@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
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { __webpack_require__ } from "./
|
|
1
|
+
import { __webpack_require__ } from "./723.js";
|
|
2
2
|
import "./723.js";
|
|
3
3
|
__webpack_require__.add({
|
|
4
4
|
"../../node_modules/.pnpm/@sinonjs+commons@3.0.1/node_modules/@sinonjs/commons/lib/called-in-order.js" (module, __unused_rspack_exports, __webpack_require__) {
|
|
@@ -183,18 +183,14 @@ __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 {
|
|
190
|
-
timersModule = __webpack_require__("
|
|
190
|
+
timersModule = __webpack_require__("?4e05");
|
|
191
191
|
} catch (e) {}
|
|
192
192
|
try {
|
|
193
|
-
timersPromisesModule = __webpack_require__(
|
|
194
|
-
var e = new Error("Cannot find module 'timers/promises'");
|
|
195
|
-
e.code = 'MODULE_NOT_FOUND';
|
|
196
|
-
throw e;
|
|
197
|
-
}()));
|
|
193
|
+
timersPromisesModule = __webpack_require__("?7123");
|
|
198
194
|
} catch (e) {}
|
|
199
195
|
function withGlobal(_global) {
|
|
200
196
|
const maxTimeout = Math.pow(2, 31) - 1;
|
|
@@ -220,11 +216,11 @@ __webpack_require__.add({
|
|
|
220
216
|
isPresent.performance = _global.performance && "function" == typeof _global.performance.now;
|
|
221
217
|
const hasPerformancePrototype = _global.Performance && (typeof _global.Performance).match(/^(function|object)$/);
|
|
222
218
|
const hasPerformanceConstructorPrototype = _global.performance && _global.performance.constructor && _global.performance.constructor.prototype;
|
|
223
|
-
isPresent.queueMicrotask =
|
|
219
|
+
isPresent.queueMicrotask = Object.prototype.hasOwnProperty.call(_global, "queueMicrotask");
|
|
224
220
|
isPresent.requestAnimationFrame = _global.requestAnimationFrame && "function" == typeof _global.requestAnimationFrame;
|
|
225
221
|
isPresent.cancelAnimationFrame = _global.cancelAnimationFrame && "function" == typeof _global.cancelAnimationFrame;
|
|
226
222
|
isPresent.requestIdleCallback = _global.requestIdleCallback && "function" == typeof _global.requestIdleCallback;
|
|
227
|
-
isPresent.
|
|
223
|
+
isPresent.cancelIdleCallback = _global.cancelIdleCallback && "function" == typeof _global.cancelIdleCallback;
|
|
228
224
|
isPresent.setImmediate = _global.setImmediate && "function" == typeof _global.setImmediate;
|
|
229
225
|
isPresent.clearImmediate = _global.clearImmediate && "function" == typeof _global.clearImmediate;
|
|
230
226
|
isPresent.Intl = _global.Intl && "object" == typeof _global.Intl;
|
|
@@ -232,6 +228,7 @@ __webpack_require__.add({
|
|
|
232
228
|
const NativeDate = _global.Date;
|
|
233
229
|
const NativeIntl = isPresent.Intl ? Object.defineProperties(Object.create(null), Object.getOwnPropertyDescriptors(_global.Intl)) : void 0;
|
|
234
230
|
let uniqueTimerId = idCounterStart;
|
|
231
|
+
let uniqueTimerOrder = 0;
|
|
235
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)");
|
|
236
233
|
isPresent.Date = true;
|
|
237
234
|
class FakePerformanceEntry {
|
|
@@ -251,12 +248,11 @@ __webpack_require__.add({
|
|
|
251
248
|
if (Number.isFinite) return Number.isFinite(num);
|
|
252
249
|
return isFinite(num);
|
|
253
250
|
}
|
|
254
|
-
let isNearInfiniteLimit = false;
|
|
255
251
|
function checkIsNearInfiniteLimit(clock, i) {
|
|
256
|
-
if (clock.loopLimit && i === clock.loopLimit - 1) isNearInfiniteLimit = true;
|
|
252
|
+
if (clock.loopLimit && i === clock.loopLimit - 1) clock.isNearInfiniteLimit = true;
|
|
257
253
|
}
|
|
258
|
-
function resetIsNearInfiniteLimit() {
|
|
259
|
-
isNearInfiniteLimit = false;
|
|
254
|
+
function resetIsNearInfiniteLimit(clock) {
|
|
255
|
+
if (clock) clock.isNearInfiniteLimit = false;
|
|
260
256
|
}
|
|
261
257
|
function parseTime(str) {
|
|
262
258
|
if (!str) return 0;
|
|
@@ -281,7 +277,7 @@ __webpack_require__.add({
|
|
|
281
277
|
}
|
|
282
278
|
function getEpoch(epoch) {
|
|
283
279
|
if (!epoch) return 0;
|
|
284
|
-
if (
|
|
280
|
+
if (epoch instanceof Date) return epoch.getTime();
|
|
285
281
|
if ("number" == typeof epoch) return epoch;
|
|
286
282
|
throw new TypeError("now should be milliseconds since UNIX epoch");
|
|
287
283
|
}
|
|
@@ -381,63 +377,175 @@ __webpack_require__.add({
|
|
|
381
377
|
}
|
|
382
378
|
function runJobs(clock) {
|
|
383
379
|
if (!clock.jobs) return;
|
|
380
|
+
const wasNearLimit = clock.isNearInfiniteLimit;
|
|
384
381
|
for(let i = 0; i < clock.jobs.length; i++){
|
|
385
382
|
const job = clock.jobs[i];
|
|
386
383
|
job.func.apply(null, job.args);
|
|
387
384
|
checkIsNearInfiniteLimit(clock, i);
|
|
388
385
|
if (clock.loopLimit && i > clock.loopLimit) throw getInfiniteLoopError(clock, job);
|
|
389
386
|
}
|
|
390
|
-
resetIsNearInfiniteLimit();
|
|
387
|
+
if (!wasNearLimit) resetIsNearInfiniteLimit(clock);
|
|
391
388
|
clock.jobs = [];
|
|
392
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
|
+
}
|
|
393
493
|
function addTimer(clock, timer) {
|
|
394
494
|
if (void 0 === timer.func) throw new Error("Callback must be provided to timer calls");
|
|
395
|
-
if (
|
|
396
|
-
|
|
397
|
-
}
|
|
398
|
-
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();
|
|
399
497
|
timer.type = timer.immediate ? "Immediate" : "Timeout";
|
|
400
|
-
if (
|
|
498
|
+
if (Object.prototype.hasOwnProperty.call(timer, "delay")) {
|
|
401
499
|
if ("number" != typeof timer.delay) timer.delay = parseInt(timer.delay, 10);
|
|
402
500
|
if (!isNumberFinite(timer.delay)) timer.delay = 0;
|
|
403
501
|
timer.delay = timer.delay > maxTimeout ? 1 : timer.delay;
|
|
404
502
|
timer.delay = Math.max(0, timer.delay);
|
|
405
503
|
}
|
|
406
|
-
if (
|
|
504
|
+
if (Object.prototype.hasOwnProperty.call(timer, "interval")) {
|
|
407
505
|
timer.type = "Interval";
|
|
408
506
|
timer.interval = timer.interval > maxTimeout ? 1 : timer.interval;
|
|
409
507
|
}
|
|
410
|
-
if (
|
|
508
|
+
if (Object.prototype.hasOwnProperty.call(timer, "animation")) {
|
|
411
509
|
timer.type = "AnimationFrame";
|
|
412
510
|
timer.animation = true;
|
|
413
511
|
}
|
|
414
|
-
if (
|
|
415
|
-
timer.type = "IdleCallback";
|
|
416
|
-
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;
|
|
417
520
|
}
|
|
418
|
-
if (!clock.timers) clock.timers = {};
|
|
419
521
|
timer.id = uniqueTimerId++;
|
|
522
|
+
if (uniqueTimerId >= Number.MAX_SAFE_INTEGER) uniqueTimerId = idCounterStart;
|
|
523
|
+
timer.order = uniqueTimerOrder++;
|
|
420
524
|
timer.createdAt = clock.now;
|
|
421
|
-
timer.callAt = clock.now + (parseInt(timer.delay) || (clock.duringTick ? 1 : 0));
|
|
422
|
-
clock
|
|
525
|
+
timer.callAt = clock.now + (parseInt(String(timer.delay)) || (clock.duringTick ? 1 : 0));
|
|
526
|
+
setTimer(clock, timer);
|
|
527
|
+
clock.timerHeap.push(timer);
|
|
423
528
|
if (addTimerReturnsObject) {
|
|
424
529
|
const res = {
|
|
425
530
|
refed: true,
|
|
426
531
|
ref: function() {
|
|
427
532
|
this.refed = true;
|
|
428
|
-
return
|
|
533
|
+
return this;
|
|
429
534
|
},
|
|
430
535
|
unref: function() {
|
|
431
536
|
this.refed = false;
|
|
432
|
-
return
|
|
537
|
+
return this;
|
|
433
538
|
},
|
|
434
539
|
hasRef: function() {
|
|
435
540
|
return this.refed;
|
|
436
541
|
},
|
|
437
542
|
refresh: function() {
|
|
438
|
-
timer.callAt = clock.now + (parseInt(timer.delay) || (clock.duringTick ? 1 : 0));
|
|
439
|
-
clock.
|
|
440
|
-
|
|
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;
|
|
441
549
|
},
|
|
442
550
|
[Symbol.toPrimitive]: function() {
|
|
443
551
|
return timer.id;
|
|
@@ -448,53 +556,53 @@ __webpack_require__.add({
|
|
|
448
556
|
return timer.id;
|
|
449
557
|
}
|
|
450
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;
|
|
451
561
|
if (a.callAt < b.callAt) return -1;
|
|
452
562
|
if (a.callAt > b.callAt) return 1;
|
|
453
563
|
if (a.immediate && !b.immediate) return -1;
|
|
454
564
|
if (!a.immediate && b.immediate) return 1;
|
|
565
|
+
if (a.order < b.order) return -1;
|
|
566
|
+
if (a.order > b.order) return 1;
|
|
455
567
|
if (a.createdAt < b.createdAt) return -1;
|
|
456
568
|
if (a.createdAt > b.createdAt) return 1;
|
|
457
569
|
if (a.id < b.id) return -1;
|
|
458
570
|
if (a.id > b.id) return 1;
|
|
571
|
+
return 0;
|
|
459
572
|
}
|
|
460
573
|
function firstTimerInRange(clock, from, to) {
|
|
461
|
-
|
|
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;
|
|
462
579
|
let timer = null;
|
|
463
|
-
let
|
|
464
|
-
for(id in timers)if (timers.hasOwnProperty(id)) {
|
|
465
|
-
isInRange = inRange(from, to, timers[id]);
|
|
466
|
-
if (isInRange && (!timer || 1 === compareTimers(timer, timers[id]))) timer = timers[id];
|
|
467
|
-
}
|
|
580
|
+
for(let i = 0; i < timers.length; i++)if (inRange(from, to, timers[i]) && (!timer || 1 === compareTimers(timer, timers[i]))) timer = timers[i];
|
|
468
581
|
return timer;
|
|
469
582
|
}
|
|
470
583
|
function firstTimer(clock) {
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
let id;
|
|
474
|
-
for(id in timers)if (timers.hasOwnProperty(id)) {
|
|
475
|
-
if (!timer || 1 === compareTimers(timer, timers[id])) timer = timers[id];
|
|
476
|
-
}
|
|
477
|
-
return timer;
|
|
584
|
+
if (!clock.timerHeap) return null;
|
|
585
|
+
return clock.timerHeap.peek() || null;
|
|
478
586
|
}
|
|
479
587
|
function lastTimer(clock) {
|
|
480
|
-
|
|
588
|
+
if (!clock.timerHeap) return null;
|
|
589
|
+
const timers = clock.timerHeap.timers;
|
|
481
590
|
let timer = null;
|
|
482
|
-
let
|
|
483
|
-
for(id in timers)if (timers.hasOwnProperty(id)) {
|
|
484
|
-
if (!timer || -1 === compareTimers(timer, timers[id])) timer = timers[id];
|
|
485
|
-
}
|
|
591
|
+
for(let i = 0; i < timers.length; i++)if (!timer || -1 === compareTimers(timer, timers[i])) timer = timers[i];
|
|
486
592
|
return timer;
|
|
487
593
|
}
|
|
488
594
|
function callTimer(clock, timer) {
|
|
489
|
-
if ("number" == typeof timer.interval)
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
(
|
|
495
|
-
|
|
496
|
-
|
|
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);
|
|
497
604
|
}
|
|
605
|
+
if ("function" == typeof timer.func) timer.func.apply(null, timer.args);
|
|
498
606
|
}
|
|
499
607
|
function getClearHandler(ttype) {
|
|
500
608
|
if ("IdleCallback" === ttype || "AnimationFrame" === ttype) return `cancel${ttype}`;
|
|
@@ -513,7 +621,6 @@ __webpack_require__.add({
|
|
|
513
621
|
const warnOnce = createWarnOnce();
|
|
514
622
|
function clearTimer(clock, timerId, ttype) {
|
|
515
623
|
if (!timerId) return;
|
|
516
|
-
if (!clock.timers) clock.timers = {};
|
|
517
624
|
const id = Number(timerId);
|
|
518
625
|
if (Number.isNaN(id) || id < idCounterStart) {
|
|
519
626
|
const handlerName = getClearHandler(ttype);
|
|
@@ -524,10 +631,12 @@ __webpack_require__.add({
|
|
|
524
631
|
const stackTrace = new Error().stack.split("\n").slice(1).join("\n");
|
|
525
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}`);
|
|
526
633
|
}
|
|
527
|
-
if (clock
|
|
528
|
-
const timer = clock
|
|
529
|
-
if (timer.type === ttype || "Timeout" === timer.type && "Interval" === ttype || "Interval" === timer.type && "Timeout" === ttype)
|
|
530
|
-
|
|
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 {
|
|
531
640
|
const clear = getClearHandler(ttype);
|
|
532
641
|
const schedule = getScheduleHandler(timer.type);
|
|
533
642
|
throw new Error(`Cannot clear timer: timer created with ${schedule}() but cleared with ${clear}()`);
|
|
@@ -546,7 +655,7 @@ __webpack_require__.add({
|
|
|
546
655
|
const originalPerfDescriptor = Object.getOwnPropertyDescriptor(clock, `_${method}`);
|
|
547
656
|
if (originalPerfDescriptor && originalPerfDescriptor.get && !originalPerfDescriptor.set) Object.defineProperty(_global, method, originalPerfDescriptor);
|
|
548
657
|
else if (originalPerfDescriptor.configurable) _global[method] = clock[`_${method}`];
|
|
549
|
-
} else if (
|
|
658
|
+
} else if (clock[method] && clock[method].hasOwnProperty) _global[method] = clock[`_${method}`];
|
|
550
659
|
else try {
|
|
551
660
|
delete _global[method];
|
|
552
661
|
} catch (ignore) {}
|
|
@@ -559,19 +668,19 @@ __webpack_require__.add({
|
|
|
559
668
|
timersPromisesModule[entry.methodName] = entry.original;
|
|
560
669
|
}
|
|
561
670
|
}
|
|
562
|
-
clock.setTickMode(
|
|
671
|
+
clock.setTickMode({
|
|
672
|
+
mode: "manual"
|
|
673
|
+
});
|
|
563
674
|
clock.methods = [];
|
|
564
675
|
for (const [listener, signal] of clock.abortListenerMap.entries()){
|
|
565
676
|
signal.removeEventListener("abort", listener);
|
|
566
677
|
clock.abortListenerMap.delete(listener);
|
|
567
678
|
}
|
|
568
|
-
if (!clock.
|
|
569
|
-
return
|
|
570
|
-
return clock.timers[key];
|
|
571
|
-
});
|
|
679
|
+
if (!clock.timerHeap) return [];
|
|
680
|
+
return clock.timerHeap.timers.slice();
|
|
572
681
|
}
|
|
573
682
|
function hijackMethod(target, method, clock) {
|
|
574
|
-
clock[method].
|
|
683
|
+
clock[method].hasOwnProperty = Object.prototype.hasOwnProperty.call(target, method);
|
|
575
684
|
clock[`_${method}`] = target[method];
|
|
576
685
|
if ("Date" === method) target[method] = clock[method];
|
|
577
686
|
else if ("Intl" === method) target[method] = clock[method];
|
|
@@ -626,6 +735,7 @@ __webpack_require__.add({
|
|
|
626
735
|
now: start,
|
|
627
736
|
Date: createDate(),
|
|
628
737
|
loopLimit: loopLimit,
|
|
738
|
+
isNearInfiniteLimit: false,
|
|
629
739
|
tickMode: {
|
|
630
740
|
mode: "manual",
|
|
631
741
|
counter: 0,
|
|
@@ -690,7 +800,7 @@ __webpack_require__.add({
|
|
|
690
800
|
const channel = new MessageChannel();
|
|
691
801
|
await new Promise((resolve)=>{
|
|
692
802
|
channel.port1.onmessage = ()=>{
|
|
693
|
-
resolve();
|
|
803
|
+
resolve(void 0);
|
|
694
804
|
channel.port1.close();
|
|
695
805
|
};
|
|
696
806
|
channel.port2.postMessage(void 0);
|
|
@@ -719,21 +829,30 @@ __webpack_require__.add({
|
|
|
719
829
|
});
|
|
720
830
|
});
|
|
721
831
|
}
|
|
722
|
-
|
|
832
|
+
function getTimeToNextIdlePeriod() {
|
|
723
833
|
let timeToNextIdlePeriod = 0;
|
|
724
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
|
+
};
|
|
725
842
|
const result = addTimer(clock, {
|
|
726
843
|
func: func,
|
|
727
|
-
args:
|
|
728
|
-
|
|
729
|
-
|
|
844
|
+
args: [
|
|
845
|
+
idleDeadline
|
|
846
|
+
],
|
|
847
|
+
delay: timeout,
|
|
848
|
+
requestIdleCallback: true
|
|
730
849
|
});
|
|
731
850
|
return Number(result);
|
|
732
851
|
};
|
|
733
852
|
clock.cancelIdleCallback = function cancelIdleCallback(timerId) {
|
|
734
853
|
return clearTimer(clock, timerId, "IdleCallback");
|
|
735
854
|
};
|
|
736
|
-
clock.setTimeout = function
|
|
855
|
+
clock.setTimeout = function setTimeout(func, timeout) {
|
|
737
856
|
return addTimer(clock, {
|
|
738
857
|
func: func,
|
|
739
858
|
args: Array.prototype.slice.call(arguments, 2),
|
|
@@ -751,20 +870,20 @@ __webpack_require__.add({
|
|
|
751
870
|
});
|
|
752
871
|
});
|
|
753
872
|
};
|
|
754
|
-
clock.clearTimeout = function
|
|
873
|
+
clock.clearTimeout = function clearTimeout(timerId) {
|
|
755
874
|
return clearTimer(clock, timerId, "Timeout");
|
|
756
875
|
};
|
|
757
876
|
clock.nextTick = function nextTick(func) {
|
|
758
877
|
return enqueueJob(clock, {
|
|
759
878
|
func: func,
|
|
760
879
|
args: Array.prototype.slice.call(arguments, 1),
|
|
761
|
-
error: isNearInfiniteLimit ? new Error() : null
|
|
880
|
+
error: clock.isNearInfiniteLimit ? new Error() : null
|
|
762
881
|
});
|
|
763
882
|
};
|
|
764
883
|
clock.queueMicrotask = function queueMicrotask(func) {
|
|
765
884
|
return clock.nextTick(func);
|
|
766
885
|
};
|
|
767
|
-
clock.setInterval = function
|
|
886
|
+
clock.setInterval = function setInterval(func, timeout) {
|
|
768
887
|
timeout = parseInt(timeout, 10);
|
|
769
888
|
return addTimer(clock, {
|
|
770
889
|
func: func,
|
|
@@ -773,7 +892,7 @@ __webpack_require__.add({
|
|
|
773
892
|
interval: timeout
|
|
774
893
|
});
|
|
775
894
|
};
|
|
776
|
-
clock.clearInterval = function
|
|
895
|
+
clock.clearInterval = function clearInterval(timerId) {
|
|
777
896
|
return clearTimer(clock, timerId, "Interval");
|
|
778
897
|
};
|
|
779
898
|
if (isPresent.setImmediate) {
|
|
@@ -800,7 +919,7 @@ __webpack_require__.add({
|
|
|
800
919
|
};
|
|
801
920
|
}
|
|
802
921
|
clock.countTimers = function countTimers() {
|
|
803
|
-
return
|
|
922
|
+
return (clock.timerHeap ? clock.timerHeap.timers.length : 0) + (clock.jobs || []).length;
|
|
804
923
|
};
|
|
805
924
|
clock.requestAnimationFrame = function requestAnimationFrame(func) {
|
|
806
925
|
const result = addTimer(clock, {
|
|
@@ -821,7 +940,7 @@ __webpack_require__.add({
|
|
|
821
940
|
clock.runMicrotasks = function runMicrotasks() {
|
|
822
941
|
runJobs(clock);
|
|
823
942
|
};
|
|
824
|
-
function
|
|
943
|
+
function createTickState(tickValue) {
|
|
825
944
|
const msFloat = "number" == typeof tickValue ? tickValue : parseTime(tickValue);
|
|
826
945
|
const ms = Math.floor(msFloat);
|
|
827
946
|
const remainder = nanoRemainder(msFloat);
|
|
@@ -832,92 +951,108 @@ __webpack_require__.add({
|
|
|
832
951
|
tickTo += 1;
|
|
833
952
|
nanosTotal -= 1e6;
|
|
834
953
|
}
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
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) {
|
|
842
967
|
if (oldNow !== clock.now) {
|
|
843
|
-
|
|
844
|
-
|
|
968
|
+
const difference = clock.now - oldNow;
|
|
969
|
+
state.tickFrom += difference;
|
|
970
|
+
state.tickTo += difference;
|
|
971
|
+
if (options && options.includePrevious) state.previous += difference;
|
|
845
972
|
}
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
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;
|
|
861
1000
|
}
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
tickFrom += clock.now - oldNow;
|
|
868
|
-
tickTo += clock.now - oldNow;
|
|
869
|
-
}
|
|
870
|
-
clock.duringTick = false;
|
|
871
|
-
timer = firstTimerInRange(clock, tickFrom, tickTo);
|
|
872
|
-
if (timer) try {
|
|
873
|
-
clock.tick(tickTo - clock.now);
|
|
874
|
-
} catch (e) {
|
|
875
|
-
firstException = firstException || e;
|
|
876
|
-
}
|
|
877
|
-
else {
|
|
878
|
-
clock.now = tickTo;
|
|
879
|
-
nanos = nanosTotal;
|
|
1001
|
+
if (isAsync) {
|
|
1002
|
+
originalSetTimeout(nextPromiseTick);
|
|
1003
|
+
return true;
|
|
1004
|
+
}
|
|
1005
|
+
compensationCheck();
|
|
880
1006
|
}
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
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;
|
|
884
1017
|
}
|
|
885
|
-
|
|
1018
|
+
else {
|
|
1019
|
+
clock.now = state.tickTo;
|
|
1020
|
+
nanos = state.nanosTotal;
|
|
1021
|
+
}
|
|
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() {
|
|
886
1037
|
try {
|
|
887
1038
|
compensationCheck();
|
|
888
|
-
|
|
1039
|
+
selectNextTimerInRange(state);
|
|
889
1040
|
doTickInner();
|
|
890
1041
|
} catch (e) {
|
|
891
1042
|
reject(e);
|
|
892
1043
|
}
|
|
893
1044
|
};
|
|
894
|
-
|
|
895
|
-
if (
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
};
|
|
901
|
-
postTimerCall = function() {
|
|
902
|
-
timer = firstTimerInRange(clock, previous, tickTo);
|
|
903
|
-
previous = tickFrom;
|
|
904
|
-
};
|
|
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
|
+
}
|
|
905
1051
|
return doTickInner();
|
|
906
1052
|
}
|
|
907
1053
|
clock.tick = function tick(tickValue) {
|
|
908
1054
|
return doTick(tickValue, false);
|
|
909
1055
|
};
|
|
910
|
-
if (void 0 !== _global.Promise) clock.tickAsync = function tickAsync(tickValue) {
|
|
911
|
-
return pauseAutoTickUntilFinished(new _global.Promise(function(resolve, reject) {
|
|
912
|
-
originalSetTimeout(function() {
|
|
913
|
-
try {
|
|
914
|
-
doTick(tickValue, true, resolve, reject);
|
|
915
|
-
} catch (e) {
|
|
916
|
-
reject(e);
|
|
917
|
-
}
|
|
918
|
-
});
|
|
919
|
-
}));
|
|
920
|
-
};
|
|
921
1056
|
clock.next = function next() {
|
|
922
1057
|
runJobs(clock);
|
|
923
1058
|
const timer = firstTimer(clock);
|
|
@@ -932,46 +1067,31 @@ __webpack_require__.add({
|
|
|
932
1067
|
clock.duringTick = false;
|
|
933
1068
|
}
|
|
934
1069
|
};
|
|
935
|
-
|
|
1070
|
+
function runAsyncWithNativeTimeout(callback) {
|
|
936
1071
|
return pauseAutoTickUntilFinished(new _global.Promise(function(resolve, reject) {
|
|
937
1072
|
originalSetTimeout(function() {
|
|
938
1073
|
try {
|
|
939
|
-
|
|
940
|
-
if (!timer) return void resolve(clock.now);
|
|
941
|
-
let err;
|
|
942
|
-
clock.duringTick = true;
|
|
943
|
-
clock.now = timer.callAt;
|
|
944
|
-
try {
|
|
945
|
-
callTimer(clock, timer);
|
|
946
|
-
} catch (e) {
|
|
947
|
-
err = e;
|
|
948
|
-
}
|
|
949
|
-
clock.duringTick = false;
|
|
950
|
-
originalSetTimeout(function() {
|
|
951
|
-
if (err) reject(err);
|
|
952
|
-
else resolve(clock.now);
|
|
953
|
-
});
|
|
1074
|
+
callback(resolve, reject);
|
|
954
1075
|
} catch (e) {
|
|
955
1076
|
reject(e);
|
|
956
1077
|
}
|
|
957
1078
|
});
|
|
958
1079
|
}));
|
|
959
|
-
}
|
|
1080
|
+
}
|
|
960
1081
|
clock.runAll = function runAll() {
|
|
961
|
-
let numTimers, i;
|
|
962
1082
|
runJobs(clock);
|
|
963
|
-
for(i = 0; i < clock.loopLimit; i++){
|
|
1083
|
+
for(let i = 0; i < clock.loopLimit; i++){
|
|
964
1084
|
if (!clock.timers) {
|
|
965
|
-
resetIsNearInfiniteLimit();
|
|
1085
|
+
resetIsNearInfiniteLimit(clock);
|
|
966
1086
|
return clock.now;
|
|
967
1087
|
}
|
|
968
|
-
numTimers =
|
|
1088
|
+
const numTimers = clock.timerHeap.timers.length;
|
|
969
1089
|
if (0 === numTimers) {
|
|
970
|
-
resetIsNearInfiniteLimit();
|
|
1090
|
+
resetIsNearInfiniteLimit(clock);
|
|
971
1091
|
return clock.now;
|
|
972
1092
|
}
|
|
973
|
-
clock.next();
|
|
974
1093
|
checkIsNearInfiniteLimit(clock, i);
|
|
1094
|
+
clock.next();
|
|
975
1095
|
}
|
|
976
1096
|
const excessJob = firstTimer(clock);
|
|
977
1097
|
throw getInfiniteLoopError(clock, excessJob);
|
|
@@ -979,42 +1099,6 @@ __webpack_require__.add({
|
|
|
979
1099
|
clock.runToFrame = function runToFrame() {
|
|
980
1100
|
return clock.tick(getTimeToNextFrame());
|
|
981
1101
|
};
|
|
982
|
-
if (void 0 !== _global.Promise) clock.runAllAsync = function runAllAsync() {
|
|
983
|
-
return pauseAutoTickUntilFinished(new _global.Promise(function(resolve, reject) {
|
|
984
|
-
let i = 0;
|
|
985
|
-
function doRun() {
|
|
986
|
-
originalSetTimeout(function() {
|
|
987
|
-
try {
|
|
988
|
-
runJobs(clock);
|
|
989
|
-
let numTimers;
|
|
990
|
-
if (i < clock.loopLimit) {
|
|
991
|
-
if (!clock.timers) {
|
|
992
|
-
resetIsNearInfiniteLimit();
|
|
993
|
-
resolve(clock.now);
|
|
994
|
-
return;
|
|
995
|
-
}
|
|
996
|
-
numTimers = Object.keys(clock.timers).length;
|
|
997
|
-
if (0 === numTimers) {
|
|
998
|
-
resetIsNearInfiniteLimit();
|
|
999
|
-
resolve(clock.now);
|
|
1000
|
-
return;
|
|
1001
|
-
}
|
|
1002
|
-
clock.next();
|
|
1003
|
-
i++;
|
|
1004
|
-
doRun();
|
|
1005
|
-
checkIsNearInfiniteLimit(clock, i);
|
|
1006
|
-
return;
|
|
1007
|
-
}
|
|
1008
|
-
const excessJob = firstTimer(clock);
|
|
1009
|
-
reject(getInfiniteLoopError(clock, excessJob));
|
|
1010
|
-
} catch (e) {
|
|
1011
|
-
reject(e);
|
|
1012
|
-
}
|
|
1013
|
-
});
|
|
1014
|
-
}
|
|
1015
|
-
doRun();
|
|
1016
|
-
}));
|
|
1017
|
-
};
|
|
1018
1102
|
clock.runToLast = function runToLast() {
|
|
1019
1103
|
const timer = lastTimer(clock);
|
|
1020
1104
|
if (!timer) {
|
|
@@ -1023,47 +1107,107 @@ __webpack_require__.add({
|
|
|
1023
1107
|
}
|
|
1024
1108
|
return clock.tick(timer.callAt - clock.now);
|
|
1025
1109
|
};
|
|
1026
|
-
if (void 0 !== _global.Promise)
|
|
1027
|
-
|
|
1028
|
-
|
|
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;
|
|
1029
1123
|
try {
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
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;
|
|
1034
1160
|
}
|
|
1035
|
-
|
|
1161
|
+
const excessJob = firstTimer(clock);
|
|
1162
|
+
reject(getInfiniteLoopError(clock, excessJob));
|
|
1036
1163
|
} catch (e) {
|
|
1037
1164
|
reject(e);
|
|
1038
1165
|
}
|
|
1166
|
+
}
|
|
1167
|
+
return runAsyncWithNativeTimeout(function(resolve, reject) {
|
|
1168
|
+
doRun(resolve, reject);
|
|
1039
1169
|
});
|
|
1040
|
-
}
|
|
1041
|
-
|
|
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
|
+
}
|
|
1042
1183
|
clock.reset = function reset() {
|
|
1043
1184
|
nanos = 0;
|
|
1044
|
-
clock.timers =
|
|
1185
|
+
clock.timers = new Map();
|
|
1186
|
+
clock.timerHeap = new TimerHeap();
|
|
1045
1187
|
clock.jobs = [];
|
|
1046
1188
|
clock.now = start;
|
|
1047
1189
|
};
|
|
1048
1190
|
clock.setSystemTime = function setSystemTime(systemTime) {
|
|
1049
1191
|
const newNow = getEpoch(systemTime);
|
|
1050
1192
|
const difference = newNow - clock.now;
|
|
1051
|
-
let id, timer;
|
|
1052
1193
|
adjustedSystemTime[0] = adjustedSystemTime[0] + difference;
|
|
1053
1194
|
adjustedSystemTime[1] = adjustedSystemTime[1] + nanos;
|
|
1054
1195
|
clock.now = newNow;
|
|
1055
1196
|
nanos = 0;
|
|
1056
|
-
|
|
1057
|
-
timer = clock.timers[id];
|
|
1197
|
+
forEachActiveTimer(clock, (timer)=>{
|
|
1058
1198
|
timer.createdAt += difference;
|
|
1059
1199
|
timer.callAt += difference;
|
|
1060
|
-
}
|
|
1200
|
+
});
|
|
1061
1201
|
};
|
|
1062
1202
|
clock.jump = function jump(tickValue) {
|
|
1063
1203
|
const msFloat = "number" == typeof tickValue ? tickValue : parseTime(tickValue);
|
|
1064
1204
|
const ms = Math.floor(msFloat);
|
|
1065
|
-
|
|
1205
|
+
forEachActiveTimer(clock, (timer)=>{
|
|
1206
|
+
if (clock.now + ms > timer.callAt) timer.callAt = clock.now + ms;
|
|
1207
|
+
});
|
|
1208
|
+
rebuildTimerHeap(clock);
|
|
1066
1209
|
clock.tick(ms);
|
|
1210
|
+
return clock.now;
|
|
1067
1211
|
};
|
|
1068
1212
|
if (isPresent.performance) {
|
|
1069
1213
|
clock.performance = Object.create(null);
|
|
@@ -1084,6 +1228,9 @@ __webpack_require__.add({
|
|
|
1084
1228
|
config.shouldAdvanceTime = config.shouldAdvanceTime || false;
|
|
1085
1229
|
config.advanceTimeDelta = config.advanceTimeDelta || 20;
|
|
1086
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");
|
|
1087
1234
|
if (config.target) throw new TypeError("config.target is no longer supported. Use `withGlobal(target)` instead.");
|
|
1088
1235
|
function handleMissingTimer(timer) {
|
|
1089
1236
|
if (config.ignoreMissingTimers) return;
|
|
@@ -1096,8 +1243,13 @@ __webpack_require__.add({
|
|
|
1096
1243
|
return uninstall(clock);
|
|
1097
1244
|
};
|
|
1098
1245
|
clock.abortListenerMap = new Map();
|
|
1099
|
-
|
|
1100
|
-
|
|
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);
|
|
1101
1253
|
if (true === config.shouldAdvanceTime) clock.setTickMode({
|
|
1102
1254
|
mode: "interval",
|
|
1103
1255
|
delta: config.advanceTimeDelta
|
|
@@ -1114,7 +1266,7 @@ __webpack_require__.add({
|
|
|
1114
1266
|
clock.performance.mark = (name)=>new FakePerformanceEntry(name, "mark", 0, 0);
|
|
1115
1267
|
clock.performance.measure = (name)=>new FakePerformanceEntry(name, "measure", 0, 100);
|
|
1116
1268
|
clock.performance.timeOrigin = getEpoch(config.now);
|
|
1117
|
-
} else if ((config.toFake || []).includes("performance"))
|
|
1269
|
+
} else if ((config.toFake || []).includes("performance")) handleMissingTimer("performance");
|
|
1118
1270
|
}
|
|
1119
1271
|
if (_global === globalObject && timersModule) clock.timersModuleMethods = [];
|
|
1120
1272
|
if (_global === globalObject && timersPromisesModule) clock.timersPromisesModuleMethods = [];
|
|
@@ -1301,175 +1453,6 @@ __webpack_require__.add({
|
|
|
1301
1453
|
defaultImplementation.install;
|
|
1302
1454
|
exports.withGlobal = withGlobal;
|
|
1303
1455
|
},
|
|
1304
|
-
"../../node_modules/.pnpm/setimmediate@1.0.5/node_modules/setimmediate/setImmediate.js" (__unused_rspack_module, __unused_rspack_exports, __webpack_require__) {
|
|
1305
|
-
var process = __webpack_require__("../../node_modules/.pnpm/process@0.11.10/node_modules/process/browser.js");
|
|
1306
|
-
(function(global, undefined) {
|
|
1307
|
-
"use strict";
|
|
1308
|
-
if (global.setImmediate) return;
|
|
1309
|
-
var nextHandle = 1;
|
|
1310
|
-
var tasksByHandle = {};
|
|
1311
|
-
var currentlyRunningATask = false;
|
|
1312
|
-
var doc = global.document;
|
|
1313
|
-
var registerImmediate;
|
|
1314
|
-
function setImmediate(callback) {
|
|
1315
|
-
if ("function" != typeof callback) callback = new Function("" + callback);
|
|
1316
|
-
var args = new Array(arguments.length - 1);
|
|
1317
|
-
for(var i = 0; i < args.length; i++)args[i] = arguments[i + 1];
|
|
1318
|
-
var task = {
|
|
1319
|
-
callback: callback,
|
|
1320
|
-
args: args
|
|
1321
|
-
};
|
|
1322
|
-
tasksByHandle[nextHandle] = task;
|
|
1323
|
-
registerImmediate(nextHandle);
|
|
1324
|
-
return nextHandle++;
|
|
1325
|
-
}
|
|
1326
|
-
function clearImmediate(handle) {
|
|
1327
|
-
delete tasksByHandle[handle];
|
|
1328
|
-
}
|
|
1329
|
-
function run(task) {
|
|
1330
|
-
var callback = task.callback;
|
|
1331
|
-
var args = task.args;
|
|
1332
|
-
switch(args.length){
|
|
1333
|
-
case 0:
|
|
1334
|
-
callback();
|
|
1335
|
-
break;
|
|
1336
|
-
case 1:
|
|
1337
|
-
callback(args[0]);
|
|
1338
|
-
break;
|
|
1339
|
-
case 2:
|
|
1340
|
-
callback(args[0], args[1]);
|
|
1341
|
-
break;
|
|
1342
|
-
case 3:
|
|
1343
|
-
callback(args[0], args[1], args[2]);
|
|
1344
|
-
break;
|
|
1345
|
-
default:
|
|
1346
|
-
callback.apply(undefined, args);
|
|
1347
|
-
break;
|
|
1348
|
-
}
|
|
1349
|
-
}
|
|
1350
|
-
function runIfPresent(handle) {
|
|
1351
|
-
if (currentlyRunningATask) setTimeout(runIfPresent, 0, handle);
|
|
1352
|
-
else {
|
|
1353
|
-
var task = tasksByHandle[handle];
|
|
1354
|
-
if (task) {
|
|
1355
|
-
currentlyRunningATask = true;
|
|
1356
|
-
try {
|
|
1357
|
-
run(task);
|
|
1358
|
-
} finally{
|
|
1359
|
-
clearImmediate(handle);
|
|
1360
|
-
currentlyRunningATask = false;
|
|
1361
|
-
}
|
|
1362
|
-
}
|
|
1363
|
-
}
|
|
1364
|
-
}
|
|
1365
|
-
function installNextTickImplementation() {
|
|
1366
|
-
registerImmediate = function(handle) {
|
|
1367
|
-
process.nextTick(function() {
|
|
1368
|
-
runIfPresent(handle);
|
|
1369
|
-
});
|
|
1370
|
-
};
|
|
1371
|
-
}
|
|
1372
|
-
function canUsePostMessage() {
|
|
1373
|
-
if (global.postMessage && !global.importScripts) {
|
|
1374
|
-
var postMessageIsAsynchronous = true;
|
|
1375
|
-
var oldOnMessage = global.onmessage;
|
|
1376
|
-
global.onmessage = function() {
|
|
1377
|
-
postMessageIsAsynchronous = false;
|
|
1378
|
-
};
|
|
1379
|
-
global.postMessage("", "*");
|
|
1380
|
-
global.onmessage = oldOnMessage;
|
|
1381
|
-
return postMessageIsAsynchronous;
|
|
1382
|
-
}
|
|
1383
|
-
}
|
|
1384
|
-
function installPostMessageImplementation() {
|
|
1385
|
-
var messagePrefix = "setImmediate$" + Math.random() + "$";
|
|
1386
|
-
var onGlobalMessage = function(event) {
|
|
1387
|
-
if (event.source === global && "string" == typeof event.data && 0 === event.data.indexOf(messagePrefix)) runIfPresent(+event.data.slice(messagePrefix.length));
|
|
1388
|
-
};
|
|
1389
|
-
if (global.addEventListener) global.addEventListener("message", onGlobalMessage, false);
|
|
1390
|
-
else global.attachEvent("onmessage", onGlobalMessage);
|
|
1391
|
-
registerImmediate = function(handle) {
|
|
1392
|
-
global.postMessage(messagePrefix + handle, "*");
|
|
1393
|
-
};
|
|
1394
|
-
}
|
|
1395
|
-
function installMessageChannelImplementation() {
|
|
1396
|
-
var channel = new MessageChannel();
|
|
1397
|
-
channel.port1.onmessage = function(event) {
|
|
1398
|
-
var handle = event.data;
|
|
1399
|
-
runIfPresent(handle);
|
|
1400
|
-
};
|
|
1401
|
-
registerImmediate = function(handle) {
|
|
1402
|
-
channel.port2.postMessage(handle);
|
|
1403
|
-
};
|
|
1404
|
-
}
|
|
1405
|
-
function installReadyStateChangeImplementation() {
|
|
1406
|
-
var html = doc.documentElement;
|
|
1407
|
-
registerImmediate = function(handle) {
|
|
1408
|
-
var script = doc.createElement("script");
|
|
1409
|
-
script.onreadystatechange = function() {
|
|
1410
|
-
runIfPresent(handle);
|
|
1411
|
-
script.onreadystatechange = null;
|
|
1412
|
-
html.removeChild(script);
|
|
1413
|
-
script = null;
|
|
1414
|
-
};
|
|
1415
|
-
html.appendChild(script);
|
|
1416
|
-
};
|
|
1417
|
-
}
|
|
1418
|
-
function installSetTimeoutImplementation() {
|
|
1419
|
-
registerImmediate = function(handle) {
|
|
1420
|
-
setTimeout(runIfPresent, 0, handle);
|
|
1421
|
-
};
|
|
1422
|
-
}
|
|
1423
|
-
var attachTo = Object.getPrototypeOf && Object.getPrototypeOf(global);
|
|
1424
|
-
attachTo = attachTo && attachTo.setTimeout ? attachTo : global;
|
|
1425
|
-
if ("[object process]" === ({}).toString.call(global.process)) installNextTickImplementation();
|
|
1426
|
-
else if (canUsePostMessage()) installPostMessageImplementation();
|
|
1427
|
-
else if (global.MessageChannel) installMessageChannelImplementation();
|
|
1428
|
-
else if (doc && "onreadystatechange" in doc.createElement("script")) installReadyStateChangeImplementation();
|
|
1429
|
-
else installSetTimeoutImplementation();
|
|
1430
|
-
attachTo.setImmediate = setImmediate;
|
|
1431
|
-
attachTo.clearImmediate = clearImmediate;
|
|
1432
|
-
})("u" < typeof self ? void 0 === __webpack_require__.g ? this : __webpack_require__.g : self);
|
|
1433
|
-
},
|
|
1434
|
-
"../../node_modules/.pnpm/timers-browserify@2.0.12/node_modules/timers-browserify/main.js" (__unused_rspack_module, exports, __webpack_require__) {
|
|
1435
|
-
var scope = void 0 !== __webpack_require__.g && __webpack_require__.g || "u" > typeof self && self || window;
|
|
1436
|
-
var apply = Function.prototype.apply;
|
|
1437
|
-
exports.setTimeout = function() {
|
|
1438
|
-
return new Timeout(apply.call(setTimeout, scope, arguments), clearTimeout);
|
|
1439
|
-
};
|
|
1440
|
-
exports.setInterval = function() {
|
|
1441
|
-
return new Timeout(apply.call(setInterval, scope, arguments), clearInterval);
|
|
1442
|
-
};
|
|
1443
|
-
exports.clearTimeout = exports.clearInterval = function(timeout) {
|
|
1444
|
-
if (timeout) timeout.close();
|
|
1445
|
-
};
|
|
1446
|
-
function Timeout(id, clearFn) {
|
|
1447
|
-
this._id = id;
|
|
1448
|
-
this._clearFn = clearFn;
|
|
1449
|
-
}
|
|
1450
|
-
Timeout.prototype.unref = Timeout.prototype.ref = function() {};
|
|
1451
|
-
Timeout.prototype.close = function() {
|
|
1452
|
-
this._clearFn.call(scope, this._id);
|
|
1453
|
-
};
|
|
1454
|
-
exports.enroll = function(item, msecs) {
|
|
1455
|
-
clearTimeout(item._idleTimeoutId);
|
|
1456
|
-
item._idleTimeout = msecs;
|
|
1457
|
-
};
|
|
1458
|
-
exports.unenroll = function(item) {
|
|
1459
|
-
clearTimeout(item._idleTimeoutId);
|
|
1460
|
-
item._idleTimeout = -1;
|
|
1461
|
-
};
|
|
1462
|
-
exports._unrefActive = exports.active = function(item) {
|
|
1463
|
-
clearTimeout(item._idleTimeoutId);
|
|
1464
|
-
var msecs = item._idleTimeout;
|
|
1465
|
-
if (msecs >= 0) item._idleTimeoutId = setTimeout(function onTimeout() {
|
|
1466
|
-
if (item._onTimeout) item._onTimeout();
|
|
1467
|
-
}, msecs);
|
|
1468
|
-
};
|
|
1469
|
-
__webpack_require__("../../node_modules/.pnpm/setimmediate@1.0.5/node_modules/setimmediate/setImmediate.js");
|
|
1470
|
-
exports.setImmediate = "u" > typeof self && self.setImmediate || void 0 !== __webpack_require__.g && __webpack_require__.g.setImmediate || this && this.setImmediate;
|
|
1471
|
-
exports.clearImmediate = "u" > typeof self && self.clearImmediate || void 0 !== __webpack_require__.g && __webpack_require__.g.clearImmediate || this && this.clearImmediate;
|
|
1472
|
-
},
|
|
1473
1456
|
"../../node_modules/.pnpm/type-detect@4.0.8/node_modules/type-detect/type-detect.js" (module, __unused_rspack_exports, __webpack_require__) {
|
|
1474
1457
|
(function(global, factory) {
|
|
1475
1458
|
module.exports = factory();
|
|
@@ -1534,12 +1517,14 @@ __webpack_require__.add({
|
|
|
1534
1517
|
}
|
|
1535
1518
|
return typeDetect;
|
|
1536
1519
|
});
|
|
1537
|
-
}
|
|
1520
|
+
},
|
|
1521
|
+
"?4e05" () {},
|
|
1522
|
+
"?7123" () {}
|
|
1538
1523
|
});
|
|
1539
1524
|
var process = __webpack_require__("../../node_modules/.pnpm/process@0.11.10/node_modules/process/browser.js");
|
|
1540
1525
|
const RealDate = Date;
|
|
1541
1526
|
const loadFakeTimersModule = ()=>{
|
|
1542
|
-
const loaded = __webpack_require__("../../node_modules/.pnpm/@sinonjs+fake-timers@15.
|
|
1527
|
+
const loaded = __webpack_require__("../../node_modules/.pnpm/@sinonjs+fake-timers@15.3.0/node_modules/@sinonjs/fake-timers/src/fake-timers-src.js");
|
|
1543
1528
|
return {
|
|
1544
1529
|
withGlobal: loaded.withGlobal
|
|
1545
1530
|
};
|
|
@@ -1606,7 +1591,7 @@ class FakeTimers {
|
|
|
1606
1591
|
}
|
|
1607
1592
|
useFakeTimers(fakeTimersConfig = {}) {
|
|
1608
1593
|
if (this._fakingTime) this._clock.uninstall();
|
|
1609
|
-
const toFake = Object.keys(this._fakeTimers.timers).filter((timer)=>'nextTick' !== timer && 'queueMicrotask' !== timer);
|
|
1594
|
+
const toFake = Object.keys(this._fakeTimers.timers).filter((timer)=>'Intl' !== timer && 'nextTick' !== timer && 'queueMicrotask' !== timer);
|
|
1610
1595
|
const isChildProcess = void 0 !== process && !!process.send;
|
|
1611
1596
|
if (this._config?.toFake?.includes('nextTick') && isChildProcess) throw new Error('process.nextTick cannot be mocked inside child_process');
|
|
1612
1597
|
this._clock = this._fakeTimers.install({
|
|
@@ -1619,6 +1604,7 @@ class FakeTimers {
|
|
|
1619
1604
|
ignoreMissingTimers: true,
|
|
1620
1605
|
...fakeTimersConfig
|
|
1621
1606
|
});
|
|
1607
|
+
this._clock.reset();
|
|
1622
1608
|
this._fakingTime = true;
|
|
1623
1609
|
}
|
|
1624
1610
|
reset() {
|