react 17.0.0 → 18.0.0-alpha-e6be2d531

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.
@@ -1,4 +1,4 @@
1
- /** @license React v17.0.0
1
+ /** @license React vundefined
2
2
  * react.production.min.js
3
3
  *
4
4
  * Copyright (c) Facebook, Inc. and its affiliates.
@@ -6,18 +6,19 @@
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
- 'use strict';var l=require("object-assign"),n=60103,p=60106;exports.Fragment=60107;exports.StrictMode=60108;exports.Profiler=60114;var q=60109,r=60110,t=60112;exports.Suspense=60113;var u=60115,v=60116;
10
- if("function"===typeof Symbol&&Symbol.for){var w=Symbol.for;n=w("react.element");p=w("react.portal");exports.Fragment=w("react.fragment");exports.StrictMode=w("react.strict_mode");exports.Profiler=w("react.profiler");q=w("react.provider");r=w("react.context");t=w("react.forward_ref");exports.Suspense=w("react.suspense");u=w("react.memo");v=w("react.lazy")}var x="function"===typeof Symbol&&Symbol.iterator;
9
+ 'use strict';var l=require("object-assign"),m=60103,p=60106;exports.Fragment=60107;exports.StrictMode=60108;exports.Profiler=60114;var q=60109,r=60110,t=60112;exports.Suspense=60113;exports.SuspenseList=60120;var u=60115,v=60116;
10
+ if("function"===typeof Symbol&&Symbol.for){var w=Symbol.for;m=w("react.element");p=w("react.portal");exports.Fragment=w("react.fragment");exports.StrictMode=w("react.strict_mode");exports.Profiler=w("react.profiler");q=w("react.provider");r=w("react.context");t=w("react.forward_ref");exports.Suspense=w("react.suspense");exports.SuspenseList=w("react.suspense_list");u=w("react.memo");v=w("react.lazy")}var x="function"===typeof Symbol&&Symbol.iterator;
11
11
  function y(a){if(null===a||"object"!==typeof a)return null;a=x&&a[x]||a["@@iterator"];return"function"===typeof a?a:null}function z(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."}
12
12
  var A={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},B={};function C(a,b,c){this.props=a;this.context=b;this.refs=B;this.updater=c||A}C.prototype.isReactComponent={};C.prototype.setState=function(a,b){if("object"!==typeof a&&"function"!==typeof a&&null!=a)throw Error(z(85));this.updater.enqueueSetState(this,a,b,"setState")};C.prototype.forceUpdate=function(a){this.updater.enqueueForceUpdate(this,a,"forceUpdate")};
13
- function D(){}D.prototype=C.prototype;function E(a,b,c){this.props=a;this.context=b;this.refs=B;this.updater=c||A}var F=E.prototype=new D;F.constructor=E;l(F,C.prototype);F.isPureReactComponent=!0;var G={current:null},H=Object.prototype.hasOwnProperty,I={key:!0,ref:!0,__self:!0,__source:!0};
14
- function J(a,b,c){var e,d={},k=null,h=null;if(null!=b)for(e in void 0!==b.ref&&(h=b.ref),void 0!==b.key&&(k=""+b.key),b)H.call(b,e)&&!I.hasOwnProperty(e)&&(d[e]=b[e]);var g=arguments.length-2;if(1===g)d.children=c;else if(1<g){for(var f=Array(g),m=0;m<g;m++)f[m]=arguments[m+2];d.children=f}if(a&&a.defaultProps)for(e in g=a.defaultProps,g)void 0===d[e]&&(d[e]=g[e]);return{$$typeof:n,type:a,key:k,ref:h,props:d,_owner:G.current}}
15
- function K(a,b){return{$$typeof:n,type:a.type,key:b,ref:a.ref,props:a.props,_owner:a._owner}}function L(a){return"object"===typeof a&&null!==a&&a.$$typeof===n}function escape(a){var b={"=":"=0",":":"=2"};return"$"+a.replace(/[=:]/g,function(a){return b[a]})}var M=/\/+/g;function N(a,b){return"object"===typeof a&&null!==a&&null!=a.key?escape(""+a.key):b.toString(36)}
16
- function O(a,b,c,e,d){var k=typeof a;if("undefined"===k||"boolean"===k)a=null;var h=!1;if(null===a)h=!0;else switch(k){case "string":case "number":h=!0;break;case "object":switch(a.$$typeof){case n:case p:h=!0}}if(h)return h=a,d=d(h),a=""===e?"."+N(h,0):e,Array.isArray(d)?(c="",null!=a&&(c=a.replace(M,"$&/")+"/"),O(d,b,c,"",function(a){return a})):null!=d&&(L(d)&&(d=K(d,c+(!d.key||h&&h.key===d.key?"":(""+d.key).replace(M,"$&/")+"/")+a)),b.push(d)),1;h=0;e=""===e?".":e+":";if(Array.isArray(a))for(var g=
17
- 0;g<a.length;g++){k=a[g];var f=e+N(k,g);h+=O(k,b,c,f,d)}else if(f=y(a),"function"===typeof f)for(a=f.call(a),g=0;!(k=a.next()).done;)k=k.value,f=e+N(k,g++),h+=O(k,b,c,f,d);else if("object"===k)throw b=""+a,Error(z(31,"[object Object]"===b?"object with keys {"+Object.keys(a).join(", ")+"}":b));return h}function P(a,b,c){if(null==a)return a;var e=[],d=0;O(a,e,"","",function(a){return b.call(c,a,d++)});return e}
18
- function Q(a){if(-1===a._status){var b=a._result;b=b();a._status=0;a._result=b;b.then(function(b){0===a._status&&(b=b.default,a._status=1,a._result=b)},function(b){0===a._status&&(a._status=2,a._result=b)})}if(1===a._status)return a._result;throw a._result;}var R={current:null};function S(){var a=R.current;if(null===a)throw Error(z(321));return a}var T={ReactCurrentDispatcher:R,ReactCurrentBatchConfig:{transition:0},ReactCurrentOwner:G,IsSomeRendererActing:{current:!1},assign:l};
19
- exports.Children={map:P,forEach:function(a,b,c){P(a,function(){b.apply(this,arguments)},c)},count:function(a){var b=0;P(a,function(){b++});return b},toArray:function(a){return P(a,function(a){return a})||[]},only:function(a){if(!L(a))throw Error(z(143));return a}};exports.Component=C;exports.PureComponent=E;exports.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=T;
20
- exports.cloneElement=function(a,b,c){if(null===a||void 0===a)throw Error(z(267,a));var e=l({},a.props),d=a.key,k=a.ref,h=a._owner;if(null!=b){void 0!==b.ref&&(k=b.ref,h=G.current);void 0!==b.key&&(d=""+b.key);if(a.type&&a.type.defaultProps)var g=a.type.defaultProps;for(f in b)H.call(b,f)&&!I.hasOwnProperty(f)&&(e[f]=void 0===b[f]&&void 0!==g?g[f]:b[f])}var f=arguments.length-2;if(1===f)e.children=c;else if(1<f){g=Array(f);for(var m=0;m<f;m++)g[m]=arguments[m+2];e.children=g}return{$$typeof:n,type:a.type,
21
- key:d,ref:k,props:e,_owner:h}};exports.createContext=function(a,b){void 0===b&&(b=null);a={$$typeof:r,_calculateChangedBits:b,_currentValue:a,_currentValue2:a,_threadCount:0,Provider:null,Consumer:null};a.Provider={$$typeof:q,_context:a};return a.Consumer=a};exports.createElement=J;exports.createFactory=function(a){var b=J.bind(null,a);b.type=a;return b};exports.createRef=function(){return{current:null}};exports.forwardRef=function(a){return{$$typeof:t,render:a}};exports.isValidElement=L;
22
- exports.lazy=function(a){return{$$typeof:v,_payload:{_status:-1,_result:a},_init:Q}};exports.memo=function(a,b){return{$$typeof:u,type:a,compare:void 0===b?null:b}};exports.useCallback=function(a,b){return S().useCallback(a,b)};exports.useContext=function(a,b){return S().useContext(a,b)};exports.useDebugValue=function(){};exports.useEffect=function(a,b){return S().useEffect(a,b)};exports.useImperativeHandle=function(a,b,c){return S().useImperativeHandle(a,b,c)};
23
- exports.useLayoutEffect=function(a,b){return S().useLayoutEffect(a,b)};exports.useMemo=function(a,b){return S().useMemo(a,b)};exports.useReducer=function(a,b,c){return S().useReducer(a,b,c)};exports.useRef=function(a){return S().useRef(a)};exports.useState=function(a){return S().useState(a)};exports.version="17.0.0";
13
+ function D(){}D.prototype=C.prototype;function E(a,b,c){this.props=a;this.context=b;this.refs=B;this.updater=c||A}var F=E.prototype=new D;F.constructor=E;l(F,C.prototype);F.isPureReactComponent=!0;var G=Array.isArray,H=Object.prototype.hasOwnProperty,I={current:null},J={key:!0,ref:!0,__self:!0,__source:!0};
14
+ function K(a,b,c){var e,d={},k=null,h=null;if(null!=b)for(e in void 0!==b.ref&&(h=b.ref),void 0!==b.key&&(k=""+b.key),b)H.call(b,e)&&!J.hasOwnProperty(e)&&(d[e]=b[e]);var g=arguments.length-2;if(1===g)d.children=c;else if(1<g){for(var f=Array(g),n=0;n<g;n++)f[n]=arguments[n+2];d.children=f}if(a&&a.defaultProps)for(e in g=a.defaultProps,g)void 0===d[e]&&(d[e]=g[e]);return{$$typeof:m,type:a,key:k,ref:h,props:d,_owner:I.current}}
15
+ function L(a,b){return{$$typeof:m,type:a.type,key:b,ref:a.ref,props:a.props,_owner:a._owner}}function M(a){return"object"===typeof a&&null!==a&&a.$$typeof===m}function escape(a){var b={"=":"=0",":":"=2"};return"$"+a.replace(/[=:]/g,function(a){return b[a]})}var N=/\/+/g;function O(a,b){return"object"===typeof a&&null!==a&&null!=a.key?escape(""+a.key):b.toString(36)}
16
+ function P(a,b,c,e,d){var k=typeof a;if("undefined"===k||"boolean"===k)a=null;var h=!1;if(null===a)h=!0;else switch(k){case "string":case "number":h=!0;break;case "object":switch(a.$$typeof){case m:case p:h=!0}}if(h)return h=a,d=d(h),a=""===e?"."+O(h,0):e,G(d)?(c="",null!=a&&(c=a.replace(N,"$&/")+"/"),P(d,b,c,"",function(a){return a})):null!=d&&(M(d)&&(d=L(d,c+(!d.key||h&&h.key===d.key?"":(""+d.key).replace(N,"$&/")+"/")+a)),b.push(d)),1;h=0;e=""===e?".":e+":";if(G(a))for(var g=0;g<a.length;g++){k=
17
+ a[g];var f=e+O(k,g);h+=P(k,b,c,f,d)}else if(f=y(a),"function"===typeof f)for(a=f.call(a),g=0;!(k=a.next()).done;)k=k.value,f=e+O(k,g++),h+=P(k,b,c,f,d);else if("object"===k)throw b=""+a,Error(z(31,"[object Object]"===b?"object with keys {"+Object.keys(a).join(", ")+"}":b));return h}function Q(a,b,c){if(null==a)return a;var e=[],d=0;P(a,e,"","",function(a){return b.call(c,a,d++)});return e}
18
+ function R(a){if(-1===a._status){var b=a._result;b=b();b.then(function(b){if(0===a._status||-1===a._status)a._status=1,a._result=b},function(b){if(0===a._status||-1===a._status)a._status=2,a._result=b});-1===a._status&&(a._status=0,a._result=b)}if(1===a._status)return a._result.default;throw a._result;}var S={current:null},T={transition:0},U={ReactCurrentDispatcher:S,ReactCurrentBatchConfig:T,ReactCurrentOwner:I,IsSomeRendererActing:{current:!1},assign:l};
19
+ exports.Children={map:Q,forEach:function(a,b,c){Q(a,function(){b.apply(this,arguments)},c)},count:function(a){var b=0;Q(a,function(){b++});return b},toArray:function(a){return Q(a,function(a){return a})||[]},only:function(a){if(!M(a))throw Error(z(143));return a}};exports.Component=C;exports.PureComponent=E;exports.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=U;
20
+ exports.cloneElement=function(a,b,c){if(null===a||void 0===a)throw Error(z(267,a));var e=l({},a.props),d=a.key,k=a.ref,h=a._owner;if(null!=b){void 0!==b.ref&&(k=b.ref,h=I.current);void 0!==b.key&&(d=""+b.key);if(a.type&&a.type.defaultProps)var g=a.type.defaultProps;for(f in b)H.call(b,f)&&!J.hasOwnProperty(f)&&(e[f]=void 0===b[f]&&void 0!==g?g[f]:b[f])}var f=arguments.length-2;if(1===f)e.children=c;else if(1<f){g=Array(f);for(var n=0;n<f;n++)g[n]=arguments[n+2];e.children=g}return{$$typeof:m,type:a.type,
21
+ key:d,ref:k,props:e,_owner:h}};exports.createContext=function(a){a={$$typeof:r,_currentValue:a,_currentValue2:a,_threadCount:0,Provider:null,Consumer:null};a.Provider={$$typeof:q,_context:a};return a.Consumer=a};exports.createElement=K;exports.createFactory=function(a){var b=K.bind(null,a);b.type=a;return b};exports.createRef=function(){return{current:null}};exports.forwardRef=function(a){return{$$typeof:t,render:a}};exports.isValidElement=M;
22
+ exports.lazy=function(a){return{$$typeof:v,_payload:{_status:-1,_result:a},_init:R}};exports.memo=function(a,b){return{$$typeof:u,type:a,compare:void 0===b?null:b}};exports.startTransition=function(a){var b=T.transition;T.transition=1;try{a()}finally{T.transition=b}};exports.unstable_createMutableSource=function(a,b){return{_getVersion:b,_source:a,_workInProgressVersionPrimary:null,_workInProgressVersionSecondary:null}};
23
+ exports.unstable_useMutableSource=function(a,b,c){return S.current.useMutableSource(a,b,c)};exports.unstable_useOpaqueIdentifier=function(){return S.current.useOpaqueIdentifier()};exports.useCallback=function(a,b){return S.current.useCallback(a,b)};exports.useContext=function(a){return S.current.useContext(a)};exports.useDebugValue=function(){};exports.useDeferredValue=function(a){return S.current.useDeferredValue(a)};exports.useEffect=function(a,b){return S.current.useEffect(a,b)};
24
+ exports.useImperativeHandle=function(a,b,c){return S.current.useImperativeHandle(a,b,c)};exports.useLayoutEffect=function(a,b){return S.current.useLayoutEffect(a,b)};exports.useMemo=function(a,b){return S.current.useMemo(a,b)};exports.useReducer=function(a,b,c){return S.current.useReducer(a,b,c)};exports.useRef=function(a){return S.current.useRef(a)};exports.useState=function(a){return S.current.useState(a)};exports.useTransition=function(){return S.current.useTransition()};exports.version="18.0.0-e6be2d531";
package/package.json CHANGED
@@ -4,7 +4,7 @@
4
4
  "keywords": [
5
5
  "react"
6
6
  ],
7
- "version": "17.0.0",
7
+ "version": "18.0.0-alpha-e6be2d531",
8
8
  "homepage": "https://reactjs.org/",
9
9
  "bugs": "https://github.com/facebook/react/issues",
10
10
  "license": "MIT",
@@ -16,9 +16,24 @@
16
16
  "cjs/",
17
17
  "umd/",
18
18
  "jsx-runtime.js",
19
- "jsx-dev-runtime.js"
19
+ "jsx-dev-runtime.js",
20
+ "unstable-shared-subset.js"
20
21
  ],
21
22
  "main": "index.js",
23
+ "exports": {
24
+ ".": {
25
+ "react-server": "./unstable-shared-subset.js",
26
+ "default": "./index.js"
27
+ },
28
+ "./index": {
29
+ "react-server": "./unstable-shared-subset.js",
30
+ "default": "./index.js"
31
+ },
32
+ "./build-info.json": "./build-info.json",
33
+ "./jsx-runtime": "./jsx-runtime.js",
34
+ "./jsx-dev-runtime": "./jsx-dev-runtime.js",
35
+ "./": "./"
36
+ },
22
37
  "repository": {
23
38
  "type": "git",
24
39
  "url": "https://github.com/facebook/react.git",
@@ -36,4 +51,4 @@
36
51
  "loose-envify"
37
52
  ]
38
53
  }
39
- }
54
+ }
@@ -1,4 +1,4 @@
1
- /** @license React v17.0.0
1
+ /** @license React vundefined
2
2
  * react.development.js
3
3
  *
4
4
  * Copyright (c) Facebook, Inc. and its affiliates.
@@ -12,8 +12,7 @@
12
12
  (global = global || self, factory(global.React = {}));
13
13
  }(this, (function (exports) { 'use strict';
14
14
 
15
- // TODO: this is special because it gets imported during build.
16
- var ReactVersion = '17.0.0';
15
+ var ReactVersion = '18.0.0-e6be2d531';
17
16
 
18
17
  // ATTENTION
19
18
  // When adding new symbols to this file,
@@ -29,17 +28,15 @@
29
28
  var REACT_CONTEXT_TYPE = 0xeace;
30
29
  var REACT_FORWARD_REF_TYPE = 0xead0;
31
30
  exports.Suspense = 0xead1;
32
- var REACT_SUSPENSE_LIST_TYPE = 0xead8;
31
+ exports.SuspenseList = 0xead8;
33
32
  var REACT_MEMO_TYPE = 0xead3;
34
33
  var REACT_LAZY_TYPE = 0xead4;
35
- var REACT_BLOCK_TYPE = 0xead9;
36
- var REACT_SERVER_BLOCK_TYPE = 0xeada;
37
- var REACT_FUNDAMENTAL_TYPE = 0xead5;
38
34
  var REACT_SCOPE_TYPE = 0xead7;
39
35
  var REACT_OPAQUE_ID_TYPE = 0xeae0;
40
36
  var REACT_DEBUG_TRACING_MODE_TYPE = 0xeae1;
41
37
  var REACT_OFFSCREEN_TYPE = 0xeae2;
42
38
  var REACT_LEGACY_HIDDEN_TYPE = 0xeae3;
39
+ var REACT_CACHE_TYPE = 0xeae4;
43
40
 
44
41
  if (typeof Symbol === 'function' && Symbol.for) {
45
42
  var symbolFor = Symbol.for;
@@ -52,17 +49,15 @@
52
49
  REACT_CONTEXT_TYPE = symbolFor('react.context');
53
50
  REACT_FORWARD_REF_TYPE = symbolFor('react.forward_ref');
54
51
  exports.Suspense = symbolFor('react.suspense');
55
- REACT_SUSPENSE_LIST_TYPE = symbolFor('react.suspense_list');
52
+ exports.SuspenseList = symbolFor('react.suspense_list');
56
53
  REACT_MEMO_TYPE = symbolFor('react.memo');
57
54
  REACT_LAZY_TYPE = symbolFor('react.lazy');
58
- REACT_BLOCK_TYPE = symbolFor('react.block');
59
- REACT_SERVER_BLOCK_TYPE = symbolFor('react.server.block');
60
- REACT_FUNDAMENTAL_TYPE = symbolFor('react.fundamental');
61
55
  REACT_SCOPE_TYPE = symbolFor('react.scope');
62
56
  REACT_OPAQUE_ID_TYPE = symbolFor('react.opaque.id');
63
57
  REACT_DEBUG_TRACING_MODE_TYPE = symbolFor('react.debug_trace_mode');
64
58
  REACT_OFFSCREEN_TYPE = symbolFor('react.offscreen');
65
59
  REACT_LEGACY_HIDDEN_TYPE = symbolFor('react.legacy_hidden');
60
+ REACT_CACHE_TYPE = symbolFor('react.cache');
66
61
  }
67
62
 
68
63
  var MAYBE_ITERATOR_SYMBOL = typeof Symbol === 'function' && Symbol.iterator;
@@ -473,16 +468,30 @@
473
468
  return refObject;
474
469
  }
475
470
 
471
+ var isArrayImpl = Array.isArray; // eslint-disable-next-line no-redeclare
472
+
473
+ function isArray(a) {
474
+ return isArrayImpl(a);
475
+ }
476
+
476
477
  function getWrappedName(outerType, innerType, wrapperName) {
478
+ var displayName = outerType.displayName;
479
+
480
+ if (displayName) {
481
+ return displayName;
482
+ }
483
+
477
484
  var functionName = innerType.displayName || innerType.name || '';
478
- return outerType.displayName || (functionName !== '' ? wrapperName + "(" + functionName + ")" : wrapperName);
479
- }
485
+ return functionName !== '' ? wrapperName + "(" + functionName + ")" : wrapperName;
486
+ } // Keep in sync with react-reconciler/getComponentNameFromFiber
487
+
480
488
 
481
489
  function getContextName(type) {
482
490
  return type.displayName || 'Context';
483
- }
491
+ } // Note that the reconciler package should generally prefer to use getComponentNameFromFiber() instead.
492
+
484
493
 
485
- function getComponentName(type) {
494
+ function getComponentNameFromType(type) {
486
495
  if (type == null) {
487
496
  // Host root, text node or just invalid type.
488
497
  return null;
@@ -490,7 +499,7 @@
490
499
 
491
500
  {
492
501
  if (typeof type.tag === 'number') {
493
- error('Received an unexpected object in getComponentName(). ' + 'This is likely a bug in React. Please file an issue.');
502
+ error('Received an unexpected object in getComponentNameFromType(). ' + 'This is likely a bug in React. Please file an issue.');
494
503
  }
495
504
  }
496
505
 
@@ -518,8 +527,11 @@
518
527
  case exports.Suspense:
519
528
  return 'Suspense';
520
529
 
521
- case REACT_SUSPENSE_LIST_TYPE:
530
+ case exports.SuspenseList:
522
531
  return 'SuspenseList';
532
+
533
+ case REACT_CACHE_TYPE:
534
+ return 'Cache';
523
535
  }
524
536
 
525
537
  if (typeof type === 'object') {
@@ -536,10 +548,13 @@
536
548
  return getWrappedName(type, type.render, 'ForwardRef');
537
549
 
538
550
  case REACT_MEMO_TYPE:
539
- return getComponentName(type.type);
551
+ var outerName = type.displayName || null;
552
+
553
+ if (outerName !== null) {
554
+ return outerName;
555
+ }
540
556
 
541
- case REACT_BLOCK_TYPE:
542
- return getComponentName(type._render);
557
+ return getComponentNameFromType(type.type) || 'Memo';
543
558
 
544
559
  case REACT_LAZY_TYPE:
545
560
  {
@@ -548,7 +563,7 @@
548
563
  var init = lazyComponent._init;
549
564
 
550
565
  try {
551
- return getComponentName(init(payload));
566
+ return getComponentNameFromType(init(payload));
552
567
  } catch (x) {
553
568
  return null;
554
569
  }
@@ -560,6 +575,7 @@
560
575
  }
561
576
 
562
577
  var hasOwnProperty$1 = Object.prototype.hasOwnProperty;
578
+
563
579
  var RESERVED_PROPS = {
564
580
  key: true,
565
581
  ref: true,
@@ -639,7 +655,7 @@
639
655
  function warnIfStringRefCannotBeAutoConverted(config) {
640
656
  {
641
657
  if (typeof config.ref === 'string' && ReactCurrentOwner.current && config.__self && ReactCurrentOwner.current.stateNode !== config.__self) {
642
- var componentName = getComponentName(ReactCurrentOwner.current.type);
658
+ var componentName = getComponentNameFromType(ReactCurrentOwner.current.type);
643
659
 
644
660
  if (!didWarnAboutStringRefs[componentName]) {
645
661
  error('Component "%s" contains the string ref "%s". ' + 'Support for string refs will be removed in a future major release. ' + 'This case cannot be automatically converted to an arrow function. ' + 'We ask you to manually fix this case by using useRef() or createRef() instead. ' + 'Learn more about using refs safely here: ' + 'https://reactjs.org/link/strict-mode-string-ref', componentName, config.ref);
@@ -991,7 +1007,7 @@
991
1007
 
992
1008
  var childKey = nameSoFar === '' ? SEPARATOR + getElementKey(_child, 0) : nameSoFar;
993
1009
 
994
- if (Array.isArray(mappedChild)) {
1010
+ if (isArray(mappedChild)) {
995
1011
  var escapedChildKey = '';
996
1012
 
997
1013
  if (childKey != null) {
@@ -1022,7 +1038,7 @@
1022
1038
 
1023
1039
  var nextNamePrefix = nameSoFar === '' ? SEPARATOR : nameSoFar + SUBSEPARATOR;
1024
1040
 
1025
- if (Array.isArray(children)) {
1041
+ if (isArray(children)) {
1026
1042
  for (var i = 0; i < children.length; i++) {
1027
1043
  child = children[i];
1028
1044
  nextName = nextNamePrefix + getElementKey(child, i);
@@ -1168,20 +1184,11 @@
1168
1184
  return children;
1169
1185
  }
1170
1186
 
1171
- function createContext(defaultValue, calculateChangedBits) {
1172
- if (calculateChangedBits === undefined) {
1173
- calculateChangedBits = null;
1174
- } else {
1175
- {
1176
- if (calculateChangedBits !== null && typeof calculateChangedBits !== 'function') {
1177
- error('createContext: Expected the optional second argument to be a ' + 'function. Instead received: %s', calculateChangedBits);
1178
- }
1179
- }
1180
- }
1181
-
1187
+ function createContext(defaultValue) {
1188
+ // TODO: Second argument used to be an optional `calculateChangedBits`
1189
+ // function. Warn to reserve for future use?
1182
1190
  var context = {
1183
1191
  $$typeof: REACT_CONTEXT_TYPE,
1184
- _calculateChangedBits: calculateChangedBits,
1185
1192
  // As a workaround to support multiple concurrent renderers, we categorize
1186
1193
  // some renderers as primary and others as secondary. We only expect
1187
1194
  // there to be two concurrent renderers at most: React Native (primary) and
@@ -1210,8 +1217,7 @@
1210
1217
  // warn for the incorrect usage of Context as a Consumer.
1211
1218
  var Consumer = {
1212
1219
  $$typeof: REACT_CONTEXT_TYPE,
1213
- _context: context,
1214
- _calculateChangedBits: context._calculateChangedBits
1220
+ _context: context
1215
1221
  }; // $FlowFixMe: Flow complains about not setting a value, which is intentional here
1216
1222
 
1217
1223
  Object.defineProperties(Consumer, {
@@ -1298,38 +1304,54 @@
1298
1304
  if (payload._status === Uninitialized) {
1299
1305
  var ctor = payload._result;
1300
1306
  var thenable = ctor(); // Transition to the next state.
1307
+ // This might throw either because it's missing or throws. If so, we treat it
1308
+ // as still uninitialized and try again next time. Which is the same as what
1309
+ // happens if the ctor or any wrappers processing the ctor throws. This might
1310
+ // end up fixing it if the resolution was a concurrency bug.
1301
1311
 
1302
- var pending = payload;
1303
- pending._status = Pending;
1304
- pending._result = thenable;
1305
1312
  thenable.then(function (moduleObject) {
1306
- if (payload._status === Pending) {
1307
- var defaultExport = moduleObject.default;
1308
-
1309
- {
1310
- if (defaultExport === undefined) {
1311
- error('lazy: Expected the result of a dynamic import() call. ' + 'Instead received: %s\n\nYour code should look like: \n ' + // Break up imports to avoid accidentally parsing them as dependencies.
1312
- 'const MyComponent = lazy(() => imp' + "ort('./MyComponent'))", moduleObject);
1313
- }
1314
- } // Transition to the next state.
1315
-
1316
-
1313
+ if (payload._status === Pending || payload._status === Uninitialized) {
1314
+ // Transition to the next state.
1317
1315
  var resolved = payload;
1318
1316
  resolved._status = Resolved;
1319
- resolved._result = defaultExport;
1317
+ resolved._result = moduleObject;
1320
1318
  }
1321
1319
  }, function (error) {
1322
- if (payload._status === Pending) {
1320
+ if (payload._status === Pending || payload._status === Uninitialized) {
1323
1321
  // Transition to the next state.
1324
1322
  var rejected = payload;
1325
1323
  rejected._status = Rejected;
1326
1324
  rejected._result = error;
1327
1325
  }
1328
1326
  });
1327
+
1328
+ if (payload._status === Uninitialized) {
1329
+ // In case, we're still uninitialized, then we're waiting for the thenable
1330
+ // to resolve. Set it as pending in the meantime.
1331
+ var pending = payload;
1332
+ pending._status = Pending;
1333
+ pending._result = thenable;
1334
+ }
1329
1335
  }
1330
1336
 
1331
1337
  if (payload._status === Resolved) {
1332
- return payload._result;
1338
+ var moduleObject = payload._result;
1339
+
1340
+ {
1341
+ if (moduleObject === undefined) {
1342
+ error('lazy: Expected the result of a dynamic import() call. ' + 'Instead received: %s\n\nYour code should look like: \n ' + // Break up imports to avoid accidentally parsing them as dependencies.
1343
+ 'const MyComponent = lazy(() => imp' + "ort('./MyComponent'))\n\n" + 'Did you accidentally put curly braces around the import?', moduleObject);
1344
+ }
1345
+ }
1346
+
1347
+ {
1348
+ if (!('default' in moduleObject)) {
1349
+ error('lazy: Expected the result of a dynamic import() call. ' + 'Instead received: %s\n\nYour code should look like: \n ' + // Break up imports to avoid accidentally parsing them as dependencies.
1350
+ 'const MyComponent = lazy(() => imp' + "ort('./MyComponent'))", moduleObject);
1351
+ }
1352
+ }
1353
+
1354
+ return moduleObject.default;
1333
1355
  } else {
1334
1356
  throw payload._result;
1335
1357
  }
@@ -1424,9 +1446,15 @@
1424
1446
  return ownName;
1425
1447
  },
1426
1448
  set: function (name) {
1427
- ownName = name;
1428
-
1429
- if (render.displayName == null) {
1449
+ ownName = name; // The inner component shouldn't inherit this display name in most cases,
1450
+ // because the component may be used elsewhere.
1451
+ // But it's nice for anonymous functions to inherit the name,
1452
+ // so that our component-stack generation logic will display their frames.
1453
+ // An anonymous function generally suggests a pattern like:
1454
+ // React.forwardRef((props, ref) => {...});
1455
+ // This kind of inner function is not used elsewhere so the side effect is okay.
1456
+
1457
+ if (!render.name && !render.displayName) {
1430
1458
  render.displayName = name;
1431
1459
  }
1432
1460
  }
@@ -1437,21 +1465,32 @@
1437
1465
  }
1438
1466
 
1439
1467
  // Filter certain DOM attributes (e.g. src, href) if their values are empty strings.
1468
+ var enableCache = false; // Only used in www builds.
1440
1469
 
1441
1470
  var enableScopeAPI = false; // Experimental Create Event Handle API.
1442
1471
 
1472
+ var REACT_MODULE_REFERENCE = 0;
1473
+
1474
+ if (typeof Symbol === 'function') {
1475
+ REACT_MODULE_REFERENCE = Symbol.for('react.module.reference');
1476
+ }
1477
+
1443
1478
  function isValidElementType(type) {
1444
1479
  if (typeof type === 'string' || typeof type === 'function') {
1445
1480
  return true;
1446
1481
  } // Note: typeof might be other than 'symbol' or 'number' (e.g. if it's a polyfill).
1447
1482
 
1448
1483
 
1449
- if (type === exports.Fragment || type === exports.Profiler || type === REACT_DEBUG_TRACING_MODE_TYPE || type === exports.StrictMode || type === exports.Suspense || type === REACT_SUSPENSE_LIST_TYPE || type === REACT_LEGACY_HIDDEN_TYPE || enableScopeAPI ) {
1484
+ if (type === exports.Fragment || type === exports.Profiler || type === REACT_DEBUG_TRACING_MODE_TYPE || type === exports.StrictMode || type === exports.Suspense || type === exports.SuspenseList || type === REACT_LEGACY_HIDDEN_TYPE || type === REACT_OFFSCREEN_TYPE || enableScopeAPI || enableCache ) {
1450
1485
  return true;
1451
1486
  }
1452
1487
 
1453
1488
  if (typeof type === 'object' && type !== null) {
1454
- if (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_BLOCK_TYPE || type[0] === REACT_SERVER_BLOCK_TYPE) {
1489
+ if (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 || // This needs to include all possible module reference object
1490
+ // types supported by any Flight configuration anywhere since
1491
+ // we don't know which Flight build this will end up being used
1492
+ // with.
1493
+ type.$$typeof === REACT_MODULE_REFERENCE || type.getModuleId !== undefined) {
1455
1494
  return true;
1456
1495
  }
1457
1496
  }
@@ -1481,9 +1520,15 @@
1481
1520
  return ownName;
1482
1521
  },
1483
1522
  set: function (name) {
1484
- ownName = name;
1485
-
1486
- if (type.displayName == null) {
1523
+ ownName = name; // The inner component shouldn't inherit this display name in most cases,
1524
+ // because the component may be used elsewhere.
1525
+ // But it's nice for anonymous functions to inherit the name,
1526
+ // so that our component-stack generation logic will display their frames.
1527
+ // An anonymous function generally suggests a pattern like:
1528
+ // React.memo((props) => {...});
1529
+ // This kind of inner function is not used elsewhere so the side effect is okay.
1530
+
1531
+ if (!type.name && !type.displayName) {
1487
1532
  type.displayName = name;
1488
1533
  }
1489
1534
  }
@@ -1496,24 +1541,22 @@
1496
1541
  function resolveDispatcher() {
1497
1542
  var dispatcher = ReactCurrentDispatcher.current;
1498
1543
 
1499
- if (!(dispatcher !== null)) {
1500
- {
1501
- 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://reactjs.org/link/invalid-hook-call for tips about how to debug and fix this problem." );
1544
+ {
1545
+ if (dispatcher === null) {
1546
+ 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:\n' + '1. You might have mismatching versions of React and the renderer (such as React DOM)\n' + '2. You might be breaking the Rules of Hooks\n' + '3. You might have more than one copy of React in the same app\n' + 'See https://reactjs.org/link/invalid-hook-call for tips about how to debug and fix this problem.');
1502
1547
  }
1503
- }
1548
+ } // Will result in a null access error if accessed outside render phase. We
1549
+ // intentionally don't throw our own error because this is in a hot path.
1550
+ // Also helps ensure this is inlined.
1551
+
1504
1552
 
1505
1553
  return dispatcher;
1506
1554
  }
1507
-
1508
- function useContext(Context, unstable_observedBits) {
1555
+ function useContext(Context) {
1509
1556
  var dispatcher = resolveDispatcher();
1510
1557
 
1511
1558
  {
1512
- if (unstable_observedBits !== undefined) {
1513
- error('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://reactjs.org/link/rules-of-hooks' : '');
1514
- } // TODO: add a more generic warning for invalid values.
1515
-
1516
-
1559
+ // TODO: add a more generic warning for invalid values.
1517
1560
  if (Context._context !== undefined) {
1518
1561
  var realContext = Context._context; // Don't deduplicate because this legitimately causes bugs
1519
1562
  // and nobody should be using this in existing code.
@@ -1526,7 +1569,7 @@
1526
1569
  }
1527
1570
  }
1528
1571
 
1529
- return dispatcher.useContext(Context, unstable_observedBits);
1572
+ return dispatcher.useContext(Context);
1530
1573
  }
1531
1574
  function useState(initialState) {
1532
1575
  var dispatcher = resolveDispatcher();
@@ -1566,6 +1609,22 @@
1566
1609
  return dispatcher.useDebugValue(value, formatterFn);
1567
1610
  }
1568
1611
  }
1612
+ function useTransition() {
1613
+ var dispatcher = resolveDispatcher();
1614
+ return dispatcher.useTransition();
1615
+ }
1616
+ function useDeferredValue(value) {
1617
+ var dispatcher = resolveDispatcher();
1618
+ return dispatcher.useDeferredValue(value);
1619
+ }
1620
+ function useOpaqueIdentifier() {
1621
+ var dispatcher = resolveDispatcher();
1622
+ return dispatcher.useOpaqueIdentifier();
1623
+ }
1624
+ function useMutableSource(source, getSnapshot, subscribe) {
1625
+ var dispatcher = resolveDispatcher();
1626
+ return dispatcher.useMutableSource(source, getSnapshot, subscribe);
1627
+ }
1569
1628
 
1570
1629
  // Helpers to patch console.logs to avoid logging during side-effect free
1571
1630
  // replaying on render function. This currently only patches the object
@@ -1689,7 +1748,7 @@
1689
1748
 
1690
1749
  function describeNativeComponentFrame(fn, construct) {
1691
1750
  // If something asked for a stack inside a fake render, it should get ignored.
1692
- if (!fn || reentry) {
1751
+ if ( !fn || reentry) {
1693
1752
  return '';
1694
1753
  }
1695
1754
 
@@ -1870,7 +1929,7 @@
1870
1929
  case exports.Suspense:
1871
1930
  return describeBuiltInComponentFrame('Suspense');
1872
1931
 
1873
- case REACT_SUSPENSE_LIST_TYPE:
1932
+ case exports.SuspenseList:
1874
1933
  return describeBuiltInComponentFrame('SuspenseList');
1875
1934
  }
1876
1935
 
@@ -1883,9 +1942,6 @@
1883
1942
  // Memo may contain any component type so we recursively resolve it.
1884
1943
  return describeUnknownElementTypeFrameInDEV(type.type, source, ownerFn);
1885
1944
 
1886
- case REACT_BLOCK_TYPE:
1887
- return describeFunctionComponentFrame(type._render);
1888
-
1889
1945
  case REACT_LAZY_TYPE:
1890
1946
  {
1891
1947
  var lazyComponent = type;
@@ -1921,7 +1977,7 @@
1921
1977
  function checkPropTypes(typeSpecs, values, location, componentName, element) {
1922
1978
  {
1923
1979
  // $FlowFixMe This is okay but Flow doesn't know it.
1924
- var has = Function.call.bind(Object.prototype.hasOwnProperty);
1980
+ var has = Function.call.bind(hasOwnProperty$1);
1925
1981
 
1926
1982
  for (var typeSpecName in typeSpecs) {
1927
1983
  if (has(typeSpecs, typeSpecName)) {
@@ -1986,7 +2042,7 @@
1986
2042
 
1987
2043
  function getDeclarationErrorAddendum() {
1988
2044
  if (ReactCurrentOwner.current) {
1989
- var name = getComponentName(ReactCurrentOwner.current.type);
2045
+ var name = getComponentNameFromType(ReactCurrentOwner.current.type);
1990
2046
 
1991
2047
  if (name) {
1992
2048
  return '\n\nCheck the render method of `' + name + '`.';
@@ -2068,7 +2124,7 @@
2068
2124
 
2069
2125
  if (element && element._owner && element._owner !== ReactCurrentOwner.current) {
2070
2126
  // Give the component that originally created this child.
2071
- childOwner = " It was passed a child from " + getComponentName(element._owner.type) + ".";
2127
+ childOwner = " It was passed a child from " + getComponentNameFromType(element._owner.type) + ".";
2072
2128
  }
2073
2129
 
2074
2130
  {
@@ -2095,7 +2151,7 @@
2095
2151
  return;
2096
2152
  }
2097
2153
 
2098
- if (Array.isArray(node)) {
2154
+ if (isArray(node)) {
2099
2155
  for (var i = 0; i < node.length; i++) {
2100
2156
  var child = node[i];
2101
2157
 
@@ -2157,12 +2213,12 @@
2157
2213
 
2158
2214
  if (propTypes) {
2159
2215
  // Intentionally inside to avoid triggering lazy initializers:
2160
- var name = getComponentName(type);
2216
+ var name = getComponentNameFromType(type);
2161
2217
  checkPropTypes(propTypes, element.props, 'prop', name, element);
2162
2218
  } else if (type.PropTypes !== undefined && !propTypesMisspellWarningShown) {
2163
2219
  propTypesMisspellWarningShown = true; // Intentionally inside to avoid triggering lazy initializers:
2164
2220
 
2165
- var _name = getComponentName(type);
2221
+ var _name = getComponentNameFromType(type);
2166
2222
 
2167
2223
  error('Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?', _name || 'Unknown');
2168
2224
  }
@@ -2227,10 +2283,10 @@
2227
2283
 
2228
2284
  if (type === null) {
2229
2285
  typeString = 'null';
2230
- } else if (Array.isArray(type)) {
2286
+ } else if (isArray(type)) {
2231
2287
  typeString = 'array';
2232
2288
  } else if (type !== undefined && type.$$typeof === REACT_ELEMENT_TYPE) {
2233
- typeString = "<" + (getComponentName(type.type) || 'Unknown') + " />";
2289
+ typeString = "<" + (getComponentNameFromType(type.type) || 'Unknown') + " />";
2234
2290
  info = ' Did you accidentally export a JSX literal instead of a component?';
2235
2291
  } else {
2236
2292
  typeString = typeof type;
@@ -2306,231 +2362,61 @@
2306
2362
  return newElement;
2307
2363
  }
2308
2364
 
2309
- var enableSchedulerDebugging = false;
2310
- var enableProfiling = true;
2311
-
2312
- var requestHostCallback;
2313
- var requestHostTimeout;
2314
- var cancelHostTimeout;
2315
- var shouldYieldToHost;
2316
- var requestPaint;
2317
- var getCurrentTime;
2318
- var forceFrameRate;
2319
- var hasPerformanceNow = typeof performance === 'object' && typeof performance.now === 'function';
2320
-
2321
- if (hasPerformanceNow) {
2322
- var localPerformance = performance;
2323
-
2324
- getCurrentTime = function () {
2325
- return localPerformance.now();
2326
- };
2327
- } else {
2328
- var localDate = Date;
2329
- var initialTime = localDate.now();
2330
-
2331
- getCurrentTime = function () {
2332
- return localDate.now() - initialTime;
2333
- };
2334
- }
2335
-
2336
- if ( // If Scheduler runs in a non-DOM environment, it falls back to a naive
2337
- // implementation using setTimeout.
2338
- typeof window === 'undefined' || // Check if MessageChannel is supported, too.
2339
- typeof MessageChannel !== 'function') {
2340
- // If this accidentally gets imported in a non-browser environment, e.g. JavaScriptCore,
2341
- // fallback to a naive implementation.
2342
- var _callback = null;
2343
- var _timeoutID = null;
2344
-
2345
- var _flushCallback = function () {
2346
- if (_callback !== null) {
2347
- try {
2348
- var currentTime = getCurrentTime();
2349
- var hasRemainingTime = true;
2350
-
2351
- _callback(hasRemainingTime, currentTime);
2352
-
2353
- _callback = null;
2354
- } catch (e) {
2355
- setTimeout(_flushCallback, 0);
2356
- throw e;
2357
- }
2358
- }
2359
- };
2360
-
2361
- requestHostCallback = function (cb) {
2362
- if (_callback !== null) {
2363
- // Protect against re-entrancy.
2364
- setTimeout(requestHostCallback, 0, cb);
2365
- } else {
2366
- _callback = cb;
2367
- setTimeout(_flushCallback, 0);
2368
- }
2365
+ function createMutableSource(source, getVersion) {
2366
+ var mutableSource = {
2367
+ _getVersion: getVersion,
2368
+ _source: source,
2369
+ _workInProgressVersionPrimary: null,
2370
+ _workInProgressVersionSecondary: null
2369
2371
  };
2370
2372
 
2371
- requestHostTimeout = function (cb, ms) {
2372
- _timeoutID = setTimeout(cb, ms);
2373
- };
2374
-
2375
- cancelHostTimeout = function () {
2376
- clearTimeout(_timeoutID);
2377
- };
2378
-
2379
- shouldYieldToHost = function () {
2380
- return false;
2381
- };
2382
-
2383
- requestPaint = forceFrameRate = function () {};
2384
- } else {
2385
- // Capture local references to native APIs, in case a polyfill overrides them.
2386
- var _setTimeout = window.setTimeout;
2387
- var _clearTimeout = window.clearTimeout;
2388
-
2389
- if (typeof console !== 'undefined') {
2390
- // TODO: Scheduler no longer requires these methods to be polyfilled. But
2391
- // maybe we want to continue warning if they don't exist, to preserve the
2392
- // option to rely on it in the future?
2393
- var requestAnimationFrame = window.requestAnimationFrame;
2394
- var cancelAnimationFrame = window.cancelAnimationFrame;
2395
-
2396
- if (typeof requestAnimationFrame !== 'function') {
2397
- // Using console['error'] to evade Babel and ESLint
2398
- console['error']("This browser doesn't support requestAnimationFrame. " + 'Make sure that you load a ' + 'polyfill in older browsers. https://reactjs.org/link/react-polyfills');
2399
- }
2400
-
2401
- if (typeof cancelAnimationFrame !== 'function') {
2402
- // Using console['error'] to evade Babel and ESLint
2403
- console['error']("This browser doesn't support cancelAnimationFrame. " + 'Make sure that you load a ' + 'polyfill in older browsers. https://reactjs.org/link/react-polyfills');
2404
- }
2405
- }
2406
-
2407
- var isMessageLoopRunning = false;
2408
- var scheduledHostCallback = null;
2409
- var taskTimeoutID = -1; // Scheduler periodically yields in case there is other work on the main
2410
- // thread, like user events. By default, it yields multiple times per frame.
2411
- // It does not attempt to align with frame boundaries, since most tasks don't
2412
- // need to be frame aligned; for those that do, use requestAnimationFrame.
2413
-
2414
- var yieldInterval = 5;
2415
- var deadline = 0; // TODO: Make this configurable
2416
-
2417
2373
  {
2418
- // `isInputPending` is not available. Since we have no way of knowing if
2419
- // there's pending input, always yield at the end of the frame.
2420
- shouldYieldToHost = function () {
2421
- return getCurrentTime() >= deadline;
2422
- }; // Since we yield every frame regardless, `requestPaint` has no effect.
2423
-
2374
+ mutableSource._currentPrimaryRenderer = null;
2375
+ mutableSource._currentSecondaryRenderer = null; // Used to detect side effects that update a mutable source during render.
2376
+ // See https://github.com/facebook/react/issues/19948
2424
2377
 
2425
- requestPaint = function () {};
2378
+ mutableSource._currentlyRenderingFiber = null;
2379
+ mutableSource._initialVersionAsOfFirstRender = null;
2426
2380
  }
2427
2381
 
2428
- forceFrameRate = function (fps) {
2429
- if (fps < 0 || fps > 125) {
2430
- // Using console['error'] to evade Babel and ESLint
2431
- console['error']('forceFrameRate takes a positive int between 0 and 125, ' + 'forcing frame rates higher than 125 fps is not supported');
2432
- return;
2433
- }
2434
-
2435
- if (fps > 0) {
2436
- yieldInterval = Math.floor(1000 / fps);
2437
- } else {
2438
- // reset the framerate
2439
- yieldInterval = 5;
2440
- }
2441
- };
2442
-
2443
- var performWorkUntilDeadline = function () {
2444
- if (scheduledHostCallback !== null) {
2445
- var currentTime = getCurrentTime(); // Yield after `yieldInterval` ms, regardless of where we are in the vsync
2446
- // cycle. This means there's always time remaining at the beginning of
2447
- // the message event.
2448
-
2449
- deadline = currentTime + yieldInterval;
2450
- var hasTimeRemaining = true;
2451
-
2452
- try {
2453
- var hasMoreWork = scheduledHostCallback(hasTimeRemaining, currentTime);
2454
-
2455
- if (!hasMoreWork) {
2456
- isMessageLoopRunning = false;
2457
- scheduledHostCallback = null;
2458
- } else {
2459
- // If there's more work, schedule the next message event at the end
2460
- // of the preceding one.
2461
- port.postMessage(null);
2462
- }
2463
- } catch (error) {
2464
- // If a scheduler task throws, exit the current browser task so the
2465
- // error can be observed.
2466
- port.postMessage(null);
2467
- throw error;
2468
- }
2469
- } else {
2470
- isMessageLoopRunning = false;
2471
- } // Yielding to the browser will give it a chance to paint, so we can
2472
- };
2473
-
2474
- var channel = new MessageChannel();
2475
- var port = channel.port2;
2476
- channel.port1.onmessage = performWorkUntilDeadline;
2477
-
2478
- requestHostCallback = function (callback) {
2479
- scheduledHostCallback = callback;
2480
-
2481
- if (!isMessageLoopRunning) {
2482
- isMessageLoopRunning = true;
2483
- port.postMessage(null);
2484
- }
2485
- };
2486
-
2487
- requestHostTimeout = function (callback, ms) {
2488
- taskTimeoutID = _setTimeout(function () {
2489
- callback(getCurrentTime());
2490
- }, ms);
2491
- };
2492
-
2493
- cancelHostTimeout = function () {
2494
- _clearTimeout(taskTimeoutID);
2495
-
2496
- taskTimeoutID = -1;
2497
- };
2382
+ return mutableSource;
2498
2383
  }
2499
2384
 
2385
+ var enableSchedulerDebugging = false;
2386
+ var enableProfiling = false;
2387
+
2500
2388
  function push(heap, node) {
2501
2389
  var index = heap.length;
2502
2390
  heap.push(node);
2503
2391
  siftUp(heap, node, index);
2504
2392
  }
2505
2393
  function peek(heap) {
2506
- var first = heap[0];
2507
- return first === undefined ? null : first;
2394
+ return heap.length === 0 ? null : heap[0];
2508
2395
  }
2509
2396
  function pop(heap) {
2510
- var first = heap[0];
2511
-
2512
- if (first !== undefined) {
2513
- var last = heap.pop();
2397
+ if (heap.length === 0) {
2398
+ return null;
2399
+ }
2514
2400
 
2515
- if (last !== first) {
2516
- heap[0] = last;
2517
- siftDown(heap, last, 0);
2518
- }
2401
+ var first = heap[0];
2402
+ var last = heap.pop();
2519
2403
 
2520
- return first;
2521
- } else {
2522
- return null;
2404
+ if (last !== first) {
2405
+ heap[0] = last;
2406
+ siftDown(heap, last, 0);
2523
2407
  }
2408
+
2409
+ return first;
2524
2410
  }
2525
2411
 
2526
2412
  function siftUp(heap, node, i) {
2527
2413
  var index = i;
2528
2414
 
2529
- while (true) {
2415
+ while (index > 0) {
2530
2416
  var parentIndex = index - 1 >>> 1;
2531
2417
  var parent = heap[parentIndex];
2532
2418
 
2533
- if (parent !== undefined && compare(parent, node) > 0) {
2419
+ if (compare(parent, node) > 0) {
2534
2420
  // The parent is larger. Swap positions.
2535
2421
  heap[parentIndex] = node;
2536
2422
  heap[index] = parent;
@@ -2545,15 +2431,16 @@
2545
2431
  function siftDown(heap, node, i) {
2546
2432
  var index = i;
2547
2433
  var length = heap.length;
2434
+ var halfLength = length >>> 1;
2548
2435
 
2549
- while (index < length) {
2436
+ while (index < halfLength) {
2550
2437
  var leftIndex = (index + 1) * 2 - 1;
2551
2438
  var left = heap[leftIndex];
2552
2439
  var rightIndex = leftIndex + 1;
2553
2440
  var right = heap[rightIndex]; // If the left or right node is smaller, swap with the smaller of those.
2554
2441
 
2555
- if (left !== undefined && compare(left, node) < 0) {
2556
- if (right !== undefined && compare(right, left) < 0) {
2442
+ if (compare(left, node) < 0) {
2443
+ if (rightIndex < length && compare(right, left) < 0) {
2557
2444
  heap[index] = right;
2558
2445
  heap[rightIndex] = node;
2559
2446
  index = rightIndex;
@@ -2562,7 +2449,7 @@
2562
2449
  heap[leftIndex] = node;
2563
2450
  index = leftIndex;
2564
2451
  }
2565
- } else if (right !== undefined && compare(right, node) < 0) {
2452
+ } else if (rightIndex < length && compare(right, node) < 0) {
2566
2453
  heap[index] = right;
2567
2454
  heap[rightIndex] = node;
2568
2455
  index = rightIndex;
@@ -2580,178 +2467,37 @@
2580
2467
  }
2581
2468
 
2582
2469
  // TODO: Use symbols?
2583
- var NoPriority = 0;
2584
2470
  var ImmediatePriority = 1;
2585
2471
  var UserBlockingPriority = 2;
2586
2472
  var NormalPriority = 3;
2587
2473
  var LowPriority = 4;
2588
2474
  var IdlePriority = 5;
2589
2475
 
2590
- var runIdCounter = 0;
2591
- var mainThreadIdCounter = 0;
2592
- var profilingStateSize = 4;
2593
- var sharedProfilingBuffer = // $FlowFixMe Flow doesn't know about SharedArrayBuffer
2594
- typeof SharedArrayBuffer === 'function' ? new SharedArrayBuffer(profilingStateSize * Int32Array.BYTES_PER_ELEMENT) : // $FlowFixMe Flow doesn't know about ArrayBuffer
2595
- typeof ArrayBuffer === 'function' ? new ArrayBuffer(profilingStateSize * Int32Array.BYTES_PER_ELEMENT) : null // Don't crash the init path on IE9
2596
- ;
2597
- var profilingState = sharedProfilingBuffer !== null ? new Int32Array(sharedProfilingBuffer) : []; // We can't read this but it helps save bytes for null checks
2598
-
2599
- var PRIORITY = 0;
2600
- var CURRENT_TASK_ID = 1;
2601
- var CURRENT_RUN_ID = 2;
2602
- var QUEUE_SIZE = 3;
2603
-
2604
- {
2605
- profilingState[PRIORITY] = NoPriority; // This is maintained with a counter, because the size of the priority queue
2606
- // array might include canceled tasks.
2607
-
2608
- profilingState[QUEUE_SIZE] = 0;
2609
- profilingState[CURRENT_TASK_ID] = 0;
2610
- } // Bytes per element is 4
2611
-
2612
-
2613
- var INITIAL_EVENT_LOG_SIZE = 131072;
2614
- var MAX_EVENT_LOG_SIZE = 524288; // Equivalent to 2 megabytes
2615
-
2616
- var eventLogSize = 0;
2617
- var eventLogBuffer = null;
2618
- var eventLog = null;
2619
- var eventLogIndex = 0;
2620
- var TaskStartEvent = 1;
2621
- var TaskCompleteEvent = 2;
2622
- var TaskErrorEvent = 3;
2623
- var TaskCancelEvent = 4;
2624
- var TaskRunEvent = 5;
2625
- var TaskYieldEvent = 6;
2626
- var SchedulerSuspendEvent = 7;
2627
- var SchedulerResumeEvent = 8;
2628
-
2629
- function logEvent(entries) {
2630
- if (eventLog !== null) {
2631
- var offset = eventLogIndex;
2632
- eventLogIndex += entries.length;
2633
-
2634
- if (eventLogIndex + 1 > eventLogSize) {
2635
- eventLogSize *= 2;
2636
-
2637
- if (eventLogSize > MAX_EVENT_LOG_SIZE) {
2638
- // Using console['error'] to evade Babel and ESLint
2639
- console['error']("Scheduler Profiling: Event log exceeded maximum size. Don't " + 'forget to call `stopLoggingProfilingEvents()`.');
2640
- stopLoggingProfilingEvents();
2641
- return;
2642
- }
2643
-
2644
- var newEventLog = new Int32Array(eventLogSize * 4);
2645
- newEventLog.set(eventLog);
2646
- eventLogBuffer = newEventLog.buffer;
2647
- eventLog = newEventLog;
2648
- }
2649
-
2650
- eventLog.set(entries, offset);
2651
- }
2652
- }
2653
-
2654
- function startLoggingProfilingEvents() {
2655
- eventLogSize = INITIAL_EVENT_LOG_SIZE;
2656
- eventLogBuffer = new ArrayBuffer(eventLogSize * 4);
2657
- eventLog = new Int32Array(eventLogBuffer);
2658
- eventLogIndex = 0;
2659
- }
2660
- function stopLoggingProfilingEvents() {
2661
- var buffer = eventLogBuffer;
2662
- eventLogSize = 0;
2663
- eventLogBuffer = null;
2664
- eventLog = null;
2665
- eventLogIndex = 0;
2666
- return buffer;
2667
- }
2668
- function markTaskStart(task, ms) {
2669
- {
2670
- profilingState[QUEUE_SIZE]++;
2671
-
2672
- if (eventLog !== null) {
2673
- // performance.now returns a float, representing milliseconds. When the
2674
- // event is logged, it's coerced to an int. Convert to microseconds to
2675
- // maintain extra degrees of precision.
2676
- logEvent([TaskStartEvent, ms * 1000, task.id, task.priorityLevel]);
2677
- }
2678
- }
2679
- }
2680
- function markTaskCompleted(task, ms) {
2681
- {
2682
- profilingState[PRIORITY] = NoPriority;
2683
- profilingState[CURRENT_TASK_ID] = 0;
2684
- profilingState[QUEUE_SIZE]--;
2685
-
2686
- if (eventLog !== null) {
2687
- logEvent([TaskCompleteEvent, ms * 1000, task.id]);
2688
- }
2689
- }
2690
- }
2691
- function markTaskCanceled(task, ms) {
2692
- {
2693
- profilingState[QUEUE_SIZE]--;
2694
-
2695
- if (eventLog !== null) {
2696
- logEvent([TaskCancelEvent, ms * 1000, task.id]);
2697
- }
2698
- }
2699
- }
2700
2476
  function markTaskErrored(task, ms) {
2701
- {
2702
- profilingState[PRIORITY] = NoPriority;
2703
- profilingState[CURRENT_TASK_ID] = 0;
2704
- profilingState[QUEUE_SIZE]--;
2705
-
2706
- if (eventLog !== null) {
2707
- logEvent([TaskErrorEvent, ms * 1000, task.id]);
2708
- }
2709
- }
2710
2477
  }
2711
- function markTaskRun(task, ms) {
2712
- {
2713
- runIdCounter++;
2714
- profilingState[PRIORITY] = task.priorityLevel;
2715
- profilingState[CURRENT_TASK_ID] = task.id;
2716
- profilingState[CURRENT_RUN_ID] = runIdCounter;
2717
2478
 
2718
- if (eventLog !== null) {
2719
- logEvent([TaskRunEvent, ms * 1000, task.id, runIdCounter]);
2720
- }
2721
- }
2722
- }
2723
- function markTaskYield(task, ms) {
2724
- {
2725
- profilingState[PRIORITY] = NoPriority;
2726
- profilingState[CURRENT_TASK_ID] = 0;
2727
- profilingState[CURRENT_RUN_ID] = 0;
2479
+ /* eslint-disable no-var */
2480
+ var getCurrentTime;
2481
+ var hasPerformanceNow = typeof performance === 'object' && typeof performance.now === 'function';
2728
2482
 
2729
- if (eventLog !== null) {
2730
- logEvent([TaskYieldEvent, ms * 1000, task.id, runIdCounter]);
2731
- }
2732
- }
2733
- }
2734
- function markSchedulerSuspended(ms) {
2735
- {
2736
- mainThreadIdCounter++;
2483
+ if (hasPerformanceNow) {
2484
+ var localPerformance = performance;
2737
2485
 
2738
- if (eventLog !== null) {
2739
- logEvent([SchedulerSuspendEvent, ms * 1000, mainThreadIdCounter]);
2740
- }
2741
- }
2742
- }
2743
- function markSchedulerUnsuspended(ms) {
2744
- {
2745
- if (eventLog !== null) {
2746
- logEvent([SchedulerResumeEvent, ms * 1000, mainThreadIdCounter]);
2747
- }
2748
- }
2749
- }
2486
+ getCurrentTime = function () {
2487
+ return localPerformance.now();
2488
+ };
2489
+ } else {
2490
+ var localDate = Date;
2491
+ var initialTime = localDate.now();
2750
2492
 
2751
- /* eslint-disable no-var */
2493
+ getCurrentTime = function () {
2494
+ return localDate.now() - initialTime;
2495
+ };
2496
+ } // Max 31 bit integer. The max integer size in V8 for 32-bit systems.
2752
2497
  // Math.pow(2, 30) - 1
2753
2498
  // 0b111111111111111111111111111111
2754
2499
 
2500
+
2755
2501
  var maxSigned31BitInt = 1073741823; // Times out immediately
2756
2502
 
2757
2503
  var IMMEDIATE_PRIORITY_TIMEOUT = -1; // Eventually times out
@@ -2771,7 +2517,11 @@
2771
2517
 
2772
2518
  var isPerformingWork = false;
2773
2519
  var isHostCallbackScheduled = false;
2774
- var isHostTimeoutScheduled = false;
2520
+ var isHostTimeoutScheduled = false; // Capture local references to native APIs, in case a polyfill overrides them.
2521
+
2522
+ var localSetTimeout = typeof setTimeout === 'function' ? setTimeout : null;
2523
+ var localClearTimeout = typeof clearTimeout === 'function' ? clearTimeout : null;
2524
+ var localSetImmediate = typeof setImmediate !== 'undefined' ? setImmediate : null; // IE and Node.js + jsdom
2775
2525
 
2776
2526
  function advanceTimers(currentTime) {
2777
2527
  // Check for tasks that are no longer delayed and add them to the queue.
@@ -2786,11 +2536,6 @@
2786
2536
  pop(timerQueue);
2787
2537
  timer.sortIndex = timer.expirationTime;
2788
2538
  push(taskQueue, timer);
2789
-
2790
- {
2791
- markTaskStart(timer, currentTime);
2792
- timer.isQueued = true;
2793
- }
2794
2539
  } else {
2795
2540
  // Remaining timers are pending.
2796
2541
  return;
@@ -2819,9 +2564,6 @@
2819
2564
  }
2820
2565
 
2821
2566
  function flushWork(hasTimeRemaining, initialTime) {
2822
- {
2823
- markSchedulerUnsuspended(initialTime);
2824
- } // We'll need a host callback the next time work is scheduled.
2825
2567
 
2826
2568
 
2827
2569
  isHostCallbackScheduled = false;
@@ -2856,12 +2598,6 @@
2856
2598
  currentTask = null;
2857
2599
  currentPriorityLevel = previousPriorityLevel;
2858
2600
  isPerformingWork = false;
2859
-
2860
- {
2861
- var _currentTime = getCurrentTime();
2862
-
2863
- markSchedulerSuspended(_currentTime);
2864
- }
2865
2601
  }
2866
2602
  }
2867
2603
 
@@ -2882,18 +2618,13 @@
2882
2618
  currentTask.callback = null;
2883
2619
  currentPriorityLevel = currentTask.priorityLevel;
2884
2620
  var didUserCallbackTimeout = currentTask.expirationTime <= currentTime;
2885
- markTaskRun(currentTask, currentTime);
2621
+
2886
2622
  var continuationCallback = callback(didUserCallbackTimeout);
2887
2623
  currentTime = getCurrentTime();
2888
2624
 
2889
2625
  if (typeof continuationCallback === 'function') {
2890
2626
  currentTask.callback = continuationCallback;
2891
- markTaskYield(currentTask, currentTime);
2892
2627
  } else {
2893
- {
2894
- markTaskCompleted(currentTask, currentTime);
2895
- currentTask.isQueued = false;
2896
- }
2897
2628
 
2898
2629
  if (currentTask === peek(taskQueue)) {
2899
2630
  pop(taskQueue);
@@ -3038,10 +2769,6 @@
3038
2769
  sortIndex: -1
3039
2770
  };
3040
2771
 
3041
- {
3042
- newTask.isQueued = false;
3043
- }
3044
-
3045
2772
  if (startTime > currentTime) {
3046
2773
  // This is a delayed task.
3047
2774
  newTask.sortIndex = startTime;
@@ -3062,11 +2789,6 @@
3062
2789
  } else {
3063
2790
  newTask.sortIndex = expirationTime;
3064
2791
  push(taskQueue, newTask);
3065
-
3066
- {
3067
- markTaskStart(newTask, currentTime);
3068
- newTask.isQueued = true;
3069
- } // Schedule a host callback, if needed. If we're already performing work,
3070
2792
  // wait until the next time we yield.
3071
2793
 
3072
2794
 
@@ -3095,13 +2817,6 @@
3095
2817
  }
3096
2818
 
3097
2819
  function unstable_cancelCallback(task) {
3098
- {
3099
- if (task.isQueued) {
3100
- var currentTime = getCurrentTime();
3101
- markTaskCanceled(task, currentTime);
3102
- task.isQueued = false;
3103
- }
3104
- } // Null out the callback to indicate the task has been canceled. (Can't
3105
2820
  // remove from the queue because you can't remove arbitrary nodes from an
3106
2821
  // array based heap, only the first one.)
3107
2822
 
@@ -3113,374 +2828,156 @@
3113
2828
  return currentPriorityLevel;
3114
2829
  }
3115
2830
 
3116
- var unstable_requestPaint = requestPaint;
3117
- var unstable_Profiling = {
3118
- startLoggingProfilingEvents: startLoggingProfilingEvents,
3119
- stopLoggingProfilingEvents: stopLoggingProfilingEvents,
3120
- sharedProfilingBuffer: sharedProfilingBuffer
3121
- } ;
3122
-
2831
+ var isMessageLoopRunning = false;
2832
+ var scheduledHostCallback = null;
2833
+ var taskTimeoutID = -1; // Scheduler periodically yields in case there is other work on the main
2834
+ // thread, like user events. By default, it yields multiple times per frame.
2835
+ // It does not attempt to align with frame boundaries, since most tasks don't
2836
+ // need to be frame aligned; for those that do, use requestAnimationFrame.
3123
2837
 
2838
+ var yieldInterval = 5;
2839
+ var deadline = 0; // TODO: Make this configurable
3124
2840
 
3125
- var Scheduler = /*#__PURE__*/Object.freeze({
3126
- __proto__: null,
3127
- unstable_ImmediatePriority: ImmediatePriority,
3128
- unstable_UserBlockingPriority: UserBlockingPriority,
3129
- unstable_NormalPriority: NormalPriority,
3130
- unstable_IdlePriority: IdlePriority,
3131
- unstable_LowPriority: LowPriority,
3132
- unstable_runWithPriority: unstable_runWithPriority,
3133
- unstable_next: unstable_next,
3134
- unstable_scheduleCallback: unstable_scheduleCallback,
3135
- unstable_cancelCallback: unstable_cancelCallback,
3136
- unstable_wrapCallback: unstable_wrapCallback,
3137
- unstable_getCurrentPriorityLevel: unstable_getCurrentPriorityLevel,
3138
- get unstable_shouldYield () { return shouldYieldToHost; },
3139
- unstable_requestPaint: unstable_requestPaint,
3140
- unstable_continueExecution: unstable_continueExecution,
3141
- unstable_pauseExecution: unstable_pauseExecution,
3142
- unstable_getFirstCallbackNode: unstable_getFirstCallbackNode,
3143
- get unstable_now () { return getCurrentTime; },
3144
- get unstable_forceFrameRate () { return forceFrameRate; },
3145
- unstable_Profiling: unstable_Profiling
3146
- });
3147
-
3148
- var DEFAULT_THREAD_ID = 0; // Counters used to generate unique IDs.
3149
-
3150
- var interactionIDCounter = 0;
3151
- var threadIDCounter = 0; // Set of currently traced interactions.
3152
- // Interactions "stack"–
3153
- // Meaning that newly traced interactions are appended to the previously active set.
3154
- // When an interaction goes out of scope, the previous set (if any) is restored.
3155
-
3156
- var interactionsRef = null; // Listener(s) to notify when interactions begin and end.
3157
-
3158
- var subscriberRef = null;
3159
-
3160
- {
3161
- interactionsRef = {
3162
- current: new Set()
3163
- };
3164
- subscriberRef = {
3165
- current: null
3166
- };
3167
- }
3168
- function unstable_clear(callback) {
3169
-
3170
- var prevInteractions = interactionsRef.current;
3171
- interactionsRef.current = new Set();
3172
-
3173
- try {
3174
- return callback();
3175
- } finally {
3176
- interactionsRef.current = prevInteractions;
3177
- }
3178
- }
3179
- function unstable_getCurrent() {
2841
+ function shouldYieldToHost() {
3180
2842
  {
3181
- return interactionsRef.current;
2843
+ // `isInputPending` is not available. Since we have no way of knowing if
2844
+ // there's pending input, always yield at the end of the frame.
2845
+ return getCurrentTime() >= deadline;
3182
2846
  }
3183
2847
  }
3184
- function unstable_getThreadID() {
3185
- return ++threadIDCounter;
3186
- }
3187
- function unstable_trace(name, timestamp, callback) {
3188
- var threadID = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : DEFAULT_THREAD_ID;
3189
-
3190
- var interaction = {
3191
- __count: 1,
3192
- id: interactionIDCounter++,
3193
- name: name,
3194
- timestamp: timestamp
3195
- };
3196
- var prevInteractions = interactionsRef.current; // Traced interactions should stack/accumulate.
3197
- // To do that, clone the current interactions.
3198
- // The previous set will be restored upon completion.
3199
2848
 
3200
- var interactions = new Set(prevInteractions);
3201
- interactions.add(interaction);
3202
- interactionsRef.current = interactions;
3203
- var subscriber = subscriberRef.current;
3204
- var returnValue;
2849
+ function requestPaint() {
3205
2850
 
3206
- try {
3207
- if (subscriber !== null) {
3208
- subscriber.onInteractionTraced(interaction);
3209
- }
3210
- } finally {
3211
- try {
3212
- if (subscriber !== null) {
3213
- subscriber.onWorkStarted(interactions, threadID);
3214
- }
3215
- } finally {
3216
- try {
3217
- returnValue = callback();
3218
- } finally {
3219
- interactionsRef.current = prevInteractions;
3220
-
3221
- try {
3222
- if (subscriber !== null) {
3223
- subscriber.onWorkStopped(interactions, threadID);
3224
- }
3225
- } finally {
3226
- interaction.__count--; // If no async work was scheduled for this interaction,
3227
- // Notify subscribers that it's completed.
2851
+ }
3228
2852
 
3229
- if (subscriber !== null && interaction.__count === 0) {
3230
- subscriber.onInteractionScheduledWorkCompleted(interaction);
3231
- }
3232
- }
3233
- }
3234
- }
2853
+ function forceFrameRate(fps) {
2854
+ if (fps < 0 || fps > 125) {
2855
+ // Using console['error'] to evade Babel and ESLint
2856
+ console['error']('forceFrameRate takes a positive int between 0 and 125, ' + 'forcing frame rates higher than 125 fps is not supported');
2857
+ return;
3235
2858
  }
3236
2859
 
3237
- return returnValue;
2860
+ if (fps > 0) {
2861
+ yieldInterval = Math.floor(1000 / fps);
2862
+ } else {
2863
+ // reset the framerate
2864
+ yieldInterval = 5;
2865
+ }
3238
2866
  }
3239
- function unstable_wrap(callback) {
3240
- var threadID = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DEFAULT_THREAD_ID;
3241
-
3242
- var wrappedInteractions = interactionsRef.current;
3243
- var subscriber = subscriberRef.current;
3244
2867
 
3245
- if (subscriber !== null) {
3246
- subscriber.onWorkScheduled(wrappedInteractions, threadID);
3247
- } // Update the pending async work count for the current interactions.
3248
- // Update after calling subscribers in case of error.
2868
+ var performWorkUntilDeadline = function () {
2869
+ if (scheduledHostCallback !== null) {
2870
+ var currentTime = getCurrentTime(); // Yield after `yieldInterval` ms, regardless of where we are in the vsync
2871
+ // cycle. This means there's always time remaining at the beginning of
2872
+ // the message event.
3249
2873
 
2874
+ deadline = currentTime + yieldInterval;
2875
+ var hasTimeRemaining = true; // If a scheduler task throws, exit the current browser task so the
2876
+ // error can be observed.
2877
+ //
2878
+ // Intentionally not using a try-catch, since that makes some debugging
2879
+ // techniques harder. Instead, if `scheduledHostCallback` errors, then
2880
+ // `hasMoreWork` will remain true, and we'll continue the work loop.
3250
2881
 
3251
- wrappedInteractions.forEach(function (interaction) {
3252
- interaction.__count++;
3253
- });
3254
- var hasRun = false;
3255
-
3256
- function wrapped() {
3257
- var prevInteractions = interactionsRef.current;
3258
- interactionsRef.current = wrappedInteractions;
3259
- subscriber = subscriberRef.current;
2882
+ var hasMoreWork = true;
3260
2883
 
3261
2884
  try {
3262
- var returnValue;
3263
-
3264
- try {
3265
- if (subscriber !== null) {
3266
- subscriber.onWorkStarted(wrappedInteractions, threadID);
3267
- }
3268
- } finally {
3269
- try {
3270
- returnValue = callback.apply(undefined, arguments);
3271
- } finally {
3272
- interactionsRef.current = prevInteractions;
3273
-
3274
- if (subscriber !== null) {
3275
- subscriber.onWorkStopped(wrappedInteractions, threadID);
3276
- }
3277
- }
3278
- }
3279
-
3280
- return returnValue;
2885
+ hasMoreWork = scheduledHostCallback(hasTimeRemaining, currentTime);
3281
2886
  } finally {
3282
- if (!hasRun) {
3283
- // We only expect a wrapped function to be executed once,
3284
- // But in the event that it's executed more than once–
3285
- // Only decrement the outstanding interaction counts once.
3286
- hasRun = true; // Update pending async counts for all wrapped interactions.
3287
- // If this was the last scheduled async work for any of them,
3288
- // Mark them as completed.
3289
-
3290
- wrappedInteractions.forEach(function (interaction) {
3291
- interaction.__count--;
3292
-
3293
- if (subscriber !== null && interaction.__count === 0) {
3294
- subscriber.onInteractionScheduledWorkCompleted(interaction);
3295
- }
3296
- });
2887
+ if (hasMoreWork) {
2888
+ // If there's more work, schedule the next message event at the end
2889
+ // of the preceding one.
2890
+ schedulePerformWorkUntilDeadline();
2891
+ } else {
2892
+ isMessageLoopRunning = false;
2893
+ scheduledHostCallback = null;
3297
2894
  }
3298
2895
  }
3299
- }
3300
-
3301
- wrapped.cancel = function cancel() {
3302
- subscriber = subscriberRef.current;
2896
+ } else {
2897
+ isMessageLoopRunning = false;
2898
+ } // Yielding to the browser will give it a chance to paint, so we can
2899
+ };
3303
2900
 
3304
- try {
3305
- if (subscriber !== null) {
3306
- subscriber.onWorkCanceled(wrappedInteractions, threadID);
3307
- }
3308
- } finally {
3309
- // Update pending async counts for all wrapped interactions.
3310
- // If this was the last scheduled async work for any of them,
3311
- // Mark them as completed.
3312
- wrappedInteractions.forEach(function (interaction) {
3313
- interaction.__count--;
3314
-
3315
- if (subscriber && interaction.__count === 0) {
3316
- subscriber.onInteractionScheduledWorkCompleted(interaction);
3317
- }
3318
- });
3319
- }
2901
+ var schedulePerformWorkUntilDeadline;
2902
+
2903
+ if (typeof localSetImmediate === 'function') {
2904
+ // Node.js and old IE.
2905
+ // There's a few reasons for why we prefer setImmediate.
2906
+ //
2907
+ // Unlike MessageChannel, it doesn't prevent a Node.js process from exiting.
2908
+ // (Even though this is a DOM fork of the Scheduler, you could get here
2909
+ // with a mix of Node.js 15+, which has a MessageChannel, and jsdom.)
2910
+ // https://github.com/facebook/react/issues/20756
2911
+ //
2912
+ // But also, it runs earlier which is the semantic we want.
2913
+ // If other browsers ever implement it, it's better to use it.
2914
+ // Although both of these would be inferior to native scheduling.
2915
+ schedulePerformWorkUntilDeadline = function () {
2916
+ localSetImmediate(performWorkUntilDeadline);
3320
2917
  };
2918
+ } else if (typeof MessageChannel !== 'undefined') {
2919
+ // DOM and Worker environments.
2920
+ // We prefer MessageChannel because of the 4ms setTimeout clamping.
2921
+ var channel = new MessageChannel();
2922
+ var port = channel.port2;
2923
+ channel.port1.onmessage = performWorkUntilDeadline;
3321
2924
 
3322
- return wrapped;
3323
- }
3324
-
3325
- var subscribers = null;
3326
-
3327
- {
3328
- subscribers = new Set();
3329
- }
3330
-
3331
- function unstable_subscribe(subscriber) {
3332
- {
3333
- subscribers.add(subscriber);
3334
-
3335
- if (subscribers.size === 1) {
3336
- subscriberRef.current = {
3337
- onInteractionScheduledWorkCompleted: onInteractionScheduledWorkCompleted,
3338
- onInteractionTraced: onInteractionTraced,
3339
- onWorkCanceled: onWorkCanceled,
3340
- onWorkScheduled: onWorkScheduled,
3341
- onWorkStarted: onWorkStarted,
3342
- onWorkStopped: onWorkStopped
3343
- };
3344
- }
3345
- }
3346
- }
3347
- function unstable_unsubscribe(subscriber) {
3348
- {
3349
- subscribers.delete(subscriber);
3350
-
3351
- if (subscribers.size === 0) {
3352
- subscriberRef.current = null;
3353
- }
3354
- }
3355
- }
3356
-
3357
- function onInteractionTraced(interaction) {
3358
- var didCatchError = false;
3359
- var caughtError = null;
3360
- subscribers.forEach(function (subscriber) {
3361
- try {
3362
- subscriber.onInteractionTraced(interaction);
3363
- } catch (error) {
3364
- if (!didCatchError) {
3365
- didCatchError = true;
3366
- caughtError = error;
3367
- }
3368
- }
3369
- });
3370
-
3371
- if (didCatchError) {
3372
- throw caughtError;
3373
- }
3374
- }
3375
-
3376
- function onInteractionScheduledWorkCompleted(interaction) {
3377
- var didCatchError = false;
3378
- var caughtError = null;
3379
- subscribers.forEach(function (subscriber) {
3380
- try {
3381
- subscriber.onInteractionScheduledWorkCompleted(interaction);
3382
- } catch (error) {
3383
- if (!didCatchError) {
3384
- didCatchError = true;
3385
- caughtError = error;
3386
- }
3387
- }
3388
- });
3389
-
3390
- if (didCatchError) {
3391
- throw caughtError;
3392
- }
2925
+ schedulePerformWorkUntilDeadline = function () {
2926
+ port.postMessage(null);
2927
+ };
2928
+ } else {
2929
+ // We should only fallback here in non-browser environments.
2930
+ schedulePerformWorkUntilDeadline = function () {
2931
+ localSetTimeout(performWorkUntilDeadline, 0);
2932
+ };
3393
2933
  }
3394
2934
 
3395
- function onWorkScheduled(interactions, threadID) {
3396
- var didCatchError = false;
3397
- var caughtError = null;
3398
- subscribers.forEach(function (subscriber) {
3399
- try {
3400
- subscriber.onWorkScheduled(interactions, threadID);
3401
- } catch (error) {
3402
- if (!didCatchError) {
3403
- didCatchError = true;
3404
- caughtError = error;
3405
- }
3406
- }
3407
- });
2935
+ function requestHostCallback(callback) {
2936
+ scheduledHostCallback = callback;
3408
2937
 
3409
- if (didCatchError) {
3410
- throw caughtError;
2938
+ if (!isMessageLoopRunning) {
2939
+ isMessageLoopRunning = true;
2940
+ schedulePerformWorkUntilDeadline();
3411
2941
  }
3412
2942
  }
3413
2943
 
3414
- function onWorkStarted(interactions, threadID) {
3415
- var didCatchError = false;
3416
- var caughtError = null;
3417
- subscribers.forEach(function (subscriber) {
3418
- try {
3419
- subscriber.onWorkStarted(interactions, threadID);
3420
- } catch (error) {
3421
- if (!didCatchError) {
3422
- didCatchError = true;
3423
- caughtError = error;
3424
- }
3425
- }
3426
- });
3427
-
3428
- if (didCatchError) {
3429
- throw caughtError;
3430
- }
2944
+ function requestHostTimeout(callback, ms) {
2945
+ taskTimeoutID = localSetTimeout(function () {
2946
+ callback(getCurrentTime());
2947
+ }, ms);
3431
2948
  }
3432
2949
 
3433
- function onWorkStopped(interactions, threadID) {
3434
- var didCatchError = false;
3435
- var caughtError = null;
3436
- subscribers.forEach(function (subscriber) {
3437
- try {
3438
- subscriber.onWorkStopped(interactions, threadID);
3439
- } catch (error) {
3440
- if (!didCatchError) {
3441
- didCatchError = true;
3442
- caughtError = error;
3443
- }
3444
- }
3445
- });
3446
-
3447
- if (didCatchError) {
3448
- throw caughtError;
3449
- }
2950
+ function cancelHostTimeout() {
2951
+ localClearTimeout(taskTimeoutID);
2952
+ taskTimeoutID = -1;
3450
2953
  }
3451
2954
 
3452
- function onWorkCanceled(interactions, threadID) {
3453
- var didCatchError = false;
3454
- var caughtError = null;
3455
- subscribers.forEach(function (subscriber) {
3456
- try {
3457
- subscriber.onWorkCanceled(interactions, threadID);
3458
- } catch (error) {
3459
- if (!didCatchError) {
3460
- didCatchError = true;
3461
- caughtError = error;
3462
- }
3463
- }
3464
- });
3465
-
3466
- if (didCatchError) {
3467
- throw caughtError;
3468
- }
3469
- }
2955
+ var unstable_requestPaint = requestPaint;
2956
+ var unstable_Profiling = null;
3470
2957
 
3471
2958
 
3472
2959
 
3473
- var SchedulerTracing = /*#__PURE__*/Object.freeze({
2960
+ var Scheduler = /*#__PURE__*/Object.freeze({
3474
2961
  __proto__: null,
3475
- get __interactionsRef () { return interactionsRef; },
3476
- get __subscriberRef () { return subscriberRef; },
3477
- unstable_clear: unstable_clear,
3478
- unstable_getCurrent: unstable_getCurrent,
3479
- unstable_getThreadID: unstable_getThreadID,
3480
- unstable_trace: unstable_trace,
3481
- unstable_wrap: unstable_wrap,
3482
- unstable_subscribe: unstable_subscribe,
3483
- unstable_unsubscribe: unstable_unsubscribe
2962
+ unstable_ImmediatePriority: ImmediatePriority,
2963
+ unstable_UserBlockingPriority: UserBlockingPriority,
2964
+ unstable_NormalPriority: NormalPriority,
2965
+ unstable_IdlePriority: IdlePriority,
2966
+ unstable_LowPriority: LowPriority,
2967
+ unstable_runWithPriority: unstable_runWithPriority,
2968
+ unstable_next: unstable_next,
2969
+ unstable_scheduleCallback: unstable_scheduleCallback,
2970
+ unstable_cancelCallback: unstable_cancelCallback,
2971
+ unstable_wrapCallback: unstable_wrapCallback,
2972
+ unstable_getCurrentPriorityLevel: unstable_getCurrentPriorityLevel,
2973
+ unstable_shouldYield: shouldYieldToHost,
2974
+ unstable_requestPaint: unstable_requestPaint,
2975
+ unstable_continueExecution: unstable_continueExecution,
2976
+ unstable_pauseExecution: unstable_pauseExecution,
2977
+ unstable_getFirstCallbackNode: unstable_getFirstCallbackNode,
2978
+ get unstable_now () { return getCurrentTime; },
2979
+ unstable_forceFrameRate: forceFrameRate,
2980
+ unstable_Profiling: unstable_Profiling
3484
2981
  });
3485
2982
 
3486
2983
  var ReactSharedInternals$1 = {
@@ -3495,24 +2992,21 @@
3495
2992
  // Since that would be a breaking change (e.g. for all existing CodeSandboxes).
3496
2993
  // This re-export is only required for UMD bundles;
3497
2994
  // CJS bundles use the shared NPM package.
3498
- Scheduler: Scheduler,
3499
- SchedulerTracing: SchedulerTracing
2995
+ Scheduler: Scheduler
3500
2996
  };
3501
2997
 
3502
2998
  {
3503
2999
  ReactSharedInternals$1.ReactDebugCurrentFrame = ReactDebugCurrentFrame;
3504
3000
  }
3505
3001
 
3506
- {
3002
+ function startTransition(scope) {
3003
+ var prevTransition = ReactCurrentBatchConfig.transition;
3004
+ ReactCurrentBatchConfig.transition = 1;
3507
3005
 
3508
3006
  try {
3509
- var frozenObject = Object.freeze({});
3510
- /* eslint-disable no-new */
3511
-
3512
- new Map([[frozenObject, null]]);
3513
- new Set([frozenObject]);
3514
- /* eslint-enable no-new */
3515
- } catch (e) {
3007
+ scope();
3008
+ } finally {
3009
+ ReactCurrentBatchConfig.transition = prevTransition;
3516
3010
  }
3517
3011
  }
3518
3012
 
@@ -3540,9 +3034,14 @@
3540
3034
  exports.isValidElement = isValidElement;
3541
3035
  exports.lazy = lazy;
3542
3036
  exports.memo = memo;
3037
+ exports.startTransition = startTransition;
3038
+ exports.unstable_createMutableSource = createMutableSource;
3039
+ exports.unstable_useMutableSource = useMutableSource;
3040
+ exports.unstable_useOpaqueIdentifier = useOpaqueIdentifier;
3543
3041
  exports.useCallback = useCallback;
3544
3042
  exports.useContext = useContext;
3545
3043
  exports.useDebugValue = useDebugValue;
3044
+ exports.useDeferredValue = useDeferredValue;
3546
3045
  exports.useEffect = useEffect;
3547
3046
  exports.useImperativeHandle = useImperativeHandle;
3548
3047
  exports.useLayoutEffect = useLayoutEffect;
@@ -3550,6 +3049,7 @@
3550
3049
  exports.useReducer = useReducer;
3551
3050
  exports.useRef = useRef;
3552
3051
  exports.useState = useState;
3052
+ exports.useTransition = useTransition;
3553
3053
  exports.version = ReactVersion;
3554
3054
 
3555
3055
  })));