@assistant-ui/react 0.10.20 → 0.10.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/primitives/composer/ComposerInput.js +1 -1
- package/dist/primitives/composer/ComposerInput.js.map +1 -1
- package/dist/runtimes/adapters/RuntimeAdapterProvider.d.ts.map +1 -1
- package/dist/runtimes/adapters/RuntimeAdapterProvider.js +2 -0
- package/dist/runtimes/adapters/RuntimeAdapterProvider.js.map +1 -1
- package/dist/tests/setup.js +130 -283
- package/dist/tests/setup.js.map +1 -1
- package/package.json +5 -5
- package/src/primitives/composer/ComposerInput.tsx +1 -1
- package/src/runtimes/adapters/RuntimeAdapterProvider.tsx +2 -0
package/dist/tests/setup.js
CHANGED
@@ -1,10 +1,10 @@
|
|
1
|
-
// ../../node_modules/.pnpm/vitest@3.
|
1
|
+
// ../../node_modules/.pnpm/vitest@3.2.0_@types+debug@4.1.12_@types+node@22.15.29_jiti@2.4.2_jsdom@26.1.0_lightningcss@1.30.1_tsx@4.19.4/node_modules/vitest/dist/chunks/vi.bdSIJ99Y.js
|
2
2
|
import { 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
|
import * as chai$1 from "chai.js";
|
6
6
|
|
7
|
-
// ../../node_modules/.pnpm/vitest@3.
|
7
|
+
// ../../node_modules/.pnpm/vitest@3.2.0_@types+debug@4.1.12_@types+node@22.15.29_jiti@2.4.2_jsdom@26.1.0_lightningcss@1.30.1_tsx@4.19.4/node_modules/vitest/dist/chunks/utils.XdZDrNZV.js
|
8
8
|
import { getSafeTimers } from "@vitest/utils.js";
|
9
9
|
var NAME_WORKER_STATE = "__vitest_worker__";
|
10
10
|
function getWorkerState() {
|
@@ -31,9 +31,7 @@ function resetModules(modules, resetMocks = false) {
|
|
31
31
|
...!resetMocks ? [/^mock:/] : []
|
32
32
|
];
|
33
33
|
modules.forEach((mod, path) => {
|
34
|
-
if (skipPaths.some((re) => re.test(path)))
|
35
|
-
return;
|
36
|
-
}
|
34
|
+
if (skipPaths.some((re) => re.test(path))) return;
|
37
35
|
modules.invalidateModule(mod);
|
38
36
|
});
|
39
37
|
}
|
@@ -47,36 +45,30 @@ async function waitForImportsToResolve() {
|
|
47
45
|
const promises = [];
|
48
46
|
let resolvingCount = 0;
|
49
47
|
for (const mod of state.moduleCache.values()) {
|
50
|
-
if (mod.promise && !mod.evaluated)
|
51
|
-
|
52
|
-
}
|
53
|
-
if (mod.resolving) {
|
54
|
-
resolvingCount++;
|
55
|
-
}
|
56
|
-
}
|
57
|
-
if (!promises.length && !resolvingCount) {
|
58
|
-
return;
|
48
|
+
if (mod.promise && !mod.evaluated) promises.push(mod.promise);
|
49
|
+
if (mod.resolving) resolvingCount++;
|
59
50
|
}
|
51
|
+
if (!promises.length && !resolvingCount) return;
|
60
52
|
await Promise.allSettled(promises);
|
61
53
|
await waitForImportsToResolve();
|
62
54
|
}
|
63
55
|
|
64
|
-
// ../../node_modules/.pnpm/vitest@3.
|
56
|
+
// ../../node_modules/.pnpm/vitest@3.2.0_@types+debug@4.1.12_@types+node@22.15.29_jiti@2.4.2_jsdom@26.1.0_lightningcss@1.30.1_tsx@4.19.4/node_modules/vitest/dist/chunks/vi.bdSIJ99Y.js
|
65
57
|
import { getSafeTimers as getSafeTimers2, assertTypes, createSimpleStackTrace } from "@vitest/utils.js";
|
66
58
|
|
67
|
-
// ../../node_modules/.pnpm/vitest@3.
|
59
|
+
// ../../node_modules/.pnpm/vitest@3.2.0_@types+debug@4.1.12_@types+node@22.15.29_jiti@2.4.2_jsdom@26.1.0_lightningcss@1.30.1_tsx@4.19.4/node_modules/vitest/dist/chunks/_commonjsHelpers.BFTU3MAI.js
|
68
60
|
var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
|
69
61
|
function getDefaultExportFromCjs(x) {
|
70
62
|
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
|
71
63
|
}
|
72
64
|
|
73
|
-
// ../../node_modules/.pnpm/vitest@3.
|
65
|
+
// ../../node_modules/.pnpm/vitest@3.2.0_@types+debug@4.1.12_@types+node@22.15.29_jiti@2.4.2_jsdom@26.1.0_lightningcss@1.30.1_tsx@4.19.4/node_modules/vitest/dist/chunks/vi.bdSIJ99Y.js
|
74
66
|
import { stripSnapshotIndentation, addSerializer, SnapshotClient } from "@vitest/snapshot.js";
|
75
67
|
import "@vitest/utils/error.js";
|
76
68
|
import { fn, spyOn, mocks, isMockFunction } from "@vitest/spy.js";
|
77
69
|
import { parseSingleStack } from "@vitest/utils/source-map.js";
|
78
70
|
|
79
|
-
// ../../node_modules/.pnpm/vitest@3.
|
71
|
+
// ../../node_modules/.pnpm/vitest@3.2.0_@types+debug@4.1.12_@types+node@22.15.29_jiti@2.4.2_jsdom@26.1.0_lightningcss@1.30.1_tsx@4.19.4/node_modules/vitest/dist/chunks/date.Bq6ZW5rf.js
|
80
72
|
var RealDate = Date;
|
81
73
|
var now = null;
|
82
74
|
var MockDate = class _MockDate extends RealDate {
|
@@ -85,11 +77,8 @@ var MockDate = class _MockDate extends RealDate {
|
|
85
77
|
let date;
|
86
78
|
switch (arguments.length) {
|
87
79
|
case 0:
|
88
|
-
if (now !== null)
|
89
|
-
|
90
|
-
} else {
|
91
|
-
date = new RealDate();
|
92
|
-
}
|
80
|
+
if (now !== null) date = new RealDate(now.valueOf());
|
81
|
+
else date = new RealDate();
|
93
82
|
break;
|
94
83
|
case 1:
|
95
84
|
date = new RealDate(y);
|
@@ -119,9 +108,7 @@ MockDate.toString = function() {
|
|
119
108
|
};
|
120
109
|
function mockDate(date) {
|
121
110
|
const dateObj = new RealDate(date.valueOf());
|
122
|
-
if (Number.isNaN(dateObj.getTime())) {
|
123
|
-
throw new TypeError(`mockdate: The time set is an invalid date: ${date}`);
|
124
|
-
}
|
111
|
+
if (Number.isNaN(dateObj.getTime())) throw new TypeError(`mockdate: The time set is an invalid date: ${date}`);
|
125
112
|
globalThis.Date = MockDate;
|
126
113
|
now = dateObj.valueOf();
|
127
114
|
}
|
@@ -129,7 +116,7 @@ function resetDate() {
|
|
129
116
|
globalThis.Date = RealDate;
|
130
117
|
}
|
131
118
|
|
132
|
-
// ../../node_modules/.pnpm/vitest@3.
|
119
|
+
// ../../node_modules/.pnpm/vitest@3.2.0_@types+debug@4.1.12_@types+node@22.15.29_jiti@2.4.2_jsdom@26.1.0_lightningcss@1.30.1_tsx@4.19.4/node_modules/vitest/dist/chunks/vi.bdSIJ99Y.js
|
133
120
|
var unsupported = [
|
134
121
|
"matchSnapshot",
|
135
122
|
"toMatchSnapshot",
|
@@ -150,20 +137,12 @@ function createExpectPoll(expect2) {
|
|
150
137
|
const assertion = expect2(null, message).withContext({ poll: true });
|
151
138
|
fn2 = fn2.bind(assertion);
|
152
139
|
const test2 = chai$1.util.flag(assertion, "vitest-test");
|
153
|
-
if (!test2)
|
154
|
-
throw new Error("expect.poll() must be called inside a test");
|
155
|
-
}
|
140
|
+
if (!test2) throw new Error("expect.poll() must be called inside a test");
|
156
141
|
const proxy = new Proxy(assertion, { get(target, key, receiver) {
|
157
142
|
const assertionFunction = Reflect.get(target, key, receiver);
|
158
|
-
if (typeof assertionFunction !== "function")
|
159
|
-
|
160
|
-
}
|
161
|
-
if (key === "assert") {
|
162
|
-
return assertionFunction;
|
163
|
-
}
|
164
|
-
if (typeof key === "string" && unsupported.includes(key)) {
|
165
|
-
throw new SyntaxError(`expect.poll() is not supported in combination with .${key}(). Use vi.waitFor() if your assertion condition is unstable.`);
|
166
|
-
}
|
143
|
+
if (typeof assertionFunction !== "function") return assertionFunction instanceof chai$1.Assertion ? proxy : assertionFunction;
|
144
|
+
if (key === "assert") return assertionFunction;
|
145
|
+
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.`);
|
167
146
|
return function(...args) {
|
168
147
|
const STACK_TRACE_ERROR = new Error("STACK_TRACE_ERROR");
|
169
148
|
const promise = () => new Promise((resolve, reject) => {
|
@@ -181,9 +160,7 @@ function createExpectPoll(expect2) {
|
|
181
160
|
clearTimeout(timeoutId);
|
182
161
|
} catch (err) {
|
183
162
|
lastError = err;
|
184
|
-
if (!chai$1.util.flag(assertion, "_isLastPollAttempt"))
|
185
|
-
intervalId = setTimeout(check, interval);
|
186
|
-
}
|
163
|
+
if (!chai$1.util.flag(assertion, "_isLastPollAttempt")) intervalId = setTimeout(check, interval);
|
187
164
|
}
|
188
165
|
};
|
189
166
|
timeoutId = setTimeout(() => {
|
@@ -230,9 +207,7 @@ await ${assertionString}
|
|
230
207
|
};
|
231
208
|
}
|
232
209
|
function copyStackTrace$1(target, source) {
|
233
|
-
if (source.stack !== void 0)
|
234
|
-
target.stack = source.stack.replace(source.message, target.message);
|
235
|
-
}
|
210
|
+
if (source.stack !== void 0) target.stack = source.stack.replace(source.message, target.message);
|
236
211
|
return target;
|
237
212
|
}
|
238
213
|
function commonjsRequire(path) {
|
@@ -332,17 +307,11 @@ function recordAsyncExpect(_test, promise, assertion, error) {
|
|
332
307
|
const test2 = _test;
|
333
308
|
if (test2 && promise instanceof Promise) {
|
334
309
|
promise = promise.finally(() => {
|
335
|
-
if (!test2.promises)
|
336
|
-
return;
|
337
|
-
}
|
310
|
+
if (!test2.promises) return;
|
338
311
|
const index = test2.promises.indexOf(promise);
|
339
|
-
if (index !== -1)
|
340
|
-
test2.promises.splice(index, 1);
|
341
|
-
}
|
312
|
+
if (index !== -1) test2.promises.splice(index, 1);
|
342
313
|
});
|
343
|
-
if (!test2.promises)
|
344
|
-
test2.promises = [];
|
345
|
-
}
|
314
|
+
if (!test2.promises) test2.promises = [];
|
346
315
|
test2.promises.push(promise);
|
347
316
|
let resolved = false;
|
348
317
|
test2.onFinished ??= [];
|
@@ -376,18 +345,14 @@ function recordAsyncExpect(_test, promise, assertion, error) {
|
|
376
345
|
}
|
377
346
|
var _client;
|
378
347
|
function getSnapshotClient() {
|
379
|
-
if (!_client) {
|
380
|
-
|
381
|
-
|
382
|
-
} });
|
383
|
-
}
|
348
|
+
if (!_client) _client = new SnapshotClient({ isEqual: (received, expected) => {
|
349
|
+
return equals(received, expected, [iterableEquality, subsetEquality]);
|
350
|
+
} });
|
384
351
|
return _client;
|
385
352
|
}
|
386
353
|
function getError(expected, promise) {
|
387
354
|
if (typeof expected !== "function") {
|
388
|
-
if (!promise) {
|
389
|
-
throw new Error(`expected must be a function, received ${typeof expected}`);
|
390
|
-
}
|
355
|
+
if (!promise) throw new Error(`expected must be a function, received ${typeof expected}`);
|
391
356
|
return expected;
|
392
357
|
}
|
393
358
|
try {
|
@@ -407,41 +372,33 @@ function getTestNames(test2) {
|
|
407
372
|
var SnapshotPlugin = (chai3, utils) => {
|
408
373
|
function getTest(assertionName, obj) {
|
409
374
|
const test2 = utils.flag(obj, "vitest-test");
|
410
|
-
if (!test2) {
|
411
|
-
throw new Error(`'${assertionName}' cannot be used without test context`);
|
412
|
-
}
|
375
|
+
if (!test2) throw new Error(`'${assertionName}' cannot be used without test context`);
|
413
376
|
return test2;
|
414
377
|
}
|
415
|
-
for (const key of ["matchSnapshot", "toMatchSnapshot"]) {
|
416
|
-
utils.
|
417
|
-
|
418
|
-
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
|
425
|
-
|
426
|
-
|
427
|
-
|
428
|
-
|
429
|
-
|
430
|
-
|
431
|
-
|
432
|
-
|
433
|
-
properties,
|
434
|
-
errorMessage,
|
435
|
-
...getTestNames(test2)
|
436
|
-
});
|
378
|
+
for (const key of ["matchSnapshot", "toMatchSnapshot"]) utils.addMethod(chai3.Assertion.prototype, key, function(properties, message) {
|
379
|
+
utils.flag(this, "_name", key);
|
380
|
+
const isNot = utils.flag(this, "negate");
|
381
|
+
if (isNot) throw new Error(`${key} cannot be used with "not"`);
|
382
|
+
const expected = utils.flag(this, "object");
|
383
|
+
const test2 = getTest(key, this);
|
384
|
+
if (typeof properties === "string" && typeof message === "undefined") {
|
385
|
+
message = properties;
|
386
|
+
properties = void 0;
|
387
|
+
}
|
388
|
+
const errorMessage = utils.flag(this, "message");
|
389
|
+
getSnapshotClient().assert({
|
390
|
+
received: expected,
|
391
|
+
message,
|
392
|
+
isInline: false,
|
393
|
+
properties,
|
394
|
+
errorMessage,
|
395
|
+
...getTestNames(test2)
|
437
396
|
});
|
438
|
-
}
|
397
|
+
});
|
439
398
|
utils.addMethod(chai3.Assertion.prototype, "toMatchFileSnapshot", function(file, message) {
|
440
399
|
utils.flag(this, "_name", "toMatchFileSnapshot");
|
441
400
|
const isNot = utils.flag(this, "negate");
|
442
|
-
if (isNot)
|
443
|
-
throw new Error('toMatchFileSnapshot cannot be used with "not"');
|
444
|
-
}
|
401
|
+
if (isNot) throw new Error('toMatchFileSnapshot cannot be used with "not"');
|
445
402
|
const error = new Error("resolves");
|
446
403
|
const expected = utils.flag(this, "object");
|
447
404
|
const test2 = getTest("toMatchFileSnapshot", this);
|
@@ -459,14 +416,10 @@ var SnapshotPlugin = (chai3, utils) => {
|
|
459
416
|
utils.addMethod(chai3.Assertion.prototype, "toMatchInlineSnapshot", function __INLINE_SNAPSHOT__(properties, inlineSnapshot, message) {
|
460
417
|
utils.flag(this, "_name", "toMatchInlineSnapshot");
|
461
418
|
const isNot = utils.flag(this, "negate");
|
462
|
-
if (isNot)
|
463
|
-
throw new Error('toMatchInlineSnapshot cannot be used with "not"');
|
464
|
-
}
|
419
|
+
if (isNot) throw new Error('toMatchInlineSnapshot cannot be used with "not"');
|
465
420
|
const test2 = getTest("toMatchInlineSnapshot", this);
|
466
421
|
const isInsideEach = test2.each || test2.suite?.each;
|
467
|
-
if (isInsideEach)
|
468
|
-
throw new Error("InlineSnapshot cannot be used inside of test.each or describe.each");
|
469
|
-
}
|
422
|
+
if (isInsideEach) throw new Error("InlineSnapshot cannot be used inside of test.each or describe.each");
|
470
423
|
const expected = utils.flag(this, "object");
|
471
424
|
const error = utils.flag(this, "error");
|
472
425
|
if (typeof properties === "string") {
|
@@ -474,9 +427,7 @@ var SnapshotPlugin = (chai3, utils) => {
|
|
474
427
|
inlineSnapshot = properties;
|
475
428
|
properties = void 0;
|
476
429
|
}
|
477
|
-
if (inlineSnapshot)
|
478
|
-
inlineSnapshot = stripSnapshotIndentation(inlineSnapshot);
|
479
|
-
}
|
430
|
+
if (inlineSnapshot) inlineSnapshot = stripSnapshotIndentation(inlineSnapshot);
|
480
431
|
const errorMessage = utils.flag(this, "message");
|
481
432
|
getSnapshotClient().assert({
|
482
433
|
received: expected,
|
@@ -492,9 +443,7 @@ var SnapshotPlugin = (chai3, utils) => {
|
|
492
443
|
utils.addMethod(chai3.Assertion.prototype, "toThrowErrorMatchingSnapshot", function(message) {
|
493
444
|
utils.flag(this, "_name", "toThrowErrorMatchingSnapshot");
|
494
445
|
const isNot = utils.flag(this, "negate");
|
495
|
-
if (isNot)
|
496
|
-
throw new Error('toThrowErrorMatchingSnapshot cannot be used with "not"');
|
497
|
-
}
|
446
|
+
if (isNot) throw new Error('toThrowErrorMatchingSnapshot cannot be used with "not"');
|
498
447
|
const expected = utils.flag(this, "object");
|
499
448
|
const test2 = getTest("toThrowErrorMatchingSnapshot", this);
|
500
449
|
const promise = utils.flag(this, "promise");
|
@@ -508,21 +457,15 @@ var SnapshotPlugin = (chai3, utils) => {
|
|
508
457
|
});
|
509
458
|
utils.addMethod(chai3.Assertion.prototype, "toThrowErrorMatchingInlineSnapshot", function __INLINE_SNAPSHOT__(inlineSnapshot, message) {
|
510
459
|
const isNot = utils.flag(this, "negate");
|
511
|
-
if (isNot)
|
512
|
-
throw new Error('toThrowErrorMatchingInlineSnapshot cannot be used with "not"');
|
513
|
-
}
|
460
|
+
if (isNot) throw new Error('toThrowErrorMatchingInlineSnapshot cannot be used with "not"');
|
514
461
|
const test2 = getTest("toThrowErrorMatchingInlineSnapshot", this);
|
515
462
|
const isInsideEach = test2.each || test2.suite?.each;
|
516
|
-
if (isInsideEach)
|
517
|
-
throw new Error("InlineSnapshot cannot be used inside of test.each or describe.each");
|
518
|
-
}
|
463
|
+
if (isInsideEach) throw new Error("InlineSnapshot cannot be used inside of test.each or describe.each");
|
519
464
|
const expected = utils.flag(this, "object");
|
520
465
|
const error = utils.flag(this, "error");
|
521
466
|
const promise = utils.flag(this, "promise");
|
522
467
|
const errorMessage = utils.flag(this, "message");
|
523
|
-
if (inlineSnapshot)
|
524
|
-
inlineSnapshot = stripSnapshotIndentation(inlineSnapshot);
|
525
|
-
}
|
468
|
+
if (inlineSnapshot) inlineSnapshot = stripSnapshotIndentation(inlineSnapshot);
|
526
469
|
getSnapshotClient().assert({
|
527
470
|
received: getError(expected, promise),
|
528
471
|
message,
|
@@ -546,11 +489,9 @@ function createExpect(test2) {
|
|
546
489
|
setState({ assertionCalls: assertionCalls + 1 }, expect2);
|
547
490
|
const assert3 = chai$1.expect(value, message);
|
548
491
|
const _test = test2 || getCurrentTest();
|
549
|
-
if (_test)
|
492
|
+
if (_test)
|
550
493
|
return assert3.withTest(_test);
|
551
|
-
|
552
|
-
return assert3;
|
553
|
-
}
|
494
|
+
else return assert3;
|
554
495
|
};
|
555
496
|
Object.assign(expect2, chai$1.expect);
|
556
497
|
Object.assign(expect2, globalThis[ASYMMETRIC_MATCHERS_OBJECT]);
|
@@ -581,9 +522,7 @@ function createExpect(test2) {
|
|
581
522
|
};
|
582
523
|
function assertions(expected) {
|
583
524
|
const errorGen = () => new Error(`expected number of assertions to be ${expected}, but got ${expect2.getState().assertionCalls}`);
|
584
|
-
if (Error.captureStackTrace)
|
585
|
-
Error.captureStackTrace(errorGen(), assertions);
|
586
|
-
}
|
525
|
+
if (Error.captureStackTrace) Error.captureStackTrace(errorGen(), assertions);
|
587
526
|
expect2.setState({
|
588
527
|
expectedAssertionsNumber: expected,
|
589
528
|
expectedAssertionsNumberErrorGen: errorGen
|
@@ -591,9 +530,7 @@ function createExpect(test2) {
|
|
591
530
|
}
|
592
531
|
function hasAssertions() {
|
593
532
|
const error = new Error("expected any number of assertion, but got none");
|
594
|
-
if (Error.captureStackTrace)
|
595
|
-
Error.captureStackTrace(error, hasAssertions);
|
596
|
-
}
|
533
|
+
if (Error.captureStackTrace) Error.captureStackTrace(error, hasAssertions);
|
597
534
|
expect2.setState({
|
598
535
|
isExpectingAssertions: true,
|
599
536
|
isExpectingAssertionsError: error
|
@@ -2431,6 +2368,12 @@ var fakeTimersSrcExports = requireFakeTimersSrc();
|
|
2431
2368
|
var FakeTimers = class {
|
2432
2369
|
_global;
|
2433
2370
|
_clock;
|
2371
|
+
// | _fakingTime | _fakingDate |
|
2372
|
+
// +-------------+-------------+
|
2373
|
+
// | false | falsy | initial
|
2374
|
+
// | false | truthy | vi.setSystemTime called first (for mocking only Date without fake timers)
|
2375
|
+
// | true | falsy | vi.useFakeTimers called first
|
2376
|
+
// | true | truthy | unreachable
|
2434
2377
|
_fakingTime;
|
2435
2378
|
_fakingDate;
|
2436
2379
|
_fakeTimers;
|
@@ -2444,74 +2387,49 @@ var FakeTimers = class {
|
|
2444
2387
|
this._global = global3;
|
2445
2388
|
}
|
2446
2389
|
clearAllTimers() {
|
2447
|
-
if (this._fakingTime)
|
2448
|
-
this._clock.reset();
|
2449
|
-
}
|
2390
|
+
if (this._fakingTime) this._clock.reset();
|
2450
2391
|
}
|
2451
2392
|
dispose() {
|
2452
2393
|
this.useRealTimers();
|
2453
2394
|
}
|
2454
2395
|
runAllTimers() {
|
2455
|
-
if (this._checkFakeTimers())
|
2456
|
-
this._clock.runAll();
|
2457
|
-
}
|
2396
|
+
if (this._checkFakeTimers()) this._clock.runAll();
|
2458
2397
|
}
|
2459
2398
|
async runAllTimersAsync() {
|
2460
|
-
if (this._checkFakeTimers())
|
2461
|
-
await this._clock.runAllAsync();
|
2462
|
-
}
|
2399
|
+
if (this._checkFakeTimers()) await this._clock.runAllAsync();
|
2463
2400
|
}
|
2464
2401
|
runOnlyPendingTimers() {
|
2465
|
-
if (this._checkFakeTimers())
|
2466
|
-
this._clock.runToLast();
|
2467
|
-
}
|
2402
|
+
if (this._checkFakeTimers()) this._clock.runToLast();
|
2468
2403
|
}
|
2469
2404
|
async runOnlyPendingTimersAsync() {
|
2470
|
-
if (this._checkFakeTimers())
|
2471
|
-
await this._clock.runToLastAsync();
|
2472
|
-
}
|
2405
|
+
if (this._checkFakeTimers()) await this._clock.runToLastAsync();
|
2473
2406
|
}
|
2474
2407
|
advanceTimersToNextTimer(steps = 1) {
|
2475
|
-
if (this._checkFakeTimers()) {
|
2476
|
-
|
2477
|
-
|
2478
|
-
|
2479
|
-
if (this._clock.countTimers() === 0) {
|
2480
|
-
break;
|
2481
|
-
}
|
2482
|
-
}
|
2408
|
+
if (this._checkFakeTimers()) for (let i = steps; i > 0; i--) {
|
2409
|
+
this._clock.next();
|
2410
|
+
this._clock.tick(0);
|
2411
|
+
if (this._clock.countTimers() === 0) break;
|
2483
2412
|
}
|
2484
2413
|
}
|
2485
2414
|
async advanceTimersToNextTimerAsync(steps = 1) {
|
2486
|
-
if (this._checkFakeTimers()) {
|
2487
|
-
|
2488
|
-
|
2489
|
-
|
2490
|
-
if (this._clock.countTimers() === 0) {
|
2491
|
-
break;
|
2492
|
-
}
|
2493
|
-
}
|
2415
|
+
if (this._checkFakeTimers()) for (let i = steps; i > 0; i--) {
|
2416
|
+
await this._clock.nextAsync();
|
2417
|
+
this._clock.tick(0);
|
2418
|
+
if (this._clock.countTimers() === 0) break;
|
2494
2419
|
}
|
2495
2420
|
}
|
2496
2421
|
advanceTimersByTime(msToRun) {
|
2497
|
-
if (this._checkFakeTimers())
|
2498
|
-
this._clock.tick(msToRun);
|
2499
|
-
}
|
2422
|
+
if (this._checkFakeTimers()) this._clock.tick(msToRun);
|
2500
2423
|
}
|
2501
2424
|
async advanceTimersByTimeAsync(msToRun) {
|
2502
|
-
if (this._checkFakeTimers())
|
2503
|
-
await this._clock.tickAsync(msToRun);
|
2504
|
-
}
|
2425
|
+
if (this._checkFakeTimers()) await this._clock.tickAsync(msToRun);
|
2505
2426
|
}
|
2506
2427
|
advanceTimersToNextFrame() {
|
2507
|
-
if (this._checkFakeTimers())
|
2508
|
-
this._clock.runToFrame();
|
2509
|
-
}
|
2428
|
+
if (this._checkFakeTimers()) this._clock.runToFrame();
|
2510
2429
|
}
|
2511
2430
|
runAllTicks() {
|
2512
|
-
if (this._checkFakeTimers())
|
2431
|
+
if (this._checkFakeTimers())
|
2513
2432
|
this._clock.runMicrotasks();
|
2514
|
-
}
|
2515
2433
|
}
|
2516
2434
|
useRealTimers() {
|
2517
2435
|
if (this._fakingDate) {
|
@@ -2524,14 +2442,10 @@ var FakeTimers = class {
|
|
2524
2442
|
}
|
2525
2443
|
}
|
2526
2444
|
useFakeTimers() {
|
2527
|
-
if (this._fakingDate)
|
2528
|
-
throw new Error('"setSystemTime" was called already and date was mocked. Reset timers using `vi.useRealTimers()` if you want to use fake timers again.');
|
2529
|
-
}
|
2445
|
+
if (this._fakingDate) throw new Error('"setSystemTime" was called already and date was mocked. Reset timers using `vi.useRealTimers()` if you want to use fake timers again.');
|
2530
2446
|
if (!this._fakingTime) {
|
2531
2447
|
const toFake = Object.keys(this._fakeTimers.timers).filter((timer) => timer !== "nextTick" && timer !== "queueMicrotask");
|
2532
|
-
if (this._userConfig?.toFake?.includes("nextTick") && isChildProcess())
|
2533
|
-
throw new Error("process.nextTick cannot be mocked inside child_process");
|
2534
|
-
}
|
2448
|
+
if (this._userConfig?.toFake?.includes("nextTick") && isChildProcess()) throw new Error("process.nextTick cannot be mocked inside child_process");
|
2535
2449
|
this._clock = this._fakeTimers.install({
|
2536
2450
|
now: Date.now(),
|
2537
2451
|
...this._userConfig,
|
@@ -2550,9 +2464,8 @@ var FakeTimers = class {
|
|
2550
2464
|
}
|
2551
2465
|
setSystemTime(now2) {
|
2552
2466
|
const date = typeof now2 === "undefined" || now2 instanceof Date ? now2 : new Date(now2);
|
2553
|
-
if (this._fakingTime)
|
2554
|
-
|
2555
|
-
} else {
|
2467
|
+
if (this._fakingTime) this._clock.setSystemTime(date);
|
2468
|
+
else {
|
2556
2469
|
this._fakingDate = date ?? new Date(this.getRealSystemTime());
|
2557
2470
|
mockDate(this._fakingDate);
|
2558
2471
|
}
|
@@ -2564,9 +2477,7 @@ var FakeTimers = class {
|
|
2564
2477
|
return this._now();
|
2565
2478
|
}
|
2566
2479
|
getTimerCount() {
|
2567
|
-
if (this._checkFakeTimers())
|
2568
|
-
return this._clock.countTimers();
|
2569
|
-
}
|
2480
|
+
if (this._checkFakeTimers()) return this._clock.countTimers();
|
2570
2481
|
return 0;
|
2571
2482
|
}
|
2572
2483
|
configure(config) {
|
@@ -2576,16 +2487,12 @@ var FakeTimers = class {
|
|
2576
2487
|
return this._fakingTime;
|
2577
2488
|
}
|
2578
2489
|
_checkFakeTimers() {
|
2579
|
-
if (!this._fakingTime)
|
2580
|
-
throw new Error('Timers are not mocked. Try calling "vi.useFakeTimers()" first.');
|
2581
|
-
}
|
2490
|
+
if (!this._fakingTime) throw new Error('Timers are not mocked. Try calling "vi.useFakeTimers()" first.');
|
2582
2491
|
return this._fakingTime;
|
2583
2492
|
}
|
2584
2493
|
};
|
2585
2494
|
function copyStackTrace(target, source) {
|
2586
|
-
if (source.stack !== void 0)
|
2587
|
-
target.stack = source.stack.replace(source.message, target.message);
|
2588
|
-
}
|
2495
|
+
if (source.stack !== void 0) target.stack = source.stack.replace(source.message, target.message);
|
2589
2496
|
return target;
|
2590
2497
|
}
|
2591
2498
|
function waitFor(callback, options = {}) {
|
@@ -2598,31 +2505,19 @@ function waitFor(callback, options = {}) {
|
|
2598
2505
|
let timeoutId;
|
2599
2506
|
let intervalId;
|
2600
2507
|
const onResolve = (result) => {
|
2601
|
-
if (timeoutId)
|
2602
|
-
|
2603
|
-
}
|
2604
|
-
if (intervalId) {
|
2605
|
-
clearInterval(intervalId);
|
2606
|
-
}
|
2508
|
+
if (timeoutId) clearTimeout(timeoutId);
|
2509
|
+
if (intervalId) clearInterval(intervalId);
|
2607
2510
|
resolve(result);
|
2608
2511
|
};
|
2609
2512
|
const handleTimeout = () => {
|
2610
|
-
if (intervalId)
|
2611
|
-
clearInterval(intervalId);
|
2612
|
-
}
|
2513
|
+
if (intervalId) clearInterval(intervalId);
|
2613
2514
|
let error = lastError;
|
2614
|
-
if (!error)
|
2615
|
-
error = copyStackTrace(new Error("Timed out in waitFor!"), STACK_TRACE_ERROR);
|
2616
|
-
}
|
2515
|
+
if (!error) error = copyStackTrace(new Error("Timed out in waitFor!"), STACK_TRACE_ERROR);
|
2617
2516
|
reject(error);
|
2618
2517
|
};
|
2619
2518
|
const checkCallback = () => {
|
2620
|
-
if (vi.isFakeTimers())
|
2621
|
-
|
2622
|
-
}
|
2623
|
-
if (promiseStatus === "pending") {
|
2624
|
-
return;
|
2625
|
-
}
|
2519
|
+
if (vi.isFakeTimers()) vi.advanceTimersByTime(interval);
|
2520
|
+
if (promiseStatus === "pending") return;
|
2626
2521
|
try {
|
2627
2522
|
const result = callback();
|
2628
2523
|
if (result !== null && typeof result === "object" && typeof result.then === "function") {
|
@@ -2643,9 +2538,7 @@ function waitFor(callback, options = {}) {
|
|
2643
2538
|
lastError = error;
|
2644
2539
|
}
|
2645
2540
|
};
|
2646
|
-
if (checkCallback() === true)
|
2647
|
-
return;
|
2648
|
-
}
|
2541
|
+
if (checkCallback() === true) return;
|
2649
2542
|
timeoutId = setTimeout(handleTimeout, timeout);
|
2650
2543
|
intervalId = setInterval(checkCallback, interval);
|
2651
2544
|
});
|
@@ -2659,34 +2552,20 @@ function waitUntil(callback, options = {}) {
|
|
2659
2552
|
let timeoutId;
|
2660
2553
|
let intervalId;
|
2661
2554
|
const onReject = (error) => {
|
2662
|
-
if (intervalId)
|
2663
|
-
|
2664
|
-
}
|
2665
|
-
if (!error) {
|
2666
|
-
error = copyStackTrace(new Error("Timed out in waitUntil!"), STACK_TRACE_ERROR);
|
2667
|
-
}
|
2555
|
+
if (intervalId) clearInterval(intervalId);
|
2556
|
+
if (!error) error = copyStackTrace(new Error("Timed out in waitUntil!"), STACK_TRACE_ERROR);
|
2668
2557
|
reject(error);
|
2669
2558
|
};
|
2670
2559
|
const onResolve = (result) => {
|
2671
|
-
if (!result)
|
2672
|
-
|
2673
|
-
|
2674
|
-
if (timeoutId) {
|
2675
|
-
clearTimeout(timeoutId);
|
2676
|
-
}
|
2677
|
-
if (intervalId) {
|
2678
|
-
clearInterval(intervalId);
|
2679
|
-
}
|
2560
|
+
if (!result) return;
|
2561
|
+
if (timeoutId) clearTimeout(timeoutId);
|
2562
|
+
if (intervalId) clearInterval(intervalId);
|
2680
2563
|
resolve(result);
|
2681
2564
|
return true;
|
2682
2565
|
};
|
2683
2566
|
const checkCallback = () => {
|
2684
|
-
if (vi.isFakeTimers())
|
2685
|
-
|
2686
|
-
}
|
2687
|
-
if (promiseStatus === "pending") {
|
2688
|
-
return;
|
2689
|
-
}
|
2567
|
+
if (vi.isFakeTimers()) vi.advanceTimersByTime(interval);
|
2568
|
+
if (promiseStatus === "pending") return;
|
2690
2569
|
try {
|
2691
2570
|
const result = callback();
|
2692
2571
|
if (result !== null && typeof result === "object" && typeof result.then === "function") {
|
@@ -2699,16 +2578,12 @@ function waitUntil(callback, options = {}) {
|
|
2699
2578
|
promiseStatus = "rejected";
|
2700
2579
|
onReject(rejectedValue);
|
2701
2580
|
});
|
2702
|
-
} else
|
2703
|
-
return onResolve(result);
|
2704
|
-
}
|
2581
|
+
} else return onResolve(result);
|
2705
2582
|
} catch (error) {
|
2706
2583
|
onReject(error);
|
2707
2584
|
}
|
2708
2585
|
};
|
2709
|
-
if (checkCallback() === true)
|
2710
|
-
return;
|
2711
|
-
}
|
2586
|
+
if (checkCallback() === true) return;
|
2712
2587
|
timeoutId = setTimeout(onReject, timeout);
|
2713
2588
|
intervalId = setInterval(checkCallback, interval);
|
2714
2589
|
});
|
@@ -2731,18 +2606,13 @@ function createVitest() {
|
|
2731
2606
|
const utils = {
|
2732
2607
|
useFakeTimers(config) {
|
2733
2608
|
if (isChildProcess()) {
|
2734
|
-
if (config?.toFake?.includes("nextTick") || workerState.config?.fakeTimers?.toFake?.includes("nextTick")) {
|
2735
|
-
throw new Error('vi.useFakeTimers({ toFake: ["nextTick"] }) is not supported in node:child_process. Use --pool=threads if mocking nextTick is required.');
|
2736
|
-
}
|
2737
|
-
}
|
2738
|
-
if (config) {
|
2739
|
-
timers().configure({
|
2740
|
-
...workerState.config.fakeTimers,
|
2741
|
-
...config
|
2742
|
-
});
|
2743
|
-
} else {
|
2744
|
-
timers().configure(workerState.config.fakeTimers);
|
2609
|
+
if (config?.toFake?.includes("nextTick") || workerState.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.');
|
2745
2610
|
}
|
2611
|
+
if (config) timers().configure({
|
2612
|
+
...workerState.config.fakeTimers,
|
2613
|
+
...config
|
2614
|
+
});
|
2615
|
+
else timers().configure(workerState.config.fakeTimers);
|
2746
2616
|
timers().useFakeTimers();
|
2747
2617
|
return utils;
|
2748
2618
|
},
|
@@ -2819,29 +2689,21 @@ function createVitest() {
|
|
2819
2689
|
return factory();
|
2820
2690
|
},
|
2821
2691
|
mock(path, factory) {
|
2822
|
-
if (typeof path !== "string") {
|
2823
|
-
throw new TypeError(`vi.mock() expects a string path, but received a ${typeof path}`);
|
2824
|
-
}
|
2692
|
+
if (typeof path !== "string") throw new TypeError(`vi.mock() expects a string path, but received a ${typeof path}`);
|
2825
2693
|
const importer = getImporter("mock");
|
2826
2694
|
_mocker().queueMock(path, importer, typeof factory === "function" ? () => factory(() => _mocker().importActual(path, importer, _mocker().getMockContext().callstack)) : factory);
|
2827
2695
|
},
|
2828
2696
|
unmock(path) {
|
2829
|
-
if (typeof path !== "string") {
|
2830
|
-
throw new TypeError(`vi.unmock() expects a string path, but received a ${typeof path}`);
|
2831
|
-
}
|
2697
|
+
if (typeof path !== "string") throw new TypeError(`vi.unmock() expects a string path, but received a ${typeof path}`);
|
2832
2698
|
_mocker().queueUnmock(path, getImporter("unmock"));
|
2833
2699
|
},
|
2834
2700
|
doMock(path, factory) {
|
2835
|
-
if (typeof path !== "string") {
|
2836
|
-
throw new TypeError(`vi.doMock() expects a string path, but received a ${typeof path}`);
|
2837
|
-
}
|
2701
|
+
if (typeof path !== "string") throw new TypeError(`vi.doMock() expects a string path, but received a ${typeof path}`);
|
2838
2702
|
const importer = getImporter("doMock");
|
2839
2703
|
_mocker().queueMock(path, importer, typeof factory === "function" ? () => factory(() => _mocker().importActual(path, importer, _mocker().getMockContext().callstack)) : factory);
|
2840
2704
|
},
|
2841
2705
|
doUnmock(path) {
|
2842
|
-
if (typeof path !== "string") {
|
2843
|
-
throw new TypeError(`vi.doUnmock() expects a string path, but received a ${typeof path}`);
|
2844
|
-
}
|
2706
|
+
if (typeof path !== "string") throw new TypeError(`vi.doUnmock() expects a string path, but received a ${typeof path}`);
|
2845
2707
|
_mocker().queueUnmock(path, getImporter("doUnmock"));
|
2846
2708
|
},
|
2847
2709
|
async importActual(path) {
|
@@ -2850,6 +2712,9 @@ function createVitest() {
|
|
2850
2712
|
async importMock(path) {
|
2851
2713
|
return _mocker().importMock(path, getImporter("importMock"));
|
2852
2714
|
},
|
2715
|
+
mockObject(value) {
|
2716
|
+
return _mocker().mockObject({ value }).value;
|
2717
|
+
},
|
2853
2718
|
mocked(item, _options = {}) {
|
2854
2719
|
return item;
|
2855
2720
|
},
|
@@ -2869,9 +2734,7 @@ function createVitest() {
|
|
2869
2734
|
return utils;
|
2870
2735
|
},
|
2871
2736
|
stubGlobal(name, value) {
|
2872
|
-
if (!_stubsGlobal.has(name))
|
2873
|
-
_stubsGlobal.set(name, Object.getOwnPropertyDescriptor(globalThis, name));
|
2874
|
-
}
|
2737
|
+
if (!_stubsGlobal.has(name)) _stubsGlobal.set(name, Object.getOwnPropertyDescriptor(globalThis, name));
|
2875
2738
|
Object.defineProperty(globalThis, name, {
|
2876
2739
|
value,
|
2877
2740
|
writable: true,
|
@@ -2881,36 +2744,24 @@ function createVitest() {
|
|
2881
2744
|
return utils;
|
2882
2745
|
},
|
2883
2746
|
stubEnv(name, value) {
|
2884
|
-
if (!_stubsEnv.has(name))
|
2885
|
-
|
2886
|
-
|
2887
|
-
|
2888
|
-
process.env[name] = value ? "1" : "";
|
2889
|
-
} else if (value === void 0) {
|
2890
|
-
delete process.env[name];
|
2891
|
-
} else {
|
2892
|
-
process.env[name] = String(value);
|
2893
|
-
}
|
2747
|
+
if (!_stubsEnv.has(name)) _stubsEnv.set(name, process.env[name]);
|
2748
|
+
if (_envBooleans.includes(name)) process.env[name] = value ? "1" : "";
|
2749
|
+
else if (value === void 0) delete process.env[name];
|
2750
|
+
else process.env[name] = String(value);
|
2894
2751
|
return utils;
|
2895
2752
|
},
|
2896
2753
|
unstubAllGlobals() {
|
2897
2754
|
_stubsGlobal.forEach((original, name) => {
|
2898
|
-
if (!original)
|
2899
|
-
|
2900
|
-
} else {
|
2901
|
-
Object.defineProperty(globalThis, name, original);
|
2902
|
-
}
|
2755
|
+
if (!original) Reflect.deleteProperty(globalThis, name);
|
2756
|
+
else Object.defineProperty(globalThis, name, original);
|
2903
2757
|
});
|
2904
2758
|
_stubsGlobal.clear();
|
2905
2759
|
return utils;
|
2906
2760
|
},
|
2907
2761
|
unstubAllEnvs() {
|
2908
2762
|
_stubsEnv.forEach((original, name) => {
|
2909
|
-
if (original === void 0)
|
2910
|
-
|
2911
|
-
} else {
|
2912
|
-
process.env[name] = original;
|
2913
|
-
}
|
2763
|
+
if (original === void 0) delete process.env[name];
|
2764
|
+
else process.env[name] = original;
|
2914
2765
|
});
|
2915
2766
|
_stubsEnv.clear();
|
2916
2767
|
return utils;
|
@@ -2923,15 +2774,11 @@ function createVitest() {
|
|
2923
2774
|
return waitForImportsToResolve();
|
2924
2775
|
},
|
2925
2776
|
setConfig(config) {
|
2926
|
-
if (!_config) {
|
2927
|
-
_config = { ...workerState.config };
|
2928
|
-
}
|
2777
|
+
if (!_config) _config = { ...workerState.config };
|
2929
2778
|
Object.assign(workerState.config, config);
|
2930
2779
|
},
|
2931
2780
|
resetConfig() {
|
2932
|
-
if (_config)
|
2933
|
-
Object.assign(workerState.config, _config);
|
2934
|
-
}
|
2781
|
+
if (_config) Object.assign(workerState.config, _config);
|
2935
2782
|
}
|
2936
2783
|
};
|
2937
2784
|
return utils;
|
@@ -2953,7 +2800,7 @@ function getImporter(name) {
|
|
2953
2800
|
return stack?.file || "";
|
2954
2801
|
}
|
2955
2802
|
|
2956
|
-
// ../../node_modules/.pnpm/vitest@3.
|
2803
|
+
// ../../node_modules/.pnpm/vitest@3.2.0_@types+debug@4.1.12_@types+node@22.15.29_jiti@2.4.2_jsdom@26.1.0_lightningcss@1.30.1_tsx@4.19.4/node_modules/vitest/dist/index.js
|
2957
2804
|
import { expectTypeOf } from "expect-type.js";
|
2958
2805
|
import { afterAll, afterEach, beforeAll, beforeEach, describe, it, onTestFailed, onTestFinished, suite, test } from "@vitest/runner.js";
|
2959
2806
|
import * as chai2 from "chai.js";
|