react 16.9.0 → 16.11.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/build-info.json +4 -4
- package/cjs/react.development.js +413 -330
- package/cjs/react.production.min.js +16 -16
- package/package.json +1 -1
- package/umd/react.development.js +937 -739
- package/umd/react.production.min.js +26 -27
- package/umd/react.profiling.min.js +33 -31
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @license React v16.
|
|
1
|
+
/** @license React v16.11.0
|
|
2
2
|
* react.production.min.js
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
@@ -7,19 +7,19 @@
|
|
|
7
7
|
* LICENSE file in the root directory of this source tree.
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
'use strict';var h=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.forward_ref"):60112,y=n?Symbol.for("react.suspense"):60113
|
|
11
|
-
60115,
|
|
12
|
-
function
|
|
13
|
-
function
|
|
14
|
-
|
|
15
|
-
function M(a,b,
|
|
16
|
-
function
|
|
10
|
+
'use strict';var h=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.forward_ref"):60112,y=n?Symbol.for("react.suspense"):60113;n&&Symbol.for("react.suspense_list");
|
|
11
|
+
var z=n?Symbol.for("react.memo"):60115,aa=n?Symbol.for("react.lazy"):60116;n&&Symbol.for("react.fundamental");n&&Symbol.for("react.responder");n&&Symbol.for("react.scope");var A="function"===typeof Symbol&&Symbol.iterator;
|
|
12
|
+
function B(a){for(var b="https://reactjs.org/docs/error-decoder.html?invariant="+a,c=1;c<arguments.length;c++)b+="&args[]="+encodeURIComponent(arguments[c]);return"Minified React error #"+a+"; visit "+b+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var C={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},D={};
|
|
13
|
+
function E(a,b,c){this.props=a;this.context=b;this.refs=D;this.updater=c||C}E.prototype.isReactComponent={};E.prototype.setState=function(a,b){if("object"!==typeof a&&"function"!==typeof a&&null!=a)throw Error(B(85));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,c){this.props=a;this.context=b;this.refs=D;this.updater=c||C}var H=G.prototype=new F;
|
|
14
|
+
H.constructor=G;h(H,E.prototype);H.isPureReactComponent=!0;var I={current:null},J={current:null},K=Object.prototype.hasOwnProperty,L={key:!0,ref:!0,__self:!0,__source:!0};
|
|
15
|
+
function M(a,b,c){var e,d={},g=null,l=null;if(null!=b)for(e in void 0!==b.ref&&(l=b.ref),void 0!==b.key&&(g=""+b.key),b)K.call(b,e)&&!L.hasOwnProperty(e)&&(d[e]=b[e]);var f=arguments.length-2;if(1===f)d.children=c;else if(1<f){for(var k=Array(f),m=0;m<f;m++)k[m]=arguments[m+2];d.children=k}if(a&&a.defaultProps)for(e in f=a.defaultProps,f)void 0===d[e]&&(d[e]=f[e]);return{$$typeof:p,type:a,key:g,ref:l,props:d,_owner:J.current}}
|
|
16
|
+
function ba(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,c,e){if(P.length){var d=P.pop();d.result=a;d.keyPrefix=b;d.func=c;d.context=e;d.count=0;return d}return{result:a,keyPrefix:b,func:c,context:e,count:0}}
|
|
17
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,
|
|
19
|
-
0;!(
|
|
20
|
-
function
|
|
21
|
-
var X={Children:{map:function(a,b,
|
|
22
|
-
_currentValue:a,_currentValue2:a,_threadCount:0,Provider:null,Consumer:null};a.Provider={$$typeof:v,_context:a};return a.Consumer=a},forwardRef:function(a){return{$$typeof:x,render:a}},lazy:function(a){return{$$typeof:
|
|
23
|
-
b,
|
|
24
|
-
|
|
25
|
-
|
|
18
|
+
function S(a,b,c,e){var d=typeof a;if("undefined"===d||"boolean"===d)a=null;var g=!1;if(null===a)g=!0;else switch(d){case "string":case "number":g=!0;break;case "object":switch(a.$$typeof){case p:case q:g=!0}}if(g)return c(e,a,""===b?"."+T(a,0):b),1;g=0;b=""===b?".":b+":";if(Array.isArray(a))for(var l=0;l<a.length;l++){d=a[l];var f=b+T(d,l);g+=S(d,f,c,e)}else if(null===a||"object"!==typeof a?f=null:(f=A&&a[A]||a["@@iterator"],f="function"===typeof f?f:null),"function"===typeof f)for(a=f.call(a),l=
|
|
19
|
+
0;!(d=a.next()).done;)d=d.value,f=b+T(d,l++),g+=S(d,f,c,e);else if("object"===d)throw c=""+a,Error(B(31,"[object Object]"===c?"object with keys {"+Object.keys(a).join(", ")+"}":c,""));return g}function U(a,b,c){return null==a?0:S(a,"",b,c)}function T(a,b){return"object"===typeof a&&null!==a&&null!=a.key?escape(a.key):b.toString(36)}function ca(a,b){a.func.call(a.context,b,a.count++)}
|
|
20
|
+
function da(a,b,c){var e=a.result,d=a.keyPrefix;a=a.func.call(a.context,b,a.count++);Array.isArray(a)?V(a,e,c,function(a){return a}):null!=a&&(N(a)&&(a=ba(a,d+(!a.key||b&&b.key===a.key?"":(""+a.key).replace(O,"$&/")+"/")+c)),e.push(a))}function V(a,b,c,e,d){var g="";null!=c&&(g=(""+c).replace(O,"$&/")+"/");b=Q(b,g,e,d);U(a,da,b);R(b)}function W(){var a=I.current;if(null===a)throw Error(B(321));return a}
|
|
21
|
+
var X={Children:{map:function(a,b,c){if(null==a)return a;var e=[];V(a,e,null,b,c);return e},forEach:function(a,b,c){if(null==a)return a;b=Q(null,null,b,c);U(a,ca,b);R(b)},count:function(a){return U(a,function(){return null},null)},toArray:function(a){var b=[];V(a,b,null,function(a){return a});return b},only:function(a){if(!N(a))throw Error(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,_threadCount:0,Provider:null,Consumer:null};a.Provider={$$typeof:v,_context:a};return a.Consumer=a},forwardRef:function(a){return{$$typeof:x,render:a}},lazy:function(a){return{$$typeof:aa,_ctor:a,_status:-1,_result:null}},memo:function(a,b){return{$$typeof:z,type:a,compare:void 0===b?null:b}},useCallback:function(a,b){return W().useCallback(a,b)},useContext:function(a,b){return W().useContext(a,b)},useEffect:function(a,b){return W().useEffect(a,b)},useImperativeHandle:function(a,
|
|
23
|
+
b,c){return W().useImperativeHandle(a,b,c)},useDebugValue:function(){},useLayoutEffect:function(a,b){return W().useLayoutEffect(a,b)},useMemo:function(a,b){return W().useMemo(a,b)},useReducer:function(a,b,c){return W().useReducer(a,b,c)},useRef:function(a){return W().useRef(a)},useState:function(a){return W().useState(a)},Fragment:r,Profiler:u,StrictMode:t,Suspense:y,createElement:M,cloneElement:function(a,b,c){if(null===a||void 0===a)throw Error(B(267,a));var e=h({},a.props),d=a.key,g=a.ref,l=a._owner;
|
|
24
|
+
if(null!=b){void 0!==b.ref&&(g=b.ref,l=J.current);void 0!==b.key&&(d=""+b.key);if(a.type&&a.type.defaultProps)var f=a.type.defaultProps;for(k in b)K.call(b,k)&&!L.hasOwnProperty(k)&&(e[k]=void 0===b[k]&&void 0!==f?f[k]:b[k])}var k=arguments.length-2;if(1===k)e.children=c;else if(1<k){f=Array(k);for(var m=0;m<k;m++)f[m]=arguments[m+2];e.children=f}return{$$typeof:p,type:a.type,key:d,ref:g,props:e,_owner:l}},createFactory:function(a){var b=M.bind(null,a);b.type=a;return b},isValidElement:N,version:"16.11.0",
|
|
25
|
+
__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED:{ReactCurrentDispatcher:I,ReactCurrentBatchConfig:{suspense:null},ReactCurrentOwner:J,IsSomeRendererActing:{current:!1},assign:h}},Y={default:X},Z=Y&&X||Y;module.exports=Z.default||Z;
|
package/package.json
CHANGED
package/umd/react.development.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** @license React v16.
|
|
1
|
+
/** @license React v16.11.0
|
|
2
2
|
* react.development.js
|
|
3
3
|
*
|
|
4
4
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
@@ -17,22 +17,21 @@
|
|
|
17
17
|
|
|
18
18
|
// TODO: this is special because it gets imported during build.
|
|
19
19
|
|
|
20
|
-
var ReactVersion = '16.
|
|
20
|
+
var ReactVersion = '16.11.0';
|
|
21
21
|
|
|
22
22
|
// The Symbol used to tag the ReactElement-like types. If there is no native Symbol
|
|
23
23
|
// nor polyfill, then a plain number is used for performance.
|
|
24
24
|
var hasSymbol = typeof Symbol === 'function' && Symbol.for;
|
|
25
|
-
|
|
26
25
|
var REACT_ELEMENT_TYPE = hasSymbol ? Symbol.for('react.element') : 0xeac7;
|
|
27
26
|
var REACT_PORTAL_TYPE = hasSymbol ? Symbol.for('react.portal') : 0xeaca;
|
|
28
27
|
var REACT_FRAGMENT_TYPE = hasSymbol ? Symbol.for('react.fragment') : 0xeacb;
|
|
29
28
|
var REACT_STRICT_MODE_TYPE = hasSymbol ? Symbol.for('react.strict_mode') : 0xeacc;
|
|
30
29
|
var REACT_PROFILER_TYPE = hasSymbol ? Symbol.for('react.profiler') : 0xead2;
|
|
31
30
|
var REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for('react.provider') : 0xeacd;
|
|
32
|
-
var REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for('react.context') : 0xeace;
|
|
33
|
-
// TODO: We don't use AsyncMode or ConcurrentMode anymore. They were temporary
|
|
31
|
+
var REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for('react.context') : 0xeace; // TODO: We don't use AsyncMode or ConcurrentMode anymore. They were temporary
|
|
34
32
|
// (unstable) APIs that have been removed. Can we remove the symbols?
|
|
35
33
|
|
|
34
|
+
|
|
36
35
|
var REACT_CONCURRENT_MODE_TYPE = hasSymbol ? Symbol.for('react.concurrent_mode') : 0xeacf;
|
|
37
36
|
var REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for('react.forward_ref') : 0xead0;
|
|
38
37
|
var REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for('react.suspense') : 0xead1;
|
|
@@ -41,18 +40,20 @@ var REACT_MEMO_TYPE = hasSymbol ? Symbol.for('react.memo') : 0xead3;
|
|
|
41
40
|
var REACT_LAZY_TYPE = hasSymbol ? Symbol.for('react.lazy') : 0xead4;
|
|
42
41
|
var REACT_FUNDAMENTAL_TYPE = hasSymbol ? Symbol.for('react.fundamental') : 0xead5;
|
|
43
42
|
var REACT_RESPONDER_TYPE = hasSymbol ? Symbol.for('react.responder') : 0xead6;
|
|
44
|
-
|
|
43
|
+
var REACT_SCOPE_TYPE = hasSymbol ? Symbol.for('react.scope') : 0xead7;
|
|
45
44
|
var MAYBE_ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
|
|
46
45
|
var FAUX_ITERATOR_SYMBOL = '@@iterator';
|
|
47
|
-
|
|
48
46
|
function getIteratorFn(maybeIterable) {
|
|
49
47
|
if (maybeIterable === null || typeof maybeIterable !== 'object') {
|
|
50
48
|
return null;
|
|
51
49
|
}
|
|
50
|
+
|
|
52
51
|
var maybeIterator = MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL];
|
|
52
|
+
|
|
53
53
|
if (typeof maybeIterator === 'function') {
|
|
54
54
|
return maybeIterator;
|
|
55
55
|
}
|
|
56
|
+
|
|
56
57
|
return null;
|
|
57
58
|
}
|
|
58
59
|
|
|
@@ -148,17 +149,8 @@ var objectAssign = shouldUseNative() ? Object.assign : function (target, source)
|
|
|
148
149
|
};
|
|
149
150
|
|
|
150
151
|
// Do not require this module directly! Use normal `invariant` calls with
|
|
151
|
-
// template literal strings. The messages will be
|
|
152
|
-
// build
|
|
153
|
-
|
|
154
|
-
// Do not require this module directly! Use normal `invariant` calls with
|
|
155
|
-
// template literal strings. The messages will be converted to ReactError during
|
|
156
|
-
// build, and in production they will be minified.
|
|
157
|
-
|
|
158
|
-
function ReactError(error) {
|
|
159
|
-
error.name = 'Invariant Violation';
|
|
160
|
-
return error;
|
|
161
|
-
}
|
|
152
|
+
// template literal strings. The messages will be replaced with error codes
|
|
153
|
+
// during build.
|
|
162
154
|
|
|
163
155
|
/**
|
|
164
156
|
* Use invariant() to assert state which your program assumes to be true.
|
|
@@ -184,12 +176,11 @@ function ReactError(error) {
|
|
|
184
176
|
* paths. Removing the logging code for production environments will keep the
|
|
185
177
|
* same logic and follow the same code paths.
|
|
186
178
|
*/
|
|
187
|
-
|
|
188
|
-
var lowPriorityWarning = function () {};
|
|
179
|
+
var lowPriorityWarningWithoutStack = function () {};
|
|
189
180
|
|
|
190
181
|
{
|
|
191
182
|
var printWarning = function (format) {
|
|
192
|
-
for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
183
|
+
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
193
184
|
args[_key - 1] = arguments[_key];
|
|
194
185
|
}
|
|
195
186
|
|
|
@@ -197,9 +188,11 @@ var lowPriorityWarning = function () {};
|
|
|
197
188
|
var message = 'Warning: ' + format.replace(/%s/g, function () {
|
|
198
189
|
return args[argIndex++];
|
|
199
190
|
});
|
|
191
|
+
|
|
200
192
|
if (typeof console !== 'undefined') {
|
|
201
193
|
console.warn(message);
|
|
202
194
|
}
|
|
195
|
+
|
|
203
196
|
try {
|
|
204
197
|
// --- Welcome to debugging React ---
|
|
205
198
|
// This error was thrown as a convenience so that you can use this stack
|
|
@@ -208,21 +201,22 @@ var lowPriorityWarning = function () {};
|
|
|
208
201
|
} catch (x) {}
|
|
209
202
|
};
|
|
210
203
|
|
|
211
|
-
|
|
204
|
+
lowPriorityWarningWithoutStack = function (condition, format) {
|
|
212
205
|
if (format === undefined) {
|
|
213
|
-
throw new Error('`
|
|
206
|
+
throw new Error('`lowPriorityWarningWithoutStack(condition, format, ...args)` requires a warning ' + 'message argument');
|
|
214
207
|
}
|
|
208
|
+
|
|
215
209
|
if (!condition) {
|
|
216
|
-
for (var _len2 = arguments.length, args = Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
|
|
210
|
+
for (var _len2 = arguments.length, args = new Array(_len2 > 2 ? _len2 - 2 : 0), _key2 = 2; _key2 < _len2; _key2++) {
|
|
217
211
|
args[_key2 - 2] = arguments[_key2];
|
|
218
212
|
}
|
|
219
213
|
|
|
220
|
-
printWarning.apply(
|
|
214
|
+
printWarning.apply(void 0, [format].concat(args));
|
|
221
215
|
}
|
|
222
216
|
};
|
|
223
217
|
}
|
|
224
218
|
|
|
225
|
-
var
|
|
219
|
+
var lowPriorityWarningWithoutStack$1 = lowPriorityWarningWithoutStack;
|
|
226
220
|
|
|
227
221
|
/**
|
|
228
222
|
* Similar to invariant but only logs a warning if the condition is not met.
|
|
@@ -230,35 +224,37 @@ var lowPriorityWarning$1 = lowPriorityWarning;
|
|
|
230
224
|
* paths. Removing the logging code for production environments will keep the
|
|
231
225
|
* same logic and follow the same code paths.
|
|
232
226
|
*/
|
|
233
|
-
|
|
234
227
|
var warningWithoutStack = function () {};
|
|
235
228
|
|
|
236
229
|
{
|
|
237
230
|
warningWithoutStack = function (condition, format) {
|
|
238
|
-
for (var _len = arguments.length, args = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
|
|
231
|
+
for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
|
|
239
232
|
args[_key - 2] = arguments[_key];
|
|
240
233
|
}
|
|
241
234
|
|
|
242
235
|
if (format === undefined) {
|
|
243
236
|
throw new Error('`warningWithoutStack(condition, format, ...args)` requires a warning ' + 'message argument');
|
|
244
237
|
}
|
|
238
|
+
|
|
245
239
|
if (args.length > 8) {
|
|
246
240
|
// Check before the condition to catch violations early.
|
|
247
241
|
throw new Error('warningWithoutStack() currently supports at most 8 arguments.');
|
|
248
242
|
}
|
|
243
|
+
|
|
249
244
|
if (condition) {
|
|
250
245
|
return;
|
|
251
246
|
}
|
|
247
|
+
|
|
252
248
|
if (typeof console !== 'undefined') {
|
|
253
249
|
var argsWithFormat = args.map(function (item) {
|
|
254
250
|
return '' + item;
|
|
255
251
|
});
|
|
256
|
-
argsWithFormat.unshift('Warning: ' + format);
|
|
257
|
-
|
|
258
|
-
// We intentionally don't use spread (or .apply) directly because it
|
|
252
|
+
argsWithFormat.unshift('Warning: ' + format); // We intentionally don't use spread (or .apply) directly because it
|
|
259
253
|
// breaks IE9: https://github.com/facebook/react/issues/13610
|
|
254
|
+
|
|
260
255
|
Function.prototype.apply.call(console.error, console, argsWithFormat);
|
|
261
256
|
}
|
|
257
|
+
|
|
262
258
|
try {
|
|
263
259
|
// --- Welcome to debugging React ---
|
|
264
260
|
// This error was thrown as a convenience so that you can use this stack
|
|
@@ -280,18 +276,21 @@ function warnNoop(publicInstance, callerName) {
|
|
|
280
276
|
{
|
|
281
277
|
var _constructor = publicInstance.constructor;
|
|
282
278
|
var componentName = _constructor && (_constructor.displayName || _constructor.name) || 'ReactClass';
|
|
283
|
-
var warningKey = componentName +
|
|
279
|
+
var warningKey = componentName + "." + callerName;
|
|
280
|
+
|
|
284
281
|
if (didWarnStateUpdateForUnmountedComponent[warningKey]) {
|
|
285
282
|
return;
|
|
286
283
|
}
|
|
284
|
+
|
|
287
285
|
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);
|
|
288
286
|
didWarnStateUpdateForUnmountedComponent[warningKey] = true;
|
|
289
287
|
}
|
|
290
288
|
}
|
|
291
|
-
|
|
292
289
|
/**
|
|
293
290
|
* This is the abstract API for an update queue.
|
|
294
291
|
*/
|
|
292
|
+
|
|
293
|
+
|
|
295
294
|
var ReactNoopUpdateQueue = {
|
|
296
295
|
/**
|
|
297
296
|
* Checks whether or not this composite component is mounted.
|
|
@@ -358,25 +357,26 @@ var ReactNoopUpdateQueue = {
|
|
|
358
357
|
};
|
|
359
358
|
|
|
360
359
|
var emptyObject = {};
|
|
360
|
+
|
|
361
361
|
{
|
|
362
362
|
Object.freeze(emptyObject);
|
|
363
363
|
}
|
|
364
|
-
|
|
365
364
|
/**
|
|
366
365
|
* Base class helpers for the updating state of a component.
|
|
367
366
|
*/
|
|
367
|
+
|
|
368
|
+
|
|
368
369
|
function Component(props, context, updater) {
|
|
369
370
|
this.props = props;
|
|
370
|
-
this.context = context;
|
|
371
|
-
|
|
372
|
-
this.refs = emptyObject;
|
|
373
|
-
// We initialize the default updater but the real one gets injected by the
|
|
371
|
+
this.context = context; // If a component has string refs, we will assign a different object later.
|
|
372
|
+
|
|
373
|
+
this.refs = emptyObject; // We initialize the default updater but the real one gets injected by the
|
|
374
374
|
// renderer.
|
|
375
|
+
|
|
375
376
|
this.updater = updater || ReactNoopUpdateQueue;
|
|
376
377
|
}
|
|
377
378
|
|
|
378
379
|
Component.prototype.isReactComponent = {};
|
|
379
|
-
|
|
380
380
|
/**
|
|
381
381
|
* Sets a subset of the state. Always use this to mutate
|
|
382
382
|
* state. You should treat `this.state` as immutable.
|
|
@@ -402,17 +402,16 @@ Component.prototype.isReactComponent = {};
|
|
|
402
402
|
* @final
|
|
403
403
|
* @protected
|
|
404
404
|
*/
|
|
405
|
+
|
|
405
406
|
Component.prototype.setState = function (partialState, callback) {
|
|
406
|
-
(function
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
throw ReactError(Error('setState(...): takes an object of state variables to update or a function which returns an object of state variables.'));
|
|
410
|
-
}
|
|
407
|
+
if (!(typeof partialState === 'object' || typeof partialState === 'function' || partialState == null)) {
|
|
408
|
+
{
|
|
409
|
+
throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");
|
|
411
410
|
}
|
|
412
|
-
}
|
|
411
|
+
}
|
|
412
|
+
|
|
413
413
|
this.updater.enqueueSetState(this, partialState, callback, 'setState');
|
|
414
414
|
};
|
|
415
|
-
|
|
416
415
|
/**
|
|
417
416
|
* Forces an update. This should only be invoked when it is known with
|
|
418
417
|
* certainty that we are **not** in a DOM transaction.
|
|
@@ -427,28 +426,33 @@ Component.prototype.setState = function (partialState, callback) {
|
|
|
427
426
|
* @final
|
|
428
427
|
* @protected
|
|
429
428
|
*/
|
|
429
|
+
|
|
430
|
+
|
|
430
431
|
Component.prototype.forceUpdate = function (callback) {
|
|
431
432
|
this.updater.enqueueForceUpdate(this, callback, 'forceUpdate');
|
|
432
433
|
};
|
|
433
|
-
|
|
434
434
|
/**
|
|
435
435
|
* Deprecated APIs. These APIs used to exist on classic React classes but since
|
|
436
436
|
* we would like to deprecate them, we're not going to move them over to this
|
|
437
437
|
* modern base class. Instead, we define a getter that warns if it's accessed.
|
|
438
438
|
*/
|
|
439
|
+
|
|
440
|
+
|
|
439
441
|
{
|
|
440
442
|
var deprecatedAPIs = {
|
|
441
443
|
isMounted: ['isMounted', 'Instead, make sure to clean up subscriptions and pending requests in ' + 'componentWillUnmount to prevent memory leaks.'],
|
|
442
444
|
replaceState: ['replaceState', 'Refactor your code to use setState instead (see ' + 'https://github.com/facebook/react/issues/3236).']
|
|
443
445
|
};
|
|
446
|
+
|
|
444
447
|
var defineDeprecationWarning = function (methodName, info) {
|
|
445
448
|
Object.defineProperty(Component.prototype, methodName, {
|
|
446
449
|
get: function () {
|
|
447
|
-
|
|
450
|
+
lowPriorityWarningWithoutStack$1(false, '%s(...) is deprecated in plain JavaScript React classes. %s', info[0], info[1]);
|
|
448
451
|
return undefined;
|
|
449
452
|
}
|
|
450
453
|
});
|
|
451
454
|
};
|
|
455
|
+
|
|
452
456
|
for (var fnName in deprecatedAPIs) {
|
|
453
457
|
if (deprecatedAPIs.hasOwnProperty(fnName)) {
|
|
454
458
|
defineDeprecationWarning(fnName, deprecatedAPIs[fnName]);
|
|
@@ -457,23 +461,25 @@ Component.prototype.forceUpdate = function (callback) {
|
|
|
457
461
|
}
|
|
458
462
|
|
|
459
463
|
function ComponentDummy() {}
|
|
460
|
-
ComponentDummy.prototype = Component.prototype;
|
|
461
464
|
|
|
465
|
+
ComponentDummy.prototype = Component.prototype;
|
|
462
466
|
/**
|
|
463
467
|
* Convenience component with default shallow equality check for sCU.
|
|
464
468
|
*/
|
|
469
|
+
|
|
465
470
|
function PureComponent(props, context, updater) {
|
|
466
471
|
this.props = props;
|
|
467
|
-
this.context = context;
|
|
468
|
-
|
|
472
|
+
this.context = context; // If a component has string refs, we will assign a different object later.
|
|
473
|
+
|
|
469
474
|
this.refs = emptyObject;
|
|
470
475
|
this.updater = updater || ReactNoopUpdateQueue;
|
|
471
476
|
}
|
|
472
477
|
|
|
473
478
|
var pureComponentPrototype = PureComponent.prototype = new ComponentDummy();
|
|
474
|
-
pureComponentPrototype.constructor = PureComponent;
|
|
475
|
-
|
|
479
|
+
pureComponentPrototype.constructor = PureComponent; // Avoid an extra prototype jump for these methods.
|
|
480
|
+
|
|
476
481
|
objectAssign(pureComponentPrototype, Component.prototype);
|
|
482
|
+
|
|
477
483
|
pureComponentPrototype.isPureReactComponent = true;
|
|
478
484
|
|
|
479
485
|
// an immutable object with a single mutable value
|
|
@@ -481,9 +487,11 @@ function createRef() {
|
|
|
481
487
|
var refObject = {
|
|
482
488
|
current: null
|
|
483
489
|
};
|
|
490
|
+
|
|
484
491
|
{
|
|
485
492
|
Object.seal(refObject);
|
|
486
493
|
}
|
|
494
|
+
|
|
487
495
|
return refObject;
|
|
488
496
|
}
|
|
489
497
|
|
|
@@ -521,19 +529,22 @@ var ReactCurrentOwner = {
|
|
|
521
529
|
};
|
|
522
530
|
|
|
523
531
|
var BEFORE_SLASH_RE = /^(.*)[\\\/]/;
|
|
524
|
-
|
|
525
532
|
var describeComponentFrame = function (name, source, ownerName) {
|
|
526
533
|
var sourceInfo = '';
|
|
534
|
+
|
|
527
535
|
if (source) {
|
|
528
536
|
var path = source.fileName;
|
|
529
537
|
var fileName = path.replace(BEFORE_SLASH_RE, '');
|
|
538
|
+
|
|
530
539
|
{
|
|
531
540
|
// In DEV, include code for a common special case:
|
|
532
541
|
// prefer "folder/index.js" instead of just "index.js".
|
|
533
542
|
if (/^index\./.test(fileName)) {
|
|
534
543
|
var match = path.match(BEFORE_SLASH_RE);
|
|
544
|
+
|
|
535
545
|
if (match) {
|
|
536
546
|
var pathBeforeSlash = match[1];
|
|
547
|
+
|
|
537
548
|
if (pathBeforeSlash) {
|
|
538
549
|
var folderName = pathBeforeSlash.replace(BEFORE_SLASH_RE, '');
|
|
539
550
|
fileName = folderName + '/' + fileName;
|
|
@@ -541,23 +552,24 @@ var describeComponentFrame = function (name, source, ownerName) {
|
|
|
541
552
|
}
|
|
542
553
|
}
|
|
543
554
|
}
|
|
555
|
+
|
|
544
556
|
sourceInfo = ' (at ' + fileName + ':' + source.lineNumber + ')';
|
|
545
557
|
} else if (ownerName) {
|
|
546
558
|
sourceInfo = ' (created by ' + ownerName + ')';
|
|
547
559
|
}
|
|
560
|
+
|
|
548
561
|
return '\n in ' + (name || 'Unknown') + sourceInfo;
|
|
549
562
|
};
|
|
550
563
|
|
|
551
564
|
var Resolved = 1;
|
|
552
565
|
|
|
553
|
-
|
|
554
566
|
function refineResolvedLazyComponent(lazyComponent) {
|
|
555
567
|
return lazyComponent._status === Resolved ? lazyComponent._result : null;
|
|
556
568
|
}
|
|
557
569
|
|
|
558
570
|
function getWrappedName(outerType, innerType, wrapperName) {
|
|
559
571
|
var functionName = innerType.displayName || innerType.name || '';
|
|
560
|
-
return outerType.displayName || (functionName !== '' ? wrapperName +
|
|
572
|
+
return outerType.displayName || (functionName !== '' ? wrapperName + "(" + functionName + ")" : wrapperName);
|
|
561
573
|
}
|
|
562
574
|
|
|
563
575
|
function getComponentName(type) {
|
|
@@ -565,59 +577,74 @@ function getComponentName(type) {
|
|
|
565
577
|
// Host root, text node or just invalid type.
|
|
566
578
|
return null;
|
|
567
579
|
}
|
|
580
|
+
|
|
568
581
|
{
|
|
569
582
|
if (typeof type.tag === 'number') {
|
|
570
583
|
warningWithoutStack$1(false, 'Received an unexpected object in getComponentName(). ' + 'This is likely a bug in React. Please file an issue.');
|
|
571
584
|
}
|
|
572
585
|
}
|
|
586
|
+
|
|
573
587
|
if (typeof type === 'function') {
|
|
574
588
|
return type.displayName || type.name || null;
|
|
575
589
|
}
|
|
590
|
+
|
|
576
591
|
if (typeof type === 'string') {
|
|
577
592
|
return type;
|
|
578
593
|
}
|
|
594
|
+
|
|
579
595
|
switch (type) {
|
|
580
596
|
case REACT_FRAGMENT_TYPE:
|
|
581
597
|
return 'Fragment';
|
|
598
|
+
|
|
582
599
|
case REACT_PORTAL_TYPE:
|
|
583
600
|
return 'Portal';
|
|
601
|
+
|
|
584
602
|
case REACT_PROFILER_TYPE:
|
|
585
|
-
return
|
|
603
|
+
return "Profiler";
|
|
604
|
+
|
|
586
605
|
case REACT_STRICT_MODE_TYPE:
|
|
587
606
|
return 'StrictMode';
|
|
607
|
+
|
|
588
608
|
case REACT_SUSPENSE_TYPE:
|
|
589
609
|
return 'Suspense';
|
|
610
|
+
|
|
590
611
|
case REACT_SUSPENSE_LIST_TYPE:
|
|
591
612
|
return 'SuspenseList';
|
|
592
613
|
}
|
|
614
|
+
|
|
593
615
|
if (typeof type === 'object') {
|
|
594
616
|
switch (type.$$typeof) {
|
|
595
617
|
case REACT_CONTEXT_TYPE:
|
|
596
618
|
return 'Context.Consumer';
|
|
619
|
+
|
|
597
620
|
case REACT_PROVIDER_TYPE:
|
|
598
621
|
return 'Context.Provider';
|
|
622
|
+
|
|
599
623
|
case REACT_FORWARD_REF_TYPE:
|
|
600
624
|
return getWrappedName(type, type.render, 'ForwardRef');
|
|
625
|
+
|
|
601
626
|
case REACT_MEMO_TYPE:
|
|
602
627
|
return getComponentName(type.type);
|
|
628
|
+
|
|
603
629
|
case REACT_LAZY_TYPE:
|
|
604
630
|
{
|
|
605
631
|
var thenable = type;
|
|
606
632
|
var resolvedThenable = refineResolvedLazyComponent(thenable);
|
|
633
|
+
|
|
607
634
|
if (resolvedThenable) {
|
|
608
635
|
return getComponentName(resolvedThenable);
|
|
609
636
|
}
|
|
637
|
+
|
|
610
638
|
break;
|
|
611
639
|
}
|
|
612
640
|
}
|
|
613
641
|
}
|
|
642
|
+
|
|
614
643
|
return null;
|
|
615
644
|
}
|
|
616
645
|
|
|
617
646
|
var ReactDebugCurrentFrame = {};
|
|
618
|
-
|
|
619
647
|
var currentlyValidatingElement = null;
|
|
620
|
-
|
|
621
648
|
function setCurrentlyValidatingElement(element) {
|
|
622
649
|
{
|
|
623
650
|
currentlyValidatingElement = element;
|
|
@@ -629,17 +656,17 @@ function setCurrentlyValidatingElement(element) {
|
|
|
629
656
|
ReactDebugCurrentFrame.getCurrentStack = null;
|
|
630
657
|
|
|
631
658
|
ReactDebugCurrentFrame.getStackAddendum = function () {
|
|
632
|
-
var stack = '';
|
|
659
|
+
var stack = ''; // Add an extra top frame while an element is being validated
|
|
633
660
|
|
|
634
|
-
// Add an extra top frame while an element is being validated
|
|
635
661
|
if (currentlyValidatingElement) {
|
|
636
662
|
var name = getComponentName(currentlyValidatingElement.type);
|
|
637
663
|
var owner = currentlyValidatingElement._owner;
|
|
638
664
|
stack += describeComponentFrame(name, currentlyValidatingElement._source, owner && getComponentName(owner.type));
|
|
639
|
-
}
|
|
665
|
+
} // Delegate to the injected renderer-specific implementation
|
|
666
|
+
|
|
640
667
|
|
|
641
|
-
// Delegate to the injected renderer-specific implementation
|
|
642
668
|
var impl = ReactDebugCurrentFrame.getCurrentStack;
|
|
669
|
+
|
|
643
670
|
if (impl) {
|
|
644
671
|
stack += impl() || '';
|
|
645
672
|
}
|
|
@@ -651,7 +678,6 @@ function setCurrentlyValidatingElement(element) {
|
|
|
651
678
|
/**
|
|
652
679
|
* Used by act() to track whether you're inside an act() scope.
|
|
653
680
|
*/
|
|
654
|
-
|
|
655
681
|
var IsSomeRendererActing = {
|
|
656
682
|
current: false
|
|
657
683
|
};
|
|
@@ -689,41 +715,41 @@ var warning = warningWithoutStack$1;
|
|
|
689
715
|
if (condition) {
|
|
690
716
|
return;
|
|
691
717
|
}
|
|
718
|
+
|
|
692
719
|
var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame;
|
|
693
|
-
var stack = ReactDebugCurrentFrame.getStackAddendum();
|
|
694
|
-
// eslint-disable-next-line react-internal/warning-and-invariant-args
|
|
720
|
+
var stack = ReactDebugCurrentFrame.getStackAddendum(); // eslint-disable-next-line react-internal/warning-and-invariant-args
|
|
695
721
|
|
|
696
|
-
for (var _len = arguments.length, args = Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
|
|
722
|
+
for (var _len = arguments.length, args = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) {
|
|
697
723
|
args[_key - 2] = arguments[_key];
|
|
698
724
|
}
|
|
699
725
|
|
|
700
|
-
warningWithoutStack$1.apply(
|
|
726
|
+
warningWithoutStack$1.apply(void 0, [false, format + '%s'].concat(args, [stack]));
|
|
701
727
|
};
|
|
702
728
|
}
|
|
703
729
|
|
|
704
730
|
var warning$1 = warning;
|
|
705
731
|
|
|
706
732
|
var hasOwnProperty$1 = Object.prototype.hasOwnProperty;
|
|
707
|
-
|
|
708
733
|
var RESERVED_PROPS = {
|
|
709
734
|
key: true,
|
|
710
735
|
ref: true,
|
|
711
736
|
__self: true,
|
|
712
737
|
__source: true
|
|
713
738
|
};
|
|
714
|
-
|
|
715
|
-
var
|
|
716
|
-
var specialPropRefWarningShown = void 0;
|
|
739
|
+
var specialPropKeyWarningShown;
|
|
740
|
+
var specialPropRefWarningShown;
|
|
717
741
|
|
|
718
742
|
function hasValidRef(config) {
|
|
719
743
|
{
|
|
720
744
|
if (hasOwnProperty$1.call(config, 'ref')) {
|
|
721
745
|
var getter = Object.getOwnPropertyDescriptor(config, 'ref').get;
|
|
746
|
+
|
|
722
747
|
if (getter && getter.isReactWarning) {
|
|
723
748
|
return false;
|
|
724
749
|
}
|
|
725
750
|
}
|
|
726
751
|
}
|
|
752
|
+
|
|
727
753
|
return config.ref !== undefined;
|
|
728
754
|
}
|
|
729
755
|
|
|
@@ -731,11 +757,13 @@ function hasValidKey(config) {
|
|
|
731
757
|
{
|
|
732
758
|
if (hasOwnProperty$1.call(config, 'key')) {
|
|
733
759
|
var getter = Object.getOwnPropertyDescriptor(config, 'key').get;
|
|
760
|
+
|
|
734
761
|
if (getter && getter.isReactWarning) {
|
|
735
762
|
return false;
|
|
736
763
|
}
|
|
737
764
|
}
|
|
738
765
|
}
|
|
766
|
+
|
|
739
767
|
return config.key !== undefined;
|
|
740
768
|
}
|
|
741
769
|
|
|
@@ -746,6 +774,7 @@ function defineKeyPropWarningGetter(props, displayName) {
|
|
|
746
774
|
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);
|
|
747
775
|
}
|
|
748
776
|
};
|
|
777
|
+
|
|
749
778
|
warnAboutAccessingKey.isReactWarning = true;
|
|
750
779
|
Object.defineProperty(props, 'key', {
|
|
751
780
|
get: warnAboutAccessingKey,
|
|
@@ -760,17 +789,17 @@ function defineRefPropWarningGetter(props, displayName) {
|
|
|
760
789
|
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);
|
|
761
790
|
}
|
|
762
791
|
};
|
|
792
|
+
|
|
763
793
|
warnAboutAccessingRef.isReactWarning = true;
|
|
764
794
|
Object.defineProperty(props, 'ref', {
|
|
765
795
|
get: warnAboutAccessingRef,
|
|
766
796
|
configurable: true
|
|
767
797
|
});
|
|
768
798
|
}
|
|
769
|
-
|
|
770
799
|
/**
|
|
771
800
|
* Factory method to create a new React element. This no longer adheres to
|
|
772
|
-
* the class pattern, so do not use new to call it. Also,
|
|
773
|
-
* will work. Instead test $$typeof field against Symbol.for('react.element') to check
|
|
801
|
+
* the class pattern, so do not use new to call it. Also, instanceof check
|
|
802
|
+
* will not work. Instead test $$typeof field against Symbol.for('react.element') to check
|
|
774
803
|
* if something is a React Element.
|
|
775
804
|
*
|
|
776
805
|
* @param {*} type
|
|
@@ -787,17 +816,17 @@ function defineRefPropWarningGetter(props, displayName) {
|
|
|
787
816
|
* indicating filename, line number, and/or other information.
|
|
788
817
|
* @internal
|
|
789
818
|
*/
|
|
819
|
+
|
|
820
|
+
|
|
790
821
|
var ReactElement = function (type, key, ref, self, source, owner, props) {
|
|
791
822
|
var element = {
|
|
792
823
|
// This tag allows us to uniquely identify this as a React Element
|
|
793
824
|
$$typeof: REACT_ELEMENT_TYPE,
|
|
794
|
-
|
|
795
825
|
// Built-in properties that belong on the element
|
|
796
826
|
type: type,
|
|
797
827
|
key: key,
|
|
798
828
|
ref: ref,
|
|
799
829
|
props: props,
|
|
800
|
-
|
|
801
830
|
// Record the component responsible for creating this element.
|
|
802
831
|
_owner: owner
|
|
803
832
|
};
|
|
@@ -807,33 +836,33 @@ var ReactElement = function (type, key, ref, self, source, owner, props) {
|
|
|
807
836
|
// an external backing store so that we can freeze the whole object.
|
|
808
837
|
// This can be replaced with a WeakMap once they are implemented in
|
|
809
838
|
// commonly used development environments.
|
|
810
|
-
element._store = {};
|
|
811
|
-
|
|
812
|
-
// To make comparing ReactElements easier for testing purposes, we make
|
|
839
|
+
element._store = {}; // To make comparing ReactElements easier for testing purposes, we make
|
|
813
840
|
// the validation flag non-enumerable (where possible, which should
|
|
814
841
|
// include every environment we run tests in), so the test framework
|
|
815
842
|
// ignores it.
|
|
843
|
+
|
|
816
844
|
Object.defineProperty(element._store, 'validated', {
|
|
817
845
|
configurable: false,
|
|
818
846
|
enumerable: false,
|
|
819
847
|
writable: true,
|
|
820
848
|
value: false
|
|
821
|
-
});
|
|
822
|
-
|
|
849
|
+
}); // self and source are DEV only properties.
|
|
850
|
+
|
|
823
851
|
Object.defineProperty(element, '_self', {
|
|
824
852
|
configurable: false,
|
|
825
853
|
enumerable: false,
|
|
826
854
|
writable: false,
|
|
827
855
|
value: self
|
|
828
|
-
});
|
|
829
|
-
// Two elements created in two different places should be considered
|
|
856
|
+
}); // Two elements created in two different places should be considered
|
|
830
857
|
// equal for testing purposes and therefore we hide it from enumeration.
|
|
858
|
+
|
|
831
859
|
Object.defineProperty(element, '_source', {
|
|
832
860
|
configurable: false,
|
|
833
861
|
enumerable: false,
|
|
834
862
|
writable: false,
|
|
835
863
|
value: source
|
|
836
864
|
});
|
|
865
|
+
|
|
837
866
|
if (Object.freeze) {
|
|
838
867
|
Object.freeze(element.props);
|
|
839
868
|
Object.freeze(element);
|
|
@@ -842,7 +871,6 @@ var ReactElement = function (type, key, ref, self, source, owner, props) {
|
|
|
842
871
|
|
|
843
872
|
return element;
|
|
844
873
|
};
|
|
845
|
-
|
|
846
874
|
/**
|
|
847
875
|
* https://github.com/reactjs/rfcs/pull/107
|
|
848
876
|
* @param {*} type
|
|
@@ -851,45 +879,49 @@ var ReactElement = function (type, key, ref, self, source, owner, props) {
|
|
|
851
879
|
*/
|
|
852
880
|
|
|
853
881
|
|
|
882
|
+
|
|
854
883
|
/**
|
|
855
884
|
* https://github.com/reactjs/rfcs/pull/107
|
|
856
885
|
* @param {*} type
|
|
857
886
|
* @param {object} props
|
|
858
887
|
* @param {string} key
|
|
859
888
|
*/
|
|
889
|
+
|
|
860
890
|
function jsxDEV(type, config, maybeKey, source, self) {
|
|
861
|
-
var propName
|
|
891
|
+
var propName; // Reserved names are extracted
|
|
862
892
|
|
|
863
|
-
// Reserved names are extracted
|
|
864
893
|
var props = {};
|
|
865
|
-
|
|
866
894
|
var key = null;
|
|
867
|
-
var ref = null;
|
|
895
|
+
var ref = null; // Currently, key can be spread in as a prop. This causes a potential
|
|
896
|
+
// issue if key is also explicitly declared (ie. <div {...props} key="Hi" />
|
|
897
|
+
// or <div key="Hi" {...props} /> ). We want to deprecate key spread,
|
|
898
|
+
// but as an intermediary step, we will use jsxDEV for everything except
|
|
899
|
+
// <div {...props} key="Hi" />, because we aren't currently able to tell if
|
|
900
|
+
// key is explicitly declared to be undefined or not.
|
|
868
901
|
|
|
869
|
-
if (
|
|
870
|
-
|
|
902
|
+
if (maybeKey !== undefined) {
|
|
903
|
+
key = '' + maybeKey;
|
|
871
904
|
}
|
|
872
905
|
|
|
873
906
|
if (hasValidKey(config)) {
|
|
874
907
|
key = '' + config.key;
|
|
875
908
|
}
|
|
876
909
|
|
|
877
|
-
|
|
910
|
+
if (hasValidRef(config)) {
|
|
911
|
+
ref = config.ref;
|
|
912
|
+
} // Remaining properties are added to a new props object
|
|
913
|
+
|
|
914
|
+
|
|
878
915
|
for (propName in config) {
|
|
879
916
|
if (hasOwnProperty$1.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) {
|
|
880
917
|
props[propName] = config[propName];
|
|
881
918
|
}
|
|
882
|
-
}
|
|
919
|
+
} // Resolve default props
|
|
883
920
|
|
|
884
|
-
// intentionally not checking if key was set above
|
|
885
|
-
// this key is higher priority as it's static
|
|
886
|
-
if (maybeKey !== undefined) {
|
|
887
|
-
key = '' + maybeKey;
|
|
888
|
-
}
|
|
889
921
|
|
|
890
|
-
// Resolve default props
|
|
891
922
|
if (type && type.defaultProps) {
|
|
892
923
|
var defaultProps = type.defaultProps;
|
|
924
|
+
|
|
893
925
|
for (propName in defaultProps) {
|
|
894
926
|
if (props[propName] === undefined) {
|
|
895
927
|
props[propName] = defaultProps[propName];
|
|
@@ -899,9 +931,11 @@ function jsxDEV(type, config, maybeKey, source, self) {
|
|
|
899
931
|
|
|
900
932
|
if (key || ref) {
|
|
901
933
|
var displayName = typeof type === 'function' ? type.displayName || type.name || 'Unknown' : type;
|
|
934
|
+
|
|
902
935
|
if (key) {
|
|
903
936
|
defineKeyPropWarningGetter(props, displayName);
|
|
904
937
|
}
|
|
938
|
+
|
|
905
939
|
if (ref) {
|
|
906
940
|
defineRefPropWarningGetter(props, displayName);
|
|
907
941
|
}
|
|
@@ -909,17 +943,15 @@ function jsxDEV(type, config, maybeKey, source, self) {
|
|
|
909
943
|
|
|
910
944
|
return ReactElement(type, key, ref, self, source, ReactCurrentOwner.current, props);
|
|
911
945
|
}
|
|
912
|
-
|
|
913
946
|
/**
|
|
914
947
|
* Create and return a new ReactElement of the given type.
|
|
915
948
|
* See https://reactjs.org/docs/react-api.html#createelement
|
|
916
949
|
*/
|
|
950
|
+
|
|
917
951
|
function createElement(type, config, children) {
|
|
918
|
-
var propName
|
|
952
|
+
var propName; // Reserved names are extracted
|
|
919
953
|
|
|
920
|
-
// Reserved names are extracted
|
|
921
954
|
var props = {};
|
|
922
|
-
|
|
923
955
|
var key = null;
|
|
924
956
|
var ref = null;
|
|
925
957
|
var self = null;
|
|
@@ -929,61 +961,70 @@ function createElement(type, config, children) {
|
|
|
929
961
|
if (hasValidRef(config)) {
|
|
930
962
|
ref = config.ref;
|
|
931
963
|
}
|
|
964
|
+
|
|
932
965
|
if (hasValidKey(config)) {
|
|
933
966
|
key = '' + config.key;
|
|
934
967
|
}
|
|
935
968
|
|
|
936
969
|
self = config.__self === undefined ? null : config.__self;
|
|
937
|
-
source = config.__source === undefined ? null : config.__source;
|
|
938
|
-
|
|
970
|
+
source = config.__source === undefined ? null : config.__source; // Remaining properties are added to a new props object
|
|
971
|
+
|
|
939
972
|
for (propName in config) {
|
|
940
973
|
if (hasOwnProperty$1.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) {
|
|
941
974
|
props[propName] = config[propName];
|
|
942
975
|
}
|
|
943
976
|
}
|
|
944
|
-
}
|
|
945
|
-
|
|
946
|
-
// Children can be more than one argument, and those are transferred onto
|
|
977
|
+
} // Children can be more than one argument, and those are transferred onto
|
|
947
978
|
// the newly allocated props object.
|
|
979
|
+
|
|
980
|
+
|
|
948
981
|
var childrenLength = arguments.length - 2;
|
|
982
|
+
|
|
949
983
|
if (childrenLength === 1) {
|
|
950
984
|
props.children = children;
|
|
951
985
|
} else if (childrenLength > 1) {
|
|
952
986
|
var childArray = Array(childrenLength);
|
|
987
|
+
|
|
953
988
|
for (var i = 0; i < childrenLength; i++) {
|
|
954
989
|
childArray[i] = arguments[i + 2];
|
|
955
990
|
}
|
|
991
|
+
|
|
956
992
|
{
|
|
957
993
|
if (Object.freeze) {
|
|
958
994
|
Object.freeze(childArray);
|
|
959
995
|
}
|
|
960
996
|
}
|
|
997
|
+
|
|
961
998
|
props.children = childArray;
|
|
962
|
-
}
|
|
999
|
+
} // Resolve default props
|
|
1000
|
+
|
|
963
1001
|
|
|
964
|
-
// Resolve default props
|
|
965
1002
|
if (type && type.defaultProps) {
|
|
966
1003
|
var defaultProps = type.defaultProps;
|
|
1004
|
+
|
|
967
1005
|
for (propName in defaultProps) {
|
|
968
1006
|
if (props[propName] === undefined) {
|
|
969
1007
|
props[propName] = defaultProps[propName];
|
|
970
1008
|
}
|
|
971
1009
|
}
|
|
972
1010
|
}
|
|
1011
|
+
|
|
973
1012
|
{
|
|
974
1013
|
if (key || ref) {
|
|
975
1014
|
var displayName = typeof type === 'function' ? type.displayName || type.name || 'Unknown' : type;
|
|
1015
|
+
|
|
976
1016
|
if (key) {
|
|
977
1017
|
defineKeyPropWarningGetter(props, displayName);
|
|
978
1018
|
}
|
|
1019
|
+
|
|
979
1020
|
if (ref) {
|
|
980
1021
|
defineRefPropWarningGetter(props, displayName);
|
|
981
1022
|
}
|
|
982
1023
|
}
|
|
983
1024
|
}
|
|
1025
|
+
|
|
984
1026
|
return ReactElement(type, key, ref, self, source, ReactCurrentOwner.current, props);
|
|
985
1027
|
}
|
|
986
|
-
|
|
987
1028
|
/**
|
|
988
1029
|
* Return a function that produces ReactElements of a given type.
|
|
989
1030
|
* See https://reactjs.org/docs/react-api.html#createfactory
|
|
@@ -992,39 +1033,34 @@ function createElement(type, config, children) {
|
|
|
992
1033
|
|
|
993
1034
|
function cloneAndReplaceKey(oldElement, newKey) {
|
|
994
1035
|
var newElement = ReactElement(oldElement.type, newKey, oldElement.ref, oldElement._self, oldElement._source, oldElement._owner, oldElement.props);
|
|
995
|
-
|
|
996
1036
|
return newElement;
|
|
997
1037
|
}
|
|
998
|
-
|
|
999
1038
|
/**
|
|
1000
1039
|
* Clone and return a new ReactElement using element as the starting point.
|
|
1001
1040
|
* See https://reactjs.org/docs/react-api.html#cloneelement
|
|
1002
1041
|
*/
|
|
1042
|
+
|
|
1003
1043
|
function cloneElement(element, config, children) {
|
|
1004
|
-
(
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
throw ReactError(Error('React.cloneElement(...): The argument must be a React element, but you passed ' + element + '.'));
|
|
1008
|
-
}
|
|
1044
|
+
if (!!(element === null || element === undefined)) {
|
|
1045
|
+
{
|
|
1046
|
+
throw Error("React.cloneElement(...): The argument must be a React element, but you passed " + element + ".");
|
|
1009
1047
|
}
|
|
1010
|
-
}
|
|
1048
|
+
}
|
|
1049
|
+
|
|
1050
|
+
var propName; // Original props are copied
|
|
1011
1051
|
|
|
1012
|
-
var
|
|
1052
|
+
var props = objectAssign({}, element.props); // Reserved names are extracted
|
|
1013
1053
|
|
|
1014
|
-
// Original props are copied
|
|
1015
|
-
var props = objectAssign({}, element.props);
|
|
1016
1054
|
|
|
1017
|
-
// Reserved names are extracted
|
|
1018
1055
|
var key = element.key;
|
|
1019
|
-
var ref = element.ref;
|
|
1020
|
-
|
|
1021
|
-
var self = element._self;
|
|
1022
|
-
// Source is preserved since cloneElement is unlikely to be targeted by a
|
|
1056
|
+
var ref = element.ref; // Self is preserved since the owner is preserved.
|
|
1057
|
+
|
|
1058
|
+
var self = element._self; // Source is preserved since cloneElement is unlikely to be targeted by a
|
|
1023
1059
|
// transpiler, and the original source is probably a better indicator of the
|
|
1024
1060
|
// true owner.
|
|
1025
|
-
var source = element._source;
|
|
1026
1061
|
|
|
1027
|
-
// Owner will be preserved, unless ref is overridden
|
|
1062
|
+
var source = element._source; // Owner will be preserved, unless ref is overridden
|
|
1063
|
+
|
|
1028
1064
|
var owner = element._owner;
|
|
1029
1065
|
|
|
1030
1066
|
if (config != null) {
|
|
@@ -1033,15 +1069,18 @@ function cloneElement(element, config, children) {
|
|
|
1033
1069
|
ref = config.ref;
|
|
1034
1070
|
owner = ReactCurrentOwner.current;
|
|
1035
1071
|
}
|
|
1072
|
+
|
|
1036
1073
|
if (hasValidKey(config)) {
|
|
1037
1074
|
key = '' + config.key;
|
|
1038
|
-
}
|
|
1075
|
+
} // Remaining properties override existing props
|
|
1076
|
+
|
|
1077
|
+
|
|
1078
|
+
var defaultProps;
|
|
1039
1079
|
|
|
1040
|
-
// Remaining properties override existing props
|
|
1041
|
-
var defaultProps = void 0;
|
|
1042
1080
|
if (element.type && element.type.defaultProps) {
|
|
1043
1081
|
defaultProps = element.type.defaultProps;
|
|
1044
1082
|
}
|
|
1083
|
+
|
|
1045
1084
|
for (propName in config) {
|
|
1046
1085
|
if (hasOwnProperty$1.call(config, propName) && !RESERVED_PROPS.hasOwnProperty(propName)) {
|
|
1047
1086
|
if (config[propName] === undefined && defaultProps !== undefined) {
|
|
@@ -1052,24 +1091,26 @@ function cloneElement(element, config, children) {
|
|
|
1052
1091
|
}
|
|
1053
1092
|
}
|
|
1054
1093
|
}
|
|
1055
|
-
}
|
|
1056
|
-
|
|
1057
|
-
// Children can be more than one argument, and those are transferred onto
|
|
1094
|
+
} // Children can be more than one argument, and those are transferred onto
|
|
1058
1095
|
// the newly allocated props object.
|
|
1096
|
+
|
|
1097
|
+
|
|
1059
1098
|
var childrenLength = arguments.length - 2;
|
|
1099
|
+
|
|
1060
1100
|
if (childrenLength === 1) {
|
|
1061
1101
|
props.children = children;
|
|
1062
1102
|
} else if (childrenLength > 1) {
|
|
1063
1103
|
var childArray = Array(childrenLength);
|
|
1104
|
+
|
|
1064
1105
|
for (var i = 0; i < childrenLength; i++) {
|
|
1065
1106
|
childArray[i] = arguments[i + 2];
|
|
1066
1107
|
}
|
|
1108
|
+
|
|
1067
1109
|
props.children = childArray;
|
|
1068
1110
|
}
|
|
1069
1111
|
|
|
1070
1112
|
return ReactElement(element.type, key, ref, self, source, owner, props);
|
|
1071
1113
|
}
|
|
1072
|
-
|
|
1073
1114
|
/**
|
|
1074
1115
|
* Verifies the object is a ReactElement.
|
|
1075
1116
|
* See https://reactjs.org/docs/react-api.html#isvalidelement
|
|
@@ -1077,19 +1118,20 @@ function cloneElement(element, config, children) {
|
|
|
1077
1118
|
* @return {boolean} True if `object` is a ReactElement.
|
|
1078
1119
|
* @final
|
|
1079
1120
|
*/
|
|
1121
|
+
|
|
1080
1122
|
function isValidElement(object) {
|
|
1081
1123
|
return typeof object === 'object' && object !== null && object.$$typeof === REACT_ELEMENT_TYPE;
|
|
1082
1124
|
}
|
|
1083
1125
|
|
|
1084
1126
|
var SEPARATOR = '.';
|
|
1085
1127
|
var SUBSEPARATOR = ':';
|
|
1086
|
-
|
|
1087
1128
|
/**
|
|
1088
1129
|
* Escape and wrap key so it is safe to use as a reactid
|
|
1089
1130
|
*
|
|
1090
1131
|
* @param {string} key to be escaped.
|
|
1091
1132
|
* @return {string} the escaped key.
|
|
1092
1133
|
*/
|
|
1134
|
+
|
|
1093
1135
|
function escape(key) {
|
|
1094
1136
|
var escapeRegex = /[=:]/g;
|
|
1095
1137
|
var escaperLookup = {
|
|
@@ -1099,24 +1141,24 @@ function escape(key) {
|
|
|
1099
1141
|
var escapedString = ('' + key).replace(escapeRegex, function (match) {
|
|
1100
1142
|
return escaperLookup[match];
|
|
1101
1143
|
});
|
|
1102
|
-
|
|
1103
1144
|
return '$' + escapedString;
|
|
1104
1145
|
}
|
|
1105
|
-
|
|
1106
1146
|
/**
|
|
1107
1147
|
* TODO: Test that a single child and an array with one item have the same key
|
|
1108
1148
|
* pattern.
|
|
1109
1149
|
*/
|
|
1110
1150
|
|
|
1111
|
-
var didWarnAboutMaps = false;
|
|
1112
1151
|
|
|
1152
|
+
var didWarnAboutMaps = false;
|
|
1113
1153
|
var userProvidedKeyEscapeRegex = /\/+/g;
|
|
1154
|
+
|
|
1114
1155
|
function escapeUserProvidedKey(text) {
|
|
1115
1156
|
return ('' + text).replace(userProvidedKeyEscapeRegex, '$&/');
|
|
1116
1157
|
}
|
|
1117
1158
|
|
|
1118
1159
|
var POOL_SIZE = 10;
|
|
1119
1160
|
var traverseContextPool = [];
|
|
1161
|
+
|
|
1120
1162
|
function getPooledTraverseContext(mapResult, keyPrefix, mapFunction, mapContext) {
|
|
1121
1163
|
if (traverseContextPool.length) {
|
|
1122
1164
|
var traverseContext = traverseContextPool.pop();
|
|
@@ -1143,11 +1185,11 @@ function releaseTraverseContext(traverseContext) {
|
|
|
1143
1185
|
traverseContext.func = null;
|
|
1144
1186
|
traverseContext.context = null;
|
|
1145
1187
|
traverseContext.count = 0;
|
|
1188
|
+
|
|
1146
1189
|
if (traverseContextPool.length < POOL_SIZE) {
|
|
1147
1190
|
traverseContextPool.push(traverseContext);
|
|
1148
1191
|
}
|
|
1149
1192
|
}
|
|
1150
|
-
|
|
1151
1193
|
/**
|
|
1152
1194
|
* @param {?*} children Children tree container.
|
|
1153
1195
|
* @param {!string} nameSoFar Name of the key path so far.
|
|
@@ -1156,6 +1198,8 @@ function releaseTraverseContext(traverseContext) {
|
|
|
1156
1198
|
* process.
|
|
1157
1199
|
* @return {!number} The number of children in this subtree.
|
|
1158
1200
|
*/
|
|
1201
|
+
|
|
1202
|
+
|
|
1159
1203
|
function traverseAllChildrenImpl(children, nameSoFar, callback, traverseContext) {
|
|
1160
1204
|
var type = typeof children;
|
|
1161
1205
|
|
|
@@ -1174,26 +1218,28 @@ function traverseAllChildrenImpl(children, nameSoFar, callback, traverseContext)
|
|
|
1174
1218
|
case 'number':
|
|
1175
1219
|
invokeCallback = true;
|
|
1176
1220
|
break;
|
|
1221
|
+
|
|
1177
1222
|
case 'object':
|
|
1178
1223
|
switch (children.$$typeof) {
|
|
1179
1224
|
case REACT_ELEMENT_TYPE:
|
|
1180
1225
|
case REACT_PORTAL_TYPE:
|
|
1181
1226
|
invokeCallback = true;
|
|
1182
1227
|
}
|
|
1228
|
+
|
|
1183
1229
|
}
|
|
1184
1230
|
}
|
|
1185
1231
|
|
|
1186
1232
|
if (invokeCallback) {
|
|
1187
|
-
callback(traverseContext, children,
|
|
1188
|
-
// If it's the only child, treat the name as if it was wrapped in an array
|
|
1233
|
+
callback(traverseContext, children, // If it's the only child, treat the name as if it was wrapped in an array
|
|
1189
1234
|
// so that it's consistent if the number of children grows.
|
|
1190
1235
|
nameSoFar === '' ? SEPARATOR + getComponentKey(children, 0) : nameSoFar);
|
|
1191
1236
|
return 1;
|
|
1192
1237
|
}
|
|
1193
1238
|
|
|
1194
|
-
var child
|
|
1195
|
-
var nextName
|
|
1239
|
+
var child;
|
|
1240
|
+
var nextName;
|
|
1196
1241
|
var subtreeCount = 0; // Count of children found in the current subtree.
|
|
1242
|
+
|
|
1197
1243
|
var nextNamePrefix = nameSoFar === '' ? SEPARATOR : nameSoFar + SUBSEPARATOR;
|
|
1198
1244
|
|
|
1199
1245
|
if (Array.isArray(children)) {
|
|
@@ -1204,6 +1250,7 @@ function traverseAllChildrenImpl(children, nameSoFar, callback, traverseContext)
|
|
|
1204
1250
|
}
|
|
1205
1251
|
} else {
|
|
1206
1252
|
var iteratorFn = getIteratorFn(children);
|
|
1253
|
+
|
|
1207
1254
|
if (typeof iteratorFn === 'function') {
|
|
1208
1255
|
{
|
|
1209
1256
|
// Warn about using Maps as children
|
|
@@ -1214,8 +1261,9 @@ function traverseAllChildrenImpl(children, nameSoFar, callback, traverseContext)
|
|
|
1214
1261
|
}
|
|
1215
1262
|
|
|
1216
1263
|
var iterator = iteratorFn.call(children);
|
|
1217
|
-
var step
|
|
1264
|
+
var step;
|
|
1218
1265
|
var ii = 0;
|
|
1266
|
+
|
|
1219
1267
|
while (!(step = iterator.next()).done) {
|
|
1220
1268
|
child = step.value;
|
|
1221
1269
|
nextName = nextNamePrefix + getComponentKey(child, ii++);
|
|
@@ -1223,23 +1271,23 @@ function traverseAllChildrenImpl(children, nameSoFar, callback, traverseContext)
|
|
|
1223
1271
|
}
|
|
1224
1272
|
} else if (type === 'object') {
|
|
1225
1273
|
var addendum = '';
|
|
1274
|
+
|
|
1226
1275
|
{
|
|
1227
1276
|
addendum = ' If you meant to render a collection of children, use an array ' + 'instead.' + ReactDebugCurrentFrame.getStackAddendum();
|
|
1228
1277
|
}
|
|
1278
|
+
|
|
1229
1279
|
var childrenString = '' + children;
|
|
1230
|
-
|
|
1280
|
+
|
|
1281
|
+
{
|
|
1231
1282
|
{
|
|
1232
|
-
{
|
|
1233
|
-
throw ReactError(Error('Objects are not valid as a React child (found: ' + (childrenString === '[object Object]' ? 'object with keys {' + Object.keys(children).join(', ') + '}' : childrenString) + ').' + addendum));
|
|
1234
|
-
}
|
|
1283
|
+
throw Error("Objects are not valid as a React child (found: " + (childrenString === '[object Object]' ? 'object with keys {' + Object.keys(children).join(', ') + '}' : childrenString) + ")." + addendum);
|
|
1235
1284
|
}
|
|
1236
|
-
}
|
|
1285
|
+
}
|
|
1237
1286
|
}
|
|
1238
1287
|
}
|
|
1239
1288
|
|
|
1240
1289
|
return subtreeCount;
|
|
1241
1290
|
}
|
|
1242
|
-
|
|
1243
1291
|
/**
|
|
1244
1292
|
* Traverses children that are typically specified as `props.children`, but
|
|
1245
1293
|
* might also be specified through attributes:
|
|
@@ -1256,6 +1304,8 @@ function traverseAllChildrenImpl(children, nameSoFar, callback, traverseContext)
|
|
|
1256
1304
|
* @param {?*} traverseContext Context for traversal.
|
|
1257
1305
|
* @return {!number} The number of children in this subtree.
|
|
1258
1306
|
*/
|
|
1307
|
+
|
|
1308
|
+
|
|
1259
1309
|
function traverseAllChildren(children, callback, traverseContext) {
|
|
1260
1310
|
if (children == null) {
|
|
1261
1311
|
return 0;
|
|
@@ -1263,7 +1313,6 @@ function traverseAllChildren(children, callback, traverseContext) {
|
|
|
1263
1313
|
|
|
1264
1314
|
return traverseAllChildrenImpl(children, '', callback, traverseContext);
|
|
1265
1315
|
}
|
|
1266
|
-
|
|
1267
1316
|
/**
|
|
1268
1317
|
* Generate a key string that identifies a component within a set.
|
|
1269
1318
|
*
|
|
@@ -1271,24 +1320,25 @@ function traverseAllChildren(children, callback, traverseContext) {
|
|
|
1271
1320
|
* @param {number} index Index that is used if a manual key is not provided.
|
|
1272
1321
|
* @return {string}
|
|
1273
1322
|
*/
|
|
1323
|
+
|
|
1324
|
+
|
|
1274
1325
|
function getComponentKey(component, index) {
|
|
1275
1326
|
// Do some typechecking here since we call this blindly. We want to ensure
|
|
1276
1327
|
// that we don't block potential future ES APIs.
|
|
1277
1328
|
if (typeof component === 'object' && component !== null && component.key != null) {
|
|
1278
1329
|
// Explicit key
|
|
1279
1330
|
return escape(component.key);
|
|
1280
|
-
}
|
|
1281
|
-
|
|
1331
|
+
} // Implicit key determined by the index in the set
|
|
1332
|
+
|
|
1333
|
+
|
|
1282
1334
|
return index.toString(36);
|
|
1283
1335
|
}
|
|
1284
1336
|
|
|
1285
1337
|
function forEachSingleChild(bookKeeping, child, name) {
|
|
1286
1338
|
var func = bookKeeping.func,
|
|
1287
1339
|
context = bookKeeping.context;
|
|
1288
|
-
|
|
1289
1340
|
func.call(context, child, bookKeeping.count++);
|
|
1290
1341
|
}
|
|
1291
|
-
|
|
1292
1342
|
/**
|
|
1293
1343
|
* Iterates through children that are typically specified as `props.children`.
|
|
1294
1344
|
*
|
|
@@ -1301,10 +1351,13 @@ function forEachSingleChild(bookKeeping, child, name) {
|
|
|
1301
1351
|
* @param {function(*, int)} forEachFunc
|
|
1302
1352
|
* @param {*} forEachContext Context for forEachContext.
|
|
1303
1353
|
*/
|
|
1354
|
+
|
|
1355
|
+
|
|
1304
1356
|
function forEachChildren(children, forEachFunc, forEachContext) {
|
|
1305
1357
|
if (children == null) {
|
|
1306
1358
|
return children;
|
|
1307
1359
|
}
|
|
1360
|
+
|
|
1308
1361
|
var traverseContext = getPooledTraverseContext(null, null, forEachFunc, forEachContext);
|
|
1309
1362
|
traverseAllChildren(children, forEachSingleChild, traverseContext);
|
|
1310
1363
|
releaseTraverseContext(traverseContext);
|
|
@@ -1315,34 +1368,34 @@ function mapSingleChildIntoContext(bookKeeping, child, childKey) {
|
|
|
1315
1368
|
keyPrefix = bookKeeping.keyPrefix,
|
|
1316
1369
|
func = bookKeeping.func,
|
|
1317
1370
|
context = bookKeeping.context;
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
1371
|
var mappedChild = func.call(context, child, bookKeeping.count++);
|
|
1372
|
+
|
|
1321
1373
|
if (Array.isArray(mappedChild)) {
|
|
1322
1374
|
mapIntoWithKeyPrefixInternal(mappedChild, result, childKey, function (c) {
|
|
1323
1375
|
return c;
|
|
1324
1376
|
});
|
|
1325
1377
|
} else if (mappedChild != null) {
|
|
1326
1378
|
if (isValidElement(mappedChild)) {
|
|
1327
|
-
mappedChild = cloneAndReplaceKey(mappedChild,
|
|
1328
|
-
// Keep both the (mapped) and old keys if they differ, just as
|
|
1379
|
+
mappedChild = cloneAndReplaceKey(mappedChild, // Keep both the (mapped) and old keys if they differ, just as
|
|
1329
1380
|
// traverseAllChildren used to do for objects as children
|
|
1330
1381
|
keyPrefix + (mappedChild.key && (!child || child.key !== mappedChild.key) ? escapeUserProvidedKey(mappedChild.key) + '/' : '') + childKey);
|
|
1331
1382
|
}
|
|
1383
|
+
|
|
1332
1384
|
result.push(mappedChild);
|
|
1333
1385
|
}
|
|
1334
1386
|
}
|
|
1335
1387
|
|
|
1336
1388
|
function mapIntoWithKeyPrefixInternal(children, array, prefix, func, context) {
|
|
1337
1389
|
var escapedPrefix = '';
|
|
1390
|
+
|
|
1338
1391
|
if (prefix != null) {
|
|
1339
1392
|
escapedPrefix = escapeUserProvidedKey(prefix) + '/';
|
|
1340
1393
|
}
|
|
1394
|
+
|
|
1341
1395
|
var traverseContext = getPooledTraverseContext(array, escapedPrefix, func, context);
|
|
1342
1396
|
traverseAllChildren(children, mapSingleChildIntoContext, traverseContext);
|
|
1343
1397
|
releaseTraverseContext(traverseContext);
|
|
1344
1398
|
}
|
|
1345
|
-
|
|
1346
1399
|
/**
|
|
1347
1400
|
* Maps children that are typically specified as `props.children`.
|
|
1348
1401
|
*
|
|
@@ -1356,15 +1409,17 @@ function mapIntoWithKeyPrefixInternal(children, array, prefix, func, context) {
|
|
|
1356
1409
|
* @param {*} context Context for mapFunction.
|
|
1357
1410
|
* @return {object} Object containing the ordered map of results.
|
|
1358
1411
|
*/
|
|
1412
|
+
|
|
1413
|
+
|
|
1359
1414
|
function mapChildren(children, func, context) {
|
|
1360
1415
|
if (children == null) {
|
|
1361
1416
|
return children;
|
|
1362
1417
|
}
|
|
1418
|
+
|
|
1363
1419
|
var result = [];
|
|
1364
1420
|
mapIntoWithKeyPrefixInternal(children, result, null, func, context);
|
|
1365
1421
|
return result;
|
|
1366
1422
|
}
|
|
1367
|
-
|
|
1368
1423
|
/**
|
|
1369
1424
|
* Count the number of children that are typically specified as
|
|
1370
1425
|
* `props.children`.
|
|
@@ -1374,18 +1429,21 @@ function mapChildren(children, func, context) {
|
|
|
1374
1429
|
* @param {?*} children Children tree container.
|
|
1375
1430
|
* @return {number} The number of children.
|
|
1376
1431
|
*/
|
|
1432
|
+
|
|
1433
|
+
|
|
1377
1434
|
function countChildren(children) {
|
|
1378
1435
|
return traverseAllChildren(children, function () {
|
|
1379
1436
|
return null;
|
|
1380
1437
|
}, null);
|
|
1381
1438
|
}
|
|
1382
|
-
|
|
1383
1439
|
/**
|
|
1384
1440
|
* Flatten a children object (typically specified as `props.children`) and
|
|
1385
1441
|
* return an array with appropriately re-keyed children.
|
|
1386
1442
|
*
|
|
1387
1443
|
* See https://reactjs.org/docs/react-api.html#reactchildrentoarray
|
|
1388
1444
|
*/
|
|
1445
|
+
|
|
1446
|
+
|
|
1389
1447
|
function toArray(children) {
|
|
1390
1448
|
var result = [];
|
|
1391
1449
|
mapIntoWithKeyPrefixInternal(children, result, null, function (child) {
|
|
@@ -1393,7 +1451,6 @@ function toArray(children) {
|
|
|
1393
1451
|
});
|
|
1394
1452
|
return result;
|
|
1395
1453
|
}
|
|
1396
|
-
|
|
1397
1454
|
/**
|
|
1398
1455
|
* Returns the first child in a collection of children and verifies that there
|
|
1399
1456
|
* is only one child in the collection.
|
|
@@ -1408,14 +1465,15 @@ function toArray(children) {
|
|
|
1408
1465
|
* @return {ReactElement} The first and only `ReactElement` contained in the
|
|
1409
1466
|
* structure.
|
|
1410
1467
|
*/
|
|
1468
|
+
|
|
1469
|
+
|
|
1411
1470
|
function onlyChild(children) {
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
throw ReactError(Error('React.Children.only expected to receive a single React element child.'));
|
|
1416
|
-
}
|
|
1471
|
+
if (!isValidElement(children)) {
|
|
1472
|
+
{
|
|
1473
|
+
throw Error("React.Children.only expected to receive a single React element child.");
|
|
1417
1474
|
}
|
|
1418
|
-
}
|
|
1475
|
+
}
|
|
1476
|
+
|
|
1419
1477
|
return children;
|
|
1420
1478
|
}
|
|
1421
1479
|
|
|
@@ -1445,12 +1503,10 @@ function createContext(defaultValue, calculateChangedBits) {
|
|
|
1445
1503
|
Provider: null,
|
|
1446
1504
|
Consumer: null
|
|
1447
1505
|
};
|
|
1448
|
-
|
|
1449
1506
|
context.Provider = {
|
|
1450
1507
|
$$typeof: REACT_PROVIDER_TYPE,
|
|
1451
1508
|
_context: context
|
|
1452
1509
|
};
|
|
1453
|
-
|
|
1454
1510
|
var hasWarnedAboutUsingNestedContextConsumers = false;
|
|
1455
1511
|
var hasWarnedAboutUsingConsumerProvider = false;
|
|
1456
1512
|
|
|
@@ -1462,8 +1518,8 @@ function createContext(defaultValue, calculateChangedBits) {
|
|
|
1462
1518
|
$$typeof: REACT_CONTEXT_TYPE,
|
|
1463
1519
|
_context: context,
|
|
1464
1520
|
_calculateChangedBits: context._calculateChangedBits
|
|
1465
|
-
};
|
|
1466
|
-
|
|
1521
|
+
}; // $FlowFixMe: Flow complains about not setting a value, which is intentional here
|
|
1522
|
+
|
|
1467
1523
|
Object.defineProperties(Consumer, {
|
|
1468
1524
|
Provider: {
|
|
1469
1525
|
get: function () {
|
|
@@ -1471,6 +1527,7 @@ function createContext(defaultValue, calculateChangedBits) {
|
|
|
1471
1527
|
hasWarnedAboutUsingConsumerProvider = true;
|
|
1472
1528
|
warning$1(false, 'Rendering <Context.Consumer.Provider> is not supported and will be removed in ' + 'a future major release. Did you mean to render <Context.Provider> instead?');
|
|
1473
1529
|
}
|
|
1530
|
+
|
|
1474
1531
|
return context.Provider;
|
|
1475
1532
|
},
|
|
1476
1533
|
set: function (_Provider) {
|
|
@@ -1507,11 +1564,12 @@ function createContext(defaultValue, calculateChangedBits) {
|
|
|
1507
1564
|
hasWarnedAboutUsingNestedContextConsumers = true;
|
|
1508
1565
|
warning$1(false, 'Rendering <Context.Consumer.Consumer> is not supported and will be removed in ' + 'a future major release. Did you mean to render <Context.Consumer> instead?');
|
|
1509
1566
|
}
|
|
1567
|
+
|
|
1510
1568
|
return context.Consumer;
|
|
1511
1569
|
}
|
|
1512
1570
|
}
|
|
1513
|
-
});
|
|
1514
|
-
|
|
1571
|
+
}); // $FlowFixMe: Flow complains about missing properties because it doesn't understand defineProperty
|
|
1572
|
+
|
|
1515
1573
|
context.Consumer = Consumer;
|
|
1516
1574
|
}
|
|
1517
1575
|
|
|
@@ -1534,8 +1592,8 @@ function lazy(ctor) {
|
|
|
1534
1592
|
|
|
1535
1593
|
{
|
|
1536
1594
|
// In production, this would just set it on the object.
|
|
1537
|
-
var defaultProps
|
|
1538
|
-
var propTypes
|
|
1595
|
+
var defaultProps;
|
|
1596
|
+
var propTypes;
|
|
1539
1597
|
Object.defineProperties(lazyType, {
|
|
1540
1598
|
defaultProps: {
|
|
1541
1599
|
configurable: true,
|
|
@@ -1544,8 +1602,8 @@ function lazy(ctor) {
|
|
|
1544
1602
|
},
|
|
1545
1603
|
set: function (newDefaultProps) {
|
|
1546
1604
|
warning$1(false, 'React.lazy(...): It is not supported to assign `defaultProps` to ' + 'a lazy component import. Either specify them where the component ' + 'is defined, or create a wrapping component around it.');
|
|
1547
|
-
defaultProps = newDefaultProps;
|
|
1548
|
-
|
|
1605
|
+
defaultProps = newDefaultProps; // Match production behavior more closely:
|
|
1606
|
+
|
|
1549
1607
|
Object.defineProperty(lazyType, 'defaultProps', {
|
|
1550
1608
|
enumerable: true
|
|
1551
1609
|
});
|
|
@@ -1558,8 +1616,8 @@ function lazy(ctor) {
|
|
|
1558
1616
|
},
|
|
1559
1617
|
set: function (newPropTypes) {
|
|
1560
1618
|
warning$1(false, 'React.lazy(...): It is not supported to assign `propTypes` to ' + 'a lazy component import. Either specify them where the component ' + 'is defined, or create a wrapping component around it.');
|
|
1561
|
-
propTypes = newPropTypes;
|
|
1562
|
-
|
|
1619
|
+
propTypes = newPropTypes; // Match production behavior more closely:
|
|
1620
|
+
|
|
1563
1621
|
Object.defineProperty(lazyType, 'propTypes', {
|
|
1564
1622
|
enumerable: true
|
|
1565
1623
|
});
|
|
@@ -1578,8 +1636,7 @@ function forwardRef(render) {
|
|
|
1578
1636
|
} else if (typeof render !== 'function') {
|
|
1579
1637
|
warningWithoutStack$1(false, 'forwardRef requires a render function but was given %s.', render === null ? 'null' : typeof render);
|
|
1580
1638
|
} else {
|
|
1581
|
-
!(
|
|
1582
|
-
// Do not warn for 0 arguments because it could be due to usage of the 'arguments' object
|
|
1639
|
+
!( // Do not warn for 0 arguments because it could be due to usage of the 'arguments' object
|
|
1583
1640
|
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;
|
|
1584
1641
|
}
|
|
1585
1642
|
|
|
@@ -1595,9 +1652,8 @@ function forwardRef(render) {
|
|
|
1595
1652
|
}
|
|
1596
1653
|
|
|
1597
1654
|
function isValidElementType(type) {
|
|
1598
|
-
return typeof type === 'string' || typeof type === 'function' ||
|
|
1599
|
-
|
|
1600
|
-
type === REACT_FRAGMENT_TYPE || type === REACT_CONCURRENT_MODE_TYPE || type === REACT_PROFILER_TYPE || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || type === REACT_SUSPENSE_LIST_TYPE || typeof type === 'object' && type !== null && (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE || type.$$typeof === REACT_FUNDAMENTAL_TYPE || type.$$typeof === REACT_RESPONDER_TYPE);
|
|
1655
|
+
return typeof type === 'string' || typeof type === 'function' || // Note: its typeof might be other than 'symbol' or 'number' if it's a polyfill.
|
|
1656
|
+
type === REACT_FRAGMENT_TYPE || type === REACT_CONCURRENT_MODE_TYPE || type === REACT_PROFILER_TYPE || type === REACT_STRICT_MODE_TYPE || type === REACT_SUSPENSE_TYPE || type === REACT_SUSPENSE_LIST_TYPE || typeof type === 'object' && type !== null && (type.$$typeof === REACT_LAZY_TYPE || type.$$typeof === REACT_MEMO_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE || type.$$typeof === REACT_FUNDAMENTAL_TYPE || type.$$typeof === REACT_RESPONDER_TYPE || type.$$typeof === REACT_SCOPE_TYPE);
|
|
1601
1657
|
}
|
|
1602
1658
|
|
|
1603
1659
|
function memo(type, compare) {
|
|
@@ -1606,6 +1662,7 @@ function memo(type, compare) {
|
|
|
1606
1662
|
warningWithoutStack$1(false, 'memo: The first argument must be a component. Instead ' + 'received: %s', type === null ? 'null' : typeof type);
|
|
1607
1663
|
}
|
|
1608
1664
|
}
|
|
1665
|
+
|
|
1609
1666
|
return {
|
|
1610
1667
|
$$typeof: REACT_MEMO_TYPE,
|
|
1611
1668
|
type: type,
|
|
@@ -1615,26 +1672,26 @@ function memo(type, compare) {
|
|
|
1615
1672
|
|
|
1616
1673
|
function resolveDispatcher() {
|
|
1617
1674
|
var dispatcher = ReactCurrentDispatcher.current;
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
}
|
|
1675
|
+
|
|
1676
|
+
if (!(dispatcher !== null)) {
|
|
1677
|
+
{
|
|
1678
|
+
throw Error("Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:\n1. You might have mismatching versions of React and the renderer (such as React DOM)\n2. You might be breaking the Rules of Hooks\n3. You might have more than one copy of React in the same app\nSee https://fb.me/react-invalid-hook-call for tips about how to debug and fix this problem.");
|
|
1623
1679
|
}
|
|
1624
|
-
}
|
|
1680
|
+
}
|
|
1681
|
+
|
|
1625
1682
|
return dispatcher;
|
|
1626
1683
|
}
|
|
1627
1684
|
|
|
1628
1685
|
function useContext(Context, unstable_observedBits) {
|
|
1629
1686
|
var dispatcher = resolveDispatcher();
|
|
1687
|
+
|
|
1630
1688
|
{
|
|
1631
|
-
!(unstable_observedBits === undefined) ? warning$1(false, 'useContext() second argument is reserved for future ' + 'use in React. Passing it is not supported. ' + 'You passed: %s.%s', unstable_observedBits, typeof unstable_observedBits === 'number' && Array.isArray(arguments[2]) ? '\n\nDid you call array.map(useContext)? ' + 'Calling Hooks inside a loop is not supported. ' + 'Learn more at https://fb.me/rules-of-hooks' : '') : void 0;
|
|
1689
|
+
!(unstable_observedBits === undefined) ? warning$1(false, 'useContext() second argument is reserved for future ' + 'use in React. Passing it is not supported. ' + 'You passed: %s.%s', unstable_observedBits, typeof unstable_observedBits === 'number' && Array.isArray(arguments[2]) ? '\n\nDid you call array.map(useContext)? ' + 'Calling Hooks inside a loop is not supported. ' + 'Learn more at https://fb.me/rules-of-hooks' : '') : void 0; // TODO: add a more generic warning for invalid values.
|
|
1632
1690
|
|
|
1633
|
-
// TODO: add a more generic warning for invalid values.
|
|
1634
1691
|
if (Context._context !== undefined) {
|
|
1635
|
-
var realContext = Context._context;
|
|
1636
|
-
// Don't deduplicate because this legitimately causes bugs
|
|
1692
|
+
var realContext = Context._context; // Don't deduplicate because this legitimately causes bugs
|
|
1637
1693
|
// and nobody should be using this in existing code.
|
|
1694
|
+
|
|
1638
1695
|
if (realContext.Consumer === Context) {
|
|
1639
1696
|
warning$1(false, 'Calling useContext(Context.Consumer) is not supported, may cause bugs, and will be ' + 'removed in a future major release. Did you mean to call useContext(Context) instead?');
|
|
1640
1697
|
} else if (realContext.Provider === Context) {
|
|
@@ -1642,73 +1699,73 @@ function useContext(Context, unstable_observedBits) {
|
|
|
1642
1699
|
}
|
|
1643
1700
|
}
|
|
1644
1701
|
}
|
|
1702
|
+
|
|
1645
1703
|
return dispatcher.useContext(Context, unstable_observedBits);
|
|
1646
1704
|
}
|
|
1647
|
-
|
|
1648
1705
|
function useState(initialState) {
|
|
1649
1706
|
var dispatcher = resolveDispatcher();
|
|
1650
1707
|
return dispatcher.useState(initialState);
|
|
1651
1708
|
}
|
|
1652
|
-
|
|
1653
1709
|
function useReducer(reducer, initialArg, init) {
|
|
1654
1710
|
var dispatcher = resolveDispatcher();
|
|
1655
1711
|
return dispatcher.useReducer(reducer, initialArg, init);
|
|
1656
1712
|
}
|
|
1657
|
-
|
|
1658
1713
|
function useRef(initialValue) {
|
|
1659
1714
|
var dispatcher = resolveDispatcher();
|
|
1660
1715
|
return dispatcher.useRef(initialValue);
|
|
1661
1716
|
}
|
|
1662
|
-
|
|
1663
1717
|
function useEffect(create, inputs) {
|
|
1664
1718
|
var dispatcher = resolveDispatcher();
|
|
1665
1719
|
return dispatcher.useEffect(create, inputs);
|
|
1666
1720
|
}
|
|
1667
|
-
|
|
1668
1721
|
function useLayoutEffect(create, inputs) {
|
|
1669
1722
|
var dispatcher = resolveDispatcher();
|
|
1670
1723
|
return dispatcher.useLayoutEffect(create, inputs);
|
|
1671
1724
|
}
|
|
1672
|
-
|
|
1673
1725
|
function useCallback(callback, inputs) {
|
|
1674
1726
|
var dispatcher = resolveDispatcher();
|
|
1675
1727
|
return dispatcher.useCallback(callback, inputs);
|
|
1676
1728
|
}
|
|
1677
|
-
|
|
1678
1729
|
function useMemo(create, inputs) {
|
|
1679
1730
|
var dispatcher = resolveDispatcher();
|
|
1680
1731
|
return dispatcher.useMemo(create, inputs);
|
|
1681
1732
|
}
|
|
1682
|
-
|
|
1683
1733
|
function useImperativeHandle(ref, create, inputs) {
|
|
1684
1734
|
var dispatcher = resolveDispatcher();
|
|
1685
1735
|
return dispatcher.useImperativeHandle(ref, create, inputs);
|
|
1686
1736
|
}
|
|
1687
|
-
|
|
1688
1737
|
function useDebugValue(value, formatterFn) {
|
|
1689
1738
|
{
|
|
1690
1739
|
var dispatcher = resolveDispatcher();
|
|
1691
1740
|
return dispatcher.useDebugValue(value, formatterFn);
|
|
1692
1741
|
}
|
|
1693
1742
|
}
|
|
1694
|
-
|
|
1695
1743
|
var emptyObject$1 = {};
|
|
1696
|
-
|
|
1697
1744
|
function useResponder(responder, listenerProps) {
|
|
1698
1745
|
var dispatcher = resolveDispatcher();
|
|
1746
|
+
|
|
1699
1747
|
{
|
|
1700
1748
|
if (responder == null || responder.$$typeof !== REACT_RESPONDER_TYPE) {
|
|
1701
1749
|
warning$1(false, 'useResponder: invalid first argument. Expected an event responder, but instead got %s', responder);
|
|
1702
1750
|
return;
|
|
1703
1751
|
}
|
|
1704
1752
|
}
|
|
1753
|
+
|
|
1705
1754
|
return dispatcher.useResponder(responder, listenerProps || emptyObject$1);
|
|
1706
1755
|
}
|
|
1756
|
+
function useTransition(config) {
|
|
1757
|
+
var dispatcher = resolveDispatcher();
|
|
1758
|
+
return dispatcher.useTransition(config);
|
|
1759
|
+
}
|
|
1760
|
+
function useDeferredValue(value, config) {
|
|
1761
|
+
var dispatcher = resolveDispatcher();
|
|
1762
|
+
return dispatcher.useDeferredValue(value, config);
|
|
1763
|
+
}
|
|
1707
1764
|
|
|
1708
|
-
// Within the scope of the callback, mark all updates as being allowed to suspend.
|
|
1709
1765
|
function withSuspenseConfig(scope, config) {
|
|
1710
1766
|
var previousConfig = ReactCurrentBatchConfig.suspense;
|
|
1711
1767
|
ReactCurrentBatchConfig.suspense = config === undefined ? null : config;
|
|
1768
|
+
|
|
1712
1769
|
try {
|
|
1713
1770
|
scope();
|
|
1714
1771
|
} finally {
|
|
@@ -1743,6 +1800,7 @@ var printWarning$1 = function() {};
|
|
|
1743
1800
|
{
|
|
1744
1801
|
var ReactPropTypesSecret = ReactPropTypesSecret_1;
|
|
1745
1802
|
var loggedTypeFailures = {};
|
|
1803
|
+
var has = Function.call.bind(Object.prototype.hasOwnProperty);
|
|
1746
1804
|
|
|
1747
1805
|
printWarning$1 = function(text) {
|
|
1748
1806
|
var message = 'Warning: ' + text;
|
|
@@ -1772,7 +1830,7 @@ var printWarning$1 = function() {};
|
|
|
1772
1830
|
function checkPropTypes(typeSpecs, values, location, componentName, getStack) {
|
|
1773
1831
|
{
|
|
1774
1832
|
for (var typeSpecName in typeSpecs) {
|
|
1775
|
-
if (typeSpecs
|
|
1833
|
+
if (has(typeSpecs, typeSpecName)) {
|
|
1776
1834
|
var error;
|
|
1777
1835
|
// Prop type validation may throw. In case they do, we don't want to
|
|
1778
1836
|
// fail the render phase where it didn't fail before. So we log it.
|
|
@@ -1801,7 +1859,6 @@ function checkPropTypes(typeSpecs, values, location, componentName, getStack) {
|
|
|
1801
1859
|
'creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and ' +
|
|
1802
1860
|
'shape all require an argument).'
|
|
1803
1861
|
);
|
|
1804
|
-
|
|
1805
1862
|
}
|
|
1806
1863
|
if (error instanceof Error && !(error.message in loggedTypeFailures)) {
|
|
1807
1864
|
// Only monitor this failure once because there tends to be a lot of the
|
|
@@ -1819,6 +1876,17 @@ function checkPropTypes(typeSpecs, values, location, componentName, getStack) {
|
|
|
1819
1876
|
}
|
|
1820
1877
|
}
|
|
1821
1878
|
|
|
1879
|
+
/**
|
|
1880
|
+
* Resets warning cache when testing.
|
|
1881
|
+
*
|
|
1882
|
+
* @private
|
|
1883
|
+
*/
|
|
1884
|
+
checkPropTypes.resetWarningCache = function() {
|
|
1885
|
+
{
|
|
1886
|
+
loggedTypeFailures = {};
|
|
1887
|
+
}
|
|
1888
|
+
};
|
|
1889
|
+
|
|
1822
1890
|
var checkPropTypes_1 = checkPropTypes;
|
|
1823
1891
|
|
|
1824
1892
|
/**
|
|
@@ -1827,20 +1895,23 @@ var checkPropTypes_1 = checkPropTypes;
|
|
|
1827
1895
|
* used only in DEV and could be replaced by a static type checker for languages
|
|
1828
1896
|
* that support it.
|
|
1829
1897
|
*/
|
|
1830
|
-
|
|
1831
|
-
var propTypesMisspellWarningShown = void 0;
|
|
1898
|
+
var propTypesMisspellWarningShown;
|
|
1832
1899
|
|
|
1833
1900
|
{
|
|
1834
1901
|
propTypesMisspellWarningShown = false;
|
|
1835
1902
|
}
|
|
1836
1903
|
|
|
1904
|
+
var hasOwnProperty$2 = Object.prototype.hasOwnProperty;
|
|
1905
|
+
|
|
1837
1906
|
function getDeclarationErrorAddendum() {
|
|
1838
1907
|
if (ReactCurrentOwner.current) {
|
|
1839
1908
|
var name = getComponentName(ReactCurrentOwner.current.type);
|
|
1909
|
+
|
|
1840
1910
|
if (name) {
|
|
1841
1911
|
return '\n\nCheck the render method of `' + name + '`.';
|
|
1842
1912
|
}
|
|
1843
1913
|
}
|
|
1914
|
+
|
|
1844
1915
|
return '';
|
|
1845
1916
|
}
|
|
1846
1917
|
|
|
@@ -1850,6 +1921,7 @@ function getSourceInfoErrorAddendum(source) {
|
|
|
1850
1921
|
var lineNumber = source.lineNumber;
|
|
1851
1922
|
return '\n\nCheck your code at ' + fileName + ':' + lineNumber + '.';
|
|
1852
1923
|
}
|
|
1924
|
+
|
|
1853
1925
|
return '';
|
|
1854
1926
|
}
|
|
1855
1927
|
|
|
@@ -1857,14 +1929,16 @@ function getSourceInfoErrorAddendumForProps(elementProps) {
|
|
|
1857
1929
|
if (elementProps !== null && elementProps !== undefined) {
|
|
1858
1930
|
return getSourceInfoErrorAddendum(elementProps.__source);
|
|
1859
1931
|
}
|
|
1932
|
+
|
|
1860
1933
|
return '';
|
|
1861
1934
|
}
|
|
1862
|
-
|
|
1863
1935
|
/**
|
|
1864
1936
|
* Warn if there's no key explicitly set on dynamic arrays of children or
|
|
1865
1937
|
* object keys are not valid. This allows us to keep track of children between
|
|
1866
1938
|
* updates.
|
|
1867
1939
|
*/
|
|
1940
|
+
|
|
1941
|
+
|
|
1868
1942
|
var ownerHasKeyUseWarning = {};
|
|
1869
1943
|
|
|
1870
1944
|
function getCurrentComponentErrorInfo(parentType) {
|
|
@@ -1872,13 +1946,14 @@ function getCurrentComponentErrorInfo(parentType) {
|
|
|
1872
1946
|
|
|
1873
1947
|
if (!info) {
|
|
1874
1948
|
var parentName = typeof parentType === 'string' ? parentType : parentType.displayName || parentType.name;
|
|
1949
|
+
|
|
1875
1950
|
if (parentName) {
|
|
1876
|
-
info =
|
|
1951
|
+
info = "\n\nCheck the top-level render call using <" + parentName + ">.";
|
|
1877
1952
|
}
|
|
1878
1953
|
}
|
|
1954
|
+
|
|
1879
1955
|
return info;
|
|
1880
1956
|
}
|
|
1881
|
-
|
|
1882
1957
|
/**
|
|
1883
1958
|
* Warn if the element doesn't have an explicit key assigned to it.
|
|
1884
1959
|
* This element is in an array. The array could grow and shrink or be
|
|
@@ -1890,34 +1965,39 @@ function getCurrentComponentErrorInfo(parentType) {
|
|
|
1890
1965
|
* @param {ReactElement} element Element that requires a key.
|
|
1891
1966
|
* @param {*} parentType element's parent's type.
|
|
1892
1967
|
*/
|
|
1968
|
+
|
|
1969
|
+
|
|
1893
1970
|
function validateExplicitKey(element, parentType) {
|
|
1894
1971
|
if (!element._store || element._store.validated || element.key != null) {
|
|
1895
1972
|
return;
|
|
1896
1973
|
}
|
|
1897
|
-
element._store.validated = true;
|
|
1898
1974
|
|
|
1975
|
+
element._store.validated = true;
|
|
1899
1976
|
var currentComponentErrorInfo = getCurrentComponentErrorInfo(parentType);
|
|
1977
|
+
|
|
1900
1978
|
if (ownerHasKeyUseWarning[currentComponentErrorInfo]) {
|
|
1901
1979
|
return;
|
|
1902
1980
|
}
|
|
1903
|
-
ownerHasKeyUseWarning[currentComponentErrorInfo] = true;
|
|
1904
1981
|
|
|
1905
|
-
// Usually the current owner is the offender, but if it accepts children as a
|
|
1982
|
+
ownerHasKeyUseWarning[currentComponentErrorInfo] = true; // Usually the current owner is the offender, but if it accepts children as a
|
|
1906
1983
|
// property, it may be the creator of the child that's responsible for
|
|
1907
1984
|
// assigning it a key.
|
|
1985
|
+
|
|
1908
1986
|
var childOwner = '';
|
|
1987
|
+
|
|
1909
1988
|
if (element && element._owner && element._owner !== ReactCurrentOwner.current) {
|
|
1910
1989
|
// Give the component that originally created this child.
|
|
1911
|
-
childOwner =
|
|
1990
|
+
childOwner = " It was passed a child from " + getComponentName(element._owner.type) + ".";
|
|
1912
1991
|
}
|
|
1913
1992
|
|
|
1914
1993
|
setCurrentlyValidatingElement(element);
|
|
1994
|
+
|
|
1915
1995
|
{
|
|
1916
1996
|
warning$1(false, 'Each child in a list should have a unique "key" prop.' + '%s%s See https://fb.me/react-warning-keys for more information.', currentComponentErrorInfo, childOwner);
|
|
1917
1997
|
}
|
|
1998
|
+
|
|
1918
1999
|
setCurrentlyValidatingElement(null);
|
|
1919
2000
|
}
|
|
1920
|
-
|
|
1921
2001
|
/**
|
|
1922
2002
|
* Ensure that every element either is passed in a static location, in an
|
|
1923
2003
|
* array with an explicit keys property defined, or in an object literal
|
|
@@ -1927,13 +2007,17 @@ function validateExplicitKey(element, parentType) {
|
|
|
1927
2007
|
* @param {ReactNode} node Statically passed child of any type.
|
|
1928
2008
|
* @param {*} parentType node's parent's type.
|
|
1929
2009
|
*/
|
|
2010
|
+
|
|
2011
|
+
|
|
1930
2012
|
function validateChildKeys(node, parentType) {
|
|
1931
2013
|
if (typeof node !== 'object') {
|
|
1932
2014
|
return;
|
|
1933
2015
|
}
|
|
2016
|
+
|
|
1934
2017
|
if (Array.isArray(node)) {
|
|
1935
2018
|
for (var i = 0; i < node.length; i++) {
|
|
1936
2019
|
var child = node[i];
|
|
2020
|
+
|
|
1937
2021
|
if (isValidElement(child)) {
|
|
1938
2022
|
validateExplicitKey(child, parentType);
|
|
1939
2023
|
}
|
|
@@ -1945,12 +2029,14 @@ function validateChildKeys(node, parentType) {
|
|
|
1945
2029
|
}
|
|
1946
2030
|
} else if (node) {
|
|
1947
2031
|
var iteratorFn = getIteratorFn(node);
|
|
2032
|
+
|
|
1948
2033
|
if (typeof iteratorFn === 'function') {
|
|
1949
2034
|
// Entry iterators used to provide implicit keys,
|
|
1950
2035
|
// but now we print a separate warning for them later.
|
|
1951
2036
|
if (iteratorFn !== node.entries) {
|
|
1952
2037
|
var iterator = iteratorFn.call(node);
|
|
1953
|
-
var step
|
|
2038
|
+
var step;
|
|
2039
|
+
|
|
1954
2040
|
while (!(step = iterator.next()).done) {
|
|
1955
2041
|
if (isValidElement(step.value)) {
|
|
1956
2042
|
validateExplicitKey(step.value, parentType);
|
|
@@ -1960,30 +2046,34 @@ function validateChildKeys(node, parentType) {
|
|
|
1960
2046
|
}
|
|
1961
2047
|
}
|
|
1962
2048
|
}
|
|
1963
|
-
|
|
1964
2049
|
/**
|
|
1965
2050
|
* Given an element, validate that its props follow the propTypes definition,
|
|
1966
2051
|
* provided by the type.
|
|
1967
2052
|
*
|
|
1968
2053
|
* @param {ReactElement} element
|
|
1969
2054
|
*/
|
|
2055
|
+
|
|
2056
|
+
|
|
1970
2057
|
function validatePropTypes(element) {
|
|
1971
2058
|
var type = element.type;
|
|
2059
|
+
|
|
1972
2060
|
if (type === null || type === undefined || typeof type === 'string') {
|
|
1973
2061
|
return;
|
|
1974
2062
|
}
|
|
2063
|
+
|
|
1975
2064
|
var name = getComponentName(type);
|
|
1976
|
-
var propTypes
|
|
2065
|
+
var propTypes;
|
|
2066
|
+
|
|
1977
2067
|
if (typeof type === 'function') {
|
|
1978
2068
|
propTypes = type.propTypes;
|
|
1979
|
-
} else if (typeof type === 'object' && (type.$$typeof === REACT_FORWARD_REF_TYPE ||
|
|
1980
|
-
// Note: Memo only checks outer props here.
|
|
2069
|
+
} else if (typeof type === 'object' && (type.$$typeof === REACT_FORWARD_REF_TYPE || // Note: Memo only checks outer props here.
|
|
1981
2070
|
// Inner props are checked in the reconciler.
|
|
1982
2071
|
type.$$typeof === REACT_MEMO_TYPE)) {
|
|
1983
2072
|
propTypes = type.propTypes;
|
|
1984
2073
|
} else {
|
|
1985
2074
|
return;
|
|
1986
2075
|
}
|
|
2076
|
+
|
|
1987
2077
|
if (propTypes) {
|
|
1988
2078
|
setCurrentlyValidatingElement(element);
|
|
1989
2079
|
checkPropTypes_1(propTypes, element.props, 'prop', name, ReactDebugCurrentFrame.getStackAddendum);
|
|
@@ -1992,21 +2082,24 @@ function validatePropTypes(element) {
|
|
|
1992
2082
|
propTypesMisspellWarningShown = true;
|
|
1993
2083
|
warningWithoutStack$1(false, 'Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?', name || 'Unknown');
|
|
1994
2084
|
}
|
|
2085
|
+
|
|
1995
2086
|
if (typeof type.getDefaultProps === 'function') {
|
|
1996
2087
|
!type.getDefaultProps.isReactClassApproved ? warningWithoutStack$1(false, 'getDefaultProps is only used on classic React.createClass ' + 'definitions. Use a static property named `defaultProps` instead.') : void 0;
|
|
1997
2088
|
}
|
|
1998
2089
|
}
|
|
1999
|
-
|
|
2000
2090
|
/**
|
|
2001
2091
|
* Given a fragment, validate that it can only be provided with fragment props
|
|
2002
2092
|
* @param {ReactElement} fragment
|
|
2003
2093
|
*/
|
|
2094
|
+
|
|
2095
|
+
|
|
2004
2096
|
function validateFragmentProps(fragment) {
|
|
2005
2097
|
setCurrentlyValidatingElement(fragment);
|
|
2006
|
-
|
|
2007
2098
|
var keys = Object.keys(fragment.props);
|
|
2099
|
+
|
|
2008
2100
|
for (var i = 0; i < keys.length; i++) {
|
|
2009
2101
|
var key = keys[i];
|
|
2102
|
+
|
|
2010
2103
|
if (key !== 'children' && key !== 'key') {
|
|
2011
2104
|
warning$1(false, 'Invalid prop `%s` supplied to `React.Fragment`. ' + 'React.Fragment can only have `key` and `children` props.', key);
|
|
2012
2105
|
break;
|
|
@@ -2021,30 +2114,32 @@ function validateFragmentProps(fragment) {
|
|
|
2021
2114
|
}
|
|
2022
2115
|
|
|
2023
2116
|
function jsxWithValidation(type, props, key, isStaticChildren, source, self) {
|
|
2024
|
-
var validType = isValidElementType(type);
|
|
2025
|
-
|
|
2026
|
-
// We warn in this case but don't throw. We expect the element creation to
|
|
2117
|
+
var validType = isValidElementType(type); // We warn in this case but don't throw. We expect the element creation to
|
|
2027
2118
|
// succeed and there will likely be errors in render.
|
|
2119
|
+
|
|
2028
2120
|
if (!validType) {
|
|
2029
2121
|
var info = '';
|
|
2122
|
+
|
|
2030
2123
|
if (type === undefined || typeof type === 'object' && type !== null && Object.keys(type).length === 0) {
|
|
2031
2124
|
info += ' You likely forgot to export your component from the file ' + "it's defined in, or you might have mixed up default and named imports.";
|
|
2032
2125
|
}
|
|
2033
2126
|
|
|
2034
2127
|
var sourceInfo = getSourceInfoErrorAddendum(source);
|
|
2128
|
+
|
|
2035
2129
|
if (sourceInfo) {
|
|
2036
2130
|
info += sourceInfo;
|
|
2037
2131
|
} else {
|
|
2038
2132
|
info += getDeclarationErrorAddendum();
|
|
2039
2133
|
}
|
|
2040
2134
|
|
|
2041
|
-
var typeString
|
|
2135
|
+
var typeString;
|
|
2136
|
+
|
|
2042
2137
|
if (type === null) {
|
|
2043
2138
|
typeString = 'null';
|
|
2044
2139
|
} else if (Array.isArray(type)) {
|
|
2045
2140
|
typeString = 'array';
|
|
2046
2141
|
} else if (type !== undefined && type.$$typeof === REACT_ELEMENT_TYPE) {
|
|
2047
|
-
typeString =
|
|
2142
|
+
typeString = "<" + (getComponentName(type.type) || 'Unknown') + " />";
|
|
2048
2143
|
info = ' Did you accidentally export a JSX literal instead of a component?';
|
|
2049
2144
|
} else {
|
|
2050
2145
|
typeString = typeof type;
|
|
@@ -2053,25 +2148,33 @@ function jsxWithValidation(type, props, key, isStaticChildren, source, self) {
|
|
|
2053
2148
|
warning$1(false, 'React.jsx: type is invalid -- expected a string (for ' + 'built-in components) or a class/function (for composite ' + 'components) but got: %s.%s', typeString, info);
|
|
2054
2149
|
}
|
|
2055
2150
|
|
|
2056
|
-
var element = jsxDEV(type, props, key, source, self);
|
|
2057
|
-
|
|
2058
|
-
// The result can be nullish if a mock or a custom function is used.
|
|
2151
|
+
var element = jsxDEV(type, props, key, source, self); // The result can be nullish if a mock or a custom function is used.
|
|
2059
2152
|
// TODO: Drop this when these are no longer allowed as the type argument.
|
|
2153
|
+
|
|
2060
2154
|
if (element == null) {
|
|
2061
2155
|
return element;
|
|
2062
|
-
}
|
|
2063
|
-
|
|
2064
|
-
// Skip key warning if the type isn't valid since our key validation logic
|
|
2156
|
+
} // Skip key warning if the type isn't valid since our key validation logic
|
|
2065
2157
|
// doesn't expect a non-string/function type and can throw confusing errors.
|
|
2066
2158
|
// We don't want exception behavior to differ between dev and prod.
|
|
2067
2159
|
// (Rendering will throw with a helpful message and as soon as the type is
|
|
2068
2160
|
// fixed, the key warnings will appear.)
|
|
2161
|
+
|
|
2162
|
+
|
|
2069
2163
|
if (validType) {
|
|
2070
2164
|
var children = props.children;
|
|
2165
|
+
|
|
2071
2166
|
if (children !== undefined) {
|
|
2072
2167
|
if (isStaticChildren) {
|
|
2073
|
-
|
|
2074
|
-
|
|
2168
|
+
if (Array.isArray(children)) {
|
|
2169
|
+
for (var i = 0; i < children.length; i++) {
|
|
2170
|
+
validateChildKeys(children[i], type);
|
|
2171
|
+
}
|
|
2172
|
+
|
|
2173
|
+
if (Object.freeze) {
|
|
2174
|
+
Object.freeze(children);
|
|
2175
|
+
}
|
|
2176
|
+
} else {
|
|
2177
|
+
warning$1(false, 'React.jsx: Static children should always be an array. ' + 'You are likely explicitly calling React.jsxs or React.jsxDEV. ' + 'Use the Babel transform instead.');
|
|
2075
2178
|
}
|
|
2076
2179
|
} else {
|
|
2077
2180
|
validateChildKeys(children, type);
|
|
@@ -2079,7 +2182,7 @@ function jsxWithValidation(type, props, key, isStaticChildren, source, self) {
|
|
|
2079
2182
|
}
|
|
2080
2183
|
}
|
|
2081
2184
|
|
|
2082
|
-
if (props
|
|
2185
|
+
if (hasOwnProperty$2.call(props, 'key')) {
|
|
2083
2186
|
warning$1(false, 'React.jsx: Spreading a key to JSX is a deprecated pattern. ' + 'Explicitly pass a key after spreading props in your JSX call. ' + 'E.g. <ComponentName {...props} key={key} />');
|
|
2084
2187
|
}
|
|
2085
2188
|
|
|
@@ -2090,45 +2193,44 @@ function jsxWithValidation(type, props, key, isStaticChildren, source, self) {
|
|
|
2090
2193
|
}
|
|
2091
2194
|
|
|
2092
2195
|
return element;
|
|
2093
|
-
}
|
|
2094
|
-
|
|
2095
|
-
// These two functions exist to still get child warnings in dev
|
|
2196
|
+
} // These two functions exist to still get child warnings in dev
|
|
2096
2197
|
// even with the prod transform. This means that jsxDEV is purely
|
|
2097
2198
|
// opt-in behavior for better messages but that we won't stop
|
|
2098
2199
|
// giving you warnings if you use production apis.
|
|
2200
|
+
|
|
2099
2201
|
function jsxWithValidationStatic(type, props, key) {
|
|
2100
2202
|
return jsxWithValidation(type, props, key, true);
|
|
2101
2203
|
}
|
|
2102
|
-
|
|
2103
2204
|
function jsxWithValidationDynamic(type, props, key) {
|
|
2104
2205
|
return jsxWithValidation(type, props, key, false);
|
|
2105
2206
|
}
|
|
2106
|
-
|
|
2107
2207
|
function createElementWithValidation(type, props, children) {
|
|
2108
|
-
var validType = isValidElementType(type);
|
|
2109
|
-
|
|
2110
|
-
// We warn in this case but don't throw. We expect the element creation to
|
|
2208
|
+
var validType = isValidElementType(type); // We warn in this case but don't throw. We expect the element creation to
|
|
2111
2209
|
// succeed and there will likely be errors in render.
|
|
2210
|
+
|
|
2112
2211
|
if (!validType) {
|
|
2113
2212
|
var info = '';
|
|
2213
|
+
|
|
2114
2214
|
if (type === undefined || typeof type === 'object' && type !== null && Object.keys(type).length === 0) {
|
|
2115
2215
|
info += ' You likely forgot to export your component from the file ' + "it's defined in, or you might have mixed up default and named imports.";
|
|
2116
2216
|
}
|
|
2117
2217
|
|
|
2118
2218
|
var sourceInfo = getSourceInfoErrorAddendumForProps(props);
|
|
2219
|
+
|
|
2119
2220
|
if (sourceInfo) {
|
|
2120
2221
|
info += sourceInfo;
|
|
2121
2222
|
} else {
|
|
2122
2223
|
info += getDeclarationErrorAddendum();
|
|
2123
2224
|
}
|
|
2124
2225
|
|
|
2125
|
-
var typeString
|
|
2226
|
+
var typeString;
|
|
2227
|
+
|
|
2126
2228
|
if (type === null) {
|
|
2127
2229
|
typeString = 'null';
|
|
2128
2230
|
} else if (Array.isArray(type)) {
|
|
2129
2231
|
typeString = 'array';
|
|
2130
2232
|
} else if (type !== undefined && type.$$typeof === REACT_ELEMENT_TYPE) {
|
|
2131
|
-
typeString =
|
|
2233
|
+
typeString = "<" + (getComponentName(type.type) || 'Unknown') + " />";
|
|
2132
2234
|
info = ' Did you accidentally export a JSX literal instead of a component?';
|
|
2133
2235
|
} else {
|
|
2134
2236
|
typeString = typeof type;
|
|
@@ -2137,19 +2239,18 @@ function createElementWithValidation(type, props, children) {
|
|
|
2137
2239
|
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);
|
|
2138
2240
|
}
|
|
2139
2241
|
|
|
2140
|
-
var element = createElement.apply(this, arguments);
|
|
2141
|
-
|
|
2142
|
-
// The result can be nullish if a mock or a custom function is used.
|
|
2242
|
+
var element = createElement.apply(this, arguments); // The result can be nullish if a mock or a custom function is used.
|
|
2143
2243
|
// TODO: Drop this when these are no longer allowed as the type argument.
|
|
2244
|
+
|
|
2144
2245
|
if (element == null) {
|
|
2145
2246
|
return element;
|
|
2146
|
-
}
|
|
2147
|
-
|
|
2148
|
-
// Skip key warning if the type isn't valid since our key validation logic
|
|
2247
|
+
} // Skip key warning if the type isn't valid since our key validation logic
|
|
2149
2248
|
// doesn't expect a non-string/function type and can throw confusing errors.
|
|
2150
2249
|
// We don't want exception behavior to differ between dev and prod.
|
|
2151
2250
|
// (Rendering will throw with a helpful message and as soon as the type is
|
|
2152
2251
|
// fixed, the key warnings will appear.)
|
|
2252
|
+
|
|
2253
|
+
|
|
2153
2254
|
if (validType) {
|
|
2154
2255
|
for (var i = 2; i < arguments.length; i++) {
|
|
2155
2256
|
validateChildKeys(arguments[i], type);
|
|
@@ -2164,16 +2265,15 @@ function createElementWithValidation(type, props, children) {
|
|
|
2164
2265
|
|
|
2165
2266
|
return element;
|
|
2166
2267
|
}
|
|
2167
|
-
|
|
2168
2268
|
function createFactoryWithValidation(type) {
|
|
2169
2269
|
var validatedFactory = createElementWithValidation.bind(null, type);
|
|
2170
|
-
validatedFactory.type = type;
|
|
2171
|
-
|
|
2270
|
+
validatedFactory.type = type; // Legacy hook: remove it
|
|
2271
|
+
|
|
2172
2272
|
{
|
|
2173
2273
|
Object.defineProperty(validatedFactory, 'type', {
|
|
2174
2274
|
enumerable: false,
|
|
2175
2275
|
get: function () {
|
|
2176
|
-
|
|
2276
|
+
lowPriorityWarningWithoutStack$1(false, 'Factory.type is deprecated. Access the class directly ' + 'before passing it to createFactory.');
|
|
2177
2277
|
Object.defineProperty(this, 'type', {
|
|
2178
2278
|
value: type
|
|
2179
2279
|
});
|
|
@@ -2184,23 +2284,22 @@ function createFactoryWithValidation(type) {
|
|
|
2184
2284
|
|
|
2185
2285
|
return validatedFactory;
|
|
2186
2286
|
}
|
|
2187
|
-
|
|
2188
2287
|
function cloneElementWithValidation(element, props, children) {
|
|
2189
2288
|
var newElement = cloneElement.apply(this, arguments);
|
|
2289
|
+
|
|
2190
2290
|
for (var i = 2; i < arguments.length; i++) {
|
|
2191
2291
|
validateChildKeys(arguments[i], newElement.type);
|
|
2192
2292
|
}
|
|
2293
|
+
|
|
2193
2294
|
validatePropTypes(newElement);
|
|
2194
2295
|
return newElement;
|
|
2195
2296
|
}
|
|
2196
2297
|
|
|
2197
2298
|
var enableSchedulerDebugging = false;
|
|
2198
2299
|
var enableIsInputPending = false;
|
|
2199
|
-
var
|
|
2200
|
-
var
|
|
2201
|
-
var enableMessageLoopImplementation = false;
|
|
2300
|
+
var enableMessageLoopImplementation = true;
|
|
2301
|
+
var enableProfiling = true;
|
|
2202
2302
|
|
|
2203
|
-
// The DOM Scheduler implementation is similar to requestIdleCallback. It
|
|
2204
2303
|
// works by scheduling a requestAnimationFrame, storing the time for the start
|
|
2205
2304
|
// of the frame, then scheduling a postMessage which gets scheduled after paint.
|
|
2206
2305
|
// Within the postMessage handler do as much work as possible until time + frame
|
|
@@ -2208,31 +2307,32 @@ var enableMessageLoopImplementation = false;
|
|
|
2208
2307
|
// layout, paint and other browser work is counted against the available time.
|
|
2209
2308
|
// The frame rate is dynamically adjusted.
|
|
2210
2309
|
|
|
2211
|
-
var requestHostCallback
|
|
2310
|
+
var requestHostCallback;
|
|
2212
2311
|
|
|
2213
|
-
var requestHostTimeout
|
|
2214
|
-
var cancelHostTimeout
|
|
2215
|
-
var shouldYieldToHost
|
|
2216
|
-
var requestPaint
|
|
2217
|
-
var getCurrentTime
|
|
2218
|
-
var forceFrameRate
|
|
2312
|
+
var requestHostTimeout;
|
|
2313
|
+
var cancelHostTimeout;
|
|
2314
|
+
var shouldYieldToHost;
|
|
2315
|
+
var requestPaint;
|
|
2316
|
+
var getCurrentTime;
|
|
2317
|
+
var forceFrameRate;
|
|
2219
2318
|
|
|
2220
|
-
if (
|
|
2221
|
-
// If Scheduler runs in a non-DOM environment, it falls back to a naive
|
|
2319
|
+
if ( // If Scheduler runs in a non-DOM environment, it falls back to a naive
|
|
2222
2320
|
// implementation using setTimeout.
|
|
2223
|
-
typeof window === 'undefined' ||
|
|
2224
|
-
// Check if MessageChannel is supported, too.
|
|
2321
|
+
typeof window === 'undefined' || // Check if MessageChannel is supported, too.
|
|
2225
2322
|
typeof MessageChannel !== 'function') {
|
|
2226
2323
|
// If this accidentally gets imported in a non-browser environment, e.g. JavaScriptCore,
|
|
2227
2324
|
// fallback to a naive implementation.
|
|
2228
2325
|
var _callback = null;
|
|
2229
2326
|
var _timeoutID = null;
|
|
2327
|
+
|
|
2230
2328
|
var _flushCallback = function () {
|
|
2231
2329
|
if (_callback !== null) {
|
|
2232
2330
|
try {
|
|
2233
2331
|
var currentTime = getCurrentTime();
|
|
2234
2332
|
var hasRemainingTime = true;
|
|
2333
|
+
|
|
2235
2334
|
_callback(hasRemainingTime, currentTime);
|
|
2335
|
+
|
|
2236
2336
|
_callback = null;
|
|
2237
2337
|
} catch (e) {
|
|
2238
2338
|
setTimeout(_flushCallback, 0);
|
|
@@ -2240,9 +2340,13 @@ typeof MessageChannel !== 'function') {
|
|
|
2240
2340
|
}
|
|
2241
2341
|
}
|
|
2242
2342
|
};
|
|
2343
|
+
|
|
2344
|
+
var initialTime = Date.now();
|
|
2345
|
+
|
|
2243
2346
|
getCurrentTime = function () {
|
|
2244
|
-
return Date.now();
|
|
2347
|
+
return Date.now() - initialTime;
|
|
2245
2348
|
};
|
|
2349
|
+
|
|
2246
2350
|
requestHostCallback = function (cb) {
|
|
2247
2351
|
if (_callback !== null) {
|
|
2248
2352
|
// Protect against re-entrancy.
|
|
@@ -2252,15 +2356,19 @@ typeof MessageChannel !== 'function') {
|
|
|
2252
2356
|
setTimeout(_flushCallback, 0);
|
|
2253
2357
|
}
|
|
2254
2358
|
};
|
|
2359
|
+
|
|
2255
2360
|
requestHostTimeout = function (cb, ms) {
|
|
2256
2361
|
_timeoutID = setTimeout(cb, ms);
|
|
2257
2362
|
};
|
|
2363
|
+
|
|
2258
2364
|
cancelHostTimeout = function () {
|
|
2259
2365
|
clearTimeout(_timeoutID);
|
|
2260
2366
|
};
|
|
2367
|
+
|
|
2261
2368
|
shouldYieldToHost = function () {
|
|
2262
2369
|
return false;
|
|
2263
2370
|
};
|
|
2371
|
+
|
|
2264
2372
|
requestPaint = forceFrameRate = function () {};
|
|
2265
2373
|
} else {
|
|
2266
2374
|
// Capture local references to native APIs, in case a polyfill overrides them.
|
|
@@ -2270,32 +2378,35 @@ typeof MessageChannel !== 'function') {
|
|
|
2270
2378
|
var _clearTimeout = window.clearTimeout;
|
|
2271
2379
|
var requestAnimationFrame = window.requestAnimationFrame;
|
|
2272
2380
|
var cancelAnimationFrame = window.cancelAnimationFrame;
|
|
2273
|
-
var requestIdleCallback = window.requestIdleCallback;
|
|
2274
2381
|
|
|
2275
2382
|
if (typeof console !== 'undefined') {
|
|
2276
2383
|
// TODO: Remove fb.me link
|
|
2277
2384
|
if (typeof requestAnimationFrame !== 'function') {
|
|
2278
2385
|
console.error("This browser doesn't support requestAnimationFrame. " + 'Make sure that you load a ' + 'polyfill in older browsers. https://fb.me/react-polyfills');
|
|
2279
2386
|
}
|
|
2387
|
+
|
|
2280
2388
|
if (typeof cancelAnimationFrame !== 'function') {
|
|
2281
2389
|
console.error("This browser doesn't support cancelAnimationFrame. " + 'Make sure that you load a ' + 'polyfill in older browsers. https://fb.me/react-polyfills');
|
|
2282
2390
|
}
|
|
2283
2391
|
}
|
|
2284
2392
|
|
|
2285
|
-
|
|
2393
|
+
if (typeof performance === 'object' && typeof performance.now === 'function') {
|
|
2394
|
+
getCurrentTime = function () {
|
|
2395
|
+
return performance.now();
|
|
2396
|
+
};
|
|
2397
|
+
} else {
|
|
2398
|
+
var _initialTime = _Date.now();
|
|
2286
2399
|
|
|
2287
|
-
|
|
2288
|
-
|
|
2289
|
-
|
|
2290
|
-
|
|
2291
|
-
};
|
|
2400
|
+
getCurrentTime = function () {
|
|
2401
|
+
return _Date.now() - _initialTime;
|
|
2402
|
+
};
|
|
2403
|
+
}
|
|
2292
2404
|
|
|
2293
2405
|
var isRAFLoopRunning = false;
|
|
2294
2406
|
var isMessageLoopRunning = false;
|
|
2295
2407
|
var scheduledHostCallback = null;
|
|
2296
2408
|
var rAFTimeoutID = -1;
|
|
2297
2409
|
var taskTimeoutID = -1;
|
|
2298
|
-
|
|
2299
2410
|
var frameLength = enableMessageLoopImplementation ? // We won't attempt to align with the vsync. Instead we'll yield multiple
|
|
2300
2411
|
// times per frame, often enough to keep it responsive even at really
|
|
2301
2412
|
// high frame rates > 120.
|
|
@@ -2304,22 +2415,21 @@ typeof MessageChannel !== 'function') {
|
|
|
2304
2415
|
// heuristic tracking will adjust this value to a faster fps if we get
|
|
2305
2416
|
// more frequent animation frames.
|
|
2306
2417
|
33.33;
|
|
2307
|
-
|
|
2308
2418
|
var prevRAFTime = -1;
|
|
2309
2419
|
var prevRAFInterval = -1;
|
|
2310
2420
|
var frameDeadline = 0;
|
|
2311
|
-
|
|
2312
|
-
var fpsLocked = false;
|
|
2313
|
-
|
|
2314
|
-
// TODO: Make this configurable
|
|
2421
|
+
var fpsLocked = false; // TODO: Make this configurable
|
|
2315
2422
|
// TODO: Adjust this based on priority?
|
|
2423
|
+
|
|
2316
2424
|
var maxFrameLength = 300;
|
|
2317
2425
|
var needsPaint = false;
|
|
2318
2426
|
|
|
2319
2427
|
if (enableIsInputPending && navigator !== undefined && navigator.scheduling !== undefined && navigator.scheduling.isInputPending !== undefined) {
|
|
2320
2428
|
var scheduling = navigator.scheduling;
|
|
2429
|
+
|
|
2321
2430
|
shouldYieldToHost = function () {
|
|
2322
2431
|
var currentTime = getCurrentTime();
|
|
2432
|
+
|
|
2323
2433
|
if (currentTime >= frameDeadline) {
|
|
2324
2434
|
// There's no time left in the frame. We may want to yield control of
|
|
2325
2435
|
// the main thread, so the browser can perform high priority tasks. The
|
|
@@ -2332,9 +2442,10 @@ typeof MessageChannel !== 'function') {
|
|
|
2332
2442
|
if (needsPaint || scheduling.isInputPending()) {
|
|
2333
2443
|
// There is either a pending paint or a pending input.
|
|
2334
2444
|
return true;
|
|
2335
|
-
}
|
|
2336
|
-
// There's no pending input. Only yield if we've reached the max
|
|
2445
|
+
} // There's no pending input. Only yield if we've reached the max
|
|
2337
2446
|
// frame length.
|
|
2447
|
+
|
|
2448
|
+
|
|
2338
2449
|
return currentTime >= frameDeadline + maxFrameLength;
|
|
2339
2450
|
} else {
|
|
2340
2451
|
// There's still time left in the frame.
|
|
@@ -2350,9 +2461,9 @@ typeof MessageChannel !== 'function') {
|
|
|
2350
2461
|
// there's pending input, always yield at the end of the frame.
|
|
2351
2462
|
shouldYieldToHost = function () {
|
|
2352
2463
|
return getCurrentTime() >= frameDeadline;
|
|
2353
|
-
};
|
|
2464
|
+
}; // Since we yield every frame regardless, `requestPaint` has no effect.
|
|
2465
|
+
|
|
2354
2466
|
|
|
2355
|
-
// Since we yield every frame regardless, `requestPaint` has no effect.
|
|
2356
2467
|
requestPaint = function () {};
|
|
2357
2468
|
}
|
|
2358
2469
|
|
|
@@ -2361,6 +2472,7 @@ typeof MessageChannel !== 'function') {
|
|
|
2361
2472
|
console.error('forceFrameRate takes a positive int between 0 and 125, ' + 'forcing framerates higher than 125 fps is not unsupported');
|
|
2362
2473
|
return;
|
|
2363
2474
|
}
|
|
2475
|
+
|
|
2364
2476
|
if (fps > 0) {
|
|
2365
2477
|
frameLength = Math.floor(1000 / fps);
|
|
2366
2478
|
fpsLocked = true;
|
|
@@ -2374,14 +2486,16 @@ typeof MessageChannel !== 'function') {
|
|
|
2374
2486
|
var performWorkUntilDeadline = function () {
|
|
2375
2487
|
if (enableMessageLoopImplementation) {
|
|
2376
2488
|
if (scheduledHostCallback !== null) {
|
|
2377
|
-
var currentTime = getCurrentTime();
|
|
2378
|
-
// Yield after `frameLength` ms, regardless of where we are in the vsync
|
|
2489
|
+
var currentTime = getCurrentTime(); // Yield after `frameLength` ms, regardless of where we are in the vsync
|
|
2379
2490
|
// cycle. This means there's always time remaining at the beginning of
|
|
2380
2491
|
// the message event.
|
|
2492
|
+
|
|
2381
2493
|
frameDeadline = currentTime + frameLength;
|
|
2382
2494
|
var hasTimeRemaining = true;
|
|
2495
|
+
|
|
2383
2496
|
try {
|
|
2384
2497
|
var hasMoreWork = scheduledHostCallback(hasTimeRemaining, currentTime);
|
|
2498
|
+
|
|
2385
2499
|
if (!hasMoreWork) {
|
|
2386
2500
|
isMessageLoopRunning = false;
|
|
2387
2501
|
scheduledHostCallback = null;
|
|
@@ -2396,16 +2510,22 @@ typeof MessageChannel !== 'function') {
|
|
|
2396
2510
|
port.postMessage(null);
|
|
2397
2511
|
throw error;
|
|
2398
2512
|
}
|
|
2399
|
-
}
|
|
2400
|
-
|
|
2513
|
+
} else {
|
|
2514
|
+
isMessageLoopRunning = false;
|
|
2515
|
+
} // Yielding to the browser will give it a chance to paint, so we can
|
|
2401
2516
|
// reset this.
|
|
2517
|
+
|
|
2518
|
+
|
|
2402
2519
|
needsPaint = false;
|
|
2403
2520
|
} else {
|
|
2404
2521
|
if (scheduledHostCallback !== null) {
|
|
2405
2522
|
var _currentTime = getCurrentTime();
|
|
2523
|
+
|
|
2406
2524
|
var _hasTimeRemaining = frameDeadline - _currentTime > 0;
|
|
2525
|
+
|
|
2407
2526
|
try {
|
|
2408
2527
|
var _hasMoreWork = scheduledHostCallback(_hasTimeRemaining, _currentTime);
|
|
2528
|
+
|
|
2409
2529
|
if (!_hasMoreWork) {
|
|
2410
2530
|
scheduledHostCallback = null;
|
|
2411
2531
|
}
|
|
@@ -2416,9 +2536,10 @@ typeof MessageChannel !== 'function') {
|
|
|
2416
2536
|
port.postMessage(null);
|
|
2417
2537
|
throw error;
|
|
2418
2538
|
}
|
|
2419
|
-
}
|
|
2420
|
-
// Yielding to the browser will give it a chance to paint, so we can
|
|
2539
|
+
} // Yielding to the browser will give it a chance to paint, so we can
|
|
2421
2540
|
// reset this.
|
|
2541
|
+
|
|
2542
|
+
|
|
2422
2543
|
needsPaint = false;
|
|
2423
2544
|
}
|
|
2424
2545
|
};
|
|
@@ -2434,9 +2555,7 @@ typeof MessageChannel !== 'function') {
|
|
|
2434
2555
|
prevRAFInterval = -1;
|
|
2435
2556
|
isRAFLoopRunning = false;
|
|
2436
2557
|
return;
|
|
2437
|
-
}
|
|
2438
|
-
|
|
2439
|
-
// Eagerly schedule the next animation callback at the beginning of the
|
|
2558
|
+
} // Eagerly schedule the next animation callback at the beginning of the
|
|
2440
2559
|
// frame. If the scheduler queue is not empty at the end of the frame, it
|
|
2441
2560
|
// will continue flushing inside that callback. If the queue *is* empty,
|
|
2442
2561
|
// then it will exit immediately. Posting the callback at the start of the
|
|
@@ -2444,27 +2563,30 @@ typeof MessageChannel !== 'function') {
|
|
|
2444
2563
|
// waited until the end of the frame to post the callback, we risk the
|
|
2445
2564
|
// browser skipping a frame and not firing the callback until the frame
|
|
2446
2565
|
// after that.
|
|
2566
|
+
|
|
2567
|
+
|
|
2447
2568
|
isRAFLoopRunning = true;
|
|
2448
2569
|
requestAnimationFrame(function (nextRAFTime) {
|
|
2449
2570
|
_clearTimeout(rAFTimeoutID);
|
|
2450
|
-
onAnimationFrame(nextRAFTime);
|
|
2451
|
-
});
|
|
2452
2571
|
|
|
2453
|
-
|
|
2572
|
+
onAnimationFrame(nextRAFTime);
|
|
2573
|
+
}); // requestAnimationFrame is throttled when the tab is backgrounded. We
|
|
2454
2574
|
// don't want to stop working entirely. So we'll fallback to a timeout loop.
|
|
2455
2575
|
// TODO: Need a better heuristic for backgrounded work.
|
|
2576
|
+
|
|
2456
2577
|
var onTimeout = function () {
|
|
2457
2578
|
frameDeadline = getCurrentTime() + frameLength / 2;
|
|
2458
2579
|
performWorkUntilDeadline();
|
|
2459
2580
|
rAFTimeoutID = _setTimeout(onTimeout, frameLength * 3);
|
|
2460
2581
|
};
|
|
2582
|
+
|
|
2461
2583
|
rAFTimeoutID = _setTimeout(onTimeout, frameLength * 3);
|
|
2462
2584
|
|
|
2463
|
-
if (prevRAFTime !== -1 &&
|
|
2464
|
-
// Make sure this rAF time is different from the previous one. This check
|
|
2585
|
+
if (prevRAFTime !== -1 && // Make sure this rAF time is different from the previous one. This check
|
|
2465
2586
|
// could fail if two rAFs fire in the same frame.
|
|
2466
2587
|
rAFTime - prevRAFTime > 0.1) {
|
|
2467
2588
|
var rAFInterval = rAFTime - prevRAFTime;
|
|
2589
|
+
|
|
2468
2590
|
if (!fpsLocked && prevRAFInterval !== -1) {
|
|
2469
2591
|
// We've observed two consecutive frame intervals. We'll use this to
|
|
2470
2592
|
// dynamically adjust the frame rate.
|
|
@@ -2477,6 +2599,7 @@ typeof MessageChannel !== 'function') {
|
|
|
2477
2599
|
// due to missed frame deadlines.
|
|
2478
2600
|
if (rAFInterval < frameLength && prevRAFInterval < frameLength) {
|
|
2479
2601
|
frameLength = rAFInterval < prevRAFInterval ? prevRAFInterval : rAFInterval;
|
|
2602
|
+
|
|
2480
2603
|
if (frameLength < 8.33) {
|
|
2481
2604
|
// Defensive coding. We don't support higher frame rates than 120hz.
|
|
2482
2605
|
// If the calculated frame length gets lower than 8, it is probably
|
|
@@ -2485,17 +2608,19 @@ typeof MessageChannel !== 'function') {
|
|
|
2485
2608
|
}
|
|
2486
2609
|
}
|
|
2487
2610
|
}
|
|
2611
|
+
|
|
2488
2612
|
prevRAFInterval = rAFInterval;
|
|
2489
2613
|
}
|
|
2614
|
+
|
|
2490
2615
|
prevRAFTime = rAFTime;
|
|
2491
|
-
frameDeadline = rAFTime + frameLength;
|
|
2616
|
+
frameDeadline = rAFTime + frameLength; // We use the postMessage trick to defer idle work until after the repaint.
|
|
2492
2617
|
|
|
2493
|
-
// We use the postMessage trick to defer idle work until after the repaint.
|
|
2494
2618
|
port.postMessage(null);
|
|
2495
2619
|
};
|
|
2496
2620
|
|
|
2497
2621
|
requestHostCallback = function (callback) {
|
|
2498
2622
|
scheduledHostCallback = callback;
|
|
2623
|
+
|
|
2499
2624
|
if (enableMessageLoopImplementation) {
|
|
2500
2625
|
if (!isMessageLoopRunning) {
|
|
2501
2626
|
isMessageLoopRunning = true;
|
|
@@ -2506,48 +2631,8 @@ typeof MessageChannel !== 'function') {
|
|
|
2506
2631
|
// Start a rAF loop.
|
|
2507
2632
|
isRAFLoopRunning = true;
|
|
2508
2633
|
requestAnimationFrame(function (rAFTime) {
|
|
2509
|
-
if (requestIdleCallbackBeforeFirstFrame$1) {
|
|
2510
|
-
cancelIdleCallback(idleCallbackID);
|
|
2511
|
-
}
|
|
2512
|
-
if (requestTimerEventBeforeFirstFrame) {
|
|
2513
|
-
_clearTimeout(idleTimeoutID);
|
|
2514
|
-
}
|
|
2515
2634
|
onAnimationFrame(rAFTime);
|
|
2516
2635
|
});
|
|
2517
|
-
|
|
2518
|
-
// If we just missed the last vsync, the next rAF might not happen for
|
|
2519
|
-
// another frame. To claim as much idle time as possible, post a
|
|
2520
|
-
// callback with `requestIdleCallback`, which should fire if there's
|
|
2521
|
-
// idle time left in the frame.
|
|
2522
|
-
//
|
|
2523
|
-
// This should only be an issue for the first rAF in the loop;
|
|
2524
|
-
// subsequent rAFs are scheduled at the beginning of the
|
|
2525
|
-
// preceding frame.
|
|
2526
|
-
var idleCallbackID = void 0;
|
|
2527
|
-
if (requestIdleCallbackBeforeFirstFrame$1) {
|
|
2528
|
-
idleCallbackID = requestIdleCallback(function onIdleCallbackBeforeFirstFrame() {
|
|
2529
|
-
if (requestTimerEventBeforeFirstFrame) {
|
|
2530
|
-
_clearTimeout(idleTimeoutID);
|
|
2531
|
-
}
|
|
2532
|
-
frameDeadline = getCurrentTime() + frameLength;
|
|
2533
|
-
performWorkUntilDeadline();
|
|
2534
|
-
});
|
|
2535
|
-
}
|
|
2536
|
-
// Alternate strategy to address the same problem. Scheduler a timer
|
|
2537
|
-
// with no delay. If this fires before the rAF, that likely indicates
|
|
2538
|
-
// that there's idle time before the next vsync. This isn't always the
|
|
2539
|
-
// case, but we'll be aggressive and assume it is, as a trade off to
|
|
2540
|
-
// prevent idle periods.
|
|
2541
|
-
var idleTimeoutID = void 0;
|
|
2542
|
-
if (requestTimerEventBeforeFirstFrame) {
|
|
2543
|
-
idleTimeoutID = _setTimeout(function onTimerEventBeforeFirstFrame() {
|
|
2544
|
-
if (requestIdleCallbackBeforeFirstFrame$1) {
|
|
2545
|
-
cancelIdleCallback(idleCallbackID);
|
|
2546
|
-
}
|
|
2547
|
-
frameDeadline = getCurrentTime() + frameLength;
|
|
2548
|
-
performWorkUntilDeadline();
|
|
2549
|
-
}, 0);
|
|
2550
|
-
}
|
|
2551
2636
|
}
|
|
2552
2637
|
}
|
|
2553
2638
|
};
|
|
@@ -2560,178 +2645,312 @@ typeof MessageChannel !== 'function') {
|
|
|
2560
2645
|
|
|
2561
2646
|
cancelHostTimeout = function () {
|
|
2562
2647
|
_clearTimeout(taskTimeoutID);
|
|
2648
|
+
|
|
2563
2649
|
taskTimeoutID = -1;
|
|
2564
2650
|
};
|
|
2565
2651
|
}
|
|
2566
2652
|
|
|
2567
|
-
|
|
2653
|
+
function push(heap, node) {
|
|
2654
|
+
var index = heap.length;
|
|
2655
|
+
heap.push(node);
|
|
2656
|
+
siftUp(heap, node, index);
|
|
2657
|
+
}
|
|
2658
|
+
function peek(heap) {
|
|
2659
|
+
var first = heap[0];
|
|
2660
|
+
return first === undefined ? null : first;
|
|
2661
|
+
}
|
|
2662
|
+
function pop(heap) {
|
|
2663
|
+
var first = heap[0];
|
|
2664
|
+
|
|
2665
|
+
if (first !== undefined) {
|
|
2666
|
+
var last = heap.pop();
|
|
2667
|
+
|
|
2668
|
+
if (last !== first) {
|
|
2669
|
+
heap[0] = last;
|
|
2670
|
+
siftDown(heap, last, 0);
|
|
2671
|
+
}
|
|
2672
|
+
|
|
2673
|
+
return first;
|
|
2674
|
+
} else {
|
|
2675
|
+
return null;
|
|
2676
|
+
}
|
|
2677
|
+
}
|
|
2678
|
+
|
|
2679
|
+
function siftUp(heap, node, i) {
|
|
2680
|
+
var index = i;
|
|
2681
|
+
|
|
2682
|
+
while (true) {
|
|
2683
|
+
var parentIndex = Math.floor((index - 1) / 2);
|
|
2684
|
+
var parent = heap[parentIndex];
|
|
2685
|
+
|
|
2686
|
+
if (parent !== undefined && compare(parent, node) > 0) {
|
|
2687
|
+
// The parent is larger. Swap positions.
|
|
2688
|
+
heap[parentIndex] = node;
|
|
2689
|
+
heap[index] = parent;
|
|
2690
|
+
index = parentIndex;
|
|
2691
|
+
} else {
|
|
2692
|
+
// The parent is smaller. Exit.
|
|
2693
|
+
return;
|
|
2694
|
+
}
|
|
2695
|
+
}
|
|
2696
|
+
}
|
|
2697
|
+
|
|
2698
|
+
function siftDown(heap, node, i) {
|
|
2699
|
+
var index = i;
|
|
2700
|
+
var length = heap.length;
|
|
2701
|
+
|
|
2702
|
+
while (index < length) {
|
|
2703
|
+
var leftIndex = (index + 1) * 2 - 1;
|
|
2704
|
+
var left = heap[leftIndex];
|
|
2705
|
+
var rightIndex = leftIndex + 1;
|
|
2706
|
+
var right = heap[rightIndex]; // If the left or right node is smaller, swap with the smaller of those.
|
|
2707
|
+
|
|
2708
|
+
if (left !== undefined && compare(left, node) < 0) {
|
|
2709
|
+
if (right !== undefined && compare(right, left) < 0) {
|
|
2710
|
+
heap[index] = right;
|
|
2711
|
+
heap[rightIndex] = node;
|
|
2712
|
+
index = rightIndex;
|
|
2713
|
+
} else {
|
|
2714
|
+
heap[index] = left;
|
|
2715
|
+
heap[leftIndex] = node;
|
|
2716
|
+
index = leftIndex;
|
|
2717
|
+
}
|
|
2718
|
+
} else if (right !== undefined && compare(right, node) < 0) {
|
|
2719
|
+
heap[index] = right;
|
|
2720
|
+
heap[rightIndex] = node;
|
|
2721
|
+
index = rightIndex;
|
|
2722
|
+
} else {
|
|
2723
|
+
// Neither child is smaller. Exit.
|
|
2724
|
+
return;
|
|
2725
|
+
}
|
|
2726
|
+
}
|
|
2727
|
+
}
|
|
2728
|
+
|
|
2729
|
+
function compare(a, b) {
|
|
2730
|
+
// Compare sort index first, then task id.
|
|
2731
|
+
var diff = a.sortIndex - b.sortIndex;
|
|
2732
|
+
return diff !== 0 ? diff : a.id - b.id;
|
|
2733
|
+
}
|
|
2568
2734
|
|
|
2569
2735
|
// TODO: Use symbols?
|
|
2736
|
+
var NoPriority = 0;
|
|
2570
2737
|
var ImmediatePriority = 1;
|
|
2571
2738
|
var UserBlockingPriority = 2;
|
|
2572
2739
|
var NormalPriority = 3;
|
|
2573
2740
|
var LowPriority = 4;
|
|
2574
2741
|
var IdlePriority = 5;
|
|
2575
2742
|
|
|
2576
|
-
|
|
2577
|
-
|
|
2578
|
-
|
|
2579
|
-
var
|
|
2580
|
-
|
|
2581
|
-
//
|
|
2582
|
-
|
|
2583
|
-
//
|
|
2584
|
-
|
|
2585
|
-
var
|
|
2586
|
-
var
|
|
2587
|
-
|
|
2588
|
-
var
|
|
2589
|
-
|
|
2590
|
-
|
|
2591
|
-
|
|
2592
|
-
|
|
2593
|
-
|
|
2594
|
-
|
|
2595
|
-
|
|
2596
|
-
|
|
2597
|
-
|
|
2598
|
-
|
|
2743
|
+
var runIdCounter = 0;
|
|
2744
|
+
var mainThreadIdCounter = 0;
|
|
2745
|
+
var profilingStateSize = 4;
|
|
2746
|
+
var sharedProfilingBuffer = enableProfiling ? // $FlowFixMe Flow doesn't know about SharedArrayBuffer
|
|
2747
|
+
typeof SharedArrayBuffer === 'function' ? new SharedArrayBuffer(profilingStateSize * Int32Array.BYTES_PER_ELEMENT) : // $FlowFixMe Flow doesn't know about ArrayBuffer
|
|
2748
|
+
typeof ArrayBuffer === 'function' ? new ArrayBuffer(profilingStateSize * Int32Array.BYTES_PER_ELEMENT) : null // Don't crash the init path on IE9
|
|
2749
|
+
: null;
|
|
2750
|
+
var profilingState = enableProfiling && sharedProfilingBuffer !== null ? new Int32Array(sharedProfilingBuffer) : []; // We can't read this but it helps save bytes for null checks
|
|
2751
|
+
|
|
2752
|
+
var PRIORITY = 0;
|
|
2753
|
+
var CURRENT_TASK_ID = 1;
|
|
2754
|
+
var CURRENT_RUN_ID = 2;
|
|
2755
|
+
var QUEUE_SIZE = 3;
|
|
2756
|
+
|
|
2757
|
+
if (enableProfiling) {
|
|
2758
|
+
profilingState[PRIORITY] = NoPriority; // This is maintained with a counter, because the size of the priority queue
|
|
2759
|
+
// array might include canceled tasks.
|
|
2760
|
+
|
|
2761
|
+
profilingState[QUEUE_SIZE] = 0;
|
|
2762
|
+
profilingState[CURRENT_TASK_ID] = 0;
|
|
2763
|
+
} // Bytes per element is 4
|
|
2764
|
+
|
|
2765
|
+
|
|
2766
|
+
var INITIAL_EVENT_LOG_SIZE = 131072;
|
|
2767
|
+
var MAX_EVENT_LOG_SIZE = 524288; // Equivalent to 2 megabytes
|
|
2768
|
+
|
|
2769
|
+
var eventLogSize = 0;
|
|
2770
|
+
var eventLogBuffer = null;
|
|
2771
|
+
var eventLog = null;
|
|
2772
|
+
var eventLogIndex = 0;
|
|
2773
|
+
var TaskStartEvent = 1;
|
|
2774
|
+
var TaskCompleteEvent = 2;
|
|
2775
|
+
var TaskErrorEvent = 3;
|
|
2776
|
+
var TaskCancelEvent = 4;
|
|
2777
|
+
var TaskRunEvent = 5;
|
|
2778
|
+
var TaskYieldEvent = 6;
|
|
2779
|
+
var SchedulerSuspendEvent = 7;
|
|
2780
|
+
var SchedulerResumeEvent = 8;
|
|
2781
|
+
|
|
2782
|
+
function logEvent(entries) {
|
|
2783
|
+
if (eventLog !== null) {
|
|
2784
|
+
var offset = eventLogIndex;
|
|
2785
|
+
eventLogIndex += entries.length;
|
|
2786
|
+
|
|
2787
|
+
if (eventLogIndex + 1 > eventLogSize) {
|
|
2788
|
+
eventLogSize *= 2;
|
|
2789
|
+
|
|
2790
|
+
if (eventLogSize > MAX_EVENT_LOG_SIZE) {
|
|
2791
|
+
console.error("Scheduler Profiling: Event log exceeded maximum size. Don't " + 'forget to call `stopLoggingProfilingEvents()`.');
|
|
2792
|
+
stopLoggingProfilingEvents();
|
|
2793
|
+
return;
|
|
2794
|
+
}
|
|
2599
2795
|
|
|
2600
|
-
|
|
2601
|
-
|
|
2796
|
+
var newEventLog = new Int32Array(eventLogSize * 4);
|
|
2797
|
+
newEventLog.set(eventLog);
|
|
2798
|
+
eventLogBuffer = newEventLog.buffer;
|
|
2799
|
+
eventLog = newEventLog;
|
|
2800
|
+
}
|
|
2602
2801
|
|
|
2603
|
-
|
|
2604
|
-
|
|
2802
|
+
eventLog.set(entries, offset);
|
|
2803
|
+
}
|
|
2804
|
+
}
|
|
2605
2805
|
|
|
2606
|
-
function
|
|
2607
|
-
|
|
2806
|
+
function startLoggingProfilingEvents() {
|
|
2807
|
+
eventLogSize = INITIAL_EVENT_LOG_SIZE;
|
|
2808
|
+
eventLogBuffer = new ArrayBuffer(eventLogSize * 4);
|
|
2809
|
+
eventLog = new Int32Array(eventLogBuffer);
|
|
2810
|
+
eventLogIndex = 0;
|
|
2608
2811
|
}
|
|
2609
|
-
function
|
|
2610
|
-
|
|
2812
|
+
function stopLoggingProfilingEvents() {
|
|
2813
|
+
var buffer = eventLogBuffer;
|
|
2814
|
+
eventLogSize = 0;
|
|
2815
|
+
eventLogBuffer = null;
|
|
2816
|
+
eventLog = null;
|
|
2817
|
+
eventLogIndex = 0;
|
|
2818
|
+
return buffer;
|
|
2611
2819
|
}
|
|
2612
|
-
function
|
|
2613
|
-
|
|
2820
|
+
function markTaskStart(task, ms) {
|
|
2821
|
+
if (enableProfiling) {
|
|
2822
|
+
profilingState[QUEUE_SIZE]++;
|
|
2823
|
+
|
|
2824
|
+
if (eventLog !== null) {
|
|
2825
|
+
// performance.now returns a float, representing milliseconds. When the
|
|
2826
|
+
// event is logged, it's coerced to an int. Convert to microseconds to
|
|
2827
|
+
// maintain extra degrees of precision.
|
|
2828
|
+
logEvent([TaskStartEvent, ms * 1000, task.id, task.priorityLevel]);
|
|
2829
|
+
}
|
|
2830
|
+
}
|
|
2614
2831
|
}
|
|
2615
|
-
function
|
|
2616
|
-
|
|
2832
|
+
function markTaskCompleted(task, ms) {
|
|
2833
|
+
if (enableProfiling) {
|
|
2834
|
+
profilingState[PRIORITY] = NoPriority;
|
|
2835
|
+
profilingState[CURRENT_TASK_ID] = 0;
|
|
2836
|
+
profilingState[QUEUE_SIZE]--;
|
|
2837
|
+
|
|
2838
|
+
if (eventLog !== null) {
|
|
2839
|
+
logEvent([TaskCompleteEvent, ms * 1000, task.id]);
|
|
2840
|
+
}
|
|
2841
|
+
}
|
|
2617
2842
|
}
|
|
2618
|
-
function
|
|
2619
|
-
|
|
2843
|
+
function markTaskCanceled(task, ms) {
|
|
2844
|
+
if (enableProfiling) {
|
|
2845
|
+
profilingState[QUEUE_SIZE]--;
|
|
2846
|
+
|
|
2847
|
+
if (eventLog !== null) {
|
|
2848
|
+
logEvent([TaskCancelEvent, ms * 1000, task.id]);
|
|
2849
|
+
}
|
|
2850
|
+
}
|
|
2620
2851
|
}
|
|
2852
|
+
function markTaskErrored(task, ms) {
|
|
2853
|
+
if (enableProfiling) {
|
|
2854
|
+
profilingState[PRIORITY] = NoPriority;
|
|
2855
|
+
profilingState[CURRENT_TASK_ID] = 0;
|
|
2856
|
+
profilingState[QUEUE_SIZE]--;
|
|
2621
2857
|
|
|
2622
|
-
|
|
2623
|
-
|
|
2624
|
-
// list is in a consistent state even if the callback throws.
|
|
2625
|
-
var next = task.next;
|
|
2626
|
-
if (next === task) {
|
|
2627
|
-
// This is the only scheduled task. Clear the list.
|
|
2628
|
-
firstTask = null;
|
|
2629
|
-
} else {
|
|
2630
|
-
// Remove the task from its position in the list.
|
|
2631
|
-
if (task === firstTask) {
|
|
2632
|
-
firstTask = next;
|
|
2858
|
+
if (eventLog !== null) {
|
|
2859
|
+
logEvent([TaskErrorEvent, ms * 1000, task.id]);
|
|
2633
2860
|
}
|
|
2634
|
-
var previous = task.previous;
|
|
2635
|
-
previous.next = next;
|
|
2636
|
-
next.previous = previous;
|
|
2637
2861
|
}
|
|
2638
|
-
|
|
2862
|
+
}
|
|
2863
|
+
function markTaskRun(task, ms) {
|
|
2864
|
+
if (enableProfiling) {
|
|
2865
|
+
runIdCounter++;
|
|
2866
|
+
profilingState[PRIORITY] = task.priorityLevel;
|
|
2867
|
+
profilingState[CURRENT_TASK_ID] = task.id;
|
|
2868
|
+
profilingState[CURRENT_RUN_ID] = runIdCounter;
|
|
2639
2869
|
|
|
2640
|
-
|
|
2641
|
-
|
|
2642
|
-
var previousPriorityLevel = currentPriorityLevel;
|
|
2643
|
-
var previousTask = currentTask;
|
|
2644
|
-
currentPriorityLevel = task.priorityLevel;
|
|
2645
|
-
currentTask = task;
|
|
2646
|
-
var continuationCallback;
|
|
2647
|
-
try {
|
|
2648
|
-
var didUserCallbackTimeout = task.expirationTime <= currentTime;
|
|
2649
|
-
// Add an extra function to the callstack. Profiling tools can use this
|
|
2650
|
-
// to infer the priority of work that appears higher in the stack.
|
|
2651
|
-
switch (currentPriorityLevel) {
|
|
2652
|
-
case ImmediatePriority:
|
|
2653
|
-
continuationCallback = scheduler_flushTaskAtPriority_Immediate(callback, didUserCallbackTimeout);
|
|
2654
|
-
break;
|
|
2655
|
-
case UserBlockingPriority:
|
|
2656
|
-
continuationCallback = scheduler_flushTaskAtPriority_UserBlocking(callback, didUserCallbackTimeout);
|
|
2657
|
-
break;
|
|
2658
|
-
case NormalPriority:
|
|
2659
|
-
continuationCallback = scheduler_flushTaskAtPriority_Normal(callback, didUserCallbackTimeout);
|
|
2660
|
-
break;
|
|
2661
|
-
case LowPriority:
|
|
2662
|
-
continuationCallback = scheduler_flushTaskAtPriority_Low(callback, didUserCallbackTimeout);
|
|
2663
|
-
break;
|
|
2664
|
-
case IdlePriority:
|
|
2665
|
-
continuationCallback = scheduler_flushTaskAtPriority_Idle(callback, didUserCallbackTimeout);
|
|
2666
|
-
break;
|
|
2870
|
+
if (eventLog !== null) {
|
|
2871
|
+
logEvent([TaskRunEvent, ms * 1000, task.id, runIdCounter]);
|
|
2667
2872
|
}
|
|
2668
|
-
}
|
|
2669
|
-
|
|
2670
|
-
|
|
2671
|
-
|
|
2672
|
-
|
|
2673
|
-
|
|
2674
|
-
|
|
2675
|
-
// A callback may return a continuation. The continuation should be scheduled
|
|
2676
|
-
// with the same priority and expiration as the just-finished callback.
|
|
2677
|
-
if (typeof continuationCallback === 'function') {
|
|
2678
|
-
var expirationTime = task.expirationTime;
|
|
2679
|
-
var continuationTask = task;
|
|
2680
|
-
continuationTask.callback = continuationCallback;
|
|
2681
|
-
|
|
2682
|
-
// Insert the new callback into the list, sorted by its timeout. This is
|
|
2683
|
-
// almost the same as the code in `scheduleCallback`, except the callback
|
|
2684
|
-
// is inserted into the list *before* callbacks of equal timeout instead
|
|
2685
|
-
// of after.
|
|
2686
|
-
if (firstTask === null) {
|
|
2687
|
-
// This is the first callback in the list.
|
|
2688
|
-
firstTask = continuationTask.next = continuationTask.previous = continuationTask;
|
|
2689
|
-
} else {
|
|
2690
|
-
var nextAfterContinuation = null;
|
|
2691
|
-
var t = firstTask;
|
|
2692
|
-
do {
|
|
2693
|
-
if (expirationTime <= t.expirationTime) {
|
|
2694
|
-
// This task times out at or after the continuation. We will insert
|
|
2695
|
-
// the continuation *before* this task.
|
|
2696
|
-
nextAfterContinuation = t;
|
|
2697
|
-
break;
|
|
2698
|
-
}
|
|
2699
|
-
t = t.next;
|
|
2700
|
-
} while (t !== firstTask);
|
|
2701
|
-
if (nextAfterContinuation === null) {
|
|
2702
|
-
// No equal or lower priority task was found, which means the new task
|
|
2703
|
-
// is the lowest priority task in the list.
|
|
2704
|
-
nextAfterContinuation = firstTask;
|
|
2705
|
-
} else if (nextAfterContinuation === firstTask) {
|
|
2706
|
-
// The new task is the highest priority task in the list.
|
|
2707
|
-
firstTask = continuationTask;
|
|
2708
|
-
}
|
|
2873
|
+
}
|
|
2874
|
+
}
|
|
2875
|
+
function markTaskYield(task, ms) {
|
|
2876
|
+
if (enableProfiling) {
|
|
2877
|
+
profilingState[PRIORITY] = NoPriority;
|
|
2878
|
+
profilingState[CURRENT_TASK_ID] = 0;
|
|
2879
|
+
profilingState[CURRENT_RUN_ID] = 0;
|
|
2709
2880
|
|
|
2710
|
-
|
|
2711
|
-
|
|
2712
|
-
continuationTask.next = nextAfterContinuation;
|
|
2713
|
-
continuationTask.previous = _previous;
|
|
2881
|
+
if (eventLog !== null) {
|
|
2882
|
+
logEvent([TaskYieldEvent, ms * 1000, task.id, runIdCounter]);
|
|
2714
2883
|
}
|
|
2715
2884
|
}
|
|
2716
2885
|
}
|
|
2886
|
+
function markSchedulerSuspended(ms) {
|
|
2887
|
+
if (enableProfiling) {
|
|
2888
|
+
mainThreadIdCounter++;
|
|
2889
|
+
|
|
2890
|
+
if (eventLog !== null) {
|
|
2891
|
+
logEvent([SchedulerSuspendEvent, ms * 1000, mainThreadIdCounter]);
|
|
2892
|
+
}
|
|
2893
|
+
}
|
|
2894
|
+
}
|
|
2895
|
+
function markSchedulerUnsuspended(ms) {
|
|
2896
|
+
if (enableProfiling) {
|
|
2897
|
+
if (eventLog !== null) {
|
|
2898
|
+
logEvent([SchedulerResumeEvent, ms * 1000, mainThreadIdCounter]);
|
|
2899
|
+
}
|
|
2900
|
+
}
|
|
2901
|
+
}
|
|
2902
|
+
|
|
2903
|
+
/* eslint-disable no-var */
|
|
2904
|
+
// Math.pow(2, 30) - 1
|
|
2905
|
+
// 0b111111111111111111111111111111
|
|
2906
|
+
|
|
2907
|
+
var maxSigned31BitInt = 1073741823; // Times out immediately
|
|
2908
|
+
|
|
2909
|
+
var IMMEDIATE_PRIORITY_TIMEOUT = -1; // Eventually times out
|
|
2910
|
+
|
|
2911
|
+
var USER_BLOCKING_PRIORITY = 250;
|
|
2912
|
+
var NORMAL_PRIORITY_TIMEOUT = 5000;
|
|
2913
|
+
var LOW_PRIORITY_TIMEOUT = 10000; // Never times out
|
|
2914
|
+
|
|
2915
|
+
var IDLE_PRIORITY = maxSigned31BitInt; // Tasks are stored on a min heap
|
|
2916
|
+
|
|
2917
|
+
var taskQueue = [];
|
|
2918
|
+
var timerQueue = []; // Incrementing id counter. Used to maintain insertion order.
|
|
2919
|
+
|
|
2920
|
+
var taskIdCounter = 1; // Pausing the scheduler is useful for debugging.
|
|
2921
|
+
|
|
2922
|
+
var isSchedulerPaused = false;
|
|
2923
|
+
var currentTask = null;
|
|
2924
|
+
var currentPriorityLevel = NormalPriority; // This is set while performing work, to prevent re-entrancy.
|
|
2925
|
+
|
|
2926
|
+
var isPerformingWork = false;
|
|
2927
|
+
var isHostCallbackScheduled = false;
|
|
2928
|
+
var isHostTimeoutScheduled = false;
|
|
2717
2929
|
|
|
2718
2930
|
function advanceTimers(currentTime) {
|
|
2719
2931
|
// Check for tasks that are no longer delayed and add them to the queue.
|
|
2720
|
-
|
|
2721
|
-
|
|
2722
|
-
|
|
2723
|
-
|
|
2724
|
-
|
|
2725
|
-
|
|
2726
|
-
|
|
2727
|
-
|
|
2728
|
-
|
|
2729
|
-
|
|
2730
|
-
|
|
2932
|
+
var timer = peek(timerQueue);
|
|
2933
|
+
|
|
2934
|
+
while (timer !== null) {
|
|
2935
|
+
if (timer.callback === null) {
|
|
2936
|
+
// Timer was cancelled.
|
|
2937
|
+
pop(timerQueue);
|
|
2938
|
+
} else if (timer.startTime <= currentTime) {
|
|
2939
|
+
// Timer fired. Transfer to the task queue.
|
|
2940
|
+
pop(timerQueue);
|
|
2941
|
+
timer.sortIndex = timer.expirationTime;
|
|
2942
|
+
push(taskQueue, timer);
|
|
2943
|
+
|
|
2944
|
+
if (enableProfiling) {
|
|
2945
|
+
markTaskStart(timer, currentTime);
|
|
2946
|
+
timer.isQueued = true;
|
|
2731
2947
|
}
|
|
2732
|
-
|
|
2733
|
-
|
|
2734
|
-
|
|
2948
|
+
} else {
|
|
2949
|
+
// Remaining timers are pending.
|
|
2950
|
+
return;
|
|
2951
|
+
}
|
|
2952
|
+
|
|
2953
|
+
timer = peek(timerQueue);
|
|
2735
2954
|
}
|
|
2736
2955
|
}
|
|
2737
2956
|
|
|
@@ -2740,64 +2959,120 @@ function handleTimeout(currentTime) {
|
|
|
2740
2959
|
advanceTimers(currentTime);
|
|
2741
2960
|
|
|
2742
2961
|
if (!isHostCallbackScheduled) {
|
|
2743
|
-
if (
|
|
2962
|
+
if (peek(taskQueue) !== null) {
|
|
2744
2963
|
isHostCallbackScheduled = true;
|
|
2745
2964
|
requestHostCallback(flushWork);
|
|
2746
|
-
} else
|
|
2747
|
-
|
|
2965
|
+
} else {
|
|
2966
|
+
var firstTimer = peek(timerQueue);
|
|
2967
|
+
|
|
2968
|
+
if (firstTimer !== null) {
|
|
2969
|
+
requestHostTimeout(handleTimeout, firstTimer.startTime - currentTime);
|
|
2970
|
+
}
|
|
2748
2971
|
}
|
|
2749
2972
|
}
|
|
2750
2973
|
}
|
|
2751
2974
|
|
|
2752
2975
|
function flushWork(hasTimeRemaining, initialTime) {
|
|
2753
|
-
|
|
2754
|
-
|
|
2755
|
-
|
|
2756
|
-
|
|
2976
|
+
if (enableProfiling) {
|
|
2977
|
+
markSchedulerUnsuspended(initialTime);
|
|
2978
|
+
} // We'll need a host callback the next time work is scheduled.
|
|
2979
|
+
|
|
2757
2980
|
|
|
2758
|
-
// We'll need a host callback the next time work is scheduled.
|
|
2759
2981
|
isHostCallbackScheduled = false;
|
|
2982
|
+
|
|
2760
2983
|
if (isHostTimeoutScheduled) {
|
|
2761
2984
|
// We scheduled a timeout but it's no longer needed. Cancel it.
|
|
2762
2985
|
isHostTimeoutScheduled = false;
|
|
2763
2986
|
cancelHostTimeout();
|
|
2764
2987
|
}
|
|
2765
2988
|
|
|
2766
|
-
var currentTime = initialTime;
|
|
2767
|
-
advanceTimers(currentTime);
|
|
2768
|
-
|
|
2769
2989
|
isPerformingWork = true;
|
|
2990
|
+
var previousPriorityLevel = currentPriorityLevel;
|
|
2991
|
+
|
|
2770
2992
|
try {
|
|
2771
|
-
if (
|
|
2772
|
-
|
|
2773
|
-
|
|
2774
|
-
|
|
2775
|
-
|
|
2776
|
-
|
|
2777
|
-
|
|
2778
|
-
|
|
2779
|
-
|
|
2780
|
-
|
|
2781
|
-
|
|
2782
|
-
if (firstTask !== null) {
|
|
2783
|
-
do {
|
|
2784
|
-
flushTask(firstTask, currentTime);
|
|
2785
|
-
currentTime = getCurrentTime();
|
|
2786
|
-
advanceTimers(currentTime);
|
|
2787
|
-
} while (firstTask !== null && !shouldYieldToHost() && !(enableSchedulerDebugging && isSchedulerPaused));
|
|
2993
|
+
if (enableProfiling) {
|
|
2994
|
+
try {
|
|
2995
|
+
return workLoop(hasTimeRemaining, initialTime);
|
|
2996
|
+
} catch (error) {
|
|
2997
|
+
if (currentTask !== null) {
|
|
2998
|
+
var currentTime = getCurrentTime();
|
|
2999
|
+
markTaskErrored(currentTask, currentTime);
|
|
3000
|
+
currentTask.isQueued = false;
|
|
3001
|
+
}
|
|
3002
|
+
|
|
3003
|
+
throw error;
|
|
2788
3004
|
}
|
|
2789
|
-
}
|
|
2790
|
-
// Return whether there's additional work
|
|
2791
|
-
if (firstTask !== null) {
|
|
2792
|
-
return true;
|
|
2793
3005
|
} else {
|
|
2794
|
-
|
|
2795
|
-
|
|
2796
|
-
}
|
|
2797
|
-
return false;
|
|
3006
|
+
// No catch in prod codepath.
|
|
3007
|
+
return workLoop(hasTimeRemaining, initialTime);
|
|
2798
3008
|
}
|
|
2799
3009
|
} finally {
|
|
3010
|
+
currentTask = null;
|
|
3011
|
+
currentPriorityLevel = previousPriorityLevel;
|
|
2800
3012
|
isPerformingWork = false;
|
|
3013
|
+
|
|
3014
|
+
if (enableProfiling) {
|
|
3015
|
+
var _currentTime = getCurrentTime();
|
|
3016
|
+
|
|
3017
|
+
markSchedulerSuspended(_currentTime);
|
|
3018
|
+
}
|
|
3019
|
+
}
|
|
3020
|
+
}
|
|
3021
|
+
|
|
3022
|
+
function workLoop(hasTimeRemaining, initialTime) {
|
|
3023
|
+
var currentTime = initialTime;
|
|
3024
|
+
advanceTimers(currentTime);
|
|
3025
|
+
currentTask = peek(taskQueue);
|
|
3026
|
+
|
|
3027
|
+
while (currentTask !== null && !(enableSchedulerDebugging && isSchedulerPaused)) {
|
|
3028
|
+
if (currentTask.expirationTime > currentTime && (!hasTimeRemaining || shouldYieldToHost())) {
|
|
3029
|
+
// This currentTask hasn't expired, and we've reached the deadline.
|
|
3030
|
+
break;
|
|
3031
|
+
}
|
|
3032
|
+
|
|
3033
|
+
var callback = currentTask.callback;
|
|
3034
|
+
|
|
3035
|
+
if (callback !== null) {
|
|
3036
|
+
currentTask.callback = null;
|
|
3037
|
+
currentPriorityLevel = currentTask.priorityLevel;
|
|
3038
|
+
var didUserCallbackTimeout = currentTask.expirationTime <= currentTime;
|
|
3039
|
+
markTaskRun(currentTask, currentTime);
|
|
3040
|
+
var continuationCallback = callback(didUserCallbackTimeout);
|
|
3041
|
+
currentTime = getCurrentTime();
|
|
3042
|
+
|
|
3043
|
+
if (typeof continuationCallback === 'function') {
|
|
3044
|
+
currentTask.callback = continuationCallback;
|
|
3045
|
+
markTaskYield(currentTask, currentTime);
|
|
3046
|
+
} else {
|
|
3047
|
+
if (enableProfiling) {
|
|
3048
|
+
markTaskCompleted(currentTask, currentTime);
|
|
3049
|
+
currentTask.isQueued = false;
|
|
3050
|
+
}
|
|
3051
|
+
|
|
3052
|
+
if (currentTask === peek(taskQueue)) {
|
|
3053
|
+
pop(taskQueue);
|
|
3054
|
+
}
|
|
3055
|
+
}
|
|
3056
|
+
|
|
3057
|
+
advanceTimers(currentTime);
|
|
3058
|
+
} else {
|
|
3059
|
+
pop(taskQueue);
|
|
3060
|
+
}
|
|
3061
|
+
|
|
3062
|
+
currentTask = peek(taskQueue);
|
|
3063
|
+
} // Return whether there's additional work
|
|
3064
|
+
|
|
3065
|
+
|
|
3066
|
+
if (currentTask !== null) {
|
|
3067
|
+
return true;
|
|
3068
|
+
} else {
|
|
3069
|
+
var firstTimer = peek(timerQueue);
|
|
3070
|
+
|
|
3071
|
+
if (firstTimer !== null) {
|
|
3072
|
+
requestHostTimeout(handleTimeout, firstTimer.startTime - currentTime);
|
|
3073
|
+
}
|
|
3074
|
+
|
|
3075
|
+
return false;
|
|
2801
3076
|
}
|
|
2802
3077
|
}
|
|
2803
3078
|
|
|
@@ -2809,6 +3084,7 @@ function unstable_runWithPriority(priorityLevel, eventHandler) {
|
|
|
2809
3084
|
case LowPriority:
|
|
2810
3085
|
case IdlePriority:
|
|
2811
3086
|
break;
|
|
3087
|
+
|
|
2812
3088
|
default:
|
|
2813
3089
|
priorityLevel = NormalPriority;
|
|
2814
3090
|
}
|
|
@@ -2825,6 +3101,7 @@ function unstable_runWithPriority(priorityLevel, eventHandler) {
|
|
|
2825
3101
|
|
|
2826
3102
|
function unstable_next(eventHandler) {
|
|
2827
3103
|
var priorityLevel;
|
|
3104
|
+
|
|
2828
3105
|
switch (currentPriorityLevel) {
|
|
2829
3106
|
case ImmediatePriority:
|
|
2830
3107
|
case UserBlockingPriority:
|
|
@@ -2832,6 +3109,7 @@ function unstable_next(eventHandler) {
|
|
|
2832
3109
|
// Shift down to normal priority
|
|
2833
3110
|
priorityLevel = NormalPriority;
|
|
2834
3111
|
break;
|
|
3112
|
+
|
|
2835
3113
|
default:
|
|
2836
3114
|
// Anything lower than normal priority should remain at the current level.
|
|
2837
3115
|
priorityLevel = currentPriorityLevel;
|
|
@@ -2867,12 +3145,16 @@ function timeoutForPriorityLevel(priorityLevel) {
|
|
|
2867
3145
|
switch (priorityLevel) {
|
|
2868
3146
|
case ImmediatePriority:
|
|
2869
3147
|
return IMMEDIATE_PRIORITY_TIMEOUT;
|
|
3148
|
+
|
|
2870
3149
|
case UserBlockingPriority:
|
|
2871
3150
|
return USER_BLOCKING_PRIORITY;
|
|
3151
|
+
|
|
2872
3152
|
case IdlePriority:
|
|
2873
3153
|
return IDLE_PRIORITY;
|
|
3154
|
+
|
|
2874
3155
|
case LowPriority:
|
|
2875
3156
|
return LOW_PRIORITY_TIMEOUT;
|
|
3157
|
+
|
|
2876
3158
|
case NormalPriority:
|
|
2877
3159
|
default:
|
|
2878
3160
|
return NORMAL_PRIORITY_TIMEOUT;
|
|
@@ -2881,16 +3163,18 @@ function timeoutForPriorityLevel(priorityLevel) {
|
|
|
2881
3163
|
|
|
2882
3164
|
function unstable_scheduleCallback(priorityLevel, callback, options) {
|
|
2883
3165
|
var currentTime = getCurrentTime();
|
|
2884
|
-
|
|
2885
3166
|
var startTime;
|
|
2886
3167
|
var timeout;
|
|
3168
|
+
|
|
2887
3169
|
if (typeof options === 'object' && options !== null) {
|
|
2888
3170
|
var delay = options.delay;
|
|
3171
|
+
|
|
2889
3172
|
if (typeof delay === 'number' && delay > 0) {
|
|
2890
3173
|
startTime = currentTime + delay;
|
|
2891
3174
|
} else {
|
|
2892
3175
|
startTime = currentTime;
|
|
2893
3176
|
}
|
|
3177
|
+
|
|
2894
3178
|
timeout = typeof options.timeout === 'number' ? options.timeout : timeoutForPriorityLevel(priorityLevel);
|
|
2895
3179
|
} else {
|
|
2896
3180
|
timeout = timeoutForPriorityLevel(priorityLevel);
|
|
@@ -2898,34 +3182,47 @@ function unstable_scheduleCallback(priorityLevel, callback, options) {
|
|
|
2898
3182
|
}
|
|
2899
3183
|
|
|
2900
3184
|
var expirationTime = startTime + timeout;
|
|
2901
|
-
|
|
2902
3185
|
var newTask = {
|
|
3186
|
+
id: taskIdCounter++,
|
|
2903
3187
|
callback: callback,
|
|
2904
3188
|
priorityLevel: priorityLevel,
|
|
2905
3189
|
startTime: startTime,
|
|
2906
3190
|
expirationTime: expirationTime,
|
|
2907
|
-
|
|
2908
|
-
previous: null
|
|
3191
|
+
sortIndex: -1
|
|
2909
3192
|
};
|
|
2910
3193
|
|
|
3194
|
+
if (enableProfiling) {
|
|
3195
|
+
newTask.isQueued = false;
|
|
3196
|
+
}
|
|
3197
|
+
|
|
2911
3198
|
if (startTime > currentTime) {
|
|
2912
3199
|
// This is a delayed task.
|
|
2913
|
-
|
|
2914
|
-
|
|
3200
|
+
newTask.sortIndex = startTime;
|
|
3201
|
+
push(timerQueue, newTask);
|
|
3202
|
+
|
|
3203
|
+
if (peek(taskQueue) === null && newTask === peek(timerQueue)) {
|
|
2915
3204
|
// All tasks are delayed, and this is the task with the earliest delay.
|
|
2916
3205
|
if (isHostTimeoutScheduled) {
|
|
2917
3206
|
// Cancel an existing timeout.
|
|
2918
3207
|
cancelHostTimeout();
|
|
2919
3208
|
} else {
|
|
2920
3209
|
isHostTimeoutScheduled = true;
|
|
2921
|
-
}
|
|
2922
|
-
|
|
3210
|
+
} // Schedule a timeout.
|
|
3211
|
+
|
|
3212
|
+
|
|
2923
3213
|
requestHostTimeout(handleTimeout, startTime - currentTime);
|
|
2924
3214
|
}
|
|
2925
3215
|
} else {
|
|
2926
|
-
|
|
2927
|
-
|
|
3216
|
+
newTask.sortIndex = expirationTime;
|
|
3217
|
+
push(taskQueue, newTask);
|
|
3218
|
+
|
|
3219
|
+
if (enableProfiling) {
|
|
3220
|
+
markTaskStart(newTask, currentTime);
|
|
3221
|
+
newTask.isQueued = true;
|
|
3222
|
+
} // Schedule a host callback, if needed. If we're already performing work,
|
|
2928
3223
|
// wait until the next time we yield.
|
|
3224
|
+
|
|
3225
|
+
|
|
2929
3226
|
if (!isHostCallbackScheduled && !isPerformingWork) {
|
|
2930
3227
|
isHostCallbackScheduled = true;
|
|
2931
3228
|
requestHostCallback(flushWork);
|
|
@@ -2935,80 +3232,13 @@ function unstable_scheduleCallback(priorityLevel, callback, options) {
|
|
|
2935
3232
|
return newTask;
|
|
2936
3233
|
}
|
|
2937
3234
|
|
|
2938
|
-
function insertScheduledTask(newTask, expirationTime) {
|
|
2939
|
-
// Insert the new task into the list, ordered first by its timeout, then by
|
|
2940
|
-
// insertion. So the new task is inserted after any other task the
|
|
2941
|
-
// same timeout
|
|
2942
|
-
if (firstTask === null) {
|
|
2943
|
-
// This is the first task in the list.
|
|
2944
|
-
firstTask = newTask.next = newTask.previous = newTask;
|
|
2945
|
-
} else {
|
|
2946
|
-
var next = null;
|
|
2947
|
-
var task = firstTask;
|
|
2948
|
-
do {
|
|
2949
|
-
if (expirationTime < task.expirationTime) {
|
|
2950
|
-
// The new task times out before this one.
|
|
2951
|
-
next = task;
|
|
2952
|
-
break;
|
|
2953
|
-
}
|
|
2954
|
-
task = task.next;
|
|
2955
|
-
} while (task !== firstTask);
|
|
2956
|
-
|
|
2957
|
-
if (next === null) {
|
|
2958
|
-
// No task with a later timeout was found, which means the new task has
|
|
2959
|
-
// the latest timeout in the list.
|
|
2960
|
-
next = firstTask;
|
|
2961
|
-
} else if (next === firstTask) {
|
|
2962
|
-
// The new task has the earliest expiration in the entire list.
|
|
2963
|
-
firstTask = newTask;
|
|
2964
|
-
}
|
|
2965
|
-
|
|
2966
|
-
var previous = next.previous;
|
|
2967
|
-
previous.next = next.previous = newTask;
|
|
2968
|
-
newTask.next = next;
|
|
2969
|
-
newTask.previous = previous;
|
|
2970
|
-
}
|
|
2971
|
-
}
|
|
2972
|
-
|
|
2973
|
-
function insertDelayedTask(newTask, startTime) {
|
|
2974
|
-
// Insert the new task into the list, ordered by its start time.
|
|
2975
|
-
if (firstDelayedTask === null) {
|
|
2976
|
-
// This is the first task in the list.
|
|
2977
|
-
firstDelayedTask = newTask.next = newTask.previous = newTask;
|
|
2978
|
-
} else {
|
|
2979
|
-
var next = null;
|
|
2980
|
-
var task = firstDelayedTask;
|
|
2981
|
-
do {
|
|
2982
|
-
if (startTime < task.startTime) {
|
|
2983
|
-
// The new task times out before this one.
|
|
2984
|
-
next = task;
|
|
2985
|
-
break;
|
|
2986
|
-
}
|
|
2987
|
-
task = task.next;
|
|
2988
|
-
} while (task !== firstDelayedTask);
|
|
2989
|
-
|
|
2990
|
-
if (next === null) {
|
|
2991
|
-
// No task with a later timeout was found, which means the new task has
|
|
2992
|
-
// the latest timeout in the list.
|
|
2993
|
-
next = firstDelayedTask;
|
|
2994
|
-
} else if (next === firstDelayedTask) {
|
|
2995
|
-
// The new task has the earliest expiration in the entire list.
|
|
2996
|
-
firstDelayedTask = newTask;
|
|
2997
|
-
}
|
|
2998
|
-
|
|
2999
|
-
var previous = next.previous;
|
|
3000
|
-
previous.next = next.previous = newTask;
|
|
3001
|
-
newTask.next = next;
|
|
3002
|
-
newTask.previous = previous;
|
|
3003
|
-
}
|
|
3004
|
-
}
|
|
3005
|
-
|
|
3006
3235
|
function unstable_pauseExecution() {
|
|
3007
3236
|
isSchedulerPaused = true;
|
|
3008
3237
|
}
|
|
3009
3238
|
|
|
3010
3239
|
function unstable_continueExecution() {
|
|
3011
3240
|
isSchedulerPaused = false;
|
|
3241
|
+
|
|
3012
3242
|
if (!isHostCallbackScheduled && !isPerformingWork) {
|
|
3013
3243
|
isHostCallbackScheduled = true;
|
|
3014
3244
|
requestHostCallback(flushWork);
|
|
@@ -3016,34 +3246,22 @@ function unstable_continueExecution() {
|
|
|
3016
3246
|
}
|
|
3017
3247
|
|
|
3018
3248
|
function unstable_getFirstCallbackNode() {
|
|
3019
|
-
return
|
|
3249
|
+
return peek(taskQueue);
|
|
3020
3250
|
}
|
|
3021
3251
|
|
|
3022
3252
|
function unstable_cancelCallback(task) {
|
|
3023
|
-
|
|
3024
|
-
|
|
3025
|
-
|
|
3026
|
-
|
|
3027
|
-
|
|
3028
|
-
|
|
3029
|
-
if (task === next) {
|
|
3030
|
-
if (task === firstTask) {
|
|
3031
|
-
firstTask = null;
|
|
3032
|
-
} else if (task === firstDelayedTask) {
|
|
3033
|
-
firstDelayedTask = null;
|
|
3034
|
-
}
|
|
3035
|
-
} else {
|
|
3036
|
-
if (task === firstTask) {
|
|
3037
|
-
firstTask = next;
|
|
3038
|
-
} else if (task === firstDelayedTask) {
|
|
3039
|
-
firstDelayedTask = next;
|
|
3253
|
+
if (enableProfiling) {
|
|
3254
|
+
if (task.isQueued) {
|
|
3255
|
+
var currentTime = getCurrentTime();
|
|
3256
|
+
markTaskCanceled(task, currentTime);
|
|
3257
|
+
task.isQueued = false;
|
|
3040
3258
|
}
|
|
3041
|
-
|
|
3042
|
-
|
|
3043
|
-
|
|
3044
|
-
}
|
|
3259
|
+
} // Null out the callback to indicate the task has been canceled. (Can't
|
|
3260
|
+
// remove from the queue because you can't remove arbitrary nodes from an
|
|
3261
|
+
// array based heap, only the first one.)
|
|
3045
3262
|
|
|
3046
|
-
|
|
3263
|
+
|
|
3264
|
+
task.callback = null;
|
|
3047
3265
|
}
|
|
3048
3266
|
|
|
3049
3267
|
function unstable_getCurrentPriorityLevel() {
|
|
@@ -3053,10 +3271,16 @@ function unstable_getCurrentPriorityLevel() {
|
|
|
3053
3271
|
function unstable_shouldYield() {
|
|
3054
3272
|
var currentTime = getCurrentTime();
|
|
3055
3273
|
advanceTimers(currentTime);
|
|
3056
|
-
|
|
3274
|
+
var firstTask = peek(taskQueue);
|
|
3275
|
+
return firstTask !== currentTask && currentTask !== null && firstTask !== null && firstTask.callback !== null && firstTask.startTime <= currentTime && firstTask.expirationTime < currentTask.expirationTime || shouldYieldToHost();
|
|
3057
3276
|
}
|
|
3058
3277
|
|
|
3059
3278
|
var unstable_requestPaint = requestPaint;
|
|
3279
|
+
var unstable_Profiling = enableProfiling ? {
|
|
3280
|
+
startLoggingProfilingEvents: startLoggingProfilingEvents,
|
|
3281
|
+
stopLoggingProfilingEvents: stopLoggingProfilingEvents,
|
|
3282
|
+
sharedProfilingBuffer: sharedProfilingBuffer
|
|
3283
|
+
} : null;
|
|
3060
3284
|
|
|
3061
3285
|
|
|
3062
3286
|
|
|
@@ -3078,103 +3302,76 @@ var Scheduler = Object.freeze({
|
|
|
3078
3302
|
unstable_pauseExecution: unstable_pauseExecution,
|
|
3079
3303
|
unstable_getFirstCallbackNode: unstable_getFirstCallbackNode,
|
|
3080
3304
|
get unstable_now () { return getCurrentTime; },
|
|
3081
|
-
get unstable_forceFrameRate () { return forceFrameRate; }
|
|
3305
|
+
get unstable_forceFrameRate () { return forceFrameRate; },
|
|
3306
|
+
unstable_Profiling: unstable_Profiling
|
|
3082
3307
|
});
|
|
3083
3308
|
|
|
3084
3309
|
// Helps identify side effects in begin-phase lifecycle hooks and setState reducers:
|
|
3085
3310
|
|
|
3086
|
-
|
|
3087
|
-
// In some cases, StrictMode should also double-render lifecycles.
|
|
3311
|
+
// In some cases, StrictMode should also double-render lifecycles.
|
|
3088
3312
|
// This can be confusing for tests though,
|
|
3089
3313
|
// And it can be bad for performance in production.
|
|
3090
3314
|
// This feature flag can be used to control the behavior:
|
|
3091
3315
|
|
|
3092
|
-
|
|
3093
|
-
// To preserve the "Pause on caught exceptions" behavior of the debugger, we
|
|
3316
|
+
// To preserve the "Pause on caught exceptions" behavior of the debugger, we
|
|
3094
3317
|
// replay the begin phase of a failed component inside invokeGuardedCallback.
|
|
3095
3318
|
|
|
3319
|
+
// Warn about deprecated, async-unsafe lifecycles; relates to RFC #6:
|
|
3096
3320
|
|
|
3097
|
-
//
|
|
3098
|
-
|
|
3099
|
-
|
|
3100
|
-
// Gather advanced timing metrics for Profiler subtrees.
|
|
3101
|
-
|
|
3102
|
-
|
|
3103
|
-
// Trace which interactions trigger each commit.
|
|
3104
|
-
var enableSchedulerTracing = true;
|
|
3321
|
+
// Gather advanced timing metrics for Profiler subtrees.
|
|
3105
3322
|
|
|
3106
|
-
//
|
|
3107
|
-
// TODO: true? Here it might just be false.
|
|
3323
|
+
// Trace which interactions trigger each commit.
|
|
3108
3324
|
|
|
3109
|
-
|
|
3325
|
+
var enableSchedulerTracing = true; // SSR experiments
|
|
3110
3326
|
|
|
3111
3327
|
|
|
3112
|
-
// Only used in www builds.
|
|
3328
|
+
// Only used in www builds.
|
|
3113
3329
|
|
|
3330
|
+
// Only used in www builds.
|
|
3114
3331
|
|
|
3115
|
-
// Disable javascript: URL strings in href for XSS protection.
|
|
3332
|
+
// Disable javascript: URL strings in href for XSS protection.
|
|
3116
3333
|
|
|
3117
|
-
|
|
3118
|
-
// React Fire: prevent the value and checked attributes from syncing
|
|
3334
|
+
// React Fire: prevent the value and checked attributes from syncing
|
|
3119
3335
|
// with their related DOM properties
|
|
3120
3336
|
|
|
3121
|
-
|
|
3122
|
-
// These APIs will no longer be "unstable" in the upcoming 16.7 release,
|
|
3337
|
+
// These APIs will no longer be "unstable" in the upcoming 16.7 release,
|
|
3123
3338
|
// Control this behavior with a flag to support 16.6 minor releases in the meanwhile.
|
|
3124
3339
|
|
|
3340
|
+
var exposeConcurrentModeAPIs = false;
|
|
3341
|
+
// Experimental React Flare event system and event components support.
|
|
3125
3342
|
|
|
3343
|
+
var enableFlareAPI = false; // Experimental Host Component support.
|
|
3126
3344
|
|
|
3345
|
+
var enableFundamentalAPI = false; // Experimental Scope support.
|
|
3127
3346
|
|
|
3128
|
-
//
|
|
3129
|
-
// This is a flag so we can fix warnings in RN core before turning it on
|
|
3130
|
-
|
|
3131
|
-
|
|
3132
|
-
// Experimental React Flare event system and event components support.
|
|
3133
|
-
var enableFlareAPI = false;
|
|
3347
|
+
var enableScopeAPI = false; // New API for JSX transforms to target - https://github.com/reactjs/rfcs/pull/107
|
|
3134
3348
|
|
|
3135
|
-
//
|
|
3136
|
-
var enableFundamentalAPI = false;
|
|
3137
|
-
|
|
3138
|
-
// New API for JSX transforms to target - https://github.com/reactjs/rfcs/pull/107
|
|
3139
|
-
var enableJSXTransformAPI = false;
|
|
3140
|
-
|
|
3141
|
-
// We will enforce mocking scheduler with scheduler/unstable_mock at some point. (v17?)
|
|
3349
|
+
var enableJSXTransformAPI = false; // We will enforce mocking scheduler with scheduler/unstable_mock at some point. (v17?)
|
|
3142
3350
|
// Till then, we warn about the missing mock, but still fallback to a sync mode compatible version
|
|
3143
3351
|
|
|
3144
|
-
//
|
|
3145
|
-
|
|
3146
|
-
|
|
3147
|
-
// For tests, we flush suspense fallbacks in an act scope;
|
|
3352
|
+
// For tests, we flush suspense fallbacks in an act scope;
|
|
3148
3353
|
// *except* in some of our own tests, where we test incremental loading states.
|
|
3149
3354
|
|
|
3150
|
-
|
|
3151
|
-
// Changes priority of some events like mousemove to user-blocking priority,
|
|
3152
|
-
// but without making them discrete. The flag exists in case it causes
|
|
3153
|
-
// starvation problems.
|
|
3154
|
-
|
|
3155
|
-
|
|
3156
|
-
// Add a callback property to suspense to notify which promises are currently
|
|
3355
|
+
// Add a callback property to suspense to notify which promises are currently
|
|
3157
3356
|
// in the update queue. This allows reporting and tracing of what is causing
|
|
3158
3357
|
// the user to see a loading state.
|
|
3358
|
+
// Also allows hydration callbacks to fire when a dehydrated boundary gets
|
|
3359
|
+
// hydrated or deleted.
|
|
3159
3360
|
|
|
3160
|
-
|
|
3161
|
-
// Part of the simplification of React.createElement so we can eventually move
|
|
3361
|
+
// Part of the simplification of React.createElement so we can eventually move
|
|
3162
3362
|
// from React.createElement to React.jsx
|
|
3163
3363
|
// https://github.com/reactjs/rfcs/blob/createlement-rfc/text/0000-create-element-changes.md
|
|
3164
3364
|
|
|
3165
|
-
var DEFAULT_THREAD_ID = 0;
|
|
3365
|
+
var DEFAULT_THREAD_ID = 0; // Counters used to generate unique IDs.
|
|
3166
3366
|
|
|
3167
|
-
// Counters used to generate unique IDs.
|
|
3168
3367
|
var interactionIDCounter = 0;
|
|
3169
|
-
var threadIDCounter = 0;
|
|
3170
|
-
|
|
3171
|
-
// Set of currently traced interactions.
|
|
3368
|
+
var threadIDCounter = 0; // Set of currently traced interactions.
|
|
3172
3369
|
// Interactions "stack"–
|
|
3173
3370
|
// Meaning that newly traced interactions are appended to the previously active set.
|
|
3174
3371
|
// When an interaction goes out of scope, the previous set (if any) is restored.
|
|
3175
|
-
var interactionsRef = null;
|
|
3176
3372
|
|
|
3177
|
-
// Listener(s) to notify when interactions begin and end.
|
|
3373
|
+
var interactionsRef = null; // Listener(s) to notify when interactions begin and end.
|
|
3374
|
+
|
|
3178
3375
|
var subscriberRef = null;
|
|
3179
3376
|
|
|
3180
3377
|
if (enableSchedulerTracing) {
|
|
@@ -3200,7 +3397,6 @@ function unstable_clear(callback) {
|
|
|
3200
3397
|
interactionsRef.current = prevInteractions;
|
|
3201
3398
|
}
|
|
3202
3399
|
}
|
|
3203
|
-
|
|
3204
3400
|
function unstable_getCurrent() {
|
|
3205
3401
|
if (!enableSchedulerTracing) {
|
|
3206
3402
|
return null;
|
|
@@ -3208,11 +3404,9 @@ function unstable_getCurrent() {
|
|
|
3208
3404
|
return interactionsRef.current;
|
|
3209
3405
|
}
|
|
3210
3406
|
}
|
|
3211
|
-
|
|
3212
3407
|
function unstable_getThreadID() {
|
|
3213
3408
|
return ++threadIDCounter;
|
|
3214
3409
|
}
|
|
3215
|
-
|
|
3216
3410
|
function unstable_trace(name, timestamp, callback) {
|
|
3217
3411
|
var threadID = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : DEFAULT_THREAD_ID;
|
|
3218
3412
|
|
|
@@ -3226,18 +3420,15 @@ function unstable_trace(name, timestamp, callback) {
|
|
|
3226
3420
|
name: name,
|
|
3227
3421
|
timestamp: timestamp
|
|
3228
3422
|
};
|
|
3229
|
-
|
|
3230
|
-
var prevInteractions = interactionsRef.current;
|
|
3231
|
-
|
|
3232
|
-
// Traced interactions should stack/accumulate.
|
|
3423
|
+
var prevInteractions = interactionsRef.current; // Traced interactions should stack/accumulate.
|
|
3233
3424
|
// To do that, clone the current interactions.
|
|
3234
3425
|
// The previous set will be restored upon completion.
|
|
3426
|
+
|
|
3235
3427
|
var interactions = new Set(prevInteractions);
|
|
3236
3428
|
interactions.add(interaction);
|
|
3237
3429
|
interactionsRef.current = interactions;
|
|
3238
|
-
|
|
3239
3430
|
var subscriber = subscriberRef.current;
|
|
3240
|
-
var returnValue
|
|
3431
|
+
var returnValue;
|
|
3241
3432
|
|
|
3242
3433
|
try {
|
|
3243
3434
|
if (subscriber !== null) {
|
|
@@ -3259,10 +3450,9 @@ function unstable_trace(name, timestamp, callback) {
|
|
|
3259
3450
|
subscriber.onWorkStopped(interactions, threadID);
|
|
3260
3451
|
}
|
|
3261
3452
|
} finally {
|
|
3262
|
-
interaction.__count--;
|
|
3263
|
-
|
|
3264
|
-
// If no async work was scheduled for this interaction,
|
|
3453
|
+
interaction.__count--; // If no async work was scheduled for this interaction,
|
|
3265
3454
|
// Notify subscribers that it's completed.
|
|
3455
|
+
|
|
3266
3456
|
if (subscriber !== null && interaction.__count === 0) {
|
|
3267
3457
|
subscriber.onInteractionScheduledWorkCompleted(interaction);
|
|
3268
3458
|
}
|
|
@@ -3273,7 +3463,6 @@ function unstable_trace(name, timestamp, callback) {
|
|
|
3273
3463
|
|
|
3274
3464
|
return returnValue;
|
|
3275
3465
|
}
|
|
3276
|
-
|
|
3277
3466
|
function unstable_wrap(callback) {
|
|
3278
3467
|
var threadID = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DEFAULT_THREAD_ID;
|
|
3279
3468
|
|
|
@@ -3282,28 +3471,26 @@ function unstable_wrap(callback) {
|
|
|
3282
3471
|
}
|
|
3283
3472
|
|
|
3284
3473
|
var wrappedInteractions = interactionsRef.current;
|
|
3285
|
-
|
|
3286
3474
|
var subscriber = subscriberRef.current;
|
|
3475
|
+
|
|
3287
3476
|
if (subscriber !== null) {
|
|
3288
3477
|
subscriber.onWorkScheduled(wrappedInteractions, threadID);
|
|
3289
|
-
}
|
|
3290
|
-
|
|
3291
|
-
// Update the pending async work count for the current interactions.
|
|
3478
|
+
} // Update the pending async work count for the current interactions.
|
|
3292
3479
|
// Update after calling subscribers in case of error.
|
|
3480
|
+
|
|
3481
|
+
|
|
3293
3482
|
wrappedInteractions.forEach(function (interaction) {
|
|
3294
3483
|
interaction.__count++;
|
|
3295
3484
|
});
|
|
3296
|
-
|
|
3297
3485
|
var hasRun = false;
|
|
3298
3486
|
|
|
3299
3487
|
function wrapped() {
|
|
3300
3488
|
var prevInteractions = interactionsRef.current;
|
|
3301
3489
|
interactionsRef.current = wrappedInteractions;
|
|
3302
|
-
|
|
3303
3490
|
subscriber = subscriberRef.current;
|
|
3304
3491
|
|
|
3305
3492
|
try {
|
|
3306
|
-
var returnValue
|
|
3493
|
+
var returnValue;
|
|
3307
3494
|
|
|
3308
3495
|
try {
|
|
3309
3496
|
if (subscriber !== null) {
|
|
@@ -3327,11 +3514,10 @@ function unstable_wrap(callback) {
|
|
|
3327
3514
|
// We only expect a wrapped function to be executed once,
|
|
3328
3515
|
// But in the event that it's executed more than once–
|
|
3329
3516
|
// Only decrement the outstanding interaction counts once.
|
|
3330
|
-
hasRun = true;
|
|
3331
|
-
|
|
3332
|
-
// Update pending async counts for all wrapped interactions.
|
|
3517
|
+
hasRun = true; // Update pending async counts for all wrapped interactions.
|
|
3333
3518
|
// If this was the last scheduled async work for any of them,
|
|
3334
3519
|
// Mark them as completed.
|
|
3520
|
+
|
|
3335
3521
|
wrappedInteractions.forEach(function (interaction) {
|
|
3336
3522
|
interaction.__count--;
|
|
3337
3523
|
|
|
@@ -3368,6 +3554,7 @@ function unstable_wrap(callback) {
|
|
|
3368
3554
|
}
|
|
3369
3555
|
|
|
3370
3556
|
var subscribers = null;
|
|
3557
|
+
|
|
3371
3558
|
if (enableSchedulerTracing) {
|
|
3372
3559
|
subscribers = new Set();
|
|
3373
3560
|
}
|
|
@@ -3388,7 +3575,6 @@ function unstable_subscribe(subscriber) {
|
|
|
3388
3575
|
}
|
|
3389
3576
|
}
|
|
3390
3577
|
}
|
|
3391
|
-
|
|
3392
3578
|
function unstable_unsubscribe(subscriber) {
|
|
3393
3579
|
if (enableSchedulerTracing) {
|
|
3394
3580
|
subscribers.delete(subscriber);
|
|
@@ -3402,7 +3588,6 @@ function unstable_unsubscribe(subscriber) {
|
|
|
3402
3588
|
function onInteractionTraced(interaction) {
|
|
3403
3589
|
var didCatchError = false;
|
|
3404
3590
|
var caughtError = null;
|
|
3405
|
-
|
|
3406
3591
|
subscribers.forEach(function (subscriber) {
|
|
3407
3592
|
try {
|
|
3408
3593
|
subscriber.onInteractionTraced(interaction);
|
|
@@ -3422,7 +3607,6 @@ function onInteractionTraced(interaction) {
|
|
|
3422
3607
|
function onInteractionScheduledWorkCompleted(interaction) {
|
|
3423
3608
|
var didCatchError = false;
|
|
3424
3609
|
var caughtError = null;
|
|
3425
|
-
|
|
3426
3610
|
subscribers.forEach(function (subscriber) {
|
|
3427
3611
|
try {
|
|
3428
3612
|
subscriber.onInteractionScheduledWorkCompleted(interaction);
|
|
@@ -3442,7 +3626,6 @@ function onInteractionScheduledWorkCompleted(interaction) {
|
|
|
3442
3626
|
function onWorkScheduled(interactions, threadID) {
|
|
3443
3627
|
var didCatchError = false;
|
|
3444
3628
|
var caughtError = null;
|
|
3445
|
-
|
|
3446
3629
|
subscribers.forEach(function (subscriber) {
|
|
3447
3630
|
try {
|
|
3448
3631
|
subscriber.onWorkScheduled(interactions, threadID);
|
|
@@ -3462,7 +3645,6 @@ function onWorkScheduled(interactions, threadID) {
|
|
|
3462
3645
|
function onWorkStarted(interactions, threadID) {
|
|
3463
3646
|
var didCatchError = false;
|
|
3464
3647
|
var caughtError = null;
|
|
3465
|
-
|
|
3466
3648
|
subscribers.forEach(function (subscriber) {
|
|
3467
3649
|
try {
|
|
3468
3650
|
subscriber.onWorkStarted(interactions, threadID);
|
|
@@ -3482,7 +3664,6 @@ function onWorkStarted(interactions, threadID) {
|
|
|
3482
3664
|
function onWorkStopped(interactions, threadID) {
|
|
3483
3665
|
var didCatchError = false;
|
|
3484
3666
|
var caughtError = null;
|
|
3485
|
-
|
|
3486
3667
|
subscribers.forEach(function (subscriber) {
|
|
3487
3668
|
try {
|
|
3488
3669
|
subscriber.onWorkStopped(interactions, threadID);
|
|
@@ -3502,7 +3683,6 @@ function onWorkStopped(interactions, threadID) {
|
|
|
3502
3683
|
function onWorkCanceled(interactions, threadID) {
|
|
3503
3684
|
var didCatchError = false;
|
|
3504
3685
|
var caughtError = null;
|
|
3505
|
-
|
|
3506
3686
|
subscribers.forEach(function (subscriber) {
|
|
3507
3687
|
try {
|
|
3508
3688
|
subscriber.onWorkCanceled(interactions, threadID);
|
|
@@ -3549,29 +3729,30 @@ var ReactSharedInternals$2 = {
|
|
|
3549
3729
|
// TODO: remove in React 17.0.
|
|
3550
3730
|
ReactComponentTreeHook: {}
|
|
3551
3731
|
});
|
|
3552
|
-
}
|
|
3553
|
-
|
|
3554
|
-
// Re-export the schedule API(s) for UMD bundles.
|
|
3732
|
+
} // Re-export the schedule API(s) for UMD bundles.
|
|
3555
3733
|
// This avoids introducing a dependency on a new UMD global in a minor update,
|
|
3556
3734
|
// Since that would be a breaking change (e.g. for all existing CodeSandboxes).
|
|
3557
3735
|
// This re-export is only required for UMD bundles;
|
|
3558
3736
|
// CJS bundles use the shared NPM package.
|
|
3737
|
+
|
|
3738
|
+
|
|
3559
3739
|
objectAssign(ReactSharedInternals$2, {
|
|
3560
3740
|
Scheduler: Scheduler,
|
|
3561
3741
|
SchedulerTracing: SchedulerTracing
|
|
3562
3742
|
});
|
|
3563
3743
|
|
|
3564
|
-
var hasBadMapPolyfill
|
|
3744
|
+
var hasBadMapPolyfill;
|
|
3565
3745
|
|
|
3566
3746
|
{
|
|
3567
3747
|
hasBadMapPolyfill = false;
|
|
3748
|
+
|
|
3568
3749
|
try {
|
|
3569
3750
|
var frozenObject = Object.freeze({});
|
|
3570
3751
|
var testMap = new Map([[frozenObject, null]]);
|
|
3571
|
-
var testSet = new Set([frozenObject]);
|
|
3572
|
-
// This is necessary for Rollup to not consider these unused.
|
|
3752
|
+
var testSet = new Set([frozenObject]); // This is necessary for Rollup to not consider these unused.
|
|
3573
3753
|
// https://github.com/rollup/rollup/issues/1771
|
|
3574
3754
|
// TODO: we can remove these if Rollup fixes the bug.
|
|
3755
|
+
|
|
3575
3756
|
testMap.set(0, 0);
|
|
3576
3757
|
testSet.add(0);
|
|
3577
3758
|
} catch (e) {
|
|
@@ -3587,13 +3768,16 @@ function createFundamentalComponent(impl) {
|
|
|
3587
3768
|
if (true && !hasBadMapPolyfill) {
|
|
3588
3769
|
Object.freeze(impl);
|
|
3589
3770
|
}
|
|
3771
|
+
|
|
3590
3772
|
var fundamantalComponent = {
|
|
3591
3773
|
$$typeof: REACT_FUNDAMENTAL_TYPE,
|
|
3592
3774
|
impl: impl
|
|
3593
3775
|
};
|
|
3776
|
+
|
|
3594
3777
|
{
|
|
3595
3778
|
Object.freeze(fundamantalComponent);
|
|
3596
3779
|
}
|
|
3780
|
+
|
|
3597
3781
|
return fundamantalComponent;
|
|
3598
3782
|
}
|
|
3599
3783
|
|
|
@@ -3602,32 +3786,44 @@ function createEventResponder(displayName, responderConfig) {
|
|
|
3602
3786
|
onEvent = responderConfig.onEvent,
|
|
3603
3787
|
onMount = responderConfig.onMount,
|
|
3604
3788
|
onUnmount = responderConfig.onUnmount,
|
|
3605
|
-
onOwnershipChange = responderConfig.onOwnershipChange,
|
|
3606
3789
|
onRootEvent = responderConfig.onRootEvent,
|
|
3607
3790
|
rootEventTypes = responderConfig.rootEventTypes,
|
|
3608
|
-
targetEventTypes = responderConfig.targetEventTypes
|
|
3609
|
-
|
|
3791
|
+
targetEventTypes = responderConfig.targetEventTypes,
|
|
3792
|
+
targetPortalPropagation = responderConfig.targetPortalPropagation;
|
|
3610
3793
|
var eventResponder = {
|
|
3611
3794
|
$$typeof: REACT_RESPONDER_TYPE,
|
|
3612
3795
|
displayName: displayName,
|
|
3613
3796
|
getInitialState: getInitialState || null,
|
|
3614
3797
|
onEvent: onEvent || null,
|
|
3615
3798
|
onMount: onMount || null,
|
|
3616
|
-
onOwnershipChange: onOwnershipChange || null,
|
|
3617
3799
|
onRootEvent: onRootEvent || null,
|
|
3618
3800
|
onUnmount: onUnmount || null,
|
|
3619
3801
|
rootEventTypes: rootEventTypes || null,
|
|
3620
|
-
targetEventTypes: targetEventTypes || null
|
|
3621
|
-
|
|
3622
|
-
// We use responder as a Map key later on. When we have a bad
|
|
3802
|
+
targetEventTypes: targetEventTypes || null,
|
|
3803
|
+
targetPortalPropagation: targetPortalPropagation || false
|
|
3804
|
+
}; // We use responder as a Map key later on. When we have a bad
|
|
3623
3805
|
// polyfill, then we can't use it as a key as the polyfill tries
|
|
3624
3806
|
// to add a property to the object.
|
|
3807
|
+
|
|
3625
3808
|
if (true && !hasBadMapPolyfill) {
|
|
3626
3809
|
Object.freeze(eventResponder);
|
|
3627
3810
|
}
|
|
3811
|
+
|
|
3628
3812
|
return eventResponder;
|
|
3629
3813
|
}
|
|
3630
3814
|
|
|
3815
|
+
function createScope() {
|
|
3816
|
+
var scopeComponent = {
|
|
3817
|
+
$$typeof: REACT_SCOPE_TYPE
|
|
3818
|
+
};
|
|
3819
|
+
|
|
3820
|
+
{
|
|
3821
|
+
Object.freeze(scopeComponent);
|
|
3822
|
+
}
|
|
3823
|
+
|
|
3824
|
+
return scopeComponent;
|
|
3825
|
+
}
|
|
3826
|
+
|
|
3631
3827
|
var React = {
|
|
3632
3828
|
Children: {
|
|
3633
3829
|
map: mapChildren,
|
|
@@ -3636,16 +3832,13 @@ var React = {
|
|
|
3636
3832
|
toArray: toArray,
|
|
3637
3833
|
only: onlyChild
|
|
3638
3834
|
},
|
|
3639
|
-
|
|
3640
3835
|
createRef: createRef,
|
|
3641
3836
|
Component: Component,
|
|
3642
3837
|
PureComponent: PureComponent,
|
|
3643
|
-
|
|
3644
3838
|
createContext: createContext,
|
|
3645
3839
|
forwardRef: forwardRef,
|
|
3646
3840
|
lazy: lazy,
|
|
3647
3841
|
memo: memo,
|
|
3648
|
-
|
|
3649
3842
|
useCallback: useCallback,
|
|
3650
3843
|
useContext: useContext,
|
|
3651
3844
|
useEffect: useEffect,
|
|
@@ -3656,25 +3849,25 @@ var React = {
|
|
|
3656
3849
|
useReducer: useReducer,
|
|
3657
3850
|
useRef: useRef,
|
|
3658
3851
|
useState: useState,
|
|
3659
|
-
|
|
3660
3852
|
Fragment: REACT_FRAGMENT_TYPE,
|
|
3661
3853
|
Profiler: REACT_PROFILER_TYPE,
|
|
3662
3854
|
StrictMode: REACT_STRICT_MODE_TYPE,
|
|
3663
3855
|
Suspense: REACT_SUSPENSE_TYPE,
|
|
3664
|
-
unstable_SuspenseList: REACT_SUSPENSE_LIST_TYPE,
|
|
3665
|
-
|
|
3666
3856
|
createElement: createElementWithValidation,
|
|
3667
3857
|
cloneElement: cloneElementWithValidation,
|
|
3668
3858
|
createFactory: createFactoryWithValidation,
|
|
3669
3859
|
isValidElement: isValidElement,
|
|
3670
|
-
|
|
3671
3860
|
version: ReactVersion,
|
|
3672
|
-
|
|
3673
|
-
unstable_withSuspenseConfig: withSuspenseConfig,
|
|
3674
|
-
|
|
3675
3861
|
__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED: ReactSharedInternals$2
|
|
3676
3862
|
};
|
|
3677
3863
|
|
|
3864
|
+
if (exposeConcurrentModeAPIs) {
|
|
3865
|
+
React.useTransition = useTransition;
|
|
3866
|
+
React.useDeferredValue = useDeferredValue;
|
|
3867
|
+
React.SuspenseList = REACT_SUSPENSE_LIST_TYPE;
|
|
3868
|
+
React.unstable_withSuspenseConfig = withSuspenseConfig;
|
|
3869
|
+
}
|
|
3870
|
+
|
|
3678
3871
|
if (enableFlareAPI) {
|
|
3679
3872
|
React.unstable_useResponder = useResponder;
|
|
3680
3873
|
React.unstable_createResponder = createEventResponder;
|
|
@@ -3684,11 +3877,14 @@ if (enableFundamentalAPI) {
|
|
|
3684
3877
|
React.unstable_createFundamental = createFundamentalComponent;
|
|
3685
3878
|
}
|
|
3686
3879
|
|
|
3687
|
-
|
|
3880
|
+
if (enableScopeAPI) {
|
|
3881
|
+
React.unstable_createScope = createScope;
|
|
3882
|
+
} // Note: some APIs are added with feature flags.
|
|
3688
3883
|
// Make sure that stable builds for open source
|
|
3689
3884
|
// don't modify the React object to avoid deopts.
|
|
3690
3885
|
// Also let's not expose their names in stable builds.
|
|
3691
3886
|
|
|
3887
|
+
|
|
3692
3888
|
if (enableJSXTransformAPI) {
|
|
3693
3889
|
{
|
|
3694
3890
|
React.jsxDEV = jsxWithValidation;
|
|
@@ -3707,6 +3903,8 @@ var React$3 = ( React$2 && React ) || React$2;
|
|
|
3707
3903
|
|
|
3708
3904
|
// TODO: decide on the top-level export form.
|
|
3709
3905
|
// This is hacky but makes it work with both Rollup and Jest.
|
|
3906
|
+
|
|
3907
|
+
|
|
3710
3908
|
var react = React$3.default || React$3;
|
|
3711
3909
|
|
|
3712
3910
|
return react;
|