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