@midscene/cli 1.8.7 → 1.8.8-beta-20260601092817.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.
@@ -0,0 +1,3989 @@
1
+ var __webpack_modules__ = {
2
+ "../../node_modules/.pnpm/ansi-styles@4.3.0/node_modules/ansi-styles/index.js" (module, __unused_rspack_exports, __webpack_require__) {
3
+ "use strict";
4
+ module = __webpack_require__.nmd(module);
5
+ const wrapAnsi16 = (fn, offset)=>(...args)=>{
6
+ const code = fn(...args);
7
+ return `\u001B[${code + offset}m`;
8
+ };
9
+ const wrapAnsi256 = (fn, offset)=>(...args)=>{
10
+ const code = fn(...args);
11
+ return `\u001B[${38 + offset};5;${code}m`;
12
+ };
13
+ const wrapAnsi16m = (fn, offset)=>(...args)=>{
14
+ const rgb = fn(...args);
15
+ return `\u001B[${38 + offset};2;${rgb[0]};${rgb[1]};${rgb[2]}m`;
16
+ };
17
+ const ansi2ansi = (n)=>n;
18
+ const rgb2rgb = (r, g, b)=>[
19
+ r,
20
+ g,
21
+ b
22
+ ];
23
+ const setLazyProperty = (object, property, get)=>{
24
+ Object.defineProperty(object, property, {
25
+ get: ()=>{
26
+ const value = get();
27
+ Object.defineProperty(object, property, {
28
+ value,
29
+ enumerable: true,
30
+ configurable: true
31
+ });
32
+ return value;
33
+ },
34
+ enumerable: true,
35
+ configurable: true
36
+ });
37
+ };
38
+ let colorConvert;
39
+ const makeDynamicStyles = (wrap, targetSpace, identity, isBackground)=>{
40
+ if (void 0 === colorConvert) colorConvert = __webpack_require__("../../node_modules/.pnpm/color-convert@2.0.1/node_modules/color-convert/index.js");
41
+ const offset = isBackground ? 10 : 0;
42
+ const styles = {};
43
+ for (const [sourceSpace, suite] of Object.entries(colorConvert)){
44
+ const name = 'ansi16' === sourceSpace ? 'ansi' : sourceSpace;
45
+ if (sourceSpace === targetSpace) styles[name] = wrap(identity, offset);
46
+ else if ('object' == typeof suite) styles[name] = wrap(suite[targetSpace], offset);
47
+ }
48
+ return styles;
49
+ };
50
+ function assembleStyles() {
51
+ const codes = new Map();
52
+ const styles = {
53
+ modifier: {
54
+ reset: [
55
+ 0,
56
+ 0
57
+ ],
58
+ bold: [
59
+ 1,
60
+ 22
61
+ ],
62
+ dim: [
63
+ 2,
64
+ 22
65
+ ],
66
+ italic: [
67
+ 3,
68
+ 23
69
+ ],
70
+ underline: [
71
+ 4,
72
+ 24
73
+ ],
74
+ inverse: [
75
+ 7,
76
+ 27
77
+ ],
78
+ hidden: [
79
+ 8,
80
+ 28
81
+ ],
82
+ strikethrough: [
83
+ 9,
84
+ 29
85
+ ]
86
+ },
87
+ color: {
88
+ black: [
89
+ 30,
90
+ 39
91
+ ],
92
+ red: [
93
+ 31,
94
+ 39
95
+ ],
96
+ green: [
97
+ 32,
98
+ 39
99
+ ],
100
+ yellow: [
101
+ 33,
102
+ 39
103
+ ],
104
+ blue: [
105
+ 34,
106
+ 39
107
+ ],
108
+ magenta: [
109
+ 35,
110
+ 39
111
+ ],
112
+ cyan: [
113
+ 36,
114
+ 39
115
+ ],
116
+ white: [
117
+ 37,
118
+ 39
119
+ ],
120
+ blackBright: [
121
+ 90,
122
+ 39
123
+ ],
124
+ redBright: [
125
+ 91,
126
+ 39
127
+ ],
128
+ greenBright: [
129
+ 92,
130
+ 39
131
+ ],
132
+ yellowBright: [
133
+ 93,
134
+ 39
135
+ ],
136
+ blueBright: [
137
+ 94,
138
+ 39
139
+ ],
140
+ magentaBright: [
141
+ 95,
142
+ 39
143
+ ],
144
+ cyanBright: [
145
+ 96,
146
+ 39
147
+ ],
148
+ whiteBright: [
149
+ 97,
150
+ 39
151
+ ]
152
+ },
153
+ bgColor: {
154
+ bgBlack: [
155
+ 40,
156
+ 49
157
+ ],
158
+ bgRed: [
159
+ 41,
160
+ 49
161
+ ],
162
+ bgGreen: [
163
+ 42,
164
+ 49
165
+ ],
166
+ bgYellow: [
167
+ 43,
168
+ 49
169
+ ],
170
+ bgBlue: [
171
+ 44,
172
+ 49
173
+ ],
174
+ bgMagenta: [
175
+ 45,
176
+ 49
177
+ ],
178
+ bgCyan: [
179
+ 46,
180
+ 49
181
+ ],
182
+ bgWhite: [
183
+ 47,
184
+ 49
185
+ ],
186
+ bgBlackBright: [
187
+ 100,
188
+ 49
189
+ ],
190
+ bgRedBright: [
191
+ 101,
192
+ 49
193
+ ],
194
+ bgGreenBright: [
195
+ 102,
196
+ 49
197
+ ],
198
+ bgYellowBright: [
199
+ 103,
200
+ 49
201
+ ],
202
+ bgBlueBright: [
203
+ 104,
204
+ 49
205
+ ],
206
+ bgMagentaBright: [
207
+ 105,
208
+ 49
209
+ ],
210
+ bgCyanBright: [
211
+ 106,
212
+ 49
213
+ ],
214
+ bgWhiteBright: [
215
+ 107,
216
+ 49
217
+ ]
218
+ }
219
+ };
220
+ styles.color.gray = styles.color.blackBright;
221
+ styles.bgColor.bgGray = styles.bgColor.bgBlackBright;
222
+ styles.color.grey = styles.color.blackBright;
223
+ styles.bgColor.bgGrey = styles.bgColor.bgBlackBright;
224
+ for (const [groupName, group] of Object.entries(styles)){
225
+ for (const [styleName, style] of Object.entries(group)){
226
+ styles[styleName] = {
227
+ open: `\u001B[${style[0]}m`,
228
+ close: `\u001B[${style[1]}m`
229
+ };
230
+ group[styleName] = styles[styleName];
231
+ codes.set(style[0], style[1]);
232
+ }
233
+ Object.defineProperty(styles, groupName, {
234
+ value: group,
235
+ enumerable: false
236
+ });
237
+ }
238
+ Object.defineProperty(styles, 'codes', {
239
+ value: codes,
240
+ enumerable: false
241
+ });
242
+ styles.color.close = '\u001B[39m';
243
+ styles.bgColor.close = '\u001B[49m';
244
+ setLazyProperty(styles.color, 'ansi', ()=>makeDynamicStyles(wrapAnsi16, 'ansi16', ansi2ansi, false));
245
+ setLazyProperty(styles.color, 'ansi256', ()=>makeDynamicStyles(wrapAnsi256, 'ansi256', ansi2ansi, false));
246
+ setLazyProperty(styles.color, 'ansi16m', ()=>makeDynamicStyles(wrapAnsi16m, 'rgb', rgb2rgb, false));
247
+ setLazyProperty(styles.bgColor, 'ansi', ()=>makeDynamicStyles(wrapAnsi16, 'ansi16', ansi2ansi, true));
248
+ setLazyProperty(styles.bgColor, 'ansi256', ()=>makeDynamicStyles(wrapAnsi256, 'ansi256', ansi2ansi, true));
249
+ setLazyProperty(styles.bgColor, 'ansi16m', ()=>makeDynamicStyles(wrapAnsi16m, 'rgb', rgb2rgb, true));
250
+ return styles;
251
+ }
252
+ Object.defineProperty(module, 'exports', {
253
+ enumerable: true,
254
+ get: assembleStyles
255
+ });
256
+ },
257
+ "../../node_modules/.pnpm/chalk@4.1.2/node_modules/chalk/source/index.js" (module, __unused_rspack_exports, __webpack_require__) {
258
+ "use strict";
259
+ const ansiStyles = __webpack_require__("../../node_modules/.pnpm/ansi-styles@4.3.0/node_modules/ansi-styles/index.js");
260
+ const { stdout: stdoutColor, stderr: stderrColor } = __webpack_require__("../../node_modules/.pnpm/supports-color@7.2.0/node_modules/supports-color/index.js");
261
+ const { stringReplaceAll, stringEncaseCRLFWithFirstIndex } = __webpack_require__("../../node_modules/.pnpm/chalk@4.1.2/node_modules/chalk/source/util.js");
262
+ const { isArray } = Array;
263
+ const levelMapping = [
264
+ 'ansi',
265
+ 'ansi',
266
+ 'ansi256',
267
+ 'ansi16m'
268
+ ];
269
+ const styles = Object.create(null);
270
+ const applyOptions = (object, options = {})=>{
271
+ if (options.level && !(Number.isInteger(options.level) && options.level >= 0 && options.level <= 3)) throw new Error('The `level` option should be an integer from 0 to 3');
272
+ const colorLevel = stdoutColor ? stdoutColor.level : 0;
273
+ object.level = void 0 === options.level ? colorLevel : options.level;
274
+ };
275
+ class ChalkClass {
276
+ constructor(options){
277
+ return chalkFactory(options);
278
+ }
279
+ }
280
+ const chalkFactory = (options)=>{
281
+ const chalk = {};
282
+ applyOptions(chalk, options);
283
+ chalk.template = (...arguments_)=>chalkTag(chalk.template, ...arguments_);
284
+ Object.setPrototypeOf(chalk, Chalk.prototype);
285
+ Object.setPrototypeOf(chalk.template, chalk);
286
+ chalk.template.constructor = ()=>{
287
+ throw new Error('`chalk.constructor()` is deprecated. Use `new chalk.Instance()` instead.');
288
+ };
289
+ chalk.template.Instance = ChalkClass;
290
+ return chalk.template;
291
+ };
292
+ function Chalk(options) {
293
+ return chalkFactory(options);
294
+ }
295
+ for (const [styleName, style] of Object.entries(ansiStyles))styles[styleName] = {
296
+ get () {
297
+ const builder = createBuilder(this, createStyler(style.open, style.close, this._styler), this._isEmpty);
298
+ Object.defineProperty(this, styleName, {
299
+ value: builder
300
+ });
301
+ return builder;
302
+ }
303
+ };
304
+ styles.visible = {
305
+ get () {
306
+ const builder = createBuilder(this, this._styler, true);
307
+ Object.defineProperty(this, 'visible', {
308
+ value: builder
309
+ });
310
+ return builder;
311
+ }
312
+ };
313
+ const usedModels = [
314
+ 'rgb',
315
+ 'hex',
316
+ 'keyword',
317
+ 'hsl',
318
+ 'hsv',
319
+ 'hwb',
320
+ 'ansi',
321
+ 'ansi256'
322
+ ];
323
+ for (const model of usedModels)styles[model] = {
324
+ get () {
325
+ const { level } = this;
326
+ return function(...arguments_) {
327
+ const styler = createStyler(ansiStyles.color[levelMapping[level]][model](...arguments_), ansiStyles.color.close, this._styler);
328
+ return createBuilder(this, styler, this._isEmpty);
329
+ };
330
+ }
331
+ };
332
+ for (const model of usedModels){
333
+ const bgModel = 'bg' + model[0].toUpperCase() + model.slice(1);
334
+ styles[bgModel] = {
335
+ get () {
336
+ const { level } = this;
337
+ return function(...arguments_) {
338
+ const styler = createStyler(ansiStyles.bgColor[levelMapping[level]][model](...arguments_), ansiStyles.bgColor.close, this._styler);
339
+ return createBuilder(this, styler, this._isEmpty);
340
+ };
341
+ }
342
+ };
343
+ }
344
+ const proto = Object.defineProperties(()=>{}, {
345
+ ...styles,
346
+ level: {
347
+ enumerable: true,
348
+ get () {
349
+ return this._generator.level;
350
+ },
351
+ set (level) {
352
+ this._generator.level = level;
353
+ }
354
+ }
355
+ });
356
+ const createStyler = (open, close, parent)=>{
357
+ let openAll;
358
+ let closeAll;
359
+ if (void 0 === parent) {
360
+ openAll = open;
361
+ closeAll = close;
362
+ } else {
363
+ openAll = parent.openAll + open;
364
+ closeAll = close + parent.closeAll;
365
+ }
366
+ return {
367
+ open,
368
+ close,
369
+ openAll,
370
+ closeAll,
371
+ parent
372
+ };
373
+ };
374
+ const createBuilder = (self, _styler, _isEmpty)=>{
375
+ const builder = (...arguments_)=>{
376
+ if (isArray(arguments_[0]) && isArray(arguments_[0].raw)) return applyStyle(builder, chalkTag(builder, ...arguments_));
377
+ return applyStyle(builder, 1 === arguments_.length ? '' + arguments_[0] : arguments_.join(' '));
378
+ };
379
+ Object.setPrototypeOf(builder, proto);
380
+ builder._generator = self;
381
+ builder._styler = _styler;
382
+ builder._isEmpty = _isEmpty;
383
+ return builder;
384
+ };
385
+ const applyStyle = (self, string)=>{
386
+ if (self.level <= 0 || !string) return self._isEmpty ? '' : string;
387
+ let styler = self._styler;
388
+ if (void 0 === styler) return string;
389
+ const { openAll, closeAll } = styler;
390
+ if (-1 !== string.indexOf('\u001B')) while(void 0 !== styler){
391
+ string = stringReplaceAll(string, styler.close, styler.open);
392
+ styler = styler.parent;
393
+ }
394
+ const lfIndex = string.indexOf('\n');
395
+ if (-1 !== lfIndex) string = stringEncaseCRLFWithFirstIndex(string, closeAll, openAll, lfIndex);
396
+ return openAll + string + closeAll;
397
+ };
398
+ let template;
399
+ const chalkTag = (chalk, ...strings)=>{
400
+ const [firstString] = strings;
401
+ if (!isArray(firstString) || !isArray(firstString.raw)) return strings.join(' ');
402
+ const arguments_ = strings.slice(1);
403
+ const parts = [
404
+ firstString.raw[0]
405
+ ];
406
+ for(let i = 1; i < firstString.length; i++)parts.push(String(arguments_[i - 1]).replace(/[{}\\]/g, '\\$&'), String(firstString.raw[i]));
407
+ if (void 0 === template) template = __webpack_require__("../../node_modules/.pnpm/chalk@4.1.2/node_modules/chalk/source/templates.js");
408
+ return template(chalk, parts.join(''));
409
+ };
410
+ Object.defineProperties(Chalk.prototype, styles);
411
+ const chalk = Chalk();
412
+ chalk.supportsColor = stdoutColor;
413
+ chalk.stderr = Chalk({
414
+ level: stderrColor ? stderrColor.level : 0
415
+ });
416
+ chalk.stderr.supportsColor = stderrColor;
417
+ module.exports = chalk;
418
+ },
419
+ "../../node_modules/.pnpm/chalk@4.1.2/node_modules/chalk/source/templates.js" (module) {
420
+ "use strict";
421
+ const TEMPLATE_REGEX = /(?:\\(u(?:[a-f\d]{4}|\{[a-f\d]{1,6}\})|x[a-f\d]{2}|.))|(?:\{(~)?(\w+(?:\([^)]*\))?(?:\.\w+(?:\([^)]*\))?)*)(?:[ \t]|(?=\r?\n)))|(\})|((?:.|[\r\n\f])+?)/gi;
422
+ const STYLE_REGEX = /(?:^|\.)(\w+)(?:\(([^)]*)\))?/g;
423
+ const STRING_REGEX = /^(['"])((?:\\.|(?!\1)[^\\])*)\1$/;
424
+ const ESCAPE_REGEX = /\\(u(?:[a-f\d]{4}|{[a-f\d]{1,6}})|x[a-f\d]{2}|.)|([^\\])/gi;
425
+ const ESCAPES = new Map([
426
+ [
427
+ 'n',
428
+ '\n'
429
+ ],
430
+ [
431
+ 'r',
432
+ '\r'
433
+ ],
434
+ [
435
+ 't',
436
+ '\t'
437
+ ],
438
+ [
439
+ 'b',
440
+ '\b'
441
+ ],
442
+ [
443
+ 'f',
444
+ '\f'
445
+ ],
446
+ [
447
+ 'v',
448
+ '\v'
449
+ ],
450
+ [
451
+ '0',
452
+ '\0'
453
+ ],
454
+ [
455
+ '\\',
456
+ '\\'
457
+ ],
458
+ [
459
+ 'e',
460
+ '\u001B'
461
+ ],
462
+ [
463
+ 'a',
464
+ '\u0007'
465
+ ]
466
+ ]);
467
+ function unescape(c) {
468
+ const u = 'u' === c[0];
469
+ const bracket = '{' === c[1];
470
+ if (u && !bracket && 5 === c.length || 'x' === c[0] && 3 === c.length) return String.fromCharCode(parseInt(c.slice(1), 16));
471
+ if (u && bracket) return String.fromCodePoint(parseInt(c.slice(2, -1), 16));
472
+ return ESCAPES.get(c) || c;
473
+ }
474
+ function parseArguments(name, arguments_) {
475
+ const results = [];
476
+ const chunks = arguments_.trim().split(/\s*,\s*/g);
477
+ let matches;
478
+ for (const chunk of chunks){
479
+ const number = Number(chunk);
480
+ if (Number.isNaN(number)) if (matches = chunk.match(STRING_REGEX)) results.push(matches[2].replace(ESCAPE_REGEX, (m, escape, character)=>escape ? unescape(escape) : character));
481
+ else throw new Error(`Invalid Chalk template style argument: ${chunk} (in style '${name}')`);
482
+ else results.push(number);
483
+ }
484
+ return results;
485
+ }
486
+ function parseStyle(style) {
487
+ STYLE_REGEX.lastIndex = 0;
488
+ const results = [];
489
+ let matches;
490
+ while(null !== (matches = STYLE_REGEX.exec(style))){
491
+ const name = matches[1];
492
+ if (matches[2]) {
493
+ const args = parseArguments(name, matches[2]);
494
+ results.push([
495
+ name
496
+ ].concat(args));
497
+ } else results.push([
498
+ name
499
+ ]);
500
+ }
501
+ return results;
502
+ }
503
+ function buildStyle(chalk, styles) {
504
+ const enabled = {};
505
+ for (const layer of styles)for (const style of layer.styles)enabled[style[0]] = layer.inverse ? null : style.slice(1);
506
+ let current = chalk;
507
+ for (const [styleName, styles] of Object.entries(enabled))if (Array.isArray(styles)) {
508
+ if (!(styleName in current)) throw new Error(`Unknown Chalk style: ${styleName}`);
509
+ current = styles.length > 0 ? current[styleName](...styles) : current[styleName];
510
+ }
511
+ return current;
512
+ }
513
+ module.exports = (chalk, temporary)=>{
514
+ const styles = [];
515
+ const chunks = [];
516
+ let chunk = [];
517
+ temporary.replace(TEMPLATE_REGEX, (m, escapeCharacter, inverse, style, close, character)=>{
518
+ if (escapeCharacter) chunk.push(unescape(escapeCharacter));
519
+ else if (style) {
520
+ const string = chunk.join('');
521
+ chunk = [];
522
+ chunks.push(0 === styles.length ? string : buildStyle(chalk, styles)(string));
523
+ styles.push({
524
+ inverse,
525
+ styles: parseStyle(style)
526
+ });
527
+ } else if (close) {
528
+ if (0 === styles.length) throw new Error('Found extraneous } in Chalk template literal');
529
+ chunks.push(buildStyle(chalk, styles)(chunk.join('')));
530
+ chunk = [];
531
+ styles.pop();
532
+ } else chunk.push(character);
533
+ });
534
+ chunks.push(chunk.join(''));
535
+ if (styles.length > 0) {
536
+ const errMessage = `Chalk template literal is missing ${styles.length} closing bracket${1 === styles.length ? '' : 's'} (\`}\`)`;
537
+ throw new Error(errMessage);
538
+ }
539
+ return chunks.join('');
540
+ };
541
+ },
542
+ "../../node_modules/.pnpm/chalk@4.1.2/node_modules/chalk/source/util.js" (module) {
543
+ "use strict";
544
+ const stringReplaceAll = (string, substring, replacer)=>{
545
+ let index = string.indexOf(substring);
546
+ if (-1 === index) return string;
547
+ const substringLength = substring.length;
548
+ let endIndex = 0;
549
+ let returnValue = '';
550
+ do {
551
+ returnValue += string.substr(endIndex, index - endIndex) + substring + replacer;
552
+ endIndex = index + substringLength;
553
+ index = string.indexOf(substring, endIndex);
554
+ }while (-1 !== index);
555
+ returnValue += string.substr(endIndex);
556
+ return returnValue;
557
+ };
558
+ const stringEncaseCRLFWithFirstIndex = (string, prefix, postfix, index)=>{
559
+ let endIndex = 0;
560
+ let returnValue = '';
561
+ do {
562
+ const gotCR = '\r' === string[index - 1];
563
+ returnValue += string.substr(endIndex, (gotCR ? index - 1 : index) - endIndex) + prefix + (gotCR ? '\r\n' : '\n') + postfix;
564
+ endIndex = index + 1;
565
+ index = string.indexOf('\n', endIndex);
566
+ }while (-1 !== index);
567
+ returnValue += string.substr(endIndex);
568
+ return returnValue;
569
+ };
570
+ module.exports = {
571
+ stringReplaceAll,
572
+ stringEncaseCRLFWithFirstIndex
573
+ };
574
+ },
575
+ "../../node_modules/.pnpm/color-convert@2.0.1/node_modules/color-convert/conversions.js" (module, __unused_rspack_exports, __webpack_require__) {
576
+ const cssKeywords = __webpack_require__("../../node_modules/.pnpm/color-name@1.1.4/node_modules/color-name/index.js");
577
+ const reverseKeywords = {};
578
+ for (const key of Object.keys(cssKeywords))reverseKeywords[cssKeywords[key]] = key;
579
+ const convert = {
580
+ rgb: {
581
+ channels: 3,
582
+ labels: 'rgb'
583
+ },
584
+ hsl: {
585
+ channels: 3,
586
+ labels: 'hsl'
587
+ },
588
+ hsv: {
589
+ channels: 3,
590
+ labels: 'hsv'
591
+ },
592
+ hwb: {
593
+ channels: 3,
594
+ labels: 'hwb'
595
+ },
596
+ cmyk: {
597
+ channels: 4,
598
+ labels: 'cmyk'
599
+ },
600
+ xyz: {
601
+ channels: 3,
602
+ labels: 'xyz'
603
+ },
604
+ lab: {
605
+ channels: 3,
606
+ labels: 'lab'
607
+ },
608
+ lch: {
609
+ channels: 3,
610
+ labels: 'lch'
611
+ },
612
+ hex: {
613
+ channels: 1,
614
+ labels: [
615
+ 'hex'
616
+ ]
617
+ },
618
+ keyword: {
619
+ channels: 1,
620
+ labels: [
621
+ 'keyword'
622
+ ]
623
+ },
624
+ ansi16: {
625
+ channels: 1,
626
+ labels: [
627
+ 'ansi16'
628
+ ]
629
+ },
630
+ ansi256: {
631
+ channels: 1,
632
+ labels: [
633
+ 'ansi256'
634
+ ]
635
+ },
636
+ hcg: {
637
+ channels: 3,
638
+ labels: [
639
+ 'h',
640
+ 'c',
641
+ 'g'
642
+ ]
643
+ },
644
+ apple: {
645
+ channels: 3,
646
+ labels: [
647
+ 'r16',
648
+ 'g16',
649
+ 'b16'
650
+ ]
651
+ },
652
+ gray: {
653
+ channels: 1,
654
+ labels: [
655
+ 'gray'
656
+ ]
657
+ }
658
+ };
659
+ module.exports = convert;
660
+ for (const model of Object.keys(convert)){
661
+ if (!('channels' in convert[model])) throw new Error('missing channels property: ' + model);
662
+ if (!('labels' in convert[model])) throw new Error('missing channel labels property: ' + model);
663
+ if (convert[model].labels.length !== convert[model].channels) throw new Error('channel and label counts mismatch: ' + model);
664
+ const { channels, labels } = convert[model];
665
+ delete convert[model].channels;
666
+ delete convert[model].labels;
667
+ Object.defineProperty(convert[model], 'channels', {
668
+ value: channels
669
+ });
670
+ Object.defineProperty(convert[model], 'labels', {
671
+ value: labels
672
+ });
673
+ }
674
+ convert.rgb.hsl = function(rgb) {
675
+ const r = rgb[0] / 255;
676
+ const g = rgb[1] / 255;
677
+ const b = rgb[2] / 255;
678
+ const min = Math.min(r, g, b);
679
+ const max = Math.max(r, g, b);
680
+ const delta = max - min;
681
+ let h;
682
+ let s;
683
+ if (max === min) h = 0;
684
+ else if (r === max) h = (g - b) / delta;
685
+ else if (g === max) h = 2 + (b - r) / delta;
686
+ else if (b === max) h = 4 + (r - g) / delta;
687
+ h = Math.min(60 * h, 360);
688
+ if (h < 0) h += 360;
689
+ const l = (min + max) / 2;
690
+ s = max === min ? 0 : l <= 0.5 ? delta / (max + min) : delta / (2 - max - min);
691
+ return [
692
+ h,
693
+ 100 * s,
694
+ 100 * l
695
+ ];
696
+ };
697
+ convert.rgb.hsv = function(rgb) {
698
+ let rdif;
699
+ let gdif;
700
+ let bdif;
701
+ let h;
702
+ let s;
703
+ const r = rgb[0] / 255;
704
+ const g = rgb[1] / 255;
705
+ const b = rgb[2] / 255;
706
+ const v = Math.max(r, g, b);
707
+ const diff = v - Math.min(r, g, b);
708
+ const diffc = function(c) {
709
+ return (v - c) / 6 / diff + 0.5;
710
+ };
711
+ if (0 === diff) {
712
+ h = 0;
713
+ s = 0;
714
+ } else {
715
+ s = diff / v;
716
+ rdif = diffc(r);
717
+ gdif = diffc(g);
718
+ bdif = diffc(b);
719
+ if (r === v) h = bdif - gdif;
720
+ else if (g === v) h = 1 / 3 + rdif - bdif;
721
+ else if (b === v) h = 2 / 3 + gdif - rdif;
722
+ if (h < 0) h += 1;
723
+ else if (h > 1) h -= 1;
724
+ }
725
+ return [
726
+ 360 * h,
727
+ 100 * s,
728
+ 100 * v
729
+ ];
730
+ };
731
+ convert.rgb.hwb = function(rgb) {
732
+ const r = rgb[0];
733
+ const g = rgb[1];
734
+ let b = rgb[2];
735
+ const h = convert.rgb.hsl(rgb)[0];
736
+ const w = 1 / 255 * Math.min(r, Math.min(g, b));
737
+ b = 1 - 1 / 255 * Math.max(r, Math.max(g, b));
738
+ return [
739
+ h,
740
+ 100 * w,
741
+ 100 * b
742
+ ];
743
+ };
744
+ convert.rgb.cmyk = function(rgb) {
745
+ const r = rgb[0] / 255;
746
+ const g = rgb[1] / 255;
747
+ const b = rgb[2] / 255;
748
+ const k = Math.min(1 - r, 1 - g, 1 - b);
749
+ const c = (1 - r - k) / (1 - k) || 0;
750
+ const m = (1 - g - k) / (1 - k) || 0;
751
+ const y = (1 - b - k) / (1 - k) || 0;
752
+ return [
753
+ 100 * c,
754
+ 100 * m,
755
+ 100 * y,
756
+ 100 * k
757
+ ];
758
+ };
759
+ function comparativeDistance(x, y) {
760
+ return (x[0] - y[0]) ** 2 + (x[1] - y[1]) ** 2 + (x[2] - y[2]) ** 2;
761
+ }
762
+ convert.rgb.keyword = function(rgb) {
763
+ const reversed = reverseKeywords[rgb];
764
+ if (reversed) return reversed;
765
+ let currentClosestDistance = 1 / 0;
766
+ let currentClosestKeyword;
767
+ for (const keyword of Object.keys(cssKeywords)){
768
+ const value = cssKeywords[keyword];
769
+ const distance = comparativeDistance(rgb, value);
770
+ if (distance < currentClosestDistance) {
771
+ currentClosestDistance = distance;
772
+ currentClosestKeyword = keyword;
773
+ }
774
+ }
775
+ return currentClosestKeyword;
776
+ };
777
+ convert.keyword.rgb = function(keyword) {
778
+ return cssKeywords[keyword];
779
+ };
780
+ convert.rgb.xyz = function(rgb) {
781
+ let r = rgb[0] / 255;
782
+ let g = rgb[1] / 255;
783
+ let b = rgb[2] / 255;
784
+ r = r > 0.04045 ? ((r + 0.055) / 1.055) ** 2.4 : r / 12.92;
785
+ g = g > 0.04045 ? ((g + 0.055) / 1.055) ** 2.4 : g / 12.92;
786
+ b = b > 0.04045 ? ((b + 0.055) / 1.055) ** 2.4 : b / 12.92;
787
+ const x = 0.4124 * r + 0.3576 * g + 0.1805 * b;
788
+ const y = 0.2126 * r + 0.7152 * g + 0.0722 * b;
789
+ const z = 0.0193 * r + 0.1192 * g + 0.9505 * b;
790
+ return [
791
+ 100 * x,
792
+ 100 * y,
793
+ 100 * z
794
+ ];
795
+ };
796
+ convert.rgb.lab = function(rgb) {
797
+ const xyz = convert.rgb.xyz(rgb);
798
+ let x = xyz[0];
799
+ let y = xyz[1];
800
+ let z = xyz[2];
801
+ x /= 95.047;
802
+ y /= 100;
803
+ z /= 108.883;
804
+ x = x > 0.008856 ? x ** (1 / 3) : 7.787 * x + 16 / 116;
805
+ y = y > 0.008856 ? y ** (1 / 3) : 7.787 * y + 16 / 116;
806
+ z = z > 0.008856 ? z ** (1 / 3) : 7.787 * z + 16 / 116;
807
+ const l = 116 * y - 16;
808
+ const a = 500 * (x - y);
809
+ const b = 200 * (y - z);
810
+ return [
811
+ l,
812
+ a,
813
+ b
814
+ ];
815
+ };
816
+ convert.hsl.rgb = function(hsl) {
817
+ const h = hsl[0] / 360;
818
+ const s = hsl[1] / 100;
819
+ const l = hsl[2] / 100;
820
+ let t2;
821
+ let t3;
822
+ let val;
823
+ if (0 === s) {
824
+ val = 255 * l;
825
+ return [
826
+ val,
827
+ val,
828
+ val
829
+ ];
830
+ }
831
+ t2 = l < 0.5 ? l * (1 + s) : l + s - l * s;
832
+ const t1 = 2 * l - t2;
833
+ const rgb = [
834
+ 0,
835
+ 0,
836
+ 0
837
+ ];
838
+ for(let i = 0; i < 3; i++){
839
+ t3 = h + 1 / 3 * -(i - 1);
840
+ if (t3 < 0) t3++;
841
+ if (t3 > 1) t3--;
842
+ val = 6 * t3 < 1 ? t1 + (t2 - t1) * 6 * t3 : 2 * t3 < 1 ? t2 : 3 * t3 < 2 ? t1 + (t2 - t1) * (2 / 3 - t3) * 6 : t1;
843
+ rgb[i] = 255 * val;
844
+ }
845
+ return rgb;
846
+ };
847
+ convert.hsl.hsv = function(hsl) {
848
+ const h = hsl[0];
849
+ let s = hsl[1] / 100;
850
+ let l = hsl[2] / 100;
851
+ let smin = s;
852
+ const lmin = Math.max(l, 0.01);
853
+ l *= 2;
854
+ s *= l <= 1 ? l : 2 - l;
855
+ smin *= lmin <= 1 ? lmin : 2 - lmin;
856
+ const v = (l + s) / 2;
857
+ const sv = 0 === l ? 2 * smin / (lmin + smin) : 2 * s / (l + s);
858
+ return [
859
+ h,
860
+ 100 * sv,
861
+ 100 * v
862
+ ];
863
+ };
864
+ convert.hsv.rgb = function(hsv) {
865
+ const h = hsv[0] / 60;
866
+ const s = hsv[1] / 100;
867
+ let v = hsv[2] / 100;
868
+ const hi = Math.floor(h) % 6;
869
+ const f = h - Math.floor(h);
870
+ const p = 255 * v * (1 - s);
871
+ const q = 255 * v * (1 - s * f);
872
+ const t = 255 * v * (1 - s * (1 - f));
873
+ v *= 255;
874
+ switch(hi){
875
+ case 0:
876
+ return [
877
+ v,
878
+ t,
879
+ p
880
+ ];
881
+ case 1:
882
+ return [
883
+ q,
884
+ v,
885
+ p
886
+ ];
887
+ case 2:
888
+ return [
889
+ p,
890
+ v,
891
+ t
892
+ ];
893
+ case 3:
894
+ return [
895
+ p,
896
+ q,
897
+ v
898
+ ];
899
+ case 4:
900
+ return [
901
+ t,
902
+ p,
903
+ v
904
+ ];
905
+ case 5:
906
+ return [
907
+ v,
908
+ p,
909
+ q
910
+ ];
911
+ }
912
+ };
913
+ convert.hsv.hsl = function(hsv) {
914
+ const h = hsv[0];
915
+ const s = hsv[1] / 100;
916
+ const v = hsv[2] / 100;
917
+ const vmin = Math.max(v, 0.01);
918
+ let sl;
919
+ let l;
920
+ l = (2 - s) * v;
921
+ const lmin = (2 - s) * vmin;
922
+ sl = s * vmin;
923
+ sl /= lmin <= 1 ? lmin : 2 - lmin;
924
+ sl = sl || 0;
925
+ l /= 2;
926
+ return [
927
+ h,
928
+ 100 * sl,
929
+ 100 * l
930
+ ];
931
+ };
932
+ convert.hwb.rgb = function(hwb) {
933
+ const h = hwb[0] / 360;
934
+ let wh = hwb[1] / 100;
935
+ let bl = hwb[2] / 100;
936
+ const ratio = wh + bl;
937
+ let f;
938
+ if (ratio > 1) {
939
+ wh /= ratio;
940
+ bl /= ratio;
941
+ }
942
+ const i = Math.floor(6 * h);
943
+ const v = 1 - bl;
944
+ f = 6 * h - i;
945
+ if ((0x01 & i) !== 0) f = 1 - f;
946
+ const n = wh + f * (v - wh);
947
+ let r;
948
+ let g;
949
+ let b;
950
+ switch(i){
951
+ default:
952
+ case 6:
953
+ case 0:
954
+ r = v;
955
+ g = n;
956
+ b = wh;
957
+ break;
958
+ case 1:
959
+ r = n;
960
+ g = v;
961
+ b = wh;
962
+ break;
963
+ case 2:
964
+ r = wh;
965
+ g = v;
966
+ b = n;
967
+ break;
968
+ case 3:
969
+ r = wh;
970
+ g = n;
971
+ b = v;
972
+ break;
973
+ case 4:
974
+ r = n;
975
+ g = wh;
976
+ b = v;
977
+ break;
978
+ case 5:
979
+ r = v;
980
+ g = wh;
981
+ b = n;
982
+ break;
983
+ }
984
+ return [
985
+ 255 * r,
986
+ 255 * g,
987
+ 255 * b
988
+ ];
989
+ };
990
+ convert.cmyk.rgb = function(cmyk) {
991
+ const c = cmyk[0] / 100;
992
+ const m = cmyk[1] / 100;
993
+ const y = cmyk[2] / 100;
994
+ const k = cmyk[3] / 100;
995
+ const r = 1 - Math.min(1, c * (1 - k) + k);
996
+ const g = 1 - Math.min(1, m * (1 - k) + k);
997
+ const b = 1 - Math.min(1, y * (1 - k) + k);
998
+ return [
999
+ 255 * r,
1000
+ 255 * g,
1001
+ 255 * b
1002
+ ];
1003
+ };
1004
+ convert.xyz.rgb = function(xyz) {
1005
+ const x = xyz[0] / 100;
1006
+ const y = xyz[1] / 100;
1007
+ const z = xyz[2] / 100;
1008
+ let r;
1009
+ let g;
1010
+ let b;
1011
+ r = 3.2406 * x + -1.5372 * y + -0.4986 * z;
1012
+ g = -0.9689 * x + 1.8758 * y + 0.0415 * z;
1013
+ b = 0.0557 * x + -0.204 * y + 1.0570 * z;
1014
+ r = r > 0.0031308 ? 1.055 * r ** (1.0 / 2.4) - 0.055 : 12.92 * r;
1015
+ g = g > 0.0031308 ? 1.055 * g ** (1.0 / 2.4) - 0.055 : 12.92 * g;
1016
+ b = b > 0.0031308 ? 1.055 * b ** (1.0 / 2.4) - 0.055 : 12.92 * b;
1017
+ r = Math.min(Math.max(0, r), 1);
1018
+ g = Math.min(Math.max(0, g), 1);
1019
+ b = Math.min(Math.max(0, b), 1);
1020
+ return [
1021
+ 255 * r,
1022
+ 255 * g,
1023
+ 255 * b
1024
+ ];
1025
+ };
1026
+ convert.xyz.lab = function(xyz) {
1027
+ let x = xyz[0];
1028
+ let y = xyz[1];
1029
+ let z = xyz[2];
1030
+ x /= 95.047;
1031
+ y /= 100;
1032
+ z /= 108.883;
1033
+ x = x > 0.008856 ? x ** (1 / 3) : 7.787 * x + 16 / 116;
1034
+ y = y > 0.008856 ? y ** (1 / 3) : 7.787 * y + 16 / 116;
1035
+ z = z > 0.008856 ? z ** (1 / 3) : 7.787 * z + 16 / 116;
1036
+ const l = 116 * y - 16;
1037
+ const a = 500 * (x - y);
1038
+ const b = 200 * (y - z);
1039
+ return [
1040
+ l,
1041
+ a,
1042
+ b
1043
+ ];
1044
+ };
1045
+ convert.lab.xyz = function(lab) {
1046
+ const l = lab[0];
1047
+ const a = lab[1];
1048
+ const b = lab[2];
1049
+ let x;
1050
+ let y;
1051
+ let z;
1052
+ y = (l + 16) / 116;
1053
+ x = a / 500 + y;
1054
+ z = y - b / 200;
1055
+ const y2 = y ** 3;
1056
+ const x2 = x ** 3;
1057
+ const z2 = z ** 3;
1058
+ y = y2 > 0.008856 ? y2 : (y - 16 / 116) / 7.787;
1059
+ x = x2 > 0.008856 ? x2 : (x - 16 / 116) / 7.787;
1060
+ z = z2 > 0.008856 ? z2 : (z - 16 / 116) / 7.787;
1061
+ x *= 95.047;
1062
+ y *= 100;
1063
+ z *= 108.883;
1064
+ return [
1065
+ x,
1066
+ y,
1067
+ z
1068
+ ];
1069
+ };
1070
+ convert.lab.lch = function(lab) {
1071
+ const l = lab[0];
1072
+ const a = lab[1];
1073
+ const b = lab[2];
1074
+ let h;
1075
+ const hr = Math.atan2(b, a);
1076
+ h = 360 * hr / 2 / Math.PI;
1077
+ if (h < 0) h += 360;
1078
+ const c = Math.sqrt(a * a + b * b);
1079
+ return [
1080
+ l,
1081
+ c,
1082
+ h
1083
+ ];
1084
+ };
1085
+ convert.lch.lab = function(lch) {
1086
+ const l = lch[0];
1087
+ const c = lch[1];
1088
+ const h = lch[2];
1089
+ const hr = h / 360 * 2 * Math.PI;
1090
+ const a = c * Math.cos(hr);
1091
+ const b = c * Math.sin(hr);
1092
+ return [
1093
+ l,
1094
+ a,
1095
+ b
1096
+ ];
1097
+ };
1098
+ convert.rgb.ansi16 = function(args, saturation = null) {
1099
+ const [r, g, b] = args;
1100
+ let value = null === saturation ? convert.rgb.hsv(args)[2] : saturation;
1101
+ value = Math.round(value / 50);
1102
+ if (0 === value) return 30;
1103
+ let ansi = 30 + (Math.round(b / 255) << 2 | Math.round(g / 255) << 1 | Math.round(r / 255));
1104
+ if (2 === value) ansi += 60;
1105
+ return ansi;
1106
+ };
1107
+ convert.hsv.ansi16 = function(args) {
1108
+ return convert.rgb.ansi16(convert.hsv.rgb(args), args[2]);
1109
+ };
1110
+ convert.rgb.ansi256 = function(args) {
1111
+ const r = args[0];
1112
+ const g = args[1];
1113
+ const b = args[2];
1114
+ if (r === g && g === b) {
1115
+ if (r < 8) return 16;
1116
+ if (r > 248) return 231;
1117
+ return Math.round((r - 8) / 247 * 24) + 232;
1118
+ }
1119
+ const ansi = 16 + 36 * Math.round(r / 255 * 5) + 6 * Math.round(g / 255 * 5) + Math.round(b / 255 * 5);
1120
+ return ansi;
1121
+ };
1122
+ convert.ansi16.rgb = function(args) {
1123
+ let color = args % 10;
1124
+ if (0 === color || 7 === color) {
1125
+ if (args > 50) color += 3.5;
1126
+ color = color / 10.5 * 255;
1127
+ return [
1128
+ color,
1129
+ color,
1130
+ color
1131
+ ];
1132
+ }
1133
+ const mult = (~~(args > 50) + 1) * 0.5;
1134
+ const r = (1 & color) * mult * 255;
1135
+ const g = (color >> 1 & 1) * mult * 255;
1136
+ const b = (color >> 2 & 1) * mult * 255;
1137
+ return [
1138
+ r,
1139
+ g,
1140
+ b
1141
+ ];
1142
+ };
1143
+ convert.ansi256.rgb = function(args) {
1144
+ if (args >= 232) {
1145
+ const c = (args - 232) * 10 + 8;
1146
+ return [
1147
+ c,
1148
+ c,
1149
+ c
1150
+ ];
1151
+ }
1152
+ args -= 16;
1153
+ let rem;
1154
+ const r = Math.floor(args / 36) / 5 * 255;
1155
+ const g = Math.floor((rem = args % 36) / 6) / 5 * 255;
1156
+ const b = rem % 6 / 5 * 255;
1157
+ return [
1158
+ r,
1159
+ g,
1160
+ b
1161
+ ];
1162
+ };
1163
+ convert.rgb.hex = function(args) {
1164
+ const integer = ((0xFF & Math.round(args[0])) << 16) + ((0xFF & Math.round(args[1])) << 8) + (0xFF & Math.round(args[2]));
1165
+ const string = integer.toString(16).toUpperCase();
1166
+ return '000000'.substring(string.length) + string;
1167
+ };
1168
+ convert.hex.rgb = function(args) {
1169
+ const match = args.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);
1170
+ if (!match) return [
1171
+ 0,
1172
+ 0,
1173
+ 0
1174
+ ];
1175
+ let colorString = match[0];
1176
+ if (3 === match[0].length) colorString = colorString.split('').map((char)=>char + char).join('');
1177
+ const integer = parseInt(colorString, 16);
1178
+ const r = integer >> 16 & 0xFF;
1179
+ const g = integer >> 8 & 0xFF;
1180
+ const b = 0xFF & integer;
1181
+ return [
1182
+ r,
1183
+ g,
1184
+ b
1185
+ ];
1186
+ };
1187
+ convert.rgb.hcg = function(rgb) {
1188
+ const r = rgb[0] / 255;
1189
+ const g = rgb[1] / 255;
1190
+ const b = rgb[2] / 255;
1191
+ const max = Math.max(Math.max(r, g), b);
1192
+ const min = Math.min(Math.min(r, g), b);
1193
+ const chroma = max - min;
1194
+ let grayscale;
1195
+ let hue;
1196
+ grayscale = chroma < 1 ? min / (1 - chroma) : 0;
1197
+ hue = chroma <= 0 ? 0 : max === r ? (g - b) / chroma % 6 : max === g ? 2 + (b - r) / chroma : 4 + (r - g) / chroma;
1198
+ hue /= 6;
1199
+ hue %= 1;
1200
+ return [
1201
+ 360 * hue,
1202
+ 100 * chroma,
1203
+ 100 * grayscale
1204
+ ];
1205
+ };
1206
+ convert.hsl.hcg = function(hsl) {
1207
+ const s = hsl[1] / 100;
1208
+ const l = hsl[2] / 100;
1209
+ const c = l < 0.5 ? 2.0 * s * l : 2.0 * s * (1.0 - l);
1210
+ let f = 0;
1211
+ if (c < 1.0) f = (l - 0.5 * c) / (1.0 - c);
1212
+ return [
1213
+ hsl[0],
1214
+ 100 * c,
1215
+ 100 * f
1216
+ ];
1217
+ };
1218
+ convert.hsv.hcg = function(hsv) {
1219
+ const s = hsv[1] / 100;
1220
+ const v = hsv[2] / 100;
1221
+ const c = s * v;
1222
+ let f = 0;
1223
+ if (c < 1.0) f = (v - c) / (1 - c);
1224
+ return [
1225
+ hsv[0],
1226
+ 100 * c,
1227
+ 100 * f
1228
+ ];
1229
+ };
1230
+ convert.hcg.rgb = function(hcg) {
1231
+ const h = hcg[0] / 360;
1232
+ const c = hcg[1] / 100;
1233
+ const g = hcg[2] / 100;
1234
+ if (0.0 === c) return [
1235
+ 255 * g,
1236
+ 255 * g,
1237
+ 255 * g
1238
+ ];
1239
+ const pure = [
1240
+ 0,
1241
+ 0,
1242
+ 0
1243
+ ];
1244
+ const hi = h % 1 * 6;
1245
+ const v = hi % 1;
1246
+ const w = 1 - v;
1247
+ let mg = 0;
1248
+ switch(Math.floor(hi)){
1249
+ case 0:
1250
+ pure[0] = 1;
1251
+ pure[1] = v;
1252
+ pure[2] = 0;
1253
+ break;
1254
+ case 1:
1255
+ pure[0] = w;
1256
+ pure[1] = 1;
1257
+ pure[2] = 0;
1258
+ break;
1259
+ case 2:
1260
+ pure[0] = 0;
1261
+ pure[1] = 1;
1262
+ pure[2] = v;
1263
+ break;
1264
+ case 3:
1265
+ pure[0] = 0;
1266
+ pure[1] = w;
1267
+ pure[2] = 1;
1268
+ break;
1269
+ case 4:
1270
+ pure[0] = v;
1271
+ pure[1] = 0;
1272
+ pure[2] = 1;
1273
+ break;
1274
+ default:
1275
+ pure[0] = 1;
1276
+ pure[1] = 0;
1277
+ pure[2] = w;
1278
+ }
1279
+ mg = (1.0 - c) * g;
1280
+ return [
1281
+ (c * pure[0] + mg) * 255,
1282
+ (c * pure[1] + mg) * 255,
1283
+ (c * pure[2] + mg) * 255
1284
+ ];
1285
+ };
1286
+ convert.hcg.hsv = function(hcg) {
1287
+ const c = hcg[1] / 100;
1288
+ const g = hcg[2] / 100;
1289
+ const v = c + g * (1.0 - c);
1290
+ let f = 0;
1291
+ if (v > 0.0) f = c / v;
1292
+ return [
1293
+ hcg[0],
1294
+ 100 * f,
1295
+ 100 * v
1296
+ ];
1297
+ };
1298
+ convert.hcg.hsl = function(hcg) {
1299
+ const c = hcg[1] / 100;
1300
+ const g = hcg[2] / 100;
1301
+ const l = g * (1.0 - c) + 0.5 * c;
1302
+ let s = 0;
1303
+ if (l > 0.0 && l < 0.5) s = c / (2 * l);
1304
+ else if (l >= 0.5 && l < 1.0) s = c / (2 * (1 - l));
1305
+ return [
1306
+ hcg[0],
1307
+ 100 * s,
1308
+ 100 * l
1309
+ ];
1310
+ };
1311
+ convert.hcg.hwb = function(hcg) {
1312
+ const c = hcg[1] / 100;
1313
+ const g = hcg[2] / 100;
1314
+ const v = c + g * (1.0 - c);
1315
+ return [
1316
+ hcg[0],
1317
+ (v - c) * 100,
1318
+ (1 - v) * 100
1319
+ ];
1320
+ };
1321
+ convert.hwb.hcg = function(hwb) {
1322
+ const w = hwb[1] / 100;
1323
+ const b = hwb[2] / 100;
1324
+ const v = 1 - b;
1325
+ const c = v - w;
1326
+ let g = 0;
1327
+ if (c < 1) g = (v - c) / (1 - c);
1328
+ return [
1329
+ hwb[0],
1330
+ 100 * c,
1331
+ 100 * g
1332
+ ];
1333
+ };
1334
+ convert.apple.rgb = function(apple) {
1335
+ return [
1336
+ apple[0] / 65535 * 255,
1337
+ apple[1] / 65535 * 255,
1338
+ apple[2] / 65535 * 255
1339
+ ];
1340
+ };
1341
+ convert.rgb.apple = function(rgb) {
1342
+ return [
1343
+ rgb[0] / 255 * 65535,
1344
+ rgb[1] / 255 * 65535,
1345
+ rgb[2] / 255 * 65535
1346
+ ];
1347
+ };
1348
+ convert.gray.rgb = function(args) {
1349
+ return [
1350
+ args[0] / 100 * 255,
1351
+ args[0] / 100 * 255,
1352
+ args[0] / 100 * 255
1353
+ ];
1354
+ };
1355
+ convert.gray.hsl = function(args) {
1356
+ return [
1357
+ 0,
1358
+ 0,
1359
+ args[0]
1360
+ ];
1361
+ };
1362
+ convert.gray.hsv = convert.gray.hsl;
1363
+ convert.gray.hwb = function(gray) {
1364
+ return [
1365
+ 0,
1366
+ 100,
1367
+ gray[0]
1368
+ ];
1369
+ };
1370
+ convert.gray.cmyk = function(gray) {
1371
+ return [
1372
+ 0,
1373
+ 0,
1374
+ 0,
1375
+ gray[0]
1376
+ ];
1377
+ };
1378
+ convert.gray.lab = function(gray) {
1379
+ return [
1380
+ gray[0],
1381
+ 0,
1382
+ 0
1383
+ ];
1384
+ };
1385
+ convert.gray.hex = function(gray) {
1386
+ const val = 0xFF & Math.round(gray[0] / 100 * 255);
1387
+ const integer = (val << 16) + (val << 8) + val;
1388
+ const string = integer.toString(16).toUpperCase();
1389
+ return '000000'.substring(string.length) + string;
1390
+ };
1391
+ convert.rgb.gray = function(rgb) {
1392
+ const val = (rgb[0] + rgb[1] + rgb[2]) / 3;
1393
+ return [
1394
+ val / 255 * 100
1395
+ ];
1396
+ };
1397
+ },
1398
+ "../../node_modules/.pnpm/color-convert@2.0.1/node_modules/color-convert/index.js" (module, __unused_rspack_exports, __webpack_require__) {
1399
+ const conversions = __webpack_require__("../../node_modules/.pnpm/color-convert@2.0.1/node_modules/color-convert/conversions.js");
1400
+ const route = __webpack_require__("../../node_modules/.pnpm/color-convert@2.0.1/node_modules/color-convert/route.js");
1401
+ const convert = {};
1402
+ const models = Object.keys(conversions);
1403
+ function wrapRaw(fn) {
1404
+ const wrappedFn = function(...args) {
1405
+ const arg0 = args[0];
1406
+ if (null == arg0) return arg0;
1407
+ if (arg0.length > 1) args = arg0;
1408
+ return fn(args);
1409
+ };
1410
+ if ('conversion' in fn) wrappedFn.conversion = fn.conversion;
1411
+ return wrappedFn;
1412
+ }
1413
+ function wrapRounded(fn) {
1414
+ const wrappedFn = function(...args) {
1415
+ const arg0 = args[0];
1416
+ if (null == arg0) return arg0;
1417
+ if (arg0.length > 1) args = arg0;
1418
+ const result = fn(args);
1419
+ if ('object' == typeof result) for(let len = result.length, i = 0; i < len; i++)result[i] = Math.round(result[i]);
1420
+ return result;
1421
+ };
1422
+ if ('conversion' in fn) wrappedFn.conversion = fn.conversion;
1423
+ return wrappedFn;
1424
+ }
1425
+ models.forEach((fromModel)=>{
1426
+ convert[fromModel] = {};
1427
+ Object.defineProperty(convert[fromModel], 'channels', {
1428
+ value: conversions[fromModel].channels
1429
+ });
1430
+ Object.defineProperty(convert[fromModel], 'labels', {
1431
+ value: conversions[fromModel].labels
1432
+ });
1433
+ const routes = route(fromModel);
1434
+ const routeModels = Object.keys(routes);
1435
+ routeModels.forEach((toModel)=>{
1436
+ const fn = routes[toModel];
1437
+ convert[fromModel][toModel] = wrapRounded(fn);
1438
+ convert[fromModel][toModel].raw = wrapRaw(fn);
1439
+ });
1440
+ });
1441
+ module.exports = convert;
1442
+ },
1443
+ "../../node_modules/.pnpm/color-convert@2.0.1/node_modules/color-convert/route.js" (module, __unused_rspack_exports, __webpack_require__) {
1444
+ const conversions = __webpack_require__("../../node_modules/.pnpm/color-convert@2.0.1/node_modules/color-convert/conversions.js");
1445
+ function buildGraph() {
1446
+ const graph = {};
1447
+ const models = Object.keys(conversions);
1448
+ for(let len = models.length, i = 0; i < len; i++)graph[models[i]] = {
1449
+ distance: -1,
1450
+ parent: null
1451
+ };
1452
+ return graph;
1453
+ }
1454
+ function deriveBFS(fromModel) {
1455
+ const graph = buildGraph();
1456
+ const queue = [
1457
+ fromModel
1458
+ ];
1459
+ graph[fromModel].distance = 0;
1460
+ while(queue.length){
1461
+ const current = queue.pop();
1462
+ const adjacents = Object.keys(conversions[current]);
1463
+ for(let len = adjacents.length, i = 0; i < len; i++){
1464
+ const adjacent = adjacents[i];
1465
+ const node = graph[adjacent];
1466
+ if (-1 === node.distance) {
1467
+ node.distance = graph[current].distance + 1;
1468
+ node.parent = current;
1469
+ queue.unshift(adjacent);
1470
+ }
1471
+ }
1472
+ }
1473
+ return graph;
1474
+ }
1475
+ function link(from, to) {
1476
+ return function(args) {
1477
+ return to(from(args));
1478
+ };
1479
+ }
1480
+ function wrapConversion(toModel, graph) {
1481
+ const path = [
1482
+ graph[toModel].parent,
1483
+ toModel
1484
+ ];
1485
+ let fn = conversions[graph[toModel].parent][toModel];
1486
+ let cur = graph[toModel].parent;
1487
+ while(graph[cur].parent){
1488
+ path.unshift(graph[cur].parent);
1489
+ fn = link(conversions[graph[cur].parent][cur], fn);
1490
+ cur = graph[cur].parent;
1491
+ }
1492
+ fn.conversion = path;
1493
+ return fn;
1494
+ }
1495
+ module.exports = function(fromModel) {
1496
+ const graph = deriveBFS(fromModel);
1497
+ const conversion = {};
1498
+ const models = Object.keys(graph);
1499
+ for(let len = models.length, i = 0; i < len; i++){
1500
+ const toModel = models[i];
1501
+ const node = graph[toModel];
1502
+ if (null !== node.parent) conversion[toModel] = wrapConversion(toModel, graph);
1503
+ }
1504
+ return conversion;
1505
+ };
1506
+ },
1507
+ "../../node_modules/.pnpm/color-name@1.1.4/node_modules/color-name/index.js" (module) {
1508
+ "use strict";
1509
+ module.exports = {
1510
+ aliceblue: [
1511
+ 240,
1512
+ 248,
1513
+ 255
1514
+ ],
1515
+ antiquewhite: [
1516
+ 250,
1517
+ 235,
1518
+ 215
1519
+ ],
1520
+ aqua: [
1521
+ 0,
1522
+ 255,
1523
+ 255
1524
+ ],
1525
+ aquamarine: [
1526
+ 127,
1527
+ 255,
1528
+ 212
1529
+ ],
1530
+ azure: [
1531
+ 240,
1532
+ 255,
1533
+ 255
1534
+ ],
1535
+ beige: [
1536
+ 245,
1537
+ 245,
1538
+ 220
1539
+ ],
1540
+ bisque: [
1541
+ 255,
1542
+ 228,
1543
+ 196
1544
+ ],
1545
+ black: [
1546
+ 0,
1547
+ 0,
1548
+ 0
1549
+ ],
1550
+ blanchedalmond: [
1551
+ 255,
1552
+ 235,
1553
+ 205
1554
+ ],
1555
+ blue: [
1556
+ 0,
1557
+ 0,
1558
+ 255
1559
+ ],
1560
+ blueviolet: [
1561
+ 138,
1562
+ 43,
1563
+ 226
1564
+ ],
1565
+ brown: [
1566
+ 165,
1567
+ 42,
1568
+ 42
1569
+ ],
1570
+ burlywood: [
1571
+ 222,
1572
+ 184,
1573
+ 135
1574
+ ],
1575
+ cadetblue: [
1576
+ 95,
1577
+ 158,
1578
+ 160
1579
+ ],
1580
+ chartreuse: [
1581
+ 127,
1582
+ 255,
1583
+ 0
1584
+ ],
1585
+ chocolate: [
1586
+ 210,
1587
+ 105,
1588
+ 30
1589
+ ],
1590
+ coral: [
1591
+ 255,
1592
+ 127,
1593
+ 80
1594
+ ],
1595
+ cornflowerblue: [
1596
+ 100,
1597
+ 149,
1598
+ 237
1599
+ ],
1600
+ cornsilk: [
1601
+ 255,
1602
+ 248,
1603
+ 220
1604
+ ],
1605
+ crimson: [
1606
+ 220,
1607
+ 20,
1608
+ 60
1609
+ ],
1610
+ cyan: [
1611
+ 0,
1612
+ 255,
1613
+ 255
1614
+ ],
1615
+ darkblue: [
1616
+ 0,
1617
+ 0,
1618
+ 139
1619
+ ],
1620
+ darkcyan: [
1621
+ 0,
1622
+ 139,
1623
+ 139
1624
+ ],
1625
+ darkgoldenrod: [
1626
+ 184,
1627
+ 134,
1628
+ 11
1629
+ ],
1630
+ darkgray: [
1631
+ 169,
1632
+ 169,
1633
+ 169
1634
+ ],
1635
+ darkgreen: [
1636
+ 0,
1637
+ 100,
1638
+ 0
1639
+ ],
1640
+ darkgrey: [
1641
+ 169,
1642
+ 169,
1643
+ 169
1644
+ ],
1645
+ darkkhaki: [
1646
+ 189,
1647
+ 183,
1648
+ 107
1649
+ ],
1650
+ darkmagenta: [
1651
+ 139,
1652
+ 0,
1653
+ 139
1654
+ ],
1655
+ darkolivegreen: [
1656
+ 85,
1657
+ 107,
1658
+ 47
1659
+ ],
1660
+ darkorange: [
1661
+ 255,
1662
+ 140,
1663
+ 0
1664
+ ],
1665
+ darkorchid: [
1666
+ 153,
1667
+ 50,
1668
+ 204
1669
+ ],
1670
+ darkred: [
1671
+ 139,
1672
+ 0,
1673
+ 0
1674
+ ],
1675
+ darksalmon: [
1676
+ 233,
1677
+ 150,
1678
+ 122
1679
+ ],
1680
+ darkseagreen: [
1681
+ 143,
1682
+ 188,
1683
+ 143
1684
+ ],
1685
+ darkslateblue: [
1686
+ 72,
1687
+ 61,
1688
+ 139
1689
+ ],
1690
+ darkslategray: [
1691
+ 47,
1692
+ 79,
1693
+ 79
1694
+ ],
1695
+ darkslategrey: [
1696
+ 47,
1697
+ 79,
1698
+ 79
1699
+ ],
1700
+ darkturquoise: [
1701
+ 0,
1702
+ 206,
1703
+ 209
1704
+ ],
1705
+ darkviolet: [
1706
+ 148,
1707
+ 0,
1708
+ 211
1709
+ ],
1710
+ deeppink: [
1711
+ 255,
1712
+ 20,
1713
+ 147
1714
+ ],
1715
+ deepskyblue: [
1716
+ 0,
1717
+ 191,
1718
+ 255
1719
+ ],
1720
+ dimgray: [
1721
+ 105,
1722
+ 105,
1723
+ 105
1724
+ ],
1725
+ dimgrey: [
1726
+ 105,
1727
+ 105,
1728
+ 105
1729
+ ],
1730
+ dodgerblue: [
1731
+ 30,
1732
+ 144,
1733
+ 255
1734
+ ],
1735
+ firebrick: [
1736
+ 178,
1737
+ 34,
1738
+ 34
1739
+ ],
1740
+ floralwhite: [
1741
+ 255,
1742
+ 250,
1743
+ 240
1744
+ ],
1745
+ forestgreen: [
1746
+ 34,
1747
+ 139,
1748
+ 34
1749
+ ],
1750
+ fuchsia: [
1751
+ 255,
1752
+ 0,
1753
+ 255
1754
+ ],
1755
+ gainsboro: [
1756
+ 220,
1757
+ 220,
1758
+ 220
1759
+ ],
1760
+ ghostwhite: [
1761
+ 248,
1762
+ 248,
1763
+ 255
1764
+ ],
1765
+ gold: [
1766
+ 255,
1767
+ 215,
1768
+ 0
1769
+ ],
1770
+ goldenrod: [
1771
+ 218,
1772
+ 165,
1773
+ 32
1774
+ ],
1775
+ gray: [
1776
+ 128,
1777
+ 128,
1778
+ 128
1779
+ ],
1780
+ green: [
1781
+ 0,
1782
+ 128,
1783
+ 0
1784
+ ],
1785
+ greenyellow: [
1786
+ 173,
1787
+ 255,
1788
+ 47
1789
+ ],
1790
+ grey: [
1791
+ 128,
1792
+ 128,
1793
+ 128
1794
+ ],
1795
+ honeydew: [
1796
+ 240,
1797
+ 255,
1798
+ 240
1799
+ ],
1800
+ hotpink: [
1801
+ 255,
1802
+ 105,
1803
+ 180
1804
+ ],
1805
+ indianred: [
1806
+ 205,
1807
+ 92,
1808
+ 92
1809
+ ],
1810
+ indigo: [
1811
+ 75,
1812
+ 0,
1813
+ 130
1814
+ ],
1815
+ ivory: [
1816
+ 255,
1817
+ 255,
1818
+ 240
1819
+ ],
1820
+ khaki: [
1821
+ 240,
1822
+ 230,
1823
+ 140
1824
+ ],
1825
+ lavender: [
1826
+ 230,
1827
+ 230,
1828
+ 250
1829
+ ],
1830
+ lavenderblush: [
1831
+ 255,
1832
+ 240,
1833
+ 245
1834
+ ],
1835
+ lawngreen: [
1836
+ 124,
1837
+ 252,
1838
+ 0
1839
+ ],
1840
+ lemonchiffon: [
1841
+ 255,
1842
+ 250,
1843
+ 205
1844
+ ],
1845
+ lightblue: [
1846
+ 173,
1847
+ 216,
1848
+ 230
1849
+ ],
1850
+ lightcoral: [
1851
+ 240,
1852
+ 128,
1853
+ 128
1854
+ ],
1855
+ lightcyan: [
1856
+ 224,
1857
+ 255,
1858
+ 255
1859
+ ],
1860
+ lightgoldenrodyellow: [
1861
+ 250,
1862
+ 250,
1863
+ 210
1864
+ ],
1865
+ lightgray: [
1866
+ 211,
1867
+ 211,
1868
+ 211
1869
+ ],
1870
+ lightgreen: [
1871
+ 144,
1872
+ 238,
1873
+ 144
1874
+ ],
1875
+ lightgrey: [
1876
+ 211,
1877
+ 211,
1878
+ 211
1879
+ ],
1880
+ lightpink: [
1881
+ 255,
1882
+ 182,
1883
+ 193
1884
+ ],
1885
+ lightsalmon: [
1886
+ 255,
1887
+ 160,
1888
+ 122
1889
+ ],
1890
+ lightseagreen: [
1891
+ 32,
1892
+ 178,
1893
+ 170
1894
+ ],
1895
+ lightskyblue: [
1896
+ 135,
1897
+ 206,
1898
+ 250
1899
+ ],
1900
+ lightslategray: [
1901
+ 119,
1902
+ 136,
1903
+ 153
1904
+ ],
1905
+ lightslategrey: [
1906
+ 119,
1907
+ 136,
1908
+ 153
1909
+ ],
1910
+ lightsteelblue: [
1911
+ 176,
1912
+ 196,
1913
+ 222
1914
+ ],
1915
+ lightyellow: [
1916
+ 255,
1917
+ 255,
1918
+ 224
1919
+ ],
1920
+ lime: [
1921
+ 0,
1922
+ 255,
1923
+ 0
1924
+ ],
1925
+ limegreen: [
1926
+ 50,
1927
+ 205,
1928
+ 50
1929
+ ],
1930
+ linen: [
1931
+ 250,
1932
+ 240,
1933
+ 230
1934
+ ],
1935
+ magenta: [
1936
+ 255,
1937
+ 0,
1938
+ 255
1939
+ ],
1940
+ maroon: [
1941
+ 128,
1942
+ 0,
1943
+ 0
1944
+ ],
1945
+ mediumaquamarine: [
1946
+ 102,
1947
+ 205,
1948
+ 170
1949
+ ],
1950
+ mediumblue: [
1951
+ 0,
1952
+ 0,
1953
+ 205
1954
+ ],
1955
+ mediumorchid: [
1956
+ 186,
1957
+ 85,
1958
+ 211
1959
+ ],
1960
+ mediumpurple: [
1961
+ 147,
1962
+ 112,
1963
+ 219
1964
+ ],
1965
+ mediumseagreen: [
1966
+ 60,
1967
+ 179,
1968
+ 113
1969
+ ],
1970
+ mediumslateblue: [
1971
+ 123,
1972
+ 104,
1973
+ 238
1974
+ ],
1975
+ mediumspringgreen: [
1976
+ 0,
1977
+ 250,
1978
+ 154
1979
+ ],
1980
+ mediumturquoise: [
1981
+ 72,
1982
+ 209,
1983
+ 204
1984
+ ],
1985
+ mediumvioletred: [
1986
+ 199,
1987
+ 21,
1988
+ 133
1989
+ ],
1990
+ midnightblue: [
1991
+ 25,
1992
+ 25,
1993
+ 112
1994
+ ],
1995
+ mintcream: [
1996
+ 245,
1997
+ 255,
1998
+ 250
1999
+ ],
2000
+ mistyrose: [
2001
+ 255,
2002
+ 228,
2003
+ 225
2004
+ ],
2005
+ moccasin: [
2006
+ 255,
2007
+ 228,
2008
+ 181
2009
+ ],
2010
+ navajowhite: [
2011
+ 255,
2012
+ 222,
2013
+ 173
2014
+ ],
2015
+ navy: [
2016
+ 0,
2017
+ 0,
2018
+ 128
2019
+ ],
2020
+ oldlace: [
2021
+ 253,
2022
+ 245,
2023
+ 230
2024
+ ],
2025
+ olive: [
2026
+ 128,
2027
+ 128,
2028
+ 0
2029
+ ],
2030
+ olivedrab: [
2031
+ 107,
2032
+ 142,
2033
+ 35
2034
+ ],
2035
+ orange: [
2036
+ 255,
2037
+ 165,
2038
+ 0
2039
+ ],
2040
+ orangered: [
2041
+ 255,
2042
+ 69,
2043
+ 0
2044
+ ],
2045
+ orchid: [
2046
+ 218,
2047
+ 112,
2048
+ 214
2049
+ ],
2050
+ palegoldenrod: [
2051
+ 238,
2052
+ 232,
2053
+ 170
2054
+ ],
2055
+ palegreen: [
2056
+ 152,
2057
+ 251,
2058
+ 152
2059
+ ],
2060
+ paleturquoise: [
2061
+ 175,
2062
+ 238,
2063
+ 238
2064
+ ],
2065
+ palevioletred: [
2066
+ 219,
2067
+ 112,
2068
+ 147
2069
+ ],
2070
+ papayawhip: [
2071
+ 255,
2072
+ 239,
2073
+ 213
2074
+ ],
2075
+ peachpuff: [
2076
+ 255,
2077
+ 218,
2078
+ 185
2079
+ ],
2080
+ peru: [
2081
+ 205,
2082
+ 133,
2083
+ 63
2084
+ ],
2085
+ pink: [
2086
+ 255,
2087
+ 192,
2088
+ 203
2089
+ ],
2090
+ plum: [
2091
+ 221,
2092
+ 160,
2093
+ 221
2094
+ ],
2095
+ powderblue: [
2096
+ 176,
2097
+ 224,
2098
+ 230
2099
+ ],
2100
+ purple: [
2101
+ 128,
2102
+ 0,
2103
+ 128
2104
+ ],
2105
+ rebeccapurple: [
2106
+ 102,
2107
+ 51,
2108
+ 153
2109
+ ],
2110
+ red: [
2111
+ 255,
2112
+ 0,
2113
+ 0
2114
+ ],
2115
+ rosybrown: [
2116
+ 188,
2117
+ 143,
2118
+ 143
2119
+ ],
2120
+ royalblue: [
2121
+ 65,
2122
+ 105,
2123
+ 225
2124
+ ],
2125
+ saddlebrown: [
2126
+ 139,
2127
+ 69,
2128
+ 19
2129
+ ],
2130
+ salmon: [
2131
+ 250,
2132
+ 128,
2133
+ 114
2134
+ ],
2135
+ sandybrown: [
2136
+ 244,
2137
+ 164,
2138
+ 96
2139
+ ],
2140
+ seagreen: [
2141
+ 46,
2142
+ 139,
2143
+ 87
2144
+ ],
2145
+ seashell: [
2146
+ 255,
2147
+ 245,
2148
+ 238
2149
+ ],
2150
+ sienna: [
2151
+ 160,
2152
+ 82,
2153
+ 45
2154
+ ],
2155
+ silver: [
2156
+ 192,
2157
+ 192,
2158
+ 192
2159
+ ],
2160
+ skyblue: [
2161
+ 135,
2162
+ 206,
2163
+ 235
2164
+ ],
2165
+ slateblue: [
2166
+ 106,
2167
+ 90,
2168
+ 205
2169
+ ],
2170
+ slategray: [
2171
+ 112,
2172
+ 128,
2173
+ 144
2174
+ ],
2175
+ slategrey: [
2176
+ 112,
2177
+ 128,
2178
+ 144
2179
+ ],
2180
+ snow: [
2181
+ 255,
2182
+ 250,
2183
+ 250
2184
+ ],
2185
+ springgreen: [
2186
+ 0,
2187
+ 255,
2188
+ 127
2189
+ ],
2190
+ steelblue: [
2191
+ 70,
2192
+ 130,
2193
+ 180
2194
+ ],
2195
+ tan: [
2196
+ 210,
2197
+ 180,
2198
+ 140
2199
+ ],
2200
+ teal: [
2201
+ 0,
2202
+ 128,
2203
+ 128
2204
+ ],
2205
+ thistle: [
2206
+ 216,
2207
+ 191,
2208
+ 216
2209
+ ],
2210
+ tomato: [
2211
+ 255,
2212
+ 99,
2213
+ 71
2214
+ ],
2215
+ turquoise: [
2216
+ 64,
2217
+ 224,
2218
+ 208
2219
+ ],
2220
+ violet: [
2221
+ 238,
2222
+ 130,
2223
+ 238
2224
+ ],
2225
+ wheat: [
2226
+ 245,
2227
+ 222,
2228
+ 179
2229
+ ],
2230
+ white: [
2231
+ 255,
2232
+ 255,
2233
+ 255
2234
+ ],
2235
+ whitesmoke: [
2236
+ 245,
2237
+ 245,
2238
+ 245
2239
+ ],
2240
+ yellow: [
2241
+ 255,
2242
+ 255,
2243
+ 0
2244
+ ],
2245
+ yellowgreen: [
2246
+ 154,
2247
+ 205,
2248
+ 50
2249
+ ]
2250
+ };
2251
+ },
2252
+ "../../node_modules/.pnpm/has-flag@4.0.0/node_modules/has-flag/index.js" (module) {
2253
+ "use strict";
2254
+ module.exports = (flag, argv = process.argv)=>{
2255
+ const prefix = flag.startsWith('-') ? '' : 1 === flag.length ? '-' : '--';
2256
+ const position = argv.indexOf(prefix + flag);
2257
+ const terminatorPosition = argv.indexOf('--');
2258
+ return -1 !== position && (-1 === terminatorPosition || position < terminatorPosition);
2259
+ };
2260
+ },
2261
+ "../../node_modules/.pnpm/supports-color@7.2.0/node_modules/supports-color/index.js" (module, __unused_rspack_exports, __webpack_require__) {
2262
+ "use strict";
2263
+ const os = __webpack_require__("os");
2264
+ const tty = __webpack_require__("tty");
2265
+ const hasFlag = __webpack_require__("../../node_modules/.pnpm/has-flag@4.0.0/node_modules/has-flag/index.js");
2266
+ const { env } = process;
2267
+ let forceColor;
2268
+ if (hasFlag('no-color') || hasFlag('no-colors') || hasFlag('color=false') || hasFlag('color=never')) forceColor = 0;
2269
+ else if (hasFlag('color') || hasFlag('colors') || hasFlag('color=true') || hasFlag('color=always')) forceColor = 1;
2270
+ if ('FORCE_COLOR' in env) forceColor = 'true' === env.FORCE_COLOR ? 1 : 'false' === env.FORCE_COLOR ? 0 : 0 === env.FORCE_COLOR.length ? 1 : Math.min(parseInt(env.FORCE_COLOR, 10), 3);
2271
+ function translateLevel(level) {
2272
+ if (0 === level) return false;
2273
+ return {
2274
+ level,
2275
+ hasBasic: true,
2276
+ has256: level >= 2,
2277
+ has16m: level >= 3
2278
+ };
2279
+ }
2280
+ function supportsColor(haveStream, streamIsTTY) {
2281
+ if (0 === forceColor) return 0;
2282
+ if (hasFlag('color=16m') || hasFlag('color=full') || hasFlag('color=truecolor')) return 3;
2283
+ if (hasFlag('color=256')) return 2;
2284
+ if (haveStream && !streamIsTTY && void 0 === forceColor) return 0;
2285
+ const min = forceColor || 0;
2286
+ if ('dumb' === env.TERM) return min;
2287
+ if ('win32' === process.platform) {
2288
+ const osRelease = os.release().split('.');
2289
+ if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) return Number(osRelease[2]) >= 14931 ? 3 : 2;
2290
+ return 1;
2291
+ }
2292
+ if ('CI' in env) {
2293
+ if ([
2294
+ 'TRAVIS',
2295
+ 'CIRCLECI',
2296
+ 'APPVEYOR',
2297
+ 'GITLAB_CI',
2298
+ 'GITHUB_ACTIONS',
2299
+ 'BUILDKITE'
2300
+ ].some((sign)=>sign in env) || 'codeship' === env.CI_NAME) return 1;
2301
+ return min;
2302
+ }
2303
+ if ('TEAMCITY_VERSION' in env) return /^(9\.(0*[1-9]\d*)\.|\d{2,}\.)/.test(env.TEAMCITY_VERSION) ? 1 : 0;
2304
+ if ('truecolor' === env.COLORTERM) return 3;
2305
+ if ('TERM_PROGRAM' in env) {
2306
+ const version = parseInt((env.TERM_PROGRAM_VERSION || '').split('.')[0], 10);
2307
+ switch(env.TERM_PROGRAM){
2308
+ case 'iTerm.app':
2309
+ return version >= 3 ? 3 : 2;
2310
+ case 'Apple_Terminal':
2311
+ return 2;
2312
+ }
2313
+ }
2314
+ if (/-256(color)?$/i.test(env.TERM)) return 2;
2315
+ if (/^screen|^xterm|^vt100|^vt220|^rxvt|color|ansi|cygwin|linux/i.test(env.TERM)) return 1;
2316
+ if ('COLORTERM' in env) return 1;
2317
+ return min;
2318
+ }
2319
+ function getSupportLevel(stream) {
2320
+ const level = supportsColor(stream, stream && stream.isTTY);
2321
+ return translateLevel(level);
2322
+ }
2323
+ module.exports = {
2324
+ supportsColor: getSupportLevel,
2325
+ stdout: translateLevel(supportsColor(true, tty.isatty(1))),
2326
+ stderr: translateLevel(supportsColor(true, tty.isatty(2)))
2327
+ };
2328
+ },
2329
+ "@midscene/core/yaml" (module) {
2330
+ "use strict";
2331
+ module.exports = require("@midscene/core/yaml");
2332
+ },
2333
+ "@midscene/shared/logger" (module) {
2334
+ "use strict";
2335
+ module.exports = require("@midscene/shared/logger");
2336
+ },
2337
+ "lodash.merge" (module) {
2338
+ "use strict";
2339
+ module.exports = require("lodash.merge");
2340
+ },
2341
+ "node:fs" (module) {
2342
+ "use strict";
2343
+ module.exports = require("node:fs");
2344
+ },
2345
+ "node:path" (module) {
2346
+ "use strict";
2347
+ module.exports = require("node:path");
2348
+ },
2349
+ "node:url" (module) {
2350
+ "use strict";
2351
+ module.exports = require("node:url");
2352
+ },
2353
+ os (module) {
2354
+ "use strict";
2355
+ module.exports = require("os");
2356
+ },
2357
+ tty (module) {
2358
+ "use strict";
2359
+ module.exports = require("tty");
2360
+ },
2361
+ "../../node_modules/.pnpm/p-limit@6.2.0/node_modules/p-limit/index.js" (__unused_rspack___webpack_module__, __webpack_exports__, __webpack_require__) {
2362
+ "use strict";
2363
+ __webpack_require__.d(__webpack_exports__, {
2364
+ A: ()=>pLimit
2365
+ });
2366
+ class Node {
2367
+ value;
2368
+ next;
2369
+ constructor(value){
2370
+ this.value = value;
2371
+ }
2372
+ }
2373
+ class Queue {
2374
+ #head;
2375
+ #tail;
2376
+ #size;
2377
+ constructor(){
2378
+ this.clear();
2379
+ }
2380
+ enqueue(value) {
2381
+ const node = new Node(value);
2382
+ if (this.#head) {
2383
+ this.#tail.next = node;
2384
+ this.#tail = node;
2385
+ } else {
2386
+ this.#head = node;
2387
+ this.#tail = node;
2388
+ }
2389
+ this.#size++;
2390
+ }
2391
+ dequeue() {
2392
+ const current = this.#head;
2393
+ if (!current) return;
2394
+ this.#head = this.#head.next;
2395
+ this.#size--;
2396
+ return current.value;
2397
+ }
2398
+ peek() {
2399
+ if (!this.#head) return;
2400
+ return this.#head.value;
2401
+ }
2402
+ clear() {
2403
+ this.#head = void 0;
2404
+ this.#tail = void 0;
2405
+ this.#size = 0;
2406
+ }
2407
+ get size() {
2408
+ return this.#size;
2409
+ }
2410
+ *[Symbol.iterator]() {
2411
+ let current = this.#head;
2412
+ while(current){
2413
+ yield current.value;
2414
+ current = current.next;
2415
+ }
2416
+ }
2417
+ *drain() {
2418
+ while(this.#head)yield this.dequeue();
2419
+ }
2420
+ }
2421
+ function pLimit(concurrency) {
2422
+ validateConcurrency(concurrency);
2423
+ const queue = new Queue();
2424
+ let activeCount = 0;
2425
+ const resumeNext = ()=>{
2426
+ if (activeCount < concurrency && queue.size > 0) {
2427
+ queue.dequeue()();
2428
+ activeCount++;
2429
+ }
2430
+ };
2431
+ const next = ()=>{
2432
+ activeCount--;
2433
+ resumeNext();
2434
+ };
2435
+ const run = async (function_, resolve, arguments_)=>{
2436
+ const result = (async ()=>function_(...arguments_))();
2437
+ resolve(result);
2438
+ try {
2439
+ await result;
2440
+ } catch {}
2441
+ next();
2442
+ };
2443
+ const enqueue = (function_, resolve, arguments_)=>{
2444
+ new Promise((internalResolve)=>{
2445
+ queue.enqueue(internalResolve);
2446
+ }).then(run.bind(void 0, function_, resolve, arguments_));
2447
+ (async ()=>{
2448
+ await Promise.resolve();
2449
+ if (activeCount < concurrency) resumeNext();
2450
+ })();
2451
+ };
2452
+ const generator = (function_, ...arguments_)=>new Promise((resolve)=>{
2453
+ enqueue(function_, resolve, arguments_);
2454
+ });
2455
+ Object.defineProperties(generator, {
2456
+ activeCount: {
2457
+ get: ()=>activeCount
2458
+ },
2459
+ pendingCount: {
2460
+ get: ()=>queue.size
2461
+ },
2462
+ clearQueue: {
2463
+ value () {
2464
+ queue.clear();
2465
+ }
2466
+ },
2467
+ concurrency: {
2468
+ get: ()=>concurrency,
2469
+ set (newConcurrency) {
2470
+ validateConcurrency(newConcurrency);
2471
+ concurrency = newConcurrency;
2472
+ queueMicrotask(()=>{
2473
+ while(activeCount < concurrency && queue.size > 0)resumeNext();
2474
+ });
2475
+ }
2476
+ }
2477
+ });
2478
+ return generator;
2479
+ }
2480
+ function validateConcurrency(concurrency) {
2481
+ if (!((Number.isInteger(concurrency) || concurrency === 1 / 0) && concurrency > 0)) throw new TypeError('Expected `concurrency` to be a number from 1 and up');
2482
+ }
2483
+ },
2484
+ "../../node_modules/.pnpm/restore-cursor@5.1.0/node_modules/restore-cursor/index.js" (__unused_rspack___webpack_module__, __webpack_exports__, __webpack_require__) {
2485
+ "use strict";
2486
+ __webpack_require__.d(__webpack_exports__, {
2487
+ A: ()=>restore_cursor
2488
+ });
2489
+ const external_node_process_namespaceObject = require("node:process");
2490
+ const copyProperty = (to, from, property, ignoreNonConfigurable)=>{
2491
+ if ('length' === property || 'prototype' === property) return;
2492
+ if ('arguments' === property || 'caller' === property) return;
2493
+ const toDescriptor = Object.getOwnPropertyDescriptor(to, property);
2494
+ const fromDescriptor = Object.getOwnPropertyDescriptor(from, property);
2495
+ if (!canCopyProperty(toDescriptor, fromDescriptor) && ignoreNonConfigurable) return;
2496
+ Object.defineProperty(to, property, fromDescriptor);
2497
+ };
2498
+ const canCopyProperty = function(toDescriptor, fromDescriptor) {
2499
+ return void 0 === toDescriptor || toDescriptor.configurable || toDescriptor.writable === fromDescriptor.writable && toDescriptor.enumerable === fromDescriptor.enumerable && toDescriptor.configurable === fromDescriptor.configurable && (toDescriptor.writable || toDescriptor.value === fromDescriptor.value);
2500
+ };
2501
+ const changePrototype = (to, from)=>{
2502
+ const fromPrototype = Object.getPrototypeOf(from);
2503
+ if (fromPrototype === Object.getPrototypeOf(to)) return;
2504
+ Object.setPrototypeOf(to, fromPrototype);
2505
+ };
2506
+ const wrappedToString = (withName, fromBody)=>`/* Wrapped ${withName}*/\n${fromBody}`;
2507
+ const toStringDescriptor = Object.getOwnPropertyDescriptor(Function.prototype, 'toString');
2508
+ const toStringName = Object.getOwnPropertyDescriptor(Function.prototype.toString, 'name');
2509
+ const changeToString = (to, from, name)=>{
2510
+ const withName = '' === name ? '' : `with ${name.trim()}() `;
2511
+ const newToString = wrappedToString.bind(null, withName, from.toString());
2512
+ Object.defineProperty(newToString, 'name', toStringName);
2513
+ const { writable, enumerable, configurable } = toStringDescriptor;
2514
+ Object.defineProperty(to, 'toString', {
2515
+ value: newToString,
2516
+ writable,
2517
+ enumerable,
2518
+ configurable
2519
+ });
2520
+ };
2521
+ function mimicFunction(to, from, { ignoreNonConfigurable = false } = {}) {
2522
+ const { name } = to;
2523
+ for (const property of Reflect.ownKeys(from))copyProperty(to, from, property, ignoreNonConfigurable);
2524
+ changePrototype(to, from);
2525
+ changeToString(to, from, name);
2526
+ return to;
2527
+ }
2528
+ const calledFunctions = new WeakMap();
2529
+ const onetime_onetime = (function_, options = {})=>{
2530
+ if ('function' != typeof function_) throw new TypeError('Expected a function');
2531
+ let returnValue;
2532
+ let callCount = 0;
2533
+ const functionName = function_.displayName || function_.name || '<anonymous>';
2534
+ const onetime = function(...arguments_) {
2535
+ calledFunctions.set(onetime, ++callCount);
2536
+ if (1 === callCount) {
2537
+ returnValue = function_.apply(this, arguments_);
2538
+ function_ = void 0;
2539
+ } else if (true === options.throw) throw new Error(`Function \`${functionName}\` can only be called once`);
2540
+ return returnValue;
2541
+ };
2542
+ mimicFunction(onetime, function_);
2543
+ calledFunctions.set(onetime, callCount);
2544
+ return onetime;
2545
+ };
2546
+ onetime_onetime.callCount = (function_)=>{
2547
+ if (!calledFunctions.has(function_)) throw new Error(`The given function \`${function_.name}\` is not wrapped by the \`onetime\` package`);
2548
+ return calledFunctions.get(function_);
2549
+ };
2550
+ const node_modules_onetime = onetime_onetime;
2551
+ const signals = [];
2552
+ signals.push('SIGHUP', 'SIGINT', 'SIGTERM');
2553
+ if ('win32' !== process.platform) signals.push('SIGALRM', 'SIGABRT', 'SIGVTALRM', 'SIGXCPU', 'SIGXFSZ', 'SIGUSR2', 'SIGTRAP', 'SIGSYS', 'SIGQUIT', 'SIGIOT');
2554
+ if ('linux' === process.platform) signals.push('SIGIO', 'SIGPOLL', 'SIGPWR', 'SIGSTKFLT');
2555
+ const processOk = (process1)=>!!process1 && 'object' == typeof process1 && 'function' == typeof process1.removeListener && 'function' == typeof process1.emit && 'function' == typeof process1.reallyExit && 'function' == typeof process1.listeners && 'function' == typeof process1.kill && 'number' == typeof process1.pid && 'function' == typeof process1.on;
2556
+ const kExitEmitter = Symbol.for('signal-exit emitter');
2557
+ const global = globalThis;
2558
+ const ObjectDefineProperty = Object.defineProperty.bind(Object);
2559
+ class Emitter {
2560
+ emitted = {
2561
+ afterExit: false,
2562
+ exit: false
2563
+ };
2564
+ listeners = {
2565
+ afterExit: [],
2566
+ exit: []
2567
+ };
2568
+ count = 0;
2569
+ id = Math.random();
2570
+ constructor(){
2571
+ if (global[kExitEmitter]) return global[kExitEmitter];
2572
+ ObjectDefineProperty(global, kExitEmitter, {
2573
+ value: this,
2574
+ writable: false,
2575
+ enumerable: false,
2576
+ configurable: false
2577
+ });
2578
+ }
2579
+ on(ev, fn) {
2580
+ this.listeners[ev].push(fn);
2581
+ }
2582
+ removeListener(ev, fn) {
2583
+ const list = this.listeners[ev];
2584
+ const i = list.indexOf(fn);
2585
+ if (-1 === i) return;
2586
+ if (0 === i && 1 === list.length) list.length = 0;
2587
+ else list.splice(i, 1);
2588
+ }
2589
+ emit(ev, code, signal) {
2590
+ if (this.emitted[ev]) return false;
2591
+ this.emitted[ev] = true;
2592
+ let ret = false;
2593
+ for (const fn of this.listeners[ev])ret = true === fn(code, signal) || ret;
2594
+ if ('exit' === ev) ret = this.emit('afterExit', code, signal) || ret;
2595
+ return ret;
2596
+ }
2597
+ }
2598
+ class SignalExitBase {
2599
+ }
2600
+ const signalExitWrap = (handler)=>({
2601
+ onExit (cb, opts) {
2602
+ return handler.onExit(cb, opts);
2603
+ },
2604
+ load () {
2605
+ return handler.load();
2606
+ },
2607
+ unload () {
2608
+ return handler.unload();
2609
+ }
2610
+ });
2611
+ class SignalExitFallback extends SignalExitBase {
2612
+ onExit() {
2613
+ return ()=>{};
2614
+ }
2615
+ load() {}
2616
+ unload() {}
2617
+ }
2618
+ class SignalExit extends SignalExitBase {
2619
+ #hupSig = 'win32' === mjs_process.platform ? 'SIGINT' : 'SIGHUP';
2620
+ #emitter = new Emitter();
2621
+ #process;
2622
+ #originalProcessEmit;
2623
+ #originalProcessReallyExit;
2624
+ #sigListeners = {};
2625
+ #loaded = false;
2626
+ constructor(process1){
2627
+ super();
2628
+ this.#process = process1;
2629
+ this.#sigListeners = {};
2630
+ for (const sig of signals)this.#sigListeners[sig] = ()=>{
2631
+ const listeners = this.#process.listeners(sig);
2632
+ let { count } = this.#emitter;
2633
+ const p = process1;
2634
+ if ('object' == typeof p.__signal_exit_emitter__ && 'number' == typeof p.__signal_exit_emitter__.count) count += p.__signal_exit_emitter__.count;
2635
+ if (listeners.length === count) {
2636
+ this.unload();
2637
+ const ret = this.#emitter.emit('exit', null, sig);
2638
+ const s = 'SIGHUP' === sig ? this.#hupSig : sig;
2639
+ if (!ret) process1.kill(process1.pid, s);
2640
+ }
2641
+ };
2642
+ this.#originalProcessReallyExit = process1.reallyExit;
2643
+ this.#originalProcessEmit = process1.emit;
2644
+ }
2645
+ onExit(cb, opts) {
2646
+ if (!processOk(this.#process)) return ()=>{};
2647
+ if (false === this.#loaded) this.load();
2648
+ const ev = opts?.alwaysLast ? 'afterExit' : 'exit';
2649
+ this.#emitter.on(ev, cb);
2650
+ return ()=>{
2651
+ this.#emitter.removeListener(ev, cb);
2652
+ if (0 === this.#emitter.listeners['exit'].length && 0 === this.#emitter.listeners['afterExit'].length) this.unload();
2653
+ };
2654
+ }
2655
+ load() {
2656
+ if (this.#loaded) return;
2657
+ this.#loaded = true;
2658
+ this.#emitter.count += 1;
2659
+ for (const sig of signals)try {
2660
+ const fn = this.#sigListeners[sig];
2661
+ if (fn) this.#process.on(sig, fn);
2662
+ } catch (_) {}
2663
+ this.#process.emit = (ev, ...a)=>this.#processEmit(ev, ...a);
2664
+ this.#process.reallyExit = (code)=>this.#processReallyExit(code);
2665
+ }
2666
+ unload() {
2667
+ if (!this.#loaded) return;
2668
+ this.#loaded = false;
2669
+ signals.forEach((sig)=>{
2670
+ const listener = this.#sigListeners[sig];
2671
+ if (!listener) throw new Error('Listener not defined for signal: ' + sig);
2672
+ try {
2673
+ this.#process.removeListener(sig, listener);
2674
+ } catch (_) {}
2675
+ });
2676
+ this.#process.emit = this.#originalProcessEmit;
2677
+ this.#process.reallyExit = this.#originalProcessReallyExit;
2678
+ this.#emitter.count -= 1;
2679
+ }
2680
+ #processReallyExit(code) {
2681
+ if (!processOk(this.#process)) return 0;
2682
+ this.#process.exitCode = code || 0;
2683
+ this.#emitter.emit('exit', this.#process.exitCode, null);
2684
+ return this.#originalProcessReallyExit.call(this.#process, this.#process.exitCode);
2685
+ }
2686
+ #processEmit(ev, ...args) {
2687
+ const og = this.#originalProcessEmit;
2688
+ if (!('exit' === ev && processOk(this.#process))) return og.call(this.#process, ev, ...args);
2689
+ {
2690
+ if ('number' == typeof args[0]) this.#process.exitCode = args[0];
2691
+ const ret = og.call(this.#process, ev, ...args);
2692
+ this.#emitter.emit('exit', this.#process.exitCode, null);
2693
+ return ret;
2694
+ }
2695
+ }
2696
+ }
2697
+ const mjs_process = globalThis.process;
2698
+ const { onExit, load, unload } = signalExitWrap(processOk(mjs_process) ? new SignalExit(mjs_process) : new SignalExitFallback());
2699
+ 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;
2700
+ const restoreCursor = terminal ? node_modules_onetime(()=>{
2701
+ onExit(()=>{
2702
+ terminal.write('\u001B[?25h');
2703
+ }, {
2704
+ alwaysLast: true
2705
+ });
2706
+ }) : ()=>{};
2707
+ const restore_cursor = restoreCursor;
2708
+ }
2709
+ };
2710
+ var __webpack_module_cache__ = {};
2711
+ function __webpack_require__(moduleId) {
2712
+ var cachedModule = __webpack_module_cache__[moduleId];
2713
+ if (void 0 !== cachedModule) return cachedModule.exports;
2714
+ var module = __webpack_module_cache__[moduleId] = {
2715
+ id: moduleId,
2716
+ loaded: false,
2717
+ exports: {}
2718
+ };
2719
+ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
2720
+ module.loaded = true;
2721
+ return module.exports;
2722
+ }
2723
+ (()=>{
2724
+ __webpack_require__.n = (module)=>{
2725
+ var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
2726
+ __webpack_require__.d(getter, {
2727
+ a: getter
2728
+ });
2729
+ return getter;
2730
+ };
2731
+ })();
2732
+ (()=>{
2733
+ __webpack_require__.d = (exports1, definition)=>{
2734
+ for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
2735
+ enumerable: true,
2736
+ get: definition[key]
2737
+ });
2738
+ };
2739
+ })();
2740
+ (()=>{
2741
+ __webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
2742
+ })();
2743
+ (()=>{
2744
+ __webpack_require__.r = (exports1)=>{
2745
+ if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
2746
+ value: 'Module'
2747
+ });
2748
+ Object.defineProperty(exports1, '__esModule', {
2749
+ value: true
2750
+ });
2751
+ };
2752
+ })();
2753
+ (()=>{
2754
+ __webpack_require__.nmd = (module)=>{
2755
+ module.paths = [];
2756
+ if (!module.children) module.children = [];
2757
+ return module;
2758
+ };
2759
+ })();
2760
+ var __webpack_exports__ = {};
2761
+ (()=>{
2762
+ "use strict";
2763
+ __webpack_require__.r(__webpack_exports__);
2764
+ __webpack_require__.d(__webpack_exports__, {
2765
+ createRstestYamlProject: ()=>createRstestYamlProject,
2766
+ defineYamlBatchTest: ()=>defineYamlBatchTest,
2767
+ resolveTestName: ()=>resolveTestName,
2768
+ runFrameworkTestConfig: ()=>runFrameworkTestConfig,
2769
+ runRstestYamlProject: ()=>runRstestYamlProject,
2770
+ runYamlCase: ()=>runYamlCase,
2771
+ defineYamlCaseTest: ()=>defineYamlCaseTest,
2772
+ getYamlPlayerFailure: ()=>getYamlPlayerFailure,
2773
+ runYamlCaseResult: ()=>runYamlCaseResult,
2774
+ runYamlBatchInRstest: ()=>runYamlBatchInRstest,
2775
+ createYamlCaseResult: ()=>createYamlCaseResult,
2776
+ createYamlCaseFailure: ()=>createYamlCaseFailure,
2777
+ resolveRstestCoreImportPath: ()=>resolveRstestCoreImportPath
2778
+ });
2779
+ var external_node_fs_ = __webpack_require__("node:fs");
2780
+ var external_node_path_ = __webpack_require__("node:path");
2781
+ var external_node_path_default = /*#__PURE__*/ __webpack_require__.n(external_node_path_);
2782
+ const common_namespaceObject = require("@midscene/shared/common");
2783
+ const notExecutedError = 'Not executed (previous task failed)';
2784
+ function createNotExecutedYamlResult(file) {
2785
+ return {
2786
+ file,
2787
+ success: false,
2788
+ executed: false,
2789
+ output: void 0,
2790
+ report: void 0,
2791
+ duration: 0,
2792
+ resultType: 'notExecuted',
2793
+ error: notExecutedError
2794
+ };
2795
+ }
2796
+ function createExecutedYamlResult(options) {
2797
+ const { file, player, duration } = options;
2798
+ const hasFailedTasks = player.taskStatusList?.some((task)=>'error' === task.status) ?? false;
2799
+ const hasPlayerError = 'error' === player.status;
2800
+ let success;
2801
+ let resultType;
2802
+ if (hasPlayerError) {
2803
+ success = false;
2804
+ resultType = 'failed';
2805
+ } else if (hasFailedTasks) {
2806
+ success = false;
2807
+ resultType = 'partialFailed';
2808
+ } else {
2809
+ success = true;
2810
+ resultType = 'success';
2811
+ }
2812
+ let outputPath = player.output || void 0;
2813
+ if (outputPath && !(0, external_node_fs_.existsSync)(outputPath)) outputPath = void 0;
2814
+ let errorMessage;
2815
+ if (player.errorInSetup?.message) errorMessage = player.errorInSetup.message;
2816
+ else if (hasPlayerError || hasFailedTasks) {
2817
+ const taskErrors = player.taskStatusList?.filter((task)=>'error' === task.status && task.error?.message).map((task)=>task.error.message);
2818
+ errorMessage = taskErrors && taskErrors.length > 0 ? taskErrors.join('; ') : hasPlayerError ? 'Execution failed' : 'Some tasks failed';
2819
+ }
2820
+ return {
2821
+ file,
2822
+ success,
2823
+ executed: true,
2824
+ output: outputPath,
2825
+ report: player.reportFile || void 0,
2826
+ duration,
2827
+ resultType,
2828
+ error: errorMessage
2829
+ };
2830
+ }
2831
+ function getExecutionSummary(results) {
2832
+ return {
2833
+ total: results.length,
2834
+ successful: getResultsByType(results, 'success').length,
2835
+ failed: getResultsByType(results, 'failed').length,
2836
+ partialFailed: getResultsByType(results, 'partialFailed').length,
2837
+ notExecuted: getResultsByType(results, 'notExecuted').length,
2838
+ totalDuration: results.reduce((sum, r)=>sum + (r.duration || 0), 0)
2839
+ };
2840
+ }
2841
+ function getResultsByType(results, resultType) {
2842
+ return results.filter((result)=>result.resultType === resultType);
2843
+ }
2844
+ function getSummaryAbsolutePath(summary) {
2845
+ return (0, external_node_path_.resolve)((0, common_namespaceObject.getMidsceneRunSubDir)('output'), summary);
2846
+ }
2847
+ function writeExecutionSummaryFile(summary, results) {
2848
+ const indexPath = getSummaryAbsolutePath(summary);
2849
+ const outputDir = (0, external_node_path_.dirname)(indexPath);
2850
+ (0, external_node_fs_.mkdirSync)(outputDir, {
2851
+ recursive: true
2852
+ });
2853
+ const executionSummary = getExecutionSummary(results);
2854
+ const indexData = {
2855
+ summary: {
2856
+ ...executionSummary,
2857
+ generatedAt: new Date().toLocaleString()
2858
+ },
2859
+ results: results.map((result)=>({
2860
+ script: (0, external_node_path_.relative)(outputDir, result.file),
2861
+ success: result.success,
2862
+ resultType: result.resultType,
2863
+ output: result.output ? (()=>{
2864
+ const relativePath = (0, external_node_path_.relative)(outputDir, result.output);
2865
+ return relativePath.startsWith('.') ? relativePath : `./${relativePath}`;
2866
+ })() : void 0,
2867
+ report: result.report ? (0, external_node_path_.relative)(outputDir, result.report) : void 0,
2868
+ error: result.error,
2869
+ duration: result.duration
2870
+ }))
2871
+ };
2872
+ (0, external_node_fs_.writeFileSync)(indexPath, JSON.stringify(indexData, null, 2));
2873
+ return indexPath;
2874
+ }
2875
+ function printExecutionPlan(config) {
2876
+ console.log(' Scripts:');
2877
+ for (const file of config.files)console.log(` - ${file}`);
2878
+ console.log('📋 Execution plan');
2879
+ console.log(` Concurrency: ${config.concurrent}`);
2880
+ console.log(` Keep window: ${config.keepWindow}`);
2881
+ console.log(` Headed: ${config.headed}`);
2882
+ console.log(` Continue on error: ${config.continueOnError}`);
2883
+ console.log(` Share browser context: ${config.shareBrowserContext ?? false}`);
2884
+ console.log(` Summary output: ${config.summary}`);
2885
+ }
2886
+ function printExecutionFinished() {
2887
+ console.log('Execution finished:');
2888
+ }
2889
+ function printExecutionSummary(results, summaryPath) {
2890
+ const summary = getExecutionSummary(results);
2891
+ const successfulFiles = getResultsByType(results, 'success');
2892
+ const failedFiles = getResultsByType(results, 'failed');
2893
+ const partialFailedFiles = getResultsByType(results, 'partialFailed');
2894
+ const notExecutedFiles = getResultsByType(results, 'notExecuted');
2895
+ const success = 0 === summary.failed && 0 === summary.partialFailed && 0 === summary.notExecuted;
2896
+ console.log('\n📊 Execution Summary:');
2897
+ console.log(` Total files: ${summary.total}`);
2898
+ console.log(` Successful: ${summary.successful}`);
2899
+ console.log(` Failed: ${summary.failed}`);
2900
+ console.log(` Partial failed: ${summary.partialFailed}`);
2901
+ console.log(` Not executed: ${summary.notExecuted}`);
2902
+ console.log(` Duration: ${(summary.totalDuration / 1000).toFixed(2)}s`);
2903
+ console.log(` Summary: ${summaryPath}`);
2904
+ if (successfulFiles.length > 0) {
2905
+ console.log('\n✅ Successful files:');
2906
+ successfulFiles.forEach((result)=>{
2907
+ console.log(` ${result.file}`);
2908
+ });
2909
+ }
2910
+ if (failedFiles.length > 0) {
2911
+ console.log('\n❌ Failed files');
2912
+ failedFiles.forEach((result)=>{
2913
+ console.log(` ${result.file}`);
2914
+ if (result.error) console.log(` Error: ${result.error}`);
2915
+ });
2916
+ }
2917
+ if (partialFailedFiles.length > 0) {
2918
+ console.log('\n⚠️ Partial failed files (some tasks failed with continueOnError)');
2919
+ partialFailedFiles.forEach((result)=>{
2920
+ console.log(` ${result.file}`);
2921
+ if (result.error) console.log(` Error: ${result.error}`);
2922
+ });
2923
+ }
2924
+ if (notExecutedFiles.length > 0) {
2925
+ console.log('\n⏸️ Not executed files');
2926
+ notExecutedFiles.forEach((result)=>{
2927
+ console.log(` ${result.file}`);
2928
+ });
2929
+ }
2930
+ if (success) console.log('\n🎉 All files executed successfully!');
2931
+ else console.log('\n⚠️ Some files failed or were not executed.');
2932
+ return success;
2933
+ }
2934
+ const DEFAULT_YAML_TEST_TIMEOUT = 0;
2935
+ const toPosixPath = (value)=>value.split(external_node_path_.sep).join('/');
2936
+ const toImportLiteral = (value)=>JSON.stringify(toPosixPath(value));
2937
+ const toVirtualModuleId = (fileStem)=>`virtual:midscene-yaml/${fileStem}.test.ts`;
2938
+ const safeFileStem = (file, index)=>{
2939
+ const base = (0, external_node_path_.basename)(file, (0, external_node_path_.extname)(file)).replace(/[^a-zA-Z0-9._-]+/g, '-').replace(/^-+|-+$/g, '');
2940
+ return `${String(index + 1).padStart(3, '0')}-${base || 'case'}`;
2941
+ };
2942
+ const resolveTestName = (projectDir, yamlFile)=>{
2943
+ const relativePath = (0, external_node_path_.relative)(projectDir, yamlFile);
2944
+ return toPosixPath(relativePath.startsWith('..') ? yamlFile : relativePath);
2945
+ };
2946
+ const createGeneratedTestContent = (options)=>{
2947
+ const testOptions = {
2948
+ testName: options.testName,
2949
+ yamlFile: options.yamlFile,
2950
+ resultFile: options.resultFile,
2951
+ ...options.caseOptions ? {
2952
+ caseOptions: options.caseOptions
2953
+ } : {},
2954
+ ...options.webRuntimeOptions ? {
2955
+ webRuntimeOptions: options.webRuntimeOptions
2956
+ } : {}
2957
+ };
2958
+ return `import { defineYamlCaseTest } from ${toImportLiteral(options.frameworkImport)};
2959
+
2960
+ defineYamlCaseTest(${JSON.stringify(testOptions, null, 2)});
2961
+ `;
2962
+ };
2963
+ const createGeneratedBatchTestContent = (options)=>{
2964
+ const testOptions = {
2965
+ testName: options.testName,
2966
+ config: options.config,
2967
+ resultFiles: options.resultFiles
2968
+ };
2969
+ return `import { defineYamlBatchTest } from ${toImportLiteral(options.frameworkImport)};
2970
+
2971
+ defineYamlBatchTest(${JSON.stringify(testOptions, null, 2)});
2972
+ `;
2973
+ };
2974
+ const resolveDefaultFrameworkImport = ()=>{
2975
+ const entry = process.argv[1] ? (0, external_node_path_.resolve)(process.argv[1]) : '';
2976
+ const candidates = [
2977
+ entry ? (0, external_node_path_.join)((0, external_node_path_.dirname)(entry), 'framework', 'index.js') : '',
2978
+ entry ? (0, external_node_path_.join)((0, external_node_path_.dirname)(entry), '..', 'dist', 'lib', 'framework', 'index.js') : ''
2979
+ ].filter(Boolean);
2980
+ const matched = candidates.find((candidate)=>(0, external_node_fs_.existsSync)(candidate));
2981
+ return matched || '@midscene/cli/dist/lib/framework/index.js';
2982
+ };
2983
+ function createRstestYamlProject(options) {
2984
+ const projectDir = (0, external_node_path_.resolve)(options.projectDir || process.cwd());
2985
+ const outputDir = options.outputDir || (0, external_node_path_.join)((0, common_namespaceObject.getMidsceneRunSubDir)('tmp'), `rstest-yaml-${Date.now()}`);
2986
+ const resultDir = options.resultDir || (0, external_node_path_.join)(outputDir, 'results');
2987
+ const frameworkImport = options.frameworkImport || resolveDefaultFrameworkImport();
2988
+ const testTimeout = options.testTimeout ?? DEFAULT_YAML_TEST_TIMEOUT;
2989
+ (0, external_node_fs_.rmSync)(outputDir, {
2990
+ recursive: true,
2991
+ force: true
2992
+ });
2993
+ (0, external_node_fs_.mkdirSync)(resultDir, {
2994
+ recursive: true
2995
+ });
2996
+ const virtualModules = {};
2997
+ const cases = options.files.map((file, index)=>{
2998
+ const yamlFile = (0, external_node_path_.resolve)(file);
2999
+ const testName = resolveTestName(projectDir, yamlFile);
3000
+ const fileStem = safeFileStem(yamlFile, index);
3001
+ const resultFile = (0, external_node_path_.join)(resultDir, `${fileStem}.json`);
3002
+ const testModule = toVirtualModuleId(fileStem);
3003
+ virtualModules[testModule] = createGeneratedTestContent({
3004
+ frameworkImport,
3005
+ yamlFile,
3006
+ resultFile,
3007
+ testName,
3008
+ caseOptions: options.caseOptions?.[yamlFile],
3009
+ webRuntimeOptions: options.webRuntimeOptions?.[yamlFile]
3010
+ });
3011
+ return {
3012
+ yamlFile,
3013
+ testModule,
3014
+ resultFile,
3015
+ testName
3016
+ };
3017
+ });
3018
+ if (options.batchConfig) {
3019
+ const batchModule = 'virtual:midscene-yaml/batch.test.ts';
3020
+ const resultFiles = Object.fromEntries(cases.map((item)=>[
3021
+ item.yamlFile,
3022
+ item.resultFile
3023
+ ]));
3024
+ return {
3025
+ projectDir,
3026
+ outputDir,
3027
+ resultDir,
3028
+ include: [
3029
+ batchModule
3030
+ ],
3031
+ virtualModules: {
3032
+ [batchModule]: createGeneratedBatchTestContent({
3033
+ frameworkImport,
3034
+ testName: 'midscene yaml batch',
3035
+ config: options.batchConfig,
3036
+ resultFiles
3037
+ })
3038
+ },
3039
+ cases,
3040
+ maxConcurrency: 1,
3041
+ testTimeout,
3042
+ bail: options.bail
3043
+ };
3044
+ }
3045
+ return {
3046
+ projectDir,
3047
+ outputDir,
3048
+ resultDir,
3049
+ include: cases.map((item)=>item.testModule),
3050
+ virtualModules,
3051
+ cases,
3052
+ maxConcurrency: options.maxConcurrency,
3053
+ testTimeout,
3054
+ bail: options.bail
3055
+ };
3056
+ }
3057
+ const external_node_module_namespaceObject = require("node:module");
3058
+ var external_node_url_ = __webpack_require__("node:url");
3059
+ const requireFromCliEntry = ()=>{
3060
+ const entry = process.argv[1] ? (0, external_node_path_.resolve)(process.argv[1]) : (0, external_node_path_.join)(process.cwd(), 'midscene-cli.js');
3061
+ return (0, external_node_module_namespaceObject.createRequire)(entry);
3062
+ };
3063
+ const resolvePackageFromRstestCore = (packageName)=>{
3064
+ const require1 = requireFromCliEntry();
3065
+ const rstestPackageJsonPath = require1.resolve('@rstest/core/package.json');
3066
+ return (0, external_node_module_namespaceObject.createRequire)(rstestPackageJsonPath).resolve(packageName);
3067
+ };
3068
+ function resolveRstestCoreImportPath() {
3069
+ const require1 = requireFromCliEntry();
3070
+ const packageJsonPath = require1.resolve('@rstest/core/package.json');
3071
+ return (0, external_node_path_.join)((0, external_node_path_.dirname)(packageJsonPath), 'dist', 'index.js');
3072
+ }
3073
+ const formatRunError = (error)=>error.stack || `${error.name}: ${error.message}`;
3074
+ async function runRstestYamlProject(options) {
3075
+ const [{ runRstest }, { rspack }] = await Promise.all([
3076
+ import("@rstest/core/api"),
3077
+ import((0, external_node_url_.pathToFileURL)(resolvePackageFromRstestCore('@rsbuild/core')).href)
3078
+ ]);
3079
+ const { project } = options;
3080
+ const maxConcurrency = void 0 !== project.maxConcurrency ? Math.max(1, project.maxConcurrency) : void 0;
3081
+ const inlineConfig = {
3082
+ root: project.projectDir,
3083
+ include: project.include,
3084
+ testEnvironment: 'node',
3085
+ testTimeout: project.testTimeout,
3086
+ ...void 0 !== maxConcurrency ? {
3087
+ maxConcurrency
3088
+ } : {},
3089
+ ...void 0 !== maxConcurrency ? {
3090
+ pool: {
3091
+ maxWorkers: maxConcurrency,
3092
+ minWorkers: maxConcurrency
3093
+ }
3094
+ } : {},
3095
+ ...void 0 !== project.bail ? {
3096
+ bail: project.bail
3097
+ } : {},
3098
+ reporters: [],
3099
+ tools: {
3100
+ rspack: (_config, { appendPlugins })=>{
3101
+ appendPlugins(new rspack.experiments.VirtualModulesPlugin(project.virtualModules));
3102
+ }
3103
+ }
3104
+ };
3105
+ const result = await runRstest({
3106
+ cwd: options.cwd || project.projectDir,
3107
+ inlineConfig
3108
+ });
3109
+ if (!result.ok && 'pipe' !== options.stdio && result.unhandledErrors.length) console.error(result.unhandledErrors.map((error)=>formatRunError(error)).join('\n'));
3110
+ return result.ok ? 0 : 1;
3111
+ }
3112
+ const createCaseOptions = (config)=>{
3113
+ const caseOptions = {};
3114
+ for (const file of config.files)caseOptions[(0, external_node_path_.resolve)(file)] = {
3115
+ globalConfig: config.globalConfig
3116
+ };
3117
+ return caseOptions;
3118
+ };
3119
+ const createWebRuntimeOptions = (config, runtimeOptions)=>{
3120
+ const caseOptions = {};
3121
+ for (const file of config.files)caseOptions[(0, external_node_path_.resolve)(file)] = {
3122
+ headed: runtimeOptions.headed ?? config.headed,
3123
+ keepWindow: runtimeOptions.keepWindow ?? config.keepWindow
3124
+ };
3125
+ return caseOptions;
3126
+ };
3127
+ const readProjectResults = (project)=>project.cases.map((item)=>{
3128
+ if ((0, external_node_fs_.existsSync)(item.resultFile)) return JSON.parse((0, external_node_fs_.readFileSync)(item.resultFile, 'utf8'));
3129
+ return createNotExecutedYamlResult(item.yamlFile);
3130
+ });
3131
+ async function runFrameworkTestConfig(config, commandOptions = {}) {
3132
+ printExecutionPlan(config);
3133
+ const projectDir = (0, external_node_path_.resolve)(commandOptions.projectDir || process.cwd());
3134
+ const project = createRstestYamlProject({
3135
+ files: config.files,
3136
+ projectDir,
3137
+ outputDir: commandOptions.outputDir,
3138
+ frameworkImport: commandOptions.frameworkImport,
3139
+ caseOptions: createCaseOptions(config),
3140
+ webRuntimeOptions: createWebRuntimeOptions(config, commandOptions),
3141
+ maxConcurrency: commandOptions.concurrent ?? config.concurrent,
3142
+ bail: config.continueOnError ? 0 : 1,
3143
+ batchConfig: config.shareBrowserContext ? config : void 0
3144
+ });
3145
+ const runner = commandOptions.rstestRunner || runRstestYamlProject;
3146
+ const exitCode = await runner({
3147
+ project,
3148
+ cwd: projectDir,
3149
+ stdio: commandOptions.stdio
3150
+ });
3151
+ const results = readProjectResults(project);
3152
+ const summaryPath = writeExecutionSummaryFile(config.summary, results);
3153
+ printExecutionFinished();
3154
+ const success = printExecutionSummary(results, summaryPath);
3155
+ return success ? exitCode : 1;
3156
+ }
3157
+ const core_namespaceObject = require("@rstest/core");
3158
+ var yaml_ = __webpack_require__("@midscene/core/yaml");
3159
+ const puppeteer_agent_launcher_namespaceObject = require("@midscene/web/puppeteer-agent-launcher");
3160
+ var external_lodash_merge_ = __webpack_require__("lodash.merge");
3161
+ var external_lodash_merge_default = /*#__PURE__*/ __webpack_require__.n(external_lodash_merge_);
3162
+ var p_limit = __webpack_require__("../../node_modules/.pnpm/p-limit@6.2.0/node_modules/p-limit/index.js");
3163
+ const external_puppeteer_namespaceObject = require("puppeteer");
3164
+ var external_puppeteer_default = /*#__PURE__*/ __webpack_require__.n(external_puppeteer_namespaceObject);
3165
+ const external_http_server_namespaceObject = require("http-server");
3166
+ const external_node_assert_namespaceObject = require("node:assert");
3167
+ var external_node_assert_default = /*#__PURE__*/ __webpack_require__.n(external_node_assert_namespaceObject);
3168
+ const agent_namespaceObject = require("@midscene/core/agent");
3169
+ const utils_namespaceObject = require("@midscene/core/utils");
3170
+ var logger_ = __webpack_require__("@midscene/shared/logger");
3171
+ const bridge_mode_namespaceObject = require("@midscene/web/bridge-mode");
3172
+ const debug = (0, logger_.getDebug)('create-yaml-player');
3173
+ const launchServer = async (dir)=>new Promise((resolve)=>{
3174
+ const server = (0, external_http_server_namespaceObject.createServer)({
3175
+ root: dir
3176
+ });
3177
+ server.listen(0, '127.0.0.1', ()=>{
3178
+ resolve(server);
3179
+ });
3180
+ });
3181
+ function resolveReportFileName(yamlReportFileName, cliTestId, yamlTestId, fileName) {
3182
+ const baseName = yamlReportFileName ?? cliTestId ?? yamlTestId ?? fileName;
3183
+ return (0, agent_namespaceObject.getReportFileName)(baseName);
3184
+ }
3185
+ function buildAgentOptions(yamlAgent, reportFileName, fileName) {
3186
+ return {
3187
+ ...yamlAgent || {},
3188
+ cache: (0, utils_namespaceObject.processCacheConfig)(yamlAgent?.cache, fileName),
3189
+ reportFileName
3190
+ };
3191
+ }
3192
+ async function createYamlPlayer(file, script, options) {
3193
+ const yamlScript = script || (0, yaml_.parseYamlScript)((0, external_node_fs_.readFileSync)(file, 'utf-8'), file);
3194
+ const clonedYamlScript = structuredClone(yamlScript);
3195
+ const fileName = (0, external_node_path_.basename)(file, (0, external_node_path_.extname)(file));
3196
+ const preference = {
3197
+ headed: options?.headed,
3198
+ keepWindow: options?.keepWindow,
3199
+ reportFileName: resolveReportFileName(clonedYamlScript.agent?.reportFileName, options?.testId, clonedYamlScript.agent?.testId, fileName)
3200
+ };
3201
+ const player = new yaml_.ScriptPlayer(clonedYamlScript, async ()=>{
3202
+ const freeFn = [];
3203
+ const webTarget = clonedYamlScript.web || clonedYamlScript.target;
3204
+ const targetCount = [
3205
+ void 0 !== webTarget,
3206
+ void 0 !== clonedYamlScript.android,
3207
+ void 0 !== clonedYamlScript.ios,
3208
+ void 0 !== clonedYamlScript.computer,
3209
+ void 0 !== clonedYamlScript.interface
3210
+ ].filter(Boolean).length;
3211
+ if (targetCount > 1) {
3212
+ const specifiedTargets = [
3213
+ void 0 !== webTarget ? 'web' : null,
3214
+ void 0 !== clonedYamlScript.android ? 'android' : null,
3215
+ void 0 !== clonedYamlScript.ios ? 'ios' : null,
3216
+ void 0 !== clonedYamlScript.computer ? 'computer' : null,
3217
+ void 0 !== clonedYamlScript.interface ? 'interface' : null
3218
+ ].filter(Boolean);
3219
+ throw new Error(`Only one target type can be specified, but found multiple: ${specifiedTargets.join(', ')}. Please specify only one of: web, android, ios, computer, or interface.`);
3220
+ }
3221
+ if (void 0 !== webTarget) {
3222
+ if (void 0 !== clonedYamlScript.target) console.warn("target is deprecated, please use web instead. See https://midscenejs.com/automate-with-scripts-in-yaml for more information. Sorry for the inconvenience.");
3223
+ let localServer;
3224
+ let urlToVisit;
3225
+ if (webTarget.serve) {
3226
+ external_node_assert_default()('string' == typeof webTarget.url, 'url is required in serve mode');
3227
+ localServer = await launchServer(webTarget.serve);
3228
+ const serverAddress = localServer.server.address();
3229
+ freeFn.push({
3230
+ name: 'local_server',
3231
+ fn: ()=>localServer?.server.close()
3232
+ });
3233
+ urlToVisit = webTarget.url.startsWith('/') ? `http://${serverAddress?.address}:${serverAddress?.port}${webTarget.url}` : `http://${serverAddress?.address}:${serverAddress?.port}/${webTarget.url}`;
3234
+ webTarget.url = urlToVisit;
3235
+ }
3236
+ if (webTarget.cdpEndpoint && webTarget.bridgeMode) throw new Error('cdpEndpoint and bridgeMode are mutually exclusive. Please specify only one.');
3237
+ if (webTarget.cdpEndpoint) {
3238
+ const cdpBrowser = options?.browser ?? await external_puppeteer_default().connect({
3239
+ browserWSEndpoint: webTarget.cdpEndpoint,
3240
+ defaultViewport: null
3241
+ });
3242
+ if (webTarget.chromeArgs) console.warn('chromeArgs are not supported in CDP mode (browser is already running). They will be ignored.');
3243
+ const { agent, freeFn: newFreeFn } = await (0, puppeteer_agent_launcher_namespaceObject.puppeteerAgentForTarget)(webTarget, {
3244
+ ...preference,
3245
+ ...buildAgentOptions(clonedYamlScript.agent, preference.reportFileName, fileName)
3246
+ }, cdpBrowser, options?.page);
3247
+ const cleanFreeFn = newFreeFn.filter((f)=>'puppeteer_browser' !== f.name);
3248
+ if (!options?.browser) cleanFreeFn.push({
3249
+ name: 'cdp_browser_disconnect',
3250
+ fn: ()=>cdpBrowser.disconnect()
3251
+ });
3252
+ freeFn.push(...cleanFreeFn);
3253
+ return {
3254
+ agent,
3255
+ freeFn
3256
+ };
3257
+ }
3258
+ if (!webTarget.bridgeMode) {
3259
+ const { agent, freeFn: newFreeFn } = await (0, puppeteer_agent_launcher_namespaceObject.puppeteerAgentForTarget)(webTarget, {
3260
+ ...preference,
3261
+ ...buildAgentOptions(clonedYamlScript.agent, preference.reportFileName, fileName)
3262
+ }, options?.browser, options?.page);
3263
+ freeFn.push(...newFreeFn);
3264
+ return {
3265
+ agent,
3266
+ freeFn
3267
+ };
3268
+ }
3269
+ external_node_assert_default()('newTabWithUrl' === webTarget.bridgeMode || 'currentTab' === webTarget.bridgeMode, `bridgeMode config value must be either "newTabWithUrl" or "currentTab", but got ${webTarget.bridgeMode}`);
3270
+ 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.');
3271
+ const agent = new bridge_mode_namespaceObject.AgentOverChromeBridge({
3272
+ closeNewTabsAfterDisconnect: webTarget.closeNewTabsAfterDisconnect,
3273
+ closeConflictServer: true,
3274
+ ...buildAgentOptions(clonedYamlScript.agent, preference.reportFileName, fileName)
3275
+ });
3276
+ if ('newTabWithUrl' === webTarget.bridgeMode) await agent.connectNewTabWithUrl(webTarget.url);
3277
+ else {
3278
+ if (webTarget.url) console.warn('url will be ignored in bridge mode with "currentTab"');
3279
+ await agent.connectCurrentTab();
3280
+ }
3281
+ freeFn.push({
3282
+ name: 'destroy_agent_over_chrome_bridge',
3283
+ fn: ()=>agent.destroy()
3284
+ });
3285
+ return {
3286
+ agent,
3287
+ freeFn
3288
+ };
3289
+ }
3290
+ if (void 0 !== clonedYamlScript.android) {
3291
+ const androidTarget = clonedYamlScript.android;
3292
+ const { agentFromAdbDevice } = await import("@midscene/android");
3293
+ const agent = await agentFromAdbDevice(androidTarget?.deviceId, {
3294
+ ...androidTarget,
3295
+ ...buildAgentOptions(clonedYamlScript.agent, preference.reportFileName, fileName)
3296
+ });
3297
+ if (androidTarget?.launch) await agent.launch(androidTarget.launch);
3298
+ freeFn.push({
3299
+ name: 'destroy_android_agent',
3300
+ fn: ()=>agent.destroy()
3301
+ });
3302
+ return {
3303
+ agent,
3304
+ freeFn
3305
+ };
3306
+ }
3307
+ if (void 0 !== clonedYamlScript.ios) {
3308
+ const iosTarget = clonedYamlScript.ios;
3309
+ const { agentFromWebDriverAgent } = await import("@midscene/ios");
3310
+ const agent = await agentFromWebDriverAgent({
3311
+ ...iosTarget,
3312
+ ...buildAgentOptions(clonedYamlScript.agent, preference.reportFileName, fileName)
3313
+ });
3314
+ if (iosTarget?.launch) await agent.launch(iosTarget.launch);
3315
+ freeFn.push({
3316
+ name: 'destroy_ios_agent',
3317
+ fn: ()=>agent.destroy()
3318
+ });
3319
+ return {
3320
+ agent,
3321
+ freeFn
3322
+ };
3323
+ }
3324
+ if (void 0 !== clonedYamlScript.computer) {
3325
+ const computerTarget = clonedYamlScript.computer;
3326
+ const { agentForComputer } = await import("@midscene/computer");
3327
+ const agent = await agentForComputer({
3328
+ ...computerTarget,
3329
+ ...buildAgentOptions(clonedYamlScript.agent, preference.reportFileName, fileName)
3330
+ });
3331
+ freeFn.push({
3332
+ name: 'destroy_computer_agent',
3333
+ fn: ()=>agent.destroy()
3334
+ });
3335
+ return {
3336
+ agent,
3337
+ freeFn
3338
+ };
3339
+ }
3340
+ if (void 0 !== clonedYamlScript.interface) {
3341
+ const interfaceTarget = clonedYamlScript.interface;
3342
+ const moduleSpecifier = interfaceTarget.module;
3343
+ let finalModuleSpecifier;
3344
+ if (moduleSpecifier.startsWith('./') || moduleSpecifier.startsWith('../') || external_node_path_default().isAbsolute(moduleSpecifier)) {
3345
+ const resolvedPath = (0, external_node_path_.join)(process.cwd(), moduleSpecifier);
3346
+ finalModuleSpecifier = resolvedPath;
3347
+ } else finalModuleSpecifier = moduleSpecifier;
3348
+ debug('importing module config', interfaceTarget.module, 'with export config', interfaceTarget.export, 'final module specifier', finalModuleSpecifier);
3349
+ const importedModule = await import(finalModuleSpecifier);
3350
+ const DeviceClass = interfaceTarget.export ? importedModule[interfaceTarget.export] : importedModule.default || importedModule;
3351
+ debug('DeviceClass', DeviceClass, 'with param', interfaceTarget.param);
3352
+ const device = new DeviceClass(interfaceTarget.param || {});
3353
+ debug('creating agent from device', device);
3354
+ const agent = (0, agent_namespaceObject.createAgent)(device, buildAgentOptions(clonedYamlScript.agent, preference.reportFileName, fileName));
3355
+ freeFn.push({
3356
+ name: 'destroy_general_interface_agent',
3357
+ fn: ()=>{
3358
+ agent.destroy();
3359
+ }
3360
+ });
3361
+ return {
3362
+ agent,
3363
+ freeFn
3364
+ };
3365
+ }
3366
+ throw new Error('No valid interface configuration found in the yaml script, should be either "web", "android", "ios", "computer", or "interface"');
3367
+ }, void 0, file);
3368
+ return player;
3369
+ }
3370
+ var source = __webpack_require__("../../node_modules/.pnpm/chalk@4.1.2/node_modules/chalk/source/index.js");
3371
+ var source_default = /*#__PURE__*/ __webpack_require__.n(source);
3372
+ const isTTY = process.env.MIDSCENE_CLI_LOG_ON_NON_TTY ? false : process.stdout.isTTY;
3373
+ const indent = ' ';
3374
+ const spinnerInterval = 80;
3375
+ const spinnerFrames = [
3376
+ '◰',
3377
+ '◳',
3378
+ '◲',
3379
+ '◱'
3380
+ ];
3381
+ const currentSpinningFrame = ()=>spinnerFrames[Math.floor(Date.now() / spinnerInterval) % spinnerFrames.length];
3382
+ function indicatorForStatus(status) {
3383
+ if ('init' === status) return source_default().gray('◌');
3384
+ if ('running' === status) return source_default().yellowBright(currentSpinningFrame());
3385
+ if ('done' === status) return source_default().green('✔︎');
3386
+ if ('error' === status) return source_default().red('✘');
3387
+ }
3388
+ const contextInfo = (context)=>{
3389
+ const filePath = context.file;
3390
+ const filePathToShow = (0, external_node_path_.relative)(process.cwd(), filePath);
3391
+ const fileNameToPrint = `${source_default().gray(`${filePathToShow}`)}`;
3392
+ const fileStatusText = indicatorForStatus(context.player.status);
3393
+ const contextActionText = void 0 === context.player.currentTaskIndex && 'running' === context.player.status ? source_default().gray('(navigating)') : '';
3394
+ const errorText = context.player.errorInSetup ? `\n${indent}${source_default().red('error:')} ${context.player.errorInSetup?.message}\n${indent}${indent}${context.player.errorInSetup?.stack}` : '';
3395
+ const outputFile = context.player.output;
3396
+ const outputText = outputFile && Object.keys(context.player.result || {}).length > 0 ? `\n${indent}${source_default().gray(`output: ${outputFile}`)}` : '';
3397
+ const reportFile = context.player.reportFile;
3398
+ const reportText = reportFile ? `\n${indent}${source_default().gray(`report: ${reportFile}`)}` : '';
3399
+ const agentStatusTip = context.player.agentStatusTip;
3400
+ const agentStatusText = agentStatusTip ? `\n${indent}${source_default().gray(`agent status: ${agentStatusTip}`)}` : '';
3401
+ const mergedText = `${fileStatusText} ${fileNameToPrint} ${contextActionText}${outputText}${reportText}${errorText}${agentStatusText}`.trim();
3402
+ return {
3403
+ fileNameToPrint,
3404
+ fileStatusText,
3405
+ contextActionText,
3406
+ outputText,
3407
+ reportText,
3408
+ mergedText
3409
+ };
3410
+ };
3411
+ const singleTaskInfo = (task)=>{
3412
+ let stepText = '';
3413
+ if ('init' === task.status) stepText = '';
3414
+ else if ('running' === task.status || 'error' === task.status) if (void 0 === task.currentStep) stepText = source_default().gray('(navigating)');
3415
+ else if ('number' == typeof task.currentStep) {
3416
+ const actionText = '';
3417
+ stepText = source_default().gray(`(task ${task.currentStep + 1}/${task.totalSteps}${actionText})`.trim());
3418
+ } else stepText = source_default().gray('(unknown task)');
3419
+ const errorText = 'error' === task.status ? `\n${indent}${source_default().gray('error:')}\n${indent}${indent}${task.error?.message}` : '';
3420
+ const statusText = indicatorForStatus(task.status);
3421
+ const mergedLine = `${statusText} ${task.name} ${stepText}${errorText}`;
3422
+ return {
3423
+ nameText: task.name,
3424
+ stepText,
3425
+ errorText,
3426
+ itemStatusText: statusText,
3427
+ mergedLine
3428
+ };
3429
+ };
3430
+ function paddingLines(lines) {
3431
+ return lines.map((line)=>`${indent}${line}`);
3432
+ }
3433
+ const contextTaskListSummary = (taskStatusArray, context)=>{
3434
+ const prefixLines = [];
3435
+ const currentLine = [];
3436
+ const suffixText = [];
3437
+ const { mergedText: fileInfo } = contextInfo(context);
3438
+ if (!context.player.errorInSetup) for (const task of taskStatusArray){
3439
+ const { mergedLine } = singleTaskInfo(task);
3440
+ if ('init' === context.player.status) suffixText.push(mergedLine);
3441
+ else if ('running' === context.player.status) currentLine.push(mergedLine);
3442
+ else if ('done' === context.player.status) prefixLines.push(mergedLine);
3443
+ else if ('error' === context.player.status) prefixLines.push(mergedLine);
3444
+ }
3445
+ const lines = [
3446
+ fileInfo
3447
+ ];
3448
+ if (prefixLines.length > 0) lines.push(...paddingLines(prefixLines));
3449
+ if (currentLine.length > 0) lines.push(...paddingLines(currentLine));
3450
+ if (suffixText.length > 0) lines.push(...paddingLines(suffixText));
3451
+ return lines.join('\n');
3452
+ };
3453
+ const external_node_util_namespaceObject = require("node:util");
3454
+ var restore_cursor = __webpack_require__("../../node_modules/.pnpm/restore-cursor@5.1.0/node_modules/restore-cursor/index.js");
3455
+ function _define_property(obj, key, value) {
3456
+ if (key in obj) Object.defineProperty(obj, key, {
3457
+ value: value,
3458
+ enumerable: true,
3459
+ configurable: true,
3460
+ writable: true
3461
+ });
3462
+ else obj[key] = value;
3463
+ return obj;
3464
+ }
3465
+ const DEFAULT_RENDER_INTERVAL = 160;
3466
+ const ESC = '\x1B[';
3467
+ const CLEAR_LINE = `${ESC}K`;
3468
+ const MOVE_CURSOR_ONE_ROW_UP = `${ESC}1A`;
3469
+ const HIDE_CURSOR = `${ESC}?25l`;
3470
+ const SHOW_CURSOR = `${ESC}?25h`;
3471
+ const SYNC_START = `${ESC}?2026h`;
3472
+ const SYNC_END = `${ESC}?2026l`;
3473
+ class TTYWindowRenderer {
3474
+ start() {
3475
+ this.finished = false;
3476
+ this.renderInterval = setInterval(()=>this.flushBuffer(), this.options.interval);
3477
+ }
3478
+ stop() {
3479
+ this.flushBuffer();
3480
+ this.write(SHOW_CURSOR, 'output');
3481
+ this.cleanups.splice(0).map((fn)=>fn());
3482
+ clearInterval(this.renderInterval);
3483
+ }
3484
+ finish() {
3485
+ this.finished = true;
3486
+ this.flushBuffer();
3487
+ clearInterval(this.renderInterval);
3488
+ }
3489
+ flushBuffer() {
3490
+ if (0 === this.buffer.length) return this.render();
3491
+ let current;
3492
+ for (const next of this.buffer.splice(0)){
3493
+ if (!current) {
3494
+ current = next;
3495
+ continue;
3496
+ }
3497
+ if (current.type !== next.type) {
3498
+ this.render(current.message, current.type);
3499
+ current = next;
3500
+ continue;
3501
+ }
3502
+ current.message += next.message;
3503
+ }
3504
+ if (current) this.render(current?.message, current?.type);
3505
+ }
3506
+ render(message, type = 'output') {
3507
+ if (this.finished) {
3508
+ this.clearWindow();
3509
+ return this.write(message || '', type);
3510
+ }
3511
+ const windowContent = this.options.getWindow();
3512
+ const rowCount = getRenderedRowCount(windowContent, this.options.outputStream);
3513
+ let padding = this.windowHeight - rowCount;
3514
+ if (padding > 0 && message) padding -= getRenderedRowCount([
3515
+ message
3516
+ ], this.options.outputStream);
3517
+ this.write(SYNC_START);
3518
+ this.clearWindow();
3519
+ if (message) this.write(message, type);
3520
+ if (padding > 0) this.write('\n'.repeat(padding));
3521
+ this.write(windowContent.join('\n'));
3522
+ this.write(SYNC_END);
3523
+ this.windowHeight = rowCount + Math.max(0, padding);
3524
+ }
3525
+ clearWindow() {
3526
+ if (0 === this.windowHeight) return;
3527
+ this.write(CLEAR_LINE);
3528
+ for(let i = 1; i < this.windowHeight; i++)this.write(`${MOVE_CURSOR_ONE_ROW_UP}${CLEAR_LINE}`);
3529
+ this.windowHeight = 0;
3530
+ }
3531
+ interceptStream(stream, type) {
3532
+ const original = stream.write;
3533
+ stream.write = (chunk, _, callback)=>{
3534
+ if (chunk) if (this.finished) this.write(chunk.toString(), type);
3535
+ else this.buffer.push({
3536
+ type,
3537
+ message: chunk.toString()
3538
+ });
3539
+ callback?.();
3540
+ };
3541
+ return function() {
3542
+ stream.write = original;
3543
+ };
3544
+ }
3545
+ write(message, type = 'output') {
3546
+ this.streams[type](message);
3547
+ }
3548
+ constructor(options){
3549
+ _define_property(this, "options", void 0);
3550
+ _define_property(this, "streams", void 0);
3551
+ _define_property(this, "buffer", []);
3552
+ _define_property(this, "renderInterval", void 0);
3553
+ _define_property(this, "windowHeight", 0);
3554
+ _define_property(this, "finished", false);
3555
+ _define_property(this, "cleanups", []);
3556
+ this.options = {
3557
+ interval: DEFAULT_RENDER_INTERVAL,
3558
+ ...options
3559
+ };
3560
+ this.streams = {
3561
+ output: options.outputStream.write.bind(options.outputStream),
3562
+ error: options.errorStream.write.bind(options.errorStream)
3563
+ };
3564
+ this.cleanups.push(this.interceptStream(process.stdout, 'output'), this.interceptStream(process.stderr, 'error'));
3565
+ (0, restore_cursor.A)();
3566
+ this.write(HIDE_CURSOR, 'output');
3567
+ this.start();
3568
+ }
3569
+ }
3570
+ function getRenderedRowCount(contents, stream) {
3571
+ let count = 0;
3572
+ const columns = 'columns' in stream ? stream.columns : 80;
3573
+ for (const content of contents){
3574
+ const rows = content.split('\n');
3575
+ for (const row of rows){
3576
+ const text = (0, external_node_util_namespaceObject.stripVTControlCharacters)(row);
3577
+ count += Math.max(1, Math.ceil(text.length / columns));
3578
+ }
3579
+ }
3580
+ return count;
3581
+ }
3582
+ function yaml_batch_executor_define_property(obj, key, value) {
3583
+ if (key in obj) Object.defineProperty(obj, key, {
3584
+ value: value,
3585
+ enumerable: true,
3586
+ configurable: true,
3587
+ writable: true
3588
+ });
3589
+ else obj[key] = value;
3590
+ return obj;
3591
+ }
3592
+ class YamlBatchExecutor {
3593
+ async run(options = {}) {
3594
+ const generateSummary = options.generateSummary ?? true;
3595
+ const shouldPrintExecutionPlan = options.printExecutionPlan ?? true;
3596
+ const { keepWindow, headed } = this.config;
3597
+ if (shouldPrintExecutionPlan) printExecutionPlan(this.config);
3598
+ const fileContextList = [];
3599
+ let browser = null;
3600
+ let sharedPage = null;
3601
+ try {
3602
+ for (const file of this.config.files){
3603
+ const fileConfig = await this.loadFileConfig(file);
3604
+ const context = await this.createFileContext(file, fileConfig, {
3605
+ headed,
3606
+ keepWindow
3607
+ });
3608
+ fileContextList.push(context);
3609
+ }
3610
+ const needsBrowser = fileContextList.some((ctx)=>Object.keys(ctx.executionConfig.web || ctx.executionConfig.target || {}).length > 0);
3611
+ if (needsBrowser && this.config.shareBrowserContext) {
3612
+ const globalWebConfig = this.config.globalConfig?.web;
3613
+ if (globalWebConfig?.cdpEndpoint) browser = await external_puppeteer_default().connect({
3614
+ browserWSEndpoint: globalWebConfig.cdpEndpoint,
3615
+ defaultViewport: null
3616
+ });
3617
+ else {
3618
+ const width = globalWebConfig?.viewportWidth ?? puppeteer_agent_launcher_namespaceObject.defaultViewportWidth;
3619
+ const height = globalWebConfig?.viewportHeight ?? puppeteer_agent_launcher_namespaceObject.defaultViewportHeight;
3620
+ const args = (0, puppeteer_agent_launcher_namespaceObject.buildChromeArgs)({
3621
+ userAgent: globalWebConfig?.userAgent,
3622
+ windowSize: headed ? {
3623
+ width,
3624
+ height
3625
+ } : void 0,
3626
+ chromeArgs: globalWebConfig?.chromeArgs
3627
+ });
3628
+ browser = await external_puppeteer_default().launch({
3629
+ headless: !headed,
3630
+ defaultViewport: headed ? null : {
3631
+ width,
3632
+ height
3633
+ },
3634
+ args,
3635
+ acceptInsecureCerts: globalWebConfig?.acceptInsecureCerts
3636
+ });
3637
+ }
3638
+ sharedPage = await browser.newPage();
3639
+ for (const context of fileContextList){
3640
+ context.options.browser = browser;
3641
+ context.options.page = sharedPage;
3642
+ }
3643
+ }
3644
+ const { executedResults, notExecutedContexts } = await this.executeFiles(fileContextList);
3645
+ this.results = await this.processResults(executedResults, notExecutedContexts);
3646
+ } finally{
3647
+ if (browser && !this.config.keepWindow) {
3648
+ const isCdp = !!this.config.globalConfig?.web?.cdpEndpoint;
3649
+ if (isCdp) browser.disconnect();
3650
+ else await browser.close();
3651
+ }
3652
+ if (generateSummary) await this.generateOutputIndex();
3653
+ }
3654
+ return this.results;
3655
+ }
3656
+ async createFileContext(file, fileConfig, options) {
3657
+ const { globalConfig } = this.config;
3658
+ const clonedFileConfig = JSON.parse(JSON.stringify(fileConfig));
3659
+ if (clonedFileConfig.target) {
3660
+ clonedFileConfig.web = {
3661
+ ...clonedFileConfig.target,
3662
+ ...clonedFileConfig.web
3663
+ };
3664
+ delete clonedFileConfig.target;
3665
+ }
3666
+ if (globalConfig?.target) {
3667
+ globalConfig.web = {
3668
+ ...globalConfig.target,
3669
+ ...globalConfig.web
3670
+ };
3671
+ delete globalConfig.target;
3672
+ }
3673
+ const executionConfig = external_lodash_merge_default()(clonedFileConfig, globalConfig);
3674
+ return {
3675
+ file,
3676
+ executionConfig,
3677
+ options
3678
+ };
3679
+ }
3680
+ async executeFiles(fileContextList) {
3681
+ const executedResults = [];
3682
+ const notExecutedContexts = [];
3683
+ const allFileContexts = [];
3684
+ for (const context of fileContextList){
3685
+ const player = await createYamlPlayer(context.file, context.executionConfig, context.options);
3686
+ allFileContexts.push({
3687
+ file: context.file,
3688
+ player
3689
+ });
3690
+ }
3691
+ let ttyRenderer;
3692
+ if (isTTY) {
3693
+ const summaryContents = ()=>{
3694
+ const summary = [
3695
+ ''
3696
+ ];
3697
+ for (const context of allFileContexts)summary.push(contextTaskListSummary(context.player.taskStatusList, context));
3698
+ summary.push('');
3699
+ return summary;
3700
+ };
3701
+ ttyRenderer = new TTYWindowRenderer({
3702
+ outputStream: process.stdout,
3703
+ errorStream: process.stderr,
3704
+ getWindow: summaryContents,
3705
+ interval: spinnerInterval
3706
+ });
3707
+ ttyRenderer.start();
3708
+ }
3709
+ try {
3710
+ const executeFile = async (context)=>{
3711
+ const allFileContext = allFileContexts.find((c)=>c.file === context.file);
3712
+ if (!allFileContext) throw new Error(`Player not found for file: ${context.file}`);
3713
+ if (!isTTY) {
3714
+ const { mergedText } = contextInfo(allFileContext);
3715
+ console.log(mergedText);
3716
+ }
3717
+ if (context.outputPath) allFileContext.player.output = context.outputPath;
3718
+ const startTime = Date.now();
3719
+ await allFileContext.player.run();
3720
+ const endTime = Date.now();
3721
+ const duration = endTime - startTime;
3722
+ const executedContext = {
3723
+ file: context.file,
3724
+ player: allFileContext.player,
3725
+ duration
3726
+ };
3727
+ if (!isTTY) console.log(contextTaskListSummary(allFileContext.player.taskStatusList, executedContext));
3728
+ return executedContext;
3729
+ };
3730
+ await this.executeConcurrently(fileContextList, executeFile, executedResults, notExecutedContexts);
3731
+ if (!isTTY) {
3732
+ console.log('\n📋 Execution Results:');
3733
+ for (const context of executedResults)console.log(contextTaskListSummary(context.player.taskStatusList, context));
3734
+ }
3735
+ } finally{
3736
+ if (ttyRenderer) ttyRenderer.stop();
3737
+ }
3738
+ return {
3739
+ executedResults,
3740
+ notExecutedContexts
3741
+ };
3742
+ }
3743
+ async executeConcurrently(fileContextList, executeFile, executedResults, notExecutedContexts) {
3744
+ const limit = (0, p_limit.A)(this.config.concurrent);
3745
+ if (this.config.continueOnError) {
3746
+ const tasks = fileContextList.map((context)=>limit(async ()=>{
3747
+ const executedContext = await executeFile(context);
3748
+ executedResults.push(executedContext);
3749
+ }));
3750
+ await Promise.allSettled(tasks);
3751
+ } else {
3752
+ let shouldStop = false;
3753
+ const stopLock = {
3754
+ value: false
3755
+ };
3756
+ const tasks = fileContextList.map((context)=>limit(async ()=>{
3757
+ if (stopLock.value) return void notExecutedContexts.push({
3758
+ file: context.file,
3759
+ player: null
3760
+ });
3761
+ const executedContext = await executeFile(context);
3762
+ executedResults.push(executedContext);
3763
+ if ('error' === executedContext.player.status && !stopLock.value) {
3764
+ stopLock.value = true;
3765
+ shouldStop = true;
3766
+ }
3767
+ }));
3768
+ await Promise.allSettled(tasks);
3769
+ if (shouldStop) {
3770
+ for (const context of fileContextList)if (!executedResults.some((r)=>r.file === context.file) && !notExecutedContexts.some((ctx)=>ctx.file === context.file)) notExecutedContexts.push({
3771
+ file: context.file,
3772
+ player: null
3773
+ });
3774
+ }
3775
+ }
3776
+ }
3777
+ async processResults(executedContexts, notExecutedContexts) {
3778
+ const results = [];
3779
+ for (const context of executedContexts){
3780
+ const { file, player, duration } = context;
3781
+ results.push(createExecutedYamlResult({
3782
+ file,
3783
+ player,
3784
+ duration
3785
+ }));
3786
+ }
3787
+ for (const context of notExecutedContexts)results.push(createNotExecutedYamlResult(context.file));
3788
+ return results;
3789
+ }
3790
+ async loadFileConfig(file) {
3791
+ const content = (0, external_node_fs_.readFileSync)(file, 'utf8');
3792
+ return (0, yaml_.parseYamlScript)(content, file);
3793
+ }
3794
+ async generateOutputIndex() {
3795
+ try {
3796
+ writeExecutionSummaryFile(this.config.summary, this.results);
3797
+ printExecutionFinished();
3798
+ } catch (error) {
3799
+ console.error('Failed to generate output index:', error);
3800
+ }
3801
+ }
3802
+ constructor(config){
3803
+ yaml_batch_executor_define_property(this, "config", void 0);
3804
+ yaml_batch_executor_define_property(this, "results", []);
3805
+ this.config = config;
3806
+ }
3807
+ }
3808
+ async function runYamlBatch(config, options = {}) {
3809
+ return new YamlBatchExecutor(config).run(options);
3810
+ }
3811
+ const writeResultFile = (resultFile, data)=>{
3812
+ (0, external_node_fs_.mkdirSync)((0, external_node_path_.dirname)(resultFile), {
3813
+ recursive: true
3814
+ });
3815
+ (0, external_node_fs_.writeFileSync)(resultFile, JSON.stringify(data, null, 2));
3816
+ };
3817
+ const batchFailureMessage = (results)=>{
3818
+ const failed = results.filter((result)=>!result.success);
3819
+ return failed.map((result)=>`${result.file}: ${result.error || result.resultType}`).join('\n');
3820
+ };
3821
+ async function runYamlBatchInRstest(options) {
3822
+ const results = await runYamlBatch(options.config, {
3823
+ generateSummary: false,
3824
+ printExecutionPlan: false
3825
+ });
3826
+ for (const result of results){
3827
+ const resultFile = options.resultFiles[result.file] || options.resultFiles[(0, external_node_path_.resolve)(result.file)];
3828
+ if (resultFile) writeResultFile(resultFile, result);
3829
+ }
3830
+ if (results.some((result)=>!result.success)) throw new Error(batchFailureMessage(results));
3831
+ return results;
3832
+ }
3833
+ const taskErrorMessage = (task)=>{
3834
+ if (task.error?.message) return task.error.message;
3835
+ if ('error' === task.status) return `Task "${task.name}" failed`;
3836
+ };
3837
+ const cloneJson = (value)=>JSON.parse(JSON.stringify(value));
3838
+ const normalizeTargetConfig = (config)=>{
3839
+ if (config.target) {
3840
+ config.web = {
3841
+ ...config.target,
3842
+ ...config.web
3843
+ };
3844
+ config.target = void 0;
3845
+ }
3846
+ };
3847
+ const createExecutionConfig = (file, globalConfig)=>{
3848
+ const content = (0, external_node_fs_.readFileSync)(file, 'utf8');
3849
+ const fileConfig = cloneJson((0, yaml_.parseYamlScript)(content, file));
3850
+ normalizeTargetConfig(fileConfig);
3851
+ const clonedGlobalConfig = cloneJson(globalConfig);
3852
+ normalizeTargetConfig(clonedGlobalConfig);
3853
+ return external_lodash_merge_default()(fileConfig, clonedGlobalConfig);
3854
+ };
3855
+ const getYamlPlayerFailure = (player)=>{
3856
+ if (player.errorInSetup) return player.errorInSetup;
3857
+ const failedMessages = player.taskStatusList?.map(taskErrorMessage).filter(Boolean) || [];
3858
+ if ('error' === player.status || failedMessages.length > 0) {
3859
+ const details = failedMessages.length ? failedMessages.join('; ') : 'YAML case failed';
3860
+ const reportLine = player.reportFile ? `\nReport: ${player.reportFile}` : '';
3861
+ const outputLine = player.output ? `\nOutput: ${player.output}` : '';
3862
+ return new Error(`${details}${reportLine}${outputLine}`);
3863
+ }
3864
+ };
3865
+ const createYamlCaseResult = (file, player, duration)=>{
3866
+ const hasFailedTasks = player.taskStatusList?.some((task)=>'error' === task.status) ?? false;
3867
+ const hasPlayerError = 'error' === player.status;
3868
+ const outputPath = player.output && (0, external_node_fs_.existsSync)(player.output) ? player.output : void 0;
3869
+ const reportFile = player.reportFile || void 0;
3870
+ let errorMessage;
3871
+ if (player.errorInSetup?.message) errorMessage = player.errorInSetup.message;
3872
+ else if (hasPlayerError || hasFailedTasks) {
3873
+ const taskErrors = player.taskStatusList?.filter((task)=>'error' === task.status && task.error?.message).map((task)=>task.error.message);
3874
+ errorMessage = taskErrors && taskErrors.length > 0 ? taskErrors.join('; ') : hasPlayerError ? 'Execution failed' : 'Some tasks failed';
3875
+ }
3876
+ const resultType = hasPlayerError ? 'failed' : hasFailedTasks ? 'partialFailed' : 'success';
3877
+ return {
3878
+ file,
3879
+ success: 'success' === resultType,
3880
+ executed: true,
3881
+ output: outputPath,
3882
+ report: reportFile,
3883
+ duration,
3884
+ resultType,
3885
+ error: errorMessage
3886
+ };
3887
+ };
3888
+ const createYamlCaseFailure = (result)=>{
3889
+ const reportLine = result.report ? `\nReport: ${result.report}` : '';
3890
+ const outputLine = result.output ? `\nOutput: ${result.output}` : '';
3891
+ return new Error(`${result.error || 'YAML case failed'}${reportLine}${outputLine}`);
3892
+ };
3893
+ async function runYamlCaseResult(options) {
3894
+ const file = (0, external_node_path_.resolve)(options.file);
3895
+ const startTime = Date.now();
3896
+ const executionConfig = options.executionConfig || (options.globalConfig ? createExecutionConfig(file, options.globalConfig) : void 0);
3897
+ const player = await createYamlPlayer(file, executionConfig, {
3898
+ headed: options.headed,
3899
+ keepWindow: options.keepWindow
3900
+ });
3901
+ await player.run();
3902
+ return createYamlCaseResult(file, player, Date.now() - startTime);
3903
+ }
3904
+ async function runYamlCase(options) {
3905
+ const result = await runYamlCaseResult(options);
3906
+ if (!result.success) throw createYamlCaseFailure(result);
3907
+ return {
3908
+ file: result.file,
3909
+ output: result.output || void 0,
3910
+ report: result.report,
3911
+ duration: result.duration || 0
3912
+ };
3913
+ }
3914
+ const errorMessageOf = (error)=>error instanceof Error ? error.message : String(error);
3915
+ const rstest_entry_writeResultFile = (resultFile, data)=>{
3916
+ (0, external_node_fs_.mkdirSync)((0, external_node_path_.dirname)(resultFile), {
3917
+ recursive: true
3918
+ });
3919
+ (0, external_node_fs_.writeFileSync)(resultFile, JSON.stringify(data, null, 2));
3920
+ };
3921
+ const createRuntimeFailureResult = (file, startTime, error)=>({
3922
+ file,
3923
+ success: false,
3924
+ executed: true,
3925
+ duration: Date.now() - startTime,
3926
+ resultType: 'failed',
3927
+ error: errorMessageOf(error)
3928
+ });
3929
+ function defineYamlCaseTest(options) {
3930
+ (0, core_namespaceObject.test)(options.testName, async ()=>{
3931
+ const file = (0, external_node_path_.resolve)(options.yamlFile);
3932
+ const startTime = Date.now();
3933
+ let result;
3934
+ try {
3935
+ result = await runYamlCaseResult({
3936
+ ...options.caseOptions,
3937
+ ...options.webRuntimeOptions,
3938
+ file
3939
+ });
3940
+ rstest_entry_writeResultFile(options.resultFile, result);
3941
+ if (!result.success && 'partialFailed' !== result.resultType) throw createYamlCaseFailure(result);
3942
+ } catch (error) {
3943
+ if (!result) rstest_entry_writeResultFile(options.resultFile, createRuntimeFailureResult(file, startTime, error));
3944
+ throw error;
3945
+ }
3946
+ });
3947
+ }
3948
+ function defineYamlBatchTest(options) {
3949
+ (0, core_namespaceObject.test)(options.testName, async ()=>{
3950
+ await runYamlBatchInRstest({
3951
+ config: options.config,
3952
+ resultFiles: options.resultFiles
3953
+ });
3954
+ });
3955
+ }
3956
+ })();
3957
+ exports.createRstestYamlProject = __webpack_exports__.createRstestYamlProject;
3958
+ exports.createYamlCaseFailure = __webpack_exports__.createYamlCaseFailure;
3959
+ exports.createYamlCaseResult = __webpack_exports__.createYamlCaseResult;
3960
+ exports.defineYamlBatchTest = __webpack_exports__.defineYamlBatchTest;
3961
+ exports.defineYamlCaseTest = __webpack_exports__.defineYamlCaseTest;
3962
+ exports.getYamlPlayerFailure = __webpack_exports__.getYamlPlayerFailure;
3963
+ exports.resolveRstestCoreImportPath = __webpack_exports__.resolveRstestCoreImportPath;
3964
+ exports.resolveTestName = __webpack_exports__.resolveTestName;
3965
+ exports.runFrameworkTestConfig = __webpack_exports__.runFrameworkTestConfig;
3966
+ exports.runRstestYamlProject = __webpack_exports__.runRstestYamlProject;
3967
+ exports.runYamlBatchInRstest = __webpack_exports__.runYamlBatchInRstest;
3968
+ exports.runYamlCase = __webpack_exports__.runYamlCase;
3969
+ exports.runYamlCaseResult = __webpack_exports__.runYamlCaseResult;
3970
+ for(var __rspack_i in __webpack_exports__)if (-1 === [
3971
+ "createRstestYamlProject",
3972
+ "createYamlCaseFailure",
3973
+ "createYamlCaseResult",
3974
+ "defineYamlBatchTest",
3975
+ "defineYamlCaseTest",
3976
+ "getYamlPlayerFailure",
3977
+ "resolveRstestCoreImportPath",
3978
+ "resolveTestName",
3979
+ "runFrameworkTestConfig",
3980
+ "runRstestYamlProject",
3981
+ "runYamlBatchInRstest",
3982
+ "runYamlCase",
3983
+ "runYamlCaseResult"
3984
+ ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
3985
+ Object.defineProperty(exports, '__esModule', {
3986
+ value: true
3987
+ });
3988
+
3989
+ //# sourceMappingURL=index.js.map