@rstest/core 0.9.6 → 0.9.7
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/0~8843.js +6 -0
- package/dist/0~browserLoader.js +1 -1
- package/dist/0~browser~1.js +2 -2
- package/dist/0~fake-timers.js +300 -250
- package/dist/0~listTests.js +67 -7
- package/dist/1255.js +6 -6
- package/dist/3145.js +179 -22
- package/dist/4411.js +128 -140
- package/dist/{6887.js → 7290.js} +3 -3
- package/dist/9784.js +1 -1
- package/dist/browser-runtime/2~fake-timers.js +308 -429
- package/dist/browser-runtime/2~magic-string.es.js +2 -2
- package/dist/browser-runtime/723.js +7 -13
- package/dist/browser-runtime/index.d.ts +17 -58
- package/dist/browser.d.ts +17 -58
- package/dist/index.d.ts +18 -58
- package/dist/worker.d.ts +3 -2
- package/globals.d.ts +1 -0
- package/package.json +9 -10
package/dist/0~fake-timers.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import "node:module";
|
|
2
2
|
import { __webpack_require__ } from "./0~rslib-runtime.js";
|
|
3
|
-
import "./
|
|
3
|
+
import "./7290.js";
|
|
4
4
|
__webpack_require__.add({
|
|
5
5
|
"../../node_modules/.pnpm/@sinonjs+commons@3.0.1/node_modules/@sinonjs/commons/lib/called-in-order.js" (module, __unused_rspack_exports, __webpack_require__) {
|
|
6
6
|
var every = __webpack_require__("../../node_modules/.pnpm/@sinonjs+commons@3.0.1/node_modules/@sinonjs/commons/lib/prototypes/array.js").every;
|
|
@@ -183,7 +183,7 @@ __webpack_require__.add({
|
|
|
183
183
|
}
|
|
184
184
|
module.exports = valueToString;
|
|
185
185
|
},
|
|
186
|
-
"../../node_modules/.pnpm/@sinonjs+fake-timers@15.
|
|
186
|
+
"../../node_modules/.pnpm/@sinonjs+fake-timers@15.3.0/node_modules/@sinonjs/fake-timers/src/fake-timers-src.js" (__unused_rspack_module, exports, __webpack_require__) {
|
|
187
187
|
const globalObject = __webpack_require__("../../node_modules/.pnpm/@sinonjs+commons@3.0.1/node_modules/@sinonjs/commons/lib/index.js").global;
|
|
188
188
|
let timersModule, timersPromisesModule;
|
|
189
189
|
try {
|
|
@@ -248,12 +248,11 @@ __webpack_require__.add({
|
|
|
248
248
|
if (Number.isFinite) return Number.isFinite(num);
|
|
249
249
|
return isFinite(num);
|
|
250
250
|
}
|
|
251
|
-
let isNearInfiniteLimit = false;
|
|
252
251
|
function checkIsNearInfiniteLimit(clock, i) {
|
|
253
|
-
if (clock.loopLimit && i === clock.loopLimit - 1) isNearInfiniteLimit = true;
|
|
252
|
+
if (clock.loopLimit && i === clock.loopLimit - 1) clock.isNearInfiniteLimit = true;
|
|
254
253
|
}
|
|
255
|
-
function resetIsNearInfiniteLimit() {
|
|
256
|
-
isNearInfiniteLimit = false;
|
|
254
|
+
function resetIsNearInfiniteLimit(clock) {
|
|
255
|
+
if (clock) clock.isNearInfiniteLimit = false;
|
|
257
256
|
}
|
|
258
257
|
function parseTime(str) {
|
|
259
258
|
if (!str) return 0;
|
|
@@ -278,7 +277,7 @@ __webpack_require__.add({
|
|
|
278
277
|
}
|
|
279
278
|
function getEpoch(epoch) {
|
|
280
279
|
if (!epoch) return 0;
|
|
281
|
-
if (
|
|
280
|
+
if (epoch instanceof Date) return epoch.getTime();
|
|
282
281
|
if ("number" == typeof epoch) return epoch;
|
|
283
282
|
throw new TypeError("now should be milliseconds since UNIX epoch");
|
|
284
283
|
}
|
|
@@ -378,19 +377,123 @@ __webpack_require__.add({
|
|
|
378
377
|
}
|
|
379
378
|
function runJobs(clock) {
|
|
380
379
|
if (!clock.jobs) return;
|
|
380
|
+
const wasNearLimit = clock.isNearInfiniteLimit;
|
|
381
381
|
for(let i = 0; i < clock.jobs.length; i++){
|
|
382
382
|
const job = clock.jobs[i];
|
|
383
383
|
job.func.apply(null, job.args);
|
|
384
384
|
checkIsNearInfiniteLimit(clock, i);
|
|
385
385
|
if (clock.loopLimit && i > clock.loopLimit) throw getInfiniteLoopError(clock, job);
|
|
386
386
|
}
|
|
387
|
-
resetIsNearInfiniteLimit();
|
|
387
|
+
if (!wasNearLimit) resetIsNearInfiniteLimit(clock);
|
|
388
388
|
clock.jobs = [];
|
|
389
389
|
}
|
|
390
|
+
class TimerHeap {
|
|
391
|
+
constructor(){
|
|
392
|
+
this.timers = [];
|
|
393
|
+
}
|
|
394
|
+
peek() {
|
|
395
|
+
return this.timers[0];
|
|
396
|
+
}
|
|
397
|
+
push(timer) {
|
|
398
|
+
this.timers.push(timer);
|
|
399
|
+
this.bubbleUp(this.timers.length - 1);
|
|
400
|
+
}
|
|
401
|
+
pop() {
|
|
402
|
+
if (0 === this.timers.length) return;
|
|
403
|
+
const first = this.timers[0];
|
|
404
|
+
const last = this.timers.pop();
|
|
405
|
+
if (this.timers.length > 0) {
|
|
406
|
+
this.timers[0] = last;
|
|
407
|
+
last.heapIndex = 0;
|
|
408
|
+
this.bubbleDown(0);
|
|
409
|
+
}
|
|
410
|
+
delete first.heapIndex;
|
|
411
|
+
return first;
|
|
412
|
+
}
|
|
413
|
+
remove(timer) {
|
|
414
|
+
const index = timer.heapIndex;
|
|
415
|
+
if (void 0 === index || this.timers[index] !== timer) return false;
|
|
416
|
+
const last = this.timers.pop();
|
|
417
|
+
if (timer !== last) {
|
|
418
|
+
this.timers[index] = last;
|
|
419
|
+
last.heapIndex = index;
|
|
420
|
+
if (compareTimers(last, timer) < 0) this.bubbleUp(index);
|
|
421
|
+
else this.bubbleDown(index);
|
|
422
|
+
}
|
|
423
|
+
delete timer.heapIndex;
|
|
424
|
+
return true;
|
|
425
|
+
}
|
|
426
|
+
bubbleUp(index) {
|
|
427
|
+
const timer = this.timers[index];
|
|
428
|
+
let currentIndex = index;
|
|
429
|
+
while(currentIndex > 0){
|
|
430
|
+
const parentIndex = Math.floor((currentIndex - 1) / 2);
|
|
431
|
+
const parent = this.timers[parentIndex];
|
|
432
|
+
if (compareTimers(timer, parent) < 0) {
|
|
433
|
+
this.timers[currentIndex] = parent;
|
|
434
|
+
parent.heapIndex = currentIndex;
|
|
435
|
+
currentIndex = parentIndex;
|
|
436
|
+
} else break;
|
|
437
|
+
}
|
|
438
|
+
this.timers[currentIndex] = timer;
|
|
439
|
+
timer.heapIndex = currentIndex;
|
|
440
|
+
}
|
|
441
|
+
bubbleDown(index) {
|
|
442
|
+
const timer = this.timers[index];
|
|
443
|
+
let currentIndex = index;
|
|
444
|
+
const halfLength = Math.floor(this.timers.length / 2);
|
|
445
|
+
while(currentIndex < halfLength){
|
|
446
|
+
const leftIndex = 2 * currentIndex + 1;
|
|
447
|
+
const rightIndex = leftIndex + 1;
|
|
448
|
+
let bestChildIndex = leftIndex;
|
|
449
|
+
let bestChild = this.timers[leftIndex];
|
|
450
|
+
if (rightIndex < this.timers.length && compareTimers(this.timers[rightIndex], bestChild) < 0) {
|
|
451
|
+
bestChildIndex = rightIndex;
|
|
452
|
+
bestChild = this.timers[rightIndex];
|
|
453
|
+
}
|
|
454
|
+
if (compareTimers(bestChild, timer) < 0) {
|
|
455
|
+
this.timers[currentIndex] = bestChild;
|
|
456
|
+
bestChild.heapIndex = currentIndex;
|
|
457
|
+
currentIndex = bestChildIndex;
|
|
458
|
+
} else break;
|
|
459
|
+
}
|
|
460
|
+
this.timers[currentIndex] = timer;
|
|
461
|
+
timer.heapIndex = currentIndex;
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
function ensureTimerState(clock) {
|
|
465
|
+
if (!clock.timers) {
|
|
466
|
+
clock.timers = new Map();
|
|
467
|
+
clock.timerHeap = new TimerHeap();
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
function hasTimer(clock, id) {
|
|
471
|
+
return clock.timers ? clock.timers.has(id) : false;
|
|
472
|
+
}
|
|
473
|
+
function getTimer(clock, id) {
|
|
474
|
+
return clock.timers ? clock.timers.get(id) : void 0;
|
|
475
|
+
}
|
|
476
|
+
function setTimer(clock, timer) {
|
|
477
|
+
ensureTimerState(clock);
|
|
478
|
+
clock.timers.set(timer.id, timer);
|
|
479
|
+
}
|
|
480
|
+
function deleteTimer(clock, id) {
|
|
481
|
+
return clock.timers ? clock.timers.delete(id) : false;
|
|
482
|
+
}
|
|
483
|
+
function forEachActiveTimer(clock, callback) {
|
|
484
|
+
if (!clock.timers) return;
|
|
485
|
+
for (const timer of clock.timers.values())callback(timer);
|
|
486
|
+
}
|
|
487
|
+
function rebuildTimerHeap(clock) {
|
|
488
|
+
clock.timerHeap = new TimerHeap();
|
|
489
|
+
forEachActiveTimer(clock, (timer)=>{
|
|
490
|
+
clock.timerHeap.push(timer);
|
|
491
|
+
});
|
|
492
|
+
}
|
|
390
493
|
function addTimer(clock, timer) {
|
|
391
494
|
if (void 0 === timer.func) throw new Error("Callback must be provided to timer calls");
|
|
392
495
|
if ("function" != typeof timer.func) throw new TypeError(`[ERR_INVALID_CALLBACK]: Callback must be a function. Received ${timer.func} of type ${typeof timer.func}`);
|
|
393
|
-
if (isNearInfiniteLimit) timer.error = new Error();
|
|
496
|
+
if (clock.isNearInfiniteLimit) timer.error = new Error();
|
|
394
497
|
timer.type = timer.immediate ? "Immediate" : "Timeout";
|
|
395
498
|
if (Object.prototype.hasOwnProperty.call(timer, "delay")) {
|
|
396
499
|
if ("number" != typeof timer.delay) timer.delay = parseInt(timer.delay, 10);
|
|
@@ -410,11 +513,8 @@ __webpack_require__.add({
|
|
|
410
513
|
if (!timer.delay) timer.type = "IdleCallback";
|
|
411
514
|
timer.requestIdleCallback = true;
|
|
412
515
|
}
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
clock.timerHeap = new TimerHeap();
|
|
416
|
-
}
|
|
417
|
-
while(clock.timers && clock.timers[uniqueTimerId]){
|
|
516
|
+
ensureTimerState(clock);
|
|
517
|
+
while(hasTimer(clock, uniqueTimerId)){
|
|
418
518
|
uniqueTimerId++;
|
|
419
519
|
if (uniqueTimerId >= Number.MAX_SAFE_INTEGER) uniqueTimerId = idCounterStart;
|
|
420
520
|
}
|
|
@@ -422,8 +522,8 @@ __webpack_require__.add({
|
|
|
422
522
|
if (uniqueTimerId >= Number.MAX_SAFE_INTEGER) uniqueTimerId = idCounterStart;
|
|
423
523
|
timer.order = uniqueTimerOrder++;
|
|
424
524
|
timer.createdAt = clock.now;
|
|
425
|
-
timer.callAt = clock.now + (parseInt(timer.delay) || (clock.duringTick ? 1 : 0));
|
|
426
|
-
clock
|
|
525
|
+
timer.callAt = clock.now + (parseInt(String(timer.delay)) || (clock.duringTick ? 1 : 0));
|
|
526
|
+
setTimer(clock, timer);
|
|
427
527
|
clock.timerHeap.push(timer);
|
|
428
528
|
if (addTimerReturnsObject) {
|
|
429
529
|
const res = {
|
|
@@ -440,10 +540,10 @@ __webpack_require__.add({
|
|
|
440
540
|
return this.refed;
|
|
441
541
|
},
|
|
442
542
|
refresh: function() {
|
|
443
|
-
timer.callAt = clock.now + (parseInt(timer.delay) || (clock.duringTick ? 1 : 0));
|
|
543
|
+
timer.callAt = clock.now + (parseInt(String(timer.delay)) || (clock.duringTick ? 1 : 0));
|
|
444
544
|
clock.timerHeap.remove(timer);
|
|
445
545
|
timer.order = uniqueTimerOrder++;
|
|
446
|
-
clock
|
|
546
|
+
setTimer(clock, timer);
|
|
447
547
|
clock.timerHeap.push(timer);
|
|
448
548
|
return this;
|
|
449
549
|
},
|
|
@@ -470,78 +570,6 @@ __webpack_require__.add({
|
|
|
470
570
|
if (a.id > b.id) return 1;
|
|
471
571
|
return 0;
|
|
472
572
|
}
|
|
473
|
-
function TimerHeap() {
|
|
474
|
-
this.timers = [];
|
|
475
|
-
}
|
|
476
|
-
TimerHeap.prototype.peek = function() {
|
|
477
|
-
return this.timers[0];
|
|
478
|
-
};
|
|
479
|
-
TimerHeap.prototype.push = function(timer) {
|
|
480
|
-
this.timers.push(timer);
|
|
481
|
-
this.bubbleUp(this.timers.length - 1);
|
|
482
|
-
};
|
|
483
|
-
TimerHeap.prototype.pop = function() {
|
|
484
|
-
if (0 === this.timers.length) return;
|
|
485
|
-
const first = this.timers[0];
|
|
486
|
-
const last = this.timers.pop();
|
|
487
|
-
if (this.timers.length > 0) {
|
|
488
|
-
this.timers[0] = last;
|
|
489
|
-
last.heapIndex = 0;
|
|
490
|
-
this.bubbleDown(0);
|
|
491
|
-
}
|
|
492
|
-
delete first.heapIndex;
|
|
493
|
-
return first;
|
|
494
|
-
};
|
|
495
|
-
TimerHeap.prototype.remove = function(timer) {
|
|
496
|
-
const index = timer.heapIndex;
|
|
497
|
-
if (void 0 === index || this.timers[index] !== timer) return false;
|
|
498
|
-
const last = this.timers.pop();
|
|
499
|
-
if (timer !== last) {
|
|
500
|
-
this.timers[index] = last;
|
|
501
|
-
last.heapIndex = index;
|
|
502
|
-
if (compareTimers(last, timer) < 0) this.bubbleUp(index);
|
|
503
|
-
else this.bubbleDown(index);
|
|
504
|
-
}
|
|
505
|
-
delete timer.heapIndex;
|
|
506
|
-
return true;
|
|
507
|
-
};
|
|
508
|
-
TimerHeap.prototype.bubbleUp = function(index) {
|
|
509
|
-
const timer = this.timers[index];
|
|
510
|
-
let currentIndex = index;
|
|
511
|
-
while(currentIndex > 0){
|
|
512
|
-
const parentIndex = Math.floor((currentIndex - 1) / 2);
|
|
513
|
-
const parent = this.timers[parentIndex];
|
|
514
|
-
if (compareTimers(timer, parent) < 0) {
|
|
515
|
-
this.timers[currentIndex] = parent;
|
|
516
|
-
parent.heapIndex = currentIndex;
|
|
517
|
-
currentIndex = parentIndex;
|
|
518
|
-
} else break;
|
|
519
|
-
}
|
|
520
|
-
this.timers[currentIndex] = timer;
|
|
521
|
-
timer.heapIndex = currentIndex;
|
|
522
|
-
};
|
|
523
|
-
TimerHeap.prototype.bubbleDown = function(index) {
|
|
524
|
-
const timer = this.timers[index];
|
|
525
|
-
let currentIndex = index;
|
|
526
|
-
const halfLength = Math.floor(this.timers.length / 2);
|
|
527
|
-
while(currentIndex < halfLength){
|
|
528
|
-
const leftIndex = 2 * currentIndex + 1;
|
|
529
|
-
const rightIndex = leftIndex + 1;
|
|
530
|
-
let bestChildIndex = leftIndex;
|
|
531
|
-
let bestChild = this.timers[leftIndex];
|
|
532
|
-
if (rightIndex < this.timers.length && compareTimers(this.timers[rightIndex], bestChild) < 0) {
|
|
533
|
-
bestChildIndex = rightIndex;
|
|
534
|
-
bestChild = this.timers[rightIndex];
|
|
535
|
-
}
|
|
536
|
-
if (compareTimers(bestChild, timer) < 0) {
|
|
537
|
-
this.timers[currentIndex] = bestChild;
|
|
538
|
-
bestChild.heapIndex = currentIndex;
|
|
539
|
-
currentIndex = bestChildIndex;
|
|
540
|
-
} else break;
|
|
541
|
-
}
|
|
542
|
-
this.timers[currentIndex] = timer;
|
|
543
|
-
timer.heapIndex = currentIndex;
|
|
544
|
-
};
|
|
545
573
|
function firstTimerInRange(clock, from, to) {
|
|
546
574
|
if (!clock.timerHeap) return null;
|
|
547
575
|
const timers = clock.timerHeap.timers;
|
|
@@ -568,9 +596,10 @@ __webpack_require__.add({
|
|
|
568
596
|
clock.timerHeap.remove(timer);
|
|
569
597
|
timer.callAt += timer.interval;
|
|
570
598
|
timer.order = uniqueTimerOrder++;
|
|
599
|
+
if (clock.isNearInfiniteLimit) timer.error = new Error();
|
|
571
600
|
clock.timerHeap.push(timer);
|
|
572
601
|
} else {
|
|
573
|
-
|
|
602
|
+
deleteTimer(clock, timer.id);
|
|
574
603
|
clock.timerHeap.remove(timer);
|
|
575
604
|
}
|
|
576
605
|
if ("function" == typeof timer.func) timer.func.apply(null, timer.args);
|
|
@@ -592,7 +621,6 @@ __webpack_require__.add({
|
|
|
592
621
|
const warnOnce = createWarnOnce();
|
|
593
622
|
function clearTimer(clock, timerId, ttype) {
|
|
594
623
|
if (!timerId) return;
|
|
595
|
-
if (!clock.timers) clock.timers = {};
|
|
596
624
|
const id = Number(timerId);
|
|
597
625
|
if (Number.isNaN(id) || id < idCounterStart) {
|
|
598
626
|
const handlerName = getClearHandler(ttype);
|
|
@@ -603,10 +631,10 @@ __webpack_require__.add({
|
|
|
603
631
|
const stackTrace = new Error().stack.split("\n").slice(1).join("\n");
|
|
604
632
|
warnOnce(`FakeTimers: ${handlerName} was invoked to clear a native timer instead of one created by this library.\nTo automatically clean-up native timers, use \`shouldClearNativeTimers\`.\n${stackTrace}`);
|
|
605
633
|
}
|
|
606
|
-
if (
|
|
607
|
-
const timer = clock
|
|
634
|
+
if (hasTimer(clock, id)) {
|
|
635
|
+
const timer = getTimer(clock, id);
|
|
608
636
|
if (timer.type === ttype || "Timeout" === timer.type && "Interval" === ttype || "Interval" === timer.type && "Timeout" === ttype) {
|
|
609
|
-
|
|
637
|
+
deleteTimer(clock, id);
|
|
610
638
|
clock.timerHeap.remove(timer);
|
|
611
639
|
} else {
|
|
612
640
|
const clear = getClearHandler(ttype);
|
|
@@ -640,7 +668,9 @@ __webpack_require__.add({
|
|
|
640
668
|
timersPromisesModule[entry.methodName] = entry.original;
|
|
641
669
|
}
|
|
642
670
|
}
|
|
643
|
-
clock.setTickMode(
|
|
671
|
+
clock.setTickMode({
|
|
672
|
+
mode: "manual"
|
|
673
|
+
});
|
|
644
674
|
clock.methods = [];
|
|
645
675
|
for (const [listener, signal] of clock.abortListenerMap.entries()){
|
|
646
676
|
signal.removeEventListener("abort", listener);
|
|
@@ -705,6 +735,7 @@ __webpack_require__.add({
|
|
|
705
735
|
now: start,
|
|
706
736
|
Date: createDate(),
|
|
707
737
|
loopLimit: loopLimit,
|
|
738
|
+
isNearInfiniteLimit: false,
|
|
708
739
|
tickMode: {
|
|
709
740
|
mode: "manual",
|
|
710
741
|
counter: 0,
|
|
@@ -769,7 +800,7 @@ __webpack_require__.add({
|
|
|
769
800
|
const channel = new MessageChannel();
|
|
770
801
|
await new Promise((resolve)=>{
|
|
771
802
|
channel.port1.onmessage = ()=>{
|
|
772
|
-
resolve();
|
|
803
|
+
resolve(void 0);
|
|
773
804
|
channel.port1.close();
|
|
774
805
|
};
|
|
775
806
|
channel.port2.postMessage(void 0);
|
|
@@ -846,7 +877,7 @@ __webpack_require__.add({
|
|
|
846
877
|
return enqueueJob(clock, {
|
|
847
878
|
func: func,
|
|
848
879
|
args: Array.prototype.slice.call(arguments, 1),
|
|
849
|
-
error: isNearInfiniteLimit ? new Error() : null
|
|
880
|
+
error: clock.isNearInfiniteLimit ? new Error() : null
|
|
850
881
|
});
|
|
851
882
|
};
|
|
852
883
|
clock.queueMicrotask = function queueMicrotask(func) {
|
|
@@ -909,7 +940,7 @@ __webpack_require__.add({
|
|
|
909
940
|
clock.runMicrotasks = function runMicrotasks() {
|
|
910
941
|
runJobs(clock);
|
|
911
942
|
};
|
|
912
|
-
function
|
|
943
|
+
function createTickState(tickValue) {
|
|
913
944
|
const msFloat = "number" == typeof tickValue ? tickValue : parseTime(tickValue);
|
|
914
945
|
const ms = Math.floor(msFloat);
|
|
915
946
|
const remainder = nanoRemainder(msFloat);
|
|
@@ -920,92 +951,108 @@ __webpack_require__.add({
|
|
|
920
951
|
tickTo += 1;
|
|
921
952
|
nanosTotal -= 1e6;
|
|
922
953
|
}
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
954
|
+
return {
|
|
955
|
+
msFloat: msFloat,
|
|
956
|
+
ms: ms,
|
|
957
|
+
nanosTotal: nanosTotal,
|
|
958
|
+
tickFrom: clock.now,
|
|
959
|
+
tickTo: tickTo,
|
|
960
|
+
previous: clock.now,
|
|
961
|
+
timer: null,
|
|
962
|
+
firstException: null,
|
|
963
|
+
oldNow: null
|
|
964
|
+
};
|
|
965
|
+
}
|
|
966
|
+
function applyClockChangeCompensation(state, oldNow, options) {
|
|
930
967
|
if (oldNow !== clock.now) {
|
|
931
|
-
|
|
932
|
-
|
|
968
|
+
const difference = clock.now - oldNow;
|
|
969
|
+
state.tickFrom += difference;
|
|
970
|
+
state.tickTo += difference;
|
|
971
|
+
if (options && options.includePrevious) state.previous += difference;
|
|
933
972
|
}
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
973
|
+
}
|
|
974
|
+
function runInitialJobs(state) {
|
|
975
|
+
state.oldNow = clock.now;
|
|
976
|
+
runJobs(clock);
|
|
977
|
+
applyClockChangeCompensation(state, state.oldNow);
|
|
978
|
+
}
|
|
979
|
+
function runPostLoopJobs(state) {
|
|
980
|
+
state.oldNow = clock.now;
|
|
981
|
+
runJobs(clock);
|
|
982
|
+
applyClockChangeCompensation(state, state.oldNow);
|
|
983
|
+
}
|
|
984
|
+
function selectNextTimerInRange(state) {
|
|
985
|
+
state.timer = firstTimerInRange(clock, state.previous, state.tickTo);
|
|
986
|
+
state.previous = state.tickFrom;
|
|
987
|
+
}
|
|
988
|
+
function runTimersInRange(state, isAsync, nextPromiseTick, compensationCheck) {
|
|
989
|
+
state.timer = firstTimerInRange(clock, state.tickFrom, state.tickTo);
|
|
990
|
+
while(state.timer && state.tickFrom <= state.tickTo){
|
|
991
|
+
if (hasTimer(clock, state.timer.id)) {
|
|
992
|
+
state.tickFrom = state.timer.callAt;
|
|
993
|
+
clock.now = state.timer.callAt;
|
|
994
|
+
state.oldNow = clock.now;
|
|
995
|
+
try {
|
|
996
|
+
runJobs(clock);
|
|
997
|
+
callTimer(clock, state.timer);
|
|
998
|
+
} catch (e) {
|
|
999
|
+
state.firstException = state.firstException || e;
|
|
949
1000
|
}
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
tickFrom += clock.now - oldNow;
|
|
956
|
-
tickTo += clock.now - oldNow;
|
|
957
|
-
}
|
|
958
|
-
clock.duringTick = false;
|
|
959
|
-
timer = firstTimerInRange(clock, tickFrom, tickTo);
|
|
960
|
-
if (timer) try {
|
|
961
|
-
clock.tick(tickTo - clock.now);
|
|
962
|
-
} catch (e) {
|
|
963
|
-
firstException = firstException || e;
|
|
964
|
-
}
|
|
965
|
-
else {
|
|
966
|
-
clock.now = tickTo;
|
|
967
|
-
nanos = nanosTotal;
|
|
1001
|
+
if (isAsync) {
|
|
1002
|
+
originalSetTimeout(nextPromiseTick);
|
|
1003
|
+
return true;
|
|
1004
|
+
}
|
|
1005
|
+
compensationCheck();
|
|
968
1006
|
}
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
1007
|
+
selectNextTimerInRange(state);
|
|
1008
|
+
}
|
|
1009
|
+
return false;
|
|
1010
|
+
}
|
|
1011
|
+
function finalizeTick(state, isAsync, resolve) {
|
|
1012
|
+
state.timer = firstTimerInRange(clock, state.tickFrom, state.tickTo);
|
|
1013
|
+
if (state.timer) try {
|
|
1014
|
+
clock.tick(state.tickTo - clock.now);
|
|
1015
|
+
} catch (e) {
|
|
1016
|
+
state.firstException = state.firstException || e;
|
|
1017
|
+
}
|
|
1018
|
+
else {
|
|
1019
|
+
clock.now = state.tickTo;
|
|
1020
|
+
nanos = state.nanosTotal;
|
|
972
1021
|
}
|
|
973
|
-
|
|
1022
|
+
if (state.firstException) throw state.firstException;
|
|
1023
|
+
if (!isAsync) return clock.now;
|
|
1024
|
+
resolve(clock.now);
|
|
1025
|
+
}
|
|
1026
|
+
function doTick(tickValue, isAsync, resolve, reject) {
|
|
1027
|
+
const state = createTickState(tickValue);
|
|
1028
|
+
nanos = state.nanosTotal;
|
|
1029
|
+
clock.duringTick = true;
|
|
1030
|
+
runInitialJobs(state);
|
|
1031
|
+
const compensationCheck = function() {
|
|
1032
|
+
applyClockChangeCompensation(state, state.oldNow, {
|
|
1033
|
+
includePrevious: true
|
|
1034
|
+
});
|
|
1035
|
+
};
|
|
1036
|
+
const nextPromiseTick = isAsync && function() {
|
|
974
1037
|
try {
|
|
975
1038
|
compensationCheck();
|
|
976
|
-
|
|
1039
|
+
selectNextTimerInRange(state);
|
|
977
1040
|
doTickInner();
|
|
978
1041
|
} catch (e) {
|
|
979
1042
|
reject(e);
|
|
980
1043
|
}
|
|
981
1044
|
};
|
|
982
|
-
|
|
983
|
-
if (
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
};
|
|
989
|
-
postTimerCall = function() {
|
|
990
|
-
timer = firstTimerInRange(clock, previous, tickTo);
|
|
991
|
-
previous = tickFrom;
|
|
992
|
-
};
|
|
1045
|
+
function doTickInner() {
|
|
1046
|
+
if (runTimersInRange(state, isAsync, nextPromiseTick, compensationCheck)) return;
|
|
1047
|
+
runPostLoopJobs(state);
|
|
1048
|
+
clock.duringTick = false;
|
|
1049
|
+
return finalizeTick(state, isAsync, resolve);
|
|
1050
|
+
}
|
|
993
1051
|
return doTickInner();
|
|
994
1052
|
}
|
|
995
1053
|
clock.tick = function tick(tickValue) {
|
|
996
1054
|
return doTick(tickValue, false);
|
|
997
1055
|
};
|
|
998
|
-
if (void 0 !== _global.Promise) clock.tickAsync = function tickAsync(tickValue) {
|
|
999
|
-
return pauseAutoTickUntilFinished(new _global.Promise(function(resolve, reject) {
|
|
1000
|
-
originalSetTimeout(function() {
|
|
1001
|
-
try {
|
|
1002
|
-
doTick(tickValue, true, resolve, reject);
|
|
1003
|
-
} catch (e) {
|
|
1004
|
-
reject(e);
|
|
1005
|
-
}
|
|
1006
|
-
});
|
|
1007
|
-
}));
|
|
1008
|
-
};
|
|
1009
1056
|
clock.next = function next() {
|
|
1010
1057
|
runJobs(clock);
|
|
1011
1058
|
const timer = firstTimer(clock);
|
|
@@ -1020,46 +1067,31 @@ __webpack_require__.add({
|
|
|
1020
1067
|
clock.duringTick = false;
|
|
1021
1068
|
}
|
|
1022
1069
|
};
|
|
1023
|
-
|
|
1070
|
+
function runAsyncWithNativeTimeout(callback) {
|
|
1024
1071
|
return pauseAutoTickUntilFinished(new _global.Promise(function(resolve, reject) {
|
|
1025
1072
|
originalSetTimeout(function() {
|
|
1026
1073
|
try {
|
|
1027
|
-
|
|
1028
|
-
if (!timer) return void resolve(clock.now);
|
|
1029
|
-
let err;
|
|
1030
|
-
clock.duringTick = true;
|
|
1031
|
-
clock.now = timer.callAt;
|
|
1032
|
-
try {
|
|
1033
|
-
callTimer(clock, timer);
|
|
1034
|
-
} catch (e) {
|
|
1035
|
-
err = e;
|
|
1036
|
-
}
|
|
1037
|
-
clock.duringTick = false;
|
|
1038
|
-
originalSetTimeout(function() {
|
|
1039
|
-
if (err) reject(err);
|
|
1040
|
-
else resolve(clock.now);
|
|
1041
|
-
});
|
|
1074
|
+
callback(resolve, reject);
|
|
1042
1075
|
} catch (e) {
|
|
1043
1076
|
reject(e);
|
|
1044
1077
|
}
|
|
1045
1078
|
});
|
|
1046
1079
|
}));
|
|
1047
|
-
}
|
|
1080
|
+
}
|
|
1048
1081
|
clock.runAll = function runAll() {
|
|
1049
|
-
let numTimers, i;
|
|
1050
1082
|
runJobs(clock);
|
|
1051
|
-
for(i = 0; i < clock.loopLimit; i++){
|
|
1083
|
+
for(let i = 0; i < clock.loopLimit; i++){
|
|
1052
1084
|
if (!clock.timers) {
|
|
1053
|
-
resetIsNearInfiniteLimit();
|
|
1085
|
+
resetIsNearInfiniteLimit(clock);
|
|
1054
1086
|
return clock.now;
|
|
1055
1087
|
}
|
|
1056
|
-
numTimers = clock.timerHeap.timers.length;
|
|
1088
|
+
const numTimers = clock.timerHeap.timers.length;
|
|
1057
1089
|
if (0 === numTimers) {
|
|
1058
|
-
resetIsNearInfiniteLimit();
|
|
1090
|
+
resetIsNearInfiniteLimit(clock);
|
|
1059
1091
|
return clock.now;
|
|
1060
1092
|
}
|
|
1061
|
-
clock.next();
|
|
1062
1093
|
checkIsNearInfiniteLimit(clock, i);
|
|
1094
|
+
clock.next();
|
|
1063
1095
|
}
|
|
1064
1096
|
const excessJob = firstTimer(clock);
|
|
1065
1097
|
throw getInfiniteLoopError(clock, excessJob);
|
|
@@ -1067,42 +1099,6 @@ __webpack_require__.add({
|
|
|
1067
1099
|
clock.runToFrame = function runToFrame() {
|
|
1068
1100
|
return clock.tick(getTimeToNextFrame());
|
|
1069
1101
|
};
|
|
1070
|
-
if (void 0 !== _global.Promise) clock.runAllAsync = function runAllAsync() {
|
|
1071
|
-
return pauseAutoTickUntilFinished(new _global.Promise(function(resolve, reject) {
|
|
1072
|
-
let i = 0;
|
|
1073
|
-
function doRun() {
|
|
1074
|
-
originalSetTimeout(function() {
|
|
1075
|
-
try {
|
|
1076
|
-
runJobs(clock);
|
|
1077
|
-
let numTimers;
|
|
1078
|
-
if (i < clock.loopLimit) {
|
|
1079
|
-
if (!clock.timerHeap) {
|
|
1080
|
-
resetIsNearInfiniteLimit();
|
|
1081
|
-
resolve(clock.now);
|
|
1082
|
-
return;
|
|
1083
|
-
}
|
|
1084
|
-
numTimers = clock.timerHeap.timers.length;
|
|
1085
|
-
if (0 === numTimers) {
|
|
1086
|
-
resetIsNearInfiniteLimit();
|
|
1087
|
-
resolve(clock.now);
|
|
1088
|
-
return;
|
|
1089
|
-
}
|
|
1090
|
-
clock.next();
|
|
1091
|
-
i++;
|
|
1092
|
-
doRun();
|
|
1093
|
-
checkIsNearInfiniteLimit(clock, i);
|
|
1094
|
-
return;
|
|
1095
|
-
}
|
|
1096
|
-
const excessJob = firstTimer(clock);
|
|
1097
|
-
reject(getInfiniteLoopError(clock, excessJob));
|
|
1098
|
-
} catch (e) {
|
|
1099
|
-
reject(e);
|
|
1100
|
-
}
|
|
1101
|
-
});
|
|
1102
|
-
}
|
|
1103
|
-
doRun();
|
|
1104
|
-
}));
|
|
1105
|
-
};
|
|
1106
1102
|
clock.runToLast = function runToLast() {
|
|
1107
1103
|
const timer = lastTimer(clock);
|
|
1108
1104
|
if (!timer) {
|
|
@@ -1111,25 +1107,82 @@ __webpack_require__.add({
|
|
|
1111
1107
|
}
|
|
1112
1108
|
return clock.tick(timer.callAt - clock.now);
|
|
1113
1109
|
};
|
|
1114
|
-
if (void 0 !== _global.Promise)
|
|
1115
|
-
|
|
1116
|
-
|
|
1110
|
+
if (void 0 !== _global.Promise) {
|
|
1111
|
+
clock.tickAsync = function tickAsync(tickValue) {
|
|
1112
|
+
return runAsyncWithNativeTimeout(function(resolve, reject) {
|
|
1113
|
+
doTick(tickValue, true, resolve, reject);
|
|
1114
|
+
});
|
|
1115
|
+
};
|
|
1116
|
+
clock.nextAsync = function nextAsync() {
|
|
1117
|
+
return runAsyncWithNativeTimeout(function(resolve, reject) {
|
|
1118
|
+
const timer = firstTimer(clock);
|
|
1119
|
+
if (!timer) return void resolve(clock.now);
|
|
1120
|
+
let err;
|
|
1121
|
+
clock.duringTick = true;
|
|
1122
|
+
clock.now = timer.callAt;
|
|
1117
1123
|
try {
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1124
|
+
callTimer(clock, timer);
|
|
1125
|
+
} catch (e) {
|
|
1126
|
+
err = e;
|
|
1127
|
+
}
|
|
1128
|
+
clock.duringTick = false;
|
|
1129
|
+
originalSetTimeout(function() {
|
|
1130
|
+
if (err) reject(err);
|
|
1131
|
+
else resolve(clock.now);
|
|
1132
|
+
});
|
|
1133
|
+
});
|
|
1134
|
+
};
|
|
1135
|
+
clock.runAllAsync = function runAllAsync() {
|
|
1136
|
+
let i = 0;
|
|
1137
|
+
function doRun(resolve, reject) {
|
|
1138
|
+
try {
|
|
1139
|
+
runJobs(clock);
|
|
1140
|
+
let numTimers;
|
|
1141
|
+
if (i < clock.loopLimit) {
|
|
1142
|
+
if (!clock.timerHeap) {
|
|
1143
|
+
resetIsNearInfiniteLimit(clock);
|
|
1144
|
+
resolve(clock.now);
|
|
1145
|
+
return;
|
|
1146
|
+
}
|
|
1147
|
+
numTimers = clock.timerHeap.timers.length;
|
|
1148
|
+
if (0 === numTimers) {
|
|
1149
|
+
resetIsNearInfiniteLimit(clock);
|
|
1150
|
+
resolve(clock.now);
|
|
1151
|
+
return;
|
|
1152
|
+
}
|
|
1153
|
+
checkIsNearInfiniteLimit(clock, i);
|
|
1154
|
+
clock.next();
|
|
1155
|
+
i++;
|
|
1156
|
+
originalSetTimeout(function() {
|
|
1157
|
+
doRun(resolve, reject);
|
|
1158
|
+
});
|
|
1159
|
+
return;
|
|
1122
1160
|
}
|
|
1123
|
-
|
|
1161
|
+
const excessJob = firstTimer(clock);
|
|
1162
|
+
reject(getInfiniteLoopError(clock, excessJob));
|
|
1124
1163
|
} catch (e) {
|
|
1125
1164
|
reject(e);
|
|
1126
1165
|
}
|
|
1166
|
+
}
|
|
1167
|
+
return runAsyncWithNativeTimeout(function(resolve, reject) {
|
|
1168
|
+
doRun(resolve, reject);
|
|
1127
1169
|
});
|
|
1128
|
-
}
|
|
1129
|
-
|
|
1170
|
+
};
|
|
1171
|
+
clock.runToLastAsync = function runToLastAsync() {
|
|
1172
|
+
return runAsyncWithNativeTimeout(function(resolve) {
|
|
1173
|
+
const timer = lastTimer(clock);
|
|
1174
|
+
if (!timer) {
|
|
1175
|
+
runJobs(clock);
|
|
1176
|
+
resolve(clock.now);
|
|
1177
|
+
return;
|
|
1178
|
+
}
|
|
1179
|
+
resolve(clock.tickAsync(timer.callAt - clock.now));
|
|
1180
|
+
});
|
|
1181
|
+
};
|
|
1182
|
+
}
|
|
1130
1183
|
clock.reset = function reset() {
|
|
1131
1184
|
nanos = 0;
|
|
1132
|
-
clock.timers =
|
|
1185
|
+
clock.timers = new Map();
|
|
1133
1186
|
clock.timerHeap = new TimerHeap();
|
|
1134
1187
|
clock.jobs = [];
|
|
1135
1188
|
clock.now = start;
|
|
@@ -1137,25 +1190,22 @@ __webpack_require__.add({
|
|
|
1137
1190
|
clock.setSystemTime = function setSystemTime(systemTime) {
|
|
1138
1191
|
const newNow = getEpoch(systemTime);
|
|
1139
1192
|
const difference = newNow - clock.now;
|
|
1140
|
-
let id, timer;
|
|
1141
1193
|
adjustedSystemTime[0] = adjustedSystemTime[0] + difference;
|
|
1142
1194
|
adjustedSystemTime[1] = adjustedSystemTime[1] + nanos;
|
|
1143
1195
|
clock.now = newNow;
|
|
1144
1196
|
nanos = 0;
|
|
1145
|
-
|
|
1146
|
-
timer = clock.timers[id];
|
|
1197
|
+
forEachActiveTimer(clock, (timer)=>{
|
|
1147
1198
|
timer.createdAt += difference;
|
|
1148
1199
|
timer.callAt += difference;
|
|
1149
|
-
}
|
|
1200
|
+
});
|
|
1150
1201
|
};
|
|
1151
1202
|
clock.jump = function jump(tickValue) {
|
|
1152
1203
|
const msFloat = "number" == typeof tickValue ? tickValue : parseTime(tickValue);
|
|
1153
1204
|
const ms = Math.floor(msFloat);
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
}
|
|
1205
|
+
forEachActiveTimer(clock, (timer)=>{
|
|
1206
|
+
if (clock.now + ms > timer.callAt) timer.callAt = clock.now + ms;
|
|
1207
|
+
});
|
|
1208
|
+
rebuildTimerHeap(clock);
|
|
1159
1209
|
clock.tick(ms);
|
|
1160
1210
|
return clock.now;
|
|
1161
1211
|
};
|
|
@@ -1216,7 +1266,7 @@ __webpack_require__.add({
|
|
|
1216
1266
|
clock.performance.mark = (name)=>new FakePerformanceEntry(name, "mark", 0, 0);
|
|
1217
1267
|
clock.performance.measure = (name)=>new FakePerformanceEntry(name, "measure", 0, 100);
|
|
1218
1268
|
clock.performance.timeOrigin = getEpoch(config.now);
|
|
1219
|
-
} else if ((config.toFake || []).includes("performance"))
|
|
1269
|
+
} else if ((config.toFake || []).includes("performance")) handleMissingTimer("performance");
|
|
1220
1270
|
}
|
|
1221
1271
|
if (_global === globalObject && timersModule) clock.timersModuleMethods = [];
|
|
1222
1272
|
if (_global === globalObject && timersPromisesModule) clock.timersPromisesModuleMethods = [];
|
|
@@ -1471,7 +1521,7 @@ __webpack_require__.add({
|
|
|
1471
1521
|
});
|
|
1472
1522
|
const RealDate = Date;
|
|
1473
1523
|
const loadFakeTimersModule = ()=>{
|
|
1474
|
-
const loaded = __webpack_require__("../../node_modules/.pnpm/@sinonjs+fake-timers@15.
|
|
1524
|
+
const loaded = __webpack_require__("../../node_modules/.pnpm/@sinonjs+fake-timers@15.3.0/node_modules/@sinonjs/fake-timers/src/fake-timers-src.js");
|
|
1475
1525
|
return {
|
|
1476
1526
|
withGlobal: loaded.withGlobal
|
|
1477
1527
|
};
|
|
@@ -1538,7 +1588,7 @@ class FakeTimers {
|
|
|
1538
1588
|
}
|
|
1539
1589
|
useFakeTimers(fakeTimersConfig = {}) {
|
|
1540
1590
|
if (this._fakingTime) this._clock.uninstall();
|
|
1541
|
-
const toFake = Object.keys(this._fakeTimers.timers).filter((timer)=>'nextTick' !== timer && 'queueMicrotask' !== timer);
|
|
1591
|
+
const toFake = Object.keys(this._fakeTimers.timers).filter((timer)=>'Intl' !== timer && 'nextTick' !== timer && 'queueMicrotask' !== timer);
|
|
1542
1592
|
const isChildProcess = "u" > typeof process && !!process.send;
|
|
1543
1593
|
if (this._config?.toFake?.includes('nextTick') && isChildProcess) throw new Error('process.nextTick cannot be mocked inside child_process');
|
|
1544
1594
|
this._clock = this._fakeTimers.install({
|