diff --git a/Libraries/Renderer/REVISION b/Libraries/Renderer/REVISION index 1741b7411..1526108b0 100644 --- a/Libraries/Renderer/REVISION +++ b/Libraries/Renderer/REVISION @@ -1 +1 @@ -bc1ea9cd96c81467c574b134349eafc303835d0e \ No newline at end of file +ade5e692883345783e32e87875bbb744fb415c9c \ No newline at end of file diff --git a/Libraries/Renderer/oss/ReactFabric-dev.js b/Libraries/Renderer/oss/ReactFabric-dev.js index 2d6425b42..410669cb5 100644 --- a/Libraries/Renderer/oss/ReactFabric-dev.js +++ b/Libraries/Renderer/oss/ReactFabric-dev.js @@ -1,5 +1,5 @@ /** - * Copyright (c) 2013-present, Facebook, Inc. + * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. @@ -26,6 +26,7 @@ var deepFreezeAndThrowOnMutationInDev = require("deepFreezeAndThrowOnMutationInD var TextInputState = require("TextInputState"); var FabricUIManager = require("FabricUIManager"); var checkPropTypes = require("prop-types/checkPropTypes"); +var tracking = require("schedule/tracking"); var ExceptionsManager = require("ExceptionsManager"); /** @@ -75,15 +76,22 @@ function invariant(condition, format, a, b, c, d, e, f) { } } -var invokeGuardedCallback = function(name, func, context, a, b, c, d, e, f) { - this._hasCaughtError = false; - this._caughtError = null; +var invokeGuardedCallbackImpl = function( + name, + func, + context, + a, + b, + c, + d, + e, + f +) { var funcArgs = Array.prototype.slice.call(arguments, 3); try { func.apply(context, funcArgs); } catch (error) { - this._caughtError = error; - this._hasCaughtError = true; + this.onError(error); } }; @@ -152,6 +160,11 @@ var invokeGuardedCallback = function(name, func, context, a, b, c, d, e, f) { // the error event at all. var didError = true; + // Keeps track of the value of window.event so that we can reset it + // during the callback to let user code access window.event in the + // browsers that support it. + var windowEvent = window.event; + // Create an event handler for our fake event. We will synchronously // dispatch our fake event using `dispatchEvent`. Inside the handler, we // call the user-provided callback. @@ -162,6 +175,18 @@ var invokeGuardedCallback = function(name, func, context, a, b, c, d, e, f) { // nested call would trigger the fake event handlers of any call higher // in the stack. fakeNode.removeEventListener(evtType, callCallback, false); + + // We check for window.hasOwnProperty('event') to prevent the + // window.event assignment in both IE <= 10 as they throw an error + // "Member not found" in strict mode, and in Firefox which does not + // support window.event. + if ( + typeof window.event !== "undefined" && + window.hasOwnProperty("event") + ) { + window.event = windowEvent; + } + func.apply(context, funcArgs); didError = false; } @@ -182,19 +207,31 @@ var invokeGuardedCallback = function(name, func, context, a, b, c, d, e, f) { var didSetError = false; var isCrossOriginError = false; - function onError(event) { + function handleWindowError(event) { error = event.error; didSetError = true; if (error === null && event.colno === 0 && event.lineno === 0) { isCrossOriginError = true; } + if (event.defaultPrevented) { + // Some other error handler has prevented default. + // Browsers silence the error report if this happens. + // We'll remember this to later decide whether to log it or not. + if (error != null && typeof error === "object") { + try { + error._suppressLogging = true; + } catch (inner) { + // Ignore. + } + } + } } // Create a fake event type. var evtType = "react-" + (name ? name : "invokeguardedcallback"); // Attach our event handlers - window.addEventListener("error", onError); + window.addEventListener("error", handleWindowError); fakeNode.addEventListener(evtType, callCallback, false); // Synchronously dispatch our fake event. If the user-provided function @@ -222,116 +259,115 @@ var invokeGuardedCallback = function(name, func, context, a, b, c, d, e, f) { "See https://fb.me/react-crossorigin-error for more information." ); } - this._hasCaughtError = true; - this._caughtError = error; - } else { - this._hasCaughtError = false; - this._caughtError = null; + this.onError(error); } // Remove our event listeners - window.removeEventListener("error", onError); + window.removeEventListener("error", handleWindowError); }; - invokeGuardedCallback = invokeGuardedCallbackDev; + invokeGuardedCallbackImpl = invokeGuardedCallbackDev; } } -var invokeGuardedCallback$1 = invokeGuardedCallback; +var invokeGuardedCallbackImpl$1 = invokeGuardedCallbackImpl; -var ReactErrorUtils = { - // Used by Fiber to simulate a try-catch. - _caughtError: null, - _hasCaughtError: false, +// Used by Fiber to simulate a try-catch. +var hasError = false; +var caughtError = null; - // Used by event system to capture/rethrow the first error. - _rethrowError: null, - _hasRethrowError: false, +// Used by event system to capture/rethrow the first error. +var hasRethrowError = false; +var rethrowError = null; - /** - * Call a function while guarding against errors that happens within it. - * Returns an error if it throws, otherwise null. - * - * In production, this is implemented using a try-catch. The reason we don't - * use a try-catch directly is so that we can swap out a different - * implementation in DEV mode. - * - * @param {String} name of the guard to use for logging or debugging - * @param {Function} func The function to invoke - * @param {*} context The context to use when calling the function - * @param {...*} args Arguments for function - */ - invokeGuardedCallback: function(name, func, context, a, b, c, d, e, f) { - invokeGuardedCallback$1.apply(ReactErrorUtils, arguments); - }, - - /** - * Same as invokeGuardedCallback, but instead of returning an error, it stores - * it in a global so it can be rethrown by `rethrowCaughtError` later. - * TODO: See if _caughtError and _rethrowError can be unified. - * - * @param {String} name of the guard to use for logging or debugging - * @param {Function} func The function to invoke - * @param {*} context The context to use when calling the function - * @param {...*} args Arguments for function - */ - invokeGuardedCallbackAndCatchFirstError: function( - name, - func, - context, - a, - b, - c, - d, - e, - f - ) { - ReactErrorUtils.invokeGuardedCallback.apply(this, arguments); - if (ReactErrorUtils.hasCaughtError()) { - var error = ReactErrorUtils.clearCaughtError(); - if (!ReactErrorUtils._hasRethrowError) { - ReactErrorUtils._hasRethrowError = true; - ReactErrorUtils._rethrowError = error; - } - } - }, - - /** - * During execution of guarded functions we will capture the first error which - * we will rethrow to be handled by the top level error handler. - */ - rethrowCaughtError: function() { - return rethrowCaughtError.apply(ReactErrorUtils, arguments); - }, - - hasCaughtError: function() { - return ReactErrorUtils._hasCaughtError; - }, - - clearCaughtError: function() { - if (ReactErrorUtils._hasCaughtError) { - var error = ReactErrorUtils._caughtError; - ReactErrorUtils._caughtError = null; - ReactErrorUtils._hasCaughtError = false; - return error; - } else { - invariant( - false, - "clearCaughtError was called but no error was captured. This error " + - "is likely caused by a bug in React. Please file an issue." - ); - } +var reporter = { + onError: function(error) { + hasError = true; + caughtError = error; } }; -var rethrowCaughtError = function() { - if (ReactErrorUtils._hasRethrowError) { - var error = ReactErrorUtils._rethrowError; - ReactErrorUtils._rethrowError = null; - ReactErrorUtils._hasRethrowError = false; +/** + * Call a function while guarding against errors that happens within it. + * Returns an error if it throws, otherwise null. + * + * In production, this is implemented using a try-catch. The reason we don't + * use a try-catch directly is so that we can swap out a different + * implementation in DEV mode. + * + * @param {String} name of the guard to use for logging or debugging + * @param {Function} func The function to invoke + * @param {*} context The context to use when calling the function + * @param {...*} args Arguments for function + */ +function invokeGuardedCallback(name, func, context, a, b, c, d, e, f) { + hasError = false; + caughtError = null; + invokeGuardedCallbackImpl$1.apply(reporter, arguments); +} + +/** + * Same as invokeGuardedCallback, but instead of returning an error, it stores + * it in a global so it can be rethrown by `rethrowCaughtError` later. + * TODO: See if caughtError and rethrowError can be unified. + * + * @param {String} name of the guard to use for logging or debugging + * @param {Function} func The function to invoke + * @param {*} context The context to use when calling the function + * @param {...*} args Arguments for function + */ +function invokeGuardedCallbackAndCatchFirstError( + name, + func, + context, + a, + b, + c, + d, + e, + f +) { + invokeGuardedCallback.apply(this, arguments); + if (hasError) { + var error = clearCaughtError(); + if (!hasRethrowError) { + hasRethrowError = true; + rethrowError = error; + } + } +} + +/** + * During execution of guarded functions we will capture the first error which + * we will rethrow to be handled by the top level error handler. + */ +function rethrowCaughtError() { + if (hasRethrowError) { + var error = rethrowError; + hasRethrowError = false; + rethrowError = null; throw error; } -}; +} + +function hasCaughtError() { + return hasError; +} + +function clearCaughtError() { + if (hasError) { + var error = caughtError; + hasError = false; + caughtError = null; + return error; + } else { + invariant( + false, + "clearCaughtError was called but no error was captured. This error " + + "is likely caused by a bug in React. Please file an issue." + ); + } +} /** * Injectable ordering of event plugins. @@ -576,9 +612,12 @@ var warningWithoutStack = function() {}; if (typeof console !== "undefined") { var _console; + var stringArgs = args.map(function(item) { + return "" + item; + }); (_console = console).error.apply( _console, - ["Warning: " + format].concat(args) + ["Warning: " + format].concat(stringArgs) ); } try { @@ -602,23 +641,24 @@ var getFiberCurrentPropsFromNode = null; var getInstanceFromNode = null; var getNodeFromInstance = null; -var injection$1 = { - injectComponentTree: function(Injected) { - getFiberCurrentPropsFromNode = Injected.getFiberCurrentPropsFromNode; - getInstanceFromNode = Injected.getInstanceFromNode; - getNodeFromInstance = Injected.getNodeFromInstance; - - { - !(getNodeFromInstance && getInstanceFromNode) - ? warningWithoutStack$1( - false, - "EventPluginUtils.injection.injectComponentTree(...): Injected " + - "module is missing getNodeFromInstance or getInstanceFromNode." - ) - : void 0; - } +function setComponentTree( + getFiberCurrentPropsFromNodeImpl, + getInstanceFromNodeImpl, + getNodeFromInstanceImpl +) { + getFiberCurrentPropsFromNode = getFiberCurrentPropsFromNodeImpl; + getInstanceFromNode = getInstanceFromNodeImpl; + getNodeFromInstance = getNodeFromInstanceImpl; + { + !(getNodeFromInstance && getInstanceFromNode) + ? warningWithoutStack$1( + false, + "EventPluginUtils.setComponentTree(...): Injected " + + "module is missing getNodeFromInstance or getInstanceFromNode." + ) + : void 0; } -}; +} var validateEventDispatches = void 0; { @@ -656,12 +696,7 @@ var validateEventDispatches = void 0; function executeDispatch(event, simulated, listener, inst) { var type = event.type || "unknown-event"; event.currentTarget = getNodeFromInstance(inst); - ReactErrorUtils.invokeGuardedCallbackAndCatchFirstError( - type, - listener, - undefined, - event - ); + invokeGuardedCallbackAndCatchFirstError(type, listener, undefined, event); event.currentTarget = null; } @@ -1022,7 +1057,7 @@ function runEventsInBatch(events, simulated) { "an event queue. Support for this has not yet been implemented." ); // This would be a good time to rethrow if any of the event handlers threw. - ReactErrorUtils.rethrowCaughtError(); + rethrowCaughtError(); } function runExtractedEventsInBatch( @@ -1040,19 +1075,21 @@ function runExtractedEventsInBatch( runEventsInBatch(events, false); } -var IndeterminateComponent = 0; // Before we know whether it is functional or class -var FunctionalComponent = 1; +var FunctionalComponent = 0; +var FunctionalComponentLazy = 1; var ClassComponent = 2; -var HostRoot = 3; // Root of a host tree. Could be nested inside another node. -var HostPortal = 4; // A subtree. Could be an entry point to a different renderer. -var HostComponent = 5; -var HostText = 6; - -var Fragment = 10; -var Mode = 11; -var ContextConsumer = 12; -var ContextProvider = 13; -var ForwardRef = 14; +var ClassComponentLazy = 3; +var IndeterminateComponent = 4; // Before we know whether it is functional or class +var HostRoot = 5; // Root of a host tree. Could be nested inside another node. +var HostPortal = 6; // A subtree. Could be an entry point to a different renderer. +var HostComponent = 7; +var HostText = 8; +var Fragment = 9; +var Mode = 10; +var ContextConsumer = 11; +var ContextProvider = 12; +var ForwardRef = 13; +var ForwardRefLazy = 14; var Profiler = 15; var PlaceholderComponent = 16; @@ -2492,13 +2529,6 @@ function getFiberCurrentPropsFromNode$1(inst) { return inst.canonical.currentProps; } -var ReactFabricComponentTree = Object.freeze({ - getClosestInstanceFromNode: getInstanceFromInstance, - getInstanceFromNode: getInstanceFromInstance, - getNodeFromInstance: getTagFromInstance, - getFiberCurrentPropsFromNode: getFiberCurrentPropsFromNode$1 -}); - // Module provided by RN: var ReactFabricGlobalResponderHandler = { onChange: function(from, to, blockNativeResponder) { @@ -2511,7 +2541,11 @@ var ReactFabricGlobalResponderHandler = { } }; -injection$1.injectComponentTree(ReactFabricComponentTree); +setComponentTree( + getFiberCurrentPropsFromNode$1, + getInstanceFromInstance, + getTagFromInstance +); ResponderEventPlugin.injection.injectGlobalResponderHandler( ReactFabricGlobalResponderHandler @@ -2569,7 +2603,7 @@ var MAYBE_ITERATOR_SYMBOL = typeof Symbol === "function" && Symbol.iterator; var FAUX_ITERATOR_SYMBOL = "@@iterator"; function getIteratorFn(maybeIterable) { - if (maybeIterable === null || typeof maybeIterable === "undefined") { + if (maybeIterable === null || typeof maybeIterable !== "object") { return null; } var maybeIterator = @@ -2581,6 +2615,18 @@ function getIteratorFn(maybeIterable) { return null; } +var Pending = 0; +var Resolved = 1; +var Rejected = 2; + +function getResultFromResolvedThenable(thenable) { + return thenable._reactResult; +} + +function refineResolvedThenable(thenable) { + return thenable._reactStatus === Resolved ? thenable._reactResult : null; +} + function getComponentName(type) { if (type == null) { // Host root, text node or just invalid type. @@ -2628,6 +2674,13 @@ function getComponentName(type) { ? "ForwardRef(" + functionName + ")" : "ForwardRef"; } + if (typeof type.then === "function") { + var thenable = type; + var resolvedThenable = refineResolvedThenable(thenable); + if (resolvedThenable) { + return getComponentName(resolvedThenable); + } + } } return null; } @@ -2698,7 +2751,10 @@ function isFiberMounted(fiber) { function isMounted(component) { { var owner = ReactCurrentOwner$1.current; - if (owner !== null && owner.tag === ClassComponent) { + if ( + owner !== null && + (owner.tag === ClassComponent || owner.tag === ClassComponentLazy) + ) { var ownerFiber = owner; var instance = ownerFiber.stateNode; !instance._warnedAboutRefsInRender @@ -2889,63 +2945,37 @@ function findCurrentHostFiber(parent) { return null; } -function findCurrentHostFiberWithNoPortals(parent) { - var currentParent = findCurrentFiberUsingSlowPath(parent); - if (!currentParent) { - return null; - } - - // Next we'll drill down this component to find the first HostComponent/Text. - var node = currentParent; - while (true) { - if (node.tag === HostComponent || node.tag === HostText) { - return node; - } else if (node.child && node.tag !== HostPortal) { - node.child.return = node; - node = node.child; - continue; - } - if (node === currentParent) { - return null; - } - while (!node.sibling) { - if (!node.return || node.return === currentParent) { - return null; - } - node = node.return; - } - node.sibling.return = node.return; - node = node.sibling; - } - // Flow needs the return null here, but ESLint complains about it. - // eslint-disable-next-line no-unreachable - return null; -} - /** * In the future, we should cleanup callbacks by cancelling them instead of * using this. */ -function mountSafeCallback(context, callback) { +function mountSafeCallback_NOT_REALLY_SAFE(context, callback) { return function() { if (!callback) { return undefined; } + // This protects against createClass() components. + // We don't know if there is code depending on it. + // We intentionally don't use isMounted() because even accessing + // isMounted property on a React ES6 class will trigger a warning. if (typeof context.__isMounted === "boolean") { - // TODO(gaearon): this is gross and should be removed. - // It is currently necessary because View uses createClass, - // and so any measure() calls on View (which are done by React - // DevTools) trigger the isMounted() deprecation warning. if (!context.__isMounted) { return undefined; } - // The else branch is important so that we don't - // trigger the deprecation warning by calling isMounted. - } else if (typeof context.isMounted === "function") { - if (!context.isMounted()) { - return undefined; - } } + + // FIXME: there used to be other branches that protected + // against unmounted host components. But RN host components don't + // define isMounted() anymore, so those checks didn't do anything. + + // They caused false positive warning noise so we removed them: + // https://github.com/facebook/react-native/issues/18868#issuecomment-413579095 + + // However, this means that the callback is NOT guaranteed to be safe + // for host components. The solution we should implement is to make + // UIManager.measure() and similar calls truly cancelable. Then we + // can change our own code calling them to cancel when something unmounts. + return callback.apply(context, arguments); }; } @@ -3032,8 +3062,8 @@ function restoreDeletedValuesInNestedArray( if (!removedKeys[propKey]) { continue; } - var _nextProp = obj[propKey]; - if (_nextProp === undefined) { + var nextProp = obj[propKey]; + if (nextProp === undefined) { continue; } @@ -3042,16 +3072,16 @@ function restoreDeletedValuesInNestedArray( continue; // not a valid native prop } - if (typeof _nextProp === "function") { - _nextProp = true; + if (typeof nextProp === "function") { + nextProp = true; } - if (typeof _nextProp === "undefined") { - _nextProp = null; + if (typeof nextProp === "undefined") { + nextProp = null; } if (typeof attributeConfig !== "object") { // case: !Object is the default case - updatePayload[propKey] = _nextProp; + updatePayload[propKey] = nextProp; } else if ( typeof attributeConfig.diff === "function" || typeof attributeConfig.process === "function" @@ -3059,8 +3089,8 @@ function restoreDeletedValuesInNestedArray( // case: CustomAttributeConfiguration var nextValue = typeof attributeConfig.process === "function" - ? attributeConfig.process(_nextProp) - : _nextProp; + ? attributeConfig.process(nextProp) + : nextProp; updatePayload[propKey] = nextValue; } removedKeys[propKey] = false; @@ -3472,8 +3502,7 @@ function cancelDeferredCallback$1(callbackID) { // Use to restore controlled state after a change event has fired. -var fiberHostComponent = null; - +var restoreImpl = null; var restoreTarget = null; var restoreQueue = null; @@ -3486,17 +3515,12 @@ function restoreStateOfTarget(target) { return; } invariant( - fiberHostComponent && - typeof fiberHostComponent.restoreControlledState === "function", - "Fiber needs to be injected to handle a fiber target for controlled " + + typeof restoreImpl === "function", + "setRestoreImplementation() needs to be called to handle a target for controlled " + "events. This error is likely caused by a bug in React. Please file an issue." ); var props = getFiberCurrentPropsFromNode(internalInstance.stateNode); - fiberHostComponent.restoreControlledState( - internalInstance.stateNode, - internalInstance.type, - props - ); + restoreImpl(internalInstance.stateNode, internalInstance.type, props); } function needsStateRestore() { @@ -3527,13 +3551,10 @@ function restoreStateIfNeeded() { // scheduled work and instead do synchronous work. // Defaults -var _batchedUpdates = function(fn, bookkeeping) { +var _batchedUpdatesImpl = function(fn, bookkeeping) { return fn(bookkeeping); }; -var _interactiveUpdates = function(fn, a, b) { - return fn(a, b); -}; -var _flushInteractiveUpdates = function() {}; +var _flushInteractiveUpdatesImpl = function() {}; var isBatching = false; function batchedUpdates(fn, bookkeeping) { @@ -3544,7 +3565,7 @@ function batchedUpdates(fn, bookkeeping) { } isBatching = true; try { - return _batchedUpdates(fn, bookkeeping); + return _batchedUpdatesImpl(fn, bookkeeping); } finally { // Here we wait until all updates have propagated, which is important // when using controlled components within layers: @@ -3556,19 +3577,20 @@ function batchedUpdates(fn, bookkeeping) { // If a controlled event was fired, we may need to restore the state of // the DOM node back to the controlled value. This is necessary when React // bails out of the update without touching the DOM. - _flushInteractiveUpdates(); + _flushInteractiveUpdatesImpl(); restoreStateIfNeeded(); } } } -var injection$2 = { - injectRenderer: function(renderer) { - _batchedUpdates = renderer.batchedUpdates; - _interactiveUpdates = renderer.interactiveUpdates; - _flushInteractiveUpdates = renderer.flushInteractiveUpdates; - } -}; +function setBatchingImplementation( + batchedUpdatesImpl, + interactiveUpdatesImpl, + flushInteractiveUpdatesImpl +) { + _batchedUpdatesImpl = batchedUpdatesImpl; + _flushInteractiveUpdatesImpl = flushInteractiveUpdatesImpl; +} function dispatchEvent(target, topLevelType, nativeEvent) { var targetFiber = target; @@ -3651,6 +3673,10 @@ function _classCallCheck(instance, Constructor) { // This means that they never overlap. var nextReactTag = 2; +/* eslint-disable no-use-before-define */ + +/* eslint-enable no-use-before-define */ + // TODO: Remove this conditional once all changes have propagated. if (FabricUIManager.registerEventHandler) { /** @@ -3681,7 +3707,10 @@ var ReactFabricHostComponent = (function() { }; ReactFabricHostComponent.prototype.measure = function measure(callback) { - UIManager.measure(this._nativeTag, mountSafeCallback(this, callback)); + UIManager.measure( + this._nativeTag, + mountSafeCallback_NOT_REALLY_SAFE(this, callback) + ); }; ReactFabricHostComponent.prototype.measureInWindow = function measureInWindow( @@ -3689,7 +3718,7 @@ var ReactFabricHostComponent = (function() { ) { UIManager.measureInWindow( this._nativeTag, - mountSafeCallback(this, callback) + mountSafeCallback_NOT_REALLY_SAFE(this, callback) ); }; @@ -3701,8 +3730,8 @@ var ReactFabricHostComponent = (function() { UIManager.measureLayout( this._nativeTag, relativeToNativeNode, - mountSafeCallback(this, onFail), - mountSafeCallback(this, onSuccess) + mountSafeCallback_NOT_REALLY_SAFE(this, onFail), + mountSafeCallback_NOT_REALLY_SAFE(this, onSuccess) ); }; @@ -3907,26 +3936,18 @@ function cloneInstance( var clone = void 0; if (keepChildren) { if (updatePayload !== null) { - clone = FabricUIManager.cloneNodeWithNewProps( - node, - updatePayload, - internalInstanceHandle - ); + clone = FabricUIManager.cloneNodeWithNewProps(node, updatePayload); } else { - clone = FabricUIManager.cloneNode(node, internalInstanceHandle); + clone = FabricUIManager.cloneNode(node); } } else { if (updatePayload !== null) { clone = FabricUIManager.cloneNodeWithNewChildrenAndProps( node, - updatePayload, - internalInstanceHandle + updatePayload ); } else { - clone = FabricUIManager.cloneNodeWithNewChildren( - node, - internalInstanceHandle - ); + clone = FabricUIManager.cloneNodeWithNewChildren(node); } } return { @@ -3947,20 +3968,32 @@ function finalizeContainerChildren(container, newChildren) { FabricUIManager.completeRoot(container, newChildren); } +var BEFORE_SLASH_RE = /^(.*)[\\\/]/; + var describeComponentFrame = function(name, source, ownerName) { - return ( - "\n in " + - (name || "Unknown") + - (source - ? " (at " + - source.fileName.replace(/^.*[\\\/]/, "") + - ":" + - source.lineNumber + - ")" - : ownerName - ? " (created by " + ownerName + ")" - : "") - ); + var sourceInfo = ""; + if (source) { + var path = source.fileName; + var fileName = path.replace(BEFORE_SLASH_RE, ""); + { + // In DEV, include code for a common special case: + // prefer "folder/index.js" instead of just "index.js". + if (/^index\./.test(fileName)) { + var match = path.match(BEFORE_SLASH_RE); + if (match) { + var pathBeforeSlash = match[1]; + if (pathBeforeSlash) { + var folderName = pathBeforeSlash.replace(BEFORE_SLASH_RE, ""); + fileName = folderName + "/" + fileName; + } + } + } + } + sourceInfo = " (at " + fileName + ":" + source.lineNumber + ")"; + } else if (ownerName) { + sourceInfo = " (created by " + ownerName + ")"; + } + return "\n in " + (name || "Unknown") + sourceInfo; }; var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame; @@ -3969,7 +4002,9 @@ function describeFiber(fiber) { switch (fiber.tag) { case IndeterminateComponent: case FunctionalComponent: + case FunctionalComponentLazy: case ClassComponent: + case ClassComponentLazy: case HostComponent: case Mode: var owner = fiber._debugOwner; @@ -4054,6 +4089,7 @@ var warnAboutDeprecatedLifecycles = false; var warnAboutLegacyContextAPI = false; var replayFailedUnitOfWorkWithInvokeGuardedCallback = true; var enableProfilerTimer = true; +var enableSchedulerTracking = true; // Only used in www builds. @@ -4604,11 +4640,14 @@ var didPerformWorkStackCursor = createCursor(false); // pushed the next context provider, and now need to merge their contexts. var previousContext = emptyContextObject; -function getUnmaskedContext(workInProgress) { - var hasOwnContext = isContextProvider(workInProgress); - if (hasOwnContext) { +function getUnmaskedContext( + workInProgress, + Component, + didPushOwnContextIfProvider +) { + if (didPushOwnContextIfProvider && isContextProvider(Component)) { // If the fiber is a context provider itself, when we read its context - // we have already pushed its own child context on the stack. A context + // we may have already pushed its own child context on the stack. A context // provider should not "see" its own child context. Therefore we read the // previous (parent) context instead for a context provider. return previousContext; @@ -4669,19 +4708,12 @@ function hasContextChanged() { return didPerformWorkStackCursor.current; } -function isContextConsumer(fiber) { - return fiber.tag === ClassComponent && fiber.type.contextTypes != null; +function isContextProvider(type) { + var childContextTypes = type.childContextTypes; + return childContextTypes !== null && childContextTypes !== undefined; } -function isContextProvider(fiber) { - return fiber.tag === ClassComponent && fiber.type.childContextTypes != null; -} - -function popContextProvider(fiber) { - if (!isContextProvider(fiber)) { - return; - } - +function popContext(fiber) { pop(didPerformWorkStackCursor, fiber); pop(contextStackCursor, fiber); } @@ -4702,9 +4734,8 @@ function pushTopLevelContextObject(fiber, context, didChange) { push(didPerformWorkStackCursor, didChange, fiber); } -function processChildContext(fiber, parentContext) { +function processChildContext(fiber, type, parentContext) { var instance = fiber.stateNode; - var type = fiber.type; var childContextTypes = type.childContextTypes; // TODO (bvaughn) Replace this behavior with an invariant() in the future. @@ -4766,10 +4797,6 @@ function processChildContext(fiber, parentContext) { } function pushContextProvider(workInProgress) { - if (!isContextProvider(workInProgress)) { - return false; - } - var instance = workInProgress.stateNode; // We push the context as early as possible to ensure stack integrity. // If the instance does not exist yet, we will push null at first, @@ -4791,7 +4818,7 @@ function pushContextProvider(workInProgress) { return true; } -function invalidateContextProvider(workInProgress, didChange) { +function invalidateContextProvider(workInProgress, type, didChange) { var instance = workInProgress.stateNode; invariant( instance, @@ -4803,7 +4830,11 @@ function invalidateContextProvider(workInProgress, didChange) { // Merge parent and own context. // Skip this if we're not updating due to sCU. // This avoids unnecessarily recomputing memoized values. - var mergedContext = processChildContext(workInProgress, previousContext); + var mergedContext = processChildContext( + workInProgress, + type, + previousContext + ); instance.__reactInternalMemoizedMergedChildContext = mergedContext; // Replace the old (or empty) context with the new one. @@ -4823,25 +4854,39 @@ function findCurrentUnmaskedContext(fiber) { // Currently this is only used with renderSubtreeIntoContainer; not sure if it // makes sense elsewhere invariant( - isFiberMounted(fiber) && fiber.tag === ClassComponent, + isFiberMounted(fiber) && + (fiber.tag === ClassComponent || fiber.tag === ClassComponentLazy), "Expected subtree parent to be a mounted class component. " + "This error is likely caused by a bug in React. Please file an issue." ); var node = fiber; - while (node.tag !== HostRoot) { - if (isContextProvider(node)) { - return node.stateNode.__reactInternalMemoizedMergedChildContext; + do { + switch (node.tag) { + case HostRoot: + return node.stateNode.context; + case ClassComponent: { + var Component = node.type; + if (isContextProvider(Component)) { + return node.stateNode.__reactInternalMemoizedMergedChildContext; + } + break; + } + case ClassComponentLazy: { + var _Component = getResultFromResolvedThenable(node.type); + if (isContextProvider(_Component)) { + return node.stateNode.__reactInternalMemoizedMergedChildContext; + } + break; + } } - var parent = node.return; - invariant( - parent, - "Found unexpected detached subtree parent. " + - "This error is likely caused by a bug in React. Please file an issue." - ); - node = parent; - } - return node.stateNode.context; + node = node.return; + } while (node !== null); + invariant( + false, + "Found unexpected detached subtree parent. " + + "This error is likely caused by a bug in React. Please file an issue." + ); } var onCommitFiberRoot = null; @@ -5065,7 +5110,7 @@ function FiberNode(tag, pendingProps, key, mode) { if (enableProfilerTimer) { this.actualDuration = 0; - this.actualStartTime = 0; + this.actualStartTime = -1; this.selfBaseDuration = 0; this.treeBaseDuration = 0; } @@ -5100,7 +5145,23 @@ var createFiber = function(tag, pendingProps, key, mode) { }; function shouldConstruct(Component) { - return !!(Component.prototype && Component.prototype.isReactComponent); + var prototype = Component.prototype; + return !!(prototype && prototype.isReactComponent); +} + +function resolveLazyComponentTag(fiber, Component) { + if (typeof Component === "function") { + return shouldConstruct(Component) + ? ClassComponentLazy + : FunctionalComponentLazy; + } else if ( + Component !== undefined && + Component !== null && + Component.$$typeof + ) { + return ForwardRefLazy; + } + return IndeterminateComponent; } // This is used to create an alternate fiber to do work on. @@ -5148,7 +5209,7 @@ function createWorkInProgress(current, pendingProps, expirationTime) { // This has the downside of resetting values for different priority renders, // But works for yielding (the common case) and should support resuming. workInProgress.actualDuration = 0; - workInProgress.actualStartTime = 0; + workInProgress.actualStartTime = -1; } } @@ -5211,7 +5272,7 @@ function createFiberFromElement(element, mode, expirationTime) { } else if (typeof type === "string") { fiberTag = HostComponent; } else { - switch (type) { + getTag: switch (type) { case REACT_FRAGMENT_TYPE: return createFiberFromFragment( pendingProps.children, @@ -5232,9 +5293,54 @@ function createFiberFromElement(element, mode, expirationTime) { case REACT_PLACEHOLDER_TYPE: fiberTag = PlaceholderComponent; break; - default: - fiberTag = getFiberTagFromObjectType(type, owner); - break; + default: { + if (typeof type === "object" && type !== null) { + switch (type.$$typeof) { + case REACT_PROVIDER_TYPE: + fiberTag = ContextProvider; + break getTag; + case REACT_CONTEXT_TYPE: + // This is a consumer + fiberTag = ContextConsumer; + break getTag; + case REACT_FORWARD_REF_TYPE: + fiberTag = ForwardRef; + break getTag; + default: { + if (typeof type.then === "function") { + fiberTag = IndeterminateComponent; + break getTag; + } + } + } + } + var info = ""; + { + if ( + type === undefined || + (typeof type === "object" && + type !== null && + Object.keys(type).length === 0) + ) { + info += + " You likely forgot to export your component from the file " + + "it's defined in, or you might have mixed up default and " + + "named imports."; + } + var ownerName = owner ? getComponentName(owner.type) : null; + if (ownerName) { + info += "\n\nCheck the render method of `" + ownerName + "`."; + } + } + invariant( + false, + "Element type is invalid: expected a string (for built-in " + + "components) or a class/function (for composite components) " + + "but got: %s.%s", + type == null ? type : typeof type, + info + ); + } } } @@ -5250,49 +5356,6 @@ function createFiberFromElement(element, mode, expirationTime) { return fiber; } -function getFiberTagFromObjectType(type, owner) { - var $$typeof = - typeof type === "object" && type !== null ? type.$$typeof : null; - - switch ($$typeof) { - case REACT_PROVIDER_TYPE: - return ContextProvider; - case REACT_CONTEXT_TYPE: - // This is a consumer - return ContextConsumer; - case REACT_FORWARD_REF_TYPE: - return ForwardRef; - default: { - var info = ""; - { - if ( - type === undefined || - (typeof type === "object" && - type !== null && - Object.keys(type).length === 0) - ) { - info += - " You likely forgot to export your component from the file " + - "it's defined in, or you might have mixed up default and " + - "named imports."; - } - var ownerName = owner ? getComponentName(owner.type) : null; - if (ownerName) { - info += "\n\nCheck the render method of `" + ownerName + "`."; - } - } - invariant( - false, - "Element type is invalid: expected a string (for built-in " + - "components) or a class/function (for composite components) " + - "but got: %s.%s", - type == null ? type : typeof type, - info - ); - } - } -} - function createFiberFromFragment(elements, mode, expirationTime, key) { var fiber = createFiber(Fragment, elements, key, mode); fiber.expirationTime = expirationTime; @@ -5305,7 +5368,7 @@ function createFiberFromProfiler(pendingProps, mode, expirationTime, key) { typeof pendingProps.id !== "string" || typeof pendingProps.onRender !== "function" ) { - invariant( + warningWithoutStack$1( false, 'Profiler must specify an "id" string and "onRender" function as props' ); @@ -5392,37 +5455,90 @@ function assignFiberPropertiesInDEV(target, source) { return target; } +/* eslint-disable no-use-before-define */ // TODO: This should be lifted into the renderer. +// The following attributes are only used by interaction tracking builds. +// They enable interactions to be associated with their async work, +// And expose interaction metadata to the React DevTools Profiler plugin. +// Note that these attributes are only defined when the enableSchedulerTracking flag is enabled. + +// Exported FiberRoot type includes all properties, +// To avoid requiring potentially error-prone :any casts throughout the project. +// Profiling properties are only safe to access in profiling builds (when enableSchedulerTracking is true). +// The types are defined separately within this file to ensure they stay in sync. +// (We don't have to use an inline :any cast when enableSchedulerTracking is disabled.) + +/* eslint-enable no-use-before-define */ + function createFiberRoot(containerInfo, isAsync, hydrate) { // Cyclic construction. This cheats the type system right now because // stateNode is any. var uninitializedFiber = createHostRootFiber(isAsync); - var root = { - current: uninitializedFiber, - containerInfo: containerInfo, - pendingChildren: null, - earliestPendingTime: NoWork, - latestPendingTime: NoWork, - earliestSuspendedTime: NoWork, - latestSuspendedTime: NoWork, - latestPingedTime: NoWork, + var root = void 0; + if (enableSchedulerTracking) { + root = { + current: uninitializedFiber, + containerInfo: containerInfo, + pendingChildren: null, - didError: false, + earliestPendingTime: NoWork, + latestPendingTime: NoWork, + earliestSuspendedTime: NoWork, + latestSuspendedTime: NoWork, + latestPingedTime: NoWork, + + didError: false, + + pendingCommitExpirationTime: NoWork, + finishedWork: null, + timeoutHandle: noTimeout, + context: null, + pendingContext: null, + hydrate: hydrate, + nextExpirationTimeToWorkOn: NoWork, + expirationTime: NoWork, + firstBatch: null, + nextScheduledRoot: null, + + interactionThreadID: tracking.unstable_getThreadID(), + memoizedInteractions: new Set(), + pendingInteractionMap: new Map() + }; + } else { + root = { + current: uninitializedFiber, + containerInfo: containerInfo, + pendingChildren: null, + + earliestPendingTime: NoWork, + latestPendingTime: NoWork, + earliestSuspendedTime: NoWork, + latestSuspendedTime: NoWork, + latestPingedTime: NoWork, + + didError: false, + + pendingCommitExpirationTime: NoWork, + finishedWork: null, + timeoutHandle: noTimeout, + context: null, + pendingContext: null, + hydrate: hydrate, + nextExpirationTimeToWorkOn: NoWork, + expirationTime: NoWork, + firstBatch: null, + nextScheduledRoot: null + }; + } - pendingCommitExpirationTime: NoWork, - finishedWork: null, - timeoutHandle: noTimeout, - context: null, - pendingContext: null, - hydrate: hydrate, - nextExpirationTimeToWorkOn: NoWork, - expirationTime: NoWork, - firstBatch: null, - nextScheduledRoot: null - }; uninitializedFiber.stateNode = root; + + // The reason for the way the Flow types are structured in this file, + // Is to avoid needing :any casts everywhere interaction tracking fields are used. + // Unfortunately that requires an :any cast for non-interaction tracking capable builds. + // $FlowFixMe Remove this :any cast and replace it with something better. return root; } @@ -6044,6 +6160,14 @@ function findEarliestOutstandingPriorityLevel(root, renderExpirationTime) { return earliestExpirationTime; } +function didExpireAtExpirationTime(root, currentTime) { + var expirationTime = root.expirationTime; + if (expirationTime !== NoWork && currentTime >= expirationTime) { + // The root has expired. Flush all work up to the current time. + root.nextExpirationTimeToWorkOn = currentTime; + } +} + function findNextExpirationTimeToWorkOn(completedExpirationTime, root) { var earliestSuspendedTime = root.earliestSuspendedTime; var latestSuspendedTime = root.latestSuspendedTime; @@ -6055,7 +6179,7 @@ function findNextExpirationTimeToWorkOn(completedExpirationTime, root) { var nextExpirationTimeToWorkOn = earliestPendingTime !== NoWork ? earliestPendingTime : latestPingedTime; - // If there is no pending or pinted work, check if there's suspended work + // If there is no pending or pinged work, check if there's suspended work // that's lower priority than what we just completed. if ( nextExpirationTimeToWorkOn === NoWork && @@ -6297,7 +6421,7 @@ function enqueueUpdate(fiber, update) { { if ( - fiber.tag === ClassComponent && + (fiber.tag === ClassComponent || fiber.tag === ClassComponentLazy) && (currentlyProcessingQueue === queue1 || (queue2 !== null && currentlyProcessingQueue === queue2)) && !didWarnUpdateInsideUpdate @@ -6615,8 +6739,14 @@ function commitUpdateQueue( } // Commit the effects - var effect = finishedQueue.firstEffect; + commitUpdateEffects(finishedQueue.firstEffect, instance); finishedQueue.firstEffect = finishedQueue.lastEffect = null; + + commitUpdateEffects(finishedQueue.firstCapturedEffect, instance); + finishedQueue.firstCapturedEffect = finishedQueue.lastCapturedEffect = null; +} + +function commitUpdateEffects(effect, instance) { while (effect !== null) { var _callback3 = effect.callback; if (_callback3 !== null) { @@ -6625,17 +6755,6 @@ function commitUpdateQueue( } effect = effect.nextEffect; } - - effect = finishedQueue.firstCapturedEffect; - finishedQueue.firstCapturedEffect = finishedQueue.lastCapturedEffect = null; - while (effect !== null) { - var _callback4 = effect.callback; - if (_callback4 !== null) { - effect.callback = null; - callCallback(_callback4, instance); - } - effect = effect.nextEffect; - } } function createCapturedValue(value, source) { @@ -6648,8 +6767,44 @@ function createCapturedValue(value, source) { }; } +/** + * Similar to invariant but only logs a warning if the condition is not met. + * This can be used to log issues in development environments in critical + * paths. Removing the logging code for production environments will keep the + * same logic and follow the same code paths. + */ + +var warning = warningWithoutStack$1; + +{ + warning = function(condition, format) { + if (condition) { + return; + } + var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame; + var stack = ReactDebugCurrentFrame.getStackAddendum(); + // eslint-disable-next-line react-internal/warning-and-invariant-args + + for ( + var _len = arguments.length, + args = Array(_len > 2 ? _len - 2 : 0), + _key = 2; + _key < _len; + _key++ + ) { + args[_key - 2] = arguments[_key]; + } + + warningWithoutStack$1.apply( + undefined, + [false, format + "%s"].concat(args, [stack]) + ); + }; +} + +var warning$1 = warning; + var valueCursor = createCursor(null); -var changedBitsCursor = createCursor(0); var rendererSigil = void 0; { @@ -6669,15 +6824,13 @@ function resetContextDependences() { lastContextWithAllBitsObserved = null; } -function pushProvider(providerFiber) { +function pushProvider(providerFiber, nextValue) { var context = providerFiber.type._context; if (isPrimaryRenderer) { - push(changedBitsCursor, context._changedBits, providerFiber); push(valueCursor, context._currentValue, providerFiber); - context._currentValue = providerFiber.pendingProps.value; - context._changedBits = providerFiber.stateNode; + context._currentValue = nextValue; { !( context._currentRenderer === undefined || @@ -6693,11 +6846,9 @@ function pushProvider(providerFiber) { context._currentRenderer = rendererSigil; } } else { - push(changedBitsCursor, context._changedBits2, providerFiber); push(valueCursor, context._currentValue2, providerFiber); - context._currentValue2 = providerFiber.pendingProps.value; - context._changedBits2 = providerFiber.stateNode; + context._currentValue2 = nextValue; { !( context._currentRenderer2 === undefined || @@ -6716,19 +6867,46 @@ function pushProvider(providerFiber) { } function popProvider(providerFiber) { - var changedBits = changedBitsCursor.current; var currentValue = valueCursor.current; pop(valueCursor, providerFiber); - pop(changedBitsCursor, providerFiber); var context = providerFiber.type._context; if (isPrimaryRenderer) { context._currentValue = currentValue; - context._changedBits = changedBits; } else { context._currentValue2 = currentValue; - context._changedBits2 = changedBits; + } +} + +function calculateChangedBits(context, newValue, oldValue) { + // Use Object.is to compare the new context value to the old value. Inlined + // Object.is polyfill. + // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is + if ( + (oldValue === newValue && + (oldValue !== 0 || 1 / oldValue === 1 / newValue)) || + (oldValue !== oldValue && newValue !== newValue) // eslint-disable-line no-self-compare + ) { + // No change + return 0; + } else { + var changedBits = + typeof context._calculateChangedBits === "function" + ? context._calculateChangedBits(oldValue, newValue) + : maxSigned31BitInt; + + { + !((changedBits & maxSigned31BitInt) === changedBits) + ? warning$1( + false, + "calculateChangedBits: Expected the return value to be a " + + "31-bit integer. Instead received: %s", + changedBits + ) + : void 0; + } + return changedBits | 0; } } @@ -6756,6 +6934,21 @@ function propagateContextChange( (dependency.observedBits & changedBits) !== 0 ) { // Match! Schedule an update on this fiber. + + if ( + fiber.tag === ClassComponent || + fiber.tag === ClassComponentLazy + ) { + // Schedule a force update on the work-in-progress. + var update = createUpdate(renderExpirationTime); + update.tag = ForceUpdate; + // TODO: Because we don't have a work-in-progress, this will add the + // update to the current fiber, too, which means it will persist even if + // this render is thrown away. Since it's a race condition, not sure it's + // worth fixing. + enqueueUpdate(fiber, update); + } + if ( fiber.expirationTime === NoWork || fiber.expirationTime > renderExpirationTime @@ -6800,13 +6993,8 @@ function propagateContextChange( } node = node.return; } - // Don't scan deeper than a matching consumer. When we render the - // consumer, we'll continue scanning from that point. This way the - // scanning work is time-sliced. - nextFiber = null; - } else { - nextFiber = fiber.child; } + nextFiber = fiber.child; dependency = dependency.next; } while (dependency !== null); } else if (fiber.tag === ContextProvider) { @@ -6849,41 +7037,8 @@ function prepareToReadContext(workInProgress, renderExpirationTime) { lastContextDependency = null; lastContextWithAllBitsObserved = null; - var firstContextDependency = workInProgress.firstContextDependency; - if (firstContextDependency !== null) { - // Reset the work-in-progress list - workInProgress.firstContextDependency = null; - - // Iterate through the context dependencies and see if there were any - // changes. If so, continue propagating the context change by scanning - // the child subtree. - var dependency = firstContextDependency; - var hasPendingContext = false; - do { - var _context = dependency.context; - var changedBits = isPrimaryRenderer - ? _context._changedBits - : _context._changedBits2; - if (changedBits !== 0) { - // Resume context change propagation. We need to call this even if - // this fiber bails out, in case deeply nested consumers observe more - // bits than this one. - propagateContextChange( - workInProgress, - _context, - changedBits, - renderExpirationTime - ); - if ((changedBits & dependency.observedBits) !== 0) { - hasPendingContext = true; - } - } - dependency = dependency.next; - } while (dependency !== null); - return hasPendingContext; - } else { - return false; - } + // Reset the work-in-progress list + workInProgress.firstContextDependency = null; } function readContext(context, observedBits) { @@ -7005,6 +7160,7 @@ function popHostContext(fiber) { } var commitTime = 0; +var profilerStartTime = -1; function getCommitTime() { return commitTime; @@ -7017,184 +7173,40 @@ function recordCommitTime() { commitTime = now(); } -/** - * The "actual" render time is total time required to render the descendants of a Profiler component. - * This time is stored as a stack, since Profilers can be nested. - * This time is started during the "begin" phase and stopped during the "complete" phase. - * It is paused (and accumulated) in the event of an interruption or an aborted render. - */ - -var fiberStack$1 = void 0; - -{ - fiberStack$1 = []; -} - -var syncCommitStartTime = 0; -var timerPausedAt = 0; -var totalElapsedPauseTime = 0; - -function checkActualRenderTimeStackEmpty() { +function startProfilerTimer(fiber) { if (!enableProfilerTimer) { return; } - { - !(fiberStack$1.length === 0) - ? warningWithoutStack$1( - false, - "Expected an empty stack. Something was not reset properly." - ) - : void 0; + + profilerStartTime = now(); + + if (fiber.actualStartTime < 0) { + fiber.actualStartTime = now(); } } -function markActualRenderTimeStarted(fiber) { +function stopProfilerTimerIfRunning(fiber) { if (!enableProfilerTimer) { return; } - { - fiberStack$1.push(fiber); - } - - fiber.actualDuration = now() - fiber.actualDuration - totalElapsedPauseTime; - fiber.actualStartTime = now(); + profilerStartTime = -1; } -function pauseActualRenderTimerIfRunning() { +function stopProfilerTimerIfRunningAndRecordDelta(fiber, overrideBaseTime) { if (!enableProfilerTimer) { return; } - if (timerPausedAt === 0) { - timerPausedAt = now(); - } - if (syncCommitStartTime > 0) { - // Don't count the time spent processing sycn work, - // Against yielded async work that will be resumed later. - totalElapsedPauseTime += now() - syncCommitStartTime; - syncCommitStartTime = 0; - } else { - totalElapsedPauseTime = 0; - } -} -function recordElapsedActualRenderTime(fiber) { - if (!enableProfilerTimer) { - return; - } - { - !(fiber === fiberStack$1.pop()) - ? warningWithoutStack$1( - false, - "Unexpected Fiber (%s) popped.", - getComponentName(fiber.type) - ) - : void 0; - } - - fiber.actualDuration = now() - totalElapsedPauseTime - fiber.actualDuration; -} - -function resumeActualRenderTimerIfPaused(isProcessingSyncWork) { - if (!enableProfilerTimer) { - return; - } - if (isProcessingSyncWork && syncCommitStartTime === 0) { - syncCommitStartTime = now(); - } - if (timerPausedAt > 0) { - totalElapsedPauseTime += now() - timerPausedAt; - timerPausedAt = 0; - } -} - -function resetActualRenderTimerStackAfterFatalErrorInDev() { - if (!enableProfilerTimer) { - return; - } - { - fiberStack$1.length = 0; - } -} - -/** - * The "base" render time is the duration of the “begin” phase of work for a particular fiber. - * This time is measured and stored on each fiber. - * The time for all sibling fibers are accumulated and stored on their parent during the "complete" phase. - * If a fiber bails out (sCU false) then its "base" timer is cancelled and the fiber is not updated. - */ - -var baseStartTime = -1; - -function recordElapsedBaseRenderTimeIfRunning(fiber) { - if (!enableProfilerTimer) { - return; - } - if (baseStartTime !== -1) { - fiber.selfBaseDuration = now() - baseStartTime; - } -} - -function startBaseRenderTimer() { - if (!enableProfilerTimer) { - return; - } - { - if (baseStartTime !== -1) { - warningWithoutStack$1( - false, - "Cannot start base timer that is already running. " + - "This error is likely caused by a bug in React. " + - "Please file an issue." - ); + if (profilerStartTime >= 0) { + var elapsedTime = now() - profilerStartTime; + fiber.actualDuration += elapsedTime; + if (overrideBaseTime) { + fiber.selfBaseDuration = elapsedTime; } + profilerStartTime = -1; } - baseStartTime = now(); } -function stopBaseRenderTimerIfRunning() { - if (!enableProfilerTimer) { - return; - } - baseStartTime = -1; -} - -/** - * Similar to invariant but only logs a warning if the condition is not met. - * This can be used to log issues in development environments in critical - * paths. Removing the logging code for production environments will keep the - * same logic and follow the same code paths. - */ - -var warning = warningWithoutStack$1; - -{ - warning = function(condition, format) { - if (condition) { - return; - } - var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame; - var stack = ReactDebugCurrentFrame.getStackAddendum(); - // eslint-disable-next-line react-internal/warning-and-invariant-args - - for ( - var _len = arguments.length, - args = Array(_len > 2 ? _len - 2 : 0), - _key = 2; - _key < _len; - _key++ - ) { - args[_key - 2] = arguments[_key]; - } - - warningWithoutStack$1.apply( - undefined, - [false, format + "%s"].concat(args, [stack]) - ); - }; -} - -var warning$1 = warning; - /*eslint-disable no-self-compare */ var hasOwnProperty = Object.prototype.hasOwnProperty; @@ -7269,12 +7281,14 @@ var didWarnAboutLegacyLifecyclesAndDerivedState = void 0; var didWarnAboutUndefinedDerivedState = void 0; var warnOnUndefinedDerivedState = void 0; var warnOnInvalidCallback = void 0; +var didWarnAboutDirectlyAssigningPropsToState = void 0; { didWarnAboutStateAssignmentForComponent = new Set(); didWarnAboutUninitializedState = new Set(); didWarnAboutGetSnapshotBeforeUpdateWithoutDidUpdate = new Set(); didWarnAboutLegacyLifecyclesAndDerivedState = new Set(); + didWarnAboutDirectlyAssigningPropsToState = new Set(); didWarnAboutUndefinedDerivedState = new Set(); var didWarnOnInvalidCallback = new Set(); @@ -7335,6 +7349,7 @@ var warnOnInvalidCallback = void 0; function applyDerivedStateFromProps( workInProgress, + ctor, getDerivedStateFromProps, nextProps ) { @@ -7354,7 +7369,7 @@ function applyDerivedStateFromProps( var partialState = getDerivedStateFromProps(nextProps, prevState); { - warnOnUndefinedDerivedState(workInProgress.type, partialState); + warnOnUndefinedDerivedState(ctor, partialState); } // Merge the partial state and the previous state. var memoizedState = @@ -7431,6 +7446,7 @@ var classComponentUpdater = { function checkShouldComponentUpdate( workInProgress, + ctor, oldProps, newProps, oldState, @@ -7438,7 +7454,6 @@ function checkShouldComponentUpdate( nextLegacyContext ) { var instance = workInProgress.stateNode; - var ctor = workInProgress.type; if (typeof instance.shouldComponentUpdate === "function") { startPhaseTimer(workInProgress, "shouldComponentUpdate"); var shouldUpdate = instance.shouldComponentUpdate( @@ -7471,15 +7486,14 @@ function checkShouldComponentUpdate( return true; } -function checkClassInstance(workInProgress) { +function checkClassInstance(workInProgress, ctor, newProps) { var instance = workInProgress.stateNode; - var type = workInProgress.type; { - var name = getComponentName(type) || "Component"; + var name = getComponentName(ctor) || "Component"; var renderPresent = instance.render; if (!renderPresent) { - if (type.prototype && typeof type.prototype.render === "function") { + if (ctor.prototype && typeof ctor.prototype.render === "function") { warningWithoutStack$1( false, "%s(...): No `render` method found on the returned component " + @@ -7552,8 +7566,8 @@ function checkClassInstance(workInProgress) { ) : void 0; if ( - type.prototype && - type.prototype.isPureReactComponent && + ctor.prototype && + ctor.prototype.isPureReactComponent && typeof instance.shouldComponentUpdate !== "undefined" ) { warningWithoutStack$1( @@ -7561,7 +7575,7 @@ function checkClassInstance(workInProgress) { "%s has a method called shouldComponentUpdate(). " + "shouldComponentUpdate should not be used when extending React.PureComponent. " + "Please extend React.Component if shouldComponentUpdate is used.", - getComponentName(type) || "A pure component" + getComponentName(ctor) || "A pure component" ); } var noComponentDidUnmount = @@ -7608,7 +7622,7 @@ function checkClassInstance(workInProgress) { name ) : void 0; - var hasMutatedProps = instance.props !== workInProgress.pendingProps; + var hasMutatedProps = instance.props !== newProps; !(instance.props === undefined || !hasMutatedProps) ? warningWithoutStack$1( false, @@ -7632,14 +7646,14 @@ function checkClassInstance(workInProgress) { if ( typeof instance.getSnapshotBeforeUpdate === "function" && typeof instance.componentDidUpdate !== "function" && - !didWarnAboutGetSnapshotBeforeUpdateWithoutDidUpdate.has(type) + !didWarnAboutGetSnapshotBeforeUpdateWithoutDidUpdate.has(ctor) ) { - didWarnAboutGetSnapshotBeforeUpdateWithoutDidUpdate.add(type); + didWarnAboutGetSnapshotBeforeUpdateWithoutDidUpdate.add(ctor); warningWithoutStack$1( false, "%s: getSnapshotBeforeUpdate() should be used with componentDidUpdate(). " + "This component defines getSnapshotBeforeUpdate() only.", - getComponentName(type) + getComponentName(ctor) ); } @@ -7664,7 +7678,7 @@ function checkClassInstance(workInProgress) { ) : void 0; var noStaticGetSnapshotBeforeUpdate = - typeof type.getSnapshotBeforeUpdate !== "function"; + typeof ctor.getSnapshotBeforeUpdate !== "function"; !noStaticGetSnapshotBeforeUpdate ? warningWithoutStack$1( false, @@ -7682,7 +7696,7 @@ function checkClassInstance(workInProgress) { ); } if (typeof instance.getChildContext === "function") { - !(typeof type.childContextTypes === "object") + !(typeof ctor.childContextTypes === "object") ? warningWithoutStack$1( false, "%s.getChildContext(): childContextTypes must be defined in order to " + @@ -7704,11 +7718,16 @@ function adoptClassInstance(workInProgress, instance) { } } -function constructClassInstance(workInProgress, props, renderExpirationTime) { - var ctor = workInProgress.type; - var unmaskedContext = getUnmaskedContext(workInProgress); - var needsContext = isContextConsumer(workInProgress); - var context = needsContext +function constructClassInstance( + workInProgress, + ctor, + props, + renderExpirationTime +) { + var unmaskedContext = getUnmaskedContext(workInProgress, ctor, true); + var contextTypes = ctor.contextTypes; + var isContextConsumer = contextTypes !== null && contextTypes !== undefined; + var context = isContextConsumer ? getMaskedContext(workInProgress, unmaskedContext) : emptyContextObject; @@ -7737,10 +7756,13 @@ function constructClassInstance(workInProgress, props, renderExpirationTime) { didWarnAboutUninitializedState.add(componentName); warningWithoutStack$1( false, - "%s: Did not properly initialize state during construction. " + - "Expected state to be an object, but it was %s.", + "`%s` uses `getDerivedStateFromProps` but its initial state is " + + "%s. This is not recommended. Instead, define the initial state by " + + "assigning an object to `this.state` in the constructor of `%s`. " + + "This ensures that `getDerivedStateFromProps` arguments have a consistent shape.", componentName, - instance.state === null ? "null" : "undefined" + instance.state === null ? "null" : "undefined", + componentName ); } } @@ -7814,7 +7836,7 @@ function constructClassInstance(workInProgress, props, renderExpirationTime) { // Cache unmasked context so we can avoid recreating masked context unless necessary. // ReactFiberContext usually updates this cache but can't for newly-created instances. - if (needsContext) { + if (isContextConsumer) { cacheContext(workInProgress, unmaskedContext, context); } @@ -7883,23 +7905,39 @@ function callComponentWillReceiveProps( } // Invokes the mount life-cycles on a previously never rendered instance. -function mountClassInstance(workInProgress, renderExpirationTime) { - var ctor = workInProgress.type; - +function mountClassInstance( + workInProgress, + ctor, + newProps, + renderExpirationTime +) { { - checkClassInstance(workInProgress); + checkClassInstance(workInProgress, ctor, newProps); } var instance = workInProgress.stateNode; - var props = workInProgress.pendingProps; - var unmaskedContext = getUnmaskedContext(workInProgress); + var unmaskedContext = getUnmaskedContext(workInProgress, ctor, true); - instance.props = props; + instance.props = newProps; instance.state = workInProgress.memoizedState; instance.refs = emptyRefsObject; instance.context = getMaskedContext(workInProgress, unmaskedContext); { + if (instance.state === newProps) { + var componentName = getComponentName(ctor) || "Component"; + if (!didWarnAboutDirectlyAssigningPropsToState.has(componentName)) { + didWarnAboutDirectlyAssigningPropsToState.add(componentName); + warningWithoutStack$1( + false, + "%s: It is not recommended to assign props directly to state " + + "because updates to props won't be reflected in state. " + + "In most cases, it is better to use props directly.", + componentName + ); + } + } + if (workInProgress.mode & StrictMode) { ReactStrictModeWarnings.recordUnsafeLifecycleWarnings( workInProgress, @@ -7925,7 +7963,7 @@ function mountClassInstance(workInProgress, renderExpirationTime) { processUpdateQueue( workInProgress, updateQueue, - props, + newProps, instance, renderExpirationTime ); @@ -7934,7 +7972,12 @@ function mountClassInstance(workInProgress, renderExpirationTime) { var getDerivedStateFromProps = ctor.getDerivedStateFromProps; if (typeof getDerivedStateFromProps === "function") { - applyDerivedStateFromProps(workInProgress, getDerivedStateFromProps, props); + applyDerivedStateFromProps( + workInProgress, + ctor, + getDerivedStateFromProps, + newProps + ); instance.state = workInProgress.memoizedState; } @@ -7954,7 +7997,7 @@ function mountClassInstance(workInProgress, renderExpirationTime) { processUpdateQueue( workInProgress, updateQueue, - props, + newProps, instance, renderExpirationTime ); @@ -7969,18 +8012,21 @@ function mountClassInstance(workInProgress, renderExpirationTime) { function resumeMountClassInstance( workInProgress, - hasPendingNewContext, + ctor, + newProps, renderExpirationTime ) { - var ctor = workInProgress.type; var instance = workInProgress.stateNode; var oldProps = workInProgress.memoizedProps; - var newProps = workInProgress.pendingProps; instance.props = oldProps; var oldContext = instance.context; - var nextLegacyUnmaskedContext = getUnmaskedContext(workInProgress); + var nextLegacyUnmaskedContext = getUnmaskedContext( + workInProgress, + ctor, + true + ); var nextLegacyContext = getMaskedContext( workInProgress, nextLegacyUnmaskedContext @@ -8031,7 +8077,6 @@ function resumeMountClassInstance( oldProps === newProps && oldState === newState && !hasContextChanged() && - !hasPendingNewContext && !checkHasForceUpdateAfterProcessing() ) { // If an update was already in progress, we should schedule an Update @@ -8045,6 +8090,7 @@ function resumeMountClassInstance( if (typeof getDerivedStateFromProps === "function") { applyDerivedStateFromProps( workInProgress, + ctor, getDerivedStateFromProps, newProps ); @@ -8053,9 +8099,9 @@ function resumeMountClassInstance( var shouldUpdate = checkHasForceUpdateAfterProcessing() || - hasPendingNewContext || checkShouldComponentUpdate( workInProgress, + ctor, oldProps, newProps, oldState, @@ -8109,18 +8155,21 @@ function resumeMountClassInstance( function updateClassInstance( current, workInProgress, - hasPendingNewContext, + ctor, + newProps, renderExpirationTime ) { - var ctor = workInProgress.type; var instance = workInProgress.stateNode; var oldProps = workInProgress.memoizedProps; - var newProps = workInProgress.pendingProps; instance.props = oldProps; var oldContext = instance.context; - var nextLegacyUnmaskedContext = getUnmaskedContext(workInProgress); + var nextLegacyUnmaskedContext = getUnmaskedContext( + workInProgress, + ctor, + true + ); var nextLegacyContext = getMaskedContext( workInProgress, nextLegacyUnmaskedContext @@ -8172,7 +8221,6 @@ function updateClassInstance( oldProps === newProps && oldState === newState && !hasContextChanged() && - !hasPendingNewContext && !checkHasForceUpdateAfterProcessing() ) { // If an update was already in progress, we should schedule an Update @@ -8199,6 +8247,7 @@ function updateClassInstance( if (typeof getDerivedStateFromProps === "function") { applyDerivedStateFromProps( workInProgress, + ctor, getDerivedStateFromProps, newProps ); @@ -8207,9 +8256,9 @@ function updateClassInstance( var shouldUpdate = checkHasForceUpdateAfterProcessing() || - hasPendingNewContext || checkShouldComponentUpdate( workInProgress, + ctor, oldProps, newProps, oldState, @@ -8280,6 +8329,7 @@ function updateClassInstance( } var didWarnAboutMaps = void 0; +var didWarnAboutGenerators = void 0; var didWarnAboutStringRefInStrictMode = void 0; var ownerHasKeyUseWarning = void 0; var ownerHasFunctionTypeWarning = void 0; @@ -8287,6 +8337,7 @@ var warnForMissingKey = function(child) {}; { didWarnAboutMaps = false; + didWarnAboutGenerators = false; didWarnAboutStringRefInStrictMode = {}; /** @@ -8345,7 +8396,7 @@ function coerceRef(returnFiber, current$$1, element) { if (!didWarnAboutStringRefInStrictMode[componentName]) { warningWithoutStack$1( false, - 'A string ref, "%s", has been found within a strict mode tree. ' + + 'A string ref, "%s", has been found within a strict mode tree. ' + "String refs are a source of potential bugs and should be avoided. " + "We recommend using createRef() instead." + "\n%s" + @@ -8365,7 +8416,8 @@ function coerceRef(returnFiber, current$$1, element) { if (owner) { var ownerFiber = owner; invariant( - ownerFiber.tag === ClassComponent, + ownerFiber.tag === ClassComponent || + ownerFiber.tag === ClassComponentLazy, "Stateless function components cannot have refs." ); inst = ownerFiber.stateNode; @@ -8403,7 +8455,7 @@ function coerceRef(returnFiber, current$$1, element) { } else { invariant( typeof mixedRef === "string", - "Expected ref to be a function or a string." + "Expected ref to be a function, a string, an object returned by React.createRef(), or null." ); invariant( element._owner, @@ -9102,6 +9154,26 @@ function ChildReconciler(shouldTrackSideEffects) { ); { + // We don't support rendering Generators because it's a mutation. + // See https://github.com/facebook/react/issues/12995 + if ( + typeof Symbol === "function" && + // $FlowFixMe Flow doesn't know about toStringTag + newChildrenIterable[Symbol.toStringTag] === "Generator" + ) { + !didWarnAboutGenerators + ? warning$1( + false, + "Using Generators as children is unsupported and will likely yield " + + "unexpected results because enumerating a generator mutates it. " + + "You may convert it to an array with `Array.from()` or the " + + "`[...spread]` operator before rendering. Keep in mind " + + "you might need to polyfill these features for older browsers." + ) + : void 0; + didWarnAboutGenerators = true; + } + // Warn about using Maps as children if (newChildrenIterable.entries === iteratorFn) { !didWarnAboutMaps @@ -9486,7 +9558,8 @@ function ChildReconciler(shouldTrackSideEffects) { // component, throw an error. If Fiber return types are disabled, // we already threw above. switch (returnFiber.tag) { - case ClassComponent: { + case ClassComponent: + case ClassComponentLazy: { { var instance = returnFiber.stateNode; if (instance.render._isMockFunction) { @@ -9869,6 +9942,49 @@ function resetHydrationState() { isHydrating = false; } +function readLazyComponentType(thenable) { + var status = thenable._reactStatus; + switch (status) { + case Resolved: + var Component = thenable._reactResult; + return Component; + case Rejected: + throw thenable._reactResult; + case Pending: + throw thenable; + default: { + thenable._reactStatus = Pending; + thenable.then( + function(resolvedValue) { + if (thenable._reactStatus === Pending) { + thenable._reactStatus = Resolved; + if (typeof resolvedValue === "object" && resolvedValue !== null) { + // If the `default` property is not empty, assume it's the result + // of an async import() and use that. Otherwise, use the + // resolved value itself. + var defaultExport = resolvedValue.default; + resolvedValue = + defaultExport !== undefined && defaultExport !== null + ? defaultExport + : resolvedValue; + } else { + resolvedValue = resolvedValue; + } + thenable._reactResult = resolvedValue; + } + }, + function(error) { + if (thenable._reactStatus === Pending) { + thenable._reactStatus = Rejected; + thenable._reactResult = error; + } + } + ); + throw thenable; + } + } +} + var ReactCurrentOwner$3 = ReactSharedInternals.ReactCurrentOwner; var didWarnAboutBadClass = void 0; @@ -9914,9 +10030,14 @@ function reconcileChildren( } } -function updateForwardRef(current$$1, workInProgress, renderExpirationTime) { - var render = workInProgress.type.render; - var nextProps = workInProgress.pendingProps; +function updateForwardRef( + current$$1, + workInProgress, + type, + nextProps, + renderExpirationTime +) { + var render = type.render; var ref = workInProgress.ref; if (hasContextChanged()) { // Normally we can bail out on props equality but if context has changed @@ -10004,11 +10125,11 @@ function markRef(current$$1, workInProgress) { function updateFunctionalComponent( current$$1, workInProgress, + Component, + nextProps, renderExpirationTime ) { - var fn = workInProgress.type; - var nextProps = workInProgress.pendingProps; - var unmaskedContext = getUnmaskedContext(workInProgress); + var unmaskedContext = getUnmaskedContext(workInProgress, Component, true); var context = getMaskedContext(workInProgress, unmaskedContext); var nextChildren = void 0; @@ -10016,7 +10137,7 @@ function updateFunctionalComponent( { ReactCurrentOwner$3.current = workInProgress; setCurrentPhase("render"); - nextChildren = fn(nextProps, context); + nextChildren = Component(nextProps, context); setCurrentPhase(null); } @@ -10035,16 +10156,21 @@ function updateFunctionalComponent( function updateClassComponent( current$$1, workInProgress, + Component, + nextProps, renderExpirationTime ) { // Push context providers early to prevent context stack mismatches. // During mounting we don't know the child context yet as the instance doesn't exist. // We will invalidate the child context in finishClassComponent() right after rendering. - var hasContext = pushContextProvider(workInProgress); - var hasPendingNewContext = prepareToReadContext( - workInProgress, - renderExpirationTime - ); + var hasContext = void 0; + if (isContextProvider(Component)) { + hasContext = true; + pushContextProvider(workInProgress); + } else { + hasContext = false; + } + prepareToReadContext(workInProgress, renderExpirationTime); var shouldUpdate = void 0; if (current$$1 === null) { @@ -10052,17 +10178,23 @@ function updateClassComponent( // In the initial pass we might need to construct the instance. constructClassInstance( workInProgress, - workInProgress.pendingProps, + Component, + nextProps, + renderExpirationTime + ); + mountClassInstance( + workInProgress, + Component, + nextProps, renderExpirationTime ); - mountClassInstance(workInProgress, renderExpirationTime); - shouldUpdate = true; } else { // In a resume, we'll already have an instance we can reuse. shouldUpdate = resumeMountClassInstance( workInProgress, - hasPendingNewContext, + Component, + nextProps, renderExpirationTime ); } @@ -10070,13 +10202,15 @@ function updateClassComponent( shouldUpdate = updateClassInstance( current$$1, workInProgress, - hasPendingNewContext, + Component, + nextProps, renderExpirationTime ); } return finishClassComponent( current$$1, workInProgress, + Component, shouldUpdate, hasContext, renderExpirationTime @@ -10086,6 +10220,7 @@ function updateClassComponent( function finishClassComponent( current$$1, workInProgress, + Component, shouldUpdate, hasContext, renderExpirationTime @@ -10098,7 +10233,7 @@ function finishClassComponent( if (!shouldUpdate && !didCaptureError) { // Context providers should defer to sCU for rendering if (hasContext) { - invalidateContextProvider(workInProgress, false); + invalidateContextProvider(workInProgress, Component, false); } return bailoutOnAlreadyFinishedWork( @@ -10108,7 +10243,6 @@ function finishClassComponent( ); } - var ctor = workInProgress.type; var instance = workInProgress.stateNode; // Rerender @@ -10117,7 +10251,7 @@ function finishClassComponent( if ( didCaptureError && (!enableGetDerivedStateFromCatch || - typeof ctor.getDerivedStateFromCatch !== "function") + typeof Component.getDerivedStateFromCatch !== "function") ) { // If we captured an error, but getDerivedStateFrom catch is not defined, // unmount all the children. componentDidCatch will schedule an update to @@ -10127,7 +10261,7 @@ function finishClassComponent( nextChildren = null; if (enableProfilerTimer) { - stopBaseRenderTimerIfRunning(); + stopProfilerTimerIfRunning(workInProgress); } } else { { @@ -10168,7 +10302,7 @@ function finishClassComponent( // The context might have changed so we need to recalculate it. if (hasContext) { - invalidateContextProvider(workInProgress, true); + invalidateContextProvider(workInProgress, Component, true); } return workInProgress.child; @@ -10323,9 +10457,25 @@ function updateHostText(current$$1, workInProgress) { return null; } +function resolveDefaultProps(Component, baseProps) { + if (Component && Component.defaultProps) { + // Resolve default props. Taken from ReactElement + var props = Object.assign({}, baseProps); + var defaultProps = Component.defaultProps; + for (var propName in defaultProps) { + if (props[propName] === undefined) { + props[propName] = defaultProps[propName]; + } + } + return props; + } + return baseProps; +} + function mountIndeterminateComponent( current$$1, workInProgress, + Component, renderExpirationTime ) { invariant( @@ -10333,9 +10483,61 @@ function mountIndeterminateComponent( "An indeterminate component should never have mounted. This error is " + "likely caused by a bug in React. Please file an issue." ); - var fn = workInProgress.type; + var props = workInProgress.pendingProps; - var unmaskedContext = getUnmaskedContext(workInProgress); + if ( + typeof Component === "object" && + Component !== null && + typeof Component.then === "function" + ) { + Component = readLazyComponentType(Component); + var resolvedTag = (workInProgress.tag = resolveLazyComponentTag( + workInProgress, + Component + )); + var resolvedProps = resolveDefaultProps(Component, props); + switch (resolvedTag) { + case FunctionalComponentLazy: { + return updateFunctionalComponent( + current$$1, + workInProgress, + Component, + resolvedProps, + renderExpirationTime + ); + } + case ClassComponentLazy: { + return updateClassComponent( + current$$1, + workInProgress, + Component, + resolvedProps, + renderExpirationTime + ); + } + case ForwardRefLazy: { + return updateForwardRef( + current$$1, + workInProgress, + Component, + resolvedProps, + renderExpirationTime + ); + } + default: { + // This message intentionally doesn't metion ForwardRef because the + // fact that it's a separate type of work is an implementation detail. + invariant( + false, + "Element type is invalid. Received a promise that resolves to: %s. " + + "Promise elements must resolve to a class or function.", + Component + ); + } + } + } + + var unmaskedContext = getUnmaskedContext(workInProgress, Component, false); var context = getMaskedContext(workInProgress, unmaskedContext); prepareToReadContext(workInProgress, renderExpirationTime); @@ -10343,8 +10545,11 @@ function mountIndeterminateComponent( var value = void 0; { - if (fn.prototype && typeof fn.prototype.render === "function") { - var componentName = getComponentName(fn) || "Unknown"; + if ( + Component.prototype && + typeof Component.prototype.render === "function" + ) { + var componentName = getComponentName(Component) || "Unknown"; if (!didWarnAboutBadClass[componentName]) { warningWithoutStack$1( @@ -10363,7 +10568,7 @@ function mountIndeterminateComponent( } ReactCurrentOwner$3.current = workInProgress; - value = fn(props, context); + value = Component(props, context); } // React DevTools reads this flag. workInProgress.effectTag |= PerformedWork; @@ -10374,15 +10579,19 @@ function mountIndeterminateComponent( typeof value.render === "function" && value.$$typeof === undefined ) { - var Component = workInProgress.type; - // Proceed under the assumption that this is a class instance workInProgress.tag = ClassComponent; // Push context providers early to prevent context stack mismatches. // During mounting we don't know the child context yet as the instance doesn't exist. // We will invalidate the child context in finishClassComponent() right after rendering. - var hasContext = pushContextProvider(workInProgress); + var hasContext = false; + if (isContextProvider(Component)) { + hasContext = true; + pushContextProvider(workInProgress); + } else { + hasContext = false; + } workInProgress.memoizedState = value.state !== null && value.state !== undefined ? value.state : null; @@ -10391,16 +10600,18 @@ function mountIndeterminateComponent( if (typeof getDerivedStateFromProps === "function") { applyDerivedStateFromProps( workInProgress, + Component, getDerivedStateFromProps, props ); } adoptClassInstance(workInProgress, value); - mountClassInstance(workInProgress, renderExpirationTime); + mountClassInstance(workInProgress, Component, props, renderExpirationTime); return finishClassComponent( current$$1, workInProgress, + Component, true, hasContext, renderExpirationTime @@ -10409,14 +10620,12 @@ function mountIndeterminateComponent( // Proceed under the assumption that this is a functional component workInProgress.tag = FunctionalComponent; { - var _Component = workInProgress.type; - - if (_Component) { - !!_Component.childContextTypes + if (Component) { + !!Component.childContextTypes ? warningWithoutStack$1( false, "%s(...): childContextTypes cannot be defined on a functional component.", - _Component.displayName || _Component.name || "Component" + Component.displayName || Component.name || "Component" ) : void 0; } @@ -10443,8 +10652,8 @@ function mountIndeterminateComponent( } } - if (typeof fn.getDerivedStateFromProps === "function") { - var _componentName = getComponentName(fn) || "Unknown"; + if (typeof Component.getDerivedStateFromProps === "function") { + var _componentName = getComponentName(Component) || "Unknown"; if (!didWarnAboutGetDerivedStateOnFunctionalComponent[_componentName]) { warningWithoutStack$1( @@ -10589,87 +10798,32 @@ function updateContextProvider( } } - var changedBits = void 0; - if (oldProps === null) { - // Initial render - changedBits = maxSigned31BitInt; - } else { - if (oldProps.value === newProps.value) { + pushProvider(workInProgress, newValue); + + if (oldProps !== null) { + var oldValue = oldProps.value; + var changedBits = calculateChangedBits(context, newValue, oldValue); + if (changedBits === 0) { // No change. Bailout early if children are the same. if (oldProps.children === newProps.children && !hasContextChanged()) { - workInProgress.stateNode = 0; - pushProvider(workInProgress); return bailoutOnAlreadyFinishedWork( current$$1, workInProgress, renderExpirationTime ); } - changedBits = 0; } else { - var oldValue = oldProps.value; - // Use Object.is to compare the new context value to the old value. - // Inlined Object.is polyfill. - // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is - if ( - (oldValue === newValue && - (oldValue !== 0 || 1 / oldValue === 1 / newValue)) || - (oldValue !== oldValue && newValue !== newValue) // eslint-disable-line no-self-compare - ) { - // No change. Bailout early if children are the same. - if (oldProps.children === newProps.children && !hasContextChanged()) { - workInProgress.stateNode = 0; - pushProvider(workInProgress); - return bailoutOnAlreadyFinishedWork( - current$$1, - workInProgress, - renderExpirationTime - ); - } - changedBits = 0; - } else { - changedBits = - typeof context._calculateChangedBits === "function" - ? context._calculateChangedBits(oldValue, newValue) - : maxSigned31BitInt; - { - !((changedBits & maxSigned31BitInt) === changedBits) - ? warning$1( - false, - "calculateChangedBits: Expected the return value to be a " + - "31-bit integer. Instead received: %s", - changedBits - ) - : void 0; - } - changedBits |= 0; - - if (changedBits === 0) { - // No change. Bailout early if children are the same. - if (oldProps.children === newProps.children && !hasContextChanged()) { - workInProgress.stateNode = 0; - pushProvider(workInProgress); - return bailoutOnAlreadyFinishedWork( - current$$1, - workInProgress, - renderExpirationTime - ); - } - } else { - propagateContextChange( - workInProgress, - context, - changedBits, - renderExpirationTime - ); - } - } + // The context value changed. Search for matching consumers and schedule + // them to update. + propagateContextChange( + workInProgress, + context, + changedBits, + renderExpirationTime + ); } } - workInProgress.stateNode = changedBits; - pushProvider(workInProgress); - var newChildren = newProps.children; reconcileChildren( current$$1, @@ -10756,7 +10910,7 @@ function bailoutOnAlreadyFinishedWork( if (enableProfilerTimer) { // Don't update "base" render times for bailouts. - stopBaseRenderTimerIfRunning(); + stopProfilerTimerIfRunning(workInProgress); } // Check if the children have any pending work. @@ -10789,12 +10943,6 @@ function memoizeState(workInProgress, nextState) { } function beginWork(current$$1, workInProgress, renderExpirationTime) { - if (enableProfilerTimer) { - if (workInProgress.mode & ProfileMode) { - markActualRenderTimeStarted(workInProgress); - } - } - var updateExpirationTime = workInProgress.expirationTime; if ( !hasContextChanged() && @@ -10812,19 +10960,32 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { case HostComponent: pushHostContext(workInProgress); break; - case ClassComponent: - pushContextProvider(workInProgress); + case ClassComponent: { + var Component = workInProgress.type; + if (isContextProvider(Component)) { + pushContextProvider(workInProgress); + } break; + } + case ClassComponentLazy: { + var thenable = workInProgress.type; + var _Component = getResultFromResolvedThenable(thenable); + if (isContextProvider(_Component)) { + pushContextProvider(workInProgress); + } + break; + } case HostPortal: pushHostContainer( workInProgress, workInProgress.stateNode.containerInfo ); break; - case ContextProvider: - workInProgress.stateNode = 0; - pushProvider(workInProgress); + case ContextProvider: { + var newValue = workInProgress.memoizedProps.value; + pushProvider(workInProgress, newValue); break; + } case Profiler: if (enableProfilerTimer) { workInProgress.effectTag |= Update; @@ -10842,24 +11003,65 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { workInProgress.expirationTime = NoWork; switch (workInProgress.tag) { - case IndeterminateComponent: + case IndeterminateComponent: { + var _Component3 = workInProgress.type; return mountIndeterminateComponent( current$$1, workInProgress, + _Component3, renderExpirationTime ); - case FunctionalComponent: + } + case FunctionalComponent: { + var _Component4 = workInProgress.type; + var _unresolvedProps = workInProgress.pendingProps; return updateFunctionalComponent( current$$1, workInProgress, + _Component4, + _unresolvedProps, renderExpirationTime ); - case ClassComponent: + } + case FunctionalComponentLazy: { + var _thenable2 = workInProgress.type; + var _Component5 = getResultFromResolvedThenable(_thenable2); + var _unresolvedProps2 = workInProgress.pendingProps; + var _child = updateFunctionalComponent( + current$$1, + workInProgress, + _Component5, + resolveDefaultProps(_Component5, _unresolvedProps2), + renderExpirationTime + ); + workInProgress.memoizedProps = _unresolvedProps2; + return _child; + } + case ClassComponent: { + var _Component6 = workInProgress.type; + var _unresolvedProps3 = workInProgress.pendingProps; return updateClassComponent( current$$1, workInProgress, + _Component6, + _unresolvedProps3, renderExpirationTime ); + } + case ClassComponentLazy: { + var _thenable3 = workInProgress.type; + var _Component7 = getResultFromResolvedThenable(_thenable3); + var _unresolvedProps4 = workInProgress.pendingProps; + var _child2 = updateClassComponent( + current$$1, + workInProgress, + _Component7, + resolveDefaultProps(_Component7, _unresolvedProps4), + renderExpirationTime + ); + workInProgress.memoizedProps = _unresolvedProps4; + return _child2; + } case HostRoot: return updateHostRoot(current$$1, workInProgress, renderExpirationTime); case HostComponent: @@ -10882,8 +11084,29 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { workInProgress, renderExpirationTime ); - case ForwardRef: - return updateForwardRef(current$$1, workInProgress, renderExpirationTime); + case ForwardRef: { + var type = workInProgress.type; + return updateForwardRef( + current$$1, + workInProgress, + type, + workInProgress.pendingProps, + renderExpirationTime + ); + } + case ForwardRefLazy: + var _thenable = workInProgress.type; + var _Component2 = getResultFromResolvedThenable(_thenable); + var unresolvedProps = workInProgress.pendingProps; + var child = updateForwardRef( + current$$1, + workInProgress, + _Component2, + resolveDefaultProps(_Component2, unresolvedProps), + renderExpirationTime + ); + workInProgress.memoizedProps = unresolvedProps; + return child; case Fragment: return updateFragment(current$$1, workInProgress, renderExpirationTime); case Mode: @@ -10963,13 +11186,36 @@ if (supportsMutation) { updateHostComponent$1 = function( current, workInProgress, - updatePayload, type, - oldProps, newProps, - rootContainerInstance, - currentHostContext + rootContainerInstance ) { + // If we have an alternate, that means this is an update and we need to + // schedule a side-effect to do the updates. + var oldProps = current.memoizedProps; + if (oldProps === newProps) { + // In mutation mode, this is sufficient for a bailout because + // we won't touch this node even if children changed. + return; + } + + // If we get updated because one of our children updated, we don't + // have newProps so we'll have to reuse them. + // TODO: Split the update API as separate for the props vs. children. + // Even better would be if children weren't special cased at all tho. + var instance = workInProgress.stateNode; + var currentHostContext = getHostContext(); + // TODO: Experiencing an error where oldProps is null. Suggests a host + // component is hitting the resume path. Figure out why. Possibly + // related to `hidden`. + var updatePayload = prepareUpdate( + instance, + type, + oldProps, + newProps, + rootContainerInstance, + currentHostContext + ); // TODO: Type this specific to this type of component. workInProgress.updateQueue = updatePayload; // If the update payload indicates that there is a change or if there @@ -11039,54 +11285,70 @@ if (supportsMutation) { updateHostComponent$1 = function( current, workInProgress, - updatePayload, type, - oldProps, newProps, - rootContainerInstance, - currentHostContext + rootContainerInstance ) { + var currentInstance = current.stateNode; + var oldProps = current.memoizedProps; // If there are no effects associated with this node, then none of our children had any updates. // This guarantees that we can reuse all of them. var childrenUnchanged = workInProgress.firstEffect === null; - var currentInstance = current.stateNode; + if (childrenUnchanged && oldProps === newProps) { + // No changes, just reuse the existing instance. + // Note that this might release a previous clone. + workInProgress.stateNode = currentInstance; + return; + } + var recyclableInstance = workInProgress.stateNode; + var currentHostContext = getHostContext(); + var updatePayload = null; + if (oldProps !== newProps) { + updatePayload = prepareUpdate( + recyclableInstance, + type, + oldProps, + newProps, + rootContainerInstance, + currentHostContext + ); + } if (childrenUnchanged && updatePayload === null) { // No changes, just reuse the existing instance. // Note that this might release a previous clone. workInProgress.stateNode = currentInstance; - } else { - var recyclableInstance = workInProgress.stateNode; - var newInstance = cloneInstance( - currentInstance, - updatePayload, + return; + } + var newInstance = cloneInstance( + currentInstance, + updatePayload, + type, + oldProps, + newProps, + workInProgress, + childrenUnchanged, + recyclableInstance + ); + if ( + finalizeInitialChildren( + newInstance, type, - oldProps, newProps, - workInProgress, - childrenUnchanged, - recyclableInstance - ); - if ( - finalizeInitialChildren( - newInstance, - type, - newProps, - rootContainerInstance, - currentHostContext - ) - ) { - markUpdate(workInProgress); - } - workInProgress.stateNode = newInstance; - if (childrenUnchanged) { - // If there are no other effects in this tree, we need to flag this node as having one. - // Even though we're not going to use it for anything. - // Otherwise parents won't know that there are new children to propagate upwards. - markUpdate(workInProgress); - } else { - // If children might have changed, we have to add them all to the set. - appendAllChildren(newInstance, workInProgress); - } + rootContainerInstance, + currentHostContext + ) + ) { + markUpdate(workInProgress); + } + workInProgress.stateNode = newInstance; + if (childrenUnchanged) { + // If there are no other effects in this tree, we need to flag this node as having one. + // Even though we're not going to use it for anything. + // Otherwise parents won't know that there are new children to propagate upwards. + markUpdate(workInProgress); + } else { + // If children might have changed, we have to add them all to the set. + appendAllChildren(newInstance, workInProgress); } }; updateHostText$1 = function(current, workInProgress, oldText, newText) { @@ -11113,12 +11375,9 @@ if (supportsMutation) { updateHostComponent$1 = function( current, workInProgress, - updatePayload, type, - oldProps, newProps, - rootContainerInstance, - currentHostContext + rootContainerInstance ) { // Noop }; @@ -11132,10 +11391,20 @@ function completeWork(current, workInProgress, renderExpirationTime) { switch (workInProgress.tag) { case FunctionalComponent: + case FunctionalComponentLazy: break; case ClassComponent: { - // We are leaving this subtree, so pop context if any. - popContextProvider(workInProgress); + var Component = workInProgress.type; + if (isContextProvider(Component)) { + popContext(workInProgress); + } + break; + } + case ClassComponentLazy: { + var _Component = getResultFromResolvedThenable(workInProgress.type); + if (isContextProvider(_Component)) { + popContext(workInProgress); + } break; } case HostRoot: { @@ -11162,36 +11431,12 @@ function completeWork(current, workInProgress, renderExpirationTime) { var rootContainerInstance = getRootHostContainer(); var type = workInProgress.type; if (current !== null && workInProgress.stateNode != null) { - // If we have an alternate, that means this is an update and we need to - // schedule a side-effect to do the updates. - var oldProps = current.memoizedProps; - // If we get updated because one of our children updated, we don't - // have newProps so we'll have to reuse them. - // TODO: Split the update API as separate for the props vs. children. - // Even better would be if children weren't special cased at all tho. - var instance = workInProgress.stateNode; - var currentHostContext = getHostContext(); - // TODO: Experiencing an error where oldProps is null. Suggests a host - // component is hitting the resume path. Figure out why. Possibly - // related to `hidden`. - var updatePayload = prepareUpdate( - instance, - type, - oldProps, - newProps, - rootContainerInstance, - currentHostContext - ); - updateHostComponent$1( current, workInProgress, - updatePayload, type, - oldProps, newProps, - rootContainerInstance, - currentHostContext + rootContainerInstance ); if (current.ref !== workInProgress.ref) { @@ -11208,7 +11453,7 @@ function completeWork(current, workInProgress, renderExpirationTime) { break; } - var _currentHostContext = getHostContext(); + var currentHostContext = getHostContext(); // TODO: Move createInstance to beginWork and keep it on a context // "stack" as the parent. Then append children as we go in beginWork // or completeWork depending on we want to add then top->down or @@ -11221,7 +11466,7 @@ function completeWork(current, workInProgress, renderExpirationTime) { prepareToHydrateHostInstance( workInProgress, rootContainerInstance, - _currentHostContext + currentHostContext ) ) { // If changes to the hydrated node needs to be applied at the @@ -11229,31 +11474,31 @@ function completeWork(current, workInProgress, renderExpirationTime) { markUpdate(workInProgress); } } else { - var _instance = createInstance( + var instance = createInstance( type, newProps, rootContainerInstance, - _currentHostContext, + currentHostContext, workInProgress ); - appendAllChildren(_instance, workInProgress); + appendAllChildren(instance, workInProgress); // Certain renderers require commit-time effects for initial mount. // (eg DOM renderer supports auto-focus for certain elements). // Make sure such renderers get scheduled for later work. if ( finalizeInitialChildren( - _instance, + instance, type, newProps, rootContainerInstance, - _currentHostContext + currentHostContext ) ) { markUpdate(workInProgress); } - workInProgress.stateNode = _instance; + workInProgress.stateNode = instance; } if (workInProgress.ref !== null) { @@ -11280,7 +11525,7 @@ function completeWork(current, workInProgress, renderExpirationTime) { // This can happen when we abort work. } var _rootContainerInstance = getRootHostContainer(); - var _currentHostContext2 = getHostContext(); + var _currentHostContext = getHostContext(); var _wasHydrated = popHydrationState(workInProgress); if (_wasHydrated) { if (prepareToHydrateHostTextInstance(workInProgress)) { @@ -11290,7 +11535,7 @@ function completeWork(current, workInProgress, renderExpirationTime) { workInProgress.stateNode = createTextInstance( newText, _rootContainerInstance, - _currentHostContext2, + _currentHostContext, workInProgress ); } @@ -11298,6 +11543,7 @@ function completeWork(current, workInProgress, renderExpirationTime) { break; } case ForwardRef: + case ForwardRefLazy: break; case PlaceholderComponent: break; @@ -11334,16 +11580,6 @@ function completeWork(current, workInProgress, renderExpirationTime) { ); } - if (enableProfilerTimer) { - if (workInProgress.mode & ProfileMode) { - // Don't record elapsed time unless the "complete" phase has succeeded. - // Certain renderers may error during this phase (i.e. ReactNative View/Text nesting validation). - // If an error occurs, we'll mark the time while unwinding. - // This simplifies the unwinding logic and ensures consistency. - recordElapsedActualRenderTime(workInProgress); - } - } - return null; } @@ -11398,11 +11634,6 @@ function logCapturedError(capturedError) { } var error = capturedError.error; - var suppressLogging = error && error.suppressReactErrorLogging; - if (suppressLogging) { - return; - } - { var componentName = capturedError.componentName, componentStack = capturedError.componentStack, @@ -11410,6 +11641,26 @@ function logCapturedError(capturedError) { errorBoundaryFound = capturedError.errorBoundaryFound, willRetry = capturedError.willRetry; + // Browsers support silencing uncaught errors by calling + // `preventDefault()` in window `error` handler. + // We record this information as an expando on the error. + + if (error != null && error._suppressLogging) { + if (errorBoundaryFound && willRetry) { + // The error is recoverable and was silenced. + // Ignore it and don't print the stack addendum. + // This is handy for testing error boundaries without noise. + return; + } + // The error is fatal. Since the silencing might have + // been accidental, we'll surface it anyway. + // However, the browser would have silenced the original error + // so we'll print it first, and then print the stack addendum. + console.error(error); + // For a more detailed description of this block, see: + // https://github.com/facebook/react/pull/13384 + } + var componentNameMessage = componentName ? "The above error occurred in the <" + componentName + "> component:" : "The above error occurred in one of your React components:"; @@ -11448,10 +11699,6 @@ function logCapturedError(capturedError) { } } -var invokeGuardedCallback$3 = ReactErrorUtils.invokeGuardedCallback; -var hasCaughtError$1 = ReactErrorUtils.hasCaughtError; -var clearCaughtError$1 = ReactErrorUtils.clearCaughtError; - var emptyObject$1 = {}; var didWarnAboutUndefinedSnapshotBeforeUpdate = null; @@ -11486,12 +11733,13 @@ function logError(boundary, errorInfo) { try { logCapturedError(capturedError); } catch (e) { - // Prevent cycle if logCapturedError() throws. - // A cycle may still occur if logCapturedError renders a component that throws. - var suppressLogging = e && e.suppressReactErrorLogging; - if (!suppressLogging) { - console.error(e); - } + // This method must not throw, or React internal state will get messed up. + // If console.error is overridden, or logCapturedError() shows a dialog that throws, + // we want to report this error outside of the normal stack as a last resort. + // https://github.com/facebook/react/issues/13188 + setTimeout(function() { + throw e; + }); } } @@ -11506,15 +11754,15 @@ var callComponentWillUnmountWithTimer = function(current$$1, instance) { // Capture errors so they don't interrupt unmounting. function safelyCallComponentWillUnmount(current$$1, instance) { { - invokeGuardedCallback$3( + invokeGuardedCallback( null, callComponentWillUnmountWithTimer, null, current$$1, instance ); - if (hasCaughtError$1()) { - var unmountError = clearCaughtError$1(); + if (hasCaughtError()) { + var unmountError = clearCaughtError(); captureCommitPhaseError(current$$1, unmountError); } } @@ -11525,9 +11773,9 @@ function safelyDetachRef(current$$1) { if (ref !== null) { if (typeof ref === "function") { { - invokeGuardedCallback$3(null, ref, null, null); - if (hasCaughtError$1()) { - var refError = clearCaughtError$1(); + invokeGuardedCallback(null, ref, null, null); + if (hasCaughtError()) { + var refError = clearCaughtError(); captureCommitPhaseError(current$$1, refError); } } @@ -11539,7 +11787,8 @@ function safelyDetachRef(current$$1) { function commitBeforeMutationLifeCycles(current$$1, finishedWork) { switch (finishedWork.tag) { - case ClassComponent: { + case ClassComponent: + case ClassComponentLazy: { if (finishedWork.effectTag & Snapshot) { if (current$$1 !== null) { var prevProps = current$$1.memoizedProps; @@ -11590,7 +11839,8 @@ function commitLifeCycles( committedExpirationTime ) { switch (finishedWork.tag) { - case ClassComponent: { + case ClassComponent: + case ClassComponentLazy: { var instance = finishedWork.stateNode; if (finishedWork.effectTag & Update) { if (current$$1 === null) { @@ -11636,6 +11886,7 @@ function commitLifeCycles( _instance = getPublicInstance(finishedWork.child.stateNode); break; case ClassComponent: + case ClassComponentLazy: _instance = finishedWork.child.stateNode; break; } @@ -11673,7 +11924,30 @@ function commitLifeCycles( return; } case Profiler: { - // We have no life-cycles associated with Profiler. + if (enableProfilerTimer) { + var onRender = finishedWork.memoizedProps.onRender; + + if (enableSchedulerTracking) { + onRender( + finishedWork.memoizedProps.id, + current$$1 === null ? "mount" : "update", + finishedWork.actualDuration, + finishedWork.treeBaseDuration, + finishedWork.actualStartTime, + getCommitTime(), + finishedRoot.memoizedInteractions + ); + } else { + onRender( + finishedWork.memoizedProps.id, + current$$1 === null ? "mount" : "update", + finishedWork.actualDuration, + finishedWork.treeBaseDuration, + finishedWork.actualStartTime, + getCommitTime() + ); + } + } return; } case PlaceholderComponent: { @@ -11755,7 +12029,8 @@ function commitUnmount(current$$1) { onCommitUnmount(current$$1); switch (current$$1.tag) { - case ClassComponent: { + case ClassComponent: + case ClassComponentLazy: { safelyDetachRef(current$$1); var instance = current$$1.stateNode; if (typeof instance.componentWillUnmount === "function") { @@ -11846,7 +12121,8 @@ function commitContainer(finishedWork) { } switch (finishedWork.tag) { - case ClassComponent: { + case ClassComponent: + case ClassComponentLazy: { return; } case HostComponent: { @@ -12126,7 +12402,8 @@ function commitWork(current$$1, finishedWork) { } switch (finishedWork.tag) { - case ClassComponent: { + case ClassComponent: + case ClassComponentLazy: { return; } case HostComponent: { @@ -12175,17 +12452,6 @@ function commitWork(current$$1, finishedWork) { return; } case Profiler: { - if (enableProfilerTimer) { - var onRender = finishedWork.memoizedProps.onRender; - onRender( - finishedWork.memoizedProps.id, - current$$1 === null ? "mount" : "update", - finishedWork.actualDuration, - finishedWork.treeBaseDuration, - finishedWork.actualStartTime, - getCommitTime() - ); - } return; } case PlaceholderComponent: { @@ -12379,7 +12645,10 @@ function throwException( sourceFiber.tag = FunctionalComponent; } - if (sourceFiber.tag === ClassComponent) { + if ( + sourceFiber.tag === ClassComponent || + sourceFiber.tag === ClassComponentLazy + ) { // We're going to commit this fiber even though it didn't // complete. But we shouldn't call any lifecycle methods or // callbacks. Remove all lifecycle effect tags. @@ -12416,8 +12685,8 @@ function throwException( // time. First, find the earliest uncommitted expiration time in the // tree, including work that is suspended. Then subtract the offset // used to compute an async update's expiration time. This will cause - // high priority (interactive) work to expire earlier than neccessary, - // but we can account for this by adjusting for the Just Noticable + // high priority (interactive) work to expire earlier than necessary, + // but we can account for this by adjusting for the Just Noticeable // Difference. var earliestExpirationTime = findEarliestOutstandingPriorityLevel( root, @@ -12473,6 +12742,7 @@ function throwException( return; } case ClassComponent: + case ClassComponentLazy: // Capture and retry var errorInfo = value; var ctor = workInProgress.type; @@ -12505,15 +12775,12 @@ function throwException( } function unwindWork(workInProgress, renderExpirationTime) { - if (enableProfilerTimer) { - if (workInProgress.mode & ProfileMode) { - recordElapsedActualRenderTime(workInProgress); - } - } - switch (workInProgress.tag) { case ClassComponent: { - popContextProvider(workInProgress); + var Component = workInProgress.type; + if (isContextProvider(Component)) { + popContext(workInProgress); + } var effectTag = workInProgress.effectTag; if (effectTag & ShouldCapture) { workInProgress.effectTag = (effectTag & ~ShouldCapture) | DidCapture; @@ -12521,16 +12788,28 @@ function unwindWork(workInProgress, renderExpirationTime) { } return null; } + case ClassComponentLazy: { + var _Component = workInProgress.type._reactResult; + if (isContextProvider(_Component)) { + popContext(workInProgress); + } + var _effectTag = workInProgress.effectTag; + if (_effectTag & ShouldCapture) { + workInProgress.effectTag = (_effectTag & ~ShouldCapture) | DidCapture; + return workInProgress; + } + return null; + } case HostRoot: { popHostContainer(workInProgress); popTopLevelContextObject(workInProgress); - var _effectTag = workInProgress.effectTag; + var _effectTag2 = workInProgress.effectTag; invariant( - (_effectTag & DidCapture) === NoEffect, + (_effectTag2 & DidCapture) === NoEffect, "The root failed to unmount after an error. This is likely a bug in " + "React. Please file an issue." ); - workInProgress.effectTag = (_effectTag & ~ShouldCapture) | DidCapture; + workInProgress.effectTag = (_effectTag2 & ~ShouldCapture) | DidCapture; return workInProgress; } case HostComponent: { @@ -12538,9 +12817,9 @@ function unwindWork(workInProgress, renderExpirationTime) { return null; } case PlaceholderComponent: { - var _effectTag2 = workInProgress.effectTag; - if (_effectTag2 & ShouldCapture) { - workInProgress.effectTag = (_effectTag2 & ~ShouldCapture) | DidCapture; + var _effectTag3 = workInProgress.effectTag; + if (_effectTag3 & ShouldCapture) { + workInProgress.effectTag = (_effectTag3 & ~ShouldCapture) | DidCapture; return workInProgress; } return null; @@ -12557,15 +12836,20 @@ function unwindWork(workInProgress, renderExpirationTime) { } function unwindInterruptedWork(interruptedWork) { - if (enableProfilerTimer) { - if (interruptedWork.mode & ProfileMode) { - recordElapsedActualRenderTime(interruptedWork); - } - } - switch (interruptedWork.tag) { case ClassComponent: { - popContextProvider(interruptedWork); + var childContextTypes = interruptedWork.type.childContextTypes; + if (childContextTypes !== null && childContextTypes !== undefined) { + popContext(interruptedWork); + } + break; + } + case ClassComponentLazy: { + var _childContextTypes = + interruptedWork.type._reactResult.childContextTypes; + if (_childContextTypes !== null && _childContextTypes !== undefined) { + popContext(interruptedWork); + } break; } case HostRoot: { @@ -12593,15 +12877,25 @@ var Dispatcher = { }; var ReactCurrentOwner$2 = ReactSharedInternals.ReactCurrentOwner; -var invokeGuardedCallback$2 = ReactErrorUtils.invokeGuardedCallback; -var hasCaughtError = ReactErrorUtils.hasCaughtError; -var clearCaughtError = ReactErrorUtils.clearCaughtError; var didWarnAboutStateTransition = void 0; var didWarnSetStateChildContext = void 0; var warnAboutUpdateOnUnmounted = void 0; var warnAboutInvalidUpdates = void 0; +if (enableSchedulerTracking) { + // Provide explicit error message when production+profiling bundle of e.g. react-dom + // is used with production (non-profiling) bundle of schedule/tracking + invariant( + tracking.__interactionsRef != null && + tracking.__interactionsRef.current != null, + "It is not supported to run the profiling version of a renderer (for example, `react-dom/profiling`) " + + "without also replacing the `schedule/tracking` module with `schedule/tracking-profiling`. " + + "Your bundler might have a setting for aliasing both modules. " + + "Learn more at http://fb.me/react-profiling" + ); +} + { didWarnAboutStateTransition = false; didWarnSetStateChildContext = false; @@ -12644,9 +12938,7 @@ var warnAboutInvalidUpdates = void 0; warningWithoutStack$1( false, "Cannot update during an existing state transition (such as within " + - "`render` or another component's constructor). Render methods should " + - "be a pure function of props and state; constructor side-effects are " + - "an anti-pattern, but can be moved to `componentWillMount`." + "`render`). Render methods should be a pure function of props and state." ); didWarnAboutStateTransition = true; break; @@ -12654,9 +12946,6 @@ var warnAboutInvalidUpdates = void 0; }; } -// Used to ensure computeUniqueAsyncExpiration is monotonically increasing. -var lastUniqueAsyncExpiration = 0; - // Represents the expiration time that incoming updates should use. (If this // is NoWork, use the default strategy: async updates in async mode, sync // updates in sync mode.) @@ -12682,6 +12971,10 @@ var legacyErrorBoundariesThatAlreadyFailed = null; // Used for performance tracking. var interruptedBy = null; +// Do not decrement interaction counts in the event of suspense timeouts. +// This would lead to prematurely calling the interaction-complete hook. +var suspenseDidTimeout = false; + var stashedWorkInProgressProperties = void 0; var replayUnitOfWork = void 0; var isReplayingFailedUnitOfWork = void 0; @@ -12726,9 +13019,20 @@ if (true && replayFailedUnitOfWorkWithInvokeGuardedCallback) { case HostComponent: popHostContext(failedUnitOfWork); break; - case ClassComponent: - popContextProvider(failedUnitOfWork); + case ClassComponent: { + var Component = failedUnitOfWork.type; + if (isContextProvider(Component)) { + popContext(failedUnitOfWork); + } break; + } + case ClassComponentLazy: { + var _Component = getResultFromResolvedThenable(failedUnitOfWork.type); + if (isContextProvider(_Component)) { + popContext(failedUnitOfWork); + } + break; + } case HostPortal: popHostContainer(failedUnitOfWork); break; @@ -12739,19 +13043,22 @@ if (true && replayFailedUnitOfWorkWithInvokeGuardedCallback) { // Replay the begin phase. isReplayingFailedUnitOfWork = true; originalReplayError = thrownValue; - invokeGuardedCallback$2(null, workLoop, null, isYieldy); + invokeGuardedCallback(null, workLoop, null, isYieldy); isReplayingFailedUnitOfWork = false; originalReplayError = null; if (hasCaughtError()) { - clearCaughtError(); - - if (enableProfilerTimer) { - if (failedUnitOfWork.mode & ProfileMode) { - recordElapsedActualRenderTime(failedUnitOfWork); + var replayError = clearCaughtError(); + if (replayError != null && thrownValue != null) { + try { + // Reading the expando property is intentionally + // inside `try` because it might be a getter or Proxy. + if (replayError._suppressLogging) { + // Also suppress logging for the original error. + thrownValue._suppressLogging = true; + } + } catch (inner) { + // Ignore. } - - // Stop "base" render timer again (after the re-thrown error). - stopBaseRenderTimerIfRunning(); } } else { // If the begin phase did not fail the second time, set this pointer @@ -12768,12 +13075,6 @@ function resetStack() { if (nextUnitOfWork !== null) { var interruptedWork = nextUnitOfWork.return; while (interruptedWork !== null) { - if (enableProfilerTimer) { - if (interruptedWork.mode & ProfileMode) { - // Resume in case we're picking up on work that was paused. - resumeActualRenderTimerIfPaused(false); - } - } unwindInterruptedWork(interruptedWork); interruptedWork = interruptedWork.return; } @@ -12970,6 +13271,36 @@ function commitRoot(root, finishedWork) { : updateExpirationTimeBeforeCommit; markCommittedPriorityLevels(root, earliestRemainingTimeBeforeCommit); + var prevInteractions = null; + var committedInteractions = enableSchedulerTracking ? [] : null; + if (enableSchedulerTracking) { + // Restore any pending interactions at this point, + // So that cascading work triggered during the render phase will be accounted for. + prevInteractions = tracking.__interactionsRef.current; + tracking.__interactionsRef.current = root.memoizedInteractions; + + // We are potentially finished with the current batch of interactions. + // So we should clear them out of the pending interaction map. + // We do this at the start of commit in case cascading work is scheduled by commit phase lifecycles. + // In that event, interaction data may be added back into the pending map for a future commit. + // We also store the interactions we are about to commit so that we can notify subscribers after we're done. + // These are stored as an Array rather than a Set, + // Because the same interaction may be pending for multiple expiration times, + // In which case it's important that we decrement the count the right number of times after finishing. + root.pendingInteractionMap.forEach(function( + scheduledInteractions, + scheduledExpirationTime + ) { + if (scheduledExpirationTime <= committedExpirationTime) { + committedInteractions.push.apply( + committedInteractions, + Array.from(scheduledInteractions) + ); + root.pendingInteractionMap.delete(scheduledExpirationTime); + } + }); + } + // Reset this to null before calling lifecycles ReactCurrentOwner$2.current = null; @@ -12999,7 +13330,7 @@ function commitRoot(root, finishedWork) { var didError = false; var error = void 0; { - invokeGuardedCallback$2(null, commitBeforeMutationLifecycles, null); + invokeGuardedCallback(null, commitBeforeMutationLifecycles, null); if (hasCaughtError()) { didError = true; error = clearCaughtError(); @@ -13035,7 +13366,7 @@ function commitRoot(root, finishedWork) { var _didError = false; var _error = void 0; { - invokeGuardedCallback$2(null, commitAllHostEffects, null); + invokeGuardedCallback(null, commitAllHostEffects, null); if (hasCaughtError()) { _didError = true; _error = clearCaughtError(); @@ -13074,7 +13405,7 @@ function commitRoot(root, finishedWork) { var _didError2 = false; var _error2 = void 0; { - invokeGuardedCallback$2( + invokeGuardedCallback( null, commitAllLifeCycles, null, @@ -13099,17 +13430,6 @@ function commitRoot(root, finishedWork) { } } - if (enableProfilerTimer) { - { - if (nextRoot === null) { - // Only check this stack once we're done processing async work. - // This prevents a false positive that occurs after a batched commit, - // If there was in-progress async work before the commit. - checkActualRenderTimeStackEmpty(); - } - } - } - isCommitting$1 = false; isWorking = false; stopCommitLifeCyclesTimer(); @@ -13133,6 +13453,53 @@ function commitRoot(root, finishedWork) { legacyErrorBoundariesThatAlreadyFailed = null; } onCommit(root, earliestRemainingTimeAfterCommit); + + if (enableSchedulerTracking) { + tracking.__interactionsRef.current = prevInteractions; + + var subscriber = void 0; + + try { + subscriber = tracking.__subscriberRef.current; + if (subscriber !== null && root.memoizedInteractions.size > 0) { + var threadID = computeThreadID( + committedExpirationTime, + root.interactionThreadID + ); + subscriber.onWorkStopped(root.memoizedInteractions, threadID); + } + } catch (error) { + // It's not safe for commitRoot() to throw. + // Store the error for now and we'll re-throw in finishRendering(). + if (!hasUnhandledError) { + hasUnhandledError = true; + unhandledError = error; + } + } finally { + // Don't update interaction counts if we're frozen due to suspense. + // In this case, we can skip the completed-work check entirely. + if (!suspenseDidTimeout) { + // Now that we're done, check the completed batch of interactions. + // If no more work is outstanding for a given interaction, + // We need to notify the subscribers that it's finished. + committedInteractions.forEach(function(interaction) { + interaction.__count--; + if (subscriber !== null && interaction.__count === 0) { + try { + subscriber.onInteractionScheduledWorkCompleted(interaction); + } catch (error) { + // It's not safe for commitRoot() to throw. + // Store the error for now and we'll re-throw in finishRendering(). + if (!hasUnhandledError) { + hasUnhandledError = true; + unhandledError = error; + } + } + } + }); + } + } + } } function resetChildExpirationTime(workInProgress, renderTime) { @@ -13146,9 +13513,22 @@ function resetChildExpirationTime(workInProgress, renderTime) { // Bubble up the earliest expiration time. if (enableProfilerTimer && workInProgress.mode & ProfileMode) { - // We're in profiling mode. Let's use this same traversal to update the - // "base" render times. + // We're in profiling mode. + // Let's use this same traversal to update the render durations. + var actualDuration = workInProgress.actualDuration; var treeBaseDuration = workInProgress.selfBaseDuration; + + // When a fiber is cloned, its actualDuration is reset to 0. + // This value will only be updated if work is done on the fiber (i.e. it doesn't bailout). + // When work is done, it should bubble to the parent's actualDuration. + // If the fiber has not been cloned though, (meaning no work was done), + // Then this value will reflect the amount of time spent working on a previous render. + // In that case it should not bubble. + // We determine whether it was cloned by comparing the child pointer. + var shouldBubbleActualDurations = + workInProgress.alternate === null || + workInProgress.child !== workInProgress.alternate.child; + var child = workInProgress.child; while (child !== null) { var childUpdateExpirationTime = child.expirationTime; @@ -13167,9 +13547,13 @@ function resetChildExpirationTime(workInProgress, renderTime) { ) { newChildExpirationTime = childChildExpirationTime; } + if (shouldBubbleActualDurations) { + actualDuration += child.actualDuration; + } treeBaseDuration += child.treeBaseDuration; child = child.sibling; } + workInProgress.actualDuration = actualDuration; workInProgress.treeBaseDuration = treeBaseDuration; } else { var _child = workInProgress.child; @@ -13216,11 +13600,28 @@ function completeUnitOfWork(workInProgress) { if ((workInProgress.effectTag & Incomplete) === NoEffect) { // This fiber completed. - nextUnitOfWork = completeWork( - current$$1, - workInProgress, - nextRenderExpirationTime - ); + if (enableProfilerTimer) { + if (workInProgress.mode & ProfileMode) { + startProfilerTimer(workInProgress); + } + + nextUnitOfWork = completeWork( + current$$1, + workInProgress, + nextRenderExpirationTime + ); + + if (workInProgress.mode & ProfileMode) { + // Update render duration assuming we didn't error. + stopProfilerTimerIfRunningAndRecordDelta(workInProgress, false); + } + } else { + nextUnitOfWork = completeWork( + current$$1, + workInProgress, + nextRenderExpirationTime + ); + } var next = nextUnitOfWork; stopWorkTimer(workInProgress); resetChildExpirationTime(workInProgress, nextRenderExpirationTime); @@ -13291,6 +13692,11 @@ function completeUnitOfWork(workInProgress) { return null; } } else { + if (workInProgress.mode & ProfileMode) { + // Record the render duration for the fiber that errored. + stopProfilerTimerIfRunningAndRecordDelta(workInProgress, false); + } + // This fiber did not complete because something threw. Pop values off // the stack without entering the complete phase. If this is a boundary, // capture values if possible. @@ -13313,6 +13719,19 @@ function completeUnitOfWork(workInProgress) { ReactFiberInstrumentation_1.debugTool.onCompleteWork(workInProgress); } + if (enableProfilerTimer) { + // Include the time spent working on failed children before continuing. + if (_next.mode & ProfileMode) { + var actualDuration = _next.actualDuration; + var child = _next.child; + while (child !== null) { + actualDuration += child.actualDuration; + child = child.sibling; + } + _next.actualDuration = actualDuration; + } + } + // If completing this work spawned new work, do that next. We'll come // back here again. // Since we're restarting, remove anything that is not a host effect @@ -13373,15 +13792,14 @@ function performUnitOfWork(workInProgress) { var next = void 0; if (enableProfilerTimer) { if (workInProgress.mode & ProfileMode) { - startBaseRenderTimer(); + startProfilerTimer(workInProgress); } next = beginWork(current$$1, workInProgress, nextRenderExpirationTime); if (workInProgress.mode & ProfileMode) { - // Update "base" time if the render wasn't bailed out on. - recordElapsedBaseRenderTimeIfRunning(workInProgress); - stopBaseRenderTimerIfRunning(); + // Record the render duration assuming we didn't bailout (or error). + stopProfilerTimerIfRunningAndRecordDelta(workInProgress, true); } } else { next = beginWork(current$$1, workInProgress, nextRenderExpirationTime); @@ -13422,12 +13840,6 @@ function workLoop(isYieldy) { while (nextUnitOfWork !== null && !shouldYield()) { nextUnitOfWork = performUnitOfWork(nextUnitOfWork); } - - if (enableProfilerTimer) { - // If we didn't finish, pause the "actual" render timer. - // We'll restart it when we resume work. - pauseActualRenderTimerIfRunning(); - } } } @@ -13442,6 +13854,14 @@ function renderRoot(root, isYieldy, isExpired) { var expirationTime = root.nextExpirationTimeToWorkOn; + var prevInteractions = null; + if (enableSchedulerTracking) { + // We're about to start new tracked work. + // Restore pending interactions so cascading work triggered during the render phase will be accounted for. + prevInteractions = tracking.__interactionsRef.current; + tracking.__interactionsRef.current = root.memoizedInteractions; + } + // Check if we're starting from a fresh stack, or if we're resuming from // previously yielded work. if ( @@ -13459,6 +13879,49 @@ function renderRoot(root, isYieldy, isExpired) { nextRenderExpirationTime ); root.pendingCommitExpirationTime = NoWork; + + if (enableSchedulerTracking) { + // Determine which interactions this batch of work currently includes, + // So that we can accurately attribute time spent working on it, + var interactions = new Set(); + root.pendingInteractionMap.forEach(function( + scheduledInteractions, + scheduledExpirationTime + ) { + if (scheduledExpirationTime <= expirationTime) { + scheduledInteractions.forEach(function(interaction) { + return interactions.add(interaction); + }); + } + }); + + // Store the current set of interactions on the FiberRoot for a few reasons: + // We can re-use it in hot functions like renderRoot() without having to recalculate it. + // We will also use it in commitWork() to pass to any Profiler onRender() hooks. + // This also provides DevTools with a way to access it when the onCommitRoot() hook is called. + root.memoizedInteractions = interactions; + + if (interactions.size > 0) { + var subscriber = tracking.__subscriberRef.current; + if (subscriber !== null) { + var threadID = computeThreadID( + expirationTime, + root.interactionThreadID + ); + try { + subscriber.onWorkStarted(interactions, threadID); + } catch (error) { + // Work thrown by an interaction tracking subscriber should be rethrown, + // But only once it's safe (to avoid leaveing the scheduler in an invalid state). + // Store the error for now and we'll re-throw in finishRendering(). + if (!hasUnhandledError) { + hasUnhandledError = true; + unhandledError = error; + } + } + } + } + } } var didFatal = false; @@ -13469,11 +13932,6 @@ function renderRoot(root, isYieldy, isExpired) { try { workLoop(isYieldy); } catch (thrownValue) { - if (enableProfilerTimer) { - // Stop "base" render timer in the event of an error. - stopBaseRenderTimerIfRunning(); - } - if (nextUnitOfWork === null) { // This is a fatal error. didFatal = true; @@ -13527,6 +13985,11 @@ function renderRoot(root, isYieldy, isExpired) { break; } while (true); + if (enableSchedulerTracking) { + // Tracked work is done for now; restore the previous interactions. + tracking.__interactionsRef.current = prevInteractions; + } + // We're done performing work. Time to clean up. isWorking = false; ReactCurrentOwner$2.currentDispatcher = null; @@ -13540,10 +14003,6 @@ function renderRoot(root, isYieldy, isExpired) { // There was a fatal error. { resetStackAfterFatalErrorInDev(); - - // Reset the DEV fiber stack in case we're profiling roots. - // (We do this for profiling bulds when DevTools is detected.) - resetActualRenderTimerStackAfterFatalErrorInDev(); } // `nextRoot` points to the in-progress root. A non-null value indicates // that we're in the middle of an async render. Set it to null to indicate @@ -13647,7 +14106,7 @@ function renderRoot(root, isYieldy, isExpired) { var msUntilTimeout = nextLatestAbsoluteTimeoutMs - currentTimeMs; msUntilTimeout = msUntilTimeout < 0 ? 0 : msUntilTimeout; - // TODO: Account for the Just Noticable Difference + // TODO: Account for the Just Noticeable Difference var _rootExpirationTime2 = root.expirationTime; onSuspend( @@ -13674,6 +14133,7 @@ function dispatch(sourceFiber, value, expirationTime) { while (fiber !== null) { switch (fiber.tag) { case ClassComponent: + case ClassComponentLazy: var ctor = fiber.type; var instance = fiber.stateNode; if ( @@ -13718,18 +14178,9 @@ function captureCommitPhaseError(fiber, error) { return dispatch(fiber, error, Sync); } -// Creates a unique async expiration time. -function computeUniqueAsyncExpiration() { - var currentTime = requestCurrentTime(); - var result = computeAsyncExpiration(currentTime); - if (result <= lastUniqueAsyncExpiration) { - // Since we assume the current time monotonically increases, we only hit - // this branch when computeUniqueAsyncExpiration is fired multiple times - // within a 200ms window (or whatever the async bucket size is). - result = lastUniqueAsyncExpiration + 1; - } - lastUniqueAsyncExpiration = result; - return lastUniqueAsyncExpiration; +function computeThreadID(expirationTime, interactionThreadID) { + // Interaction threads are unique per root and expiration time. + return expirationTime * 1000 + interactionThreadID; } function computeExpirationForFiber(currentTime, fiber) { @@ -13773,10 +14224,10 @@ function computeExpirationForFiber(currentTime, fiber) { // interactive expiration time. This allows us to synchronously flush // all interactive updates when needed. if ( - lowestPendingInteractiveExpirationTime === NoWork || - expirationTime > lowestPendingInteractiveExpirationTime + lowestPriorityPendingInteractiveExpirationTime === NoWork || + expirationTime > lowestPriorityPendingInteractiveExpirationTime ) { - lowestPendingInteractiveExpirationTime = expirationTime; + lowestPriorityPendingInteractiveExpirationTime = expirationTime; } } return expirationTime; @@ -13814,7 +14265,18 @@ function retrySuspendedRoot(root, fiber, suspendedTime) { scheduleWorkToRoot(fiber, retryTime); var rootExpirationTime = root.expirationTime; if (rootExpirationTime !== NoWork) { - requestWork(root, rootExpirationTime); + if (enableSchedulerTracking) { + // Restore previous interactions so that new work is associated with them. + var prevInteractions = tracking.__interactionsRef.current; + tracking.__interactionsRef.current = root.memoizedInteractions; + // Because suspense timeouts do not decrement the interaction count, + // Continued suspense work should also not increment the count. + storeInteractionsForExpirationTime(root, rootExpirationTime, false); + requestWork(root, rootExpirationTime); + tracking.__interactionsRef.current = prevInteractions; + } else { + requestWork(root, rootExpirationTime); + } } } } @@ -13869,11 +14331,51 @@ function scheduleWorkToRoot(fiber, expirationTime) { return null; } +function storeInteractionsForExpirationTime( + root, + expirationTime, + updateInteractionCounts +) { + if (!enableSchedulerTracking) { + return; + } + + var interactions = tracking.__interactionsRef.current; + if (interactions.size > 0) { + var pendingInteractions = root.pendingInteractionMap.get(expirationTime); + if (pendingInteractions != null) { + interactions.forEach(function(interaction) { + if (updateInteractionCounts && !pendingInteractions.has(interaction)) { + // Update the pending async work count for previously unscheduled interaction. + interaction.__count++; + } + + pendingInteractions.add(interaction); + }); + } else { + root.pendingInteractionMap.set(expirationTime, new Set(interactions)); + + // Update the pending async work count for the current interactions. + if (updateInteractionCounts) { + interactions.forEach(function(interaction) { + interaction.__count++; + }); + } + } + + var subscriber = tracking.__subscriberRef.current; + if (subscriber !== null) { + var threadID = computeThreadID(expirationTime, root.interactionThreadID); + subscriber.onWorkScheduled(interactions, threadID); + } + } +} + function scheduleWork(fiber, expirationTime) { recordScheduleUpdate(); { - if (fiber.tag === ClassComponent) { + if (fiber.tag === ClassComponent || fiber.tag === ClassComponentLazy) { var instance = fiber.stateNode; warnAboutInvalidUpdates(instance); } @@ -13881,12 +14383,19 @@ function scheduleWork(fiber, expirationTime) { var root = scheduleWorkToRoot(fiber, expirationTime); if (root === null) { - if (true && fiber.tag === ClassComponent) { + if ( + true && + (fiber.tag === ClassComponent || fiber.tag === ClassComponentLazy) + ) { warnAboutUpdateOnUnmounted(fiber); } return; } + if (enableSchedulerTracking) { + storeInteractionsForExpirationTime(root, expirationTime, true); + } + if ( !isWorking && nextRenderExpirationTime !== NoWork && @@ -13921,27 +14430,6 @@ function scheduleWork(fiber, expirationTime) { } } -function deferredUpdates(fn) { - var currentTime = requestCurrentTime(); - var previousExpirationContext = expirationContext; - expirationContext = computeAsyncExpiration(currentTime); - try { - return fn(); - } finally { - expirationContext = previousExpirationContext; - } -} - -function syncUpdates(fn, a, b, c, d) { - var previousExpirationContext = expirationContext; - expirationContext = Sync; - try { - return fn(a, b, c, d); - } finally { - expirationContext = previousExpirationContext; - } -} - // TODO: Everything below this is written as if it has been lifted to the // renderers. I'll do this in a follow-up. @@ -13954,7 +14442,7 @@ var callbackID = void 0; var isRendering = false; var nextFlushedRoot = null; var nextFlushedExpirationTime = NoWork; -var lowestPendingInteractiveExpirationTime = NoWork; +var lowestPriorityPendingInteractiveExpirationTime = NoWork; var deadlineDidExpire = false; var hasUnhandledError = false; var unhandledError = null; @@ -13982,7 +14470,7 @@ function recomputeCurrentRendererTime() { currentRendererTime = msToExpirationTime(currentTimeMs); } -function scheduleCallbackWithExpirationTime(expirationTime) { +function scheduleCallbackWithExpirationTime(root, expirationTime) { if (callbackExpirationTime !== NoWork) { // A callback is already scheduled. Check its expiration time (timeout). if (expirationTime > callbackExpirationTime) { @@ -14055,7 +14543,16 @@ function onTimeout(root, finishedWork, suspendedExpirationTime) { // because we're at the top of a timer event. recomputeCurrentRendererTime(); currentSchedulerTime = currentRendererTime; - flushRoot(root, suspendedExpirationTime); + + if (enableSchedulerTracking) { + // Don't update pending interaction counts for suspense timeouts, + // Because we know we still need to do more work in this case. + suspenseDidTimeout = true; + flushRoot(root, suspendedExpirationTime); + suspenseDidTimeout = false; + } else { + flushRoot(root, suspendedExpirationTime); + } } } @@ -14134,7 +14631,7 @@ function requestWork(root, expirationTime) { if (expirationTime === Sync) { performSyncWork(); } else { - scheduleCallbackWithExpirationTime(expirationTime); + scheduleCallbackWithExpirationTime(root, expirationTime); } } @@ -14218,6 +14715,11 @@ function findHighestPriorityRoot() { if (root === lastScheduledRoot) { break; } + if (highestPriorityWork === Sync) { + // Sync is highest priority by definition so + // we can stop searching. + break; + } previousScheduledRoot = root; root = root.nextScheduledRoot; } @@ -14229,6 +14731,22 @@ function findHighestPriorityRoot() { } function performAsyncWork(dl) { + if (dl.didTimeout) { + // The callback timed out. That means at least one update has expired. + // Iterate through the root schedule. If they contain expired work, set + // the next render expiration time to the current time. This has the effect + // of flushing all expired work in a single batch, instead of flushing each + // level one at a time. + if (firstScheduledRoot !== null) { + recomputeCurrentRendererTime(); + var root = firstScheduledRoot; + do { + didExpireAtExpirationTime(root, currentRendererTime); + // The root schedule is circular, so this is never null. + root = root.nextScheduledRoot; + } while (root !== firstScheduledRoot); + } + } performWork(NoWork, dl); } @@ -14239,14 +14757,10 @@ function performSyncWork() { function performWork(minExpirationTime, dl) { deadline = dl; - // Keep working on roots until there's no more work, or until the we reach + // Keep working on roots until there's no more work, or until we reach // the deadline. findHighestPriorityRoot(); - if (enableProfilerTimer) { - resumeActualRenderTimerIfPaused(minExpirationTime === Sync); - } - if (deadline !== null) { recomputeCurrentRendererTime(); currentSchedulerTime = currentRendererTime; @@ -14295,7 +14809,10 @@ function performWork(minExpirationTime, dl) { } // If there's work left over, schedule a new callback. if (nextFlushedExpirationTime !== NoWork) { - scheduleCallbackWithExpirationTime(nextFlushedExpirationTime); + scheduleCallbackWithExpirationTime( + nextFlushedRoot, + nextFlushedExpirationTime + ); } // Clean-up. @@ -14319,7 +14836,6 @@ function flushRoot(root, expirationTime) { performWorkOnRoot(root, expirationTime, true); // Flush any sync work that was scheduled by lifecycles performSyncWork(); - pauseActualRenderTimerIfRunning(); } function finishRendering() { @@ -14417,12 +14933,6 @@ function performWorkOnRoot(root, expirationTime, isExpired) { // There's no time left. Mark this root as complete. We'll come // back and commit it later. root.finishedWork = _finishedWork; - - if (enableProfilerTimer) { - // If we didn't finish, pause the "actual" render timer. - // We'll restart it when we resume work. - pauseActualRenderTimerIfRunning(); - } } } } @@ -14514,38 +15024,6 @@ function batchedUpdates$1(fn, a) { } } -// TODO: Batching should be implemented at the renderer level, not inside -// the reconciler. -function unbatchedUpdates(fn, a) { - if (isBatchingUpdates && !isUnbatchingUpdates) { - isUnbatchingUpdates = true; - try { - return fn(a); - } finally { - isUnbatchingUpdates = false; - } - } - return fn(a); -} - -// TODO: Batching should be implemented at the renderer level, not within -// the reconciler. -function flushSync(fn, a) { - invariant( - !isRendering, - "flushSync was called from inside a lifecycle method. It cannot be " + - "called when React is already rendering." - ); - var previousIsBatchingUpdates = isBatchingUpdates; - isBatchingUpdates = true; - try { - return syncUpdates(fn, a); - } finally { - isBatchingUpdates = previousIsBatchingUpdates; - performSyncWork(); - } -} - function interactiveUpdates$1(fn, a, b) { if (isBatchingInteractiveUpdates) { return fn(a, b); @@ -14557,11 +15035,11 @@ function interactiveUpdates$1(fn, a, b) { if ( !isBatchingUpdates && !isRendering && - lowestPendingInteractiveExpirationTime !== NoWork + lowestPriorityPendingInteractiveExpirationTime !== NoWork ) { // Synchronously flush pending interactive updates. - performWork(lowestPendingInteractiveExpirationTime, null); - lowestPendingInteractiveExpirationTime = NoWork; + performWork(lowestPriorityPendingInteractiveExpirationTime, null); + lowestPriorityPendingInteractiveExpirationTime = NoWork; } var previousIsBatchingInteractiveUpdates = isBatchingInteractiveUpdates; var previousIsBatchingUpdates = isBatchingUpdates; @@ -14579,23 +15057,13 @@ function interactiveUpdates$1(fn, a, b) { } function flushInteractiveUpdates$1() { - if (!isRendering && lowestPendingInteractiveExpirationTime !== NoWork) { + if ( + !isRendering && + lowestPriorityPendingInteractiveExpirationTime !== NoWork + ) { // Synchronously flush pending interactive updates. - performWork(lowestPendingInteractiveExpirationTime, null); - lowestPendingInteractiveExpirationTime = NoWork; - } -} - -function flushControlled(fn) { - var previousIsBatchingUpdates = isBatchingUpdates; - isBatchingUpdates = true; - try { - syncUpdates(fn); - } finally { - isBatchingUpdates = previousIsBatchingUpdates; - if (!isBatchingUpdates && !isRendering) { - performWork(Sync, null); - } + performWork(lowestPriorityPendingInteractiveExpirationTime, null); + lowestPriorityPendingInteractiveExpirationTime = NoWork; } } @@ -14615,9 +15083,20 @@ function getContextForSubtree(parentComponent) { var fiber = get$1(parentComponent); var parentContext = findCurrentUnmaskedContext(fiber); - return isContextProvider(fiber) - ? processChildContext(fiber, parentContext) - : parentContext; + + if (fiber.tag === ClassComponent) { + var Component = fiber.type; + if (isContextProvider(Component)) { + return processChildContext(fiber, Component, parentContext); + } + } else if (fiber.tag === ClassComponentLazy) { + var _Component = getResultFromResolvedThenable(fiber.type); + if (isContextProvider(_Component)) { + return processChildContext(fiber, _Component, parentContext); + } + } + + return parentContext; } function scheduleRootUpdate(current$$1, element, expirationTime, callback) { @@ -14740,14 +15219,6 @@ function getPublicRootInstance(container) { } } -function findHostInstanceWithNoPortals(fiber) { - var hostFiber = findCurrentHostFiberWithNoPortals(fiber); - if (hostFiber === null) { - return null; - } - return hostFiber.stateNode; -} - function injectIntoDevTools(devToolsConfig) { var findFiberByHostInstance = devToolsConfig.findFiberByHostInstance; @@ -14774,27 +15245,6 @@ function injectIntoDevTools(devToolsConfig) { // This file intentionally does *not* have the Flow annotation. // Don't add it. See `./inline-typed.js` for an explanation. -var ReactFabricRenderer = Object.freeze({ - updateContainerAtExpirationTime: updateContainerAtExpirationTime, - createContainer: createContainer, - updateContainer: updateContainer, - flushRoot: flushRoot, - requestWork: requestWork, - computeUniqueAsyncExpiration: computeUniqueAsyncExpiration, - batchedUpdates: batchedUpdates$1, - unbatchedUpdates: unbatchedUpdates, - deferredUpdates: deferredUpdates, - syncUpdates: syncUpdates, - interactiveUpdates: interactiveUpdates$1, - flushInteractiveUpdates: flushInteractiveUpdates$1, - flushControlled: flushControlled, - flushSync: flushSync, - getPublicRootInstance: getPublicRootInstance, - findHostInstance: findHostInstance$1, - findHostInstanceWithNoPortals: findHostInstanceWithNoPortals, - injectIntoDevTools: injectIntoDevTools -}); - function createPortal( children, containerInfo, @@ -14816,7 +15266,7 @@ function createPortal( // TODO: this is special because it gets imported during build. -var ReactVersion = "16.4.1"; +var ReactVersion = "16.5.0"; // Modules provided by RN: var NativeMethodsMixin = function(findNodeHandle, findHostInstance) { @@ -14856,7 +15306,7 @@ var NativeMethodsMixin = function(findNodeHandle, findHostInstance) { measure: function(callback) { UIManager.measure( findNodeHandle(this), - mountSafeCallback(this, callback) + mountSafeCallback_NOT_REALLY_SAFE(this, callback) ); }, @@ -14878,7 +15328,7 @@ var NativeMethodsMixin = function(findNodeHandle, findHostInstance) { measureInWindow: function(callback) { UIManager.measureInWindow( findNodeHandle(this), - mountSafeCallback(this, callback) + mountSafeCallback_NOT_REALLY_SAFE(this, callback) ); }, @@ -14898,8 +15348,8 @@ var NativeMethodsMixin = function(findNodeHandle, findHostInstance) { UIManager.measureLayout( findNodeHandle(this), relativeToNativeNode, - mountSafeCallback(this, onFail), - mountSafeCallback(this, onSuccess) + mountSafeCallback_NOT_REALLY_SAFE(this, onFail), + mountSafeCallback_NOT_REALLY_SAFE(this, onSuccess) ); }, @@ -15108,7 +15558,7 @@ var ReactNativeComponent = function(findNodeHandle, findHostInstance) { ReactNativeComponent.prototype.measure = function measure(callback) { UIManager.measure( findNodeHandle(this), - mountSafeCallback(this, callback) + mountSafeCallback_NOT_REALLY_SAFE(this, callback) ); }; @@ -15131,7 +15581,7 @@ var ReactNativeComponent = function(findNodeHandle, findHostInstance) { ) { UIManager.measureInWindow( findNodeHandle(this), - mountSafeCallback(this, callback) + mountSafeCallback_NOT_REALLY_SAFE(this, callback) ); }; @@ -15150,8 +15600,8 @@ var ReactNativeComponent = function(findNodeHandle, findHostInstance) { UIManager.measureLayout( findNodeHandle(this), relativeToNativeNode, - mountSafeCallback(this, onFail), - mountSafeCallback(this, onSuccess) + mountSafeCallback_NOT_REALLY_SAFE(this, onFail), + mountSafeCallback_NOT_REALLY_SAFE(this, onSuccess) ); }; @@ -15372,7 +15822,11 @@ function findNodeHandle(componentOrHandle) { return hostInstance._nativeTag; } -injection$2.injectRenderer(ReactFabricRenderer); +setBatchingImplementation( + batchedUpdates$1, + interactiveUpdates$1, + flushInteractiveUpdates$1 +); var roots = new Map(); @@ -15432,7 +15886,7 @@ var ReactFabric$3 = (ReactFabric$2 && ReactFabric) || ReactFabric$2; // TODO: decide on the top-level export form. // This is hacky but makes it work with both Rollup and Jest. -var fabric = ReactFabric$3.default ? ReactFabric$3.default : ReactFabric$3; +var fabric = ReactFabric$3.default || ReactFabric$3; module.exports = fabric; diff --git a/Libraries/Renderer/oss/ReactFabric-prod.js b/Libraries/Renderer/oss/ReactFabric-prod.js index ab3317fa8..fb635b0d5 100644 --- a/Libraries/Renderer/oss/ReactFabric-prod.js +++ b/Libraries/Renderer/oss/ReactFabric-prod.js @@ -1,5 +1,5 @@ /** - * Copyright (c) 2013-present, Facebook, Inc. + * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. @@ -18,8 +18,8 @@ var ReactNativeViewConfigRegistry = require("ReactNativeViewConfigRegistry"), deepDiffer = require("deepDiffer"), flattenStyle = require("flattenStyle"), TextInputState = require("TextInputState"), - FabricUIManager = require("FabricUIManager"), - ExceptionsManager = require("ExceptionsManager"); + FabricUIManager = require("FabricUIManager"); +var ExceptionsManager = require("ExceptionsManager"); function invariant(condition, format, a, b, c, d, e, f) { if (!condition) { condition = void 0; @@ -41,68 +41,53 @@ function invariant(condition, format, a, b, c, d, e, f) { throw condition; } } -function invokeGuardedCallback(name, func, context, a, b, c, d, e, f) { - this._hasCaughtError = !1; - this._caughtError = null; +function invokeGuardedCallbackImpl(name, func, context, a, b, c, d, e, f) { var funcArgs = Array.prototype.slice.call(arguments, 3); try { func.apply(context, funcArgs); } catch (error) { - (this._caughtError = error), (this._hasCaughtError = !0); + this.onError(error); } } -var ReactErrorUtils = { - _caughtError: null, - _hasCaughtError: !1, - _rethrowError: null, - _hasRethrowError: !1, - invokeGuardedCallback: function(name, func, context, a, b, c, d, e, f) { - invokeGuardedCallback.apply(ReactErrorUtils, arguments); - }, - invokeGuardedCallbackAndCatchFirstError: function( - name, - func, - context, - a, - b, - c, - d, - e, - f - ) { - ReactErrorUtils.invokeGuardedCallback.apply(this, arguments); - if (ReactErrorUtils.hasCaughtError()) { - var error = ReactErrorUtils.clearCaughtError(); - ReactErrorUtils._hasRethrowError || - ((ReactErrorUtils._hasRethrowError = !0), - (ReactErrorUtils._rethrowError = error)); +var hasError = !1, + caughtError = null, + hasRethrowError = !1, + rethrowError = null, + reporter = { + onError: function(error) { + hasError = !0; + caughtError = error; } - }, - rethrowCaughtError: function() { - return rethrowCaughtError.apply(ReactErrorUtils, arguments); - }, - hasCaughtError: function() { - return ReactErrorUtils._hasCaughtError; - }, - clearCaughtError: function() { - if (ReactErrorUtils._hasCaughtError) { - var error = ReactErrorUtils._caughtError; - ReactErrorUtils._caughtError = null; - ReactErrorUtils._hasCaughtError = !1; - return error; - } - invariant( - !1, - "clearCaughtError was called but no error was captured. This error is likely caused by a bug in React. Please file an issue." - ); - } -}; -function rethrowCaughtError() { - if (ReactErrorUtils._hasRethrowError) { - var error = ReactErrorUtils._rethrowError; - ReactErrorUtils._rethrowError = null; - ReactErrorUtils._hasRethrowError = !1; - throw error; + }; +function invokeGuardedCallback(name, func, context, a, b, c, d, e, f) { + hasError = !1; + caughtError = null; + invokeGuardedCallbackImpl.apply(reporter, arguments); +} +function invokeGuardedCallbackAndCatchFirstError( + name, + func, + context, + a, + b, + c, + d, + e, + f +) { + invokeGuardedCallback.apply(this, arguments); + if (hasError) { + if (hasError) { + var error = caughtError; + hasError = !1; + caughtError = null; + } else + invariant( + !1, + "clearCaughtError was called but no error was captured. This error is likely caused by a bug in React. Please file an issue." + ), + (error = void 0); + hasRethrowError || ((hasRethrowError = !0), (rethrowError = error)); } } var eventPluginOrder = null, @@ -184,12 +169,7 @@ var plugins = [], function executeDispatch(event, simulated, listener, inst) { simulated = event.type || "unknown-event"; event.currentTarget = getNodeFromInstance(inst); - ReactErrorUtils.invokeGuardedCallbackAndCatchFirstError( - simulated, - listener, - void 0, - event - ); + invokeGuardedCallbackAndCatchFirstError(simulated, listener, void 0, event); event.currentTarget = null; } function executeDirectDispatch(event) { @@ -313,7 +293,7 @@ function getListener(inst, registrationName) { } function getParent(inst) { do inst = inst.return; - while (inst && 5 !== inst.tag); + while (inst && 7 !== inst.tag); return inst ? inst : null; } function traverseTwoPhase(inst, fn, arg) { @@ -1020,22 +1000,15 @@ injection.injectEventPluginsByName({ function getInstanceFromInstance(instanceHandle) { return instanceHandle; } -var Injected$jscomp$inline_618 = { - getClosestInstanceFromNode: getInstanceFromInstance, - getInstanceFromNode: getInstanceFromInstance, - getNodeFromInstance: function(inst) { - inst = inst.stateNode.canonical._nativeTag; - invariant(inst, "All native instances should have a tag."); - return inst; - }, - getFiberCurrentPropsFromNode: function(inst) { - return inst.canonical.currentProps; - } +getFiberCurrentPropsFromNode = function(inst) { + return inst.canonical.currentProps; +}; +getInstanceFromNode = getInstanceFromInstance; +getNodeFromInstance = function(inst) { + inst = inst.stateNode.canonical._nativeTag; + invariant(inst, "All native instances should have a tag."); + return inst; }; -getFiberCurrentPropsFromNode = - Injected$jscomp$inline_618.getFiberCurrentPropsFromNode; -getInstanceFromNode = Injected$jscomp$inline_618.getInstanceFromNode; -getNodeFromInstance = Injected$jscomp$inline_618.getNodeFromInstance; ResponderEventPlugin.injection.injectGlobalResponderHandler({ onChange: function(from, to, blockNativeResponder) { null !== to @@ -1061,8 +1034,7 @@ var ReactSharedInternals = REACT_PLACEHOLDER_TYPE = hasSymbol ? Symbol.for("react.placeholder") : 60113, MAYBE_ITERATOR_SYMBOL = "function" === typeof Symbol && Symbol.iterator; function getIteratorFn(maybeIterable) { - if (null === maybeIterable || "undefined" === typeof maybeIterable) - return null; + if (null === maybeIterable || "object" !== typeof maybeIterable) return null; maybeIterable = (MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL]) || maybeIterable["@@iterator"]; @@ -1086,7 +1058,7 @@ function getComponentName(type) { case REACT_PLACEHOLDER_TYPE: return "Placeholder"; } - if ("object" === typeof type) + if ("object" === typeof type) { switch (type.$$typeof) { case REACT_CONTEXT_TYPE: return "Context.Consumer"; @@ -1099,6 +1071,12 @@ function getComponentName(type) { "" !== type ? "ForwardRef(" + type + ")" : "ForwardRef" ); } + if ( + "function" === typeof type.then && + (type = 1 === type._reactStatus ? type._reactResult : null) + ) + return getComponentName(type); + } return null; } function isFiberMountedImpl(fiber) { @@ -1109,7 +1087,7 @@ function isFiberMountedImpl(fiber) { for (; node.return; ) if (((node = node.return), 0 !== (node.effectTag & 2))) return 1; } - return 3 === node.tag ? 2 : 3; + return 5 === node.tag ? 2 : 3; } function assertIsMounted(fiber) { invariant( @@ -1185,14 +1163,14 @@ function findCurrentFiberUsingSlowPath(fiber) { "Return fibers should always be each others' alternates. This error is likely caused by a bug in React. Please file an issue." ); } - invariant(3 === a.tag, "Unable to find node on an unmounted component."); + invariant(5 === a.tag, "Unable to find node on an unmounted component."); return a.stateNode.current === a ? fiber : alternate; } function findCurrentHostFiber(parent) { parent = findCurrentFiberUsingSlowPath(parent); if (!parent) return null; for (var node = parent; ; ) { - if (5 === node.tag || 6 === node.tag) return node; + if (7 === node.tag || 8 === node.tag) return node; if (node.child) (node.child.return = node), (node = node.child); else { if (node === parent) break; @@ -1206,37 +1184,13 @@ function findCurrentHostFiber(parent) { } return null; } -function findCurrentHostFiberWithNoPortals(parent) { - parent = findCurrentFiberUsingSlowPath(parent); - if (!parent) return null; - for (var node = parent; ; ) { - if (5 === node.tag || 6 === node.tag) return node; - if (node.child && 4 !== node.tag) - (node.child.return = node), (node = node.child); - else { - if (node === parent) break; - for (; !node.sibling; ) { - if (!node.return || node.return === parent) return null; - node = node.return; - } - node.sibling.return = node.return; - node = node.sibling; - } - } - return null; -} -function mountSafeCallback(context, callback) { +function mountSafeCallback_NOT_REALLY_SAFE(context, callback) { return function() { - if (callback) { - if ("boolean" === typeof context.__isMounted) { - if (!context.__isMounted) return; - } else if ( - "function" === typeof context.isMounted && - !context.isMounted() - ) - return; + if ( + callback && + ("boolean" !== typeof context.__isMounted || context.__isMounted) + ) return callback.apply(context, arguments); - } }; } var emptyObject = {}, @@ -1257,23 +1211,23 @@ function restoreDeletedValuesInNestedArray( else if (node && 0 < removedKeyCount) for (i in removedKeys) if (removedKeys[i]) { - var _nextProp = node[i]; - if (void 0 !== _nextProp) { + var nextProp = node[i]; + if (void 0 !== nextProp) { var attributeConfig = validAttributes[i]; if (attributeConfig) { - "function" === typeof _nextProp && (_nextProp = !0); - "undefined" === typeof _nextProp && (_nextProp = null); + "function" === typeof nextProp && (nextProp = !0); + "undefined" === typeof nextProp && (nextProp = null); if ("object" !== typeof attributeConfig) - updatePayload[i] = _nextProp; + updatePayload[i] = nextProp; else if ( "function" === typeof attributeConfig.diff || "function" === typeof attributeConfig.process ) - (_nextProp = + (nextProp = "function" === typeof attributeConfig.process - ? attributeConfig.process(_nextProp) - : _nextProp), - (updatePayload[i] = _nextProp); + ? attributeConfig.process(nextProp) + : nextProp), + (updatePayload[i] = nextProp); removedKeys[i] = !1; removedKeyCount--; } @@ -1484,27 +1438,27 @@ var restoreTarget = null, function restoreStateOfTarget(target) { if ((target = getInstanceFromNode(target))) { invariant( - null, - "Fiber needs to be injected to handle a fiber target for controlled events. This error is likely caused by a bug in React. Please file an issue." + !1, + "setRestoreImplementation() needs to be called to handle a target for controlled events. This error is likely caused by a bug in React. Please file an issue." ); var props = getFiberCurrentPropsFromNode(target.stateNode); - null.restoreControlledState(target.stateNode, target.type, props); + null(target.stateNode, target.type, props); } } -function _batchedUpdates(fn, bookkeeping) { +function _batchedUpdatesImpl(fn, bookkeeping) { return fn(bookkeeping); } -function _flushInteractiveUpdates() {} +function _flushInteractiveUpdatesImpl() {} var isBatching = !1; function batchedUpdates(fn, bookkeeping) { if (isBatching) return fn(bookkeeping); isBatching = !0; try { - return _batchedUpdates(fn, bookkeeping); + return _batchedUpdatesImpl(fn, bookkeeping); } finally { if (((isBatching = !1), null !== restoreTarget || null !== restoreQueue)) if ( - (_flushInteractiveUpdates(), + (_flushInteractiveUpdatesImpl(), restoreTarget && ((bookkeeping = restoreTarget), (fn = restoreQueue), @@ -1534,13 +1488,19 @@ function dispatchEvent(target, topLevelType, nativeEvent) { null !== events && (eventQueue = accumulateInto(eventQueue, events)); events = eventQueue; eventQueue = null; - events && + if ( + events && (forEachAccumulated(events, executeDispatchesAndReleaseTopLevel), invariant( !eventQueue, "processEventQueue(): Additional events were enqueued while processing an event queue. Support for this has not yet been implemented." ), - ReactErrorUtils.rethrowCaughtError()); + hasRethrowError) + ) + throw ((events = rethrowError), + (hasRethrowError = !1), + (rethrowError = null), + events); }); } function shim$1() { @@ -1567,12 +1527,15 @@ var ReactFabricHostComponent = (function() { TextInputState.focusTextInput(this._nativeTag); }; ReactFabricHostComponent.prototype.measure = function(callback) { - UIManager.measure(this._nativeTag, mountSafeCallback(this, callback)); + UIManager.measure( + this._nativeTag, + mountSafeCallback_NOT_REALLY_SAFE(this, callback) + ); }; ReactFabricHostComponent.prototype.measureInWindow = function(callback) { UIManager.measureInWindow( this._nativeTag, - mountSafeCallback(this, callback) + mountSafeCallback_NOT_REALLY_SAFE(this, callback) ); }; ReactFabricHostComponent.prototype.measureLayout = function( @@ -1583,8 +1546,8 @@ var ReactFabricHostComponent = (function() { UIManager.measureLayout( this._nativeTag, relativeToNativeNode, - mountSafeCallback(this, onFail), - mountSafeCallback(this, onSuccess) + mountSafeCallback_NOT_REALLY_SAFE(this, onFail), + mountSafeCallback_NOT_REALLY_SAFE(this, onSuccess) ); }; ReactFabricHostComponent.prototype.setNativeProps = function(nativeProps) { @@ -1625,33 +1588,35 @@ function createTextInstance( ) }; } +var BEFORE_SLASH_RE = /^(.*)[\\\/]/; function getStackByFiberInDevAndProd(workInProgress) { var info = ""; do { a: switch (workInProgress.tag) { + case 4: case 0: case 1: case 2: - case 5: - case 11: + case 3: + case 7: + case 10: var owner = workInProgress._debugOwner, - source = workInProgress._debugSource; - var JSCompiler_inline_result = getComponentName(workInProgress.type); - var ownerName = null; - owner && (ownerName = getComponentName(owner.type)); - owner = source; - JSCompiler_inline_result = - "\n in " + - (JSCompiler_inline_result || "Unknown") + - (owner - ? " (at " + - owner.fileName.replace(/^.*[\\\/]/, "") + + source = workInProgress._debugSource, + name = getComponentName(workInProgress.type); + var JSCompiler_inline_result = null; + owner && (JSCompiler_inline_result = getComponentName(owner.type)); + owner = name; + name = ""; + source + ? (name = + " (at " + + source.fileName.replace(BEFORE_SLASH_RE, "") + ":" + - owner.lineNumber + - ")" - : ownerName - ? " (created by " + ownerName + ")" - : ""); + source.lineNumber + + ")") + : JSCompiler_inline_result && + (name = " (created by " + JSCompiler_inline_result + ")"); + JSCompiler_inline_result = "\n in " + (owner || "Unknown") + name; break a; default: JSCompiler_inline_result = ""; @@ -1677,11 +1642,6 @@ var emptyContextObject = {}, contextStackCursor = { current: emptyContextObject }, didPerformWorkStackCursor = { current: !1 }, previousContext = emptyContextObject; -function getUnmaskedContext(workInProgress) { - return isContextProvider(workInProgress) - ? previousContext - : contextStackCursor.current; -} function getMaskedContext(workInProgress, unmaskedContext) { var contextTypes = workInProgress.type.contextTypes; if (!contextTypes) return emptyContextObject; @@ -1700,12 +1660,13 @@ function getMaskedContext(workInProgress, unmaskedContext) { (workInProgress.__reactInternalMemoizedMaskedChildContext = context)); return context; } -function isContextProvider(fiber) { - return 2 === fiber.tag && null != fiber.type.childContextTypes; +function isContextProvider(type) { + type = type.childContextTypes; + return null !== type && void 0 !== type; } -function popContextProvider(fiber) { - isContextProvider(fiber) && - (pop(didPerformWorkStackCursor, fiber), pop(contextStackCursor, fiber)); +function popContext(fiber) { + pop(didPerformWorkStackCursor, fiber); + pop(contextStackCursor, fiber); } function popTopLevelContextObject(fiber) { pop(didPerformWorkStackCursor, fiber); @@ -1719,23 +1680,21 @@ function pushTopLevelContextObject(fiber, context, didChange) { push(contextStackCursor, context, fiber); push(didPerformWorkStackCursor, didChange, fiber); } -function processChildContext(fiber, parentContext) { +function processChildContext(fiber, type, parentContext) { var instance = fiber.stateNode; - fiber = fiber.type; - var childContextTypes = fiber.childContextTypes; + fiber = type.childContextTypes; if ("function" !== typeof instance.getChildContext) return parentContext; instance = instance.getChildContext(); for (var contextKey in instance) invariant( - contextKey in childContextTypes, + contextKey in fiber, '%s.getChildContext(): key "%s" is not defined in childContextTypes.', - getComponentName(fiber) || "Unknown", + getComponentName(type) || "Unknown", contextKey ); return Object.assign({}, parentContext, instance); } function pushContextProvider(workInProgress) { - if (!isContextProvider(workInProgress)) return !1; var instance = workInProgress.stateNode; instance = (instance && instance.__reactInternalMemoizedMergedChildContext) || @@ -1749,19 +1708,19 @@ function pushContextProvider(workInProgress) { ); return !0; } -function invalidateContextProvider(workInProgress, didChange) { +function invalidateContextProvider(workInProgress, type, didChange) { var instance = workInProgress.stateNode; invariant( instance, "Expected to have an instance by this point. This error is likely caused by a bug in React. Please file an issue." ); - if (didChange) { - var mergedContext = processChildContext(workInProgress, previousContext); - instance.__reactInternalMemoizedMergedChildContext = mergedContext; - pop(didPerformWorkStackCursor, workInProgress); - pop(contextStackCursor, workInProgress); - push(contextStackCursor, mergedContext, workInProgress); - } else pop(didPerformWorkStackCursor, workInProgress); + didChange + ? ((type = processChildContext(workInProgress, type, previousContext)), + (instance.__reactInternalMemoizedMergedChildContext = type), + pop(didPerformWorkStackCursor, workInProgress), + pop(contextStackCursor, workInProgress), + push(contextStackCursor, type, workInProgress)) + : pop(didPerformWorkStackCursor, workInProgress); push(didPerformWorkStackCursor, didChange, workInProgress); } var onCommitFiberRoot = null, @@ -1802,6 +1761,10 @@ function FiberNode(tag, pendingProps, key, mode) { this.childExpirationTime = this.expirationTime = 0; this.alternate = null; } +function shouldConstruct(Component) { + Component = Component.prototype; + return !(!Component || !Component.isReactComponent); +} function createWorkInProgress(current, pendingProps, expirationTime) { var workInProgress = current.alternate; null === workInProgress @@ -1839,11 +1802,11 @@ function createFiberFromElement(element, mode, expirationTime) { var type = element.type, key = element.key; element = element.props; - if ("function" === typeof type) - var fiberTag = type.prototype && type.prototype.isReactComponent ? 2 : 0; - else if ("string" === typeof type) fiberTag = 5; + var fiberTag = void 0; + if ("function" === typeof type) fiberTag = shouldConstruct(type) ? 2 : 4; + else if ("string" === typeof type) fiberTag = 7; else - switch (type) { + a: switch (type) { case REACT_FRAGMENT_TYPE: return createFiberFromFragment( element.children, @@ -1852,11 +1815,11 @@ function createFiberFromElement(element, mode, expirationTime) { key ); case REACT_ASYNC_MODE_TYPE: - fiberTag = 11; + fiberTag = 10; mode |= 3; break; case REACT_STRICT_MODE_TYPE: - fiberTag = 11; + fiberTag = 10; mode |= 2; break; case REACT_PROFILER_TYPE: @@ -1870,29 +1833,29 @@ function createFiberFromElement(element, mode, expirationTime) { fiberTag = 16; break; default: - a: { - switch ( - "object" === typeof type && null !== type ? type.$$typeof : null - ) { + if ("object" === typeof type && null !== type) + switch (type.$$typeof) { case REACT_PROVIDER_TYPE: - fiberTag = 13; - break a; - case REACT_CONTEXT_TYPE: fiberTag = 12; break a; + case REACT_CONTEXT_TYPE: + fiberTag = 11; + break a; case REACT_FORWARD_REF_TYPE: - fiberTag = 14; + fiberTag = 13; break a; default: - invariant( - !1, - "Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s", - null == type ? type : typeof type, - "" - ); + if ("function" === typeof type.then) { + fiberTag = 4; + break a; + } } - fiberTag = void 0; - } + invariant( + !1, + "Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s", + null == type ? type : typeof type, + "" + ); } mode = new FiberNode(fiberTag, element, key, mode); mode.type = type; @@ -1900,18 +1863,18 @@ function createFiberFromElement(element, mode, expirationTime) { return mode; } function createFiberFromFragment(elements, mode, expirationTime, key) { - elements = new FiberNode(10, elements, key, mode); + elements = new FiberNode(9, elements, key, mode); elements.expirationTime = expirationTime; return elements; } function createFiberFromText(content, mode, expirationTime) { - content = new FiberNode(6, content, null, mode); + content = new FiberNode(8, content, null, mode); content.expirationTime = expirationTime; return content; } function createFiberFromPortal(portal, mode, expirationTime) { mode = new FiberNode( - 4, + 6, null !== portal.children ? portal.children : [], portal.key, mode @@ -1924,31 +1887,6 @@ function createFiberFromPortal(portal, mode, expirationTime) { }; return mode; } -function createFiberRoot(containerInfo, isAsync, hydrate) { - isAsync = new FiberNode(3, null, null, isAsync ? 3 : 0); - containerInfo = { - current: isAsync, - containerInfo: containerInfo, - pendingChildren: null, - earliestPendingTime: 0, - latestPendingTime: 0, - earliestSuspendedTime: 0, - latestSuspendedTime: 0, - latestPingedTime: 0, - didError: !1, - pendingCommitExpirationTime: 0, - finishedWork: null, - timeoutHandle: -1, - context: null, - pendingContext: null, - hydrate: hydrate, - nextExpirationTimeToWorkOn: 0, - expirationTime: 0, - firstBatch: null, - nextScheduledRoot: null - }; - return (isAsync.stateNode = containerInfo); -} function markPendingPriorityLevel(root, expirationTime) { root.didError = !1; var earliestPendingTime = root.earliestPendingTime; @@ -2186,41 +2124,32 @@ function processUpdateQueue( workInProgress.expirationTime = newExpirationTime; workInProgress.memoizedState = resultState; } -function callCallback(callback, context) { - invariant( - "function" === typeof callback, - "Invalid argument passed as callback. Expected a function. Instead received: %s", - callback - ); - callback.call(context); -} function commitUpdateQueue(finishedWork, finishedQueue, instance) { null !== finishedQueue.firstCapturedUpdate && (null !== finishedQueue.lastUpdate && ((finishedQueue.lastUpdate.next = finishedQueue.firstCapturedUpdate), (finishedQueue.lastUpdate = finishedQueue.lastCapturedUpdate)), (finishedQueue.firstCapturedUpdate = finishedQueue.lastCapturedUpdate = null)); - finishedWork = finishedQueue.firstEffect; - for ( - finishedQueue.firstEffect = finishedQueue.lastEffect = null; - null !== finishedWork; - - ) { - var _callback3 = finishedWork.callback; - null !== _callback3 && - ((finishedWork.callback = null), callCallback(_callback3, instance)); - finishedWork = finishedWork.nextEffect; + commitUpdateEffects(finishedQueue.firstEffect, instance); + finishedQueue.firstEffect = finishedQueue.lastEffect = null; + commitUpdateEffects(finishedQueue.firstCapturedEffect, instance); + finishedQueue.firstCapturedEffect = finishedQueue.lastCapturedEffect = null; +} +function commitUpdateEffects(effect, instance) { + for (; null !== effect; ) { + var _callback3 = effect.callback; + if (null !== _callback3) { + effect.callback = null; + var context = instance; + invariant( + "function" === typeof _callback3, + "Invalid argument passed as callback. Expected a function. Instead received: %s", + _callback3 + ); + _callback3.call(context); + } + effect = effect.nextEffect; } - finishedWork = finishedQueue.firstCapturedEffect; - for ( - finishedQueue.firstCapturedEffect = finishedQueue.lastCapturedEffect = null; - null !== finishedWork; - - ) - (finishedQueue = finishedWork.callback), - null !== finishedQueue && - ((finishedWork.callback = null), callCallback(finishedQueue, instance)), - (finishedWork = finishedWork.nextEffect); } function createCapturedValue(value, source) { return { @@ -2230,125 +2159,23 @@ function createCapturedValue(value, source) { }; } var valueCursor = { current: null }, - changedBitsCursor = { current: 0 }, currentlyRenderingFiber = null, lastContextDependency = null, lastContextWithAllBitsObserved = null; -function pushProvider(providerFiber) { +function pushProvider(providerFiber, nextValue) { var context = providerFiber.type._context; - push(changedBitsCursor, context._changedBits2, providerFiber); push(valueCursor, context._currentValue2, providerFiber); - context._currentValue2 = providerFiber.pendingProps.value; - context._changedBits2 = providerFiber.stateNode; + context._currentValue2 = nextValue; } function popProvider(providerFiber) { - var changedBits = changedBitsCursor.current, - currentValue = valueCursor.current; + var currentValue = valueCursor.current; pop(valueCursor, providerFiber); - pop(changedBitsCursor, providerFiber); - providerFiber = providerFiber.type._context; - providerFiber._currentValue2 = currentValue; - providerFiber._changedBits2 = changedBits; + providerFiber.type._context._currentValue2 = currentValue; } -function propagateContextChange( - workInProgress, - context, - changedBits, - renderExpirationTime -) { - var fiber = workInProgress.child; - null !== fiber && (fiber.return = workInProgress); - for (; null !== fiber; ) { - var dependency = fiber.firstContextDependency; - if (null !== dependency) { - do { - if ( - dependency.context === context && - 0 !== (dependency.observedBits & changedBits) - ) { - if ( - 0 === fiber.expirationTime || - fiber.expirationTime > renderExpirationTime - ) - fiber.expirationTime = renderExpirationTime; - var nextFiber = fiber.alternate; - null !== nextFiber && - (0 === nextFiber.expirationTime || - nextFiber.expirationTime > renderExpirationTime) && - (nextFiber.expirationTime = renderExpirationTime); - for (var node = fiber.return; null !== node; ) { - nextFiber = node.alternate; - if ( - 0 === node.childExpirationTime || - node.childExpirationTime > renderExpirationTime - ) - (node.childExpirationTime = renderExpirationTime), - null !== nextFiber && - (0 === nextFiber.childExpirationTime || - nextFiber.childExpirationTime > renderExpirationTime) && - (nextFiber.childExpirationTime = renderExpirationTime); - else if ( - null !== nextFiber && - (0 === nextFiber.childExpirationTime || - nextFiber.childExpirationTime > renderExpirationTime) - ) - nextFiber.childExpirationTime = renderExpirationTime; - else break; - node = node.return; - } - nextFiber = null; - } else nextFiber = fiber.child; - dependency = dependency.next; - } while (null !== dependency); - } else - nextFiber = - 13 === fiber.tag - ? fiber.type === workInProgress.type - ? null - : fiber.child - : fiber.child; - if (null !== nextFiber) nextFiber.return = fiber; - else - for (nextFiber = fiber; null !== nextFiber; ) { - if (nextFiber === workInProgress) { - nextFiber = null; - break; - } - fiber = nextFiber.sibling; - if (null !== fiber) { - fiber.return = nextFiber.return; - nextFiber = fiber; - break; - } - nextFiber = nextFiber.return; - } - fiber = nextFiber; - } -} -function prepareToReadContext(workInProgress, renderExpirationTime) { +function prepareToReadContext(workInProgress) { currentlyRenderingFiber = workInProgress; lastContextWithAllBitsObserved = lastContextDependency = null; - var firstContextDependency = workInProgress.firstContextDependency; - if (null !== firstContextDependency) { - workInProgress.firstContextDependency = null; - var hasPendingContext = !1; - do { - var _context = firstContextDependency.context, - changedBits = _context._changedBits2; - 0 !== changedBits && - (propagateContextChange( - workInProgress, - _context, - changedBits, - renderExpirationTime - ), - 0 !== (changedBits & firstContextDependency.observedBits) && - (hasPendingContext = !0)); - firstContextDependency = firstContextDependency.next; - } while (null !== firstContextDependency); - return hasPendingContext; - } - return !1; + workInProgress.firstContextDependency = null; } function readContext(context, observedBits) { if ( @@ -2441,20 +2268,21 @@ function shallowEqual(objA, objB) { var emptyRefsObject = new React.Component().refs; function applyDerivedStateFromProps( workInProgress, + ctor, getDerivedStateFromProps, nextProps ) { - var prevState = workInProgress.memoizedState; - getDerivedStateFromProps = getDerivedStateFromProps(nextProps, prevState); - prevState = + ctor = workInProgress.memoizedState; + getDerivedStateFromProps = getDerivedStateFromProps(nextProps, ctor); + getDerivedStateFromProps = null === getDerivedStateFromProps || void 0 === getDerivedStateFromProps - ? prevState - : Object.assign({}, prevState, getDerivedStateFromProps); - workInProgress.memoizedState = prevState; - getDerivedStateFromProps = workInProgress.updateQueue; - null !== getDerivedStateFromProps && + ? ctor + : Object.assign({}, ctor, getDerivedStateFromProps); + workInProgress.memoizedState = getDerivedStateFromProps; + nextProps = workInProgress.updateQueue; + null !== nextProps && 0 === workInProgress.expirationTime && - (getDerivedStateFromProps.baseState = prevState); + (nextProps.baseState = getDerivedStateFromProps); } var classComponentUpdater = { isMounted: function(component) { @@ -2496,17 +2324,21 @@ var classComponentUpdater = { }; function checkShouldComponentUpdate( workInProgress, + ctor, oldProps, newProps, oldState, newState, nextLegacyContext ) { - var instance = workInProgress.stateNode; - workInProgress = workInProgress.type; - return "function" === typeof instance.shouldComponentUpdate - ? instance.shouldComponentUpdate(newProps, newState, nextLegacyContext) - : workInProgress.prototype && workInProgress.prototype.isPureReactComponent + workInProgress = workInProgress.stateNode; + return "function" === typeof workInProgress.shouldComponentUpdate + ? workInProgress.shouldComponentUpdate( + newProps, + newState, + nextLegacyContext + ) + : ctor.prototype && ctor.prototype.isPureReactComponent ? !shallowEqual(oldProps, newProps) || !shallowEqual(oldState, newState) : !0; } @@ -2524,12 +2356,17 @@ function callComponentWillReceiveProps( instance.state !== workInProgress && classComponentUpdater.enqueueReplaceState(instance, instance.state, null); } -function mountClassInstance(workInProgress, renderExpirationTime) { - var ctor = workInProgress.type, - instance = workInProgress.stateNode, - props = workInProgress.pendingProps, - unmaskedContext = getUnmaskedContext(workInProgress); - instance.props = props; +function mountClassInstance( + workInProgress, + ctor, + newProps, + renderExpirationTime +) { + var instance = workInProgress.stateNode, + unmaskedContext = isContextProvider(ctor) + ? previousContext + : contextStackCursor.current; + instance.props = newProps; instance.state = workInProgress.memoizedState; instance.refs = emptyRefsObject; instance.context = getMaskedContext(workInProgress, unmaskedContext); @@ -2538,14 +2375,19 @@ function mountClassInstance(workInProgress, renderExpirationTime) { (processUpdateQueue( workInProgress, unmaskedContext, - props, + newProps, instance, renderExpirationTime ), (instance.state = workInProgress.memoizedState)); unmaskedContext = ctor.getDerivedStateFromProps; "function" === typeof unmaskedContext && - (applyDerivedStateFromProps(workInProgress, unmaskedContext, props), + (applyDerivedStateFromProps( + workInProgress, + ctor, + unmaskedContext, + newProps + ), (instance.state = workInProgress.memoizedState)); "function" === typeof ctor.getDerivedStateFromProps || "function" === typeof instance.getSnapshotBeforeUpdate || @@ -2563,7 +2405,7 @@ function mountClassInstance(workInProgress, renderExpirationTime) { (processUpdateQueue( workInProgress, unmaskedContext, - props, + newProps, instance, renderExpirationTime ), @@ -2584,7 +2426,7 @@ function coerceRef(returnFiber, current$$1, element) { var inst = void 0; element && (invariant( - 2 === element.tag, + 2 === element.tag || 3 === element.tag, "Stateless function components cannot have refs." ), (inst = element.stateNode)); @@ -2611,7 +2453,7 @@ function coerceRef(returnFiber, current$$1, element) { } invariant( "string" === typeof returnFiber, - "Expected ref to be a function or a string." + "Expected ref to be a function, a string, an object returned by React.createRef(), or null." ); invariant( element._owner, @@ -2691,7 +2533,7 @@ function ChildReconciler(shouldTrackSideEffects) { textContent, expirationTime ) { - if (null === current$$1 || 6 !== current$$1.tag) + if (null === current$$1 || 8 !== current$$1.tag) return ( (current$$1 = createFiberFromText( textContent, @@ -2725,7 +2567,7 @@ function ChildReconciler(shouldTrackSideEffects) { function updatePortal(returnFiber, current$$1, portal, expirationTime) { if ( null === current$$1 || - 4 !== current$$1.tag || + 6 !== current$$1.tag || current$$1.stateNode.containerInfo !== portal.containerInfo || current$$1.stateNode.implementation !== portal.implementation ) @@ -2749,7 +2591,7 @@ function ChildReconciler(shouldTrackSideEffects) { expirationTime, key ) { - if (null === current$$1 || 10 !== current$$1.tag) + if (null === current$$1 || 9 !== current$$1.tag) return ( (current$$1 = createFiberFromFragment( fragment, @@ -3124,7 +2966,7 @@ function ChildReconciler(shouldTrackSideEffects) { ) { if (isUnkeyedTopLevelFragment.key === isObject) if ( - 10 === isUnkeyedTopLevelFragment.tag + 9 === isUnkeyedTopLevelFragment.tag ? newChild.type === REACT_FRAGMENT_TYPE : isUnkeyedTopLevelFragment.type === newChild.type ) { @@ -3189,7 +3031,7 @@ function ChildReconciler(shouldTrackSideEffects) { ) { if (currentFirstChild.key === isUnkeyedTopLevelFragment) if ( - 4 === currentFirstChild.tag && + 6 === currentFirstChild.tag && currentFirstChild.stateNode.containerInfo === newChild.containerInfo && currentFirstChild.stateNode.implementation === @@ -3227,7 +3069,7 @@ function ChildReconciler(shouldTrackSideEffects) { if ("string" === typeof newChild || "number" === typeof newChild) return ( (newChild = "" + newChild), - null !== currentFirstChild && 6 === currentFirstChild.tag + null !== currentFirstChild && 8 === currentFirstChild.tag ? (deleteRemainingChildren(returnFiber, currentFirstChild.sibling), (currentFirstChild = useFiber( currentFirstChild, @@ -3264,7 +3106,8 @@ function ChildReconciler(shouldTrackSideEffects) { if ("undefined" === typeof newChild && !isUnkeyedTopLevelFragment) switch (returnFiber.tag) { case 2: - case 1: + case 3: + case 0: (expirationTime = returnFiber.type), invariant( !1, @@ -3282,12 +3125,12 @@ var reconcileChildFibers = ChildReconciler(!0), isHydrating = !1; function tryHydrate(fiber, nextInstance) { switch (fiber.tag) { - case 5: + case 7: return ( (nextInstance = shim$1(nextInstance, fiber.type, fiber.pendingProps)), null !== nextInstance ? ((fiber.stateNode = nextInstance), !0) : !1 ); - case 6: + case 8: return ( (nextInstance = shim$1(nextInstance, fiber.pendingProps)), null !== nextInstance ? ((fiber.stateNode = nextInstance), !0) : !1 @@ -3310,7 +3153,7 @@ function tryToClaimNextHydratableInstance(fiber$jscomp$0) { return; } var returnFiber = hydrationParentFiber, - fiber = new FiberNode(5, null, null, 0); + fiber = new FiberNode(7, null, null, 0); fiber.type = "DELETED"; fiber.stateNode = firstAttemptedInstance; fiber.return = returnFiber; @@ -3328,6 +3171,38 @@ function tryToClaimNextHydratableInstance(fiber$jscomp$0) { (hydrationParentFiber = fiber$jscomp$0); } } +function readLazyComponentType(thenable) { + switch (thenable._reactStatus) { + case 1: + return thenable._reactResult; + case 2: + throw thenable._reactResult; + case 0: + throw thenable; + default: + throw ((thenable._reactStatus = 0), + thenable.then( + function(resolvedValue) { + if (0 === thenable._reactStatus) { + thenable._reactStatus = 1; + if ("object" === typeof resolvedValue && null !== resolvedValue) { + var defaultExport = resolvedValue.default; + resolvedValue = + void 0 !== defaultExport && null !== defaultExport + ? defaultExport + : resolvedValue; + } + thenable._reactResult = resolvedValue; + } + }, + function(error) { + 0 === thenable._reactStatus && + ((thenable._reactStatus = 2), (thenable._reactResult = error)); + } + ), + thenable); + } +} var ReactCurrentOwner$3 = ReactSharedInternals.ReactCurrentOwner; function reconcileChildren( current$$1, @@ -3350,6 +3225,30 @@ function reconcileChildren( renderExpirationTime ); } +function updateForwardRef( + current$$1, + workInProgress, + type, + nextProps, + renderExpirationTime +) { + type = type.render; + var ref = workInProgress.ref; + if ( + !didPerformWorkStackCursor.current && + workInProgress.memoizedProps === nextProps && + ref === (null !== current$$1 ? current$$1.ref : null) + ) + return bailoutOnAlreadyFinishedWork( + current$$1, + workInProgress, + renderExpirationTime + ); + type = type(nextProps, ref); + reconcileChildren(current$$1, workInProgress, type, renderExpirationTime); + workInProgress.memoizedProps = nextProps; + return workInProgress.child; +} function markRef(current$$1, workInProgress) { var ref = workInProgress.ref; if ( @@ -3358,9 +3257,268 @@ function markRef(current$$1, workInProgress) { ) workInProgress.effectTag |= 128; } +function updateFunctionalComponent( + current$$1, + workInProgress, + Component, + nextProps, + renderExpirationTime +) { + var unmaskedContext = isContextProvider(Component) + ? previousContext + : contextStackCursor.current; + unmaskedContext = getMaskedContext(workInProgress, unmaskedContext); + prepareToReadContext(workInProgress, renderExpirationTime); + Component = Component(nextProps, unmaskedContext); + workInProgress.effectTag |= 1; + reconcileChildren( + current$$1, + workInProgress, + Component, + renderExpirationTime + ); + workInProgress.memoizedProps = nextProps; + return workInProgress.child; +} +function updateClassComponent( + current$$1, + workInProgress, + Component, + nextProps, + renderExpirationTime +) { + if (isContextProvider(Component)) { + var hasContext = !0; + pushContextProvider(workInProgress); + } else hasContext = !1; + prepareToReadContext(workInProgress, renderExpirationTime); + if (null === current$$1) + if (null === workInProgress.stateNode) { + var unmaskedContext = isContextProvider(Component) + ? previousContext + : contextStackCursor.current, + contextTypes = Component.contextTypes, + isContextConsumer = null !== contextTypes && void 0 !== contextTypes; + contextTypes = isContextConsumer + ? getMaskedContext(workInProgress, unmaskedContext) + : emptyContextObject; + var instance = new Component(nextProps, contextTypes); + workInProgress.memoizedState = + null !== instance.state && void 0 !== instance.state + ? instance.state + : null; + instance.updater = classComponentUpdater; + workInProgress.stateNode = instance; + instance._reactInternalFiber = workInProgress; + isContextConsumer && + ((isContextConsumer = workInProgress.stateNode), + (isContextConsumer.__reactInternalMemoizedUnmaskedChildContext = unmaskedContext), + (isContextConsumer.__reactInternalMemoizedMaskedChildContext = contextTypes)); + mountClassInstance( + workInProgress, + Component, + nextProps, + renderExpirationTime + ); + nextProps = !0; + } else { + unmaskedContext = workInProgress.stateNode; + contextTypes = workInProgress.memoizedProps; + unmaskedContext.props = contextTypes; + var oldContext = unmaskedContext.context; + isContextConsumer = isContextProvider(Component) + ? previousContext + : contextStackCursor.current; + isContextConsumer = getMaskedContext(workInProgress, isContextConsumer); + var getDerivedStateFromProps = Component.getDerivedStateFromProps; + (instance = + "function" === typeof getDerivedStateFromProps || + "function" === typeof unmaskedContext.getSnapshotBeforeUpdate) || + ("function" !== + typeof unmaskedContext.UNSAFE_componentWillReceiveProps && + "function" !== typeof unmaskedContext.componentWillReceiveProps) || + ((contextTypes !== nextProps || oldContext !== isContextConsumer) && + callComponentWillReceiveProps( + workInProgress, + unmaskedContext, + nextProps, + isContextConsumer + )); + hasForceUpdate = !1; + var oldState = workInProgress.memoizedState; + oldContext = unmaskedContext.state = oldState; + var updateQueue = workInProgress.updateQueue; + null !== updateQueue && + (processUpdateQueue( + workInProgress, + updateQueue, + nextProps, + unmaskedContext, + renderExpirationTime + ), + (oldContext = workInProgress.memoizedState)); + contextTypes !== nextProps || + oldState !== oldContext || + didPerformWorkStackCursor.current || + hasForceUpdate + ? ("function" === typeof getDerivedStateFromProps && + (applyDerivedStateFromProps( + workInProgress, + Component, + getDerivedStateFromProps, + nextProps + ), + (oldContext = workInProgress.memoizedState)), + (contextTypes = + hasForceUpdate || + checkShouldComponentUpdate( + workInProgress, + Component, + contextTypes, + nextProps, + oldState, + oldContext, + isContextConsumer + )) + ? (instance || + ("function" !== + typeof unmaskedContext.UNSAFE_componentWillMount && + "function" !== typeof unmaskedContext.componentWillMount) || + ("function" === typeof unmaskedContext.componentWillMount && + unmaskedContext.componentWillMount(), + "function" === + typeof unmaskedContext.UNSAFE_componentWillMount && + unmaskedContext.UNSAFE_componentWillMount()), + "function" === typeof unmaskedContext.componentDidMount && + (workInProgress.effectTag |= 4)) + : ("function" === typeof unmaskedContext.componentDidMount && + (workInProgress.effectTag |= 4), + (workInProgress.memoizedProps = nextProps), + (workInProgress.memoizedState = oldContext)), + (unmaskedContext.props = nextProps), + (unmaskedContext.state = oldContext), + (unmaskedContext.context = isContextConsumer), + (nextProps = contextTypes)) + : ("function" === typeof unmaskedContext.componentDidMount && + (workInProgress.effectTag |= 4), + (nextProps = !1)); + } + else + (unmaskedContext = workInProgress.stateNode), + (contextTypes = workInProgress.memoizedProps), + (unmaskedContext.props = contextTypes), + (oldContext = unmaskedContext.context), + (isContextConsumer = isContextProvider(Component) + ? previousContext + : contextStackCursor.current), + (isContextConsumer = getMaskedContext(workInProgress, isContextConsumer)), + (getDerivedStateFromProps = Component.getDerivedStateFromProps), + (instance = + "function" === typeof getDerivedStateFromProps || + "function" === typeof unmaskedContext.getSnapshotBeforeUpdate) || + ("function" !== + typeof unmaskedContext.UNSAFE_componentWillReceiveProps && + "function" !== typeof unmaskedContext.componentWillReceiveProps) || + ((contextTypes !== nextProps || oldContext !== isContextConsumer) && + callComponentWillReceiveProps( + workInProgress, + unmaskedContext, + nextProps, + isContextConsumer + )), + (hasForceUpdate = !1), + (oldContext = workInProgress.memoizedState), + (oldState = unmaskedContext.state = oldContext), + (updateQueue = workInProgress.updateQueue), + null !== updateQueue && + (processUpdateQueue( + workInProgress, + updateQueue, + nextProps, + unmaskedContext, + renderExpirationTime + ), + (oldState = workInProgress.memoizedState)), + contextTypes !== nextProps || + oldContext !== oldState || + didPerformWorkStackCursor.current || + hasForceUpdate + ? ("function" === typeof getDerivedStateFromProps && + (applyDerivedStateFromProps( + workInProgress, + Component, + getDerivedStateFromProps, + nextProps + ), + (oldState = workInProgress.memoizedState)), + (getDerivedStateFromProps = + hasForceUpdate || + checkShouldComponentUpdate( + workInProgress, + Component, + contextTypes, + nextProps, + oldContext, + oldState, + isContextConsumer + )) + ? (instance || + ("function" !== + typeof unmaskedContext.UNSAFE_componentWillUpdate && + "function" !== typeof unmaskedContext.componentWillUpdate) || + ("function" === typeof unmaskedContext.componentWillUpdate && + unmaskedContext.componentWillUpdate( + nextProps, + oldState, + isContextConsumer + ), + "function" === + typeof unmaskedContext.UNSAFE_componentWillUpdate && + unmaskedContext.UNSAFE_componentWillUpdate( + nextProps, + oldState, + isContextConsumer + )), + "function" === typeof unmaskedContext.componentDidUpdate && + (workInProgress.effectTag |= 4), + "function" === typeof unmaskedContext.getSnapshotBeforeUpdate && + (workInProgress.effectTag |= 256)) + : ("function" !== typeof unmaskedContext.componentDidUpdate || + (contextTypes === current$$1.memoizedProps && + oldContext === current$$1.memoizedState) || + (workInProgress.effectTag |= 4), + "function" !== typeof unmaskedContext.getSnapshotBeforeUpdate || + (contextTypes === current$$1.memoizedProps && + oldContext === current$$1.memoizedState) || + (workInProgress.effectTag |= 256), + (workInProgress.memoizedProps = nextProps), + (workInProgress.memoizedState = oldState)), + (unmaskedContext.props = nextProps), + (unmaskedContext.state = oldState), + (unmaskedContext.context = isContextConsumer), + (nextProps = getDerivedStateFromProps)) + : ("function" !== typeof unmaskedContext.componentDidUpdate || + (contextTypes === current$$1.memoizedProps && + oldContext === current$$1.memoizedState) || + (workInProgress.effectTag |= 4), + "function" !== typeof unmaskedContext.getSnapshotBeforeUpdate || + (contextTypes === current$$1.memoizedProps && + oldContext === current$$1.memoizedState) || + (workInProgress.effectTag |= 256), + (nextProps = !1)); + return finishClassComponent( + current$$1, + workInProgress, + Component, + nextProps, + hasContext, + renderExpirationTime + ); +} function finishClassComponent( current$$1, workInProgress, + Component, shouldUpdate, hasContext, renderExpirationTime @@ -3369,7 +3527,7 @@ function finishClassComponent( var didCaptureError = 0 !== (workInProgress.effectTag & 64); if (!shouldUpdate && !didCaptureError) return ( - hasContext && invalidateContextProvider(workInProgress, !1), + hasContext && invalidateContextProvider(workInProgress, Component, !1), bailoutOnAlreadyFinishedWork( current$$1, workInProgress, @@ -3392,7 +3550,7 @@ function finishClassComponent( ); workInProgress.memoizedState = shouldUpdate.state; workInProgress.memoizedProps = shouldUpdate.props; - hasContext && invalidateContextProvider(workInProgress, !0); + hasContext && invalidateContextProvider(workInProgress, Component, !0); return workInProgress.child; } function pushHostRootContext(workInProgress) { @@ -3407,6 +3565,132 @@ function pushHostRootContext(workInProgress) { pushTopLevelContextObject(workInProgress, root.context, !1); pushHostContainer(workInProgress, root.containerInfo); } +function resolveDefaultProps(Component, baseProps) { + if (Component && Component.defaultProps) { + baseProps = Object.assign({}, baseProps); + Component = Component.defaultProps; + for (var propName in Component) + void 0 === baseProps[propName] && + (baseProps[propName] = Component[propName]); + } + return baseProps; +} +function mountIndeterminateComponent( + current$$1, + workInProgress, + Component, + renderExpirationTime +) { + invariant( + null === current$$1, + "An indeterminate component should never have mounted. This error is likely caused by a bug in React. Please file an issue." + ); + var props = workInProgress.pendingProps; + if ( + "object" === typeof Component && + null !== Component && + "function" === typeof Component.then + ) { + Component = readLazyComponentType(Component); + var JSCompiler_inline_result = Component; + JSCompiler_inline_result = + "function" === typeof JSCompiler_inline_result + ? shouldConstruct(JSCompiler_inline_result) + ? 3 + : 1 + : void 0 !== JSCompiler_inline_result && + null !== JSCompiler_inline_result && + JSCompiler_inline_result.$$typeof + ? 14 + : 4; + JSCompiler_inline_result = workInProgress.tag = JSCompiler_inline_result; + var resolvedProps = resolveDefaultProps(Component, props); + switch (JSCompiler_inline_result) { + case 1: + return updateFunctionalComponent( + current$$1, + workInProgress, + Component, + resolvedProps, + renderExpirationTime + ); + case 3: + return updateClassComponent( + current$$1, + workInProgress, + Component, + resolvedProps, + renderExpirationTime + ); + case 14: + return updateForwardRef( + current$$1, + workInProgress, + Component, + resolvedProps, + renderExpirationTime + ); + default: + invariant( + !1, + "Element type is invalid. Received a promise that resolves to: %s. Promise elements must resolve to a class or function.", + Component + ); + } + } + JSCompiler_inline_result = getMaskedContext( + workInProgress, + contextStackCursor.current + ); + prepareToReadContext(workInProgress, renderExpirationTime); + JSCompiler_inline_result = Component(props, JSCompiler_inline_result); + workInProgress.effectTag |= 1; + if ( + "object" === typeof JSCompiler_inline_result && + null !== JSCompiler_inline_result && + "function" === typeof JSCompiler_inline_result.render && + void 0 === JSCompiler_inline_result.$$typeof + ) { + workInProgress.tag = 2; + isContextProvider(Component) + ? ((resolvedProps = !0), pushContextProvider(workInProgress)) + : (resolvedProps = !1); + workInProgress.memoizedState = + null !== JSCompiler_inline_result.state && + void 0 !== JSCompiler_inline_result.state + ? JSCompiler_inline_result.state + : null; + var getDerivedStateFromProps = Component.getDerivedStateFromProps; + "function" === typeof getDerivedStateFromProps && + applyDerivedStateFromProps( + workInProgress, + Component, + getDerivedStateFromProps, + props + ); + JSCompiler_inline_result.updater = classComponentUpdater; + workInProgress.stateNode = JSCompiler_inline_result; + JSCompiler_inline_result._reactInternalFiber = workInProgress; + mountClassInstance(workInProgress, Component, props, renderExpirationTime); + return finishClassComponent( + current$$1, + workInProgress, + Component, + !0, + resolvedProps, + renderExpirationTime + ); + } + workInProgress.tag = 0; + reconcileChildren( + current$$1, + workInProgress, + JSCompiler_inline_result, + renderExpirationTime + ); + workInProgress.memoizedProps = props; + return workInProgress.child; +} function bailoutOnAlreadyFinishedWork( current$$1, workInProgress, @@ -3452,23 +3736,28 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { (0 === updateExpirationTime || updateExpirationTime > renderExpirationTime) ) { switch (workInProgress.tag) { - case 3: + case 5: pushHostRootContext(workInProgress); break; - case 5: + case 7: pushHostContext(workInProgress); break; case 2: - pushContextProvider(workInProgress); + isContextProvider(workInProgress.type) && + pushContextProvider(workInProgress); break; - case 4: + case 3: + isContextProvider(workInProgress.type._reactResult) && + pushContextProvider(workInProgress); + break; + case 6: pushHostContainer( workInProgress, workInProgress.stateNode.containerInfo ); break; - case 13: - (workInProgress.stateNode = 0), pushProvider(workInProgress); + case 12: + pushProvider(workInProgress, workInProgress.memoizedProps.value); } return bailoutOnAlreadyFinishedWork( current$$1, @@ -3478,294 +3767,56 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { } workInProgress.expirationTime = 0; switch (workInProgress.tag) { - case 0: - invariant( - null === current$$1, - "An indeterminate component should never have mounted. This error is likely caused by a bug in React. Please file an issue." - ); - var fn = workInProgress.type; - updateExpirationTime = workInProgress.pendingProps; - var unmaskedContext = getUnmaskedContext(workInProgress); - unmaskedContext = getMaskedContext(workInProgress, unmaskedContext); - prepareToReadContext(workInProgress, renderExpirationTime); - fn = fn(updateExpirationTime, unmaskedContext); - workInProgress.effectTag |= 1; - if ( - "object" === typeof fn && - null !== fn && - "function" === typeof fn.render && - void 0 === fn.$$typeof - ) { - var Component = workInProgress.type; - workInProgress.tag = 2; - unmaskedContext = pushContextProvider(workInProgress); - workInProgress.memoizedState = - null !== fn.state && void 0 !== fn.state ? fn.state : null; - Component = Component.getDerivedStateFromProps; - "function" === typeof Component && - applyDerivedStateFromProps( - workInProgress, - Component, - updateExpirationTime - ); - fn.updater = classComponentUpdater; - workInProgress.stateNode = fn; - fn._reactInternalFiber = workInProgress; - mountClassInstance(workInProgress, renderExpirationTime); - current$$1 = finishClassComponent( - current$$1, - workInProgress, - !0, - unmaskedContext, - renderExpirationTime - ); - } else - (workInProgress.tag = 1), - reconcileChildren( - current$$1, - workInProgress, - fn, - renderExpirationTime - ), - (workInProgress.memoizedProps = updateExpirationTime), - (current$$1 = workInProgress.child); - return current$$1; - case 1: - return ( - (fn = workInProgress.type), - (updateExpirationTime = workInProgress.pendingProps), - (unmaskedContext = getUnmaskedContext(workInProgress)), - (unmaskedContext = getMaskedContext(workInProgress, unmaskedContext)), - prepareToReadContext(workInProgress, renderExpirationTime), - (fn = fn(updateExpirationTime, unmaskedContext)), - (workInProgress.effectTag |= 1), - reconcileChildren(current$$1, workInProgress, fn, renderExpirationTime), - (workInProgress.memoizedProps = updateExpirationTime), - workInProgress.child - ); - case 2: - updateExpirationTime = pushContextProvider(workInProgress); - fn = prepareToReadContext(workInProgress, renderExpirationTime); - if (null === current$$1) - if (null === workInProgress.stateNode) { - var props = workInProgress.pendingProps, - ctor = workInProgress.type; - fn = getUnmaskedContext(workInProgress); - unmaskedContext = (Component = - 2 === workInProgress.tag && - null != workInProgress.type.contextTypes) - ? getMaskedContext(workInProgress, fn) - : emptyContextObject; - props = new ctor(props, unmaskedContext); - workInProgress.memoizedState = - null !== props.state && void 0 !== props.state ? props.state : null; - props.updater = classComponentUpdater; - workInProgress.stateNode = props; - props._reactInternalFiber = workInProgress; - Component && - ((Component = workInProgress.stateNode), - (Component.__reactInternalMemoizedUnmaskedChildContext = fn), - (Component.__reactInternalMemoizedMaskedChildContext = unmaskedContext)); - mountClassInstance(workInProgress, renderExpirationTime); - fn = !0; - } else { - var ctor$jscomp$0 = workInProgress.type; - unmaskedContext = workInProgress.stateNode; - props = workInProgress.memoizedProps; - Component = workInProgress.pendingProps; - unmaskedContext.props = props; - var oldContext = unmaskedContext.context; - ctor = getUnmaskedContext(workInProgress); - ctor = getMaskedContext(workInProgress, ctor); - var getDerivedStateFromProps = ctor$jscomp$0.getDerivedStateFromProps; - (ctor$jscomp$0 = - "function" === typeof getDerivedStateFromProps || - "function" === typeof unmaskedContext.getSnapshotBeforeUpdate) || - ("function" !== - typeof unmaskedContext.UNSAFE_componentWillReceiveProps && - "function" !== - typeof unmaskedContext.componentWillReceiveProps) || - ((props !== Component || oldContext !== ctor) && - callComponentWillReceiveProps( - workInProgress, - unmaskedContext, - Component, - ctor - )); - hasForceUpdate = !1; - var oldState = workInProgress.memoizedState; - oldContext = unmaskedContext.state = oldState; - var updateQueue = workInProgress.updateQueue; - null !== updateQueue && - (processUpdateQueue( - workInProgress, - updateQueue, - Component, - unmaskedContext, - renderExpirationTime - ), - (oldContext = workInProgress.memoizedState)); - props !== Component || - oldState !== oldContext || - didPerformWorkStackCursor.current || - fn || - hasForceUpdate - ? ("function" === typeof getDerivedStateFromProps && - (applyDerivedStateFromProps( - workInProgress, - getDerivedStateFromProps, - Component - ), - (oldContext = workInProgress.memoizedState)), - (fn = - hasForceUpdate || - fn || - checkShouldComponentUpdate( - workInProgress, - props, - Component, - oldState, - oldContext, - ctor - )) - ? (ctor$jscomp$0 || - ("function" !== - typeof unmaskedContext.UNSAFE_componentWillMount && - "function" !== - typeof unmaskedContext.componentWillMount) || - ("function" === typeof unmaskedContext.componentWillMount && - unmaskedContext.componentWillMount(), - "function" === - typeof unmaskedContext.UNSAFE_componentWillMount && - unmaskedContext.UNSAFE_componentWillMount()), - "function" === typeof unmaskedContext.componentDidMount && - (workInProgress.effectTag |= 4)) - : ("function" === typeof unmaskedContext.componentDidMount && - (workInProgress.effectTag |= 4), - (workInProgress.memoizedProps = Component), - (workInProgress.memoizedState = oldContext)), - (unmaskedContext.props = Component), - (unmaskedContext.state = oldContext), - (unmaskedContext.context = ctor)) - : ("function" === typeof unmaskedContext.componentDidMount && - (workInProgress.effectTag |= 4), - (fn = !1)); - } - else - (ctor$jscomp$0 = workInProgress.type), - (unmaskedContext = workInProgress.stateNode), - (Component = workInProgress.memoizedProps), - (props = workInProgress.pendingProps), - (unmaskedContext.props = Component), - (oldContext = unmaskedContext.context), - (ctor = getUnmaskedContext(workInProgress)), - (ctor = getMaskedContext(workInProgress, ctor)), - (getDerivedStateFromProps = ctor$jscomp$0.getDerivedStateFromProps), - (ctor$jscomp$0 = - "function" === typeof getDerivedStateFromProps || - "function" === typeof unmaskedContext.getSnapshotBeforeUpdate) || - ("function" !== - typeof unmaskedContext.UNSAFE_componentWillReceiveProps && - "function" !== - typeof unmaskedContext.componentWillReceiveProps) || - ((Component !== props || oldContext !== ctor) && - callComponentWillReceiveProps( - workInProgress, - unmaskedContext, - props, - ctor - )), - (hasForceUpdate = !1), - (oldContext = workInProgress.memoizedState), - (oldState = unmaskedContext.state = oldContext), - (updateQueue = workInProgress.updateQueue), - null !== updateQueue && - (processUpdateQueue( - workInProgress, - updateQueue, - props, - unmaskedContext, - renderExpirationTime - ), - (oldState = workInProgress.memoizedState)), - Component !== props || - oldContext !== oldState || - didPerformWorkStackCursor.current || - fn || - hasForceUpdate - ? ("function" === typeof getDerivedStateFromProps && - (applyDerivedStateFromProps( - workInProgress, - getDerivedStateFromProps, - props - ), - (oldState = workInProgress.memoizedState)), - (fn = - hasForceUpdate || - fn || - checkShouldComponentUpdate( - workInProgress, - Component, - props, - oldContext, - oldState, - ctor - )) - ? (ctor$jscomp$0 || - ("function" !== - typeof unmaskedContext.UNSAFE_componentWillUpdate && - "function" !== - typeof unmaskedContext.componentWillUpdate) || - ("function" === - typeof unmaskedContext.componentWillUpdate && - unmaskedContext.componentWillUpdate( - props, - oldState, - ctor - ), - "function" === - typeof unmaskedContext.UNSAFE_componentWillUpdate && - unmaskedContext.UNSAFE_componentWillUpdate( - props, - oldState, - ctor - )), - "function" === typeof unmaskedContext.componentDidUpdate && - (workInProgress.effectTag |= 4), - "function" === - typeof unmaskedContext.getSnapshotBeforeUpdate && - (workInProgress.effectTag |= 256)) - : ("function" !== typeof unmaskedContext.componentDidUpdate || - (Component === current$$1.memoizedProps && - oldContext === current$$1.memoizedState) || - (workInProgress.effectTag |= 4), - "function" !== - typeof unmaskedContext.getSnapshotBeforeUpdate || - (Component === current$$1.memoizedProps && - oldContext === current$$1.memoizedState) || - (workInProgress.effectTag |= 256), - (workInProgress.memoizedProps = props), - (workInProgress.memoizedState = oldState)), - (unmaskedContext.props = props), - (unmaskedContext.state = oldState), - (unmaskedContext.context = ctor)) - : ("function" !== typeof unmaskedContext.componentDidUpdate || - (Component === current$$1.memoizedProps && - oldContext === current$$1.memoizedState) || - (workInProgress.effectTag |= 4), - "function" !== typeof unmaskedContext.getSnapshotBeforeUpdate || - (Component === current$$1.memoizedProps && - oldContext === current$$1.memoizedState) || - (workInProgress.effectTag |= 256), - (fn = !1)); - return finishClassComponent( + case 4: + return mountIndeterminateComponent( current$$1, workInProgress, - fn, - updateExpirationTime, + workInProgress.type, + renderExpirationTime + ); + case 0: + return updateFunctionalComponent( + current$$1, + workInProgress, + workInProgress.type, + workInProgress.pendingProps, + renderExpirationTime + ); + case 1: + var _Component5 = workInProgress.type._reactResult; + updateExpirationTime = workInProgress.pendingProps; + current$$1 = updateFunctionalComponent( + current$$1, + workInProgress, + _Component5, + resolveDefaultProps(_Component5, updateExpirationTime), + renderExpirationTime + ); + workInProgress.memoizedProps = updateExpirationTime; + return current$$1; + case 2: + return updateClassComponent( + current$$1, + workInProgress, + workInProgress.type, + workInProgress.pendingProps, renderExpirationTime ); case 3: + return ( + (_Component5 = workInProgress.type._reactResult), + (updateExpirationTime = workInProgress.pendingProps), + (current$$1 = updateClassComponent( + current$$1, + workInProgress, + _Component5, + resolveDefaultProps(_Component5, updateExpirationTime), + renderExpirationTime + )), + (workInProgress.memoizedProps = updateExpirationTime), + current$$1 + ); + case 5: return ( pushHostRootContext(workInProgress), (updateExpirationTime = workInProgress.updateQueue), @@ -3773,8 +3824,8 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { null !== updateExpirationTime, "If the root does not have an updateQueue, we should have already bailed out. This error is likely caused by a bug in React. Please file an issue." ), - (fn = workInProgress.memoizedState), - (fn = null !== fn ? fn.element : null), + (_Component5 = workInProgress.memoizedState), + (_Component5 = null !== _Component5 ? _Component5.element : null), processUpdateQueue( workInProgress, updateExpirationTime, @@ -3783,8 +3834,8 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { renderExpirationTime ), (updateExpirationTime = workInProgress.memoizedState.element), - updateExpirationTime === fn - ? (current$$1 = bailoutOnAlreadyFinishedWork( + updateExpirationTime === _Component5 + ? (workInProgress = bailoutOnAlreadyFinishedWork( current$$1, workInProgress, renderExpirationTime @@ -3795,22 +3846,27 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { updateExpirationTime, renderExpirationTime ), - (current$$1 = workInProgress.child)), - current$$1 + (workInProgress = workInProgress.child)), + workInProgress ); - case 5: + case 7: return ( pushHostContext(workInProgress), null === current$$1 && tryToClaimNextHydratableInstance(workInProgress), (updateExpirationTime = workInProgress.pendingProps), - (fn = updateExpirationTime.children), + (_Component5 = updateExpirationTime.children), markRef(current$$1, workInProgress), - reconcileChildren(current$$1, workInProgress, fn, renderExpirationTime), + reconcileChildren( + current$$1, + workInProgress, + _Component5, + renderExpirationTime + ), (workInProgress.memoizedProps = updateExpirationTime), - (current$$1 = workInProgress.child), - current$$1 + (workInProgress = workInProgress.child), + workInProgress ); - case 6: + case 8: return ( null === current$$1 && tryToClaimNextHydratableInstance(workInProgress), (workInProgress.memoizedProps = workInProgress.pendingProps), @@ -3818,7 +3874,7 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { ); case 16: return null; - case 4: + case 6: return ( pushHostContainer( workInProgress, @@ -3841,31 +3897,29 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { (workInProgress.memoizedProps = updateExpirationTime), workInProgress.child ); + case 13: + return updateForwardRef( + current$$1, + workInProgress, + workInProgress.type, + workInProgress.pendingProps, + renderExpirationTime + ); case 14: return ( - (fn = workInProgress.type.render), + (_Component5 = workInProgress.type._reactResult), (updateExpirationTime = workInProgress.pendingProps), - (unmaskedContext = workInProgress.ref), - didPerformWorkStackCursor.current || - workInProgress.memoizedProps !== updateExpirationTime || - unmaskedContext !== (null !== current$$1 ? current$$1.ref : null) - ? ((fn = fn(updateExpirationTime, unmaskedContext)), - reconcileChildren( - current$$1, - workInProgress, - fn, - renderExpirationTime - ), - (workInProgress.memoizedProps = updateExpirationTime), - (current$$1 = workInProgress.child)) - : (current$$1 = bailoutOnAlreadyFinishedWork( - current$$1, - workInProgress, - renderExpirationTime - )), + (current$$1 = updateForwardRef( + current$$1, + workInProgress, + _Component5, + resolveDefaultProps(_Component5, updateExpirationTime), + renderExpirationTime + )), + (workInProgress.memoizedProps = updateExpirationTime), current$$1 ); - case 10: + case 9: return ( (updateExpirationTime = workInProgress.pendingProps), reconcileChildren( @@ -3877,7 +3931,7 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { (workInProgress.memoizedProps = updateExpirationTime), workInProgress.child ); - case 11: + case 10: return ( (updateExpirationTime = workInProgress.pendingProps.children), reconcileChildren( @@ -3901,101 +3955,146 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { (workInProgress.memoizedProps = updateExpirationTime), workInProgress.child ); - case 13: + case 12: a: { updateExpirationTime = workInProgress.type._context; - fn = workInProgress.pendingProps; - unmaskedContext = workInProgress.memoizedProps; - Component = fn.value; - workInProgress.memoizedProps = fn; - if (null === unmaskedContext) Component = 1073741823; - else if (unmaskedContext.value === fn.value) { - if ( - unmaskedContext.children === fn.children && - !didPerformWorkStackCursor.current - ) { - workInProgress.stateNode = 0; - pushProvider(workInProgress); - current$$1 = bailoutOnAlreadyFinishedWork( - current$$1, - workInProgress, - renderExpirationTime - ); - break a; - } - Component = 0; - } else if ( - ((props = unmaskedContext.value), - (props === Component && - (0 !== props || 1 / props === 1 / Component)) || - (props !== props && Component !== Component)) - ) { - if ( - unmaskedContext.children === fn.children && - !didPerformWorkStackCursor.current - ) { - workInProgress.stateNode = 0; - pushProvider(workInProgress); - current$$1 = bailoutOnAlreadyFinishedWork( - current$$1, - workInProgress, - renderExpirationTime - ); - break a; - } - Component = 0; - } else if ( - ((Component = - "function" === typeof updateExpirationTime._calculateChangedBits - ? updateExpirationTime._calculateChangedBits(props, Component) - : 1073741823), - (Component |= 0), - 0 === Component) - ) { - if ( - unmaskedContext.children === fn.children && - !didPerformWorkStackCursor.current - ) { - workInProgress.stateNode = 0; - pushProvider(workInProgress); - current$$1 = bailoutOnAlreadyFinishedWork( - current$$1, - workInProgress, - renderExpirationTime - ); - break a; - } - } else - propagateContextChange( - workInProgress, - updateExpirationTime, - Component, - renderExpirationTime - ); - workInProgress.stateNode = Component; - pushProvider(workInProgress); + _Component5 = workInProgress.pendingProps; + var oldProps = workInProgress.memoizedProps, + newValue = _Component5.value; + workInProgress.memoizedProps = _Component5; + pushProvider(workInProgress, newValue); + if (null !== oldProps) { + var oldValue = oldProps.value; + newValue = + (oldValue === newValue && + (0 !== oldValue || 1 / oldValue === 1 / newValue)) || + (oldValue !== oldValue && newValue !== newValue) + ? 0 + : ("function" === + typeof updateExpirationTime._calculateChangedBits + ? updateExpirationTime._calculateChangedBits( + oldValue, + newValue + ) + : 1073741823) | 0; + if (0 === newValue) { + if ( + oldProps.children === _Component5.children && + !didPerformWorkStackCursor.current + ) { + workInProgress = bailoutOnAlreadyFinishedWork( + current$$1, + workInProgress, + renderExpirationTime + ); + break a; + } + } else + for ( + oldProps = workInProgress.child, + null !== oldProps && (oldProps.return = workInProgress); + null !== oldProps; + + ) { + oldValue = oldProps.firstContextDependency; + if (null !== oldValue) { + do { + if ( + oldValue.context === updateExpirationTime && + 0 !== (oldValue.observedBits & newValue) + ) { + if (2 === oldProps.tag || 3 === oldProps.tag) { + var nextFiber = createUpdate(renderExpirationTime); + nextFiber.tag = 2; + enqueueUpdate(oldProps, nextFiber); + } + if ( + 0 === oldProps.expirationTime || + oldProps.expirationTime > renderExpirationTime + ) + oldProps.expirationTime = renderExpirationTime; + nextFiber = oldProps.alternate; + null !== nextFiber && + (0 === nextFiber.expirationTime || + nextFiber.expirationTime > renderExpirationTime) && + (nextFiber.expirationTime = renderExpirationTime); + for (var node = oldProps.return; null !== node; ) { + nextFiber = node.alternate; + if ( + 0 === node.childExpirationTime || + node.childExpirationTime > renderExpirationTime + ) + (node.childExpirationTime = renderExpirationTime), + null !== nextFiber && + (0 === nextFiber.childExpirationTime || + nextFiber.childExpirationTime > + renderExpirationTime) && + (nextFiber.childExpirationTime = renderExpirationTime); + else if ( + null !== nextFiber && + (0 === nextFiber.childExpirationTime || + nextFiber.childExpirationTime > renderExpirationTime) + ) + nextFiber.childExpirationTime = renderExpirationTime; + else break; + node = node.return; + } + } + nextFiber = oldProps.child; + oldValue = oldValue.next; + } while (null !== oldValue); + } else + nextFiber = + 12 === oldProps.tag + ? oldProps.type === workInProgress.type + ? null + : oldProps.child + : oldProps.child; + if (null !== nextFiber) nextFiber.return = oldProps; + else + for (nextFiber = oldProps; null !== nextFiber; ) { + if (nextFiber === workInProgress) { + nextFiber = null; + break; + } + oldProps = nextFiber.sibling; + if (null !== oldProps) { + oldProps.return = nextFiber.return; + nextFiber = oldProps; + break; + } + nextFiber = nextFiber.return; + } + oldProps = nextFiber; + } + } reconcileChildren( current$$1, workInProgress, - fn.children, + _Component5.children, renderExpirationTime ); - current$$1 = workInProgress.child; + workInProgress = workInProgress.child; } - return current$$1; - case 12: + return workInProgress; + case 11: return ( - (unmaskedContext = workInProgress.type), + (newValue = workInProgress.type), (updateExpirationTime = workInProgress.pendingProps), - (fn = updateExpirationTime.children), + (_Component5 = updateExpirationTime.children), prepareToReadContext(workInProgress, renderExpirationTime), - (unmaskedContext = readContext( - unmaskedContext, + (newValue = readContext( + newValue, updateExpirationTime.unstable_observedBits )), - (fn = fn(unmaskedContext)), + (_Component5 = _Component5(newValue)), (workInProgress.effectTag |= 1), - reconcileChildren(current$$1, workInProgress, fn, renderExpirationTime), + reconcileChildren( + current$$1, + workInProgress, + _Component5, + renderExpirationTime + ), (workInProgress.memoizedProps = updateExpirationTime), workInProgress.child ); @@ -4008,9 +4107,9 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { } function appendAllChildren(parent, workInProgress) { for (var node = workInProgress.child; null !== node; ) { - if (5 === node.tag || 6 === node.tag) + if (7 === node.tag || 8 === node.tag) FabricUIManager.appendChild(parent.node, node.stateNode.node); - else if (4 !== node.tag && null !== node.child) { + else if (6 !== node.tag && null !== node.child) { node.child.return = node; node = node.child; continue; @@ -4033,9 +4132,9 @@ updateHostContainer = function(workInProgress) { var container = portalOrRoot.containerInfo, newChildSet = FabricUIManager.createChildSet(container); a: for (var node = workInProgress.child; null !== node; ) { - if (5 === node.tag || 6 === node.tag) + if (7 === node.tag || 8 === node.tag) FabricUIManager.appendChildToSet(newChildSet, node.stateNode.node); - else if (4 !== node.tag && null !== node.child) { + else if (6 !== node.tag && null !== node.child) { node.child.return = node; node = node.child; continue; @@ -4053,35 +4152,48 @@ updateHostContainer = function(workInProgress) { FabricUIManager.completeRoot(container, newChildSet); } }; -updateHostComponent$1 = function(current, workInProgress, updatePayload) { - var childrenUnchanged = null === workInProgress.firstEffect; - current = current.stateNode; - if (childrenUnchanged && null === updatePayload) - workInProgress.stateNode = current; +updateHostComponent$1 = function(current, workInProgress, type, newProps) { + type = current.stateNode; + var oldProps = current.memoizedProps; + if ((current = null === workInProgress.firstEffect) && oldProps === newProps) + workInProgress.stateNode = type; else { - var node = current.node; - updatePayload = { - node: childrenUnchanged - ? null !== updatePayload - ? FabricUIManager.cloneNodeWithNewProps( - node, - updatePayload, - workInProgress - ) - : FabricUIManager.cloneNode(node, workInProgress) - : null !== updatePayload - ? FabricUIManager.cloneNodeWithNewChildrenAndProps( - node, - updatePayload, - workInProgress - ) - : FabricUIManager.cloneNodeWithNewChildren(node, workInProgress), - canonical: current.canonical - }; - workInProgress.stateNode = updatePayload; - childrenUnchanged - ? (workInProgress.effectTag |= 4) - : appendAllChildren(updatePayload, workInProgress); + var recyclableInstance = workInProgress.stateNode; + requiredContext(contextStackCursor$1.current); + var updatePayload = null; + oldProps !== newProps && + ((oldProps = diffProperties( + null, + oldProps, + newProps, + recyclableInstance.canonical.viewConfig.validAttributes + )), + (recyclableInstance.canonical.currentProps = newProps), + (updatePayload = oldProps)); + current && null === updatePayload + ? (workInProgress.stateNode = type) + : ((newProps = updatePayload), + (recyclableInstance = type.node), + (type = { + node: current + ? null !== newProps + ? FabricUIManager.cloneNodeWithNewProps( + recyclableInstance, + newProps + ) + : FabricUIManager.cloneNode(recyclableInstance) + : null !== newProps + ? FabricUIManager.cloneNodeWithNewChildrenAndProps( + recyclableInstance, + newProps + ) + : FabricUIManager.cloneNodeWithNewChildren(recyclableInstance), + canonical: type.canonical + }), + (workInProgress.stateNode = type), + current + ? (workInProgress.effectTag |= 4) + : appendAllChildren(type, workInProgress)); } }; updateHostText$1 = function(current, workInProgress, oldText, newText) { @@ -4096,35 +4208,52 @@ updateHostText$1 = function(current, workInProgress, oldText, newText) { )), (workInProgress.effectTag |= 4)); }; +function logCapturedError(capturedError) { + var componentStack = capturedError.componentStack, + error = capturedError.error; + if (error instanceof Error) { + capturedError = error.message; + var name = error.name; + try { + error.message = + (capturedError ? name + ": " + capturedError : name) + + "\n\nThis error is located at:" + + componentStack; + } catch (e) {} + } else + error = + "string" === typeof error + ? Error(error + "\n\nThis error is located at:" + componentStack) + : Error("Unspecified error at:" + componentStack); + ExceptionsManager.handleException(error, !1); +} function logError(boundary, errorInfo) { var source = errorInfo.source, stack = errorInfo.stack; null === stack && null !== source && (stack = getStackByFiberInDevAndProd(source)); - null !== source && getComponentName(source.type); - source = null !== stack ? stack : ""; - errorInfo = errorInfo.value; - null !== boundary && 2 === boundary.tag && getComponentName(boundary.type); + errorInfo = { + componentName: null !== source ? getComponentName(source.type) : null, + componentStack: null !== stack ? stack : "", + error: errorInfo.value, + errorBoundary: null, + errorBoundaryName: null, + errorBoundaryFound: !1, + willRetry: !1 + }; + null !== boundary && + 2 === boundary.tag && + ((errorInfo.errorBoundary = boundary.stateNode), + (errorInfo.errorBoundaryName = getComponentName(boundary.type)), + (errorInfo.errorBoundaryFound = !0), + (errorInfo.willRetry = !0)); try { - if (errorInfo instanceof Error) { - var message = errorInfo.message, - name = errorInfo.name; - var errorToHandle = errorInfo; - try { - errorToHandle.message = - (message ? name + ": " + message : name) + - "\n\nThis error is located at:" + - source; - } catch (e) {} - } else - errorToHandle = - "string" === typeof errorInfo - ? Error(errorInfo + "\n\nThis error is located at:" + source) - : Error("Unspecified error at:" + source); - ExceptionsManager.handleException(errorToHandle, !1); + logCapturedError(errorInfo); } catch (e) { - (e && e.suppressReactErrorLogging) || console.error(e); + setTimeout(function() { + throw e; + }); } } function safelyDetachRef(current$$1) { @@ -4141,14 +4270,15 @@ function safelyDetachRef(current$$1) { function commitWork(current$$1, finishedWork) { switch (finishedWork.tag) { case 2: + case 3: + break; + case 7: + break; + case 8: break; case 5: - break; case 6: break; - case 3: - case 4: - break; default: invariant( !1, @@ -4189,13 +4319,23 @@ function createClassErrorUpdate(fiber, errorInfo, expirationTime) { function unwindWork(workInProgress) { switch (workInProgress.tag) { case 2: - popContextProvider(workInProgress); + isContextProvider(workInProgress.type) && popContext(workInProgress); var effectTag = workInProgress.effectTag; return effectTag & 1024 ? ((workInProgress.effectTag = (effectTag & -1025) | 64), workInProgress) : null; case 3: + return ( + isContextProvider(workInProgress.type._reactResult) && + popContext(workInProgress), + (effectTag = workInProgress.effectTag), + effectTag & 1024 + ? ((workInProgress.effectTag = (effectTag & -1025) | 64), + workInProgress) + : null + ); + case 5: return ( popHostContainer(workInProgress), popTopLevelContextObject(workInProgress), @@ -4207,7 +4347,7 @@ function unwindWork(workInProgress) { (workInProgress.effectTag = (effectTag & -1025) | 64), workInProgress ); - case 5: + case 7: return popHostContext(workInProgress), null; case 16: return ( @@ -4217,9 +4357,9 @@ function unwindWork(workInProgress) { workInProgress) : null ); - case 4: + case 6: return popHostContainer(workInProgress), null; - case 13: + case 12: return popProvider(workInProgress), null; default: return null; @@ -4227,8 +4367,6 @@ function unwindWork(workInProgress) { } var Dispatcher = { readContext: readContext }, ReactCurrentOwner$2 = ReactSharedInternals.ReactCurrentOwner, - lastUniqueAsyncExpiration = 0, - expirationContext = 0, isWorking = !1, nextUnitOfWork = null, nextRoot = null, @@ -4247,19 +4385,30 @@ function resetStack() { var interruptedWork$jscomp$0 = interruptedWork; switch (interruptedWork$jscomp$0.tag) { case 2: - popContextProvider(interruptedWork$jscomp$0); + var childContextTypes = + interruptedWork$jscomp$0.type.childContextTypes; + null !== childContextTypes && + void 0 !== childContextTypes && + popContext(interruptedWork$jscomp$0); break; case 3: + childContextTypes = + interruptedWork$jscomp$0.type._reactResult.childContextTypes; + null !== childContextTypes && + void 0 !== childContextTypes && + popContext(interruptedWork$jscomp$0); + break; + case 5: popHostContainer(interruptedWork$jscomp$0); popTopLevelContextObject(interruptedWork$jscomp$0); break; - case 5: + case 7: popHostContext(interruptedWork$jscomp$0); break; - case 4: + case 6: popHostContainer(interruptedWork$jscomp$0); break; - case 13: + case 12: popProvider(interruptedWork$jscomp$0); } interruptedWork = interruptedWork.return; @@ -4277,136 +4426,129 @@ function completeUnitOfWork(workInProgress) { if (0 === (workInProgress.effectTag & 512)) { var current = current$$1; current$$1 = workInProgress; - var newProps = current$$1.pendingProps; + var instance = current$$1.pendingProps; switch (current$$1.tag) { + case 0: case 1: break; case 2: - popContextProvider(current$$1); + isContextProvider(current$$1.type) && popContext(current$$1); break; case 3: + isContextProvider(current$$1.type._reactResult) && + popContext(current$$1); + break; + case 5: popHostContainer(current$$1); popTopLevelContextObject(current$$1); - var fiberRoot = current$$1.stateNode; - fiberRoot.pendingContext && - ((fiberRoot.context = fiberRoot.pendingContext), - (fiberRoot.pendingContext = null)); + instance = current$$1.stateNode; + instance.pendingContext && + ((instance.context = instance.pendingContext), + (instance.pendingContext = null)); if (null === current || null === current.child) current$$1.effectTag &= -3; updateHostContainer(current$$1); break; - case 5: + case 7: popHostContext(current$$1); - fiberRoot = requiredContext(rootInstanceStackCursor.current); - var type = current$$1.type; - if (null !== current && null != current$$1.stateNode) { - var oldProps = current.memoizedProps, - instance = current$$1.stateNode, - currentHostContext = requiredContext( - contextStackCursor$1.current - ), - newProps$jscomp$0 = newProps, - updatePayload = diffProperties( - null, - oldProps, - newProps$jscomp$0, - instance.canonical.viewConfig.validAttributes - ); - instance.canonical.currentProps = newProps$jscomp$0; + var rootContainerInstance = requiredContext( + rootInstanceStackCursor.current + ), + type = current$$1.type; + if (null !== current && null != current$$1.stateNode) updateHostComponent$1( current, current$$1, - updatePayload, type, - oldProps, - newProps, - fiberRoot, - currentHostContext + instance, + rootContainerInstance + ), + current.ref !== current$$1.ref && (current$$1.effectTag |= 128); + else if (instance) { + var currentHostContext = requiredContext( + contextStackCursor$1.current + ), + internalInstanceHandle = current$$1; + current = nextReactTag; + nextReactTag += 2; + var viewConfig = ReactNativeViewConfigRegistry.get(type); + invariant( + "RCTView" !== type || !currentHostContext.isInAParentText, + "Nesting of within is not currently supported." ); - current.ref !== current$$1.ref && (current$$1.effectTag |= 128); + type = diffProperties( + null, + emptyObject, + instance, + viewConfig.validAttributes + ); + rootContainerInstance = FabricUIManager.createNode( + current, + viewConfig.uiViewClassName, + rootContainerInstance, + type, + internalInstanceHandle + ); + instance = new ReactFabricHostComponent( + current, + viewConfig, + instance + ); + instance = { node: rootContainerInstance, canonical: instance }; + appendAllChildren(instance, current$$1); + current$$1.stateNode = instance; + null !== current$$1.ref && (current$$1.effectTag |= 128); } else - newProps - ? ((oldProps = requiredContext(contextStackCursor$1.current)), - (current = newProps), - (instance = oldProps), - (currentHostContext = current$$1), - (newProps = nextReactTag), - (nextReactTag += 2), - (oldProps = ReactNativeViewConfigRegistry.get(type)), - invariant( - "RCTView" !== type || !instance.isInAParentText, - "Nesting of within is not currently supported." - ), - (type = diffProperties( - null, - emptyObject, - current, - oldProps.validAttributes - )), - (fiberRoot = FabricUIManager.createNode( - newProps, - oldProps.uiViewClassName, - fiberRoot, - type, - currentHostContext - )), - (current = new ReactFabricHostComponent( - newProps, - oldProps, - current - )), - (fiberRoot = { node: fiberRoot, canonical: current }), - appendAllChildren(fiberRoot, current$$1), - (current$$1.stateNode = fiberRoot), - null !== current$$1.ref && (current$$1.effectTag |= 128)) - : invariant( - null !== current$$1.stateNode, - "We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue." - ); + invariant( + null !== current$$1.stateNode, + "We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue." + ); break; - case 6: - fiberRoot = newProps; + case 8: current && null != current$$1.stateNode ? updateHostText$1( current, current$$1, current.memoizedProps, - fiberRoot + instance ) - : ("string" !== typeof fiberRoot && + : ("string" !== typeof instance && invariant( null !== current$$1.stateNode, "We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue." ), - (current = requiredContext(rootInstanceStackCursor.current)), - (newProps = requiredContext(contextStackCursor$1.current)), + (rootContainerInstance = requiredContext( + rootInstanceStackCursor.current + )), + (current = requiredContext(contextStackCursor$1.current)), (current$$1.stateNode = createTextInstance( - fiberRoot, + instance, + rootContainerInstance, current, - newProps, current$$1 ))); break; + case 13: case 14: break; case 16: break; - case 10: + case 9: break; - case 11: + case 10: break; case 15: break; - case 4: + case 6: popHostContainer(current$$1); updateHostContainer(current$$1); break; - case 13: + case 12: popProvider(current$$1); break; - case 12: + case 11: break; - case 0: + case 4: invariant( !1, "An indeterminate component should have become determinate before completing. This error is likely caused by a bug in React. Please file an issue." @@ -4418,21 +4560,28 @@ function completeUnitOfWork(workInProgress) { ); } current$$1 = nextUnitOfWork = null; - fiberRoot = workInProgress; + instance = workInProgress; if ( 1073741823 === nextRenderExpirationTime || - 1073741823 !== fiberRoot.childExpirationTime + 1073741823 !== instance.childExpirationTime ) { - current = 0; - for (newProps = fiberRoot.child; null !== newProps; ) { - type = newProps.expirationTime; - oldProps = newProps.childExpirationTime; - if (0 === current || (0 !== type && type < current)) current = type; - if (0 === current || (0 !== oldProps && oldProps < current)) - current = oldProps; - newProps = newProps.sibling; + rootContainerInstance = 0; + for (current = instance.child; null !== current; ) { + viewConfig = current.expirationTime; + type = current.childExpirationTime; + if ( + 0 === rootContainerInstance || + (0 !== viewConfig && viewConfig < rootContainerInstance) + ) + rootContainerInstance = viewConfig; + if ( + 0 === rootContainerInstance || + (0 !== type && type < rootContainerInstance) + ) + rootContainerInstance = type; + current = current.sibling; } - fiberRoot.childExpirationTime = current; + instance.childExpirationTime = rootContainerInstance; } if (null !== current$$1) return current$$1; null !== returnFiber && @@ -4526,7 +4675,7 @@ function renderRoot(root, isYieldy, isExpired) { value = createCapturedValue(value, sourceFiber$jscomp$0); do { switch (returnFiber$jscomp$0.tag) { - case 3: + case 5: returnFiber$jscomp$0.effectTag |= 1024; returnFiber$jscomp$0.expirationTime = returnFiber; returnFiber = createRootErrorUpdate( @@ -4537,6 +4686,7 @@ function renderRoot(root, isYieldy, isExpired) { enqueueCapturedUpdate(returnFiber$jscomp$0, returnFiber); break a; case 2: + case 3: sourceFiber$jscomp$0 = value; var instance = returnFiber$jscomp$0.stateNode; if ( @@ -4637,6 +4787,7 @@ function captureCommitPhaseError(fiber, error) { ) { switch (JSCompiler_inline_result.tag) { case 2: + case 3: var instance = JSCompiler_inline_result.stateNode; if ( "function" === @@ -4653,7 +4804,7 @@ function captureCommitPhaseError(fiber, error) { break a; } break; - case 3: + case 5: fiber = createCapturedValue(error, fiber); fiber = createRootErrorUpdate(JSCompiler_inline_result, fiber, 1); enqueueUpdate(JSCompiler_inline_result, fiber); @@ -4663,7 +4814,7 @@ function captureCommitPhaseError(fiber, error) { } JSCompiler_inline_result = JSCompiler_inline_result.return; } - 3 === fiber.tag && + 5 === fiber.tag && ((JSCompiler_inline_result = createCapturedValue(error, fiber)), (JSCompiler_inline_result = createRootErrorUpdate( fiber, @@ -4677,22 +4828,20 @@ function captureCommitPhaseError(fiber, error) { return JSCompiler_inline_result; } function computeExpirationForFiber(currentTime, fiber) { - 0 !== expirationContext - ? (currentTime = expirationContext) - : isWorking - ? (currentTime = isCommitting$1 ? 1 : nextRenderExpirationTime) - : fiber.mode & 1 - ? ((currentTime = isBatchingInteractiveUpdates - ? 2 + 10 * ((((currentTime - 2 + 15) / 10) | 0) + 1) - : 2 + 25 * ((((currentTime - 2 + 500) / 25) | 0) + 1)), - null !== nextRoot && - currentTime === nextRenderExpirationTime && - (currentTime += 1)) - : (currentTime = 1); + isWorking + ? (currentTime = isCommitting$1 ? 1 : nextRenderExpirationTime) + : fiber.mode & 1 + ? ((currentTime = isBatchingInteractiveUpdates + ? 2 + 10 * ((((currentTime - 2 + 15) / 10) | 0) + 1) + : 2 + 25 * ((((currentTime - 2 + 500) / 25) | 0) + 1)), + null !== nextRoot && + currentTime === nextRenderExpirationTime && + (currentTime += 1)) + : (currentTime = 1); isBatchingInteractiveUpdates && - (0 === lowestPendingInteractiveExpirationTime || - currentTime > lowestPendingInteractiveExpirationTime) && - (lowestPendingInteractiveExpirationTime = currentTime); + (0 === lowestPriorityPendingInteractiveExpirationTime || + currentTime > lowestPriorityPendingInteractiveExpirationTime) && + (lowestPriorityPendingInteractiveExpirationTime = currentTime); return currentTime; } function scheduleWork(fiber, expirationTime) { @@ -4705,7 +4854,7 @@ function scheduleWork(fiber, expirationTime) { alternate.expirationTime > expirationTime) && (alternate.expirationTime = expirationTime); var node = fiber.return; - if (null === node && 3 === fiber.tag) fiber = fiber.stateNode; + if (null === node && 5 === fiber.tag) fiber = fiber.stateNode; else { for (; null !== node; ) { alternate = node.alternate; @@ -4718,7 +4867,7 @@ function scheduleWork(fiber, expirationTime) { (0 === alternate.childExpirationTime || alternate.childExpirationTime > expirationTime) && (alternate.childExpirationTime = expirationTime); - if (null === node.return && 3 === node.tag) { + if (null === node.return && 5 === node.tag) { fiber = node.stateNode; break a; } @@ -4727,28 +4876,43 @@ function scheduleWork(fiber, expirationTime) { fiber = null; } } - null !== fiber && - (!isWorking && + if (null !== fiber) { + !isWorking && 0 !== nextRenderExpirationTime && expirationTime < nextRenderExpirationTime && - resetStack(), - markPendingPriorityLevel(fiber, expirationTime), - (isWorking && !isCommitting$1 && nextRoot === fiber) || - requestWork(fiber, fiber.expirationTime), + resetStack(); + markPendingPriorityLevel(fiber, expirationTime); + if (!isWorking || isCommitting$1 || nextRoot !== fiber) { + expirationTime = fiber; + fiber = fiber.expirationTime; + if (null === expirationTime.nextScheduledRoot) + (expirationTime.expirationTime = fiber), + null === lastScheduledRoot + ? ((firstScheduledRoot = lastScheduledRoot = expirationTime), + (expirationTime.nextScheduledRoot = expirationTime)) + : ((lastScheduledRoot = lastScheduledRoot.nextScheduledRoot = expirationTime), + (lastScheduledRoot.nextScheduledRoot = firstScheduledRoot)); + else if ( + ((alternate = expirationTime.expirationTime), + 0 === alternate || fiber < alternate) + ) + expirationTime.expirationTime = fiber; + isRendering || + (isBatchingUpdates + ? isUnbatchingUpdates && + ((nextFlushedRoot = expirationTime), + (nextFlushedExpirationTime = 1), + performWorkOnRoot(expirationTime, 1, !0)) + : 1 === fiber + ? performWork(1, null) + : scheduleCallbackWithExpirationTime(expirationTime, fiber)); + } nestedUpdateCount > NESTED_UPDATE_LIMIT && ((nestedUpdateCount = 0), invariant( !1, "Maximum update depth exceeded. This can happen when a component repeatedly calls setState inside componentWillUpdate or componentDidUpdate. React limits the number of nested updates to prevent infinite loops." - ))); -} -function syncUpdates(fn, a, b, c, d) { - var previousExpirationContext = expirationContext; - expirationContext = 1; - try { - return fn(a, b, c, d); - } finally { - expirationContext = previousExpirationContext; + )); } } var firstScheduledRoot = null, @@ -4758,7 +4922,7 @@ var firstScheduledRoot = null, isRendering = !1, nextFlushedRoot = null, nextFlushedExpirationTime = 0, - lowestPendingInteractiveExpirationTime = 0, + lowestPriorityPendingInteractiveExpirationTime = 0, deadlineDidExpire = !1, hasUnhandledError = !1, unhandledError = null, @@ -4777,14 +4941,11 @@ var firstScheduledRoot = null, function recomputeCurrentRendererTime() { currentRendererTime = (((now$1() - originalStartTimeMs) / 10) | 0) + 2; } -function scheduleCallbackWithExpirationTime(expirationTime) { +function scheduleCallbackWithExpirationTime(root, expirationTime) { if (0 !== callbackExpirationTime) { if (expirationTime > callbackExpirationTime) return; - if (null !== callbackID) { - var callbackID$jscomp$0 = callbackID; - scheduledCallback = null; - clearTimeout(callbackID$jscomp$0); - } + null !== callbackID && + ((root = callbackID), (scheduledCallback = null), clearTimeout(root)); } callbackExpirationTime = expirationTime; now$1(); @@ -4802,32 +4963,6 @@ function requestCurrentTime() { (currentSchedulerTime = currentRendererTime); return currentSchedulerTime; } -function requestWork(root, expirationTime) { - if (null === root.nextScheduledRoot) - (root.expirationTime = expirationTime), - null === lastScheduledRoot - ? ((firstScheduledRoot = lastScheduledRoot = root), - (root.nextScheduledRoot = root)) - : ((lastScheduledRoot = lastScheduledRoot.nextScheduledRoot = root), - (lastScheduledRoot.nextScheduledRoot = firstScheduledRoot)); - else { - var remainingExpirationTime = root.expirationTime; - if ( - 0 === remainingExpirationTime || - expirationTime < remainingExpirationTime - ) - root.expirationTime = expirationTime; - } - isRendering || - (isBatchingUpdates - ? isUnbatchingUpdates && - ((nextFlushedRoot = root), - (nextFlushedExpirationTime = 1), - performWorkOnRoot(root, 1, !0)) - : 1 === expirationTime - ? performWork(1, null) - : scheduleCallbackWithExpirationTime(expirationTime)); -} function findHighestPriorityRoot() { var highestPriorityWork = 0, highestPriorityRoot = null; @@ -4868,6 +5003,7 @@ function findHighestPriorityRoot() { (highestPriorityWork = remainingExpirationTime), (highestPriorityRoot = root); if (root === lastScheduledRoot) break; + if (1 === highestPriorityWork) break; previousScheduledRoot = root; root = root.nextScheduledRoot; } @@ -4876,6 +5012,17 @@ function findHighestPriorityRoot() { nextFlushedExpirationTime = highestPriorityWork; } function performAsyncWork(dl) { + if (dl.didTimeout && null !== firstScheduledRoot) { + recomputeCurrentRendererTime(); + var root = firstScheduledRoot; + do { + var expirationTime = root.expirationTime; + 0 !== expirationTime && + currentRendererTime >= expirationTime && + (root.nextExpirationTimeToWorkOn = currentRendererTime); + root = root.nextScheduledRoot; + } while (root !== firstScheduledRoot); + } performWork(0, dl); } function performWork(minExpirationTime, dl) { @@ -4913,7 +5060,10 @@ function performWork(minExpirationTime, dl) { findHighestPriorityRoot(); null !== deadline && ((callbackExpirationTime = 0), (callbackID = null)); 0 !== nextFlushedExpirationTime && - scheduleCallbackWithExpirationTime(nextFlushedExpirationTime); + scheduleCallbackWithExpirationTime( + nextFlushedRoot, + nextFlushedExpirationTime + ); deadline = null; deadlineDidExpire = !1; nestedUpdateCount = 0; @@ -5041,33 +5191,36 @@ function completeRoot$1(root, finishedWork$jscomp$0, expirationTime) { try { for (; null !== nextEffect; ) { if (nextEffect.effectTag & 256) { - var current$$1 = nextEffect.alternate, - finishedWork = nextEffect; - switch (finishedWork.tag) { - case 2: - if (finishedWork.effectTag & 256 && null !== current$$1) { - var prevProps = current$$1.memoizedProps, - prevState = current$$1.memoizedState, - instance = finishedWork.stateNode; - instance.props = finishedWork.memoizedProps; - instance.state = finishedWork.memoizedState; - var snapshot = instance.getSnapshotBeforeUpdate( - prevProps, - prevState + var current$$1 = nextEffect.alternate; + a: { + var finishedWork = nextEffect; + switch (finishedWork.tag) { + case 2: + case 3: + if (finishedWork.effectTag & 256 && null !== current$$1) { + var prevProps = current$$1.memoizedProps, + prevState = current$$1.memoizedState, + instance = finishedWork.stateNode; + instance.props = finishedWork.memoizedProps; + instance.state = finishedWork.memoizedState; + var snapshot = instance.getSnapshotBeforeUpdate( + prevProps, + prevState + ); + instance.__reactInternalSnapshotBeforeUpdate = snapshot; + } + break a; + case 5: + case 7: + case 8: + case 6: + break a; + default: + invariant( + !1, + "This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue." ); - instance.__reactInternalSnapshotBeforeUpdate = snapshot; - } - break; - case 3: - case 5: - case 6: - case 4: - break; - default: - invariant( - !1, - "This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue." - ); + } } } nextEffect = nextEffect.nextEffect; @@ -5118,6 +5271,7 @@ function completeRoot$1(root, finishedWork$jscomp$0, expirationTime) { onCommitFiberUnmount(childExpirationTimeBeforeCommit); switch (childExpirationTimeBeforeCommit.tag) { case 2: + case 3: safelyDetachRef(childExpirationTimeBeforeCommit); var instance$jscomp$0 = childExpirationTimeBeforeCommit.stateNode; @@ -5137,10 +5291,10 @@ function completeRoot$1(root, finishedWork$jscomp$0, expirationTime) { ); } break; - case 5: + case 7: safelyDetachRef(childExpirationTimeBeforeCommit); break; - case 4: + case 6: FabricUIManager.createChildSet( childExpirationTimeBeforeCommit.stateNode.containerInfo ); @@ -5190,6 +5344,7 @@ function completeRoot$1(root, finishedWork$jscomp$0, expirationTime) { firstBatch = currentRef; switch (instance$jscomp$0.tag) { case 2: + case 3: var instance$jscomp$1 = instance$jscomp$0.stateNode; if (instance$jscomp$0.effectTag & 4) if (null === current$$1$jscomp$1) @@ -5218,16 +5373,17 @@ function completeRoot$1(root, finishedWork$jscomp$0, expirationTime) { firstBatch )); break; - case 3: + case 5: var _updateQueue = instance$jscomp$0.updateQueue; if (null !== _updateQueue) { current$$1 = null; if (null !== instance$jscomp$0.child) switch (instance$jscomp$0.child.tag) { - case 5: + case 7: current$$1 = instance$jscomp$0.child.stateNode.canonical; break; case 2: + case 3: current$$1 = instance$jscomp$0.child.stateNode; } commitUpdateQueue( @@ -5238,7 +5394,7 @@ function completeRoot$1(root, finishedWork$jscomp$0, expirationTime) { ); } break; - case 5: + case 7: null === current$$1$jscomp$1 && instance$jscomp$0.effectTag & 4 && invariant( @@ -5246,9 +5402,9 @@ function completeRoot$1(root, finishedWork$jscomp$0, expirationTime) { "The current renderer does not support mutation. This error is likely caused by a bug in React. Please file an issue." ); break; - case 6: + case 8: break; - case 4: + case 6: break; case 15: break; @@ -5262,20 +5418,19 @@ function completeRoot$1(root, finishedWork$jscomp$0, expirationTime) { } } if (effectTag$jscomp$0 & 128) { - instance$jscomp$0 = void 0; var ref = nextEffect.ref; if (null !== ref) { var instance$jscomp$2 = nextEffect.stateNode; switch (nextEffect.tag) { - case 5: - instance$jscomp$0 = instance$jscomp$2.canonical; + case 7: + var instanceToUse = instance$jscomp$2.canonical; break; default: - instance$jscomp$0 = instance$jscomp$2; + instanceToUse = instance$jscomp$2; } "function" === typeof ref - ? ref(instance$jscomp$0) - : (ref.current = instance$jscomp$0); + ? ref(instanceToUse) + : (ref.current = instanceToUse); } } var next = nextEffect.nextEffect; @@ -5323,51 +5478,54 @@ function onUncaughtError(error) { nextFlushedRoot.expirationTime = 0; hasUnhandledError || ((hasUnhandledError = !0), (unhandledError = error)); } -function updateContainerAtExpirationTime( - element, - container, - parentComponent, - expirationTime, - callback -) { - var current$$1 = container.current; - if (parentComponent) { - parentComponent = parentComponent._reactInternalFiber; - var parentContext; - b: { - invariant( - 2 === isFiberMountedImpl(parentComponent) && 2 === parentComponent.tag, - "Expected subtree parent to be a mounted class component. This error is likely caused by a bug in React. Please file an issue." - ); - for (parentContext = parentComponent; 3 !== parentContext.tag; ) { - if (isContextProvider(parentContext)) { - parentContext = - parentContext.stateNode.__reactInternalMemoizedMergedChildContext; - break b; - } - parentContext = parentContext.return; - invariant( - parentContext, - "Found unexpected detached subtree parent. This error is likely caused by a bug in React. Please file an issue." - ); +function getContextForSubtree(parentComponent) { + if (!parentComponent) return emptyContextObject; + parentComponent = parentComponent._reactInternalFiber; + a: { + invariant( + 2 === isFiberMountedImpl(parentComponent) && + (2 === parentComponent.tag || 3 === parentComponent.tag), + "Expected subtree parent to be a mounted class component. This error is likely caused by a bug in React. Please file an issue." + ); + var parentContext = parentComponent; + do { + switch (parentContext.tag) { + case 5: + parentContext = parentContext.stateNode.context; + break a; + case 2: + if (isContextProvider(parentContext.type)) { + parentContext = + parentContext.stateNode.__reactInternalMemoizedMergedChildContext; + break a; + } + break; + case 3: + if (isContextProvider(parentContext.type._reactResult)) { + parentContext = + parentContext.stateNode.__reactInternalMemoizedMergedChildContext; + break a; + } } - parentContext = parentContext.stateNode.context; - } - parentComponent = isContextProvider(parentComponent) - ? processChildContext(parentComponent, parentContext) - : parentContext; - } else parentComponent = emptyContextObject; - null === container.context - ? (container.context = parentComponent) - : (container.pendingContext = parentComponent); - container = callback; - callback = createUpdate(expirationTime); - callback.payload = { element: element }; - container = void 0 === container ? null : container; - null !== container && (callback.callback = container); - enqueueUpdate(current$$1, callback); - scheduleWork(current$$1, expirationTime); - return expirationTime; + parentContext = parentContext.return; + } while (null !== parentContext); + invariant( + !1, + "Found unexpected detached subtree parent. This error is likely caused by a bug in React. Please file an issue." + ); + parentContext = void 0; + } + if (2 === parentComponent.tag) { + var Component = parentComponent.type; + if (isContextProvider(Component)) + return processChildContext(parentComponent, Component, parentContext); + } else if ( + 3 === parentComponent.tag && + ((Component = parentComponent.type._reactResult), + isContextProvider(Component)) + ) + return processChildContext(parentComponent, Component, parentContext); + return parentContext; } function findHostInstance$1(component) { var fiber = component._reactInternalFiber; @@ -5386,153 +5544,20 @@ function updateContainer(element, container, parentComponent, callback) { var current$$1 = container.current, currentTime = requestCurrentTime(); current$$1 = computeExpirationForFiber(currentTime, current$$1); - return updateContainerAtExpirationTime( - element, - container, - parentComponent, - current$$1, - callback - ); + currentTime = container.current; + parentComponent = getContextForSubtree(parentComponent); + null === container.context + ? (container.context = parentComponent) + : (container.pendingContext = parentComponent); + container = callback; + callback = createUpdate(current$$1); + callback.payload = { element: element }; + container = void 0 === container ? null : container; + null !== container && (callback.callback = container); + enqueueUpdate(currentTime, callback); + scheduleWork(currentTime, current$$1); + return current$$1; } -function getPublicRootInstance(container) { - container = container.current; - if (!container.child) return null; - switch (container.child.tag) { - case 5: - return container.child.stateNode.canonical; - default: - return container.child.stateNode; - } -} -function injectIntoDevTools(devToolsConfig) { - var findFiberByHostInstance = devToolsConfig.findFiberByHostInstance; - return injectInternals( - Object.assign({}, devToolsConfig, { - findHostInstanceByFiber: function(fiber) { - fiber = findCurrentHostFiber(fiber); - return null === fiber ? null : fiber.stateNode; - }, - findFiberByHostInstance: function(instance) { - return findFiberByHostInstance - ? findFiberByHostInstance(instance) - : null; - } - }) - ); -} -var ReactFabricRenderer = { - updateContainerAtExpirationTime: updateContainerAtExpirationTime, - createContainer: function(containerInfo, isAsync, hydrate) { - return createFiberRoot(containerInfo, isAsync, hydrate); - }, - updateContainer: updateContainer, - flushRoot: function(root, expirationTime) { - invariant( - !isRendering, - "work.commit(): Cannot commit while already rendering. This likely means you attempted to commit from inside a lifecycle method." - ); - nextFlushedRoot = root; - nextFlushedExpirationTime = expirationTime; - performWorkOnRoot(root, expirationTime, !0); - performWork(1, null); - }, - requestWork: requestWork, - computeUniqueAsyncExpiration: function() { - var result = 2 + 25 * ((((requestCurrentTime() - 2 + 500) / 25) | 0) + 1); - result <= lastUniqueAsyncExpiration && - (result = lastUniqueAsyncExpiration + 1); - return (lastUniqueAsyncExpiration = result); - }, - batchedUpdates: function(fn, a) { - var previousIsBatchingUpdates = isBatchingUpdates; - isBatchingUpdates = !0; - try { - return fn(a); - } finally { - (isBatchingUpdates = previousIsBatchingUpdates) || - isRendering || - performWork(1, null); - } - }, - unbatchedUpdates: function(fn, a) { - if (isBatchingUpdates && !isUnbatchingUpdates) { - isUnbatchingUpdates = !0; - try { - return fn(a); - } finally { - isUnbatchingUpdates = !1; - } - } - return fn(a); - }, - deferredUpdates: function(fn) { - var currentTime = requestCurrentTime(), - previousExpirationContext = expirationContext; - expirationContext = 2 + 25 * ((((currentTime - 2 + 500) / 25) | 0) + 1); - try { - return fn(); - } finally { - expirationContext = previousExpirationContext; - } - }, - syncUpdates: syncUpdates, - interactiveUpdates: function(fn, a, b) { - if (isBatchingInteractiveUpdates) return fn(a, b); - isBatchingUpdates || - isRendering || - 0 === lowestPendingInteractiveExpirationTime || - (performWork(lowestPendingInteractiveExpirationTime, null), - (lowestPendingInteractiveExpirationTime = 0)); - var previousIsBatchingInteractiveUpdates = isBatchingInteractiveUpdates, - previousIsBatchingUpdates = isBatchingUpdates; - isBatchingUpdates = isBatchingInteractiveUpdates = !0; - try { - return fn(a, b); - } finally { - (isBatchingInteractiveUpdates = previousIsBatchingInteractiveUpdates), - (isBatchingUpdates = previousIsBatchingUpdates) || - isRendering || - performWork(1, null); - } - }, - flushInteractiveUpdates: function() { - isRendering || - 0 === lowestPendingInteractiveExpirationTime || - (performWork(lowestPendingInteractiveExpirationTime, null), - (lowestPendingInteractiveExpirationTime = 0)); - }, - flushControlled: function(fn) { - var previousIsBatchingUpdates = isBatchingUpdates; - isBatchingUpdates = !0; - try { - syncUpdates(fn); - } finally { - (isBatchingUpdates = previousIsBatchingUpdates) || - isRendering || - performWork(1, null); - } - }, - flushSync: function(fn, a) { - invariant( - !isRendering, - "flushSync was called from inside a lifecycle method. It cannot be called when React is already rendering." - ); - var previousIsBatchingUpdates = isBatchingUpdates; - isBatchingUpdates = !0; - try { - return syncUpdates(fn, a); - } finally { - (isBatchingUpdates = previousIsBatchingUpdates), performWork(1, null); - } - }, - getPublicRootInstance: getPublicRootInstance, - findHostInstance: findHostInstance$1, - findHostInstanceWithNoPortals: function(fiber) { - fiber = findCurrentHostFiberWithNoPortals(fiber); - return null === fiber ? null : fiber.stateNode; - }, - injectIntoDevTools: injectIntoDevTools -}; function createPortal(children, containerInfo, implementation) { var key = 3 < arguments.length && void 0 !== arguments[3] ? arguments[3] : null; @@ -5580,8 +5605,23 @@ function findNodeHandle(componentOrHandle) { ? componentOrHandle.canonical._nativeTag : componentOrHandle._nativeTag; } -_batchedUpdates = ReactFabricRenderer.batchedUpdates; -_flushInteractiveUpdates = ReactFabricRenderer.flushInteractiveUpdates; +_batchedUpdatesImpl = function(fn, a) { + var previousIsBatchingUpdates = isBatchingUpdates; + isBatchingUpdates = !0; + try { + return fn(a); + } finally { + (isBatchingUpdates = previousIsBatchingUpdates) || + isRendering || + performWork(1, null); + } +}; +_flushInteractiveUpdatesImpl = function() { + isRendering || + 0 === lowestPriorityPendingInteractiveExpirationTime || + (performWork(lowestPriorityPendingInteractiveExpirationTime, null), + (lowestPriorityPendingInteractiveExpirationTime = 0)); +}; var roots = new Map(), ReactFabric = { NativeComponent: (function(findNodeHandle, findHostInstance) { @@ -5609,13 +5649,13 @@ var roots = new Map(), ReactNativeComponent.prototype.measure = function(callback) { UIManager.measure( findNodeHandle(this), - mountSafeCallback(this, callback) + mountSafeCallback_NOT_REALLY_SAFE(this, callback) ); }; ReactNativeComponent.prototype.measureInWindow = function(callback) { UIManager.measureInWindow( findNodeHandle(this), - mountSafeCallback(this, callback) + mountSafeCallback_NOT_REALLY_SAFE(this, callback) ); }; ReactNativeComponent.prototype.measureLayout = function( @@ -5626,8 +5666,8 @@ var roots = new Map(), UIManager.measureLayout( findNodeHandle(this), relativeToNativeNode, - mountSafeCallback(this, onFail), - mountSafeCallback(this, onSuccess) + mountSafeCallback_NOT_REALLY_SAFE(this, onFail), + mountSafeCallback_NOT_REALLY_SAFE(this, onSuccess) ); }; ReactNativeComponent.prototype.setNativeProps = function(nativeProps) { @@ -5658,11 +5698,43 @@ var roots = new Map(), findNodeHandle: findNodeHandle, render: function(element, containerTag, callback) { var root = roots.get(containerTag); - root || - ((root = createFiberRoot(containerTag, !1, !1)), - roots.set(containerTag, root)); + if (!root) { + root = new FiberNode(5, null, null, 0); + var root$jscomp$0 = { + current: root, + containerInfo: containerTag, + pendingChildren: null, + earliestPendingTime: 0, + latestPendingTime: 0, + earliestSuspendedTime: 0, + latestSuspendedTime: 0, + latestPingedTime: 0, + didError: !1, + pendingCommitExpirationTime: 0, + finishedWork: null, + timeoutHandle: -1, + context: null, + pendingContext: null, + hydrate: !1, + nextExpirationTimeToWorkOn: 0, + expirationTime: 0, + firstBatch: null, + nextScheduledRoot: null + }; + root = root.stateNode = root$jscomp$0; + roots.set(containerTag, root); + } updateContainer(element, root, null, callback); - return getPublicRootInstance(root); + a: if (((element = root.current), element.child)) + switch (element.child.tag) { + case 7: + element = element.child.stateNode.canonical; + break a; + default: + element = element.child.stateNode; + } + else element = null; + return element; }, unmountComponentAtNode: function(containerTag) { var root = roots.get(containerTag); @@ -5685,21 +5757,21 @@ var roots = new Map(), measure: function(callback) { UIManager.measure( findNodeHandle(this), - mountSafeCallback(this, callback) + mountSafeCallback_NOT_REALLY_SAFE(this, callback) ); }, measureInWindow: function(callback) { UIManager.measureInWindow( findNodeHandle(this), - mountSafeCallback(this, callback) + mountSafeCallback_NOT_REALLY_SAFE(this, callback) ); }, measureLayout: function(relativeToNativeNode, onSuccess, onFail) { UIManager.measureLayout( findNodeHandle(this), relativeToNativeNode, - mountSafeCallback(this, onFail), - mountSafeCallback(this, onSuccess) + mountSafeCallback_NOT_REALLY_SAFE(this, onFail), + mountSafeCallback_NOT_REALLY_SAFE(this, onSuccess) ); }, setNativeProps: function(nativeProps) { @@ -5733,13 +5805,28 @@ var roots = new Map(), })(findNodeHandle, findHostInstance$1) } }; -injectIntoDevTools({ +(function(devToolsConfig) { + var findFiberByHostInstance = devToolsConfig.findFiberByHostInstance; + return injectInternals( + Object.assign({}, devToolsConfig, { + findHostInstanceByFiber: function(fiber) { + fiber = findCurrentHostFiber(fiber); + return null === fiber ? null : fiber.stateNode; + }, + findFiberByHostInstance: function(instance) { + return findFiberByHostInstance + ? findFiberByHostInstance(instance) + : null; + } + }) + ); +})({ findFiberByHostInstance: getInstanceFromInstance, getInspectorDataForViewTag: getInspectorDataForViewTag, bundleType: 0, - version: "16.4.1", + version: "16.5.0", rendererPackageName: "react-native-renderer" }); var ReactFabric$2 = { default: ReactFabric }, ReactFabric$3 = (ReactFabric$2 && ReactFabric) || ReactFabric$2; -module.exports = ReactFabric$3.default ? ReactFabric$3.default : ReactFabric$3; +module.exports = ReactFabric$3.default || ReactFabric$3; diff --git a/Libraries/Renderer/oss/ReactFabric-profiling.js b/Libraries/Renderer/oss/ReactFabric-profiling.js index 91cc588cc..de00c9c48 100644 --- a/Libraries/Renderer/oss/ReactFabric-profiling.js +++ b/Libraries/Renderer/oss/ReactFabric-profiling.js @@ -1,5 +1,5 @@ /** - * Copyright (c) 2013-present, Facebook, Inc. + * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. @@ -19,6 +19,7 @@ var ReactNativeViewConfigRegistry = require("ReactNativeViewConfigRegistry"), flattenStyle = require("flattenStyle"), TextInputState = require("TextInputState"), FabricUIManager = require("FabricUIManager"), + tracking = require("schedule/tracking"), ExceptionsManager = require("ExceptionsManager"); function invariant(condition, format, a, b, c, d, e, f) { if (!condition) { @@ -41,68 +42,53 @@ function invariant(condition, format, a, b, c, d, e, f) { throw condition; } } -function invokeGuardedCallback(name, func, context, a, b, c, d, e, f) { - this._hasCaughtError = !1; - this._caughtError = null; +function invokeGuardedCallbackImpl(name, func, context, a, b, c, d, e, f) { var funcArgs = Array.prototype.slice.call(arguments, 3); try { func.apply(context, funcArgs); } catch (error) { - (this._caughtError = error), (this._hasCaughtError = !0); + this.onError(error); } } -var ReactErrorUtils = { - _caughtError: null, - _hasCaughtError: !1, - _rethrowError: null, - _hasRethrowError: !1, - invokeGuardedCallback: function(name, func, context, a, b, c, d, e, f) { - invokeGuardedCallback.apply(ReactErrorUtils, arguments); - }, - invokeGuardedCallbackAndCatchFirstError: function( - name, - func, - context, - a, - b, - c, - d, - e, - f - ) { - ReactErrorUtils.invokeGuardedCallback.apply(this, arguments); - if (ReactErrorUtils.hasCaughtError()) { - var error = ReactErrorUtils.clearCaughtError(); - ReactErrorUtils._hasRethrowError || - ((ReactErrorUtils._hasRethrowError = !0), - (ReactErrorUtils._rethrowError = error)); +var hasError = !1, + caughtError = null, + hasRethrowError = !1, + rethrowError = null, + reporter = { + onError: function(error) { + hasError = !0; + caughtError = error; } - }, - rethrowCaughtError: function() { - return rethrowCaughtError.apply(ReactErrorUtils, arguments); - }, - hasCaughtError: function() { - return ReactErrorUtils._hasCaughtError; - }, - clearCaughtError: function() { - if (ReactErrorUtils._hasCaughtError) { - var error = ReactErrorUtils._caughtError; - ReactErrorUtils._caughtError = null; - ReactErrorUtils._hasCaughtError = !1; - return error; - } - invariant( - !1, - "clearCaughtError was called but no error was captured. This error is likely caused by a bug in React. Please file an issue." - ); - } -}; -function rethrowCaughtError() { - if (ReactErrorUtils._hasRethrowError) { - var error = ReactErrorUtils._rethrowError; - ReactErrorUtils._rethrowError = null; - ReactErrorUtils._hasRethrowError = !1; - throw error; + }; +function invokeGuardedCallback(name, func, context, a, b, c, d, e, f) { + hasError = !1; + caughtError = null; + invokeGuardedCallbackImpl.apply(reporter, arguments); +} +function invokeGuardedCallbackAndCatchFirstError( + name, + func, + context, + a, + b, + c, + d, + e, + f +) { + invokeGuardedCallback.apply(this, arguments); + if (hasError) { + if (hasError) { + var error = caughtError; + hasError = !1; + caughtError = null; + } else + invariant( + !1, + "clearCaughtError was called but no error was captured. This error is likely caused by a bug in React. Please file an issue." + ), + (error = void 0); + hasRethrowError || ((hasRethrowError = !0), (rethrowError = error)); } } var eventPluginOrder = null, @@ -184,12 +170,7 @@ var plugins = [], function executeDispatch(event, simulated, listener, inst) { simulated = event.type || "unknown-event"; event.currentTarget = getNodeFromInstance(inst); - ReactErrorUtils.invokeGuardedCallbackAndCatchFirstError( - simulated, - listener, - void 0, - event - ); + invokeGuardedCallbackAndCatchFirstError(simulated, listener, void 0, event); event.currentTarget = null; } function executeDirectDispatch(event) { @@ -313,7 +294,7 @@ function getListener(inst, registrationName) { } function getParent(inst) { do inst = inst.return; - while (inst && 5 !== inst.tag); + while (inst && 7 !== inst.tag); return inst ? inst : null; } function traverseTwoPhase(inst, fn, arg) { @@ -1020,22 +1001,15 @@ injection.injectEventPluginsByName({ function getInstanceFromInstance(instanceHandle) { return instanceHandle; } -var Injected$jscomp$inline_618 = { - getClosestInstanceFromNode: getInstanceFromInstance, - getInstanceFromNode: getInstanceFromInstance, - getNodeFromInstance: function(inst) { - inst = inst.stateNode.canonical._nativeTag; - invariant(inst, "All native instances should have a tag."); - return inst; - }, - getFiberCurrentPropsFromNode: function(inst) { - return inst.canonical.currentProps; - } +getFiberCurrentPropsFromNode = function(inst) { + return inst.canonical.currentProps; +}; +getInstanceFromNode = getInstanceFromInstance; +getNodeFromInstance = function(inst) { + inst = inst.stateNode.canonical._nativeTag; + invariant(inst, "All native instances should have a tag."); + return inst; }; -getFiberCurrentPropsFromNode = - Injected$jscomp$inline_618.getFiberCurrentPropsFromNode; -getInstanceFromNode = Injected$jscomp$inline_618.getInstanceFromNode; -getNodeFromInstance = Injected$jscomp$inline_618.getNodeFromInstance; ResponderEventPlugin.injection.injectGlobalResponderHandler({ onChange: function(from, to, blockNativeResponder) { null !== to @@ -1061,8 +1035,7 @@ var ReactSharedInternals = REACT_PLACEHOLDER_TYPE = hasSymbol ? Symbol.for("react.placeholder") : 60113, MAYBE_ITERATOR_SYMBOL = "function" === typeof Symbol && Symbol.iterator; function getIteratorFn(maybeIterable) { - if (null === maybeIterable || "undefined" === typeof maybeIterable) - return null; + if (null === maybeIterable || "object" !== typeof maybeIterable) return null; maybeIterable = (MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL]) || maybeIterable["@@iterator"]; @@ -1086,7 +1059,7 @@ function getComponentName(type) { case REACT_PLACEHOLDER_TYPE: return "Placeholder"; } - if ("object" === typeof type) + if ("object" === typeof type) { switch (type.$$typeof) { case REACT_CONTEXT_TYPE: return "Context.Consumer"; @@ -1099,6 +1072,12 @@ function getComponentName(type) { "" !== type ? "ForwardRef(" + type + ")" : "ForwardRef" ); } + if ( + "function" === typeof type.then && + (type = 1 === type._reactStatus ? type._reactResult : null) + ) + return getComponentName(type); + } return null; } function isFiberMountedImpl(fiber) { @@ -1109,7 +1088,7 @@ function isFiberMountedImpl(fiber) { for (; node.return; ) if (((node = node.return), 0 !== (node.effectTag & 2))) return 1; } - return 3 === node.tag ? 2 : 3; + return 5 === node.tag ? 2 : 3; } function assertIsMounted(fiber) { invariant( @@ -1185,14 +1164,14 @@ function findCurrentFiberUsingSlowPath(fiber) { "Return fibers should always be each others' alternates. This error is likely caused by a bug in React. Please file an issue." ); } - invariant(3 === a.tag, "Unable to find node on an unmounted component."); + invariant(5 === a.tag, "Unable to find node on an unmounted component."); return a.stateNode.current === a ? fiber : alternate; } function findCurrentHostFiber(parent) { parent = findCurrentFiberUsingSlowPath(parent); if (!parent) return null; for (var node = parent; ; ) { - if (5 === node.tag || 6 === node.tag) return node; + if (7 === node.tag || 8 === node.tag) return node; if (node.child) (node.child.return = node), (node = node.child); else { if (node === parent) break; @@ -1206,37 +1185,13 @@ function findCurrentHostFiber(parent) { } return null; } -function findCurrentHostFiberWithNoPortals(parent) { - parent = findCurrentFiberUsingSlowPath(parent); - if (!parent) return null; - for (var node = parent; ; ) { - if (5 === node.tag || 6 === node.tag) return node; - if (node.child && 4 !== node.tag) - (node.child.return = node), (node = node.child); - else { - if (node === parent) break; - for (; !node.sibling; ) { - if (!node.return || node.return === parent) return null; - node = node.return; - } - node.sibling.return = node.return; - node = node.sibling; - } - } - return null; -} -function mountSafeCallback(context, callback) { +function mountSafeCallback_NOT_REALLY_SAFE(context, callback) { return function() { - if (callback) { - if ("boolean" === typeof context.__isMounted) { - if (!context.__isMounted) return; - } else if ( - "function" === typeof context.isMounted && - !context.isMounted() - ) - return; + if ( + callback && + ("boolean" !== typeof context.__isMounted || context.__isMounted) + ) return callback.apply(context, arguments); - } }; } var emptyObject = {}, @@ -1257,23 +1212,23 @@ function restoreDeletedValuesInNestedArray( else if (node && 0 < removedKeyCount) for (i in removedKeys) if (removedKeys[i]) { - var _nextProp = node[i]; - if (void 0 !== _nextProp) { + var nextProp = node[i]; + if (void 0 !== nextProp) { var attributeConfig = validAttributes[i]; if (attributeConfig) { - "function" === typeof _nextProp && (_nextProp = !0); - "undefined" === typeof _nextProp && (_nextProp = null); + "function" === typeof nextProp && (nextProp = !0); + "undefined" === typeof nextProp && (nextProp = null); if ("object" !== typeof attributeConfig) - updatePayload[i] = _nextProp; + updatePayload[i] = nextProp; else if ( "function" === typeof attributeConfig.diff || "function" === typeof attributeConfig.process ) - (_nextProp = + (nextProp = "function" === typeof attributeConfig.process - ? attributeConfig.process(_nextProp) - : _nextProp), - (updatePayload[i] = _nextProp); + ? attributeConfig.process(nextProp) + : nextProp), + (updatePayload[i] = nextProp); removedKeys[i] = !1; removedKeyCount--; } @@ -1484,27 +1439,27 @@ var restoreTarget = null, function restoreStateOfTarget(target) { if ((target = getInstanceFromNode(target))) { invariant( - null, - "Fiber needs to be injected to handle a fiber target for controlled events. This error is likely caused by a bug in React. Please file an issue." + !1, + "setRestoreImplementation() needs to be called to handle a target for controlled events. This error is likely caused by a bug in React. Please file an issue." ); var props = getFiberCurrentPropsFromNode(target.stateNode); - null.restoreControlledState(target.stateNode, target.type, props); + null(target.stateNode, target.type, props); } } -function _batchedUpdates(fn, bookkeeping) { +function _batchedUpdatesImpl(fn, bookkeeping) { return fn(bookkeeping); } -function _flushInteractiveUpdates() {} +function _flushInteractiveUpdatesImpl() {} var isBatching = !1; function batchedUpdates(fn, bookkeeping) { if (isBatching) return fn(bookkeeping); isBatching = !0; try { - return _batchedUpdates(fn, bookkeeping); + return _batchedUpdatesImpl(fn, bookkeeping); } finally { if (((isBatching = !1), null !== restoreTarget || null !== restoreQueue)) if ( - (_flushInteractiveUpdates(), + (_flushInteractiveUpdatesImpl(), restoreTarget && ((bookkeeping = restoreTarget), (fn = restoreQueue), @@ -1534,13 +1489,19 @@ function dispatchEvent(target, topLevelType, nativeEvent) { null !== events && (eventQueue = accumulateInto(eventQueue, events)); events = eventQueue; eventQueue = null; - events && + if ( + events && (forEachAccumulated(events, executeDispatchesAndReleaseTopLevel), invariant( !eventQueue, "processEventQueue(): Additional events were enqueued while processing an event queue. Support for this has not yet been implemented." ), - ReactErrorUtils.rethrowCaughtError()); + hasRethrowError) + ) + throw ((events = rethrowError), + (hasRethrowError = !1), + (rethrowError = null), + events); }); } function shim$1() { @@ -1567,12 +1528,15 @@ var ReactFabricHostComponent = (function() { TextInputState.focusTextInput(this._nativeTag); }; ReactFabricHostComponent.prototype.measure = function(callback) { - UIManager.measure(this._nativeTag, mountSafeCallback(this, callback)); + UIManager.measure( + this._nativeTag, + mountSafeCallback_NOT_REALLY_SAFE(this, callback) + ); }; ReactFabricHostComponent.prototype.measureInWindow = function(callback) { UIManager.measureInWindow( this._nativeTag, - mountSafeCallback(this, callback) + mountSafeCallback_NOT_REALLY_SAFE(this, callback) ); }; ReactFabricHostComponent.prototype.measureLayout = function( @@ -1583,8 +1547,8 @@ var ReactFabricHostComponent = (function() { UIManager.measureLayout( this._nativeTag, relativeToNativeNode, - mountSafeCallback(this, onFail), - mountSafeCallback(this, onSuccess) + mountSafeCallback_NOT_REALLY_SAFE(this, onFail), + mountSafeCallback_NOT_REALLY_SAFE(this, onSuccess) ); }; ReactFabricHostComponent.prototype.setNativeProps = function(nativeProps) { @@ -1625,33 +1589,36 @@ function createTextInstance( ) }; } +var scheduleTimeout = setTimeout, + BEFORE_SLASH_RE = /^(.*)[\\\/]/; function getStackByFiberInDevAndProd(workInProgress) { var info = ""; do { a: switch (workInProgress.tag) { + case 4: case 0: case 1: case 2: - case 5: - case 11: + case 3: + case 7: + case 10: var owner = workInProgress._debugOwner, - source = workInProgress._debugSource; - var JSCompiler_inline_result = getComponentName(workInProgress.type); - var ownerName = null; - owner && (ownerName = getComponentName(owner.type)); - owner = source; - JSCompiler_inline_result = - "\n in " + - (JSCompiler_inline_result || "Unknown") + - (owner - ? " (at " + - owner.fileName.replace(/^.*[\\\/]/, "") + + source = workInProgress._debugSource, + name = getComponentName(workInProgress.type); + var JSCompiler_inline_result = null; + owner && (JSCompiler_inline_result = getComponentName(owner.type)); + owner = name; + name = ""; + source + ? (name = + " (at " + + source.fileName.replace(BEFORE_SLASH_RE, "") + ":" + - owner.lineNumber + - ")" - : ownerName - ? " (created by " + ownerName + ")" - : ""); + source.lineNumber + + ")") + : JSCompiler_inline_result && + (name = " (created by " + JSCompiler_inline_result + ")"); + JSCompiler_inline_result = "\n in " + (owner || "Unknown") + name; break a; default: JSCompiler_inline_result = ""; @@ -1677,11 +1644,6 @@ var emptyContextObject = {}, contextStackCursor = { current: emptyContextObject }, didPerformWorkStackCursor = { current: !1 }, previousContext = emptyContextObject; -function getUnmaskedContext(workInProgress) { - return isContextProvider(workInProgress) - ? previousContext - : contextStackCursor.current; -} function getMaskedContext(workInProgress, unmaskedContext) { var contextTypes = workInProgress.type.contextTypes; if (!contextTypes) return emptyContextObject; @@ -1700,12 +1662,13 @@ function getMaskedContext(workInProgress, unmaskedContext) { (workInProgress.__reactInternalMemoizedMaskedChildContext = context)); return context; } -function isContextProvider(fiber) { - return 2 === fiber.tag && null != fiber.type.childContextTypes; +function isContextProvider(type) { + type = type.childContextTypes; + return null !== type && void 0 !== type; } -function popContextProvider(fiber) { - isContextProvider(fiber) && - (pop(didPerformWorkStackCursor, fiber), pop(contextStackCursor, fiber)); +function popContext(fiber) { + pop(didPerformWorkStackCursor, fiber); + pop(contextStackCursor, fiber); } function popTopLevelContextObject(fiber) { pop(didPerformWorkStackCursor, fiber); @@ -1719,23 +1682,21 @@ function pushTopLevelContextObject(fiber, context, didChange) { push(contextStackCursor, context, fiber); push(didPerformWorkStackCursor, didChange, fiber); } -function processChildContext(fiber, parentContext) { +function processChildContext(fiber, type, parentContext) { var instance = fiber.stateNode; - fiber = fiber.type; - var childContextTypes = fiber.childContextTypes; + fiber = type.childContextTypes; if ("function" !== typeof instance.getChildContext) return parentContext; instance = instance.getChildContext(); for (var contextKey in instance) invariant( - contextKey in childContextTypes, + contextKey in fiber, '%s.getChildContext(): key "%s" is not defined in childContextTypes.', - getComponentName(fiber) || "Unknown", + getComponentName(type) || "Unknown", contextKey ); return Object.assign({}, parentContext, instance); } function pushContextProvider(workInProgress) { - if (!isContextProvider(workInProgress)) return !1; var instance = workInProgress.stateNode; instance = (instance && instance.__reactInternalMemoizedMergedChildContext) || @@ -1749,19 +1710,19 @@ function pushContextProvider(workInProgress) { ); return !0; } -function invalidateContextProvider(workInProgress, didChange) { +function invalidateContextProvider(workInProgress, type, didChange) { var instance = workInProgress.stateNode; invariant( instance, "Expected to have an instance by this point. This error is likely caused by a bug in React. Please file an issue." ); - if (didChange) { - var mergedContext = processChildContext(workInProgress, previousContext); - instance.__reactInternalMemoizedMergedChildContext = mergedContext; - pop(didPerformWorkStackCursor, workInProgress); - pop(contextStackCursor, workInProgress); - push(contextStackCursor, mergedContext, workInProgress); - } else pop(didPerformWorkStackCursor, workInProgress); + didChange + ? ((type = processChildContext(workInProgress, type, previousContext)), + (instance.__reactInternalMemoizedMergedChildContext = type), + pop(didPerformWorkStackCursor, workInProgress), + pop(contextStackCursor, workInProgress), + push(contextStackCursor, type, workInProgress)) + : pop(didPerformWorkStackCursor, workInProgress); push(didPerformWorkStackCursor, didChange, workInProgress); } var onCommitFiberRoot = null, @@ -1802,7 +1763,13 @@ function FiberNode(tag, pendingProps, key, mode) { this.lastEffect = this.firstEffect = this.nextEffect = null; this.childExpirationTime = this.expirationTime = 0; this.alternate = null; - this.treeBaseDuration = this.selfBaseDuration = this.actualStartTime = this.actualDuration = 0; + this.actualDuration = 0; + this.actualStartTime = -1; + this.treeBaseDuration = this.selfBaseDuration = 0; +} +function shouldConstruct(Component) { + Component = Component.prototype; + return !(!Component || !Component.isReactComponent); } function createWorkInProgress(current, pendingProps, expirationTime) { var workInProgress = current.alternate; @@ -1823,7 +1790,7 @@ function createWorkInProgress(current, pendingProps, expirationTime) { (workInProgress.firstEffect = null), (workInProgress.lastEffect = null), (workInProgress.actualDuration = 0), - (workInProgress.actualStartTime = 0)); + (workInProgress.actualStartTime = -1)); workInProgress.childExpirationTime = current.childExpirationTime; workInProgress.expirationTime = pendingProps !== current.pendingProps @@ -1845,11 +1812,11 @@ function createFiberFromElement(element, mode, expirationTime) { var type = element.type, key = element.key; element = element.props; - if ("function" === typeof type) - var fiberTag = type.prototype && type.prototype.isReactComponent ? 2 : 0; - else if ("string" === typeof type) fiberTag = 5; + var fiberTag = void 0; + if ("function" === typeof type) fiberTag = shouldConstruct(type) ? 2 : 4; + else if ("string" === typeof type) fiberTag = 7; else - switch (type) { + a: switch (type) { case REACT_FRAGMENT_TYPE: return createFiberFromFragment( element.children, @@ -1858,11 +1825,11 @@ function createFiberFromElement(element, mode, expirationTime) { key ); case REACT_ASYNC_MODE_TYPE: - fiberTag = 11; + fiberTag = 10; mode |= 3; break; case REACT_STRICT_MODE_TYPE: - fiberTag = 11; + fiberTag = 10; mode |= 2; break; case REACT_PROFILER_TYPE: @@ -1876,29 +1843,29 @@ function createFiberFromElement(element, mode, expirationTime) { fiberTag = 16; break; default: - a: { - switch ( - "object" === typeof type && null !== type ? type.$$typeof : null - ) { + if ("object" === typeof type && null !== type) + switch (type.$$typeof) { case REACT_PROVIDER_TYPE: - fiberTag = 13; - break a; - case REACT_CONTEXT_TYPE: fiberTag = 12; break a; + case REACT_CONTEXT_TYPE: + fiberTag = 11; + break a; case REACT_FORWARD_REF_TYPE: - fiberTag = 14; + fiberTag = 13; break a; default: - invariant( - !1, - "Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s", - null == type ? type : typeof type, - "" - ); + if ("function" === typeof type.then) { + fiberTag = 4; + break a; + } } - fiberTag = void 0; - } + invariant( + !1, + "Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s", + null == type ? type : typeof type, + "" + ); } mode = new FiberNode(fiberTag, element, key, mode); mode.type = type; @@ -1906,18 +1873,18 @@ function createFiberFromElement(element, mode, expirationTime) { return mode; } function createFiberFromFragment(elements, mode, expirationTime, key) { - elements = new FiberNode(10, elements, key, mode); + elements = new FiberNode(9, elements, key, mode); elements.expirationTime = expirationTime; return elements; } function createFiberFromText(content, mode, expirationTime) { - content = new FiberNode(6, content, null, mode); + content = new FiberNode(8, content, null, mode); content.expirationTime = expirationTime; return content; } function createFiberFromPortal(portal, mode, expirationTime) { mode = new FiberNode( - 4, + 6, null !== portal.children ? portal.children : [], portal.key, mode @@ -1930,33 +1897,6 @@ function createFiberFromPortal(portal, mode, expirationTime) { }; return mode; } -function createFiberRoot(containerInfo, isAsync, hydrate) { - isAsync = isAsync ? 3 : 0; - isDevToolsPresent && (isAsync |= 4); - isAsync = new FiberNode(3, null, null, isAsync); - containerInfo = { - current: isAsync, - containerInfo: containerInfo, - pendingChildren: null, - earliestPendingTime: 0, - latestPendingTime: 0, - earliestSuspendedTime: 0, - latestSuspendedTime: 0, - latestPingedTime: 0, - didError: !1, - pendingCommitExpirationTime: 0, - finishedWork: null, - timeoutHandle: -1, - context: null, - pendingContext: null, - hydrate: hydrate, - nextExpirationTimeToWorkOn: 0, - expirationTime: 0, - firstBatch: null, - nextScheduledRoot: null - }; - return (isAsync.stateNode = containerInfo); -} function markPendingPriorityLevel(root, expirationTime) { root.didError = !1; var earliestPendingTime = root.earliestPendingTime; @@ -1968,6 +1908,70 @@ function markPendingPriorityLevel(root, expirationTime) { (root.latestPendingTime = expirationTime); findNextExpirationTimeToWorkOn(expirationTime, root); } +function markCommittedPriorityLevels(root, earliestRemainingTime) { + root.didError = !1; + if (0 === earliestRemainingTime) + (root.earliestPendingTime = 0), + (root.latestPendingTime = 0), + (root.earliestSuspendedTime = 0), + (root.latestSuspendedTime = 0), + (root.latestPingedTime = 0); + else { + var latestPendingTime = root.latestPendingTime; + 0 !== latestPendingTime && + (latestPendingTime < earliestRemainingTime + ? (root.earliestPendingTime = root.latestPendingTime = 0) + : root.earliestPendingTime < earliestRemainingTime && + (root.earliestPendingTime = root.latestPendingTime)); + latestPendingTime = root.earliestSuspendedTime; + 0 === latestPendingTime + ? markPendingPriorityLevel(root, earliestRemainingTime) + : earliestRemainingTime > root.latestSuspendedTime + ? ((root.earliestSuspendedTime = 0), + (root.latestSuspendedTime = 0), + (root.latestPingedTime = 0), + markPendingPriorityLevel(root, earliestRemainingTime)) + : earliestRemainingTime < latestPendingTime && + markPendingPriorityLevel(root, earliestRemainingTime); + } + findNextExpirationTimeToWorkOn(0, root); +} +function hasLowerPriorityWork(root, erroredExpirationTime) { + var latestPendingTime = root.latestPendingTime, + latestSuspendedTime = root.latestSuspendedTime; + root = root.latestPingedTime; + return ( + (0 !== latestPendingTime && latestPendingTime > erroredExpirationTime) || + (0 !== latestSuspendedTime && + latestSuspendedTime > erroredExpirationTime) || + (0 !== root && root > erroredExpirationTime) + ); +} +function markSuspendedPriorityLevel(root, suspendedTime) { + root.didError = !1; + var latestPingedTime = root.latestPingedTime; + 0 !== latestPingedTime && + latestPingedTime <= suspendedTime && + (root.latestPingedTime = 0); + latestPingedTime = root.earliestPendingTime; + var latestPendingTime = root.latestPendingTime; + latestPingedTime === suspendedTime + ? (root.earliestPendingTime = + latestPendingTime === suspendedTime + ? (root.latestPendingTime = 0) + : latestPendingTime) + : latestPendingTime === suspendedTime && + (root.latestPendingTime = latestPingedTime); + latestPingedTime = root.earliestSuspendedTime; + latestPendingTime = root.latestSuspendedTime; + 0 === latestPingedTime + ? (root.earliestSuspendedTime = root.latestSuspendedTime = suspendedTime) + : latestPingedTime > suspendedTime + ? (root.earliestSuspendedTime = suspendedTime) + : latestPendingTime < suspendedTime && + (root.latestSuspendedTime = suspendedTime); + findNextExpirationTimeToWorkOn(suspendedTime, root); +} function findNextExpirationTimeToWorkOn(completedExpirationTime, root) { var earliestSuspendedTime = root.earliestSuspendedTime, latestSuspendedTime = root.latestSuspendedTime, @@ -2194,41 +2198,32 @@ function processUpdateQueue( workInProgress.expirationTime = newExpirationTime; workInProgress.memoizedState = resultState; } -function callCallback(callback, context) { - invariant( - "function" === typeof callback, - "Invalid argument passed as callback. Expected a function. Instead received: %s", - callback - ); - callback.call(context); -} function commitUpdateQueue(finishedWork, finishedQueue, instance) { null !== finishedQueue.firstCapturedUpdate && (null !== finishedQueue.lastUpdate && ((finishedQueue.lastUpdate.next = finishedQueue.firstCapturedUpdate), (finishedQueue.lastUpdate = finishedQueue.lastCapturedUpdate)), (finishedQueue.firstCapturedUpdate = finishedQueue.lastCapturedUpdate = null)); - finishedWork = finishedQueue.firstEffect; - for ( - finishedQueue.firstEffect = finishedQueue.lastEffect = null; - null !== finishedWork; - - ) { - var _callback3 = finishedWork.callback; - null !== _callback3 && - ((finishedWork.callback = null), callCallback(_callback3, instance)); - finishedWork = finishedWork.nextEffect; + commitUpdateEffects(finishedQueue.firstEffect, instance); + finishedQueue.firstEffect = finishedQueue.lastEffect = null; + commitUpdateEffects(finishedQueue.firstCapturedEffect, instance); + finishedQueue.firstCapturedEffect = finishedQueue.lastCapturedEffect = null; +} +function commitUpdateEffects(effect, instance) { + for (; null !== effect; ) { + var _callback3 = effect.callback; + if (null !== _callback3) { + effect.callback = null; + var context = instance; + invariant( + "function" === typeof _callback3, + "Invalid argument passed as callback. Expected a function. Instead received: %s", + _callback3 + ); + _callback3.call(context); + } + effect = effect.nextEffect; } - finishedWork = finishedQueue.firstCapturedEffect; - for ( - finishedQueue.firstCapturedEffect = finishedQueue.lastCapturedEffect = null; - null !== finishedWork; - - ) - (finishedQueue = finishedWork.callback), - null !== finishedQueue && - ((finishedWork.callback = null), callCallback(finishedQueue, instance)), - (finishedWork = finishedWork.nextEffect); } function createCapturedValue(value, source) { return { @@ -2238,125 +2233,23 @@ function createCapturedValue(value, source) { }; } var valueCursor = { current: null }, - changedBitsCursor = { current: 0 }, currentlyRenderingFiber = null, lastContextDependency = null, lastContextWithAllBitsObserved = null; -function pushProvider(providerFiber) { +function pushProvider(providerFiber, nextValue) { var context = providerFiber.type._context; - push(changedBitsCursor, context._changedBits2, providerFiber); push(valueCursor, context._currentValue2, providerFiber); - context._currentValue2 = providerFiber.pendingProps.value; - context._changedBits2 = providerFiber.stateNode; + context._currentValue2 = nextValue; } function popProvider(providerFiber) { - var changedBits = changedBitsCursor.current, - currentValue = valueCursor.current; + var currentValue = valueCursor.current; pop(valueCursor, providerFiber); - pop(changedBitsCursor, providerFiber); - providerFiber = providerFiber.type._context; - providerFiber._currentValue2 = currentValue; - providerFiber._changedBits2 = changedBits; + providerFiber.type._context._currentValue2 = currentValue; } -function propagateContextChange( - workInProgress, - context, - changedBits, - renderExpirationTime -) { - var fiber = workInProgress.child; - null !== fiber && (fiber.return = workInProgress); - for (; null !== fiber; ) { - var dependency = fiber.firstContextDependency; - if (null !== dependency) { - do { - if ( - dependency.context === context && - 0 !== (dependency.observedBits & changedBits) - ) { - if ( - 0 === fiber.expirationTime || - fiber.expirationTime > renderExpirationTime - ) - fiber.expirationTime = renderExpirationTime; - var nextFiber = fiber.alternate; - null !== nextFiber && - (0 === nextFiber.expirationTime || - nextFiber.expirationTime > renderExpirationTime) && - (nextFiber.expirationTime = renderExpirationTime); - for (var node = fiber.return; null !== node; ) { - nextFiber = node.alternate; - if ( - 0 === node.childExpirationTime || - node.childExpirationTime > renderExpirationTime - ) - (node.childExpirationTime = renderExpirationTime), - null !== nextFiber && - (0 === nextFiber.childExpirationTime || - nextFiber.childExpirationTime > renderExpirationTime) && - (nextFiber.childExpirationTime = renderExpirationTime); - else if ( - null !== nextFiber && - (0 === nextFiber.childExpirationTime || - nextFiber.childExpirationTime > renderExpirationTime) - ) - nextFiber.childExpirationTime = renderExpirationTime; - else break; - node = node.return; - } - nextFiber = null; - } else nextFiber = fiber.child; - dependency = dependency.next; - } while (null !== dependency); - } else - nextFiber = - 13 === fiber.tag - ? fiber.type === workInProgress.type - ? null - : fiber.child - : fiber.child; - if (null !== nextFiber) nextFiber.return = fiber; - else - for (nextFiber = fiber; null !== nextFiber; ) { - if (nextFiber === workInProgress) { - nextFiber = null; - break; - } - fiber = nextFiber.sibling; - if (null !== fiber) { - fiber.return = nextFiber.return; - nextFiber = fiber; - break; - } - nextFiber = nextFiber.return; - } - fiber = nextFiber; - } -} -function prepareToReadContext(workInProgress, renderExpirationTime) { +function prepareToReadContext(workInProgress) { currentlyRenderingFiber = workInProgress; lastContextWithAllBitsObserved = lastContextDependency = null; - var firstContextDependency = workInProgress.firstContextDependency; - if (null !== firstContextDependency) { - workInProgress.firstContextDependency = null; - var hasPendingContext = !1; - do { - var _context = firstContextDependency.context, - changedBits = _context._changedBits2; - 0 !== changedBits && - (propagateContextChange( - workInProgress, - _context, - changedBits, - renderExpirationTime - ), - 0 !== (changedBits & firstContextDependency.observedBits) && - (hasPendingContext = !0)); - firstContextDependency = firstContextDependency.next; - } while (null !== firstContextDependency); - return hasPendingContext; - } - return !1; + workInProgress.firstContextDependency = null; } function readContext(context, observedBits) { if ( @@ -2422,28 +2315,17 @@ function popHostContext(fiber) { contextFiberStackCursor.current === fiber && (pop(contextStackCursor$1, fiber), pop(contextFiberStackCursor, fiber)); } -var syncCommitStartTime = 0, - timerPausedAt = 0, - totalElapsedPauseTime = 0; -function pauseActualRenderTimerIfRunning() { - 0 === timerPausedAt && (timerPausedAt = now$1()); - 0 < syncCommitStartTime - ? ((totalElapsedPauseTime += now$1() - syncCommitStartTime), - (syncCommitStartTime = 0)) - : (totalElapsedPauseTime = 0); +var commitTime = 0, + profilerStartTime = -1; +function stopProfilerTimerIfRunningAndRecordDelta(fiber, overrideBaseTime) { + if (0 <= profilerStartTime) { + var elapsedTime = now$1() - profilerStartTime; + fiber.actualDuration += elapsedTime; + overrideBaseTime && (fiber.selfBaseDuration = elapsedTime); + profilerStartTime = -1; + } } -function recordElapsedActualRenderTime(fiber) { - fiber.actualDuration = now$1() - totalElapsedPauseTime - fiber.actualDuration; -} -function resumeActualRenderTimerIfPaused(isProcessingSyncWork) { - isProcessingSyncWork && - 0 === syncCommitStartTime && - (syncCommitStartTime = now$1()); - 0 < timerPausedAt && - ((totalElapsedPauseTime += now$1() - timerPausedAt), (timerPausedAt = 0)); -} -var baseStartTime = -1, - hasOwnProperty = Object.prototype.hasOwnProperty; +var hasOwnProperty = Object.prototype.hasOwnProperty; function is(x, y) { return x === y ? 0 !== x || 0 !== y || 1 / x === 1 / y : x !== x && y !== y; } @@ -2470,20 +2352,21 @@ function shallowEqual(objA, objB) { var emptyRefsObject = new React.Component().refs; function applyDerivedStateFromProps( workInProgress, + ctor, getDerivedStateFromProps, nextProps ) { - var prevState = workInProgress.memoizedState; - getDerivedStateFromProps = getDerivedStateFromProps(nextProps, prevState); - prevState = + ctor = workInProgress.memoizedState; + getDerivedStateFromProps = getDerivedStateFromProps(nextProps, ctor); + getDerivedStateFromProps = null === getDerivedStateFromProps || void 0 === getDerivedStateFromProps - ? prevState - : Object.assign({}, prevState, getDerivedStateFromProps); - workInProgress.memoizedState = prevState; - getDerivedStateFromProps = workInProgress.updateQueue; - null !== getDerivedStateFromProps && + ? ctor + : Object.assign({}, ctor, getDerivedStateFromProps); + workInProgress.memoizedState = getDerivedStateFromProps; + nextProps = workInProgress.updateQueue; + null !== nextProps && 0 === workInProgress.expirationTime && - (getDerivedStateFromProps.baseState = prevState); + (nextProps.baseState = getDerivedStateFromProps); } var classComponentUpdater = { isMounted: function(component) { @@ -2525,17 +2408,21 @@ var classComponentUpdater = { }; function checkShouldComponentUpdate( workInProgress, + ctor, oldProps, newProps, oldState, newState, nextLegacyContext ) { - var instance = workInProgress.stateNode; - workInProgress = workInProgress.type; - return "function" === typeof instance.shouldComponentUpdate - ? instance.shouldComponentUpdate(newProps, newState, nextLegacyContext) - : workInProgress.prototype && workInProgress.prototype.isPureReactComponent + workInProgress = workInProgress.stateNode; + return "function" === typeof workInProgress.shouldComponentUpdate + ? workInProgress.shouldComponentUpdate( + newProps, + newState, + nextLegacyContext + ) + : ctor.prototype && ctor.prototype.isPureReactComponent ? !shallowEqual(oldProps, newProps) || !shallowEqual(oldState, newState) : !0; } @@ -2553,12 +2440,17 @@ function callComponentWillReceiveProps( instance.state !== workInProgress && classComponentUpdater.enqueueReplaceState(instance, instance.state, null); } -function mountClassInstance(workInProgress, renderExpirationTime) { - var ctor = workInProgress.type, - instance = workInProgress.stateNode, - props = workInProgress.pendingProps, - unmaskedContext = getUnmaskedContext(workInProgress); - instance.props = props; +function mountClassInstance( + workInProgress, + ctor, + newProps, + renderExpirationTime +) { + var instance = workInProgress.stateNode, + unmaskedContext = isContextProvider(ctor) + ? previousContext + : contextStackCursor.current; + instance.props = newProps; instance.state = workInProgress.memoizedState; instance.refs = emptyRefsObject; instance.context = getMaskedContext(workInProgress, unmaskedContext); @@ -2567,14 +2459,19 @@ function mountClassInstance(workInProgress, renderExpirationTime) { (processUpdateQueue( workInProgress, unmaskedContext, - props, + newProps, instance, renderExpirationTime ), (instance.state = workInProgress.memoizedState)); unmaskedContext = ctor.getDerivedStateFromProps; "function" === typeof unmaskedContext && - (applyDerivedStateFromProps(workInProgress, unmaskedContext, props), + (applyDerivedStateFromProps( + workInProgress, + ctor, + unmaskedContext, + newProps + ), (instance.state = workInProgress.memoizedState)); "function" === typeof ctor.getDerivedStateFromProps || "function" === typeof instance.getSnapshotBeforeUpdate || @@ -2592,7 +2489,7 @@ function mountClassInstance(workInProgress, renderExpirationTime) { (processUpdateQueue( workInProgress, unmaskedContext, - props, + newProps, instance, renderExpirationTime ), @@ -2613,7 +2510,7 @@ function coerceRef(returnFiber, current$$1, element) { var inst = void 0; element && (invariant( - 2 === element.tag, + 2 === element.tag || 3 === element.tag, "Stateless function components cannot have refs." ), (inst = element.stateNode)); @@ -2640,7 +2537,7 @@ function coerceRef(returnFiber, current$$1, element) { } invariant( "string" === typeof returnFiber, - "Expected ref to be a function or a string." + "Expected ref to be a function, a string, an object returned by React.createRef(), or null." ); invariant( element._owner, @@ -2720,7 +2617,7 @@ function ChildReconciler(shouldTrackSideEffects) { textContent, expirationTime ) { - if (null === current$$1 || 6 !== current$$1.tag) + if (null === current$$1 || 8 !== current$$1.tag) return ( (current$$1 = createFiberFromText( textContent, @@ -2754,7 +2651,7 @@ function ChildReconciler(shouldTrackSideEffects) { function updatePortal(returnFiber, current$$1, portal, expirationTime) { if ( null === current$$1 || - 4 !== current$$1.tag || + 6 !== current$$1.tag || current$$1.stateNode.containerInfo !== portal.containerInfo || current$$1.stateNode.implementation !== portal.implementation ) @@ -2778,7 +2675,7 @@ function ChildReconciler(shouldTrackSideEffects) { expirationTime, key ) { - if (null === current$$1 || 10 !== current$$1.tag) + if (null === current$$1 || 9 !== current$$1.tag) return ( (current$$1 = createFiberFromFragment( fragment, @@ -3153,7 +3050,7 @@ function ChildReconciler(shouldTrackSideEffects) { ) { if (isUnkeyedTopLevelFragment.key === isObject) if ( - 10 === isUnkeyedTopLevelFragment.tag + 9 === isUnkeyedTopLevelFragment.tag ? newChild.type === REACT_FRAGMENT_TYPE : isUnkeyedTopLevelFragment.type === newChild.type ) { @@ -3218,7 +3115,7 @@ function ChildReconciler(shouldTrackSideEffects) { ) { if (currentFirstChild.key === isUnkeyedTopLevelFragment) if ( - 4 === currentFirstChild.tag && + 6 === currentFirstChild.tag && currentFirstChild.stateNode.containerInfo === newChild.containerInfo && currentFirstChild.stateNode.implementation === @@ -3256,7 +3153,7 @@ function ChildReconciler(shouldTrackSideEffects) { if ("string" === typeof newChild || "number" === typeof newChild) return ( (newChild = "" + newChild), - null !== currentFirstChild && 6 === currentFirstChild.tag + null !== currentFirstChild && 8 === currentFirstChild.tag ? (deleteRemainingChildren(returnFiber, currentFirstChild.sibling), (currentFirstChild = useFiber( currentFirstChild, @@ -3293,7 +3190,8 @@ function ChildReconciler(shouldTrackSideEffects) { if ("undefined" === typeof newChild && !isUnkeyedTopLevelFragment) switch (returnFiber.tag) { case 2: - case 1: + case 3: + case 0: (expirationTime = returnFiber.type), invariant( !1, @@ -3311,12 +3209,12 @@ var reconcileChildFibers = ChildReconciler(!0), isHydrating = !1; function tryHydrate(fiber, nextInstance) { switch (fiber.tag) { - case 5: + case 7: return ( (nextInstance = shim$1(nextInstance, fiber.type, fiber.pendingProps)), null !== nextInstance ? ((fiber.stateNode = nextInstance), !0) : !1 ); - case 6: + case 8: return ( (nextInstance = shim$1(nextInstance, fiber.pendingProps)), null !== nextInstance ? ((fiber.stateNode = nextInstance), !0) : !1 @@ -3339,7 +3237,7 @@ function tryToClaimNextHydratableInstance(fiber$jscomp$0) { return; } var returnFiber = hydrationParentFiber, - fiber = new FiberNode(5, null, null, 0); + fiber = new FiberNode(7, null, null, 0); fiber.type = "DELETED"; fiber.stateNode = firstAttemptedInstance; fiber.return = returnFiber; @@ -3357,6 +3255,38 @@ function tryToClaimNextHydratableInstance(fiber$jscomp$0) { (hydrationParentFiber = fiber$jscomp$0); } } +function readLazyComponentType(thenable) { + switch (thenable._reactStatus) { + case 1: + return thenable._reactResult; + case 2: + throw thenable._reactResult; + case 0: + throw thenable; + default: + throw ((thenable._reactStatus = 0), + thenable.then( + function(resolvedValue) { + if (0 === thenable._reactStatus) { + thenable._reactStatus = 1; + if ("object" === typeof resolvedValue && null !== resolvedValue) { + var defaultExport = resolvedValue.default; + resolvedValue = + void 0 !== defaultExport && null !== defaultExport + ? defaultExport + : resolvedValue; + } + thenable._reactResult = resolvedValue; + } + }, + function(error) { + 0 === thenable._reactStatus && + ((thenable._reactStatus = 2), (thenable._reactResult = error)); + } + ), + thenable); + } +} var ReactCurrentOwner$3 = ReactSharedInternals.ReactCurrentOwner; function reconcileChildren( current$$1, @@ -3379,6 +3309,30 @@ function reconcileChildren( renderExpirationTime ); } +function updateForwardRef( + current$$1, + workInProgress, + type, + nextProps, + renderExpirationTime +) { + type = type.render; + var ref = workInProgress.ref; + if ( + !didPerformWorkStackCursor.current && + workInProgress.memoizedProps === nextProps && + ref === (null !== current$$1 ? current$$1.ref : null) + ) + return bailoutOnAlreadyFinishedWork( + current$$1, + workInProgress, + renderExpirationTime + ); + type = type(nextProps, ref); + reconcileChildren(current$$1, workInProgress, type, renderExpirationTime); + workInProgress.memoizedProps = nextProps; + return workInProgress.child; +} function markRef(current$$1, workInProgress) { var ref = workInProgress.ref; if ( @@ -3387,9 +3341,268 @@ function markRef(current$$1, workInProgress) { ) workInProgress.effectTag |= 128; } +function updateFunctionalComponent( + current$$1, + workInProgress, + Component, + nextProps, + renderExpirationTime +) { + var unmaskedContext = isContextProvider(Component) + ? previousContext + : contextStackCursor.current; + unmaskedContext = getMaskedContext(workInProgress, unmaskedContext); + prepareToReadContext(workInProgress, renderExpirationTime); + Component = Component(nextProps, unmaskedContext); + workInProgress.effectTag |= 1; + reconcileChildren( + current$$1, + workInProgress, + Component, + renderExpirationTime + ); + workInProgress.memoizedProps = nextProps; + return workInProgress.child; +} +function updateClassComponent( + current$$1, + workInProgress, + Component, + nextProps, + renderExpirationTime +) { + if (isContextProvider(Component)) { + var hasContext = !0; + pushContextProvider(workInProgress); + } else hasContext = !1; + prepareToReadContext(workInProgress, renderExpirationTime); + if (null === current$$1) + if (null === workInProgress.stateNode) { + var unmaskedContext = isContextProvider(Component) + ? previousContext + : contextStackCursor.current, + contextTypes = Component.contextTypes, + isContextConsumer = null !== contextTypes && void 0 !== contextTypes; + contextTypes = isContextConsumer + ? getMaskedContext(workInProgress, unmaskedContext) + : emptyContextObject; + var instance = new Component(nextProps, contextTypes); + workInProgress.memoizedState = + null !== instance.state && void 0 !== instance.state + ? instance.state + : null; + instance.updater = classComponentUpdater; + workInProgress.stateNode = instance; + instance._reactInternalFiber = workInProgress; + isContextConsumer && + ((isContextConsumer = workInProgress.stateNode), + (isContextConsumer.__reactInternalMemoizedUnmaskedChildContext = unmaskedContext), + (isContextConsumer.__reactInternalMemoizedMaskedChildContext = contextTypes)); + mountClassInstance( + workInProgress, + Component, + nextProps, + renderExpirationTime + ); + nextProps = !0; + } else { + unmaskedContext = workInProgress.stateNode; + contextTypes = workInProgress.memoizedProps; + unmaskedContext.props = contextTypes; + var oldContext = unmaskedContext.context; + isContextConsumer = isContextProvider(Component) + ? previousContext + : contextStackCursor.current; + isContextConsumer = getMaskedContext(workInProgress, isContextConsumer); + var getDerivedStateFromProps = Component.getDerivedStateFromProps; + (instance = + "function" === typeof getDerivedStateFromProps || + "function" === typeof unmaskedContext.getSnapshotBeforeUpdate) || + ("function" !== + typeof unmaskedContext.UNSAFE_componentWillReceiveProps && + "function" !== typeof unmaskedContext.componentWillReceiveProps) || + ((contextTypes !== nextProps || oldContext !== isContextConsumer) && + callComponentWillReceiveProps( + workInProgress, + unmaskedContext, + nextProps, + isContextConsumer + )); + hasForceUpdate = !1; + var oldState = workInProgress.memoizedState; + oldContext = unmaskedContext.state = oldState; + var updateQueue = workInProgress.updateQueue; + null !== updateQueue && + (processUpdateQueue( + workInProgress, + updateQueue, + nextProps, + unmaskedContext, + renderExpirationTime + ), + (oldContext = workInProgress.memoizedState)); + contextTypes !== nextProps || + oldState !== oldContext || + didPerformWorkStackCursor.current || + hasForceUpdate + ? ("function" === typeof getDerivedStateFromProps && + (applyDerivedStateFromProps( + workInProgress, + Component, + getDerivedStateFromProps, + nextProps + ), + (oldContext = workInProgress.memoizedState)), + (contextTypes = + hasForceUpdate || + checkShouldComponentUpdate( + workInProgress, + Component, + contextTypes, + nextProps, + oldState, + oldContext, + isContextConsumer + )) + ? (instance || + ("function" !== + typeof unmaskedContext.UNSAFE_componentWillMount && + "function" !== typeof unmaskedContext.componentWillMount) || + ("function" === typeof unmaskedContext.componentWillMount && + unmaskedContext.componentWillMount(), + "function" === + typeof unmaskedContext.UNSAFE_componentWillMount && + unmaskedContext.UNSAFE_componentWillMount()), + "function" === typeof unmaskedContext.componentDidMount && + (workInProgress.effectTag |= 4)) + : ("function" === typeof unmaskedContext.componentDidMount && + (workInProgress.effectTag |= 4), + (workInProgress.memoizedProps = nextProps), + (workInProgress.memoizedState = oldContext)), + (unmaskedContext.props = nextProps), + (unmaskedContext.state = oldContext), + (unmaskedContext.context = isContextConsumer), + (nextProps = contextTypes)) + : ("function" === typeof unmaskedContext.componentDidMount && + (workInProgress.effectTag |= 4), + (nextProps = !1)); + } + else + (unmaskedContext = workInProgress.stateNode), + (contextTypes = workInProgress.memoizedProps), + (unmaskedContext.props = contextTypes), + (oldContext = unmaskedContext.context), + (isContextConsumer = isContextProvider(Component) + ? previousContext + : contextStackCursor.current), + (isContextConsumer = getMaskedContext(workInProgress, isContextConsumer)), + (getDerivedStateFromProps = Component.getDerivedStateFromProps), + (instance = + "function" === typeof getDerivedStateFromProps || + "function" === typeof unmaskedContext.getSnapshotBeforeUpdate) || + ("function" !== + typeof unmaskedContext.UNSAFE_componentWillReceiveProps && + "function" !== typeof unmaskedContext.componentWillReceiveProps) || + ((contextTypes !== nextProps || oldContext !== isContextConsumer) && + callComponentWillReceiveProps( + workInProgress, + unmaskedContext, + nextProps, + isContextConsumer + )), + (hasForceUpdate = !1), + (oldContext = workInProgress.memoizedState), + (oldState = unmaskedContext.state = oldContext), + (updateQueue = workInProgress.updateQueue), + null !== updateQueue && + (processUpdateQueue( + workInProgress, + updateQueue, + nextProps, + unmaskedContext, + renderExpirationTime + ), + (oldState = workInProgress.memoizedState)), + contextTypes !== nextProps || + oldContext !== oldState || + didPerformWorkStackCursor.current || + hasForceUpdate + ? ("function" === typeof getDerivedStateFromProps && + (applyDerivedStateFromProps( + workInProgress, + Component, + getDerivedStateFromProps, + nextProps + ), + (oldState = workInProgress.memoizedState)), + (getDerivedStateFromProps = + hasForceUpdate || + checkShouldComponentUpdate( + workInProgress, + Component, + contextTypes, + nextProps, + oldContext, + oldState, + isContextConsumer + )) + ? (instance || + ("function" !== + typeof unmaskedContext.UNSAFE_componentWillUpdate && + "function" !== typeof unmaskedContext.componentWillUpdate) || + ("function" === typeof unmaskedContext.componentWillUpdate && + unmaskedContext.componentWillUpdate( + nextProps, + oldState, + isContextConsumer + ), + "function" === + typeof unmaskedContext.UNSAFE_componentWillUpdate && + unmaskedContext.UNSAFE_componentWillUpdate( + nextProps, + oldState, + isContextConsumer + )), + "function" === typeof unmaskedContext.componentDidUpdate && + (workInProgress.effectTag |= 4), + "function" === typeof unmaskedContext.getSnapshotBeforeUpdate && + (workInProgress.effectTag |= 256)) + : ("function" !== typeof unmaskedContext.componentDidUpdate || + (contextTypes === current$$1.memoizedProps && + oldContext === current$$1.memoizedState) || + (workInProgress.effectTag |= 4), + "function" !== typeof unmaskedContext.getSnapshotBeforeUpdate || + (contextTypes === current$$1.memoizedProps && + oldContext === current$$1.memoizedState) || + (workInProgress.effectTag |= 256), + (workInProgress.memoizedProps = nextProps), + (workInProgress.memoizedState = oldState)), + (unmaskedContext.props = nextProps), + (unmaskedContext.state = oldState), + (unmaskedContext.context = isContextConsumer), + (nextProps = getDerivedStateFromProps)) + : ("function" !== typeof unmaskedContext.componentDidUpdate || + (contextTypes === current$$1.memoizedProps && + oldContext === current$$1.memoizedState) || + (workInProgress.effectTag |= 4), + "function" !== typeof unmaskedContext.getSnapshotBeforeUpdate || + (contextTypes === current$$1.memoizedProps && + oldContext === current$$1.memoizedState) || + (workInProgress.effectTag |= 256), + (nextProps = !1)); + return finishClassComponent( + current$$1, + workInProgress, + Component, + nextProps, + hasContext, + renderExpirationTime + ); +} function finishClassComponent( current$$1, workInProgress, + Component, shouldUpdate, hasContext, renderExpirationTime @@ -3398,7 +3611,7 @@ function finishClassComponent( var didCaptureError = 0 !== (workInProgress.effectTag & 64); if (!shouldUpdate && !didCaptureError) return ( - hasContext && invalidateContextProvider(workInProgress, !1), + hasContext && invalidateContextProvider(workInProgress, Component, !1), bailoutOnAlreadyFinishedWork( current$$1, workInProgress, @@ -3409,7 +3622,7 @@ function finishClassComponent( ReactCurrentOwner$3.current = workInProgress; if (didCaptureError) { var nextChildren = null; - baseStartTime = -1; + profilerStartTime = -1; } else nextChildren = shouldUpdate.render(); workInProgress.effectTag |= 1; null !== current$$1 && @@ -3424,7 +3637,7 @@ function finishClassComponent( ); workInProgress.memoizedState = shouldUpdate.state; workInProgress.memoizedProps = shouldUpdate.props; - hasContext && invalidateContextProvider(workInProgress, !0); + hasContext && invalidateContextProvider(workInProgress, Component, !0); return workInProgress.child; } function pushHostRootContext(workInProgress) { @@ -3439,6 +3652,132 @@ function pushHostRootContext(workInProgress) { pushTopLevelContextObject(workInProgress, root.context, !1); pushHostContainer(workInProgress, root.containerInfo); } +function resolveDefaultProps(Component, baseProps) { + if (Component && Component.defaultProps) { + baseProps = Object.assign({}, baseProps); + Component = Component.defaultProps; + for (var propName in Component) + void 0 === baseProps[propName] && + (baseProps[propName] = Component[propName]); + } + return baseProps; +} +function mountIndeterminateComponent( + current$$1, + workInProgress, + Component, + renderExpirationTime +) { + invariant( + null === current$$1, + "An indeterminate component should never have mounted. This error is likely caused by a bug in React. Please file an issue." + ); + var props = workInProgress.pendingProps; + if ( + "object" === typeof Component && + null !== Component && + "function" === typeof Component.then + ) { + Component = readLazyComponentType(Component); + var JSCompiler_inline_result = Component; + JSCompiler_inline_result = + "function" === typeof JSCompiler_inline_result + ? shouldConstruct(JSCompiler_inline_result) + ? 3 + : 1 + : void 0 !== JSCompiler_inline_result && + null !== JSCompiler_inline_result && + JSCompiler_inline_result.$$typeof + ? 14 + : 4; + JSCompiler_inline_result = workInProgress.tag = JSCompiler_inline_result; + var resolvedProps = resolveDefaultProps(Component, props); + switch (JSCompiler_inline_result) { + case 1: + return updateFunctionalComponent( + current$$1, + workInProgress, + Component, + resolvedProps, + renderExpirationTime + ); + case 3: + return updateClassComponent( + current$$1, + workInProgress, + Component, + resolvedProps, + renderExpirationTime + ); + case 14: + return updateForwardRef( + current$$1, + workInProgress, + Component, + resolvedProps, + renderExpirationTime + ); + default: + invariant( + !1, + "Element type is invalid. Received a promise that resolves to: %s. Promise elements must resolve to a class or function.", + Component + ); + } + } + JSCompiler_inline_result = getMaskedContext( + workInProgress, + contextStackCursor.current + ); + prepareToReadContext(workInProgress, renderExpirationTime); + JSCompiler_inline_result = Component(props, JSCompiler_inline_result); + workInProgress.effectTag |= 1; + if ( + "object" === typeof JSCompiler_inline_result && + null !== JSCompiler_inline_result && + "function" === typeof JSCompiler_inline_result.render && + void 0 === JSCompiler_inline_result.$$typeof + ) { + workInProgress.tag = 2; + isContextProvider(Component) + ? ((resolvedProps = !0), pushContextProvider(workInProgress)) + : (resolvedProps = !1); + workInProgress.memoizedState = + null !== JSCompiler_inline_result.state && + void 0 !== JSCompiler_inline_result.state + ? JSCompiler_inline_result.state + : null; + var getDerivedStateFromProps = Component.getDerivedStateFromProps; + "function" === typeof getDerivedStateFromProps && + applyDerivedStateFromProps( + workInProgress, + Component, + getDerivedStateFromProps, + props + ); + JSCompiler_inline_result.updater = classComponentUpdater; + workInProgress.stateNode = JSCompiler_inline_result; + JSCompiler_inline_result._reactInternalFiber = workInProgress; + mountClassInstance(workInProgress, Component, props, renderExpirationTime); + return finishClassComponent( + current$$1, + workInProgress, + Component, + !0, + resolvedProps, + renderExpirationTime + ); + } + workInProgress.tag = 0; + reconcileChildren( + current$$1, + workInProgress, + JSCompiler_inline_result, + renderExpirationTime + ); + workInProgress.memoizedProps = props; + return workInProgress.child; +} function bailoutOnAlreadyFinishedWork( current$$1, workInProgress, @@ -3446,7 +3785,7 @@ function bailoutOnAlreadyFinishedWork( ) { null !== current$$1 && (workInProgress.firstContextDependency = current$$1.firstContextDependency); - baseStartTime = -1; + profilerStartTime = -1; var childExpirationTime = workInProgress.childExpirationTime; if (0 === childExpirationTime || childExpirationTime > renderExpirationTime) return null; @@ -3479,34 +3818,34 @@ function bailoutOnAlreadyFinishedWork( return workInProgress.child; } function beginWork(current$$1, workInProgress, renderExpirationTime) { - workInProgress.mode & 4 && - ((workInProgress.actualDuration = - now$1() - workInProgress.actualDuration - totalElapsedPauseTime), - (workInProgress.actualStartTime = now$1())); var updateExpirationTime = workInProgress.expirationTime; if ( !didPerformWorkStackCursor.current && (0 === updateExpirationTime || updateExpirationTime > renderExpirationTime) ) { switch (workInProgress.tag) { - case 3: + case 5: pushHostRootContext(workInProgress); break; - case 5: + case 7: pushHostContext(workInProgress); break; case 2: - pushContextProvider(workInProgress); + isContextProvider(workInProgress.type) && + pushContextProvider(workInProgress); break; - case 4: + case 3: + isContextProvider(workInProgress.type._reactResult) && + pushContextProvider(workInProgress); + break; + case 6: pushHostContainer( workInProgress, workInProgress.stateNode.containerInfo ); break; - case 13: - workInProgress.stateNode = 0; - pushProvider(workInProgress); + case 12: + pushProvider(workInProgress, workInProgress.memoizedProps.value); break; case 15: workInProgress.effectTag |= 4; @@ -3519,294 +3858,56 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { } workInProgress.expirationTime = 0; switch (workInProgress.tag) { - case 0: - invariant( - null === current$$1, - "An indeterminate component should never have mounted. This error is likely caused by a bug in React. Please file an issue." - ); - var fn = workInProgress.type; - updateExpirationTime = workInProgress.pendingProps; - var unmaskedContext = getUnmaskedContext(workInProgress); - unmaskedContext = getMaskedContext(workInProgress, unmaskedContext); - prepareToReadContext(workInProgress, renderExpirationTime); - fn = fn(updateExpirationTime, unmaskedContext); - workInProgress.effectTag |= 1; - if ( - "object" === typeof fn && - null !== fn && - "function" === typeof fn.render && - void 0 === fn.$$typeof - ) { - var Component = workInProgress.type; - workInProgress.tag = 2; - unmaskedContext = pushContextProvider(workInProgress); - workInProgress.memoizedState = - null !== fn.state && void 0 !== fn.state ? fn.state : null; - Component = Component.getDerivedStateFromProps; - "function" === typeof Component && - applyDerivedStateFromProps( - workInProgress, - Component, - updateExpirationTime - ); - fn.updater = classComponentUpdater; - workInProgress.stateNode = fn; - fn._reactInternalFiber = workInProgress; - mountClassInstance(workInProgress, renderExpirationTime); - current$$1 = finishClassComponent( - current$$1, - workInProgress, - !0, - unmaskedContext, - renderExpirationTime - ); - } else - (workInProgress.tag = 1), - reconcileChildren( - current$$1, - workInProgress, - fn, - renderExpirationTime - ), - (workInProgress.memoizedProps = updateExpirationTime), - (current$$1 = workInProgress.child); - return current$$1; - case 1: - return ( - (fn = workInProgress.type), - (updateExpirationTime = workInProgress.pendingProps), - (unmaskedContext = getUnmaskedContext(workInProgress)), - (unmaskedContext = getMaskedContext(workInProgress, unmaskedContext)), - prepareToReadContext(workInProgress, renderExpirationTime), - (fn = fn(updateExpirationTime, unmaskedContext)), - (workInProgress.effectTag |= 1), - reconcileChildren(current$$1, workInProgress, fn, renderExpirationTime), - (workInProgress.memoizedProps = updateExpirationTime), - workInProgress.child - ); - case 2: - updateExpirationTime = pushContextProvider(workInProgress); - fn = prepareToReadContext(workInProgress, renderExpirationTime); - if (null === current$$1) - if (null === workInProgress.stateNode) { - var props = workInProgress.pendingProps, - ctor = workInProgress.type; - fn = getUnmaskedContext(workInProgress); - unmaskedContext = (Component = - 2 === workInProgress.tag && - null != workInProgress.type.contextTypes) - ? getMaskedContext(workInProgress, fn) - : emptyContextObject; - props = new ctor(props, unmaskedContext); - workInProgress.memoizedState = - null !== props.state && void 0 !== props.state ? props.state : null; - props.updater = classComponentUpdater; - workInProgress.stateNode = props; - props._reactInternalFiber = workInProgress; - Component && - ((Component = workInProgress.stateNode), - (Component.__reactInternalMemoizedUnmaskedChildContext = fn), - (Component.__reactInternalMemoizedMaskedChildContext = unmaskedContext)); - mountClassInstance(workInProgress, renderExpirationTime); - fn = !0; - } else { - var ctor$jscomp$0 = workInProgress.type; - unmaskedContext = workInProgress.stateNode; - props = workInProgress.memoizedProps; - Component = workInProgress.pendingProps; - unmaskedContext.props = props; - var oldContext = unmaskedContext.context; - ctor = getUnmaskedContext(workInProgress); - ctor = getMaskedContext(workInProgress, ctor); - var getDerivedStateFromProps = ctor$jscomp$0.getDerivedStateFromProps; - (ctor$jscomp$0 = - "function" === typeof getDerivedStateFromProps || - "function" === typeof unmaskedContext.getSnapshotBeforeUpdate) || - ("function" !== - typeof unmaskedContext.UNSAFE_componentWillReceiveProps && - "function" !== - typeof unmaskedContext.componentWillReceiveProps) || - ((props !== Component || oldContext !== ctor) && - callComponentWillReceiveProps( - workInProgress, - unmaskedContext, - Component, - ctor - )); - hasForceUpdate = !1; - var oldState = workInProgress.memoizedState; - oldContext = unmaskedContext.state = oldState; - var updateQueue = workInProgress.updateQueue; - null !== updateQueue && - (processUpdateQueue( - workInProgress, - updateQueue, - Component, - unmaskedContext, - renderExpirationTime - ), - (oldContext = workInProgress.memoizedState)); - props !== Component || - oldState !== oldContext || - didPerformWorkStackCursor.current || - fn || - hasForceUpdate - ? ("function" === typeof getDerivedStateFromProps && - (applyDerivedStateFromProps( - workInProgress, - getDerivedStateFromProps, - Component - ), - (oldContext = workInProgress.memoizedState)), - (fn = - hasForceUpdate || - fn || - checkShouldComponentUpdate( - workInProgress, - props, - Component, - oldState, - oldContext, - ctor - )) - ? (ctor$jscomp$0 || - ("function" !== - typeof unmaskedContext.UNSAFE_componentWillMount && - "function" !== - typeof unmaskedContext.componentWillMount) || - ("function" === typeof unmaskedContext.componentWillMount && - unmaskedContext.componentWillMount(), - "function" === - typeof unmaskedContext.UNSAFE_componentWillMount && - unmaskedContext.UNSAFE_componentWillMount()), - "function" === typeof unmaskedContext.componentDidMount && - (workInProgress.effectTag |= 4)) - : ("function" === typeof unmaskedContext.componentDidMount && - (workInProgress.effectTag |= 4), - (workInProgress.memoizedProps = Component), - (workInProgress.memoizedState = oldContext)), - (unmaskedContext.props = Component), - (unmaskedContext.state = oldContext), - (unmaskedContext.context = ctor)) - : ("function" === typeof unmaskedContext.componentDidMount && - (workInProgress.effectTag |= 4), - (fn = !1)); - } - else - (ctor$jscomp$0 = workInProgress.type), - (unmaskedContext = workInProgress.stateNode), - (Component = workInProgress.memoizedProps), - (props = workInProgress.pendingProps), - (unmaskedContext.props = Component), - (oldContext = unmaskedContext.context), - (ctor = getUnmaskedContext(workInProgress)), - (ctor = getMaskedContext(workInProgress, ctor)), - (getDerivedStateFromProps = ctor$jscomp$0.getDerivedStateFromProps), - (ctor$jscomp$0 = - "function" === typeof getDerivedStateFromProps || - "function" === typeof unmaskedContext.getSnapshotBeforeUpdate) || - ("function" !== - typeof unmaskedContext.UNSAFE_componentWillReceiveProps && - "function" !== - typeof unmaskedContext.componentWillReceiveProps) || - ((Component !== props || oldContext !== ctor) && - callComponentWillReceiveProps( - workInProgress, - unmaskedContext, - props, - ctor - )), - (hasForceUpdate = !1), - (oldContext = workInProgress.memoizedState), - (oldState = unmaskedContext.state = oldContext), - (updateQueue = workInProgress.updateQueue), - null !== updateQueue && - (processUpdateQueue( - workInProgress, - updateQueue, - props, - unmaskedContext, - renderExpirationTime - ), - (oldState = workInProgress.memoizedState)), - Component !== props || - oldContext !== oldState || - didPerformWorkStackCursor.current || - fn || - hasForceUpdate - ? ("function" === typeof getDerivedStateFromProps && - (applyDerivedStateFromProps( - workInProgress, - getDerivedStateFromProps, - props - ), - (oldState = workInProgress.memoizedState)), - (fn = - hasForceUpdate || - fn || - checkShouldComponentUpdate( - workInProgress, - Component, - props, - oldContext, - oldState, - ctor - )) - ? (ctor$jscomp$0 || - ("function" !== - typeof unmaskedContext.UNSAFE_componentWillUpdate && - "function" !== - typeof unmaskedContext.componentWillUpdate) || - ("function" === - typeof unmaskedContext.componentWillUpdate && - unmaskedContext.componentWillUpdate( - props, - oldState, - ctor - ), - "function" === - typeof unmaskedContext.UNSAFE_componentWillUpdate && - unmaskedContext.UNSAFE_componentWillUpdate( - props, - oldState, - ctor - )), - "function" === typeof unmaskedContext.componentDidUpdate && - (workInProgress.effectTag |= 4), - "function" === - typeof unmaskedContext.getSnapshotBeforeUpdate && - (workInProgress.effectTag |= 256)) - : ("function" !== typeof unmaskedContext.componentDidUpdate || - (Component === current$$1.memoizedProps && - oldContext === current$$1.memoizedState) || - (workInProgress.effectTag |= 4), - "function" !== - typeof unmaskedContext.getSnapshotBeforeUpdate || - (Component === current$$1.memoizedProps && - oldContext === current$$1.memoizedState) || - (workInProgress.effectTag |= 256), - (workInProgress.memoizedProps = props), - (workInProgress.memoizedState = oldState)), - (unmaskedContext.props = props), - (unmaskedContext.state = oldState), - (unmaskedContext.context = ctor)) - : ("function" !== typeof unmaskedContext.componentDidUpdate || - (Component === current$$1.memoizedProps && - oldContext === current$$1.memoizedState) || - (workInProgress.effectTag |= 4), - "function" !== typeof unmaskedContext.getSnapshotBeforeUpdate || - (Component === current$$1.memoizedProps && - oldContext === current$$1.memoizedState) || - (workInProgress.effectTag |= 256), - (fn = !1)); - return finishClassComponent( + case 4: + return mountIndeterminateComponent( current$$1, workInProgress, - fn, - updateExpirationTime, + workInProgress.type, + renderExpirationTime + ); + case 0: + return updateFunctionalComponent( + current$$1, + workInProgress, + workInProgress.type, + workInProgress.pendingProps, + renderExpirationTime + ); + case 1: + var _Component5 = workInProgress.type._reactResult; + updateExpirationTime = workInProgress.pendingProps; + current$$1 = updateFunctionalComponent( + current$$1, + workInProgress, + _Component5, + resolveDefaultProps(_Component5, updateExpirationTime), + renderExpirationTime + ); + workInProgress.memoizedProps = updateExpirationTime; + return current$$1; + case 2: + return updateClassComponent( + current$$1, + workInProgress, + workInProgress.type, + workInProgress.pendingProps, renderExpirationTime ); case 3: + return ( + (_Component5 = workInProgress.type._reactResult), + (updateExpirationTime = workInProgress.pendingProps), + (current$$1 = updateClassComponent( + current$$1, + workInProgress, + _Component5, + resolveDefaultProps(_Component5, updateExpirationTime), + renderExpirationTime + )), + (workInProgress.memoizedProps = updateExpirationTime), + current$$1 + ); + case 5: return ( pushHostRootContext(workInProgress), (updateExpirationTime = workInProgress.updateQueue), @@ -3814,8 +3915,8 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { null !== updateExpirationTime, "If the root does not have an updateQueue, we should have already bailed out. This error is likely caused by a bug in React. Please file an issue." ), - (fn = workInProgress.memoizedState), - (fn = null !== fn ? fn.element : null), + (_Component5 = workInProgress.memoizedState), + (_Component5 = null !== _Component5 ? _Component5.element : null), processUpdateQueue( workInProgress, updateExpirationTime, @@ -3824,8 +3925,8 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { renderExpirationTime ), (updateExpirationTime = workInProgress.memoizedState.element), - updateExpirationTime === fn - ? (current$$1 = bailoutOnAlreadyFinishedWork( + updateExpirationTime === _Component5 + ? (workInProgress = bailoutOnAlreadyFinishedWork( current$$1, workInProgress, renderExpirationTime @@ -3836,22 +3937,27 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { updateExpirationTime, renderExpirationTime ), - (current$$1 = workInProgress.child)), - current$$1 + (workInProgress = workInProgress.child)), + workInProgress ); - case 5: + case 7: return ( pushHostContext(workInProgress), null === current$$1 && tryToClaimNextHydratableInstance(workInProgress), (updateExpirationTime = workInProgress.pendingProps), - (fn = updateExpirationTime.children), + (_Component5 = updateExpirationTime.children), markRef(current$$1, workInProgress), - reconcileChildren(current$$1, workInProgress, fn, renderExpirationTime), + reconcileChildren( + current$$1, + workInProgress, + _Component5, + renderExpirationTime + ), (workInProgress.memoizedProps = updateExpirationTime), - (current$$1 = workInProgress.child), - current$$1 + (workInProgress = workInProgress.child), + workInProgress ); - case 6: + case 8: return ( null === current$$1 && tryToClaimNextHydratableInstance(workInProgress), (workInProgress.memoizedProps = workInProgress.pendingProps), @@ -3859,7 +3965,7 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { ); case 16: return null; - case 4: + case 6: return ( pushHostContainer( workInProgress, @@ -3882,31 +3988,29 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { (workInProgress.memoizedProps = updateExpirationTime), workInProgress.child ); + case 13: + return updateForwardRef( + current$$1, + workInProgress, + workInProgress.type, + workInProgress.pendingProps, + renderExpirationTime + ); case 14: return ( - (fn = workInProgress.type.render), + (_Component5 = workInProgress.type._reactResult), (updateExpirationTime = workInProgress.pendingProps), - (unmaskedContext = workInProgress.ref), - didPerformWorkStackCursor.current || - workInProgress.memoizedProps !== updateExpirationTime || - unmaskedContext !== (null !== current$$1 ? current$$1.ref : null) - ? ((fn = fn(updateExpirationTime, unmaskedContext)), - reconcileChildren( - current$$1, - workInProgress, - fn, - renderExpirationTime - ), - (workInProgress.memoizedProps = updateExpirationTime), - (current$$1 = workInProgress.child)) - : (current$$1 = bailoutOnAlreadyFinishedWork( - current$$1, - workInProgress, - renderExpirationTime - )), + (current$$1 = updateForwardRef( + current$$1, + workInProgress, + _Component5, + resolveDefaultProps(_Component5, updateExpirationTime), + renderExpirationTime + )), + (workInProgress.memoizedProps = updateExpirationTime), current$$1 ); - case 10: + case 9: return ( (updateExpirationTime = workInProgress.pendingProps), reconcileChildren( @@ -3918,7 +4022,7 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { (workInProgress.memoizedProps = updateExpirationTime), workInProgress.child ); - case 11: + case 10: return ( (updateExpirationTime = workInProgress.pendingProps.children), reconcileChildren( @@ -3943,101 +4047,146 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { (workInProgress.memoizedProps = updateExpirationTime), workInProgress.child ); - case 13: + case 12: a: { updateExpirationTime = workInProgress.type._context; - fn = workInProgress.pendingProps; - unmaskedContext = workInProgress.memoizedProps; - Component = fn.value; - workInProgress.memoizedProps = fn; - if (null === unmaskedContext) Component = 1073741823; - else if (unmaskedContext.value === fn.value) { - if ( - unmaskedContext.children === fn.children && - !didPerformWorkStackCursor.current - ) { - workInProgress.stateNode = 0; - pushProvider(workInProgress); - current$$1 = bailoutOnAlreadyFinishedWork( - current$$1, - workInProgress, - renderExpirationTime - ); - break a; - } - Component = 0; - } else if ( - ((props = unmaskedContext.value), - (props === Component && - (0 !== props || 1 / props === 1 / Component)) || - (props !== props && Component !== Component)) - ) { - if ( - unmaskedContext.children === fn.children && - !didPerformWorkStackCursor.current - ) { - workInProgress.stateNode = 0; - pushProvider(workInProgress); - current$$1 = bailoutOnAlreadyFinishedWork( - current$$1, - workInProgress, - renderExpirationTime - ); - break a; - } - Component = 0; - } else if ( - ((Component = - "function" === typeof updateExpirationTime._calculateChangedBits - ? updateExpirationTime._calculateChangedBits(props, Component) - : 1073741823), - (Component |= 0), - 0 === Component) - ) { - if ( - unmaskedContext.children === fn.children && - !didPerformWorkStackCursor.current - ) { - workInProgress.stateNode = 0; - pushProvider(workInProgress); - current$$1 = bailoutOnAlreadyFinishedWork( - current$$1, - workInProgress, - renderExpirationTime - ); - break a; - } - } else - propagateContextChange( - workInProgress, - updateExpirationTime, - Component, - renderExpirationTime - ); - workInProgress.stateNode = Component; - pushProvider(workInProgress); + _Component5 = workInProgress.pendingProps; + var oldProps = workInProgress.memoizedProps, + newValue = _Component5.value; + workInProgress.memoizedProps = _Component5; + pushProvider(workInProgress, newValue); + if (null !== oldProps) { + var oldValue = oldProps.value; + newValue = + (oldValue === newValue && + (0 !== oldValue || 1 / oldValue === 1 / newValue)) || + (oldValue !== oldValue && newValue !== newValue) + ? 0 + : ("function" === + typeof updateExpirationTime._calculateChangedBits + ? updateExpirationTime._calculateChangedBits( + oldValue, + newValue + ) + : 1073741823) | 0; + if (0 === newValue) { + if ( + oldProps.children === _Component5.children && + !didPerformWorkStackCursor.current + ) { + workInProgress = bailoutOnAlreadyFinishedWork( + current$$1, + workInProgress, + renderExpirationTime + ); + break a; + } + } else + for ( + oldProps = workInProgress.child, + null !== oldProps && (oldProps.return = workInProgress); + null !== oldProps; + + ) { + oldValue = oldProps.firstContextDependency; + if (null !== oldValue) { + do { + if ( + oldValue.context === updateExpirationTime && + 0 !== (oldValue.observedBits & newValue) + ) { + if (2 === oldProps.tag || 3 === oldProps.tag) { + var nextFiber = createUpdate(renderExpirationTime); + nextFiber.tag = 2; + enqueueUpdate(oldProps, nextFiber); + } + if ( + 0 === oldProps.expirationTime || + oldProps.expirationTime > renderExpirationTime + ) + oldProps.expirationTime = renderExpirationTime; + nextFiber = oldProps.alternate; + null !== nextFiber && + (0 === nextFiber.expirationTime || + nextFiber.expirationTime > renderExpirationTime) && + (nextFiber.expirationTime = renderExpirationTime); + for (var node = oldProps.return; null !== node; ) { + nextFiber = node.alternate; + if ( + 0 === node.childExpirationTime || + node.childExpirationTime > renderExpirationTime + ) + (node.childExpirationTime = renderExpirationTime), + null !== nextFiber && + (0 === nextFiber.childExpirationTime || + nextFiber.childExpirationTime > + renderExpirationTime) && + (nextFiber.childExpirationTime = renderExpirationTime); + else if ( + null !== nextFiber && + (0 === nextFiber.childExpirationTime || + nextFiber.childExpirationTime > renderExpirationTime) + ) + nextFiber.childExpirationTime = renderExpirationTime; + else break; + node = node.return; + } + } + nextFiber = oldProps.child; + oldValue = oldValue.next; + } while (null !== oldValue); + } else + nextFiber = + 12 === oldProps.tag + ? oldProps.type === workInProgress.type + ? null + : oldProps.child + : oldProps.child; + if (null !== nextFiber) nextFiber.return = oldProps; + else + for (nextFiber = oldProps; null !== nextFiber; ) { + if (nextFiber === workInProgress) { + nextFiber = null; + break; + } + oldProps = nextFiber.sibling; + if (null !== oldProps) { + oldProps.return = nextFiber.return; + nextFiber = oldProps; + break; + } + nextFiber = nextFiber.return; + } + oldProps = nextFiber; + } + } reconcileChildren( current$$1, workInProgress, - fn.children, + _Component5.children, renderExpirationTime ); - current$$1 = workInProgress.child; + workInProgress = workInProgress.child; } - return current$$1; - case 12: + return workInProgress; + case 11: return ( - (unmaskedContext = workInProgress.type), + (newValue = workInProgress.type), (updateExpirationTime = workInProgress.pendingProps), - (fn = updateExpirationTime.children), + (_Component5 = updateExpirationTime.children), prepareToReadContext(workInProgress, renderExpirationTime), - (unmaskedContext = readContext( - unmaskedContext, + (newValue = readContext( + newValue, updateExpirationTime.unstable_observedBits )), - (fn = fn(unmaskedContext)), + (_Component5 = _Component5(newValue)), (workInProgress.effectTag |= 1), - reconcileChildren(current$$1, workInProgress, fn, renderExpirationTime), + reconcileChildren( + current$$1, + workInProgress, + _Component5, + renderExpirationTime + ), (workInProgress.memoizedProps = updateExpirationTime), workInProgress.child ); @@ -4050,9 +4199,9 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { } function appendAllChildren(parent, workInProgress) { for (var node = workInProgress.child; null !== node; ) { - if (5 === node.tag || 6 === node.tag) + if (7 === node.tag || 8 === node.tag) FabricUIManager.appendChild(parent.node, node.stateNode.node); - else if (4 !== node.tag && null !== node.child) { + else if (6 !== node.tag && null !== node.child) { node.child.return = node; node = node.child; continue; @@ -4075,9 +4224,9 @@ updateHostContainer = function(workInProgress) { var container = portalOrRoot.containerInfo, newChildSet = FabricUIManager.createChildSet(container); a: for (var node = workInProgress.child; null !== node; ) { - if (5 === node.tag || 6 === node.tag) + if (7 === node.tag || 8 === node.tag) FabricUIManager.appendChildToSet(newChildSet, node.stateNode.node); - else if (4 !== node.tag && null !== node.child) { + else if (6 !== node.tag && null !== node.child) { node.child.return = node; node = node.child; continue; @@ -4095,35 +4244,48 @@ updateHostContainer = function(workInProgress) { FabricUIManager.completeRoot(container, newChildSet); } }; -updateHostComponent$1 = function(current, workInProgress, updatePayload) { - var childrenUnchanged = null === workInProgress.firstEffect; - current = current.stateNode; - if (childrenUnchanged && null === updatePayload) - workInProgress.stateNode = current; +updateHostComponent$1 = function(current, workInProgress, type, newProps) { + type = current.stateNode; + var oldProps = current.memoizedProps; + if ((current = null === workInProgress.firstEffect) && oldProps === newProps) + workInProgress.stateNode = type; else { - var node = current.node; - updatePayload = { - node: childrenUnchanged - ? null !== updatePayload - ? FabricUIManager.cloneNodeWithNewProps( - node, - updatePayload, - workInProgress - ) - : FabricUIManager.cloneNode(node, workInProgress) - : null !== updatePayload - ? FabricUIManager.cloneNodeWithNewChildrenAndProps( - node, - updatePayload, - workInProgress - ) - : FabricUIManager.cloneNodeWithNewChildren(node, workInProgress), - canonical: current.canonical - }; - workInProgress.stateNode = updatePayload; - childrenUnchanged - ? (workInProgress.effectTag |= 4) - : appendAllChildren(updatePayload, workInProgress); + var recyclableInstance = workInProgress.stateNode; + requiredContext(contextStackCursor$1.current); + var updatePayload = null; + oldProps !== newProps && + ((oldProps = diffProperties( + null, + oldProps, + newProps, + recyclableInstance.canonical.viewConfig.validAttributes + )), + (recyclableInstance.canonical.currentProps = newProps), + (updatePayload = oldProps)); + current && null === updatePayload + ? (workInProgress.stateNode = type) + : ((newProps = updatePayload), + (recyclableInstance = type.node), + (type = { + node: current + ? null !== newProps + ? FabricUIManager.cloneNodeWithNewProps( + recyclableInstance, + newProps + ) + : FabricUIManager.cloneNode(recyclableInstance) + : null !== newProps + ? FabricUIManager.cloneNodeWithNewChildrenAndProps( + recyclableInstance, + newProps + ) + : FabricUIManager.cloneNodeWithNewChildren(recyclableInstance), + canonical: type.canonical + }), + (workInProgress.stateNode = type), + current + ? (workInProgress.effectTag |= 4) + : appendAllChildren(type, workInProgress)); } }; updateHostText$1 = function(current, workInProgress, oldText, newText) { @@ -4138,35 +4300,52 @@ updateHostText$1 = function(current, workInProgress, oldText, newText) { )), (workInProgress.effectTag |= 4)); }; +function logCapturedError(capturedError) { + var componentStack = capturedError.componentStack, + error = capturedError.error; + if (error instanceof Error) { + capturedError = error.message; + var name = error.name; + try { + error.message = + (capturedError ? name + ": " + capturedError : name) + + "\n\nThis error is located at:" + + componentStack; + } catch (e) {} + } else + error = + "string" === typeof error + ? Error(error + "\n\nThis error is located at:" + componentStack) + : Error("Unspecified error at:" + componentStack); + ExceptionsManager.handleException(error, !1); +} function logError(boundary, errorInfo) { var source = errorInfo.source, stack = errorInfo.stack; null === stack && null !== source && (stack = getStackByFiberInDevAndProd(source)); - null !== source && getComponentName(source.type); - source = null !== stack ? stack : ""; - errorInfo = errorInfo.value; - null !== boundary && 2 === boundary.tag && getComponentName(boundary.type); + errorInfo = { + componentName: null !== source ? getComponentName(source.type) : null, + componentStack: null !== stack ? stack : "", + error: errorInfo.value, + errorBoundary: null, + errorBoundaryName: null, + errorBoundaryFound: !1, + willRetry: !1 + }; + null !== boundary && + 2 === boundary.tag && + ((errorInfo.errorBoundary = boundary.stateNode), + (errorInfo.errorBoundaryName = getComponentName(boundary.type)), + (errorInfo.errorBoundaryFound = !0), + (errorInfo.willRetry = !0)); try { - if (errorInfo instanceof Error) { - var message = errorInfo.message, - name = errorInfo.name; - var errorToHandle = errorInfo; - try { - errorToHandle.message = - (message ? name + ": " + message : name) + - "\n\nThis error is located at:" + - source; - } catch (e) {} - } else - errorToHandle = - "string" === typeof errorInfo - ? Error(errorInfo + "\n\nThis error is located at:" + source) - : Error("Unspecified error at:" + source); - ExceptionsManager.handleException(errorToHandle, !1); + logCapturedError(errorInfo); } catch (e) { - (e && e.suppressReactErrorLogging) || console.error(e); + setTimeout(function() { + throw e; + }); } } function safelyDetachRef(current$$1) { @@ -4183,14 +4362,15 @@ function safelyDetachRef(current$$1) { function commitWork(current$$1, finishedWork) { switch (finishedWork.tag) { case 2: + case 3: + break; + case 7: + break; + case 8: break; case 5: - break; case 6: break; - case 3: - case 4: - break; default: invariant( !1, @@ -4228,17 +4408,75 @@ function createClassErrorUpdate(fiber, errorInfo, expirationTime) { }); return expirationTime; } +function throwException( + root, + returnFiber, + sourceFiber, + value, + renderExpirationTime +) { + sourceFiber.effectTag |= 512; + sourceFiber.firstEffect = sourceFiber.lastEffect = null; + nextRenderDidError = !0; + value = createCapturedValue(value, sourceFiber); + root = returnFiber; + do { + switch (root.tag) { + case 5: + root.effectTag |= 1024; + root.expirationTime = renderExpirationTime; + renderExpirationTime = createRootErrorUpdate( + root, + value, + renderExpirationTime + ); + enqueueCapturedUpdate(root, renderExpirationTime); + return; + case 2: + case 3: + if ( + ((returnFiber = value), + (sourceFiber = root.stateNode), + 0 === (root.effectTag & 64) && + null !== sourceFiber && + "function" === typeof sourceFiber.componentDidCatch && + (null === legacyErrorBoundariesThatAlreadyFailed || + !legacyErrorBoundariesThatAlreadyFailed.has(sourceFiber))) + ) { + root.effectTag |= 1024; + root.expirationTime = renderExpirationTime; + renderExpirationTime = createClassErrorUpdate( + root, + returnFiber, + renderExpirationTime + ); + enqueueCapturedUpdate(root, renderExpirationTime); + return; + } + } + root = root.return; + } while (null !== root); +} function unwindWork(workInProgress) { - workInProgress.mode & 4 && recordElapsedActualRenderTime(workInProgress); switch (workInProgress.tag) { case 2: - popContextProvider(workInProgress); + isContextProvider(workInProgress.type) && popContext(workInProgress); var effectTag = workInProgress.effectTag; return effectTag & 1024 ? ((workInProgress.effectTag = (effectTag & -1025) | 64), workInProgress) : null; case 3: + return ( + isContextProvider(workInProgress.type._reactResult) && + popContext(workInProgress), + (effectTag = workInProgress.effectTag), + effectTag & 1024 + ? ((workInProgress.effectTag = (effectTag & -1025) | 64), + workInProgress) + : null + ); + case 5: return ( popHostContainer(workInProgress), popTopLevelContextObject(workInProgress), @@ -4250,7 +4488,7 @@ function unwindWork(workInProgress) { (workInProgress.effectTag = (effectTag & -1025) | 64), workInProgress ); - case 5: + case 7: return popHostContext(workInProgress), null; case 16: return ( @@ -4260,26 +4498,30 @@ function unwindWork(workInProgress) { workInProgress) : null ); - case 4: + case 6: return popHostContainer(workInProgress), null; - case 13: + case 12: return popProvider(workInProgress), null; default: return null; } } var Dispatcher = { readContext: readContext }, - ReactCurrentOwner$2 = ReactSharedInternals.ReactCurrentOwner, - lastUniqueAsyncExpiration = 0, - expirationContext = 0, - isWorking = !1, + ReactCurrentOwner$2 = ReactSharedInternals.ReactCurrentOwner; +invariant( + null != tracking.__interactionsRef && + null != tracking.__interactionsRef.current, + "It is not supported to run the profiling version of a renderer (for example, `react-dom/profiling`) without also replacing the `schedule/tracking` module with `schedule/tracking-profiling`. Your bundler might have a setting for aliasing both modules. Learn more at http://fb.me/react-profiling" +); +var isWorking = !1, nextUnitOfWork = null, nextRoot = null, nextRenderExpirationTime = 0, nextRenderDidError = !1, nextEffect = null, isCommitting$1 = !1, - legacyErrorBoundariesThatAlreadyFailed = null; + legacyErrorBoundariesThatAlreadyFailed = null, + suspenseDidTimeout = !1; function resetStack() { if (null !== nextUnitOfWork) for ( @@ -4287,25 +4529,33 @@ function resetStack() { null !== interruptedWork; ) { - interruptedWork.mode & 4 && resumeActualRenderTimerIfPaused(!1); var interruptedWork$jscomp$0 = interruptedWork; - interruptedWork$jscomp$0.mode & 4 && - recordElapsedActualRenderTime(interruptedWork$jscomp$0); switch (interruptedWork$jscomp$0.tag) { case 2: - popContextProvider(interruptedWork$jscomp$0); + var childContextTypes = + interruptedWork$jscomp$0.type.childContextTypes; + null !== childContextTypes && + void 0 !== childContextTypes && + popContext(interruptedWork$jscomp$0); break; case 3: + childContextTypes = + interruptedWork$jscomp$0.type._reactResult.childContextTypes; + null !== childContextTypes && + void 0 !== childContextTypes && + popContext(interruptedWork$jscomp$0); + break; + case 5: popHostContainer(interruptedWork$jscomp$0); popTopLevelContextObject(interruptedWork$jscomp$0); break; - case 5: + case 7: popHostContext(interruptedWork$jscomp$0); break; - case 4: + case 6: popHostContainer(interruptedWork$jscomp$0); break; - case 13: + case 12: popProvider(interruptedWork$jscomp$0); } interruptedWork = interruptedWork.return; @@ -4315,144 +4565,493 @@ function resetStack() { nextRenderDidError = !1; nextUnitOfWork = null; } +function commitAllHostEffects() { + for (; null !== nextEffect; ) { + var effectTag = nextEffect.effectTag; + if (effectTag & 128) { + var current$$1 = nextEffect.alternate; + null !== current$$1 && + ((current$$1 = current$$1.ref), + null !== current$$1 && + ("function" === typeof current$$1 + ? current$$1(null) + : (current$$1.current = null))); + } + switch (effectTag & 14) { + case 2: + nextEffect.effectTag &= -3; + break; + case 6: + nextEffect.effectTag &= -3; + commitWork(nextEffect.alternate, nextEffect); + break; + case 4: + commitWork(nextEffect.alternate, nextEffect); + break; + case 8: + effectTag = nextEffect; + a: for (var node = (current$$1 = effectTag); ; ) { + var current$$1$jscomp$0 = node; + "function" === typeof onCommitFiberUnmount && + onCommitFiberUnmount(current$$1$jscomp$0); + switch (current$$1$jscomp$0.tag) { + case 2: + case 3: + safelyDetachRef(current$$1$jscomp$0); + var instance = current$$1$jscomp$0.stateNode; + if ("function" === typeof instance.componentWillUnmount) + try { + (instance.props = current$$1$jscomp$0.memoizedProps), + (instance.state = current$$1$jscomp$0.memoizedState), + instance.componentWillUnmount(); + } catch (unmountError) { + captureCommitPhaseError(current$$1$jscomp$0, unmountError); + } + break; + case 7: + safelyDetachRef(current$$1$jscomp$0); + break; + case 6: + FabricUIManager.createChildSet( + current$$1$jscomp$0.stateNode.containerInfo + ); + } + if (null !== node.child) + (node.child.return = node), (node = node.child); + else { + if (node === current$$1) break; + for (; null === node.sibling; ) { + if (null === node.return || node.return === current$$1) break a; + node = node.return; + } + node.sibling.return = node.return; + node = node.sibling; + } + } + effectTag.return = null; + effectTag.child = null; + effectTag.alternate && + ((effectTag.alternate.child = null), + (effectTag.alternate.return = null)); + } + nextEffect = nextEffect.nextEffect; + } +} +function commitBeforeMutationLifecycles() { + for (; null !== nextEffect; ) { + if (nextEffect.effectTag & 256) { + var current$$1 = nextEffect.alternate; + a: { + var finishedWork = nextEffect; + switch (finishedWork.tag) { + case 2: + case 3: + if (finishedWork.effectTag & 256 && null !== current$$1) { + var prevProps = current$$1.memoizedProps, + prevState = current$$1.memoizedState; + current$$1 = finishedWork.stateNode; + current$$1.props = finishedWork.memoizedProps; + current$$1.state = finishedWork.memoizedState; + finishedWork = current$$1.getSnapshotBeforeUpdate( + prevProps, + prevState + ); + current$$1.__reactInternalSnapshotBeforeUpdate = finishedWork; + } + break a; + case 5: + case 7: + case 8: + case 6: + break a; + default: + invariant( + !1, + "This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue." + ); + } + } + } + nextEffect = nextEffect.nextEffect; + } +} +function commitAllLifeCycles( + finishedRoot$jscomp$0, + committedExpirationTime$jscomp$0 +) { + for (; null !== nextEffect; ) { + var effectTag = nextEffect.effectTag; + if (effectTag & 36) { + var finishedRoot = finishedRoot$jscomp$0, + current$$1 = nextEffect.alternate, + finishedWork = nextEffect, + committedExpirationTime = committedExpirationTime$jscomp$0; + switch (finishedWork.tag) { + case 2: + case 3: + finishedRoot = finishedWork.stateNode; + if (finishedWork.effectTag & 4) + if (null === current$$1) + (finishedRoot.props = finishedWork.memoizedProps), + (finishedRoot.state = finishedWork.memoizedState), + finishedRoot.componentDidMount(); + else { + var prevProps = current$$1.memoizedProps; + current$$1 = current$$1.memoizedState; + finishedRoot.props = finishedWork.memoizedProps; + finishedRoot.state = finishedWork.memoizedState; + finishedRoot.componentDidUpdate( + prevProps, + current$$1, + finishedRoot.__reactInternalSnapshotBeforeUpdate + ); + } + current$$1 = finishedWork.updateQueue; + null !== current$$1 && + ((finishedRoot.props = finishedWork.memoizedProps), + (finishedRoot.state = finishedWork.memoizedState), + commitUpdateQueue( + finishedWork, + current$$1, + finishedRoot, + committedExpirationTime + )); + break; + case 5: + current$$1 = finishedWork.updateQueue; + if (null !== current$$1) { + finishedRoot = null; + if (null !== finishedWork.child) + switch (finishedWork.child.tag) { + case 7: + finishedRoot = finishedWork.child.stateNode.canonical; + break; + case 2: + case 3: + finishedRoot = finishedWork.child.stateNode; + } + commitUpdateQueue( + finishedWork, + current$$1, + finishedRoot, + committedExpirationTime + ); + } + break; + case 7: + null === current$$1 && + finishedWork.effectTag & 4 && + invariant( + !1, + "The current renderer does not support mutation. This error is likely caused by a bug in React. Please file an issue." + ); + break; + case 8: + break; + case 6: + break; + case 15: + committedExpirationTime = finishedWork.memoizedProps.onRender; + committedExpirationTime( + finishedWork.memoizedProps.id, + null === current$$1 ? "mount" : "update", + finishedWork.actualDuration, + finishedWork.treeBaseDuration, + finishedWork.actualStartTime, + commitTime, + finishedRoot.memoizedInteractions + ); + break; + case 16: + break; + default: + invariant( + !1, + "This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue." + ); + } + } + if (effectTag & 128 && ((effectTag = nextEffect.ref), null !== effectTag)) { + finishedWork = nextEffect.stateNode; + switch (nextEffect.tag) { + case 7: + finishedWork = finishedWork.canonical; + } + "function" === typeof effectTag + ? effectTag(finishedWork) + : (effectTag.current = finishedWork); + } + effectTag = nextEffect.nextEffect; + nextEffect.nextEffect = null; + nextEffect = effectTag; + } +} +function commitRoot(root, finishedWork) { + isCommitting$1 = isWorking = !0; + invariant( + root.current !== finishedWork, + "Cannot commit the same tree as before. This is probably a bug related to the return field. This error is likely caused by a bug in React. Please file an issue." + ); + var committedExpirationTime = root.pendingCommitExpirationTime; + invariant( + 0 !== committedExpirationTime, + "Cannot commit an incomplete root. This error is likely caused by a bug in React. Please file an issue." + ); + root.pendingCommitExpirationTime = 0; + var updateExpirationTimeBeforeCommit = finishedWork.expirationTime, + childExpirationTimeBeforeCommit = finishedWork.childExpirationTime; + markCommittedPriorityLevels( + root, + 0 === updateExpirationTimeBeforeCommit || + (0 !== childExpirationTimeBeforeCommit && + childExpirationTimeBeforeCommit < updateExpirationTimeBeforeCommit) + ? childExpirationTimeBeforeCommit + : updateExpirationTimeBeforeCommit + ); + updateExpirationTimeBeforeCommit = null; + var committedInteractions = []; + updateExpirationTimeBeforeCommit = tracking.__interactionsRef.current; + tracking.__interactionsRef.current = root.memoizedInteractions; + root.pendingInteractionMap.forEach(function( + scheduledInteractions, + scheduledExpirationTime + ) { + scheduledExpirationTime <= committedExpirationTime && + (committedInteractions.push.apply( + committedInteractions, + Array.from(scheduledInteractions) + ), + root.pendingInteractionMap.delete(scheduledExpirationTime)); + }); + ReactCurrentOwner$2.current = null; + childExpirationTimeBeforeCommit = void 0; + 1 < finishedWork.effectTag + ? null !== finishedWork.lastEffect + ? ((finishedWork.lastEffect.nextEffect = finishedWork), + (childExpirationTimeBeforeCommit = finishedWork.firstEffect)) + : (childExpirationTimeBeforeCommit = finishedWork) + : (childExpirationTimeBeforeCommit = finishedWork.firstEffect); + for (nextEffect = childExpirationTimeBeforeCommit; null !== nextEffect; ) { + var didError = !1, + error$jscomp$0 = void 0; + try { + commitBeforeMutationLifecycles(); + } catch (e) { + (didError = !0), (error$jscomp$0 = e); + } + didError && + (invariant( + null !== nextEffect, + "Should have next effect. This error is likely caused by a bug in React. Please file an issue." + ), + captureCommitPhaseError(nextEffect, error$jscomp$0), + null !== nextEffect && (nextEffect = nextEffect.nextEffect)); + } + commitTime = now$1(); + for (nextEffect = childExpirationTimeBeforeCommit; null !== nextEffect; ) { + didError = !1; + error$jscomp$0 = void 0; + try { + commitAllHostEffects(); + } catch (e) { + (didError = !0), (error$jscomp$0 = e); + } + didError && + (invariant( + null !== nextEffect, + "Should have next effect. This error is likely caused by a bug in React. Please file an issue." + ), + captureCommitPhaseError(nextEffect, error$jscomp$0), + null !== nextEffect && (nextEffect = nextEffect.nextEffect)); + } + root.current = finishedWork; + for (nextEffect = childExpirationTimeBeforeCommit; null !== nextEffect; ) { + childExpirationTimeBeforeCommit = !1; + didError = void 0; + try { + commitAllLifeCycles(root, committedExpirationTime); + } catch (e) { + (childExpirationTimeBeforeCommit = !0), (didError = e); + } + childExpirationTimeBeforeCommit && + (invariant( + null !== nextEffect, + "Should have next effect. This error is likely caused by a bug in React. Please file an issue." + ), + captureCommitPhaseError(nextEffect, didError), + null !== nextEffect && (nextEffect = nextEffect.nextEffect)); + } + isWorking = isCommitting$1 = !1; + "function" === typeof onCommitFiberRoot && + onCommitFiberRoot(finishedWork.stateNode); + childExpirationTimeBeforeCommit = finishedWork.expirationTime; + finishedWork = finishedWork.childExpirationTime; + finishedWork = + 0 === childExpirationTimeBeforeCommit || + (0 !== finishedWork && finishedWork < childExpirationTimeBeforeCommit) + ? finishedWork + : childExpirationTimeBeforeCommit; + 0 === finishedWork && (legacyErrorBoundariesThatAlreadyFailed = null); + onCommit(root, finishedWork); + tracking.__interactionsRef.current = updateExpirationTimeBeforeCommit; + var subscriber = void 0; + try { + if ( + ((subscriber = tracking.__subscriberRef.current), + null !== subscriber && 0 < root.memoizedInteractions.size) + ) + subscriber.onWorkStopped( + root.memoizedInteractions, + 1e3 * committedExpirationTime + root.interactionThreadID + ); + } catch (error) { + hasUnhandledError || ((hasUnhandledError = !0), (unhandledError = error)); + } finally { + suspenseDidTimeout || + committedInteractions.forEach(function(interaction) { + interaction.__count--; + if (null !== subscriber && 0 === interaction.__count) + try { + subscriber.onInteractionScheduledWorkCompleted(interaction); + } catch (error) { + hasUnhandledError || + ((hasUnhandledError = !0), (unhandledError = error)); + } + }); + } +} function completeUnitOfWork(workInProgress) { for (;;) { var current$$1 = workInProgress.alternate, returnFiber = workInProgress.return, siblingFiber = workInProgress.sibling; if (0 === (workInProgress.effectTag & 512)) { + if (workInProgress.mode & 4) { + var fiber = workInProgress; + profilerStartTime = now$1(); + 0 > fiber.actualStartTime && (fiber.actualStartTime = now$1()); + } var current = current$$1; current$$1 = workInProgress; - var newProps = current$$1.pendingProps; + fiber = current$$1.pendingProps; switch (current$$1.tag) { + case 0: case 1: break; case 2: - popContextProvider(current$$1); + isContextProvider(current$$1.type) && popContext(current$$1); break; case 3: + isContextProvider(current$$1.type._reactResult) && + popContext(current$$1); + break; + case 5: popHostContainer(current$$1); popTopLevelContextObject(current$$1); - var fiberRoot = current$$1.stateNode; - fiberRoot.pendingContext && - ((fiberRoot.context = fiberRoot.pendingContext), - (fiberRoot.pendingContext = null)); + fiber = current$$1.stateNode; + fiber.pendingContext && + ((fiber.context = fiber.pendingContext), + (fiber.pendingContext = null)); if (null === current || null === current.child) current$$1.effectTag &= -3; updateHostContainer(current$$1); break; - case 5: + case 7: popHostContext(current$$1); - fiberRoot = requiredContext(rootInstanceStackCursor.current); - var type = current$$1.type; - if (null !== current && null != current$$1.stateNode) { - var oldProps = current.memoizedProps, - instance = current$$1.stateNode, - currentHostContext = requiredContext( - contextStackCursor$1.current - ), - newProps$jscomp$0 = newProps, - updatePayload = diffProperties( - null, - oldProps, - newProps$jscomp$0, - instance.canonical.viewConfig.validAttributes - ); - instance.canonical.currentProps = newProps$jscomp$0; + var rootContainerInstance = requiredContext( + rootInstanceStackCursor.current + ), + type = current$$1.type; + if (null !== current && null != current$$1.stateNode) updateHostComponent$1( current, current$$1, - updatePayload, type, - oldProps, - newProps, - fiberRoot, - currentHostContext + fiber, + rootContainerInstance + ), + current.ref !== current$$1.ref && (current$$1.effectTag |= 128); + else if (fiber) { + var currentHostContext = requiredContext( + contextStackCursor$1.current + ), + internalInstanceHandle = current$$1; + current = nextReactTag; + nextReactTag += 2; + var viewConfig = ReactNativeViewConfigRegistry.get(type); + invariant( + "RCTView" !== type || !currentHostContext.isInAParentText, + "Nesting of within is not currently supported." ); - current.ref !== current$$1.ref && (current$$1.effectTag |= 128); + type = diffProperties( + null, + emptyObject, + fiber, + viewConfig.validAttributes + ); + rootContainerInstance = FabricUIManager.createNode( + current, + viewConfig.uiViewClassName, + rootContainerInstance, + type, + internalInstanceHandle + ); + fiber = new ReactFabricHostComponent(current, viewConfig, fiber); + fiber = { node: rootContainerInstance, canonical: fiber }; + appendAllChildren(fiber, current$$1); + current$$1.stateNode = fiber; + null !== current$$1.ref && (current$$1.effectTag |= 128); } else - newProps - ? ((oldProps = requiredContext(contextStackCursor$1.current)), - (current = newProps), - (instance = oldProps), - (currentHostContext = current$$1), - (newProps = nextReactTag), - (nextReactTag += 2), - (oldProps = ReactNativeViewConfigRegistry.get(type)), - invariant( - "RCTView" !== type || !instance.isInAParentText, - "Nesting of within is not currently supported." - ), - (type = diffProperties( - null, - emptyObject, - current, - oldProps.validAttributes - )), - (fiberRoot = FabricUIManager.createNode( - newProps, - oldProps.uiViewClassName, - fiberRoot, - type, - currentHostContext - )), - (current = new ReactFabricHostComponent( - newProps, - oldProps, - current - )), - (fiberRoot = { node: fiberRoot, canonical: current }), - appendAllChildren(fiberRoot, current$$1), - (current$$1.stateNode = fiberRoot), - null !== current$$1.ref && (current$$1.effectTag |= 128)) - : invariant( - null !== current$$1.stateNode, - "We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue." - ); + invariant( + null !== current$$1.stateNode, + "We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue." + ); break; - case 6: - fiberRoot = newProps; + case 8: current && null != current$$1.stateNode ? updateHostText$1( current, current$$1, current.memoizedProps, - fiberRoot + fiber ) - : ("string" !== typeof fiberRoot && + : ("string" !== typeof fiber && invariant( null !== current$$1.stateNode, "We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue." ), - (current = requiredContext(rootInstanceStackCursor.current)), - (newProps = requiredContext(contextStackCursor$1.current)), + (rootContainerInstance = requiredContext( + rootInstanceStackCursor.current + )), + (current = requiredContext(contextStackCursor$1.current)), (current$$1.stateNode = createTextInstance( - fiberRoot, + fiber, + rootContainerInstance, current, - newProps, current$$1 ))); break; + case 13: case 14: break; case 16: break; - case 10: + case 9: break; - case 11: + case 10: break; case 15: break; - case 4: + case 6: popHostContainer(current$$1); updateHostContainer(current$$1); break; - case 13: + case 12: popProvider(current$$1); break; - case 12: + case 11: break; - case 0: + case 4: invariant( !1, "An indeterminate component should have become determinate before completing. This error is likely caused by a bug in React. Please file an issue." @@ -4463,40 +5062,64 @@ function completeUnitOfWork(workInProgress) { "Unknown unit of work tag. This error is likely caused by a bug in React. Please file an issue." ); } - current$$1.mode & 4 && recordElapsedActualRenderTime(current$$1); - current$$1 = nextUnitOfWork = null; - fiberRoot = workInProgress; + nextUnitOfWork = null; + workInProgress.mode & 4 && + stopProfilerTimerIfRunningAndRecordDelta(workInProgress, !1); + current$$1 = nextUnitOfWork; + fiber = workInProgress; if ( 1073741823 === nextRenderExpirationTime || - 1073741823 !== fiberRoot.childExpirationTime + 1073741823 !== fiber.childExpirationTime ) { - current = 0; - if (fiberRoot.mode & 4) { - newProps = fiberRoot.selfBaseDuration; - for (type = fiberRoot.child; null !== type; ) { - oldProps = type.expirationTime; - currentHostContext = type.childExpirationTime; - if (0 === current || (0 !== oldProps && oldProps < current)) - current = oldProps; + rootContainerInstance = 0; + if (fiber.mode & 4) { + current = fiber.actualDuration; + viewConfig = fiber.selfBaseDuration; + type = + null === fiber.alternate || fiber.child !== fiber.alternate.child; + for ( + internalInstanceHandle = fiber.child; + null !== internalInstanceHandle; + + ) { + currentHostContext = internalInstanceHandle.expirationTime; + var childChildExpirationTime = + internalInstanceHandle.childExpirationTime; if ( - 0 === current || - (0 !== currentHostContext && currentHostContext < current) + 0 === rootContainerInstance || + (0 !== currentHostContext && + currentHostContext < rootContainerInstance) ) - current = currentHostContext; - newProps += type.treeBaseDuration; - type = type.sibling; + rootContainerInstance = currentHostContext; + if ( + 0 === rootContainerInstance || + (0 !== childChildExpirationTime && + childChildExpirationTime < rootContainerInstance) + ) + rootContainerInstance = childChildExpirationTime; + type && (current += internalInstanceHandle.actualDuration); + viewConfig += internalInstanceHandle.treeBaseDuration; + internalInstanceHandle = internalInstanceHandle.sibling; } - fiberRoot.treeBaseDuration = newProps; + fiber.actualDuration = current; + fiber.treeBaseDuration = viewConfig; } else - for (newProps = fiberRoot.child; null !== newProps; ) { - type = newProps.expirationTime; - oldProps = newProps.childExpirationTime; - if (0 === current || (0 !== type && type < current)) current = type; - if (0 === current || (0 !== oldProps && oldProps < current)) - current = oldProps; - newProps = newProps.sibling; + for (current = fiber.child; null !== current; ) { + viewConfig = current.expirationTime; + type = current.childExpirationTime; + if ( + 0 === rootContainerInstance || + (0 !== viewConfig && viewConfig < rootContainerInstance) + ) + rootContainerInstance = viewConfig; + if ( + 0 === rootContainerInstance || + (0 !== type && type < rootContainerInstance) + ) + rootContainerInstance = type; + current = current.sibling; } - fiberRoot.childExpirationTime = current; + fiber.childExpirationTime = rootContainerInstance; } if (null !== current$$1) return current$$1; null !== returnFiber && @@ -4513,9 +5136,20 @@ function completeUnitOfWork(workInProgress) { : (returnFiber.firstEffect = workInProgress), (returnFiber.lastEffect = workInProgress))); } else { + workInProgress.mode & 4 && + stopProfilerTimerIfRunningAndRecordDelta(workInProgress, !1); workInProgress = unwindWork(workInProgress, nextRenderExpirationTime); - if (null !== workInProgress) - return (workInProgress.effectTag &= 511), workInProgress; + if (null !== workInProgress) { + if (workInProgress.mode & 4) { + returnFiber = workInProgress.actualDuration; + for (siblingFiber = workInProgress.child; null !== siblingFiber; ) + (returnFiber += siblingFiber.actualDuration), + (siblingFiber = siblingFiber.sibling); + workInProgress.actualDuration = returnFiber; + } + workInProgress.effectTag &= 511; + return workInProgress; + } null !== returnFiber && ((returnFiber.firstEffect = returnFiber.lastEffect = null), (returnFiber.effectTag |= 512)); @@ -4528,12 +5162,13 @@ function completeUnitOfWork(workInProgress) { } function performUnitOfWork(workInProgress) { var current$$1 = workInProgress.alternate; - workInProgress.mode & 4 && (baseStartTime = now$1()); + workInProgress.mode & 4 && + ((profilerStartTime = now$1()), + 0 > workInProgress.actualStartTime && + (workInProgress.actualStartTime = now$1())); current$$1 = beginWork(current$$1, workInProgress, nextRenderExpirationTime); workInProgress.mode & 4 && - (-1 !== baseStartTime && - (workInProgress.selfBaseDuration = now$1() - baseStartTime), - (baseStartTime = -1)); + stopProfilerTimerIfRunningAndRecordDelta(workInProgress, !0); null === current$$1 && (current$$1 = completeUnitOfWork(workInProgress)); ReactCurrentOwner$2.current = null; return current$$1; @@ -4545,98 +5180,88 @@ function renderRoot(root, isYieldy, isExpired) { ); isWorking = !0; ReactCurrentOwner$2.currentDispatcher = Dispatcher; - var expirationTime = root.nextExpirationTimeToWorkOn; + var expirationTime = root.nextExpirationTimeToWorkOn, + prevInteractions = null; + prevInteractions = tracking.__interactionsRef.current; + tracking.__interactionsRef.current = root.memoizedInteractions; if ( expirationTime !== nextRenderExpirationTime || root !== nextRoot || null === nextUnitOfWork - ) - resetStack(), - (nextRoot = root), - (nextRenderExpirationTime = expirationTime), - (nextUnitOfWork = createWorkInProgress( - nextRoot.current, - null, - nextRenderExpirationTime - )), - (root.pendingCommitExpirationTime = 0); - var didFatal = !1; + ) { + resetStack(); + nextRoot = root; + nextRenderExpirationTime = expirationTime; + nextUnitOfWork = createWorkInProgress( + nextRoot.current, + null, + nextRenderExpirationTime + ); + root.pendingCommitExpirationTime = 0; + var interactions = new Set(); + root.pendingInteractionMap.forEach(function( + scheduledInteractions, + scheduledExpirationTime + ) { + scheduledExpirationTime <= expirationTime && + scheduledInteractions.forEach(function(interaction) { + return interactions.add(interaction); + }); + }); + root.memoizedInteractions = interactions; + if (0 < interactions.size) { + var subscriber = tracking.__subscriberRef.current; + if (null !== subscriber) { + var threadID = 1e3 * expirationTime + root.interactionThreadID; + try { + subscriber.onWorkStarted(interactions, threadID); + } catch (error) { + hasUnhandledError || + ((hasUnhandledError = !0), (unhandledError = error)); + } + } + } + } + subscriber = !1; do { try { - if (isYieldy) { + if (isYieldy) for (; null !== nextUnitOfWork && !shouldYield(); ) nextUnitOfWork = performUnitOfWork(nextUnitOfWork); - pauseActualRenderTimerIfRunning(); - } else + else for (; null !== nextUnitOfWork; ) nextUnitOfWork = performUnitOfWork(nextUnitOfWork); } catch (thrownValue) { - if (((baseStartTime = -1), null === nextUnitOfWork)) - (didFatal = !0), onUncaughtError(thrownValue); + if (null === nextUnitOfWork) + (subscriber = !0), onUncaughtError(thrownValue); else { invariant( null !== nextUnitOfWork, "Failed to replay rendering after an error. This is likely caused by a bug in React. Please file an issue with a reproducing case to help us find it." ); - var sourceFiber = nextUnitOfWork, - returnFiber = sourceFiber.return; - if (null === returnFiber) (didFatal = !0), onUncaughtError(thrownValue); + threadID = nextUnitOfWork; + var returnFiber = threadID.return; + if (null === returnFiber) + (subscriber = !0), onUncaughtError(thrownValue); else { - a: { - var returnFiber$jscomp$0 = returnFiber, - sourceFiber$jscomp$0 = sourceFiber, - value = thrownValue; - returnFiber = nextRenderExpirationTime; - sourceFiber$jscomp$0.effectTag |= 512; - sourceFiber$jscomp$0.firstEffect = sourceFiber$jscomp$0.lastEffect = null; - nextRenderDidError = !0; - value = createCapturedValue(value, sourceFiber$jscomp$0); - do { - switch (returnFiber$jscomp$0.tag) { - case 3: - returnFiber$jscomp$0.effectTag |= 1024; - returnFiber$jscomp$0.expirationTime = returnFiber; - returnFiber = createRootErrorUpdate( - returnFiber$jscomp$0, - value, - returnFiber - ); - enqueueCapturedUpdate(returnFiber$jscomp$0, returnFiber); - break a; - case 2: - sourceFiber$jscomp$0 = value; - var instance = returnFiber$jscomp$0.stateNode; - if ( - 0 === (returnFiber$jscomp$0.effectTag & 64) && - null !== instance && - "function" === typeof instance.componentDidCatch && - (null === legacyErrorBoundariesThatAlreadyFailed || - !legacyErrorBoundariesThatAlreadyFailed.has(instance)) - ) { - returnFiber$jscomp$0.effectTag |= 1024; - returnFiber$jscomp$0.expirationTime = returnFiber; - returnFiber = createClassErrorUpdate( - returnFiber$jscomp$0, - sourceFiber$jscomp$0, - returnFiber - ); - enqueueCapturedUpdate(returnFiber$jscomp$0, returnFiber); - break a; - } - } - returnFiber$jscomp$0 = returnFiber$jscomp$0.return; - } while (null !== returnFiber$jscomp$0); - } - nextUnitOfWork = completeUnitOfWork(sourceFiber); + throwException( + root, + returnFiber, + threadID, + thrownValue, + nextRenderExpirationTime + ); + nextUnitOfWork = completeUnitOfWork(threadID); continue; } } } break; } while (1); + tracking.__interactionsRef.current = prevInteractions; isWorking = !1; lastContextWithAllBitsObserved = lastContextDependency = currentlyRenderingFiber = ReactCurrentOwner$2.currentDispatcher = null; - if (didFatal) (nextRoot = null), (root.finishedWork = null); + if (subscriber) (nextRoot = null), (root.finishedWork = null); else if (null !== nextUnitOfWork) root.finishedWork = null; else { isYieldy = root.current.alternate; @@ -4646,48 +5271,20 @@ function renderRoot(root, isYieldy, isExpired) { ); nextRoot = null; if (nextRenderDidError) { - didFatal = root.latestPendingTime; - sourceFiber = root.latestSuspendedTime; - returnFiber = root.latestPingedTime; - if ( - (0 !== didFatal && didFatal > expirationTime) || - (0 !== sourceFiber && sourceFiber > expirationTime) || - (0 !== returnFiber && returnFiber > expirationTime) - ) { - root.didError = !1; - isExpired = root.latestPingedTime; - 0 !== isExpired && - isExpired <= expirationTime && - (root.latestPingedTime = 0); - isExpired = root.earliestPendingTime; - isYieldy = root.latestPendingTime; - isExpired === expirationTime - ? (root.earliestPendingTime = - isYieldy === expirationTime - ? (root.latestPendingTime = 0) - : isYieldy) - : isYieldy === expirationTime && (root.latestPendingTime = isExpired); - isExpired = root.earliestSuspendedTime; - isYieldy = root.latestSuspendedTime; - 0 === isExpired - ? (root.earliestSuspendedTime = root.latestSuspendedTime = expirationTime) - : isExpired > expirationTime - ? (root.earliestSuspendedTime = expirationTime) - : isYieldy < expirationTime && - (root.latestSuspendedTime = expirationTime); - findNextExpirationTimeToWorkOn(expirationTime, root); - root.expirationTime = root.expirationTime; + if (hasLowerPriorityWork(root, expirationTime)) { + markSuspendedPriorityLevel(root, expirationTime); + onSuspend(root, isYieldy, expirationTime, root.expirationTime, -1); return; } if (!root.didError && !isExpired) { root.didError = !0; - root.nextExpirationTimeToWorkOn = expirationTime; - root.expirationTime = 1; + isExpired = root.nextExpirationTimeToWorkOn = expirationTime; + prevInteractions = root.expirationTime = 1; + onSuspend(root, isYieldy, isExpired, prevInteractions, -1); return; } } - root.pendingCommitExpirationTime = expirationTime; - root.finishedWork = isYieldy; + onComplete(root, isYieldy, expirationTime); } } function captureCommitPhaseError(fiber, error) { @@ -4704,6 +5301,7 @@ function captureCommitPhaseError(fiber, error) { ) { switch (JSCompiler_inline_result.tag) { case 2: + case 3: var instance = JSCompiler_inline_result.stateNode; if ( "function" === @@ -4720,7 +5318,7 @@ function captureCommitPhaseError(fiber, error) { break a; } break; - case 3: + case 5: fiber = createCapturedValue(error, fiber); fiber = createRootErrorUpdate(JSCompiler_inline_result, fiber, 1); enqueueUpdate(JSCompiler_inline_result, fiber); @@ -4730,7 +5328,7 @@ function captureCommitPhaseError(fiber, error) { } JSCompiler_inline_result = JSCompiler_inline_result.return; } - 3 === fiber.tag && + 5 === fiber.tag && ((JSCompiler_inline_result = createCapturedValue(error, fiber)), (JSCompiler_inline_result = createRootErrorUpdate( fiber, @@ -4744,24 +5342,50 @@ function captureCommitPhaseError(fiber, error) { return JSCompiler_inline_result; } function computeExpirationForFiber(currentTime, fiber) { - 0 !== expirationContext - ? (currentTime = expirationContext) - : isWorking - ? (currentTime = isCommitting$1 ? 1 : nextRenderExpirationTime) - : fiber.mode & 1 - ? ((currentTime = isBatchingInteractiveUpdates - ? 2 + 10 * ((((currentTime - 2 + 15) / 10) | 0) + 1) - : 2 + 25 * ((((currentTime - 2 + 500) / 25) | 0) + 1)), - null !== nextRoot && - currentTime === nextRenderExpirationTime && - (currentTime += 1)) - : (currentTime = 1); + isWorking + ? (currentTime = isCommitting$1 ? 1 : nextRenderExpirationTime) + : fiber.mode & 1 + ? ((currentTime = isBatchingInteractiveUpdates + ? 2 + 10 * ((((currentTime - 2 + 15) / 10) | 0) + 1) + : 2 + 25 * ((((currentTime - 2 + 500) / 25) | 0) + 1)), + null !== nextRoot && + currentTime === nextRenderExpirationTime && + (currentTime += 1)) + : (currentTime = 1); isBatchingInteractiveUpdates && - (0 === lowestPendingInteractiveExpirationTime || - currentTime > lowestPendingInteractiveExpirationTime) && - (lowestPendingInteractiveExpirationTime = currentTime); + (0 === lowestPriorityPendingInteractiveExpirationTime || + currentTime > lowestPriorityPendingInteractiveExpirationTime) && + (lowestPriorityPendingInteractiveExpirationTime = currentTime); return currentTime; } +function storeInteractionsForExpirationTime( + root, + expirationTime, + updateInteractionCounts +) { + var interactions = tracking.__interactionsRef.current; + if (0 < interactions.size) { + var pendingInteractions = root.pendingInteractionMap.get(expirationTime); + null != pendingInteractions + ? interactions.forEach(function(interaction) { + updateInteractionCounts && + !pendingInteractions.has(interaction) && + interaction.__count++; + pendingInteractions.add(interaction); + }) + : (root.pendingInteractionMap.set(expirationTime, new Set(interactions)), + updateInteractionCounts && + interactions.forEach(function(interaction) { + interaction.__count++; + })); + var subscriber = tracking.__subscriberRef.current; + if (null !== subscriber) + subscriber.onWorkScheduled( + interactions, + 1e3 * expirationTime + root.interactionThreadID + ); + } +} function scheduleWork(fiber, expirationTime) { a: { if (0 === fiber.expirationTime || fiber.expirationTime > expirationTime) @@ -4772,7 +5396,7 @@ function scheduleWork(fiber, expirationTime) { alternate.expirationTime > expirationTime) && (alternate.expirationTime = expirationTime); var node = fiber.return; - if (null === node && 3 === fiber.tag) fiber = fiber.stateNode; + if (null === node && 5 === fiber.tag) fiber = fiber.stateNode; else { for (; null !== node; ) { alternate = node.alternate; @@ -4785,7 +5409,7 @@ function scheduleWork(fiber, expirationTime) { (0 === alternate.childExpirationTime || alternate.childExpirationTime > expirationTime) && (alternate.childExpirationTime = expirationTime); - if (null === node.return && 3 === node.tag) { + if (null === node.return && 5 === node.tag) { fiber = node.stateNode; break a; } @@ -4794,28 +5418,44 @@ function scheduleWork(fiber, expirationTime) { fiber = null; } } - null !== fiber && - (!isWorking && + if (null !== fiber) { + storeInteractionsForExpirationTime(fiber, expirationTime, !0); + !isWorking && 0 !== nextRenderExpirationTime && expirationTime < nextRenderExpirationTime && - resetStack(), - markPendingPriorityLevel(fiber, expirationTime), - (isWorking && !isCommitting$1 && nextRoot === fiber) || - requestWork(fiber, fiber.expirationTime), + resetStack(); + markPendingPriorityLevel(fiber, expirationTime); + if (!isWorking || isCommitting$1 || nextRoot !== fiber) { + expirationTime = fiber; + fiber = fiber.expirationTime; + if (null === expirationTime.nextScheduledRoot) + (expirationTime.expirationTime = fiber), + null === lastScheduledRoot + ? ((firstScheduledRoot = lastScheduledRoot = expirationTime), + (expirationTime.nextScheduledRoot = expirationTime)) + : ((lastScheduledRoot = lastScheduledRoot.nextScheduledRoot = expirationTime), + (lastScheduledRoot.nextScheduledRoot = firstScheduledRoot)); + else if ( + ((alternate = expirationTime.expirationTime), + 0 === alternate || fiber < alternate) + ) + expirationTime.expirationTime = fiber; + isRendering || + (isBatchingUpdates + ? isUnbatchingUpdates && + ((nextFlushedRoot = expirationTime), + (nextFlushedExpirationTime = 1), + performWorkOnRoot(expirationTime, 1, !0)) + : 1 === fiber + ? performWork(1, null) + : scheduleCallbackWithExpirationTime(expirationTime, fiber)); + } nestedUpdateCount > NESTED_UPDATE_LIMIT && ((nestedUpdateCount = 0), invariant( !1, "Maximum update depth exceeded. This can happen when a component repeatedly calls setState inside componentWillUpdate or componentDidUpdate. React limits the number of nested updates to prevent infinite loops." - ))); -} -function syncUpdates(fn, a, b, c, d) { - var previousExpirationContext = expirationContext; - expirationContext = 1; - try { - return fn(a, b, c, d); - } finally { - expirationContext = previousExpirationContext; + )); } } var firstScheduledRoot = null, @@ -4825,7 +5465,7 @@ var firstScheduledRoot = null, isRendering = !1, nextFlushedRoot = null, nextFlushedExpirationTime = 0, - lowestPendingInteractiveExpirationTime = 0, + lowestPriorityPendingInteractiveExpirationTime = 0, deadlineDidExpire = !1, hasUnhandledError = !1, unhandledError = null, @@ -4844,20 +5484,40 @@ var firstScheduledRoot = null, function recomputeCurrentRendererTime() { currentRendererTime = (((now$1() - originalStartTimeMs) / 10) | 0) + 2; } -function scheduleCallbackWithExpirationTime(expirationTime) { +function scheduleCallbackWithExpirationTime(root, expirationTime) { if (0 !== callbackExpirationTime) { if (expirationTime > callbackExpirationTime) return; - if (null !== callbackID) { - var callbackID$jscomp$0 = callbackID; - scheduledCallback = null; - clearTimeout(callbackID$jscomp$0); - } + null !== callbackID && + ((root = callbackID), (scheduledCallback = null), clearTimeout(root)); } callbackExpirationTime = expirationTime; now$1(); scheduledCallback = performAsyncWork; callbackID = setTimeout(setTimeoutCallback, 1); } +function onComplete(root, finishedWork, expirationTime) { + root.pendingCommitExpirationTime = expirationTime; + root.finishedWork = finishedWork; +} +function onSuspend( + root, + finishedWork, + suspendedExpirationTime, + rootExpirationTime, + msUntilTimeout +) { + root.expirationTime = rootExpirationTime; + 0 < msUntilTimeout && + (root.timeoutHandle = scheduleTimeout( + onTimeout.bind(null, root, finishedWork, suspendedExpirationTime), + msUntilTimeout + )); +} +function onTimeout() {} +function onCommit(root, expirationTime) { + root.expirationTime = expirationTime; + root.finishedWork = null; +} function requestCurrentTime() { if (isRendering) return currentSchedulerTime; findHighestPriorityRoot(); @@ -4869,32 +5529,6 @@ function requestCurrentTime() { (currentSchedulerTime = currentRendererTime); return currentSchedulerTime; } -function requestWork(root, expirationTime) { - if (null === root.nextScheduledRoot) - (root.expirationTime = expirationTime), - null === lastScheduledRoot - ? ((firstScheduledRoot = lastScheduledRoot = root), - (root.nextScheduledRoot = root)) - : ((lastScheduledRoot = lastScheduledRoot.nextScheduledRoot = root), - (lastScheduledRoot.nextScheduledRoot = firstScheduledRoot)); - else { - var remainingExpirationTime = root.expirationTime; - if ( - 0 === remainingExpirationTime || - expirationTime < remainingExpirationTime - ) - root.expirationTime = expirationTime; - } - isRendering || - (isBatchingUpdates - ? isUnbatchingUpdates && - ((nextFlushedRoot = root), - (nextFlushedExpirationTime = 1), - performWorkOnRoot(root, 1, !0)) - : 1 === expirationTime - ? performWork(1, null) - : scheduleCallbackWithExpirationTime(expirationTime)); -} function findHighestPriorityRoot() { var highestPriorityWork = 0, highestPriorityRoot = null; @@ -4935,6 +5569,7 @@ function findHighestPriorityRoot() { (highestPriorityWork = remainingExpirationTime), (highestPriorityRoot = root); if (root === lastScheduledRoot) break; + if (1 === highestPriorityWork) break; previousScheduledRoot = root; root = root.nextScheduledRoot; } @@ -4943,12 +5578,22 @@ function findHighestPriorityRoot() { nextFlushedExpirationTime = highestPriorityWork; } function performAsyncWork(dl) { + if (dl.didTimeout && null !== firstScheduledRoot) { + recomputeCurrentRendererTime(); + var root = firstScheduledRoot; + do { + var expirationTime = root.expirationTime; + 0 !== expirationTime && + currentRendererTime >= expirationTime && + (root.nextExpirationTimeToWorkOn = currentRendererTime); + root = root.nextScheduledRoot; + } while (root !== firstScheduledRoot); + } performWork(0, dl); } function performWork(minExpirationTime, dl) { deadline = dl; findHighestPriorityRoot(); - resumeActualRenderTimerIfPaused(1 === minExpirationTime); if (null !== deadline) for ( recomputeCurrentRendererTime(), @@ -4981,7 +5626,10 @@ function performWork(minExpirationTime, dl) { findHighestPriorityRoot(); null !== deadline && ((callbackExpirationTime = 0), (callbackID = null)); 0 !== nextFlushedExpirationTime && - scheduleCallbackWithExpirationTime(nextFlushedExpirationTime); + scheduleCallbackWithExpirationTime( + nextFlushedRoot, + nextFlushedExpirationTime + ); deadline = null; deadlineDidExpire = !1; nestedUpdateCount = 0; @@ -5030,12 +5678,11 @@ function performWorkOnRoot(root, expirationTime, isExpired) { (finishedWork = root.finishedWork), null !== finishedWork && (shouldYield() - ? ((root.finishedWork = finishedWork), - pauseActualRenderTimerIfRunning()) + ? (root.finishedWork = finishedWork) : completeRoot$1(root, finishedWork, expirationTime))); isRendering = !1; } -function completeRoot$1(root, finishedWork$jscomp$0, expirationTime) { +function completeRoot$1(root, finishedWork, expirationTime) { var firstBatch = root.firstBatch; if ( null !== firstBatch && @@ -5045,7 +5692,7 @@ function completeRoot$1(root, finishedWork$jscomp$0, expirationTime) { : completedBatches.push(firstBatch), firstBatch._defer) ) { - root.finishedWork = finishedWork$jscomp$0; + root.finishedWork = finishedWork; root.expirationTime = 0; return; } @@ -5053,330 +5700,7 @@ function completeRoot$1(root, finishedWork$jscomp$0, expirationTime) { root === lastCommittedRootDuringThisBatch ? nestedUpdateCount++ : ((lastCommittedRootDuringThisBatch = root), (nestedUpdateCount = 0)); - isCommitting$1 = isWorking = !0; - invariant( - root.current !== finishedWork$jscomp$0, - "Cannot commit the same tree as before. This is probably a bug related to the return field. This error is likely caused by a bug in React. Please file an issue." - ); - expirationTime = root.pendingCommitExpirationTime; - invariant( - 0 !== expirationTime, - "Cannot commit an incomplete root. This error is likely caused by a bug in React. Please file an issue." - ); - root.pendingCommitExpirationTime = 0; - firstBatch = finishedWork$jscomp$0.expirationTime; - var childExpirationTimeBeforeCommit = - finishedWork$jscomp$0.childExpirationTime; - firstBatch = - 0 === firstBatch || - (0 !== childExpirationTimeBeforeCommit && - childExpirationTimeBeforeCommit < firstBatch) - ? childExpirationTimeBeforeCommit - : firstBatch; - root.didError = !1; - 0 === firstBatch - ? ((root.earliestPendingTime = 0), - (root.latestPendingTime = 0), - (root.earliestSuspendedTime = 0), - (root.latestSuspendedTime = 0), - (root.latestPingedTime = 0)) - : ((childExpirationTimeBeforeCommit = root.latestPendingTime), - 0 !== childExpirationTimeBeforeCommit && - (childExpirationTimeBeforeCommit < firstBatch - ? (root.earliestPendingTime = root.latestPendingTime = 0) - : root.earliestPendingTime < firstBatch && - (root.earliestPendingTime = root.latestPendingTime)), - (childExpirationTimeBeforeCommit = root.earliestSuspendedTime), - 0 === childExpirationTimeBeforeCommit - ? markPendingPriorityLevel(root, firstBatch) - : firstBatch > root.latestSuspendedTime - ? ((root.earliestSuspendedTime = 0), - (root.latestSuspendedTime = 0), - (root.latestPingedTime = 0), - markPendingPriorityLevel(root, firstBatch)) - : firstBatch < childExpirationTimeBeforeCommit && - markPendingPriorityLevel(root, firstBatch)); - findNextExpirationTimeToWorkOn(0, root); - ReactCurrentOwner$2.current = null; - 1 < finishedWork$jscomp$0.effectTag - ? null !== finishedWork$jscomp$0.lastEffect - ? ((finishedWork$jscomp$0.lastEffect.nextEffect = finishedWork$jscomp$0), - (firstBatch = finishedWork$jscomp$0.firstEffect)) - : (firstBatch = finishedWork$jscomp$0) - : (firstBatch = finishedWork$jscomp$0.firstEffect); - for (nextEffect = firstBatch; null !== nextEffect; ) { - childExpirationTimeBeforeCommit = !1; - var error = void 0; - try { - for (; null !== nextEffect; ) { - if (nextEffect.effectTag & 256) { - var current$$1 = nextEffect.alternate, - finishedWork = nextEffect; - switch (finishedWork.tag) { - case 2: - if (finishedWork.effectTag & 256 && null !== current$$1) { - var prevProps = current$$1.memoizedProps, - prevState = current$$1.memoizedState, - instance = finishedWork.stateNode; - instance.props = finishedWork.memoizedProps; - instance.state = finishedWork.memoizedState; - var snapshot = instance.getSnapshotBeforeUpdate( - prevProps, - prevState - ); - instance.__reactInternalSnapshotBeforeUpdate = snapshot; - } - break; - case 3: - case 5: - case 6: - case 4: - break; - default: - invariant( - !1, - "This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue." - ); - } - } - nextEffect = nextEffect.nextEffect; - } - } catch (e) { - (childExpirationTimeBeforeCommit = !0), (error = e); - } - childExpirationTimeBeforeCommit && - (invariant( - null !== nextEffect, - "Should have next effect. This error is likely caused by a bug in React. Please file an issue." - ), - captureCommitPhaseError(nextEffect, error), - null !== nextEffect && (nextEffect = nextEffect.nextEffect)); - } - now$1(); - for (nextEffect = firstBatch; null !== nextEffect; ) { - current$$1 = !1; - prevProps = void 0; - try { - for (; null !== nextEffect; ) { - var effectTag = nextEffect.effectTag; - if (effectTag & 128) { - var current$$1$jscomp$0 = nextEffect.alternate; - if (null !== current$$1$jscomp$0) { - var currentRef = current$$1$jscomp$0.ref; - null !== currentRef && - ("function" === typeof currentRef - ? currentRef(null) - : (currentRef.current = null)); - } - } - switch (effectTag & 14) { - case 2: - nextEffect.effectTag &= -3; - break; - case 6: - nextEffect.effectTag &= -3; - commitWork(nextEffect.alternate, nextEffect); - break; - case 4: - commitWork(nextEffect.alternate, nextEffect); - break; - case 8: - prevState = nextEffect; - a: for (snapshot = instance = prevState; ; ) { - childExpirationTimeBeforeCommit = snapshot; - "function" === typeof onCommitFiberUnmount && - onCommitFiberUnmount(childExpirationTimeBeforeCommit); - switch (childExpirationTimeBeforeCommit.tag) { - case 2: - safelyDetachRef(childExpirationTimeBeforeCommit); - var instance$jscomp$0 = - childExpirationTimeBeforeCommit.stateNode; - if ( - "function" === typeof instance$jscomp$0.componentWillUnmount - ) - try { - (instance$jscomp$0.props = - childExpirationTimeBeforeCommit.memoizedProps), - (instance$jscomp$0.state = - childExpirationTimeBeforeCommit.memoizedState), - instance$jscomp$0.componentWillUnmount(); - } catch (unmountError) { - captureCommitPhaseError( - childExpirationTimeBeforeCommit, - unmountError - ); - } - break; - case 5: - safelyDetachRef(childExpirationTimeBeforeCommit); - break; - case 4: - FabricUIManager.createChildSet( - childExpirationTimeBeforeCommit.stateNode.containerInfo - ); - } - if (null !== snapshot.child) - (snapshot.child.return = snapshot), (snapshot = snapshot.child); - else { - if (snapshot === instance) break; - for (; null === snapshot.sibling; ) { - if (null === snapshot.return || snapshot.return === instance) - break a; - snapshot = snapshot.return; - } - snapshot.sibling.return = snapshot.return; - snapshot = snapshot.sibling; - } - } - prevState.return = null; - prevState.child = null; - prevState.alternate && - ((prevState.alternate.child = null), - (prevState.alternate.return = null)); - } - nextEffect = nextEffect.nextEffect; - } - } catch (e) { - (current$$1 = !0), (prevProps = e); - } - current$$1 && - (invariant( - null !== nextEffect, - "Should have next effect. This error is likely caused by a bug in React. Please file an issue." - ), - captureCommitPhaseError(nextEffect, prevProps), - null !== nextEffect && (nextEffect = nextEffect.nextEffect)); - } - root.current = finishedWork$jscomp$0; - for (nextEffect = firstBatch; null !== nextEffect; ) { - effectTag = !1; - current$$1$jscomp$0 = void 0; - try { - for (currentRef = expirationTime; null !== nextEffect; ) { - var effectTag$jscomp$0 = nextEffect.effectTag; - if (effectTag$jscomp$0 & 36) { - var current$$1$jscomp$1 = nextEffect.alternate; - instance$jscomp$0 = nextEffect; - firstBatch = currentRef; - switch (instance$jscomp$0.tag) { - case 2: - var instance$jscomp$1 = instance$jscomp$0.stateNode; - if (instance$jscomp$0.effectTag & 4) - if (null === current$$1$jscomp$1) - (instance$jscomp$1.props = instance$jscomp$0.memoizedProps), - (instance$jscomp$1.state = instance$jscomp$0.memoizedState), - instance$jscomp$1.componentDidMount(); - else { - var prevProps$jscomp$0 = current$$1$jscomp$1.memoizedProps, - prevState$jscomp$0 = current$$1$jscomp$1.memoizedState; - instance$jscomp$1.props = instance$jscomp$0.memoizedProps; - instance$jscomp$1.state = instance$jscomp$0.memoizedState; - instance$jscomp$1.componentDidUpdate( - prevProps$jscomp$0, - prevState$jscomp$0, - instance$jscomp$1.__reactInternalSnapshotBeforeUpdate - ); - } - var updateQueue = instance$jscomp$0.updateQueue; - null !== updateQueue && - ((instance$jscomp$1.props = instance$jscomp$0.memoizedProps), - (instance$jscomp$1.state = instance$jscomp$0.memoizedState), - commitUpdateQueue( - instance$jscomp$0, - updateQueue, - instance$jscomp$1, - firstBatch - )); - break; - case 3: - var _updateQueue = instance$jscomp$0.updateQueue; - if (null !== _updateQueue) { - current$$1 = null; - if (null !== instance$jscomp$0.child) - switch (instance$jscomp$0.child.tag) { - case 5: - current$$1 = instance$jscomp$0.child.stateNode.canonical; - break; - case 2: - current$$1 = instance$jscomp$0.child.stateNode; - } - commitUpdateQueue( - instance$jscomp$0, - _updateQueue, - current$$1, - firstBatch - ); - } - break; - case 5: - null === current$$1$jscomp$1 && - instance$jscomp$0.effectTag & 4 && - invariant( - !1, - "The current renderer does not support mutation. This error is likely caused by a bug in React. Please file an issue." - ); - break; - case 6: - break; - case 4: - break; - case 15: - break; - case 16: - break; - default: - invariant( - !1, - "This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue." - ); - } - } - if (effectTag$jscomp$0 & 128) { - instance$jscomp$0 = void 0; - var ref = nextEffect.ref; - if (null !== ref) { - var instance$jscomp$2 = nextEffect.stateNode; - switch (nextEffect.tag) { - case 5: - instance$jscomp$0 = instance$jscomp$2.canonical; - break; - default: - instance$jscomp$0 = instance$jscomp$2; - } - "function" === typeof ref - ? ref(instance$jscomp$0) - : (ref.current = instance$jscomp$0); - } - } - var next = nextEffect.nextEffect; - nextEffect.nextEffect = null; - nextEffect = next; - } - } catch (e) { - (effectTag = !0), (current$$1$jscomp$0 = e); - } - effectTag && - (invariant( - null !== nextEffect, - "Should have next effect. This error is likely caused by a bug in React. Please file an issue." - ), - captureCommitPhaseError(nextEffect, current$$1$jscomp$0), - null !== nextEffect && (nextEffect = nextEffect.nextEffect)); - } - isWorking = isCommitting$1 = !1; - "function" === typeof onCommitFiberRoot && - onCommitFiberRoot(finishedWork$jscomp$0.stateNode); - effectTag$jscomp$0 = finishedWork$jscomp$0.expirationTime; - finishedWork$jscomp$0 = finishedWork$jscomp$0.childExpirationTime; - finishedWork$jscomp$0 = - 0 === effectTag$jscomp$0 || - (0 !== finishedWork$jscomp$0 && finishedWork$jscomp$0 < effectTag$jscomp$0) - ? finishedWork$jscomp$0 - : effectTag$jscomp$0; - 0 === finishedWork$jscomp$0 && - (legacyErrorBoundariesThatAlreadyFailed = null); - root.expirationTime = finishedWork$jscomp$0; - root.finishedWork = null; + commitRoot(root, finishedWork); } function shouldYield() { return deadlineDidExpire @@ -5393,51 +5717,54 @@ function onUncaughtError(error) { nextFlushedRoot.expirationTime = 0; hasUnhandledError || ((hasUnhandledError = !0), (unhandledError = error)); } -function updateContainerAtExpirationTime( - element, - container, - parentComponent, - expirationTime, - callback -) { - var current$$1 = container.current; - if (parentComponent) { - parentComponent = parentComponent._reactInternalFiber; - var parentContext; - b: { - invariant( - 2 === isFiberMountedImpl(parentComponent) && 2 === parentComponent.tag, - "Expected subtree parent to be a mounted class component. This error is likely caused by a bug in React. Please file an issue." - ); - for (parentContext = parentComponent; 3 !== parentContext.tag; ) { - if (isContextProvider(parentContext)) { - parentContext = - parentContext.stateNode.__reactInternalMemoizedMergedChildContext; - break b; - } - parentContext = parentContext.return; - invariant( - parentContext, - "Found unexpected detached subtree parent. This error is likely caused by a bug in React. Please file an issue." - ); +function getContextForSubtree(parentComponent) { + if (!parentComponent) return emptyContextObject; + parentComponent = parentComponent._reactInternalFiber; + a: { + invariant( + 2 === isFiberMountedImpl(parentComponent) && + (2 === parentComponent.tag || 3 === parentComponent.tag), + "Expected subtree parent to be a mounted class component. This error is likely caused by a bug in React. Please file an issue." + ); + var parentContext = parentComponent; + do { + switch (parentContext.tag) { + case 5: + parentContext = parentContext.stateNode.context; + break a; + case 2: + if (isContextProvider(parentContext.type)) { + parentContext = + parentContext.stateNode.__reactInternalMemoizedMergedChildContext; + break a; + } + break; + case 3: + if (isContextProvider(parentContext.type._reactResult)) { + parentContext = + parentContext.stateNode.__reactInternalMemoizedMergedChildContext; + break a; + } } - parentContext = parentContext.stateNode.context; - } - parentComponent = isContextProvider(parentComponent) - ? processChildContext(parentComponent, parentContext) - : parentContext; - } else parentComponent = emptyContextObject; - null === container.context - ? (container.context = parentComponent) - : (container.pendingContext = parentComponent); - container = callback; - callback = createUpdate(expirationTime); - callback.payload = { element: element }; - container = void 0 === container ? null : container; - null !== container && (callback.callback = container); - enqueueUpdate(current$$1, callback); - scheduleWork(current$$1, expirationTime); - return expirationTime; + parentContext = parentContext.return; + } while (null !== parentContext); + invariant( + !1, + "Found unexpected detached subtree parent. This error is likely caused by a bug in React. Please file an issue." + ); + parentContext = void 0; + } + if (2 === parentComponent.tag) { + var Component = parentComponent.type; + if (isContextProvider(Component)) + return processChildContext(parentComponent, Component, parentContext); + } else if ( + 3 === parentComponent.tag && + ((Component = parentComponent.type._reactResult), + isContextProvider(Component)) + ) + return processChildContext(parentComponent, Component, parentContext); + return parentContext; } function findHostInstance$1(component) { var fiber = component._reactInternalFiber; @@ -5456,154 +5783,20 @@ function updateContainer(element, container, parentComponent, callback) { var current$$1 = container.current, currentTime = requestCurrentTime(); current$$1 = computeExpirationForFiber(currentTime, current$$1); - return updateContainerAtExpirationTime( - element, - container, - parentComponent, - current$$1, - callback - ); + currentTime = container.current; + parentComponent = getContextForSubtree(parentComponent); + null === container.context + ? (container.context = parentComponent) + : (container.pendingContext = parentComponent); + container = callback; + callback = createUpdate(current$$1); + callback.payload = { element: element }; + container = void 0 === container ? null : container; + null !== container && (callback.callback = container); + enqueueUpdate(currentTime, callback); + scheduleWork(currentTime, current$$1); + return current$$1; } -function getPublicRootInstance(container) { - container = container.current; - if (!container.child) return null; - switch (container.child.tag) { - case 5: - return container.child.stateNode.canonical; - default: - return container.child.stateNode; - } -} -function injectIntoDevTools(devToolsConfig) { - var findFiberByHostInstance = devToolsConfig.findFiberByHostInstance; - return injectInternals( - Object.assign({}, devToolsConfig, { - findHostInstanceByFiber: function(fiber) { - fiber = findCurrentHostFiber(fiber); - return null === fiber ? null : fiber.stateNode; - }, - findFiberByHostInstance: function(instance) { - return findFiberByHostInstance - ? findFiberByHostInstance(instance) - : null; - } - }) - ); -} -var ReactFabricRenderer = { - updateContainerAtExpirationTime: updateContainerAtExpirationTime, - createContainer: function(containerInfo, isAsync, hydrate) { - return createFiberRoot(containerInfo, isAsync, hydrate); - }, - updateContainer: updateContainer, - flushRoot: function(root, expirationTime) { - invariant( - !isRendering, - "work.commit(): Cannot commit while already rendering. This likely means you attempted to commit from inside a lifecycle method." - ); - nextFlushedRoot = root; - nextFlushedExpirationTime = expirationTime; - performWorkOnRoot(root, expirationTime, !0); - performWork(1, null); - pauseActualRenderTimerIfRunning(); - }, - requestWork: requestWork, - computeUniqueAsyncExpiration: function() { - var result = 2 + 25 * ((((requestCurrentTime() - 2 + 500) / 25) | 0) + 1); - result <= lastUniqueAsyncExpiration && - (result = lastUniqueAsyncExpiration + 1); - return (lastUniqueAsyncExpiration = result); - }, - batchedUpdates: function(fn, a) { - var previousIsBatchingUpdates = isBatchingUpdates; - isBatchingUpdates = !0; - try { - return fn(a); - } finally { - (isBatchingUpdates = previousIsBatchingUpdates) || - isRendering || - performWork(1, null); - } - }, - unbatchedUpdates: function(fn, a) { - if (isBatchingUpdates && !isUnbatchingUpdates) { - isUnbatchingUpdates = !0; - try { - return fn(a); - } finally { - isUnbatchingUpdates = !1; - } - } - return fn(a); - }, - deferredUpdates: function(fn) { - var currentTime = requestCurrentTime(), - previousExpirationContext = expirationContext; - expirationContext = 2 + 25 * ((((currentTime - 2 + 500) / 25) | 0) + 1); - try { - return fn(); - } finally { - expirationContext = previousExpirationContext; - } - }, - syncUpdates: syncUpdates, - interactiveUpdates: function(fn, a, b) { - if (isBatchingInteractiveUpdates) return fn(a, b); - isBatchingUpdates || - isRendering || - 0 === lowestPendingInteractiveExpirationTime || - (performWork(lowestPendingInteractiveExpirationTime, null), - (lowestPendingInteractiveExpirationTime = 0)); - var previousIsBatchingInteractiveUpdates = isBatchingInteractiveUpdates, - previousIsBatchingUpdates = isBatchingUpdates; - isBatchingUpdates = isBatchingInteractiveUpdates = !0; - try { - return fn(a, b); - } finally { - (isBatchingInteractiveUpdates = previousIsBatchingInteractiveUpdates), - (isBatchingUpdates = previousIsBatchingUpdates) || - isRendering || - performWork(1, null); - } - }, - flushInteractiveUpdates: function() { - isRendering || - 0 === lowestPendingInteractiveExpirationTime || - (performWork(lowestPendingInteractiveExpirationTime, null), - (lowestPendingInteractiveExpirationTime = 0)); - }, - flushControlled: function(fn) { - var previousIsBatchingUpdates = isBatchingUpdates; - isBatchingUpdates = !0; - try { - syncUpdates(fn); - } finally { - (isBatchingUpdates = previousIsBatchingUpdates) || - isRendering || - performWork(1, null); - } - }, - flushSync: function(fn, a) { - invariant( - !isRendering, - "flushSync was called from inside a lifecycle method. It cannot be called when React is already rendering." - ); - var previousIsBatchingUpdates = isBatchingUpdates; - isBatchingUpdates = !0; - try { - return syncUpdates(fn, a); - } finally { - (isBatchingUpdates = previousIsBatchingUpdates), performWork(1, null); - } - }, - getPublicRootInstance: getPublicRootInstance, - findHostInstance: findHostInstance$1, - findHostInstanceWithNoPortals: function(fiber) { - fiber = findCurrentHostFiberWithNoPortals(fiber); - return null === fiber ? null : fiber.stateNode; - }, - injectIntoDevTools: injectIntoDevTools -}; function createPortal(children, containerInfo, implementation) { var key = 3 < arguments.length && void 0 !== arguments[3] ? arguments[3] : null; @@ -5651,8 +5844,23 @@ function findNodeHandle(componentOrHandle) { ? componentOrHandle.canonical._nativeTag : componentOrHandle._nativeTag; } -_batchedUpdates = ReactFabricRenderer.batchedUpdates; -_flushInteractiveUpdates = ReactFabricRenderer.flushInteractiveUpdates; +_batchedUpdatesImpl = function(fn, a) { + var previousIsBatchingUpdates = isBatchingUpdates; + isBatchingUpdates = !0; + try { + return fn(a); + } finally { + (isBatchingUpdates = previousIsBatchingUpdates) || + isRendering || + performWork(1, null); + } +}; +_flushInteractiveUpdatesImpl = function() { + isRendering || + 0 === lowestPriorityPendingInteractiveExpirationTime || + (performWork(lowestPriorityPendingInteractiveExpirationTime, null), + (lowestPriorityPendingInteractiveExpirationTime = 0)); +}; var roots = new Map(), ReactFabric = { NativeComponent: (function(findNodeHandle, findHostInstance) { @@ -5680,13 +5888,13 @@ var roots = new Map(), ReactNativeComponent.prototype.measure = function(callback) { UIManager.measure( findNodeHandle(this), - mountSafeCallback(this, callback) + mountSafeCallback_NOT_REALLY_SAFE(this, callback) ); }; ReactNativeComponent.prototype.measureInWindow = function(callback) { UIManager.measureInWindow( findNodeHandle(this), - mountSafeCallback(this, callback) + mountSafeCallback_NOT_REALLY_SAFE(this, callback) ); }; ReactNativeComponent.prototype.measureLayout = function( @@ -5697,8 +5905,8 @@ var roots = new Map(), UIManager.measureLayout( findNodeHandle(this), relativeToNativeNode, - mountSafeCallback(this, onFail), - mountSafeCallback(this, onSuccess) + mountSafeCallback_NOT_REALLY_SAFE(this, onFail), + mountSafeCallback_NOT_REALLY_SAFE(this, onSuccess) ); }; ReactNativeComponent.prototype.setNativeProps = function(nativeProps) { @@ -5729,11 +5937,48 @@ var roots = new Map(), findNodeHandle: findNodeHandle, render: function(element, containerTag, callback) { var root = roots.get(containerTag); - root || - ((root = createFiberRoot(containerTag, !1, !1)), - roots.set(containerTag, root)); + if (!root) { + root = 0; + isDevToolsPresent && (root |= 4); + root = new FiberNode(5, null, null, root); + var root$jscomp$0 = { + current: root, + containerInfo: containerTag, + pendingChildren: null, + earliestPendingTime: 0, + latestPendingTime: 0, + earliestSuspendedTime: 0, + latestSuspendedTime: 0, + latestPingedTime: 0, + didError: !1, + pendingCommitExpirationTime: 0, + finishedWork: null, + timeoutHandle: -1, + context: null, + pendingContext: null, + hydrate: !1, + nextExpirationTimeToWorkOn: 0, + expirationTime: 0, + firstBatch: null, + nextScheduledRoot: null, + interactionThreadID: tracking.unstable_getThreadID(), + memoizedInteractions: new Set(), + pendingInteractionMap: new Map() + }; + root = root.stateNode = root$jscomp$0; + roots.set(containerTag, root); + } updateContainer(element, root, null, callback); - return getPublicRootInstance(root); + a: if (((element = root.current), element.child)) + switch (element.child.tag) { + case 7: + element = element.child.stateNode.canonical; + break a; + default: + element = element.child.stateNode; + } + else element = null; + return element; }, unmountComponentAtNode: function(containerTag) { var root = roots.get(containerTag); @@ -5756,21 +6001,21 @@ var roots = new Map(), measure: function(callback) { UIManager.measure( findNodeHandle(this), - mountSafeCallback(this, callback) + mountSafeCallback_NOT_REALLY_SAFE(this, callback) ); }, measureInWindow: function(callback) { UIManager.measureInWindow( findNodeHandle(this), - mountSafeCallback(this, callback) + mountSafeCallback_NOT_REALLY_SAFE(this, callback) ); }, measureLayout: function(relativeToNativeNode, onSuccess, onFail) { UIManager.measureLayout( findNodeHandle(this), relativeToNativeNode, - mountSafeCallback(this, onFail), - mountSafeCallback(this, onSuccess) + mountSafeCallback_NOT_REALLY_SAFE(this, onFail), + mountSafeCallback_NOT_REALLY_SAFE(this, onSuccess) ); }, setNativeProps: function(nativeProps) { @@ -5804,13 +6049,28 @@ var roots = new Map(), })(findNodeHandle, findHostInstance$1) } }; -injectIntoDevTools({ +(function(devToolsConfig) { + var findFiberByHostInstance = devToolsConfig.findFiberByHostInstance; + return injectInternals( + Object.assign({}, devToolsConfig, { + findHostInstanceByFiber: function(fiber) { + fiber = findCurrentHostFiber(fiber); + return null === fiber ? null : fiber.stateNode; + }, + findFiberByHostInstance: function(instance) { + return findFiberByHostInstance + ? findFiberByHostInstance(instance) + : null; + } + }) + ); +})({ findFiberByHostInstance: getInstanceFromInstance, getInspectorDataForViewTag: getInspectorDataForViewTag, bundleType: 0, - version: "16.4.1", + version: "16.5.0", rendererPackageName: "react-native-renderer" }); var ReactFabric$2 = { default: ReactFabric }, ReactFabric$3 = (ReactFabric$2 && ReactFabric) || ReactFabric$2; -module.exports = ReactFabric$3.default ? ReactFabric$3.default : ReactFabric$3; +module.exports = ReactFabric$3.default || ReactFabric$3; diff --git a/Libraries/Renderer/oss/ReactNativeRenderer-dev.js b/Libraries/Renderer/oss/ReactNativeRenderer-dev.js index 9b68fa5a4..b3fdfc9ae 100644 --- a/Libraries/Renderer/oss/ReactNativeRenderer-dev.js +++ b/Libraries/Renderer/oss/ReactNativeRenderer-dev.js @@ -1,5 +1,5 @@ /** - * Copyright (c) 2013-present, Facebook, Inc. + * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. @@ -26,6 +26,7 @@ var deepDiffer = require("deepDiffer"); var flattenStyle = require("flattenStyle"); var TextInputState = require("TextInputState"); var checkPropTypes = require("prop-types/checkPropTypes"); +var tracking = require("schedule/tracking"); var ExceptionsManager = require("ExceptionsManager"); /** @@ -75,15 +76,22 @@ function invariant(condition, format, a, b, c, d, e, f) { } } -var invokeGuardedCallback = function(name, func, context, a, b, c, d, e, f) { - this._hasCaughtError = false; - this._caughtError = null; +var invokeGuardedCallbackImpl = function( + name, + func, + context, + a, + b, + c, + d, + e, + f +) { var funcArgs = Array.prototype.slice.call(arguments, 3); try { func.apply(context, funcArgs); } catch (error) { - this._caughtError = error; - this._hasCaughtError = true; + this.onError(error); } }; @@ -152,6 +160,11 @@ var invokeGuardedCallback = function(name, func, context, a, b, c, d, e, f) { // the error event at all. var didError = true; + // Keeps track of the value of window.event so that we can reset it + // during the callback to let user code access window.event in the + // browsers that support it. + var windowEvent = window.event; + // Create an event handler for our fake event. We will synchronously // dispatch our fake event using `dispatchEvent`. Inside the handler, we // call the user-provided callback. @@ -162,6 +175,18 @@ var invokeGuardedCallback = function(name, func, context, a, b, c, d, e, f) { // nested call would trigger the fake event handlers of any call higher // in the stack. fakeNode.removeEventListener(evtType, callCallback, false); + + // We check for window.hasOwnProperty('event') to prevent the + // window.event assignment in both IE <= 10 as they throw an error + // "Member not found" in strict mode, and in Firefox which does not + // support window.event. + if ( + typeof window.event !== "undefined" && + window.hasOwnProperty("event") + ) { + window.event = windowEvent; + } + func.apply(context, funcArgs); didError = false; } @@ -182,19 +207,31 @@ var invokeGuardedCallback = function(name, func, context, a, b, c, d, e, f) { var didSetError = false; var isCrossOriginError = false; - function onError(event) { + function handleWindowError(event) { error = event.error; didSetError = true; if (error === null && event.colno === 0 && event.lineno === 0) { isCrossOriginError = true; } + if (event.defaultPrevented) { + // Some other error handler has prevented default. + // Browsers silence the error report if this happens. + // We'll remember this to later decide whether to log it or not. + if (error != null && typeof error === "object") { + try { + error._suppressLogging = true; + } catch (inner) { + // Ignore. + } + } + } } // Create a fake event type. var evtType = "react-" + (name ? name : "invokeguardedcallback"); // Attach our event handlers - window.addEventListener("error", onError); + window.addEventListener("error", handleWindowError); fakeNode.addEventListener(evtType, callCallback, false); // Synchronously dispatch our fake event. If the user-provided function @@ -222,116 +259,115 @@ var invokeGuardedCallback = function(name, func, context, a, b, c, d, e, f) { "See https://fb.me/react-crossorigin-error for more information." ); } - this._hasCaughtError = true; - this._caughtError = error; - } else { - this._hasCaughtError = false; - this._caughtError = null; + this.onError(error); } // Remove our event listeners - window.removeEventListener("error", onError); + window.removeEventListener("error", handleWindowError); }; - invokeGuardedCallback = invokeGuardedCallbackDev; + invokeGuardedCallbackImpl = invokeGuardedCallbackDev; } } -var invokeGuardedCallback$1 = invokeGuardedCallback; +var invokeGuardedCallbackImpl$1 = invokeGuardedCallbackImpl; -var ReactErrorUtils = { - // Used by Fiber to simulate a try-catch. - _caughtError: null, - _hasCaughtError: false, +// Used by Fiber to simulate a try-catch. +var hasError = false; +var caughtError = null; - // Used by event system to capture/rethrow the first error. - _rethrowError: null, - _hasRethrowError: false, +// Used by event system to capture/rethrow the first error. +var hasRethrowError = false; +var rethrowError = null; - /** - * Call a function while guarding against errors that happens within it. - * Returns an error if it throws, otherwise null. - * - * In production, this is implemented using a try-catch. The reason we don't - * use a try-catch directly is so that we can swap out a different - * implementation in DEV mode. - * - * @param {String} name of the guard to use for logging or debugging - * @param {Function} func The function to invoke - * @param {*} context The context to use when calling the function - * @param {...*} args Arguments for function - */ - invokeGuardedCallback: function(name, func, context, a, b, c, d, e, f) { - invokeGuardedCallback$1.apply(ReactErrorUtils, arguments); - }, - - /** - * Same as invokeGuardedCallback, but instead of returning an error, it stores - * it in a global so it can be rethrown by `rethrowCaughtError` later. - * TODO: See if _caughtError and _rethrowError can be unified. - * - * @param {String} name of the guard to use for logging or debugging - * @param {Function} func The function to invoke - * @param {*} context The context to use when calling the function - * @param {...*} args Arguments for function - */ - invokeGuardedCallbackAndCatchFirstError: function( - name, - func, - context, - a, - b, - c, - d, - e, - f - ) { - ReactErrorUtils.invokeGuardedCallback.apply(this, arguments); - if (ReactErrorUtils.hasCaughtError()) { - var error = ReactErrorUtils.clearCaughtError(); - if (!ReactErrorUtils._hasRethrowError) { - ReactErrorUtils._hasRethrowError = true; - ReactErrorUtils._rethrowError = error; - } - } - }, - - /** - * During execution of guarded functions we will capture the first error which - * we will rethrow to be handled by the top level error handler. - */ - rethrowCaughtError: function() { - return rethrowCaughtError.apply(ReactErrorUtils, arguments); - }, - - hasCaughtError: function() { - return ReactErrorUtils._hasCaughtError; - }, - - clearCaughtError: function() { - if (ReactErrorUtils._hasCaughtError) { - var error = ReactErrorUtils._caughtError; - ReactErrorUtils._caughtError = null; - ReactErrorUtils._hasCaughtError = false; - return error; - } else { - invariant( - false, - "clearCaughtError was called but no error was captured. This error " + - "is likely caused by a bug in React. Please file an issue." - ); - } +var reporter = { + onError: function(error) { + hasError = true; + caughtError = error; } }; -var rethrowCaughtError = function() { - if (ReactErrorUtils._hasRethrowError) { - var error = ReactErrorUtils._rethrowError; - ReactErrorUtils._rethrowError = null; - ReactErrorUtils._hasRethrowError = false; +/** + * Call a function while guarding against errors that happens within it. + * Returns an error if it throws, otherwise null. + * + * In production, this is implemented using a try-catch. The reason we don't + * use a try-catch directly is so that we can swap out a different + * implementation in DEV mode. + * + * @param {String} name of the guard to use for logging or debugging + * @param {Function} func The function to invoke + * @param {*} context The context to use when calling the function + * @param {...*} args Arguments for function + */ +function invokeGuardedCallback(name, func, context, a, b, c, d, e, f) { + hasError = false; + caughtError = null; + invokeGuardedCallbackImpl$1.apply(reporter, arguments); +} + +/** + * Same as invokeGuardedCallback, but instead of returning an error, it stores + * it in a global so it can be rethrown by `rethrowCaughtError` later. + * TODO: See if caughtError and rethrowError can be unified. + * + * @param {String} name of the guard to use for logging or debugging + * @param {Function} func The function to invoke + * @param {*} context The context to use when calling the function + * @param {...*} args Arguments for function + */ +function invokeGuardedCallbackAndCatchFirstError( + name, + func, + context, + a, + b, + c, + d, + e, + f +) { + invokeGuardedCallback.apply(this, arguments); + if (hasError) { + var error = clearCaughtError(); + if (!hasRethrowError) { + hasRethrowError = true; + rethrowError = error; + } + } +} + +/** + * During execution of guarded functions we will capture the first error which + * we will rethrow to be handled by the top level error handler. + */ +function rethrowCaughtError() { + if (hasRethrowError) { + var error = rethrowError; + hasRethrowError = false; + rethrowError = null; throw error; } -}; +} + +function hasCaughtError() { + return hasError; +} + +function clearCaughtError() { + if (hasError) { + var error = caughtError; + hasError = false; + caughtError = null; + return error; + } else { + invariant( + false, + "clearCaughtError was called but no error was captured. This error " + + "is likely caused by a bug in React. Please file an issue." + ); + } +} /** * Injectable ordering of event plugins. @@ -576,9 +612,12 @@ var warningWithoutStack = function() {}; if (typeof console !== "undefined") { var _console; + var stringArgs = args.map(function(item) { + return "" + item; + }); (_console = console).error.apply( _console, - ["Warning: " + format].concat(args) + ["Warning: " + format].concat(stringArgs) ); } try { @@ -602,23 +641,24 @@ var getFiberCurrentPropsFromNode = null; var getInstanceFromNode = null; var getNodeFromInstance = null; -var injection$1 = { - injectComponentTree: function(Injected) { - getFiberCurrentPropsFromNode = Injected.getFiberCurrentPropsFromNode; - getInstanceFromNode = Injected.getInstanceFromNode; - getNodeFromInstance = Injected.getNodeFromInstance; - - { - !(getNodeFromInstance && getInstanceFromNode) - ? warningWithoutStack$1( - false, - "EventPluginUtils.injection.injectComponentTree(...): Injected " + - "module is missing getNodeFromInstance or getInstanceFromNode." - ) - : void 0; - } +function setComponentTree( + getFiberCurrentPropsFromNodeImpl, + getInstanceFromNodeImpl, + getNodeFromInstanceImpl +) { + getFiberCurrentPropsFromNode = getFiberCurrentPropsFromNodeImpl; + getInstanceFromNode = getInstanceFromNodeImpl; + getNodeFromInstance = getNodeFromInstanceImpl; + { + !(getNodeFromInstance && getInstanceFromNode) + ? warningWithoutStack$1( + false, + "EventPluginUtils.setComponentTree(...): Injected " + + "module is missing getNodeFromInstance or getInstanceFromNode." + ) + : void 0; } -}; +} var validateEventDispatches = void 0; { @@ -656,12 +696,7 @@ var validateEventDispatches = void 0; function executeDispatch(event, simulated, listener, inst) { var type = event.type || "unknown-event"; event.currentTarget = getNodeFromInstance(inst); - ReactErrorUtils.invokeGuardedCallbackAndCatchFirstError( - type, - listener, - undefined, - event - ); + invokeGuardedCallbackAndCatchFirstError(type, listener, undefined, event); event.currentTarget = null; } @@ -1022,7 +1057,7 @@ function runEventsInBatch(events, simulated) { "an event queue. Support for this has not yet been implemented." ); // This would be a good time to rethrow if any of the event handlers threw. - ReactErrorUtils.rethrowCaughtError(); + rethrowCaughtError(); } function runExtractedEventsInBatch( @@ -1040,19 +1075,21 @@ function runExtractedEventsInBatch( runEventsInBatch(events, false); } -var IndeterminateComponent = 0; // Before we know whether it is functional or class -var FunctionalComponent = 1; +var FunctionalComponent = 0; +var FunctionalComponentLazy = 1; var ClassComponent = 2; -var HostRoot = 3; // Root of a host tree. Could be nested inside another node. -var HostPortal = 4; // A subtree. Could be an entry point to a different renderer. -var HostComponent = 5; -var HostText = 6; - -var Fragment = 10; -var Mode = 11; -var ContextConsumer = 12; -var ContextProvider = 13; -var ForwardRef = 14; +var ClassComponentLazy = 3; +var IndeterminateComponent = 4; // Before we know whether it is functional or class +var HostRoot = 5; // Root of a host tree. Could be nested inside another node. +var HostPortal = 6; // A subtree. Could be an entry point to a different renderer. +var HostComponent = 7; +var HostText = 8; +var Fragment = 9; +var Mode = 10; +var ContextConsumer = 11; +var ContextProvider = 12; +var ForwardRef = 13; +var ForwardRefLazy = 14; var Profiler = 15; var PlaceholderComponent = 16; @@ -2511,20 +2548,9 @@ function updateFiberProps(tag, props) { instanceProps[tag] = props; } -var ReactNativeComponentTree = Object.freeze({ - precacheFiberNode: precacheFiberNode, - uncacheFiberNode: uncacheFiberNode, - getClosestInstanceFromNode: getInstanceFromTag, - getInstanceFromNode: getInstanceFromTag, - getNodeFromInstance: getTagFromInstance, - getFiberCurrentPropsFromNode: getFiberCurrentPropsFromNode$1, - updateFiberProps: updateFiberProps -}); - // Use to restore controlled state after a change event has fired. -var fiberHostComponent = null; - +var restoreImpl = null; var restoreTarget = null; var restoreQueue = null; @@ -2537,17 +2563,12 @@ function restoreStateOfTarget(target) { return; } invariant( - fiberHostComponent && - typeof fiberHostComponent.restoreControlledState === "function", - "Fiber needs to be injected to handle a fiber target for controlled " + + typeof restoreImpl === "function", + "setRestoreImplementation() needs to be called to handle a target for controlled " + "events. This error is likely caused by a bug in React. Please file an issue." ); var props = getFiberCurrentPropsFromNode(internalInstance.stateNode); - fiberHostComponent.restoreControlledState( - internalInstance.stateNode, - internalInstance.type, - props - ); + restoreImpl(internalInstance.stateNode, internalInstance.type, props); } function needsStateRestore() { @@ -2578,13 +2599,10 @@ function restoreStateIfNeeded() { // scheduled work and instead do synchronous work. // Defaults -var _batchedUpdates = function(fn, bookkeeping) { +var _batchedUpdatesImpl = function(fn, bookkeeping) { return fn(bookkeeping); }; -var _interactiveUpdates = function(fn, a, b) { - return fn(a, b); -}; -var _flushInteractiveUpdates = function() {}; +var _flushInteractiveUpdatesImpl = function() {}; var isBatching = false; function batchedUpdates(fn, bookkeeping) { @@ -2595,7 +2613,7 @@ function batchedUpdates(fn, bookkeeping) { } isBatching = true; try { - return _batchedUpdates(fn, bookkeeping); + return _batchedUpdatesImpl(fn, bookkeeping); } finally { // Here we wait until all updates have propagated, which is important // when using controlled components within layers: @@ -2607,19 +2625,20 @@ function batchedUpdates(fn, bookkeeping) { // If a controlled event was fired, we may need to restore the state of // the DOM node back to the controlled value. This is necessary when React // bails out of the update without touching the DOM. - _flushInteractiveUpdates(); + _flushInteractiveUpdatesImpl(); restoreStateIfNeeded(); } } } -var injection$2 = { - injectRenderer: function(renderer) { - _batchedUpdates = renderer.batchedUpdates; - _interactiveUpdates = renderer.interactiveUpdates; - _flushInteractiveUpdates = renderer.flushInteractiveUpdates; - } -}; +function setBatchingImplementation( + batchedUpdatesImpl, + interactiveUpdatesImpl, + flushInteractiveUpdatesImpl +) { + _batchedUpdatesImpl = batchedUpdatesImpl; + _flushInteractiveUpdatesImpl = flushInteractiveUpdatesImpl; +} /** * Version of `ReactBrowserEventEmitter` that works on the receiving side of a @@ -2795,7 +2814,11 @@ var ReactNativeGlobalResponderHandler = { */ RCTEventEmitter.register(ReactNativeEventEmitter); -injection$1.injectComponentTree(ReactNativeComponentTree); +setComponentTree( + getFiberCurrentPropsFromNode$1, + getInstanceFromTag, + getTagFromInstance +); ResponderEventPlugin.injection.injectGlobalResponderHandler( ReactNativeGlobalResponderHandler @@ -2853,7 +2876,7 @@ var MAYBE_ITERATOR_SYMBOL = typeof Symbol === "function" && Symbol.iterator; var FAUX_ITERATOR_SYMBOL = "@@iterator"; function getIteratorFn(maybeIterable) { - if (maybeIterable === null || typeof maybeIterable === "undefined") { + if (maybeIterable === null || typeof maybeIterable !== "object") { return null; } var maybeIterator = @@ -2865,6 +2888,18 @@ function getIteratorFn(maybeIterable) { return null; } +var Pending = 0; +var Resolved = 1; +var Rejected = 2; + +function getResultFromResolvedThenable(thenable) { + return thenable._reactResult; +} + +function refineResolvedThenable(thenable) { + return thenable._reactStatus === Resolved ? thenable._reactResult : null; +} + function getComponentName(type) { if (type == null) { // Host root, text node or just invalid type. @@ -2912,6 +2947,13 @@ function getComponentName(type) { ? "ForwardRef(" + functionName + ")" : "ForwardRef"; } + if (typeof type.then === "function") { + var thenable = type; + var resolvedThenable = refineResolvedThenable(thenable); + if (resolvedThenable) { + return getComponentName(resolvedThenable); + } + } } return null; } @@ -2982,7 +3024,10 @@ function isFiberMounted(fiber) { function isMounted(component) { { var owner = ReactCurrentOwner$1.current; - if (owner !== null && owner.tag === ClassComponent) { + if ( + owner !== null && + (owner.tag === ClassComponent || owner.tag === ClassComponentLazy) + ) { var ownerFiber = owner; var instance = ownerFiber.stateNode; !instance._warnedAboutRefsInRender @@ -3173,39 +3218,6 @@ function findCurrentHostFiber(parent) { return null; } -function findCurrentHostFiberWithNoPortals(parent) { - var currentParent = findCurrentFiberUsingSlowPath(parent); - if (!currentParent) { - return null; - } - - // Next we'll drill down this component to find the first HostComponent/Text. - var node = currentParent; - while (true) { - if (node.tag === HostComponent || node.tag === HostText) { - return node; - } else if (node.child && node.tag !== HostPortal) { - node.child.return = node; - node = node.child; - continue; - } - if (node === currentParent) { - return null; - } - while (!node.sibling) { - if (!node.return || node.return === currentParent) { - return null; - } - node = node.return; - } - node.sibling.return = node.return; - node = node.sibling; - } - // Flow needs the return null here, but ESLint complains about it. - // eslint-disable-next-line no-unreachable - return null; -} - // Modules provided by RN: var emptyObject = {}; @@ -3252,8 +3264,8 @@ function restoreDeletedValuesInNestedArray( if (!removedKeys[propKey]) { continue; } - var _nextProp = obj[propKey]; - if (_nextProp === undefined) { + var nextProp = obj[propKey]; + if (nextProp === undefined) { continue; } @@ -3262,16 +3274,16 @@ function restoreDeletedValuesInNestedArray( continue; // not a valid native prop } - if (typeof _nextProp === "function") { - _nextProp = true; + if (typeof nextProp === "function") { + nextProp = true; } - if (typeof _nextProp === "undefined") { - _nextProp = null; + if (typeof nextProp === "undefined") { + nextProp = null; } if (typeof attributeConfig !== "object") { // case: !Object is the default case - updatePayload[propKey] = _nextProp; + updatePayload[propKey] = nextProp; } else if ( typeof attributeConfig.diff === "function" || typeof attributeConfig.process === "function" @@ -3279,8 +3291,8 @@ function restoreDeletedValuesInNestedArray( // case: CustomAttributeConfiguration var nextValue = typeof attributeConfig.process === "function" - ? attributeConfig.process(_nextProp) - : _nextProp; + ? attributeConfig.process(nextProp) + : nextProp; updatePayload[propKey] = nextValue; } removedKeys[propKey] = false; @@ -3644,26 +3656,33 @@ function diff(prevProps, nextProps, validAttributes) { * In the future, we should cleanup callbacks by cancelling them instead of * using this. */ -function mountSafeCallback(context, callback) { +function mountSafeCallback_NOT_REALLY_SAFE(context, callback) { return function() { if (!callback) { return undefined; } + // This protects against createClass() components. + // We don't know if there is code depending on it. + // We intentionally don't use isMounted() because even accessing + // isMounted property on a React ES6 class will trigger a warning. if (typeof context.__isMounted === "boolean") { - // TODO(gaearon): this is gross and should be removed. - // It is currently necessary because View uses createClass, - // and so any measure() calls on View (which are done by React - // DevTools) trigger the isMounted() deprecation warning. if (!context.__isMounted) { return undefined; } - // The else branch is important so that we don't - // trigger the deprecation warning by calling isMounted. - } else if (typeof context.isMounted === "function") { - if (!context.isMounted()) { - return undefined; - } } + + // FIXME: there used to be other branches that protected + // against unmounted host components. But RN host components don't + // define isMounted() anymore, so those checks didn't do anything. + + // They caused false positive warning noise so we removed them: + // https://github.com/facebook/react-native/issues/18868#issuecomment-413579095 + + // However, this means that the callback is NOT guaranteed to be safe + // for host components. The solution we should implement is to make + // UIManager.measure() and similar calls truly cancelable. Then we + // can change our own code calling them to cancel when something unmounts. + return callback.apply(context, arguments); }; } @@ -3737,7 +3756,10 @@ var ReactNativeFiberHostComponent = (function() { }; ReactNativeFiberHostComponent.prototype.measure = function measure(callback) { - UIManager.measure(this._nativeTag, mountSafeCallback(this, callback)); + UIManager.measure( + this._nativeTag, + mountSafeCallback_NOT_REALLY_SAFE(this, callback) + ); }; ReactNativeFiberHostComponent.prototype.measureInWindow = function measureInWindow( @@ -3745,7 +3767,7 @@ var ReactNativeFiberHostComponent = (function() { ) { UIManager.measureInWindow( this._nativeTag, - mountSafeCallback(this, callback) + mountSafeCallback_NOT_REALLY_SAFE(this, callback) ); }; @@ -3757,8 +3779,8 @@ var ReactNativeFiberHostComponent = (function() { UIManager.measureLayout( this._nativeTag, relativeToNativeNode, - mountSafeCallback(this, onFail), - mountSafeCallback(this, onSuccess) + mountSafeCallback_NOT_REALLY_SAFE(this, onFail), + mountSafeCallback_NOT_REALLY_SAFE(this, onSuccess) ); }; @@ -4240,20 +4262,32 @@ function resetTextContent(instance) { // Noop } +var BEFORE_SLASH_RE = /^(.*)[\\\/]/; + var describeComponentFrame = function(name, source, ownerName) { - return ( - "\n in " + - (name || "Unknown") + - (source - ? " (at " + - source.fileName.replace(/^.*[\\\/]/, "") + - ":" + - source.lineNumber + - ")" - : ownerName - ? " (created by " + ownerName + ")" - : "") - ); + var sourceInfo = ""; + if (source) { + var path = source.fileName; + var fileName = path.replace(BEFORE_SLASH_RE, ""); + { + // In DEV, include code for a common special case: + // prefer "folder/index.js" instead of just "index.js". + if (/^index\./.test(fileName)) { + var match = path.match(BEFORE_SLASH_RE); + if (match) { + var pathBeforeSlash = match[1]; + if (pathBeforeSlash) { + var folderName = pathBeforeSlash.replace(BEFORE_SLASH_RE, ""); + fileName = folderName + "/" + fileName; + } + } + } + } + sourceInfo = " (at " + fileName + ":" + source.lineNumber + ")"; + } else if (ownerName) { + sourceInfo = " (created by " + ownerName + ")"; + } + return "\n in " + (name || "Unknown") + sourceInfo; }; var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame; @@ -4262,7 +4296,9 @@ function describeFiber(fiber) { switch (fiber.tag) { case IndeterminateComponent: case FunctionalComponent: + case FunctionalComponentLazy: case ClassComponent: + case ClassComponentLazy: case HostComponent: case Mode: var owner = fiber._debugOwner; @@ -4347,6 +4383,7 @@ var replayFailedUnitOfWorkWithInvokeGuardedCallback = true; var warnAboutDeprecatedLifecycles = false; var warnAboutLegacyContextAPI = false; var enableProfilerTimer = true; +var enableSchedulerTracking = true; // Only used in www builds. @@ -4897,11 +4934,14 @@ var didPerformWorkStackCursor = createCursor(false); // pushed the next context provider, and now need to merge their contexts. var previousContext = emptyContextObject; -function getUnmaskedContext(workInProgress) { - var hasOwnContext = isContextProvider(workInProgress); - if (hasOwnContext) { +function getUnmaskedContext( + workInProgress, + Component, + didPushOwnContextIfProvider +) { + if (didPushOwnContextIfProvider && isContextProvider(Component)) { // If the fiber is a context provider itself, when we read its context - // we have already pushed its own child context on the stack. A context + // we may have already pushed its own child context on the stack. A context // provider should not "see" its own child context. Therefore we read the // previous (parent) context instead for a context provider. return previousContext; @@ -4962,19 +5002,12 @@ function hasContextChanged() { return didPerformWorkStackCursor.current; } -function isContextConsumer(fiber) { - return fiber.tag === ClassComponent && fiber.type.contextTypes != null; +function isContextProvider(type) { + var childContextTypes = type.childContextTypes; + return childContextTypes !== null && childContextTypes !== undefined; } -function isContextProvider(fiber) { - return fiber.tag === ClassComponent && fiber.type.childContextTypes != null; -} - -function popContextProvider(fiber) { - if (!isContextProvider(fiber)) { - return; - } - +function popContext(fiber) { pop(didPerformWorkStackCursor, fiber); pop(contextStackCursor, fiber); } @@ -4995,9 +5028,8 @@ function pushTopLevelContextObject(fiber, context, didChange) { push(didPerformWorkStackCursor, didChange, fiber); } -function processChildContext(fiber, parentContext) { +function processChildContext(fiber, type, parentContext) { var instance = fiber.stateNode; - var type = fiber.type; var childContextTypes = type.childContextTypes; // TODO (bvaughn) Replace this behavior with an invariant() in the future. @@ -5059,10 +5091,6 @@ function processChildContext(fiber, parentContext) { } function pushContextProvider(workInProgress) { - if (!isContextProvider(workInProgress)) { - return false; - } - var instance = workInProgress.stateNode; // We push the context as early as possible to ensure stack integrity. // If the instance does not exist yet, we will push null at first, @@ -5084,7 +5112,7 @@ function pushContextProvider(workInProgress) { return true; } -function invalidateContextProvider(workInProgress, didChange) { +function invalidateContextProvider(workInProgress, type, didChange) { var instance = workInProgress.stateNode; invariant( instance, @@ -5096,7 +5124,11 @@ function invalidateContextProvider(workInProgress, didChange) { // Merge parent and own context. // Skip this if we're not updating due to sCU. // This avoids unnecessarily recomputing memoized values. - var mergedContext = processChildContext(workInProgress, previousContext); + var mergedContext = processChildContext( + workInProgress, + type, + previousContext + ); instance.__reactInternalMemoizedMergedChildContext = mergedContext; // Replace the old (or empty) context with the new one. @@ -5116,25 +5148,39 @@ function findCurrentUnmaskedContext(fiber) { // Currently this is only used with renderSubtreeIntoContainer; not sure if it // makes sense elsewhere invariant( - isFiberMounted(fiber) && fiber.tag === ClassComponent, + isFiberMounted(fiber) && + (fiber.tag === ClassComponent || fiber.tag === ClassComponentLazy), "Expected subtree parent to be a mounted class component. " + "This error is likely caused by a bug in React. Please file an issue." ); var node = fiber; - while (node.tag !== HostRoot) { - if (isContextProvider(node)) { - return node.stateNode.__reactInternalMemoizedMergedChildContext; + do { + switch (node.tag) { + case HostRoot: + return node.stateNode.context; + case ClassComponent: { + var Component = node.type; + if (isContextProvider(Component)) { + return node.stateNode.__reactInternalMemoizedMergedChildContext; + } + break; + } + case ClassComponentLazy: { + var _Component = getResultFromResolvedThenable(node.type); + if (isContextProvider(_Component)) { + return node.stateNode.__reactInternalMemoizedMergedChildContext; + } + break; + } } - var parent = node.return; - invariant( - parent, - "Found unexpected detached subtree parent. " + - "This error is likely caused by a bug in React. Please file an issue." - ); - node = parent; - } - return node.stateNode.context; + node = node.return; + } while (node !== null); + invariant( + false, + "Found unexpected detached subtree parent. " + + "This error is likely caused by a bug in React. Please file an issue." + ); } var onCommitFiberRoot = null; @@ -5358,7 +5404,7 @@ function FiberNode(tag, pendingProps, key, mode) { if (enableProfilerTimer) { this.actualDuration = 0; - this.actualStartTime = 0; + this.actualStartTime = -1; this.selfBaseDuration = 0; this.treeBaseDuration = 0; } @@ -5393,7 +5439,23 @@ var createFiber = function(tag, pendingProps, key, mode) { }; function shouldConstruct(Component) { - return !!(Component.prototype && Component.prototype.isReactComponent); + var prototype = Component.prototype; + return !!(prototype && prototype.isReactComponent); +} + +function resolveLazyComponentTag(fiber, Component) { + if (typeof Component === "function") { + return shouldConstruct(Component) + ? ClassComponentLazy + : FunctionalComponentLazy; + } else if ( + Component !== undefined && + Component !== null && + Component.$$typeof + ) { + return ForwardRefLazy; + } + return IndeterminateComponent; } // This is used to create an alternate fiber to do work on. @@ -5441,7 +5503,7 @@ function createWorkInProgress(current, pendingProps, expirationTime) { // This has the downside of resetting values for different priority renders, // But works for yielding (the common case) and should support resuming. workInProgress.actualDuration = 0; - workInProgress.actualStartTime = 0; + workInProgress.actualStartTime = -1; } } @@ -5504,7 +5566,7 @@ function createFiberFromElement(element, mode, expirationTime) { } else if (typeof type === "string") { fiberTag = HostComponent; } else { - switch (type) { + getTag: switch (type) { case REACT_FRAGMENT_TYPE: return createFiberFromFragment( pendingProps.children, @@ -5525,9 +5587,54 @@ function createFiberFromElement(element, mode, expirationTime) { case REACT_PLACEHOLDER_TYPE: fiberTag = PlaceholderComponent; break; - default: - fiberTag = getFiberTagFromObjectType(type, owner); - break; + default: { + if (typeof type === "object" && type !== null) { + switch (type.$$typeof) { + case REACT_PROVIDER_TYPE: + fiberTag = ContextProvider; + break getTag; + case REACT_CONTEXT_TYPE: + // This is a consumer + fiberTag = ContextConsumer; + break getTag; + case REACT_FORWARD_REF_TYPE: + fiberTag = ForwardRef; + break getTag; + default: { + if (typeof type.then === "function") { + fiberTag = IndeterminateComponent; + break getTag; + } + } + } + } + var info = ""; + { + if ( + type === undefined || + (typeof type === "object" && + type !== null && + Object.keys(type).length === 0) + ) { + info += + " You likely forgot to export your component from the file " + + "it's defined in, or you might have mixed up default and " + + "named imports."; + } + var ownerName = owner ? getComponentName(owner.type) : null; + if (ownerName) { + info += "\n\nCheck the render method of `" + ownerName + "`."; + } + } + invariant( + false, + "Element type is invalid: expected a string (for built-in " + + "components) or a class/function (for composite components) " + + "but got: %s.%s", + type == null ? type : typeof type, + info + ); + } } } @@ -5543,49 +5650,6 @@ function createFiberFromElement(element, mode, expirationTime) { return fiber; } -function getFiberTagFromObjectType(type, owner) { - var $$typeof = - typeof type === "object" && type !== null ? type.$$typeof : null; - - switch ($$typeof) { - case REACT_PROVIDER_TYPE: - return ContextProvider; - case REACT_CONTEXT_TYPE: - // This is a consumer - return ContextConsumer; - case REACT_FORWARD_REF_TYPE: - return ForwardRef; - default: { - var info = ""; - { - if ( - type === undefined || - (typeof type === "object" && - type !== null && - Object.keys(type).length === 0) - ) { - info += - " You likely forgot to export your component from the file " + - "it's defined in, or you might have mixed up default and " + - "named imports."; - } - var ownerName = owner ? getComponentName(owner.type) : null; - if (ownerName) { - info += "\n\nCheck the render method of `" + ownerName + "`."; - } - } - invariant( - false, - "Element type is invalid: expected a string (for built-in " + - "components) or a class/function (for composite components) " + - "but got: %s.%s", - type == null ? type : typeof type, - info - ); - } - } -} - function createFiberFromFragment(elements, mode, expirationTime, key) { var fiber = createFiber(Fragment, elements, key, mode); fiber.expirationTime = expirationTime; @@ -5598,7 +5662,7 @@ function createFiberFromProfiler(pendingProps, mode, expirationTime, key) { typeof pendingProps.id !== "string" || typeof pendingProps.onRender !== "function" ) { - invariant( + warningWithoutStack$1( false, 'Profiler must specify an "id" string and "onRender" function as props' ); @@ -5685,37 +5749,90 @@ function assignFiberPropertiesInDEV(target, source) { return target; } +/* eslint-disable no-use-before-define */ // TODO: This should be lifted into the renderer. +// The following attributes are only used by interaction tracking builds. +// They enable interactions to be associated with their async work, +// And expose interaction metadata to the React DevTools Profiler plugin. +// Note that these attributes are only defined when the enableSchedulerTracking flag is enabled. + +// Exported FiberRoot type includes all properties, +// To avoid requiring potentially error-prone :any casts throughout the project. +// Profiling properties are only safe to access in profiling builds (when enableSchedulerTracking is true). +// The types are defined separately within this file to ensure they stay in sync. +// (We don't have to use an inline :any cast when enableSchedulerTracking is disabled.) + +/* eslint-enable no-use-before-define */ + function createFiberRoot(containerInfo, isAsync, hydrate) { // Cyclic construction. This cheats the type system right now because // stateNode is any. var uninitializedFiber = createHostRootFiber(isAsync); - var root = { - current: uninitializedFiber, - containerInfo: containerInfo, - pendingChildren: null, - earliestPendingTime: NoWork, - latestPendingTime: NoWork, - earliestSuspendedTime: NoWork, - latestSuspendedTime: NoWork, - latestPingedTime: NoWork, + var root = void 0; + if (enableSchedulerTracking) { + root = { + current: uninitializedFiber, + containerInfo: containerInfo, + pendingChildren: null, - didError: false, + earliestPendingTime: NoWork, + latestPendingTime: NoWork, + earliestSuspendedTime: NoWork, + latestSuspendedTime: NoWork, + latestPingedTime: NoWork, + + didError: false, + + pendingCommitExpirationTime: NoWork, + finishedWork: null, + timeoutHandle: noTimeout, + context: null, + pendingContext: null, + hydrate: hydrate, + nextExpirationTimeToWorkOn: NoWork, + expirationTime: NoWork, + firstBatch: null, + nextScheduledRoot: null, + + interactionThreadID: tracking.unstable_getThreadID(), + memoizedInteractions: new Set(), + pendingInteractionMap: new Map() + }; + } else { + root = { + current: uninitializedFiber, + containerInfo: containerInfo, + pendingChildren: null, + + earliestPendingTime: NoWork, + latestPendingTime: NoWork, + earliestSuspendedTime: NoWork, + latestSuspendedTime: NoWork, + latestPingedTime: NoWork, + + didError: false, + + pendingCommitExpirationTime: NoWork, + finishedWork: null, + timeoutHandle: noTimeout, + context: null, + pendingContext: null, + hydrate: hydrate, + nextExpirationTimeToWorkOn: NoWork, + expirationTime: NoWork, + firstBatch: null, + nextScheduledRoot: null + }; + } - pendingCommitExpirationTime: NoWork, - finishedWork: null, - timeoutHandle: noTimeout, - context: null, - pendingContext: null, - hydrate: hydrate, - nextExpirationTimeToWorkOn: NoWork, - expirationTime: NoWork, - firstBatch: null, - nextScheduledRoot: null - }; uninitializedFiber.stateNode = root; + + // The reason for the way the Flow types are structured in this file, + // Is to avoid needing :any casts everywhere interaction tracking fields are used. + // Unfortunately that requires an :any cast for non-interaction tracking capable builds. + // $FlowFixMe Remove this :any cast and replace it with something better. return root; } @@ -6337,6 +6454,14 @@ function findEarliestOutstandingPriorityLevel(root, renderExpirationTime) { return earliestExpirationTime; } +function didExpireAtExpirationTime(root, currentTime) { + var expirationTime = root.expirationTime; + if (expirationTime !== NoWork && currentTime >= expirationTime) { + // The root has expired. Flush all work up to the current time. + root.nextExpirationTimeToWorkOn = currentTime; + } +} + function findNextExpirationTimeToWorkOn(completedExpirationTime, root) { var earliestSuspendedTime = root.earliestSuspendedTime; var latestSuspendedTime = root.latestSuspendedTime; @@ -6348,7 +6473,7 @@ function findNextExpirationTimeToWorkOn(completedExpirationTime, root) { var nextExpirationTimeToWorkOn = earliestPendingTime !== NoWork ? earliestPendingTime : latestPingedTime; - // If there is no pending or pinted work, check if there's suspended work + // If there is no pending or pinged work, check if there's suspended work // that's lower priority than what we just completed. if ( nextExpirationTimeToWorkOn === NoWork && @@ -6590,7 +6715,7 @@ function enqueueUpdate(fiber, update) { { if ( - fiber.tag === ClassComponent && + (fiber.tag === ClassComponent || fiber.tag === ClassComponentLazy) && (currentlyProcessingQueue === queue1 || (queue2 !== null && currentlyProcessingQueue === queue2)) && !didWarnUpdateInsideUpdate @@ -6908,8 +7033,14 @@ function commitUpdateQueue( } // Commit the effects - var effect = finishedQueue.firstEffect; + commitUpdateEffects(finishedQueue.firstEffect, instance); finishedQueue.firstEffect = finishedQueue.lastEffect = null; + + commitUpdateEffects(finishedQueue.firstCapturedEffect, instance); + finishedQueue.firstCapturedEffect = finishedQueue.lastCapturedEffect = null; +} + +function commitUpdateEffects(effect, instance) { while (effect !== null) { var _callback3 = effect.callback; if (_callback3 !== null) { @@ -6918,17 +7049,6 @@ function commitUpdateQueue( } effect = effect.nextEffect; } - - effect = finishedQueue.firstCapturedEffect; - finishedQueue.firstCapturedEffect = finishedQueue.lastCapturedEffect = null; - while (effect !== null) { - var _callback4 = effect.callback; - if (_callback4 !== null) { - effect.callback = null; - callCallback(_callback4, instance); - } - effect = effect.nextEffect; - } } function createCapturedValue(value, source) { @@ -6941,8 +7061,44 @@ function createCapturedValue(value, source) { }; } +/** + * Similar to invariant but only logs a warning if the condition is not met. + * This can be used to log issues in development environments in critical + * paths. Removing the logging code for production environments will keep the + * same logic and follow the same code paths. + */ + +var warning = warningWithoutStack$1; + +{ + warning = function(condition, format) { + if (condition) { + return; + } + var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame; + var stack = ReactDebugCurrentFrame.getStackAddendum(); + // eslint-disable-next-line react-internal/warning-and-invariant-args + + for ( + var _len = arguments.length, + args = Array(_len > 2 ? _len - 2 : 0), + _key = 2; + _key < _len; + _key++ + ) { + args[_key - 2] = arguments[_key]; + } + + warningWithoutStack$1.apply( + undefined, + [false, format + "%s"].concat(args, [stack]) + ); + }; +} + +var warning$1 = warning; + var valueCursor = createCursor(null); -var changedBitsCursor = createCursor(0); var rendererSigil = void 0; { @@ -6962,15 +7118,13 @@ function resetContextDependences() { lastContextWithAllBitsObserved = null; } -function pushProvider(providerFiber) { +function pushProvider(providerFiber, nextValue) { var context = providerFiber.type._context; if (isPrimaryRenderer) { - push(changedBitsCursor, context._changedBits, providerFiber); push(valueCursor, context._currentValue, providerFiber); - context._currentValue = providerFiber.pendingProps.value; - context._changedBits = providerFiber.stateNode; + context._currentValue = nextValue; { !( context._currentRenderer === undefined || @@ -6986,11 +7140,9 @@ function pushProvider(providerFiber) { context._currentRenderer = rendererSigil; } } else { - push(changedBitsCursor, context._changedBits2, providerFiber); push(valueCursor, context._currentValue2, providerFiber); - context._currentValue2 = providerFiber.pendingProps.value; - context._changedBits2 = providerFiber.stateNode; + context._currentValue2 = nextValue; { !( context._currentRenderer2 === undefined || @@ -7009,19 +7161,46 @@ function pushProvider(providerFiber) { } function popProvider(providerFiber) { - var changedBits = changedBitsCursor.current; var currentValue = valueCursor.current; pop(valueCursor, providerFiber); - pop(changedBitsCursor, providerFiber); var context = providerFiber.type._context; if (isPrimaryRenderer) { context._currentValue = currentValue; - context._changedBits = changedBits; } else { context._currentValue2 = currentValue; - context._changedBits2 = changedBits; + } +} + +function calculateChangedBits(context, newValue, oldValue) { + // Use Object.is to compare the new context value to the old value. Inlined + // Object.is polyfill. + // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is + if ( + (oldValue === newValue && + (oldValue !== 0 || 1 / oldValue === 1 / newValue)) || + (oldValue !== oldValue && newValue !== newValue) // eslint-disable-line no-self-compare + ) { + // No change + return 0; + } else { + var changedBits = + typeof context._calculateChangedBits === "function" + ? context._calculateChangedBits(oldValue, newValue) + : maxSigned31BitInt; + + { + !((changedBits & maxSigned31BitInt) === changedBits) + ? warning$1( + false, + "calculateChangedBits: Expected the return value to be a " + + "31-bit integer. Instead received: %s", + changedBits + ) + : void 0; + } + return changedBits | 0; } } @@ -7049,6 +7228,21 @@ function propagateContextChange( (dependency.observedBits & changedBits) !== 0 ) { // Match! Schedule an update on this fiber. + + if ( + fiber.tag === ClassComponent || + fiber.tag === ClassComponentLazy + ) { + // Schedule a force update on the work-in-progress. + var update = createUpdate(renderExpirationTime); + update.tag = ForceUpdate; + // TODO: Because we don't have a work-in-progress, this will add the + // update to the current fiber, too, which means it will persist even if + // this render is thrown away. Since it's a race condition, not sure it's + // worth fixing. + enqueueUpdate(fiber, update); + } + if ( fiber.expirationTime === NoWork || fiber.expirationTime > renderExpirationTime @@ -7093,13 +7287,8 @@ function propagateContextChange( } node = node.return; } - // Don't scan deeper than a matching consumer. When we render the - // consumer, we'll continue scanning from that point. This way the - // scanning work is time-sliced. - nextFiber = null; - } else { - nextFiber = fiber.child; } + nextFiber = fiber.child; dependency = dependency.next; } while (dependency !== null); } else if (fiber.tag === ContextProvider) { @@ -7142,41 +7331,8 @@ function prepareToReadContext(workInProgress, renderExpirationTime) { lastContextDependency = null; lastContextWithAllBitsObserved = null; - var firstContextDependency = workInProgress.firstContextDependency; - if (firstContextDependency !== null) { - // Reset the work-in-progress list - workInProgress.firstContextDependency = null; - - // Iterate through the context dependencies and see if there were any - // changes. If so, continue propagating the context change by scanning - // the child subtree. - var dependency = firstContextDependency; - var hasPendingContext = false; - do { - var _context = dependency.context; - var changedBits = isPrimaryRenderer - ? _context._changedBits - : _context._changedBits2; - if (changedBits !== 0) { - // Resume context change propagation. We need to call this even if - // this fiber bails out, in case deeply nested consumers observe more - // bits than this one. - propagateContextChange( - workInProgress, - _context, - changedBits, - renderExpirationTime - ); - if ((changedBits & dependency.observedBits) !== 0) { - hasPendingContext = true; - } - } - dependency = dependency.next; - } while (dependency !== null); - return hasPendingContext; - } else { - return false; - } + // Reset the work-in-progress list + workInProgress.firstContextDependency = null; } function readContext(context, observedBits) { @@ -7298,6 +7454,7 @@ function popHostContext(fiber) { } var commitTime = 0; +var profilerStartTime = -1; function getCommitTime() { return commitTime; @@ -7310,184 +7467,40 @@ function recordCommitTime() { commitTime = now(); } -/** - * The "actual" render time is total time required to render the descendants of a Profiler component. - * This time is stored as a stack, since Profilers can be nested. - * This time is started during the "begin" phase and stopped during the "complete" phase. - * It is paused (and accumulated) in the event of an interruption or an aborted render. - */ - -var fiberStack$1 = void 0; - -{ - fiberStack$1 = []; -} - -var syncCommitStartTime = 0; -var timerPausedAt = 0; -var totalElapsedPauseTime = 0; - -function checkActualRenderTimeStackEmpty() { +function startProfilerTimer(fiber) { if (!enableProfilerTimer) { return; } - { - !(fiberStack$1.length === 0) - ? warningWithoutStack$1( - false, - "Expected an empty stack. Something was not reset properly." - ) - : void 0; + + profilerStartTime = now(); + + if (fiber.actualStartTime < 0) { + fiber.actualStartTime = now(); } } -function markActualRenderTimeStarted(fiber) { +function stopProfilerTimerIfRunning(fiber) { if (!enableProfilerTimer) { return; } - { - fiberStack$1.push(fiber); - } - - fiber.actualDuration = now() - fiber.actualDuration - totalElapsedPauseTime; - fiber.actualStartTime = now(); + profilerStartTime = -1; } -function pauseActualRenderTimerIfRunning() { +function stopProfilerTimerIfRunningAndRecordDelta(fiber, overrideBaseTime) { if (!enableProfilerTimer) { return; } - if (timerPausedAt === 0) { - timerPausedAt = now(); - } - if (syncCommitStartTime > 0) { - // Don't count the time spent processing sycn work, - // Against yielded async work that will be resumed later. - totalElapsedPauseTime += now() - syncCommitStartTime; - syncCommitStartTime = 0; - } else { - totalElapsedPauseTime = 0; - } -} -function recordElapsedActualRenderTime(fiber) { - if (!enableProfilerTimer) { - return; - } - { - !(fiber === fiberStack$1.pop()) - ? warningWithoutStack$1( - false, - "Unexpected Fiber (%s) popped.", - getComponentName(fiber.type) - ) - : void 0; - } - - fiber.actualDuration = now() - totalElapsedPauseTime - fiber.actualDuration; -} - -function resumeActualRenderTimerIfPaused(isProcessingSyncWork) { - if (!enableProfilerTimer) { - return; - } - if (isProcessingSyncWork && syncCommitStartTime === 0) { - syncCommitStartTime = now(); - } - if (timerPausedAt > 0) { - totalElapsedPauseTime += now() - timerPausedAt; - timerPausedAt = 0; - } -} - -function resetActualRenderTimerStackAfterFatalErrorInDev() { - if (!enableProfilerTimer) { - return; - } - { - fiberStack$1.length = 0; - } -} - -/** - * The "base" render time is the duration of the “begin” phase of work for a particular fiber. - * This time is measured and stored on each fiber. - * The time for all sibling fibers are accumulated and stored on their parent during the "complete" phase. - * If a fiber bails out (sCU false) then its "base" timer is cancelled and the fiber is not updated. - */ - -var baseStartTime = -1; - -function recordElapsedBaseRenderTimeIfRunning(fiber) { - if (!enableProfilerTimer) { - return; - } - if (baseStartTime !== -1) { - fiber.selfBaseDuration = now() - baseStartTime; - } -} - -function startBaseRenderTimer() { - if (!enableProfilerTimer) { - return; - } - { - if (baseStartTime !== -1) { - warningWithoutStack$1( - false, - "Cannot start base timer that is already running. " + - "This error is likely caused by a bug in React. " + - "Please file an issue." - ); + if (profilerStartTime >= 0) { + var elapsedTime = now() - profilerStartTime; + fiber.actualDuration += elapsedTime; + if (overrideBaseTime) { + fiber.selfBaseDuration = elapsedTime; } + profilerStartTime = -1; } - baseStartTime = now(); } -function stopBaseRenderTimerIfRunning() { - if (!enableProfilerTimer) { - return; - } - baseStartTime = -1; -} - -/** - * Similar to invariant but only logs a warning if the condition is not met. - * This can be used to log issues in development environments in critical - * paths. Removing the logging code for production environments will keep the - * same logic and follow the same code paths. - */ - -var warning = warningWithoutStack$1; - -{ - warning = function(condition, format) { - if (condition) { - return; - } - var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame; - var stack = ReactDebugCurrentFrame.getStackAddendum(); - // eslint-disable-next-line react-internal/warning-and-invariant-args - - for ( - var _len = arguments.length, - args = Array(_len > 2 ? _len - 2 : 0), - _key = 2; - _key < _len; - _key++ - ) { - args[_key - 2] = arguments[_key]; - } - - warningWithoutStack$1.apply( - undefined, - [false, format + "%s"].concat(args, [stack]) - ); - }; -} - -var warning$1 = warning; - /*eslint-disable no-self-compare */ var hasOwnProperty = Object.prototype.hasOwnProperty; @@ -7562,12 +7575,14 @@ var didWarnAboutLegacyLifecyclesAndDerivedState = void 0; var didWarnAboutUndefinedDerivedState = void 0; var warnOnUndefinedDerivedState = void 0; var warnOnInvalidCallback = void 0; +var didWarnAboutDirectlyAssigningPropsToState = void 0; { didWarnAboutStateAssignmentForComponent = new Set(); didWarnAboutUninitializedState = new Set(); didWarnAboutGetSnapshotBeforeUpdateWithoutDidUpdate = new Set(); didWarnAboutLegacyLifecyclesAndDerivedState = new Set(); + didWarnAboutDirectlyAssigningPropsToState = new Set(); didWarnAboutUndefinedDerivedState = new Set(); var didWarnOnInvalidCallback = new Set(); @@ -7628,6 +7643,7 @@ var warnOnInvalidCallback = void 0; function applyDerivedStateFromProps( workInProgress, + ctor, getDerivedStateFromProps, nextProps ) { @@ -7647,7 +7663,7 @@ function applyDerivedStateFromProps( var partialState = getDerivedStateFromProps(nextProps, prevState); { - warnOnUndefinedDerivedState(workInProgress.type, partialState); + warnOnUndefinedDerivedState(ctor, partialState); } // Merge the partial state and the previous state. var memoizedState = @@ -7724,6 +7740,7 @@ var classComponentUpdater = { function checkShouldComponentUpdate( workInProgress, + ctor, oldProps, newProps, oldState, @@ -7731,7 +7748,6 @@ function checkShouldComponentUpdate( nextLegacyContext ) { var instance = workInProgress.stateNode; - var ctor = workInProgress.type; if (typeof instance.shouldComponentUpdate === "function") { startPhaseTimer(workInProgress, "shouldComponentUpdate"); var shouldUpdate = instance.shouldComponentUpdate( @@ -7764,15 +7780,14 @@ function checkShouldComponentUpdate( return true; } -function checkClassInstance(workInProgress) { +function checkClassInstance(workInProgress, ctor, newProps) { var instance = workInProgress.stateNode; - var type = workInProgress.type; { - var name = getComponentName(type) || "Component"; + var name = getComponentName(ctor) || "Component"; var renderPresent = instance.render; if (!renderPresent) { - if (type.prototype && typeof type.prototype.render === "function") { + if (ctor.prototype && typeof ctor.prototype.render === "function") { warningWithoutStack$1( false, "%s(...): No `render` method found on the returned component " + @@ -7845,8 +7860,8 @@ function checkClassInstance(workInProgress) { ) : void 0; if ( - type.prototype && - type.prototype.isPureReactComponent && + ctor.prototype && + ctor.prototype.isPureReactComponent && typeof instance.shouldComponentUpdate !== "undefined" ) { warningWithoutStack$1( @@ -7854,7 +7869,7 @@ function checkClassInstance(workInProgress) { "%s has a method called shouldComponentUpdate(). " + "shouldComponentUpdate should not be used when extending React.PureComponent. " + "Please extend React.Component if shouldComponentUpdate is used.", - getComponentName(type) || "A pure component" + getComponentName(ctor) || "A pure component" ); } var noComponentDidUnmount = @@ -7901,7 +7916,7 @@ function checkClassInstance(workInProgress) { name ) : void 0; - var hasMutatedProps = instance.props !== workInProgress.pendingProps; + var hasMutatedProps = instance.props !== newProps; !(instance.props === undefined || !hasMutatedProps) ? warningWithoutStack$1( false, @@ -7925,14 +7940,14 @@ function checkClassInstance(workInProgress) { if ( typeof instance.getSnapshotBeforeUpdate === "function" && typeof instance.componentDidUpdate !== "function" && - !didWarnAboutGetSnapshotBeforeUpdateWithoutDidUpdate.has(type) + !didWarnAboutGetSnapshotBeforeUpdateWithoutDidUpdate.has(ctor) ) { - didWarnAboutGetSnapshotBeforeUpdateWithoutDidUpdate.add(type); + didWarnAboutGetSnapshotBeforeUpdateWithoutDidUpdate.add(ctor); warningWithoutStack$1( false, "%s: getSnapshotBeforeUpdate() should be used with componentDidUpdate(). " + "This component defines getSnapshotBeforeUpdate() only.", - getComponentName(type) + getComponentName(ctor) ); } @@ -7957,7 +7972,7 @@ function checkClassInstance(workInProgress) { ) : void 0; var noStaticGetSnapshotBeforeUpdate = - typeof type.getSnapshotBeforeUpdate !== "function"; + typeof ctor.getSnapshotBeforeUpdate !== "function"; !noStaticGetSnapshotBeforeUpdate ? warningWithoutStack$1( false, @@ -7975,7 +7990,7 @@ function checkClassInstance(workInProgress) { ); } if (typeof instance.getChildContext === "function") { - !(typeof type.childContextTypes === "object") + !(typeof ctor.childContextTypes === "object") ? warningWithoutStack$1( false, "%s.getChildContext(): childContextTypes must be defined in order to " + @@ -7997,11 +8012,16 @@ function adoptClassInstance(workInProgress, instance) { } } -function constructClassInstance(workInProgress, props, renderExpirationTime) { - var ctor = workInProgress.type; - var unmaskedContext = getUnmaskedContext(workInProgress); - var needsContext = isContextConsumer(workInProgress); - var context = needsContext +function constructClassInstance( + workInProgress, + ctor, + props, + renderExpirationTime +) { + var unmaskedContext = getUnmaskedContext(workInProgress, ctor, true); + var contextTypes = ctor.contextTypes; + var isContextConsumer = contextTypes !== null && contextTypes !== undefined; + var context = isContextConsumer ? getMaskedContext(workInProgress, unmaskedContext) : emptyContextObject; @@ -8030,10 +8050,13 @@ function constructClassInstance(workInProgress, props, renderExpirationTime) { didWarnAboutUninitializedState.add(componentName); warningWithoutStack$1( false, - "%s: Did not properly initialize state during construction. " + - "Expected state to be an object, but it was %s.", + "`%s` uses `getDerivedStateFromProps` but its initial state is " + + "%s. This is not recommended. Instead, define the initial state by " + + "assigning an object to `this.state` in the constructor of `%s`. " + + "This ensures that `getDerivedStateFromProps` arguments have a consistent shape.", componentName, - instance.state === null ? "null" : "undefined" + instance.state === null ? "null" : "undefined", + componentName ); } } @@ -8107,7 +8130,7 @@ function constructClassInstance(workInProgress, props, renderExpirationTime) { // Cache unmasked context so we can avoid recreating masked context unless necessary. // ReactFiberContext usually updates this cache but can't for newly-created instances. - if (needsContext) { + if (isContextConsumer) { cacheContext(workInProgress, unmaskedContext, context); } @@ -8176,23 +8199,39 @@ function callComponentWillReceiveProps( } // Invokes the mount life-cycles on a previously never rendered instance. -function mountClassInstance(workInProgress, renderExpirationTime) { - var ctor = workInProgress.type; - +function mountClassInstance( + workInProgress, + ctor, + newProps, + renderExpirationTime +) { { - checkClassInstance(workInProgress); + checkClassInstance(workInProgress, ctor, newProps); } var instance = workInProgress.stateNode; - var props = workInProgress.pendingProps; - var unmaskedContext = getUnmaskedContext(workInProgress); + var unmaskedContext = getUnmaskedContext(workInProgress, ctor, true); - instance.props = props; + instance.props = newProps; instance.state = workInProgress.memoizedState; instance.refs = emptyRefsObject; instance.context = getMaskedContext(workInProgress, unmaskedContext); { + if (instance.state === newProps) { + var componentName = getComponentName(ctor) || "Component"; + if (!didWarnAboutDirectlyAssigningPropsToState.has(componentName)) { + didWarnAboutDirectlyAssigningPropsToState.add(componentName); + warningWithoutStack$1( + false, + "%s: It is not recommended to assign props directly to state " + + "because updates to props won't be reflected in state. " + + "In most cases, it is better to use props directly.", + componentName + ); + } + } + if (workInProgress.mode & StrictMode) { ReactStrictModeWarnings.recordUnsafeLifecycleWarnings( workInProgress, @@ -8218,7 +8257,7 @@ function mountClassInstance(workInProgress, renderExpirationTime) { processUpdateQueue( workInProgress, updateQueue, - props, + newProps, instance, renderExpirationTime ); @@ -8227,7 +8266,12 @@ function mountClassInstance(workInProgress, renderExpirationTime) { var getDerivedStateFromProps = ctor.getDerivedStateFromProps; if (typeof getDerivedStateFromProps === "function") { - applyDerivedStateFromProps(workInProgress, getDerivedStateFromProps, props); + applyDerivedStateFromProps( + workInProgress, + ctor, + getDerivedStateFromProps, + newProps + ); instance.state = workInProgress.memoizedState; } @@ -8247,7 +8291,7 @@ function mountClassInstance(workInProgress, renderExpirationTime) { processUpdateQueue( workInProgress, updateQueue, - props, + newProps, instance, renderExpirationTime ); @@ -8262,18 +8306,21 @@ function mountClassInstance(workInProgress, renderExpirationTime) { function resumeMountClassInstance( workInProgress, - hasPendingNewContext, + ctor, + newProps, renderExpirationTime ) { - var ctor = workInProgress.type; var instance = workInProgress.stateNode; var oldProps = workInProgress.memoizedProps; - var newProps = workInProgress.pendingProps; instance.props = oldProps; var oldContext = instance.context; - var nextLegacyUnmaskedContext = getUnmaskedContext(workInProgress); + var nextLegacyUnmaskedContext = getUnmaskedContext( + workInProgress, + ctor, + true + ); var nextLegacyContext = getMaskedContext( workInProgress, nextLegacyUnmaskedContext @@ -8324,7 +8371,6 @@ function resumeMountClassInstance( oldProps === newProps && oldState === newState && !hasContextChanged() && - !hasPendingNewContext && !checkHasForceUpdateAfterProcessing() ) { // If an update was already in progress, we should schedule an Update @@ -8338,6 +8384,7 @@ function resumeMountClassInstance( if (typeof getDerivedStateFromProps === "function") { applyDerivedStateFromProps( workInProgress, + ctor, getDerivedStateFromProps, newProps ); @@ -8346,9 +8393,9 @@ function resumeMountClassInstance( var shouldUpdate = checkHasForceUpdateAfterProcessing() || - hasPendingNewContext || checkShouldComponentUpdate( workInProgress, + ctor, oldProps, newProps, oldState, @@ -8402,18 +8449,21 @@ function resumeMountClassInstance( function updateClassInstance( current, workInProgress, - hasPendingNewContext, + ctor, + newProps, renderExpirationTime ) { - var ctor = workInProgress.type; var instance = workInProgress.stateNode; var oldProps = workInProgress.memoizedProps; - var newProps = workInProgress.pendingProps; instance.props = oldProps; var oldContext = instance.context; - var nextLegacyUnmaskedContext = getUnmaskedContext(workInProgress); + var nextLegacyUnmaskedContext = getUnmaskedContext( + workInProgress, + ctor, + true + ); var nextLegacyContext = getMaskedContext( workInProgress, nextLegacyUnmaskedContext @@ -8465,7 +8515,6 @@ function updateClassInstance( oldProps === newProps && oldState === newState && !hasContextChanged() && - !hasPendingNewContext && !checkHasForceUpdateAfterProcessing() ) { // If an update was already in progress, we should schedule an Update @@ -8492,6 +8541,7 @@ function updateClassInstance( if (typeof getDerivedStateFromProps === "function") { applyDerivedStateFromProps( workInProgress, + ctor, getDerivedStateFromProps, newProps ); @@ -8500,9 +8550,9 @@ function updateClassInstance( var shouldUpdate = checkHasForceUpdateAfterProcessing() || - hasPendingNewContext || checkShouldComponentUpdate( workInProgress, + ctor, oldProps, newProps, oldState, @@ -8573,6 +8623,7 @@ function updateClassInstance( } var didWarnAboutMaps = void 0; +var didWarnAboutGenerators = void 0; var didWarnAboutStringRefInStrictMode = void 0; var ownerHasKeyUseWarning = void 0; var ownerHasFunctionTypeWarning = void 0; @@ -8580,6 +8631,7 @@ var warnForMissingKey = function(child) {}; { didWarnAboutMaps = false; + didWarnAboutGenerators = false; didWarnAboutStringRefInStrictMode = {}; /** @@ -8638,7 +8690,7 @@ function coerceRef(returnFiber, current$$1, element) { if (!didWarnAboutStringRefInStrictMode[componentName]) { warningWithoutStack$1( false, - 'A string ref, "%s", has been found within a strict mode tree. ' + + 'A string ref, "%s", has been found within a strict mode tree. ' + "String refs are a source of potential bugs and should be avoided. " + "We recommend using createRef() instead." + "\n%s" + @@ -8658,7 +8710,8 @@ function coerceRef(returnFiber, current$$1, element) { if (owner) { var ownerFiber = owner; invariant( - ownerFiber.tag === ClassComponent, + ownerFiber.tag === ClassComponent || + ownerFiber.tag === ClassComponentLazy, "Stateless function components cannot have refs." ); inst = ownerFiber.stateNode; @@ -8696,7 +8749,7 @@ function coerceRef(returnFiber, current$$1, element) { } else { invariant( typeof mixedRef === "string", - "Expected ref to be a function or a string." + "Expected ref to be a function, a string, an object returned by React.createRef(), or null." ); invariant( element._owner, @@ -9395,6 +9448,26 @@ function ChildReconciler(shouldTrackSideEffects) { ); { + // We don't support rendering Generators because it's a mutation. + // See https://github.com/facebook/react/issues/12995 + if ( + typeof Symbol === "function" && + // $FlowFixMe Flow doesn't know about toStringTag + newChildrenIterable[Symbol.toStringTag] === "Generator" + ) { + !didWarnAboutGenerators + ? warning$1( + false, + "Using Generators as children is unsupported and will likely yield " + + "unexpected results because enumerating a generator mutates it. " + + "You may convert it to an array with `Array.from()` or the " + + "`[...spread]` operator before rendering. Keep in mind " + + "you might need to polyfill these features for older browsers." + ) + : void 0; + didWarnAboutGenerators = true; + } + // Warn about using Maps as children if (newChildrenIterable.entries === iteratorFn) { !didWarnAboutMaps @@ -9779,7 +9852,8 @@ function ChildReconciler(shouldTrackSideEffects) { // component, throw an error. If Fiber return types are disabled, // we already threw above. switch (returnFiber.tag) { - case ClassComponent: { + case ClassComponent: + case ClassComponentLazy: { { var instance = returnFiber.stateNode; if (instance.render._isMockFunction) { @@ -10162,6 +10236,49 @@ function resetHydrationState() { isHydrating = false; } +function readLazyComponentType(thenable) { + var status = thenable._reactStatus; + switch (status) { + case Resolved: + var Component = thenable._reactResult; + return Component; + case Rejected: + throw thenable._reactResult; + case Pending: + throw thenable; + default: { + thenable._reactStatus = Pending; + thenable.then( + function(resolvedValue) { + if (thenable._reactStatus === Pending) { + thenable._reactStatus = Resolved; + if (typeof resolvedValue === "object" && resolvedValue !== null) { + // If the `default` property is not empty, assume it's the result + // of an async import() and use that. Otherwise, use the + // resolved value itself. + var defaultExport = resolvedValue.default; + resolvedValue = + defaultExport !== undefined && defaultExport !== null + ? defaultExport + : resolvedValue; + } else { + resolvedValue = resolvedValue; + } + thenable._reactResult = resolvedValue; + } + }, + function(error) { + if (thenable._reactStatus === Pending) { + thenable._reactStatus = Rejected; + thenable._reactResult = error; + } + } + ); + throw thenable; + } + } +} + var ReactCurrentOwner$3 = ReactSharedInternals.ReactCurrentOwner; var didWarnAboutBadClass = void 0; @@ -10207,9 +10324,14 @@ function reconcileChildren( } } -function updateForwardRef(current$$1, workInProgress, renderExpirationTime) { - var render = workInProgress.type.render; - var nextProps = workInProgress.pendingProps; +function updateForwardRef( + current$$1, + workInProgress, + type, + nextProps, + renderExpirationTime +) { + var render = type.render; var ref = workInProgress.ref; if (hasContextChanged()) { // Normally we can bail out on props equality but if context has changed @@ -10297,11 +10419,11 @@ function markRef(current$$1, workInProgress) { function updateFunctionalComponent( current$$1, workInProgress, + Component, + nextProps, renderExpirationTime ) { - var fn = workInProgress.type; - var nextProps = workInProgress.pendingProps; - var unmaskedContext = getUnmaskedContext(workInProgress); + var unmaskedContext = getUnmaskedContext(workInProgress, Component, true); var context = getMaskedContext(workInProgress, unmaskedContext); var nextChildren = void 0; @@ -10309,7 +10431,7 @@ function updateFunctionalComponent( { ReactCurrentOwner$3.current = workInProgress; setCurrentPhase("render"); - nextChildren = fn(nextProps, context); + nextChildren = Component(nextProps, context); setCurrentPhase(null); } @@ -10328,16 +10450,21 @@ function updateFunctionalComponent( function updateClassComponent( current$$1, workInProgress, + Component, + nextProps, renderExpirationTime ) { // Push context providers early to prevent context stack mismatches. // During mounting we don't know the child context yet as the instance doesn't exist. // We will invalidate the child context in finishClassComponent() right after rendering. - var hasContext = pushContextProvider(workInProgress); - var hasPendingNewContext = prepareToReadContext( - workInProgress, - renderExpirationTime - ); + var hasContext = void 0; + if (isContextProvider(Component)) { + hasContext = true; + pushContextProvider(workInProgress); + } else { + hasContext = false; + } + prepareToReadContext(workInProgress, renderExpirationTime); var shouldUpdate = void 0; if (current$$1 === null) { @@ -10345,17 +10472,23 @@ function updateClassComponent( // In the initial pass we might need to construct the instance. constructClassInstance( workInProgress, - workInProgress.pendingProps, + Component, + nextProps, + renderExpirationTime + ); + mountClassInstance( + workInProgress, + Component, + nextProps, renderExpirationTime ); - mountClassInstance(workInProgress, renderExpirationTime); - shouldUpdate = true; } else { // In a resume, we'll already have an instance we can reuse. shouldUpdate = resumeMountClassInstance( workInProgress, - hasPendingNewContext, + Component, + nextProps, renderExpirationTime ); } @@ -10363,13 +10496,15 @@ function updateClassComponent( shouldUpdate = updateClassInstance( current$$1, workInProgress, - hasPendingNewContext, + Component, + nextProps, renderExpirationTime ); } return finishClassComponent( current$$1, workInProgress, + Component, shouldUpdate, hasContext, renderExpirationTime @@ -10379,6 +10514,7 @@ function updateClassComponent( function finishClassComponent( current$$1, workInProgress, + Component, shouldUpdate, hasContext, renderExpirationTime @@ -10391,7 +10527,7 @@ function finishClassComponent( if (!shouldUpdate && !didCaptureError) { // Context providers should defer to sCU for rendering if (hasContext) { - invalidateContextProvider(workInProgress, false); + invalidateContextProvider(workInProgress, Component, false); } return bailoutOnAlreadyFinishedWork( @@ -10401,7 +10537,6 @@ function finishClassComponent( ); } - var ctor = workInProgress.type; var instance = workInProgress.stateNode; // Rerender @@ -10410,7 +10545,7 @@ function finishClassComponent( if ( didCaptureError && (!enableGetDerivedStateFromCatch || - typeof ctor.getDerivedStateFromCatch !== "function") + typeof Component.getDerivedStateFromCatch !== "function") ) { // If we captured an error, but getDerivedStateFrom catch is not defined, // unmount all the children. componentDidCatch will schedule an update to @@ -10420,7 +10555,7 @@ function finishClassComponent( nextChildren = null; if (enableProfilerTimer) { - stopBaseRenderTimerIfRunning(); + stopProfilerTimerIfRunning(workInProgress); } } else { { @@ -10461,7 +10596,7 @@ function finishClassComponent( // The context might have changed so we need to recalculate it. if (hasContext) { - invalidateContextProvider(workInProgress, true); + invalidateContextProvider(workInProgress, Component, true); } return workInProgress.child; @@ -10616,9 +10751,25 @@ function updateHostText(current$$1, workInProgress) { return null; } +function resolveDefaultProps(Component, baseProps) { + if (Component && Component.defaultProps) { + // Resolve default props. Taken from ReactElement + var props = Object.assign({}, baseProps); + var defaultProps = Component.defaultProps; + for (var propName in defaultProps) { + if (props[propName] === undefined) { + props[propName] = defaultProps[propName]; + } + } + return props; + } + return baseProps; +} + function mountIndeterminateComponent( current$$1, workInProgress, + Component, renderExpirationTime ) { invariant( @@ -10626,9 +10777,61 @@ function mountIndeterminateComponent( "An indeterminate component should never have mounted. This error is " + "likely caused by a bug in React. Please file an issue." ); - var fn = workInProgress.type; + var props = workInProgress.pendingProps; - var unmaskedContext = getUnmaskedContext(workInProgress); + if ( + typeof Component === "object" && + Component !== null && + typeof Component.then === "function" + ) { + Component = readLazyComponentType(Component); + var resolvedTag = (workInProgress.tag = resolveLazyComponentTag( + workInProgress, + Component + )); + var resolvedProps = resolveDefaultProps(Component, props); + switch (resolvedTag) { + case FunctionalComponentLazy: { + return updateFunctionalComponent( + current$$1, + workInProgress, + Component, + resolvedProps, + renderExpirationTime + ); + } + case ClassComponentLazy: { + return updateClassComponent( + current$$1, + workInProgress, + Component, + resolvedProps, + renderExpirationTime + ); + } + case ForwardRefLazy: { + return updateForwardRef( + current$$1, + workInProgress, + Component, + resolvedProps, + renderExpirationTime + ); + } + default: { + // This message intentionally doesn't metion ForwardRef because the + // fact that it's a separate type of work is an implementation detail. + invariant( + false, + "Element type is invalid. Received a promise that resolves to: %s. " + + "Promise elements must resolve to a class or function.", + Component + ); + } + } + } + + var unmaskedContext = getUnmaskedContext(workInProgress, Component, false); var context = getMaskedContext(workInProgress, unmaskedContext); prepareToReadContext(workInProgress, renderExpirationTime); @@ -10636,8 +10839,11 @@ function mountIndeterminateComponent( var value = void 0; { - if (fn.prototype && typeof fn.prototype.render === "function") { - var componentName = getComponentName(fn) || "Unknown"; + if ( + Component.prototype && + typeof Component.prototype.render === "function" + ) { + var componentName = getComponentName(Component) || "Unknown"; if (!didWarnAboutBadClass[componentName]) { warningWithoutStack$1( @@ -10656,7 +10862,7 @@ function mountIndeterminateComponent( } ReactCurrentOwner$3.current = workInProgress; - value = fn(props, context); + value = Component(props, context); } // React DevTools reads this flag. workInProgress.effectTag |= PerformedWork; @@ -10667,15 +10873,19 @@ function mountIndeterminateComponent( typeof value.render === "function" && value.$$typeof === undefined ) { - var Component = workInProgress.type; - // Proceed under the assumption that this is a class instance workInProgress.tag = ClassComponent; // Push context providers early to prevent context stack mismatches. // During mounting we don't know the child context yet as the instance doesn't exist. // We will invalidate the child context in finishClassComponent() right after rendering. - var hasContext = pushContextProvider(workInProgress); + var hasContext = false; + if (isContextProvider(Component)) { + hasContext = true; + pushContextProvider(workInProgress); + } else { + hasContext = false; + } workInProgress.memoizedState = value.state !== null && value.state !== undefined ? value.state : null; @@ -10684,16 +10894,18 @@ function mountIndeterminateComponent( if (typeof getDerivedStateFromProps === "function") { applyDerivedStateFromProps( workInProgress, + Component, getDerivedStateFromProps, props ); } adoptClassInstance(workInProgress, value); - mountClassInstance(workInProgress, renderExpirationTime); + mountClassInstance(workInProgress, Component, props, renderExpirationTime); return finishClassComponent( current$$1, workInProgress, + Component, true, hasContext, renderExpirationTime @@ -10702,14 +10914,12 @@ function mountIndeterminateComponent( // Proceed under the assumption that this is a functional component workInProgress.tag = FunctionalComponent; { - var _Component = workInProgress.type; - - if (_Component) { - !!_Component.childContextTypes + if (Component) { + !!Component.childContextTypes ? warningWithoutStack$1( false, "%s(...): childContextTypes cannot be defined on a functional component.", - _Component.displayName || _Component.name || "Component" + Component.displayName || Component.name || "Component" ) : void 0; } @@ -10736,8 +10946,8 @@ function mountIndeterminateComponent( } } - if (typeof fn.getDerivedStateFromProps === "function") { - var _componentName = getComponentName(fn) || "Unknown"; + if (typeof Component.getDerivedStateFromProps === "function") { + var _componentName = getComponentName(Component) || "Unknown"; if (!didWarnAboutGetDerivedStateOnFunctionalComponent[_componentName]) { warningWithoutStack$1( @@ -10882,87 +11092,32 @@ function updateContextProvider( } } - var changedBits = void 0; - if (oldProps === null) { - // Initial render - changedBits = maxSigned31BitInt; - } else { - if (oldProps.value === newProps.value) { + pushProvider(workInProgress, newValue); + + if (oldProps !== null) { + var oldValue = oldProps.value; + var changedBits = calculateChangedBits(context, newValue, oldValue); + if (changedBits === 0) { // No change. Bailout early if children are the same. if (oldProps.children === newProps.children && !hasContextChanged()) { - workInProgress.stateNode = 0; - pushProvider(workInProgress); return bailoutOnAlreadyFinishedWork( current$$1, workInProgress, renderExpirationTime ); } - changedBits = 0; } else { - var oldValue = oldProps.value; - // Use Object.is to compare the new context value to the old value. - // Inlined Object.is polyfill. - // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is - if ( - (oldValue === newValue && - (oldValue !== 0 || 1 / oldValue === 1 / newValue)) || - (oldValue !== oldValue && newValue !== newValue) // eslint-disable-line no-self-compare - ) { - // No change. Bailout early if children are the same. - if (oldProps.children === newProps.children && !hasContextChanged()) { - workInProgress.stateNode = 0; - pushProvider(workInProgress); - return bailoutOnAlreadyFinishedWork( - current$$1, - workInProgress, - renderExpirationTime - ); - } - changedBits = 0; - } else { - changedBits = - typeof context._calculateChangedBits === "function" - ? context._calculateChangedBits(oldValue, newValue) - : maxSigned31BitInt; - { - !((changedBits & maxSigned31BitInt) === changedBits) - ? warning$1( - false, - "calculateChangedBits: Expected the return value to be a " + - "31-bit integer. Instead received: %s", - changedBits - ) - : void 0; - } - changedBits |= 0; - - if (changedBits === 0) { - // No change. Bailout early if children are the same. - if (oldProps.children === newProps.children && !hasContextChanged()) { - workInProgress.stateNode = 0; - pushProvider(workInProgress); - return bailoutOnAlreadyFinishedWork( - current$$1, - workInProgress, - renderExpirationTime - ); - } - } else { - propagateContextChange( - workInProgress, - context, - changedBits, - renderExpirationTime - ); - } - } + // The context value changed. Search for matching consumers and schedule + // them to update. + propagateContextChange( + workInProgress, + context, + changedBits, + renderExpirationTime + ); } } - workInProgress.stateNode = changedBits; - pushProvider(workInProgress); - var newChildren = newProps.children; reconcileChildren( current$$1, @@ -11049,7 +11204,7 @@ function bailoutOnAlreadyFinishedWork( if (enableProfilerTimer) { // Don't update "base" render times for bailouts. - stopBaseRenderTimerIfRunning(); + stopProfilerTimerIfRunning(workInProgress); } // Check if the children have any pending work. @@ -11082,12 +11237,6 @@ function memoizeState(workInProgress, nextState) { } function beginWork(current$$1, workInProgress, renderExpirationTime) { - if (enableProfilerTimer) { - if (workInProgress.mode & ProfileMode) { - markActualRenderTimeStarted(workInProgress); - } - } - var updateExpirationTime = workInProgress.expirationTime; if ( !hasContextChanged() && @@ -11105,19 +11254,32 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { case HostComponent: pushHostContext(workInProgress); break; - case ClassComponent: - pushContextProvider(workInProgress); + case ClassComponent: { + var Component = workInProgress.type; + if (isContextProvider(Component)) { + pushContextProvider(workInProgress); + } break; + } + case ClassComponentLazy: { + var thenable = workInProgress.type; + var _Component = getResultFromResolvedThenable(thenable); + if (isContextProvider(_Component)) { + pushContextProvider(workInProgress); + } + break; + } case HostPortal: pushHostContainer( workInProgress, workInProgress.stateNode.containerInfo ); break; - case ContextProvider: - workInProgress.stateNode = 0; - pushProvider(workInProgress); + case ContextProvider: { + var newValue = workInProgress.memoizedProps.value; + pushProvider(workInProgress, newValue); break; + } case Profiler: if (enableProfilerTimer) { workInProgress.effectTag |= Update; @@ -11135,24 +11297,65 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { workInProgress.expirationTime = NoWork; switch (workInProgress.tag) { - case IndeterminateComponent: + case IndeterminateComponent: { + var _Component3 = workInProgress.type; return mountIndeterminateComponent( current$$1, workInProgress, + _Component3, renderExpirationTime ); - case FunctionalComponent: + } + case FunctionalComponent: { + var _Component4 = workInProgress.type; + var _unresolvedProps = workInProgress.pendingProps; return updateFunctionalComponent( current$$1, workInProgress, + _Component4, + _unresolvedProps, renderExpirationTime ); - case ClassComponent: + } + case FunctionalComponentLazy: { + var _thenable2 = workInProgress.type; + var _Component5 = getResultFromResolvedThenable(_thenable2); + var _unresolvedProps2 = workInProgress.pendingProps; + var _child = updateFunctionalComponent( + current$$1, + workInProgress, + _Component5, + resolveDefaultProps(_Component5, _unresolvedProps2), + renderExpirationTime + ); + workInProgress.memoizedProps = _unresolvedProps2; + return _child; + } + case ClassComponent: { + var _Component6 = workInProgress.type; + var _unresolvedProps3 = workInProgress.pendingProps; return updateClassComponent( current$$1, workInProgress, + _Component6, + _unresolvedProps3, renderExpirationTime ); + } + case ClassComponentLazy: { + var _thenable3 = workInProgress.type; + var _Component7 = getResultFromResolvedThenable(_thenable3); + var _unresolvedProps4 = workInProgress.pendingProps; + var _child2 = updateClassComponent( + current$$1, + workInProgress, + _Component7, + resolveDefaultProps(_Component7, _unresolvedProps4), + renderExpirationTime + ); + workInProgress.memoizedProps = _unresolvedProps4; + return _child2; + } case HostRoot: return updateHostRoot(current$$1, workInProgress, renderExpirationTime); case HostComponent: @@ -11175,8 +11378,29 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { workInProgress, renderExpirationTime ); - case ForwardRef: - return updateForwardRef(current$$1, workInProgress, renderExpirationTime); + case ForwardRef: { + var type = workInProgress.type; + return updateForwardRef( + current$$1, + workInProgress, + type, + workInProgress.pendingProps, + renderExpirationTime + ); + } + case ForwardRefLazy: + var _thenable = workInProgress.type; + var _Component2 = getResultFromResolvedThenable(_thenable); + var unresolvedProps = workInProgress.pendingProps; + var child = updateForwardRef( + current$$1, + workInProgress, + _Component2, + resolveDefaultProps(_Component2, unresolvedProps), + renderExpirationTime + ); + workInProgress.memoizedProps = unresolvedProps; + return child; case Fragment: return updateFragment(current$$1, workInProgress, renderExpirationTime); case Mode: @@ -11256,13 +11480,36 @@ if (supportsMutation) { updateHostComponent$1 = function( current, workInProgress, - updatePayload, type, - oldProps, newProps, - rootContainerInstance, - currentHostContext + rootContainerInstance ) { + // If we have an alternate, that means this is an update and we need to + // schedule a side-effect to do the updates. + var oldProps = current.memoizedProps; + if (oldProps === newProps) { + // In mutation mode, this is sufficient for a bailout because + // we won't touch this node even if children changed. + return; + } + + // If we get updated because one of our children updated, we don't + // have newProps so we'll have to reuse them. + // TODO: Split the update API as separate for the props vs. children. + // Even better would be if children weren't special cased at all tho. + var instance = workInProgress.stateNode; + var currentHostContext = getHostContext(); + // TODO: Experiencing an error where oldProps is null. Suggests a host + // component is hitting the resume path. Figure out why. Possibly + // related to `hidden`. + var updatePayload = prepareUpdate( + instance, + type, + oldProps, + newProps, + rootContainerInstance, + currentHostContext + ); // TODO: Type this specific to this type of component. workInProgress.updateQueue = updatePayload; // If the update payload indicates that there is a change or if there @@ -11332,54 +11579,70 @@ if (supportsMutation) { updateHostComponent$1 = function( current, workInProgress, - updatePayload, type, - oldProps, newProps, - rootContainerInstance, - currentHostContext + rootContainerInstance ) { + var currentInstance = current.stateNode; + var oldProps = current.memoizedProps; // If there are no effects associated with this node, then none of our children had any updates. // This guarantees that we can reuse all of them. var childrenUnchanged = workInProgress.firstEffect === null; - var currentInstance = current.stateNode; + if (childrenUnchanged && oldProps === newProps) { + // No changes, just reuse the existing instance. + // Note that this might release a previous clone. + workInProgress.stateNode = currentInstance; + return; + } + var recyclableInstance = workInProgress.stateNode; + var currentHostContext = getHostContext(); + var updatePayload = null; + if (oldProps !== newProps) { + updatePayload = prepareUpdate( + recyclableInstance, + type, + oldProps, + newProps, + rootContainerInstance, + currentHostContext + ); + } if (childrenUnchanged && updatePayload === null) { // No changes, just reuse the existing instance. // Note that this might release a previous clone. workInProgress.stateNode = currentInstance; - } else { - var recyclableInstance = workInProgress.stateNode; - var newInstance = cloneInstance( - currentInstance, - updatePayload, + return; + } + var newInstance = cloneInstance( + currentInstance, + updatePayload, + type, + oldProps, + newProps, + workInProgress, + childrenUnchanged, + recyclableInstance + ); + if ( + finalizeInitialChildren( + newInstance, type, - oldProps, newProps, - workInProgress, - childrenUnchanged, - recyclableInstance - ); - if ( - finalizeInitialChildren( - newInstance, - type, - newProps, - rootContainerInstance, - currentHostContext - ) - ) { - markUpdate(workInProgress); - } - workInProgress.stateNode = newInstance; - if (childrenUnchanged) { - // If there are no other effects in this tree, we need to flag this node as having one. - // Even though we're not going to use it for anything. - // Otherwise parents won't know that there are new children to propagate upwards. - markUpdate(workInProgress); - } else { - // If children might have changed, we have to add them all to the set. - appendAllChildren(newInstance, workInProgress); - } + rootContainerInstance, + currentHostContext + ) + ) { + markUpdate(workInProgress); + } + workInProgress.stateNode = newInstance; + if (childrenUnchanged) { + // If there are no other effects in this tree, we need to flag this node as having one. + // Even though we're not going to use it for anything. + // Otherwise parents won't know that there are new children to propagate upwards. + markUpdate(workInProgress); + } else { + // If children might have changed, we have to add them all to the set. + appendAllChildren(newInstance, workInProgress); } }; updateHostText$1 = function(current, workInProgress, oldText, newText) { @@ -11406,12 +11669,9 @@ if (supportsMutation) { updateHostComponent$1 = function( current, workInProgress, - updatePayload, type, - oldProps, newProps, - rootContainerInstance, - currentHostContext + rootContainerInstance ) { // Noop }; @@ -11425,10 +11685,20 @@ function completeWork(current, workInProgress, renderExpirationTime) { switch (workInProgress.tag) { case FunctionalComponent: + case FunctionalComponentLazy: break; case ClassComponent: { - // We are leaving this subtree, so pop context if any. - popContextProvider(workInProgress); + var Component = workInProgress.type; + if (isContextProvider(Component)) { + popContext(workInProgress); + } + break; + } + case ClassComponentLazy: { + var _Component = getResultFromResolvedThenable(workInProgress.type); + if (isContextProvider(_Component)) { + popContext(workInProgress); + } break; } case HostRoot: { @@ -11455,36 +11725,12 @@ function completeWork(current, workInProgress, renderExpirationTime) { var rootContainerInstance = getRootHostContainer(); var type = workInProgress.type; if (current !== null && workInProgress.stateNode != null) { - // If we have an alternate, that means this is an update and we need to - // schedule a side-effect to do the updates. - var oldProps = current.memoizedProps; - // If we get updated because one of our children updated, we don't - // have newProps so we'll have to reuse them. - // TODO: Split the update API as separate for the props vs. children. - // Even better would be if children weren't special cased at all tho. - var instance = workInProgress.stateNode; - var currentHostContext = getHostContext(); - // TODO: Experiencing an error where oldProps is null. Suggests a host - // component is hitting the resume path. Figure out why. Possibly - // related to `hidden`. - var updatePayload = prepareUpdate( - instance, - type, - oldProps, - newProps, - rootContainerInstance, - currentHostContext - ); - updateHostComponent$1( current, workInProgress, - updatePayload, type, - oldProps, newProps, - rootContainerInstance, - currentHostContext + rootContainerInstance ); if (current.ref !== workInProgress.ref) { @@ -11501,7 +11747,7 @@ function completeWork(current, workInProgress, renderExpirationTime) { break; } - var _currentHostContext = getHostContext(); + var currentHostContext = getHostContext(); // TODO: Move createInstance to beginWork and keep it on a context // "stack" as the parent. Then append children as we go in beginWork // or completeWork depending on we want to add then top->down or @@ -11514,7 +11760,7 @@ function completeWork(current, workInProgress, renderExpirationTime) { prepareToHydrateHostInstance( workInProgress, rootContainerInstance, - _currentHostContext + currentHostContext ) ) { // If changes to the hydrated node needs to be applied at the @@ -11522,31 +11768,31 @@ function completeWork(current, workInProgress, renderExpirationTime) { markUpdate(workInProgress); } } else { - var _instance = createInstance( + var instance = createInstance( type, newProps, rootContainerInstance, - _currentHostContext, + currentHostContext, workInProgress ); - appendAllChildren(_instance, workInProgress); + appendAllChildren(instance, workInProgress); // Certain renderers require commit-time effects for initial mount. // (eg DOM renderer supports auto-focus for certain elements). // Make sure such renderers get scheduled for later work. if ( finalizeInitialChildren( - _instance, + instance, type, newProps, rootContainerInstance, - _currentHostContext + currentHostContext ) ) { markUpdate(workInProgress); } - workInProgress.stateNode = _instance; + workInProgress.stateNode = instance; } if (workInProgress.ref !== null) { @@ -11573,7 +11819,7 @@ function completeWork(current, workInProgress, renderExpirationTime) { // This can happen when we abort work. } var _rootContainerInstance = getRootHostContainer(); - var _currentHostContext2 = getHostContext(); + var _currentHostContext = getHostContext(); var _wasHydrated = popHydrationState(workInProgress); if (_wasHydrated) { if (prepareToHydrateHostTextInstance(workInProgress)) { @@ -11583,7 +11829,7 @@ function completeWork(current, workInProgress, renderExpirationTime) { workInProgress.stateNode = createTextInstance( newText, _rootContainerInstance, - _currentHostContext2, + _currentHostContext, workInProgress ); } @@ -11591,6 +11837,7 @@ function completeWork(current, workInProgress, renderExpirationTime) { break; } case ForwardRef: + case ForwardRefLazy: break; case PlaceholderComponent: break; @@ -11627,16 +11874,6 @@ function completeWork(current, workInProgress, renderExpirationTime) { ); } - if (enableProfilerTimer) { - if (workInProgress.mode & ProfileMode) { - // Don't record elapsed time unless the "complete" phase has succeeded. - // Certain renderers may error during this phase (i.e. ReactNative View/Text nesting validation). - // If an error occurs, we'll mark the time while unwinding. - // This simplifies the unwinding logic and ensures consistency. - recordElapsedActualRenderTime(workInProgress); - } - } - return null; } @@ -11691,11 +11928,6 @@ function logCapturedError(capturedError) { } var error = capturedError.error; - var suppressLogging = error && error.suppressReactErrorLogging; - if (suppressLogging) { - return; - } - { var componentName = capturedError.componentName, componentStack = capturedError.componentStack, @@ -11703,6 +11935,26 @@ function logCapturedError(capturedError) { errorBoundaryFound = capturedError.errorBoundaryFound, willRetry = capturedError.willRetry; + // Browsers support silencing uncaught errors by calling + // `preventDefault()` in window `error` handler. + // We record this information as an expando on the error. + + if (error != null && error._suppressLogging) { + if (errorBoundaryFound && willRetry) { + // The error is recoverable and was silenced. + // Ignore it and don't print the stack addendum. + // This is handy for testing error boundaries without noise. + return; + } + // The error is fatal. Since the silencing might have + // been accidental, we'll surface it anyway. + // However, the browser would have silenced the original error + // so we'll print it first, and then print the stack addendum. + console.error(error); + // For a more detailed description of this block, see: + // https://github.com/facebook/react/pull/13384 + } + var componentNameMessage = componentName ? "The above error occurred in the <" + componentName + "> component:" : "The above error occurred in one of your React components:"; @@ -11741,10 +11993,6 @@ function logCapturedError(capturedError) { } } -var invokeGuardedCallback$3 = ReactErrorUtils.invokeGuardedCallback; -var hasCaughtError$1 = ReactErrorUtils.hasCaughtError; -var clearCaughtError$1 = ReactErrorUtils.clearCaughtError; - var emptyObject$1 = {}; var didWarnAboutUndefinedSnapshotBeforeUpdate = null; @@ -11779,12 +12027,13 @@ function logError(boundary, errorInfo) { try { logCapturedError(capturedError); } catch (e) { - // Prevent cycle if logCapturedError() throws. - // A cycle may still occur if logCapturedError renders a component that throws. - var suppressLogging = e && e.suppressReactErrorLogging; - if (!suppressLogging) { - console.error(e); - } + // This method must not throw, or React internal state will get messed up. + // If console.error is overridden, or logCapturedError() shows a dialog that throws, + // we want to report this error outside of the normal stack as a last resort. + // https://github.com/facebook/react/issues/13188 + setTimeout(function() { + throw e; + }); } } @@ -11799,15 +12048,15 @@ var callComponentWillUnmountWithTimer = function(current$$1, instance) { // Capture errors so they don't interrupt unmounting. function safelyCallComponentWillUnmount(current$$1, instance) { { - invokeGuardedCallback$3( + invokeGuardedCallback( null, callComponentWillUnmountWithTimer, null, current$$1, instance ); - if (hasCaughtError$1()) { - var unmountError = clearCaughtError$1(); + if (hasCaughtError()) { + var unmountError = clearCaughtError(); captureCommitPhaseError(current$$1, unmountError); } } @@ -11818,9 +12067,9 @@ function safelyDetachRef(current$$1) { if (ref !== null) { if (typeof ref === "function") { { - invokeGuardedCallback$3(null, ref, null, null); - if (hasCaughtError$1()) { - var refError = clearCaughtError$1(); + invokeGuardedCallback(null, ref, null, null); + if (hasCaughtError()) { + var refError = clearCaughtError(); captureCommitPhaseError(current$$1, refError); } } @@ -11832,7 +12081,8 @@ function safelyDetachRef(current$$1) { function commitBeforeMutationLifeCycles(current$$1, finishedWork) { switch (finishedWork.tag) { - case ClassComponent: { + case ClassComponent: + case ClassComponentLazy: { if (finishedWork.effectTag & Snapshot) { if (current$$1 !== null) { var prevProps = current$$1.memoizedProps; @@ -11883,7 +12133,8 @@ function commitLifeCycles( committedExpirationTime ) { switch (finishedWork.tag) { - case ClassComponent: { + case ClassComponent: + case ClassComponentLazy: { var instance = finishedWork.stateNode; if (finishedWork.effectTag & Update) { if (current$$1 === null) { @@ -11929,6 +12180,7 @@ function commitLifeCycles( _instance = getPublicInstance(finishedWork.child.stateNode); break; case ClassComponent: + case ClassComponentLazy: _instance = finishedWork.child.stateNode; break; } @@ -11965,7 +12217,30 @@ function commitLifeCycles( return; } case Profiler: { - // We have no life-cycles associated with Profiler. + if (enableProfilerTimer) { + var onRender = finishedWork.memoizedProps.onRender; + + if (enableSchedulerTracking) { + onRender( + finishedWork.memoizedProps.id, + current$$1 === null ? "mount" : "update", + finishedWork.actualDuration, + finishedWork.treeBaseDuration, + finishedWork.actualStartTime, + getCommitTime(), + finishedRoot.memoizedInteractions + ); + } else { + onRender( + finishedWork.memoizedProps.id, + current$$1 === null ? "mount" : "update", + finishedWork.actualDuration, + finishedWork.treeBaseDuration, + finishedWork.actualStartTime, + getCommitTime() + ); + } + } return; } case PlaceholderComponent: { @@ -12047,7 +12322,8 @@ function commitUnmount(current$$1) { onCommitUnmount(current$$1); switch (current$$1.tag) { - case ClassComponent: { + case ClassComponent: + case ClassComponentLazy: { safelyDetachRef(current$$1); var instance = current$$1.stateNode; if (typeof instance.componentWillUnmount === "function") { @@ -12139,7 +12415,8 @@ function commitContainer(finishedWork) { } switch (finishedWork.tag) { - case ClassComponent: { + case ClassComponent: + case ClassComponentLazy: { return; } case HostComponent: { @@ -12418,7 +12695,8 @@ function commitWork(current$$1, finishedWork) { } switch (finishedWork.tag) { - case ClassComponent: { + case ClassComponent: + case ClassComponentLazy: { return; } case HostComponent: { @@ -12467,17 +12745,6 @@ function commitWork(current$$1, finishedWork) { return; } case Profiler: { - if (enableProfilerTimer) { - var onRender = finishedWork.memoizedProps.onRender; - onRender( - finishedWork.memoizedProps.id, - current$$1 === null ? "mount" : "update", - finishedWork.actualDuration, - finishedWork.treeBaseDuration, - finishedWork.actualStartTime, - getCommitTime() - ); - } return; } case PlaceholderComponent: { @@ -12671,7 +12938,10 @@ function throwException( sourceFiber.tag = FunctionalComponent; } - if (sourceFiber.tag === ClassComponent) { + if ( + sourceFiber.tag === ClassComponent || + sourceFiber.tag === ClassComponentLazy + ) { // We're going to commit this fiber even though it didn't // complete. But we shouldn't call any lifecycle methods or // callbacks. Remove all lifecycle effect tags. @@ -12708,8 +12978,8 @@ function throwException( // time. First, find the earliest uncommitted expiration time in the // tree, including work that is suspended. Then subtract the offset // used to compute an async update's expiration time. This will cause - // high priority (interactive) work to expire earlier than neccessary, - // but we can account for this by adjusting for the Just Noticable + // high priority (interactive) work to expire earlier than necessary, + // but we can account for this by adjusting for the Just Noticeable // Difference. var earliestExpirationTime = findEarliestOutstandingPriorityLevel( root, @@ -12765,6 +13035,7 @@ function throwException( return; } case ClassComponent: + case ClassComponentLazy: // Capture and retry var errorInfo = value; var ctor = workInProgress.type; @@ -12797,15 +13068,12 @@ function throwException( } function unwindWork(workInProgress, renderExpirationTime) { - if (enableProfilerTimer) { - if (workInProgress.mode & ProfileMode) { - recordElapsedActualRenderTime(workInProgress); - } - } - switch (workInProgress.tag) { case ClassComponent: { - popContextProvider(workInProgress); + var Component = workInProgress.type; + if (isContextProvider(Component)) { + popContext(workInProgress); + } var effectTag = workInProgress.effectTag; if (effectTag & ShouldCapture) { workInProgress.effectTag = (effectTag & ~ShouldCapture) | DidCapture; @@ -12813,16 +13081,28 @@ function unwindWork(workInProgress, renderExpirationTime) { } return null; } + case ClassComponentLazy: { + var _Component = workInProgress.type._reactResult; + if (isContextProvider(_Component)) { + popContext(workInProgress); + } + var _effectTag = workInProgress.effectTag; + if (_effectTag & ShouldCapture) { + workInProgress.effectTag = (_effectTag & ~ShouldCapture) | DidCapture; + return workInProgress; + } + return null; + } case HostRoot: { popHostContainer(workInProgress); popTopLevelContextObject(workInProgress); - var _effectTag = workInProgress.effectTag; + var _effectTag2 = workInProgress.effectTag; invariant( - (_effectTag & DidCapture) === NoEffect, + (_effectTag2 & DidCapture) === NoEffect, "The root failed to unmount after an error. This is likely a bug in " + "React. Please file an issue." ); - workInProgress.effectTag = (_effectTag & ~ShouldCapture) | DidCapture; + workInProgress.effectTag = (_effectTag2 & ~ShouldCapture) | DidCapture; return workInProgress; } case HostComponent: { @@ -12830,9 +13110,9 @@ function unwindWork(workInProgress, renderExpirationTime) { return null; } case PlaceholderComponent: { - var _effectTag2 = workInProgress.effectTag; - if (_effectTag2 & ShouldCapture) { - workInProgress.effectTag = (_effectTag2 & ~ShouldCapture) | DidCapture; + var _effectTag3 = workInProgress.effectTag; + if (_effectTag3 & ShouldCapture) { + workInProgress.effectTag = (_effectTag3 & ~ShouldCapture) | DidCapture; return workInProgress; } return null; @@ -12849,15 +13129,20 @@ function unwindWork(workInProgress, renderExpirationTime) { } function unwindInterruptedWork(interruptedWork) { - if (enableProfilerTimer) { - if (interruptedWork.mode & ProfileMode) { - recordElapsedActualRenderTime(interruptedWork); - } - } - switch (interruptedWork.tag) { case ClassComponent: { - popContextProvider(interruptedWork); + var childContextTypes = interruptedWork.type.childContextTypes; + if (childContextTypes !== null && childContextTypes !== undefined) { + popContext(interruptedWork); + } + break; + } + case ClassComponentLazy: { + var _childContextTypes = + interruptedWork.type._reactResult.childContextTypes; + if (_childContextTypes !== null && _childContextTypes !== undefined) { + popContext(interruptedWork); + } break; } case HostRoot: { @@ -12885,15 +13170,25 @@ var Dispatcher = { }; var ReactCurrentOwner$2 = ReactSharedInternals.ReactCurrentOwner; -var invokeGuardedCallback$2 = ReactErrorUtils.invokeGuardedCallback; -var hasCaughtError = ReactErrorUtils.hasCaughtError; -var clearCaughtError = ReactErrorUtils.clearCaughtError; var didWarnAboutStateTransition = void 0; var didWarnSetStateChildContext = void 0; var warnAboutUpdateOnUnmounted = void 0; var warnAboutInvalidUpdates = void 0; +if (enableSchedulerTracking) { + // Provide explicit error message when production+profiling bundle of e.g. react-dom + // is used with production (non-profiling) bundle of schedule/tracking + invariant( + tracking.__interactionsRef != null && + tracking.__interactionsRef.current != null, + "It is not supported to run the profiling version of a renderer (for example, `react-dom/profiling`) " + + "without also replacing the `schedule/tracking` module with `schedule/tracking-profiling`. " + + "Your bundler might have a setting for aliasing both modules. " + + "Learn more at http://fb.me/react-profiling" + ); +} + { didWarnAboutStateTransition = false; didWarnSetStateChildContext = false; @@ -12936,9 +13231,7 @@ var warnAboutInvalidUpdates = void 0; warningWithoutStack$1( false, "Cannot update during an existing state transition (such as within " + - "`render` or another component's constructor). Render methods should " + - "be a pure function of props and state; constructor side-effects are " + - "an anti-pattern, but can be moved to `componentWillMount`." + "`render`). Render methods should be a pure function of props and state." ); didWarnAboutStateTransition = true; break; @@ -12946,9 +13239,6 @@ var warnAboutInvalidUpdates = void 0; }; } -// Used to ensure computeUniqueAsyncExpiration is monotonically increasing. -var lastUniqueAsyncExpiration = 0; - // Represents the expiration time that incoming updates should use. (If this // is NoWork, use the default strategy: async updates in async mode, sync // updates in sync mode.) @@ -12974,6 +13264,10 @@ var legacyErrorBoundariesThatAlreadyFailed = null; // Used for performance tracking. var interruptedBy = null; +// Do not decrement interaction counts in the event of suspense timeouts. +// This would lead to prematurely calling the interaction-complete hook. +var suspenseDidTimeout = false; + var stashedWorkInProgressProperties = void 0; var replayUnitOfWork = void 0; var isReplayingFailedUnitOfWork = void 0; @@ -13018,9 +13312,20 @@ if (true && replayFailedUnitOfWorkWithInvokeGuardedCallback) { case HostComponent: popHostContext(failedUnitOfWork); break; - case ClassComponent: - popContextProvider(failedUnitOfWork); + case ClassComponent: { + var Component = failedUnitOfWork.type; + if (isContextProvider(Component)) { + popContext(failedUnitOfWork); + } break; + } + case ClassComponentLazy: { + var _Component = getResultFromResolvedThenable(failedUnitOfWork.type); + if (isContextProvider(_Component)) { + popContext(failedUnitOfWork); + } + break; + } case HostPortal: popHostContainer(failedUnitOfWork); break; @@ -13031,19 +13336,22 @@ if (true && replayFailedUnitOfWorkWithInvokeGuardedCallback) { // Replay the begin phase. isReplayingFailedUnitOfWork = true; originalReplayError = thrownValue; - invokeGuardedCallback$2(null, workLoop, null, isYieldy); + invokeGuardedCallback(null, workLoop, null, isYieldy); isReplayingFailedUnitOfWork = false; originalReplayError = null; if (hasCaughtError()) { - clearCaughtError(); - - if (enableProfilerTimer) { - if (failedUnitOfWork.mode & ProfileMode) { - recordElapsedActualRenderTime(failedUnitOfWork); + var replayError = clearCaughtError(); + if (replayError != null && thrownValue != null) { + try { + // Reading the expando property is intentionally + // inside `try` because it might be a getter or Proxy. + if (replayError._suppressLogging) { + // Also suppress logging for the original error. + thrownValue._suppressLogging = true; + } + } catch (inner) { + // Ignore. } - - // Stop "base" render timer again (after the re-thrown error). - stopBaseRenderTimerIfRunning(); } } else { // If the begin phase did not fail the second time, set this pointer @@ -13060,12 +13368,6 @@ function resetStack() { if (nextUnitOfWork !== null) { var interruptedWork = nextUnitOfWork.return; while (interruptedWork !== null) { - if (enableProfilerTimer) { - if (interruptedWork.mode & ProfileMode) { - // Resume in case we're picking up on work that was paused. - resumeActualRenderTimerIfPaused(false); - } - } unwindInterruptedWork(interruptedWork); interruptedWork = interruptedWork.return; } @@ -13262,6 +13564,36 @@ function commitRoot(root, finishedWork) { : updateExpirationTimeBeforeCommit; markCommittedPriorityLevels(root, earliestRemainingTimeBeforeCommit); + var prevInteractions = null; + var committedInteractions = enableSchedulerTracking ? [] : null; + if (enableSchedulerTracking) { + // Restore any pending interactions at this point, + // So that cascading work triggered during the render phase will be accounted for. + prevInteractions = tracking.__interactionsRef.current; + tracking.__interactionsRef.current = root.memoizedInteractions; + + // We are potentially finished with the current batch of interactions. + // So we should clear them out of the pending interaction map. + // We do this at the start of commit in case cascading work is scheduled by commit phase lifecycles. + // In that event, interaction data may be added back into the pending map for a future commit. + // We also store the interactions we are about to commit so that we can notify subscribers after we're done. + // These are stored as an Array rather than a Set, + // Because the same interaction may be pending for multiple expiration times, + // In which case it's important that we decrement the count the right number of times after finishing. + root.pendingInteractionMap.forEach(function( + scheduledInteractions, + scheduledExpirationTime + ) { + if (scheduledExpirationTime <= committedExpirationTime) { + committedInteractions.push.apply( + committedInteractions, + Array.from(scheduledInteractions) + ); + root.pendingInteractionMap.delete(scheduledExpirationTime); + } + }); + } + // Reset this to null before calling lifecycles ReactCurrentOwner$2.current = null; @@ -13291,7 +13623,7 @@ function commitRoot(root, finishedWork) { var didError = false; var error = void 0; { - invokeGuardedCallback$2(null, commitBeforeMutationLifecycles, null); + invokeGuardedCallback(null, commitBeforeMutationLifecycles, null); if (hasCaughtError()) { didError = true; error = clearCaughtError(); @@ -13327,7 +13659,7 @@ function commitRoot(root, finishedWork) { var _didError = false; var _error = void 0; { - invokeGuardedCallback$2(null, commitAllHostEffects, null); + invokeGuardedCallback(null, commitAllHostEffects, null); if (hasCaughtError()) { _didError = true; _error = clearCaughtError(); @@ -13366,7 +13698,7 @@ function commitRoot(root, finishedWork) { var _didError2 = false; var _error2 = void 0; { - invokeGuardedCallback$2( + invokeGuardedCallback( null, commitAllLifeCycles, null, @@ -13391,17 +13723,6 @@ function commitRoot(root, finishedWork) { } } - if (enableProfilerTimer) { - { - if (nextRoot === null) { - // Only check this stack once we're done processing async work. - // This prevents a false positive that occurs after a batched commit, - // If there was in-progress async work before the commit. - checkActualRenderTimeStackEmpty(); - } - } - } - isCommitting$1 = false; isWorking = false; stopCommitLifeCyclesTimer(); @@ -13425,6 +13746,53 @@ function commitRoot(root, finishedWork) { legacyErrorBoundariesThatAlreadyFailed = null; } onCommit(root, earliestRemainingTimeAfterCommit); + + if (enableSchedulerTracking) { + tracking.__interactionsRef.current = prevInteractions; + + var subscriber = void 0; + + try { + subscriber = tracking.__subscriberRef.current; + if (subscriber !== null && root.memoizedInteractions.size > 0) { + var threadID = computeThreadID( + committedExpirationTime, + root.interactionThreadID + ); + subscriber.onWorkStopped(root.memoizedInteractions, threadID); + } + } catch (error) { + // It's not safe for commitRoot() to throw. + // Store the error for now and we'll re-throw in finishRendering(). + if (!hasUnhandledError) { + hasUnhandledError = true; + unhandledError = error; + } + } finally { + // Don't update interaction counts if we're frozen due to suspense. + // In this case, we can skip the completed-work check entirely. + if (!suspenseDidTimeout) { + // Now that we're done, check the completed batch of interactions. + // If no more work is outstanding for a given interaction, + // We need to notify the subscribers that it's finished. + committedInteractions.forEach(function(interaction) { + interaction.__count--; + if (subscriber !== null && interaction.__count === 0) { + try { + subscriber.onInteractionScheduledWorkCompleted(interaction); + } catch (error) { + // It's not safe for commitRoot() to throw. + // Store the error for now and we'll re-throw in finishRendering(). + if (!hasUnhandledError) { + hasUnhandledError = true; + unhandledError = error; + } + } + } + }); + } + } + } } function resetChildExpirationTime(workInProgress, renderTime) { @@ -13438,9 +13806,22 @@ function resetChildExpirationTime(workInProgress, renderTime) { // Bubble up the earliest expiration time. if (enableProfilerTimer && workInProgress.mode & ProfileMode) { - // We're in profiling mode. Let's use this same traversal to update the - // "base" render times. + // We're in profiling mode. + // Let's use this same traversal to update the render durations. + var actualDuration = workInProgress.actualDuration; var treeBaseDuration = workInProgress.selfBaseDuration; + + // When a fiber is cloned, its actualDuration is reset to 0. + // This value will only be updated if work is done on the fiber (i.e. it doesn't bailout). + // When work is done, it should bubble to the parent's actualDuration. + // If the fiber has not been cloned though, (meaning no work was done), + // Then this value will reflect the amount of time spent working on a previous render. + // In that case it should not bubble. + // We determine whether it was cloned by comparing the child pointer. + var shouldBubbleActualDurations = + workInProgress.alternate === null || + workInProgress.child !== workInProgress.alternate.child; + var child = workInProgress.child; while (child !== null) { var childUpdateExpirationTime = child.expirationTime; @@ -13459,9 +13840,13 @@ function resetChildExpirationTime(workInProgress, renderTime) { ) { newChildExpirationTime = childChildExpirationTime; } + if (shouldBubbleActualDurations) { + actualDuration += child.actualDuration; + } treeBaseDuration += child.treeBaseDuration; child = child.sibling; } + workInProgress.actualDuration = actualDuration; workInProgress.treeBaseDuration = treeBaseDuration; } else { var _child = workInProgress.child; @@ -13508,11 +13893,28 @@ function completeUnitOfWork(workInProgress) { if ((workInProgress.effectTag & Incomplete) === NoEffect) { // This fiber completed. - nextUnitOfWork = completeWork( - current$$1, - workInProgress, - nextRenderExpirationTime - ); + if (enableProfilerTimer) { + if (workInProgress.mode & ProfileMode) { + startProfilerTimer(workInProgress); + } + + nextUnitOfWork = completeWork( + current$$1, + workInProgress, + nextRenderExpirationTime + ); + + if (workInProgress.mode & ProfileMode) { + // Update render duration assuming we didn't error. + stopProfilerTimerIfRunningAndRecordDelta(workInProgress, false); + } + } else { + nextUnitOfWork = completeWork( + current$$1, + workInProgress, + nextRenderExpirationTime + ); + } var next = nextUnitOfWork; stopWorkTimer(workInProgress); resetChildExpirationTime(workInProgress, nextRenderExpirationTime); @@ -13583,6 +13985,11 @@ function completeUnitOfWork(workInProgress) { return null; } } else { + if (workInProgress.mode & ProfileMode) { + // Record the render duration for the fiber that errored. + stopProfilerTimerIfRunningAndRecordDelta(workInProgress, false); + } + // This fiber did not complete because something threw. Pop values off // the stack without entering the complete phase. If this is a boundary, // capture values if possible. @@ -13605,6 +14012,19 @@ function completeUnitOfWork(workInProgress) { ReactFiberInstrumentation_1.debugTool.onCompleteWork(workInProgress); } + if (enableProfilerTimer) { + // Include the time spent working on failed children before continuing. + if (_next.mode & ProfileMode) { + var actualDuration = _next.actualDuration; + var child = _next.child; + while (child !== null) { + actualDuration += child.actualDuration; + child = child.sibling; + } + _next.actualDuration = actualDuration; + } + } + // If completing this work spawned new work, do that next. We'll come // back here again. // Since we're restarting, remove anything that is not a host effect @@ -13665,15 +14085,14 @@ function performUnitOfWork(workInProgress) { var next = void 0; if (enableProfilerTimer) { if (workInProgress.mode & ProfileMode) { - startBaseRenderTimer(); + startProfilerTimer(workInProgress); } next = beginWork(current$$1, workInProgress, nextRenderExpirationTime); if (workInProgress.mode & ProfileMode) { - // Update "base" time if the render wasn't bailed out on. - recordElapsedBaseRenderTimeIfRunning(workInProgress); - stopBaseRenderTimerIfRunning(); + // Record the render duration assuming we didn't bailout (or error). + stopProfilerTimerIfRunningAndRecordDelta(workInProgress, true); } } else { next = beginWork(current$$1, workInProgress, nextRenderExpirationTime); @@ -13714,12 +14133,6 @@ function workLoop(isYieldy) { while (nextUnitOfWork !== null && !shouldYield()) { nextUnitOfWork = performUnitOfWork(nextUnitOfWork); } - - if (enableProfilerTimer) { - // If we didn't finish, pause the "actual" render timer. - // We'll restart it when we resume work. - pauseActualRenderTimerIfRunning(); - } } } @@ -13734,6 +14147,14 @@ function renderRoot(root, isYieldy, isExpired) { var expirationTime = root.nextExpirationTimeToWorkOn; + var prevInteractions = null; + if (enableSchedulerTracking) { + // We're about to start new tracked work. + // Restore pending interactions so cascading work triggered during the render phase will be accounted for. + prevInteractions = tracking.__interactionsRef.current; + tracking.__interactionsRef.current = root.memoizedInteractions; + } + // Check if we're starting from a fresh stack, or if we're resuming from // previously yielded work. if ( @@ -13751,6 +14172,49 @@ function renderRoot(root, isYieldy, isExpired) { nextRenderExpirationTime ); root.pendingCommitExpirationTime = NoWork; + + if (enableSchedulerTracking) { + // Determine which interactions this batch of work currently includes, + // So that we can accurately attribute time spent working on it, + var interactions = new Set(); + root.pendingInteractionMap.forEach(function( + scheduledInteractions, + scheduledExpirationTime + ) { + if (scheduledExpirationTime <= expirationTime) { + scheduledInteractions.forEach(function(interaction) { + return interactions.add(interaction); + }); + } + }); + + // Store the current set of interactions on the FiberRoot for a few reasons: + // We can re-use it in hot functions like renderRoot() without having to recalculate it. + // We will also use it in commitWork() to pass to any Profiler onRender() hooks. + // This also provides DevTools with a way to access it when the onCommitRoot() hook is called. + root.memoizedInteractions = interactions; + + if (interactions.size > 0) { + var subscriber = tracking.__subscriberRef.current; + if (subscriber !== null) { + var threadID = computeThreadID( + expirationTime, + root.interactionThreadID + ); + try { + subscriber.onWorkStarted(interactions, threadID); + } catch (error) { + // Work thrown by an interaction tracking subscriber should be rethrown, + // But only once it's safe (to avoid leaveing the scheduler in an invalid state). + // Store the error for now and we'll re-throw in finishRendering(). + if (!hasUnhandledError) { + hasUnhandledError = true; + unhandledError = error; + } + } + } + } + } } var didFatal = false; @@ -13761,11 +14225,6 @@ function renderRoot(root, isYieldy, isExpired) { try { workLoop(isYieldy); } catch (thrownValue) { - if (enableProfilerTimer) { - // Stop "base" render timer in the event of an error. - stopBaseRenderTimerIfRunning(); - } - if (nextUnitOfWork === null) { // This is a fatal error. didFatal = true; @@ -13819,6 +14278,11 @@ function renderRoot(root, isYieldy, isExpired) { break; } while (true); + if (enableSchedulerTracking) { + // Tracked work is done for now; restore the previous interactions. + tracking.__interactionsRef.current = prevInteractions; + } + // We're done performing work. Time to clean up. isWorking = false; ReactCurrentOwner$2.currentDispatcher = null; @@ -13832,10 +14296,6 @@ function renderRoot(root, isYieldy, isExpired) { // There was a fatal error. { resetStackAfterFatalErrorInDev(); - - // Reset the DEV fiber stack in case we're profiling roots. - // (We do this for profiling bulds when DevTools is detected.) - resetActualRenderTimerStackAfterFatalErrorInDev(); } // `nextRoot` points to the in-progress root. A non-null value indicates // that we're in the middle of an async render. Set it to null to indicate @@ -13939,7 +14399,7 @@ function renderRoot(root, isYieldy, isExpired) { var msUntilTimeout = nextLatestAbsoluteTimeoutMs - currentTimeMs; msUntilTimeout = msUntilTimeout < 0 ? 0 : msUntilTimeout; - // TODO: Account for the Just Noticable Difference + // TODO: Account for the Just Noticeable Difference var _rootExpirationTime2 = root.expirationTime; onSuspend( @@ -13966,6 +14426,7 @@ function dispatch(sourceFiber, value, expirationTime) { while (fiber !== null) { switch (fiber.tag) { case ClassComponent: + case ClassComponentLazy: var ctor = fiber.type; var instance = fiber.stateNode; if ( @@ -14010,18 +14471,9 @@ function captureCommitPhaseError(fiber, error) { return dispatch(fiber, error, Sync); } -// Creates a unique async expiration time. -function computeUniqueAsyncExpiration() { - var currentTime = requestCurrentTime(); - var result = computeAsyncExpiration(currentTime); - if (result <= lastUniqueAsyncExpiration) { - // Since we assume the current time monotonically increases, we only hit - // this branch when computeUniqueAsyncExpiration is fired multiple times - // within a 200ms window (or whatever the async bucket size is). - result = lastUniqueAsyncExpiration + 1; - } - lastUniqueAsyncExpiration = result; - return lastUniqueAsyncExpiration; +function computeThreadID(expirationTime, interactionThreadID) { + // Interaction threads are unique per root and expiration time. + return expirationTime * 1000 + interactionThreadID; } function computeExpirationForFiber(currentTime, fiber) { @@ -14065,10 +14517,10 @@ function computeExpirationForFiber(currentTime, fiber) { // interactive expiration time. This allows us to synchronously flush // all interactive updates when needed. if ( - lowestPendingInteractiveExpirationTime === NoWork || - expirationTime > lowestPendingInteractiveExpirationTime + lowestPriorityPendingInteractiveExpirationTime === NoWork || + expirationTime > lowestPriorityPendingInteractiveExpirationTime ) { - lowestPendingInteractiveExpirationTime = expirationTime; + lowestPriorityPendingInteractiveExpirationTime = expirationTime; } } return expirationTime; @@ -14106,7 +14558,18 @@ function retrySuspendedRoot(root, fiber, suspendedTime) { scheduleWorkToRoot(fiber, retryTime); var rootExpirationTime = root.expirationTime; if (rootExpirationTime !== NoWork) { - requestWork(root, rootExpirationTime); + if (enableSchedulerTracking) { + // Restore previous interactions so that new work is associated with them. + var prevInteractions = tracking.__interactionsRef.current; + tracking.__interactionsRef.current = root.memoizedInteractions; + // Because suspense timeouts do not decrement the interaction count, + // Continued suspense work should also not increment the count. + storeInteractionsForExpirationTime(root, rootExpirationTime, false); + requestWork(root, rootExpirationTime); + tracking.__interactionsRef.current = prevInteractions; + } else { + requestWork(root, rootExpirationTime); + } } } } @@ -14161,11 +14624,51 @@ function scheduleWorkToRoot(fiber, expirationTime) { return null; } +function storeInteractionsForExpirationTime( + root, + expirationTime, + updateInteractionCounts +) { + if (!enableSchedulerTracking) { + return; + } + + var interactions = tracking.__interactionsRef.current; + if (interactions.size > 0) { + var pendingInteractions = root.pendingInteractionMap.get(expirationTime); + if (pendingInteractions != null) { + interactions.forEach(function(interaction) { + if (updateInteractionCounts && !pendingInteractions.has(interaction)) { + // Update the pending async work count for previously unscheduled interaction. + interaction.__count++; + } + + pendingInteractions.add(interaction); + }); + } else { + root.pendingInteractionMap.set(expirationTime, new Set(interactions)); + + // Update the pending async work count for the current interactions. + if (updateInteractionCounts) { + interactions.forEach(function(interaction) { + interaction.__count++; + }); + } + } + + var subscriber = tracking.__subscriberRef.current; + if (subscriber !== null) { + var threadID = computeThreadID(expirationTime, root.interactionThreadID); + subscriber.onWorkScheduled(interactions, threadID); + } + } +} + function scheduleWork(fiber, expirationTime) { recordScheduleUpdate(); { - if (fiber.tag === ClassComponent) { + if (fiber.tag === ClassComponent || fiber.tag === ClassComponentLazy) { var instance = fiber.stateNode; warnAboutInvalidUpdates(instance); } @@ -14173,12 +14676,19 @@ function scheduleWork(fiber, expirationTime) { var root = scheduleWorkToRoot(fiber, expirationTime); if (root === null) { - if (true && fiber.tag === ClassComponent) { + if ( + true && + (fiber.tag === ClassComponent || fiber.tag === ClassComponentLazy) + ) { warnAboutUpdateOnUnmounted(fiber); } return; } + if (enableSchedulerTracking) { + storeInteractionsForExpirationTime(root, expirationTime, true); + } + if ( !isWorking && nextRenderExpirationTime !== NoWork && @@ -14213,27 +14723,6 @@ function scheduleWork(fiber, expirationTime) { } } -function deferredUpdates(fn) { - var currentTime = requestCurrentTime(); - var previousExpirationContext = expirationContext; - expirationContext = computeAsyncExpiration(currentTime); - try { - return fn(); - } finally { - expirationContext = previousExpirationContext; - } -} - -function syncUpdates(fn, a, b, c, d) { - var previousExpirationContext = expirationContext; - expirationContext = Sync; - try { - return fn(a, b, c, d); - } finally { - expirationContext = previousExpirationContext; - } -} - // TODO: Everything below this is written as if it has been lifted to the // renderers. I'll do this in a follow-up. @@ -14246,7 +14735,7 @@ var callbackID = void 0; var isRendering = false; var nextFlushedRoot = null; var nextFlushedExpirationTime = NoWork; -var lowestPendingInteractiveExpirationTime = NoWork; +var lowestPriorityPendingInteractiveExpirationTime = NoWork; var deadlineDidExpire = false; var hasUnhandledError = false; var unhandledError = null; @@ -14274,7 +14763,7 @@ function recomputeCurrentRendererTime() { currentRendererTime = msToExpirationTime(currentTimeMs); } -function scheduleCallbackWithExpirationTime(expirationTime) { +function scheduleCallbackWithExpirationTime(root, expirationTime) { if (callbackExpirationTime !== NoWork) { // A callback is already scheduled. Check its expiration time (timeout). if (expirationTime > callbackExpirationTime) { @@ -14347,7 +14836,16 @@ function onTimeout(root, finishedWork, suspendedExpirationTime) { // because we're at the top of a timer event. recomputeCurrentRendererTime(); currentSchedulerTime = currentRendererTime; - flushRoot(root, suspendedExpirationTime); + + if (enableSchedulerTracking) { + // Don't update pending interaction counts for suspense timeouts, + // Because we know we still need to do more work in this case. + suspenseDidTimeout = true; + flushRoot(root, suspendedExpirationTime); + suspenseDidTimeout = false; + } else { + flushRoot(root, suspendedExpirationTime); + } } } @@ -14426,7 +14924,7 @@ function requestWork(root, expirationTime) { if (expirationTime === Sync) { performSyncWork(); } else { - scheduleCallbackWithExpirationTime(expirationTime); + scheduleCallbackWithExpirationTime(root, expirationTime); } } @@ -14510,6 +15008,11 @@ function findHighestPriorityRoot() { if (root === lastScheduledRoot) { break; } + if (highestPriorityWork === Sync) { + // Sync is highest priority by definition so + // we can stop searching. + break; + } previousScheduledRoot = root; root = root.nextScheduledRoot; } @@ -14521,6 +15024,22 @@ function findHighestPriorityRoot() { } function performAsyncWork(dl) { + if (dl.didTimeout) { + // The callback timed out. That means at least one update has expired. + // Iterate through the root schedule. If they contain expired work, set + // the next render expiration time to the current time. This has the effect + // of flushing all expired work in a single batch, instead of flushing each + // level one at a time. + if (firstScheduledRoot !== null) { + recomputeCurrentRendererTime(); + var root = firstScheduledRoot; + do { + didExpireAtExpirationTime(root, currentRendererTime); + // The root schedule is circular, so this is never null. + root = root.nextScheduledRoot; + } while (root !== firstScheduledRoot); + } + } performWork(NoWork, dl); } @@ -14531,14 +15050,10 @@ function performSyncWork() { function performWork(minExpirationTime, dl) { deadline = dl; - // Keep working on roots until there's no more work, or until the we reach + // Keep working on roots until there's no more work, or until we reach // the deadline. findHighestPriorityRoot(); - if (enableProfilerTimer) { - resumeActualRenderTimerIfPaused(minExpirationTime === Sync); - } - if (deadline !== null) { recomputeCurrentRendererTime(); currentSchedulerTime = currentRendererTime; @@ -14587,7 +15102,10 @@ function performWork(minExpirationTime, dl) { } // If there's work left over, schedule a new callback. if (nextFlushedExpirationTime !== NoWork) { - scheduleCallbackWithExpirationTime(nextFlushedExpirationTime); + scheduleCallbackWithExpirationTime( + nextFlushedRoot, + nextFlushedExpirationTime + ); } // Clean-up. @@ -14611,7 +15129,6 @@ function flushRoot(root, expirationTime) { performWorkOnRoot(root, expirationTime, true); // Flush any sync work that was scheduled by lifecycles performSyncWork(); - pauseActualRenderTimerIfRunning(); } function finishRendering() { @@ -14709,12 +15226,6 @@ function performWorkOnRoot(root, expirationTime, isExpired) { // There's no time left. Mark this root as complete. We'll come // back and commit it later. root.finishedWork = _finishedWork; - - if (enableProfilerTimer) { - // If we didn't finish, pause the "actual" render timer. - // We'll restart it when we resume work. - pauseActualRenderTimerIfRunning(); - } } } } @@ -14806,38 +15317,6 @@ function batchedUpdates$1(fn, a) { } } -// TODO: Batching should be implemented at the renderer level, not inside -// the reconciler. -function unbatchedUpdates(fn, a) { - if (isBatchingUpdates && !isUnbatchingUpdates) { - isUnbatchingUpdates = true; - try { - return fn(a); - } finally { - isUnbatchingUpdates = false; - } - } - return fn(a); -} - -// TODO: Batching should be implemented at the renderer level, not within -// the reconciler. -function flushSync(fn, a) { - invariant( - !isRendering, - "flushSync was called from inside a lifecycle method. It cannot be " + - "called when React is already rendering." - ); - var previousIsBatchingUpdates = isBatchingUpdates; - isBatchingUpdates = true; - try { - return syncUpdates(fn, a); - } finally { - isBatchingUpdates = previousIsBatchingUpdates; - performSyncWork(); - } -} - function interactiveUpdates$1(fn, a, b) { if (isBatchingInteractiveUpdates) { return fn(a, b); @@ -14849,11 +15328,11 @@ function interactiveUpdates$1(fn, a, b) { if ( !isBatchingUpdates && !isRendering && - lowestPendingInteractiveExpirationTime !== NoWork + lowestPriorityPendingInteractiveExpirationTime !== NoWork ) { // Synchronously flush pending interactive updates. - performWork(lowestPendingInteractiveExpirationTime, null); - lowestPendingInteractiveExpirationTime = NoWork; + performWork(lowestPriorityPendingInteractiveExpirationTime, null); + lowestPriorityPendingInteractiveExpirationTime = NoWork; } var previousIsBatchingInteractiveUpdates = isBatchingInteractiveUpdates; var previousIsBatchingUpdates = isBatchingUpdates; @@ -14871,23 +15350,13 @@ function interactiveUpdates$1(fn, a, b) { } function flushInteractiveUpdates$1() { - if (!isRendering && lowestPendingInteractiveExpirationTime !== NoWork) { + if ( + !isRendering && + lowestPriorityPendingInteractiveExpirationTime !== NoWork + ) { // Synchronously flush pending interactive updates. - performWork(lowestPendingInteractiveExpirationTime, null); - lowestPendingInteractiveExpirationTime = NoWork; - } -} - -function flushControlled(fn) { - var previousIsBatchingUpdates = isBatchingUpdates; - isBatchingUpdates = true; - try { - syncUpdates(fn); - } finally { - isBatchingUpdates = previousIsBatchingUpdates; - if (!isBatchingUpdates && !isRendering) { - performWork(Sync, null); - } + performWork(lowestPriorityPendingInteractiveExpirationTime, null); + lowestPriorityPendingInteractiveExpirationTime = NoWork; } } @@ -14907,9 +15376,20 @@ function getContextForSubtree(parentComponent) { var fiber = get$1(parentComponent); var parentContext = findCurrentUnmaskedContext(fiber); - return isContextProvider(fiber) - ? processChildContext(fiber, parentContext) - : parentContext; + + if (fiber.tag === ClassComponent) { + var Component = fiber.type; + if (isContextProvider(Component)) { + return processChildContext(fiber, Component, parentContext); + } + } else if (fiber.tag === ClassComponentLazy) { + var _Component = getResultFromResolvedThenable(fiber.type); + if (isContextProvider(_Component)) { + return processChildContext(fiber, _Component, parentContext); + } + } + + return parentContext; } function scheduleRootUpdate(current$$1, element, expirationTime, callback) { @@ -15032,14 +15512,6 @@ function getPublicRootInstance(container) { } } -function findHostInstanceWithNoPortals(fiber) { - var hostFiber = findCurrentHostFiberWithNoPortals(fiber); - if (hostFiber === null) { - return null; - } - return hostFiber.stateNode; -} - function injectIntoDevTools(devToolsConfig) { var findFiberByHostInstance = devToolsConfig.findFiberByHostInstance; @@ -15066,27 +15538,6 @@ function injectIntoDevTools(devToolsConfig) { // This file intentionally does *not* have the Flow annotation. // Don't add it. See `./inline-typed.js` for an explanation. -var ReactNativeFiberRenderer = Object.freeze({ - updateContainerAtExpirationTime: updateContainerAtExpirationTime, - createContainer: createContainer, - updateContainer: updateContainer, - flushRoot: flushRoot, - requestWork: requestWork, - computeUniqueAsyncExpiration: computeUniqueAsyncExpiration, - batchedUpdates: batchedUpdates$1, - unbatchedUpdates: unbatchedUpdates, - deferredUpdates: deferredUpdates, - syncUpdates: syncUpdates, - interactiveUpdates: interactiveUpdates$1, - flushInteractiveUpdates: flushInteractiveUpdates$1, - flushControlled: flushControlled, - flushSync: flushSync, - getPublicRootInstance: getPublicRootInstance, - findHostInstance: findHostInstance$1, - findHostInstanceWithNoPortals: findHostInstanceWithNoPortals, - injectIntoDevTools: injectIntoDevTools -}); - function createPortal( children, containerInfo, @@ -15108,7 +15559,7 @@ function createPortal( // TODO: this is special because it gets imported during build. -var ReactVersion = "16.4.1"; +var ReactVersion = "16.5.0"; // Modules provided by RN: var NativeMethodsMixin = function(findNodeHandle, findHostInstance) { @@ -15148,7 +15599,7 @@ var NativeMethodsMixin = function(findNodeHandle, findHostInstance) { measure: function(callback) { UIManager.measure( findNodeHandle(this), - mountSafeCallback(this, callback) + mountSafeCallback_NOT_REALLY_SAFE(this, callback) ); }, @@ -15170,7 +15621,7 @@ var NativeMethodsMixin = function(findNodeHandle, findHostInstance) { measureInWindow: function(callback) { UIManager.measureInWindow( findNodeHandle(this), - mountSafeCallback(this, callback) + mountSafeCallback_NOT_REALLY_SAFE(this, callback) ); }, @@ -15190,8 +15641,8 @@ var NativeMethodsMixin = function(findNodeHandle, findHostInstance) { UIManager.measureLayout( findNodeHandle(this), relativeToNativeNode, - mountSafeCallback(this, onFail), - mountSafeCallback(this, onSuccess) + mountSafeCallback_NOT_REALLY_SAFE(this, onFail), + mountSafeCallback_NOT_REALLY_SAFE(this, onSuccess) ); }, @@ -15400,7 +15851,7 @@ var ReactNativeComponent = function(findNodeHandle, findHostInstance) { ReactNativeComponent.prototype.measure = function measure(callback) { UIManager.measure( findNodeHandle(this), - mountSafeCallback(this, callback) + mountSafeCallback_NOT_REALLY_SAFE(this, callback) ); }; @@ -15423,7 +15874,7 @@ var ReactNativeComponent = function(findNodeHandle, findHostInstance) { ) { UIManager.measureInWindow( findNodeHandle(this), - mountSafeCallback(this, callback) + mountSafeCallback_NOT_REALLY_SAFE(this, callback) ); }; @@ -15442,8 +15893,8 @@ var ReactNativeComponent = function(findNodeHandle, findHostInstance) { UIManager.measureLayout( findNodeHandle(this), relativeToNativeNode, - mountSafeCallback(this, onFail), - mountSafeCallback(this, onSuccess) + mountSafeCallback_NOT_REALLY_SAFE(this, onFail), + mountSafeCallback_NOT_REALLY_SAFE(this, onSuccess) ); }; @@ -15658,7 +16109,11 @@ function findNodeHandle(componentOrHandle) { return hostInstance._nativeTag; } -injection$2.injectRenderer(ReactNativeFiberRenderer); +setBatchingImplementation( + batchedUpdates$1, + interactiveUpdates$1, + flushInteractiveUpdates$1 +); function computeComponentStackForErrorReporting(reactTag) { var fiber = getInstanceFromTag(reactTag); @@ -15736,9 +16191,8 @@ var ReactNativeRenderer$3 = // TODO: decide on the top-level export form. // This is hacky but makes it work with both Rollup and Jest. -var reactNativeRenderer = ReactNativeRenderer$3.default - ? ReactNativeRenderer$3.default - : ReactNativeRenderer$3; +var reactNativeRenderer = + ReactNativeRenderer$3.default || ReactNativeRenderer$3; module.exports = reactNativeRenderer; diff --git a/Libraries/Renderer/oss/ReactNativeRenderer-prod.js b/Libraries/Renderer/oss/ReactNativeRenderer-prod.js index 4b5462dfa..cc861113f 100644 --- a/Libraries/Renderer/oss/ReactNativeRenderer-prod.js +++ b/Libraries/Renderer/oss/ReactNativeRenderer-prod.js @@ -1,5 +1,5 @@ /** - * Copyright (c) 2013-present, Facebook, Inc. + * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. @@ -18,8 +18,8 @@ var ReactNativeViewConfigRegistry = require("ReactNativeViewConfigRegistry"), React = require("react"), deepDiffer = require("deepDiffer"), flattenStyle = require("flattenStyle"), - TextInputState = require("TextInputState"), - ExceptionsManager = require("ExceptionsManager"); + TextInputState = require("TextInputState"); +var ExceptionsManager = require("ExceptionsManager"); function invariant(condition, format, a, b, c, d, e, f) { if (!condition) { condition = void 0; @@ -41,68 +41,53 @@ function invariant(condition, format, a, b, c, d, e, f) { throw condition; } } -function invokeGuardedCallback(name, func, context, a, b, c, d, e, f) { - this._hasCaughtError = !1; - this._caughtError = null; +function invokeGuardedCallbackImpl(name, func, context, a, b, c, d, e, f) { var funcArgs = Array.prototype.slice.call(arguments, 3); try { func.apply(context, funcArgs); } catch (error) { - (this._caughtError = error), (this._hasCaughtError = !0); + this.onError(error); } } -var ReactErrorUtils = { - _caughtError: null, - _hasCaughtError: !1, - _rethrowError: null, - _hasRethrowError: !1, - invokeGuardedCallback: function(name, func, context, a, b, c, d, e, f) { - invokeGuardedCallback.apply(ReactErrorUtils, arguments); - }, - invokeGuardedCallbackAndCatchFirstError: function( - name, - func, - context, - a, - b, - c, - d, - e, - f - ) { - ReactErrorUtils.invokeGuardedCallback.apply(this, arguments); - if (ReactErrorUtils.hasCaughtError()) { - var error = ReactErrorUtils.clearCaughtError(); - ReactErrorUtils._hasRethrowError || - ((ReactErrorUtils._hasRethrowError = !0), - (ReactErrorUtils._rethrowError = error)); +var hasError = !1, + caughtError = null, + hasRethrowError = !1, + rethrowError = null, + reporter = { + onError: function(error) { + hasError = !0; + caughtError = error; } - }, - rethrowCaughtError: function() { - return rethrowCaughtError.apply(ReactErrorUtils, arguments); - }, - hasCaughtError: function() { - return ReactErrorUtils._hasCaughtError; - }, - clearCaughtError: function() { - if (ReactErrorUtils._hasCaughtError) { - var error = ReactErrorUtils._caughtError; - ReactErrorUtils._caughtError = null; - ReactErrorUtils._hasCaughtError = !1; - return error; - } - invariant( - !1, - "clearCaughtError was called but no error was captured. This error is likely caused by a bug in React. Please file an issue." - ); - } -}; -function rethrowCaughtError() { - if (ReactErrorUtils._hasRethrowError) { - var error = ReactErrorUtils._rethrowError; - ReactErrorUtils._rethrowError = null; - ReactErrorUtils._hasRethrowError = !1; - throw error; + }; +function invokeGuardedCallback(name, func, context, a, b, c, d, e, f) { + hasError = !1; + caughtError = null; + invokeGuardedCallbackImpl.apply(reporter, arguments); +} +function invokeGuardedCallbackAndCatchFirstError( + name, + func, + context, + a, + b, + c, + d, + e, + f +) { + invokeGuardedCallback.apply(this, arguments); + if (hasError) { + if (hasError) { + var error = caughtError; + hasError = !1; + caughtError = null; + } else + invariant( + !1, + "clearCaughtError was called but no error was captured. This error is likely caused by a bug in React. Please file an issue." + ), + (error = void 0); + hasRethrowError || ((hasRethrowError = !0), (rethrowError = error)); } } var eventPluginOrder = null, @@ -184,12 +169,7 @@ var plugins = [], function executeDispatch(event, simulated, listener, inst) { simulated = event.type || "unknown-event"; event.currentTarget = getNodeFromInstance(inst); - ReactErrorUtils.invokeGuardedCallbackAndCatchFirstError( - simulated, - listener, - void 0, - event - ); + invokeGuardedCallbackAndCatchFirstError(simulated, listener, void 0, event); event.currentTarget = null; } function executeDirectDispatch(event) { @@ -313,7 +293,7 @@ function getListener(inst, registrationName) { } function getParent(inst) { do inst = inst.return; - while (inst && 5 !== inst.tag); + while (inst && 7 !== inst.tag); return inst ? inst : null; } function traverseTwoPhase(inst, fn, arg) { @@ -1019,59 +999,35 @@ injection.injectEventPluginsByName({ }); var instanceCache = {}, instanceProps = {}; -function uncacheFiberNode(tag) { - delete instanceCache[tag]; - delete instanceProps[tag]; -} function getInstanceFromTag(tag) { return instanceCache[tag] || null; } -var ReactNativeComponentTree = { - precacheFiberNode: function(hostInst, tag) { - instanceCache[tag] = hostInst; - }, - uncacheFiberNode: uncacheFiberNode, - getClosestInstanceFromNode: getInstanceFromTag, - getInstanceFromNode: getInstanceFromTag, - getNodeFromInstance: function(inst) { - var tag = inst.stateNode._nativeTag; - void 0 === tag && (tag = inst.stateNode.canonical._nativeTag); - invariant(tag, "All native instances should have a tag."); - return tag; - }, - getFiberCurrentPropsFromNode: function(stateNode) { - return instanceProps[stateNode._nativeTag] || null; - }, - updateFiberProps: function(tag, props) { - instanceProps[tag] = props; - } - }, - restoreTarget = null, +var restoreTarget = null, restoreQueue = null; function restoreStateOfTarget(target) { if ((target = getInstanceFromNode(target))) { invariant( - null, - "Fiber needs to be injected to handle a fiber target for controlled events. This error is likely caused by a bug in React. Please file an issue." + !1, + "setRestoreImplementation() needs to be called to handle a target for controlled events. This error is likely caused by a bug in React. Please file an issue." ); var props = getFiberCurrentPropsFromNode(target.stateNode); - null.restoreControlledState(target.stateNode, target.type, props); + null(target.stateNode, target.type, props); } } -function _batchedUpdates(fn, bookkeeping) { +function _batchedUpdatesImpl(fn, bookkeeping) { return fn(bookkeeping); } -function _flushInteractiveUpdates() {} +function _flushInteractiveUpdatesImpl() {} var isBatching = !1; function batchedUpdates(fn, bookkeeping) { if (isBatching) return fn(bookkeeping); isBatching = !0; try { - return _batchedUpdates(fn, bookkeeping); + return _batchedUpdatesImpl(fn, bookkeeping); } finally { if (((isBatching = !1), null !== restoreTarget || null !== restoreQueue)) if ( - (_flushInteractiveUpdates(), + (_flushInteractiveUpdatesImpl(), restoreTarget && ((bookkeeping = restoreTarget), (fn = restoreQueue), @@ -1104,13 +1060,19 @@ function _receiveRootNodeIDEvent(rootNodeID, topLevelType, nativeEventParam) { null !== events && (eventQueue = accumulateInto(eventQueue, events)); events = eventQueue; eventQueue = null; - events && + if ( + events && (forEachAccumulated(events, executeDispatchesAndReleaseTopLevel), invariant( !eventQueue, "processEventQueue(): Additional events were enqueued while processing an event queue. Support for this has not yet been implemented." ), - ReactErrorUtils.rethrowCaughtError()); + hasRethrowError) + ) + throw ((events = rethrowError), + (hasRethrowError = !1), + (rethrowError = null), + events); }); } RCTEventEmitter.register({ @@ -1153,10 +1115,16 @@ RCTEventEmitter.register({ } } }); -getFiberCurrentPropsFromNode = - ReactNativeComponentTree.getFiberCurrentPropsFromNode; -getInstanceFromNode = ReactNativeComponentTree.getInstanceFromNode; -getNodeFromInstance = ReactNativeComponentTree.getNodeFromInstance; +getFiberCurrentPropsFromNode = function(stateNode) { + return instanceProps[stateNode._nativeTag] || null; +}; +getInstanceFromNode = getInstanceFromTag; +getNodeFromInstance = function(inst) { + var tag = inst.stateNode._nativeTag; + void 0 === tag && (tag = inst.stateNode.canonical._nativeTag); + invariant(tag, "All native instances should have a tag."); + return tag; +}; ResponderEventPlugin.injection.injectGlobalResponderHandler({ onChange: function(from, to, blockNativeResponder) { null !== to @@ -1179,8 +1147,7 @@ var ReactSharedInternals = REACT_PLACEHOLDER_TYPE = hasSymbol ? Symbol.for("react.placeholder") : 60113, MAYBE_ITERATOR_SYMBOL = "function" === typeof Symbol && Symbol.iterator; function getIteratorFn(maybeIterable) { - if (null === maybeIterable || "undefined" === typeof maybeIterable) - return null; + if (null === maybeIterable || "object" !== typeof maybeIterable) return null; maybeIterable = (MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL]) || maybeIterable["@@iterator"]; @@ -1204,7 +1171,7 @@ function getComponentName(type) { case REACT_PLACEHOLDER_TYPE: return "Placeholder"; } - if ("object" === typeof type) + if ("object" === typeof type) { switch (type.$$typeof) { case REACT_CONTEXT_TYPE: return "Context.Consumer"; @@ -1217,6 +1184,12 @@ function getComponentName(type) { "" !== type ? "ForwardRef(" + type + ")" : "ForwardRef" ); } + if ( + "function" === typeof type.then && + (type = 1 === type._reactStatus ? type._reactResult : null) + ) + return getComponentName(type); + } return null; } function isFiberMountedImpl(fiber) { @@ -1227,7 +1200,7 @@ function isFiberMountedImpl(fiber) { for (; node.return; ) if (((node = node.return), 0 !== (node.effectTag & 2))) return 1; } - return 3 === node.tag ? 2 : 3; + return 5 === node.tag ? 2 : 3; } function assertIsMounted(fiber) { invariant( @@ -1303,14 +1276,14 @@ function findCurrentFiberUsingSlowPath(fiber) { "Return fibers should always be each others' alternates. This error is likely caused by a bug in React. Please file an issue." ); } - invariant(3 === a.tag, "Unable to find node on an unmounted component."); + invariant(5 === a.tag, "Unable to find node on an unmounted component."); return a.stateNode.current === a ? fiber : alternate; } function findCurrentHostFiber(parent) { parent = findCurrentFiberUsingSlowPath(parent); if (!parent) return null; for (var node = parent; ; ) { - if (5 === node.tag || 6 === node.tag) return node; + if (7 === node.tag || 8 === node.tag) return node; if (node.child) (node.child.return = node), (node = node.child); else { if (node === parent) break; @@ -1324,25 +1297,6 @@ function findCurrentHostFiber(parent) { } return null; } -function findCurrentHostFiberWithNoPortals(parent) { - parent = findCurrentFiberUsingSlowPath(parent); - if (!parent) return null; - for (var node = parent; ; ) { - if (5 === node.tag || 6 === node.tag) return node; - if (node.child && 4 !== node.tag) - (node.child.return = node), (node = node.child); - else { - if (node === parent) break; - for (; !node.sibling; ) { - if (!node.return || node.return === parent) return null; - node = node.return; - } - node.sibling.return = node.return; - node = node.sibling; - } - } - return null; -} var emptyObject = {}, removedKeys = null, removedKeyCount = 0; @@ -1361,23 +1315,23 @@ function restoreDeletedValuesInNestedArray( else if (node && 0 < removedKeyCount) for (i in removedKeys) if (removedKeys[i]) { - var _nextProp = node[i]; - if (void 0 !== _nextProp) { + var nextProp = node[i]; + if (void 0 !== nextProp) { var attributeConfig = validAttributes[i]; if (attributeConfig) { - "function" === typeof _nextProp && (_nextProp = !0); - "undefined" === typeof _nextProp && (_nextProp = null); + "function" === typeof nextProp && (nextProp = !0); + "undefined" === typeof nextProp && (nextProp = null); if ("object" !== typeof attributeConfig) - updatePayload[i] = _nextProp; + updatePayload[i] = nextProp; else if ( "function" === typeof attributeConfig.diff || "function" === typeof attributeConfig.process ) - (_nextProp = + (nextProp = "function" === typeof attributeConfig.process - ? attributeConfig.process(_nextProp) - : _nextProp), - (updatePayload[i] = _nextProp); + ? attributeConfig.process(nextProp) + : nextProp), + (updatePayload[i] = nextProp); removedKeys[i] = !1; removedKeyCount--; } @@ -1561,18 +1515,13 @@ function diffProperties(updatePayload, prevProps, nextProps, validAttributes) { ))))); return updatePayload; } -function mountSafeCallback(context, callback) { +function mountSafeCallback_NOT_REALLY_SAFE(context, callback) { return function() { - if (callback) { - if ("boolean" === typeof context.__isMounted) { - if (!context.__isMounted) return; - } else if ( - "function" === typeof context.isMounted && - !context.isMounted() - ) - return; + if ( + callback && + ("boolean" !== typeof context.__isMounted || context.__isMounted) + ) return callback.apply(context, arguments); - } }; } var ReactNativeFiberHostComponent = (function() { @@ -1590,14 +1539,17 @@ var ReactNativeFiberHostComponent = (function() { TextInputState.focusTextInput(this._nativeTag); }; ReactNativeFiberHostComponent.prototype.measure = function(callback) { - UIManager.measure(this._nativeTag, mountSafeCallback(this, callback)); + UIManager.measure( + this._nativeTag, + mountSafeCallback_NOT_REALLY_SAFE(this, callback) + ); }; ReactNativeFiberHostComponent.prototype.measureInWindow = function( callback ) { UIManager.measureInWindow( this._nativeTag, - mountSafeCallback(this, callback) + mountSafeCallback_NOT_REALLY_SAFE(this, callback) ); }; ReactNativeFiberHostComponent.prototype.measureLayout = function( @@ -1608,8 +1560,8 @@ var ReactNativeFiberHostComponent = (function() { UIManager.measureLayout( this._nativeTag, relativeToNativeNode, - mountSafeCallback(this, onFail), - mountSafeCallback(this, onSuccess) + mountSafeCallback_NOT_REALLY_SAFE(this, onFail), + mountSafeCallback_NOT_REALLY_SAFE(this, onSuccess) ); }; ReactNativeFiberHostComponent.prototype.setNativeProps = function( @@ -1667,10 +1619,14 @@ function allocateTag() { return tag; } function recursivelyUncacheFiberNode(node) { - "number" === typeof node - ? uncacheFiberNode(node) - : (uncacheFiberNode(node._nativeTag), - node._children.forEach(recursivelyUncacheFiberNode)); + if ("number" === typeof node) + delete instanceCache[node], delete instanceProps[node]; + else { + var tag = node._nativeTag; + delete instanceCache[tag]; + delete instanceProps[tag]; + node._children.forEach(recursivelyUncacheFiberNode); + } } function finalizeInitialChildren(parentInstance) { if (0 === parentInstance._children.length) return !1; @@ -1680,33 +1636,35 @@ function finalizeInitialChildren(parentInstance) { UIManager.setChildren(parentInstance._nativeTag, nativeTags); return !1; } +var BEFORE_SLASH_RE = /^(.*)[\\\/]/; function getStackByFiberInDevAndProd(workInProgress) { var info = ""; do { a: switch (workInProgress.tag) { + case 4: case 0: case 1: case 2: - case 5: - case 11: + case 3: + case 7: + case 10: var owner = workInProgress._debugOwner, - source = workInProgress._debugSource; - var JSCompiler_inline_result = getComponentName(workInProgress.type); - var ownerName = null; - owner && (ownerName = getComponentName(owner.type)); - owner = source; - JSCompiler_inline_result = - "\n in " + - (JSCompiler_inline_result || "Unknown") + - (owner - ? " (at " + - owner.fileName.replace(/^.*[\\\/]/, "") + + source = workInProgress._debugSource, + name = getComponentName(workInProgress.type); + var JSCompiler_inline_result = null; + owner && (JSCompiler_inline_result = getComponentName(owner.type)); + owner = name; + name = ""; + source + ? (name = + " (at " + + source.fileName.replace(BEFORE_SLASH_RE, "") + ":" + - owner.lineNumber + - ")" - : ownerName - ? " (created by " + ownerName + ")" - : ""); + source.lineNumber + + ")") + : JSCompiler_inline_result && + (name = " (created by " + JSCompiler_inline_result + ")"); + JSCompiler_inline_result = "\n in " + (owner || "Unknown") + name; break a; default: JSCompiler_inline_result = ""; @@ -1732,11 +1690,6 @@ var emptyContextObject = {}, contextStackCursor = { current: emptyContextObject }, didPerformWorkStackCursor = { current: !1 }, previousContext = emptyContextObject; -function getUnmaskedContext(workInProgress) { - return isContextProvider(workInProgress) - ? previousContext - : contextStackCursor.current; -} function getMaskedContext(workInProgress, unmaskedContext) { var contextTypes = workInProgress.type.contextTypes; if (!contextTypes) return emptyContextObject; @@ -1755,12 +1708,13 @@ function getMaskedContext(workInProgress, unmaskedContext) { (workInProgress.__reactInternalMemoizedMaskedChildContext = context)); return context; } -function isContextProvider(fiber) { - return 2 === fiber.tag && null != fiber.type.childContextTypes; +function isContextProvider(type) { + type = type.childContextTypes; + return null !== type && void 0 !== type; } -function popContextProvider(fiber) { - isContextProvider(fiber) && - (pop(didPerformWorkStackCursor, fiber), pop(contextStackCursor, fiber)); +function popContext(fiber) { + pop(didPerformWorkStackCursor, fiber); + pop(contextStackCursor, fiber); } function popTopLevelContextObject(fiber) { pop(didPerformWorkStackCursor, fiber); @@ -1774,23 +1728,21 @@ function pushTopLevelContextObject(fiber, context, didChange) { push(contextStackCursor, context, fiber); push(didPerformWorkStackCursor, didChange, fiber); } -function processChildContext(fiber, parentContext) { +function processChildContext(fiber, type, parentContext) { var instance = fiber.stateNode; - fiber = fiber.type; - var childContextTypes = fiber.childContextTypes; + fiber = type.childContextTypes; if ("function" !== typeof instance.getChildContext) return parentContext; instance = instance.getChildContext(); for (var contextKey in instance) invariant( - contextKey in childContextTypes, + contextKey in fiber, '%s.getChildContext(): key "%s" is not defined in childContextTypes.', - getComponentName(fiber) || "Unknown", + getComponentName(type) || "Unknown", contextKey ); return Object.assign({}, parentContext, instance); } function pushContextProvider(workInProgress) { - if (!isContextProvider(workInProgress)) return !1; var instance = workInProgress.stateNode; instance = (instance && instance.__reactInternalMemoizedMergedChildContext) || @@ -1804,19 +1756,19 @@ function pushContextProvider(workInProgress) { ); return !0; } -function invalidateContextProvider(workInProgress, didChange) { +function invalidateContextProvider(workInProgress, type, didChange) { var instance = workInProgress.stateNode; invariant( instance, "Expected to have an instance by this point. This error is likely caused by a bug in React. Please file an issue." ); - if (didChange) { - var mergedContext = processChildContext(workInProgress, previousContext); - instance.__reactInternalMemoizedMergedChildContext = mergedContext; - pop(didPerformWorkStackCursor, workInProgress); - pop(contextStackCursor, workInProgress); - push(contextStackCursor, mergedContext, workInProgress); - } else pop(didPerformWorkStackCursor, workInProgress); + didChange + ? ((type = processChildContext(workInProgress, type, previousContext)), + (instance.__reactInternalMemoizedMergedChildContext = type), + pop(didPerformWorkStackCursor, workInProgress), + pop(contextStackCursor, workInProgress), + push(contextStackCursor, type, workInProgress)) + : pop(didPerformWorkStackCursor, workInProgress); push(didPerformWorkStackCursor, didChange, workInProgress); } var onCommitFiberRoot = null, @@ -1857,6 +1809,10 @@ function FiberNode(tag, pendingProps, key, mode) { this.childExpirationTime = this.expirationTime = 0; this.alternate = null; } +function shouldConstruct(Component) { + Component = Component.prototype; + return !(!Component || !Component.isReactComponent); +} function createWorkInProgress(current, pendingProps, expirationTime) { var workInProgress = current.alternate; null === workInProgress @@ -1894,11 +1850,11 @@ function createFiberFromElement(element, mode, expirationTime) { var type = element.type, key = element.key; element = element.props; - if ("function" === typeof type) - var fiberTag = type.prototype && type.prototype.isReactComponent ? 2 : 0; - else if ("string" === typeof type) fiberTag = 5; + var fiberTag = void 0; + if ("function" === typeof type) fiberTag = shouldConstruct(type) ? 2 : 4; + else if ("string" === typeof type) fiberTag = 7; else - switch (type) { + a: switch (type) { case REACT_FRAGMENT_TYPE: return createFiberFromFragment( element.children, @@ -1907,11 +1863,11 @@ function createFiberFromElement(element, mode, expirationTime) { key ); case REACT_ASYNC_MODE_TYPE: - fiberTag = 11; + fiberTag = 10; mode |= 3; break; case REACT_STRICT_MODE_TYPE: - fiberTag = 11; + fiberTag = 10; mode |= 2; break; case REACT_PROFILER_TYPE: @@ -1925,29 +1881,29 @@ function createFiberFromElement(element, mode, expirationTime) { fiberTag = 16; break; default: - a: { - switch ( - "object" === typeof type && null !== type ? type.$$typeof : null - ) { + if ("object" === typeof type && null !== type) + switch (type.$$typeof) { case REACT_PROVIDER_TYPE: - fiberTag = 13; - break a; - case REACT_CONTEXT_TYPE: fiberTag = 12; break a; + case REACT_CONTEXT_TYPE: + fiberTag = 11; + break a; case REACT_FORWARD_REF_TYPE: - fiberTag = 14; + fiberTag = 13; break a; default: - invariant( - !1, - "Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s", - null == type ? type : typeof type, - "" - ); + if ("function" === typeof type.then) { + fiberTag = 4; + break a; + } } - fiberTag = void 0; - } + invariant( + !1, + "Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s", + null == type ? type : typeof type, + "" + ); } mode = new FiberNode(fiberTag, element, key, mode); mode.type = type; @@ -1955,18 +1911,18 @@ function createFiberFromElement(element, mode, expirationTime) { return mode; } function createFiberFromFragment(elements, mode, expirationTime, key) { - elements = new FiberNode(10, elements, key, mode); + elements = new FiberNode(9, elements, key, mode); elements.expirationTime = expirationTime; return elements; } function createFiberFromText(content, mode, expirationTime) { - content = new FiberNode(6, content, null, mode); + content = new FiberNode(8, content, null, mode); content.expirationTime = expirationTime; return content; } function createFiberFromPortal(portal, mode, expirationTime) { mode = new FiberNode( - 4, + 6, null !== portal.children ? portal.children : [], portal.key, mode @@ -1979,31 +1935,6 @@ function createFiberFromPortal(portal, mode, expirationTime) { }; return mode; } -function createFiberRoot(containerInfo, isAsync, hydrate) { - isAsync = new FiberNode(3, null, null, isAsync ? 3 : 0); - containerInfo = { - current: isAsync, - containerInfo: containerInfo, - pendingChildren: null, - earliestPendingTime: 0, - latestPendingTime: 0, - earliestSuspendedTime: 0, - latestSuspendedTime: 0, - latestPingedTime: 0, - didError: !1, - pendingCommitExpirationTime: 0, - finishedWork: null, - timeoutHandle: -1, - context: null, - pendingContext: null, - hydrate: hydrate, - nextExpirationTimeToWorkOn: 0, - expirationTime: 0, - firstBatch: null, - nextScheduledRoot: null - }; - return (isAsync.stateNode = containerInfo); -} function markPendingPriorityLevel(root, expirationTime) { root.didError = !1; var earliestPendingTime = root.earliestPendingTime; @@ -2241,41 +2172,32 @@ function processUpdateQueue( workInProgress.expirationTime = newExpirationTime; workInProgress.memoizedState = resultState; } -function callCallback(callback, context) { - invariant( - "function" === typeof callback, - "Invalid argument passed as callback. Expected a function. Instead received: %s", - callback - ); - callback.call(context); -} function commitUpdateQueue(finishedWork, finishedQueue, instance) { null !== finishedQueue.firstCapturedUpdate && (null !== finishedQueue.lastUpdate && ((finishedQueue.lastUpdate.next = finishedQueue.firstCapturedUpdate), (finishedQueue.lastUpdate = finishedQueue.lastCapturedUpdate)), (finishedQueue.firstCapturedUpdate = finishedQueue.lastCapturedUpdate = null)); - finishedWork = finishedQueue.firstEffect; - for ( - finishedQueue.firstEffect = finishedQueue.lastEffect = null; - null !== finishedWork; - - ) { - var _callback3 = finishedWork.callback; - null !== _callback3 && - ((finishedWork.callback = null), callCallback(_callback3, instance)); - finishedWork = finishedWork.nextEffect; + commitUpdateEffects(finishedQueue.firstEffect, instance); + finishedQueue.firstEffect = finishedQueue.lastEffect = null; + commitUpdateEffects(finishedQueue.firstCapturedEffect, instance); + finishedQueue.firstCapturedEffect = finishedQueue.lastCapturedEffect = null; +} +function commitUpdateEffects(effect, instance) { + for (; null !== effect; ) { + var _callback3 = effect.callback; + if (null !== _callback3) { + effect.callback = null; + var context = instance; + invariant( + "function" === typeof _callback3, + "Invalid argument passed as callback. Expected a function. Instead received: %s", + _callback3 + ); + _callback3.call(context); + } + effect = effect.nextEffect; } - finishedWork = finishedQueue.firstCapturedEffect; - for ( - finishedQueue.firstCapturedEffect = finishedQueue.lastCapturedEffect = null; - null !== finishedWork; - - ) - (finishedQueue = finishedWork.callback), - null !== finishedQueue && - ((finishedWork.callback = null), callCallback(finishedQueue, instance)), - (finishedWork = finishedWork.nextEffect); } function createCapturedValue(value, source) { return { @@ -2285,125 +2207,23 @@ function createCapturedValue(value, source) { }; } var valueCursor = { current: null }, - changedBitsCursor = { current: 0 }, currentlyRenderingFiber = null, lastContextDependency = null, lastContextWithAllBitsObserved = null; -function pushProvider(providerFiber) { +function pushProvider(providerFiber, nextValue) { var context = providerFiber.type._context; - push(changedBitsCursor, context._changedBits, providerFiber); push(valueCursor, context._currentValue, providerFiber); - context._currentValue = providerFiber.pendingProps.value; - context._changedBits = providerFiber.stateNode; + context._currentValue = nextValue; } function popProvider(providerFiber) { - var changedBits = changedBitsCursor.current, - currentValue = valueCursor.current; + var currentValue = valueCursor.current; pop(valueCursor, providerFiber); - pop(changedBitsCursor, providerFiber); - providerFiber = providerFiber.type._context; - providerFiber._currentValue = currentValue; - providerFiber._changedBits = changedBits; + providerFiber.type._context._currentValue = currentValue; } -function propagateContextChange( - workInProgress, - context, - changedBits, - renderExpirationTime -) { - var fiber = workInProgress.child; - null !== fiber && (fiber.return = workInProgress); - for (; null !== fiber; ) { - var dependency = fiber.firstContextDependency; - if (null !== dependency) { - do { - if ( - dependency.context === context && - 0 !== (dependency.observedBits & changedBits) - ) { - if ( - 0 === fiber.expirationTime || - fiber.expirationTime > renderExpirationTime - ) - fiber.expirationTime = renderExpirationTime; - var nextFiber = fiber.alternate; - null !== nextFiber && - (0 === nextFiber.expirationTime || - nextFiber.expirationTime > renderExpirationTime) && - (nextFiber.expirationTime = renderExpirationTime); - for (var node = fiber.return; null !== node; ) { - nextFiber = node.alternate; - if ( - 0 === node.childExpirationTime || - node.childExpirationTime > renderExpirationTime - ) - (node.childExpirationTime = renderExpirationTime), - null !== nextFiber && - (0 === nextFiber.childExpirationTime || - nextFiber.childExpirationTime > renderExpirationTime) && - (nextFiber.childExpirationTime = renderExpirationTime); - else if ( - null !== nextFiber && - (0 === nextFiber.childExpirationTime || - nextFiber.childExpirationTime > renderExpirationTime) - ) - nextFiber.childExpirationTime = renderExpirationTime; - else break; - node = node.return; - } - nextFiber = null; - } else nextFiber = fiber.child; - dependency = dependency.next; - } while (null !== dependency); - } else - nextFiber = - 13 === fiber.tag - ? fiber.type === workInProgress.type - ? null - : fiber.child - : fiber.child; - if (null !== nextFiber) nextFiber.return = fiber; - else - for (nextFiber = fiber; null !== nextFiber; ) { - if (nextFiber === workInProgress) { - nextFiber = null; - break; - } - fiber = nextFiber.sibling; - if (null !== fiber) { - fiber.return = nextFiber.return; - nextFiber = fiber; - break; - } - nextFiber = nextFiber.return; - } - fiber = nextFiber; - } -} -function prepareToReadContext(workInProgress, renderExpirationTime) { +function prepareToReadContext(workInProgress) { currentlyRenderingFiber = workInProgress; lastContextWithAllBitsObserved = lastContextDependency = null; - var firstContextDependency = workInProgress.firstContextDependency; - if (null !== firstContextDependency) { - workInProgress.firstContextDependency = null; - var hasPendingContext = !1; - do { - var _context = firstContextDependency.context, - changedBits = _context._changedBits; - 0 !== changedBits && - (propagateContextChange( - workInProgress, - _context, - changedBits, - renderExpirationTime - ), - 0 !== (changedBits & firstContextDependency.observedBits) && - (hasPendingContext = !0)); - firstContextDependency = firstContextDependency.next; - } while (null !== firstContextDependency); - return hasPendingContext; - } - return !1; + workInProgress.firstContextDependency = null; } function readContext(context, observedBits) { if ( @@ -2496,20 +2316,21 @@ function shallowEqual(objA, objB) { var emptyRefsObject = new React.Component().refs; function applyDerivedStateFromProps( workInProgress, + ctor, getDerivedStateFromProps, nextProps ) { - var prevState = workInProgress.memoizedState; - getDerivedStateFromProps = getDerivedStateFromProps(nextProps, prevState); - prevState = + ctor = workInProgress.memoizedState; + getDerivedStateFromProps = getDerivedStateFromProps(nextProps, ctor); + getDerivedStateFromProps = null === getDerivedStateFromProps || void 0 === getDerivedStateFromProps - ? prevState - : Object.assign({}, prevState, getDerivedStateFromProps); - workInProgress.memoizedState = prevState; - getDerivedStateFromProps = workInProgress.updateQueue; - null !== getDerivedStateFromProps && + ? ctor + : Object.assign({}, ctor, getDerivedStateFromProps); + workInProgress.memoizedState = getDerivedStateFromProps; + nextProps = workInProgress.updateQueue; + null !== nextProps && 0 === workInProgress.expirationTime && - (getDerivedStateFromProps.baseState = prevState); + (nextProps.baseState = getDerivedStateFromProps); } var classComponentUpdater = { isMounted: function(component) { @@ -2551,17 +2372,21 @@ var classComponentUpdater = { }; function checkShouldComponentUpdate( workInProgress, + ctor, oldProps, newProps, oldState, newState, nextLegacyContext ) { - var instance = workInProgress.stateNode; - workInProgress = workInProgress.type; - return "function" === typeof instance.shouldComponentUpdate - ? instance.shouldComponentUpdate(newProps, newState, nextLegacyContext) - : workInProgress.prototype && workInProgress.prototype.isPureReactComponent + workInProgress = workInProgress.stateNode; + return "function" === typeof workInProgress.shouldComponentUpdate + ? workInProgress.shouldComponentUpdate( + newProps, + newState, + nextLegacyContext + ) + : ctor.prototype && ctor.prototype.isPureReactComponent ? !shallowEqual(oldProps, newProps) || !shallowEqual(oldState, newState) : !0; } @@ -2579,12 +2404,17 @@ function callComponentWillReceiveProps( instance.state !== workInProgress && classComponentUpdater.enqueueReplaceState(instance, instance.state, null); } -function mountClassInstance(workInProgress, renderExpirationTime) { - var ctor = workInProgress.type, - instance = workInProgress.stateNode, - props = workInProgress.pendingProps, - unmaskedContext = getUnmaskedContext(workInProgress); - instance.props = props; +function mountClassInstance( + workInProgress, + ctor, + newProps, + renderExpirationTime +) { + var instance = workInProgress.stateNode, + unmaskedContext = isContextProvider(ctor) + ? previousContext + : contextStackCursor.current; + instance.props = newProps; instance.state = workInProgress.memoizedState; instance.refs = emptyRefsObject; instance.context = getMaskedContext(workInProgress, unmaskedContext); @@ -2593,14 +2423,19 @@ function mountClassInstance(workInProgress, renderExpirationTime) { (processUpdateQueue( workInProgress, unmaskedContext, - props, + newProps, instance, renderExpirationTime ), (instance.state = workInProgress.memoizedState)); unmaskedContext = ctor.getDerivedStateFromProps; "function" === typeof unmaskedContext && - (applyDerivedStateFromProps(workInProgress, unmaskedContext, props), + (applyDerivedStateFromProps( + workInProgress, + ctor, + unmaskedContext, + newProps + ), (instance.state = workInProgress.memoizedState)); "function" === typeof ctor.getDerivedStateFromProps || "function" === typeof instance.getSnapshotBeforeUpdate || @@ -2618,7 +2453,7 @@ function mountClassInstance(workInProgress, renderExpirationTime) { (processUpdateQueue( workInProgress, unmaskedContext, - props, + newProps, instance, renderExpirationTime ), @@ -2639,7 +2474,7 @@ function coerceRef(returnFiber, current$$1, element) { var inst = void 0; element && (invariant( - 2 === element.tag, + 2 === element.tag || 3 === element.tag, "Stateless function components cannot have refs." ), (inst = element.stateNode)); @@ -2666,7 +2501,7 @@ function coerceRef(returnFiber, current$$1, element) { } invariant( "string" === typeof returnFiber, - "Expected ref to be a function or a string." + "Expected ref to be a function, a string, an object returned by React.createRef(), or null." ); invariant( element._owner, @@ -2746,7 +2581,7 @@ function ChildReconciler(shouldTrackSideEffects) { textContent, expirationTime ) { - if (null === current$$1 || 6 !== current$$1.tag) + if (null === current$$1 || 8 !== current$$1.tag) return ( (current$$1 = createFiberFromText( textContent, @@ -2780,7 +2615,7 @@ function ChildReconciler(shouldTrackSideEffects) { function updatePortal(returnFiber, current$$1, portal, expirationTime) { if ( null === current$$1 || - 4 !== current$$1.tag || + 6 !== current$$1.tag || current$$1.stateNode.containerInfo !== portal.containerInfo || current$$1.stateNode.implementation !== portal.implementation ) @@ -2804,7 +2639,7 @@ function ChildReconciler(shouldTrackSideEffects) { expirationTime, key ) { - if (null === current$$1 || 10 !== current$$1.tag) + if (null === current$$1 || 9 !== current$$1.tag) return ( (current$$1 = createFiberFromFragment( fragment, @@ -3179,7 +3014,7 @@ function ChildReconciler(shouldTrackSideEffects) { ) { if (isUnkeyedTopLevelFragment.key === isObject) if ( - 10 === isUnkeyedTopLevelFragment.tag + 9 === isUnkeyedTopLevelFragment.tag ? newChild.type === REACT_FRAGMENT_TYPE : isUnkeyedTopLevelFragment.type === newChild.type ) { @@ -3244,7 +3079,7 @@ function ChildReconciler(shouldTrackSideEffects) { ) { if (currentFirstChild.key === isUnkeyedTopLevelFragment) if ( - 4 === currentFirstChild.tag && + 6 === currentFirstChild.tag && currentFirstChild.stateNode.containerInfo === newChild.containerInfo && currentFirstChild.stateNode.implementation === @@ -3282,7 +3117,7 @@ function ChildReconciler(shouldTrackSideEffects) { if ("string" === typeof newChild || "number" === typeof newChild) return ( (newChild = "" + newChild), - null !== currentFirstChild && 6 === currentFirstChild.tag + null !== currentFirstChild && 8 === currentFirstChild.tag ? (deleteRemainingChildren(returnFiber, currentFirstChild.sibling), (currentFirstChild = useFiber( currentFirstChild, @@ -3319,7 +3154,8 @@ function ChildReconciler(shouldTrackSideEffects) { if ("undefined" === typeof newChild && !isUnkeyedTopLevelFragment) switch (returnFiber.tag) { case 2: - case 1: + case 3: + case 0: (expirationTime = returnFiber.type), invariant( !1, @@ -3337,12 +3173,12 @@ var reconcileChildFibers = ChildReconciler(!0), isHydrating = !1; function tryHydrate(fiber, nextInstance) { switch (fiber.tag) { - case 5: + case 7: return ( (nextInstance = shim$1(nextInstance, fiber.type, fiber.pendingProps)), null !== nextInstance ? ((fiber.stateNode = nextInstance), !0) : !1 ); - case 6: + case 8: return ( (nextInstance = shim$1(nextInstance, fiber.pendingProps)), null !== nextInstance ? ((fiber.stateNode = nextInstance), !0) : !1 @@ -3365,7 +3201,7 @@ function tryToClaimNextHydratableInstance(fiber$jscomp$0) { return; } var returnFiber = hydrationParentFiber, - fiber = new FiberNode(5, null, null, 0); + fiber = new FiberNode(7, null, null, 0); fiber.type = "DELETED"; fiber.stateNode = firstAttemptedInstance; fiber.return = returnFiber; @@ -3383,6 +3219,38 @@ function tryToClaimNextHydratableInstance(fiber$jscomp$0) { (hydrationParentFiber = fiber$jscomp$0); } } +function readLazyComponentType(thenable) { + switch (thenable._reactStatus) { + case 1: + return thenable._reactResult; + case 2: + throw thenable._reactResult; + case 0: + throw thenable; + default: + throw ((thenable._reactStatus = 0), + thenable.then( + function(resolvedValue) { + if (0 === thenable._reactStatus) { + thenable._reactStatus = 1; + if ("object" === typeof resolvedValue && null !== resolvedValue) { + var defaultExport = resolvedValue.default; + resolvedValue = + void 0 !== defaultExport && null !== defaultExport + ? defaultExport + : resolvedValue; + } + thenable._reactResult = resolvedValue; + } + }, + function(error) { + 0 === thenable._reactStatus && + ((thenable._reactStatus = 2), (thenable._reactResult = error)); + } + ), + thenable); + } +} var ReactCurrentOwner$3 = ReactSharedInternals.ReactCurrentOwner; function reconcileChildren( current$$1, @@ -3405,6 +3273,30 @@ function reconcileChildren( renderExpirationTime ); } +function updateForwardRef( + current$$1, + workInProgress, + type, + nextProps, + renderExpirationTime +) { + type = type.render; + var ref = workInProgress.ref; + if ( + !didPerformWorkStackCursor.current && + workInProgress.memoizedProps === nextProps && + ref === (null !== current$$1 ? current$$1.ref : null) + ) + return bailoutOnAlreadyFinishedWork( + current$$1, + workInProgress, + renderExpirationTime + ); + type = type(nextProps, ref); + reconcileChildren(current$$1, workInProgress, type, renderExpirationTime); + workInProgress.memoizedProps = nextProps; + return workInProgress.child; +} function markRef(current$$1, workInProgress) { var ref = workInProgress.ref; if ( @@ -3413,9 +3305,268 @@ function markRef(current$$1, workInProgress) { ) workInProgress.effectTag |= 128; } +function updateFunctionalComponent( + current$$1, + workInProgress, + Component, + nextProps, + renderExpirationTime +) { + var unmaskedContext = isContextProvider(Component) + ? previousContext + : contextStackCursor.current; + unmaskedContext = getMaskedContext(workInProgress, unmaskedContext); + prepareToReadContext(workInProgress, renderExpirationTime); + Component = Component(nextProps, unmaskedContext); + workInProgress.effectTag |= 1; + reconcileChildren( + current$$1, + workInProgress, + Component, + renderExpirationTime + ); + workInProgress.memoizedProps = nextProps; + return workInProgress.child; +} +function updateClassComponent( + current$$1, + workInProgress, + Component, + nextProps, + renderExpirationTime +) { + if (isContextProvider(Component)) { + var hasContext = !0; + pushContextProvider(workInProgress); + } else hasContext = !1; + prepareToReadContext(workInProgress, renderExpirationTime); + if (null === current$$1) + if (null === workInProgress.stateNode) { + var unmaskedContext = isContextProvider(Component) + ? previousContext + : contextStackCursor.current, + contextTypes = Component.contextTypes, + isContextConsumer = null !== contextTypes && void 0 !== contextTypes; + contextTypes = isContextConsumer + ? getMaskedContext(workInProgress, unmaskedContext) + : emptyContextObject; + var instance = new Component(nextProps, contextTypes); + workInProgress.memoizedState = + null !== instance.state && void 0 !== instance.state + ? instance.state + : null; + instance.updater = classComponentUpdater; + workInProgress.stateNode = instance; + instance._reactInternalFiber = workInProgress; + isContextConsumer && + ((isContextConsumer = workInProgress.stateNode), + (isContextConsumer.__reactInternalMemoizedUnmaskedChildContext = unmaskedContext), + (isContextConsumer.__reactInternalMemoizedMaskedChildContext = contextTypes)); + mountClassInstance( + workInProgress, + Component, + nextProps, + renderExpirationTime + ); + nextProps = !0; + } else { + unmaskedContext = workInProgress.stateNode; + contextTypes = workInProgress.memoizedProps; + unmaskedContext.props = contextTypes; + var oldContext = unmaskedContext.context; + isContextConsumer = isContextProvider(Component) + ? previousContext + : contextStackCursor.current; + isContextConsumer = getMaskedContext(workInProgress, isContextConsumer); + var getDerivedStateFromProps = Component.getDerivedStateFromProps; + (instance = + "function" === typeof getDerivedStateFromProps || + "function" === typeof unmaskedContext.getSnapshotBeforeUpdate) || + ("function" !== + typeof unmaskedContext.UNSAFE_componentWillReceiveProps && + "function" !== typeof unmaskedContext.componentWillReceiveProps) || + ((contextTypes !== nextProps || oldContext !== isContextConsumer) && + callComponentWillReceiveProps( + workInProgress, + unmaskedContext, + nextProps, + isContextConsumer + )); + hasForceUpdate = !1; + var oldState = workInProgress.memoizedState; + oldContext = unmaskedContext.state = oldState; + var updateQueue = workInProgress.updateQueue; + null !== updateQueue && + (processUpdateQueue( + workInProgress, + updateQueue, + nextProps, + unmaskedContext, + renderExpirationTime + ), + (oldContext = workInProgress.memoizedState)); + contextTypes !== nextProps || + oldState !== oldContext || + didPerformWorkStackCursor.current || + hasForceUpdate + ? ("function" === typeof getDerivedStateFromProps && + (applyDerivedStateFromProps( + workInProgress, + Component, + getDerivedStateFromProps, + nextProps + ), + (oldContext = workInProgress.memoizedState)), + (contextTypes = + hasForceUpdate || + checkShouldComponentUpdate( + workInProgress, + Component, + contextTypes, + nextProps, + oldState, + oldContext, + isContextConsumer + )) + ? (instance || + ("function" !== + typeof unmaskedContext.UNSAFE_componentWillMount && + "function" !== typeof unmaskedContext.componentWillMount) || + ("function" === typeof unmaskedContext.componentWillMount && + unmaskedContext.componentWillMount(), + "function" === + typeof unmaskedContext.UNSAFE_componentWillMount && + unmaskedContext.UNSAFE_componentWillMount()), + "function" === typeof unmaskedContext.componentDidMount && + (workInProgress.effectTag |= 4)) + : ("function" === typeof unmaskedContext.componentDidMount && + (workInProgress.effectTag |= 4), + (workInProgress.memoizedProps = nextProps), + (workInProgress.memoizedState = oldContext)), + (unmaskedContext.props = nextProps), + (unmaskedContext.state = oldContext), + (unmaskedContext.context = isContextConsumer), + (nextProps = contextTypes)) + : ("function" === typeof unmaskedContext.componentDidMount && + (workInProgress.effectTag |= 4), + (nextProps = !1)); + } + else + (unmaskedContext = workInProgress.stateNode), + (contextTypes = workInProgress.memoizedProps), + (unmaskedContext.props = contextTypes), + (oldContext = unmaskedContext.context), + (isContextConsumer = isContextProvider(Component) + ? previousContext + : contextStackCursor.current), + (isContextConsumer = getMaskedContext(workInProgress, isContextConsumer)), + (getDerivedStateFromProps = Component.getDerivedStateFromProps), + (instance = + "function" === typeof getDerivedStateFromProps || + "function" === typeof unmaskedContext.getSnapshotBeforeUpdate) || + ("function" !== + typeof unmaskedContext.UNSAFE_componentWillReceiveProps && + "function" !== typeof unmaskedContext.componentWillReceiveProps) || + ((contextTypes !== nextProps || oldContext !== isContextConsumer) && + callComponentWillReceiveProps( + workInProgress, + unmaskedContext, + nextProps, + isContextConsumer + )), + (hasForceUpdate = !1), + (oldContext = workInProgress.memoizedState), + (oldState = unmaskedContext.state = oldContext), + (updateQueue = workInProgress.updateQueue), + null !== updateQueue && + (processUpdateQueue( + workInProgress, + updateQueue, + nextProps, + unmaskedContext, + renderExpirationTime + ), + (oldState = workInProgress.memoizedState)), + contextTypes !== nextProps || + oldContext !== oldState || + didPerformWorkStackCursor.current || + hasForceUpdate + ? ("function" === typeof getDerivedStateFromProps && + (applyDerivedStateFromProps( + workInProgress, + Component, + getDerivedStateFromProps, + nextProps + ), + (oldState = workInProgress.memoizedState)), + (getDerivedStateFromProps = + hasForceUpdate || + checkShouldComponentUpdate( + workInProgress, + Component, + contextTypes, + nextProps, + oldContext, + oldState, + isContextConsumer + )) + ? (instance || + ("function" !== + typeof unmaskedContext.UNSAFE_componentWillUpdate && + "function" !== typeof unmaskedContext.componentWillUpdate) || + ("function" === typeof unmaskedContext.componentWillUpdate && + unmaskedContext.componentWillUpdate( + nextProps, + oldState, + isContextConsumer + ), + "function" === + typeof unmaskedContext.UNSAFE_componentWillUpdate && + unmaskedContext.UNSAFE_componentWillUpdate( + nextProps, + oldState, + isContextConsumer + )), + "function" === typeof unmaskedContext.componentDidUpdate && + (workInProgress.effectTag |= 4), + "function" === typeof unmaskedContext.getSnapshotBeforeUpdate && + (workInProgress.effectTag |= 256)) + : ("function" !== typeof unmaskedContext.componentDidUpdate || + (contextTypes === current$$1.memoizedProps && + oldContext === current$$1.memoizedState) || + (workInProgress.effectTag |= 4), + "function" !== typeof unmaskedContext.getSnapshotBeforeUpdate || + (contextTypes === current$$1.memoizedProps && + oldContext === current$$1.memoizedState) || + (workInProgress.effectTag |= 256), + (workInProgress.memoizedProps = nextProps), + (workInProgress.memoizedState = oldState)), + (unmaskedContext.props = nextProps), + (unmaskedContext.state = oldState), + (unmaskedContext.context = isContextConsumer), + (nextProps = getDerivedStateFromProps)) + : ("function" !== typeof unmaskedContext.componentDidUpdate || + (contextTypes === current$$1.memoizedProps && + oldContext === current$$1.memoizedState) || + (workInProgress.effectTag |= 4), + "function" !== typeof unmaskedContext.getSnapshotBeforeUpdate || + (contextTypes === current$$1.memoizedProps && + oldContext === current$$1.memoizedState) || + (workInProgress.effectTag |= 256), + (nextProps = !1)); + return finishClassComponent( + current$$1, + workInProgress, + Component, + nextProps, + hasContext, + renderExpirationTime + ); +} function finishClassComponent( current$$1, workInProgress, + Component, shouldUpdate, hasContext, renderExpirationTime @@ -3424,7 +3575,7 @@ function finishClassComponent( var didCaptureError = 0 !== (workInProgress.effectTag & 64); if (!shouldUpdate && !didCaptureError) return ( - hasContext && invalidateContextProvider(workInProgress, !1), + hasContext && invalidateContextProvider(workInProgress, Component, !1), bailoutOnAlreadyFinishedWork( current$$1, workInProgress, @@ -3447,7 +3598,7 @@ function finishClassComponent( ); workInProgress.memoizedState = shouldUpdate.state; workInProgress.memoizedProps = shouldUpdate.props; - hasContext && invalidateContextProvider(workInProgress, !0); + hasContext && invalidateContextProvider(workInProgress, Component, !0); return workInProgress.child; } function pushHostRootContext(workInProgress) { @@ -3462,6 +3613,132 @@ function pushHostRootContext(workInProgress) { pushTopLevelContextObject(workInProgress, root.context, !1); pushHostContainer(workInProgress, root.containerInfo); } +function resolveDefaultProps(Component, baseProps) { + if (Component && Component.defaultProps) { + baseProps = Object.assign({}, baseProps); + Component = Component.defaultProps; + for (var propName in Component) + void 0 === baseProps[propName] && + (baseProps[propName] = Component[propName]); + } + return baseProps; +} +function mountIndeterminateComponent( + current$$1, + workInProgress, + Component, + renderExpirationTime +) { + invariant( + null === current$$1, + "An indeterminate component should never have mounted. This error is likely caused by a bug in React. Please file an issue." + ); + var props = workInProgress.pendingProps; + if ( + "object" === typeof Component && + null !== Component && + "function" === typeof Component.then + ) { + Component = readLazyComponentType(Component); + var JSCompiler_inline_result = Component; + JSCompiler_inline_result = + "function" === typeof JSCompiler_inline_result + ? shouldConstruct(JSCompiler_inline_result) + ? 3 + : 1 + : void 0 !== JSCompiler_inline_result && + null !== JSCompiler_inline_result && + JSCompiler_inline_result.$$typeof + ? 14 + : 4; + JSCompiler_inline_result = workInProgress.tag = JSCompiler_inline_result; + var resolvedProps = resolveDefaultProps(Component, props); + switch (JSCompiler_inline_result) { + case 1: + return updateFunctionalComponent( + current$$1, + workInProgress, + Component, + resolvedProps, + renderExpirationTime + ); + case 3: + return updateClassComponent( + current$$1, + workInProgress, + Component, + resolvedProps, + renderExpirationTime + ); + case 14: + return updateForwardRef( + current$$1, + workInProgress, + Component, + resolvedProps, + renderExpirationTime + ); + default: + invariant( + !1, + "Element type is invalid. Received a promise that resolves to: %s. Promise elements must resolve to a class or function.", + Component + ); + } + } + JSCompiler_inline_result = getMaskedContext( + workInProgress, + contextStackCursor.current + ); + prepareToReadContext(workInProgress, renderExpirationTime); + JSCompiler_inline_result = Component(props, JSCompiler_inline_result); + workInProgress.effectTag |= 1; + if ( + "object" === typeof JSCompiler_inline_result && + null !== JSCompiler_inline_result && + "function" === typeof JSCompiler_inline_result.render && + void 0 === JSCompiler_inline_result.$$typeof + ) { + workInProgress.tag = 2; + isContextProvider(Component) + ? ((resolvedProps = !0), pushContextProvider(workInProgress)) + : (resolvedProps = !1); + workInProgress.memoizedState = + null !== JSCompiler_inline_result.state && + void 0 !== JSCompiler_inline_result.state + ? JSCompiler_inline_result.state + : null; + var getDerivedStateFromProps = Component.getDerivedStateFromProps; + "function" === typeof getDerivedStateFromProps && + applyDerivedStateFromProps( + workInProgress, + Component, + getDerivedStateFromProps, + props + ); + JSCompiler_inline_result.updater = classComponentUpdater; + workInProgress.stateNode = JSCompiler_inline_result; + JSCompiler_inline_result._reactInternalFiber = workInProgress; + mountClassInstance(workInProgress, Component, props, renderExpirationTime); + return finishClassComponent( + current$$1, + workInProgress, + Component, + !0, + resolvedProps, + renderExpirationTime + ); + } + workInProgress.tag = 0; + reconcileChildren( + current$$1, + workInProgress, + JSCompiler_inline_result, + renderExpirationTime + ); + workInProgress.memoizedProps = props; + return workInProgress.child; +} function bailoutOnAlreadyFinishedWork( current$$1, workInProgress, @@ -3507,23 +3784,28 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { (0 === updateExpirationTime || updateExpirationTime > renderExpirationTime) ) { switch (workInProgress.tag) { - case 3: + case 5: pushHostRootContext(workInProgress); break; - case 5: + case 7: pushHostContext(workInProgress); break; case 2: - pushContextProvider(workInProgress); + isContextProvider(workInProgress.type) && + pushContextProvider(workInProgress); break; - case 4: + case 3: + isContextProvider(workInProgress.type._reactResult) && + pushContextProvider(workInProgress); + break; + case 6: pushHostContainer( workInProgress, workInProgress.stateNode.containerInfo ); break; - case 13: - (workInProgress.stateNode = 0), pushProvider(workInProgress); + case 12: + pushProvider(workInProgress, workInProgress.memoizedProps.value); } return bailoutOnAlreadyFinishedWork( current$$1, @@ -3533,294 +3815,56 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { } workInProgress.expirationTime = 0; switch (workInProgress.tag) { - case 0: - invariant( - null === current$$1, - "An indeterminate component should never have mounted. This error is likely caused by a bug in React. Please file an issue." - ); - var fn = workInProgress.type; - updateExpirationTime = workInProgress.pendingProps; - var unmaskedContext = getUnmaskedContext(workInProgress); - unmaskedContext = getMaskedContext(workInProgress, unmaskedContext); - prepareToReadContext(workInProgress, renderExpirationTime); - fn = fn(updateExpirationTime, unmaskedContext); - workInProgress.effectTag |= 1; - if ( - "object" === typeof fn && - null !== fn && - "function" === typeof fn.render && - void 0 === fn.$$typeof - ) { - var Component = workInProgress.type; - workInProgress.tag = 2; - unmaskedContext = pushContextProvider(workInProgress); - workInProgress.memoizedState = - null !== fn.state && void 0 !== fn.state ? fn.state : null; - Component = Component.getDerivedStateFromProps; - "function" === typeof Component && - applyDerivedStateFromProps( - workInProgress, - Component, - updateExpirationTime - ); - fn.updater = classComponentUpdater; - workInProgress.stateNode = fn; - fn._reactInternalFiber = workInProgress; - mountClassInstance(workInProgress, renderExpirationTime); - current$$1 = finishClassComponent( - current$$1, - workInProgress, - !0, - unmaskedContext, - renderExpirationTime - ); - } else - (workInProgress.tag = 1), - reconcileChildren( - current$$1, - workInProgress, - fn, - renderExpirationTime - ), - (workInProgress.memoizedProps = updateExpirationTime), - (current$$1 = workInProgress.child); - return current$$1; - case 1: - return ( - (fn = workInProgress.type), - (updateExpirationTime = workInProgress.pendingProps), - (unmaskedContext = getUnmaskedContext(workInProgress)), - (unmaskedContext = getMaskedContext(workInProgress, unmaskedContext)), - prepareToReadContext(workInProgress, renderExpirationTime), - (fn = fn(updateExpirationTime, unmaskedContext)), - (workInProgress.effectTag |= 1), - reconcileChildren(current$$1, workInProgress, fn, renderExpirationTime), - (workInProgress.memoizedProps = updateExpirationTime), - workInProgress.child - ); - case 2: - updateExpirationTime = pushContextProvider(workInProgress); - fn = prepareToReadContext(workInProgress, renderExpirationTime); - if (null === current$$1) - if (null === workInProgress.stateNode) { - var props = workInProgress.pendingProps, - ctor = workInProgress.type; - fn = getUnmaskedContext(workInProgress); - unmaskedContext = (Component = - 2 === workInProgress.tag && - null != workInProgress.type.contextTypes) - ? getMaskedContext(workInProgress, fn) - : emptyContextObject; - props = new ctor(props, unmaskedContext); - workInProgress.memoizedState = - null !== props.state && void 0 !== props.state ? props.state : null; - props.updater = classComponentUpdater; - workInProgress.stateNode = props; - props._reactInternalFiber = workInProgress; - Component && - ((Component = workInProgress.stateNode), - (Component.__reactInternalMemoizedUnmaskedChildContext = fn), - (Component.__reactInternalMemoizedMaskedChildContext = unmaskedContext)); - mountClassInstance(workInProgress, renderExpirationTime); - fn = !0; - } else { - var ctor$jscomp$0 = workInProgress.type; - unmaskedContext = workInProgress.stateNode; - props = workInProgress.memoizedProps; - Component = workInProgress.pendingProps; - unmaskedContext.props = props; - var oldContext = unmaskedContext.context; - ctor = getUnmaskedContext(workInProgress); - ctor = getMaskedContext(workInProgress, ctor); - var getDerivedStateFromProps = ctor$jscomp$0.getDerivedStateFromProps; - (ctor$jscomp$0 = - "function" === typeof getDerivedStateFromProps || - "function" === typeof unmaskedContext.getSnapshotBeforeUpdate) || - ("function" !== - typeof unmaskedContext.UNSAFE_componentWillReceiveProps && - "function" !== - typeof unmaskedContext.componentWillReceiveProps) || - ((props !== Component || oldContext !== ctor) && - callComponentWillReceiveProps( - workInProgress, - unmaskedContext, - Component, - ctor - )); - hasForceUpdate = !1; - var oldState = workInProgress.memoizedState; - oldContext = unmaskedContext.state = oldState; - var updateQueue = workInProgress.updateQueue; - null !== updateQueue && - (processUpdateQueue( - workInProgress, - updateQueue, - Component, - unmaskedContext, - renderExpirationTime - ), - (oldContext = workInProgress.memoizedState)); - props !== Component || - oldState !== oldContext || - didPerformWorkStackCursor.current || - fn || - hasForceUpdate - ? ("function" === typeof getDerivedStateFromProps && - (applyDerivedStateFromProps( - workInProgress, - getDerivedStateFromProps, - Component - ), - (oldContext = workInProgress.memoizedState)), - (fn = - hasForceUpdate || - fn || - checkShouldComponentUpdate( - workInProgress, - props, - Component, - oldState, - oldContext, - ctor - )) - ? (ctor$jscomp$0 || - ("function" !== - typeof unmaskedContext.UNSAFE_componentWillMount && - "function" !== - typeof unmaskedContext.componentWillMount) || - ("function" === typeof unmaskedContext.componentWillMount && - unmaskedContext.componentWillMount(), - "function" === - typeof unmaskedContext.UNSAFE_componentWillMount && - unmaskedContext.UNSAFE_componentWillMount()), - "function" === typeof unmaskedContext.componentDidMount && - (workInProgress.effectTag |= 4)) - : ("function" === typeof unmaskedContext.componentDidMount && - (workInProgress.effectTag |= 4), - (workInProgress.memoizedProps = Component), - (workInProgress.memoizedState = oldContext)), - (unmaskedContext.props = Component), - (unmaskedContext.state = oldContext), - (unmaskedContext.context = ctor)) - : ("function" === typeof unmaskedContext.componentDidMount && - (workInProgress.effectTag |= 4), - (fn = !1)); - } - else - (ctor$jscomp$0 = workInProgress.type), - (unmaskedContext = workInProgress.stateNode), - (Component = workInProgress.memoizedProps), - (props = workInProgress.pendingProps), - (unmaskedContext.props = Component), - (oldContext = unmaskedContext.context), - (ctor = getUnmaskedContext(workInProgress)), - (ctor = getMaskedContext(workInProgress, ctor)), - (getDerivedStateFromProps = ctor$jscomp$0.getDerivedStateFromProps), - (ctor$jscomp$0 = - "function" === typeof getDerivedStateFromProps || - "function" === typeof unmaskedContext.getSnapshotBeforeUpdate) || - ("function" !== - typeof unmaskedContext.UNSAFE_componentWillReceiveProps && - "function" !== - typeof unmaskedContext.componentWillReceiveProps) || - ((Component !== props || oldContext !== ctor) && - callComponentWillReceiveProps( - workInProgress, - unmaskedContext, - props, - ctor - )), - (hasForceUpdate = !1), - (oldContext = workInProgress.memoizedState), - (oldState = unmaskedContext.state = oldContext), - (updateQueue = workInProgress.updateQueue), - null !== updateQueue && - (processUpdateQueue( - workInProgress, - updateQueue, - props, - unmaskedContext, - renderExpirationTime - ), - (oldState = workInProgress.memoizedState)), - Component !== props || - oldContext !== oldState || - didPerformWorkStackCursor.current || - fn || - hasForceUpdate - ? ("function" === typeof getDerivedStateFromProps && - (applyDerivedStateFromProps( - workInProgress, - getDerivedStateFromProps, - props - ), - (oldState = workInProgress.memoizedState)), - (fn = - hasForceUpdate || - fn || - checkShouldComponentUpdate( - workInProgress, - Component, - props, - oldContext, - oldState, - ctor - )) - ? (ctor$jscomp$0 || - ("function" !== - typeof unmaskedContext.UNSAFE_componentWillUpdate && - "function" !== - typeof unmaskedContext.componentWillUpdate) || - ("function" === - typeof unmaskedContext.componentWillUpdate && - unmaskedContext.componentWillUpdate( - props, - oldState, - ctor - ), - "function" === - typeof unmaskedContext.UNSAFE_componentWillUpdate && - unmaskedContext.UNSAFE_componentWillUpdate( - props, - oldState, - ctor - )), - "function" === typeof unmaskedContext.componentDidUpdate && - (workInProgress.effectTag |= 4), - "function" === - typeof unmaskedContext.getSnapshotBeforeUpdate && - (workInProgress.effectTag |= 256)) - : ("function" !== typeof unmaskedContext.componentDidUpdate || - (Component === current$$1.memoizedProps && - oldContext === current$$1.memoizedState) || - (workInProgress.effectTag |= 4), - "function" !== - typeof unmaskedContext.getSnapshotBeforeUpdate || - (Component === current$$1.memoizedProps && - oldContext === current$$1.memoizedState) || - (workInProgress.effectTag |= 256), - (workInProgress.memoizedProps = props), - (workInProgress.memoizedState = oldState)), - (unmaskedContext.props = props), - (unmaskedContext.state = oldState), - (unmaskedContext.context = ctor)) - : ("function" !== typeof unmaskedContext.componentDidUpdate || - (Component === current$$1.memoizedProps && - oldContext === current$$1.memoizedState) || - (workInProgress.effectTag |= 4), - "function" !== typeof unmaskedContext.getSnapshotBeforeUpdate || - (Component === current$$1.memoizedProps && - oldContext === current$$1.memoizedState) || - (workInProgress.effectTag |= 256), - (fn = !1)); - return finishClassComponent( + case 4: + return mountIndeterminateComponent( current$$1, workInProgress, - fn, - updateExpirationTime, + workInProgress.type, + renderExpirationTime + ); + case 0: + return updateFunctionalComponent( + current$$1, + workInProgress, + workInProgress.type, + workInProgress.pendingProps, + renderExpirationTime + ); + case 1: + var _Component5 = workInProgress.type._reactResult; + updateExpirationTime = workInProgress.pendingProps; + current$$1 = updateFunctionalComponent( + current$$1, + workInProgress, + _Component5, + resolveDefaultProps(_Component5, updateExpirationTime), + renderExpirationTime + ); + workInProgress.memoizedProps = updateExpirationTime; + return current$$1; + case 2: + return updateClassComponent( + current$$1, + workInProgress, + workInProgress.type, + workInProgress.pendingProps, renderExpirationTime ); case 3: + return ( + (_Component5 = workInProgress.type._reactResult), + (updateExpirationTime = workInProgress.pendingProps), + (current$$1 = updateClassComponent( + current$$1, + workInProgress, + _Component5, + resolveDefaultProps(_Component5, updateExpirationTime), + renderExpirationTime + )), + (workInProgress.memoizedProps = updateExpirationTime), + current$$1 + ); + case 5: return ( pushHostRootContext(workInProgress), (updateExpirationTime = workInProgress.updateQueue), @@ -3828,8 +3872,8 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { null !== updateExpirationTime, "If the root does not have an updateQueue, we should have already bailed out. This error is likely caused by a bug in React. Please file an issue." ), - (fn = workInProgress.memoizedState), - (fn = null !== fn ? fn.element : null), + (_Component5 = workInProgress.memoizedState), + (_Component5 = null !== _Component5 ? _Component5.element : null), processUpdateQueue( workInProgress, updateExpirationTime, @@ -3838,8 +3882,8 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { renderExpirationTime ), (updateExpirationTime = workInProgress.memoizedState.element), - updateExpirationTime === fn - ? (current$$1 = bailoutOnAlreadyFinishedWork( + updateExpirationTime === _Component5 + ? (workInProgress = bailoutOnAlreadyFinishedWork( current$$1, workInProgress, renderExpirationTime @@ -3850,22 +3894,27 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { updateExpirationTime, renderExpirationTime ), - (current$$1 = workInProgress.child)), - current$$1 + (workInProgress = workInProgress.child)), + workInProgress ); - case 5: + case 7: return ( pushHostContext(workInProgress), null === current$$1 && tryToClaimNextHydratableInstance(workInProgress), (updateExpirationTime = workInProgress.pendingProps), - (fn = updateExpirationTime.children), + (_Component5 = updateExpirationTime.children), markRef(current$$1, workInProgress), - reconcileChildren(current$$1, workInProgress, fn, renderExpirationTime), + reconcileChildren( + current$$1, + workInProgress, + _Component5, + renderExpirationTime + ), (workInProgress.memoizedProps = updateExpirationTime), - (current$$1 = workInProgress.child), - current$$1 + (workInProgress = workInProgress.child), + workInProgress ); - case 6: + case 8: return ( null === current$$1 && tryToClaimNextHydratableInstance(workInProgress), (workInProgress.memoizedProps = workInProgress.pendingProps), @@ -3873,7 +3922,7 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { ); case 16: return null; - case 4: + case 6: return ( pushHostContainer( workInProgress, @@ -3896,31 +3945,29 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { (workInProgress.memoizedProps = updateExpirationTime), workInProgress.child ); + case 13: + return updateForwardRef( + current$$1, + workInProgress, + workInProgress.type, + workInProgress.pendingProps, + renderExpirationTime + ); case 14: return ( - (fn = workInProgress.type.render), + (_Component5 = workInProgress.type._reactResult), (updateExpirationTime = workInProgress.pendingProps), - (unmaskedContext = workInProgress.ref), - didPerformWorkStackCursor.current || - workInProgress.memoizedProps !== updateExpirationTime || - unmaskedContext !== (null !== current$$1 ? current$$1.ref : null) - ? ((fn = fn(updateExpirationTime, unmaskedContext)), - reconcileChildren( - current$$1, - workInProgress, - fn, - renderExpirationTime - ), - (workInProgress.memoizedProps = updateExpirationTime), - (current$$1 = workInProgress.child)) - : (current$$1 = bailoutOnAlreadyFinishedWork( - current$$1, - workInProgress, - renderExpirationTime - )), + (current$$1 = updateForwardRef( + current$$1, + workInProgress, + _Component5, + resolveDefaultProps(_Component5, updateExpirationTime), + renderExpirationTime + )), + (workInProgress.memoizedProps = updateExpirationTime), current$$1 ); - case 10: + case 9: return ( (updateExpirationTime = workInProgress.pendingProps), reconcileChildren( @@ -3932,7 +3979,7 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { (workInProgress.memoizedProps = updateExpirationTime), workInProgress.child ); - case 11: + case 10: return ( (updateExpirationTime = workInProgress.pendingProps.children), reconcileChildren( @@ -3956,101 +4003,146 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { (workInProgress.memoizedProps = updateExpirationTime), workInProgress.child ); - case 13: + case 12: a: { updateExpirationTime = workInProgress.type._context; - fn = workInProgress.pendingProps; - unmaskedContext = workInProgress.memoizedProps; - Component = fn.value; - workInProgress.memoizedProps = fn; - if (null === unmaskedContext) Component = 1073741823; - else if (unmaskedContext.value === fn.value) { - if ( - unmaskedContext.children === fn.children && - !didPerformWorkStackCursor.current - ) { - workInProgress.stateNode = 0; - pushProvider(workInProgress); - current$$1 = bailoutOnAlreadyFinishedWork( - current$$1, - workInProgress, - renderExpirationTime - ); - break a; - } - Component = 0; - } else if ( - ((props = unmaskedContext.value), - (props === Component && - (0 !== props || 1 / props === 1 / Component)) || - (props !== props && Component !== Component)) - ) { - if ( - unmaskedContext.children === fn.children && - !didPerformWorkStackCursor.current - ) { - workInProgress.stateNode = 0; - pushProvider(workInProgress); - current$$1 = bailoutOnAlreadyFinishedWork( - current$$1, - workInProgress, - renderExpirationTime - ); - break a; - } - Component = 0; - } else if ( - ((Component = - "function" === typeof updateExpirationTime._calculateChangedBits - ? updateExpirationTime._calculateChangedBits(props, Component) - : 1073741823), - (Component |= 0), - 0 === Component) - ) { - if ( - unmaskedContext.children === fn.children && - !didPerformWorkStackCursor.current - ) { - workInProgress.stateNode = 0; - pushProvider(workInProgress); - current$$1 = bailoutOnAlreadyFinishedWork( - current$$1, - workInProgress, - renderExpirationTime - ); - break a; - } - } else - propagateContextChange( - workInProgress, - updateExpirationTime, - Component, - renderExpirationTime - ); - workInProgress.stateNode = Component; - pushProvider(workInProgress); + _Component5 = workInProgress.pendingProps; + var oldProps = workInProgress.memoizedProps, + newValue = _Component5.value; + workInProgress.memoizedProps = _Component5; + pushProvider(workInProgress, newValue); + if (null !== oldProps) { + var oldValue = oldProps.value; + newValue = + (oldValue === newValue && + (0 !== oldValue || 1 / oldValue === 1 / newValue)) || + (oldValue !== oldValue && newValue !== newValue) + ? 0 + : ("function" === + typeof updateExpirationTime._calculateChangedBits + ? updateExpirationTime._calculateChangedBits( + oldValue, + newValue + ) + : 1073741823) | 0; + if (0 === newValue) { + if ( + oldProps.children === _Component5.children && + !didPerformWorkStackCursor.current + ) { + workInProgress = bailoutOnAlreadyFinishedWork( + current$$1, + workInProgress, + renderExpirationTime + ); + break a; + } + } else + for ( + oldProps = workInProgress.child, + null !== oldProps && (oldProps.return = workInProgress); + null !== oldProps; + + ) { + oldValue = oldProps.firstContextDependency; + if (null !== oldValue) { + do { + if ( + oldValue.context === updateExpirationTime && + 0 !== (oldValue.observedBits & newValue) + ) { + if (2 === oldProps.tag || 3 === oldProps.tag) { + var nextFiber = createUpdate(renderExpirationTime); + nextFiber.tag = 2; + enqueueUpdate(oldProps, nextFiber); + } + if ( + 0 === oldProps.expirationTime || + oldProps.expirationTime > renderExpirationTime + ) + oldProps.expirationTime = renderExpirationTime; + nextFiber = oldProps.alternate; + null !== nextFiber && + (0 === nextFiber.expirationTime || + nextFiber.expirationTime > renderExpirationTime) && + (nextFiber.expirationTime = renderExpirationTime); + for (var node = oldProps.return; null !== node; ) { + nextFiber = node.alternate; + if ( + 0 === node.childExpirationTime || + node.childExpirationTime > renderExpirationTime + ) + (node.childExpirationTime = renderExpirationTime), + null !== nextFiber && + (0 === nextFiber.childExpirationTime || + nextFiber.childExpirationTime > + renderExpirationTime) && + (nextFiber.childExpirationTime = renderExpirationTime); + else if ( + null !== nextFiber && + (0 === nextFiber.childExpirationTime || + nextFiber.childExpirationTime > renderExpirationTime) + ) + nextFiber.childExpirationTime = renderExpirationTime; + else break; + node = node.return; + } + } + nextFiber = oldProps.child; + oldValue = oldValue.next; + } while (null !== oldValue); + } else + nextFiber = + 12 === oldProps.tag + ? oldProps.type === workInProgress.type + ? null + : oldProps.child + : oldProps.child; + if (null !== nextFiber) nextFiber.return = oldProps; + else + for (nextFiber = oldProps; null !== nextFiber; ) { + if (nextFiber === workInProgress) { + nextFiber = null; + break; + } + oldProps = nextFiber.sibling; + if (null !== oldProps) { + oldProps.return = nextFiber.return; + nextFiber = oldProps; + break; + } + nextFiber = nextFiber.return; + } + oldProps = nextFiber; + } + } reconcileChildren( current$$1, workInProgress, - fn.children, + _Component5.children, renderExpirationTime ); - current$$1 = workInProgress.child; + workInProgress = workInProgress.child; } - return current$$1; - case 12: + return workInProgress; + case 11: return ( - (unmaskedContext = workInProgress.type), + (newValue = workInProgress.type), (updateExpirationTime = workInProgress.pendingProps), - (fn = updateExpirationTime.children), + (_Component5 = updateExpirationTime.children), prepareToReadContext(workInProgress, renderExpirationTime), - (unmaskedContext = readContext( - unmaskedContext, + (newValue = readContext( + newValue, updateExpirationTime.unstable_observedBits )), - (fn = fn(unmaskedContext)), + (_Component5 = _Component5(newValue)), (workInProgress.effectTag |= 1), - reconcileChildren(current$$1, workInProgress, fn, renderExpirationTime), + reconcileChildren( + current$$1, + workInProgress, + _Component5, + renderExpirationTime + ), (workInProgress.memoizedProps = updateExpirationTime), workInProgress.child ); @@ -4065,42 +4157,61 @@ var updateHostContainer = void 0, updateHostComponent$1 = void 0, updateHostText$1 = void 0; updateHostContainer = function() {}; -updateHostComponent$1 = function(current, workInProgress, updatePayload) { - if ((workInProgress.updateQueue = updatePayload)) - workInProgress.effectTag |= 4; +updateHostComponent$1 = function(current, workInProgress, type, newProps) { + current.memoizedProps !== newProps && + (requiredContext(contextStackCursor$1.current), + (workInProgress.updateQueue = UPDATE_SIGNAL)) && + (workInProgress.effectTag |= 4); }; updateHostText$1 = function(current, workInProgress, oldText, newText) { oldText !== newText && (workInProgress.effectTag |= 4); }; +function logCapturedError(capturedError) { + var componentStack = capturedError.componentStack, + error = capturedError.error; + if (error instanceof Error) { + capturedError = error.message; + var name = error.name; + try { + error.message = + (capturedError ? name + ": " + capturedError : name) + + "\n\nThis error is located at:" + + componentStack; + } catch (e) {} + } else + error = + "string" === typeof error + ? Error(error + "\n\nThis error is located at:" + componentStack) + : Error("Unspecified error at:" + componentStack); + ExceptionsManager.handleException(error, !1); +} function logError(boundary, errorInfo) { var source = errorInfo.source, stack = errorInfo.stack; null === stack && null !== source && (stack = getStackByFiberInDevAndProd(source)); - null !== source && getComponentName(source.type); - source = null !== stack ? stack : ""; - errorInfo = errorInfo.value; - null !== boundary && 2 === boundary.tag && getComponentName(boundary.type); + errorInfo = { + componentName: null !== source ? getComponentName(source.type) : null, + componentStack: null !== stack ? stack : "", + error: errorInfo.value, + errorBoundary: null, + errorBoundaryName: null, + errorBoundaryFound: !1, + willRetry: !1 + }; + null !== boundary && + 2 === boundary.tag && + ((errorInfo.errorBoundary = boundary.stateNode), + (errorInfo.errorBoundaryName = getComponentName(boundary.type)), + (errorInfo.errorBoundaryFound = !0), + (errorInfo.willRetry = !0)); try { - if (errorInfo instanceof Error) { - var message = errorInfo.message, - name = errorInfo.name; - var errorToHandle = errorInfo; - try { - errorToHandle.message = - (message ? name + ": " + message : name) + - "\n\nThis error is located at:" + - source; - } catch (e) {} - } else - errorToHandle = - "string" === typeof errorInfo - ? Error(errorInfo + "\n\nThis error is located at:" + source) - : Error("Unspecified error at:" + source); - ExceptionsManager.handleException(errorToHandle, !1); + logCapturedError(errorInfo); } catch (e) { - (e && e.suppressReactErrorLogging) || console.error(e); + setTimeout(function() { + throw e; + }); } } function safelyDetachRef(current$$1) { @@ -4119,6 +4230,7 @@ function commitUnmount(current$$1) { onCommitFiberUnmount(current$$1); switch (current$$1.tag) { case 2: + case 3: safelyDetachRef(current$$1); var instance = current$$1.stateNode; if ("function" === typeof instance.componentWillUnmount) @@ -4130,15 +4242,15 @@ function commitUnmount(current$$1) { captureCommitPhaseError(current$$1, unmountError); } break; - case 5: + case 7: safelyDetachRef(current$$1); break; - case 4: + case 6: unmountHostComponents(current$$1); } } function isHostParent(fiber) { - return 5 === fiber.tag || 3 === fiber.tag || 4 === fiber.tag; + return 7 === fiber.tag || 5 === fiber.tag || 6 === fiber.tag; } function commitPlacement(finishedWork) { a: { @@ -4157,15 +4269,15 @@ function commitPlacement(finishedWork) { } var isContainer = (parent = void 0); switch (parentFiber.tag) { - case 5: + case 7: parent = parentFiber.stateNode; isContainer = !1; break; - case 3: + case 5: parent = parentFiber.stateNode.containerInfo; isContainer = !0; break; - case 4: + case 6: parent = parentFiber.stateNode.containerInfo; isContainer = !0; break; @@ -4187,11 +4299,11 @@ function commitPlacement(finishedWork) { parentFiber.sibling.return = parentFiber.return; for ( parentFiber = parentFiber.sibling; - 5 !== parentFiber.tag && 6 !== parentFiber.tag; + 7 !== parentFiber.tag && 8 !== parentFiber.tag; ) { if (parentFiber.effectTag & 2) continue b; - if (null === parentFiber.child || 4 === parentFiber.tag) continue b; + if (null === parentFiber.child || 6 === parentFiber.tag) continue b; else (parentFiber.child.return = parentFiber), (parentFiber = parentFiber.child); @@ -4202,7 +4314,7 @@ function commitPlacement(finishedWork) { } } for (var node = finishedWork; ; ) { - if (5 === node.tag || 6 === node.tag) + if (7 === node.tag || 8 === node.tag) if (parentFiber) if (isContainer) invariant( @@ -4271,7 +4383,7 @@ function commitPlacement(finishedWork) { [index.length - 1], [] ))); - else if (4 !== node.tag && null !== node.child) { + else if (6 !== node.tag && null !== node.child) { node.child.return = node; node = node.child; continue; @@ -4302,15 +4414,15 @@ function unmountHostComponents(current$$1) { "Expected to find a host parent. This error is likely caused by a bug in React. Please file an issue." ); switch (currentParentIsValid.tag) { - case 5: + case 7: currentParent = currentParentIsValid.stateNode; currentParentIsContainer = !1; break a; - case 3: + case 5: currentParent = currentParentIsValid.stateNode.containerInfo; currentParentIsContainer = !0; break a; - case 4: + case 6: currentParent = currentParentIsValid.stateNode.containerInfo; currentParentIsContainer = !0; break a; @@ -4319,11 +4431,11 @@ function unmountHostComponents(current$$1) { } currentParentIsValid = !0; } - if (5 === node.tag || 6 === node.tag) { + if (7 === node.tag || 8 === node.tag) { a: for (var root = node, node$jscomp$0 = root; ; ) if ( (commitUnmount(node$jscomp$0), - null !== node$jscomp$0.child && 4 !== node$jscomp$0.tag) + null !== node$jscomp$0.child && 6 !== node$jscomp$0.tag) ) (node$jscomp$0.child.return = node$jscomp$0), (node$jscomp$0 = node$jscomp$0.child); @@ -4351,7 +4463,7 @@ function unmountHostComponents(current$$1) { UIManager.manageChildren(root._nativeTag, [], [], [], [], [child]); } } else if ( - (4 === node.tag + (6 === node.tag ? ((currentParent = node.stateNode.containerInfo), (currentParentIsContainer = !0)) : commitUnmount(node), @@ -4365,7 +4477,7 @@ function unmountHostComponents(current$$1) { for (; null === node.sibling; ) { if (null === node.return || node.return === current$$1) return; node = node.return; - 4 === node.tag && (currentParentIsValid = !1); + 6 === node.tag && (currentParentIsValid = !1); } node.sibling.return = node.return; node = node.sibling; @@ -4374,8 +4486,9 @@ function unmountHostComponents(current$$1) { function commitWork(current$$1, finishedWork) { switch (finishedWork.tag) { case 2: + case 3: break; - case 5: + case 7: var instance = finishedWork.stateNode; if (null != instance) { var newProps = finishedWork.memoizedProps; @@ -4399,7 +4512,7 @@ function commitWork(current$$1, finishedWork) { )); } break; - case 6: + case 8: invariant( null !== finishedWork.stateNode, "This should have a text node initialized. This error is likely caused by a bug in React. Please file an issue." @@ -4408,7 +4521,7 @@ function commitWork(current$$1, finishedWork) { text: finishedWork.memoizedProps }); break; - case 3: + case 5: break; case 15: break; @@ -4454,13 +4567,23 @@ function createClassErrorUpdate(fiber, errorInfo, expirationTime) { function unwindWork(workInProgress) { switch (workInProgress.tag) { case 2: - popContextProvider(workInProgress); + isContextProvider(workInProgress.type) && popContext(workInProgress); var effectTag = workInProgress.effectTag; return effectTag & 1024 ? ((workInProgress.effectTag = (effectTag & -1025) | 64), workInProgress) : null; case 3: + return ( + isContextProvider(workInProgress.type._reactResult) && + popContext(workInProgress), + (effectTag = workInProgress.effectTag), + effectTag & 1024 + ? ((workInProgress.effectTag = (effectTag & -1025) | 64), + workInProgress) + : null + ); + case 5: return ( popHostContainer(workInProgress), popTopLevelContextObject(workInProgress), @@ -4472,7 +4595,7 @@ function unwindWork(workInProgress) { (workInProgress.effectTag = (effectTag & -1025) | 64), workInProgress ); - case 5: + case 7: return popHostContext(workInProgress), null; case 16: return ( @@ -4482,9 +4605,9 @@ function unwindWork(workInProgress) { workInProgress) : null ); - case 4: + case 6: return popHostContainer(workInProgress), null; - case 13: + case 12: return popProvider(workInProgress), null; default: return null; @@ -4492,8 +4615,6 @@ function unwindWork(workInProgress) { } var Dispatcher = { readContext: readContext }, ReactCurrentOwner$2 = ReactSharedInternals.ReactCurrentOwner, - lastUniqueAsyncExpiration = 0, - expirationContext = 0, isWorking = !1, nextUnitOfWork = null, nextRoot = null, @@ -4512,19 +4633,30 @@ function resetStack() { var interruptedWork$jscomp$0 = interruptedWork; switch (interruptedWork$jscomp$0.tag) { case 2: - popContextProvider(interruptedWork$jscomp$0); + var childContextTypes = + interruptedWork$jscomp$0.type.childContextTypes; + null !== childContextTypes && + void 0 !== childContextTypes && + popContext(interruptedWork$jscomp$0); break; case 3: + childContextTypes = + interruptedWork$jscomp$0.type._reactResult.childContextTypes; + null !== childContextTypes && + void 0 !== childContextTypes && + popContext(interruptedWork$jscomp$0); + break; + case 5: popHostContainer(interruptedWork$jscomp$0); popTopLevelContextObject(interruptedWork$jscomp$0); break; - case 5: + case 7: popHostContext(interruptedWork$jscomp$0); break; - case 4: + case 6: popHostContainer(interruptedWork$jscomp$0); break; - case 13: + case 12: popProvider(interruptedWork$jscomp$0); } interruptedWork = interruptedWork.return; @@ -4544,12 +4676,17 @@ function completeUnitOfWork(workInProgress) { current$$1 = workInProgress; var newProps = current$$1.pendingProps; switch (current$$1.tag) { + case 0: case 1: break; case 2: - popContextProvider(current$$1); + isContextProvider(current$$1.type) && popContext(current$$1); break; case 3: + isContextProvider(current$$1.type._reactResult) && + popContext(current$$1); + break; + case 5: popHostContainer(current$$1); popTopLevelContextObject(current$$1); newProps = current$$1.stateNode; @@ -4560,106 +4697,82 @@ function completeUnitOfWork(workInProgress) { current$$1.effectTag &= -3; updateHostContainer(current$$1); break; - case 5: + case 7: popHostContext(current$$1); var rootContainerInstance = requiredContext( rootInstanceStackCursor.current ), type = current$$1.type; - if (null !== current && null != current$$1.stateNode) { - var oldProps = current.memoizedProps, - currentHostContext = requiredContext( - contextStackCursor$1.current - ); + if (null !== current && null != current$$1.stateNode) updateHostComponent$1( current, current$$1, - UPDATE_SIGNAL, type, - oldProps, newProps, - rootContainerInstance, - currentHostContext - ); - current.ref !== current$$1.ref && (current$$1.effectTag |= 128); - } else if (newProps) { + rootContainerInstance + ), + current.ref !== current$$1.ref && (current$$1.effectTag |= 128); + else if (newProps) { current = requiredContext(contextStackCursor$1.current); - var type$jscomp$0 = type; - oldProps = newProps; - var rootContainerInstance$jscomp$0 = rootContainerInstance, - hostContext = current; - currentHostContext = current$$1; - var tag = allocateTag(), - viewConfig = ReactNativeViewConfigRegistry.get(type$jscomp$0); + var internalInstanceHandle = current$$1, + tag = allocateTag(), + viewConfig = ReactNativeViewConfigRegistry.get(type); invariant( - "RCTView" !== type$jscomp$0 || !hostContext.isInAParentText, + "RCTView" !== type || !current.isInAParentText, "Nesting of within is not currently supported." ); - type$jscomp$0 = diffProperties( + var updatePayload = diffProperties( null, emptyObject, - oldProps, + newProps, viewConfig.validAttributes ); UIManager.createView( tag, viewConfig.uiViewClassName, - rootContainerInstance$jscomp$0, - type$jscomp$0 + rootContainerInstance, + updatePayload ); - rootContainerInstance$jscomp$0 = new ReactNativeFiberHostComponent( - tag, - viewConfig - ); - instanceCache[tag] = currentHostContext; - instanceProps[tag] = oldProps; - oldProps = rootContainerInstance$jscomp$0; + viewConfig = new ReactNativeFiberHostComponent(tag, viewConfig); + instanceCache[tag] = internalInstanceHandle; + instanceProps[tag] = newProps; a: for ( - currentHostContext = oldProps, + internalInstanceHandle = viewConfig, tag = current$$1, - rootContainerInstance$jscomp$0 = tag.child; - null !== rootContainerInstance$jscomp$0; + updatePayload = tag.child; + null !== updatePayload; ) { - if ( - 5 === rootContainerInstance$jscomp$0.tag || - 6 === rootContainerInstance$jscomp$0.tag - ) - currentHostContext._children.push( - rootContainerInstance$jscomp$0.stateNode - ); + if (7 === updatePayload.tag || 8 === updatePayload.tag) + internalInstanceHandle._children.push(updatePayload.stateNode); else if ( - 4 !== rootContainerInstance$jscomp$0.tag && - null !== rootContainerInstance$jscomp$0.child + 6 !== updatePayload.tag && + null !== updatePayload.child ) { - rootContainerInstance$jscomp$0.child.return = rootContainerInstance$jscomp$0; - rootContainerInstance$jscomp$0 = - rootContainerInstance$jscomp$0.child; + updatePayload.child.return = updatePayload; + updatePayload = updatePayload.child; continue; } - if (rootContainerInstance$jscomp$0 === tag) break; - for (; null === rootContainerInstance$jscomp$0.sibling; ) { + if (updatePayload === tag) break; + for (; null === updatePayload.sibling; ) { if ( - null === rootContainerInstance$jscomp$0.return || - rootContainerInstance$jscomp$0.return === tag + null === updatePayload.return || + updatePayload.return === tag ) break a; - rootContainerInstance$jscomp$0 = - rootContainerInstance$jscomp$0.return; + updatePayload = updatePayload.return; } - rootContainerInstance$jscomp$0.sibling.return = - rootContainerInstance$jscomp$0.return; - rootContainerInstance$jscomp$0 = - rootContainerInstance$jscomp$0.sibling; + updatePayload.sibling.return = updatePayload.return; + updatePayload = updatePayload.sibling; } finalizeInitialChildren( - oldProps, + viewConfig, type, newProps, rootContainerInstance, current ) && (current$$1.effectTag |= 4); - current$$1.stateNode = oldProps; + current$$1.stateNode = viewConfig; null !== current$$1.ref && (current$$1.effectTag |= 128); } else invariant( @@ -4667,54 +4780,54 @@ function completeUnitOfWork(workInProgress) { "We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue." ); break; - case 6: - type = newProps; + case 8: current && null != current$$1.stateNode - ? updateHostText$1(current, current$$1, current.memoizedProps, type) - : ("string" !== typeof type && + ? updateHostText$1( + current, + current$$1, + current.memoizedProps, + newProps + ) + : ("string" !== typeof newProps && invariant( null !== current$$1.stateNode, "We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue." ), (current = requiredContext(rootInstanceStackCursor.current)), - (rootContainerInstance = requiredContext( - contextStackCursor$1.current - )), - (newProps = current$$1), + (type = requiredContext(contextStackCursor$1.current)), + (rootContainerInstance = current$$1), invariant( - rootContainerInstance.isInAParentText, + type.isInAParentText, "Text strings must be rendered within a component." ), - (rootContainerInstance = allocateTag()), - UIManager.createView( - rootContainerInstance, - "RCTRawText", - current, - { text: type } - ), - (instanceCache[rootContainerInstance] = current$$1), - (newProps.stateNode = rootContainerInstance)); + (type = allocateTag()), + UIManager.createView(type, "RCTRawText", current, { + text: newProps + }), + (instanceCache[type] = current$$1), + (rootContainerInstance.stateNode = type)); break; + case 13: case 14: break; case 16: break; - case 10: + case 9: break; - case 11: + case 10: break; case 15: break; - case 4: + case 6: popHostContainer(current$$1); updateHostContainer(current$$1); break; - case 13: + case 12: popProvider(current$$1); break; - case 12: + case 11: break; - case 0: + case 4: invariant( !1, "An indeterminate component should have become determinate before completing. This error is likely caused by a bug in React. Please file an issue." @@ -4734,7 +4847,7 @@ function completeUnitOfWork(workInProgress) { rootContainerInstance = 0; for (type = newProps.child; null !== type; ) { current = type.expirationTime; - oldProps = type.childExpirationTime; + viewConfig = type.childExpirationTime; if ( 0 === rootContainerInstance || (0 !== current && current < rootContainerInstance) @@ -4742,9 +4855,9 @@ function completeUnitOfWork(workInProgress) { rootContainerInstance = current; if ( 0 === rootContainerInstance || - (0 !== oldProps && oldProps < rootContainerInstance) + (0 !== viewConfig && viewConfig < rootContainerInstance) ) - rootContainerInstance = oldProps; + rootContainerInstance = viewConfig; type = type.sibling; } newProps.childExpirationTime = rootContainerInstance; @@ -4841,7 +4954,7 @@ function renderRoot(root, isYieldy, isExpired) { value = createCapturedValue(value, sourceFiber$jscomp$0); do { switch (returnFiber$jscomp$0.tag) { - case 3: + case 5: returnFiber$jscomp$0.effectTag |= 1024; returnFiber$jscomp$0.expirationTime = returnFiber; returnFiber = createRootErrorUpdate( @@ -4852,6 +4965,7 @@ function renderRoot(root, isYieldy, isExpired) { enqueueCapturedUpdate(returnFiber$jscomp$0, returnFiber); break a; case 2: + case 3: sourceFiber$jscomp$0 = value; var instance = returnFiber$jscomp$0.stateNode; if ( @@ -4952,6 +5066,7 @@ function captureCommitPhaseError(fiber, error) { ) { switch (JSCompiler_inline_result.tag) { case 2: + case 3: var instance = JSCompiler_inline_result.stateNode; if ( "function" === @@ -4968,7 +5083,7 @@ function captureCommitPhaseError(fiber, error) { break a; } break; - case 3: + case 5: fiber = createCapturedValue(error, fiber); fiber = createRootErrorUpdate(JSCompiler_inline_result, fiber, 1); enqueueUpdate(JSCompiler_inline_result, fiber); @@ -4978,7 +5093,7 @@ function captureCommitPhaseError(fiber, error) { } JSCompiler_inline_result = JSCompiler_inline_result.return; } - 3 === fiber.tag && + 5 === fiber.tag && ((JSCompiler_inline_result = createCapturedValue(error, fiber)), (JSCompiler_inline_result = createRootErrorUpdate( fiber, @@ -4992,22 +5107,20 @@ function captureCommitPhaseError(fiber, error) { return JSCompiler_inline_result; } function computeExpirationForFiber(currentTime, fiber) { - 0 !== expirationContext - ? (currentTime = expirationContext) - : isWorking - ? (currentTime = isCommitting$1 ? 1 : nextRenderExpirationTime) - : fiber.mode & 1 - ? ((currentTime = isBatchingInteractiveUpdates - ? 2 + 10 * ((((currentTime - 2 + 15) / 10) | 0) + 1) - : 2 + 25 * ((((currentTime - 2 + 500) / 25) | 0) + 1)), - null !== nextRoot && - currentTime === nextRenderExpirationTime && - (currentTime += 1)) - : (currentTime = 1); + isWorking + ? (currentTime = isCommitting$1 ? 1 : nextRenderExpirationTime) + : fiber.mode & 1 + ? ((currentTime = isBatchingInteractiveUpdates + ? 2 + 10 * ((((currentTime - 2 + 15) / 10) | 0) + 1) + : 2 + 25 * ((((currentTime - 2 + 500) / 25) | 0) + 1)), + null !== nextRoot && + currentTime === nextRenderExpirationTime && + (currentTime += 1)) + : (currentTime = 1); isBatchingInteractiveUpdates && - (0 === lowestPendingInteractiveExpirationTime || - currentTime > lowestPendingInteractiveExpirationTime) && - (lowestPendingInteractiveExpirationTime = currentTime); + (0 === lowestPriorityPendingInteractiveExpirationTime || + currentTime > lowestPriorityPendingInteractiveExpirationTime) && + (lowestPriorityPendingInteractiveExpirationTime = currentTime); return currentTime; } function scheduleWork(fiber, expirationTime) { @@ -5020,7 +5133,7 @@ function scheduleWork(fiber, expirationTime) { alternate.expirationTime > expirationTime) && (alternate.expirationTime = expirationTime); var node = fiber.return; - if (null === node && 3 === fiber.tag) fiber = fiber.stateNode; + if (null === node && 5 === fiber.tag) fiber = fiber.stateNode; else { for (; null !== node; ) { alternate = node.alternate; @@ -5033,7 +5146,7 @@ function scheduleWork(fiber, expirationTime) { (0 === alternate.childExpirationTime || alternate.childExpirationTime > expirationTime) && (alternate.childExpirationTime = expirationTime); - if (null === node.return && 3 === node.tag) { + if (null === node.return && 5 === node.tag) { fiber = node.stateNode; break a; } @@ -5042,28 +5155,43 @@ function scheduleWork(fiber, expirationTime) { fiber = null; } } - null !== fiber && - (!isWorking && + if (null !== fiber) { + !isWorking && 0 !== nextRenderExpirationTime && expirationTime < nextRenderExpirationTime && - resetStack(), - markPendingPriorityLevel(fiber, expirationTime), - (isWorking && !isCommitting$1 && nextRoot === fiber) || - requestWork(fiber, fiber.expirationTime), + resetStack(); + markPendingPriorityLevel(fiber, expirationTime); + if (!isWorking || isCommitting$1 || nextRoot !== fiber) { + expirationTime = fiber; + fiber = fiber.expirationTime; + if (null === expirationTime.nextScheduledRoot) + (expirationTime.expirationTime = fiber), + null === lastScheduledRoot + ? ((firstScheduledRoot = lastScheduledRoot = expirationTime), + (expirationTime.nextScheduledRoot = expirationTime)) + : ((lastScheduledRoot = lastScheduledRoot.nextScheduledRoot = expirationTime), + (lastScheduledRoot.nextScheduledRoot = firstScheduledRoot)); + else if ( + ((alternate = expirationTime.expirationTime), + 0 === alternate || fiber < alternate) + ) + expirationTime.expirationTime = fiber; + isRendering || + (isBatchingUpdates + ? isUnbatchingUpdates && + ((nextFlushedRoot = expirationTime), + (nextFlushedExpirationTime = 1), + performWorkOnRoot(expirationTime, 1, !0)) + : 1 === fiber + ? performWork(1, null) + : scheduleCallbackWithExpirationTime(expirationTime, fiber)); + } nestedUpdateCount > NESTED_UPDATE_LIMIT && ((nestedUpdateCount = 0), invariant( !1, "Maximum update depth exceeded. This can happen when a component repeatedly calls setState inside componentWillUpdate or componentDidUpdate. React limits the number of nested updates to prevent infinite loops." - ))); -} -function syncUpdates(fn, a, b, c, d) { - var previousExpirationContext = expirationContext; - expirationContext = 1; - try { - return fn(a, b, c, d); - } finally { - expirationContext = previousExpirationContext; + )); } } var firstScheduledRoot = null, @@ -5073,7 +5201,7 @@ var firstScheduledRoot = null, isRendering = !1, nextFlushedRoot = null, nextFlushedExpirationTime = 0, - lowestPendingInteractiveExpirationTime = 0, + lowestPriorityPendingInteractiveExpirationTime = 0, deadlineDidExpire = !1, hasUnhandledError = !1, unhandledError = null, @@ -5092,14 +5220,11 @@ var firstScheduledRoot = null, function recomputeCurrentRendererTime() { currentRendererTime = (((now$1() - originalStartTimeMs) / 10) | 0) + 2; } -function scheduleCallbackWithExpirationTime(expirationTime) { +function scheduleCallbackWithExpirationTime(root, expirationTime) { if (0 !== callbackExpirationTime) { if (expirationTime > callbackExpirationTime) return; - if (null !== callbackID) { - var callbackID$jscomp$0 = callbackID; - scheduledCallback = null; - clearTimeout(callbackID$jscomp$0); - } + null !== callbackID && + ((root = callbackID), (scheduledCallback = null), clearTimeout(root)); } callbackExpirationTime = expirationTime; now$1(); @@ -5117,32 +5242,6 @@ function requestCurrentTime() { (currentSchedulerTime = currentRendererTime); return currentSchedulerTime; } -function requestWork(root, expirationTime) { - if (null === root.nextScheduledRoot) - (root.expirationTime = expirationTime), - null === lastScheduledRoot - ? ((firstScheduledRoot = lastScheduledRoot = root), - (root.nextScheduledRoot = root)) - : ((lastScheduledRoot = lastScheduledRoot.nextScheduledRoot = root), - (lastScheduledRoot.nextScheduledRoot = firstScheduledRoot)); - else { - var remainingExpirationTime = root.expirationTime; - if ( - 0 === remainingExpirationTime || - expirationTime < remainingExpirationTime - ) - root.expirationTime = expirationTime; - } - isRendering || - (isBatchingUpdates - ? isUnbatchingUpdates && - ((nextFlushedRoot = root), - (nextFlushedExpirationTime = 1), - performWorkOnRoot(root, 1, !0)) - : 1 === expirationTime - ? performWork(1, null) - : scheduleCallbackWithExpirationTime(expirationTime)); -} function findHighestPriorityRoot() { var highestPriorityWork = 0, highestPriorityRoot = null; @@ -5183,6 +5282,7 @@ function findHighestPriorityRoot() { (highestPriorityWork = remainingExpirationTime), (highestPriorityRoot = root); if (root === lastScheduledRoot) break; + if (1 === highestPriorityWork) break; previousScheduledRoot = root; root = root.nextScheduledRoot; } @@ -5191,6 +5291,17 @@ function findHighestPriorityRoot() { nextFlushedExpirationTime = highestPriorityWork; } function performAsyncWork(dl) { + if (dl.didTimeout && null !== firstScheduledRoot) { + recomputeCurrentRendererTime(); + var root = firstScheduledRoot; + do { + var expirationTime = root.expirationTime; + 0 !== expirationTime && + currentRendererTime >= expirationTime && + (root.nextExpirationTimeToWorkOn = currentRendererTime); + root = root.nextScheduledRoot; + } while (root !== firstScheduledRoot); + } performWork(0, dl); } function performWork(minExpirationTime, dl) { @@ -5228,7 +5339,10 @@ function performWork(minExpirationTime, dl) { findHighestPriorityRoot(); null !== deadline && ((callbackExpirationTime = 0), (callbackID = null)); 0 !== nextFlushedExpirationTime && - scheduleCallbackWithExpirationTime(nextFlushedExpirationTime); + scheduleCallbackWithExpirationTime( + nextFlushedRoot, + nextFlushedExpirationTime + ); deadline = null; deadlineDidExpire = !1; nestedUpdateCount = 0; @@ -5356,33 +5470,36 @@ function completeRoot(root, finishedWork$jscomp$0, expirationTime) { try { for (; null !== nextEffect; ) { if (nextEffect.effectTag & 256) { - var current$$1 = nextEffect.alternate, - finishedWork = nextEffect; - switch (finishedWork.tag) { - case 2: - if (finishedWork.effectTag & 256 && null !== current$$1) { - var prevProps = current$$1.memoizedProps, - prevState = current$$1.memoizedState, - instance = finishedWork.stateNode; - instance.props = finishedWork.memoizedProps; - instance.state = finishedWork.memoizedState; - var snapshot = instance.getSnapshotBeforeUpdate( - prevProps, - prevState + var current$$1 = nextEffect.alternate; + a: { + var finishedWork = nextEffect; + switch (finishedWork.tag) { + case 2: + case 3: + if (finishedWork.effectTag & 256 && null !== current$$1) { + var prevProps = current$$1.memoizedProps, + prevState = current$$1.memoizedState, + instance = finishedWork.stateNode; + instance.props = finishedWork.memoizedProps; + instance.state = finishedWork.memoizedState; + var snapshot = instance.getSnapshotBeforeUpdate( + prevProps, + prevState + ); + instance.__reactInternalSnapshotBeforeUpdate = snapshot; + } + break a; + case 5: + case 7: + case 8: + case 6: + break a; + default: + invariant( + !1, + "This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue." ); - instance.__reactInternalSnapshotBeforeUpdate = snapshot; - } - break; - case 3: - case 5: - case 6: - case 4: - break; - default: - invariant( - !1, - "This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue." - ); + } } } nextEffect = nextEffect.nextEffect; @@ -5462,6 +5579,7 @@ function completeRoot(root, finishedWork$jscomp$0, expirationTime) { prevProps = currentRef; switch (current$$1.tag) { case 2: + case 3: var instance$jscomp$0 = current$$1.stateNode; if (current$$1.effectTag & 4) if (null === current$$1$jscomp$1) @@ -5490,16 +5608,17 @@ function completeRoot(root, finishedWork$jscomp$0, expirationTime) { prevProps )); break; - case 3: + case 5: var _updateQueue = current$$1.updateQueue; if (null !== _updateQueue) { prevState = null; if (null !== current$$1.child) switch (current$$1.child.tag) { - case 5: + case 7: prevState = current$$1.child.stateNode; break; case 2: + case 3: prevState = current$$1.child.stateNode; } commitUpdateQueue( @@ -5510,12 +5629,12 @@ function completeRoot(root, finishedWork$jscomp$0, expirationTime) { ); } break; - case 5: + case 7: + break; + case 8: break; case 6: break; - case 4: - break; case 15: break; case 16: @@ -5528,20 +5647,19 @@ function completeRoot(root, finishedWork$jscomp$0, expirationTime) { } } if (effectTag$jscomp$0 & 128) { - current$$1 = void 0; var ref = nextEffect.ref; if (null !== ref) { var instance$jscomp$1 = nextEffect.stateNode; switch (nextEffect.tag) { - case 5: - current$$1 = instance$jscomp$1; + case 7: + var instanceToUse = instance$jscomp$1; break; default: - current$$1 = instance$jscomp$1; + instanceToUse = instance$jscomp$1; } "function" === typeof ref - ? ref(current$$1) - : (ref.current = current$$1); + ? ref(instanceToUse) + : (ref.current = instanceToUse); } } var next = nextEffect.nextEffect; @@ -5589,51 +5707,54 @@ function onUncaughtError(error) { nextFlushedRoot.expirationTime = 0; hasUnhandledError || ((hasUnhandledError = !0), (unhandledError = error)); } -function updateContainerAtExpirationTime( - element, - container, - parentComponent, - expirationTime, - callback -) { - var current$$1 = container.current; - if (parentComponent) { - parentComponent = parentComponent._reactInternalFiber; - var parentContext; - b: { - invariant( - 2 === isFiberMountedImpl(parentComponent) && 2 === parentComponent.tag, - "Expected subtree parent to be a mounted class component. This error is likely caused by a bug in React. Please file an issue." - ); - for (parentContext = parentComponent; 3 !== parentContext.tag; ) { - if (isContextProvider(parentContext)) { - parentContext = - parentContext.stateNode.__reactInternalMemoizedMergedChildContext; - break b; - } - parentContext = parentContext.return; - invariant( - parentContext, - "Found unexpected detached subtree parent. This error is likely caused by a bug in React. Please file an issue." - ); +function getContextForSubtree(parentComponent) { + if (!parentComponent) return emptyContextObject; + parentComponent = parentComponent._reactInternalFiber; + a: { + invariant( + 2 === isFiberMountedImpl(parentComponent) && + (2 === parentComponent.tag || 3 === parentComponent.tag), + "Expected subtree parent to be a mounted class component. This error is likely caused by a bug in React. Please file an issue." + ); + var parentContext = parentComponent; + do { + switch (parentContext.tag) { + case 5: + parentContext = parentContext.stateNode.context; + break a; + case 2: + if (isContextProvider(parentContext.type)) { + parentContext = + parentContext.stateNode.__reactInternalMemoizedMergedChildContext; + break a; + } + break; + case 3: + if (isContextProvider(parentContext.type._reactResult)) { + parentContext = + parentContext.stateNode.__reactInternalMemoizedMergedChildContext; + break a; + } } - parentContext = parentContext.stateNode.context; - } - parentComponent = isContextProvider(parentComponent) - ? processChildContext(parentComponent, parentContext) - : parentContext; - } else parentComponent = emptyContextObject; - null === container.context - ? (container.context = parentComponent) - : (container.pendingContext = parentComponent); - container = callback; - callback = createUpdate(expirationTime); - callback.payload = { element: element }; - container = void 0 === container ? null : container; - null !== container && (callback.callback = container); - enqueueUpdate(current$$1, callback); - scheduleWork(current$$1, expirationTime); - return expirationTime; + parentContext = parentContext.return; + } while (null !== parentContext); + invariant( + !1, + "Found unexpected detached subtree parent. This error is likely caused by a bug in React. Please file an issue." + ); + parentContext = void 0; + } + if (2 === parentComponent.tag) { + var Component = parentComponent.type; + if (isContextProvider(Component)) + return processChildContext(parentComponent, Component, parentContext); + } else if ( + 3 === parentComponent.tag && + ((Component = parentComponent.type._reactResult), + isContextProvider(Component)) + ) + return processChildContext(parentComponent, Component, parentContext); + return parentContext; } function findHostInstance$1(component) { var fiber = component._reactInternalFiber; @@ -5652,153 +5773,20 @@ function updateContainer(element, container, parentComponent, callback) { var current$$1 = container.current, currentTime = requestCurrentTime(); current$$1 = computeExpirationForFiber(currentTime, current$$1); - return updateContainerAtExpirationTime( - element, - container, - parentComponent, - current$$1, - callback - ); + currentTime = container.current; + parentComponent = getContextForSubtree(parentComponent); + null === container.context + ? (container.context = parentComponent) + : (container.pendingContext = parentComponent); + container = callback; + callback = createUpdate(current$$1); + callback.payload = { element: element }; + container = void 0 === container ? null : container; + null !== container && (callback.callback = container); + enqueueUpdate(currentTime, callback); + scheduleWork(currentTime, current$$1); + return current$$1; } -function getPublicRootInstance(container) { - container = container.current; - if (!container.child) return null; - switch (container.child.tag) { - case 5: - return container.child.stateNode; - default: - return container.child.stateNode; - } -} -function injectIntoDevTools(devToolsConfig) { - var findFiberByHostInstance = devToolsConfig.findFiberByHostInstance; - return injectInternals( - Object.assign({}, devToolsConfig, { - findHostInstanceByFiber: function(fiber) { - fiber = findCurrentHostFiber(fiber); - return null === fiber ? null : fiber.stateNode; - }, - findFiberByHostInstance: function(instance) { - return findFiberByHostInstance - ? findFiberByHostInstance(instance) - : null; - } - }) - ); -} -var ReactNativeFiberRenderer = { - updateContainerAtExpirationTime: updateContainerAtExpirationTime, - createContainer: function(containerInfo, isAsync, hydrate) { - return createFiberRoot(containerInfo, isAsync, hydrate); - }, - updateContainer: updateContainer, - flushRoot: function(root, expirationTime) { - invariant( - !isRendering, - "work.commit(): Cannot commit while already rendering. This likely means you attempted to commit from inside a lifecycle method." - ); - nextFlushedRoot = root; - nextFlushedExpirationTime = expirationTime; - performWorkOnRoot(root, expirationTime, !0); - performWork(1, null); - }, - requestWork: requestWork, - computeUniqueAsyncExpiration: function() { - var result = 2 + 25 * ((((requestCurrentTime() - 2 + 500) / 25) | 0) + 1); - result <= lastUniqueAsyncExpiration && - (result = lastUniqueAsyncExpiration + 1); - return (lastUniqueAsyncExpiration = result); - }, - batchedUpdates: function(fn, a) { - var previousIsBatchingUpdates = isBatchingUpdates; - isBatchingUpdates = !0; - try { - return fn(a); - } finally { - (isBatchingUpdates = previousIsBatchingUpdates) || - isRendering || - performWork(1, null); - } - }, - unbatchedUpdates: function(fn, a) { - if (isBatchingUpdates && !isUnbatchingUpdates) { - isUnbatchingUpdates = !0; - try { - return fn(a); - } finally { - isUnbatchingUpdates = !1; - } - } - return fn(a); - }, - deferredUpdates: function(fn) { - var currentTime = requestCurrentTime(), - previousExpirationContext = expirationContext; - expirationContext = 2 + 25 * ((((currentTime - 2 + 500) / 25) | 0) + 1); - try { - return fn(); - } finally { - expirationContext = previousExpirationContext; - } - }, - syncUpdates: syncUpdates, - interactiveUpdates: function(fn, a, b) { - if (isBatchingInteractiveUpdates) return fn(a, b); - isBatchingUpdates || - isRendering || - 0 === lowestPendingInteractiveExpirationTime || - (performWork(lowestPendingInteractiveExpirationTime, null), - (lowestPendingInteractiveExpirationTime = 0)); - var previousIsBatchingInteractiveUpdates = isBatchingInteractiveUpdates, - previousIsBatchingUpdates = isBatchingUpdates; - isBatchingUpdates = isBatchingInteractiveUpdates = !0; - try { - return fn(a, b); - } finally { - (isBatchingInteractiveUpdates = previousIsBatchingInteractiveUpdates), - (isBatchingUpdates = previousIsBatchingUpdates) || - isRendering || - performWork(1, null); - } - }, - flushInteractiveUpdates: function() { - isRendering || - 0 === lowestPendingInteractiveExpirationTime || - (performWork(lowestPendingInteractiveExpirationTime, null), - (lowestPendingInteractiveExpirationTime = 0)); - }, - flushControlled: function(fn) { - var previousIsBatchingUpdates = isBatchingUpdates; - isBatchingUpdates = !0; - try { - syncUpdates(fn); - } finally { - (isBatchingUpdates = previousIsBatchingUpdates) || - isRendering || - performWork(1, null); - } - }, - flushSync: function(fn, a) { - invariant( - !isRendering, - "flushSync was called from inside a lifecycle method. It cannot be called when React is already rendering." - ); - var previousIsBatchingUpdates = isBatchingUpdates; - isBatchingUpdates = !0; - try { - return syncUpdates(fn, a); - } finally { - (isBatchingUpdates = previousIsBatchingUpdates), performWork(1, null); - } - }, - getPublicRootInstance: getPublicRootInstance, - findHostInstance: findHostInstance$1, - findHostInstanceWithNoPortals: function(fiber) { - fiber = findCurrentHostFiberWithNoPortals(fiber); - return null === fiber ? null : fiber.stateNode; - }, - injectIntoDevTools: injectIntoDevTools -}; function createPortal(children, containerInfo, implementation) { var key = 3 < arguments.length && void 0 !== arguments[3] ? arguments[3] : null; @@ -5846,8 +5834,23 @@ function findNodeHandle(componentOrHandle) { ? componentOrHandle.canonical._nativeTag : componentOrHandle._nativeTag; } -_batchedUpdates = ReactNativeFiberRenderer.batchedUpdates; -_flushInteractiveUpdates = ReactNativeFiberRenderer.flushInteractiveUpdates; +_batchedUpdatesImpl = function(fn, a) { + var previousIsBatchingUpdates = isBatchingUpdates; + isBatchingUpdates = !0; + try { + return fn(a); + } finally { + (isBatchingUpdates = previousIsBatchingUpdates) || + isRendering || + performWork(1, null); + } +}; +_flushInteractiveUpdatesImpl = function() { + isRendering || + 0 === lowestPriorityPendingInteractiveExpirationTime || + (performWork(lowestPriorityPendingInteractiveExpirationTime, null), + (lowestPriorityPendingInteractiveExpirationTime = 0)); +}; var roots = new Map(), ReactNativeRenderer = { NativeComponent: (function(findNodeHandle, findHostInstance) { @@ -5875,13 +5878,13 @@ var roots = new Map(), ReactNativeComponent.prototype.measure = function(callback) { UIManager.measure( findNodeHandle(this), - mountSafeCallback(this, callback) + mountSafeCallback_NOT_REALLY_SAFE(this, callback) ); }; ReactNativeComponent.prototype.measureInWindow = function(callback) { UIManager.measureInWindow( findNodeHandle(this), - mountSafeCallback(this, callback) + mountSafeCallback_NOT_REALLY_SAFE(this, callback) ); }; ReactNativeComponent.prototype.measureLayout = function( @@ -5892,8 +5895,8 @@ var roots = new Map(), UIManager.measureLayout( findNodeHandle(this), relativeToNativeNode, - mountSafeCallback(this, onFail), - mountSafeCallback(this, onSuccess) + mountSafeCallback_NOT_REALLY_SAFE(this, onFail), + mountSafeCallback_NOT_REALLY_SAFE(this, onSuccess) ); }; ReactNativeComponent.prototype.setNativeProps = function(nativeProps) { @@ -5924,11 +5927,43 @@ var roots = new Map(), findNodeHandle: findNodeHandle, render: function(element, containerTag, callback) { var root = roots.get(containerTag); - root || - ((root = createFiberRoot(containerTag, !1, !1)), - roots.set(containerTag, root)); + if (!root) { + root = new FiberNode(5, null, null, 0); + var root$jscomp$0 = { + current: root, + containerInfo: containerTag, + pendingChildren: null, + earliestPendingTime: 0, + latestPendingTime: 0, + earliestSuspendedTime: 0, + latestSuspendedTime: 0, + latestPingedTime: 0, + didError: !1, + pendingCommitExpirationTime: 0, + finishedWork: null, + timeoutHandle: -1, + context: null, + pendingContext: null, + hydrate: !1, + nextExpirationTimeToWorkOn: 0, + expirationTime: 0, + firstBatch: null, + nextScheduledRoot: null + }; + root = root.stateNode = root$jscomp$0; + roots.set(containerTag, root); + } updateContainer(element, root, null, callback); - return getPublicRootInstance(root); + a: if (((element = root.current), element.child)) + switch (element.child.tag) { + case 7: + element = element.child.stateNode; + break a; + default: + element = element.child.stateNode; + } + else element = null; + return element; }, unmountComponentAtNode: function(containerTag) { var root = roots.get(containerTag); @@ -5956,21 +5991,21 @@ var roots = new Map(), measure: function(callback) { UIManager.measure( findNodeHandle(this), - mountSafeCallback(this, callback) + mountSafeCallback_NOT_REALLY_SAFE(this, callback) ); }, measureInWindow: function(callback) { UIManager.measureInWindow( findNodeHandle(this), - mountSafeCallback(this, callback) + mountSafeCallback_NOT_REALLY_SAFE(this, callback) ); }, measureLayout: function(relativeToNativeNode, onSuccess, onFail) { UIManager.measureLayout( findNodeHandle(this), relativeToNativeNode, - mountSafeCallback(this, onFail), - mountSafeCallback(this, onSuccess) + mountSafeCallback_NOT_REALLY_SAFE(this, onFail), + mountSafeCallback_NOT_REALLY_SAFE(this, onSuccess) ); }, setNativeProps: function(nativeProps) { @@ -6009,16 +6044,29 @@ var roots = new Map(), } } }; -injectIntoDevTools({ +(function(devToolsConfig) { + var findFiberByHostInstance = devToolsConfig.findFiberByHostInstance; + return injectInternals( + Object.assign({}, devToolsConfig, { + findHostInstanceByFiber: function(fiber) { + fiber = findCurrentHostFiber(fiber); + return null === fiber ? null : fiber.stateNode; + }, + findFiberByHostInstance: function(instance) { + return findFiberByHostInstance + ? findFiberByHostInstance(instance) + : null; + } + }) + ); +})({ findFiberByHostInstance: getInstanceFromTag, getInspectorDataForViewTag: getInspectorDataForViewTag, bundleType: 0, - version: "16.4.1", + version: "16.5.0", rendererPackageName: "react-native-renderer" }); var ReactNativeRenderer$2 = { default: ReactNativeRenderer }, ReactNativeRenderer$3 = (ReactNativeRenderer$2 && ReactNativeRenderer) || ReactNativeRenderer$2; -module.exports = ReactNativeRenderer$3.default - ? ReactNativeRenderer$3.default - : ReactNativeRenderer$3; +module.exports = ReactNativeRenderer$3.default || ReactNativeRenderer$3; diff --git a/Libraries/Renderer/oss/ReactNativeRenderer-profiling.js b/Libraries/Renderer/oss/ReactNativeRenderer-profiling.js index 6ef889e1d..f9c2b56db 100644 --- a/Libraries/Renderer/oss/ReactNativeRenderer-profiling.js +++ b/Libraries/Renderer/oss/ReactNativeRenderer-profiling.js @@ -1,5 +1,5 @@ /** - * Copyright (c) 2013-present, Facebook, Inc. + * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. @@ -19,6 +19,7 @@ var ReactNativeViewConfigRegistry = require("ReactNativeViewConfigRegistry"), deepDiffer = require("deepDiffer"), flattenStyle = require("flattenStyle"), TextInputState = require("TextInputState"), + tracking = require("schedule/tracking"), ExceptionsManager = require("ExceptionsManager"); function invariant(condition, format, a, b, c, d, e, f) { if (!condition) { @@ -41,68 +42,53 @@ function invariant(condition, format, a, b, c, d, e, f) { throw condition; } } -function invokeGuardedCallback(name, func, context, a, b, c, d, e, f) { - this._hasCaughtError = !1; - this._caughtError = null; +function invokeGuardedCallbackImpl(name, func, context, a, b, c, d, e, f) { var funcArgs = Array.prototype.slice.call(arguments, 3); try { func.apply(context, funcArgs); } catch (error) { - (this._caughtError = error), (this._hasCaughtError = !0); + this.onError(error); } } -var ReactErrorUtils = { - _caughtError: null, - _hasCaughtError: !1, - _rethrowError: null, - _hasRethrowError: !1, - invokeGuardedCallback: function(name, func, context, a, b, c, d, e, f) { - invokeGuardedCallback.apply(ReactErrorUtils, arguments); - }, - invokeGuardedCallbackAndCatchFirstError: function( - name, - func, - context, - a, - b, - c, - d, - e, - f - ) { - ReactErrorUtils.invokeGuardedCallback.apply(this, arguments); - if (ReactErrorUtils.hasCaughtError()) { - var error = ReactErrorUtils.clearCaughtError(); - ReactErrorUtils._hasRethrowError || - ((ReactErrorUtils._hasRethrowError = !0), - (ReactErrorUtils._rethrowError = error)); +var hasError = !1, + caughtError = null, + hasRethrowError = !1, + rethrowError = null, + reporter = { + onError: function(error) { + hasError = !0; + caughtError = error; } - }, - rethrowCaughtError: function() { - return rethrowCaughtError.apply(ReactErrorUtils, arguments); - }, - hasCaughtError: function() { - return ReactErrorUtils._hasCaughtError; - }, - clearCaughtError: function() { - if (ReactErrorUtils._hasCaughtError) { - var error = ReactErrorUtils._caughtError; - ReactErrorUtils._caughtError = null; - ReactErrorUtils._hasCaughtError = !1; - return error; - } - invariant( - !1, - "clearCaughtError was called but no error was captured. This error is likely caused by a bug in React. Please file an issue." - ); - } -}; -function rethrowCaughtError() { - if (ReactErrorUtils._hasRethrowError) { - var error = ReactErrorUtils._rethrowError; - ReactErrorUtils._rethrowError = null; - ReactErrorUtils._hasRethrowError = !1; - throw error; + }; +function invokeGuardedCallback(name, func, context, a, b, c, d, e, f) { + hasError = !1; + caughtError = null; + invokeGuardedCallbackImpl.apply(reporter, arguments); +} +function invokeGuardedCallbackAndCatchFirstError( + name, + func, + context, + a, + b, + c, + d, + e, + f +) { + invokeGuardedCallback.apply(this, arguments); + if (hasError) { + if (hasError) { + var error = caughtError; + hasError = !1; + caughtError = null; + } else + invariant( + !1, + "clearCaughtError was called but no error was captured. This error is likely caused by a bug in React. Please file an issue." + ), + (error = void 0); + hasRethrowError || ((hasRethrowError = !0), (rethrowError = error)); } } var eventPluginOrder = null, @@ -184,12 +170,7 @@ var plugins = [], function executeDispatch(event, simulated, listener, inst) { simulated = event.type || "unknown-event"; event.currentTarget = getNodeFromInstance(inst); - ReactErrorUtils.invokeGuardedCallbackAndCatchFirstError( - simulated, - listener, - void 0, - event - ); + invokeGuardedCallbackAndCatchFirstError(simulated, listener, void 0, event); event.currentTarget = null; } function executeDirectDispatch(event) { @@ -313,7 +294,7 @@ function getListener(inst, registrationName) { } function getParent(inst) { do inst = inst.return; - while (inst && 5 !== inst.tag); + while (inst && 7 !== inst.tag); return inst ? inst : null; } function traverseTwoPhase(inst, fn, arg) { @@ -1019,59 +1000,35 @@ injection.injectEventPluginsByName({ }); var instanceCache = {}, instanceProps = {}; -function uncacheFiberNode(tag) { - delete instanceCache[tag]; - delete instanceProps[tag]; -} function getInstanceFromTag(tag) { return instanceCache[tag] || null; } -var ReactNativeComponentTree = { - precacheFiberNode: function(hostInst, tag) { - instanceCache[tag] = hostInst; - }, - uncacheFiberNode: uncacheFiberNode, - getClosestInstanceFromNode: getInstanceFromTag, - getInstanceFromNode: getInstanceFromTag, - getNodeFromInstance: function(inst) { - var tag = inst.stateNode._nativeTag; - void 0 === tag && (tag = inst.stateNode.canonical._nativeTag); - invariant(tag, "All native instances should have a tag."); - return tag; - }, - getFiberCurrentPropsFromNode: function(stateNode) { - return instanceProps[stateNode._nativeTag] || null; - }, - updateFiberProps: function(tag, props) { - instanceProps[tag] = props; - } - }, - restoreTarget = null, +var restoreTarget = null, restoreQueue = null; function restoreStateOfTarget(target) { if ((target = getInstanceFromNode(target))) { invariant( - null, - "Fiber needs to be injected to handle a fiber target for controlled events. This error is likely caused by a bug in React. Please file an issue." + !1, + "setRestoreImplementation() needs to be called to handle a target for controlled events. This error is likely caused by a bug in React. Please file an issue." ); var props = getFiberCurrentPropsFromNode(target.stateNode); - null.restoreControlledState(target.stateNode, target.type, props); + null(target.stateNode, target.type, props); } } -function _batchedUpdates(fn, bookkeeping) { +function _batchedUpdatesImpl(fn, bookkeeping) { return fn(bookkeeping); } -function _flushInteractiveUpdates() {} +function _flushInteractiveUpdatesImpl() {} var isBatching = !1; function batchedUpdates(fn, bookkeeping) { if (isBatching) return fn(bookkeeping); isBatching = !0; try { - return _batchedUpdates(fn, bookkeeping); + return _batchedUpdatesImpl(fn, bookkeeping); } finally { if (((isBatching = !1), null !== restoreTarget || null !== restoreQueue)) if ( - (_flushInteractiveUpdates(), + (_flushInteractiveUpdatesImpl(), restoreTarget && ((bookkeeping = restoreTarget), (fn = restoreQueue), @@ -1104,13 +1061,19 @@ function _receiveRootNodeIDEvent(rootNodeID, topLevelType, nativeEventParam) { null !== events && (eventQueue = accumulateInto(eventQueue, events)); events = eventQueue; eventQueue = null; - events && + if ( + events && (forEachAccumulated(events, executeDispatchesAndReleaseTopLevel), invariant( !eventQueue, "processEventQueue(): Additional events were enqueued while processing an event queue. Support for this has not yet been implemented." ), - ReactErrorUtils.rethrowCaughtError()); + hasRethrowError) + ) + throw ((events = rethrowError), + (hasRethrowError = !1), + (rethrowError = null), + events); }); } RCTEventEmitter.register({ @@ -1153,10 +1116,16 @@ RCTEventEmitter.register({ } } }); -getFiberCurrentPropsFromNode = - ReactNativeComponentTree.getFiberCurrentPropsFromNode; -getInstanceFromNode = ReactNativeComponentTree.getInstanceFromNode; -getNodeFromInstance = ReactNativeComponentTree.getNodeFromInstance; +getFiberCurrentPropsFromNode = function(stateNode) { + return instanceProps[stateNode._nativeTag] || null; +}; +getInstanceFromNode = getInstanceFromTag; +getNodeFromInstance = function(inst) { + var tag = inst.stateNode._nativeTag; + void 0 === tag && (tag = inst.stateNode.canonical._nativeTag); + invariant(tag, "All native instances should have a tag."); + return tag; +}; ResponderEventPlugin.injection.injectGlobalResponderHandler({ onChange: function(from, to, blockNativeResponder) { null !== to @@ -1179,8 +1148,7 @@ var ReactSharedInternals = REACT_PLACEHOLDER_TYPE = hasSymbol ? Symbol.for("react.placeholder") : 60113, MAYBE_ITERATOR_SYMBOL = "function" === typeof Symbol && Symbol.iterator; function getIteratorFn(maybeIterable) { - if (null === maybeIterable || "undefined" === typeof maybeIterable) - return null; + if (null === maybeIterable || "object" !== typeof maybeIterable) return null; maybeIterable = (MAYBE_ITERATOR_SYMBOL && maybeIterable[MAYBE_ITERATOR_SYMBOL]) || maybeIterable["@@iterator"]; @@ -1204,7 +1172,7 @@ function getComponentName(type) { case REACT_PLACEHOLDER_TYPE: return "Placeholder"; } - if ("object" === typeof type) + if ("object" === typeof type) { switch (type.$$typeof) { case REACT_CONTEXT_TYPE: return "Context.Consumer"; @@ -1217,6 +1185,12 @@ function getComponentName(type) { "" !== type ? "ForwardRef(" + type + ")" : "ForwardRef" ); } + if ( + "function" === typeof type.then && + (type = 1 === type._reactStatus ? type._reactResult : null) + ) + return getComponentName(type); + } return null; } function isFiberMountedImpl(fiber) { @@ -1227,7 +1201,7 @@ function isFiberMountedImpl(fiber) { for (; node.return; ) if (((node = node.return), 0 !== (node.effectTag & 2))) return 1; } - return 3 === node.tag ? 2 : 3; + return 5 === node.tag ? 2 : 3; } function assertIsMounted(fiber) { invariant( @@ -1303,14 +1277,14 @@ function findCurrentFiberUsingSlowPath(fiber) { "Return fibers should always be each others' alternates. This error is likely caused by a bug in React. Please file an issue." ); } - invariant(3 === a.tag, "Unable to find node on an unmounted component."); + invariant(5 === a.tag, "Unable to find node on an unmounted component."); return a.stateNode.current === a ? fiber : alternate; } function findCurrentHostFiber(parent) { parent = findCurrentFiberUsingSlowPath(parent); if (!parent) return null; for (var node = parent; ; ) { - if (5 === node.tag || 6 === node.tag) return node; + if (7 === node.tag || 8 === node.tag) return node; if (node.child) (node.child.return = node), (node = node.child); else { if (node === parent) break; @@ -1324,25 +1298,6 @@ function findCurrentHostFiber(parent) { } return null; } -function findCurrentHostFiberWithNoPortals(parent) { - parent = findCurrentFiberUsingSlowPath(parent); - if (!parent) return null; - for (var node = parent; ; ) { - if (5 === node.tag || 6 === node.tag) return node; - if (node.child && 4 !== node.tag) - (node.child.return = node), (node = node.child); - else { - if (node === parent) break; - for (; !node.sibling; ) { - if (!node.return || node.return === parent) return null; - node = node.return; - } - node.sibling.return = node.return; - node = node.sibling; - } - } - return null; -} var emptyObject = {}, removedKeys = null, removedKeyCount = 0; @@ -1361,23 +1316,23 @@ function restoreDeletedValuesInNestedArray( else if (node && 0 < removedKeyCount) for (i in removedKeys) if (removedKeys[i]) { - var _nextProp = node[i]; - if (void 0 !== _nextProp) { + var nextProp = node[i]; + if (void 0 !== nextProp) { var attributeConfig = validAttributes[i]; if (attributeConfig) { - "function" === typeof _nextProp && (_nextProp = !0); - "undefined" === typeof _nextProp && (_nextProp = null); + "function" === typeof nextProp && (nextProp = !0); + "undefined" === typeof nextProp && (nextProp = null); if ("object" !== typeof attributeConfig) - updatePayload[i] = _nextProp; + updatePayload[i] = nextProp; else if ( "function" === typeof attributeConfig.diff || "function" === typeof attributeConfig.process ) - (_nextProp = + (nextProp = "function" === typeof attributeConfig.process - ? attributeConfig.process(_nextProp) - : _nextProp), - (updatePayload[i] = _nextProp); + ? attributeConfig.process(nextProp) + : nextProp), + (updatePayload[i] = nextProp); removedKeys[i] = !1; removedKeyCount--; } @@ -1561,18 +1516,13 @@ function diffProperties(updatePayload, prevProps, nextProps, validAttributes) { ))))); return updatePayload; } -function mountSafeCallback(context, callback) { +function mountSafeCallback_NOT_REALLY_SAFE(context, callback) { return function() { - if (callback) { - if ("boolean" === typeof context.__isMounted) { - if (!context.__isMounted) return; - } else if ( - "function" === typeof context.isMounted && - !context.isMounted() - ) - return; + if ( + callback && + ("boolean" !== typeof context.__isMounted || context.__isMounted) + ) return callback.apply(context, arguments); - } }; } var ReactNativeFiberHostComponent = (function() { @@ -1590,14 +1540,17 @@ var ReactNativeFiberHostComponent = (function() { TextInputState.focusTextInput(this._nativeTag); }; ReactNativeFiberHostComponent.prototype.measure = function(callback) { - UIManager.measure(this._nativeTag, mountSafeCallback(this, callback)); + UIManager.measure( + this._nativeTag, + mountSafeCallback_NOT_REALLY_SAFE(this, callback) + ); }; ReactNativeFiberHostComponent.prototype.measureInWindow = function( callback ) { UIManager.measureInWindow( this._nativeTag, - mountSafeCallback(this, callback) + mountSafeCallback_NOT_REALLY_SAFE(this, callback) ); }; ReactNativeFiberHostComponent.prototype.measureLayout = function( @@ -1608,8 +1561,8 @@ var ReactNativeFiberHostComponent = (function() { UIManager.measureLayout( this._nativeTag, relativeToNativeNode, - mountSafeCallback(this, onFail), - mountSafeCallback(this, onSuccess) + mountSafeCallback_NOT_REALLY_SAFE(this, onFail), + mountSafeCallback_NOT_REALLY_SAFE(this, onSuccess) ); }; ReactNativeFiberHostComponent.prototype.setNativeProps = function( @@ -1667,10 +1620,14 @@ function allocateTag() { return tag; } function recursivelyUncacheFiberNode(node) { - "number" === typeof node - ? uncacheFiberNode(node) - : (uncacheFiberNode(node._nativeTag), - node._children.forEach(recursivelyUncacheFiberNode)); + if ("number" === typeof node) + delete instanceCache[node], delete instanceProps[node]; + else { + var tag = node._nativeTag; + delete instanceCache[tag]; + delete instanceProps[tag]; + node._children.forEach(recursivelyUncacheFiberNode); + } } function finalizeInitialChildren(parentInstance) { if (0 === parentInstance._children.length) return !1; @@ -1680,33 +1637,36 @@ function finalizeInitialChildren(parentInstance) { UIManager.setChildren(parentInstance._nativeTag, nativeTags); return !1; } +var scheduleTimeout = setTimeout, + BEFORE_SLASH_RE = /^(.*)[\\\/]/; function getStackByFiberInDevAndProd(workInProgress) { var info = ""; do { a: switch (workInProgress.tag) { + case 4: case 0: case 1: case 2: - case 5: - case 11: + case 3: + case 7: + case 10: var owner = workInProgress._debugOwner, - source = workInProgress._debugSource; - var JSCompiler_inline_result = getComponentName(workInProgress.type); - var ownerName = null; - owner && (ownerName = getComponentName(owner.type)); - owner = source; - JSCompiler_inline_result = - "\n in " + - (JSCompiler_inline_result || "Unknown") + - (owner - ? " (at " + - owner.fileName.replace(/^.*[\\\/]/, "") + + source = workInProgress._debugSource, + name = getComponentName(workInProgress.type); + var JSCompiler_inline_result = null; + owner && (JSCompiler_inline_result = getComponentName(owner.type)); + owner = name; + name = ""; + source + ? (name = + " (at " + + source.fileName.replace(BEFORE_SLASH_RE, "") + ":" + - owner.lineNumber + - ")" - : ownerName - ? " (created by " + ownerName + ")" - : ""); + source.lineNumber + + ")") + : JSCompiler_inline_result && + (name = " (created by " + JSCompiler_inline_result + ")"); + JSCompiler_inline_result = "\n in " + (owner || "Unknown") + name; break a; default: JSCompiler_inline_result = ""; @@ -1732,11 +1692,6 @@ var emptyContextObject = {}, contextStackCursor = { current: emptyContextObject }, didPerformWorkStackCursor = { current: !1 }, previousContext = emptyContextObject; -function getUnmaskedContext(workInProgress) { - return isContextProvider(workInProgress) - ? previousContext - : contextStackCursor.current; -} function getMaskedContext(workInProgress, unmaskedContext) { var contextTypes = workInProgress.type.contextTypes; if (!contextTypes) return emptyContextObject; @@ -1755,12 +1710,13 @@ function getMaskedContext(workInProgress, unmaskedContext) { (workInProgress.__reactInternalMemoizedMaskedChildContext = context)); return context; } -function isContextProvider(fiber) { - return 2 === fiber.tag && null != fiber.type.childContextTypes; +function isContextProvider(type) { + type = type.childContextTypes; + return null !== type && void 0 !== type; } -function popContextProvider(fiber) { - isContextProvider(fiber) && - (pop(didPerformWorkStackCursor, fiber), pop(contextStackCursor, fiber)); +function popContext(fiber) { + pop(didPerformWorkStackCursor, fiber); + pop(contextStackCursor, fiber); } function popTopLevelContextObject(fiber) { pop(didPerformWorkStackCursor, fiber); @@ -1774,23 +1730,21 @@ function pushTopLevelContextObject(fiber, context, didChange) { push(contextStackCursor, context, fiber); push(didPerformWorkStackCursor, didChange, fiber); } -function processChildContext(fiber, parentContext) { +function processChildContext(fiber, type, parentContext) { var instance = fiber.stateNode; - fiber = fiber.type; - var childContextTypes = fiber.childContextTypes; + fiber = type.childContextTypes; if ("function" !== typeof instance.getChildContext) return parentContext; instance = instance.getChildContext(); for (var contextKey in instance) invariant( - contextKey in childContextTypes, + contextKey in fiber, '%s.getChildContext(): key "%s" is not defined in childContextTypes.', - getComponentName(fiber) || "Unknown", + getComponentName(type) || "Unknown", contextKey ); return Object.assign({}, parentContext, instance); } function pushContextProvider(workInProgress) { - if (!isContextProvider(workInProgress)) return !1; var instance = workInProgress.stateNode; instance = (instance && instance.__reactInternalMemoizedMergedChildContext) || @@ -1804,19 +1758,19 @@ function pushContextProvider(workInProgress) { ); return !0; } -function invalidateContextProvider(workInProgress, didChange) { +function invalidateContextProvider(workInProgress, type, didChange) { var instance = workInProgress.stateNode; invariant( instance, "Expected to have an instance by this point. This error is likely caused by a bug in React. Please file an issue." ); - if (didChange) { - var mergedContext = processChildContext(workInProgress, previousContext); - instance.__reactInternalMemoizedMergedChildContext = mergedContext; - pop(didPerformWorkStackCursor, workInProgress); - pop(contextStackCursor, workInProgress); - push(contextStackCursor, mergedContext, workInProgress); - } else pop(didPerformWorkStackCursor, workInProgress); + didChange + ? ((type = processChildContext(workInProgress, type, previousContext)), + (instance.__reactInternalMemoizedMergedChildContext = type), + pop(didPerformWorkStackCursor, workInProgress), + pop(contextStackCursor, workInProgress), + push(contextStackCursor, type, workInProgress)) + : pop(didPerformWorkStackCursor, workInProgress); push(didPerformWorkStackCursor, didChange, workInProgress); } var onCommitFiberRoot = null, @@ -1857,7 +1811,13 @@ function FiberNode(tag, pendingProps, key, mode) { this.lastEffect = this.firstEffect = this.nextEffect = null; this.childExpirationTime = this.expirationTime = 0; this.alternate = null; - this.treeBaseDuration = this.selfBaseDuration = this.actualStartTime = this.actualDuration = 0; + this.actualDuration = 0; + this.actualStartTime = -1; + this.treeBaseDuration = this.selfBaseDuration = 0; +} +function shouldConstruct(Component) { + Component = Component.prototype; + return !(!Component || !Component.isReactComponent); } function createWorkInProgress(current, pendingProps, expirationTime) { var workInProgress = current.alternate; @@ -1878,7 +1838,7 @@ function createWorkInProgress(current, pendingProps, expirationTime) { (workInProgress.firstEffect = null), (workInProgress.lastEffect = null), (workInProgress.actualDuration = 0), - (workInProgress.actualStartTime = 0)); + (workInProgress.actualStartTime = -1)); workInProgress.childExpirationTime = current.childExpirationTime; workInProgress.expirationTime = pendingProps !== current.pendingProps @@ -1900,11 +1860,11 @@ function createFiberFromElement(element, mode, expirationTime) { var type = element.type, key = element.key; element = element.props; - if ("function" === typeof type) - var fiberTag = type.prototype && type.prototype.isReactComponent ? 2 : 0; - else if ("string" === typeof type) fiberTag = 5; + var fiberTag = void 0; + if ("function" === typeof type) fiberTag = shouldConstruct(type) ? 2 : 4; + else if ("string" === typeof type) fiberTag = 7; else - switch (type) { + a: switch (type) { case REACT_FRAGMENT_TYPE: return createFiberFromFragment( element.children, @@ -1913,11 +1873,11 @@ function createFiberFromElement(element, mode, expirationTime) { key ); case REACT_ASYNC_MODE_TYPE: - fiberTag = 11; + fiberTag = 10; mode |= 3; break; case REACT_STRICT_MODE_TYPE: - fiberTag = 11; + fiberTag = 10; mode |= 2; break; case REACT_PROFILER_TYPE: @@ -1931,29 +1891,29 @@ function createFiberFromElement(element, mode, expirationTime) { fiberTag = 16; break; default: - a: { - switch ( - "object" === typeof type && null !== type ? type.$$typeof : null - ) { + if ("object" === typeof type && null !== type) + switch (type.$$typeof) { case REACT_PROVIDER_TYPE: - fiberTag = 13; - break a; - case REACT_CONTEXT_TYPE: fiberTag = 12; break a; + case REACT_CONTEXT_TYPE: + fiberTag = 11; + break a; case REACT_FORWARD_REF_TYPE: - fiberTag = 14; + fiberTag = 13; break a; default: - invariant( - !1, - "Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s", - null == type ? type : typeof type, - "" - ); + if ("function" === typeof type.then) { + fiberTag = 4; + break a; + } } - fiberTag = void 0; - } + invariant( + !1, + "Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s", + null == type ? type : typeof type, + "" + ); } mode = new FiberNode(fiberTag, element, key, mode); mode.type = type; @@ -1961,18 +1921,18 @@ function createFiberFromElement(element, mode, expirationTime) { return mode; } function createFiberFromFragment(elements, mode, expirationTime, key) { - elements = new FiberNode(10, elements, key, mode); + elements = new FiberNode(9, elements, key, mode); elements.expirationTime = expirationTime; return elements; } function createFiberFromText(content, mode, expirationTime) { - content = new FiberNode(6, content, null, mode); + content = new FiberNode(8, content, null, mode); content.expirationTime = expirationTime; return content; } function createFiberFromPortal(portal, mode, expirationTime) { mode = new FiberNode( - 4, + 6, null !== portal.children ? portal.children : [], portal.key, mode @@ -1985,33 +1945,6 @@ function createFiberFromPortal(portal, mode, expirationTime) { }; return mode; } -function createFiberRoot(containerInfo, isAsync, hydrate) { - isAsync = isAsync ? 3 : 0; - isDevToolsPresent && (isAsync |= 4); - isAsync = new FiberNode(3, null, null, isAsync); - containerInfo = { - current: isAsync, - containerInfo: containerInfo, - pendingChildren: null, - earliestPendingTime: 0, - latestPendingTime: 0, - earliestSuspendedTime: 0, - latestSuspendedTime: 0, - latestPingedTime: 0, - didError: !1, - pendingCommitExpirationTime: 0, - finishedWork: null, - timeoutHandle: -1, - context: null, - pendingContext: null, - hydrate: hydrate, - nextExpirationTimeToWorkOn: 0, - expirationTime: 0, - firstBatch: null, - nextScheduledRoot: null - }; - return (isAsync.stateNode = containerInfo); -} function markPendingPriorityLevel(root, expirationTime) { root.didError = !1; var earliestPendingTime = root.earliestPendingTime; @@ -2023,6 +1956,70 @@ function markPendingPriorityLevel(root, expirationTime) { (root.latestPendingTime = expirationTime); findNextExpirationTimeToWorkOn(expirationTime, root); } +function markCommittedPriorityLevels(root, earliestRemainingTime) { + root.didError = !1; + if (0 === earliestRemainingTime) + (root.earliestPendingTime = 0), + (root.latestPendingTime = 0), + (root.earliestSuspendedTime = 0), + (root.latestSuspendedTime = 0), + (root.latestPingedTime = 0); + else { + var latestPendingTime = root.latestPendingTime; + 0 !== latestPendingTime && + (latestPendingTime < earliestRemainingTime + ? (root.earliestPendingTime = root.latestPendingTime = 0) + : root.earliestPendingTime < earliestRemainingTime && + (root.earliestPendingTime = root.latestPendingTime)); + latestPendingTime = root.earliestSuspendedTime; + 0 === latestPendingTime + ? markPendingPriorityLevel(root, earliestRemainingTime) + : earliestRemainingTime > root.latestSuspendedTime + ? ((root.earliestSuspendedTime = 0), + (root.latestSuspendedTime = 0), + (root.latestPingedTime = 0), + markPendingPriorityLevel(root, earliestRemainingTime)) + : earliestRemainingTime < latestPendingTime && + markPendingPriorityLevel(root, earliestRemainingTime); + } + findNextExpirationTimeToWorkOn(0, root); +} +function hasLowerPriorityWork(root, erroredExpirationTime) { + var latestPendingTime = root.latestPendingTime, + latestSuspendedTime = root.latestSuspendedTime; + root = root.latestPingedTime; + return ( + (0 !== latestPendingTime && latestPendingTime > erroredExpirationTime) || + (0 !== latestSuspendedTime && + latestSuspendedTime > erroredExpirationTime) || + (0 !== root && root > erroredExpirationTime) + ); +} +function markSuspendedPriorityLevel(root, suspendedTime) { + root.didError = !1; + var latestPingedTime = root.latestPingedTime; + 0 !== latestPingedTime && + latestPingedTime <= suspendedTime && + (root.latestPingedTime = 0); + latestPingedTime = root.earliestPendingTime; + var latestPendingTime = root.latestPendingTime; + latestPingedTime === suspendedTime + ? (root.earliestPendingTime = + latestPendingTime === suspendedTime + ? (root.latestPendingTime = 0) + : latestPendingTime) + : latestPendingTime === suspendedTime && + (root.latestPendingTime = latestPingedTime); + latestPingedTime = root.earliestSuspendedTime; + latestPendingTime = root.latestSuspendedTime; + 0 === latestPingedTime + ? (root.earliestSuspendedTime = root.latestSuspendedTime = suspendedTime) + : latestPingedTime > suspendedTime + ? (root.earliestSuspendedTime = suspendedTime) + : latestPendingTime < suspendedTime && + (root.latestSuspendedTime = suspendedTime); + findNextExpirationTimeToWorkOn(suspendedTime, root); +} function findNextExpirationTimeToWorkOn(completedExpirationTime, root) { var earliestSuspendedTime = root.earliestSuspendedTime, latestSuspendedTime = root.latestSuspendedTime, @@ -2249,41 +2246,32 @@ function processUpdateQueue( workInProgress.expirationTime = newExpirationTime; workInProgress.memoizedState = resultState; } -function callCallback(callback, context) { - invariant( - "function" === typeof callback, - "Invalid argument passed as callback. Expected a function. Instead received: %s", - callback - ); - callback.call(context); -} function commitUpdateQueue(finishedWork, finishedQueue, instance) { null !== finishedQueue.firstCapturedUpdate && (null !== finishedQueue.lastUpdate && ((finishedQueue.lastUpdate.next = finishedQueue.firstCapturedUpdate), (finishedQueue.lastUpdate = finishedQueue.lastCapturedUpdate)), (finishedQueue.firstCapturedUpdate = finishedQueue.lastCapturedUpdate = null)); - finishedWork = finishedQueue.firstEffect; - for ( - finishedQueue.firstEffect = finishedQueue.lastEffect = null; - null !== finishedWork; - - ) { - var _callback3 = finishedWork.callback; - null !== _callback3 && - ((finishedWork.callback = null), callCallback(_callback3, instance)); - finishedWork = finishedWork.nextEffect; + commitUpdateEffects(finishedQueue.firstEffect, instance); + finishedQueue.firstEffect = finishedQueue.lastEffect = null; + commitUpdateEffects(finishedQueue.firstCapturedEffect, instance); + finishedQueue.firstCapturedEffect = finishedQueue.lastCapturedEffect = null; +} +function commitUpdateEffects(effect, instance) { + for (; null !== effect; ) { + var _callback3 = effect.callback; + if (null !== _callback3) { + effect.callback = null; + var context = instance; + invariant( + "function" === typeof _callback3, + "Invalid argument passed as callback. Expected a function. Instead received: %s", + _callback3 + ); + _callback3.call(context); + } + effect = effect.nextEffect; } - finishedWork = finishedQueue.firstCapturedEffect; - for ( - finishedQueue.firstCapturedEffect = finishedQueue.lastCapturedEffect = null; - null !== finishedWork; - - ) - (finishedQueue = finishedWork.callback), - null !== finishedQueue && - ((finishedWork.callback = null), callCallback(finishedQueue, instance)), - (finishedWork = finishedWork.nextEffect); } function createCapturedValue(value, source) { return { @@ -2293,125 +2281,23 @@ function createCapturedValue(value, source) { }; } var valueCursor = { current: null }, - changedBitsCursor = { current: 0 }, currentlyRenderingFiber = null, lastContextDependency = null, lastContextWithAllBitsObserved = null; -function pushProvider(providerFiber) { +function pushProvider(providerFiber, nextValue) { var context = providerFiber.type._context; - push(changedBitsCursor, context._changedBits, providerFiber); push(valueCursor, context._currentValue, providerFiber); - context._currentValue = providerFiber.pendingProps.value; - context._changedBits = providerFiber.stateNode; + context._currentValue = nextValue; } function popProvider(providerFiber) { - var changedBits = changedBitsCursor.current, - currentValue = valueCursor.current; + var currentValue = valueCursor.current; pop(valueCursor, providerFiber); - pop(changedBitsCursor, providerFiber); - providerFiber = providerFiber.type._context; - providerFiber._currentValue = currentValue; - providerFiber._changedBits = changedBits; + providerFiber.type._context._currentValue = currentValue; } -function propagateContextChange( - workInProgress, - context, - changedBits, - renderExpirationTime -) { - var fiber = workInProgress.child; - null !== fiber && (fiber.return = workInProgress); - for (; null !== fiber; ) { - var dependency = fiber.firstContextDependency; - if (null !== dependency) { - do { - if ( - dependency.context === context && - 0 !== (dependency.observedBits & changedBits) - ) { - if ( - 0 === fiber.expirationTime || - fiber.expirationTime > renderExpirationTime - ) - fiber.expirationTime = renderExpirationTime; - var nextFiber = fiber.alternate; - null !== nextFiber && - (0 === nextFiber.expirationTime || - nextFiber.expirationTime > renderExpirationTime) && - (nextFiber.expirationTime = renderExpirationTime); - for (var node = fiber.return; null !== node; ) { - nextFiber = node.alternate; - if ( - 0 === node.childExpirationTime || - node.childExpirationTime > renderExpirationTime - ) - (node.childExpirationTime = renderExpirationTime), - null !== nextFiber && - (0 === nextFiber.childExpirationTime || - nextFiber.childExpirationTime > renderExpirationTime) && - (nextFiber.childExpirationTime = renderExpirationTime); - else if ( - null !== nextFiber && - (0 === nextFiber.childExpirationTime || - nextFiber.childExpirationTime > renderExpirationTime) - ) - nextFiber.childExpirationTime = renderExpirationTime; - else break; - node = node.return; - } - nextFiber = null; - } else nextFiber = fiber.child; - dependency = dependency.next; - } while (null !== dependency); - } else - nextFiber = - 13 === fiber.tag - ? fiber.type === workInProgress.type - ? null - : fiber.child - : fiber.child; - if (null !== nextFiber) nextFiber.return = fiber; - else - for (nextFiber = fiber; null !== nextFiber; ) { - if (nextFiber === workInProgress) { - nextFiber = null; - break; - } - fiber = nextFiber.sibling; - if (null !== fiber) { - fiber.return = nextFiber.return; - nextFiber = fiber; - break; - } - nextFiber = nextFiber.return; - } - fiber = nextFiber; - } -} -function prepareToReadContext(workInProgress, renderExpirationTime) { +function prepareToReadContext(workInProgress) { currentlyRenderingFiber = workInProgress; lastContextWithAllBitsObserved = lastContextDependency = null; - var firstContextDependency = workInProgress.firstContextDependency; - if (null !== firstContextDependency) { - workInProgress.firstContextDependency = null; - var hasPendingContext = !1; - do { - var _context = firstContextDependency.context, - changedBits = _context._changedBits; - 0 !== changedBits && - (propagateContextChange( - workInProgress, - _context, - changedBits, - renderExpirationTime - ), - 0 !== (changedBits & firstContextDependency.observedBits) && - (hasPendingContext = !0)); - firstContextDependency = firstContextDependency.next; - } while (null !== firstContextDependency); - return hasPendingContext; - } - return !1; + workInProgress.firstContextDependency = null; } function readContext(context, observedBits) { if ( @@ -2478,28 +2364,16 @@ function popHostContext(fiber) { (pop(contextStackCursor$1, fiber), pop(contextFiberStackCursor, fiber)); } var commitTime = 0, - syncCommitStartTime = 0, - timerPausedAt = 0, - totalElapsedPauseTime = 0; -function pauseActualRenderTimerIfRunning() { - 0 === timerPausedAt && (timerPausedAt = now$1()); - 0 < syncCommitStartTime - ? ((totalElapsedPauseTime += now$1() - syncCommitStartTime), - (syncCommitStartTime = 0)) - : (totalElapsedPauseTime = 0); + profilerStartTime = -1; +function stopProfilerTimerIfRunningAndRecordDelta(fiber, overrideBaseTime) { + if (0 <= profilerStartTime) { + var elapsedTime = now$1() - profilerStartTime; + fiber.actualDuration += elapsedTime; + overrideBaseTime && (fiber.selfBaseDuration = elapsedTime); + profilerStartTime = -1; + } } -function recordElapsedActualRenderTime(fiber) { - fiber.actualDuration = now$1() - totalElapsedPauseTime - fiber.actualDuration; -} -function resumeActualRenderTimerIfPaused(isProcessingSyncWork) { - isProcessingSyncWork && - 0 === syncCommitStartTime && - (syncCommitStartTime = now$1()); - 0 < timerPausedAt && - ((totalElapsedPauseTime += now$1() - timerPausedAt), (timerPausedAt = 0)); -} -var baseStartTime = -1, - hasOwnProperty = Object.prototype.hasOwnProperty; +var hasOwnProperty = Object.prototype.hasOwnProperty; function is(x, y) { return x === y ? 0 !== x || 0 !== y || 1 / x === 1 / y : x !== x && y !== y; } @@ -2526,20 +2400,21 @@ function shallowEqual(objA, objB) { var emptyRefsObject = new React.Component().refs; function applyDerivedStateFromProps( workInProgress, + ctor, getDerivedStateFromProps, nextProps ) { - var prevState = workInProgress.memoizedState; - getDerivedStateFromProps = getDerivedStateFromProps(nextProps, prevState); - prevState = + ctor = workInProgress.memoizedState; + getDerivedStateFromProps = getDerivedStateFromProps(nextProps, ctor); + getDerivedStateFromProps = null === getDerivedStateFromProps || void 0 === getDerivedStateFromProps - ? prevState - : Object.assign({}, prevState, getDerivedStateFromProps); - workInProgress.memoizedState = prevState; - getDerivedStateFromProps = workInProgress.updateQueue; - null !== getDerivedStateFromProps && + ? ctor + : Object.assign({}, ctor, getDerivedStateFromProps); + workInProgress.memoizedState = getDerivedStateFromProps; + nextProps = workInProgress.updateQueue; + null !== nextProps && 0 === workInProgress.expirationTime && - (getDerivedStateFromProps.baseState = prevState); + (nextProps.baseState = getDerivedStateFromProps); } var classComponentUpdater = { isMounted: function(component) { @@ -2581,17 +2456,21 @@ var classComponentUpdater = { }; function checkShouldComponentUpdate( workInProgress, + ctor, oldProps, newProps, oldState, newState, nextLegacyContext ) { - var instance = workInProgress.stateNode; - workInProgress = workInProgress.type; - return "function" === typeof instance.shouldComponentUpdate - ? instance.shouldComponentUpdate(newProps, newState, nextLegacyContext) - : workInProgress.prototype && workInProgress.prototype.isPureReactComponent + workInProgress = workInProgress.stateNode; + return "function" === typeof workInProgress.shouldComponentUpdate + ? workInProgress.shouldComponentUpdate( + newProps, + newState, + nextLegacyContext + ) + : ctor.prototype && ctor.prototype.isPureReactComponent ? !shallowEqual(oldProps, newProps) || !shallowEqual(oldState, newState) : !0; } @@ -2609,12 +2488,17 @@ function callComponentWillReceiveProps( instance.state !== workInProgress && classComponentUpdater.enqueueReplaceState(instance, instance.state, null); } -function mountClassInstance(workInProgress, renderExpirationTime) { - var ctor = workInProgress.type, - instance = workInProgress.stateNode, - props = workInProgress.pendingProps, - unmaskedContext = getUnmaskedContext(workInProgress); - instance.props = props; +function mountClassInstance( + workInProgress, + ctor, + newProps, + renderExpirationTime +) { + var instance = workInProgress.stateNode, + unmaskedContext = isContextProvider(ctor) + ? previousContext + : contextStackCursor.current; + instance.props = newProps; instance.state = workInProgress.memoizedState; instance.refs = emptyRefsObject; instance.context = getMaskedContext(workInProgress, unmaskedContext); @@ -2623,14 +2507,19 @@ function mountClassInstance(workInProgress, renderExpirationTime) { (processUpdateQueue( workInProgress, unmaskedContext, - props, + newProps, instance, renderExpirationTime ), (instance.state = workInProgress.memoizedState)); unmaskedContext = ctor.getDerivedStateFromProps; "function" === typeof unmaskedContext && - (applyDerivedStateFromProps(workInProgress, unmaskedContext, props), + (applyDerivedStateFromProps( + workInProgress, + ctor, + unmaskedContext, + newProps + ), (instance.state = workInProgress.memoizedState)); "function" === typeof ctor.getDerivedStateFromProps || "function" === typeof instance.getSnapshotBeforeUpdate || @@ -2648,7 +2537,7 @@ function mountClassInstance(workInProgress, renderExpirationTime) { (processUpdateQueue( workInProgress, unmaskedContext, - props, + newProps, instance, renderExpirationTime ), @@ -2669,7 +2558,7 @@ function coerceRef(returnFiber, current$$1, element) { var inst = void 0; element && (invariant( - 2 === element.tag, + 2 === element.tag || 3 === element.tag, "Stateless function components cannot have refs." ), (inst = element.stateNode)); @@ -2696,7 +2585,7 @@ function coerceRef(returnFiber, current$$1, element) { } invariant( "string" === typeof returnFiber, - "Expected ref to be a function or a string." + "Expected ref to be a function, a string, an object returned by React.createRef(), or null." ); invariant( element._owner, @@ -2776,7 +2665,7 @@ function ChildReconciler(shouldTrackSideEffects) { textContent, expirationTime ) { - if (null === current$$1 || 6 !== current$$1.tag) + if (null === current$$1 || 8 !== current$$1.tag) return ( (current$$1 = createFiberFromText( textContent, @@ -2810,7 +2699,7 @@ function ChildReconciler(shouldTrackSideEffects) { function updatePortal(returnFiber, current$$1, portal, expirationTime) { if ( null === current$$1 || - 4 !== current$$1.tag || + 6 !== current$$1.tag || current$$1.stateNode.containerInfo !== portal.containerInfo || current$$1.stateNode.implementation !== portal.implementation ) @@ -2834,7 +2723,7 @@ function ChildReconciler(shouldTrackSideEffects) { expirationTime, key ) { - if (null === current$$1 || 10 !== current$$1.tag) + if (null === current$$1 || 9 !== current$$1.tag) return ( (current$$1 = createFiberFromFragment( fragment, @@ -3209,7 +3098,7 @@ function ChildReconciler(shouldTrackSideEffects) { ) { if (isUnkeyedTopLevelFragment.key === isObject) if ( - 10 === isUnkeyedTopLevelFragment.tag + 9 === isUnkeyedTopLevelFragment.tag ? newChild.type === REACT_FRAGMENT_TYPE : isUnkeyedTopLevelFragment.type === newChild.type ) { @@ -3274,7 +3163,7 @@ function ChildReconciler(shouldTrackSideEffects) { ) { if (currentFirstChild.key === isUnkeyedTopLevelFragment) if ( - 4 === currentFirstChild.tag && + 6 === currentFirstChild.tag && currentFirstChild.stateNode.containerInfo === newChild.containerInfo && currentFirstChild.stateNode.implementation === @@ -3312,7 +3201,7 @@ function ChildReconciler(shouldTrackSideEffects) { if ("string" === typeof newChild || "number" === typeof newChild) return ( (newChild = "" + newChild), - null !== currentFirstChild && 6 === currentFirstChild.tag + null !== currentFirstChild && 8 === currentFirstChild.tag ? (deleteRemainingChildren(returnFiber, currentFirstChild.sibling), (currentFirstChild = useFiber( currentFirstChild, @@ -3349,7 +3238,8 @@ function ChildReconciler(shouldTrackSideEffects) { if ("undefined" === typeof newChild && !isUnkeyedTopLevelFragment) switch (returnFiber.tag) { case 2: - case 1: + case 3: + case 0: (expirationTime = returnFiber.type), invariant( !1, @@ -3367,12 +3257,12 @@ var reconcileChildFibers = ChildReconciler(!0), isHydrating = !1; function tryHydrate(fiber, nextInstance) { switch (fiber.tag) { - case 5: + case 7: return ( (nextInstance = shim$1(nextInstance, fiber.type, fiber.pendingProps)), null !== nextInstance ? ((fiber.stateNode = nextInstance), !0) : !1 ); - case 6: + case 8: return ( (nextInstance = shim$1(nextInstance, fiber.pendingProps)), null !== nextInstance ? ((fiber.stateNode = nextInstance), !0) : !1 @@ -3395,7 +3285,7 @@ function tryToClaimNextHydratableInstance(fiber$jscomp$0) { return; } var returnFiber = hydrationParentFiber, - fiber = new FiberNode(5, null, null, 0); + fiber = new FiberNode(7, null, null, 0); fiber.type = "DELETED"; fiber.stateNode = firstAttemptedInstance; fiber.return = returnFiber; @@ -3413,6 +3303,38 @@ function tryToClaimNextHydratableInstance(fiber$jscomp$0) { (hydrationParentFiber = fiber$jscomp$0); } } +function readLazyComponentType(thenable) { + switch (thenable._reactStatus) { + case 1: + return thenable._reactResult; + case 2: + throw thenable._reactResult; + case 0: + throw thenable; + default: + throw ((thenable._reactStatus = 0), + thenable.then( + function(resolvedValue) { + if (0 === thenable._reactStatus) { + thenable._reactStatus = 1; + if ("object" === typeof resolvedValue && null !== resolvedValue) { + var defaultExport = resolvedValue.default; + resolvedValue = + void 0 !== defaultExport && null !== defaultExport + ? defaultExport + : resolvedValue; + } + thenable._reactResult = resolvedValue; + } + }, + function(error) { + 0 === thenable._reactStatus && + ((thenable._reactStatus = 2), (thenable._reactResult = error)); + } + ), + thenable); + } +} var ReactCurrentOwner$3 = ReactSharedInternals.ReactCurrentOwner; function reconcileChildren( current$$1, @@ -3435,6 +3357,30 @@ function reconcileChildren( renderExpirationTime ); } +function updateForwardRef( + current$$1, + workInProgress, + type, + nextProps, + renderExpirationTime +) { + type = type.render; + var ref = workInProgress.ref; + if ( + !didPerformWorkStackCursor.current && + workInProgress.memoizedProps === nextProps && + ref === (null !== current$$1 ? current$$1.ref : null) + ) + return bailoutOnAlreadyFinishedWork( + current$$1, + workInProgress, + renderExpirationTime + ); + type = type(nextProps, ref); + reconcileChildren(current$$1, workInProgress, type, renderExpirationTime); + workInProgress.memoizedProps = nextProps; + return workInProgress.child; +} function markRef(current$$1, workInProgress) { var ref = workInProgress.ref; if ( @@ -3443,9 +3389,268 @@ function markRef(current$$1, workInProgress) { ) workInProgress.effectTag |= 128; } +function updateFunctionalComponent( + current$$1, + workInProgress, + Component, + nextProps, + renderExpirationTime +) { + var unmaskedContext = isContextProvider(Component) + ? previousContext + : contextStackCursor.current; + unmaskedContext = getMaskedContext(workInProgress, unmaskedContext); + prepareToReadContext(workInProgress, renderExpirationTime); + Component = Component(nextProps, unmaskedContext); + workInProgress.effectTag |= 1; + reconcileChildren( + current$$1, + workInProgress, + Component, + renderExpirationTime + ); + workInProgress.memoizedProps = nextProps; + return workInProgress.child; +} +function updateClassComponent( + current$$1, + workInProgress, + Component, + nextProps, + renderExpirationTime +) { + if (isContextProvider(Component)) { + var hasContext = !0; + pushContextProvider(workInProgress); + } else hasContext = !1; + prepareToReadContext(workInProgress, renderExpirationTime); + if (null === current$$1) + if (null === workInProgress.stateNode) { + var unmaskedContext = isContextProvider(Component) + ? previousContext + : contextStackCursor.current, + contextTypes = Component.contextTypes, + isContextConsumer = null !== contextTypes && void 0 !== contextTypes; + contextTypes = isContextConsumer + ? getMaskedContext(workInProgress, unmaskedContext) + : emptyContextObject; + var instance = new Component(nextProps, contextTypes); + workInProgress.memoizedState = + null !== instance.state && void 0 !== instance.state + ? instance.state + : null; + instance.updater = classComponentUpdater; + workInProgress.stateNode = instance; + instance._reactInternalFiber = workInProgress; + isContextConsumer && + ((isContextConsumer = workInProgress.stateNode), + (isContextConsumer.__reactInternalMemoizedUnmaskedChildContext = unmaskedContext), + (isContextConsumer.__reactInternalMemoizedMaskedChildContext = contextTypes)); + mountClassInstance( + workInProgress, + Component, + nextProps, + renderExpirationTime + ); + nextProps = !0; + } else { + unmaskedContext = workInProgress.stateNode; + contextTypes = workInProgress.memoizedProps; + unmaskedContext.props = contextTypes; + var oldContext = unmaskedContext.context; + isContextConsumer = isContextProvider(Component) + ? previousContext + : contextStackCursor.current; + isContextConsumer = getMaskedContext(workInProgress, isContextConsumer); + var getDerivedStateFromProps = Component.getDerivedStateFromProps; + (instance = + "function" === typeof getDerivedStateFromProps || + "function" === typeof unmaskedContext.getSnapshotBeforeUpdate) || + ("function" !== + typeof unmaskedContext.UNSAFE_componentWillReceiveProps && + "function" !== typeof unmaskedContext.componentWillReceiveProps) || + ((contextTypes !== nextProps || oldContext !== isContextConsumer) && + callComponentWillReceiveProps( + workInProgress, + unmaskedContext, + nextProps, + isContextConsumer + )); + hasForceUpdate = !1; + var oldState = workInProgress.memoizedState; + oldContext = unmaskedContext.state = oldState; + var updateQueue = workInProgress.updateQueue; + null !== updateQueue && + (processUpdateQueue( + workInProgress, + updateQueue, + nextProps, + unmaskedContext, + renderExpirationTime + ), + (oldContext = workInProgress.memoizedState)); + contextTypes !== nextProps || + oldState !== oldContext || + didPerformWorkStackCursor.current || + hasForceUpdate + ? ("function" === typeof getDerivedStateFromProps && + (applyDerivedStateFromProps( + workInProgress, + Component, + getDerivedStateFromProps, + nextProps + ), + (oldContext = workInProgress.memoizedState)), + (contextTypes = + hasForceUpdate || + checkShouldComponentUpdate( + workInProgress, + Component, + contextTypes, + nextProps, + oldState, + oldContext, + isContextConsumer + )) + ? (instance || + ("function" !== + typeof unmaskedContext.UNSAFE_componentWillMount && + "function" !== typeof unmaskedContext.componentWillMount) || + ("function" === typeof unmaskedContext.componentWillMount && + unmaskedContext.componentWillMount(), + "function" === + typeof unmaskedContext.UNSAFE_componentWillMount && + unmaskedContext.UNSAFE_componentWillMount()), + "function" === typeof unmaskedContext.componentDidMount && + (workInProgress.effectTag |= 4)) + : ("function" === typeof unmaskedContext.componentDidMount && + (workInProgress.effectTag |= 4), + (workInProgress.memoizedProps = nextProps), + (workInProgress.memoizedState = oldContext)), + (unmaskedContext.props = nextProps), + (unmaskedContext.state = oldContext), + (unmaskedContext.context = isContextConsumer), + (nextProps = contextTypes)) + : ("function" === typeof unmaskedContext.componentDidMount && + (workInProgress.effectTag |= 4), + (nextProps = !1)); + } + else + (unmaskedContext = workInProgress.stateNode), + (contextTypes = workInProgress.memoizedProps), + (unmaskedContext.props = contextTypes), + (oldContext = unmaskedContext.context), + (isContextConsumer = isContextProvider(Component) + ? previousContext + : contextStackCursor.current), + (isContextConsumer = getMaskedContext(workInProgress, isContextConsumer)), + (getDerivedStateFromProps = Component.getDerivedStateFromProps), + (instance = + "function" === typeof getDerivedStateFromProps || + "function" === typeof unmaskedContext.getSnapshotBeforeUpdate) || + ("function" !== + typeof unmaskedContext.UNSAFE_componentWillReceiveProps && + "function" !== typeof unmaskedContext.componentWillReceiveProps) || + ((contextTypes !== nextProps || oldContext !== isContextConsumer) && + callComponentWillReceiveProps( + workInProgress, + unmaskedContext, + nextProps, + isContextConsumer + )), + (hasForceUpdate = !1), + (oldContext = workInProgress.memoizedState), + (oldState = unmaskedContext.state = oldContext), + (updateQueue = workInProgress.updateQueue), + null !== updateQueue && + (processUpdateQueue( + workInProgress, + updateQueue, + nextProps, + unmaskedContext, + renderExpirationTime + ), + (oldState = workInProgress.memoizedState)), + contextTypes !== nextProps || + oldContext !== oldState || + didPerformWorkStackCursor.current || + hasForceUpdate + ? ("function" === typeof getDerivedStateFromProps && + (applyDerivedStateFromProps( + workInProgress, + Component, + getDerivedStateFromProps, + nextProps + ), + (oldState = workInProgress.memoizedState)), + (getDerivedStateFromProps = + hasForceUpdate || + checkShouldComponentUpdate( + workInProgress, + Component, + contextTypes, + nextProps, + oldContext, + oldState, + isContextConsumer + )) + ? (instance || + ("function" !== + typeof unmaskedContext.UNSAFE_componentWillUpdate && + "function" !== typeof unmaskedContext.componentWillUpdate) || + ("function" === typeof unmaskedContext.componentWillUpdate && + unmaskedContext.componentWillUpdate( + nextProps, + oldState, + isContextConsumer + ), + "function" === + typeof unmaskedContext.UNSAFE_componentWillUpdate && + unmaskedContext.UNSAFE_componentWillUpdate( + nextProps, + oldState, + isContextConsumer + )), + "function" === typeof unmaskedContext.componentDidUpdate && + (workInProgress.effectTag |= 4), + "function" === typeof unmaskedContext.getSnapshotBeforeUpdate && + (workInProgress.effectTag |= 256)) + : ("function" !== typeof unmaskedContext.componentDidUpdate || + (contextTypes === current$$1.memoizedProps && + oldContext === current$$1.memoizedState) || + (workInProgress.effectTag |= 4), + "function" !== typeof unmaskedContext.getSnapshotBeforeUpdate || + (contextTypes === current$$1.memoizedProps && + oldContext === current$$1.memoizedState) || + (workInProgress.effectTag |= 256), + (workInProgress.memoizedProps = nextProps), + (workInProgress.memoizedState = oldState)), + (unmaskedContext.props = nextProps), + (unmaskedContext.state = oldState), + (unmaskedContext.context = isContextConsumer), + (nextProps = getDerivedStateFromProps)) + : ("function" !== typeof unmaskedContext.componentDidUpdate || + (contextTypes === current$$1.memoizedProps && + oldContext === current$$1.memoizedState) || + (workInProgress.effectTag |= 4), + "function" !== typeof unmaskedContext.getSnapshotBeforeUpdate || + (contextTypes === current$$1.memoizedProps && + oldContext === current$$1.memoizedState) || + (workInProgress.effectTag |= 256), + (nextProps = !1)); + return finishClassComponent( + current$$1, + workInProgress, + Component, + nextProps, + hasContext, + renderExpirationTime + ); +} function finishClassComponent( current$$1, workInProgress, + Component, shouldUpdate, hasContext, renderExpirationTime @@ -3454,7 +3659,7 @@ function finishClassComponent( var didCaptureError = 0 !== (workInProgress.effectTag & 64); if (!shouldUpdate && !didCaptureError) return ( - hasContext && invalidateContextProvider(workInProgress, !1), + hasContext && invalidateContextProvider(workInProgress, Component, !1), bailoutOnAlreadyFinishedWork( current$$1, workInProgress, @@ -3465,7 +3670,7 @@ function finishClassComponent( ReactCurrentOwner$3.current = workInProgress; if (didCaptureError) { var nextChildren = null; - baseStartTime = -1; + profilerStartTime = -1; } else nextChildren = shouldUpdate.render(); workInProgress.effectTag |= 1; null !== current$$1 && @@ -3480,7 +3685,7 @@ function finishClassComponent( ); workInProgress.memoizedState = shouldUpdate.state; workInProgress.memoizedProps = shouldUpdate.props; - hasContext && invalidateContextProvider(workInProgress, !0); + hasContext && invalidateContextProvider(workInProgress, Component, !0); return workInProgress.child; } function pushHostRootContext(workInProgress) { @@ -3495,6 +3700,132 @@ function pushHostRootContext(workInProgress) { pushTopLevelContextObject(workInProgress, root.context, !1); pushHostContainer(workInProgress, root.containerInfo); } +function resolveDefaultProps(Component, baseProps) { + if (Component && Component.defaultProps) { + baseProps = Object.assign({}, baseProps); + Component = Component.defaultProps; + for (var propName in Component) + void 0 === baseProps[propName] && + (baseProps[propName] = Component[propName]); + } + return baseProps; +} +function mountIndeterminateComponent( + current$$1, + workInProgress, + Component, + renderExpirationTime +) { + invariant( + null === current$$1, + "An indeterminate component should never have mounted. This error is likely caused by a bug in React. Please file an issue." + ); + var props = workInProgress.pendingProps; + if ( + "object" === typeof Component && + null !== Component && + "function" === typeof Component.then + ) { + Component = readLazyComponentType(Component); + var JSCompiler_inline_result = Component; + JSCompiler_inline_result = + "function" === typeof JSCompiler_inline_result + ? shouldConstruct(JSCompiler_inline_result) + ? 3 + : 1 + : void 0 !== JSCompiler_inline_result && + null !== JSCompiler_inline_result && + JSCompiler_inline_result.$$typeof + ? 14 + : 4; + JSCompiler_inline_result = workInProgress.tag = JSCompiler_inline_result; + var resolvedProps = resolveDefaultProps(Component, props); + switch (JSCompiler_inline_result) { + case 1: + return updateFunctionalComponent( + current$$1, + workInProgress, + Component, + resolvedProps, + renderExpirationTime + ); + case 3: + return updateClassComponent( + current$$1, + workInProgress, + Component, + resolvedProps, + renderExpirationTime + ); + case 14: + return updateForwardRef( + current$$1, + workInProgress, + Component, + resolvedProps, + renderExpirationTime + ); + default: + invariant( + !1, + "Element type is invalid. Received a promise that resolves to: %s. Promise elements must resolve to a class or function.", + Component + ); + } + } + JSCompiler_inline_result = getMaskedContext( + workInProgress, + contextStackCursor.current + ); + prepareToReadContext(workInProgress, renderExpirationTime); + JSCompiler_inline_result = Component(props, JSCompiler_inline_result); + workInProgress.effectTag |= 1; + if ( + "object" === typeof JSCompiler_inline_result && + null !== JSCompiler_inline_result && + "function" === typeof JSCompiler_inline_result.render && + void 0 === JSCompiler_inline_result.$$typeof + ) { + workInProgress.tag = 2; + isContextProvider(Component) + ? ((resolvedProps = !0), pushContextProvider(workInProgress)) + : (resolvedProps = !1); + workInProgress.memoizedState = + null !== JSCompiler_inline_result.state && + void 0 !== JSCompiler_inline_result.state + ? JSCompiler_inline_result.state + : null; + var getDerivedStateFromProps = Component.getDerivedStateFromProps; + "function" === typeof getDerivedStateFromProps && + applyDerivedStateFromProps( + workInProgress, + Component, + getDerivedStateFromProps, + props + ); + JSCompiler_inline_result.updater = classComponentUpdater; + workInProgress.stateNode = JSCompiler_inline_result; + JSCompiler_inline_result._reactInternalFiber = workInProgress; + mountClassInstance(workInProgress, Component, props, renderExpirationTime); + return finishClassComponent( + current$$1, + workInProgress, + Component, + !0, + resolvedProps, + renderExpirationTime + ); + } + workInProgress.tag = 0; + reconcileChildren( + current$$1, + workInProgress, + JSCompiler_inline_result, + renderExpirationTime + ); + workInProgress.memoizedProps = props; + return workInProgress.child; +} function bailoutOnAlreadyFinishedWork( current$$1, workInProgress, @@ -3502,7 +3833,7 @@ function bailoutOnAlreadyFinishedWork( ) { null !== current$$1 && (workInProgress.firstContextDependency = current$$1.firstContextDependency); - baseStartTime = -1; + profilerStartTime = -1; var childExpirationTime = workInProgress.childExpirationTime; if (0 === childExpirationTime || childExpirationTime > renderExpirationTime) return null; @@ -3535,34 +3866,34 @@ function bailoutOnAlreadyFinishedWork( return workInProgress.child; } function beginWork(current$$1, workInProgress, renderExpirationTime) { - workInProgress.mode & 4 && - ((workInProgress.actualDuration = - now$1() - workInProgress.actualDuration - totalElapsedPauseTime), - (workInProgress.actualStartTime = now$1())); var updateExpirationTime = workInProgress.expirationTime; if ( !didPerformWorkStackCursor.current && (0 === updateExpirationTime || updateExpirationTime > renderExpirationTime) ) { switch (workInProgress.tag) { - case 3: + case 5: pushHostRootContext(workInProgress); break; - case 5: + case 7: pushHostContext(workInProgress); break; case 2: - pushContextProvider(workInProgress); + isContextProvider(workInProgress.type) && + pushContextProvider(workInProgress); break; - case 4: + case 3: + isContextProvider(workInProgress.type._reactResult) && + pushContextProvider(workInProgress); + break; + case 6: pushHostContainer( workInProgress, workInProgress.stateNode.containerInfo ); break; - case 13: - workInProgress.stateNode = 0; - pushProvider(workInProgress); + case 12: + pushProvider(workInProgress, workInProgress.memoizedProps.value); break; case 15: workInProgress.effectTag |= 4; @@ -3575,294 +3906,56 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { } workInProgress.expirationTime = 0; switch (workInProgress.tag) { - case 0: - invariant( - null === current$$1, - "An indeterminate component should never have mounted. This error is likely caused by a bug in React. Please file an issue." - ); - var fn = workInProgress.type; - updateExpirationTime = workInProgress.pendingProps; - var unmaskedContext = getUnmaskedContext(workInProgress); - unmaskedContext = getMaskedContext(workInProgress, unmaskedContext); - prepareToReadContext(workInProgress, renderExpirationTime); - fn = fn(updateExpirationTime, unmaskedContext); - workInProgress.effectTag |= 1; - if ( - "object" === typeof fn && - null !== fn && - "function" === typeof fn.render && - void 0 === fn.$$typeof - ) { - var Component = workInProgress.type; - workInProgress.tag = 2; - unmaskedContext = pushContextProvider(workInProgress); - workInProgress.memoizedState = - null !== fn.state && void 0 !== fn.state ? fn.state : null; - Component = Component.getDerivedStateFromProps; - "function" === typeof Component && - applyDerivedStateFromProps( - workInProgress, - Component, - updateExpirationTime - ); - fn.updater = classComponentUpdater; - workInProgress.stateNode = fn; - fn._reactInternalFiber = workInProgress; - mountClassInstance(workInProgress, renderExpirationTime); - current$$1 = finishClassComponent( - current$$1, - workInProgress, - !0, - unmaskedContext, - renderExpirationTime - ); - } else - (workInProgress.tag = 1), - reconcileChildren( - current$$1, - workInProgress, - fn, - renderExpirationTime - ), - (workInProgress.memoizedProps = updateExpirationTime), - (current$$1 = workInProgress.child); - return current$$1; - case 1: - return ( - (fn = workInProgress.type), - (updateExpirationTime = workInProgress.pendingProps), - (unmaskedContext = getUnmaskedContext(workInProgress)), - (unmaskedContext = getMaskedContext(workInProgress, unmaskedContext)), - prepareToReadContext(workInProgress, renderExpirationTime), - (fn = fn(updateExpirationTime, unmaskedContext)), - (workInProgress.effectTag |= 1), - reconcileChildren(current$$1, workInProgress, fn, renderExpirationTime), - (workInProgress.memoizedProps = updateExpirationTime), - workInProgress.child - ); - case 2: - updateExpirationTime = pushContextProvider(workInProgress); - fn = prepareToReadContext(workInProgress, renderExpirationTime); - if (null === current$$1) - if (null === workInProgress.stateNode) { - var props = workInProgress.pendingProps, - ctor = workInProgress.type; - fn = getUnmaskedContext(workInProgress); - unmaskedContext = (Component = - 2 === workInProgress.tag && - null != workInProgress.type.contextTypes) - ? getMaskedContext(workInProgress, fn) - : emptyContextObject; - props = new ctor(props, unmaskedContext); - workInProgress.memoizedState = - null !== props.state && void 0 !== props.state ? props.state : null; - props.updater = classComponentUpdater; - workInProgress.stateNode = props; - props._reactInternalFiber = workInProgress; - Component && - ((Component = workInProgress.stateNode), - (Component.__reactInternalMemoizedUnmaskedChildContext = fn), - (Component.__reactInternalMemoizedMaskedChildContext = unmaskedContext)); - mountClassInstance(workInProgress, renderExpirationTime); - fn = !0; - } else { - var ctor$jscomp$0 = workInProgress.type; - unmaskedContext = workInProgress.stateNode; - props = workInProgress.memoizedProps; - Component = workInProgress.pendingProps; - unmaskedContext.props = props; - var oldContext = unmaskedContext.context; - ctor = getUnmaskedContext(workInProgress); - ctor = getMaskedContext(workInProgress, ctor); - var getDerivedStateFromProps = ctor$jscomp$0.getDerivedStateFromProps; - (ctor$jscomp$0 = - "function" === typeof getDerivedStateFromProps || - "function" === typeof unmaskedContext.getSnapshotBeforeUpdate) || - ("function" !== - typeof unmaskedContext.UNSAFE_componentWillReceiveProps && - "function" !== - typeof unmaskedContext.componentWillReceiveProps) || - ((props !== Component || oldContext !== ctor) && - callComponentWillReceiveProps( - workInProgress, - unmaskedContext, - Component, - ctor - )); - hasForceUpdate = !1; - var oldState = workInProgress.memoizedState; - oldContext = unmaskedContext.state = oldState; - var updateQueue = workInProgress.updateQueue; - null !== updateQueue && - (processUpdateQueue( - workInProgress, - updateQueue, - Component, - unmaskedContext, - renderExpirationTime - ), - (oldContext = workInProgress.memoizedState)); - props !== Component || - oldState !== oldContext || - didPerformWorkStackCursor.current || - fn || - hasForceUpdate - ? ("function" === typeof getDerivedStateFromProps && - (applyDerivedStateFromProps( - workInProgress, - getDerivedStateFromProps, - Component - ), - (oldContext = workInProgress.memoizedState)), - (fn = - hasForceUpdate || - fn || - checkShouldComponentUpdate( - workInProgress, - props, - Component, - oldState, - oldContext, - ctor - )) - ? (ctor$jscomp$0 || - ("function" !== - typeof unmaskedContext.UNSAFE_componentWillMount && - "function" !== - typeof unmaskedContext.componentWillMount) || - ("function" === typeof unmaskedContext.componentWillMount && - unmaskedContext.componentWillMount(), - "function" === - typeof unmaskedContext.UNSAFE_componentWillMount && - unmaskedContext.UNSAFE_componentWillMount()), - "function" === typeof unmaskedContext.componentDidMount && - (workInProgress.effectTag |= 4)) - : ("function" === typeof unmaskedContext.componentDidMount && - (workInProgress.effectTag |= 4), - (workInProgress.memoizedProps = Component), - (workInProgress.memoizedState = oldContext)), - (unmaskedContext.props = Component), - (unmaskedContext.state = oldContext), - (unmaskedContext.context = ctor)) - : ("function" === typeof unmaskedContext.componentDidMount && - (workInProgress.effectTag |= 4), - (fn = !1)); - } - else - (ctor$jscomp$0 = workInProgress.type), - (unmaskedContext = workInProgress.stateNode), - (Component = workInProgress.memoizedProps), - (props = workInProgress.pendingProps), - (unmaskedContext.props = Component), - (oldContext = unmaskedContext.context), - (ctor = getUnmaskedContext(workInProgress)), - (ctor = getMaskedContext(workInProgress, ctor)), - (getDerivedStateFromProps = ctor$jscomp$0.getDerivedStateFromProps), - (ctor$jscomp$0 = - "function" === typeof getDerivedStateFromProps || - "function" === typeof unmaskedContext.getSnapshotBeforeUpdate) || - ("function" !== - typeof unmaskedContext.UNSAFE_componentWillReceiveProps && - "function" !== - typeof unmaskedContext.componentWillReceiveProps) || - ((Component !== props || oldContext !== ctor) && - callComponentWillReceiveProps( - workInProgress, - unmaskedContext, - props, - ctor - )), - (hasForceUpdate = !1), - (oldContext = workInProgress.memoizedState), - (oldState = unmaskedContext.state = oldContext), - (updateQueue = workInProgress.updateQueue), - null !== updateQueue && - (processUpdateQueue( - workInProgress, - updateQueue, - props, - unmaskedContext, - renderExpirationTime - ), - (oldState = workInProgress.memoizedState)), - Component !== props || - oldContext !== oldState || - didPerformWorkStackCursor.current || - fn || - hasForceUpdate - ? ("function" === typeof getDerivedStateFromProps && - (applyDerivedStateFromProps( - workInProgress, - getDerivedStateFromProps, - props - ), - (oldState = workInProgress.memoizedState)), - (fn = - hasForceUpdate || - fn || - checkShouldComponentUpdate( - workInProgress, - Component, - props, - oldContext, - oldState, - ctor - )) - ? (ctor$jscomp$0 || - ("function" !== - typeof unmaskedContext.UNSAFE_componentWillUpdate && - "function" !== - typeof unmaskedContext.componentWillUpdate) || - ("function" === - typeof unmaskedContext.componentWillUpdate && - unmaskedContext.componentWillUpdate( - props, - oldState, - ctor - ), - "function" === - typeof unmaskedContext.UNSAFE_componentWillUpdate && - unmaskedContext.UNSAFE_componentWillUpdate( - props, - oldState, - ctor - )), - "function" === typeof unmaskedContext.componentDidUpdate && - (workInProgress.effectTag |= 4), - "function" === - typeof unmaskedContext.getSnapshotBeforeUpdate && - (workInProgress.effectTag |= 256)) - : ("function" !== typeof unmaskedContext.componentDidUpdate || - (Component === current$$1.memoizedProps && - oldContext === current$$1.memoizedState) || - (workInProgress.effectTag |= 4), - "function" !== - typeof unmaskedContext.getSnapshotBeforeUpdate || - (Component === current$$1.memoizedProps && - oldContext === current$$1.memoizedState) || - (workInProgress.effectTag |= 256), - (workInProgress.memoizedProps = props), - (workInProgress.memoizedState = oldState)), - (unmaskedContext.props = props), - (unmaskedContext.state = oldState), - (unmaskedContext.context = ctor)) - : ("function" !== typeof unmaskedContext.componentDidUpdate || - (Component === current$$1.memoizedProps && - oldContext === current$$1.memoizedState) || - (workInProgress.effectTag |= 4), - "function" !== typeof unmaskedContext.getSnapshotBeforeUpdate || - (Component === current$$1.memoizedProps && - oldContext === current$$1.memoizedState) || - (workInProgress.effectTag |= 256), - (fn = !1)); - return finishClassComponent( + case 4: + return mountIndeterminateComponent( current$$1, workInProgress, - fn, - updateExpirationTime, + workInProgress.type, + renderExpirationTime + ); + case 0: + return updateFunctionalComponent( + current$$1, + workInProgress, + workInProgress.type, + workInProgress.pendingProps, + renderExpirationTime + ); + case 1: + var _Component5 = workInProgress.type._reactResult; + updateExpirationTime = workInProgress.pendingProps; + current$$1 = updateFunctionalComponent( + current$$1, + workInProgress, + _Component5, + resolveDefaultProps(_Component5, updateExpirationTime), + renderExpirationTime + ); + workInProgress.memoizedProps = updateExpirationTime; + return current$$1; + case 2: + return updateClassComponent( + current$$1, + workInProgress, + workInProgress.type, + workInProgress.pendingProps, renderExpirationTime ); case 3: + return ( + (_Component5 = workInProgress.type._reactResult), + (updateExpirationTime = workInProgress.pendingProps), + (current$$1 = updateClassComponent( + current$$1, + workInProgress, + _Component5, + resolveDefaultProps(_Component5, updateExpirationTime), + renderExpirationTime + )), + (workInProgress.memoizedProps = updateExpirationTime), + current$$1 + ); + case 5: return ( pushHostRootContext(workInProgress), (updateExpirationTime = workInProgress.updateQueue), @@ -3870,8 +3963,8 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { null !== updateExpirationTime, "If the root does not have an updateQueue, we should have already bailed out. This error is likely caused by a bug in React. Please file an issue." ), - (fn = workInProgress.memoizedState), - (fn = null !== fn ? fn.element : null), + (_Component5 = workInProgress.memoizedState), + (_Component5 = null !== _Component5 ? _Component5.element : null), processUpdateQueue( workInProgress, updateExpirationTime, @@ -3880,8 +3973,8 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { renderExpirationTime ), (updateExpirationTime = workInProgress.memoizedState.element), - updateExpirationTime === fn - ? (current$$1 = bailoutOnAlreadyFinishedWork( + updateExpirationTime === _Component5 + ? (workInProgress = bailoutOnAlreadyFinishedWork( current$$1, workInProgress, renderExpirationTime @@ -3892,22 +3985,27 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { updateExpirationTime, renderExpirationTime ), - (current$$1 = workInProgress.child)), - current$$1 + (workInProgress = workInProgress.child)), + workInProgress ); - case 5: + case 7: return ( pushHostContext(workInProgress), null === current$$1 && tryToClaimNextHydratableInstance(workInProgress), (updateExpirationTime = workInProgress.pendingProps), - (fn = updateExpirationTime.children), + (_Component5 = updateExpirationTime.children), markRef(current$$1, workInProgress), - reconcileChildren(current$$1, workInProgress, fn, renderExpirationTime), + reconcileChildren( + current$$1, + workInProgress, + _Component5, + renderExpirationTime + ), (workInProgress.memoizedProps = updateExpirationTime), - (current$$1 = workInProgress.child), - current$$1 + (workInProgress = workInProgress.child), + workInProgress ); - case 6: + case 8: return ( null === current$$1 && tryToClaimNextHydratableInstance(workInProgress), (workInProgress.memoizedProps = workInProgress.pendingProps), @@ -3915,7 +4013,7 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { ); case 16: return null; - case 4: + case 6: return ( pushHostContainer( workInProgress, @@ -3938,31 +4036,29 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { (workInProgress.memoizedProps = updateExpirationTime), workInProgress.child ); + case 13: + return updateForwardRef( + current$$1, + workInProgress, + workInProgress.type, + workInProgress.pendingProps, + renderExpirationTime + ); case 14: return ( - (fn = workInProgress.type.render), + (_Component5 = workInProgress.type._reactResult), (updateExpirationTime = workInProgress.pendingProps), - (unmaskedContext = workInProgress.ref), - didPerformWorkStackCursor.current || - workInProgress.memoizedProps !== updateExpirationTime || - unmaskedContext !== (null !== current$$1 ? current$$1.ref : null) - ? ((fn = fn(updateExpirationTime, unmaskedContext)), - reconcileChildren( - current$$1, - workInProgress, - fn, - renderExpirationTime - ), - (workInProgress.memoizedProps = updateExpirationTime), - (current$$1 = workInProgress.child)) - : (current$$1 = bailoutOnAlreadyFinishedWork( - current$$1, - workInProgress, - renderExpirationTime - )), + (current$$1 = updateForwardRef( + current$$1, + workInProgress, + _Component5, + resolveDefaultProps(_Component5, updateExpirationTime), + renderExpirationTime + )), + (workInProgress.memoizedProps = updateExpirationTime), current$$1 ); - case 10: + case 9: return ( (updateExpirationTime = workInProgress.pendingProps), reconcileChildren( @@ -3974,7 +4070,7 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { (workInProgress.memoizedProps = updateExpirationTime), workInProgress.child ); - case 11: + case 10: return ( (updateExpirationTime = workInProgress.pendingProps.children), reconcileChildren( @@ -3999,101 +4095,146 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { (workInProgress.memoizedProps = updateExpirationTime), workInProgress.child ); - case 13: + case 12: a: { updateExpirationTime = workInProgress.type._context; - fn = workInProgress.pendingProps; - unmaskedContext = workInProgress.memoizedProps; - Component = fn.value; - workInProgress.memoizedProps = fn; - if (null === unmaskedContext) Component = 1073741823; - else if (unmaskedContext.value === fn.value) { - if ( - unmaskedContext.children === fn.children && - !didPerformWorkStackCursor.current - ) { - workInProgress.stateNode = 0; - pushProvider(workInProgress); - current$$1 = bailoutOnAlreadyFinishedWork( - current$$1, - workInProgress, - renderExpirationTime - ); - break a; - } - Component = 0; - } else if ( - ((props = unmaskedContext.value), - (props === Component && - (0 !== props || 1 / props === 1 / Component)) || - (props !== props && Component !== Component)) - ) { - if ( - unmaskedContext.children === fn.children && - !didPerformWorkStackCursor.current - ) { - workInProgress.stateNode = 0; - pushProvider(workInProgress); - current$$1 = bailoutOnAlreadyFinishedWork( - current$$1, - workInProgress, - renderExpirationTime - ); - break a; - } - Component = 0; - } else if ( - ((Component = - "function" === typeof updateExpirationTime._calculateChangedBits - ? updateExpirationTime._calculateChangedBits(props, Component) - : 1073741823), - (Component |= 0), - 0 === Component) - ) { - if ( - unmaskedContext.children === fn.children && - !didPerformWorkStackCursor.current - ) { - workInProgress.stateNode = 0; - pushProvider(workInProgress); - current$$1 = bailoutOnAlreadyFinishedWork( - current$$1, - workInProgress, - renderExpirationTime - ); - break a; - } - } else - propagateContextChange( - workInProgress, - updateExpirationTime, - Component, - renderExpirationTime - ); - workInProgress.stateNode = Component; - pushProvider(workInProgress); + _Component5 = workInProgress.pendingProps; + var oldProps = workInProgress.memoizedProps, + newValue = _Component5.value; + workInProgress.memoizedProps = _Component5; + pushProvider(workInProgress, newValue); + if (null !== oldProps) { + var oldValue = oldProps.value; + newValue = + (oldValue === newValue && + (0 !== oldValue || 1 / oldValue === 1 / newValue)) || + (oldValue !== oldValue && newValue !== newValue) + ? 0 + : ("function" === + typeof updateExpirationTime._calculateChangedBits + ? updateExpirationTime._calculateChangedBits( + oldValue, + newValue + ) + : 1073741823) | 0; + if (0 === newValue) { + if ( + oldProps.children === _Component5.children && + !didPerformWorkStackCursor.current + ) { + workInProgress = bailoutOnAlreadyFinishedWork( + current$$1, + workInProgress, + renderExpirationTime + ); + break a; + } + } else + for ( + oldProps = workInProgress.child, + null !== oldProps && (oldProps.return = workInProgress); + null !== oldProps; + + ) { + oldValue = oldProps.firstContextDependency; + if (null !== oldValue) { + do { + if ( + oldValue.context === updateExpirationTime && + 0 !== (oldValue.observedBits & newValue) + ) { + if (2 === oldProps.tag || 3 === oldProps.tag) { + var nextFiber = createUpdate(renderExpirationTime); + nextFiber.tag = 2; + enqueueUpdate(oldProps, nextFiber); + } + if ( + 0 === oldProps.expirationTime || + oldProps.expirationTime > renderExpirationTime + ) + oldProps.expirationTime = renderExpirationTime; + nextFiber = oldProps.alternate; + null !== nextFiber && + (0 === nextFiber.expirationTime || + nextFiber.expirationTime > renderExpirationTime) && + (nextFiber.expirationTime = renderExpirationTime); + for (var node = oldProps.return; null !== node; ) { + nextFiber = node.alternate; + if ( + 0 === node.childExpirationTime || + node.childExpirationTime > renderExpirationTime + ) + (node.childExpirationTime = renderExpirationTime), + null !== nextFiber && + (0 === nextFiber.childExpirationTime || + nextFiber.childExpirationTime > + renderExpirationTime) && + (nextFiber.childExpirationTime = renderExpirationTime); + else if ( + null !== nextFiber && + (0 === nextFiber.childExpirationTime || + nextFiber.childExpirationTime > renderExpirationTime) + ) + nextFiber.childExpirationTime = renderExpirationTime; + else break; + node = node.return; + } + } + nextFiber = oldProps.child; + oldValue = oldValue.next; + } while (null !== oldValue); + } else + nextFiber = + 12 === oldProps.tag + ? oldProps.type === workInProgress.type + ? null + : oldProps.child + : oldProps.child; + if (null !== nextFiber) nextFiber.return = oldProps; + else + for (nextFiber = oldProps; null !== nextFiber; ) { + if (nextFiber === workInProgress) { + nextFiber = null; + break; + } + oldProps = nextFiber.sibling; + if (null !== oldProps) { + oldProps.return = nextFiber.return; + nextFiber = oldProps; + break; + } + nextFiber = nextFiber.return; + } + oldProps = nextFiber; + } + } reconcileChildren( current$$1, workInProgress, - fn.children, + _Component5.children, renderExpirationTime ); - current$$1 = workInProgress.child; + workInProgress = workInProgress.child; } - return current$$1; - case 12: + return workInProgress; + case 11: return ( - (unmaskedContext = workInProgress.type), + (newValue = workInProgress.type), (updateExpirationTime = workInProgress.pendingProps), - (fn = updateExpirationTime.children), + (_Component5 = updateExpirationTime.children), prepareToReadContext(workInProgress, renderExpirationTime), - (unmaskedContext = readContext( - unmaskedContext, + (newValue = readContext( + newValue, updateExpirationTime.unstable_observedBits )), - (fn = fn(unmaskedContext)), + (_Component5 = _Component5(newValue)), (workInProgress.effectTag |= 1), - reconcileChildren(current$$1, workInProgress, fn, renderExpirationTime), + reconcileChildren( + current$$1, + workInProgress, + _Component5, + renderExpirationTime + ), (workInProgress.memoizedProps = updateExpirationTime), workInProgress.child ); @@ -4108,42 +4249,61 @@ var updateHostContainer = void 0, updateHostComponent$1 = void 0, updateHostText$1 = void 0; updateHostContainer = function() {}; -updateHostComponent$1 = function(current, workInProgress, updatePayload) { - if ((workInProgress.updateQueue = updatePayload)) - workInProgress.effectTag |= 4; +updateHostComponent$1 = function(current, workInProgress, type, newProps) { + current.memoizedProps !== newProps && + (requiredContext(contextStackCursor$1.current), + (workInProgress.updateQueue = UPDATE_SIGNAL)) && + (workInProgress.effectTag |= 4); }; updateHostText$1 = function(current, workInProgress, oldText, newText) { oldText !== newText && (workInProgress.effectTag |= 4); }; +function logCapturedError(capturedError) { + var componentStack = capturedError.componentStack, + error = capturedError.error; + if (error instanceof Error) { + capturedError = error.message; + var name = error.name; + try { + error.message = + (capturedError ? name + ": " + capturedError : name) + + "\n\nThis error is located at:" + + componentStack; + } catch (e) {} + } else + error = + "string" === typeof error + ? Error(error + "\n\nThis error is located at:" + componentStack) + : Error("Unspecified error at:" + componentStack); + ExceptionsManager.handleException(error, !1); +} function logError(boundary, errorInfo) { var source = errorInfo.source, stack = errorInfo.stack; null === stack && null !== source && (stack = getStackByFiberInDevAndProd(source)); - null !== source && getComponentName(source.type); - source = null !== stack ? stack : ""; - errorInfo = errorInfo.value; - null !== boundary && 2 === boundary.tag && getComponentName(boundary.type); + errorInfo = { + componentName: null !== source ? getComponentName(source.type) : null, + componentStack: null !== stack ? stack : "", + error: errorInfo.value, + errorBoundary: null, + errorBoundaryName: null, + errorBoundaryFound: !1, + willRetry: !1 + }; + null !== boundary && + 2 === boundary.tag && + ((errorInfo.errorBoundary = boundary.stateNode), + (errorInfo.errorBoundaryName = getComponentName(boundary.type)), + (errorInfo.errorBoundaryFound = !0), + (errorInfo.willRetry = !0)); try { - if (errorInfo instanceof Error) { - var message = errorInfo.message, - name = errorInfo.name; - var errorToHandle = errorInfo; - try { - errorToHandle.message = - (message ? name + ": " + message : name) + - "\n\nThis error is located at:" + - source; - } catch (e) {} - } else - errorToHandle = - "string" === typeof errorInfo - ? Error(errorInfo + "\n\nThis error is located at:" + source) - : Error("Unspecified error at:" + source); - ExceptionsManager.handleException(errorToHandle, !1); + logCapturedError(errorInfo); } catch (e) { - (e && e.suppressReactErrorLogging) || console.error(e); + setTimeout(function() { + throw e; + }); } } function safelyDetachRef(current$$1) { @@ -4162,6 +4322,7 @@ function commitUnmount(current$$1) { onCommitFiberUnmount(current$$1); switch (current$$1.tag) { case 2: + case 3: safelyDetachRef(current$$1); var instance = current$$1.stateNode; if ("function" === typeof instance.componentWillUnmount) @@ -4173,15 +4334,15 @@ function commitUnmount(current$$1) { captureCommitPhaseError(current$$1, unmountError); } break; - case 5: + case 7: safelyDetachRef(current$$1); break; - case 4: + case 6: unmountHostComponents(current$$1); } } function isHostParent(fiber) { - return 5 === fiber.tag || 3 === fiber.tag || 4 === fiber.tag; + return 7 === fiber.tag || 5 === fiber.tag || 6 === fiber.tag; } function commitPlacement(finishedWork) { a: { @@ -4200,15 +4361,15 @@ function commitPlacement(finishedWork) { } var isContainer = (parent = void 0); switch (parentFiber.tag) { - case 5: + case 7: parent = parentFiber.stateNode; isContainer = !1; break; - case 3: + case 5: parent = parentFiber.stateNode.containerInfo; isContainer = !0; break; - case 4: + case 6: parent = parentFiber.stateNode.containerInfo; isContainer = !0; break; @@ -4230,11 +4391,11 @@ function commitPlacement(finishedWork) { parentFiber.sibling.return = parentFiber.return; for ( parentFiber = parentFiber.sibling; - 5 !== parentFiber.tag && 6 !== parentFiber.tag; + 7 !== parentFiber.tag && 8 !== parentFiber.tag; ) { if (parentFiber.effectTag & 2) continue b; - if (null === parentFiber.child || 4 === parentFiber.tag) continue b; + if (null === parentFiber.child || 6 === parentFiber.tag) continue b; else (parentFiber.child.return = parentFiber), (parentFiber = parentFiber.child); @@ -4245,7 +4406,7 @@ function commitPlacement(finishedWork) { } } for (var node = finishedWork; ; ) { - if (5 === node.tag || 6 === node.tag) + if (7 === node.tag || 8 === node.tag) if (parentFiber) if (isContainer) invariant( @@ -4314,7 +4475,7 @@ function commitPlacement(finishedWork) { [index.length - 1], [] ))); - else if (4 !== node.tag && null !== node.child) { + else if (6 !== node.tag && null !== node.child) { node.child.return = node; node = node.child; continue; @@ -4345,15 +4506,15 @@ function unmountHostComponents(current$$1) { "Expected to find a host parent. This error is likely caused by a bug in React. Please file an issue." ); switch (currentParentIsValid.tag) { - case 5: + case 7: currentParent = currentParentIsValid.stateNode; currentParentIsContainer = !1; break a; - case 3: + case 5: currentParent = currentParentIsValid.stateNode.containerInfo; currentParentIsContainer = !0; break a; - case 4: + case 6: currentParent = currentParentIsValid.stateNode.containerInfo; currentParentIsContainer = !0; break a; @@ -4362,11 +4523,11 @@ function unmountHostComponents(current$$1) { } currentParentIsValid = !0; } - if (5 === node.tag || 6 === node.tag) { + if (7 === node.tag || 8 === node.tag) { a: for (var root = node, node$jscomp$0 = root; ; ) if ( (commitUnmount(node$jscomp$0), - null !== node$jscomp$0.child && 4 !== node$jscomp$0.tag) + null !== node$jscomp$0.child && 6 !== node$jscomp$0.tag) ) (node$jscomp$0.child.return = node$jscomp$0), (node$jscomp$0 = node$jscomp$0.child); @@ -4394,7 +4555,7 @@ function unmountHostComponents(current$$1) { UIManager.manageChildren(root._nativeTag, [], [], [], [], [child]); } } else if ( - (4 === node.tag + (6 === node.tag ? ((currentParent = node.stateNode.containerInfo), (currentParentIsContainer = !0)) : commitUnmount(node), @@ -4408,7 +4569,7 @@ function unmountHostComponents(current$$1) { for (; null === node.sibling; ) { if (null === node.return || node.return === current$$1) return; node = node.return; - 4 === node.tag && (currentParentIsValid = !1); + 6 === node.tag && (currentParentIsValid = !1); } node.sibling.return = node.return; node = node.sibling; @@ -4417,8 +4578,9 @@ function unmountHostComponents(current$$1) { function commitWork(current$$1, finishedWork) { switch (finishedWork.tag) { case 2: + case 3: break; - case 5: + case 7: var instance = finishedWork.stateNode; if (null != instance) { var newProps = finishedWork.memoizedProps; @@ -4442,7 +4604,7 @@ function commitWork(current$$1, finishedWork) { )); } break; - case 6: + case 8: invariant( null !== finishedWork.stateNode, "This should have a text node initialized. This error is likely caused by a bug in React. Please file an issue." @@ -4451,18 +4613,9 @@ function commitWork(current$$1, finishedWork) { text: finishedWork.memoizedProps }); break; - case 3: + case 5: break; case 15: - instance = finishedWork.memoizedProps.onRender; - instance( - finishedWork.memoizedProps.id, - null === current$$1 ? "mount" : "update", - finishedWork.actualDuration, - finishedWork.treeBaseDuration, - finishedWork.actualStartTime, - commitTime - ); break; case 16: break; @@ -4503,17 +4656,75 @@ function createClassErrorUpdate(fiber, errorInfo, expirationTime) { }); return expirationTime; } +function throwException( + root, + returnFiber, + sourceFiber, + value, + renderExpirationTime +) { + sourceFiber.effectTag |= 512; + sourceFiber.firstEffect = sourceFiber.lastEffect = null; + nextRenderDidError = !0; + value = createCapturedValue(value, sourceFiber); + root = returnFiber; + do { + switch (root.tag) { + case 5: + root.effectTag |= 1024; + root.expirationTime = renderExpirationTime; + renderExpirationTime = createRootErrorUpdate( + root, + value, + renderExpirationTime + ); + enqueueCapturedUpdate(root, renderExpirationTime); + return; + case 2: + case 3: + if ( + ((returnFiber = value), + (sourceFiber = root.stateNode), + 0 === (root.effectTag & 64) && + null !== sourceFiber && + "function" === typeof sourceFiber.componentDidCatch && + (null === legacyErrorBoundariesThatAlreadyFailed || + !legacyErrorBoundariesThatAlreadyFailed.has(sourceFiber))) + ) { + root.effectTag |= 1024; + root.expirationTime = renderExpirationTime; + renderExpirationTime = createClassErrorUpdate( + root, + returnFiber, + renderExpirationTime + ); + enqueueCapturedUpdate(root, renderExpirationTime); + return; + } + } + root = root.return; + } while (null !== root); +} function unwindWork(workInProgress) { - workInProgress.mode & 4 && recordElapsedActualRenderTime(workInProgress); switch (workInProgress.tag) { case 2: - popContextProvider(workInProgress); + isContextProvider(workInProgress.type) && popContext(workInProgress); var effectTag = workInProgress.effectTag; return effectTag & 1024 ? ((workInProgress.effectTag = (effectTag & -1025) | 64), workInProgress) : null; case 3: + return ( + isContextProvider(workInProgress.type._reactResult) && + popContext(workInProgress), + (effectTag = workInProgress.effectTag), + effectTag & 1024 + ? ((workInProgress.effectTag = (effectTag & -1025) | 64), + workInProgress) + : null + ); + case 5: return ( popHostContainer(workInProgress), popTopLevelContextObject(workInProgress), @@ -4525,7 +4736,7 @@ function unwindWork(workInProgress) { (workInProgress.effectTag = (effectTag & -1025) | 64), workInProgress ); - case 5: + case 7: return popHostContext(workInProgress), null; case 16: return ( @@ -4535,26 +4746,30 @@ function unwindWork(workInProgress) { workInProgress) : null ); - case 4: + case 6: return popHostContainer(workInProgress), null; - case 13: + case 12: return popProvider(workInProgress), null; default: return null; } } var Dispatcher = { readContext: readContext }, - ReactCurrentOwner$2 = ReactSharedInternals.ReactCurrentOwner, - lastUniqueAsyncExpiration = 0, - expirationContext = 0, - isWorking = !1, + ReactCurrentOwner$2 = ReactSharedInternals.ReactCurrentOwner; +invariant( + null != tracking.__interactionsRef && + null != tracking.__interactionsRef.current, + "It is not supported to run the profiling version of a renderer (for example, `react-dom/profiling`) without also replacing the `schedule/tracking` module with `schedule/tracking-profiling`. Your bundler might have a setting for aliasing both modules. Learn more at http://fb.me/react-profiling" +); +var isWorking = !1, nextUnitOfWork = null, nextRoot = null, nextRenderExpirationTime = 0, nextRenderDidError = !1, nextEffect = null, isCommitting$1 = !1, - legacyErrorBoundariesThatAlreadyFailed = null; + legacyErrorBoundariesThatAlreadyFailed = null, + suspenseDidTimeout = !1; function resetStack() { if (null !== nextUnitOfWork) for ( @@ -4562,25 +4777,33 @@ function resetStack() { null !== interruptedWork; ) { - interruptedWork.mode & 4 && resumeActualRenderTimerIfPaused(!1); var interruptedWork$jscomp$0 = interruptedWork; - interruptedWork$jscomp$0.mode & 4 && - recordElapsedActualRenderTime(interruptedWork$jscomp$0); switch (interruptedWork$jscomp$0.tag) { case 2: - popContextProvider(interruptedWork$jscomp$0); + var childContextTypes = + interruptedWork$jscomp$0.type.childContextTypes; + null !== childContextTypes && + void 0 !== childContextTypes && + popContext(interruptedWork$jscomp$0); break; case 3: + childContextTypes = + interruptedWork$jscomp$0.type._reactResult.childContextTypes; + null !== childContextTypes && + void 0 !== childContextTypes && + popContext(interruptedWork$jscomp$0); + break; + case 5: popHostContainer(interruptedWork$jscomp$0); popTopLevelContextObject(interruptedWork$jscomp$0); break; - case 5: + case 7: popHostContext(interruptedWork$jscomp$0); break; - case 4: + case 6: popHostContainer(interruptedWork$jscomp$0); break; - case 13: + case 12: popProvider(interruptedWork$jscomp$0); } interruptedWork = interruptedWork.return; @@ -4590,132 +4813,429 @@ function resetStack() { nextRenderDidError = !1; nextUnitOfWork = null; } +function commitAllHostEffects() { + for (; null !== nextEffect; ) { + var effectTag = nextEffect.effectTag; + if (effectTag & 128) { + var current$$1 = nextEffect.alternate; + null !== current$$1 && + ((current$$1 = current$$1.ref), + null !== current$$1 && + ("function" === typeof current$$1 + ? current$$1(null) + : (current$$1.current = null))); + } + switch (effectTag & 14) { + case 2: + commitPlacement(nextEffect); + nextEffect.effectTag &= -3; + break; + case 6: + commitPlacement(nextEffect); + nextEffect.effectTag &= -3; + commitWork(nextEffect.alternate, nextEffect); + break; + case 4: + commitWork(nextEffect.alternate, nextEffect); + break; + case 8: + (effectTag = nextEffect), + unmountHostComponents(effectTag), + (effectTag.return = null), + (effectTag.child = null), + effectTag.alternate && + ((effectTag.alternate.child = null), + (effectTag.alternate.return = null)); + } + nextEffect = nextEffect.nextEffect; + } +} +function commitBeforeMutationLifecycles() { + for (; null !== nextEffect; ) { + if (nextEffect.effectTag & 256) { + var current$$1 = nextEffect.alternate; + a: { + var finishedWork = nextEffect; + switch (finishedWork.tag) { + case 2: + case 3: + if (finishedWork.effectTag & 256 && null !== current$$1) { + var prevProps = current$$1.memoizedProps, + prevState = current$$1.memoizedState; + current$$1 = finishedWork.stateNode; + current$$1.props = finishedWork.memoizedProps; + current$$1.state = finishedWork.memoizedState; + finishedWork = current$$1.getSnapshotBeforeUpdate( + prevProps, + prevState + ); + current$$1.__reactInternalSnapshotBeforeUpdate = finishedWork; + } + break a; + case 5: + case 7: + case 8: + case 6: + break a; + default: + invariant( + !1, + "This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue." + ); + } + } + } + nextEffect = nextEffect.nextEffect; + } +} +function commitAllLifeCycles( + finishedRoot$jscomp$0, + committedExpirationTime$jscomp$0 +) { + for (; null !== nextEffect; ) { + var effectTag = nextEffect.effectTag; + if (effectTag & 36) { + var finishedRoot = finishedRoot$jscomp$0, + current$$1 = nextEffect.alternate, + finishedWork = nextEffect, + committedExpirationTime = committedExpirationTime$jscomp$0; + switch (finishedWork.tag) { + case 2: + case 3: + finishedRoot = finishedWork.stateNode; + if (finishedWork.effectTag & 4) + if (null === current$$1) + (finishedRoot.props = finishedWork.memoizedProps), + (finishedRoot.state = finishedWork.memoizedState), + finishedRoot.componentDidMount(); + else { + var prevProps = current$$1.memoizedProps; + current$$1 = current$$1.memoizedState; + finishedRoot.props = finishedWork.memoizedProps; + finishedRoot.state = finishedWork.memoizedState; + finishedRoot.componentDidUpdate( + prevProps, + current$$1, + finishedRoot.__reactInternalSnapshotBeforeUpdate + ); + } + current$$1 = finishedWork.updateQueue; + null !== current$$1 && + ((finishedRoot.props = finishedWork.memoizedProps), + (finishedRoot.state = finishedWork.memoizedState), + commitUpdateQueue( + finishedWork, + current$$1, + finishedRoot, + committedExpirationTime + )); + break; + case 5: + current$$1 = finishedWork.updateQueue; + if (null !== current$$1) { + finishedRoot = null; + if (null !== finishedWork.child) + switch (finishedWork.child.tag) { + case 7: + finishedRoot = finishedWork.child.stateNode; + break; + case 2: + case 3: + finishedRoot = finishedWork.child.stateNode; + } + commitUpdateQueue( + finishedWork, + current$$1, + finishedRoot, + committedExpirationTime + ); + } + break; + case 7: + break; + case 8: + break; + case 6: + break; + case 15: + committedExpirationTime = finishedWork.memoizedProps.onRender; + committedExpirationTime( + finishedWork.memoizedProps.id, + null === current$$1 ? "mount" : "update", + finishedWork.actualDuration, + finishedWork.treeBaseDuration, + finishedWork.actualStartTime, + commitTime, + finishedRoot.memoizedInteractions + ); + break; + case 16: + break; + default: + invariant( + !1, + "This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue." + ); + } + } + effectTag & 128 && + ((effectTag = nextEffect.ref), + null !== effectTag && + ((finishedWork = nextEffect.stateNode), + "function" === typeof effectTag + ? effectTag(finishedWork) + : (effectTag.current = finishedWork))); + effectTag = nextEffect.nextEffect; + nextEffect.nextEffect = null; + nextEffect = effectTag; + } +} +function commitRoot(root, finishedWork) { + isCommitting$1 = isWorking = !0; + invariant( + root.current !== finishedWork, + "Cannot commit the same tree as before. This is probably a bug related to the return field. This error is likely caused by a bug in React. Please file an issue." + ); + var committedExpirationTime = root.pendingCommitExpirationTime; + invariant( + 0 !== committedExpirationTime, + "Cannot commit an incomplete root. This error is likely caused by a bug in React. Please file an issue." + ); + root.pendingCommitExpirationTime = 0; + var updateExpirationTimeBeforeCommit = finishedWork.expirationTime, + childExpirationTimeBeforeCommit = finishedWork.childExpirationTime; + markCommittedPriorityLevels( + root, + 0 === updateExpirationTimeBeforeCommit || + (0 !== childExpirationTimeBeforeCommit && + childExpirationTimeBeforeCommit < updateExpirationTimeBeforeCommit) + ? childExpirationTimeBeforeCommit + : updateExpirationTimeBeforeCommit + ); + updateExpirationTimeBeforeCommit = null; + var committedInteractions = []; + updateExpirationTimeBeforeCommit = tracking.__interactionsRef.current; + tracking.__interactionsRef.current = root.memoizedInteractions; + root.pendingInteractionMap.forEach(function( + scheduledInteractions, + scheduledExpirationTime + ) { + scheduledExpirationTime <= committedExpirationTime && + (committedInteractions.push.apply( + committedInteractions, + Array.from(scheduledInteractions) + ), + root.pendingInteractionMap.delete(scheduledExpirationTime)); + }); + ReactCurrentOwner$2.current = null; + childExpirationTimeBeforeCommit = void 0; + 1 < finishedWork.effectTag + ? null !== finishedWork.lastEffect + ? ((finishedWork.lastEffect.nextEffect = finishedWork), + (childExpirationTimeBeforeCommit = finishedWork.firstEffect)) + : (childExpirationTimeBeforeCommit = finishedWork) + : (childExpirationTimeBeforeCommit = finishedWork.firstEffect); + for (nextEffect = childExpirationTimeBeforeCommit; null !== nextEffect; ) { + var didError = !1, + error$jscomp$0 = void 0; + try { + commitBeforeMutationLifecycles(); + } catch (e) { + (didError = !0), (error$jscomp$0 = e); + } + didError && + (invariant( + null !== nextEffect, + "Should have next effect. This error is likely caused by a bug in React. Please file an issue." + ), + captureCommitPhaseError(nextEffect, error$jscomp$0), + null !== nextEffect && (nextEffect = nextEffect.nextEffect)); + } + commitTime = now$1(); + for (nextEffect = childExpirationTimeBeforeCommit; null !== nextEffect; ) { + didError = !1; + error$jscomp$0 = void 0; + try { + commitAllHostEffects(); + } catch (e) { + (didError = !0), (error$jscomp$0 = e); + } + didError && + (invariant( + null !== nextEffect, + "Should have next effect. This error is likely caused by a bug in React. Please file an issue." + ), + captureCommitPhaseError(nextEffect, error$jscomp$0), + null !== nextEffect && (nextEffect = nextEffect.nextEffect)); + } + root.current = finishedWork; + for (nextEffect = childExpirationTimeBeforeCommit; null !== nextEffect; ) { + childExpirationTimeBeforeCommit = !1; + didError = void 0; + try { + commitAllLifeCycles(root, committedExpirationTime); + } catch (e) { + (childExpirationTimeBeforeCommit = !0), (didError = e); + } + childExpirationTimeBeforeCommit && + (invariant( + null !== nextEffect, + "Should have next effect. This error is likely caused by a bug in React. Please file an issue." + ), + captureCommitPhaseError(nextEffect, didError), + null !== nextEffect && (nextEffect = nextEffect.nextEffect)); + } + isWorking = isCommitting$1 = !1; + "function" === typeof onCommitFiberRoot && + onCommitFiberRoot(finishedWork.stateNode); + childExpirationTimeBeforeCommit = finishedWork.expirationTime; + finishedWork = finishedWork.childExpirationTime; + finishedWork = + 0 === childExpirationTimeBeforeCommit || + (0 !== finishedWork && finishedWork < childExpirationTimeBeforeCommit) + ? finishedWork + : childExpirationTimeBeforeCommit; + 0 === finishedWork && (legacyErrorBoundariesThatAlreadyFailed = null); + onCommit(root, finishedWork); + tracking.__interactionsRef.current = updateExpirationTimeBeforeCommit; + var subscriber = void 0; + try { + if ( + ((subscriber = tracking.__subscriberRef.current), + null !== subscriber && 0 < root.memoizedInteractions.size) + ) + subscriber.onWorkStopped( + root.memoizedInteractions, + 1e3 * committedExpirationTime + root.interactionThreadID + ); + } catch (error) { + hasUnhandledError || ((hasUnhandledError = !0), (unhandledError = error)); + } finally { + suspenseDidTimeout || + committedInteractions.forEach(function(interaction) { + interaction.__count--; + if (null !== subscriber && 0 === interaction.__count) + try { + subscriber.onInteractionScheduledWorkCompleted(interaction); + } catch (error) { + hasUnhandledError || + ((hasUnhandledError = !0), (unhandledError = error)); + } + }); + } +} function completeUnitOfWork(workInProgress) { for (;;) { var current$$1 = workInProgress.alternate, returnFiber = workInProgress.return, siblingFiber = workInProgress.sibling; if (0 === (workInProgress.effectTag & 512)) { + if (workInProgress.mode & 4) { + var fiber = workInProgress; + profilerStartTime = now$1(); + 0 > fiber.actualStartTime && (fiber.actualStartTime = now$1()); + } var current = current$$1; current$$1 = workInProgress; - var newProps = current$$1.pendingProps; + fiber = current$$1.pendingProps; switch (current$$1.tag) { + case 0: case 1: break; case 2: - popContextProvider(current$$1); + isContextProvider(current$$1.type) && popContext(current$$1); break; case 3: + isContextProvider(current$$1.type._reactResult) && + popContext(current$$1); + break; + case 5: popHostContainer(current$$1); popTopLevelContextObject(current$$1); - newProps = current$$1.stateNode; - newProps.pendingContext && - ((newProps.context = newProps.pendingContext), - (newProps.pendingContext = null)); + fiber = current$$1.stateNode; + fiber.pendingContext && + ((fiber.context = fiber.pendingContext), + (fiber.pendingContext = null)); if (null === current || null === current.child) current$$1.effectTag &= -3; updateHostContainer(current$$1); break; - case 5: + case 7: popHostContext(current$$1); var rootContainerInstance = requiredContext( rootInstanceStackCursor.current ), type = current$$1.type; - if (null !== current && null != current$$1.stateNode) { - var oldProps = current.memoizedProps, - currentHostContext = requiredContext( - contextStackCursor$1.current - ); + if (null !== current && null != current$$1.stateNode) updateHostComponent$1( current, current$$1, - UPDATE_SIGNAL, type, - oldProps, - newProps, - rootContainerInstance, - currentHostContext - ); - current.ref !== current$$1.ref && (current$$1.effectTag |= 128); - } else if (newProps) { + fiber, + rootContainerInstance + ), + current.ref !== current$$1.ref && (current$$1.effectTag |= 128); + else if (fiber) { current = requiredContext(contextStackCursor$1.current); - var type$jscomp$0 = type; - oldProps = newProps; - var rootContainerInstance$jscomp$0 = rootContainerInstance, - hostContext = current; - currentHostContext = current$$1; - var tag = allocateTag(), - viewConfig = ReactNativeViewConfigRegistry.get(type$jscomp$0); + var internalInstanceHandle = current$$1, + tag = allocateTag(), + viewConfig = ReactNativeViewConfigRegistry.get(type); invariant( - "RCTView" !== type$jscomp$0 || !hostContext.isInAParentText, + "RCTView" !== type || !current.isInAParentText, "Nesting of within is not currently supported." ); - type$jscomp$0 = diffProperties( + var updatePayload = diffProperties( null, emptyObject, - oldProps, + fiber, viewConfig.validAttributes ); UIManager.createView( tag, viewConfig.uiViewClassName, - rootContainerInstance$jscomp$0, - type$jscomp$0 + rootContainerInstance, + updatePayload ); - rootContainerInstance$jscomp$0 = new ReactNativeFiberHostComponent( - tag, - viewConfig - ); - instanceCache[tag] = currentHostContext; - instanceProps[tag] = oldProps; - oldProps = rootContainerInstance$jscomp$0; + viewConfig = new ReactNativeFiberHostComponent(tag, viewConfig); + instanceCache[tag] = internalInstanceHandle; + instanceProps[tag] = fiber; a: for ( - currentHostContext = oldProps, + internalInstanceHandle = viewConfig, tag = current$$1, - rootContainerInstance$jscomp$0 = tag.child; - null !== rootContainerInstance$jscomp$0; + updatePayload = tag.child; + null !== updatePayload; ) { - if ( - 5 === rootContainerInstance$jscomp$0.tag || - 6 === rootContainerInstance$jscomp$0.tag - ) - currentHostContext._children.push( - rootContainerInstance$jscomp$0.stateNode - ); + if (7 === updatePayload.tag || 8 === updatePayload.tag) + internalInstanceHandle._children.push(updatePayload.stateNode); else if ( - 4 !== rootContainerInstance$jscomp$0.tag && - null !== rootContainerInstance$jscomp$0.child + 6 !== updatePayload.tag && + null !== updatePayload.child ) { - rootContainerInstance$jscomp$0.child.return = rootContainerInstance$jscomp$0; - rootContainerInstance$jscomp$0 = - rootContainerInstance$jscomp$0.child; + updatePayload.child.return = updatePayload; + updatePayload = updatePayload.child; continue; } - if (rootContainerInstance$jscomp$0 === tag) break; - for (; null === rootContainerInstance$jscomp$0.sibling; ) { + if (updatePayload === tag) break; + for (; null === updatePayload.sibling; ) { if ( - null === rootContainerInstance$jscomp$0.return || - rootContainerInstance$jscomp$0.return === tag + null === updatePayload.return || + updatePayload.return === tag ) break a; - rootContainerInstance$jscomp$0 = - rootContainerInstance$jscomp$0.return; + updatePayload = updatePayload.return; } - rootContainerInstance$jscomp$0.sibling.return = - rootContainerInstance$jscomp$0.return; - rootContainerInstance$jscomp$0 = - rootContainerInstance$jscomp$0.sibling; + updatePayload.sibling.return = updatePayload.return; + updatePayload = updatePayload.sibling; } finalizeInitialChildren( - oldProps, + viewConfig, type, - newProps, + fiber, rootContainerInstance, current ) && (current$$1.effectTag |= 4); - current$$1.stateNode = oldProps; + current$$1.stateNode = viewConfig; null !== current$$1.ref && (current$$1.effectTag |= 128); } else invariant( @@ -4723,54 +5243,54 @@ function completeUnitOfWork(workInProgress) { "We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue." ); break; - case 6: - type = newProps; + case 8: current && null != current$$1.stateNode - ? updateHostText$1(current, current$$1, current.memoizedProps, type) - : ("string" !== typeof type && + ? updateHostText$1( + current, + current$$1, + current.memoizedProps, + fiber + ) + : ("string" !== typeof fiber && invariant( null !== current$$1.stateNode, "We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue." ), (current = requiredContext(rootInstanceStackCursor.current)), - (rootContainerInstance = requiredContext( - contextStackCursor$1.current - )), - (oldProps = newProps = current$$1), + (type = requiredContext(contextStackCursor$1.current)), + (rootContainerInstance = current$$1), invariant( - rootContainerInstance.isInAParentText, + type.isInAParentText, "Text strings must be rendered within a component." ), - (rootContainerInstance = allocateTag()), - UIManager.createView( - rootContainerInstance, - "RCTRawText", - current, - { text: type } - ), - (instanceCache[rootContainerInstance] = oldProps), - (newProps.stateNode = rootContainerInstance)); + (type = allocateTag()), + UIManager.createView(type, "RCTRawText", current, { + text: fiber + }), + (instanceCache[type] = current$$1), + (rootContainerInstance.stateNode = type)); break; + case 13: case 14: break; case 16: break; - case 10: + case 9: break; - case 11: + case 10: break; case 15: break; - case 4: + case 6: popHostContainer(current$$1); updateHostContainer(current$$1); break; - case 13: + case 12: popProvider(current$$1); break; - case 12: + case 11: break; - case 0: + case 4: invariant( !1, "An indeterminate component should have become determinate before completing. This error is likely caused by a bug in React. Please file an issue." @@ -4781,38 +5301,48 @@ function completeUnitOfWork(workInProgress) { "Unknown unit of work tag. This error is likely caused by a bug in React. Please file an issue." ); } - current$$1.mode & 4 && recordElapsedActualRenderTime(current$$1); - current$$1 = nextUnitOfWork = null; - newProps = workInProgress; + nextUnitOfWork = null; + workInProgress.mode & 4 && + stopProfilerTimerIfRunningAndRecordDelta(workInProgress, !1); + current$$1 = nextUnitOfWork; + fiber = workInProgress; if ( 1073741823 === nextRenderExpirationTime || - 1073741823 !== newProps.childExpirationTime + 1073741823 !== fiber.childExpirationTime ) { rootContainerInstance = 0; - if (newProps.mode & 4) { - type = newProps.selfBaseDuration; - for (current = newProps.child; null !== current; ) { - oldProps = current.expirationTime; - currentHostContext = current.childExpirationTime; + if (fiber.mode & 4) { + type = fiber.actualDuration; + current = fiber.selfBaseDuration; + viewConfig = + null === fiber.alternate || fiber.child !== fiber.alternate.child; + for ( + internalInstanceHandle = fiber.child; + null !== internalInstanceHandle; + + ) { + tag = internalInstanceHandle.expirationTime; + updatePayload = internalInstanceHandle.childExpirationTime; if ( 0 === rootContainerInstance || - (0 !== oldProps && oldProps < rootContainerInstance) + (0 !== tag && tag < rootContainerInstance) ) - rootContainerInstance = oldProps; + rootContainerInstance = tag; if ( 0 === rootContainerInstance || - (0 !== currentHostContext && - currentHostContext < rootContainerInstance) + (0 !== updatePayload && updatePayload < rootContainerInstance) ) - rootContainerInstance = currentHostContext; - type += current.treeBaseDuration; - current = current.sibling; + rootContainerInstance = updatePayload; + viewConfig && (type += internalInstanceHandle.actualDuration); + current += internalInstanceHandle.treeBaseDuration; + internalInstanceHandle = internalInstanceHandle.sibling; } - newProps.treeBaseDuration = type; + fiber.actualDuration = type; + fiber.treeBaseDuration = current; } else - for (type = newProps.child; null !== type; ) { + for (type = fiber.child; null !== type; ) { current = type.expirationTime; - oldProps = type.childExpirationTime; + viewConfig = type.childExpirationTime; if ( 0 === rootContainerInstance || (0 !== current && current < rootContainerInstance) @@ -4820,12 +5350,12 @@ function completeUnitOfWork(workInProgress) { rootContainerInstance = current; if ( 0 === rootContainerInstance || - (0 !== oldProps && oldProps < rootContainerInstance) + (0 !== viewConfig && viewConfig < rootContainerInstance) ) - rootContainerInstance = oldProps; + rootContainerInstance = viewConfig; type = type.sibling; } - newProps.childExpirationTime = rootContainerInstance; + fiber.childExpirationTime = rootContainerInstance; } if (null !== current$$1) return current$$1; null !== returnFiber && @@ -4842,9 +5372,20 @@ function completeUnitOfWork(workInProgress) { : (returnFiber.firstEffect = workInProgress), (returnFiber.lastEffect = workInProgress))); } else { + workInProgress.mode & 4 && + stopProfilerTimerIfRunningAndRecordDelta(workInProgress, !1); workInProgress = unwindWork(workInProgress, nextRenderExpirationTime); - if (null !== workInProgress) - return (workInProgress.effectTag &= 511), workInProgress; + if (null !== workInProgress) { + if (workInProgress.mode & 4) { + returnFiber = workInProgress.actualDuration; + for (siblingFiber = workInProgress.child; null !== siblingFiber; ) + (returnFiber += siblingFiber.actualDuration), + (siblingFiber = siblingFiber.sibling); + workInProgress.actualDuration = returnFiber; + } + workInProgress.effectTag &= 511; + return workInProgress; + } null !== returnFiber && ((returnFiber.firstEffect = returnFiber.lastEffect = null), (returnFiber.effectTag |= 512)); @@ -4857,12 +5398,13 @@ function completeUnitOfWork(workInProgress) { } function performUnitOfWork(workInProgress) { var current$$1 = workInProgress.alternate; - workInProgress.mode & 4 && (baseStartTime = now$1()); + workInProgress.mode & 4 && + ((profilerStartTime = now$1()), + 0 > workInProgress.actualStartTime && + (workInProgress.actualStartTime = now$1())); current$$1 = beginWork(current$$1, workInProgress, nextRenderExpirationTime); workInProgress.mode & 4 && - (-1 !== baseStartTime && - (workInProgress.selfBaseDuration = now$1() - baseStartTime), - (baseStartTime = -1)); + stopProfilerTimerIfRunningAndRecordDelta(workInProgress, !0); null === current$$1 && (current$$1 = completeUnitOfWork(workInProgress)); ReactCurrentOwner$2.current = null; return current$$1; @@ -4874,98 +5416,88 @@ function renderRoot(root, isYieldy, isExpired) { ); isWorking = !0; ReactCurrentOwner$2.currentDispatcher = Dispatcher; - var expirationTime = root.nextExpirationTimeToWorkOn; + var expirationTime = root.nextExpirationTimeToWorkOn, + prevInteractions = null; + prevInteractions = tracking.__interactionsRef.current; + tracking.__interactionsRef.current = root.memoizedInteractions; if ( expirationTime !== nextRenderExpirationTime || root !== nextRoot || null === nextUnitOfWork - ) - resetStack(), - (nextRoot = root), - (nextRenderExpirationTime = expirationTime), - (nextUnitOfWork = createWorkInProgress( - nextRoot.current, - null, - nextRenderExpirationTime - )), - (root.pendingCommitExpirationTime = 0); - var didFatal = !1; + ) { + resetStack(); + nextRoot = root; + nextRenderExpirationTime = expirationTime; + nextUnitOfWork = createWorkInProgress( + nextRoot.current, + null, + nextRenderExpirationTime + ); + root.pendingCommitExpirationTime = 0; + var interactions = new Set(); + root.pendingInteractionMap.forEach(function( + scheduledInteractions, + scheduledExpirationTime + ) { + scheduledExpirationTime <= expirationTime && + scheduledInteractions.forEach(function(interaction) { + return interactions.add(interaction); + }); + }); + root.memoizedInteractions = interactions; + if (0 < interactions.size) { + var subscriber = tracking.__subscriberRef.current; + if (null !== subscriber) { + var threadID = 1e3 * expirationTime + root.interactionThreadID; + try { + subscriber.onWorkStarted(interactions, threadID); + } catch (error) { + hasUnhandledError || + ((hasUnhandledError = !0), (unhandledError = error)); + } + } + } + } + subscriber = !1; do { try { - if (isYieldy) { + if (isYieldy) for (; null !== nextUnitOfWork && !shouldYield(); ) nextUnitOfWork = performUnitOfWork(nextUnitOfWork); - pauseActualRenderTimerIfRunning(); - } else + else for (; null !== nextUnitOfWork; ) nextUnitOfWork = performUnitOfWork(nextUnitOfWork); } catch (thrownValue) { - if (((baseStartTime = -1), null === nextUnitOfWork)) - (didFatal = !0), onUncaughtError(thrownValue); + if (null === nextUnitOfWork) + (subscriber = !0), onUncaughtError(thrownValue); else { invariant( null !== nextUnitOfWork, "Failed to replay rendering after an error. This is likely caused by a bug in React. Please file an issue with a reproducing case to help us find it." ); - var sourceFiber = nextUnitOfWork, - returnFiber = sourceFiber.return; - if (null === returnFiber) (didFatal = !0), onUncaughtError(thrownValue); + threadID = nextUnitOfWork; + var returnFiber = threadID.return; + if (null === returnFiber) + (subscriber = !0), onUncaughtError(thrownValue); else { - a: { - var returnFiber$jscomp$0 = returnFiber, - sourceFiber$jscomp$0 = sourceFiber, - value = thrownValue; - returnFiber = nextRenderExpirationTime; - sourceFiber$jscomp$0.effectTag |= 512; - sourceFiber$jscomp$0.firstEffect = sourceFiber$jscomp$0.lastEffect = null; - nextRenderDidError = !0; - value = createCapturedValue(value, sourceFiber$jscomp$0); - do { - switch (returnFiber$jscomp$0.tag) { - case 3: - returnFiber$jscomp$0.effectTag |= 1024; - returnFiber$jscomp$0.expirationTime = returnFiber; - returnFiber = createRootErrorUpdate( - returnFiber$jscomp$0, - value, - returnFiber - ); - enqueueCapturedUpdate(returnFiber$jscomp$0, returnFiber); - break a; - case 2: - sourceFiber$jscomp$0 = value; - var instance = returnFiber$jscomp$0.stateNode; - if ( - 0 === (returnFiber$jscomp$0.effectTag & 64) && - null !== instance && - "function" === typeof instance.componentDidCatch && - (null === legacyErrorBoundariesThatAlreadyFailed || - !legacyErrorBoundariesThatAlreadyFailed.has(instance)) - ) { - returnFiber$jscomp$0.effectTag |= 1024; - returnFiber$jscomp$0.expirationTime = returnFiber; - returnFiber = createClassErrorUpdate( - returnFiber$jscomp$0, - sourceFiber$jscomp$0, - returnFiber - ); - enqueueCapturedUpdate(returnFiber$jscomp$0, returnFiber); - break a; - } - } - returnFiber$jscomp$0 = returnFiber$jscomp$0.return; - } while (null !== returnFiber$jscomp$0); - } - nextUnitOfWork = completeUnitOfWork(sourceFiber); + throwException( + root, + returnFiber, + threadID, + thrownValue, + nextRenderExpirationTime + ); + nextUnitOfWork = completeUnitOfWork(threadID); continue; } } } break; } while (1); + tracking.__interactionsRef.current = prevInteractions; isWorking = !1; lastContextWithAllBitsObserved = lastContextDependency = currentlyRenderingFiber = ReactCurrentOwner$2.currentDispatcher = null; - if (didFatal) (nextRoot = null), (root.finishedWork = null); + if (subscriber) (nextRoot = null), (root.finishedWork = null); else if (null !== nextUnitOfWork) root.finishedWork = null; else { isYieldy = root.current.alternate; @@ -4975,48 +5507,20 @@ function renderRoot(root, isYieldy, isExpired) { ); nextRoot = null; if (nextRenderDidError) { - didFatal = root.latestPendingTime; - sourceFiber = root.latestSuspendedTime; - returnFiber = root.latestPingedTime; - if ( - (0 !== didFatal && didFatal > expirationTime) || - (0 !== sourceFiber && sourceFiber > expirationTime) || - (0 !== returnFiber && returnFiber > expirationTime) - ) { - root.didError = !1; - isExpired = root.latestPingedTime; - 0 !== isExpired && - isExpired <= expirationTime && - (root.latestPingedTime = 0); - isExpired = root.earliestPendingTime; - isYieldy = root.latestPendingTime; - isExpired === expirationTime - ? (root.earliestPendingTime = - isYieldy === expirationTime - ? (root.latestPendingTime = 0) - : isYieldy) - : isYieldy === expirationTime && (root.latestPendingTime = isExpired); - isExpired = root.earliestSuspendedTime; - isYieldy = root.latestSuspendedTime; - 0 === isExpired - ? (root.earliestSuspendedTime = root.latestSuspendedTime = expirationTime) - : isExpired > expirationTime - ? (root.earliestSuspendedTime = expirationTime) - : isYieldy < expirationTime && - (root.latestSuspendedTime = expirationTime); - findNextExpirationTimeToWorkOn(expirationTime, root); - root.expirationTime = root.expirationTime; + if (hasLowerPriorityWork(root, expirationTime)) { + markSuspendedPriorityLevel(root, expirationTime); + onSuspend(root, isYieldy, expirationTime, root.expirationTime, -1); return; } if (!root.didError && !isExpired) { root.didError = !0; - root.nextExpirationTimeToWorkOn = expirationTime; - root.expirationTime = 1; + isExpired = root.nextExpirationTimeToWorkOn = expirationTime; + prevInteractions = root.expirationTime = 1; + onSuspend(root, isYieldy, isExpired, prevInteractions, -1); return; } } - root.pendingCommitExpirationTime = expirationTime; - root.finishedWork = isYieldy; + onComplete(root, isYieldy, expirationTime); } } function captureCommitPhaseError(fiber, error) { @@ -5033,6 +5537,7 @@ function captureCommitPhaseError(fiber, error) { ) { switch (JSCompiler_inline_result.tag) { case 2: + case 3: var instance = JSCompiler_inline_result.stateNode; if ( "function" === @@ -5049,7 +5554,7 @@ function captureCommitPhaseError(fiber, error) { break a; } break; - case 3: + case 5: fiber = createCapturedValue(error, fiber); fiber = createRootErrorUpdate(JSCompiler_inline_result, fiber, 1); enqueueUpdate(JSCompiler_inline_result, fiber); @@ -5059,7 +5564,7 @@ function captureCommitPhaseError(fiber, error) { } JSCompiler_inline_result = JSCompiler_inline_result.return; } - 3 === fiber.tag && + 5 === fiber.tag && ((JSCompiler_inline_result = createCapturedValue(error, fiber)), (JSCompiler_inline_result = createRootErrorUpdate( fiber, @@ -5073,24 +5578,50 @@ function captureCommitPhaseError(fiber, error) { return JSCompiler_inline_result; } function computeExpirationForFiber(currentTime, fiber) { - 0 !== expirationContext - ? (currentTime = expirationContext) - : isWorking - ? (currentTime = isCommitting$1 ? 1 : nextRenderExpirationTime) - : fiber.mode & 1 - ? ((currentTime = isBatchingInteractiveUpdates - ? 2 + 10 * ((((currentTime - 2 + 15) / 10) | 0) + 1) - : 2 + 25 * ((((currentTime - 2 + 500) / 25) | 0) + 1)), - null !== nextRoot && - currentTime === nextRenderExpirationTime && - (currentTime += 1)) - : (currentTime = 1); + isWorking + ? (currentTime = isCommitting$1 ? 1 : nextRenderExpirationTime) + : fiber.mode & 1 + ? ((currentTime = isBatchingInteractiveUpdates + ? 2 + 10 * ((((currentTime - 2 + 15) / 10) | 0) + 1) + : 2 + 25 * ((((currentTime - 2 + 500) / 25) | 0) + 1)), + null !== nextRoot && + currentTime === nextRenderExpirationTime && + (currentTime += 1)) + : (currentTime = 1); isBatchingInteractiveUpdates && - (0 === lowestPendingInteractiveExpirationTime || - currentTime > lowestPendingInteractiveExpirationTime) && - (lowestPendingInteractiveExpirationTime = currentTime); + (0 === lowestPriorityPendingInteractiveExpirationTime || + currentTime > lowestPriorityPendingInteractiveExpirationTime) && + (lowestPriorityPendingInteractiveExpirationTime = currentTime); return currentTime; } +function storeInteractionsForExpirationTime( + root, + expirationTime, + updateInteractionCounts +) { + var interactions = tracking.__interactionsRef.current; + if (0 < interactions.size) { + var pendingInteractions = root.pendingInteractionMap.get(expirationTime); + null != pendingInteractions + ? interactions.forEach(function(interaction) { + updateInteractionCounts && + !pendingInteractions.has(interaction) && + interaction.__count++; + pendingInteractions.add(interaction); + }) + : (root.pendingInteractionMap.set(expirationTime, new Set(interactions)), + updateInteractionCounts && + interactions.forEach(function(interaction) { + interaction.__count++; + })); + var subscriber = tracking.__subscriberRef.current; + if (null !== subscriber) + subscriber.onWorkScheduled( + interactions, + 1e3 * expirationTime + root.interactionThreadID + ); + } +} function scheduleWork(fiber, expirationTime) { a: { if (0 === fiber.expirationTime || fiber.expirationTime > expirationTime) @@ -5101,7 +5632,7 @@ function scheduleWork(fiber, expirationTime) { alternate.expirationTime > expirationTime) && (alternate.expirationTime = expirationTime); var node = fiber.return; - if (null === node && 3 === fiber.tag) fiber = fiber.stateNode; + if (null === node && 5 === fiber.tag) fiber = fiber.stateNode; else { for (; null !== node; ) { alternate = node.alternate; @@ -5114,7 +5645,7 @@ function scheduleWork(fiber, expirationTime) { (0 === alternate.childExpirationTime || alternate.childExpirationTime > expirationTime) && (alternate.childExpirationTime = expirationTime); - if (null === node.return && 3 === node.tag) { + if (null === node.return && 5 === node.tag) { fiber = node.stateNode; break a; } @@ -5123,28 +5654,44 @@ function scheduleWork(fiber, expirationTime) { fiber = null; } } - null !== fiber && - (!isWorking && + if (null !== fiber) { + storeInteractionsForExpirationTime(fiber, expirationTime, !0); + !isWorking && 0 !== nextRenderExpirationTime && expirationTime < nextRenderExpirationTime && - resetStack(), - markPendingPriorityLevel(fiber, expirationTime), - (isWorking && !isCommitting$1 && nextRoot === fiber) || - requestWork(fiber, fiber.expirationTime), + resetStack(); + markPendingPriorityLevel(fiber, expirationTime); + if (!isWorking || isCommitting$1 || nextRoot !== fiber) { + expirationTime = fiber; + fiber = fiber.expirationTime; + if (null === expirationTime.nextScheduledRoot) + (expirationTime.expirationTime = fiber), + null === lastScheduledRoot + ? ((firstScheduledRoot = lastScheduledRoot = expirationTime), + (expirationTime.nextScheduledRoot = expirationTime)) + : ((lastScheduledRoot = lastScheduledRoot.nextScheduledRoot = expirationTime), + (lastScheduledRoot.nextScheduledRoot = firstScheduledRoot)); + else if ( + ((alternate = expirationTime.expirationTime), + 0 === alternate || fiber < alternate) + ) + expirationTime.expirationTime = fiber; + isRendering || + (isBatchingUpdates + ? isUnbatchingUpdates && + ((nextFlushedRoot = expirationTime), + (nextFlushedExpirationTime = 1), + performWorkOnRoot(expirationTime, 1, !0)) + : 1 === fiber + ? performWork(1, null) + : scheduleCallbackWithExpirationTime(expirationTime, fiber)); + } nestedUpdateCount > NESTED_UPDATE_LIMIT && ((nestedUpdateCount = 0), invariant( !1, "Maximum update depth exceeded. This can happen when a component repeatedly calls setState inside componentWillUpdate or componentDidUpdate. React limits the number of nested updates to prevent infinite loops." - ))); -} -function syncUpdates(fn, a, b, c, d) { - var previousExpirationContext = expirationContext; - expirationContext = 1; - try { - return fn(a, b, c, d); - } finally { - expirationContext = previousExpirationContext; + )); } } var firstScheduledRoot = null, @@ -5154,7 +5701,7 @@ var firstScheduledRoot = null, isRendering = !1, nextFlushedRoot = null, nextFlushedExpirationTime = 0, - lowestPendingInteractiveExpirationTime = 0, + lowestPriorityPendingInteractiveExpirationTime = 0, deadlineDidExpire = !1, hasUnhandledError = !1, unhandledError = null, @@ -5173,20 +5720,40 @@ var firstScheduledRoot = null, function recomputeCurrentRendererTime() { currentRendererTime = (((now$1() - originalStartTimeMs) / 10) | 0) + 2; } -function scheduleCallbackWithExpirationTime(expirationTime) { +function scheduleCallbackWithExpirationTime(root, expirationTime) { if (0 !== callbackExpirationTime) { if (expirationTime > callbackExpirationTime) return; - if (null !== callbackID) { - var callbackID$jscomp$0 = callbackID; - scheduledCallback = null; - clearTimeout(callbackID$jscomp$0); - } + null !== callbackID && + ((root = callbackID), (scheduledCallback = null), clearTimeout(root)); } callbackExpirationTime = expirationTime; now$1(); scheduledCallback = performAsyncWork; callbackID = setTimeout(setTimeoutCallback, 1); } +function onComplete(root, finishedWork, expirationTime) { + root.pendingCommitExpirationTime = expirationTime; + root.finishedWork = finishedWork; +} +function onSuspend( + root, + finishedWork, + suspendedExpirationTime, + rootExpirationTime, + msUntilTimeout +) { + root.expirationTime = rootExpirationTime; + 0 < msUntilTimeout && + (root.timeoutHandle = scheduleTimeout( + onTimeout.bind(null, root, finishedWork, suspendedExpirationTime), + msUntilTimeout + )); +} +function onTimeout() {} +function onCommit(root, expirationTime) { + root.expirationTime = expirationTime; + root.finishedWork = null; +} function requestCurrentTime() { if (isRendering) return currentSchedulerTime; findHighestPriorityRoot(); @@ -5198,32 +5765,6 @@ function requestCurrentTime() { (currentSchedulerTime = currentRendererTime); return currentSchedulerTime; } -function requestWork(root, expirationTime) { - if (null === root.nextScheduledRoot) - (root.expirationTime = expirationTime), - null === lastScheduledRoot - ? ((firstScheduledRoot = lastScheduledRoot = root), - (root.nextScheduledRoot = root)) - : ((lastScheduledRoot = lastScheduledRoot.nextScheduledRoot = root), - (lastScheduledRoot.nextScheduledRoot = firstScheduledRoot)); - else { - var remainingExpirationTime = root.expirationTime; - if ( - 0 === remainingExpirationTime || - expirationTime < remainingExpirationTime - ) - root.expirationTime = expirationTime; - } - isRendering || - (isBatchingUpdates - ? isUnbatchingUpdates && - ((nextFlushedRoot = root), - (nextFlushedExpirationTime = 1), - performWorkOnRoot(root, 1, !0)) - : 1 === expirationTime - ? performWork(1, null) - : scheduleCallbackWithExpirationTime(expirationTime)); -} function findHighestPriorityRoot() { var highestPriorityWork = 0, highestPriorityRoot = null; @@ -5264,6 +5805,7 @@ function findHighestPriorityRoot() { (highestPriorityWork = remainingExpirationTime), (highestPriorityRoot = root); if (root === lastScheduledRoot) break; + if (1 === highestPriorityWork) break; previousScheduledRoot = root; root = root.nextScheduledRoot; } @@ -5272,12 +5814,22 @@ function findHighestPriorityRoot() { nextFlushedExpirationTime = highestPriorityWork; } function performAsyncWork(dl) { + if (dl.didTimeout && null !== firstScheduledRoot) { + recomputeCurrentRendererTime(); + var root = firstScheduledRoot; + do { + var expirationTime = root.expirationTime; + 0 !== expirationTime && + currentRendererTime >= expirationTime && + (root.nextExpirationTimeToWorkOn = currentRendererTime); + root = root.nextScheduledRoot; + } while (root !== firstScheduledRoot); + } performWork(0, dl); } function performWork(minExpirationTime, dl) { deadline = dl; findHighestPriorityRoot(); - resumeActualRenderTimerIfPaused(1 === minExpirationTime); if (null !== deadline) for ( recomputeCurrentRendererTime(), @@ -5310,7 +5862,10 @@ function performWork(minExpirationTime, dl) { findHighestPriorityRoot(); null !== deadline && ((callbackExpirationTime = 0), (callbackID = null)); 0 !== nextFlushedExpirationTime && - scheduleCallbackWithExpirationTime(nextFlushedExpirationTime); + scheduleCallbackWithExpirationTime( + nextFlushedRoot, + nextFlushedExpirationTime + ); deadline = null; deadlineDidExpire = !1; nestedUpdateCount = 0; @@ -5359,12 +5914,11 @@ function performWorkOnRoot(root, expirationTime, isExpired) { (finishedWork = root.finishedWork), null !== finishedWork && (shouldYield() - ? ((root.finishedWork = finishedWork), - pauseActualRenderTimerIfRunning()) + ? (root.finishedWork = finishedWork) : completeRoot(root, finishedWork, expirationTime))); isRendering = !1; } -function completeRoot(root, finishedWork$jscomp$0, expirationTime) { +function completeRoot(root, finishedWork, expirationTime) { var firstBatch = root.firstBatch; if ( null !== firstBatch && @@ -5374,7 +5928,7 @@ function completeRoot(root, finishedWork$jscomp$0, expirationTime) { : completedBatches.push(firstBatch), firstBatch._defer) ) { - root.finishedWork = finishedWork$jscomp$0; + root.finishedWork = finishedWork; root.expirationTime = 0; return; } @@ -5382,281 +5936,7 @@ function completeRoot(root, finishedWork$jscomp$0, expirationTime) { root === lastCommittedRootDuringThisBatch ? nestedUpdateCount++ : ((lastCommittedRootDuringThisBatch = root), (nestedUpdateCount = 0)); - isCommitting$1 = isWorking = !0; - invariant( - root.current !== finishedWork$jscomp$0, - "Cannot commit the same tree as before. This is probably a bug related to the return field. This error is likely caused by a bug in React. Please file an issue." - ); - expirationTime = root.pendingCommitExpirationTime; - invariant( - 0 !== expirationTime, - "Cannot commit an incomplete root. This error is likely caused by a bug in React. Please file an issue." - ); - root.pendingCommitExpirationTime = 0; - firstBatch = finishedWork$jscomp$0.expirationTime; - var childExpirationTimeBeforeCommit = - finishedWork$jscomp$0.childExpirationTime; - firstBatch = - 0 === firstBatch || - (0 !== childExpirationTimeBeforeCommit && - childExpirationTimeBeforeCommit < firstBatch) - ? childExpirationTimeBeforeCommit - : firstBatch; - root.didError = !1; - 0 === firstBatch - ? ((root.earliestPendingTime = 0), - (root.latestPendingTime = 0), - (root.earliestSuspendedTime = 0), - (root.latestSuspendedTime = 0), - (root.latestPingedTime = 0)) - : ((childExpirationTimeBeforeCommit = root.latestPendingTime), - 0 !== childExpirationTimeBeforeCommit && - (childExpirationTimeBeforeCommit < firstBatch - ? (root.earliestPendingTime = root.latestPendingTime = 0) - : root.earliestPendingTime < firstBatch && - (root.earliestPendingTime = root.latestPendingTime)), - (childExpirationTimeBeforeCommit = root.earliestSuspendedTime), - 0 === childExpirationTimeBeforeCommit - ? markPendingPriorityLevel(root, firstBatch) - : firstBatch > root.latestSuspendedTime - ? ((root.earliestSuspendedTime = 0), - (root.latestSuspendedTime = 0), - (root.latestPingedTime = 0), - markPendingPriorityLevel(root, firstBatch)) - : firstBatch < childExpirationTimeBeforeCommit && - markPendingPriorityLevel(root, firstBatch)); - findNextExpirationTimeToWorkOn(0, root); - ReactCurrentOwner$2.current = null; - 1 < finishedWork$jscomp$0.effectTag - ? null !== finishedWork$jscomp$0.lastEffect - ? ((finishedWork$jscomp$0.lastEffect.nextEffect = finishedWork$jscomp$0), - (firstBatch = finishedWork$jscomp$0.firstEffect)) - : (firstBatch = finishedWork$jscomp$0) - : (firstBatch = finishedWork$jscomp$0.firstEffect); - for (nextEffect = firstBatch; null !== nextEffect; ) { - childExpirationTimeBeforeCommit = !1; - var error = void 0; - try { - for (; null !== nextEffect; ) { - if (nextEffect.effectTag & 256) { - var current$$1 = nextEffect.alternate, - finishedWork = nextEffect; - switch (finishedWork.tag) { - case 2: - if (finishedWork.effectTag & 256 && null !== current$$1) { - var prevProps = current$$1.memoizedProps, - prevState = current$$1.memoizedState, - instance = finishedWork.stateNode; - instance.props = finishedWork.memoizedProps; - instance.state = finishedWork.memoizedState; - var snapshot = instance.getSnapshotBeforeUpdate( - prevProps, - prevState - ); - instance.__reactInternalSnapshotBeforeUpdate = snapshot; - } - break; - case 3: - case 5: - case 6: - case 4: - break; - default: - invariant( - !1, - "This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue." - ); - } - } - nextEffect = nextEffect.nextEffect; - } - } catch (e) { - (childExpirationTimeBeforeCommit = !0), (error = e); - } - childExpirationTimeBeforeCommit && - (invariant( - null !== nextEffect, - "Should have next effect. This error is likely caused by a bug in React. Please file an issue." - ), - captureCommitPhaseError(nextEffect, error), - null !== nextEffect && (nextEffect = nextEffect.nextEffect)); - } - commitTime = now$1(); - for (nextEffect = firstBatch; null !== nextEffect; ) { - current$$1 = !1; - prevProps = void 0; - try { - for (; null !== nextEffect; ) { - var effectTag = nextEffect.effectTag; - if (effectTag & 128) { - var current$$1$jscomp$0 = nextEffect.alternate; - if (null !== current$$1$jscomp$0) { - var currentRef = current$$1$jscomp$0.ref; - null !== currentRef && - ("function" === typeof currentRef - ? currentRef(null) - : (currentRef.current = null)); - } - } - switch (effectTag & 14) { - case 2: - commitPlacement(nextEffect); - nextEffect.effectTag &= -3; - break; - case 6: - commitPlacement(nextEffect); - nextEffect.effectTag &= -3; - commitWork(nextEffect.alternate, nextEffect); - break; - case 4: - commitWork(nextEffect.alternate, nextEffect); - break; - case 8: - (prevState = nextEffect), - unmountHostComponents(prevState), - (prevState.return = null), - (prevState.child = null), - prevState.alternate && - ((prevState.alternate.child = null), - (prevState.alternate.return = null)); - } - nextEffect = nextEffect.nextEffect; - } - } catch (e) { - (current$$1 = !0), (prevProps = e); - } - current$$1 && - (invariant( - null !== nextEffect, - "Should have next effect. This error is likely caused by a bug in React. Please file an issue." - ), - captureCommitPhaseError(nextEffect, prevProps), - null !== nextEffect && (nextEffect = nextEffect.nextEffect)); - } - root.current = finishedWork$jscomp$0; - for (nextEffect = firstBatch; null !== nextEffect; ) { - effectTag = !1; - current$$1$jscomp$0 = void 0; - try { - for (currentRef = expirationTime; null !== nextEffect; ) { - var effectTag$jscomp$0 = nextEffect.effectTag; - if (effectTag$jscomp$0 & 36) { - var current$$1$jscomp$1 = nextEffect.alternate; - current$$1 = nextEffect; - prevProps = currentRef; - switch (current$$1.tag) { - case 2: - var instance$jscomp$0 = current$$1.stateNode; - if (current$$1.effectTag & 4) - if (null === current$$1$jscomp$1) - (instance$jscomp$0.props = current$$1.memoizedProps), - (instance$jscomp$0.state = current$$1.memoizedState), - instance$jscomp$0.componentDidMount(); - else { - var prevProps$jscomp$0 = current$$1$jscomp$1.memoizedProps, - prevState$jscomp$0 = current$$1$jscomp$1.memoizedState; - instance$jscomp$0.props = current$$1.memoizedProps; - instance$jscomp$0.state = current$$1.memoizedState; - instance$jscomp$0.componentDidUpdate( - prevProps$jscomp$0, - prevState$jscomp$0, - instance$jscomp$0.__reactInternalSnapshotBeforeUpdate - ); - } - var updateQueue = current$$1.updateQueue; - null !== updateQueue && - ((instance$jscomp$0.props = current$$1.memoizedProps), - (instance$jscomp$0.state = current$$1.memoizedState), - commitUpdateQueue( - current$$1, - updateQueue, - instance$jscomp$0, - prevProps - )); - break; - case 3: - var _updateQueue = current$$1.updateQueue; - if (null !== _updateQueue) { - prevState = null; - if (null !== current$$1.child) - switch (current$$1.child.tag) { - case 5: - prevState = current$$1.child.stateNode; - break; - case 2: - prevState = current$$1.child.stateNode; - } - commitUpdateQueue( - current$$1, - _updateQueue, - prevState, - prevProps - ); - } - break; - case 5: - break; - case 6: - break; - case 4: - break; - case 15: - break; - case 16: - break; - default: - invariant( - !1, - "This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue." - ); - } - } - if (effectTag$jscomp$0 & 128) { - current$$1 = void 0; - var ref = nextEffect.ref; - if (null !== ref) { - var instance$jscomp$1 = nextEffect.stateNode; - switch (nextEffect.tag) { - case 5: - current$$1 = instance$jscomp$1; - break; - default: - current$$1 = instance$jscomp$1; - } - "function" === typeof ref - ? ref(current$$1) - : (ref.current = current$$1); - } - } - var next = nextEffect.nextEffect; - nextEffect.nextEffect = null; - nextEffect = next; - } - } catch (e) { - (effectTag = !0), (current$$1$jscomp$0 = e); - } - effectTag && - (invariant( - null !== nextEffect, - "Should have next effect. This error is likely caused by a bug in React. Please file an issue." - ), - captureCommitPhaseError(nextEffect, current$$1$jscomp$0), - null !== nextEffect && (nextEffect = nextEffect.nextEffect)); - } - isWorking = isCommitting$1 = !1; - "function" === typeof onCommitFiberRoot && - onCommitFiberRoot(finishedWork$jscomp$0.stateNode); - effectTag$jscomp$0 = finishedWork$jscomp$0.expirationTime; - finishedWork$jscomp$0 = finishedWork$jscomp$0.childExpirationTime; - finishedWork$jscomp$0 = - 0 === effectTag$jscomp$0 || - (0 !== finishedWork$jscomp$0 && finishedWork$jscomp$0 < effectTag$jscomp$0) - ? finishedWork$jscomp$0 - : effectTag$jscomp$0; - 0 === finishedWork$jscomp$0 && - (legacyErrorBoundariesThatAlreadyFailed = null); - root.expirationTime = finishedWork$jscomp$0; - root.finishedWork = null; + commitRoot(root, finishedWork); } function shouldYield() { return deadlineDidExpire @@ -5673,51 +5953,54 @@ function onUncaughtError(error) { nextFlushedRoot.expirationTime = 0; hasUnhandledError || ((hasUnhandledError = !0), (unhandledError = error)); } -function updateContainerAtExpirationTime( - element, - container, - parentComponent, - expirationTime, - callback -) { - var current$$1 = container.current; - if (parentComponent) { - parentComponent = parentComponent._reactInternalFiber; - var parentContext; - b: { - invariant( - 2 === isFiberMountedImpl(parentComponent) && 2 === parentComponent.tag, - "Expected subtree parent to be a mounted class component. This error is likely caused by a bug in React. Please file an issue." - ); - for (parentContext = parentComponent; 3 !== parentContext.tag; ) { - if (isContextProvider(parentContext)) { - parentContext = - parentContext.stateNode.__reactInternalMemoizedMergedChildContext; - break b; - } - parentContext = parentContext.return; - invariant( - parentContext, - "Found unexpected detached subtree parent. This error is likely caused by a bug in React. Please file an issue." - ); +function getContextForSubtree(parentComponent) { + if (!parentComponent) return emptyContextObject; + parentComponent = parentComponent._reactInternalFiber; + a: { + invariant( + 2 === isFiberMountedImpl(parentComponent) && + (2 === parentComponent.tag || 3 === parentComponent.tag), + "Expected subtree parent to be a mounted class component. This error is likely caused by a bug in React. Please file an issue." + ); + var parentContext = parentComponent; + do { + switch (parentContext.tag) { + case 5: + parentContext = parentContext.stateNode.context; + break a; + case 2: + if (isContextProvider(parentContext.type)) { + parentContext = + parentContext.stateNode.__reactInternalMemoizedMergedChildContext; + break a; + } + break; + case 3: + if (isContextProvider(parentContext.type._reactResult)) { + parentContext = + parentContext.stateNode.__reactInternalMemoizedMergedChildContext; + break a; + } } - parentContext = parentContext.stateNode.context; - } - parentComponent = isContextProvider(parentComponent) - ? processChildContext(parentComponent, parentContext) - : parentContext; - } else parentComponent = emptyContextObject; - null === container.context - ? (container.context = parentComponent) - : (container.pendingContext = parentComponent); - container = callback; - callback = createUpdate(expirationTime); - callback.payload = { element: element }; - container = void 0 === container ? null : container; - null !== container && (callback.callback = container); - enqueueUpdate(current$$1, callback); - scheduleWork(current$$1, expirationTime); - return expirationTime; + parentContext = parentContext.return; + } while (null !== parentContext); + invariant( + !1, + "Found unexpected detached subtree parent. This error is likely caused by a bug in React. Please file an issue." + ); + parentContext = void 0; + } + if (2 === parentComponent.tag) { + var Component = parentComponent.type; + if (isContextProvider(Component)) + return processChildContext(parentComponent, Component, parentContext); + } else if ( + 3 === parentComponent.tag && + ((Component = parentComponent.type._reactResult), + isContextProvider(Component)) + ) + return processChildContext(parentComponent, Component, parentContext); + return parentContext; } function findHostInstance$1(component) { var fiber = component._reactInternalFiber; @@ -5736,154 +6019,20 @@ function updateContainer(element, container, parentComponent, callback) { var current$$1 = container.current, currentTime = requestCurrentTime(); current$$1 = computeExpirationForFiber(currentTime, current$$1); - return updateContainerAtExpirationTime( - element, - container, - parentComponent, - current$$1, - callback - ); + currentTime = container.current; + parentComponent = getContextForSubtree(parentComponent); + null === container.context + ? (container.context = parentComponent) + : (container.pendingContext = parentComponent); + container = callback; + callback = createUpdate(current$$1); + callback.payload = { element: element }; + container = void 0 === container ? null : container; + null !== container && (callback.callback = container); + enqueueUpdate(currentTime, callback); + scheduleWork(currentTime, current$$1); + return current$$1; } -function getPublicRootInstance(container) { - container = container.current; - if (!container.child) return null; - switch (container.child.tag) { - case 5: - return container.child.stateNode; - default: - return container.child.stateNode; - } -} -function injectIntoDevTools(devToolsConfig) { - var findFiberByHostInstance = devToolsConfig.findFiberByHostInstance; - return injectInternals( - Object.assign({}, devToolsConfig, { - findHostInstanceByFiber: function(fiber) { - fiber = findCurrentHostFiber(fiber); - return null === fiber ? null : fiber.stateNode; - }, - findFiberByHostInstance: function(instance) { - return findFiberByHostInstance - ? findFiberByHostInstance(instance) - : null; - } - }) - ); -} -var ReactNativeFiberRenderer = { - updateContainerAtExpirationTime: updateContainerAtExpirationTime, - createContainer: function(containerInfo, isAsync, hydrate) { - return createFiberRoot(containerInfo, isAsync, hydrate); - }, - updateContainer: updateContainer, - flushRoot: function(root, expirationTime) { - invariant( - !isRendering, - "work.commit(): Cannot commit while already rendering. This likely means you attempted to commit from inside a lifecycle method." - ); - nextFlushedRoot = root; - nextFlushedExpirationTime = expirationTime; - performWorkOnRoot(root, expirationTime, !0); - performWork(1, null); - pauseActualRenderTimerIfRunning(); - }, - requestWork: requestWork, - computeUniqueAsyncExpiration: function() { - var result = 2 + 25 * ((((requestCurrentTime() - 2 + 500) / 25) | 0) + 1); - result <= lastUniqueAsyncExpiration && - (result = lastUniqueAsyncExpiration + 1); - return (lastUniqueAsyncExpiration = result); - }, - batchedUpdates: function(fn, a) { - var previousIsBatchingUpdates = isBatchingUpdates; - isBatchingUpdates = !0; - try { - return fn(a); - } finally { - (isBatchingUpdates = previousIsBatchingUpdates) || - isRendering || - performWork(1, null); - } - }, - unbatchedUpdates: function(fn, a) { - if (isBatchingUpdates && !isUnbatchingUpdates) { - isUnbatchingUpdates = !0; - try { - return fn(a); - } finally { - isUnbatchingUpdates = !1; - } - } - return fn(a); - }, - deferredUpdates: function(fn) { - var currentTime = requestCurrentTime(), - previousExpirationContext = expirationContext; - expirationContext = 2 + 25 * ((((currentTime - 2 + 500) / 25) | 0) + 1); - try { - return fn(); - } finally { - expirationContext = previousExpirationContext; - } - }, - syncUpdates: syncUpdates, - interactiveUpdates: function(fn, a, b) { - if (isBatchingInteractiveUpdates) return fn(a, b); - isBatchingUpdates || - isRendering || - 0 === lowestPendingInteractiveExpirationTime || - (performWork(lowestPendingInteractiveExpirationTime, null), - (lowestPendingInteractiveExpirationTime = 0)); - var previousIsBatchingInteractiveUpdates = isBatchingInteractiveUpdates, - previousIsBatchingUpdates = isBatchingUpdates; - isBatchingUpdates = isBatchingInteractiveUpdates = !0; - try { - return fn(a, b); - } finally { - (isBatchingInteractiveUpdates = previousIsBatchingInteractiveUpdates), - (isBatchingUpdates = previousIsBatchingUpdates) || - isRendering || - performWork(1, null); - } - }, - flushInteractiveUpdates: function() { - isRendering || - 0 === lowestPendingInteractiveExpirationTime || - (performWork(lowestPendingInteractiveExpirationTime, null), - (lowestPendingInteractiveExpirationTime = 0)); - }, - flushControlled: function(fn) { - var previousIsBatchingUpdates = isBatchingUpdates; - isBatchingUpdates = !0; - try { - syncUpdates(fn); - } finally { - (isBatchingUpdates = previousIsBatchingUpdates) || - isRendering || - performWork(1, null); - } - }, - flushSync: function(fn, a) { - invariant( - !isRendering, - "flushSync was called from inside a lifecycle method. It cannot be called when React is already rendering." - ); - var previousIsBatchingUpdates = isBatchingUpdates; - isBatchingUpdates = !0; - try { - return syncUpdates(fn, a); - } finally { - (isBatchingUpdates = previousIsBatchingUpdates), performWork(1, null); - } - }, - getPublicRootInstance: getPublicRootInstance, - findHostInstance: findHostInstance$1, - findHostInstanceWithNoPortals: function(fiber) { - fiber = findCurrentHostFiberWithNoPortals(fiber); - return null === fiber ? null : fiber.stateNode; - }, - injectIntoDevTools: injectIntoDevTools -}; function createPortal(children, containerInfo, implementation) { var key = 3 < arguments.length && void 0 !== arguments[3] ? arguments[3] : null; @@ -5931,8 +6080,23 @@ function findNodeHandle(componentOrHandle) { ? componentOrHandle.canonical._nativeTag : componentOrHandle._nativeTag; } -_batchedUpdates = ReactNativeFiberRenderer.batchedUpdates; -_flushInteractiveUpdates = ReactNativeFiberRenderer.flushInteractiveUpdates; +_batchedUpdatesImpl = function(fn, a) { + var previousIsBatchingUpdates = isBatchingUpdates; + isBatchingUpdates = !0; + try { + return fn(a); + } finally { + (isBatchingUpdates = previousIsBatchingUpdates) || + isRendering || + performWork(1, null); + } +}; +_flushInteractiveUpdatesImpl = function() { + isRendering || + 0 === lowestPriorityPendingInteractiveExpirationTime || + (performWork(lowestPriorityPendingInteractiveExpirationTime, null), + (lowestPriorityPendingInteractiveExpirationTime = 0)); +}; var roots = new Map(), ReactNativeRenderer = { NativeComponent: (function(findNodeHandle, findHostInstance) { @@ -5960,13 +6124,13 @@ var roots = new Map(), ReactNativeComponent.prototype.measure = function(callback) { UIManager.measure( findNodeHandle(this), - mountSafeCallback(this, callback) + mountSafeCallback_NOT_REALLY_SAFE(this, callback) ); }; ReactNativeComponent.prototype.measureInWindow = function(callback) { UIManager.measureInWindow( findNodeHandle(this), - mountSafeCallback(this, callback) + mountSafeCallback_NOT_REALLY_SAFE(this, callback) ); }; ReactNativeComponent.prototype.measureLayout = function( @@ -5977,8 +6141,8 @@ var roots = new Map(), UIManager.measureLayout( findNodeHandle(this), relativeToNativeNode, - mountSafeCallback(this, onFail), - mountSafeCallback(this, onSuccess) + mountSafeCallback_NOT_REALLY_SAFE(this, onFail), + mountSafeCallback_NOT_REALLY_SAFE(this, onSuccess) ); }; ReactNativeComponent.prototype.setNativeProps = function(nativeProps) { @@ -6009,11 +6173,48 @@ var roots = new Map(), findNodeHandle: findNodeHandle, render: function(element, containerTag, callback) { var root = roots.get(containerTag); - root || - ((root = createFiberRoot(containerTag, !1, !1)), - roots.set(containerTag, root)); + if (!root) { + root = 0; + isDevToolsPresent && (root |= 4); + root = new FiberNode(5, null, null, root); + var root$jscomp$0 = { + current: root, + containerInfo: containerTag, + pendingChildren: null, + earliestPendingTime: 0, + latestPendingTime: 0, + earliestSuspendedTime: 0, + latestSuspendedTime: 0, + latestPingedTime: 0, + didError: !1, + pendingCommitExpirationTime: 0, + finishedWork: null, + timeoutHandle: -1, + context: null, + pendingContext: null, + hydrate: !1, + nextExpirationTimeToWorkOn: 0, + expirationTime: 0, + firstBatch: null, + nextScheduledRoot: null, + interactionThreadID: tracking.unstable_getThreadID(), + memoizedInteractions: new Set(), + pendingInteractionMap: new Map() + }; + root = root.stateNode = root$jscomp$0; + roots.set(containerTag, root); + } updateContainer(element, root, null, callback); - return getPublicRootInstance(root); + a: if (((element = root.current), element.child)) + switch (element.child.tag) { + case 7: + element = element.child.stateNode; + break a; + default: + element = element.child.stateNode; + } + else element = null; + return element; }, unmountComponentAtNode: function(containerTag) { var root = roots.get(containerTag); @@ -6041,21 +6242,21 @@ var roots = new Map(), measure: function(callback) { UIManager.measure( findNodeHandle(this), - mountSafeCallback(this, callback) + mountSafeCallback_NOT_REALLY_SAFE(this, callback) ); }, measureInWindow: function(callback) { UIManager.measureInWindow( findNodeHandle(this), - mountSafeCallback(this, callback) + mountSafeCallback_NOT_REALLY_SAFE(this, callback) ); }, measureLayout: function(relativeToNativeNode, onSuccess, onFail) { UIManager.measureLayout( findNodeHandle(this), relativeToNativeNode, - mountSafeCallback(this, onFail), - mountSafeCallback(this, onSuccess) + mountSafeCallback_NOT_REALLY_SAFE(this, onFail), + mountSafeCallback_NOT_REALLY_SAFE(this, onSuccess) ); }, setNativeProps: function(nativeProps) { @@ -6094,16 +6295,29 @@ var roots = new Map(), } } }; -injectIntoDevTools({ +(function(devToolsConfig) { + var findFiberByHostInstance = devToolsConfig.findFiberByHostInstance; + return injectInternals( + Object.assign({}, devToolsConfig, { + findHostInstanceByFiber: function(fiber) { + fiber = findCurrentHostFiber(fiber); + return null === fiber ? null : fiber.stateNode; + }, + findFiberByHostInstance: function(instance) { + return findFiberByHostInstance + ? findFiberByHostInstance(instance) + : null; + } + }) + ); +})({ findFiberByHostInstance: getInstanceFromTag, getInspectorDataForViewTag: getInspectorDataForViewTag, bundleType: 0, - version: "16.4.1", + version: "16.5.0", rendererPackageName: "react-native-renderer" }); var ReactNativeRenderer$2 = { default: ReactNativeRenderer }, ReactNativeRenderer$3 = (ReactNativeRenderer$2 && ReactNativeRenderer) || ReactNativeRenderer$2; -module.exports = ReactNativeRenderer$3.default - ? ReactNativeRenderer$3.default - : ReactNativeRenderer$3; +module.exports = ReactNativeRenderer$3.default || ReactNativeRenderer$3; diff --git a/Libraries/Renderer/shims/NativeMethodsMixin.js b/Libraries/Renderer/shims/NativeMethodsMixin.js index 70e1d9dda..857e29810 100644 --- a/Libraries/Renderer/shims/NativeMethodsMixin.js +++ b/Libraries/Renderer/shims/NativeMethodsMixin.js @@ -1,5 +1,5 @@ /** - * Copyright (c) 2013-present, Facebook, Inc. + * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. diff --git a/Libraries/Renderer/shims/ReactFabric.js b/Libraries/Renderer/shims/ReactFabric.js index a5e317ba4..03691e23d 100644 --- a/Libraries/Renderer/shims/ReactFabric.js +++ b/Libraries/Renderer/shims/ReactFabric.js @@ -1,5 +1,5 @@ /** - * Copyright (c) 2015-present, Facebook, Inc. + * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. diff --git a/Libraries/Renderer/shims/ReactNative.js b/Libraries/Renderer/shims/ReactNative.js index fd7d3e3db..13a5985f9 100644 --- a/Libraries/Renderer/shims/ReactNative.js +++ b/Libraries/Renderer/shims/ReactNative.js @@ -1,5 +1,5 @@ /** - * Copyright (c) 2015-present, Facebook, Inc. + * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. diff --git a/Libraries/Renderer/shims/ReactNativeTypes.js b/Libraries/Renderer/shims/ReactNativeTypes.js index 1ee89e82d..8daf4fe7f 100644 --- a/Libraries/Renderer/shims/ReactNativeTypes.js +++ b/Libraries/Renderer/shims/ReactNativeTypes.js @@ -1,5 +1,5 @@ /** - * Copyright (c) 2015-present, Facebook, Inc. + * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. @@ -33,17 +33,6 @@ export type MeasureLayoutOnSuccessCallback = ( height: number, ) => void; -type BubblingEventType = { - phasedRegistrationNames: { - captured: string, - bubbled: string, - }, -}; - -type DirectEventType = { - registrationName: string, -}; - type AttributeType = | true | $ReadOnly<{| @@ -51,6 +40,16 @@ type AttributeType = process: ?(arg1: any) => any, |}>; +export type AttributeConfiguration< + TProps = string, + TStyleProps = string, +> = $ReadOnly<{ + [propName: TProps]: AttributeType, + style: $ReadOnly<{ + [propName: TStyleProps]: AttributeType, + }>, +}>; + export type ReactNativeBaseComponentViewConfig< TProps = string, TStyleProps = string, @@ -76,12 +75,7 @@ export type ReactNativeBaseComponentViewConfig< [propName: string]: string, }>, uiViewClassName: string, - validAttributes: $ReadOnly<{ - [propName: TProps]: AttributeType, - style: $ReadOnly<{ - [propName: TStyleProps]: AttributeType, - }>, - }>, + validAttributes: AttributeConfiguration, |}>; export type ViewConfigGetter = () => ReactNativeBaseComponentViewConfig<>; diff --git a/Libraries/Renderer/shims/ReactNativeViewConfigRegistry.js b/Libraries/Renderer/shims/ReactNativeViewConfigRegistry.js index cb16c50f5..0430c8e9f 100644 --- a/Libraries/Renderer/shims/ReactNativeViewConfigRegistry.js +++ b/Libraries/Renderer/shims/ReactNativeViewConfigRegistry.js @@ -1,5 +1,5 @@ /** - * Copyright (c) 2015-present, Facebook, Inc. + * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. @@ -90,11 +90,16 @@ exports.get = function(name: string): ReactNativeBaseComponentViewConfig<> { let viewConfig; if (!viewConfigs.has(name)) { const callback = viewConfigCallbacks.get(name); - invariant( - typeof callback === 'function', - 'View config not found for name %s', - name, - ); + if (typeof callback !== 'function') { + invariant( + false, + 'View config not found for name %s.%s', + name, + typeof name[0] === 'string' && /[a-z]/.test(name[0]) + ? ' Make sure to start component names with a capital letter.' + : '', + ); + } viewConfigCallbacks.set(name, null); viewConfig = callback(); processEventTypes(viewConfig); diff --git a/Libraries/Renderer/shims/ReactTypes.js b/Libraries/Renderer/shims/ReactTypes.js index bff9413c8..4beed2224 100644 --- a/Libraries/Renderer/shims/ReactTypes.js +++ b/Libraries/Renderer/shims/ReactTypes.js @@ -1,5 +1,5 @@ /** - * Copyright (c) 2014-present, Facebook, Inc. + * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. @@ -7,15 +7,17 @@ * @flow */ +/* eslint-disable no-use-before-define */ export type ReactNode = | React$Element - | ReactCall - | ReactReturn | ReactPortal | ReactText | ReactFragment | ReactProvider | ReactConsumer; +/* eslint-enable no-use-before-define */ + +export type ReactEmpty = null | void | boolean; export type ReactFragment = ReactEmpty | Iterable; @@ -23,31 +25,6 @@ export type ReactNodeList = ReactEmpty | React$Node; export type ReactText = string | number; -export type ReactEmpty = null | void | boolean; - -export type ReactCall = { - $$typeof: Symbol | number, - type: Symbol | number, - key: null | string, - ref: null, - props: { - props: any, - // This should be a more specific CallHandler - handler: (props: any, returns: Array) => ReactNodeList, - children?: ReactNodeList, - }, -}; - -export type ReactReturn = { - $$typeof: Symbol | number, - type: Symbol | number, - key: null, - ref: null, - props: { - value: V, - }, -}; - export type ReactProvider = { $$typeof: Symbol | number, type: ReactProviderType, @@ -82,12 +59,9 @@ export type ReactContext = { unstable_read: () => T, _calculateChangedBits: ((a: T, b: T) => number) | null, - _defaultValue: T, _currentValue: T, _currentValue2: T, - _changedBits: number, - _changedBits2: number, // DEV only _currentRenderer?: Object | null, diff --git a/Libraries/Renderer/shims/createReactNativeComponentClass.js b/Libraries/Renderer/shims/createReactNativeComponentClass.js index 33e708b7c..e9f5fc0f9 100644 --- a/Libraries/Renderer/shims/createReactNativeComponentClass.js +++ b/Libraries/Renderer/shims/createReactNativeComponentClass.js @@ -1,5 +1,5 @@ /** - * Copyright (c) 2013-present, Facebook, Inc. + * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. diff --git a/package.json b/package.json index 9767f7543..65405a664 100644 --- a/package.json +++ b/package.json @@ -145,7 +145,7 @@ "react-native": "local-cli/wrong-react-native.js" }, "peerDependencies": { - "react": "16.4.1" + "react": "16.5.0" }, "dependencies": { "absolute-path": "^0.0.0", @@ -220,8 +220,8 @@ "jest": "23.4.1", "jest-junit": "5.1.0", "prettier": "1.13.6", - "react": "16.4.1", - "react-test-renderer": "16.4.1", + "react": "16.5.0", + "react-test-renderer": "16.5.0", "shelljs": "^0.7.8", "sinon": "^2.2.0" },