vitest 0.29.8 → 0.30.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.
Files changed (56) hide show
  1. package/LICENSE.md +2 -81
  2. package/dist/browser.d.ts +5 -3
  3. package/dist/browser.js +5 -6
  4. package/dist/child.js +12 -16
  5. package/dist/{chunk-api-setup.3aabe9ac.js → chunk-api-setup.6662587e.js} +53 -48
  6. package/dist/{chunk-install-pkg.6aa7cf6d.js → chunk-install-pkg.6450b372.js} +32 -32
  7. package/dist/chunk-integrations-globals.d419838f.js +26 -0
  8. package/dist/{chunk-node-git.ed5bded8.js → chunk-node-git.4c43bd73.js} +4 -2
  9. package/dist/cli-wrapper.js +6 -5
  10. package/dist/cli.js +26 -26
  11. package/dist/config.cjs +15 -2
  12. package/dist/config.d.ts +15 -4
  13. package/dist/config.js +10 -1
  14. package/dist/coverage.d.ts +5 -2
  15. package/dist/coverage.js +6 -0
  16. package/dist/entry.js +34 -34
  17. package/dist/environments.d.ts +5 -2
  18. package/dist/environments.js +1 -1
  19. package/dist/index.d.ts +11 -10
  20. package/dist/index.js +9 -11
  21. package/dist/loader.js +396 -13
  22. package/dist/node.d.ts +9 -7
  23. package/dist/node.js +27 -30
  24. package/dist/runners.d.ts +5 -2
  25. package/dist/runners.js +34 -31
  26. package/dist/{types-94cfe4b4.d.ts → types-f03c83c4.d.ts} +225 -306
  27. package/dist/{chunk-node-pkg.30d8b37e.js → vendor-cli-api.c04eaa34.js} +3845 -3326
  28. package/dist/vendor-constants.538d9b49.js +54 -0
  29. package/dist/{chunk-runtime-mocker.3283818a.js → vendor-execute.8eaab47b.js} +9 -12
  30. package/dist/{chunk-utils-base.b5ddfcc9.js → vendor-index.4f82d248.js} +80 -10
  31. package/dist/{chunk-env-node.affdd278.js → vendor-index.75f2b63d.js} +9 -2
  32. package/dist/{chunk-integrations-utils.23c19408.js → vendor-index.81b9e499.js} +22 -21
  33. package/dist/{vendor-index.2cbcdd1e.js → vendor-index.c1e09929.js} +458 -373
  34. package/dist/vendor-index.fad2598b.js +44 -0
  35. package/dist/{vendor-index.534e612c.js → vendor-index.fc98d30f.js} +2 -2
  36. package/dist/{chunk-runtime-inspector.b1427a10.js → vendor-inspector.47fc8cbb.js} +5 -2
  37. package/dist/{chunk-runtime-rpc.d6aa57f8.js → vendor-rpc.4d3d7a54.js} +5 -5
  38. package/dist/{chunk-integrations-run-once.ea614f17.js → vendor-run-once.69ce7172.js} +3 -3
  39. package/dist/{chunk-runtime-setup.5d504677.js → vendor-setup.common.cef38f4e.js} +2 -2
  40. package/dist/vendor-tasks.042d6084.js +14 -0
  41. package/dist/{chunk-utils-import.e488ace3.js → vendor-vi.a3ff54b1.js} +73 -2957
  42. package/dist/worker.js +13 -18
  43. package/package.json +29 -34
  44. package/dist/chunk-constants.bc18a549.js +0 -36
  45. package/dist/chunk-integrations-globals.49802775.js +0 -28
  46. package/dist/chunk-snapshot-env.a347d647.js +0 -11
  47. package/dist/chunk-utils-env.6b856dbf.js +0 -64
  48. package/dist/chunk-utils-tasks.8781fd71.js +0 -107
  49. package/dist/env-afee91f0.d.ts +0 -10
  50. package/dist/vendor-index.783e7f3e.js +0 -71
  51. package/dist/vendor-index.bdee400f.js +0 -396
  52. package/dist/vendor-magic-string.es.b3bc5745.js +0 -1591
  53. /package/dist/{vendor-_commonjsHelpers.addc3445.js → vendor-_commonjsHelpers.76cdd49e.js} +0 -0
  54. /package/dist/{chunk-integrations-coverage.d93ee824.js → vendor-coverage.a585b712.js} +0 -0
  55. /package/dist/{chunk-utils-global.fd174983.js → vendor-global.6795f91f.js} +0 -0
  56. /package/dist/{chunk-paths.e36446b4.js → vendor-paths.84fc7a99.js} +0 -0
@@ -1,17 +1,13 @@
1
- import { getCurrentSuite } from '@vitest/runner';
1
+ import { getCurrentSuite, getCurrentTest } from '@vitest/runner';
2
2
  import { createChainable, getNames } from '@vitest/runner/utils';
3
- import { getSafeTimers, noop, createSimpleStackTrace } from '@vitest/utils';
4
- import { i as isRunningInBenchmark, g as getCallLastIndex, r as resetModules } from './chunk-utils-env.6b856dbf.js';
3
+ import { getSafeTimers, noop, createSimpleStackTrace, parseSingleStack } from '@vitest/utils';
4
+ import { d as isRunningInBenchmark, c as resetModules } from './vendor-index.fad2598b.js';
5
5
  import * as chai$1 from 'chai';
6
- import { expect } from 'chai';
7
- import { c as commonjsGlobal } from './vendor-_commonjsHelpers.addc3445.js';
6
+ import { c as commonjsGlobal } from './vendor-_commonjsHelpers.76cdd49e.js';
8
7
  import { equals, iterableEquality, subsetEquality, JestExtend, JestChaiExpect, JestAsymmetricMatchers, GLOBAL_EXPECT, getState, setState } from '@vitest/expect';
9
- import { r as rpc } from './chunk-runtime-rpc.d6aa57f8.js';
10
- import { join, dirname } from 'pathe';
11
- import { g as getSnapshotEnvironment } from './chunk-snapshot-env.a347d647.js';
12
- import { i as isObject } from './chunk-utils-base.b5ddfcc9.js';
13
- import { p as positionToOffset, o as offsetToLineNumber, l as lineSplitRE, a as parseErrorStacktrace, g as getFullName, b as parseSingleStack } from './chunk-utils-tasks.8781fd71.js';
14
- import { g as getWorkerState, a as getCurrentEnvironment } from './chunk-utils-global.fd174983.js';
8
+ import { SnapshotClient, stripSnapshotIndentation, addSerializer } from '@vitest/snapshot';
9
+ import { g as getWorkerState, a as getCurrentEnvironment } from './vendor-global.6795f91f.js';
10
+ import { g as getFullName } from './vendor-tasks.042d6084.js';
15
11
  import require$$0 from 'util';
16
12
  import { spyOn, fn, isMockFunction, spies } from '@vitest/spy';
17
13
 
@@ -155,2953 +151,38 @@ var chaiSubset = {exports: {}};
155
151
 
156
152
  var Subset = chaiSubset.exports;
157
153
 
158
- var naturalCompare$1 = {exports: {}};
159
-
160
- /*
161
- * @version 1.4.0
162
- * @date 2015-10-26
163
- * @stability 3 - Stable
164
- * @author Lauri Rooden (https://github.com/litejs/natural-compare-lite)
165
- * @license MIT License
166
- */
167
-
168
-
169
- var naturalCompare = function(a, b) {
170
- var i, codeA
171
- , codeB = 1
172
- , posA = 0
173
- , posB = 0
174
- , alphabet = String.alphabet;
175
-
176
- function getCode(str, pos, code) {
177
- if (code) {
178
- for (i = pos; code = getCode(str, i), code < 76 && code > 65;) ++i;
179
- return +str.slice(pos - 1, i)
180
- }
181
- code = alphabet && alphabet.indexOf(str.charAt(pos));
182
- return code > -1 ? code + 76 : ((code = str.charCodeAt(pos) || 0), code < 45 || code > 127) ? code
183
- : code < 46 ? 65 // -
184
- : code < 48 ? code - 1
185
- : code < 58 ? code + 18 // 0-9
186
- : code < 65 ? code - 11
187
- : code < 91 ? code + 11 // A-Z
188
- : code < 97 ? code - 37
189
- : code < 123 ? code + 5 // a-z
190
- : code - 63
191
- }
192
-
193
-
194
- if ((a+="") != (b+="")) for (;codeB;) {
195
- codeA = getCode(a, posA++);
196
- codeB = getCode(b, posB++);
197
-
198
- if (codeA < 76 && codeB < 76 && codeA > 66 && codeB > 66) {
199
- codeA = getCode(a, posA, posA);
200
- codeB = getCode(b, posB, posA = i);
201
- posB = i;
202
- }
203
-
204
- if (codeA != codeB) return (codeA < codeB) ? -1 : 1
205
- }
206
- return 0
207
- };
208
-
209
- try {
210
- naturalCompare$1.exports = naturalCompare;
211
- } catch (e) {
212
- String.naturalCompare = naturalCompare;
213
- }
214
-
215
- var build = {};
216
-
217
- var ansiStyles = {exports: {}};
218
-
219
- (function (module) {
220
-
221
- const ANSI_BACKGROUND_OFFSET = 10;
222
-
223
- const wrapAnsi256 = (offset = 0) => code => `\u001B[${38 + offset};5;${code}m`;
224
-
225
- const wrapAnsi16m = (offset = 0) => (red, green, blue) => `\u001B[${38 + offset};2;${red};${green};${blue}m`;
226
-
227
- function assembleStyles() {
228
- const codes = new Map();
229
- const styles = {
230
- modifier: {
231
- reset: [0, 0],
232
- // 21 isn't widely supported and 22 does the same thing
233
- bold: [1, 22],
234
- dim: [2, 22],
235
- italic: [3, 23],
236
- underline: [4, 24],
237
- overline: [53, 55],
238
- inverse: [7, 27],
239
- hidden: [8, 28],
240
- strikethrough: [9, 29]
241
- },
242
- color: {
243
- black: [30, 39],
244
- red: [31, 39],
245
- green: [32, 39],
246
- yellow: [33, 39],
247
- blue: [34, 39],
248
- magenta: [35, 39],
249
- cyan: [36, 39],
250
- white: [37, 39],
251
-
252
- // Bright color
253
- blackBright: [90, 39],
254
- redBright: [91, 39],
255
- greenBright: [92, 39],
256
- yellowBright: [93, 39],
257
- blueBright: [94, 39],
258
- magentaBright: [95, 39],
259
- cyanBright: [96, 39],
260
- whiteBright: [97, 39]
261
- },
262
- bgColor: {
263
- bgBlack: [40, 49],
264
- bgRed: [41, 49],
265
- bgGreen: [42, 49],
266
- bgYellow: [43, 49],
267
- bgBlue: [44, 49],
268
- bgMagenta: [45, 49],
269
- bgCyan: [46, 49],
270
- bgWhite: [47, 49],
271
-
272
- // Bright color
273
- bgBlackBright: [100, 49],
274
- bgRedBright: [101, 49],
275
- bgGreenBright: [102, 49],
276
- bgYellowBright: [103, 49],
277
- bgBlueBright: [104, 49],
278
- bgMagentaBright: [105, 49],
279
- bgCyanBright: [106, 49],
280
- bgWhiteBright: [107, 49]
281
- }
282
- };
283
-
284
- // Alias bright black as gray (and grey)
285
- styles.color.gray = styles.color.blackBright;
286
- styles.bgColor.bgGray = styles.bgColor.bgBlackBright;
287
- styles.color.grey = styles.color.blackBright;
288
- styles.bgColor.bgGrey = styles.bgColor.bgBlackBright;
289
-
290
- for (const [groupName, group] of Object.entries(styles)) {
291
- for (const [styleName, style] of Object.entries(group)) {
292
- styles[styleName] = {
293
- open: `\u001B[${style[0]}m`,
294
- close: `\u001B[${style[1]}m`
295
- };
296
-
297
- group[styleName] = styles[styleName];
298
-
299
- codes.set(style[0], style[1]);
300
- }
301
-
302
- Object.defineProperty(styles, groupName, {
303
- value: group,
304
- enumerable: false
305
- });
306
- }
307
-
308
- Object.defineProperty(styles, 'codes', {
309
- value: codes,
310
- enumerable: false
311
- });
312
-
313
- styles.color.close = '\u001B[39m';
314
- styles.bgColor.close = '\u001B[49m';
315
-
316
- styles.color.ansi256 = wrapAnsi256();
317
- styles.color.ansi16m = wrapAnsi16m();
318
- styles.bgColor.ansi256 = wrapAnsi256(ANSI_BACKGROUND_OFFSET);
319
- styles.bgColor.ansi16m = wrapAnsi16m(ANSI_BACKGROUND_OFFSET);
320
-
321
- // From https://github.com/Qix-/color-convert/blob/3f0e0d4e92e235796ccb17f6e85c72094a651f49/conversions.js
322
- Object.defineProperties(styles, {
323
- rgbToAnsi256: {
324
- value: (red, green, blue) => {
325
- // We use the extended greyscale palette here, with the exception of
326
- // black and white. normal palette only has 4 greyscale shades.
327
- if (red === green && green === blue) {
328
- if (red < 8) {
329
- return 16;
330
- }
331
-
332
- if (red > 248) {
333
- return 231;
334
- }
335
-
336
- return Math.round(((red - 8) / 247) * 24) + 232;
337
- }
338
-
339
- return 16 +
340
- (36 * Math.round(red / 255 * 5)) +
341
- (6 * Math.round(green / 255 * 5)) +
342
- Math.round(blue / 255 * 5);
343
- },
344
- enumerable: false
345
- },
346
- hexToRgb: {
347
- value: hex => {
348
- const matches = /(?<colorString>[a-f\d]{6}|[a-f\d]{3})/i.exec(hex.toString(16));
349
- if (!matches) {
350
- return [0, 0, 0];
351
- }
352
-
353
- let {colorString} = matches.groups;
354
-
355
- if (colorString.length === 3) {
356
- colorString = colorString.split('').map(character => character + character).join('');
357
- }
358
-
359
- const integer = Number.parseInt(colorString, 16);
360
-
361
- return [
362
- (integer >> 16) & 0xFF,
363
- (integer >> 8) & 0xFF,
364
- integer & 0xFF
365
- ];
366
- },
367
- enumerable: false
368
- },
369
- hexToAnsi256: {
370
- value: hex => styles.rgbToAnsi256(...styles.hexToRgb(hex)),
371
- enumerable: false
372
- }
373
- });
374
-
375
- return styles;
376
- }
377
-
378
- // Make the export immutable
379
- Object.defineProperty(module, 'exports', {
380
- enumerable: true,
381
- get: assembleStyles
382
- });
383
- } (ansiStyles));
384
-
385
- var collections = {};
386
-
387
- Object.defineProperty(collections, '__esModule', {
388
- value: true
389
- });
390
- collections.printIteratorEntries = printIteratorEntries;
391
- collections.printIteratorValues = printIteratorValues;
392
- collections.printListItems = printListItems;
393
- collections.printObjectProperties = printObjectProperties;
394
-
395
- /**
396
- * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
397
- *
398
- * This source code is licensed under the MIT license found in the
399
- * LICENSE file in the root directory of this source tree.
400
- *
401
- */
402
- const getKeysOfEnumerableProperties = (object, compareKeys) => {
403
- const keys = Object.keys(object).sort(compareKeys);
404
-
405
- if (Object.getOwnPropertySymbols) {
406
- Object.getOwnPropertySymbols(object).forEach(symbol => {
407
- if (Object.getOwnPropertyDescriptor(object, symbol).enumerable) {
408
- keys.push(symbol);
409
- }
410
- });
411
- }
412
-
413
- return keys;
414
- };
415
- /**
416
- * Return entries (for example, of a map)
417
- * with spacing, indentation, and comma
418
- * without surrounding punctuation (for example, braces)
419
- */
420
-
421
- function printIteratorEntries(
422
- iterator,
423
- config,
424
- indentation,
425
- depth,
426
- refs,
427
- printer, // Too bad, so sad that separator for ECMAScript Map has been ' => '
428
- // What a distracting diff if you change a data structure to/from
429
- // ECMAScript Object or Immutable.Map/OrderedMap which use the default.
430
- separator = ': '
431
- ) {
432
- let result = '';
433
- let current = iterator.next();
434
-
435
- if (!current.done) {
436
- result += config.spacingOuter;
437
- const indentationNext = indentation + config.indent;
438
-
439
- while (!current.done) {
440
- const name = printer(
441
- current.value[0],
442
- config,
443
- indentationNext,
444
- depth,
445
- refs
446
- );
447
- const value = printer(
448
- current.value[1],
449
- config,
450
- indentationNext,
451
- depth,
452
- refs
453
- );
454
- result += indentationNext + name + separator + value;
455
- current = iterator.next();
456
-
457
- if (!current.done) {
458
- result += ',' + config.spacingInner;
459
- } else if (!config.min) {
460
- result += ',';
461
- }
462
- }
463
-
464
- result += config.spacingOuter + indentation;
465
- }
466
-
467
- return result;
468
- }
469
- /**
470
- * Return values (for example, of a set)
471
- * with spacing, indentation, and comma
472
- * without surrounding punctuation (braces or brackets)
473
- */
474
-
475
- function printIteratorValues(
476
- iterator,
477
- config,
478
- indentation,
479
- depth,
480
- refs,
481
- printer
482
- ) {
483
- let result = '';
484
- let current = iterator.next();
485
-
486
- if (!current.done) {
487
- result += config.spacingOuter;
488
- const indentationNext = indentation + config.indent;
489
-
490
- while (!current.done) {
491
- result +=
492
- indentationNext +
493
- printer(current.value, config, indentationNext, depth, refs);
494
- current = iterator.next();
495
-
496
- if (!current.done) {
497
- result += ',' + config.spacingInner;
498
- } else if (!config.min) {
499
- result += ',';
500
- }
501
- }
502
-
503
- result += config.spacingOuter + indentation;
504
- }
505
-
506
- return result;
507
- }
508
- /**
509
- * Return items (for example, of an array)
510
- * with spacing, indentation, and comma
511
- * without surrounding punctuation (for example, brackets)
512
- **/
513
-
514
- function printListItems(list, config, indentation, depth, refs, printer) {
515
- let result = '';
516
-
517
- if (list.length) {
518
- result += config.spacingOuter;
519
- const indentationNext = indentation + config.indent;
520
-
521
- for (let i = 0; i < list.length; i++) {
522
- result += indentationNext;
523
-
524
- if (i in list) {
525
- result += printer(list[i], config, indentationNext, depth, refs);
526
- }
527
-
528
- if (i < list.length - 1) {
529
- result += ',' + config.spacingInner;
530
- } else if (!config.min) {
531
- result += ',';
532
- }
533
- }
534
-
535
- result += config.spacingOuter + indentation;
536
- }
537
-
538
- return result;
539
- }
540
- /**
541
- * Return properties of an object
542
- * with spacing, indentation, and comma
543
- * without surrounding punctuation (for example, braces)
544
- */
545
-
546
- function printObjectProperties(val, config, indentation, depth, refs, printer) {
547
- let result = '';
548
- const keys = getKeysOfEnumerableProperties(val, config.compareKeys);
549
-
550
- if (keys.length) {
551
- result += config.spacingOuter;
552
- const indentationNext = indentation + config.indent;
553
-
554
- for (let i = 0; i < keys.length; i++) {
555
- const key = keys[i];
556
- const name = printer(key, config, indentationNext, depth, refs);
557
- const value = printer(val[key], config, indentationNext, depth, refs);
558
- result += indentationNext + name + ': ' + value;
559
-
560
- if (i < keys.length - 1) {
561
- result += ',' + config.spacingInner;
562
- } else if (!config.min) {
563
- result += ',';
564
- }
565
- }
566
-
567
- result += config.spacingOuter + indentation;
568
- }
569
-
570
- return result;
571
- }
572
-
573
- var AsymmetricMatcher$1 = {};
574
-
575
- Object.defineProperty(AsymmetricMatcher$1, '__esModule', {
576
- value: true
577
- });
578
- AsymmetricMatcher$1.test = AsymmetricMatcher$1.serialize = AsymmetricMatcher$1.default = void 0;
579
-
580
- var _collections$3 = collections;
581
-
582
- var global$2 = (function () {
583
- if (typeof globalThis !== 'undefined') {
584
- return globalThis;
585
- } else if (typeof global$2 !== 'undefined') {
586
- return global$2;
587
- } else if (typeof self !== 'undefined') {
588
- return self;
589
- } else if (typeof window !== 'undefined') {
590
- return window;
591
- } else {
592
- return Function('return this')();
593
- }
594
- })();
595
-
596
- var Symbol$2 = global$2['jest-symbol-do-not-touch'] || global$2.Symbol;
597
- const asymmetricMatcher =
598
- typeof Symbol$2 === 'function' && Symbol$2.for
599
- ? Symbol$2.for('jest.asymmetricMatcher')
600
- : 0x1357a5;
601
- const SPACE$2 = ' ';
602
-
603
- const serialize$8 = (val, config, indentation, depth, refs, printer) => {
604
- const stringedValue = val.toString();
605
-
606
- if (
607
- stringedValue === 'ArrayContaining' ||
608
- stringedValue === 'ArrayNotContaining'
609
- ) {
610
- if (++depth > config.maxDepth) {
611
- return '[' + stringedValue + ']';
612
- }
613
-
614
- return (
615
- stringedValue +
616
- SPACE$2 +
617
- '[' +
618
- (0, _collections$3.printListItems)(
619
- val.sample,
620
- config,
621
- indentation,
622
- depth,
623
- refs,
624
- printer
625
- ) +
626
- ']'
627
- );
628
- }
629
-
630
- if (
631
- stringedValue === 'ObjectContaining' ||
632
- stringedValue === 'ObjectNotContaining'
633
- ) {
634
- if (++depth > config.maxDepth) {
635
- return '[' + stringedValue + ']';
636
- }
637
-
638
- return (
639
- stringedValue +
640
- SPACE$2 +
641
- '{' +
642
- (0, _collections$3.printObjectProperties)(
643
- val.sample,
644
- config,
645
- indentation,
646
- depth,
647
- refs,
648
- printer
649
- ) +
650
- '}'
651
- );
652
- }
653
-
654
- if (
655
- stringedValue === 'StringMatching' ||
656
- stringedValue === 'StringNotMatching'
657
- ) {
658
- return (
659
- stringedValue +
660
- SPACE$2 +
661
- printer(val.sample, config, indentation, depth, refs)
662
- );
663
- }
664
-
665
- if (
666
- stringedValue === 'StringContaining' ||
667
- stringedValue === 'StringNotContaining'
668
- ) {
669
- return (
670
- stringedValue +
671
- SPACE$2 +
672
- printer(val.sample, config, indentation, depth, refs)
673
- );
674
- }
675
-
676
- return val.toAsymmetricMatcher();
677
- };
678
-
679
- AsymmetricMatcher$1.serialize = serialize$8;
680
-
681
- const test$7 = val => val && val.$$typeof === asymmetricMatcher;
682
-
683
- AsymmetricMatcher$1.test = test$7;
684
- const plugin$7 = {
685
- serialize: serialize$8,
686
- test: test$7
687
- };
688
- var _default$7 = plugin$7;
689
- AsymmetricMatcher$1.default = _default$7;
690
-
691
- var ConvertAnsi = {};
692
-
693
- var ansiRegex = ({onlyFirst = false} = {}) => {
694
- const pattern = [
695
- '[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)',
696
- '(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-ntqry=><~]))'
697
- ].join('|');
698
-
699
- return new RegExp(pattern, onlyFirst ? undefined : 'g');
700
- };
701
-
702
- Object.defineProperty(ConvertAnsi, '__esModule', {
703
- value: true
704
- });
705
- ConvertAnsi.test = ConvertAnsi.serialize = ConvertAnsi.default = void 0;
706
-
707
- var _ansiRegex = _interopRequireDefault$2(ansiRegex);
708
-
709
- var _ansiStyles$1 = _interopRequireDefault$2(ansiStyles.exports);
710
-
711
- function _interopRequireDefault$2(obj) {
712
- return obj && obj.__esModule ? obj : {default: obj};
713
- }
714
-
715
- /**
716
- * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
717
- *
718
- * This source code is licensed under the MIT license found in the
719
- * LICENSE file in the root directory of this source tree.
720
- */
721
- const toHumanReadableAnsi = text =>
722
- text.replace((0, _ansiRegex.default)(), match => {
723
- switch (match) {
724
- case _ansiStyles$1.default.red.close:
725
- case _ansiStyles$1.default.green.close:
726
- case _ansiStyles$1.default.cyan.close:
727
- case _ansiStyles$1.default.gray.close:
728
- case _ansiStyles$1.default.white.close:
729
- case _ansiStyles$1.default.yellow.close:
730
- case _ansiStyles$1.default.bgRed.close:
731
- case _ansiStyles$1.default.bgGreen.close:
732
- case _ansiStyles$1.default.bgYellow.close:
733
- case _ansiStyles$1.default.inverse.close:
734
- case _ansiStyles$1.default.dim.close:
735
- case _ansiStyles$1.default.bold.close:
736
- case _ansiStyles$1.default.reset.open:
737
- case _ansiStyles$1.default.reset.close:
738
- return '</>';
739
-
740
- case _ansiStyles$1.default.red.open:
741
- return '<red>';
742
-
743
- case _ansiStyles$1.default.green.open:
744
- return '<green>';
745
-
746
- case _ansiStyles$1.default.cyan.open:
747
- return '<cyan>';
748
-
749
- case _ansiStyles$1.default.gray.open:
750
- return '<gray>';
751
-
752
- case _ansiStyles$1.default.white.open:
753
- return '<white>';
754
-
755
- case _ansiStyles$1.default.yellow.open:
756
- return '<yellow>';
757
-
758
- case _ansiStyles$1.default.bgRed.open:
759
- return '<bgRed>';
760
-
761
- case _ansiStyles$1.default.bgGreen.open:
762
- return '<bgGreen>';
763
-
764
- case _ansiStyles$1.default.bgYellow.open:
765
- return '<bgYellow>';
766
-
767
- case _ansiStyles$1.default.inverse.open:
768
- return '<inverse>';
769
-
770
- case _ansiStyles$1.default.dim.open:
771
- return '<dim>';
772
-
773
- case _ansiStyles$1.default.bold.open:
774
- return '<bold>';
775
-
776
- default:
777
- return '';
778
- }
779
- });
780
-
781
- const test$6 = val =>
782
- typeof val === 'string' && !!val.match((0, _ansiRegex.default)());
783
-
784
- ConvertAnsi.test = test$6;
785
-
786
- const serialize$7 = (val, config, indentation, depth, refs, printer) =>
787
- printer(toHumanReadableAnsi(val), config, indentation, depth, refs);
788
-
789
- ConvertAnsi.serialize = serialize$7;
790
- const plugin$6 = {
791
- serialize: serialize$7,
792
- test: test$6
793
- };
794
- var _default$6 = plugin$6;
795
- ConvertAnsi.default = _default$6;
796
-
797
- var DOMCollection$1 = {};
798
-
799
- Object.defineProperty(DOMCollection$1, '__esModule', {
800
- value: true
801
- });
802
- DOMCollection$1.test = DOMCollection$1.serialize = DOMCollection$1.default = void 0;
803
-
804
- var _collections$2 = collections;
805
-
806
- /**
807
- * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
808
- *
809
- * This source code is licensed under the MIT license found in the
810
- * LICENSE file in the root directory of this source tree.
811
- */
812
-
813
- /* eslint-disable local/ban-types-eventually */
814
- const SPACE$1 = ' ';
815
- const OBJECT_NAMES = ['DOMStringMap', 'NamedNodeMap'];
816
- const ARRAY_REGEXP = /^(HTML\w*Collection|NodeList)$/;
817
-
818
- const testName = name =>
819
- OBJECT_NAMES.indexOf(name) !== -1 || ARRAY_REGEXP.test(name);
820
-
821
- const test$5 = val =>
822
- val &&
823
- val.constructor &&
824
- !!val.constructor.name &&
825
- testName(val.constructor.name);
826
-
827
- DOMCollection$1.test = test$5;
828
-
829
- const isNamedNodeMap = collection =>
830
- collection.constructor.name === 'NamedNodeMap';
831
-
832
- const serialize$6 = (collection, config, indentation, depth, refs, printer) => {
833
- const name = collection.constructor.name;
834
-
835
- if (++depth > config.maxDepth) {
836
- return '[' + name + ']';
837
- }
838
-
839
- return (
840
- (config.min ? '' : name + SPACE$1) +
841
- (OBJECT_NAMES.indexOf(name) !== -1
842
- ? '{' +
843
- (0, _collections$2.printObjectProperties)(
844
- isNamedNodeMap(collection)
845
- ? Array.from(collection).reduce((props, attribute) => {
846
- props[attribute.name] = attribute.value;
847
- return props;
848
- }, {})
849
- : {...collection},
850
- config,
851
- indentation,
852
- depth,
853
- refs,
854
- printer
855
- ) +
856
- '}'
857
- : '[' +
858
- (0, _collections$2.printListItems)(
859
- Array.from(collection),
860
- config,
861
- indentation,
862
- depth,
863
- refs,
864
- printer
865
- ) +
866
- ']')
867
- );
868
- };
869
-
870
- DOMCollection$1.serialize = serialize$6;
871
- const plugin$5 = {
872
- serialize: serialize$6,
873
- test: test$5
874
- };
875
- var _default$5 = plugin$5;
876
- DOMCollection$1.default = _default$5;
877
-
878
- var DOMElement$1 = {};
879
-
880
- var markup = {};
881
-
882
- var escapeHTML$1 = {};
883
-
884
- Object.defineProperty(escapeHTML$1, '__esModule', {
885
- value: true
886
- });
887
- escapeHTML$1.default = escapeHTML;
888
-
889
- /**
890
- * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
891
- *
892
- * This source code is licensed under the MIT license found in the
893
- * LICENSE file in the root directory of this source tree.
894
- */
895
- function escapeHTML(str) {
896
- return str.replace(/</g, '&lt;').replace(/>/g, '&gt;');
897
- }
898
-
899
- Object.defineProperty(markup, '__esModule', {
900
- value: true
901
- });
902
- markup.printText =
903
- markup.printProps =
904
- markup.printElementAsLeaf =
905
- markup.printElement =
906
- markup.printComment =
907
- markup.printChildren =
908
- void 0;
909
-
910
- var _escapeHTML = _interopRequireDefault$1(escapeHTML$1);
911
-
912
- function _interopRequireDefault$1(obj) {
913
- return obj && obj.__esModule ? obj : {default: obj};
914
- }
915
-
916
- /**
917
- * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
918
- *
919
- * This source code is licensed under the MIT license found in the
920
- * LICENSE file in the root directory of this source tree.
921
- */
922
- // Return empty string if keys is empty.
923
- const printProps = (keys, props, config, indentation, depth, refs, printer) => {
924
- const indentationNext = indentation + config.indent;
925
- const colors = config.colors;
926
- return keys
927
- .map(key => {
928
- const value = props[key];
929
- let printed = printer(value, config, indentationNext, depth, refs);
930
-
931
- if (typeof value !== 'string') {
932
- if (printed.indexOf('\n') !== -1) {
933
- printed =
934
- config.spacingOuter +
935
- indentationNext +
936
- printed +
937
- config.spacingOuter +
938
- indentation;
939
- }
940
-
941
- printed = '{' + printed + '}';
942
- }
943
-
944
- return (
945
- config.spacingInner +
946
- indentation +
947
- colors.prop.open +
948
- key +
949
- colors.prop.close +
950
- '=' +
951
- colors.value.open +
952
- printed +
953
- colors.value.close
954
- );
955
- })
956
- .join('');
957
- }; // Return empty string if children is empty.
958
-
959
- markup.printProps = printProps;
960
-
961
- const printChildren = (children, config, indentation, depth, refs, printer) =>
962
- children
963
- .map(
964
- child =>
965
- config.spacingOuter +
966
- indentation +
967
- (typeof child === 'string'
968
- ? printText(child, config)
969
- : printer(child, config, indentation, depth, refs))
970
- )
971
- .join('');
972
-
973
- markup.printChildren = printChildren;
974
-
975
- const printText = (text, config) => {
976
- const contentColor = config.colors.content;
977
- return (
978
- contentColor.open + (0, _escapeHTML.default)(text) + contentColor.close
979
- );
980
- };
981
-
982
- markup.printText = printText;
983
-
984
- const printComment = (comment, config) => {
985
- const commentColor = config.colors.comment;
986
- return (
987
- commentColor.open +
988
- '<!--' +
989
- (0, _escapeHTML.default)(comment) +
990
- '-->' +
991
- commentColor.close
992
- );
993
- }; // Separate the functions to format props, children, and element,
994
- // so a plugin could override a particular function, if needed.
995
- // Too bad, so sad: the traditional (but unnecessary) space
996
- // in a self-closing tagColor requires a second test of printedProps.
997
-
998
- markup.printComment = printComment;
999
-
1000
- const printElement = (
1001
- type,
1002
- printedProps,
1003
- printedChildren,
1004
- config,
1005
- indentation
1006
- ) => {
1007
- const tagColor = config.colors.tag;
1008
- return (
1009
- tagColor.open +
1010
- '<' +
1011
- type +
1012
- (printedProps &&
1013
- tagColor.close +
1014
- printedProps +
1015
- config.spacingOuter +
1016
- indentation +
1017
- tagColor.open) +
1018
- (printedChildren
1019
- ? '>' +
1020
- tagColor.close +
1021
- printedChildren +
1022
- config.spacingOuter +
1023
- indentation +
1024
- tagColor.open +
1025
- '</' +
1026
- type
1027
- : (printedProps && !config.min ? '' : ' ') + '/') +
1028
- '>' +
1029
- tagColor.close
1030
- );
1031
- };
1032
-
1033
- markup.printElement = printElement;
1034
-
1035
- const printElementAsLeaf = (type, config) => {
1036
- const tagColor = config.colors.tag;
1037
- return (
1038
- tagColor.open +
1039
- '<' +
1040
- type +
1041
- tagColor.close +
1042
- ' …' +
1043
- tagColor.open +
1044
- ' />' +
1045
- tagColor.close
1046
- );
1047
- };
1048
-
1049
- markup.printElementAsLeaf = printElementAsLeaf;
1050
-
1051
- Object.defineProperty(DOMElement$1, '__esModule', {
1052
- value: true
1053
- });
1054
- DOMElement$1.test = DOMElement$1.serialize = DOMElement$1.default = void 0;
1055
-
1056
- var _markup$2 = markup;
1057
-
1058
- /**
1059
- * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
1060
- *
1061
- * This source code is licensed under the MIT license found in the
1062
- * LICENSE file in the root directory of this source tree.
1063
- */
1064
- const ELEMENT_NODE = 1;
1065
- const TEXT_NODE = 3;
1066
- const COMMENT_NODE = 8;
1067
- const FRAGMENT_NODE = 11;
1068
- const ELEMENT_REGEXP = /^((HTML|SVG)\w*)?Element$/;
1069
-
1070
- const testHasAttribute = val => {
1071
- try {
1072
- return typeof val.hasAttribute === 'function' && val.hasAttribute('is');
1073
- } catch {
1074
- return false;
1075
- }
1076
- };
1077
-
1078
- const testNode = val => {
1079
- const constructorName = val.constructor.name;
1080
- const {nodeType, tagName} = val;
1081
- const isCustomElement =
1082
- (typeof tagName === 'string' && tagName.includes('-')) ||
1083
- testHasAttribute(val);
1084
- return (
1085
- (nodeType === ELEMENT_NODE &&
1086
- (ELEMENT_REGEXP.test(constructorName) || isCustomElement)) ||
1087
- (nodeType === TEXT_NODE && constructorName === 'Text') ||
1088
- (nodeType === COMMENT_NODE && constructorName === 'Comment') ||
1089
- (nodeType === FRAGMENT_NODE && constructorName === 'DocumentFragment')
1090
- );
1091
- };
1092
-
1093
- const test$4 = val => {
1094
- var _val$constructor;
1095
-
1096
- return (
1097
- (val === null || val === void 0
1098
- ? void 0
1099
- : (_val$constructor = val.constructor) === null ||
1100
- _val$constructor === void 0
1101
- ? void 0
1102
- : _val$constructor.name) && testNode(val)
1103
- );
1104
- };
1105
-
1106
- DOMElement$1.test = test$4;
1107
-
1108
- function nodeIsText(node) {
1109
- return node.nodeType === TEXT_NODE;
1110
- }
1111
-
1112
- function nodeIsComment(node) {
1113
- return node.nodeType === COMMENT_NODE;
1114
- }
1115
-
1116
- function nodeIsFragment(node) {
1117
- return node.nodeType === FRAGMENT_NODE;
1118
- }
1119
-
1120
- const serialize$5 = (node, config, indentation, depth, refs, printer) => {
1121
- if (nodeIsText(node)) {
1122
- return (0, _markup$2.printText)(node.data, config);
1123
- }
1124
-
1125
- if (nodeIsComment(node)) {
1126
- return (0, _markup$2.printComment)(node.data, config);
1127
- }
1128
-
1129
- const type = nodeIsFragment(node)
1130
- ? 'DocumentFragment'
1131
- : node.tagName.toLowerCase();
1132
-
1133
- if (++depth > config.maxDepth) {
1134
- return (0, _markup$2.printElementAsLeaf)(type, config);
1135
- }
1136
-
1137
- return (0, _markup$2.printElement)(
1138
- type,
1139
- (0, _markup$2.printProps)(
1140
- nodeIsFragment(node)
1141
- ? []
1142
- : Array.from(node.attributes)
1143
- .map(attr => attr.name)
1144
- .sort(),
1145
- nodeIsFragment(node)
1146
- ? {}
1147
- : Array.from(node.attributes).reduce((props, attribute) => {
1148
- props[attribute.name] = attribute.value;
1149
- return props;
1150
- }, {}),
1151
- config,
1152
- indentation + config.indent,
1153
- depth,
1154
- refs,
1155
- printer
1156
- ),
1157
- (0, _markup$2.printChildren)(
1158
- Array.prototype.slice.call(node.childNodes || node.children),
1159
- config,
1160
- indentation + config.indent,
1161
- depth,
1162
- refs,
1163
- printer
1164
- ),
1165
- config,
1166
- indentation
1167
- );
1168
- };
1169
-
1170
- DOMElement$1.serialize = serialize$5;
1171
- const plugin$4 = {
1172
- serialize: serialize$5,
1173
- test: test$4
1174
- };
1175
- var _default$4 = plugin$4;
1176
- DOMElement$1.default = _default$4;
1177
-
1178
- var Immutable$1 = {};
1179
-
1180
- Object.defineProperty(Immutable$1, '__esModule', {
1181
- value: true
1182
- });
1183
- Immutable$1.test = Immutable$1.serialize = Immutable$1.default = void 0;
1184
-
1185
- var _collections$1 = collections;
1186
-
1187
- /**
1188
- * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
1189
- *
1190
- * This source code is licensed under the MIT license found in the
1191
- * LICENSE file in the root directory of this source tree.
1192
- */
1193
- // SENTINEL constants are from https://github.com/facebook/immutable-js
1194
- const IS_ITERABLE_SENTINEL = '@@__IMMUTABLE_ITERABLE__@@';
1195
- const IS_LIST_SENTINEL = '@@__IMMUTABLE_LIST__@@';
1196
- const IS_KEYED_SENTINEL = '@@__IMMUTABLE_KEYED__@@';
1197
- const IS_MAP_SENTINEL = '@@__IMMUTABLE_MAP__@@';
1198
- const IS_ORDERED_SENTINEL = '@@__IMMUTABLE_ORDERED__@@';
1199
- const IS_RECORD_SENTINEL = '@@__IMMUTABLE_RECORD__@@'; // immutable v4
1200
-
1201
- const IS_SEQ_SENTINEL = '@@__IMMUTABLE_SEQ__@@';
1202
- const IS_SET_SENTINEL = '@@__IMMUTABLE_SET__@@';
1203
- const IS_STACK_SENTINEL = '@@__IMMUTABLE_STACK__@@';
1204
-
1205
- const getImmutableName = name => 'Immutable.' + name;
1206
-
1207
- const printAsLeaf = name => '[' + name + ']';
1208
-
1209
- const SPACE = ' ';
1210
- const LAZY = '…'; // Seq is lazy if it calls a method like filter
1211
-
1212
- const printImmutableEntries = (
1213
- val,
1214
- config,
1215
- indentation,
1216
- depth,
1217
- refs,
1218
- printer,
1219
- type
1220
- ) =>
1221
- ++depth > config.maxDepth
1222
- ? printAsLeaf(getImmutableName(type))
1223
- : getImmutableName(type) +
1224
- SPACE +
1225
- '{' +
1226
- (0, _collections$1.printIteratorEntries)(
1227
- val.entries(),
1228
- config,
1229
- indentation,
1230
- depth,
1231
- refs,
1232
- printer
1233
- ) +
1234
- '}'; // Record has an entries method because it is a collection in immutable v3.
1235
- // Return an iterator for Immutable Record from version v3 or v4.
1236
-
1237
- function getRecordEntries(val) {
1238
- let i = 0;
1239
- return {
1240
- next() {
1241
- if (i < val._keys.length) {
1242
- const key = val._keys[i++];
1243
- return {
1244
- done: false,
1245
- value: [key, val.get(key)]
1246
- };
1247
- }
1248
-
1249
- return {
1250
- done: true,
1251
- value: undefined
1252
- };
1253
- }
1254
- };
1255
- }
1256
-
1257
- const printImmutableRecord = (
1258
- val,
1259
- config,
1260
- indentation,
1261
- depth,
1262
- refs,
1263
- printer
1264
- ) => {
1265
- // _name property is defined only for an Immutable Record instance
1266
- // which was constructed with a second optional descriptive name arg
1267
- const name = getImmutableName(val._name || 'Record');
1268
- return ++depth > config.maxDepth
1269
- ? printAsLeaf(name)
1270
- : name +
1271
- SPACE +
1272
- '{' +
1273
- (0, _collections$1.printIteratorEntries)(
1274
- getRecordEntries(val),
1275
- config,
1276
- indentation,
1277
- depth,
1278
- refs,
1279
- printer
1280
- ) +
1281
- '}';
1282
- };
1283
-
1284
- const printImmutableSeq = (val, config, indentation, depth, refs, printer) => {
1285
- const name = getImmutableName('Seq');
1286
-
1287
- if (++depth > config.maxDepth) {
1288
- return printAsLeaf(name);
1289
- }
1290
-
1291
- if (val[IS_KEYED_SENTINEL]) {
1292
- return (
1293
- name +
1294
- SPACE +
1295
- '{' + // from Immutable collection of entries or from ECMAScript object
1296
- (val._iter || val._object
1297
- ? (0, _collections$1.printIteratorEntries)(
1298
- val.entries(),
1299
- config,
1300
- indentation,
1301
- depth,
1302
- refs,
1303
- printer
1304
- )
1305
- : LAZY) +
1306
- '}'
1307
- );
1308
- }
1309
-
1310
- return (
1311
- name +
1312
- SPACE +
1313
- '[' +
1314
- (val._iter || // from Immutable collection of values
1315
- val._array || // from ECMAScript array
1316
- val._collection || // from ECMAScript collection in immutable v4
1317
- val._iterable // from ECMAScript collection in immutable v3
1318
- ? (0, _collections$1.printIteratorValues)(
1319
- val.values(),
1320
- config,
1321
- indentation,
1322
- depth,
1323
- refs,
1324
- printer
1325
- )
1326
- : LAZY) +
1327
- ']'
1328
- );
1329
- };
1330
-
1331
- const printImmutableValues = (
1332
- val,
1333
- config,
1334
- indentation,
1335
- depth,
1336
- refs,
1337
- printer,
1338
- type
1339
- ) =>
1340
- ++depth > config.maxDepth
1341
- ? printAsLeaf(getImmutableName(type))
1342
- : getImmutableName(type) +
1343
- SPACE +
1344
- '[' +
1345
- (0, _collections$1.printIteratorValues)(
1346
- val.values(),
1347
- config,
1348
- indentation,
1349
- depth,
1350
- refs,
1351
- printer
1352
- ) +
1353
- ']';
1354
-
1355
- const serialize$4 = (val, config, indentation, depth, refs, printer) => {
1356
- if (val[IS_MAP_SENTINEL]) {
1357
- return printImmutableEntries(
1358
- val,
1359
- config,
1360
- indentation,
1361
- depth,
1362
- refs,
1363
- printer,
1364
- val[IS_ORDERED_SENTINEL] ? 'OrderedMap' : 'Map'
1365
- );
1366
- }
1367
-
1368
- if (val[IS_LIST_SENTINEL]) {
1369
- return printImmutableValues(
1370
- val,
1371
- config,
1372
- indentation,
1373
- depth,
1374
- refs,
1375
- printer,
1376
- 'List'
1377
- );
1378
- }
1379
-
1380
- if (val[IS_SET_SENTINEL]) {
1381
- return printImmutableValues(
1382
- val,
1383
- config,
1384
- indentation,
1385
- depth,
1386
- refs,
1387
- printer,
1388
- val[IS_ORDERED_SENTINEL] ? 'OrderedSet' : 'Set'
1389
- );
1390
- }
1391
-
1392
- if (val[IS_STACK_SENTINEL]) {
1393
- return printImmutableValues(
1394
- val,
1395
- config,
1396
- indentation,
1397
- depth,
1398
- refs,
1399
- printer,
1400
- 'Stack'
1401
- );
1402
- }
1403
-
1404
- if (val[IS_SEQ_SENTINEL]) {
1405
- return printImmutableSeq(val, config, indentation, depth, refs, printer);
1406
- } // For compatibility with immutable v3 and v4, let record be the default.
1407
-
1408
- return printImmutableRecord(val, config, indentation, depth, refs, printer);
1409
- }; // Explicitly comparing sentinel properties to true avoids false positive
1410
- // when mock identity-obj-proxy returns the key as the value for any key.
1411
-
1412
- Immutable$1.serialize = serialize$4;
1413
-
1414
- const test$3 = val =>
1415
- val &&
1416
- (val[IS_ITERABLE_SENTINEL] === true || val[IS_RECORD_SENTINEL] === true);
1417
-
1418
- Immutable$1.test = test$3;
1419
- const plugin$3 = {
1420
- serialize: serialize$4,
1421
- test: test$3
1422
- };
1423
- var _default$3 = plugin$3;
1424
- Immutable$1.default = _default$3;
1425
-
1426
- var ReactElement$1 = {};
1427
-
1428
- var reactIs = {exports: {}};
1429
-
1430
- var reactIs_production_min = {};
1431
-
1432
- /** @license React v17.0.2
1433
- * react-is.production.min.js
1434
- *
1435
- * Copyright (c) Facebook, Inc. and its affiliates.
1436
- *
1437
- * This source code is licensed under the MIT license found in the
1438
- * LICENSE file in the root directory of this source tree.
1439
- */
1440
-
1441
- var hasRequiredReactIs_production_min;
1442
-
1443
- function requireReactIs_production_min () {
1444
- if (hasRequiredReactIs_production_min) return reactIs_production_min;
1445
- hasRequiredReactIs_production_min = 1;
1446
- var b=60103,c=60106,d=60107,e=60108,f=60114,g=60109,h=60110,k=60112,l=60113,m=60120,n=60115,p=60116,q=60121,r=60122,u=60117,v=60129,w=60131;
1447
- if("function"===typeof Symbol&&Symbol.for){var x=Symbol.for;b=x("react.element");c=x("react.portal");d=x("react.fragment");e=x("react.strict_mode");f=x("react.profiler");g=x("react.provider");h=x("react.context");k=x("react.forward_ref");l=x("react.suspense");m=x("react.suspense_list");n=x("react.memo");p=x("react.lazy");q=x("react.block");r=x("react.server.block");u=x("react.fundamental");v=x("react.debug_trace_mode");w=x("react.legacy_hidden");}
1448
- function y(a){if("object"===typeof a&&null!==a){var t=a.$$typeof;switch(t){case b:switch(a=a.type,a){case d:case f:case e:case l:case m:return a;default:switch(a=a&&a.$$typeof,a){case h:case k:case p:case n:case g:return a;default:return t}}case c:return t}}}var z=g,A=b,B=k,C=d,D=p,E=n,F=c,G=f,H=e,I=l;reactIs_production_min.ContextConsumer=h;reactIs_production_min.ContextProvider=z;reactIs_production_min.Element=A;reactIs_production_min.ForwardRef=B;reactIs_production_min.Fragment=C;reactIs_production_min.Lazy=D;reactIs_production_min.Memo=E;reactIs_production_min.Portal=F;reactIs_production_min.Profiler=G;reactIs_production_min.StrictMode=H;
1449
- reactIs_production_min.Suspense=I;reactIs_production_min.isAsyncMode=function(){return !1};reactIs_production_min.isConcurrentMode=function(){return !1};reactIs_production_min.isContextConsumer=function(a){return y(a)===h};reactIs_production_min.isContextProvider=function(a){return y(a)===g};reactIs_production_min.isElement=function(a){return "object"===typeof a&&null!==a&&a.$$typeof===b};reactIs_production_min.isForwardRef=function(a){return y(a)===k};reactIs_production_min.isFragment=function(a){return y(a)===d};reactIs_production_min.isLazy=function(a){return y(a)===p};reactIs_production_min.isMemo=function(a){return y(a)===n};
1450
- reactIs_production_min.isPortal=function(a){return y(a)===c};reactIs_production_min.isProfiler=function(a){return y(a)===f};reactIs_production_min.isStrictMode=function(a){return y(a)===e};reactIs_production_min.isSuspense=function(a){return y(a)===l};reactIs_production_min.isValidElementType=function(a){return "string"===typeof a||"function"===typeof a||a===d||a===f||a===v||a===e||a===l||a===m||a===w||"object"===typeof a&&null!==a&&(a.$$typeof===p||a.$$typeof===n||a.$$typeof===g||a.$$typeof===h||a.$$typeof===k||a.$$typeof===u||a.$$typeof===q||a[0]===r)?!0:!1};
1451
- reactIs_production_min.typeOf=y;
1452
- return reactIs_production_min;
1453
- }
1454
-
1455
- var reactIs_development = {};
1456
-
1457
- /** @license React v17.0.2
1458
- * react-is.development.js
1459
- *
1460
- * Copyright (c) Facebook, Inc. and its affiliates.
1461
- *
1462
- * This source code is licensed under the MIT license found in the
1463
- * LICENSE file in the root directory of this source tree.
1464
- */
1465
-
1466
- var hasRequiredReactIs_development;
1467
-
1468
- function requireReactIs_development () {
1469
- if (hasRequiredReactIs_development) return reactIs_development;
1470
- hasRequiredReactIs_development = 1;
1471
-
1472
- if (process.env.NODE_ENV !== "production") {
1473
- (function() {
1474
-
1475
- // ATTENTION
1476
- // When adding new symbols to this file,
1477
- // Please consider also adding to 'react-devtools-shared/src/backend/ReactSymbols'
1478
- // The Symbol used to tag the ReactElement-like types. If there is no native Symbol
1479
- // nor polyfill, then a plain number is used for performance.
1480
- var REACT_ELEMENT_TYPE = 0xeac7;
1481
- var REACT_PORTAL_TYPE = 0xeaca;
1482
- var REACT_FRAGMENT_TYPE = 0xeacb;
1483
- var REACT_STRICT_MODE_TYPE = 0xeacc;
1484
- var REACT_PROFILER_TYPE = 0xead2;
1485
- var REACT_PROVIDER_TYPE = 0xeacd;
1486
- var REACT_CONTEXT_TYPE = 0xeace;
1487
- var REACT_FORWARD_REF_TYPE = 0xead0;
1488
- var REACT_SUSPENSE_TYPE = 0xead1;
1489
- var REACT_SUSPENSE_LIST_TYPE = 0xead8;
1490
- var REACT_MEMO_TYPE = 0xead3;
1491
- var REACT_LAZY_TYPE = 0xead4;
1492
- var REACT_BLOCK_TYPE = 0xead9;
1493
- var REACT_SERVER_BLOCK_TYPE = 0xeada;
1494
- var REACT_FUNDAMENTAL_TYPE = 0xead5;
1495
- var REACT_DEBUG_TRACING_MODE_TYPE = 0xeae1;
1496
- var REACT_LEGACY_HIDDEN_TYPE = 0xeae3;
1497
-
1498
- if (typeof Symbol === 'function' && Symbol.for) {
1499
- var symbolFor = Symbol.for;
1500
- REACT_ELEMENT_TYPE = symbolFor('react.element');
1501
- REACT_PORTAL_TYPE = symbolFor('react.portal');
1502
- REACT_FRAGMENT_TYPE = symbolFor('react.fragment');
1503
- REACT_STRICT_MODE_TYPE = symbolFor('react.strict_mode');
1504
- REACT_PROFILER_TYPE = symbolFor('react.profiler');
1505
- REACT_PROVIDER_TYPE = symbolFor('react.provider');
1506
- REACT_CONTEXT_TYPE = symbolFor('react.context');
1507
- REACT_FORWARD_REF_TYPE = symbolFor('react.forward_ref');
1508
- REACT_SUSPENSE_TYPE = symbolFor('react.suspense');
1509
- REACT_SUSPENSE_LIST_TYPE = symbolFor('react.suspense_list');
1510
- REACT_MEMO_TYPE = symbolFor('react.memo');
1511
- REACT_LAZY_TYPE = symbolFor('react.lazy');
1512
- REACT_BLOCK_TYPE = symbolFor('react.block');
1513
- REACT_SERVER_BLOCK_TYPE = symbolFor('react.server.block');
1514
- REACT_FUNDAMENTAL_TYPE = symbolFor('react.fundamental');
1515
- symbolFor('react.scope');
1516
- symbolFor('react.opaque.id');
1517
- REACT_DEBUG_TRACING_MODE_TYPE = symbolFor('react.debug_trace_mode');
1518
- symbolFor('react.offscreen');
1519
- REACT_LEGACY_HIDDEN_TYPE = symbolFor('react.legacy_hidden');
1520
- }
1521
-
1522
- // Filter certain DOM attributes (e.g. src, href) if their values are empty strings.
1523
-
1524
- var enableScopeAPI = false; // Experimental Create Event Handle API.
1525
-
1526
- function isValidElementType(type) {
1527
- if (typeof type === 'string' || typeof type === 'function') {
1528
- return true;
1529
- } // Note: typeof might be other than 'symbol' or 'number' (e.g. if it's a polyfill).
1530
-
1531
-
1532
- if (type === REACT_FRAGMENT_TYPE || type === REACT_PROFILER_TYPE || type === REACT_DEBUG_TRACING_MODE_TYPE || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || type === REACT_SUSPENSE_LIST_TYPE || type === REACT_LEGACY_HIDDEN_TYPE || enableScopeAPI ) {
1533
- return true;
1534
- }
1535
-
1536
- if (typeof type === 'object' && type !== null) {
1537
- if (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE || type.$$typeof === REACT_FUNDAMENTAL_TYPE || type.$$typeof === REACT_BLOCK_TYPE || type[0] === REACT_SERVER_BLOCK_TYPE) {
1538
- return true;
1539
- }
1540
- }
1541
-
1542
- return false;
1543
- }
1544
-
1545
- function typeOf(object) {
1546
- if (typeof object === 'object' && object !== null) {
1547
- var $$typeof = object.$$typeof;
1548
-
1549
- switch ($$typeof) {
1550
- case REACT_ELEMENT_TYPE:
1551
- var type = object.type;
1552
-
1553
- switch (type) {
1554
- case REACT_FRAGMENT_TYPE:
1555
- case REACT_PROFILER_TYPE:
1556
- case REACT_STRICT_MODE_TYPE:
1557
- case REACT_SUSPENSE_TYPE:
1558
- case REACT_SUSPENSE_LIST_TYPE:
1559
- return type;
1560
-
1561
- default:
1562
- var $$typeofType = type && type.$$typeof;
1563
-
1564
- switch ($$typeofType) {
1565
- case REACT_CONTEXT_TYPE:
1566
- case REACT_FORWARD_REF_TYPE:
1567
- case REACT_LAZY_TYPE:
1568
- case REACT_MEMO_TYPE:
1569
- case REACT_PROVIDER_TYPE:
1570
- return $$typeofType;
1571
-
1572
- default:
1573
- return $$typeof;
1574
- }
1575
-
1576
- }
1577
-
1578
- case REACT_PORTAL_TYPE:
1579
- return $$typeof;
1580
- }
1581
- }
1582
-
1583
- return undefined;
1584
- }
1585
- var ContextConsumer = REACT_CONTEXT_TYPE;
1586
- var ContextProvider = REACT_PROVIDER_TYPE;
1587
- var Element = REACT_ELEMENT_TYPE;
1588
- var ForwardRef = REACT_FORWARD_REF_TYPE;
1589
- var Fragment = REACT_FRAGMENT_TYPE;
1590
- var Lazy = REACT_LAZY_TYPE;
1591
- var Memo = REACT_MEMO_TYPE;
1592
- var Portal = REACT_PORTAL_TYPE;
1593
- var Profiler = REACT_PROFILER_TYPE;
1594
- var StrictMode = REACT_STRICT_MODE_TYPE;
1595
- var Suspense = REACT_SUSPENSE_TYPE;
1596
- var hasWarnedAboutDeprecatedIsAsyncMode = false;
1597
- var hasWarnedAboutDeprecatedIsConcurrentMode = false; // AsyncMode should be deprecated
1598
-
1599
- function isAsyncMode(object) {
1600
- {
1601
- if (!hasWarnedAboutDeprecatedIsAsyncMode) {
1602
- hasWarnedAboutDeprecatedIsAsyncMode = true; // Using console['warn'] to evade Babel and ESLint
1603
-
1604
- console['warn']('The ReactIs.isAsyncMode() alias has been deprecated, ' + 'and will be removed in React 18+.');
1605
- }
1606
- }
1607
-
1608
- return false;
1609
- }
1610
- function isConcurrentMode(object) {
1611
- {
1612
- if (!hasWarnedAboutDeprecatedIsConcurrentMode) {
1613
- hasWarnedAboutDeprecatedIsConcurrentMode = true; // Using console['warn'] to evade Babel and ESLint
1614
-
1615
- console['warn']('The ReactIs.isConcurrentMode() alias has been deprecated, ' + 'and will be removed in React 18+.');
1616
- }
1617
- }
1618
-
1619
- return false;
1620
- }
1621
- function isContextConsumer(object) {
1622
- return typeOf(object) === REACT_CONTEXT_TYPE;
1623
- }
1624
- function isContextProvider(object) {
1625
- return typeOf(object) === REACT_PROVIDER_TYPE;
1626
- }
1627
- function isElement(object) {
1628
- return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
1629
- }
1630
- function isForwardRef(object) {
1631
- return typeOf(object) === REACT_FORWARD_REF_TYPE;
1632
- }
1633
- function isFragment(object) {
1634
- return typeOf(object) === REACT_FRAGMENT_TYPE;
1635
- }
1636
- function isLazy(object) {
1637
- return typeOf(object) === REACT_LAZY_TYPE;
1638
- }
1639
- function isMemo(object) {
1640
- return typeOf(object) === REACT_MEMO_TYPE;
1641
- }
1642
- function isPortal(object) {
1643
- return typeOf(object) === REACT_PORTAL_TYPE;
1644
- }
1645
- function isProfiler(object) {
1646
- return typeOf(object) === REACT_PROFILER_TYPE;
1647
- }
1648
- function isStrictMode(object) {
1649
- return typeOf(object) === REACT_STRICT_MODE_TYPE;
1650
- }
1651
- function isSuspense(object) {
1652
- return typeOf(object) === REACT_SUSPENSE_TYPE;
1653
- }
1654
-
1655
- reactIs_development.ContextConsumer = ContextConsumer;
1656
- reactIs_development.ContextProvider = ContextProvider;
1657
- reactIs_development.Element = Element;
1658
- reactIs_development.ForwardRef = ForwardRef;
1659
- reactIs_development.Fragment = Fragment;
1660
- reactIs_development.Lazy = Lazy;
1661
- reactIs_development.Memo = Memo;
1662
- reactIs_development.Portal = Portal;
1663
- reactIs_development.Profiler = Profiler;
1664
- reactIs_development.StrictMode = StrictMode;
1665
- reactIs_development.Suspense = Suspense;
1666
- reactIs_development.isAsyncMode = isAsyncMode;
1667
- reactIs_development.isConcurrentMode = isConcurrentMode;
1668
- reactIs_development.isContextConsumer = isContextConsumer;
1669
- reactIs_development.isContextProvider = isContextProvider;
1670
- reactIs_development.isElement = isElement;
1671
- reactIs_development.isForwardRef = isForwardRef;
1672
- reactIs_development.isFragment = isFragment;
1673
- reactIs_development.isLazy = isLazy;
1674
- reactIs_development.isMemo = isMemo;
1675
- reactIs_development.isPortal = isPortal;
1676
- reactIs_development.isProfiler = isProfiler;
1677
- reactIs_development.isStrictMode = isStrictMode;
1678
- reactIs_development.isSuspense = isSuspense;
1679
- reactIs_development.isValidElementType = isValidElementType;
1680
- reactIs_development.typeOf = typeOf;
1681
- })();
1682
- }
1683
- return reactIs_development;
1684
- }
1685
-
1686
- (function (module) {
1687
-
1688
- if (process.env.NODE_ENV === 'production') {
1689
- module.exports = requireReactIs_production_min();
1690
- } else {
1691
- module.exports = requireReactIs_development();
1692
- }
1693
- } (reactIs));
1694
-
1695
- Object.defineProperty(ReactElement$1, '__esModule', {
1696
- value: true
1697
- });
1698
- ReactElement$1.test = ReactElement$1.serialize = ReactElement$1.default = void 0;
1699
-
1700
- var ReactIs = _interopRequireWildcard(reactIs.exports);
1701
-
1702
- var _markup$1 = markup;
1703
-
1704
- function _getRequireWildcardCache(nodeInterop) {
1705
- if (typeof WeakMap !== 'function') return null;
1706
- var cacheBabelInterop = new WeakMap();
1707
- var cacheNodeInterop = new WeakMap();
1708
- return (_getRequireWildcardCache = function (nodeInterop) {
1709
- return nodeInterop ? cacheNodeInterop : cacheBabelInterop;
1710
- })(nodeInterop);
1711
- }
1712
-
1713
- function _interopRequireWildcard(obj, nodeInterop) {
1714
- if (!nodeInterop && obj && obj.__esModule) {
1715
- return obj;
1716
- }
1717
- if (obj === null || (typeof obj !== 'object' && typeof obj !== 'function')) {
1718
- return {default: obj};
1719
- }
1720
- var cache = _getRequireWildcardCache(nodeInterop);
1721
- if (cache && cache.has(obj)) {
1722
- return cache.get(obj);
1723
- }
1724
- var newObj = {};
1725
- var hasPropertyDescriptor =
1726
- Object.defineProperty && Object.getOwnPropertyDescriptor;
1727
- for (var key in obj) {
1728
- if (key !== 'default' && Object.prototype.hasOwnProperty.call(obj, key)) {
1729
- var desc = hasPropertyDescriptor
1730
- ? Object.getOwnPropertyDescriptor(obj, key)
1731
- : null;
1732
- if (desc && (desc.get || desc.set)) {
1733
- Object.defineProperty(newObj, key, desc);
1734
- } else {
1735
- newObj[key] = obj[key];
1736
- }
1737
- }
1738
- }
1739
- newObj.default = obj;
1740
- if (cache) {
1741
- cache.set(obj, newObj);
1742
- }
1743
- return newObj;
1744
- }
1745
-
1746
- /**
1747
- * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
1748
- *
1749
- * This source code is licensed under the MIT license found in the
1750
- * LICENSE file in the root directory of this source tree.
1751
- */
1752
- // Given element.props.children, or subtree during recursive traversal,
1753
- // return flattened array of children.
1754
- const getChildren = (arg, children = []) => {
1755
- if (Array.isArray(arg)) {
1756
- arg.forEach(item => {
1757
- getChildren(item, children);
1758
- });
1759
- } else if (arg != null && arg !== false) {
1760
- children.push(arg);
1761
- }
1762
-
1763
- return children;
1764
- };
1765
-
1766
- const getType = element => {
1767
- const type = element.type;
1768
-
1769
- if (typeof type === 'string') {
1770
- return type;
1771
- }
1772
-
1773
- if (typeof type === 'function') {
1774
- return type.displayName || type.name || 'Unknown';
1775
- }
1776
-
1777
- if (ReactIs.isFragment(element)) {
1778
- return 'React.Fragment';
1779
- }
1780
-
1781
- if (ReactIs.isSuspense(element)) {
1782
- return 'React.Suspense';
1783
- }
1784
-
1785
- if (typeof type === 'object' && type !== null) {
1786
- if (ReactIs.isContextProvider(element)) {
1787
- return 'Context.Provider';
1788
- }
1789
-
1790
- if (ReactIs.isContextConsumer(element)) {
1791
- return 'Context.Consumer';
1792
- }
1793
-
1794
- if (ReactIs.isForwardRef(element)) {
1795
- if (type.displayName) {
1796
- return type.displayName;
1797
- }
1798
-
1799
- const functionName = type.render.displayName || type.render.name || '';
1800
- return functionName !== ''
1801
- ? 'ForwardRef(' + functionName + ')'
1802
- : 'ForwardRef';
1803
- }
1804
-
1805
- if (ReactIs.isMemo(element)) {
1806
- const functionName =
1807
- type.displayName || type.type.displayName || type.type.name || '';
1808
- return functionName !== '' ? 'Memo(' + functionName + ')' : 'Memo';
1809
- }
1810
- }
1811
-
1812
- return 'UNDEFINED';
1813
- };
1814
-
1815
- const getPropKeys$1 = element => {
1816
- const {props} = element;
1817
- return Object.keys(props)
1818
- .filter(key => key !== 'children' && props[key] !== undefined)
1819
- .sort();
1820
- };
1821
-
1822
- const serialize$3 = (element, config, indentation, depth, refs, printer) =>
1823
- ++depth > config.maxDepth
1824
- ? (0, _markup$1.printElementAsLeaf)(getType(element), config)
1825
- : (0, _markup$1.printElement)(
1826
- getType(element),
1827
- (0, _markup$1.printProps)(
1828
- getPropKeys$1(element),
1829
- element.props,
1830
- config,
1831
- indentation + config.indent,
1832
- depth,
1833
- refs,
1834
- printer
1835
- ),
1836
- (0, _markup$1.printChildren)(
1837
- getChildren(element.props.children),
1838
- config,
1839
- indentation + config.indent,
1840
- depth,
1841
- refs,
1842
- printer
1843
- ),
1844
- config,
1845
- indentation
1846
- );
1847
-
1848
- ReactElement$1.serialize = serialize$3;
1849
-
1850
- const test$2 = val => val != null && ReactIs.isElement(val);
1851
-
1852
- ReactElement$1.test = test$2;
1853
- const plugin$2 = {
1854
- serialize: serialize$3,
1855
- test: test$2
1856
- };
1857
- var _default$2 = plugin$2;
1858
- ReactElement$1.default = _default$2;
1859
-
1860
- var ReactTestComponent$1 = {};
1861
-
1862
- Object.defineProperty(ReactTestComponent$1, '__esModule', {
1863
- value: true
1864
- });
1865
- ReactTestComponent$1.test = ReactTestComponent$1.serialize = ReactTestComponent$1.default = void 0;
1866
-
1867
- var _markup = markup;
1868
-
1869
- var global$1 = (function () {
1870
- if (typeof globalThis !== 'undefined') {
1871
- return globalThis;
1872
- } else if (typeof global$1 !== 'undefined') {
1873
- return global$1;
1874
- } else if (typeof self !== 'undefined') {
1875
- return self;
1876
- } else if (typeof window !== 'undefined') {
1877
- return window;
1878
- } else {
1879
- return Function('return this')();
1880
- }
1881
- })();
1882
-
1883
- var Symbol$1 = global$1['jest-symbol-do-not-touch'] || global$1.Symbol;
1884
- const testSymbol =
1885
- typeof Symbol$1 === 'function' && Symbol$1.for
1886
- ? Symbol$1.for('react.test.json')
1887
- : 0xea71357;
1888
-
1889
- const getPropKeys = object => {
1890
- const {props} = object;
1891
- return props
1892
- ? Object.keys(props)
1893
- .filter(key => props[key] !== undefined)
1894
- .sort()
1895
- : [];
1896
- };
1897
-
1898
- const serialize$2 = (object, config, indentation, depth, refs, printer) =>
1899
- ++depth > config.maxDepth
1900
- ? (0, _markup.printElementAsLeaf)(object.type, config)
1901
- : (0, _markup.printElement)(
1902
- object.type,
1903
- object.props
1904
- ? (0, _markup.printProps)(
1905
- getPropKeys(object),
1906
- object.props,
1907
- config,
1908
- indentation + config.indent,
1909
- depth,
1910
- refs,
1911
- printer
1912
- )
1913
- : '',
1914
- object.children
1915
- ? (0, _markup.printChildren)(
1916
- object.children,
1917
- config,
1918
- indentation + config.indent,
1919
- depth,
1920
- refs,
1921
- printer
1922
- )
1923
- : '',
1924
- config,
1925
- indentation
1926
- );
1927
-
1928
- ReactTestComponent$1.serialize = serialize$2;
1929
-
1930
- const test$1 = val => val && val.$$typeof === testSymbol;
1931
-
1932
- ReactTestComponent$1.test = test$1;
1933
- const plugin$1 = {
1934
- serialize: serialize$2,
1935
- test: test$1
1936
- };
1937
- var _default$1 = plugin$1;
1938
- ReactTestComponent$1.default = _default$1;
1939
-
1940
- Object.defineProperty(build, '__esModule', {
1941
- value: true
1942
- });
1943
- build.default = build.DEFAULT_OPTIONS = void 0;
1944
- var format_1 = build.format = format;
1945
- var plugins_1 = build.plugins = void 0;
1946
-
1947
- var _ansiStyles = _interopRequireDefault(ansiStyles.exports);
1948
-
1949
- var _collections = collections;
1950
-
1951
- var _AsymmetricMatcher = _interopRequireDefault(
1952
- AsymmetricMatcher$1
1953
- );
1954
-
1955
- var _ConvertAnsi = _interopRequireDefault(ConvertAnsi);
1956
-
1957
- var _DOMCollection = _interopRequireDefault(DOMCollection$1);
1958
-
1959
- var _DOMElement = _interopRequireDefault(DOMElement$1);
1960
-
1961
- var _Immutable = _interopRequireDefault(Immutable$1);
1962
-
1963
- var _ReactElement = _interopRequireDefault(ReactElement$1);
1964
-
1965
- var _ReactTestComponent = _interopRequireDefault(
1966
- ReactTestComponent$1
1967
- );
1968
-
1969
- function _interopRequireDefault(obj) {
1970
- return obj && obj.__esModule ? obj : {default: obj};
1971
- }
1972
-
1973
- /**
1974
- * Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
1975
- *
1976
- * This source code is licensed under the MIT license found in the
1977
- * LICENSE file in the root directory of this source tree.
1978
- */
1979
-
1980
- /* eslint-disable local/ban-types-eventually */
1981
- const toString = Object.prototype.toString;
1982
- const toISOString = Date.prototype.toISOString;
1983
- const errorToString = Error.prototype.toString;
1984
- const regExpToString = RegExp.prototype.toString;
1985
- /**
1986
- * Explicitly comparing typeof constructor to function avoids undefined as name
1987
- * when mock identity-obj-proxy returns the key as the value for any key.
1988
- */
1989
-
1990
- const getConstructorName = val =>
1991
- (typeof val.constructor === 'function' && val.constructor.name) || 'Object';
1992
- /* global window */
1993
-
1994
- /** Is val is equal to global window object? Works even if it does not exist :) */
1995
-
1996
- const isWindow = val => typeof window !== 'undefined' && val === window;
1997
-
1998
- const SYMBOL_REGEXP = /^Symbol\((.*)\)(.*)$/;
1999
- const NEWLINE_REGEXP = /\n/gi;
2000
-
2001
- class PrettyFormatPluginError extends Error {
2002
- constructor(message, stack) {
2003
- super(message);
2004
- this.stack = stack;
2005
- this.name = this.constructor.name;
2006
- }
2007
- }
2008
-
2009
- function isToStringedArrayType(toStringed) {
2010
- return (
2011
- toStringed === '[object Array]' ||
2012
- toStringed === '[object ArrayBuffer]' ||
2013
- toStringed === '[object DataView]' ||
2014
- toStringed === '[object Float32Array]' ||
2015
- toStringed === '[object Float64Array]' ||
2016
- toStringed === '[object Int8Array]' ||
2017
- toStringed === '[object Int16Array]' ||
2018
- toStringed === '[object Int32Array]' ||
2019
- toStringed === '[object Uint8Array]' ||
2020
- toStringed === '[object Uint8ClampedArray]' ||
2021
- toStringed === '[object Uint16Array]' ||
2022
- toStringed === '[object Uint32Array]'
2023
- );
2024
- }
2025
-
2026
- function printNumber(val) {
2027
- return Object.is(val, -0) ? '-0' : String(val);
2028
- }
2029
-
2030
- function printBigInt(val) {
2031
- return String(`${val}n`);
2032
- }
2033
-
2034
- function printFunction(val, printFunctionName) {
2035
- if (!printFunctionName) {
2036
- return '[Function]';
2037
- }
2038
-
2039
- return '[Function ' + (val.name || 'anonymous') + ']';
2040
- }
2041
-
2042
- function printSymbol(val) {
2043
- return String(val).replace(SYMBOL_REGEXP, 'Symbol($1)');
2044
- }
2045
-
2046
- function printError(val) {
2047
- return '[' + errorToString.call(val) + ']';
2048
- }
2049
- /**
2050
- * The first port of call for printing an object, handles most of the
2051
- * data-types in JS.
2052
- */
2053
-
2054
- function printBasicValue(val, printFunctionName, escapeRegex, escapeString) {
2055
- if (val === true || val === false) {
2056
- return '' + val;
2057
- }
2058
-
2059
- if (val === undefined) {
2060
- return 'undefined';
2061
- }
2062
-
2063
- if (val === null) {
2064
- return 'null';
2065
- }
2066
-
2067
- const typeOf = typeof val;
2068
-
2069
- if (typeOf === 'number') {
2070
- return printNumber(val);
2071
- }
2072
-
2073
- if (typeOf === 'bigint') {
2074
- return printBigInt(val);
2075
- }
2076
-
2077
- if (typeOf === 'string') {
2078
- if (escapeString) {
2079
- return '"' + val.replace(/"|\\/g, '\\$&') + '"';
2080
- }
2081
-
2082
- return '"' + val + '"';
2083
- }
2084
-
2085
- if (typeOf === 'function') {
2086
- return printFunction(val, printFunctionName);
2087
- }
2088
-
2089
- if (typeOf === 'symbol') {
2090
- return printSymbol(val);
2091
- }
2092
-
2093
- const toStringed = toString.call(val);
2094
-
2095
- if (toStringed === '[object WeakMap]') {
2096
- return 'WeakMap {}';
2097
- }
2098
-
2099
- if (toStringed === '[object WeakSet]') {
2100
- return 'WeakSet {}';
2101
- }
2102
-
2103
- if (
2104
- toStringed === '[object Function]' ||
2105
- toStringed === '[object GeneratorFunction]'
2106
- ) {
2107
- return printFunction(val, printFunctionName);
2108
- }
2109
-
2110
- if (toStringed === '[object Symbol]') {
2111
- return printSymbol(val);
2112
- }
2113
-
2114
- if (toStringed === '[object Date]') {
2115
- return isNaN(+val) ? 'Date { NaN }' : toISOString.call(val);
2116
- }
2117
-
2118
- if (toStringed === '[object Error]') {
2119
- return printError(val);
2120
- }
2121
-
2122
- if (toStringed === '[object RegExp]') {
2123
- if (escapeRegex) {
2124
- // https://github.com/benjamingr/RegExp.escape/blob/main/polyfill.js
2125
- return regExpToString.call(val).replace(/[\\^$*+?.()|[\]{}]/g, '\\$&');
2126
- }
2127
-
2128
- return regExpToString.call(val);
2129
- }
2130
-
2131
- if (val instanceof Error) {
2132
- return printError(val);
2133
- }
2134
-
2135
- return null;
2136
- }
2137
- /**
2138
- * Handles more complex objects ( such as objects with circular references.
2139
- * maps and sets etc )
2140
- */
2141
-
2142
- function printComplexValue(
2143
- val,
2144
- config,
2145
- indentation,
2146
- depth,
2147
- refs,
2148
- hasCalledToJSON
2149
- ) {
2150
- if (refs.indexOf(val) !== -1) {
2151
- return '[Circular]';
2152
- }
2153
-
2154
- refs = refs.slice();
2155
- refs.push(val);
2156
- const hitMaxDepth = ++depth > config.maxDepth;
2157
- const min = config.min;
2158
-
2159
- if (
2160
- config.callToJSON &&
2161
- !hitMaxDepth &&
2162
- val.toJSON &&
2163
- typeof val.toJSON === 'function' &&
2164
- !hasCalledToJSON
2165
- ) {
2166
- return printer(val.toJSON(), config, indentation, depth, refs, true);
2167
- }
2168
-
2169
- const toStringed = toString.call(val);
2170
-
2171
- if (toStringed === '[object Arguments]') {
2172
- return hitMaxDepth
2173
- ? '[Arguments]'
2174
- : (min ? '' : 'Arguments ') +
2175
- '[' +
2176
- (0, _collections.printListItems)(
2177
- val,
2178
- config,
2179
- indentation,
2180
- depth,
2181
- refs,
2182
- printer
2183
- ) +
2184
- ']';
2185
- }
2186
-
2187
- if (isToStringedArrayType(toStringed)) {
2188
- return hitMaxDepth
2189
- ? '[' + val.constructor.name + ']'
2190
- : (min
2191
- ? ''
2192
- : !config.printBasicPrototype && val.constructor.name === 'Array'
2193
- ? ''
2194
- : val.constructor.name + ' ') +
2195
- '[' +
2196
- (0, _collections.printListItems)(
2197
- val,
2198
- config,
2199
- indentation,
2200
- depth,
2201
- refs,
2202
- printer
2203
- ) +
2204
- ']';
2205
- }
2206
-
2207
- if (toStringed === '[object Map]') {
2208
- return hitMaxDepth
2209
- ? '[Map]'
2210
- : 'Map {' +
2211
- (0, _collections.printIteratorEntries)(
2212
- val.entries(),
2213
- config,
2214
- indentation,
2215
- depth,
2216
- refs,
2217
- printer,
2218
- ' => '
2219
- ) +
2220
- '}';
2221
- }
2222
-
2223
- if (toStringed === '[object Set]') {
2224
- return hitMaxDepth
2225
- ? '[Set]'
2226
- : 'Set {' +
2227
- (0, _collections.printIteratorValues)(
2228
- val.values(),
2229
- config,
2230
- indentation,
2231
- depth,
2232
- refs,
2233
- printer
2234
- ) +
2235
- '}';
2236
- } // Avoid failure to serialize global window object in jsdom test environment.
2237
- // For example, not even relevant if window is prop of React element.
2238
-
2239
- return hitMaxDepth || isWindow(val)
2240
- ? '[' + getConstructorName(val) + ']'
2241
- : (min
2242
- ? ''
2243
- : !config.printBasicPrototype && getConstructorName(val) === 'Object'
2244
- ? ''
2245
- : getConstructorName(val) + ' ') +
2246
- '{' +
2247
- (0, _collections.printObjectProperties)(
2248
- val,
2249
- config,
2250
- indentation,
2251
- depth,
2252
- refs,
2253
- printer
2254
- ) +
2255
- '}';
2256
- }
2257
-
2258
- function isNewPlugin(plugin) {
2259
- return plugin.serialize != null;
2260
- }
2261
-
2262
- function printPlugin(plugin, val, config, indentation, depth, refs) {
2263
- let printed;
2264
-
2265
- try {
2266
- printed = isNewPlugin(plugin)
2267
- ? plugin.serialize(val, config, indentation, depth, refs, printer)
2268
- : plugin.print(
2269
- val,
2270
- valChild => printer(valChild, config, indentation, depth, refs),
2271
- str => {
2272
- const indentationNext = indentation + config.indent;
2273
- return (
2274
- indentationNext +
2275
- str.replace(NEWLINE_REGEXP, '\n' + indentationNext)
2276
- );
2277
- },
2278
- {
2279
- edgeSpacing: config.spacingOuter,
2280
- min: config.min,
2281
- spacing: config.spacingInner
2282
- },
2283
- config.colors
2284
- );
2285
- } catch (error) {
2286
- throw new PrettyFormatPluginError(error.message, error.stack);
2287
- }
2288
-
2289
- if (typeof printed !== 'string') {
2290
- throw new Error(
2291
- `pretty-format: Plugin must return type "string" but instead returned "${typeof printed}".`
2292
- );
2293
- }
2294
-
2295
- return printed;
2296
- }
2297
-
2298
- function findPlugin(plugins, val) {
2299
- for (let p = 0; p < plugins.length; p++) {
2300
- try {
2301
- if (plugins[p].test(val)) {
2302
- return plugins[p];
2303
- }
2304
- } catch (error) {
2305
- throw new PrettyFormatPluginError(error.message, error.stack);
2306
- }
2307
- }
2308
-
2309
- return null;
2310
- }
2311
-
2312
- function printer(val, config, indentation, depth, refs, hasCalledToJSON) {
2313
- const plugin = findPlugin(config.plugins, val);
2314
-
2315
- if (plugin !== null) {
2316
- return printPlugin(plugin, val, config, indentation, depth, refs);
2317
- }
2318
-
2319
- const basicResult = printBasicValue(
2320
- val,
2321
- config.printFunctionName,
2322
- config.escapeRegex,
2323
- config.escapeString
2324
- );
2325
-
2326
- if (basicResult !== null) {
2327
- return basicResult;
2328
- }
2329
-
2330
- return printComplexValue(
2331
- val,
2332
- config,
2333
- indentation,
2334
- depth,
2335
- refs,
2336
- hasCalledToJSON
2337
- );
2338
- }
2339
-
2340
- const DEFAULT_THEME = {
2341
- comment: 'gray',
2342
- content: 'reset',
2343
- prop: 'yellow',
2344
- tag: 'cyan',
2345
- value: 'green'
2346
- };
2347
- const DEFAULT_THEME_KEYS = Object.keys(DEFAULT_THEME);
2348
- const DEFAULT_OPTIONS = {
2349
- callToJSON: true,
2350
- compareKeys: undefined,
2351
- escapeRegex: false,
2352
- escapeString: true,
2353
- highlight: false,
2354
- indent: 2,
2355
- maxDepth: Infinity,
2356
- min: false,
2357
- plugins: [],
2358
- printBasicPrototype: true,
2359
- printFunctionName: true,
2360
- theme: DEFAULT_THEME
2361
- };
2362
- build.DEFAULT_OPTIONS = DEFAULT_OPTIONS;
2363
-
2364
- function validateOptions(options) {
2365
- Object.keys(options).forEach(key => {
2366
- if (!DEFAULT_OPTIONS.hasOwnProperty(key)) {
2367
- throw new Error(`pretty-format: Unknown option "${key}".`);
2368
- }
2369
- });
2370
-
2371
- if (options.min && options.indent !== undefined && options.indent !== 0) {
2372
- throw new Error(
2373
- 'pretty-format: Options "min" and "indent" cannot be used together.'
2374
- );
2375
- }
2376
-
2377
- if (options.theme !== undefined) {
2378
- if (options.theme === null) {
2379
- throw new Error('pretty-format: Option "theme" must not be null.');
2380
- }
2381
-
2382
- if (typeof options.theme !== 'object') {
2383
- throw new Error(
2384
- `pretty-format: Option "theme" must be of type "object" but instead received "${typeof options.theme}".`
2385
- );
2386
- }
2387
- }
2388
- }
2389
-
2390
- const getColorsHighlight = options =>
2391
- DEFAULT_THEME_KEYS.reduce((colors, key) => {
2392
- const value =
2393
- options.theme && options.theme[key] !== undefined
2394
- ? options.theme[key]
2395
- : DEFAULT_THEME[key];
2396
- const color = value && _ansiStyles.default[value];
2397
-
2398
- if (
2399
- color &&
2400
- typeof color.close === 'string' &&
2401
- typeof color.open === 'string'
2402
- ) {
2403
- colors[key] = color;
2404
- } else {
2405
- throw new Error(
2406
- `pretty-format: Option "theme" has a key "${key}" whose value "${value}" is undefined in ansi-styles.`
2407
- );
2408
- }
2409
-
2410
- return colors;
2411
- }, Object.create(null));
2412
-
2413
- const getColorsEmpty = () =>
2414
- DEFAULT_THEME_KEYS.reduce((colors, key) => {
2415
- colors[key] = {
2416
- close: '',
2417
- open: ''
2418
- };
2419
- return colors;
2420
- }, Object.create(null));
2421
-
2422
- const getPrintFunctionName = options =>
2423
- options && options.printFunctionName !== undefined
2424
- ? options.printFunctionName
2425
- : DEFAULT_OPTIONS.printFunctionName;
2426
-
2427
- const getEscapeRegex = options =>
2428
- options && options.escapeRegex !== undefined
2429
- ? options.escapeRegex
2430
- : DEFAULT_OPTIONS.escapeRegex;
2431
-
2432
- const getEscapeString = options =>
2433
- options && options.escapeString !== undefined
2434
- ? options.escapeString
2435
- : DEFAULT_OPTIONS.escapeString;
2436
-
2437
- const getConfig = options => {
2438
- var _options$printBasicPr;
2439
-
2440
- return {
2441
- callToJSON:
2442
- options && options.callToJSON !== undefined
2443
- ? options.callToJSON
2444
- : DEFAULT_OPTIONS.callToJSON,
2445
- colors:
2446
- options && options.highlight
2447
- ? getColorsHighlight(options)
2448
- : getColorsEmpty(),
2449
- compareKeys:
2450
- options && typeof options.compareKeys === 'function'
2451
- ? options.compareKeys
2452
- : DEFAULT_OPTIONS.compareKeys,
2453
- escapeRegex: getEscapeRegex(options),
2454
- escapeString: getEscapeString(options),
2455
- indent:
2456
- options && options.min
2457
- ? ''
2458
- : createIndent(
2459
- options && options.indent !== undefined
2460
- ? options.indent
2461
- : DEFAULT_OPTIONS.indent
2462
- ),
2463
- maxDepth:
2464
- options && options.maxDepth !== undefined
2465
- ? options.maxDepth
2466
- : DEFAULT_OPTIONS.maxDepth,
2467
- min:
2468
- options && options.min !== undefined ? options.min : DEFAULT_OPTIONS.min,
2469
- plugins:
2470
- options && options.plugins !== undefined
2471
- ? options.plugins
2472
- : DEFAULT_OPTIONS.plugins,
2473
- printBasicPrototype:
2474
- (_options$printBasicPr =
2475
- options === null || options === void 0
2476
- ? void 0
2477
- : options.printBasicPrototype) !== null &&
2478
- _options$printBasicPr !== void 0
2479
- ? _options$printBasicPr
2480
- : true,
2481
- printFunctionName: getPrintFunctionName(options),
2482
- spacingInner: options && options.min ? ' ' : '\n',
2483
- spacingOuter: options && options.min ? '' : '\n'
2484
- };
2485
- };
2486
-
2487
- function createIndent(indent) {
2488
- return new Array(indent + 1).join(' ');
2489
- }
2490
- /**
2491
- * Returns a presentation string of your `val` object
2492
- * @param val any potential JavaScript object
2493
- * @param options Custom settings
2494
- */
2495
-
2496
- function format(val, options) {
2497
- if (options) {
2498
- validateOptions(options);
2499
-
2500
- if (options.plugins) {
2501
- const plugin = findPlugin(options.plugins, val);
2502
-
2503
- if (plugin !== null) {
2504
- return printPlugin(plugin, val, getConfig(options), '', 0, []);
2505
- }
2506
- }
2507
- }
2508
-
2509
- const basicResult = printBasicValue(
2510
- val,
2511
- getPrintFunctionName(options),
2512
- getEscapeRegex(options),
2513
- getEscapeString(options)
2514
- );
2515
-
2516
- if (basicResult !== null) {
2517
- return basicResult;
2518
- }
2519
-
2520
- return printComplexValue(val, getConfig(options), '', 0, []);
2521
- }
2522
-
2523
- const plugins = {
2524
- AsymmetricMatcher: _AsymmetricMatcher.default,
2525
- ConvertAnsi: _ConvertAnsi.default,
2526
- DOMCollection: _DOMCollection.default,
2527
- DOMElement: _DOMElement.default,
2528
- Immutable: _Immutable.default,
2529
- ReactElement: _ReactElement.default,
2530
- ReactTestComponent: _ReactTestComponent.default
2531
- };
2532
- plugins_1 = build.plugins = plugins;
2533
- var _default = format;
2534
- build.default = _default;
2535
-
2536
- const serialize$1 = (val, config, indentation, depth, refs, printer) => {
2537
- const name = val.getMockName();
2538
- const nameString = name === "vi.fn()" ? "" : ` ${name}`;
2539
- let callsString = "";
2540
- if (val.mock.calls.length !== 0) {
2541
- const indentationNext = indentation + config.indent;
2542
- callsString = ` {${config.spacingOuter}${indentationNext}"calls": ${printer(val.mock.calls, config, indentationNext, depth, refs)}${config.min ? ", " : ","}${config.spacingOuter}${indentationNext}"results": ${printer(val.mock.results, config, indentationNext, depth, refs)}${config.min ? "" : ","}${config.spacingOuter}${indentation}}`;
2543
- }
2544
- return `[MockFunction${nameString}]${callsString}`;
2545
- };
2546
- const test = (val) => val && !!val._isMockFunction;
2547
- const plugin = { serialize: serialize$1, test };
2548
-
2549
- const {
2550
- DOMCollection,
2551
- DOMElement,
2552
- Immutable,
2553
- ReactElement,
2554
- ReactTestComponent,
2555
- AsymmetricMatcher
2556
- } = plugins_1;
2557
- let PLUGINS = [
2558
- ReactTestComponent,
2559
- ReactElement,
2560
- DOMElement,
2561
- DOMCollection,
2562
- Immutable,
2563
- AsymmetricMatcher,
2564
- plugin
2565
- ];
2566
- const addSerializer = (plugin) => {
2567
- PLUGINS = [plugin].concat(PLUGINS);
2568
- };
2569
- const getSerializers = () => PLUGINS;
2570
-
2571
- const SNAPSHOT_VERSION = "1";
2572
- const writeSnapshotVersion = () => `// Vitest Snapshot v${SNAPSHOT_VERSION}, https://vitest.dev/guide/snapshot.html`;
2573
- const testNameToKey = (testName, count) => `${testName} ${count}`;
2574
- const keyToTestName = (key) => {
2575
- if (!/ \d+$/.test(key))
2576
- throw new Error("Snapshot keys must end with a number.");
2577
- return key.replace(/ \d+$/, "");
2578
- };
2579
- const getSnapshotData = (content, options) => {
2580
- const update = options.updateSnapshot;
2581
- const data = /* @__PURE__ */ Object.create(null);
2582
- let snapshotContents = "";
2583
- let dirty = false;
2584
- if (content != null) {
2585
- try {
2586
- snapshotContents = content;
2587
- const populate = new Function("exports", snapshotContents);
2588
- populate(data);
2589
- } catch {
2590
- }
2591
- }
2592
- const isInvalid = snapshotContents;
2593
- if ((update === "all" || update === "new") && isInvalid)
2594
- dirty = true;
2595
- return { data, dirty };
2596
- };
2597
- const addExtraLineBreaks = (string) => string.includes("\n") ? `
2598
- ${string}
2599
- ` : string;
2600
- const removeExtraLineBreaks = (string) => string.length > 2 && string.startsWith("\n") && string.endsWith("\n") ? string.slice(1, -1) : string;
2601
- const escapeRegex = true;
2602
- const printFunctionName = false;
2603
- function serialize(val, indent = 2, formatOverrides = {}) {
2604
- return normalizeNewlines(
2605
- format_1(val, {
2606
- escapeRegex,
2607
- indent,
2608
- plugins: getSerializers(),
2609
- printFunctionName,
2610
- ...formatOverrides
2611
- })
2612
- );
2613
- }
2614
- function escapeBacktickString(str) {
2615
- return str.replace(/`|\\|\${/g, "\\$&");
2616
- }
2617
- function printBacktickString(str) {
2618
- return `\`${escapeBacktickString(str)}\``;
2619
- }
2620
- async function ensureDirectoryExists(filePath) {
2621
- try {
2622
- const environment = getSnapshotEnvironment();
2623
- await environment.prepareDirectory(join(dirname(filePath)));
2624
- } catch {
2625
- }
2626
- }
2627
- function normalizeNewlines(string) {
2628
- return string.replace(/\r\n|\r/g, "\n");
2629
- }
2630
- async function saveSnapshotFile(snapshotData, snapshotPath) {
2631
- const environment = getSnapshotEnvironment();
2632
- const snapshots = Object.keys(snapshotData).sort(naturalCompare$1.exports).map(
2633
- (key) => `exports[${printBacktickString(key)}] = ${printBacktickString(normalizeNewlines(snapshotData[key]))};`
2634
- );
2635
- const content = `${writeSnapshotVersion()}
2636
-
2637
- ${snapshots.join("\n\n")}
2638
- `;
2639
- const oldContent = await environment.readSnapshotFile(snapshotPath);
2640
- const skipWriting = oldContent && oldContent === content;
2641
- if (skipWriting)
2642
- return;
2643
- await ensureDirectoryExists(snapshotPath);
2644
- await environment.saveSnapshotFile(
2645
- snapshotPath,
2646
- content
2647
- );
2648
- }
2649
- function prepareExpected(expected) {
2650
- function findStartIndent() {
2651
- var _a, _b;
2652
- const matchObject = /^( +)}\s+$/m.exec(expected || "");
2653
- const objectIndent = (_a = matchObject == null ? void 0 : matchObject[1]) == null ? void 0 : _a.length;
2654
- if (objectIndent)
2655
- return objectIndent;
2656
- const matchText = /^\n( +)"/.exec(expected || "");
2657
- return ((_b = matchText == null ? void 0 : matchText[1]) == null ? void 0 : _b.length) || 0;
2658
- }
2659
- const startIndent = findStartIndent();
2660
- let expectedTrimmed = expected == null ? void 0 : expected.trim();
2661
- if (startIndent) {
2662
- expectedTrimmed = expectedTrimmed == null ? void 0 : expectedTrimmed.replace(new RegExp(`^${" ".repeat(startIndent)}`, "gm"), "").replace(/ +}$/, "}");
2663
- }
2664
- return expectedTrimmed;
2665
- }
2666
- function deepMergeArray(target = [], source = []) {
2667
- const mergedOutput = Array.from(target);
2668
- source.forEach((sourceElement, index) => {
2669
- const targetElement = mergedOutput[index];
2670
- if (Array.isArray(target[index])) {
2671
- mergedOutput[index] = deepMergeArray(target[index], sourceElement);
2672
- } else if (isObject(targetElement)) {
2673
- mergedOutput[index] = deepMergeSnapshot(target[index], sourceElement);
2674
- } else {
2675
- mergedOutput[index] = sourceElement;
2676
- }
2677
- });
2678
- return mergedOutput;
2679
- }
2680
- function deepMergeSnapshot(target, source) {
2681
- if (isObject(target) && isObject(source)) {
2682
- const mergedOutput = { ...target };
2683
- Object.keys(source).forEach((key) => {
2684
- if (isObject(source[key]) && !source[key].$$typeof) {
2685
- if (!(key in target))
2686
- Object.assign(mergedOutput, { [key]: source[key] });
2687
- else
2688
- mergedOutput[key] = deepMergeSnapshot(target[key], source[key]);
2689
- } else if (Array.isArray(source[key])) {
2690
- mergedOutput[key] = deepMergeArray(target[key], source[key]);
2691
- } else {
2692
- Object.assign(mergedOutput, { [key]: source[key] });
2693
- }
154
+ function recordAsyncExpect(test, promise) {
155
+ if (test) {
156
+ promise = promise.finally(() => {
157
+ const index = test.promises.indexOf(promise);
158
+ if (index !== -1)
159
+ test.promises.splice(index, 1);
2694
160
  });
2695
- return mergedOutput;
2696
- } else if (Array.isArray(target) && Array.isArray(source)) {
2697
- return deepMergeArray(target, source);
2698
- }
2699
- return target;
2700
- }
2701
-
2702
- async function saveInlineSnapshots(snapshots) {
2703
- const environment = getSnapshotEnvironment();
2704
- const MagicString = (await import('./vendor-magic-string.es.b3bc5745.js').then(function (n) { return n.m; })).default;
2705
- const files = new Set(snapshots.map((i) => i.file));
2706
- await Promise.all(Array.from(files).map(async (file) => {
2707
- const snaps = snapshots.filter((i) => i.file === file);
2708
- const code = await environment.readSnapshotFile(file);
2709
- const s = new MagicString(code);
2710
- for (const snap of snaps) {
2711
- const index = positionToOffset(code, snap.line, snap.column);
2712
- replaceInlineSnap(code, s, index, snap.snapshot);
2713
- }
2714
- const transformed = s.toString();
2715
- if (transformed !== code)
2716
- await environment.saveSnapshotFile(file, transformed);
2717
- }));
2718
- }
2719
- const startObjectRegex = /(?:toMatchInlineSnapshot|toThrowErrorMatchingInlineSnapshot)\s*\(\s*(?:\/\*[\S\s]*\*\/\s*|\/\/.*\s+)*\s*({)/m;
2720
- function replaceObjectSnap(code, s, index, newSnap) {
2721
- code = code.slice(index);
2722
- const startMatch = startObjectRegex.exec(code);
2723
- if (!startMatch)
2724
- return false;
2725
- code = code.slice(startMatch.index);
2726
- const charIndex = getCallLastIndex(code);
2727
- if (charIndex === null)
2728
- return false;
2729
- s.appendLeft(index + startMatch.index + charIndex, `, ${prepareSnapString(newSnap, code, index)}`);
2730
- return true;
2731
- }
2732
- function prepareSnapString(snap, source, index) {
2733
- const lineNumber = offsetToLineNumber(source, index);
2734
- const line = source.split(lineSplitRE)[lineNumber - 1];
2735
- const indent = line.match(/^\s*/)[0] || "";
2736
- const indentNext = indent.includes(" ") ? `${indent} ` : `${indent} `;
2737
- const lines = snap.trim().replace(/\\/g, "\\\\").split(/\n/g);
2738
- const isOneline = lines.length <= 1;
2739
- const quote = isOneline ? "'" : "`";
2740
- if (isOneline)
2741
- return `'${lines.join("\n").replace(/'/g, "\\'")}'`;
2742
- else
2743
- return `${quote}
2744
- ${lines.map((i) => i ? indentNext + i : "").join("\n").replace(/`/g, "\\`").replace(/\${/g, "\\${")}
2745
- ${indent}${quote}`;
2746
- }
2747
- const startRegex = /(?:toMatchInlineSnapshot|toThrowErrorMatchingInlineSnapshot)\s*\(\s*(?:\/\*[\S\s]*\*\/\s*|\/\/.*\s+)*\s*[\w_$]*(['"`\)])/m;
2748
- function replaceInlineSnap(code, s, index, newSnap) {
2749
- const startMatch = startRegex.exec(code.slice(index));
2750
- if (!startMatch)
2751
- return replaceObjectSnap(code, s, index, newSnap);
2752
- const quote = startMatch[1];
2753
- const startIndex = index + startMatch.index + startMatch[0].length;
2754
- const snapString = prepareSnapString(newSnap, code, index);
2755
- if (quote === ")") {
2756
- s.appendRight(startIndex - 1, snapString);
2757
- return true;
2758
- }
2759
- const quoteEndRE = new RegExp(`(?:^|[^\\\\])${quote}`);
2760
- const endMatch = quoteEndRE.exec(code.slice(startIndex));
2761
- if (!endMatch)
2762
- return false;
2763
- const endIndex = startIndex + endMatch.index + endMatch[0].length;
2764
- s.overwrite(startIndex - 1, endIndex, snapString);
2765
- return true;
2766
- }
2767
- const INDENTATION_REGEX = /^([^\S\n]*)\S/m;
2768
- function stripSnapshotIndentation(inlineSnapshot) {
2769
- const match = inlineSnapshot.match(INDENTATION_REGEX);
2770
- if (!match || !match[1]) {
2771
- return inlineSnapshot;
2772
- }
2773
- const indentation = match[1];
2774
- const lines = inlineSnapshot.split(/\n/g);
2775
- if (lines.length <= 2) {
2776
- return inlineSnapshot;
2777
- }
2778
- if (lines[0].trim() !== "" || lines[lines.length - 1].trim() !== "") {
2779
- return inlineSnapshot;
2780
- }
2781
- for (let i = 1; i < lines.length - 1; i++) {
2782
- if (lines[i] !== "") {
2783
- if (lines[i].indexOf(indentation) !== 0) {
2784
- return inlineSnapshot;
2785
- }
2786
- lines[i] = lines[i].substring(indentation.length);
2787
- }
2788
- }
2789
- lines[lines.length - 1] = "";
2790
- inlineSnapshot = lines.join("\n");
2791
- return inlineSnapshot;
2792
- }
2793
-
2794
- class SnapshotState {
2795
- constructor(testFilePath, snapshotPath, snapshotContent, options) {
2796
- this.testFilePath = testFilePath;
2797
- this.snapshotPath = snapshotPath;
2798
- const { data, dirty } = getSnapshotData(
2799
- snapshotContent,
2800
- options
2801
- );
2802
- this._fileExists = snapshotContent != null;
2803
- this._initialData = data;
2804
- this._snapshotData = data;
2805
- this._dirty = dirty;
2806
- this._inlineSnapshots = [];
2807
- this._uncheckedKeys = new Set(Object.keys(this._snapshotData));
2808
- this._counters = /* @__PURE__ */ new Map();
2809
- this.expand = options.expand || false;
2810
- this.added = 0;
2811
- this.matched = 0;
2812
- this.unmatched = 0;
2813
- this._updateSnapshot = options.updateSnapshot;
2814
- this.updated = 0;
2815
- this._snapshotFormat = {
2816
- printBasicPrototype: false,
2817
- ...options.snapshotFormat
2818
- };
2819
- this._environment = getSnapshotEnvironment();
2820
- }
2821
- static async create(testFilePath, options) {
2822
- const environment = getSnapshotEnvironment();
2823
- const snapshotPath = await environment.resolvePath(testFilePath);
2824
- const content = await environment.readSnapshotFile(snapshotPath);
2825
- return new SnapshotState(testFilePath, snapshotPath, content, options);
2826
- }
2827
- markSnapshotsAsCheckedForTest(testName) {
2828
- this._uncheckedKeys.forEach((uncheckedKey) => {
2829
- if (keyToTestName(uncheckedKey) === testName)
2830
- this._uncheckedKeys.delete(uncheckedKey);
2831
- });
2832
- }
2833
- _inferInlineSnapshotStack(stacks) {
2834
- const promiseIndex = stacks.findIndex((i) => i.method.match(/__VITEST_(RESOLVES|REJECTS)__/));
2835
- if (promiseIndex !== -1)
2836
- return stacks[promiseIndex + 3];
2837
- const stackIndex = stacks.findIndex((i) => i.method.includes("__VITEST_INLINE_SNAPSHOT__"));
2838
- return stackIndex !== -1 ? stacks[stackIndex + 2] : null;
2839
- }
2840
- _addSnapshot(key, receivedSerialized, options) {
2841
- this._dirty = true;
2842
- if (options.isInline) {
2843
- const stacks = parseErrorStacktrace(options.error || new Error("snapshot"), true);
2844
- const stack = this._inferInlineSnapshotStack(stacks);
2845
- if (!stack) {
2846
- throw new Error(
2847
- `Vitest: Couldn't infer stack frame for inline snapshot.
2848
- ${JSON.stringify(stacks)}`
2849
- );
2850
- }
2851
- stack.column--;
2852
- this._inlineSnapshots.push({
2853
- snapshot: receivedSerialized,
2854
- ...stack
2855
- });
2856
- } else {
2857
- this._snapshotData[key] = receivedSerialized;
2858
- }
2859
- }
2860
- clear() {
2861
- this._snapshotData = this._initialData;
2862
- this._counters = /* @__PURE__ */ new Map();
2863
- this.added = 0;
2864
- this.matched = 0;
2865
- this.unmatched = 0;
2866
- this.updated = 0;
2867
- this._dirty = false;
2868
- }
2869
- async save() {
2870
- const hasExternalSnapshots = Object.keys(this._snapshotData).length;
2871
- const hasInlineSnapshots = this._inlineSnapshots.length;
2872
- const isEmpty = !hasExternalSnapshots && !hasInlineSnapshots;
2873
- const status = {
2874
- deleted: false,
2875
- saved: false
2876
- };
2877
- if ((this._dirty || this._uncheckedKeys.size) && !isEmpty) {
2878
- if (hasExternalSnapshots) {
2879
- await saveSnapshotFile(this._snapshotData, this.snapshotPath);
2880
- this._fileExists = true;
2881
- }
2882
- if (hasInlineSnapshots)
2883
- await saveInlineSnapshots(this._inlineSnapshots);
2884
- status.saved = true;
2885
- } else if (!hasExternalSnapshots && this._fileExists) {
2886
- if (this._updateSnapshot === "all") {
2887
- await this._environment.removeSnapshotFile(this.snapshotPath);
2888
- this._fileExists = false;
2889
- }
2890
- status.deleted = true;
2891
- }
2892
- return status;
2893
- }
2894
- getUncheckedCount() {
2895
- return this._uncheckedKeys.size || 0;
2896
- }
2897
- getUncheckedKeys() {
2898
- return Array.from(this._uncheckedKeys);
2899
- }
2900
- removeUncheckedKeys() {
2901
- if (this._updateSnapshot === "all" && this._uncheckedKeys.size) {
2902
- this._dirty = true;
2903
- this._uncheckedKeys.forEach((key) => delete this._snapshotData[key]);
2904
- this._uncheckedKeys.clear();
2905
- }
2906
- }
2907
- match({
2908
- testName,
2909
- received,
2910
- key,
2911
- inlineSnapshot,
2912
- isInline,
2913
- error
2914
- }) {
2915
- this._counters.set(testName, (this._counters.get(testName) || 0) + 1);
2916
- const count = Number(this._counters.get(testName));
2917
- if (!key)
2918
- key = testNameToKey(testName, count);
2919
- if (!(isInline && this._snapshotData[key] !== void 0))
2920
- this._uncheckedKeys.delete(key);
2921
- const receivedSerialized = addExtraLineBreaks(serialize(received, void 0, this._snapshotFormat));
2922
- const expected = isInline ? inlineSnapshot : this._snapshotData[key];
2923
- const expectedTrimmed = prepareExpected(expected);
2924
- const pass = expectedTrimmed === prepareExpected(receivedSerialized);
2925
- const hasSnapshot = expected !== void 0;
2926
- const snapshotIsPersisted = isInline || this._fileExists;
2927
- if (pass && !isInline) {
2928
- this._snapshotData[key] = receivedSerialized;
2929
- }
2930
- if (hasSnapshot && this._updateSnapshot === "all" || (!hasSnapshot || !snapshotIsPersisted) && (this._updateSnapshot === "new" || this._updateSnapshot === "all")) {
2931
- if (this._updateSnapshot === "all") {
2932
- if (!pass) {
2933
- if (hasSnapshot)
2934
- this.updated++;
2935
- else
2936
- this.added++;
2937
- this._addSnapshot(key, receivedSerialized, { error, isInline });
2938
- } else {
2939
- this.matched++;
2940
- }
2941
- } else {
2942
- this._addSnapshot(key, receivedSerialized, { error, isInline });
2943
- this.added++;
2944
- }
2945
- return {
2946
- actual: "",
2947
- count,
2948
- expected: "",
2949
- key,
2950
- pass: true
2951
- };
2952
- } else {
2953
- if (!pass) {
2954
- this.unmatched++;
2955
- return {
2956
- actual: removeExtraLineBreaks(receivedSerialized),
2957
- count,
2958
- expected: expectedTrimmed !== void 0 ? removeExtraLineBreaks(expectedTrimmed) : void 0,
2959
- key,
2960
- pass: false
2961
- };
2962
- } else {
2963
- this.matched++;
2964
- return {
2965
- actual: "",
2966
- count,
2967
- expected: "",
2968
- key,
2969
- pass: true
2970
- };
2971
- }
2972
- }
2973
- }
2974
- async pack() {
2975
- const snapshot = {
2976
- filepath: this.testFilePath,
2977
- added: 0,
2978
- fileDeleted: false,
2979
- matched: 0,
2980
- unchecked: 0,
2981
- uncheckedKeys: [],
2982
- unmatched: 0,
2983
- updated: 0
2984
- };
2985
- const uncheckedCount = this.getUncheckedCount();
2986
- const uncheckedKeys = this.getUncheckedKeys();
2987
- if (uncheckedCount)
2988
- this.removeUncheckedKeys();
2989
- const status = await this.save();
2990
- snapshot.fileDeleted = status.deleted;
2991
- snapshot.added = this.added;
2992
- snapshot.matched = this.matched;
2993
- snapshot.unmatched = this.unmatched;
2994
- snapshot.updated = this.updated;
2995
- snapshot.unchecked = !status.deleted ? uncheckedCount : 0;
2996
- snapshot.uncheckedKeys = Array.from(uncheckedKeys);
2997
- return snapshot;
161
+ if (!test.promises)
162
+ test.promises = [];
163
+ test.promises.push(promise);
2998
164
  }
165
+ return promise;
2999
166
  }
3000
167
 
3001
- class SnapshotClient {
3002
- constructor() {
3003
- this.snapshotStateMap = /* @__PURE__ */ new Map();
3004
- }
3005
- async setTest(test) {
3006
- var _a;
3007
- this.test = test;
3008
- if (((_a = this.snapshotState) == null ? void 0 : _a.testFilePath) !== this.test.file.filepath) {
3009
- this.saveCurrent();
3010
- const filePath = this.test.file.filepath;
3011
- if (!this.getSnapshotState(test)) {
3012
- this.snapshotStateMap.set(
3013
- filePath,
3014
- await SnapshotState.create(
3015
- filePath,
3016
- getWorkerState().config.snapshotOptions
3017
- )
3018
- );
3019
- }
3020
- this.snapshotState = this.getSnapshotState(test);
3021
- }
3022
- }
3023
- getSnapshotState(test) {
3024
- return this.snapshotStateMap.get(test.file.filepath);
3025
- }
3026
- clearTest() {
3027
- this.test = void 0;
3028
- }
3029
- skipTestSnapshots(test) {
3030
- var _a;
3031
- (_a = this.snapshotState) == null ? void 0 : _a.markSnapshotsAsCheckedForTest(test.name);
3032
- }
3033
- assert(options) {
3034
- const {
3035
- test = this.test,
3036
- message,
3037
- isInline = false,
3038
- properties,
3039
- inlineSnapshot,
3040
- error,
3041
- errorMessage
3042
- } = options;
3043
- let { received } = options;
3044
- if (!test)
3045
- throw new Error("Snapshot cannot be used outside of test");
3046
- if (typeof properties === "object") {
3047
- if (typeof received !== "object" || !received)
3048
- throw new Error("Received value must be an object when the matcher has properties");
3049
- try {
3050
- const pass2 = equals(received, properties, [iterableEquality, subsetEquality]);
3051
- if (!pass2)
3052
- expect(received).equals(properties);
3053
- else
3054
- received = deepMergeSnapshot(received, properties);
3055
- } catch (err) {
3056
- err.message = errorMessage || "Snapshot mismatched";
3057
- throw err;
3058
- }
3059
- }
3060
- const testName = [
3061
- ...getNames(test).slice(1),
3062
- ...message ? [message] : []
3063
- ].join(" > ");
3064
- const snapshotState = this.getSnapshotState(test);
3065
- const { actual, expected, key, pass } = snapshotState.match({
3066
- testName,
3067
- received,
3068
- isInline,
3069
- error,
3070
- inlineSnapshot
3071
- });
3072
- if (!pass) {
3073
- try {
3074
- expect(actual.trim()).equals(expected ? expected.trim() : "");
3075
- } catch (error2) {
3076
- error2.message = errorMessage || `Snapshot \`${key || "unknown"}\` mismatched`;
3077
- throw error2;
3078
- }
3079
- }
3080
- }
3081
- async saveCurrent() {
3082
- if (!this.snapshotState)
3083
- return;
3084
- const result = await this.snapshotState.pack();
3085
- await rpc().snapshotSaved(result);
3086
- this.snapshotState = void 0;
3087
- }
3088
- clear() {
3089
- this.snapshotStateMap.clear();
168
+ class VitestSnapshotClient extends SnapshotClient {
169
+ equalityCheck(received, expected) {
170
+ return equals(received, expected, [iterableEquality, subsetEquality]);
3090
171
  }
3091
172
  }
3092
173
 
3093
174
  let _client;
3094
175
  function getSnapshotClient() {
3095
176
  if (!_client)
3096
- _client = new SnapshotClient();
177
+ _client = new VitestSnapshotClient();
3097
178
  return _client;
3098
179
  }
3099
- const getErrorMessage = (err) => {
180
+ function getErrorMessage(err) {
3100
181
  if (err instanceof Error)
3101
182
  return err.message;
3102
183
  return err;
3103
- };
3104
- const getErrorString = (expected, promise) => {
184
+ }
185
+ function getErrorString(expected, promise) {
3105
186
  if (typeof expected !== "function") {
3106
187
  if (!promise)
3107
188
  throw new Error(`expected must be a function, received ${typeof expected}`);
@@ -3113,8 +194,17 @@ const getErrorString = (expected, promise) => {
3113
194
  return getErrorMessage(e);
3114
195
  }
3115
196
  throw new Error("snapshot function didn't throw");
3116
- };
197
+ }
3117
198
  const SnapshotPlugin = (chai, utils) => {
199
+ const getTestNames = (test) => {
200
+ var _a;
201
+ if (!test)
202
+ return {};
203
+ return {
204
+ filepath: (_a = test.file) == null ? void 0 : _a.filepath,
205
+ name: getNames(test).slice(1).join(" > ")
206
+ };
207
+ };
3118
208
  for (const key of ["matchSnapshot", "toMatchSnapshot"]) {
3119
209
  utils.addMethod(
3120
210
  chai.Assertion.prototype,
@@ -3129,19 +219,39 @@ const SnapshotPlugin = (chai, utils) => {
3129
219
  const errorMessage = utils.flag(this, "message");
3130
220
  getSnapshotClient().assert({
3131
221
  received: expected,
3132
- test,
3133
222
  message,
3134
223
  isInline: false,
3135
224
  properties,
3136
- errorMessage
225
+ errorMessage,
226
+ ...getTestNames(test)
3137
227
  });
3138
228
  }
3139
229
  );
3140
230
  }
231
+ utils.addMethod(
232
+ chai.Assertion.prototype,
233
+ "toMatchFileSnapshot",
234
+ function(file, message) {
235
+ const expected = utils.flag(this, "object");
236
+ const test = utils.flag(this, "vitest-test");
237
+ const errorMessage = utils.flag(this, "message");
238
+ const promise = getSnapshotClient().assertRaw({
239
+ received: expected,
240
+ message,
241
+ isInline: false,
242
+ rawSnapshot: {
243
+ file
244
+ },
245
+ errorMessage,
246
+ ...getTestNames(test)
247
+ });
248
+ return recordAsyncExpect(test, promise);
249
+ }
250
+ );
3141
251
  utils.addMethod(
3142
252
  chai.Assertion.prototype,
3143
253
  "toMatchInlineSnapshot",
3144
- function __VITEST_INLINE_SNAPSHOT__(properties, inlineSnapshot, message) {
254
+ function __INLINE_SNAPSHOT__(properties, inlineSnapshot, message) {
3145
255
  const expected = utils.flag(this, "object");
3146
256
  const error = utils.flag(this, "error");
3147
257
  const test = utils.flag(this, "vitest-test");
@@ -3155,13 +265,13 @@ const SnapshotPlugin = (chai, utils) => {
3155
265
  const errorMessage = utils.flag(this, "message");
3156
266
  getSnapshotClient().assert({
3157
267
  received: expected,
3158
- test,
3159
268
  message,
3160
269
  isInline: true,
3161
270
  properties,
3162
271
  inlineSnapshot,
3163
272
  error,
3164
- errorMessage
273
+ errorMessage,
274
+ ...getTestNames(test)
3165
275
  });
3166
276
  }
3167
277
  );
@@ -3175,16 +285,16 @@ const SnapshotPlugin = (chai, utils) => {
3175
285
  const errorMessage = utils.flag(this, "message");
3176
286
  getSnapshotClient().assert({
3177
287
  received: getErrorString(expected, promise),
3178
- test,
3179
288
  message,
3180
- errorMessage
289
+ errorMessage,
290
+ ...getTestNames(test)
3181
291
  });
3182
292
  }
3183
293
  );
3184
294
  utils.addMethod(
3185
295
  chai.Assertion.prototype,
3186
296
  "toThrowErrorMatchingInlineSnapshot",
3187
- function __VITEST_INLINE_SNAPSHOT__(inlineSnapshot, message) {
297
+ function __INLINE_SNAPSHOT__(inlineSnapshot, message) {
3188
298
  const expected = utils.flag(this, "object");
3189
299
  const error = utils.flag(this, "error");
3190
300
  const test = utils.flag(this, "vitest-test");
@@ -3192,12 +302,12 @@ const SnapshotPlugin = (chai, utils) => {
3192
302
  const errorMessage = utils.flag(this, "message");
3193
303
  getSnapshotClient().assert({
3194
304
  received: getErrorString(expected, promise),
3195
- test,
3196
305
  message,
3197
306
  inlineSnapshot,
3198
307
  isInline: true,
3199
308
  error,
3200
- errorMessage
309
+ errorMessage,
310
+ ...getTestNames(test)
3201
311
  });
3202
312
  }
3203
313
  );
@@ -3220,8 +330,9 @@ function createExpect(test) {
3220
330
  const { assertionCalls } = getState(expect);
3221
331
  setState({ assertionCalls: assertionCalls + 1 }, expect);
3222
332
  const assert2 = chai$1.expect(value, message);
3223
- if (test)
3224
- return assert2.withTest(test);
333
+ const _test = test || getCurrentTest();
334
+ if (_test)
335
+ return assert2.withTest(_test);
3225
336
  else
3226
337
  return assert2;
3227
338
  };
@@ -3230,6 +341,7 @@ function createExpect(test) {
3230
341
  expect.setState = (state) => setState(state, expect);
3231
342
  const globalState = getState(globalThis[GLOBAL_EXPECT]) || {};
3232
343
  setState({
344
+ // this should also add "snapshotState" that is added conditionally
3233
345
  ...globalState,
3234
346
  assertionCalls: 0,
3235
347
  isExpectingAssertions: false,
@@ -3269,6 +381,9 @@ Object.defineProperty(globalThis, GLOBAL_EXPECT, {
3269
381
  writable: true,
3270
382
  configurable: true
3271
383
  });
384
+ function setupChaiConfig(config) {
385
+ Object.assign(chai$1.config, config);
386
+ }
3272
387
 
3273
388
  /**
3274
389
  * A reference to the global object
@@ -6084,6 +3199,7 @@ function createVitest() {
6084
3199
  _timers.clearAllTimers();
6085
3200
  return this;
6086
3201
  },
3202
+ // mocks
6087
3203
  spyOn,
6088
3204
  fn,
6089
3205
  mock(path, factory) {
@@ -6189,4 +3305,4 @@ function createVitest() {
6189
3305
  const vitest = createVitest();
6190
3306
  const vi = vitest;
6191
3307
 
6192
- export { RealDate as R, vi as a, bench as b, createExpect as c, getSnapshotClient as d, getBenchOptions as e, getBenchFn as f, globalExpect as g, vitest as v };
3308
+ export { RealDate as R, getBenchOptions as a, getBenchFn as b, createExpect as c, globalExpect as d, bench as e, vitest as f, getSnapshotClient as g, setupChaiConfig as s, vi as v };