react 16.5.2 → 16.6.0-alpha.8af6728
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/cjs/react.development.js +33 -58
- package/cjs/react.production.min.js +16 -16
- package/package.json +2 -2
- package/umd/react.development.js +371 -137
- package/umd/react.production.min.js +25 -21
- package/umd/react.profiling.min.js +29 -26
package/cjs/react.development.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @license React v16.
|
|
1
|
+
/** @license React v16.6.0-alpha.8af6728
|
|
2
2
|
* react.development.js
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
@@ -20,7 +20,7 @@ var checkPropTypes = require('prop-types/checkPropTypes');
|
|
|
20
20
|
|
|
21
21
|
// TODO: this is special because it gets imported during build.
|
|
22
22
|
|
|
23
|
-
var ReactVersion = '16.
|
|
23
|
+
var ReactVersion = '16.6.0-alpha.8af6728';
|
|
24
24
|
|
|
25
25
|
// The Symbol used to tag the ReactElement-like types. If there is no native Symbol
|
|
26
26
|
// nor polyfill, then a plain number is used for performance.
|
|
@@ -33,9 +33,10 @@ var REACT_STRICT_MODE_TYPE = hasSymbol ? Symbol.for('react.strict_mode') : 0xeac
|
|
|
33
33
|
var REACT_PROFILER_TYPE = hasSymbol ? Symbol.for('react.profiler') : 0xead2;
|
|
34
34
|
var REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for('react.provider') : 0xeacd;
|
|
35
35
|
var REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for('react.context') : 0xeace;
|
|
36
|
-
var
|
|
36
|
+
var REACT_CONCURRENT_MODE_TYPE = hasSymbol ? Symbol.for('react.concurrent_mode') : 0xeacf;
|
|
37
37
|
var REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for('react.forward_ref') : 0xead0;
|
|
38
|
-
var
|
|
38
|
+
var REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for('react.suspense') : 0xead1;
|
|
39
|
+
var REACT_PURE_TYPE = hasSymbol ? Symbol.for('react.pure') : 0xead3;
|
|
39
40
|
|
|
40
41
|
var MAYBE_ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
|
|
41
42
|
var FAUX_ITERATOR_SYMBOL = '@@iterator';
|
|
@@ -51,48 +52,6 @@ function getIteratorFn(maybeIterable) {
|
|
|
51
52
|
return null;
|
|
52
53
|
}
|
|
53
54
|
|
|
54
|
-
// Exports ReactDOM.createRoot
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
// Experimental error-boundary API that can recover from errors within a single
|
|
58
|
-
// render phase
|
|
59
|
-
|
|
60
|
-
// Suspense
|
|
61
|
-
var enableSuspense = false;
|
|
62
|
-
// Helps identify side effects in begin-phase lifecycle hooks and setState reducers:
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
// In some cases, StrictMode should also double-render lifecycles.
|
|
66
|
-
// This can be confusing for tests though,
|
|
67
|
-
// And it can be bad for performance in production.
|
|
68
|
-
// This feature flag can be used to control the behavior:
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
// To preserve the "Pause on caught exceptions" behavior of the debugger, we
|
|
72
|
-
// replay the begin phase of a failed component inside invokeGuardedCallback.
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
// Warn about deprecated, async-unsafe lifecycles; relates to RFC #6:
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
// Warn about legacy context API
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
// Gather advanced timing metrics for Profiler subtrees.
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
// Trace which interactions trigger each commit.
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
// Only used in www builds.
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
// Only used in www builds.
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
// React Fire: prevent the value and checked attributes from syncing
|
|
94
|
-
// with their related DOM properties
|
|
95
|
-
|
|
96
55
|
/**
|
|
97
56
|
* Use invariant() to assert state which your program assumes to be true.
|
|
98
57
|
*
|
|
@@ -556,8 +515,8 @@ function getComponentName(type) {
|
|
|
556
515
|
return type;
|
|
557
516
|
}
|
|
558
517
|
switch (type) {
|
|
559
|
-
case
|
|
560
|
-
return '
|
|
518
|
+
case REACT_CONCURRENT_MODE_TYPE:
|
|
519
|
+
return 'ConcurrentMode';
|
|
561
520
|
case REACT_FRAGMENT_TYPE:
|
|
562
521
|
return 'Fragment';
|
|
563
522
|
case REACT_PORTAL_TYPE:
|
|
@@ -566,8 +525,8 @@ function getComponentName(type) {
|
|
|
566
525
|
return 'Profiler';
|
|
567
526
|
case REACT_STRICT_MODE_TYPE:
|
|
568
527
|
return 'StrictMode';
|
|
569
|
-
case
|
|
570
|
-
return '
|
|
528
|
+
case REACT_SUSPENSE_TYPE:
|
|
529
|
+
return 'Suspense';
|
|
571
530
|
}
|
|
572
531
|
if (typeof type === 'object') {
|
|
573
532
|
switch (type.$$typeof) {
|
|
@@ -1385,10 +1344,28 @@ function forwardRef(render) {
|
|
|
1385
1344
|
};
|
|
1386
1345
|
}
|
|
1387
1346
|
|
|
1347
|
+
function pure(render, compare) {
|
|
1348
|
+
{
|
|
1349
|
+
if (typeof render !== 'function') {
|
|
1350
|
+
warningWithoutStack$1(false, 'pure: The first argument must be a function component. Instead ' + 'received: %s', render === null ? 'null' : typeof render);
|
|
1351
|
+
} else {
|
|
1352
|
+
var prototype = render.prototype;
|
|
1353
|
+
if (prototype && prototype.isReactComponent) {
|
|
1354
|
+
warningWithoutStack$1(false, 'pure: The first argument must be a function component. Classes ' + 'are not supported. Use React.PureComponent instead.');
|
|
1355
|
+
}
|
|
1356
|
+
}
|
|
1357
|
+
}
|
|
1358
|
+
return {
|
|
1359
|
+
$$typeof: REACT_PURE_TYPE,
|
|
1360
|
+
render: render,
|
|
1361
|
+
compare: compare === undefined ? null : compare
|
|
1362
|
+
};
|
|
1363
|
+
}
|
|
1364
|
+
|
|
1388
1365
|
function isValidElementType(type) {
|
|
1389
1366
|
return typeof type === 'string' || typeof type === 'function' ||
|
|
1390
1367
|
// Note: its typeof might be other than 'symbol' or 'number' if it's a polyfill.
|
|
1391
|
-
type === REACT_FRAGMENT_TYPE || type ===
|
|
1368
|
+
type === REACT_FRAGMENT_TYPE || type === REACT_CONCURRENT_MODE_TYPE || type === REACT_PROFILER_TYPE || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || typeof type === 'object' && type !== null && (typeof type.then === 'function' || type.$$typeof === REACT_PURE_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE);
|
|
1392
1369
|
}
|
|
1393
1370
|
|
|
1394
1371
|
/**
|
|
@@ -1536,7 +1513,7 @@ function validatePropTypes(element) {
|
|
|
1536
1513
|
var name = void 0,
|
|
1537
1514
|
propTypes = void 0;
|
|
1538
1515
|
if (typeof type === 'function') {
|
|
1539
|
-
// Class or
|
|
1516
|
+
// Class or function component
|
|
1540
1517
|
name = type.displayName || type.name;
|
|
1541
1518
|
propTypes = type.propTypes;
|
|
1542
1519
|
} else if (typeof type === 'object' && type !== null && type.$$typeof === REACT_FORWARD_REF_TYPE) {
|
|
@@ -1688,10 +1665,13 @@ var React = {
|
|
|
1688
1665
|
|
|
1689
1666
|
createContext: createContext,
|
|
1690
1667
|
forwardRef: forwardRef,
|
|
1668
|
+
lazy: lazy,
|
|
1669
|
+
pure: pure,
|
|
1691
1670
|
|
|
1692
1671
|
Fragment: REACT_FRAGMENT_TYPE,
|
|
1693
1672
|
StrictMode: REACT_STRICT_MODE_TYPE,
|
|
1694
|
-
|
|
1673
|
+
unstable_ConcurrentMode: REACT_CONCURRENT_MODE_TYPE,
|
|
1674
|
+
unstable_Suspense: REACT_SUSPENSE_TYPE,
|
|
1695
1675
|
unstable_Profiler: REACT_PROFILER_TYPE,
|
|
1696
1676
|
|
|
1697
1677
|
createElement: createElementWithValidation,
|
|
@@ -1704,11 +1684,6 @@ var React = {
|
|
|
1704
1684
|
__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED: ReactSharedInternals
|
|
1705
1685
|
};
|
|
1706
1686
|
|
|
1707
|
-
if (enableSuspense) {
|
|
1708
|
-
React.Placeholder = REACT_PLACEHOLDER_TYPE;
|
|
1709
|
-
React.lazy = lazy;
|
|
1710
|
-
}
|
|
1711
|
-
|
|
1712
1687
|
|
|
1713
1688
|
|
|
1714
1689
|
var React$2 = Object.freeze({
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @license React v16.
|
|
1
|
+
/** @license React v16.6.0-alpha.8af6728
|
|
2
2
|
* react.production.min.js
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
@@ -7,18 +7,18 @@
|
|
|
7
7
|
* LICENSE file in the root directory of this source tree.
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
'use strict';var
|
|
11
|
-
|
|
12
|
-
function
|
|
13
|
-
function
|
|
14
|
-
|
|
15
|
-
function
|
|
16
|
-
function
|
|
17
|
-
function
|
|
18
|
-
function
|
|
19
|
-
0;!(e=a.next()).done;)e=e.value,f=b+
|
|
20
|
-
function
|
|
21
|
-
var X={Children:{map:function(a,b,d){if(null==a)return a;var c=[];W(a,c,null,b,d);return c},forEach:function(a,b,d){if(null==a)return a;b=
|
|
22
|
-
_currentValue:a,_currentValue2:a,Provider:null,Consumer:null,unstable_read:null};a.Provider={$$typeof:v,_context:a};a.Consumer=a;a.unstable_read=
|
|
23
|
-
var k=void 0;a.type&&a.type.defaultProps&&(
|
|
24
|
-
assign:
|
|
10
|
+
'use strict';var k=require("object-assign"),n="function"===typeof Symbol&&Symbol.for,p=n?Symbol.for("react.element"):60103,q=n?Symbol.for("react.portal"):60106,r=n?Symbol.for("react.fragment"):60107,t=n?Symbol.for("react.strict_mode"):60108,u=n?Symbol.for("react.profiler"):60114,v=n?Symbol.for("react.provider"):60109,w=n?Symbol.for("react.context"):60110,x=n?Symbol.for("react.concurrent_mode"):60111,y=n?Symbol.for("react.forward_ref"):60112,z=n?Symbol.for("react.suspense"):60113,A=n?Symbol.for("react.pure"):
|
|
11
|
+
60115,B="function"===typeof Symbol&&Symbol.iterator;function C(a,b,d,c,e,g,h,f){if(!a){a=void 0;if(void 0===b)a=Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var l=[d,c,e,g,h,f],m=0;a=Error(b.replace(/%s/g,function(){return l[m++]}));a.name="Invariant Violation"}a.framesToPop=1;throw a;}}
|
|
12
|
+
function D(a){for(var b=arguments.length-1,d="https://reactjs.org/docs/error-decoder.html?invariant="+a,c=0;c<b;c++)d+="&args[]="+encodeURIComponent(arguments[c+1]);C(!1,"Minified React error #"+a+"; visit %s for the full message or use the non-minified dev environment for full errors and additional helpful warnings. ",d)}var E={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},F={};
|
|
13
|
+
function G(a,b,d){this.props=a;this.context=b;this.refs=F;this.updater=d||E}G.prototype.isReactComponent={};G.prototype.setState=function(a,b){"object"!==typeof a&&"function"!==typeof a&&null!=a?D("85"):void 0;this.updater.enqueueSetState(this,a,b,"setState")};G.prototype.forceUpdate=function(a){this.updater.enqueueForceUpdate(this,a,"forceUpdate")};function H(){}H.prototype=G.prototype;function I(a,b,d){this.props=a;this.context=b;this.refs=F;this.updater=d||E}var J=I.prototype=new H;
|
|
14
|
+
J.constructor=I;k(J,G.prototype);J.isPureReactComponent=!0;var K={current:null,currentDispatcher:null},L=Object.prototype.hasOwnProperty,M={key:!0,ref:!0,__self:!0,__source:!0};
|
|
15
|
+
function N(a,b,d){var c=void 0,e={},g=null,h=null;if(null!=b)for(c in void 0!==b.ref&&(h=b.ref),void 0!==b.key&&(g=""+b.key),b)L.call(b,c)&&!M.hasOwnProperty(c)&&(e[c]=b[c]);var f=arguments.length-2;if(1===f)e.children=d;else if(1<f){for(var l=Array(f),m=0;m<f;m++)l[m]=arguments[m+2];e.children=l}if(a&&a.defaultProps)for(c in f=a.defaultProps,f)void 0===e[c]&&(e[c]=f[c]);return{$$typeof:p,type:a,key:g,ref:h,props:e,_owner:K.current}}
|
|
16
|
+
function aa(a,b){return{$$typeof:p,type:a.type,key:b,ref:a.ref,props:a.props,_owner:a._owner}}function O(a){return"object"===typeof a&&null!==a&&a.$$typeof===p}function escape(a){var b={"=":"=0",":":"=2"};return"$"+(""+a).replace(/[=:]/g,function(a){return b[a]})}var P=/\/+/g,Q=[];function R(a,b,d,c){if(Q.length){var e=Q.pop();e.result=a;e.keyPrefix=b;e.func=d;e.context=c;e.count=0;return e}return{result:a,keyPrefix:b,func:d,context:c,count:0}}
|
|
17
|
+
function S(a){a.result=null;a.keyPrefix=null;a.func=null;a.context=null;a.count=0;10>Q.length&&Q.push(a)}
|
|
18
|
+
function T(a,b,d,c){var e=typeof a;if("undefined"===e||"boolean"===e)a=null;var g=!1;if(null===a)g=!0;else switch(e){case "string":case "number":g=!0;break;case "object":switch(a.$$typeof){case p:case q:g=!0}}if(g)return d(c,a,""===b?"."+U(a,0):b),1;g=0;b=""===b?".":b+":";if(Array.isArray(a))for(var h=0;h<a.length;h++){e=a[h];var f=b+U(e,h);g+=T(e,f,d,c)}else if(null===a||"object"!==typeof a?f=null:(f=B&&a[B]||a["@@iterator"],f="function"===typeof f?f:null),"function"===typeof f)for(a=f.call(a),h=
|
|
19
|
+
0;!(e=a.next()).done;)e=e.value,f=b+U(e,h++),g+=T(e,f,d,c);else"object"===e&&(d=""+a,D("31","[object Object]"===d?"object with keys {"+Object.keys(a).join(", ")+"}":d,""));return g}function V(a,b,d){return null==a?0:T(a,"",b,d)}function U(a,b){return"object"===typeof a&&null!==a&&null!=a.key?escape(a.key):b.toString(36)}function ba(a,b){a.func.call(a.context,b,a.count++)}
|
|
20
|
+
function ca(a,b,d){var c=a.result,e=a.keyPrefix;a=a.func.call(a.context,b,a.count++);Array.isArray(a)?W(a,c,d,function(a){return a}):null!=a&&(O(a)&&(a=aa(a,e+(!a.key||b&&b.key===a.key?"":(""+a.key).replace(P,"$&/")+"/")+d)),c.push(a))}function W(a,b,d,c,e){var g="";null!=d&&(g=(""+d).replace(P,"$&/")+"/");b=R(b,g,c,e);V(a,ca,b);S(b)}function da(a,b){var d=K.currentDispatcher;null===d?D("277"):void 0;return d.readContext(a,b)}
|
|
21
|
+
var X={Children:{map:function(a,b,d){if(null==a)return a;var c=[];W(a,c,null,b,d);return c},forEach:function(a,b,d){if(null==a)return a;b=R(null,null,b,d);V(a,ba,b);S(b)},count:function(a){return V(a,function(){return null},null)},toArray:function(a){var b=[];W(a,b,null,function(a){return a});return b},only:function(a){O(a)?void 0:D("143");return a}},createRef:function(){return{current:null}},Component:G,PureComponent:I,createContext:function(a,b){void 0===b&&(b=null);a={$$typeof:w,_calculateChangedBits:b,
|
|
22
|
+
_currentValue:a,_currentValue2:a,Provider:null,Consumer:null,unstable_read:null};a.Provider={$$typeof:v,_context:a};a.Consumer=a;a.unstable_read=da.bind(null,a);return a},forwardRef:function(a){return{$$typeof:y,render:a}},lazy:function(a){var b=null;return{then:function(d,c){null===b&&(b=a(),a=null);return b.then(d,c)},_reactStatus:-1,_reactResult:null}},pure:function(a,b){return{$$typeof:A,render:a,compare:void 0===b?null:b}},Fragment:r,StrictMode:t,unstable_ConcurrentMode:x,unstable_Suspense:z,
|
|
23
|
+
unstable_Profiler:u,createElement:N,cloneElement:function(a,b,d){null===a||void 0===a?D("267",a):void 0;var c=void 0,e=k({},a.props),g=a.key,h=a.ref,f=a._owner;if(null!=b){void 0!==b.ref&&(h=b.ref,f=K.current);void 0!==b.key&&(g=""+b.key);var l=void 0;a.type&&a.type.defaultProps&&(l=a.type.defaultProps);for(c in b)L.call(b,c)&&!M.hasOwnProperty(c)&&(e[c]=void 0===b[c]&&void 0!==l?l[c]:b[c])}c=arguments.length-2;if(1===c)e.children=d;else if(1<c){l=Array(c);for(var m=0;m<c;m++)l[m]=arguments[m+2];
|
|
24
|
+
e.children=l}return{$$typeof:p,type:a.type,key:g,ref:h,props:e,_owner:f}},createFactory:function(a){var b=N.bind(null,a);b.type=a;return b},isValidElement:O,version:"16.6.0-alpha.8af6728",__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED:{ReactCurrentOwner:K,assign:k}},Y={default:X},Z=Y&&X||Y;module.exports=Z.default||Z;
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"keywords": [
|
|
5
5
|
"react"
|
|
6
6
|
],
|
|
7
|
-
"version": "16.
|
|
7
|
+
"version": "16.6.0-alpha.8af6728",
|
|
8
8
|
"homepage": "https://reactjs.org/",
|
|
9
9
|
"bugs": "https://github.com/facebook/react/issues",
|
|
10
10
|
"license": "MIT",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"loose-envify": "^1.1.0",
|
|
25
25
|
"object-assign": "^4.1.1",
|
|
26
26
|
"prop-types": "^15.6.2",
|
|
27
|
-
"
|
|
27
|
+
"scheduler": "^0.10.0-alpha.8af6728"
|
|
28
28
|
},
|
|
29
29
|
"browserify": {
|
|
30
30
|
"transform": [
|
package/umd/react.development.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @license React v16.
|
|
1
|
+
/** @license React v16.6.0-alpha.8af6728
|
|
2
2
|
* react.development.js
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
|
|
18
18
|
// TODO: this is special because it gets imported during build.
|
|
19
19
|
|
|
20
|
-
var ReactVersion = '16.
|
|
20
|
+
var ReactVersion = '16.6.0-alpha.8af6728';
|
|
21
21
|
|
|
22
22
|
// The Symbol used to tag the ReactElement-like types. If there is no native Symbol
|
|
23
23
|
// nor polyfill, then a plain number is used for performance.
|
|
@@ -30,9 +30,10 @@ var REACT_STRICT_MODE_TYPE = hasSymbol ? Symbol.for('react.strict_mode') : 0xeac
|
|
|
30
30
|
var REACT_PROFILER_TYPE = hasSymbol ? Symbol.for('react.profiler') : 0xead2;
|
|
31
31
|
var REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for('react.provider') : 0xeacd;
|
|
32
32
|
var REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for('react.context') : 0xeace;
|
|
33
|
-
var
|
|
33
|
+
var REACT_CONCURRENT_MODE_TYPE = hasSymbol ? Symbol.for('react.concurrent_mode') : 0xeacf;
|
|
34
34
|
var REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for('react.forward_ref') : 0xead0;
|
|
35
|
-
var
|
|
35
|
+
var REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for('react.suspense') : 0xead1;
|
|
36
|
+
var REACT_PURE_TYPE = hasSymbol ? Symbol.for('react.pure') : 0xead3;
|
|
36
37
|
|
|
37
38
|
var MAYBE_ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
|
|
38
39
|
var FAUX_ITERATOR_SYMBOL = '@@iterator';
|
|
@@ -48,48 +49,6 @@ function getIteratorFn(maybeIterable) {
|
|
|
48
49
|
return null;
|
|
49
50
|
}
|
|
50
51
|
|
|
51
|
-
// Exports ReactDOM.createRoot
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
// Experimental error-boundary API that can recover from errors within a single
|
|
55
|
-
// render phase
|
|
56
|
-
|
|
57
|
-
// Suspense
|
|
58
|
-
var enableSuspense = false;
|
|
59
|
-
// Helps identify side effects in begin-phase lifecycle hooks and setState reducers:
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
// In some cases, StrictMode should also double-render lifecycles.
|
|
63
|
-
// This can be confusing for tests though,
|
|
64
|
-
// And it can be bad for performance in production.
|
|
65
|
-
// This feature flag can be used to control the behavior:
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
// To preserve the "Pause on caught exceptions" behavior of the debugger, we
|
|
69
|
-
// replay the begin phase of a failed component inside invokeGuardedCallback.
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
// Warn about deprecated, async-unsafe lifecycles; relates to RFC #6:
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
// Warn about legacy context API
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
// Gather advanced timing metrics for Profiler subtrees.
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
// Trace which interactions trigger each commit.
|
|
82
|
-
var enableSchedulerTracing = true;
|
|
83
|
-
|
|
84
|
-
// Only used in www builds.
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
// Only used in www builds.
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
// React Fire: prevent the value and checked attributes from syncing
|
|
91
|
-
// with their related DOM properties
|
|
92
|
-
|
|
93
52
|
/*
|
|
94
53
|
object-assign
|
|
95
54
|
(c) Sindre Sorhus
|
|
@@ -577,14 +536,34 @@ function createRef() {
|
|
|
577
536
|
|
|
578
537
|
/* eslint-disable no-var */
|
|
579
538
|
|
|
580
|
-
// TODO:
|
|
581
|
-
|
|
582
|
-
var
|
|
539
|
+
// TODO: Use symbols?
|
|
540
|
+
var ImmediatePriority = 1;
|
|
541
|
+
var InteractivePriority = 2;
|
|
542
|
+
var NormalPriority = 3;
|
|
543
|
+
var WheneverPriority = 4;
|
|
544
|
+
|
|
545
|
+
// Max 31 bit integer. The max integer size in V8 for 32-bit systems.
|
|
546
|
+
// Math.pow(2, 30) - 1
|
|
547
|
+
// 0b111111111111111111111111111111
|
|
548
|
+
var maxSigned31BitInt = 1073741823;
|
|
549
|
+
|
|
550
|
+
// Times out immediately
|
|
551
|
+
var IMMEDIATE_PRIORITY_TIMEOUT = -1;
|
|
552
|
+
// Eventually times out
|
|
553
|
+
var INTERACTIVE_PRIORITY_TIMEOUT = 250;
|
|
554
|
+
var NORMAL_PRIORITY_TIMEOUT = 5000;
|
|
555
|
+
// Never times out
|
|
556
|
+
var WHENEVER_PRIORITY_TIMEOUT = maxSigned31BitInt;
|
|
583
557
|
|
|
584
558
|
// Callbacks are stored as a circular, doubly linked list.
|
|
585
559
|
var firstCallbackNode = null;
|
|
586
560
|
|
|
587
|
-
var
|
|
561
|
+
var currentPriorityLevel = NormalPriority;
|
|
562
|
+
var currentEventStartTime = -1;
|
|
563
|
+
var currentExpirationTime = -1;
|
|
564
|
+
|
|
565
|
+
// This is set when a callback is being executed, to prevent re-entrancy.
|
|
566
|
+
var isExecutingCallback = false;
|
|
588
567
|
|
|
589
568
|
var isHostCallbackScheduled = false;
|
|
590
569
|
|
|
@@ -593,6 +572,11 @@ var hasNativePerformanceNow = typeof performance === 'object' && typeof performa
|
|
|
593
572
|
var timeRemaining;
|
|
594
573
|
if (hasNativePerformanceNow) {
|
|
595
574
|
timeRemaining = function () {
|
|
575
|
+
if (firstCallbackNode !== null && firstCallbackNode.expirationTime < currentExpirationTime) {
|
|
576
|
+
// A higher priority callback was scheduled. Yield so we can switch to
|
|
577
|
+
// working on that.
|
|
578
|
+
return 0;
|
|
579
|
+
}
|
|
596
580
|
// We assume that if we have a performance timer that the rAF callback
|
|
597
581
|
// gets a performance timer value. Not sure if this is always true.
|
|
598
582
|
var remaining = getFrameDeadline() - performance.now();
|
|
@@ -601,6 +585,9 @@ if (hasNativePerformanceNow) {
|
|
|
601
585
|
} else {
|
|
602
586
|
timeRemaining = function () {
|
|
603
587
|
// Fallback to Date.now()
|
|
588
|
+
if (firstCallbackNode !== null && firstCallbackNode.expirationTime < currentExpirationTime) {
|
|
589
|
+
return 0;
|
|
590
|
+
}
|
|
604
591
|
var remaining = getFrameDeadline() - Date.now();
|
|
605
592
|
return remaining > 0 ? remaining : 0;
|
|
606
593
|
};
|
|
@@ -612,22 +599,22 @@ var deadlineObject = {
|
|
|
612
599
|
};
|
|
613
600
|
|
|
614
601
|
function ensureHostCallbackIsScheduled() {
|
|
615
|
-
if (
|
|
602
|
+
if (isExecutingCallback) {
|
|
616
603
|
// Don't schedule work yet; wait until the next time we yield.
|
|
617
604
|
return;
|
|
618
605
|
}
|
|
619
|
-
// Schedule the host callback using the earliest
|
|
620
|
-
var
|
|
606
|
+
// Schedule the host callback using the earliest expiration in the list.
|
|
607
|
+
var expirationTime = firstCallbackNode.expirationTime;
|
|
621
608
|
if (!isHostCallbackScheduled) {
|
|
622
609
|
isHostCallbackScheduled = true;
|
|
623
610
|
} else {
|
|
624
611
|
// Cancel the existing host callback.
|
|
625
|
-
|
|
612
|
+
cancelHostCallback();
|
|
626
613
|
}
|
|
627
|
-
|
|
614
|
+
requestHostCallback(flushWork, expirationTime);
|
|
628
615
|
}
|
|
629
616
|
|
|
630
|
-
function flushFirstCallback(
|
|
617
|
+
function flushFirstCallback() {
|
|
631
618
|
var flushedNode = firstCallbackNode;
|
|
632
619
|
|
|
633
620
|
// Remove the node from the list before calling the callback. That way the
|
|
@@ -638,33 +625,117 @@ function flushFirstCallback(node) {
|
|
|
638
625
|
firstCallbackNode = null;
|
|
639
626
|
next = null;
|
|
640
627
|
} else {
|
|
641
|
-
var
|
|
642
|
-
firstCallbackNode =
|
|
643
|
-
next.previous =
|
|
628
|
+
var lastCallbackNode = firstCallbackNode.previous;
|
|
629
|
+
firstCallbackNode = lastCallbackNode.next = next;
|
|
630
|
+
next.previous = lastCallbackNode;
|
|
644
631
|
}
|
|
645
632
|
|
|
646
633
|
flushedNode.next = flushedNode.previous = null;
|
|
647
634
|
|
|
648
635
|
// Now it's safe to call the callback.
|
|
649
636
|
var callback = flushedNode.callback;
|
|
650
|
-
|
|
637
|
+
var expirationTime = flushedNode.expirationTime;
|
|
638
|
+
var priorityLevel = flushedNode.priorityLevel;
|
|
639
|
+
var previousPriorityLevel = currentPriorityLevel;
|
|
640
|
+
var previousExpirationTime = currentExpirationTime;
|
|
641
|
+
currentPriorityLevel = priorityLevel;
|
|
642
|
+
currentExpirationTime = expirationTime;
|
|
643
|
+
var continuationCallback;
|
|
644
|
+
try {
|
|
645
|
+
continuationCallback = callback(deadlineObject);
|
|
646
|
+
} finally {
|
|
647
|
+
currentPriorityLevel = previousPriorityLevel;
|
|
648
|
+
currentExpirationTime = previousExpirationTime;
|
|
649
|
+
}
|
|
650
|
+
|
|
651
|
+
// A callback may return a continuation. The continuation should be scheduled
|
|
652
|
+
// with the same priority and expiration as the just-finished callback.
|
|
653
|
+
if (typeof continuationCallback === 'function') {
|
|
654
|
+
var continuationNode = {
|
|
655
|
+
callback: continuationCallback,
|
|
656
|
+
priorityLevel: priorityLevel,
|
|
657
|
+
expirationTime: expirationTime,
|
|
658
|
+
next: null,
|
|
659
|
+
previous: null
|
|
660
|
+
};
|
|
661
|
+
|
|
662
|
+
// Insert the new callback into the list, sorted by its expiration. This is
|
|
663
|
+
// almost the same as the code in `scheduleCallback`, except the callback
|
|
664
|
+
// is inserted into the list *before* callbacks of equal expiration instead
|
|
665
|
+
// of after.
|
|
666
|
+
if (firstCallbackNode === null) {
|
|
667
|
+
// This is the first callback in the list.
|
|
668
|
+
firstCallbackNode = continuationNode.next = continuationNode.previous = continuationNode;
|
|
669
|
+
} else {
|
|
670
|
+
var nextAfterContinuation = null;
|
|
671
|
+
var node = firstCallbackNode;
|
|
672
|
+
do {
|
|
673
|
+
if (node.expirationTime >= expirationTime) {
|
|
674
|
+
// This callback expires at or after the continuation. We will insert
|
|
675
|
+
// the continuation *before* this callback.
|
|
676
|
+
nextAfterContinuation = node;
|
|
677
|
+
break;
|
|
678
|
+
}
|
|
679
|
+
node = node.next;
|
|
680
|
+
} while (node !== firstCallbackNode);
|
|
681
|
+
|
|
682
|
+
if (nextAfterContinuation === null) {
|
|
683
|
+
// No equal or lower priority callback was found, which means the new
|
|
684
|
+
// callback is the lowest priority callback in the list.
|
|
685
|
+
nextAfterContinuation = firstCallbackNode;
|
|
686
|
+
} else if (nextAfterContinuation === firstCallbackNode) {
|
|
687
|
+
// The new callback is the highest priority callback in the list.
|
|
688
|
+
firstCallbackNode = continuationNode;
|
|
689
|
+
ensureHostCallbackIsScheduled(firstCallbackNode);
|
|
690
|
+
}
|
|
691
|
+
|
|
692
|
+
var previous = nextAfterContinuation.previous;
|
|
693
|
+
previous.next = nextAfterContinuation.previous = continuationNode;
|
|
694
|
+
continuationNode.next = nextAfterContinuation;
|
|
695
|
+
continuationNode.previous = previous;
|
|
696
|
+
}
|
|
697
|
+
}
|
|
698
|
+
}
|
|
699
|
+
|
|
700
|
+
function flushImmediateWork() {
|
|
701
|
+
if (
|
|
702
|
+
// Confirm we've exited the outer most event handler
|
|
703
|
+
currentEventStartTime === -1 && firstCallbackNode !== null && firstCallbackNode.priorityLevel === ImmediatePriority) {
|
|
704
|
+
isExecutingCallback = true;
|
|
705
|
+
deadlineObject.didTimeout = true;
|
|
706
|
+
try {
|
|
707
|
+
do {
|
|
708
|
+
flushFirstCallback();
|
|
709
|
+
} while (
|
|
710
|
+
// Keep flushing until there are no more immediate callbacks
|
|
711
|
+
firstCallbackNode !== null && firstCallbackNode.priorityLevel === ImmediatePriority);
|
|
712
|
+
} finally {
|
|
713
|
+
isExecutingCallback = false;
|
|
714
|
+
if (firstCallbackNode !== null) {
|
|
715
|
+
// There's still work remaining. Request another callback.
|
|
716
|
+
ensureHostCallbackIsScheduled(firstCallbackNode);
|
|
717
|
+
} else {
|
|
718
|
+
isHostCallbackScheduled = false;
|
|
719
|
+
}
|
|
720
|
+
}
|
|
721
|
+
}
|
|
651
722
|
}
|
|
652
723
|
|
|
653
724
|
function flushWork(didTimeout) {
|
|
654
|
-
|
|
725
|
+
isExecutingCallback = true;
|
|
655
726
|
deadlineObject.didTimeout = didTimeout;
|
|
656
727
|
try {
|
|
657
728
|
if (didTimeout) {
|
|
658
|
-
// Flush all the
|
|
729
|
+
// Flush all the expired callbacks without yielding.
|
|
659
730
|
while (firstCallbackNode !== null) {
|
|
660
731
|
// Read the current time. Flush all the callbacks that expire at or
|
|
661
732
|
// earlier than that time. Then read the current time again and repeat.
|
|
662
733
|
// This optimizes for as few performance.now calls as possible.
|
|
663
734
|
var currentTime = getCurrentTime();
|
|
664
|
-
if (firstCallbackNode.
|
|
735
|
+
if (firstCallbackNode.expirationTime <= currentTime) {
|
|
665
736
|
do {
|
|
666
737
|
flushFirstCallback();
|
|
667
|
-
} while (firstCallbackNode !== null && firstCallbackNode.
|
|
738
|
+
} while (firstCallbackNode !== null && firstCallbackNode.expirationTime <= currentTime);
|
|
668
739
|
continue;
|
|
669
740
|
}
|
|
670
741
|
break;
|
|
@@ -678,36 +749,99 @@ function flushWork(didTimeout) {
|
|
|
678
749
|
}
|
|
679
750
|
}
|
|
680
751
|
} finally {
|
|
681
|
-
|
|
752
|
+
isExecutingCallback = false;
|
|
682
753
|
if (firstCallbackNode !== null) {
|
|
683
754
|
// There's still work remaining. Request another callback.
|
|
684
755
|
ensureHostCallbackIsScheduled(firstCallbackNode);
|
|
685
756
|
} else {
|
|
686
757
|
isHostCallbackScheduled = false;
|
|
687
758
|
}
|
|
759
|
+
// Before exiting, flush all the immediate work that was scheduled.
|
|
760
|
+
flushImmediateWork();
|
|
761
|
+
}
|
|
762
|
+
}
|
|
763
|
+
|
|
764
|
+
function unstable_runWithPriority(priorityLevel, eventHandler) {
|
|
765
|
+
switch (priorityLevel) {
|
|
766
|
+
case ImmediatePriority:
|
|
767
|
+
case InteractivePriority:
|
|
768
|
+
case NormalPriority:
|
|
769
|
+
case WheneverPriority:
|
|
770
|
+
break;
|
|
771
|
+
default:
|
|
772
|
+
priorityLevel = NormalPriority;
|
|
773
|
+
}
|
|
774
|
+
|
|
775
|
+
var previousPriorityLevel = currentPriorityLevel;
|
|
776
|
+
var previousEventStartTime = currentEventStartTime;
|
|
777
|
+
currentPriorityLevel = priorityLevel;
|
|
778
|
+
currentEventStartTime = getCurrentTime();
|
|
779
|
+
|
|
780
|
+
try {
|
|
781
|
+
return eventHandler();
|
|
782
|
+
} finally {
|
|
783
|
+
currentPriorityLevel = previousPriorityLevel;
|
|
784
|
+
currentEventStartTime = previousEventStartTime;
|
|
785
|
+
|
|
786
|
+
// Before exiting, flush all the immediate work that was scheduled.
|
|
787
|
+
flushImmediateWork();
|
|
688
788
|
}
|
|
689
789
|
}
|
|
690
790
|
|
|
691
|
-
function
|
|
692
|
-
var
|
|
791
|
+
function unstable_wrapCallback(callback) {
|
|
792
|
+
var parentPriorityLevel = currentPriorityLevel;
|
|
793
|
+
return function () {
|
|
794
|
+
// This is a fork of runWithPriority, inlined for performance.
|
|
795
|
+
var previousPriorityLevel = currentPriorityLevel;
|
|
796
|
+
var previousEventStartTime = currentEventStartTime;
|
|
797
|
+
currentPriorityLevel = parentPriorityLevel;
|
|
798
|
+
currentEventStartTime = getCurrentTime();
|
|
799
|
+
|
|
800
|
+
try {
|
|
801
|
+
return callback.apply(this, arguments);
|
|
802
|
+
} finally {
|
|
803
|
+
currentPriorityLevel = previousPriorityLevel;
|
|
804
|
+
currentEventStartTime = previousEventStartTime;
|
|
805
|
+
flushImmediateWork();
|
|
806
|
+
}
|
|
807
|
+
};
|
|
808
|
+
}
|
|
809
|
+
|
|
810
|
+
function unstable_scheduleCallback(callback, deprecated_options) {
|
|
811
|
+
var startTime = currentEventStartTime !== -1 ? currentEventStartTime : getCurrentTime();
|
|
693
812
|
|
|
694
|
-
var
|
|
695
|
-
if (
|
|
696
|
-
//
|
|
697
|
-
|
|
813
|
+
var expirationTime;
|
|
814
|
+
if (typeof deprecated_options === 'object' && deprecated_options !== null && typeof deprecated_options.timeout === 'number') {
|
|
815
|
+
// FIXME: Remove this branch once we lift expiration times out of React.
|
|
816
|
+
expirationTime = startTime + deprecated_options.timeout;
|
|
698
817
|
} else {
|
|
699
|
-
|
|
700
|
-
|
|
818
|
+
switch (currentPriorityLevel) {
|
|
819
|
+
case ImmediatePriority:
|
|
820
|
+
expirationTime = startTime + IMMEDIATE_PRIORITY_TIMEOUT;
|
|
821
|
+
break;
|
|
822
|
+
case InteractivePriority:
|
|
823
|
+
expirationTime = startTime + INTERACTIVE_PRIORITY_TIMEOUT;
|
|
824
|
+
break;
|
|
825
|
+
case WheneverPriority:
|
|
826
|
+
expirationTime = startTime + WHENEVER_PRIORITY_TIMEOUT;
|
|
827
|
+
break;
|
|
828
|
+
case NormalPriority:
|
|
829
|
+
default:
|
|
830
|
+
expirationTime = startTime + NORMAL_PRIORITY_TIMEOUT;
|
|
831
|
+
}
|
|
701
832
|
}
|
|
702
833
|
|
|
703
834
|
var newNode = {
|
|
704
835
|
callback: callback,
|
|
705
|
-
|
|
836
|
+
priorityLevel: currentPriorityLevel,
|
|
837
|
+
expirationTime: expirationTime,
|
|
706
838
|
next: null,
|
|
707
839
|
previous: null
|
|
708
840
|
};
|
|
709
841
|
|
|
710
|
-
// Insert the new callback into the list,
|
|
842
|
+
// Insert the new callback into the list, ordered first by expiration, then
|
|
843
|
+
// by insertion. So the new callback is inserted any other callback with
|
|
844
|
+
// equal expiration.
|
|
711
845
|
if (firstCallbackNode === null) {
|
|
712
846
|
// This is the first callback in the list.
|
|
713
847
|
firstCallbackNode = newNode.next = newNode.previous = newNode;
|
|
@@ -716,8 +850,8 @@ function unstable_scheduleWork(callback, options) {
|
|
|
716
850
|
var next = null;
|
|
717
851
|
var node = firstCallbackNode;
|
|
718
852
|
do {
|
|
719
|
-
if (node.
|
|
720
|
-
// The new callback
|
|
853
|
+
if (node.expirationTime > expirationTime) {
|
|
854
|
+
// The new callback expires before this one.
|
|
721
855
|
next = node;
|
|
722
856
|
break;
|
|
723
857
|
}
|
|
@@ -725,11 +859,11 @@ function unstable_scheduleWork(callback, options) {
|
|
|
725
859
|
} while (node !== firstCallbackNode);
|
|
726
860
|
|
|
727
861
|
if (next === null) {
|
|
728
|
-
// No callback with a later
|
|
729
|
-
// callback has the latest
|
|
862
|
+
// No callback with a later expiration was found, which means the new
|
|
863
|
+
// callback has the latest expiration in the list.
|
|
730
864
|
next = firstCallbackNode;
|
|
731
865
|
} else if (next === firstCallbackNode) {
|
|
732
|
-
// The new callback has the earliest
|
|
866
|
+
// The new callback has the earliest expiration in the entire list.
|
|
733
867
|
firstCallbackNode = newNode;
|
|
734
868
|
ensureHostCallbackIsScheduled(firstCallbackNode);
|
|
735
869
|
}
|
|
@@ -743,7 +877,7 @@ function unstable_scheduleWork(callback, options) {
|
|
|
743
877
|
return newNode;
|
|
744
878
|
}
|
|
745
879
|
|
|
746
|
-
function
|
|
880
|
+
function unstable_cancelCallback(callbackNode) {
|
|
747
881
|
var next = callbackNode.next;
|
|
748
882
|
if (next === null) {
|
|
749
883
|
// Already cancelled.
|
|
@@ -766,6 +900,10 @@ function unstable_cancelScheduledWork(callbackNode) {
|
|
|
766
900
|
callbackNode.next = callbackNode.previous = null;
|
|
767
901
|
}
|
|
768
902
|
|
|
903
|
+
function unstable_getCurrentPriorityLevel() {
|
|
904
|
+
return currentPriorityLevel;
|
|
905
|
+
}
|
|
906
|
+
|
|
769
907
|
// The remaining code is essentially a polyfill for requestIdleCallback. It
|
|
770
908
|
// works by scheduling a requestAnimationFrame, storing the time for the start
|
|
771
909
|
// of the frame, then scheduling a postMessage which gets scheduled after paint.
|
|
@@ -826,31 +964,59 @@ if (hasNativePerformanceNow) {
|
|
|
826
964
|
};
|
|
827
965
|
}
|
|
828
966
|
|
|
829
|
-
var
|
|
830
|
-
var
|
|
967
|
+
var requestHostCallback;
|
|
968
|
+
var cancelHostCallback;
|
|
831
969
|
var getFrameDeadline;
|
|
832
970
|
|
|
833
|
-
if (typeof window
|
|
834
|
-
//
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
971
|
+
if (typeof window !== 'undefined' && window._schedMock) {
|
|
972
|
+
// Dynamic injection, only for testing purposes.
|
|
973
|
+
var impl = window._schedMock;
|
|
974
|
+
requestHostCallback = impl[0];
|
|
975
|
+
cancelHostCallback = impl[1];
|
|
976
|
+
getFrameDeadline = impl[2];
|
|
977
|
+
} else if (
|
|
978
|
+
// If Scheduler runs in a non-DOM environment, it falls back to a naive
|
|
979
|
+
// implementation using setTimeout.
|
|
980
|
+
typeof window === 'undefined' ||
|
|
981
|
+
// "addEventListener" might not be available on the window object
|
|
982
|
+
// if this is a mocked "window" object. So we need to validate that too.
|
|
983
|
+
typeof window.addEventListener !== 'function') {
|
|
984
|
+
var _callback = null;
|
|
985
|
+
var _currentTime = -1;
|
|
986
|
+
var _flushCallback = function (didTimeout, ms) {
|
|
987
|
+
if (_callback !== null) {
|
|
988
|
+
var cb = _callback;
|
|
989
|
+
_callback = null;
|
|
990
|
+
try {
|
|
991
|
+
_currentTime = ms;
|
|
992
|
+
cb(didTimeout);
|
|
993
|
+
} finally {
|
|
994
|
+
_currentTime = -1;
|
|
995
|
+
}
|
|
996
|
+
}
|
|
839
997
|
};
|
|
840
|
-
|
|
841
|
-
|
|
998
|
+
requestHostCallback = function (cb, ms) {
|
|
999
|
+
if (_currentTime !== -1) {
|
|
1000
|
+
// Protect against re-entrancy.
|
|
1001
|
+
setTimeout(requestHostCallback, 0, cb, ms);
|
|
1002
|
+
} else {
|
|
1003
|
+
_callback = cb;
|
|
1004
|
+
setTimeout(_flushCallback, ms, true, ms);
|
|
1005
|
+
setTimeout(_flushCallback, maxSigned31BitInt, false, maxSigned31BitInt);
|
|
1006
|
+
}
|
|
1007
|
+
};
|
|
1008
|
+
cancelHostCallback = function () {
|
|
1009
|
+
_callback = null;
|
|
842
1010
|
};
|
|
843
1011
|
getFrameDeadline = function () {
|
|
844
|
-
return
|
|
1012
|
+
return Infinity;
|
|
1013
|
+
};
|
|
1014
|
+
getCurrentTime = function () {
|
|
1015
|
+
return _currentTime === -1 ? 0 : _currentTime;
|
|
845
1016
|
};
|
|
846
|
-
} else if (window._schedMock) {
|
|
847
|
-
// Dynamic injection, only for testing purposes.
|
|
848
|
-
var impl = window._schedMock;
|
|
849
|
-
requestCallback = impl[0];
|
|
850
|
-
cancelCallback = impl[1];
|
|
851
|
-
getFrameDeadline = impl[2];
|
|
852
1017
|
} else {
|
|
853
1018
|
if (typeof console !== 'undefined') {
|
|
1019
|
+
// TODO: Remove fb.me link
|
|
854
1020
|
if (typeof localRequestAnimationFrame !== 'function') {
|
|
855
1021
|
console.error("This browser doesn't support requestAnimationFrame. " + 'Make sure that you load a ' + 'polyfill in older browsers. https://fb.me/react-polyfills');
|
|
856
1022
|
}
|
|
@@ -859,13 +1025,13 @@ if (typeof window === 'undefined') {
|
|
|
859
1025
|
}
|
|
860
1026
|
}
|
|
861
1027
|
|
|
862
|
-
var
|
|
863
|
-
var
|
|
1028
|
+
var scheduledHostCallback = null;
|
|
1029
|
+
var isMessageEventScheduled = false;
|
|
864
1030
|
var timeoutTime = -1;
|
|
865
1031
|
|
|
866
1032
|
var isAnimationFrameScheduled = false;
|
|
867
1033
|
|
|
868
|
-
var
|
|
1034
|
+
var isFlushingHostCallback = false;
|
|
869
1035
|
|
|
870
1036
|
var frameDeadline = 0;
|
|
871
1037
|
// We start out assuming that we run at 30fps but then the heuristic tracking
|
|
@@ -885,7 +1051,12 @@ if (typeof window === 'undefined') {
|
|
|
885
1051
|
return;
|
|
886
1052
|
}
|
|
887
1053
|
|
|
888
|
-
|
|
1054
|
+
isMessageEventScheduled = false;
|
|
1055
|
+
|
|
1056
|
+
var prevScheduledCallback = scheduledHostCallback;
|
|
1057
|
+
var prevTimeoutTime = timeoutTime;
|
|
1058
|
+
scheduledHostCallback = null;
|
|
1059
|
+
timeoutTime = -1;
|
|
889
1060
|
|
|
890
1061
|
var currentTime = getCurrentTime();
|
|
891
1062
|
|
|
@@ -893,7 +1064,7 @@ if (typeof window === 'undefined') {
|
|
|
893
1064
|
if (frameDeadline - currentTime <= 0) {
|
|
894
1065
|
// There's no time left in this idle period. Check if the callback has
|
|
895
1066
|
// a timeout and whether it's been exceeded.
|
|
896
|
-
if (
|
|
1067
|
+
if (prevTimeoutTime !== -1 && prevTimeoutTime <= currentTime) {
|
|
897
1068
|
// Exceeded the timeout. Invoke the callback even though there's no
|
|
898
1069
|
// time left.
|
|
899
1070
|
didTimeout = true;
|
|
@@ -905,19 +1076,18 @@ if (typeof window === 'undefined') {
|
|
|
905
1076
|
requestAnimationFrameWithTimeout(animationTick);
|
|
906
1077
|
}
|
|
907
1078
|
// Exit without invoking the callback.
|
|
1079
|
+
scheduledHostCallback = prevScheduledCallback;
|
|
1080
|
+
timeoutTime = prevTimeoutTime;
|
|
908
1081
|
return;
|
|
909
1082
|
}
|
|
910
1083
|
}
|
|
911
1084
|
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
scheduledCallback = null;
|
|
915
|
-
if (callback !== null) {
|
|
916
|
-
isPerformingIdleWork = true;
|
|
1085
|
+
if (prevScheduledCallback !== null) {
|
|
1086
|
+
isFlushingHostCallback = true;
|
|
917
1087
|
try {
|
|
918
|
-
|
|
1088
|
+
prevScheduledCallback(didTimeout);
|
|
919
1089
|
} finally {
|
|
920
|
-
|
|
1090
|
+
isFlushingHostCallback = false;
|
|
921
1091
|
}
|
|
922
1092
|
}
|
|
923
1093
|
};
|
|
@@ -926,12 +1096,27 @@ if (typeof window === 'undefined') {
|
|
|
926
1096
|
window.addEventListener('message', idleTick, false);
|
|
927
1097
|
|
|
928
1098
|
var animationTick = function (rafTime) {
|
|
929
|
-
|
|
1099
|
+
if (scheduledHostCallback !== null) {
|
|
1100
|
+
// Eagerly schedule the next animation callback at the beginning of the
|
|
1101
|
+
// frame. If the scheduler queue is not empty at the end of the frame, it
|
|
1102
|
+
// will continue flushing inside that callback. If the queue *is* empty,
|
|
1103
|
+
// then it will exit immediately. Posting the callback at the start of the
|
|
1104
|
+
// frame ensures it's fired within the earliest possible frame. If we
|
|
1105
|
+
// waited until the end of the frame to post the callback, we risk the
|
|
1106
|
+
// browser skipping a frame and not firing the callback until the frame
|
|
1107
|
+
// after that.
|
|
1108
|
+
requestAnimationFrameWithTimeout(animationTick);
|
|
1109
|
+
} else {
|
|
1110
|
+
// No pending work. Exit.
|
|
1111
|
+
isAnimationFrameScheduled = false;
|
|
1112
|
+
return;
|
|
1113
|
+
}
|
|
1114
|
+
|
|
930
1115
|
var nextFrameTime = rafTime - frameDeadline + activeFrameTime;
|
|
931
1116
|
if (nextFrameTime < activeFrameTime && previousFrameTime < activeFrameTime) {
|
|
932
1117
|
if (nextFrameTime < 8) {
|
|
933
1118
|
// Defensive coding. We don't support higher frame rates than 120hz.
|
|
934
|
-
// If
|
|
1119
|
+
// If the calculated frame time gets lower than 8, it is probably a bug.
|
|
935
1120
|
nextFrameTime = 8;
|
|
936
1121
|
}
|
|
937
1122
|
// If one frame goes long, then the next one can be short to catch up.
|
|
@@ -946,17 +1131,16 @@ if (typeof window === 'undefined') {
|
|
|
946
1131
|
previousFrameTime = nextFrameTime;
|
|
947
1132
|
}
|
|
948
1133
|
frameDeadline = rafTime + activeFrameTime;
|
|
949
|
-
if (!
|
|
950
|
-
|
|
1134
|
+
if (!isMessageEventScheduled) {
|
|
1135
|
+
isMessageEventScheduled = true;
|
|
951
1136
|
window.postMessage(messageKey, '*');
|
|
952
1137
|
}
|
|
953
1138
|
};
|
|
954
1139
|
|
|
955
|
-
|
|
956
|
-
|
|
1140
|
+
requestHostCallback = function (callback, absoluteTimeout) {
|
|
1141
|
+
scheduledHostCallback = callback;
|
|
957
1142
|
timeoutTime = absoluteTimeout;
|
|
958
|
-
if (
|
|
959
|
-
// If we're already performing idle work, an error must have been thrown.
|
|
1143
|
+
if (isFlushingHostCallback || absoluteTimeout < 0) {
|
|
960
1144
|
// Don't wait for the next frame. Continue working ASAP, in a new event.
|
|
961
1145
|
window.postMessage(messageKey, '*');
|
|
962
1146
|
} else if (!isAnimationFrameScheduled) {
|
|
@@ -969,13 +1153,44 @@ if (typeof window === 'undefined') {
|
|
|
969
1153
|
}
|
|
970
1154
|
};
|
|
971
1155
|
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
1156
|
+
cancelHostCallback = function () {
|
|
1157
|
+
scheduledHostCallback = null;
|
|
1158
|
+
isMessageEventScheduled = false;
|
|
975
1159
|
timeoutTime = -1;
|
|
976
1160
|
};
|
|
977
1161
|
}
|
|
978
1162
|
|
|
1163
|
+
// Helps identify side effects in begin-phase lifecycle hooks and setState reducers:
|
|
1164
|
+
|
|
1165
|
+
|
|
1166
|
+
// In some cases, StrictMode should also double-render lifecycles.
|
|
1167
|
+
// This can be confusing for tests though,
|
|
1168
|
+
// And it can be bad for performance in production.
|
|
1169
|
+
// This feature flag can be used to control the behavior:
|
|
1170
|
+
|
|
1171
|
+
|
|
1172
|
+
// To preserve the "Pause on caught exceptions" behavior of the debugger, we
|
|
1173
|
+
// replay the begin phase of a failed component inside invokeGuardedCallback.
|
|
1174
|
+
|
|
1175
|
+
|
|
1176
|
+
// Warn about deprecated, async-unsafe lifecycles; relates to RFC #6:
|
|
1177
|
+
|
|
1178
|
+
|
|
1179
|
+
// Gather advanced timing metrics for Profiler subtrees.
|
|
1180
|
+
|
|
1181
|
+
|
|
1182
|
+
// Trace which interactions trigger each commit.
|
|
1183
|
+
var enableSchedulerTracing = true;
|
|
1184
|
+
|
|
1185
|
+
// Only used in www builds.
|
|
1186
|
+
|
|
1187
|
+
|
|
1188
|
+
// Only used in www builds.
|
|
1189
|
+
|
|
1190
|
+
|
|
1191
|
+
// React Fire: prevent the value and checked attributes from syncing
|
|
1192
|
+
// with their related DOM properties
|
|
1193
|
+
|
|
979
1194
|
var DEFAULT_THREAD_ID = 0;
|
|
980
1195
|
|
|
981
1196
|
// Counters used to generate unique IDs.
|
|
@@ -1402,8 +1617,8 @@ function getComponentName(type) {
|
|
|
1402
1617
|
return type;
|
|
1403
1618
|
}
|
|
1404
1619
|
switch (type) {
|
|
1405
|
-
case
|
|
1406
|
-
return '
|
|
1620
|
+
case REACT_CONCURRENT_MODE_TYPE:
|
|
1621
|
+
return 'ConcurrentMode';
|
|
1407
1622
|
case REACT_FRAGMENT_TYPE:
|
|
1408
1623
|
return 'Fragment';
|
|
1409
1624
|
case REACT_PORTAL_TYPE:
|
|
@@ -1412,8 +1627,8 @@ function getComponentName(type) {
|
|
|
1412
1627
|
return 'Profiler';
|
|
1413
1628
|
case REACT_STRICT_MODE_TYPE:
|
|
1414
1629
|
return 'StrictMode';
|
|
1415
|
-
case
|
|
1416
|
-
return '
|
|
1630
|
+
case REACT_SUSPENSE_TYPE:
|
|
1631
|
+
return 'Suspense';
|
|
1417
1632
|
}
|
|
1418
1633
|
if (typeof type === 'object') {
|
|
1419
1634
|
switch (type.$$typeof) {
|
|
@@ -1484,12 +1699,15 @@ var ReactSharedInternals = {
|
|
|
1484
1699
|
// This re-export is only required for UMD bundles;
|
|
1485
1700
|
// CJS bundles use the shared NPM package.
|
|
1486
1701
|
objectAssign(ReactSharedInternals, {
|
|
1487
|
-
|
|
1488
|
-
|
|
1702
|
+
Scheduler: {
|
|
1703
|
+
unstable_cancelCallback: unstable_cancelCallback,
|
|
1489
1704
|
unstable_now: getCurrentTime,
|
|
1490
|
-
|
|
1705
|
+
unstable_scheduleCallback: unstable_scheduleCallback,
|
|
1706
|
+
unstable_runWithPriority: unstable_runWithPriority,
|
|
1707
|
+
unstable_wrapCallback: unstable_wrapCallback,
|
|
1708
|
+
unstable_getCurrentPriorityLevel: unstable_getCurrentPriorityLevel
|
|
1491
1709
|
},
|
|
1492
|
-
|
|
1710
|
+
SchedulerTracing: {
|
|
1493
1711
|
__interactionsRef: interactionsRef,
|
|
1494
1712
|
__subscriberRef: subscriberRef,
|
|
1495
1713
|
unstable_clear: unstable_clear,
|
|
@@ -2257,10 +2475,28 @@ function forwardRef(render) {
|
|
|
2257
2475
|
};
|
|
2258
2476
|
}
|
|
2259
2477
|
|
|
2478
|
+
function pure(render, compare) {
|
|
2479
|
+
{
|
|
2480
|
+
if (typeof render !== 'function') {
|
|
2481
|
+
warningWithoutStack$1(false, 'pure: The first argument must be a function component. Instead ' + 'received: %s', render === null ? 'null' : typeof render);
|
|
2482
|
+
} else {
|
|
2483
|
+
var prototype = render.prototype;
|
|
2484
|
+
if (prototype && prototype.isReactComponent) {
|
|
2485
|
+
warningWithoutStack$1(false, 'pure: The first argument must be a function component. Classes ' + 'are not supported. Use React.PureComponent instead.');
|
|
2486
|
+
}
|
|
2487
|
+
}
|
|
2488
|
+
}
|
|
2489
|
+
return {
|
|
2490
|
+
$$typeof: REACT_PURE_TYPE,
|
|
2491
|
+
render: render,
|
|
2492
|
+
compare: compare === undefined ? null : compare
|
|
2493
|
+
};
|
|
2494
|
+
}
|
|
2495
|
+
|
|
2260
2496
|
function isValidElementType(type) {
|
|
2261
2497
|
return typeof type === 'string' || typeof type === 'function' ||
|
|
2262
2498
|
// Note: its typeof might be other than 'symbol' or 'number' if it's a polyfill.
|
|
2263
|
-
type === REACT_FRAGMENT_TYPE || type ===
|
|
2499
|
+
type === REACT_FRAGMENT_TYPE || type === REACT_CONCURRENT_MODE_TYPE || type === REACT_PROFILER_TYPE || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || typeof type === 'object' && type !== null && (typeof type.then === 'function' || type.$$typeof === REACT_PURE_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE);
|
|
2264
2500
|
}
|
|
2265
2501
|
|
|
2266
2502
|
/**
|
|
@@ -2513,7 +2749,7 @@ function validatePropTypes(element) {
|
|
|
2513
2749
|
var name = void 0,
|
|
2514
2750
|
propTypes = void 0;
|
|
2515
2751
|
if (typeof type === 'function') {
|
|
2516
|
-
// Class or
|
|
2752
|
+
// Class or function component
|
|
2517
2753
|
name = type.displayName || type.name;
|
|
2518
2754
|
propTypes = type.propTypes;
|
|
2519
2755
|
} else if (typeof type === 'object' && type !== null && type.$$typeof === REACT_FORWARD_REF_TYPE) {
|
|
@@ -2665,10 +2901,13 @@ var React = {
|
|
|
2665
2901
|
|
|
2666
2902
|
createContext: createContext,
|
|
2667
2903
|
forwardRef: forwardRef,
|
|
2904
|
+
lazy: lazy,
|
|
2905
|
+
pure: pure,
|
|
2668
2906
|
|
|
2669
2907
|
Fragment: REACT_FRAGMENT_TYPE,
|
|
2670
2908
|
StrictMode: REACT_STRICT_MODE_TYPE,
|
|
2671
|
-
|
|
2909
|
+
unstable_ConcurrentMode: REACT_CONCURRENT_MODE_TYPE,
|
|
2910
|
+
unstable_Suspense: REACT_SUSPENSE_TYPE,
|
|
2672
2911
|
unstable_Profiler: REACT_PROFILER_TYPE,
|
|
2673
2912
|
|
|
2674
2913
|
createElement: createElementWithValidation,
|
|
@@ -2681,11 +2920,6 @@ var React = {
|
|
|
2681
2920
|
__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED: ReactSharedInternals
|
|
2682
2921
|
};
|
|
2683
2922
|
|
|
2684
|
-
if (enableSuspense) {
|
|
2685
|
-
React.Placeholder = REACT_PLACEHOLDER_TYPE;
|
|
2686
|
-
React.lazy = lazy;
|
|
2687
|
-
}
|
|
2688
|
-
|
|
2689
2923
|
|
|
2690
2924
|
|
|
2691
2925
|
var React$2 = Object.freeze({
|