react 16.4.2 → 16.6.0-alpha.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.
- package/LICENSE +1 -1
- package/README.md +4 -7
- package/cjs/react.development.js +407 -167
- package/cjs/react.production.min.js +17 -15
- package/package.json +3 -3
- package/umd/react.development.js +1275 -385
- package/umd/react.production.min.js +22 -16
- package/umd/react.profiling.min.js +33 -0
|
@@ -1,22 +1,24 @@
|
|
|
1
|
-
/** @license React v16.
|
|
1
|
+
/** @license React v16.6.0-alpha.0
|
|
2
2
|
* react.production.min.js
|
|
3
3
|
*
|
|
4
|
-
* Copyright (c)
|
|
4
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
5
5
|
*
|
|
6
6
|
* This source code is licensed under the MIT license found in the
|
|
7
7
|
* LICENSE file in the root directory of this source tree.
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
'use strict';var
|
|
11
|
-
|
|
12
|
-
var
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
function
|
|
16
|
-
function
|
|
17
|
-
|
|
18
|
-
function
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
10
|
+
'use strict';var m=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.async_mode"):60111,y=n?Symbol.for("react.forward_ref"):60112;n&&Symbol.for("react.placeholder");
|
|
11
|
+
var z="function"===typeof Symbol&&Symbol.iterator;function A(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 k=[d,c,e,g,h,f],l=0;a=Error(b.replace(/%s/g,function(){return k[l++]}));a.name="Invariant Violation"}a.framesToPop=1;throw a;}}
|
|
12
|
+
function B(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]);A(!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 C={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},D={};
|
|
13
|
+
function E(a,b,d){this.props=a;this.context=b;this.refs=D;this.updater=d||C}E.prototype.isReactComponent={};E.prototype.setState=function(a,b){"object"!==typeof a&&"function"!==typeof a&&null!=a?B("85"):void 0;this.updater.enqueueSetState(this,a,b,"setState")};E.prototype.forceUpdate=function(a){this.updater.enqueueForceUpdate(this,a,"forceUpdate")};function F(){}F.prototype=E.prototype;function G(a,b,d){this.props=a;this.context=b;this.refs=D;this.updater=d||C}var H=G.prototype=new F;
|
|
14
|
+
H.constructor=G;m(H,E.prototype);H.isPureReactComponent=!0;var I={current:null,currentDispatcher:null},J=Object.prototype.hasOwnProperty,K={key:!0,ref:!0,__self:!0,__source:!0};
|
|
15
|
+
function L(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)J.call(b,c)&&!K.hasOwnProperty(c)&&(e[c]=b[c]);var f=arguments.length-2;if(1===f)e.children=d;else if(1<f){for(var k=Array(f),l=0;l<f;l++)k[l]=arguments[l+2];e.children=k}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:I.current}}
|
|
16
|
+
function M(a,b){return{$$typeof:p,type:a.type,key:b,ref:a.ref,props:a.props,_owner:a._owner}}function N(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 O=/\/+/g,P=[];function Q(a,b,d,c){if(P.length){var e=P.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 R(a){a.result=null;a.keyPrefix=null;a.func=null;a.context=null;a.count=0;10>P.length&&P.push(a)}
|
|
18
|
+
function S(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?"."+T(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+T(e,h);g+=S(e,f,d,c)}else if(null===a||"object"!==typeof a?f=null:(f=z&&a[z]||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+T(e,h++),g+=S(e,f,d,c);else"object"===e&&(d=""+a,B("31","[object Object]"===d?"object with keys {"+Object.keys(a).join(", ")+"}":d,""));return g}function U(a,b,d){return null==a?0:S(a,"",b,d)}function T(a,b){return"object"===typeof a&&null!==a&&null!=a.key?escape(a.key):b.toString(36)}function V(a,b){a.func.call(a.context,b,a.count++)}
|
|
20
|
+
function aa(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&&(N(a)&&(a=M(a,e+(!a.key||b&&b.key===a.key?"":(""+a.key).replace(O,"$&/")+"/")+d)),c.push(a))}function W(a,b,d,c,e){var g="";null!=d&&(g=(""+d).replace(O,"$&/")+"/");b=Q(b,g,c,e);U(a,aa,b);R(b)}function ba(a,b){var d=I.currentDispatcher;null===d?B("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=Q(null,null,b,d);U(a,V,b);R(b)},count:function(a){return U(a,function(){return null},null)},toArray:function(a){var b=[];W(a,b,null,function(a){return a});return b},only:function(a){N(a)?void 0:B("143");return a}},createRef:function(){return{current:null}},Component:E,PureComponent:G,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=ba.bind(null,a);return a},forwardRef:function(a){return{$$typeof:y,render:a}},Fragment:r,StrictMode:t,unstable_AsyncMode:x,unstable_Profiler:u,createElement:L,cloneElement:function(a,b,d){null===a||void 0===a?B("267",a):void 0;var c=void 0,e=m({},a.props),g=a.key,h=a.ref,f=a._owner;if(null!=b){void 0!==b.ref&&(h=b.ref,f=I.current);void 0!==b.key&&(g=""+b.key);
|
|
23
|
+
var k=void 0;a.type&&a.type.defaultProps&&(k=a.type.defaultProps);for(c in b)J.call(b,c)&&!K.hasOwnProperty(c)&&(e[c]=void 0===b[c]&&void 0!==k?k[c]:b[c])}c=arguments.length-2;if(1===c)e.children=d;else if(1<c){k=Array(c);for(var l=0;l<c;l++)k[l]=arguments[l+2];e.children=k}return{$$typeof:p,type:a.type,key:g,ref:h,props:e,_owner:f}},createFactory:function(a){var b=L.bind(null,a);b.type=a;return b},isValidElement:N,version:"16.6.0-alpha.0",__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED:{ReactCurrentOwner:I,
|
|
24
|
+
assign:m}},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.0",
|
|
8
8
|
"homepage": "https://reactjs.org/",
|
|
9
9
|
"bugs": "https://github.com/facebook/react/issues",
|
|
10
10
|
"license": "MIT",
|
|
@@ -21,10 +21,10 @@
|
|
|
21
21
|
"node": ">=0.10.0"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"fbjs": "^0.8.16",
|
|
25
24
|
"loose-envify": "^1.1.0",
|
|
26
25
|
"object-assign": "^4.1.1",
|
|
27
|
-
"prop-types": "^15.6.
|
|
26
|
+
"prop-types": "^15.6.2",
|
|
27
|
+
"schedule": "^0.5.0-alpha.0"
|
|
28
28
|
},
|
|
29
29
|
"browserify": {
|
|
30
30
|
"transform": [
|
package/umd/react.development.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
/** @license React v16.
|
|
1
|
+
/** @license React v16.6.0-alpha.0
|
|
2
2
|
* react.development.js
|
|
3
3
|
*
|
|
4
|
-
* Copyright (c)
|
|
4
|
+
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
5
5
|
*
|
|
6
6
|
* This source code is licensed under the MIT license found in the
|
|
7
7
|
* LICENSE file in the root directory of this source tree.
|
|
@@ -15,6 +15,81 @@
|
|
|
15
15
|
(global.React = factory());
|
|
16
16
|
}(this, (function () { 'use strict';
|
|
17
17
|
|
|
18
|
+
// TODO: this is special because it gets imported during build.
|
|
19
|
+
|
|
20
|
+
var ReactVersion = '16.6.0-alpha.0';
|
|
21
|
+
|
|
22
|
+
// The Symbol used to tag the ReactElement-like types. If there is no native Symbol
|
|
23
|
+
// nor polyfill, then a plain number is used for performance.
|
|
24
|
+
var hasSymbol = typeof Symbol === 'function' && Symbol.for;
|
|
25
|
+
|
|
26
|
+
var REACT_ELEMENT_TYPE = hasSymbol ? Symbol.for('react.element') : 0xeac7;
|
|
27
|
+
var REACT_PORTAL_TYPE = hasSymbol ? Symbol.for('react.portal') : 0xeaca;
|
|
28
|
+
var REACT_FRAGMENT_TYPE = hasSymbol ? Symbol.for('react.fragment') : 0xeacb;
|
|
29
|
+
var REACT_STRICT_MODE_TYPE = hasSymbol ? Symbol.for('react.strict_mode') : 0xeacc;
|
|
30
|
+
var REACT_PROFILER_TYPE = hasSymbol ? Symbol.for('react.profiler') : 0xead2;
|
|
31
|
+
var REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for('react.provider') : 0xeacd;
|
|
32
|
+
var REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for('react.context') : 0xeace;
|
|
33
|
+
var REACT_ASYNC_MODE_TYPE = hasSymbol ? Symbol.for('react.async_mode') : 0xeacf;
|
|
34
|
+
var REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for('react.forward_ref') : 0xead0;
|
|
35
|
+
var REACT_PLACEHOLDER_TYPE = hasSymbol ? Symbol.for('react.placeholder') : 0xead1;
|
|
36
|
+
|
|
37
|
+
var MAYBE_ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
|
|
38
|
+
var FAUX_ITERATOR_SYMBOL = '@@iterator';
|
|
39
|
+
|
|
40
|
+
function getIteratorFn(maybeIterable) {
|
|
41
|
+
if (maybeIterable === null || typeof maybeIterable !== 'object') {
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
var maybeIterator = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL];
|
|
45
|
+
if (typeof maybeIterator === 'function') {
|
|
46
|
+
return maybeIterator;
|
|
47
|
+
}
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
|
|
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
|
+
|
|
18
93
|
/*
|
|
19
94
|
object-assign
|
|
20
95
|
(c) Sindre Sorhus
|
|
@@ -106,49 +181,6 @@ var objectAssign = shouldUseNative() ? Object.assign : function (target, source)
|
|
|
106
181
|
return to;
|
|
107
182
|
};
|
|
108
183
|
|
|
109
|
-
// TODO: this is special because it gets imported during build.
|
|
110
|
-
|
|
111
|
-
var ReactVersion = '16.4.2';
|
|
112
|
-
|
|
113
|
-
// The Symbol used to tag the ReactElement-like types. If there is no native Symbol
|
|
114
|
-
// nor polyfill, then a plain number is used for performance.
|
|
115
|
-
var hasSymbol = typeof Symbol === 'function' && Symbol.for;
|
|
116
|
-
|
|
117
|
-
var REACT_ELEMENT_TYPE = hasSymbol ? Symbol.for('react.element') : 0xeac7;
|
|
118
|
-
var REACT_PORTAL_TYPE = hasSymbol ? Symbol.for('react.portal') : 0xeaca;
|
|
119
|
-
var REACT_FRAGMENT_TYPE = hasSymbol ? Symbol.for('react.fragment') : 0xeacb;
|
|
120
|
-
var REACT_STRICT_MODE_TYPE = hasSymbol ? Symbol.for('react.strict_mode') : 0xeacc;
|
|
121
|
-
var REACT_PROFILER_TYPE = hasSymbol ? Symbol.for('react.profiler') : 0xead2;
|
|
122
|
-
var REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for('react.provider') : 0xeacd;
|
|
123
|
-
var REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for('react.context') : 0xeace;
|
|
124
|
-
var REACT_ASYNC_MODE_TYPE = hasSymbol ? Symbol.for('react.async_mode') : 0xeacf;
|
|
125
|
-
var REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for('react.forward_ref') : 0xead0;
|
|
126
|
-
var REACT_TIMEOUT_TYPE = hasSymbol ? Symbol.for('react.timeout') : 0xead1;
|
|
127
|
-
|
|
128
|
-
var MAYBE_ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
|
|
129
|
-
var FAUX_ITERATOR_SYMBOL = '@@iterator';
|
|
130
|
-
|
|
131
|
-
function getIteratorFn(maybeIterable) {
|
|
132
|
-
if (maybeIterable === null || typeof maybeIterable === 'undefined') {
|
|
133
|
-
return null;
|
|
134
|
-
}
|
|
135
|
-
var maybeIterator = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL];
|
|
136
|
-
if (typeof maybeIterator === 'function') {
|
|
137
|
-
return maybeIterator;
|
|
138
|
-
}
|
|
139
|
-
return null;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
/**
|
|
143
|
-
* Copyright (c) 2013-present, Facebook, Inc.
|
|
144
|
-
*
|
|
145
|
-
* This source code is licensed under the MIT license found in the
|
|
146
|
-
* LICENSE file in the root directory of this source tree.
|
|
147
|
-
*
|
|
148
|
-
*/
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
184
|
/**
|
|
153
185
|
* Use invariant() to assert state which your program assumes to be true.
|
|
154
186
|
*
|
|
@@ -160,10 +192,10 @@ function getIteratorFn(maybeIterable) {
|
|
|
160
192
|
* will remain to ensure logic does not differ in production.
|
|
161
193
|
*/
|
|
162
194
|
|
|
163
|
-
var validateFormat = function
|
|
195
|
+
var validateFormat = function () {};
|
|
164
196
|
|
|
165
197
|
{
|
|
166
|
-
validateFormat = function
|
|
198
|
+
validateFormat = function (format) {
|
|
167
199
|
if (format === undefined) {
|
|
168
200
|
throw new Error('invariant requires an error message argument');
|
|
169
201
|
}
|
|
@@ -174,7 +206,7 @@ function invariant(condition, format, a, b, c, d, e, f) {
|
|
|
174
206
|
validateFormat(format);
|
|
175
207
|
|
|
176
208
|
if (!condition) {
|
|
177
|
-
var error;
|
|
209
|
+
var error = void 0;
|
|
178
210
|
if (format === undefined) {
|
|
179
211
|
error = new Error('Minified exception occurred; use the non-minified dev environment ' + 'for the full error message and additional helpful warnings.');
|
|
180
212
|
} else {
|
|
@@ -191,60 +223,8 @@ function invariant(condition, format, a, b, c, d, e, f) {
|
|
|
191
223
|
}
|
|
192
224
|
}
|
|
193
225
|
|
|
194
|
-
var invariant_1 = invariant;
|
|
195
|
-
|
|
196
226
|
// Relying on the `invariant()` implementation lets us
|
|
197
|
-
//
|
|
198
|
-
|
|
199
|
-
// Exports ReactDOM.createRoot
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
// Experimental error-boundary API that can recover from errors within a single
|
|
203
|
-
// render phase
|
|
204
|
-
|
|
205
|
-
// Suspense
|
|
206
|
-
var enableSuspense = false;
|
|
207
|
-
// Helps identify side effects in begin-phase lifecycle hooks and setState reducers:
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
// In some cases, StrictMode should also double-render lifecycles.
|
|
211
|
-
// This can be confusing for tests though,
|
|
212
|
-
// And it can be bad for performance in production.
|
|
213
|
-
// This feature flag can be used to control the behavior:
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
// To preserve the "Pause on caught exceptions" behavior of the debugger, we
|
|
217
|
-
// replay the begin phase of a failed component inside invokeGuardedCallback.
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
// Warn about deprecated, async-unsafe lifecycles; relates to RFC #6:
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
// Warn about legacy context API
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
// Gather advanced timing metrics for Profiler subtrees.
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
// Only used in www builds.
|
|
230
|
-
|
|
231
|
-
/**
|
|
232
|
-
* Copyright (c) 2013-present, Facebook, Inc.
|
|
233
|
-
*
|
|
234
|
-
* This source code is licensed under the MIT license found in the
|
|
235
|
-
* LICENSE file in the root directory of this source tree.
|
|
236
|
-
*
|
|
237
|
-
*/
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
var emptyObject = {};
|
|
242
|
-
|
|
243
|
-
{
|
|
244
|
-
Object.freeze(emptyObject);
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
var emptyObject_1 = emptyObject;
|
|
227
|
+
// preserve the format and params in the www builds.
|
|
248
228
|
|
|
249
229
|
/**
|
|
250
230
|
* Forked from fbjs/warning:
|
|
@@ -285,7 +265,7 @@ var lowPriorityWarning = function () {};
|
|
|
285
265
|
|
|
286
266
|
lowPriorityWarning = function (condition, format) {
|
|
287
267
|
if (format === undefined) {
|
|
288
|
-
throw new Error('`
|
|
268
|
+
throw new Error('`lowPriorityWarning(condition, format, ...args)` requires a warning ' + 'message argument');
|
|
289
269
|
}
|
|
290
270
|
if (!condition) {
|
|
291
271
|
for (var _len2 = arguments.length, args = Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
|
|
@@ -299,53 +279,6 @@ var lowPriorityWarning = function () {};
|
|
|
299
279
|
|
|
300
280
|
var lowPriorityWarning$1 = lowPriorityWarning;
|
|
301
281
|
|
|
302
|
-
/**
|
|
303
|
-
* Copyright (c) 2013-present, Facebook, Inc.
|
|
304
|
-
*
|
|
305
|
-
* This source code is licensed under the MIT license found in the
|
|
306
|
-
* LICENSE file in the root directory of this source tree.
|
|
307
|
-
*
|
|
308
|
-
*
|
|
309
|
-
*/
|
|
310
|
-
|
|
311
|
-
function makeEmptyFunction(arg) {
|
|
312
|
-
return function () {
|
|
313
|
-
return arg;
|
|
314
|
-
};
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
/**
|
|
318
|
-
* This function accepts and discards inputs; it has no side effects. This is
|
|
319
|
-
* primarily useful idiomatically for overridable function endpoints which
|
|
320
|
-
* always need to be callable, since JS lacks a null-call idiom ala Cocoa.
|
|
321
|
-
*/
|
|
322
|
-
var emptyFunction = function emptyFunction() {};
|
|
323
|
-
|
|
324
|
-
emptyFunction.thatReturns = makeEmptyFunction;
|
|
325
|
-
emptyFunction.thatReturnsFalse = makeEmptyFunction(false);
|
|
326
|
-
emptyFunction.thatReturnsTrue = makeEmptyFunction(true);
|
|
327
|
-
emptyFunction.thatReturnsNull = makeEmptyFunction(null);
|
|
328
|
-
emptyFunction.thatReturnsThis = function () {
|
|
329
|
-
return this;
|
|
330
|
-
};
|
|
331
|
-
emptyFunction.thatReturnsArgument = function (arg) {
|
|
332
|
-
return arg;
|
|
333
|
-
};
|
|
334
|
-
|
|
335
|
-
var emptyFunction_1 = emptyFunction;
|
|
336
|
-
|
|
337
|
-
/**
|
|
338
|
-
* Copyright (c) 2014-present, Facebook, Inc.
|
|
339
|
-
*
|
|
340
|
-
* This source code is licensed under the MIT license found in the
|
|
341
|
-
* LICENSE file in the root directory of this source tree.
|
|
342
|
-
*
|
|
343
|
-
*/
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
282
|
/**
|
|
350
283
|
* Similar to invariant but only logs a warning if the condition is not met.
|
|
351
284
|
* This can be used to log issues in development environments in critical
|
|
@@ -353,49 +286,87 @@ var emptyFunction_1 = emptyFunction;
|
|
|
353
286
|
* same logic and follow the same code paths.
|
|
354
287
|
*/
|
|
355
288
|
|
|
356
|
-
var
|
|
289
|
+
var warningWithoutStack = function () {};
|
|
357
290
|
|
|
358
291
|
{
|
|
359
|
-
|
|
360
|
-
for (var _len = arguments.length, args = Array(_len >
|
|
361
|
-
args[_key -
|
|
292
|
+
warningWithoutStack = function (condition, format) {
|
|
293
|
+
for (var _len = arguments.length, args = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
|
|
294
|
+
args[_key - 2] = arguments[_key];
|
|
362
295
|
}
|
|
363
296
|
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
297
|
+
if (format === undefined) {
|
|
298
|
+
throw new Error('`warningWithoutStack(condition, format, ...args)` requires a warning ' + 'message argument');
|
|
299
|
+
}
|
|
300
|
+
if (args.length > 8) {
|
|
301
|
+
// Check before the condition to catch violations early.
|
|
302
|
+
throw new Error('warningWithoutStack() currently supports at most 8 arguments.');
|
|
303
|
+
}
|
|
304
|
+
if (condition) {
|
|
305
|
+
return;
|
|
306
|
+
}
|
|
368
307
|
if (typeof console !== 'undefined') {
|
|
369
|
-
|
|
308
|
+
var _args$map = args.map(function (item) {
|
|
309
|
+
return '' + item;
|
|
310
|
+
}),
|
|
311
|
+
a = _args$map[0],
|
|
312
|
+
b = _args$map[1],
|
|
313
|
+
c = _args$map[2],
|
|
314
|
+
d = _args$map[3],
|
|
315
|
+
e = _args$map[4],
|
|
316
|
+
f = _args$map[5],
|
|
317
|
+
g = _args$map[6],
|
|
318
|
+
h = _args$map[7];
|
|
319
|
+
|
|
320
|
+
var message = 'Warning: ' + format;
|
|
321
|
+
|
|
322
|
+
// We intentionally don't use spread (or .apply) because it breaks IE9:
|
|
323
|
+
// https://github.com/facebook/react/issues/13610
|
|
324
|
+
switch (args.length) {
|
|
325
|
+
case 0:
|
|
326
|
+
console.error(message);
|
|
327
|
+
break;
|
|
328
|
+
case 1:
|
|
329
|
+
console.error(message, a);
|
|
330
|
+
break;
|
|
331
|
+
case 2:
|
|
332
|
+
console.error(message, a, b);
|
|
333
|
+
break;
|
|
334
|
+
case 3:
|
|
335
|
+
console.error(message, a, b, c);
|
|
336
|
+
break;
|
|
337
|
+
case 4:
|
|
338
|
+
console.error(message, a, b, c, d);
|
|
339
|
+
break;
|
|
340
|
+
case 5:
|
|
341
|
+
console.error(message, a, b, c, d, e);
|
|
342
|
+
break;
|
|
343
|
+
case 6:
|
|
344
|
+
console.error(message, a, b, c, d, e, f);
|
|
345
|
+
break;
|
|
346
|
+
case 7:
|
|
347
|
+
console.error(message, a, b, c, d, e, f, g);
|
|
348
|
+
break;
|
|
349
|
+
case 8:
|
|
350
|
+
console.error(message, a, b, c, d, e, f, g, h);
|
|
351
|
+
break;
|
|
352
|
+
default:
|
|
353
|
+
throw new Error('warningWithoutStack() currently supports at most 8 arguments.');
|
|
354
|
+
}
|
|
370
355
|
}
|
|
371
356
|
try {
|
|
372
357
|
// --- Welcome to debugging React ---
|
|
373
358
|
// This error was thrown as a convenience so that you can use this stack
|
|
374
359
|
// to find the callsite that caused this warning to fire.
|
|
375
|
-
|
|
360
|
+
var argIndex = 0;
|
|
361
|
+
var _message = 'Warning: ' + format.replace(/%s/g, function () {
|
|
362
|
+
return args[argIndex++];
|
|
363
|
+
});
|
|
364
|
+
throw new Error(_message);
|
|
376
365
|
} catch (x) {}
|
|
377
366
|
};
|
|
378
|
-
|
|
379
|
-
warning = function warning(condition, format) {
|
|
380
|
-
if (format === undefined) {
|
|
381
|
-
throw new Error('`warning(condition, format, ...args)` requires a warning ' + 'message argument');
|
|
382
|
-
}
|
|
383
|
-
|
|
384
|
-
if (format.indexOf('Failed Composite propType: ') === 0) {
|
|
385
|
-
return; // Ignore CompositeComponent proptype check.
|
|
386
|
-
}
|
|
387
|
-
|
|
388
|
-
if (!condition) {
|
|
389
|
-
for (var _len2 = arguments.length, args = Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
|
|
390
|
-
args[_key2 - 2] = arguments[_key2];
|
|
391
|
-
}
|
|
392
|
-
|
|
393
|
-
printWarning$1.apply(undefined, [format].concat(args));
|
|
394
|
-
}
|
|
395
|
-
};
|
|
396
367
|
}
|
|
397
368
|
|
|
398
|
-
var
|
|
369
|
+
var warningWithoutStack$1 = warningWithoutStack;
|
|
399
370
|
|
|
400
371
|
var didWarnStateUpdateForUnmountedComponent = {};
|
|
401
372
|
|
|
@@ -407,7 +378,7 @@ function warnNoop(publicInstance, callerName) {
|
|
|
407
378
|
if (didWarnStateUpdateForUnmountedComponent[warningKey]) {
|
|
408
379
|
return;
|
|
409
380
|
}
|
|
410
|
-
|
|
381
|
+
warningWithoutStack$1(false, "Can't call %s on a component that is not yet mounted. " + 'This is a no-op, but it might indicate a bug in your application. ' + 'Instead, assign to `this.state` directly or define a `state = {};` ' + 'class property with the desired state in the %s component.', callerName, componentName);
|
|
411
382
|
didWarnStateUpdateForUnmountedComponent[warningKey] = true;
|
|
412
383
|
}
|
|
413
384
|
}
|
|
@@ -480,13 +451,19 @@ var ReactNoopUpdateQueue = {
|
|
|
480
451
|
}
|
|
481
452
|
};
|
|
482
453
|
|
|
454
|
+
var emptyObject = {};
|
|
455
|
+
{
|
|
456
|
+
Object.freeze(emptyObject);
|
|
457
|
+
}
|
|
458
|
+
|
|
483
459
|
/**
|
|
484
460
|
* Base class helpers for the updating state of a component.
|
|
485
461
|
*/
|
|
486
462
|
function Component(props, context, updater) {
|
|
487
463
|
this.props = props;
|
|
488
464
|
this.context = context;
|
|
489
|
-
|
|
465
|
+
// If a component has string refs, we will assign a different object later.
|
|
466
|
+
this.refs = emptyObject;
|
|
490
467
|
// We initialize the default updater but the real one gets injected by the
|
|
491
468
|
// renderer.
|
|
492
469
|
this.updater = updater || ReactNoopUpdateQueue;
|
|
@@ -520,7 +497,7 @@ Component.prototype.isReactComponent = {};
|
|
|
520
497
|
* @protected
|
|
521
498
|
*/
|
|
522
499
|
Component.prototype.setState = function (partialState, callback) {
|
|
523
|
-
!(typeof partialState === 'object' || typeof partialState === 'function' || partialState == null) ?
|
|
500
|
+
!(typeof partialState === 'object' || typeof partialState === 'function' || partialState == null) ? invariant(false, 'setState(...): takes an object of state variables to update or a function which returns an object of state variables.') : void 0;
|
|
524
501
|
this.updater.enqueueSetState(this, partialState, callback, 'setState');
|
|
525
502
|
};
|
|
526
503
|
|
|
@@ -542,59 +519,818 @@ Component.prototype.forceUpdate = function (callback) {
|
|
|
542
519
|
this.updater.enqueueForceUpdate(this, callback, 'forceUpdate');
|
|
543
520
|
};
|
|
544
521
|
|
|
545
|
-
/**
|
|
546
|
-
* Deprecated APIs. These APIs used to exist on classic React classes but since
|
|
547
|
-
* we would like to deprecate them, we're not going to move them over to this
|
|
548
|
-
* modern base class. Instead, we define a getter that warns if it's accessed.
|
|
549
|
-
*/
|
|
550
|
-
{
|
|
551
|
-
var deprecatedAPIs = {
|
|
552
|
-
isMounted: ['isMounted', 'Instead, make sure to clean up subscriptions and pending requests in ' + 'componentWillUnmount to prevent memory leaks.'],
|
|
553
|
-
replaceState: ['replaceState', 'Refactor your code to use setState instead (see ' + 'https://github.com/facebook/react/issues/3236).']
|
|
554
|
-
};
|
|
555
|
-
var defineDeprecationWarning = function (methodName, info) {
|
|
556
|
-
Object.defineProperty(Component.prototype, methodName, {
|
|
557
|
-
get: function () {
|
|
558
|
-
lowPriorityWarning$1(false, '%s(...) is deprecated in plain JavaScript React classes. %s', info[0], info[1]);
|
|
559
|
-
return undefined;
|
|
522
|
+
/**
|
|
523
|
+
* Deprecated APIs. These APIs used to exist on classic React classes but since
|
|
524
|
+
* we would like to deprecate them, we're not going to move them over to this
|
|
525
|
+
* modern base class. Instead, we define a getter that warns if it's accessed.
|
|
526
|
+
*/
|
|
527
|
+
{
|
|
528
|
+
var deprecatedAPIs = {
|
|
529
|
+
isMounted: ['isMounted', 'Instead, make sure to clean up subscriptions and pending requests in ' + 'componentWillUnmount to prevent memory leaks.'],
|
|
530
|
+
replaceState: ['replaceState', 'Refactor your code to use setState instead (see ' + 'https://github.com/facebook/react/issues/3236).']
|
|
531
|
+
};
|
|
532
|
+
var defineDeprecationWarning = function (methodName, info) {
|
|
533
|
+
Object.defineProperty(Component.prototype, methodName, {
|
|
534
|
+
get: function () {
|
|
535
|
+
lowPriorityWarning$1(false, '%s(...) is deprecated in plain JavaScript React classes. %s', info[0], info[1]);
|
|
536
|
+
return undefined;
|
|
537
|
+
}
|
|
538
|
+
});
|
|
539
|
+
};
|
|
540
|
+
for (var fnName in deprecatedAPIs) {
|
|
541
|
+
if (deprecatedAPIs.hasOwnProperty(fnName)) {
|
|
542
|
+
defineDeprecationWarning(fnName, deprecatedAPIs[fnName]);
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
function ComponentDummy() {}
|
|
548
|
+
ComponentDummy.prototype = Component.prototype;
|
|
549
|
+
|
|
550
|
+
/**
|
|
551
|
+
* Convenience component with default shallow equality check for sCU.
|
|
552
|
+
*/
|
|
553
|
+
function PureComponent(props, context, updater) {
|
|
554
|
+
this.props = props;
|
|
555
|
+
this.context = context;
|
|
556
|
+
// If a component has string refs, we will assign a different object later.
|
|
557
|
+
this.refs = emptyObject;
|
|
558
|
+
this.updater = updater || ReactNoopUpdateQueue;
|
|
559
|
+
}
|
|
560
|
+
|
|
561
|
+
var pureComponentPrototype = PureComponent.prototype = new ComponentDummy();
|
|
562
|
+
pureComponentPrototype.constructor = PureComponent;
|
|
563
|
+
// Avoid an extra prototype jump for these methods.
|
|
564
|
+
objectAssign(pureComponentPrototype, Component.prototype);
|
|
565
|
+
pureComponentPrototype.isPureReactComponent = true;
|
|
566
|
+
|
|
567
|
+
// an immutable object with a single mutable value
|
|
568
|
+
function createRef() {
|
|
569
|
+
var refObject = {
|
|
570
|
+
current: null
|
|
571
|
+
};
|
|
572
|
+
{
|
|
573
|
+
Object.seal(refObject);
|
|
574
|
+
}
|
|
575
|
+
return refObject;
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
/* eslint-disable no-var */
|
|
579
|
+
|
|
580
|
+
// TODO: Currently there's only a single priority level, Deferred. Will add
|
|
581
|
+
// additional priorities.
|
|
582
|
+
var DEFERRED_TIMEOUT = 5000;
|
|
583
|
+
|
|
584
|
+
// Callbacks are stored as a circular, doubly linked list.
|
|
585
|
+
var firstCallbackNode = null;
|
|
586
|
+
|
|
587
|
+
var isPerformingWork = false;
|
|
588
|
+
|
|
589
|
+
var isHostCallbackScheduled = false;
|
|
590
|
+
|
|
591
|
+
var hasNativePerformanceNow = typeof performance === 'object' && typeof performance.now === 'function';
|
|
592
|
+
|
|
593
|
+
var timeRemaining;
|
|
594
|
+
if (hasNativePerformanceNow) {
|
|
595
|
+
timeRemaining = function () {
|
|
596
|
+
// We assume that if we have a performance timer that the rAF callback
|
|
597
|
+
// gets a performance timer value. Not sure if this is always true.
|
|
598
|
+
var remaining = getFrameDeadline() - performance.now();
|
|
599
|
+
return remaining > 0 ? remaining : 0;
|
|
600
|
+
};
|
|
601
|
+
} else {
|
|
602
|
+
timeRemaining = function () {
|
|
603
|
+
// Fallback to Date.now()
|
|
604
|
+
var remaining = getFrameDeadline() - Date.now();
|
|
605
|
+
return remaining > 0 ? remaining : 0;
|
|
606
|
+
};
|
|
607
|
+
}
|
|
608
|
+
|
|
609
|
+
var deadlineObject = {
|
|
610
|
+
timeRemaining: timeRemaining,
|
|
611
|
+
didTimeout: false
|
|
612
|
+
};
|
|
613
|
+
|
|
614
|
+
function ensureHostCallbackIsScheduled() {
|
|
615
|
+
if (isPerformingWork) {
|
|
616
|
+
// Don't schedule work yet; wait until the next time we yield.
|
|
617
|
+
return;
|
|
618
|
+
}
|
|
619
|
+
// Schedule the host callback using the earliest timeout in the list.
|
|
620
|
+
var timesOutAt = firstCallbackNode.timesOutAt;
|
|
621
|
+
if (!isHostCallbackScheduled) {
|
|
622
|
+
isHostCallbackScheduled = true;
|
|
623
|
+
} else {
|
|
624
|
+
// Cancel the existing host callback.
|
|
625
|
+
cancelCallback();
|
|
626
|
+
}
|
|
627
|
+
requestCallback(flushWork, timesOutAt);
|
|
628
|
+
}
|
|
629
|
+
|
|
630
|
+
function flushFirstCallback(node) {
|
|
631
|
+
var flushedNode = firstCallbackNode;
|
|
632
|
+
|
|
633
|
+
// Remove the node from the list before calling the callback. That way the
|
|
634
|
+
// list is in a consistent state even if the callback throws.
|
|
635
|
+
var next = firstCallbackNode.next;
|
|
636
|
+
if (firstCallbackNode === next) {
|
|
637
|
+
// This is the last callback in the list.
|
|
638
|
+
firstCallbackNode = null;
|
|
639
|
+
next = null;
|
|
640
|
+
} else {
|
|
641
|
+
var previous = firstCallbackNode.previous;
|
|
642
|
+
firstCallbackNode = previous.next = next;
|
|
643
|
+
next.previous = previous;
|
|
644
|
+
}
|
|
645
|
+
|
|
646
|
+
flushedNode.next = flushedNode.previous = null;
|
|
647
|
+
|
|
648
|
+
// Now it's safe to call the callback.
|
|
649
|
+
var callback = flushedNode.callback;
|
|
650
|
+
callback(deadlineObject);
|
|
651
|
+
}
|
|
652
|
+
|
|
653
|
+
function flushWork(didTimeout) {
|
|
654
|
+
isPerformingWork = true;
|
|
655
|
+
deadlineObject.didTimeout = didTimeout;
|
|
656
|
+
try {
|
|
657
|
+
if (didTimeout) {
|
|
658
|
+
// Flush all the timed out callbacks without yielding.
|
|
659
|
+
while (firstCallbackNode !== null) {
|
|
660
|
+
// Read the current time. Flush all the callbacks that expire at or
|
|
661
|
+
// earlier than that time. Then read the current time again and repeat.
|
|
662
|
+
// This optimizes for as few performance.now calls as possible.
|
|
663
|
+
var currentTime = getCurrentTime();
|
|
664
|
+
if (firstCallbackNode.timesOutAt <= currentTime) {
|
|
665
|
+
do {
|
|
666
|
+
flushFirstCallback();
|
|
667
|
+
} while (firstCallbackNode !== null && firstCallbackNode.timesOutAt <= currentTime);
|
|
668
|
+
continue;
|
|
669
|
+
}
|
|
670
|
+
break;
|
|
671
|
+
}
|
|
672
|
+
} else {
|
|
673
|
+
// Keep flushing callbacks until we run out of time in the frame.
|
|
674
|
+
if (firstCallbackNode !== null) {
|
|
675
|
+
do {
|
|
676
|
+
flushFirstCallback();
|
|
677
|
+
} while (firstCallbackNode !== null && getFrameDeadline() - getCurrentTime() > 0);
|
|
678
|
+
}
|
|
679
|
+
}
|
|
680
|
+
} finally {
|
|
681
|
+
isPerformingWork = false;
|
|
682
|
+
if (firstCallbackNode !== null) {
|
|
683
|
+
// There's still work remaining. Request another callback.
|
|
684
|
+
ensureHostCallbackIsScheduled(firstCallbackNode);
|
|
685
|
+
} else {
|
|
686
|
+
isHostCallbackScheduled = false;
|
|
687
|
+
}
|
|
688
|
+
}
|
|
689
|
+
}
|
|
690
|
+
|
|
691
|
+
function unstable_scheduleWork(callback, options) {
|
|
692
|
+
var currentTime = getCurrentTime();
|
|
693
|
+
|
|
694
|
+
var timesOutAt;
|
|
695
|
+
if (options !== undefined && options !== null && options.timeout !== null && options.timeout !== undefined) {
|
|
696
|
+
// Check for an explicit timeout
|
|
697
|
+
timesOutAt = currentTime + options.timeout;
|
|
698
|
+
} else {
|
|
699
|
+
// Compute an absolute timeout using the default constant.
|
|
700
|
+
timesOutAt = currentTime + DEFERRED_TIMEOUT;
|
|
701
|
+
}
|
|
702
|
+
|
|
703
|
+
var newNode = {
|
|
704
|
+
callback: callback,
|
|
705
|
+
timesOutAt: timesOutAt,
|
|
706
|
+
next: null,
|
|
707
|
+
previous: null
|
|
708
|
+
};
|
|
709
|
+
|
|
710
|
+
// Insert the new callback into the list, sorted by its timeout.
|
|
711
|
+
if (firstCallbackNode === null) {
|
|
712
|
+
// This is the first callback in the list.
|
|
713
|
+
firstCallbackNode = newNode.next = newNode.previous = newNode;
|
|
714
|
+
ensureHostCallbackIsScheduled(firstCallbackNode);
|
|
715
|
+
} else {
|
|
716
|
+
var next = null;
|
|
717
|
+
var node = firstCallbackNode;
|
|
718
|
+
do {
|
|
719
|
+
if (node.timesOutAt > timesOutAt) {
|
|
720
|
+
// The new callback times out before this one.
|
|
721
|
+
next = node;
|
|
722
|
+
break;
|
|
723
|
+
}
|
|
724
|
+
node = node.next;
|
|
725
|
+
} while (node !== firstCallbackNode);
|
|
726
|
+
|
|
727
|
+
if (next === null) {
|
|
728
|
+
// No callback with a later timeout was found, which means the new
|
|
729
|
+
// callback has the latest timeout in the list.
|
|
730
|
+
next = firstCallbackNode;
|
|
731
|
+
} else if (next === firstCallbackNode) {
|
|
732
|
+
// The new callback has the earliest timeout in the entire list.
|
|
733
|
+
firstCallbackNode = newNode;
|
|
734
|
+
ensureHostCallbackIsScheduled(firstCallbackNode);
|
|
735
|
+
}
|
|
736
|
+
|
|
737
|
+
var previous = next.previous;
|
|
738
|
+
previous.next = next.previous = newNode;
|
|
739
|
+
newNode.next = next;
|
|
740
|
+
newNode.previous = previous;
|
|
741
|
+
}
|
|
742
|
+
|
|
743
|
+
return newNode;
|
|
744
|
+
}
|
|
745
|
+
|
|
746
|
+
function unstable_cancelScheduledWork(callbackNode) {
|
|
747
|
+
var next = callbackNode.next;
|
|
748
|
+
if (next === null) {
|
|
749
|
+
// Already cancelled.
|
|
750
|
+
return;
|
|
751
|
+
}
|
|
752
|
+
|
|
753
|
+
if (next === callbackNode) {
|
|
754
|
+
// This is the only scheduled callback. Clear the list.
|
|
755
|
+
firstCallbackNode = null;
|
|
756
|
+
} else {
|
|
757
|
+
// Remove the callback from its position in the list.
|
|
758
|
+
if (callbackNode === firstCallbackNode) {
|
|
759
|
+
firstCallbackNode = next;
|
|
760
|
+
}
|
|
761
|
+
var previous = callbackNode.previous;
|
|
762
|
+
previous.next = next;
|
|
763
|
+
next.previous = previous;
|
|
764
|
+
}
|
|
765
|
+
|
|
766
|
+
callbackNode.next = callbackNode.previous = null;
|
|
767
|
+
}
|
|
768
|
+
|
|
769
|
+
// The remaining code is essentially a polyfill for requestIdleCallback. It
|
|
770
|
+
// works by scheduling a requestAnimationFrame, storing the time for the start
|
|
771
|
+
// of the frame, then scheduling a postMessage which gets scheduled after paint.
|
|
772
|
+
// Within the postMessage handler do as much work as possible until time + frame
|
|
773
|
+
// rate. By separating the idle call into a separate event tick we ensure that
|
|
774
|
+
// layout, paint and other browser work is counted against the available time.
|
|
775
|
+
// The frame rate is dynamically adjusted.
|
|
776
|
+
|
|
777
|
+
// We capture a local reference to any global, in case it gets polyfilled after
|
|
778
|
+
// this module is initially evaluated. We want to be using a
|
|
779
|
+
// consistent implementation.
|
|
780
|
+
var localDate = Date;
|
|
781
|
+
|
|
782
|
+
// This initialization code may run even on server environments if a component
|
|
783
|
+
// just imports ReactDOM (e.g. for findDOMNode). Some environments might not
|
|
784
|
+
// have setTimeout or clearTimeout. However, we always expect them to be defined
|
|
785
|
+
// on the client. https://github.com/facebook/react/pull/13088
|
|
786
|
+
var localSetTimeout = typeof setTimeout === 'function' ? setTimeout : undefined;
|
|
787
|
+
var localClearTimeout = typeof clearTimeout === 'function' ? clearTimeout : undefined;
|
|
788
|
+
|
|
789
|
+
// We don't expect either of these to necessarily be defined, but we will error
|
|
790
|
+
// later if they are missing on the client.
|
|
791
|
+
var localRequestAnimationFrame = typeof requestAnimationFrame === 'function' ? requestAnimationFrame : undefined;
|
|
792
|
+
var localCancelAnimationFrame = typeof cancelAnimationFrame === 'function' ? cancelAnimationFrame : undefined;
|
|
793
|
+
|
|
794
|
+
var getCurrentTime;
|
|
795
|
+
|
|
796
|
+
// requestAnimationFrame does not run when the tab is in the background. If
|
|
797
|
+
// we're backgrounded we prefer for that work to happen so that the page
|
|
798
|
+
// continues to load in the background. So we also schedule a 'setTimeout' as
|
|
799
|
+
// a fallback.
|
|
800
|
+
// TODO: Need a better heuristic for backgrounded work.
|
|
801
|
+
var ANIMATION_FRAME_TIMEOUT = 100;
|
|
802
|
+
var rAFID;
|
|
803
|
+
var rAFTimeoutID;
|
|
804
|
+
var requestAnimationFrameWithTimeout = function (callback) {
|
|
805
|
+
// schedule rAF and also a setTimeout
|
|
806
|
+
rAFID = localRequestAnimationFrame(function (timestamp) {
|
|
807
|
+
// cancel the setTimeout
|
|
808
|
+
localClearTimeout(rAFTimeoutID);
|
|
809
|
+
callback(timestamp);
|
|
810
|
+
});
|
|
811
|
+
rAFTimeoutID = localSetTimeout(function () {
|
|
812
|
+
// cancel the requestAnimationFrame
|
|
813
|
+
localCancelAnimationFrame(rAFID);
|
|
814
|
+
callback(getCurrentTime());
|
|
815
|
+
}, ANIMATION_FRAME_TIMEOUT);
|
|
816
|
+
};
|
|
817
|
+
|
|
818
|
+
if (hasNativePerformanceNow) {
|
|
819
|
+
var Performance = performance;
|
|
820
|
+
getCurrentTime = function () {
|
|
821
|
+
return Performance.now();
|
|
822
|
+
};
|
|
823
|
+
} else {
|
|
824
|
+
getCurrentTime = function () {
|
|
825
|
+
return localDate.now();
|
|
826
|
+
};
|
|
827
|
+
}
|
|
828
|
+
|
|
829
|
+
var requestCallback;
|
|
830
|
+
var cancelCallback;
|
|
831
|
+
var getFrameDeadline;
|
|
832
|
+
|
|
833
|
+
if (typeof window === 'undefined') {
|
|
834
|
+
// If this accidentally gets imported in a non-browser environment, fallback
|
|
835
|
+
// to a naive implementation.
|
|
836
|
+
var timeoutID = -1;
|
|
837
|
+
requestCallback = function (callback, absoluteTimeout) {
|
|
838
|
+
timeoutID = setTimeout(callback, 0, true);
|
|
839
|
+
};
|
|
840
|
+
cancelCallback = function () {
|
|
841
|
+
clearTimeout(timeoutID);
|
|
842
|
+
};
|
|
843
|
+
getFrameDeadline = function () {
|
|
844
|
+
return 0;
|
|
845
|
+
};
|
|
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
|
+
} else {
|
|
853
|
+
if (typeof console !== 'undefined') {
|
|
854
|
+
if (typeof localRequestAnimationFrame !== 'function') {
|
|
855
|
+
console.error("This browser doesn't support requestAnimationFrame. " + 'Make sure that you load a ' + 'polyfill in older browsers. https://fb.me/react-polyfills');
|
|
856
|
+
}
|
|
857
|
+
if (typeof localCancelAnimationFrame !== 'function') {
|
|
858
|
+
console.error("This browser doesn't support cancelAnimationFrame. " + 'Make sure that you load a ' + 'polyfill in older browsers. https://fb.me/react-polyfills');
|
|
859
|
+
}
|
|
860
|
+
}
|
|
861
|
+
|
|
862
|
+
var scheduledCallback = null;
|
|
863
|
+
var isIdleScheduled = false;
|
|
864
|
+
var timeoutTime = -1;
|
|
865
|
+
|
|
866
|
+
var isAnimationFrameScheduled = false;
|
|
867
|
+
|
|
868
|
+
var isPerformingIdleWork = false;
|
|
869
|
+
|
|
870
|
+
var frameDeadline = 0;
|
|
871
|
+
// We start out assuming that we run at 30fps but then the heuristic tracking
|
|
872
|
+
// will adjust this value to a faster fps if we get more frequent animation
|
|
873
|
+
// frames.
|
|
874
|
+
var previousFrameTime = 33;
|
|
875
|
+
var activeFrameTime = 33;
|
|
876
|
+
|
|
877
|
+
getFrameDeadline = function () {
|
|
878
|
+
return frameDeadline;
|
|
879
|
+
};
|
|
880
|
+
|
|
881
|
+
// We use the postMessage trick to defer idle work until after the repaint.
|
|
882
|
+
var messageKey = '__reactIdleCallback$' + Math.random().toString(36).slice(2);
|
|
883
|
+
var idleTick = function (event) {
|
|
884
|
+
if (event.source !== window || event.data !== messageKey) {
|
|
885
|
+
return;
|
|
886
|
+
}
|
|
887
|
+
|
|
888
|
+
isIdleScheduled = false;
|
|
889
|
+
|
|
890
|
+
var currentTime = getCurrentTime();
|
|
891
|
+
|
|
892
|
+
var didTimeout = false;
|
|
893
|
+
if (frameDeadline - currentTime <= 0) {
|
|
894
|
+
// There's no time left in this idle period. Check if the callback has
|
|
895
|
+
// a timeout and whether it's been exceeded.
|
|
896
|
+
if (timeoutTime !== -1 && timeoutTime <= currentTime) {
|
|
897
|
+
// Exceeded the timeout. Invoke the callback even though there's no
|
|
898
|
+
// time left.
|
|
899
|
+
didTimeout = true;
|
|
900
|
+
} else {
|
|
901
|
+
// No timeout.
|
|
902
|
+
if (!isAnimationFrameScheduled) {
|
|
903
|
+
// Schedule another animation callback so we retry later.
|
|
904
|
+
isAnimationFrameScheduled = true;
|
|
905
|
+
requestAnimationFrameWithTimeout(animationTick);
|
|
906
|
+
}
|
|
907
|
+
// Exit without invoking the callback.
|
|
908
|
+
return;
|
|
909
|
+
}
|
|
910
|
+
}
|
|
911
|
+
|
|
912
|
+
timeoutTime = -1;
|
|
913
|
+
var callback = scheduledCallback;
|
|
914
|
+
scheduledCallback = null;
|
|
915
|
+
if (callback !== null) {
|
|
916
|
+
isPerformingIdleWork = true;
|
|
917
|
+
try {
|
|
918
|
+
callback(didTimeout);
|
|
919
|
+
} finally {
|
|
920
|
+
isPerformingIdleWork = false;
|
|
921
|
+
}
|
|
922
|
+
}
|
|
923
|
+
};
|
|
924
|
+
// Assumes that we have addEventListener in this environment. Might need
|
|
925
|
+
// something better for old IE.
|
|
926
|
+
window.addEventListener('message', idleTick, false);
|
|
927
|
+
|
|
928
|
+
var animationTick = function (rafTime) {
|
|
929
|
+
isAnimationFrameScheduled = false;
|
|
930
|
+
var nextFrameTime = rafTime - frameDeadline + activeFrameTime;
|
|
931
|
+
if (nextFrameTime < activeFrameTime && previousFrameTime < activeFrameTime) {
|
|
932
|
+
if (nextFrameTime < 8) {
|
|
933
|
+
// Defensive coding. We don't support higher frame rates than 120hz.
|
|
934
|
+
// If we get lower than that, it is probably a bug.
|
|
935
|
+
nextFrameTime = 8;
|
|
936
|
+
}
|
|
937
|
+
// If one frame goes long, then the next one can be short to catch up.
|
|
938
|
+
// If two frames are short in a row, then that's an indication that we
|
|
939
|
+
// actually have a higher frame rate than what we're currently optimizing.
|
|
940
|
+
// We adjust our heuristic dynamically accordingly. For example, if we're
|
|
941
|
+
// running on 120hz display or 90hz VR display.
|
|
942
|
+
// Take the max of the two in case one of them was an anomaly due to
|
|
943
|
+
// missed frame deadlines.
|
|
944
|
+
activeFrameTime = nextFrameTime < previousFrameTime ? previousFrameTime : nextFrameTime;
|
|
945
|
+
} else {
|
|
946
|
+
previousFrameTime = nextFrameTime;
|
|
947
|
+
}
|
|
948
|
+
frameDeadline = rafTime + activeFrameTime;
|
|
949
|
+
if (!isIdleScheduled) {
|
|
950
|
+
isIdleScheduled = true;
|
|
951
|
+
window.postMessage(messageKey, '*');
|
|
952
|
+
}
|
|
953
|
+
};
|
|
954
|
+
|
|
955
|
+
requestCallback = function (callback, absoluteTimeout) {
|
|
956
|
+
scheduledCallback = callback;
|
|
957
|
+
timeoutTime = absoluteTimeout;
|
|
958
|
+
if (isPerformingIdleWork) {
|
|
959
|
+
// If we're already performing idle work, an error must have been thrown.
|
|
960
|
+
// Don't wait for the next frame. Continue working ASAP, in a new event.
|
|
961
|
+
window.postMessage(messageKey, '*');
|
|
962
|
+
} else if (!isAnimationFrameScheduled) {
|
|
963
|
+
// If rAF didn't already schedule one, we need to schedule a frame.
|
|
964
|
+
// TODO: If this rAF doesn't materialize because the browser throttles, we
|
|
965
|
+
// might want to still have setTimeout trigger rIC as a backup to ensure
|
|
966
|
+
// that we keep performing work.
|
|
967
|
+
isAnimationFrameScheduled = true;
|
|
968
|
+
requestAnimationFrameWithTimeout(animationTick);
|
|
969
|
+
}
|
|
970
|
+
};
|
|
971
|
+
|
|
972
|
+
cancelCallback = function () {
|
|
973
|
+
scheduledCallback = null;
|
|
974
|
+
isIdleScheduled = false;
|
|
975
|
+
timeoutTime = -1;
|
|
976
|
+
};
|
|
977
|
+
}
|
|
978
|
+
|
|
979
|
+
var DEFAULT_THREAD_ID = 0;
|
|
980
|
+
|
|
981
|
+
// Counters used to generate unique IDs.
|
|
982
|
+
var interactionIDCounter = 0;
|
|
983
|
+
var threadIDCounter = 0;
|
|
984
|
+
|
|
985
|
+
// Set of currently traced interactions.
|
|
986
|
+
// Interactions "stack"–
|
|
987
|
+
// Meaning that newly traced interactions are appended to the previously active set.
|
|
988
|
+
// When an interaction goes out of scope, the previous set (if any) is restored.
|
|
989
|
+
var interactionsRef = null;
|
|
990
|
+
|
|
991
|
+
// Listener(s) to notify when interactions begin and end.
|
|
992
|
+
var subscriberRef = null;
|
|
993
|
+
|
|
994
|
+
if (enableSchedulerTracing) {
|
|
995
|
+
interactionsRef = {
|
|
996
|
+
current: new Set()
|
|
997
|
+
};
|
|
998
|
+
subscriberRef = {
|
|
999
|
+
current: null
|
|
1000
|
+
};
|
|
1001
|
+
}
|
|
1002
|
+
|
|
1003
|
+
function unstable_clear(callback) {
|
|
1004
|
+
if (!enableSchedulerTracing) {
|
|
1005
|
+
return callback();
|
|
1006
|
+
}
|
|
1007
|
+
|
|
1008
|
+
var prevInteractions = interactionsRef.current;
|
|
1009
|
+
interactionsRef.current = new Set();
|
|
1010
|
+
|
|
1011
|
+
try {
|
|
1012
|
+
return callback();
|
|
1013
|
+
} finally {
|
|
1014
|
+
interactionsRef.current = prevInteractions;
|
|
1015
|
+
}
|
|
1016
|
+
}
|
|
1017
|
+
|
|
1018
|
+
function unstable_getCurrent() {
|
|
1019
|
+
if (!enableSchedulerTracing) {
|
|
1020
|
+
return null;
|
|
1021
|
+
} else {
|
|
1022
|
+
return interactionsRef.current;
|
|
1023
|
+
}
|
|
1024
|
+
}
|
|
1025
|
+
|
|
1026
|
+
function unstable_getThreadID() {
|
|
1027
|
+
return ++threadIDCounter;
|
|
1028
|
+
}
|
|
1029
|
+
|
|
1030
|
+
function unstable_trace(name, timestamp, callback) {
|
|
1031
|
+
var threadID = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : DEFAULT_THREAD_ID;
|
|
1032
|
+
|
|
1033
|
+
if (!enableSchedulerTracing) {
|
|
1034
|
+
return callback();
|
|
1035
|
+
}
|
|
1036
|
+
|
|
1037
|
+
var interaction = {
|
|
1038
|
+
__count: 1,
|
|
1039
|
+
id: interactionIDCounter++,
|
|
1040
|
+
name: name,
|
|
1041
|
+
timestamp: timestamp
|
|
1042
|
+
};
|
|
1043
|
+
|
|
1044
|
+
var prevInteractions = interactionsRef.current;
|
|
1045
|
+
|
|
1046
|
+
// Traced interactions should stack/accumulate.
|
|
1047
|
+
// To do that, clone the current interactions.
|
|
1048
|
+
// The previous set will be restored upon completion.
|
|
1049
|
+
var interactions = new Set(prevInteractions);
|
|
1050
|
+
interactions.add(interaction);
|
|
1051
|
+
interactionsRef.current = interactions;
|
|
1052
|
+
|
|
1053
|
+
var subscriber = subscriberRef.current;
|
|
1054
|
+
var returnValue = void 0;
|
|
1055
|
+
|
|
1056
|
+
try {
|
|
1057
|
+
if (subscriber !== null) {
|
|
1058
|
+
subscriber.onInteractionTraced(interaction);
|
|
1059
|
+
}
|
|
1060
|
+
} finally {
|
|
1061
|
+
try {
|
|
1062
|
+
if (subscriber !== null) {
|
|
1063
|
+
subscriber.onWorkStarted(interactions, threadID);
|
|
1064
|
+
}
|
|
1065
|
+
} finally {
|
|
1066
|
+
try {
|
|
1067
|
+
returnValue = callback();
|
|
1068
|
+
} finally {
|
|
1069
|
+
interactionsRef.current = prevInteractions;
|
|
1070
|
+
|
|
1071
|
+
try {
|
|
1072
|
+
if (subscriber !== null) {
|
|
1073
|
+
subscriber.onWorkStopped(interactions, threadID);
|
|
1074
|
+
}
|
|
1075
|
+
} finally {
|
|
1076
|
+
interaction.__count--;
|
|
1077
|
+
|
|
1078
|
+
// If no async work was scheduled for this interaction,
|
|
1079
|
+
// Notify subscribers that it's completed.
|
|
1080
|
+
if (subscriber !== null && interaction.__count === 0) {
|
|
1081
|
+
subscriber.onInteractionScheduledWorkCompleted(interaction);
|
|
1082
|
+
}
|
|
1083
|
+
}
|
|
1084
|
+
}
|
|
1085
|
+
}
|
|
1086
|
+
}
|
|
1087
|
+
|
|
1088
|
+
return returnValue;
|
|
1089
|
+
}
|
|
1090
|
+
|
|
1091
|
+
function unstable_wrap(callback) {
|
|
1092
|
+
var threadID = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DEFAULT_THREAD_ID;
|
|
1093
|
+
|
|
1094
|
+
if (!enableSchedulerTracing) {
|
|
1095
|
+
return callback;
|
|
1096
|
+
}
|
|
1097
|
+
|
|
1098
|
+
var wrappedInteractions = interactionsRef.current;
|
|
1099
|
+
|
|
1100
|
+
var subscriber = subscriberRef.current;
|
|
1101
|
+
if (subscriber !== null) {
|
|
1102
|
+
subscriber.onWorkScheduled(wrappedInteractions, threadID);
|
|
1103
|
+
}
|
|
1104
|
+
|
|
1105
|
+
// Update the pending async work count for the current interactions.
|
|
1106
|
+
// Update after calling subscribers in case of error.
|
|
1107
|
+
wrappedInteractions.forEach(function (interaction) {
|
|
1108
|
+
interaction.__count++;
|
|
1109
|
+
});
|
|
1110
|
+
|
|
1111
|
+
var hasRun = false;
|
|
1112
|
+
|
|
1113
|
+
function wrapped() {
|
|
1114
|
+
var prevInteractions = interactionsRef.current;
|
|
1115
|
+
interactionsRef.current = wrappedInteractions;
|
|
1116
|
+
|
|
1117
|
+
subscriber = subscriberRef.current;
|
|
1118
|
+
|
|
1119
|
+
try {
|
|
1120
|
+
var returnValue = void 0;
|
|
1121
|
+
|
|
1122
|
+
try {
|
|
1123
|
+
if (subscriber !== null) {
|
|
1124
|
+
subscriber.onWorkStarted(wrappedInteractions, threadID);
|
|
1125
|
+
}
|
|
1126
|
+
} finally {
|
|
1127
|
+
try {
|
|
1128
|
+
returnValue = callback.apply(undefined, arguments);
|
|
1129
|
+
} finally {
|
|
1130
|
+
interactionsRef.current = prevInteractions;
|
|
1131
|
+
|
|
1132
|
+
if (subscriber !== null) {
|
|
1133
|
+
subscriber.onWorkStopped(wrappedInteractions, threadID);
|
|
1134
|
+
}
|
|
1135
|
+
}
|
|
1136
|
+
}
|
|
1137
|
+
|
|
1138
|
+
return returnValue;
|
|
1139
|
+
} finally {
|
|
1140
|
+
if (!hasRun) {
|
|
1141
|
+
// We only expect a wrapped function to be executed once,
|
|
1142
|
+
// But in the event that it's executed more than once–
|
|
1143
|
+
// Only decrement the outstanding interaction counts once.
|
|
1144
|
+
hasRun = true;
|
|
1145
|
+
|
|
1146
|
+
// Update pending async counts for all wrapped interactions.
|
|
1147
|
+
// If this was the last scheduled async work for any of them,
|
|
1148
|
+
// Mark them as completed.
|
|
1149
|
+
wrappedInteractions.forEach(function (interaction) {
|
|
1150
|
+
interaction.__count--;
|
|
1151
|
+
|
|
1152
|
+
if (subscriber !== null && interaction.__count === 0) {
|
|
1153
|
+
subscriber.onInteractionScheduledWorkCompleted(interaction);
|
|
1154
|
+
}
|
|
1155
|
+
});
|
|
1156
|
+
}
|
|
1157
|
+
}
|
|
1158
|
+
}
|
|
1159
|
+
|
|
1160
|
+
wrapped.cancel = function cancel() {
|
|
1161
|
+
subscriber = subscriberRef.current;
|
|
1162
|
+
|
|
1163
|
+
try {
|
|
1164
|
+
if (subscriber !== null) {
|
|
1165
|
+
subscriber.onWorkCanceled(wrappedInteractions, threadID);
|
|
1166
|
+
}
|
|
1167
|
+
} finally {
|
|
1168
|
+
// Update pending async counts for all wrapped interactions.
|
|
1169
|
+
// If this was the last scheduled async work for any of them,
|
|
1170
|
+
// Mark them as completed.
|
|
1171
|
+
wrappedInteractions.forEach(function (interaction) {
|
|
1172
|
+
interaction.__count--;
|
|
1173
|
+
|
|
1174
|
+
if (subscriber && interaction.__count === 0) {
|
|
1175
|
+
subscriber.onInteractionScheduledWorkCompleted(interaction);
|
|
1176
|
+
}
|
|
1177
|
+
});
|
|
1178
|
+
}
|
|
1179
|
+
};
|
|
1180
|
+
|
|
1181
|
+
return wrapped;
|
|
1182
|
+
}
|
|
1183
|
+
|
|
1184
|
+
var subscribers = null;
|
|
1185
|
+
if (enableSchedulerTracing) {
|
|
1186
|
+
subscribers = new Set();
|
|
1187
|
+
}
|
|
1188
|
+
|
|
1189
|
+
function unstable_subscribe(subscriber) {
|
|
1190
|
+
if (enableSchedulerTracing) {
|
|
1191
|
+
subscribers.add(subscriber);
|
|
1192
|
+
|
|
1193
|
+
if (subscribers.size === 1) {
|
|
1194
|
+
subscriberRef.current = {
|
|
1195
|
+
onInteractionScheduledWorkCompleted: onInteractionScheduledWorkCompleted,
|
|
1196
|
+
onInteractionTraced: onInteractionTraced,
|
|
1197
|
+
onWorkCanceled: onWorkCanceled,
|
|
1198
|
+
onWorkScheduled: onWorkScheduled,
|
|
1199
|
+
onWorkStarted: onWorkStarted,
|
|
1200
|
+
onWorkStopped: onWorkStopped
|
|
1201
|
+
};
|
|
1202
|
+
}
|
|
1203
|
+
}
|
|
1204
|
+
}
|
|
1205
|
+
|
|
1206
|
+
function unstable_unsubscribe(subscriber) {
|
|
1207
|
+
if (enableSchedulerTracing) {
|
|
1208
|
+
subscribers.delete(subscriber);
|
|
1209
|
+
|
|
1210
|
+
if (subscribers.size === 0) {
|
|
1211
|
+
subscriberRef.current = null;
|
|
1212
|
+
}
|
|
1213
|
+
}
|
|
1214
|
+
}
|
|
1215
|
+
|
|
1216
|
+
function onInteractionTraced(interaction) {
|
|
1217
|
+
var didCatchError = false;
|
|
1218
|
+
var caughtError = null;
|
|
1219
|
+
|
|
1220
|
+
subscribers.forEach(function (subscriber) {
|
|
1221
|
+
try {
|
|
1222
|
+
subscriber.onInteractionTraced(interaction);
|
|
1223
|
+
} catch (error) {
|
|
1224
|
+
if (!didCatchError) {
|
|
1225
|
+
didCatchError = true;
|
|
1226
|
+
caughtError = error;
|
|
1227
|
+
}
|
|
1228
|
+
}
|
|
1229
|
+
});
|
|
1230
|
+
|
|
1231
|
+
if (didCatchError) {
|
|
1232
|
+
throw caughtError;
|
|
1233
|
+
}
|
|
1234
|
+
}
|
|
1235
|
+
|
|
1236
|
+
function onInteractionScheduledWorkCompleted(interaction) {
|
|
1237
|
+
var didCatchError = false;
|
|
1238
|
+
var caughtError = null;
|
|
1239
|
+
|
|
1240
|
+
subscribers.forEach(function (subscriber) {
|
|
1241
|
+
try {
|
|
1242
|
+
subscriber.onInteractionScheduledWorkCompleted(interaction);
|
|
1243
|
+
} catch (error) {
|
|
1244
|
+
if (!didCatchError) {
|
|
1245
|
+
didCatchError = true;
|
|
1246
|
+
caughtError = error;
|
|
1247
|
+
}
|
|
1248
|
+
}
|
|
1249
|
+
});
|
|
1250
|
+
|
|
1251
|
+
if (didCatchError) {
|
|
1252
|
+
throw caughtError;
|
|
1253
|
+
}
|
|
1254
|
+
}
|
|
1255
|
+
|
|
1256
|
+
function onWorkScheduled(interactions, threadID) {
|
|
1257
|
+
var didCatchError = false;
|
|
1258
|
+
var caughtError = null;
|
|
1259
|
+
|
|
1260
|
+
subscribers.forEach(function (subscriber) {
|
|
1261
|
+
try {
|
|
1262
|
+
subscriber.onWorkScheduled(interactions, threadID);
|
|
1263
|
+
} catch (error) {
|
|
1264
|
+
if (!didCatchError) {
|
|
1265
|
+
didCatchError = true;
|
|
1266
|
+
caughtError = error;
|
|
1267
|
+
}
|
|
1268
|
+
}
|
|
1269
|
+
});
|
|
1270
|
+
|
|
1271
|
+
if (didCatchError) {
|
|
1272
|
+
throw caughtError;
|
|
1273
|
+
}
|
|
1274
|
+
}
|
|
1275
|
+
|
|
1276
|
+
function onWorkStarted(interactions, threadID) {
|
|
1277
|
+
var didCatchError = false;
|
|
1278
|
+
var caughtError = null;
|
|
1279
|
+
|
|
1280
|
+
subscribers.forEach(function (subscriber) {
|
|
1281
|
+
try {
|
|
1282
|
+
subscriber.onWorkStarted(interactions, threadID);
|
|
1283
|
+
} catch (error) {
|
|
1284
|
+
if (!didCatchError) {
|
|
1285
|
+
didCatchError = true;
|
|
1286
|
+
caughtError = error;
|
|
560
1287
|
}
|
|
561
|
-
});
|
|
562
|
-
};
|
|
563
|
-
for (var fnName in deprecatedAPIs) {
|
|
564
|
-
if (deprecatedAPIs.hasOwnProperty(fnName)) {
|
|
565
|
-
defineDeprecationWarning(fnName, deprecatedAPIs[fnName]);
|
|
566
1288
|
}
|
|
1289
|
+
});
|
|
1290
|
+
|
|
1291
|
+
if (didCatchError) {
|
|
1292
|
+
throw caughtError;
|
|
567
1293
|
}
|
|
568
1294
|
}
|
|
569
1295
|
|
|
570
|
-
function
|
|
571
|
-
|
|
1296
|
+
function onWorkStopped(interactions, threadID) {
|
|
1297
|
+
var didCatchError = false;
|
|
1298
|
+
var caughtError = null;
|
|
572
1299
|
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
1300
|
+
subscribers.forEach(function (subscriber) {
|
|
1301
|
+
try {
|
|
1302
|
+
subscriber.onWorkStopped(interactions, threadID);
|
|
1303
|
+
} catch (error) {
|
|
1304
|
+
if (!didCatchError) {
|
|
1305
|
+
didCatchError = true;
|
|
1306
|
+
caughtError = error;
|
|
1307
|
+
}
|
|
1308
|
+
}
|
|
1309
|
+
});
|
|
1310
|
+
|
|
1311
|
+
if (didCatchError) {
|
|
1312
|
+
throw caughtError;
|
|
1313
|
+
}
|
|
581
1314
|
}
|
|
582
1315
|
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
objectAssign(pureComponentPrototype, Component.prototype);
|
|
587
|
-
pureComponentPrototype.isPureReactComponent = true;
|
|
1316
|
+
function onWorkCanceled(interactions, threadID) {
|
|
1317
|
+
var didCatchError = false;
|
|
1318
|
+
var caughtError = null;
|
|
588
1319
|
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
1320
|
+
subscribers.forEach(function (subscriber) {
|
|
1321
|
+
try {
|
|
1322
|
+
subscriber.onWorkCanceled(interactions, threadID);
|
|
1323
|
+
} catch (error) {
|
|
1324
|
+
if (!didCatchError) {
|
|
1325
|
+
didCatchError = true;
|
|
1326
|
+
caughtError = error;
|
|
1327
|
+
}
|
|
1328
|
+
}
|
|
1329
|
+
});
|
|
1330
|
+
|
|
1331
|
+
if (didCatchError) {
|
|
1332
|
+
throw caughtError;
|
|
596
1333
|
}
|
|
597
|
-
return refObject;
|
|
598
1334
|
}
|
|
599
1335
|
|
|
600
1336
|
/**
|
|
@@ -608,9 +1344,203 @@ var ReactCurrentOwner = {
|
|
|
608
1344
|
* @internal
|
|
609
1345
|
* @type {ReactComponent}
|
|
610
1346
|
*/
|
|
611
|
-
current: null
|
|
1347
|
+
current: null,
|
|
1348
|
+
currentDispatcher: null
|
|
1349
|
+
};
|
|
1350
|
+
|
|
1351
|
+
var BEFORE_SLASH_RE = /^(.*)[\\\/]/;
|
|
1352
|
+
|
|
1353
|
+
var describeComponentFrame = function (name, source, ownerName) {
|
|
1354
|
+
var sourceInfo = '';
|
|
1355
|
+
if (source) {
|
|
1356
|
+
var path = source.fileName;
|
|
1357
|
+
var fileName = path.replace(BEFORE_SLASH_RE, '');
|
|
1358
|
+
{
|
|
1359
|
+
// In DEV, include code for a common special case:
|
|
1360
|
+
// prefer "folder/index.js" instead of just "index.js".
|
|
1361
|
+
if (/^index\./.test(fileName)) {
|
|
1362
|
+
var match = path.match(BEFORE_SLASH_RE);
|
|
1363
|
+
if (match) {
|
|
1364
|
+
var pathBeforeSlash = match[1];
|
|
1365
|
+
if (pathBeforeSlash) {
|
|
1366
|
+
var folderName = pathBeforeSlash.replace(BEFORE_SLASH_RE, '');
|
|
1367
|
+
fileName = folderName + '/' + fileName;
|
|
1368
|
+
}
|
|
1369
|
+
}
|
|
1370
|
+
}
|
|
1371
|
+
}
|
|
1372
|
+
sourceInfo = ' (at ' + fileName + ':' + source.lineNumber + ')';
|
|
1373
|
+
} else if (ownerName) {
|
|
1374
|
+
sourceInfo = ' (created by ' + ownerName + ')';
|
|
1375
|
+
}
|
|
1376
|
+
return '\n in ' + (name || 'Unknown') + sourceInfo;
|
|
1377
|
+
};
|
|
1378
|
+
|
|
1379
|
+
var Resolved = 1;
|
|
1380
|
+
|
|
1381
|
+
|
|
1382
|
+
|
|
1383
|
+
|
|
1384
|
+
function refineResolvedThenable(thenable) {
|
|
1385
|
+
return thenable._reactStatus === Resolved ? thenable._reactResult : null;
|
|
1386
|
+
}
|
|
1387
|
+
|
|
1388
|
+
function getComponentName(type) {
|
|
1389
|
+
if (type == null) {
|
|
1390
|
+
// Host root, text node or just invalid type.
|
|
1391
|
+
return null;
|
|
1392
|
+
}
|
|
1393
|
+
{
|
|
1394
|
+
if (typeof type.tag === 'number') {
|
|
1395
|
+
warningWithoutStack$1(false, 'Received an unexpected object in getComponentName(). ' + 'This is likely a bug in React. Please file an issue.');
|
|
1396
|
+
}
|
|
1397
|
+
}
|
|
1398
|
+
if (typeof type === 'function') {
|
|
1399
|
+
return type.displayName || type.name || null;
|
|
1400
|
+
}
|
|
1401
|
+
if (typeof type === 'string') {
|
|
1402
|
+
return type;
|
|
1403
|
+
}
|
|
1404
|
+
switch (type) {
|
|
1405
|
+
case REACT_ASYNC_MODE_TYPE:
|
|
1406
|
+
return 'AsyncMode';
|
|
1407
|
+
case REACT_FRAGMENT_TYPE:
|
|
1408
|
+
return 'Fragment';
|
|
1409
|
+
case REACT_PORTAL_TYPE:
|
|
1410
|
+
return 'Portal';
|
|
1411
|
+
case REACT_PROFILER_TYPE:
|
|
1412
|
+
return 'Profiler';
|
|
1413
|
+
case REACT_STRICT_MODE_TYPE:
|
|
1414
|
+
return 'StrictMode';
|
|
1415
|
+
case REACT_PLACEHOLDER_TYPE:
|
|
1416
|
+
return 'Placeholder';
|
|
1417
|
+
}
|
|
1418
|
+
if (typeof type === 'object') {
|
|
1419
|
+
switch (type.$$typeof) {
|
|
1420
|
+
case REACT_CONTEXT_TYPE:
|
|
1421
|
+
return 'Context.Consumer';
|
|
1422
|
+
case REACT_PROVIDER_TYPE:
|
|
1423
|
+
return 'Context.Provider';
|
|
1424
|
+
case REACT_FORWARD_REF_TYPE:
|
|
1425
|
+
var renderFn = type.render;
|
|
1426
|
+
var functionName = renderFn.displayName || renderFn.name || '';
|
|
1427
|
+
return type.displayName || (functionName !== '' ? 'ForwardRef(' + functionName + ')' : 'ForwardRef');
|
|
1428
|
+
}
|
|
1429
|
+
if (typeof type.then === 'function') {
|
|
1430
|
+
var thenable = type;
|
|
1431
|
+
var resolvedThenable = refineResolvedThenable(thenable);
|
|
1432
|
+
if (resolvedThenable) {
|
|
1433
|
+
return getComponentName(resolvedThenable);
|
|
1434
|
+
}
|
|
1435
|
+
}
|
|
1436
|
+
}
|
|
1437
|
+
return null;
|
|
1438
|
+
}
|
|
1439
|
+
|
|
1440
|
+
var ReactDebugCurrentFrame = {};
|
|
1441
|
+
|
|
1442
|
+
var currentlyValidatingElement = null;
|
|
1443
|
+
|
|
1444
|
+
function setCurrentlyValidatingElement(element) {
|
|
1445
|
+
{
|
|
1446
|
+
currentlyValidatingElement = element;
|
|
1447
|
+
}
|
|
1448
|
+
}
|
|
1449
|
+
|
|
1450
|
+
{
|
|
1451
|
+
// Stack implementation injected by the current renderer.
|
|
1452
|
+
ReactDebugCurrentFrame.getCurrentStack = null;
|
|
1453
|
+
|
|
1454
|
+
ReactDebugCurrentFrame.getStackAddendum = function () {
|
|
1455
|
+
var stack = '';
|
|
1456
|
+
|
|
1457
|
+
// Add an extra top frame while an element is being validated
|
|
1458
|
+
if (currentlyValidatingElement) {
|
|
1459
|
+
var name = getComponentName(currentlyValidatingElement.type);
|
|
1460
|
+
var owner = currentlyValidatingElement._owner;
|
|
1461
|
+
stack += describeComponentFrame(name, currentlyValidatingElement._source, owner && getComponentName(owner.type));
|
|
1462
|
+
}
|
|
1463
|
+
|
|
1464
|
+
// Delegate to the injected renderer-specific implementation
|
|
1465
|
+
var impl = ReactDebugCurrentFrame.getCurrentStack;
|
|
1466
|
+
if (impl) {
|
|
1467
|
+
stack += impl() || '';
|
|
1468
|
+
}
|
|
1469
|
+
|
|
1470
|
+
return stack;
|
|
1471
|
+
};
|
|
1472
|
+
}
|
|
1473
|
+
|
|
1474
|
+
var ReactSharedInternals = {
|
|
1475
|
+
ReactCurrentOwner: ReactCurrentOwner,
|
|
1476
|
+
// Used by renderers to avoid bundling object-assign twice in UMD bundles:
|
|
1477
|
+
assign: objectAssign
|
|
612
1478
|
};
|
|
613
1479
|
|
|
1480
|
+
{
|
|
1481
|
+
// Re-export the schedule API(s) for UMD bundles.
|
|
1482
|
+
// This avoids introducing a dependency on a new UMD global in a minor update,
|
|
1483
|
+
// Since that would be a breaking change (e.g. for all existing CodeSandboxes).
|
|
1484
|
+
// This re-export is only required for UMD bundles;
|
|
1485
|
+
// CJS bundles use the shared NPM package.
|
|
1486
|
+
objectAssign(ReactSharedInternals, {
|
|
1487
|
+
Schedule: {
|
|
1488
|
+
unstable_cancelScheduledWork: unstable_cancelScheduledWork,
|
|
1489
|
+
unstable_now: getCurrentTime,
|
|
1490
|
+
unstable_scheduleWork: unstable_scheduleWork
|
|
1491
|
+
},
|
|
1492
|
+
ScheduleTracing: {
|
|
1493
|
+
__interactionsRef: interactionsRef,
|
|
1494
|
+
__subscriberRef: subscriberRef,
|
|
1495
|
+
unstable_clear: unstable_clear,
|
|
1496
|
+
unstable_getCurrent: unstable_getCurrent,
|
|
1497
|
+
unstable_getThreadID: unstable_getThreadID,
|
|
1498
|
+
unstable_subscribe: unstable_subscribe,
|
|
1499
|
+
unstable_trace: unstable_trace,
|
|
1500
|
+
unstable_unsubscribe: unstable_unsubscribe,
|
|
1501
|
+
unstable_wrap: unstable_wrap
|
|
1502
|
+
}
|
|
1503
|
+
});
|
|
1504
|
+
}
|
|
1505
|
+
|
|
1506
|
+
{
|
|
1507
|
+
objectAssign(ReactSharedInternals, {
|
|
1508
|
+
// These should not be included in production.
|
|
1509
|
+
ReactDebugCurrentFrame: ReactDebugCurrentFrame,
|
|
1510
|
+
// Shim for React DOM 16.0.0 which still destructured (but not used) this.
|
|
1511
|
+
// TODO: remove in React 17.0.
|
|
1512
|
+
ReactComponentTreeHook: {}
|
|
1513
|
+
});
|
|
1514
|
+
}
|
|
1515
|
+
|
|
1516
|
+
/**
|
|
1517
|
+
* Similar to invariant but only logs a warning if the condition is not met.
|
|
1518
|
+
* This can be used to log issues in development environments in critical
|
|
1519
|
+
* paths. Removing the logging code for production environments will keep the
|
|
1520
|
+
* same logic and follow the same code paths.
|
|
1521
|
+
*/
|
|
1522
|
+
|
|
1523
|
+
var warning = warningWithoutStack$1;
|
|
1524
|
+
|
|
1525
|
+
{
|
|
1526
|
+
warning = function (condition, format) {
|
|
1527
|
+
if (condition) {
|
|
1528
|
+
return;
|
|
1529
|
+
}
|
|
1530
|
+
var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
|
|
1531
|
+
var stack = ReactDebugCurrentFrame.getStackAddendum();
|
|
1532
|
+
// eslint-disable-next-line react-internal/warning-and-invariant-args
|
|
1533
|
+
|
|
1534
|
+
for (var _len = arguments.length, args = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
|
|
1535
|
+
args[_key - 2] = arguments[_key];
|
|
1536
|
+
}
|
|
1537
|
+
|
|
1538
|
+
warningWithoutStack$1.apply(undefined, [false, format + '%s'].concat(args, [stack]));
|
|
1539
|
+
};
|
|
1540
|
+
}
|
|
1541
|
+
|
|
1542
|
+
var warning$1 = warning;
|
|
1543
|
+
|
|
614
1544
|
var hasOwnProperty$1 = Object.prototype.hasOwnProperty;
|
|
615
1545
|
|
|
616
1546
|
var RESERVED_PROPS = {
|
|
@@ -651,7 +1581,7 @@ function defineKeyPropWarningGetter(props, displayName) {
|
|
|
651
1581
|
var warnAboutAccessingKey = function () {
|
|
652
1582
|
if (!specialPropKeyWarningShown) {
|
|
653
1583
|
specialPropKeyWarningShown = true;
|
|
654
|
-
|
|
1584
|
+
warningWithoutStack$1(false, '%s: `key` is not a prop. Trying to access it will result ' + 'in `undefined` being returned. If you need to access the same ' + 'value within the child component, you should pass it as a different ' + 'prop. (https://fb.me/react-special-props)', displayName);
|
|
655
1585
|
}
|
|
656
1586
|
};
|
|
657
1587
|
warnAboutAccessingKey.isReactWarning = true;
|
|
@@ -665,7 +1595,7 @@ function defineRefPropWarningGetter(props, displayName) {
|
|
|
665
1595
|
var warnAboutAccessingRef = function () {
|
|
666
1596
|
if (!specialPropRefWarningShown) {
|
|
667
1597
|
specialPropRefWarningShown = true;
|
|
668
|
-
|
|
1598
|
+
warningWithoutStack$1(false, '%s: `ref` is not a prop. Trying to access it will result ' + 'in `undefined` being returned. If you need to access the same ' + 'value within the child component, you should pass it as a different ' + 'prop. (https://fb.me/react-special-props)', displayName);
|
|
669
1599
|
}
|
|
670
1600
|
};
|
|
671
1601
|
warnAboutAccessingRef.isReactWarning = true;
|
|
@@ -813,14 +1743,12 @@ function createElement(type, config, children) {
|
|
|
813
1743
|
}
|
|
814
1744
|
{
|
|
815
1745
|
if (key || ref) {
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
defineRefPropWarningGetter(props, displayName);
|
|
823
|
-
}
|
|
1746
|
+
var displayName = typeof type === 'function' ? type.displayName || type.name || 'Unknown' : type;
|
|
1747
|
+
if (key) {
|
|
1748
|
+
defineKeyPropWarningGetter(props, displayName);
|
|
1749
|
+
}
|
|
1750
|
+
if (ref) {
|
|
1751
|
+
defineRefPropWarningGetter(props, displayName);
|
|
824
1752
|
}
|
|
825
1753
|
}
|
|
826
1754
|
}
|
|
@@ -844,7 +1772,7 @@ function cloneAndReplaceKey(oldElement, newKey) {
|
|
|
844
1772
|
* See https://reactjs.org/docs/react-api.html#cloneelement
|
|
845
1773
|
*/
|
|
846
1774
|
function cloneElement(element, config, children) {
|
|
847
|
-
!!(element === null || element === undefined) ?
|
|
1775
|
+
!!(element === null || element === undefined) ? invariant(false, 'React.cloneElement(...): The argument must be a React element, but you passed %s.', element) : void 0;
|
|
848
1776
|
|
|
849
1777
|
var propName = void 0;
|
|
850
1778
|
|
|
@@ -911,28 +1839,13 @@ function cloneElement(element, config, children) {
|
|
|
911
1839
|
* Verifies the object is a ReactElement.
|
|
912
1840
|
* See https://reactjs.org/docs/react-api.html#isvalidelement
|
|
913
1841
|
* @param {?object} object
|
|
914
|
-
* @return {boolean} True if `object` is a
|
|
1842
|
+
* @return {boolean} True if `object` is a ReactElement.
|
|
915
1843
|
* @final
|
|
916
1844
|
*/
|
|
917
1845
|
function isValidElement(object) {
|
|
918
1846
|
return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
|
|
919
1847
|
}
|
|
920
1848
|
|
|
921
|
-
var ReactDebugCurrentFrame = {};
|
|
922
|
-
|
|
923
|
-
{
|
|
924
|
-
// Component that is being worked on
|
|
925
|
-
ReactDebugCurrentFrame.getCurrentStack = null;
|
|
926
|
-
|
|
927
|
-
ReactDebugCurrentFrame.getStackAddendum = function () {
|
|
928
|
-
var impl = ReactDebugCurrentFrame.getCurrentStack;
|
|
929
|
-
if (impl) {
|
|
930
|
-
return impl();
|
|
931
|
-
}
|
|
932
|
-
return null;
|
|
933
|
-
};
|
|
934
|
-
}
|
|
935
|
-
|
|
936
1849
|
var SEPARATOR = '.';
|
|
937
1850
|
var SUBSEPARATOR = ':';
|
|
938
1851
|
|
|
@@ -1060,7 +1973,7 @@ function traverseAllChildrenImpl(children, nameSoFar, callback, traverseContext)
|
|
|
1060
1973
|
{
|
|
1061
1974
|
// Warn about using Maps as children
|
|
1062
1975
|
if (iteratorFn === children.entries) {
|
|
1063
|
-
!didWarnAboutMaps ?
|
|
1976
|
+
!didWarnAboutMaps ? warning$1(false, 'Using Maps as children is unsupported and will likely yield ' + 'unexpected results. Convert it to a sequence/iterable of keyed ' + 'ReactElements instead.') : void 0;
|
|
1064
1977
|
didWarnAboutMaps = true;
|
|
1065
1978
|
}
|
|
1066
1979
|
}
|
|
@@ -1079,7 +1992,7 @@ function traverseAllChildrenImpl(children, nameSoFar, callback, traverseContext)
|
|
|
1079
1992
|
addendum = ' If you meant to render a collection of children, use an array ' + 'instead.' + ReactDebugCurrentFrame.getStackAddendum();
|
|
1080
1993
|
}
|
|
1081
1994
|
var childrenString = '' + children;
|
|
1082
|
-
|
|
1995
|
+
invariant(false, 'Objects are not valid as a React child (found: %s).%s', childrenString === '[object Object]' ? 'object with keys {' + Object.keys(children).join(', ') + '}' : childrenString, addendum);
|
|
1083
1996
|
}
|
|
1084
1997
|
}
|
|
1085
1998
|
|
|
@@ -1165,7 +2078,9 @@ function mapSingleChildIntoContext(bookKeeping, child, childKey) {
|
|
|
1165
2078
|
|
|
1166
2079
|
var mappedChild = func.call(context, child, bookKeeping.count++);
|
|
1167
2080
|
if (Array.isArray(mappedChild)) {
|
|
1168
|
-
mapIntoWithKeyPrefixInternal(mappedChild, result, childKey,
|
|
2081
|
+
mapIntoWithKeyPrefixInternal(mappedChild, result, childKey, function (c) {
|
|
2082
|
+
return c;
|
|
2083
|
+
});
|
|
1169
2084
|
} else if (mappedChild != null) {
|
|
1170
2085
|
if (isValidElement(mappedChild)) {
|
|
1171
2086
|
mappedChild = cloneAndReplaceKey(mappedChild,
|
|
@@ -1219,7 +2134,9 @@ function mapChildren(children, func, context) {
|
|
|
1219
2134
|
* @return {number} The number of children.
|
|
1220
2135
|
*/
|
|
1221
2136
|
function countChildren(children) {
|
|
1222
|
-
return traverseAllChildren(children,
|
|
2137
|
+
return traverseAllChildren(children, function () {
|
|
2138
|
+
return null;
|
|
2139
|
+
}, null);
|
|
1223
2140
|
}
|
|
1224
2141
|
|
|
1225
2142
|
/**
|
|
@@ -1230,7 +2147,9 @@ function countChildren(children) {
|
|
|
1230
2147
|
*/
|
|
1231
2148
|
function toArray(children) {
|
|
1232
2149
|
var result = [];
|
|
1233
|
-
mapIntoWithKeyPrefixInternal(children, result, null,
|
|
2150
|
+
mapIntoWithKeyPrefixInternal(children, result, null, function (child) {
|
|
2151
|
+
return child;
|
|
2152
|
+
});
|
|
1234
2153
|
return result;
|
|
1235
2154
|
}
|
|
1236
2155
|
|
|
@@ -1249,35 +2168,39 @@ function toArray(children) {
|
|
|
1249
2168
|
* structure.
|
|
1250
2169
|
*/
|
|
1251
2170
|
function onlyChild(children) {
|
|
1252
|
-
!isValidElement(children) ?
|
|
2171
|
+
!isValidElement(children) ? invariant(false, 'React.Children.only expected to receive a single React element child.') : void 0;
|
|
1253
2172
|
return children;
|
|
1254
2173
|
}
|
|
1255
2174
|
|
|
2175
|
+
function readContext(context, observedBits) {
|
|
2176
|
+
var dispatcher = ReactCurrentOwner.currentDispatcher;
|
|
2177
|
+
!(dispatcher !== null) ? invariant(false, 'Context.unstable_read(): Context can only be read while React is rendering, e.g. inside the render method or getDerivedStateFromProps.') : void 0;
|
|
2178
|
+
return dispatcher.readContext(context, observedBits);
|
|
2179
|
+
}
|
|
2180
|
+
|
|
1256
2181
|
function createContext(defaultValue, calculateChangedBits) {
|
|
1257
2182
|
if (calculateChangedBits === undefined) {
|
|
1258
2183
|
calculateChangedBits = null;
|
|
1259
2184
|
} else {
|
|
1260
2185
|
{
|
|
1261
|
-
!(calculateChangedBits === null || typeof calculateChangedBits === 'function') ?
|
|
2186
|
+
!(calculateChangedBits === null || typeof calculateChangedBits === 'function') ? warningWithoutStack$1(false, 'createContext: Expected the optional second argument to be a ' + 'function. Instead received: %s', calculateChangedBits) : void 0;
|
|
1262
2187
|
}
|
|
1263
2188
|
}
|
|
1264
2189
|
|
|
1265
2190
|
var context = {
|
|
1266
2191
|
$$typeof: REACT_CONTEXT_TYPE,
|
|
1267
2192
|
_calculateChangedBits: calculateChangedBits,
|
|
1268
|
-
_defaultValue: defaultValue,
|
|
1269
|
-
_currentValue: defaultValue,
|
|
1270
2193
|
// As a workaround to support multiple concurrent renderers, we categorize
|
|
1271
2194
|
// some renderers as primary and others as secondary. We only expect
|
|
1272
2195
|
// there to be two concurrent renderers at most: React Native (primary) and
|
|
1273
2196
|
// Fabric (secondary); React DOM (primary) and React ART (secondary).
|
|
1274
2197
|
// Secondary renderers store their context values on separate fields.
|
|
2198
|
+
_currentValue: defaultValue,
|
|
1275
2199
|
_currentValue2: defaultValue,
|
|
1276
|
-
_changedBits: 0,
|
|
1277
|
-
_changedBits2: 0,
|
|
1278
2200
|
// These are circular
|
|
1279
2201
|
Provider: null,
|
|
1280
|
-
Consumer: null
|
|
2202
|
+
Consumer: null,
|
|
2203
|
+
unstable_read: null
|
|
1281
2204
|
};
|
|
1282
2205
|
|
|
1283
2206
|
context.Provider = {
|
|
@@ -1285,6 +2208,7 @@ function createContext(defaultValue, calculateChangedBits) {
|
|
|
1285
2208
|
_context: context
|
|
1286
2209
|
};
|
|
1287
2210
|
context.Consumer = context;
|
|
2211
|
+
context.unstable_read = readContext.bind(null, context);
|
|
1288
2212
|
|
|
1289
2213
|
{
|
|
1290
2214
|
context._currentRenderer = null;
|
|
@@ -1294,12 +2218,36 @@ function createContext(defaultValue, calculateChangedBits) {
|
|
|
1294
2218
|
return context;
|
|
1295
2219
|
}
|
|
1296
2220
|
|
|
2221
|
+
function lazy(ctor) {
|
|
2222
|
+
var thenable = null;
|
|
2223
|
+
return {
|
|
2224
|
+
then: function (resolve, reject) {
|
|
2225
|
+
if (thenable === null) {
|
|
2226
|
+
// Lazily create thenable by wrapping in an extra thenable.
|
|
2227
|
+
thenable = ctor();
|
|
2228
|
+
ctor = null;
|
|
2229
|
+
}
|
|
2230
|
+
return thenable.then(resolve, reject);
|
|
2231
|
+
},
|
|
2232
|
+
|
|
2233
|
+
// React uses these fields to store the result.
|
|
2234
|
+
_reactStatus: -1,
|
|
2235
|
+
_reactResult: null
|
|
2236
|
+
};
|
|
2237
|
+
}
|
|
2238
|
+
|
|
1297
2239
|
function forwardRef(render) {
|
|
1298
2240
|
{
|
|
1299
|
-
|
|
2241
|
+
if (typeof render !== 'function') {
|
|
2242
|
+
warningWithoutStack$1(false, 'forwardRef requires a render function but was given %s.', render === null ? 'null' : typeof render);
|
|
2243
|
+
} else {
|
|
2244
|
+
!(
|
|
2245
|
+
// Do not warn for 0 arguments because it could be due to usage of the 'arguments' object
|
|
2246
|
+
render.length === 0 || render.length === 2) ? warningWithoutStack$1(false, 'forwardRef render functions accept exactly two parameters: props and ref. %s', render.length === 1 ? 'Did you forget to use the ref parameter?' : 'Any additional parameter will be undefined.') : void 0;
|
|
2247
|
+
}
|
|
1300
2248
|
|
|
1301
2249
|
if (render != null) {
|
|
1302
|
-
!(render.defaultProps == null && render.propTypes == null) ?
|
|
2250
|
+
!(render.defaultProps == null && render.propTypes == null) ? warningWithoutStack$1(false, 'forwardRef render functions do not support propTypes or defaultProps. ' + 'Did you accidentally pass a React component?') : void 0;
|
|
1303
2251
|
}
|
|
1304
2252
|
}
|
|
1305
2253
|
|
|
@@ -1309,51 +2257,10 @@ function forwardRef(render) {
|
|
|
1309
2257
|
};
|
|
1310
2258
|
}
|
|
1311
2259
|
|
|
1312
|
-
var describeComponentFrame = function (name, source, ownerName) {
|
|
1313
|
-
return '\n in ' + (name || 'Unknown') + (source ? ' (at ' + source.fileName.replace(/^.*[\\\/]/, '') + ':' + source.lineNumber + ')' : ownerName ? ' (created by ' + ownerName + ')' : '');
|
|
1314
|
-
};
|
|
1315
|
-
|
|
1316
2260
|
function isValidElementType(type) {
|
|
1317
2261
|
return typeof type === 'string' || typeof type === 'function' ||
|
|
1318
2262
|
// Note: its typeof might be other than 'symbol' or 'number' if it's a polyfill.
|
|
1319
|
-
type === REACT_FRAGMENT_TYPE || type === REACT_ASYNC_MODE_TYPE || type === REACT_PROFILER_TYPE || type === REACT_STRICT_MODE_TYPE || type ===
|
|
1320
|
-
}
|
|
1321
|
-
|
|
1322
|
-
function getComponentName(fiber) {
|
|
1323
|
-
var type = fiber.type;
|
|
1324
|
-
|
|
1325
|
-
if (typeof type === 'function') {
|
|
1326
|
-
return type.displayName || type.name;
|
|
1327
|
-
}
|
|
1328
|
-
if (typeof type === 'string') {
|
|
1329
|
-
return type;
|
|
1330
|
-
}
|
|
1331
|
-
switch (type) {
|
|
1332
|
-
case REACT_ASYNC_MODE_TYPE:
|
|
1333
|
-
return 'AsyncMode';
|
|
1334
|
-
case REACT_CONTEXT_TYPE:
|
|
1335
|
-
return 'Context.Consumer';
|
|
1336
|
-
case REACT_FRAGMENT_TYPE:
|
|
1337
|
-
return 'ReactFragment';
|
|
1338
|
-
case REACT_PORTAL_TYPE:
|
|
1339
|
-
return 'ReactPortal';
|
|
1340
|
-
case REACT_PROFILER_TYPE:
|
|
1341
|
-
return 'Profiler(' + fiber.pendingProps.id + ')';
|
|
1342
|
-
case REACT_PROVIDER_TYPE:
|
|
1343
|
-
return 'Context.Provider';
|
|
1344
|
-
case REACT_STRICT_MODE_TYPE:
|
|
1345
|
-
return 'StrictMode';
|
|
1346
|
-
case REACT_TIMEOUT_TYPE:
|
|
1347
|
-
return 'Timeout';
|
|
1348
|
-
}
|
|
1349
|
-
if (typeof type === 'object' && type !== null) {
|
|
1350
|
-
switch (type.$$typeof) {
|
|
1351
|
-
case REACT_FORWARD_REF_TYPE:
|
|
1352
|
-
var functionName = type.render.displayName || type.render.name || '';
|
|
1353
|
-
return functionName !== '' ? 'ForwardRef(' + functionName + ')' : 'ForwardRef';
|
|
1354
|
-
}
|
|
1355
|
-
}
|
|
1356
|
-
return null;
|
|
2263
|
+
type === REACT_FRAGMENT_TYPE || type === REACT_ASYNC_MODE_TYPE || type === REACT_PROFILER_TYPE || type === REACT_STRICT_MODE_TYPE || type === REACT_PLACEHOLDER_TYPE || typeof type === 'object' && type !== null && (typeof type.then === 'function' || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE);
|
|
1357
2264
|
}
|
|
1358
2265
|
|
|
1359
2266
|
/**
|
|
@@ -1378,11 +2285,24 @@ var ReactPropTypesSecret_1 = ReactPropTypesSecret$1;
|
|
|
1378
2285
|
|
|
1379
2286
|
|
|
1380
2287
|
|
|
2288
|
+
var printWarning$1 = function() {};
|
|
2289
|
+
|
|
1381
2290
|
{
|
|
1382
|
-
var invariant$2 = invariant_1;
|
|
1383
|
-
var warning$2 = warning_1;
|
|
1384
2291
|
var ReactPropTypesSecret = ReactPropTypesSecret_1;
|
|
1385
2292
|
var loggedTypeFailures = {};
|
|
2293
|
+
|
|
2294
|
+
printWarning$1 = function(text) {
|
|
2295
|
+
var message = 'Warning: ' + text;
|
|
2296
|
+
if (typeof console !== 'undefined') {
|
|
2297
|
+
console.error(message);
|
|
2298
|
+
}
|
|
2299
|
+
try {
|
|
2300
|
+
// --- Welcome to debugging React ---
|
|
2301
|
+
// This error was thrown as a convenience so that you can use this stack
|
|
2302
|
+
// to find the callsite that caused this warning to fire.
|
|
2303
|
+
throw new Error(message);
|
|
2304
|
+
} catch (x) {}
|
|
2305
|
+
};
|
|
1386
2306
|
}
|
|
1387
2307
|
|
|
1388
2308
|
/**
|
|
@@ -1407,12 +2327,29 @@ function checkPropTypes(typeSpecs, values, location, componentName, getStack) {
|
|
|
1407
2327
|
try {
|
|
1408
2328
|
// This is intentionally an invariant that gets caught. It's the same
|
|
1409
2329
|
// behavior as without this statement except with a better message.
|
|
1410
|
-
|
|
2330
|
+
if (typeof typeSpecs[typeSpecName] !== 'function') {
|
|
2331
|
+
var err = Error(
|
|
2332
|
+
(componentName || 'React class') + ': ' + location + ' type `' + typeSpecName + '` is invalid; ' +
|
|
2333
|
+
'it must be a function, usually from the `prop-types` package, but received `' + typeof typeSpecs[typeSpecName] + '`.'
|
|
2334
|
+
);
|
|
2335
|
+
err.name = 'Invariant Violation';
|
|
2336
|
+
throw err;
|
|
2337
|
+
}
|
|
1411
2338
|
error = typeSpecs[typeSpecName](values, typeSpecName, componentName, location, null, ReactPropTypesSecret);
|
|
1412
2339
|
} catch (ex) {
|
|
1413
2340
|
error = ex;
|
|
1414
2341
|
}
|
|
1415
|
-
|
|
2342
|
+
if (error && !(error instanceof Error)) {
|
|
2343
|
+
printWarning$1(
|
|
2344
|
+
(componentName || 'React class') + ': type specification of ' +
|
|
2345
|
+
location + ' `' + typeSpecName + '` is invalid; the type checker ' +
|
|
2346
|
+
'function must return `null` or an `Error` but returned a ' + typeof error + '. ' +
|
|
2347
|
+
'You may have forgotten to pass an argument to the type checker ' +
|
|
2348
|
+
'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' +
|
|
2349
|
+
'shape all require an argument).'
|
|
2350
|
+
);
|
|
2351
|
+
|
|
2352
|
+
}
|
|
1416
2353
|
if (error instanceof Error && !(error.message in loggedTypeFailures)) {
|
|
1417
2354
|
// Only monitor this failure once because there tends to be a lot of the
|
|
1418
2355
|
// same error.
|
|
@@ -1420,7 +2357,9 @@ function checkPropTypes(typeSpecs, values, location, componentName, getStack) {
|
|
|
1420
2357
|
|
|
1421
2358
|
var stack = getStack ? getStack() : '';
|
|
1422
2359
|
|
|
1423
|
-
|
|
2360
|
+
printWarning$1(
|
|
2361
|
+
'Failed ' + location + ' type: ' + error.message + (stack != null ? stack : '')
|
|
2362
|
+
);
|
|
1424
2363
|
}
|
|
1425
2364
|
}
|
|
1426
2365
|
}
|
|
@@ -1436,52 +2375,15 @@ var checkPropTypes_1 = checkPropTypes;
|
|
|
1436
2375
|
* that support it.
|
|
1437
2376
|
*/
|
|
1438
2377
|
|
|
1439
|
-
var currentlyValidatingElement = void 0;
|
|
1440
2378
|
var propTypesMisspellWarningShown = void 0;
|
|
1441
2379
|
|
|
1442
|
-
var getDisplayName = function () {};
|
|
1443
|
-
var getStackAddendum = function () {};
|
|
1444
|
-
|
|
1445
2380
|
{
|
|
1446
|
-
currentlyValidatingElement = null;
|
|
1447
|
-
|
|
1448
2381
|
propTypesMisspellWarningShown = false;
|
|
1449
|
-
|
|
1450
|
-
getDisplayName = function (element) {
|
|
1451
|
-
if (element == null) {
|
|
1452
|
-
return '#empty';
|
|
1453
|
-
} else if (typeof element === 'string' || typeof element === 'number') {
|
|
1454
|
-
return '#text';
|
|
1455
|
-
} else if (typeof element.type === 'string') {
|
|
1456
|
-
return element.type;
|
|
1457
|
-
}
|
|
1458
|
-
|
|
1459
|
-
var type = element.type;
|
|
1460
|
-
if (type === REACT_FRAGMENT_TYPE) {
|
|
1461
|
-
return 'React.Fragment';
|
|
1462
|
-
} else if (typeof type === 'object' && type !== null && type.$$typeof === REACT_FORWARD_REF_TYPE) {
|
|
1463
|
-
var functionName = type.render.displayName || type.render.name || '';
|
|
1464
|
-
return functionName !== '' ? 'ForwardRef(' + functionName + ')' : 'ForwardRef';
|
|
1465
|
-
} else {
|
|
1466
|
-
return type.displayName || type.name || 'Unknown';
|
|
1467
|
-
}
|
|
1468
|
-
};
|
|
1469
|
-
|
|
1470
|
-
getStackAddendum = function () {
|
|
1471
|
-
var stack = '';
|
|
1472
|
-
if (currentlyValidatingElement) {
|
|
1473
|
-
var name = getDisplayName(currentlyValidatingElement);
|
|
1474
|
-
var owner = currentlyValidatingElement._owner;
|
|
1475
|
-
stack += describeComponentFrame(name, currentlyValidatingElement._source, owner && getComponentName(owner));
|
|
1476
|
-
}
|
|
1477
|
-
stack += ReactDebugCurrentFrame.getStackAddendum() || '';
|
|
1478
|
-
return stack;
|
|
1479
|
-
};
|
|
1480
2382
|
}
|
|
1481
2383
|
|
|
1482
2384
|
function getDeclarationErrorAddendum() {
|
|
1483
2385
|
if (ReactCurrentOwner.current) {
|
|
1484
|
-
var name = getComponentName(ReactCurrentOwner.current);
|
|
2386
|
+
var name = getComponentName(ReactCurrentOwner.current.type);
|
|
1485
2387
|
if (name) {
|
|
1486
2388
|
return '\n\nCheck the render method of `' + name + '`.';
|
|
1487
2389
|
}
|
|
@@ -1547,14 +2449,14 @@ function validateExplicitKey(element, parentType) {
|
|
|
1547
2449
|
var childOwner = '';
|
|
1548
2450
|
if (element && element._owner && element._owner !== ReactCurrentOwner.current) {
|
|
1549
2451
|
// Give the component that originally created this child.
|
|
1550
|
-
childOwner = ' It was passed a child from ' + getComponentName(element._owner) + '.';
|
|
2452
|
+
childOwner = ' It was passed a child from ' + getComponentName(element._owner.type) + '.';
|
|
1551
2453
|
}
|
|
1552
2454
|
|
|
1553
|
-
|
|
2455
|
+
setCurrentlyValidatingElement(element);
|
|
1554
2456
|
{
|
|
1555
|
-
|
|
2457
|
+
warning$1(false, 'Each child in an array or iterator should have a unique "key" prop.' + '%s%s See https://fb.me/react-warning-keys for more information.', currentComponentErrorInfo, childOwner);
|
|
1556
2458
|
}
|
|
1557
|
-
|
|
2459
|
+
setCurrentlyValidatingElement(null);
|
|
1558
2460
|
}
|
|
1559
2461
|
|
|
1560
2462
|
/**
|
|
@@ -1617,21 +2519,21 @@ function validatePropTypes(element) {
|
|
|
1617
2519
|
} else if (typeof type === 'object' && type !== null && type.$$typeof === REACT_FORWARD_REF_TYPE) {
|
|
1618
2520
|
// ForwardRef
|
|
1619
2521
|
var functionName = type.render.displayName || type.render.name || '';
|
|
1620
|
-
name = functionName !== '' ? 'ForwardRef(' + functionName + ')' : 'ForwardRef';
|
|
2522
|
+
name = type.displayName || (functionName !== '' ? 'ForwardRef(' + functionName + ')' : 'ForwardRef');
|
|
1621
2523
|
propTypes = type.propTypes;
|
|
1622
2524
|
} else {
|
|
1623
2525
|
return;
|
|
1624
2526
|
}
|
|
1625
2527
|
if (propTypes) {
|
|
1626
|
-
|
|
1627
|
-
checkPropTypes_1(propTypes, element.props, 'prop', name, getStackAddendum);
|
|
1628
|
-
|
|
2528
|
+
setCurrentlyValidatingElement(element);
|
|
2529
|
+
checkPropTypes_1(propTypes, element.props, 'prop', name, ReactDebugCurrentFrame.getStackAddendum);
|
|
2530
|
+
setCurrentlyValidatingElement(null);
|
|
1629
2531
|
} else if (type.PropTypes !== undefined && !propTypesMisspellWarningShown) {
|
|
1630
2532
|
propTypesMisspellWarningShown = true;
|
|
1631
|
-
|
|
2533
|
+
warningWithoutStack$1(false, 'Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?', name || 'Unknown');
|
|
1632
2534
|
}
|
|
1633
2535
|
if (typeof type.getDefaultProps === 'function') {
|
|
1634
|
-
!type.getDefaultProps.isReactClassApproved ?
|
|
2536
|
+
!type.getDefaultProps.isReactClassApproved ? warningWithoutStack$1(false, 'getDefaultProps is only used on classic React.createClass ' + 'definitions. Use a static property named `defaultProps` instead.') : void 0;
|
|
1635
2537
|
}
|
|
1636
2538
|
}
|
|
1637
2539
|
|
|
@@ -1640,22 +2542,22 @@ function validatePropTypes(element) {
|
|
|
1640
2542
|
* @param {ReactElement} fragment
|
|
1641
2543
|
*/
|
|
1642
2544
|
function validateFragmentProps(fragment) {
|
|
1643
|
-
|
|
2545
|
+
setCurrentlyValidatingElement(fragment);
|
|
1644
2546
|
|
|
1645
2547
|
var keys = Object.keys(fragment.props);
|
|
1646
2548
|
for (var i = 0; i < keys.length; i++) {
|
|
1647
2549
|
var key = keys[i];
|
|
1648
2550
|
if (key !== 'children' && key !== 'key') {
|
|
1649
|
-
|
|
2551
|
+
warning$1(false, 'Invalid prop `%s` supplied to `React.Fragment`. ' + 'React.Fragment can only have `key` and `children` props.', key);
|
|
1650
2552
|
break;
|
|
1651
2553
|
}
|
|
1652
2554
|
}
|
|
1653
2555
|
|
|
1654
2556
|
if (fragment.ref !== null) {
|
|
1655
|
-
|
|
2557
|
+
warning$1(false, 'Invalid attribute `ref` supplied to `React.Fragment`.');
|
|
1656
2558
|
}
|
|
1657
2559
|
|
|
1658
|
-
|
|
2560
|
+
setCurrentlyValidatingElement(null);
|
|
1659
2561
|
}
|
|
1660
2562
|
|
|
1661
2563
|
function createElementWithValidation(type, props, children) {
|
|
@@ -1676,18 +2578,19 @@ function createElementWithValidation(type, props, children) {
|
|
|
1676
2578
|
info += getDeclarationErrorAddendum();
|
|
1677
2579
|
}
|
|
1678
2580
|
|
|
1679
|
-
info += getStackAddendum() || '';
|
|
1680
|
-
|
|
1681
2581
|
var typeString = void 0;
|
|
1682
2582
|
if (type === null) {
|
|
1683
2583
|
typeString = 'null';
|
|
1684
2584
|
} else if (Array.isArray(type)) {
|
|
1685
2585
|
typeString = 'array';
|
|
2586
|
+
} else if (type !== undefined && type.$$typeof === REACT_ELEMENT_TYPE) {
|
|
2587
|
+
typeString = '<' + (getComponentName(type.type) || 'Unknown') + ' />';
|
|
2588
|
+
info = ' Did you accidentally export a JSX literal instead of a component?';
|
|
1686
2589
|
} else {
|
|
1687
2590
|
typeString = typeof type;
|
|
1688
2591
|
}
|
|
1689
2592
|
|
|
1690
|
-
|
|
2593
|
+
warning$1(false, 'React.createElement: type is invalid -- expected a string (for ' + 'built-in components) or a class/function (for composite ' + 'components) but got: %s.%s', typeString, info);
|
|
1691
2594
|
}
|
|
1692
2595
|
|
|
1693
2596
|
var element = createElement.apply(this, arguments);
|
|
@@ -1775,25 +2678,12 @@ var React = {
|
|
|
1775
2678
|
|
|
1776
2679
|
version: ReactVersion,
|
|
1777
2680
|
|
|
1778
|
-
__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED:
|
|
1779
|
-
ReactCurrentOwner: ReactCurrentOwner,
|
|
1780
|
-
// Used by renderers to avoid bundling object-assign twice in UMD bundles:
|
|
1781
|
-
assign: objectAssign
|
|
1782
|
-
}
|
|
2681
|
+
__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED: ReactSharedInternals
|
|
1783
2682
|
};
|
|
1784
2683
|
|
|
1785
2684
|
if (enableSuspense) {
|
|
1786
|
-
React.
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
{
|
|
1790
|
-
objectAssign(React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED, {
|
|
1791
|
-
// These should not be included in production.
|
|
1792
|
-
ReactDebugCurrentFrame: ReactDebugCurrentFrame,
|
|
1793
|
-
// Shim for React DOM 16.0.0 which still destructured (but not used) this.
|
|
1794
|
-
// TODO: remove in React 17.0.
|
|
1795
|
-
ReactComponentTreeHook: {}
|
|
1796
|
-
});
|
|
2685
|
+
React.Placeholder = REACT_PLACEHOLDER_TYPE;
|
|
2686
|
+
React.lazy = lazy;
|
|
1797
2687
|
}
|
|
1798
2688
|
|
|
1799
2689
|
|
|
@@ -1806,7 +2696,7 @@ var React$3 = ( React$2 && React ) || React$2;
|
|
|
1806
2696
|
|
|
1807
2697
|
// TODO: decide on the top-level export form.
|
|
1808
2698
|
// This is hacky but makes it work with both Rollup and Jest.
|
|
1809
|
-
var react = React$3.default
|
|
2699
|
+
var react = React$3.default || React$3;
|
|
1810
2700
|
|
|
1811
2701
|
return react;
|
|
1812
2702
|
|