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