@midscene/cli 1.8.7 → 1.8.8-beta-20260601092605.0
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 +3880 -0
- package/dist/es/framework/index.mjs.map +1 -0
- package/dist/es/index.mjs +1507 -2196
- package/dist/es/index.mjs.map +1 -1
- package/dist/lib/framework/index.js +3989 -0
- package/dist/lib/framework/index.js.map +1 -0
- package/dist/lib/index.js +1546 -2202
- package/dist/lib/index.js.map +1 -1
- package/dist/types/framework/index.d.ts +152 -0
- package/package.json +8 -7
package/dist/lib/index.js
CHANGED
|
@@ -262,200 +262,6 @@ 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
|
-
},
|
|
459
265
|
"../../node_modules/.pnpm/chalk@4.1.2/node_modules/chalk/source/index.js" (module, __unused_rspack_exports, __webpack_require__) {
|
|
460
266
|
"use strict";
|
|
461
267
|
const ansiStyles = __webpack_require__("../../node_modules/.pnpm/ansi-styles@4.3.0/node_modules/ansi-styles/index.js");
|
|
@@ -3007,1153 +2813,570 @@ var __webpack_modules__ = {
|
|
|
3007
2813
|
};
|
|
3008
2814
|
module.exports = (string, columns, options)=>String(string).normalize().replace(/\r\n/g, '\n').split('\n').map((line)=>exec(line, columns, options)).join('\n');
|
|
3009
2815
|
},
|
|
3010
|
-
"./src/index.ts" (__unused_rspack_module,
|
|
2816
|
+
"./src/framework/index.ts" (__unused_rspack_module, __webpack_exports__, __webpack_require__) {
|
|
3011
2817
|
"use strict";
|
|
3012
|
-
|
|
3013
|
-
|
|
3014
|
-
|
|
3015
|
-
var
|
|
3016
|
-
|
|
3017
|
-
const cli_namespaceObject = require("@midscene/shared/cli");
|
|
3018
|
-
var main = __webpack_require__("../../node_modules/.pnpm/dotenv@16.4.5/node_modules/dotenv/lib/main.js");
|
|
3019
|
-
var main_default = /*#__PURE__*/ __webpack_require__.n(main);
|
|
3020
|
-
var package_namespaceObject = {
|
|
3021
|
-
rE: "1.8.7"
|
|
3022
|
-
};
|
|
3023
|
-
const yaml_namespaceObject = require("@midscene/core/yaml");
|
|
2818
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
2819
|
+
runFrameworkTestConfig: ()=>runFrameworkTestConfig
|
|
2820
|
+
});
|
|
2821
|
+
var external_node_fs_ = __webpack_require__("node:fs");
|
|
2822
|
+
var external_node_path_ = __webpack_require__("node:path");
|
|
3024
2823
|
const common_namespaceObject = require("@midscene/shared/common");
|
|
3025
|
-
const
|
|
3026
|
-
|
|
3027
|
-
|
|
3028
|
-
|
|
3029
|
-
|
|
3030
|
-
|
|
3031
|
-
|
|
3032
|
-
|
|
3033
|
-
|
|
3034
|
-
|
|
3035
|
-
|
|
3036
|
-
|
|
3037
|
-
|
|
3038
|
-
|
|
3039
|
-
|
|
3040
|
-
|
|
3041
|
-
|
|
3042
|
-
|
|
3043
|
-
|
|
3044
|
-
|
|
3045
|
-
|
|
3046
|
-
|
|
3047
|
-
|
|
3048
|
-
|
|
3049
|
-
|
|
3050
|
-
|
|
3051
|
-
|
|
3052
|
-
|
|
3053
|
-
|
|
3054
|
-
|
|
3055
|
-
|
|
3056
|
-
|
|
3057
|
-
|
|
3058
|
-
|
|
3059
|
-
}
|
|
3060
|
-
|
|
3061
|
-
|
|
3062
|
-
|
|
3063
|
-
|
|
3064
|
-
|
|
3065
|
-
|
|
3066
|
-
|
|
3067
|
-
|
|
2824
|
+
const notExecutedError = 'Not executed (previous task failed)';
|
|
2825
|
+
function execution_summary_createNotExecutedYamlResult(file) {
|
|
2826
|
+
return {
|
|
2827
|
+
file,
|
|
2828
|
+
success: false,
|
|
2829
|
+
executed: false,
|
|
2830
|
+
output: void 0,
|
|
2831
|
+
report: void 0,
|
|
2832
|
+
duration: 0,
|
|
2833
|
+
resultType: 'notExecuted',
|
|
2834
|
+
error: notExecutedError
|
|
2835
|
+
};
|
|
2836
|
+
}
|
|
2837
|
+
function getExecutionSummary(results) {
|
|
2838
|
+
return {
|
|
2839
|
+
total: results.length,
|
|
2840
|
+
successful: getResultsByType(results, 'success').length,
|
|
2841
|
+
failed: getResultsByType(results, 'failed').length,
|
|
2842
|
+
partialFailed: getResultsByType(results, 'partialFailed').length,
|
|
2843
|
+
notExecuted: getResultsByType(results, 'notExecuted').length,
|
|
2844
|
+
totalDuration: results.reduce((sum, r)=>sum + (r.duration || 0), 0)
|
|
2845
|
+
};
|
|
2846
|
+
}
|
|
2847
|
+
function getResultsByType(results, resultType) {
|
|
2848
|
+
return results.filter((result)=>result.resultType === resultType);
|
|
2849
|
+
}
|
|
2850
|
+
function getSummaryAbsolutePath(summary) {
|
|
2851
|
+
return (0, external_node_path_.resolve)((0, common_namespaceObject.getMidsceneRunSubDir)('output'), summary);
|
|
2852
|
+
}
|
|
2853
|
+
function execution_summary_writeExecutionSummaryFile(summary, results) {
|
|
2854
|
+
const indexPath = getSummaryAbsolutePath(summary);
|
|
2855
|
+
const outputDir = (0, external_node_path_.dirname)(indexPath);
|
|
2856
|
+
(0, external_node_fs_.mkdirSync)(outputDir, {
|
|
2857
|
+
recursive: true
|
|
2858
|
+
});
|
|
2859
|
+
const executionSummary = getExecutionSummary(results);
|
|
2860
|
+
const indexData = {
|
|
2861
|
+
summary: {
|
|
2862
|
+
...executionSummary,
|
|
2863
|
+
generatedAt: new Date().toLocaleString()
|
|
2864
|
+
},
|
|
2865
|
+
results: results.map((result)=>({
|
|
2866
|
+
script: (0, external_node_path_.relative)(outputDir, result.file),
|
|
2867
|
+
success: result.success,
|
|
2868
|
+
resultType: result.resultType,
|
|
2869
|
+
output: result.output ? (()=>{
|
|
2870
|
+
const relativePath = (0, external_node_path_.relative)(outputDir, result.output);
|
|
2871
|
+
return relativePath.startsWith('.') ? relativePath : `./${relativePath}`;
|
|
2872
|
+
})() : void 0,
|
|
2873
|
+
report: result.report ? (0, external_node_path_.relative)(outputDir, result.report) : void 0,
|
|
2874
|
+
error: result.error,
|
|
2875
|
+
duration: result.duration
|
|
2876
|
+
}))
|
|
2877
|
+
};
|
|
2878
|
+
(0, external_node_fs_.writeFileSync)(indexPath, JSON.stringify(indexData, null, 2));
|
|
2879
|
+
return indexPath;
|
|
2880
|
+
}
|
|
2881
|
+
function execution_summary_printExecutionPlan(config) {
|
|
2882
|
+
console.log(' Scripts:');
|
|
2883
|
+
for (const file of config.files)console.log(` - ${file}`);
|
|
2884
|
+
console.log('📋 Execution plan');
|
|
2885
|
+
console.log(` Concurrency: ${config.concurrent}`);
|
|
2886
|
+
console.log(` Keep window: ${config.keepWindow}`);
|
|
2887
|
+
console.log(` Headed: ${config.headed}`);
|
|
2888
|
+
console.log(` Continue on error: ${config.continueOnError}`);
|
|
2889
|
+
console.log(` Share browser context: ${config.shareBrowserContext ?? false}`);
|
|
2890
|
+
console.log(` Summary output: ${config.summary}`);
|
|
2891
|
+
}
|
|
2892
|
+
function execution_summary_printExecutionFinished() {
|
|
2893
|
+
console.log('Execution finished:');
|
|
2894
|
+
}
|
|
2895
|
+
function printExecutionSummary(results, summaryPath) {
|
|
2896
|
+
const summary = getExecutionSummary(results);
|
|
2897
|
+
const successfulFiles = getResultsByType(results, 'success');
|
|
2898
|
+
const failedFiles = getResultsByType(results, 'failed');
|
|
2899
|
+
const partialFailedFiles = getResultsByType(results, 'partialFailed');
|
|
2900
|
+
const notExecutedFiles = getResultsByType(results, 'notExecuted');
|
|
2901
|
+
const success = 0 === summary.failed && 0 === summary.partialFailed && 0 === summary.notExecuted;
|
|
2902
|
+
console.log('\n📊 Execution Summary:');
|
|
2903
|
+
console.log(` Total files: ${summary.total}`);
|
|
2904
|
+
console.log(` Successful: ${summary.successful}`);
|
|
2905
|
+
console.log(` Failed: ${summary.failed}`);
|
|
2906
|
+
console.log(` Partial failed: ${summary.partialFailed}`);
|
|
2907
|
+
console.log(` Not executed: ${summary.notExecuted}`);
|
|
2908
|
+
console.log(` Duration: ${(summary.totalDuration / 1000).toFixed(2)}s`);
|
|
2909
|
+
console.log(` Summary: ${summaryPath}`);
|
|
2910
|
+
if (successfulFiles.length > 0) {
|
|
2911
|
+
console.log('\n✅ Successful files:');
|
|
2912
|
+
successfulFiles.forEach((result)=>{
|
|
2913
|
+
console.log(` ${result.file}`);
|
|
2914
|
+
});
|
|
3068
2915
|
}
|
|
3069
|
-
|
|
3070
|
-
|
|
2916
|
+
if (failedFiles.length > 0) {
|
|
2917
|
+
console.log('\n❌ Failed files');
|
|
2918
|
+
failedFiles.forEach((result)=>{
|
|
2919
|
+
console.log(` ${result.file}`);
|
|
2920
|
+
if (result.error) console.log(` Error: ${result.error}`);
|
|
2921
|
+
});
|
|
3071
2922
|
}
|
|
3072
|
-
|
|
3073
|
-
|
|
3074
|
-
|
|
3075
|
-
|
|
3076
|
-
|
|
3077
|
-
}
|
|
2923
|
+
if (partialFailedFiles.length > 0) {
|
|
2924
|
+
console.log('\n⚠️ Partial failed files (some tasks failed with continueOnError)');
|
|
2925
|
+
partialFailedFiles.forEach((result)=>{
|
|
2926
|
+
console.log(` ${result.file}`);
|
|
2927
|
+
if (result.error) console.log(` Error: ${result.error}`);
|
|
2928
|
+
});
|
|
3078
2929
|
}
|
|
3079
|
-
|
|
3080
|
-
|
|
2930
|
+
if (notExecutedFiles.length > 0) {
|
|
2931
|
+
console.log('\n⏸️ Not executed files');
|
|
2932
|
+
notExecutedFiles.forEach((result)=>{
|
|
2933
|
+
console.log(` ${result.file}`);
|
|
2934
|
+
});
|
|
3081
2935
|
}
|
|
3082
|
-
|
|
3083
|
-
|
|
3084
|
-
|
|
3085
|
-
|
|
3086
|
-
|
|
3087
|
-
|
|
3088
|
-
|
|
3089
|
-
|
|
3090
|
-
|
|
3091
|
-
|
|
3092
|
-
}
|
|
3093
|
-
|
|
3094
|
-
|
|
3095
|
-
|
|
3096
|
-
|
|
3097
|
-
|
|
3098
|
-
|
|
3099
|
-
|
|
3100
|
-
|
|
3101
|
-
|
|
3102
|
-
|
|
3103
|
-
|
|
2936
|
+
if (success) console.log('\n🎉 All files executed successfully!');
|
|
2937
|
+
else console.log('\n⚠️ Some files failed or were not executed.');
|
|
2938
|
+
return success;
|
|
2939
|
+
}
|
|
2940
|
+
const DEFAULT_YAML_TEST_TIMEOUT = 0;
|
|
2941
|
+
const toPosixPath = (value)=>value.split(external_node_path_.sep).join('/');
|
|
2942
|
+
const toImportLiteral = (value)=>JSON.stringify(toPosixPath(value));
|
|
2943
|
+
const toVirtualModuleId = (fileStem)=>`virtual:midscene-yaml/${fileStem}.test.ts`;
|
|
2944
|
+
const safeFileStem = (file, index)=>{
|
|
2945
|
+
const base = (0, external_node_path_.basename)(file, (0, external_node_path_.extname)(file)).replace(/[^a-zA-Z0-9._-]+/g, '-').replace(/^-+|-+$/g, '');
|
|
2946
|
+
return `${String(index + 1).padStart(3, '0')}-${base || 'case'}`;
|
|
2947
|
+
};
|
|
2948
|
+
const resolveTestName = (projectDir, yamlFile)=>{
|
|
2949
|
+
const relativePath = (0, external_node_path_.relative)(projectDir, yamlFile);
|
|
2950
|
+
return toPosixPath(relativePath.startsWith('..') ? yamlFile : relativePath);
|
|
2951
|
+
};
|
|
2952
|
+
const createGeneratedTestContent = (options)=>{
|
|
2953
|
+
const testOptions = {
|
|
2954
|
+
testName: options.testName,
|
|
2955
|
+
yamlFile: options.yamlFile,
|
|
2956
|
+
resultFile: options.resultFile,
|
|
2957
|
+
...options.caseOptions ? {
|
|
2958
|
+
caseOptions: options.caseOptions
|
|
2959
|
+
} : {},
|
|
2960
|
+
...options.webRuntimeOptions ? {
|
|
2961
|
+
webRuntimeOptions: options.webRuntimeOptions
|
|
2962
|
+
} : {}
|
|
3104
2963
|
};
|
|
3105
|
-
|
|
3106
|
-
|
|
3107
|
-
|
|
3108
|
-
|
|
3109
|
-
|
|
3110
|
-
|
|
3111
|
-
|
|
3112
|
-
|
|
2964
|
+
return `import { defineYamlCaseTest } from ${toImportLiteral(options.frameworkImport)};
|
|
2965
|
+
|
|
2966
|
+
defineYamlCaseTest(${JSON.stringify(testOptions, null, 2)});
|
|
2967
|
+
`;
|
|
2968
|
+
};
|
|
2969
|
+
const createGeneratedBatchTestContent = (options)=>{
|
|
2970
|
+
const testOptions = {
|
|
2971
|
+
testName: options.testName,
|
|
2972
|
+
config: options.config,
|
|
2973
|
+
resultFiles: options.resultFiles
|
|
3113
2974
|
};
|
|
3114
|
-
|
|
3115
|
-
|
|
3116
|
-
|
|
3117
|
-
|
|
3118
|
-
|
|
3119
|
-
|
|
3120
|
-
|
|
3121
|
-
|
|
3122
|
-
|
|
3123
|
-
|
|
3124
|
-
|
|
3125
|
-
|
|
3126
|
-
|
|
3127
|
-
|
|
3128
|
-
|
|
3129
|
-
|
|
3130
|
-
|
|
3131
|
-
|
|
3132
|
-
|
|
3133
|
-
|
|
3134
|
-
|
|
3135
|
-
|
|
3136
|
-
|
|
3137
|
-
}
|
|
3138
|
-
}
|
|
2975
|
+
return `import { defineYamlBatchTest } from ${toImportLiteral(options.frameworkImport)};
|
|
2976
|
+
|
|
2977
|
+
defineYamlBatchTest(${JSON.stringify(testOptions, null, 2)});
|
|
2978
|
+
`;
|
|
2979
|
+
};
|
|
2980
|
+
const resolveDefaultFrameworkImport = ()=>{
|
|
2981
|
+
const entry = process.argv[1] ? (0, external_node_path_.resolve)(process.argv[1]) : '';
|
|
2982
|
+
const candidates = [
|
|
2983
|
+
entry ? (0, external_node_path_.join)((0, external_node_path_.dirname)(entry), 'framework', 'index.js') : '',
|
|
2984
|
+
entry ? (0, external_node_path_.join)((0, external_node_path_.dirname)(entry), '..', 'dist', 'lib', 'framework', 'index.js') : ''
|
|
2985
|
+
].filter(Boolean);
|
|
2986
|
+
const matched = candidates.find((candidate)=>(0, external_node_fs_.existsSync)(candidate));
|
|
2987
|
+
return matched || '@midscene/cli/dist/lib/framework/index.js';
|
|
2988
|
+
};
|
|
2989
|
+
function createRstestYamlProject(options) {
|
|
2990
|
+
const projectDir = (0, external_node_path_.resolve)(options.projectDir || process.cwd());
|
|
2991
|
+
const outputDir = options.outputDir || (0, external_node_path_.join)((0, common_namespaceObject.getMidsceneRunSubDir)('tmp'), `rstest-yaml-${Date.now()}`);
|
|
2992
|
+
const resultDir = options.resultDir || (0, external_node_path_.join)(outputDir, 'results');
|
|
2993
|
+
const frameworkImport = options.frameworkImport || resolveDefaultFrameworkImport();
|
|
2994
|
+
const testTimeout = options.testTimeout ?? DEFAULT_YAML_TEST_TIMEOUT;
|
|
2995
|
+
(0, external_node_fs_.rmSync)(outputDir, {
|
|
2996
|
+
recursive: true,
|
|
2997
|
+
force: true
|
|
3139
2998
|
});
|
|
3140
|
-
|
|
3141
|
-
|
|
3142
|
-
|
|
3143
|
-
|
|
3144
|
-
|
|
3145
|
-
|
|
3146
|
-
|
|
3147
|
-
|
|
3148
|
-
|
|
3149
|
-
|
|
3150
|
-
|
|
3151
|
-
|
|
3152
|
-
|
|
3153
|
-
|
|
3154
|
-
|
|
3155
|
-
|
|
3156
|
-
|
|
3157
|
-
root: dir
|
|
3158
|
-
});
|
|
3159
|
-
server.listen(0, '127.0.0.1', ()=>{
|
|
3160
|
-
resolve(server);
|
|
2999
|
+
(0, external_node_fs_.mkdirSync)(resultDir, {
|
|
3000
|
+
recursive: true
|
|
3001
|
+
});
|
|
3002
|
+
const virtualModules = {};
|
|
3003
|
+
const cases = options.files.map((file, index)=>{
|
|
3004
|
+
const yamlFile = (0, external_node_path_.resolve)(file);
|
|
3005
|
+
const testName = resolveTestName(projectDir, yamlFile);
|
|
3006
|
+
const fileStem = safeFileStem(yamlFile, index);
|
|
3007
|
+
const resultFile = (0, external_node_path_.join)(resultDir, `${fileStem}.json`);
|
|
3008
|
+
const testModule = toVirtualModuleId(fileStem);
|
|
3009
|
+
virtualModules[testModule] = createGeneratedTestContent({
|
|
3010
|
+
frameworkImport,
|
|
3011
|
+
yamlFile,
|
|
3012
|
+
resultFile,
|
|
3013
|
+
testName,
|
|
3014
|
+
caseOptions: options.caseOptions?.[yamlFile],
|
|
3015
|
+
webRuntimeOptions: options.webRuntimeOptions?.[yamlFile]
|
|
3161
3016
|
});
|
|
3017
|
+
return {
|
|
3018
|
+
yamlFile,
|
|
3019
|
+
testModule,
|
|
3020
|
+
resultFile,
|
|
3021
|
+
testName
|
|
3022
|
+
};
|
|
3162
3023
|
});
|
|
3163
|
-
|
|
3164
|
-
|
|
3165
|
-
|
|
3166
|
-
|
|
3167
|
-
|
|
3024
|
+
if (options.batchConfig) {
|
|
3025
|
+
const batchModule = 'virtual:midscene-yaml/batch.test.ts';
|
|
3026
|
+
const resultFiles = Object.fromEntries(cases.map((item)=>[
|
|
3027
|
+
item.yamlFile,
|
|
3028
|
+
item.resultFile
|
|
3029
|
+
]));
|
|
3030
|
+
return {
|
|
3031
|
+
projectDir,
|
|
3032
|
+
outputDir,
|
|
3033
|
+
resultDir,
|
|
3034
|
+
include: [
|
|
3035
|
+
batchModule
|
|
3036
|
+
],
|
|
3037
|
+
virtualModules: {
|
|
3038
|
+
[batchModule]: createGeneratedBatchTestContent({
|
|
3039
|
+
frameworkImport,
|
|
3040
|
+
testName: 'midscene yaml batch',
|
|
3041
|
+
config: options.batchConfig,
|
|
3042
|
+
resultFiles
|
|
3043
|
+
})
|
|
3044
|
+
},
|
|
3045
|
+
cases,
|
|
3046
|
+
maxConcurrency: 1,
|
|
3047
|
+
testTimeout,
|
|
3048
|
+
bail: options.bail
|
|
3049
|
+
};
|
|
3050
|
+
}
|
|
3168
3051
|
return {
|
|
3169
|
-
|
|
3170
|
-
|
|
3171
|
-
|
|
3052
|
+
projectDir,
|
|
3053
|
+
outputDir,
|
|
3054
|
+
resultDir,
|
|
3055
|
+
include: cases.map((item)=>item.testModule),
|
|
3056
|
+
virtualModules,
|
|
3057
|
+
cases,
|
|
3058
|
+
maxConcurrency: options.maxConcurrency,
|
|
3059
|
+
testTimeout,
|
|
3060
|
+
bail: options.bail
|
|
3172
3061
|
};
|
|
3173
3062
|
}
|
|
3174
|
-
|
|
3175
|
-
|
|
3176
|
-
|
|
3177
|
-
const
|
|
3178
|
-
|
|
3179
|
-
|
|
3180
|
-
|
|
3181
|
-
|
|
3182
|
-
|
|
3183
|
-
|
|
3184
|
-
|
|
3185
|
-
|
|
3186
|
-
|
|
3187
|
-
|
|
3188
|
-
|
|
3189
|
-
|
|
3190
|
-
|
|
3191
|
-
|
|
3192
|
-
|
|
3193
|
-
|
|
3194
|
-
|
|
3195
|
-
|
|
3196
|
-
|
|
3197
|
-
|
|
3198
|
-
|
|
3199
|
-
|
|
3200
|
-
|
|
3201
|
-
|
|
3202
|
-
|
|
3203
|
-
|
|
3204
|
-
|
|
3205
|
-
|
|
3206
|
-
|
|
3207
|
-
|
|
3208
|
-
|
|
3209
|
-
|
|
3210
|
-
|
|
3211
|
-
|
|
3212
|
-
|
|
3213
|
-
|
|
3214
|
-
});
|
|
3215
|
-
urlToVisit = webTarget.url.startsWith('/') ? `http://${serverAddress?.address}:${serverAddress?.port}${webTarget.url}` : `http://${serverAddress?.address}:${serverAddress?.port}/${webTarget.url}`;
|
|
3216
|
-
webTarget.url = urlToVisit;
|
|
3217
|
-
}
|
|
3218
|
-
if (webTarget.cdpEndpoint && webTarget.bridgeMode) throw new Error('cdpEndpoint and bridgeMode are mutually exclusive. Please specify only one.');
|
|
3219
|
-
if (webTarget.cdpEndpoint) {
|
|
3220
|
-
const cdpBrowser = options?.browser ?? await external_puppeteer_default().connect({
|
|
3221
|
-
browserWSEndpoint: webTarget.cdpEndpoint,
|
|
3222
|
-
defaultViewport: null
|
|
3223
|
-
});
|
|
3224
|
-
if (webTarget.chromeArgs) console.warn('chromeArgs are not supported in CDP mode (browser is already running). They will be ignored.');
|
|
3225
|
-
const { agent, freeFn: newFreeFn } = await (0, puppeteer_agent_launcher_namespaceObject.puppeteerAgentForTarget)(webTarget, {
|
|
3226
|
-
...preference,
|
|
3227
|
-
...buildAgentOptions(clonedYamlScript.agent, preference.reportFileName, fileName)
|
|
3228
|
-
}, cdpBrowser, options?.page);
|
|
3229
|
-
const cleanFreeFn = newFreeFn.filter((f)=>'puppeteer_browser' !== f.name);
|
|
3230
|
-
if (!options?.browser) cleanFreeFn.push({
|
|
3231
|
-
name: 'cdp_browser_disconnect',
|
|
3232
|
-
fn: ()=>cdpBrowser.disconnect()
|
|
3233
|
-
});
|
|
3234
|
-
freeFn.push(...cleanFreeFn);
|
|
3235
|
-
return {
|
|
3236
|
-
agent,
|
|
3237
|
-
freeFn
|
|
3238
|
-
};
|
|
3239
|
-
}
|
|
3240
|
-
if (!webTarget.bridgeMode) {
|
|
3241
|
-
const { agent, freeFn: newFreeFn } = await (0, puppeteer_agent_launcher_namespaceObject.puppeteerAgentForTarget)(webTarget, {
|
|
3242
|
-
...preference,
|
|
3243
|
-
...buildAgentOptions(clonedYamlScript.agent, preference.reportFileName, fileName)
|
|
3244
|
-
}, options?.browser, options?.page);
|
|
3245
|
-
freeFn.push(...newFreeFn);
|
|
3246
|
-
return {
|
|
3247
|
-
agent,
|
|
3248
|
-
freeFn
|
|
3249
|
-
};
|
|
3250
|
-
}
|
|
3251
|
-
external_node_assert_default()('newTabWithUrl' === webTarget.bridgeMode || 'currentTab' === webTarget.bridgeMode, `bridgeMode config value must be either "newTabWithUrl" or "currentTab", but got ${webTarget.bridgeMode}`);
|
|
3252
|
-
if (webTarget.userAgent || null != webTarget.viewportWidth || null != webTarget.viewportHeight || null != webTarget.deviceScaleFactor || webTarget.waitForNetworkIdle || webTarget.cookie || webTarget.chromeArgs) console.warn('puppeteer options (userAgent, viewportWidth, viewportHeight, deviceScaleFactor, waitForNetworkIdle, cookie, chromeArgs) are not supported in bridge mode. They will be ignored.');
|
|
3253
|
-
const agent = new bridge_mode_namespaceObject.AgentOverChromeBridge({
|
|
3254
|
-
closeNewTabsAfterDisconnect: webTarget.closeNewTabsAfterDisconnect,
|
|
3255
|
-
closeConflictServer: true,
|
|
3256
|
-
...buildAgentOptions(clonedYamlScript.agent, preference.reportFileName, fileName)
|
|
3257
|
-
});
|
|
3258
|
-
if ('newTabWithUrl' === webTarget.bridgeMode) await agent.connectNewTabWithUrl(webTarget.url);
|
|
3259
|
-
else {
|
|
3260
|
-
if (webTarget.url) console.warn('url will be ignored in bridge mode with "currentTab"');
|
|
3261
|
-
await agent.connectCurrentTab();
|
|
3063
|
+
const external_node_module_namespaceObject = require("node:module");
|
|
3064
|
+
var external_node_url_ = __webpack_require__("node:url");
|
|
3065
|
+
const requireFromCliEntry = ()=>{
|
|
3066
|
+
const entry = process.argv[1] ? (0, external_node_path_.resolve)(process.argv[1]) : (0, external_node_path_.join)(process.cwd(), 'midscene-cli.js');
|
|
3067
|
+
return (0, external_node_module_namespaceObject.createRequire)(entry);
|
|
3068
|
+
};
|
|
3069
|
+
const resolvePackageFromRstestCore = (packageName)=>{
|
|
3070
|
+
const require1 = requireFromCliEntry();
|
|
3071
|
+
const rstestPackageJsonPath = require1.resolve('@rstest/core/package.json');
|
|
3072
|
+
return (0, external_node_module_namespaceObject.createRequire)(rstestPackageJsonPath).resolve(packageName);
|
|
3073
|
+
};
|
|
3074
|
+
const formatRunError = (error)=>error.stack || `${error.name}: ${error.message}`;
|
|
3075
|
+
async function runRstestYamlProject(options) {
|
|
3076
|
+
const [{ runRstest }, { rspack }] = await Promise.all([
|
|
3077
|
+
import("@rstest/core/api"),
|
|
3078
|
+
import((0, external_node_url_.pathToFileURL)(resolvePackageFromRstestCore('@rsbuild/core')).href)
|
|
3079
|
+
]);
|
|
3080
|
+
const { project } = options;
|
|
3081
|
+
const maxConcurrency = void 0 !== project.maxConcurrency ? Math.max(1, project.maxConcurrency) : void 0;
|
|
3082
|
+
const inlineConfig = {
|
|
3083
|
+
root: project.projectDir,
|
|
3084
|
+
include: project.include,
|
|
3085
|
+
testEnvironment: 'node',
|
|
3086
|
+
testTimeout: project.testTimeout,
|
|
3087
|
+
...void 0 !== maxConcurrency ? {
|
|
3088
|
+
maxConcurrency
|
|
3089
|
+
} : {},
|
|
3090
|
+
...void 0 !== maxConcurrency ? {
|
|
3091
|
+
pool: {
|
|
3092
|
+
maxWorkers: maxConcurrency,
|
|
3093
|
+
minWorkers: maxConcurrency
|
|
3094
|
+
}
|
|
3095
|
+
} : {},
|
|
3096
|
+
...void 0 !== project.bail ? {
|
|
3097
|
+
bail: project.bail
|
|
3098
|
+
} : {},
|
|
3099
|
+
reporters: [],
|
|
3100
|
+
tools: {
|
|
3101
|
+
rspack: (_config, { appendPlugins })=>{
|
|
3102
|
+
appendPlugins(new rspack.experiments.VirtualModulesPlugin(project.virtualModules));
|
|
3262
3103
|
}
|
|
3263
|
-
freeFn.push({
|
|
3264
|
-
name: 'destroy_agent_over_chrome_bridge',
|
|
3265
|
-
fn: ()=>agent.destroy()
|
|
3266
|
-
});
|
|
3267
|
-
return {
|
|
3268
|
-
agent,
|
|
3269
|
-
freeFn
|
|
3270
|
-
};
|
|
3271
|
-
}
|
|
3272
|
-
if (void 0 !== clonedYamlScript.android) {
|
|
3273
|
-
const androidTarget = clonedYamlScript.android;
|
|
3274
|
-
const { agentFromAdbDevice } = await import("@midscene/android");
|
|
3275
|
-
const agent = await agentFromAdbDevice(androidTarget?.deviceId, {
|
|
3276
|
-
...androidTarget,
|
|
3277
|
-
...buildAgentOptions(clonedYamlScript.agent, preference.reportFileName, fileName)
|
|
3278
|
-
});
|
|
3279
|
-
if (androidTarget?.launch) await agent.launch(androidTarget.launch);
|
|
3280
|
-
freeFn.push({
|
|
3281
|
-
name: 'destroy_android_agent',
|
|
3282
|
-
fn: ()=>agent.destroy()
|
|
3283
|
-
});
|
|
3284
|
-
return {
|
|
3285
|
-
agent,
|
|
3286
|
-
freeFn
|
|
3287
|
-
};
|
|
3288
|
-
}
|
|
3289
|
-
if (void 0 !== clonedYamlScript.ios) {
|
|
3290
|
-
const iosTarget = clonedYamlScript.ios;
|
|
3291
|
-
const { agentFromWebDriverAgent } = await import("@midscene/ios");
|
|
3292
|
-
const agent = await agentFromWebDriverAgent({
|
|
3293
|
-
...iosTarget,
|
|
3294
|
-
...buildAgentOptions(clonedYamlScript.agent, preference.reportFileName, fileName)
|
|
3295
|
-
});
|
|
3296
|
-
if (iosTarget?.launch) await agent.launch(iosTarget.launch);
|
|
3297
|
-
freeFn.push({
|
|
3298
|
-
name: 'destroy_ios_agent',
|
|
3299
|
-
fn: ()=>agent.destroy()
|
|
3300
|
-
});
|
|
3301
|
-
return {
|
|
3302
|
-
agent,
|
|
3303
|
-
freeFn
|
|
3304
|
-
};
|
|
3305
|
-
}
|
|
3306
|
-
if (void 0 !== clonedYamlScript.computer) {
|
|
3307
|
-
const computerTarget = clonedYamlScript.computer;
|
|
3308
|
-
const { agentForComputer } = await import("@midscene/computer");
|
|
3309
|
-
const agent = await agentForComputer({
|
|
3310
|
-
...computerTarget,
|
|
3311
|
-
...buildAgentOptions(clonedYamlScript.agent, preference.reportFileName, fileName)
|
|
3312
|
-
});
|
|
3313
|
-
freeFn.push({
|
|
3314
|
-
name: 'destroy_computer_agent',
|
|
3315
|
-
fn: ()=>agent.destroy()
|
|
3316
|
-
});
|
|
3317
|
-
return {
|
|
3318
|
-
agent,
|
|
3319
|
-
freeFn
|
|
3320
|
-
};
|
|
3321
3104
|
}
|
|
3322
|
-
if (void 0 !== clonedYamlScript.interface) {
|
|
3323
|
-
const interfaceTarget = clonedYamlScript.interface;
|
|
3324
|
-
const moduleSpecifier = interfaceTarget.module;
|
|
3325
|
-
let finalModuleSpecifier;
|
|
3326
|
-
if (moduleSpecifier.startsWith('./') || moduleSpecifier.startsWith('../') || external_node_path_default().isAbsolute(moduleSpecifier)) {
|
|
3327
|
-
const resolvedPath = (0, external_node_path_namespaceObject.join)(process.cwd(), moduleSpecifier);
|
|
3328
|
-
finalModuleSpecifier = resolvedPath;
|
|
3329
|
-
} else finalModuleSpecifier = moduleSpecifier;
|
|
3330
|
-
debug('importing module config', interfaceTarget.module, 'with export config', interfaceTarget.export, 'final module specifier', finalModuleSpecifier);
|
|
3331
|
-
const importedModule = await import(finalModuleSpecifier);
|
|
3332
|
-
const DeviceClass = interfaceTarget.export ? importedModule[interfaceTarget.export] : importedModule.default || importedModule;
|
|
3333
|
-
debug('DeviceClass', DeviceClass, 'with param', interfaceTarget.param);
|
|
3334
|
-
const device = new DeviceClass(interfaceTarget.param || {});
|
|
3335
|
-
debug('creating agent from device', device);
|
|
3336
|
-
const agent = (0, agent_namespaceObject.createAgent)(device, buildAgentOptions(clonedYamlScript.agent, preference.reportFileName, fileName));
|
|
3337
|
-
freeFn.push({
|
|
3338
|
-
name: 'destroy_general_interface_agent',
|
|
3339
|
-
fn: ()=>{
|
|
3340
|
-
agent.destroy();
|
|
3341
|
-
}
|
|
3342
|
-
});
|
|
3343
|
-
return {
|
|
3344
|
-
agent,
|
|
3345
|
-
freeFn
|
|
3346
|
-
};
|
|
3347
|
-
}
|
|
3348
|
-
throw new Error('No valid interface configuration found in the yaml script, should be either "web", "android", "ios", "computer", or "interface"');
|
|
3349
|
-
}, void 0, file);
|
|
3350
|
-
return player;
|
|
3351
|
-
}
|
|
3352
|
-
var chalk_source = __webpack_require__("../../node_modules/.pnpm/chalk@4.1.2/node_modules/chalk/source/index.js");
|
|
3353
|
-
var source_default = /*#__PURE__*/ __webpack_require__.n(chalk_source);
|
|
3354
|
-
const isTTY = process.env.MIDSCENE_CLI_LOG_ON_NON_TTY ? false : process.stdout.isTTY;
|
|
3355
|
-
const printer_indent = ' ';
|
|
3356
|
-
const spinnerInterval = 80;
|
|
3357
|
-
const spinnerFrames = [
|
|
3358
|
-
'◰',
|
|
3359
|
-
'◳',
|
|
3360
|
-
'◲',
|
|
3361
|
-
'◱'
|
|
3362
|
-
];
|
|
3363
|
-
const currentSpinningFrame = ()=>spinnerFrames[Math.floor(Date.now() / spinnerInterval) % spinnerFrames.length];
|
|
3364
|
-
function indicatorForStatus(status) {
|
|
3365
|
-
if ('init' === status) return source_default().gray('◌');
|
|
3366
|
-
if ('running' === status) return source_default().yellowBright(currentSpinningFrame());
|
|
3367
|
-
if ('done' === status) return source_default().green('✔︎');
|
|
3368
|
-
if ('error' === status) return source_default().red('✘');
|
|
3369
|
-
}
|
|
3370
|
-
const contextInfo = (context)=>{
|
|
3371
|
-
const filePath = context.file;
|
|
3372
|
-
const filePathToShow = (0, external_node_path_namespaceObject.relative)(process.cwd(), filePath);
|
|
3373
|
-
const fileNameToPrint = `${source_default().gray(`${filePathToShow}`)}`;
|
|
3374
|
-
const fileStatusText = indicatorForStatus(context.player.status);
|
|
3375
|
-
const contextActionText = void 0 === context.player.currentTaskIndex && 'running' === context.player.status ? source_default().gray('(navigating)') : '';
|
|
3376
|
-
const errorText = context.player.errorInSetup ? `\n${printer_indent}${source_default().red('error:')} ${context.player.errorInSetup?.message}\n${printer_indent}${printer_indent}${context.player.errorInSetup?.stack}` : '';
|
|
3377
|
-
const outputFile = context.player.output;
|
|
3378
|
-
const outputText = outputFile && Object.keys(context.player.result || {}).length > 0 ? `\n${printer_indent}${source_default().gray(`output: ${outputFile}`)}` : '';
|
|
3379
|
-
const reportFile = context.player.reportFile;
|
|
3380
|
-
const reportText = reportFile ? `\n${printer_indent}${source_default().gray(`report: ${reportFile}`)}` : '';
|
|
3381
|
-
const agentStatusTip = context.player.agentStatusTip;
|
|
3382
|
-
const agentStatusText = agentStatusTip ? `\n${printer_indent}${source_default().gray(`agent status: ${agentStatusTip}`)}` : '';
|
|
3383
|
-
const mergedText = `${fileStatusText} ${fileNameToPrint} ${contextActionText}${outputText}${reportText}${errorText}${agentStatusText}`.trim();
|
|
3384
|
-
return {
|
|
3385
|
-
fileNameToPrint,
|
|
3386
|
-
fileStatusText,
|
|
3387
|
-
contextActionText,
|
|
3388
|
-
outputText,
|
|
3389
|
-
reportText,
|
|
3390
|
-
mergedText
|
|
3391
3105
|
};
|
|
3392
|
-
|
|
3393
|
-
|
|
3394
|
-
|
|
3395
|
-
|
|
3396
|
-
|
|
3397
|
-
|
|
3398
|
-
|
|
3399
|
-
|
|
3400
|
-
|
|
3401
|
-
const
|
|
3402
|
-
|
|
3403
|
-
const mergedLine = `${statusText} ${task.name} ${stepText}${errorText}`;
|
|
3404
|
-
return {
|
|
3405
|
-
nameText: task.name,
|
|
3406
|
-
stepText,
|
|
3407
|
-
errorText,
|
|
3408
|
-
itemStatusText: statusText,
|
|
3409
|
-
mergedLine
|
|
3106
|
+
const result = await runRstest({
|
|
3107
|
+
cwd: options.cwd || project.projectDir,
|
|
3108
|
+
inlineConfig
|
|
3109
|
+
});
|
|
3110
|
+
if (!result.ok && 'pipe' !== options.stdio && result.unhandledErrors.length) console.error(result.unhandledErrors.map((error)=>formatRunError(error)).join('\n'));
|
|
3111
|
+
return result.ok ? 0 : 1;
|
|
3112
|
+
}
|
|
3113
|
+
const createCaseOptions = (config)=>{
|
|
3114
|
+
const caseOptions = {};
|
|
3115
|
+
for (const file of config.files)caseOptions[(0, external_node_path_.resolve)(file)] = {
|
|
3116
|
+
globalConfig: config.globalConfig
|
|
3410
3117
|
};
|
|
3118
|
+
return caseOptions;
|
|
3411
3119
|
};
|
|
3412
|
-
|
|
3413
|
-
|
|
3414
|
-
|
|
3415
|
-
|
|
3416
|
-
|
|
3417
|
-
|
|
3418
|
-
|
|
3419
|
-
const { mergedText: fileInfo } = contextInfo(context);
|
|
3420
|
-
if (!context.player.errorInSetup) for (const task of taskStatusArray){
|
|
3421
|
-
const { mergedLine } = singleTaskInfo(task);
|
|
3422
|
-
if ('init' === context.player.status) suffixText.push(mergedLine);
|
|
3423
|
-
else if ('running' === context.player.status) currentLine.push(mergedLine);
|
|
3424
|
-
else if ('done' === context.player.status) prefixLines.push(mergedLine);
|
|
3425
|
-
else if ('error' === context.player.status) prefixLines.push(mergedLine);
|
|
3426
|
-
}
|
|
3427
|
-
const lines = [
|
|
3428
|
-
fileInfo
|
|
3429
|
-
];
|
|
3430
|
-
if (prefixLines.length > 0) lines.push(...paddingLines(prefixLines));
|
|
3431
|
-
if (currentLine.length > 0) lines.push(...paddingLines(currentLine));
|
|
3432
|
-
if (suffixText.length > 0) lines.push(...paddingLines(suffixText));
|
|
3433
|
-
return lines.join('\n');
|
|
3434
|
-
};
|
|
3435
|
-
const external_node_util_namespaceObject = require("node:util");
|
|
3436
|
-
const external_node_process_namespaceObject = require("node:process");
|
|
3437
|
-
const copyProperty = (to, from, property, ignoreNonConfigurable)=>{
|
|
3438
|
-
if ('length' === property || 'prototype' === property) return;
|
|
3439
|
-
if ('arguments' === property || 'caller' === property) return;
|
|
3440
|
-
const toDescriptor = Object.getOwnPropertyDescriptor(to, property);
|
|
3441
|
-
const fromDescriptor = Object.getOwnPropertyDescriptor(from, property);
|
|
3442
|
-
if (!canCopyProperty(toDescriptor, fromDescriptor) && ignoreNonConfigurable) return;
|
|
3443
|
-
Object.defineProperty(to, property, fromDescriptor);
|
|
3444
|
-
};
|
|
3445
|
-
const canCopyProperty = function(toDescriptor, fromDescriptor) {
|
|
3446
|
-
return void 0 === toDescriptor || toDescriptor.configurable || toDescriptor.writable === fromDescriptor.writable && toDescriptor.enumerable === fromDescriptor.enumerable && toDescriptor.configurable === fromDescriptor.configurable && (toDescriptor.writable || toDescriptor.value === fromDescriptor.value);
|
|
3447
|
-
};
|
|
3448
|
-
const changePrototype = (to, from)=>{
|
|
3449
|
-
const fromPrototype = Object.getPrototypeOf(from);
|
|
3450
|
-
if (fromPrototype === Object.getPrototypeOf(to)) return;
|
|
3451
|
-
Object.setPrototypeOf(to, fromPrototype);
|
|
3120
|
+
const createWebRuntimeOptions = (config, runtimeOptions)=>{
|
|
3121
|
+
const caseOptions = {};
|
|
3122
|
+
for (const file of config.files)caseOptions[(0, external_node_path_.resolve)(file)] = {
|
|
3123
|
+
headed: runtimeOptions.headed ?? config.headed,
|
|
3124
|
+
keepWindow: runtimeOptions.keepWindow ?? config.keepWindow
|
|
3125
|
+
};
|
|
3126
|
+
return caseOptions;
|
|
3452
3127
|
};
|
|
3453
|
-
const
|
|
3454
|
-
|
|
3455
|
-
|
|
3456
|
-
const changeToString = (to, from, name)=>{
|
|
3457
|
-
const withName = '' === name ? '' : `with ${name.trim()}() `;
|
|
3458
|
-
const newToString = wrappedToString.bind(null, withName, from.toString());
|
|
3459
|
-
Object.defineProperty(newToString, 'name', toStringName);
|
|
3460
|
-
const { writable, enumerable, configurable } = toStringDescriptor;
|
|
3461
|
-
Object.defineProperty(to, 'toString', {
|
|
3462
|
-
value: newToString,
|
|
3463
|
-
writable,
|
|
3464
|
-
enumerable,
|
|
3465
|
-
configurable
|
|
3128
|
+
const readProjectResults = (project)=>project.cases.map((item)=>{
|
|
3129
|
+
if ((0, external_node_fs_.existsSync)(item.resultFile)) return JSON.parse((0, external_node_fs_.readFileSync)(item.resultFile, 'utf8'));
|
|
3130
|
+
return execution_summary_createNotExecutedYamlResult(item.yamlFile);
|
|
3466
3131
|
});
|
|
3467
|
-
}
|
|
3468
|
-
|
|
3469
|
-
const
|
|
3470
|
-
|
|
3471
|
-
|
|
3472
|
-
|
|
3473
|
-
|
|
3474
|
-
|
|
3475
|
-
|
|
3476
|
-
|
|
3477
|
-
|
|
3478
|
-
|
|
3479
|
-
|
|
3480
|
-
|
|
3481
|
-
const
|
|
3482
|
-
|
|
3483
|
-
|
|
3484
|
-
|
|
3485
|
-
|
|
3486
|
-
|
|
3487
|
-
|
|
3132
|
+
async function runFrameworkTestConfig(config, commandOptions = {}) {
|
|
3133
|
+
execution_summary_printExecutionPlan(config);
|
|
3134
|
+
const projectDir = (0, external_node_path_.resolve)(commandOptions.projectDir || process.cwd());
|
|
3135
|
+
const project = createRstestYamlProject({
|
|
3136
|
+
files: config.files,
|
|
3137
|
+
projectDir,
|
|
3138
|
+
outputDir: commandOptions.outputDir,
|
|
3139
|
+
frameworkImport: commandOptions.frameworkImport,
|
|
3140
|
+
caseOptions: createCaseOptions(config),
|
|
3141
|
+
webRuntimeOptions: createWebRuntimeOptions(config, commandOptions),
|
|
3142
|
+
maxConcurrency: commandOptions.concurrent ?? config.concurrent,
|
|
3143
|
+
bail: config.continueOnError ? 0 : 1,
|
|
3144
|
+
batchConfig: config.shareBrowserContext ? config : void 0
|
|
3145
|
+
});
|
|
3146
|
+
const runner = commandOptions.rstestRunner || runRstestYamlProject;
|
|
3147
|
+
const exitCode = await runner({
|
|
3148
|
+
project,
|
|
3149
|
+
cwd: projectDir,
|
|
3150
|
+
stdio: commandOptions.stdio
|
|
3151
|
+
});
|
|
3152
|
+
const results = readProjectResults(project);
|
|
3153
|
+
const summaryPath = execution_summary_writeExecutionSummaryFile(config.summary, results);
|
|
3154
|
+
execution_summary_printExecutionFinished();
|
|
3155
|
+
const success = printExecutionSummary(results, summaryPath);
|
|
3156
|
+
return success ? exitCode : 1;
|
|
3157
|
+
}
|
|
3158
|
+
require("@rstest/core");
|
|
3159
|
+
__webpack_require__("@midscene/core/yaml");
|
|
3160
|
+
require("@midscene/web/puppeteer-agent-launcher");
|
|
3161
|
+
__webpack_require__("lodash.merge");
|
|
3162
|
+
require("puppeteer");
|
|
3163
|
+
require("http-server");
|
|
3164
|
+
require("node:assert");
|
|
3165
|
+
require("@midscene/core/agent");
|
|
3166
|
+
require("@midscene/core/utils");
|
|
3167
|
+
var logger_ = __webpack_require__("@midscene/shared/logger");
|
|
3168
|
+
require("@midscene/web/bridge-mode");
|
|
3169
|
+
(0, logger_.getDebug)('create-yaml-player');
|
|
3170
|
+
__webpack_require__("../../node_modules/.pnpm/chalk@4.1.2/node_modules/chalk/source/index.js");
|
|
3171
|
+
process.env.MIDSCENE_CLI_LOG_ON_NON_TTY || process.stdout.isTTY;
|
|
3172
|
+
require("node:util");
|
|
3173
|
+
},
|
|
3174
|
+
"./src/index.ts" (__unused_rspack_module, __unused_rspack___webpack_exports__, __webpack_require__) {
|
|
3175
|
+
"use strict";
|
|
3176
|
+
var external_node_fs_ = __webpack_require__("node:fs");
|
|
3177
|
+
var external_node_fs_namespaceObject = /*#__PURE__*/ __webpack_require__.t(external_node_fs_, 2);
|
|
3178
|
+
var external_node_path_ = __webpack_require__("node:path");
|
|
3179
|
+
const core_namespaceObject = require("@midscene/core");
|
|
3180
|
+
const cli_namespaceObject = require("@midscene/shared/cli");
|
|
3181
|
+
var main = __webpack_require__("../../node_modules/.pnpm/dotenv@16.4.5/node_modules/dotenv/lib/main.js");
|
|
3182
|
+
var main_default = /*#__PURE__*/ __webpack_require__.n(main);
|
|
3183
|
+
var package_namespaceObject = JSON.parse('{"rE":"1.8.8-beta-20260601092605.0"}');
|
|
3184
|
+
var logger_ = __webpack_require__("@midscene/shared/logger");
|
|
3185
|
+
const balanced = (a, b, str)=>{
|
|
3186
|
+
const ma = a instanceof RegExp ? maybeMatch(a, str) : a;
|
|
3187
|
+
const mb = b instanceof RegExp ? maybeMatch(b, str) : b;
|
|
3188
|
+
const r = null !== ma && null != mb && range(ma, mb, str);
|
|
3189
|
+
return r && {
|
|
3190
|
+
start: r[0],
|
|
3191
|
+
end: r[1],
|
|
3192
|
+
pre: str.slice(0, r[0]),
|
|
3193
|
+
body: str.slice(r[0] + ma.length, r[1]),
|
|
3194
|
+
post: str.slice(r[1] + mb.length)
|
|
3488
3195
|
};
|
|
3489
|
-
mimicFunction(onetime, function_);
|
|
3490
|
-
calledFunctions.set(onetime, callCount);
|
|
3491
|
-
return onetime;
|
|
3492
3196
|
};
|
|
3493
|
-
|
|
3494
|
-
|
|
3495
|
-
return
|
|
3197
|
+
const maybeMatch = (reg, str)=>{
|
|
3198
|
+
const m = str.match(reg);
|
|
3199
|
+
return m ? m[0] : null;
|
|
3496
3200
|
};
|
|
3497
|
-
const
|
|
3498
|
-
|
|
3499
|
-
|
|
3500
|
-
|
|
3501
|
-
|
|
3502
|
-
|
|
3503
|
-
|
|
3504
|
-
|
|
3505
|
-
|
|
3506
|
-
|
|
3507
|
-
|
|
3508
|
-
|
|
3509
|
-
|
|
3510
|
-
|
|
3511
|
-
|
|
3512
|
-
|
|
3513
|
-
|
|
3514
|
-
|
|
3515
|
-
|
|
3516
|
-
|
|
3517
|
-
|
|
3518
|
-
|
|
3519
|
-
|
|
3520
|
-
|
|
3521
|
-
|
|
3522
|
-
|
|
3523
|
-
|
|
3524
|
-
|
|
3525
|
-
|
|
3526
|
-
on(ev, fn) {
|
|
3527
|
-
this.listeners[ev].push(fn);
|
|
3528
|
-
}
|
|
3529
|
-
removeListener(ev, fn) {
|
|
3530
|
-
const list = this.listeners[ev];
|
|
3531
|
-
const i = list.indexOf(fn);
|
|
3532
|
-
if (-1 === i) return;
|
|
3533
|
-
if (0 === i && 1 === list.length) list.length = 0;
|
|
3534
|
-
else list.splice(i, 1);
|
|
3535
|
-
}
|
|
3536
|
-
emit(ev, code, signal) {
|
|
3537
|
-
if (this.emitted[ev]) return false;
|
|
3538
|
-
this.emitted[ev] = true;
|
|
3539
|
-
let ret = false;
|
|
3540
|
-
for (const fn of this.listeners[ev])ret = true === fn(code, signal) || ret;
|
|
3541
|
-
if ('exit' === ev) ret = this.emit('afterExit', code, signal) || ret;
|
|
3542
|
-
return ret;
|
|
3543
|
-
}
|
|
3544
|
-
}
|
|
3545
|
-
class SignalExitBase {
|
|
3546
|
-
}
|
|
3547
|
-
const signalExitWrap = (handler)=>({
|
|
3548
|
-
onExit (cb, opts) {
|
|
3549
|
-
return handler.onExit(cb, opts);
|
|
3550
|
-
},
|
|
3551
|
-
load () {
|
|
3552
|
-
return handler.load();
|
|
3553
|
-
},
|
|
3554
|
-
unload () {
|
|
3555
|
-
return handler.unload();
|
|
3556
|
-
}
|
|
3557
|
-
});
|
|
3558
|
-
class SignalExitFallback extends SignalExitBase {
|
|
3559
|
-
onExit() {
|
|
3560
|
-
return ()=>{};
|
|
3561
|
-
}
|
|
3562
|
-
load() {}
|
|
3563
|
-
unload() {}
|
|
3564
|
-
}
|
|
3565
|
-
class SignalExit extends SignalExitBase {
|
|
3566
|
-
#hupSig = 'win32' === mjs_process.platform ? 'SIGINT' : 'SIGHUP';
|
|
3567
|
-
#emitter = new Emitter();
|
|
3568
|
-
#process;
|
|
3569
|
-
#originalProcessEmit;
|
|
3570
|
-
#originalProcessReallyExit;
|
|
3571
|
-
#sigListeners = {};
|
|
3572
|
-
#loaded = false;
|
|
3573
|
-
constructor(process1){
|
|
3574
|
-
super();
|
|
3575
|
-
this.#process = process1;
|
|
3576
|
-
this.#sigListeners = {};
|
|
3577
|
-
for (const sig of signals)this.#sigListeners[sig] = ()=>{
|
|
3578
|
-
const listeners = this.#process.listeners(sig);
|
|
3579
|
-
let { count } = this.#emitter;
|
|
3580
|
-
const p = process1;
|
|
3581
|
-
if ('object' == typeof p.__signal_exit_emitter__ && 'number' == typeof p.__signal_exit_emitter__.count) count += p.__signal_exit_emitter__.count;
|
|
3582
|
-
if (listeners.length === count) {
|
|
3583
|
-
this.unload();
|
|
3584
|
-
const ret = this.#emitter.emit('exit', null, sig);
|
|
3585
|
-
const s = 'SIGHUP' === sig ? this.#hupSig : sig;
|
|
3586
|
-
if (!ret) process1.kill(process1.pid, s);
|
|
3201
|
+
const range = (a, b, str)=>{
|
|
3202
|
+
let begs, beg, left, right, result;
|
|
3203
|
+
let ai = str.indexOf(a);
|
|
3204
|
+
let bi = str.indexOf(b, ai + 1);
|
|
3205
|
+
let i = ai;
|
|
3206
|
+
if (ai >= 0 && bi > 0) {
|
|
3207
|
+
if (a === b) return [
|
|
3208
|
+
ai,
|
|
3209
|
+
bi
|
|
3210
|
+
];
|
|
3211
|
+
begs = [];
|
|
3212
|
+
left = str.length;
|
|
3213
|
+
while(i >= 0 && !result){
|
|
3214
|
+
if (i === ai) {
|
|
3215
|
+
begs.push(i);
|
|
3216
|
+
ai = str.indexOf(a, i + 1);
|
|
3217
|
+
} else if (1 === begs.length) {
|
|
3218
|
+
const r = begs.pop();
|
|
3219
|
+
if (void 0 !== r) result = [
|
|
3220
|
+
r,
|
|
3221
|
+
bi
|
|
3222
|
+
];
|
|
3223
|
+
} else {
|
|
3224
|
+
beg = begs.pop();
|
|
3225
|
+
if (void 0 !== beg && beg < left) {
|
|
3226
|
+
left = beg;
|
|
3227
|
+
right = bi;
|
|
3228
|
+
}
|
|
3229
|
+
bi = str.indexOf(b, i + 1);
|
|
3587
3230
|
}
|
|
3588
|
-
|
|
3589
|
-
this.#originalProcessReallyExit = process1.reallyExit;
|
|
3590
|
-
this.#originalProcessEmit = process1.emit;
|
|
3591
|
-
}
|
|
3592
|
-
onExit(cb, opts) {
|
|
3593
|
-
if (!processOk(this.#process)) return ()=>{};
|
|
3594
|
-
if (false === this.#loaded) this.load();
|
|
3595
|
-
const ev = opts?.alwaysLast ? 'afterExit' : 'exit';
|
|
3596
|
-
this.#emitter.on(ev, cb);
|
|
3597
|
-
return ()=>{
|
|
3598
|
-
this.#emitter.removeListener(ev, cb);
|
|
3599
|
-
if (0 === this.#emitter.listeners['exit'].length && 0 === this.#emitter.listeners['afterExit'].length) this.unload();
|
|
3600
|
-
};
|
|
3601
|
-
}
|
|
3602
|
-
load() {
|
|
3603
|
-
if (this.#loaded) return;
|
|
3604
|
-
this.#loaded = true;
|
|
3605
|
-
this.#emitter.count += 1;
|
|
3606
|
-
for (const sig of signals)try {
|
|
3607
|
-
const fn = this.#sigListeners[sig];
|
|
3608
|
-
if (fn) this.#process.on(sig, fn);
|
|
3609
|
-
} catch (_) {}
|
|
3610
|
-
this.#process.emit = (ev, ...a)=>this.#processEmit(ev, ...a);
|
|
3611
|
-
this.#process.reallyExit = (code)=>this.#processReallyExit(code);
|
|
3612
|
-
}
|
|
3613
|
-
unload() {
|
|
3614
|
-
if (!this.#loaded) return;
|
|
3615
|
-
this.#loaded = false;
|
|
3616
|
-
signals.forEach((sig)=>{
|
|
3617
|
-
const listener = this.#sigListeners[sig];
|
|
3618
|
-
if (!listener) throw new Error('Listener not defined for signal: ' + sig);
|
|
3619
|
-
try {
|
|
3620
|
-
this.#process.removeListener(sig, listener);
|
|
3621
|
-
} catch (_) {}
|
|
3622
|
-
});
|
|
3623
|
-
this.#process.emit = this.#originalProcessEmit;
|
|
3624
|
-
this.#process.reallyExit = this.#originalProcessReallyExit;
|
|
3625
|
-
this.#emitter.count -= 1;
|
|
3626
|
-
}
|
|
3627
|
-
#processReallyExit(code) {
|
|
3628
|
-
if (!processOk(this.#process)) return 0;
|
|
3629
|
-
this.#process.exitCode = code || 0;
|
|
3630
|
-
this.#emitter.emit('exit', this.#process.exitCode, null);
|
|
3631
|
-
return this.#originalProcessReallyExit.call(this.#process, this.#process.exitCode);
|
|
3632
|
-
}
|
|
3633
|
-
#processEmit(ev, ...args) {
|
|
3634
|
-
const og = this.#originalProcessEmit;
|
|
3635
|
-
if (!('exit' === ev && processOk(this.#process))) return og.call(this.#process, ev, ...args);
|
|
3636
|
-
{
|
|
3637
|
-
if ('number' == typeof args[0]) this.#process.exitCode = args[0];
|
|
3638
|
-
const ret = og.call(this.#process, ev, ...args);
|
|
3639
|
-
this.#emitter.emit('exit', this.#process.exitCode, null);
|
|
3640
|
-
return ret;
|
|
3231
|
+
i = ai < bi && ai >= 0 ? ai : bi;
|
|
3641
3232
|
}
|
|
3233
|
+
if (begs.length && void 0 !== right) result = [
|
|
3234
|
+
left,
|
|
3235
|
+
right
|
|
3236
|
+
];
|
|
3642
3237
|
}
|
|
3238
|
+
return result;
|
|
3239
|
+
};
|
|
3240
|
+
const escSlash = '\0SLASH' + Math.random() + '\0';
|
|
3241
|
+
const escOpen = '\0OPEN' + Math.random() + '\0';
|
|
3242
|
+
const escClose = '\0CLOSE' + Math.random() + '\0';
|
|
3243
|
+
const escComma = '\0COMMA' + Math.random() + '\0';
|
|
3244
|
+
const escPeriod = '\0PERIOD' + Math.random() + '\0';
|
|
3245
|
+
const escSlashPattern = new RegExp(escSlash, 'g');
|
|
3246
|
+
const escOpenPattern = new RegExp(escOpen, 'g');
|
|
3247
|
+
const escClosePattern = new RegExp(escClose, 'g');
|
|
3248
|
+
const escCommaPattern = new RegExp(escComma, 'g');
|
|
3249
|
+
const escPeriodPattern = new RegExp(escPeriod, 'g');
|
|
3250
|
+
const slashPattern = /\\\\/g;
|
|
3251
|
+
const openPattern = /\\{/g;
|
|
3252
|
+
const closePattern = /\\}/g;
|
|
3253
|
+
const commaPattern = /\\,/g;
|
|
3254
|
+
const periodPattern = /\\\./g;
|
|
3255
|
+
const EXPANSION_MAX = 100000;
|
|
3256
|
+
function numeric(str) {
|
|
3257
|
+
return isNaN(str) ? str.charCodeAt(0) : parseInt(str, 10);
|
|
3643
3258
|
}
|
|
3644
|
-
|
|
3645
|
-
|
|
3646
|
-
const terminal = external_node_process_namespaceObject.stderr.isTTY ? external_node_process_namespaceObject.stderr : external_node_process_namespaceObject.stdout.isTTY ? external_node_process_namespaceObject.stdout : void 0;
|
|
3647
|
-
const restoreCursor = terminal ? node_modules_onetime(()=>{
|
|
3648
|
-
onExit(()=>{
|
|
3649
|
-
terminal.write('\u001B[?25h');
|
|
3650
|
-
}, {
|
|
3651
|
-
alwaysLast: true
|
|
3652
|
-
});
|
|
3653
|
-
}) : ()=>{};
|
|
3654
|
-
const restore_cursor = restoreCursor;
|
|
3655
|
-
function _define_property(obj, key, value) {
|
|
3656
|
-
if (key in obj) Object.defineProperty(obj, key, {
|
|
3657
|
-
value: value,
|
|
3658
|
-
enumerable: true,
|
|
3659
|
-
configurable: true,
|
|
3660
|
-
writable: true
|
|
3661
|
-
});
|
|
3662
|
-
else obj[key] = value;
|
|
3663
|
-
return obj;
|
|
3259
|
+
function escapeBraces(str) {
|
|
3260
|
+
return str.replace(slashPattern, escSlash).replace(openPattern, escOpen).replace(closePattern, escClose).replace(commaPattern, escComma).replace(periodPattern, escPeriod);
|
|
3664
3261
|
}
|
|
3665
|
-
|
|
3666
|
-
|
|
3667
|
-
const CLEAR_LINE = `${ESC}K`;
|
|
3668
|
-
const MOVE_CURSOR_ONE_ROW_UP = `${ESC}1A`;
|
|
3669
|
-
const HIDE_CURSOR = `${ESC}?25l`;
|
|
3670
|
-
const SHOW_CURSOR = `${ESC}?25h`;
|
|
3671
|
-
const SYNC_START = `${ESC}?2026h`;
|
|
3672
|
-
const SYNC_END = `${ESC}?2026l`;
|
|
3673
|
-
class TTYWindowRenderer {
|
|
3674
|
-
start() {
|
|
3675
|
-
this.finished = false;
|
|
3676
|
-
this.renderInterval = setInterval(()=>this.flushBuffer(), this.options.interval);
|
|
3677
|
-
}
|
|
3678
|
-
stop() {
|
|
3679
|
-
this.flushBuffer();
|
|
3680
|
-
this.write(SHOW_CURSOR, 'output');
|
|
3681
|
-
this.cleanups.splice(0).map((fn)=>fn());
|
|
3682
|
-
clearInterval(this.renderInterval);
|
|
3683
|
-
}
|
|
3684
|
-
finish() {
|
|
3685
|
-
this.finished = true;
|
|
3686
|
-
this.flushBuffer();
|
|
3687
|
-
clearInterval(this.renderInterval);
|
|
3688
|
-
}
|
|
3689
|
-
flushBuffer() {
|
|
3690
|
-
if (0 === this.buffer.length) return this.render();
|
|
3691
|
-
let current;
|
|
3692
|
-
for (const next of this.buffer.splice(0)){
|
|
3693
|
-
if (!current) {
|
|
3694
|
-
current = next;
|
|
3695
|
-
continue;
|
|
3696
|
-
}
|
|
3697
|
-
if (current.type !== next.type) {
|
|
3698
|
-
this.render(current.message, current.type);
|
|
3699
|
-
current = next;
|
|
3700
|
-
continue;
|
|
3701
|
-
}
|
|
3702
|
-
current.message += next.message;
|
|
3703
|
-
}
|
|
3704
|
-
if (current) this.render(current?.message, current?.type);
|
|
3705
|
-
}
|
|
3706
|
-
render(message, type = 'output') {
|
|
3707
|
-
if (this.finished) {
|
|
3708
|
-
this.clearWindow();
|
|
3709
|
-
return this.write(message || '', type);
|
|
3710
|
-
}
|
|
3711
|
-
const windowContent = this.options.getWindow();
|
|
3712
|
-
const rowCount = getRenderedRowCount(windowContent, this.options.outputStream);
|
|
3713
|
-
let padding = this.windowHeight - rowCount;
|
|
3714
|
-
if (padding > 0 && message) padding -= getRenderedRowCount([
|
|
3715
|
-
message
|
|
3716
|
-
], this.options.outputStream);
|
|
3717
|
-
this.write(SYNC_START);
|
|
3718
|
-
this.clearWindow();
|
|
3719
|
-
if (message) this.write(message, type);
|
|
3720
|
-
if (padding > 0) this.write('\n'.repeat(padding));
|
|
3721
|
-
this.write(windowContent.join('\n'));
|
|
3722
|
-
this.write(SYNC_END);
|
|
3723
|
-
this.windowHeight = rowCount + Math.max(0, padding);
|
|
3724
|
-
}
|
|
3725
|
-
clearWindow() {
|
|
3726
|
-
if (0 === this.windowHeight) return;
|
|
3727
|
-
this.write(CLEAR_LINE);
|
|
3728
|
-
for(let i = 1; i < this.windowHeight; i++)this.write(`${MOVE_CURSOR_ONE_ROW_UP}${CLEAR_LINE}`);
|
|
3729
|
-
this.windowHeight = 0;
|
|
3730
|
-
}
|
|
3731
|
-
interceptStream(stream, type) {
|
|
3732
|
-
const original = stream.write;
|
|
3733
|
-
stream.write = (chunk, _, callback)=>{
|
|
3734
|
-
if (chunk) if (this.finished) this.write(chunk.toString(), type);
|
|
3735
|
-
else this.buffer.push({
|
|
3736
|
-
type,
|
|
3737
|
-
message: chunk.toString()
|
|
3738
|
-
});
|
|
3739
|
-
callback?.();
|
|
3740
|
-
};
|
|
3741
|
-
return function() {
|
|
3742
|
-
stream.write = original;
|
|
3743
|
-
};
|
|
3744
|
-
}
|
|
3745
|
-
write(message, type = 'output') {
|
|
3746
|
-
this.streams[type](message);
|
|
3747
|
-
}
|
|
3748
|
-
constructor(options){
|
|
3749
|
-
_define_property(this, "options", void 0);
|
|
3750
|
-
_define_property(this, "streams", void 0);
|
|
3751
|
-
_define_property(this, "buffer", []);
|
|
3752
|
-
_define_property(this, "renderInterval", void 0);
|
|
3753
|
-
_define_property(this, "windowHeight", 0);
|
|
3754
|
-
_define_property(this, "finished", false);
|
|
3755
|
-
_define_property(this, "cleanups", []);
|
|
3756
|
-
this.options = {
|
|
3757
|
-
interval: DEFAULT_RENDER_INTERVAL,
|
|
3758
|
-
...options
|
|
3759
|
-
};
|
|
3760
|
-
this.streams = {
|
|
3761
|
-
output: options.outputStream.write.bind(options.outputStream),
|
|
3762
|
-
error: options.errorStream.write.bind(options.errorStream)
|
|
3763
|
-
};
|
|
3764
|
-
this.cleanups.push(this.interceptStream(process.stdout, 'output'), this.interceptStream(process.stderr, 'error'));
|
|
3765
|
-
restore_cursor();
|
|
3766
|
-
this.write(HIDE_CURSOR, 'output');
|
|
3767
|
-
this.start();
|
|
3768
|
-
}
|
|
3262
|
+
function unescapeBraces(str) {
|
|
3263
|
+
return str.replace(escSlashPattern, '\\').replace(escOpenPattern, '{').replace(escClosePattern, '}').replace(escCommaPattern, ',').replace(escPeriodPattern, '.');
|
|
3769
3264
|
}
|
|
3770
|
-
function
|
|
3771
|
-
|
|
3772
|
-
|
|
3773
|
-
|
|
3774
|
-
|
|
3775
|
-
|
|
3776
|
-
|
|
3777
|
-
|
|
3778
|
-
|
|
3265
|
+
function parseCommaParts(str) {
|
|
3266
|
+
if (!str) return [
|
|
3267
|
+
''
|
|
3268
|
+
];
|
|
3269
|
+
const parts = [];
|
|
3270
|
+
const m = balanced('{', '}', str);
|
|
3271
|
+
if (!m) return str.split(',');
|
|
3272
|
+
const { pre, body, post } = m;
|
|
3273
|
+
const p = pre.split(',');
|
|
3274
|
+
p[p.length - 1] += '{' + body + '}';
|
|
3275
|
+
const postParts = parseCommaParts(post);
|
|
3276
|
+
if (post.length) {
|
|
3277
|
+
p[p.length - 1] += postParts.shift();
|
|
3278
|
+
p.push.apply(p, postParts);
|
|
3779
3279
|
}
|
|
3780
|
-
|
|
3280
|
+
parts.push.apply(parts, p);
|
|
3281
|
+
return parts;
|
|
3781
3282
|
}
|
|
3782
|
-
function
|
|
3783
|
-
if (
|
|
3784
|
-
|
|
3785
|
-
|
|
3786
|
-
|
|
3787
|
-
writable: true
|
|
3788
|
-
});
|
|
3789
|
-
else obj[key] = value;
|
|
3790
|
-
return obj;
|
|
3283
|
+
function expand(str, options = {}) {
|
|
3284
|
+
if (!str) return [];
|
|
3285
|
+
const { max = EXPANSION_MAX } = options;
|
|
3286
|
+
if ('{}' === str.slice(0, 2)) str = '\\{\\}' + str.slice(2);
|
|
3287
|
+
return expand_(escapeBraces(str), max, true).map(unescapeBraces);
|
|
3791
3288
|
}
|
|
3792
|
-
|
|
3793
|
-
|
|
3794
|
-
|
|
3795
|
-
|
|
3796
|
-
|
|
3797
|
-
|
|
3798
|
-
|
|
3799
|
-
|
|
3800
|
-
|
|
3801
|
-
|
|
3802
|
-
|
|
3803
|
-
|
|
3804
|
-
|
|
3805
|
-
|
|
3806
|
-
|
|
3807
|
-
|
|
3808
|
-
|
|
3809
|
-
|
|
3810
|
-
|
|
3811
|
-
|
|
3812
|
-
|
|
3813
|
-
|
|
3814
|
-
|
|
3815
|
-
|
|
3816
|
-
|
|
3817
|
-
const height = globalWebConfig?.viewportHeight ?? puppeteer_agent_launcher_namespaceObject.defaultViewportHeight;
|
|
3818
|
-
const args = (0, puppeteer_agent_launcher_namespaceObject.buildChromeArgs)({
|
|
3819
|
-
userAgent: globalWebConfig?.userAgent,
|
|
3820
|
-
windowSize: headed ? {
|
|
3821
|
-
width,
|
|
3822
|
-
height
|
|
3823
|
-
} : void 0,
|
|
3824
|
-
chromeArgs: globalWebConfig?.chromeArgs
|
|
3825
|
-
});
|
|
3826
|
-
browser = await external_puppeteer_default().launch({
|
|
3827
|
-
headless: !headed,
|
|
3828
|
-
defaultViewport: headed ? null : {
|
|
3829
|
-
width,
|
|
3830
|
-
height
|
|
3831
|
-
},
|
|
3832
|
-
args,
|
|
3833
|
-
acceptInsecureCerts: globalWebConfig?.acceptInsecureCerts
|
|
3834
|
-
});
|
|
3835
|
-
}
|
|
3836
|
-
sharedPage = await browser.newPage();
|
|
3837
|
-
for (const context of fileContextList){
|
|
3838
|
-
context.options.browser = browser;
|
|
3839
|
-
context.options.page = sharedPage;
|
|
3840
|
-
}
|
|
3841
|
-
}
|
|
3842
|
-
const { executedResults, notExecutedContexts } = await this.executeFiles(fileContextList);
|
|
3843
|
-
this.results = await this.processResults(executedResults, notExecutedContexts);
|
|
3844
|
-
} finally{
|
|
3845
|
-
if (browser && !this.config.keepWindow) {
|
|
3846
|
-
const isCdp = !!this.config.globalConfig?.web?.cdpEndpoint;
|
|
3847
|
-
if (isCdp) browser.disconnect();
|
|
3848
|
-
else await browser.close();
|
|
3849
|
-
}
|
|
3850
|
-
await this.generateOutputIndex();
|
|
3851
|
-
}
|
|
3852
|
-
return this.results;
|
|
3853
|
-
}
|
|
3854
|
-
async createFileContext(file, fileConfig, options) {
|
|
3855
|
-
const { globalConfig } = this.config;
|
|
3856
|
-
const clonedFileConfig = JSON.parse(JSON.stringify(fileConfig));
|
|
3857
|
-
if (clonedFileConfig.target) {
|
|
3858
|
-
clonedFileConfig.web = {
|
|
3859
|
-
...clonedFileConfig.target,
|
|
3860
|
-
...clonedFileConfig.web
|
|
3861
|
-
};
|
|
3862
|
-
delete clonedFileConfig.target;
|
|
3863
|
-
}
|
|
3864
|
-
if (globalConfig?.target) {
|
|
3865
|
-
globalConfig.web = {
|
|
3866
|
-
...globalConfig.target,
|
|
3867
|
-
...globalConfig.web
|
|
3868
|
-
};
|
|
3869
|
-
delete globalConfig.target;
|
|
3870
|
-
}
|
|
3871
|
-
const executionConfig = external_lodash_merge_default()(clonedFileConfig, globalConfig);
|
|
3872
|
-
return {
|
|
3873
|
-
file,
|
|
3874
|
-
executionConfig,
|
|
3875
|
-
options
|
|
3876
|
-
};
|
|
3877
|
-
}
|
|
3878
|
-
async executeFiles(fileContextList) {
|
|
3879
|
-
const executedResults = [];
|
|
3880
|
-
const notExecutedContexts = [];
|
|
3881
|
-
const allFileContexts = [];
|
|
3882
|
-
for (const context of fileContextList){
|
|
3883
|
-
const player = await createYamlPlayer(context.file, context.executionConfig, context.options);
|
|
3884
|
-
allFileContexts.push({
|
|
3885
|
-
file: context.file,
|
|
3886
|
-
player
|
|
3887
|
-
});
|
|
3888
|
-
}
|
|
3889
|
-
let ttyRenderer;
|
|
3890
|
-
if (isTTY) {
|
|
3891
|
-
const summaryContents = ()=>{
|
|
3892
|
-
const summary = [
|
|
3893
|
-
''
|
|
3894
|
-
];
|
|
3895
|
-
for (const context of allFileContexts)summary.push(contextTaskListSummary(context.player.taskStatusList, context));
|
|
3896
|
-
summary.push('');
|
|
3897
|
-
return summary;
|
|
3898
|
-
};
|
|
3899
|
-
ttyRenderer = new TTYWindowRenderer({
|
|
3900
|
-
outputStream: process.stdout,
|
|
3901
|
-
errorStream: process.stderr,
|
|
3902
|
-
getWindow: summaryContents,
|
|
3903
|
-
interval: spinnerInterval
|
|
3904
|
-
});
|
|
3905
|
-
ttyRenderer.start();
|
|
3906
|
-
}
|
|
3907
|
-
try {
|
|
3908
|
-
const executeFile = async (context)=>{
|
|
3909
|
-
const allFileContext = allFileContexts.find((c)=>c.file === context.file);
|
|
3910
|
-
if (!allFileContext) throw new Error(`Player not found for file: ${context.file}`);
|
|
3911
|
-
if (!isTTY) {
|
|
3912
|
-
const { mergedText } = contextInfo(allFileContext);
|
|
3913
|
-
console.log(mergedText);
|
|
3914
|
-
}
|
|
3915
|
-
if (context.outputPath) allFileContext.player.output = context.outputPath;
|
|
3916
|
-
const startTime = Date.now();
|
|
3917
|
-
await allFileContext.player.run();
|
|
3918
|
-
const endTime = Date.now();
|
|
3919
|
-
const duration = endTime - startTime;
|
|
3920
|
-
const executedContext = {
|
|
3921
|
-
file: context.file,
|
|
3922
|
-
player: allFileContext.player,
|
|
3923
|
-
duration
|
|
3924
|
-
};
|
|
3925
|
-
if (!isTTY) console.log(contextTaskListSummary(allFileContext.player.taskStatusList, executedContext));
|
|
3926
|
-
return executedContext;
|
|
3927
|
-
};
|
|
3928
|
-
await this.executeConcurrently(fileContextList, executeFile, executedResults, notExecutedContexts);
|
|
3929
|
-
if (!isTTY) {
|
|
3930
|
-
console.log('\n📋 Execution Results:');
|
|
3931
|
-
for (const context of executedResults)console.log(contextTaskListSummary(context.player.taskStatusList, context));
|
|
3932
|
-
}
|
|
3933
|
-
} finally{
|
|
3934
|
-
if (ttyRenderer) ttyRenderer.stop();
|
|
3935
|
-
}
|
|
3936
|
-
return {
|
|
3937
|
-
executedResults,
|
|
3938
|
-
notExecutedContexts
|
|
3939
|
-
};
|
|
3289
|
+
function embrace(str) {
|
|
3290
|
+
return '{' + str + '}';
|
|
3291
|
+
}
|
|
3292
|
+
function isPadded(el) {
|
|
3293
|
+
return /^-?0\d/.test(el);
|
|
3294
|
+
}
|
|
3295
|
+
function lte(i, y) {
|
|
3296
|
+
return i <= y;
|
|
3297
|
+
}
|
|
3298
|
+
function gte(i, y) {
|
|
3299
|
+
return i >= y;
|
|
3300
|
+
}
|
|
3301
|
+
function expand_(str, max, isTop) {
|
|
3302
|
+
const expansions = [];
|
|
3303
|
+
const m = balanced('{', '}', str);
|
|
3304
|
+
if (!m) return [
|
|
3305
|
+
str
|
|
3306
|
+
];
|
|
3307
|
+
const pre = m.pre;
|
|
3308
|
+
const post = m.post.length ? expand_(m.post, max, false) : [
|
|
3309
|
+
''
|
|
3310
|
+
];
|
|
3311
|
+
if (/\$$/.test(m.pre)) for(let k = 0; k < post.length && k < max; k++){
|
|
3312
|
+
const expansion = pre + '{' + m.body + '}' + post[k];
|
|
3313
|
+
expansions.push(expansion);
|
|
3940
3314
|
}
|
|
3941
|
-
|
|
3942
|
-
const
|
|
3943
|
-
|
|
3944
|
-
|
|
3945
|
-
|
|
3946
|
-
|
|
3947
|
-
|
|
3948
|
-
|
|
3949
|
-
|
|
3950
|
-
let shouldStop = false;
|
|
3951
|
-
const stopLock = {
|
|
3952
|
-
value: false
|
|
3953
|
-
};
|
|
3954
|
-
const tasks = fileContextList.map((context)=>limit(async ()=>{
|
|
3955
|
-
if (stopLock.value) return void notExecutedContexts.push({
|
|
3956
|
-
file: context.file,
|
|
3957
|
-
player: null
|
|
3958
|
-
});
|
|
3959
|
-
const executedContext = await executeFile(context);
|
|
3960
|
-
executedResults.push(executedContext);
|
|
3961
|
-
if ('error' === executedContext.player.status && !stopLock.value) {
|
|
3962
|
-
stopLock.value = true;
|
|
3963
|
-
shouldStop = true;
|
|
3964
|
-
}
|
|
3965
|
-
}));
|
|
3966
|
-
await Promise.allSettled(tasks);
|
|
3967
|
-
if (shouldStop) {
|
|
3968
|
-
for (const context of fileContextList)if (!executedResults.some((r)=>r.file === context.file) && !notExecutedContexts.some((ctx)=>ctx.file === context.file)) notExecutedContexts.push({
|
|
3969
|
-
file: context.file,
|
|
3970
|
-
player: null
|
|
3971
|
-
});
|
|
3315
|
+
else {
|
|
3316
|
+
const isNumericSequence = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(m.body);
|
|
3317
|
+
const isAlphaSequence = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(m.body);
|
|
3318
|
+
const isSequence = isNumericSequence || isAlphaSequence;
|
|
3319
|
+
const isOptions = m.body.indexOf(',') >= 0;
|
|
3320
|
+
if (!isSequence && !isOptions) {
|
|
3321
|
+
if (m.post.match(/,(?!,).*\}/)) {
|
|
3322
|
+
str = m.pre + '{' + m.body + escClose + m.post;
|
|
3323
|
+
return expand_(str, max, true);
|
|
3972
3324
|
}
|
|
3325
|
+
return [
|
|
3326
|
+
str
|
|
3327
|
+
];
|
|
3973
3328
|
}
|
|
3974
|
-
|
|
3975
|
-
|
|
3976
|
-
|
|
3977
|
-
|
|
3978
|
-
|
|
3979
|
-
|
|
3980
|
-
|
|
3981
|
-
|
|
3982
|
-
|
|
3983
|
-
|
|
3984
|
-
|
|
3985
|
-
|
|
3986
|
-
|
|
3987
|
-
|
|
3988
|
-
|
|
3989
|
-
|
|
3990
|
-
|
|
3991
|
-
|
|
3992
|
-
|
|
3993
|
-
|
|
3994
|
-
|
|
3995
|
-
|
|
3996
|
-
|
|
3997
|
-
let
|
|
3998
|
-
|
|
3999
|
-
|
|
4000
|
-
|
|
4001
|
-
|
|
4002
|
-
|
|
4003
|
-
|
|
4004
|
-
|
|
4005
|
-
|
|
4006
|
-
|
|
4007
|
-
|
|
4008
|
-
|
|
4009
|
-
|
|
4010
|
-
|
|
4011
|
-
|
|
4012
|
-
|
|
4013
|
-
|
|
4014
|
-
|
|
4015
|
-
|
|
4016
|
-
|
|
4017
|
-
executed: false,
|
|
4018
|
-
output: void 0,
|
|
4019
|
-
report: void 0,
|
|
4020
|
-
duration: 0,
|
|
4021
|
-
resultType: 'notExecuted',
|
|
4022
|
-
error: 'Not executed (previous task failed)'
|
|
4023
|
-
});
|
|
4024
|
-
return results;
|
|
4025
|
-
}
|
|
4026
|
-
async loadFileConfig(file) {
|
|
4027
|
-
const content = (0, external_node_fs_namespaceObject.readFileSync)(file, 'utf8');
|
|
4028
|
-
return (0, yaml_namespaceObject.parseYamlScript)(content, file);
|
|
4029
|
-
}
|
|
4030
|
-
getSummaryAbsolutePath() {
|
|
4031
|
-
return (0, external_node_path_namespaceObject.resolve)((0, common_namespaceObject.getMidsceneRunSubDir)('output'), this.config.summary);
|
|
4032
|
-
}
|
|
4033
|
-
printExecutionPlan() {
|
|
4034
|
-
console.log(' Scripts:');
|
|
4035
|
-
for (const file of this.config.files)console.log(` - ${file}`);
|
|
4036
|
-
console.log('📋 Execution plan');
|
|
4037
|
-
console.log(` Concurrency: ${this.config.concurrent}`);
|
|
4038
|
-
console.log(` Keep window: ${this.config.keepWindow}`);
|
|
4039
|
-
console.log(` Headed: ${this.config.headed}`);
|
|
4040
|
-
console.log(` Continue on error: ${this.config.continueOnError}`);
|
|
4041
|
-
console.log(` Share browser context: ${this.config.shareBrowserContext ?? false}`);
|
|
4042
|
-
console.log(` Summary output: ${this.config.summary}`);
|
|
4043
|
-
}
|
|
4044
|
-
async generateOutputIndex() {
|
|
4045
|
-
const indexPath = (0, external_node_path_namespaceObject.resolve)((0, common_namespaceObject.getMidsceneRunSubDir)('output'), this.config.summary);
|
|
4046
|
-
const outputDir = (0, external_node_path_namespaceObject.dirname)(indexPath);
|
|
4047
|
-
try {
|
|
4048
|
-
(0, external_node_fs_namespaceObject.mkdirSync)(outputDir, {
|
|
4049
|
-
recursive: true
|
|
4050
|
-
});
|
|
4051
|
-
const indexData = {
|
|
4052
|
-
summary: {
|
|
4053
|
-
total: this.results.length,
|
|
4054
|
-
successful: this.results.filter((r)=>'success' === r.resultType).length,
|
|
4055
|
-
failed: this.results.filter((r)=>'failed' === r.resultType).length,
|
|
4056
|
-
partialFailed: this.results.filter((r)=>'partialFailed' === r.resultType).length,
|
|
4057
|
-
notExecuted: this.results.filter((r)=>'notExecuted' === r.resultType).length,
|
|
4058
|
-
totalDuration: this.results.reduce((sum, r)=>sum + (r.duration || 0), 0),
|
|
4059
|
-
generatedAt: new Date().toLocaleString()
|
|
4060
|
-
},
|
|
4061
|
-
results: this.results.map((result)=>({
|
|
4062
|
-
script: (0, external_node_path_namespaceObject.relative)(outputDir, result.file),
|
|
4063
|
-
success: result.success,
|
|
4064
|
-
resultType: result.resultType,
|
|
4065
|
-
output: result.output ? (()=>{
|
|
4066
|
-
const relativePath = (0, external_node_path_namespaceObject.relative)(outputDir, result.output);
|
|
4067
|
-
return relativePath.startsWith('.') ? relativePath : `./${relativePath}`;
|
|
4068
|
-
})() : void 0,
|
|
4069
|
-
report: result.report ? (0, external_node_path_namespaceObject.relative)(outputDir, result.report) : void 0,
|
|
4070
|
-
error: result.error,
|
|
4071
|
-
duration: result.duration
|
|
4072
|
-
}))
|
|
4073
|
-
};
|
|
4074
|
-
(0, external_node_fs_namespaceObject.writeFileSync)(indexPath, JSON.stringify(indexData, null, 2));
|
|
4075
|
-
console.log('Execution finished:');
|
|
4076
|
-
} catch (error) {
|
|
4077
|
-
console.error('Failed to generate output index:', error);
|
|
4078
|
-
}
|
|
4079
|
-
}
|
|
4080
|
-
getExecutionSummary() {
|
|
4081
|
-
const successful = this.results.filter((r)=>'success' === r.resultType).length;
|
|
4082
|
-
const failed = this.results.filter((r)=>'failed' === r.resultType).length;
|
|
4083
|
-
const partialFailed = this.results.filter((r)=>'partialFailed' === r.resultType).length;
|
|
4084
|
-
const notExecuted = this.results.filter((r)=>'notExecuted' === r.resultType).length;
|
|
4085
|
-
return {
|
|
4086
|
-
total: this.results.length,
|
|
4087
|
-
successful,
|
|
4088
|
-
failed,
|
|
4089
|
-
partialFailed,
|
|
4090
|
-
notExecuted,
|
|
4091
|
-
totalDuration: this.results.reduce((sum, r)=>sum + (r.duration || 0), 0)
|
|
4092
|
-
};
|
|
4093
|
-
}
|
|
4094
|
-
getFailedFiles() {
|
|
4095
|
-
return this.results.filter((r)=>'failed' === r.resultType).map((r)=>r.file);
|
|
4096
|
-
}
|
|
4097
|
-
getPartialFailedFiles() {
|
|
4098
|
-
return this.results.filter((r)=>'partialFailed' === r.resultType).map((r)=>r.file);
|
|
4099
|
-
}
|
|
4100
|
-
getNotExecutedFiles() {
|
|
4101
|
-
return this.results.filter((r)=>'notExecuted' === r.resultType).map((r)=>r.file);
|
|
4102
|
-
}
|
|
4103
|
-
getSuccessfulFiles() {
|
|
4104
|
-
return this.results.filter((r)=>'success' === r.resultType).map((r)=>r.file);
|
|
4105
|
-
}
|
|
4106
|
-
getResults() {
|
|
4107
|
-
return [
|
|
4108
|
-
...this.results
|
|
4109
|
-
];
|
|
4110
|
-
}
|
|
4111
|
-
printExecutionSummary() {
|
|
4112
|
-
const summary = this.getExecutionSummary();
|
|
4113
|
-
const success = 0 === summary.failed && 0 === summary.partialFailed && 0 === summary.notExecuted;
|
|
4114
|
-
console.log('\n📊 Execution Summary:');
|
|
4115
|
-
console.log(` Total files: ${summary.total}`);
|
|
4116
|
-
console.log(` Successful: ${summary.successful}`);
|
|
4117
|
-
console.log(` Failed: ${summary.failed}`);
|
|
4118
|
-
console.log(` Partial failed: ${summary.partialFailed}`);
|
|
4119
|
-
console.log(` Not executed: ${summary.notExecuted}`);
|
|
4120
|
-
console.log(` Duration: ${(summary.totalDuration / 1000).toFixed(2)}s`);
|
|
4121
|
-
console.log(` Summary: ${this.getSummaryAbsolutePath()}`);
|
|
4122
|
-
if (summary.successful > 0) {
|
|
4123
|
-
console.log('\n✅ Successful files:');
|
|
4124
|
-
this.getSuccessfulFiles().forEach((file)=>{
|
|
4125
|
-
console.log(` ${file}`);
|
|
4126
|
-
});
|
|
4127
|
-
}
|
|
4128
|
-
if (summary.failed > 0) {
|
|
4129
|
-
console.log('\n❌ Failed files');
|
|
4130
|
-
this.getFailedFiles().forEach((file)=>{
|
|
4131
|
-
console.log(` ${file}`);
|
|
4132
|
-
});
|
|
4133
|
-
}
|
|
4134
|
-
if (summary.partialFailed > 0) {
|
|
4135
|
-
console.log('\n⚠️ Partial failed files (some tasks failed with continueOnError)');
|
|
4136
|
-
this.getPartialFailedFiles().forEach((file)=>{
|
|
4137
|
-
console.log(` ${file}`);
|
|
4138
|
-
});
|
|
3329
|
+
let n;
|
|
3330
|
+
if (isSequence) n = m.body.split(/\.\./);
|
|
3331
|
+
else {
|
|
3332
|
+
n = parseCommaParts(m.body);
|
|
3333
|
+
if (1 === n.length && void 0 !== n[0]) {
|
|
3334
|
+
n = expand_(n[0], max, false).map(embrace);
|
|
3335
|
+
if (1 === n.length) return post.map((p)=>m.pre + n[0] + p);
|
|
3336
|
+
}
|
|
3337
|
+
}
|
|
3338
|
+
let N;
|
|
3339
|
+
if (isSequence && void 0 !== n[0] && void 0 !== n[1]) {
|
|
3340
|
+
const x = numeric(n[0]);
|
|
3341
|
+
const y = numeric(n[1]);
|
|
3342
|
+
const width = Math.max(n[0].length, n[1].length);
|
|
3343
|
+
let incr = 3 === n.length && void 0 !== n[2] ? Math.max(Math.abs(numeric(n[2])), 1) : 1;
|
|
3344
|
+
let test = lte;
|
|
3345
|
+
const reverse = y < x;
|
|
3346
|
+
if (reverse) {
|
|
3347
|
+
incr *= -1;
|
|
3348
|
+
test = gte;
|
|
3349
|
+
}
|
|
3350
|
+
const pad = n.some(isPadded);
|
|
3351
|
+
N = [];
|
|
3352
|
+
for(let i = x; test(i, y); i += incr){
|
|
3353
|
+
let c;
|
|
3354
|
+
if (isAlphaSequence) {
|
|
3355
|
+
c = String.fromCharCode(i);
|
|
3356
|
+
if ('\\' === c) c = '';
|
|
3357
|
+
} else {
|
|
3358
|
+
c = String(i);
|
|
3359
|
+
if (pad) {
|
|
3360
|
+
const need = width - c.length;
|
|
3361
|
+
if (need > 0) {
|
|
3362
|
+
const z = new Array(need + 1).join('0');
|
|
3363
|
+
c = i < 0 ? '-' + z + c.slice(1) : z + c;
|
|
3364
|
+
}
|
|
3365
|
+
}
|
|
3366
|
+
}
|
|
3367
|
+
N.push(c);
|
|
3368
|
+
}
|
|
3369
|
+
} else {
|
|
3370
|
+
N = [];
|
|
3371
|
+
for(let j = 0; j < n.length; j++)N.push.apply(N, expand_(n[j], max, false));
|
|
4139
3372
|
}
|
|
4140
|
-
|
|
4141
|
-
|
|
4142
|
-
|
|
4143
|
-
console.log(` ${file}`);
|
|
4144
|
-
});
|
|
3373
|
+
for(let j = 0; j < N.length; j++)for(let k = 0; k < post.length && expansions.length < max; k++){
|
|
3374
|
+
const expansion = pre + N[j] + post[k];
|
|
3375
|
+
if (!isTop || isSequence || expansion) expansions.push(expansion);
|
|
4145
3376
|
}
|
|
4146
|
-
if (success) console.log('\n🎉 All files executed successfully!');
|
|
4147
|
-
else console.log('\n⚠️ Some files failed or were not executed.');
|
|
4148
|
-
return success;
|
|
4149
|
-
}
|
|
4150
|
-
constructor(config){
|
|
4151
|
-
batch_runner_define_property(this, "config", void 0);
|
|
4152
|
-
batch_runner_define_property(this, "results", []);
|
|
4153
|
-
this.config = config;
|
|
4154
3377
|
}
|
|
3378
|
+
return expansions;
|
|
4155
3379
|
}
|
|
4156
|
-
var brace_expansion = __webpack_require__("../../node_modules/.pnpm/brace-expansion@2.0.1/node_modules/brace-expansion/index.js");
|
|
4157
3380
|
const MAX_PATTERN_LENGTH = 65536;
|
|
4158
3381
|
const assertValidPattern = (pattern)=>{
|
|
4159
3382
|
if ('string' != typeof pattern) throw new TypeError('invalid pattern');
|
|
@@ -4319,7 +3542,11 @@ var __webpack_modules__ = {
|
|
|
4319
3542
|
true
|
|
4320
3543
|
];
|
|
4321
3544
|
};
|
|
4322
|
-
const unescape_unescape = (s, { windowsPathsNoEscape = false } = {})=>
|
|
3545
|
+
const unescape_unescape = (s, { windowsPathsNoEscape = false, magicalBraces = true } = {})=>{
|
|
3546
|
+
if (magicalBraces) return windowsPathsNoEscape ? s.replace(/\[([^/\\])\]/g, '$1') : s.replace(/((?!\\).|^)\[([^/\\])\]/g, '$1$2').replace(/\\([^/])/g, '$1');
|
|
3547
|
+
return windowsPathsNoEscape ? s.replace(/\[([^/\\{}])\]/g, '$1') : s.replace(/((?!\\).|^)\[([^/\\{}])\]/g, '$1$2').replace(/\\([^/{}])/g, '$1');
|
|
3548
|
+
};
|
|
3549
|
+
var ast_a;
|
|
4323
3550
|
const types = new Set([
|
|
4324
3551
|
'!',
|
|
4325
3552
|
'?',
|
|
@@ -4328,6 +3555,168 @@ var __webpack_modules__ = {
|
|
|
4328
3555
|
'@'
|
|
4329
3556
|
]);
|
|
4330
3557
|
const isExtglobType = (c)=>types.has(c);
|
|
3558
|
+
const isExtglobAST = (c)=>isExtglobType(c.type);
|
|
3559
|
+
const adoptionMap = new Map([
|
|
3560
|
+
[
|
|
3561
|
+
'!',
|
|
3562
|
+
[
|
|
3563
|
+
'@'
|
|
3564
|
+
]
|
|
3565
|
+
],
|
|
3566
|
+
[
|
|
3567
|
+
'?',
|
|
3568
|
+
[
|
|
3569
|
+
'?',
|
|
3570
|
+
'@'
|
|
3571
|
+
]
|
|
3572
|
+
],
|
|
3573
|
+
[
|
|
3574
|
+
'@',
|
|
3575
|
+
[
|
|
3576
|
+
'@'
|
|
3577
|
+
]
|
|
3578
|
+
],
|
|
3579
|
+
[
|
|
3580
|
+
'*',
|
|
3581
|
+
[
|
|
3582
|
+
'*',
|
|
3583
|
+
'+',
|
|
3584
|
+
'?',
|
|
3585
|
+
'@'
|
|
3586
|
+
]
|
|
3587
|
+
],
|
|
3588
|
+
[
|
|
3589
|
+
'+',
|
|
3590
|
+
[
|
|
3591
|
+
'+',
|
|
3592
|
+
'@'
|
|
3593
|
+
]
|
|
3594
|
+
]
|
|
3595
|
+
]);
|
|
3596
|
+
const adoptionWithSpaceMap = new Map([
|
|
3597
|
+
[
|
|
3598
|
+
'!',
|
|
3599
|
+
[
|
|
3600
|
+
'?'
|
|
3601
|
+
]
|
|
3602
|
+
],
|
|
3603
|
+
[
|
|
3604
|
+
'@',
|
|
3605
|
+
[
|
|
3606
|
+
'?'
|
|
3607
|
+
]
|
|
3608
|
+
],
|
|
3609
|
+
[
|
|
3610
|
+
'+',
|
|
3611
|
+
[
|
|
3612
|
+
'?',
|
|
3613
|
+
'*'
|
|
3614
|
+
]
|
|
3615
|
+
]
|
|
3616
|
+
]);
|
|
3617
|
+
const adoptionAnyMap = new Map([
|
|
3618
|
+
[
|
|
3619
|
+
'!',
|
|
3620
|
+
[
|
|
3621
|
+
'?',
|
|
3622
|
+
'@'
|
|
3623
|
+
]
|
|
3624
|
+
],
|
|
3625
|
+
[
|
|
3626
|
+
'?',
|
|
3627
|
+
[
|
|
3628
|
+
'?',
|
|
3629
|
+
'@'
|
|
3630
|
+
]
|
|
3631
|
+
],
|
|
3632
|
+
[
|
|
3633
|
+
'@',
|
|
3634
|
+
[
|
|
3635
|
+
'?',
|
|
3636
|
+
'@'
|
|
3637
|
+
]
|
|
3638
|
+
],
|
|
3639
|
+
[
|
|
3640
|
+
'*',
|
|
3641
|
+
[
|
|
3642
|
+
'*',
|
|
3643
|
+
'+',
|
|
3644
|
+
'?',
|
|
3645
|
+
'@'
|
|
3646
|
+
]
|
|
3647
|
+
],
|
|
3648
|
+
[
|
|
3649
|
+
'+',
|
|
3650
|
+
[
|
|
3651
|
+
'+',
|
|
3652
|
+
'@',
|
|
3653
|
+
'?',
|
|
3654
|
+
'*'
|
|
3655
|
+
]
|
|
3656
|
+
]
|
|
3657
|
+
]);
|
|
3658
|
+
const usurpMap = new Map([
|
|
3659
|
+
[
|
|
3660
|
+
'!',
|
|
3661
|
+
new Map([
|
|
3662
|
+
[
|
|
3663
|
+
'!',
|
|
3664
|
+
'@'
|
|
3665
|
+
]
|
|
3666
|
+
])
|
|
3667
|
+
],
|
|
3668
|
+
[
|
|
3669
|
+
'?',
|
|
3670
|
+
new Map([
|
|
3671
|
+
[
|
|
3672
|
+
'*',
|
|
3673
|
+
'*'
|
|
3674
|
+
],
|
|
3675
|
+
[
|
|
3676
|
+
'+',
|
|
3677
|
+
'*'
|
|
3678
|
+
]
|
|
3679
|
+
])
|
|
3680
|
+
],
|
|
3681
|
+
[
|
|
3682
|
+
'@',
|
|
3683
|
+
new Map([
|
|
3684
|
+
[
|
|
3685
|
+
'!',
|
|
3686
|
+
'!'
|
|
3687
|
+
],
|
|
3688
|
+
[
|
|
3689
|
+
'?',
|
|
3690
|
+
'?'
|
|
3691
|
+
],
|
|
3692
|
+
[
|
|
3693
|
+
'@',
|
|
3694
|
+
'@'
|
|
3695
|
+
],
|
|
3696
|
+
[
|
|
3697
|
+
'*',
|
|
3698
|
+
'*'
|
|
3699
|
+
],
|
|
3700
|
+
[
|
|
3701
|
+
'+',
|
|
3702
|
+
'+'
|
|
3703
|
+
]
|
|
3704
|
+
])
|
|
3705
|
+
],
|
|
3706
|
+
[
|
|
3707
|
+
'+',
|
|
3708
|
+
new Map([
|
|
3709
|
+
[
|
|
3710
|
+
'?',
|
|
3711
|
+
'*'
|
|
3712
|
+
],
|
|
3713
|
+
[
|
|
3714
|
+
'*',
|
|
3715
|
+
'*'
|
|
3716
|
+
]
|
|
3717
|
+
])
|
|
3718
|
+
]
|
|
3719
|
+
]);
|
|
4331
3720
|
const startNoTraversal = '(?!(?:^|/)\\.\\.?(?:$|/))';
|
|
4332
3721
|
const startNoDot = '(?!\\.)';
|
|
4333
3722
|
const addPatternStart = new Set([
|
|
@@ -4343,6 +3732,7 @@ var __webpack_modules__ = {
|
|
|
4343
3732
|
const qmark = '[^/]';
|
|
4344
3733
|
const star = qmark + '*?';
|
|
4345
3734
|
const starNoEmpty = qmark + '+?';
|
|
3735
|
+
let ID = 0;
|
|
4346
3736
|
class ast_AST {
|
|
4347
3737
|
type;
|
|
4348
3738
|
#root;
|
|
@@ -4356,6 +3746,22 @@ var __webpack_modules__ = {
|
|
|
4356
3746
|
#options;
|
|
4357
3747
|
#toString;
|
|
4358
3748
|
#emptyExt = false;
|
|
3749
|
+
id = ++ID;
|
|
3750
|
+
get depth() {
|
|
3751
|
+
return (this.#parent?.depth ?? -1) + 1;
|
|
3752
|
+
}
|
|
3753
|
+
[Symbol.for('nodejs.util.inspect.custom')]() {
|
|
3754
|
+
return {
|
|
3755
|
+
'@@type': 'AST',
|
|
3756
|
+
id: this.id,
|
|
3757
|
+
type: this.type,
|
|
3758
|
+
root: this.#root.id,
|
|
3759
|
+
parent: this.#parent?.id,
|
|
3760
|
+
depth: this.depth,
|
|
3761
|
+
partsLength: this.#parts.length,
|
|
3762
|
+
parts: this.#parts
|
|
3763
|
+
};
|
|
3764
|
+
}
|
|
4359
3765
|
constructor(type, parent, options = {}){
|
|
4360
3766
|
this.type = type;
|
|
4361
3767
|
if (type) this.#hasMagic = true;
|
|
@@ -4374,9 +3780,7 @@ var __webpack_modules__ = {
|
|
|
4374
3780
|
return this.#hasMagic;
|
|
4375
3781
|
}
|
|
4376
3782
|
toString() {
|
|
4377
|
-
|
|
4378
|
-
if (!this.type) return this.#toString = this.#parts.map((p)=>String(p)).join('');
|
|
4379
|
-
return this.#toString = this.type + '(' + this.#parts.map((p)=>String(p)).join('|') + ')';
|
|
3783
|
+
return void 0 !== this.#toString ? this.#toString : this.type ? this.#toString = this.type + '(' + this.#parts.map((p)=>String(p)).join('|') + ')' : this.#toString = this.#parts.map((p)=>String(p)).join('');
|
|
4380
3784
|
}
|
|
4381
3785
|
#fillNegs() {
|
|
4382
3786
|
if (this !== this.#root) throw new Error('should only call on root');
|
|
@@ -4401,7 +3805,7 @@ var __webpack_modules__ = {
|
|
|
4401
3805
|
}
|
|
4402
3806
|
push(...parts) {
|
|
4403
3807
|
for (const p of parts)if ('' !== p) {
|
|
4404
|
-
if ('string' != typeof p && !(p instanceof
|
|
3808
|
+
if ('string' != typeof p && !(p instanceof ast_a && p.#parent === this)) throw new Error('invalid part: ' + p);
|
|
4405
3809
|
this.#parts.push(p);
|
|
4406
3810
|
}
|
|
4407
3811
|
}
|
|
@@ -4421,7 +3825,7 @@ var __webpack_modules__ = {
|
|
|
4421
3825
|
const p = this.#parent;
|
|
4422
3826
|
for(let i = 0; i < this.#parentIndex; i++){
|
|
4423
3827
|
const pp = p.#parts[i];
|
|
4424
|
-
if (!(pp instanceof
|
|
3828
|
+
if (!(pp instanceof ast_a && '!' === pp.type)) return false;
|
|
4425
3829
|
}
|
|
4426
3830
|
return true;
|
|
4427
3831
|
}
|
|
@@ -4438,11 +3842,12 @@ var __webpack_modules__ = {
|
|
|
4438
3842
|
else this.push(part.clone(this));
|
|
4439
3843
|
}
|
|
4440
3844
|
clone(parent) {
|
|
4441
|
-
const c = new
|
|
3845
|
+
const c = new ast_a(this.type, parent);
|
|
4442
3846
|
for (const p of this.#parts)c.copyIn(p);
|
|
4443
3847
|
return c;
|
|
4444
3848
|
}
|
|
4445
|
-
static #parseAST(str, ast, pos, opt) {
|
|
3849
|
+
static #parseAST(str, ast, pos, opt, extDepth) {
|
|
3850
|
+
const maxDepth = opt.maxExtglobRecursion ?? 2;
|
|
4446
3851
|
let escaping = false;
|
|
4447
3852
|
let inBrace = false;
|
|
4448
3853
|
let braceStart = -1;
|
|
@@ -4471,11 +3876,12 @@ var __webpack_modules__ = {
|
|
|
4471
3876
|
acc += c;
|
|
4472
3877
|
continue;
|
|
4473
3878
|
}
|
|
4474
|
-
|
|
3879
|
+
const doRecurse = !opt.noext && isExtglobType(c) && '(' === str.charAt(i) && extDepth <= maxDepth;
|
|
3880
|
+
if (doRecurse) {
|
|
4475
3881
|
ast.push(acc);
|
|
4476
3882
|
acc = '';
|
|
4477
|
-
const ext = new
|
|
4478
|
-
i =
|
|
3883
|
+
const ext = new ast_a(c, ast);
|
|
3884
|
+
i = ast_a.#parseAST(str, ext, i, opt, extDepth + 1);
|
|
4479
3885
|
ast.push(ext);
|
|
4480
3886
|
continue;
|
|
4481
3887
|
}
|
|
@@ -4485,7 +3891,7 @@ var __webpack_modules__ = {
|
|
|
4485
3891
|
return i;
|
|
4486
3892
|
}
|
|
4487
3893
|
let i = pos + 1;
|
|
4488
|
-
let part = new
|
|
3894
|
+
let part = new ast_a(null, ast);
|
|
4489
3895
|
const parts = [];
|
|
4490
3896
|
let acc = '';
|
|
4491
3897
|
while(i < str.length){
|
|
@@ -4509,19 +3915,21 @@ var __webpack_modules__ = {
|
|
|
4509
3915
|
acc += c;
|
|
4510
3916
|
continue;
|
|
4511
3917
|
}
|
|
4512
|
-
|
|
3918
|
+
const doRecurse = !opt.noext && isExtglobType(c) && '(' === str.charAt(i) && (extDepth <= maxDepth || ast && ast.#canAdoptType(c));
|
|
3919
|
+
if (doRecurse) {
|
|
3920
|
+
const depthAdd = ast && ast.#canAdoptType(c) ? 0 : 1;
|
|
4513
3921
|
part.push(acc);
|
|
4514
3922
|
acc = '';
|
|
4515
|
-
const ext = new
|
|
3923
|
+
const ext = new ast_a(c, part);
|
|
4516
3924
|
part.push(ext);
|
|
4517
|
-
i =
|
|
3925
|
+
i = ast_a.#parseAST(str, ext, i, opt, extDepth + depthAdd);
|
|
4518
3926
|
continue;
|
|
4519
3927
|
}
|
|
4520
3928
|
if ('|' === c) {
|
|
4521
3929
|
part.push(acc);
|
|
4522
3930
|
acc = '';
|
|
4523
3931
|
parts.push(part);
|
|
4524
|
-
part = new
|
|
3932
|
+
part = new ast_a(null, ast);
|
|
4525
3933
|
continue;
|
|
4526
3934
|
}
|
|
4527
3935
|
if (')' === c) {
|
|
@@ -4540,9 +3948,55 @@ var __webpack_modules__ = {
|
|
|
4540
3948
|
];
|
|
4541
3949
|
return i;
|
|
4542
3950
|
}
|
|
3951
|
+
#canAdoptWithSpace(child) {
|
|
3952
|
+
return this.#canAdopt(child, adoptionWithSpaceMap);
|
|
3953
|
+
}
|
|
3954
|
+
#canAdopt(child, map = adoptionMap) {
|
|
3955
|
+
if (!child || 'object' != typeof child || null !== child.type || 1 !== child.#parts.length || null === this.type) return false;
|
|
3956
|
+
const gc = child.#parts[0];
|
|
3957
|
+
if (!gc || 'object' != typeof gc || null === gc.type) return false;
|
|
3958
|
+
return this.#canAdoptType(gc.type, map);
|
|
3959
|
+
}
|
|
3960
|
+
#canAdoptType(c, map = adoptionAnyMap) {
|
|
3961
|
+
return !!map.get(this.type)?.includes(c);
|
|
3962
|
+
}
|
|
3963
|
+
#adoptWithSpace(child, index) {
|
|
3964
|
+
const gc = child.#parts[0];
|
|
3965
|
+
const blank = new ast_a(null, gc, this.options);
|
|
3966
|
+
blank.#parts.push('');
|
|
3967
|
+
gc.push(blank);
|
|
3968
|
+
this.#adopt(child, index);
|
|
3969
|
+
}
|
|
3970
|
+
#adopt(child, index) {
|
|
3971
|
+
const gc = child.#parts[0];
|
|
3972
|
+
this.#parts.splice(index, 1, ...gc.#parts);
|
|
3973
|
+
for (const p of gc.#parts)if ('object' == typeof p) p.#parent = this;
|
|
3974
|
+
this.#toString = void 0;
|
|
3975
|
+
}
|
|
3976
|
+
#canUsurpType(c) {
|
|
3977
|
+
const m = usurpMap.get(this.type);
|
|
3978
|
+
return !!m?.has(c);
|
|
3979
|
+
}
|
|
3980
|
+
#canUsurp(child) {
|
|
3981
|
+
if (!child || 'object' != typeof child || null !== child.type || 1 !== child.#parts.length || null === this.type || 1 !== this.#parts.length) return false;
|
|
3982
|
+
const gc = child.#parts[0];
|
|
3983
|
+
if (!gc || 'object' != typeof gc || null === gc.type) return false;
|
|
3984
|
+
return this.#canUsurpType(gc.type);
|
|
3985
|
+
}
|
|
3986
|
+
#usurp(child) {
|
|
3987
|
+
const m = usurpMap.get(this.type);
|
|
3988
|
+
const gc = child.#parts[0];
|
|
3989
|
+
const nt = m?.get(gc.type);
|
|
3990
|
+
if (!nt) return false;
|
|
3991
|
+
this.#parts = gc.#parts;
|
|
3992
|
+
for (const p of this.#parts)if ('object' == typeof p) p.#parent = this;
|
|
3993
|
+
this.type = nt;
|
|
3994
|
+
this.#toString = void 0;
|
|
3995
|
+
this.#emptyExt = false;
|
|
3996
|
+
}
|
|
4543
3997
|
static fromGlob(pattern, options = {}) {
|
|
4544
|
-
const ast = new
|
|
4545
|
-
|
|
3998
|
+
const ast = new ast_a(null, void 0, options);
|
|
3999
|
+
ast_a.#parseAST(pattern, ast, 0, options, 0);
|
|
4546
4000
|
return ast;
|
|
4547
4001
|
}
|
|
4548
4002
|
toMMPattern() {
|
|
@@ -4562,11 +4016,14 @@ var __webpack_modules__ = {
|
|
|
4562
4016
|
}
|
|
4563
4017
|
toRegExpSource(allowDot) {
|
|
4564
4018
|
const dot = allowDot ?? !!this.#options.dot;
|
|
4565
|
-
if (this.#root === this)
|
|
4566
|
-
|
|
4567
|
-
|
|
4019
|
+
if (this.#root === this) {
|
|
4020
|
+
this.#flatten();
|
|
4021
|
+
this.#fillNegs();
|
|
4022
|
+
}
|
|
4023
|
+
if (!isExtglobAST(this)) {
|
|
4024
|
+
const noEmpty = this.isStart() && this.isEnd() && !this.#parts.some((s)=>'string' != typeof s);
|
|
4568
4025
|
const src = this.#parts.map((p)=>{
|
|
4569
|
-
const [re, _, hasMagic, uflag] = 'string' == typeof p ?
|
|
4026
|
+
const [re, _, hasMagic, uflag] = 'string' == typeof p ? ast_a.#parseGlob(p, this.#hasMagic, noEmpty) : p.toRegExpSource(allowDot);
|
|
4570
4027
|
this.#hasMagic = this.#hasMagic || hasMagic;
|
|
4571
4028
|
this.#uflag = this.#uflag || uflag;
|
|
4572
4029
|
return re;
|
|
@@ -4598,11 +4055,12 @@ var __webpack_modules__ = {
|
|
|
4598
4055
|
let body = this.#partsToRegExp(dot);
|
|
4599
4056
|
if (this.isStart() && this.isEnd() && !body && '!' !== this.type) {
|
|
4600
4057
|
const s = this.toString();
|
|
4601
|
-
|
|
4058
|
+
const me = this;
|
|
4059
|
+
me.#parts = [
|
|
4602
4060
|
s
|
|
4603
4061
|
];
|
|
4604
|
-
|
|
4605
|
-
|
|
4062
|
+
me.type = null;
|
|
4063
|
+
me.#hasMagic = void 0;
|
|
4606
4064
|
return [
|
|
4607
4065
|
s,
|
|
4608
4066
|
unescape_unescape(this.toString()),
|
|
@@ -4626,6 +4084,32 @@ var __webpack_modules__ = {
|
|
|
4626
4084
|
this.#uflag
|
|
4627
4085
|
];
|
|
4628
4086
|
}
|
|
4087
|
+
#flatten() {
|
|
4088
|
+
if (isExtglobAST(this)) {
|
|
4089
|
+
let iterations = 0;
|
|
4090
|
+
let done = false;
|
|
4091
|
+
do {
|
|
4092
|
+
done = true;
|
|
4093
|
+
for(let i = 0; i < this.#parts.length; i++){
|
|
4094
|
+
const c = this.#parts[i];
|
|
4095
|
+
if ('object' == typeof c) {
|
|
4096
|
+
c.#flatten();
|
|
4097
|
+
if (this.#canAdopt(c)) {
|
|
4098
|
+
done = false;
|
|
4099
|
+
this.#adopt(c, i);
|
|
4100
|
+
} else if (this.#canAdoptWithSpace(c)) {
|
|
4101
|
+
done = false;
|
|
4102
|
+
this.#adoptWithSpace(c, i);
|
|
4103
|
+
} else if (this.#canUsurp(c)) {
|
|
4104
|
+
done = false;
|
|
4105
|
+
this.#usurp(c);
|
|
4106
|
+
}
|
|
4107
|
+
}
|
|
4108
|
+
}
|
|
4109
|
+
}while (!done && ++iterations < 10);
|
|
4110
|
+
} else for (const p of this.#parts)if ('object' == typeof p) p.#flatten();
|
|
4111
|
+
this.#toString = void 0;
|
|
4112
|
+
}
|
|
4629
4113
|
#partsToRegExp(dot) {
|
|
4630
4114
|
return this.#parts.map((p)=>{
|
|
4631
4115
|
if ('string' == typeof p) throw new Error('string type in extglob ast??');
|
|
@@ -4638,6 +4122,7 @@ var __webpack_modules__ = {
|
|
|
4638
4122
|
let escaping = false;
|
|
4639
4123
|
let re = '';
|
|
4640
4124
|
let uflag = false;
|
|
4125
|
+
let inStar = false;
|
|
4641
4126
|
for(let i = 0; i < glob.length; i++){
|
|
4642
4127
|
const c = glob.charAt(i);
|
|
4643
4128
|
if (escaping) {
|
|
@@ -4645,6 +4130,14 @@ var __webpack_modules__ = {
|
|
|
4645
4130
|
re += (reSpecials.has(c) ? '\\' : '') + c;
|
|
4646
4131
|
continue;
|
|
4647
4132
|
}
|
|
4133
|
+
if ('*' === c) {
|
|
4134
|
+
if (inStar) continue;
|
|
4135
|
+
inStar = true;
|
|
4136
|
+
re += noEmpty && /^[*]+$/.test(glob) ? starNoEmpty : star;
|
|
4137
|
+
hasMagic = true;
|
|
4138
|
+
continue;
|
|
4139
|
+
}
|
|
4140
|
+
inStar = false;
|
|
4648
4141
|
if ('\\' === c) {
|
|
4649
4142
|
if (i === glob.length - 1) re += '\\\\';
|
|
4650
4143
|
else escaping = true;
|
|
@@ -4660,12 +4153,6 @@ var __webpack_modules__ = {
|
|
|
4660
4153
|
continue;
|
|
4661
4154
|
}
|
|
4662
4155
|
}
|
|
4663
|
-
if ('*' === c) {
|
|
4664
|
-
if (noEmpty && '*' === glob) re += starNoEmpty;
|
|
4665
|
-
else re += star;
|
|
4666
|
-
hasMagic = true;
|
|
4667
|
-
continue;
|
|
4668
|
-
}
|
|
4669
4156
|
if ('?' === c) {
|
|
4670
4157
|
re += qmark;
|
|
4671
4158
|
hasMagic = true;
|
|
@@ -4681,13 +4168,17 @@ var __webpack_modules__ = {
|
|
|
4681
4168
|
];
|
|
4682
4169
|
}
|
|
4683
4170
|
}
|
|
4684
|
-
|
|
4171
|
+
ast_a = ast_AST;
|
|
4172
|
+
const escape_escape = (s, { windowsPathsNoEscape = false, magicalBraces = false } = {})=>{
|
|
4173
|
+
if (magicalBraces) return windowsPathsNoEscape ? s.replace(/[?*()[\]{}]/g, '[$&]') : s.replace(/[?*()[\]\\{}]/g, '\\$&');
|
|
4174
|
+
return windowsPathsNoEscape ? s.replace(/[?*()[\]]/g, '[$&]') : s.replace(/[?*()[\]\\]/g, '\\$&');
|
|
4175
|
+
};
|
|
4685
4176
|
const minimatch = (p, pattern, options = {})=>{
|
|
4686
4177
|
assertValidPattern(pattern);
|
|
4687
4178
|
if (!options.nocomment && '#' === pattern.charAt(0)) return false;
|
|
4688
4179
|
return new esm_Minimatch(pattern, options).match(p);
|
|
4689
4180
|
};
|
|
4690
|
-
const starDotExtRE = /^\*+([
|
|
4181
|
+
const starDotExtRE = /^\*+([^+@!?*[(]*)$/;
|
|
4691
4182
|
const starDotExtTest = (ext)=>(f)=>!f.startsWith('.') && f.endsWith(ext);
|
|
4692
4183
|
const starDotExtTestDot = (ext)=>(f)=>f.endsWith(ext);
|
|
4693
4184
|
const starDotExtTestNocase = (ext)=>{
|
|
@@ -4706,7 +4197,7 @@ var __webpack_modules__ = {
|
|
|
4706
4197
|
const starRE = /^\*+$/;
|
|
4707
4198
|
const starTest = (f)=>0 !== f.length && !f.startsWith('.');
|
|
4708
4199
|
const starTestDot = (f)=>0 !== f.length && '.' !== f && '..' !== f;
|
|
4709
|
-
const qmarksRE = /^\?+([
|
|
4200
|
+
const qmarksRE = /^\?+([^+@!?*[(]*)?$/;
|
|
4710
4201
|
const qmarksTestNocase = ([$0, ext = ''])=>{
|
|
4711
4202
|
const noext = qmarksTestNoExt([
|
|
4712
4203
|
$0
|
|
@@ -4801,7 +4292,9 @@ var __webpack_modules__ = {
|
|
|
4801
4292
|
if (options.nobrace || !/\{(?:(?!\{).)*\}/.test(pattern)) return [
|
|
4802
4293
|
pattern
|
|
4803
4294
|
];
|
|
4804
|
-
return
|
|
4295
|
+
return expand(pattern, {
|
|
4296
|
+
max: options.braceExpandMax
|
|
4297
|
+
});
|
|
4805
4298
|
};
|
|
4806
4299
|
minimatch.braceExpand = braceExpand;
|
|
4807
4300
|
const makeRe = (pattern, options = {})=>new esm_Minimatch(pattern, options).makeRe();
|
|
@@ -4832,15 +4325,18 @@ var __webpack_modules__ = {
|
|
|
4832
4325
|
isWindows;
|
|
4833
4326
|
platform;
|
|
4834
4327
|
windowsNoMagicRoot;
|
|
4328
|
+
maxGlobstarRecursion;
|
|
4835
4329
|
regexp;
|
|
4836
4330
|
constructor(pattern, options = {}){
|
|
4837
4331
|
assertValidPattern(pattern);
|
|
4838
4332
|
options = options || {};
|
|
4839
4333
|
this.options = options;
|
|
4334
|
+
this.maxGlobstarRecursion = options.maxGlobstarRecursion ?? 200;
|
|
4840
4335
|
this.pattern = pattern;
|
|
4841
4336
|
this.platform = options.platform || defaultPlatform;
|
|
4842
4337
|
this.isWindows = 'win32' === this.platform;
|
|
4843
|
-
|
|
4338
|
+
const awe = "allowWindowsEscape";
|
|
4339
|
+
this.windowsPathsNoEscape = !!options.windowsPathsNoEscape || false === options[awe];
|
|
4844
4340
|
if (this.windowsPathsNoEscape) this.pattern = this.pattern.replace(/\\/g, '/');
|
|
4845
4341
|
this.preserveMultipleSlashes = !!options.preserveMultipleSlashes;
|
|
4846
4342
|
this.regexp = null;
|
|
@@ -4907,7 +4403,7 @@ var __webpack_modules__ = {
|
|
|
4907
4403
|
}
|
|
4908
4404
|
preprocess(globParts) {
|
|
4909
4405
|
if (this.options.noglobstar) {
|
|
4910
|
-
for(
|
|
4406
|
+
for (const partset of globParts)for(let j = 0; j < partset.length; j++)if ('**' === partset[j]) partset[j] = '*';
|
|
4911
4407
|
}
|
|
4912
4408
|
const { optimizationLevel = 1 } = this.options;
|
|
4913
4409
|
if (optimizationLevel >= 2) {
|
|
@@ -4970,7 +4466,7 @@ var __webpack_modules__ = {
|
|
|
4970
4466
|
let dd = 0;
|
|
4971
4467
|
while(-1 !== (dd = parts.indexOf('..', dd + 1))){
|
|
4972
4468
|
const p = parts[dd - 1];
|
|
4973
|
-
if (p && '.' !== p && '..' !== p && '**' !== p) {
|
|
4469
|
+
if (p && '.' !== p && '..' !== p && '**' !== p && !(this.isWindows && /^[a-z]:$/i.test(p))) {
|
|
4974
4470
|
didSomething = true;
|
|
4975
4471
|
parts.splice(dd - 1, 2);
|
|
4976
4472
|
dd -= 2;
|
|
@@ -5092,7 +4588,8 @@ var __webpack_modules__ = {
|
|
|
5092
4588
|
this.negate = negate;
|
|
5093
4589
|
}
|
|
5094
4590
|
matchOne(file, pattern, partial = false) {
|
|
5095
|
-
|
|
4591
|
+
let fileStartIndex = 0;
|
|
4592
|
+
let patternStartIndex = 0;
|
|
5096
4593
|
if (this.isWindows) {
|
|
5097
4594
|
const fileDrive = 'string' == typeof file[0] && /^[a-z]:$/i.test(file[0]);
|
|
5098
4595
|
const fileUNC = !fileDrive && '' === file[0] && '' === file[1] && '?' === file[2] && /^[a-z]:$/i.test(file[3]);
|
|
@@ -5107,57 +4604,116 @@ var __webpack_modules__ = {
|
|
|
5107
4604
|
];
|
|
5108
4605
|
if (fd.toLowerCase() === pd.toLowerCase()) {
|
|
5109
4606
|
pattern[pdi] = fd;
|
|
5110
|
-
|
|
5111
|
-
|
|
4607
|
+
patternStartIndex = pdi;
|
|
4608
|
+
fileStartIndex = fdi;
|
|
5112
4609
|
}
|
|
5113
4610
|
}
|
|
5114
4611
|
}
|
|
5115
4612
|
const { optimizationLevel = 1 } = this.options;
|
|
5116
4613
|
if (optimizationLevel >= 2) file = this.levelTwoFileOptimize(file);
|
|
5117
|
-
|
|
5118
|
-
|
|
5119
|
-
|
|
5120
|
-
|
|
5121
|
-
|
|
5122
|
-
|
|
4614
|
+
if (pattern.includes(GLOBSTAR)) return this.#matchGlobstar(file, pattern, partial, fileStartIndex, patternStartIndex);
|
|
4615
|
+
return this.#matchOne(file, pattern, partial, fileStartIndex, patternStartIndex);
|
|
4616
|
+
}
|
|
4617
|
+
#matchGlobstar(file, pattern, partial, fileIndex, patternIndex) {
|
|
4618
|
+
const firstgs = pattern.indexOf(GLOBSTAR, patternIndex);
|
|
4619
|
+
const lastgs = pattern.lastIndexOf(GLOBSTAR);
|
|
4620
|
+
const [head, body, tail] = partial ? [
|
|
4621
|
+
pattern.slice(patternIndex, firstgs),
|
|
4622
|
+
pattern.slice(firstgs + 1),
|
|
4623
|
+
[]
|
|
4624
|
+
] : [
|
|
4625
|
+
pattern.slice(patternIndex, firstgs),
|
|
4626
|
+
pattern.slice(firstgs + 1, lastgs),
|
|
4627
|
+
pattern.slice(lastgs + 1)
|
|
4628
|
+
];
|
|
4629
|
+
if (head.length) {
|
|
4630
|
+
const fileHead = file.slice(fileIndex, fileIndex + head.length);
|
|
4631
|
+
if (!this.#matchOne(fileHead, head, partial, 0, 0)) return false;
|
|
4632
|
+
fileIndex += head.length;
|
|
4633
|
+
patternIndex += head.length;
|
|
4634
|
+
}
|
|
4635
|
+
let fileTailMatch = 0;
|
|
4636
|
+
if (tail.length) {
|
|
4637
|
+
if (tail.length + fileIndex > file.length) return false;
|
|
4638
|
+
let tailStart = file.length - tail.length;
|
|
4639
|
+
if (this.#matchOne(file, tail, partial, tailStart, 0)) fileTailMatch = tail.length;
|
|
4640
|
+
else {
|
|
4641
|
+
if ('' !== file[file.length - 1] || fileIndex + tail.length === file.length) return false;
|
|
4642
|
+
tailStart--;
|
|
4643
|
+
if (!this.#matchOne(file, tail, partial, tailStart, 0)) return false;
|
|
4644
|
+
fileTailMatch = tail.length + 1;
|
|
4645
|
+
}
|
|
4646
|
+
}
|
|
4647
|
+
if (!body.length) {
|
|
4648
|
+
let sawSome = !!fileTailMatch;
|
|
4649
|
+
for(let i = fileIndex; i < file.length - fileTailMatch; i++){
|
|
4650
|
+
const f = String(file[i]);
|
|
4651
|
+
sawSome = true;
|
|
4652
|
+
if ('.' === f || '..' === f || !this.options.dot && f.startsWith('.')) return false;
|
|
4653
|
+
}
|
|
4654
|
+
return partial || sawSome;
|
|
4655
|
+
}
|
|
4656
|
+
const bodySegments = [
|
|
4657
|
+
[
|
|
4658
|
+
[],
|
|
4659
|
+
0
|
|
4660
|
+
]
|
|
4661
|
+
];
|
|
4662
|
+
let currentBody = bodySegments[0];
|
|
4663
|
+
let nonGsParts = 0;
|
|
4664
|
+
const nonGsPartsSums = [
|
|
4665
|
+
0
|
|
4666
|
+
];
|
|
4667
|
+
for (const b of body)if (b === GLOBSTAR) {
|
|
4668
|
+
nonGsPartsSums.push(nonGsParts);
|
|
4669
|
+
currentBody = [
|
|
4670
|
+
[],
|
|
4671
|
+
0
|
|
4672
|
+
];
|
|
4673
|
+
bodySegments.push(currentBody);
|
|
4674
|
+
} else {
|
|
4675
|
+
currentBody[0].push(b);
|
|
4676
|
+
nonGsParts++;
|
|
4677
|
+
}
|
|
4678
|
+
let i = bodySegments.length - 1;
|
|
4679
|
+
const fileLength = file.length - fileTailMatch;
|
|
4680
|
+
for (const b of bodySegments)b[1] = fileLength - (nonGsPartsSums[i--] + b[0].length);
|
|
4681
|
+
return !!this.#matchGlobStarBodySections(file, bodySegments, fileIndex, 0, partial, 0, !!fileTailMatch);
|
|
4682
|
+
}
|
|
4683
|
+
#matchGlobStarBodySections(file, bodySegments, fileIndex, bodyIndex, partial, globStarDepth, sawTail) {
|
|
4684
|
+
const bs = bodySegments[bodyIndex];
|
|
4685
|
+
if (!bs) {
|
|
4686
|
+
for(let i = fileIndex; i < file.length; i++){
|
|
4687
|
+
sawTail = true;
|
|
4688
|
+
const f = file[i];
|
|
4689
|
+
if ('.' === f || '..' === f || !this.options.dot && f.startsWith('.')) return false;
|
|
4690
|
+
}
|
|
4691
|
+
return sawTail;
|
|
4692
|
+
}
|
|
4693
|
+
const [body, after] = bs;
|
|
4694
|
+
while(fileIndex <= after){
|
|
4695
|
+
const m = this.#matchOne(file.slice(0, fileIndex + body.length), body, partial, fileIndex, 0);
|
|
4696
|
+
if (m && globStarDepth < this.maxGlobstarRecursion) {
|
|
4697
|
+
const sub = this.#matchGlobStarBodySections(file, bodySegments, fileIndex + body.length, bodyIndex + 1, partial, globStarDepth + 1, sawTail);
|
|
4698
|
+
if (false !== sub) return sub;
|
|
4699
|
+
}
|
|
4700
|
+
const f = file[fileIndex];
|
|
4701
|
+
if ('.' === f || '..' === f || !this.options.dot && f.startsWith('.')) return false;
|
|
4702
|
+
fileIndex++;
|
|
4703
|
+
}
|
|
4704
|
+
return partial || null;
|
|
4705
|
+
}
|
|
4706
|
+
#matchOne(file, pattern, partial, fileIndex, patternIndex) {
|
|
4707
|
+
let fi;
|
|
4708
|
+
let pi;
|
|
4709
|
+
let pl;
|
|
4710
|
+
let fl;
|
|
4711
|
+
for(fi = fileIndex, pi = patternIndex, fl = file.length, pl = pattern.length; fi < fl && pi < pl; fi++, pi++){
|
|
5123
4712
|
this.debug('matchOne loop');
|
|
5124
|
-
|
|
5125
|
-
|
|
4713
|
+
let p = pattern[pi];
|
|
4714
|
+
let f = file[fi];
|
|
5126
4715
|
this.debug(pattern, p, f);
|
|
5127
|
-
if (false === p) return false;
|
|
5128
|
-
if (p === GLOBSTAR) {
|
|
5129
|
-
this.debug('GLOBSTAR', [
|
|
5130
|
-
pattern,
|
|
5131
|
-
p,
|
|
5132
|
-
f
|
|
5133
|
-
]);
|
|
5134
|
-
var fr = fi;
|
|
5135
|
-
var pr = pi + 1;
|
|
5136
|
-
if (pr === pl) {
|
|
5137
|
-
this.debug('** at the end');
|
|
5138
|
-
for(; fi < fl; fi++)if ('.' === file[fi] || '..' === file[fi] || !options.dot && '.' === file[fi].charAt(0)) return false;
|
|
5139
|
-
return true;
|
|
5140
|
-
}
|
|
5141
|
-
while(fr < fl){
|
|
5142
|
-
var swallowee = file[fr];
|
|
5143
|
-
this.debug('\nglobstar while', file, fr, pattern, pr, swallowee);
|
|
5144
|
-
if (this.matchOne(file.slice(fr), pattern.slice(pr), partial)) {
|
|
5145
|
-
this.debug('globstar found match!', fr, fl, swallowee);
|
|
5146
|
-
return true;
|
|
5147
|
-
}
|
|
5148
|
-
if ('.' === swallowee || '..' === swallowee || !options.dot && '.' === swallowee.charAt(0)) {
|
|
5149
|
-
this.debug('dot detected!', file, fr, pattern, pr);
|
|
5150
|
-
break;
|
|
5151
|
-
}
|
|
5152
|
-
this.debug('globstar swallow a segment, and continue');
|
|
5153
|
-
fr++;
|
|
5154
|
-
}
|
|
5155
|
-
if (partial) {
|
|
5156
|
-
this.debug('\n>>> no match, partial?', file, fr, pattern, pr);
|
|
5157
|
-
if (fr === fl) return true;
|
|
5158
|
-
}
|
|
5159
|
-
return false;
|
|
5160
|
-
}
|
|
4716
|
+
if (false === p || p === GLOBSTAR) return false;
|
|
5161
4717
|
let hit;
|
|
5162
4718
|
if ('string' == typeof p) {
|
|
5163
4719
|
hit = f === p;
|
|
@@ -5217,13 +4773,19 @@ var __webpack_modules__ = {
|
|
|
5217
4773
|
if (p !== GLOBSTAR || prev === GLOBSTAR) return;
|
|
5218
4774
|
if (void 0 === prev) if (void 0 !== next && next !== GLOBSTAR) pp[i + 1] = '(?:\\/|' + twoStar + '\\/)?' + next;
|
|
5219
4775
|
else pp[i] = twoStar;
|
|
5220
|
-
else if (void 0 === next) pp[i - 1] = prev + '(
|
|
4776
|
+
else if (void 0 === next) pp[i - 1] = prev + '(?:\\/|\\/' + twoStar + ')?';
|
|
5221
4777
|
else if (next !== GLOBSTAR) {
|
|
5222
4778
|
pp[i - 1] = prev + '(?:\\/|\\/' + twoStar + '\\/)' + next;
|
|
5223
4779
|
pp[i + 1] = GLOBSTAR;
|
|
5224
4780
|
}
|
|
5225
4781
|
});
|
|
5226
|
-
|
|
4782
|
+
const filtered = pp.filter((p)=>p !== GLOBSTAR);
|
|
4783
|
+
if (this.partial && filtered.length >= 1) {
|
|
4784
|
+
const prefixes = [];
|
|
4785
|
+
for(let i = 1; i <= filtered.length; i++)prefixes.push(filtered.slice(0, i).join('/'));
|
|
4786
|
+
return '(?:' + prefixes.join('|') + ')';
|
|
4787
|
+
}
|
|
4788
|
+
return filtered.join('/');
|
|
5227
4789
|
}).join('|');
|
|
5228
4790
|
const [open, close] = set.length > 1 ? [
|
|
5229
4791
|
'(?:',
|
|
@@ -5233,19 +4795,20 @@ var __webpack_modules__ = {
|
|
|
5233
4795
|
''
|
|
5234
4796
|
];
|
|
5235
4797
|
re = '^' + open + re + close + '$';
|
|
4798
|
+
if (this.partial) re = '^(?:\\/|' + open + re.slice(1, -1) + close + ')$';
|
|
5236
4799
|
if (this.negate) re = '^(?!' + re + ').+$';
|
|
5237
4800
|
try {
|
|
5238
4801
|
this.regexp = new RegExp(re, [
|
|
5239
4802
|
...flags
|
|
5240
4803
|
].join(''));
|
|
5241
|
-
} catch
|
|
4804
|
+
} catch {
|
|
5242
4805
|
this.regexp = false;
|
|
5243
4806
|
}
|
|
5244
4807
|
return this.regexp;
|
|
5245
4808
|
}
|
|
5246
4809
|
slashSplit(p) {
|
|
5247
4810
|
if (this.preserveMultipleSlashes) return p.split('/');
|
|
5248
|
-
if (this.isWindows && /^\/\/[
|
|
4811
|
+
if (this.isWindows && /^\/\/[^/]+/.test(p)) return [
|
|
5249
4812
|
'',
|
|
5250
4813
|
...p.split(/\/+/)
|
|
5251
4814
|
];
|
|
@@ -5264,8 +4827,7 @@ var __webpack_modules__ = {
|
|
|
5264
4827
|
this.debug(this.pattern, 'set', set);
|
|
5265
4828
|
let filename = ff[ff.length - 1];
|
|
5266
4829
|
if (!filename) for(let i = ff.length - 2; !filename && i >= 0; i--)filename = ff[i];
|
|
5267
|
-
for(
|
|
5268
|
-
const pattern = set[i];
|
|
4830
|
+
for (const pattern of set){
|
|
5269
4831
|
let file = ff;
|
|
5270
4832
|
if (options.matchBase && 1 === pattern.length) file = [
|
|
5271
4833
|
filename
|
|
@@ -5287,86 +4849,48 @@ var __webpack_modules__ = {
|
|
|
5287
4849
|
minimatch.Minimatch = esm_Minimatch;
|
|
5288
4850
|
minimatch.escape = escape_escape;
|
|
5289
4851
|
minimatch.unescape = unescape_unescape;
|
|
5290
|
-
|
|
5291
|
-
const
|
|
5292
|
-
|
|
5293
|
-
|
|
5294
|
-
|
|
5295
|
-
|
|
5296
|
-
|
|
5297
|
-
|
|
5298
|
-
|
|
5299
|
-
|
|
5300
|
-
AS = class {
|
|
5301
|
-
onabort;
|
|
5302
|
-
_onabort = [];
|
|
5303
|
-
reason;
|
|
5304
|
-
aborted = false;
|
|
5305
|
-
addEventListener(_, fn) {
|
|
5306
|
-
this._onabort.push(fn);
|
|
5307
|
-
}
|
|
5308
|
-
};
|
|
5309
|
-
AC = class {
|
|
5310
|
-
constructor(){
|
|
5311
|
-
warnACPolyfill();
|
|
5312
|
-
}
|
|
5313
|
-
signal = new AS();
|
|
5314
|
-
abort(reason) {
|
|
5315
|
-
if (this.signal.aborted) return;
|
|
5316
|
-
this.signal.reason = reason;
|
|
5317
|
-
this.signal.aborted = true;
|
|
5318
|
-
for (const fn of this.signal._onabort)fn(reason);
|
|
5319
|
-
this.signal.onabort?.(reason);
|
|
5320
|
-
}
|
|
5321
|
-
};
|
|
5322
|
-
let printACPolyfillWarning = PROCESS.env?.LRU_CACHE_IGNORE_AC_WARNING !== '1';
|
|
5323
|
-
const warnACPolyfill = ()=>{
|
|
5324
|
-
if (!printACPolyfillWarning) return;
|
|
5325
|
-
printACPolyfillWarning = false;
|
|
5326
|
-
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);
|
|
5327
|
-
};
|
|
5328
|
-
}
|
|
5329
|
-
const shouldWarn = (code)=>!warned.has(code);
|
|
5330
|
-
Symbol('type');
|
|
5331
|
-
const isPosInt = (n)=>n && n === Math.floor(n) && n > 0 && isFinite(n);
|
|
5332
|
-
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;
|
|
5333
|
-
class ZeroArray extends Array {
|
|
5334
|
-
constructor(size){
|
|
5335
|
-
super(size);
|
|
5336
|
-
this.fill(0);
|
|
5337
|
-
}
|
|
5338
|
-
}
|
|
5339
|
-
class Stack {
|
|
4852
|
+
var external_node_url_ = __webpack_require__("node:url");
|
|
4853
|
+
const external_node_diagnostics_channel_namespaceObject = require("node:diagnostics_channel");
|
|
4854
|
+
var S = (0, external_node_diagnostics_channel_namespaceObject.channel)("lru-cache:metrics"), W = (0, external_node_diagnostics_channel_namespaceObject.tracingChannel)("lru-cache");
|
|
4855
|
+
var D = ()=>S.hasSubscribers || W.hasSubscribers, G = "object" == typeof performance && performance && "function" == typeof performance.now ? performance : Date, M = new Set, C = "object" == typeof process && process ? process : {}, P = (u, e1, t1, i)=>{
|
|
4856
|
+
"function" == typeof C.emitWarning ? C.emitWarning(u, e1, t1, i) : console.error(`[${t1}] ${e1}: ${u}`);
|
|
4857
|
+
}, H = (u)=>!M.has(u), F = (Symbol("type"), (u)=>!!u && u === Math.floor(u) && u > 0 && isFinite(u)), U = (u)=>F(u) ? u <= Math.pow(2, 8) ? Uint8Array : u <= Math.pow(2, 16) ? Uint16Array : u <= Math.pow(2, 32) ? Uint32Array : u <= Number.MAX_SAFE_INTEGER ? O : null : null, O = class extends Array {
|
|
4858
|
+
constructor(e1){
|
|
4859
|
+
super(e1), this.fill(0);
|
|
4860
|
+
}
|
|
4861
|
+
}, R = class u {
|
|
5340
4862
|
heap;
|
|
5341
4863
|
length;
|
|
5342
|
-
static #
|
|
5343
|
-
static create(
|
|
5344
|
-
|
|
5345
|
-
if (!
|
|
5346
|
-
|
|
5347
|
-
|
|
5348
|
-
|
|
5349
|
-
|
|
5350
|
-
|
|
5351
|
-
|
|
5352
|
-
|
|
5353
|
-
|
|
5354
|
-
|
|
5355
|
-
|
|
5356
|
-
push(n) {
|
|
5357
|
-
this.heap[this.length++] = n;
|
|
4864
|
+
static #o = !1;
|
|
4865
|
+
static create(e1) {
|
|
4866
|
+
let t1 = U(e1);
|
|
4867
|
+
if (!t1) return [];
|
|
4868
|
+
u.#o = !0;
|
|
4869
|
+
let i = new u(e1, t1);
|
|
4870
|
+
return u.#o = !1, i;
|
|
4871
|
+
}
|
|
4872
|
+
constructor(e1, t1){
|
|
4873
|
+
if (!u.#o) throw new TypeError("instantiate Stack using Stack.create(n)");
|
|
4874
|
+
this.heap = new t1(e1), this.length = 0;
|
|
4875
|
+
}
|
|
4876
|
+
push(e1) {
|
|
4877
|
+
this.heap[this.length++] = e1;
|
|
5358
4878
|
}
|
|
5359
4879
|
pop() {
|
|
5360
4880
|
return this.heap[--this.length];
|
|
5361
4881
|
}
|
|
5362
|
-
}
|
|
5363
|
-
|
|
5364
|
-
#
|
|
5365
|
-
#
|
|
5366
|
-
#
|
|
5367
|
-
#
|
|
5368
|
-
#
|
|
5369
|
-
#
|
|
4882
|
+
}, L = class u {
|
|
4883
|
+
#o;
|
|
4884
|
+
#u;
|
|
4885
|
+
#w;
|
|
4886
|
+
#D;
|
|
4887
|
+
#S;
|
|
4888
|
+
#M;
|
|
4889
|
+
#U;
|
|
4890
|
+
#m;
|
|
4891
|
+
get perf() {
|
|
4892
|
+
return this.#m;
|
|
4893
|
+
}
|
|
5370
4894
|
ttl;
|
|
5371
4895
|
ttlResolution;
|
|
5372
4896
|
ttlAutopurge;
|
|
@@ -5382,823 +4906,613 @@ var __webpack_modules__ = {
|
|
|
5382
4906
|
allowStaleOnFetchAbort;
|
|
5383
4907
|
allowStaleOnFetchRejection;
|
|
5384
4908
|
ignoreFetchAbort;
|
|
5385
|
-
#
|
|
5386
|
-
#
|
|
5387
|
-
#
|
|
5388
|
-
#
|
|
5389
|
-
#
|
|
5390
|
-
#
|
|
5391
|
-
#
|
|
5392
|
-
#
|
|
5393
|
-
#
|
|
5394
|
-
#
|
|
5395
|
-
#
|
|
5396
|
-
#
|
|
5397
|
-
#
|
|
5398
|
-
#
|
|
5399
|
-
#
|
|
5400
|
-
#
|
|
5401
|
-
#
|
|
5402
|
-
|
|
4909
|
+
#n;
|
|
4910
|
+
#b;
|
|
4911
|
+
#s;
|
|
4912
|
+
#i;
|
|
4913
|
+
#t;
|
|
4914
|
+
#a;
|
|
4915
|
+
#c;
|
|
4916
|
+
#l;
|
|
4917
|
+
#h;
|
|
4918
|
+
#y;
|
|
4919
|
+
#r;
|
|
4920
|
+
#_;
|
|
4921
|
+
#F;
|
|
4922
|
+
#d;
|
|
4923
|
+
#g;
|
|
4924
|
+
#T;
|
|
4925
|
+
#W;
|
|
4926
|
+
#f;
|
|
4927
|
+
#j;
|
|
4928
|
+
static unsafeExposeInternals(e1) {
|
|
5403
4929
|
return {
|
|
5404
|
-
starts:
|
|
5405
|
-
ttls:
|
|
5406
|
-
|
|
5407
|
-
|
|
5408
|
-
|
|
5409
|
-
|
|
5410
|
-
|
|
5411
|
-
|
|
4930
|
+
starts: e1.#F,
|
|
4931
|
+
ttls: e1.#d,
|
|
4932
|
+
autopurgeTimers: e1.#g,
|
|
4933
|
+
sizes: e1.#_,
|
|
4934
|
+
keyMap: e1.#s,
|
|
4935
|
+
keyList: e1.#i,
|
|
4936
|
+
valList: e1.#t,
|
|
4937
|
+
next: e1.#a,
|
|
4938
|
+
prev: e1.#c,
|
|
5412
4939
|
get head () {
|
|
5413
|
-
return
|
|
4940
|
+
return e1.#l;
|
|
5414
4941
|
},
|
|
5415
4942
|
get tail () {
|
|
5416
|
-
return
|
|
4943
|
+
return e1.#h;
|
|
5417
4944
|
},
|
|
5418
|
-
free:
|
|
5419
|
-
isBackgroundFetch: (
|
|
5420
|
-
backgroundFetch: (
|
|
5421
|
-
moveToTail: (
|
|
5422
|
-
indexes: (
|
|
5423
|
-
rindexes: (
|
|
5424
|
-
isStale: (
|
|
4945
|
+
free: e1.#y,
|
|
4946
|
+
isBackgroundFetch: (t1)=>e1.#e(t1),
|
|
4947
|
+
backgroundFetch: (t1, i, s, n)=>e1.#P(t1, i, s, n),
|
|
4948
|
+
moveToTail: (t1)=>e1.#L(t1),
|
|
4949
|
+
indexes: (t1)=>e1.#A(t1),
|
|
4950
|
+
rindexes: (t1)=>e1.#z(t1),
|
|
4951
|
+
isStale: (t1)=>e1.#p(t1)
|
|
5425
4952
|
};
|
|
5426
4953
|
}
|
|
5427
4954
|
get max() {
|
|
5428
|
-
return this.#
|
|
4955
|
+
return this.#o;
|
|
5429
4956
|
}
|
|
5430
4957
|
get maxSize() {
|
|
5431
|
-
return this.#
|
|
4958
|
+
return this.#u;
|
|
5432
4959
|
}
|
|
5433
4960
|
get calculatedSize() {
|
|
5434
|
-
return this.#
|
|
4961
|
+
return this.#b;
|
|
5435
4962
|
}
|
|
5436
4963
|
get size() {
|
|
5437
|
-
return this.#
|
|
4964
|
+
return this.#n;
|
|
5438
4965
|
}
|
|
5439
4966
|
get fetchMethod() {
|
|
5440
|
-
return this.#
|
|
4967
|
+
return this.#M;
|
|
5441
4968
|
}
|
|
5442
4969
|
get memoMethod() {
|
|
5443
|
-
return this.#
|
|
4970
|
+
return this.#U;
|
|
5444
4971
|
}
|
|
5445
4972
|
get dispose() {
|
|
5446
|
-
return this.#
|
|
4973
|
+
return this.#w;
|
|
5447
4974
|
}
|
|
5448
|
-
get
|
|
5449
|
-
return this.#
|
|
4975
|
+
get onInsert() {
|
|
4976
|
+
return this.#D;
|
|
5450
4977
|
}
|
|
5451
|
-
|
|
5452
|
-
|
|
5453
|
-
|
|
5454
|
-
|
|
5455
|
-
|
|
5456
|
-
|
|
5457
|
-
this.#
|
|
5458
|
-
|
|
5459
|
-
|
|
5460
|
-
if (this.sizeCalculation) {
|
|
5461
|
-
if (!this.#
|
|
5462
|
-
if (
|
|
5463
|
-
}
|
|
5464
|
-
if (void 0 !==
|
|
5465
|
-
this.#
|
|
5466
|
-
if (
|
|
5467
|
-
|
|
5468
|
-
this.#
|
|
5469
|
-
|
|
5470
|
-
this.#
|
|
5471
|
-
|
|
5472
|
-
|
|
5473
|
-
|
|
5474
|
-
|
|
5475
|
-
this
|
|
5476
|
-
|
|
5477
|
-
|
|
5478
|
-
|
|
5479
|
-
if (
|
|
5480
|
-
if (
|
|
5481
|
-
|
|
5482
|
-
|
|
5483
|
-
}
|
|
5484
|
-
|
|
5485
|
-
|
|
5486
|
-
|
|
5487
|
-
|
|
5488
|
-
|
|
5489
|
-
this
|
|
5490
|
-
this
|
|
5491
|
-
this.
|
|
5492
|
-
|
|
5493
|
-
|
|
5494
|
-
this
|
|
5495
|
-
|
|
5496
|
-
|
|
5497
|
-
|
|
5498
|
-
}
|
|
5499
|
-
if (!isPosInt(this.maxEntrySize)) throw new TypeError('maxEntrySize must be a positive integer if specified');
|
|
5500
|
-
this.#initializeSizeTracking();
|
|
5501
|
-
}
|
|
5502
|
-
this.allowStale = !!allowStale;
|
|
5503
|
-
this.noDeleteOnStaleGet = !!noDeleteOnStaleGet;
|
|
5504
|
-
this.updateAgeOnGet = !!updateAgeOnGet;
|
|
5505
|
-
this.updateAgeOnHas = !!updateAgeOnHas;
|
|
5506
|
-
this.ttlResolution = isPosInt(ttlResolution) || 0 === ttlResolution ? ttlResolution : 1;
|
|
5507
|
-
this.ttlAutopurge = !!ttlAutopurge;
|
|
5508
|
-
this.ttl = ttl || 0;
|
|
5509
|
-
if (this.ttl) {
|
|
5510
|
-
if (!isPosInt(this.ttl)) throw new TypeError('ttl must be a positive integer if specified');
|
|
5511
|
-
this.#initializeTTLTracking();
|
|
5512
|
-
}
|
|
5513
|
-
if (0 === this.#max && 0 === this.ttl && 0 === this.#maxSize) throw new TypeError('At least one of max, maxSize, or ttl is required');
|
|
5514
|
-
if (!this.ttlAutopurge && !this.#max && !this.#maxSize) {
|
|
5515
|
-
const code = 'LRU_CACHE_UNBOUNDED';
|
|
5516
|
-
if (shouldWarn(code)) {
|
|
5517
|
-
warned.add(code);
|
|
5518
|
-
const msg = "TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.";
|
|
5519
|
-
emitWarning(msg, 'UnboundedCacheWarning', code, LRUCache);
|
|
5520
|
-
}
|
|
5521
|
-
}
|
|
5522
|
-
}
|
|
5523
|
-
getRemainingTTL(key) {
|
|
5524
|
-
return this.#keyMap.has(key) ? 1 / 0 : 0;
|
|
5525
|
-
}
|
|
5526
|
-
#initializeTTLTracking() {
|
|
5527
|
-
const ttls = new ZeroArray(this.#max);
|
|
5528
|
-
const starts = new ZeroArray(this.#max);
|
|
5529
|
-
this.#ttls = ttls;
|
|
5530
|
-
this.#starts = starts;
|
|
5531
|
-
this.#setItemTTL = (index, ttl, start = perf.now())=>{
|
|
5532
|
-
starts[index] = 0 !== ttl ? start : 0;
|
|
5533
|
-
ttls[index] = ttl;
|
|
5534
|
-
if (0 !== ttl && this.ttlAutopurge) {
|
|
5535
|
-
const t1 = setTimeout(()=>{
|
|
5536
|
-
if (this.#isStale(index)) this.#delete(this.#keyList[index], 'expire');
|
|
5537
|
-
}, ttl + 1);
|
|
5538
|
-
if (t1.unref) t1.unref();
|
|
5539
|
-
}
|
|
5540
|
-
};
|
|
5541
|
-
this.#updateItemAge = (index)=>{
|
|
5542
|
-
starts[index] = 0 !== ttls[index] ? perf.now() : 0;
|
|
4978
|
+
get disposeAfter() {
|
|
4979
|
+
return this.#S;
|
|
4980
|
+
}
|
|
4981
|
+
constructor(e1){
|
|
4982
|
+
let { max: t1 = 0, ttl: i, ttlResolution: s = 1, ttlAutopurge: n, updateAgeOnGet: o, updateAgeOnHas: r, allowStale: h, dispose: l, onInsert: c, disposeAfter: f, noDisposeOnSet: g, noUpdateTTL: p, maxSize: T = 0, maxEntrySize: w = 0, sizeCalculation: y, fetchMethod: a, memoMethod: m, noDeleteOnFetchRejection: _, noDeleteOnStaleGet: b, allowStaleOnFetchRejection: d, allowStaleOnFetchAbort: A, ignoreFetchAbort: z, perf: x } = e1;
|
|
4983
|
+
if (void 0 !== x && "function" != typeof x?.now) throw new TypeError("perf option must have a now() method if specified");
|
|
4984
|
+
if (this.#m = x ?? G, 0 !== t1 && !F(t1)) throw new TypeError("max option must be a nonnegative integer");
|
|
4985
|
+
let v = t1 ? U(t1) : Array;
|
|
4986
|
+
if (!v) throw new Error("invalid max value: " + t1);
|
|
4987
|
+
if (this.#o = t1, this.#u = T, this.maxEntrySize = w || this.#u, this.sizeCalculation = y, this.sizeCalculation) {
|
|
4988
|
+
if (!this.#u && !this.maxEntrySize) throw new TypeError("cannot set sizeCalculation without setting maxSize or maxEntrySize");
|
|
4989
|
+
if ("function" != typeof this.sizeCalculation) throw new TypeError("sizeCalculation set to non-function");
|
|
4990
|
+
}
|
|
4991
|
+
if (void 0 !== m && "function" != typeof m) throw new TypeError("memoMethod must be a function if defined");
|
|
4992
|
+
if (this.#U = m, void 0 !== a && "function" != typeof a) throw new TypeError("fetchMethod must be a function if specified");
|
|
4993
|
+
if (this.#M = a, this.#W = !!a, this.#s = new Map, this.#i = Array.from({
|
|
4994
|
+
length: t1
|
|
4995
|
+
}).fill(void 0), this.#t = Array.from({
|
|
4996
|
+
length: t1
|
|
4997
|
+
}).fill(void 0), this.#a = new v(t1), this.#c = new v(t1), this.#l = 0, this.#h = 0, this.#y = R.create(t1), this.#n = 0, this.#b = 0, "function" == typeof l && (this.#w = l), "function" == typeof c && (this.#D = c), "function" == typeof f ? (this.#S = f, this.#r = []) : (this.#S = void 0, this.#r = void 0), this.#T = !!this.#w, this.#j = !!this.#D, this.#f = !!this.#S, this.noDisposeOnSet = !!g, this.noUpdateTTL = !!p, this.noDeleteOnFetchRejection = !!_, this.allowStaleOnFetchRejection = !!d, this.allowStaleOnFetchAbort = !!A, this.ignoreFetchAbort = !!z, 0 !== this.maxEntrySize) {
|
|
4998
|
+
if (0 !== this.#u && !F(this.#u)) throw new TypeError("maxSize must be a positive integer if specified");
|
|
4999
|
+
if (!F(this.maxEntrySize)) throw new TypeError("maxEntrySize must be a positive integer if specified");
|
|
5000
|
+
this.#X();
|
|
5001
|
+
}
|
|
5002
|
+
if (this.allowStale = !!h, this.noDeleteOnStaleGet = !!b, this.updateAgeOnGet = !!o, this.updateAgeOnHas = !!r, this.ttlResolution = F(s) || 0 === s ? s : 1, this.ttlAutopurge = !!n, this.ttl = i || 0, this.ttl) {
|
|
5003
|
+
if (!F(this.ttl)) throw new TypeError("ttl must be a positive integer if specified");
|
|
5004
|
+
this.#H();
|
|
5005
|
+
}
|
|
5006
|
+
if (0 === this.#o && 0 === this.ttl && 0 === this.#u) throw new TypeError("At least one of max, maxSize, or ttl is required");
|
|
5007
|
+
if (!this.ttlAutopurge && !this.#o && !this.#u) {
|
|
5008
|
+
let E = "LRU_CACHE_UNBOUNDED";
|
|
5009
|
+
H(E) && (M.add(E), P("TTL caching without ttlAutopurge, max, or maxSize can result in unbounded memory consumption.", "UnboundedCacheWarning", E, u));
|
|
5010
|
+
}
|
|
5011
|
+
}
|
|
5012
|
+
getRemainingTTL(e1) {
|
|
5013
|
+
return this.#s.has(e1) ? 1 / 0 : 0;
|
|
5014
|
+
}
|
|
5015
|
+
#H() {
|
|
5016
|
+
let e1 = new O(this.#o), t1 = new O(this.#o);
|
|
5017
|
+
this.#d = e1, this.#F = t1;
|
|
5018
|
+
let i = this.ttlAutopurge ? Array.from({
|
|
5019
|
+
length: this.#o
|
|
5020
|
+
}) : void 0;
|
|
5021
|
+
this.#g = i, this.#N = (r, h, l = this.#m.now())=>{
|
|
5022
|
+
t1[r] = 0 !== h ? l : 0, e1[r] = h, s(r, h);
|
|
5023
|
+
}, this.#x = (r)=>{
|
|
5024
|
+
t1[r] = 0 !== e1[r] ? this.#m.now() : 0, s(r, e1[r]);
|
|
5543
5025
|
};
|
|
5544
|
-
|
|
5545
|
-
if (
|
|
5546
|
-
|
|
5547
|
-
|
|
5548
|
-
|
|
5549
|
-
|
|
5550
|
-
|
|
5551
|
-
|
|
5552
|
-
|
|
5553
|
-
|
|
5026
|
+
let s = this.ttlAutopurge ? (r, h)=>{
|
|
5027
|
+
if (i?.[r] && (clearTimeout(i[r]), i[r] = void 0), h && 0 !== h && i) {
|
|
5028
|
+
let l = setTimeout(()=>{
|
|
5029
|
+
this.#p(r) && this.#v(this.#i[r], "expire");
|
|
5030
|
+
}, h + 1);
|
|
5031
|
+
l.unref && l.unref(), i[r] = l;
|
|
5032
|
+
}
|
|
5033
|
+
} : ()=>{};
|
|
5034
|
+
this.#E = (r, h)=>{
|
|
5035
|
+
if (e1[h]) {
|
|
5036
|
+
let l = e1[h], c = t1[h];
|
|
5037
|
+
if (!l || !c) return;
|
|
5038
|
+
r.ttl = l, r.start = c, r.now = n || o();
|
|
5039
|
+
let f = r.now - c;
|
|
5040
|
+
r.remainingTTL = l - f;
|
|
5554
5041
|
}
|
|
5555
5042
|
};
|
|
5556
|
-
let
|
|
5557
|
-
|
|
5558
|
-
const n = perf.now();
|
|
5043
|
+
let n = 0, o = ()=>{
|
|
5044
|
+
let r = this.#m.now();
|
|
5559
5045
|
if (this.ttlResolution > 0) {
|
|
5560
|
-
|
|
5561
|
-
|
|
5562
|
-
|
|
5046
|
+
n = r;
|
|
5047
|
+
let h = setTimeout(()=>n = 0, this.ttlResolution);
|
|
5048
|
+
h.unref && h.unref();
|
|
5563
5049
|
}
|
|
5564
|
-
return
|
|
5565
|
-
};
|
|
5566
|
-
this.getRemainingTTL = (key)=>{
|
|
5567
|
-
const index = this.#keyMap.get(key);
|
|
5568
|
-
if (void 0 === index) return 0;
|
|
5569
|
-
const ttl = ttls[index];
|
|
5570
|
-
const start = starts[index];
|
|
5571
|
-
if (!ttl || !start) return 1 / 0;
|
|
5572
|
-
const age = (cachedNow || getNow()) - start;
|
|
5573
|
-
return ttl - age;
|
|
5050
|
+
return r;
|
|
5574
5051
|
};
|
|
5575
|
-
this
|
|
5576
|
-
|
|
5577
|
-
|
|
5578
|
-
|
|
5052
|
+
this.getRemainingTTL = (r)=>{
|
|
5053
|
+
let h = this.#s.get(r);
|
|
5054
|
+
if (void 0 === h) return 0;
|
|
5055
|
+
let l = e1[h], c = t1[h];
|
|
5056
|
+
if (!l || !c) return 1 / 0;
|
|
5057
|
+
let f = (n || o()) - c;
|
|
5058
|
+
return l - f;
|
|
5059
|
+
}, this.#p = (r)=>{
|
|
5060
|
+
let h = t1[r], l = e1[r];
|
|
5061
|
+
return !!l && !!h && (n || o()) - h > l;
|
|
5579
5062
|
};
|
|
5580
5063
|
}
|
|
5581
|
-
#
|
|
5582
|
-
#
|
|
5583
|
-
#
|
|
5584
|
-
#
|
|
5585
|
-
#
|
|
5586
|
-
|
|
5587
|
-
this.#
|
|
5588
|
-
|
|
5589
|
-
this.#
|
|
5590
|
-
this.#
|
|
5591
|
-
|
|
5592
|
-
|
|
5593
|
-
|
|
5594
|
-
if (this.#isBackgroundFetch(v)) return 0;
|
|
5595
|
-
if (!isPosInt(size)) if (sizeCalculation) {
|
|
5596
|
-
if ('function' != typeof sizeCalculation) throw new TypeError('sizeCalculation must be a function');
|
|
5597
|
-
size = sizeCalculation(v, k);
|
|
5598
|
-
if (!isPosInt(size)) throw new TypeError('sizeCalculation return invalid (expect positive integer)');
|
|
5064
|
+
#x = ()=>{};
|
|
5065
|
+
#E = ()=>{};
|
|
5066
|
+
#N = ()=>{};
|
|
5067
|
+
#p = ()=>!1;
|
|
5068
|
+
#X() {
|
|
5069
|
+
let e1 = new O(this.#o);
|
|
5070
|
+
this.#b = 0, this.#_ = e1, this.#R = (t1)=>{
|
|
5071
|
+
this.#b -= e1[t1], e1[t1] = 0;
|
|
5072
|
+
}, this.#k = (t1, i, s, n)=>{
|
|
5073
|
+
if (this.#e(i)) return 0;
|
|
5074
|
+
if (!F(s)) if (n) {
|
|
5075
|
+
if ("function" != typeof n) throw new TypeError("sizeCalculation must be a function");
|
|
5076
|
+
if (s = n(i, t1), !F(s)) throw new TypeError("sizeCalculation return invalid (expect positive integer)");
|
|
5599
5077
|
} else throw new TypeError("invalid size value (must be positive integer). When maxSize or maxEntrySize is used, sizeCalculation or size must be set.");
|
|
5600
|
-
return
|
|
5601
|
-
}
|
|
5602
|
-
|
|
5603
|
-
|
|
5604
|
-
|
|
5605
|
-
const maxSize = this.#maxSize - sizes[index];
|
|
5606
|
-
while(this.#calculatedSize > maxSize)this.#evict(true);
|
|
5607
|
-
}
|
|
5608
|
-
this.#calculatedSize += sizes[index];
|
|
5609
|
-
if (status) {
|
|
5610
|
-
status.entrySize = size;
|
|
5611
|
-
status.totalCalculatedSize = this.#calculatedSize;
|
|
5078
|
+
return s;
|
|
5079
|
+
}, this.#I = (t1, i, s)=>{
|
|
5080
|
+
if (e1[t1] = i, this.#u) {
|
|
5081
|
+
let n = this.#u - e1[t1];
|
|
5082
|
+
for(; this.#b > n;)this.#G(!0);
|
|
5612
5083
|
}
|
|
5084
|
+
this.#b += e1[t1], s && (s.entrySize = i, s.totalCalculatedSize = this.#b);
|
|
5613
5085
|
};
|
|
5614
5086
|
}
|
|
5615
|
-
#
|
|
5616
|
-
#
|
|
5617
|
-
#
|
|
5618
|
-
if (
|
|
5087
|
+
#R = (e1)=>{};
|
|
5088
|
+
#I = (e1, t1, i)=>{};
|
|
5089
|
+
#k = (e1, t1, i, s)=>{
|
|
5090
|
+
if (i || s) throw new TypeError("cannot set size without setting maxSize or maxEntrySize on cache");
|
|
5619
5091
|
return 0;
|
|
5620
5092
|
};
|
|
5621
|
-
*#
|
|
5622
|
-
if (this.#
|
|
5623
|
-
if (!this.#isValidIndex(i)) break;
|
|
5624
|
-
if (allowStale || !this.#isStale(i)) yield i;
|
|
5625
|
-
if (i === this.#head) break;
|
|
5626
|
-
i = this.#prev[i];
|
|
5627
|
-
}
|
|
5093
|
+
*#A({ allowStale: e1 = this.allowStale } = {}) {
|
|
5094
|
+
if (this.#n) for(let t1 = this.#h; this.#V(t1) && ((e1 || !this.#p(t1)) && (yield t1), t1 !== this.#l);)t1 = this.#c[t1];
|
|
5628
5095
|
}
|
|
5629
|
-
*#
|
|
5630
|
-
if (this.#
|
|
5631
|
-
if (!this.#isValidIndex(i)) break;
|
|
5632
|
-
if (allowStale || !this.#isStale(i)) yield i;
|
|
5633
|
-
if (i === this.#tail) break;
|
|
5634
|
-
i = this.#next[i];
|
|
5635
|
-
}
|
|
5096
|
+
*#z({ allowStale: e1 = this.allowStale } = {}) {
|
|
5097
|
+
if (this.#n) for(let t1 = this.#l; this.#V(t1) && ((e1 || !this.#p(t1)) && (yield t1), t1 !== this.#h);)t1 = this.#a[t1];
|
|
5636
5098
|
}
|
|
5637
|
-
#
|
|
5638
|
-
return void 0 !==
|
|
5099
|
+
#V(e1) {
|
|
5100
|
+
return void 0 !== e1 && this.#s.get(this.#i[e1]) === e1;
|
|
5639
5101
|
}
|
|
5640
5102
|
*entries() {
|
|
5641
|
-
for (
|
|
5642
|
-
this.#
|
|
5643
|
-
this.#
|
|
5644
|
-
];
|
|
5103
|
+
for (let e1 of this.#A())void 0 === this.#t[e1] || void 0 === this.#i[e1] || this.#e(this.#t[e1]) || (yield [
|
|
5104
|
+
this.#i[e1],
|
|
5105
|
+
this.#t[e1]
|
|
5106
|
+
]);
|
|
5645
5107
|
}
|
|
5646
5108
|
*rentries() {
|
|
5647
|
-
for (
|
|
5648
|
-
this.#
|
|
5649
|
-
this.#
|
|
5650
|
-
];
|
|
5109
|
+
for (let e1 of this.#z())void 0 === this.#t[e1] || void 0 === this.#i[e1] || this.#e(this.#t[e1]) || (yield [
|
|
5110
|
+
this.#i[e1],
|
|
5111
|
+
this.#t[e1]
|
|
5112
|
+
]);
|
|
5651
5113
|
}
|
|
5652
5114
|
*keys() {
|
|
5653
|
-
for (
|
|
5654
|
-
|
|
5655
|
-
|
|
5115
|
+
for (let e1 of this.#A()){
|
|
5116
|
+
let t1 = this.#i[e1];
|
|
5117
|
+
void 0 === t1 || this.#e(this.#t[e1]) || (yield t1);
|
|
5656
5118
|
}
|
|
5657
5119
|
}
|
|
5658
5120
|
*rkeys() {
|
|
5659
|
-
for (
|
|
5660
|
-
|
|
5661
|
-
|
|
5121
|
+
for (let e1 of this.#z()){
|
|
5122
|
+
let t1 = this.#i[e1];
|
|
5123
|
+
void 0 === t1 || this.#e(this.#t[e1]) || (yield t1);
|
|
5662
5124
|
}
|
|
5663
5125
|
}
|
|
5664
5126
|
*values() {
|
|
5665
|
-
for (
|
|
5666
|
-
const v = this.#valList[i];
|
|
5667
|
-
if (void 0 !== v && !this.#isBackgroundFetch(this.#valList[i])) yield this.#valList[i];
|
|
5668
|
-
}
|
|
5127
|
+
for (let e1 of this.#A())void 0 === this.#t[e1] || this.#e(this.#t[e1]) || (yield this.#t[e1]);
|
|
5669
5128
|
}
|
|
5670
5129
|
*rvalues() {
|
|
5671
|
-
for (
|
|
5672
|
-
const v = this.#valList[i];
|
|
5673
|
-
if (void 0 !== v && !this.#isBackgroundFetch(this.#valList[i])) yield this.#valList[i];
|
|
5674
|
-
}
|
|
5130
|
+
for (let e1 of this.#z())void 0 === this.#t[e1] || this.#e(this.#t[e1]) || (yield this.#t[e1]);
|
|
5675
5131
|
}
|
|
5676
5132
|
[Symbol.iterator]() {
|
|
5677
5133
|
return this.entries();
|
|
5678
5134
|
}
|
|
5679
|
-
[Symbol.toStringTag] =
|
|
5680
|
-
find(
|
|
5681
|
-
for (
|
|
5682
|
-
|
|
5683
|
-
|
|
5684
|
-
if (void 0 !== value) {
|
|
5685
|
-
if (fn(value, this.#keyList[i], this)) return this.get(this.#keyList[i], getOptions);
|
|
5686
|
-
}
|
|
5135
|
+
[Symbol.toStringTag] = "LRUCache";
|
|
5136
|
+
find(e1, t1 = {}) {
|
|
5137
|
+
for (let i of this.#A()){
|
|
5138
|
+
let s = this.#t[i], n = this.#e(s) ? s.__staleWhileFetching : s;
|
|
5139
|
+
if (void 0 !== n && e1(n, this.#i[i], this)) return this.#C(this.#i[i], t1);
|
|
5687
5140
|
}
|
|
5688
5141
|
}
|
|
5689
|
-
forEach(
|
|
5690
|
-
for (
|
|
5691
|
-
|
|
5692
|
-
|
|
5693
|
-
if (void 0 !== value) fn.call(thisp, value, this.#keyList[i], this);
|
|
5142
|
+
forEach(e1, t1 = this) {
|
|
5143
|
+
for (let i of this.#A()){
|
|
5144
|
+
let s = this.#t[i], n = this.#e(s) ? s.__staleWhileFetching : s;
|
|
5145
|
+
void 0 !== n && e1.call(t1, n, this.#i[i], this);
|
|
5694
5146
|
}
|
|
5695
5147
|
}
|
|
5696
|
-
rforEach(
|
|
5697
|
-
for (
|
|
5698
|
-
|
|
5699
|
-
|
|
5700
|
-
if (void 0 !== value) fn.call(thisp, value, this.#keyList[i], this);
|
|
5148
|
+
rforEach(e1, t1 = this) {
|
|
5149
|
+
for (let i of this.#z()){
|
|
5150
|
+
let s = this.#t[i], n = this.#e(s) ? s.__staleWhileFetching : s;
|
|
5151
|
+
void 0 !== n && e1.call(t1, n, this.#i[i], this);
|
|
5701
5152
|
}
|
|
5702
5153
|
}
|
|
5703
5154
|
purgeStale() {
|
|
5704
|
-
let
|
|
5705
|
-
for (
|
|
5706
|
-
allowStale:
|
|
5707
|
-
}))
|
|
5708
|
-
|
|
5709
|
-
|
|
5710
|
-
|
|
5711
|
-
|
|
5712
|
-
|
|
5713
|
-
|
|
5714
|
-
|
|
5715
|
-
|
|
5716
|
-
|
|
5717
|
-
const value = this.#isBackgroundFetch(v) ? v.__staleWhileFetching : v;
|
|
5718
|
-
if (void 0 === value) return;
|
|
5719
|
-
const entry = {
|
|
5720
|
-
value
|
|
5155
|
+
let e1 = !1;
|
|
5156
|
+
for (let t1 of this.#z({
|
|
5157
|
+
allowStale: !0
|
|
5158
|
+
}))this.#p(t1) && (this.#v(this.#i[t1], "expire"), e1 = !0);
|
|
5159
|
+
return e1;
|
|
5160
|
+
}
|
|
5161
|
+
info(e1) {
|
|
5162
|
+
let t1 = this.#s.get(e1);
|
|
5163
|
+
if (void 0 === t1) return;
|
|
5164
|
+
let i = this.#t[t1], s = this.#e(i) ? i.__staleWhileFetching : i;
|
|
5165
|
+
if (void 0 === s) return;
|
|
5166
|
+
let n = {
|
|
5167
|
+
value: s
|
|
5721
5168
|
};
|
|
5722
|
-
if (this.#
|
|
5723
|
-
|
|
5724
|
-
|
|
5725
|
-
|
|
5726
|
-
|
|
5727
|
-
entry.ttl = remain;
|
|
5728
|
-
entry.start = Date.now();
|
|
5169
|
+
if (this.#d && this.#F) {
|
|
5170
|
+
let o = this.#d[t1], r = this.#F[t1];
|
|
5171
|
+
if (o && r) {
|
|
5172
|
+
let h = o - (this.#m.now() - r);
|
|
5173
|
+
n.ttl = h, n.start = Date.now();
|
|
5729
5174
|
}
|
|
5730
5175
|
}
|
|
5731
|
-
|
|
5732
|
-
return entry;
|
|
5176
|
+
return this.#_ && (n.size = this.#_[t1]), n;
|
|
5733
5177
|
}
|
|
5734
5178
|
dump() {
|
|
5735
|
-
|
|
5736
|
-
for (
|
|
5737
|
-
allowStale:
|
|
5179
|
+
let e1 = [];
|
|
5180
|
+
for (let t1 of this.#A({
|
|
5181
|
+
allowStale: !0
|
|
5738
5182
|
})){
|
|
5739
|
-
|
|
5740
|
-
|
|
5741
|
-
|
|
5742
|
-
|
|
5743
|
-
const entry = {
|
|
5744
|
-
value
|
|
5183
|
+
let i = this.#i[t1], s = this.#t[t1], n = this.#e(s) ? s.__staleWhileFetching : s;
|
|
5184
|
+
if (void 0 === n || void 0 === i) continue;
|
|
5185
|
+
let o = {
|
|
5186
|
+
value: n
|
|
5745
5187
|
};
|
|
5746
|
-
if (this.#
|
|
5747
|
-
|
|
5748
|
-
|
|
5749
|
-
|
|
5750
|
-
}
|
|
5751
|
-
|
|
5752
|
-
|
|
5753
|
-
|
|
5754
|
-
entry
|
|
5188
|
+
if (this.#d && this.#F) {
|
|
5189
|
+
o.ttl = this.#d[t1];
|
|
5190
|
+
let r = this.#m.now() - this.#F[t1];
|
|
5191
|
+
o.start = Math.floor(Date.now() - r);
|
|
5192
|
+
}
|
|
5193
|
+
this.#_ && (o.size = this.#_[t1]), e1.unshift([
|
|
5194
|
+
i,
|
|
5195
|
+
o
|
|
5755
5196
|
]);
|
|
5756
5197
|
}
|
|
5757
|
-
return
|
|
5198
|
+
return e1;
|
|
5758
5199
|
}
|
|
5759
|
-
load(
|
|
5200
|
+
load(e1) {
|
|
5760
5201
|
this.clear();
|
|
5761
|
-
for (
|
|
5762
|
-
if (
|
|
5763
|
-
|
|
5764
|
-
|
|
5765
|
-
}
|
|
5766
|
-
this
|
|
5767
|
-
}
|
|
5768
|
-
}
|
|
5769
|
-
set(
|
|
5770
|
-
|
|
5771
|
-
|
|
5772
|
-
|
|
5773
|
-
|
|
5774
|
-
|
|
5775
|
-
|
|
5776
|
-
|
|
5777
|
-
if (
|
|
5778
|
-
|
|
5779
|
-
|
|
5780
|
-
|
|
5781
|
-
|
|
5782
|
-
|
|
5783
|
-
|
|
5784
|
-
|
|
5785
|
-
|
|
5786
|
-
|
|
5787
|
-
|
|
5788
|
-
|
|
5789
|
-
|
|
5790
|
-
|
|
5791
|
-
|
|
5792
|
-
|
|
5793
|
-
|
|
5794
|
-
|
|
5795
|
-
|
|
5796
|
-
|
|
5797
|
-
|
|
5798
|
-
|
|
5799
|
-
|
|
5800
|
-
|
|
5801
|
-
|
|
5802
|
-
|
|
5803
|
-
|
|
5804
|
-
|
|
5805
|
-
if (void 0 !== s && !noDisposeOnSet) {
|
|
5806
|
-
if (this.#hasDispose) this.#dispose?.(s, k, 'set');
|
|
5807
|
-
if (this.#hasDisposeAfter) this.#disposed?.push([
|
|
5808
|
-
s,
|
|
5809
|
-
k,
|
|
5810
|
-
'set'
|
|
5811
|
-
]);
|
|
5812
|
-
}
|
|
5813
|
-
} else if (!noDisposeOnSet) {
|
|
5814
|
-
if (this.#hasDispose) this.#dispose?.(oldVal, k, 'set');
|
|
5815
|
-
if (this.#hasDisposeAfter) this.#disposed?.push([
|
|
5816
|
-
oldVal,
|
|
5817
|
-
k,
|
|
5818
|
-
'set'
|
|
5819
|
-
]);
|
|
5820
|
-
}
|
|
5821
|
-
this.#removeItemSize(index);
|
|
5822
|
-
this.#addItemSize(index, size, status);
|
|
5823
|
-
this.#valList[index] = v;
|
|
5824
|
-
if (status) {
|
|
5825
|
-
status.set = 'replace';
|
|
5826
|
-
const oldValue = oldVal && this.#isBackgroundFetch(oldVal) ? oldVal.__staleWhileFetching : oldVal;
|
|
5827
|
-
if (void 0 !== oldValue) status.oldValue = oldValue;
|
|
5202
|
+
for (let [t1, i] of e1){
|
|
5203
|
+
if (i.start) {
|
|
5204
|
+
let s = Date.now() - i.start;
|
|
5205
|
+
i.start = this.#m.now() - s;
|
|
5206
|
+
}
|
|
5207
|
+
this.#O(t1, i.value, i);
|
|
5208
|
+
}
|
|
5209
|
+
}
|
|
5210
|
+
set(e1, t1, i = {}) {
|
|
5211
|
+
let { status: s = S.hasSubscribers ? {} : void 0 } = i;
|
|
5212
|
+
i.status = s, s && (s.op = "set", s.key = e1, void 0 !== t1 && (s.value = t1));
|
|
5213
|
+
let n = this.#O(e1, t1, i);
|
|
5214
|
+
return s && S.hasSubscribers && S.publish(s), n;
|
|
5215
|
+
}
|
|
5216
|
+
#O(e1, t1, i = {}) {
|
|
5217
|
+
let { ttl: s = this.ttl, start: n, noDisposeOnSet: o = this.noDisposeOnSet, sizeCalculation: r = this.sizeCalculation, status: h } = i;
|
|
5218
|
+
if (void 0 === t1) return h && (h.set = "deleted"), this.delete(e1), this;
|
|
5219
|
+
let { noUpdateTTL: l = this.noUpdateTTL } = i;
|
|
5220
|
+
h && !this.#e(t1) && (h.value = t1);
|
|
5221
|
+
let c = this.#k(e1, t1, i.size || 0, r, h);
|
|
5222
|
+
if (this.maxEntrySize && c > this.maxEntrySize) return this.#v(e1, "set"), h && (h.set = "miss", h.maxEntrySizeExceeded = !0), this;
|
|
5223
|
+
let f = 0 === this.#n ? void 0 : this.#s.get(e1);
|
|
5224
|
+
if (void 0 === f) f = 0 === this.#n ? this.#h : 0 !== this.#y.length ? this.#y.pop() : this.#n === this.#o ? this.#G(!1) : this.#n, this.#i[f] = e1, this.#t[f] = t1, this.#s.set(e1, f), this.#a[this.#h] = f, this.#c[f] = this.#h, this.#h = f, this.#n++, this.#I(f, c, h), h && (h.set = "add"), l = !1, this.#j && this.#D?.(t1, e1, "add");
|
|
5225
|
+
else {
|
|
5226
|
+
this.#L(f);
|
|
5227
|
+
let g = this.#t[f];
|
|
5228
|
+
if (t1 !== g) {
|
|
5229
|
+
if (this.#W && this.#e(g)) {
|
|
5230
|
+
g.__abortController.abort(new Error("replaced"));
|
|
5231
|
+
let { __staleWhileFetching: p } = g;
|
|
5232
|
+
void 0 !== p && !o && (this.#T && this.#w?.(p, e1, "set"), this.#f && this.#r?.push([
|
|
5233
|
+
p,
|
|
5234
|
+
e1,
|
|
5235
|
+
"set"
|
|
5236
|
+
]));
|
|
5237
|
+
} else o || (this.#T && this.#w?.(g, e1, "set"), this.#f && this.#r?.push([
|
|
5238
|
+
g,
|
|
5239
|
+
e1,
|
|
5240
|
+
"set"
|
|
5241
|
+
]));
|
|
5242
|
+
if (this.#R(f), this.#I(f, c, h), this.#t[f] = t1, h) {
|
|
5243
|
+
h.set = "replace";
|
|
5244
|
+
let p = g && this.#e(g) ? g.__staleWhileFetching : g;
|
|
5245
|
+
void 0 !== p && (h.oldValue = p);
|
|
5828
5246
|
}
|
|
5829
|
-
} else
|
|
5247
|
+
} else h && (h.set = "update");
|
|
5248
|
+
this.#j && this.onInsert?.(t1, e1, t1 === g ? "update" : "replace");
|
|
5830
5249
|
}
|
|
5831
|
-
if (0
|
|
5832
|
-
|
|
5833
|
-
|
|
5834
|
-
if (status) this.#statusTTL(status, index);
|
|
5835
|
-
}
|
|
5836
|
-
if (!noDisposeOnSet && this.#hasDisposeAfter && this.#disposed) {
|
|
5837
|
-
const dt = this.#disposed;
|
|
5838
|
-
let task;
|
|
5839
|
-
while(task = dt?.shift())this.#disposeAfter?.(...task);
|
|
5250
|
+
if (0 === s || this.#d || this.#H(), this.#d && (l || this.#N(f, s, n), h && this.#E(h, f)), !o && this.#f && this.#r) {
|
|
5251
|
+
let g = this.#r, p;
|
|
5252
|
+
for(; p = g?.shift();)this.#S?.(...p);
|
|
5840
5253
|
}
|
|
5841
5254
|
return this;
|
|
5842
5255
|
}
|
|
5843
5256
|
pop() {
|
|
5844
5257
|
try {
|
|
5845
|
-
|
|
5846
|
-
|
|
5847
|
-
this.#
|
|
5848
|
-
|
|
5849
|
-
|
|
5850
|
-
} else if (void 0 !== val) return val;
|
|
5258
|
+
for(; this.#n;){
|
|
5259
|
+
let e1 = this.#t[this.#l];
|
|
5260
|
+
if (this.#G(!0), this.#e(e1)) {
|
|
5261
|
+
if (e1.__staleWhileFetching) return e1.__staleWhileFetching;
|
|
5262
|
+
} else if (void 0 !== e1) return e1;
|
|
5851
5263
|
}
|
|
5852
5264
|
} finally{
|
|
5853
|
-
if (this.#
|
|
5854
|
-
|
|
5855
|
-
|
|
5856
|
-
while(task = dt?.shift())this.#disposeAfter?.(...task);
|
|
5265
|
+
if (this.#f && this.#r) {
|
|
5266
|
+
let e1 = this.#r, t1;
|
|
5267
|
+
for(; t1 = e1?.shift();)this.#S?.(...t1);
|
|
5857
5268
|
}
|
|
5858
5269
|
}
|
|
5859
5270
|
}
|
|
5860
|
-
#
|
|
5861
|
-
|
|
5862
|
-
|
|
5863
|
-
|
|
5864
|
-
|
|
5865
|
-
|
|
5866
|
-
|
|
5867
|
-
|
|
5868
|
-
|
|
5869
|
-
|
|
5870
|
-
|
|
5871
|
-
|
|
5271
|
+
#G(e1) {
|
|
5272
|
+
let t1 = this.#l, i = this.#i[t1], s = this.#t[t1];
|
|
5273
|
+
return this.#W && this.#e(s) ? s.__abortController.abort(new Error("evicted")) : (this.#T || this.#f) && (this.#T && this.#w?.(s, i, "evict"), this.#f && this.#r?.push([
|
|
5274
|
+
s,
|
|
5275
|
+
i,
|
|
5276
|
+
"evict"
|
|
5277
|
+
])), this.#R(t1), this.#g?.[t1] && (clearTimeout(this.#g[t1]), this.#g[t1] = void 0), e1 && (this.#i[t1] = void 0, this.#t[t1] = void 0, this.#y.push(t1)), 1 === this.#n ? (this.#l = this.#h = 0, this.#y.length = 0) : this.#l = this.#a[t1], this.#s.delete(i), this.#n--, t1;
|
|
5278
|
+
}
|
|
5279
|
+
has(e1, t1 = {}) {
|
|
5280
|
+
let { status: i = S.hasSubscribers ? {} : void 0 } = t1;
|
|
5281
|
+
t1.status = i, i && (i.op = "has", i.key = e1);
|
|
5282
|
+
let s = this.#Y(e1, t1);
|
|
5283
|
+
return S.hasSubscribers && S.publish(i), s;
|
|
5284
|
+
}
|
|
5285
|
+
#Y(e1, t1 = {}) {
|
|
5286
|
+
let { updateAgeOnHas: i = this.updateAgeOnHas, status: s } = t1, n = this.#s.get(e1);
|
|
5287
|
+
if (void 0 !== n) {
|
|
5288
|
+
let o = this.#t[n];
|
|
5289
|
+
if (this.#e(o) && void 0 === o.__staleWhileFetching) return !1;
|
|
5290
|
+
if (!this.#p(n)) return i && this.#x(n), s && (s.has = "hit", this.#E(s, n)), !0;
|
|
5291
|
+
s && (s.has = "stale", this.#E(s, n));
|
|
5292
|
+
} else s && (s.has = "miss");
|
|
5293
|
+
return !1;
|
|
5294
|
+
}
|
|
5295
|
+
peek(e1, t1 = {}) {
|
|
5296
|
+
let { status: i = D() ? {} : void 0 } = t1;
|
|
5297
|
+
i && (i.op = "peek", i.key = e1), t1.status = i;
|
|
5298
|
+
let s = this.#J(e1, t1);
|
|
5299
|
+
return S.hasSubscribers && S.publish(i), s;
|
|
5300
|
+
}
|
|
5301
|
+
#J(e1, t1) {
|
|
5302
|
+
let { status: i, allowStale: s = this.allowStale } = t1, n = this.#s.get(e1);
|
|
5303
|
+
if (void 0 === n || !s && this.#p(n)) {
|
|
5304
|
+
i && (i.peek = void 0 === n ? "miss" : "stale");
|
|
5305
|
+
return;
|
|
5872
5306
|
}
|
|
5873
|
-
this.#
|
|
5874
|
-
|
|
5875
|
-
this.#keyList[head] = void 0;
|
|
5876
|
-
this.#valList[head] = void 0;
|
|
5877
|
-
this.#free.push(head);
|
|
5878
|
-
}
|
|
5879
|
-
if (1 === this.#size) {
|
|
5880
|
-
this.#head = this.#tail = 0;
|
|
5881
|
-
this.#free.length = 0;
|
|
5882
|
-
} else this.#head = this.#next[head];
|
|
5883
|
-
this.#keyMap.delete(k);
|
|
5884
|
-
this.#size--;
|
|
5885
|
-
return head;
|
|
5886
|
-
}
|
|
5887
|
-
has(k, hasOptions = {}) {
|
|
5888
|
-
const { updateAgeOnHas = this.updateAgeOnHas, status } = hasOptions;
|
|
5889
|
-
const index = this.#keyMap.get(k);
|
|
5890
|
-
if (void 0 !== index) {
|
|
5891
|
-
const v = this.#valList[index];
|
|
5892
|
-
if (this.#isBackgroundFetch(v) && void 0 === v.__staleWhileFetching) return false;
|
|
5893
|
-
if (this.#isStale(index)) {
|
|
5894
|
-
if (status) {
|
|
5895
|
-
status.has = 'stale';
|
|
5896
|
-
this.#statusTTL(status, index);
|
|
5897
|
-
}
|
|
5898
|
-
} else {
|
|
5899
|
-
if (updateAgeOnHas) this.#updateItemAge(index);
|
|
5900
|
-
if (status) {
|
|
5901
|
-
status.has = 'hit';
|
|
5902
|
-
this.#statusTTL(status, index);
|
|
5903
|
-
}
|
|
5904
|
-
return true;
|
|
5905
|
-
}
|
|
5906
|
-
} else if (status) status.has = 'miss';
|
|
5907
|
-
return false;
|
|
5307
|
+
let o = this.#t[n], r = this.#e(o) ? o.__staleWhileFetching : o;
|
|
5308
|
+
return i && (void 0 !== r ? (i.peek = "hit", i.value = r) : i.peek = "miss"), r;
|
|
5908
5309
|
}
|
|
5909
|
-
|
|
5910
|
-
|
|
5911
|
-
|
|
5912
|
-
|
|
5913
|
-
|
|
5914
|
-
|
|
5915
|
-
}
|
|
5916
|
-
#backgroundFetch(k, index, options, context) {
|
|
5917
|
-
const v = void 0 === index ? void 0 : this.#valList[index];
|
|
5918
|
-
if (this.#isBackgroundFetch(v)) return v;
|
|
5919
|
-
const ac = new AC();
|
|
5920
|
-
const { signal } = options;
|
|
5921
|
-
signal?.addEventListener('abort', ()=>ac.abort(signal.reason), {
|
|
5922
|
-
signal: ac.signal
|
|
5310
|
+
#P(e1, t1, i, s) {
|
|
5311
|
+
let n = void 0 === t1 ? void 0 : this.#t[t1];
|
|
5312
|
+
if (this.#e(n)) return n;
|
|
5313
|
+
let o = new AbortController, { signal: r } = i;
|
|
5314
|
+
r?.addEventListener("abort", ()=>o.abort(r.reason), {
|
|
5315
|
+
signal: o.signal
|
|
5923
5316
|
});
|
|
5924
|
-
|
|
5925
|
-
signal:
|
|
5926
|
-
options,
|
|
5927
|
-
context
|
|
5928
|
-
}
|
|
5929
|
-
|
|
5930
|
-
|
|
5931
|
-
|
|
5932
|
-
|
|
5933
|
-
|
|
5934
|
-
|
|
5935
|
-
|
|
5936
|
-
|
|
5937
|
-
|
|
5938
|
-
|
|
5939
|
-
|
|
5940
|
-
|
|
5941
|
-
else {
|
|
5942
|
-
if (options.status) options.status.fetchUpdated = true;
|
|
5943
|
-
this.set(k, v, fetchOpts.options);
|
|
5944
|
-
}
|
|
5945
|
-
return v;
|
|
5946
|
-
};
|
|
5947
|
-
const eb = (er)=>{
|
|
5948
|
-
if (options.status) {
|
|
5949
|
-
options.status.fetchRejected = true;
|
|
5950
|
-
options.status.fetchError = er;
|
|
5951
|
-
}
|
|
5952
|
-
return fetchFail(er);
|
|
5953
|
-
};
|
|
5954
|
-
const fetchFail = (er)=>{
|
|
5955
|
-
const { aborted } = ac.signal;
|
|
5956
|
-
const allowStaleAborted = aborted && options.allowStaleOnFetchAbort;
|
|
5957
|
-
const allowStale = allowStaleAborted || options.allowStaleOnFetchRejection;
|
|
5958
|
-
const noDelete = allowStale || options.noDeleteOnFetchRejection;
|
|
5959
|
-
const bf = p;
|
|
5960
|
-
if (this.#valList[index] === p) {
|
|
5961
|
-
const del = !noDelete || void 0 === bf.__staleWhileFetching;
|
|
5962
|
-
if (del) this.#delete(k, 'fetch');
|
|
5963
|
-
else if (!allowStaleAborted) this.#valList[index] = bf.__staleWhileFetching;
|
|
5964
|
-
}
|
|
5965
|
-
if (allowStale) {
|
|
5966
|
-
if (options.status && void 0 !== bf.__staleWhileFetching) options.status.returnedStale = true;
|
|
5967
|
-
return bf.__staleWhileFetching;
|
|
5968
|
-
}
|
|
5969
|
-
if (bf.__returned === bf) throw er;
|
|
5970
|
-
};
|
|
5971
|
-
const pcall = (res, rej)=>{
|
|
5972
|
-
const fmp = this.#fetchMethod?.(k, v, fetchOpts);
|
|
5973
|
-
if (fmp && fmp instanceof Promise) fmp.then((v)=>res(void 0 === v ? void 0 : v), rej);
|
|
5974
|
-
ac.signal.addEventListener('abort', ()=>{
|
|
5975
|
-
if (!options.ignoreFetchAbort || options.allowStaleOnFetchAbort) {
|
|
5976
|
-
res(void 0);
|
|
5977
|
-
if (options.allowStaleOnFetchAbort) res = (v)=>cb(v, true);
|
|
5978
|
-
}
|
|
5317
|
+
let h = {
|
|
5318
|
+
signal: o.signal,
|
|
5319
|
+
options: i,
|
|
5320
|
+
context: s
|
|
5321
|
+
}, l = (w, y = !1)=>{
|
|
5322
|
+
let { aborted: a } = o.signal, m = i.ignoreFetchAbort && void 0 !== w, _ = i.ignoreFetchAbort || !!(i.allowStaleOnFetchAbort && void 0 !== w);
|
|
5323
|
+
if (i.status && (a && !y ? (i.status.fetchAborted = !0, i.status.fetchError = o.signal.reason, m && (i.status.fetchAbortIgnored = !0)) : i.status.fetchResolved = !0), a && !m && !y) return f(o.signal.reason, _);
|
|
5324
|
+
let b = p, d = this.#t[t1];
|
|
5325
|
+
return (d === p || void 0 === d && m && y) && (void 0 === w ? void 0 !== b.__staleWhileFetching ? this.#t[t1] = b.__staleWhileFetching : this.#v(e1, "fetch") : (i.status && (i.status.fetchUpdated = !0), this.#O(e1, w, h.options))), w;
|
|
5326
|
+
}, c = (w)=>(i.status && (i.status.fetchRejected = !0, i.status.fetchError = w), f(w, !1)), f = (w, y)=>{
|
|
5327
|
+
let { aborted: a } = o.signal, m = a && i.allowStaleOnFetchAbort, _ = m || i.allowStaleOnFetchRejection, b = _ || i.noDeleteOnFetchRejection, d = p;
|
|
5328
|
+
if (this.#t[t1] === p && (b && (y || void 0 !== d.__staleWhileFetching) ? m || (this.#t[t1] = d.__staleWhileFetching) : this.#v(e1, "fetch")), _) return i.status && void 0 !== d.__staleWhileFetching && (i.status.returnedStale = !0), d.__staleWhileFetching;
|
|
5329
|
+
if (d.__returned === d) throw w;
|
|
5330
|
+
}, g = (w, y)=>{
|
|
5331
|
+
let a = this.#M?.(e1, n, h);
|
|
5332
|
+
a && a instanceof Promise && a.then((m)=>w(void 0 === m ? void 0 : m), y), o.signal.addEventListener("abort", ()=>{
|
|
5333
|
+
(!i.ignoreFetchAbort || i.allowStaleOnFetchAbort) && (w(void 0), i.allowStaleOnFetchAbort && (w = (m)=>l(m, !0)));
|
|
5979
5334
|
});
|
|
5980
5335
|
};
|
|
5981
|
-
|
|
5982
|
-
|
|
5983
|
-
|
|
5984
|
-
|
|
5985
|
-
__staleWhileFetching: v,
|
|
5336
|
+
i.status && (i.status.fetchDispatched = !0);
|
|
5337
|
+
let p = new Promise(g).then(l, c), T = Object.assign(p, {
|
|
5338
|
+
__abortController: o,
|
|
5339
|
+
__staleWhileFetching: n,
|
|
5986
5340
|
__returned: void 0
|
|
5987
5341
|
});
|
|
5988
|
-
|
|
5989
|
-
|
|
5990
|
-
|
|
5991
|
-
|
|
5992
|
-
|
|
5993
|
-
|
|
5994
|
-
|
|
5995
|
-
|
|
5996
|
-
|
|
5997
|
-
|
|
5998
|
-
|
|
5999
|
-
|
|
6000
|
-
|
|
6001
|
-
|
|
6002
|
-
|
|
6003
|
-
|
|
6004
|
-
|
|
6005
|
-
|
|
6006
|
-
|
|
6007
|
-
|
|
6008
|
-
|
|
6009
|
-
|
|
6010
|
-
|
|
6011
|
-
|
|
6012
|
-
|
|
6013
|
-
|
|
6014
|
-
|
|
6015
|
-
|
|
6016
|
-
|
|
6017
|
-
|
|
6018
|
-
|
|
6019
|
-
|
|
6020
|
-
|
|
6021
|
-
|
|
6022
|
-
|
|
6023
|
-
|
|
6024
|
-
|
|
6025
|
-
|
|
6026
|
-
|
|
6027
|
-
|
|
6028
|
-
|
|
6029
|
-
|
|
6030
|
-
|
|
6031
|
-
|
|
6032
|
-
const p = this.#backgroundFetch(k, index, options, context);
|
|
6033
|
-
return p.__returned = p;
|
|
5342
|
+
return void 0 === t1 ? (this.#O(e1, T, {
|
|
5343
|
+
...h.options,
|
|
5344
|
+
status: void 0
|
|
5345
|
+
}), t1 = this.#s.get(e1)) : this.#t[t1] = T, T;
|
|
5346
|
+
}
|
|
5347
|
+
#e(e1) {
|
|
5348
|
+
if (!this.#W) return !1;
|
|
5349
|
+
let t1 = e1;
|
|
5350
|
+
return !!t1 && t1 instanceof Promise && t1.hasOwnProperty("__staleWhileFetching") && t1.__abortController instanceof AbortController;
|
|
5351
|
+
}
|
|
5352
|
+
fetch(e1, t1 = {}) {
|
|
5353
|
+
let i = W.hasSubscribers, { status: s = D() ? {} : void 0 } = t1;
|
|
5354
|
+
t1.status = s, s && t1.context && (s.context = t1.context);
|
|
5355
|
+
let n = this.#B(e1, t1);
|
|
5356
|
+
return s && D() && i && (s.trace = !0, W.tracePromise(()=>n, s).catch(()=>{})), n;
|
|
5357
|
+
}
|
|
5358
|
+
async #B(e1, t1 = {}) {
|
|
5359
|
+
let { allowStale: i = this.allowStale, updateAgeOnGet: s = this.updateAgeOnGet, noDeleteOnStaleGet: n = this.noDeleteOnStaleGet, ttl: o = this.ttl, noDisposeOnSet: r = this.noDisposeOnSet, size: h = 0, sizeCalculation: l = this.sizeCalculation, noUpdateTTL: c = this.noUpdateTTL, noDeleteOnFetchRejection: f = this.noDeleteOnFetchRejection, allowStaleOnFetchRejection: g = this.allowStaleOnFetchRejection, ignoreFetchAbort: p = this.ignoreFetchAbort, allowStaleOnFetchAbort: T = this.allowStaleOnFetchAbort, context: w, forceRefresh: y = !1, status: a, signal: m } = t1;
|
|
5360
|
+
if (a && (a.op = "fetch", a.key = e1, y && (a.forceRefresh = !0)), !this.#W) return a && (a.fetch = "get"), this.#C(e1, {
|
|
5361
|
+
allowStale: i,
|
|
5362
|
+
updateAgeOnGet: s,
|
|
5363
|
+
noDeleteOnStaleGet: n,
|
|
5364
|
+
status: a
|
|
5365
|
+
});
|
|
5366
|
+
let _ = {
|
|
5367
|
+
allowStale: i,
|
|
5368
|
+
updateAgeOnGet: s,
|
|
5369
|
+
noDeleteOnStaleGet: n,
|
|
5370
|
+
ttl: o,
|
|
5371
|
+
noDisposeOnSet: r,
|
|
5372
|
+
size: h,
|
|
5373
|
+
sizeCalculation: l,
|
|
5374
|
+
noUpdateTTL: c,
|
|
5375
|
+
noDeleteOnFetchRejection: f,
|
|
5376
|
+
allowStaleOnFetchRejection: g,
|
|
5377
|
+
allowStaleOnFetchAbort: T,
|
|
5378
|
+
ignoreFetchAbort: p,
|
|
5379
|
+
status: a,
|
|
5380
|
+
signal: m
|
|
5381
|
+
}, b = this.#s.get(e1);
|
|
5382
|
+
if (void 0 === b) {
|
|
5383
|
+
a && (a.fetch = "miss");
|
|
5384
|
+
let d = this.#P(e1, b, _, w);
|
|
5385
|
+
return d.__returned = d;
|
|
6034
5386
|
}
|
|
6035
5387
|
{
|
|
6036
|
-
|
|
6037
|
-
if (this.#
|
|
6038
|
-
|
|
6039
|
-
|
|
6040
|
-
|
|
6041
|
-
|
|
6042
|
-
|
|
6043
|
-
|
|
6044
|
-
|
|
6045
|
-
|
|
6046
|
-
|
|
6047
|
-
|
|
6048
|
-
|
|
6049
|
-
|
|
6050
|
-
|
|
6051
|
-
|
|
6052
|
-
|
|
6053
|
-
|
|
6054
|
-
|
|
6055
|
-
|
|
6056
|
-
|
|
6057
|
-
|
|
6058
|
-
|
|
6059
|
-
|
|
6060
|
-
|
|
6061
|
-
|
|
6062
|
-
|
|
6063
|
-
|
|
6064
|
-
|
|
6065
|
-
|
|
6066
|
-
|
|
6067
|
-
|
|
6068
|
-
|
|
6069
|
-
|
|
6070
|
-
if (
|
|
6071
|
-
|
|
6072
|
-
|
|
6073
|
-
|
|
6074
|
-
const vv = memoMethod(k, v, {
|
|
6075
|
-
options,
|
|
6076
|
-
context
|
|
5388
|
+
let d = this.#t[b];
|
|
5389
|
+
if (this.#e(d)) {
|
|
5390
|
+
let E = i && void 0 !== d.__staleWhileFetching;
|
|
5391
|
+
return a && (a.fetch = "inflight", E && (a.returnedStale = !0)), E ? d.__staleWhileFetching : d.__returned = d;
|
|
5392
|
+
}
|
|
5393
|
+
let A = this.#p(b);
|
|
5394
|
+
if (!y && !A) return a && (a.fetch = "hit"), this.#L(b), s && this.#x(b), a && this.#E(a, b), d;
|
|
5395
|
+
let z = this.#P(e1, b, _, w), v = void 0 !== z.__staleWhileFetching && i;
|
|
5396
|
+
return a && (a.fetch = A ? "stale" : "refresh", v && A && (a.returnedStale = !0)), v ? z.__staleWhileFetching : z.__returned = z;
|
|
5397
|
+
}
|
|
5398
|
+
}
|
|
5399
|
+
forceFetch(e1, t1 = {}) {
|
|
5400
|
+
let i = W.hasSubscribers, { status: s = D() ? {} : void 0 } = t1;
|
|
5401
|
+
t1.status = s, s && t1.context && (s.context = t1.context);
|
|
5402
|
+
let n = this.#K(e1, t1);
|
|
5403
|
+
return s && D() && i && (s.trace = !0, W.tracePromise(()=>n, s).catch(()=>{})), n;
|
|
5404
|
+
}
|
|
5405
|
+
async #K(e1, t1 = {}) {
|
|
5406
|
+
let i = await this.#B(e1, t1);
|
|
5407
|
+
if (void 0 === i) throw new Error("fetch() returned undefined");
|
|
5408
|
+
return i;
|
|
5409
|
+
}
|
|
5410
|
+
memo(e1, t1 = {}) {
|
|
5411
|
+
let { status: i = S.hasSubscribers ? {} : void 0 } = t1;
|
|
5412
|
+
t1.status = i, i && (i.op = "memo", i.key = e1, t1.context && (i.context = t1.context));
|
|
5413
|
+
let s = this.#Q(e1, t1);
|
|
5414
|
+
return i && (i.value = s), S.hasSubscribers && S.publish(i), s;
|
|
5415
|
+
}
|
|
5416
|
+
#Q(e1, t1 = {}) {
|
|
5417
|
+
let i = this.#U;
|
|
5418
|
+
if (!i) throw new Error("no memoMethod provided to constructor");
|
|
5419
|
+
let { context: s, status: n, forceRefresh: o, ...r } = t1;
|
|
5420
|
+
n && o && (n.forceRefresh = !0);
|
|
5421
|
+
let h = this.#C(e1, r), l = o || void 0 === h;
|
|
5422
|
+
if (n && (n.memo = l ? "miss" : "hit", l || (n.value = h)), !l) return h;
|
|
5423
|
+
let c = i(e1, h, {
|
|
5424
|
+
options: r,
|
|
5425
|
+
context: s
|
|
6077
5426
|
});
|
|
6078
|
-
this
|
|
6079
|
-
|
|
6080
|
-
}
|
|
6081
|
-
|
|
6082
|
-
|
|
6083
|
-
|
|
6084
|
-
|
|
6085
|
-
|
|
6086
|
-
|
|
6087
|
-
|
|
6088
|
-
|
|
6089
|
-
|
|
6090
|
-
|
|
6091
|
-
if (status && allowStale && void 0 !== value.__staleWhileFetching) status.returnedStale = true;
|
|
6092
|
-
return allowStale ? value.__staleWhileFetching : void 0;
|
|
6093
|
-
}
|
|
6094
|
-
if (!noDeleteOnStaleGet) this.#delete(k, 'expire');
|
|
6095
|
-
if (status && allowStale) status.returnedStale = true;
|
|
6096
|
-
return allowStale ? value : void 0;
|
|
6097
|
-
}
|
|
6098
|
-
if (status) status.get = 'hit';
|
|
6099
|
-
if (fetching) return value.__staleWhileFetching;
|
|
6100
|
-
this.#moveToTail(index);
|
|
6101
|
-
if (updateAgeOnGet) this.#updateItemAge(index);
|
|
6102
|
-
return value;
|
|
5427
|
+
return n && (n.value = c), this.#O(e1, c, r), c;
|
|
5428
|
+
}
|
|
5429
|
+
get(e1, t1 = {}) {
|
|
5430
|
+
let { status: i = S.hasSubscribers ? {} : void 0 } = t1;
|
|
5431
|
+
t1.status = i, i && (i.op = "get", i.key = e1);
|
|
5432
|
+
let s = this.#C(e1, t1);
|
|
5433
|
+
return i && (void 0 !== s && (i.value = s), S.hasSubscribers && S.publish(i)), s;
|
|
5434
|
+
}
|
|
5435
|
+
#C(e1, t1 = {}) {
|
|
5436
|
+
let { allowStale: i = this.allowStale, updateAgeOnGet: s = this.updateAgeOnGet, noDeleteOnStaleGet: n = this.noDeleteOnStaleGet, status: o } = t1, r = this.#s.get(e1);
|
|
5437
|
+
if (void 0 === r) {
|
|
5438
|
+
o && (o.get = "miss");
|
|
5439
|
+
return;
|
|
6103
5440
|
}
|
|
6104
|
-
|
|
5441
|
+
let h = this.#t[r], l = this.#e(h);
|
|
5442
|
+
return o && this.#E(o, r), this.#p(r) ? l ? (o && (o.get = "stale-fetching"), i && void 0 !== h.__staleWhileFetching ? (o && (o.returnedStale = !0), h.__staleWhileFetching) : void 0) : (n || this.#v(e1, "expire"), o && (o.get = "stale"), i ? (o && (o.returnedStale = !0), h) : void 0) : (o && (o.get = l ? "fetching" : "hit"), this.#L(r), s && this.#x(r), l ? h.__staleWhileFetching : h);
|
|
6105
5443
|
}
|
|
6106
|
-
|
|
6107
|
-
this.#
|
|
6108
|
-
this.#next[p] = n;
|
|
5444
|
+
#$(e1, t1) {
|
|
5445
|
+
this.#c[t1] = e1, this.#a[e1] = t1;
|
|
6109
5446
|
}
|
|
6110
|
-
#
|
|
6111
|
-
|
|
6112
|
-
if (index === this.#head) this.#head = this.#next[index];
|
|
6113
|
-
else this.#connect(this.#prev[index], this.#next[index]);
|
|
6114
|
-
this.#connect(this.#tail, index);
|
|
6115
|
-
this.#tail = index;
|
|
6116
|
-
}
|
|
5447
|
+
#L(e1) {
|
|
5448
|
+
e1 !== this.#h && (e1 === this.#l ? this.#l = this.#a[e1] : this.#$(this.#c[e1], this.#a[e1]), this.#$(this.#h, e1), this.#h = e1);
|
|
6117
5449
|
}
|
|
6118
|
-
delete(
|
|
6119
|
-
return this.#
|
|
5450
|
+
delete(e1) {
|
|
5451
|
+
return this.#v(e1, "delete");
|
|
6120
5452
|
}
|
|
6121
|
-
#
|
|
6122
|
-
|
|
6123
|
-
|
|
6124
|
-
|
|
6125
|
-
|
|
6126
|
-
|
|
6127
|
-
|
|
5453
|
+
#v(e1, t1) {
|
|
5454
|
+
S.hasSubscribers && S.publish({
|
|
5455
|
+
op: "delete",
|
|
5456
|
+
delete: t1,
|
|
5457
|
+
key: e1
|
|
5458
|
+
});
|
|
5459
|
+
let i = !1;
|
|
5460
|
+
if (0 !== this.#n) {
|
|
5461
|
+
let s = this.#s.get(e1);
|
|
5462
|
+
if (void 0 !== s) if (this.#g?.[s] && (clearTimeout(this.#g?.[s]), this.#g[s] = void 0), i = !0, 1 === this.#n) this.#q(t1);
|
|
5463
|
+
else {
|
|
5464
|
+
this.#R(s);
|
|
5465
|
+
let n = this.#t[s];
|
|
5466
|
+
if (this.#e(n) ? n.__abortController.abort(new Error("deleted")) : (this.#T || this.#f) && (this.#T && this.#w?.(n, e1, t1), this.#f && this.#r?.push([
|
|
5467
|
+
n,
|
|
5468
|
+
e1,
|
|
5469
|
+
t1
|
|
5470
|
+
])), this.#s.delete(e1), this.#i[s] = void 0, this.#t[s] = void 0, s === this.#h) this.#h = this.#c[s];
|
|
5471
|
+
else if (s === this.#l) this.#l = this.#a[s];
|
|
6128
5472
|
else {
|
|
6129
|
-
this.#
|
|
6130
|
-
|
|
6131
|
-
|
|
6132
|
-
|
|
6133
|
-
if (this.#hasDispose) this.#dispose?.(v, k, reason);
|
|
6134
|
-
if (this.#hasDisposeAfter) this.#disposed?.push([
|
|
6135
|
-
v,
|
|
6136
|
-
k,
|
|
6137
|
-
reason
|
|
6138
|
-
]);
|
|
6139
|
-
}
|
|
6140
|
-
this.#keyMap.delete(k);
|
|
6141
|
-
this.#keyList[index] = void 0;
|
|
6142
|
-
this.#valList[index] = void 0;
|
|
6143
|
-
if (index === this.#tail) this.#tail = this.#prev[index];
|
|
6144
|
-
else if (index === this.#head) this.#head = this.#next[index];
|
|
6145
|
-
else {
|
|
6146
|
-
const pi = this.#prev[index];
|
|
6147
|
-
this.#next[pi] = this.#next[index];
|
|
6148
|
-
const ni = this.#next[index];
|
|
6149
|
-
this.#prev[ni] = this.#prev[index];
|
|
6150
|
-
}
|
|
6151
|
-
this.#size--;
|
|
6152
|
-
this.#free.push(index);
|
|
5473
|
+
let o = this.#c[s];
|
|
5474
|
+
this.#a[o] = this.#a[s];
|
|
5475
|
+
let r = this.#a[s];
|
|
5476
|
+
this.#c[r] = this.#c[s];
|
|
6153
5477
|
}
|
|
5478
|
+
this.#n--, this.#y.push(s);
|
|
6154
5479
|
}
|
|
6155
5480
|
}
|
|
6156
|
-
if (this.#
|
|
6157
|
-
|
|
6158
|
-
|
|
6159
|
-
while(task = dt?.shift())this.#disposeAfter?.(...task);
|
|
5481
|
+
if (this.#f && this.#r?.length) {
|
|
5482
|
+
let s = this.#r, n;
|
|
5483
|
+
for(; n = s?.shift();)this.#S?.(...n);
|
|
6160
5484
|
}
|
|
6161
|
-
return
|
|
5485
|
+
return i;
|
|
6162
5486
|
}
|
|
6163
5487
|
clear() {
|
|
6164
|
-
return this.#
|
|
5488
|
+
return this.#q("delete");
|
|
6165
5489
|
}
|
|
6166
|
-
#
|
|
6167
|
-
for (
|
|
6168
|
-
allowStale:
|
|
5490
|
+
#q(e1) {
|
|
5491
|
+
for (let t1 of this.#z({
|
|
5492
|
+
allowStale: !0
|
|
6169
5493
|
})){
|
|
6170
|
-
|
|
6171
|
-
if (this.#
|
|
5494
|
+
let i = this.#t[t1];
|
|
5495
|
+
if (this.#e(i)) i.__abortController.abort(new Error("deleted"));
|
|
6172
5496
|
else {
|
|
6173
|
-
|
|
6174
|
-
|
|
6175
|
-
|
|
6176
|
-
|
|
6177
|
-
|
|
6178
|
-
reason
|
|
5497
|
+
let s = this.#i[t1];
|
|
5498
|
+
this.#T && this.#w?.(i, s, e1), this.#f && this.#r?.push([
|
|
5499
|
+
i,
|
|
5500
|
+
s,
|
|
5501
|
+
e1
|
|
6179
5502
|
]);
|
|
6180
5503
|
}
|
|
6181
5504
|
}
|
|
6182
|
-
this.#
|
|
6183
|
-
|
|
6184
|
-
|
|
6185
|
-
|
|
6186
|
-
this.#ttls.fill(0);
|
|
6187
|
-
this.#starts.fill(0);
|
|
5505
|
+
if (this.#s.clear(), this.#t.fill(void 0), this.#i.fill(void 0), this.#d && this.#F) {
|
|
5506
|
+
this.#d.fill(0), this.#F.fill(0);
|
|
5507
|
+
for (let t1 of this.#g ?? [])void 0 !== t1 && clearTimeout(t1);
|
|
5508
|
+
this.#g?.fill(void 0);
|
|
6188
5509
|
}
|
|
6189
|
-
if (this.#
|
|
6190
|
-
|
|
6191
|
-
|
|
6192
|
-
this.#free.length = 0;
|
|
6193
|
-
this.#calculatedSize = 0;
|
|
6194
|
-
this.#size = 0;
|
|
6195
|
-
if (this.#hasDisposeAfter && this.#disposed) {
|
|
6196
|
-
const dt = this.#disposed;
|
|
6197
|
-
let task;
|
|
6198
|
-
while(task = dt?.shift())this.#disposeAfter?.(...task);
|
|
5510
|
+
if (this.#_ && this.#_.fill(0), this.#l = 0, this.#h = 0, this.#y.length = 0, this.#b = 0, this.#n = 0, this.#f && this.#r) {
|
|
5511
|
+
let t1 = this.#r, i;
|
|
5512
|
+
for(; i = t1?.shift();)this.#S?.(...i);
|
|
6199
5513
|
}
|
|
6200
5514
|
}
|
|
6201
|
-
}
|
|
5515
|
+
};
|
|
6202
5516
|
var external_fs_ = __webpack_require__("fs");
|
|
6203
5517
|
const promises_namespaceObject = require("node:fs/promises");
|
|
6204
5518
|
const external_node_events_namespaceObject = require("node:events");
|
|
@@ -6275,7 +5589,7 @@ var __webpack_modules__ = {
|
|
|
6275
5589
|
}
|
|
6276
5590
|
constructor(src, dest, opts){
|
|
6277
5591
|
super(src, dest, opts);
|
|
6278
|
-
this.proxyErrors = (er)=>dest.emit('error', er);
|
|
5592
|
+
this.proxyErrors = (er)=>this.dest.emit('error', er);
|
|
6279
5593
|
src.on('error', this.proxyErrors);
|
|
6280
5594
|
}
|
|
6281
5595
|
}
|
|
@@ -6727,7 +6041,8 @@ var __webpack_modules__ = {
|
|
|
6727
6041
|
return: stop,
|
|
6728
6042
|
[Symbol.asyncIterator] () {
|
|
6729
6043
|
return this;
|
|
6730
|
-
}
|
|
6044
|
+
},
|
|
6045
|
+
[Symbol.asyncDispose]: async ()=>{}
|
|
6731
6046
|
};
|
|
6732
6047
|
}
|
|
6733
6048
|
[Symbol.iterator]() {
|
|
@@ -6761,7 +6076,8 @@ var __webpack_modules__ = {
|
|
|
6761
6076
|
return: stop,
|
|
6762
6077
|
[Symbol.iterator] () {
|
|
6763
6078
|
return this;
|
|
6764
|
-
}
|
|
6079
|
+
},
|
|
6080
|
+
[Symbol.dispose]: ()=>{}
|
|
6765
6081
|
};
|
|
6766
6082
|
}
|
|
6767
6083
|
destroy(er) {
|
|
@@ -6798,7 +6114,7 @@ var __webpack_modules__ = {
|
|
|
6798
6114
|
realpath: promises_namespaceObject.realpath
|
|
6799
6115
|
}
|
|
6800
6116
|
};
|
|
6801
|
-
const fsFromOption = (fsOption)=>fsOption && fsOption !== defaultFS && fsOption !==
|
|
6117
|
+
const fsFromOption = (fsOption)=>fsOption && fsOption !== defaultFS && fsOption !== external_node_fs_namespaceObject ? {
|
|
6802
6118
|
...defaultFS,
|
|
6803
6119
|
...fsOption,
|
|
6804
6120
|
promises: {
|
|
@@ -6828,7 +6144,9 @@ var __webpack_modules__ = {
|
|
|
6828
6144
|
const ENOCHILD = ENOTDIR | ENOENT | ENOREALPATH;
|
|
6829
6145
|
const TYPEMASK = 1023;
|
|
6830
6146
|
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;
|
|
6831
|
-
const normalizeCache = new
|
|
6147
|
+
const normalizeCache = new L({
|
|
6148
|
+
max: 4096
|
|
6149
|
+
});
|
|
6832
6150
|
const normalize = (s)=>{
|
|
6833
6151
|
const c = normalizeCache.get(s);
|
|
6834
6152
|
if (c) return c;
|
|
@@ -6836,7 +6154,9 @@ var __webpack_modules__ = {
|
|
|
6836
6154
|
normalizeCache.set(s, n);
|
|
6837
6155
|
return n;
|
|
6838
6156
|
};
|
|
6839
|
-
const normalizeNocaseCache = new
|
|
6157
|
+
const normalizeNocaseCache = new L({
|
|
6158
|
+
max: 4096
|
|
6159
|
+
});
|
|
6840
6160
|
const normalizeNocase = (s)=>{
|
|
6841
6161
|
const c = normalizeNocaseCache.get(s);
|
|
6842
6162
|
if (c) return c;
|
|
@@ -6844,14 +6164,14 @@ var __webpack_modules__ = {
|
|
|
6844
6164
|
normalizeNocaseCache.set(s, n);
|
|
6845
6165
|
return n;
|
|
6846
6166
|
};
|
|
6847
|
-
class ResolveCache extends
|
|
6167
|
+
class ResolveCache extends L {
|
|
6848
6168
|
constructor(){
|
|
6849
6169
|
super({
|
|
6850
6170
|
max: 256
|
|
6851
6171
|
});
|
|
6852
6172
|
}
|
|
6853
6173
|
}
|
|
6854
|
-
class ChildrenCache extends
|
|
6174
|
+
class ChildrenCache extends L {
|
|
6855
6175
|
constructor(maxSize = 16384){
|
|
6856
6176
|
super({
|
|
6857
6177
|
maxSize,
|
|
@@ -7405,7 +6725,7 @@ var __webpack_modules__ = {
|
|
|
7405
6725
|
return new PathWin32(name, type, this.root, this.roots, this.nocase, this.childrenCache(), opts);
|
|
7406
6726
|
}
|
|
7407
6727
|
getRootString(path) {
|
|
7408
|
-
return
|
|
6728
|
+
return external_node_path_.win32.parse(path).root;
|
|
7409
6729
|
}
|
|
7410
6730
|
getRoot(rootPath) {
|
|
7411
6731
|
rootPath = uncToDrive(rootPath.toUpperCase());
|
|
@@ -7446,7 +6766,7 @@ var __webpack_modules__ = {
|
|
|
7446
6766
|
#fs;
|
|
7447
6767
|
constructor(cwd = process.cwd(), pathImpl, sep, { nocase, childrenCacheSize = 16384, fs = defaultFS } = {}){
|
|
7448
6768
|
this.#fs = fsFromOption(fs);
|
|
7449
|
-
if (cwd instanceof URL || cwd.startsWith('file://')) cwd = (0,
|
|
6769
|
+
if (cwd instanceof URL || cwd.startsWith('file://')) cwd = (0, external_node_url_.fileURLToPath)(cwd);
|
|
7450
6770
|
const cwdPath = pathImpl.resolve(cwd);
|
|
7451
6771
|
this.roots = Object.create(null);
|
|
7452
6772
|
this.rootPath = this.parseRootPath(cwdPath);
|
|
@@ -7814,7 +7134,7 @@ var __webpack_modules__ = {
|
|
|
7814
7134
|
sep = '\\';
|
|
7815
7135
|
constructor(cwd = process.cwd(), opts = {}){
|
|
7816
7136
|
const { nocase = true } = opts;
|
|
7817
|
-
super(cwd,
|
|
7137
|
+
super(cwd, external_node_path_.win32, '\\', {
|
|
7818
7138
|
...opts,
|
|
7819
7139
|
nocase
|
|
7820
7140
|
});
|
|
@@ -7822,7 +7142,7 @@ var __webpack_modules__ = {
|
|
|
7822
7142
|
for(let p = this.cwd; p; p = p.parent)p.nocase = this.nocase;
|
|
7823
7143
|
}
|
|
7824
7144
|
parseRootPath(dir) {
|
|
7825
|
-
return
|
|
7145
|
+
return external_node_path_.win32.parse(dir).root.toUpperCase();
|
|
7826
7146
|
}
|
|
7827
7147
|
newRoot(fs) {
|
|
7828
7148
|
return new PathWin32(this.rootPath, IFDIR, void 0, this.roots, this.nocase, this.childrenCache(), {
|
|
@@ -7837,7 +7157,7 @@ var __webpack_modules__ = {
|
|
|
7837
7157
|
sep = '/';
|
|
7838
7158
|
constructor(cwd = process.cwd(), opts = {}){
|
|
7839
7159
|
const { nocase = false } = opts;
|
|
7840
|
-
super(cwd,
|
|
7160
|
+
super(cwd, external_node_path_.posix, '/', {
|
|
7841
7161
|
...opts,
|
|
7842
7162
|
nocase
|
|
7843
7163
|
});
|
|
@@ -8536,7 +7856,7 @@ var __webpack_modules__ = {
|
|
|
8536
7856
|
this.nodir = !!opts.nodir;
|
|
8537
7857
|
this.mark = !!opts.mark;
|
|
8538
7858
|
if (opts.cwd) {
|
|
8539
|
-
if (opts.cwd instanceof URL || opts.cwd.startsWith('file://')) opts.cwd = (0,
|
|
7859
|
+
if (opts.cwd instanceof URL || opts.cwd.startsWith('file://')) opts.cwd = (0, external_node_url_.fileURLToPath)(opts.cwd);
|
|
8540
7860
|
} else this.cwd = '';
|
|
8541
7861
|
this.cwd = opts.cwd || '';
|
|
8542
7862
|
this.root = opts.root;
|
|
@@ -8688,7 +8008,7 @@ var __webpack_modules__ = {
|
|
|
8688
8008
|
return new Glob(pattern, options).iterate();
|
|
8689
8009
|
}
|
|
8690
8010
|
const streamSync = globStreamSync;
|
|
8691
|
-
const
|
|
8011
|
+
const stream = Object.assign(globStream, {
|
|
8692
8012
|
sync: globStreamSync
|
|
8693
8013
|
});
|
|
8694
8014
|
const iterateSync = globIterateSync;
|
|
@@ -8704,7 +8024,7 @@ var __webpack_modules__ = {
|
|
|
8704
8024
|
globSync,
|
|
8705
8025
|
sync: esm_sync,
|
|
8706
8026
|
globStream,
|
|
8707
|
-
stream
|
|
8027
|
+
stream,
|
|
8708
8028
|
globStreamSync,
|
|
8709
8029
|
streamSync,
|
|
8710
8030
|
globIterate,
|
|
@@ -9564,7 +8884,7 @@ var __webpack_modules__ = {
|
|
|
9564
8884
|
var external_assert_ = __webpack_require__("assert");
|
|
9565
8885
|
new RegExp("\x1b(?:\\[(?:\\d+[ABCDEFGJKSTm]|\\d+;\\d+[Hfm]|\\d+;\\d+;\\d+m|6n|s|u|\\?25[lh])|\\w)", 'g');
|
|
9566
8886
|
const external_url_namespaceObject = require("url");
|
|
9567
|
-
const
|
|
8887
|
+
const node = {
|
|
9568
8888
|
fs: {
|
|
9569
8889
|
readFileSync: external_fs_.readFileSync,
|
|
9570
8890
|
writeFile: external_fs_.writeFile
|
|
@@ -9714,7 +9034,7 @@ var __webpack_modules__ = {
|
|
|
9714
9034
|
locale: y18n.locale
|
|
9715
9035
|
};
|
|
9716
9036
|
}
|
|
9717
|
-
const y18n_y18n = (opts)=>lib_y18n(opts,
|
|
9037
|
+
const y18n_y18n = (opts)=>lib_y18n(opts, node);
|
|
9718
9038
|
const node_modules_y18n = y18n_y18n;
|
|
9719
9039
|
let esm_dirname;
|
|
9720
9040
|
try {
|
|
@@ -9733,6 +9053,8 @@ var __webpack_modules__ = {
|
|
|
9733
9053
|
Yargs.hideBin = processArgv.hideBin;
|
|
9734
9054
|
Yargs.Parser = yargs_Parser;
|
|
9735
9055
|
const yargs = Yargs;
|
|
9056
|
+
const external_node_process_namespaceObject = require("node:process");
|
|
9057
|
+
var yaml_ = __webpack_require__("@midscene/core/yaml");
|
|
9736
9058
|
/*! js-yaml 4.1.0 https://github.com/nodeca/js-yaml @license MIT */ function isNothing(subject) {
|
|
9737
9059
|
return null == subject;
|
|
9738
9060
|
}
|
|
@@ -11805,12 +11127,14 @@ var __webpack_modules__ = {
|
|
|
11805
11127
|
throw new Error('Function yaml.' + from + " is removed in js-yaml 4. Use yaml." + to + ' instead, which is now safe by default.');
|
|
11806
11128
|
};
|
|
11807
11129
|
}
|
|
11808
|
-
var
|
|
11130
|
+
var load = loader.load;
|
|
11809
11131
|
loader.loadAll;
|
|
11810
11132
|
dumper.dump;
|
|
11811
11133
|
renamed('safeLoad', 'load');
|
|
11812
11134
|
renamed('safeLoadAll', 'loadAll');
|
|
11813
11135
|
renamed('safeDump', 'dump');
|
|
11136
|
+
var external_lodash_merge_ = __webpack_require__("lodash.merge");
|
|
11137
|
+
var external_lodash_merge_default = /*#__PURE__*/ __webpack_require__.n(external_lodash_merge_);
|
|
11814
11138
|
const config_factory_defaultConfig = {
|
|
11815
11139
|
concurrent: 1,
|
|
11816
11140
|
continueOnError: false,
|
|
@@ -11833,19 +11157,19 @@ var __webpack_modules__ = {
|
|
|
11833
11157
|
return allFiles;
|
|
11834
11158
|
}
|
|
11835
11159
|
async function parseConfigYaml(configYamlPath) {
|
|
11836
|
-
const basePath = (0,
|
|
11837
|
-
const configContent = (0,
|
|
11838
|
-
const interpolatedContent = (0,
|
|
11160
|
+
const basePath = (0, external_node_path_.dirname)((0, external_node_path_.resolve)(configYamlPath));
|
|
11161
|
+
const configContent = (0, external_node_fs_.readFileSync)(configYamlPath, 'utf8');
|
|
11162
|
+
const interpolatedContent = (0, yaml_.interpolateEnvVars)(configContent);
|
|
11839
11163
|
let configYaml;
|
|
11840
11164
|
try {
|
|
11841
|
-
configYaml =
|
|
11165
|
+
configYaml = load(interpolatedContent);
|
|
11842
11166
|
} catch (error) {
|
|
11843
11167
|
throw new Error(`Failed to parse config YAML: ${error}`);
|
|
11844
11168
|
}
|
|
11845
11169
|
if (!configYaml?.files || !Array.isArray(configYaml?.files)) throw new Error('Config YAML must contain a "files" array');
|
|
11846
11170
|
const files = await expandFilePatterns(configYaml?.files, basePath);
|
|
11847
11171
|
if (0 === files.length) throw new Error('No YAML files found matching the patterns in "files"');
|
|
11848
|
-
const configFileName = (0,
|
|
11172
|
+
const configFileName = (0, external_node_path_.basename)(configYamlPath, (0, external_node_path_.extname)(configYamlPath));
|
|
11849
11173
|
const timestamp = Date.now();
|
|
11850
11174
|
const defaultSummary = `${configFileName}-${timestamp}.json`;
|
|
11851
11175
|
const config = {
|
|
@@ -11882,7 +11206,7 @@ var __webpack_modules__ = {
|
|
|
11882
11206
|
const finalHeaded = keepWindow || headed;
|
|
11883
11207
|
let files = parsedConfig.files;
|
|
11884
11208
|
if (options?.files && options.files.length > 0) {
|
|
11885
|
-
const basePath = (0,
|
|
11209
|
+
const basePath = (0, external_node_path_.dirname)((0, external_node_path_.resolve)(configYamlPath));
|
|
11886
11210
|
files = await expandFilePatterns(options.files, basePath);
|
|
11887
11211
|
}
|
|
11888
11212
|
return {
|
|
@@ -11922,7 +11246,7 @@ var __webpack_modules__ = {
|
|
|
11922
11246
|
}
|
|
11923
11247
|
};
|
|
11924
11248
|
}
|
|
11925
|
-
const
|
|
11249
|
+
const debug = (0, logger_.getDebug)('midscene:cli');
|
|
11926
11250
|
function kebabToCamel(str) {
|
|
11927
11251
|
return str.replace(/-([a-z])/g, (_, letter)=>letter.toUpperCase());
|
|
11928
11252
|
}
|
|
@@ -11981,7 +11305,7 @@ Usage:
|
|
|
11981
11305
|
type: 'boolean',
|
|
11982
11306
|
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}`
|
|
11983
11307
|
}
|
|
11984
|
-
}).version('version', 'Show version number', "1.8.
|
|
11308
|
+
}).version('version', 'Show version number', "1.8.8-beta-20260601092605.0").help().epilogue(`For complete list of configuration options, please visit:
|
|
11985
11309
|
• Web options: https://midscenejs.com/automate-with-scripts-in-yaml#the-web-part
|
|
11986
11310
|
• Android options: https://midscenejs.com/automate-with-scripts-in-yaml#the-android-part
|
|
11987
11311
|
• iOS options: https://midscenejs.com/automate-with-scripts-in-yaml#the-ios-part
|
|
@@ -11991,7 +11315,7 @@ Examples:
|
|
|
11991
11315
|
$0 script.yaml --android.device-id emulator-5554 --android.ime-strategy yadb-for-non-ascii
|
|
11992
11316
|
$0 script.yaml --ios.wda-port 8100 --ios.auto-dismiss-keyboard`).wrap(yargs().terminalWidth());
|
|
11993
11317
|
const argv = await args.argv;
|
|
11994
|
-
|
|
11318
|
+
debug('argv', argv);
|
|
11995
11319
|
const transformedArgv = {
|
|
11996
11320
|
...argv
|
|
11997
11321
|
};
|
|
@@ -12015,7 +11339,7 @@ Examples:
|
|
|
12015
11339
|
};
|
|
12016
11340
|
};
|
|
12017
11341
|
async function matchYamlFiles(fileGlob, options) {
|
|
12018
|
-
if ((0,
|
|
11342
|
+
if ((0, external_node_fs_.existsSync)(fileGlob) && (0, external_node_fs_.statSync)(fileGlob).isDirectory()) fileGlob = (0, external_node_path_.join)(fileGlob, '**/*.{yml,yaml}');
|
|
12019
11343
|
const { cwd } = options || {};
|
|
12020
11344
|
const ignore = [
|
|
12021
11345
|
'**/node_modules/**'
|
|
@@ -12029,6 +11353,7 @@ Examples:
|
|
|
12029
11353
|
});
|
|
12030
11354
|
return files.filter((file)=>file.endsWith('.yml') || file.endsWith('.yaml')).sort();
|
|
12031
11355
|
}
|
|
11356
|
+
var framework = __webpack_require__("./src/framework/index.ts");
|
|
12032
11357
|
Promise.resolve((async ()=>{
|
|
12033
11358
|
const rawArgs = process.argv.slice(2);
|
|
12034
11359
|
const [firstArg] = rawArgs;
|
|
@@ -12087,8 +11412,8 @@ Examples:
|
|
|
12087
11412
|
console.error('Could not create a valid configuration.');
|
|
12088
11413
|
process.exit(1);
|
|
12089
11414
|
}
|
|
12090
|
-
const dotEnvConfigFile = (0,
|
|
12091
|
-
if ((0,
|
|
11415
|
+
const dotEnvConfigFile = (0, external_node_path_.join)(process.cwd(), '.env');
|
|
11416
|
+
if ((0, external_node_fs_.existsSync)(dotEnvConfigFile)) {
|
|
12092
11417
|
console.log(` Env file: ${dotEnvConfigFile}`);
|
|
12093
11418
|
main_default().config({
|
|
12094
11419
|
path: dotEnvConfigFile,
|
|
@@ -12096,21 +11421,24 @@ Examples:
|
|
|
12096
11421
|
override: config.dotenvOverride
|
|
12097
11422
|
});
|
|
12098
11423
|
}
|
|
12099
|
-
const
|
|
12100
|
-
await executor.run();
|
|
12101
|
-
const success = executor.printExecutionSummary();
|
|
11424
|
+
const exitCode = await (0, framework.runFrameworkTestConfig)(config);
|
|
12102
11425
|
if (config.keepWindow) setInterval(()=>{
|
|
12103
11426
|
console.log('browser is still running, use ctrl+c to stop it');
|
|
12104
11427
|
}, 5000);
|
|
12105
|
-
else
|
|
12106
|
-
if (!success) process.exit(1);
|
|
12107
|
-
process.exit(0);
|
|
12108
|
-
}
|
|
11428
|
+
else process.exit(exitCode);
|
|
12109
11429
|
})().catch((e1)=>{
|
|
12110
11430
|
console.error(e1);
|
|
12111
11431
|
process.exit(1);
|
|
12112
11432
|
}));
|
|
12113
11433
|
},
|
|
11434
|
+
"@midscene/core/yaml" (module) {
|
|
11435
|
+
"use strict";
|
|
11436
|
+
module.exports = require("@midscene/core/yaml");
|
|
11437
|
+
},
|
|
11438
|
+
"@midscene/shared/logger" (module) {
|
|
11439
|
+
"use strict";
|
|
11440
|
+
module.exports = require("@midscene/shared/logger");
|
|
11441
|
+
},
|
|
12114
11442
|
assert (module) {
|
|
12115
11443
|
"use strict";
|
|
12116
11444
|
module.exports = require("assert");
|
|
@@ -12123,6 +11451,22 @@ Examples:
|
|
|
12123
11451
|
"use strict";
|
|
12124
11452
|
module.exports = require("fs");
|
|
12125
11453
|
},
|
|
11454
|
+
"lodash.merge" (module) {
|
|
11455
|
+
"use strict";
|
|
11456
|
+
module.exports = require("lodash.merge");
|
|
11457
|
+
},
|
|
11458
|
+
"node:fs" (module) {
|
|
11459
|
+
"use strict";
|
|
11460
|
+
module.exports = require("node:fs");
|
|
11461
|
+
},
|
|
11462
|
+
"node:path" (module) {
|
|
11463
|
+
"use strict";
|
|
11464
|
+
module.exports = require("node:path");
|
|
11465
|
+
},
|
|
11466
|
+
"node:url" (module) {
|
|
11467
|
+
"use strict";
|
|
11468
|
+
module.exports = require("node:url");
|
|
11469
|
+
},
|
|
12126
11470
|
os (module) {
|
|
12127
11471
|
"use strict";
|
|
12128
11472
|
module.exports = require("os");
|