trilean 1.13.4 → 1.13.6

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.
@@ -1,88 +1,90 @@
1
1
  import "expect-type";
2
- //#region ../../node_modules/.pnpm/vitest@5.0.3_@types+node@26.6.5_@vitest+coverage-v8@5.0.4_vite@8.2.2_@types+node@26.6.5_220b0db820952837b535c2e83c4bd0a5/node_modules/vitest/dist/chunks/tinyrainbow.Ht9iggcq.js
3
- var b$1 = {
4
- reset: [0, 0],
5
- bold: [
6
- 1,
7
- 22,
8
- "\x1B[22m\x1B[1m"
9
- ],
10
- dim: [
11
- 2,
12
- 22,
13
- "\x1B[22m\x1B[2m"
14
- ],
15
- italic: [3, 23],
16
- underline: [4, 24],
17
- inverse: [7, 27],
18
- hidden: [8, 28],
19
- strikethrough: [9, 29],
20
- black: [30, 39],
21
- red: [31, 39],
22
- green: [32, 39],
23
- yellow: [33, 39],
24
- blue: [34, 39],
25
- magenta: [35, 39],
26
- cyan: [36, 39],
27
- white: [37, 39],
28
- gray: [90, 39],
29
- bgBlack: [40, 49],
30
- bgRed: [41, 49],
31
- bgGreen: [42, 49],
32
- bgYellow: [43, 49],
33
- bgBlue: [44, 49],
34
- bgMagenta: [45, 49],
35
- bgCyan: [46, 49],
36
- bgWhite: [47, 49],
37
- blackBright: [90, 39],
38
- redBright: [91, 39],
39
- greenBright: [92, 39],
40
- yellowBright: [93, 39],
41
- blueBright: [94, 39],
42
- magentaBright: [95, 39],
43
- cyanBright: [96, 39],
44
- whiteBright: [97, 39],
45
- bgBlackBright: [100, 49],
46
- bgRedBright: [101, 49],
47
- bgGreenBright: [102, 49],
48
- bgYellowBright: [103, 49],
49
- bgBlueBright: [104, 49],
50
- bgMagentaBright: [105, 49],
51
- bgCyanBright: [106, 49],
52
- bgWhiteBright: [107, 49]
53
- };
54
- function i$1(e) {
55
- return String(e);
56
- }
57
- i$1.open = "";
58
- i$1.close = "";
59
- function B() {
60
- let e = typeof process != "undefined" ? process : void 0, r = (e == null ? void 0 : e.env) || {}, a = r.FORCE_TTY !== "false", l = (e == null ? void 0 : e.argv) || [];
61
- return !("NO_COLOR" in r || l.includes("--no-color")) && ("FORCE_COLOR" in r || l.includes("--color") || (e == null ? void 0 : e.platform) === "win32" || a && r.TERM !== "dumb" || "CI" in r) || typeof window != "undefined" && !!window.chrome;
62
- }
63
- function C({ force: e } = {}) {
64
- let r = e || B(), a = (t, o, u, n) => {
65
- let g = "", s = 0;
66
- do
67
- g += t.substring(s, n) + u, s = n + o.length, n = t.indexOf(o, s);
68
- while (~n);
69
- return g + t.substring(s);
70
- }, l = (t, o, u = t) => {
71
- let n = (g) => {
72
- let s = String(g), h = s.indexOf(o, t.length);
73
- return ~h ? t + a(s, o, u, h) + o : t + s + o;
74
- };
75
- return n.open = t, n.close = o, n;
76
- }, c = { isColorSupported: r }, f = (t) => `\x1B[${t}m`;
77
- for (let t in b$1) {
78
- let o = b$1[t];
79
- c[t] = r ? l(f(o[0]), f(o[1]), o[2]) : i$1;
80
- }
81
- return c;
82
- }
83
- var y$1 = C();
2
+ //#region ../../node_modules/.pnpm/vitest@5.1.0_@types+node@26.6.5_@vitest+coverage-v8@5.0.4_vite@8.2.2_@types+node@26.6.5_4fc92309849883ad11a836cad05c50d8/node_modules/vitest/dist/chunks/tinyrainbow.Do8I1XRG.js
3
+ var d$1 = (e) => String(e);
4
+ d$1.open = d$1.close = "";
5
+ var i$1 = () => d$1;
6
+ var t$1 = "\x1B[39m";
7
+ var o = "\x1B[49m";
8
+ var F = (e, r, a, n, l) => {
9
+ let m = "", g = 0;
10
+ do
11
+ m += e.substring(g, n) + a, g = n + l, n = e.indexOf(r, g);
12
+ while (~n);
13
+ return m + e.substring(g);
14
+ };
15
+ var u$1 = (e, r, a = e, n = e.length) => {
16
+ let l = r.length, m = (g) => {
17
+ let s = g + "", x = s.indexOf(r, n);
18
+ return ~x ? e + F(s, r, a, x, l) + r : e + s + r;
19
+ };
20
+ return m.open = e, m.close = r, m;
21
+ };
22
+ var B = (e, r) => u$1(e, r, e, 5);
23
+ var c = (e) => {
24
+ let r = e.charCodeAt(0) === 35 ? e.slice(1) : e, a = parseInt(r, 16) || 0;
25
+ return r.length < 6 ? `${(a >> 8 & 15) * 17};${(a >> 4 & 15) * 17};${(a & 15) * 17}` : `${a >> 16 & 255};${a >> 8 & 255};${a & 255}`;
26
+ };
27
+ function y$1(e) {
28
+ let r = e ? u$1 : i$1;
29
+ return {
30
+ isColorSupported: e,
31
+ reset: r("\x1B[0m", "\x1B[0m"),
32
+ bold: r("\x1B[1m", "\x1B[22m", "\x1B[22m\x1B[1m"),
33
+ dim: r("\x1B[2m", "\x1B[22m", "\x1B[22m\x1B[2m"),
34
+ italic: r("\x1B[3m", "\x1B[23m"),
35
+ underline: r("\x1B[4m", "\x1B[24m"),
36
+ inverse: r("\x1B[7m", "\x1B[27m"),
37
+ hidden: r("\x1B[8m", "\x1B[28m"),
38
+ strikethrough: r("\x1B[9m", "\x1B[29m"),
39
+ black: r("\x1B[30m", t$1),
40
+ red: r("\x1B[31m", t$1),
41
+ green: r("\x1B[32m", t$1),
42
+ yellow: r("\x1B[33m", t$1),
43
+ blue: r("\x1B[34m", t$1),
44
+ magenta: r("\x1B[35m", t$1),
45
+ cyan: r("\x1B[36m", t$1),
46
+ white: r("\x1B[37m", t$1),
47
+ gray: r("\x1B[90m", t$1),
48
+ bgBlack: r("\x1B[40m", o),
49
+ bgRed: r("\x1B[41m", o),
50
+ bgGreen: r("\x1B[42m", o),
51
+ bgYellow: r("\x1B[43m", o),
52
+ bgBlue: r("\x1B[44m", o),
53
+ bgMagenta: r("\x1B[45m", o),
54
+ bgCyan: r("\x1B[46m", o),
55
+ bgWhite: r("\x1B[47m", o),
56
+ blackBright: r("\x1B[90m", t$1),
57
+ redBright: r("\x1B[91m", t$1),
58
+ greenBright: r("\x1B[92m", t$1),
59
+ yellowBright: r("\x1B[93m", t$1),
60
+ blueBright: r("\x1B[94m", t$1),
61
+ magentaBright: r("\x1B[95m", t$1),
62
+ cyanBright: r("\x1B[96m", t$1),
63
+ whiteBright: r("\x1B[97m", t$1),
64
+ bgBlackBright: r("\x1B[100m", o),
65
+ bgRedBright: r("\x1B[101m", o),
66
+ bgGreenBright: r("\x1B[102m", o),
67
+ bgYellowBright: r("\x1B[103m", o),
68
+ bgBlueBright: r("\x1B[104m", o),
69
+ bgMagentaBright: r("\x1B[105m", o),
70
+ bgCyanBright: r("\x1B[106m", o),
71
+ bgWhiteBright: r("\x1B[107m", o),
72
+ rgb: e ? (n, l, m) => B(`\x1B[38;2;${n};${l};${m}m`, t$1) : i$1,
73
+ bgRgb: e ? (n, l, m) => B(`\x1B[48;2;${n};${l};${m}m`, o) : i$1,
74
+ hex: e ? (n) => B(`\x1B[38;2;${c(n)}m`, t$1) : i$1,
75
+ bgHex: e ? (n) => B(`\x1B[48;2;${c(n)}m`, o) : i$1
76
+ };
77
+ }
78
+ function C$1() {
79
+ let e = typeof process != "undefined" ? process : void 0, r = (e == null ? void 0 : e.env) || {}, a = r.FORCE_TTY !== "false", n = (e == null ? void 0 : e.argv) || [];
80
+ return !("NO_COLOR" in r || n.includes("--no-color")) && ("FORCE_COLOR" in r || n.includes("--color") || (e == null ? void 0 : e.platform) === "win32" || a && r.TERM !== "dumb" || "CI" in r) || typeof window != "undefined" && !!window.chrome;
81
+ }
82
+ function h$1({ force: e } = {}) {
83
+ return y$1(e || C$1());
84
+ }
85
+ var $ = h$1();
84
86
  //#endregion
85
- //#region ../../node_modules/.pnpm/vitest@5.0.3_@types+node@26.6.5_@vitest+coverage-v8@5.0.4_vite@8.2.2_@types+node@26.6.5_220b0db820952837b535c2e83c4bd0a5/node_modules/vitest/dist/chunks/index.cx-_w29y.js
87
+ //#region ../../node_modules/.pnpm/vitest@5.1.0_@types+node@26.6.5_@vitest+coverage-v8@5.0.4_vite@8.2.2_@types+node@26.6.5_4fc92309849883ad11a836cad05c50d8/node_modules/vitest/dist/chunks/index.D0heQG4v.js
86
88
  function _mergeNamespaces(n, m) {
87
89
  m.forEach(function(e) {
88
90
  e && typeof e !== "string" && !Array.isArray(e) && Object.keys(e).forEach(function(k) {
@@ -524,7 +526,7 @@ function requireReactIs_production() {
524
526
  return typeOf(object) === REACT_SUSPENSE_LIST_TYPE;
525
527
  };
526
528
  reactIs_production.isValidElementType = function(type) {
527
- 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;
529
+ 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 || type === REACT_VIEW_TRANSITION_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;
528
530
  };
529
531
  reactIs_production.typeOf = typeOf;
530
532
  return reactIs_production;
@@ -618,7 +620,7 @@ function requireReactIs_development$1() {
618
620
  return typeOf(object) === REACT_SUSPENSE_LIST_TYPE;
619
621
  };
620
622
  reactIs_development$1.isValidElementType = function(type) {
621
- 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;
623
+ 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 || type === REACT_VIEW_TRANSITION_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;
622
624
  };
623
625
  reactIs_development$1.typeOf = typeOf;
624
626
  })();
@@ -1018,7 +1020,7 @@ function printFunction(val, printFunctionName) {
1018
1020
  return `[Function ${val.name || "anonymous"}]`;
1019
1021
  }
1020
1022
  function printSymbol(val) {
1021
- return String(val).replace(SYMBOL_REGEXP, "Symbol($1)");
1023
+ return Symbol.prototype.toString.call(val).replace(SYMBOL_REGEXP, "Symbol($1)");
1022
1024
  }
1023
1025
  function printError(val) {
1024
1026
  return `[${errorToString.call(val)}]`;
@@ -1171,7 +1173,7 @@ function validateOptions$1(options) {
1171
1173
  function getColorsHighlight() {
1172
1174
  return DEFAULT_THEME_KEYS.reduce((colors, key) => {
1173
1175
  const value = DEFAULT_THEME[key];
1174
- const color = value && y$1[value];
1176
+ const color = value && $[value];
1175
1177
  if (color && typeof color.close === "string" && typeof color.open === "string") colors[key] = color;
1176
1178
  else throw new Error(`pretty-format: Option "theme" has a key "${key}" whose value "${value}" is undefined in ansi-styles.`);
1177
1179
  return colors;
@@ -1245,7 +1247,7 @@ const plugins = {
1245
1247
  Error: ErrorPlugin
1246
1248
  };
1247
1249
  //#endregion
1248
- //#region ../../node_modules/.pnpm/vitest@5.0.3_@types+node@26.6.5_@vitest+coverage-v8@5.0.4_vite@8.2.2_@types+node@26.6.5_220b0db820952837b535c2e83c4bd0a5/node_modules/vitest/dist/chunks/display.CXBnkt9a.js
1250
+ //#region ../../node_modules/.pnpm/vitest@5.1.0_@types+node@26.6.5_@vitest+coverage-v8@5.0.4_vite@8.2.2_@types+node@26.6.5_4fc92309849883ad11a836cad05c50d8/node_modules/vitest/dist/chunks/display.BlTmubjj.js
1249
1251
  const { AsymmetricMatcher: AsymmetricMatcher$3, DOMCollection: DOMCollection$2, DOMElement: DOMElement$2, Immutable: Immutable$2, ReactElement: ReactElement$2, ReactTestComponent: ReactTestComponent$2 } = plugins;
1250
1252
  const PLUGINS$2 = [
1251
1253
  ReactTestComponent$2,
@@ -1485,11 +1487,13 @@ function filterOutComments(s) {
1485
1487
  if (s[i] === "\n") commentState = "none";
1486
1488
  } else if (commentState === "multiline") {
1487
1489
  if (s[i - 1] === "*" && s[i] === "/") commentState = "none";
1488
- } else if (commentState === "none") if (s[i] === "/" && s[i + 1] === "/") commentState = "singleline";
1489
- else if (s[i] === "/" && s[i + 1] === "*") {
1490
- commentState = "multiline";
1491
- i += 2;
1492
- } else result.push(s[i]);
1490
+ } else if (commentState === "none") {
1491
+ if (s[i] === "/" && s[i + 1] === "/") commentState = "singleline";
1492
+ else if (s[i] === "/" && s[i + 1] === "*") {
1493
+ commentState = "multiline";
1494
+ i += 2;
1495
+ } else result.push(s[i]);
1496
+ }
1493
1497
  return result.join("");
1494
1498
  }
1495
1499
  function toArray(array) {
@@ -1706,7 +1710,7 @@ const isAbsolute = function(p) {
1706
1710
  return _IS_ABSOLUTE_RE.test(p);
1707
1711
  };
1708
1712
  //#endregion
1709
- //#region ../../node_modules/.pnpm/vitest@5.0.3_@types+node@26.6.5_@vitest+coverage-v8@5.0.4_vite@8.2.2_@types+node@26.6.5_220b0db820952837b535c2e83c4bd0a5/node_modules/vitest/dist/chunks/source-map.DUxvo12T.js
1713
+ //#region ../../node_modules/.pnpm/vitest@5.1.0_@types+node@26.6.5_@vitest+coverage-v8@5.0.4_vite@8.2.2_@types+node@26.6.5_4fc92309849883ad11a836cad05c50d8/node_modules/vitest/dist/chunks/source-map.DakdQc29.js
1710
1714
  var build = {};
1711
1715
  var hasRequiredBuild;
1712
1716
  function requireBuild() {
@@ -2118,7 +2122,7 @@ for (let i = 0; i < chars.length; i++) {
2118
2122
  intToChar[i] = c;
2119
2123
  charToInt[c] = i;
2120
2124
  }
2121
- function decodeInteger(reader, relative) {
2125
+ function decodeInteger(reader) {
2122
2126
  let value = 0;
2123
2127
  let shift = 0;
2124
2128
  let integer = 0;
@@ -2127,10 +2131,10 @@ function decodeInteger(reader, relative) {
2127
2131
  value |= (integer & 31) << shift;
2128
2132
  shift += 5;
2129
2133
  } while (integer & 32);
2130
- const shouldNegate = value & 1;
2131
- value >>>= 1;
2132
- if (shouldNegate) value = -2147483648 | -value;
2133
- return relative + value;
2134
+ return value;
2135
+ }
2136
+ function decodeSign(num) {
2137
+ return num & 1 ? -2147483648 | -(num >>> 1) : num >>> 1;
2134
2138
  }
2135
2139
  function hasMoreVlq(reader, max) {
2136
2140
  if (reader.pos >= max) return false;
@@ -2170,15 +2174,15 @@ function decode(mappings) {
2170
2174
  genColumn = 0;
2171
2175
  while (reader.pos < semi) {
2172
2176
  let seg;
2173
- genColumn = decodeInteger(reader, genColumn);
2177
+ genColumn += decodeSign(decodeInteger(reader));
2174
2178
  if (genColumn < lastCol) sorted = false;
2175
2179
  lastCol = genColumn;
2176
2180
  if (hasMoreVlq(reader, semi)) {
2177
- sourcesIndex = decodeInteger(reader, sourcesIndex);
2178
- sourceLine = decodeInteger(reader, sourceLine);
2179
- sourceColumn = decodeInteger(reader, sourceColumn);
2181
+ sourcesIndex += decodeSign(decodeInteger(reader));
2182
+ sourceLine += decodeSign(decodeInteger(reader));
2183
+ sourceColumn += decodeSign(decodeInteger(reader));
2180
2184
  if (hasMoreVlq(reader, semi)) {
2181
- namesIndex = decodeInteger(reader, namesIndex);
2185
+ namesIndex += decodeSign(decodeInteger(reader));
2182
2186
  seg = [
2183
2187
  genColumn,
2184
2188
  sourcesIndex,
@@ -2333,7 +2337,7 @@ function extractLocation(urlLike) {
2333
2337
  const urlObj = new URL(url);
2334
2338
  urlObj.searchParams.delete("import");
2335
2339
  urlObj.searchParams.delete("browserv");
2336
- url = urlObj.pathname + urlObj.hash + urlObj.search;
2340
+ url = tryDecode(urlObj.pathname, decodeURI) + urlObj.hash + urlObj.search;
2337
2341
  }
2338
2342
  if (url.startsWith("/@fs/")) {
2339
2343
  const isWindows = /^\/@fs\/[a-zA-Z]:\//.test(url);
@@ -2346,6 +2350,13 @@ function extractLocation(urlLike) {
2346
2350
  parts[3] || void 0
2347
2351
  ];
2348
2352
  }
2353
+ function tryDecode(value, decode) {
2354
+ try {
2355
+ return decode(value);
2356
+ } catch {
2357
+ return value;
2358
+ }
2359
+ }
2349
2360
  function parseSingleFFOrSafariStack(raw) {
2350
2361
  let line = raw.trim();
2351
2362
  if (SAFARI_NATIVE_CODE_REGEXP.test(line)) return null;
@@ -2390,7 +2401,7 @@ function parseSingleV8Stack(raw) {
2390
2401
  let file = url && ["eval", "<anonymous>"].includes(url) ? void 0 : url;
2391
2402
  if (!file || !lineNumber || !columnNumber) return null;
2392
2403
  if (method.startsWith("async ")) method = method.slice(6);
2393
- if (file.startsWith("file://")) file = file.slice(7);
2404
+ if (file.startsWith("file://")) file = tryDecode(file.slice(7), decodeURIComponent);
2394
2405
  file = file.startsWith("node:") || file.startsWith("internal:") ? file : resolve(file);
2395
2406
  if (method) method = method.replace(/\(0\s?,\s?__vite_ssr_import_\d+__.(\w+)\)/g, "$1").replace(/__(vite_ssr_import|vi_import)_\d+__\./g, "").replace(/(Object\.)?__vite_ssr_export_default__\s?/g, "");
2396
2407
  return {
@@ -2405,29 +2416,37 @@ function parseStacktrace(stack, options = {}) {
2405
2416
  let stacks = !CHROME_IE_STACK_REGEXP.test(stack) ? parseFFOrSafariStackTrace(stack) : parseV8Stacktrace(stack);
2406
2417
  const helperIndex = stacks.findLastIndex((s) => s.method.includes("__VITEST_HELPER__"));
2407
2418
  if (helperIndex >= 0) stacks = stacks.slice(helperIndex + 1);
2408
- return stacks.map((stack) => {
2409
- if (options.getUrlId) stack.file = options.getUrlId(stack.file);
2410
- const map = options.getSourceMap?.(stack.file);
2411
- if (!map || typeof map !== "object" || !map.version) return shouldFilter(ignoreStackEntries, stack.file) ? null : stack;
2412
- const traceMap = new DecodedMap(map, stack.file);
2413
- if (stack.line <= 0 || stack.column <= 0) return stack;
2414
- const position = getOriginalPosition(traceMap, {
2415
- line: stack.line,
2416
- column: stack.column - 1
2417
- });
2418
- if (!position) return stack;
2419
- const { line, column, source, name } = position;
2420
- let file = source || stack.file;
2421
- if (/\/\w:\//.test(file)) file = file.slice(1);
2422
- if (shouldFilter(ignoreStackEntries, file)) return null;
2423
- if (line != null && column != null) return {
2424
- line,
2425
- column: column + 1,
2426
- file,
2427
- method: name || stack.method
2428
- };
2429
- return stack;
2430
- }).filter((s) => s != null);
2419
+ if (options.firstOnly) {
2420
+ for (const stack of stacks) {
2421
+ const mapped = mapStackFrame(stack, options, ignoreStackEntries);
2422
+ if (mapped) return [mapped];
2423
+ }
2424
+ return [];
2425
+ }
2426
+ return stacks.map((stack) => mapStackFrame(stack, options, ignoreStackEntries)).filter((s) => s != null);
2427
+ }
2428
+ function mapStackFrame(stack, options, ignoreStackEntries) {
2429
+ if (options.getUrlId) stack.file = options.getUrlId(stack.file);
2430
+ const map = options.getSourceMap?.(stack.file);
2431
+ if (!map || typeof map !== "object" || !map.version) return shouldFilter(ignoreStackEntries, stack.file) ? null : stack;
2432
+ const traceMap = new DecodedMap(map, stack.file);
2433
+ if (stack.line <= 0 || stack.column <= 0) return stack;
2434
+ const position = getOriginalPosition(traceMap, {
2435
+ line: stack.line,
2436
+ column: stack.column - 1
2437
+ });
2438
+ if (!position) return stack;
2439
+ const { line, column, source, name } = position;
2440
+ let file = source || stack.file;
2441
+ if (/\/\w:\//.test(file)) file = file.slice(1);
2442
+ if (shouldFilter(ignoreStackEntries, file)) return null;
2443
+ if (line != null && column != null) return {
2444
+ line,
2445
+ column: column + 1,
2446
+ file,
2447
+ method: name || stack.method
2448
+ };
2449
+ return stack;
2431
2450
  }
2432
2451
  function shouldFilter(ignoreStackEntries, file) {
2433
2452
  return ignoreStackEntries.some((p) => file.match(p));
@@ -2485,7 +2504,7 @@ function getOriginalPosition(map, needle) {
2485
2504
  return result;
2486
2505
  }
2487
2506
  //#endregion
2488
- //#region ../../node_modules/.pnpm/vitest@5.0.3_@types+node@26.6.5_@vitest+coverage-v8@5.0.4_vite@8.2.2_@types+node@26.6.5_220b0db820952837b535c2e83c4bd0a5/node_modules/vitest/dist/task-utils.js
2507
+ //#region ../../node_modules/.pnpm/vitest@5.1.0_@types+node@26.6.5_@vitest+coverage-v8@5.0.4_vite@8.2.2_@types+node@26.6.5_4fc92309849883ad11a836cad05c50d8/node_modules/vitest/dist/task-utils.js
2489
2508
  /* @__NO_SIDE_EFFECTS__ */
2490
2509
  function getNames(task) {
2491
2510
  const names = [task.name];
@@ -2502,7 +2521,7 @@ function createTaskName(names, separator = " > ") {
2502
2521
  return names.filter((name) => name !== void 0).join(separator);
2503
2522
  }
2504
2523
  //#endregion
2505
- //#region ../../node_modules/.pnpm/vitest@5.0.3_@types+node@26.6.5_@vitest+coverage-v8@5.0.4_vite@8.2.2_@types+node@26.6.5_220b0db820952837b535c2e83c4bd0a5/node_modules/vitest/dist/chunks/run.BTlFXlnv.js
2524
+ //#region ../../node_modules/.pnpm/vitest@5.1.0_@types+node@26.6.5_@vitest+coverage-v8@5.0.4_vite@8.2.2_@types+node@26.6.5_4fc92309849883ad11a836cad05c50d8/node_modules/vitest/dist/chunks/run.CjdgFZiW.js
2506
2525
  /**
2507
2526
  * Diff Match and Patch
2508
2527
  * Copyright 2018 The diff-match-patch Authors.
@@ -2909,22 +2928,24 @@ function joinAlignedDiffsNoExpand(diffs, options) {
2909
2928
  while (i !== iLength) {
2910
2929
  const iStart = i;
2911
2930
  while (i !== iLength && diffs[i][0] === DIFF_EQUAL) i += 1;
2912
- if (iStart !== i) if (iStart === 0) {
2913
- if (i > nContextLines) {
2914
- jLength -= i - nContextLines;
2915
- hasExcessAtStartOrEnd = true;
2916
- }
2917
- } else if (i === iLength) {
2918
- const n = i - iStart;
2919
- if (n > nContextLines) {
2920
- jLength -= n - nContextLines;
2921
- hasExcessAtStartOrEnd = true;
2922
- }
2923
- } else {
2924
- const n = i - iStart;
2925
- if (n > nContextLines2) {
2926
- jLength -= n - nContextLines2;
2927
- nExcessesBetweenChanges += 1;
2931
+ if (iStart !== i) {
2932
+ if (iStart === 0) {
2933
+ if (i > nContextLines) {
2934
+ jLength -= i - nContextLines;
2935
+ hasExcessAtStartOrEnd = true;
2936
+ }
2937
+ } else if (i === iLength) {
2938
+ const n = i - iStart;
2939
+ if (n > nContextLines) {
2940
+ jLength -= n - nContextLines;
2941
+ hasExcessAtStartOrEnd = true;
2942
+ }
2943
+ } else {
2944
+ const n = i - iStart;
2945
+ if (n > nContextLines2) {
2946
+ jLength -= n - nContextLines2;
2947
+ nExcessesBetweenChanges += 1;
2948
+ }
2928
2949
  }
2929
2950
  }
2930
2951
  while (i !== iLength && diffs[i][0] !== DIFF_EQUAL) i += 1;
@@ -2960,33 +2981,35 @@ function joinAlignedDiffsNoExpand(diffs, options) {
2960
2981
  while (i !== iLength) {
2961
2982
  let iStart = i;
2962
2983
  while (i !== iLength && diffs[i][0] === DIFF_EQUAL) i += 1;
2963
- if (iStart !== i) if (iStart === 0) {
2964
- if (i > nContextLines) {
2965
- iStart = i - nContextLines;
2966
- aStart = iStart;
2967
- bStart = iStart;
2968
- aEnd = aStart;
2969
- bEnd = bStart;
2970
- }
2971
- for (let iCommon = iStart; iCommon !== i; iCommon += 1) pushCommonLine(diffs[iCommon][1]);
2972
- } else if (i === iLength) {
2973
- const iEnd = i - iStart > nContextLines ? iStart + nContextLines : i;
2974
- for (let iCommon = iStart; iCommon !== iEnd; iCommon += 1) pushCommonLine(diffs[iCommon][1]);
2975
- } else {
2976
- const nCommon = i - iStart;
2977
- if (nCommon > nContextLines2) {
2978
- const iEnd = iStart + nContextLines;
2984
+ if (iStart !== i) {
2985
+ if (iStart === 0) {
2986
+ if (i > nContextLines) {
2987
+ iStart = i - nContextLines;
2988
+ aStart = iStart;
2989
+ bStart = iStart;
2990
+ aEnd = aStart;
2991
+ bEnd = bStart;
2992
+ }
2993
+ for (let iCommon = iStart; iCommon !== i; iCommon += 1) pushCommonLine(diffs[iCommon][1]);
2994
+ } else if (i === iLength) {
2995
+ const iEnd = i - iStart > nContextLines ? iStart + nContextLines : i;
2979
2996
  for (let iCommon = iStart; iCommon !== iEnd; iCommon += 1) pushCommonLine(diffs[iCommon][1]);
2980
- lines[jPatchMark] = createPatchMark(aStart, aEnd, bStart, bEnd, options);
2981
- jPatchMark = lines.length;
2982
- lines.push("");
2983
- const nOmit = nCommon - nContextLines2;
2984
- aStart = aEnd + nOmit;
2985
- bStart = bEnd + nOmit;
2986
- aEnd = aStart;
2987
- bEnd = bStart;
2988
- for (let iCommon = i - nContextLines; iCommon !== i; iCommon += 1) pushCommonLine(diffs[iCommon][1]);
2989
- } else for (let iCommon = iStart; iCommon !== i; iCommon += 1) pushCommonLine(diffs[iCommon][1]);
2997
+ } else {
2998
+ const nCommon = i - iStart;
2999
+ if (nCommon > nContextLines2) {
3000
+ const iEnd = iStart + nContextLines;
3001
+ for (let iCommon = iStart; iCommon !== iEnd; iCommon += 1) pushCommonLine(diffs[iCommon][1]);
3002
+ lines[jPatchMark] = createPatchMark(aStart, aEnd, bStart, bEnd, options);
3003
+ jPatchMark = lines.length;
3004
+ lines.push("");
3005
+ const nOmit = nCommon - nContextLines2;
3006
+ aStart = aEnd + nOmit;
3007
+ bStart = bEnd + nOmit;
3008
+ aEnd = aStart;
3009
+ bEnd = bStart;
3010
+ for (let iCommon = i - nContextLines; iCommon !== i; iCommon += 1) pushCommonLine(diffs[iCommon][1]);
3011
+ } else for (let iCommon = iStart; iCommon !== i; iCommon += 1) pushCommonLine(diffs[iCommon][1]);
3012
+ }
2990
3013
  }
2991
3014
  while (i !== iLength && diffs[i][0] === DIFF_DELETE) {
2992
3015
  pushDeleteLine(diffs[i][1]);
@@ -3017,14 +3040,14 @@ const DIFF_TRUNCATE_THRESHOLD_DEFAULT = 0;
3017
3040
  function getDefaultOptions() {
3018
3041
  return {
3019
3042
  aAnnotation: "Expected",
3020
- aColor: y$1.green,
3043
+ aColor: $.green,
3021
3044
  aIndicator: "-",
3022
3045
  bAnnotation: "Received",
3023
- bColor: y$1.red,
3046
+ bColor: $.red,
3024
3047
  bIndicator: "+",
3025
- changeColor: y$1.inverse,
3048
+ changeColor: $.inverse,
3026
3049
  changeLineTrailingSpaceColor: noColor,
3027
- commonColor: y$1.dim,
3050
+ commonColor: $.dim,
3028
3051
  commonIndicator: " ",
3029
3052
  commonLineTrailingSpaceColor: noColor,
3030
3053
  compareKeys: void 0,
@@ -3033,7 +3056,7 @@ function getDefaultOptions() {
3033
3056
  expand: false,
3034
3057
  includeChangeCounts: false,
3035
3058
  omitAnnotationLines: false,
3036
- patchColor: y$1.yellow,
3059
+ patchColor: $.yellow,
3037
3060
  printBasicPrototype: false,
3038
3061
  truncateThreshold: DIFF_TRUNCATE_THRESHOLD_DEFAULT,
3039
3062
  truncateAnnotation: "... Diff result is truncated",
@@ -3538,13 +3561,13 @@ function replaceTrailingSpaces$1(text) {
3538
3561
  return text.replace(/\s+$/gm, (spaces) => SPACE_SYMBOL$1.repeat(spaces.length));
3539
3562
  }
3540
3563
  function printReceived$1(object) {
3541
- return y$1.red(replaceTrailingSpaces$1(stringify(object)));
3564
+ return $.red(replaceTrailingSpaces$1(stringify(object)));
3542
3565
  }
3543
3566
  function printExpected$1(value) {
3544
- return y$1.green(replaceTrailingSpaces$1(stringify(value)));
3567
+ return $.green(replaceTrailingSpaces$1(stringify(value)));
3545
3568
  }
3546
3569
  function getCommonAndChangedSubstrings(diffs, op, hasCommonDiff) {
3547
- return diffs.reduce((reduced, diff) => reduced + (diff[0] === DIFF_EQUAL ? diff[1] : diff[0] === op ? hasCommonDiff ? y$1.inverse(diff[1]) : diff[1] : ""), "");
3570
+ return diffs.reduce((reduced, diff) => reduced + (diff[0] === DIFF_EQUAL ? diff[1] : diff[0] === op ? hasCommonDiff ? $.inverse(diff[1]) : diff[1] : ""), "");
3548
3571
  }
3549
3572
  function processError(_err, diffOptions, seen = /* @__PURE__ */ new WeakSet()) {
3550
3573
  if (!_err || typeof _err !== "object") return { message: String(_err) };
@@ -3806,8 +3829,12 @@ function withFixtures(fn, options) {
3806
3829
  for (const fixture of pendingFixtures) if (fixture.scope === "test") {
3807
3830
  if (cachedFixtures.has(fixture)) continue;
3808
3831
  cachedFixtures.add(fixture);
3809
- const resolvedValue = await resolveTestFixtureValue(fixture, context, cleanupFnArray);
3810
- context[fixture.name] = resolvedValue;
3832
+ try {
3833
+ context[fixture.name] = await resolveTestFixtureValue(fixture, context, cleanupFnArray);
3834
+ } catch (error) {
3835
+ cachedFixtures.delete(fixture);
3836
+ throw error;
3837
+ }
3811
3838
  cleanupFnArray.push(() => {
3812
3839
  cachedFixtures.delete(fixture);
3813
3840
  });
@@ -3848,8 +3875,9 @@ async function resolveScopeFixtureValue(fixtures, suite, fixture) {
3848
3875
  ...fileContext
3849
3876
  } : fixtureContext, cleanupFnFileArray).then((value) => {
3850
3877
  fixtureContext[fixture.name] = value;
3851
- scopedFixturePromiseCache.delete(fixture);
3852
3878
  return value;
3879
+ }).finally(() => {
3880
+ scopedFixturePromiseCache.delete(fixture);
3853
3881
  });
3854
3882
  scopedFixturePromiseCache.set(fixture, promise);
3855
3883
  return promise;
@@ -3889,8 +3917,10 @@ function resolveDeps(usedFixtures, registrations, depSet = /* @__PURE__ */ new S
3889
3917
  pendingFixtures.push(fixture);
3890
3918
  return;
3891
3919
  }
3892
- if (depSet.has(fixture)) if (fixture.parent) fixture = fixture.parent;
3893
- else throw new Error(`Circular fixture dependency detected: ${fixture.name} <- ${[...depSet].reverse().map((d) => d.name).join(" <- ")}`);
3920
+ if (depSet.has(fixture)) {
3921
+ if (fixture.parent) fixture = fixture.parent;
3922
+ else throw new Error(`Circular fixture dependency detected: ${fixture.name} <- ${[...depSet].reverse().map((d) => d.name).join(" <- ")}`);
3923
+ }
3894
3924
  depSet.add(fixture);
3895
3925
  resolveDeps(Array.from(fixture.deps, (n) => n === fixture.name ? fixture.parent : registrations.get(n)).filter((n) => !!n), registrations, depSet, pendingFixtures);
3896
3926
  pendingFixtures.push(fixture);
@@ -3977,6 +4007,10 @@ function createChainable(keys, fn, context) {
3977
4007
  Object.defineProperty(chain, kChainableContext, {
3978
4008
  value: {
3979
4009
  withContext: () => chain.bind(context),
4010
+ extendContext: (ctx) => create({
4011
+ ...context,
4012
+ ...ctx
4013
+ }),
3980
4014
  getFixtures: () => context.fixtures,
3981
4015
  setContext: (key, value) => {
3982
4016
  context[key] = value;
@@ -4299,6 +4333,10 @@ function createSuiteHooks() {
4299
4333
  };
4300
4334
  }
4301
4335
  const POSITIVE_INFINITY = Number.POSITIVE_INFINITY;
4336
+ function assignDefined(target, source) {
4337
+ for (const key in source) if (source[key] !== void 0) target[key] = source[key];
4338
+ return target;
4339
+ }
4302
4340
  function parseArguments(optionsOrFn, timeoutOrTest) {
4303
4341
  if (timeoutOrTest != null && typeof timeoutOrTest === "object") 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.`);
4304
4342
  let options = {};
@@ -4327,16 +4365,16 @@ function createSuiteCollector(name, factory = () => {}, mode, each, suiteOptions
4327
4365
  return tagDefinition;
4328
4366
  }).filter((r) => r != null).sort((tag1, tag2) => (tag2.priority ?? POSITIVE_INFINITY) - (tag1.priority ?? POSITIVE_INFINITY)).reduce((acc, tag) => {
4329
4367
  const { name, description, priority, meta, ...options } = tag;
4330
- Object.assign(acc, options);
4368
+ assignDefined(acc, options);
4331
4369
  if (meta) acc.meta = Object.assign(acc.meta ?? Object.create(null), meta);
4332
4370
  return acc;
4333
4371
  }, {});
4334
4372
  const testOwnMeta = options.meta;
4335
- options = {
4336
- ...collectorContext.currentSuite?.options,
4337
- ...tagsOptions,
4338
- ...options
4339
- };
4373
+ const parentOptions = collectorContext.currentSuite?.options;
4374
+ options = assignDefined({
4375
+ ...parentOptions,
4376
+ ...tagsOptions
4377
+ }, options);
4340
4378
  const timeout = options.timeout ?? runner.config.testTimeout;
4341
4379
  const parentMeta = currentSuite?.meta;
4342
4380
  const tagMeta = tagsOptions.meta;
@@ -4395,8 +4433,7 @@ function createSuiteCollector(name, factory = () => {}, mode, each, suiteOptions
4395
4433
  const concurrent = this.concurrent ?? options?.concurrent;
4396
4434
  if (concurrent != null) options.concurrent = concurrent;
4397
4435
  const test = task(formatName(name), {
4398
- ...this,
4399
- ...options,
4436
+ ...assignDefined({ ...this }, options),
4400
4437
  handler
4401
4438
  });
4402
4439
  test.type = "test";
@@ -4481,10 +4518,7 @@ function createSuite() {
4481
4518
  const currentSuite = collectorContext.currentSuite || defaultSuite;
4482
4519
  let { options, handler: factory } = parseArguments(factoryOrOptions, optionsOrFactory);
4483
4520
  const { meta: parentMeta, ...parentOptions } = currentSuite?.options || {};
4484
- options = {
4485
- ...parentOptions,
4486
- ...options
4487
- };
4521
+ options = assignDefined({ ...parentOptions }, options);
4488
4522
  const shuffle = this.shuffle ?? options.shuffle ?? currentSuite?.options?.shuffle ?? void 0;
4489
4523
  if (shuffle != null) options.shuffle = shuffle;
4490
4524
  let mode = this.only ?? options.only ? "only" : this.skip ?? options.skip ? "skip" : this.todo ?? options.todo ? "todo" : "run";
@@ -4506,9 +4540,10 @@ function createSuite() {
4506
4540
  const fnFirst = typeof optionsOrFn === "function";
4507
4541
  cases.forEach((i, idx) => {
4508
4542
  const items = Array.isArray(i) ? i : [i];
4509
- if (fnFirst) if (arrayOnlyCases) suite(formatTitle(_name, items, idx), handler ? () => handler(...items) : void 0, options.timeout);
4510
- else suite(formatTitle(_name, items, idx), handler ? () => handler(i) : void 0, options.timeout);
4511
- else if (arrayOnlyCases) suite(formatTitle(_name, items, idx), options, handler ? () => handler(...items) : void 0);
4543
+ if (fnFirst) {
4544
+ if (arrayOnlyCases) suite(formatTitle(_name, items, idx), handler ? () => handler(...items) : void 0, options.timeout);
4545
+ else suite(formatTitle(_name, items, idx), handler ? () => handler(i) : void 0, options.timeout);
4546
+ } else if (arrayOnlyCases) suite(formatTitle(_name, items, idx), options, handler ? () => handler(...items) : void 0);
4512
4547
  else suite(formatTitle(_name, items, idx), options, handler ? () => handler(i) : void 0);
4513
4548
  });
4514
4549
  context.setContext("each", void 0);
@@ -4549,9 +4584,10 @@ function createTaskCollector(fn) {
4549
4584
  const fnFirst = typeof optionsOrFn === "function";
4550
4585
  cases.forEach((i, idx) => {
4551
4586
  const items = Array.isArray(i) ? i : [i];
4552
- if (fnFirst) if (arrayOnlyCases) test(formatTitle(_name, items, idx), handler ? () => handler(...items) : void 0, options.timeout);
4553
- else test(formatTitle(_name, items, idx), handler ? () => handler(i) : void 0, options.timeout);
4554
- else if (arrayOnlyCases) test(formatTitle(_name, items, idx), options, handler ? () => handler(...items) : void 0);
4587
+ if (fnFirst) {
4588
+ if (arrayOnlyCases) test(formatTitle(_name, items, idx), handler ? () => handler(...items) : void 0, options.timeout);
4589
+ else test(formatTitle(_name, items, idx), handler ? () => handler(i) : void 0, options.timeout);
4590
+ } else if (arrayOnlyCases) test(formatTitle(_name, items, idx), options, handler ? () => handler(...items) : void 0);
4555
4591
  else test(formatTitle(_name, items, idx), options, handler ? () => handler(i) : void 0);
4556
4592
  });
4557
4593
  context.setContext("each", void 0);
@@ -4574,10 +4610,10 @@ function createTaskCollector(fn) {
4574
4610
  };
4575
4611
  };
4576
4612
  taskFn.skipIf = function(condition) {
4577
- return condition ? this.skip : this;
4613
+ return getChainableContext(this).extendContext({ skip: !!condition });
4578
4614
  };
4579
4615
  taskFn.runIf = function(condition) {
4580
- return condition ? this : this.skip;
4616
+ return getChainableContext(this).extendContext({ skip: !condition });
4581
4617
  };
4582
4618
  /**
4583
4619
  * Parse builder pattern arguments into a fixtures object.
@@ -4676,7 +4712,7 @@ function formatTitle(template, items, idx) {
4676
4712
  if (!isObjectItem && !isArrayKey) return `$${key}`;
4677
4713
  const arrayElement = isArrayKey ? objectAttr(items, key) : void 0;
4678
4714
  const value = isObjectItem ? objectAttr(items[0], key, arrayElement) : arrayElement;
4679
- if (typeof value === "string") return truncateString(value, inspectOptions.truncate);
4715
+ if (typeof value === "string") return inspectOptions.truncate ? truncateString(value, inspectOptions.truncate) : value;
4680
4716
  return inspect$1(value, inspectOptions);
4681
4717
  });
4682
4718
  }
@@ -5070,7 +5106,7 @@ async function finishSendTasksUpdate(runner) {
5070
5106
  await Promise.all(pendingTasksUpdates);
5071
5107
  }
5072
5108
  //#endregion
5073
- //#region ../../node_modules/.pnpm/vitest@5.0.3_@types+node@26.6.5_@vitest+coverage-v8@5.0.4_vite@8.2.2_@types+node@26.6.5_220b0db820952837b535c2e83c4bd0a5/node_modules/vitest/dist/chunks/utils.DYj33du9.js
5109
+ //#region ../../node_modules/.pnpm/vitest@5.1.0_@types+node@26.6.5_@vitest+coverage-v8@5.0.4_vite@8.2.2_@types+node@26.6.5_4fc92309849883ad11a836cad05c50d8/node_modules/vitest/dist/chunks/utils.DYj33du9.js
5074
5110
  const NAME_WORKER_STATE = "__vitest_worker__";
5075
5111
  function getWorkerState() {
5076
5112
  const workerState = globalThis[NAME_WORKER_STATE];
@@ -5096,19 +5132,41 @@ function resetModules(modules, resetMocks = false) {
5096
5132
  });
5097
5133
  }
5098
5134
  //#endregion
5099
- //#region ../../node_modules/.pnpm/vitest@5.0.3_@types+node@26.6.5_@vitest+coverage-v8@5.0.4_vite@8.2.2_@types+node@26.6.5_220b0db820952837b535c2e83c4bd0a5/node_modules/vitest/dist/chunks/spy.DgMTfhrK.js
5135
+ //#region ../../node_modules/.pnpm/vitest@5.1.0_@types+node@26.6.5_@vitest+coverage-v8@5.0.4_vite@8.2.2_@types+node@26.6.5_4fc92309849883ad11a836cad05c50d8/node_modules/vitest/dist/chunks/spy.DDMXghXv.js
5100
5136
  function isMockFunction(fn) {
5101
5137
  return typeof fn === "function" && "_isMockFunction" in fn && fn._isMockFunction === true;
5102
5138
  }
5103
5139
  const MOCK_RESTORE = /* @__PURE__ */ new Set();
5104
5140
  const DIRTY_MOCK_STATES = /* @__PURE__ */ new Set();
5105
- const addDirtyMock = DIRTY_MOCK_STATES.add.bind(DIRTY_MOCK_STATES);
5106
- const REGISTERED_MOCKS = /* @__PURE__ */ new Set();
5141
+ const DIRTY_MOCK_CONFIGS = /* @__PURE__ */ new Set();
5142
+ const addToSet = Set.prototype.add;
5143
+ const MOCK_REFS = /* @__PURE__ */ new WeakMap();
5107
5144
  const MOCK_FINALIZER = new FinalizationRegistry((ref) => {
5108
- REGISTERED_MOCKS.delete(ref);
5145
+ DIRTY_MOCK_STATES.delete(ref);
5146
+ DIRTY_MOCK_CONFIGS.delete(ref);
5109
5147
  });
5110
5148
  const MOCK_CONFIGS = /* @__PURE__ */ new WeakMap();
5111
5149
  const MOCKS_BY_STATE = /* @__PURE__ */ new WeakMap();
5150
+ function markDirty(set, mock) {
5151
+ let ref = MOCK_REFS.get(mock);
5152
+ if (!ref) {
5153
+ ref = new WeakRef(mock);
5154
+ MOCK_REFS.set(mock, ref);
5155
+ MOCK_FINALIZER.register(mock, ref);
5156
+ }
5157
+ addToSet.call(set, ref);
5158
+ }
5159
+ function unmarkDirty(set, mock) {
5160
+ const ref = MOCK_REFS.get(mock);
5161
+ if (ref) set.delete(ref);
5162
+ }
5163
+ function forEachDirty(set, fn) {
5164
+ for (const ref of set) {
5165
+ const mock = ref.deref();
5166
+ if (mock) fn(mock);
5167
+ else set.delete(ref);
5168
+ }
5169
+ }
5112
5170
  function createMockInstance(options = {}) {
5113
5171
  const { originalImplementation, restore, mockImplementation, resetToMockImplementation, resetToMockName } = options;
5114
5172
  if (restore) MOCK_RESTORE.add(restore);
@@ -5129,9 +5187,6 @@ function createMockInstance(options = {}) {
5129
5187
  if (resetToMockName) config.mockName = mock.name || "vi.fn()";
5130
5188
  MOCK_CONFIGS.set(mock, config);
5131
5189
  MOCKS_BY_STATE.set(state, mock);
5132
- const ref = new WeakRef(mock);
5133
- REGISTERED_MOCKS.add(ref);
5134
- MOCK_FINALIZER.register(mock, ref);
5135
5190
  mock._isMockFunction = true;
5136
5191
  mock.getMockImplementation = () => {
5137
5192
  return config.onceMockImplementations[0] || config.mockImplementation;
@@ -5146,21 +5201,25 @@ function createMockInstance(options = {}) {
5146
5201
  value: state
5147
5202
  });
5148
5203
  mock.mockImplementation = function mockImplementation(implementation) {
5204
+ markDirty(DIRTY_MOCK_CONFIGS, mock);
5149
5205
  config.mockImplementation = implementation;
5150
5206
  updateMockPrototype();
5151
5207
  return mock;
5152
5208
  };
5153
5209
  mock.mockImplementationOnce = function mockImplementationOnce(implementation) {
5210
+ markDirty(DIRTY_MOCK_CONFIGS, mock);
5154
5211
  config.onceMockImplementations.push(implementation);
5155
5212
  updateMockPrototype();
5156
5213
  return mock;
5157
5214
  };
5158
5215
  mock.withImplementation = function withImplementation(implementation, callback) {
5216
+ markDirty(DIRTY_MOCK_CONFIGS, mock);
5159
5217
  const previousImplementation = config.mockImplementation;
5160
5218
  const previousOnceImplementations = config.onceMockImplementations;
5161
5219
  const reset = () => {
5162
5220
  config.mockImplementation = previousImplementation;
5163
5221
  config.onceMockImplementations = previousOnceImplementations;
5222
+ markDirty(DIRTY_MOCK_CONFIGS, mock);
5164
5223
  updateMockPrototype();
5165
5224
  };
5166
5225
  config.mockImplementation = implementation;
@@ -5232,7 +5291,7 @@ function createMockInstance(options = {}) {
5232
5291
  state.invocationCallOrder = [];
5233
5292
  state.results = [];
5234
5293
  state.settledResults = [];
5235
- DIRTY_MOCK_STATES.delete(mock);
5294
+ unmarkDirty(DIRTY_MOCK_STATES, mock);
5236
5295
  return mock;
5237
5296
  };
5238
5297
  mock.mockReset = function mockReset() {
@@ -5240,6 +5299,7 @@ function createMockInstance(options = {}) {
5240
5299
  config.mockImplementation = resetToMockImplementation ? mockImplementation : void 0;
5241
5300
  config.mockName = resetToMockName ? mock.name || "vi.fn()" : "vi.fn()";
5242
5301
  config.onceMockImplementations = [];
5302
+ unmarkDirty(DIRTY_MOCK_CONFIGS, mock);
5243
5303
  updateMockPrototype();
5244
5304
  return mock;
5245
5305
  };
@@ -5248,7 +5308,10 @@ function createMockInstance(options = {}) {
5248
5308
  return restore?.();
5249
5309
  };
5250
5310
  mock.mockName = function mockName(name) {
5251
- if (typeof name === "string") config.mockName = name;
5311
+ if (typeof name === "string") {
5312
+ markDirty(DIRTY_MOCK_CONFIGS, mock);
5313
+ config.mockName = name;
5314
+ }
5252
5315
  return mock;
5253
5316
  };
5254
5317
  mock.getMockName = function getMockName() {
@@ -5335,8 +5398,8 @@ function createMock({ state, config, name: mockName, prototypeState, prototypeCo
5335
5398
  const noopImplementation = function() {};
5336
5399
  const prototypeMock = prototypeState && MOCKS_BY_STATE.get(prototypeState);
5337
5400
  const namedObject = { [name]: function(...args) {
5338
- addDirtyMock(namedObject[name]);
5339
- if (prototypeMock) addDirtyMock(prototypeMock);
5401
+ markDirty(DIRTY_MOCK_STATES, namedObject[name]);
5402
+ if (prototypeMock) markDirty(DIRTY_MOCK_STATES, prototypeMock);
5340
5403
  registerCalls(args, state, prototypeState);
5341
5404
  registerInvocationOrder(invocationCallCounter++, state, prototypeState);
5342
5405
  const result = {
@@ -5500,20 +5563,17 @@ function restoreAllMocks() {
5500
5563
  MOCK_RESTORE.clear();
5501
5564
  }
5502
5565
  function clearAllMocks() {
5503
- for (const mock of DIRTY_MOCK_STATES) mock.mockClear();
5566
+ forEachDirty(DIRTY_MOCK_STATES, (mock) => mock.mockClear());
5504
5567
  }
5505
5568
  function resetAllMocks() {
5506
- for (const ref of REGISTERED_MOCKS) {
5507
- const mock = ref.deref();
5508
- if (mock) mock.mockReset();
5509
- else REGISTERED_MOCKS.delete(ref);
5510
- }
5569
+ forEachDirty(DIRTY_MOCK_STATES, (mock) => mock.mockReset());
5570
+ forEachDirty(DIRTY_MOCK_CONFIGS, (mock) => mock.mockReset());
5511
5571
  }
5512
5572
  function throwConstructorError(shorthand) {
5513
5573
  throw new TypeError(`Cannot use \`${shorthand}\` when called with \`new\`. Use \`mockImplementation\` with a \`class\` keyword instead. See https://vitest.dev/api/mock#class-support for more information.`);
5514
5574
  }
5515
5575
  //#endregion
5516
- //#region ../../node_modules/.pnpm/chai@6.2.2/node_modules/chai/index.js
5576
+ //#region ../../node_modules/.pnpm/chai@6.3.0/node_modules/chai/index.js
5517
5577
  var __defProp = Object.defineProperty;
5518
5578
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, {
5519
5579
  enumerable: true,
@@ -5594,6 +5654,7 @@ function compatibleConstructor(thrown, errorLike) {
5594
5654
  __name(compatibleConstructor, "compatibleConstructor");
5595
5655
  function compatibleMessage(thrown, errMatcher) {
5596
5656
  const comparisonString = typeof thrown === "string" ? thrown : thrown.message;
5657
+ if (comparisonString === void 0) return false;
5597
5658
  if (isRegExp(errMatcher)) return errMatcher.test(comparisonString);
5598
5659
  else if (typeof errMatcher === "string") return comparisonString.indexOf(errMatcher) !== -1;
5599
5660
  return false;
@@ -6251,8 +6312,10 @@ __name(inspect2, "inspect");
6251
6312
  function objDisplay(obj) {
6252
6313
  let str = inspect2(obj), type3 = Object.prototype.toString.call(obj);
6253
6314
  if (config.truncateThreshold && str.length >= config.truncateThreshold) {
6254
- if (type3 === "[object Function]") return !obj.name || obj.name === "" ? "[Function]" : "[Function: " + obj.name + "]";
6255
- else if (type3 === "[object Array]") return "[ Array(" + obj.length + ") ]";
6315
+ if (type3 === "[object Function]") {
6316
+ const objAsFunction = obj;
6317
+ return !objAsFunction.name || objAsFunction.name === "" ? "[Function]" : "[Function: " + objAsFunction.name + "]";
6318
+ } else if (type3 === "[object Array]") return "[ Array(" + obj.length + ") ]";
6256
6319
  else if (type3 === "[object Object]") {
6257
6320
  let keys = Object.keys(obj);
6258
6321
  return "{ Object (" + (keys.length > 2 ? keys.splice(0, 2).join(", ") + ", ..." : keys.join(", ")) + ") }";
@@ -6265,25 +6328,24 @@ function getMessage2(obj, args) {
6265
6328
  let val = flag(obj, "object");
6266
6329
  let expected = args[3];
6267
6330
  let actual = getActual(obj, args);
6268
- let msg = negate ? args[2] : args[1];
6331
+ let rawMsg = negate ? args[2] : args[1];
6269
6332
  let flagMsg = flag(obj, "message");
6270
- if (typeof msg === "function") msg = msg();
6271
- msg = msg || "";
6272
- msg = msg.replace(/#\{this\}/g, function() {
6273
- return objDisplay(val);
6274
- }).replace(/#\{act\}/g, function() {
6275
- return objDisplay(actual);
6276
- }).replace(/#\{exp\}/g, function() {
6333
+ if (typeof rawMsg === "function") rawMsg = rawMsg();
6334
+ const msg = (rawMsg || "").replace(/#\{(this|act|exp)\}/g, function(_, tag) {
6335
+ if (tag === "this") return objDisplay(val);
6336
+ if (tag === "act") return objDisplay(actual);
6277
6337
  return objDisplay(expected);
6278
6338
  });
6279
6339
  return flagMsg ? flagMsg + ": " + msg : msg;
6280
6340
  }
6281
6341
  __name(getMessage2, "getMessage");
6282
- function transferFlags(assertion, object, includeAll) {
6283
- let flags = assertion.__flags || (assertion.__flags = /* @__PURE__ */ Object.create(null));
6284
- if (!object.__flags) object.__flags = /* @__PURE__ */ Object.create(null);
6342
+ function transferFlags(source, object, includeAll) {
6343
+ const sourceWithFlags = source;
6344
+ const objWithFlags = object;
6345
+ let flags = sourceWithFlags.__flags || (sourceWithFlags.__flags = /* @__PURE__ */ Object.create(null));
6346
+ const objFlags = objWithFlags.__flags || (objWithFlags.__flags = /* @__PURE__ */ Object.create(null));
6285
6347
  includeAll = arguments.length === 3 ? includeAll : true;
6286
- for (let flag3 in flags) if (includeAll || flag3 !== "object" && flag3 !== "ssfi" && flag3 !== "lockSsfi" && flag3 != "message") object.__flags[flag3] = flags[flag3];
6348
+ for (let flag3 in flags) if (includeAll || flag3 !== "object" && flag3 !== "ssfi" && flag3 !== "lockSsfi" && flag3 != "message") objFlags[flag3] = flags[flag3];
6287
6349
  }
6288
6350
  __name(transferFlags, "transferFlags");
6289
6351
  function type2(obj) {
@@ -6610,9 +6672,9 @@ var _Assertion = class _Assertion {
6610
6672
  * - `eql`: This flag contains the deepEqual function to be used by the assertion.
6611
6673
  *
6612
6674
  * @param {unknown} obj target of the assertion
6613
- * @param {string} [msg] (optional) custom error message
6614
- * @param {Function} [ssfi] (optional) starting point for removing stack frames
6615
- * @param {boolean} [lockSsfi] (optional) whether or not the ssfi flag is locked
6675
+ * @param {string=} msg (optional) custom error message
6676
+ * @param {Function=} ssfi (optional) starting point for removing stack frames
6677
+ * @param {boolean=} lockSsfi (optional) whether or not the ssfi flag is locked
6616
6678
  */
6617
6679
  constructor(obj, msg, ssfi, lockSsfi) {
6618
6680
  /** @type {{}} */
@@ -6646,44 +6708,44 @@ var _Assertion = class _Assertion {
6646
6708
  }
6647
6709
  /**
6648
6710
  * @param {string} name
6649
- * @param {Function} fn
6711
+ * @param {(...args: never) => unknown} fn
6650
6712
  */
6651
6713
  static addProperty(name, fn) {
6652
6714
  addProperty(this.prototype, name, fn);
6653
6715
  }
6654
6716
  /**
6655
6717
  * @param {string} name
6656
- * @param {Function} fn
6718
+ * @param {(...args: never) => unknown} fn
6657
6719
  */
6658
6720
  static addMethod(name, fn) {
6659
6721
  addMethod(this.prototype, name, fn);
6660
6722
  }
6661
6723
  /**
6662
6724
  * @param {string} name
6663
- * @param {Function} fn
6664
- * @param {Function} chainingBehavior
6725
+ * @param {(...args: never) => unknown} fn
6726
+ * @param {(...args: never) => unknown} chainingBehavior
6665
6727
  */
6666
6728
  static addChainableMethod(name, fn, chainingBehavior) {
6667
6729
  addChainableMethod(this.prototype, name, fn, chainingBehavior);
6668
6730
  }
6669
6731
  /**
6670
6732
  * @param {string} name
6671
- * @param {Function} fn
6733
+ * @param {(...args: never) => unknown} fn
6672
6734
  */
6673
6735
  static overwriteProperty(name, fn) {
6674
6736
  overwriteProperty(this.prototype, name, fn);
6675
6737
  }
6676
6738
  /**
6677
6739
  * @param {string} name
6678
- * @param {Function} fn
6740
+ * @param {(...args: never) => unknown} fn
6679
6741
  */
6680
6742
  static overwriteMethod(name, fn) {
6681
6743
  overwriteMethod(this.prototype, name, fn);
6682
6744
  }
6683
6745
  /**
6684
6746
  * @param {string} name
6685
- * @param {Function} fn
6686
- * @param {Function} chainingBehavior
6747
+ * @param {(...args: never) => unknown} fn
6748
+ * @param {(...args: never) => unknown} chainingBehavior
6687
6749
  */
6688
6750
  static overwriteChainableMethod(name, fn, chainingBehavior) {
6689
6751
  overwriteChainableMethod(this.prototype, name, fn, chainingBehavior);
@@ -6740,6 +6802,11 @@ __name(_Assertion, "Assertion");
6740
6802
  var Assertion = _Assertion;
6741
6803
  var events = new EventTarget();
6742
6804
  var _PluginEvent = class _PluginEvent extends Event {
6805
+ /**
6806
+ * @param {string} type
6807
+ * @param {string} name
6808
+ * @param {Function} fn
6809
+ */
6743
6810
  constructor(type3, name, fn) {
6744
6811
  super(type3);
6745
6812
  this.name = String(name);
@@ -6770,7 +6837,7 @@ function addProperty(ctx, name, getter) {
6770
6837
  __name(addProperty, "addProperty");
6771
6838
  var fnLengthDesc = Object.getOwnPropertyDescriptor(function() {}, "length");
6772
6839
  function addLengthGuard(fn, assertionName, isChainable) {
6773
- if (!fnLengthDesc.configurable) return fn;
6840
+ if (!fnLengthDesc?.configurable) return fn;
6774
6841
  Object.defineProperty(fn, "length", { get: /* @__PURE__ */ __name(function() {
6775
6842
  if (isChainable) throw Error("Invalid Chai property: " + assertionName + ".length. Due to a compatibility issue, \"length\" cannot directly follow \"" + assertionName + "\". Use \"" + assertionName + ".lengthOf\" instead.");
6776
6843
  throw Error("Invalid Chai property: " + assertionName + ".length. See docs for proper usage of \"" + assertionName + "\".");
@@ -6802,7 +6869,7 @@ function proxify(obj, nonChainableMethodName) {
6802
6869
  if (!isProxyEnabled()) return obj;
6803
6870
  return new Proxy(obj, { get: /* @__PURE__ */ __name(function proxyGetter(target, property) {
6804
6871
  if (typeof property === "string" && config.proxyExcludedKeys.indexOf(property) === -1 && !Reflect.has(target, property)) {
6805
- if (nonChainableMethodName) throw Error("Invalid Chai property: " + nonChainableMethodName + "." + property + ". See docs for proper usage of \"" + nonChainableMethodName + "\".");
6872
+ if (nonChainableMethodName) throw Error("Invalid Chai property: " + String(nonChainableMethodName) + "." + property + ". See docs for proper usage of \"" + String(nonChainableMethodName) + "\".");
6806
6873
  let suggestion = null;
6807
6874
  let suggestionDistance = 4;
6808
6875
  getProperties(target).forEach(function(prop) {
@@ -6858,7 +6925,8 @@ function addMethod(ctx, name, method) {
6858
6925
  }
6859
6926
  __name(addMethod, "addMethod");
6860
6927
  function overwriteProperty(ctx, name, getter) {
6861
- let _get = Object.getOwnPropertyDescriptor(ctx, name), _super = /* @__PURE__ */ __name(function() {}, "_super");
6928
+ let _get = Object.getOwnPropertyDescriptor(ctx, name);
6929
+ let _super = /* @__PURE__ */ __name(function() {}, "_super");
6862
6930
  if (_get && "function" === typeof _get.get) _super = _get.get;
6863
6931
  Object.defineProperty(ctx, name, {
6864
6932
  get: /* @__PURE__ */ __name(function overwritingPropertyGetter() {
@@ -6877,11 +6945,12 @@ function overwriteProperty(ctx, name, getter) {
6877
6945
  }
6878
6946
  __name(overwriteProperty, "overwriteProperty");
6879
6947
  function overwriteMethod(ctx, name, method) {
6880
- let _method = ctx[name], _super = /* @__PURE__ */ __name(function() {
6881
- throw new Error(name + " is not a function");
6948
+ let _method = ctx[name];
6949
+ let _super = /* @__PURE__ */ __name(function() {
6950
+ throw new Error(String(name) + " is not a function");
6882
6951
  }, "_super");
6883
6952
  if (_method && "function" === typeof _method) _super = _method;
6884
- let overwritingMethodWrapper = /* @__PURE__ */ __name(function() {
6953
+ function overwritingMethodWrapper() {
6885
6954
  if (!flag(this, "lockSsfi")) flag(this, "ssfi", overwritingMethodWrapper);
6886
6955
  let origLockSsfi = flag(this, "lockSsfi");
6887
6956
  flag(this, "lockSsfi", true);
@@ -6891,8 +6960,9 @@ function overwriteMethod(ctx, name, method) {
6891
6960
  let newAssertion = new Assertion();
6892
6961
  transferFlags(this, newAssertion);
6893
6962
  return newAssertion;
6894
- }, "overwritingMethodWrapper");
6895
- addLengthGuard(overwritingMethodWrapper, name, false);
6963
+ }
6964
+ __name(overwritingMethodWrapper, "overwritingMethodWrapper");
6965
+ addLengthGuard(overwritingMethodWrapper, String(name), false);
6896
6966
  ctx[name] = proxify(overwritingMethodWrapper, name);
6897
6967
  }
6898
6968
  __name(overwriteMethod, "overwriteMethod");
@@ -6906,6 +6976,12 @@ var excludeNames = Object.getOwnPropertyNames(testFn).filter(function(name) {
6906
6976
  var call = Function.prototype.call;
6907
6977
  var apply = Function.prototype.apply;
6908
6978
  var _PluginAddChainableMethodEvent = class _PluginAddChainableMethodEvent extends PluginEvent {
6979
+ /**
6980
+ * @param {string} type
6981
+ * @param {string} name
6982
+ * @param {Function} fn
6983
+ * @param {Function} chainingBehavior
6984
+ */
6909
6985
  constructor(type3, name, fn, chainingBehavior) {
6910
6986
  super(type3, name, fn);
6911
6987
  this.chainingBehavior = chainingBehavior;
@@ -6914,24 +6990,26 @@ var _PluginAddChainableMethodEvent = class _PluginAddChainableMethodEvent extend
6914
6990
  __name(_PluginAddChainableMethodEvent, "PluginAddChainableMethodEvent");
6915
6991
  var PluginAddChainableMethodEvent = _PluginAddChainableMethodEvent;
6916
6992
  function addChainableMethod(ctx, name, method, chainingBehavior) {
6993
+ const ctxChainable = ctx;
6917
6994
  if (typeof chainingBehavior !== "function") chainingBehavior = /* @__PURE__ */ __name(function() {}, "chainingBehavior");
6918
6995
  let chainableBehavior = {
6919
6996
  method,
6920
6997
  chainingBehavior
6921
6998
  };
6922
- if (!ctx.__methods) ctx.__methods = {};
6923
- ctx.__methods[name] = chainableBehavior;
6999
+ if (!ctxChainable.__methods) ctxChainable.__methods = {};
7000
+ ctxChainable.__methods[name] = chainableBehavior;
6924
7001
  Object.defineProperty(ctx, name, {
6925
7002
  get: /* @__PURE__ */ __name(function chainableMethodGetter() {
6926
7003
  chainableBehavior.chainingBehavior.call(this);
6927
- let chainableMethodWrapper = /* @__PURE__ */ __name(function() {
7004
+ function chainableMethodWrapper(...args) {
6928
7005
  if (!flag(this, "lockSsfi")) flag(this, "ssfi", chainableMethodWrapper);
6929
- let result = chainableBehavior.method.apply(this, arguments);
7006
+ let result = chainableBehavior.method.apply(this, args);
6930
7007
  if (result !== void 0) return result;
6931
7008
  let newAssertion = new Assertion();
6932
7009
  transferFlags(this, newAssertion);
6933
7010
  return newAssertion;
6934
- }, "chainableMethodWrapper");
7011
+ }
7012
+ __name(chainableMethodWrapper, "chainableMethodWrapper");
6935
7013
  addLengthGuard(chainableMethodWrapper, name, true);
6936
7014
  if (canSetPrototype) {
6937
7015
  let prototype = Object.create(this);
@@ -6941,7 +7019,7 @@ function addChainableMethod(ctx, name, method, chainingBehavior) {
6941
7019
  } else Object.getOwnPropertyNames(ctx).forEach(function(asserterName) {
6942
7020
  if (excludeNames.indexOf(asserterName) !== -1) return;
6943
7021
  let pd = Object.getOwnPropertyDescriptor(ctx, asserterName);
6944
- Object.defineProperty(chainableMethodWrapper, asserterName, pd);
7022
+ if (pd) Object.defineProperty(chainableMethodWrapper, asserterName, pd);
6945
7023
  });
6946
7024
  transferFlags(this, chainableMethodWrapper);
6947
7025
  return proxify(chainableMethodWrapper);
@@ -6978,7 +7056,7 @@ __name(compareByInspect, "compareByInspect");
6978
7056
  function getOwnEnumerablePropertySymbols(obj) {
6979
7057
  if (typeof Object.getOwnPropertySymbols !== "function") return [];
6980
7058
  return Object.getOwnPropertySymbols(obj).filter(function(sym) {
6981
- return Object.getOwnPropertyDescriptor(obj, sym).enumerable;
7059
+ return Object.getOwnPropertyDescriptor(obj, sym)?.enumerable;
6982
7060
  });
6983
7061
  }
6984
7062
  __name(getOwnEnumerablePropertySymbols, "getOwnEnumerablePropertySymbols");
@@ -7001,13 +7079,14 @@ function getOperator(obj, args) {
7001
7079
  let negate = flag(obj, "negate");
7002
7080
  let expected = args[3];
7003
7081
  let msg = negate ? args[2] : args[1];
7004
- if (operator) return operator;
7082
+ if (operator) return String(operator);
7005
7083
  if (typeof msg === "function") msg = msg();
7006
7084
  msg = msg || "";
7007
7085
  if (!msg) return;
7008
- if (/\shave\s/.test(msg)) return;
7086
+ const msgString = String(msg);
7087
+ if (/\shave\s/.test(msgString)) return;
7009
7088
  let isObject = isObjectType(expected);
7010
- if (/\snot\s/.test(msg)) return isObject ? "notDeepStrictEqual" : "notStrictEqual";
7089
+ if (/\snot\s/.test(msgString)) return isObject ? "notDeepStrictEqual" : "notStrictEqual";
7011
7090
  return isObject ? "deepStrictEqual" : "strictEqual";
7012
7091
  }
7013
7092
  __name(getOperator, "getOperator");
@@ -7511,18 +7590,19 @@ function assertKeys(keys) {
7511
7590
  if (!keys.length) throw new AssertionError(flagMsg + "keys required", void 0, ssfi);
7512
7591
  let len = keys.length, any = flag2(this, "any"), all = flag2(this, "all"), expected = keys, isEql = isDeep ? flag2(this, "eql") : (val1, val2) => val1 === val2;
7513
7592
  if (!any && !all) all = true;
7514
- if (any) ok = expected.some(function(expectedKey) {
7593
+ const uniqueExpected = [...new Set(expected)];
7594
+ if (any) ok = uniqueExpected.some(function(expectedKey) {
7515
7595
  return actual.some(function(actualKey) {
7516
7596
  return isEql(expectedKey, actualKey);
7517
7597
  });
7518
7598
  });
7519
7599
  if (all) {
7520
- ok = expected.every(function(expectedKey) {
7600
+ ok = uniqueExpected.every(function(expectedKey) {
7521
7601
  return actual.some(function(actualKey) {
7522
7602
  return isEql(expectedKey, actualKey);
7523
7603
  });
7524
7604
  });
7525
- if (!flag2(this, "contains")) ok = ok && keys.length == actual.length;
7605
+ if (!flag2(this, "contains")) ok = ok && uniqueExpected.length == actual.length;
7526
7606
  }
7527
7607
  if (len > 1) {
7528
7608
  keys = keys.map(function(key) {
@@ -7680,28 +7760,32 @@ Assertion.addMethod("members", function(subset, msg) {
7680
7760
  Assertion.addProperty("iterable", function(msg) {
7681
7761
  if (msg) flag2(this, "message", msg);
7682
7762
  let obj = flag2(this, "object");
7683
- this.assert(obj != void 0 && obj[Symbol.iterator], "expected #{this} to be an iterable", "expected #{this} to not be an iterable", obj);
7763
+ this.assert(obj != void 0 && typeof obj[Symbol.iterator] === "function", "expected #{this} to be an iterable", "expected #{this} to not be an iterable", obj);
7684
7764
  });
7685
7765
  function oneOf(list, msg) {
7686
7766
  if (msg) flag2(this, "message", msg);
7687
7767
  let expected = flag2(this, "object"), flagMsg = flag2(this, "message"), ssfi = flag2(this, "ssfi"), contains = flag2(this, "contains"), isDeep = flag2(this, "deep"), eql = flag2(this, "eql");
7688
7768
  new Assertion(list, flagMsg, ssfi, true).to.be.an("array");
7689
7769
  if (contains) this.assert(list.some(function(possibility) {
7690
- return expected.indexOf(possibility) > -1;
7691
- }), "expected #{this} to contain one of #{exp}", "expected #{this} to not contain one of #{exp}", list, expected);
7770
+ return expected.indexOf(possibility) > -1 || isDeep && Array.isArray(expected) && expected.some(function(item) {
7771
+ return eql(item, possibility);
7772
+ });
7773
+ }), "expected #{this} to " + (isDeep ? "deeply " : "") + "contain one of #{exp}", "expected #{this} to not " + (isDeep ? "deeply " : "") + "contain one of #{exp}", list, expected);
7692
7774
  else if (isDeep) this.assert(list.some(function(possibility) {
7693
7775
  return eql(expected, possibility);
7694
- }), "expected #{this} to deeply equal one of #{exp}", "expected #{this} to deeply equal one of #{exp}", list, expected);
7776
+ }), "expected #{this} to deeply equal one of #{exp}", "expected #{this} to not deeply equal one of #{exp}", list, expected);
7695
7777
  else this.assert(list.indexOf(expected) > -1, "expected #{this} to be one of #{exp}", "expected #{this} to not be one of #{exp}", list, expected);
7696
7778
  }
7697
7779
  __name(oneOf, "oneOf");
7698
7780
  Assertion.addMethod("oneOf", oneOf);
7699
7781
  function assertChanges(subject, prop, msg) {
7700
7782
  if (msg) flag2(this, "message", msg);
7701
- let fn = flag2(this, "object"), flagMsg = flag2(this, "message"), ssfi = flag2(this, "ssfi");
7783
+ const fn = flag2(this, "object");
7784
+ const flagMsg = flag2(this, "message");
7785
+ const ssfi = flag2(this, "ssfi");
7702
7786
  new Assertion(fn, flagMsg, ssfi, true).is.a("function");
7703
7787
  let initial;
7704
- if (!prop) {
7788
+ if (prop === null || prop === void 0) {
7705
7789
  new Assertion(subject, flagMsg, ssfi, true).is.a("function");
7706
7790
  initial = subject();
7707
7791
  } else {
@@ -7709,7 +7793,9 @@ function assertChanges(subject, prop, msg) {
7709
7793
  initial = subject[prop];
7710
7794
  }
7711
7795
  fn();
7712
- let final = prop === void 0 || prop === null ? subject() : subject[prop];
7796
+ let final = prop === void 0 || prop === null ? subject() :
7797
+ /** @type {Record<PropertyKey, unknown>} */
7798
+ subject[prop];
7713
7799
  let msgObj = prop === void 0 || prop === null ? initial : "." + prop;
7714
7800
  flag2(this, "deltaMsgObj", msgObj);
7715
7801
  flag2(this, "initialDeltaValue", initial);
@@ -7723,10 +7809,12 @@ Assertion.addMethod("change", assertChanges);
7723
7809
  Assertion.addMethod("changes", assertChanges);
7724
7810
  function assertIncreases(subject, prop, msg) {
7725
7811
  if (msg) flag2(this, "message", msg);
7726
- let fn = flag2(this, "object"), flagMsg = flag2(this, "message"), ssfi = flag2(this, "ssfi");
7812
+ const fn = flag2(this, "object");
7813
+ const flagMsg = flag2(this, "message");
7814
+ const ssfi = flag2(this, "ssfi");
7727
7815
  new Assertion(fn, flagMsg, ssfi, true).is.a("function");
7728
7816
  let initial;
7729
- if (!prop) {
7817
+ if (prop === null || prop === void 0) {
7730
7818
  new Assertion(subject, flagMsg, ssfi, true).is.a("function");
7731
7819
  initial = subject();
7732
7820
  } else {
@@ -7735,7 +7823,9 @@ function assertIncreases(subject, prop, msg) {
7735
7823
  }
7736
7824
  new Assertion(initial, flagMsg, ssfi, true).is.a("number");
7737
7825
  fn();
7738
- let final = prop === void 0 || prop === null ? subject() : subject[prop];
7826
+ let final = prop === void 0 || prop === null ? subject() :
7827
+ /** @type {Record<PropertyKey, number>} */
7828
+ subject[prop];
7739
7829
  let msgObj = prop === void 0 || prop === null ? initial : "." + prop;
7740
7830
  flag2(this, "deltaMsgObj", msgObj);
7741
7831
  flag2(this, "initialDeltaValue", initial);
@@ -7749,10 +7839,12 @@ Assertion.addMethod("increase", assertIncreases);
7749
7839
  Assertion.addMethod("increases", assertIncreases);
7750
7840
  function assertDecreases(subject, prop, msg) {
7751
7841
  if (msg) flag2(this, "message", msg);
7752
- let fn = flag2(this, "object"), flagMsg = flag2(this, "message"), ssfi = flag2(this, "ssfi");
7842
+ const fn = flag2(this, "object");
7843
+ const flagMsg = flag2(this, "message");
7844
+ const ssfi = flag2(this, "ssfi");
7753
7845
  new Assertion(fn, flagMsg, ssfi, true).is.a("function");
7754
7846
  let initial;
7755
- if (!prop) {
7847
+ if (prop === null || prop === void 0) {
7756
7848
  new Assertion(subject, flagMsg, ssfi, true).is.a("function");
7757
7849
  initial = subject();
7758
7850
  } else {
@@ -7761,7 +7853,9 @@ function assertDecreases(subject, prop, msg) {
7761
7853
  }
7762
7854
  new Assertion(initial, flagMsg, ssfi, true).is.a("number");
7763
7855
  fn();
7764
- let final = prop === void 0 || prop === null ? subject() : subject[prop];
7856
+ let final = prop === void 0 || prop === null ? subject() :
7857
+ /** @type {Record<PropertyKey, number>} */
7858
+ subject[prop];
7765
7859
  let msgObj = prop === void 0 || prop === null ? initial : "." + prop;
7766
7860
  flag2(this, "deltaMsgObj", msgObj);
7767
7861
  flag2(this, "initialDeltaValue", initial);
@@ -7842,12 +7936,12 @@ function expect(val, message) {
7842
7936
  }
7843
7937
  __name(expect, "expect");
7844
7938
  expect.fail = function(actual, expected, message, operator) {
7939
+ let msg = message;
7845
7940
  if (arguments.length < 2) {
7846
- message = actual;
7941
+ msg = actual;
7847
7942
  actual = void 0;
7848
7943
  }
7849
- message = message || "expect.fail()";
7850
- throw new AssertionError(message, {
7944
+ throw new AssertionError(msg || "expect.fail()", {
7851
7945
  actual,
7852
7946
  expected,
7853
7947
  operator
@@ -8299,7 +8393,7 @@ assert.oneOf = function(inList, list, msg) {
8299
8393
  new Assertion(inList, msg, assert.oneOf, true).to.be.oneOf(list);
8300
8394
  };
8301
8395
  assert.isIterable = function(obj, msg) {
8302
- if (obj == void 0 || !obj[Symbol.iterator]) {
8396
+ if (obj == void 0 || typeof obj[Symbol.iterator] !== "function") {
8303
8397
  msg = msg ? `${msg} expected ${inspect2(obj)} to be an iterable` : `expected ${inspect2(obj)} to be an iterable`;
8304
8398
  throw new AssertionError(msg, void 0, assert.isIterable);
8305
8399
  }
@@ -8493,7 +8587,7 @@ function use(fn) {
8493
8587
  }
8494
8588
  __name(use, "use");
8495
8589
  //#endregion
8496
- //#region ../../node_modules/.pnpm/vitest@5.0.3_@types+node@26.6.5_@vitest+coverage-v8@5.0.4_vite@8.2.2_@types+node@26.6.5_220b0db820952837b535c2e83c4bd0a5/node_modules/vitest/dist/chunks/plugins.D2ut1V9b.js
8590
+ //#region ../../node_modules/.pnpm/vitest@5.1.0_@types+node@26.6.5_@vitest+coverage-v8@5.0.4_vite@8.2.2_@types+node@26.6.5_4fc92309849883ad11a836cad05c50d8/node_modules/vitest/dist/chunks/plugins.DPQHVT0p.js
8497
8591
  const serialize$1 = (val, config, indentation, depth, refs, printer) => {
8498
8592
  const name = val.getMockName();
8499
8593
  const nameString = name === "vi.fn()" ? "" : ` ${name}`;
@@ -8526,7 +8620,7 @@ function getSerializers() {
8526
8620
  return PLUGINS;
8527
8621
  }
8528
8622
  //#endregion
8529
- //#region ../../node_modules/.pnpm/vitest@5.0.3_@types+node@26.6.5_@vitest+coverage-v8@5.0.4_vite@8.2.2_@types+node@26.6.5_220b0db820952837b535c2e83c4bd0a5/node_modules/vitest/dist/chunks/offset.Dy-5Fdfn.js
8623
+ //#region ../../node_modules/.pnpm/vitest@5.1.0_@types+node@26.6.5_@vitest+coverage-v8@5.0.4_vite@8.2.2_@types+node@26.6.5_4fc92309849883ad11a836cad05c50d8/node_modules/vitest/dist/chunks/offset.Dy-5Fdfn.js
8530
8624
  const lineSplitRE = /\r?\n/;
8531
8625
  function positionToOffset(source, lineNumber, columnNumber) {
8532
8626
  const lines = source.split(lineSplitRE);
@@ -8549,25 +8643,8 @@ function offsetToLineNumber(source, offset) {
8549
8643
  }
8550
8644
  return line + 1;
8551
8645
  }
8552
- Object.freeze(() => {});
8553
- globalThis.Event;
8554
- function r(e = globalThis) {
8555
- let t = "unknown", n = "unknown";
8556
- return e.Bun || e.process && e.process.versions?.bun ? (t = "bun", n = e.Bun.version || "unknown") : e.Deno ? (t = "deno", n = e.Deno.version?.deno ?? "unknown") : e.process && e.process.release?.name === "node" ? (t = "node", n = e.process.versions?.node ?? "unknown") : e.HermesInternal ? (t = "hermes", n = e.HermesInternal.getRuntimeProperties?.()["OSS Release Version"] ?? "unknown") : i(e) && e.navigator.userAgent === "Cloudflare-Workers" ? t = "workerd" : i(e) && e.navigator.userAgent.toLowerCase().startsWith("quickjs-ng") ? (t = "quickjs-ng", n = e.navigator.userAgent.split("/")[1] ?? "unknown") : typeof e.Netlify == "object" ? t = "netlify" : typeof e.EdgeRuntime == "string" ? t = "edge-light" : e.__lagon__ ? t = "lagon" : e.fastly ? t = "fastly" : e.$262 && e.lockdown && e.AsyncDisposableStack ? t = "moddable" : e.d8 ? (t = "v8", n = typeof e.version == "function" ? e.version() : "unknown") : e.inIon && e.performance && e.performance.mozMemory ? t = "spidermonkey" : typeof e.$ == "object" && e.$ !== null && "IsHTMLDDA" in e.$ ? t = "jsc" : e.window && e.navigator && (t = "browser"), {
8557
- runtime: t,
8558
- version: n
8559
- };
8560
- }
8561
- function i(e = globalThis) {
8562
- return typeof e.navigator == "object" && e.navigator !== null && typeof e.navigator.userAgent == "string";
8563
- }
8564
- const { runtime: a, version: o } = r();
8565
- (async () => {}).constructor;
8566
- globalThis.performance.now.bind(globalThis.performance);
8567
- globalThis.process?.hrtime?.bigint.bind(globalThis.process?.hrtime);
8568
- globalThis.Bun?.nanoseconds;
8569
8646
  //#endregion
8570
- //#region ../../node_modules/.pnpm/vitest@5.0.3_@types+node@26.6.5_@vitest+coverage-v8@5.0.4_vite@8.2.2_@types+node@26.6.5_220b0db820952837b535c2e83c4bd0a5/node_modules/vitest/dist/chunks/index.C4tKZ0yW.js
8647
+ //#region ../../node_modules/.pnpm/vitest@5.1.0_@types+node@26.6.5_@vitest+coverage-v8@5.0.4_vite@8.2.2_@types+node@26.6.5_4fc92309849883ad11a836cad05c50d8/node_modules/vitest/dist/chunks/rawSnapshot.DqSiqIEx.js
8571
8648
  var naturalCompare$1 = { exports: {} };
8572
8649
  var hasRequiredNaturalCompare;
8573
8650
  function requireNaturalCompare() {
@@ -8644,7 +8721,7 @@ function serialize(val, indent = 2, formatOverrides = {}) {
8644
8721
  }));
8645
8722
  }
8646
8723
  function escapeBacktickString(str) {
8647
- return str.replace(/`|\\|\$\{/g, "\\$&");
8724
+ return str.replace(/`|\\|\$\{/g, "\\$&").replace(/\r/g, "\\r");
8648
8725
  }
8649
8726
  function printBacktickString(str) {
8650
8727
  return `\`${escapeBacktickString(str)}\``;
@@ -8685,9 +8762,10 @@ function deepMergeSnapshot(target, source) {
8685
8762
  if (isObject(target) && isObject(source)) {
8686
8763
  const mergedOutput = { ...target };
8687
8764
  Object.keys(source).forEach((key) => {
8688
- if (isObject(source[key]) && !source[key].$$typeof) if (!(key in target)) Object.assign(mergedOutput, { [key]: source[key] });
8689
- else mergedOutput[key] = deepMergeSnapshot(target[key], source[key]);
8690
- else if (Array.isArray(source[key])) mergedOutput[key] = deepMergeArray(target[key], source[key]);
8765
+ if (isObject(source[key]) && !source[key].$$typeof) {
8766
+ if (!(key in target)) Object.assign(mergedOutput, { [key]: source[key] });
8767
+ else mergedOutput[key] = deepMergeSnapshot(target[key], source[key]);
8768
+ } else if (Array.isArray(source[key])) mergedOutput[key] = deepMergeArray(target[key], source[key]);
8691
8769
  else Object.assign(mergedOutput, { [key]: source[key] });
8692
8770
  });
8693
8771
  return mergedOutput;
@@ -8733,7 +8811,7 @@ function memo(fn) {
8733
8811
  };
8734
8812
  }
8735
8813
  async function saveInlineSnapshots(environment, snapshots) {
8736
- const MagicString = (await import("./dist-DKhCurgc.js")).default;
8814
+ const MagicString = (await import("./dist-Dn-LI_AV.js")).default;
8737
8815
  const files = new Set(snapshots.map((i) => i.file));
8738
8816
  await Promise.all(Array.from(files).map(async (file) => {
8739
8817
  const snaps = snapshots.filter((i) => i.file === file);
@@ -8845,6 +8923,34 @@ async function saveRawSnapshots(environment, snapshots) {
8845
8923
  if (!snap.readonly) await environment.saveSnapshotFile(snap.file, snap.snapshot);
8846
8924
  }));
8847
8925
  }
8926
+ Object.freeze(() => {});
8927
+ globalThis.Event;
8928
+ (async () => {}).constructor;
8929
+ function p(e = globalThis) {
8930
+ let t = "unknown", n = "unknown";
8931
+ if (e.Bun || e.process && e.process.versions?.bun) {
8932
+ t = "bun";
8933
+ let r = e.Bun?.version;
8934
+ if (r) n = r;
8935
+ else {
8936
+ let t = e.process?.versions?.bun;
8937
+ t && (n = t);
8938
+ }
8939
+ } else e.Deno ? (t = "deno", n = e.Deno.version?.deno ?? "unknown") : e.process && e.process.release?.name === "node" ? (t = "node", n = e.process.versions?.node ?? "unknown") : e.HermesInternal ? (t = "hermes", n = e.HermesInternal.getRuntimeProperties?.()["OSS Release Version"] ?? "unknown") : m(e) && e.navigator.userAgent === "Cloudflare-Workers" ? t = "workerd" : m(e) && e.navigator.userAgent.toLowerCase().startsWith("quickjs-ng") ? (t = "quickjs-ng", n = e.navigator.userAgent.split("/")[1] ?? "unknown") : typeof e.Netlify == "object" ? t = "netlify" : typeof e.EdgeRuntime == "string" ? t = "edge-light" : e.__lagon__ ? t = "lagon" : e.fastly ? t = "fastly" : e.$262 && e.lockdown && e.AsyncDisposableStack ? t = "moddable" : e.d8 ? (t = "v8", n = typeof e.version == "function" ? e.version() : "unknown") : e.inIon && e.performance && e.performance.mozMemory ? t = "spidermonkey" : typeof e.$ == "object" && e.$ !== null && "IsHTMLDDA" in e.$ ? t = "jsc" : e.window && e.navigator && (t = "browser");
8940
+ return {
8941
+ runtime: t,
8942
+ version: n
8943
+ };
8944
+ }
8945
+ function m(e = globalThis) {
8946
+ return typeof e.navigator == "object" && e.navigator !== null && typeof e.navigator.userAgent == "string";
8947
+ }
8948
+ const { runtime: h, version: g } = p();
8949
+ globalThis.performance.now.bind(globalThis.performance);
8950
+ globalThis.process?.hrtime?.bigint.bind(globalThis.process?.hrtime);
8951
+ globalThis.Bun?.nanoseconds;
8952
+ //#endregion
8953
+ //#region ../../node_modules/.pnpm/vitest@5.1.0_@types+node@26.6.5_@vitest+coverage-v8@5.0.4_vite@8.2.2_@types+node@26.6.5_4fc92309849883ad11a836cad05c50d8/node_modules/vitest/dist/chunks/index.CZzC1gGg.js
8848
8954
  function isSameStackPosition(x, y) {
8849
8955
  return x.file === y.file && x.column === y.column && x.line === y.line;
8850
8956
  }
@@ -8860,6 +8966,7 @@ var SnapshotState = class SnapshotState {
8860
8966
  _inlineSnapshotStacks;
8861
8967
  _testIdToKeys = new DefaultMap(() => []);
8862
8968
  _rawSnapshots;
8969
+ _rawSnapshotFiles = /* @__PURE__ */ new Set();
8863
8970
  _uncheckedKeys;
8864
8971
  _snapshotFormat;
8865
8972
  _environment;
@@ -9022,17 +9129,18 @@ var SnapshotState = class SnapshotState {
9022
9129
  }
9023
9130
  _reconcile(opts) {
9024
9131
  if (opts.hasSnapshot && this._updateSnapshot === "all" || (!opts.hasSnapshot || !opts.snapshotIsPersisted) && (this._updateSnapshot === "new" || this._updateSnapshot === "all")) {
9025
- if (this._updateSnapshot === "all") if (!opts.pass) {
9026
- if (opts.hasSnapshot) this.updated.increment(opts.testId);
9027
- else this.added.increment(opts.testId);
9028
- this._addSnapshot(opts.key, opts.addValue, {
9029
- stack: opts.stack,
9030
- testId: opts.testId,
9031
- rawSnapshot: opts.rawSnapshot,
9032
- assertionName: opts.assertionName
9033
- });
9034
- } else this.matched.increment(opts.testId);
9035
- else {
9132
+ if (this._updateSnapshot === "all") {
9133
+ if (!opts.pass) {
9134
+ if (opts.hasSnapshot) this.updated.increment(opts.testId);
9135
+ else this.added.increment(opts.testId);
9136
+ this._addSnapshot(opts.key, opts.addValue, {
9137
+ stack: opts.stack,
9138
+ testId: opts.testId,
9139
+ rawSnapshot: opts.rawSnapshot,
9140
+ assertionName: opts.assertionName
9141
+ });
9142
+ } else this.matched.increment(opts.testId);
9143
+ } else {
9036
9144
  this._addSnapshot(opts.key, opts.addValue, {
9037
9145
  stack: opts.stack,
9038
9146
  testId: opts.testId,
@@ -9055,7 +9163,8 @@ var SnapshotState = class SnapshotState {
9055
9163
  count: opts.count,
9056
9164
  expected: opts.expectedDisplay,
9057
9165
  key: opts.key,
9058
- pass: false
9166
+ pass: false,
9167
+ update: this._createUpdate(opts)
9059
9168
  };
9060
9169
  } else {
9061
9170
  this.matched.increment(opts.testId);
@@ -9068,6 +9177,29 @@ var SnapshotState = class SnapshotState {
9068
9177
  };
9069
9178
  }
9070
9179
  }
9180
+ _createUpdate(opts) {
9181
+ if (opts.stack) return {
9182
+ type: "inline",
9183
+ file: opts.stack.file,
9184
+ line: opts.stack.line,
9185
+ column: opts.stack.column,
9186
+ snapshot: opts.addValue,
9187
+ testId: opts.testId,
9188
+ assertionName: opts.assertionName
9189
+ };
9190
+ if (opts.rawSnapshot) return {
9191
+ type: "raw",
9192
+ file: opts.rawSnapshot.file,
9193
+ readonly: opts.rawSnapshot.readonly,
9194
+ snapshot: opts.addValue
9195
+ };
9196
+ return {
9197
+ type: "file",
9198
+ file: this.snapshotPath,
9199
+ key: opts.key,
9200
+ snapshot: opts.addValue
9201
+ };
9202
+ }
9071
9203
  async save() {
9072
9204
  const hasExternalSnapshots = Object.keys(this._snapshotData).length;
9073
9205
  const hasInlineSnapshots = this._inlineSnapshots.length;
@@ -9129,6 +9261,7 @@ var SnapshotState = class SnapshotState {
9129
9261
  let receivedSerialized = rawSnapshot && typeof received === "string" ? received : serialize(received, void 0, this._snapshotFormat);
9130
9262
  if (!rawSnapshot) receivedSerialized = addExtraLineBreaks(receivedSerialized);
9131
9263
  if (rawSnapshot) {
9264
+ this._rawSnapshotFiles.add(rawSnapshot.file);
9132
9265
  if (rawSnapshot.content && /\r\n/.test(rawSnapshot.content) && !/\r\n/.test(receivedSerialized)) rawSnapshot.content = normalizeNewlines(rawSnapshot.content);
9133
9266
  }
9134
9267
  const expected = isInline ? inlineSnapshot : rawSnapshot ? rawSnapshot.content : this._snapshotData[key];
@@ -9181,6 +9314,14 @@ var SnapshotState = class SnapshotState {
9181
9314
  assertionName
9182
9315
  });
9183
9316
  }
9317
+ /**
9318
+ * The snapshot file, if the test file stores snapshots in it, and every asserted file snapshot.
9319
+ */
9320
+ getSnapshotFiles() {
9321
+ const files = Array.from(this._rawSnapshotFiles);
9322
+ if (this._fileExists || Object.keys(this._snapshotData).length) files.unshift(this.snapshotPath);
9323
+ return files;
9324
+ }
9184
9325
  async pack() {
9185
9326
  const snapshot = {
9186
9327
  filepath: this.testFilePath,
@@ -9285,7 +9426,7 @@ var SnapshotClient = class {
9285
9426
  }
9286
9427
  received = deepMergeSnapshot(received, properties);
9287
9428
  }
9288
- const { actual, expected, key, pass } = snapshotState.match({
9429
+ const { actual, expected, key, pass, update } = snapshotState.match({
9289
9430
  testId,
9290
9431
  testName,
9291
9432
  received,
@@ -9299,7 +9440,8 @@ var SnapshotClient = class {
9299
9440
  pass,
9300
9441
  message: () => `Snapshot \`${key || "unknown"}\` mismatched`,
9301
9442
  actual: rawSnapshot ? actual : actual?.trim(),
9302
- expected: rawSnapshot ? expected : expected?.trim()
9443
+ expected: rawSnapshot ? expected : expected?.trim(),
9444
+ meta: createMatchMeta(key, update)
9303
9445
  };
9304
9446
  }
9305
9447
  assert(options) {
@@ -9310,7 +9452,7 @@ var SnapshotClient = class {
9310
9452
  }
9311
9453
  }
9312
9454
  matchDomain(options) {
9313
- const { received, filepath, name, testId = name, message, adapter, isInline = false, inlineSnapshot, error } = options;
9455
+ const { received, filepath, name, testId = name, message, adapter, isInline = false, inlineSnapshot, error, assertionName } = options;
9314
9456
  if (!filepath) throw new Error("Snapshot cannot be used outside of test");
9315
9457
  const captured = adapter.capture(received);
9316
9458
  const rendered = adapter.render(captured);
@@ -9324,24 +9466,25 @@ var SnapshotClient = class {
9324
9466
  });
9325
9467
  expectedSnapshot.markAsChecked();
9326
9468
  const matchResult = expectedSnapshot.data !== void 0 ? adapter.match(captured, adapter.parseExpected(expectedSnapshot.data)) : void 0;
9327
- const { actual, expected, key, pass } = snapshotState.processDomainSnapshot({
9469
+ const { actual, expected, key, pass, update } = snapshotState.processDomainSnapshot({
9328
9470
  testId,
9329
9471
  received: rendered,
9330
9472
  expectedSnapshot,
9331
9473
  matchResult,
9332
9474
  isInline,
9333
9475
  error,
9334
- assertionName: options.assertionName
9476
+ assertionName
9335
9477
  });
9336
9478
  return {
9337
9479
  pass,
9338
9480
  message: () => `Snapshot \`${key}\` mismatched`,
9339
9481
  actual: actual?.trim(),
9340
- expected: expected?.trim()
9482
+ expected: expected?.trim(),
9483
+ meta: createMatchMeta(key, update)
9341
9484
  };
9342
9485
  }
9343
9486
  async pollMatchDomain(options) {
9344
- const { poll, filepath, name, testId = name, message, adapter, isInline = false, inlineSnapshot, error, timeout = 1e3, interval = 50 } = options;
9487
+ const { poll, filepath, name, testId = name, message, adapter, isInline = false, inlineSnapshot, error, timeout = 1e3, interval = 50, assertionName } = options;
9345
9488
  if (!filepath) throw new Error("Snapshot cannot be used outside of test");
9346
9489
  const snapshotState = this.getSnapshotState(filepath);
9347
9490
  const testName = [name, ...message ? [message] : []].join(" > ");
@@ -9372,20 +9515,21 @@ var SnapshotClient = class {
9372
9515
  };
9373
9516
  }
9374
9517
  const matchResult = expectedSnapshot.data !== void 0 ? adapter.match(stableResult.captured, adapter.parseExpected(expectedSnapshot.data)) : void 0;
9375
- const { actual, expected, key, pass } = snapshotState.processDomainSnapshot({
9518
+ const { actual, expected, key, pass, update } = snapshotState.processDomainSnapshot({
9376
9519
  testId,
9377
9520
  received: stableResult.rendered,
9378
9521
  expectedSnapshot,
9379
9522
  matchResult,
9380
9523
  isInline,
9381
9524
  error,
9382
- assertionName: options.assertionName
9525
+ assertionName
9383
9526
  });
9384
9527
  return {
9385
9528
  pass,
9386
9529
  message: () => `Snapshot \`${key}\` mismatched`,
9387
9530
  actual: actual?.trim(),
9388
- expected: expected?.trim()
9531
+ expected: expected?.trim(),
9532
+ meta: createMatchMeta(key, update)
9389
9533
  };
9390
9534
  }
9391
9535
  async assertRaw(options) {
@@ -9458,6 +9602,13 @@ function raceWith$1(promise, other) {
9458
9602
  value
9459
9603
  }))]);
9460
9604
  }
9605
+ function createMatchMeta(key, update) {
9606
+ return update && {
9607
+ type: "snapshot",
9608
+ key,
9609
+ update
9610
+ };
9611
+ }
9461
9612
  const ChaiStyleAssertions = (chai, utils) => {
9462
9613
  function defProperty(name, delegateTo) {
9463
9614
  utils.addProperty(chai.Assertion.prototype, name, function() {
@@ -9489,7 +9640,7 @@ const ChaiStyleAssertions = (chai, utils) => {
9489
9640
  defMethod("calledOnceWith", "toHaveBeenCalledExactlyOnceWith");
9490
9641
  defMethod("lastCalledWith", "toHaveBeenLastCalledWith");
9491
9642
  defMethod("nthCalledWith", "toHaveBeenNthCalledWith");
9492
- defMethod("returned", "toHaveReturned");
9643
+ defMethod("returned", "toHaveReturnedWith");
9493
9644
  defMethod("returnedWith", "toHaveReturnedWith");
9494
9645
  defMethod("returnedTimes", "toHaveReturnedTimes");
9495
9646
  defMethod("lastReturnedWith", "toHaveLastReturnedWith");
@@ -9525,10 +9676,11 @@ ${printReceived(actual)}`
9525
9676
  },
9526
9677
  toBeOneOf(actual, expected) {
9527
9678
  const { equals, customTesters } = this;
9528
- const { printReceived, printExpected, matcherHint } = this.utils;
9679
+ const { printReceived, printExpected, matcherHint, iterableEquality } = this.utils;
9680
+ const testers = [...customTesters, iterableEquality];
9529
9681
  let pass;
9530
- if (Array.isArray(expected)) pass = expected.length === 0 || expected.some((item) => equals(item, actual, customTesters));
9531
- else if (expected instanceof Set) pass = expected.size === 0 || expected.has(actual) || [...expected].some((item) => equals(item, actual, customTesters));
9682
+ if (Array.isArray(expected)) pass = expected.length === 0 || expected.some((item) => equals(item, actual, testers));
9683
+ else if (expected instanceof Set) pass = expected.size === 0 || expected.has(actual) || [...expected].some((item) => equals(item, actual, testers));
9532
9684
  else throw new TypeError(`You must provide an array or set to ${matcherHint(".toBeOneOf")}, not '${typeof expected}'.`);
9533
9685
  return {
9534
9686
  pass,
@@ -9549,11 +9701,11 @@ ${printReceived(actual)}`
9549
9701
  };
9550
9702
  }
9551
9703
  };
9552
- const EXPECTED_COLOR = y$1.green;
9553
- const RECEIVED_COLOR = y$1.red;
9554
- const INVERTED_COLOR = y$1.inverse;
9555
- const BOLD_WEIGHT = y$1.bold;
9556
- const DIM_COLOR = y$1.dim;
9704
+ const EXPECTED_COLOR = $.green;
9705
+ const RECEIVED_COLOR = $.red;
9706
+ const INVERTED_COLOR = $.inverse;
9707
+ const BOLD_WEIGHT = $.bold;
9708
+ const DIM_COLOR = $.dim;
9557
9709
  function matcherHint(matcherName, received = "received", expected = "expected", options = {}) {
9558
9710
  const { comment = "", isDirectExpectCall = false, isNot = false, promise = "", secondArgument = "", expectedColor = EXPECTED_COLOR, receivedColor = RECEIVED_COLOR, secondArgumentColor = EXPECTED_COLOR } = options;
9559
9711
  let hint = "";
@@ -9768,6 +9920,12 @@ const IteratorSymbol = Symbol.iterator;
9768
9920
  function hasIterator(object) {
9769
9921
  return !!(object != null && object[IteratorSymbol]);
9770
9922
  }
9923
+ function isTypedArray(value) {
9924
+ return ArrayBuffer.isView(value);
9925
+ }
9926
+ function getNonIndexEntries(typedArray) {
9927
+ return Object.keys(typedArray).slice(typedArray.length).map((key) => [key, Reflect.get(typedArray, key)]);
9928
+ }
9771
9929
  function iterableEquality(a, b, customTesters = [], aStack = [], bStack = []) {
9772
9930
  if (typeof a !== "object" || typeof b !== "object" || Array.isArray(a) || Array.isArray(b) || !hasIterator(a) || !hasIterator(b)) return;
9773
9931
  if (a.constructor !== b.constructor) return false;
@@ -9814,6 +9972,14 @@ function iterableEquality(a, b, customTesters = [], aStack = [], bStack = []) {
9814
9972
  return allFound;
9815
9973
  }
9816
9974
  }
9975
+ if (isTypedArray(a) && isTypedArray(b)) {
9976
+ if (a.length !== b.length) return false;
9977
+ for (let i = 0; i < a.length; i++) if (!Object.is(a[i], b[i]) && !equals(a[i], b[i], filteredCustomTesters)) return false;
9978
+ if (!equals(getNonIndexEntries(a), getNonIndexEntries(b), filteredCustomTesters)) return false;
9979
+ aStack.pop();
9980
+ bStack.pop();
9981
+ return true;
9982
+ }
9817
9983
  const bIterator = b[IteratorSymbol]();
9818
9984
  for (const aValue of a) {
9819
9985
  const nextB = bIterator.next();
@@ -10264,7 +10430,7 @@ function handleTestError(test, err) {
10264
10430
  function wrapAssertion(utils, name, fn) {
10265
10431
  return function(...args) {
10266
10432
  if (name !== "withTest") utils.flag(this, "_name", name);
10267
- if (!utils.flag(this, "soft")) try {
10433
+ if (!(utils.flag(this, "soft") && !utils.flag(this, "promise"))) try {
10268
10434
  return fn.apply(this, args);
10269
10435
  } finally {}
10270
10436
  const test = utils.flag(this, "vitest-test");
@@ -10305,10 +10471,12 @@ const JestChaiExpect = (chai, utils) => {
10305
10471
  if (promise === "rejects") utils.flag(this, "object", () => {
10306
10472
  throw object;
10307
10473
  });
10308
- else if (promise === "resolves" && typeof object !== "function") if (!isNot) {
10309
- const message = utils.flag(this, "message") || "expected promise to throw an error, but it didn't";
10310
- throw new AssertionError(message, { showDiff: false }, utils.flag(this, "ssfi"));
10311
- } else return;
10474
+ else if (promise === "resolves" && typeof object !== "function") {
10475
+ if (!isNot) {
10476
+ const message = utils.flag(this, "message") || "expected promise to throw an error, but it didn't";
10477
+ throw new AssertionError(message, { showDiff: false }, utils.flag(this, "ssfi"));
10478
+ } else return;
10479
+ }
10312
10480
  _super.apply(this, args);
10313
10481
  };
10314
10482
  });
@@ -10398,7 +10566,7 @@ const JestChaiExpect = (chai, utils) => {
10398
10566
  def("toContainEqual", function(expected) {
10399
10567
  const obj = utils.flag(this, "object");
10400
10568
  const index = Array.from(obj).findIndex((item) => {
10401
- return equals(item, expected, customTesters);
10569
+ return equals(item, expected, [...customTesters, iterableEquality]);
10402
10570
  });
10403
10571
  this.assert(index !== -1, "expected #{this} to deep equally contain #{exp}", "expected #{this} to not deep equally contain #{exp}", expected);
10404
10572
  });
@@ -10478,7 +10646,7 @@ const JestChaiExpect = (chai, utils) => {
10478
10646
  return utils.getPathInfo(actual, propertyName);
10479
10647
  };
10480
10648
  const { value, exists } = getValue();
10481
- const pass = exists && (args.length === 1 || equals(expected, value, customTesters));
10649
+ const pass = exists && (args.length === 1 || equals(expected, value, [...customTesters, iterableEquality]));
10482
10650
  const valueString = args.length === 1 ? "" : ` with value ${inspect$1(expected, { truncate: 40 })}`;
10483
10651
  return this.assert(pass, `expected #{this} to have property "${propertyName}"${valueString}`, `expected #{this} to not have property "${propertyName}"${valueString}`, expected, exists ? value : void 0);
10484
10652
  });
@@ -10606,11 +10774,12 @@ const JestChaiExpect = (chai, utils) => {
10606
10774
  const isNot = utils.flag(this, "negate");
10607
10775
  let thrown = null;
10608
10776
  if (promise === "rejects") thrown = obj;
10609
- else if (promise === "resolves" && typeof obj !== "function") if (!isNot) {
10610
- const message = utils.flag(this, "message") || "expected promise to throw an error, but it didn't";
10611
- throw new AssertionError(message, { showDiff: false }, utils.flag(this, "ssfi"));
10612
- } else return;
10613
- else {
10777
+ else if (promise === "resolves" && typeof obj !== "function") {
10778
+ if (!isNot) {
10779
+ const message = utils.flag(this, "message") || "expected promise to throw an error, but it didn't";
10780
+ throw new AssertionError(message, { showDiff: false }, utils.flag(this, "ssfi"));
10781
+ } else return;
10782
+ } else {
10614
10783
  let isThrow = false;
10615
10784
  try {
10616
10785
  obj();
@@ -10633,7 +10802,7 @@ const JestChaiExpect = (chai, utils) => {
10633
10802
  }
10634
10803
  if (typeof expected === "object" && "asymmetricMatch" in expected && typeof expected.asymmetricMatch === "function") {
10635
10804
  const matcher = expected;
10636
- return this.assert(thrown && matcher.asymmetricMatch(thrown), "expected error to match asymmetric matcher", "expected error not to match asymmetric matcher", matcher, thrown);
10805
+ return this.assert(thrown && matcher.asymmetricMatch(thrown, [...customTesters, iterableEquality]), "expected error to match asymmetric matcher", "expected error not to match asymmetric matcher", matcher, thrown);
10637
10806
  }
10638
10807
  const equal = equals(thrown, expected, [...customTesters, iterableEquality]);
10639
10808
  return this.assert(equal, "expected a thrown value to equal #{exp}", "expected a thrown value not to equal #{exp}", expected, thrown);
@@ -10672,11 +10841,11 @@ const JestChaiExpect = (chai, utils) => {
10672
10841
  });
10673
10842
  [{
10674
10843
  name: "toHaveResolvedWith",
10675
- condition: (spy, value) => spy.mock.settledResults.some(({ type, value: result }) => type === "fulfilled" && equals(value, result)),
10844
+ condition: (spy, value) => spy.mock.settledResults.some(({ type, value: result }) => type === "fulfilled" && equals(value, result, [...customTesters, iterableEquality])),
10676
10845
  action: "resolve"
10677
10846
  }, {
10678
10847
  name: ["toHaveReturnedWith", "toReturnWith"],
10679
- condition: (spy, value) => spy.mock.results.some(({ type, value: result }) => type === "return" && equals(value, result)),
10848
+ condition: (spy, value) => spy.mock.results.some(({ type, value: result }) => type === "return" && equals(value, result, [...customTesters, iterableEquality])),
10680
10849
  action: "return"
10681
10850
  }].forEach(({ name, condition, action }) => {
10682
10851
  def(name, function(value) {
@@ -10700,14 +10869,14 @@ const JestChaiExpect = (chai, utils) => {
10700
10869
  name: "toHaveLastResolvedWith",
10701
10870
  condition: (spy, value) => {
10702
10871
  const result = spy.mock.settledResults.at(-1);
10703
- return Boolean(result && result.type === "fulfilled" && equals(result.value, value));
10872
+ return Boolean(result && result.type === "fulfilled" && equals(result.value, value, [...customTesters, iterableEquality]));
10704
10873
  },
10705
10874
  action: "resolve"
10706
10875
  }, {
10707
10876
  name: "toHaveLastReturnedWith",
10708
10877
  condition: (spy, value) => {
10709
10878
  const result = spy.mock.results.at(-1);
10710
- return Boolean(result && result.type === "return" && equals(result.value, value));
10879
+ return Boolean(result && result.type === "return" && equals(result.value, value, [...customTesters, iterableEquality]));
10711
10880
  },
10712
10881
  action: "return"
10713
10882
  }].forEach(({ name, condition, action }) => {
@@ -10722,14 +10891,14 @@ const JestChaiExpect = (chai, utils) => {
10722
10891
  name: "toHaveNthResolvedWith",
10723
10892
  condition: (spy, index, value) => {
10724
10893
  const result = spy.mock.settledResults[index - 1];
10725
- return result && result.type === "fulfilled" && equals(result.value, value);
10894
+ return result && result.type === "fulfilled" && equals(result.value, value, [...customTesters, iterableEquality]);
10726
10895
  },
10727
10896
  action: "resolve"
10728
10897
  }, {
10729
10898
  name: "toHaveNthReturnedWith",
10730
10899
  condition: (spy, index, value) => {
10731
10900
  const result = spy.mock.results[index - 1];
10732
- return result && result.type === "return" && equals(result.value, value);
10901
+ return result && result.type === "return" && equals(result.value, value, [...customTesters, iterableEquality]);
10733
10902
  },
10734
10903
  action: "return"
10735
10904
  }].forEach(({ name, condition, action }) => {
@@ -10808,25 +10977,25 @@ const JestChaiExpect = (chai, utils) => {
10808
10977
  });
10809
10978
  };
10810
10979
  function formatCalls(spy, msg, showActualCall) {
10811
- if (spy.mock.calls.length) msg += y$1.gray(`\n\nReceived:\n\n${spy.mock.calls.map((callArg, i) => {
10812
- let methodCall = y$1.bold(` ${ordinal(i + 1)} ${spy.getMockName()} call:\n\n`);
10980
+ if (spy.mock.calls.length) msg += $.gray(`\n\nReceived:\n\n${spy.mock.calls.map((callArg, i) => {
10981
+ let methodCall = $.bold(` ${ordinal(i + 1)} ${spy.getMockName()} call:\n\n`);
10813
10982
  if (showActualCall) methodCall += diff(showActualCall, callArg, { omitAnnotationLines: true });
10814
10983
  else methodCall += stringify(callArg).split("\n").map((line) => ` ${line}`).join("\n");
10815
10984
  methodCall += "\n";
10816
10985
  return methodCall;
10817
10986
  }).join("\n")}`);
10818
- msg += y$1.gray(`\n\nNumber of calls: ${y$1.bold(spy.mock.calls.length)}\n`);
10987
+ msg += $.gray(`\n\nNumber of calls: ${$.bold(spy.mock.calls.length)}\n`);
10819
10988
  return msg;
10820
10989
  }
10821
10990
  function formatReturns(spy, results, msg, showActualReturn) {
10822
- if (results.length) msg += y$1.gray(`\n\nReceived:\n\n${results.map((callReturn, i) => {
10823
- let methodCall = y$1.bold(` ${ordinal(i + 1)} ${spy.getMockName()} call return:\n\n`);
10991
+ if (results.length) msg += $.gray(`\n\nReceived:\n\n${results.map((callReturn, i) => {
10992
+ let methodCall = $.bold(` ${ordinal(i + 1)} ${spy.getMockName()} call return:\n\n`);
10824
10993
  if (showActualReturn) methodCall += diff(showActualReturn, callReturn.value, { omitAnnotationLines: true });
10825
10994
  else methodCall += stringify(callReturn).split("\n").map((line) => ` ${line}`).join("\n");
10826
10995
  methodCall += "\n";
10827
10996
  return methodCall;
10828
10997
  }).join("\n")}`);
10829
- msg += y$1.gray(`\n\nNumber of calls: ${y$1.bold(spy.mock.calls.length)}\n`);
10998
+ msg += $.gray(`\n\nNumber of calls: ${$.bold(spy.mock.calls.length)}\n`);
10830
10999
  return msg;
10831
11000
  }
10832
11001
  function getMatcherState(assertion, expect) {
@@ -10991,6 +11160,38 @@ const benchMatchers = {
10991
11160
  };
10992
11161
  }
10993
11162
  };
11163
+ const attempts = /* @__PURE__ */ new WeakMap();
11164
+ function getTraceAttempt(test) {
11165
+ return attempts.get(test);
11166
+ }
11167
+ function createTraceRangeId() {
11168
+ return Math.random().toString(36).slice(2);
11169
+ }
11170
+ function recordTraceEntry(attempt, entry, source) {
11171
+ attempt.entries.push({
11172
+ entry: {
11173
+ ...entry,
11174
+ startTime: performance.now() - attempt.startTime
11175
+ },
11176
+ source
11177
+ });
11178
+ }
11179
+ function startPromiseTraceRange(name, source) {
11180
+ return (promise) => promise;
11181
+ }
11182
+ /**
11183
+ * Copies the stack trace from one error to another.
11184
+ *
11185
+ * If the source has no stack trace, the target is left unchanged.
11186
+ *
11187
+ * @param target - The error to copy the stack trace to.
11188
+ * @param source - The error to copy the stack trace from.
11189
+ * @returns The target error with the updated stack trace.
11190
+ */
11191
+ function copyStackTrace(target, source) {
11192
+ if (source.stack !== void 0) target.stack = source.stack.replace(source.message, target.message);
11193
+ return target;
11194
+ }
10994
11195
  var fakeTimersSrc = {};
10995
11196
  var global$1;
10996
11197
  var hasRequiredGlobal;
@@ -11440,15 +11641,6 @@ function requireFakeTimersSrc() {
11440
11641
  if (hasRequiredFakeTimersSrc) return fakeTimersSrc;
11441
11642
  hasRequiredFakeTimersSrc = 1;
11442
11643
  const globalObject = requireLib().global;
11443
- let timersModule, timersPromisesModule;
11444
- if (typeof __vitest_required__ !== "undefined") {
11445
- try {
11446
- timersModule = __vitest_required__.timers;
11447
- } catch {}
11448
- try {
11449
- timersPromisesModule = __vitest_required__.timersPromises;
11450
- } catch {}
11451
- }
11452
11644
  /**
11453
11645
  * @typedef {"nextAsync" | "manual" | "interval"} TickMode
11454
11646
  */
@@ -11896,7 +12088,7 @@ function requireFakeTimersSrc() {
11896
12088
  isPresent.hrtime = _global.process && typeof _global.process.hrtime === "function";
11897
12089
  isPresent.hrtimeBigint = isPresent.hrtime && typeof _global.process.hrtime.bigint === "function";
11898
12090
  isPresent.nextTick = _global.process && typeof _global.process.nextTick === "function";
11899
- const utilPromisify = _global.process && _global.__vitest_required__ && _global.__vitest_required__.util.promisify;
12091
+ const utilPromisify = _global.process && _global.__vitest_required__?.util.promisify;
11900
12092
  isPresent.performance = _global.performance && typeof _global.performance.now === "function";
11901
12093
  const hasPerformancePrototype = _global.Performance && (typeof _global.Performance).match(/^(function|object)$/);
11902
12094
  const hasPerformanceConstructorPrototype = _global.performance && _global.performance.constructor && _global.performance.constructor.prototype;
@@ -13213,6 +13405,7 @@ To automatically clean-up native timers, use \`shouldClearNativeTimers\`.\n${sta
13213
13405
  clock.uninstall = function() {
13214
13406
  uninstalled = true;
13215
13407
  clock.setTickMode({ mode: "manual" });
13408
+ const { timersModule, timersPromisesModule } = clock;
13216
13409
  if (clock.methods) {
13217
13410
  const installedHrTime = "_hrtime";
13218
13411
  const installedNextTick = "_nextTick";
@@ -13284,6 +13477,12 @@ To automatically clean-up native timers, use \`shouldClearNativeTimers\`.\n${sta
13284
13477
  let i, l;
13285
13478
  const clock = createClock(config.now, config.loopLimit);
13286
13479
  clock.shouldClearNativeTimers = config.shouldClearNativeTimers;
13480
+ const vitestRequired = config.fakeNodeBuiltins && _global.__vitest_required__;
13481
+ const timersModule = vitestRequired?.timers;
13482
+ const timersPromisesModule = vitestRequired?.timersPromises;
13483
+ const syncBuiltinESMExports = vitestRequired?.syncBuiltinESMExports;
13484
+ clock.timersModule = timersModule;
13485
+ clock.timersPromisesModule = timersPromisesModule;
13287
13486
  clock.abortListenerMap = /* @__PURE__ */ new Map();
13288
13487
  if (hasToFake) {
13289
13488
  clock.methods = config.toFake || [];
@@ -13484,6 +13683,15 @@ To automatically clean-up native timers, use \`shouldClearNativeTimers\`.\n${sta
13484
13683
  }
13485
13684
  }
13486
13685
  }
13686
+ if (syncBuiltinESMExports && (clock.timersModuleMethods?.length || clock.timersPromisesModuleMethods?.length)) {
13687
+ const uninstall = clock.uninstall;
13688
+ clock.uninstall = () => {
13689
+ const result = uninstall();
13690
+ syncBuiltinESMExports();
13691
+ return result;
13692
+ };
13693
+ syncBuiltinESMExports();
13694
+ }
13487
13695
  return clock;
13488
13696
  }
13489
13697
  return {
@@ -13605,7 +13813,8 @@ var FakeTimers = class {
13605
13813
  }
13606
13814
  }
13607
13815
  setSystemTime(now) {
13608
- const date = typeof now === "undefined" || now instanceof Date ? now : new Date(now);
13816
+ const normalized = normalizeSystemTime(now);
13817
+ const date = typeof normalized === "undefined" || normalized instanceof Date ? normalized : new Date(normalized);
13609
13818
  if (this._fakingTime) this._clock.setSystemTime(date);
13610
13819
  else {
13611
13820
  const newFakingDate = date ?? new Date(this.getRealSystemTime());
@@ -13633,13 +13842,15 @@ var FakeTimers = class {
13633
13842
  return 0;
13634
13843
  }
13635
13844
  setTimerTickMode(mode, interval) {
13636
- if (this._checkFakeTimers()) if (mode === "manual") this._clock.setTickMode({ mode: "manual" });
13637
- else if (mode === "nextTimerAsync") this._clock.setTickMode({ mode: "nextAsync" });
13638
- else if (mode === "interval") this._clock.setTickMode({
13639
- mode: "interval",
13640
- delta: interval
13641
- });
13642
- else throw new Error(`Invalid tick mode: ${mode}`);
13845
+ if (this._checkFakeTimers()) {
13846
+ if (mode === "manual") this._clock.setTickMode({ mode: "manual" });
13847
+ else if (mode === "nextTimerAsync") this._clock.setTickMode({ mode: "nextAsync" });
13848
+ else if (mode === "interval") this._clock.setTickMode({
13849
+ mode: "interval",
13850
+ delta: interval
13851
+ });
13852
+ else throw new Error(`Invalid tick mode: ${mode}`);
13853
+ }
13643
13854
  }
13644
13855
  configure(config) {
13645
13856
  this._userConfig = config;
@@ -13652,6 +13863,9 @@ var FakeTimers = class {
13652
13863
  return this._fakingTime;
13653
13864
  }
13654
13865
  };
13866
+ function normalizeSystemTime(time) {
13867
+ return time && typeof time === "object" && "epochMilliseconds" in time ? time.epochMilliseconds : time;
13868
+ }
13655
13869
  const whenSymbol = Symbol.for("$$vitest:when");
13656
13870
  /**
13657
13871
  * Returns `true` if the given value is a {@linkcode When} chain created by {@linkcode when|vi.when}.
@@ -13873,15 +14087,26 @@ function getSymbol(action) {
13873
14087
  function validateOptions(options) {
13874
14088
  if (typeof options?.times === "number" && options.times <= 0) throw new RangeError("vi.when: `times` option must be greater than 0");
13875
14089
  }
13876
- function copyStackTrace$2(target, source) {
13877
- if (source.stack !== void 0) target.stack = source.stack.replace(source.message, target.message);
13878
- return target;
14090
+ function prefixMessage(error, message) {
14091
+ if (message && error instanceof Error) {
14092
+ const original = error.message;
14093
+ try {
14094
+ error.message = `${message}: ${original}`;
14095
+ } catch {
14096
+ return error;
14097
+ }
14098
+ if (error.stack !== void 0) error.stack = error.stack.replace(original, error.message);
14099
+ }
14100
+ return error;
14101
+ }
14102
+ function getTraceName(name, message) {
14103
+ return message ? `${message} (${name})` : `${name}()`;
13879
14104
  }
13880
14105
  function waitFor(callback, options = {}) {
13881
14106
  const { setTimeout, setInterval, clearTimeout, clearInterval } = getSafeTimers();
13882
- const { interval = 50, timeout = 1e3 } = typeof options === "number" ? { timeout: options } : options;
14107
+ const { interval = 50, timeout = 1e3, message } = typeof options === "number" ? { timeout: options } : options;
13883
14108
  const STACK_TRACE_ERROR = /* @__PURE__ */ new Error("STACK_TRACE_ERROR");
13884
- return new Promise((resolve, reject) => {
14109
+ return startPromiseTraceRange(getTraceName("vi.waitFor", message), STACK_TRACE_ERROR)(new Promise((resolve, reject) => {
13885
14110
  let lastError;
13886
14111
  let promiseStatus = "idle";
13887
14112
  let timeoutId;
@@ -13894,8 +14119,8 @@ function waitFor(callback, options = {}) {
13894
14119
  const handleTimeout = () => {
13895
14120
  if (intervalId) clearInterval(intervalId);
13896
14121
  let error = lastError;
13897
- if (!error) error = copyStackTrace$2(/* @__PURE__ */ new Error("Timed out in waitFor!"), STACK_TRACE_ERROR);
13898
- reject(error);
14122
+ if (!error) error = copyStackTrace(/* @__PURE__ */ new Error("Timed out in waitFor!"), STACK_TRACE_ERROR);
14123
+ reject(prefixMessage(error, message));
13899
14124
  };
13900
14125
  const checkCallback = () => {
13901
14126
  if (vi.isFakeTimers()) vi.advanceTimersByTime(interval);
@@ -13923,20 +14148,20 @@ function waitFor(callback, options = {}) {
13923
14148
  if (checkCallback() === true) return;
13924
14149
  timeoutId = setTimeout(handleTimeout, timeout);
13925
14150
  intervalId = setInterval(checkCallback, interval);
13926
- });
14151
+ }));
13927
14152
  }
13928
14153
  function waitUntil(callback, options = {}) {
13929
14154
  const { setTimeout, setInterval, clearTimeout, clearInterval } = getSafeTimers();
13930
- const { interval = 50, timeout = 1e3 } = typeof options === "number" ? { timeout: options } : options;
14155
+ const { interval = 50, timeout = 1e3, message } = typeof options === "number" ? { timeout: options } : options;
13931
14156
  const STACK_TRACE_ERROR = /* @__PURE__ */ new Error("STACK_TRACE_ERROR");
13932
- return new Promise((resolve, reject) => {
14157
+ return startPromiseTraceRange(getTraceName("vi.waitUntil", message), STACK_TRACE_ERROR)(new Promise((resolve, reject) => {
13933
14158
  let promiseStatus = "idle";
13934
14159
  let timeoutId;
13935
14160
  let intervalId;
13936
14161
  const onReject = (error) => {
13937
14162
  if (intervalId) clearInterval(intervalId);
13938
- if (!error) error = copyStackTrace$2(/* @__PURE__ */ new Error("Timed out in waitUntil!"), STACK_TRACE_ERROR);
13939
- reject(error);
14163
+ if (!error) error = copyStackTrace(/* @__PURE__ */ new Error("Timed out in waitUntil!"), STACK_TRACE_ERROR);
14164
+ reject(prefixMessage(error, message));
13940
14165
  };
13941
14166
  const onResolve = (result) => {
13942
14167
  if (!result) return;
@@ -13968,7 +14193,7 @@ function waitUntil(callback, options = {}) {
13968
14193
  if (checkCallback() === true) return;
13969
14194
  timeoutId = setTimeout(onReject, timeout);
13970
14195
  intervalId = setInterval(checkCallback, interval);
13971
- });
14196
+ }));
13972
14197
  }
13973
14198
  function createVitest() {
13974
14199
  let _config = null;
@@ -14081,7 +14306,7 @@ function createVitest() {
14081
14306
  try {
14082
14307
  return await result;
14083
14308
  } catch (error) {
14084
- if (error instanceof Error && !error.stack?.includes("__VITEST_HELPER__")) copyStackTrace$1(error, stackTraceError);
14309
+ if (error instanceof Error && !error.stack?.includes("__VITEST_HELPER__")) copyStackTrace(error, stackTraceError);
14085
14310
  throw error;
14086
14311
  }
14087
14312
  })();
@@ -14210,10 +14435,6 @@ function getImporter(name) {
14210
14435
  return stack.includes(` at Object.${name}`) || stack.includes(`${name}@`) || stack.includes(` at ${name} (`);
14211
14436
  }) + 1])?.file || "";
14212
14437
  }
14213
- function copyStackTrace$1(target, source) {
14214
- if (source.stack !== void 0) target.stack = source.stack.replace(source.message, target.message);
14215
- return target;
14216
- }
14217
14438
  function waitNextTick() {
14218
14439
  const { setTimeout } = getSafeTimers();
14219
14440
  return new Promise((resolve) => setTimeout(resolve, 0));
@@ -14241,15 +14462,19 @@ const unsupported = [
14241
14462
  "toThrowError"
14242
14463
  ];
14243
14464
  /**
14244
- * Attaches a `cause` property to the error if missing, copies the stack trace from the source, and throws.
14465
+ * Attaches a `cause` property to the error if missing, prefixes the custom message, copies the stack trace from the source, and throws.
14245
14466
  *
14246
14467
  * @param error - The error to throw
14247
14468
  * @param source - Error to copy the stack trace from
14469
+ * @param message - Custom message passed to `expect.poll`
14248
14470
  *
14249
14471
  * @throws Always throws the provided error with an amended stack trace
14250
14472
  */
14251
- function throwWithCause(error, source) {
14473
+ function throwWithCause(error, source, message) {
14252
14474
  error.cause ??= /* @__PURE__ */ new Error("Matcher did not succeed in time.");
14475
+ if (message && typeof error.message === "string" && !error.message.startsWith(`${message}: `)) try {
14476
+ error.message = `${message}: ${error.message}`;
14477
+ } catch {}
14253
14478
  throw copyStackTrace(error, source);
14254
14479
  }
14255
14480
  function createExpectPoll(expect) {
@@ -14263,6 +14488,7 @@ function createExpectPoll(expect) {
14263
14488
  utils_exports.flag(assertion, "_poll.interval", interval);
14264
14489
  const test = utils_exports.flag(assertion, "vitest-test");
14265
14490
  if (!test) throw new Error("expect.poll() must be called inside a test");
14491
+ setTraceHandlers(assertion, test);
14266
14492
  const proxy = new Proxy(assertion, { get(target, key, receiver) {
14267
14493
  const assertionFunction = Reflect.get(target, key, receiver);
14268
14494
  if (typeof assertionFunction !== "function") return assertionFunction instanceof Assertion ? proxy : assertionFunction;
@@ -14288,7 +14514,7 @@ function createExpectPoll(expect) {
14288
14514
  assertion,
14289
14515
  status: "fail"
14290
14516
  });
14291
- throwWithCause(err, STACK_TRACE_ERROR);
14517
+ throwWithCause(err, STACK_TRACE_ERROR, message);
14292
14518
  }
14293
14519
  const { setTimeout, clearTimeout } = getSafeTimers();
14294
14520
  let timerId;
@@ -14334,7 +14560,7 @@ function createExpectPoll(expect) {
14334
14560
  assertion,
14335
14561
  status: "fail"
14336
14562
  });
14337
- throwWithCause(lastError, STACK_TRACE_ERROR);
14563
+ throwWithCause(lastError, STACK_TRACE_ERROR, message);
14338
14564
  }
14339
14565
  };
14340
14566
  let awaited = false;
@@ -14369,9 +14595,39 @@ function createExpectPoll(expect) {
14369
14595
  return proxy;
14370
14596
  };
14371
14597
  }
14372
- function copyStackTrace(target, source) {
14373
- if (source.stack !== void 0) target.stack = source.stack.replace(source.message, target.message);
14374
- return target;
14598
+ function setTraceHandlers(assertion, test) {
14599
+ const attempt = getTraceAttempt(test);
14600
+ if (!attempt) return;
14601
+ const rangeId = createTraceRangeId();
14602
+ const getName = (assertion) => {
14603
+ const negated = utils_exports.flag(assertion, "negate") ? "not." : "";
14604
+ const message = utils_exports.flag(assertion, "message");
14605
+ const name = `expect.poll().${negated}${utils_exports.flag(assertion, "_name")}`;
14606
+ return message ? `${message} (${name})` : `${name}()`;
14607
+ };
14608
+ const onStart = ({ assertion }) => {
14609
+ recordTraceEntry(attempt, {
14610
+ name: getName(assertion),
14611
+ kind: "expect",
14612
+ range: {
14613
+ id: rangeId,
14614
+ phase: "start"
14615
+ }
14616
+ }, utils_exports.flag(assertion, "error"));
14617
+ };
14618
+ const onSettled = ({ assertion, status }) => {
14619
+ recordTraceEntry(attempt, {
14620
+ name: getName(assertion),
14621
+ kind: "expect",
14622
+ range: {
14623
+ id: rangeId,
14624
+ phase: "end"
14625
+ },
14626
+ status
14627
+ }, utils_exports.flag(assertion, "error"));
14628
+ };
14629
+ utils_exports.flag(assertion, "_poll.onStart", onStart);
14630
+ utils_exports.flag(assertion, "_poll.onSettled", onSettled);
14375
14631
  }
14376
14632
  function raceWith(promise, other) {
14377
14633
  const left = promise.then((value) => ({
@@ -14449,7 +14705,8 @@ const SnapshotPlugin = (chai, utils) => {
14449
14705
  filepath,
14450
14706
  hint
14451
14707
  }).then((result) => assertMatchResult(result, chai.util.flag(this, "message")));
14452
- return recordAsyncExpect(getTest(this), assertPromise, createAssertionMessage(utils, this, true), /* @__PURE__ */ new Error("resolves"), utils.flag(this, "soft"));
14708
+ const isSoft = utils.flag(this, "soft") && !utils.flag(this, "promise");
14709
+ return recordAsyncExpect(getTest(this), assertPromise, createAssertionMessage(utils, this, true), /* @__PURE__ */ new Error("resolves"), isSoft);
14453
14710
  });
14454
14711
  utils.addMethod(chai.Assertion.prototype, "toMatchInlineSnapshot", wrapAssertion(utils, "toMatchInlineSnapshot", function __INLINE_SNAPSHOT_OFFSET_3__(propertiesOrInlineSnapshot, inlineSnapshotOrHint, hint) {
14455
14712
  return assertMatchResult(toMatchSnapshotImpl({
@@ -14528,6 +14785,7 @@ async function toMatchFileSnapshotImpl(options) {
14528
14785
  const snapshotState = getSnapshotClient().getSnapshotState(testNames.filepath);
14529
14786
  const rawSnapshotFile = await snapshotState.environment.resolveRawPath(testNames.filepath, options.filepath);
14530
14787
  const rawSnapshotContent = await snapshotState.environment.readSnapshotFile(rawSnapshotFile);
14788
+ const assertionName = getAssertionName(assertion);
14531
14789
  return getSnapshotClient().match({
14532
14790
  received: options.received,
14533
14791
  message: options.hint,
@@ -14535,6 +14793,7 @@ async function toMatchFileSnapshotImpl(options) {
14535
14793
  file: rawSnapshotFile,
14536
14794
  content: rawSnapshotContent ?? void 0
14537
14795
  },
14796
+ assertionName,
14538
14797
  ...testNames
14539
14798
  });
14540
14799
  }
@@ -14544,7 +14803,8 @@ function assertMatchResult(result, customMessage) {
14544
14803
  throw Object.assign(new Error(errorMessage), {
14545
14804
  actual: result.actual,
14546
14805
  expected: result.expected,
14547
- diffOptions: { expand: getWorkerState().config.snapshotOptions.expand }
14806
+ diffOptions: { expand: getWorkerState().config.snapshotOptions.expand },
14807
+ __vitest_error_context__: { meta: result.meta }
14548
14808
  });
14549
14809
  }
14550
14810
  }