react 16.5.0 → 16.6.0-alpha.400d197

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2013-present, Facebook, Inc.
3
+ Copyright (c) Facebook, Inc. and its affiliates.
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
@@ -1,7 +1,7 @@
1
- /** @license React v16.5.0
1
+ /** @license React v16.6.0-alpha.400d197
2
2
  * react.development.js
3
3
  *
4
- * Copyright (c) 2013-present, Facebook, Inc.
4
+ * Copyright (c) Facebook, Inc. and its affiliates.
5
5
  *
6
6
  * This source code is licensed under the MIT license found in the
7
7
  * LICENSE file in the root directory of this source tree.
@@ -20,7 +20,7 @@ var checkPropTypes = require('prop-types/checkPropTypes');
20
20
 
21
21
  // TODO: this is special because it gets imported during build.
22
22
 
23
- var ReactVersion = '16.5.0';
23
+ var ReactVersion = '16.6.0-alpha.400d197';
24
24
 
25
25
  // The Symbol used to tag the ReactElement-like types. If there is no native Symbol
26
26
  // nor polyfill, then a plain number is used for performance.
@@ -33,9 +33,10 @@ var REACT_STRICT_MODE_TYPE = hasSymbol ? Symbol.for('react.strict_mode') : 0xeac
33
33
  var REACT_PROFILER_TYPE = hasSymbol ? Symbol.for('react.profiler') : 0xead2;
34
34
  var REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for('react.provider') : 0xeacd;
35
35
  var REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for('react.context') : 0xeace;
36
- var REACT_ASYNC_MODE_TYPE = hasSymbol ? Symbol.for('react.async_mode') : 0xeacf;
36
+ var REACT_CONCURRENT_MODE_TYPE = hasSymbol ? Symbol.for('react.concurrent_mode') : 0xeacf;
37
37
  var REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for('react.forward_ref') : 0xead0;
38
38
  var REACT_PLACEHOLDER_TYPE = hasSymbol ? Symbol.for('react.placeholder') : 0xead1;
39
+ var REACT_PURE_TYPE = hasSymbol ? Symbol.for('react.pure') : 0xead3;
39
40
 
40
41
  var MAYBE_ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
41
42
  var FAUX_ITERATOR_SYMBOL = '@@iterator';
@@ -51,6 +52,43 @@ function getIteratorFn(maybeIterable) {
51
52
  return null;
52
53
  }
53
54
 
55
+ // Exports ReactDOM.createRoot
56
+
57
+
58
+ // Suspense
59
+ var enableSuspense = false;
60
+ var enableHooks_DEPRECATED = false;
61
+ // Helps identify side effects in begin-phase lifecycle hooks and setState reducers:
62
+
63
+
64
+ // In some cases, StrictMode should also double-render lifecycles.
65
+ // This can be confusing for tests though,
66
+ // And it can be bad for performance in production.
67
+ // This feature flag can be used to control the behavior:
68
+
69
+
70
+ // To preserve the "Pause on caught exceptions" behavior of the debugger, we
71
+ // replay the begin phase of a failed component inside invokeGuardedCallback.
72
+
73
+
74
+ // Warn about deprecated, async-unsafe lifecycles; relates to RFC #6:
75
+
76
+
77
+ // Gather advanced timing metrics for Profiler subtrees.
78
+
79
+
80
+ // Trace which interactions trigger each commit.
81
+
82
+
83
+ // Only used in www builds.
84
+
85
+
86
+ // Only used in www builds.
87
+
88
+
89
+ // React Fire: prevent the value and checked attributes from syncing
90
+ // with their related DOM properties
91
+
54
92
  /**
55
93
  * Use invariant() to assert state which your program assumes to be true.
56
94
  *
@@ -96,44 +134,6 @@ function invariant(condition, format, a, b, c, d, e, f) {
96
134
  // Relying on the `invariant()` implementation lets us
97
135
  // preserve the format and params in the www builds.
98
136
 
99
- // Exports ReactDOM.createRoot
100
-
101
-
102
- // Experimental error-boundary API that can recover from errors within a single
103
- // render phase
104
-
105
- // Suspense
106
- var enableSuspense = false;
107
- // Helps identify side effects in begin-phase lifecycle hooks and setState reducers:
108
-
109
-
110
- // In some cases, StrictMode should also double-render lifecycles.
111
- // This can be confusing for tests though,
112
- // And it can be bad for performance in production.
113
- // This feature flag can be used to control the behavior:
114
-
115
-
116
- // To preserve the "Pause on caught exceptions" behavior of the debugger, we
117
- // replay the begin phase of a failed component inside invokeGuardedCallback.
118
-
119
-
120
- // Warn about deprecated, async-unsafe lifecycles; relates to RFC #6:
121
-
122
-
123
- // Warn about legacy context API
124
-
125
-
126
- // Gather advanced timing metrics for Profiler subtrees.
127
-
128
-
129
- // Track which interactions trigger each commit.
130
-
131
-
132
- // Only used in www builds.
133
-
134
-
135
- // Only used in www builds.
136
-
137
137
  /**
138
138
  * Forked from fbjs/warning:
139
139
  * https://github.com/facebook/fbjs/blob/e66ba20ad5be433eb54423f2b097d829324d9de6/packages/fbjs/src/__forks__/warning.js
@@ -205,26 +205,71 @@ var warningWithoutStack = function () {};
205
205
  if (format === undefined) {
206
206
  throw new Error('`warningWithoutStack(condition, format, ...args)` requires a warning ' + 'message argument');
207
207
  }
208
+ if (args.length > 8) {
209
+ // Check before the condition to catch violations early.
210
+ throw new Error('warningWithoutStack() currently supports at most 8 arguments.');
211
+ }
208
212
  if (condition) {
209
213
  return;
210
214
  }
211
215
  if (typeof console !== 'undefined') {
212
- var _console;
213
-
214
- var stringArgs = args.map(function (item) {
216
+ var _args$map = args.map(function (item) {
215
217
  return '' + item;
216
- });
217
- (_console = console).error.apply(_console, ['Warning: ' + format].concat(stringArgs));
218
+ }),
219
+ a = _args$map[0],
220
+ b = _args$map[1],
221
+ c = _args$map[2],
222
+ d = _args$map[3],
223
+ e = _args$map[4],
224
+ f = _args$map[5],
225
+ g = _args$map[6],
226
+ h = _args$map[7];
227
+
228
+ var message = 'Warning: ' + format;
229
+
230
+ // We intentionally don't use spread (or .apply) because it breaks IE9:
231
+ // https://github.com/facebook/react/issues/13610
232
+ switch (args.length) {
233
+ case 0:
234
+ console.error(message);
235
+ break;
236
+ case 1:
237
+ console.error(message, a);
238
+ break;
239
+ case 2:
240
+ console.error(message, a, b);
241
+ break;
242
+ case 3:
243
+ console.error(message, a, b, c);
244
+ break;
245
+ case 4:
246
+ console.error(message, a, b, c, d);
247
+ break;
248
+ case 5:
249
+ console.error(message, a, b, c, d, e);
250
+ break;
251
+ case 6:
252
+ console.error(message, a, b, c, d, e, f);
253
+ break;
254
+ case 7:
255
+ console.error(message, a, b, c, d, e, f, g);
256
+ break;
257
+ case 8:
258
+ console.error(message, a, b, c, d, e, f, g, h);
259
+ break;
260
+ default:
261
+ throw new Error('warningWithoutStack() currently supports at most 8 arguments.');
262
+ }
218
263
  }
219
264
  try {
220
265
  // --- Welcome to debugging React ---
221
266
  // This error was thrown as a convenience so that you can use this stack
222
267
  // to find the callsite that caused this warning to fire.
223
268
  var argIndex = 0;
224
- var message = 'Warning: ' + format.replace(/%s/g, function () {
269
+ var _message = 'Warning: ' + format.replace(/%s/g, function () {
225
270
  return args[argIndex++];
226
271
  });
227
- throw new Error(message);
272
+ throw new Error(_message);
228
273
  } catch (x) {}
229
274
  };
230
275
  }
@@ -507,8 +552,8 @@ function getComponentName(type) {
507
552
  return type;
508
553
  }
509
554
  switch (type) {
510
- case REACT_ASYNC_MODE_TYPE:
511
- return 'AsyncMode';
555
+ case REACT_CONCURRENT_MODE_TYPE:
556
+ return 'ConcurrentMode';
512
557
  case REACT_FRAGMENT_TYPE:
513
558
  return 'Fragment';
514
559
  case REACT_PORTAL_TYPE:
@@ -529,7 +574,7 @@ function getComponentName(type) {
529
574
  case REACT_FORWARD_REF_TYPE:
530
575
  var renderFn = type.render;
531
576
  var functionName = renderFn.displayName || renderFn.name || '';
532
- return functionName !== '' ? 'ForwardRef(' + functionName + ')' : 'ForwardRef';
577
+ return type.displayName || (functionName !== '' ? 'ForwardRef(' + functionName + ')' : 'ForwardRef');
533
578
  }
534
579
  if (typeof type.then === 'function') {
535
580
  var thenable = type;
@@ -1320,7 +1365,9 @@ function forwardRef(render) {
1320
1365
  if (typeof render !== 'function') {
1321
1366
  warningWithoutStack$1(false, 'forwardRef requires a render function but was given %s.', render === null ? 'null' : typeof render);
1322
1367
  } else {
1323
- !(render.length === 2) ? warningWithoutStack$1(false, 'forwardRef render functions accept two parameters: props and ref. ' + 'Did you forget to use the ref parameter?') : void 0;
1368
+ !(
1369
+ // Do not warn for 0 arguments because it could be due to usage of the 'arguments' object
1370
+ 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;
1324
1371
  }
1325
1372
 
1326
1373
  if (render != null) {
@@ -1334,10 +1381,84 @@ function forwardRef(render) {
1334
1381
  };
1335
1382
  }
1336
1383
 
1384
+ function pure(render, compare) {
1385
+ {
1386
+ if (typeof render !== 'function') {
1387
+ warningWithoutStack$1(false, 'pure: The first argument must be a function component. Instead ' + 'received: %s', render === null ? 'null' : typeof render);
1388
+ } else {
1389
+ var prototype = render.prototype;
1390
+ if (prototype && prototype.isReactComponent) {
1391
+ warningWithoutStack$1(false, 'pure: The first argument must be a function component. Classes ' + 'are not supported. Use React.PureComponent instead.');
1392
+ }
1393
+ }
1394
+ }
1395
+ return {
1396
+ $$typeof: REACT_PURE_TYPE,
1397
+ render: render,
1398
+ compare: compare === undefined ? null : compare
1399
+ };
1400
+ }
1401
+
1402
+ function resolveDispatcher() {
1403
+ var dispatcher = ReactCurrentOwner.currentDispatcher;
1404
+ !(dispatcher !== null) ? invariant(false, 'Hooks can only be called inside the body of a functional component.') : void 0;
1405
+ return dispatcher;
1406
+ }
1407
+
1408
+ function useContext(context, observedBits) {
1409
+ var dispatcher = resolveDispatcher();
1410
+ return dispatcher.useContext(context, observedBits);
1411
+ }
1412
+
1413
+ function useState(initialState) {
1414
+ var dispatcher = resolveDispatcher();
1415
+ return dispatcher.useState(initialState);
1416
+ }
1417
+
1418
+ function useReducer(reducer, initialState, initialAction) {
1419
+ var dispatcher = resolveDispatcher();
1420
+ return dispatcher.useReducer(reducer, initialState, initialAction);
1421
+ }
1422
+
1423
+ function useRef(initialValue) {
1424
+ var dispatcher = resolveDispatcher();
1425
+ return dispatcher.useRef(initialValue);
1426
+ }
1427
+
1428
+ function useEffect(create, inputs) {
1429
+ var dispatcher = resolveDispatcher();
1430
+ return dispatcher.useEffect(create, inputs);
1431
+ }
1432
+
1433
+ function useMutationEffect(create, inputs) {
1434
+ var dispatcher = resolveDispatcher();
1435
+ return dispatcher.useMutationEffect(create, inputs);
1436
+ }
1437
+
1438
+ function useLayoutEffect(create, inputs) {
1439
+ var dispatcher = resolveDispatcher();
1440
+ return dispatcher.useLayoutEffect(create, inputs);
1441
+ }
1442
+
1443
+ function useCallback(callback, inputs) {
1444
+ var dispatcher = resolveDispatcher();
1445
+ return dispatcher.useCallback(callback, inputs);
1446
+ }
1447
+
1448
+ function useMemo(create, inputs) {
1449
+ var dispatcher = resolveDispatcher();
1450
+ return dispatcher.useMemo(create, inputs);
1451
+ }
1452
+
1453
+ function useAPI(ref, create, inputs) {
1454
+ var dispatcher = resolveDispatcher();
1455
+ return dispatcher.useAPI(ref, create, inputs);
1456
+ }
1457
+
1337
1458
  function isValidElementType(type) {
1338
1459
  return typeof type === 'string' || typeof type === 'function' ||
1339
1460
  // Note: its typeof might be other than 'symbol' or 'number' if it's a polyfill.
1340
- type === REACT_FRAGMENT_TYPE || type === REACT_ASYNC_MODE_TYPE || type === REACT_PROFILER_TYPE || type === REACT_STRICT_MODE_TYPE || type === REACT_PLACEHOLDER_TYPE || typeof type === 'object' && type !== null && (typeof type.then === 'function' || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE);
1461
+ type === REACT_FRAGMENT_TYPE || type === REACT_CONCURRENT_MODE_TYPE || type === REACT_PROFILER_TYPE || type === REACT_STRICT_MODE_TYPE || type === REACT_PLACEHOLDER_TYPE || typeof type === 'object' && type !== null && (typeof type.then === 'function' || type.$$typeof === REACT_PURE_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE);
1341
1462
  }
1342
1463
 
1343
1464
  /**
@@ -1485,13 +1606,13 @@ function validatePropTypes(element) {
1485
1606
  var name = void 0,
1486
1607
  propTypes = void 0;
1487
1608
  if (typeof type === 'function') {
1488
- // Class or functional component
1609
+ // Class or function component
1489
1610
  name = type.displayName || type.name;
1490
1611
  propTypes = type.propTypes;
1491
1612
  } else if (typeof type === 'object' && type !== null && type.$$typeof === REACT_FORWARD_REF_TYPE) {
1492
1613
  // ForwardRef
1493
1614
  var functionName = type.render.displayName || type.render.name || '';
1494
- name = functionName !== '' ? 'ForwardRef(' + functionName + ')' : 'ForwardRef';
1615
+ name = type.displayName || (functionName !== '' ? 'ForwardRef(' + functionName + ')' : 'ForwardRef');
1495
1616
  propTypes = type.propTypes;
1496
1617
  } else {
1497
1618
  return;
@@ -1637,10 +1758,11 @@ var React = {
1637
1758
 
1638
1759
  createContext: createContext,
1639
1760
  forwardRef: forwardRef,
1761
+ pure: pure,
1640
1762
 
1641
1763
  Fragment: REACT_FRAGMENT_TYPE,
1642
1764
  StrictMode: REACT_STRICT_MODE_TYPE,
1643
- unstable_AsyncMode: REACT_ASYNC_MODE_TYPE,
1765
+ unstable_ConcurrentMode: REACT_CONCURRENT_MODE_TYPE,
1644
1766
  unstable_Profiler: REACT_PROFILER_TYPE,
1645
1767
 
1646
1768
  createElement: createElementWithValidation,
@@ -1658,6 +1780,19 @@ if (enableSuspense) {
1658
1780
  React.lazy = lazy;
1659
1781
  }
1660
1782
 
1783
+ if (enableHooks_DEPRECATED) {
1784
+ React.useAPI = useAPI;
1785
+ React.useCallback = useCallback;
1786
+ React.useContext = useContext;
1787
+ React.useEffect = useEffect;
1788
+ React.useLayoutEffect = useLayoutEffect;
1789
+ React.useMemo = useMemo;
1790
+ React.useMutationEffect = useMutationEffect;
1791
+ React.useReducer = useReducer;
1792
+ React.useRef = useRef;
1793
+ React.useState = useState;
1794
+ }
1795
+
1661
1796
 
1662
1797
 
1663
1798
  var React$2 = Object.freeze({
@@ -1,24 +1,24 @@
1
- /** @license React v16.5.0
1
+ /** @license React v16.6.0-alpha.400d197
2
2
  * react.production.min.js
3
3
  *
4
- * Copyright (c) 2013-present, Facebook, Inc.
4
+ * Copyright (c) Facebook, Inc. and its affiliates.
5
5
  *
6
6
  * This source code is licensed under the MIT license found in the
7
7
  * LICENSE file in the root directory of this source tree.
8
8
  */
9
9
 
10
- 'use strict';var m=require("object-assign"),n="function"===typeof Symbol&&Symbol.for,p=n?Symbol.for("react.element"):60103,q=n?Symbol.for("react.portal"):60106,r=n?Symbol.for("react.fragment"):60107,t=n?Symbol.for("react.strict_mode"):60108,u=n?Symbol.for("react.profiler"):60114,v=n?Symbol.for("react.provider"):60109,w=n?Symbol.for("react.context"):60110,x=n?Symbol.for("react.async_mode"):60111,y=n?Symbol.for("react.forward_ref"):60112;n&&Symbol.for("react.placeholder");
11
- var z="function"===typeof Symbol&&Symbol.iterator;function A(a,b,d,c,e,g,h,f){if(!a){a=void 0;if(void 0===b)a=Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var k=[d,c,e,g,h,f],l=0;a=Error(b.replace(/%s/g,function(){return k[l++]}));a.name="Invariant Violation"}a.framesToPop=1;throw a;}}
12
- function B(a){for(var b=arguments.length-1,d="https://reactjs.org/docs/error-decoder.html?invariant="+a,c=0;c<b;c++)d+="&args[]="+encodeURIComponent(arguments[c+1]);A(!1,"Minified React error #"+a+"; visit %s for the full message or use the non-minified dev environment for full errors and additional helpful warnings. ",d)}var C={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},D={};
13
- function E(a,b,d){this.props=a;this.context=b;this.refs=D;this.updater=d||C}E.prototype.isReactComponent={};E.prototype.setState=function(a,b){"object"!==typeof a&&"function"!==typeof a&&null!=a?B("85"):void 0;this.updater.enqueueSetState(this,a,b,"setState")};E.prototype.forceUpdate=function(a){this.updater.enqueueForceUpdate(this,a,"forceUpdate")};function F(){}F.prototype=E.prototype;function G(a,b,d){this.props=a;this.context=b;this.refs=D;this.updater=d||C}var H=G.prototype=new F;
14
- H.constructor=G;m(H,E.prototype);H.isPureReactComponent=!0;var I={current:null,currentDispatcher:null},J=Object.prototype.hasOwnProperty,K={key:!0,ref:!0,__self:!0,__source:!0};
15
- function L(a,b,d){var c=void 0,e={},g=null,h=null;if(null!=b)for(c in void 0!==b.ref&&(h=b.ref),void 0!==b.key&&(g=""+b.key),b)J.call(b,c)&&!K.hasOwnProperty(c)&&(e[c]=b[c]);var f=arguments.length-2;if(1===f)e.children=d;else if(1<f){for(var k=Array(f),l=0;l<f;l++)k[l]=arguments[l+2];e.children=k}if(a&&a.defaultProps)for(c in f=a.defaultProps,f)void 0===e[c]&&(e[c]=f[c]);return{$$typeof:p,type:a,key:g,ref:h,props:e,_owner:I.current}}
16
- function M(a,b){return{$$typeof:p,type:a.type,key:b,ref:a.ref,props:a.props,_owner:a._owner}}function N(a){return"object"===typeof a&&null!==a&&a.$$typeof===p}function escape(a){var b={"=":"=0",":":"=2"};return"$"+(""+a).replace(/[=:]/g,function(a){return b[a]})}var O=/\/+/g,P=[];function Q(a,b,d,c){if(P.length){var e=P.pop();e.result=a;e.keyPrefix=b;e.func=d;e.context=c;e.count=0;return e}return{result:a,keyPrefix:b,func:d,context:c,count:0}}
17
- function R(a){a.result=null;a.keyPrefix=null;a.func=null;a.context=null;a.count=0;10>P.length&&P.push(a)}
18
- function S(a,b,d,c){var e=typeof a;if("undefined"===e||"boolean"===e)a=null;var g=!1;if(null===a)g=!0;else switch(e){case "string":case "number":g=!0;break;case "object":switch(a.$$typeof){case p:case q:g=!0}}if(g)return d(c,a,""===b?"."+T(a,0):b),1;g=0;b=""===b?".":b+":";if(Array.isArray(a))for(var h=0;h<a.length;h++){e=a[h];var f=b+T(e,h);g+=S(e,f,d,c)}else if(null===a||"object"!==typeof a?f=null:(f=z&&a[z]||a["@@iterator"],f="function"===typeof f?f:null),"function"===typeof f)for(a=f.call(a),h=
19
- 0;!(e=a.next()).done;)e=e.value,f=b+T(e,h++),g+=S(e,f,d,c);else"object"===e&&(d=""+a,B("31","[object Object]"===d?"object with keys {"+Object.keys(a).join(", ")+"}":d,""));return g}function U(a,b,d){return null==a?0:S(a,"",b,d)}function T(a,b){return"object"===typeof a&&null!==a&&null!=a.key?escape(a.key):b.toString(36)}function V(a,b){a.func.call(a.context,b,a.count++)}
20
- function aa(a,b,d){var c=a.result,e=a.keyPrefix;a=a.func.call(a.context,b,a.count++);Array.isArray(a)?W(a,c,d,function(a){return a}):null!=a&&(N(a)&&(a=M(a,e+(!a.key||b&&b.key===a.key?"":(""+a.key).replace(O,"$&/")+"/")+d)),c.push(a))}function W(a,b,d,c,e){var g="";null!=d&&(g=(""+d).replace(O,"$&/")+"/");b=Q(b,g,c,e);U(a,aa,b);R(b)}function ba(a,b){var d=I.currentDispatcher;null===d?B("277"):void 0;return d.readContext(a,b)}
21
- var X={Children:{map:function(a,b,d){if(null==a)return a;var c=[];W(a,c,null,b,d);return c},forEach:function(a,b,d){if(null==a)return a;b=Q(null,null,b,d);U(a,V,b);R(b)},count:function(a){return U(a,function(){return null},null)},toArray:function(a){var b=[];W(a,b,null,function(a){return a});return b},only:function(a){N(a)?void 0:B("143");return a}},createRef:function(){return{current:null}},Component:E,PureComponent:G,createContext:function(a,b){void 0===b&&(b=null);a={$$typeof:w,_calculateChangedBits:b,
22
- _currentValue:a,_currentValue2:a,Provider:null,Consumer:null,unstable_read:null};a.Provider={$$typeof:v,_context:a};a.Consumer=a;a.unstable_read=ba.bind(null,a);return a},forwardRef:function(a){return{$$typeof:y,render:a}},Fragment:r,StrictMode:t,unstable_AsyncMode:x,unstable_Profiler:u,createElement:L,cloneElement:function(a,b,d){null===a||void 0===a?B("267",a):void 0;var c=void 0,e=m({},a.props),g=a.key,h=a.ref,f=a._owner;if(null!=b){void 0!==b.ref&&(h=b.ref,f=I.current);void 0!==b.key&&(g=""+b.key);
23
- var k=void 0;a.type&&a.type.defaultProps&&(k=a.type.defaultProps);for(c in b)J.call(b,c)&&!K.hasOwnProperty(c)&&(e[c]=void 0===b[c]&&void 0!==k?k[c]:b[c])}c=arguments.length-2;if(1===c)e.children=d;else if(1<c){k=Array(c);for(var l=0;l<c;l++)k[l]=arguments[l+2];e.children=k}return{$$typeof:p,type:a.type,key:g,ref:h,props:e,_owner:f}},createFactory:function(a){var b=L.bind(null,a);b.type=a;return b},isValidElement:N,version:"16.5.0",__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED:{ReactCurrentOwner:I,
24
- assign:m}},Y={default:X},Z=Y&&X||Y;module.exports=Z.default||Z;
10
+ 'use strict';var k=require("object-assign"),n="function"===typeof Symbol&&Symbol.for,p=n?Symbol.for("react.element"):60103,q=n?Symbol.for("react.portal"):60106,r=n?Symbol.for("react.fragment"):60107,t=n?Symbol.for("react.strict_mode"):60108,u=n?Symbol.for("react.profiler"):60114,v=n?Symbol.for("react.provider"):60109,w=n?Symbol.for("react.context"):60110,x=n?Symbol.for("react.concurrent_mode"):60111,y=n?Symbol.for("react.forward_ref"):60112;n&&Symbol.for("react.placeholder");
11
+ var z=n?Symbol.for("react.pure"):60115,A="function"===typeof Symbol&&Symbol.iterator;function B(a,b,d,c,e,g,h,f){if(!a){a=void 0;if(void 0===b)a=Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var l=[d,c,e,g,h,f],m=0;a=Error(b.replace(/%s/g,function(){return l[m++]}));a.name="Invariant Violation"}a.framesToPop=1;throw a;}}
12
+ function C(a){for(var b=arguments.length-1,d="https://reactjs.org/docs/error-decoder.html?invariant="+a,c=0;c<b;c++)d+="&args[]="+encodeURIComponent(arguments[c+1]);B(!1,"Minified React error #"+a+"; visit %s for the full message or use the non-minified dev environment for full errors and additional helpful warnings. ",d)}var D={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},E={};
13
+ function F(a,b,d){this.props=a;this.context=b;this.refs=E;this.updater=d||D}F.prototype.isReactComponent={};F.prototype.setState=function(a,b){"object"!==typeof a&&"function"!==typeof a&&null!=a?C("85"):void 0;this.updater.enqueueSetState(this,a,b,"setState")};F.prototype.forceUpdate=function(a){this.updater.enqueueForceUpdate(this,a,"forceUpdate")};function G(){}G.prototype=F.prototype;function H(a,b,d){this.props=a;this.context=b;this.refs=E;this.updater=d||D}var I=H.prototype=new G;
14
+ I.constructor=H;k(I,F.prototype);I.isPureReactComponent=!0;var J={current:null,currentDispatcher:null},K=Object.prototype.hasOwnProperty,L={key:!0,ref:!0,__self:!0,__source:!0};
15
+ function M(a,b,d){var c=void 0,e={},g=null,h=null;if(null!=b)for(c in void 0!==b.ref&&(h=b.ref),void 0!==b.key&&(g=""+b.key),b)K.call(b,c)&&!L.hasOwnProperty(c)&&(e[c]=b[c]);var f=arguments.length-2;if(1===f)e.children=d;else if(1<f){for(var l=Array(f),m=0;m<f;m++)l[m]=arguments[m+2];e.children=l}if(a&&a.defaultProps)for(c in f=a.defaultProps,f)void 0===e[c]&&(e[c]=f[c]);return{$$typeof:p,type:a,key:g,ref:h,props:e,_owner:J.current}}
16
+ function N(a,b){return{$$typeof:p,type:a.type,key:b,ref:a.ref,props:a.props,_owner:a._owner}}function O(a){return"object"===typeof a&&null!==a&&a.$$typeof===p}function escape(a){var b={"=":"=0",":":"=2"};return"$"+(""+a).replace(/[=:]/g,function(a){return b[a]})}var P=/\/+/g,Q=[];function R(a,b,d,c){if(Q.length){var e=Q.pop();e.result=a;e.keyPrefix=b;e.func=d;e.context=c;e.count=0;return e}return{result:a,keyPrefix:b,func:d,context:c,count:0}}
17
+ function S(a){a.result=null;a.keyPrefix=null;a.func=null;a.context=null;a.count=0;10>Q.length&&Q.push(a)}
18
+ function T(a,b,d,c){var e=typeof a;if("undefined"===e||"boolean"===e)a=null;var g=!1;if(null===a)g=!0;else switch(e){case "string":case "number":g=!0;break;case "object":switch(a.$$typeof){case p:case q:g=!0}}if(g)return d(c,a,""===b?"."+U(a,0):b),1;g=0;b=""===b?".":b+":";if(Array.isArray(a))for(var h=0;h<a.length;h++){e=a[h];var f=b+U(e,h);g+=T(e,f,d,c)}else if(null===a||"object"!==typeof a?f=null:(f=A&&a[A]||a["@@iterator"],f="function"===typeof f?f:null),"function"===typeof f)for(a=f.call(a),h=
19
+ 0;!(e=a.next()).done;)e=e.value,f=b+U(e,h++),g+=T(e,f,d,c);else"object"===e&&(d=""+a,C("31","[object Object]"===d?"object with keys {"+Object.keys(a).join(", ")+"}":d,""));return g}function V(a,b,d){return null==a?0:T(a,"",b,d)}function U(a,b){return"object"===typeof a&&null!==a&&null!=a.key?escape(a.key):b.toString(36)}function aa(a,b){a.func.call(a.context,b,a.count++)}
20
+ function ba(a,b,d){var c=a.result,e=a.keyPrefix;a=a.func.call(a.context,b,a.count++);Array.isArray(a)?W(a,c,d,function(a){return a}):null!=a&&(O(a)&&(a=N(a,e+(!a.key||b&&b.key===a.key?"":(""+a.key).replace(P,"$&/")+"/")+d)),c.push(a))}function W(a,b,d,c,e){var g="";null!=d&&(g=(""+d).replace(P,"$&/")+"/");b=R(b,g,c,e);V(a,ba,b);S(b)}function ca(a,b){var d=J.currentDispatcher;null===d?C("277"):void 0;return d.readContext(a,b)}
21
+ var X={Children:{map:function(a,b,d){if(null==a)return a;var c=[];W(a,c,null,b,d);return c},forEach:function(a,b,d){if(null==a)return a;b=R(null,null,b,d);V(a,aa,b);S(b)},count:function(a){return V(a,function(){return null},null)},toArray:function(a){var b=[];W(a,b,null,function(a){return a});return b},only:function(a){O(a)?void 0:C("143");return a}},createRef:function(){return{current:null}},Component:F,PureComponent:H,createContext:function(a,b){void 0===b&&(b=null);a={$$typeof:w,_calculateChangedBits:b,
22
+ _currentValue:a,_currentValue2:a,Provider:null,Consumer:null,unstable_read:null};a.Provider={$$typeof:v,_context:a};a.Consumer=a;a.unstable_read=ca.bind(null,a);return a},forwardRef:function(a){return{$$typeof:y,render:a}},pure:function(a,b){return{$$typeof:z,render:a,compare:void 0===b?null:b}},Fragment:r,StrictMode:t,unstable_ConcurrentMode:x,unstable_Profiler:u,createElement:M,cloneElement:function(a,b,d){null===a||void 0===a?C("267",a):void 0;var c=void 0,e=k({},a.props),g=a.key,h=a.ref,f=a._owner;
23
+ if(null!=b){void 0!==b.ref&&(h=b.ref,f=J.current);void 0!==b.key&&(g=""+b.key);var l=void 0;a.type&&a.type.defaultProps&&(l=a.type.defaultProps);for(c in b)K.call(b,c)&&!L.hasOwnProperty(c)&&(e[c]=void 0===b[c]&&void 0!==l?l[c]:b[c])}c=arguments.length-2;if(1===c)e.children=d;else if(1<c){l=Array(c);for(var m=0;m<c;m++)l[m]=arguments[m+2];e.children=l}return{$$typeof:p,type:a.type,key:g,ref:h,props:e,_owner:f}},createFactory:function(a){var b=M.bind(null,a);b.type=a;return b},isValidElement:O,version:"16.6.0-alpha.400d197",
24
+ __SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED:{ReactCurrentOwner:J,assign:k}},Y={default:X},Z=Y&&X||Y;module.exports=Z.default||Z;
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "keywords": [
5
5
  "react"
6
6
  ],
7
- "version": "16.5.0",
7
+ "version": "16.6.0-alpha.400d197",
8
8
  "homepage": "https://reactjs.org/",
9
9
  "bugs": "https://github.com/facebook/react/issues",
10
10
  "license": "MIT",
@@ -24,7 +24,7 @@
24
24
  "loose-envify": "^1.1.0",
25
25
  "object-assign": "^4.1.1",
26
26
  "prop-types": "^15.6.2",
27
- "schedule": "^0.3.0"
27
+ "scheduler": "^0.10.0-alpha.400d197"
28
28
  },
29
29
  "browserify": {
30
30
  "transform": [
@@ -1,7 +1,7 @@
1
- /** @license React v16.5.0
1
+ /** @license React v16.6.0-alpha.400d197
2
2
  * react.development.js
3
3
  *
4
- * Copyright (c) 2013-present, Facebook, Inc.
4
+ * Copyright (c) Facebook, Inc. and its affiliates.
5
5
  *
6
6
  * This source code is licensed under the MIT license found in the
7
7
  * LICENSE file in the root directory of this source tree.
@@ -17,7 +17,7 @@
17
17
 
18
18
  // TODO: this is special because it gets imported during build.
19
19
 
20
- var ReactVersion = '16.5.0';
20
+ var ReactVersion = '16.6.0-alpha.400d197';
21
21
 
22
22
  // The Symbol used to tag the ReactElement-like types. If there is no native Symbol
23
23
  // nor polyfill, then a plain number is used for performance.
@@ -30,9 +30,10 @@ var REACT_STRICT_MODE_TYPE = hasSymbol ? Symbol.for('react.strict_mode') : 0xeac
30
30
  var REACT_PROFILER_TYPE = hasSymbol ? Symbol.for('react.profiler') : 0xead2;
31
31
  var REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for('react.provider') : 0xeacd;
32
32
  var REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for('react.context') : 0xeace;
33
- var REACT_ASYNC_MODE_TYPE = hasSymbol ? Symbol.for('react.async_mode') : 0xeacf;
33
+ var REACT_CONCURRENT_MODE_TYPE = hasSymbol ? Symbol.for('react.concurrent_mode') : 0xeacf;
34
34
  var REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for('react.forward_ref') : 0xead0;
35
35
  var REACT_PLACEHOLDER_TYPE = hasSymbol ? Symbol.for('react.placeholder') : 0xead1;
36
+ var REACT_PURE_TYPE = hasSymbol ? Symbol.for('react.pure') : 0xead3;
36
37
 
37
38
  var MAYBE_ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
38
39
  var FAUX_ITERATOR_SYMBOL = '@@iterator';
@@ -48,59 +49,12 @@ function getIteratorFn(maybeIterable) {
48
49
  return null;
49
50
  }
50
51
 
51
- /**
52
- * Use invariant() to assert state which your program assumes to be true.
53
- *
54
- * Provide sprintf-style format (only %s is supported) and arguments
55
- * to provide information about what broke and what you were
56
- * expecting.
57
- *
58
- * The invariant message will be stripped in production, but the invariant
59
- * will remain to ensure logic does not differ in production.
60
- */
61
-
62
- var validateFormat = function () {};
63
-
64
- {
65
- validateFormat = function (format) {
66
- if (format === undefined) {
67
- throw new Error('invariant requires an error message argument');
68
- }
69
- };
70
- }
71
-
72
- function invariant(condition, format, a, b, c, d, e, f) {
73
- validateFormat(format);
74
-
75
- if (!condition) {
76
- var error = void 0;
77
- if (format === undefined) {
78
- error = new Error('Minified exception occurred; use the non-minified dev environment ' + 'for the full error message and additional helpful warnings.');
79
- } else {
80
- var args = [a, b, c, d, e, f];
81
- var argIndex = 0;
82
- error = new Error(format.replace(/%s/g, function () {
83
- return args[argIndex++];
84
- }));
85
- error.name = 'Invariant Violation';
86
- }
87
-
88
- error.framesToPop = 1; // we don't care about invariant's own frame
89
- throw error;
90
- }
91
- }
92
-
93
- // Relying on the `invariant()` implementation lets us
94
- // preserve the format and params in the www builds.
95
-
96
52
  // Exports ReactDOM.createRoot
97
53
 
98
54
 
99
- // Experimental error-boundary API that can recover from errors within a single
100
- // render phase
101
-
102
55
  // Suspense
103
56
  var enableSuspense = false;
57
+ var enableHooks_DEPRECATED = false;
104
58
  // Helps identify side effects in begin-phase lifecycle hooks and setState reducers:
105
59
 
106
60
 
@@ -117,20 +71,21 @@ var enableSuspense = false;
117
71
  // Warn about deprecated, async-unsafe lifecycles; relates to RFC #6:
118
72
 
119
73
 
120
- // Warn about legacy context API
121
-
122
-
123
74
  // Gather advanced timing metrics for Profiler subtrees.
124
75
 
125
76
 
126
- // Track which interactions trigger each commit.
127
- var enableSchedulerTracking = true;
77
+ // Trace which interactions trigger each commit.
78
+ var enableSchedulerTracing = true;
128
79
 
129
80
  // Only used in www builds.
130
81
 
131
82
 
132
83
  // Only used in www builds.
133
84
 
85
+
86
+ // React Fire: prevent the value and checked attributes from syncing
87
+ // with their related DOM properties
88
+
134
89
  /*
135
90
  object-assign
136
91
  (c) Sindre Sorhus
@@ -222,6 +177,51 @@ var objectAssign = shouldUseNative() ? Object.assign : function (target, source)
222
177
  return to;
223
178
  };
224
179
 
180
+ /**
181
+ * Use invariant() to assert state which your program assumes to be true.
182
+ *
183
+ * Provide sprintf-style format (only %s is supported) and arguments
184
+ * to provide information about what broke and what you were
185
+ * expecting.
186
+ *
187
+ * The invariant message will be stripped in production, but the invariant
188
+ * will remain to ensure logic does not differ in production.
189
+ */
190
+
191
+ var validateFormat = function () {};
192
+
193
+ {
194
+ validateFormat = function (format) {
195
+ if (format === undefined) {
196
+ throw new Error('invariant requires an error message argument');
197
+ }
198
+ };
199
+ }
200
+
201
+ function invariant(condition, format, a, b, c, d, e, f) {
202
+ validateFormat(format);
203
+
204
+ if (!condition) {
205
+ var error = void 0;
206
+ if (format === undefined) {
207
+ error = new Error('Minified exception occurred; use the non-minified dev environment ' + 'for the full error message and additional helpful warnings.');
208
+ } else {
209
+ var args = [a, b, c, d, e, f];
210
+ var argIndex = 0;
211
+ error = new Error(format.replace(/%s/g, function () {
212
+ return args[argIndex++];
213
+ }));
214
+ error.name = 'Invariant Violation';
215
+ }
216
+
217
+ error.framesToPop = 1; // we don't care about invariant's own frame
218
+ throw error;
219
+ }
220
+ }
221
+
222
+ // Relying on the `invariant()` implementation lets us
223
+ // preserve the format and params in the www builds.
224
+
225
225
  /**
226
226
  * Forked from fbjs/warning:
227
227
  * https://github.com/facebook/fbjs/blob/e66ba20ad5be433eb54423f2b097d829324d9de6/packages/fbjs/src/__forks__/warning.js
@@ -293,26 +293,71 @@ var warningWithoutStack = function () {};
293
293
  if (format === undefined) {
294
294
  throw new Error('`warningWithoutStack(condition, format, ...args)` requires a warning ' + 'message argument');
295
295
  }
296
+ if (args.length > 8) {
297
+ // Check before the condition to catch violations early.
298
+ throw new Error('warningWithoutStack() currently supports at most 8 arguments.');
299
+ }
296
300
  if (condition) {
297
301
  return;
298
302
  }
299
303
  if (typeof console !== 'undefined') {
300
- var _console;
301
-
302
- var stringArgs = args.map(function (item) {
304
+ var _args$map = args.map(function (item) {
303
305
  return '' + item;
304
- });
305
- (_console = console).error.apply(_console, ['Warning: ' + format].concat(stringArgs));
306
+ }),
307
+ a = _args$map[0],
308
+ b = _args$map[1],
309
+ c = _args$map[2],
310
+ d = _args$map[3],
311
+ e = _args$map[4],
312
+ f = _args$map[5],
313
+ g = _args$map[6],
314
+ h = _args$map[7];
315
+
316
+ var message = 'Warning: ' + format;
317
+
318
+ // We intentionally don't use spread (or .apply) because it breaks IE9:
319
+ // https://github.com/facebook/react/issues/13610
320
+ switch (args.length) {
321
+ case 0:
322
+ console.error(message);
323
+ break;
324
+ case 1:
325
+ console.error(message, a);
326
+ break;
327
+ case 2:
328
+ console.error(message, a, b);
329
+ break;
330
+ case 3:
331
+ console.error(message, a, b, c);
332
+ break;
333
+ case 4:
334
+ console.error(message, a, b, c, d);
335
+ break;
336
+ case 5:
337
+ console.error(message, a, b, c, d, e);
338
+ break;
339
+ case 6:
340
+ console.error(message, a, b, c, d, e, f);
341
+ break;
342
+ case 7:
343
+ console.error(message, a, b, c, d, e, f, g);
344
+ break;
345
+ case 8:
346
+ console.error(message, a, b, c, d, e, f, g, h);
347
+ break;
348
+ default:
349
+ throw new Error('warningWithoutStack() currently supports at most 8 arguments.');
350
+ }
306
351
  }
307
352
  try {
308
353
  // --- Welcome to debugging React ---
309
354
  // This error was thrown as a convenience so that you can use this stack
310
355
  // to find the callsite that caused this warning to fire.
311
356
  var argIndex = 0;
312
- var message = 'Warning: ' + format.replace(/%s/g, function () {
357
+ var _message = 'Warning: ' + format.replace(/%s/g, function () {
313
358
  return args[argIndex++];
314
359
  });
315
- throw new Error(message);
360
+ throw new Error(_message);
316
361
  } catch (x) {}
317
362
  };
318
363
  }
@@ -526,230 +571,514 @@ function createRef() {
526
571
  return refObject;
527
572
  }
528
573
 
529
- var canUseDOM = !!(typeof window !== 'undefined' && window.document && window.document.createElement);
574
+ /* eslint-disable no-var */
530
575
 
531
- /**
532
- * A scheduling library to allow scheduling work with more granular priority and
533
- * control than requestAnimationFrame and requestIdleCallback.
534
- * Current TODO items:
535
- * X- Pull out the scheduleWork polyfill built into React
536
- * X- Initial test coverage
537
- * X- Support for multiple callbacks
538
- * - Support for two priorities; serial and deferred
539
- * - Better test coverage
540
- * - Better docblock
541
- * - Polish documentation, API
542
- */
576
+ // TODO: Use symbols?
577
+ var ImmediatePriority = 1;
578
+ var InteractivePriority = 2;
579
+ var NormalPriority = 3;
580
+ var WheneverPriority = 4;
543
581
 
544
- // This is a built-in polyfill for requestIdleCallback. It works by scheduling
545
- // a requestAnimationFrame, storing the time for the start of the frame, then
546
- // scheduling a postMessage which gets scheduled after paint. Within the
547
- // postMessage handler do as much work as possible until time + frame rate.
548
- // By separating the idle call into a separate event tick we ensure that
549
- // layout, paint and other browser work is counted against the available time.
550
- // The frame rate is dynamically adjusted.
582
+ // Max 31 bit integer. The max integer size in V8 for 32-bit systems.
583
+ // Math.pow(2, 30) - 1
584
+ // 0b111111111111111111111111111111
585
+ var maxSigned31BitInt = 1073741823;
551
586
 
552
- // We capture a local reference to any global, in case it gets polyfilled after
553
- // this module is initially evaluated.
554
- // We want to be using a consistent implementation.
555
- var localDate = Date;
587
+ // Times out immediately
588
+ var IMMEDIATE_PRIORITY_TIMEOUT = -1;
589
+ // Eventually times out
590
+ var INTERACTIVE_PRIORITY_TIMEOUT = 250;
591
+ var NORMAL_PRIORITY_TIMEOUT = 5000;
592
+ // Never times out
593
+ var WHENEVER_PRIORITY_TIMEOUT = maxSigned31BitInt;
556
594
 
557
- // This initialization code may run even on server environments
558
- // if a component just imports ReactDOM (e.g. for findDOMNode).
559
- // Some environments might not have setTimeout or clearTimeout.
560
- // However, we always expect them to be defined on the client.
561
- // https://github.com/facebook/react/pull/13088
562
- var localSetTimeout = typeof setTimeout === 'function' ? setTimeout : undefined;
563
- var localClearTimeout = typeof clearTimeout === 'function' ? clearTimeout : undefined;
595
+ // Callbacks are stored as a circular, doubly linked list.
596
+ var firstCallbackNode = null;
564
597
 
565
- // We don't expect either of these to necessarily be defined,
566
- // but we will error later if they are missing on the client.
567
- var localRequestAnimationFrame = typeof requestAnimationFrame === 'function' ? requestAnimationFrame : undefined;
568
- var localCancelAnimationFrame = typeof cancelAnimationFrame === 'function' ? cancelAnimationFrame : undefined;
598
+ var currentPriorityLevel = NormalPriority;
599
+ var currentEventStartTime = -1;
600
+ var currentExpirationTime = -1;
601
+
602
+ // This is set when a callback is being executed, to prevent re-entrancy.
603
+ var isExecutingCallback = false;
604
+
605
+ var isHostCallbackScheduled = false;
569
606
 
570
607
  var hasNativePerformanceNow = typeof performance === 'object' && typeof performance.now === 'function';
571
608
 
572
- var now = void 0;
609
+ var timeRemaining;
573
610
  if (hasNativePerformanceNow) {
574
- var Performance = performance;
575
- now = function () {
576
- return Performance.now();
611
+ timeRemaining = function () {
612
+ if (firstCallbackNode !== null && firstCallbackNode.expirationTime < currentExpirationTime) {
613
+ // A higher priority callback was scheduled. Yield so we can switch to
614
+ // working on that.
615
+ return 0;
616
+ }
617
+ // We assume that if we have a performance timer that the rAF callback
618
+ // gets a performance timer value. Not sure if this is always true.
619
+ var remaining = getFrameDeadline() - performance.now();
620
+ return remaining > 0 ? remaining : 0;
577
621
  };
578
622
  } else {
579
- now = function () {
580
- return localDate.now();
623
+ timeRemaining = function () {
624
+ // Fallback to Date.now()
625
+ if (firstCallbackNode !== null && firstCallbackNode.expirationTime < currentExpirationTime) {
626
+ return 0;
627
+ }
628
+ var remaining = getFrameDeadline() - Date.now();
629
+ return remaining > 0 ? remaining : 0;
581
630
  };
582
631
  }
583
632
 
584
- var scheduleWork = void 0;
585
- var cancelScheduledWork = void 0;
633
+ var deadlineObject = {
634
+ timeRemaining: timeRemaining,
635
+ didTimeout: false
636
+ };
637
+
638
+ function ensureHostCallbackIsScheduled() {
639
+ if (isExecutingCallback) {
640
+ // Don't schedule work yet; wait until the next time we yield.
641
+ return;
642
+ }
643
+ // Schedule the host callback using the earliest expiration in the list.
644
+ var expirationTime = firstCallbackNode.expirationTime;
645
+ if (!isHostCallbackScheduled) {
646
+ isHostCallbackScheduled = true;
647
+ } else {
648
+ // Cancel the existing host callback.
649
+ cancelHostCallback();
650
+ }
651
+ requestHostCallback(flushWork, expirationTime);
652
+ }
653
+
654
+ function flushFirstCallback() {
655
+ var flushedNode = firstCallbackNode;
586
656
 
587
- if (!canUseDOM) {
588
- var timeoutIds = new Map();
657
+ // Remove the node from the list before calling the callback. That way the
658
+ // list is in a consistent state even if the callback throws.
659
+ var next = firstCallbackNode.next;
660
+ if (firstCallbackNode === next) {
661
+ // This is the last callback in the list.
662
+ firstCallbackNode = null;
663
+ next = null;
664
+ } else {
665
+ var lastCallbackNode = firstCallbackNode.previous;
666
+ firstCallbackNode = lastCallbackNode.next = next;
667
+ next.previous = lastCallbackNode;
668
+ }
669
+
670
+ flushedNode.next = flushedNode.previous = null;
671
+
672
+ // Now it's safe to call the callback.
673
+ var callback = flushedNode.callback;
674
+ var expirationTime = flushedNode.expirationTime;
675
+ var priorityLevel = flushedNode.priorityLevel;
676
+ var previousPriorityLevel = currentPriorityLevel;
677
+ var previousExpirationTime = currentExpirationTime;
678
+ currentPriorityLevel = priorityLevel;
679
+ currentExpirationTime = expirationTime;
680
+ var continuationCallback;
681
+ try {
682
+ continuationCallback = callback(deadlineObject);
683
+ } finally {
684
+ currentPriorityLevel = previousPriorityLevel;
685
+ currentExpirationTime = previousExpirationTime;
686
+ }
589
687
 
590
- scheduleWork = function (callback, options) {
591
- // keeping return type consistent
592
- var callbackConfig = {
593
- scheduledCallback: callback,
594
- timeoutTime: 0,
688
+ // A callback may return a continuation. The continuation should be scheduled
689
+ // with the same priority and expiration as the just-finished callback.
690
+ if (typeof continuationCallback === 'function') {
691
+ var continuationNode = {
692
+ callback: continuationCallback,
693
+ priorityLevel: priorityLevel,
694
+ expirationTime: expirationTime,
595
695
  next: null,
596
- prev: null
696
+ previous: null
597
697
  };
598
- var timeoutId = localSetTimeout(function () {
599
- callback({
600
- timeRemaining: function () {
601
- return Infinity;
602
- },
603
698
 
604
- didTimeout: false
605
- });
606
- });
607
- timeoutIds.set(callback, timeoutId);
608
- return callbackConfig;
609
- };
610
- cancelScheduledWork = function (callbackId) {
611
- var callback = callbackId.scheduledCallback;
612
- var timeoutId = timeoutIds.get(callback);
613
- timeoutIds.delete(callbackId);
614
- localClearTimeout(timeoutId);
615
- };
616
- } else {
617
- {
618
- if (typeof console !== 'undefined') {
619
- if (typeof localRequestAnimationFrame !== 'function') {
620
- console.error("This browser doesn't support requestAnimationFrame. " + 'Make sure that you load a ' + 'polyfill in older browsers. https://fb.me/react-polyfills');
699
+ // Insert the new callback into the list, sorted by its expiration. This is
700
+ // almost the same as the code in `scheduleCallback`, except the callback
701
+ // is inserted into the list *before* callbacks of equal expiration instead
702
+ // of after.
703
+ if (firstCallbackNode === null) {
704
+ // This is the first callback in the list.
705
+ firstCallbackNode = continuationNode.next = continuationNode.previous = continuationNode;
706
+ } else {
707
+ var nextAfterContinuation = null;
708
+ var node = firstCallbackNode;
709
+ do {
710
+ if (node.expirationTime >= expirationTime) {
711
+ // This callback expires at or after the continuation. We will insert
712
+ // the continuation *before* this callback.
713
+ nextAfterContinuation = node;
714
+ break;
715
+ }
716
+ node = node.next;
717
+ } while (node !== firstCallbackNode);
718
+
719
+ if (nextAfterContinuation === null) {
720
+ // No equal or lower priority callback was found, which means the new
721
+ // callback is the lowest priority callback in the list.
722
+ nextAfterContinuation = firstCallbackNode;
723
+ } else if (nextAfterContinuation === firstCallbackNode) {
724
+ // The new callback is the highest priority callback in the list.
725
+ firstCallbackNode = continuationNode;
726
+ ensureHostCallbackIsScheduled(firstCallbackNode);
621
727
  }
622
- if (typeof localCancelAnimationFrame !== 'function') {
623
- console.error("This browser doesn't support cancelAnimationFrame. " + 'Make sure that you load a ' + 'polyfill in older browsers. https://fb.me/react-polyfills');
728
+
729
+ var previous = nextAfterContinuation.previous;
730
+ previous.next = nextAfterContinuation.previous = continuationNode;
731
+ continuationNode.next = nextAfterContinuation;
732
+ continuationNode.previous = previous;
733
+ }
734
+ }
735
+ }
736
+
737
+ function flushImmediateWork() {
738
+ if (
739
+ // Confirm we've exited the outer most event handler
740
+ currentEventStartTime === -1 && firstCallbackNode !== null && firstCallbackNode.priorityLevel === ImmediatePriority) {
741
+ isExecutingCallback = true;
742
+ deadlineObject.didTimeout = true;
743
+ try {
744
+ do {
745
+ flushFirstCallback();
746
+ } while (
747
+ // Keep flushing until there are no more immediate callbacks
748
+ firstCallbackNode !== null && firstCallbackNode.priorityLevel === ImmediatePriority);
749
+ } finally {
750
+ isExecutingCallback = false;
751
+ if (firstCallbackNode !== null) {
752
+ // There's still work remaining. Request another callback.
753
+ ensureHostCallbackIsScheduled(firstCallbackNode);
754
+ } else {
755
+ isHostCallbackScheduled = false;
624
756
  }
625
757
  }
626
758
  }
759
+ }
627
760
 
628
- var headOfPendingCallbacksLinkedList = null;
629
- var tailOfPendingCallbacksLinkedList = null;
761
+ function flushWork(didTimeout) {
762
+ isExecutingCallback = true;
763
+ deadlineObject.didTimeout = didTimeout;
764
+ try {
765
+ if (didTimeout) {
766
+ // Flush all the expired callbacks without yielding.
767
+ while (firstCallbackNode !== null) {
768
+ // Read the current time. Flush all the callbacks that expire at or
769
+ // earlier than that time. Then read the current time again and repeat.
770
+ // This optimizes for as few performance.now calls as possible.
771
+ var currentTime = getCurrentTime();
772
+ if (firstCallbackNode.expirationTime <= currentTime) {
773
+ do {
774
+ flushFirstCallback();
775
+ } while (firstCallbackNode !== null && firstCallbackNode.expirationTime <= currentTime);
776
+ continue;
777
+ }
778
+ break;
779
+ }
780
+ } else {
781
+ // Keep flushing callbacks until we run out of time in the frame.
782
+ if (firstCallbackNode !== null) {
783
+ do {
784
+ flushFirstCallback();
785
+ } while (firstCallbackNode !== null && getFrameDeadline() - getCurrentTime() > 0);
786
+ }
787
+ }
788
+ } finally {
789
+ isExecutingCallback = false;
790
+ if (firstCallbackNode !== null) {
791
+ // There's still work remaining. Request another callback.
792
+ ensureHostCallbackIsScheduled(firstCallbackNode);
793
+ } else {
794
+ isHostCallbackScheduled = false;
795
+ }
796
+ // Before exiting, flush all the immediate work that was scheduled.
797
+ flushImmediateWork();
798
+ }
799
+ }
630
800
 
631
- // We track what the next soonest timeoutTime is, to be able to quickly tell
632
- // if none of the scheduled callbacks have timed out.
633
- var nextSoonestTimeoutTime = -1;
801
+ function unstable_runWithPriority(priorityLevel, eventHandler) {
802
+ switch (priorityLevel) {
803
+ case ImmediatePriority:
804
+ case InteractivePriority:
805
+ case NormalPriority:
806
+ case WheneverPriority:
807
+ break;
808
+ default:
809
+ priorityLevel = NormalPriority;
810
+ }
634
811
 
635
- var isIdleScheduled = false;
636
- var isAnimationFrameScheduled = false;
812
+ var previousPriorityLevel = currentPriorityLevel;
813
+ var previousEventStartTime = currentEventStartTime;
814
+ currentPriorityLevel = priorityLevel;
815
+ currentEventStartTime = getCurrentTime();
637
816
 
638
- // requestAnimationFrame does not run when the tab is in the background.
639
- // if we're backgrounded we prefer for that work to happen so that the page
640
- // continues to load in the background.
641
- // so we also schedule a 'setTimeout' as a fallback.
642
- var animationFrameTimeout = 100;
643
- var rafID = void 0;
644
- var timeoutID = void 0;
645
- var scheduleAnimationFrameWithFallbackSupport = function (callback) {
646
- // schedule rAF and also a setTimeout
647
- rafID = localRequestAnimationFrame(function (timestamp) {
648
- // cancel the setTimeout
649
- localClearTimeout(timeoutID);
650
- callback(timestamp);
651
- });
652
- timeoutID = localSetTimeout(function () {
653
- // cancel the requestAnimationFrame
654
- localCancelAnimationFrame(rafID);
655
- callback(now());
656
- }, animationFrameTimeout);
657
- };
817
+ try {
818
+ return eventHandler();
819
+ } finally {
820
+ currentPriorityLevel = previousPriorityLevel;
821
+ currentEventStartTime = previousEventStartTime;
658
822
 
659
- var frameDeadline = 0;
660
- // We start out assuming that we run at 30fps but then the heuristic tracking
661
- // will adjust this value to a faster fps if we get more frequent animation
662
- // frames.
663
- var previousFrameTime = 33;
664
- var activeFrameTime = 33;
823
+ // Before exiting, flush all the immediate work that was scheduled.
824
+ flushImmediateWork();
825
+ }
826
+ }
665
827
 
666
- var frameDeadlineObject = {
667
- didTimeout: false,
668
- timeRemaining: function () {
669
- var remaining = frameDeadline - now();
670
- return remaining > 0 ? remaining : 0;
671
- }
672
- };
828
+ function unstable_wrapCallback(callback) {
829
+ var parentPriorityLevel = currentPriorityLevel;
830
+ return function () {
831
+ // This is a fork of runWithPriority, inlined for performance.
832
+ var previousPriorityLevel = currentPriorityLevel;
833
+ var previousEventStartTime = currentEventStartTime;
834
+ currentPriorityLevel = parentPriorityLevel;
835
+ currentEventStartTime = getCurrentTime();
673
836
 
674
- /**
675
- * Handles the case where a callback errors:
676
- * - don't catch the error, because this changes debugging behavior
677
- * - do start a new postMessage callback, to call any remaining callbacks,
678
- * - but only if there is an error, so there is not extra overhead.
679
- */
680
- var callUnsafely = function (callbackConfig, arg) {
681
- var callback = callbackConfig.scheduledCallback;
682
- var finishedCalling = false;
683
837
  try {
684
- callback(arg);
685
- finishedCalling = true;
838
+ return callback.apply(this, arguments);
686
839
  } finally {
687
- // always remove it from linked list
688
- cancelScheduledWork(callbackConfig);
689
-
690
- if (!finishedCalling) {
691
- // an error must have been thrown
692
- isIdleScheduled = true;
693
- window.postMessage(messageKey, '*');
694
- }
840
+ currentPriorityLevel = previousPriorityLevel;
841
+ currentEventStartTime = previousEventStartTime;
842
+ flushImmediateWork();
695
843
  }
696
844
  };
845
+ }
697
846
 
698
- /**
699
- * Checks for timed out callbacks, runs them, and then checks again to see if
700
- * any more have timed out.
701
- * Keeps doing this until there are none which have currently timed out.
702
- */
703
- var callTimedOutCallbacks = function () {
704
- if (headOfPendingCallbacksLinkedList === null) {
705
- return;
706
- }
847
+ function unstable_scheduleCallback(callback, deprecated_options) {
848
+ var startTime = currentEventStartTime !== -1 ? currentEventStartTime : getCurrentTime();
707
849
 
708
- var currentTime = now();
709
- // TODO: this would be more efficient if deferred callbacks are stored in
710
- // min heap.
711
- // Or in a linked list with links for both timeoutTime order and insertion
712
- // order.
713
- // For now an easy compromise is the current approach:
714
- // Keep a pointer to the soonest timeoutTime, and check that first.
715
- // If it has not expired, we can skip traversing the whole list.
716
- // If it has expired, then we step through all the callbacks.
717
- if (nextSoonestTimeoutTime === -1 || nextSoonestTimeoutTime > currentTime) {
718
- // We know that none of them have timed out yet.
719
- return;
850
+ var expirationTime;
851
+ if (typeof deprecated_options === 'object' && deprecated_options !== null && typeof deprecated_options.timeout === 'number') {
852
+ // FIXME: Remove this branch once we lift expiration times out of React.
853
+ expirationTime = startTime + deprecated_options.timeout;
854
+ } else {
855
+ switch (currentPriorityLevel) {
856
+ case ImmediatePriority:
857
+ expirationTime = startTime + IMMEDIATE_PRIORITY_TIMEOUT;
858
+ break;
859
+ case InteractivePriority:
860
+ expirationTime = startTime + INTERACTIVE_PRIORITY_TIMEOUT;
861
+ break;
862
+ case WheneverPriority:
863
+ expirationTime = startTime + WHENEVER_PRIORITY_TIMEOUT;
864
+ break;
865
+ case NormalPriority:
866
+ default:
867
+ expirationTime = startTime + NORMAL_PRIORITY_TIMEOUT;
720
868
  }
721
- // NOTE: we intentionally wait to update the nextSoonestTimeoutTime until
722
- // after successfully calling any timed out callbacks.
723
- // If a timed out callback throws an error, we could get stuck in a state
724
- // where the nextSoonestTimeoutTime was set wrong.
725
- var updatedNextSoonestTimeoutTime = -1; // we will update nextSoonestTimeoutTime below
726
- var timedOutCallbacks = [];
727
-
728
- // iterate once to find timed out callbacks and find nextSoonestTimeoutTime
729
- var currentCallbackConfig = headOfPendingCallbacksLinkedList;
730
- while (currentCallbackConfig !== null) {
731
- var _timeoutTime = currentCallbackConfig.timeoutTime;
732
- if (_timeoutTime !== -1 && _timeoutTime <= currentTime) {
733
- // it has timed out!
734
- timedOutCallbacks.push(currentCallbackConfig);
735
- } else {
736
- if (_timeoutTime !== -1 && (updatedNextSoonestTimeoutTime === -1 || _timeoutTime < updatedNextSoonestTimeoutTime)) {
737
- updatedNextSoonestTimeoutTime = _timeoutTime;
738
- }
869
+ }
870
+
871
+ var newNode = {
872
+ callback: callback,
873
+ priorityLevel: currentPriorityLevel,
874
+ expirationTime: expirationTime,
875
+ next: null,
876
+ previous: null
877
+ };
878
+
879
+ // Insert the new callback into the list, ordered first by expiration, then
880
+ // by insertion. So the new callback is inserted any other callback with
881
+ // equal expiration.
882
+ if (firstCallbackNode === null) {
883
+ // This is the first callback in the list.
884
+ firstCallbackNode = newNode.next = newNode.previous = newNode;
885
+ ensureHostCallbackIsScheduled(firstCallbackNode);
886
+ } else {
887
+ var next = null;
888
+ var node = firstCallbackNode;
889
+ do {
890
+ if (node.expirationTime > expirationTime) {
891
+ // The new callback expires before this one.
892
+ next = node;
893
+ break;
739
894
  }
740
- currentCallbackConfig = currentCallbackConfig.next;
895
+ node = node.next;
896
+ } while (node !== firstCallbackNode);
897
+
898
+ if (next === null) {
899
+ // No callback with a later expiration was found, which means the new
900
+ // callback has the latest expiration in the list.
901
+ next = firstCallbackNode;
902
+ } else if (next === firstCallbackNode) {
903
+ // The new callback has the earliest expiration in the entire list.
904
+ firstCallbackNode = newNode;
905
+ ensureHostCallbackIsScheduled(firstCallbackNode);
906
+ }
907
+
908
+ var previous = next.previous;
909
+ previous.next = next.previous = newNode;
910
+ newNode.next = next;
911
+ newNode.previous = previous;
912
+ }
913
+
914
+ return newNode;
915
+ }
916
+
917
+ function unstable_cancelCallback(callbackNode) {
918
+ var next = callbackNode.next;
919
+ if (next === null) {
920
+ // Already cancelled.
921
+ return;
922
+ }
923
+
924
+ if (next === callbackNode) {
925
+ // This is the only scheduled callback. Clear the list.
926
+ firstCallbackNode = null;
927
+ } else {
928
+ // Remove the callback from its position in the list.
929
+ if (callbackNode === firstCallbackNode) {
930
+ firstCallbackNode = next;
741
931
  }
932
+ var previous = callbackNode.previous;
933
+ previous.next = next;
934
+ next.previous = previous;
935
+ }
936
+
937
+ callbackNode.next = callbackNode.previous = null;
938
+ }
939
+
940
+ function unstable_getCurrentPriorityLevel() {
941
+ return currentPriorityLevel;
942
+ }
943
+
944
+ // The remaining code is essentially a polyfill for requestIdleCallback. It
945
+ // works by scheduling a requestAnimationFrame, storing the time for the start
946
+ // of the frame, then scheduling a postMessage which gets scheduled after paint.
947
+ // Within the postMessage handler do as much work as possible until time + frame
948
+ // rate. By separating the idle call into a separate event tick we ensure that
949
+ // layout, paint and other browser work is counted against the available time.
950
+ // The frame rate is dynamically adjusted.
951
+
952
+ // We capture a local reference to any global, in case it gets polyfilled after
953
+ // this module is initially evaluated. We want to be using a
954
+ // consistent implementation.
955
+ var localDate = Date;
956
+
957
+ // This initialization code may run even on server environments if a component
958
+ // just imports ReactDOM (e.g. for findDOMNode). Some environments might not
959
+ // have setTimeout or clearTimeout. However, we always expect them to be defined
960
+ // on the client. https://github.com/facebook/react/pull/13088
961
+ var localSetTimeout = typeof setTimeout === 'function' ? setTimeout : undefined;
962
+ var localClearTimeout = typeof clearTimeout === 'function' ? clearTimeout : undefined;
963
+
964
+ // We don't expect either of these to necessarily be defined, but we will error
965
+ // later if they are missing on the client.
966
+ var localRequestAnimationFrame = typeof requestAnimationFrame === 'function' ? requestAnimationFrame : undefined;
967
+ var localCancelAnimationFrame = typeof cancelAnimationFrame === 'function' ? cancelAnimationFrame : undefined;
968
+
969
+ var getCurrentTime;
970
+
971
+ // requestAnimationFrame does not run when the tab is in the background. If
972
+ // we're backgrounded we prefer for that work to happen so that the page
973
+ // continues to load in the background. So we also schedule a 'setTimeout' as
974
+ // a fallback.
975
+ // TODO: Need a better heuristic for backgrounded work.
976
+ var ANIMATION_FRAME_TIMEOUT = 100;
977
+ var rAFID;
978
+ var rAFTimeoutID;
979
+ var requestAnimationFrameWithTimeout = function (callback) {
980
+ // schedule rAF and also a setTimeout
981
+ rAFID = localRequestAnimationFrame(function (timestamp) {
982
+ // cancel the setTimeout
983
+ localClearTimeout(rAFTimeoutID);
984
+ callback(timestamp);
985
+ });
986
+ rAFTimeoutID = localSetTimeout(function () {
987
+ // cancel the requestAnimationFrame
988
+ localCancelAnimationFrame(rAFID);
989
+ callback(getCurrentTime());
990
+ }, ANIMATION_FRAME_TIMEOUT);
991
+ };
992
+
993
+ if (hasNativePerformanceNow) {
994
+ var Performance = performance;
995
+ getCurrentTime = function () {
996
+ return Performance.now();
997
+ };
998
+ } else {
999
+ getCurrentTime = function () {
1000
+ return localDate.now();
1001
+ };
1002
+ }
742
1003
 
743
- if (timedOutCallbacks.length > 0) {
744
- frameDeadlineObject.didTimeout = true;
745
- for (var i = 0, len = timedOutCallbacks.length; i < len; i++) {
746
- callUnsafely(timedOutCallbacks[i], frameDeadlineObject);
1004
+ var requestHostCallback;
1005
+ var cancelHostCallback;
1006
+ var getFrameDeadline;
1007
+
1008
+ if (typeof window !== 'undefined' && window._schedMock) {
1009
+ // Dynamic injection, only for testing purposes.
1010
+ var impl = window._schedMock;
1011
+ requestHostCallback = impl[0];
1012
+ cancelHostCallback = impl[1];
1013
+ getFrameDeadline = impl[2];
1014
+ } else if (
1015
+ // If Scheduler runs in a non-DOM environment, it falls back to a naive
1016
+ // implementation using setTimeout.
1017
+ typeof window === 'undefined' ||
1018
+ // "addEventListener" might not be available on the window object
1019
+ // if this is a mocked "window" object. So we need to validate that too.
1020
+ typeof window.addEventListener !== 'function') {
1021
+ var _callback = null;
1022
+ var _currentTime = -1;
1023
+ var _flushCallback = function (didTimeout, ms) {
1024
+ if (_callback !== null) {
1025
+ var cb = _callback;
1026
+ _callback = null;
1027
+ try {
1028
+ _currentTime = ms;
1029
+ cb(didTimeout);
1030
+ } finally {
1031
+ _currentTime = -1;
747
1032
  }
748
1033
  }
1034
+ };
1035
+ requestHostCallback = function (cb, ms) {
1036
+ if (_currentTime !== -1) {
1037
+ // Protect against re-entrancy.
1038
+ setTimeout(requestHostCallback, 0, cb, ms);
1039
+ } else {
1040
+ _callback = cb;
1041
+ setTimeout(_flushCallback, ms, true, ms);
1042
+ setTimeout(_flushCallback, maxSigned31BitInt, false, maxSigned31BitInt);
1043
+ }
1044
+ };
1045
+ cancelHostCallback = function () {
1046
+ _callback = null;
1047
+ };
1048
+ getFrameDeadline = function () {
1049
+ return Infinity;
1050
+ };
1051
+ getCurrentTime = function () {
1052
+ return _currentTime === -1 ? 0 : _currentTime;
1053
+ };
1054
+ } else {
1055
+ if (typeof console !== 'undefined') {
1056
+ // TODO: Remove fb.me link
1057
+ if (typeof localRequestAnimationFrame !== 'function') {
1058
+ console.error("This browser doesn't support requestAnimationFrame. " + 'Make sure that you load a ' + 'polyfill in older browsers. https://fb.me/react-polyfills');
1059
+ }
1060
+ if (typeof localCancelAnimationFrame !== 'function') {
1061
+ console.error("This browser doesn't support cancelAnimationFrame. " + 'Make sure that you load a ' + 'polyfill in older browsers. https://fb.me/react-polyfills');
1062
+ }
1063
+ }
749
1064
 
750
- // NOTE: we intentionally wait to update the nextSoonestTimeoutTime until
751
- // after successfully calling any timed out callbacks.
752
- nextSoonestTimeoutTime = updatedNextSoonestTimeoutTime;
1065
+ var scheduledCallback = null;
1066
+ var isIdleScheduled = false;
1067
+ var timeoutTime = -1;
1068
+
1069
+ var isAnimationFrameScheduled = false;
1070
+
1071
+ var isPerformingIdleWork = false;
1072
+
1073
+ var frameDeadline = 0;
1074
+ // We start out assuming that we run at 30fps but then the heuristic tracking
1075
+ // will adjust this value to a faster fps if we get more frequent animation
1076
+ // frames.
1077
+ var previousFrameTime = 33;
1078
+ var activeFrameTime = 33;
1079
+
1080
+ getFrameDeadline = function () {
1081
+ return frameDeadline;
753
1082
  };
754
1083
 
755
1084
  // We use the postMessage trick to defer idle work until after the repaint.
@@ -758,29 +1087,40 @@ if (!canUseDOM) {
758
1087
  if (event.source !== window || event.data !== messageKey) {
759
1088
  return;
760
1089
  }
761
- isIdleScheduled = false;
762
1090
 
763
- if (headOfPendingCallbacksLinkedList === null) {
764
- return;
765
- }
1091
+ isIdleScheduled = false;
766
1092
 
767
- // First call anything which has timed out, until we have caught up.
768
- callTimedOutCallbacks();
1093
+ var currentTime = getCurrentTime();
769
1094
 
770
- var currentTime = now();
771
- // Next, as long as we have idle time, try calling more callbacks.
772
- while (frameDeadline - currentTime > 0 && headOfPendingCallbacksLinkedList !== null) {
773
- var latestCallbackConfig = headOfPendingCallbacksLinkedList;
774
- frameDeadlineObject.didTimeout = false;
775
- // callUnsafely will remove it from the head of the linked list
776
- callUnsafely(latestCallbackConfig, frameDeadlineObject);
777
- currentTime = now();
1095
+ var didTimeout = false;
1096
+ if (frameDeadline - currentTime <= 0) {
1097
+ // There's no time left in this idle period. Check if the callback has
1098
+ // a timeout and whether it's been exceeded.
1099
+ if (timeoutTime !== -1 && timeoutTime <= currentTime) {
1100
+ // Exceeded the timeout. Invoke the callback even though there's no
1101
+ // time left.
1102
+ didTimeout = true;
1103
+ } else {
1104
+ // No timeout.
1105
+ if (!isAnimationFrameScheduled) {
1106
+ // Schedule another animation callback so we retry later.
1107
+ isAnimationFrameScheduled = true;
1108
+ requestAnimationFrameWithTimeout(animationTick);
1109
+ }
1110
+ // Exit without invoking the callback.
1111
+ return;
1112
+ }
778
1113
  }
779
- if (headOfPendingCallbacksLinkedList !== null) {
780
- if (!isAnimationFrameScheduled) {
781
- // Schedule another animation callback so we retry later.
782
- isAnimationFrameScheduled = true;
783
- scheduleAnimationFrameWithFallbackSupport(animationTick);
1114
+
1115
+ timeoutTime = -1;
1116
+ var callback = scheduledCallback;
1117
+ scheduledCallback = null;
1118
+ if (callback !== null) {
1119
+ isPerformingIdleWork = true;
1120
+ try {
1121
+ callback(didTimeout);
1122
+ } finally {
1123
+ isPerformingIdleWork = false;
784
1124
  }
785
1125
  }
786
1126
  };
@@ -794,7 +1134,7 @@ if (!canUseDOM) {
794
1134
  if (nextFrameTime < activeFrameTime && previousFrameTime < activeFrameTime) {
795
1135
  if (nextFrameTime < 8) {
796
1136
  // Defensive coding. We don't support higher frame rates than 120hz.
797
- // If we get lower than that, it is probably a bug.
1137
+ // If the calculated frame time gets lower than 8, it is probably a bug.
798
1138
  nextFrameTime = 8;
799
1139
  }
800
1140
  // If one frame goes long, then the next one can be short to catch up.
@@ -815,109 +1155,26 @@ if (!canUseDOM) {
815
1155
  }
816
1156
  };
817
1157
 
818
- scheduleWork = function (callback, options) /* CallbackConfigType */{
819
- var timeoutTime = -1;
820
- if (options != null && typeof options.timeout === 'number') {
821
- timeoutTime = now() + options.timeout;
822
- }
823
- if (nextSoonestTimeoutTime === -1 || timeoutTime !== -1 && timeoutTime < nextSoonestTimeoutTime) {
824
- nextSoonestTimeoutTime = timeoutTime;
825
- }
826
-
827
- var scheduledCallbackConfig = {
828
- scheduledCallback: callback,
829
- timeoutTime: timeoutTime,
830
- prev: null,
831
- next: null
832
- };
833
- if (headOfPendingCallbacksLinkedList === null) {
834
- // Make this callback the head and tail of our list
835
- headOfPendingCallbacksLinkedList = scheduledCallbackConfig;
836
- tailOfPendingCallbacksLinkedList = scheduledCallbackConfig;
837
- } else {
838
- // Add latest callback as the new tail of the list
839
- scheduledCallbackConfig.prev = tailOfPendingCallbacksLinkedList;
840
- // renaming for clarity
841
- var oldTailOfPendingCallbacksLinkedList = tailOfPendingCallbacksLinkedList;
842
- if (oldTailOfPendingCallbacksLinkedList !== null) {
843
- oldTailOfPendingCallbacksLinkedList.next = scheduledCallbackConfig;
844
- }
845
- tailOfPendingCallbacksLinkedList = scheduledCallbackConfig;
846
- }
847
-
848
- if (!isAnimationFrameScheduled) {
1158
+ requestHostCallback = function (callback, absoluteTimeout) {
1159
+ scheduledCallback = callback;
1160
+ timeoutTime = absoluteTimeout;
1161
+ if (isPerformingIdleWork || absoluteTimeout < 0) {
1162
+ // Don't wait for the next frame. Continue working ASAP, in a new event.
1163
+ window.postMessage(messageKey, '*');
1164
+ } else if (!isAnimationFrameScheduled) {
849
1165
  // If rAF didn't already schedule one, we need to schedule a frame.
850
1166
  // TODO: If this rAF doesn't materialize because the browser throttles, we
851
- // might want to still have setTimeout trigger scheduleWork as a backup to ensure
1167
+ // might want to still have setTimeout trigger rIC as a backup to ensure
852
1168
  // that we keep performing work.
853
1169
  isAnimationFrameScheduled = true;
854
- scheduleAnimationFrameWithFallbackSupport(animationTick);
1170
+ requestAnimationFrameWithTimeout(animationTick);
855
1171
  }
856
- return scheduledCallbackConfig;
857
1172
  };
858
1173
 
859
- cancelScheduledWork = function (callbackConfig /* CallbackConfigType */
860
- ) {
861
- if (callbackConfig.prev === null && headOfPendingCallbacksLinkedList !== callbackConfig) {
862
- // this callbackConfig has already been cancelled.
863
- // cancelScheduledWork should be idempotent, a no-op after first call.
864
- return;
865
- }
866
-
867
- /**
868
- * There are four possible cases:
869
- * - Head/nodeToRemove/Tail -> null
870
- * In this case we set Head and Tail to null.
871
- * - Head -> ... middle nodes... -> Tail/nodeToRemove
872
- * In this case we point the middle.next to null and put middle as the new
873
- * Tail.
874
- * - Head/nodeToRemove -> ...middle nodes... -> Tail
875
- * In this case we point the middle.prev at null and move the Head to
876
- * middle.
877
- * - Head -> ... ?some nodes ... -> nodeToRemove -> ... ?some nodes ... -> Tail
878
- * In this case we point the Head.next to the Tail and the Tail.prev to
879
- * the Head.
880
- */
881
- var next = callbackConfig.next;
882
- var prev = callbackConfig.prev;
883
- callbackConfig.next = null;
884
- callbackConfig.prev = null;
885
- if (next !== null) {
886
- // we have a next
887
-
888
- if (prev !== null) {
889
- // we have a prev
890
-
891
- // callbackConfig is somewhere in the middle of a list of 3 or more nodes.
892
- prev.next = next;
893
- next.prev = prev;
894
- return;
895
- } else {
896
- // there is a next but not a previous one;
897
- // callbackConfig is the head of a list of 2 or more other nodes.
898
- next.prev = null;
899
- headOfPendingCallbacksLinkedList = next;
900
- return;
901
- }
902
- } else {
903
- // there is no next callback config; this must the tail of the list
904
-
905
- if (prev !== null) {
906
- // we have a prev
907
-
908
- // callbackConfig is the tail of a list of 2 or more other nodes.
909
- prev.next = null;
910
- tailOfPendingCallbacksLinkedList = prev;
911
- return;
912
- } else {
913
- // there is no previous callback config;
914
- // callbackConfig is the only thing in the linked list,
915
- // so both head and tail point to it.
916
- headOfPendingCallbacksLinkedList = null;
917
- tailOfPendingCallbacksLinkedList = null;
918
- return;
919
- }
920
- }
1174
+ cancelHostCallback = function () {
1175
+ scheduledCallback = null;
1176
+ isIdleScheduled = false;
1177
+ timeoutTime = -1;
921
1178
  };
922
1179
  }
923
1180
 
@@ -927,16 +1184,16 @@ var DEFAULT_THREAD_ID = 0;
927
1184
  var interactionIDCounter = 0;
928
1185
  var threadIDCounter = 0;
929
1186
 
930
- // Set of currently tracked interactions.
1187
+ // Set of currently traced interactions.
931
1188
  // Interactions "stack"–
932
- // Meaning that newly tracked interactions are appended to the previously active set.
1189
+ // Meaning that newly traced interactions are appended to the previously active set.
933
1190
  // When an interaction goes out of scope, the previous set (if any) is restored.
934
1191
  var interactionsRef = null;
935
1192
 
936
1193
  // Listener(s) to notify when interactions begin and end.
937
1194
  var subscriberRef = null;
938
1195
 
939
- if (enableSchedulerTracking) {
1196
+ if (enableSchedulerTracing) {
940
1197
  interactionsRef = {
941
1198
  current: new Set()
942
1199
  };
@@ -946,7 +1203,7 @@ if (enableSchedulerTracking) {
946
1203
  }
947
1204
 
948
1205
  function unstable_clear(callback) {
949
- if (!enableSchedulerTracking) {
1206
+ if (!enableSchedulerTracing) {
950
1207
  return callback();
951
1208
  }
952
1209
 
@@ -961,7 +1218,7 @@ function unstable_clear(callback) {
961
1218
  }
962
1219
 
963
1220
  function unstable_getCurrent() {
964
- if (!enableSchedulerTracking) {
1221
+ if (!enableSchedulerTracing) {
965
1222
  return null;
966
1223
  } else {
967
1224
  return interactionsRef.current;
@@ -972,10 +1229,10 @@ function unstable_getThreadID() {
972
1229
  return ++threadIDCounter;
973
1230
  }
974
1231
 
975
- function unstable_track(name, timestamp, callback) {
1232
+ function unstable_trace(name, timestamp, callback) {
976
1233
  var threadID = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : DEFAULT_THREAD_ID;
977
1234
 
978
- if (!enableSchedulerTracking) {
1235
+ if (!enableSchedulerTracing) {
979
1236
  return callback();
980
1237
  }
981
1238
 
@@ -988,7 +1245,7 @@ function unstable_track(name, timestamp, callback) {
988
1245
 
989
1246
  var prevInteractions = interactionsRef.current;
990
1247
 
991
- // Tracked interactions should stack/accumulate.
1248
+ // Traced interactions should stack/accumulate.
992
1249
  // To do that, clone the current interactions.
993
1250
  // The previous set will be restored upon completion.
994
1251
  var interactions = new Set(prevInteractions);
@@ -1000,7 +1257,7 @@ function unstable_track(name, timestamp, callback) {
1000
1257
 
1001
1258
  try {
1002
1259
  if (subscriber !== null) {
1003
- subscriber.onInteractionTracked(interaction);
1260
+ subscriber.onInteractionTraced(interaction);
1004
1261
  }
1005
1262
  } finally {
1006
1263
  try {
@@ -1036,7 +1293,7 @@ function unstable_track(name, timestamp, callback) {
1036
1293
  function unstable_wrap(callback) {
1037
1294
  var threadID = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DEFAULT_THREAD_ID;
1038
1295
 
1039
- if (!enableSchedulerTracking) {
1296
+ if (!enableSchedulerTracing) {
1040
1297
  return callback;
1041
1298
  }
1042
1299
 
@@ -1127,18 +1384,18 @@ function unstable_wrap(callback) {
1127
1384
  }
1128
1385
 
1129
1386
  var subscribers = null;
1130
- if (enableSchedulerTracking) {
1387
+ if (enableSchedulerTracing) {
1131
1388
  subscribers = new Set();
1132
1389
  }
1133
1390
 
1134
1391
  function unstable_subscribe(subscriber) {
1135
- if (enableSchedulerTracking) {
1392
+ if (enableSchedulerTracing) {
1136
1393
  subscribers.add(subscriber);
1137
1394
 
1138
1395
  if (subscribers.size === 1) {
1139
1396
  subscriberRef.current = {
1140
1397
  onInteractionScheduledWorkCompleted: onInteractionScheduledWorkCompleted,
1141
- onInteractionTracked: onInteractionTracked,
1398
+ onInteractionTraced: onInteractionTraced,
1142
1399
  onWorkCanceled: onWorkCanceled,
1143
1400
  onWorkScheduled: onWorkScheduled,
1144
1401
  onWorkStarted: onWorkStarted,
@@ -1149,7 +1406,7 @@ function unstable_subscribe(subscriber) {
1149
1406
  }
1150
1407
 
1151
1408
  function unstable_unsubscribe(subscriber) {
1152
- if (enableSchedulerTracking) {
1409
+ if (enableSchedulerTracing) {
1153
1410
  subscribers.delete(subscriber);
1154
1411
 
1155
1412
  if (subscribers.size === 0) {
@@ -1158,13 +1415,13 @@ function unstable_unsubscribe(subscriber) {
1158
1415
  }
1159
1416
  }
1160
1417
 
1161
- function onInteractionTracked(interaction) {
1418
+ function onInteractionTraced(interaction) {
1162
1419
  var didCatchError = false;
1163
1420
  var caughtError = null;
1164
1421
 
1165
1422
  subscribers.forEach(function (subscriber) {
1166
1423
  try {
1167
- subscriber.onInteractionTracked(interaction);
1424
+ subscriber.onInteractionTraced(interaction);
1168
1425
  } catch (error) {
1169
1426
  if (!didCatchError) {
1170
1427
  didCatchError = true;
@@ -1347,8 +1604,8 @@ function getComponentName(type) {
1347
1604
  return type;
1348
1605
  }
1349
1606
  switch (type) {
1350
- case REACT_ASYNC_MODE_TYPE:
1351
- return 'AsyncMode';
1607
+ case REACT_CONCURRENT_MODE_TYPE:
1608
+ return 'ConcurrentMode';
1352
1609
  case REACT_FRAGMENT_TYPE:
1353
1610
  return 'Fragment';
1354
1611
  case REACT_PORTAL_TYPE:
@@ -1369,7 +1626,7 @@ function getComponentName(type) {
1369
1626
  case REACT_FORWARD_REF_TYPE:
1370
1627
  var renderFn = type.render;
1371
1628
  var functionName = renderFn.displayName || renderFn.name || '';
1372
- return functionName !== '' ? 'ForwardRef(' + functionName + ')' : 'ForwardRef';
1629
+ return type.displayName || (functionName !== '' ? 'ForwardRef(' + functionName + ')' : 'ForwardRef');
1373
1630
  }
1374
1631
  if (typeof type.then === 'function') {
1375
1632
  var thenable = type;
@@ -1429,19 +1686,22 @@ var ReactSharedInternals = {
1429
1686
  // This re-export is only required for UMD bundles;
1430
1687
  // CJS bundles use the shared NPM package.
1431
1688
  objectAssign(ReactSharedInternals, {
1432
- Schedule: {
1433
- unstable_cancelScheduledWork: cancelScheduledWork,
1434
- unstable_now: now,
1435
- unstable_scheduleWork: scheduleWork
1689
+ Scheduler: {
1690
+ unstable_cancelCallback: unstable_cancelCallback,
1691
+ unstable_now: getCurrentTime,
1692
+ unstable_scheduleCallback: unstable_scheduleCallback,
1693
+ unstable_runWithPriority: unstable_runWithPriority,
1694
+ unstable_wrapCallback: unstable_wrapCallback,
1695
+ unstable_getCurrentPriorityLevel: unstable_getCurrentPriorityLevel
1436
1696
  },
1437
- ScheduleTracking: {
1697
+ SchedulerTracing: {
1438
1698
  __interactionsRef: interactionsRef,
1439
1699
  __subscriberRef: subscriberRef,
1440
1700
  unstable_clear: unstable_clear,
1441
1701
  unstable_getCurrent: unstable_getCurrent,
1442
1702
  unstable_getThreadID: unstable_getThreadID,
1443
1703
  unstable_subscribe: unstable_subscribe,
1444
- unstable_track: unstable_track,
1704
+ unstable_trace: unstable_trace,
1445
1705
  unstable_unsubscribe: unstable_unsubscribe,
1446
1706
  unstable_wrap: unstable_wrap
1447
1707
  }
@@ -2186,7 +2446,9 @@ function forwardRef(render) {
2186
2446
  if (typeof render !== 'function') {
2187
2447
  warningWithoutStack$1(false, 'forwardRef requires a render function but was given %s.', render === null ? 'null' : typeof render);
2188
2448
  } else {
2189
- !(render.length === 2) ? warningWithoutStack$1(false, 'forwardRef render functions accept two parameters: props and ref. ' + 'Did you forget to use the ref parameter?') : void 0;
2449
+ !(
2450
+ // Do not warn for 0 arguments because it could be due to usage of the 'arguments' object
2451
+ 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;
2190
2452
  }
2191
2453
 
2192
2454
  if (render != null) {
@@ -2200,10 +2462,84 @@ function forwardRef(render) {
2200
2462
  };
2201
2463
  }
2202
2464
 
2465
+ function pure(render, compare) {
2466
+ {
2467
+ if (typeof render !== 'function') {
2468
+ warningWithoutStack$1(false, 'pure: The first argument must be a function component. Instead ' + 'received: %s', render === null ? 'null' : typeof render);
2469
+ } else {
2470
+ var prototype = render.prototype;
2471
+ if (prototype && prototype.isReactComponent) {
2472
+ warningWithoutStack$1(false, 'pure: The first argument must be a function component. Classes ' + 'are not supported. Use React.PureComponent instead.');
2473
+ }
2474
+ }
2475
+ }
2476
+ return {
2477
+ $$typeof: REACT_PURE_TYPE,
2478
+ render: render,
2479
+ compare: compare === undefined ? null : compare
2480
+ };
2481
+ }
2482
+
2483
+ function resolveDispatcher() {
2484
+ var dispatcher = ReactCurrentOwner.currentDispatcher;
2485
+ !(dispatcher !== null) ? invariant(false, 'Hooks can only be called inside the body of a functional component.') : void 0;
2486
+ return dispatcher;
2487
+ }
2488
+
2489
+ function useContext(context, observedBits) {
2490
+ var dispatcher = resolveDispatcher();
2491
+ return dispatcher.useContext(context, observedBits);
2492
+ }
2493
+
2494
+ function useState(initialState) {
2495
+ var dispatcher = resolveDispatcher();
2496
+ return dispatcher.useState(initialState);
2497
+ }
2498
+
2499
+ function useReducer(reducer, initialState, initialAction) {
2500
+ var dispatcher = resolveDispatcher();
2501
+ return dispatcher.useReducer(reducer, initialState, initialAction);
2502
+ }
2503
+
2504
+ function useRef(initialValue) {
2505
+ var dispatcher = resolveDispatcher();
2506
+ return dispatcher.useRef(initialValue);
2507
+ }
2508
+
2509
+ function useEffect(create, inputs) {
2510
+ var dispatcher = resolveDispatcher();
2511
+ return dispatcher.useEffect(create, inputs);
2512
+ }
2513
+
2514
+ function useMutationEffect(create, inputs) {
2515
+ var dispatcher = resolveDispatcher();
2516
+ return dispatcher.useMutationEffect(create, inputs);
2517
+ }
2518
+
2519
+ function useLayoutEffect(create, inputs) {
2520
+ var dispatcher = resolveDispatcher();
2521
+ return dispatcher.useLayoutEffect(create, inputs);
2522
+ }
2523
+
2524
+ function useCallback(callback, inputs) {
2525
+ var dispatcher = resolveDispatcher();
2526
+ return dispatcher.useCallback(callback, inputs);
2527
+ }
2528
+
2529
+ function useMemo(create, inputs) {
2530
+ var dispatcher = resolveDispatcher();
2531
+ return dispatcher.useMemo(create, inputs);
2532
+ }
2533
+
2534
+ function useAPI(ref, create, inputs) {
2535
+ var dispatcher = resolveDispatcher();
2536
+ return dispatcher.useAPI(ref, create, inputs);
2537
+ }
2538
+
2203
2539
  function isValidElementType(type) {
2204
2540
  return typeof type === 'string' || typeof type === 'function' ||
2205
2541
  // Note: its typeof might be other than 'symbol' or 'number' if it's a polyfill.
2206
- type === REACT_FRAGMENT_TYPE || type === REACT_ASYNC_MODE_TYPE || type === REACT_PROFILER_TYPE || type === REACT_STRICT_MODE_TYPE || type === REACT_PLACEHOLDER_TYPE || typeof type === 'object' && type !== null && (typeof type.then === 'function' || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE);
2542
+ type === REACT_FRAGMENT_TYPE || type === REACT_CONCURRENT_MODE_TYPE || type === REACT_PROFILER_TYPE || type === REACT_STRICT_MODE_TYPE || type === REACT_PLACEHOLDER_TYPE || typeof type === 'object' && type !== null && (typeof type.then === 'function' || type.$$typeof === REACT_PURE_TYPE || type.$$typeof === REACT_PROVIDER_TYPE || type.$$typeof === REACT_CONTEXT_TYPE || type.$$typeof === REACT_FORWARD_REF_TYPE);
2207
2543
  }
2208
2544
 
2209
2545
  /**
@@ -2456,13 +2792,13 @@ function validatePropTypes(element) {
2456
2792
  var name = void 0,
2457
2793
  propTypes = void 0;
2458
2794
  if (typeof type === 'function') {
2459
- // Class or functional component
2795
+ // Class or function component
2460
2796
  name = type.displayName || type.name;
2461
2797
  propTypes = type.propTypes;
2462
2798
  } else if (typeof type === 'object' && type !== null && type.$$typeof === REACT_FORWARD_REF_TYPE) {
2463
2799
  // ForwardRef
2464
2800
  var functionName = type.render.displayName || type.render.name || '';
2465
- name = functionName !== '' ? 'ForwardRef(' + functionName + ')' : 'ForwardRef';
2801
+ name = type.displayName || (functionName !== '' ? 'ForwardRef(' + functionName + ')' : 'ForwardRef');
2466
2802
  propTypes = type.propTypes;
2467
2803
  } else {
2468
2804
  return;
@@ -2608,10 +2944,11 @@ var React = {
2608
2944
 
2609
2945
  createContext: createContext,
2610
2946
  forwardRef: forwardRef,
2947
+ pure: pure,
2611
2948
 
2612
2949
  Fragment: REACT_FRAGMENT_TYPE,
2613
2950
  StrictMode: REACT_STRICT_MODE_TYPE,
2614
- unstable_AsyncMode: REACT_ASYNC_MODE_TYPE,
2951
+ unstable_ConcurrentMode: REACT_CONCURRENT_MODE_TYPE,
2615
2952
  unstable_Profiler: REACT_PROFILER_TYPE,
2616
2953
 
2617
2954
  createElement: createElementWithValidation,
@@ -2629,6 +2966,19 @@ if (enableSuspense) {
2629
2966
  React.lazy = lazy;
2630
2967
  }
2631
2968
 
2969
+ if (enableHooks_DEPRECATED) {
2970
+ React.useAPI = useAPI;
2971
+ React.useCallback = useCallback;
2972
+ React.useContext = useContext;
2973
+ React.useEffect = useEffect;
2974
+ React.useLayoutEffect = useLayoutEffect;
2975
+ React.useMemo = useMemo;
2976
+ React.useMutationEffect = useMutationEffect;
2977
+ React.useReducer = useReducer;
2978
+ React.useRef = useRef;
2979
+ React.useState = useState;
2980
+ }
2981
+
2632
2982
 
2633
2983
 
2634
2984
  var React$2 = Object.freeze({