@rstest/core 0.9.5 → 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/LICENSE.md +80 -0
- package/dist/0~8843.js +15 -1
- package/dist/{0~lib.js → 0~@babel/code-frame.js} +2 -2
- package/dist/0~@clack/prompts.js +1044 -0
- package/dist/0~browserLoader.js +1 -1
- package/dist/0~browser~1.js +17 -17
- package/dist/0~checkThresholds.js +1 -1
- package/dist/0~chokidar.js +43 -42
- package/dist/0~fake-timers.js +381 -228
- package/dist/0~generate.js +1 -2
- package/dist/0~listTests.js +67 -7
- package/dist/0~magic-string.es.js +1 -181
- package/dist/0~restart.js +1 -1
- package/dist/0~snapshot.js +1 -1
- package/dist/1255.js +11 -11
- package/dist/3145.js +275 -25
- package/dist/4411.js +127 -139
- package/dist/6830.js +1 -1
- package/dist/7290.js +15 -0
- package/dist/9743.js +1 -1
- package/dist/9784.js +1 -1
- package/dist/browser-runtime/2~fake-timers.js +389 -403
- package/dist/browser-runtime/2~magic-string.es.js +5 -191
- package/dist/browser-runtime/2~snapshot.js +2 -2
- package/dist/browser-runtime/723.js +77 -15
- package/dist/browser-runtime/index.d.ts +32 -62
- package/dist/browser.d.ts +32 -62
- package/dist/globalSetupWorker.js +1 -1
- package/dist/index.d.ts +56 -68
- package/dist/index.js +1 -1
- package/dist/worker.d.ts +18 -6
- package/dist/worker.js +1 -1
- package/globals.d.ts +1 -0
- package/package.json +13 -14
- package/dist/0~dist.js +0 -1014
- package/dist/4899.js +0 -11
- package/dist/browser-runtime/rslib-runtime.js +0 -49
- /package/dist/{rslib-runtime.js → 0~rslib-runtime.js} +0 -0
package/dist/0~fake-timers.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import "node:module";
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import "./4899.js";
|
|
2
|
+
import { __webpack_require__ } from "./0~rslib-runtime.js";
|
|
3
|
+
import "./7290.js";
|
|
5
4
|
__webpack_require__.add({
|
|
6
5
|
"../../node_modules/.pnpm/@sinonjs+commons@3.0.1/node_modules/@sinonjs/commons/lib/called-in-order.js" (module, __unused_rspack_exports, __webpack_require__) {
|
|
7
6
|
var every = __webpack_require__("../../node_modules/.pnpm/@sinonjs+commons@3.0.1/node_modules/@sinonjs/commons/lib/prototypes/array.js").every;
|
|
@@ -184,7 +183,7 @@ __webpack_require__.add({
|
|
|
184
183
|
}
|
|
185
184
|
module.exports = valueToString;
|
|
186
185
|
},
|
|
187
|
-
"../../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__) {
|
|
188
187
|
const globalObject = __webpack_require__("../../node_modules/.pnpm/@sinonjs+commons@3.0.1/node_modules/@sinonjs/commons/lib/index.js").global;
|
|
189
188
|
let timersModule, timersPromisesModule;
|
|
190
189
|
try {
|
|
@@ -217,11 +216,11 @@ __webpack_require__.add({
|
|
|
217
216
|
isPresent.performance = _global.performance && "function" == typeof _global.performance.now;
|
|
218
217
|
const hasPerformancePrototype = _global.Performance && (typeof _global.Performance).match(/^(function|object)$/);
|
|
219
218
|
const hasPerformanceConstructorPrototype = _global.performance && _global.performance.constructor && _global.performance.constructor.prototype;
|
|
220
|
-
isPresent.queueMicrotask =
|
|
219
|
+
isPresent.queueMicrotask = Object.prototype.hasOwnProperty.call(_global, "queueMicrotask");
|
|
221
220
|
isPresent.requestAnimationFrame = _global.requestAnimationFrame && "function" == typeof _global.requestAnimationFrame;
|
|
222
221
|
isPresent.cancelAnimationFrame = _global.cancelAnimationFrame && "function" == typeof _global.cancelAnimationFrame;
|
|
223
222
|
isPresent.requestIdleCallback = _global.requestIdleCallback && "function" == typeof _global.requestIdleCallback;
|
|
224
|
-
isPresent.
|
|
223
|
+
isPresent.cancelIdleCallback = _global.cancelIdleCallback && "function" == typeof _global.cancelIdleCallback;
|
|
225
224
|
isPresent.setImmediate = _global.setImmediate && "function" == typeof _global.setImmediate;
|
|
226
225
|
isPresent.clearImmediate = _global.clearImmediate && "function" == typeof _global.clearImmediate;
|
|
227
226
|
isPresent.Intl = _global.Intl && "object" == typeof _global.Intl;
|
|
@@ -229,6 +228,7 @@ __webpack_require__.add({
|
|
|
229
228
|
const NativeDate = _global.Date;
|
|
230
229
|
const NativeIntl = isPresent.Intl ? Object.defineProperties(Object.create(null), Object.getOwnPropertyDescriptors(_global.Intl)) : void 0;
|
|
231
230
|
let uniqueTimerId = idCounterStart;
|
|
231
|
+
let uniqueTimerOrder = 0;
|
|
232
232
|
if (void 0 === NativeDate) throw new Error("The global scope doesn't have a `Date` object (see https://github.com/sinonjs/sinon/issues/1852#issuecomment-419622780)");
|
|
233
233
|
isPresent.Date = true;
|
|
234
234
|
class FakePerformanceEntry {
|
|
@@ -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,63 +377,175 @@ __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
|
-
if (
|
|
393
|
-
|
|
394
|
-
}
|
|
395
|
-
if (isNearInfiniteLimit) timer.error = new Error();
|
|
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}`);
|
|
496
|
+
if (clock.isNearInfiniteLimit) timer.error = new Error();
|
|
396
497
|
timer.type = timer.immediate ? "Immediate" : "Timeout";
|
|
397
|
-
if (
|
|
498
|
+
if (Object.prototype.hasOwnProperty.call(timer, "delay")) {
|
|
398
499
|
if ("number" != typeof timer.delay) timer.delay = parseInt(timer.delay, 10);
|
|
399
500
|
if (!isNumberFinite(timer.delay)) timer.delay = 0;
|
|
400
501
|
timer.delay = timer.delay > maxTimeout ? 1 : timer.delay;
|
|
401
502
|
timer.delay = Math.max(0, timer.delay);
|
|
402
503
|
}
|
|
403
|
-
if (
|
|
504
|
+
if (Object.prototype.hasOwnProperty.call(timer, "interval")) {
|
|
404
505
|
timer.type = "Interval";
|
|
405
506
|
timer.interval = timer.interval > maxTimeout ? 1 : timer.interval;
|
|
406
507
|
}
|
|
407
|
-
if (
|
|
508
|
+
if (Object.prototype.hasOwnProperty.call(timer, "animation")) {
|
|
408
509
|
timer.type = "AnimationFrame";
|
|
409
510
|
timer.animation = true;
|
|
410
511
|
}
|
|
411
|
-
if (
|
|
412
|
-
timer.type = "IdleCallback";
|
|
413
|
-
timer.
|
|
512
|
+
if (Object.prototype.hasOwnProperty.call(timer, "requestIdleCallback")) {
|
|
513
|
+
if (!timer.delay) timer.type = "IdleCallback";
|
|
514
|
+
timer.requestIdleCallback = true;
|
|
515
|
+
}
|
|
516
|
+
ensureTimerState(clock);
|
|
517
|
+
while(hasTimer(clock, uniqueTimerId)){
|
|
518
|
+
uniqueTimerId++;
|
|
519
|
+
if (uniqueTimerId >= Number.MAX_SAFE_INTEGER) uniqueTimerId = idCounterStart;
|
|
414
520
|
}
|
|
415
|
-
if (!clock.timers) clock.timers = {};
|
|
416
521
|
timer.id = uniqueTimerId++;
|
|
522
|
+
if (uniqueTimerId >= Number.MAX_SAFE_INTEGER) uniqueTimerId = idCounterStart;
|
|
523
|
+
timer.order = uniqueTimerOrder++;
|
|
417
524
|
timer.createdAt = clock.now;
|
|
418
|
-
timer.callAt = clock.now + (parseInt(timer.delay) || (clock.duringTick ? 1 : 0));
|
|
419
|
-
clock
|
|
525
|
+
timer.callAt = clock.now + (parseInt(String(timer.delay)) || (clock.duringTick ? 1 : 0));
|
|
526
|
+
setTimer(clock, timer);
|
|
527
|
+
clock.timerHeap.push(timer);
|
|
420
528
|
if (addTimerReturnsObject) {
|
|
421
529
|
const res = {
|
|
422
530
|
refed: true,
|
|
423
531
|
ref: function() {
|
|
424
532
|
this.refed = true;
|
|
425
|
-
return
|
|
533
|
+
return this;
|
|
426
534
|
},
|
|
427
535
|
unref: function() {
|
|
428
536
|
this.refed = false;
|
|
429
|
-
return
|
|
537
|
+
return this;
|
|
430
538
|
},
|
|
431
539
|
hasRef: function() {
|
|
432
540
|
return this.refed;
|
|
433
541
|
},
|
|
434
542
|
refresh: function() {
|
|
435
|
-
timer.callAt = clock.now + (parseInt(timer.delay) || (clock.duringTick ? 1 : 0));
|
|
436
|
-
clock.
|
|
437
|
-
|
|
543
|
+
timer.callAt = clock.now + (parseInt(String(timer.delay)) || (clock.duringTick ? 1 : 0));
|
|
544
|
+
clock.timerHeap.remove(timer);
|
|
545
|
+
timer.order = uniqueTimerOrder++;
|
|
546
|
+
setTimer(clock, timer);
|
|
547
|
+
clock.timerHeap.push(timer);
|
|
548
|
+
return this;
|
|
438
549
|
},
|
|
439
550
|
[Symbol.toPrimitive]: function() {
|
|
440
551
|
return timer.id;
|
|
@@ -445,53 +556,53 @@ __webpack_require__.add({
|
|
|
445
556
|
return timer.id;
|
|
446
557
|
}
|
|
447
558
|
function compareTimers(a, b) {
|
|
559
|
+
if ("IdleCallback" === a.type && "IdleCallback" !== b.type) return 1;
|
|
560
|
+
if ("IdleCallback" !== a.type && "IdleCallback" === b.type) return -1;
|
|
448
561
|
if (a.callAt < b.callAt) return -1;
|
|
449
562
|
if (a.callAt > b.callAt) return 1;
|
|
450
563
|
if (a.immediate && !b.immediate) return -1;
|
|
451
564
|
if (!a.immediate && b.immediate) return 1;
|
|
565
|
+
if (a.order < b.order) return -1;
|
|
566
|
+
if (a.order > b.order) return 1;
|
|
452
567
|
if (a.createdAt < b.createdAt) return -1;
|
|
453
568
|
if (a.createdAt > b.createdAt) return 1;
|
|
454
569
|
if (a.id < b.id) return -1;
|
|
455
570
|
if (a.id > b.id) return 1;
|
|
571
|
+
return 0;
|
|
456
572
|
}
|
|
457
573
|
function firstTimerInRange(clock, from, to) {
|
|
458
|
-
|
|
574
|
+
if (!clock.timerHeap) return null;
|
|
575
|
+
const timers = clock.timerHeap.timers;
|
|
576
|
+
if (1 === timers.length && timers[0].requestIdleCallback) return timers[0];
|
|
577
|
+
const first = clock.timerHeap.peek();
|
|
578
|
+
if (first && inRange(from, to, first)) return first;
|
|
459
579
|
let timer = null;
|
|
460
|
-
let
|
|
461
|
-
for(id in timers)if (timers.hasOwnProperty(id)) {
|
|
462
|
-
isInRange = inRange(from, to, timers[id]);
|
|
463
|
-
if (isInRange && (!timer || 1 === compareTimers(timer, timers[id]))) timer = timers[id];
|
|
464
|
-
}
|
|
580
|
+
for(let i = 0; i < timers.length; i++)if (inRange(from, to, timers[i]) && (!timer || 1 === compareTimers(timer, timers[i]))) timer = timers[i];
|
|
465
581
|
return timer;
|
|
466
582
|
}
|
|
467
583
|
function firstTimer(clock) {
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
let id;
|
|
471
|
-
for(id in timers)if (timers.hasOwnProperty(id)) {
|
|
472
|
-
if (!timer || 1 === compareTimers(timer, timers[id])) timer = timers[id];
|
|
473
|
-
}
|
|
474
|
-
return timer;
|
|
584
|
+
if (!clock.timerHeap) return null;
|
|
585
|
+
return clock.timerHeap.peek() || null;
|
|
475
586
|
}
|
|
476
587
|
function lastTimer(clock) {
|
|
477
|
-
|
|
588
|
+
if (!clock.timerHeap) return null;
|
|
589
|
+
const timers = clock.timerHeap.timers;
|
|
478
590
|
let timer = null;
|
|
479
|
-
let
|
|
480
|
-
for(id in timers)if (timers.hasOwnProperty(id)) {
|
|
481
|
-
if (!timer || -1 === compareTimers(timer, timers[id])) timer = timers[id];
|
|
482
|
-
}
|
|
591
|
+
for(let i = 0; i < timers.length; i++)if (!timer || -1 === compareTimers(timer, timers[i])) timer = timers[i];
|
|
483
592
|
return timer;
|
|
484
593
|
}
|
|
485
594
|
function callTimer(clock, timer) {
|
|
486
|
-
if ("number" == typeof timer.interval)
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
(
|
|
492
|
-
|
|
493
|
-
|
|
595
|
+
if ("number" == typeof timer.interval) {
|
|
596
|
+
clock.timerHeap.remove(timer);
|
|
597
|
+
timer.callAt += timer.interval;
|
|
598
|
+
timer.order = uniqueTimerOrder++;
|
|
599
|
+
if (clock.isNearInfiniteLimit) timer.error = new Error();
|
|
600
|
+
clock.timerHeap.push(timer);
|
|
601
|
+
} else {
|
|
602
|
+
deleteTimer(clock, timer.id);
|
|
603
|
+
clock.timerHeap.remove(timer);
|
|
494
604
|
}
|
|
605
|
+
if ("function" == typeof timer.func) timer.func.apply(null, timer.args);
|
|
495
606
|
}
|
|
496
607
|
function getClearHandler(ttype) {
|
|
497
608
|
if ("IdleCallback" === ttype || "AnimationFrame" === ttype) return `cancel${ttype}`;
|
|
@@ -510,7 +621,6 @@ __webpack_require__.add({
|
|
|
510
621
|
const warnOnce = createWarnOnce();
|
|
511
622
|
function clearTimer(clock, timerId, ttype) {
|
|
512
623
|
if (!timerId) return;
|
|
513
|
-
if (!clock.timers) clock.timers = {};
|
|
514
624
|
const id = Number(timerId);
|
|
515
625
|
if (Number.isNaN(id) || id < idCounterStart) {
|
|
516
626
|
const handlerName = getClearHandler(ttype);
|
|
@@ -521,10 +631,12 @@ __webpack_require__.add({
|
|
|
521
631
|
const stackTrace = new Error().stack.split("\n").slice(1).join("\n");
|
|
522
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}`);
|
|
523
633
|
}
|
|
524
|
-
if (clock
|
|
525
|
-
const timer = clock
|
|
526
|
-
if (timer.type === ttype || "Timeout" === timer.type && "Interval" === ttype || "Interval" === timer.type && "Timeout" === ttype)
|
|
527
|
-
|
|
634
|
+
if (hasTimer(clock, id)) {
|
|
635
|
+
const timer = getTimer(clock, id);
|
|
636
|
+
if (timer.type === ttype || "Timeout" === timer.type && "Interval" === ttype || "Interval" === timer.type && "Timeout" === ttype) {
|
|
637
|
+
deleteTimer(clock, id);
|
|
638
|
+
clock.timerHeap.remove(timer);
|
|
639
|
+
} else {
|
|
528
640
|
const clear = getClearHandler(ttype);
|
|
529
641
|
const schedule = getScheduleHandler(timer.type);
|
|
530
642
|
throw new Error(`Cannot clear timer: timer created with ${schedule}() but cleared with ${clear}()`);
|
|
@@ -543,7 +655,7 @@ __webpack_require__.add({
|
|
|
543
655
|
const originalPerfDescriptor = Object.getOwnPropertyDescriptor(clock, `_${method}`);
|
|
544
656
|
if (originalPerfDescriptor && originalPerfDescriptor.get && !originalPerfDescriptor.set) Object.defineProperty(_global, method, originalPerfDescriptor);
|
|
545
657
|
else if (originalPerfDescriptor.configurable) _global[method] = clock[`_${method}`];
|
|
546
|
-
} else if (
|
|
658
|
+
} else if (clock[method] && clock[method].hasOwnProperty) _global[method] = clock[`_${method}`];
|
|
547
659
|
else try {
|
|
548
660
|
delete _global[method];
|
|
549
661
|
} catch (ignore) {}
|
|
@@ -556,19 +668,19 @@ __webpack_require__.add({
|
|
|
556
668
|
timersPromisesModule[entry.methodName] = entry.original;
|
|
557
669
|
}
|
|
558
670
|
}
|
|
559
|
-
clock.setTickMode(
|
|
671
|
+
clock.setTickMode({
|
|
672
|
+
mode: "manual"
|
|
673
|
+
});
|
|
560
674
|
clock.methods = [];
|
|
561
675
|
for (const [listener, signal] of clock.abortListenerMap.entries()){
|
|
562
676
|
signal.removeEventListener("abort", listener);
|
|
563
677
|
clock.abortListenerMap.delete(listener);
|
|
564
678
|
}
|
|
565
|
-
if (!clock.
|
|
566
|
-
return
|
|
567
|
-
return clock.timers[key];
|
|
568
|
-
});
|
|
679
|
+
if (!clock.timerHeap) return [];
|
|
680
|
+
return clock.timerHeap.timers.slice();
|
|
569
681
|
}
|
|
570
682
|
function hijackMethod(target, method, clock) {
|
|
571
|
-
clock[method].
|
|
683
|
+
clock[method].hasOwnProperty = Object.prototype.hasOwnProperty.call(target, method);
|
|
572
684
|
clock[`_${method}`] = target[method];
|
|
573
685
|
if ("Date" === method) target[method] = clock[method];
|
|
574
686
|
else if ("Intl" === method) target[method] = clock[method];
|
|
@@ -623,6 +735,7 @@ __webpack_require__.add({
|
|
|
623
735
|
now: start,
|
|
624
736
|
Date: createDate(),
|
|
625
737
|
loopLimit: loopLimit,
|
|
738
|
+
isNearInfiniteLimit: false,
|
|
626
739
|
tickMode: {
|
|
627
740
|
mode: "manual",
|
|
628
741
|
counter: 0,
|
|
@@ -687,7 +800,7 @@ __webpack_require__.add({
|
|
|
687
800
|
const channel = new MessageChannel();
|
|
688
801
|
await new Promise((resolve)=>{
|
|
689
802
|
channel.port1.onmessage = ()=>{
|
|
690
|
-
resolve();
|
|
803
|
+
resolve(void 0);
|
|
691
804
|
channel.port1.close();
|
|
692
805
|
};
|
|
693
806
|
channel.port2.postMessage(void 0);
|
|
@@ -716,14 +829,23 @@ __webpack_require__.add({
|
|
|
716
829
|
});
|
|
717
830
|
});
|
|
718
831
|
}
|
|
719
|
-
|
|
832
|
+
function getTimeToNextIdlePeriod() {
|
|
720
833
|
let timeToNextIdlePeriod = 0;
|
|
721
834
|
if (clock.countTimers() > 0) timeToNextIdlePeriod = 50;
|
|
835
|
+
return timeToNextIdlePeriod;
|
|
836
|
+
}
|
|
837
|
+
clock.requestIdleCallback = function requestIdleCallback(func, { timeout } = {}) {
|
|
838
|
+
const idleDeadline = {
|
|
839
|
+
didTimeout: true,
|
|
840
|
+
timeRemaining: getTimeToNextIdlePeriod
|
|
841
|
+
};
|
|
722
842
|
const result = addTimer(clock, {
|
|
723
843
|
func: func,
|
|
724
|
-
args:
|
|
725
|
-
|
|
726
|
-
|
|
844
|
+
args: [
|
|
845
|
+
idleDeadline
|
|
846
|
+
],
|
|
847
|
+
delay: timeout,
|
|
848
|
+
requestIdleCallback: true
|
|
727
849
|
});
|
|
728
850
|
return Number(result);
|
|
729
851
|
};
|
|
@@ -755,7 +877,7 @@ __webpack_require__.add({
|
|
|
755
877
|
return enqueueJob(clock, {
|
|
756
878
|
func: func,
|
|
757
879
|
args: Array.prototype.slice.call(arguments, 1),
|
|
758
|
-
error: isNearInfiniteLimit ? new Error() : null
|
|
880
|
+
error: clock.isNearInfiniteLimit ? new Error() : null
|
|
759
881
|
});
|
|
760
882
|
};
|
|
761
883
|
clock.queueMicrotask = function queueMicrotask(func) {
|
|
@@ -797,7 +919,7 @@ __webpack_require__.add({
|
|
|
797
919
|
};
|
|
798
920
|
}
|
|
799
921
|
clock.countTimers = function countTimers() {
|
|
800
|
-
return
|
|
922
|
+
return (clock.timerHeap ? clock.timerHeap.timers.length : 0) + (clock.jobs || []).length;
|
|
801
923
|
};
|
|
802
924
|
clock.requestAnimationFrame = function requestAnimationFrame(func) {
|
|
803
925
|
const result = addTimer(clock, {
|
|
@@ -818,7 +940,7 @@ __webpack_require__.add({
|
|
|
818
940
|
clock.runMicrotasks = function runMicrotasks() {
|
|
819
941
|
runJobs(clock);
|
|
820
942
|
};
|
|
821
|
-
function
|
|
943
|
+
function createTickState(tickValue) {
|
|
822
944
|
const msFloat = "number" == typeof tickValue ? tickValue : parseTime(tickValue);
|
|
823
945
|
const ms = Math.floor(msFloat);
|
|
824
946
|
const remainder = nanoRemainder(msFloat);
|
|
@@ -829,92 +951,108 @@ __webpack_require__.add({
|
|
|
829
951
|
tickTo += 1;
|
|
830
952
|
nanosTotal -= 1e6;
|
|
831
953
|
}
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
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) {
|
|
839
967
|
if (oldNow !== clock.now) {
|
|
840
|
-
|
|
841
|
-
|
|
968
|
+
const difference = clock.now - oldNow;
|
|
969
|
+
state.tickFrom += difference;
|
|
970
|
+
state.tickTo += difference;
|
|
971
|
+
if (options && options.includePrevious) state.previous += difference;
|
|
842
972
|
}
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
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;
|
|
858
1000
|
}
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
tickFrom += clock.now - oldNow;
|
|
865
|
-
tickTo += clock.now - oldNow;
|
|
866
|
-
}
|
|
867
|
-
clock.duringTick = false;
|
|
868
|
-
timer = firstTimerInRange(clock, tickFrom, tickTo);
|
|
869
|
-
if (timer) try {
|
|
870
|
-
clock.tick(tickTo - clock.now);
|
|
871
|
-
} catch (e) {
|
|
872
|
-
firstException = firstException || e;
|
|
873
|
-
}
|
|
874
|
-
else {
|
|
875
|
-
clock.now = tickTo;
|
|
876
|
-
nanos = nanosTotal;
|
|
1001
|
+
if (isAsync) {
|
|
1002
|
+
originalSetTimeout(nextPromiseTick);
|
|
1003
|
+
return true;
|
|
1004
|
+
}
|
|
1005
|
+
compensationCheck();
|
|
877
1006
|
}
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
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;
|
|
881
1021
|
}
|
|
882
|
-
|
|
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() {
|
|
883
1037
|
try {
|
|
884
1038
|
compensationCheck();
|
|
885
|
-
|
|
1039
|
+
selectNextTimerInRange(state);
|
|
886
1040
|
doTickInner();
|
|
887
1041
|
} catch (e) {
|
|
888
1042
|
reject(e);
|
|
889
1043
|
}
|
|
890
1044
|
};
|
|
891
|
-
|
|
892
|
-
if (
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
};
|
|
898
|
-
postTimerCall = function() {
|
|
899
|
-
timer = firstTimerInRange(clock, previous, tickTo);
|
|
900
|
-
previous = tickFrom;
|
|
901
|
-
};
|
|
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
|
+
}
|
|
902
1051
|
return doTickInner();
|
|
903
1052
|
}
|
|
904
1053
|
clock.tick = function tick(tickValue) {
|
|
905
1054
|
return doTick(tickValue, false);
|
|
906
1055
|
};
|
|
907
|
-
if (void 0 !== _global.Promise) clock.tickAsync = function tickAsync(tickValue) {
|
|
908
|
-
return pauseAutoTickUntilFinished(new _global.Promise(function(resolve, reject) {
|
|
909
|
-
originalSetTimeout(function() {
|
|
910
|
-
try {
|
|
911
|
-
doTick(tickValue, true, resolve, reject);
|
|
912
|
-
} catch (e) {
|
|
913
|
-
reject(e);
|
|
914
|
-
}
|
|
915
|
-
});
|
|
916
|
-
}));
|
|
917
|
-
};
|
|
918
1056
|
clock.next = function next() {
|
|
919
1057
|
runJobs(clock);
|
|
920
1058
|
const timer = firstTimer(clock);
|
|
@@ -929,46 +1067,31 @@ __webpack_require__.add({
|
|
|
929
1067
|
clock.duringTick = false;
|
|
930
1068
|
}
|
|
931
1069
|
};
|
|
932
|
-
|
|
1070
|
+
function runAsyncWithNativeTimeout(callback) {
|
|
933
1071
|
return pauseAutoTickUntilFinished(new _global.Promise(function(resolve, reject) {
|
|
934
1072
|
originalSetTimeout(function() {
|
|
935
1073
|
try {
|
|
936
|
-
|
|
937
|
-
if (!timer) return void resolve(clock.now);
|
|
938
|
-
let err;
|
|
939
|
-
clock.duringTick = true;
|
|
940
|
-
clock.now = timer.callAt;
|
|
941
|
-
try {
|
|
942
|
-
callTimer(clock, timer);
|
|
943
|
-
} catch (e) {
|
|
944
|
-
err = e;
|
|
945
|
-
}
|
|
946
|
-
clock.duringTick = false;
|
|
947
|
-
originalSetTimeout(function() {
|
|
948
|
-
if (err) reject(err);
|
|
949
|
-
else resolve(clock.now);
|
|
950
|
-
});
|
|
1074
|
+
callback(resolve, reject);
|
|
951
1075
|
} catch (e) {
|
|
952
1076
|
reject(e);
|
|
953
1077
|
}
|
|
954
1078
|
});
|
|
955
1079
|
}));
|
|
956
|
-
}
|
|
1080
|
+
}
|
|
957
1081
|
clock.runAll = function runAll() {
|
|
958
|
-
let numTimers, i;
|
|
959
1082
|
runJobs(clock);
|
|
960
|
-
for(i = 0; i < clock.loopLimit; i++){
|
|
1083
|
+
for(let i = 0; i < clock.loopLimit; i++){
|
|
961
1084
|
if (!clock.timers) {
|
|
962
|
-
resetIsNearInfiniteLimit();
|
|
1085
|
+
resetIsNearInfiniteLimit(clock);
|
|
963
1086
|
return clock.now;
|
|
964
1087
|
}
|
|
965
|
-
numTimers =
|
|
1088
|
+
const numTimers = clock.timerHeap.timers.length;
|
|
966
1089
|
if (0 === numTimers) {
|
|
967
|
-
resetIsNearInfiniteLimit();
|
|
1090
|
+
resetIsNearInfiniteLimit(clock);
|
|
968
1091
|
return clock.now;
|
|
969
1092
|
}
|
|
970
|
-
clock.next();
|
|
971
1093
|
checkIsNearInfiniteLimit(clock, i);
|
|
1094
|
+
clock.next();
|
|
972
1095
|
}
|
|
973
1096
|
const excessJob = firstTimer(clock);
|
|
974
1097
|
throw getInfiniteLoopError(clock, excessJob);
|
|
@@ -976,42 +1099,6 @@ __webpack_require__.add({
|
|
|
976
1099
|
clock.runToFrame = function runToFrame() {
|
|
977
1100
|
return clock.tick(getTimeToNextFrame());
|
|
978
1101
|
};
|
|
979
|
-
if (void 0 !== _global.Promise) clock.runAllAsync = function runAllAsync() {
|
|
980
|
-
return pauseAutoTickUntilFinished(new _global.Promise(function(resolve, reject) {
|
|
981
|
-
let i = 0;
|
|
982
|
-
function doRun() {
|
|
983
|
-
originalSetTimeout(function() {
|
|
984
|
-
try {
|
|
985
|
-
runJobs(clock);
|
|
986
|
-
let numTimers;
|
|
987
|
-
if (i < clock.loopLimit) {
|
|
988
|
-
if (!clock.timers) {
|
|
989
|
-
resetIsNearInfiniteLimit();
|
|
990
|
-
resolve(clock.now);
|
|
991
|
-
return;
|
|
992
|
-
}
|
|
993
|
-
numTimers = Object.keys(clock.timers).length;
|
|
994
|
-
if (0 === numTimers) {
|
|
995
|
-
resetIsNearInfiniteLimit();
|
|
996
|
-
resolve(clock.now);
|
|
997
|
-
return;
|
|
998
|
-
}
|
|
999
|
-
clock.next();
|
|
1000
|
-
i++;
|
|
1001
|
-
doRun();
|
|
1002
|
-
checkIsNearInfiniteLimit(clock, i);
|
|
1003
|
-
return;
|
|
1004
|
-
}
|
|
1005
|
-
const excessJob = firstTimer(clock);
|
|
1006
|
-
reject(getInfiniteLoopError(clock, excessJob));
|
|
1007
|
-
} catch (e) {
|
|
1008
|
-
reject(e);
|
|
1009
|
-
}
|
|
1010
|
-
});
|
|
1011
|
-
}
|
|
1012
|
-
doRun();
|
|
1013
|
-
}));
|
|
1014
|
-
};
|
|
1015
1102
|
clock.runToLast = function runToLast() {
|
|
1016
1103
|
const timer = lastTimer(clock);
|
|
1017
1104
|
if (!timer) {
|
|
@@ -1020,47 +1107,107 @@ __webpack_require__.add({
|
|
|
1020
1107
|
}
|
|
1021
1108
|
return clock.tick(timer.callAt - clock.now);
|
|
1022
1109
|
};
|
|
1023
|
-
if (void 0 !== _global.Promise)
|
|
1024
|
-
|
|
1025
|
-
|
|
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;
|
|
1026
1123
|
try {
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
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;
|
|
1031
1160
|
}
|
|
1032
|
-
|
|
1161
|
+
const excessJob = firstTimer(clock);
|
|
1162
|
+
reject(getInfiniteLoopError(clock, excessJob));
|
|
1033
1163
|
} catch (e) {
|
|
1034
1164
|
reject(e);
|
|
1035
1165
|
}
|
|
1166
|
+
}
|
|
1167
|
+
return runAsyncWithNativeTimeout(function(resolve, reject) {
|
|
1168
|
+
doRun(resolve, reject);
|
|
1036
1169
|
});
|
|
1037
|
-
}
|
|
1038
|
-
|
|
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
|
+
}
|
|
1039
1183
|
clock.reset = function reset() {
|
|
1040
1184
|
nanos = 0;
|
|
1041
|
-
clock.timers =
|
|
1185
|
+
clock.timers = new Map();
|
|
1186
|
+
clock.timerHeap = new TimerHeap();
|
|
1042
1187
|
clock.jobs = [];
|
|
1043
1188
|
clock.now = start;
|
|
1044
1189
|
};
|
|
1045
1190
|
clock.setSystemTime = function setSystemTime(systemTime) {
|
|
1046
1191
|
const newNow = getEpoch(systemTime);
|
|
1047
1192
|
const difference = newNow - clock.now;
|
|
1048
|
-
let id, timer;
|
|
1049
1193
|
adjustedSystemTime[0] = adjustedSystemTime[0] + difference;
|
|
1050
1194
|
adjustedSystemTime[1] = adjustedSystemTime[1] + nanos;
|
|
1051
1195
|
clock.now = newNow;
|
|
1052
1196
|
nanos = 0;
|
|
1053
|
-
|
|
1054
|
-
timer = clock.timers[id];
|
|
1197
|
+
forEachActiveTimer(clock, (timer)=>{
|
|
1055
1198
|
timer.createdAt += difference;
|
|
1056
1199
|
timer.callAt += difference;
|
|
1057
|
-
}
|
|
1200
|
+
});
|
|
1058
1201
|
};
|
|
1059
1202
|
clock.jump = function jump(tickValue) {
|
|
1060
1203
|
const msFloat = "number" == typeof tickValue ? tickValue : parseTime(tickValue);
|
|
1061
1204
|
const ms = Math.floor(msFloat);
|
|
1062
|
-
|
|
1205
|
+
forEachActiveTimer(clock, (timer)=>{
|
|
1206
|
+
if (clock.now + ms > timer.callAt) timer.callAt = clock.now + ms;
|
|
1207
|
+
});
|
|
1208
|
+
rebuildTimerHeap(clock);
|
|
1063
1209
|
clock.tick(ms);
|
|
1210
|
+
return clock.now;
|
|
1064
1211
|
};
|
|
1065
1212
|
if (isPresent.performance) {
|
|
1066
1213
|
clock.performance = Object.create(null);
|
|
@@ -1081,6 +1228,9 @@ __webpack_require__.add({
|
|
|
1081
1228
|
config.shouldAdvanceTime = config.shouldAdvanceTime || false;
|
|
1082
1229
|
config.advanceTimeDelta = config.advanceTimeDelta || 20;
|
|
1083
1230
|
config.shouldClearNativeTimers = config.shouldClearNativeTimers || false;
|
|
1231
|
+
const hasToFake = Object.prototype.hasOwnProperty.call(config, "toFake");
|
|
1232
|
+
const hasToNotFake = Object.prototype.hasOwnProperty.call(config, "toNotFake");
|
|
1233
|
+
if (hasToFake && hasToNotFake) throw new TypeError("config.toFake and config.toNotFake cannot be used together");
|
|
1084
1234
|
if (config.target) throw new TypeError("config.target is no longer supported. Use `withGlobal(target)` instead.");
|
|
1085
1235
|
function handleMissingTimer(timer) {
|
|
1086
1236
|
if (config.ignoreMissingTimers) return;
|
|
@@ -1093,8 +1243,13 @@ __webpack_require__.add({
|
|
|
1093
1243
|
return uninstall(clock);
|
|
1094
1244
|
};
|
|
1095
1245
|
clock.abortListenerMap = new Map();
|
|
1096
|
-
|
|
1097
|
-
|
|
1246
|
+
if (hasToFake) {
|
|
1247
|
+
clock.methods = config.toFake || [];
|
|
1248
|
+
if (0 === clock.methods.length) clock.methods = Object.keys(timers);
|
|
1249
|
+
} else if (hasToNotFake) {
|
|
1250
|
+
const methodsToNotFake = config.toNotFake || [];
|
|
1251
|
+
clock.methods = Object.keys(timers).filter((method)=>!methodsToNotFake.includes(method));
|
|
1252
|
+
} else clock.methods = Object.keys(timers);
|
|
1098
1253
|
if (true === config.shouldAdvanceTime) clock.setTickMode({
|
|
1099
1254
|
mode: "interval",
|
|
1100
1255
|
delta: config.advanceTimeDelta
|
|
@@ -1111,7 +1266,7 @@ __webpack_require__.add({
|
|
|
1111
1266
|
clock.performance.mark = (name)=>new FakePerformanceEntry(name, "mark", 0, 0);
|
|
1112
1267
|
clock.performance.measure = (name)=>new FakePerformanceEntry(name, "measure", 0, 100);
|
|
1113
1268
|
clock.performance.timeOrigin = getEpoch(config.now);
|
|
1114
|
-
} else if ((config.toFake || []).includes("performance"))
|
|
1269
|
+
} else if ((config.toFake || []).includes("performance")) handleMissingTimer("performance");
|
|
1115
1270
|
}
|
|
1116
1271
|
if (_global === globalObject && timersModule) clock.timersModuleMethods = [];
|
|
1117
1272
|
if (_global === globalObject && timersPromisesModule) clock.timersPromisesModuleMethods = [];
|
|
@@ -1362,14 +1517,11 @@ __webpack_require__.add({
|
|
|
1362
1517
|
}
|
|
1363
1518
|
return typeDetect;
|
|
1364
1519
|
});
|
|
1365
|
-
},
|
|
1366
|
-
util (module) {
|
|
1367
|
-
module.exports = __rspack_external_node_util_1b29d436;
|
|
1368
1520
|
}
|
|
1369
1521
|
});
|
|
1370
1522
|
const RealDate = Date;
|
|
1371
1523
|
const loadFakeTimersModule = ()=>{
|
|
1372
|
-
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");
|
|
1373
1525
|
return {
|
|
1374
1526
|
withGlobal: loaded.withGlobal
|
|
1375
1527
|
};
|
|
@@ -1436,7 +1588,7 @@ class FakeTimers {
|
|
|
1436
1588
|
}
|
|
1437
1589
|
useFakeTimers(fakeTimersConfig = {}) {
|
|
1438
1590
|
if (this._fakingTime) this._clock.uninstall();
|
|
1439
|
-
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);
|
|
1440
1592
|
const isChildProcess = "u" > typeof process && !!process.send;
|
|
1441
1593
|
if (this._config?.toFake?.includes('nextTick') && isChildProcess) throw new Error('process.nextTick cannot be mocked inside child_process');
|
|
1442
1594
|
this._clock = this._fakeTimers.install({
|
|
@@ -1449,6 +1601,7 @@ class FakeTimers {
|
|
|
1449
1601
|
ignoreMissingTimers: true,
|
|
1450
1602
|
...fakeTimersConfig
|
|
1451
1603
|
});
|
|
1604
|
+
this._clock.reset();
|
|
1452
1605
|
this._fakingTime = true;
|
|
1453
1606
|
}
|
|
1454
1607
|
reset() {
|