scheduler 0.9.0 → 0.10.0

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.
@@ -1,4 +1,4 @@
1
- /** @license React v16.5.2
1
+ /** @license React v16.6.0
2
2
  * scheduler-tracing.development.js
3
3
  *
4
4
  * Copyright (c) Facebook, Inc. and its affiliates.
@@ -17,14 +17,6 @@ if (process.env.NODE_ENV !== "production") {
17
17
 
18
18
  Object.defineProperty(exports, '__esModule', { value: true });
19
19
 
20
- // Exports ReactDOM.createRoot
21
-
22
-
23
- // Experimental error-boundary API that can recover from errors within a single
24
- // render phase
25
-
26
- // Suspense
27
-
28
20
  // Helps identify side effects in begin-phase lifecycle hooks and setState reducers:
29
21
 
30
22
 
@@ -41,9 +33,6 @@ Object.defineProperty(exports, '__esModule', { value: true });
41
33
  // Warn about deprecated, async-unsafe lifecycles; relates to RFC #6:
42
34
 
43
35
 
44
- // Warn about legacy context API
45
-
46
-
47
36
  // Gather advanced timing metrics for Profiler subtrees.
48
37
 
49
38
 
@@ -1,4 +1,4 @@
1
- /** @license React v16.5.2
1
+ /** @license React v16.6.0
2
2
  * scheduler-tracing.production.min.js
3
3
  *
4
4
  * Copyright (c) Facebook, Inc. and its affiliates.
@@ -1,4 +1,4 @@
1
- /** @license React v16.5.2
1
+ /** @license React v16.6.0
2
2
  * scheduler-tracing.profiling.min.js
3
3
  *
4
4
  * Copyright (c) Facebook, Inc. and its affiliates.
@@ -1,4 +1,4 @@
1
- /** @license React v16.5.2
1
+ /** @license React v16.6.0
2
2
  * scheduler.development.js
3
3
  *
4
4
  * Copyright (c) Facebook, Inc. and its affiliates.
@@ -21,9 +21,9 @@ Object.defineProperty(exports, '__esModule', { value: true });
21
21
 
22
22
  // TODO: Use symbols?
23
23
  var ImmediatePriority = 1;
24
- var InteractivePriority = 2;
24
+ var UserBlockingPriority = 2;
25
25
  var NormalPriority = 3;
26
- var WheneverPriority = 4;
26
+ var IdlePriority = 4;
27
27
 
28
28
  // Max 31 bit integer. The max integer size in V8 for 32-bit systems.
29
29
  // Math.pow(2, 30) - 1
@@ -33,10 +33,10 @@ var maxSigned31BitInt = 1073741823;
33
33
  // Times out immediately
34
34
  var IMMEDIATE_PRIORITY_TIMEOUT = -1;
35
35
  // Eventually times out
36
- var INTERACTIVE_PRIORITY_TIMEOUT = 250;
36
+ var USER_BLOCKING_PRIORITY = 250;
37
37
  var NORMAL_PRIORITY_TIMEOUT = 5000;
38
38
  // Never times out
39
- var WHENEVER_PRIORITY_TIMEOUT = maxSigned31BitInt;
39
+ var IDLE_PRIORITY = maxSigned31BitInt;
40
40
 
41
41
  // Callbacks are stored as a circular, doubly linked list.
42
42
  var firstCallbackNode = null;
@@ -169,7 +169,7 @@ function flushFirstCallback() {
169
169
  } else if (nextAfterContinuation === firstCallbackNode) {
170
170
  // The new callback is the highest priority callback in the list.
171
171
  firstCallbackNode = continuationNode;
172
- ensureHostCallbackIsScheduled(firstCallbackNode);
172
+ ensureHostCallbackIsScheduled();
173
173
  }
174
174
 
175
175
  var previous = nextAfterContinuation.previous;
@@ -196,7 +196,7 @@ function flushImmediateWork() {
196
196
  isExecutingCallback = false;
197
197
  if (firstCallbackNode !== null) {
198
198
  // There's still work remaining. Request another callback.
199
- ensureHostCallbackIsScheduled(firstCallbackNode);
199
+ ensureHostCallbackIsScheduled();
200
200
  } else {
201
201
  isHostCallbackScheduled = false;
202
202
  }
@@ -235,7 +235,7 @@ function flushWork(didTimeout) {
235
235
  isExecutingCallback = false;
236
236
  if (firstCallbackNode !== null) {
237
237
  // There's still work remaining. Request another callback.
238
- ensureHostCallbackIsScheduled(firstCallbackNode);
238
+ ensureHostCallbackIsScheduled();
239
239
  } else {
240
240
  isHostCallbackScheduled = false;
241
241
  }
@@ -247,9 +247,9 @@ function flushWork(didTimeout) {
247
247
  function unstable_runWithPriority(priorityLevel, eventHandler) {
248
248
  switch (priorityLevel) {
249
249
  case ImmediatePriority:
250
- case InteractivePriority:
250
+ case UserBlockingPriority:
251
251
  case NormalPriority:
252
- case WheneverPriority:
252
+ case IdlePriority:
253
253
  break;
254
254
  default:
255
255
  priorityLevel = NormalPriority;
@@ -302,11 +302,11 @@ function unstable_scheduleCallback(callback, deprecated_options) {
302
302
  case ImmediatePriority:
303
303
  expirationTime = startTime + IMMEDIATE_PRIORITY_TIMEOUT;
304
304
  break;
305
- case InteractivePriority:
306
- expirationTime = startTime + INTERACTIVE_PRIORITY_TIMEOUT;
305
+ case UserBlockingPriority:
306
+ expirationTime = startTime + USER_BLOCKING_PRIORITY;
307
307
  break;
308
- case WheneverPriority:
309
- expirationTime = startTime + WHENEVER_PRIORITY_TIMEOUT;
308
+ case IdlePriority:
309
+ expirationTime = startTime + IDLE_PRIORITY;
310
310
  break;
311
311
  case NormalPriority:
312
312
  default:
@@ -328,7 +328,7 @@ function unstable_scheduleCallback(callback, deprecated_options) {
328
328
  if (firstCallbackNode === null) {
329
329
  // This is the first callback in the list.
330
330
  firstCallbackNode = newNode.next = newNode.previous = newNode;
331
- ensureHostCallbackIsScheduled(firstCallbackNode);
331
+ ensureHostCallbackIsScheduled();
332
332
  } else {
333
333
  var next = null;
334
334
  var node = firstCallbackNode;
@@ -348,7 +348,7 @@ function unstable_scheduleCallback(callback, deprecated_options) {
348
348
  } else if (next === firstCallbackNode) {
349
349
  // The new callback has the earliest expiration in the entire list.
350
350
  firstCallbackNode = newNode;
351
- ensureHostCallbackIsScheduled(firstCallbackNode);
351
+ ensureHostCallbackIsScheduled();
352
352
  }
353
353
 
354
354
  var previous = next.previous;
@@ -506,13 +506,13 @@ typeof window.addEventListener !== 'function') {
506
506
  }
507
507
  }
508
508
 
509
- var scheduledCallback = null;
510
- var isIdleScheduled = false;
509
+ var scheduledHostCallback = null;
510
+ var isMessageEventScheduled = false;
511
511
  var timeoutTime = -1;
512
512
 
513
513
  var isAnimationFrameScheduled = false;
514
514
 
515
- var isPerformingIdleWork = false;
515
+ var isFlushingHostCallback = false;
516
516
 
517
517
  var frameDeadline = 0;
518
518
  // We start out assuming that we run at 30fps but then the heuristic tracking
@@ -532,7 +532,12 @@ typeof window.addEventListener !== 'function') {
532
532
  return;
533
533
  }
534
534
 
535
- isIdleScheduled = false;
535
+ isMessageEventScheduled = false;
536
+
537
+ var prevScheduledCallback = scheduledHostCallback;
538
+ var prevTimeoutTime = timeoutTime;
539
+ scheduledHostCallback = null;
540
+ timeoutTime = -1;
536
541
 
537
542
  var currentTime = exports.unstable_now();
538
543
 
@@ -540,7 +545,7 @@ typeof window.addEventListener !== 'function') {
540
545
  if (frameDeadline - currentTime <= 0) {
541
546
  // There's no time left in this idle period. Check if the callback has
542
547
  // a timeout and whether it's been exceeded.
543
- if (timeoutTime !== -1 && timeoutTime <= currentTime) {
548
+ if (prevTimeoutTime !== -1 && prevTimeoutTime <= currentTime) {
544
549
  // Exceeded the timeout. Invoke the callback even though there's no
545
550
  // time left.
546
551
  didTimeout = true;
@@ -552,19 +557,18 @@ typeof window.addEventListener !== 'function') {
552
557
  requestAnimationFrameWithTimeout(animationTick);
553
558
  }
554
559
  // Exit without invoking the callback.
560
+ scheduledHostCallback = prevScheduledCallback;
561
+ timeoutTime = prevTimeoutTime;
555
562
  return;
556
563
  }
557
564
  }
558
565
 
559
- timeoutTime = -1;
560
- var callback = scheduledCallback;
561
- scheduledCallback = null;
562
- if (callback !== null) {
563
- isPerformingIdleWork = true;
566
+ if (prevScheduledCallback !== null) {
567
+ isFlushingHostCallback = true;
564
568
  try {
565
- callback(didTimeout);
569
+ prevScheduledCallback(didTimeout);
566
570
  } finally {
567
- isPerformingIdleWork = false;
571
+ isFlushingHostCallback = false;
568
572
  }
569
573
  }
570
574
  };
@@ -573,7 +577,22 @@ typeof window.addEventListener !== 'function') {
573
577
  window.addEventListener('message', idleTick, false);
574
578
 
575
579
  var animationTick = function (rafTime) {
576
- isAnimationFrameScheduled = false;
580
+ if (scheduledHostCallback !== null) {
581
+ // Eagerly schedule the next animation callback at the beginning of the
582
+ // frame. If the scheduler queue is not empty at the end of the frame, it
583
+ // will continue flushing inside that callback. If the queue *is* empty,
584
+ // then it will exit immediately. Posting the callback at the start of the
585
+ // frame ensures it's fired within the earliest possible frame. If we
586
+ // waited until the end of the frame to post the callback, we risk the
587
+ // browser skipping a frame and not firing the callback until the frame
588
+ // after that.
589
+ requestAnimationFrameWithTimeout(animationTick);
590
+ } else {
591
+ // No pending work. Exit.
592
+ isAnimationFrameScheduled = false;
593
+ return;
594
+ }
595
+
577
596
  var nextFrameTime = rafTime - frameDeadline + activeFrameTime;
578
597
  if (nextFrameTime < activeFrameTime && previousFrameTime < activeFrameTime) {
579
598
  if (nextFrameTime < 8) {
@@ -593,16 +612,16 @@ typeof window.addEventListener !== 'function') {
593
612
  previousFrameTime = nextFrameTime;
594
613
  }
595
614
  frameDeadline = rafTime + activeFrameTime;
596
- if (!isIdleScheduled) {
597
- isIdleScheduled = true;
615
+ if (!isMessageEventScheduled) {
616
+ isMessageEventScheduled = true;
598
617
  window.postMessage(messageKey, '*');
599
618
  }
600
619
  };
601
620
 
602
621
  requestHostCallback = function (callback, absoluteTimeout) {
603
- scheduledCallback = callback;
622
+ scheduledHostCallback = callback;
604
623
  timeoutTime = absoluteTimeout;
605
- if (isPerformingIdleWork || absoluteTimeout < 0) {
624
+ if (isFlushingHostCallback || absoluteTimeout < 0) {
606
625
  // Don't wait for the next frame. Continue working ASAP, in a new event.
607
626
  window.postMessage(messageKey, '*');
608
627
  } else if (!isAnimationFrameScheduled) {
@@ -616,16 +635,16 @@ typeof window.addEventListener !== 'function') {
616
635
  };
617
636
 
618
637
  cancelHostCallback = function () {
619
- scheduledCallback = null;
620
- isIdleScheduled = false;
638
+ scheduledHostCallback = null;
639
+ isMessageEventScheduled = false;
621
640
  timeoutTime = -1;
622
641
  };
623
642
  }
624
643
 
625
644
  exports.unstable_ImmediatePriority = ImmediatePriority;
626
- exports.unstable_InteractivePriority = InteractivePriority;
645
+ exports.unstable_UserBlockingPriority = UserBlockingPriority;
627
646
  exports.unstable_NormalPriority = NormalPriority;
628
- exports.unstable_WheneverPriority = WheneverPriority;
647
+ exports.unstable_IdlePriority = IdlePriority;
629
648
  exports.unstable_runWithPriority = unstable_runWithPriority;
630
649
  exports.unstable_scheduleCallback = unstable_scheduleCallback;
631
650
  exports.unstable_cancelCallback = unstable_cancelCallback;
@@ -1,4 +1,4 @@
1
- /** @license React v16.5.2
1
+ /** @license React v16.6.0
2
2
  * scheduler.production.min.js
3
3
  *
4
4
  * Copyright (c) Facebook, Inc. and its affiliates.
@@ -7,13 +7,13 @@
7
7
  * LICENSE file in the root directory of this source tree.
8
8
  */
9
9
 
10
- 'use strict';Object.defineProperty(exports,"__esModule",{value:!0});var c=null,e=3,h=-1,k=-1,l=!1,m=!1,n="object"===typeof performance&&"function"===typeof performance.now,q={timeRemaining:n?function(){if(null!==c&&c.expirationTime<k)return 0;var a=p()-performance.now();return 0<a?a:0}:function(){if(null!==c&&c.expirationTime<k)return 0;var a=p()-Date.now();return 0<a?a:0},didTimeout:!1};function r(){if(!l){var a=c.expirationTime;m?t():m=!0;u(v,a)}}
11
- function w(){var a=c,b=c.next;if(c===b)c=null;else{var d=c.previous;c=d.next=b;b.previous=d}a.next=a.previous=null;d=a.callback;b=a.expirationTime;a=a.priorityLevel;var f=e,R=k;e=a;k=b;try{var g=d(q)}finally{e=f,k=R}if("function"===typeof g)if(g={callback:g,priorityLevel:a,expirationTime:b,next:null,previous:null},null===c)c=g.next=g.previous=g;else{d=null;a=c;do{if(a.expirationTime>=b){d=a;break}a=a.next}while(a!==c);null===d?d=c:d===c&&(c=g,r(c));b=d.previous;b.next=d.previous=g;g.next=d;g.previous=
12
- b}}function x(){if(-1===h&&null!==c&&1===c.priorityLevel){l=!0;q.didTimeout=!0;try{do w();while(null!==c&&1===c.priorityLevel)}finally{l=!1,null!==c?r(c):m=!1}}}function v(a){l=!0;q.didTimeout=a;try{if(a)for(;null!==c;){var b=exports.unstable_now();if(c.expirationTime<=b){do w();while(null!==c&&c.expirationTime<=b)}else break}else if(null!==c){do w();while(null!==c&&0<p()-exports.unstable_now())}}finally{l=!1,null!==c?r(c):m=!1,x()}}
10
+ 'use strict';Object.defineProperty(exports,"__esModule",{value:!0});var c=null,f=3,h=-1,k=-1,l=!1,m=!1,n="object"===typeof performance&&"function"===typeof performance.now,q={timeRemaining:n?function(){if(null!==c&&c.expirationTime<k)return 0;var a=p()-performance.now();return 0<a?a:0}:function(){if(null!==c&&c.expirationTime<k)return 0;var a=p()-Date.now();return 0<a?a:0},didTimeout:!1};function r(){if(!l){var a=c.expirationTime;m?t():m=!0;u(v,a)}}
11
+ function w(){var a=c,b=c.next;if(c===b)c=null;else{var d=c.previous;c=d.next=b;b.previous=d}a.next=a.previous=null;d=a.callback;b=a.expirationTime;a=a.priorityLevel;var e=f,R=k;f=a;k=b;try{var g=d(q)}finally{f=e,k=R}if("function"===typeof g)if(g={callback:g,priorityLevel:a,expirationTime:b,next:null,previous:null},null===c)c=g.next=g.previous=g;else{d=null;a=c;do{if(a.expirationTime>=b){d=a;break}a=a.next}while(a!==c);null===d?d=c:d===c&&(c=g,r());b=d.previous;b.next=d.previous=g;g.next=d;g.previous=
12
+ b}}function x(){if(-1===h&&null!==c&&1===c.priorityLevel){l=!0;q.didTimeout=!0;try{do w();while(null!==c&&1===c.priorityLevel)}finally{l=!1,null!==c?r():m=!1}}}function v(a){l=!0;q.didTimeout=a;try{if(a)for(;null!==c;){var b=exports.unstable_now();if(c.expirationTime<=b){do w();while(null!==c&&c.expirationTime<=b)}else break}else if(null!==c){do w();while(null!==c&&0<p()-exports.unstable_now())}}finally{l=!1,null!==c?r():m=!1,x()}}
13
13
  var y=Date,z="function"===typeof setTimeout?setTimeout:void 0,A="function"===typeof clearTimeout?clearTimeout:void 0,B="function"===typeof requestAnimationFrame?requestAnimationFrame:void 0,C="function"===typeof cancelAnimationFrame?cancelAnimationFrame:void 0,D,E;function F(a){D=B(function(b){A(E);a(b)});E=z(function(){C(D);a(exports.unstable_now())},100)}if(n){var G=performance;exports.unstable_now=function(){return G.now()}}else exports.unstable_now=function(){return y.now()};var u,t,p;
14
14
  if("undefined"!==typeof window&&window._schedMock){var H=window._schedMock;u=H[0];t=H[1];p=H[2]}else if("undefined"===typeof window||"function"!==typeof window.addEventListener){var I=null,J=-1,K=function(a,b){if(null!==I){var d=I;I=null;try{J=b,d(a)}finally{J=-1}}};u=function(a,b){-1!==J?setTimeout(u,0,a,b):(I=a,setTimeout(K,b,!0,b),setTimeout(K,1073741823,!1,1073741823))};t=function(){I=null};p=function(){return Infinity};exports.unstable_now=function(){return-1===J?0:J}}else{"undefined"!==typeof console&&
15
15
  ("function"!==typeof B&&console.error("This browser doesn't support requestAnimationFrame. Make sure that you load a polyfill in older browsers. https://fb.me/react-polyfills"),"function"!==typeof C&&console.error("This browser doesn't support cancelAnimationFrame. Make sure that you load a polyfill in older browsers. https://fb.me/react-polyfills"));var L=null,M=!1,N=-1,O=!1,P=!1,Q=0,S=33,T=33;p=function(){return Q};var U="__reactIdleCallback$"+Math.random().toString(36).slice(2);window.addEventListener("message",
16
- function(a){if(a.source===window&&a.data===U){M=!1;var b=exports.unstable_now();a=!1;if(0>=Q-b)if(-1!==N&&N<=b)a=!0;else{O||(O=!0,F(V));return}N=-1;b=L;L=null;if(null!==b){P=!0;try{b(a)}finally{P=!1}}}},!1);var V=function(a){O=!1;var b=a-Q+T;b<T&&S<T?(8>b&&(b=8),T=b<S?S:b):S=b;Q=a+T;M||(M=!0,window.postMessage(U,"*"))};u=function(a,b){L=a;N=b;P||0>b?window.postMessage(U,"*"):O||(O=!0,F(V))};t=function(){L=null;M=!1;N=-1}}exports.unstable_ImmediatePriority=1;exports.unstable_InteractivePriority=2;
17
- exports.unstable_NormalPriority=3;exports.unstable_WheneverPriority=4;exports.unstable_runWithPriority=function(a,b){switch(a){case 1:case 2:case 3:case 4:break;default:a=3}var d=e,f=h;e=a;h=exports.unstable_now();try{return b()}finally{e=d,h=f,x()}};
18
- exports.unstable_scheduleCallback=function(a,b){var d=-1!==h?h:exports.unstable_now();if("object"===typeof b&&null!==b&&"number"===typeof b.timeout)b=d+b.timeout;else switch(e){case 1:b=d+-1;break;case 2:b=d+250;break;case 4:b=d+1073741823;break;default:b=d+5E3}a={callback:a,priorityLevel:e,expirationTime:b,next:null,previous:null};if(null===c)c=a.next=a.previous=a,r(c);else{d=null;var f=c;do{if(f.expirationTime>b){d=f;break}f=f.next}while(f!==c);null===d?d=c:d===c&&(c=a,r(c));b=d.previous;b.next=
19
- d.previous=a;a.next=d;a.previous=b}return a};exports.unstable_cancelCallback=function(a){var b=a.next;if(null!==b){if(b===a)c=null;else{a===c&&(c=b);var d=a.previous;d.next=b;b.previous=d}a.next=a.previous=null}};exports.unstable_wrapCallback=function(a){var b=e;return function(){var d=e,f=h;e=b;h=exports.unstable_now();try{return a.apply(this,arguments)}finally{e=d,h=f,x()}}};exports.unstable_getCurrentPriorityLevel=function(){return e};
16
+ function(a){if(a.source===window&&a.data===U){M=!1;a=L;var b=N;L=null;N=-1;var d=exports.unstable_now(),e=!1;if(0>=Q-d)if(-1!==b&&b<=d)e=!0;else{O||(O=!0,F(V));L=a;N=b;return}if(null!==a){P=!0;try{a(e)}finally{P=!1}}}},!1);var V=function(a){if(null!==L){F(V);var b=a-Q+T;b<T&&S<T?(8>b&&(b=8),T=b<S?S:b):S=b;Q=a+T;M||(M=!0,window.postMessage(U,"*"))}else O=!1};u=function(a,b){L=a;N=b;P||0>b?window.postMessage(U,"*"):O||(O=!0,F(V))};t=function(){L=null;M=!1;N=-1}}exports.unstable_ImmediatePriority=1;
17
+ exports.unstable_UserBlockingPriority=2;exports.unstable_NormalPriority=3;exports.unstable_IdlePriority=4;exports.unstable_runWithPriority=function(a,b){switch(a){case 1:case 2:case 3:case 4:break;default:a=3}var d=f,e=h;f=a;h=exports.unstable_now();try{return b()}finally{f=d,h=e,x()}};
18
+ exports.unstable_scheduleCallback=function(a,b){var d=-1!==h?h:exports.unstable_now();if("object"===typeof b&&null!==b&&"number"===typeof b.timeout)b=d+b.timeout;else switch(f){case 1:b=d+-1;break;case 2:b=d+250;break;case 4:b=d+1073741823;break;default:b=d+5E3}a={callback:a,priorityLevel:f,expirationTime:b,next:null,previous:null};if(null===c)c=a.next=a.previous=a,r();else{d=null;var e=c;do{if(e.expirationTime>b){d=e;break}e=e.next}while(e!==c);null===d?d=c:d===c&&(c=a,r());b=d.previous;b.next=d.previous=
19
+ a;a.next=d;a.previous=b}return a};exports.unstable_cancelCallback=function(a){var b=a.next;if(null!==b){if(b===a)c=null;else{a===c&&(c=b);var d=a.previous;d.next=b;b.previous=d}a.next=a.previous=null}};exports.unstable_wrapCallback=function(a){var b=f;return function(){var d=f,e=h;f=b;h=exports.unstable_now();try{return a.apply(this,arguments)}finally{f=d,h=e,x()}}};exports.unstable_getCurrentPriorityLevel=function(){return f};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "scheduler",
3
- "version": "0.9.0",
3
+ "version": "0.10.0",
4
4
  "description": "Cooperative scheduler for the browser environment.",
5
5
  "main": "index.js",
6
6
  "repository": "facebook/react",
@@ -13,6 +13,7 @@
13
13
  },
14
14
  "homepage": "https://reactjs.org/",
15
15
  "dependencies": {
16
+ "loose-envify": "^1.1.0",
16
17
  "object-assign": "^4.1.1"
17
18
  },
18
19
  "files": [
@@ -23,5 +24,10 @@
23
24
  "tracing-profiling.js",
24
25
  "cjs/",
25
26
  "umd/"
26
- ]
27
+ ],
28
+ "browserify": {
29
+ "transform": [
30
+ "loose-envify"
31
+ ]
32
+ }
27
33
  }