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