@shware/security 2.2.2 → 2.3.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.
@@ -108,3366 +108,23 @@ var require_dist = __commonJS({
108
108
  // src/session/__tests__/redis.test.ts
109
109
  var import_ioredis = __toESM(require("ioredis"), 1);
110
110
 
111
- // ../../node_modules/.pnpm/vitest@4.1.0_@opentelemetry+api@1.9.0_@types+node@25.3.0_vite@7.3.1_@types+node@25.3.0__1256cd9683254972294f67b42fe9fd18/node_modules/vitest/dist/index.js
112
- var import_test_CTcmp4Su = require("./chunks/test.CTcmp4Su.js.cjs");
113
- var import_benchmark_D0SlKNbZ = require("./chunks/benchmark.D0SlKNbZ.js.cjs");
111
+ // ../../node_modules/.pnpm/vitest@4.1.2_@opentelemetry+api@1.9.0_@types+node@25.3.0_vite@7.3.1_@types+node@25.3.0__e6bcf260a45e49571a6b9e648e155cb6/node_modules/vitest/dist/index.js
112
+ var import_test_p_J6dB8a = require("./chunks/test.p_J6dB8a.js.cjs");
113
+ var import_benchmark_CX_oY03V = require("./chunks/benchmark.CX_oY03V.js.cjs");
114
114
  var import_evaluatedModules_Dg1zASAC = require("./chunks/evaluatedModules.Dg1zASAC.js.cjs");
115
- var import_index_DlDSLQD3 = require("./chunks/index.DlDSLQD3.js.cjs");
115
+ var import_index_DOa3dzoN = require("./chunks/index.DOa3dzoN.js.cjs");
116
116
  var import_expect_type = __toESM(require_dist(), 1);
117
117
 
118
- // ../../node_modules/.pnpm/tinyrainbow@3.0.3/node_modules/tinyrainbow/dist/index.js
119
- var d = {
120
- reset: [0, 0],
121
- bold: [1, 22, "\x1B[22m\x1B[1m"],
122
- dim: [2, 22, "\x1B[22m\x1B[2m"],
123
- italic: [3, 23],
124
- underline: [4, 24],
125
- inverse: [7, 27],
126
- hidden: [8, 28],
127
- strikethrough: [9, 29],
128
- black: [30, 39],
129
- red: [31, 39],
130
- green: [32, 39],
131
- yellow: [33, 39],
132
- blue: [34, 39],
133
- magenta: [35, 39],
134
- cyan: [36, 39],
135
- white: [37, 39],
136
- gray: [90, 39],
137
- bgBlack: [40, 49],
138
- bgRed: [41, 49],
139
- bgGreen: [42, 49],
140
- bgYellow: [43, 49],
141
- bgBlue: [44, 49],
142
- bgMagenta: [45, 49],
143
- bgCyan: [46, 49],
144
- bgWhite: [47, 49],
145
- blackBright: [90, 39],
146
- redBright: [91, 39],
147
- greenBright: [92, 39],
148
- yellowBright: [93, 39],
149
- blueBright: [94, 39],
150
- magentaBright: [95, 39],
151
- cyanBright: [96, 39],
152
- whiteBright: [97, 39],
153
- bgBlackBright: [100, 49],
154
- bgRedBright: [101, 49],
155
- bgGreenBright: [102, 49],
156
- bgYellowBright: [103, 49],
157
- bgBlueBright: [104, 49],
158
- bgMagentaBright: [105, 49],
159
- bgCyanBright: [106, 49],
160
- bgWhiteBright: [107, 49]
161
- };
162
- function g(e2) {
163
- return String(e2);
164
- }
165
- g.open = "";
166
- g.close = "";
167
- function h() {
168
- let e2 = typeof process != "undefined" ? process : void 0, n2 = (e2 == null ? void 0 : e2.env) || {}, a4 = n2.FORCE_TTY !== "false", i3 = (e2 == null ? void 0 : e2.argv) || [];
169
- return !("NO_COLOR" in n2 || i3.includes("--no-color")) && ("FORCE_COLOR" in n2 || i3.includes("--color") || (e2 == null ? void 0 : e2.platform) === "win32" || a4 && n2.TERM !== "dumb" || "CI" in n2) || typeof window != "undefined" && !!window.chrome;
170
- }
171
- function f() {
172
- let e2 = h(), n2 = (r2, t2, u2, o2) => {
173
- let l2 = "", s3 = 0;
174
- do
175
- l2 += r2.substring(s3, o2) + u2, s3 = o2 + t2.length, o2 = r2.indexOf(t2, s3);
176
- while (~o2);
177
- return l2 + r2.substring(s3);
178
- }, a4 = (r2, t2, u2 = r2) => {
179
- let o2 = (l2) => {
180
- let s3 = String(l2), b4 = s3.indexOf(t2, r2.length);
181
- return ~b4 ? r2 + n2(s3, t2, u2, b4) + t2 : r2 + s3 + t2;
182
- };
183
- return o2.open = r2, o2.close = t2, o2;
184
- }, i3 = {
185
- isColorSupported: e2
186
- }, c3 = (r2) => `\x1B[${r2}m`;
187
- for (let r2 in d) {
188
- let t2 = d[r2];
189
- i3[r2] = e2 ? a4(
190
- c3(t2[0]),
191
- c3(t2[1]),
192
- t2[2]
193
- ) : g;
194
- }
195
- return i3;
196
- }
197
- var C = f();
198
-
199
- // ../../node_modules/.pnpm/@vitest+pretty-format@4.1.0/node_modules/@vitest/pretty-format/dist/index.js
200
- function _mergeNamespaces(n2, m2) {
201
- m2.forEach(function(e2) {
202
- e2 && typeof e2 !== "string" && !Array.isArray(e2) && Object.keys(e2).forEach(function(k2) {
203
- if (k2 !== "default" && !(k2 in n2)) {
204
- var d3 = Object.getOwnPropertyDescriptor(e2, k2);
205
- Object.defineProperty(n2, k2, d3.get ? d3 : {
206
- enumerable: true,
207
- get: function() {
208
- return e2[k2];
209
- }
210
- });
211
- }
212
- });
213
- });
214
- return Object.freeze(n2);
215
- }
216
- function getKeysOfEnumerableProperties(object, compareKeys) {
217
- const rawKeys = Object.keys(object);
218
- const keys = compareKeys === null ? rawKeys : rawKeys.sort(compareKeys);
219
- if (Object.getOwnPropertySymbols) {
220
- for (const symbol of Object.getOwnPropertySymbols(object)) {
221
- if (Object.getOwnPropertyDescriptor(object, symbol).enumerable) {
222
- keys.push(symbol);
223
- }
224
- }
225
- }
226
- return keys;
227
- }
228
- function printIteratorEntries(iterator, config, indentation, depth, refs, printer2, separator = ": ") {
229
- let result = "";
230
- let width = 0;
231
- let current = iterator.next();
232
- if (!current.done) {
233
- result += config.spacingOuter;
234
- const indentationNext = indentation + config.indent;
235
- while (!current.done) {
236
- result += indentationNext;
237
- if (width++ === config.maxWidth) {
238
- result += "\u2026";
239
- break;
240
- }
241
- const name = printer2(current.value[0], config, indentationNext, depth, refs);
242
- const value = printer2(current.value[1], config, indentationNext, depth, refs);
243
- result += name + separator + value;
244
- current = iterator.next();
245
- if (!current.done) {
246
- result += `,${config.spacingInner}`;
247
- } else if (!config.min) {
248
- result += ",";
249
- }
250
- }
251
- result += config.spacingOuter + indentation;
252
- }
253
- return result;
254
- }
255
- function printIteratorValues(iterator, config, indentation, depth, refs, printer2) {
256
- let result = "";
257
- let width = 0;
258
- let current = iterator.next();
259
- if (!current.done) {
260
- result += config.spacingOuter;
261
- const indentationNext = indentation + config.indent;
262
- while (!current.done) {
263
- result += indentationNext;
264
- if (width++ === config.maxWidth) {
265
- result += "\u2026";
266
- break;
267
- }
268
- result += printer2(current.value, config, indentationNext, depth, refs);
269
- current = iterator.next();
270
- if (!current.done) {
271
- result += `,${config.spacingInner}`;
272
- } else if (!config.min) {
273
- result += ",";
274
- }
275
- }
276
- result += config.spacingOuter + indentation;
277
- }
278
- return result;
279
- }
280
- function printListItems(list, config, indentation, depth, refs, printer2) {
281
- let result = "";
282
- list = list instanceof ArrayBuffer ? new DataView(list) : list;
283
- const isDataView = (l2) => l2 instanceof DataView;
284
- const length = isDataView(list) ? list.byteLength : list.length;
285
- if (length > 0) {
286
- result += config.spacingOuter;
287
- const indentationNext = indentation + config.indent;
288
- for (let i3 = 0; i3 < length; i3++) {
289
- result += indentationNext;
290
- if (i3 === config.maxWidth) {
291
- result += "\u2026";
292
- break;
293
- }
294
- if (isDataView(list) || i3 in list) {
295
- result += printer2(isDataView(list) ? list.getInt8(i3) : list[i3], config, indentationNext, depth, refs);
296
- }
297
- if (i3 < length - 1) {
298
- result += `,${config.spacingInner}`;
299
- } else if (!config.min) {
300
- result += ",";
301
- }
302
- }
303
- result += config.spacingOuter + indentation;
304
- }
305
- return result;
306
- }
307
- function printObjectProperties(val, config, indentation, depth, refs, printer2) {
308
- let result = "";
309
- const keys = getKeysOfEnumerableProperties(val, config.compareKeys);
310
- if (keys.length > 0) {
311
- result += config.spacingOuter;
312
- const indentationNext = indentation + config.indent;
313
- for (let i3 = 0; i3 < keys.length; i3++) {
314
- const key = keys[i3];
315
- const name = printer2(key, config, indentationNext, depth, refs);
316
- const value = printer2(val[key], config, indentationNext, depth, refs);
317
- result += `${indentationNext + name}: ${value}`;
318
- if (i3 < keys.length - 1) {
319
- result += `,${config.spacingInner}`;
320
- } else if (!config.min) {
321
- result += ",";
322
- }
323
- }
324
- result += config.spacingOuter + indentation;
325
- }
326
- return result;
327
- }
328
- var asymmetricMatcher = typeof Symbol === "function" && Symbol.for ? /* @__PURE__ */ Symbol.for("jest.asymmetricMatcher") : 1267621;
329
- var SPACE$2 = " ";
330
- var serialize$5 = (val, config, indentation, depth, refs, printer2) => {
331
- const stringedValue = val.toString();
332
- if (stringedValue === "ArrayContaining" || stringedValue === "ArrayNotContaining") {
333
- if (++depth > config.maxDepth) {
334
- return `[${stringedValue}]`;
335
- }
336
- return `${stringedValue + SPACE$2}[${printListItems(val.sample, config, indentation, depth, refs, printer2)}]`;
337
- }
338
- if (stringedValue === "ObjectContaining" || stringedValue === "ObjectNotContaining") {
339
- if (++depth > config.maxDepth) {
340
- return `[${stringedValue}]`;
341
- }
342
- return `${stringedValue + SPACE$2}{${printObjectProperties(val.sample, config, indentation, depth, refs, printer2)}}`;
343
- }
344
- if (stringedValue === "StringMatching" || stringedValue === "StringNotMatching") {
345
- return stringedValue + SPACE$2 + printer2(val.sample, config, indentation, depth, refs);
346
- }
347
- if (stringedValue === "StringContaining" || stringedValue === "StringNotContaining") {
348
- return stringedValue + SPACE$2 + printer2(val.sample, config, indentation, depth, refs);
349
- }
350
- if (typeof val.toAsymmetricMatcher !== "function") {
351
- throw new TypeError(`Asymmetric matcher ${val.constructor.name} does not implement toAsymmetricMatcher()`);
352
- }
353
- return val.toAsymmetricMatcher();
354
- };
355
- var test$5 = (val) => val && val.$$typeof === asymmetricMatcher;
356
- var plugin$5 = {
357
- serialize: serialize$5,
358
- test: test$5
359
- };
360
- var SPACE$1 = " ";
361
- var OBJECT_NAMES = /* @__PURE__ */ new Set(["DOMStringMap", "NamedNodeMap"]);
362
- var ARRAY_REGEXP = /^(?:HTML\w*Collection|NodeList)$/;
363
- function testName(name) {
364
- return OBJECT_NAMES.has(name) || ARRAY_REGEXP.test(name);
365
- }
366
- var test$4 = (val) => val && val.constructor && !!val.constructor.name && testName(val.constructor.name);
367
- function isNamedNodeMap(collection) {
368
- return collection.constructor.name === "NamedNodeMap";
369
- }
370
- var serialize$4 = (collection, config, indentation, depth, refs, printer2) => {
371
- const name = collection.constructor.name;
372
- if (++depth > config.maxDepth) {
373
- return `[${name}]`;
374
- }
375
- return (config.min ? "" : name + SPACE$1) + (OBJECT_NAMES.has(name) ? `{${printObjectProperties(isNamedNodeMap(collection) ? [...collection].reduce((props, attribute) => {
376
- props[attribute.name] = attribute.value;
377
- return props;
378
- }, {}) : { ...collection }, config, indentation, depth, refs, printer2)}}` : `[${printListItems([...collection], config, indentation, depth, refs, printer2)}]`);
379
- };
380
- var plugin$4 = {
381
- serialize: serialize$4,
382
- test: test$4
383
- };
384
- function escapeHTML(str) {
385
- return str.replaceAll("<", "&lt;").replaceAll(">", "&gt;");
386
- }
387
- function printProps(keys, props, config, indentation, depth, refs, printer2) {
388
- const indentationNext = indentation + config.indent;
389
- const colors = config.colors;
390
- return keys.map((key) => {
391
- const value = props[key];
392
- if (typeof value === "string" && value[0] === "_" && value.startsWith("__vitest_") && value.match(/__vitest_\d+__/)) {
393
- return "";
394
- }
395
- let printed = printer2(value, config, indentationNext, depth, refs);
396
- if (typeof value !== "string") {
397
- if (printed.includes("\n")) {
398
- printed = config.spacingOuter + indentationNext + printed + config.spacingOuter + indentation;
399
- }
400
- printed = `{${printed}}`;
401
- }
402
- return `${config.spacingInner + indentation + colors.prop.open + key + colors.prop.close}=${colors.value.open}${printed}${colors.value.close}`;
403
- }).join("");
404
- }
405
- function printChildren(children, config, indentation, depth, refs, printer2) {
406
- return children.map((child) => config.spacingOuter + indentation + (typeof child === "string" ? printText(child, config) : printer2(child, config, indentation, depth, refs))).join("");
407
- }
408
- function printShadowRoot(children, config, indentation, depth, refs, printer2) {
409
- if (config.printShadowRoot === false) {
410
- return "";
411
- }
412
- return [`${config.spacingOuter + indentation}#shadow-root`, printChildren(children, config, indentation + config.indent, depth, refs, printer2)].join("");
413
- }
414
- function printText(text, config) {
415
- const contentColor = config.colors.content;
416
- return contentColor.open + escapeHTML(text) + contentColor.close;
417
- }
418
- function printComment(comment, config) {
419
- const commentColor = config.colors.comment;
420
- return `${commentColor.open}<!--${escapeHTML(comment)}-->${commentColor.close}`;
421
- }
422
- function printElement(type, printedProps, printedChildren, config, indentation) {
423
- const tagColor = config.colors.tag;
424
- return `${tagColor.open}<${type}${printedProps && tagColor.close + printedProps + config.spacingOuter + indentation + tagColor.open}${printedChildren ? `>${tagColor.close}${printedChildren}${config.spacingOuter}${indentation}${tagColor.open}</${type}` : `${printedProps && !config.min ? "" : " "}/`}>${tagColor.close}`;
425
- }
426
- function printElementAsLeaf(type, config) {
427
- const tagColor = config.colors.tag;
428
- return `${tagColor.open}<${type}${tagColor.close} \u2026${tagColor.open} />${tagColor.close}`;
429
- }
430
- var ELEMENT_NODE = 1;
431
- var TEXT_NODE = 3;
432
- var COMMENT_NODE = 8;
433
- var FRAGMENT_NODE = 11;
434
- var ELEMENT_REGEXP = /^(?:(?:HTML|SVG)\w*)?Element$/;
435
- function testHasAttribute(val) {
436
- try {
437
- return typeof val.hasAttribute === "function" && val.hasAttribute("is");
438
- } catch {
439
- return false;
440
- }
441
- }
442
- function testNode(val) {
443
- const constructorName = val.constructor.name;
444
- const { nodeType, tagName } = val;
445
- const isCustomElement = typeof tagName === "string" && tagName.includes("-") || testHasAttribute(val);
446
- return nodeType === ELEMENT_NODE && (ELEMENT_REGEXP.test(constructorName) || isCustomElement) || nodeType === TEXT_NODE && constructorName === "Text" || nodeType === COMMENT_NODE && constructorName === "Comment" || nodeType === FRAGMENT_NODE && constructorName === "DocumentFragment";
447
- }
448
- var test$3 = (val) => val?.constructor?.name && testNode(val);
449
- function nodeIsText(node) {
450
- return node.nodeType === TEXT_NODE;
451
- }
452
- function nodeIsComment(node) {
453
- return node.nodeType === COMMENT_NODE;
454
- }
455
- function nodeIsFragment(node) {
456
- return node.nodeType === FRAGMENT_NODE;
457
- }
458
- function filterChildren(children, filterNode) {
459
- let filtered = children.filter((node) => {
460
- if (node.nodeType === TEXT_NODE) {
461
- const text = node.data || "";
462
- return text.trim().length > 0;
463
- }
464
- return true;
465
- });
466
- if (filterNode) {
467
- filtered = filtered.filter(filterNode);
468
- }
469
- return filtered;
470
- }
471
- function serializeDOM(node, config, indentation, depth, refs, printer2, filterNode) {
472
- if (nodeIsText(node)) {
473
- return printText(node.data, config);
474
- }
475
- if (nodeIsComment(node)) {
476
- return printComment(node.data, config);
477
- }
478
- const type = nodeIsFragment(node) ? "DocumentFragment" : node.tagName.toLowerCase();
479
- if (++depth > config.maxDepth) {
480
- return printElementAsLeaf(type, config);
481
- }
482
- const children = Array.prototype.slice.call(node.childNodes || node.children);
483
- const shadowChildren = nodeIsFragment(node) || !node.shadowRoot ? [] : Array.prototype.slice.call(node.shadowRoot.children);
484
- const resolvedChildren = filterNode ? filterChildren(children, filterNode) : children;
485
- const resolvedShadowChildren = filterNode ? filterChildren(shadowChildren, filterNode) : shadowChildren;
486
- return printElement(type, printProps(nodeIsFragment(node) ? [] : Array.from(node.attributes, (attr) => attr.name).sort(), nodeIsFragment(node) ? {} : [...node.attributes].reduce((props, attribute) => {
487
- props[attribute.name] = attribute.value;
488
- return props;
489
- }, {}), config, indentation + config.indent, depth, refs, printer2), (resolvedShadowChildren.length > 0 ? printShadowRoot(resolvedShadowChildren, config, indentation + config.indent, depth, refs, printer2) : "") + printChildren(resolvedChildren, config, indentation + config.indent, depth, refs, printer2), config, indentation);
490
- }
491
- var serialize$3 = (node, config, indentation, depth, refs, printer2) => serializeDOM(node, config, indentation, depth, refs, printer2);
492
- function createDOMElementFilter(filterNode) {
493
- return {
494
- test: test$3,
495
- serialize: (node, config, indentation, depth, refs, printer2) => serializeDOM(node, config, indentation, depth, refs, printer2, filterNode)
496
- };
497
- }
498
- var plugin$3 = {
499
- serialize: serialize$3,
500
- test: test$3
501
- };
502
- var IS_ITERABLE_SENTINEL = "@@__IMMUTABLE_ITERABLE__@@";
503
- var IS_LIST_SENTINEL = "@@__IMMUTABLE_LIST__@@";
504
- var IS_KEYED_SENTINEL = "@@__IMMUTABLE_KEYED__@@";
505
- var IS_MAP_SENTINEL = "@@__IMMUTABLE_MAP__@@";
506
- var IS_ORDERED_SENTINEL = "@@__IMMUTABLE_ORDERED__@@";
507
- var IS_RECORD_SENTINEL = "@@__IMMUTABLE_RECORD__@@";
508
- var IS_SEQ_SENTINEL = "@@__IMMUTABLE_SEQ__@@";
509
- var IS_SET_SENTINEL = "@@__IMMUTABLE_SET__@@";
510
- var IS_STACK_SENTINEL = "@@__IMMUTABLE_STACK__@@";
511
- var getImmutableName = (name) => `Immutable.${name}`;
512
- var printAsLeaf = (name) => `[${name}]`;
513
- var SPACE = " ";
514
- var LAZY = "\u2026";
515
- function printImmutableEntries(val, config, indentation, depth, refs, printer2, type) {
516
- return ++depth > config.maxDepth ? printAsLeaf(getImmutableName(type)) : `${getImmutableName(type) + SPACE}{${printIteratorEntries(val.entries(), config, indentation, depth, refs, printer2)}}`;
517
- }
518
- function getRecordEntries(val) {
519
- let i3 = 0;
520
- return { next() {
521
- if (i3 < val._keys.length) {
522
- const key = val._keys[i3++];
523
- return {
524
- done: false,
525
- value: [key, val.get(key)]
526
- };
527
- }
528
- return {
529
- done: true,
530
- value: void 0
531
- };
532
- } };
533
- }
534
- function printImmutableRecord(val, config, indentation, depth, refs, printer2) {
535
- const name = getImmutableName(val._name || "Record");
536
- return ++depth > config.maxDepth ? printAsLeaf(name) : `${name + SPACE}{${printIteratorEntries(getRecordEntries(val), config, indentation, depth, refs, printer2)}}`;
537
- }
538
- function printImmutableSeq(val, config, indentation, depth, refs, printer2) {
539
- const name = getImmutableName("Seq");
540
- if (++depth > config.maxDepth) {
541
- return printAsLeaf(name);
542
- }
543
- if (val[IS_KEYED_SENTINEL]) {
544
- return `${name + SPACE}{${val._iter || val._object ? printIteratorEntries(val.entries(), config, indentation, depth, refs, printer2) : LAZY}}`;
545
- }
546
- return `${name + SPACE}[${val._iter || val._array || val._collection || val._iterable ? printIteratorValues(val.values(), config, indentation, depth, refs, printer2) : LAZY}]`;
547
- }
548
- function printImmutableValues(val, config, indentation, depth, refs, printer2, type) {
549
- return ++depth > config.maxDepth ? printAsLeaf(getImmutableName(type)) : `${getImmutableName(type) + SPACE}[${printIteratorValues(val.values(), config, indentation, depth, refs, printer2)}]`;
550
- }
551
- var serialize$2 = (val, config, indentation, depth, refs, printer2) => {
552
- if (val[IS_MAP_SENTINEL]) {
553
- return printImmutableEntries(val, config, indentation, depth, refs, printer2, val[IS_ORDERED_SENTINEL] ? "OrderedMap" : "Map");
554
- }
555
- if (val[IS_LIST_SENTINEL]) {
556
- return printImmutableValues(val, config, indentation, depth, refs, printer2, "List");
557
- }
558
- if (val[IS_SET_SENTINEL]) {
559
- return printImmutableValues(val, config, indentation, depth, refs, printer2, val[IS_ORDERED_SENTINEL] ? "OrderedSet" : "Set");
560
- }
561
- if (val[IS_STACK_SENTINEL]) {
562
- return printImmutableValues(val, config, indentation, depth, refs, printer2, "Stack");
563
- }
564
- if (val[IS_SEQ_SENTINEL]) {
565
- return printImmutableSeq(val, config, indentation, depth, refs, printer2);
566
- }
567
- return printImmutableRecord(val, config, indentation, depth, refs, printer2);
568
- };
569
- var test$2 = (val) => val && (val[IS_ITERABLE_SENTINEL] === true || val[IS_RECORD_SENTINEL] === true);
570
- var plugin$2 = {
571
- serialize: serialize$2,
572
- test: test$2
573
- };
574
- function getDefaultExportFromCjs(x) {
575
- return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
576
- }
577
- var reactIs$1 = { exports: {} };
578
- var reactIs_production = {};
579
- var hasRequiredReactIs_production;
580
- function requireReactIs_production() {
581
- if (hasRequiredReactIs_production) return reactIs_production;
582
- hasRequiredReactIs_production = 1;
583
- var REACT_ELEMENT_TYPE = /* @__PURE__ */ Symbol.for("react.transitional.element"), REACT_PORTAL_TYPE = /* @__PURE__ */ Symbol.for("react.portal"), REACT_FRAGMENT_TYPE = /* @__PURE__ */ Symbol.for("react.fragment"), REACT_STRICT_MODE_TYPE = /* @__PURE__ */ Symbol.for("react.strict_mode"), REACT_PROFILER_TYPE = /* @__PURE__ */ Symbol.for("react.profiler"), REACT_CONSUMER_TYPE = /* @__PURE__ */ Symbol.for("react.consumer"), REACT_CONTEXT_TYPE = /* @__PURE__ */ Symbol.for("react.context"), REACT_FORWARD_REF_TYPE = /* @__PURE__ */ Symbol.for("react.forward_ref"), REACT_SUSPENSE_TYPE = /* @__PURE__ */ Symbol.for("react.suspense"), REACT_SUSPENSE_LIST_TYPE = /* @__PURE__ */ Symbol.for("react.suspense_list"), REACT_MEMO_TYPE = /* @__PURE__ */ Symbol.for("react.memo"), REACT_LAZY_TYPE = /* @__PURE__ */ Symbol.for("react.lazy"), REACT_VIEW_TRANSITION_TYPE = /* @__PURE__ */ Symbol.for("react.view_transition"), REACT_CLIENT_REFERENCE = /* @__PURE__ */ Symbol.for("react.client.reference");
584
- function typeOf(object) {
585
- if ("object" === typeof object && null !== object) {
586
- var $$typeof = object.$$typeof;
587
- switch ($$typeof) {
588
- case REACT_ELEMENT_TYPE:
589
- switch (object = object.type, object) {
590
- case REACT_FRAGMENT_TYPE:
591
- case REACT_PROFILER_TYPE:
592
- case REACT_STRICT_MODE_TYPE:
593
- case REACT_SUSPENSE_TYPE:
594
- case REACT_SUSPENSE_LIST_TYPE:
595
- case REACT_VIEW_TRANSITION_TYPE:
596
- return object;
597
- default:
598
- switch (object = object && object.$$typeof, object) {
599
- case REACT_CONTEXT_TYPE:
600
- case REACT_FORWARD_REF_TYPE:
601
- case REACT_LAZY_TYPE:
602
- case REACT_MEMO_TYPE:
603
- return object;
604
- case REACT_CONSUMER_TYPE:
605
- return object;
606
- default:
607
- return $$typeof;
608
- }
609
- }
610
- case REACT_PORTAL_TYPE:
611
- return $$typeof;
612
- }
613
- }
614
- }
615
- reactIs_production.ContextConsumer = REACT_CONSUMER_TYPE;
616
- reactIs_production.ContextProvider = REACT_CONTEXT_TYPE;
617
- reactIs_production.Element = REACT_ELEMENT_TYPE;
618
- reactIs_production.ForwardRef = REACT_FORWARD_REF_TYPE;
619
- reactIs_production.Fragment = REACT_FRAGMENT_TYPE;
620
- reactIs_production.Lazy = REACT_LAZY_TYPE;
621
- reactIs_production.Memo = REACT_MEMO_TYPE;
622
- reactIs_production.Portal = REACT_PORTAL_TYPE;
623
- reactIs_production.Profiler = REACT_PROFILER_TYPE;
624
- reactIs_production.StrictMode = REACT_STRICT_MODE_TYPE;
625
- reactIs_production.Suspense = REACT_SUSPENSE_TYPE;
626
- reactIs_production.SuspenseList = REACT_SUSPENSE_LIST_TYPE;
627
- reactIs_production.isContextConsumer = function(object) {
628
- return typeOf(object) === REACT_CONSUMER_TYPE;
629
- };
630
- reactIs_production.isContextProvider = function(object) {
631
- return typeOf(object) === REACT_CONTEXT_TYPE;
632
- };
633
- reactIs_production.isElement = function(object) {
634
- return "object" === typeof object && null !== object && object.$$typeof === REACT_ELEMENT_TYPE;
635
- };
636
- reactIs_production.isForwardRef = function(object) {
637
- return typeOf(object) === REACT_FORWARD_REF_TYPE;
638
- };
639
- reactIs_production.isFragment = function(object) {
640
- return typeOf(object) === REACT_FRAGMENT_TYPE;
641
- };
642
- reactIs_production.isLazy = function(object) {
643
- return typeOf(object) === REACT_LAZY_TYPE;
644
- };
645
- reactIs_production.isMemo = function(object) {
646
- return typeOf(object) === REACT_MEMO_TYPE;
647
- };
648
- reactIs_production.isPortal = function(object) {
649
- return typeOf(object) === REACT_PORTAL_TYPE;
650
- };
651
- reactIs_production.isProfiler = function(object) {
652
- return typeOf(object) === REACT_PROFILER_TYPE;
653
- };
654
- reactIs_production.isStrictMode = function(object) {
655
- return typeOf(object) === REACT_STRICT_MODE_TYPE;
656
- };
657
- reactIs_production.isSuspense = function(object) {
658
- return typeOf(object) === REACT_SUSPENSE_TYPE;
659
- };
660
- reactIs_production.isSuspenseList = function(object) {
661
- return typeOf(object) === REACT_SUSPENSE_LIST_TYPE;
662
- };
663
- reactIs_production.isValidElementType = function(type) {
664
- return "string" === typeof type || "function" === typeof type || type === REACT_FRAGMENT_TYPE || type === REACT_PROFILER_TYPE || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || type === REACT_SUSPENSE_LIST_TYPE || "object" === typeof type && null !== type && (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_CONSUMER_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE || type.$$typeof === REACT_CLIENT_REFERENCE || void 0 !== type.getModuleId) ? true : false;
665
- };
666
- reactIs_production.typeOf = typeOf;
667
- return reactIs_production;
668
- }
669
- var hasRequiredReactIs$1;
670
- function requireReactIs$1() {
671
- if (hasRequiredReactIs$1) return reactIs$1.exports;
672
- hasRequiredReactIs$1 = 1;
673
- {
674
- reactIs$1.exports = requireReactIs_production();
675
- }
676
- return reactIs$1.exports;
677
- }
678
- var reactIsExports$1 = requireReactIs$1();
679
- var index$1 = /* @__PURE__ */ getDefaultExportFromCjs(reactIsExports$1);
680
- var ReactIs19 = /* @__PURE__ */ _mergeNamespaces({
681
- __proto__: null,
682
- default: index$1
683
- }, [reactIsExports$1]);
684
- var reactIs = { exports: {} };
685
- var reactIs_production_min = {};
686
- var hasRequiredReactIs_production_min;
687
- function requireReactIs_production_min() {
688
- if (hasRequiredReactIs_production_min) return reactIs_production_min;
689
- hasRequiredReactIs_production_min = 1;
690
- var b4 = /* @__PURE__ */ Symbol.for("react.element"), c3 = /* @__PURE__ */ Symbol.for("react.portal"), d3 = /* @__PURE__ */ Symbol.for("react.fragment"), e2 = /* @__PURE__ */ Symbol.for("react.strict_mode"), f3 = /* @__PURE__ */ Symbol.for("react.profiler"), g4 = /* @__PURE__ */ Symbol.for("react.provider"), h3 = /* @__PURE__ */ Symbol.for("react.context"), k2 = /* @__PURE__ */ Symbol.for("react.server_context"), l2 = /* @__PURE__ */ Symbol.for("react.forward_ref"), m2 = /* @__PURE__ */ Symbol.for("react.suspense"), n2 = /* @__PURE__ */ Symbol.for("react.suspense_list"), p2 = /* @__PURE__ */ Symbol.for("react.memo"), q2 = /* @__PURE__ */ Symbol.for("react.lazy"), t2 = /* @__PURE__ */ Symbol.for("react.offscreen"), u2;
691
- u2 = /* @__PURE__ */ Symbol.for("react.module.reference");
692
- function v3(a4) {
693
- if ("object" === typeof a4 && null !== a4) {
694
- var r2 = a4.$$typeof;
695
- switch (r2) {
696
- case b4:
697
- switch (a4 = a4.type, a4) {
698
- case d3:
699
- case f3:
700
- case e2:
701
- case m2:
702
- case n2:
703
- return a4;
704
- default:
705
- switch (a4 = a4 && a4.$$typeof, a4) {
706
- case k2:
707
- case h3:
708
- case l2:
709
- case q2:
710
- case p2:
711
- case g4:
712
- return a4;
713
- default:
714
- return r2;
715
- }
716
- }
717
- case c3:
718
- return r2;
719
- }
720
- }
721
- }
722
- reactIs_production_min.ContextConsumer = h3;
723
- reactIs_production_min.ContextProvider = g4;
724
- reactIs_production_min.Element = b4;
725
- reactIs_production_min.ForwardRef = l2;
726
- reactIs_production_min.Fragment = d3;
727
- reactIs_production_min.Lazy = q2;
728
- reactIs_production_min.Memo = p2;
729
- reactIs_production_min.Portal = c3;
730
- reactIs_production_min.Profiler = f3;
731
- reactIs_production_min.StrictMode = e2;
732
- reactIs_production_min.Suspense = m2;
733
- reactIs_production_min.SuspenseList = n2;
734
- reactIs_production_min.isAsyncMode = function() {
735
- return false;
736
- };
737
- reactIs_production_min.isConcurrentMode = function() {
738
- return false;
739
- };
740
- reactIs_production_min.isContextConsumer = function(a4) {
741
- return v3(a4) === h3;
742
- };
743
- reactIs_production_min.isContextProvider = function(a4) {
744
- return v3(a4) === g4;
745
- };
746
- reactIs_production_min.isElement = function(a4) {
747
- return "object" === typeof a4 && null !== a4 && a4.$$typeof === b4;
748
- };
749
- reactIs_production_min.isForwardRef = function(a4) {
750
- return v3(a4) === l2;
751
- };
752
- reactIs_production_min.isFragment = function(a4) {
753
- return v3(a4) === d3;
754
- };
755
- reactIs_production_min.isLazy = function(a4) {
756
- return v3(a4) === q2;
757
- };
758
- reactIs_production_min.isMemo = function(a4) {
759
- return v3(a4) === p2;
760
- };
761
- reactIs_production_min.isPortal = function(a4) {
762
- return v3(a4) === c3;
763
- };
764
- reactIs_production_min.isProfiler = function(a4) {
765
- return v3(a4) === f3;
766
- };
767
- reactIs_production_min.isStrictMode = function(a4) {
768
- return v3(a4) === e2;
769
- };
770
- reactIs_production_min.isSuspense = function(a4) {
771
- return v3(a4) === m2;
772
- };
773
- reactIs_production_min.isSuspenseList = function(a4) {
774
- return v3(a4) === n2;
775
- };
776
- reactIs_production_min.isValidElementType = function(a4) {
777
- return "string" === typeof a4 || "function" === typeof a4 || a4 === d3 || a4 === f3 || a4 === e2 || a4 === m2 || a4 === n2 || a4 === t2 || "object" === typeof a4 && null !== a4 && (a4.$$typeof === q2 || a4.$$typeof === p2 || a4.$$typeof === g4 || a4.$$typeof === h3 || a4.$$typeof === l2 || a4.$$typeof === u2 || void 0 !== a4.getModuleId) ? true : false;
778
- };
779
- reactIs_production_min.typeOf = v3;
780
- return reactIs_production_min;
781
- }
782
- var hasRequiredReactIs;
783
- function requireReactIs() {
784
- if (hasRequiredReactIs) return reactIs.exports;
785
- hasRequiredReactIs = 1;
786
- {
787
- reactIs.exports = requireReactIs_production_min();
788
- }
789
- return reactIs.exports;
790
- }
791
- var reactIsExports = requireReactIs();
792
- var index = /* @__PURE__ */ getDefaultExportFromCjs(reactIsExports);
793
- var ReactIs18 = /* @__PURE__ */ _mergeNamespaces({
794
- __proto__: null,
795
- default: index
796
- }, [reactIsExports]);
797
- var reactIsMethods = [
798
- "isAsyncMode",
799
- "isConcurrentMode",
800
- "isContextConsumer",
801
- "isContextProvider",
802
- "isElement",
803
- "isForwardRef",
804
- "isFragment",
805
- "isLazy",
806
- "isMemo",
807
- "isPortal",
808
- "isProfiler",
809
- "isStrictMode",
810
- "isSuspense",
811
- "isSuspenseList",
812
- "isValidElementType"
813
- ];
814
- var ReactIs = Object.fromEntries(reactIsMethods.map((m2) => [m2, (v3) => ReactIs18[m2](v3) || ReactIs19[m2](v3)]));
815
- function getChildren(arg, children = []) {
816
- if (Array.isArray(arg)) {
817
- for (const item of arg) {
818
- getChildren(item, children);
819
- }
820
- } else if (arg != null && arg !== false && arg !== "") {
821
- children.push(arg);
822
- }
823
- return children;
824
- }
825
- function getType(element) {
826
- const type = element.type;
827
- if (typeof type === "string") {
828
- return type;
829
- }
830
- if (typeof type === "function") {
831
- return type.displayName || type.name || "Unknown";
832
- }
833
- if (ReactIs.isFragment(element)) {
834
- return "React.Fragment";
835
- }
836
- if (ReactIs.isSuspense(element)) {
837
- return "React.Suspense";
838
- }
839
- if (typeof type === "object" && type !== null) {
840
- if (ReactIs.isContextProvider(element)) {
841
- return "Context.Provider";
842
- }
843
- if (ReactIs.isContextConsumer(element)) {
844
- return "Context.Consumer";
845
- }
846
- if (ReactIs.isForwardRef(element)) {
847
- if (type.displayName) {
848
- return type.displayName;
849
- }
850
- const functionName = type.render.displayName || type.render.name || "";
851
- return functionName === "" ? "ForwardRef" : `ForwardRef(${functionName})`;
852
- }
853
- if (ReactIs.isMemo(element)) {
854
- const functionName = type.displayName || type.type.displayName || type.type.name || "";
855
- return functionName === "" ? "Memo" : `Memo(${functionName})`;
856
- }
857
- }
858
- return "UNDEFINED";
859
- }
860
- function getPropKeys$1(element) {
861
- const { props } = element;
862
- return Object.keys(props).filter((key) => key !== "children" && props[key] !== void 0).sort();
863
- }
864
- var serialize$1 = (element, config, indentation, depth, refs, printer2) => ++depth > config.maxDepth ? printElementAsLeaf(getType(element), config) : printElement(getType(element), printProps(getPropKeys$1(element), element.props, config, indentation + config.indent, depth, refs, printer2), printChildren(getChildren(element.props.children), config, indentation + config.indent, depth, refs, printer2), config, indentation);
865
- var test$1 = (val) => val != null && ReactIs.isElement(val);
866
- var plugin$1 = {
867
- serialize: serialize$1,
868
- test: test$1
869
- };
870
- var testSymbol = typeof Symbol === "function" && Symbol.for ? /* @__PURE__ */ Symbol.for("react.test.json") : 245830487;
871
- function getPropKeys(object) {
872
- const { props } = object;
873
- return props ? Object.keys(props).filter((key) => props[key] !== void 0).sort() : [];
874
- }
875
- var serialize = (object, config, indentation, depth, refs, printer2) => ++depth > config.maxDepth ? printElementAsLeaf(object.type, config) : printElement(object.type, object.props ? printProps(getPropKeys(object), object.props, config, indentation + config.indent, depth, refs, printer2) : "", object.children ? printChildren(object.children, config, indentation + config.indent, depth, refs, printer2) : "", config, indentation);
876
- var test = (val) => val && val.$$typeof === testSymbol;
877
- var plugin = {
878
- serialize,
879
- test
880
- };
881
- var toString = Object.prototype.toString;
882
- var toISOString = Date.prototype.toISOString;
883
- var errorToString = Error.prototype.toString;
884
- var regExpToString = RegExp.prototype.toString;
885
- function getConstructorName(val) {
886
- return typeof val.constructor === "function" && val.constructor.name || "Object";
887
- }
888
- function isWindow(val) {
889
- return typeof window !== "undefined" && val === window;
890
- }
891
- var SYMBOL_REGEXP = /^Symbol\((.*)\)(.*)$/;
892
- var NEWLINE_REGEXP = /\n/g;
893
- var PrettyFormatPluginError = class extends Error {
894
- constructor(message, stack) {
895
- super(message);
896
- this.stack = stack;
897
- this.name = this.constructor.name;
898
- }
899
- };
900
- function isToStringedArrayType(toStringed) {
901
- return toStringed === "[object Array]" || toStringed === "[object ArrayBuffer]" || toStringed === "[object DataView]" || toStringed === "[object Float32Array]" || toStringed === "[object Float64Array]" || toStringed === "[object Int8Array]" || toStringed === "[object Int16Array]" || toStringed === "[object Int32Array]" || toStringed === "[object Uint8Array]" || toStringed === "[object Uint8ClampedArray]" || toStringed === "[object Uint16Array]" || toStringed === "[object Uint32Array]";
902
- }
903
- function printNumber(val) {
904
- return Object.is(val, -0) ? "-0" : String(val);
905
- }
906
- function printBigInt(val) {
907
- return String(`${val}n`);
908
- }
909
- function printFunction(val, printFunctionName) {
910
- if (!printFunctionName) {
911
- return "[Function]";
912
- }
913
- return `[Function ${val.name || "anonymous"}]`;
914
- }
915
- function printSymbol(val) {
916
- return String(val).replace(SYMBOL_REGEXP, "Symbol($1)");
917
- }
918
- function printError(val) {
919
- return `[${errorToString.call(val)}]`;
920
- }
921
- function printBasicValue(val, printFunctionName, escapeRegex, escapeString) {
922
- if (val === true || val === false) {
923
- return `${val}`;
924
- }
925
- if (val === void 0) {
926
- return "undefined";
927
- }
928
- if (val === null) {
929
- return "null";
930
- }
931
- const typeOf = typeof val;
932
- if (typeOf === "number") {
933
- return printNumber(val);
934
- }
935
- if (typeOf === "bigint") {
936
- return printBigInt(val);
937
- }
938
- if (typeOf === "string") {
939
- if (escapeString) {
940
- return `"${val.replaceAll(/"|\\/g, "\\$&")}"`;
941
- }
942
- return `"${val}"`;
943
- }
944
- if (typeOf === "function") {
945
- return printFunction(val, printFunctionName);
946
- }
947
- if (typeOf === "symbol") {
948
- return printSymbol(val);
949
- }
950
- const toStringed = toString.call(val);
951
- if (toStringed === "[object WeakMap]") {
952
- return "WeakMap {}";
953
- }
954
- if (toStringed === "[object WeakSet]") {
955
- return "WeakSet {}";
956
- }
957
- if (toStringed === "[object Function]" || toStringed === "[object GeneratorFunction]") {
958
- return printFunction(val, printFunctionName);
959
- }
960
- if (toStringed === "[object Symbol]") {
961
- return printSymbol(val);
962
- }
963
- if (toStringed === "[object Date]") {
964
- return Number.isNaN(+val) ? "Date { NaN }" : toISOString.call(val);
965
- }
966
- if (toStringed === "[object Error]") {
967
- return printError(val);
968
- }
969
- if (toStringed === "[object RegExp]") {
970
- if (escapeRegex) {
971
- return regExpToString.call(val).replaceAll(/[$()*+.?[\\\]^{|}]/g, "\\$&");
972
- }
973
- return regExpToString.call(val);
974
- }
975
- if (val instanceof Error) {
976
- return printError(val);
977
- }
978
- return null;
979
- }
980
- function printComplexValue(val, config, indentation, depth, refs, hasCalledToJSON) {
981
- if (refs.includes(val)) {
982
- return "[Circular]";
983
- }
984
- refs = [...refs];
985
- refs.push(val);
986
- const hitMaxDepth = ++depth > config.maxDepth;
987
- const min = config.min;
988
- if (config.callToJSON && !hitMaxDepth && val.toJSON && typeof val.toJSON === "function" && !hasCalledToJSON) {
989
- return printer(val.toJSON(), config, indentation, depth, refs, true);
990
- }
991
- const toStringed = toString.call(val);
992
- if (toStringed === "[object Arguments]") {
993
- return hitMaxDepth ? "[Arguments]" : `${min ? "" : "Arguments "}[${printListItems(val, config, indentation, depth, refs, printer)}]`;
994
- }
995
- if (isToStringedArrayType(toStringed)) {
996
- return hitMaxDepth ? `[${val.constructor.name}]` : `${min ? "" : !config.printBasicPrototype && val.constructor.name === "Array" ? "" : `${val.constructor.name} `}[${printListItems(val, config, indentation, depth, refs, printer)}]`;
997
- }
998
- if (toStringed === "[object Map]") {
999
- return hitMaxDepth ? "[Map]" : `Map {${printIteratorEntries(val.entries(), config, indentation, depth, refs, printer, " => ")}}`;
1000
- }
1001
- if (toStringed === "[object Set]") {
1002
- return hitMaxDepth ? "[Set]" : `Set {${printIteratorValues(val.values(), config, indentation, depth, refs, printer)}}`;
1003
- }
1004
- return hitMaxDepth || isWindow(val) ? `[${getConstructorName(val)}]` : `${min ? "" : !config.printBasicPrototype && getConstructorName(val) === "Object" ? "" : `${getConstructorName(val)} `}{${printObjectProperties(val, config, indentation, depth, refs, printer)}}`;
1005
- }
1006
- var ErrorPlugin = {
1007
- test: (val) => val && val instanceof Error,
1008
- serialize(val, config, indentation, depth, refs, printer2) {
1009
- if (refs.includes(val)) {
1010
- return "[Circular]";
1011
- }
1012
- refs = [...refs, val];
1013
- const hitMaxDepth = ++depth > config.maxDepth;
1014
- const { message, cause, ...rest } = val;
1015
- const entries = {
1016
- message,
1017
- ...typeof cause !== "undefined" ? { cause } : {},
1018
- ...val instanceof AggregateError ? { errors: val.errors } : {},
1019
- ...rest
1020
- };
1021
- const name = val.name !== "Error" ? val.name : getConstructorName(val);
1022
- return hitMaxDepth ? `[${name}]` : `${name} {${printIteratorEntries(Object.entries(entries).values(), config, indentation, depth, refs, printer2)}}`;
1023
- }
1024
- };
1025
- function isNewPlugin(plugin2) {
1026
- return plugin2.serialize != null;
1027
- }
1028
- function printPlugin(plugin2, val, config, indentation, depth, refs) {
1029
- let printed;
1030
- try {
1031
- printed = isNewPlugin(plugin2) ? plugin2.serialize(val, config, indentation, depth, refs, printer) : plugin2.print(val, (valChild) => printer(valChild, config, indentation, depth, refs), (str) => {
1032
- const indentationNext = indentation + config.indent;
1033
- return indentationNext + str.replaceAll(NEWLINE_REGEXP, `
1034
- ${indentationNext}`);
1035
- }, {
1036
- edgeSpacing: config.spacingOuter,
1037
- min: config.min,
1038
- spacing: config.spacingInner
1039
- }, config.colors);
1040
- } catch (error) {
1041
- throw new PrettyFormatPluginError(error.message, error.stack);
1042
- }
1043
- if (typeof printed !== "string") {
1044
- throw new TypeError(`pretty-format: Plugin must return type "string" but instead returned "${typeof printed}".`);
1045
- }
1046
- return printed;
1047
- }
1048
- function findPlugin(plugins2, val) {
1049
- for (const plugin2 of plugins2) {
1050
- try {
1051
- if (plugin2.test(val)) {
1052
- return plugin2;
1053
- }
1054
- } catch (error) {
1055
- throw new PrettyFormatPluginError(error.message, error.stack);
1056
- }
1057
- }
1058
- return null;
1059
- }
1060
- function printer(val, config, indentation, depth, refs, hasCalledToJSON) {
1061
- const plugin2 = findPlugin(config.plugins, val);
1062
- if (plugin2 !== null) {
1063
- return printPlugin(plugin2, val, config, indentation, depth, refs);
1064
- }
1065
- const basicResult = printBasicValue(val, config.printFunctionName, config.escapeRegex, config.escapeString);
1066
- if (basicResult !== null) {
1067
- return basicResult;
1068
- }
1069
- return printComplexValue(val, config, indentation, depth, refs, hasCalledToJSON);
1070
- }
1071
- var DEFAULT_THEME = {
1072
- comment: "gray",
1073
- content: "reset",
1074
- prop: "yellow",
1075
- tag: "cyan",
1076
- value: "green"
1077
- };
1078
- var DEFAULT_THEME_KEYS = Object.keys(DEFAULT_THEME);
1079
- var DEFAULT_OPTIONS = {
1080
- callToJSON: true,
1081
- compareKeys: void 0,
1082
- escapeRegex: false,
1083
- escapeString: true,
1084
- highlight: false,
1085
- indent: 2,
1086
- maxDepth: Number.POSITIVE_INFINITY,
1087
- maxWidth: Number.POSITIVE_INFINITY,
1088
- min: false,
1089
- plugins: [],
1090
- printBasicPrototype: true,
1091
- printFunctionName: true,
1092
- printShadowRoot: true,
1093
- theme: DEFAULT_THEME
1094
- };
1095
- function validateOptions(options) {
1096
- for (const key of Object.keys(options)) {
1097
- if (!Object.hasOwn(DEFAULT_OPTIONS, key)) {
1098
- throw new Error(`pretty-format: Unknown option "${key}".`);
1099
- }
1100
- }
1101
- if (options.min && options.indent !== void 0 && options.indent !== 0) {
1102
- throw new Error('pretty-format: Options "min" and "indent" cannot be used together.');
1103
- }
1104
- }
1105
- function getColorsHighlight() {
1106
- return DEFAULT_THEME_KEYS.reduce((colors, key) => {
1107
- const value = DEFAULT_THEME[key];
1108
- const color = value && C[value];
1109
- if (color && typeof color.close === "string" && typeof color.open === "string") {
1110
- colors[key] = color;
1111
- } else {
1112
- throw new Error(`pretty-format: Option "theme" has a key "${key}" whose value "${value}" is undefined in ansi-styles.`);
1113
- }
1114
- return colors;
1115
- }, /* @__PURE__ */ Object.create(null));
1116
- }
1117
- function getColorsEmpty() {
1118
- return DEFAULT_THEME_KEYS.reduce((colors, key) => {
1119
- colors[key] = {
1120
- close: "",
1121
- open: ""
1122
- };
1123
- return colors;
1124
- }, /* @__PURE__ */ Object.create(null));
1125
- }
1126
- function getPrintFunctionName(options) {
1127
- return options?.printFunctionName ?? DEFAULT_OPTIONS.printFunctionName;
1128
- }
1129
- function getEscapeRegex(options) {
1130
- return options?.escapeRegex ?? DEFAULT_OPTIONS.escapeRegex;
1131
- }
1132
- function getEscapeString(options) {
1133
- return options?.escapeString ?? DEFAULT_OPTIONS.escapeString;
1134
- }
1135
- function getConfig(options) {
1136
- return {
1137
- callToJSON: options?.callToJSON ?? DEFAULT_OPTIONS.callToJSON,
1138
- colors: options?.highlight ? getColorsHighlight() : getColorsEmpty(),
1139
- compareKeys: typeof options?.compareKeys === "function" || options?.compareKeys === null ? options.compareKeys : DEFAULT_OPTIONS.compareKeys,
1140
- escapeRegex: getEscapeRegex(options),
1141
- escapeString: getEscapeString(options),
1142
- indent: options?.min ? "" : createIndent(options?.indent ?? DEFAULT_OPTIONS.indent),
1143
- maxDepth: options?.maxDepth ?? DEFAULT_OPTIONS.maxDepth,
1144
- maxWidth: options?.maxWidth ?? DEFAULT_OPTIONS.maxWidth,
1145
- min: options?.min ?? DEFAULT_OPTIONS.min,
1146
- plugins: options?.plugins ?? DEFAULT_OPTIONS.plugins,
1147
- printBasicPrototype: options?.printBasicPrototype ?? true,
1148
- printFunctionName: getPrintFunctionName(options),
1149
- printShadowRoot: options?.printShadowRoot ?? true,
1150
- spacingInner: options?.min ? " " : "\n",
1151
- spacingOuter: options?.min ? "" : "\n"
1152
- };
1153
- }
1154
- function createIndent(indent) {
1155
- return Array.from({ length: indent + 1 }).join(" ");
1156
- }
1157
- function format(val, options) {
1158
- if (options) {
1159
- validateOptions(options);
1160
- if (options.plugins) {
1161
- const plugin2 = findPlugin(options.plugins, val);
1162
- if (plugin2 !== null) {
1163
- return printPlugin(plugin2, val, getConfig(options), "", 0, []);
1164
- }
1165
- }
1166
- }
1167
- const basicResult = printBasicValue(val, getPrintFunctionName(options), getEscapeRegex(options), getEscapeString(options));
1168
- if (basicResult !== null) {
1169
- return basicResult;
1170
- }
1171
- return printComplexValue(val, getConfig(options), "", 0, []);
1172
- }
1173
- var plugins = {
1174
- AsymmetricMatcher: plugin$5,
1175
- DOMCollection: plugin$4,
1176
- DOMElement: plugin$3,
1177
- Immutable: plugin$2,
1178
- ReactElement: plugin$1,
1179
- ReactTestComponent: plugin,
1180
- Error: ErrorPlugin
1181
- };
1182
-
1183
- // ../../node_modules/.pnpm/@vitest+utils@4.1.0/node_modules/@vitest/utils/dist/helpers.js
1184
- var import_constants = require("./constants.js.cjs");
1185
- function assertTypes(value, name, types) {
1186
- const receivedType = typeof value;
1187
- const pass = types.includes(receivedType);
1188
- if (!pass) {
1189
- throw new TypeError(`${name} value must be ${types.join(" or ")}, received "${receivedType}"`);
1190
- }
1191
- }
1192
- function filterOutComments(s3) {
1193
- const result = [];
1194
- let commentState = "none";
1195
- for (let i3 = 0; i3 < s3.length; ++i3) {
1196
- if (commentState === "singleline") {
1197
- if (s3[i3] === "\n") {
1198
- commentState = "none";
1199
- }
1200
- } else if (commentState === "multiline") {
1201
- if (s3[i3 - 1] === "*" && s3[i3] === "/") {
1202
- commentState = "none";
1203
- }
1204
- } else if (commentState === "none") {
1205
- if (s3[i3] === "/" && s3[i3 + 1] === "/") {
1206
- commentState = "singleline";
1207
- } else if (s3[i3] === "/" && s3[i3 + 1] === "*") {
1208
- commentState = "multiline";
1209
- i3 += 2;
1210
- } else {
1211
- result.push(s3[i3]);
1212
- }
1213
- }
1214
- }
1215
- return result.join("");
1216
- }
1217
- function toArray(array) {
1218
- if (array === null || array === void 0) {
1219
- array = [];
1220
- }
1221
- if (Array.isArray(array)) {
1222
- return array;
1223
- }
1224
- return [array];
1225
- }
1226
- function isObject(item) {
1227
- return item != null && typeof item === "object" && !Array.isArray(item);
1228
- }
1229
- function objectAttr(source, path, defaultValue = void 0) {
1230
- const paths = path.replace(/\[(\d+)\]/g, ".$1").split(".");
1231
- let result = source;
1232
- for (const p2 of paths) {
1233
- result = new Object(result)[p2];
1234
- if (result === void 0) {
1235
- return defaultValue;
1236
- }
1237
- }
1238
- return result;
1239
- }
1240
- function createDefer() {
1241
- let resolve = null;
1242
- let reject = null;
1243
- const p2 = new Promise((_resolve, _reject) => {
1244
- resolve = _resolve;
1245
- reject = _reject;
1246
- });
1247
- p2.resolve = resolve;
1248
- p2.reject = reject;
1249
- return p2;
1250
- }
1251
- function isNegativeNaN(val) {
1252
- if (!Number.isNaN(val)) {
1253
- return false;
1254
- }
1255
- const f64 = new Float64Array(1);
1256
- f64[0] = val;
1257
- const u32 = new Uint32Array(f64.buffer);
1258
- const isNegative = u32[1] >>> 31 === 1;
1259
- return isNegative;
1260
- }
1261
- function ordinal(i3) {
1262
- const j2 = i3 % 10;
1263
- const k2 = i3 % 100;
1264
- if (j2 === 1 && k2 !== 11) {
1265
- return `${i3}st`;
1266
- }
1267
- if (j2 === 2 && k2 !== 12) {
1268
- return `${i3}nd`;
1269
- }
1270
- if (j2 === 3 && k2 !== 13) {
1271
- return `${i3}rd`;
1272
- }
1273
- return `${i3}th`;
1274
- }
1275
- function unique(array) {
1276
- return Array.from(new Set(array));
1277
- }
1278
-
1279
- // ../../node_modules/.pnpm/@vitest+utils@4.1.0/node_modules/@vitest/utils/dist/timers.js
1280
- var SAFE_TIMERS_SYMBOL = /* @__PURE__ */ Symbol("vitest:SAFE_TIMERS");
1281
- function getSafeTimers() {
1282
- const { setTimeout: safeSetTimeout, setInterval: safeSetInterval, clearInterval: safeClearInterval, clearTimeout: safeClearTimeout, setImmediate: safeSetImmediate, clearImmediate: safeClearImmediate, queueMicrotask: safeQueueMicrotask } = globalThis[SAFE_TIMERS_SYMBOL] || globalThis;
1283
- const { nextTick: safeNextTick } = globalThis[SAFE_TIMERS_SYMBOL] || globalThis.process || {};
1284
- return {
1285
- nextTick: safeNextTick,
1286
- setTimeout: safeSetTimeout,
1287
- setInterval: safeSetInterval,
1288
- clearInterval: safeClearInterval,
1289
- clearTimeout: safeClearTimeout,
1290
- setImmediate: safeSetImmediate,
1291
- clearImmediate: safeClearImmediate,
1292
- queueMicrotask: safeQueueMicrotask
1293
- };
1294
- }
1295
-
1296
- // ../../node_modules/.pnpm/@vitest+utils@4.1.0/node_modules/@vitest/utils/dist/display.js
1297
- var ansiColors = {
1298
- bold: ["1", "22"],
1299
- dim: ["2", "22"],
1300
- italic: ["3", "23"],
1301
- underline: ["4", "24"],
1302
- // 5 & 6 are blinking
1303
- inverse: ["7", "27"],
1304
- hidden: ["8", "28"],
1305
- strike: ["9", "29"],
1306
- // 10-20 are fonts
1307
- // 21-29 are resets for 1-9
1308
- black: ["30", "39"],
1309
- red: ["31", "39"],
1310
- green: ["32", "39"],
1311
- yellow: ["33", "39"],
1312
- blue: ["34", "39"],
1313
- magenta: ["35", "39"],
1314
- cyan: ["36", "39"],
1315
- white: ["37", "39"],
1316
- brightblack: ["30;1", "39"],
1317
- brightred: ["31;1", "39"],
1318
- brightgreen: ["32;1", "39"],
1319
- brightyellow: ["33;1", "39"],
1320
- brightblue: ["34;1", "39"],
1321
- brightmagenta: ["35;1", "39"],
1322
- brightcyan: ["36;1", "39"],
1323
- brightwhite: ["37;1", "39"],
1324
- grey: ["90", "39"]
1325
- };
1326
- var styles = {
1327
- special: "cyan",
1328
- number: "yellow",
1329
- bigint: "yellow",
1330
- boolean: "yellow",
1331
- undefined: "grey",
1332
- null: "bold",
1333
- string: "green",
1334
- symbol: "green",
1335
- date: "magenta",
1336
- regexp: "red"
1337
- };
1338
- var truncator = "\u2026";
1339
- function colorise(value, styleType) {
1340
- const color = ansiColors[styles[styleType]] || ansiColors[styleType] || "";
1341
- if (!color) {
1342
- return String(value);
1343
- }
1344
- return `\x1B[${color[0]}m${String(value)}\x1B[${color[1]}m`;
1345
- }
1346
- function normaliseOptions({
1347
- showHidden = false,
1348
- depth = 2,
1349
- colors = false,
1350
- customInspect = true,
1351
- showProxy = false,
1352
- maxArrayLength = Infinity,
1353
- breakLength = Infinity,
1354
- seen = [],
1355
- // eslint-disable-next-line no-shadow
1356
- truncate: truncate2 = Infinity,
1357
- stylize = String
1358
- } = {}, inspect2) {
1359
- const options = {
1360
- showHidden: Boolean(showHidden),
1361
- depth: Number(depth),
1362
- colors: Boolean(colors),
1363
- customInspect: Boolean(customInspect),
1364
- showProxy: Boolean(showProxy),
1365
- maxArrayLength: Number(maxArrayLength),
1366
- breakLength: Number(breakLength),
1367
- truncate: Number(truncate2),
1368
- seen,
1369
- inspect: inspect2,
1370
- stylize
1371
- };
1372
- if (options.colors) {
1373
- options.stylize = colorise;
1374
- }
1375
- return options;
1376
- }
1377
- function isHighSurrogate(char) {
1378
- return char >= "\uD800" && char <= "\uDBFF";
1379
- }
1380
- function truncate(string, length, tail = truncator) {
1381
- string = String(string);
1382
- const tailLength = tail.length;
1383
- const stringLength = string.length;
1384
- if (tailLength > length && stringLength > tailLength) {
1385
- return tail;
1386
- }
1387
- if (stringLength > length && stringLength > tailLength) {
1388
- let end = length - tailLength;
1389
- if (end > 0 && isHighSurrogate(string[end - 1])) {
1390
- end = end - 1;
1391
- }
1392
- return `${string.slice(0, end)}${tail}`;
1393
- }
1394
- return string;
1395
- }
1396
- function inspectList(list, options, inspectItem, separator = ", ") {
1397
- inspectItem = inspectItem || options.inspect;
1398
- const size = list.length;
1399
- if (size === 0)
1400
- return "";
1401
- const originalLength = options.truncate;
1402
- let output = "";
1403
- let peek = "";
1404
- let truncated = "";
1405
- for (let i3 = 0; i3 < size; i3 += 1) {
1406
- const last = i3 + 1 === list.length;
1407
- const secondToLast = i3 + 2 === list.length;
1408
- truncated = `${truncator}(${list.length - i3})`;
1409
- const value = list[i3];
1410
- options.truncate = originalLength - output.length - (last ? 0 : separator.length);
1411
- const string = peek || inspectItem(value, options) + (last ? "" : separator);
1412
- const nextLength = output.length + string.length;
1413
- const truncatedLength = nextLength + truncated.length;
1414
- if (last && nextLength > originalLength && output.length + truncated.length <= originalLength) {
1415
- break;
1416
- }
1417
- if (!last && !secondToLast && truncatedLength > originalLength) {
1418
- break;
1419
- }
1420
- peek = last ? "" : inspectItem(list[i3 + 1], options) + (secondToLast ? "" : separator);
1421
- if (!last && secondToLast && truncatedLength > originalLength && nextLength + peek.length > originalLength) {
1422
- break;
1423
- }
1424
- output += string;
1425
- if (!last && !secondToLast && nextLength + peek.length >= originalLength) {
1426
- truncated = `${truncator}(${list.length - i3 - 1})`;
1427
- break;
1428
- }
1429
- truncated = "";
1430
- }
1431
- return `${output}${truncated}`;
1432
- }
1433
- function quoteComplexKey(key) {
1434
- if (key.match(/^[a-zA-Z_][a-zA-Z_0-9]*$/)) {
1435
- return key;
1436
- }
1437
- return JSON.stringify(key).replace(/'/g, "\\'").replace(/\\"/g, '"').replace(/(^"|"$)/g, "'");
1438
- }
1439
- function inspectProperty([key, value], options) {
1440
- options.truncate -= 2;
1441
- if (typeof key === "string") {
1442
- key = quoteComplexKey(key);
1443
- } else if (typeof key !== "number") {
1444
- key = `[${options.inspect(key, options)}]`;
1445
- }
1446
- options.truncate -= key.length;
1447
- value = options.inspect(value, options);
1448
- return `${key}: ${value}`;
1449
- }
1450
- function inspectArray(array, options) {
1451
- const nonIndexProperties = Object.keys(array).slice(array.length);
1452
- if (!array.length && !nonIndexProperties.length)
1453
- return "[]";
1454
- options.truncate -= 4;
1455
- const listContents = inspectList(array, options);
1456
- options.truncate -= listContents.length;
1457
- let propertyContents = "";
1458
- if (nonIndexProperties.length) {
1459
- propertyContents = inspectList(nonIndexProperties.map((key) => [key, array[key]]), options, inspectProperty);
1460
- }
1461
- return `[ ${listContents}${propertyContents ? `, ${propertyContents}` : ""} ]`;
1462
- }
1463
- var getArrayName = (array) => {
1464
- if (typeof Buffer === "function" && array instanceof Buffer) {
1465
- return "Buffer";
1466
- }
1467
- if (array[Symbol.toStringTag]) {
1468
- return array[Symbol.toStringTag];
1469
- }
1470
- return array.constructor.name;
1471
- };
1472
- function inspectTypedArray(array, options) {
1473
- const name = getArrayName(array);
1474
- options.truncate -= name.length + 4;
1475
- const nonIndexProperties = Object.keys(array).slice(array.length);
1476
- if (!array.length && !nonIndexProperties.length)
1477
- return `${name}[]`;
1478
- let output = "";
1479
- for (let i3 = 0; i3 < array.length; i3++) {
1480
- const string = `${options.stylize(truncate(array[i3], options.truncate), "number")}${i3 === array.length - 1 ? "" : ", "}`;
1481
- options.truncate -= string.length;
1482
- if (array[i3] !== array.length && options.truncate <= 3) {
1483
- output += `${truncator}(${array.length - array[i3] + 1})`;
1484
- break;
1485
- }
1486
- output += string;
1487
- }
1488
- let propertyContents = "";
1489
- if (nonIndexProperties.length) {
1490
- propertyContents = inspectList(nonIndexProperties.map((key) => [key, array[key]]), options, inspectProperty);
1491
- }
1492
- return `${name}[ ${output}${propertyContents ? `, ${propertyContents}` : ""} ]`;
1493
- }
1494
- function inspectDate(dateObject, options) {
1495
- const stringRepresentation = dateObject.toJSON();
1496
- if (stringRepresentation === null) {
1497
- return "Invalid Date";
1498
- }
1499
- const split = stringRepresentation.split("T");
1500
- const date = split[0];
1501
- return options.stylize(`${date}T${truncate(split[1], options.truncate - date.length - 1)}`, "date");
1502
- }
1503
- function inspectFunction(func, options) {
1504
- const functionType = func[Symbol.toStringTag] || "Function";
1505
- const name = func.name;
1506
- if (!name) {
1507
- return options.stylize(`[${functionType}]`, "special");
1508
- }
1509
- return options.stylize(`[${functionType} ${truncate(name, options.truncate - 11)}]`, "special");
1510
- }
1511
- function inspectMapEntry([key, value], options) {
1512
- options.truncate -= 4;
1513
- key = options.inspect(key, options);
1514
- options.truncate -= key.length;
1515
- value = options.inspect(value, options);
1516
- return `${key} => ${value}`;
1517
- }
1518
- function mapToEntries(map) {
1519
- const entries = [];
1520
- map.forEach((value, key) => {
1521
- entries.push([key, value]);
1522
- });
1523
- return entries;
1524
- }
1525
- function inspectMap(map, options) {
1526
- if (map.size === 0)
1527
- return "Map{}";
1528
- options.truncate -= 7;
1529
- return `Map{ ${inspectList(mapToEntries(map), options, inspectMapEntry)} }`;
1530
- }
1531
- var isNaN = Number.isNaN || ((i3) => i3 !== i3);
1532
- function inspectNumber(number, options) {
1533
- if (isNaN(number)) {
1534
- return options.stylize("NaN", "number");
1535
- }
1536
- if (number === Infinity) {
1537
- return options.stylize("Infinity", "number");
1538
- }
1539
- if (number === -Infinity) {
1540
- return options.stylize("-Infinity", "number");
1541
- }
1542
- if (number === 0) {
1543
- return options.stylize(1 / number === Infinity ? "+0" : "-0", "number");
1544
- }
1545
- return options.stylize(truncate(String(number), options.truncate), "number");
1546
- }
1547
- function inspectBigInt(number, options) {
1548
- let nums = truncate(number.toString(), options.truncate - 1);
1549
- if (nums !== truncator)
1550
- nums += "n";
1551
- return options.stylize(nums, "bigint");
1552
- }
1553
- function inspectRegExp(value, options) {
1554
- const flags = value.toString().split("/")[2];
1555
- const sourceLength = options.truncate - (2 + flags.length);
1556
- const source = value.source;
1557
- return options.stylize(`/${truncate(source, sourceLength)}/${flags}`, "regexp");
1558
- }
1559
- function arrayFromSet(set) {
1560
- const values = [];
1561
- set.forEach((value) => {
1562
- values.push(value);
1563
- });
1564
- return values;
1565
- }
1566
- function inspectSet(set, options) {
1567
- if (set.size === 0)
1568
- return "Set{}";
1569
- options.truncate -= 7;
1570
- return `Set{ ${inspectList(arrayFromSet(set), options)} }`;
1571
- }
1572
- var stringEscapeChars = new RegExp("['\\u0000-\\u001f\\u007f-\\u009f\\u00ad\\u0600-\\u0604\\u070f\\u17b4\\u17b5\\u200c-\\u200f\\u2028-\\u202f\\u2060-\\u206f\\ufeff\\ufff0-\\uffff]", "g");
1573
- var escapeCharacters = {
1574
- "\b": "\\b",
1575
- " ": "\\t",
1576
- "\n": "\\n",
1577
- "\f": "\\f",
1578
- "\r": "\\r",
1579
- "'": "\\'",
1580
- "\\": "\\\\"
1581
- };
1582
- var hex = 16;
1583
- function escape(char) {
1584
- return escapeCharacters[char] || `\\u${`0000${char.charCodeAt(0).toString(hex)}`.slice(-4)}`;
1585
- }
1586
- function inspectString(string, options) {
1587
- if (stringEscapeChars.test(string)) {
1588
- string = string.replace(stringEscapeChars, escape);
1589
- }
1590
- return options.stylize(`'${truncate(string, options.truncate - 2)}'`, "string");
1591
- }
1592
- function inspectSymbol(value) {
1593
- if ("description" in Symbol.prototype) {
1594
- return value.description ? `Symbol(${value.description})` : "Symbol()";
1595
- }
1596
- return value.toString();
1597
- }
1598
- var getPromiseValue = () => "Promise{\u2026}";
1599
- function inspectObject$1(object, options) {
1600
- const properties = Object.getOwnPropertyNames(object);
1601
- const symbols = Object.getOwnPropertySymbols ? Object.getOwnPropertySymbols(object) : [];
1602
- if (properties.length === 0 && symbols.length === 0) {
1603
- return "{}";
1604
- }
1605
- options.truncate -= 4;
1606
- options.seen = options.seen || [];
1607
- if (options.seen.includes(object)) {
1608
- return "[Circular]";
1609
- }
1610
- options.seen.push(object);
1611
- const propertyContents = inspectList(properties.map((key) => [key, object[key]]), options, inspectProperty);
1612
- const symbolContents = inspectList(symbols.map((key) => [key, object[key]]), options, inspectProperty);
1613
- options.seen.pop();
1614
- let sep = "";
1615
- if (propertyContents && symbolContents) {
1616
- sep = ", ";
1617
- }
1618
- return `{ ${propertyContents}${sep}${symbolContents} }`;
1619
- }
1620
- var toStringTag = typeof Symbol !== "undefined" && Symbol.toStringTag ? Symbol.toStringTag : false;
1621
- function inspectClass(value, options) {
1622
- let name = "";
1623
- if (toStringTag && toStringTag in value) {
1624
- name = value[toStringTag];
1625
- }
1626
- name = name || value.constructor.name;
1627
- if (!name || name === "_class") {
1628
- name = "<Anonymous Class>";
1629
- }
1630
- options.truncate -= name.length;
1631
- return `${name}${inspectObject$1(value, options)}`;
1632
- }
1633
- function inspectArguments(args, options) {
1634
- if (args.length === 0)
1635
- return "Arguments[]";
1636
- options.truncate -= 13;
1637
- return `Arguments[ ${inspectList(args, options)} ]`;
1638
- }
1639
- var errorKeys = [
1640
- "stack",
1641
- "line",
1642
- "column",
1643
- "name",
1644
- "message",
1645
- "fileName",
1646
- "lineNumber",
1647
- "columnNumber",
1648
- "number",
1649
- "description",
1650
- "cause"
1651
- ];
1652
- function inspectObject(error, options) {
1653
- const properties = Object.getOwnPropertyNames(error).filter((key) => errorKeys.indexOf(key) === -1);
1654
- const name = error.name;
1655
- options.truncate -= name.length;
1656
- let message = "";
1657
- if (typeof error.message === "string") {
1658
- message = truncate(error.message, options.truncate);
1659
- } else {
1660
- properties.unshift("message");
1661
- }
1662
- message = message ? `: ${message}` : "";
1663
- options.truncate -= message.length + 5;
1664
- options.seen = options.seen || [];
1665
- if (options.seen.includes(error)) {
1666
- return "[Circular]";
1667
- }
1668
- options.seen.push(error);
1669
- const propertyContents = inspectList(properties.map((key) => [key, error[key]]), options, inspectProperty);
1670
- return `${name}${message}${propertyContents ? ` { ${propertyContents} }` : ""}`;
1671
- }
1672
- function inspectAttribute([key, value], options) {
1673
- options.truncate -= 3;
1674
- if (!value) {
1675
- return `${options.stylize(String(key), "yellow")}`;
1676
- }
1677
- return `${options.stylize(String(key), "yellow")}=${options.stylize(`"${value}"`, "string")}`;
1678
- }
1679
- function inspectNodeCollection(collection, options) {
1680
- return inspectList(collection, options, inspectNode, "\n");
1681
- }
1682
- function inspectNode(node, options) {
1683
- switch (node.nodeType) {
1684
- case 1:
1685
- return inspectHTML(node, options);
1686
- case 3:
1687
- return options.inspect(node.data, options);
1688
- default:
1689
- return options.inspect(node, options);
1690
- }
1691
- }
1692
- function inspectHTML(element, options) {
1693
- const properties = element.getAttributeNames();
1694
- const name = element.tagName.toLowerCase();
1695
- const head = options.stylize(`<${name}`, "special");
1696
- const headClose = options.stylize(`>`, "special");
1697
- const tail = options.stylize(`</${name}>`, "special");
1698
- options.truncate -= name.length * 2 + 5;
1699
- let propertyContents = "";
1700
- if (properties.length > 0) {
1701
- propertyContents += " ";
1702
- propertyContents += inspectList(properties.map((key) => [key, element.getAttribute(key)]), options, inspectAttribute, " ");
1703
- }
1704
- options.truncate -= propertyContents.length;
1705
- const truncate2 = options.truncate;
1706
- let children = inspectNodeCollection(element.children, options);
1707
- if (children && children.length > truncate2) {
1708
- children = `${truncator}(${element.children.length})`;
1709
- }
1710
- return `${head}${propertyContents}${headClose}${children}${tail}`;
1711
- }
1712
- var symbolsSupported = typeof Symbol === "function" && typeof Symbol.for === "function";
1713
- var chaiInspect = symbolsSupported ? /* @__PURE__ */ Symbol.for("chai/inspect") : "@@chai/inspect";
1714
- var nodeInspect = /* @__PURE__ */ Symbol.for("nodejs.util.inspect.custom");
1715
- var constructorMap = /* @__PURE__ */ new WeakMap();
1716
- var stringTagMap = {};
1717
- var baseTypesMap = {
1718
- undefined: (value, options) => options.stylize("undefined", "undefined"),
1719
- null: (value, options) => options.stylize("null", "null"),
1720
- boolean: (value, options) => options.stylize(String(value), "boolean"),
1721
- Boolean: (value, options) => options.stylize(String(value), "boolean"),
1722
- number: inspectNumber,
1723
- Number: inspectNumber,
1724
- bigint: inspectBigInt,
1725
- BigInt: inspectBigInt,
1726
- string: inspectString,
1727
- String: inspectString,
1728
- function: inspectFunction,
1729
- Function: inspectFunction,
1730
- symbol: inspectSymbol,
1731
- // A Symbol polyfill will return `Symbol` not `symbol` from typedetect
1732
- Symbol: inspectSymbol,
1733
- Array: inspectArray,
1734
- Date: inspectDate,
1735
- Map: inspectMap,
1736
- Set: inspectSet,
1737
- RegExp: inspectRegExp,
1738
- Promise: getPromiseValue,
1739
- // WeakSet, WeakMap are totally opaque to us
1740
- WeakSet: (value, options) => options.stylize("WeakSet{\u2026}", "special"),
1741
- WeakMap: (value, options) => options.stylize("WeakMap{\u2026}", "special"),
1742
- Arguments: inspectArguments,
1743
- Int8Array: inspectTypedArray,
1744
- Uint8Array: inspectTypedArray,
1745
- Uint8ClampedArray: inspectTypedArray,
1746
- Int16Array: inspectTypedArray,
1747
- Uint16Array: inspectTypedArray,
1748
- Int32Array: inspectTypedArray,
1749
- Uint32Array: inspectTypedArray,
1750
- Float32Array: inspectTypedArray,
1751
- Float64Array: inspectTypedArray,
1752
- Generator: () => "",
1753
- DataView: () => "",
1754
- ArrayBuffer: () => "",
1755
- Error: inspectObject,
1756
- HTMLCollection: inspectNodeCollection,
1757
- NodeList: inspectNodeCollection
1758
- };
1759
- var inspectCustom = (value, options, type, inspectFn) => {
1760
- if (chaiInspect in value && typeof value[chaiInspect] === "function") {
1761
- return value[chaiInspect](options);
1762
- }
1763
- if (nodeInspect in value && typeof value[nodeInspect] === "function") {
1764
- return value[nodeInspect](options.depth, options, inspectFn);
1765
- }
1766
- if ("inspect" in value && typeof value.inspect === "function") {
1767
- return value.inspect(options.depth, options);
1768
- }
1769
- if ("constructor" in value && constructorMap.has(value.constructor)) {
1770
- return constructorMap.get(value.constructor)(value, options);
1771
- }
1772
- if (stringTagMap[type]) {
1773
- return stringTagMap[type](value, options);
1774
- }
1775
- return "";
1776
- };
1777
- var toString2 = Object.prototype.toString;
1778
- function inspect$1(value, opts = {}) {
1779
- const options = normaliseOptions(opts, inspect$1);
1780
- const { customInspect } = options;
1781
- let type = value === null ? "null" : typeof value;
1782
- if (type === "object") {
1783
- type = toString2.call(value).slice(8, -1);
1784
- }
1785
- if (type in baseTypesMap) {
1786
- return baseTypesMap[type](value, options);
1787
- }
1788
- if (customInspect && value) {
1789
- const output = inspectCustom(value, options, type, inspect$1);
1790
- if (output) {
1791
- if (typeof output === "string")
1792
- return output;
1793
- return inspect$1(output, options);
1794
- }
1795
- }
1796
- const proto = value ? Object.getPrototypeOf(value) : false;
1797
- if (proto === Object.prototype || proto === null) {
1798
- return inspectObject$1(value, options);
1799
- }
1800
- if (value && typeof HTMLElement === "function" && value instanceof HTMLElement) {
1801
- return inspectHTML(value, options);
1802
- }
1803
- if ("constructor" in value) {
1804
- if (value.constructor !== Object) {
1805
- return inspectClass(value, options);
1806
- }
1807
- return inspectObject$1(value, options);
1808
- }
1809
- if (value === Object(value)) {
1810
- return inspectObject$1(value, options);
1811
- }
1812
- return options.stylize(String(value), type);
1813
- }
1814
- var { AsymmetricMatcher, DOMCollection, DOMElement, Immutable, ReactElement, ReactTestComponent } = plugins;
1815
- var PLUGINS = [
1816
- ReactTestComponent,
1817
- ReactElement,
1818
- DOMElement,
1819
- DOMCollection,
1820
- Immutable,
1821
- AsymmetricMatcher
1822
- ];
1823
- function stringify(object, maxDepth = 10, { maxLength, filterNode, ...options } = {}) {
1824
- const MAX_LENGTH = maxLength ?? 1e4;
1825
- let result;
1826
- const filterFn = typeof filterNode === "string" ? createNodeFilterFromSelector(filterNode) : filterNode;
1827
- const plugins2 = filterFn ? [
1828
- ReactTestComponent,
1829
- ReactElement,
1830
- createDOMElementFilter(filterFn),
1831
- DOMCollection,
1832
- Immutable,
1833
- AsymmetricMatcher
1834
- ] : PLUGINS;
1835
- try {
1836
- result = format(object, {
1837
- maxDepth,
1838
- escapeString: false,
1839
- plugins: plugins2,
1840
- ...options
1841
- });
1842
- } catch {
1843
- result = format(object, {
1844
- callToJSON: false,
1845
- maxDepth,
1846
- escapeString: false,
1847
- plugins: plugins2,
1848
- ...options
1849
- });
1850
- }
1851
- return result.length >= MAX_LENGTH && maxDepth > 1 ? stringify(object, Math.floor(Math.min(maxDepth, Number.MAX_SAFE_INTEGER) / 2), {
1852
- maxLength,
1853
- filterNode,
1854
- ...options
1855
- }) : result;
1856
- }
1857
- function createNodeFilterFromSelector(selector) {
1858
- const ELEMENT_NODE2 = 1;
1859
- const COMMENT_NODE2 = 8;
1860
- return (node) => {
1861
- if (node.nodeType === COMMENT_NODE2) {
1862
- return false;
1863
- }
1864
- if (node.nodeType === ELEMENT_NODE2 && node.matches) {
1865
- try {
1866
- return !node.matches(selector);
1867
- } catch {
1868
- return true;
1869
- }
1870
- }
1871
- return true;
1872
- };
1873
- }
1874
- var formatRegExp = /%[sdjifoOc%]/g;
1875
- function baseFormat(args, options = {}) {
1876
- const formatArg = (item, inspecOptions) => {
1877
- if (options.prettifyObject) {
1878
- return stringify(item, void 0, {
1879
- printBasicPrototype: false,
1880
- escapeString: false
1881
- });
1882
- }
1883
- return inspect(item, inspecOptions);
1884
- };
1885
- if (typeof args[0] !== "string") {
1886
- const objects = [];
1887
- for (let i4 = 0; i4 < args.length; i4++) {
1888
- objects.push(formatArg(args[i4], {
1889
- depth: 0,
1890
- colors: false
1891
- }));
1892
- }
1893
- return objects.join(" ");
1894
- }
1895
- const len = args.length;
1896
- let i3 = 1;
1897
- const template = args[0];
1898
- let str = String(template).replace(formatRegExp, (x) => {
1899
- if (x === "%%") {
1900
- return "%";
1901
- }
1902
- if (i3 >= len) {
1903
- return x;
1904
- }
1905
- switch (x) {
1906
- case "%s": {
1907
- const value = args[i3++];
1908
- if (typeof value === "bigint") {
1909
- return `${value.toString()}n`;
1910
- }
1911
- if (typeof value === "number" && value === 0 && 1 / value < 0) {
1912
- return "-0";
1913
- }
1914
- if (typeof value === "object" && value !== null) {
1915
- if (typeof value.toString === "function" && value.toString !== Object.prototype.toString) {
1916
- return value.toString();
1917
- }
1918
- return formatArg(value, {
1919
- depth: 0,
1920
- colors: false
1921
- });
1922
- }
1923
- return String(value);
1924
- }
1925
- case "%d": {
1926
- const value = args[i3++];
1927
- if (typeof value === "bigint") {
1928
- return `${value.toString()}n`;
1929
- }
1930
- if (typeof value === "symbol") {
1931
- return "NaN";
1932
- }
1933
- return Number(value).toString();
1934
- }
1935
- case "%i": {
1936
- const value = args[i3++];
1937
- if (typeof value === "bigint") {
1938
- return `${value.toString()}n`;
1939
- }
1940
- return Number.parseInt(String(value)).toString();
1941
- }
1942
- case "%f":
1943
- return Number.parseFloat(String(args[i3++])).toString();
1944
- case "%o":
1945
- return formatArg(args[i3++], {
1946
- showHidden: true,
1947
- showProxy: true
1948
- });
1949
- case "%O":
1950
- return formatArg(args[i3++]);
1951
- case "%c": {
1952
- i3++;
1953
- return "";
1954
- }
1955
- case "%j":
1956
- try {
1957
- return JSON.stringify(args[i3++]);
1958
- } catch (err) {
1959
- const m2 = err.message;
1960
- if (m2.includes("circular structure") || m2.includes("cyclic structures") || m2.includes("cyclic object")) {
1961
- return "[Circular]";
1962
- }
1963
- throw err;
1964
- }
1965
- default:
1966
- return x;
1967
- }
1968
- });
1969
- for (let x = args[i3]; i3 < len; x = args[++i3]) {
1970
- if (x === null || typeof x !== "object") {
1971
- str += ` ${typeof x === "symbol" ? x.toString() : x}`;
1972
- } else {
1973
- str += ` ${formatArg(x)}`;
1974
- }
1975
- }
1976
- return str;
1977
- }
1978
- function format2(...args) {
1979
- return baseFormat(args);
1980
- }
1981
- function inspect(obj, options = {}) {
1982
- if (options.truncate === 0) {
1983
- options.truncate = Number.POSITIVE_INFINITY;
1984
- }
1985
- return inspect$1(obj, options);
1986
- }
1987
- function objDisplay(obj, options = {}) {
1988
- if (typeof options.truncate === "undefined") {
1989
- options.truncate = 40;
1990
- }
1991
- const str = inspect(obj, options);
1992
- const type = Object.prototype.toString.call(obj);
1993
- if (options.truncate && str.length >= options.truncate) {
1994
- if (type === "[object Function]") {
1995
- const fn = obj;
1996
- return !fn.name ? "[Function]" : `[Function: ${fn.name}]`;
1997
- } else if (type === "[object Array]") {
1998
- return `[ Array(${obj.length}) ]`;
1999
- } else if (type === "[object Object]") {
2000
- const keys = Object.keys(obj);
2001
- const kstr = keys.length > 2 ? `${keys.splice(0, 2).join(", ")}, ...` : keys.join(", ");
2002
- return `{ Object (${kstr}) }`;
2003
- } else {
2004
- return str;
2005
- }
2006
- }
2007
- return str;
2008
- }
2009
-
2010
- // ../../node_modules/.pnpm/@vitest+runner@4.1.0/node_modules/@vitest/runner/dist/index.js
2011
- var import_chunk_tasks = require("./chunk-tasks.js.cjs");
2012
- var PendingError = class extends Error {
2013
- code = "VITEST_PENDING";
2014
- taskId;
2015
- constructor(message, task, note) {
2016
- super(message);
2017
- this.message = message;
2018
- this.note = note;
2019
- this.taskId = task.id;
2020
- }
2021
- };
2022
- var FixtureDependencyError = class extends Error {
2023
- name = "FixtureDependencyError";
2024
- };
2025
- var FixtureAccessError = class extends Error {
2026
- name = "FixtureAccessError";
2027
- };
2028
- var FixtureParseError = class extends Error {
2029
- name = "FixtureParseError";
2030
- };
2031
- var fnMap = /* @__PURE__ */ new WeakMap();
2032
- var testFixtureMap = /* @__PURE__ */ new WeakMap();
2033
- var hooksMap = /* @__PURE__ */ new WeakMap();
2034
- function setFn(key, fn) {
2035
- fnMap.set(key, fn);
2036
- }
2037
- function setTestFixture(key, fixture) {
2038
- testFixtureMap.set(key, fixture);
2039
- }
2040
- function getTestFixtures(key) {
2041
- return testFixtureMap.get(key);
2042
- }
2043
- function setHooks(key, hooks) {
2044
- hooksMap.set(key, hooks);
2045
- }
2046
- function getHooks(key) {
2047
- return hooksMap.get(key);
2048
- }
2049
- var TestFixtures = class _TestFixtures {
2050
- _suiteContexts;
2051
- _overrides = /* @__PURE__ */ new WeakMap();
2052
- _registrations;
2053
- static _definitions = [];
2054
- static _builtinFixtures = [
2055
- "task",
2056
- "signal",
2057
- "onTestFailed",
2058
- "onTestFinished",
2059
- "skip",
2060
- "annotate"
2061
- ];
2062
- static _fixtureOptionKeys = [
2063
- "auto",
2064
- "injected",
2065
- "scope"
2066
- ];
2067
- static _fixtureScopes = [
2068
- "test",
2069
- "file",
2070
- "worker"
2071
- ];
2072
- static _workerContextSuite = { type: "worker" };
2073
- static clearDefinitions() {
2074
- _TestFixtures._definitions.length = 0;
2075
- }
2076
- static getWorkerContexts() {
2077
- return _TestFixtures._definitions.map((f3) => f3.getWorkerContext());
2078
- }
2079
- static getFileContexts(file) {
2080
- return _TestFixtures._definitions.map((f3) => f3.getFileContext(file));
2081
- }
2082
- constructor(registrations) {
2083
- this._registrations = registrations ?? /* @__PURE__ */ new Map();
2084
- this._suiteContexts = /* @__PURE__ */ new WeakMap();
2085
- _TestFixtures._definitions.push(this);
2086
- }
2087
- extend(runner2, userFixtures) {
2088
- const { suite: suite2 } = getCurrentSuite();
2089
- const isTopLevel = !suite2 || suite2.file === suite2;
2090
- const registrations = this.parseUserFixtures(runner2, userFixtures, isTopLevel);
2091
- return new _TestFixtures(registrations);
2092
- }
2093
- get(suite2) {
2094
- let currentSuite = suite2;
2095
- while (currentSuite) {
2096
- const overrides = this._overrides.get(currentSuite);
2097
- if (overrides) {
2098
- return overrides;
2099
- }
2100
- if (currentSuite === currentSuite.file) {
2101
- break;
2102
- }
2103
- currentSuite = currentSuite.suite || currentSuite.file;
2104
- }
2105
- return this._registrations;
2106
- }
2107
- override(runner2, userFixtures) {
2108
- const { suite: currentSuite, file } = getCurrentSuite();
2109
- const suite2 = currentSuite || file;
2110
- const isTopLevel = !currentSuite || currentSuite.file === currentSuite;
2111
- const suiteRegistrations = new Map(this.get(suite2));
2112
- const registrations = this.parseUserFixtures(runner2, userFixtures, isTopLevel, suiteRegistrations);
2113
- if (isTopLevel) {
2114
- this._registrations = registrations;
2115
- } else {
2116
- this._overrides.set(suite2, registrations);
2117
- }
2118
- }
2119
- getFileContext(file) {
2120
- if (!this._suiteContexts.has(file)) {
2121
- this._suiteContexts.set(file, /* @__PURE__ */ Object.create(null));
2122
- }
2123
- return this._suiteContexts.get(file);
2124
- }
2125
- getWorkerContext() {
2126
- if (!this._suiteContexts.has(_TestFixtures._workerContextSuite)) {
2127
- this._suiteContexts.set(_TestFixtures._workerContextSuite, /* @__PURE__ */ Object.create(null));
2128
- }
2129
- return this._suiteContexts.get(_TestFixtures._workerContextSuite);
2130
- }
2131
- parseUserFixtures(runner2, userFixtures, supportNonTest, registrations = new Map(this._registrations)) {
2132
- const errors = [];
2133
- Object.entries(userFixtures).forEach(([name, fn]) => {
2134
- let options;
2135
- let value;
2136
- let _options;
2137
- if (Array.isArray(fn) && fn.length >= 2 && isObject(fn[1]) && Object.keys(fn[1]).some((key) => _TestFixtures._fixtureOptionKeys.includes(key))) {
2138
- _options = fn[1];
2139
- options = {
2140
- auto: _options.auto ?? false,
2141
- scope: _options.scope ?? "test",
2142
- injected: _options.injected ?? false
2143
- };
2144
- value = options.injected ? runner2.injectValue?.(name) ?? fn[0] : fn[0];
2145
- } else {
2146
- value = fn;
2147
- }
2148
- const parent = registrations.get(name);
2149
- if (parent && options) {
2150
- if (parent.scope !== options.scope) {
2151
- errors.push(new FixtureDependencyError(`The "${name}" fixture was already registered with a "${options.scope}" scope.`));
2152
- }
2153
- if (parent.auto !== options.auto) {
2154
- errors.push(new FixtureDependencyError(`The "${name}" fixture was already registered as { auto: ${options.auto} }.`));
2155
- }
2156
- } else if (parent) {
2157
- options = {
2158
- auto: parent.auto,
2159
- scope: parent.scope,
2160
- injected: parent.injected
2161
- };
2162
- } else if (!options) {
2163
- options = {
2164
- auto: false,
2165
- injected: false,
2166
- scope: "test"
2167
- };
2168
- }
2169
- if (options.scope && !_TestFixtures._fixtureScopes.includes(options.scope)) {
2170
- errors.push(new FixtureDependencyError(`The "${name}" fixture has unknown scope "${options.scope}".`));
2171
- }
2172
- if (!supportNonTest && options.scope !== "test") {
2173
- errors.push(new FixtureDependencyError(`The "${name}" fixture cannot be defined with a ${options.scope} scope${!_options?.scope && parent?.scope ? " (inherited from the base fixture)" : ""} inside the describe block. Define it at the top level of the file instead.`));
2174
- }
2175
- const deps = isFixtureFunction(value) ? getUsedProps(value) : /* @__PURE__ */ new Set();
2176
- const item = {
2177
- name,
2178
- value,
2179
- auto: options.auto ?? false,
2180
- injected: options.injected ?? false,
2181
- scope: options.scope ?? "test",
2182
- deps,
2183
- parent
2184
- };
2185
- registrations.set(name, item);
2186
- if (item.scope === "worker" && (runner2.pool === "vmThreads" || runner2.pool === "vmForks")) {
2187
- item.scope = "file";
2188
- }
2189
- });
2190
- for (const fixture of registrations.values()) {
2191
- for (const depName of fixture.deps) {
2192
- if (_TestFixtures._builtinFixtures.includes(depName)) {
2193
- continue;
2194
- }
2195
- const dep = registrations.get(depName);
2196
- if (!dep) {
2197
- errors.push(new FixtureDependencyError(`The "${fixture.name}" fixture depends on unknown fixture "${depName}".`));
2198
- continue;
2199
- }
2200
- if (depName === fixture.name && !fixture.parent) {
2201
- errors.push(new FixtureDependencyError(`The "${fixture.name}" fixture depends on itself, but does not have a base implementation.`));
2202
- continue;
2203
- }
2204
- if (_TestFixtures._fixtureScopes.indexOf(fixture.scope) > _TestFixtures._fixtureScopes.indexOf(dep.scope)) {
2205
- errors.push(new FixtureDependencyError(`The ${fixture.scope} "${fixture.name}" fixture cannot depend on a ${dep.scope} fixture "${dep.name}".`));
2206
- continue;
2207
- }
2208
- }
2209
- }
2210
- if (errors.length === 1) {
2211
- throw errors[0];
2212
- } else if (errors.length > 1) {
2213
- throw new AggregateError(errors, "Cannot resolve user fixtures. See errors for more information.");
2214
- }
2215
- return registrations;
2216
- }
2217
- };
2218
- var cleanupFnArrayMap = /* @__PURE__ */ new WeakMap();
2219
- var contextHasFixturesCache = /* @__PURE__ */ new WeakMap();
2220
- function withFixtures(fn, options) {
2221
- const collector = getCurrentSuite();
2222
- const suite2 = options?.suite || collector.suite || collector.file;
2223
- return async (hookContext) => {
2224
- const context = hookContext || options?.context;
2225
- if (!context) {
2226
- if (options?.suiteHook) {
2227
- validateSuiteHook(fn, options.suiteHook, options.stackTraceError);
2228
- }
2229
- return fn({});
2230
- }
2231
- const fixtures = options?.fixtures || getTestFixtures(context);
2232
- if (!fixtures) {
2233
- return fn(context);
2234
- }
2235
- const registrations = fixtures.get(suite2);
2236
- if (!registrations.size) {
2237
- return fn(context);
2238
- }
2239
- const usedFixtures = [];
2240
- const usedProps = getUsedProps(fn);
2241
- for (const fixture of registrations.values()) {
2242
- if (fixture.auto || usedProps.has(fixture.name)) {
2243
- usedFixtures.push(fixture);
2244
- }
2245
- }
2246
- if (!usedFixtures.length) {
2247
- return fn(context);
2248
- }
2249
- if (!cleanupFnArrayMap.has(context)) {
2250
- cleanupFnArrayMap.set(context, []);
2251
- }
2252
- const cleanupFnArray = cleanupFnArrayMap.get(context);
2253
- const pendingFixtures = resolveDeps(usedFixtures, registrations);
2254
- if (!pendingFixtures.length) {
2255
- return fn(context);
2256
- }
2257
- if (options?.suiteHook) {
2258
- const testScopedFixtures = pendingFixtures.filter((f3) => f3.scope === "test");
2259
- if (testScopedFixtures.length > 0) {
2260
- const fixtureNames = testScopedFixtures.map((f3) => `"${f3.name}"`).join(", ");
2261
- const alternativeHook = {
2262
- aroundAll: "aroundEach",
2263
- beforeAll: "beforeEach",
2264
- afterAll: "afterEach"
2265
- };
2266
- const error = new FixtureDependencyError(`Test-scoped fixtures cannot be used inside ${options.suiteHook} hook. The following fixtures are test-scoped: ${fixtureNames}. Use { scope: 'file' } or { scope: 'worker' } fixtures instead, or move the logic to ${alternativeHook[options.suiteHook]} hook.`);
2267
- if (options.stackTraceError?.stack) {
2268
- error.stack = error.message + options.stackTraceError.stack.replace(options.stackTraceError.message, "");
2269
- }
2270
- throw error;
2271
- }
2272
- }
2273
- if (!contextHasFixturesCache.has(context)) {
2274
- contextHasFixturesCache.set(context, /* @__PURE__ */ new WeakSet());
2275
- }
2276
- const cachedFixtures = contextHasFixturesCache.get(context);
2277
- for (const fixture of pendingFixtures) {
2278
- if (fixture.scope === "test") {
2279
- if (cachedFixtures.has(fixture)) {
2280
- continue;
2281
- }
2282
- cachedFixtures.add(fixture);
2283
- const resolvedValue = await resolveTestFixtureValue(fixture, context, cleanupFnArray);
2284
- context[fixture.name] = resolvedValue;
2285
- cleanupFnArray.push(() => {
2286
- cachedFixtures.delete(fixture);
2287
- });
2288
- } else {
2289
- const resolvedValue = await resolveScopeFixtureValue(fixtures, suite2, fixture);
2290
- context[fixture.name] = resolvedValue;
2291
- }
2292
- }
2293
- return fn(context);
2294
- };
2295
- }
2296
- function isFixtureFunction(value) {
2297
- return typeof value === "function";
2298
- }
2299
- function resolveTestFixtureValue(fixture, context, cleanupFnArray) {
2300
- if (!isFixtureFunction(fixture.value)) {
2301
- return fixture.value;
2302
- }
2303
- return resolveFixtureFunction(fixture.value, context, cleanupFnArray);
2304
- }
2305
- var scopedFixturePromiseCache = /* @__PURE__ */ new WeakMap();
2306
- async function resolveScopeFixtureValue(fixtures, suite2, fixture) {
2307
- const workerContext = fixtures.getWorkerContext();
2308
- const fileContext = fixtures.getFileContext(suite2.file);
2309
- const fixtureContext = fixture.scope === "worker" ? workerContext : fileContext;
2310
- if (!isFixtureFunction(fixture.value)) {
2311
- fixtureContext[fixture.name] = fixture.value;
2312
- return fixture.value;
2313
- }
2314
- if (fixture.name in fixtureContext) {
2315
- return fixtureContext[fixture.name];
2316
- }
2317
- if (scopedFixturePromiseCache.has(fixture)) {
2318
- return scopedFixturePromiseCache.get(fixture);
2319
- }
2320
- if (!cleanupFnArrayMap.has(fixtureContext)) {
2321
- cleanupFnArrayMap.set(fixtureContext, []);
2322
- }
2323
- const cleanupFnFileArray = cleanupFnArrayMap.get(fixtureContext);
2324
- const promise = resolveFixtureFunction(fixture.value, fixture.scope === "file" ? {
2325
- ...workerContext,
2326
- ...fileContext
2327
- } : fixtureContext, cleanupFnFileArray).then((value) => {
2328
- fixtureContext[fixture.name] = value;
2329
- scopedFixturePromiseCache.delete(fixture);
2330
- return value;
2331
- });
2332
- scopedFixturePromiseCache.set(fixture, promise);
2333
- return promise;
2334
- }
2335
- async function resolveFixtureFunction(fixtureFn, context, cleanupFnArray) {
2336
- const useFnArgPromise = createDefer();
2337
- let isUseFnArgResolved = false;
2338
- const fixtureReturn = fixtureFn(context, async (useFnArg) => {
2339
- isUseFnArgResolved = true;
2340
- useFnArgPromise.resolve(useFnArg);
2341
- const useReturnPromise = createDefer();
2342
- cleanupFnArray.push(async () => {
2343
- useReturnPromise.resolve();
2344
- await fixtureReturn;
2345
- });
2346
- await useReturnPromise;
2347
- }).catch((e2) => {
2348
- if (!isUseFnArgResolved) {
2349
- useFnArgPromise.reject(e2);
2350
- return;
2351
- }
2352
- throw e2;
2353
- });
2354
- return useFnArgPromise;
2355
- }
2356
- function resolveDeps(usedFixtures, registrations, depSet = /* @__PURE__ */ new Set(), pendingFixtures = []) {
2357
- usedFixtures.forEach((fixture) => {
2358
- if (pendingFixtures.includes(fixture)) {
2359
- return;
2360
- }
2361
- if (!isFixtureFunction(fixture.value) || !fixture.deps) {
2362
- pendingFixtures.push(fixture);
2363
- return;
2364
- }
2365
- if (depSet.has(fixture)) {
2366
- if (fixture.parent) {
2367
- fixture = fixture.parent;
2368
- } else {
2369
- throw new Error(`Circular fixture dependency detected: ${fixture.name} <- ${[...depSet].reverse().map((d3) => d3.name).join(" <- ")}`);
2370
- }
2371
- }
2372
- depSet.add(fixture);
2373
- resolveDeps([...fixture.deps].map((n2) => n2 === fixture.name ? fixture.parent : registrations.get(n2)).filter((n2) => !!n2), registrations, depSet, pendingFixtures);
2374
- pendingFixtures.push(fixture);
2375
- depSet.clear();
2376
- });
2377
- return pendingFixtures;
2378
- }
2379
- function validateSuiteHook(fn, hook, suiteError) {
2380
- const usedProps = getUsedProps(fn, {
2381
- sourceError: suiteError,
2382
- suiteHook: hook
2383
- });
2384
- if (usedProps.size) {
2385
- const error = new FixtureAccessError(`The ${hook} hook uses fixtures "${[...usedProps].join('", "')}", but has no access to context. Did you forget to call it as "test.${hook}()" instead of "${hook}()"?
2386
- If you used internal "suite" task as the first argument previously, access it in the second argument instead. See https://vitest.dev/guide/test-context#suite-level-hooks`);
2387
- if (suiteError) {
2388
- error.stack = suiteError.stack?.replace(suiteError.message, error.message);
2389
- }
2390
- throw error;
2391
- }
2392
- }
2393
- var kPropsSymbol = /* @__PURE__ */ Symbol("$vitest:fixture-props");
2394
- var kPropNamesSymbol = /* @__PURE__ */ Symbol("$vitest:fixture-prop-names");
2395
- function configureProps(fn, options) {
2396
- Object.defineProperty(fn, kPropsSymbol, {
2397
- value: options,
2398
- enumerable: false
2399
- });
2400
- }
2401
- function memoProps(fn, props) {
2402
- fn[kPropNamesSymbol] = props;
2403
- return props;
2404
- }
2405
- function getUsedProps(fn, { sourceError, suiteHook } = {}) {
2406
- if (kPropNamesSymbol in fn) {
2407
- return fn[kPropNamesSymbol];
2408
- }
2409
- const { index: fixturesIndex = 0, original: implementation = fn } = kPropsSymbol in fn ? fn[kPropsSymbol] : {};
2410
- let fnString = filterOutComments(implementation.toString());
2411
- if (/__async\((?:this|null), (?:null|arguments|\[[_0-9, ]*\]), function\*/.test(fnString)) {
2412
- fnString = fnString.split(/__async\((?:this|null),/)[1];
2413
- }
2414
- const match = fnString.match(/[^(]*\(([^)]*)/);
2415
- if (!match) {
2416
- return memoProps(fn, /* @__PURE__ */ new Set());
2417
- }
2418
- const args = splitByComma(match[1]);
2419
- if (!args.length) {
2420
- return memoProps(fn, /* @__PURE__ */ new Set());
2421
- }
2422
- const fixturesArgument = args[fixturesIndex];
2423
- if (!fixturesArgument) {
2424
- return memoProps(fn, /* @__PURE__ */ new Set());
2425
- }
2426
- if (!(fixturesArgument[0] === "{" && fixturesArgument.endsWith("}"))) {
2427
- const ordinalArgument = ordinal(fixturesIndex + 1);
2428
- const error = new FixtureParseError(`The ${ordinalArgument} argument inside a fixture must use object destructuring pattern, e.g. ({ task } => {}). Instead, received "${fixturesArgument}".${suiteHook ? ` If you used internal "suite" task as the ${ordinalArgument} argument previously, access it in the ${ordinal(fixturesIndex + 2)} argument instead.` : ""}`);
2429
- if (sourceError) {
2430
- error.stack = sourceError.stack?.replace(sourceError.message, error.message);
2431
- }
2432
- throw error;
2433
- }
2434
- const _first = fixturesArgument.slice(1, -1).replace(/\s/g, "");
2435
- const props = splitByComma(_first).map((prop) => {
2436
- return prop.replace(/:.*|=.*/g, "");
2437
- });
2438
- const last = props.at(-1);
2439
- if (last && last.startsWith("...")) {
2440
- const error = new FixtureParseError(`Rest parameters are not supported in fixtures, received "${last}".`);
2441
- if (sourceError) {
2442
- error.stack = sourceError.stack?.replace(sourceError.message, error.message);
2443
- }
2444
- throw error;
2445
- }
2446
- return memoProps(fn, new Set(props));
2447
- }
2448
- function splitByComma(s3) {
2449
- const result = [];
2450
- const stack = [];
2451
- let start = 0;
2452
- for (let i3 = 0; i3 < s3.length; i3++) {
2453
- if (s3[i3] === "{" || s3[i3] === "[") {
2454
- stack.push(s3[i3] === "{" ? "}" : "]");
2455
- } else if (s3[i3] === stack.at(-1)) {
2456
- stack.pop();
2457
- } else if (!stack.length && s3[i3] === ",") {
2458
- const token = s3.substring(start, i3).trim();
2459
- if (token) {
2460
- result.push(token);
2461
- }
2462
- start = i3 + 1;
2463
- }
2464
- }
2465
- const lastToken = s3.substring(start).trim();
2466
- if (lastToken) {
2467
- result.push(lastToken);
2468
- }
2469
- return result;
2470
- }
2471
- var _test;
2472
- function getCurrentTest() {
2473
- return _test;
2474
- }
2475
- function getDefaultHookTimeout() {
2476
- return getRunner().config.hookTimeout;
2477
- }
2478
- var CLEANUP_TIMEOUT_KEY = /* @__PURE__ */ Symbol.for("VITEST_CLEANUP_TIMEOUT");
2479
- var CLEANUP_STACK_TRACE_KEY = /* @__PURE__ */ Symbol.for("VITEST_CLEANUP_STACK_TRACE");
2480
- var AROUND_TIMEOUT_KEY = /* @__PURE__ */ Symbol.for("VITEST_AROUND_TIMEOUT");
2481
- var AROUND_STACK_TRACE_KEY = /* @__PURE__ */ Symbol.for("VITEST_AROUND_STACK_TRACE");
2482
- function beforeAll(fn, timeout = getDefaultHookTimeout()) {
2483
- assertTypes(fn, '"beforeAll" callback', ["function"]);
2484
- const stackTraceError = new Error("STACK_TRACE_ERROR");
2485
- const context = (0, import_chunk_tasks.w)(this);
2486
- return getCurrentSuite().on("beforeAll", Object.assign(withTimeout(withSuiteFixtures("beforeAll", fn, context, stackTraceError), timeout, true, stackTraceError), {
2487
- [CLEANUP_TIMEOUT_KEY]: timeout,
2488
- [CLEANUP_STACK_TRACE_KEY]: stackTraceError
2489
- }));
2490
- }
2491
- function afterAll(fn, timeout) {
2492
- assertTypes(fn, '"afterAll" callback', ["function"]);
2493
- const context = (0, import_chunk_tasks.w)(this);
2494
- const stackTraceError = new Error("STACK_TRACE_ERROR");
2495
- return getCurrentSuite().on("afterAll", withTimeout(withSuiteFixtures("afterAll", fn, context, stackTraceError), timeout ?? getDefaultHookTimeout(), true, stackTraceError));
2496
- }
2497
- function beforeEach(fn, timeout = getDefaultHookTimeout()) {
2498
- assertTypes(fn, '"beforeEach" callback', ["function"]);
2499
- const stackTraceError = new Error("STACK_TRACE_ERROR");
2500
- const wrapper = (context, suite2) => {
2501
- const fixtureResolver = withFixtures(fn, { suite: suite2 });
2502
- return fixtureResolver(context);
2503
- };
2504
- return getCurrentSuite().on("beforeEach", Object.assign(withTimeout(wrapper, timeout ?? getDefaultHookTimeout(), true, stackTraceError, abortIfTimeout), {
2505
- [CLEANUP_TIMEOUT_KEY]: timeout,
2506
- [CLEANUP_STACK_TRACE_KEY]: stackTraceError
2507
- }));
2508
- }
2509
- function afterEach(fn, timeout) {
2510
- assertTypes(fn, '"afterEach" callback', ["function"]);
2511
- const wrapper = (context, suite2) => {
2512
- const fixtureResolver = withFixtures(fn, { suite: suite2 });
2513
- return fixtureResolver(context);
2514
- };
2515
- return getCurrentSuite().on("afterEach", withTimeout(wrapper, timeout ?? getDefaultHookTimeout(), true, new Error("STACK_TRACE_ERROR"), abortIfTimeout));
2516
- }
2517
- var onTestFailed = createTestHook("onTestFailed", (test3, handler, timeout) => {
2518
- test3.onFailed ||= [];
2519
- test3.onFailed.push(withTimeout(handler, timeout ?? getDefaultHookTimeout(), true, new Error("STACK_TRACE_ERROR"), abortIfTimeout));
2520
- });
2521
- var onTestFinished = createTestHook("onTestFinished", (test3, handler, timeout) => {
2522
- test3.onFinished ||= [];
2523
- test3.onFinished.push(withTimeout(handler, timeout ?? getDefaultHookTimeout(), true, new Error("STACK_TRACE_ERROR"), abortIfTimeout));
2524
- });
2525
- function aroundAll(fn, timeout) {
2526
- assertTypes(fn, '"aroundAll" callback', ["function"]);
2527
- const stackTraceError = new Error("STACK_TRACE_ERROR");
2528
- const resolvedTimeout = timeout ?? getDefaultHookTimeout();
2529
- const context = (0, import_chunk_tasks.w)(this);
2530
- return getCurrentSuite().on("aroundAll", Object.assign(withSuiteFixtures("aroundAll", fn, context, stackTraceError, 1), {
2531
- [AROUND_TIMEOUT_KEY]: resolvedTimeout,
2532
- [AROUND_STACK_TRACE_KEY]: stackTraceError
2533
- }));
2534
- }
2535
- function aroundEach(fn, timeout) {
2536
- assertTypes(fn, '"aroundEach" callback', ["function"]);
2537
- const stackTraceError = new Error("STACK_TRACE_ERROR");
2538
- const resolvedTimeout = timeout ?? getDefaultHookTimeout();
2539
- const wrapper = (runTest, context, suite2) => {
2540
- const innerFn = (ctx) => fn(runTest, ctx, suite2);
2541
- configureProps(innerFn, {
2542
- index: 1,
2543
- original: fn
2544
- });
2545
- const fixtureResolver = withFixtures(innerFn, { suite: suite2 });
2546
- return fixtureResolver(context);
2547
- };
2548
- return getCurrentSuite().on("aroundEach", Object.assign(wrapper, {
2549
- [AROUND_TIMEOUT_KEY]: resolvedTimeout,
2550
- [AROUND_STACK_TRACE_KEY]: stackTraceError
2551
- }));
2552
- }
2553
- function withSuiteFixtures(suiteHook, fn, context, stackTraceError, contextIndex = 0) {
2554
- return (...args) => {
2555
- const suite2 = args.at(-1);
2556
- const prefix = args.slice(0, -1);
2557
- const wrapper = (ctx) => fn(...prefix, ctx, suite2);
2558
- configureProps(wrapper, {
2559
- index: contextIndex,
2560
- original: fn
2561
- });
2562
- const fixtures = context?.getFixtures();
2563
- const fileContext = fixtures?.getFileContext(suite2.file);
2564
- const fixtured = withFixtures(wrapper, {
2565
- suiteHook,
2566
- fixtures,
2567
- context: fileContext,
2568
- stackTraceError
2569
- });
2570
- return fixtured();
2571
- };
2572
- }
2573
- function createTestHook(name, handler) {
2574
- return (fn, timeout) => {
2575
- assertTypes(fn, `"${name}" callback`, ["function"]);
2576
- const current = getCurrentTest();
2577
- if (!current) {
2578
- throw new Error(`Hook ${name}() can only be called inside a test`);
2579
- }
2580
- return handler(current, fn, timeout);
2581
- };
2582
- }
2583
- var suite = createSuite();
2584
- var test2 = createTest(function(name, optionsOrFn, optionsOrTest) {
2585
- if (getCurrentTest()) {
2586
- throw new Error('Calling the test function inside another test function is not allowed. Please put it inside "describe" or "suite" so it can be properly collected.');
2587
- }
2588
- getCurrentSuite().test.fn.call(this, formatName(name), optionsOrFn, optionsOrTest);
2589
- });
2590
- var describe = suite;
2591
- var runner;
2592
- var defaultSuite;
2593
- var currentTestFilepath;
2594
- function assert(condition, message) {
2595
- if (!condition) {
2596
- throw new Error(`Vitest failed to find ${message}. One of the following is possible:
2597
- - "vitest" is imported directly without running "vitest" command
2598
- - "vitest" is imported inside "globalSetup" (to fix this, use "setupFiles" instead, because "globalSetup" runs in a different context)
2599
- - "vitest" is imported inside Vite / Vitest config file
2600
- - Otherwise, it might be a Vitest bug. Please report it to https://github.com/vitest-dev/vitest/issues
2601
- `);
2602
- }
2603
- }
2604
- function getRunner() {
2605
- assert(runner, "the runner");
2606
- return runner;
2607
- }
2608
- function getCurrentSuite() {
2609
- const currentSuite = collectorContext.currentSuite || defaultSuite;
2610
- assert(currentSuite, "the current suite");
2611
- return currentSuite;
2612
- }
2613
- function createSuiteHooks() {
2614
- return {
2615
- beforeAll: [],
2616
- afterAll: [],
2617
- beforeEach: [],
2618
- afterEach: [],
2619
- aroundEach: [],
2620
- aroundAll: []
2621
- };
2622
- }
2623
- var POSITIVE_INFINITY = Number.POSITIVE_INFINITY;
2624
- function parseArguments(optionsOrFn, timeoutOrTest) {
2625
- if (timeoutOrTest != null && typeof timeoutOrTest === "object") {
2626
- throw new TypeError(`Signature "test(name, fn, { ... })" was deprecated in Vitest 3 and removed in Vitest 4. Please, provide options as a second argument instead.`);
2627
- }
2628
- let options = {};
2629
- let fn;
2630
- if (typeof timeoutOrTest === "number") {
2631
- options = { timeout: timeoutOrTest };
2632
- } else if (typeof optionsOrFn === "object") {
2633
- options = optionsOrFn;
2634
- }
2635
- if (typeof optionsOrFn === "function") {
2636
- if (typeof timeoutOrTest === "function") {
2637
- throw new TypeError("Cannot use two functions as arguments. Please use the second argument for options.");
2638
- }
2639
- fn = optionsOrFn;
2640
- } else if (typeof timeoutOrTest === "function") {
2641
- fn = timeoutOrTest;
2642
- }
2643
- return {
2644
- options,
2645
- handler: fn
2646
- };
2647
- }
2648
- function createSuiteCollector(name, factory = () => {
2649
- }, mode, each, suiteOptions) {
2650
- const tasks = [];
2651
- let suite2;
2652
- initSuite(true);
2653
- const task = function(name2 = "", options = {}) {
2654
- const currentSuite = collectorContext.currentSuite?.suite;
2655
- const parentTask = currentSuite ?? collectorContext.currentSuite?.file;
2656
- const parentTags = parentTask?.tags || [];
2657
- const testTags = unique([...parentTags, ...toArray(options.tags)]);
2658
- const tagsOptions = testTags.map((tag) => {
2659
- const tagDefinition = runner.config.tags?.find((t2) => t2.name === tag);
2660
- if (!tagDefinition && runner.config.strictTags) {
2661
- throw (0, import_chunk_tasks.x)(runner.config.tags, tag);
2662
- }
2663
- return tagDefinition;
2664
- }).filter((r2) => r2 != null).sort((tag1, tag2) => (tag2.priority ?? POSITIVE_INFINITY) - (tag1.priority ?? POSITIVE_INFINITY)).reduce((acc, tag) => {
2665
- const { name: name3, description, priority, meta, ...options2 } = tag;
2666
- Object.assign(acc, options2);
2667
- if (meta) {
2668
- acc.meta = Object.assign(acc.meta ?? /* @__PURE__ */ Object.create(null), meta);
2669
- }
2670
- return acc;
2671
- }, {});
2672
- const testOwnMeta = options.meta;
2673
- options = {
2674
- ...tagsOptions,
2675
- ...options
2676
- };
2677
- const timeout = options.timeout ?? runner.config.testTimeout;
2678
- const parentMeta = currentSuite?.meta;
2679
- const tagMeta = tagsOptions.meta;
2680
- const testMeta = /* @__PURE__ */ Object.create(null);
2681
- if (tagMeta) {
2682
- Object.assign(testMeta, tagMeta);
2683
- }
2684
- if (parentMeta) {
2685
- Object.assign(testMeta, parentMeta);
2686
- }
2687
- if (testOwnMeta) {
2688
- Object.assign(testMeta, testOwnMeta);
2689
- }
2690
- const task2 = {
2691
- id: "",
2692
- name: name2,
2693
- fullName: (0, import_chunk_tasks.e)([currentSuite?.fullName ?? collectorContext.currentSuite?.file?.fullName, name2]),
2694
- fullTestName: (0, import_chunk_tasks.e)([currentSuite?.fullTestName, name2]),
2695
- suite: currentSuite,
2696
- each: options.each,
2697
- fails: options.fails,
2698
- context: void 0,
2699
- type: "test",
2700
- file: currentSuite?.file ?? collectorContext.currentSuite?.file,
2701
- timeout,
2702
- retry: options.retry ?? runner.config.retry,
2703
- repeats: options.repeats,
2704
- mode: options.only ? "only" : options.skip ? "skip" : options.todo ? "todo" : "run",
2705
- meta: testMeta,
2706
- annotations: [],
2707
- artifacts: [],
2708
- tags: testTags
2709
- };
2710
- const handler = options.handler;
2711
- if (task2.mode === "run" && !handler) {
2712
- task2.mode = "todo";
2713
- }
2714
- if (options.concurrent || !options.sequential && runner.config.sequence.concurrent) {
2715
- task2.concurrent = true;
2716
- }
2717
- task2.shuffle = suiteOptions?.shuffle;
2718
- const context = createTestContext(task2, runner);
2719
- Object.defineProperty(task2, "context", {
2720
- value: context,
2721
- enumerable: false
2722
- });
2723
- setTestFixture(context, options.fixtures ?? new TestFixtures());
2724
- const limit = Error.stackTraceLimit;
2725
- Error.stackTraceLimit = 10;
2726
- const stackTraceError = new Error("STACK_TRACE_ERROR");
2727
- Error.stackTraceLimit = limit;
2728
- if (handler) {
2729
- setFn(task2, withTimeout(withCancel(withAwaitAsyncAssertions(withFixtures(handler, { context }), task2), task2.context.signal), timeout, false, stackTraceError, (_, error) => abortIfTimeout([context], error)));
2730
- }
2731
- if (runner.config.includeTaskLocation) {
2732
- const error = stackTraceError.stack;
2733
- const stack = (0, import_chunk_tasks.f)(currentTestFilepath, error);
2734
- if (stack) {
2735
- task2.location = {
2736
- line: stack.line,
2737
- column: stack.column
2738
- };
2739
- }
2740
- }
2741
- tasks.push(task2);
2742
- return task2;
2743
- };
2744
- const test3 = createTest(function(name2, optionsOrFn, timeoutOrTest) {
2745
- let { options, handler } = parseArguments(optionsOrFn, timeoutOrTest);
2746
- if (typeof suiteOptions === "object") {
2747
- options = Object.assign({}, suiteOptions, options);
2748
- }
2749
- const concurrent = this.concurrent ?? (!this.sequential && options?.concurrent);
2750
- if (options.concurrent != null && concurrent != null) {
2751
- options.concurrent = concurrent;
2752
- }
2753
- const sequential = this.sequential ?? (!this.concurrent && options?.sequential);
2754
- if (options.sequential != null && sequential != null) {
2755
- options.sequential = sequential;
2756
- }
2757
- const test4 = task(formatName(name2), {
2758
- ...this,
2759
- ...options,
2760
- handler
2761
- });
2762
- test4.type = "test";
2763
- });
2764
- const collector = {
2765
- type: "collector",
2766
- name,
2767
- mode,
2768
- suite: suite2,
2769
- options: suiteOptions,
2770
- test: test3,
2771
- file: suite2.file,
2772
- tasks,
2773
- collect,
2774
- task,
2775
- clear,
2776
- on: addHook
2777
- };
2778
- function addHook(name2, ...fn) {
2779
- getHooks(suite2)[name2].push(...fn);
2780
- }
2781
- function initSuite(includeLocation) {
2782
- if (typeof suiteOptions === "number") {
2783
- suiteOptions = { timeout: suiteOptions };
2784
- }
2785
- const currentSuite = collectorContext.currentSuite?.suite;
2786
- const parentTask = currentSuite ?? collectorContext.currentSuite?.file;
2787
- const suiteTags = toArray(suiteOptions?.tags);
2788
- (0, import_chunk_tasks.v)(runner.config, suiteTags);
2789
- suite2 = {
2790
- id: "",
2791
- type: "suite",
2792
- name,
2793
- fullName: (0, import_chunk_tasks.e)([currentSuite?.fullName ?? collectorContext.currentSuite?.file?.fullName, name]),
2794
- fullTestName: (0, import_chunk_tasks.e)([currentSuite?.fullTestName, name]),
2795
- suite: currentSuite,
2796
- mode,
2797
- each,
2798
- file: currentSuite?.file ?? collectorContext.currentSuite?.file,
2799
- shuffle: suiteOptions?.shuffle,
2800
- tasks: [],
2801
- meta: suiteOptions?.meta ?? /* @__PURE__ */ Object.create(null),
2802
- concurrent: suiteOptions?.concurrent,
2803
- tags: unique([...parentTask?.tags || [], ...suiteTags])
2804
- };
2805
- if (runner && includeLocation && runner.config.includeTaskLocation) {
2806
- const limit = Error.stackTraceLimit;
2807
- Error.stackTraceLimit = 15;
2808
- const error = new Error("stacktrace").stack;
2809
- Error.stackTraceLimit = limit;
2810
- const stack = (0, import_chunk_tasks.f)(currentTestFilepath, error);
2811
- if (stack) {
2812
- suite2.location = {
2813
- line: stack.line,
2814
- column: stack.column
2815
- };
2816
- }
2817
- }
2818
- setHooks(suite2, createSuiteHooks());
2819
- }
2820
- function clear() {
2821
- tasks.length = 0;
2822
- initSuite(false);
2823
- }
2824
- async function collect(file) {
2825
- if (!file) {
2826
- throw new TypeError("File is required to collect tasks.");
2827
- }
2828
- if (factory) {
2829
- await runWithSuite(collector, () => factory(test3));
2830
- }
2831
- const allChildren = [];
2832
- for (const i3 of tasks) {
2833
- allChildren.push(i3.type === "collector" ? await i3.collect(file) : i3);
2834
- }
2835
- suite2.tasks = allChildren;
2836
- return suite2;
2837
- }
2838
- collectTask(collector);
2839
- return collector;
2840
- }
2841
- function withAwaitAsyncAssertions(fn, task) {
2842
- return (async (...args) => {
2843
- const fnResult = await fn(...args);
2844
- if (task.promises) {
2845
- const result = await Promise.allSettled(task.promises);
2846
- const errors = result.map((r2) => r2.status === "rejected" ? r2.reason : void 0).filter(Boolean);
2847
- if (errors.length) {
2848
- throw errors;
2849
- }
2850
- }
2851
- return fnResult;
2852
- });
2853
- }
2854
- function createSuite() {
2855
- function suiteFn(name, factoryOrOptions, optionsOrFactory) {
2856
- if (getCurrentTest()) {
2857
- throw new Error("Calling the suite function inside test function is not allowed. It can be only called at the top level or inside another suite function.");
2858
- }
2859
- const currentSuite = collectorContext.currentSuite || defaultSuite;
2860
- let { options, handler: factory } = parseArguments(factoryOrOptions, optionsOrFactory);
2861
- const isConcurrentSpecified = options.concurrent || this.concurrent || options.sequential === false;
2862
- const isSequentialSpecified = options.sequential || this.sequential || options.concurrent === false;
2863
- const { meta: parentMeta, ...parentOptions } = currentSuite?.options || {};
2864
- options = {
2865
- ...parentOptions,
2866
- ...options
2867
- };
2868
- const shuffle2 = this.shuffle ?? options.shuffle ?? currentSuite?.options?.shuffle ?? runner?.config.sequence.shuffle;
2869
- if (shuffle2 != null) {
2870
- options.shuffle = shuffle2;
2871
- }
2872
- let mode = this.only ?? options.only ? "only" : this.skip ?? options.skip ? "skip" : this.todo ?? options.todo ? "todo" : "run";
2873
- if (mode === "run" && !factory) {
2874
- mode = "todo";
2875
- }
2876
- const isConcurrent = isConcurrentSpecified || options.concurrent && !isSequentialSpecified;
2877
- const isSequential = isSequentialSpecified || options.sequential && !isConcurrentSpecified;
2878
- if (isConcurrent != null) {
2879
- options.concurrent = isConcurrent && !isSequential;
2880
- }
2881
- if (isSequential != null) {
2882
- options.sequential = isSequential && !isConcurrent;
2883
- }
2884
- if (parentMeta) {
2885
- options.meta = Object.assign(/* @__PURE__ */ Object.create(null), parentMeta, options.meta);
2886
- }
2887
- return createSuiteCollector(formatName(name), factory, mode, this.each, options);
2888
- }
2889
- suiteFn.each = function(cases, ...args) {
2890
- const context = (0, import_chunk_tasks.w)(this);
2891
- const suite2 = context.withContext();
2892
- context.setContext("each", true);
2893
- if (Array.isArray(cases) && args.length) {
2894
- cases = formatTemplateString(cases, args);
2895
- }
2896
- return (name, optionsOrFn, fnOrOptions) => {
2897
- const _name = formatName(name);
2898
- const arrayOnlyCases = cases.every(Array.isArray);
2899
- const { options, handler } = parseArguments(optionsOrFn, fnOrOptions);
2900
- const fnFirst = typeof optionsOrFn === "function";
2901
- cases.forEach((i3, idx) => {
2902
- const items = Array.isArray(i3) ? i3 : [i3];
2903
- if (fnFirst) {
2904
- if (arrayOnlyCases) {
2905
- suite2(formatTitle(_name, items, idx), handler ? () => handler(...items) : void 0, options.timeout);
2906
- } else {
2907
- suite2(formatTitle(_name, items, idx), handler ? () => handler(i3) : void 0, options.timeout);
2908
- }
2909
- } else {
2910
- if (arrayOnlyCases) {
2911
- suite2(formatTitle(_name, items, idx), options, handler ? () => handler(...items) : void 0);
2912
- } else {
2913
- suite2(formatTitle(_name, items, idx), options, handler ? () => handler(i3) : void 0);
2914
- }
2915
- }
2916
- });
2917
- context.setContext("each", void 0);
2918
- };
2919
- };
2920
- suiteFn.for = function(cases, ...args) {
2921
- if (Array.isArray(cases) && args.length) {
2922
- cases = formatTemplateString(cases, args);
2923
- }
2924
- return (name, optionsOrFn, fnOrOptions) => {
2925
- const name_ = formatName(name);
2926
- const { options, handler } = parseArguments(optionsOrFn, fnOrOptions);
2927
- cases.forEach((item, idx) => {
2928
- suite(formatTitle(name_, toArray(item), idx), options, handler ? () => handler(item) : void 0);
2929
- });
2930
- };
2931
- };
2932
- suiteFn.skipIf = (condition) => condition ? suite.skip : suite;
2933
- suiteFn.runIf = (condition) => condition ? suite : suite.skip;
2934
- return (0, import_chunk_tasks.a)([
2935
- "concurrent",
2936
- "sequential",
2937
- "shuffle",
2938
- "skip",
2939
- "only",
2940
- "todo"
2941
- ], suiteFn);
2942
- }
2943
- function createTaskCollector(fn) {
2944
- const taskFn = fn;
2945
- taskFn.each = function(cases, ...args) {
2946
- const context = (0, import_chunk_tasks.w)(this);
2947
- const test3 = context.withContext();
2948
- context.setContext("each", true);
2949
- if (Array.isArray(cases) && args.length) {
2950
- cases = formatTemplateString(cases, args);
2951
- }
2952
- return (name, optionsOrFn, fnOrOptions) => {
2953
- const _name = formatName(name);
2954
- const arrayOnlyCases = cases.every(Array.isArray);
2955
- const { options, handler } = parseArguments(optionsOrFn, fnOrOptions);
2956
- const fnFirst = typeof optionsOrFn === "function";
2957
- cases.forEach((i3, idx) => {
2958
- const items = Array.isArray(i3) ? i3 : [i3];
2959
- if (fnFirst) {
2960
- if (arrayOnlyCases) {
2961
- test3(formatTitle(_name, items, idx), handler ? () => handler(...items) : void 0, options.timeout);
2962
- } else {
2963
- test3(formatTitle(_name, items, idx), handler ? () => handler(i3) : void 0, options.timeout);
2964
- }
2965
- } else {
2966
- if (arrayOnlyCases) {
2967
- test3(formatTitle(_name, items, idx), options, handler ? () => handler(...items) : void 0);
2968
- } else {
2969
- test3(formatTitle(_name, items, idx), options, handler ? () => handler(i3) : void 0);
2970
- }
2971
- }
2972
- });
2973
- context.setContext("each", void 0);
2974
- };
2975
- };
2976
- taskFn.for = function(cases, ...args) {
2977
- const context = (0, import_chunk_tasks.w)(this);
2978
- const test3 = context.withContext();
2979
- if (Array.isArray(cases) && args.length) {
2980
- cases = formatTemplateString(cases, args);
2981
- }
2982
- return (name, optionsOrFn, fnOrOptions) => {
2983
- const _name = formatName(name);
2984
- const { options, handler } = parseArguments(optionsOrFn, fnOrOptions);
2985
- cases.forEach((item, idx) => {
2986
- const handlerWrapper = handler ? (ctx) => handler(item, ctx) : void 0;
2987
- if (handlerWrapper) {
2988
- configureProps(handlerWrapper, {
2989
- index: 1,
2990
- original: handler
2991
- });
2992
- }
2993
- test3(formatTitle(_name, toArray(item), idx), options, handlerWrapper);
2994
- });
2995
- };
2996
- };
2997
- taskFn.skipIf = function(condition) {
2998
- return condition ? this.skip : this;
2999
- };
3000
- taskFn.runIf = function(condition) {
3001
- return condition ? this : this.skip;
3002
- };
3003
- function parseBuilderFixtures(fixturesOrName, optionsOrFn, maybeFn) {
3004
- if (typeof fixturesOrName !== "string") {
3005
- return fixturesOrName;
3006
- }
3007
- const fixtureName = fixturesOrName;
3008
- let fixtureOptions;
3009
- let fixtureValue;
3010
- if (maybeFn !== void 0) {
3011
- fixtureOptions = optionsOrFn;
3012
- fixtureValue = maybeFn;
3013
- } else {
3014
- if (optionsOrFn !== null && typeof optionsOrFn === "object" && !Array.isArray(optionsOrFn) && ("scope" in optionsOrFn || "auto" in optionsOrFn)) {
3015
- fixtureOptions = optionsOrFn;
3016
- fixtureValue = {};
3017
- } else {
3018
- fixtureOptions = void 0;
3019
- fixtureValue = optionsOrFn;
3020
- }
3021
- }
3022
- if (typeof fixtureValue === "function") {
3023
- const builderFn = fixtureValue;
3024
- const fixture = async (ctx, use) => {
3025
- let cleanup;
3026
- const onCleanup = (fn2) => {
3027
- if (cleanup !== void 0) {
3028
- throw new Error(`onCleanup can only be called once per fixture. Define separate fixtures if you need multiple cleanup functions.`);
3029
- }
3030
- cleanup = fn2;
3031
- };
3032
- const value = await builderFn(ctx, { onCleanup });
3033
- await use(value);
3034
- if (cleanup) {
3035
- await cleanup();
3036
- }
3037
- };
3038
- configureProps(fixture, { original: builderFn });
3039
- if (fixtureOptions) {
3040
- return { [fixtureName]: [fixture, fixtureOptions] };
3041
- }
3042
- return { [fixtureName]: fixture };
3043
- }
3044
- if (fixtureOptions) {
3045
- return { [fixtureName]: [fixtureValue, fixtureOptions] };
3046
- }
3047
- return { [fixtureName]: fixtureValue };
3048
- }
3049
- taskFn.override = function(fixturesOrName, optionsOrFn, maybeFn) {
3050
- const userFixtures = parseBuilderFixtures(fixturesOrName, optionsOrFn, maybeFn);
3051
- (0, import_chunk_tasks.w)(this).getFixtures().override(runner, userFixtures);
3052
- return this;
3053
- };
3054
- taskFn.scoped = function(fixtures) {
3055
- console.warn(`test.scoped() is deprecated and will be removed in future versions. Please use test.override() instead.`);
3056
- return this.override(fixtures);
3057
- };
3058
- taskFn.extend = function(fixturesOrName, optionsOrFn, maybeFn) {
3059
- const userFixtures = parseBuilderFixtures(fixturesOrName, optionsOrFn, maybeFn);
3060
- const fixtures = (0, import_chunk_tasks.w)(this).getFixtures().extend(runner, userFixtures);
3061
- const _test3 = createTest(function(name, optionsOrFn2, optionsOrTest) {
3062
- fn.call(this, formatName(name), optionsOrFn2, optionsOrTest);
3063
- });
3064
- (0, import_chunk_tasks.w)(_test3).mergeContext({ fixtures });
3065
- return _test3;
3066
- };
3067
- taskFn.describe = suite;
3068
- taskFn.suite = suite;
3069
- taskFn.beforeEach = beforeEach;
3070
- taskFn.afterEach = afterEach;
3071
- taskFn.beforeAll = beforeAll;
3072
- taskFn.afterAll = afterAll;
3073
- taskFn.aroundEach = aroundEach;
3074
- taskFn.aroundAll = aroundAll;
3075
- const _test2 = (0, import_chunk_tasks.a)([
3076
- "concurrent",
3077
- "sequential",
3078
- "skip",
3079
- "only",
3080
- "todo",
3081
- "fails"
3082
- ], taskFn, { fixtures: new TestFixtures() });
3083
- return _test2;
3084
- }
3085
- function createTest(fn) {
3086
- return createTaskCollector(fn);
3087
- }
3088
- function formatName(name) {
3089
- return typeof name === "string" ? name : typeof name === "function" ? name.name || "<anonymous>" : String(name);
3090
- }
3091
- function formatTitle(template, items, idx) {
3092
- if (template.includes("%#") || template.includes("%$")) {
3093
- template = template.replace(/%%/g, "__vitest_escaped_%__").replace(/%#/g, `${idx}`).replace(/%\$/g, `${idx + 1}`).replace(/__vitest_escaped_%__/g, "%%");
3094
- }
3095
- const count = template.split("%").length - 1;
3096
- if (template.includes("%f")) {
3097
- const placeholders = template.match(/%f/g) || [];
3098
- placeholders.forEach((_, i4) => {
3099
- if (isNegativeNaN(items[i4]) || Object.is(items[i4], -0)) {
3100
- let occurrence = 0;
3101
- template = template.replace(/%f/g, (match) => {
3102
- occurrence++;
3103
- return occurrence === i4 + 1 ? "-%f" : match;
3104
- });
3105
- }
3106
- });
3107
- }
3108
- const isObjectItem = isObject(items[0]);
3109
- function formatAttribute(s3) {
3110
- return s3.replace(/\$([$\w.]+)/g, (_, key) => {
3111
- const isArrayKey = /^\d+$/.test(key);
3112
- if (!isObjectItem && !isArrayKey) {
3113
- return `$${key}`;
3114
- }
3115
- const arrayElement = isArrayKey ? objectAttr(items, key) : void 0;
3116
- const value = isObjectItem ? objectAttr(items[0], key, arrayElement) : arrayElement;
3117
- return objDisplay(value, { truncate: runner?.config?.chaiConfig?.truncateThreshold });
3118
- });
3119
- }
3120
- let output = "";
3121
- let i3 = 0;
3122
- handleRegexMatch(
3123
- template,
3124
- formatRegExp,
3125
- // format "%"
3126
- (match) => {
3127
- if (i3 < count) {
3128
- output += format2(match[0], items[i3++]);
3129
- } else {
3130
- output += match[0];
3131
- }
3132
- },
3133
- // format "$"
3134
- (nonMatch) => {
3135
- output += formatAttribute(nonMatch);
3136
- }
3137
- );
3138
- return output;
3139
- }
3140
- function handleRegexMatch(input, regex, onMatch, onNonMatch) {
3141
- let lastIndex = 0;
3142
- for (const m2 of input.matchAll(regex)) {
3143
- if (lastIndex < m2.index) {
3144
- onNonMatch(input.slice(lastIndex, m2.index));
3145
- }
3146
- onMatch(m2);
3147
- lastIndex = m2.index + m2[0].length;
3148
- }
3149
- if (lastIndex < input.length) {
3150
- onNonMatch(input.slice(lastIndex));
3151
- }
3152
- }
3153
- function formatTemplateString(cases, args) {
3154
- const header = cases.join("").trim().replace(/ /g, "").split("\n").map((i3) => i3.split("|"))[0];
3155
- const res = [];
3156
- for (let i3 = 0; i3 < Math.floor(args.length / header.length); i3++) {
3157
- const oneCase = {};
3158
- for (let j2 = 0; j2 < header.length; j2++) {
3159
- oneCase[header[j2]] = args[i3 * header.length + j2];
3160
- }
3161
- res.push(oneCase);
3162
- }
3163
- return res;
3164
- }
3165
- var now$2 = globalThis.performance ? globalThis.performance.now.bind(globalThis.performance) : Date.now;
3166
- var collectorContext = {
3167
- tasks: [],
3168
- currentSuite: null
3169
- };
3170
- function collectTask(task) {
3171
- collectorContext.currentSuite?.tasks.push(task);
3172
- }
3173
- async function runWithSuite(suite2, fn) {
3174
- const prev = collectorContext.currentSuite;
3175
- collectorContext.currentSuite = suite2;
3176
- await fn();
3177
- collectorContext.currentSuite = prev;
3178
- }
3179
- function withTimeout(fn, timeout, isHook = false, stackTraceError, onTimeout) {
3180
- if (timeout <= 0 || timeout === Number.POSITIVE_INFINITY) {
3181
- return fn;
3182
- }
3183
- const { setTimeout: setTimeout3, clearTimeout: clearTimeout3 } = getSafeTimers();
3184
- return (function runWithTimeout(...args) {
3185
- const startTime = now$2();
3186
- const runner2 = getRunner();
3187
- runner2._currentTaskStartTime = startTime;
3188
- runner2._currentTaskTimeout = timeout;
3189
- return new Promise((resolve_, reject_) => {
3190
- const timer = setTimeout3(() => {
3191
- clearTimeout3(timer);
3192
- rejectTimeoutError();
3193
- }, timeout);
3194
- timer.unref?.();
3195
- function rejectTimeoutError() {
3196
- const error = makeTimeoutError(isHook, timeout, stackTraceError);
3197
- onTimeout?.(args, error);
3198
- reject_(error);
3199
- }
3200
- function resolve(result) {
3201
- runner2._currentTaskStartTime = void 0;
3202
- runner2._currentTaskTimeout = void 0;
3203
- clearTimeout3(timer);
3204
- if (now$2() - startTime >= timeout) {
3205
- rejectTimeoutError();
3206
- return;
3207
- }
3208
- resolve_(result);
3209
- }
3210
- function reject(error) {
3211
- runner2._currentTaskStartTime = void 0;
3212
- runner2._currentTaskTimeout = void 0;
3213
- clearTimeout3(timer);
3214
- reject_(error);
3215
- }
3216
- try {
3217
- const result = fn(...args);
3218
- if (typeof result === "object" && result != null && typeof result.then === "function") {
3219
- result.then(resolve, reject);
3220
- } else {
3221
- resolve(result);
3222
- }
3223
- } catch (error) {
3224
- reject(error);
3225
- }
3226
- });
3227
- });
3228
- }
3229
- function withCancel(fn, signal) {
3230
- return (function runWithCancel(...args) {
3231
- return new Promise((resolve, reject) => {
3232
- signal.addEventListener("abort", () => reject(signal.reason));
3233
- try {
3234
- const result = fn(...args);
3235
- if (typeof result === "object" && result != null && typeof result.then === "function") {
3236
- result.then(resolve, reject);
3237
- } else {
3238
- resolve(result);
3239
- }
3240
- } catch (error) {
3241
- reject(error);
3242
- }
3243
- });
3244
- });
3245
- }
3246
- var abortControllers = /* @__PURE__ */ new WeakMap();
3247
- function abortIfTimeout([context], error) {
3248
- if (context) {
3249
- abortContextSignal(context, error);
3250
- }
3251
- }
3252
- function abortContextSignal(context, error) {
3253
- const abortController = abortControllers.get(context);
3254
- abortController?.abort(error);
3255
- }
3256
- function createTestContext(test3, runner2) {
3257
- const context = function() {
3258
- throw new Error("done() callback is deprecated, use promise instead");
3259
- };
3260
- let abortController = abortControllers.get(context);
3261
- if (!abortController) {
3262
- abortController = new AbortController();
3263
- abortControllers.set(context, abortController);
3264
- }
3265
- context.signal = abortController.signal;
3266
- context.task = test3;
3267
- context.skip = (condition, note) => {
3268
- if (condition === false) {
3269
- return void 0;
3270
- }
3271
- test3.result ??= { state: "skip" };
3272
- test3.result.pending = true;
3273
- throw new PendingError("test is skipped; abort execution", test3, typeof condition === "string" ? condition : note);
3274
- };
3275
- context.annotate = ((message, type, attachment) => {
3276
- if (test3.result && test3.result.state !== "run") {
3277
- throw new Error(`Cannot annotate tests outside of the test run. The test "${test3.name}" finished running with the "${test3.result.state}" state already.`);
3278
- }
3279
- const annotation = {
3280
- message,
3281
- type: typeof type === "object" || type === void 0 ? "notice" : type
3282
- };
3283
- const annotationAttachment = typeof type === "object" ? type : attachment;
3284
- if (annotationAttachment) {
3285
- annotation.attachment = annotationAttachment;
3286
- manageArtifactAttachment(annotation.attachment);
3287
- }
3288
- return recordAsyncOperation(test3, recordArtifact(test3, {
3289
- type: "internal:annotation",
3290
- annotation
3291
- }).then(async ({ annotation: annotation2 }) => {
3292
- if (!runner2.onTestAnnotate) {
3293
- throw new Error(`Test runner doesn't support test annotations.`);
3294
- }
3295
- await finishSendTasksUpdate(runner2);
3296
- const resolvedAnnotation = await runner2.onTestAnnotate(test3, annotation2);
3297
- test3.annotations.push(resolvedAnnotation);
3298
- return resolvedAnnotation;
3299
- }));
3300
- });
3301
- context.onTestFailed = (handler, timeout) => {
3302
- test3.onFailed ||= [];
3303
- test3.onFailed.push(withTimeout(handler, timeout ?? runner2.config.hookTimeout, true, new Error("STACK_TRACE_ERROR"), (_, error) => abortController.abort(error)));
3304
- };
3305
- context.onTestFinished = (handler, timeout) => {
3306
- test3.onFinished ||= [];
3307
- test3.onFinished.push(withTimeout(handler, timeout ?? runner2.config.hookTimeout, true, new Error("STACK_TRACE_ERROR"), (_, error) => abortController.abort(error)));
3308
- };
3309
- return runner2.extendTaskContext?.(context) || context;
3310
- }
3311
- function makeTimeoutError(isHook, timeout, stackTraceError) {
3312
- const message = `${isHook ? "Hook" : "Test"} timed out in ${timeout}ms.
3313
- If this is a long-running ${isHook ? "hook" : "test"}, pass a timeout value as the last argument or configure it globally with "${isHook ? "hookTimeout" : "testTimeout"}".`;
3314
- const error = new Error(message);
3315
- if (stackTraceError?.stack) {
3316
- error.stack = stackTraceError.stack.replace(error.message, stackTraceError.message);
3317
- }
3318
- return error;
3319
- }
3320
- var now$1 = globalThis.performance ? globalThis.performance.now.bind(globalThis.performance) : Date.now;
3321
- var now = globalThis.performance ? globalThis.performance.now.bind(globalThis.performance) : Date.now;
3322
- var unixNow = Date.now;
3323
- var { clearTimeout: clearTimeout2, setTimeout: setTimeout2 } = getSafeTimers();
3324
- var packs = /* @__PURE__ */ new Map();
3325
- var eventsPacks = [];
3326
- var pendingTasksUpdates = [];
3327
- function sendTasksUpdate(runner2) {
3328
- if (packs.size) {
3329
- const taskPacks = Array.from(packs).map(([id, task]) => {
3330
- return [
3331
- id,
3332
- task[0],
3333
- task[1]
3334
- ];
3335
- });
3336
- const p2 = runner2.onTaskUpdate?.(taskPacks, eventsPacks);
3337
- if (p2) {
3338
- pendingTasksUpdates.push(p2);
3339
- p2.then(() => pendingTasksUpdates.splice(pendingTasksUpdates.indexOf(p2), 1), () => {
3340
- });
3341
- }
3342
- eventsPacks.length = 0;
3343
- packs.clear();
3344
- }
3345
- }
3346
- async function finishSendTasksUpdate(runner2) {
3347
- sendTasksUpdate(runner2);
3348
- await Promise.all(pendingTasksUpdates);
3349
- }
3350
- function throttle(fn, ms) {
3351
- let last = 0;
3352
- let pendingCall;
3353
- return function call(...args) {
3354
- const now2 = unixNow();
3355
- if (now2 - last > ms) {
3356
- last = now2;
3357
- clearTimeout2(pendingCall);
3358
- pendingCall = void 0;
3359
- return fn.apply(this, args);
3360
- }
3361
- pendingCall ??= setTimeout2(() => call.bind(this)(...args), ms);
3362
- };
3363
- }
3364
- var sendTasksUpdateThrottled = throttle(sendTasksUpdate, 100);
3365
- async function recordArtifact(task, artifact) {
3366
- const runner2 = getRunner();
3367
- const stack = (0, import_chunk_tasks.f)(task.file.filepath, new Error("STACK_TRACE").stack);
3368
- if (stack) {
3369
- artifact.location = {
3370
- file: stack.file,
3371
- line: stack.line,
3372
- column: stack.column
3373
- };
3374
- if (artifact.type === "internal:annotation") {
3375
- artifact.annotation.location = artifact.location;
3376
- }
3377
- }
3378
- if (Array.isArray(artifact.attachments)) {
3379
- for (const attachment of artifact.attachments) {
3380
- manageArtifactAttachment(attachment);
3381
- }
3382
- }
3383
- if (artifact.type === "internal:annotation") {
3384
- return artifact;
3385
- }
3386
- if (!runner2.onTestArtifactRecord) {
3387
- throw new Error(`Test runner doesn't support test artifacts.`);
3388
- }
3389
- await finishSendTasksUpdate(runner2);
3390
- const resolvedArtifact = await runner2.onTestArtifactRecord(task, artifact);
3391
- task.artifacts.push(resolvedArtifact);
3392
- return resolvedArtifact;
3393
- }
3394
- var table = [];
3395
- for (let i3 = 65; i3 < 91; i3++) {
3396
- table.push(String.fromCharCode(i3));
3397
- }
3398
- for (let i3 = 97; i3 < 123; i3++) {
3399
- table.push(String.fromCharCode(i3));
3400
- }
3401
- for (let i3 = 0; i3 < 10; i3++) {
3402
- table.push(i3.toString(10));
3403
- }
3404
- table.push("+", "/");
3405
- function encodeUint8Array(bytes) {
3406
- let base64 = "";
3407
- const len = bytes.byteLength;
3408
- for (let i3 = 0; i3 < len; i3 += 3) {
3409
- if (len === i3 + 1) {
3410
- const a4 = (bytes[i3] & 252) >> 2;
3411
- const b4 = (bytes[i3] & 3) << 4;
3412
- base64 += table[a4];
3413
- base64 += table[b4];
3414
- base64 += "==";
3415
- } else if (len === i3 + 2) {
3416
- const a4 = (bytes[i3] & 252) >> 2;
3417
- const b4 = (bytes[i3] & 3) << 4 | (bytes[i3 + 1] & 240) >> 4;
3418
- const c3 = (bytes[i3 + 1] & 15) << 2;
3419
- base64 += table[a4];
3420
- base64 += table[b4];
3421
- base64 += table[c3];
3422
- base64 += "=";
3423
- } else {
3424
- const a4 = (bytes[i3] & 252) >> 2;
3425
- const b4 = (bytes[i3] & 3) << 4 | (bytes[i3 + 1] & 240) >> 4;
3426
- const c3 = (bytes[i3 + 1] & 15) << 2 | (bytes[i3 + 2] & 192) >> 6;
3427
- const d3 = bytes[i3 + 2] & 63;
3428
- base64 += table[a4];
3429
- base64 += table[b4];
3430
- base64 += table[c3];
3431
- base64 += table[d3];
3432
- }
3433
- }
3434
- return base64;
3435
- }
3436
- function recordAsyncOperation(test3, promise) {
3437
- promise = promise.finally(() => {
3438
- if (!test3.promises) {
3439
- return;
3440
- }
3441
- const index2 = test3.promises.indexOf(promise);
3442
- if (index2 !== -1) {
3443
- test3.promises.splice(index2, 1);
3444
- }
3445
- });
3446
- if (!test3.promises) {
3447
- test3.promises = [];
3448
- }
3449
- test3.promises.push(promise);
3450
- return promise;
3451
- }
3452
- function manageArtifactAttachment(attachment) {
3453
- if (attachment.body == null && !attachment.path) {
3454
- throw new TypeError(`Test attachment requires "body" or "path" to be set. Both are missing.`);
3455
- }
3456
- if (attachment.body && attachment.path) {
3457
- throw new TypeError(`Test attachment requires only one of "body" or "path" to be set. Both are specified.`);
3458
- }
3459
- if (attachment.body instanceof Uint8Array) {
3460
- attachment.body = encodeUint8Array(attachment.body);
3461
- }
3462
- }
118
+ // ../../node_modules/.pnpm/@vitest+runner@4.1.2/node_modules/@vitest/runner/dist/index.js
119
+ var import_chunk_artifact = require("./chunk-artifact.js.cjs");
3463
120
 
3464
- // ../../node_modules/.pnpm/vitest@4.1.0_@opentelemetry+api@1.9.0_@types+node@25.3.0_vite@7.3.1_@types+node@25.3.0__1256cd9683254972294f67b42fe9fd18/node_modules/vitest/dist/index.js
121
+ // ../../node_modules/.pnpm/vitest@4.1.2_@opentelemetry+api@1.9.0_@types+node@25.3.0_vite@7.3.1_@types+node@25.3.0__e6bcf260a45e49571a6b9e648e155cb6/node_modules/vitest/dist/index.js
3465
122
  var import_utils_BX5Fg8C4 = require("./chunks/utils.BX5Fg8C4.js.cjs");
3466
123
 
3467
- // ../../node_modules/.pnpm/@vitest+runner@4.1.0/node_modules/@vitest/runner/dist/utils.js
3468
- var import_chunk_tasks2 = require("./chunk-tasks.js.cjs");
124
+ // ../../node_modules/.pnpm/@vitest+runner@4.1.2/node_modules/@vitest/runner/dist/utils.js
125
+ var import_chunk_artifact2 = require("./chunk-artifact.js.cjs");
3469
126
 
3470
- // ../../node_modules/.pnpm/vitest@4.1.0_@opentelemetry+api@1.9.0_@types+node@25.3.0_vite@7.3.1_@types+node@25.3.0__1256cd9683254972294f67b42fe9fd18/node_modules/vitest/dist/index.js
127
+ // ../../node_modules/.pnpm/vitest@4.1.2_@opentelemetry+api@1.9.0_@types+node@25.3.0_vite@7.3.1_@types+node@25.3.0__e6bcf260a45e49571a6b9e648e155cb6/node_modules/vitest/dist/index.js
3471
128
  var import_commonjsHelpers_D26ty3Ew = require("./chunks/_commonjsHelpers.D26ty3Ew.js.cjs");
3472
129
  var import_rpc_MzXet3jl = require("./chunks/rpc.MzXet3jl.js.cjs");
3473
130
  var import_index_Chj8NDwU = require("./chunks/index.Chj8NDwU.js.cjs");
@@ -3522,90 +179,68 @@ var import_common = require("../common.cjs");
3522
179
  var import_redis = require("../redis.cjs");
3523
180
  var redis = new import_ioredis.default("redis://default:123456@localhost:6379");
3524
181
  var repository = new import_redis.RedisIndexedSessionRepository(redis, "myapp:session");
3525
- describe("redis session crud", () => {
182
+ (0, import_chunk_artifact.h)("redis session crud", () => {
3526
183
  const principalName = "user_123456";
3527
- test2("should create a session", async () => {
184
+ (0, import_chunk_artifact.v)("should create a session", async () => {
3528
185
  const session = repository.createSession();
3529
186
  const sessionId = session.getId();
3530
187
  session.setAttribute(import_common.PRINCIPAL_NAME_INDEX_NAME, principalName);
3531
188
  await repository.save(session);
3532
189
  const foundSession = await repository.findById(sessionId);
3533
- (0, import_test_CTcmp4Su.g)(foundSession?.getAttribute(import_common.PRINCIPAL_NAME_INDEX_NAME)).toBe(principalName);
190
+ (0, import_test_p_J6dB8a.g)(foundSession?.getAttribute(import_common.PRINCIPAL_NAME_INDEX_NAME)).toBe(principalName);
3534
191
  });
3535
- test2("should find a session by principal name", async () => {
192
+ (0, import_chunk_artifact.v)("should find a session by principal name", async () => {
3536
193
  const sessions = await repository.findByPrincipalName(principalName);
3537
- (0, import_test_CTcmp4Su.g)(sessions.size).toBeGreaterThan(0);
194
+ (0, import_test_p_J6dB8a.g)(sessions.size).toBeGreaterThan(0);
3538
195
  });
3539
- test2("should delete a session by id", async () => {
196
+ (0, import_chunk_artifact.v)("should delete a session by id", async () => {
3540
197
  const sessions = await repository.findByPrincipalName(principalName);
3541
198
  for (const session of sessions.values()) {
3542
199
  const sessionId = session.getId();
3543
200
  await repository.deleteById(sessionId);
3544
201
  const foundSession = await repository.findById(sessionId);
3545
- (0, import_test_CTcmp4Su.g)(foundSession).toBeNull();
202
+ (0, import_test_p_J6dB8a.g)(foundSession).toBeNull();
3546
203
  }
3547
204
  });
3548
205
  });
3549
- describe("redis session attributes", () => {
3550
- test2("should set and get attributes", async () => {
206
+ (0, import_chunk_artifact.h)("redis session attributes", () => {
207
+ (0, import_chunk_artifact.v)("should set and get attributes", async () => {
3551
208
  const session = repository.createSession();
3552
209
  session.setAttribute("test_key", "test_value");
3553
210
  const sessionId = session.getId();
3554
211
  await repository.save(session);
3555
212
  const foundSession = await repository.findById(sessionId);
3556
- (0, import_test_CTcmp4Su.g)(foundSession).not.toBeNull();
3557
- (0, import_test_CTcmp4Su.g)(foundSession?.getAttribute("test_key")).toBe("test_value");
213
+ (0, import_test_p_J6dB8a.g)(foundSession).not.toBeNull();
214
+ (0, import_test_p_J6dB8a.g)(foundSession?.getAttribute("test_key")).toBe("test_value");
3558
215
  foundSession?.removeAttribute("test_key");
3559
216
  if (foundSession) await repository.save(foundSession);
3560
217
  const foundSession2 = await repository.findById(sessionId);
3561
- (0, import_test_CTcmp4Su.g)(foundSession2?.getAttribute("test_key")).toBeNull();
218
+ (0, import_test_p_J6dB8a.g)(foundSession2?.getAttribute("test_key")).toBeNull();
3562
219
  });
3563
- test2("should change session id", async () => {
220
+ (0, import_chunk_artifact.v)("should change session id", async () => {
3564
221
  const session = repository.createSession();
3565
222
  session.setAttribute("test_key", "test_value");
3566
223
  session.setAttribute(import_common.PRINCIPAL_NAME_INDEX_NAME, "user_123");
3567
224
  const oldSessionId = session.getId();
3568
225
  await repository.save(session);
3569
226
  const oldSession = await repository.findById(oldSessionId);
3570
- (0, import_test_CTcmp4Su.g)(oldSession).not.toBeNull();
227
+ (0, import_test_p_J6dB8a.g)(oldSession).not.toBeNull();
3571
228
  if (!oldSession) throw new Error("Not found session id");
3572
229
  const newSessionId = oldSession.changeSessionId();
3573
230
  await repository.save(oldSession);
3574
231
  const foundSession1 = await repository.findById(oldSessionId);
3575
- (0, import_test_CTcmp4Su.g)(foundSession1).toBeNull();
232
+ (0, import_test_p_J6dB8a.g)(foundSession1).toBeNull();
3576
233
  const foundSession2 = await repository.findById(newSessionId);
3577
- (0, import_test_CTcmp4Su.g)(foundSession2).not.toBeNull();
234
+ (0, import_test_p_J6dB8a.g)(foundSession2).not.toBeNull();
3578
235
  });
3579
236
  });
3580
- describe("redis session config", () => {
237
+ (0, import_chunk_artifact.h)("redis session config", () => {
3581
238
  const maxInactiveInterval = 24 * 60 * 60;
3582
239
  repository.setDefaultMaxInactiveInterval(maxInactiveInterval);
3583
- test2("should set default max inactive interval", () => {
240
+ (0, import_chunk_artifact.v)("should set default max inactive interval", () => {
3584
241
  const session = repository.createSession();
3585
- (0, import_test_CTcmp4Su.g)(session.isExpired()).toBe(false);
3586
- (0, import_test_CTcmp4Su.g)(session.getMaxInactiveInterval()).toBe(maxInactiveInterval);
242
+ (0, import_test_p_J6dB8a.g)(session.isExpired()).toBe(false);
243
+ (0, import_test_p_J6dB8a.g)(session.getMaxInactiveInterval()).toBe(maxInactiveInterval);
3587
244
  });
3588
245
  });
3589
- /*! Bundled license information:
3590
-
3591
- @vitest/pretty-format/dist/index.js:
3592
- (**
3593
- * @license React
3594
- * react-is.production.js
3595
- *
3596
- * Copyright (c) Meta Platforms, Inc. and affiliates.
3597
- *
3598
- * This source code is licensed under the MIT license found in the
3599
- * LICENSE file in the root directory of this source tree.
3600
- *)
3601
- (**
3602
- * @license React
3603
- * react-is.production.min.js
3604
- *
3605
- * Copyright (c) Facebook, Inc. and its affiliates.
3606
- *
3607
- * This source code is licensed under the MIT license found in the
3608
- * LICENSE file in the root directory of this source tree.
3609
- *)
3610
- */
3611
246
  //# sourceMappingURL=redis.test.cjs.map