@assistant-ui/react 0.11.36 → 0.11.38

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/dist/legacy-runtime/runtime-cores/remote-thread-list/RemoteThreadListThreadListRuntimeCore.d.ts.map +1 -1
  2. package/dist/legacy-runtime/runtime-cores/remote-thread-list/RemoteThreadListThreadListRuntimeCore.js +34 -1
  3. package/dist/legacy-runtime/runtime-cores/remote-thread-list/RemoteThreadListThreadListRuntimeCore.js.map +1 -1
  4. package/dist/legacy-runtime/runtime-cores/remote-thread-list/adapter/cloud.d.ts.map +1 -1
  5. package/dist/legacy-runtime/runtime-cores/remote-thread-list/adapter/cloud.js +9 -0
  6. package/dist/legacy-runtime/runtime-cores/remote-thread-list/adapter/cloud.js.map +1 -1
  7. package/dist/legacy-runtime/runtime-cores/remote-thread-list/adapter/in-memory.d.ts +2 -1
  8. package/dist/legacy-runtime/runtime-cores/remote-thread-list/adapter/in-memory.d.ts.map +1 -1
  9. package/dist/legacy-runtime/runtime-cores/remote-thread-list/adapter/in-memory.js +3 -0
  10. package/dist/legacy-runtime/runtime-cores/remote-thread-list/adapter/in-memory.js.map +1 -1
  11. package/dist/legacy-runtime/runtime-cores/remote-thread-list/types.d.ts +1 -0
  12. package/dist/legacy-runtime/runtime-cores/remote-thread-list/types.d.ts.map +1 -1
  13. package/dist/primitives/assistantModal/scope.d.ts +2 -3
  14. package/dist/primitives/assistantModal/scope.d.ts.map +1 -1
  15. package/dist/primitives/assistantModal/scope.js.map +1 -1
  16. package/dist/primitives/index.d.ts +1 -0
  17. package/dist/primitives/index.d.ts.map +1 -1
  18. package/dist/primitives/index.js +2 -0
  19. package/dist/primitives/index.js.map +1 -1
  20. package/dist/primitives/message/MessageParts.d.ts +31 -1
  21. package/dist/primitives/message/MessageParts.d.ts.map +1 -1
  22. package/dist/primitives/message/MessageParts.js +66 -23
  23. package/dist/primitives/message/MessageParts.js.map +1 -1
  24. package/dist/primitives/reasoning/index.d.ts +2 -0
  25. package/dist/primitives/reasoning/index.d.ts.map +1 -0
  26. package/dist/primitives/reasoning/index.js +6 -0
  27. package/dist/primitives/reasoning/index.js.map +1 -0
  28. package/dist/primitives/reasoning/useScrollLock.d.ts +29 -0
  29. package/dist/primitives/reasoning/useScrollLock.d.ts.map +1 -0
  30. package/dist/primitives/reasoning/useScrollLock.js +50 -0
  31. package/dist/primitives/reasoning/useScrollLock.js.map +1 -0
  32. package/dist/primitives/thread/useThreadViewportAutoScroll.d.ts.map +1 -1
  33. package/dist/primitives/thread/useThreadViewportAutoScroll.js +11 -12
  34. package/dist/primitives/thread/useThreadViewportAutoScroll.js.map +1 -1
  35. package/dist/tests/setup.js +287 -125
  36. package/dist/tests/setup.js.map +1 -1
  37. package/dist/types/MessagePartComponentTypes.d.ts +6 -1
  38. package/dist/types/MessagePartComponentTypes.d.ts.map +1 -1
  39. package/dist/types/index.d.ts +1 -1
  40. package/dist/types/index.d.ts.map +1 -1
  41. package/package.json +8 -8
  42. package/src/legacy-runtime/runtime-cores/remote-thread-list/RemoteThreadListThreadListRuntimeCore.tsx +49 -2
  43. package/src/legacy-runtime/runtime-cores/remote-thread-list/adapter/cloud.tsx +10 -0
  44. package/src/legacy-runtime/runtime-cores/remote-thread-list/adapter/in-memory.tsx +5 -0
  45. package/src/legacy-runtime/runtime-cores/remote-thread-list/types.tsx +1 -0
  46. package/src/primitives/assistantModal/scope.tsx +3 -1
  47. package/src/primitives/index.ts +1 -0
  48. package/src/primitives/message/MessageParts.tsx +111 -30
  49. package/src/primitives/reasoning/index.ts +1 -0
  50. package/src/primitives/reasoning/useScrollLock.tsx +86 -0
  51. package/src/primitives/thread/useThreadViewportAutoScroll.tsx +14 -13
  52. package/src/types/MessagePartComponentTypes.tsx +7 -1
  53. package/src/types/index.ts +2 -0
@@ -1,9 +1,9 @@
1
- // ../../node_modules/.pnpm/vitest@4.0.6_@types+debug@4.1.12_@types+node@24.10.0_@vitest+ui@4.0.6_jiti@2.6.1_jsdom@_38fcb34f3d4da47a9b9d4b13a6949560/node_modules/vitest/dist/chunks/vi.BZvkKVkM.js
1
+ // ../../node_modules/.pnpm/vitest@4.0.8_@types+debug@4.1.12_@types+node@24.10.1_@vitest+ui@4.0.8_jiti@2.6.1_jsdom@_c97fdea49f1663602bf3dfb16acdd85d/node_modules/vitest/dist/chunks/vi.Bgcdy3bQ.js
2
2
  import { chai, equals, iterableEquality, subsetEquality, JestExtend, JestChaiExpect, JestAsymmetricMatchers, GLOBAL_EXPECT, ASYMMETRIC_MATCHERS_OBJECT, getState, setState, addCustomEqualityTesters, customMatchers } from "@vitest/expect.js";
3
3
  import { getCurrentTest } from "@vitest/runner.js";
4
4
  import { getNames, getTestName } from "@vitest/runner/utils.js";
5
5
 
6
- // ../../node_modules/.pnpm/vitest@4.0.6_@types+debug@4.1.12_@types+node@24.10.0_@vitest+ui@4.0.6_jiti@2.6.1_jsdom@_38fcb34f3d4da47a9b9d4b13a6949560/node_modules/vitest/dist/chunks/utils.CG9h5ccR.js
6
+ // ../../node_modules/.pnpm/vitest@4.0.8_@types+debug@4.1.12_@types+node@24.10.1_@vitest+ui@4.0.8_jiti@2.6.1_jsdom@_c97fdea49f1663602bf3dfb16acdd85d/node_modules/vitest/dist/chunks/utils.DvEY5TfP.js
7
7
  import { getSafeTimers } from "@vitest/utils/timers.js";
8
8
  var NAME_WORKER_STATE = "__vitest_worker__";
9
9
  function getWorkerState() {
@@ -22,7 +22,11 @@ function resetModules(modules, resetMocks = false) {
22
22
  ...!resetMocks ? [/^mock:/] : []
23
23
  ];
24
24
  modules.idToModuleMap.forEach((node, path) => {
25
- skipPaths.some((re) => re.test(path)) || (node.promise = void 0, node.exports = void 0, node.evaluated = false, node.importers.clear());
25
+ if (skipPaths.some((re) => re.test(path))) return;
26
+ node.promise = void 0;
27
+ node.exports = void 0;
28
+ node.evaluated = false;
29
+ node.importers.clear();
26
30
  });
27
31
  }
28
32
  function waitNextTick() {
@@ -31,12 +35,16 @@ function waitNextTick() {
31
35
  }
32
36
  async function waitForImportsToResolve() {
33
37
  await waitNextTick();
34
- const state = getWorkerState(), promises = [], resolvingCount = state.resolvingModules.size;
38
+ const state = getWorkerState();
39
+ const promises = [];
40
+ const resolvingCount = state.resolvingModules.size;
35
41
  for (const [_, mod] of state.evaluatedModules.idToModuleMap) if (mod.promise && !mod.evaluated) promises.push(mod.promise);
36
- !promises.length && !resolvingCount || (await Promise.allSettled(promises), await waitForImportsToResolve());
42
+ if (!promises.length && !resolvingCount) return;
43
+ await Promise.allSettled(promises);
44
+ await waitForImportsToResolve();
37
45
  }
38
46
 
39
- // ../../node_modules/.pnpm/vitest@4.0.6_@types+debug@4.1.12_@types+node@24.10.0_@vitest+ui@4.0.6_jiti@2.6.1_jsdom@_38fcb34f3d4da47a9b9d4b13a6949560/node_modules/vitest/dist/chunks/vi.BZvkKVkM.js
47
+ // ../../node_modules/.pnpm/vitest@4.0.8_@types+debug@4.1.12_@types+node@24.10.1_@vitest+ui@4.0.8_jiti@2.6.1_jsdom@_c97fdea49f1663602bf3dfb16acdd85d/node_modules/vitest/dist/chunks/vi.Bgcdy3bQ.js
40
48
  import { getSafeTimers as getSafeTimers2 } from "@vitest/utils/timers.js";
41
49
  import { stripSnapshotIndentation, addSerializer, SnapshotClient } from "@vitest/snapshot.js";
42
50
  import "@vitest/utils/error.js";
@@ -45,10 +53,10 @@ import { fn, spyOn, restoreAllMocks, resetAllMocks, clearAllMocks, isMockFunctio
45
53
  import "@vitest/utils/offset.js";
46
54
  import { parseSingleStack } from "@vitest/utils/source-map.js";
47
55
 
48
- // ../../node_modules/.pnpm/vitest@4.0.6_@types+debug@4.1.12_@types+node@24.10.0_@vitest+ui@4.0.6_jiti@2.6.1_jsdom@_38fcb34f3d4da47a9b9d4b13a6949560/node_modules/vitest/dist/chunks/_commonjsHelpers.BFTU3MAI.js
56
+ // ../../node_modules/.pnpm/vitest@4.0.8_@types+debug@4.1.12_@types+node@24.10.1_@vitest+ui@4.0.8_jiti@2.6.1_jsdom@_c97fdea49f1663602bf3dfb16acdd85d/node_modules/vitest/dist/chunks/_commonjsHelpers.BFTU3MAI.js
49
57
  var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
50
58
 
51
- // ../../node_modules/.pnpm/vitest@4.0.6_@types+debug@4.1.12_@types+node@24.10.0_@vitest+ui@4.0.6_jiti@2.6.1_jsdom@_38fcb34f3d4da47a9b9d4b13a6949560/node_modules/vitest/dist/chunks/date.-jtEtIeV.js
59
+ // ../../node_modules/.pnpm/vitest@4.0.8_@types+debug@4.1.12_@types+node@24.10.1_@vitest+ui@4.0.8_jiti@2.6.1_jsdom@_c97fdea49f1663602bf3dfb16acdd85d/node_modules/vitest/dist/chunks/date.Bq6ZW5rf.js
52
60
  var RealDate = Date;
53
61
  var now = null;
54
62
  var MockDate = class _MockDate extends RealDate {
@@ -64,29 +72,39 @@ var MockDate = class _MockDate extends RealDate {
64
72
  date = new RealDate(y);
65
73
  break;
66
74
  default:
67
- d = typeof d === "undefined" ? 1 : d, h = h || 0, M = M || 0, s = s || 0, ms = ms || 0, date = new RealDate(y, m, d, h, M, s, ms);
75
+ d = typeof d === "undefined" ? 1 : d;
76
+ h = h || 0;
77
+ M = M || 0;
78
+ s = s || 0;
79
+ ms = ms || 0;
80
+ date = new RealDate(y, m, d, h, M, s, ms);
68
81
  break;
69
82
  }
70
- return Object.setPrototypeOf(date, _MockDate.prototype), date;
83
+ Object.setPrototypeOf(date, _MockDate.prototype);
84
+ return date;
71
85
  }
72
86
  };
73
- MockDate.UTC = RealDate.UTC, MockDate.now = function() {
87
+ MockDate.UTC = RealDate.UTC;
88
+ MockDate.now = function() {
74
89
  return new MockDate().valueOf();
75
- }, MockDate.parse = function(dateString) {
90
+ };
91
+ MockDate.parse = function(dateString) {
76
92
  return RealDate.parse(dateString);
77
- }, MockDate.toString = function() {
93
+ };
94
+ MockDate.toString = function() {
78
95
  return RealDate.toString();
79
96
  };
80
97
  function mockDate(date) {
81
98
  const dateObj = new RealDate(date.valueOf());
82
99
  if (Number.isNaN(dateObj.getTime())) throw new TypeError(`mockdate: The time set is an invalid date: ${date}`);
83
- globalThis.Date = MockDate, now = dateObj.valueOf();
100
+ globalThis.Date = MockDate;
101
+ now = dateObj.valueOf();
84
102
  }
85
103
  function resetDate() {
86
104
  globalThis.Date = RealDate;
87
105
  }
88
106
 
89
- // ../../node_modules/.pnpm/vitest@4.0.6_@types+debug@4.1.12_@types+node@24.10.0_@vitest+ui@4.0.6_jiti@2.6.1_jsdom@_38fcb34f3d4da47a9b9d4b13a6949560/node_modules/vitest/dist/chunks/vi.BZvkKVkM.js
107
+ // ../../node_modules/.pnpm/vitest@4.0.8_@types+debug@4.1.12_@types+node@24.10.1_@vitest+ui@4.0.8_jiti@2.6.1_jsdom@_c97fdea49f1663602bf3dfb16acdd85d/node_modules/vitest/dist/chunks/vi.Bgcdy3bQ.js
90
108
  var unsupported = [
91
109
  "matchSnapshot",
92
110
  "toMatchSnapshot",
@@ -101,7 +119,9 @@ var unsupported = [
101
119
  ];
102
120
  function createExpectPoll(expect) {
103
121
  return function poll(fn2, options = {}) {
104
- const defaults = getWorkerState().config.expect?.poll ?? {}, { interval = defaults.interval ?? 50, timeout = defaults.timeout ?? 1e3, message } = options, assertion = expect(null, message).withContext({ poll: true });
122
+ const defaults = getWorkerState().config.expect?.poll ?? {};
123
+ const { interval = defaults.interval ?? 50, timeout = defaults.timeout ?? 1e3, message } = options;
124
+ const assertion = expect(null, message).withContext({ poll: true });
105
125
  fn2 = fn2.bind(assertion);
106
126
  const test2 = chai.util.flag(assertion, "vitest-test");
107
127
  if (!test2) throw new Error("expect.poll() must be called inside a test");
@@ -111,40 +131,53 @@ function createExpectPoll(expect) {
111
131
  if (key === "assert") return assertionFunction;
112
132
  if (typeof key === "string" && unsupported.includes(key)) throw new SyntaxError(`expect.poll() is not supported in combination with .${key}(). Use vi.waitFor() if your assertion condition is unstable.`);
113
133
  return function(...args) {
114
- const STACK_TRACE_ERROR = /* @__PURE__ */ new Error("STACK_TRACE_ERROR"), promise = () => new Promise((resolve, reject) => {
115
- let intervalId, timeoutId, lastError;
116
- const { setTimeout, clearTimeout } = getSafeTimers2(), check = async () => {
134
+ const STACK_TRACE_ERROR = /* @__PURE__ */ new Error("STACK_TRACE_ERROR");
135
+ const promise = () => new Promise((resolve, reject) => {
136
+ let intervalId;
137
+ let timeoutId;
138
+ let lastError;
139
+ const { setTimeout, clearTimeout } = getSafeTimers2();
140
+ const check = async () => {
117
141
  try {
118
142
  chai.util.flag(assertion, "_name", key);
119
143
  const obj = await fn2();
120
- chai.util.flag(assertion, "object", obj), resolve(await assertionFunction.call(assertion, ...args)), clearTimeout(intervalId), clearTimeout(timeoutId);
144
+ chai.util.flag(assertion, "object", obj);
145
+ resolve(await assertionFunction.call(assertion, ...args));
146
+ clearTimeout(intervalId);
147
+ clearTimeout(timeoutId);
121
148
  } catch (err) {
122
- if (lastError = err, !chai.util.flag(assertion, "_isLastPollAttempt")) intervalId = setTimeout(check, interval);
149
+ lastError = err;
150
+ if (!chai.util.flag(assertion, "_isLastPollAttempt")) intervalId = setTimeout(check, interval);
123
151
  }
124
152
  };
125
153
  timeoutId = setTimeout(() => {
126
- clearTimeout(intervalId), chai.util.flag(assertion, "_isLastPollAttempt", true);
154
+ clearTimeout(intervalId);
155
+ chai.util.flag(assertion, "_isLastPollAttempt", true);
127
156
  const rejectWithCause = (error) => {
128
157
  if (error.cause == null) error.cause = /* @__PURE__ */ new Error("Matcher did not succeed in time.");
129
158
  reject(copyStackTrace$1(error, STACK_TRACE_ERROR));
130
159
  };
131
160
  check().then(() => rejectWithCause(lastError)).catch((e) => rejectWithCause(e));
132
- }, timeout), check();
161
+ }, timeout);
162
+ check();
133
163
  });
134
164
  let awaited = false;
135
- test2.onFinished ??= [], test2.onFinished.push(() => {
165
+ test2.onFinished ??= [];
166
+ test2.onFinished.push(() => {
136
167
  if (!awaited) {
137
- const negated = chai.util.flag(assertion, "negate") ? "not." : "", assertionString = `expect.${chai.util.flag(assertion, "_poll.element") ? "element(locator)" : "poll(assertion)"}.${negated}${String(key)}()`, error = /* @__PURE__ */ new Error(`${assertionString} was not awaited. This assertion is asynchronous and must be awaited; otherwise, it is not executed to avoid unhandled rejections:
168
+ const negated = chai.util.flag(assertion, "negate") ? "not." : "";
169
+ const assertionString = `expect.${chai.util.flag(assertion, "_poll.element") ? "element(locator)" : "poll(assertion)"}.${negated}${String(key)}()`;
170
+ throw copyStackTrace$1(/* @__PURE__ */ new Error(`${assertionString} was not awaited. This assertion is asynchronous and must be awaited; otherwise, it is not executed to avoid unhandled rejections:
138
171
 
139
172
  await ${assertionString}
140
- `);
141
- throw copyStackTrace$1(error, STACK_TRACE_ERROR);
173
+ `), STACK_TRACE_ERROR);
142
174
  }
143
175
  });
144
176
  let resultPromise;
145
177
  return {
146
178
  then(onFulfilled, onRejected) {
147
- return awaited = true, (resultPromise ||= promise()).then(onFulfilled, onRejected);
179
+ awaited = true;
180
+ return (resultPromise ||= promise()).then(onFulfilled, onRejected);
148
181
  },
149
182
  catch(onRejected) {
150
183
  return (resultPromise ||= promise()).catch(onRejected);
@@ -164,20 +197,24 @@ function copyStackTrace$1(target, source) {
164
197
  return target;
165
198
  }
166
199
  function createAssertionMessage(util, assertion, hasArgs) {
167
- const not = util.flag(assertion, "negate") ? "not." : "", name = `${util.flag(assertion, "_name")}(${"expected"})`, promiseName = util.flag(assertion, "promise");
200
+ const not = util.flag(assertion, "negate") ? "not." : "";
201
+ const name = `${util.flag(assertion, "_name")}(${"expected"})`;
202
+ const promiseName = util.flag(assertion, "promise");
168
203
  return `expect(actual)${promiseName ? `.${promiseName}` : ""}.${not}${name}`;
169
204
  }
170
205
  function recordAsyncExpect(_test, promise, assertion, error) {
171
206
  const test2 = _test;
172
207
  if (test2 && promise instanceof Promise) {
173
- if (promise = promise.finally(() => {
208
+ promise = promise.finally(() => {
174
209
  if (!test2.promises) return;
175
210
  const index = test2.promises.indexOf(promise);
176
211
  if (index !== -1) test2.promises.splice(index, 1);
177
- }), !test2.promises) test2.promises = [];
212
+ });
213
+ if (!test2.promises) test2.promises = [];
178
214
  test2.promises.push(promise);
179
215
  let resolved = false;
180
- return test2.onFinished ??= [], test2.onFinished.push(() => {
216
+ test2.onFinished ??= [];
217
+ test2.onFinished.push(() => {
181
218
  if (!resolved) {
182
219
  const stack = (globalThis.__vitest_worker__?.onFilterStackTrace || ((s) => s || ""))(error.stack);
183
220
  console.warn([
@@ -187,9 +224,11 @@ function recordAsyncExpect(_test, promise, assertion, error) {
187
224
  stack
188
225
  ].join(""));
189
226
  }
190
- }), {
227
+ });
228
+ return {
191
229
  then(onFulfilled, onRejected) {
192
- return resolved = true, promise.then(onFulfilled, onRejected);
230
+ resolved = true;
231
+ return promise.then(onFulfilled, onRejected);
193
232
  },
194
233
  catch(onRejected) {
195
234
  return promise.catch(onRejected);
@@ -235,9 +274,14 @@ var SnapshotPlugin = (chai3, utils) => {
235
274
  return test2;
236
275
  }
237
276
  for (const key of ["matchSnapshot", "toMatchSnapshot"]) utils.addMethod(chai3.Assertion.prototype, key, function(properties, message) {
238
- if (utils.flag(this, "_name", key), utils.flag(this, "negate")) throw new Error(`${key} cannot be used with "not"`);
239
- const expected = utils.flag(this, "object"), test2 = getTest(key, this);
240
- if (typeof properties === "string" && typeof message === "undefined") message = properties, properties = void 0;
277
+ utils.flag(this, "_name", key);
278
+ if (utils.flag(this, "negate")) throw new Error(`${key} cannot be used with "not"`);
279
+ const expected = utils.flag(this, "object");
280
+ const test2 = getTest(key, this);
281
+ if (typeof properties === "string" && typeof message === "undefined") {
282
+ message = properties;
283
+ properties = void 0;
284
+ }
241
285
  const errorMessage = utils.flag(this, "message");
242
286
  getSnapshotClient().assert({
243
287
  received: expected,
@@ -249,22 +293,33 @@ var SnapshotPlugin = (chai3, utils) => {
249
293
  });
250
294
  });
251
295
  utils.addMethod(chai3.Assertion.prototype, "toMatchFileSnapshot", function(file, message) {
252
- if (utils.flag(this, "_name", "toMatchFileSnapshot"), utils.flag(this, "negate")) throw new Error('toMatchFileSnapshot cannot be used with "not"');
253
- const error = /* @__PURE__ */ new Error("resolves"), expected = utils.flag(this, "object"), test2 = getTest("toMatchFileSnapshot", this), errorMessage = utils.flag(this, "message"), promise = getSnapshotClient().assertRaw({
296
+ utils.flag(this, "_name", "toMatchFileSnapshot");
297
+ if (utils.flag(this, "negate")) throw new Error('toMatchFileSnapshot cannot be used with "not"');
298
+ const error = /* @__PURE__ */ new Error("resolves");
299
+ const expected = utils.flag(this, "object");
300
+ const test2 = getTest("toMatchFileSnapshot", this);
301
+ const errorMessage = utils.flag(this, "message");
302
+ return recordAsyncExpect(test2, getSnapshotClient().assertRaw({
254
303
  received: expected,
255
304
  message,
256
305
  isInline: false,
257
306
  rawSnapshot: { file },
258
307
  errorMessage,
259
308
  ...getTestNames(test2)
260
- });
261
- return recordAsyncExpect(test2, promise, createAssertionMessage(utils, this), error);
262
- }), utils.addMethod(chai3.Assertion.prototype, "toMatchInlineSnapshot", function __INLINE_SNAPSHOT__(properties, inlineSnapshot, message) {
263
- if (utils.flag(this, "_name", "toMatchInlineSnapshot"), utils.flag(this, "negate")) throw new Error('toMatchInlineSnapshot cannot be used with "not"');
309
+ }), createAssertionMessage(utils, this), error);
310
+ });
311
+ utils.addMethod(chai3.Assertion.prototype, "toMatchInlineSnapshot", function __INLINE_SNAPSHOT__(properties, inlineSnapshot, message) {
312
+ utils.flag(this, "_name", "toMatchInlineSnapshot");
313
+ if (utils.flag(this, "negate")) throw new Error('toMatchInlineSnapshot cannot be used with "not"');
264
314
  const test2 = getTest("toMatchInlineSnapshot", this);
265
315
  if (test2.each || test2.suite?.each) throw new Error("InlineSnapshot cannot be used inside of test.each or describe.each");
266
- const expected = utils.flag(this, "object"), error = utils.flag(this, "error");
267
- if (typeof properties === "string") message = inlineSnapshot, inlineSnapshot = properties, properties = void 0;
316
+ const expected = utils.flag(this, "object");
317
+ const error = utils.flag(this, "error");
318
+ if (typeof properties === "string") {
319
+ message = inlineSnapshot;
320
+ inlineSnapshot = properties;
321
+ properties = void 0;
322
+ }
268
323
  if (inlineSnapshot) inlineSnapshot = stripSnapshotIndentation(inlineSnapshot);
269
324
  const errorMessage = utils.flag(this, "message");
270
325
  getSnapshotClient().assert({
@@ -277,20 +332,29 @@ var SnapshotPlugin = (chai3, utils) => {
277
332
  errorMessage,
278
333
  ...getTestNames(test2)
279
334
  });
280
- }), utils.addMethod(chai3.Assertion.prototype, "toThrowErrorMatchingSnapshot", function(message) {
281
- if (utils.flag(this, "_name", "toThrowErrorMatchingSnapshot"), utils.flag(this, "negate")) throw new Error('toThrowErrorMatchingSnapshot cannot be used with "not"');
282
- const expected = utils.flag(this, "object"), test2 = getTest("toThrowErrorMatchingSnapshot", this), promise = utils.flag(this, "promise"), errorMessage = utils.flag(this, "message");
335
+ });
336
+ utils.addMethod(chai3.Assertion.prototype, "toThrowErrorMatchingSnapshot", function(message) {
337
+ utils.flag(this, "_name", "toThrowErrorMatchingSnapshot");
338
+ if (utils.flag(this, "negate")) throw new Error('toThrowErrorMatchingSnapshot cannot be used with "not"');
339
+ const expected = utils.flag(this, "object");
340
+ const test2 = getTest("toThrowErrorMatchingSnapshot", this);
341
+ const promise = utils.flag(this, "promise");
342
+ const errorMessage = utils.flag(this, "message");
283
343
  getSnapshotClient().assert({
284
344
  received: getError(expected, promise),
285
345
  message,
286
346
  errorMessage,
287
347
  ...getTestNames(test2)
288
348
  });
289
- }), utils.addMethod(chai3.Assertion.prototype, "toThrowErrorMatchingInlineSnapshot", function __INLINE_SNAPSHOT__(inlineSnapshot, message) {
349
+ });
350
+ utils.addMethod(chai3.Assertion.prototype, "toThrowErrorMatchingInlineSnapshot", function __INLINE_SNAPSHOT__(inlineSnapshot, message) {
290
351
  if (utils.flag(this, "negate")) throw new Error('toThrowErrorMatchingInlineSnapshot cannot be used with "not"');
291
352
  const test2 = getTest("toThrowErrorMatchingInlineSnapshot", this);
292
353
  if (test2.each || test2.suite?.each) throw new Error("InlineSnapshot cannot be used inside of test.each or describe.each");
293
- const expected = utils.flag(this, "object"), error = utils.flag(this, "error"), promise = utils.flag(this, "promise"), errorMessage = utils.flag(this, "message");
354
+ const expected = utils.flag(this, "object");
355
+ const error = utils.flag(this, "error");
356
+ const promise = utils.flag(this, "promise");
357
+ const errorMessage = utils.flag(this, "message");
294
358
  if (inlineSnapshot) inlineSnapshot = stripSnapshotIndentation(inlineSnapshot);
295
359
  getSnapshotClient().assert({
296
360
  received: getError(expected, promise),
@@ -301,17 +365,27 @@ var SnapshotPlugin = (chai3, utils) => {
301
365
  errorMessage,
302
366
  ...getTestNames(test2)
303
367
  });
304
- }), utils.addMethod(chai3.expect, "addSnapshotSerializer", addSerializer);
368
+ });
369
+ utils.addMethod(chai3.expect, "addSnapshotSerializer", addSerializer);
305
370
  };
306
- chai.use(JestExtend), chai.use(JestChaiExpect), chai.use(SnapshotPlugin), chai.use(JestAsymmetricMatchers);
371
+ chai.use(JestExtend);
372
+ chai.use(JestChaiExpect);
373
+ chai.use(SnapshotPlugin);
374
+ chai.use(JestAsymmetricMatchers);
307
375
  function createExpect(test2) {
308
376
  const expect = ((value, message) => {
309
377
  const { assertionCalls } = getState(expect);
310
378
  setState({ assertionCalls: assertionCalls + 1 }, expect);
311
- const assert2 = chai.expect(value, message), _test = test2 || getCurrentTest();
312
- return _test ? assert2.withTest(_test) : assert2;
379
+ const assert2 = chai.expect(value, message);
380
+ const _test = test2 || getCurrentTest();
381
+ if (_test)
382
+ return assert2.withTest(_test);
383
+ else return assert2;
313
384
  });
314
- Object.assign(expect, chai.expect), Object.assign(expect, globalThis[ASYMMETRIC_MATCHERS_OBJECT]), expect.getState = () => getState(expect), expect.setState = (state) => setState(state, expect);
385
+ Object.assign(expect, chai.expect);
386
+ Object.assign(expect, globalThis[ASYMMETRIC_MATCHERS_OBJECT]);
387
+ expect.getState = () => getState(expect);
388
+ expect.setState = (state) => setState(state, expect);
315
389
  const globalState = getState(globalThis[GLOBAL_EXPECT]) || {};
316
390
  setState({
317
391
  ...globalState,
@@ -324,9 +398,15 @@ function createExpect(test2) {
324
398
  return getWorkerState().filepath;
325
399
  },
326
400
  currentTestName: test2 ? getTestName(test2) : globalState.currentTestName
327
- }, expect), expect.assert = chai.assert, expect.extend = (matchers) => chai.expect.extend(expect, matchers), expect.addEqualityTesters = (customTesters) => addCustomEqualityTesters(customTesters), expect.soft = (...args) => {
401
+ }, expect);
402
+ expect.assert = chai.assert;
403
+ expect.extend = (matchers) => chai.expect.extend(expect, matchers);
404
+ expect.addEqualityTesters = (customTesters) => addCustomEqualityTesters(customTesters);
405
+ expect.soft = (...args) => {
328
406
  return expect(...args).withContext({ soft: true });
329
- }, expect.poll = createExpectPoll(expect), expect.unreachable = (message) => {
407
+ };
408
+ expect.poll = createExpectPoll(expect);
409
+ expect.unreachable = (message) => {
330
410
  chai.assert.fail(`expected${message ? ` "${message}" ` : " "}not to be reached`);
331
411
  };
332
412
  function assertions(expected) {
@@ -345,7 +425,10 @@ function createExpect(test2) {
345
425
  isExpectingAssertionsError: error
346
426
  });
347
427
  }
348
- return chai.util.addMethod(expect, "assertions", assertions), chai.util.addMethod(expect, "hasAssertions", hasAssertions), expect.extend(customMatchers), expect;
428
+ chai.util.addMethod(expect, "assertions", assertions);
429
+ chai.util.addMethod(expect, "hasAssertions", hasAssertions);
430
+ expect.extend(customMatchers);
431
+ return expect;
349
432
  }
350
433
  var globalExpect = createExpect();
351
434
  Object.defineProperty(globalThis, GLOBAL_EXPECT, {
@@ -2188,7 +2271,11 @@ var FakeTimers = class {
2188
2271
  _userConfig;
2189
2272
  _now = RealDate.now;
2190
2273
  constructor({ global: global3, config }) {
2191
- this._userConfig = config, this._fakingDate = null, this._fakingTime = false, this._fakeTimers = fakeTimersSrcExports.withGlobal(global3), this._global = global3;
2274
+ this._userConfig = config;
2275
+ this._fakingDate = null;
2276
+ this._fakingTime = false;
2277
+ this._fakeTimers = fakeTimersSrcExports.withGlobal(global3);
2278
+ this._global = global3;
2192
2279
  }
2193
2280
  clearAllTimers() {
2194
2281
  if (this._fakingTime) this._clock.reset();
@@ -2209,13 +2296,17 @@ var FakeTimers = class {
2209
2296
  if (this._checkFakeTimers()) await this._clock.runToLastAsync();
2210
2297
  }
2211
2298
  advanceTimersToNextTimer(steps = 1) {
2212
- if (this._checkFakeTimers()) {
2213
- for (let i = steps; i > 0; i--) if (this._clock.next(), this._clock.tick(0), this._clock.countTimers() === 0) break;
2299
+ if (this._checkFakeTimers()) for (let i = steps; i > 0; i--) {
2300
+ this._clock.next();
2301
+ this._clock.tick(0);
2302
+ if (this._clock.countTimers() === 0) break;
2214
2303
  }
2215
2304
  }
2216
2305
  async advanceTimersToNextTimerAsync(steps = 1) {
2217
- if (this._checkFakeTimers()) {
2218
- for (let i = steps; i > 0; i--) if (await this._clock.nextAsync(), this._clock.tick(0), this._clock.countTimers() === 0) break;
2306
+ if (this._checkFakeTimers()) for (let i = steps; i > 0; i--) {
2307
+ await this._clock.nextAsync();
2308
+ this._clock.tick(0);
2309
+ if (this._clock.countTimers() === 0) break;
2219
2310
  }
2220
2311
  }
2221
2312
  advanceTimersByTime(msToRun) {
@@ -2232,12 +2323,21 @@ var FakeTimers = class {
2232
2323
  this._clock.runMicrotasks();
2233
2324
  }
2234
2325
  useRealTimers() {
2235
- if (this._fakingDate) resetDate(), this._fakingDate = null;
2236
- if (this._fakingTime) this._clock.uninstall(), this._fakingTime = false;
2326
+ if (this._fakingDate) {
2327
+ resetDate();
2328
+ this._fakingDate = null;
2329
+ }
2330
+ if (this._fakingTime) {
2331
+ this._clock.uninstall();
2332
+ this._fakingTime = false;
2333
+ }
2237
2334
  }
2238
2335
  useFakeTimers() {
2239
2336
  const fakeDate = this._fakingDate || Date.now();
2240
- if (this._fakingDate) resetDate(), this._fakingDate = null;
2337
+ if (this._fakingDate) {
2338
+ resetDate();
2339
+ this._fakingDate = null;
2340
+ }
2241
2341
  if (this._fakingTime) this._clock.uninstall();
2242
2342
  const toFake = Object.keys(this._fakeTimers.timers).filter((timer) => timer !== "nextTick" && timer !== "queueMicrotask");
2243
2343
  if (this._userConfig?.toFake?.includes("nextTick") && isChildProcess()) throw new Error("process.nextTick cannot be mocked inside child_process");
@@ -2246,18 +2346,23 @@ var FakeTimers = class {
2246
2346
  ...this._userConfig,
2247
2347
  toFake: this._userConfig?.toFake || toFake,
2248
2348
  ignoreMissingTimers: true
2249
- }), this._fakingTime = true;
2349
+ });
2350
+ this._fakingTime = true;
2250
2351
  }
2251
2352
  reset() {
2252
2353
  if (this._checkFakeTimers()) {
2253
2354
  const { now: now2 } = this._clock;
2254
- this._clock.reset(), this._clock.setSystemTime(now2);
2355
+ this._clock.reset();
2356
+ this._clock.setSystemTime(now2);
2255
2357
  }
2256
2358
  }
2257
2359
  setSystemTime(now2) {
2258
2360
  const date = typeof now2 === "undefined" || now2 instanceof Date ? now2 : new Date(now2);
2259
2361
  if (this._fakingTime) this._clock.setSystemTime(date);
2260
- else this._fakingDate = date ?? new Date(this.getRealSystemTime()), mockDate(this._fakingDate);
2362
+ else {
2363
+ this._fakingDate = date ?? new Date(this.getRealSystemTime());
2364
+ mockDate(this._fakingDate);
2365
+ }
2261
2366
  }
2262
2367
  getMockedSystemTime() {
2263
2368
  return this._fakingTime ? new Date(this._clock.now) : this._fakingDate;
@@ -2266,7 +2371,8 @@ var FakeTimers = class {
2266
2371
  return this._now();
2267
2372
  }
2268
2373
  getTimerCount() {
2269
- return this._checkFakeTimers() ? this._clock.countTimers() : 0;
2374
+ if (this._checkFakeTimers()) return this._clock.countTimers();
2375
+ return 0;
2270
2376
  }
2271
2377
  configure(config) {
2272
2378
  this._userConfig = config;
@@ -2284,68 +2390,96 @@ function copyStackTrace(target, source) {
2284
2390
  return target;
2285
2391
  }
2286
2392
  function waitFor(callback, options = {}) {
2287
- const { setTimeout, setInterval, clearTimeout, clearInterval } = getSafeTimers2(), { interval = 50, timeout = 1e3 } = typeof options === "number" ? { timeout: options } : options, STACK_TRACE_ERROR = /* @__PURE__ */ new Error("STACK_TRACE_ERROR");
2393
+ const { setTimeout, setInterval, clearTimeout, clearInterval } = getSafeTimers2();
2394
+ const { interval = 50, timeout = 1e3 } = typeof options === "number" ? { timeout: options } : options;
2395
+ const STACK_TRACE_ERROR = /* @__PURE__ */ new Error("STACK_TRACE_ERROR");
2288
2396
  return new Promise((resolve, reject) => {
2289
- let lastError, promiseStatus = "idle", timeoutId, intervalId;
2397
+ let lastError;
2398
+ let promiseStatus = "idle";
2399
+ let timeoutId;
2400
+ let intervalId;
2290
2401
  const onResolve = (result) => {
2291
2402
  if (timeoutId) clearTimeout(timeoutId);
2292
2403
  if (intervalId) clearInterval(intervalId);
2293
2404
  resolve(result);
2294
- }, handleTimeout = () => {
2405
+ };
2406
+ const handleTimeout = () => {
2295
2407
  if (intervalId) clearInterval(intervalId);
2296
2408
  let error = lastError;
2297
2409
  if (!error) error = copyStackTrace(/* @__PURE__ */ new Error("Timed out in waitFor!"), STACK_TRACE_ERROR);
2298
2410
  reject(error);
2299
- }, checkCallback = () => {
2411
+ };
2412
+ const checkCallback = () => {
2300
2413
  if (vi.isFakeTimers()) vi.advanceTimersByTime(interval);
2301
- if (promiseStatus !== "pending") try {
2414
+ if (promiseStatus === "pending") return;
2415
+ try {
2302
2416
  const result = callback();
2303
2417
  if (result !== null && typeof result === "object" && typeof result.then === "function") {
2304
2418
  const thenable = result;
2305
- promiseStatus = "pending", thenable.then((resolvedValue) => {
2306
- promiseStatus = "resolved", onResolve(resolvedValue);
2419
+ promiseStatus = "pending";
2420
+ thenable.then((resolvedValue) => {
2421
+ promiseStatus = "resolved";
2422
+ onResolve(resolvedValue);
2307
2423
  }, (rejectedValue) => {
2308
- promiseStatus = "rejected", lastError = rejectedValue;
2424
+ promiseStatus = "rejected";
2425
+ lastError = rejectedValue;
2309
2426
  });
2310
- } else return onResolve(result), true;
2427
+ } else {
2428
+ onResolve(result);
2429
+ return true;
2430
+ }
2311
2431
  } catch (error) {
2312
2432
  lastError = error;
2313
2433
  }
2314
2434
  };
2315
- checkCallback() !== true && (timeoutId = setTimeout(handleTimeout, timeout), intervalId = setInterval(checkCallback, interval));
2435
+ if (checkCallback() === true) return;
2436
+ timeoutId = setTimeout(handleTimeout, timeout);
2437
+ intervalId = setInterval(checkCallback, interval);
2316
2438
  });
2317
2439
  }
2318
2440
  function waitUntil(callback, options = {}) {
2319
- const { setTimeout, setInterval, clearTimeout, clearInterval } = getSafeTimers2(), { interval = 50, timeout = 1e3 } = typeof options === "number" ? { timeout: options } : options, STACK_TRACE_ERROR = /* @__PURE__ */ new Error("STACK_TRACE_ERROR");
2441
+ const { setTimeout, setInterval, clearTimeout, clearInterval } = getSafeTimers2();
2442
+ const { interval = 50, timeout = 1e3 } = typeof options === "number" ? { timeout: options } : options;
2443
+ const STACK_TRACE_ERROR = /* @__PURE__ */ new Error("STACK_TRACE_ERROR");
2320
2444
  return new Promise((resolve, reject) => {
2321
- let promiseStatus = "idle", timeoutId, intervalId;
2445
+ let promiseStatus = "idle";
2446
+ let timeoutId;
2447
+ let intervalId;
2322
2448
  const onReject = (error) => {
2323
2449
  if (intervalId) clearInterval(intervalId);
2324
2450
  if (!error) error = copyStackTrace(/* @__PURE__ */ new Error("Timed out in waitUntil!"), STACK_TRACE_ERROR);
2325
2451
  reject(error);
2326
- }, onResolve = (result) => {
2327
- if (result) {
2328
- if (timeoutId) clearTimeout(timeoutId);
2329
- if (intervalId) clearInterval(intervalId);
2330
- return resolve(result), true;
2331
- }
2332
- }, checkCallback = () => {
2452
+ };
2453
+ const onResolve = (result) => {
2454
+ if (!result) return;
2455
+ if (timeoutId) clearTimeout(timeoutId);
2456
+ if (intervalId) clearInterval(intervalId);
2457
+ resolve(result);
2458
+ return true;
2459
+ };
2460
+ const checkCallback = () => {
2333
2461
  if (vi.isFakeTimers()) vi.advanceTimersByTime(interval);
2334
- if (promiseStatus !== "pending") try {
2462
+ if (promiseStatus === "pending") return;
2463
+ try {
2335
2464
  const result = callback();
2336
2465
  if (result !== null && typeof result === "object" && typeof result.then === "function") {
2337
2466
  const thenable = result;
2338
- promiseStatus = "pending", thenable.then((resolvedValue) => {
2339
- promiseStatus = "resolved", onResolve(resolvedValue);
2467
+ promiseStatus = "pending";
2468
+ thenable.then((resolvedValue) => {
2469
+ promiseStatus = "resolved";
2470
+ onResolve(resolvedValue);
2340
2471
  }, (rejectedValue) => {
2341
- promiseStatus = "rejected", onReject(rejectedValue);
2472
+ promiseStatus = "rejected";
2473
+ onReject(rejectedValue);
2342
2474
  });
2343
2475
  } else return onResolve(result);
2344
2476
  } catch (error) {
2345
2477
  onReject(error);
2346
2478
  }
2347
2479
  };
2348
- checkCallback() !== true && (timeoutId = setTimeout(onReject, timeout), intervalId = setInterval(checkCallback, interval));
2480
+ if (checkCallback() === true) return;
2481
+ timeoutId = setTimeout(onReject, timeout);
2482
+ intervalId = setInterval(checkCallback, interval);
2349
2483
  });
2350
2484
  }
2351
2485
  function createVitest() {
@@ -2355,11 +2489,15 @@ function createVitest() {
2355
2489
  const timers = () => _timers ||= new FakeTimers({
2356
2490
  global: globalThis,
2357
2491
  config: state().config.fakeTimers
2358
- }), _stubsGlobal = /* @__PURE__ */ new Map(), _stubsEnv = /* @__PURE__ */ new Map(), _envBooleans = [
2492
+ });
2493
+ const _stubsGlobal = /* @__PURE__ */ new Map();
2494
+ const _stubsEnv = /* @__PURE__ */ new Map();
2495
+ const _envBooleans = [
2359
2496
  "PROD",
2360
2497
  "DEV",
2361
2498
  "SSR"
2362
- ], utils = {
2499
+ ];
2500
+ const utils = {
2363
2501
  useFakeTimers(config) {
2364
2502
  if (isChildProcess()) {
2365
2503
  if (config?.toFake?.includes("nextTick") || state().config?.fakeTimers?.toFake?.includes("nextTick")) throw new Error('vi.useFakeTimers({ toFake: ["nextTick"] }) is not supported in node:child_process. Use --pool=threads if mocking nextTick is required.');
@@ -2369,49 +2507,62 @@ function createVitest() {
2369
2507
  ...config
2370
2508
  });
2371
2509
  else timers().configure(state().config.fakeTimers);
2372
- return timers().useFakeTimers(), utils;
2510
+ timers().useFakeTimers();
2511
+ return utils;
2373
2512
  },
2374
2513
  isFakeTimers() {
2375
2514
  return timers().isFakeTimers();
2376
2515
  },
2377
2516
  useRealTimers() {
2378
- return timers().useRealTimers(), utils;
2517
+ timers().useRealTimers();
2518
+ return utils;
2379
2519
  },
2380
2520
  runOnlyPendingTimers() {
2381
- return timers().runOnlyPendingTimers(), utils;
2521
+ timers().runOnlyPendingTimers();
2522
+ return utils;
2382
2523
  },
2383
2524
  async runOnlyPendingTimersAsync() {
2384
- return await timers().runOnlyPendingTimersAsync(), utils;
2525
+ await timers().runOnlyPendingTimersAsync();
2526
+ return utils;
2385
2527
  },
2386
2528
  runAllTimers() {
2387
- return timers().runAllTimers(), utils;
2529
+ timers().runAllTimers();
2530
+ return utils;
2388
2531
  },
2389
2532
  async runAllTimersAsync() {
2390
- return await timers().runAllTimersAsync(), utils;
2533
+ await timers().runAllTimersAsync();
2534
+ return utils;
2391
2535
  },
2392
2536
  runAllTicks() {
2393
- return timers().runAllTicks(), utils;
2537
+ timers().runAllTicks();
2538
+ return utils;
2394
2539
  },
2395
2540
  advanceTimersByTime(ms) {
2396
- return timers().advanceTimersByTime(ms), utils;
2541
+ timers().advanceTimersByTime(ms);
2542
+ return utils;
2397
2543
  },
2398
2544
  async advanceTimersByTimeAsync(ms) {
2399
- return await timers().advanceTimersByTimeAsync(ms), utils;
2545
+ await timers().advanceTimersByTimeAsync(ms);
2546
+ return utils;
2400
2547
  },
2401
2548
  advanceTimersToNextTimer() {
2402
- return timers().advanceTimersToNextTimer(), utils;
2549
+ timers().advanceTimersToNextTimer();
2550
+ return utils;
2403
2551
  },
2404
2552
  async advanceTimersToNextTimerAsync() {
2405
- return await timers().advanceTimersToNextTimerAsync(), utils;
2553
+ await timers().advanceTimersToNextTimerAsync();
2554
+ return utils;
2406
2555
  },
2407
2556
  advanceTimersToNextFrame() {
2408
- return timers().advanceTimersToNextFrame(), utils;
2557
+ timers().advanceTimersToNextFrame();
2558
+ return utils;
2409
2559
  },
2410
2560
  getTimerCount() {
2411
2561
  return timers().getTimerCount();
2412
2562
  },
2413
2563
  setSystemTime(time) {
2414
- return timers().setSystemTime(time), utils;
2564
+ timers().setSystemTime(time);
2565
+ return utils;
2415
2566
  },
2416
2567
  getMockedSystemTime() {
2417
2568
  return timers().getMockedSystemTime();
@@ -2420,14 +2571,16 @@ function createVitest() {
2420
2571
  return timers().getRealSystemTime();
2421
2572
  },
2422
2573
  clearAllTimers() {
2423
- return timers().clearAllTimers(), utils;
2574
+ timers().clearAllTimers();
2575
+ return utils;
2424
2576
  },
2425
2577
  spyOn,
2426
2578
  fn,
2427
2579
  waitFor,
2428
2580
  waitUntil,
2429
2581
  hoisted(factory) {
2430
- return assertTypes(factory, '"vi.hoisted" factory', ["function"]), factory();
2582
+ assertTypes(factory, '"vi.hoisted" factory', ["function"]);
2583
+ return factory();
2431
2584
  },
2432
2585
  mock(path, factory) {
2433
2586
  if (typeof path !== "string") throw new TypeError(`vi.mock() expects a string path, but received a ${typeof path}`);
@@ -2466,22 +2619,26 @@ function createVitest() {
2466
2619
  return isMockFunction(fn2);
2467
2620
  },
2468
2621
  clearAllMocks() {
2469
- return clearAllMocks(), utils;
2622
+ clearAllMocks();
2623
+ return utils;
2470
2624
  },
2471
2625
  resetAllMocks() {
2472
- return resetAllMocks(), utils;
2626
+ resetAllMocks();
2627
+ return utils;
2473
2628
  },
2474
2629
  restoreAllMocks() {
2475
- return restoreAllMocks(), utils;
2630
+ restoreAllMocks();
2631
+ return utils;
2476
2632
  },
2477
2633
  stubGlobal(name, value) {
2478
2634
  if (!_stubsGlobal.has(name)) _stubsGlobal.set(name, Object.getOwnPropertyDescriptor(globalThis, name));
2479
- return Object.defineProperty(globalThis, name, {
2635
+ Object.defineProperty(globalThis, name, {
2480
2636
  value,
2481
2637
  writable: true,
2482
2638
  configurable: true,
2483
2639
  enumerable: true
2484
- }), utils;
2640
+ });
2641
+ return utils;
2485
2642
  },
2486
2643
  stubEnv(name, value) {
2487
2644
  const env = state().metaEnv;
@@ -2492,20 +2649,25 @@ function createVitest() {
2492
2649
  return utils;
2493
2650
  },
2494
2651
  unstubAllGlobals() {
2495
- return _stubsGlobal.forEach((original, name) => {
2652
+ _stubsGlobal.forEach((original, name) => {
2496
2653
  if (!original) Reflect.deleteProperty(globalThis, name);
2497
2654
  else Object.defineProperty(globalThis, name, original);
2498
- }), _stubsGlobal.clear(), utils;
2655
+ });
2656
+ _stubsGlobal.clear();
2657
+ return utils;
2499
2658
  },
2500
2659
  unstubAllEnvs() {
2501
2660
  const env = state().metaEnv;
2502
- return _stubsEnv.forEach((original, name) => {
2661
+ _stubsEnv.forEach((original, name) => {
2503
2662
  if (original === void 0) delete env[name];
2504
2663
  else env[name] = original;
2505
- }), _stubsEnv.clear(), utils;
2664
+ });
2665
+ _stubsEnv.clear();
2666
+ return utils;
2506
2667
  },
2507
2668
  resetModules() {
2508
- return resetModules(state().evaluatedModules), utils;
2669
+ resetModules(state().evaluatedModules);
2670
+ return utils;
2509
2671
  },
2510
2672
  async dynamicImportSettled() {
2511
2673
  return waitForImportsToResolve();
@@ -2528,13 +2690,13 @@ function _mocker() {
2528
2690
  } });
2529
2691
  }
2530
2692
  function getImporter(name) {
2531
- const stackArray = createSimpleStackTrace({ stackTraceLimit: 5 }).split("\n"), importerStackIndex = stackArray.findLastIndex((stack) => {
2693
+ const stackArray = createSimpleStackTrace({ stackTraceLimit: 5 }).split("\n");
2694
+ return parseSingleStack(stackArray[stackArray.findLastIndex((stack) => {
2532
2695
  return stack.includes(` at Object.${name}`) || stack.includes(`${name}@`);
2533
- });
2534
- return parseSingleStack(stackArray[importerStackIndex + 1])?.file || "";
2696
+ }) + 1])?.file || "";
2535
2697
  }
2536
2698
 
2537
- // ../../node_modules/.pnpm/vitest@4.0.6_@types+debug@4.1.12_@types+node@24.10.0_@vitest+ui@4.0.6_jiti@2.6.1_jsdom@_38fcb34f3d4da47a9b9d4b13a6949560/node_modules/vitest/dist/index.js
2699
+ // ../../node_modules/.pnpm/vitest@4.0.8_@types+debug@4.1.12_@types+node@24.10.1_@vitest+ui@4.0.8_jiti@2.6.1_jsdom@_c97fdea49f1663602bf3dfb16acdd85d/node_modules/vitest/dist/index.js
2538
2700
  import { expectTypeOf } from "expect-type.js";
2539
2701
  import { afterAll, afterEach, beforeAll, beforeEach, describe, it, onTestFailed, onTestFinished, suite, test } from "@vitest/runner.js";
2540
2702
  import { chai as chai2 } from "@vitest/expect.js";