scheduler 0.20.1 → 0.20.2
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/build-info.json +5 -5
- package/cjs/scheduler-tracing.development.js +1 -1
- package/cjs/scheduler-tracing.production.min.js +1 -1
- package/cjs/scheduler-tracing.profiling.min.js +1 -1
- package/cjs/scheduler-unstable_mock.development.js +4 -202
- package/cjs/scheduler-unstable_mock.production.min.js +1 -1
- package/cjs/scheduler-unstable_post_task.development.js +1 -1
- package/cjs/scheduler-unstable_post_task.production.min.js +1 -1
- package/cjs/scheduler.development.js +4 -202
- package/cjs/scheduler.production.min.js +1 -1
- package/package.json +1 -1
- package/umd/scheduler-unstable_mock.development.js +4 -202
- package/umd/scheduler-unstable_mock.production.min.js +1 -1
package/build-info.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
|
-
"branch": "
|
|
3
|
-
"buildNumber": "
|
|
4
|
-
"checksum": "
|
|
5
|
-
"commit": "
|
|
2
|
+
"branch": "pull/21051",
|
|
3
|
+
"buildNumber": "287151",
|
|
4
|
+
"checksum": "94f5c65",
|
|
5
|
+
"commit": "12adaffef",
|
|
6
6
|
"environment": "ci",
|
|
7
|
-
"reactVersion": "17.0.0-
|
|
7
|
+
"reactVersion": "17.0.0-12adaffef"
|
|
8
8
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @license React v0.20.
|
|
1
|
+
/** @license React v0.20.2
|
|
2
2
|
* scheduler-unstable_mock.development.js
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
@@ -14,7 +14,7 @@ if (process.env.NODE_ENV !== "production") {
|
|
|
14
14
|
'use strict';
|
|
15
15
|
|
|
16
16
|
var enableSchedulerDebugging = false;
|
|
17
|
-
var enableProfiling =
|
|
17
|
+
var enableProfiling = false;
|
|
18
18
|
|
|
19
19
|
var currentTime = 0;
|
|
20
20
|
var scheduledCallback = null;
|
|
@@ -292,172 +292,13 @@ function compare(a, b) {
|
|
|
292
292
|
}
|
|
293
293
|
|
|
294
294
|
// TODO: Use symbols?
|
|
295
|
-
var NoPriority = 0;
|
|
296
295
|
var ImmediatePriority = 1;
|
|
297
296
|
var UserBlockingPriority = 2;
|
|
298
297
|
var NormalPriority = 3;
|
|
299
298
|
var LowPriority = 4;
|
|
300
299
|
var IdlePriority = 5;
|
|
301
300
|
|
|
302
|
-
var runIdCounter = 0;
|
|
303
|
-
var mainThreadIdCounter = 0;
|
|
304
|
-
var profilingStateSize = 4;
|
|
305
|
-
var sharedProfilingBuffer = // $FlowFixMe Flow doesn't know about SharedArrayBuffer
|
|
306
|
-
typeof SharedArrayBuffer === 'function' ? new SharedArrayBuffer(profilingStateSize * Int32Array.BYTES_PER_ELEMENT) : // $FlowFixMe Flow doesn't know about ArrayBuffer
|
|
307
|
-
typeof ArrayBuffer === 'function' ? new ArrayBuffer(profilingStateSize * Int32Array.BYTES_PER_ELEMENT) : null // Don't crash the init path on IE9
|
|
308
|
-
;
|
|
309
|
-
var profilingState = sharedProfilingBuffer !== null ? new Int32Array(sharedProfilingBuffer) : []; // We can't read this but it helps save bytes for null checks
|
|
310
|
-
|
|
311
|
-
var PRIORITY = 0;
|
|
312
|
-
var CURRENT_TASK_ID = 1;
|
|
313
|
-
var CURRENT_RUN_ID = 2;
|
|
314
|
-
var QUEUE_SIZE = 3;
|
|
315
|
-
|
|
316
|
-
{
|
|
317
|
-
profilingState[PRIORITY] = NoPriority; // This is maintained with a counter, because the size of the priority queue
|
|
318
|
-
// array might include canceled tasks.
|
|
319
|
-
|
|
320
|
-
profilingState[QUEUE_SIZE] = 0;
|
|
321
|
-
profilingState[CURRENT_TASK_ID] = 0;
|
|
322
|
-
} // Bytes per element is 4
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
var INITIAL_EVENT_LOG_SIZE = 131072;
|
|
326
|
-
var MAX_EVENT_LOG_SIZE = 524288; // Equivalent to 2 megabytes
|
|
327
|
-
|
|
328
|
-
var eventLogSize = 0;
|
|
329
|
-
var eventLogBuffer = null;
|
|
330
|
-
var eventLog = null;
|
|
331
|
-
var eventLogIndex = 0;
|
|
332
|
-
var TaskStartEvent = 1;
|
|
333
|
-
var TaskCompleteEvent = 2;
|
|
334
|
-
var TaskErrorEvent = 3;
|
|
335
|
-
var TaskCancelEvent = 4;
|
|
336
|
-
var TaskRunEvent = 5;
|
|
337
|
-
var TaskYieldEvent = 6;
|
|
338
|
-
var SchedulerSuspendEvent = 7;
|
|
339
|
-
var SchedulerResumeEvent = 8;
|
|
340
|
-
|
|
341
|
-
function logEvent(entries) {
|
|
342
|
-
if (eventLog !== null) {
|
|
343
|
-
var offset = eventLogIndex;
|
|
344
|
-
eventLogIndex += entries.length;
|
|
345
|
-
|
|
346
|
-
if (eventLogIndex + 1 > eventLogSize) {
|
|
347
|
-
eventLogSize *= 2;
|
|
348
|
-
|
|
349
|
-
if (eventLogSize > MAX_EVENT_LOG_SIZE) {
|
|
350
|
-
// Using console['error'] to evade Babel and ESLint
|
|
351
|
-
console['error']("Scheduler Profiling: Event log exceeded maximum size. Don't " + 'forget to call `stopLoggingProfilingEvents()`.');
|
|
352
|
-
stopLoggingProfilingEvents();
|
|
353
|
-
return;
|
|
354
|
-
}
|
|
355
|
-
|
|
356
|
-
var newEventLog = new Int32Array(eventLogSize * 4);
|
|
357
|
-
newEventLog.set(eventLog);
|
|
358
|
-
eventLogBuffer = newEventLog.buffer;
|
|
359
|
-
eventLog = newEventLog;
|
|
360
|
-
}
|
|
361
|
-
|
|
362
|
-
eventLog.set(entries, offset);
|
|
363
|
-
}
|
|
364
|
-
}
|
|
365
|
-
|
|
366
|
-
function startLoggingProfilingEvents() {
|
|
367
|
-
eventLogSize = INITIAL_EVENT_LOG_SIZE;
|
|
368
|
-
eventLogBuffer = new ArrayBuffer(eventLogSize * 4);
|
|
369
|
-
eventLog = new Int32Array(eventLogBuffer);
|
|
370
|
-
eventLogIndex = 0;
|
|
371
|
-
}
|
|
372
|
-
function stopLoggingProfilingEvents() {
|
|
373
|
-
var buffer = eventLogBuffer;
|
|
374
|
-
eventLogSize = 0;
|
|
375
|
-
eventLogBuffer = null;
|
|
376
|
-
eventLog = null;
|
|
377
|
-
eventLogIndex = 0;
|
|
378
|
-
return buffer;
|
|
379
|
-
}
|
|
380
|
-
function markTaskStart(task, ms) {
|
|
381
|
-
{
|
|
382
|
-
profilingState[QUEUE_SIZE]++;
|
|
383
|
-
|
|
384
|
-
if (eventLog !== null) {
|
|
385
|
-
// performance.now returns a float, representing milliseconds. When the
|
|
386
|
-
// event is logged, it's coerced to an int. Convert to microseconds to
|
|
387
|
-
// maintain extra degrees of precision.
|
|
388
|
-
logEvent([TaskStartEvent, ms * 1000, task.id, task.priorityLevel]);
|
|
389
|
-
}
|
|
390
|
-
}
|
|
391
|
-
}
|
|
392
|
-
function markTaskCompleted(task, ms) {
|
|
393
|
-
{
|
|
394
|
-
profilingState[PRIORITY] = NoPriority;
|
|
395
|
-
profilingState[CURRENT_TASK_ID] = 0;
|
|
396
|
-
profilingState[QUEUE_SIZE]--;
|
|
397
|
-
|
|
398
|
-
if (eventLog !== null) {
|
|
399
|
-
logEvent([TaskCompleteEvent, ms * 1000, task.id]);
|
|
400
|
-
}
|
|
401
|
-
}
|
|
402
|
-
}
|
|
403
|
-
function markTaskCanceled(task, ms) {
|
|
404
|
-
{
|
|
405
|
-
profilingState[QUEUE_SIZE]--;
|
|
406
|
-
|
|
407
|
-
if (eventLog !== null) {
|
|
408
|
-
logEvent([TaskCancelEvent, ms * 1000, task.id]);
|
|
409
|
-
}
|
|
410
|
-
}
|
|
411
|
-
}
|
|
412
301
|
function markTaskErrored(task, ms) {
|
|
413
|
-
{
|
|
414
|
-
profilingState[PRIORITY] = NoPriority;
|
|
415
|
-
profilingState[CURRENT_TASK_ID] = 0;
|
|
416
|
-
profilingState[QUEUE_SIZE]--;
|
|
417
|
-
|
|
418
|
-
if (eventLog !== null) {
|
|
419
|
-
logEvent([TaskErrorEvent, ms * 1000, task.id]);
|
|
420
|
-
}
|
|
421
|
-
}
|
|
422
|
-
}
|
|
423
|
-
function markTaskRun(task, ms) {
|
|
424
|
-
{
|
|
425
|
-
runIdCounter++;
|
|
426
|
-
profilingState[PRIORITY] = task.priorityLevel;
|
|
427
|
-
profilingState[CURRENT_TASK_ID] = task.id;
|
|
428
|
-
profilingState[CURRENT_RUN_ID] = runIdCounter;
|
|
429
|
-
|
|
430
|
-
if (eventLog !== null) {
|
|
431
|
-
logEvent([TaskRunEvent, ms * 1000, task.id, runIdCounter]);
|
|
432
|
-
}
|
|
433
|
-
}
|
|
434
|
-
}
|
|
435
|
-
function markTaskYield(task, ms) {
|
|
436
|
-
{
|
|
437
|
-
profilingState[PRIORITY] = NoPriority;
|
|
438
|
-
profilingState[CURRENT_TASK_ID] = 0;
|
|
439
|
-
profilingState[CURRENT_RUN_ID] = 0;
|
|
440
|
-
|
|
441
|
-
if (eventLog !== null) {
|
|
442
|
-
logEvent([TaskYieldEvent, ms * 1000, task.id, runIdCounter]);
|
|
443
|
-
}
|
|
444
|
-
}
|
|
445
|
-
}
|
|
446
|
-
function markSchedulerSuspended(ms) {
|
|
447
|
-
{
|
|
448
|
-
mainThreadIdCounter++;
|
|
449
|
-
|
|
450
|
-
if (eventLog !== null) {
|
|
451
|
-
logEvent([SchedulerSuspendEvent, ms * 1000, mainThreadIdCounter]);
|
|
452
|
-
}
|
|
453
|
-
}
|
|
454
|
-
}
|
|
455
|
-
function markSchedulerUnsuspended(ms) {
|
|
456
|
-
{
|
|
457
|
-
if (eventLog !== null) {
|
|
458
|
-
logEvent([SchedulerResumeEvent, ms * 1000, mainThreadIdCounter]);
|
|
459
|
-
}
|
|
460
|
-
}
|
|
461
302
|
}
|
|
462
303
|
|
|
463
304
|
/* eslint-disable no-var */
|
|
@@ -498,11 +339,6 @@ function advanceTimers(currentTime) {
|
|
|
498
339
|
pop(timerQueue);
|
|
499
340
|
timer.sortIndex = timer.expirationTime;
|
|
500
341
|
push(taskQueue, timer);
|
|
501
|
-
|
|
502
|
-
{
|
|
503
|
-
markTaskStart(timer, currentTime);
|
|
504
|
-
timer.isQueued = true;
|
|
505
|
-
}
|
|
506
342
|
} else {
|
|
507
343
|
// Remaining timers are pending.
|
|
508
344
|
return;
|
|
@@ -531,9 +367,6 @@ function handleTimeout(currentTime) {
|
|
|
531
367
|
}
|
|
532
368
|
|
|
533
369
|
function flushWork(hasTimeRemaining, initialTime) {
|
|
534
|
-
{
|
|
535
|
-
markSchedulerUnsuspended(initialTime);
|
|
536
|
-
} // We'll need a host callback the next time work is scheduled.
|
|
537
370
|
|
|
538
371
|
|
|
539
372
|
isHostCallbackScheduled = false;
|
|
@@ -568,12 +401,6 @@ function flushWork(hasTimeRemaining, initialTime) {
|
|
|
568
401
|
currentTask = null;
|
|
569
402
|
currentPriorityLevel = previousPriorityLevel;
|
|
570
403
|
isPerformingWork = false;
|
|
571
|
-
|
|
572
|
-
{
|
|
573
|
-
var _currentTime = getCurrentTime();
|
|
574
|
-
|
|
575
|
-
markSchedulerSuspended(_currentTime);
|
|
576
|
-
}
|
|
577
404
|
}
|
|
578
405
|
}
|
|
579
406
|
|
|
@@ -594,18 +421,13 @@ function workLoop(hasTimeRemaining, initialTime) {
|
|
|
594
421
|
currentTask.callback = null;
|
|
595
422
|
currentPriorityLevel = currentTask.priorityLevel;
|
|
596
423
|
var didUserCallbackTimeout = currentTask.expirationTime <= currentTime;
|
|
597
|
-
|
|
424
|
+
|
|
598
425
|
var continuationCallback = callback(didUserCallbackTimeout);
|
|
599
426
|
currentTime = getCurrentTime();
|
|
600
427
|
|
|
601
428
|
if (typeof continuationCallback === 'function') {
|
|
602
429
|
currentTask.callback = continuationCallback;
|
|
603
|
-
markTaskYield(currentTask, currentTime);
|
|
604
430
|
} else {
|
|
605
|
-
{
|
|
606
|
-
markTaskCompleted(currentTask, currentTime);
|
|
607
|
-
currentTask.isQueued = false;
|
|
608
|
-
}
|
|
609
431
|
|
|
610
432
|
if (currentTask === peek(taskQueue)) {
|
|
611
433
|
pop(taskQueue);
|
|
@@ -750,10 +572,6 @@ function unstable_scheduleCallback(priorityLevel, callback, options) {
|
|
|
750
572
|
sortIndex: -1
|
|
751
573
|
};
|
|
752
574
|
|
|
753
|
-
{
|
|
754
|
-
newTask.isQueued = false;
|
|
755
|
-
}
|
|
756
|
-
|
|
757
575
|
if (startTime > currentTime) {
|
|
758
576
|
// This is a delayed task.
|
|
759
577
|
newTask.sortIndex = startTime;
|
|
@@ -774,11 +592,6 @@ function unstable_scheduleCallback(priorityLevel, callback, options) {
|
|
|
774
592
|
} else {
|
|
775
593
|
newTask.sortIndex = expirationTime;
|
|
776
594
|
push(taskQueue, newTask);
|
|
777
|
-
|
|
778
|
-
{
|
|
779
|
-
markTaskStart(newTask, currentTime);
|
|
780
|
-
newTask.isQueued = true;
|
|
781
|
-
} // Schedule a host callback, if needed. If we're already performing work,
|
|
782
595
|
// wait until the next time we yield.
|
|
783
596
|
|
|
784
597
|
|
|
@@ -807,13 +620,6 @@ function unstable_getFirstCallbackNode() {
|
|
|
807
620
|
}
|
|
808
621
|
|
|
809
622
|
function unstable_cancelCallback(task) {
|
|
810
|
-
{
|
|
811
|
-
if (task.isQueued) {
|
|
812
|
-
var currentTime = getCurrentTime();
|
|
813
|
-
markTaskCanceled(task, currentTime);
|
|
814
|
-
task.isQueued = false;
|
|
815
|
-
}
|
|
816
|
-
} // Null out the callback to indicate the task has been canceled. (Can't
|
|
817
623
|
// remove from the queue because you can't remove arbitrary nodes from an
|
|
818
624
|
// array based heap, only the first one.)
|
|
819
625
|
|
|
@@ -826,11 +632,7 @@ function unstable_getCurrentPriorityLevel() {
|
|
|
826
632
|
}
|
|
827
633
|
|
|
828
634
|
var unstable_requestPaint = requestPaint;
|
|
829
|
-
var unstable_Profiling =
|
|
830
|
-
startLoggingProfilingEvents: startLoggingProfilingEvents,
|
|
831
|
-
stopLoggingProfilingEvents: stopLoggingProfilingEvents,
|
|
832
|
-
sharedProfilingBuffer: sharedProfilingBuffer
|
|
833
|
-
} ;
|
|
635
|
+
var unstable_Profiling = null;
|
|
834
636
|
|
|
835
637
|
exports.unstable_IdlePriority = IdlePriority;
|
|
836
638
|
exports.unstable_ImmediatePriority = ImmediatePriority;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @license React v0.20.
|
|
1
|
+
/** @license React v0.20.2
|
|
2
2
|
* scheduler.development.js
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
@@ -14,7 +14,7 @@ if (process.env.NODE_ENV !== "production") {
|
|
|
14
14
|
'use strict';
|
|
15
15
|
|
|
16
16
|
var enableSchedulerDebugging = false;
|
|
17
|
-
var enableProfiling =
|
|
17
|
+
var enableProfiling = false;
|
|
18
18
|
|
|
19
19
|
var requestHostCallback;
|
|
20
20
|
var requestHostTimeout;
|
|
@@ -284,172 +284,13 @@ function compare(a, b) {
|
|
|
284
284
|
}
|
|
285
285
|
|
|
286
286
|
// TODO: Use symbols?
|
|
287
|
-
var NoPriority = 0;
|
|
288
287
|
var ImmediatePriority = 1;
|
|
289
288
|
var UserBlockingPriority = 2;
|
|
290
289
|
var NormalPriority = 3;
|
|
291
290
|
var LowPriority = 4;
|
|
292
291
|
var IdlePriority = 5;
|
|
293
292
|
|
|
294
|
-
var runIdCounter = 0;
|
|
295
|
-
var mainThreadIdCounter = 0;
|
|
296
|
-
var profilingStateSize = 4;
|
|
297
|
-
var sharedProfilingBuffer = // $FlowFixMe Flow doesn't know about SharedArrayBuffer
|
|
298
|
-
typeof SharedArrayBuffer === 'function' ? new SharedArrayBuffer(profilingStateSize * Int32Array.BYTES_PER_ELEMENT) : // $FlowFixMe Flow doesn't know about ArrayBuffer
|
|
299
|
-
typeof ArrayBuffer === 'function' ? new ArrayBuffer(profilingStateSize * Int32Array.BYTES_PER_ELEMENT) : null // Don't crash the init path on IE9
|
|
300
|
-
;
|
|
301
|
-
var profilingState = sharedProfilingBuffer !== null ? new Int32Array(sharedProfilingBuffer) : []; // We can't read this but it helps save bytes for null checks
|
|
302
|
-
|
|
303
|
-
var PRIORITY = 0;
|
|
304
|
-
var CURRENT_TASK_ID = 1;
|
|
305
|
-
var CURRENT_RUN_ID = 2;
|
|
306
|
-
var QUEUE_SIZE = 3;
|
|
307
|
-
|
|
308
|
-
{
|
|
309
|
-
profilingState[PRIORITY] = NoPriority; // This is maintained with a counter, because the size of the priority queue
|
|
310
|
-
// array might include canceled tasks.
|
|
311
|
-
|
|
312
|
-
profilingState[QUEUE_SIZE] = 0;
|
|
313
|
-
profilingState[CURRENT_TASK_ID] = 0;
|
|
314
|
-
} // Bytes per element is 4
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
var INITIAL_EVENT_LOG_SIZE = 131072;
|
|
318
|
-
var MAX_EVENT_LOG_SIZE = 524288; // Equivalent to 2 megabytes
|
|
319
|
-
|
|
320
|
-
var eventLogSize = 0;
|
|
321
|
-
var eventLogBuffer = null;
|
|
322
|
-
var eventLog = null;
|
|
323
|
-
var eventLogIndex = 0;
|
|
324
|
-
var TaskStartEvent = 1;
|
|
325
|
-
var TaskCompleteEvent = 2;
|
|
326
|
-
var TaskErrorEvent = 3;
|
|
327
|
-
var TaskCancelEvent = 4;
|
|
328
|
-
var TaskRunEvent = 5;
|
|
329
|
-
var TaskYieldEvent = 6;
|
|
330
|
-
var SchedulerSuspendEvent = 7;
|
|
331
|
-
var SchedulerResumeEvent = 8;
|
|
332
|
-
|
|
333
|
-
function logEvent(entries) {
|
|
334
|
-
if (eventLog !== null) {
|
|
335
|
-
var offset = eventLogIndex;
|
|
336
|
-
eventLogIndex += entries.length;
|
|
337
|
-
|
|
338
|
-
if (eventLogIndex + 1 > eventLogSize) {
|
|
339
|
-
eventLogSize *= 2;
|
|
340
|
-
|
|
341
|
-
if (eventLogSize > MAX_EVENT_LOG_SIZE) {
|
|
342
|
-
// Using console['error'] to evade Babel and ESLint
|
|
343
|
-
console['error']("Scheduler Profiling: Event log exceeded maximum size. Don't " + 'forget to call `stopLoggingProfilingEvents()`.');
|
|
344
|
-
stopLoggingProfilingEvents();
|
|
345
|
-
return;
|
|
346
|
-
}
|
|
347
|
-
|
|
348
|
-
var newEventLog = new Int32Array(eventLogSize * 4);
|
|
349
|
-
newEventLog.set(eventLog);
|
|
350
|
-
eventLogBuffer = newEventLog.buffer;
|
|
351
|
-
eventLog = newEventLog;
|
|
352
|
-
}
|
|
353
|
-
|
|
354
|
-
eventLog.set(entries, offset);
|
|
355
|
-
}
|
|
356
|
-
}
|
|
357
|
-
|
|
358
|
-
function startLoggingProfilingEvents() {
|
|
359
|
-
eventLogSize = INITIAL_EVENT_LOG_SIZE;
|
|
360
|
-
eventLogBuffer = new ArrayBuffer(eventLogSize * 4);
|
|
361
|
-
eventLog = new Int32Array(eventLogBuffer);
|
|
362
|
-
eventLogIndex = 0;
|
|
363
|
-
}
|
|
364
|
-
function stopLoggingProfilingEvents() {
|
|
365
|
-
var buffer = eventLogBuffer;
|
|
366
|
-
eventLogSize = 0;
|
|
367
|
-
eventLogBuffer = null;
|
|
368
|
-
eventLog = null;
|
|
369
|
-
eventLogIndex = 0;
|
|
370
|
-
return buffer;
|
|
371
|
-
}
|
|
372
|
-
function markTaskStart(task, ms) {
|
|
373
|
-
{
|
|
374
|
-
profilingState[QUEUE_SIZE]++;
|
|
375
|
-
|
|
376
|
-
if (eventLog !== null) {
|
|
377
|
-
// performance.now returns a float, representing milliseconds. When the
|
|
378
|
-
// event is logged, it's coerced to an int. Convert to microseconds to
|
|
379
|
-
// maintain extra degrees of precision.
|
|
380
|
-
logEvent([TaskStartEvent, ms * 1000, task.id, task.priorityLevel]);
|
|
381
|
-
}
|
|
382
|
-
}
|
|
383
|
-
}
|
|
384
|
-
function markTaskCompleted(task, ms) {
|
|
385
|
-
{
|
|
386
|
-
profilingState[PRIORITY] = NoPriority;
|
|
387
|
-
profilingState[CURRENT_TASK_ID] = 0;
|
|
388
|
-
profilingState[QUEUE_SIZE]--;
|
|
389
|
-
|
|
390
|
-
if (eventLog !== null) {
|
|
391
|
-
logEvent([TaskCompleteEvent, ms * 1000, task.id]);
|
|
392
|
-
}
|
|
393
|
-
}
|
|
394
|
-
}
|
|
395
|
-
function markTaskCanceled(task, ms) {
|
|
396
|
-
{
|
|
397
|
-
profilingState[QUEUE_SIZE]--;
|
|
398
|
-
|
|
399
|
-
if (eventLog !== null) {
|
|
400
|
-
logEvent([TaskCancelEvent, ms * 1000, task.id]);
|
|
401
|
-
}
|
|
402
|
-
}
|
|
403
|
-
}
|
|
404
293
|
function markTaskErrored(task, ms) {
|
|
405
|
-
{
|
|
406
|
-
profilingState[PRIORITY] = NoPriority;
|
|
407
|
-
profilingState[CURRENT_TASK_ID] = 0;
|
|
408
|
-
profilingState[QUEUE_SIZE]--;
|
|
409
|
-
|
|
410
|
-
if (eventLog !== null) {
|
|
411
|
-
logEvent([TaskErrorEvent, ms * 1000, task.id]);
|
|
412
|
-
}
|
|
413
|
-
}
|
|
414
|
-
}
|
|
415
|
-
function markTaskRun(task, ms) {
|
|
416
|
-
{
|
|
417
|
-
runIdCounter++;
|
|
418
|
-
profilingState[PRIORITY] = task.priorityLevel;
|
|
419
|
-
profilingState[CURRENT_TASK_ID] = task.id;
|
|
420
|
-
profilingState[CURRENT_RUN_ID] = runIdCounter;
|
|
421
|
-
|
|
422
|
-
if (eventLog !== null) {
|
|
423
|
-
logEvent([TaskRunEvent, ms * 1000, task.id, runIdCounter]);
|
|
424
|
-
}
|
|
425
|
-
}
|
|
426
|
-
}
|
|
427
|
-
function markTaskYield(task, ms) {
|
|
428
|
-
{
|
|
429
|
-
profilingState[PRIORITY] = NoPriority;
|
|
430
|
-
profilingState[CURRENT_TASK_ID] = 0;
|
|
431
|
-
profilingState[CURRENT_RUN_ID] = 0;
|
|
432
|
-
|
|
433
|
-
if (eventLog !== null) {
|
|
434
|
-
logEvent([TaskYieldEvent, ms * 1000, task.id, runIdCounter]);
|
|
435
|
-
}
|
|
436
|
-
}
|
|
437
|
-
}
|
|
438
|
-
function markSchedulerSuspended(ms) {
|
|
439
|
-
{
|
|
440
|
-
mainThreadIdCounter++;
|
|
441
|
-
|
|
442
|
-
if (eventLog !== null) {
|
|
443
|
-
logEvent([SchedulerSuspendEvent, ms * 1000, mainThreadIdCounter]);
|
|
444
|
-
}
|
|
445
|
-
}
|
|
446
|
-
}
|
|
447
|
-
function markSchedulerUnsuspended(ms) {
|
|
448
|
-
{
|
|
449
|
-
if (eventLog !== null) {
|
|
450
|
-
logEvent([SchedulerResumeEvent, ms * 1000, mainThreadIdCounter]);
|
|
451
|
-
}
|
|
452
|
-
}
|
|
453
294
|
}
|
|
454
295
|
|
|
455
296
|
/* eslint-disable no-var */
|
|
@@ -490,11 +331,6 @@ function advanceTimers(currentTime) {
|
|
|
490
331
|
pop(timerQueue);
|
|
491
332
|
timer.sortIndex = timer.expirationTime;
|
|
492
333
|
push(taskQueue, timer);
|
|
493
|
-
|
|
494
|
-
{
|
|
495
|
-
markTaskStart(timer, currentTime);
|
|
496
|
-
timer.isQueued = true;
|
|
497
|
-
}
|
|
498
334
|
} else {
|
|
499
335
|
// Remaining timers are pending.
|
|
500
336
|
return;
|
|
@@ -523,9 +359,6 @@ function handleTimeout(currentTime) {
|
|
|
523
359
|
}
|
|
524
360
|
|
|
525
361
|
function flushWork(hasTimeRemaining, initialTime) {
|
|
526
|
-
{
|
|
527
|
-
markSchedulerUnsuspended(initialTime);
|
|
528
|
-
} // We'll need a host callback the next time work is scheduled.
|
|
529
362
|
|
|
530
363
|
|
|
531
364
|
isHostCallbackScheduled = false;
|
|
@@ -560,12 +393,6 @@ function flushWork(hasTimeRemaining, initialTime) {
|
|
|
560
393
|
currentTask = null;
|
|
561
394
|
currentPriorityLevel = previousPriorityLevel;
|
|
562
395
|
isPerformingWork = false;
|
|
563
|
-
|
|
564
|
-
{
|
|
565
|
-
var _currentTime = exports.unstable_now();
|
|
566
|
-
|
|
567
|
-
markSchedulerSuspended(_currentTime);
|
|
568
|
-
}
|
|
569
396
|
}
|
|
570
397
|
}
|
|
571
398
|
|
|
@@ -586,18 +413,13 @@ function workLoop(hasTimeRemaining, initialTime) {
|
|
|
586
413
|
currentTask.callback = null;
|
|
587
414
|
currentPriorityLevel = currentTask.priorityLevel;
|
|
588
415
|
var didUserCallbackTimeout = currentTask.expirationTime <= currentTime;
|
|
589
|
-
|
|
416
|
+
|
|
590
417
|
var continuationCallback = callback(didUserCallbackTimeout);
|
|
591
418
|
currentTime = exports.unstable_now();
|
|
592
419
|
|
|
593
420
|
if (typeof continuationCallback === 'function') {
|
|
594
421
|
currentTask.callback = continuationCallback;
|
|
595
|
-
markTaskYield(currentTask, currentTime);
|
|
596
422
|
} else {
|
|
597
|
-
{
|
|
598
|
-
markTaskCompleted(currentTask, currentTime);
|
|
599
|
-
currentTask.isQueued = false;
|
|
600
|
-
}
|
|
601
423
|
|
|
602
424
|
if (currentTask === peek(taskQueue)) {
|
|
603
425
|
pop(taskQueue);
|
|
@@ -742,10 +564,6 @@ function unstable_scheduleCallback(priorityLevel, callback, options) {
|
|
|
742
564
|
sortIndex: -1
|
|
743
565
|
};
|
|
744
566
|
|
|
745
|
-
{
|
|
746
|
-
newTask.isQueued = false;
|
|
747
|
-
}
|
|
748
|
-
|
|
749
567
|
if (startTime > currentTime) {
|
|
750
568
|
// This is a delayed task.
|
|
751
569
|
newTask.sortIndex = startTime;
|
|
@@ -766,11 +584,6 @@ function unstable_scheduleCallback(priorityLevel, callback, options) {
|
|
|
766
584
|
} else {
|
|
767
585
|
newTask.sortIndex = expirationTime;
|
|
768
586
|
push(taskQueue, newTask);
|
|
769
|
-
|
|
770
|
-
{
|
|
771
|
-
markTaskStart(newTask, currentTime);
|
|
772
|
-
newTask.isQueued = true;
|
|
773
|
-
} // Schedule a host callback, if needed. If we're already performing work,
|
|
774
587
|
// wait until the next time we yield.
|
|
775
588
|
|
|
776
589
|
|
|
@@ -799,13 +612,6 @@ function unstable_getFirstCallbackNode() {
|
|
|
799
612
|
}
|
|
800
613
|
|
|
801
614
|
function unstable_cancelCallback(task) {
|
|
802
|
-
{
|
|
803
|
-
if (task.isQueued) {
|
|
804
|
-
var currentTime = exports.unstable_now();
|
|
805
|
-
markTaskCanceled(task, currentTime);
|
|
806
|
-
task.isQueued = false;
|
|
807
|
-
}
|
|
808
|
-
} // Null out the callback to indicate the task has been canceled. (Can't
|
|
809
615
|
// remove from the queue because you can't remove arbitrary nodes from an
|
|
810
616
|
// array based heap, only the first one.)
|
|
811
617
|
|
|
@@ -818,11 +624,7 @@ function unstable_getCurrentPriorityLevel() {
|
|
|
818
624
|
}
|
|
819
625
|
|
|
820
626
|
var unstable_requestPaint = requestPaint;
|
|
821
|
-
var unstable_Profiling =
|
|
822
|
-
startLoggingProfilingEvents: startLoggingProfilingEvents,
|
|
823
|
-
stopLoggingProfilingEvents: stopLoggingProfilingEvents,
|
|
824
|
-
sharedProfilingBuffer: sharedProfilingBuffer
|
|
825
|
-
} ;
|
|
627
|
+
var unstable_Profiling = null;
|
|
826
628
|
|
|
827
629
|
exports.unstable_IdlePriority = IdlePriority;
|
|
828
630
|
exports.unstable_ImmediatePriority = ImmediatePriority;
|
package/package.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @license React v0.20.
|
|
1
|
+
/** @license React v0.20.2
|
|
2
2
|
* scheduler-unstable_mock.development.js
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
}(this, (function (exports) { 'use strict';
|
|
14
14
|
|
|
15
15
|
var enableSchedulerDebugging = false;
|
|
16
|
-
var enableProfiling =
|
|
16
|
+
var enableProfiling = false;
|
|
17
17
|
|
|
18
18
|
var currentTime = 0;
|
|
19
19
|
var scheduledCallback = null;
|
|
@@ -291,172 +291,13 @@
|
|
|
291
291
|
}
|
|
292
292
|
|
|
293
293
|
// TODO: Use symbols?
|
|
294
|
-
var NoPriority = 0;
|
|
295
294
|
var ImmediatePriority = 1;
|
|
296
295
|
var UserBlockingPriority = 2;
|
|
297
296
|
var NormalPriority = 3;
|
|
298
297
|
var LowPriority = 4;
|
|
299
298
|
var IdlePriority = 5;
|
|
300
299
|
|
|
301
|
-
var runIdCounter = 0;
|
|
302
|
-
var mainThreadIdCounter = 0;
|
|
303
|
-
var profilingStateSize = 4;
|
|
304
|
-
var sharedProfilingBuffer = // $FlowFixMe Flow doesn't know about SharedArrayBuffer
|
|
305
|
-
typeof SharedArrayBuffer === 'function' ? new SharedArrayBuffer(profilingStateSize * Int32Array.BYTES_PER_ELEMENT) : // $FlowFixMe Flow doesn't know about ArrayBuffer
|
|
306
|
-
typeof ArrayBuffer === 'function' ? new ArrayBuffer(profilingStateSize * Int32Array.BYTES_PER_ELEMENT) : null // Don't crash the init path on IE9
|
|
307
|
-
;
|
|
308
|
-
var profilingState = sharedProfilingBuffer !== null ? new Int32Array(sharedProfilingBuffer) : []; // We can't read this but it helps save bytes for null checks
|
|
309
|
-
|
|
310
|
-
var PRIORITY = 0;
|
|
311
|
-
var CURRENT_TASK_ID = 1;
|
|
312
|
-
var CURRENT_RUN_ID = 2;
|
|
313
|
-
var QUEUE_SIZE = 3;
|
|
314
|
-
|
|
315
|
-
{
|
|
316
|
-
profilingState[PRIORITY] = NoPriority; // This is maintained with a counter, because the size of the priority queue
|
|
317
|
-
// array might include canceled tasks.
|
|
318
|
-
|
|
319
|
-
profilingState[QUEUE_SIZE] = 0;
|
|
320
|
-
profilingState[CURRENT_TASK_ID] = 0;
|
|
321
|
-
} // Bytes per element is 4
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
var INITIAL_EVENT_LOG_SIZE = 131072;
|
|
325
|
-
var MAX_EVENT_LOG_SIZE = 524288; // Equivalent to 2 megabytes
|
|
326
|
-
|
|
327
|
-
var eventLogSize = 0;
|
|
328
|
-
var eventLogBuffer = null;
|
|
329
|
-
var eventLog = null;
|
|
330
|
-
var eventLogIndex = 0;
|
|
331
|
-
var TaskStartEvent = 1;
|
|
332
|
-
var TaskCompleteEvent = 2;
|
|
333
|
-
var TaskErrorEvent = 3;
|
|
334
|
-
var TaskCancelEvent = 4;
|
|
335
|
-
var TaskRunEvent = 5;
|
|
336
|
-
var TaskYieldEvent = 6;
|
|
337
|
-
var SchedulerSuspendEvent = 7;
|
|
338
|
-
var SchedulerResumeEvent = 8;
|
|
339
|
-
|
|
340
|
-
function logEvent(entries) {
|
|
341
|
-
if (eventLog !== null) {
|
|
342
|
-
var offset = eventLogIndex;
|
|
343
|
-
eventLogIndex += entries.length;
|
|
344
|
-
|
|
345
|
-
if (eventLogIndex + 1 > eventLogSize) {
|
|
346
|
-
eventLogSize *= 2;
|
|
347
|
-
|
|
348
|
-
if (eventLogSize > MAX_EVENT_LOG_SIZE) {
|
|
349
|
-
// Using console['error'] to evade Babel and ESLint
|
|
350
|
-
console['error']("Scheduler Profiling: Event log exceeded maximum size. Don't " + 'forget to call `stopLoggingProfilingEvents()`.');
|
|
351
|
-
stopLoggingProfilingEvents();
|
|
352
|
-
return;
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
var newEventLog = new Int32Array(eventLogSize * 4);
|
|
356
|
-
newEventLog.set(eventLog);
|
|
357
|
-
eventLogBuffer = newEventLog.buffer;
|
|
358
|
-
eventLog = newEventLog;
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
eventLog.set(entries, offset);
|
|
362
|
-
}
|
|
363
|
-
}
|
|
364
|
-
|
|
365
|
-
function startLoggingProfilingEvents() {
|
|
366
|
-
eventLogSize = INITIAL_EVENT_LOG_SIZE;
|
|
367
|
-
eventLogBuffer = new ArrayBuffer(eventLogSize * 4);
|
|
368
|
-
eventLog = new Int32Array(eventLogBuffer);
|
|
369
|
-
eventLogIndex = 0;
|
|
370
|
-
}
|
|
371
|
-
function stopLoggingProfilingEvents() {
|
|
372
|
-
var buffer = eventLogBuffer;
|
|
373
|
-
eventLogSize = 0;
|
|
374
|
-
eventLogBuffer = null;
|
|
375
|
-
eventLog = null;
|
|
376
|
-
eventLogIndex = 0;
|
|
377
|
-
return buffer;
|
|
378
|
-
}
|
|
379
|
-
function markTaskStart(task, ms) {
|
|
380
|
-
{
|
|
381
|
-
profilingState[QUEUE_SIZE]++;
|
|
382
|
-
|
|
383
|
-
if (eventLog !== null) {
|
|
384
|
-
// performance.now returns a float, representing milliseconds. When the
|
|
385
|
-
// event is logged, it's coerced to an int. Convert to microseconds to
|
|
386
|
-
// maintain extra degrees of precision.
|
|
387
|
-
logEvent([TaskStartEvent, ms * 1000, task.id, task.priorityLevel]);
|
|
388
|
-
}
|
|
389
|
-
}
|
|
390
|
-
}
|
|
391
|
-
function markTaskCompleted(task, ms) {
|
|
392
|
-
{
|
|
393
|
-
profilingState[PRIORITY] = NoPriority;
|
|
394
|
-
profilingState[CURRENT_TASK_ID] = 0;
|
|
395
|
-
profilingState[QUEUE_SIZE]--;
|
|
396
|
-
|
|
397
|
-
if (eventLog !== null) {
|
|
398
|
-
logEvent([TaskCompleteEvent, ms * 1000, task.id]);
|
|
399
|
-
}
|
|
400
|
-
}
|
|
401
|
-
}
|
|
402
|
-
function markTaskCanceled(task, ms) {
|
|
403
|
-
{
|
|
404
|
-
profilingState[QUEUE_SIZE]--;
|
|
405
|
-
|
|
406
|
-
if (eventLog !== null) {
|
|
407
|
-
logEvent([TaskCancelEvent, ms * 1000, task.id]);
|
|
408
|
-
}
|
|
409
|
-
}
|
|
410
|
-
}
|
|
411
300
|
function markTaskErrored(task, ms) {
|
|
412
|
-
{
|
|
413
|
-
profilingState[PRIORITY] = NoPriority;
|
|
414
|
-
profilingState[CURRENT_TASK_ID] = 0;
|
|
415
|
-
profilingState[QUEUE_SIZE]--;
|
|
416
|
-
|
|
417
|
-
if (eventLog !== null) {
|
|
418
|
-
logEvent([TaskErrorEvent, ms * 1000, task.id]);
|
|
419
|
-
}
|
|
420
|
-
}
|
|
421
|
-
}
|
|
422
|
-
function markTaskRun(task, ms) {
|
|
423
|
-
{
|
|
424
|
-
runIdCounter++;
|
|
425
|
-
profilingState[PRIORITY] = task.priorityLevel;
|
|
426
|
-
profilingState[CURRENT_TASK_ID] = task.id;
|
|
427
|
-
profilingState[CURRENT_RUN_ID] = runIdCounter;
|
|
428
|
-
|
|
429
|
-
if (eventLog !== null) {
|
|
430
|
-
logEvent([TaskRunEvent, ms * 1000, task.id, runIdCounter]);
|
|
431
|
-
}
|
|
432
|
-
}
|
|
433
|
-
}
|
|
434
|
-
function markTaskYield(task, ms) {
|
|
435
|
-
{
|
|
436
|
-
profilingState[PRIORITY] = NoPriority;
|
|
437
|
-
profilingState[CURRENT_TASK_ID] = 0;
|
|
438
|
-
profilingState[CURRENT_RUN_ID] = 0;
|
|
439
|
-
|
|
440
|
-
if (eventLog !== null) {
|
|
441
|
-
logEvent([TaskYieldEvent, ms * 1000, task.id, runIdCounter]);
|
|
442
|
-
}
|
|
443
|
-
}
|
|
444
|
-
}
|
|
445
|
-
function markSchedulerSuspended(ms) {
|
|
446
|
-
{
|
|
447
|
-
mainThreadIdCounter++;
|
|
448
|
-
|
|
449
|
-
if (eventLog !== null) {
|
|
450
|
-
logEvent([SchedulerSuspendEvent, ms * 1000, mainThreadIdCounter]);
|
|
451
|
-
}
|
|
452
|
-
}
|
|
453
|
-
}
|
|
454
|
-
function markSchedulerUnsuspended(ms) {
|
|
455
|
-
{
|
|
456
|
-
if (eventLog !== null) {
|
|
457
|
-
logEvent([SchedulerResumeEvent, ms * 1000, mainThreadIdCounter]);
|
|
458
|
-
}
|
|
459
|
-
}
|
|
460
301
|
}
|
|
461
302
|
|
|
462
303
|
/* eslint-disable no-var */
|
|
@@ -497,11 +338,6 @@
|
|
|
497
338
|
pop(timerQueue);
|
|
498
339
|
timer.sortIndex = timer.expirationTime;
|
|
499
340
|
push(taskQueue, timer);
|
|
500
|
-
|
|
501
|
-
{
|
|
502
|
-
markTaskStart(timer, currentTime);
|
|
503
|
-
timer.isQueued = true;
|
|
504
|
-
}
|
|
505
341
|
} else {
|
|
506
342
|
// Remaining timers are pending.
|
|
507
343
|
return;
|
|
@@ -530,9 +366,6 @@
|
|
|
530
366
|
}
|
|
531
367
|
|
|
532
368
|
function flushWork(hasTimeRemaining, initialTime) {
|
|
533
|
-
{
|
|
534
|
-
markSchedulerUnsuspended(initialTime);
|
|
535
|
-
} // We'll need a host callback the next time work is scheduled.
|
|
536
369
|
|
|
537
370
|
|
|
538
371
|
isHostCallbackScheduled = false;
|
|
@@ -567,12 +400,6 @@
|
|
|
567
400
|
currentTask = null;
|
|
568
401
|
currentPriorityLevel = previousPriorityLevel;
|
|
569
402
|
isPerformingWork = false;
|
|
570
|
-
|
|
571
|
-
{
|
|
572
|
-
var _currentTime = getCurrentTime();
|
|
573
|
-
|
|
574
|
-
markSchedulerSuspended(_currentTime);
|
|
575
|
-
}
|
|
576
403
|
}
|
|
577
404
|
}
|
|
578
405
|
|
|
@@ -593,18 +420,13 @@
|
|
|
593
420
|
currentTask.callback = null;
|
|
594
421
|
currentPriorityLevel = currentTask.priorityLevel;
|
|
595
422
|
var didUserCallbackTimeout = currentTask.expirationTime <= currentTime;
|
|
596
|
-
|
|
423
|
+
|
|
597
424
|
var continuationCallback = callback(didUserCallbackTimeout);
|
|
598
425
|
currentTime = getCurrentTime();
|
|
599
426
|
|
|
600
427
|
if (typeof continuationCallback === 'function') {
|
|
601
428
|
currentTask.callback = continuationCallback;
|
|
602
|
-
markTaskYield(currentTask, currentTime);
|
|
603
429
|
} else {
|
|
604
|
-
{
|
|
605
|
-
markTaskCompleted(currentTask, currentTime);
|
|
606
|
-
currentTask.isQueued = false;
|
|
607
|
-
}
|
|
608
430
|
|
|
609
431
|
if (currentTask === peek(taskQueue)) {
|
|
610
432
|
pop(taskQueue);
|
|
@@ -749,10 +571,6 @@
|
|
|
749
571
|
sortIndex: -1
|
|
750
572
|
};
|
|
751
573
|
|
|
752
|
-
{
|
|
753
|
-
newTask.isQueued = false;
|
|
754
|
-
}
|
|
755
|
-
|
|
756
574
|
if (startTime > currentTime) {
|
|
757
575
|
// This is a delayed task.
|
|
758
576
|
newTask.sortIndex = startTime;
|
|
@@ -773,11 +591,6 @@
|
|
|
773
591
|
} else {
|
|
774
592
|
newTask.sortIndex = expirationTime;
|
|
775
593
|
push(taskQueue, newTask);
|
|
776
|
-
|
|
777
|
-
{
|
|
778
|
-
markTaskStart(newTask, currentTime);
|
|
779
|
-
newTask.isQueued = true;
|
|
780
|
-
} // Schedule a host callback, if needed. If we're already performing work,
|
|
781
594
|
// wait until the next time we yield.
|
|
782
595
|
|
|
783
596
|
|
|
@@ -806,13 +619,6 @@
|
|
|
806
619
|
}
|
|
807
620
|
|
|
808
621
|
function unstable_cancelCallback(task) {
|
|
809
|
-
{
|
|
810
|
-
if (task.isQueued) {
|
|
811
|
-
var currentTime = getCurrentTime();
|
|
812
|
-
markTaskCanceled(task, currentTime);
|
|
813
|
-
task.isQueued = false;
|
|
814
|
-
}
|
|
815
|
-
} // Null out the callback to indicate the task has been canceled. (Can't
|
|
816
622
|
// remove from the queue because you can't remove arbitrary nodes from an
|
|
817
623
|
// array based heap, only the first one.)
|
|
818
624
|
|
|
@@ -825,11 +631,7 @@
|
|
|
825
631
|
}
|
|
826
632
|
|
|
827
633
|
var unstable_requestPaint = requestPaint;
|
|
828
|
-
var unstable_Profiling =
|
|
829
|
-
startLoggingProfilingEvents: startLoggingProfilingEvents,
|
|
830
|
-
stopLoggingProfilingEvents: stopLoggingProfilingEvents,
|
|
831
|
-
sharedProfilingBuffer: sharedProfilingBuffer
|
|
832
|
-
} ;
|
|
634
|
+
var unstable_Profiling = null;
|
|
833
635
|
|
|
834
636
|
exports.unstable_IdlePriority = IdlePriority;
|
|
835
637
|
exports.unstable_ImmediatePriority = ImmediatePriority;
|