diff --git a/Libraries/Renderer/REVISION b/Libraries/Renderer/REVISION index 21b691427..7274d4dc4 100644 --- a/Libraries/Renderer/REVISION +++ b/Libraries/Renderer/REVISION @@ -1 +1 @@ -4773fdf7cdf5d6d775ad0960f23ee1a830e7b82b \ No newline at end of file +c84b9bf828c38e0b24042ebb9cd859292146a6fb \ No newline at end of file diff --git a/Libraries/Renderer/oss/ReactFabric-dev.js b/Libraries/Renderer/oss/ReactFabric-dev.js index de566d72b..0d1049073 100644 --- a/Libraries/Renderer/oss/ReactFabric-dev.js +++ b/Libraries/Renderer/oss/ReactFabric-dev.js @@ -27,6 +27,7 @@ var TextInputState = require("TextInputState"); var FabricUIManager = require("FabricUIManager"); var checkPropTypes = require("prop-types/checkPropTypes"); var tracing = require("scheduler/tracing"); +var scheduler = require("scheduler"); var ExceptionsManager = require("ExceptionsManager"); /** @@ -1133,24 +1134,23 @@ function runExtractedEventsInBatch( } var FunctionComponent = 0; -var FunctionComponentLazy = 1; -var ClassComponent = 2; -var ClassComponentLazy = 3; -var IndeterminateComponent = 4; // Before we know whether it is function 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 SuspenseComponent = 16; -var PureComponent = 17; -var PureComponentLazy = 18; +var ClassComponent = 1; +var IndeterminateComponent = 2; // Before we know whether it is function or class +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 = 7; +var Mode = 8; +var ContextConsumer = 9; +var ContextProvider = 10; +var ForwardRef = 11; +var Profiler = 12; +var SuspenseComponent = 13; +var MemoComponent = 14; +var SimpleMemoComponent = 15; +var LazyComponent = 16; +var IncompleteClassComponent = 17; function getParent(inst) { do { @@ -2650,6 +2650,7 @@ var REACT_STRICT_MODE_TYPE = hasSymbol var REACT_PROFILER_TYPE = hasSymbol ? Symbol.for("react.profiler") : 0xead2; var REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for("react.provider") : 0xeacd; var REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for("react.context") : 0xeace; + var REACT_CONCURRENT_MODE_TYPE = hasSymbol ? Symbol.for("react.concurrent_mode") : 0xeacf; @@ -2657,7 +2658,8 @@ var REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for("react.forward_ref") : 0xead0; var REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for("react.suspense") : 0xead1; -var REACT_PURE_TYPE = hasSymbol ? Symbol.for("react.pure") : 0xead3; +var REACT_MEMO_TYPE = hasSymbol ? Symbol.for("react.memo") : 0xead3; +var REACT_LAZY_TYPE = hasSymbol ? Symbol.for("react.lazy") : 0xead4; var MAYBE_ITERATOR_SYMBOL = typeof Symbol === "function" && Symbol.iterator; var FAUX_ITERATOR_SYMBOL = "@@iterator"; @@ -2679,12 +2681,8 @@ 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 refineResolvedLazyComponent(lazyComponent) { + return lazyComponent._status === Resolved ? lazyComponent._result : null; } function getWrappedName(outerType, innerType, wrapperName) { @@ -2737,14 +2735,14 @@ function getComponentName(type) { return "Context.Provider"; case REACT_FORWARD_REF_TYPE: return getWrappedName(type, type.render, "ForwardRef"); - case REACT_PURE_TYPE: - return getWrappedName(type, type.render, "Pure"); - } - if (typeof type.then === "function") { - var thenable = type; - var resolvedThenable = refineResolvedThenable(thenable); - if (resolvedThenable) { - return getComponentName(resolvedThenable); + case REACT_MEMO_TYPE: + return getComponentName(type.type); + case REACT_LAZY_TYPE: { + var thenable = type; + var resolvedThenable = refineResolvedLazyComponent(thenable); + if (resolvedThenable) { + return getComponentName(resolvedThenable); + } } } } @@ -2765,15 +2763,16 @@ var Callback = /* */ 32; var DidCapture = /* */ 64; var Ref = /* */ 128; var Snapshot = /* */ 256; +var Passive = /* */ 512; -// Update & Callback & Ref & Snapshot -var LifecycleEffectMask = /* */ 420; +// Passive & Update & Callback & Ref & Snapshot +var LifecycleEffectMask = /* */ 932; // Union of all host effects -var HostEffectMask = /* */ 511; +var HostEffectMask = /* */ 1023; -var Incomplete = /* */ 512; -var ShouldCapture = /* */ 1024; +var Incomplete = /* */ 1024; +var ShouldCapture = /* */ 2048; var ReactCurrentOwner$1 = ReactSharedInternals.ReactCurrentOwner; @@ -2817,10 +2816,7 @@ function isFiberMounted(fiber) { function isMounted(component) { { var owner = ReactCurrentOwner$1.current; - if ( - owner !== null && - (owner.tag === ClassComponent || owner.tag === ClassComponentLazy) - ) { + if (owner !== null && owner.tag === ClassComponent) { var ownerFiber = owner; var instance = ownerFiber.stateNode; !instance._warnedAboutRefsInRender @@ -3530,13 +3526,6 @@ var now$1 = hasNativePerformanceNow var scheduledCallback = null; var frameDeadline = 0; -var frameDeadlineObject = { - timeRemaining: function() { - return frameDeadline - now$1(); - }, - didTimeout: false -}; - function setTimeoutCallback() { // TODO (bvaughn) Hard-coded 5ms unblocks initial async testing. // React API probably changing to boolean rather than time remaining. @@ -3547,7 +3536,7 @@ function setTimeoutCallback() { var callback = scheduledCallback; scheduledCallback = null; if (callback !== null) { - callback(frameDeadlineObject); + callback(); } } @@ -3566,6 +3555,10 @@ function cancelDeferredCallback$1(callbackID) { clearTimeout(callbackID); // Timeouts are always numbers on RN } +function shouldYield$1() { + return frameDeadline <= now$1(); +} + // Use to restore controlled state after a change event has fired. var restoreImpl = null; @@ -3696,6 +3689,10 @@ var insertInContainerBefore = shim; var removeChild = shim; var removeChildFromContainer = shim; var resetTextContent = shim; +var hideInstance = shim; +var hideTextInstance = shim; +var unhideInstance = shim; +var unhideTextInstance = shim; // Renderers that don't support hydration // can re-export everything from this module. @@ -3973,6 +3970,7 @@ var isPrimaryRenderer = false; var now = now$1; var scheduleDeferredCallback = scheduleDeferredCallback$1; var cancelDeferredCallback = cancelDeferredCallback$1; +var shouldYield = shouldYield$1; var scheduleTimeout = setTimeout; var cancelTimeout = clearTimeout; @@ -4018,6 +4016,23 @@ function cloneInstance( }; } +function cloneHiddenInstance(instance, type, props, internalInstanceHandle) { + throw new Error("Not yet implemented."); +} + +function cloneUnhiddenInstance(instance, type, props, internalInstanceHandle) { + throw new Error("Not yet implemented."); +} + +function createHiddenTextInstance( + text, + rootContainerInstance, + hostContext, + internalInstanceHandle +) { + throw new Error("Not yet implemented."); +} + function createContainerChildSet(container) { return FabricUIManager.createChildSet(container); } @@ -4063,12 +4078,12 @@ var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame; function describeFiber(fiber) { switch (fiber.tag) { case IndeterminateComponent: + case LazyComponent: case FunctionComponent: - case FunctionComponentLazy: case ClassComponent: - case ClassComponentLazy: case HostComponent: case Mode: + case SuspenseComponent: var owner = fiber._debugOwner; var source = fiber._debugSource; var name = getComponentName(fiber.type); @@ -4145,6 +4160,7 @@ function setCurrentPhase(lifeCyclePhase) { var debugRenderPhaseSideEffects = false; var debugRenderPhaseSideEffectsForStrictMode = false; var enableUserTimingAPI = true; + var warnAboutDeprecatedLifecycles = false; var replayFailedUnitOfWorkWithInvokeGuardedCallback = true; var enableProfilerTimer = true; @@ -4916,8 +4932,7 @@ function findCurrentUnmaskedContext(fiber) { // Currently this is only used with renderSubtreeIntoContainer; not sure if it // makes sense elsewhere invariant( - isFiberMounted(fiber) && - (fiber.tag === ClassComponent || fiber.tag === ClassComponentLazy), + isFiberMounted(fiber) && fiber.tag === ClassComponent, "Expected subtree parent to be a mounted class component. " + "This error is likely caused by a bug in React. Please file an issue." ); @@ -4934,13 +4949,6 @@ function findCurrentUnmaskedContext(fiber) { } break; } - case ClassComponentLazy: { - var _Component = getResultFromResolvedThenable(node.type); - if (isContextProvider(_Component)) { - return node.stateNode.__reactInternalMemoizedMergedChildContext; - } - break; - } } node = node.return; } while (node !== null); @@ -5039,20 +5047,20 @@ function onCommitUnmount(fiber) { var maxSigned31BitInt = 1073741823; var NoWork = 0; -var Sync = 1; -var Never = maxSigned31BitInt; +var Never = 1; +var Sync = maxSigned31BitInt; var UNIT_SIZE = 10; -var MAGIC_NUMBER_OFFSET = 2; +var MAGIC_NUMBER_OFFSET = maxSigned31BitInt - 1; // 1 unit of expiration time represents 10ms. function msToExpirationTime(ms) { // Always add an offset so that we don't clash with the magic number for NoWork. - return ((ms / UNIT_SIZE) | 0) + MAGIC_NUMBER_OFFSET; + return MAGIC_NUMBER_OFFSET - ((ms / UNIT_SIZE) | 0); } function expirationTimeToMs(expirationTime) { - return (expirationTime - MAGIC_NUMBER_OFFSET) * UNIT_SIZE; + return (MAGIC_NUMBER_OFFSET - expirationTime) * UNIT_SIZE; } function ceiling(num, precision) { @@ -5061,9 +5069,9 @@ function ceiling(num, precision) { function computeExpirationBucket(currentTime, expirationInMs, bucketSizeMs) { return ( - MAGIC_NUMBER_OFFSET + + MAGIC_NUMBER_OFFSET - ceiling( - currentTime - MAGIC_NUMBER_OFFSET + expirationInMs / UNIT_SIZE, + MAGIC_NUMBER_OFFSET - currentTime + expirationInMs / UNIT_SIZE, bucketSizeMs / UNIT_SIZE ) ); @@ -5139,6 +5147,7 @@ function FiberNode(tag, pendingProps, key, mode) { // Instance this.tag = tag; this.key = key; + this.elementType = null; this.type = null; this.stateNode = null; @@ -5211,18 +5220,24 @@ function shouldConstruct(Component) { return !!(prototype && prototype.isReactComponent); } -function resolveLazyComponentTag(fiber, Component) { +function isSimpleFunctionComponent(type) { + return ( + typeof type === "function" && + !shouldConstruct(type) && + type.defaultProps === undefined + ); +} + +function resolveLazyComponentTag(Component) { if (typeof Component === "function") { - return shouldConstruct(Component) - ? ClassComponentLazy - : FunctionComponentLazy; + return shouldConstruct(Component) ? ClassComponent : FunctionComponent; } else if (Component !== undefined && Component !== null) { var $$typeof = Component.$$typeof; if ($$typeof === REACT_FORWARD_REF_TYPE) { - return ForwardRefLazy; + return ForwardRef; } - if ($$typeof === REACT_PURE_TYPE) { - return PureComponentLazy; + if ($$typeof === REACT_MEMO_TYPE) { + return MemoComponent; } } return IndeterminateComponent; @@ -5243,6 +5258,7 @@ function createWorkInProgress(current, pendingProps, expirationTime) { current.key, current.mode ); + workInProgress.elementType = current.elementType; workInProgress.type = current.type; workInProgress.stateNode = current.stateNode; @@ -5312,20 +5328,23 @@ function createHostRootFiber(isConcurrent) { return createFiber(HostRoot, null, null, mode); } -function createFiberFromElement(element, mode, expirationTime) { - var owner = null; - { - owner = element._owner; - } - +function createFiberFromTypeAndProps( + type, // React$ElementType + key, + pendingProps, + owner, + mode, + expirationTime +) { var fiber = void 0; - var type = element.type; - var key = element.key; - var pendingProps = element.props; - var fiberTag = void 0; + var fiberTag = IndeterminateComponent; + // The resolved type is set if we know what the final type will be. I.e. it's not lazy. + var resolvedType = type; if (typeof type === "function") { - fiberTag = shouldConstruct(type) ? ClassComponent : IndeterminateComponent; + if (shouldConstruct(type)) { + fiberTag = ClassComponent; + } } else if (typeof type === "string") { fiberTag = HostComponent; } else { @@ -5338,18 +5357,23 @@ function createFiberFromElement(element, mode, expirationTime) { key ); case REACT_CONCURRENT_MODE_TYPE: - fiberTag = Mode; - mode |= ConcurrentMode | StrictMode; - break; + return createFiberFromMode( + pendingProps, + mode | ConcurrentMode | StrictMode, + expirationTime, + key + ); case REACT_STRICT_MODE_TYPE: - fiberTag = Mode; - mode |= StrictMode; - break; + return createFiberFromMode( + pendingProps, + mode | StrictMode, + expirationTime, + key + ); case REACT_PROFILER_TYPE: return createFiberFromProfiler(pendingProps, mode, expirationTime, key); case REACT_SUSPENSE_TYPE: - fiberTag = SuspenseComponent; - break; + return createFiberFromSuspense(pendingProps, mode, expirationTime, key); default: { if (typeof type === "object" && type !== null) { switch (type.$$typeof) { @@ -5363,15 +5387,13 @@ function createFiberFromElement(element, mode, expirationTime) { case REACT_FORWARD_REF_TYPE: fiberTag = ForwardRef; break getTag; - case REACT_PURE_TYPE: - fiberTag = PureComponent; + case REACT_MEMO_TYPE: + fiberTag = MemoComponent; + break getTag; + case REACT_LAZY_TYPE: + fiberTag = LazyComponent; + resolvedType = null; break getTag; - default: { - if (typeof type.then === "function") { - fiberTag = IndeterminateComponent; - break getTag; - } - } } } var info = ""; @@ -5405,14 +5427,33 @@ function createFiberFromElement(element, mode, expirationTime) { } fiber = createFiber(fiberTag, pendingProps, key, mode); - fiber.type = type; + fiber.elementType = type; + fiber.type = resolvedType; fiber.expirationTime = expirationTime; + return fiber; +} + +function createFiberFromElement(element, mode, expirationTime) { + var owner = null; + { + owner = element._owner; + } + var type = element.type; + var key = element.key; + var pendingProps = element.props; + var fiber = createFiberFromTypeAndProps( + type, + key, + pendingProps, + owner, + mode, + expirationTime + ); { fiber._debugSource = element._source; fiber._debugOwner = element._owner; } - return fiber; } @@ -5436,12 +5477,41 @@ function createFiberFromProfiler(pendingProps, mode, expirationTime, key) { } var fiber = createFiber(Profiler, pendingProps, key, mode | ProfileMode); + // TODO: The Profiler fiber shouldn't have a type. It has a tag. + fiber.elementType = REACT_PROFILER_TYPE; fiber.type = REACT_PROFILER_TYPE; fiber.expirationTime = expirationTime; return fiber; } +function createFiberFromMode(pendingProps, mode, expirationTime, key) { + var fiber = createFiber(Mode, pendingProps, key, mode); + + // TODO: The Mode fiber shouldn't have a type. It has a tag. + var type = + (mode & ConcurrentMode) === NoContext + ? REACT_STRICT_MODE_TYPE + : REACT_CONCURRENT_MODE_TYPE; + fiber.elementType = type; + fiber.type = type; + + fiber.expirationTime = expirationTime; + return fiber; +} + +function createFiberFromSuspense(pendingProps, mode, expirationTime, key) { + var fiber = createFiber(SuspenseComponent, pendingProps, key, mode); + + // TODO: The SuspenseComponent fiber shouldn't have a type. It has a tag. + var type = REACT_SUSPENSE_TYPE; + fiber.elementType = type; + fiber.type = type; + + fiber.expirationTime = expirationTime; + return fiber; +} + function createFiberFromText(content, mode, expirationTime) { var fiber = createFiber(HostText, content, null, mode); fiber.expirationTime = expirationTime; @@ -5450,6 +5520,8 @@ function createFiberFromText(content, mode, expirationTime) { function createFiberFromHostInstanceForDeletion() { var fiber = createFiber(HostComponent, null, null, NoContext); + // TODO: These should not need a type. + fiber.elementType = "DELETED"; fiber.type = "DELETED"; return fiber; } @@ -5482,6 +5554,7 @@ function assignFiberPropertiesInDEV(target, source) { target.tag = source.tag; target.key = source.key; + target.elementType = source.elementType; target.type = source.type; target.stateNode = source.stateNode; target.return = source.return; @@ -6024,12 +6097,12 @@ function markPendingPriorityLevel(root, expirationTime) { // No other pending updates. root.earliestPendingTime = root.latestPendingTime = expirationTime; } else { - if (earliestPendingTime > expirationTime) { + if (earliestPendingTime < expirationTime) { // This is the earliest pending update. root.earliestPendingTime = expirationTime; } else { var latestPendingTime = root.latestPendingTime; - if (latestPendingTime < expirationTime) { + if (latestPendingTime > expirationTime) { // This is the latest pending update root.latestPendingTime = expirationTime; } @@ -6055,12 +6128,12 @@ function markCommittedPriorityLevels(root, earliestRemainingTime) { // Let's see if the previous latest known pending level was just flushed. var latestPendingTime = root.latestPendingTime; if (latestPendingTime !== NoWork) { - if (latestPendingTime < earliestRemainingTime) { + if (latestPendingTime > earliestRemainingTime) { // We've flushed all the known pending levels. root.earliestPendingTime = root.latestPendingTime = NoWork; } else { var earliestPendingTime = root.earliestPendingTime; - if (earliestPendingTime < earliestRemainingTime) { + if (earliestPendingTime > earliestRemainingTime) { // We've flushed the earliest known pending level. Set this to the // latest pending time. root.earliestPendingTime = root.latestPendingTime; @@ -6082,7 +6155,7 @@ function markCommittedPriorityLevels(root, earliestRemainingTime) { } var latestSuspendedTime = root.latestSuspendedTime; - if (earliestRemainingTime > latestSuspendedTime) { + if (earliestRemainingTime < latestSuspendedTime) { // The earliest remaining level is later than all the suspended work. That // means we've flushed all the suspended work. root.earliestSuspendedTime = NoWork; @@ -6096,7 +6169,7 @@ function markCommittedPriorityLevels(root, earliestRemainingTime) { return; } - if (earliestRemainingTime < earliestSuspendedTime) { + if (earliestRemainingTime > earliestSuspendedTime) { // The earliest remaining time is earlier than all the suspended work. // Treat it as a pending update. markPendingPriorityLevel(root, earliestRemainingTime); @@ -6115,10 +6188,10 @@ function hasLowerPriorityWork(root, erroredExpirationTime) { var latestPingedTime = root.latestPingedTime; return ( (latestPendingTime !== NoWork && - latestPendingTime > erroredExpirationTime) || + latestPendingTime < erroredExpirationTime) || (latestSuspendedTime !== NoWork && - latestSuspendedTime > erroredExpirationTime) || - (latestPingedTime !== NoWork && latestPingedTime > erroredExpirationTime) + latestSuspendedTime < erroredExpirationTime) || + (latestPingedTime !== NoWork && latestPingedTime < erroredExpirationTime) ); } @@ -6127,8 +6200,8 @@ function isPriorityLevelSuspended(root, expirationTime) { var latestSuspendedTime = root.latestSuspendedTime; return ( earliestSuspendedTime !== NoWork && - expirationTime >= earliestSuspendedTime && - expirationTime <= latestSuspendedTime + expirationTime <= earliestSuspendedTime && + expirationTime >= latestSuspendedTime ); } @@ -6161,10 +6234,10 @@ function markSuspendedPriorityLevel(root, suspendedTime) { // No other suspended levels. root.earliestSuspendedTime = root.latestSuspendedTime = suspendedTime; } else { - if (earliestSuspendedTime > suspendedTime) { + if (earliestSuspendedTime < suspendedTime) { // This is the earliest suspended level. root.earliestSuspendedTime = suspendedTime; - } else if (latestSuspendedTime < suspendedTime) { + } else if (latestSuspendedTime > suspendedTime) { // This is the latest suspended level root.latestSuspendedTime = suspendedTime; } @@ -6180,7 +6253,7 @@ function markPingedPriorityLevel(root, pingedTime) { // is thrown out and not reused during the restarted render. One way to // invalidate the progressed work is to restart at expirationTime + 1. var latestPingedTime = root.latestPingedTime; - if (latestPingedTime === NoWork || latestPingedTime < pingedTime) { + if (latestPingedTime === NoWork || latestPingedTime > pingedTime) { root.latestPingedTime = pingedTime; } findNextExpirationTimeToWorkOn(pingedTime, root); @@ -6190,7 +6263,7 @@ function clearPing(root, completedTime) { // TODO: Track whether the root was pinged during the render phase. If so, // we need to make sure we don't lose track of it. var latestPingedTime = root.latestPingedTime; - if (latestPingedTime !== NoWork && latestPingedTime <= completedTime) { + if (latestPingedTime !== NoWork && latestPingedTime >= completedTime) { root.latestPingedTime = NoWork; } } @@ -6200,18 +6273,10 @@ function findEarliestOutstandingPriorityLevel(root, renderExpirationTime) { var earliestPendingTime = root.earliestPendingTime; var earliestSuspendedTime = root.earliestSuspendedTime; - if ( - earliestExpirationTime === NoWork || - (earliestPendingTime !== NoWork && - earliestPendingTime < earliestExpirationTime) - ) { + if (earliestPendingTime > earliestExpirationTime) { earliestExpirationTime = earliestPendingTime; } - if ( - earliestExpirationTime === NoWork || - (earliestSuspendedTime !== NoWork && - earliestSuspendedTime < earliestExpirationTime) - ) { + if (earliestSuspendedTime > earliestExpirationTime) { earliestExpirationTime = earliestSuspendedTime; } return earliestExpirationTime; @@ -6219,7 +6284,7 @@ function findEarliestOutstandingPriorityLevel(root, renderExpirationTime) { function didExpireAtExpirationTime(root, currentTime) { var expirationTime = root.expirationTime; - if (expirationTime !== NoWork && currentTime >= expirationTime) { + if (expirationTime !== NoWork && currentTime <= expirationTime) { // The root has expired. Flush all work up to the current time. root.nextExpirationTimeToWorkOn = currentTime; } @@ -6241,7 +6306,7 @@ function findNextExpirationTimeToWorkOn(completedExpirationTime, root) { if ( nextExpirationTimeToWorkOn === NoWork && (completedExpirationTime === NoWork || - latestSuspendedTime > completedExpirationTime) + latestSuspendedTime < completedExpirationTime) ) { // The lowest priority suspended work is the work most likely to be // committed next. Let's start rendering it again, so that if it times out, @@ -6250,11 +6315,7 @@ function findNextExpirationTimeToWorkOn(completedExpirationTime, root) { } var expirationTime = nextExpirationTimeToWorkOn; - if ( - expirationTime !== NoWork && - earliestSuspendedTime !== NoWork && - earliestSuspendedTime < expirationTime - ) { + if (expirationTime !== NoWork && earliestSuspendedTime > expirationTime) { // Expire using the earliest known expiration time. expirationTime = earliestSuspendedTime; } @@ -6478,7 +6539,7 @@ function enqueueUpdate(fiber, update) { { if ( - (fiber.tag === ClassComponent || fiber.tag === ClassComponentLazy) && + fiber.tag === ClassComponent && (currentlyProcessingQueue === queue1 || (queue2 !== null && currentlyProcessingQueue === queue2)) && !didWarnUpdateInsideUpdate @@ -6626,7 +6687,7 @@ function processUpdateQueue( var resultState = newBaseState; while (update !== null) { var updateExpirationTime = update.expirationTime; - if (updateExpirationTime > renderExpirationTime) { + if (updateExpirationTime < renderExpirationTime) { // This update does not have sufficient priority. Skip it. if (newFirstUpdate === null) { // This is the first skipped update. It will be the first update in @@ -6638,10 +6699,7 @@ function processUpdateQueue( } // Since this update will remain in the list, update the remaining // expiration time. - if ( - newExpirationTime === NoWork || - newExpirationTime > updateExpirationTime - ) { + if (newExpirationTime < updateExpirationTime) { newExpirationTime = updateExpirationTime; } } else { @@ -6677,7 +6735,7 @@ function processUpdateQueue( update = queue.firstCapturedUpdate; while (update !== null) { var _updateExpirationTime = update.expirationTime; - if (_updateExpirationTime > renderExpirationTime) { + if (_updateExpirationTime < renderExpirationTime) { // This update does not have sufficient priority. Skip it. if (newFirstCapturedUpdate === null) { // This is the first skipped captured update. It will be the first @@ -6691,10 +6749,7 @@ function processUpdateQueue( } // Since this update will remain in the list, update the remaining // expiration time. - if ( - newExpirationTime === NoWork || - newExpirationTime > _updateExpirationTime - ) { + if (newExpirationTime < _updateExpirationTime) { newExpirationTime = _updateExpirationTime; } } else { @@ -6992,10 +7047,7 @@ function propagateContextChange( ) { // Match! Schedule an update on this fiber. - if ( - fiber.tag === ClassComponent || - fiber.tag === ClassComponentLazy - ) { + if (fiber.tag === ClassComponent) { // Schedule a force update on the work-in-progress. var update = createUpdate(renderExpirationTime); update.tag = ForceUpdate; @@ -7006,17 +7058,13 @@ function propagateContextChange( enqueueUpdate(fiber, update); } - if ( - fiber.expirationTime === NoWork || - fiber.expirationTime > renderExpirationTime - ) { + if (fiber.expirationTime < renderExpirationTime) { fiber.expirationTime = renderExpirationTime; } var alternate = fiber.alternate; if ( alternate !== null && - (alternate.expirationTime === NoWork || - alternate.expirationTime > renderExpirationTime) + alternate.expirationTime < renderExpirationTime ) { alternate.expirationTime = renderExpirationTime; } @@ -7025,22 +7073,17 @@ function propagateContextChange( var node = fiber.return; while (node !== null) { alternate = node.alternate; - if ( - node.childExpirationTime === NoWork || - node.childExpirationTime > renderExpirationTime - ) { + if (node.childExpirationTime < renderExpirationTime) { node.childExpirationTime = renderExpirationTime; if ( alternate !== null && - (alternate.childExpirationTime === NoWork || - alternate.childExpirationTime > renderExpirationTime) + alternate.childExpirationTime < renderExpirationTime ) { alternate.childExpirationTime = renderExpirationTime; } } else if ( alternate !== null && - (alternate.childExpirationTime === NoWork || - alternate.childExpirationTime > renderExpirationTime) + alternate.childExpirationTime < renderExpirationTime ) { alternate.childExpirationTime = renderExpirationTime; } else { @@ -7125,7 +7168,7 @@ function readContext(context, observedBits) { if (lastContextDependency === null) { invariant( currentlyRenderingFiber !== null, - "Context.unstable_read(): Context can only be read while React is " + + "Context can only be read while React is " + "rendering, e.g. inside the render method or getDerivedStateFromProps." ); // This is the first dependency in the list @@ -7138,6 +7181,637 @@ function readContext(context, observedBits) { return isPrimaryRenderer ? context._currentValue : context._currentValue2; } +var NoEffect$1 = /* */ 0; +var UnmountSnapshot = /* */ 2; +var UnmountMutation = /* */ 4; +var MountMutation = /* */ 8; +var UnmountLayout = /* */ 16; +var MountLayout = /* */ 32; +var MountPassive = /* */ 64; +var UnmountPassive = /* */ 128; + +// These are set right before calling the component. +var renderExpirationTime = NoWork; +// The work-in-progress fiber. I've named it differently to distinguish it from +// the work-in-progress hook. +var currentlyRenderingFiber$1 = null; + +// Hooks are stored as a linked list on the fiber's memoizedState field. The +// current hook list is the list that belongs to the current fiber. The +// work-in-progress hook list is a new list that will be added to the +// work-in-progress fiber. +var firstCurrentHook = null; +var currentHook = null; +var firstWorkInProgressHook = null; +var workInProgressHook = null; + +var remainingExpirationTime = NoWork; +var componentUpdateQueue = null; + +// Updates scheduled during render will trigger an immediate re-render at the +// end of the current pass. We can't store these updates on the normal queue, +// because if the work is aborted, they should be discarded. Because this is +// a relatively rare case, we also don't want to add an additional field to +// either the hook or queue object types. So we store them in a lazily create +// map of queue -> render-phase updates, which are discarded once the component +// completes without re-rendering. + +// Whether the work-in-progress hook is a re-rendered hook +var isReRender = false; +// Whether an update was scheduled during the currently executing render pass. +var didScheduleRenderPhaseUpdate = false; +// Lazily created map of render-phase updates +var renderPhaseUpdates = null; +// Counter to prevent infinite loops. +var numberOfReRenders = 0; +var RE_RENDER_LIMIT = 25; + +function resolveCurrentlyRenderingFiber() { + invariant( + currentlyRenderingFiber$1 !== null, + "Hooks can only be called inside the body of a function component." + ); + return currentlyRenderingFiber$1; +} + +function prepareToUseHooks(current, workInProgress, nextRenderExpirationTime) { + renderExpirationTime = nextRenderExpirationTime; + currentlyRenderingFiber$1 = workInProgress; + firstCurrentHook = current !== null ? current.memoizedState : null; + + // The following should have already been reset + // currentHook = null; + // workInProgressHook = null; + + // remainingExpirationTime = NoWork; + // componentUpdateQueue = null; + + // isReRender = false; + // didScheduleRenderPhaseUpdate = false; + // renderPhaseUpdates = null; + // numberOfReRenders = 0; +} + +function finishHooks(Component, props, children, refOrContext) { + // This must be called after every function component to prevent hooks from + // being used in classes. + + while (didScheduleRenderPhaseUpdate) { + // Updates were scheduled during the render phase. They are stored in + // the `renderPhaseUpdates` map. Call the component again, reusing the + // work-in-progress hooks and applying the additional updates on top. Keep + // restarting until no more updates are scheduled. + didScheduleRenderPhaseUpdate = false; + numberOfReRenders += 1; + + // Start over from the beginning of the list + currentHook = null; + workInProgressHook = null; + componentUpdateQueue = null; + + children = Component(props, refOrContext); + } + renderPhaseUpdates = null; + numberOfReRenders = 0; + + var renderedWork = currentlyRenderingFiber$1; + + renderedWork.memoizedState = firstWorkInProgressHook; + renderedWork.expirationTime = remainingExpirationTime; + renderedWork.updateQueue = componentUpdateQueue; + + var didRenderTooFewHooks = currentHook !== null && currentHook.next !== null; + + renderExpirationTime = NoWork; + currentlyRenderingFiber$1 = null; + + firstCurrentHook = null; + currentHook = null; + firstWorkInProgressHook = null; + workInProgressHook = null; + + remainingExpirationTime = NoWork; + componentUpdateQueue = null; + + // Always set during createWorkInProgress + // isReRender = false; + + // These were reset above + // didScheduleRenderPhaseUpdate = false; + // renderPhaseUpdates = null; + // numberOfReRenders = 0; + + invariant( + !didRenderTooFewHooks, + "Rendered fewer hooks than expected. This may be caused by an accidental " + + "early return statement." + ); + + return children; +} + +function resetHooks() { + // This is called instead of `finishHooks` if the component throws. It's also + // called inside mountIndeterminateComponent if we determine the component + // is a module-style component. + renderExpirationTime = NoWork; + currentlyRenderingFiber$1 = null; + + firstCurrentHook = null; + currentHook = null; + firstWorkInProgressHook = null; + workInProgressHook = null; + + remainingExpirationTime = NoWork; + componentUpdateQueue = null; + + // Always set during createWorkInProgress + // isReRender = false; + + didScheduleRenderPhaseUpdate = false; + renderPhaseUpdates = null; + numberOfReRenders = 0; +} + +function createHook() { + return { + memoizedState: null, + + baseState: null, + queue: null, + baseUpdate: null, + + next: null + }; +} + +function cloneHook(hook) { + return { + memoizedState: hook.memoizedState, + + baseState: hook.memoizedState, + queue: hook.queue, + baseUpdate: hook.baseUpdate, + + next: null + }; +} + +function createWorkInProgressHook() { + if (workInProgressHook === null) { + // This is the first hook in the list + if (firstWorkInProgressHook === null) { + isReRender = false; + currentHook = firstCurrentHook; + if (currentHook === null) { + // This is a newly mounted hook + workInProgressHook = createHook(); + } else { + // Clone the current hook. + workInProgressHook = cloneHook(currentHook); + } + firstWorkInProgressHook = workInProgressHook; + } else { + // There's already a work-in-progress. Reuse it. + isReRender = true; + currentHook = firstCurrentHook; + workInProgressHook = firstWorkInProgressHook; + } + } else { + if (workInProgressHook.next === null) { + isReRender = false; + var hook = void 0; + if (currentHook === null) { + // This is a newly mounted hook + hook = createHook(); + } else { + currentHook = currentHook.next; + if (currentHook === null) { + // This is a newly mounted hook + hook = createHook(); + } else { + // Clone the current hook. + hook = cloneHook(currentHook); + } + } + // Append to the end of the list + workInProgressHook = workInProgressHook.next = hook; + } else { + // There's already a work-in-progress. Reuse it. + isReRender = true; + workInProgressHook = workInProgressHook.next; + currentHook = currentHook !== null ? currentHook.next : null; + } + } + return workInProgressHook; +} + +function createFunctionComponentUpdateQueue() { + return { + lastEffect: null + }; +} + +function basicStateReducer(state, action) { + return typeof action === "function" ? action(state) : action; +} + +function useContext(context, observedBits) { + // Ensure we're in a function component (class components support only the + // .unstable_read() form) + resolveCurrentlyRenderingFiber(); + return readContext(context, observedBits); +} + +function useState(initialState) { + return useReducer( + basicStateReducer, + // useReducer has a special case to support lazy useState initializers + initialState + ); +} + +function useReducer(reducer, initialState, initialAction) { + currentlyRenderingFiber$1 = resolveCurrentlyRenderingFiber(); + workInProgressHook = createWorkInProgressHook(); + var queue = workInProgressHook.queue; + if (queue !== null) { + // Already have a queue, so this is an update. + if (isReRender) { + // This is a re-render. Apply the new render phase updates to the previous + var _dispatch2 = queue.dispatch; + if (renderPhaseUpdates !== null) { + // Render phase updates are stored in a map of queue -> linked list + var firstRenderPhaseUpdate = renderPhaseUpdates.get(queue); + if (firstRenderPhaseUpdate !== undefined) { + renderPhaseUpdates.delete(queue); + var newState = workInProgressHook.memoizedState; + var update = firstRenderPhaseUpdate; + do { + // Process this render phase update. We don't have to check the + // priority because it will always be the same as the current + // render's. + var _action = update.action; + newState = reducer(newState, _action); + update = update.next; + } while (update !== null); + + workInProgressHook.memoizedState = newState; + + // Don't persist the state accumlated from the render phase updates to + // the base state unless the queue is empty. + // TODO: Not sure if this is the desired semantics, but it's what we + // do for gDSFP. I can't remember why. + if (workInProgressHook.baseUpdate === queue.last) { + workInProgressHook.baseState = newState; + } + + return [newState, _dispatch2]; + } + } + return [workInProgressHook.memoizedState, _dispatch2]; + } + + // The last update in the entire queue + var _last = queue.last; + // The last update that is part of the base state. + var _baseUpdate = workInProgressHook.baseUpdate; + + // Find the first unprocessed update. + var first = void 0; + if (_baseUpdate !== null) { + if (_last !== null) { + // For the first update, the queue is a circular linked list where + // `queue.last.next = queue.first`. Once the first update commits, and + // the `baseUpdate` is no longer empty, we can unravel the list. + _last.next = null; + } + first = _baseUpdate.next; + } else { + first = _last !== null ? _last.next : null; + } + if (first !== null) { + var _newState = workInProgressHook.baseState; + var newBaseState = null; + var newBaseUpdate = null; + var prevUpdate = _baseUpdate; + var _update = first; + var didSkip = false; + do { + var updateExpirationTime = _update.expirationTime; + if (updateExpirationTime < renderExpirationTime) { + // Priority is insufficient. Skip this update. If this is the first + // skipped update, the previous update/state is the new base + // update/state. + if (!didSkip) { + didSkip = true; + newBaseUpdate = prevUpdate; + newBaseState = _newState; + } + // Update the remaining priority in the queue. + if (updateExpirationTime > remainingExpirationTime) { + remainingExpirationTime = updateExpirationTime; + } + } else { + // Process this update. + var _action2 = _update.action; + _newState = reducer(_newState, _action2); + } + prevUpdate = _update; + _update = _update.next; + } while (_update !== null && _update !== first); + + if (!didSkip) { + newBaseUpdate = prevUpdate; + newBaseState = _newState; + } + + workInProgressHook.memoizedState = _newState; + workInProgressHook.baseUpdate = newBaseUpdate; + workInProgressHook.baseState = newBaseState; + } + + var _dispatch = queue.dispatch; + return [workInProgressHook.memoizedState, _dispatch]; + } + + // There's no existing queue, so this is the initial render. + if (reducer === basicStateReducer) { + // Special case for `useState`. + if (typeof initialState === "function") { + initialState = initialState(); + } + } else if (initialAction !== undefined && initialAction !== null) { + initialState = reducer(initialState, initialAction); + } + workInProgressHook.memoizedState = workInProgressHook.baseState = initialState; + queue = workInProgressHook.queue = { + last: null, + dispatch: null + }; + var dispatch = (queue.dispatch = dispatchAction.bind( + null, + currentlyRenderingFiber$1, + queue + )); + return [workInProgressHook.memoizedState, dispatch]; +} + +function pushEffect(tag, create, destroy, inputs) { + var effect = { + tag: tag, + create: create, + destroy: destroy, + inputs: inputs, + // Circular + next: null + }; + if (componentUpdateQueue === null) { + componentUpdateQueue = createFunctionComponentUpdateQueue(); + componentUpdateQueue.lastEffect = effect.next = effect; + } else { + var _lastEffect = componentUpdateQueue.lastEffect; + if (_lastEffect === null) { + componentUpdateQueue.lastEffect = effect.next = effect; + } else { + var firstEffect = _lastEffect.next; + _lastEffect.next = effect; + effect.next = firstEffect; + componentUpdateQueue.lastEffect = effect; + } + } + return effect; +} + +function useRef(initialValue) { + currentlyRenderingFiber$1 = resolveCurrentlyRenderingFiber(); + workInProgressHook = createWorkInProgressHook(); + var ref = void 0; + + if (workInProgressHook.memoizedState === null) { + ref = { current: initialValue }; + { + Object.seal(ref); + } + workInProgressHook.memoizedState = ref; + } else { + ref = workInProgressHook.memoizedState; + } + return ref; +} + +function useMutationEffect(create, inputs) { + useEffectImpl( + Snapshot | Update, + UnmountSnapshot | MountMutation, + create, + inputs + ); +} + +function useLayoutEffect(create, inputs) { + useEffectImpl(Update, UnmountMutation | MountLayout, create, inputs); +} + +function useEffect(create, inputs) { + useEffectImpl( + Update | Passive, + UnmountPassive | MountPassive, + create, + inputs + ); +} + +function useEffectImpl(fiberEffectTag, hookEffectTag, create, inputs) { + currentlyRenderingFiber$1 = resolveCurrentlyRenderingFiber(); + workInProgressHook = createWorkInProgressHook(); + + var nextInputs = inputs !== undefined && inputs !== null ? inputs : [create]; + var destroy = null; + if (currentHook !== null) { + var prevEffect = currentHook.memoizedState; + destroy = prevEffect.destroy; + if (inputsAreEqual(nextInputs, prevEffect.inputs)) { + pushEffect(NoEffect$1, create, destroy, nextInputs); + return; + } + } + + currentlyRenderingFiber$1.effectTag |= fiberEffectTag; + workInProgressHook.memoizedState = pushEffect( + hookEffectTag, + create, + destroy, + nextInputs + ); +} + +function useImperativeMethods(ref, create, inputs) { + // TODO: If inputs are provided, should we skip comparing the ref itself? + var nextInputs = + inputs !== null && inputs !== undefined + ? inputs.concat([ref]) + : [ref, create]; + + // TODO: I've implemented this on top of useEffect because it's almost the + // same thing, and it would require an equal amount of code. It doesn't seem + // like a common enough use case to justify the additional size. + useEffectImpl( + Update, + UnmountMutation | MountLayout, + function() { + if (typeof ref === "function") { + var refCallback = ref; + var _inst = create(); + refCallback(_inst); + return function() { + return refCallback(null); + }; + } else if (ref !== null && ref !== undefined) { + var refObject = ref; + var _inst2 = create(); + refObject.current = _inst2; + return function() { + refObject.current = null; + }; + } + }, + nextInputs + ); +} + +function useCallback(callback, inputs) { + currentlyRenderingFiber$1 = resolveCurrentlyRenderingFiber(); + workInProgressHook = createWorkInProgressHook(); + + var nextInputs = + inputs !== undefined && inputs !== null ? inputs : [callback]; + + var prevState = workInProgressHook.memoizedState; + if (prevState !== null) { + var prevInputs = prevState[1]; + if (inputsAreEqual(nextInputs, prevInputs)) { + return prevState[0]; + } + } + workInProgressHook.memoizedState = [callback, nextInputs]; + return callback; +} + +function useMemo(nextCreate, inputs) { + currentlyRenderingFiber$1 = resolveCurrentlyRenderingFiber(); + workInProgressHook = createWorkInProgressHook(); + + var nextInputs = + inputs !== undefined && inputs !== null ? inputs : [nextCreate]; + + var prevState = workInProgressHook.memoizedState; + if (prevState !== null) { + var prevInputs = prevState[1]; + if (inputsAreEqual(nextInputs, prevInputs)) { + return prevState[0]; + } + } + + var nextValue = nextCreate(); + workInProgressHook.memoizedState = [nextValue, nextInputs]; + return nextValue; +} + +function dispatchAction(fiber, queue, action) { + invariant( + numberOfReRenders < RE_RENDER_LIMIT, + "Too many re-renders. React limits the number of renders to prevent " + + "an infinite loop." + ); + + var alternate = fiber.alternate; + if ( + fiber === currentlyRenderingFiber$1 || + (alternate !== null && alternate === currentlyRenderingFiber$1) + ) { + // This is a render phase update. Stash it in a lazily-created map of + // queue -> linked list of updates. After this render pass, we'll restart + // and apply the stashed updates on top of the work-in-progress hook. + didScheduleRenderPhaseUpdate = true; + var update = { + expirationTime: renderExpirationTime, + action: action, + next: null + }; + if (renderPhaseUpdates === null) { + renderPhaseUpdates = new Map(); + } + var firstRenderPhaseUpdate = renderPhaseUpdates.get(queue); + if (firstRenderPhaseUpdate === undefined) { + renderPhaseUpdates.set(queue, update); + } else { + // Append the update to the end of the list. + var lastRenderPhaseUpdate = firstRenderPhaseUpdate; + while (lastRenderPhaseUpdate.next !== null) { + lastRenderPhaseUpdate = lastRenderPhaseUpdate.next; + } + lastRenderPhaseUpdate.next = update; + } + } else { + var currentTime = requestCurrentTime(); + var _expirationTime = computeExpirationForFiber(currentTime, fiber); + var _update2 = { + expirationTime: _expirationTime, + action: action, + next: null + }; + flushPassiveEffects(); + // Append the update to the end of the list. + var _last2 = queue.last; + if (_last2 === null) { + // This is the first update. Create a circular list. + _update2.next = _update2; + } else { + var first = _last2.next; + if (first !== null) { + // Still circular. + _update2.next = first; + } + _last2.next = _update2; + } + queue.last = _update2; + scheduleWork(fiber, _expirationTime); + } +} + +function inputsAreEqual(arr1, arr2) { + // Don't bother comparing lengths in prod because these arrays should be + // passed inline. + { + !(arr1.length === arr2.length) + ? warning$1( + false, + "Detected a variable number of hook dependencies. The length of the " + + "dependencies array should be constant between renders.\n\n" + + "Previous: %s\n" + + "Incoming: %s", + arr1.join(", "), + arr2.join(", ") + ) + : void 0; + } + for (var i = 0; i < arr1.length; i++) { + // Inlined Object.is polyfill. + // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is + var val1 = arr1[i]; + var val2 = arr2[i]; + if ( + (val1 === val2 && (val1 !== 0 || 1 / val1 === 1 / val2)) || + (val1 !== val1 && val2 !== val2) // eslint-disable-line no-self-compare + ) { + continue; + } + return false; + } + return true; +} + var NO_CONTEXT = {}; var contextStackCursor$1 = createCursor(NO_CONTEXT); @@ -7324,6 +7998,13 @@ function shallowEqual(objA, objB) { return true; } +var ReactCurrentOwner$4 = ReactSharedInternals.ReactCurrentOwner; + +function readContext$1(contextType) { + var dispatcher = ReactCurrentOwner$4.currentDispatcher; + return dispatcher.readContext(contextType); +} + var fakeInternalInstance = {}; var isArray$1 = Array.isArray; @@ -7463,6 +8144,7 @@ var classComponentUpdater = { update.callback = callback; } + flushPassiveEffects(); enqueueUpdate(fiber, update); scheduleWork(fiber, expirationTime); }, @@ -7482,6 +8164,7 @@ var classComponentUpdater = { update.callback = callback; } + flushPassiveEffects(); enqueueUpdate(fiber, update); scheduleWork(fiber, expirationTime); }, @@ -7500,6 +8183,7 @@ var classComponentUpdater = { update.callback = callback; } + flushPassiveEffects(); enqueueUpdate(fiber, update); scheduleWork(fiber, expirationTime); } @@ -7816,7 +8500,7 @@ function constructClassInstance( if (typeof contextType === "object" && contextType !== null) { { if ( - typeof contextType.unstable_read !== "function" && + contextType.$$typeof !== REACT_CONTEXT_TYPE && !didWarnAboutInvalidateContextType.has(ctor) ) { didWarnAboutInvalidateContextType.add(ctor); @@ -7830,7 +8514,7 @@ function constructClassInstance( } } - context = contextType.unstable_read(); + context = readContext$1(contextType); } else { unmaskedContext = getUnmaskedContext(workInProgress, ctor, true); var contextTypes = ctor.contextTypes; @@ -8032,7 +8716,7 @@ function mountClassInstance( var contextType = ctor.contextType; if (typeof contextType === "object" && contextType !== null) { - instance.context = contextType.unstable_read(); + instance.context = readContext$1(contextType); } else { var unmaskedContext = getUnmaskedContext(workInProgress, ctor, true); instance.context = getMaskedContext(workInProgress, unmaskedContext); @@ -8140,7 +8824,7 @@ function resumeMountClassInstance( var contextType = ctor.contextType; var nextContext = void 0; if (typeof contextType === "object" && contextType !== null) { - nextContext = contextType.unstable_read(); + nextContext = readContext$1(contextType); } else { var nextLegacyUnmaskedContext = getUnmaskedContext( workInProgress, @@ -8286,7 +8970,7 @@ function updateClassInstance( var contextType = ctor.contextType; var nextContext = void 0; if (typeof contextType === "object" && contextType !== null) { - nextContext = contextType.unstable_read(); + nextContext = readContext$1(contextType); } else { var nextUnmaskedContext = getUnmaskedContext(workInProgress, ctor, true); nextContext = getMaskedContext(workInProgress, nextUnmaskedContext); @@ -8529,8 +9213,7 @@ function coerceRef(returnFiber, current$$1, element) { if (owner) { var ownerFiber = owner; invariant( - ownerFiber.tag === ClassComponent || - ownerFiber.tag === ClassComponentLazy, + ownerFiber.tag === ClassComponent, "Function components cannot have refs." ); inst = ownerFiber.stateNode; @@ -8750,7 +9433,7 @@ function ChildReconciler(shouldTrackSideEffects) { } function updateElement(returnFiber, current$$1, element, expirationTime) { - if (current$$1 !== null && current$$1.type === element.type) { + if (current$$1 !== null && current$$1.elementType === element.type) { // Move based on index var existing = useFiber(current$$1, element.props, expirationTime); existing.ref = coerceRef(returnFiber, current$$1, element); @@ -9488,7 +10171,7 @@ function ChildReconciler(shouldTrackSideEffects) { if ( child.tag === Fragment ? element.type === REACT_FRAGMENT_TYPE - : child.type === element.type + : child.elementType === element.type ) { deleteRemainingChildren(returnFiber, child.sibling); var existing = useFiber( @@ -9671,8 +10354,7 @@ function ChildReconciler(shouldTrackSideEffects) { // component, throw an error. If Fiber return types are disabled, // we already threw above. switch (returnFiber.tag) { - case ClassComponent: - case ClassComponentLazy: { + case ClassComponent: { { var instance = returnFiber.stateNode; if (instance.render._isMockFunction) { @@ -10055,45 +10737,54 @@ function resetHydrationState() { isHydrating = false; } -function readLazyComponentType(thenable) { - var status = thenable._reactStatus; +function readLazyComponentType(lazyComponent) { + var status = lazyComponent._status; + var result = lazyComponent._result; switch (status) { - case Resolved: - var Component = thenable._reactResult; + case Resolved: { + var Component = result; return Component; - case Rejected: - throw thenable._reactResult; - case Pending: + } + case Rejected: { + var error = result; + throw error; + } + case Pending: { + var thenable = result; 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; + lazyComponent._status = Pending; + var ctor = lazyComponent._ctor; + var _thenable = ctor(); + _thenable.then( + function(moduleObject) { + if (lazyComponent._status === Pending) { + var defaultExport = moduleObject.default; + { + if (defaultExport === undefined) { + warning$1( + false, + "lazy: Expected the result of a dynamic import() call. " + + "Instead received: %s\n\nYour code should look like: \n " + + "const MyComponent = lazy(() => import('./MyComponent'))", + moduleObject + ); + } } - thenable._reactResult = resolvedValue; + lazyComponent._status = Resolved; + lazyComponent._result = defaultExport; } }, function(error) { - if (thenable._reactStatus === Pending) { - thenable._reactStatus = Rejected; - thenable._reactResult = error; + if (lazyComponent._status === Pending) { + lazyComponent._status = Rejected; + lazyComponent._result = error; } } ); - throw thenable; + lazyComponent._result = _thenable; + throw _thenable; } } } @@ -10178,87 +10869,26 @@ function forceUnmountCurrentAndReconcile( } 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 - // we don't do the bailout and we have to reuse existing props instead. - } else if (workInProgress.memoizedProps === nextProps) { - var currentRef = current$$1 !== null ? current$$1.ref : null; - if (ref === currentRef) { - return bailoutOnAlreadyFinishedWork( - current$$1, - workInProgress, - renderExpirationTime - ); - } - } - - var nextChildren = void 0; - { - ReactCurrentOwner$3.current = workInProgress; - setCurrentPhase("render"); - nextChildren = render(nextProps, ref); - setCurrentPhase(null); - } - - reconcileChildren( - current$$1, - workInProgress, - nextChildren, - renderExpirationTime - ); - memoizeProps(workInProgress, nextProps); - return workInProgress.child; -} - -function updatePureComponent( current$$1, workInProgress, Component, nextProps, - updateExpirationTime, renderExpirationTime ) { var render = Component.render; var ref = workInProgress.ref; - if ( - current$$1 !== null && - (updateExpirationTime === NoWork || - updateExpirationTime > renderExpirationTime) - ) { - var prevProps = current$$1.memoizedProps; - // Default to shallow comparison - var compare = Component.compare; - compare = compare !== null ? compare : shallowEqual; - if ( - workInProgress.ref === current$$1.ref && - compare(prevProps, nextProps) - ) { - return bailoutOnAlreadyFinishedWork( - current$$1, - workInProgress, - renderExpirationTime - ); - } - } - // The rest is a fork of updateFunctionComponent var nextChildren = void 0; prepareToReadContext(workInProgress, renderExpirationTime); + prepareToUseHooks(current$$1, workInProgress, renderExpirationTime); { ReactCurrentOwner$3.current = workInProgress; setCurrentPhase("render"); nextChildren = render(nextProps, ref); setCurrentPhase(null); } + nextChildren = finishHooks(render, nextProps, nextChildren, ref); // React DevTools reads this flag. workInProgress.effectTag |= PerformedWork; @@ -10268,10 +10898,107 @@ function updatePureComponent( nextChildren, renderExpirationTime ); - memoizeProps(workInProgress, nextProps); return workInProgress.child; } +function updateMemoComponent( + current$$1, + workInProgress, + Component, + nextProps, + updateExpirationTime, + renderExpirationTime +) { + if (current$$1 === null) { + var type = Component.type; + if (isSimpleFunctionComponent(type) && Component.compare === null) { + // If this is a plain function component without default props, + // and with only the default shallow comparison, we upgrade it + // to a SimpleMemoComponent to allow fast path updates. + workInProgress.tag = SimpleMemoComponent; + workInProgress.type = type; + return updateSimpleMemoComponent( + current$$1, + workInProgress, + type, + nextProps, + updateExpirationTime, + renderExpirationTime + ); + } + var child = createFiberFromTypeAndProps( + Component.type, + null, + nextProps, + null, + workInProgress.mode, + renderExpirationTime + ); + child.ref = workInProgress.ref; + child.return = workInProgress; + workInProgress.child = child; + return child; + } + var currentChild = current$$1.child; // This is always exactly one child + if (updateExpirationTime < renderExpirationTime) { + // This will be the props with resolved defaultProps, + // unlike current.memoizedProps which will be the unresolved ones. + var prevProps = currentChild.memoizedProps; + // Default to shallow comparison + var compare = Component.compare; + compare = compare !== null ? compare : shallowEqual; + if ( + compare(prevProps, nextProps) && + current$$1.ref === workInProgress.ref + ) { + return bailoutOnAlreadyFinishedWork( + current$$1, + workInProgress, + renderExpirationTime + ); + } + } + var newChild = createWorkInProgress( + currentChild, + nextProps, + renderExpirationTime + ); + newChild.ref = workInProgress.ref; + newChild.return = workInProgress; + workInProgress.child = newChild; + return newChild; +} + +function updateSimpleMemoComponent( + current$$1, + workInProgress, + Component, + nextProps, + updateExpirationTime, + renderExpirationTime +) { + if (current$$1 !== null && updateExpirationTime < renderExpirationTime) { + var prevProps = current$$1.memoizedProps; + if ( + shallowEqual(prevProps, nextProps) && + current$$1.ref === workInProgress.ref + ) { + return bailoutOnAlreadyFinishedWork( + current$$1, + workInProgress, + renderExpirationTime + ); + } + } + return updateFunctionComponent( + current$$1, + workInProgress, + Component, + nextProps, + renderExpirationTime + ); +} + function updateFragment(current$$1, workInProgress, renderExpirationTime) { var nextChildren = workInProgress.pendingProps; reconcileChildren( @@ -10280,7 +11007,6 @@ function updateFragment(current$$1, workInProgress, renderExpirationTime) { nextChildren, renderExpirationTime ); - memoizeProps(workInProgress, nextChildren); return workInProgress.child; } @@ -10292,7 +11018,6 @@ function updateMode(current$$1, workInProgress, renderExpirationTime) { nextChildren, renderExpirationTime ); - memoizeProps(workInProgress, nextChildren); return workInProgress.child; } @@ -10308,7 +11033,6 @@ function updateProfiler(current$$1, workInProgress, renderExpirationTime) { nextChildren, renderExpirationTime ); - memoizeProps(workInProgress, nextProps); return workInProgress.child; } @@ -10335,12 +11059,14 @@ function updateFunctionComponent( var nextChildren = void 0; prepareToReadContext(workInProgress, renderExpirationTime); + prepareToUseHooks(current$$1, workInProgress, renderExpirationTime); { ReactCurrentOwner$3.current = workInProgress; setCurrentPhase("render"); nextChildren = Component(nextProps, context); setCurrentPhase(null); } + nextChildren = finishHooks(Component, nextProps, nextChildren, context); // React DevTools reads this flag. workInProgress.effectTag |= PerformedWork; @@ -10350,7 +11076,6 @@ function updateFunctionComponent( nextChildren, renderExpirationTime ); - memoizeProps(workInProgress, nextProps); return workInProgress.child; } @@ -10373,32 +11098,41 @@ function updateClassComponent( } prepareToReadContext(workInProgress, renderExpirationTime); + var instance = workInProgress.stateNode; var shouldUpdate = void 0; - if (current$$1 === null) { - if (workInProgress.stateNode === null) { - // In the initial pass we might need to construct the instance. - constructClassInstance( - workInProgress, - Component, - nextProps, - renderExpirationTime - ); - mountClassInstance( - workInProgress, - Component, - nextProps, - renderExpirationTime - ); - shouldUpdate = true; - } else { - // In a resume, we'll already have an instance we can reuse. - shouldUpdate = resumeMountClassInstance( - workInProgress, - Component, - nextProps, - renderExpirationTime - ); + if (instance === null) { + if (current$$1 !== null) { + // An class component without an instance only mounts if it suspended + // inside a non- concurrent tree, in an inconsistent state. We want to + // tree it like a new mount, even though an empty version of it already + // committed. Disconnect the alternate pointers. + current$$1.alternate = null; + workInProgress.alternate = null; + // Since this is conceptually a new fiber, schedule a Placement effect + workInProgress.effectTag |= Placement; } + // In the initial pass we might need to construct the instance. + constructClassInstance( + workInProgress, + Component, + nextProps, + renderExpirationTime + ); + mountClassInstance( + workInProgress, + Component, + nextProps, + renderExpirationTime + ); + shouldUpdate = true; + } else if (current$$1 === null) { + // In a resume, we'll already have an instance we can reuse. + shouldUpdate = resumeMountClassInstance( + workInProgress, + Component, + nextProps, + renderExpirationTime + ); } else { shouldUpdate = updateClassInstance( current$$1, @@ -10500,10 +11234,9 @@ function finishClassComponent( ); } - // Memoize props and state using the values we just used to render. + // Memoize state using the values we just used to render. // TODO: Restructure so we never read values from the instance. - memoizeState(workInProgress, instance.state); - memoizeProps(workInProgress, instance.props); + workInProgress.memoizedState = instance.state; // The context might have changed so we need to recalculate it. if (hasContext) { @@ -10637,7 +11370,6 @@ function updateHostComponent(current$$1, workInProgress, renderExpirationTime) { ) { // Schedule this fiber to re-render at offscreen priority. Then bailout. workInProgress.expirationTime = Never; - workInProgress.memoizedProps = nextProps; return null; } @@ -10647,7 +11379,6 @@ function updateHostComponent(current$$1, workInProgress, renderExpirationTime) { nextChildren, renderExpirationTime ); - memoizeProps(workInProgress, nextProps); return workInProgress.child; } @@ -10655,8 +11386,6 @@ function updateHostText(current$$1, workInProgress) { if (current$$1 === null) { tryToClaimNextHydratableInstance(workInProgress); } - var nextProps = workInProgress.pendingProps; - memoizeProps(workInProgress, nextProps); // Nothing to do here. This is terminal. We'll do the completion step // immediately after. return null; @@ -10677,98 +11406,173 @@ function resolveDefaultProps(Component, baseProps) { return baseProps; } -function mountIndeterminateComponent( - current$$1, +function mountLazyComponent( + _current, workInProgress, - Component, + elementType, updateExpirationTime, renderExpirationTime ) { - invariant( - current$$1 === null, - "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 ( - typeof Component === "object" && - Component !== null && - typeof Component.then === "function" - ) { - // We can't start a User Timing measurement with correct label yet. - // Cancel and resume right after we know the tag. - cancelWorkTimer(workInProgress); - Component = readLazyComponentType(Component); - var resolvedTag = (workInProgress.tag = resolveLazyComponentTag( - workInProgress, - Component - )); - startWorkTimer(workInProgress); - var resolvedProps = resolveDefaultProps(Component, props); - var child = void 0; - switch (resolvedTag) { - case FunctionComponentLazy: { - child = updateFunctionComponent( - current$$1, - workInProgress, - Component, - resolvedProps, - renderExpirationTime - ); - break; - } - case ClassComponentLazy: { - child = updateClassComponent( - current$$1, - workInProgress, - Component, - resolvedProps, - renderExpirationTime - ); - break; - } - case ForwardRefLazy: { - child = updateForwardRef( - current$$1, - workInProgress, - Component, - resolvedProps, - renderExpirationTime - ); - break; - } - case PureComponentLazy: { - child = updatePureComponent( - current$$1, - workInProgress, - Component, - resolvedProps, - updateExpirationTime, - renderExpirationTime - ); - break; - } - default: { - // This message intentionally doesn't metion ForwardRef or PureComponent - // 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 - ); - } - } - workInProgress.memoizedProps = props; - return child; + if (_current !== null) { + // An lazy component only mounts if it suspended inside a non- + // concurrent tree, in an inconsistent state. We want to tree it like + // a new mount, even though an empty version of it already committed. + // Disconnect the alternate pointers. + _current.alternate = null; + workInProgress.alternate = null; + // Since this is conceptually a new fiber, schedule a Placement effect + workInProgress.effectTag |= Placement; } + var props = workInProgress.pendingProps; + // We can't start a User Timing measurement with correct label yet. + // Cancel and resume right after we know the tag. + cancelWorkTimer(workInProgress); + var Component = readLazyComponentType(elementType); + // Store the unwrapped component in the type. + workInProgress.type = Component; + var resolvedTag = (workInProgress.tag = resolveLazyComponentTag(Component)); + startWorkTimer(workInProgress); + var resolvedProps = resolveDefaultProps(Component, props); + var child = void 0; + switch (resolvedTag) { + case FunctionComponent: { + child = updateFunctionComponent( + null, + workInProgress, + Component, + resolvedProps, + renderExpirationTime + ); + break; + } + case ClassComponent: { + child = updateClassComponent( + null, + workInProgress, + Component, + resolvedProps, + renderExpirationTime + ); + break; + } + case ForwardRef: { + child = updateForwardRef( + null, + workInProgress, + Component, + resolvedProps, + renderExpirationTime + ); + break; + } + case MemoComponent: { + child = updateMemoComponent( + null, + workInProgress, + Component, + resolveDefaultProps(Component.type, resolvedProps), // The inner type can have defaults too + updateExpirationTime, + renderExpirationTime + ); + break; + } + default: { + // This message intentionally doesn't metion ForwardRef or MemoComponent + // 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 + ); + } + } + return child; +} + +function mountIncompleteClassComponent( + _current, + workInProgress, + Component, + nextProps, + renderExpirationTime +) { + if (_current !== null) { + // An incomplete component only mounts if it suspended inside a non- + // concurrent tree, in an inconsistent state. We want to tree it like + // a new mount, even though an empty version of it already committed. + // Disconnect the alternate pointers. + _current.alternate = null; + workInProgress.alternate = null; + // Since this is conceptually a new fiber, schedule a Placement effect + workInProgress.effectTag |= Placement; + } + + // Promote the fiber to a class and try rendering again. + workInProgress.tag = ClassComponent; + + // The rest of this function is a fork of `updateClassComponent` + + // 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 = void 0; + if (isContextProvider(Component)) { + hasContext = true; + pushContextProvider(workInProgress); + } else { + hasContext = false; + } + prepareToReadContext(workInProgress, renderExpirationTime); + + constructClassInstance( + workInProgress, + Component, + nextProps, + renderExpirationTime + ); + mountClassInstance( + workInProgress, + Component, + nextProps, + renderExpirationTime + ); + + return finishClassComponent( + null, + workInProgress, + Component, + true, + hasContext, + renderExpirationTime + ); +} + +function mountIndeterminateComponent( + _current, + workInProgress, + Component, + renderExpirationTime +) { + if (_current !== null) { + // An indeterminate component only mounts if it suspended inside a non- + // concurrent tree, in an inconsistent state. We want to tree it like + // a new mount, even though an empty version of it already committed. + // Disconnect the alternate pointers. + _current.alternate = null; + workInProgress.alternate = null; + // Since this is conceptually a new fiber, schedule a Placement effect + workInProgress.effectTag |= Placement; + } + + var props = workInProgress.pendingProps; var unmaskedContext = getUnmaskedContext(workInProgress, Component, false); var context = getMaskedContext(workInProgress, unmaskedContext); prepareToReadContext(workInProgress, renderExpirationTime); + prepareToUseHooks(null, workInProgress, renderExpirationTime); var value = void 0; @@ -10810,6 +11614,9 @@ function mountIndeterminateComponent( // Proceed under the assumption that this is a class instance workInProgress.tag = ClassComponent; + // Throw out any hooks that were used. + resetHooks(); + // 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. @@ -10837,7 +11644,7 @@ function mountIndeterminateComponent( adoptClassInstance(workInProgress, value); mountClassInstance(workInProgress, Component, props, renderExpirationTime); return finishClassComponent( - current$$1, + null, workInProgress, Component, true, @@ -10847,6 +11654,7 @@ function mountIndeterminateComponent( } else { // Proceed under the assumption that this is a function component workInProgress.tag = FunctionComponent; + value = finishHooks(Component, props, value, context); { if (Component) { !!Component.childContextTypes @@ -10909,8 +11717,7 @@ function mountIndeterminateComponent( } } } - reconcileChildren(current$$1, workInProgress, value, renderExpirationTime); - memoizeProps(workInProgress, props); + reconcileChildren(null, workInProgress, value, renderExpirationTime); return workInProgress.child; } } @@ -10920,67 +11727,207 @@ function updateSuspenseComponent( workInProgress, renderExpirationTime ) { + var mode = workInProgress.mode; var nextProps = workInProgress.pendingProps; - // Check if we already attempted to render the normal state. If we did, - // and we timed out, render the placeholder state. - var alreadyCaptured = (workInProgress.effectTag & DidCapture) === NoEffect; - - var nextDidTimeout = void 0; - if (current$$1 !== null && workInProgress.updateQueue !== null) { - // We're outside strict mode. Something inside this Placeholder boundary - // suspended during the last commit. Switch to the placholder. - workInProgress.updateQueue = null; - nextDidTimeout = true; + // We should attempt to render the primary children unless this boundary + // already suspended during this render (`alreadyCaptured` is true). + var nextState = workInProgress.memoizedState; + if (nextState === null) { + // An empty suspense state means this boundary has not yet timed out. } else { - nextDidTimeout = !alreadyCaptured; - } - - if ((workInProgress.mode & StrictMode) !== NoEffect) { - if (nextDidTimeout) { - // If the timed-out view commits, schedule an update effect to record - // the committed time. - workInProgress.effectTag |= Update; + if (!nextState.alreadyCaptured) { + // Since we haven't already suspended during this commit, clear the + // existing suspense state. We'll try rendering again. + nextState = null; } else { - // The state node points to the time at which placeholder timed out. - // We can clear it once we switch back to the normal children. - workInProgress.stateNode = null; + // Something in this boundary's subtree already suspended. Switch to + // rendering the fallback children. Set `alreadyCaptured` to true. + if (current$$1 !== null && nextState === current$$1.memoizedState) { + // Create a new suspense state to avoid mutating the current tree's. + nextState = { + alreadyCaptured: true, + didTimeout: true, + timedOutAt: nextState.timedOutAt + }; + } else { + // Already have a clone, so it's safe to mutate. + nextState.alreadyCaptured = true; + nextState.didTimeout = true; + } + } + } + var nextDidTimeout = nextState !== null && nextState.didTimeout; + + // This next part is a bit confusing. If the children timeout, we switch to + // showing the fallback children in place of the "primary" children. + // However, we don't want to delete the primary children because then their + // state will be lost (both the React state and the host state, e.g. + // uncontrolled form inputs). Instead we keep them mounted and hide them. + // Both the fallback children AND the primary children are rendered at the + // same time. Once the primary children are un-suspended, we can delete + // the fallback children — don't need to preserve their state. + // + // The two sets of children are siblings in the host environment, but + // semantically, for purposes of reconciliation, they are two separate sets. + // So we store them using two fragment fibers. + // + // However, we want to avoid allocating extra fibers for every placeholder. + // They're only necessary when the children time out, because that's the + // only time when both sets are mounted. + // + // So, the extra fragment fibers are only used if the children time out. + // Otherwise, we render the primary children directly. This requires some + // custom reconciliation logic to preserve the state of the primary + // children. It's essentially a very basic form of re-parenting. + + // `child` points to the child fiber. In the normal case, this is the first + // fiber of the primary children set. In the timed-out case, it's a + // a fragment fiber containing the primary children. + var child = void 0; + // `next` points to the next fiber React should render. In the normal case, + // it's the same as `child`: the first fiber of the primary children set. + // In the timed-out case, it's a fragment fiber containing the *fallback* + // children -- we skip over the primary children entirely. + var next = void 0; + if (current$$1 === null) { + // This is the initial mount. This branch is pretty simple because there's + // no previous state that needs to be preserved. + if (nextDidTimeout) { + // Mount separate fragments for primary and fallback children. + var nextFallbackChildren = nextProps.fallback; + var primaryChildFragment = createFiberFromFragment( + null, + mode, + NoWork, + null + ); + var fallbackChildFragment = createFiberFromFragment( + nextFallbackChildren, + mode, + renderExpirationTime, + null + ); + primaryChildFragment.sibling = fallbackChildFragment; + child = primaryChildFragment; + // Skip the primary children, and continue working on the + // fallback children. + next = fallbackChildFragment; + child.return = next.return = workInProgress; + } else { + // Mount the primary children without an intermediate fragment fiber. + var nextPrimaryChildren = nextProps.children; + child = next = mountChildFibers( + workInProgress, + null, + nextPrimaryChildren, + renderExpirationTime + ); + } + } else { + // This is an update. This branch is more complicated because we need to + // ensure the state of the primary children is preserved. + var prevState = current$$1.memoizedState; + var prevDidTimeout = prevState !== null && prevState.didTimeout; + if (prevDidTimeout) { + // The current tree already timed out. That means each child set is + var currentPrimaryChildFragment = current$$1.child; + var currentFallbackChildFragment = currentPrimaryChildFragment.sibling; + if (nextDidTimeout) { + // Still timed out. Reuse the current primary children by cloning + // its fragment. We're going to skip over these entirely. + var _nextFallbackChildren = nextProps.fallback; + var _primaryChildFragment = createWorkInProgress( + currentPrimaryChildFragment, + currentPrimaryChildFragment.pendingProps, + NoWork + ); + _primaryChildFragment.effectTag |= Placement; + // Clone the fallback child fragment, too. These we'll continue + // working on. + var _fallbackChildFragment = (_primaryChildFragment.sibling = createWorkInProgress( + currentFallbackChildFragment, + _nextFallbackChildren, + currentFallbackChildFragment.expirationTime + )); + _fallbackChildFragment.effectTag |= Placement; + child = _primaryChildFragment; + _primaryChildFragment.childExpirationTime = NoWork; + // Skip the primary children, and continue working on the + // fallback children. + next = _fallbackChildFragment; + child.return = next.return = workInProgress; + } else { + // No longer suspended. Switch back to showing the primary children, + // and remove the intermediate fragment fiber. + var _nextPrimaryChildren = nextProps.children; + var currentPrimaryChild = currentPrimaryChildFragment.child; + var currentFallbackChild = currentFallbackChildFragment.child; + var primaryChild = reconcileChildFibers( + workInProgress, + currentPrimaryChild, + _nextPrimaryChildren, + renderExpirationTime + ); + // Delete the fallback children. + reconcileChildFibers( + workInProgress, + currentFallbackChild, + null, + renderExpirationTime + ); + // Continue rendering the children, like we normally do. + child = next = primaryChild; + } + } else { + // The current tree has not already timed out. That means the primary + var _currentPrimaryChild = current$$1.child; + if (nextDidTimeout) { + // Timed out. Wrap the children in a fragment fiber to keep them + // separate from the fallback children. + var _nextFallbackChildren2 = nextProps.fallback; + var _primaryChildFragment2 = createFiberFromFragment( + // It shouldn't matter what the pending props are because we aren't + // going to render this fragment. + null, + mode, + NoWork, + null + ); + _primaryChildFragment2.effectTag |= Placement; + _primaryChildFragment2.child = _currentPrimaryChild; + _currentPrimaryChild.return = _primaryChildFragment2; + // Create a fragment from the fallback children, too. + var _fallbackChildFragment2 = (_primaryChildFragment2.sibling = createFiberFromFragment( + _nextFallbackChildren2, + mode, + renderExpirationTime, + null + )); + _fallbackChildFragment2.effectTag |= Placement; + child = _primaryChildFragment2; + _primaryChildFragment2.childExpirationTime = NoWork; + // Skip the primary children, and continue working on the + // fallback children. + next = _fallbackChildFragment2; + child.return = next.return = workInProgress; + } else { + // Still haven't timed out. Continue rendering the children, like we + // normally do. + var _nextPrimaryChildren2 = nextProps.children; + next = child = reconcileChildFibers( + workInProgress, + _currentPrimaryChild, + _nextPrimaryChildren2, + renderExpirationTime + ); + } } } - // If the `children` prop is a function, treat it like a render prop. - // TODO: This is temporary until we finalize a lower level API. - var children = nextProps.children; - var nextChildren = void 0; - if (typeof children === "function") { - nextChildren = children(nextDidTimeout); - } else { - nextChildren = nextDidTimeout ? nextProps.fallback : children; - } - - if (current$$1 !== null && nextDidTimeout !== workInProgress.memoizedState) { - // We're about to switch from the placeholder children to the normal - // children, or vice versa. These are two different conceptual sets that - // happen to be stored in the same set. Call this special function to - // force the new set not to match with the current set. - // TODO: The proper way to model this is by storing each set separately. - forceUnmountCurrentAndReconcile( - current$$1, - workInProgress, - nextChildren, - renderExpirationTime - ); - } else { - reconcileChildren( - current$$1, - workInProgress, - nextChildren, - renderExpirationTime - ); - } - workInProgress.memoizedProps = nextProps; - workInProgress.memoizedState = nextDidTimeout; - return workInProgress.child; + workInProgress.memoizedState = nextState; + workInProgress.child = child; + return next; } function updatePortalComponent( @@ -11002,7 +11949,6 @@ function updatePortalComponent( nextChildren, renderExpirationTime ); - memoizeProps(workInProgress, nextChildren); } else { reconcileChildren( current$$1, @@ -11010,7 +11956,6 @@ function updatePortalComponent( nextChildren, renderExpirationTime ); - memoizeProps(workInProgress, nextChildren); } return workInProgress.child; } @@ -11027,7 +11972,6 @@ function updateContextProvider( var oldProps = workInProgress.memoizedProps; var newValue = newProps.value; - workInProgress.memoizedProps = newProps; { var providerPropTypes = workInProgress.type.propTypes; @@ -11096,13 +12040,18 @@ function updateContextConsumer( // in DEV mode if this property exists or not and warn if it does not. { if (context._context === undefined) { - if (!hasWarnedAboutUsingContextAsConsumer) { - hasWarnedAboutUsingContextAsConsumer = true; - warning$1( - false, - "Rendering directly is not supported and will be removed in " + - "a future major release. Did you mean to render instead?" - ); + // This may be because it's a Context (rather than a Consumer). + // Or it may be because it's older React where they're the same thing. + // We only want to warn if we're sure it's a new React. + if (context !== context.Consumer) { + if (!hasWarnedAboutUsingContextAsConsumer) { + hasWarnedAboutUsingContextAsConsumer = true; + warning$1( + false, + "Rendering directly is not supported and will be removed in " + + "a future major release. Did you mean to render instead?" + ); + } } } else { context = context._context; @@ -11141,7 +12090,6 @@ function updateContextConsumer( newChildren, renderExpirationTime ); - workInProgress.memoizedProps = newProps; return workInProgress.child; } @@ -11183,10 +12131,7 @@ function bailoutOnAlreadyFinishedWork( // Check if the children have any pending work. var childExpirationTime = workInProgress.childExpirationTime; - if ( - childExpirationTime === NoWork || - childExpirationTime > renderExpirationTime - ) { + if (childExpirationTime < renderExpirationTime) { // The children don't have any work either. We can skip them. // TODO: Once we add back resuming, we should check if the children are // a work-in-progress set. If so, we need to transfer their effects. @@ -11199,17 +12144,6 @@ function bailoutOnAlreadyFinishedWork( } } -// TODO: Delete memoizeProps/State and move to reconcile/bailout instead -function memoizeProps(workInProgress, nextProps) { - workInProgress.memoizedProps = nextProps; -} - -function memoizeState(workInProgress, nextState) { - workInProgress.memoizedState = nextState; - // Don't reset the updateQueue, in case there are pending updates. Resetting - // is handled by processUpdateQueue. -} - function beginWork(current$$1, workInProgress, renderExpirationTime) { var updateExpirationTime = workInProgress.expirationTime; @@ -11219,8 +12153,7 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { if ( oldProps === newProps && !hasContextChanged() && - (updateExpirationTime === NoWork || - updateExpirationTime > renderExpirationTime) + updateExpirationTime < renderExpirationTime ) { // This fiber does not have any pending work. Bailout without entering // the begin phase. There's still some bookkeeping we that needs to be done @@ -11240,14 +12173,6 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { } break; } - case ClassComponentLazy: { - var thenable = workInProgress.type; - var _Component = getResultFromResolvedThenable(thenable); - if (isContextProvider(_Component)) { - pushContextProvider(workInProgress); - } - break; - } case HostPortal: pushHostContainer( workInProgress, @@ -11264,6 +12189,46 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { workInProgress.effectTag |= Update; } break; + case SuspenseComponent: { + var state = workInProgress.memoizedState; + var didTimeout = state !== null && state.didTimeout; + if (didTimeout) { + // If this boundary is currently timed out, we need to decide + // whether to retry the primary children, or to skip over it and + // go straight to the fallback. Check the priority of the primary + var primaryChildFragment = workInProgress.child; + var primaryChildExpirationTime = + primaryChildFragment.childExpirationTime; + if ( + primaryChildExpirationTime !== NoWork && + primaryChildExpirationTime >= renderExpirationTime + ) { + // The primary children have pending work. Use the normal path + // to attempt to render the primary children again. + return updateSuspenseComponent( + current$$1, + workInProgress, + renderExpirationTime + ); + } else { + // The primary children do not have pending work with sufficient + // priority. Bailout. + var child = bailoutOnAlreadyFinishedWork( + current$$1, + workInProgress, + renderExpirationTime + ); + if (child !== null) { + // The fallback children have pending work. Skip over the + // primary children and work on the fallback. + return child.sibling; + } else { + return null; + } + } + } + break; + } } return bailoutOnAlreadyFinishedWork( current$$1, @@ -11278,65 +12243,54 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { switch (workInProgress.tag) { case IndeterminateComponent: { - var _Component2 = workInProgress.type; + var elementType = workInProgress.elementType; return mountIndeterminateComponent( current$$1, workInProgress, - _Component2, + elementType, + renderExpirationTime + ); + } + case LazyComponent: { + var _elementType = workInProgress.elementType; + return mountLazyComponent( + current$$1, + workInProgress, + _elementType, updateExpirationTime, renderExpirationTime ); } case FunctionComponent: { - var _Component3 = workInProgress.type; + var _Component = workInProgress.type; var unresolvedProps = workInProgress.pendingProps; + var resolvedProps = + workInProgress.elementType === _Component + ? unresolvedProps + : resolveDefaultProps(_Component, unresolvedProps); return updateFunctionComponent( current$$1, workInProgress, - _Component3, - unresolvedProps, + _Component, + resolvedProps, renderExpirationTime ); } - case FunctionComponentLazy: { - var _thenable = workInProgress.type; - var _Component4 = getResultFromResolvedThenable(_thenable); - var _unresolvedProps = workInProgress.pendingProps; - var child = updateFunctionComponent( - current$$1, - workInProgress, - _Component4, - resolveDefaultProps(_Component4, _unresolvedProps), - renderExpirationTime - ); - workInProgress.memoizedProps = _unresolvedProps; - return child; - } case ClassComponent: { - var _Component5 = workInProgress.type; - var _unresolvedProps2 = workInProgress.pendingProps; + var _Component2 = workInProgress.type; + var _unresolvedProps = workInProgress.pendingProps; + var _resolvedProps = + workInProgress.elementType === _Component2 + ? _unresolvedProps + : resolveDefaultProps(_Component2, _unresolvedProps); return updateClassComponent( current$$1, workInProgress, - _Component5, - _unresolvedProps2, + _Component2, + _resolvedProps, renderExpirationTime ); } - case ClassComponentLazy: { - var _thenable2 = workInProgress.type; - var _Component6 = getResultFromResolvedThenable(_thenable2); - var _unresolvedProps3 = workInProgress.pendingProps; - var _child = updateClassComponent( - current$$1, - workInProgress, - _Component6, - resolveDefaultProps(_Component6, _unresolvedProps3), - renderExpirationTime - ); - workInProgress.memoizedProps = _unresolvedProps3; - return _child; - } case HostRoot: return updateHostRoot(current$$1, workInProgress, renderExpirationTime); case HostComponent: @@ -11361,28 +12315,19 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { ); case ForwardRef: { var type = workInProgress.type; + var _unresolvedProps2 = workInProgress.pendingProps; + var _resolvedProps2 = + workInProgress.elementType === type + ? _unresolvedProps2 + : resolveDefaultProps(type, _unresolvedProps2); return updateForwardRef( current$$1, workInProgress, type, - workInProgress.pendingProps, + _resolvedProps2, renderExpirationTime ); } - case ForwardRefLazy: { - var _thenable3 = workInProgress.type; - var _Component7 = getResultFromResolvedThenable(_thenable3); - var _unresolvedProps4 = workInProgress.pendingProps; - var _child2 = updateForwardRef( - current$$1, - workInProgress, - _Component7, - resolveDefaultProps(_Component7, _unresolvedProps4), - renderExpirationTime - ); - workInProgress.memoizedProps = _unresolvedProps4; - return _child2; - } case Fragment: return updateFragment(current$$1, workInProgress, renderExpirationTime); case Mode: @@ -11401,31 +12346,43 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { workInProgress, renderExpirationTime ); - case PureComponent: { + case MemoComponent: { var _type = workInProgress.type; - return updatePureComponent( + var _unresolvedProps3 = workInProgress.pendingProps; + var _resolvedProps3 = resolveDefaultProps(_type.type, _unresolvedProps3); + return updateMemoComponent( current$$1, workInProgress, _type, + _resolvedProps3, + updateExpirationTime, + renderExpirationTime + ); + } + case SimpleMemoComponent: { + return updateSimpleMemoComponent( + current$$1, + workInProgress, + workInProgress.type, workInProgress.pendingProps, updateExpirationTime, renderExpirationTime ); } - case PureComponentLazy: { - var _thenable4 = workInProgress.type; - var _Component8 = getResultFromResolvedThenable(_thenable4); - var _unresolvedProps5 = workInProgress.pendingProps; - var _child3 = updatePureComponent( + case IncompleteClassComponent: { + var _Component3 = workInProgress.type; + var _unresolvedProps4 = workInProgress.pendingProps; + var _resolvedProps4 = + workInProgress.elementType === _Component3 + ? _unresolvedProps4 + : resolveDefaultProps(_Component3, _unresolvedProps4); + return mountIncompleteClassComponent( current$$1, workInProgress, - _Component8, - resolveDefaultProps(_Component8, _unresolvedProps5), - updateExpirationTime, + _Component3, + _resolvedProps4, renderExpirationTime ); - workInProgress.memoizedProps = _unresolvedProps5; - return _child3; } default: invariant( @@ -11446,42 +12403,48 @@ function markRef$1(workInProgress) { workInProgress.effectTag |= Ref; } -function appendAllChildren(parent, workInProgress) { - // We only have the top Fiber that was created but we need recurse down its - // children to find all the terminal nodes. - var node = workInProgress.child; - while (node !== null) { - if (node.tag === HostComponent || node.tag === HostText) { - appendInitialChild(parent, node.stateNode); - } else if (node.tag === HostPortal) { - // If we have a portal child, then we don't want to traverse - // down its children. Instead, we'll get insertions from each child in - // the portal directly. - } else if (node.child !== null) { - node.child.return = node; - node = node.child; - continue; - } - if (node === workInProgress) { - return; - } - while (node.sibling === null) { - if (node.return === null || node.return === workInProgress) { - return; - } - node = node.return; - } - node.sibling.return = node.return; - node = node.sibling; - } -} - +var appendAllChildren = void 0; var updateHostContainer = void 0; var updateHostComponent$1 = void 0; var updateHostText$1 = void 0; if (supportsMutation) { // Mutation mode + appendAllChildren = function( + parent, + workInProgress, + needsVisibilityToggle, + isHidden + ) { + // We only have the top Fiber that was created but we need recurse down its + // children to find all the terminal nodes. + var node = workInProgress.child; + while (node !== null) { + if (node.tag === HostComponent || node.tag === HostText) { + appendInitialChild(parent, node.stateNode); + } else if (node.tag === HostPortal) { + // If we have a portal child, then we don't want to traverse + // down its children. Instead, we'll get insertions from each child in + // the portal directly. + } else if (node.child !== null) { + node.child.return = node; + node = node.child; + continue; + } + if (node === workInProgress) { + return; + } + while (node.sibling === null) { + if (node.return === null || node.return === workInProgress) { + return; + } + node = node.return; + } + node.sibling.return = node.return; + node = node.sibling; + } + }; + updateHostContainer = function(workInProgress) { // Noop }; @@ -11535,26 +12498,202 @@ if (supportsMutation) { } else if (supportsPersistence) { // Persistent host tree mode - // An unfortunate fork of appendAllChildren because we have two different parent types. - var appendAllChildrenToContainer = function( - containerChildSet, - workInProgress + appendAllChildren = function( + parent, + workInProgress, + needsVisibilityToggle, + isHidden ) { // We only have the top Fiber that was created but we need recurse down its // children to find all the terminal nodes. var node = workInProgress.child; while (node !== null) { - if (node.tag === HostComponent || node.tag === HostText) { - appendChildToContainerChildSet(containerChildSet, node.stateNode); + // eslint-disable-next-line no-labels + branches: if (node.tag === HostComponent) { + var instance = node.stateNode; + if (needsVisibilityToggle) { + var props = node.memoizedProps; + var type = node.type; + if (isHidden) { + // This child is inside a timed out tree. Hide it. + instance = cloneHiddenInstance(instance, type, props, node); + } else { + // This child was previously inside a timed out tree. If it was not + // updated during this render, it may need to be unhidden. Clone + // again to be sure. + instance = cloneUnhiddenInstance(instance, type, props, node); + } + node.stateNode = instance; + } + appendInitialChild(parent, instance); + } else if (node.tag === HostText) { + var _instance = node.stateNode; + if (needsVisibilityToggle) { + var text = node.memoizedProps; + var rootContainerInstance = getRootHostContainer(); + var currentHostContext = getHostContext(); + if (isHidden) { + _instance = createHiddenTextInstance( + text, + rootContainerInstance, + currentHostContext, + workInProgress + ); + } else { + _instance = createTextInstance( + text, + rootContainerInstance, + currentHostContext, + workInProgress + ); + } + node.stateNode = _instance; + } + appendInitialChild(parent, _instance); } else if (node.tag === HostPortal) { // If we have a portal child, then we don't want to traverse // down its children. Instead, we'll get insertions from each child in // the portal directly. + } else if (node.tag === SuspenseComponent) { + var current = node.alternate; + if (current !== null) { + var oldState = current.memoizedState; + var newState = node.memoizedState; + var oldIsHidden = oldState !== null && oldState.didTimeout; + var newIsHidden = newState !== null && newState.didTimeout; + if (oldIsHidden !== newIsHidden) { + // The placeholder either just timed out or switched back to the normal + // children after having previously timed out. Toggle the visibility of + // the direct host children. + var primaryChildParent = newIsHidden ? node.child : node; + if (primaryChildParent !== null) { + appendAllChildren(parent, primaryChildParent, true, newIsHidden); + } + // eslint-disable-next-line no-labels + break branches; + } + } + if (node.child !== null) { + // Continue traversing like normal + node.child.return = node; + node = node.child; + continue; + } } else if (node.child !== null) { node.child.return = node; node = node.child; continue; } + // $FlowFixMe This is correct but Flow is confused by the labeled break. + node = node; + if (node === workInProgress) { + return; + } + while (node.sibling === null) { + if (node.return === null || node.return === workInProgress) { + return; + } + node = node.return; + } + node.sibling.return = node.return; + node = node.sibling; + } + }; + + // An unfortunate fork of appendAllChildren because we have two different parent types. + var appendAllChildrenToContainer = function( + containerChildSet, + workInProgress, + needsVisibilityToggle, + isHidden + ) { + // We only have the top Fiber that was created but we need recurse down its + // children to find all the terminal nodes. + var node = workInProgress.child; + while (node !== null) { + // eslint-disable-next-line no-labels + branches: if (node.tag === HostComponent) { + var instance = node.stateNode; + if (needsVisibilityToggle) { + var props = node.memoizedProps; + var type = node.type; + if (isHidden) { + // This child is inside a timed out tree. Hide it. + instance = cloneHiddenInstance(instance, type, props, node); + } else { + // This child was previously inside a timed out tree. If it was not + // updated during this render, it may need to be unhidden. Clone + // again to be sure. + instance = cloneUnhiddenInstance(instance, type, props, node); + } + node.stateNode = instance; + } + appendChildToContainerChildSet(containerChildSet, instance); + } else if (node.tag === HostText) { + var _instance2 = node.stateNode; + if (needsVisibilityToggle) { + var text = node.memoizedProps; + var rootContainerInstance = getRootHostContainer(); + var currentHostContext = getHostContext(); + if (isHidden) { + _instance2 = createHiddenTextInstance( + text, + rootContainerInstance, + currentHostContext, + workInProgress + ); + } else { + _instance2 = createTextInstance( + text, + rootContainerInstance, + currentHostContext, + workInProgress + ); + } + node.stateNode = _instance2; + } + appendChildToContainerChildSet(containerChildSet, _instance2); + } else if (node.tag === HostPortal) { + // If we have a portal child, then we don't want to traverse + // down its children. Instead, we'll get insertions from each child in + // the portal directly. + } else if (node.tag === SuspenseComponent) { + var current = node.alternate; + if (current !== null) { + var oldState = current.memoizedState; + var newState = node.memoizedState; + var oldIsHidden = oldState !== null && oldState.didTimeout; + var newIsHidden = newState !== null && newState.didTimeout; + if (oldIsHidden !== newIsHidden) { + // The placeholder either just timed out or switched back to the normal + // children after having previously timed out. Toggle the visibility of + // the direct host children. + var primaryChildParent = newIsHidden ? node.child : node; + if (primaryChildParent !== null) { + appendAllChildrenToContainer( + containerChildSet, + primaryChildParent, + true, + newIsHidden + ); + } + // eslint-disable-next-line no-labels + break branches; + } + } + if (node.child !== null) { + // Continue traversing like normal + node.child.return = node; + node = node.child; + continue; + } + } else if (node.child !== null) { + node.child.return = node; + node = node.child; + continue; + } + // $FlowFixMe This is correct but Flow is confused by the labeled break. + node = node; if (node === workInProgress) { return; } @@ -11577,7 +12716,7 @@ if (supportsMutation) { var container = portalOrRoot.containerInfo; var newChildSet = createContainerChildSet(container); // If children might have changed, we have to add them all to the set. - appendAllChildrenToContainer(newChildSet, workInProgress); + appendAllChildrenToContainer(newChildSet, workInProgress, false, false); portalOrRoot.pendingChildren = newChildSet; // Schedule an update on the container to swap out the container. markUpdate(workInProgress); @@ -11650,7 +12789,7 @@ if (supportsMutation) { markUpdate(workInProgress); } else { // If children might have changed, we have to add them all to the set. - appendAllChildren(newInstance, workInProgress); + appendAllChildren(newInstance, workInProgress, false, false); } }; updateHostText$1 = function(current, workInProgress, oldText, newText) { @@ -11692,8 +12831,12 @@ function completeWork(current, workInProgress, renderExpirationTime) { var newProps = workInProgress.pendingProps; switch (workInProgress.tag) { + case IndeterminateComponent: + break; + case LazyComponent: + break; + case SimpleMemoComponent: case FunctionComponent: - case FunctionComponentLazy: break; case ClassComponent: { var Component = workInProgress.type; @@ -11702,13 +12845,6 @@ function completeWork(current, workInProgress, renderExpirationTime) { } break; } - case ClassComponentLazy: { - var _Component = getResultFromResolvedThenable(workInProgress.type); - if (isContextProvider(_Component)) { - popContext(workInProgress); - } - break; - } case HostRoot: { popHostContainer(workInProgress); popTopLevelContextObject(workInProgress); @@ -11784,7 +12920,7 @@ function completeWork(current, workInProgress, renderExpirationTime) { workInProgress ); - appendAllChildren(instance, workInProgress); + appendAllChildren(instance, workInProgress, false, false); // Certain renderers require commit-time effects for initial mount. // (eg DOM renderer supports auto-focus for certain elements). @@ -11845,10 +12981,19 @@ function completeWork(current, workInProgress, renderExpirationTime) { break; } case ForwardRef: - case ForwardRefLazy: break; - case SuspenseComponent: + case SuspenseComponent: { + var nextState = workInProgress.memoizedState; + var prevState = current !== null ? current.memoizedState : null; + var nextDidTimeout = nextState !== null && nextState.didTimeout; + var prevDidTimeout = prevState !== null && prevState.didTimeout; + if (nextDidTimeout !== prevDidTimeout) { + // If this render commits, and it switches between the normal state + // and the timed-out state, schedule an effect. + workInProgress.effectTag |= Update; + } break; + } case Fragment: break; case Mode: @@ -11865,18 +13010,17 @@ function completeWork(current, workInProgress, renderExpirationTime) { break; case ContextConsumer: break; - case PureComponent: - case PureComponentLazy: + case MemoComponent: break; - // Error cases - case IndeterminateComponent: - invariant( - false, - "An indeterminate component should have become determinate before " + - "completing. This error is likely caused by a bug in React. Please " + - "file an issue." - ); - // eslint-disable-next-line no-fallthrough + case IncompleteClassComponent: { + // Same as class component case. I put it down here so that the tags are + // sequential to ensure this switch is compiled to a jump table. + var _Component = workInProgress.type; + if (isContextProvider(_Component)) { + popContext(workInProgress); + } + break; + } default: invariant( false, @@ -11888,6 +13032,17 @@ function completeWork(current, workInProgress, renderExpirationTime) { return null; } +function shouldCaptureSuspense(current, workInProgress) { + // In order to capture, the Suspense component must have a fallback prop. + if (workInProgress.memoizedProps.fallback === undefined) { + return false; + } + // If it was the primary children that just suspended, capture and render the + // fallback. Otherwise, don't capture and bubble to the next boundary. + var nextState = workInProgress.memoizedState; + return nextState === null || !nextState.didTimeout; +} + // Module provided by RN: /** * Intercept lifecycle errors and ensure they are shown with the correct stack @@ -12004,8 +13159,6 @@ function logCapturedError(capturedError) { } } -var emptyObject$1 = {}; - var didWarnAboutUndefinedSnapshotBeforeUpdate = null; { didWarnAboutUndefinedSnapshotBeforeUpdate = new Set(); @@ -12090,10 +13243,25 @@ function safelyDetachRef(current$$1) { } } +function safelyCallDestroy(current$$1, destroy) { + { + invokeGuardedCallback(null, destroy, null); + if (hasCaughtError()) { + var error = clearCaughtError(); + captureCommitPhaseError(current$$1, error); + } + } +} + function commitBeforeMutationLifeCycles(current$$1, finishedWork) { switch (finishedWork.tag) { - case ClassComponent: - case ClassComponentLazy: { + case FunctionComponent: + case ForwardRef: + case SimpleMemoComponent: { + commitHookEffectList(UnmountSnapshot, NoEffect$1, finishedWork); + return; + } + case ClassComponent: { if (finishedWork.effectTag & Snapshot) { if (current$$1 !== null) { var prevProps = current$$1.memoizedProps; @@ -12125,6 +13293,7 @@ function commitBeforeMutationLifeCycles(current$$1, finishedWork) { case HostComponent: case HostText: case HostPortal: + case IncompleteClassComponent: // Nothing to do for these component types return; default: { @@ -12137,6 +13306,37 @@ function commitBeforeMutationLifeCycles(current$$1, finishedWork) { } } +function commitHookEffectList(unmountTag, mountTag, finishedWork) { + var updateQueue = finishedWork.updateQueue; + var lastEffect = updateQueue !== null ? updateQueue.lastEffect : null; + if (lastEffect !== null) { + var firstEffect = lastEffect.next; + var effect = firstEffect; + do { + if ((effect.tag & unmountTag) !== NoEffect$1) { + // Unmount + var destroy = effect.destroy; + effect.destroy = null; + if (destroy !== null) { + destroy(); + } + } + if ((effect.tag & mountTag) !== NoEffect$1) { + // Mount + var create = effect.create; + var _destroy = create(); + effect.destroy = typeof _destroy === "function" ? _destroy : null; + } + effect = effect.next; + } while (effect !== firstEffect); + } +} + +function commitPassiveHookEffects(finishedWork) { + commitHookEffectList(UnmountPassive, NoEffect$1, finishedWork); + commitHookEffectList(NoEffect$1, MountPassive, finishedWork); +} + function commitLifeCycles( finishedRoot, current$$1, @@ -12144,8 +13344,13 @@ function commitLifeCycles( committedExpirationTime ) { switch (finishedWork.tag) { - case ClassComponent: - case ClassComponentLazy: { + case FunctionComponent: + case ForwardRef: + case SimpleMemoComponent: { + commitHookEffectList(UnmountLayout, MountLayout, finishedWork); + break; + } + case ClassComponent: { var instance = finishedWork.stateNode; if (finishedWork.effectTag & Update) { if (current$$1 === null) { @@ -12191,7 +13396,6 @@ function commitLifeCycles( _instance = getPublicInstance(finishedWork.child.stateNode); break; case ClassComponent: - case ClassComponentLazy: _instance = finishedWork.child.stateNode; break; } @@ -12256,22 +13460,49 @@ function commitLifeCycles( return; } case SuspenseComponent: { - if ((finishedWork.mode & StrictMode) === NoEffect) { - // In loose mode, a placeholder times out by scheduling a synchronous - // update in the commit phase. Use `updateQueue` field to signal that - // the Timeout needs to switch to the placeholder. We don't need an - // entire queue. Any non-null value works. - // $FlowFixMe - Intentionally using a value other than an UpdateQueue. - finishedWork.updateQueue = emptyObject$1; + if (finishedWork.effectTag & Callback) { + // In non-strict mode, a suspense boundary times out by commiting + // twice: first, by committing the children in an inconsistent state, + // then hiding them and showing the fallback children in a subsequent + var _newState = { + alreadyCaptured: true, + didTimeout: false, + timedOutAt: NoWork + }; + finishedWork.memoizedState = _newState; + flushPassiveEffects(); scheduleWork(finishedWork, Sync); + return; + } + var oldState = current$$1 !== null ? current$$1.memoizedState : null; + var newState = finishedWork.memoizedState; + var oldDidTimeout = oldState !== null ? oldState.didTimeout : false; + + var newDidTimeout = void 0; + var primaryChildParent = finishedWork; + if (newState === null) { + newDidTimeout = false; } else { - // In strict mode, the Update effect is used to record the time at - // which the placeholder timed out. - var currentTime = requestCurrentTime(); - finishedWork.stateNode = { timedOutAt: currentTime }; + newDidTimeout = newState.didTimeout; + if (newDidTimeout) { + primaryChildParent = finishedWork.child; + newState.alreadyCaptured = false; + if (newState.timedOutAt === NoWork) { + // If the children had not already timed out, record the time. + // This is used to compute the elapsed time during subsequent + // attempts to render the children. + newState.timedOutAt = requestCurrentTime(); + } + } + } + + if (newDidTimeout !== oldDidTimeout && primaryChildParent !== null) { + hideOrUnhideAllChildren(primaryChildParent, newDidTimeout); } return; } + case IncompleteClassComponent: + break; default: { invariant( false, @@ -12282,6 +13513,45 @@ function commitLifeCycles( } } +function hideOrUnhideAllChildren(finishedWork, isHidden) { + if (supportsMutation) { + // We only have the top Fiber that was inserted but we need recurse down its + var node = finishedWork; + while (true) { + if (node.tag === HostComponent) { + var instance = node.stateNode; + if (isHidden) { + hideInstance(instance); + } else { + unhideInstance(node.stateNode, node.memoizedProps); + } + } else if (node.tag === HostText) { + var _instance3 = node.stateNode; + if (isHidden) { + hideTextInstance(_instance3); + } else { + unhideTextInstance(_instance3, node.memoizedProps); + } + } else if (node.child !== null) { + node.child.return = node; + node = node.child; + continue; + } + if (node === finishedWork) { + return; + } + while (node.sibling === null) { + if (node.return === null || node.return === finishedWork) { + return; + } + node = node.return; + } + node.sibling.return = node.return; + node = node.sibling; + } + } +} + function commitAttachRef(finishedWork) { var ref = finishedWork.ref; if (ref !== null) { @@ -12332,8 +13602,28 @@ function commitUnmount(current$$1) { onCommitUnmount(current$$1); switch (current$$1.tag) { - case ClassComponent: - case ClassComponentLazy: { + case FunctionComponent: + case ForwardRef: + case MemoComponent: + case SimpleMemoComponent: { + var updateQueue = current$$1.updateQueue; + if (updateQueue !== null) { + var lastEffect = updateQueue.lastEffect; + if (lastEffect !== null) { + var firstEffect = lastEffect.next; + var effect = firstEffect; + do { + var destroy = effect.destroy; + if (destroy !== null) { + safelyCallDestroy(current$$1, destroy); + } + effect = effect.next; + } while (effect !== firstEffect); + } + } + break; + } + case ClassComponent: { safelyDetachRef(current$$1); var instance = current$$1.stateNode; if (typeof instance.componentWillUnmount === "function") { @@ -12424,8 +13714,7 @@ function commitContainer(finishedWork) { } switch (finishedWork.tag) { - case ClassComponent: - case ClassComponentLazy: { + case ClassComponent: { return; } case HostComponent: { @@ -12700,13 +13989,29 @@ function commitDeletion(current$$1) { function commitWork(current$$1, finishedWork) { if (!supportsMutation) { + switch (finishedWork.tag) { + case FunctionComponent: + case ForwardRef: + case MemoComponent: + case SimpleMemoComponent: { + commitHookEffectList(UnmountMutation, MountMutation, finishedWork); + return; + } + } + commitContainer(finishedWork); return; } switch (finishedWork.tag) { - case ClassComponent: - case ClassComponentLazy: { + case FunctionComponent: + case ForwardRef: + case MemoComponent: + case SimpleMemoComponent: { + commitHookEffectList(UnmountMutation, MountMutation, finishedWork); + return; + } + case ClassComponent: { return; } case HostComponent: { @@ -12760,6 +14065,9 @@ function commitWork(current$$1, finishedWork) { case SuspenseComponent: { return; } + case IncompleteClassComponent: { + return; + } default: { invariant( false, @@ -12777,10 +14085,6 @@ function commitResetTextContent(current$$1) { resetTextContent(current$$1.stateNode); } -function NoopComponent() { - return null; -} - function createRootErrorUpdate(fiber, errorInfo, expirationTime) { var update = createUpdate(expirationTime); // Unmount the root by rendering null. @@ -12874,22 +14178,17 @@ function throwException( var startTimeMs = -1; do { if (_workInProgress.tag === SuspenseComponent) { - var current = _workInProgress.alternate; - if ( - current !== null && - current.memoizedState === true && - current.stateNode !== null - ) { - // Reached a placeholder that already timed out. Each timed out - // placeholder acts as the root of a new suspense boundary. - - // Use the time at which the placeholder timed out as the start time - // for the current render. - var timedOutAt = current.stateNode.timedOutAt; - startTimeMs = expirationTimeToMs(timedOutAt); - - // Do not search any further. - break; + var current$$1 = _workInProgress.alternate; + if (current$$1 !== null) { + var currentState = current$$1.memoizedState; + if (currentState !== null && currentState.didTimeout) { + // Reached a boundary that already timed out. Do not search + // any further. + var timedOutAt = currentState.timedOutAt; + startTimeMs = expirationTimeToMs(timedOutAt); + // Do not search any further. + break; + } } var timeoutPropMs = _workInProgress.pendingProps.maxDuration; if (typeof timeoutPropMs === "number") { @@ -12909,129 +14208,127 @@ function throwException( // Schedule the nearest Suspense to re-render the timed out view. _workInProgress = returnFiber; do { - if (_workInProgress.tag === SuspenseComponent) { - var didTimeout = _workInProgress.memoizedState; - if (!didTimeout) { - // Found the nearest boundary. + if ( + _workInProgress.tag === SuspenseComponent && + shouldCaptureSuspense(_workInProgress.alternate, _workInProgress) + ) { + // Found the nearest boundary. - // If the boundary is not in concurrent mode, we should not suspend, and - // likewise, when the promise resolves, we should ping synchronously. - var pingTime = - (_workInProgress.mode & ConcurrentMode) === NoEffect - ? Sync - : renderExpirationTime; + // If the boundary is not in concurrent mode, we should not suspend, and + // likewise, when the promise resolves, we should ping synchronously. + var pingTime = + (_workInProgress.mode & ConcurrentMode) === NoEffect + ? Sync + : renderExpirationTime; - // Attach a listener to the promise to "ping" the root and retry. - var onResolveOrReject = retrySuspendedRoot.bind( - null, - root, - _workInProgress, - pingTime + // Attach a listener to the promise to "ping" the root and retry. + var onResolveOrReject = retrySuspendedRoot.bind( + null, + root, + _workInProgress, + sourceFiber, + pingTime + ); + if (enableSchedulerTracing) { + onResolveOrReject = tracing.unstable_wrap(onResolveOrReject); + } + thenable.then(onResolveOrReject, onResolveOrReject); + + // If the boundary is outside of concurrent mode, we should *not* + // suspend the commit. Pretend as if the suspended component rendered + // null and keep rendering. In the commit phase, we'll schedule a + // subsequent synchronous update to re-render the Suspense. + // + // Note: It doesn't matter whether the component that suspended was + // inside a concurrent mode tree. If the Suspense is outside of it, we + // should *not* suspend the commit. + if ((_workInProgress.mode & ConcurrentMode) === NoEffect) { + _workInProgress.effectTag |= Callback; + + // Unmount the source fiber's children + var nextChildren = null; + reconcileChildren( + sourceFiber.alternate, + sourceFiber, + nextChildren, + renderExpirationTime ); - if (enableSchedulerTracing) { - onResolveOrReject = tracing.unstable_wrap(onResolveOrReject); - } - thenable.then(onResolveOrReject, onResolveOrReject); + sourceFiber.effectTag &= ~Incomplete; - // If the boundary is outside of strict mode, we should *not* suspend - // the commit. Pretend as if the suspended component rendered null and - // keep rendering. In the commit phase, we'll schedule a subsequent - // synchronous update to re-render the Suspense. - // - // Note: It doesn't matter whether the component that suspended was - // inside a strict mode tree. If the Suspense is outside of it, we - // should *not* suspend the commit. - if ((_workInProgress.mode & StrictMode) === NoEffect) { - _workInProgress.effectTag |= Update; + // 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. + sourceFiber.effectTag &= ~LifecycleEffectMask; - // Unmount the source fiber's children - var nextChildren = null; - reconcileChildren( - sourceFiber.alternate, - sourceFiber, - nextChildren, - renderExpirationTime - ); - sourceFiber.effectTag &= ~Incomplete; - if (sourceFiber.tag === IndeterminateComponent) { - // Let's just assume it's a function component. This fiber will - // be unmounted in the immediate next commit, anyway. - sourceFiber.tag = FunctionComponent; + if (sourceFiber.tag === ClassComponent) { + var _current = sourceFiber.alternate; + if (_current === null) { + // This is a new mount. Change the tag so it's not mistaken for a + // completed class component. For example, we should not call + // componentWillUnmount if it is deleted. + sourceFiber.tag = IncompleteClassComponent; } - - 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. - sourceFiber.effectTag &= ~LifecycleEffectMask; - if (sourceFiber.alternate === null) { - // We're about to mount a class component that doesn't have an - // instance. Turn this into a dummy function component instead, - // to prevent type errors. This is a bit weird but it's an edge - // case and we're about to synchronously delete this - // component, anyway. - sourceFiber.tag = FunctionComponent; - sourceFiber.type = NoopComponent; - } - } - - // Exit without suspending. - return; } - // Confirmed that the boundary is in a strict mode tree. Continue with - // the normal suspend path. - - var absoluteTimeoutMs = void 0; - if (earliestTimeoutMs === -1) { - // If no explicit threshold is given, default to an abitrarily large - // value. The actual size doesn't matter because the threshold for the - // whole tree will be clamped to the expiration time. - absoluteTimeoutMs = maxSigned31BitInt; - } else { - if (startTimeMs === -1) { - // This suspend happened outside of any already timed-out - // placeholders. We don't know exactly when the update was scheduled, - // but we can infer an approximate start time from the expiration - // 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 necessary, - // but we can account for this by adjusting for the Just Noticeable - // Difference. - var earliestExpirationTime = findEarliestOutstandingPriorityLevel( - root, - renderExpirationTime - ); - var earliestExpirationTimeMs = expirationTimeToMs( - earliestExpirationTime - ); - startTimeMs = earliestExpirationTimeMs - LOW_PRIORITY_EXPIRATION; - } - absoluteTimeoutMs = startTimeMs + earliestTimeoutMs; - } - - // Mark the earliest timeout in the suspended fiber's ancestor path. - // After completing the root, we'll take the largest of all the - // suspended fiber's timeouts and use it to compute a timeout for the - // whole tree. - renderDidSuspend(root, absoluteTimeoutMs, renderExpirationTime); - - _workInProgress.effectTag |= ShouldCapture; - _workInProgress.expirationTime = renderExpirationTime; + // Exit without suspending. return; } - // This boundary already captured during this render. Continue to the - // next boundary. + + // Confirmed that the boundary is in a concurrent mode tree. Continue + // with the normal suspend path. + + var absoluteTimeoutMs = void 0; + if (earliestTimeoutMs === -1) { + // If no explicit threshold is given, default to an abitrarily large + // value. The actual size doesn't matter because the threshold for the + // whole tree will be clamped to the expiration time. + absoluteTimeoutMs = maxSigned31BitInt; + } else { + if (startTimeMs === -1) { + // This suspend happened outside of any already timed-out + // placeholders. We don't know exactly when the update was + // scheduled, but we can infer an approximate start time from the + // expiration 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 necessary, but we can account for this by adjusting + // for the Just Noticeable Difference. + var earliestExpirationTime = findEarliestOutstandingPriorityLevel( + root, + renderExpirationTime + ); + var earliestExpirationTimeMs = expirationTimeToMs( + earliestExpirationTime + ); + startTimeMs = earliestExpirationTimeMs - LOW_PRIORITY_EXPIRATION; + } + absoluteTimeoutMs = startTimeMs + earliestTimeoutMs; + } + + // Mark the earliest timeout in the suspended fiber's ancestor path. + // After completing the root, we'll take the largest of all the + // suspended fiber's timeouts and use it to compute a timeout for the + // whole tree. + renderDidSuspend(root, absoluteTimeoutMs, renderExpirationTime); + + _workInProgress.effectTag |= ShouldCapture; + _workInProgress.expirationTime = renderExpirationTime; + return; } + // This boundary already captured during this render. Continue to the next + // boundary. _workInProgress = _workInProgress.return; } while (_workInProgress !== null); // No boundary was found. Fallthrough to error mode. + // TODO: Use invariant so the message is stripped in prod? value = new Error( - "An update was suspended, but no placeholder UI was provided." + (getComponentName(sourceFiber.type) || "A React component") + + " suspended while rendering, but no fallback UI was specified.\n" + + "\n" + + "Add a component higher in the tree to " + + "provide a loading indicator or placeholder to display." + + getStackByFiberInDevAndProd(sourceFiber) ); } @@ -13056,7 +14353,6 @@ function throwException( return; } case ClassComponent: - case ClassComponentLazy: // Capture and retry var errorInfo = value; var ctor = workInProgress.type; @@ -13101,28 +14397,16 @@ 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 _effectTag2 = workInProgress.effectTag; + var _effectTag = workInProgress.effectTag; invariant( - (_effectTag2 & DidCapture) === NoEffect, + (_effectTag & DidCapture) === NoEffect, "The root failed to unmount after an error. This is likely a bug in " + "React. Please file an issue." ); - workInProgress.effectTag = (_effectTag2 & ~ShouldCapture) | DidCapture; + workInProgress.effectTag = (_effectTag & ~ShouldCapture) | DidCapture; return workInProgress; } case HostComponent: { @@ -13130,9 +14414,36 @@ function unwindWork(workInProgress, renderExpirationTime) { return null; } case SuspenseComponent: { - var _effectTag3 = workInProgress.effectTag; - if (_effectTag3 & ShouldCapture) { - workInProgress.effectTag = (_effectTag3 & ~ShouldCapture) | DidCapture; + var _effectTag2 = workInProgress.effectTag; + if (_effectTag2 & ShouldCapture) { + workInProgress.effectTag = (_effectTag2 & ~ShouldCapture) | DidCapture; + // Captured a suspense effect. Set the boundary's `alreadyCaptured` + // state to true so we know to render the fallback. + var current$$1 = workInProgress.alternate; + var currentState = + current$$1 !== null ? current$$1.memoizedState : null; + var nextState = workInProgress.memoizedState; + if (nextState === null) { + // No existing state. Create a new object. + nextState = { + alreadyCaptured: true, + didTimeout: false, + timedOutAt: NoWork + }; + } else if (currentState === nextState) { + // There is an existing state but it's the same as the current tree's. + // Clone the object. + nextState = { + alreadyCaptured: true, + didTimeout: nextState.didTimeout, + timedOutAt: nextState.timedOutAt + }; + } else { + // Already have a clone, so it's safe to mutate. + nextState.alreadyCaptured = true; + } + workInProgress.memoizedState = nextState; + // Re-render the boundary. return workInProgress; } return null; @@ -13157,14 +14468,6 @@ function unwindInterruptedWork(interruptedWork) { } break; } - case ClassComponentLazy: { - var _childContextTypes = - interruptedWork.type._reactResult.childContextTypes; - if (_childContextTypes !== null && _childContextTypes !== undefined) { - popContext(interruptedWork); - } - break; - } case HostRoot: { popHostContainer(interruptedWork); popTopLevelContextObject(interruptedWork); @@ -13186,7 +14489,17 @@ function unwindInterruptedWork(interruptedWork) { } var Dispatcher = { - readContext: readContext + readContext: readContext, + useCallback: useCallback, + useContext: useContext, + useEffect: useEffect, + useImperativeMethods: useImperativeMethods, + useLayoutEffect: useLayoutEffect, + useMemo: useMemo, + useMutationEffect: useMutationEffect, + useReducer: useReducer, + useRef: useRef, + useState: useState }; var ReactCurrentOwner$2 = ReactSharedInternals.ReactCurrentOwner; @@ -13214,19 +14527,21 @@ if (enableSchedulerTracing) { didWarnSetStateChildContext = false; var didWarnStateUpdateForUnmountedComponent = {}; - warnAboutUpdateOnUnmounted = function(fiber) { + warnAboutUpdateOnUnmounted = function(fiber, isClass) { // We show the whole stack but dedupe on the top component's name because // the problematic code almost always lies inside that component. - var componentName = getComponentName(fiber.type) || "ReactClass"; + var componentName = getComponentName(fiber.type) || "ReactComponent"; if (didWarnStateUpdateForUnmountedComponent[componentName]) { return; } warningWithoutStack$1( false, - "Can't call setState (or forceUpdate) on an unmounted component. This " + + "Can't perform a React state update on an unmounted component. This " + "is a no-op, but it indicates a memory leak in your application. To " + - "fix, cancel all subscriptions and asynchronous tasks in the " + - "componentWillUnmount method.%s", + "fix, cancel all subscriptions and asynchronous tasks in %s.%s", + isClass + ? "the componentWillUnmount method" + : "a useEffect cleanup function", getStackByFiberInDevAndProd(fiber) ); didWarnStateUpdateForUnmountedComponent[componentName] = true; @@ -13278,6 +14593,9 @@ var nextRenderDidError = false; var nextEffect = null; var isCommitting$1 = false; +var rootWithPendingPassiveEffects = null; +var passiveEffectCallbackHandle = null; +var passiveEffectCallback = null; var legacyErrorBoundariesThatAlreadyFailed = null; @@ -13335,13 +14653,6 @@ if (true && replayFailedUnitOfWorkWithInvokeGuardedCallback) { } break; } - case ClassComponentLazy: { - var _Component = getResultFromResolvedThenable(failedUnitOfWork.type); - if (isContextProvider(_Component)) { - popContext(failedUnitOfWork); - } - break; - } case HostPortal: popHostContainer(failedUnitOfWork); break; @@ -13480,8 +14791,6 @@ function commitBeforeMutationLifecycles() { commitBeforeMutationLifeCycles(current$$1, nextEffect); } - // Don't cleanup effects yet; - // This will be done by commitAllLifeCycles() nextEffect = nextEffect.nextEffect; } @@ -13518,15 +14827,48 @@ function commitAllLifeCycles(finishedRoot, committedExpirationTime) { commitAttachRef(nextEffect); } - var next = nextEffect.nextEffect; - // Ensure that we clean these up so that we don't accidentally keep them. - // I'm not actually sure this matters because we can't reset firstEffect - // and lastEffect since they're on every node, not just the effectful - // ones. So we have to clean everything as we reuse nodes anyway. - nextEffect.nextEffect = null; - // Ensure that we reset the effectTag here so that we can rely on effect - // tags to reason about the current life-cycle. - nextEffect = next; + if (effectTag & Passive) { + rootWithPendingPassiveEffects = finishedRoot; + } + + nextEffect = nextEffect.nextEffect; + } +} + +function commitPassiveEffects(root, firstEffect) { + rootWithPendingPassiveEffects = null; + passiveEffectCallbackHandle = null; + passiveEffectCallback = null; + + // Set this to true to prevent re-entrancy + var previousIsRendering = isRendering; + isRendering = true; + + var effect = firstEffect; + do { + if (effect.effectTag & Passive) { + var didError = false; + var error = void 0; + { + invokeGuardedCallback(null, commitPassiveHookEffects, null, effect); + if (hasCaughtError()) { + didError = true; + error = clearCaughtError(); + } + } + if (didError) { + captureCommitPhaseError(effect, error); + } + } + effect = effect.nextEffect; + } while (effect !== null); + + isRendering = previousIsRendering; + + // Check if work was scheduled by one of the effects + var rootExpirationTime = root.expirationTime; + if (rootExpirationTime !== NoWork) { + requestWork(root, rootExpirationTime); } } @@ -13545,6 +14887,15 @@ function markLegacyErrorBoundaryAsFailed(instance) { } } +function flushPassiveEffects() { + if (passiveEffectCallback !== null) { + scheduler.unstable_cancelCallback(passiveEffectCallbackHandle); + // We call the scheduled callback instead of commitPassiveEffects directly + // to ensure tracing works correctly. + passiveEffectCallback(); + } +} + function commitRoot(root, finishedWork) { isWorking = true; isCommitting$1 = true; @@ -13570,9 +14921,7 @@ function commitRoot(root, finishedWork) { var updateExpirationTimeBeforeCommit = finishedWork.expirationTime; var childExpirationTimeBeforeCommit = finishedWork.childExpirationTime; var earliestRemainingTimeBeforeCommit = - updateExpirationTimeBeforeCommit === NoWork || - (childExpirationTimeBeforeCommit !== NoWork && - childExpirationTimeBeforeCommit < updateExpirationTimeBeforeCommit) + childExpirationTimeBeforeCommit > updateExpirationTimeBeforeCommit ? childExpirationTimeBeforeCommit : updateExpirationTimeBeforeCommit; markCommittedPriorityLevels(root, earliestRemainingTimeBeforeCommit); @@ -13714,6 +15063,22 @@ function commitRoot(root, finishedWork) { } } + if (firstEffect !== null && rootWithPendingPassiveEffects !== null) { + // This commit included a passive effect. These do not need to fire until + // after the next paint. Schedule an callback to fire them in an async + // event. To ensure serial execution, the callback will be flushed early if + // we enter rootWithPendingPassiveEffects commit phase before then. + var callback = commitPassiveEffects.bind(null, root, firstEffect); + if (enableSchedulerTracing) { + // TODO: Avoid this extra callback by mutating the tracing ref directly, + // like we do at the beginning of commitRoot. I've opted not to do that + // here because that code is still in flux. + callback = tracing.unstable_wrap(callback); + } + passiveEffectCallbackHandle = scheduler.unstable_scheduleCallback(callback); + passiveEffectCallback = callback; + } + isCommitting$1 = false; isWorking = false; stopCommitLifeCyclesTimer(); @@ -13726,9 +15091,7 @@ function commitRoot(root, finishedWork) { var updateExpirationTimeAfterCommit = finishedWork.expirationTime; var childExpirationTimeAfterCommit = finishedWork.childExpirationTime; var earliestRemainingTimeAfterCommit = - updateExpirationTimeAfterCommit === NoWork || - (childExpirationTimeAfterCommit !== NoWork && - childExpirationTimeAfterCommit < updateExpirationTimeAfterCommit) + childExpirationTimeAfterCommit > updateExpirationTimeAfterCommit ? childExpirationTimeAfterCommit : updateExpirationTimeAfterCommit; if (earliestRemainingTimeAfterCommit === NoWork) { @@ -13771,10 +15134,7 @@ function commitRoot(root, finishedWork) { // Only decrement the pending interaction count if we're done. // If there's still work at the current priority, // That indicates that we are waiting for suspense data. - if ( - earliestRemainingTimeAfterCommit === NoWork || - scheduledExpirationTime < earliestRemainingTimeAfterCommit - ) { + if (scheduledExpirationTime > earliestRemainingTimeAfterCommit) { pendingInteractionMap.delete(scheduledExpirationTime); scheduledInteractions.forEach(function(interaction) { @@ -13830,18 +15190,10 @@ function resetChildExpirationTime(workInProgress, renderTime) { while (child !== null) { var childUpdateExpirationTime = child.expirationTime; var childChildExpirationTime = child.childExpirationTime; - if ( - newChildExpirationTime === NoWork || - (childUpdateExpirationTime !== NoWork && - childUpdateExpirationTime < newChildExpirationTime) - ) { + if (childUpdateExpirationTime > newChildExpirationTime) { newChildExpirationTime = childUpdateExpirationTime; } - if ( - newChildExpirationTime === NoWork || - (childChildExpirationTime !== NoWork && - childChildExpirationTime < newChildExpirationTime) - ) { + if (childChildExpirationTime > newChildExpirationTime) { newChildExpirationTime = childChildExpirationTime; } if (shouldBubbleActualDurations) { @@ -13857,18 +15209,10 @@ function resetChildExpirationTime(workInProgress, renderTime) { while (_child !== null) { var _childUpdateExpirationTime = _child.expirationTime; var _childChildExpirationTime = _child.childExpirationTime; - if ( - newChildExpirationTime === NoWork || - (_childUpdateExpirationTime !== NoWork && - _childUpdateExpirationTime < newChildExpirationTime) - ) { + if (_childUpdateExpirationTime > newChildExpirationTime) { newChildExpirationTime = _childUpdateExpirationTime; } - if ( - newChildExpirationTime === NoWork || - (_childChildExpirationTime !== NoWork && - _childChildExpirationTime < newChildExpirationTime) - ) { + if (_childChildExpirationTime > newChildExpirationTime) { newChildExpirationTime = _childChildExpirationTime; } _child = _child.sibling; @@ -14082,6 +15426,7 @@ function performUnitOfWork(workInProgress) { } next = beginWork(current$$1, workInProgress, nextRenderExpirationTime); + workInProgress.memoizedProps = workInProgress.pendingProps; if (workInProgress.mode & ProfileMode) { // Record the render duration assuming we didn't bailout (or error). @@ -14089,6 +15434,7 @@ function performUnitOfWork(workInProgress) { } } else { next = beginWork(current$$1, workInProgress, nextRenderExpirationTime); + workInProgress.memoizedProps = workInProgress.pendingProps; } { @@ -14122,19 +15468,22 @@ function workLoop(isYieldy) { nextUnitOfWork = performUnitOfWork(nextUnitOfWork); } } else { - // Flush asynchronous work until the deadline runs out of time. - while (nextUnitOfWork !== null && !shouldYield()) { + // Flush asynchronous work until there's a higher priority event + while (nextUnitOfWork !== null && !shouldYieldToRenderer()) { nextUnitOfWork = performUnitOfWork(nextUnitOfWork); } } } -function renderRoot(root, isYieldy, isExpired) { +function renderRoot(root, isYieldy) { invariant( !isWorking, "renderRoot was called recursively. This error is likely caused " + "by a bug in React. Please file an issue." ); + + flushPassiveEffects(); + isWorking = true; ReactCurrentOwner$2.currentDispatcher = Dispatcher; @@ -14166,7 +15515,7 @@ function renderRoot(root, isYieldy, isExpired) { scheduledInteractions, scheduledExpirationTime ) { - if (scheduledExpirationTime <= expirationTime) { + if (scheduledExpirationTime >= expirationTime) { scheduledInteractions.forEach(function(interaction) { return interactions.add(interaction); }); @@ -14218,6 +15567,9 @@ function renderRoot(root, isYieldy, isExpired) { try { workLoop(isYieldy); } catch (thrownValue) { + resetContextDependences(); + resetHooks(); + if (nextUnitOfWork === null) { // This is a fatal error. didFatal = true; @@ -14280,6 +15632,7 @@ function renderRoot(root, isYieldy, isExpired) { isWorking = false; ReactCurrentOwner$2.currentDispatcher = null; resetContextDependences(); + resetHooks(); // Yield back to main thread. if (didFatal) { @@ -14351,7 +15704,7 @@ function renderRoot(root, isYieldy, isExpired) { // similar to a suspend, but without a timeout because we're not waiting // for a promise to resolve. !root.didError && - !isExpired + isYieldy ) { root.didError = true; var _suspendedExpirationTime = (root.nextExpirationTimeToWorkOn = expirationTime); @@ -14367,7 +15720,7 @@ function renderRoot(root, isYieldy, isExpired) { } } - if (!isExpired && nextLatestAbsoluteTimeoutMs !== -1) { + if (isYieldy && nextLatestAbsoluteTimeoutMs !== -1) { // The tree was suspended. var _suspendedExpirationTime2 = expirationTime; markSuspendedPriorityLevel(root, _suspendedExpirationTime2); @@ -14409,17 +15762,12 @@ function renderRoot(root, isYieldy, isExpired) { onComplete(root, rootWorkInProgress, expirationTime); } -function dispatch(sourceFiber, value, expirationTime) { - invariant( - !isWorking || isCommitting$1, - "dispatch: Cannot dispatch during the render phase." - ); - +function captureCommitPhaseError(sourceFiber, value) { + var expirationTime = Sync; var fiber = sourceFiber.return; while (fiber !== null) { switch (fiber.tag) { case ClassComponent: - case ClassComponentLazy: var ctor = fiber.type; var instance = fiber.stateNode; if ( @@ -14460,10 +15808,6 @@ function dispatch(sourceFiber, value, expirationTime) { } } -function captureCommitPhaseError(fiber, error) { - return dispatch(fiber, error, Sync); -} - function computeThreadID(expirationTime, interactionThreadID) { // Interaction threads are unique per root and expiration time. return expirationTime * 1000 + interactionThreadID; @@ -14498,7 +15842,7 @@ function computeExpirationForFiber(currentTime, fiber) { // If we're in the middle of rendering a tree, do not update at the same // expiration time that is already rendering. if (nextRoot !== null && expirationTime === nextRenderExpirationTime) { - expirationTime += 1; + expirationTime -= 1; } } else { // This is a sync update @@ -14509,7 +15853,10 @@ function computeExpirationForFiber(currentTime, fiber) { // This is an interactive update. Keep track of the lowest pending // interactive expiration time. This allows us to synchronously flush // all interactive updates when needed. - if (expirationTime > lowestPriorityPendingInteractiveExpirationTime) { + if ( + lowestPriorityPendingInteractiveExpirationTime === NoWork || + expirationTime < lowestPriorityPendingInteractiveExpirationTime + ) { lowestPriorityPendingInteractiveExpirationTime = expirationTime; } } @@ -14530,7 +15877,7 @@ function renderDidError() { nextRenderDidError = true; } -function retrySuspendedRoot(root, fiber, suspendedTime) { +function retrySuspendedRoot(root, boundaryFiber, sourceFiber, suspendedTime) { var retryTime = void 0; if (isPriorityLevelSuspended(root, suspendedTime)) { @@ -14541,18 +15888,18 @@ function retrySuspendedRoot(root, fiber, suspendedTime) { } else { // Suspense already timed out. Compute a new expiration time var currentTime = requestCurrentTime(); - retryTime = computeExpirationForFiber(currentTime, fiber); + retryTime = computeExpirationForFiber(currentTime, boundaryFiber); markPendingPriorityLevel(root, retryTime); } - // TODO: If the placeholder fiber has already rendered the primary children + // TODO: If the suspense fiber has already rendered the primary children // without suspending (that is, all of the promises have already resolved), // we should not trigger another update here. One case this happens is when // we are in sync mode and a single promise is thrown both on initial render // and on update; we attach two .then(retrySuspendedRoot) callbacks and each // one performs Sync work, rerendering the Suspense. - if ((fiber.mode & ConcurrentMode) !== NoContext) { + if ((boundaryFiber.mode & ConcurrentMode) !== NoContext) { if (root === nextRoot && nextRenderExpirationTime === suspendedTime) { // Received a ping at the same priority level at which we're currently // rendering. Restart from the root. @@ -14560,7 +15907,23 @@ function retrySuspendedRoot(root, fiber, suspendedTime) { } } - scheduleWorkToRoot(fiber, retryTime); + scheduleWorkToRoot(boundaryFiber, retryTime); + if ((boundaryFiber.mode & ConcurrentMode) === NoContext) { + // Outside of concurrent mode, we must schedule an update on the source + // fiber, too, since it already committed in an inconsistent state and + // therefore does not have any pending work. + scheduleWorkToRoot(sourceFiber, retryTime); + var sourceTag = sourceFiber.tag; + if (sourceTag === ClassComponent && sourceFiber.stateNode !== null) { + // When we try rendering again, we should not reuse the current fiber, + // since it's known to be in an inconsistent state. Use a force updte to + // prevent a bail out. + var update = createUpdate(retryTime); + update.tag = ForceUpdate; + enqueueUpdate(sourceFiber, update); + } + } + var rootExpirationTime = root.expirationTime; if (rootExpirationTime !== NoWork) { requestWork(root, rootExpirationTime); @@ -14571,25 +15934,18 @@ function scheduleWorkToRoot(fiber, expirationTime) { recordScheduleUpdate(); { - if (fiber.tag === ClassComponent || fiber.tag === ClassComponentLazy) { + if (fiber.tag === ClassComponent) { var instance = fiber.stateNode; warnAboutInvalidUpdates(instance); } } // Update the source fiber's expiration time - if ( - fiber.expirationTime === NoWork || - fiber.expirationTime > expirationTime - ) { + if (fiber.expirationTime < expirationTime) { fiber.expirationTime = expirationTime; } var alternate = fiber.alternate; - if ( - alternate !== null && - (alternate.expirationTime === NoWork || - alternate.expirationTime > expirationTime) - ) { + if (alternate !== null && alternate.expirationTime < expirationTime) { alternate.expirationTime = expirationTime; } // Walk the parent path to the root and update the child expiration time. @@ -14600,22 +15956,17 @@ function scheduleWorkToRoot(fiber, expirationTime) { } else { while (node !== null) { alternate = node.alternate; - if ( - node.childExpirationTime === NoWork || - node.childExpirationTime > expirationTime - ) { + if (node.childExpirationTime < expirationTime) { node.childExpirationTime = expirationTime; if ( alternate !== null && - (alternate.childExpirationTime === NoWork || - alternate.childExpirationTime > expirationTime) + alternate.childExpirationTime < expirationTime ) { alternate.childExpirationTime = expirationTime; } } else if ( alternate !== null && - (alternate.childExpirationTime === NoWork || - alternate.childExpirationTime > expirationTime) + alternate.childExpirationTime < expirationTime ) { alternate.childExpirationTime = expirationTime; } @@ -14628,11 +15979,18 @@ function scheduleWorkToRoot(fiber, expirationTime) { } if (root === null) { - if ( - true && - (fiber.tag === ClassComponent || fiber.tag === ClassComponentLazy) - ) { - warnAboutUpdateOnUnmounted(fiber); + { + switch (fiber.tag) { + case ClassComponent: + warnAboutUpdateOnUnmounted(fiber, true); + break; + case FunctionComponent: + case ForwardRef: + case MemoComponent: + case SimpleMemoComponent: + warnAboutUpdateOnUnmounted(fiber, false); + break; + } } return null; } @@ -14683,7 +16041,7 @@ function scheduleWork(fiber, expirationTime) { if ( !isWorking && nextRenderExpirationTime !== NoWork && - expirationTime < nextRenderExpirationTime + expirationTime > nextRenderExpirationTime ) { // This is an interruption. (Used for performance tracking.) interruptedBy = fiber; @@ -14727,10 +16085,8 @@ var isRendering = false; var nextFlushedRoot = null; var nextFlushedExpirationTime = NoWork; var lowestPriorityPendingInteractiveExpirationTime = NoWork; -var deadlineDidExpire = false; var hasUnhandledError = false; var unhandledError = null; -var deadline = null; var isBatchingUpdates = false; var isUnbatchingUpdates = false; @@ -14747,8 +16103,6 @@ var NESTED_UPDATE_LIMIT = 50; var nestedUpdateCount = 0; var lastCommittedRootDuringThisBatch = null; -var timeHeuristicForUnitOfWork = 1; - function recomputeCurrentRendererTime() { var currentTimeMs = now() - originalStartTimeMs; currentRendererTime = msToExpirationTime(currentTimeMs); @@ -14757,7 +16111,7 @@ function recomputeCurrentRendererTime() { function scheduleCallbackWithExpirationTime(root, expirationTime) { if (callbackExpirationTime !== NoWork) { // A callback is already scheduled. Check its expiration time (timeout). - if (expirationTime > callbackExpirationTime) { + if (expirationTime < callbackExpirationTime) { // Existing callback has sufficient timeout. Exit. return; } else { @@ -14800,7 +16154,7 @@ function onSuspend( msUntilTimeout ) { root.expirationTime = rootExpirationTime; - if (msUntilTimeout === 0 && !shouldYield()) { + if (msUntilTimeout === 0 && !shouldYieldToRenderer()) { // Don't wait an additional tick. Commit the tree immediately. root.pendingCommitExpirationTime = suspendedExpirationTime; root.finishedWork = finishedWork; @@ -14895,7 +16249,7 @@ function requestWork(root, expirationTime) { // flush it now. nextFlushedRoot = root; nextFlushedExpirationTime = Sync; - performWorkOnRoot(root, Sync, true); + performWorkOnRoot(root, Sync, false); } return; } @@ -14925,10 +16279,7 @@ function addRootToSchedule(root, expirationTime) { } else { // This root is already scheduled, but its priority may have increased. var remainingExpirationTime = root.expirationTime; - if ( - remainingExpirationTime === NoWork || - expirationTime < remainingExpirationTime - ) { + if (expirationTime > remainingExpirationTime) { // Update the priority. root.expirationTime = expirationTime; } @@ -14977,10 +16328,7 @@ function findHighestPriorityRoot() { } root = previousScheduledRoot.nextScheduledRoot; } else { - if ( - highestPriorityWork === NoWork || - remainingExpirationTime < highestPriorityWork - ) { + if (remainingExpirationTime > highestPriorityWork) { // Update the priority, if it's higher highestPriorityWork = remainingExpirationTime; highestPriorityRoot = root; @@ -15003,43 +16351,60 @@ function findHighestPriorityRoot() { nextFlushedExpirationTime = highestPriorityWork; } -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); - } +// TODO: This wrapper exists because many of the older tests (the ones that use +// flushDeferredPri) rely on the number of times `shouldYield` is called. We +// should get rid of it. +var didYield = false; +function shouldYieldToRenderer() { + if (didYield) { + return true; + } + if (shouldYield()) { + didYield = true; + return true; + } + return false; +} + +function performAsyncWork() { + try { + if (!shouldYieldToRenderer()) { + // 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, true); + } finally { + didYield = false; } - performWork(NoWork, dl); } function performSyncWork() { - performWork(Sync, null); + performWork(Sync, false); } -function performWork(minExpirationTime, dl) { - deadline = dl; - - // Keep working on roots until there's no more work, or until we reach - // the deadline. +function performWork(minExpirationTime, isYieldy) { + // Keep working on roots until there's no more work, or until there's a higher + // priority event. findHighestPriorityRoot(); - if (deadline !== null) { + if (isYieldy) { recomputeCurrentRendererTime(); currentSchedulerTime = currentRendererTime; if (enableUserTimingAPI) { - var didExpire = nextFlushedExpirationTime < currentRendererTime; + var didExpire = nextFlushedExpirationTime > currentRendererTime; var timeout = expirationTimeToMs(nextFlushedExpirationTime); stopRequestCallbackTimer(didExpire, timeout); } @@ -15047,14 +16412,13 @@ function performWork(minExpirationTime, dl) { while ( nextFlushedRoot !== null && nextFlushedExpirationTime !== NoWork && - (minExpirationTime === NoWork || - minExpirationTime >= nextFlushedExpirationTime) && - (!deadlineDidExpire || currentRendererTime >= nextFlushedExpirationTime) + minExpirationTime <= nextFlushedExpirationTime && + !(didYield && currentRendererTime > nextFlushedExpirationTime) ) { performWorkOnRoot( nextFlushedRoot, nextFlushedExpirationTime, - currentRendererTime >= nextFlushedExpirationTime + currentRendererTime > nextFlushedExpirationTime ); findHighestPriorityRoot(); recomputeCurrentRendererTime(); @@ -15064,10 +16428,9 @@ function performWork(minExpirationTime, dl) { while ( nextFlushedRoot !== null && nextFlushedExpirationTime !== NoWork && - (minExpirationTime === NoWork || - minExpirationTime >= nextFlushedExpirationTime) + minExpirationTime <= nextFlushedExpirationTime ) { - performWorkOnRoot(nextFlushedRoot, nextFlushedExpirationTime, true); + performWorkOnRoot(nextFlushedRoot, nextFlushedExpirationTime, false); findHighestPriorityRoot(); } } @@ -15076,7 +16439,7 @@ function performWork(minExpirationTime, dl) { // or there's no more work left with sufficient priority. // If we're inside a callback, set this to false since we just completed it. - if (deadline !== null) { + if (isYieldy) { callbackExpirationTime = NoWork; callbackID = null; } @@ -15089,9 +16452,6 @@ function performWork(minExpirationTime, dl) { } // Clean-up. - deadline = null; - deadlineDidExpire = false; - finishRendering(); } @@ -15106,7 +16466,7 @@ function flushRoot(root, expirationTime) { // including the given time. nextFlushedRoot = root; nextFlushedExpirationTime = expirationTime; - performWorkOnRoot(root, expirationTime, true); + performWorkOnRoot(root, expirationTime, false); // Flush any sync work that was scheduled by lifecycles performSyncWork(); } @@ -15139,7 +16499,7 @@ function finishRendering() { } } -function performWorkOnRoot(root, expirationTime, isExpired) { +function performWorkOnRoot(root, expirationTime, isYieldy) { invariant( !isRendering, "performWorkOnRoot was called recursively. This error is likely caused " + @@ -15149,7 +16509,7 @@ function performWorkOnRoot(root, expirationTime, isExpired) { isRendering = true; // Check if this is async work or sync/expired work. - if (deadline === null || isExpired) { + if (!isYieldy) { // Flush work without yielding. // TODO: Non-yieldy work does not necessarily imply expired work. A renderer // may want to perform some work without yielding, but also without @@ -15169,8 +16529,7 @@ function performWorkOnRoot(root, expirationTime, isExpired) { // $FlowFixMe Complains noTimeout is not a TimeoutID, despite the check above cancelTimeout(timeoutHandle); } - var isYieldy = false; - renderRoot(root, isYieldy, isExpired); + renderRoot(root, isYieldy); finishedWork = root.finishedWork; if (finishedWork !== null) { // We've completed the root. Commit it. @@ -15193,13 +16552,12 @@ function performWorkOnRoot(root, expirationTime, isExpired) { // $FlowFixMe Complains noTimeout is not a TimeoutID, despite the check above cancelTimeout(_timeoutHandle); } - var _isYieldy = true; - renderRoot(root, _isYieldy, isExpired); + renderRoot(root, isYieldy); _finishedWork = root.finishedWork; if (_finishedWork !== null) { - // We've completed the root. Check the deadline one more time + // We've completed the root. Check the if we should yield one more time // before committing. - if (!shouldYield()) { + if (!shouldYieldToRenderer()) { // Still time left. Commit the root. completeRoot$1(root, _finishedWork, expirationTime); } else { @@ -15217,7 +16575,7 @@ function performWorkOnRoot(root, expirationTime, isExpired) { function completeRoot$1(root, finishedWork, expirationTime) { // Check if there's a batch that matches this expiration time. var firstBatch = root.firstBatch; - if (firstBatch !== null && firstBatch._expirationTime <= expirationTime) { + if (firstBatch !== null && firstBatch._expirationTime >= expirationTime) { if (completedBatches === null) { completedBatches = [firstBatch]; } else { @@ -15249,24 +16607,6 @@ function completeRoot$1(root, finishedWork, expirationTime) { commitRoot(root, finishedWork); } -// When working on async work, the reconciler asks the renderer if it should -// yield execution. For DOM, we implement this with requestIdleCallback. -function shouldYield() { - if (deadlineDidExpire) { - return true; - } - if ( - deadline === null || - deadline.timeRemaining() > timeHeuristicForUnitOfWork - ) { - // Disregard deadline.didTimeout. Only expired work should be flushed - // during a timeout. This path is only hit for non-expired work. - return false; - } - deadlineDidExpire = true; - return true; -} - function onUncaughtError(error) { invariant( nextFlushedRoot !== null, @@ -15311,7 +16651,7 @@ function interactiveUpdates$1(fn, a, b) { lowestPriorityPendingInteractiveExpirationTime !== NoWork ) { // Synchronously flush pending interactive updates. - performWork(lowestPriorityPendingInteractiveExpirationTime, null); + performWork(lowestPriorityPendingInteractiveExpirationTime, false); lowestPriorityPendingInteractiveExpirationTime = NoWork; } var previousIsBatchingInteractiveUpdates = isBatchingInteractiveUpdates; @@ -15335,7 +16675,7 @@ function flushInteractiveUpdates$1() { lowestPriorityPendingInteractiveExpirationTime !== NoWork ) { // Synchronously flush pending interactive updates. - performWork(lowestPriorityPendingInteractiveExpirationTime, null); + performWork(lowestPriorityPendingInteractiveExpirationTime, false); lowestPriorityPendingInteractiveExpirationTime = NoWork; } } @@ -15364,11 +16704,6 @@ function getContextForSubtree(parentComponent) { 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; @@ -15406,9 +16741,11 @@ function scheduleRootUpdate(current$$1, element, expirationTime, callback) { : void 0; update.callback = callback; } - enqueueUpdate(current$$1, update); + flushPassiveEffects(); + enqueueUpdate(current$$1, update); scheduleWork(current$$1, expirationTime); + return expirationTime; } @@ -15599,7 +16936,7 @@ function createPortal( // TODO: this is special because it gets imported during build. -var ReactVersion = "16.6.0-alpha.8af6728"; +var ReactVersion = "16.6.0"; // Modules provided by RN: var NativeMethodsMixin = function(findNodeHandle, findHostInstance) { @@ -16001,9 +17338,9 @@ function getInstanceFromTag(tag) { } // Module provided by RN: -var emptyObject$2 = {}; +var emptyObject$1 = {}; { - Object.freeze(emptyObject$2); + Object.freeze(emptyObject$1); } var getInspectorDataForViewTag = void 0; @@ -16036,9 +17373,9 @@ var getInspectorDataForViewTag = void 0; var getHostProps = function(fiber) { var host = findCurrentHostFiber(fiber); if (host) { - return host.memoizedProps || emptyObject$2; + return host.memoizedProps || emptyObject$1; } - return emptyObject$2; + return emptyObject$1; }; var getHostNode = function(fiber, findNodeHandle) { @@ -16084,7 +17421,7 @@ var getInspectorDataForViewTag = void 0; if (!closestInstance) { return { hierarchy: [], - props: emptyObject$2, + props: emptyObject$1, selection: null, source: null }; diff --git a/Libraries/Renderer/oss/ReactFabric-prod.js b/Libraries/Renderer/oss/ReactFabric-prod.js index 9bd0a470b..58700577f 100644 --- a/Libraries/Renderer/oss/ReactFabric-prod.js +++ b/Libraries/Renderer/oss/ReactFabric-prod.js @@ -19,7 +19,8 @@ var ReactNativeViewConfigRegistry = require("ReactNativeViewConfigRegistry"), flattenStyle = require("flattenStyle"), TextInputState = require("TextInputState"), FabricUIManager = require("FabricUIManager"); -var ExceptionsManager = require("ExceptionsManager"); +var scheduler = require("scheduler"), + ExceptionsManager = require("ExceptionsManager"); function invariant(condition, format, a, b, c, d, e, f) { if (!condition) { condition = void 0; @@ -293,7 +294,7 @@ function getListener(inst, registrationName) { } function getParent(inst) { do inst = inst.return; - while (inst && 7 !== inst.tag); + while (inst && 5 !== inst.tag); return inst ? inst : null; } function traverseTwoPhase(inst, fn, arg) { @@ -1034,7 +1035,8 @@ var ReactSharedInternals = : 60111, REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for("react.forward_ref") : 60112, REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for("react.suspense") : 60113, - REACT_PURE_TYPE = hasSymbol ? Symbol.for("react.pure") : 60115, + REACT_MEMO_TYPE = hasSymbol ? Symbol.for("react.memo") : 60115, + REACT_LAZY_TYPE = hasSymbol ? Symbol.for("react.lazy") : 60116, MAYBE_ITERATOR_SYMBOL = "function" === typeof Symbol && Symbol.iterator; function getIteratorFn(maybeIterable) { if (null === maybeIterable || "object" !== typeof maybeIterable) return null; @@ -1043,13 +1045,6 @@ function getIteratorFn(maybeIterable) { maybeIterable["@@iterator"]; return "function" === typeof maybeIterable ? maybeIterable : null; } -function getWrappedName(outerType, innerType, wrapperName) { - innerType = innerType.displayName || innerType.name || ""; - return ( - outerType.displayName || - ("" !== innerType ? wrapperName + "(" + innerType + ")" : wrapperName) - ); -} function getComponentName(type) { if (null == type) return null; if ("function" === typeof type) return type.displayName || type.name || null; @@ -1068,23 +1063,25 @@ function getComponentName(type) { case REACT_SUSPENSE_TYPE: return "Suspense"; } - if ("object" === typeof type) { + if ("object" === typeof type) switch (type.$$typeof) { case REACT_CONTEXT_TYPE: return "Context.Consumer"; case REACT_PROVIDER_TYPE: return "Context.Provider"; case REACT_FORWARD_REF_TYPE: - return getWrappedName(type, type.render, "ForwardRef"); - case REACT_PURE_TYPE: - return getWrappedName(type, type.render, "Pure"); + var innerType = type.render; + innerType = innerType.displayName || innerType.name || ""; + return ( + type.displayName || + ("" !== innerType ? "ForwardRef(" + innerType + ")" : "ForwardRef") + ); + case REACT_MEMO_TYPE: + return getComponentName(type.type); + case REACT_LAZY_TYPE: + if ((type = 1 === type._status ? type._result : null)) + return getComponentName(type); } - if ( - "function" === typeof type.then && - (type = 1 === type._reactStatus ? type._reactResult : null) - ) - return getComponentName(type); - } return null; } function isFiberMountedImpl(fiber) { @@ -1095,7 +1092,7 @@ function isFiberMountedImpl(fiber) { for (; node.return; ) if (((node = node.return), 0 !== (node.effectTag & 2))) return 1; } - return 5 === node.tag ? 2 : 3; + return 3 === node.tag ? 2 : 3; } function assertIsMounted(fiber) { invariant( @@ -1171,14 +1168,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(5 === a.tag, "Unable to find node on an unmounted component."); + invariant(3 === 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 (7 === node.tag || 8 === node.tag) return node; + if (5 === node.tag || 6 === node.tag) return node; if (node.child) (node.child.return = node), (node = node.child); else { if (node === parent) break; @@ -1428,18 +1425,12 @@ var now$1 = return Date.now(); }, scheduledCallback = null, - frameDeadline = 0, - frameDeadlineObject = { - timeRemaining: function() { - return frameDeadline - now$1(); - }, - didTimeout: !1 - }; + frameDeadline = 0; function setTimeoutCallback() { frameDeadline = now$1() + 5; var callback = scheduledCallback; scheduledCallback = null; - null !== callback && callback(frameDeadlineObject); + null !== callback && callback(); } var restoreTarget = null, restoreQueue = null; @@ -1603,13 +1594,13 @@ function getStackByFiberInDevAndProd(workInProgress) { var info = ""; do { a: switch (workInProgress.tag) { - case 4: + case 2: + case 16: case 0: case 1: - case 2: - case 3: - case 7: - case 10: + case 5: + case 8: + case 13: var owner = workInProgress._debugOwner, source = workInProgress._debugSource, name = getComponentName(workInProgress.type); @@ -1760,7 +1751,7 @@ function injectInternals(internals) { function FiberNode(tag, pendingProps, key, mode) { this.tag = tag; this.key = key; - this.sibling = this.child = this.return = this.stateNode = this.type = null; + this.sibling = this.child = this.return = this.stateNode = this.type = this.elementType = null; this.index = 0; this.ref = null; this.pendingProps = pendingProps; @@ -1771,29 +1762,33 @@ function FiberNode(tag, pendingProps, key, mode) { this.childExpirationTime = this.expirationTime = 0; this.alternate = null; } +function createFiber(tag, pendingProps, key, mode) { + return new FiberNode(tag, pendingProps, key, mode); +} function shouldConstruct(Component) { Component = Component.prototype; return !(!Component || !Component.isReactComponent); } -function resolveLazyComponentTag(fiber, Component) { +function resolveLazyComponentTag(Component) { if ("function" === typeof Component) - return shouldConstruct(Component) ? 3 : 1; + return shouldConstruct(Component) ? 1 : 0; if (void 0 !== Component && null !== Component) { - fiber = Component.$$typeof; - if (fiber === REACT_FORWARD_REF_TYPE) return 14; - if (fiber === REACT_PURE_TYPE) return 18; + Component = Component.$$typeof; + if (Component === REACT_FORWARD_REF_TYPE) return 11; + if (Component === REACT_MEMO_TYPE) return 14; } - return 4; + return 2; } function createWorkInProgress(current, pendingProps) { var workInProgress = current.alternate; null === workInProgress - ? ((workInProgress = new FiberNode( + ? ((workInProgress = createFiber( current.tag, pendingProps, current.key, current.mode )), + (workInProgress.elementType = current.elementType), (workInProgress.type = current.type), (workInProgress.stateNode = current.stateNode), (workInProgress.alternate = current), @@ -1815,60 +1810,66 @@ function createWorkInProgress(current, pendingProps) { workInProgress.ref = current.ref; return workInProgress; } -function createFiberFromElement(element, mode, expirationTime) { - var type = element.type, - key = element.key; - element = element.props; - var fiberTag = void 0; - if ("function" === typeof type) fiberTag = shouldConstruct(type) ? 2 : 4; - else if ("string" === typeof type) fiberTag = 7; +function createFiberFromTypeAndProps( + type, + key, + pendingProps, + owner, + mode, + expirationTime +) { + var fiberTag = 2; + owner = type; + if ("function" === typeof type) shouldConstruct(type) && (fiberTag = 1); + else if ("string" === typeof type) fiberTag = 5; else a: switch (type) { case REACT_FRAGMENT_TYPE: return createFiberFromFragment( - element.children, + pendingProps.children, mode, expirationTime, key ); case REACT_CONCURRENT_MODE_TYPE: - fiberTag = 10; - mode |= 3; - break; + return createFiberFromMode(pendingProps, mode | 3, expirationTime, key); case REACT_STRICT_MODE_TYPE: - fiberTag = 10; - mode |= 2; - break; + return createFiberFromMode(pendingProps, mode | 2, expirationTime, key); case REACT_PROFILER_TYPE: return ( - (type = new FiberNode(15, element, key, mode | 4)), + (type = createFiber(12, pendingProps, key, mode | 4)), + (type.elementType = REACT_PROFILER_TYPE), (type.type = REACT_PROFILER_TYPE), (type.expirationTime = expirationTime), type ); case REACT_SUSPENSE_TYPE: - fiberTag = 16; - break; + return ( + (type = createFiber(13, pendingProps, key, mode)), + (type.elementType = REACT_SUSPENSE_TYPE), + (type.type = REACT_SUSPENSE_TYPE), + (type.expirationTime = expirationTime), + type + ); default: if ("object" === typeof type && null !== type) switch (type.$$typeof) { case REACT_PROVIDER_TYPE: - fiberTag = 12; + fiberTag = 10; break a; case REACT_CONTEXT_TYPE: - fiberTag = 11; + fiberTag = 9; break a; case REACT_FORWARD_REF_TYPE: - fiberTag = 13; + fiberTag = 11; break a; - case REACT_PURE_TYPE: - fiberTag = 17; + case REACT_MEMO_TYPE: + fiberTag = 14; + break a; + case REACT_LAZY_TYPE: + fiberTag = 16; + owner = null; break a; - default: - if ("function" === typeof type.then) { - fiberTag = 4; - break a; - } } invariant( !1, @@ -1877,24 +1878,33 @@ function createFiberFromElement(element, mode, expirationTime) { "" ); } - mode = new FiberNode(fiberTag, element, key, mode); - mode.type = type; - mode.expirationTime = expirationTime; - return mode; + key = createFiber(fiberTag, pendingProps, key, mode); + key.elementType = type; + key.type = owner; + key.expirationTime = expirationTime; + return key; } function createFiberFromFragment(elements, mode, expirationTime, key) { - elements = new FiberNode(9, elements, key, mode); + elements = createFiber(7, elements, key, mode); elements.expirationTime = expirationTime; return elements; } +function createFiberFromMode(pendingProps, mode, expirationTime, key) { + pendingProps = createFiber(8, pendingProps, key, mode); + mode = 0 === (mode & 1) ? REACT_STRICT_MODE_TYPE : REACT_CONCURRENT_MODE_TYPE; + pendingProps.elementType = mode; + pendingProps.type = mode; + pendingProps.expirationTime = expirationTime; + return pendingProps; +} function createFiberFromText(content, mode, expirationTime) { - content = new FiberNode(8, content, null, mode); + content = createFiber(6, content, null, mode); content.expirationTime = expirationTime; return content; } function createFiberFromPortal(portal, mode, expirationTime) { - mode = new FiberNode( - 6, + mode = createFiber( + 4, null !== portal.children ? portal.children : [], portal.key, mode @@ -1912,9 +1922,9 @@ function markPendingPriorityLevel(root, expirationTime) { var earliestPendingTime = root.earliestPendingTime; 0 === earliestPendingTime ? (root.earliestPendingTime = root.latestPendingTime = expirationTime) - : earliestPendingTime > expirationTime + : earliestPendingTime < expirationTime ? (root.earliestPendingTime = expirationTime) - : root.latestPendingTime < expirationTime && + : root.latestPendingTime > expirationTime && (root.latestPendingTime = expirationTime); findNextExpirationTimeToWorkOn(expirationTime, root); } @@ -1922,7 +1932,7 @@ function markSuspendedPriorityLevel(root, suspendedTime) { root.didError = !1; var latestPingedTime = root.latestPingedTime; 0 !== latestPingedTime && - latestPingedTime <= suspendedTime && + latestPingedTime >= suspendedTime && (root.latestPingedTime = 0); latestPingedTime = root.earliestPendingTime; var latestPendingTime = root.latestPendingTime; @@ -1937,22 +1947,18 @@ function markSuspendedPriorityLevel(root, suspendedTime) { latestPendingTime = root.latestSuspendedTime; 0 === latestPingedTime ? (root.earliestSuspendedTime = root.latestSuspendedTime = suspendedTime) - : latestPingedTime > suspendedTime + : latestPingedTime < suspendedTime ? (root.earliestSuspendedTime = suspendedTime) - : latestPendingTime < suspendedTime && + : latestPendingTime > suspendedTime && (root.latestSuspendedTime = suspendedTime); findNextExpirationTimeToWorkOn(suspendedTime, root); } function findEarliestOutstandingPriorityLevel(root, renderExpirationTime) { var earliestPendingTime = root.earliestPendingTime; root = root.earliestSuspendedTime; - if ( - 0 === renderExpirationTime || - (0 !== earliestPendingTime && earliestPendingTime < renderExpirationTime) - ) - renderExpirationTime = earliestPendingTime; - if (0 === renderExpirationTime || (0 !== root && root < renderExpirationTime)) - renderExpirationTime = root; + earliestPendingTime > renderExpirationTime && + (renderExpirationTime = earliestPendingTime); + root > renderExpirationTime && (renderExpirationTime = root); return renderExpirationTime; } function findNextExpirationTimeToWorkOn(completedExpirationTime, root) { @@ -1964,12 +1970,11 @@ function findNextExpirationTimeToWorkOn(completedExpirationTime, root) { 0 !== earliestPendingTime ? earliestPendingTime : latestPingedTime; 0 === earliestPendingTime && (0 === completedExpirationTime || - latestSuspendedTime > completedExpirationTime) && + latestSuspendedTime < completedExpirationTime) && (earliestPendingTime = latestSuspendedTime); completedExpirationTime = earliestPendingTime; 0 !== completedExpirationTime && - 0 !== earliestSuspendedTime && - earliestSuspendedTime < completedExpirationTime && + earliestSuspendedTime > completedExpirationTime && (completedExpirationTime = earliestSuspendedTime); root.nextExpirationTimeToWorkOn = earliestPendingTime; root.expirationTime = completedExpirationTime; @@ -2081,7 +2086,7 @@ function getStateFromUpdate( : workInProgress ); case 3: - workInProgress.effectTag = (workInProgress.effectTag & -1025) | 64; + workInProgress.effectTag = (workInProgress.effectTag & -2049) | 64; case 0: workInProgress = update.payload; nextProps = @@ -2114,58 +2119,52 @@ function processUpdateQueue( ) { var updateExpirationTime = update.expirationTime; - if (updateExpirationTime > renderExpirationTime) { - if ( - (null === newFirstUpdate && + updateExpirationTime < renderExpirationTime + ? (null === newFirstUpdate && ((newFirstUpdate = update), (newBaseState = resultState)), - 0 === newExpirationTime || newExpirationTime > updateExpirationTime) - ) - newExpirationTime = updateExpirationTime; - } else - (resultState = getStateFromUpdate( - workInProgress, - queue, - update, - resultState, - props, - instance - )), + newExpirationTime < updateExpirationTime && + (newExpirationTime = updateExpirationTime)) + : ((resultState = getStateFromUpdate( + workInProgress, + queue, + update, + resultState, + props, + instance + )), null !== update.callback && ((workInProgress.effectTag |= 32), (update.nextEffect = null), null === queue.lastEffect ? (queue.firstEffect = queue.lastEffect = update) : ((queue.lastEffect.nextEffect = update), - (queue.lastEffect = update))); + (queue.lastEffect = update)))); update = update.next; } updateExpirationTime = null; for (update = queue.firstCapturedUpdate; null !== update; ) { var _updateExpirationTime = update.expirationTime; - if (_updateExpirationTime > renderExpirationTime) { - if ( - (null === updateExpirationTime && + _updateExpirationTime < renderExpirationTime + ? (null === updateExpirationTime && ((updateExpirationTime = update), null === newFirstUpdate && (newBaseState = resultState)), - 0 === newExpirationTime || newExpirationTime > _updateExpirationTime) - ) - newExpirationTime = _updateExpirationTime; - } else - (resultState = getStateFromUpdate( - workInProgress, - queue, - update, - resultState, - props, - instance - )), + newExpirationTime < _updateExpirationTime && + (newExpirationTime = _updateExpirationTime)) + : ((resultState = getStateFromUpdate( + workInProgress, + queue, + update, + resultState, + props, + instance + )), null !== update.callback && ((workInProgress.effectTag |= 32), (update.nextEffect = null), null === queue.lastCapturedEffect ? (queue.firstCapturedEffect = queue.lastCapturedEffect = update) : ((queue.lastCapturedEffect.nextEffect = update), - (queue.lastCapturedEffect = update))); + (queue.lastCapturedEffect = update)))); update = update.next; } null === newFirstUpdate && (queue.lastUpdate = null); @@ -2246,13 +2245,277 @@ function readContext(context, observedBits) { null === lastContextDependency ? (invariant( null !== currentlyRenderingFiber, - "Context.unstable_read(): Context can only be read while React is rendering, e.g. inside the render method or getDerivedStateFromProps." + "Context can only be read while React is rendering, e.g. inside the render method or getDerivedStateFromProps." ), (currentlyRenderingFiber.firstContextDependency = lastContextDependency = observedBits)) : (lastContextDependency = lastContextDependency.next = observedBits); } return context._currentValue2; } +var renderExpirationTime = 0, + currentlyRenderingFiber$1 = null, + firstCurrentHook = null, + currentHook = null, + firstWorkInProgressHook = null, + workInProgressHook = null, + remainingExpirationTime = 0, + componentUpdateQueue = null, + isReRender = !1, + didScheduleRenderPhaseUpdate = !1, + renderPhaseUpdates = null, + numberOfReRenders = 0; +function resolveCurrentlyRenderingFiber() { + invariant( + null !== currentlyRenderingFiber$1, + "Hooks can only be called inside the body of a function component." + ); + return currentlyRenderingFiber$1; +} +function finishHooks(Component, props, children, refOrContext) { + for (; didScheduleRenderPhaseUpdate; ) + (didScheduleRenderPhaseUpdate = !1), + (numberOfReRenders += 1), + (componentUpdateQueue = workInProgressHook = currentHook = null), + (children = Component(props, refOrContext)); + renderPhaseUpdates = null; + numberOfReRenders = 0; + Component = currentlyRenderingFiber$1; + Component.memoizedState = firstWorkInProgressHook; + Component.expirationTime = remainingExpirationTime; + Component.updateQueue = componentUpdateQueue; + Component = null !== currentHook && null !== currentHook.next; + renderExpirationTime = 0; + workInProgressHook = firstWorkInProgressHook = currentHook = firstCurrentHook = currentlyRenderingFiber$1 = null; + remainingExpirationTime = 0; + componentUpdateQueue = null; + invariant( + !Component, + "Rendered fewer hooks than expected. This may be caused by an accidental early return statement." + ); + return children; +} +function resetHooks() { + renderExpirationTime = 0; + workInProgressHook = firstWorkInProgressHook = currentHook = firstCurrentHook = currentlyRenderingFiber$1 = null; + remainingExpirationTime = 0; + componentUpdateQueue = null; + didScheduleRenderPhaseUpdate = !1; + renderPhaseUpdates = null; + numberOfReRenders = 0; +} +function createHook() { + return { + memoizedState: null, + baseState: null, + queue: null, + baseUpdate: null, + next: null + }; +} +function cloneHook(hook) { + return { + memoizedState: hook.memoizedState, + baseState: hook.memoizedState, + queue: hook.queue, + baseUpdate: hook.baseUpdate, + next: null + }; +} +function createWorkInProgressHook() { + if (null === workInProgressHook) + null === firstWorkInProgressHook + ? ((isReRender = !1), + (currentHook = firstCurrentHook), + (firstWorkInProgressHook = workInProgressHook = + null === currentHook ? createHook() : cloneHook(currentHook))) + : ((isReRender = !0), + (currentHook = firstCurrentHook), + (workInProgressHook = firstWorkInProgressHook)); + else if (null === workInProgressHook.next) { + isReRender = !1; + if (null === currentHook) var hook = createHook(); + else + (currentHook = currentHook.next), + (hook = null === currentHook ? createHook() : cloneHook(currentHook)); + workInProgressHook = workInProgressHook.next = hook; + } else + (isReRender = !0), + (workInProgressHook = workInProgressHook.next), + (currentHook = null !== currentHook ? currentHook.next : null); + return workInProgressHook; +} +function basicStateReducer(state, action) { + return "function" === typeof action ? action(state) : action; +} +function useReducer(reducer, initialState, initialAction) { + currentlyRenderingFiber$1 = resolveCurrentlyRenderingFiber(); + workInProgressHook = createWorkInProgressHook(); + var queue = workInProgressHook.queue; + if (null !== queue) { + if (isReRender) { + initialState = queue.dispatch; + if (null !== renderPhaseUpdates) { + var firstRenderPhaseUpdate = renderPhaseUpdates.get(queue); + if (void 0 !== firstRenderPhaseUpdate) { + renderPhaseUpdates.delete(queue); + initialAction = workInProgressHook.memoizedState; + do + (initialAction = reducer( + initialAction, + firstRenderPhaseUpdate.action + )), + (firstRenderPhaseUpdate = firstRenderPhaseUpdate.next); + while (null !== firstRenderPhaseUpdate); + workInProgressHook.memoizedState = initialAction; + workInProgressHook.baseUpdate === queue.last && + (workInProgressHook.baseState = initialAction); + return [initialAction, initialState]; + } + } + return [workInProgressHook.memoizedState, initialState]; + } + initialState = queue.last; + var _baseUpdate = workInProgressHook.baseUpdate; + null !== _baseUpdate + ? (null !== initialState && (initialState.next = null), + (initialState = _baseUpdate.next)) + : (initialState = null !== initialState ? initialState.next : null); + if (null !== initialState) { + initialAction = workInProgressHook.baseState; + var newBaseUpdate = (firstRenderPhaseUpdate = null), + _update = initialState, + didSkip = !1; + do { + var updateExpirationTime = _update.expirationTime; + updateExpirationTime < renderExpirationTime + ? (didSkip || + ((didSkip = !0), + (newBaseUpdate = _baseUpdate), + (firstRenderPhaseUpdate = initialAction)), + updateExpirationTime > remainingExpirationTime && + (remainingExpirationTime = updateExpirationTime)) + : (initialAction = reducer(initialAction, _update.action)); + _baseUpdate = _update; + _update = _update.next; + } while (null !== _update && _update !== initialState); + didSkip || + ((newBaseUpdate = _baseUpdate), + (firstRenderPhaseUpdate = initialAction)); + workInProgressHook.memoizedState = initialAction; + workInProgressHook.baseUpdate = newBaseUpdate; + workInProgressHook.baseState = firstRenderPhaseUpdate; + } + return [workInProgressHook.memoizedState, queue.dispatch]; + } + reducer === basicStateReducer + ? "function" === typeof initialState && (initialState = initialState()) + : void 0 !== initialAction && + null !== initialAction && + (initialState = reducer(initialState, initialAction)); + workInProgressHook.memoizedState = workInProgressHook.baseState = initialState; + queue = workInProgressHook.queue = { last: null, dispatch: null }; + reducer = queue.dispatch = dispatchAction.bind( + null, + currentlyRenderingFiber$1, + queue + ); + return [workInProgressHook.memoizedState, reducer]; +} +function pushEffect(tag, create, destroy, inputs) { + tag = { + tag: tag, + create: create, + destroy: destroy, + inputs: inputs, + next: null + }; + null === componentUpdateQueue + ? ((componentUpdateQueue = { lastEffect: null }), + (componentUpdateQueue.lastEffect = tag.next = tag)) + : ((create = componentUpdateQueue.lastEffect), + null === create + ? (componentUpdateQueue.lastEffect = tag.next = tag) + : ((destroy = create.next), + (create.next = tag), + (tag.next = destroy), + (componentUpdateQueue.lastEffect = tag))); + return tag; +} +function useEffectImpl(fiberEffectTag, hookEffectTag, create, inputs) { + currentlyRenderingFiber$1 = resolveCurrentlyRenderingFiber(); + workInProgressHook = createWorkInProgressHook(); + inputs = void 0 !== inputs && null !== inputs ? inputs : [create]; + var destroy = null; + if (null !== currentHook) { + var prevEffect = currentHook.memoizedState; + destroy = prevEffect.destroy; + if (inputsAreEqual(inputs, prevEffect.inputs)) { + pushEffect(0, create, destroy, inputs); + return; + } + } + currentlyRenderingFiber$1.effectTag |= fiberEffectTag; + workInProgressHook.memoizedState = pushEffect( + hookEffectTag, + create, + destroy, + inputs + ); +} +function dispatchAction(fiber, queue, action) { + invariant( + 25 > numberOfReRenders, + "Too many re-renders. React limits the number of renders to prevent an infinite loop." + ); + var alternate = fiber.alternate; + if ( + fiber === currentlyRenderingFiber$1 || + (null !== alternate && alternate === currentlyRenderingFiber$1) + ) + if ( + ((didScheduleRenderPhaseUpdate = !0), + (fiber = { + expirationTime: renderExpirationTime, + action: action, + next: null + }), + null === renderPhaseUpdates && (renderPhaseUpdates = new Map()), + (alternate = renderPhaseUpdates.get(queue)), + void 0 === alternate) + ) + renderPhaseUpdates.set(queue, fiber); + else { + for (queue = alternate; null !== queue.next; ) queue = queue.next; + queue.next = fiber; + } + else { + alternate = requestCurrentTime(); + alternate = computeExpirationForFiber(alternate, fiber); + action = { expirationTime: alternate, action: action, next: null }; + flushPassiveEffects(); + var _last2 = queue.last; + if (null === _last2) action.next = action; + else { + var first = _last2.next; + null !== first && (action.next = first); + _last2.next = action; + } + queue.last = action; + scheduleWork(fiber, alternate); + } +} +function inputsAreEqual(arr1, arr2) { + for (var i = 0; i < arr1.length; i++) { + var val1 = arr1[i], + val2 = arr2[i]; + if ( + (val1 !== val2 || (0 === val1 && 1 / val1 !== 1 / val2)) && + (val1 === val1 || val2 === val2) + ) + return !1; + } + return !0; +} var NO_CONTEXT = {}, contextStackCursor$1 = { current: NO_CONTEXT }, contextFiberStackCursor = { current: NO_CONTEXT }, @@ -2322,7 +2585,8 @@ function shallowEqual(objA, objB) { return !1; return !0; } -var emptyRefsObject = new React.Component().refs; +var ReactCurrentOwner$4 = ReactSharedInternals.ReactCurrentOwner, + emptyRefsObject = new React.Component().refs; function applyDerivedStateFromProps( workInProgress, ctor, @@ -2354,6 +2618,7 @@ var classComponentUpdater = { var update = createUpdate(currentTime); update.payload = payload; void 0 !== callback && null !== callback && (update.callback = callback); + flushPassiveEffects(); enqueueUpdate(inst, update); scheduleWork(inst, currentTime); }, @@ -2365,6 +2630,7 @@ var classComponentUpdater = { update.tag = 1; update.payload = payload; void 0 !== callback && null !== callback && (update.callback = callback); + flushPassiveEffects(); enqueueUpdate(inst, update); scheduleWork(inst, currentTime); }, @@ -2375,6 +2641,7 @@ var classComponentUpdater = { var update = createUpdate(currentTime); update.tag = 2; void 0 !== callback && null !== callback && (update.callback = callback); + flushPassiveEffects(); enqueueUpdate(inst, update); scheduleWork(inst, currentTime); } @@ -2395,6 +2662,32 @@ function checkShouldComponentUpdate( ? !shallowEqual(oldProps, newProps) || !shallowEqual(oldState, newState) : !0; } +function constructClassInstance(workInProgress, ctor, props) { + var isLegacyContextConsumer = !1, + unmaskedContext = emptyContextObject; + var context = ctor.contextType; + "object" === typeof context && null !== context + ? (context = ReactCurrentOwner$4.currentDispatcher.readContext(context)) + : ((unmaskedContext = isContextProvider(ctor) + ? previousContext + : contextStackCursor.current), + (isLegacyContextConsumer = ctor.contextTypes), + (context = (isLegacyContextConsumer = + null !== isLegacyContextConsumer && void 0 !== isLegacyContextConsumer) + ? getMaskedContext(workInProgress, unmaskedContext) + : emptyContextObject)); + ctor = new ctor(props, context); + workInProgress.memoizedState = + null !== ctor.state && void 0 !== ctor.state ? ctor.state : null; + ctor.updater = classComponentUpdater; + workInProgress.stateNode = ctor; + ctor._reactInternalFiber = workInProgress; + isLegacyContextConsumer && + ((workInProgress = workInProgress.stateNode), + (workInProgress.__reactInternalMemoizedUnmaskedChildContext = unmaskedContext), + (workInProgress.__reactInternalMemoizedMaskedChildContext = context)); + return ctor; +} function callComponentWillReceiveProps( workInProgress, instance, @@ -2421,7 +2714,9 @@ function mountClassInstance( instance.refs = emptyRefsObject; var contextType = ctor.contextType; "object" === typeof contextType && null !== contextType - ? (instance.context = contextType.unstable_read()) + ? (instance.context = ReactCurrentOwner$4.currentDispatcher.readContext( + contextType + )) : ((contextType = isContextProvider(ctor) ? previousContext : contextStackCursor.current), @@ -2476,10 +2771,7 @@ function coerceRef(returnFiber, current$$1, element) { element = element._owner; var inst = void 0; element && - (invariant( - 2 === element.tag || 3 === element.tag, - "Function components cannot have refs." - ), + (invariant(1 === element.tag, "Function components cannot have refs."), (inst = element.stateNode)); invariant( inst, @@ -2584,7 +2876,7 @@ function ChildReconciler(shouldTrackSideEffects) { textContent, expirationTime ) { - if (null === current$$1 || 8 !== current$$1.tag) + if (null === current$$1 || 6 !== current$$1.tag) return ( (current$$1 = createFiberFromText( textContent, @@ -2599,15 +2891,18 @@ function ChildReconciler(shouldTrackSideEffects) { return current$$1; } function updateElement(returnFiber, current$$1, element, expirationTime) { - if (null !== current$$1 && current$$1.type === element.type) + if (null !== current$$1 && current$$1.elementType === element.type) return ( (expirationTime = useFiber(current$$1, element.props, expirationTime)), (expirationTime.ref = coerceRef(returnFiber, current$$1, element)), (expirationTime.return = returnFiber), expirationTime ); - expirationTime = createFiberFromElement( - element, + expirationTime = createFiberFromTypeAndProps( + element.type, + element.key, + element.props, + null, returnFiber.mode, expirationTime ); @@ -2618,7 +2913,7 @@ function ChildReconciler(shouldTrackSideEffects) { function updatePortal(returnFiber, current$$1, portal, expirationTime) { if ( null === current$$1 || - 6 !== current$$1.tag || + 4 !== current$$1.tag || current$$1.stateNode.containerInfo !== portal.containerInfo || current$$1.stateNode.implementation !== portal.implementation ) @@ -2642,7 +2937,7 @@ function ChildReconciler(shouldTrackSideEffects) { expirationTime, key ) { - if (null === current$$1 || 9 !== current$$1.tag) + if (null === current$$1 || 7 !== current$$1.tag) return ( (current$$1 = createFiberFromFragment( fragment, @@ -2672,8 +2967,11 @@ function ChildReconciler(shouldTrackSideEffects) { switch (newChild.$$typeof) { case REACT_ELEMENT_TYPE: return ( - (expirationTime = createFiberFromElement( - newChild, + (expirationTime = createFiberFromTypeAndProps( + newChild.type, + newChild.key, + newChild.props, + null, returnFiber.mode, expirationTime )), @@ -3017,9 +3315,9 @@ function ChildReconciler(shouldTrackSideEffects) { ) { if (isUnkeyedTopLevelFragment.key === isObject) if ( - 9 === isUnkeyedTopLevelFragment.tag + 7 === isUnkeyedTopLevelFragment.tag ? newChild.type === REACT_FRAGMENT_TYPE - : isUnkeyedTopLevelFragment.type === newChild.type + : isUnkeyedTopLevelFragment.elementType === newChild.type ) { deleteRemainingChildren( returnFiber, @@ -3059,8 +3357,11 @@ function ChildReconciler(shouldTrackSideEffects) { )), (currentFirstChild.return = returnFiber), (returnFiber = currentFirstChild)) - : ((expirationTime = createFiberFromElement( - newChild, + : ((expirationTime = createFiberFromTypeAndProps( + newChild.type, + newChild.key, + newChild.props, + null, returnFiber.mode, expirationTime )), @@ -3082,7 +3383,7 @@ function ChildReconciler(shouldTrackSideEffects) { ) { if (currentFirstChild.key === isUnkeyedTopLevelFragment) if ( - 6 === currentFirstChild.tag && + 4 === currentFirstChild.tag && currentFirstChild.stateNode.containerInfo === newChild.containerInfo && currentFirstChild.stateNode.implementation === @@ -3120,7 +3421,7 @@ function ChildReconciler(shouldTrackSideEffects) { if ("string" === typeof newChild || "number" === typeof newChild) return ( (newChild = "" + newChild), - null !== currentFirstChild && 8 === currentFirstChild.tag + null !== currentFirstChild && 6 === currentFirstChild.tag ? (deleteRemainingChildren(returnFiber, currentFirstChild.sibling), (currentFirstChild = useFiber( currentFirstChild, @@ -3156,8 +3457,7 @@ function ChildReconciler(shouldTrackSideEffects) { isObject && throwOnInvalidObjectType(returnFiber, newChild); if ("undefined" === typeof newChild && !isUnkeyedTopLevelFragment) switch (returnFiber.tag) { - case 2: - case 3: + case 1: case 0: (expirationTime = returnFiber.type), invariant( @@ -3176,12 +3476,12 @@ var reconcileChildFibers = ChildReconciler(!0), isHydrating = !1; function tryHydrate(fiber, nextInstance) { switch (fiber.tag) { - case 7: + case 5: return ( (nextInstance = shim$1(nextInstance, fiber.type, fiber.pendingProps)), null !== nextInstance ? ((fiber.stateNode = nextInstance), !0) : !1 ); - case 8: + case 6: return ( (nextInstance = shim$1(nextInstance, fiber.pendingProps)), null !== nextInstance ? ((fiber.stateNode = nextInstance), !0) : !1 @@ -3204,7 +3504,8 @@ function tryToClaimNextHydratableInstance(fiber$jscomp$0) { return; } var returnFiber = hydrationParentFiber, - fiber = new FiberNode(7, null, null, 0); + fiber = createFiber(5, null, null, 0); + fiber.elementType = "DELETED"; fiber.type = "DELETED"; fiber.stateNode = firstAttemptedInstance; fiber.return = returnFiber; @@ -3222,36 +3523,33 @@ function tryToClaimNextHydratableInstance(fiber$jscomp$0) { (hydrationParentFiber = fiber$jscomp$0); } } -function readLazyComponentType(thenable) { - switch (thenable._reactStatus) { +function readLazyComponentType(lazyComponent) { + var result = lazyComponent._result; + switch (lazyComponent._status) { case 1: - return thenable._reactResult; + return result; case 2: - throw thenable._reactResult; + throw result; case 0: - throw thenable; + throw result; 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; - } + throw ((lazyComponent._status = 0), + (result = lazyComponent._ctor), + (result = result()), + result.then( + function(moduleObject) { + 0 === lazyComponent._status && + ((moduleObject = moduleObject.default), + (lazyComponent._status = 1), + (lazyComponent._result = moduleObject)); }, function(error) { - 0 === thenable._reactStatus && - ((thenable._reactStatus = 2), (thenable._reactResult = error)); + 0 === lazyComponent._status && + ((lazyComponent._status = 2), (lazyComponent._result = error)); } ), - thenable); + (lazyComponent._result = result), + result); } } var ReactCurrentOwner$3 = ReactSharedInternals.ReactCurrentOwner; @@ -3279,28 +3577,28 @@ function reconcileChildren( function updateForwardRef( current$$1, workInProgress, - type, + Component, nextProps, - renderExpirationTime + renderExpirationTime$jscomp$0 ) { - type = type.render; + Component = Component.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; + prepareToReadContext(workInProgress, renderExpirationTime$jscomp$0); + renderExpirationTime = renderExpirationTime$jscomp$0; + currentlyRenderingFiber$1 = workInProgress; + firstCurrentHook = null !== current$$1 ? current$$1.memoizedState : null; + var nextChildren = Component(nextProps, ref); + nextChildren = finishHooks(Component, nextProps, nextChildren, ref); + workInProgress.effectTag |= 1; + reconcileChildren( + current$$1, + workInProgress, + nextChildren, + renderExpirationTime$jscomp$0 + ); return workInProgress.child; } -function updatePureComponent( +function updateMemoComponent( current$$1, workInProgress, Component, @@ -3308,29 +3606,81 @@ function updatePureComponent( updateExpirationTime, renderExpirationTime ) { - var render = Component.render, - ref = workInProgress.ref; + if (null === current$$1) { + var type = Component.type; + if ( + "function" === typeof type && + !shouldConstruct(type) && + void 0 === type.defaultProps && + null === Component.compare + ) + return ( + (workInProgress.tag = 15), + (workInProgress.type = type), + updateSimpleMemoComponent( + current$$1, + workInProgress, + type, + nextProps, + updateExpirationTime, + renderExpirationTime + ) + ); + current$$1 = createFiberFromTypeAndProps( + Component.type, + null, + nextProps, + null, + workInProgress.mode, + renderExpirationTime + ); + current$$1.ref = workInProgress.ref; + current$$1.return = workInProgress; + return (workInProgress.child = current$$1); + } + type = current$$1.child; if ( - null !== current$$1 && - (0 === updateExpirationTime || - updateExpirationTime > renderExpirationTime) && - ((updateExpirationTime = current$$1.memoizedProps), + updateExpirationTime < renderExpirationTime && + ((updateExpirationTime = type.memoizedProps), (Component = Component.compare), (Component = null !== Component ? Component : shallowEqual), - workInProgress.ref === current$$1.ref && - Component(updateExpirationTime, nextProps)) + Component(updateExpirationTime, nextProps) && + current$$1.ref === workInProgress.ref) ) return bailoutOnAlreadyFinishedWork( current$$1, workInProgress, renderExpirationTime ); - prepareToReadContext(workInProgress, renderExpirationTime); - render = render(nextProps, ref); - workInProgress.effectTag |= 1; - reconcileChildren(current$$1, workInProgress, render, renderExpirationTime); - workInProgress.memoizedProps = nextProps; - return workInProgress.child; + current$$1 = createWorkInProgress(type, nextProps, renderExpirationTime); + current$$1.ref = workInProgress.ref; + current$$1.return = workInProgress; + return (workInProgress.child = current$$1); +} +function updateSimpleMemoComponent( + current$$1, + workInProgress, + Component, + nextProps, + updateExpirationTime, + renderExpirationTime +) { + return null !== current$$1 && + updateExpirationTime < renderExpirationTime && + shallowEqual(current$$1.memoizedProps, nextProps) && + current$$1.ref === workInProgress.ref + ? bailoutOnAlreadyFinishedWork( + current$$1, + workInProgress, + renderExpirationTime + ) + : updateFunctionComponent( + current$$1, + workInProgress, + Component, + nextProps, + renderExpirationTime + ); } function markRef(current$$1, workInProgress) { var ref = workInProgress.ref; @@ -3345,22 +3695,30 @@ function updateFunctionComponent( workInProgress, Component, nextProps, - renderExpirationTime + renderExpirationTime$jscomp$0 ) { var unmaskedContext = isContextProvider(Component) ? previousContext : contextStackCursor.current; unmaskedContext = getMaskedContext(workInProgress, unmaskedContext); - prepareToReadContext(workInProgress, renderExpirationTime); - Component = Component(nextProps, unmaskedContext); + prepareToReadContext(workInProgress, renderExpirationTime$jscomp$0); + renderExpirationTime = renderExpirationTime$jscomp$0; + currentlyRenderingFiber$1 = workInProgress; + firstCurrentHook = null !== current$$1 ? current$$1.memoizedState : null; + var nextChildren = Component(nextProps, unmaskedContext); + nextChildren = finishHooks( + Component, + nextProps, + nextChildren, + unmaskedContext + ); workInProgress.effectTag |= 1; reconcileChildren( current$$1, workInProgress, - Component, - renderExpirationTime + nextChildren, + renderExpirationTime$jscomp$0 ); - workInProgress.memoizedProps = nextProps; return workInProgress.child; } function updateClassComponent( @@ -3375,166 +3733,149 @@ function updateClassComponent( pushContextProvider(workInProgress); } else hasContext = !1; prepareToReadContext(workInProgress, renderExpirationTime); - if (null === current$$1) - if (null === workInProgress.stateNode) { - var isLegacyContextConsumer = !1, - unmaskedContext = emptyContextObject; - var context = Component.contextType; - "object" === typeof context && null !== context - ? (context = context.unstable_read()) - : ((unmaskedContext = isContextProvider(Component) - ? previousContext - : contextStackCursor.current), - (isLegacyContextConsumer = Component.contextTypes), - (context = (isLegacyContextConsumer = - null !== isLegacyContextConsumer && - void 0 !== isLegacyContextConsumer) - ? getMaskedContext(workInProgress, unmaskedContext) - : emptyContextObject)); - var instance = new Component(nextProps, context); - workInProgress.memoizedState = - null !== instance.state && void 0 !== instance.state - ? instance.state - : null; - instance.updater = classComponentUpdater; - workInProgress.stateNode = instance; - instance._reactInternalFiber = workInProgress; - isLegacyContextConsumer && - ((isLegacyContextConsumer = workInProgress.stateNode), - (isLegacyContextConsumer.__reactInternalMemoizedUnmaskedChildContext = unmaskedContext), - (isLegacyContextConsumer.__reactInternalMemoizedMaskedChildContext = context)); + if (null === workInProgress.stateNode) + null !== current$$1 && + ((current$$1.alternate = null), + (workInProgress.alternate = null), + (workInProgress.effectTag |= 2)), + constructClassInstance( + workInProgress, + Component, + nextProps, + renderExpirationTime + ), mountClassInstance( workInProgress, Component, nextProps, renderExpirationTime - ); - nextProps = !0; - } else { - unmaskedContext = workInProgress.stateNode; - isLegacyContextConsumer = workInProgress.memoizedProps; - unmaskedContext.props = isLegacyContextConsumer; - var oldContext = unmaskedContext.context; - context = Component.contextType; - "object" === typeof context && null !== context - ? (context = context.unstable_read()) - : ((context = isContextProvider(Component) - ? previousContext - : contextStackCursor.current), - (context = getMaskedContext(workInProgress, context))); - var getDerivedStateFromProps = Component.getDerivedStateFromProps; - (instance = + ), + (nextProps = !0); + else if (null === current$$1) { + var instance = workInProgress.stateNode, + oldProps = workInProgress.memoizedProps; + instance.props = oldProps; + var oldContext = instance.context, + contextType = Component.contextType; + "object" === typeof contextType && null !== contextType + ? (contextType = ReactCurrentOwner$4.currentDispatcher.readContext( + contextType + )) + : ((contextType = isContextProvider(Component) + ? previousContext + : contextStackCursor.current), + (contextType = getMaskedContext(workInProgress, contextType))); + var getDerivedStateFromProps = Component.getDerivedStateFromProps, + hasNewLifecycles = "function" === typeof getDerivedStateFromProps || - "function" === typeof unmaskedContext.getSnapshotBeforeUpdate) || - ("function" !== - typeof unmaskedContext.UNSAFE_componentWillReceiveProps && - "function" !== typeof unmaskedContext.componentWillReceiveProps) || - ((isLegacyContextConsumer !== nextProps || oldContext !== context) && - callComponentWillReceiveProps( - workInProgress, - unmaskedContext, - nextProps, - context - )); - hasForceUpdate = !1; - var oldState = workInProgress.memoizedState; - oldContext = unmaskedContext.state = oldState; - var updateQueue = workInProgress.updateQueue; - null !== updateQueue && - (processUpdateQueue( + "function" === typeof instance.getSnapshotBeforeUpdate; + hasNewLifecycles || + ("function" !== typeof instance.UNSAFE_componentWillReceiveProps && + "function" !== typeof instance.componentWillReceiveProps) || + ((oldProps !== nextProps || oldContext !== contextType) && + callComponentWillReceiveProps( workInProgress, - updateQueue, + instance, nextProps, - unmaskedContext, - renderExpirationTime - ), - (oldContext = workInProgress.memoizedState)); - isLegacyContextConsumer !== nextProps || - oldState !== oldContext || - didPerformWorkStackCursor.current || - hasForceUpdate - ? ("function" === typeof getDerivedStateFromProps && - (applyDerivedStateFromProps( - workInProgress, - Component, - getDerivedStateFromProps, - nextProps - ), - (oldContext = workInProgress.memoizedState)), - (isLegacyContextConsumer = - hasForceUpdate || - checkShouldComponentUpdate( - workInProgress, - Component, - isLegacyContextConsumer, - nextProps, - oldState, - oldContext, - context - )) - ? (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 = context), - (nextProps = isLegacyContextConsumer)) - : ("function" === typeof unmaskedContext.componentDidMount && - (workInProgress.effectTag |= 4), - (nextProps = !1)); - } - else - (unmaskedContext = workInProgress.stateNode), - (isLegacyContextConsumer = workInProgress.memoizedProps), - (unmaskedContext.props = isLegacyContextConsumer), - (oldContext = unmaskedContext.context), - (context = Component.contextType), - "object" === typeof context && null !== context - ? (context = context.unstable_read()) - : ((context = isContextProvider(Component) + contextType + )); + hasForceUpdate = !1; + var oldState = workInProgress.memoizedState; + oldContext = instance.state = oldState; + var updateQueue = workInProgress.updateQueue; + null !== updateQueue && + (processUpdateQueue( + workInProgress, + updateQueue, + nextProps, + instance, + renderExpirationTime + ), + (oldContext = workInProgress.memoizedState)); + oldProps !== nextProps || + oldState !== oldContext || + didPerformWorkStackCursor.current || + hasForceUpdate + ? ("function" === typeof getDerivedStateFromProps && + (applyDerivedStateFromProps( + workInProgress, + Component, + getDerivedStateFromProps, + nextProps + ), + (oldContext = workInProgress.memoizedState)), + (oldProps = + hasForceUpdate || + checkShouldComponentUpdate( + workInProgress, + Component, + oldProps, + nextProps, + oldState, + oldContext, + contextType + )) + ? (hasNewLifecycles || + ("function" !== typeof instance.UNSAFE_componentWillMount && + "function" !== typeof instance.componentWillMount) || + ("function" === typeof instance.componentWillMount && + instance.componentWillMount(), + "function" === typeof instance.UNSAFE_componentWillMount && + instance.UNSAFE_componentWillMount()), + "function" === typeof instance.componentDidMount && + (workInProgress.effectTag |= 4)) + : ("function" === typeof instance.componentDidMount && + (workInProgress.effectTag |= 4), + (workInProgress.memoizedProps = nextProps), + (workInProgress.memoizedState = oldContext)), + (instance.props = nextProps), + (instance.state = oldContext), + (instance.context = contextType), + (nextProps = oldProps)) + : ("function" === typeof instance.componentDidMount && + (workInProgress.effectTag |= 4), + (nextProps = !1)); + } else + (instance = workInProgress.stateNode), + (oldProps = workInProgress.memoizedProps), + (instance.props = oldProps), + (oldContext = instance.context), + (contextType = Component.contextType), + "object" === typeof contextType && null !== contextType + ? (contextType = ReactCurrentOwner$4.currentDispatcher.readContext( + contextType + )) + : ((contextType = isContextProvider(Component) ? previousContext : contextStackCursor.current), - (context = getMaskedContext(workInProgress, context))), + (contextType = getMaskedContext(workInProgress, contextType))), (getDerivedStateFromProps = Component.getDerivedStateFromProps), - (instance = + (hasNewLifecycles = "function" === typeof getDerivedStateFromProps || - "function" === typeof unmaskedContext.getSnapshotBeforeUpdate) || - ("function" !== - typeof unmaskedContext.UNSAFE_componentWillReceiveProps && - "function" !== typeof unmaskedContext.componentWillReceiveProps) || - ((isLegacyContextConsumer !== nextProps || oldContext !== context) && + "function" === typeof instance.getSnapshotBeforeUpdate) || + ("function" !== typeof instance.UNSAFE_componentWillReceiveProps && + "function" !== typeof instance.componentWillReceiveProps) || + ((oldProps !== nextProps || oldContext !== contextType) && callComponentWillReceiveProps( workInProgress, - unmaskedContext, + instance, nextProps, - context + contextType )), (hasForceUpdate = !1), (oldContext = workInProgress.memoizedState), - (oldState = unmaskedContext.state = oldContext), + (oldState = instance.state = oldContext), (updateQueue = workInProgress.updateQueue), null !== updateQueue && (processUpdateQueue( workInProgress, updateQueue, nextProps, - unmaskedContext, + instance, renderExpirationTime ), (oldState = workInProgress.memoizedState)), - isLegacyContextConsumer !== nextProps || + oldProps !== nextProps || oldContext !== oldState || didPerformWorkStackCursor.current || hasForceUpdate @@ -3551,53 +3892,51 @@ function updateClassComponent( checkShouldComponentUpdate( workInProgress, Component, - isLegacyContextConsumer, + oldProps, nextProps, oldContext, oldState, - context + contextType )) - ? (instance || - ("function" !== - typeof unmaskedContext.UNSAFE_componentWillUpdate && - "function" !== typeof unmaskedContext.componentWillUpdate) || - ("function" === typeof unmaskedContext.componentWillUpdate && - unmaskedContext.componentWillUpdate( + ? (hasNewLifecycles || + ("function" !== typeof instance.UNSAFE_componentWillUpdate && + "function" !== typeof instance.componentWillUpdate) || + ("function" === typeof instance.componentWillUpdate && + instance.componentWillUpdate( nextProps, oldState, - context + contextType ), - "function" === - typeof unmaskedContext.UNSAFE_componentWillUpdate && - unmaskedContext.UNSAFE_componentWillUpdate( + "function" === typeof instance.UNSAFE_componentWillUpdate && + instance.UNSAFE_componentWillUpdate( nextProps, oldState, - context + contextType )), - "function" === typeof unmaskedContext.componentDidUpdate && + "function" === typeof instance.componentDidUpdate && (workInProgress.effectTag |= 4), - "function" === typeof unmaskedContext.getSnapshotBeforeUpdate && + "function" === typeof instance.getSnapshotBeforeUpdate && (workInProgress.effectTag |= 256)) - : ("function" !== typeof unmaskedContext.componentDidUpdate || - (isLegacyContextConsumer === current$$1.memoizedProps && + : ("function" !== typeof instance.componentDidUpdate || + (oldProps === current$$1.memoizedProps && oldContext === current$$1.memoizedState) || (workInProgress.effectTag |= 4), - "function" !== typeof unmaskedContext.getSnapshotBeforeUpdate || - (isLegacyContextConsumer === current$$1.memoizedProps && + "function" !== typeof instance.getSnapshotBeforeUpdate || + (oldProps === current$$1.memoizedProps && oldContext === current$$1.memoizedState) || (workInProgress.effectTag |= 256), (workInProgress.memoizedProps = nextProps), (workInProgress.memoizedState = oldState)), - (unmaskedContext.props = nextProps), - (unmaskedContext.state = oldState), - (unmaskedContext.context = context), + (instance.props = nextProps), + (instance.state = oldState), + (instance.context = contextType), (nextProps = getDerivedStateFromProps)) - : ("function" !== typeof unmaskedContext.componentDidUpdate || - (isLegacyContextConsumer === current$$1.memoizedProps && + : ("function" !== typeof instance.componentDidUpdate || + (oldProps === current$$1.memoizedProps && oldContext === current$$1.memoizedState) || (workInProgress.effectTag |= 4), - "function" !== typeof unmaskedContext.getSnapshotBeforeUpdate || - (isLegacyContextConsumer === current$$1.memoizedProps && + "function" !== typeof instance.getSnapshotBeforeUpdate || + (oldProps === current$$1.memoizedProps && oldContext === current$$1.memoizedState) || (workInProgress.effectTag |= 256), (nextProps = !1)); @@ -3656,7 +3995,6 @@ function finishClassComponent( renderExpirationTime ); workInProgress.memoizedState = shouldUpdate.state; - workInProgress.memoizedProps = shouldUpdate.props; hasContext && invalidateContextProvider(workInProgress, Component, !0); return workInProgress.child; } @@ -3682,6 +4020,105 @@ function resolveDefaultProps(Component, baseProps) { } return baseProps; } +function updateSuspenseComponent( + current$$1, + workInProgress, + renderExpirationTime +) { + var mode = workInProgress.mode, + nextProps = workInProgress.pendingProps, + nextState = workInProgress.memoizedState; + null !== nextState && + (nextState.alreadyCaptured + ? null !== current$$1 && nextState === current$$1.memoizedState + ? (nextState = { + alreadyCaptured: !0, + didTimeout: !0, + timedOutAt: nextState.timedOutAt + }) + : ((nextState.alreadyCaptured = !0), (nextState.didTimeout = !0)) + : (nextState = null)); + var nextDidTimeout = null !== nextState && nextState.didTimeout; + if (null === current$$1) + nextDidTimeout + ? ((nextDidTimeout = nextProps.fallback), + (nextProps = createFiberFromFragment(null, mode, 0, null)), + (mode = createFiberFromFragment( + nextDidTimeout, + mode, + renderExpirationTime, + null + )), + (nextProps.sibling = mode), + (renderExpirationTime = nextProps), + (renderExpirationTime.return = mode.return = workInProgress)) + : (renderExpirationTime = mode = mountChildFibers( + workInProgress, + null, + nextProps.children, + renderExpirationTime + )); + else { + var prevState = current$$1.memoizedState; + null !== prevState && prevState.didTimeout + ? ((mode = current$$1.child), + (current$$1 = mode.sibling), + nextDidTimeout + ? ((renderExpirationTime = nextProps.fallback), + (mode = createWorkInProgress(mode, mode.pendingProps, 0)), + (mode.effectTag |= 2), + (nextProps = mode.sibling = createWorkInProgress( + current$$1, + renderExpirationTime, + current$$1.expirationTime + )), + (nextProps.effectTag |= 2), + (renderExpirationTime = mode), + (mode.childExpirationTime = 0), + (mode = nextProps), + (renderExpirationTime.return = mode.return = workInProgress)) + : ((nextDidTimeout = current$$1.child), + (mode = reconcileChildFibers( + workInProgress, + mode.child, + nextProps.children, + renderExpirationTime + )), + reconcileChildFibers( + workInProgress, + nextDidTimeout, + null, + renderExpirationTime + ), + (renderExpirationTime = mode))) + : ((current$$1 = current$$1.child), + nextDidTimeout + ? ((nextDidTimeout = nextProps.fallback), + (nextProps = createFiberFromFragment(null, mode, 0, null)), + (nextProps.effectTag |= 2), + (nextProps.child = current$$1), + (current$$1.return = nextProps), + (mode = nextProps.sibling = createFiberFromFragment( + nextDidTimeout, + mode, + renderExpirationTime, + null + )), + (mode.effectTag |= 2), + (renderExpirationTime = nextProps), + (nextProps.childExpirationTime = 0), + (renderExpirationTime.return = mode.return = workInProgress)) + : (mode = renderExpirationTime = reconcileChildFibers( + workInProgress, + current$$1, + nextProps.children, + renderExpirationTime + ))); + } + workInProgress.memoizedState = nextState; + workInProgress.child = renderExpirationTime; + return mode; +} function bailoutOnAlreadyFinishedWork( current$$1, workInProgress, @@ -3689,9 +4126,7 @@ function bailoutOnAlreadyFinishedWork( ) { null !== current$$1 && (workInProgress.firstContextDependency = current$$1.firstContextDependency); - var childExpirationTime = workInProgress.childExpirationTime; - if (0 === childExpirationTime || childExpirationTime > renderExpirationTime) - return null; + if (workInProgress.childExpirationTime < renderExpirationTime) return null; invariant( null === current$$1 || workInProgress.child === current$$1.child, "Resuming work not yet implemented." @@ -3720,557 +4155,562 @@ function bailoutOnAlreadyFinishedWork( } return workInProgress.child; } -function beginWork(current$$1, workInProgress, renderExpirationTime) { +function beginWork(current$$1, workInProgress, renderExpirationTime$jscomp$0) { var updateExpirationTime = workInProgress.expirationTime; if ( null !== current$$1 && current$$1.memoizedProps === workInProgress.pendingProps && !didPerformWorkStackCursor.current && - (0 === updateExpirationTime || updateExpirationTime > renderExpirationTime) + updateExpirationTime < renderExpirationTime$jscomp$0 ) { switch (workInProgress.tag) { - case 5: + case 3: pushHostRootContext(workInProgress); break; - case 7: + case 5: pushHostContext(workInProgress); break; - case 2: + case 1: isContextProvider(workInProgress.type) && pushContextProvider(workInProgress); break; - case 3: - isContextProvider(workInProgress.type._reactResult) && - pushContextProvider(workInProgress); - break; - case 6: + case 4: pushHostContainer( workInProgress, workInProgress.stateNode.containerInfo ); break; - case 12: + case 10: pushProvider(workInProgress, workInProgress.memoizedProps.value); + break; + case 13: + if ( + ((updateExpirationTime = workInProgress.memoizedState), + null !== updateExpirationTime && updateExpirationTime.didTimeout) + ) { + updateExpirationTime = workInProgress.child.childExpirationTime; + if ( + 0 !== updateExpirationTime && + updateExpirationTime >= renderExpirationTime$jscomp$0 + ) + return updateSuspenseComponent( + current$$1, + workInProgress, + renderExpirationTime$jscomp$0 + ); + workInProgress = bailoutOnAlreadyFinishedWork( + current$$1, + workInProgress, + renderExpirationTime$jscomp$0 + ); + return null !== workInProgress ? workInProgress.sibling : null; + } } return bailoutOnAlreadyFinishedWork( current$$1, workInProgress, - renderExpirationTime + renderExpirationTime$jscomp$0 ); } workInProgress.expirationTime = 0; switch (workInProgress.tag) { - case 4: - var Component = workInProgress.type; - 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 resolvedTag = (workInProgress.tag = resolveLazyComponentTag( - workInProgress, - Component - )), - resolvedProps = resolveDefaultProps(Component, props), - child = void 0; - switch (resolvedTag) { - case 1: - child = updateFunctionComponent( - current$$1, - workInProgress, - Component, - resolvedProps, - renderExpirationTime - ); - break; - case 3: - child = updateClassComponent( - current$$1, - workInProgress, - Component, - resolvedProps, - renderExpirationTime - ); - break; - case 14: - child = updateForwardRef( - current$$1, - workInProgress, - Component, - resolvedProps, - renderExpirationTime - ); - break; - case 18: - child = updatePureComponent( - current$$1, - workInProgress, - Component, - resolvedProps, - updateExpirationTime, - renderExpirationTime - ); - break; - default: - invariant( - !1, - "Element type is invalid. Received a promise that resolves to: %s. Promise elements must resolve to a class or function.", - Component - ); - } - workInProgress.memoizedProps = props; - workInProgress = child; - } else - (updateExpirationTime = getMaskedContext( - workInProgress, - contextStackCursor.current - )), - prepareToReadContext(workInProgress, renderExpirationTime), - (updateExpirationTime = Component(props, updateExpirationTime)), - (workInProgress.effectTag |= 1), - "object" === typeof updateExpirationTime && - null !== updateExpirationTime && - "function" === typeof updateExpirationTime.render && - void 0 === updateExpirationTime.$$typeof - ? ((workInProgress.tag = 2), - isContextProvider(Component) - ? ((resolvedTag = !0), pushContextProvider(workInProgress)) - : (resolvedTag = !1), - (workInProgress.memoizedState = - null !== updateExpirationTime.state && - void 0 !== updateExpirationTime.state - ? updateExpirationTime.state - : null), - (resolvedProps = Component.getDerivedStateFromProps), - "function" === typeof resolvedProps && - applyDerivedStateFromProps( - workInProgress, - Component, - resolvedProps, - props - ), - (updateExpirationTime.updater = classComponentUpdater), - (workInProgress.stateNode = updateExpirationTime), - (updateExpirationTime._reactInternalFiber = workInProgress), - mountClassInstance( - workInProgress, - Component, - props, - renderExpirationTime - ), - (workInProgress = finishClassComponent( - current$$1, - workInProgress, - Component, - !0, - resolvedTag, - renderExpirationTime - ))) - : ((workInProgress.tag = 0), - reconcileChildren( - current$$1, - workInProgress, - updateExpirationTime, - renderExpirationTime - ), - (workInProgress.memoizedProps = props), - (workInProgress = workInProgress.child)); - return workInProgress; - case 0: - return updateFunctionComponent( - current$$1, + case 2: + updateExpirationTime = workInProgress.elementType; + null !== current$$1 && + ((current$$1.alternate = null), + (workInProgress.alternate = null), + (workInProgress.effectTag |= 2)); + current$$1 = workInProgress.pendingProps; + var context = getMaskedContext( workInProgress, - workInProgress.type, - workInProgress.pendingProps, - renderExpirationTime + contextStackCursor.current + ); + prepareToReadContext(workInProgress, renderExpirationTime$jscomp$0); + renderExpirationTime = renderExpirationTime$jscomp$0; + currentlyRenderingFiber$1 = workInProgress; + firstCurrentHook = null; + var value = updateExpirationTime(current$$1, context); + workInProgress.effectTag |= 1; + if ( + "object" === typeof value && + null !== value && + "function" === typeof value.render && + void 0 === value.$$typeof + ) { + workInProgress.tag = 1; + resetHooks(); + isContextProvider(updateExpirationTime) + ? ((context = !0), pushContextProvider(workInProgress)) + : (context = !1); + workInProgress.memoizedState = + null !== value.state && void 0 !== value.state ? value.state : null; + var getDerivedStateFromProps = + updateExpirationTime.getDerivedStateFromProps; + "function" === typeof getDerivedStateFromProps && + applyDerivedStateFromProps( + workInProgress, + updateExpirationTime, + getDerivedStateFromProps, + current$$1 + ); + value.updater = classComponentUpdater; + workInProgress.stateNode = value; + value._reactInternalFiber = workInProgress; + mountClassInstance( + workInProgress, + updateExpirationTime, + current$$1, + renderExpirationTime$jscomp$0 + ); + workInProgress = finishClassComponent( + null, + workInProgress, + updateExpirationTime, + !0, + context, + renderExpirationTime$jscomp$0 + ); + } else + (workInProgress.tag = 0), + (value = finishHooks( + updateExpirationTime, + current$$1, + value, + context + )), + reconcileChildren( + null, + workInProgress, + value, + renderExpirationTime$jscomp$0 + ), + (workInProgress = workInProgress.child); + return workInProgress; + case 16: + value = workInProgress.elementType; + null !== current$$1 && + ((current$$1.alternate = null), + (workInProgress.alternate = null), + (workInProgress.effectTag |= 2)); + context = workInProgress.pendingProps; + current$$1 = readLazyComponentType(value); + workInProgress.type = current$$1; + value = workInProgress.tag = resolveLazyComponentTag(current$$1); + context = resolveDefaultProps(current$$1, context); + getDerivedStateFromProps = void 0; + switch (value) { + case 0: + getDerivedStateFromProps = updateFunctionComponent( + null, + workInProgress, + current$$1, + context, + renderExpirationTime$jscomp$0 + ); + break; + case 1: + getDerivedStateFromProps = updateClassComponent( + null, + workInProgress, + current$$1, + context, + renderExpirationTime$jscomp$0 + ); + break; + case 11: + getDerivedStateFromProps = updateForwardRef( + null, + workInProgress, + current$$1, + context, + renderExpirationTime$jscomp$0 + ); + break; + case 14: + getDerivedStateFromProps = updateMemoComponent( + null, + workInProgress, + current$$1, + resolveDefaultProps(current$$1.type, context), + updateExpirationTime, + renderExpirationTime$jscomp$0 + ); + break; + default: + invariant( + !1, + "Element type is invalid. Received a promise that resolves to: %s. Promise elements must resolve to a class or function.", + current$$1 + ); + } + return getDerivedStateFromProps; + case 0: + return ( + (updateExpirationTime = workInProgress.type), + (value = workInProgress.pendingProps), + (value = + workInProgress.elementType === updateExpirationTime + ? value + : resolveDefaultProps(updateExpirationTime, value)), + updateFunctionComponent( + current$$1, + workInProgress, + updateExpirationTime, + value, + renderExpirationTime$jscomp$0 + ) ); case 1: return ( - (props = workInProgress.type._reactResult), - (Component = workInProgress.pendingProps), - (current$$1 = updateFunctionComponent( + (updateExpirationTime = workInProgress.type), + (value = workInProgress.pendingProps), + (value = + workInProgress.elementType === updateExpirationTime + ? value + : resolveDefaultProps(updateExpirationTime, value)), + updateClassComponent( current$$1, workInProgress, - props, - resolveDefaultProps(props, Component), - renderExpirationTime - )), - (workInProgress.memoizedProps = Component), - current$$1 - ); - case 2: - return updateClassComponent( - current$$1, - workInProgress, - workInProgress.type, - workInProgress.pendingProps, - renderExpirationTime + updateExpirationTime, + value, + renderExpirationTime$jscomp$0 + ) ); case 3: - return ( - (props = workInProgress.type._reactResult), - (Component = workInProgress.pendingProps), - (current$$1 = updateClassComponent( - current$$1, - workInProgress, - props, - resolveDefaultProps(props, Component), - renderExpirationTime - )), - (workInProgress.memoizedProps = Component), - current$$1 - ); - case 5: return ( pushHostRootContext(workInProgress), - (Component = workInProgress.updateQueue), + (updateExpirationTime = workInProgress.updateQueue), invariant( - null !== Component, + 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." ), - (props = workInProgress.memoizedState), - (props = null !== props ? props.element : null), + (value = workInProgress.memoizedState), + (value = null !== value ? value.element : null), processUpdateQueue( workInProgress, - Component, + updateExpirationTime, workInProgress.pendingProps, null, - renderExpirationTime + renderExpirationTime$jscomp$0 ), - (Component = workInProgress.memoizedState.element), - Component === props + (updateExpirationTime = workInProgress.memoizedState.element), + updateExpirationTime === value ? (workInProgress = bailoutOnAlreadyFinishedWork( current$$1, workInProgress, - renderExpirationTime + renderExpirationTime$jscomp$0 )) : (reconcileChildren( current$$1, workInProgress, - Component, - renderExpirationTime + updateExpirationTime, + renderExpirationTime$jscomp$0 ), (workInProgress = workInProgress.child)), workInProgress ); - case 7: + case 5: return ( pushHostContext(workInProgress), null === current$$1 && tryToClaimNextHydratableInstance(workInProgress), - (Component = workInProgress.pendingProps), - (props = Component.children), + (updateExpirationTime = workInProgress.pendingProps.children), markRef(current$$1, workInProgress), reconcileChildren( current$$1, workInProgress, - props, - renderExpirationTime + updateExpirationTime, + renderExpirationTime$jscomp$0 ), - (workInProgress.memoizedProps = Component), (workInProgress = workInProgress.child), workInProgress ); - case 8: + case 6: return ( null === current$$1 && tryToClaimNextHydratableInstance(workInProgress), - (workInProgress.memoizedProps = workInProgress.pendingProps), null ); - case 16: - return ( - (Component = workInProgress.pendingProps), - (props = 0 === (workInProgress.effectTag & 64)), - null !== current$$1 && null !== workInProgress.updateQueue - ? ((workInProgress.updateQueue = null), (props = !0)) - : (props = !props), - 0 !== (workInProgress.mode & 2) && - (props - ? (workInProgress.effectTag |= 4) - : (workInProgress.stateNode = null)), - (updateExpirationTime = Component.children), - (updateExpirationTime = - "function" === typeof updateExpirationTime - ? updateExpirationTime(props) - : props - ? Component.fallback - : updateExpirationTime), - null !== current$$1 && props !== workInProgress.memoizedState - ? ((workInProgress.child = reconcileChildFibers( - workInProgress, - current$$1.child, - null, - renderExpirationTime - )), - (workInProgress.child = reconcileChildFibers( - workInProgress, - null, - updateExpirationTime, - renderExpirationTime - ))) - : reconcileChildren( - current$$1, - workInProgress, - updateExpirationTime, - renderExpirationTime - ), - (workInProgress.memoizedProps = Component), - (workInProgress.memoizedState = props), - workInProgress.child + case 13: + return updateSuspenseComponent( + current$$1, + workInProgress, + renderExpirationTime$jscomp$0 ); - case 6: + case 4: return ( pushHostContainer( workInProgress, workInProgress.stateNode.containerInfo ), - (Component = workInProgress.pendingProps), + (updateExpirationTime = workInProgress.pendingProps), null === current$$1 ? (workInProgress.child = reconcileChildFibers( workInProgress, null, - Component, - renderExpirationTime + updateExpirationTime, + renderExpirationTime$jscomp$0 )) : reconcileChildren( current$$1, workInProgress, - Component, - renderExpirationTime + updateExpirationTime, + renderExpirationTime$jscomp$0 ), - (workInProgress.memoizedProps = Component), workInProgress.child ); - case 13: - return updateForwardRef( - current$$1, - workInProgress, - workInProgress.type, - workInProgress.pendingProps, - renderExpirationTime - ); - case 14: + case 11: return ( - (props = workInProgress.type._reactResult), - (Component = workInProgress.pendingProps), - (current$$1 = updateForwardRef( + (updateExpirationTime = workInProgress.type), + (value = workInProgress.pendingProps), + (value = + workInProgress.elementType === updateExpirationTime + ? value + : resolveDefaultProps(updateExpirationTime, value)), + updateForwardRef( current$$1, workInProgress, - props, - resolveDefaultProps(props, Component), - renderExpirationTime - )), - (workInProgress.memoizedProps = Component), - current$$1 + updateExpirationTime, + value, + renderExpirationTime$jscomp$0 + ) ); - case 9: + case 7: return ( - (Component = workInProgress.pendingProps), reconcileChildren( current$$1, workInProgress, - Component, - renderExpirationTime + workInProgress.pendingProps, + renderExpirationTime$jscomp$0 ), - (workInProgress.memoizedProps = Component), workInProgress.child ); - case 10: + case 8: return ( - (Component = workInProgress.pendingProps.children), reconcileChildren( current$$1, workInProgress, - Component, - renderExpirationTime + workInProgress.pendingProps.children, + renderExpirationTime$jscomp$0 ), - (workInProgress.memoizedProps = Component), - workInProgress.child - ); - case 15: - return ( - (Component = workInProgress.pendingProps), - reconcileChildren( - current$$1, - workInProgress, - Component.children, - renderExpirationTime - ), - (workInProgress.memoizedProps = Component), workInProgress.child ); case 12: + return ( + reconcileChildren( + current$$1, + workInProgress, + workInProgress.pendingProps.children, + renderExpirationTime$jscomp$0 + ), + workInProgress.child + ); + case 10: a: { - Component = workInProgress.type._context; - props = workInProgress.pendingProps; - resolvedTag = workInProgress.memoizedProps; - updateExpirationTime = props.value; - workInProgress.memoizedProps = props; - pushProvider(workInProgress, updateExpirationTime); - if (null !== resolvedTag) - if ( - ((resolvedProps = resolvedTag.value), - (updateExpirationTime = - (resolvedProps === updateExpirationTime && - (0 !== resolvedProps || - 1 / resolvedProps === 1 / updateExpirationTime)) || - (resolvedProps !== resolvedProps && - updateExpirationTime !== updateExpirationTime) - ? 0 - : ("function" === typeof Component._calculateChangedBits - ? Component._calculateChangedBits( - resolvedProps, - updateExpirationTime - ) - : 1073741823) | 0), - 0 === updateExpirationTime) - ) { + updateExpirationTime = workInProgress.type._context; + value = workInProgress.pendingProps; + getDerivedStateFromProps = workInProgress.memoizedProps; + context = value.value; + pushProvider(workInProgress, context); + if (null !== getDerivedStateFromProps) { + var oldValue = getDerivedStateFromProps.value; + context = + (oldValue === context && + (0 !== oldValue || 1 / oldValue === 1 / context)) || + (oldValue !== oldValue && context !== context) + ? 0 + : ("function" === + typeof updateExpirationTime._calculateChangedBits + ? updateExpirationTime._calculateChangedBits( + oldValue, + context + ) + : 1073741823) | 0; + if (0 === context) { if ( - resolvedTag.children === props.children && + getDerivedStateFromProps.children === value.children && !didPerformWorkStackCursor.current ) { workInProgress = bailoutOnAlreadyFinishedWork( current$$1, workInProgress, - renderExpirationTime + renderExpirationTime$jscomp$0 ); break a; } } else for ( - resolvedTag = workInProgress.child, - null !== resolvedTag && (resolvedTag.return = workInProgress); - null !== resolvedTag; + getDerivedStateFromProps = workInProgress.child, + null !== getDerivedStateFromProps && + (getDerivedStateFromProps.return = workInProgress); + null !== getDerivedStateFromProps; ) { - resolvedProps = resolvedTag.firstContextDependency; - if (null !== resolvedProps) { + oldValue = getDerivedStateFromProps.firstContextDependency; + if (null !== oldValue) { do { if ( - resolvedProps.context === Component && - 0 !== (resolvedProps.observedBits & updateExpirationTime) + oldValue.context === updateExpirationTime && + 0 !== (oldValue.observedBits & context) ) { - if (2 === resolvedTag.tag || 3 === resolvedTag.tag) - (child = createUpdate(renderExpirationTime)), - (child.tag = 2), - enqueueUpdate(resolvedTag, child); - if ( - 0 === resolvedTag.expirationTime || - resolvedTag.expirationTime > renderExpirationTime - ) - resolvedTag.expirationTime = renderExpirationTime; - child = resolvedTag.alternate; - null !== child && - (0 === child.expirationTime || - child.expirationTime > renderExpirationTime) && - (child.expirationTime = renderExpirationTime); - for (var node = resolvedTag.return; null !== node; ) { - child = node.alternate; + if (1 === getDerivedStateFromProps.tag) { + var nextFiber = createUpdate( + renderExpirationTime$jscomp$0 + ); + nextFiber.tag = 2; + enqueueUpdate(getDerivedStateFromProps, nextFiber); + } + getDerivedStateFromProps.expirationTime < + renderExpirationTime$jscomp$0 && + (getDerivedStateFromProps.expirationTime = renderExpirationTime$jscomp$0); + nextFiber = getDerivedStateFromProps.alternate; + null !== nextFiber && + nextFiber.expirationTime < + renderExpirationTime$jscomp$0 && + (nextFiber.expirationTime = renderExpirationTime$jscomp$0); + for ( + var node = getDerivedStateFromProps.return; + null !== node; + + ) { + nextFiber = node.alternate; if ( - 0 === node.childExpirationTime || - node.childExpirationTime > renderExpirationTime + node.childExpirationTime < renderExpirationTime$jscomp$0 ) - (node.childExpirationTime = renderExpirationTime), - null !== child && - (0 === child.childExpirationTime || - child.childExpirationTime > - renderExpirationTime) && - (child.childExpirationTime = renderExpirationTime); + (node.childExpirationTime = renderExpirationTime$jscomp$0), + null !== nextFiber && + nextFiber.childExpirationTime < + renderExpirationTime$jscomp$0 && + (nextFiber.childExpirationTime = renderExpirationTime$jscomp$0); else if ( - null !== child && - (0 === child.childExpirationTime || - child.childExpirationTime > renderExpirationTime) + null !== nextFiber && + nextFiber.childExpirationTime < + renderExpirationTime$jscomp$0 ) - child.childExpirationTime = renderExpirationTime; + nextFiber.childExpirationTime = renderExpirationTime$jscomp$0; else break; node = node.return; } } - child = resolvedTag.child; - resolvedProps = resolvedProps.next; - } while (null !== resolvedProps); + nextFiber = getDerivedStateFromProps.child; + oldValue = oldValue.next; + } while (null !== oldValue); } else - child = - 12 === resolvedTag.tag - ? resolvedTag.type === workInProgress.type + nextFiber = + 10 === getDerivedStateFromProps.tag + ? getDerivedStateFromProps.type === workInProgress.type ? null - : resolvedTag.child - : resolvedTag.child; - if (null !== child) child.return = resolvedTag; + : getDerivedStateFromProps.child + : getDerivedStateFromProps.child; + if (null !== nextFiber) + nextFiber.return = getDerivedStateFromProps; else - for (child = resolvedTag; null !== child; ) { - if (child === workInProgress) { - child = null; + for ( + nextFiber = getDerivedStateFromProps; + null !== nextFiber; + + ) { + if (nextFiber === workInProgress) { + nextFiber = null; break; } - resolvedTag = child.sibling; - if (null !== resolvedTag) { - resolvedTag.return = child.return; - child = resolvedTag; + getDerivedStateFromProps = nextFiber.sibling; + if (null !== getDerivedStateFromProps) { + getDerivedStateFromProps.return = nextFiber.return; + nextFiber = getDerivedStateFromProps; break; } - child = child.return; + nextFiber = nextFiber.return; } - resolvedTag = child; + getDerivedStateFromProps = nextFiber; } + } reconcileChildren( current$$1, workInProgress, - props.children, - renderExpirationTime + value.children, + renderExpirationTime$jscomp$0 ); workInProgress = workInProgress.child; } return workInProgress; - case 11: + case 9: return ( - (updateExpirationTime = workInProgress.type), - (Component = workInProgress.pendingProps), - (props = Component.children), - prepareToReadContext(workInProgress, renderExpirationTime), - (updateExpirationTime = readContext( - updateExpirationTime, - Component.unstable_observedBits - )), - (props = props(updateExpirationTime)), + (value = workInProgress.type), + (context = workInProgress.pendingProps), + (updateExpirationTime = context.children), + prepareToReadContext(workInProgress, renderExpirationTime$jscomp$0), + (value = readContext(value, context.unstable_observedBits)), + (updateExpirationTime = updateExpirationTime(value)), (workInProgress.effectTag |= 1), reconcileChildren( current$$1, workInProgress, - props, - renderExpirationTime + updateExpirationTime, + renderExpirationTime$jscomp$0 ), - (workInProgress.memoizedProps = Component), workInProgress.child ); - case 17: - return updatePureComponent( + case 14: + return ( + (value = workInProgress.type), + (context = resolveDefaultProps( + value.type, + workInProgress.pendingProps + )), + updateMemoComponent( + current$$1, + workInProgress, + value, + context, + updateExpirationTime, + renderExpirationTime$jscomp$0 + ) + ); + case 15: + return updateSimpleMemoComponent( current$$1, workInProgress, workInProgress.type, workInProgress.pendingProps, updateExpirationTime, - renderExpirationTime + renderExpirationTime$jscomp$0 ); - case 18: + case 17: return ( - (props = workInProgress.type._reactResult), - (Component = workInProgress.pendingProps), - (current$$1 = updatePureComponent( - current$$1, + (updateExpirationTime = workInProgress.type), + (value = workInProgress.pendingProps), + (value = + workInProgress.elementType === updateExpirationTime + ? value + : resolveDefaultProps(updateExpirationTime, value)), + null !== current$$1 && + ((current$$1.alternate = null), + (workInProgress.alternate = null), + (workInProgress.effectTag |= 2)), + (workInProgress.tag = 1), + isContextProvider(updateExpirationTime) + ? ((current$$1 = !0), pushContextProvider(workInProgress)) + : (current$$1 = !1), + prepareToReadContext(workInProgress, renderExpirationTime$jscomp$0), + constructClassInstance( workInProgress, - props, - resolveDefaultProps(props, Component), updateExpirationTime, - renderExpirationTime - )), - (workInProgress.memoizedProps = Component), - current$$1 + value, + renderExpirationTime$jscomp$0 + ), + mountClassInstance( + workInProgress, + updateExpirationTime, + value, + renderExpirationTime$jscomp$0 + ), + finishClassComponent( + null, + workInProgress, + updateExpirationTime, + !0, + current$$1, + renderExpirationTime$jscomp$0 + ) ); default: invariant( @@ -4279,14 +4719,125 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { ); } } -function appendAllChildren(parent, workInProgress) { +var appendAllChildren = void 0, + updateHostContainer = void 0, + updateHostComponent$1 = void 0, + updateHostText$1 = void 0; +appendAllChildren = function( + parent, + workInProgress, + needsVisibilityToggle, + isHidden +) { for (var node = workInProgress.child; null !== node; ) { - if (7 === node.tag || 8 === node.tag) - FabricUIManager.appendChild(parent.node, node.stateNode.node); - else if (6 !== node.tag && null !== node.child) { - node.child.return = node; - node = node.child; - continue; + a: if (5 === node.tag) { + var instance = node.stateNode; + if (needsVisibilityToggle) throw Error("Not yet implemented."); + FabricUIManager.appendChild(parent.node, instance.node); + } else if (6 === node.tag) { + instance = node.stateNode; + if (needsVisibilityToggle) { + instance = node.memoizedProps; + var rootContainerInstance = requiredContext( + rootInstanceStackCursor.current + ), + currentHostContext = requiredContext(contextStackCursor$1.current); + if (isHidden) throw Error("Not yet implemented."); + instance = createTextInstance( + instance, + rootContainerInstance, + currentHostContext, + workInProgress + ); + node.stateNode = instance; + } + FabricUIManager.appendChild(parent.node, instance.node); + } else if (4 !== node.tag) { + if ( + 13 === node.tag && + ((instance = node.alternate), + null !== instance && + ((instance = instance.memoizedState), + (rootContainerInstance = node.memoizedState), + (rootContainerInstance = + null !== rootContainerInstance && rootContainerInstance.didTimeout), + (null !== instance && instance.didTimeout) !== rootContainerInstance)) + ) { + instance = rootContainerInstance ? node.child : node; + null !== instance && + appendAllChildren(parent, instance, !0, rootContainerInstance); + break a; + } + if (null !== node.child) { + node.child.return = node; + node = node.child; + continue; + } + } + if (node === workInProgress) break; + for (; null === node.sibling; ) { + if (null === node.return || node.return === workInProgress) return; + node = node.return; + } + node.sibling.return = node.return; + node = node.sibling; + } +}; +function appendAllChildrenToContainer( + containerChildSet, + workInProgress, + needsVisibilityToggle, + isHidden +) { + for (var node = workInProgress.child; null !== node; ) { + a: if (5 === node.tag) { + var instance = node.stateNode; + if (needsVisibilityToggle) throw Error("Not yet implemented."); + FabricUIManager.appendChildToSet(containerChildSet, instance.node); + } else if (6 === node.tag) { + instance = node.stateNode; + if (needsVisibilityToggle) { + instance = node.memoizedProps; + var rootContainerInstance = requiredContext( + rootInstanceStackCursor.current + ), + currentHostContext = requiredContext(contextStackCursor$1.current); + if (isHidden) throw Error("Not yet implemented."); + instance = createTextInstance( + instance, + rootContainerInstance, + currentHostContext, + workInProgress + ); + node.stateNode = instance; + } + FabricUIManager.appendChildToSet(containerChildSet, instance.node); + } else if (4 !== node.tag) { + if ( + 13 === node.tag && + ((instance = node.alternate), + null !== instance && + ((instance = instance.memoizedState), + (rootContainerInstance = node.memoizedState), + (rootContainerInstance = + null !== rootContainerInstance && rootContainerInstance.didTimeout), + (null !== instance && instance.didTimeout) !== rootContainerInstance)) + ) { + instance = rootContainerInstance ? node.child : node; + null !== instance && + appendAllChildrenToContainer( + containerChildSet, + instance, + !0, + rootContainerInstance + ); + break a; + } + if (null !== node.child) { + node.child.return = node; + node = node.child; + continue; + } } if (node === workInProgress) break; for (; null === node.sibling; ) { @@ -4297,30 +4848,12 @@ function appendAllChildren(parent, workInProgress) { node = node.sibling; } } -var updateHostContainer = void 0, - updateHostComponent$1 = void 0, - updateHostText$1 = void 0; updateHostContainer = function(workInProgress) { var portalOrRoot = workInProgress.stateNode; if (null !== workInProgress.firstEffect) { var container = portalOrRoot.containerInfo, newChildSet = FabricUIManager.createChildSet(container); - a: for (var node = workInProgress.child; null !== node; ) { - if (7 === node.tag || 8 === node.tag) - FabricUIManager.appendChildToSet(newChildSet, node.stateNode.node); - else if (6 !== node.tag && null !== node.child) { - node.child.return = node; - node = node.child; - continue; - } - if (node === workInProgress) break a; - for (; null === node.sibling; ) { - if (null === node.return || node.return === workInProgress) break a; - node = node.return; - } - node.sibling.return = node.return; - node = node.sibling; - } + appendAllChildrenToContainer(newChildSet, workInProgress, !1, !1); portalOrRoot.pendingChildren = newChildSet; workInProgress.effectTag |= 4; FabricUIManager.completeRoot(container, newChildSet); @@ -4367,7 +4900,7 @@ updateHostComponent$1 = function(current, workInProgress, type, newProps) { (workInProgress.stateNode = type), current ? (workInProgress.effectTag |= 4) - : appendAllChildren(type, workInProgress)); + : appendAllChildren(type, workInProgress, !1, !1)); } }; updateHostText$1 = function(current, workInProgress, oldText, newText) { @@ -4401,7 +4934,6 @@ function logCapturedError(capturedError) { : Error("Unspecified error at:" + componentStack); ExceptionsManager.handleException(error, !1); } -var emptyObject$1 = {}; function logError(boundary, errorInfo) { var source = errorInfo.source, stack = errorInfo.stack; @@ -4418,7 +4950,7 @@ function logError(boundary, errorInfo) { willRetry: !1 }; null !== boundary && - 2 === boundary.tag && + 1 === boundary.tag && ((errorInfo.errorBoundary = boundary.stateNode), (errorInfo.errorBoundaryName = getComponentName(boundary.type)), (errorInfo.errorBoundaryFound = !0), @@ -4442,18 +4974,44 @@ function safelyDetachRef(current$$1) { } else ref.current = null; } +function commitHookEffectList(unmountTag, mountTag, finishedWork) { + finishedWork = finishedWork.updateQueue; + finishedWork = null !== finishedWork ? finishedWork.lastEffect : null; + if (null !== finishedWork) { + var effect = (finishedWork = finishedWork.next); + do { + if (0 !== (effect.tag & unmountTag)) { + var destroy = effect.destroy; + effect.destroy = null; + null !== destroy && destroy(); + } + 0 !== (effect.tag & mountTag) && + ((destroy = effect.create), + (destroy = destroy()), + (effect.destroy = "function" === typeof destroy ? destroy : null)); + effect = effect.next; + } while (effect !== finishedWork); + } +} function commitWork(current$$1, finishedWork) { switch (finishedWork.tag) { - case 2: - case 3: - break; - case 7: - break; - case 8: + case 0: + case 11: + case 14: + case 15: + commitHookEffectList(4, 8, finishedWork); + return; + } + switch (finishedWork.tag) { + case 1: break; case 5: + break; case 6: break; + case 3: + case 4: + break; default: invariant( !1, @@ -4461,9 +5019,6 @@ function commitWork(current$$1, finishedWork) { ); } } -function NoopComponent() { - return null; -} function createRootErrorUpdate(fiber, errorInfo, expirationTime) { expirationTime = createUpdate(expirationTime); expirationTime.tag = 3; @@ -4504,24 +5059,14 @@ function createClassErrorUpdate(fiber, errorInfo, expirationTime) { } function unwindWork(workInProgress) { switch (workInProgress.tag) { - case 2: + case 1: isContextProvider(workInProgress.type) && popContext(workInProgress); var effectTag = workInProgress.effectTag; - return effectTag & 1024 - ? ((workInProgress.effectTag = (effectTag & -1025) | 64), + return effectTag & 2048 + ? ((workInProgress.effectTag = (effectTag & -2049) | 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), @@ -4530,28 +5075,117 @@ function unwindWork(workInProgress) { 0 === (effectTag & 64), "The root failed to unmount after an error. This is likely a bug in React. Please file an issue." ), - (workInProgress.effectTag = (effectTag & -1025) | 64), + (workInProgress.effectTag = (effectTag & -2049) | 64), workInProgress ); - case 7: + case 5: return popHostContext(workInProgress), null; - case 16: - return ( - (effectTag = workInProgress.effectTag), - effectTag & 1024 - ? ((workInProgress.effectTag = (effectTag & -1025) | 64), - workInProgress) - : null - ); - case 6: + case 13: + effectTag = workInProgress.effectTag; + if (effectTag & 2048) { + workInProgress.effectTag = (effectTag & -2049) | 64; + effectTag = workInProgress.alternate; + effectTag = null !== effectTag ? effectTag.memoizedState : null; + var nextState = workInProgress.memoizedState; + null === nextState + ? (nextState = { alreadyCaptured: !0, didTimeout: !1, timedOutAt: 0 }) + : effectTag === nextState + ? (nextState = { + alreadyCaptured: !0, + didTimeout: nextState.didTimeout, + timedOutAt: nextState.timedOutAt + }) + : (nextState.alreadyCaptured = !0); + workInProgress.memoizedState = nextState; + return workInProgress; + } + return null; + case 4: return popHostContainer(workInProgress), null; - case 12: + case 10: return popProvider(workInProgress), null; default: return null; } } -var Dispatcher = { readContext: readContext }, +var Dispatcher = { + readContext: readContext, + useCallback: function(callback, inputs) { + currentlyRenderingFiber$1 = resolveCurrentlyRenderingFiber(); + workInProgressHook = createWorkInProgressHook(); + inputs = void 0 !== inputs && null !== inputs ? inputs : [callback]; + var prevState = workInProgressHook.memoizedState; + if (null !== prevState && inputsAreEqual(inputs, prevState[1])) + return prevState[0]; + workInProgressHook.memoizedState = [callback, inputs]; + return callback; + }, + useContext: function(context, observedBits) { + resolveCurrentlyRenderingFiber(); + return readContext(context, observedBits); + }, + useEffect: function(create, inputs) { + useEffectImpl(516, 192, create, inputs); + }, + useImperativeMethods: function(ref, create, inputs) { + inputs = + null !== inputs && void 0 !== inputs + ? inputs.concat([ref]) + : [ref, create]; + useEffectImpl( + 4, + 36, + function() { + if ("function" === typeof ref) { + var _inst = create(); + ref(_inst); + return function() { + return ref(null); + }; + } + if (null !== ref && void 0 !== ref) + return ( + (_inst = create()), + (ref.current = _inst), + function() { + ref.current = null; + } + ); + }, + inputs + ); + }, + useLayoutEffect: function(create, inputs) { + useEffectImpl(4, 36, create, inputs); + }, + useMemo: function(nextCreate, inputs) { + currentlyRenderingFiber$1 = resolveCurrentlyRenderingFiber(); + workInProgressHook = createWorkInProgressHook(); + inputs = void 0 !== inputs && null !== inputs ? inputs : [nextCreate]; + var prevState = workInProgressHook.memoizedState; + if (null !== prevState && inputsAreEqual(inputs, prevState[1])) + return prevState[0]; + nextCreate = nextCreate(); + workInProgressHook.memoizedState = [nextCreate, inputs]; + return nextCreate; + }, + useMutationEffect: function(create, inputs) { + useEffectImpl(260, 10, create, inputs); + }, + useReducer: useReducer, + useRef: function(initialValue) { + currentlyRenderingFiber$1 = resolveCurrentlyRenderingFiber(); + workInProgressHook = createWorkInProgressHook(); + null === workInProgressHook.memoizedState + ? ((initialValue = { current: initialValue }), + (workInProgressHook.memoizedState = initialValue)) + : (initialValue = workInProgressHook.memoizedState); + return initialValue; + }, + useState: function(initialState) { + return useReducer(basicStateReducer, initialState); + } + }, ReactCurrentOwner$2 = ReactSharedInternals.ReactCurrentOwner, isWorking = !1, nextUnitOfWork = null, @@ -4561,6 +5195,9 @@ var Dispatcher = { readContext: readContext }, nextRenderDidError = !1, nextEffect = null, isCommitting$1 = !1, + rootWithPendingPassiveEffects = null, + passiveEffectCallbackHandle = null, + passiveEffectCallback = null, legacyErrorBoundariesThatAlreadyFailed = null; function resetStack() { if (null !== nextUnitOfWork) @@ -4571,7 +5208,7 @@ function resetStack() { ) { var interruptedWork$jscomp$0 = interruptedWork; switch (interruptedWork$jscomp$0.tag) { - case 2: + case 1: var childContextTypes = interruptedWork$jscomp$0.type.childContextTypes; null !== childContextTypes && @@ -4579,23 +5216,16 @@ function resetStack() { 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 7: + case 5: popHostContext(interruptedWork$jscomp$0); break; - case 6: + case 4: popHostContainer(interruptedWork$jscomp$0); break; - case 12: + case 10: popProvider(interruptedWork$jscomp$0); } interruptedWork = interruptedWork.return; @@ -4606,27 +5236,55 @@ function resetStack() { nextRenderDidError = !1; nextUnitOfWork = null; } +function commitPassiveEffects(root, firstEffect) { + passiveEffectCallback = passiveEffectCallbackHandle = rootWithPendingPassiveEffects = null; + var previousIsRendering = isRendering; + isRendering = !0; + do { + if (firstEffect.effectTag & 512) { + var didError = !1, + error = void 0; + try { + var finishedWork = firstEffect; + commitHookEffectList(128, 0, finishedWork); + commitHookEffectList(0, 64, finishedWork); + } catch (e) { + (didError = !0), (error = e); + } + didError && captureCommitPhaseError(firstEffect, error); + } + firstEffect = firstEffect.nextEffect; + } while (null !== firstEffect); + isRendering = previousIsRendering; + previousIsRendering = root.expirationTime; + 0 !== previousIsRendering && requestWork(root, previousIsRendering); +} +function flushPassiveEffects() { + null !== passiveEffectCallback && + (scheduler.unstable_cancelCallback(passiveEffectCallbackHandle), + passiveEffectCallback()); +} function completeUnitOfWork(workInProgress) { for (;;) { var current$$1 = workInProgress.alternate, returnFiber = workInProgress.return, siblingFiber = workInProgress.sibling; - if (0 === (workInProgress.effectTag & 512)) { + if (0 === (workInProgress.effectTag & 1024)) { var current = current$$1; current$$1 = workInProgress; var instance = current$$1.pendingProps; switch (current$$1.tag) { - case 0: - case 1: - break; case 2: + break; + case 16: + break; + case 15: + case 0: + break; + case 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); instance = current$$1.stateNode; @@ -4637,7 +5295,7 @@ function completeUnitOfWork(workInProgress) { current$$1.effectTag &= -3; updateHostContainer(current$$1); break; - case 7: + case 5: popHostContext(current$$1); var rootContainerInstance = requiredContext( rootInstanceStackCursor.current @@ -4683,7 +5341,7 @@ function completeUnitOfWork(workInProgress) { instance ); instance = { node: rootContainerInstance, canonical: instance }; - appendAllChildren(instance, current$$1); + appendAllChildren(instance, current$$1, !1, !1); current$$1.stateNode = instance; null !== current$$1.ref && (current$$1.effectTag |= 128); } else @@ -4692,7 +5350,7 @@ 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 8: + case 6: current && null != current$$1.stateNode ? updateHostText$1( current, @@ -4716,34 +5374,36 @@ function completeUnitOfWork(workInProgress) { current$$1 ))); break; + case 11: + break; case 13: - case 14: + instance = current$$1.memoizedState; + rootContainerInstance = + null !== current ? current.memoizedState : null; + (null !== instance && instance.didTimeout) !== + (null !== rootContainerInstance && + rootContainerInstance.didTimeout) && (current$$1.effectTag |= 4); break; - case 16: + case 7: break; - case 9: + case 8: break; - case 10: + case 12: break; - case 15: - break; - case 6: + case 4: popHostContainer(current$$1); updateHostContainer(current$$1); break; - case 12: + case 10: popProvider(current$$1); break; - case 11: + case 9: + break; + case 14: break; case 17: - case 18: + isContextProvider(current$$1.type) && popContext(current$$1); break; - 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." - ); default: invariant( !1, @@ -4753,27 +5413,24 @@ function completeUnitOfWork(workInProgress) { nextUnitOfWork = null; current$$1 = workInProgress; if ( - 1073741823 === nextRenderExpirationTime || - 1073741823 !== current$$1.childExpirationTime + 1 === nextRenderExpirationTime || + 1 !== current$$1.childExpirationTime ) { instance = 0; for ( rootContainerInstance = current$$1.child; null !== rootContainerInstance; - ) { - current = rootContainerInstance.expirationTime; - viewConfig = rootContainerInstance.childExpirationTime; - if (0 === instance || (0 !== current && current < instance)) - instance = current; - if (0 === instance || (0 !== viewConfig && viewConfig < instance)) - instance = viewConfig; - rootContainerInstance = rootContainerInstance.sibling; - } + ) + (current = rootContainerInstance.expirationTime), + (viewConfig = rootContainerInstance.childExpirationTime), + current > instance && (instance = current), + viewConfig > instance && (instance = viewConfig), + (rootContainerInstance = rootContainerInstance.sibling); current$$1.childExpirationTime = instance; } null !== returnFiber && - 0 === (returnFiber.effectTag & 512) && + 0 === (returnFiber.effectTag & 1024) && (null === returnFiber.firstEffect && (returnFiber.firstEffect = workInProgress.firstEffect), null !== workInProgress.lastEffect && @@ -4788,10 +5445,10 @@ function completeUnitOfWork(workInProgress) { } else { workInProgress = unwindWork(workInProgress, nextRenderExpirationTime); if (null !== workInProgress) - return (workInProgress.effectTag &= 511), workInProgress; + return (workInProgress.effectTag &= 1023), workInProgress; null !== returnFiber && ((returnFiber.firstEffect = returnFiber.lastEffect = null), - (returnFiber.effectTag |= 512)); + (returnFiber.effectTag |= 1024)); } if (null !== siblingFiber) return siblingFiber; if (null !== returnFiber) workInProgress = returnFiber; @@ -4805,15 +5462,17 @@ function performUnitOfWork(workInProgress) { workInProgress, nextRenderExpirationTime ); + workInProgress.memoizedProps = workInProgress.pendingProps; null === next && (next = completeUnitOfWork(workInProgress)); ReactCurrentOwner$2.current = null; return next; } -function renderRoot(root$jscomp$0, isYieldy, isExpired) { +function renderRoot(root$jscomp$0, isYieldy) { invariant( !isWorking, "renderRoot was called recursively. This error is likely caused by a bug in React. Please file an issue." ); + flushPassiveEffects(); isWorking = !0; ReactCurrentOwner$2.currentDispatcher = Dispatcher; var expirationTime = root$jscomp$0.nextExpirationTimeToWorkOn; @@ -4835,13 +5494,17 @@ function renderRoot(root$jscomp$0, isYieldy, isExpired) { do { try { if (isYieldy) - for (; null !== nextUnitOfWork && !shouldYield(); ) + for (; null !== nextUnitOfWork && !shouldYieldToRenderer(); ) nextUnitOfWork = performUnitOfWork(nextUnitOfWork); else for (; null !== nextUnitOfWork; ) nextUnitOfWork = performUnitOfWork(nextUnitOfWork); } catch (thrownValue) { - if (null === nextUnitOfWork) + if ( + ((lastContextWithAllBitsObserved = lastContextDependency = currentlyRenderingFiber = null), + resetHooks(), + null === nextUnitOfWork) + ) (didFatal = !0), onUncaughtError(thrownValue); else { invariant( @@ -4858,7 +5521,7 @@ function renderRoot(root$jscomp$0, isYieldy, isExpired) { sourceFiber$jscomp$0 = sourceFiber, value = thrownValue; returnFiber = nextRenderExpirationTime; - sourceFiber$jscomp$0.effectTag |= 512; + sourceFiber$jscomp$0.effectTag |= 1024; sourceFiber$jscomp$0.firstEffect = sourceFiber$jscomp$0.lastEffect = null; if ( null !== value && @@ -4870,56 +5533,57 @@ function renderRoot(root$jscomp$0, isYieldy, isExpired) { var earliestTimeoutMs = -1, startTimeMs = -1; do { - if (16 === value.tag) { - var current = value.alternate; + if (13 === value.tag) { + var current$$1 = value.alternate; if ( - null !== current && - !0 === current.memoizedState && - null !== current.stateNode + null !== current$$1 && + ((current$$1 = current$$1.memoizedState), + null !== current$$1 && current$$1.didTimeout) ) { - startTimeMs = 10 * (current.stateNode.timedOutAt - 2); + startTimeMs = 10 * (1073741822 - current$$1.timedOutAt); break; } - current = value.pendingProps.maxDuration; - if ("number" === typeof current) - if (0 >= current) earliestTimeoutMs = 0; + current$$1 = value.pendingProps.maxDuration; + if ("number" === typeof current$$1) + if (0 >= current$$1) earliestTimeoutMs = 0; else if ( -1 === earliestTimeoutMs || - current < earliestTimeoutMs + current$$1 < earliestTimeoutMs ) - earliestTimeoutMs = current; + earliestTimeoutMs = current$$1; } value = value.return; } while (null !== value); value = returnFiber$jscomp$0; do { - if (16 === value.tag && !value.memoizedState) { + if ((current$$1 = 13 === value.tag)) + void 0 === value.memoizedProps.fallback + ? (current$$1 = !1) + : ((current$$1 = value.memoizedState), + (current$$1 = + null === current$$1 || !current$$1.didTimeout)); + if (current$$1) { returnFiber$jscomp$0 = retrySuspendedRoot.bind( null, root, value, - 0 === (value.mode & 1) ? 1 : returnFiber + sourceFiber$jscomp$0, + 0 === (value.mode & 1) ? 1073741823 : returnFiber ); thenable.then(returnFiber$jscomp$0, returnFiber$jscomp$0); - if (0 === (value.mode & 2)) { - value.effectTag |= 4; + if (0 === (value.mode & 1)) { + value.effectTag |= 32; reconcileChildren( sourceFiber$jscomp$0.alternate, sourceFiber$jscomp$0, null, returnFiber ); - sourceFiber$jscomp$0.effectTag &= -513; - 4 === sourceFiber$jscomp$0.tag && - (sourceFiber$jscomp$0.tag = 0); - if ( - 2 === sourceFiber$jscomp$0.tag || - 3 === sourceFiber$jscomp$0.tag - ) - (sourceFiber$jscomp$0.effectTag &= -421), - null === sourceFiber$jscomp$0.alternate && - ((sourceFiber$jscomp$0.tag = 0), - (sourceFiber$jscomp$0.type = NoopComponent)); + sourceFiber$jscomp$0.effectTag &= -1025; + sourceFiber$jscomp$0.effectTag &= -933; + 1 === sourceFiber$jscomp$0.tag && + null === sourceFiber$jscomp$0.alternate && + (sourceFiber$jscomp$0.tag = 17); break a; } -1 === earliestTimeoutMs @@ -4927,24 +5591,27 @@ function renderRoot(root$jscomp$0, isYieldy, isExpired) { : (-1 === startTimeMs && (startTimeMs = 10 * - (findEarliestOutstandingPriorityLevel( - root, - returnFiber - ) - - 2) - + (1073741822 - + findEarliestOutstandingPriorityLevel( + root, + returnFiber + )) - 5e3), (root = startTimeMs + earliestTimeoutMs)); 0 <= root && nextLatestAbsoluteTimeoutMs < root && (nextLatestAbsoluteTimeoutMs = root); - value.effectTag |= 1024; + value.effectTag |= 2048; value.expirationTime = returnFiber; break a; } value = value.return; } while (null !== value); value = Error( - "An update was suspended, but no placeholder UI was provided." + (getComponentName(sourceFiber$jscomp$0.type) || + "A React component") + + " suspended while rendering, but no fallback UI was specified.\n\nAdd a component higher in the tree to provide a loading indicator or placeholder to display." + + getStackByFiberInDevAndProd(sourceFiber$jscomp$0) ); } nextRenderDidError = !0; @@ -4952,9 +5619,9 @@ function renderRoot(root$jscomp$0, isYieldy, isExpired) { root = returnFiber$jscomp$0; do { switch (root.tag) { - case 5: + case 3: sourceFiber$jscomp$0 = value; - root.effectTag |= 1024; + root.effectTag |= 2048; root.expirationTime = returnFiber; returnFiber = createRootErrorUpdate( root, @@ -4963,8 +5630,7 @@ function renderRoot(root$jscomp$0, isYieldy, isExpired) { ); enqueueCapturedUpdate(root, returnFiber); break a; - case 2: - case 3: + case 1: if ( ((sourceFiber$jscomp$0 = value), (returnFiber$jscomp$0 = root.type), @@ -4979,7 +5645,7 @@ function renderRoot(root$jscomp$0, isYieldy, isExpired) { thenable ))))) ) { - root.effectTag |= 1024; + root.effectTag |= 2048; root.expirationTime = returnFiber; returnFiber = createClassErrorUpdate( root, @@ -5002,183 +5668,170 @@ function renderRoot(root$jscomp$0, isYieldy, isExpired) { } while (1); isWorking = !1; lastContextWithAllBitsObserved = lastContextDependency = currentlyRenderingFiber = ReactCurrentOwner$2.currentDispatcher = null; + resetHooks(); if (didFatal) (nextRoot = null), (root$jscomp$0.finishedWork = null); else if (null !== nextUnitOfWork) root$jscomp$0.finishedWork = null; else { - isYieldy = root$jscomp$0.current.alternate; + didFatal = root$jscomp$0.current.alternate; invariant( - null !== isYieldy, + null !== didFatal, "Finished root should have a work-in-progress. This error is likely caused by a bug in React. Please file an issue." ); nextRoot = null; if (nextRenderDidError) { - didFatal = root$jscomp$0.latestPendingTime; - sourceFiber = root$jscomp$0.latestSuspendedTime; - returnFiber = root$jscomp$0.latestPingedTime; + sourceFiber = root$jscomp$0.latestPendingTime; + returnFiber = root$jscomp$0.latestSuspendedTime; + root = root$jscomp$0.latestPingedTime; if ( - (0 !== didFatal && didFatal > expirationTime) || - (0 !== sourceFiber && sourceFiber > expirationTime) || - (0 !== returnFiber && returnFiber > expirationTime) + (0 !== sourceFiber && sourceFiber < expirationTime) || + (0 !== returnFiber && returnFiber < expirationTime) || + (0 !== root && root < expirationTime) ) { markSuspendedPriorityLevel(root$jscomp$0, expirationTime); onSuspend( root$jscomp$0, - isYieldy, + didFatal, expirationTime, root$jscomp$0.expirationTime, -1 ); return; } - if (!root$jscomp$0.didError && !isExpired) { + if (!root$jscomp$0.didError && isYieldy) { root$jscomp$0.didError = !0; expirationTime = root$jscomp$0.nextExpirationTimeToWorkOn = expirationTime; - isExpired = root$jscomp$0.expirationTime = 1; - onSuspend(root$jscomp$0, isYieldy, expirationTime, isExpired, -1); + isYieldy = root$jscomp$0.expirationTime = 1073741823; + onSuspend(root$jscomp$0, didFatal, expirationTime, isYieldy, -1); return; } } - isExpired || -1 === nextLatestAbsoluteTimeoutMs - ? ((root$jscomp$0.pendingCommitExpirationTime = expirationTime), - (root$jscomp$0.finishedWork = isYieldy)) - : (markSuspendedPriorityLevel(root$jscomp$0, expirationTime), - (isExpired = + isYieldy && -1 !== nextLatestAbsoluteTimeoutMs + ? (markSuspendedPriorityLevel(root$jscomp$0, expirationTime), + (isYieldy = 10 * - (findEarliestOutstandingPriorityLevel(root$jscomp$0, expirationTime) - - 2)), - isExpired < nextLatestAbsoluteTimeoutMs && - (nextLatestAbsoluteTimeoutMs = isExpired), - (isExpired = 10 * (requestCurrentTime() - 2)), - (isExpired = nextLatestAbsoluteTimeoutMs - isExpired), + (1073741822 - + findEarliestOutstandingPriorityLevel( + root$jscomp$0, + expirationTime + ))), + isYieldy < nextLatestAbsoluteTimeoutMs && + (nextLatestAbsoluteTimeoutMs = isYieldy), + (isYieldy = 10 * (1073741822 - requestCurrentTime())), + (isYieldy = nextLatestAbsoluteTimeoutMs - isYieldy), onSuspend( root$jscomp$0, - isYieldy, + didFatal, expirationTime, root$jscomp$0.expirationTime, - 0 > isExpired ? 0 : isExpired - )); + 0 > isYieldy ? 0 : isYieldy + )) + : ((root$jscomp$0.pendingCommitExpirationTime = expirationTime), + (root$jscomp$0.finishedWork = didFatal)); } } -function captureCommitPhaseError(fiber, error) { - var JSCompiler_inline_result; - a: { - invariant( - !isWorking || isCommitting$1, - "dispatch: Cannot dispatch during the render phase." - ); - for ( - JSCompiler_inline_result = fiber.return; - null !== JSCompiler_inline_result; - - ) { - switch (JSCompiler_inline_result.tag) { - case 2: - case 3: - var instance = JSCompiler_inline_result.stateNode; - if ( - "function" === - typeof JSCompiler_inline_result.type.getDerivedStateFromError || - ("function" === typeof instance.componentDidCatch && - (null === legacyErrorBoundariesThatAlreadyFailed || - !legacyErrorBoundariesThatAlreadyFailed.has(instance))) - ) { - fiber = createCapturedValue(error, fiber); - fiber = createClassErrorUpdate(JSCompiler_inline_result, fiber, 1); - enqueueUpdate(JSCompiler_inline_result, fiber); - scheduleWork(JSCompiler_inline_result, 1); - JSCompiler_inline_result = void 0; - break a; - } - break; - case 5: - fiber = createCapturedValue(error, fiber); - fiber = createRootErrorUpdate(JSCompiler_inline_result, fiber, 1); - enqueueUpdate(JSCompiler_inline_result, fiber); - scheduleWork(JSCompiler_inline_result, 1); - JSCompiler_inline_result = void 0; - break a; - } - JSCompiler_inline_result = JSCompiler_inline_result.return; +function captureCommitPhaseError(sourceFiber, value) { + for (var fiber = sourceFiber.return; null !== fiber; ) { + switch (fiber.tag) { + case 1: + var instance = fiber.stateNode; + if ( + "function" === typeof fiber.type.getDerivedStateFromError || + ("function" === typeof instance.componentDidCatch && + (null === legacyErrorBoundariesThatAlreadyFailed || + !legacyErrorBoundariesThatAlreadyFailed.has(instance))) + ) { + sourceFiber = createCapturedValue(value, sourceFiber); + sourceFiber = createClassErrorUpdate(fiber, sourceFiber, 1073741823); + enqueueUpdate(fiber, sourceFiber); + scheduleWork(fiber, 1073741823); + return; + } + break; + case 3: + sourceFiber = createCapturedValue(value, sourceFiber); + sourceFiber = createRootErrorUpdate(fiber, sourceFiber, 1073741823); + enqueueUpdate(fiber, sourceFiber); + scheduleWork(fiber, 1073741823); + return; } - 5 === fiber.tag && - ((JSCompiler_inline_result = createCapturedValue(error, fiber)), - (JSCompiler_inline_result = createRootErrorUpdate( - fiber, - JSCompiler_inline_result, - 1 - )), - enqueueUpdate(fiber, JSCompiler_inline_result), - scheduleWork(fiber, 1)); - JSCompiler_inline_result = void 0; + fiber = fiber.return; } - return JSCompiler_inline_result; + 3 === sourceFiber.tag && + ((fiber = createCapturedValue(value, sourceFiber)), + (fiber = createRootErrorUpdate(sourceFiber, fiber, 1073741823)), + enqueueUpdate(sourceFiber, fiber), + scheduleWork(sourceFiber, 1073741823)); } function computeExpirationForFiber(currentTime, fiber) { isWorking - ? (currentTime = isCommitting$1 ? 1 : nextRenderExpirationTime) + ? (currentTime = isCommitting$1 ? 1073741823 : nextRenderExpirationTime) : fiber.mode & 1 ? ((currentTime = isBatchingInteractiveUpdates - ? 2 + 10 * ((((currentTime - 2 + 15) / 10) | 0) + 1) - : 2 + 25 * ((((currentTime - 2 + 500) / 25) | 0) + 1)), + ? 1073741822 - 10 * ((((1073741822 - currentTime + 15) / 10) | 0) + 1) + : 1073741822 - + 25 * ((((1073741822 - currentTime + 500) / 25) | 0) + 1)), null !== nextRoot && currentTime === nextRenderExpirationTime && - (currentTime += 1)) - : (currentTime = 1); + --currentTime) + : (currentTime = 1073741823); isBatchingInteractiveUpdates && - currentTime > lowestPriorityPendingInteractiveExpirationTime && + (0 === lowestPriorityPendingInteractiveExpirationTime || + currentTime < lowestPriorityPendingInteractiveExpirationTime) && (lowestPriorityPendingInteractiveExpirationTime = currentTime); return currentTime; } -function retrySuspendedRoot(root, fiber, suspendedTime) { +function retrySuspendedRoot(root, boundaryFiber, sourceFiber, suspendedTime) { var retryTime = root.earliestSuspendedTime; var latestSuspendedTime = root.latestSuspendedTime; if ( 0 !== retryTime && - suspendedTime >= retryTime && - suspendedTime <= latestSuspendedTime + suspendedTime <= retryTime && + suspendedTime >= latestSuspendedTime ) { latestSuspendedTime = retryTime = suspendedTime; root.didError = !1; var latestPingedTime = root.latestPingedTime; - if (0 === latestPingedTime || latestPingedTime < latestSuspendedTime) + if (0 === latestPingedTime || latestPingedTime > latestSuspendedTime) root.latestPingedTime = latestSuspendedTime; findNextExpirationTimeToWorkOn(latestSuspendedTime, root); } else (retryTime = requestCurrentTime()), - (retryTime = computeExpirationForFiber(retryTime, fiber)), + (retryTime = computeExpirationForFiber(retryTime, boundaryFiber)), markPendingPriorityLevel(root, retryTime); - 0 !== (fiber.mode & 1) && + 0 !== (boundaryFiber.mode & 1) && root === nextRoot && nextRenderExpirationTime === suspendedTime && (nextRoot = null); - scheduleWorkToRoot(fiber, retryTime); - fiber = root.expirationTime; - 0 !== fiber && requestWork(root, fiber); + scheduleWorkToRoot(boundaryFiber, retryTime); + 0 === (boundaryFiber.mode & 1) && + (scheduleWorkToRoot(sourceFiber, retryTime), + 1 === sourceFiber.tag && + null !== sourceFiber.stateNode && + ((boundaryFiber = createUpdate(retryTime)), + (boundaryFiber.tag = 2), + enqueueUpdate(sourceFiber, boundaryFiber))); + sourceFiber = root.expirationTime; + 0 !== sourceFiber && requestWork(root, sourceFiber); } function scheduleWorkToRoot(fiber, expirationTime) { - if (0 === fiber.expirationTime || fiber.expirationTime > expirationTime) - fiber.expirationTime = expirationTime; + fiber.expirationTime < expirationTime && + (fiber.expirationTime = expirationTime); var alternate = fiber.alternate; null !== alternate && - (0 === alternate.expirationTime || - alternate.expirationTime > expirationTime) && + alternate.expirationTime < expirationTime && (alternate.expirationTime = expirationTime); var node = fiber.return, root = null; - if (null === node && 5 === fiber.tag) root = fiber.stateNode; + if (null === node && 3 === fiber.tag) root = fiber.stateNode; else for (; null !== node; ) { alternate = node.alternate; - if ( - 0 === node.childExpirationTime || - node.childExpirationTime > expirationTime - ) - node.childExpirationTime = expirationTime; + node.childExpirationTime < expirationTime && + (node.childExpirationTime = expirationTime); null !== alternate && - (0 === alternate.childExpirationTime || - alternate.childExpirationTime > expirationTime) && + alternate.childExpirationTime < expirationTime && (alternate.childExpirationTime = expirationTime); - if (null === node.return && 5 === node.tag) { + if (null === node.return && 3 === node.tag) { root = node.stateNode; break; } @@ -5191,7 +5844,7 @@ function scheduleWork(fiber, expirationTime) { null !== fiber && (!isWorking && 0 !== nextRenderExpirationTime && - expirationTime < nextRenderExpirationTime && + expirationTime > nextRenderExpirationTime && resetStack(), markPendingPriorityLevel(fiber, expirationTime), (isWorking && !isCommitting$1 && nextRoot === fiber) || @@ -5211,27 +5864,25 @@ var firstScheduledRoot = null, nextFlushedRoot = null, nextFlushedExpirationTime = 0, lowestPriorityPendingInteractiveExpirationTime = 0, - deadlineDidExpire = !1, hasUnhandledError = !1, unhandledError = null, - deadline = null, isBatchingUpdates = !1, isUnbatchingUpdates = !1, isBatchingInteractiveUpdates = !1, completedBatches = null, originalStartTimeMs = now$1(), - currentRendererTime = ((originalStartTimeMs / 10) | 0) + 2, + currentRendererTime = 1073741822 - ((originalStartTimeMs / 10) | 0), currentSchedulerTime = currentRendererTime, NESTED_UPDATE_LIMIT = 50, nestedUpdateCount = 0, - lastCommittedRootDuringThisBatch = null, - timeHeuristicForUnitOfWork = 1; + lastCommittedRootDuringThisBatch = null; function recomputeCurrentRendererTime() { - currentRendererTime = (((now$1() - originalStartTimeMs) / 10) | 0) + 2; + currentRendererTime = + 1073741822 - (((now$1() - originalStartTimeMs) / 10) | 0); } function scheduleCallbackWithExpirationTime(root, expirationTime) { if (0 !== callbackExpirationTime) { - if (expirationTime > callbackExpirationTime) return; + if (expirationTime < callbackExpirationTime) return; null !== callbackID && ((root = callbackID), (scheduledCallback = null), clearTimeout(root)); } @@ -5248,7 +5899,7 @@ function onSuspend( msUntilTimeout ) { root.expirationTime = rootExpirationTime; - 0 !== msUntilTimeout || shouldYield() + 0 !== msUntilTimeout || shouldYieldToRenderer() ? 0 < msUntilTimeout && (root.timeoutHandle = scheduleTimeout( onTimeout.bind(null, root, finishedWork, suspendedExpirationTime), @@ -5268,44 +5919,35 @@ function onTimeout(root, finishedWork, suspendedExpirationTime) { ); nextFlushedRoot = root; nextFlushedExpirationTime = suspendedExpirationTime; - performWorkOnRoot(root, suspendedExpirationTime, !0); - performWork(1, null); + performWorkOnRoot(root, suspendedExpirationTime, !1); + performWork(1073741823, !1); } function requestCurrentTime() { if (isRendering) return currentSchedulerTime; findHighestPriorityRoot(); - if ( - 0 === nextFlushedExpirationTime || - 1073741823 === nextFlushedExpirationTime - ) + if (0 === nextFlushedExpirationTime || 1 === nextFlushedExpirationTime) recomputeCurrentRendererTime(), (currentSchedulerTime = currentRendererTime); return currentSchedulerTime; } function requestWork(root, expirationTime) { - if (null === root.nextScheduledRoot) - (root.expirationTime = expirationTime), + 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; - } + (lastScheduledRoot.nextScheduledRoot = firstScheduledRoot))) + : expirationTime > root.expirationTime && + (root.expirationTime = expirationTime); isRendering || (isBatchingUpdates ? isUnbatchingUpdates && ((nextFlushedRoot = root), - (nextFlushedExpirationTime = 1), - performWorkOnRoot(root, 1, !0)) - : 1 === expirationTime - ? performWork(1, null) + (nextFlushedExpirationTime = 1073741823), + performWorkOnRoot(root, 1073741823, !1)) + : 1073741823 === expirationTime + ? performWork(1073741823, !1) : scheduleCallbackWithExpirationTime(root, expirationTime)); } function findHighestPriorityRoot() { @@ -5341,14 +5983,11 @@ function findHighestPriorityRoot() { (root.nextScheduledRoot = null); root = previousScheduledRoot.nextScheduledRoot; } else { - if ( - 0 === highestPriorityWork || - remainingExpirationTime < highestPriorityWork - ) - (highestPriorityWork = remainingExpirationTime), - (highestPriorityRoot = root); + remainingExpirationTime > highestPriorityWork && + ((highestPriorityWork = remainingExpirationTime), + (highestPriorityRoot = root)); if (root === lastScheduledRoot) break; - if (1 === highestPriorityWork) break; + if (1073741823 === highestPriorityWork) break; previousScheduledRoot = root; root = root.nextScheduledRoot; } @@ -5356,38 +5995,44 @@ function findHighestPriorityRoot() { nextFlushedRoot = highestPriorityRoot; 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); +var didYield = !1; +function shouldYieldToRenderer() { + return didYield ? !0 : frameDeadline <= now$1() ? (didYield = !0) : !1; } -function performWork(minExpirationTime, dl) { - deadline = dl; +function performAsyncWork() { + try { + if (!shouldYieldToRenderer() && 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, !0); + } finally { + didYield = !1; + } +} +function performWork(minExpirationTime, isYieldy) { findHighestPriorityRoot(); - if (null !== deadline) + if (isYieldy) for ( recomputeCurrentRendererTime(), currentSchedulerTime = currentRendererTime; null !== nextFlushedRoot && 0 !== nextFlushedExpirationTime && - (0 === minExpirationTime || - minExpirationTime >= nextFlushedExpirationTime) && - (!deadlineDidExpire || currentRendererTime >= nextFlushedExpirationTime); + minExpirationTime <= nextFlushedExpirationTime && + !(didYield && currentRendererTime > nextFlushedExpirationTime); ) performWorkOnRoot( nextFlushedRoot, nextFlushedExpirationTime, - currentRendererTime >= nextFlushedExpirationTime + currentRendererTime > nextFlushedExpirationTime ), findHighestPriorityRoot(), recomputeCurrentRendererTime(), @@ -5397,29 +6042,28 @@ function performWork(minExpirationTime, dl) { ; null !== nextFlushedRoot && 0 !== nextFlushedExpirationTime && - (0 === minExpirationTime || - minExpirationTime >= nextFlushedExpirationTime); + minExpirationTime <= nextFlushedExpirationTime; ) - performWorkOnRoot(nextFlushedRoot, nextFlushedExpirationTime, !0), + performWorkOnRoot(nextFlushedRoot, nextFlushedExpirationTime, !1), findHighestPriorityRoot(); - null !== deadline && ((callbackExpirationTime = 0), (callbackID = null)); + isYieldy && ((callbackExpirationTime = 0), (callbackID = null)); 0 !== nextFlushedExpirationTime && scheduleCallbackWithExpirationTime( nextFlushedRoot, nextFlushedExpirationTime ); - deadline = null; - deadlineDidExpire = !1; nestedUpdateCount = 0; lastCommittedRootDuringThisBatch = null; if (null !== completedBatches) for ( - minExpirationTime = completedBatches, completedBatches = null, dl = 0; - dl < minExpirationTime.length; - dl++ + minExpirationTime = completedBatches, + completedBatches = null, + isYieldy = 0; + isYieldy < minExpirationTime.length; + isYieldy++ ) { - var batch = minExpirationTime[dl]; + var batch = minExpirationTime[isYieldy]; try { batch._onComplete(); } catch (error) { @@ -5433,45 +6077,45 @@ function performWork(minExpirationTime, dl) { (hasUnhandledError = !1), minExpirationTime); } -function performWorkOnRoot(root, expirationTime, isExpired) { +function performWorkOnRoot(root, expirationTime, isYieldy) { invariant( !isRendering, "performWorkOnRoot was called recursively. This error is likely caused by a bug in React. Please file an issue." ); isRendering = !0; - if (null === deadline || isExpired) { - var finishedWork = root.finishedWork; - null !== finishedWork - ? completeRoot$1(root, finishedWork, expirationTime) + if (isYieldy) { + var _finishedWork = root.finishedWork; + null !== _finishedWork + ? completeRoot$1(root, _finishedWork, expirationTime) : ((root.finishedWork = null), - (finishedWork = root.timeoutHandle), - -1 !== finishedWork && - ((root.timeoutHandle = -1), cancelTimeout(finishedWork)), - renderRoot(root, !1, isExpired), - (finishedWork = root.finishedWork), - null !== finishedWork && - completeRoot$1(root, finishedWork, expirationTime)); + (_finishedWork = root.timeoutHandle), + -1 !== _finishedWork && + ((root.timeoutHandle = -1), cancelTimeout(_finishedWork)), + renderRoot(root, isYieldy), + (_finishedWork = root.finishedWork), + null !== _finishedWork && + (shouldYieldToRenderer() + ? (root.finishedWork = _finishedWork) + : completeRoot$1(root, _finishedWork, expirationTime))); } else - (finishedWork = root.finishedWork), - null !== finishedWork - ? completeRoot$1(root, finishedWork, expirationTime) + (_finishedWork = root.finishedWork), + null !== _finishedWork + ? completeRoot$1(root, _finishedWork, expirationTime) : ((root.finishedWork = null), - (finishedWork = root.timeoutHandle), - -1 !== finishedWork && - ((root.timeoutHandle = -1), cancelTimeout(finishedWork)), - renderRoot(root, !0, isExpired), - (finishedWork = root.finishedWork), - null !== finishedWork && - (shouldYield() - ? (root.finishedWork = finishedWork) - : completeRoot$1(root, finishedWork, expirationTime))); + (_finishedWork = root.timeoutHandle), + -1 !== _finishedWork && + ((root.timeoutHandle = -1), cancelTimeout(_finishedWork)), + renderRoot(root, isYieldy), + (_finishedWork = root.finishedWork), + null !== _finishedWork && + completeRoot$1(root, _finishedWork, expirationTime)); isRendering = !1; } function completeRoot$1(root, finishedWork$jscomp$0, expirationTime) { var firstBatch = root.firstBatch; if ( null !== firstBatch && - firstBatch._expirationTime <= expirationTime && + firstBatch._expirationTime >= expirationTime && (null === completedBatches ? (completedBatches = [firstBatch]) : completedBatches.push(firstBatch), @@ -5500,9 +6144,7 @@ function completeRoot$1(root, finishedWork$jscomp$0, expirationTime) { var childExpirationTimeBeforeCommit = finishedWork$jscomp$0.childExpirationTime; firstBatch = - 0 === firstBatch || - (0 !== childExpirationTimeBeforeCommit && - childExpirationTimeBeforeCommit < firstBatch) + childExpirationTimeBeforeCommit > firstBatch ? childExpirationTimeBeforeCommit : firstBatch; root.didError = !1; @@ -5514,19 +6156,19 @@ function completeRoot$1(root, finishedWork$jscomp$0, expirationTime) { (root.latestPingedTime = 0)) : ((childExpirationTimeBeforeCommit = root.latestPendingTime), 0 !== childExpirationTimeBeforeCommit && - (childExpirationTimeBeforeCommit < firstBatch + (childExpirationTimeBeforeCommit > firstBatch ? (root.earliestPendingTime = root.latestPendingTime = 0) - : root.earliestPendingTime < firstBatch && + : root.earliestPendingTime > firstBatch && (root.earliestPendingTime = root.latestPendingTime)), (childExpirationTimeBeforeCommit = root.earliestSuspendedTime), 0 === childExpirationTimeBeforeCommit ? markPendingPriorityLevel(root, firstBatch) - : firstBatch > root.latestSuspendedTime + : firstBatch < root.latestSuspendedTime ? ((root.earliestSuspendedTime = 0), (root.latestSuspendedTime = 0), (root.latestPingedTime = 0), markPendingPriorityLevel(root, firstBatch)) - : firstBatch < childExpirationTimeBeforeCommit && + : firstBatch > childExpirationTimeBeforeCommit && markPendingPriorityLevel(root, firstBatch)); findNextExpirationTimeToWorkOn(0, root); ReactCurrentOwner$2.current = null; @@ -5538,16 +6180,20 @@ function completeRoot$1(root, finishedWork$jscomp$0, expirationTime) { : (firstBatch = finishedWork$jscomp$0.firstEffect); for (nextEffect = firstBatch; null !== nextEffect; ) { childExpirationTimeBeforeCommit = !1; - var error = void 0; + var error$jscomp$0 = void 0; try { for (; null !== nextEffect; ) { - if (nextEffect.effectTag & 256) { - var current$$1 = nextEffect.alternate; + if (nextEffect.effectTag & 256) a: { - var finishedWork = nextEffect; + var current$$1 = nextEffect.alternate, + finishedWork = nextEffect; switch (finishedWork.tag) { - case 2: - case 3: + case 0: + case 11: + case 15: + commitHookEffectList(2, 0, finishedWork); + break a; + case 1: if (finishedWork.effectTag & 256 && null !== current$$1) { var prevProps = current$$1.memoizedProps, prevState = current$$1.memoizedState, @@ -5561,10 +6207,11 @@ function completeRoot$1(root, finishedWork$jscomp$0, expirationTime) { instance.__reactInternalSnapshotBeforeUpdate = snapshot; } break a; + case 3: case 5: - case 7: - case 8: case 6: + case 4: + case 17: break a; default: invariant( @@ -5573,18 +6220,17 @@ function completeRoot$1(root, finishedWork$jscomp$0, expirationTime) { ); } } - } nextEffect = nextEffect.nextEffect; } } catch (e) { - (childExpirationTimeBeforeCommit = !0), (error = e); + (childExpirationTimeBeforeCommit = !0), (error$jscomp$0 = 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), + captureCommitPhaseError(nextEffect, error$jscomp$0), null !== nextEffect && (nextEffect = nextEffect.nextEffect)); } for (nextEffect = firstBatch; null !== nextEffect; ) { @@ -5621,8 +6267,32 @@ function completeRoot$1(root, finishedWork$jscomp$0, expirationTime) { "function" === typeof onCommitFiberUnmount && onCommitFiberUnmount(childExpirationTimeBeforeCommit); switch (childExpirationTimeBeforeCommit.tag) { - case 2: - case 3: + case 0: + case 11: + case 14: + case 15: + var updateQueue = childExpirationTimeBeforeCommit.updateQueue; + if (null !== updateQueue) { + var lastEffect = updateQueue.lastEffect; + if (null !== lastEffect) { + var firstEffect = lastEffect.next; + error$jscomp$0 = firstEffect; + do { + var destroy = error$jscomp$0.destroy; + if (null !== destroy) { + finishedWork = childExpirationTimeBeforeCommit; + try { + destroy(); + } catch (error) { + captureCommitPhaseError(finishedWork, error); + } + } + error$jscomp$0 = error$jscomp$0.next; + } while (error$jscomp$0 !== firstEffect); + } + } + break; + case 1: safelyDetachRef(childExpirationTimeBeforeCommit); var instance$jscomp$0 = childExpirationTimeBeforeCommit.stateNode; @@ -5642,10 +6312,10 @@ function completeRoot$1(root, finishedWork$jscomp$0, expirationTime) { ); } break; - case 7: + case 5: safelyDetachRef(childExpirationTimeBeforeCommit); break; - case 6: + case 4: FabricUIManager.createChildSet( childExpirationTimeBeforeCommit.stateNode.containerInfo ); @@ -5687,86 +6357,105 @@ function completeRoot$1(root, finishedWork$jscomp$0, expirationTime) { effectTag = !1; current$$1$jscomp$0 = void 0; try { - for (currentRef = expirationTime; null !== nextEffect; ) { + for ( + currentRef = root, updateQueue = expirationTime; + null !== nextEffect; + + ) { var effectTag$jscomp$0 = nextEffect.effectTag; if (effectTag$jscomp$0 & 36) { + destroy = void 0; var current$$1$jscomp$1 = nextEffect.alternate; - instance$jscomp$0 = nextEffect; - 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) + lastEffect = nextEffect; + firstEffect = updateQueue; + switch (lastEffect.tag) { + case 0: + case 11: + case 15: + commitHookEffectList(16, 32, lastEffect); + break; + case 1: + var instance$jscomp$1 = lastEffect.stateNode; + if (lastEffect.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.props = lastEffect.memoizedProps), + (instance$jscomp$1.state = lastEffect.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.props = lastEffect.memoizedProps; + instance$jscomp$1.state = lastEffect.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), + var updateQueue$jscomp$0 = lastEffect.updateQueue; + null !== updateQueue$jscomp$0 && + ((instance$jscomp$1.props = lastEffect.memoizedProps), + (instance$jscomp$1.state = lastEffect.memoizedState), commitUpdateQueue( - instance$jscomp$0, - updateQueue, + lastEffect, + updateQueue$jscomp$0, instance$jscomp$1, - firstBatch + firstEffect )); break; - case 5: - var _updateQueue = instance$jscomp$0.updateQueue; + case 3: + var _updateQueue = lastEffect.updateQueue; if (null !== _updateQueue) { - current$$1 = null; - if (null !== instance$jscomp$0.child) - switch (instance$jscomp$0.child.tag) { - case 7: - current$$1 = instance$jscomp$0.child.stateNode.canonical; + destroy = null; + if (null !== lastEffect.child) + switch (lastEffect.child.tag) { + case 5: + destroy = lastEffect.child.stateNode.canonical; break; - case 2: - case 3: - current$$1 = instance$jscomp$0.child.stateNode; + case 1: + destroy = lastEffect.child.stateNode; } commitUpdateQueue( - instance$jscomp$0, + lastEffect, _updateQueue, - current$$1, - firstBatch + destroy, + firstEffect ); } break; - case 7: + case 5: null === current$$1$jscomp$1 && - instance$jscomp$0.effectTag & 4 && + lastEffect.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: + case 4: break; - case 16: - if (0 === (instance$jscomp$0.mode & 2)) - (instance$jscomp$0.updateQueue = emptyObject$1), - scheduleWork(instance$jscomp$0, 1); - else { - var currentTime = requestCurrentTime(); - instance$jscomp$0.stateNode = { timedOutAt: currentTime }; + case 12: + break; + case 13: + if (lastEffect.effectTag & 32) { + lastEffect.memoizedState = { + alreadyCaptured: !0, + didTimeout: !1, + timedOutAt: 0 + }; + flushPassiveEffects(); + scheduleWork(lastEffect, 1073741823); + break; } + var newState = lastEffect.memoizedState; + null !== newState && + (destroy = newState.didTimeout) && + ((newState.alreadyCaptured = !1), + 0 === newState.timedOutAt && + (newState.timedOutAt = requestCurrentTime())); + break; + case 17: break; default: invariant( @@ -5780,7 +6469,7 @@ function completeRoot$1(root, finishedWork$jscomp$0, expirationTime) { if (null !== ref) { var instance$jscomp$2 = nextEffect.stateNode; switch (nextEffect.tag) { - case 7: + case 5: var instanceToUse = instance$jscomp$2.canonical; break; default: @@ -5791,9 +6480,9 @@ function completeRoot$1(root, finishedWork$jscomp$0, expirationTime) { : (ref.current = instanceToUse); } } - var next = nextEffect.nextEffect; - nextEffect.nextEffect = null; - nextEffect = next; + effectTag$jscomp$0 & 512 && + (rootWithPendingPassiveEffects = currentRef); + nextEffect = nextEffect.nextEffect; } } catch (e) { (effectTag = !0), (current$$1$jscomp$0 = e); @@ -5806,14 +6495,20 @@ function completeRoot$1(root, finishedWork$jscomp$0, expirationTime) { captureCommitPhaseError(nextEffect, current$$1$jscomp$0), null !== nextEffect && (nextEffect = nextEffect.nextEffect)); } + null !== firstBatch && + null !== rootWithPendingPassiveEffects && + ((effectTag$jscomp$0 = commitPassiveEffects.bind(null, root, firstBatch)), + (passiveEffectCallbackHandle = scheduler.unstable_scheduleCallback( + effectTag$jscomp$0 + )), + (passiveEffectCallback = effectTag$jscomp$0)); 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 ? finishedWork$jscomp$0 : effectTag$jscomp$0; 0 === finishedWork$jscomp$0 && @@ -5821,13 +6516,6 @@ function completeRoot$1(root, finishedWork$jscomp$0, expirationTime) { root.expirationTime = finishedWork$jscomp$0; root.finishedWork = null; } -function shouldYield() { - return deadlineDidExpire - ? !0 - : null === deadline || deadline.timeRemaining() > timeHeuristicForUnitOfWork - ? !1 - : (deadlineDidExpire = !0); -} function onUncaughtError(error) { invariant( null !== nextFlushedRoot, @@ -5836,55 +6524,6 @@ function onUncaughtError(error) { nextFlushedRoot.expirationTime = 0; hasUnhandledError || ((hasUnhandledError = !0), (unhandledError = error)); } -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.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; void 0 === fiber && @@ -5903,7 +6542,48 @@ function updateContainer(element, container, parentComponent, callback) { currentTime = requestCurrentTime(); current$$1 = computeExpirationForFiber(currentTime, current$$1); currentTime = container.current; - parentComponent = getContextForSubtree(parentComponent); + a: if (parentComponent) { + parentComponent = parentComponent._reactInternalFiber; + b: { + invariant( + 2 === isFiberMountedImpl(parentComponent) && 1 === 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 3: + parentContext = parentContext.stateNode.context; + break b; + case 1: + if (isContextProvider(parentContext.type)) { + parentContext = + parentContext.stateNode + .__reactInternalMemoizedMergedChildContext; + break b; + } + } + 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 (1 === parentComponent.tag) { + var Component = parentComponent.type; + if (isContextProvider(Component)) { + parentComponent = processChildContext( + parentComponent, + Component, + parentContext + ); + break a; + } + } + parentComponent = parentContext; + } else parentComponent = emptyContextObject; null === container.context ? (container.context = parentComponent) : (container.pendingContext = parentComponent); @@ -5912,6 +6592,7 @@ function updateContainer(element, container, parentComponent, callback) { callback.payload = { element: element }; container = void 0 === container ? null : container; null !== container && (callback.callback = container); + flushPassiveEffects(); enqueueUpdate(currentTime, callback); scheduleWork(currentTime, current$$1); return current$$1; @@ -5971,13 +6652,13 @@ _batchedUpdatesImpl = function(fn, a) { } finally { (isBatchingUpdates = previousIsBatchingUpdates) || isRendering || - performWork(1, null); + performWork(1073741823, !1); } }; _flushInteractiveUpdatesImpl = function() { isRendering || 0 === lowestPriorityPendingInteractiveExpirationTime || - (performWork(lowestPriorityPendingInteractiveExpirationTime, null), + (performWork(lowestPriorityPendingInteractiveExpirationTime, !1), (lowestPriorityPendingInteractiveExpirationTime = 0)); }; var roots = new Map(), @@ -6057,7 +6738,7 @@ var roots = new Map(), render: function(element, containerTag, callback) { var root = roots.get(containerTag); if (!root) { - root = new FiberNode(5, null, null, 0); + root = createFiber(3, null, null, 0); var root$jscomp$0 = { current: root, containerInfo: containerTag, @@ -6085,7 +6766,7 @@ var roots = new Map(), updateContainer(element, root, null, callback); a: if (((element = root.current), element.child)) switch (element.child.tag) { - case 7: + case 5: element = element.child.stateNode.canonical; break a; default: @@ -6182,7 +6863,7 @@ var roots = new Map(), findFiberByHostInstance: getInstanceFromInstance, getInspectorDataForViewTag: getInspectorDataForViewTag, bundleType: 0, - version: "16.6.0-alpha.8af6728", + version: "16.6.0", rendererPackageName: "react-native-renderer" }); var ReactFabric$2 = { default: ReactFabric }, diff --git a/Libraries/Renderer/oss/ReactFabric-profiling.js b/Libraries/Renderer/oss/ReactFabric-profiling.js index 0ca239937..f877b504e 100644 --- a/Libraries/Renderer/oss/ReactFabric-profiling.js +++ b/Libraries/Renderer/oss/ReactFabric-profiling.js @@ -20,6 +20,7 @@ var ReactNativeViewConfigRegistry = require("ReactNativeViewConfigRegistry"), TextInputState = require("TextInputState"), FabricUIManager = require("FabricUIManager"), tracing = require("scheduler/tracing"), + scheduler = require("scheduler"), ExceptionsManager = require("ExceptionsManager"); function invariant(condition, format, a, b, c, d, e, f) { if (!condition) { @@ -294,7 +295,7 @@ function getListener(inst, registrationName) { } function getParent(inst) { do inst = inst.return; - while (inst && 7 !== inst.tag); + while (inst && 5 !== inst.tag); return inst ? inst : null; } function traverseTwoPhase(inst, fn, arg) { @@ -1035,7 +1036,8 @@ var ReactSharedInternals = : 60111, REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for("react.forward_ref") : 60112, REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for("react.suspense") : 60113, - REACT_PURE_TYPE = hasSymbol ? Symbol.for("react.pure") : 60115, + REACT_MEMO_TYPE = hasSymbol ? Symbol.for("react.memo") : 60115, + REACT_LAZY_TYPE = hasSymbol ? Symbol.for("react.lazy") : 60116, MAYBE_ITERATOR_SYMBOL = "function" === typeof Symbol && Symbol.iterator; function getIteratorFn(maybeIterable) { if (null === maybeIterable || "object" !== typeof maybeIterable) return null; @@ -1044,13 +1046,6 @@ function getIteratorFn(maybeIterable) { maybeIterable["@@iterator"]; return "function" === typeof maybeIterable ? maybeIterable : null; } -function getWrappedName(outerType, innerType, wrapperName) { - innerType = innerType.displayName || innerType.name || ""; - return ( - outerType.displayName || - ("" !== innerType ? wrapperName + "(" + innerType + ")" : wrapperName) - ); -} function getComponentName(type) { if (null == type) return null; if ("function" === typeof type) return type.displayName || type.name || null; @@ -1069,23 +1064,25 @@ function getComponentName(type) { case REACT_SUSPENSE_TYPE: return "Suspense"; } - if ("object" === typeof type) { + if ("object" === typeof type) switch (type.$$typeof) { case REACT_CONTEXT_TYPE: return "Context.Consumer"; case REACT_PROVIDER_TYPE: return "Context.Provider"; case REACT_FORWARD_REF_TYPE: - return getWrappedName(type, type.render, "ForwardRef"); - case REACT_PURE_TYPE: - return getWrappedName(type, type.render, "Pure"); + var innerType = type.render; + innerType = innerType.displayName || innerType.name || ""; + return ( + type.displayName || + ("" !== innerType ? "ForwardRef(" + innerType + ")" : "ForwardRef") + ); + case REACT_MEMO_TYPE: + return getComponentName(type.type); + case REACT_LAZY_TYPE: + if ((type = 1 === type._status ? type._result : null)) + return getComponentName(type); } - if ( - "function" === typeof type.then && - (type = 1 === type._reactStatus ? type._reactResult : null) - ) - return getComponentName(type); - } return null; } function isFiberMountedImpl(fiber) { @@ -1096,7 +1093,7 @@ function isFiberMountedImpl(fiber) { for (; node.return; ) if (((node = node.return), 0 !== (node.effectTag & 2))) return 1; } - return 5 === node.tag ? 2 : 3; + return 3 === node.tag ? 2 : 3; } function assertIsMounted(fiber) { invariant( @@ -1172,14 +1169,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(5 === a.tag, "Unable to find node on an unmounted component."); + invariant(3 === 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 (7 === node.tag || 8 === node.tag) return node; + if (5 === node.tag || 6 === node.tag) return node; if (node.child) (node.child.return = node), (node = node.child); else { if (node === parent) break; @@ -1429,18 +1426,12 @@ var now$1 = return Date.now(); }, scheduledCallback = null, - frameDeadline = 0, - frameDeadlineObject = { - timeRemaining: function() { - return frameDeadline - now$1(); - }, - didTimeout: !1 - }; + frameDeadline = 0; function setTimeoutCallback() { frameDeadline = now$1() + 5; var callback = scheduledCallback; scheduledCallback = null; - null !== callback && callback(frameDeadlineObject); + null !== callback && callback(); } var restoreTarget = null, restoreQueue = null; @@ -1604,13 +1595,13 @@ function getStackByFiberInDevAndProd(workInProgress) { var info = ""; do { a: switch (workInProgress.tag) { - case 4: + case 2: + case 16: case 0: case 1: - case 2: - case 3: - case 7: - case 10: + case 5: + case 8: + case 13: var owner = workInProgress._debugOwner, source = workInProgress._debugSource, name = getComponentName(workInProgress.type); @@ -1762,7 +1753,7 @@ function injectInternals(internals) { function FiberNode(tag, pendingProps, key, mode) { this.tag = tag; this.key = key; - this.sibling = this.child = this.return = this.stateNode = this.type = null; + this.sibling = this.child = this.return = this.stateNode = this.type = this.elementType = null; this.index = 0; this.ref = null; this.pendingProps = pendingProps; @@ -1776,29 +1767,33 @@ function FiberNode(tag, pendingProps, key, mode) { this.actualStartTime = -1; this.treeBaseDuration = this.selfBaseDuration = 0; } +function createFiber(tag, pendingProps, key, mode) { + return new FiberNode(tag, pendingProps, key, mode); +} function shouldConstruct(Component) { Component = Component.prototype; return !(!Component || !Component.isReactComponent); } -function resolveLazyComponentTag(fiber, Component) { +function resolveLazyComponentTag(Component) { if ("function" === typeof Component) - return shouldConstruct(Component) ? 3 : 1; + return shouldConstruct(Component) ? 1 : 0; if (void 0 !== Component && null !== Component) { - fiber = Component.$$typeof; - if (fiber === REACT_FORWARD_REF_TYPE) return 14; - if (fiber === REACT_PURE_TYPE) return 18; + Component = Component.$$typeof; + if (Component === REACT_FORWARD_REF_TYPE) return 11; + if (Component === REACT_MEMO_TYPE) return 14; } - return 4; + return 2; } function createWorkInProgress(current, pendingProps) { var workInProgress = current.alternate; null === workInProgress - ? ((workInProgress = new FiberNode( + ? ((workInProgress = createFiber( current.tag, pendingProps, current.key, current.mode )), + (workInProgress.elementType = current.elementType), (workInProgress.type = current.type), (workInProgress.stateNode = current.stateNode), (workInProgress.alternate = current), @@ -1824,60 +1819,66 @@ function createWorkInProgress(current, pendingProps) { workInProgress.treeBaseDuration = current.treeBaseDuration; return workInProgress; } -function createFiberFromElement(element, mode, expirationTime) { - var type = element.type, - key = element.key; - element = element.props; - var fiberTag = void 0; - if ("function" === typeof type) fiberTag = shouldConstruct(type) ? 2 : 4; - else if ("string" === typeof type) fiberTag = 7; +function createFiberFromTypeAndProps( + type, + key, + pendingProps, + owner, + mode, + expirationTime +) { + var fiberTag = 2; + owner = type; + if ("function" === typeof type) shouldConstruct(type) && (fiberTag = 1); + else if ("string" === typeof type) fiberTag = 5; else a: switch (type) { case REACT_FRAGMENT_TYPE: return createFiberFromFragment( - element.children, + pendingProps.children, mode, expirationTime, key ); case REACT_CONCURRENT_MODE_TYPE: - fiberTag = 10; - mode |= 3; - break; + return createFiberFromMode(pendingProps, mode | 3, expirationTime, key); case REACT_STRICT_MODE_TYPE: - fiberTag = 10; - mode |= 2; - break; + return createFiberFromMode(pendingProps, mode | 2, expirationTime, key); case REACT_PROFILER_TYPE: return ( - (type = new FiberNode(15, element, key, mode | 4)), + (type = createFiber(12, pendingProps, key, mode | 4)), + (type.elementType = REACT_PROFILER_TYPE), (type.type = REACT_PROFILER_TYPE), (type.expirationTime = expirationTime), type ); case REACT_SUSPENSE_TYPE: - fiberTag = 16; - break; + return ( + (type = createFiber(13, pendingProps, key, mode)), + (type.elementType = REACT_SUSPENSE_TYPE), + (type.type = REACT_SUSPENSE_TYPE), + (type.expirationTime = expirationTime), + type + ); default: if ("object" === typeof type && null !== type) switch (type.$$typeof) { case REACT_PROVIDER_TYPE: - fiberTag = 12; + fiberTag = 10; break a; case REACT_CONTEXT_TYPE: - fiberTag = 11; + fiberTag = 9; break a; case REACT_FORWARD_REF_TYPE: - fiberTag = 13; + fiberTag = 11; break a; - case REACT_PURE_TYPE: - fiberTag = 17; + case REACT_MEMO_TYPE: + fiberTag = 14; + break a; + case REACT_LAZY_TYPE: + fiberTag = 16; + owner = null; break a; - default: - if ("function" === typeof type.then) { - fiberTag = 4; - break a; - } } invariant( !1, @@ -1886,24 +1887,33 @@ function createFiberFromElement(element, mode, expirationTime) { "" ); } - mode = new FiberNode(fiberTag, element, key, mode); - mode.type = type; - mode.expirationTime = expirationTime; - return mode; + key = createFiber(fiberTag, pendingProps, key, mode); + key.elementType = type; + key.type = owner; + key.expirationTime = expirationTime; + return key; } function createFiberFromFragment(elements, mode, expirationTime, key) { - elements = new FiberNode(9, elements, key, mode); + elements = createFiber(7, elements, key, mode); elements.expirationTime = expirationTime; return elements; } +function createFiberFromMode(pendingProps, mode, expirationTime, key) { + pendingProps = createFiber(8, pendingProps, key, mode); + mode = 0 === (mode & 1) ? REACT_STRICT_MODE_TYPE : REACT_CONCURRENT_MODE_TYPE; + pendingProps.elementType = mode; + pendingProps.type = mode; + pendingProps.expirationTime = expirationTime; + return pendingProps; +} function createFiberFromText(content, mode, expirationTime) { - content = new FiberNode(8, content, null, mode); + content = createFiber(6, content, null, mode); content.expirationTime = expirationTime; return content; } function createFiberFromPortal(portal, mode, expirationTime) { - mode = new FiberNode( - 6, + mode = createFiber( + 4, null !== portal.children ? portal.children : [], portal.key, mode @@ -1921,9 +1931,9 @@ function markPendingPriorityLevel(root, expirationTime) { var earliestPendingTime = root.earliestPendingTime; 0 === earliestPendingTime ? (root.earliestPendingTime = root.latestPendingTime = expirationTime) - : earliestPendingTime > expirationTime + : earliestPendingTime < expirationTime ? (root.earliestPendingTime = expirationTime) - : root.latestPendingTime < expirationTime && + : root.latestPendingTime > expirationTime && (root.latestPendingTime = expirationTime); findNextExpirationTimeToWorkOn(expirationTime, root); } @@ -1938,19 +1948,19 @@ function markCommittedPriorityLevels(root, earliestRemainingTime) { else { var latestPendingTime = root.latestPendingTime; 0 !== latestPendingTime && - (latestPendingTime < earliestRemainingTime + (latestPendingTime > earliestRemainingTime ? (root.earliestPendingTime = root.latestPendingTime = 0) - : root.earliestPendingTime < earliestRemainingTime && + : root.earliestPendingTime > earliestRemainingTime && (root.earliestPendingTime = root.latestPendingTime)); latestPendingTime = root.earliestSuspendedTime; 0 === latestPendingTime ? markPendingPriorityLevel(root, earliestRemainingTime) - : earliestRemainingTime > root.latestSuspendedTime + : earliestRemainingTime < root.latestSuspendedTime ? ((root.earliestSuspendedTime = 0), (root.latestSuspendedTime = 0), (root.latestPingedTime = 0), markPendingPriorityLevel(root, earliestRemainingTime)) - : earliestRemainingTime < latestPendingTime && + : earliestRemainingTime > latestPendingTime && markPendingPriorityLevel(root, earliestRemainingTime); } findNextExpirationTimeToWorkOn(0, root); @@ -1960,17 +1970,17 @@ function hasLowerPriorityWork(root, erroredExpirationTime) { latestSuspendedTime = root.latestSuspendedTime; root = root.latestPingedTime; return ( - (0 !== latestPendingTime && latestPendingTime > erroredExpirationTime) || + (0 !== latestPendingTime && latestPendingTime < erroredExpirationTime) || (0 !== latestSuspendedTime && - latestSuspendedTime > erroredExpirationTime) || - (0 !== root && root > erroredExpirationTime) + latestSuspendedTime < erroredExpirationTime) || + (0 !== root && root < erroredExpirationTime) ); } function markSuspendedPriorityLevel(root, suspendedTime) { root.didError = !1; var latestPingedTime = root.latestPingedTime; 0 !== latestPingedTime && - latestPingedTime <= suspendedTime && + latestPingedTime >= suspendedTime && (root.latestPingedTime = 0); latestPingedTime = root.earliestPendingTime; var latestPendingTime = root.latestPendingTime; @@ -1985,22 +1995,18 @@ function markSuspendedPriorityLevel(root, suspendedTime) { latestPendingTime = root.latestSuspendedTime; 0 === latestPingedTime ? (root.earliestSuspendedTime = root.latestSuspendedTime = suspendedTime) - : latestPingedTime > suspendedTime + : latestPingedTime < suspendedTime ? (root.earliestSuspendedTime = suspendedTime) - : latestPendingTime < suspendedTime && + : latestPendingTime > suspendedTime && (root.latestSuspendedTime = suspendedTime); findNextExpirationTimeToWorkOn(suspendedTime, root); } function findEarliestOutstandingPriorityLevel(root, renderExpirationTime) { var earliestPendingTime = root.earliestPendingTime; root = root.earliestSuspendedTime; - if ( - 0 === renderExpirationTime || - (0 !== earliestPendingTime && earliestPendingTime < renderExpirationTime) - ) - renderExpirationTime = earliestPendingTime; - if (0 === renderExpirationTime || (0 !== root && root < renderExpirationTime)) - renderExpirationTime = root; + earliestPendingTime > renderExpirationTime && + (renderExpirationTime = earliestPendingTime); + root > renderExpirationTime && (renderExpirationTime = root); return renderExpirationTime; } function findNextExpirationTimeToWorkOn(completedExpirationTime, root) { @@ -2012,12 +2018,11 @@ function findNextExpirationTimeToWorkOn(completedExpirationTime, root) { 0 !== earliestPendingTime ? earliestPendingTime : latestPingedTime; 0 === earliestPendingTime && (0 === completedExpirationTime || - latestSuspendedTime > completedExpirationTime) && + latestSuspendedTime < completedExpirationTime) && (earliestPendingTime = latestSuspendedTime); completedExpirationTime = earliestPendingTime; 0 !== completedExpirationTime && - 0 !== earliestSuspendedTime && - earliestSuspendedTime < completedExpirationTime && + earliestSuspendedTime > completedExpirationTime && (completedExpirationTime = earliestSuspendedTime); root.nextExpirationTimeToWorkOn = earliestPendingTime; root.expirationTime = completedExpirationTime; @@ -2129,7 +2134,7 @@ function getStateFromUpdate( : workInProgress ); case 3: - workInProgress.effectTag = (workInProgress.effectTag & -1025) | 64; + workInProgress.effectTag = (workInProgress.effectTag & -2049) | 64; case 0: workInProgress = update.payload; nextProps = @@ -2162,58 +2167,52 @@ function processUpdateQueue( ) { var updateExpirationTime = update.expirationTime; - if (updateExpirationTime > renderExpirationTime) { - if ( - (null === newFirstUpdate && + updateExpirationTime < renderExpirationTime + ? (null === newFirstUpdate && ((newFirstUpdate = update), (newBaseState = resultState)), - 0 === newExpirationTime || newExpirationTime > updateExpirationTime) - ) - newExpirationTime = updateExpirationTime; - } else - (resultState = getStateFromUpdate( - workInProgress, - queue, - update, - resultState, - props, - instance - )), + newExpirationTime < updateExpirationTime && + (newExpirationTime = updateExpirationTime)) + : ((resultState = getStateFromUpdate( + workInProgress, + queue, + update, + resultState, + props, + instance + )), null !== update.callback && ((workInProgress.effectTag |= 32), (update.nextEffect = null), null === queue.lastEffect ? (queue.firstEffect = queue.lastEffect = update) : ((queue.lastEffect.nextEffect = update), - (queue.lastEffect = update))); + (queue.lastEffect = update)))); update = update.next; } updateExpirationTime = null; for (update = queue.firstCapturedUpdate; null !== update; ) { var _updateExpirationTime = update.expirationTime; - if (_updateExpirationTime > renderExpirationTime) { - if ( - (null === updateExpirationTime && + _updateExpirationTime < renderExpirationTime + ? (null === updateExpirationTime && ((updateExpirationTime = update), null === newFirstUpdate && (newBaseState = resultState)), - 0 === newExpirationTime || newExpirationTime > _updateExpirationTime) - ) - newExpirationTime = _updateExpirationTime; - } else - (resultState = getStateFromUpdate( - workInProgress, - queue, - update, - resultState, - props, - instance - )), + newExpirationTime < _updateExpirationTime && + (newExpirationTime = _updateExpirationTime)) + : ((resultState = getStateFromUpdate( + workInProgress, + queue, + update, + resultState, + props, + instance + )), null !== update.callback && ((workInProgress.effectTag |= 32), (update.nextEffect = null), null === queue.lastCapturedEffect ? (queue.firstCapturedEffect = queue.lastCapturedEffect = update) : ((queue.lastCapturedEffect.nextEffect = update), - (queue.lastCapturedEffect = update))); + (queue.lastCapturedEffect = update)))); update = update.next; } null === newFirstUpdate && (queue.lastUpdate = null); @@ -2294,13 +2293,277 @@ function readContext(context, observedBits) { null === lastContextDependency ? (invariant( null !== currentlyRenderingFiber, - "Context.unstable_read(): Context can only be read while React is rendering, e.g. inside the render method or getDerivedStateFromProps." + "Context can only be read while React is rendering, e.g. inside the render method or getDerivedStateFromProps." ), (currentlyRenderingFiber.firstContextDependency = lastContextDependency = observedBits)) : (lastContextDependency = lastContextDependency.next = observedBits); } return context._currentValue2; } +var renderExpirationTime = 0, + currentlyRenderingFiber$1 = null, + firstCurrentHook = null, + currentHook = null, + firstWorkInProgressHook = null, + workInProgressHook = null, + remainingExpirationTime = 0, + componentUpdateQueue = null, + isReRender = !1, + didScheduleRenderPhaseUpdate = !1, + renderPhaseUpdates = null, + numberOfReRenders = 0; +function resolveCurrentlyRenderingFiber() { + invariant( + null !== currentlyRenderingFiber$1, + "Hooks can only be called inside the body of a function component." + ); + return currentlyRenderingFiber$1; +} +function finishHooks(Component, props, children, refOrContext) { + for (; didScheduleRenderPhaseUpdate; ) + (didScheduleRenderPhaseUpdate = !1), + (numberOfReRenders += 1), + (componentUpdateQueue = workInProgressHook = currentHook = null), + (children = Component(props, refOrContext)); + renderPhaseUpdates = null; + numberOfReRenders = 0; + Component = currentlyRenderingFiber$1; + Component.memoizedState = firstWorkInProgressHook; + Component.expirationTime = remainingExpirationTime; + Component.updateQueue = componentUpdateQueue; + Component = null !== currentHook && null !== currentHook.next; + renderExpirationTime = 0; + workInProgressHook = firstWorkInProgressHook = currentHook = firstCurrentHook = currentlyRenderingFiber$1 = null; + remainingExpirationTime = 0; + componentUpdateQueue = null; + invariant( + !Component, + "Rendered fewer hooks than expected. This may be caused by an accidental early return statement." + ); + return children; +} +function resetHooks() { + renderExpirationTime = 0; + workInProgressHook = firstWorkInProgressHook = currentHook = firstCurrentHook = currentlyRenderingFiber$1 = null; + remainingExpirationTime = 0; + componentUpdateQueue = null; + didScheduleRenderPhaseUpdate = !1; + renderPhaseUpdates = null; + numberOfReRenders = 0; +} +function createHook() { + return { + memoizedState: null, + baseState: null, + queue: null, + baseUpdate: null, + next: null + }; +} +function cloneHook(hook) { + return { + memoizedState: hook.memoizedState, + baseState: hook.memoizedState, + queue: hook.queue, + baseUpdate: hook.baseUpdate, + next: null + }; +} +function createWorkInProgressHook() { + if (null === workInProgressHook) + null === firstWorkInProgressHook + ? ((isReRender = !1), + (currentHook = firstCurrentHook), + (firstWorkInProgressHook = workInProgressHook = + null === currentHook ? createHook() : cloneHook(currentHook))) + : ((isReRender = !0), + (currentHook = firstCurrentHook), + (workInProgressHook = firstWorkInProgressHook)); + else if (null === workInProgressHook.next) { + isReRender = !1; + if (null === currentHook) var hook = createHook(); + else + (currentHook = currentHook.next), + (hook = null === currentHook ? createHook() : cloneHook(currentHook)); + workInProgressHook = workInProgressHook.next = hook; + } else + (isReRender = !0), + (workInProgressHook = workInProgressHook.next), + (currentHook = null !== currentHook ? currentHook.next : null); + return workInProgressHook; +} +function basicStateReducer(state, action) { + return "function" === typeof action ? action(state) : action; +} +function useReducer(reducer, initialState, initialAction) { + currentlyRenderingFiber$1 = resolveCurrentlyRenderingFiber(); + workInProgressHook = createWorkInProgressHook(); + var queue = workInProgressHook.queue; + if (null !== queue) { + if (isReRender) { + initialState = queue.dispatch; + if (null !== renderPhaseUpdates) { + var firstRenderPhaseUpdate = renderPhaseUpdates.get(queue); + if (void 0 !== firstRenderPhaseUpdate) { + renderPhaseUpdates.delete(queue); + initialAction = workInProgressHook.memoizedState; + do + (initialAction = reducer( + initialAction, + firstRenderPhaseUpdate.action + )), + (firstRenderPhaseUpdate = firstRenderPhaseUpdate.next); + while (null !== firstRenderPhaseUpdate); + workInProgressHook.memoizedState = initialAction; + workInProgressHook.baseUpdate === queue.last && + (workInProgressHook.baseState = initialAction); + return [initialAction, initialState]; + } + } + return [workInProgressHook.memoizedState, initialState]; + } + initialState = queue.last; + var _baseUpdate = workInProgressHook.baseUpdate; + null !== _baseUpdate + ? (null !== initialState && (initialState.next = null), + (initialState = _baseUpdate.next)) + : (initialState = null !== initialState ? initialState.next : null); + if (null !== initialState) { + initialAction = workInProgressHook.baseState; + var newBaseUpdate = (firstRenderPhaseUpdate = null), + _update = initialState, + didSkip = !1; + do { + var updateExpirationTime = _update.expirationTime; + updateExpirationTime < renderExpirationTime + ? (didSkip || + ((didSkip = !0), + (newBaseUpdate = _baseUpdate), + (firstRenderPhaseUpdate = initialAction)), + updateExpirationTime > remainingExpirationTime && + (remainingExpirationTime = updateExpirationTime)) + : (initialAction = reducer(initialAction, _update.action)); + _baseUpdate = _update; + _update = _update.next; + } while (null !== _update && _update !== initialState); + didSkip || + ((newBaseUpdate = _baseUpdate), + (firstRenderPhaseUpdate = initialAction)); + workInProgressHook.memoizedState = initialAction; + workInProgressHook.baseUpdate = newBaseUpdate; + workInProgressHook.baseState = firstRenderPhaseUpdate; + } + return [workInProgressHook.memoizedState, queue.dispatch]; + } + reducer === basicStateReducer + ? "function" === typeof initialState && (initialState = initialState()) + : void 0 !== initialAction && + null !== initialAction && + (initialState = reducer(initialState, initialAction)); + workInProgressHook.memoizedState = workInProgressHook.baseState = initialState; + queue = workInProgressHook.queue = { last: null, dispatch: null }; + reducer = queue.dispatch = dispatchAction.bind( + null, + currentlyRenderingFiber$1, + queue + ); + return [workInProgressHook.memoizedState, reducer]; +} +function pushEffect(tag, create, destroy, inputs) { + tag = { + tag: tag, + create: create, + destroy: destroy, + inputs: inputs, + next: null + }; + null === componentUpdateQueue + ? ((componentUpdateQueue = { lastEffect: null }), + (componentUpdateQueue.lastEffect = tag.next = tag)) + : ((create = componentUpdateQueue.lastEffect), + null === create + ? (componentUpdateQueue.lastEffect = tag.next = tag) + : ((destroy = create.next), + (create.next = tag), + (tag.next = destroy), + (componentUpdateQueue.lastEffect = tag))); + return tag; +} +function useEffectImpl(fiberEffectTag, hookEffectTag, create, inputs) { + currentlyRenderingFiber$1 = resolveCurrentlyRenderingFiber(); + workInProgressHook = createWorkInProgressHook(); + inputs = void 0 !== inputs && null !== inputs ? inputs : [create]; + var destroy = null; + if (null !== currentHook) { + var prevEffect = currentHook.memoizedState; + destroy = prevEffect.destroy; + if (inputsAreEqual(inputs, prevEffect.inputs)) { + pushEffect(0, create, destroy, inputs); + return; + } + } + currentlyRenderingFiber$1.effectTag |= fiberEffectTag; + workInProgressHook.memoizedState = pushEffect( + hookEffectTag, + create, + destroy, + inputs + ); +} +function dispatchAction(fiber, queue, action) { + invariant( + 25 > numberOfReRenders, + "Too many re-renders. React limits the number of renders to prevent an infinite loop." + ); + var alternate = fiber.alternate; + if ( + fiber === currentlyRenderingFiber$1 || + (null !== alternate && alternate === currentlyRenderingFiber$1) + ) + if ( + ((didScheduleRenderPhaseUpdate = !0), + (fiber = { + expirationTime: renderExpirationTime, + action: action, + next: null + }), + null === renderPhaseUpdates && (renderPhaseUpdates = new Map()), + (alternate = renderPhaseUpdates.get(queue)), + void 0 === alternate) + ) + renderPhaseUpdates.set(queue, fiber); + else { + for (queue = alternate; null !== queue.next; ) queue = queue.next; + queue.next = fiber; + } + else { + alternate = requestCurrentTime(); + alternate = computeExpirationForFiber(alternate, fiber); + action = { expirationTime: alternate, action: action, next: null }; + flushPassiveEffects(); + var _last2 = queue.last; + if (null === _last2) action.next = action; + else { + var first = _last2.next; + null !== first && (action.next = first); + _last2.next = action; + } + queue.last = action; + scheduleWork(fiber, alternate); + } +} +function inputsAreEqual(arr1, arr2) { + for (var i = 0; i < arr1.length; i++) { + var val1 = arr1[i], + val2 = arr2[i]; + if ( + (val1 !== val2 || (0 === val1 && 1 / val1 !== 1 / val2)) && + (val1 === val1 || val2 === val2) + ) + return !1; + } + return !0; +} var NO_CONTEXT = {}, contextStackCursor$1 = { current: NO_CONTEXT }, contextFiberStackCursor = { current: NO_CONTEXT }, @@ -2380,7 +2643,8 @@ function shallowEqual(objA, objB) { return !1; return !0; } -var emptyRefsObject = new React.Component().refs; +var ReactCurrentOwner$4 = ReactSharedInternals.ReactCurrentOwner, + emptyRefsObject = new React.Component().refs; function applyDerivedStateFromProps( workInProgress, ctor, @@ -2412,6 +2676,7 @@ var classComponentUpdater = { var update = createUpdate(currentTime); update.payload = payload; void 0 !== callback && null !== callback && (update.callback = callback); + flushPassiveEffects(); enqueueUpdate(inst, update); scheduleWork(inst, currentTime); }, @@ -2423,6 +2688,7 @@ var classComponentUpdater = { update.tag = 1; update.payload = payload; void 0 !== callback && null !== callback && (update.callback = callback); + flushPassiveEffects(); enqueueUpdate(inst, update); scheduleWork(inst, currentTime); }, @@ -2433,6 +2699,7 @@ var classComponentUpdater = { var update = createUpdate(currentTime); update.tag = 2; void 0 !== callback && null !== callback && (update.callback = callback); + flushPassiveEffects(); enqueueUpdate(inst, update); scheduleWork(inst, currentTime); } @@ -2453,6 +2720,32 @@ function checkShouldComponentUpdate( ? !shallowEqual(oldProps, newProps) || !shallowEqual(oldState, newState) : !0; } +function constructClassInstance(workInProgress, ctor, props) { + var isLegacyContextConsumer = !1, + unmaskedContext = emptyContextObject; + var context = ctor.contextType; + "object" === typeof context && null !== context + ? (context = ReactCurrentOwner$4.currentDispatcher.readContext(context)) + : ((unmaskedContext = isContextProvider(ctor) + ? previousContext + : contextStackCursor.current), + (isLegacyContextConsumer = ctor.contextTypes), + (context = (isLegacyContextConsumer = + null !== isLegacyContextConsumer && void 0 !== isLegacyContextConsumer) + ? getMaskedContext(workInProgress, unmaskedContext) + : emptyContextObject)); + ctor = new ctor(props, context); + workInProgress.memoizedState = + null !== ctor.state && void 0 !== ctor.state ? ctor.state : null; + ctor.updater = classComponentUpdater; + workInProgress.stateNode = ctor; + ctor._reactInternalFiber = workInProgress; + isLegacyContextConsumer && + ((workInProgress = workInProgress.stateNode), + (workInProgress.__reactInternalMemoizedUnmaskedChildContext = unmaskedContext), + (workInProgress.__reactInternalMemoizedMaskedChildContext = context)); + return ctor; +} function callComponentWillReceiveProps( workInProgress, instance, @@ -2479,7 +2772,9 @@ function mountClassInstance( instance.refs = emptyRefsObject; var contextType = ctor.contextType; "object" === typeof contextType && null !== contextType - ? (instance.context = contextType.unstable_read()) + ? (instance.context = ReactCurrentOwner$4.currentDispatcher.readContext( + contextType + )) : ((contextType = isContextProvider(ctor) ? previousContext : contextStackCursor.current), @@ -2534,10 +2829,7 @@ function coerceRef(returnFiber, current$$1, element) { element = element._owner; var inst = void 0; element && - (invariant( - 2 === element.tag || 3 === element.tag, - "Function components cannot have refs." - ), + (invariant(1 === element.tag, "Function components cannot have refs."), (inst = element.stateNode)); invariant( inst, @@ -2642,7 +2934,7 @@ function ChildReconciler(shouldTrackSideEffects) { textContent, expirationTime ) { - if (null === current$$1 || 8 !== current$$1.tag) + if (null === current$$1 || 6 !== current$$1.tag) return ( (current$$1 = createFiberFromText( textContent, @@ -2657,15 +2949,18 @@ function ChildReconciler(shouldTrackSideEffects) { return current$$1; } function updateElement(returnFiber, current$$1, element, expirationTime) { - if (null !== current$$1 && current$$1.type === element.type) + if (null !== current$$1 && current$$1.elementType === element.type) return ( (expirationTime = useFiber(current$$1, element.props, expirationTime)), (expirationTime.ref = coerceRef(returnFiber, current$$1, element)), (expirationTime.return = returnFiber), expirationTime ); - expirationTime = createFiberFromElement( - element, + expirationTime = createFiberFromTypeAndProps( + element.type, + element.key, + element.props, + null, returnFiber.mode, expirationTime ); @@ -2676,7 +2971,7 @@ function ChildReconciler(shouldTrackSideEffects) { function updatePortal(returnFiber, current$$1, portal, expirationTime) { if ( null === current$$1 || - 6 !== current$$1.tag || + 4 !== current$$1.tag || current$$1.stateNode.containerInfo !== portal.containerInfo || current$$1.stateNode.implementation !== portal.implementation ) @@ -2700,7 +2995,7 @@ function ChildReconciler(shouldTrackSideEffects) { expirationTime, key ) { - if (null === current$$1 || 9 !== current$$1.tag) + if (null === current$$1 || 7 !== current$$1.tag) return ( (current$$1 = createFiberFromFragment( fragment, @@ -2730,8 +3025,11 @@ function ChildReconciler(shouldTrackSideEffects) { switch (newChild.$$typeof) { case REACT_ELEMENT_TYPE: return ( - (expirationTime = createFiberFromElement( - newChild, + (expirationTime = createFiberFromTypeAndProps( + newChild.type, + newChild.key, + newChild.props, + null, returnFiber.mode, expirationTime )), @@ -3075,9 +3373,9 @@ function ChildReconciler(shouldTrackSideEffects) { ) { if (isUnkeyedTopLevelFragment.key === isObject) if ( - 9 === isUnkeyedTopLevelFragment.tag + 7 === isUnkeyedTopLevelFragment.tag ? newChild.type === REACT_FRAGMENT_TYPE - : isUnkeyedTopLevelFragment.type === newChild.type + : isUnkeyedTopLevelFragment.elementType === newChild.type ) { deleteRemainingChildren( returnFiber, @@ -3117,8 +3415,11 @@ function ChildReconciler(shouldTrackSideEffects) { )), (currentFirstChild.return = returnFiber), (returnFiber = currentFirstChild)) - : ((expirationTime = createFiberFromElement( - newChild, + : ((expirationTime = createFiberFromTypeAndProps( + newChild.type, + newChild.key, + newChild.props, + null, returnFiber.mode, expirationTime )), @@ -3140,7 +3441,7 @@ function ChildReconciler(shouldTrackSideEffects) { ) { if (currentFirstChild.key === isUnkeyedTopLevelFragment) if ( - 6 === currentFirstChild.tag && + 4 === currentFirstChild.tag && currentFirstChild.stateNode.containerInfo === newChild.containerInfo && currentFirstChild.stateNode.implementation === @@ -3178,7 +3479,7 @@ function ChildReconciler(shouldTrackSideEffects) { if ("string" === typeof newChild || "number" === typeof newChild) return ( (newChild = "" + newChild), - null !== currentFirstChild && 8 === currentFirstChild.tag + null !== currentFirstChild && 6 === currentFirstChild.tag ? (deleteRemainingChildren(returnFiber, currentFirstChild.sibling), (currentFirstChild = useFiber( currentFirstChild, @@ -3214,8 +3515,7 @@ function ChildReconciler(shouldTrackSideEffects) { isObject && throwOnInvalidObjectType(returnFiber, newChild); if ("undefined" === typeof newChild && !isUnkeyedTopLevelFragment) switch (returnFiber.tag) { - case 2: - case 3: + case 1: case 0: (expirationTime = returnFiber.type), invariant( @@ -3234,12 +3534,12 @@ var reconcileChildFibers = ChildReconciler(!0), isHydrating = !1; function tryHydrate(fiber, nextInstance) { switch (fiber.tag) { - case 7: + case 5: return ( (nextInstance = shim$1(nextInstance, fiber.type, fiber.pendingProps)), null !== nextInstance ? ((fiber.stateNode = nextInstance), !0) : !1 ); - case 8: + case 6: return ( (nextInstance = shim$1(nextInstance, fiber.pendingProps)), null !== nextInstance ? ((fiber.stateNode = nextInstance), !0) : !1 @@ -3262,7 +3562,8 @@ function tryToClaimNextHydratableInstance(fiber$jscomp$0) { return; } var returnFiber = hydrationParentFiber, - fiber = new FiberNode(7, null, null, 0); + fiber = createFiber(5, null, null, 0); + fiber.elementType = "DELETED"; fiber.type = "DELETED"; fiber.stateNode = firstAttemptedInstance; fiber.return = returnFiber; @@ -3280,36 +3581,33 @@ function tryToClaimNextHydratableInstance(fiber$jscomp$0) { (hydrationParentFiber = fiber$jscomp$0); } } -function readLazyComponentType(thenable) { - switch (thenable._reactStatus) { +function readLazyComponentType(lazyComponent) { + var result = lazyComponent._result; + switch (lazyComponent._status) { case 1: - return thenable._reactResult; + return result; case 2: - throw thenable._reactResult; + throw result; case 0: - throw thenable; + throw result; 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; - } + throw ((lazyComponent._status = 0), + (result = lazyComponent._ctor), + (result = result()), + result.then( + function(moduleObject) { + 0 === lazyComponent._status && + ((moduleObject = moduleObject.default), + (lazyComponent._status = 1), + (lazyComponent._result = moduleObject)); }, function(error) { - 0 === thenable._reactStatus && - ((thenable._reactStatus = 2), (thenable._reactResult = error)); + 0 === lazyComponent._status && + ((lazyComponent._status = 2), (lazyComponent._result = error)); } ), - thenable); + (lazyComponent._result = result), + result); } } var ReactCurrentOwner$3 = ReactSharedInternals.ReactCurrentOwner; @@ -3337,28 +3635,28 @@ function reconcileChildren( function updateForwardRef( current$$1, workInProgress, - type, + Component, nextProps, - renderExpirationTime + renderExpirationTime$jscomp$0 ) { - type = type.render; + Component = Component.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; + prepareToReadContext(workInProgress, renderExpirationTime$jscomp$0); + renderExpirationTime = renderExpirationTime$jscomp$0; + currentlyRenderingFiber$1 = workInProgress; + firstCurrentHook = null !== current$$1 ? current$$1.memoizedState : null; + var nextChildren = Component(nextProps, ref); + nextChildren = finishHooks(Component, nextProps, nextChildren, ref); + workInProgress.effectTag |= 1; + reconcileChildren( + current$$1, + workInProgress, + nextChildren, + renderExpirationTime$jscomp$0 + ); return workInProgress.child; } -function updatePureComponent( +function updateMemoComponent( current$$1, workInProgress, Component, @@ -3366,29 +3664,81 @@ function updatePureComponent( updateExpirationTime, renderExpirationTime ) { - var render = Component.render, - ref = workInProgress.ref; + if (null === current$$1) { + var type = Component.type; + if ( + "function" === typeof type && + !shouldConstruct(type) && + void 0 === type.defaultProps && + null === Component.compare + ) + return ( + (workInProgress.tag = 15), + (workInProgress.type = type), + updateSimpleMemoComponent( + current$$1, + workInProgress, + type, + nextProps, + updateExpirationTime, + renderExpirationTime + ) + ); + current$$1 = createFiberFromTypeAndProps( + Component.type, + null, + nextProps, + null, + workInProgress.mode, + renderExpirationTime + ); + current$$1.ref = workInProgress.ref; + current$$1.return = workInProgress; + return (workInProgress.child = current$$1); + } + type = current$$1.child; if ( - null !== current$$1 && - (0 === updateExpirationTime || - updateExpirationTime > renderExpirationTime) && - ((updateExpirationTime = current$$1.memoizedProps), + updateExpirationTime < renderExpirationTime && + ((updateExpirationTime = type.memoizedProps), (Component = Component.compare), (Component = null !== Component ? Component : shallowEqual), - workInProgress.ref === current$$1.ref && - Component(updateExpirationTime, nextProps)) + Component(updateExpirationTime, nextProps) && + current$$1.ref === workInProgress.ref) ) return bailoutOnAlreadyFinishedWork( current$$1, workInProgress, renderExpirationTime ); - prepareToReadContext(workInProgress, renderExpirationTime); - render = render(nextProps, ref); - workInProgress.effectTag |= 1; - reconcileChildren(current$$1, workInProgress, render, renderExpirationTime); - workInProgress.memoizedProps = nextProps; - return workInProgress.child; + current$$1 = createWorkInProgress(type, nextProps, renderExpirationTime); + current$$1.ref = workInProgress.ref; + current$$1.return = workInProgress; + return (workInProgress.child = current$$1); +} +function updateSimpleMemoComponent( + current$$1, + workInProgress, + Component, + nextProps, + updateExpirationTime, + renderExpirationTime +) { + return null !== current$$1 && + updateExpirationTime < renderExpirationTime && + shallowEqual(current$$1.memoizedProps, nextProps) && + current$$1.ref === workInProgress.ref + ? bailoutOnAlreadyFinishedWork( + current$$1, + workInProgress, + renderExpirationTime + ) + : updateFunctionComponent( + current$$1, + workInProgress, + Component, + nextProps, + renderExpirationTime + ); } function markRef(current$$1, workInProgress) { var ref = workInProgress.ref; @@ -3403,22 +3753,30 @@ function updateFunctionComponent( workInProgress, Component, nextProps, - renderExpirationTime + renderExpirationTime$jscomp$0 ) { var unmaskedContext = isContextProvider(Component) ? previousContext : contextStackCursor.current; unmaskedContext = getMaskedContext(workInProgress, unmaskedContext); - prepareToReadContext(workInProgress, renderExpirationTime); - Component = Component(nextProps, unmaskedContext); + prepareToReadContext(workInProgress, renderExpirationTime$jscomp$0); + renderExpirationTime = renderExpirationTime$jscomp$0; + currentlyRenderingFiber$1 = workInProgress; + firstCurrentHook = null !== current$$1 ? current$$1.memoizedState : null; + var nextChildren = Component(nextProps, unmaskedContext); + nextChildren = finishHooks( + Component, + nextProps, + nextChildren, + unmaskedContext + ); workInProgress.effectTag |= 1; reconcileChildren( current$$1, workInProgress, - Component, - renderExpirationTime + nextChildren, + renderExpirationTime$jscomp$0 ); - workInProgress.memoizedProps = nextProps; return workInProgress.child; } function updateClassComponent( @@ -3433,166 +3791,149 @@ function updateClassComponent( pushContextProvider(workInProgress); } else hasContext = !1; prepareToReadContext(workInProgress, renderExpirationTime); - if (null === current$$1) - if (null === workInProgress.stateNode) { - var isLegacyContextConsumer = !1, - unmaskedContext = emptyContextObject; - var context = Component.contextType; - "object" === typeof context && null !== context - ? (context = context.unstable_read()) - : ((unmaskedContext = isContextProvider(Component) - ? previousContext - : contextStackCursor.current), - (isLegacyContextConsumer = Component.contextTypes), - (context = (isLegacyContextConsumer = - null !== isLegacyContextConsumer && - void 0 !== isLegacyContextConsumer) - ? getMaskedContext(workInProgress, unmaskedContext) - : emptyContextObject)); - var instance = new Component(nextProps, context); - workInProgress.memoizedState = - null !== instance.state && void 0 !== instance.state - ? instance.state - : null; - instance.updater = classComponentUpdater; - workInProgress.stateNode = instance; - instance._reactInternalFiber = workInProgress; - isLegacyContextConsumer && - ((isLegacyContextConsumer = workInProgress.stateNode), - (isLegacyContextConsumer.__reactInternalMemoizedUnmaskedChildContext = unmaskedContext), - (isLegacyContextConsumer.__reactInternalMemoizedMaskedChildContext = context)); + if (null === workInProgress.stateNode) + null !== current$$1 && + ((current$$1.alternate = null), + (workInProgress.alternate = null), + (workInProgress.effectTag |= 2)), + constructClassInstance( + workInProgress, + Component, + nextProps, + renderExpirationTime + ), mountClassInstance( workInProgress, Component, nextProps, renderExpirationTime - ); - nextProps = !0; - } else { - unmaskedContext = workInProgress.stateNode; - isLegacyContextConsumer = workInProgress.memoizedProps; - unmaskedContext.props = isLegacyContextConsumer; - var oldContext = unmaskedContext.context; - context = Component.contextType; - "object" === typeof context && null !== context - ? (context = context.unstable_read()) - : ((context = isContextProvider(Component) - ? previousContext - : contextStackCursor.current), - (context = getMaskedContext(workInProgress, context))); - var getDerivedStateFromProps = Component.getDerivedStateFromProps; - (instance = + ), + (nextProps = !0); + else if (null === current$$1) { + var instance = workInProgress.stateNode, + oldProps = workInProgress.memoizedProps; + instance.props = oldProps; + var oldContext = instance.context, + contextType = Component.contextType; + "object" === typeof contextType && null !== contextType + ? (contextType = ReactCurrentOwner$4.currentDispatcher.readContext( + contextType + )) + : ((contextType = isContextProvider(Component) + ? previousContext + : contextStackCursor.current), + (contextType = getMaskedContext(workInProgress, contextType))); + var getDerivedStateFromProps = Component.getDerivedStateFromProps, + hasNewLifecycles = "function" === typeof getDerivedStateFromProps || - "function" === typeof unmaskedContext.getSnapshotBeforeUpdate) || - ("function" !== - typeof unmaskedContext.UNSAFE_componentWillReceiveProps && - "function" !== typeof unmaskedContext.componentWillReceiveProps) || - ((isLegacyContextConsumer !== nextProps || oldContext !== context) && - callComponentWillReceiveProps( - workInProgress, - unmaskedContext, - nextProps, - context - )); - hasForceUpdate = !1; - var oldState = workInProgress.memoizedState; - oldContext = unmaskedContext.state = oldState; - var updateQueue = workInProgress.updateQueue; - null !== updateQueue && - (processUpdateQueue( + "function" === typeof instance.getSnapshotBeforeUpdate; + hasNewLifecycles || + ("function" !== typeof instance.UNSAFE_componentWillReceiveProps && + "function" !== typeof instance.componentWillReceiveProps) || + ((oldProps !== nextProps || oldContext !== contextType) && + callComponentWillReceiveProps( workInProgress, - updateQueue, + instance, nextProps, - unmaskedContext, - renderExpirationTime - ), - (oldContext = workInProgress.memoizedState)); - isLegacyContextConsumer !== nextProps || - oldState !== oldContext || - didPerformWorkStackCursor.current || - hasForceUpdate - ? ("function" === typeof getDerivedStateFromProps && - (applyDerivedStateFromProps( - workInProgress, - Component, - getDerivedStateFromProps, - nextProps - ), - (oldContext = workInProgress.memoizedState)), - (isLegacyContextConsumer = - hasForceUpdate || - checkShouldComponentUpdate( - workInProgress, - Component, - isLegacyContextConsumer, - nextProps, - oldState, - oldContext, - context - )) - ? (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 = context), - (nextProps = isLegacyContextConsumer)) - : ("function" === typeof unmaskedContext.componentDidMount && - (workInProgress.effectTag |= 4), - (nextProps = !1)); - } - else - (unmaskedContext = workInProgress.stateNode), - (isLegacyContextConsumer = workInProgress.memoizedProps), - (unmaskedContext.props = isLegacyContextConsumer), - (oldContext = unmaskedContext.context), - (context = Component.contextType), - "object" === typeof context && null !== context - ? (context = context.unstable_read()) - : ((context = isContextProvider(Component) + contextType + )); + hasForceUpdate = !1; + var oldState = workInProgress.memoizedState; + oldContext = instance.state = oldState; + var updateQueue = workInProgress.updateQueue; + null !== updateQueue && + (processUpdateQueue( + workInProgress, + updateQueue, + nextProps, + instance, + renderExpirationTime + ), + (oldContext = workInProgress.memoizedState)); + oldProps !== nextProps || + oldState !== oldContext || + didPerformWorkStackCursor.current || + hasForceUpdate + ? ("function" === typeof getDerivedStateFromProps && + (applyDerivedStateFromProps( + workInProgress, + Component, + getDerivedStateFromProps, + nextProps + ), + (oldContext = workInProgress.memoizedState)), + (oldProps = + hasForceUpdate || + checkShouldComponentUpdate( + workInProgress, + Component, + oldProps, + nextProps, + oldState, + oldContext, + contextType + )) + ? (hasNewLifecycles || + ("function" !== typeof instance.UNSAFE_componentWillMount && + "function" !== typeof instance.componentWillMount) || + ("function" === typeof instance.componentWillMount && + instance.componentWillMount(), + "function" === typeof instance.UNSAFE_componentWillMount && + instance.UNSAFE_componentWillMount()), + "function" === typeof instance.componentDidMount && + (workInProgress.effectTag |= 4)) + : ("function" === typeof instance.componentDidMount && + (workInProgress.effectTag |= 4), + (workInProgress.memoizedProps = nextProps), + (workInProgress.memoizedState = oldContext)), + (instance.props = nextProps), + (instance.state = oldContext), + (instance.context = contextType), + (nextProps = oldProps)) + : ("function" === typeof instance.componentDidMount && + (workInProgress.effectTag |= 4), + (nextProps = !1)); + } else + (instance = workInProgress.stateNode), + (oldProps = workInProgress.memoizedProps), + (instance.props = oldProps), + (oldContext = instance.context), + (contextType = Component.contextType), + "object" === typeof contextType && null !== contextType + ? (contextType = ReactCurrentOwner$4.currentDispatcher.readContext( + contextType + )) + : ((contextType = isContextProvider(Component) ? previousContext : contextStackCursor.current), - (context = getMaskedContext(workInProgress, context))), + (contextType = getMaskedContext(workInProgress, contextType))), (getDerivedStateFromProps = Component.getDerivedStateFromProps), - (instance = + (hasNewLifecycles = "function" === typeof getDerivedStateFromProps || - "function" === typeof unmaskedContext.getSnapshotBeforeUpdate) || - ("function" !== - typeof unmaskedContext.UNSAFE_componentWillReceiveProps && - "function" !== typeof unmaskedContext.componentWillReceiveProps) || - ((isLegacyContextConsumer !== nextProps || oldContext !== context) && + "function" === typeof instance.getSnapshotBeforeUpdate) || + ("function" !== typeof instance.UNSAFE_componentWillReceiveProps && + "function" !== typeof instance.componentWillReceiveProps) || + ((oldProps !== nextProps || oldContext !== contextType) && callComponentWillReceiveProps( workInProgress, - unmaskedContext, + instance, nextProps, - context + contextType )), (hasForceUpdate = !1), (oldContext = workInProgress.memoizedState), - (oldState = unmaskedContext.state = oldContext), + (oldState = instance.state = oldContext), (updateQueue = workInProgress.updateQueue), null !== updateQueue && (processUpdateQueue( workInProgress, updateQueue, nextProps, - unmaskedContext, + instance, renderExpirationTime ), (oldState = workInProgress.memoizedState)), - isLegacyContextConsumer !== nextProps || + oldProps !== nextProps || oldContext !== oldState || didPerformWorkStackCursor.current || hasForceUpdate @@ -3609,53 +3950,51 @@ function updateClassComponent( checkShouldComponentUpdate( workInProgress, Component, - isLegacyContextConsumer, + oldProps, nextProps, oldContext, oldState, - context + contextType )) - ? (instance || - ("function" !== - typeof unmaskedContext.UNSAFE_componentWillUpdate && - "function" !== typeof unmaskedContext.componentWillUpdate) || - ("function" === typeof unmaskedContext.componentWillUpdate && - unmaskedContext.componentWillUpdate( + ? (hasNewLifecycles || + ("function" !== typeof instance.UNSAFE_componentWillUpdate && + "function" !== typeof instance.componentWillUpdate) || + ("function" === typeof instance.componentWillUpdate && + instance.componentWillUpdate( nextProps, oldState, - context + contextType ), - "function" === - typeof unmaskedContext.UNSAFE_componentWillUpdate && - unmaskedContext.UNSAFE_componentWillUpdate( + "function" === typeof instance.UNSAFE_componentWillUpdate && + instance.UNSAFE_componentWillUpdate( nextProps, oldState, - context + contextType )), - "function" === typeof unmaskedContext.componentDidUpdate && + "function" === typeof instance.componentDidUpdate && (workInProgress.effectTag |= 4), - "function" === typeof unmaskedContext.getSnapshotBeforeUpdate && + "function" === typeof instance.getSnapshotBeforeUpdate && (workInProgress.effectTag |= 256)) - : ("function" !== typeof unmaskedContext.componentDidUpdate || - (isLegacyContextConsumer === current$$1.memoizedProps && + : ("function" !== typeof instance.componentDidUpdate || + (oldProps === current$$1.memoizedProps && oldContext === current$$1.memoizedState) || (workInProgress.effectTag |= 4), - "function" !== typeof unmaskedContext.getSnapshotBeforeUpdate || - (isLegacyContextConsumer === current$$1.memoizedProps && + "function" !== typeof instance.getSnapshotBeforeUpdate || + (oldProps === current$$1.memoizedProps && oldContext === current$$1.memoizedState) || (workInProgress.effectTag |= 256), (workInProgress.memoizedProps = nextProps), (workInProgress.memoizedState = oldState)), - (unmaskedContext.props = nextProps), - (unmaskedContext.state = oldState), - (unmaskedContext.context = context), + (instance.props = nextProps), + (instance.state = oldState), + (instance.context = contextType), (nextProps = getDerivedStateFromProps)) - : ("function" !== typeof unmaskedContext.componentDidUpdate || - (isLegacyContextConsumer === current$$1.memoizedProps && + : ("function" !== typeof instance.componentDidUpdate || + (oldProps === current$$1.memoizedProps && oldContext === current$$1.memoizedState) || (workInProgress.effectTag |= 4), - "function" !== typeof unmaskedContext.getSnapshotBeforeUpdate || - (isLegacyContextConsumer === current$$1.memoizedProps && + "function" !== typeof instance.getSnapshotBeforeUpdate || + (oldProps === current$$1.memoizedProps && oldContext === current$$1.memoizedState) || (workInProgress.effectTag |= 256), (nextProps = !1)); @@ -3718,7 +4057,6 @@ function finishClassComponent( renderExpirationTime ); workInProgress.memoizedState = shouldUpdate.state; - workInProgress.memoizedProps = shouldUpdate.props; hasContext && invalidateContextProvider(workInProgress, Component, !0); return workInProgress.child; } @@ -3744,6 +4082,105 @@ function resolveDefaultProps(Component, baseProps) { } return baseProps; } +function updateSuspenseComponent( + current$$1, + workInProgress, + renderExpirationTime +) { + var mode = workInProgress.mode, + nextProps = workInProgress.pendingProps, + nextState = workInProgress.memoizedState; + null !== nextState && + (nextState.alreadyCaptured + ? null !== current$$1 && nextState === current$$1.memoizedState + ? (nextState = { + alreadyCaptured: !0, + didTimeout: !0, + timedOutAt: nextState.timedOutAt + }) + : ((nextState.alreadyCaptured = !0), (nextState.didTimeout = !0)) + : (nextState = null)); + var nextDidTimeout = null !== nextState && nextState.didTimeout; + if (null === current$$1) + nextDidTimeout + ? ((nextDidTimeout = nextProps.fallback), + (nextProps = createFiberFromFragment(null, mode, 0, null)), + (mode = createFiberFromFragment( + nextDidTimeout, + mode, + renderExpirationTime, + null + )), + (nextProps.sibling = mode), + (renderExpirationTime = nextProps), + (renderExpirationTime.return = mode.return = workInProgress)) + : (renderExpirationTime = mode = mountChildFibers( + workInProgress, + null, + nextProps.children, + renderExpirationTime + )); + else { + var prevState = current$$1.memoizedState; + null !== prevState && prevState.didTimeout + ? ((mode = current$$1.child), + (current$$1 = mode.sibling), + nextDidTimeout + ? ((renderExpirationTime = nextProps.fallback), + (mode = createWorkInProgress(mode, mode.pendingProps, 0)), + (mode.effectTag |= 2), + (nextProps = mode.sibling = createWorkInProgress( + current$$1, + renderExpirationTime, + current$$1.expirationTime + )), + (nextProps.effectTag |= 2), + (renderExpirationTime = mode), + (mode.childExpirationTime = 0), + (mode = nextProps), + (renderExpirationTime.return = mode.return = workInProgress)) + : ((nextDidTimeout = current$$1.child), + (mode = reconcileChildFibers( + workInProgress, + mode.child, + nextProps.children, + renderExpirationTime + )), + reconcileChildFibers( + workInProgress, + nextDidTimeout, + null, + renderExpirationTime + ), + (renderExpirationTime = mode))) + : ((current$$1 = current$$1.child), + nextDidTimeout + ? ((nextDidTimeout = nextProps.fallback), + (nextProps = createFiberFromFragment(null, mode, 0, null)), + (nextProps.effectTag |= 2), + (nextProps.child = current$$1), + (current$$1.return = nextProps), + (mode = nextProps.sibling = createFiberFromFragment( + nextDidTimeout, + mode, + renderExpirationTime, + null + )), + (mode.effectTag |= 2), + (renderExpirationTime = nextProps), + (nextProps.childExpirationTime = 0), + (renderExpirationTime.return = mode.return = workInProgress)) + : (mode = renderExpirationTime = reconcileChildFibers( + workInProgress, + current$$1, + nextProps.children, + renderExpirationTime + ))); + } + workInProgress.memoizedState = nextState; + workInProgress.child = renderExpirationTime; + return mode; +} function bailoutOnAlreadyFinishedWork( current$$1, workInProgress, @@ -3752,9 +4189,7 @@ function bailoutOnAlreadyFinishedWork( null !== current$$1 && (workInProgress.firstContextDependency = current$$1.firstContextDependency); profilerStartTime = -1; - var childExpirationTime = workInProgress.childExpirationTime; - if (0 === childExpirationTime || childExpirationTime > renderExpirationTime) - return null; + if (workInProgress.childExpirationTime < renderExpirationTime) return null; invariant( null === current$$1 || workInProgress.child === current$$1.child, "Resuming work not yet implemented." @@ -3783,561 +4218,566 @@ function bailoutOnAlreadyFinishedWork( } return workInProgress.child; } -function beginWork(current$$1, workInProgress, renderExpirationTime) { +function beginWork(current$$1, workInProgress, renderExpirationTime$jscomp$0) { var updateExpirationTime = workInProgress.expirationTime; if ( null !== current$$1 && current$$1.memoizedProps === workInProgress.pendingProps && !didPerformWorkStackCursor.current && - (0 === updateExpirationTime || updateExpirationTime > renderExpirationTime) + updateExpirationTime < renderExpirationTime$jscomp$0 ) { switch (workInProgress.tag) { - case 5: + case 3: pushHostRootContext(workInProgress); break; - case 7: + case 5: pushHostContext(workInProgress); break; - case 2: + case 1: isContextProvider(workInProgress.type) && pushContextProvider(workInProgress); break; - case 3: - isContextProvider(workInProgress.type._reactResult) && - pushContextProvider(workInProgress); - break; - case 6: + case 4: pushHostContainer( workInProgress, workInProgress.stateNode.containerInfo ); break; - case 12: + case 10: pushProvider(workInProgress, workInProgress.memoizedProps.value); break; - case 15: + case 12: workInProgress.effectTag |= 4; + break; + case 13: + if ( + ((updateExpirationTime = workInProgress.memoizedState), + null !== updateExpirationTime && updateExpirationTime.didTimeout) + ) { + updateExpirationTime = workInProgress.child.childExpirationTime; + if ( + 0 !== updateExpirationTime && + updateExpirationTime >= renderExpirationTime$jscomp$0 + ) + return updateSuspenseComponent( + current$$1, + workInProgress, + renderExpirationTime$jscomp$0 + ); + workInProgress = bailoutOnAlreadyFinishedWork( + current$$1, + workInProgress, + renderExpirationTime$jscomp$0 + ); + return null !== workInProgress ? workInProgress.sibling : null; + } } return bailoutOnAlreadyFinishedWork( current$$1, workInProgress, - renderExpirationTime + renderExpirationTime$jscomp$0 ); } workInProgress.expirationTime = 0; switch (workInProgress.tag) { - case 4: - var Component = workInProgress.type; - 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 resolvedTag = (workInProgress.tag = resolveLazyComponentTag( - workInProgress, - Component - )), - resolvedProps = resolveDefaultProps(Component, props), - child = void 0; - switch (resolvedTag) { - case 1: - child = updateFunctionComponent( - current$$1, - workInProgress, - Component, - resolvedProps, - renderExpirationTime - ); - break; - case 3: - child = updateClassComponent( - current$$1, - workInProgress, - Component, - resolvedProps, - renderExpirationTime - ); - break; - case 14: - child = updateForwardRef( - current$$1, - workInProgress, - Component, - resolvedProps, - renderExpirationTime - ); - break; - case 18: - child = updatePureComponent( - current$$1, - workInProgress, - Component, - resolvedProps, - updateExpirationTime, - renderExpirationTime - ); - break; - default: - invariant( - !1, - "Element type is invalid. Received a promise that resolves to: %s. Promise elements must resolve to a class or function.", - Component - ); - } - workInProgress.memoizedProps = props; - workInProgress = child; - } else - (updateExpirationTime = getMaskedContext( - workInProgress, - contextStackCursor.current - )), - prepareToReadContext(workInProgress, renderExpirationTime), - (updateExpirationTime = Component(props, updateExpirationTime)), - (workInProgress.effectTag |= 1), - "object" === typeof updateExpirationTime && - null !== updateExpirationTime && - "function" === typeof updateExpirationTime.render && - void 0 === updateExpirationTime.$$typeof - ? ((workInProgress.tag = 2), - isContextProvider(Component) - ? ((resolvedTag = !0), pushContextProvider(workInProgress)) - : (resolvedTag = !1), - (workInProgress.memoizedState = - null !== updateExpirationTime.state && - void 0 !== updateExpirationTime.state - ? updateExpirationTime.state - : null), - (resolvedProps = Component.getDerivedStateFromProps), - "function" === typeof resolvedProps && - applyDerivedStateFromProps( - workInProgress, - Component, - resolvedProps, - props - ), - (updateExpirationTime.updater = classComponentUpdater), - (workInProgress.stateNode = updateExpirationTime), - (updateExpirationTime._reactInternalFiber = workInProgress), - mountClassInstance( - workInProgress, - Component, - props, - renderExpirationTime - ), - (workInProgress = finishClassComponent( - current$$1, - workInProgress, - Component, - !0, - resolvedTag, - renderExpirationTime - ))) - : ((workInProgress.tag = 0), - reconcileChildren( - current$$1, - workInProgress, - updateExpirationTime, - renderExpirationTime - ), - (workInProgress.memoizedProps = props), - (workInProgress = workInProgress.child)); - return workInProgress; - case 0: - return updateFunctionComponent( - current$$1, + case 2: + updateExpirationTime = workInProgress.elementType; + null !== current$$1 && + ((current$$1.alternate = null), + (workInProgress.alternate = null), + (workInProgress.effectTag |= 2)); + current$$1 = workInProgress.pendingProps; + var context = getMaskedContext( workInProgress, - workInProgress.type, - workInProgress.pendingProps, - renderExpirationTime + contextStackCursor.current + ); + prepareToReadContext(workInProgress, renderExpirationTime$jscomp$0); + renderExpirationTime = renderExpirationTime$jscomp$0; + currentlyRenderingFiber$1 = workInProgress; + firstCurrentHook = null; + var value = updateExpirationTime(current$$1, context); + workInProgress.effectTag |= 1; + if ( + "object" === typeof value && + null !== value && + "function" === typeof value.render && + void 0 === value.$$typeof + ) { + workInProgress.tag = 1; + resetHooks(); + isContextProvider(updateExpirationTime) + ? ((context = !0), pushContextProvider(workInProgress)) + : (context = !1); + workInProgress.memoizedState = + null !== value.state && void 0 !== value.state ? value.state : null; + var getDerivedStateFromProps = + updateExpirationTime.getDerivedStateFromProps; + "function" === typeof getDerivedStateFromProps && + applyDerivedStateFromProps( + workInProgress, + updateExpirationTime, + getDerivedStateFromProps, + current$$1 + ); + value.updater = classComponentUpdater; + workInProgress.stateNode = value; + value._reactInternalFiber = workInProgress; + mountClassInstance( + workInProgress, + updateExpirationTime, + current$$1, + renderExpirationTime$jscomp$0 + ); + workInProgress = finishClassComponent( + null, + workInProgress, + updateExpirationTime, + !0, + context, + renderExpirationTime$jscomp$0 + ); + } else + (workInProgress.tag = 0), + (value = finishHooks( + updateExpirationTime, + current$$1, + value, + context + )), + reconcileChildren( + null, + workInProgress, + value, + renderExpirationTime$jscomp$0 + ), + (workInProgress = workInProgress.child); + return workInProgress; + case 16: + value = workInProgress.elementType; + null !== current$$1 && + ((current$$1.alternate = null), + (workInProgress.alternate = null), + (workInProgress.effectTag |= 2)); + context = workInProgress.pendingProps; + current$$1 = readLazyComponentType(value); + workInProgress.type = current$$1; + value = workInProgress.tag = resolveLazyComponentTag(current$$1); + context = resolveDefaultProps(current$$1, context); + getDerivedStateFromProps = void 0; + switch (value) { + case 0: + getDerivedStateFromProps = updateFunctionComponent( + null, + workInProgress, + current$$1, + context, + renderExpirationTime$jscomp$0 + ); + break; + case 1: + getDerivedStateFromProps = updateClassComponent( + null, + workInProgress, + current$$1, + context, + renderExpirationTime$jscomp$0 + ); + break; + case 11: + getDerivedStateFromProps = updateForwardRef( + null, + workInProgress, + current$$1, + context, + renderExpirationTime$jscomp$0 + ); + break; + case 14: + getDerivedStateFromProps = updateMemoComponent( + null, + workInProgress, + current$$1, + resolveDefaultProps(current$$1.type, context), + updateExpirationTime, + renderExpirationTime$jscomp$0 + ); + break; + default: + invariant( + !1, + "Element type is invalid. Received a promise that resolves to: %s. Promise elements must resolve to a class or function.", + current$$1 + ); + } + return getDerivedStateFromProps; + case 0: + return ( + (updateExpirationTime = workInProgress.type), + (value = workInProgress.pendingProps), + (value = + workInProgress.elementType === updateExpirationTime + ? value + : resolveDefaultProps(updateExpirationTime, value)), + updateFunctionComponent( + current$$1, + workInProgress, + updateExpirationTime, + value, + renderExpirationTime$jscomp$0 + ) ); case 1: return ( - (props = workInProgress.type._reactResult), - (Component = workInProgress.pendingProps), - (current$$1 = updateFunctionComponent( + (updateExpirationTime = workInProgress.type), + (value = workInProgress.pendingProps), + (value = + workInProgress.elementType === updateExpirationTime + ? value + : resolveDefaultProps(updateExpirationTime, value)), + updateClassComponent( current$$1, workInProgress, - props, - resolveDefaultProps(props, Component), - renderExpirationTime - )), - (workInProgress.memoizedProps = Component), - current$$1 - ); - case 2: - return updateClassComponent( - current$$1, - workInProgress, - workInProgress.type, - workInProgress.pendingProps, - renderExpirationTime + updateExpirationTime, + value, + renderExpirationTime$jscomp$0 + ) ); case 3: - return ( - (props = workInProgress.type._reactResult), - (Component = workInProgress.pendingProps), - (current$$1 = updateClassComponent( - current$$1, - workInProgress, - props, - resolveDefaultProps(props, Component), - renderExpirationTime - )), - (workInProgress.memoizedProps = Component), - current$$1 - ); - case 5: return ( pushHostRootContext(workInProgress), - (Component = workInProgress.updateQueue), + (updateExpirationTime = workInProgress.updateQueue), invariant( - null !== Component, + 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." ), - (props = workInProgress.memoizedState), - (props = null !== props ? props.element : null), + (value = workInProgress.memoizedState), + (value = null !== value ? value.element : null), processUpdateQueue( workInProgress, - Component, + updateExpirationTime, workInProgress.pendingProps, null, - renderExpirationTime + renderExpirationTime$jscomp$0 ), - (Component = workInProgress.memoizedState.element), - Component === props + (updateExpirationTime = workInProgress.memoizedState.element), + updateExpirationTime === value ? (workInProgress = bailoutOnAlreadyFinishedWork( current$$1, workInProgress, - renderExpirationTime + renderExpirationTime$jscomp$0 )) : (reconcileChildren( current$$1, workInProgress, - Component, - renderExpirationTime + updateExpirationTime, + renderExpirationTime$jscomp$0 ), (workInProgress = workInProgress.child)), workInProgress ); - case 7: + case 5: return ( pushHostContext(workInProgress), null === current$$1 && tryToClaimNextHydratableInstance(workInProgress), - (Component = workInProgress.pendingProps), - (props = Component.children), + (updateExpirationTime = workInProgress.pendingProps.children), markRef(current$$1, workInProgress), reconcileChildren( current$$1, workInProgress, - props, - renderExpirationTime + updateExpirationTime, + renderExpirationTime$jscomp$0 ), - (workInProgress.memoizedProps = Component), (workInProgress = workInProgress.child), workInProgress ); - case 8: + case 6: return ( null === current$$1 && tryToClaimNextHydratableInstance(workInProgress), - (workInProgress.memoizedProps = workInProgress.pendingProps), null ); - case 16: - return ( - (Component = workInProgress.pendingProps), - (props = 0 === (workInProgress.effectTag & 64)), - null !== current$$1 && null !== workInProgress.updateQueue - ? ((workInProgress.updateQueue = null), (props = !0)) - : (props = !props), - 0 !== (workInProgress.mode & 2) && - (props - ? (workInProgress.effectTag |= 4) - : (workInProgress.stateNode = null)), - (updateExpirationTime = Component.children), - (updateExpirationTime = - "function" === typeof updateExpirationTime - ? updateExpirationTime(props) - : props - ? Component.fallback - : updateExpirationTime), - null !== current$$1 && props !== workInProgress.memoizedState - ? ((workInProgress.child = reconcileChildFibers( - workInProgress, - current$$1.child, - null, - renderExpirationTime - )), - (workInProgress.child = reconcileChildFibers( - workInProgress, - null, - updateExpirationTime, - renderExpirationTime - ))) - : reconcileChildren( - current$$1, - workInProgress, - updateExpirationTime, - renderExpirationTime - ), - (workInProgress.memoizedProps = Component), - (workInProgress.memoizedState = props), - workInProgress.child + case 13: + return updateSuspenseComponent( + current$$1, + workInProgress, + renderExpirationTime$jscomp$0 ); - case 6: + case 4: return ( pushHostContainer( workInProgress, workInProgress.stateNode.containerInfo ), - (Component = workInProgress.pendingProps), + (updateExpirationTime = workInProgress.pendingProps), null === current$$1 ? (workInProgress.child = reconcileChildFibers( workInProgress, null, - Component, - renderExpirationTime + updateExpirationTime, + renderExpirationTime$jscomp$0 )) : reconcileChildren( current$$1, workInProgress, - Component, - renderExpirationTime + updateExpirationTime, + renderExpirationTime$jscomp$0 ), - (workInProgress.memoizedProps = Component), workInProgress.child ); - case 13: - return updateForwardRef( - current$$1, - workInProgress, - workInProgress.type, - workInProgress.pendingProps, - renderExpirationTime - ); - case 14: + case 11: return ( - (props = workInProgress.type._reactResult), - (Component = workInProgress.pendingProps), - (current$$1 = updateForwardRef( + (updateExpirationTime = workInProgress.type), + (value = workInProgress.pendingProps), + (value = + workInProgress.elementType === updateExpirationTime + ? value + : resolveDefaultProps(updateExpirationTime, value)), + updateForwardRef( current$$1, workInProgress, - props, - resolveDefaultProps(props, Component), - renderExpirationTime - )), - (workInProgress.memoizedProps = Component), - current$$1 + updateExpirationTime, + value, + renderExpirationTime$jscomp$0 + ) ); - case 9: + case 7: return ( - (Component = workInProgress.pendingProps), reconcileChildren( current$$1, workInProgress, - Component, - renderExpirationTime + workInProgress.pendingProps, + renderExpirationTime$jscomp$0 ), - (workInProgress.memoizedProps = Component), workInProgress.child ); - case 10: + case 8: return ( - (Component = workInProgress.pendingProps.children), reconcileChildren( current$$1, workInProgress, - Component, - renderExpirationTime + workInProgress.pendingProps.children, + renderExpirationTime$jscomp$0 ), - (workInProgress.memoizedProps = Component), - workInProgress.child - ); - case 15: - return ( - (workInProgress.effectTag |= 4), - (Component = workInProgress.pendingProps), - reconcileChildren( - current$$1, - workInProgress, - Component.children, - renderExpirationTime - ), - (workInProgress.memoizedProps = Component), workInProgress.child ); case 12: + return ( + (workInProgress.effectTag |= 4), + reconcileChildren( + current$$1, + workInProgress, + workInProgress.pendingProps.children, + renderExpirationTime$jscomp$0 + ), + workInProgress.child + ); + case 10: a: { - Component = workInProgress.type._context; - props = workInProgress.pendingProps; - resolvedTag = workInProgress.memoizedProps; - updateExpirationTime = props.value; - workInProgress.memoizedProps = props; - pushProvider(workInProgress, updateExpirationTime); - if (null !== resolvedTag) - if ( - ((resolvedProps = resolvedTag.value), - (updateExpirationTime = - (resolvedProps === updateExpirationTime && - (0 !== resolvedProps || - 1 / resolvedProps === 1 / updateExpirationTime)) || - (resolvedProps !== resolvedProps && - updateExpirationTime !== updateExpirationTime) - ? 0 - : ("function" === typeof Component._calculateChangedBits - ? Component._calculateChangedBits( - resolvedProps, - updateExpirationTime - ) - : 1073741823) | 0), - 0 === updateExpirationTime) - ) { + updateExpirationTime = workInProgress.type._context; + value = workInProgress.pendingProps; + getDerivedStateFromProps = workInProgress.memoizedProps; + context = value.value; + pushProvider(workInProgress, context); + if (null !== getDerivedStateFromProps) { + var oldValue = getDerivedStateFromProps.value; + context = + (oldValue === context && + (0 !== oldValue || 1 / oldValue === 1 / context)) || + (oldValue !== oldValue && context !== context) + ? 0 + : ("function" === + typeof updateExpirationTime._calculateChangedBits + ? updateExpirationTime._calculateChangedBits( + oldValue, + context + ) + : 1073741823) | 0; + if (0 === context) { if ( - resolvedTag.children === props.children && + getDerivedStateFromProps.children === value.children && !didPerformWorkStackCursor.current ) { workInProgress = bailoutOnAlreadyFinishedWork( current$$1, workInProgress, - renderExpirationTime + renderExpirationTime$jscomp$0 ); break a; } } else for ( - resolvedTag = workInProgress.child, - null !== resolvedTag && (resolvedTag.return = workInProgress); - null !== resolvedTag; + getDerivedStateFromProps = workInProgress.child, + null !== getDerivedStateFromProps && + (getDerivedStateFromProps.return = workInProgress); + null !== getDerivedStateFromProps; ) { - resolvedProps = resolvedTag.firstContextDependency; - if (null !== resolvedProps) { + oldValue = getDerivedStateFromProps.firstContextDependency; + if (null !== oldValue) { do { if ( - resolvedProps.context === Component && - 0 !== (resolvedProps.observedBits & updateExpirationTime) + oldValue.context === updateExpirationTime && + 0 !== (oldValue.observedBits & context) ) { - if (2 === resolvedTag.tag || 3 === resolvedTag.tag) - (child = createUpdate(renderExpirationTime)), - (child.tag = 2), - enqueueUpdate(resolvedTag, child); - if ( - 0 === resolvedTag.expirationTime || - resolvedTag.expirationTime > renderExpirationTime - ) - resolvedTag.expirationTime = renderExpirationTime; - child = resolvedTag.alternate; - null !== child && - (0 === child.expirationTime || - child.expirationTime > renderExpirationTime) && - (child.expirationTime = renderExpirationTime); - for (var node = resolvedTag.return; null !== node; ) { - child = node.alternate; + if (1 === getDerivedStateFromProps.tag) { + var nextFiber = createUpdate( + renderExpirationTime$jscomp$0 + ); + nextFiber.tag = 2; + enqueueUpdate(getDerivedStateFromProps, nextFiber); + } + getDerivedStateFromProps.expirationTime < + renderExpirationTime$jscomp$0 && + (getDerivedStateFromProps.expirationTime = renderExpirationTime$jscomp$0); + nextFiber = getDerivedStateFromProps.alternate; + null !== nextFiber && + nextFiber.expirationTime < + renderExpirationTime$jscomp$0 && + (nextFiber.expirationTime = renderExpirationTime$jscomp$0); + for ( + var node = getDerivedStateFromProps.return; + null !== node; + + ) { + nextFiber = node.alternate; if ( - 0 === node.childExpirationTime || - node.childExpirationTime > renderExpirationTime + node.childExpirationTime < renderExpirationTime$jscomp$0 ) - (node.childExpirationTime = renderExpirationTime), - null !== child && - (0 === child.childExpirationTime || - child.childExpirationTime > - renderExpirationTime) && - (child.childExpirationTime = renderExpirationTime); + (node.childExpirationTime = renderExpirationTime$jscomp$0), + null !== nextFiber && + nextFiber.childExpirationTime < + renderExpirationTime$jscomp$0 && + (nextFiber.childExpirationTime = renderExpirationTime$jscomp$0); else if ( - null !== child && - (0 === child.childExpirationTime || - child.childExpirationTime > renderExpirationTime) + null !== nextFiber && + nextFiber.childExpirationTime < + renderExpirationTime$jscomp$0 ) - child.childExpirationTime = renderExpirationTime; + nextFiber.childExpirationTime = renderExpirationTime$jscomp$0; else break; node = node.return; } } - child = resolvedTag.child; - resolvedProps = resolvedProps.next; - } while (null !== resolvedProps); + nextFiber = getDerivedStateFromProps.child; + oldValue = oldValue.next; + } while (null !== oldValue); } else - child = - 12 === resolvedTag.tag - ? resolvedTag.type === workInProgress.type + nextFiber = + 10 === getDerivedStateFromProps.tag + ? getDerivedStateFromProps.type === workInProgress.type ? null - : resolvedTag.child - : resolvedTag.child; - if (null !== child) child.return = resolvedTag; + : getDerivedStateFromProps.child + : getDerivedStateFromProps.child; + if (null !== nextFiber) + nextFiber.return = getDerivedStateFromProps; else - for (child = resolvedTag; null !== child; ) { - if (child === workInProgress) { - child = null; + for ( + nextFiber = getDerivedStateFromProps; + null !== nextFiber; + + ) { + if (nextFiber === workInProgress) { + nextFiber = null; break; } - resolvedTag = child.sibling; - if (null !== resolvedTag) { - resolvedTag.return = child.return; - child = resolvedTag; + getDerivedStateFromProps = nextFiber.sibling; + if (null !== getDerivedStateFromProps) { + getDerivedStateFromProps.return = nextFiber.return; + nextFiber = getDerivedStateFromProps; break; } - child = child.return; + nextFiber = nextFiber.return; } - resolvedTag = child; + getDerivedStateFromProps = nextFiber; } + } reconcileChildren( current$$1, workInProgress, - props.children, - renderExpirationTime + value.children, + renderExpirationTime$jscomp$0 ); workInProgress = workInProgress.child; } return workInProgress; - case 11: + case 9: return ( - (updateExpirationTime = workInProgress.type), - (Component = workInProgress.pendingProps), - (props = Component.children), - prepareToReadContext(workInProgress, renderExpirationTime), - (updateExpirationTime = readContext( - updateExpirationTime, - Component.unstable_observedBits - )), - (props = props(updateExpirationTime)), + (value = workInProgress.type), + (context = workInProgress.pendingProps), + (updateExpirationTime = context.children), + prepareToReadContext(workInProgress, renderExpirationTime$jscomp$0), + (value = readContext(value, context.unstable_observedBits)), + (updateExpirationTime = updateExpirationTime(value)), (workInProgress.effectTag |= 1), reconcileChildren( current$$1, workInProgress, - props, - renderExpirationTime + updateExpirationTime, + renderExpirationTime$jscomp$0 ), - (workInProgress.memoizedProps = Component), workInProgress.child ); - case 17: - return updatePureComponent( + case 14: + return ( + (value = workInProgress.type), + (context = resolveDefaultProps( + value.type, + workInProgress.pendingProps + )), + updateMemoComponent( + current$$1, + workInProgress, + value, + context, + updateExpirationTime, + renderExpirationTime$jscomp$0 + ) + ); + case 15: + return updateSimpleMemoComponent( current$$1, workInProgress, workInProgress.type, workInProgress.pendingProps, updateExpirationTime, - renderExpirationTime + renderExpirationTime$jscomp$0 ); - case 18: + case 17: return ( - (props = workInProgress.type._reactResult), - (Component = workInProgress.pendingProps), - (current$$1 = updatePureComponent( - current$$1, + (updateExpirationTime = workInProgress.type), + (value = workInProgress.pendingProps), + (value = + workInProgress.elementType === updateExpirationTime + ? value + : resolveDefaultProps(updateExpirationTime, value)), + null !== current$$1 && + ((current$$1.alternate = null), + (workInProgress.alternate = null), + (workInProgress.effectTag |= 2)), + (workInProgress.tag = 1), + isContextProvider(updateExpirationTime) + ? ((current$$1 = !0), pushContextProvider(workInProgress)) + : (current$$1 = !1), + prepareToReadContext(workInProgress, renderExpirationTime$jscomp$0), + constructClassInstance( workInProgress, - props, - resolveDefaultProps(props, Component), updateExpirationTime, - renderExpirationTime - )), - (workInProgress.memoizedProps = Component), - current$$1 + value, + renderExpirationTime$jscomp$0 + ), + mountClassInstance( + workInProgress, + updateExpirationTime, + value, + renderExpirationTime$jscomp$0 + ), + finishClassComponent( + null, + workInProgress, + updateExpirationTime, + !0, + current$$1, + renderExpirationTime$jscomp$0 + ) ); default: invariant( @@ -4346,14 +4786,125 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { ); } } -function appendAllChildren(parent, workInProgress) { +var appendAllChildren = void 0, + updateHostContainer = void 0, + updateHostComponent$1 = void 0, + updateHostText$1 = void 0; +appendAllChildren = function( + parent, + workInProgress, + needsVisibilityToggle, + isHidden +) { for (var node = workInProgress.child; null !== node; ) { - if (7 === node.tag || 8 === node.tag) - FabricUIManager.appendChild(parent.node, node.stateNode.node); - else if (6 !== node.tag && null !== node.child) { - node.child.return = node; - node = node.child; - continue; + a: if (5 === node.tag) { + var instance = node.stateNode; + if (needsVisibilityToggle) throw Error("Not yet implemented."); + FabricUIManager.appendChild(parent.node, instance.node); + } else if (6 === node.tag) { + instance = node.stateNode; + if (needsVisibilityToggle) { + instance = node.memoizedProps; + var rootContainerInstance = requiredContext( + rootInstanceStackCursor.current + ), + currentHostContext = requiredContext(contextStackCursor$1.current); + if (isHidden) throw Error("Not yet implemented."); + instance = createTextInstance( + instance, + rootContainerInstance, + currentHostContext, + workInProgress + ); + node.stateNode = instance; + } + FabricUIManager.appendChild(parent.node, instance.node); + } else if (4 !== node.tag) { + if ( + 13 === node.tag && + ((instance = node.alternate), + null !== instance && + ((instance = instance.memoizedState), + (rootContainerInstance = node.memoizedState), + (rootContainerInstance = + null !== rootContainerInstance && rootContainerInstance.didTimeout), + (null !== instance && instance.didTimeout) !== rootContainerInstance)) + ) { + instance = rootContainerInstance ? node.child : node; + null !== instance && + appendAllChildren(parent, instance, !0, rootContainerInstance); + break a; + } + if (null !== node.child) { + node.child.return = node; + node = node.child; + continue; + } + } + if (node === workInProgress) break; + for (; null === node.sibling; ) { + if (null === node.return || node.return === workInProgress) return; + node = node.return; + } + node.sibling.return = node.return; + node = node.sibling; + } +}; +function appendAllChildrenToContainer( + containerChildSet, + workInProgress, + needsVisibilityToggle, + isHidden +) { + for (var node = workInProgress.child; null !== node; ) { + a: if (5 === node.tag) { + var instance = node.stateNode; + if (needsVisibilityToggle) throw Error("Not yet implemented."); + FabricUIManager.appendChildToSet(containerChildSet, instance.node); + } else if (6 === node.tag) { + instance = node.stateNode; + if (needsVisibilityToggle) { + instance = node.memoizedProps; + var rootContainerInstance = requiredContext( + rootInstanceStackCursor.current + ), + currentHostContext = requiredContext(contextStackCursor$1.current); + if (isHidden) throw Error("Not yet implemented."); + instance = createTextInstance( + instance, + rootContainerInstance, + currentHostContext, + workInProgress + ); + node.stateNode = instance; + } + FabricUIManager.appendChildToSet(containerChildSet, instance.node); + } else if (4 !== node.tag) { + if ( + 13 === node.tag && + ((instance = node.alternate), + null !== instance && + ((instance = instance.memoizedState), + (rootContainerInstance = node.memoizedState), + (rootContainerInstance = + null !== rootContainerInstance && rootContainerInstance.didTimeout), + (null !== instance && instance.didTimeout) !== rootContainerInstance)) + ) { + instance = rootContainerInstance ? node.child : node; + null !== instance && + appendAllChildrenToContainer( + containerChildSet, + instance, + !0, + rootContainerInstance + ); + break a; + } + if (null !== node.child) { + node.child.return = node; + node = node.child; + continue; + } } if (node === workInProgress) break; for (; null === node.sibling; ) { @@ -4364,30 +4915,12 @@ function appendAllChildren(parent, workInProgress) { node = node.sibling; } } -var updateHostContainer = void 0, - updateHostComponent$1 = void 0, - updateHostText$1 = void 0; updateHostContainer = function(workInProgress) { var portalOrRoot = workInProgress.stateNode; if (null !== workInProgress.firstEffect) { var container = portalOrRoot.containerInfo, newChildSet = FabricUIManager.createChildSet(container); - a: for (var node = workInProgress.child; null !== node; ) { - if (7 === node.tag || 8 === node.tag) - FabricUIManager.appendChildToSet(newChildSet, node.stateNode.node); - else if (6 !== node.tag && null !== node.child) { - node.child.return = node; - node = node.child; - continue; - } - if (node === workInProgress) break a; - for (; null === node.sibling; ) { - if (null === node.return || node.return === workInProgress) break a; - node = node.return; - } - node.sibling.return = node.return; - node = node.sibling; - } + appendAllChildrenToContainer(newChildSet, workInProgress, !1, !1); portalOrRoot.pendingChildren = newChildSet; workInProgress.effectTag |= 4; FabricUIManager.completeRoot(container, newChildSet); @@ -4434,7 +4967,7 @@ updateHostComponent$1 = function(current, workInProgress, type, newProps) { (workInProgress.stateNode = type), current ? (workInProgress.effectTag |= 4) - : appendAllChildren(type, workInProgress)); + : appendAllChildren(type, workInProgress, !1, !1)); } }; updateHostText$1 = function(current, workInProgress, oldText, newText) { @@ -4468,7 +5001,6 @@ function logCapturedError(capturedError) { : Error("Unspecified error at:" + componentStack); ExceptionsManager.handleException(error, !1); } -var emptyObject$1 = {}; function logError(boundary, errorInfo) { var source = errorInfo.source, stack = errorInfo.stack; @@ -4485,7 +5017,7 @@ function logError(boundary, errorInfo) { willRetry: !1 }; null !== boundary && - 2 === boundary.tag && + 1 === boundary.tag && ((errorInfo.errorBoundary = boundary.stateNode), (errorInfo.errorBoundaryName = getComponentName(boundary.type)), (errorInfo.errorBoundaryFound = !0), @@ -4509,18 +5041,44 @@ function safelyDetachRef(current$$1) { } else ref.current = null; } +function commitHookEffectList(unmountTag, mountTag, finishedWork) { + finishedWork = finishedWork.updateQueue; + finishedWork = null !== finishedWork ? finishedWork.lastEffect : null; + if (null !== finishedWork) { + var effect = (finishedWork = finishedWork.next); + do { + if (0 !== (effect.tag & unmountTag)) { + var destroy = effect.destroy; + effect.destroy = null; + null !== destroy && destroy(); + } + 0 !== (effect.tag & mountTag) && + ((destroy = effect.create), + (destroy = destroy()), + (effect.destroy = "function" === typeof destroy ? destroy : null)); + effect = effect.next; + } while (effect !== finishedWork); + } +} function commitWork(current$$1, finishedWork) { switch (finishedWork.tag) { - case 2: - case 3: - break; - case 7: - break; - case 8: + case 0: + case 11: + case 14: + case 15: + commitHookEffectList(4, 8, finishedWork); + return; + } + switch (finishedWork.tag) { + case 1: break; case 5: + break; case 6: break; + case 3: + case 4: + break; default: invariant( !1, @@ -4528,9 +5086,6 @@ function commitWork(current$$1, finishedWork) { ); } } -function NoopComponent() { - return null; -} function createRootErrorUpdate(fiber, errorInfo, expirationTime) { expirationTime = createUpdate(expirationTime); expirationTime.tag = 3; @@ -4576,7 +5131,7 @@ function throwException( value, renderExpirationTime ) { - sourceFiber.effectTag |= 512; + sourceFiber.effectTag |= 1024; sourceFiber.firstEffect = sourceFiber.lastEffect = null; if ( null !== value && @@ -4588,49 +5143,54 @@ function throwException( var earliestTimeoutMs = -1, startTimeMs = -1; do { - if (16 === value.tag) { - var current = value.alternate; + if (13 === value.tag) { + var current$$1 = value.alternate; if ( - null !== current && - !0 === current.memoizedState && - null !== current.stateNode + null !== current$$1 && + ((current$$1 = current$$1.memoizedState), + null !== current$$1 && current$$1.didTimeout) ) { - startTimeMs = 10 * (current.stateNode.timedOutAt - 2); + startTimeMs = 10 * (1073741822 - current$$1.timedOutAt); break; } - current = value.pendingProps.maxDuration; - if ("number" === typeof current) - if (0 >= current) earliestTimeoutMs = 0; - else if (-1 === earliestTimeoutMs || current < earliestTimeoutMs) - earliestTimeoutMs = current; + current$$1 = value.pendingProps.maxDuration; + if ("number" === typeof current$$1) + if (0 >= current$$1) earliestTimeoutMs = 0; + else if (-1 === earliestTimeoutMs || current$$1 < earliestTimeoutMs) + earliestTimeoutMs = current$$1; } value = value.return; } while (null !== value); value = returnFiber; do { - if (16 === value.tag && !value.memoizedState) { + if ((current$$1 = 13 === value.tag)) + void 0 === value.memoizedProps.fallback + ? (current$$1 = !1) + : ((current$$1 = value.memoizedState), + (current$$1 = null === current$$1 || !current$$1.didTimeout)); + if (current$$1) { returnFiber = retrySuspendedRoot.bind( null, root, value, - 0 === (value.mode & 1) ? 1 : renderExpirationTime + sourceFiber, + 0 === (value.mode & 1) ? 1073741823 : renderExpirationTime ); returnFiber = tracing.unstable_wrap(returnFiber); thenable.then(returnFiber, returnFiber); - if (0 === (value.mode & 2)) { - value.effectTag |= 4; + if (0 === (value.mode & 1)) { + value.effectTag |= 32; reconcileChildren( sourceFiber.alternate, sourceFiber, null, renderExpirationTime ); - sourceFiber.effectTag &= -513; - 4 === sourceFiber.tag && (sourceFiber.tag = 0); - if (2 === sourceFiber.tag || 3 === sourceFiber.tag) - (sourceFiber.effectTag &= -421), - null === sourceFiber.alternate && - ((sourceFiber.tag = 0), (sourceFiber.type = NoopComponent)); + sourceFiber.effectTag &= -1025; + sourceFiber.effectTag &= -933; + 1 === sourceFiber.tag && + null === sourceFiber.alternate && + (sourceFiber.tag = 17); return; } -1 === earliestTimeoutMs @@ -4638,24 +5198,26 @@ function throwException( : (-1 === startTimeMs && (startTimeMs = 10 * - (findEarliestOutstandingPriorityLevel( - root, - renderExpirationTime - ) - - 2) - + (1073741822 - + findEarliestOutstandingPriorityLevel( + root, + renderExpirationTime + )) - 5e3), (root = startTimeMs + earliestTimeoutMs)); 0 <= root && nextLatestAbsoluteTimeoutMs < root && (nextLatestAbsoluteTimeoutMs = root); - value.effectTag |= 1024; + value.effectTag |= 2048; value.expirationTime = renderExpirationTime; return; } value = value.return; } while (null !== value); value = Error( - "An update was suspended, but no placeholder UI was provided." + (getComponentName(sourceFiber.type) || "A React component") + + " suspended while rendering, but no fallback UI was specified.\n\nAdd a component higher in the tree to provide a loading indicator or placeholder to display." + + getStackByFiberInDevAndProd(sourceFiber) ); } nextRenderDidError = !0; @@ -4663,9 +5225,9 @@ function throwException( root = returnFiber; do { switch (root.tag) { - case 5: + case 3: sourceFiber = value; - root.effectTag |= 1024; + root.effectTag |= 2048; root.expirationTime = renderExpirationTime; renderExpirationTime = createRootErrorUpdate( root, @@ -4674,8 +5236,7 @@ function throwException( ); enqueueCapturedUpdate(root, renderExpirationTime); return; - case 2: - case 3: + case 1: if ( ((sourceFiber = value), (returnFiber = root.type), @@ -4687,7 +5248,7 @@ function throwException( (null === legacyErrorBoundariesThatAlreadyFailed || !legacyErrorBoundariesThatAlreadyFailed.has(thenable))))) ) { - root.effectTag |= 1024; + root.effectTag |= 2048; root.expirationTime = renderExpirationTime; renderExpirationTime = createClassErrorUpdate( root, @@ -4703,24 +5264,14 @@ function throwException( } function unwindWork(workInProgress) { switch (workInProgress.tag) { - case 2: + case 1: isContextProvider(workInProgress.type) && popContext(workInProgress); var effectTag = workInProgress.effectTag; - return effectTag & 1024 - ? ((workInProgress.effectTag = (effectTag & -1025) | 64), + return effectTag & 2048 + ? ((workInProgress.effectTag = (effectTag & -2049) | 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), @@ -4729,28 +5280,117 @@ function unwindWork(workInProgress) { 0 === (effectTag & 64), "The root failed to unmount after an error. This is likely a bug in React. Please file an issue." ), - (workInProgress.effectTag = (effectTag & -1025) | 64), + (workInProgress.effectTag = (effectTag & -2049) | 64), workInProgress ); - case 7: + case 5: return popHostContext(workInProgress), null; - case 16: - return ( - (effectTag = workInProgress.effectTag), - effectTag & 1024 - ? ((workInProgress.effectTag = (effectTag & -1025) | 64), - workInProgress) - : null - ); - case 6: + case 13: + effectTag = workInProgress.effectTag; + if (effectTag & 2048) { + workInProgress.effectTag = (effectTag & -2049) | 64; + effectTag = workInProgress.alternate; + effectTag = null !== effectTag ? effectTag.memoizedState : null; + var nextState = workInProgress.memoizedState; + null === nextState + ? (nextState = { alreadyCaptured: !0, didTimeout: !1, timedOutAt: 0 }) + : effectTag === nextState + ? (nextState = { + alreadyCaptured: !0, + didTimeout: nextState.didTimeout, + timedOutAt: nextState.timedOutAt + }) + : (nextState.alreadyCaptured = !0); + workInProgress.memoizedState = nextState; + return workInProgress; + } + return null; + case 4: return popHostContainer(workInProgress), null; - case 12: + case 10: return popProvider(workInProgress), null; default: return null; } } -var Dispatcher = { readContext: readContext }, +var Dispatcher = { + readContext: readContext, + useCallback: function(callback, inputs) { + currentlyRenderingFiber$1 = resolveCurrentlyRenderingFiber(); + workInProgressHook = createWorkInProgressHook(); + inputs = void 0 !== inputs && null !== inputs ? inputs : [callback]; + var prevState = workInProgressHook.memoizedState; + if (null !== prevState && inputsAreEqual(inputs, prevState[1])) + return prevState[0]; + workInProgressHook.memoizedState = [callback, inputs]; + return callback; + }, + useContext: function(context, observedBits) { + resolveCurrentlyRenderingFiber(); + return readContext(context, observedBits); + }, + useEffect: function(create, inputs) { + useEffectImpl(516, 192, create, inputs); + }, + useImperativeMethods: function(ref, create, inputs) { + inputs = + null !== inputs && void 0 !== inputs + ? inputs.concat([ref]) + : [ref, create]; + useEffectImpl( + 4, + 36, + function() { + if ("function" === typeof ref) { + var _inst = create(); + ref(_inst); + return function() { + return ref(null); + }; + } + if (null !== ref && void 0 !== ref) + return ( + (_inst = create()), + (ref.current = _inst), + function() { + ref.current = null; + } + ); + }, + inputs + ); + }, + useLayoutEffect: function(create, inputs) { + useEffectImpl(4, 36, create, inputs); + }, + useMemo: function(nextCreate, inputs) { + currentlyRenderingFiber$1 = resolveCurrentlyRenderingFiber(); + workInProgressHook = createWorkInProgressHook(); + inputs = void 0 !== inputs && null !== inputs ? inputs : [nextCreate]; + var prevState = workInProgressHook.memoizedState; + if (null !== prevState && inputsAreEqual(inputs, prevState[1])) + return prevState[0]; + nextCreate = nextCreate(); + workInProgressHook.memoizedState = [nextCreate, inputs]; + return nextCreate; + }, + useMutationEffect: function(create, inputs) { + useEffectImpl(260, 10, create, inputs); + }, + useReducer: useReducer, + useRef: function(initialValue) { + currentlyRenderingFiber$1 = resolveCurrentlyRenderingFiber(); + workInProgressHook = createWorkInProgressHook(); + null === workInProgressHook.memoizedState + ? ((initialValue = { current: initialValue }), + (workInProgressHook.memoizedState = initialValue)) + : (initialValue = workInProgressHook.memoizedState); + return initialValue; + }, + useState: function(initialState) { + return useReducer(basicStateReducer, initialState); + } + }, ReactCurrentOwner$2 = ReactSharedInternals.ReactCurrentOwner; invariant( null != tracing.__interactionsRef && @@ -4765,6 +5405,9 @@ var isWorking = !1, nextRenderDidError = !1, nextEffect = null, isCommitting$1 = !1, + rootWithPendingPassiveEffects = null, + passiveEffectCallbackHandle = null, + passiveEffectCallback = null, legacyErrorBoundariesThatAlreadyFailed = null; function resetStack() { if (null !== nextUnitOfWork) @@ -4775,7 +5418,7 @@ function resetStack() { ) { var interruptedWork$jscomp$0 = interruptedWork; switch (interruptedWork$jscomp$0.tag) { - case 2: + case 1: var childContextTypes = interruptedWork$jscomp$0.type.childContextTypes; null !== childContextTypes && @@ -4783,23 +5426,16 @@ function resetStack() { 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 7: + case 5: popHostContext(interruptedWork$jscomp$0); break; - case 6: + case 4: popHostContainer(interruptedWork$jscomp$0); break; - case 12: + case 10: popProvider(interruptedWork$jscomp$0); } interruptedWork = interruptedWork.return; @@ -4840,23 +5476,46 @@ function commitAllHostEffects() { "function" === typeof onCommitFiberUnmount && onCommitFiberUnmount(current$$1$jscomp$0); switch (current$$1$jscomp$0.tag) { - case 2: - case 3: + case 0: + case 11: + case 14: + case 15: + var updateQueue = current$$1$jscomp$0.updateQueue; + if ( + null !== updateQueue && + ((updateQueue = updateQueue.lastEffect), null !== updateQueue) + ) { + var effect = (updateQueue = updateQueue.next); + do { + var destroy = effect.destroy; + if (null !== destroy) { + var current$$1$jscomp$1 = current$$1$jscomp$0; + try { + destroy(); + } catch (error) { + captureCommitPhaseError(current$$1$jscomp$1, error); + } + } + effect = effect.next; + } while (effect !== updateQueue); + } + break; + case 1: safelyDetachRef(current$$1$jscomp$0); - var instance = current$$1$jscomp$0.stateNode; - if ("function" === typeof instance.componentWillUnmount) + updateQueue = current$$1$jscomp$0.stateNode; + if ("function" === typeof updateQueue.componentWillUnmount) try { - (instance.props = current$$1$jscomp$0.memoizedProps), - (instance.state = current$$1$jscomp$0.memoizedState), - instance.componentWillUnmount(); + (updateQueue.props = current$$1$jscomp$0.memoizedProps), + (updateQueue.state = current$$1$jscomp$0.memoizedState), + updateQueue.componentWillUnmount(); } catch (unmountError) { captureCommitPhaseError(current$$1$jscomp$0, unmountError); } break; - case 7: + case 5: safelyDetachRef(current$$1$jscomp$0); break; - case 6: + case 4: FabricUIManager.createChildSet( current$$1$jscomp$0.stateNode.containerInfo ); @@ -4884,13 +5543,17 @@ function commitAllHostEffects() { } function commitBeforeMutationLifecycles() { for (; null !== nextEffect; ) { - if (nextEffect.effectTag & 256) { - var current$$1 = nextEffect.alternate; + if (nextEffect.effectTag & 256) a: { - var finishedWork = nextEffect; + var current$$1 = nextEffect.alternate, + finishedWork = nextEffect; switch (finishedWork.tag) { - case 2: - case 3: + case 0: + case 11: + case 15: + commitHookEffectList(2, 0, finishedWork); + break a; + case 1: if (finishedWork.effectTag & 256 && null !== current$$1) { var prevProps = current$$1.memoizedProps, prevState = current$$1.memoizedState; @@ -4904,10 +5567,11 @@ function commitBeforeMutationLifecycles() { current$$1.__reactInternalSnapshotBeforeUpdate = finishedWork; } break a; + case 3: case 5: - case 7: - case 8: case 6: + case 4: + case 17: break a; default: invariant( @@ -4916,7 +5580,6 @@ function commitBeforeMutationLifecycles() { ); } } - } nextEffect = nextEffect.nextEffect; } } @@ -4928,93 +5591,107 @@ function commitAllLifeCycles( 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) + current$$1 = nextEffect.alternate; + var newDidTimeout = nextEffect; + var committedExpirationTime = committedExpirationTime$jscomp$0; + switch (newDidTimeout.tag) { + case 0: + case 11: + case 15: + commitHookEffectList(16, 32, newDidTimeout); + break; + case 1: + finishedRoot = newDidTimeout.stateNode; + if (newDidTimeout.effectTag & 4) if (null === current$$1) - (finishedRoot.props = finishedWork.memoizedProps), - (finishedRoot.state = finishedWork.memoizedState), + (finishedRoot.props = newDidTimeout.memoizedProps), + (finishedRoot.state = newDidTimeout.memoizedState), finishedRoot.componentDidMount(); else { var prevProps = current$$1.memoizedProps; current$$1 = current$$1.memoizedState; - finishedRoot.props = finishedWork.memoizedProps; - finishedRoot.state = finishedWork.memoizedState; + finishedRoot.props = newDidTimeout.memoizedProps; + finishedRoot.state = newDidTimeout.memoizedState; finishedRoot.componentDidUpdate( prevProps, current$$1, finishedRoot.__reactInternalSnapshotBeforeUpdate ); } - current$$1 = finishedWork.updateQueue; + current$$1 = newDidTimeout.updateQueue; null !== current$$1 && - ((finishedRoot.props = finishedWork.memoizedProps), - (finishedRoot.state = finishedWork.memoizedState), + ((finishedRoot.props = newDidTimeout.memoizedProps), + (finishedRoot.state = newDidTimeout.memoizedState), commitUpdateQueue( - finishedWork, + newDidTimeout, current$$1, finishedRoot, committedExpirationTime )); break; - case 5: - current$$1 = finishedWork.updateQueue; + case 3: + current$$1 = newDidTimeout.updateQueue; if (null !== current$$1) { finishedRoot = null; - if (null !== finishedWork.child) - switch (finishedWork.child.tag) { - case 7: - finishedRoot = finishedWork.child.stateNode.canonical; + if (null !== newDidTimeout.child) + switch (newDidTimeout.child.tag) { + case 5: + finishedRoot = newDidTimeout.child.stateNode.canonical; break; - case 2: - case 3: - finishedRoot = finishedWork.child.stateNode; + case 1: + finishedRoot = newDidTimeout.child.stateNode; } commitUpdateQueue( - finishedWork, + newDidTimeout, current$$1, finishedRoot, committedExpirationTime ); } break; - case 7: + case 5: null === current$$1 && - finishedWork.effectTag & 4 && + newDidTimeout.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; + case 4: + break; + case 12: + committedExpirationTime = newDidTimeout.memoizedProps.onRender; committedExpirationTime( - finishedWork.memoizedProps.id, + newDidTimeout.memoizedProps.id, null === current$$1 ? "mount" : "update", - finishedWork.actualDuration, - finishedWork.treeBaseDuration, - finishedWork.actualStartTime, + newDidTimeout.actualDuration, + newDidTimeout.treeBaseDuration, + newDidTimeout.actualStartTime, commitTime, finishedRoot.memoizedInteractions ); break; - case 16: - 0 === (finishedWork.mode & 2) - ? ((finishedWork.updateQueue = emptyObject$1), - scheduleWork(finishedWork, 1)) - : ((committedExpirationTime = requestCurrentTime()), - (finishedWork.stateNode = { - timedOutAt: committedExpirationTime - })); + case 13: + if (newDidTimeout.effectTag & 32) { + newDidTimeout.memoizedState = { + alreadyCaptured: !0, + didTimeout: !1, + timedOutAt: 0 + }; + flushPassiveEffects(); + scheduleWork(newDidTimeout, 1073741823); + break; + } + committedExpirationTime = newDidTimeout.memoizedState; + null !== committedExpirationTime && + (newDidTimeout = committedExpirationTime.didTimeout) && + ((committedExpirationTime.alreadyCaptured = !1), + 0 === committedExpirationTime.timedOutAt && + (committedExpirationTime.timedOutAt = requestCurrentTime())); + break; + case 17: break; default: invariant( @@ -5023,21 +5700,51 @@ function commitAllLifeCycles( ); } } - if (effectTag & 128 && ((effectTag = nextEffect.ref), null !== effectTag)) { - finishedWork = nextEffect.stateNode; + if ( + effectTag & 128 && + ((newDidTimeout = nextEffect.ref), null !== newDidTimeout) + ) { + committedExpirationTime = nextEffect.stateNode; switch (nextEffect.tag) { - case 7: - finishedWork = finishedWork.canonical; + case 5: + committedExpirationTime = committedExpirationTime.canonical; } - "function" === typeof effectTag - ? effectTag(finishedWork) - : (effectTag.current = finishedWork); + "function" === typeof newDidTimeout + ? newDidTimeout(committedExpirationTime) + : (newDidTimeout.current = committedExpirationTime); } - effectTag = nextEffect.nextEffect; - nextEffect.nextEffect = null; - nextEffect = effectTag; + effectTag & 512 && (rootWithPendingPassiveEffects = finishedRoot$jscomp$0); + nextEffect = nextEffect.nextEffect; } } +function commitPassiveEffects(root, firstEffect) { + passiveEffectCallback = passiveEffectCallbackHandle = rootWithPendingPassiveEffects = null; + var previousIsRendering = isRendering; + isRendering = !0; + do { + if (firstEffect.effectTag & 512) { + var didError = !1, + error = void 0; + try { + var finishedWork = firstEffect; + commitHookEffectList(128, 0, finishedWork); + commitHookEffectList(0, 64, finishedWork); + } catch (e) { + (didError = !0), (error = e); + } + didError && captureCommitPhaseError(firstEffect, error); + } + firstEffect = firstEffect.nextEffect; + } while (null !== firstEffect); + isRendering = previousIsRendering; + previousIsRendering = root.expirationTime; + 0 !== previousIsRendering && requestWork(root, previousIsRendering); +} +function flushPassiveEffects() { + null !== passiveEffectCallback && + (scheduler.unstable_cancelCallback(passiveEffectCallbackHandle), + passiveEffectCallback()); +} function commitRoot(root, finishedWork) { isCommitting$1 = isWorking = !0; invariant( @@ -5054,9 +5761,7 @@ function commitRoot(root, finishedWork) { childExpirationTimeBeforeCommit = finishedWork.childExpirationTime; markCommittedPriorityLevels( root, - 0 === updateExpirationTimeBeforeCommit || - (0 !== childExpirationTimeBeforeCommit && - childExpirationTimeBeforeCommit < updateExpirationTimeBeforeCommit) + childExpirationTimeBeforeCommit > updateExpirationTimeBeforeCommit ? childExpirationTimeBeforeCommit : updateExpirationTimeBeforeCommit ); @@ -5106,29 +5811,42 @@ function commitRoot(root, finishedWork) { } root.current = finishedWork; for (nextEffect = childExpirationTimeBeforeCommit; null !== nextEffect; ) { - childExpirationTimeBeforeCommit = !1; - didError = void 0; + didError = !1; + error$jscomp$0 = void 0; try { commitAllLifeCycles(root, committedExpirationTime); } catch (e) { - (childExpirationTimeBeforeCommit = !0), (didError = e); + (didError = !0), (error$jscomp$0 = e); } - childExpirationTimeBeforeCommit && + didError && (invariant( null !== nextEffect, "Should have next effect. This error is likely caused by a bug in React. Please file an issue." ), - captureCommitPhaseError(nextEffect, didError), + captureCommitPhaseError(nextEffect, error$jscomp$0), null !== nextEffect && (nextEffect = nextEffect.nextEffect)); } + null !== childExpirationTimeBeforeCommit && + null !== rootWithPendingPassiveEffects && + ((childExpirationTimeBeforeCommit = commitPassiveEffects.bind( + null, + root, + childExpirationTimeBeforeCommit + )), + (childExpirationTimeBeforeCommit = tracing.unstable_wrap( + childExpirationTimeBeforeCommit + )), + (passiveEffectCallbackHandle = scheduler.unstable_scheduleCallback( + childExpirationTimeBeforeCommit + )), + (passiveEffectCallback = childExpirationTimeBeforeCommit)); isWorking = isCommitting$1 = !1; "function" === typeof onCommitFiberRoot && onCommitFiberRoot(finishedWork.stateNode); childExpirationTimeBeforeCommit = finishedWork.expirationTime; finishedWork = finishedWork.childExpirationTime; var earliestRemainingTimeAfterCommit = - 0 === childExpirationTimeBeforeCommit || - (0 !== finishedWork && finishedWork < childExpirationTimeBeforeCommit) + finishedWork > childExpirationTimeBeforeCommit ? finishedWork : childExpirationTimeBeforeCommit; 0 === earliestRemainingTimeAfterCommit && @@ -5153,21 +5871,18 @@ function commitRoot(root, finishedWork) { scheduledInteractions, scheduledExpirationTime ) { - if ( - 0 === earliestRemainingTimeAfterCommit || - scheduledExpirationTime < earliestRemainingTimeAfterCommit - ) - pendingInteractionMap.delete(scheduledExpirationTime), - scheduledInteractions.forEach(function(interaction) { - interaction.__count--; - if (null !== subscriber && 0 === interaction.__count) - try { - subscriber.onInteractionScheduledWorkCompleted(interaction); - } catch (error) { - hasUnhandledError || - ((hasUnhandledError = !0), (unhandledError = error)); - } - }); + scheduledExpirationTime > earliestRemainingTimeAfterCommit && + (pendingInteractionMap.delete(scheduledExpirationTime), + scheduledInteractions.forEach(function(interaction) { + interaction.__count--; + if (null !== subscriber && 0 === interaction.__count) + try { + subscriber.onInteractionScheduledWorkCompleted(interaction); + } catch (error) { + hasUnhandledError || + ((hasUnhandledError = !0), (unhandledError = error)); + } + })); }); } } @@ -5176,7 +5891,7 @@ function completeUnitOfWork(workInProgress) { var current$$1 = workInProgress.alternate, returnFiber = workInProgress.return, siblingFiber = workInProgress.sibling; - if (0 === (workInProgress.effectTag & 512)) { + if (0 === (workInProgress.effectTag & 1024)) { if (workInProgress.mode & 4) { var fiber = workInProgress; profilerStartTime = now$1(); @@ -5186,17 +5901,17 @@ function completeUnitOfWork(workInProgress) { current$$1 = workInProgress; fiber = current$$1.pendingProps; switch (current$$1.tag) { - case 0: - case 1: - break; case 2: + break; + case 16: + break; + case 15: + case 0: + break; + case 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); fiber = current$$1.stateNode; @@ -5207,7 +5922,7 @@ function completeUnitOfWork(workInProgress) { current$$1.effectTag &= -3; updateHostContainer(current$$1); break; - case 7: + case 5: popHostContext(current$$1); var rootContainerInstance = requiredContext( rootInstanceStackCursor.current @@ -5249,7 +5964,7 @@ function completeUnitOfWork(workInProgress) { ); fiber = new ReactFabricHostComponent(current, viewConfig, fiber); fiber = { node: rootContainerInstance, canonical: fiber }; - appendAllChildren(fiber, current$$1); + appendAllChildren(fiber, current$$1, !1, !1); current$$1.stateNode = fiber; null !== current$$1.ref && (current$$1.effectTag |= 128); } else @@ -5258,7 +5973,7 @@ 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 8: + case 6: current && null != current$$1.stateNode ? updateHostText$1( current, @@ -5282,34 +5997,36 @@ function completeUnitOfWork(workInProgress) { current$$1 ))); break; + case 11: + break; case 13: - case 14: + fiber = current$$1.memoizedState; + rootContainerInstance = + null !== current ? current.memoizedState : null; + (null !== fiber && fiber.didTimeout) !== + (null !== rootContainerInstance && + rootContainerInstance.didTimeout) && (current$$1.effectTag |= 4); break; - case 16: + case 7: break; - case 9: + case 8: break; - case 10: + case 12: break; - case 15: - break; - case 6: + case 4: popHostContainer(current$$1); updateHostContainer(current$$1); break; - case 12: + case 10: popProvider(current$$1); break; - case 11: + case 9: + break; + case 14: break; case 17: - case 18: + isContextProvider(current$$1.type) && popContext(current$$1); break; - 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." - ); default: invariant( !1, @@ -5321,8 +6038,8 @@ function completeUnitOfWork(workInProgress) { stopProfilerTimerIfRunningAndRecordDelta(workInProgress, !1); current$$1 = workInProgress; if ( - 1073741823 === nextRenderExpirationTime || - 1073741823 !== current$$1.childExpirationTime + 1 === nextRenderExpirationTime || + 1 !== current$$1.childExpirationTime ) { fiber = 0; if (current$$1.mode & 4) { @@ -5331,23 +6048,15 @@ function completeUnitOfWork(workInProgress) { viewConfig = null === current$$1.alternate || current$$1.child !== current$$1.alternate.child; - for (type = current$$1.child; null !== type; ) { - internalInstanceHandle = type.expirationTime; - currentHostContext = type.childExpirationTime; - if ( - 0 === fiber || - (0 !== internalInstanceHandle && internalInstanceHandle < fiber) - ) - fiber = internalInstanceHandle; - if ( - 0 === fiber || - (0 !== currentHostContext && currentHostContext < fiber) - ) - fiber = currentHostContext; - viewConfig && (rootContainerInstance += type.actualDuration); - current += type.treeBaseDuration; - type = type.sibling; - } + for (type = current$$1.child; null !== type; ) + (internalInstanceHandle = type.expirationTime), + (currentHostContext = type.childExpirationTime), + internalInstanceHandle > fiber && + (fiber = internalInstanceHandle), + currentHostContext > fiber && (fiber = currentHostContext), + viewConfig && (rootContainerInstance += type.actualDuration), + (current += type.treeBaseDuration), + (type = type.sibling); current$$1.actualDuration = rootContainerInstance; current$$1.treeBaseDuration = current; } else @@ -5355,19 +6064,16 @@ function completeUnitOfWork(workInProgress) { rootContainerInstance = current$$1.child; null !== rootContainerInstance; - ) { - current = rootContainerInstance.expirationTime; - viewConfig = rootContainerInstance.childExpirationTime; - if (0 === fiber || (0 !== current && current < fiber)) - fiber = current; - if (0 === fiber || (0 !== viewConfig && viewConfig < fiber)) - fiber = viewConfig; - rootContainerInstance = rootContainerInstance.sibling; - } + ) + (current = rootContainerInstance.expirationTime), + (viewConfig = rootContainerInstance.childExpirationTime), + current > fiber && (fiber = current), + viewConfig > fiber && (fiber = viewConfig), + (rootContainerInstance = rootContainerInstance.sibling); current$$1.childExpirationTime = fiber; } null !== returnFiber && - 0 === (returnFiber.effectTag & 512) && + 0 === (returnFiber.effectTag & 1024) && (null === returnFiber.firstEffect && (returnFiber.firstEffect = workInProgress.firstEffect), null !== workInProgress.lastEffect && @@ -5391,12 +6097,12 @@ function completeUnitOfWork(workInProgress) { (siblingFiber = siblingFiber.sibling); workInProgress.actualDuration = returnFiber; } - workInProgress.effectTag &= 511; + workInProgress.effectTag &= 1023; return workInProgress; } null !== returnFiber && ((returnFiber.firstEffect = returnFiber.lastEffect = null), - (returnFiber.effectTag |= 512)); + (returnFiber.effectTag |= 1024)); } if (null !== siblingFiber) return siblingFiber; if (null !== returnFiber) workInProgress = returnFiber; @@ -5411,17 +6117,19 @@ function performUnitOfWork(workInProgress) { 0 > workInProgress.actualStartTime && (workInProgress.actualStartTime = now$1())); current$$1 = beginWork(current$$1, workInProgress, nextRenderExpirationTime); + workInProgress.memoizedProps = workInProgress.pendingProps; workInProgress.mode & 4 && stopProfilerTimerIfRunningAndRecordDelta(workInProgress, !0); null === current$$1 && (current$$1 = completeUnitOfWork(workInProgress)); ReactCurrentOwner$2.current = null; return current$$1; } -function renderRoot(root, isYieldy, isExpired) { +function renderRoot(root, isYieldy) { invariant( !isWorking, "renderRoot was called recursively. This error is likely caused by a bug in React. Please file an issue." ); + flushPassiveEffects(); isWorking = !0; ReactCurrentOwner$2.currentDispatcher = Dispatcher; var expirationTime = root.nextExpirationTimeToWorkOn; @@ -5444,7 +6152,7 @@ function renderRoot(root, isYieldy, isExpired) { scheduledInteractions, scheduledExpirationTime ) { - scheduledExpirationTime <= expirationTime && + scheduledExpirationTime >= expirationTime && scheduledInteractions.forEach(function(interaction) { return interactions.add(interaction); }); @@ -5470,13 +6178,17 @@ function renderRoot(root, isYieldy, isExpired) { do { try { if (isYieldy) - for (; null !== nextUnitOfWork && !shouldYield(); ) + for (; null !== nextUnitOfWork && !shouldYieldToRenderer(); ) nextUnitOfWork = performUnitOfWork(nextUnitOfWork); else for (; null !== nextUnitOfWork; ) nextUnitOfWork = performUnitOfWork(nextUnitOfWork); } catch (thrownValue) { - if (null === nextUnitOfWork) + if ( + ((lastContextWithAllBitsObserved = lastContextDependency = currentlyRenderingFiber = null), + resetHooks(), + null === nextUnitOfWork) + ) (threadID = !0), onUncaughtError(thrownValue); else { invariant( @@ -5504,168 +6216,153 @@ function renderRoot(root, isYieldy, isExpired) { tracing.__interactionsRef.current = subscriber; isWorking = !1; lastContextWithAllBitsObserved = lastContextDependency = currentlyRenderingFiber = ReactCurrentOwner$2.currentDispatcher = null; + resetHooks(); if (threadID) (nextRoot = null), (root.finishedWork = null); else if (null !== nextUnitOfWork) root.finishedWork = null; else { - isYieldy = root.current.alternate; + subscriber = root.current.alternate; invariant( - null !== isYieldy, + null !== subscriber, "Finished root should have a work-in-progress. This error is likely caused by a bug in React. Please file an issue." ); nextRoot = null; if (nextRenderDidError) { if (hasLowerPriorityWork(root, expirationTime)) { markSuspendedPriorityLevel(root, expirationTime); - onSuspend(root, isYieldy, expirationTime, root.expirationTime, -1); + onSuspend(root, subscriber, expirationTime, root.expirationTime, -1); return; } - if (!root.didError && !isExpired) { + if (!root.didError && isYieldy) { root.didError = !0; - isExpired = root.nextExpirationTimeToWorkOn = expirationTime; - subscriber = root.expirationTime = 1; - onSuspend(root, isYieldy, isExpired, subscriber, -1); + isYieldy = root.nextExpirationTimeToWorkOn = expirationTime; + threadID = root.expirationTime = 1073741823; + onSuspend(root, subscriber, isYieldy, threadID, -1); return; } } - isExpired || -1 === nextLatestAbsoluteTimeoutMs - ? onComplete(root, isYieldy, expirationTime) - : (markSuspendedPriorityLevel(root, expirationTime), - (isExpired = + isYieldy && -1 !== nextLatestAbsoluteTimeoutMs + ? (markSuspendedPriorityLevel(root, expirationTime), + (isYieldy = 10 * - (findEarliestOutstandingPriorityLevel(root, expirationTime) - 2)), - isExpired < nextLatestAbsoluteTimeoutMs && - (nextLatestAbsoluteTimeoutMs = isExpired), - (isExpired = 10 * (requestCurrentTime() - 2)), - (isExpired = nextLatestAbsoluteTimeoutMs - isExpired), + (1073741822 - + findEarliestOutstandingPriorityLevel(root, expirationTime))), + isYieldy < nextLatestAbsoluteTimeoutMs && + (nextLatestAbsoluteTimeoutMs = isYieldy), + (isYieldy = 10 * (1073741822 - requestCurrentTime())), + (isYieldy = nextLatestAbsoluteTimeoutMs - isYieldy), onSuspend( root, - isYieldy, + subscriber, expirationTime, root.expirationTime, - 0 > isExpired ? 0 : isExpired - )); + 0 > isYieldy ? 0 : isYieldy + )) + : onComplete(root, subscriber, expirationTime); } } -function captureCommitPhaseError(fiber, error) { - var JSCompiler_inline_result; - a: { - invariant( - !isWorking || isCommitting$1, - "dispatch: Cannot dispatch during the render phase." - ); - for ( - JSCompiler_inline_result = fiber.return; - null !== JSCompiler_inline_result; - - ) { - switch (JSCompiler_inline_result.tag) { - case 2: - case 3: - var instance = JSCompiler_inline_result.stateNode; - if ( - "function" === - typeof JSCompiler_inline_result.type.getDerivedStateFromError || - ("function" === typeof instance.componentDidCatch && - (null === legacyErrorBoundariesThatAlreadyFailed || - !legacyErrorBoundariesThatAlreadyFailed.has(instance))) - ) { - fiber = createCapturedValue(error, fiber); - fiber = createClassErrorUpdate(JSCompiler_inline_result, fiber, 1); - enqueueUpdate(JSCompiler_inline_result, fiber); - scheduleWork(JSCompiler_inline_result, 1); - JSCompiler_inline_result = void 0; - break a; - } - break; - case 5: - fiber = createCapturedValue(error, fiber); - fiber = createRootErrorUpdate(JSCompiler_inline_result, fiber, 1); - enqueueUpdate(JSCompiler_inline_result, fiber); - scheduleWork(JSCompiler_inline_result, 1); - JSCompiler_inline_result = void 0; - break a; - } - JSCompiler_inline_result = JSCompiler_inline_result.return; +function captureCommitPhaseError(sourceFiber, value) { + for (var fiber = sourceFiber.return; null !== fiber; ) { + switch (fiber.tag) { + case 1: + var instance = fiber.stateNode; + if ( + "function" === typeof fiber.type.getDerivedStateFromError || + ("function" === typeof instance.componentDidCatch && + (null === legacyErrorBoundariesThatAlreadyFailed || + !legacyErrorBoundariesThatAlreadyFailed.has(instance))) + ) { + sourceFiber = createCapturedValue(value, sourceFiber); + sourceFiber = createClassErrorUpdate(fiber, sourceFiber, 1073741823); + enqueueUpdate(fiber, sourceFiber); + scheduleWork(fiber, 1073741823); + return; + } + break; + case 3: + sourceFiber = createCapturedValue(value, sourceFiber); + sourceFiber = createRootErrorUpdate(fiber, sourceFiber, 1073741823); + enqueueUpdate(fiber, sourceFiber); + scheduleWork(fiber, 1073741823); + return; } - 5 === fiber.tag && - ((JSCompiler_inline_result = createCapturedValue(error, fiber)), - (JSCompiler_inline_result = createRootErrorUpdate( - fiber, - JSCompiler_inline_result, - 1 - )), - enqueueUpdate(fiber, JSCompiler_inline_result), - scheduleWork(fiber, 1)); - JSCompiler_inline_result = void 0; + fiber = fiber.return; } - return JSCompiler_inline_result; + 3 === sourceFiber.tag && + ((fiber = createCapturedValue(value, sourceFiber)), + (fiber = createRootErrorUpdate(sourceFiber, fiber, 1073741823)), + enqueueUpdate(sourceFiber, fiber), + scheduleWork(sourceFiber, 1073741823)); } function computeExpirationForFiber(currentTime, fiber) { isWorking - ? (currentTime = isCommitting$1 ? 1 : nextRenderExpirationTime) + ? (currentTime = isCommitting$1 ? 1073741823 : nextRenderExpirationTime) : fiber.mode & 1 ? ((currentTime = isBatchingInteractiveUpdates - ? 2 + 10 * ((((currentTime - 2 + 15) / 10) | 0) + 1) - : 2 + 25 * ((((currentTime - 2 + 500) / 25) | 0) + 1)), + ? 1073741822 - 10 * ((((1073741822 - currentTime + 15) / 10) | 0) + 1) + : 1073741822 - + 25 * ((((1073741822 - currentTime + 500) / 25) | 0) + 1)), null !== nextRoot && currentTime === nextRenderExpirationTime && - (currentTime += 1)) - : (currentTime = 1); + --currentTime) + : (currentTime = 1073741823); isBatchingInteractiveUpdates && - currentTime > lowestPriorityPendingInteractiveExpirationTime && + (0 === lowestPriorityPendingInteractiveExpirationTime || + currentTime < lowestPriorityPendingInteractiveExpirationTime) && (lowestPriorityPendingInteractiveExpirationTime = currentTime); return currentTime; } -function retrySuspendedRoot(root, fiber, suspendedTime) { +function retrySuspendedRoot(root, boundaryFiber, sourceFiber, suspendedTime) { var retryTime = root.earliestSuspendedTime; var latestSuspendedTime = root.latestSuspendedTime; if ( 0 !== retryTime && - suspendedTime >= retryTime && - suspendedTime <= latestSuspendedTime + suspendedTime <= retryTime && + suspendedTime >= latestSuspendedTime ) { latestSuspendedTime = retryTime = suspendedTime; root.didError = !1; var latestPingedTime = root.latestPingedTime; - if (0 === latestPingedTime || latestPingedTime < latestSuspendedTime) + if (0 === latestPingedTime || latestPingedTime > latestSuspendedTime) root.latestPingedTime = latestSuspendedTime; findNextExpirationTimeToWorkOn(latestSuspendedTime, root); } else (retryTime = requestCurrentTime()), - (retryTime = computeExpirationForFiber(retryTime, fiber)), + (retryTime = computeExpirationForFiber(retryTime, boundaryFiber)), markPendingPriorityLevel(root, retryTime); - 0 !== (fiber.mode & 1) && + 0 !== (boundaryFiber.mode & 1) && root === nextRoot && nextRenderExpirationTime === suspendedTime && (nextRoot = null); - scheduleWorkToRoot(fiber, retryTime); - fiber = root.expirationTime; - 0 !== fiber && requestWork(root, fiber); + scheduleWorkToRoot(boundaryFiber, retryTime); + 0 === (boundaryFiber.mode & 1) && + (scheduleWorkToRoot(sourceFiber, retryTime), + 1 === sourceFiber.tag && + null !== sourceFiber.stateNode && + ((boundaryFiber = createUpdate(retryTime)), + (boundaryFiber.tag = 2), + enqueueUpdate(sourceFiber, boundaryFiber))); + sourceFiber = root.expirationTime; + 0 !== sourceFiber && requestWork(root, sourceFiber); } function scheduleWorkToRoot(fiber, expirationTime) { - if (0 === fiber.expirationTime || fiber.expirationTime > expirationTime) - fiber.expirationTime = expirationTime; + fiber.expirationTime < expirationTime && + (fiber.expirationTime = expirationTime); var alternate = fiber.alternate; null !== alternate && - (0 === alternate.expirationTime || - alternate.expirationTime > expirationTime) && + alternate.expirationTime < expirationTime && (alternate.expirationTime = expirationTime); var node = fiber.return, root = null; - if (null === node && 5 === fiber.tag) root = fiber.stateNode; + if (null === node && 3 === fiber.tag) root = fiber.stateNode; else for (; null !== node; ) { alternate = node.alternate; - if ( - 0 === node.childExpirationTime || - node.childExpirationTime > expirationTime - ) - node.childExpirationTime = expirationTime; + node.childExpirationTime < expirationTime && + (node.childExpirationTime = expirationTime); null !== alternate && - (0 === alternate.childExpirationTime || - alternate.childExpirationTime > expirationTime) && + alternate.childExpirationTime < expirationTime && (alternate.childExpirationTime = expirationTime); - if (null === node.return && 5 === node.tag) { + if (null === node.return && 3 === node.tag) { root = node.stateNode; break; } @@ -5699,7 +6396,7 @@ function scheduleWork(fiber, expirationTime) { null !== fiber && (!isWorking && 0 !== nextRenderExpirationTime && - expirationTime < nextRenderExpirationTime && + expirationTime > nextRenderExpirationTime && resetStack(), markPendingPriorityLevel(fiber, expirationTime), (isWorking && !isCommitting$1 && nextRoot === fiber) || @@ -5719,27 +6416,25 @@ var firstScheduledRoot = null, nextFlushedRoot = null, nextFlushedExpirationTime = 0, lowestPriorityPendingInteractiveExpirationTime = 0, - deadlineDidExpire = !1, hasUnhandledError = !1, unhandledError = null, - deadline = null, isBatchingUpdates = !1, isUnbatchingUpdates = !1, isBatchingInteractiveUpdates = !1, completedBatches = null, originalStartTimeMs = now$1(), - currentRendererTime = ((originalStartTimeMs / 10) | 0) + 2, + currentRendererTime = 1073741822 - ((originalStartTimeMs / 10) | 0), currentSchedulerTime = currentRendererTime, NESTED_UPDATE_LIMIT = 50, nestedUpdateCount = 0, - lastCommittedRootDuringThisBatch = null, - timeHeuristicForUnitOfWork = 1; + lastCommittedRootDuringThisBatch = null; function recomputeCurrentRendererTime() { - currentRendererTime = (((now$1() - originalStartTimeMs) / 10) | 0) + 2; + currentRendererTime = + 1073741822 - (((now$1() - originalStartTimeMs) / 10) | 0); } function scheduleCallbackWithExpirationTime(root, expirationTime) { if (0 !== callbackExpirationTime) { - if (expirationTime > callbackExpirationTime) return; + if (expirationTime < callbackExpirationTime) return; null !== callbackID && ((root = callbackID), (scheduledCallback = null), clearTimeout(root)); } @@ -5760,7 +6455,7 @@ function onSuspend( msUntilTimeout ) { root.expirationTime = rootExpirationTime; - 0 !== msUntilTimeout || shouldYield() + 0 !== msUntilTimeout || shouldYieldToRenderer() ? 0 < msUntilTimeout && (root.timeoutHandle = scheduleTimeout( onTimeout.bind(null, root, finishedWork, suspendedExpirationTime), @@ -5780,8 +6475,8 @@ function onTimeout(root, finishedWork, suspendedExpirationTime) { ); nextFlushedRoot = root; nextFlushedExpirationTime = suspendedExpirationTime; - performWorkOnRoot(root, suspendedExpirationTime, !0); - performWork(1, null); + performWorkOnRoot(root, suspendedExpirationTime, !1); + performWork(1073741823, !1); } function onCommit(root, expirationTime) { root.expirationTime = expirationTime; @@ -5790,38 +6485,29 @@ function onCommit(root, expirationTime) { function requestCurrentTime() { if (isRendering) return currentSchedulerTime; findHighestPriorityRoot(); - if ( - 0 === nextFlushedExpirationTime || - 1073741823 === nextFlushedExpirationTime - ) + if (0 === nextFlushedExpirationTime || 1 === nextFlushedExpirationTime) recomputeCurrentRendererTime(), (currentSchedulerTime = currentRendererTime); return currentSchedulerTime; } function requestWork(root, expirationTime) { - if (null === root.nextScheduledRoot) - (root.expirationTime = expirationTime), + 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; - } + (lastScheduledRoot.nextScheduledRoot = firstScheduledRoot))) + : expirationTime > root.expirationTime && + (root.expirationTime = expirationTime); isRendering || (isBatchingUpdates ? isUnbatchingUpdates && ((nextFlushedRoot = root), - (nextFlushedExpirationTime = 1), - performWorkOnRoot(root, 1, !0)) - : 1 === expirationTime - ? performWork(1, null) + (nextFlushedExpirationTime = 1073741823), + performWorkOnRoot(root, 1073741823, !1)) + : 1073741823 === expirationTime + ? performWork(1073741823, !1) : scheduleCallbackWithExpirationTime(root, expirationTime)); } function findHighestPriorityRoot() { @@ -5857,14 +6543,11 @@ function findHighestPriorityRoot() { (root.nextScheduledRoot = null); root = previousScheduledRoot.nextScheduledRoot; } else { - if ( - 0 === highestPriorityWork || - remainingExpirationTime < highestPriorityWork - ) - (highestPriorityWork = remainingExpirationTime), - (highestPriorityRoot = root); + remainingExpirationTime > highestPriorityWork && + ((highestPriorityWork = remainingExpirationTime), + (highestPriorityRoot = root)); if (root === lastScheduledRoot) break; - if (1 === highestPriorityWork) break; + if (1073741823 === highestPriorityWork) break; previousScheduledRoot = root; root = root.nextScheduledRoot; } @@ -5872,38 +6555,44 @@ function findHighestPriorityRoot() { nextFlushedRoot = highestPriorityRoot; 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); +var didYield = !1; +function shouldYieldToRenderer() { + return didYield ? !0 : frameDeadline <= now$1() ? (didYield = !0) : !1; } -function performWork(minExpirationTime, dl) { - deadline = dl; +function performAsyncWork() { + try { + if (!shouldYieldToRenderer() && 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, !0); + } finally { + didYield = !1; + } +} +function performWork(minExpirationTime, isYieldy) { findHighestPriorityRoot(); - if (null !== deadline) + if (isYieldy) for ( recomputeCurrentRendererTime(), currentSchedulerTime = currentRendererTime; null !== nextFlushedRoot && 0 !== nextFlushedExpirationTime && - (0 === minExpirationTime || - minExpirationTime >= nextFlushedExpirationTime) && - (!deadlineDidExpire || currentRendererTime >= nextFlushedExpirationTime); + minExpirationTime <= nextFlushedExpirationTime && + !(didYield && currentRendererTime > nextFlushedExpirationTime); ) performWorkOnRoot( nextFlushedRoot, nextFlushedExpirationTime, - currentRendererTime >= nextFlushedExpirationTime + currentRendererTime > nextFlushedExpirationTime ), findHighestPriorityRoot(), recomputeCurrentRendererTime(), @@ -5913,29 +6602,28 @@ function performWork(minExpirationTime, dl) { ; null !== nextFlushedRoot && 0 !== nextFlushedExpirationTime && - (0 === minExpirationTime || - minExpirationTime >= nextFlushedExpirationTime); + minExpirationTime <= nextFlushedExpirationTime; ) - performWorkOnRoot(nextFlushedRoot, nextFlushedExpirationTime, !0), + performWorkOnRoot(nextFlushedRoot, nextFlushedExpirationTime, !1), findHighestPriorityRoot(); - null !== deadline && ((callbackExpirationTime = 0), (callbackID = null)); + isYieldy && ((callbackExpirationTime = 0), (callbackID = null)); 0 !== nextFlushedExpirationTime && scheduleCallbackWithExpirationTime( nextFlushedRoot, nextFlushedExpirationTime ); - deadline = null; - deadlineDidExpire = !1; nestedUpdateCount = 0; lastCommittedRootDuringThisBatch = null; if (null !== completedBatches) for ( - minExpirationTime = completedBatches, completedBatches = null, dl = 0; - dl < minExpirationTime.length; - dl++ + minExpirationTime = completedBatches, + completedBatches = null, + isYieldy = 0; + isYieldy < minExpirationTime.length; + isYieldy++ ) { - var batch = minExpirationTime[dl]; + var batch = minExpirationTime[isYieldy]; try { batch._onComplete(); } catch (error) { @@ -5949,45 +6637,45 @@ function performWork(minExpirationTime, dl) { (hasUnhandledError = !1), minExpirationTime); } -function performWorkOnRoot(root, expirationTime, isExpired) { +function performWorkOnRoot(root, expirationTime, isYieldy) { invariant( !isRendering, "performWorkOnRoot was called recursively. This error is likely caused by a bug in React. Please file an issue." ); isRendering = !0; - if (null === deadline || isExpired) { - var finishedWork = root.finishedWork; - null !== finishedWork - ? completeRoot$1(root, finishedWork, expirationTime) + if (isYieldy) { + var _finishedWork = root.finishedWork; + null !== _finishedWork + ? completeRoot$1(root, _finishedWork, expirationTime) : ((root.finishedWork = null), - (finishedWork = root.timeoutHandle), - -1 !== finishedWork && - ((root.timeoutHandle = -1), cancelTimeout(finishedWork)), - renderRoot(root, !1, isExpired), - (finishedWork = root.finishedWork), - null !== finishedWork && - completeRoot$1(root, finishedWork, expirationTime)); + (_finishedWork = root.timeoutHandle), + -1 !== _finishedWork && + ((root.timeoutHandle = -1), cancelTimeout(_finishedWork)), + renderRoot(root, isYieldy), + (_finishedWork = root.finishedWork), + null !== _finishedWork && + (shouldYieldToRenderer() + ? (root.finishedWork = _finishedWork) + : completeRoot$1(root, _finishedWork, expirationTime))); } else - (finishedWork = root.finishedWork), - null !== finishedWork - ? completeRoot$1(root, finishedWork, expirationTime) + (_finishedWork = root.finishedWork), + null !== _finishedWork + ? completeRoot$1(root, _finishedWork, expirationTime) : ((root.finishedWork = null), - (finishedWork = root.timeoutHandle), - -1 !== finishedWork && - ((root.timeoutHandle = -1), cancelTimeout(finishedWork)), - renderRoot(root, !0, isExpired), - (finishedWork = root.finishedWork), - null !== finishedWork && - (shouldYield() - ? (root.finishedWork = finishedWork) - : completeRoot$1(root, finishedWork, expirationTime))); + (_finishedWork = root.timeoutHandle), + -1 !== _finishedWork && + ((root.timeoutHandle = -1), cancelTimeout(_finishedWork)), + renderRoot(root, isYieldy), + (_finishedWork = root.finishedWork), + null !== _finishedWork && + completeRoot$1(root, _finishedWork, expirationTime)); isRendering = !1; } function completeRoot$1(root, finishedWork, expirationTime) { var firstBatch = root.firstBatch; if ( null !== firstBatch && - firstBatch._expirationTime <= expirationTime && + firstBatch._expirationTime >= expirationTime && (null === completedBatches ? (completedBatches = [firstBatch]) : completedBatches.push(firstBatch), @@ -6003,13 +6691,6 @@ function completeRoot$1(root, finishedWork, expirationTime) { : ((lastCommittedRootDuringThisBatch = root), (nestedUpdateCount = 0)); commitRoot(root, finishedWork); } -function shouldYield() { - return deadlineDidExpire - ? !0 - : null === deadline || deadline.timeRemaining() > timeHeuristicForUnitOfWork - ? !1 - : (deadlineDidExpire = !0); -} function onUncaughtError(error) { invariant( null !== nextFlushedRoot, @@ -6018,55 +6699,6 @@ function onUncaughtError(error) { nextFlushedRoot.expirationTime = 0; hasUnhandledError || ((hasUnhandledError = !0), (unhandledError = error)); } -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.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; void 0 === fiber && @@ -6085,7 +6717,48 @@ function updateContainer(element, container, parentComponent, callback) { currentTime = requestCurrentTime(); current$$1 = computeExpirationForFiber(currentTime, current$$1); currentTime = container.current; - parentComponent = getContextForSubtree(parentComponent); + a: if (parentComponent) { + parentComponent = parentComponent._reactInternalFiber; + b: { + invariant( + 2 === isFiberMountedImpl(parentComponent) && 1 === 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 3: + parentContext = parentContext.stateNode.context; + break b; + case 1: + if (isContextProvider(parentContext.type)) { + parentContext = + parentContext.stateNode + .__reactInternalMemoizedMergedChildContext; + break b; + } + } + 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 (1 === parentComponent.tag) { + var Component = parentComponent.type; + if (isContextProvider(Component)) { + parentComponent = processChildContext( + parentComponent, + Component, + parentContext + ); + break a; + } + } + parentComponent = parentContext; + } else parentComponent = emptyContextObject; null === container.context ? (container.context = parentComponent) : (container.pendingContext = parentComponent); @@ -6094,6 +6767,7 @@ function updateContainer(element, container, parentComponent, callback) { callback.payload = { element: element }; container = void 0 === container ? null : container; null !== container && (callback.callback = container); + flushPassiveEffects(); enqueueUpdate(currentTime, callback); scheduleWork(currentTime, current$$1); return current$$1; @@ -6153,13 +6827,13 @@ _batchedUpdatesImpl = function(fn, a) { } finally { (isBatchingUpdates = previousIsBatchingUpdates) || isRendering || - performWork(1, null); + performWork(1073741823, !1); } }; _flushInteractiveUpdatesImpl = function() { isRendering || 0 === lowestPriorityPendingInteractiveExpirationTime || - (performWork(lowestPriorityPendingInteractiveExpirationTime, null), + (performWork(lowestPriorityPendingInteractiveExpirationTime, !1), (lowestPriorityPendingInteractiveExpirationTime = 0)); }; var roots = new Map(), @@ -6241,7 +6915,7 @@ var roots = new Map(), if (!root) { root = 0; isDevToolsPresent && (root |= 4); - root = new FiberNode(5, null, null, root); + root = createFiber(3, null, null, root); var root$jscomp$0 = { current: root, containerInfo: containerTag, @@ -6272,7 +6946,7 @@ var roots = new Map(), updateContainer(element, root, null, callback); a: if (((element = root.current), element.child)) switch (element.child.tag) { - case 7: + case 5: element = element.child.stateNode.canonical; break a; default: @@ -6369,7 +7043,7 @@ var roots = new Map(), findFiberByHostInstance: getInstanceFromInstance, getInspectorDataForViewTag: getInspectorDataForViewTag, bundleType: 0, - version: "16.6.0-alpha.8af6728", + version: "16.6.0", rendererPackageName: "react-native-renderer" }); var ReactFabric$2 = { default: ReactFabric }, diff --git a/Libraries/Renderer/oss/ReactNativeRenderer-dev.js b/Libraries/Renderer/oss/ReactNativeRenderer-dev.js index e77e96de3..9c112c83d 100644 --- a/Libraries/Renderer/oss/ReactNativeRenderer-dev.js +++ b/Libraries/Renderer/oss/ReactNativeRenderer-dev.js @@ -27,6 +27,7 @@ var flattenStyle = require("flattenStyle"); var TextInputState = require("TextInputState"); var checkPropTypes = require("prop-types/checkPropTypes"); var tracing = require("scheduler/tracing"); +var scheduler = require("scheduler"); var ExceptionsManager = require("ExceptionsManager"); /** @@ -1133,24 +1134,23 @@ function runExtractedEventsInBatch( } var FunctionComponent = 0; -var FunctionComponentLazy = 1; -var ClassComponent = 2; -var ClassComponentLazy = 3; -var IndeterminateComponent = 4; // Before we know whether it is function 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 SuspenseComponent = 16; -var PureComponent = 17; -var PureComponentLazy = 18; +var ClassComponent = 1; +var IndeterminateComponent = 2; // Before we know whether it is function or class +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 = 7; +var Mode = 8; +var ContextConsumer = 9; +var ContextProvider = 10; +var ForwardRef = 11; +var Profiler = 12; +var SuspenseComponent = 13; +var MemoComponent = 14; +var SimpleMemoComponent = 15; +var LazyComponent = 16; +var IncompleteClassComponent = 17; function getParent(inst) { do { @@ -2923,6 +2923,7 @@ var REACT_STRICT_MODE_TYPE = hasSymbol var REACT_PROFILER_TYPE = hasSymbol ? Symbol.for("react.profiler") : 0xead2; var REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for("react.provider") : 0xeacd; var REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for("react.context") : 0xeace; + var REACT_CONCURRENT_MODE_TYPE = hasSymbol ? Symbol.for("react.concurrent_mode") : 0xeacf; @@ -2930,7 +2931,8 @@ var REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for("react.forward_ref") : 0xead0; var REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for("react.suspense") : 0xead1; -var REACT_PURE_TYPE = hasSymbol ? Symbol.for("react.pure") : 0xead3; +var REACT_MEMO_TYPE = hasSymbol ? Symbol.for("react.memo") : 0xead3; +var REACT_LAZY_TYPE = hasSymbol ? Symbol.for("react.lazy") : 0xead4; var MAYBE_ITERATOR_SYMBOL = typeof Symbol === "function" && Symbol.iterator; var FAUX_ITERATOR_SYMBOL = "@@iterator"; @@ -2952,12 +2954,8 @@ 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 refineResolvedLazyComponent(lazyComponent) { + return lazyComponent._status === Resolved ? lazyComponent._result : null; } function getWrappedName(outerType, innerType, wrapperName) { @@ -3010,14 +3008,14 @@ function getComponentName(type) { return "Context.Provider"; case REACT_FORWARD_REF_TYPE: return getWrappedName(type, type.render, "ForwardRef"); - case REACT_PURE_TYPE: - return getWrappedName(type, type.render, "Pure"); - } - if (typeof type.then === "function") { - var thenable = type; - var resolvedThenable = refineResolvedThenable(thenable); - if (resolvedThenable) { - return getComponentName(resolvedThenable); + case REACT_MEMO_TYPE: + return getComponentName(type.type); + case REACT_LAZY_TYPE: { + var thenable = type; + var resolvedThenable = refineResolvedLazyComponent(thenable); + if (resolvedThenable) { + return getComponentName(resolvedThenable); + } } } } @@ -3038,15 +3036,16 @@ var Callback = /* */ 32; var DidCapture = /* */ 64; var Ref = /* */ 128; var Snapshot = /* */ 256; +var Passive = /* */ 512; -// Update & Callback & Ref & Snapshot -var LifecycleEffectMask = /* */ 420; +// Passive & Update & Callback & Ref & Snapshot +var LifecycleEffectMask = /* */ 932; // Union of all host effects -var HostEffectMask = /* */ 511; +var HostEffectMask = /* */ 1023; -var Incomplete = /* */ 512; -var ShouldCapture = /* */ 1024; +var Incomplete = /* */ 1024; +var ShouldCapture = /* */ 2048; var ReactCurrentOwner$1 = ReactSharedInternals.ReactCurrentOwner; @@ -3090,10 +3089,7 @@ function isFiberMounted(fiber) { function isMounted(component) { { var owner = ReactCurrentOwner$1.current; - if ( - owner !== null && - (owner.tag === ClassComponent || owner.tag === ClassComponentLazy) - ) { + if (owner !== null && owner.tag === ClassComponent) { var ownerFiber = owner; var instance = ownerFiber.stateNode; !instance._warnedAboutRefsInRender @@ -3888,13 +3884,6 @@ var now$1 = hasNativePerformanceNow var scheduledCallback = null; var frameDeadline = 0; -var frameDeadlineObject = { - timeRemaining: function() { - return frameDeadline - now$1(); - }, - didTimeout: false -}; - function setTimeoutCallback() { // TODO (bvaughn) Hard-coded 5ms unblocks initial async testing. // React API probably changing to boolean rather than time remaining. @@ -3905,7 +3894,7 @@ function setTimeoutCallback() { var callback = scheduledCallback; scheduledCallback = null; if (callback !== null) { - callback(frameDeadlineObject); + callback(); } } @@ -3924,6 +3913,10 @@ function cancelDeferredCallback$1(callbackID) { clearTimeout(callbackID); // Timeouts are always numbers on RN } +function shouldYield$1() { + return frameDeadline <= now$1(); +} + // Renderers that don't support persistence // can re-export everything from this module. @@ -3943,6 +3936,9 @@ var createContainerChildSet = shim; var appendChildToContainerChildSet = shim; var finalizeContainerChildren = shim; var replaceContainerChildren = shim; +var cloneHiddenInstance = shim; +var cloneUnhiddenInstance = shim; +var createHiddenTextInstance = shim; // Renderers that don't support hydration // can re-export everything from this module. @@ -4151,6 +4147,7 @@ var now = now$1; var isPrimaryRenderer = true; var scheduleDeferredCallback = scheduleDeferredCallback$1; var cancelDeferredCallback = cancelDeferredCallback$1; +var shouldYield = shouldYield$1; var scheduleTimeout = setTimeout; var cancelTimeout = clearTimeout; @@ -4328,6 +4325,22 @@ function resetTextContent(instance) { // Noop } +function hideInstance(instance) { + throw new Error("Not yet implemented."); +} + +function hideTextInstance(textInstance) { + throw new Error("Not yet implemented."); +} + +function unhideInstance(instance, props) { + throw new Error("Not yet implemented."); +} + +function unhideTextInstance(textInstance, text) { + throw new Error("Not yet implemented."); +} + var BEFORE_SLASH_RE = /^(.*)[\\\/]/; var describeComponentFrame = function(name, source, ownerName) { @@ -4361,12 +4374,12 @@ var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame; function describeFiber(fiber) { switch (fiber.tag) { case IndeterminateComponent: + case LazyComponent: case FunctionComponent: - case FunctionComponentLazy: case ClassComponent: - case ClassComponentLazy: case HostComponent: case Mode: + case SuspenseComponent: var owner = fiber._debugOwner; var source = fiber._debugSource; var name = getComponentName(fiber.type); @@ -4442,6 +4455,7 @@ function setCurrentPhase(lifeCyclePhase) { var debugRenderPhaseSideEffects = false; var debugRenderPhaseSideEffectsForStrictMode = false; + var enableUserTimingAPI = true; var replayFailedUnitOfWorkWithInvokeGuardedCallback = true; var warnAboutDeprecatedLifecycles = false; @@ -5214,8 +5228,7 @@ function findCurrentUnmaskedContext(fiber) { // Currently this is only used with renderSubtreeIntoContainer; not sure if it // makes sense elsewhere invariant( - isFiberMounted(fiber) && - (fiber.tag === ClassComponent || fiber.tag === ClassComponentLazy), + isFiberMounted(fiber) && fiber.tag === ClassComponent, "Expected subtree parent to be a mounted class component. " + "This error is likely caused by a bug in React. Please file an issue." ); @@ -5232,13 +5245,6 @@ function findCurrentUnmaskedContext(fiber) { } break; } - case ClassComponentLazy: { - var _Component = getResultFromResolvedThenable(node.type); - if (isContextProvider(_Component)) { - return node.stateNode.__reactInternalMemoizedMergedChildContext; - } - break; - } } node = node.return; } while (node !== null); @@ -5337,20 +5343,20 @@ function onCommitUnmount(fiber) { var maxSigned31BitInt = 1073741823; var NoWork = 0; -var Sync = 1; -var Never = maxSigned31BitInt; +var Never = 1; +var Sync = maxSigned31BitInt; var UNIT_SIZE = 10; -var MAGIC_NUMBER_OFFSET = 2; +var MAGIC_NUMBER_OFFSET = maxSigned31BitInt - 1; // 1 unit of expiration time represents 10ms. function msToExpirationTime(ms) { // Always add an offset so that we don't clash with the magic number for NoWork. - return ((ms / UNIT_SIZE) | 0) + MAGIC_NUMBER_OFFSET; + return MAGIC_NUMBER_OFFSET - ((ms / UNIT_SIZE) | 0); } function expirationTimeToMs(expirationTime) { - return (expirationTime - MAGIC_NUMBER_OFFSET) * UNIT_SIZE; + return (MAGIC_NUMBER_OFFSET - expirationTime) * UNIT_SIZE; } function ceiling(num, precision) { @@ -5359,9 +5365,9 @@ function ceiling(num, precision) { function computeExpirationBucket(currentTime, expirationInMs, bucketSizeMs) { return ( - MAGIC_NUMBER_OFFSET + + MAGIC_NUMBER_OFFSET - ceiling( - currentTime - MAGIC_NUMBER_OFFSET + expirationInMs / UNIT_SIZE, + MAGIC_NUMBER_OFFSET - currentTime + expirationInMs / UNIT_SIZE, bucketSizeMs / UNIT_SIZE ) ); @@ -5437,6 +5443,7 @@ function FiberNode(tag, pendingProps, key, mode) { // Instance this.tag = tag; this.key = key; + this.elementType = null; this.type = null; this.stateNode = null; @@ -5509,18 +5516,24 @@ function shouldConstruct(Component) { return !!(prototype && prototype.isReactComponent); } -function resolveLazyComponentTag(fiber, Component) { +function isSimpleFunctionComponent(type) { + return ( + typeof type === "function" && + !shouldConstruct(type) && + type.defaultProps === undefined + ); +} + +function resolveLazyComponentTag(Component) { if (typeof Component === "function") { - return shouldConstruct(Component) - ? ClassComponentLazy - : FunctionComponentLazy; + return shouldConstruct(Component) ? ClassComponent : FunctionComponent; } else if (Component !== undefined && Component !== null) { var $$typeof = Component.$$typeof; if ($$typeof === REACT_FORWARD_REF_TYPE) { - return ForwardRefLazy; + return ForwardRef; } - if ($$typeof === REACT_PURE_TYPE) { - return PureComponentLazy; + if ($$typeof === REACT_MEMO_TYPE) { + return MemoComponent; } } return IndeterminateComponent; @@ -5541,6 +5554,7 @@ function createWorkInProgress(current, pendingProps, expirationTime) { current.key, current.mode ); + workInProgress.elementType = current.elementType; workInProgress.type = current.type; workInProgress.stateNode = current.stateNode; @@ -5610,20 +5624,23 @@ function createHostRootFiber(isConcurrent) { return createFiber(HostRoot, null, null, mode); } -function createFiberFromElement(element, mode, expirationTime) { - var owner = null; - { - owner = element._owner; - } - +function createFiberFromTypeAndProps( + type, // React$ElementType + key, + pendingProps, + owner, + mode, + expirationTime +) { var fiber = void 0; - var type = element.type; - var key = element.key; - var pendingProps = element.props; - var fiberTag = void 0; + var fiberTag = IndeterminateComponent; + // The resolved type is set if we know what the final type will be. I.e. it's not lazy. + var resolvedType = type; if (typeof type === "function") { - fiberTag = shouldConstruct(type) ? ClassComponent : IndeterminateComponent; + if (shouldConstruct(type)) { + fiberTag = ClassComponent; + } } else if (typeof type === "string") { fiberTag = HostComponent; } else { @@ -5636,18 +5653,23 @@ function createFiberFromElement(element, mode, expirationTime) { key ); case REACT_CONCURRENT_MODE_TYPE: - fiberTag = Mode; - mode |= ConcurrentMode | StrictMode; - break; + return createFiberFromMode( + pendingProps, + mode | ConcurrentMode | StrictMode, + expirationTime, + key + ); case REACT_STRICT_MODE_TYPE: - fiberTag = Mode; - mode |= StrictMode; - break; + return createFiberFromMode( + pendingProps, + mode | StrictMode, + expirationTime, + key + ); case REACT_PROFILER_TYPE: return createFiberFromProfiler(pendingProps, mode, expirationTime, key); case REACT_SUSPENSE_TYPE: - fiberTag = SuspenseComponent; - break; + return createFiberFromSuspense(pendingProps, mode, expirationTime, key); default: { if (typeof type === "object" && type !== null) { switch (type.$$typeof) { @@ -5661,15 +5683,13 @@ function createFiberFromElement(element, mode, expirationTime) { case REACT_FORWARD_REF_TYPE: fiberTag = ForwardRef; break getTag; - case REACT_PURE_TYPE: - fiberTag = PureComponent; + case REACT_MEMO_TYPE: + fiberTag = MemoComponent; + break getTag; + case REACT_LAZY_TYPE: + fiberTag = LazyComponent; + resolvedType = null; break getTag; - default: { - if (typeof type.then === "function") { - fiberTag = IndeterminateComponent; - break getTag; - } - } } } var info = ""; @@ -5703,14 +5723,33 @@ function createFiberFromElement(element, mode, expirationTime) { } fiber = createFiber(fiberTag, pendingProps, key, mode); - fiber.type = type; + fiber.elementType = type; + fiber.type = resolvedType; fiber.expirationTime = expirationTime; + return fiber; +} + +function createFiberFromElement(element, mode, expirationTime) { + var owner = null; + { + owner = element._owner; + } + var type = element.type; + var key = element.key; + var pendingProps = element.props; + var fiber = createFiberFromTypeAndProps( + type, + key, + pendingProps, + owner, + mode, + expirationTime + ); { fiber._debugSource = element._source; fiber._debugOwner = element._owner; } - return fiber; } @@ -5734,12 +5773,41 @@ function createFiberFromProfiler(pendingProps, mode, expirationTime, key) { } var fiber = createFiber(Profiler, pendingProps, key, mode | ProfileMode); + // TODO: The Profiler fiber shouldn't have a type. It has a tag. + fiber.elementType = REACT_PROFILER_TYPE; fiber.type = REACT_PROFILER_TYPE; fiber.expirationTime = expirationTime; return fiber; } +function createFiberFromMode(pendingProps, mode, expirationTime, key) { + var fiber = createFiber(Mode, pendingProps, key, mode); + + // TODO: The Mode fiber shouldn't have a type. It has a tag. + var type = + (mode & ConcurrentMode) === NoContext + ? REACT_STRICT_MODE_TYPE + : REACT_CONCURRENT_MODE_TYPE; + fiber.elementType = type; + fiber.type = type; + + fiber.expirationTime = expirationTime; + return fiber; +} + +function createFiberFromSuspense(pendingProps, mode, expirationTime, key) { + var fiber = createFiber(SuspenseComponent, pendingProps, key, mode); + + // TODO: The SuspenseComponent fiber shouldn't have a type. It has a tag. + var type = REACT_SUSPENSE_TYPE; + fiber.elementType = type; + fiber.type = type; + + fiber.expirationTime = expirationTime; + return fiber; +} + function createFiberFromText(content, mode, expirationTime) { var fiber = createFiber(HostText, content, null, mode); fiber.expirationTime = expirationTime; @@ -5748,6 +5816,8 @@ function createFiberFromText(content, mode, expirationTime) { function createFiberFromHostInstanceForDeletion() { var fiber = createFiber(HostComponent, null, null, NoContext); + // TODO: These should not need a type. + fiber.elementType = "DELETED"; fiber.type = "DELETED"; return fiber; } @@ -5780,6 +5850,7 @@ function assignFiberPropertiesInDEV(target, source) { target.tag = source.tag; target.key = source.key; + target.elementType = source.elementType; target.type = source.type; target.stateNode = source.stateNode; target.return = source.return; @@ -6322,12 +6393,12 @@ function markPendingPriorityLevel(root, expirationTime) { // No other pending updates. root.earliestPendingTime = root.latestPendingTime = expirationTime; } else { - if (earliestPendingTime > expirationTime) { + if (earliestPendingTime < expirationTime) { // This is the earliest pending update. root.earliestPendingTime = expirationTime; } else { var latestPendingTime = root.latestPendingTime; - if (latestPendingTime < expirationTime) { + if (latestPendingTime > expirationTime) { // This is the latest pending update root.latestPendingTime = expirationTime; } @@ -6353,12 +6424,12 @@ function markCommittedPriorityLevels(root, earliestRemainingTime) { // Let's see if the previous latest known pending level was just flushed. var latestPendingTime = root.latestPendingTime; if (latestPendingTime !== NoWork) { - if (latestPendingTime < earliestRemainingTime) { + if (latestPendingTime > earliestRemainingTime) { // We've flushed all the known pending levels. root.earliestPendingTime = root.latestPendingTime = NoWork; } else { var earliestPendingTime = root.earliestPendingTime; - if (earliestPendingTime < earliestRemainingTime) { + if (earliestPendingTime > earliestRemainingTime) { // We've flushed the earliest known pending level. Set this to the // latest pending time. root.earliestPendingTime = root.latestPendingTime; @@ -6380,7 +6451,7 @@ function markCommittedPriorityLevels(root, earliestRemainingTime) { } var latestSuspendedTime = root.latestSuspendedTime; - if (earliestRemainingTime > latestSuspendedTime) { + if (earliestRemainingTime < latestSuspendedTime) { // The earliest remaining level is later than all the suspended work. That // means we've flushed all the suspended work. root.earliestSuspendedTime = NoWork; @@ -6394,7 +6465,7 @@ function markCommittedPriorityLevels(root, earliestRemainingTime) { return; } - if (earliestRemainingTime < earliestSuspendedTime) { + if (earliestRemainingTime > earliestSuspendedTime) { // The earliest remaining time is earlier than all the suspended work. // Treat it as a pending update. markPendingPriorityLevel(root, earliestRemainingTime); @@ -6413,10 +6484,10 @@ function hasLowerPriorityWork(root, erroredExpirationTime) { var latestPingedTime = root.latestPingedTime; return ( (latestPendingTime !== NoWork && - latestPendingTime > erroredExpirationTime) || + latestPendingTime < erroredExpirationTime) || (latestSuspendedTime !== NoWork && - latestSuspendedTime > erroredExpirationTime) || - (latestPingedTime !== NoWork && latestPingedTime > erroredExpirationTime) + latestSuspendedTime < erroredExpirationTime) || + (latestPingedTime !== NoWork && latestPingedTime < erroredExpirationTime) ); } @@ -6425,8 +6496,8 @@ function isPriorityLevelSuspended(root, expirationTime) { var latestSuspendedTime = root.latestSuspendedTime; return ( earliestSuspendedTime !== NoWork && - expirationTime >= earliestSuspendedTime && - expirationTime <= latestSuspendedTime + expirationTime <= earliestSuspendedTime && + expirationTime >= latestSuspendedTime ); } @@ -6459,10 +6530,10 @@ function markSuspendedPriorityLevel(root, suspendedTime) { // No other suspended levels. root.earliestSuspendedTime = root.latestSuspendedTime = suspendedTime; } else { - if (earliestSuspendedTime > suspendedTime) { + if (earliestSuspendedTime < suspendedTime) { // This is the earliest suspended level. root.earliestSuspendedTime = suspendedTime; - } else if (latestSuspendedTime < suspendedTime) { + } else if (latestSuspendedTime > suspendedTime) { // This is the latest suspended level root.latestSuspendedTime = suspendedTime; } @@ -6478,7 +6549,7 @@ function markPingedPriorityLevel(root, pingedTime) { // is thrown out and not reused during the restarted render. One way to // invalidate the progressed work is to restart at expirationTime + 1. var latestPingedTime = root.latestPingedTime; - if (latestPingedTime === NoWork || latestPingedTime < pingedTime) { + if (latestPingedTime === NoWork || latestPingedTime > pingedTime) { root.latestPingedTime = pingedTime; } findNextExpirationTimeToWorkOn(pingedTime, root); @@ -6488,7 +6559,7 @@ function clearPing(root, completedTime) { // TODO: Track whether the root was pinged during the render phase. If so, // we need to make sure we don't lose track of it. var latestPingedTime = root.latestPingedTime; - if (latestPingedTime !== NoWork && latestPingedTime <= completedTime) { + if (latestPingedTime !== NoWork && latestPingedTime >= completedTime) { root.latestPingedTime = NoWork; } } @@ -6498,18 +6569,10 @@ function findEarliestOutstandingPriorityLevel(root, renderExpirationTime) { var earliestPendingTime = root.earliestPendingTime; var earliestSuspendedTime = root.earliestSuspendedTime; - if ( - earliestExpirationTime === NoWork || - (earliestPendingTime !== NoWork && - earliestPendingTime < earliestExpirationTime) - ) { + if (earliestPendingTime > earliestExpirationTime) { earliestExpirationTime = earliestPendingTime; } - if ( - earliestExpirationTime === NoWork || - (earliestSuspendedTime !== NoWork && - earliestSuspendedTime < earliestExpirationTime) - ) { + if (earliestSuspendedTime > earliestExpirationTime) { earliestExpirationTime = earliestSuspendedTime; } return earliestExpirationTime; @@ -6517,7 +6580,7 @@ function findEarliestOutstandingPriorityLevel(root, renderExpirationTime) { function didExpireAtExpirationTime(root, currentTime) { var expirationTime = root.expirationTime; - if (expirationTime !== NoWork && currentTime >= expirationTime) { + if (expirationTime !== NoWork && currentTime <= expirationTime) { // The root has expired. Flush all work up to the current time. root.nextExpirationTimeToWorkOn = currentTime; } @@ -6539,7 +6602,7 @@ function findNextExpirationTimeToWorkOn(completedExpirationTime, root) { if ( nextExpirationTimeToWorkOn === NoWork && (completedExpirationTime === NoWork || - latestSuspendedTime > completedExpirationTime) + latestSuspendedTime < completedExpirationTime) ) { // The lowest priority suspended work is the work most likely to be // committed next. Let's start rendering it again, so that if it times out, @@ -6548,11 +6611,7 @@ function findNextExpirationTimeToWorkOn(completedExpirationTime, root) { } var expirationTime = nextExpirationTimeToWorkOn; - if ( - expirationTime !== NoWork && - earliestSuspendedTime !== NoWork && - earliestSuspendedTime < expirationTime - ) { + if (expirationTime !== NoWork && earliestSuspendedTime > expirationTime) { // Expire using the earliest known expiration time. expirationTime = earliestSuspendedTime; } @@ -6776,7 +6835,7 @@ function enqueueUpdate(fiber, update) { { if ( - (fiber.tag === ClassComponent || fiber.tag === ClassComponentLazy) && + fiber.tag === ClassComponent && (currentlyProcessingQueue === queue1 || (queue2 !== null && currentlyProcessingQueue === queue2)) && !didWarnUpdateInsideUpdate @@ -6924,7 +6983,7 @@ function processUpdateQueue( var resultState = newBaseState; while (update !== null) { var updateExpirationTime = update.expirationTime; - if (updateExpirationTime > renderExpirationTime) { + if (updateExpirationTime < renderExpirationTime) { // This update does not have sufficient priority. Skip it. if (newFirstUpdate === null) { // This is the first skipped update. It will be the first update in @@ -6936,10 +6995,7 @@ function processUpdateQueue( } // Since this update will remain in the list, update the remaining // expiration time. - if ( - newExpirationTime === NoWork || - newExpirationTime > updateExpirationTime - ) { + if (newExpirationTime < updateExpirationTime) { newExpirationTime = updateExpirationTime; } } else { @@ -6975,7 +7031,7 @@ function processUpdateQueue( update = queue.firstCapturedUpdate; while (update !== null) { var _updateExpirationTime = update.expirationTime; - if (_updateExpirationTime > renderExpirationTime) { + if (_updateExpirationTime < renderExpirationTime) { // This update does not have sufficient priority. Skip it. if (newFirstCapturedUpdate === null) { // This is the first skipped captured update. It will be the first @@ -6989,10 +7045,7 @@ function processUpdateQueue( } // Since this update will remain in the list, update the remaining // expiration time. - if ( - newExpirationTime === NoWork || - newExpirationTime > _updateExpirationTime - ) { + if (newExpirationTime < _updateExpirationTime) { newExpirationTime = _updateExpirationTime; } } else { @@ -7290,10 +7343,7 @@ function propagateContextChange( ) { // Match! Schedule an update on this fiber. - if ( - fiber.tag === ClassComponent || - fiber.tag === ClassComponentLazy - ) { + if (fiber.tag === ClassComponent) { // Schedule a force update on the work-in-progress. var update = createUpdate(renderExpirationTime); update.tag = ForceUpdate; @@ -7304,17 +7354,13 @@ function propagateContextChange( enqueueUpdate(fiber, update); } - if ( - fiber.expirationTime === NoWork || - fiber.expirationTime > renderExpirationTime - ) { + if (fiber.expirationTime < renderExpirationTime) { fiber.expirationTime = renderExpirationTime; } var alternate = fiber.alternate; if ( alternate !== null && - (alternate.expirationTime === NoWork || - alternate.expirationTime > renderExpirationTime) + alternate.expirationTime < renderExpirationTime ) { alternate.expirationTime = renderExpirationTime; } @@ -7323,22 +7369,17 @@ function propagateContextChange( var node = fiber.return; while (node !== null) { alternate = node.alternate; - if ( - node.childExpirationTime === NoWork || - node.childExpirationTime > renderExpirationTime - ) { + if (node.childExpirationTime < renderExpirationTime) { node.childExpirationTime = renderExpirationTime; if ( alternate !== null && - (alternate.childExpirationTime === NoWork || - alternate.childExpirationTime > renderExpirationTime) + alternate.childExpirationTime < renderExpirationTime ) { alternate.childExpirationTime = renderExpirationTime; } } else if ( alternate !== null && - (alternate.childExpirationTime === NoWork || - alternate.childExpirationTime > renderExpirationTime) + alternate.childExpirationTime < renderExpirationTime ) { alternate.childExpirationTime = renderExpirationTime; } else { @@ -7423,7 +7464,7 @@ function readContext(context, observedBits) { if (lastContextDependency === null) { invariant( currentlyRenderingFiber !== null, - "Context.unstable_read(): Context can only be read while React is " + + "Context can only be read while React is " + "rendering, e.g. inside the render method or getDerivedStateFromProps." ); // This is the first dependency in the list @@ -7436,6 +7477,637 @@ function readContext(context, observedBits) { return isPrimaryRenderer ? context._currentValue : context._currentValue2; } +var NoEffect$1 = /* */ 0; +var UnmountSnapshot = /* */ 2; +var UnmountMutation = /* */ 4; +var MountMutation = /* */ 8; +var UnmountLayout = /* */ 16; +var MountLayout = /* */ 32; +var MountPassive = /* */ 64; +var UnmountPassive = /* */ 128; + +// These are set right before calling the component. +var renderExpirationTime = NoWork; +// The work-in-progress fiber. I've named it differently to distinguish it from +// the work-in-progress hook. +var currentlyRenderingFiber$1 = null; + +// Hooks are stored as a linked list on the fiber's memoizedState field. The +// current hook list is the list that belongs to the current fiber. The +// work-in-progress hook list is a new list that will be added to the +// work-in-progress fiber. +var firstCurrentHook = null; +var currentHook = null; +var firstWorkInProgressHook = null; +var workInProgressHook = null; + +var remainingExpirationTime = NoWork; +var componentUpdateQueue = null; + +// Updates scheduled during render will trigger an immediate re-render at the +// end of the current pass. We can't store these updates on the normal queue, +// because if the work is aborted, they should be discarded. Because this is +// a relatively rare case, we also don't want to add an additional field to +// either the hook or queue object types. So we store them in a lazily create +// map of queue -> render-phase updates, which are discarded once the component +// completes without re-rendering. + +// Whether the work-in-progress hook is a re-rendered hook +var isReRender = false; +// Whether an update was scheduled during the currently executing render pass. +var didScheduleRenderPhaseUpdate = false; +// Lazily created map of render-phase updates +var renderPhaseUpdates = null; +// Counter to prevent infinite loops. +var numberOfReRenders = 0; +var RE_RENDER_LIMIT = 25; + +function resolveCurrentlyRenderingFiber() { + invariant( + currentlyRenderingFiber$1 !== null, + "Hooks can only be called inside the body of a function component." + ); + return currentlyRenderingFiber$1; +} + +function prepareToUseHooks(current, workInProgress, nextRenderExpirationTime) { + renderExpirationTime = nextRenderExpirationTime; + currentlyRenderingFiber$1 = workInProgress; + firstCurrentHook = current !== null ? current.memoizedState : null; + + // The following should have already been reset + // currentHook = null; + // workInProgressHook = null; + + // remainingExpirationTime = NoWork; + // componentUpdateQueue = null; + + // isReRender = false; + // didScheduleRenderPhaseUpdate = false; + // renderPhaseUpdates = null; + // numberOfReRenders = 0; +} + +function finishHooks(Component, props, children, refOrContext) { + // This must be called after every function component to prevent hooks from + // being used in classes. + + while (didScheduleRenderPhaseUpdate) { + // Updates were scheduled during the render phase. They are stored in + // the `renderPhaseUpdates` map. Call the component again, reusing the + // work-in-progress hooks and applying the additional updates on top. Keep + // restarting until no more updates are scheduled. + didScheduleRenderPhaseUpdate = false; + numberOfReRenders += 1; + + // Start over from the beginning of the list + currentHook = null; + workInProgressHook = null; + componentUpdateQueue = null; + + children = Component(props, refOrContext); + } + renderPhaseUpdates = null; + numberOfReRenders = 0; + + var renderedWork = currentlyRenderingFiber$1; + + renderedWork.memoizedState = firstWorkInProgressHook; + renderedWork.expirationTime = remainingExpirationTime; + renderedWork.updateQueue = componentUpdateQueue; + + var didRenderTooFewHooks = currentHook !== null && currentHook.next !== null; + + renderExpirationTime = NoWork; + currentlyRenderingFiber$1 = null; + + firstCurrentHook = null; + currentHook = null; + firstWorkInProgressHook = null; + workInProgressHook = null; + + remainingExpirationTime = NoWork; + componentUpdateQueue = null; + + // Always set during createWorkInProgress + // isReRender = false; + + // These were reset above + // didScheduleRenderPhaseUpdate = false; + // renderPhaseUpdates = null; + // numberOfReRenders = 0; + + invariant( + !didRenderTooFewHooks, + "Rendered fewer hooks than expected. This may be caused by an accidental " + + "early return statement." + ); + + return children; +} + +function resetHooks() { + // This is called instead of `finishHooks` if the component throws. It's also + // called inside mountIndeterminateComponent if we determine the component + // is a module-style component. + renderExpirationTime = NoWork; + currentlyRenderingFiber$1 = null; + + firstCurrentHook = null; + currentHook = null; + firstWorkInProgressHook = null; + workInProgressHook = null; + + remainingExpirationTime = NoWork; + componentUpdateQueue = null; + + // Always set during createWorkInProgress + // isReRender = false; + + didScheduleRenderPhaseUpdate = false; + renderPhaseUpdates = null; + numberOfReRenders = 0; +} + +function createHook() { + return { + memoizedState: null, + + baseState: null, + queue: null, + baseUpdate: null, + + next: null + }; +} + +function cloneHook(hook) { + return { + memoizedState: hook.memoizedState, + + baseState: hook.memoizedState, + queue: hook.queue, + baseUpdate: hook.baseUpdate, + + next: null + }; +} + +function createWorkInProgressHook() { + if (workInProgressHook === null) { + // This is the first hook in the list + if (firstWorkInProgressHook === null) { + isReRender = false; + currentHook = firstCurrentHook; + if (currentHook === null) { + // This is a newly mounted hook + workInProgressHook = createHook(); + } else { + // Clone the current hook. + workInProgressHook = cloneHook(currentHook); + } + firstWorkInProgressHook = workInProgressHook; + } else { + // There's already a work-in-progress. Reuse it. + isReRender = true; + currentHook = firstCurrentHook; + workInProgressHook = firstWorkInProgressHook; + } + } else { + if (workInProgressHook.next === null) { + isReRender = false; + var hook = void 0; + if (currentHook === null) { + // This is a newly mounted hook + hook = createHook(); + } else { + currentHook = currentHook.next; + if (currentHook === null) { + // This is a newly mounted hook + hook = createHook(); + } else { + // Clone the current hook. + hook = cloneHook(currentHook); + } + } + // Append to the end of the list + workInProgressHook = workInProgressHook.next = hook; + } else { + // There's already a work-in-progress. Reuse it. + isReRender = true; + workInProgressHook = workInProgressHook.next; + currentHook = currentHook !== null ? currentHook.next : null; + } + } + return workInProgressHook; +} + +function createFunctionComponentUpdateQueue() { + return { + lastEffect: null + }; +} + +function basicStateReducer(state, action) { + return typeof action === "function" ? action(state) : action; +} + +function useContext(context, observedBits) { + // Ensure we're in a function component (class components support only the + // .unstable_read() form) + resolveCurrentlyRenderingFiber(); + return readContext(context, observedBits); +} + +function useState(initialState) { + return useReducer( + basicStateReducer, + // useReducer has a special case to support lazy useState initializers + initialState + ); +} + +function useReducer(reducer, initialState, initialAction) { + currentlyRenderingFiber$1 = resolveCurrentlyRenderingFiber(); + workInProgressHook = createWorkInProgressHook(); + var queue = workInProgressHook.queue; + if (queue !== null) { + // Already have a queue, so this is an update. + if (isReRender) { + // This is a re-render. Apply the new render phase updates to the previous + var _dispatch2 = queue.dispatch; + if (renderPhaseUpdates !== null) { + // Render phase updates are stored in a map of queue -> linked list + var firstRenderPhaseUpdate = renderPhaseUpdates.get(queue); + if (firstRenderPhaseUpdate !== undefined) { + renderPhaseUpdates.delete(queue); + var newState = workInProgressHook.memoizedState; + var update = firstRenderPhaseUpdate; + do { + // Process this render phase update. We don't have to check the + // priority because it will always be the same as the current + // render's. + var _action = update.action; + newState = reducer(newState, _action); + update = update.next; + } while (update !== null); + + workInProgressHook.memoizedState = newState; + + // Don't persist the state accumlated from the render phase updates to + // the base state unless the queue is empty. + // TODO: Not sure if this is the desired semantics, but it's what we + // do for gDSFP. I can't remember why. + if (workInProgressHook.baseUpdate === queue.last) { + workInProgressHook.baseState = newState; + } + + return [newState, _dispatch2]; + } + } + return [workInProgressHook.memoizedState, _dispatch2]; + } + + // The last update in the entire queue + var _last = queue.last; + // The last update that is part of the base state. + var _baseUpdate = workInProgressHook.baseUpdate; + + // Find the first unprocessed update. + var first = void 0; + if (_baseUpdate !== null) { + if (_last !== null) { + // For the first update, the queue is a circular linked list where + // `queue.last.next = queue.first`. Once the first update commits, and + // the `baseUpdate` is no longer empty, we can unravel the list. + _last.next = null; + } + first = _baseUpdate.next; + } else { + first = _last !== null ? _last.next : null; + } + if (first !== null) { + var _newState = workInProgressHook.baseState; + var newBaseState = null; + var newBaseUpdate = null; + var prevUpdate = _baseUpdate; + var _update = first; + var didSkip = false; + do { + var updateExpirationTime = _update.expirationTime; + if (updateExpirationTime < renderExpirationTime) { + // Priority is insufficient. Skip this update. If this is the first + // skipped update, the previous update/state is the new base + // update/state. + if (!didSkip) { + didSkip = true; + newBaseUpdate = prevUpdate; + newBaseState = _newState; + } + // Update the remaining priority in the queue. + if (updateExpirationTime > remainingExpirationTime) { + remainingExpirationTime = updateExpirationTime; + } + } else { + // Process this update. + var _action2 = _update.action; + _newState = reducer(_newState, _action2); + } + prevUpdate = _update; + _update = _update.next; + } while (_update !== null && _update !== first); + + if (!didSkip) { + newBaseUpdate = prevUpdate; + newBaseState = _newState; + } + + workInProgressHook.memoizedState = _newState; + workInProgressHook.baseUpdate = newBaseUpdate; + workInProgressHook.baseState = newBaseState; + } + + var _dispatch = queue.dispatch; + return [workInProgressHook.memoizedState, _dispatch]; + } + + // There's no existing queue, so this is the initial render. + if (reducer === basicStateReducer) { + // Special case for `useState`. + if (typeof initialState === "function") { + initialState = initialState(); + } + } else if (initialAction !== undefined && initialAction !== null) { + initialState = reducer(initialState, initialAction); + } + workInProgressHook.memoizedState = workInProgressHook.baseState = initialState; + queue = workInProgressHook.queue = { + last: null, + dispatch: null + }; + var dispatch = (queue.dispatch = dispatchAction.bind( + null, + currentlyRenderingFiber$1, + queue + )); + return [workInProgressHook.memoizedState, dispatch]; +} + +function pushEffect(tag, create, destroy, inputs) { + var effect = { + tag: tag, + create: create, + destroy: destroy, + inputs: inputs, + // Circular + next: null + }; + if (componentUpdateQueue === null) { + componentUpdateQueue = createFunctionComponentUpdateQueue(); + componentUpdateQueue.lastEffect = effect.next = effect; + } else { + var _lastEffect = componentUpdateQueue.lastEffect; + if (_lastEffect === null) { + componentUpdateQueue.lastEffect = effect.next = effect; + } else { + var firstEffect = _lastEffect.next; + _lastEffect.next = effect; + effect.next = firstEffect; + componentUpdateQueue.lastEffect = effect; + } + } + return effect; +} + +function useRef(initialValue) { + currentlyRenderingFiber$1 = resolveCurrentlyRenderingFiber(); + workInProgressHook = createWorkInProgressHook(); + var ref = void 0; + + if (workInProgressHook.memoizedState === null) { + ref = { current: initialValue }; + { + Object.seal(ref); + } + workInProgressHook.memoizedState = ref; + } else { + ref = workInProgressHook.memoizedState; + } + return ref; +} + +function useMutationEffect(create, inputs) { + useEffectImpl( + Snapshot | Update, + UnmountSnapshot | MountMutation, + create, + inputs + ); +} + +function useLayoutEffect(create, inputs) { + useEffectImpl(Update, UnmountMutation | MountLayout, create, inputs); +} + +function useEffect(create, inputs) { + useEffectImpl( + Update | Passive, + UnmountPassive | MountPassive, + create, + inputs + ); +} + +function useEffectImpl(fiberEffectTag, hookEffectTag, create, inputs) { + currentlyRenderingFiber$1 = resolveCurrentlyRenderingFiber(); + workInProgressHook = createWorkInProgressHook(); + + var nextInputs = inputs !== undefined && inputs !== null ? inputs : [create]; + var destroy = null; + if (currentHook !== null) { + var prevEffect = currentHook.memoizedState; + destroy = prevEffect.destroy; + if (inputsAreEqual(nextInputs, prevEffect.inputs)) { + pushEffect(NoEffect$1, create, destroy, nextInputs); + return; + } + } + + currentlyRenderingFiber$1.effectTag |= fiberEffectTag; + workInProgressHook.memoizedState = pushEffect( + hookEffectTag, + create, + destroy, + nextInputs + ); +} + +function useImperativeMethods(ref, create, inputs) { + // TODO: If inputs are provided, should we skip comparing the ref itself? + var nextInputs = + inputs !== null && inputs !== undefined + ? inputs.concat([ref]) + : [ref, create]; + + // TODO: I've implemented this on top of useEffect because it's almost the + // same thing, and it would require an equal amount of code. It doesn't seem + // like a common enough use case to justify the additional size. + useEffectImpl( + Update, + UnmountMutation | MountLayout, + function() { + if (typeof ref === "function") { + var refCallback = ref; + var _inst = create(); + refCallback(_inst); + return function() { + return refCallback(null); + }; + } else if (ref !== null && ref !== undefined) { + var refObject = ref; + var _inst2 = create(); + refObject.current = _inst2; + return function() { + refObject.current = null; + }; + } + }, + nextInputs + ); +} + +function useCallback(callback, inputs) { + currentlyRenderingFiber$1 = resolveCurrentlyRenderingFiber(); + workInProgressHook = createWorkInProgressHook(); + + var nextInputs = + inputs !== undefined && inputs !== null ? inputs : [callback]; + + var prevState = workInProgressHook.memoizedState; + if (prevState !== null) { + var prevInputs = prevState[1]; + if (inputsAreEqual(nextInputs, prevInputs)) { + return prevState[0]; + } + } + workInProgressHook.memoizedState = [callback, nextInputs]; + return callback; +} + +function useMemo(nextCreate, inputs) { + currentlyRenderingFiber$1 = resolveCurrentlyRenderingFiber(); + workInProgressHook = createWorkInProgressHook(); + + var nextInputs = + inputs !== undefined && inputs !== null ? inputs : [nextCreate]; + + var prevState = workInProgressHook.memoizedState; + if (prevState !== null) { + var prevInputs = prevState[1]; + if (inputsAreEqual(nextInputs, prevInputs)) { + return prevState[0]; + } + } + + var nextValue = nextCreate(); + workInProgressHook.memoizedState = [nextValue, nextInputs]; + return nextValue; +} + +function dispatchAction(fiber, queue, action) { + invariant( + numberOfReRenders < RE_RENDER_LIMIT, + "Too many re-renders. React limits the number of renders to prevent " + + "an infinite loop." + ); + + var alternate = fiber.alternate; + if ( + fiber === currentlyRenderingFiber$1 || + (alternate !== null && alternate === currentlyRenderingFiber$1) + ) { + // This is a render phase update. Stash it in a lazily-created map of + // queue -> linked list of updates. After this render pass, we'll restart + // and apply the stashed updates on top of the work-in-progress hook. + didScheduleRenderPhaseUpdate = true; + var update = { + expirationTime: renderExpirationTime, + action: action, + next: null + }; + if (renderPhaseUpdates === null) { + renderPhaseUpdates = new Map(); + } + var firstRenderPhaseUpdate = renderPhaseUpdates.get(queue); + if (firstRenderPhaseUpdate === undefined) { + renderPhaseUpdates.set(queue, update); + } else { + // Append the update to the end of the list. + var lastRenderPhaseUpdate = firstRenderPhaseUpdate; + while (lastRenderPhaseUpdate.next !== null) { + lastRenderPhaseUpdate = lastRenderPhaseUpdate.next; + } + lastRenderPhaseUpdate.next = update; + } + } else { + var currentTime = requestCurrentTime(); + var _expirationTime = computeExpirationForFiber(currentTime, fiber); + var _update2 = { + expirationTime: _expirationTime, + action: action, + next: null + }; + flushPassiveEffects(); + // Append the update to the end of the list. + var _last2 = queue.last; + if (_last2 === null) { + // This is the first update. Create a circular list. + _update2.next = _update2; + } else { + var first = _last2.next; + if (first !== null) { + // Still circular. + _update2.next = first; + } + _last2.next = _update2; + } + queue.last = _update2; + scheduleWork(fiber, _expirationTime); + } +} + +function inputsAreEqual(arr1, arr2) { + // Don't bother comparing lengths in prod because these arrays should be + // passed inline. + { + !(arr1.length === arr2.length) + ? warning$1( + false, + "Detected a variable number of hook dependencies. The length of the " + + "dependencies array should be constant between renders.\n\n" + + "Previous: %s\n" + + "Incoming: %s", + arr1.join(", "), + arr2.join(", ") + ) + : void 0; + } + for (var i = 0; i < arr1.length; i++) { + // Inlined Object.is polyfill. + // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is + var val1 = arr1[i]; + var val2 = arr2[i]; + if ( + (val1 === val2 && (val1 !== 0 || 1 / val1 === 1 / val2)) || + (val1 !== val1 && val2 !== val2) // eslint-disable-line no-self-compare + ) { + continue; + } + return false; + } + return true; +} + var NO_CONTEXT = {}; var contextStackCursor$1 = createCursor(NO_CONTEXT); @@ -7622,6 +8294,13 @@ function shallowEqual(objA, objB) { return true; } +var ReactCurrentOwner$4 = ReactSharedInternals.ReactCurrentOwner; + +function readContext$1(contextType) { + var dispatcher = ReactCurrentOwner$4.currentDispatcher; + return dispatcher.readContext(contextType); +} + var fakeInternalInstance = {}; var isArray$1 = Array.isArray; @@ -7761,6 +8440,7 @@ var classComponentUpdater = { update.callback = callback; } + flushPassiveEffects(); enqueueUpdate(fiber, update); scheduleWork(fiber, expirationTime); }, @@ -7780,6 +8460,7 @@ var classComponentUpdater = { update.callback = callback; } + flushPassiveEffects(); enqueueUpdate(fiber, update); scheduleWork(fiber, expirationTime); }, @@ -7798,6 +8479,7 @@ var classComponentUpdater = { update.callback = callback; } + flushPassiveEffects(); enqueueUpdate(fiber, update); scheduleWork(fiber, expirationTime); } @@ -8114,7 +8796,7 @@ function constructClassInstance( if (typeof contextType === "object" && contextType !== null) { { if ( - typeof contextType.unstable_read !== "function" && + contextType.$$typeof !== REACT_CONTEXT_TYPE && !didWarnAboutInvalidateContextType.has(ctor) ) { didWarnAboutInvalidateContextType.add(ctor); @@ -8128,7 +8810,7 @@ function constructClassInstance( } } - context = contextType.unstable_read(); + context = readContext$1(contextType); } else { unmaskedContext = getUnmaskedContext(workInProgress, ctor, true); var contextTypes = ctor.contextTypes; @@ -8330,7 +9012,7 @@ function mountClassInstance( var contextType = ctor.contextType; if (typeof contextType === "object" && contextType !== null) { - instance.context = contextType.unstable_read(); + instance.context = readContext$1(contextType); } else { var unmaskedContext = getUnmaskedContext(workInProgress, ctor, true); instance.context = getMaskedContext(workInProgress, unmaskedContext); @@ -8438,7 +9120,7 @@ function resumeMountClassInstance( var contextType = ctor.contextType; var nextContext = void 0; if (typeof contextType === "object" && contextType !== null) { - nextContext = contextType.unstable_read(); + nextContext = readContext$1(contextType); } else { var nextLegacyUnmaskedContext = getUnmaskedContext( workInProgress, @@ -8584,7 +9266,7 @@ function updateClassInstance( var contextType = ctor.contextType; var nextContext = void 0; if (typeof contextType === "object" && contextType !== null) { - nextContext = contextType.unstable_read(); + nextContext = readContext$1(contextType); } else { var nextUnmaskedContext = getUnmaskedContext(workInProgress, ctor, true); nextContext = getMaskedContext(workInProgress, nextUnmaskedContext); @@ -8827,8 +9509,7 @@ function coerceRef(returnFiber, current$$1, element) { if (owner) { var ownerFiber = owner; invariant( - ownerFiber.tag === ClassComponent || - ownerFiber.tag === ClassComponentLazy, + ownerFiber.tag === ClassComponent, "Function components cannot have refs." ); inst = ownerFiber.stateNode; @@ -9048,7 +9729,7 @@ function ChildReconciler(shouldTrackSideEffects) { } function updateElement(returnFiber, current$$1, element, expirationTime) { - if (current$$1 !== null && current$$1.type === element.type) { + if (current$$1 !== null && current$$1.elementType === element.type) { // Move based on index var existing = useFiber(current$$1, element.props, expirationTime); existing.ref = coerceRef(returnFiber, current$$1, element); @@ -9786,7 +10467,7 @@ function ChildReconciler(shouldTrackSideEffects) { if ( child.tag === Fragment ? element.type === REACT_FRAGMENT_TYPE - : child.type === element.type + : child.elementType === element.type ) { deleteRemainingChildren(returnFiber, child.sibling); var existing = useFiber( @@ -9969,8 +10650,7 @@ function ChildReconciler(shouldTrackSideEffects) { // component, throw an error. If Fiber return types are disabled, // we already threw above. switch (returnFiber.tag) { - case ClassComponent: - case ClassComponentLazy: { + case ClassComponent: { { var instance = returnFiber.stateNode; if (instance.render._isMockFunction) { @@ -10353,45 +11033,54 @@ function resetHydrationState() { isHydrating = false; } -function readLazyComponentType(thenable) { - var status = thenable._reactStatus; +function readLazyComponentType(lazyComponent) { + var status = lazyComponent._status; + var result = lazyComponent._result; switch (status) { - case Resolved: - var Component = thenable._reactResult; + case Resolved: { + var Component = result; return Component; - case Rejected: - throw thenable._reactResult; - case Pending: + } + case Rejected: { + var error = result; + throw error; + } + case Pending: { + var thenable = result; 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; + lazyComponent._status = Pending; + var ctor = lazyComponent._ctor; + var _thenable = ctor(); + _thenable.then( + function(moduleObject) { + if (lazyComponent._status === Pending) { + var defaultExport = moduleObject.default; + { + if (defaultExport === undefined) { + warning$1( + false, + "lazy: Expected the result of a dynamic import() call. " + + "Instead received: %s\n\nYour code should look like: \n " + + "const MyComponent = lazy(() => import('./MyComponent'))", + moduleObject + ); + } } - thenable._reactResult = resolvedValue; + lazyComponent._status = Resolved; + lazyComponent._result = defaultExport; } }, function(error) { - if (thenable._reactStatus === Pending) { - thenable._reactStatus = Rejected; - thenable._reactResult = error; + if (lazyComponent._status === Pending) { + lazyComponent._status = Rejected; + lazyComponent._result = error; } } ); - throw thenable; + lazyComponent._result = _thenable; + throw _thenable; } } } @@ -10476,87 +11165,26 @@ function forceUnmountCurrentAndReconcile( } 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 - // we don't do the bailout and we have to reuse existing props instead. - } else if (workInProgress.memoizedProps === nextProps) { - var currentRef = current$$1 !== null ? current$$1.ref : null; - if (ref === currentRef) { - return bailoutOnAlreadyFinishedWork( - current$$1, - workInProgress, - renderExpirationTime - ); - } - } - - var nextChildren = void 0; - { - ReactCurrentOwner$3.current = workInProgress; - setCurrentPhase("render"); - nextChildren = render(nextProps, ref); - setCurrentPhase(null); - } - - reconcileChildren( - current$$1, - workInProgress, - nextChildren, - renderExpirationTime - ); - memoizeProps(workInProgress, nextProps); - return workInProgress.child; -} - -function updatePureComponent( current$$1, workInProgress, Component, nextProps, - updateExpirationTime, renderExpirationTime ) { var render = Component.render; var ref = workInProgress.ref; - if ( - current$$1 !== null && - (updateExpirationTime === NoWork || - updateExpirationTime > renderExpirationTime) - ) { - var prevProps = current$$1.memoizedProps; - // Default to shallow comparison - var compare = Component.compare; - compare = compare !== null ? compare : shallowEqual; - if ( - workInProgress.ref === current$$1.ref && - compare(prevProps, nextProps) - ) { - return bailoutOnAlreadyFinishedWork( - current$$1, - workInProgress, - renderExpirationTime - ); - } - } - // The rest is a fork of updateFunctionComponent var nextChildren = void 0; prepareToReadContext(workInProgress, renderExpirationTime); + prepareToUseHooks(current$$1, workInProgress, renderExpirationTime); { ReactCurrentOwner$3.current = workInProgress; setCurrentPhase("render"); nextChildren = render(nextProps, ref); setCurrentPhase(null); } + nextChildren = finishHooks(render, nextProps, nextChildren, ref); // React DevTools reads this flag. workInProgress.effectTag |= PerformedWork; @@ -10566,10 +11194,107 @@ function updatePureComponent( nextChildren, renderExpirationTime ); - memoizeProps(workInProgress, nextProps); return workInProgress.child; } +function updateMemoComponent( + current$$1, + workInProgress, + Component, + nextProps, + updateExpirationTime, + renderExpirationTime +) { + if (current$$1 === null) { + var type = Component.type; + if (isSimpleFunctionComponent(type) && Component.compare === null) { + // If this is a plain function component without default props, + // and with only the default shallow comparison, we upgrade it + // to a SimpleMemoComponent to allow fast path updates. + workInProgress.tag = SimpleMemoComponent; + workInProgress.type = type; + return updateSimpleMemoComponent( + current$$1, + workInProgress, + type, + nextProps, + updateExpirationTime, + renderExpirationTime + ); + } + var child = createFiberFromTypeAndProps( + Component.type, + null, + nextProps, + null, + workInProgress.mode, + renderExpirationTime + ); + child.ref = workInProgress.ref; + child.return = workInProgress; + workInProgress.child = child; + return child; + } + var currentChild = current$$1.child; // This is always exactly one child + if (updateExpirationTime < renderExpirationTime) { + // This will be the props with resolved defaultProps, + // unlike current.memoizedProps which will be the unresolved ones. + var prevProps = currentChild.memoizedProps; + // Default to shallow comparison + var compare = Component.compare; + compare = compare !== null ? compare : shallowEqual; + if ( + compare(prevProps, nextProps) && + current$$1.ref === workInProgress.ref + ) { + return bailoutOnAlreadyFinishedWork( + current$$1, + workInProgress, + renderExpirationTime + ); + } + } + var newChild = createWorkInProgress( + currentChild, + nextProps, + renderExpirationTime + ); + newChild.ref = workInProgress.ref; + newChild.return = workInProgress; + workInProgress.child = newChild; + return newChild; +} + +function updateSimpleMemoComponent( + current$$1, + workInProgress, + Component, + nextProps, + updateExpirationTime, + renderExpirationTime +) { + if (current$$1 !== null && updateExpirationTime < renderExpirationTime) { + var prevProps = current$$1.memoizedProps; + if ( + shallowEqual(prevProps, nextProps) && + current$$1.ref === workInProgress.ref + ) { + return bailoutOnAlreadyFinishedWork( + current$$1, + workInProgress, + renderExpirationTime + ); + } + } + return updateFunctionComponent( + current$$1, + workInProgress, + Component, + nextProps, + renderExpirationTime + ); +} + function updateFragment(current$$1, workInProgress, renderExpirationTime) { var nextChildren = workInProgress.pendingProps; reconcileChildren( @@ -10578,7 +11303,6 @@ function updateFragment(current$$1, workInProgress, renderExpirationTime) { nextChildren, renderExpirationTime ); - memoizeProps(workInProgress, nextChildren); return workInProgress.child; } @@ -10590,7 +11314,6 @@ function updateMode(current$$1, workInProgress, renderExpirationTime) { nextChildren, renderExpirationTime ); - memoizeProps(workInProgress, nextChildren); return workInProgress.child; } @@ -10606,7 +11329,6 @@ function updateProfiler(current$$1, workInProgress, renderExpirationTime) { nextChildren, renderExpirationTime ); - memoizeProps(workInProgress, nextProps); return workInProgress.child; } @@ -10633,12 +11355,14 @@ function updateFunctionComponent( var nextChildren = void 0; prepareToReadContext(workInProgress, renderExpirationTime); + prepareToUseHooks(current$$1, workInProgress, renderExpirationTime); { ReactCurrentOwner$3.current = workInProgress; setCurrentPhase("render"); nextChildren = Component(nextProps, context); setCurrentPhase(null); } + nextChildren = finishHooks(Component, nextProps, nextChildren, context); // React DevTools reads this flag. workInProgress.effectTag |= PerformedWork; @@ -10648,7 +11372,6 @@ function updateFunctionComponent( nextChildren, renderExpirationTime ); - memoizeProps(workInProgress, nextProps); return workInProgress.child; } @@ -10671,32 +11394,41 @@ function updateClassComponent( } prepareToReadContext(workInProgress, renderExpirationTime); + var instance = workInProgress.stateNode; var shouldUpdate = void 0; - if (current$$1 === null) { - if (workInProgress.stateNode === null) { - // In the initial pass we might need to construct the instance. - constructClassInstance( - workInProgress, - Component, - nextProps, - renderExpirationTime - ); - mountClassInstance( - workInProgress, - Component, - nextProps, - renderExpirationTime - ); - shouldUpdate = true; - } else { - // In a resume, we'll already have an instance we can reuse. - shouldUpdate = resumeMountClassInstance( - workInProgress, - Component, - nextProps, - renderExpirationTime - ); + if (instance === null) { + if (current$$1 !== null) { + // An class component without an instance only mounts if it suspended + // inside a non- concurrent tree, in an inconsistent state. We want to + // tree it like a new mount, even though an empty version of it already + // committed. Disconnect the alternate pointers. + current$$1.alternate = null; + workInProgress.alternate = null; + // Since this is conceptually a new fiber, schedule a Placement effect + workInProgress.effectTag |= Placement; } + // In the initial pass we might need to construct the instance. + constructClassInstance( + workInProgress, + Component, + nextProps, + renderExpirationTime + ); + mountClassInstance( + workInProgress, + Component, + nextProps, + renderExpirationTime + ); + shouldUpdate = true; + } else if (current$$1 === null) { + // In a resume, we'll already have an instance we can reuse. + shouldUpdate = resumeMountClassInstance( + workInProgress, + Component, + nextProps, + renderExpirationTime + ); } else { shouldUpdate = updateClassInstance( current$$1, @@ -10798,10 +11530,9 @@ function finishClassComponent( ); } - // Memoize props and state using the values we just used to render. + // Memoize state using the values we just used to render. // TODO: Restructure so we never read values from the instance. - memoizeState(workInProgress, instance.state); - memoizeProps(workInProgress, instance.props); + workInProgress.memoizedState = instance.state; // The context might have changed so we need to recalculate it. if (hasContext) { @@ -10935,7 +11666,6 @@ function updateHostComponent(current$$1, workInProgress, renderExpirationTime) { ) { // Schedule this fiber to re-render at offscreen priority. Then bailout. workInProgress.expirationTime = Never; - workInProgress.memoizedProps = nextProps; return null; } @@ -10945,7 +11675,6 @@ function updateHostComponent(current$$1, workInProgress, renderExpirationTime) { nextChildren, renderExpirationTime ); - memoizeProps(workInProgress, nextProps); return workInProgress.child; } @@ -10953,8 +11682,6 @@ function updateHostText(current$$1, workInProgress) { if (current$$1 === null) { tryToClaimNextHydratableInstance(workInProgress); } - var nextProps = workInProgress.pendingProps; - memoizeProps(workInProgress, nextProps); // Nothing to do here. This is terminal. We'll do the completion step // immediately after. return null; @@ -10975,98 +11702,173 @@ function resolveDefaultProps(Component, baseProps) { return baseProps; } -function mountIndeterminateComponent( - current$$1, +function mountLazyComponent( + _current, workInProgress, - Component, + elementType, updateExpirationTime, renderExpirationTime ) { - invariant( - current$$1 === null, - "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 ( - typeof Component === "object" && - Component !== null && - typeof Component.then === "function" - ) { - // We can't start a User Timing measurement with correct label yet. - // Cancel and resume right after we know the tag. - cancelWorkTimer(workInProgress); - Component = readLazyComponentType(Component); - var resolvedTag = (workInProgress.tag = resolveLazyComponentTag( - workInProgress, - Component - )); - startWorkTimer(workInProgress); - var resolvedProps = resolveDefaultProps(Component, props); - var child = void 0; - switch (resolvedTag) { - case FunctionComponentLazy: { - child = updateFunctionComponent( - current$$1, - workInProgress, - Component, - resolvedProps, - renderExpirationTime - ); - break; - } - case ClassComponentLazy: { - child = updateClassComponent( - current$$1, - workInProgress, - Component, - resolvedProps, - renderExpirationTime - ); - break; - } - case ForwardRefLazy: { - child = updateForwardRef( - current$$1, - workInProgress, - Component, - resolvedProps, - renderExpirationTime - ); - break; - } - case PureComponentLazy: { - child = updatePureComponent( - current$$1, - workInProgress, - Component, - resolvedProps, - updateExpirationTime, - renderExpirationTime - ); - break; - } - default: { - // This message intentionally doesn't metion ForwardRef or PureComponent - // 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 - ); - } - } - workInProgress.memoizedProps = props; - return child; + if (_current !== null) { + // An lazy component only mounts if it suspended inside a non- + // concurrent tree, in an inconsistent state. We want to tree it like + // a new mount, even though an empty version of it already committed. + // Disconnect the alternate pointers. + _current.alternate = null; + workInProgress.alternate = null; + // Since this is conceptually a new fiber, schedule a Placement effect + workInProgress.effectTag |= Placement; } + var props = workInProgress.pendingProps; + // We can't start a User Timing measurement with correct label yet. + // Cancel and resume right after we know the tag. + cancelWorkTimer(workInProgress); + var Component = readLazyComponentType(elementType); + // Store the unwrapped component in the type. + workInProgress.type = Component; + var resolvedTag = (workInProgress.tag = resolveLazyComponentTag(Component)); + startWorkTimer(workInProgress); + var resolvedProps = resolveDefaultProps(Component, props); + var child = void 0; + switch (resolvedTag) { + case FunctionComponent: { + child = updateFunctionComponent( + null, + workInProgress, + Component, + resolvedProps, + renderExpirationTime + ); + break; + } + case ClassComponent: { + child = updateClassComponent( + null, + workInProgress, + Component, + resolvedProps, + renderExpirationTime + ); + break; + } + case ForwardRef: { + child = updateForwardRef( + null, + workInProgress, + Component, + resolvedProps, + renderExpirationTime + ); + break; + } + case MemoComponent: { + child = updateMemoComponent( + null, + workInProgress, + Component, + resolveDefaultProps(Component.type, resolvedProps), // The inner type can have defaults too + updateExpirationTime, + renderExpirationTime + ); + break; + } + default: { + // This message intentionally doesn't metion ForwardRef or MemoComponent + // 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 + ); + } + } + return child; +} + +function mountIncompleteClassComponent( + _current, + workInProgress, + Component, + nextProps, + renderExpirationTime +) { + if (_current !== null) { + // An incomplete component only mounts if it suspended inside a non- + // concurrent tree, in an inconsistent state. We want to tree it like + // a new mount, even though an empty version of it already committed. + // Disconnect the alternate pointers. + _current.alternate = null; + workInProgress.alternate = null; + // Since this is conceptually a new fiber, schedule a Placement effect + workInProgress.effectTag |= Placement; + } + + // Promote the fiber to a class and try rendering again. + workInProgress.tag = ClassComponent; + + // The rest of this function is a fork of `updateClassComponent` + + // 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 = void 0; + if (isContextProvider(Component)) { + hasContext = true; + pushContextProvider(workInProgress); + } else { + hasContext = false; + } + prepareToReadContext(workInProgress, renderExpirationTime); + + constructClassInstance( + workInProgress, + Component, + nextProps, + renderExpirationTime + ); + mountClassInstance( + workInProgress, + Component, + nextProps, + renderExpirationTime + ); + + return finishClassComponent( + null, + workInProgress, + Component, + true, + hasContext, + renderExpirationTime + ); +} + +function mountIndeterminateComponent( + _current, + workInProgress, + Component, + renderExpirationTime +) { + if (_current !== null) { + // An indeterminate component only mounts if it suspended inside a non- + // concurrent tree, in an inconsistent state. We want to tree it like + // a new mount, even though an empty version of it already committed. + // Disconnect the alternate pointers. + _current.alternate = null; + workInProgress.alternate = null; + // Since this is conceptually a new fiber, schedule a Placement effect + workInProgress.effectTag |= Placement; + } + + var props = workInProgress.pendingProps; var unmaskedContext = getUnmaskedContext(workInProgress, Component, false); var context = getMaskedContext(workInProgress, unmaskedContext); prepareToReadContext(workInProgress, renderExpirationTime); + prepareToUseHooks(null, workInProgress, renderExpirationTime); var value = void 0; @@ -11108,6 +11910,9 @@ function mountIndeterminateComponent( // Proceed under the assumption that this is a class instance workInProgress.tag = ClassComponent; + // Throw out any hooks that were used. + resetHooks(); + // 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. @@ -11135,7 +11940,7 @@ function mountIndeterminateComponent( adoptClassInstance(workInProgress, value); mountClassInstance(workInProgress, Component, props, renderExpirationTime); return finishClassComponent( - current$$1, + null, workInProgress, Component, true, @@ -11145,6 +11950,7 @@ function mountIndeterminateComponent( } else { // Proceed under the assumption that this is a function component workInProgress.tag = FunctionComponent; + value = finishHooks(Component, props, value, context); { if (Component) { !!Component.childContextTypes @@ -11207,8 +12013,7 @@ function mountIndeterminateComponent( } } } - reconcileChildren(current$$1, workInProgress, value, renderExpirationTime); - memoizeProps(workInProgress, props); + reconcileChildren(null, workInProgress, value, renderExpirationTime); return workInProgress.child; } } @@ -11218,67 +12023,207 @@ function updateSuspenseComponent( workInProgress, renderExpirationTime ) { + var mode = workInProgress.mode; var nextProps = workInProgress.pendingProps; - // Check if we already attempted to render the normal state. If we did, - // and we timed out, render the placeholder state. - var alreadyCaptured = (workInProgress.effectTag & DidCapture) === NoEffect; - - var nextDidTimeout = void 0; - if (current$$1 !== null && workInProgress.updateQueue !== null) { - // We're outside strict mode. Something inside this Placeholder boundary - // suspended during the last commit. Switch to the placholder. - workInProgress.updateQueue = null; - nextDidTimeout = true; + // We should attempt to render the primary children unless this boundary + // already suspended during this render (`alreadyCaptured` is true). + var nextState = workInProgress.memoizedState; + if (nextState === null) { + // An empty suspense state means this boundary has not yet timed out. } else { - nextDidTimeout = !alreadyCaptured; - } - - if ((workInProgress.mode & StrictMode) !== NoEffect) { - if (nextDidTimeout) { - // If the timed-out view commits, schedule an update effect to record - // the committed time. - workInProgress.effectTag |= Update; + if (!nextState.alreadyCaptured) { + // Since we haven't already suspended during this commit, clear the + // existing suspense state. We'll try rendering again. + nextState = null; } else { - // The state node points to the time at which placeholder timed out. - // We can clear it once we switch back to the normal children. - workInProgress.stateNode = null; + // Something in this boundary's subtree already suspended. Switch to + // rendering the fallback children. Set `alreadyCaptured` to true. + if (current$$1 !== null && nextState === current$$1.memoizedState) { + // Create a new suspense state to avoid mutating the current tree's. + nextState = { + alreadyCaptured: true, + didTimeout: true, + timedOutAt: nextState.timedOutAt + }; + } else { + // Already have a clone, so it's safe to mutate. + nextState.alreadyCaptured = true; + nextState.didTimeout = true; + } + } + } + var nextDidTimeout = nextState !== null && nextState.didTimeout; + + // This next part is a bit confusing. If the children timeout, we switch to + // showing the fallback children in place of the "primary" children. + // However, we don't want to delete the primary children because then their + // state will be lost (both the React state and the host state, e.g. + // uncontrolled form inputs). Instead we keep them mounted and hide them. + // Both the fallback children AND the primary children are rendered at the + // same time. Once the primary children are un-suspended, we can delete + // the fallback children — don't need to preserve their state. + // + // The two sets of children are siblings in the host environment, but + // semantically, for purposes of reconciliation, they are two separate sets. + // So we store them using two fragment fibers. + // + // However, we want to avoid allocating extra fibers for every placeholder. + // They're only necessary when the children time out, because that's the + // only time when both sets are mounted. + // + // So, the extra fragment fibers are only used if the children time out. + // Otherwise, we render the primary children directly. This requires some + // custom reconciliation logic to preserve the state of the primary + // children. It's essentially a very basic form of re-parenting. + + // `child` points to the child fiber. In the normal case, this is the first + // fiber of the primary children set. In the timed-out case, it's a + // a fragment fiber containing the primary children. + var child = void 0; + // `next` points to the next fiber React should render. In the normal case, + // it's the same as `child`: the first fiber of the primary children set. + // In the timed-out case, it's a fragment fiber containing the *fallback* + // children -- we skip over the primary children entirely. + var next = void 0; + if (current$$1 === null) { + // This is the initial mount. This branch is pretty simple because there's + // no previous state that needs to be preserved. + if (nextDidTimeout) { + // Mount separate fragments for primary and fallback children. + var nextFallbackChildren = nextProps.fallback; + var primaryChildFragment = createFiberFromFragment( + null, + mode, + NoWork, + null + ); + var fallbackChildFragment = createFiberFromFragment( + nextFallbackChildren, + mode, + renderExpirationTime, + null + ); + primaryChildFragment.sibling = fallbackChildFragment; + child = primaryChildFragment; + // Skip the primary children, and continue working on the + // fallback children. + next = fallbackChildFragment; + child.return = next.return = workInProgress; + } else { + // Mount the primary children without an intermediate fragment fiber. + var nextPrimaryChildren = nextProps.children; + child = next = mountChildFibers( + workInProgress, + null, + nextPrimaryChildren, + renderExpirationTime + ); + } + } else { + // This is an update. This branch is more complicated because we need to + // ensure the state of the primary children is preserved. + var prevState = current$$1.memoizedState; + var prevDidTimeout = prevState !== null && prevState.didTimeout; + if (prevDidTimeout) { + // The current tree already timed out. That means each child set is + var currentPrimaryChildFragment = current$$1.child; + var currentFallbackChildFragment = currentPrimaryChildFragment.sibling; + if (nextDidTimeout) { + // Still timed out. Reuse the current primary children by cloning + // its fragment. We're going to skip over these entirely. + var _nextFallbackChildren = nextProps.fallback; + var _primaryChildFragment = createWorkInProgress( + currentPrimaryChildFragment, + currentPrimaryChildFragment.pendingProps, + NoWork + ); + _primaryChildFragment.effectTag |= Placement; + // Clone the fallback child fragment, too. These we'll continue + // working on. + var _fallbackChildFragment = (_primaryChildFragment.sibling = createWorkInProgress( + currentFallbackChildFragment, + _nextFallbackChildren, + currentFallbackChildFragment.expirationTime + )); + _fallbackChildFragment.effectTag |= Placement; + child = _primaryChildFragment; + _primaryChildFragment.childExpirationTime = NoWork; + // Skip the primary children, and continue working on the + // fallback children. + next = _fallbackChildFragment; + child.return = next.return = workInProgress; + } else { + // No longer suspended. Switch back to showing the primary children, + // and remove the intermediate fragment fiber. + var _nextPrimaryChildren = nextProps.children; + var currentPrimaryChild = currentPrimaryChildFragment.child; + var currentFallbackChild = currentFallbackChildFragment.child; + var primaryChild = reconcileChildFibers( + workInProgress, + currentPrimaryChild, + _nextPrimaryChildren, + renderExpirationTime + ); + // Delete the fallback children. + reconcileChildFibers( + workInProgress, + currentFallbackChild, + null, + renderExpirationTime + ); + // Continue rendering the children, like we normally do. + child = next = primaryChild; + } + } else { + // The current tree has not already timed out. That means the primary + var _currentPrimaryChild = current$$1.child; + if (nextDidTimeout) { + // Timed out. Wrap the children in a fragment fiber to keep them + // separate from the fallback children. + var _nextFallbackChildren2 = nextProps.fallback; + var _primaryChildFragment2 = createFiberFromFragment( + // It shouldn't matter what the pending props are because we aren't + // going to render this fragment. + null, + mode, + NoWork, + null + ); + _primaryChildFragment2.effectTag |= Placement; + _primaryChildFragment2.child = _currentPrimaryChild; + _currentPrimaryChild.return = _primaryChildFragment2; + // Create a fragment from the fallback children, too. + var _fallbackChildFragment2 = (_primaryChildFragment2.sibling = createFiberFromFragment( + _nextFallbackChildren2, + mode, + renderExpirationTime, + null + )); + _fallbackChildFragment2.effectTag |= Placement; + child = _primaryChildFragment2; + _primaryChildFragment2.childExpirationTime = NoWork; + // Skip the primary children, and continue working on the + // fallback children. + next = _fallbackChildFragment2; + child.return = next.return = workInProgress; + } else { + // Still haven't timed out. Continue rendering the children, like we + // normally do. + var _nextPrimaryChildren2 = nextProps.children; + next = child = reconcileChildFibers( + workInProgress, + _currentPrimaryChild, + _nextPrimaryChildren2, + renderExpirationTime + ); + } } } - // If the `children` prop is a function, treat it like a render prop. - // TODO: This is temporary until we finalize a lower level API. - var children = nextProps.children; - var nextChildren = void 0; - if (typeof children === "function") { - nextChildren = children(nextDidTimeout); - } else { - nextChildren = nextDidTimeout ? nextProps.fallback : children; - } - - if (current$$1 !== null && nextDidTimeout !== workInProgress.memoizedState) { - // We're about to switch from the placeholder children to the normal - // children, or vice versa. These are two different conceptual sets that - // happen to be stored in the same set. Call this special function to - // force the new set not to match with the current set. - // TODO: The proper way to model this is by storing each set separately. - forceUnmountCurrentAndReconcile( - current$$1, - workInProgress, - nextChildren, - renderExpirationTime - ); - } else { - reconcileChildren( - current$$1, - workInProgress, - nextChildren, - renderExpirationTime - ); - } - workInProgress.memoizedProps = nextProps; - workInProgress.memoizedState = nextDidTimeout; - return workInProgress.child; + workInProgress.memoizedState = nextState; + workInProgress.child = child; + return next; } function updatePortalComponent( @@ -11300,7 +12245,6 @@ function updatePortalComponent( nextChildren, renderExpirationTime ); - memoizeProps(workInProgress, nextChildren); } else { reconcileChildren( current$$1, @@ -11308,7 +12252,6 @@ function updatePortalComponent( nextChildren, renderExpirationTime ); - memoizeProps(workInProgress, nextChildren); } return workInProgress.child; } @@ -11325,7 +12268,6 @@ function updateContextProvider( var oldProps = workInProgress.memoizedProps; var newValue = newProps.value; - workInProgress.memoizedProps = newProps; { var providerPropTypes = workInProgress.type.propTypes; @@ -11394,13 +12336,18 @@ function updateContextConsumer( // in DEV mode if this property exists or not and warn if it does not. { if (context._context === undefined) { - if (!hasWarnedAboutUsingContextAsConsumer) { - hasWarnedAboutUsingContextAsConsumer = true; - warning$1( - false, - "Rendering directly is not supported and will be removed in " + - "a future major release. Did you mean to render instead?" - ); + // This may be because it's a Context (rather than a Consumer). + // Or it may be because it's older React where they're the same thing. + // We only want to warn if we're sure it's a new React. + if (context !== context.Consumer) { + if (!hasWarnedAboutUsingContextAsConsumer) { + hasWarnedAboutUsingContextAsConsumer = true; + warning$1( + false, + "Rendering directly is not supported and will be removed in " + + "a future major release. Did you mean to render instead?" + ); + } } } else { context = context._context; @@ -11439,7 +12386,6 @@ function updateContextConsumer( newChildren, renderExpirationTime ); - workInProgress.memoizedProps = newProps; return workInProgress.child; } @@ -11481,10 +12427,7 @@ function bailoutOnAlreadyFinishedWork( // Check if the children have any pending work. var childExpirationTime = workInProgress.childExpirationTime; - if ( - childExpirationTime === NoWork || - childExpirationTime > renderExpirationTime - ) { + if (childExpirationTime < renderExpirationTime) { // The children don't have any work either. We can skip them. // TODO: Once we add back resuming, we should check if the children are // a work-in-progress set. If so, we need to transfer their effects. @@ -11497,17 +12440,6 @@ function bailoutOnAlreadyFinishedWork( } } -// TODO: Delete memoizeProps/State and move to reconcile/bailout instead -function memoizeProps(workInProgress, nextProps) { - workInProgress.memoizedProps = nextProps; -} - -function memoizeState(workInProgress, nextState) { - workInProgress.memoizedState = nextState; - // Don't reset the updateQueue, in case there are pending updates. Resetting - // is handled by processUpdateQueue. -} - function beginWork(current$$1, workInProgress, renderExpirationTime) { var updateExpirationTime = workInProgress.expirationTime; @@ -11517,8 +12449,7 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { if ( oldProps === newProps && !hasContextChanged() && - (updateExpirationTime === NoWork || - updateExpirationTime > renderExpirationTime) + updateExpirationTime < renderExpirationTime ) { // This fiber does not have any pending work. Bailout without entering // the begin phase. There's still some bookkeeping we that needs to be done @@ -11538,14 +12469,6 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { } break; } - case ClassComponentLazy: { - var thenable = workInProgress.type; - var _Component = getResultFromResolvedThenable(thenable); - if (isContextProvider(_Component)) { - pushContextProvider(workInProgress); - } - break; - } case HostPortal: pushHostContainer( workInProgress, @@ -11562,6 +12485,46 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { workInProgress.effectTag |= Update; } break; + case SuspenseComponent: { + var state = workInProgress.memoizedState; + var didTimeout = state !== null && state.didTimeout; + if (didTimeout) { + // If this boundary is currently timed out, we need to decide + // whether to retry the primary children, or to skip over it and + // go straight to the fallback. Check the priority of the primary + var primaryChildFragment = workInProgress.child; + var primaryChildExpirationTime = + primaryChildFragment.childExpirationTime; + if ( + primaryChildExpirationTime !== NoWork && + primaryChildExpirationTime >= renderExpirationTime + ) { + // The primary children have pending work. Use the normal path + // to attempt to render the primary children again. + return updateSuspenseComponent( + current$$1, + workInProgress, + renderExpirationTime + ); + } else { + // The primary children do not have pending work with sufficient + // priority. Bailout. + var child = bailoutOnAlreadyFinishedWork( + current$$1, + workInProgress, + renderExpirationTime + ); + if (child !== null) { + // The fallback children have pending work. Skip over the + // primary children and work on the fallback. + return child.sibling; + } else { + return null; + } + } + } + break; + } } return bailoutOnAlreadyFinishedWork( current$$1, @@ -11576,65 +12539,54 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { switch (workInProgress.tag) { case IndeterminateComponent: { - var _Component2 = workInProgress.type; + var elementType = workInProgress.elementType; return mountIndeterminateComponent( current$$1, workInProgress, - _Component2, + elementType, + renderExpirationTime + ); + } + case LazyComponent: { + var _elementType = workInProgress.elementType; + return mountLazyComponent( + current$$1, + workInProgress, + _elementType, updateExpirationTime, renderExpirationTime ); } case FunctionComponent: { - var _Component3 = workInProgress.type; + var _Component = workInProgress.type; var unresolvedProps = workInProgress.pendingProps; + var resolvedProps = + workInProgress.elementType === _Component + ? unresolvedProps + : resolveDefaultProps(_Component, unresolvedProps); return updateFunctionComponent( current$$1, workInProgress, - _Component3, - unresolvedProps, + _Component, + resolvedProps, renderExpirationTime ); } - case FunctionComponentLazy: { - var _thenable = workInProgress.type; - var _Component4 = getResultFromResolvedThenable(_thenable); - var _unresolvedProps = workInProgress.pendingProps; - var child = updateFunctionComponent( - current$$1, - workInProgress, - _Component4, - resolveDefaultProps(_Component4, _unresolvedProps), - renderExpirationTime - ); - workInProgress.memoizedProps = _unresolvedProps; - return child; - } case ClassComponent: { - var _Component5 = workInProgress.type; - var _unresolvedProps2 = workInProgress.pendingProps; + var _Component2 = workInProgress.type; + var _unresolvedProps = workInProgress.pendingProps; + var _resolvedProps = + workInProgress.elementType === _Component2 + ? _unresolvedProps + : resolveDefaultProps(_Component2, _unresolvedProps); return updateClassComponent( current$$1, workInProgress, - _Component5, - _unresolvedProps2, + _Component2, + _resolvedProps, renderExpirationTime ); } - case ClassComponentLazy: { - var _thenable2 = workInProgress.type; - var _Component6 = getResultFromResolvedThenable(_thenable2); - var _unresolvedProps3 = workInProgress.pendingProps; - var _child = updateClassComponent( - current$$1, - workInProgress, - _Component6, - resolveDefaultProps(_Component6, _unresolvedProps3), - renderExpirationTime - ); - workInProgress.memoizedProps = _unresolvedProps3; - return _child; - } case HostRoot: return updateHostRoot(current$$1, workInProgress, renderExpirationTime); case HostComponent: @@ -11659,28 +12611,19 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { ); case ForwardRef: { var type = workInProgress.type; + var _unresolvedProps2 = workInProgress.pendingProps; + var _resolvedProps2 = + workInProgress.elementType === type + ? _unresolvedProps2 + : resolveDefaultProps(type, _unresolvedProps2); return updateForwardRef( current$$1, workInProgress, type, - workInProgress.pendingProps, + _resolvedProps2, renderExpirationTime ); } - case ForwardRefLazy: { - var _thenable3 = workInProgress.type; - var _Component7 = getResultFromResolvedThenable(_thenable3); - var _unresolvedProps4 = workInProgress.pendingProps; - var _child2 = updateForwardRef( - current$$1, - workInProgress, - _Component7, - resolveDefaultProps(_Component7, _unresolvedProps4), - renderExpirationTime - ); - workInProgress.memoizedProps = _unresolvedProps4; - return _child2; - } case Fragment: return updateFragment(current$$1, workInProgress, renderExpirationTime); case Mode: @@ -11699,31 +12642,43 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { workInProgress, renderExpirationTime ); - case PureComponent: { + case MemoComponent: { var _type = workInProgress.type; - return updatePureComponent( + var _unresolvedProps3 = workInProgress.pendingProps; + var _resolvedProps3 = resolveDefaultProps(_type.type, _unresolvedProps3); + return updateMemoComponent( current$$1, workInProgress, _type, + _resolvedProps3, + updateExpirationTime, + renderExpirationTime + ); + } + case SimpleMemoComponent: { + return updateSimpleMemoComponent( + current$$1, + workInProgress, + workInProgress.type, workInProgress.pendingProps, updateExpirationTime, renderExpirationTime ); } - case PureComponentLazy: { - var _thenable4 = workInProgress.type; - var _Component8 = getResultFromResolvedThenable(_thenable4); - var _unresolvedProps5 = workInProgress.pendingProps; - var _child3 = updatePureComponent( + case IncompleteClassComponent: { + var _Component3 = workInProgress.type; + var _unresolvedProps4 = workInProgress.pendingProps; + var _resolvedProps4 = + workInProgress.elementType === _Component3 + ? _unresolvedProps4 + : resolveDefaultProps(_Component3, _unresolvedProps4); + return mountIncompleteClassComponent( current$$1, workInProgress, - _Component8, - resolveDefaultProps(_Component8, _unresolvedProps5), - updateExpirationTime, + _Component3, + _resolvedProps4, renderExpirationTime ); - workInProgress.memoizedProps = _unresolvedProps5; - return _child3; } default: invariant( @@ -11744,42 +12699,48 @@ function markRef$1(workInProgress) { workInProgress.effectTag |= Ref; } -function appendAllChildren(parent, workInProgress) { - // We only have the top Fiber that was created but we need recurse down its - // children to find all the terminal nodes. - var node = workInProgress.child; - while (node !== null) { - if (node.tag === HostComponent || node.tag === HostText) { - appendInitialChild(parent, node.stateNode); - } else if (node.tag === HostPortal) { - // If we have a portal child, then we don't want to traverse - // down its children. Instead, we'll get insertions from each child in - // the portal directly. - } else if (node.child !== null) { - node.child.return = node; - node = node.child; - continue; - } - if (node === workInProgress) { - return; - } - while (node.sibling === null) { - if (node.return === null || node.return === workInProgress) { - return; - } - node = node.return; - } - node.sibling.return = node.return; - node = node.sibling; - } -} - +var appendAllChildren = void 0; var updateHostContainer = void 0; var updateHostComponent$1 = void 0; var updateHostText$1 = void 0; if (supportsMutation) { // Mutation mode + appendAllChildren = function( + parent, + workInProgress, + needsVisibilityToggle, + isHidden + ) { + // We only have the top Fiber that was created but we need recurse down its + // children to find all the terminal nodes. + var node = workInProgress.child; + while (node !== null) { + if (node.tag === HostComponent || node.tag === HostText) { + appendInitialChild(parent, node.stateNode); + } else if (node.tag === HostPortal) { + // If we have a portal child, then we don't want to traverse + // down its children. Instead, we'll get insertions from each child in + // the portal directly. + } else if (node.child !== null) { + node.child.return = node; + node = node.child; + continue; + } + if (node === workInProgress) { + return; + } + while (node.sibling === null) { + if (node.return === null || node.return === workInProgress) { + return; + } + node = node.return; + } + node.sibling.return = node.return; + node = node.sibling; + } + }; + updateHostContainer = function(workInProgress) { // Noop }; @@ -11833,26 +12794,202 @@ if (supportsMutation) { } else if (supportsPersistence) { // Persistent host tree mode - // An unfortunate fork of appendAllChildren because we have two different parent types. - var appendAllChildrenToContainer = function( - containerChildSet, - workInProgress + appendAllChildren = function( + parent, + workInProgress, + needsVisibilityToggle, + isHidden ) { // We only have the top Fiber that was created but we need recurse down its // children to find all the terminal nodes. var node = workInProgress.child; while (node !== null) { - if (node.tag === HostComponent || node.tag === HostText) { - appendChildToContainerChildSet(containerChildSet, node.stateNode); + // eslint-disable-next-line no-labels + branches: if (node.tag === HostComponent) { + var instance = node.stateNode; + if (needsVisibilityToggle) { + var props = node.memoizedProps; + var type = node.type; + if (isHidden) { + // This child is inside a timed out tree. Hide it. + instance = cloneHiddenInstance(instance, type, props, node); + } else { + // This child was previously inside a timed out tree. If it was not + // updated during this render, it may need to be unhidden. Clone + // again to be sure. + instance = cloneUnhiddenInstance(instance, type, props, node); + } + node.stateNode = instance; + } + appendInitialChild(parent, instance); + } else if (node.tag === HostText) { + var _instance = node.stateNode; + if (needsVisibilityToggle) { + var text = node.memoizedProps; + var rootContainerInstance = getRootHostContainer(); + var currentHostContext = getHostContext(); + if (isHidden) { + _instance = createHiddenTextInstance( + text, + rootContainerInstance, + currentHostContext, + workInProgress + ); + } else { + _instance = createTextInstance( + text, + rootContainerInstance, + currentHostContext, + workInProgress + ); + } + node.stateNode = _instance; + } + appendInitialChild(parent, _instance); } else if (node.tag === HostPortal) { // If we have a portal child, then we don't want to traverse // down its children. Instead, we'll get insertions from each child in // the portal directly. + } else if (node.tag === SuspenseComponent) { + var current = node.alternate; + if (current !== null) { + var oldState = current.memoizedState; + var newState = node.memoizedState; + var oldIsHidden = oldState !== null && oldState.didTimeout; + var newIsHidden = newState !== null && newState.didTimeout; + if (oldIsHidden !== newIsHidden) { + // The placeholder either just timed out or switched back to the normal + // children after having previously timed out. Toggle the visibility of + // the direct host children. + var primaryChildParent = newIsHidden ? node.child : node; + if (primaryChildParent !== null) { + appendAllChildren(parent, primaryChildParent, true, newIsHidden); + } + // eslint-disable-next-line no-labels + break branches; + } + } + if (node.child !== null) { + // Continue traversing like normal + node.child.return = node; + node = node.child; + continue; + } } else if (node.child !== null) { node.child.return = node; node = node.child; continue; } + // $FlowFixMe This is correct but Flow is confused by the labeled break. + node = node; + if (node === workInProgress) { + return; + } + while (node.sibling === null) { + if (node.return === null || node.return === workInProgress) { + return; + } + node = node.return; + } + node.sibling.return = node.return; + node = node.sibling; + } + }; + + // An unfortunate fork of appendAllChildren because we have two different parent types. + var appendAllChildrenToContainer = function( + containerChildSet, + workInProgress, + needsVisibilityToggle, + isHidden + ) { + // We only have the top Fiber that was created but we need recurse down its + // children to find all the terminal nodes. + var node = workInProgress.child; + while (node !== null) { + // eslint-disable-next-line no-labels + branches: if (node.tag === HostComponent) { + var instance = node.stateNode; + if (needsVisibilityToggle) { + var props = node.memoizedProps; + var type = node.type; + if (isHidden) { + // This child is inside a timed out tree. Hide it. + instance = cloneHiddenInstance(instance, type, props, node); + } else { + // This child was previously inside a timed out tree. If it was not + // updated during this render, it may need to be unhidden. Clone + // again to be sure. + instance = cloneUnhiddenInstance(instance, type, props, node); + } + node.stateNode = instance; + } + appendChildToContainerChildSet(containerChildSet, instance); + } else if (node.tag === HostText) { + var _instance2 = node.stateNode; + if (needsVisibilityToggle) { + var text = node.memoizedProps; + var rootContainerInstance = getRootHostContainer(); + var currentHostContext = getHostContext(); + if (isHidden) { + _instance2 = createHiddenTextInstance( + text, + rootContainerInstance, + currentHostContext, + workInProgress + ); + } else { + _instance2 = createTextInstance( + text, + rootContainerInstance, + currentHostContext, + workInProgress + ); + } + node.stateNode = _instance2; + } + appendChildToContainerChildSet(containerChildSet, _instance2); + } else if (node.tag === HostPortal) { + // If we have a portal child, then we don't want to traverse + // down its children. Instead, we'll get insertions from each child in + // the portal directly. + } else if (node.tag === SuspenseComponent) { + var current = node.alternate; + if (current !== null) { + var oldState = current.memoizedState; + var newState = node.memoizedState; + var oldIsHidden = oldState !== null && oldState.didTimeout; + var newIsHidden = newState !== null && newState.didTimeout; + if (oldIsHidden !== newIsHidden) { + // The placeholder either just timed out or switched back to the normal + // children after having previously timed out. Toggle the visibility of + // the direct host children. + var primaryChildParent = newIsHidden ? node.child : node; + if (primaryChildParent !== null) { + appendAllChildrenToContainer( + containerChildSet, + primaryChildParent, + true, + newIsHidden + ); + } + // eslint-disable-next-line no-labels + break branches; + } + } + if (node.child !== null) { + // Continue traversing like normal + node.child.return = node; + node = node.child; + continue; + } + } else if (node.child !== null) { + node.child.return = node; + node = node.child; + continue; + } + // $FlowFixMe This is correct but Flow is confused by the labeled break. + node = node; if (node === workInProgress) { return; } @@ -11875,7 +13012,7 @@ if (supportsMutation) { var container = portalOrRoot.containerInfo; var newChildSet = createContainerChildSet(container); // If children might have changed, we have to add them all to the set. - appendAllChildrenToContainer(newChildSet, workInProgress); + appendAllChildrenToContainer(newChildSet, workInProgress, false, false); portalOrRoot.pendingChildren = newChildSet; // Schedule an update on the container to swap out the container. markUpdate(workInProgress); @@ -11948,7 +13085,7 @@ if (supportsMutation) { markUpdate(workInProgress); } else { // If children might have changed, we have to add them all to the set. - appendAllChildren(newInstance, workInProgress); + appendAllChildren(newInstance, workInProgress, false, false); } }; updateHostText$1 = function(current, workInProgress, oldText, newText) { @@ -11990,8 +13127,12 @@ function completeWork(current, workInProgress, renderExpirationTime) { var newProps = workInProgress.pendingProps; switch (workInProgress.tag) { + case IndeterminateComponent: + break; + case LazyComponent: + break; + case SimpleMemoComponent: case FunctionComponent: - case FunctionComponentLazy: break; case ClassComponent: { var Component = workInProgress.type; @@ -12000,13 +13141,6 @@ function completeWork(current, workInProgress, renderExpirationTime) { } break; } - case ClassComponentLazy: { - var _Component = getResultFromResolvedThenable(workInProgress.type); - if (isContextProvider(_Component)) { - popContext(workInProgress); - } - break; - } case HostRoot: { popHostContainer(workInProgress); popTopLevelContextObject(workInProgress); @@ -12082,7 +13216,7 @@ function completeWork(current, workInProgress, renderExpirationTime) { workInProgress ); - appendAllChildren(instance, workInProgress); + appendAllChildren(instance, workInProgress, false, false); // Certain renderers require commit-time effects for initial mount. // (eg DOM renderer supports auto-focus for certain elements). @@ -12143,10 +13277,19 @@ function completeWork(current, workInProgress, renderExpirationTime) { break; } case ForwardRef: - case ForwardRefLazy: break; - case SuspenseComponent: + case SuspenseComponent: { + var nextState = workInProgress.memoizedState; + var prevState = current !== null ? current.memoizedState : null; + var nextDidTimeout = nextState !== null && nextState.didTimeout; + var prevDidTimeout = prevState !== null && prevState.didTimeout; + if (nextDidTimeout !== prevDidTimeout) { + // If this render commits, and it switches between the normal state + // and the timed-out state, schedule an effect. + workInProgress.effectTag |= Update; + } break; + } case Fragment: break; case Mode: @@ -12163,18 +13306,17 @@ function completeWork(current, workInProgress, renderExpirationTime) { break; case ContextConsumer: break; - case PureComponent: - case PureComponentLazy: + case MemoComponent: break; - // Error cases - case IndeterminateComponent: - invariant( - false, - "An indeterminate component should have become determinate before " + - "completing. This error is likely caused by a bug in React. Please " + - "file an issue." - ); - // eslint-disable-next-line no-fallthrough + case IncompleteClassComponent: { + // Same as class component case. I put it down here so that the tags are + // sequential to ensure this switch is compiled to a jump table. + var _Component = workInProgress.type; + if (isContextProvider(_Component)) { + popContext(workInProgress); + } + break; + } default: invariant( false, @@ -12186,6 +13328,17 @@ function completeWork(current, workInProgress, renderExpirationTime) { return null; } +function shouldCaptureSuspense(current, workInProgress) { + // In order to capture, the Suspense component must have a fallback prop. + if (workInProgress.memoizedProps.fallback === undefined) { + return false; + } + // If it was the primary children that just suspended, capture and render the + // fallback. Otherwise, don't capture and bubble to the next boundary. + var nextState = workInProgress.memoizedState; + return nextState === null || !nextState.didTimeout; +} + // Module provided by RN: /** * Intercept lifecycle errors and ensure they are shown with the correct stack @@ -12302,8 +13455,6 @@ function logCapturedError(capturedError) { } } -var emptyObject$1 = {}; - var didWarnAboutUndefinedSnapshotBeforeUpdate = null; { didWarnAboutUndefinedSnapshotBeforeUpdate = new Set(); @@ -12388,10 +13539,25 @@ function safelyDetachRef(current$$1) { } } +function safelyCallDestroy(current$$1, destroy) { + { + invokeGuardedCallback(null, destroy, null); + if (hasCaughtError()) { + var error = clearCaughtError(); + captureCommitPhaseError(current$$1, error); + } + } +} + function commitBeforeMutationLifeCycles(current$$1, finishedWork) { switch (finishedWork.tag) { - case ClassComponent: - case ClassComponentLazy: { + case FunctionComponent: + case ForwardRef: + case SimpleMemoComponent: { + commitHookEffectList(UnmountSnapshot, NoEffect$1, finishedWork); + return; + } + case ClassComponent: { if (finishedWork.effectTag & Snapshot) { if (current$$1 !== null) { var prevProps = current$$1.memoizedProps; @@ -12423,6 +13589,7 @@ function commitBeforeMutationLifeCycles(current$$1, finishedWork) { case HostComponent: case HostText: case HostPortal: + case IncompleteClassComponent: // Nothing to do for these component types return; default: { @@ -12435,6 +13602,37 @@ function commitBeforeMutationLifeCycles(current$$1, finishedWork) { } } +function commitHookEffectList(unmountTag, mountTag, finishedWork) { + var updateQueue = finishedWork.updateQueue; + var lastEffect = updateQueue !== null ? updateQueue.lastEffect : null; + if (lastEffect !== null) { + var firstEffect = lastEffect.next; + var effect = firstEffect; + do { + if ((effect.tag & unmountTag) !== NoEffect$1) { + // Unmount + var destroy = effect.destroy; + effect.destroy = null; + if (destroy !== null) { + destroy(); + } + } + if ((effect.tag & mountTag) !== NoEffect$1) { + // Mount + var create = effect.create; + var _destroy = create(); + effect.destroy = typeof _destroy === "function" ? _destroy : null; + } + effect = effect.next; + } while (effect !== firstEffect); + } +} + +function commitPassiveHookEffects(finishedWork) { + commitHookEffectList(UnmountPassive, NoEffect$1, finishedWork); + commitHookEffectList(NoEffect$1, MountPassive, finishedWork); +} + function commitLifeCycles( finishedRoot, current$$1, @@ -12442,8 +13640,13 @@ function commitLifeCycles( committedExpirationTime ) { switch (finishedWork.tag) { - case ClassComponent: - case ClassComponentLazy: { + case FunctionComponent: + case ForwardRef: + case SimpleMemoComponent: { + commitHookEffectList(UnmountLayout, MountLayout, finishedWork); + break; + } + case ClassComponent: { var instance = finishedWork.stateNode; if (finishedWork.effectTag & Update) { if (current$$1 === null) { @@ -12489,7 +13692,6 @@ function commitLifeCycles( _instance = getPublicInstance(finishedWork.child.stateNode); break; case ClassComponent: - case ClassComponentLazy: _instance = finishedWork.child.stateNode; break; } @@ -12553,22 +13755,49 @@ function commitLifeCycles( return; } case SuspenseComponent: { - if ((finishedWork.mode & StrictMode) === NoEffect) { - // In loose mode, a placeholder times out by scheduling a synchronous - // update in the commit phase. Use `updateQueue` field to signal that - // the Timeout needs to switch to the placeholder. We don't need an - // entire queue. Any non-null value works. - // $FlowFixMe - Intentionally using a value other than an UpdateQueue. - finishedWork.updateQueue = emptyObject$1; + if (finishedWork.effectTag & Callback) { + // In non-strict mode, a suspense boundary times out by commiting + // twice: first, by committing the children in an inconsistent state, + // then hiding them and showing the fallback children in a subsequent + var _newState = { + alreadyCaptured: true, + didTimeout: false, + timedOutAt: NoWork + }; + finishedWork.memoizedState = _newState; + flushPassiveEffects(); scheduleWork(finishedWork, Sync); + return; + } + var oldState = current$$1 !== null ? current$$1.memoizedState : null; + var newState = finishedWork.memoizedState; + var oldDidTimeout = oldState !== null ? oldState.didTimeout : false; + + var newDidTimeout = void 0; + var primaryChildParent = finishedWork; + if (newState === null) { + newDidTimeout = false; } else { - // In strict mode, the Update effect is used to record the time at - // which the placeholder timed out. - var currentTime = requestCurrentTime(); - finishedWork.stateNode = { timedOutAt: currentTime }; + newDidTimeout = newState.didTimeout; + if (newDidTimeout) { + primaryChildParent = finishedWork.child; + newState.alreadyCaptured = false; + if (newState.timedOutAt === NoWork) { + // If the children had not already timed out, record the time. + // This is used to compute the elapsed time during subsequent + // attempts to render the children. + newState.timedOutAt = requestCurrentTime(); + } + } + } + + if (newDidTimeout !== oldDidTimeout && primaryChildParent !== null) { + hideOrUnhideAllChildren(primaryChildParent, newDidTimeout); } return; } + case IncompleteClassComponent: + break; default: { invariant( false, @@ -12579,6 +13808,45 @@ function commitLifeCycles( } } +function hideOrUnhideAllChildren(finishedWork, isHidden) { + if (supportsMutation) { + // We only have the top Fiber that was inserted but we need recurse down its + var node = finishedWork; + while (true) { + if (node.tag === HostComponent) { + var instance = node.stateNode; + if (isHidden) { + hideInstance(instance); + } else { + unhideInstance(node.stateNode, node.memoizedProps); + } + } else if (node.tag === HostText) { + var _instance3 = node.stateNode; + if (isHidden) { + hideTextInstance(_instance3); + } else { + unhideTextInstance(_instance3, node.memoizedProps); + } + } else if (node.child !== null) { + node.child.return = node; + node = node.child; + continue; + } + if (node === finishedWork) { + return; + } + while (node.sibling === null) { + if (node.return === null || node.return === finishedWork) { + return; + } + node = node.return; + } + node.sibling.return = node.return; + node = node.sibling; + } + } +} + function commitAttachRef(finishedWork) { var ref = finishedWork.ref; if (ref !== null) { @@ -12629,8 +13897,28 @@ function commitUnmount(current$$1) { onCommitUnmount(current$$1); switch (current$$1.tag) { - case ClassComponent: - case ClassComponentLazy: { + case FunctionComponent: + case ForwardRef: + case MemoComponent: + case SimpleMemoComponent: { + var updateQueue = current$$1.updateQueue; + if (updateQueue !== null) { + var lastEffect = updateQueue.lastEffect; + if (lastEffect !== null) { + var firstEffect = lastEffect.next; + var effect = firstEffect; + do { + var destroy = effect.destroy; + if (destroy !== null) { + safelyCallDestroy(current$$1, destroy); + } + effect = effect.next; + } while (effect !== firstEffect); + } + } + break; + } + case ClassComponent: { safelyDetachRef(current$$1); var instance = current$$1.stateNode; if (typeof instance.componentWillUnmount === "function") { @@ -12722,8 +14010,7 @@ function commitContainer(finishedWork) { } switch (finishedWork.tag) { - case ClassComponent: - case ClassComponentLazy: { + case ClassComponent: { return; } case HostComponent: { @@ -12997,13 +14284,29 @@ function commitDeletion(current$$1) { function commitWork(current$$1, finishedWork) { if (!supportsMutation) { + switch (finishedWork.tag) { + case FunctionComponent: + case ForwardRef: + case MemoComponent: + case SimpleMemoComponent: { + commitHookEffectList(UnmountMutation, MountMutation, finishedWork); + return; + } + } + commitContainer(finishedWork); return; } switch (finishedWork.tag) { - case ClassComponent: - case ClassComponentLazy: { + case FunctionComponent: + case ForwardRef: + case MemoComponent: + case SimpleMemoComponent: { + commitHookEffectList(UnmountMutation, MountMutation, finishedWork); + return; + } + case ClassComponent: { return; } case HostComponent: { @@ -13057,6 +14360,9 @@ function commitWork(current$$1, finishedWork) { case SuspenseComponent: { return; } + case IncompleteClassComponent: { + return; + } default: { invariant( false, @@ -13074,10 +14380,6 @@ function commitResetTextContent(current$$1) { resetTextContent(current$$1.stateNode); } -function NoopComponent() { - return null; -} - function createRootErrorUpdate(fiber, errorInfo, expirationTime) { var update = createUpdate(expirationTime); // Unmount the root by rendering null. @@ -13171,22 +14473,17 @@ function throwException( var startTimeMs = -1; do { if (_workInProgress.tag === SuspenseComponent) { - var current = _workInProgress.alternate; - if ( - current !== null && - current.memoizedState === true && - current.stateNode !== null - ) { - // Reached a placeholder that already timed out. Each timed out - // placeholder acts as the root of a new suspense boundary. - - // Use the time at which the placeholder timed out as the start time - // for the current render. - var timedOutAt = current.stateNode.timedOutAt; - startTimeMs = expirationTimeToMs(timedOutAt); - - // Do not search any further. - break; + var current$$1 = _workInProgress.alternate; + if (current$$1 !== null) { + var currentState = current$$1.memoizedState; + if (currentState !== null && currentState.didTimeout) { + // Reached a boundary that already timed out. Do not search + // any further. + var timedOutAt = currentState.timedOutAt; + startTimeMs = expirationTimeToMs(timedOutAt); + // Do not search any further. + break; + } } var timeoutPropMs = _workInProgress.pendingProps.maxDuration; if (typeof timeoutPropMs === "number") { @@ -13206,129 +14503,127 @@ function throwException( // Schedule the nearest Suspense to re-render the timed out view. _workInProgress = returnFiber; do { - if (_workInProgress.tag === SuspenseComponent) { - var didTimeout = _workInProgress.memoizedState; - if (!didTimeout) { - // Found the nearest boundary. + if ( + _workInProgress.tag === SuspenseComponent && + shouldCaptureSuspense(_workInProgress.alternate, _workInProgress) + ) { + // Found the nearest boundary. - // If the boundary is not in concurrent mode, we should not suspend, and - // likewise, when the promise resolves, we should ping synchronously. - var pingTime = - (_workInProgress.mode & ConcurrentMode) === NoEffect - ? Sync - : renderExpirationTime; + // If the boundary is not in concurrent mode, we should not suspend, and + // likewise, when the promise resolves, we should ping synchronously. + var pingTime = + (_workInProgress.mode & ConcurrentMode) === NoEffect + ? Sync + : renderExpirationTime; - // Attach a listener to the promise to "ping" the root and retry. - var onResolveOrReject = retrySuspendedRoot.bind( - null, - root, - _workInProgress, - pingTime + // Attach a listener to the promise to "ping" the root and retry. + var onResolveOrReject = retrySuspendedRoot.bind( + null, + root, + _workInProgress, + sourceFiber, + pingTime + ); + if (enableSchedulerTracing) { + onResolveOrReject = tracing.unstable_wrap(onResolveOrReject); + } + thenable.then(onResolveOrReject, onResolveOrReject); + + // If the boundary is outside of concurrent mode, we should *not* + // suspend the commit. Pretend as if the suspended component rendered + // null and keep rendering. In the commit phase, we'll schedule a + // subsequent synchronous update to re-render the Suspense. + // + // Note: It doesn't matter whether the component that suspended was + // inside a concurrent mode tree. If the Suspense is outside of it, we + // should *not* suspend the commit. + if ((_workInProgress.mode & ConcurrentMode) === NoEffect) { + _workInProgress.effectTag |= Callback; + + // Unmount the source fiber's children + var nextChildren = null; + reconcileChildren( + sourceFiber.alternate, + sourceFiber, + nextChildren, + renderExpirationTime ); - if (enableSchedulerTracing) { - onResolveOrReject = tracing.unstable_wrap(onResolveOrReject); - } - thenable.then(onResolveOrReject, onResolveOrReject); + sourceFiber.effectTag &= ~Incomplete; - // If the boundary is outside of strict mode, we should *not* suspend - // the commit. Pretend as if the suspended component rendered null and - // keep rendering. In the commit phase, we'll schedule a subsequent - // synchronous update to re-render the Suspense. - // - // Note: It doesn't matter whether the component that suspended was - // inside a strict mode tree. If the Suspense is outside of it, we - // should *not* suspend the commit. - if ((_workInProgress.mode & StrictMode) === NoEffect) { - _workInProgress.effectTag |= Update; + // 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. + sourceFiber.effectTag &= ~LifecycleEffectMask; - // Unmount the source fiber's children - var nextChildren = null; - reconcileChildren( - sourceFiber.alternate, - sourceFiber, - nextChildren, - renderExpirationTime - ); - sourceFiber.effectTag &= ~Incomplete; - if (sourceFiber.tag === IndeterminateComponent) { - // Let's just assume it's a function component. This fiber will - // be unmounted in the immediate next commit, anyway. - sourceFiber.tag = FunctionComponent; + if (sourceFiber.tag === ClassComponent) { + var _current = sourceFiber.alternate; + if (_current === null) { + // This is a new mount. Change the tag so it's not mistaken for a + // completed class component. For example, we should not call + // componentWillUnmount if it is deleted. + sourceFiber.tag = IncompleteClassComponent; } - - 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. - sourceFiber.effectTag &= ~LifecycleEffectMask; - if (sourceFiber.alternate === null) { - // We're about to mount a class component that doesn't have an - // instance. Turn this into a dummy function component instead, - // to prevent type errors. This is a bit weird but it's an edge - // case and we're about to synchronously delete this - // component, anyway. - sourceFiber.tag = FunctionComponent; - sourceFiber.type = NoopComponent; - } - } - - // Exit without suspending. - return; } - // Confirmed that the boundary is in a strict mode tree. Continue with - // the normal suspend path. - - var absoluteTimeoutMs = void 0; - if (earliestTimeoutMs === -1) { - // If no explicit threshold is given, default to an abitrarily large - // value. The actual size doesn't matter because the threshold for the - // whole tree will be clamped to the expiration time. - absoluteTimeoutMs = maxSigned31BitInt; - } else { - if (startTimeMs === -1) { - // This suspend happened outside of any already timed-out - // placeholders. We don't know exactly when the update was scheduled, - // but we can infer an approximate start time from the expiration - // 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 necessary, - // but we can account for this by adjusting for the Just Noticeable - // Difference. - var earliestExpirationTime = findEarliestOutstandingPriorityLevel( - root, - renderExpirationTime - ); - var earliestExpirationTimeMs = expirationTimeToMs( - earliestExpirationTime - ); - startTimeMs = earliestExpirationTimeMs - LOW_PRIORITY_EXPIRATION; - } - absoluteTimeoutMs = startTimeMs + earliestTimeoutMs; - } - - // Mark the earliest timeout in the suspended fiber's ancestor path. - // After completing the root, we'll take the largest of all the - // suspended fiber's timeouts and use it to compute a timeout for the - // whole tree. - renderDidSuspend(root, absoluteTimeoutMs, renderExpirationTime); - - _workInProgress.effectTag |= ShouldCapture; - _workInProgress.expirationTime = renderExpirationTime; + // Exit without suspending. return; } - // This boundary already captured during this render. Continue to the - // next boundary. + + // Confirmed that the boundary is in a concurrent mode tree. Continue + // with the normal suspend path. + + var absoluteTimeoutMs = void 0; + if (earliestTimeoutMs === -1) { + // If no explicit threshold is given, default to an abitrarily large + // value. The actual size doesn't matter because the threshold for the + // whole tree will be clamped to the expiration time. + absoluteTimeoutMs = maxSigned31BitInt; + } else { + if (startTimeMs === -1) { + // This suspend happened outside of any already timed-out + // placeholders. We don't know exactly when the update was + // scheduled, but we can infer an approximate start time from the + // expiration 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 necessary, but we can account for this by adjusting + // for the Just Noticeable Difference. + var earliestExpirationTime = findEarliestOutstandingPriorityLevel( + root, + renderExpirationTime + ); + var earliestExpirationTimeMs = expirationTimeToMs( + earliestExpirationTime + ); + startTimeMs = earliestExpirationTimeMs - LOW_PRIORITY_EXPIRATION; + } + absoluteTimeoutMs = startTimeMs + earliestTimeoutMs; + } + + // Mark the earliest timeout in the suspended fiber's ancestor path. + // After completing the root, we'll take the largest of all the + // suspended fiber's timeouts and use it to compute a timeout for the + // whole tree. + renderDidSuspend(root, absoluteTimeoutMs, renderExpirationTime); + + _workInProgress.effectTag |= ShouldCapture; + _workInProgress.expirationTime = renderExpirationTime; + return; } + // This boundary already captured during this render. Continue to the next + // boundary. _workInProgress = _workInProgress.return; } while (_workInProgress !== null); // No boundary was found. Fallthrough to error mode. + // TODO: Use invariant so the message is stripped in prod? value = new Error( - "An update was suspended, but no placeholder UI was provided." + (getComponentName(sourceFiber.type) || "A React component") + + " suspended while rendering, but no fallback UI was specified.\n" + + "\n" + + "Add a component higher in the tree to " + + "provide a loading indicator or placeholder to display." + + getStackByFiberInDevAndProd(sourceFiber) ); } @@ -13353,7 +14648,6 @@ function throwException( return; } case ClassComponent: - case ClassComponentLazy: // Capture and retry var errorInfo = value; var ctor = workInProgress.type; @@ -13398,28 +14692,16 @@ 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 _effectTag2 = workInProgress.effectTag; + var _effectTag = workInProgress.effectTag; invariant( - (_effectTag2 & DidCapture) === NoEffect, + (_effectTag & DidCapture) === NoEffect, "The root failed to unmount after an error. This is likely a bug in " + "React. Please file an issue." ); - workInProgress.effectTag = (_effectTag2 & ~ShouldCapture) | DidCapture; + workInProgress.effectTag = (_effectTag & ~ShouldCapture) | DidCapture; return workInProgress; } case HostComponent: { @@ -13427,9 +14709,36 @@ function unwindWork(workInProgress, renderExpirationTime) { return null; } case SuspenseComponent: { - var _effectTag3 = workInProgress.effectTag; - if (_effectTag3 & ShouldCapture) { - workInProgress.effectTag = (_effectTag3 & ~ShouldCapture) | DidCapture; + var _effectTag2 = workInProgress.effectTag; + if (_effectTag2 & ShouldCapture) { + workInProgress.effectTag = (_effectTag2 & ~ShouldCapture) | DidCapture; + // Captured a suspense effect. Set the boundary's `alreadyCaptured` + // state to true so we know to render the fallback. + var current$$1 = workInProgress.alternate; + var currentState = + current$$1 !== null ? current$$1.memoizedState : null; + var nextState = workInProgress.memoizedState; + if (nextState === null) { + // No existing state. Create a new object. + nextState = { + alreadyCaptured: true, + didTimeout: false, + timedOutAt: NoWork + }; + } else if (currentState === nextState) { + // There is an existing state but it's the same as the current tree's. + // Clone the object. + nextState = { + alreadyCaptured: true, + didTimeout: nextState.didTimeout, + timedOutAt: nextState.timedOutAt + }; + } else { + // Already have a clone, so it's safe to mutate. + nextState.alreadyCaptured = true; + } + workInProgress.memoizedState = nextState; + // Re-render the boundary. return workInProgress; } return null; @@ -13454,14 +14763,6 @@ function unwindInterruptedWork(interruptedWork) { } break; } - case ClassComponentLazy: { - var _childContextTypes = - interruptedWork.type._reactResult.childContextTypes; - if (_childContextTypes !== null && _childContextTypes !== undefined) { - popContext(interruptedWork); - } - break; - } case HostRoot: { popHostContainer(interruptedWork); popTopLevelContextObject(interruptedWork); @@ -13483,7 +14784,17 @@ function unwindInterruptedWork(interruptedWork) { } var Dispatcher = { - readContext: readContext + readContext: readContext, + useCallback: useCallback, + useContext: useContext, + useEffect: useEffect, + useImperativeMethods: useImperativeMethods, + useLayoutEffect: useLayoutEffect, + useMemo: useMemo, + useMutationEffect: useMutationEffect, + useReducer: useReducer, + useRef: useRef, + useState: useState }; var ReactCurrentOwner$2 = ReactSharedInternals.ReactCurrentOwner; @@ -13511,19 +14822,21 @@ if (enableSchedulerTracing) { didWarnSetStateChildContext = false; var didWarnStateUpdateForUnmountedComponent = {}; - warnAboutUpdateOnUnmounted = function(fiber) { + warnAboutUpdateOnUnmounted = function(fiber, isClass) { // We show the whole stack but dedupe on the top component's name because // the problematic code almost always lies inside that component. - var componentName = getComponentName(fiber.type) || "ReactClass"; + var componentName = getComponentName(fiber.type) || "ReactComponent"; if (didWarnStateUpdateForUnmountedComponent[componentName]) { return; } warningWithoutStack$1( false, - "Can't call setState (or forceUpdate) on an unmounted component. This " + + "Can't perform a React state update on an unmounted component. This " + "is a no-op, but it indicates a memory leak in your application. To " + - "fix, cancel all subscriptions and asynchronous tasks in the " + - "componentWillUnmount method.%s", + "fix, cancel all subscriptions and asynchronous tasks in %s.%s", + isClass + ? "the componentWillUnmount method" + : "a useEffect cleanup function", getStackByFiberInDevAndProd(fiber) ); didWarnStateUpdateForUnmountedComponent[componentName] = true; @@ -13575,6 +14888,9 @@ var nextRenderDidError = false; var nextEffect = null; var isCommitting$1 = false; +var rootWithPendingPassiveEffects = null; +var passiveEffectCallbackHandle = null; +var passiveEffectCallback = null; var legacyErrorBoundariesThatAlreadyFailed = null; @@ -13632,13 +14948,6 @@ if (true && replayFailedUnitOfWorkWithInvokeGuardedCallback) { } break; } - case ClassComponentLazy: { - var _Component = getResultFromResolvedThenable(failedUnitOfWork.type); - if (isContextProvider(_Component)) { - popContext(failedUnitOfWork); - } - break; - } case HostPortal: popHostContainer(failedUnitOfWork); break; @@ -13777,8 +15086,6 @@ function commitBeforeMutationLifecycles() { commitBeforeMutationLifeCycles(current$$1, nextEffect); } - // Don't cleanup effects yet; - // This will be done by commitAllLifeCycles() nextEffect = nextEffect.nextEffect; } @@ -13815,15 +15122,48 @@ function commitAllLifeCycles(finishedRoot, committedExpirationTime) { commitAttachRef(nextEffect); } - var next = nextEffect.nextEffect; - // Ensure that we clean these up so that we don't accidentally keep them. - // I'm not actually sure this matters because we can't reset firstEffect - // and lastEffect since they're on every node, not just the effectful - // ones. So we have to clean everything as we reuse nodes anyway. - nextEffect.nextEffect = null; - // Ensure that we reset the effectTag here so that we can rely on effect - // tags to reason about the current life-cycle. - nextEffect = next; + if (effectTag & Passive) { + rootWithPendingPassiveEffects = finishedRoot; + } + + nextEffect = nextEffect.nextEffect; + } +} + +function commitPassiveEffects(root, firstEffect) { + rootWithPendingPassiveEffects = null; + passiveEffectCallbackHandle = null; + passiveEffectCallback = null; + + // Set this to true to prevent re-entrancy + var previousIsRendering = isRendering; + isRendering = true; + + var effect = firstEffect; + do { + if (effect.effectTag & Passive) { + var didError = false; + var error = void 0; + { + invokeGuardedCallback(null, commitPassiveHookEffects, null, effect); + if (hasCaughtError()) { + didError = true; + error = clearCaughtError(); + } + } + if (didError) { + captureCommitPhaseError(effect, error); + } + } + effect = effect.nextEffect; + } while (effect !== null); + + isRendering = previousIsRendering; + + // Check if work was scheduled by one of the effects + var rootExpirationTime = root.expirationTime; + if (rootExpirationTime !== NoWork) { + requestWork(root, rootExpirationTime); } } @@ -13842,6 +15182,15 @@ function markLegacyErrorBoundaryAsFailed(instance) { } } +function flushPassiveEffects() { + if (passiveEffectCallback !== null) { + scheduler.unstable_cancelCallback(passiveEffectCallbackHandle); + // We call the scheduled callback instead of commitPassiveEffects directly + // to ensure tracing works correctly. + passiveEffectCallback(); + } +} + function commitRoot(root, finishedWork) { isWorking = true; isCommitting$1 = true; @@ -13867,9 +15216,7 @@ function commitRoot(root, finishedWork) { var updateExpirationTimeBeforeCommit = finishedWork.expirationTime; var childExpirationTimeBeforeCommit = finishedWork.childExpirationTime; var earliestRemainingTimeBeforeCommit = - updateExpirationTimeBeforeCommit === NoWork || - (childExpirationTimeBeforeCommit !== NoWork && - childExpirationTimeBeforeCommit < updateExpirationTimeBeforeCommit) + childExpirationTimeBeforeCommit > updateExpirationTimeBeforeCommit ? childExpirationTimeBeforeCommit : updateExpirationTimeBeforeCommit; markCommittedPriorityLevels(root, earliestRemainingTimeBeforeCommit); @@ -14011,6 +15358,22 @@ function commitRoot(root, finishedWork) { } } + if (firstEffect !== null && rootWithPendingPassiveEffects !== null) { + // This commit included a passive effect. These do not need to fire until + // after the next paint. Schedule an callback to fire them in an async + // event. To ensure serial execution, the callback will be flushed early if + // we enter rootWithPendingPassiveEffects commit phase before then. + var callback = commitPassiveEffects.bind(null, root, firstEffect); + if (enableSchedulerTracing) { + // TODO: Avoid this extra callback by mutating the tracing ref directly, + // like we do at the beginning of commitRoot. I've opted not to do that + // here because that code is still in flux. + callback = tracing.unstable_wrap(callback); + } + passiveEffectCallbackHandle = scheduler.unstable_scheduleCallback(callback); + passiveEffectCallback = callback; + } + isCommitting$1 = false; isWorking = false; stopCommitLifeCyclesTimer(); @@ -14023,9 +15386,7 @@ function commitRoot(root, finishedWork) { var updateExpirationTimeAfterCommit = finishedWork.expirationTime; var childExpirationTimeAfterCommit = finishedWork.childExpirationTime; var earliestRemainingTimeAfterCommit = - updateExpirationTimeAfterCommit === NoWork || - (childExpirationTimeAfterCommit !== NoWork && - childExpirationTimeAfterCommit < updateExpirationTimeAfterCommit) + childExpirationTimeAfterCommit > updateExpirationTimeAfterCommit ? childExpirationTimeAfterCommit : updateExpirationTimeAfterCommit; if (earliestRemainingTimeAfterCommit === NoWork) { @@ -14068,10 +15429,7 @@ function commitRoot(root, finishedWork) { // Only decrement the pending interaction count if we're done. // If there's still work at the current priority, // That indicates that we are waiting for suspense data. - if ( - earliestRemainingTimeAfterCommit === NoWork || - scheduledExpirationTime < earliestRemainingTimeAfterCommit - ) { + if (scheduledExpirationTime > earliestRemainingTimeAfterCommit) { pendingInteractionMap.delete(scheduledExpirationTime); scheduledInteractions.forEach(function(interaction) { @@ -14127,18 +15485,10 @@ function resetChildExpirationTime(workInProgress, renderTime) { while (child !== null) { var childUpdateExpirationTime = child.expirationTime; var childChildExpirationTime = child.childExpirationTime; - if ( - newChildExpirationTime === NoWork || - (childUpdateExpirationTime !== NoWork && - childUpdateExpirationTime < newChildExpirationTime) - ) { + if (childUpdateExpirationTime > newChildExpirationTime) { newChildExpirationTime = childUpdateExpirationTime; } - if ( - newChildExpirationTime === NoWork || - (childChildExpirationTime !== NoWork && - childChildExpirationTime < newChildExpirationTime) - ) { + if (childChildExpirationTime > newChildExpirationTime) { newChildExpirationTime = childChildExpirationTime; } if (shouldBubbleActualDurations) { @@ -14154,18 +15504,10 @@ function resetChildExpirationTime(workInProgress, renderTime) { while (_child !== null) { var _childUpdateExpirationTime = _child.expirationTime; var _childChildExpirationTime = _child.childExpirationTime; - if ( - newChildExpirationTime === NoWork || - (_childUpdateExpirationTime !== NoWork && - _childUpdateExpirationTime < newChildExpirationTime) - ) { + if (_childUpdateExpirationTime > newChildExpirationTime) { newChildExpirationTime = _childUpdateExpirationTime; } - if ( - newChildExpirationTime === NoWork || - (_childChildExpirationTime !== NoWork && - _childChildExpirationTime < newChildExpirationTime) - ) { + if (_childChildExpirationTime > newChildExpirationTime) { newChildExpirationTime = _childChildExpirationTime; } _child = _child.sibling; @@ -14379,6 +15721,7 @@ function performUnitOfWork(workInProgress) { } next = beginWork(current$$1, workInProgress, nextRenderExpirationTime); + workInProgress.memoizedProps = workInProgress.pendingProps; if (workInProgress.mode & ProfileMode) { // Record the render duration assuming we didn't bailout (or error). @@ -14386,6 +15729,7 @@ function performUnitOfWork(workInProgress) { } } else { next = beginWork(current$$1, workInProgress, nextRenderExpirationTime); + workInProgress.memoizedProps = workInProgress.pendingProps; } { @@ -14419,19 +15763,22 @@ function workLoop(isYieldy) { nextUnitOfWork = performUnitOfWork(nextUnitOfWork); } } else { - // Flush asynchronous work until the deadline runs out of time. - while (nextUnitOfWork !== null && !shouldYield()) { + // Flush asynchronous work until there's a higher priority event + while (nextUnitOfWork !== null && !shouldYieldToRenderer()) { nextUnitOfWork = performUnitOfWork(nextUnitOfWork); } } } -function renderRoot(root, isYieldy, isExpired) { +function renderRoot(root, isYieldy) { invariant( !isWorking, "renderRoot was called recursively. This error is likely caused " + "by a bug in React. Please file an issue." ); + + flushPassiveEffects(); + isWorking = true; ReactCurrentOwner$2.currentDispatcher = Dispatcher; @@ -14463,7 +15810,7 @@ function renderRoot(root, isYieldy, isExpired) { scheduledInteractions, scheduledExpirationTime ) { - if (scheduledExpirationTime <= expirationTime) { + if (scheduledExpirationTime >= expirationTime) { scheduledInteractions.forEach(function(interaction) { return interactions.add(interaction); }); @@ -14515,6 +15862,9 @@ function renderRoot(root, isYieldy, isExpired) { try { workLoop(isYieldy); } catch (thrownValue) { + resetContextDependences(); + resetHooks(); + if (nextUnitOfWork === null) { // This is a fatal error. didFatal = true; @@ -14577,6 +15927,7 @@ function renderRoot(root, isYieldy, isExpired) { isWorking = false; ReactCurrentOwner$2.currentDispatcher = null; resetContextDependences(); + resetHooks(); // Yield back to main thread. if (didFatal) { @@ -14648,7 +15999,7 @@ function renderRoot(root, isYieldy, isExpired) { // similar to a suspend, but without a timeout because we're not waiting // for a promise to resolve. !root.didError && - !isExpired + isYieldy ) { root.didError = true; var _suspendedExpirationTime = (root.nextExpirationTimeToWorkOn = expirationTime); @@ -14664,7 +16015,7 @@ function renderRoot(root, isYieldy, isExpired) { } } - if (!isExpired && nextLatestAbsoluteTimeoutMs !== -1) { + if (isYieldy && nextLatestAbsoluteTimeoutMs !== -1) { // The tree was suspended. var _suspendedExpirationTime2 = expirationTime; markSuspendedPriorityLevel(root, _suspendedExpirationTime2); @@ -14706,17 +16057,12 @@ function renderRoot(root, isYieldy, isExpired) { onComplete(root, rootWorkInProgress, expirationTime); } -function dispatch(sourceFiber, value, expirationTime) { - invariant( - !isWorking || isCommitting$1, - "dispatch: Cannot dispatch during the render phase." - ); - +function captureCommitPhaseError(sourceFiber, value) { + var expirationTime = Sync; var fiber = sourceFiber.return; while (fiber !== null) { switch (fiber.tag) { case ClassComponent: - case ClassComponentLazy: var ctor = fiber.type; var instance = fiber.stateNode; if ( @@ -14757,10 +16103,6 @@ function dispatch(sourceFiber, value, expirationTime) { } } -function captureCommitPhaseError(fiber, error) { - return dispatch(fiber, error, Sync); -} - function computeThreadID(expirationTime, interactionThreadID) { // Interaction threads are unique per root and expiration time. return expirationTime * 1000 + interactionThreadID; @@ -14795,7 +16137,7 @@ function computeExpirationForFiber(currentTime, fiber) { // If we're in the middle of rendering a tree, do not update at the same // expiration time that is already rendering. if (nextRoot !== null && expirationTime === nextRenderExpirationTime) { - expirationTime += 1; + expirationTime -= 1; } } else { // This is a sync update @@ -14806,7 +16148,10 @@ function computeExpirationForFiber(currentTime, fiber) { // This is an interactive update. Keep track of the lowest pending // interactive expiration time. This allows us to synchronously flush // all interactive updates when needed. - if (expirationTime > lowestPriorityPendingInteractiveExpirationTime) { + if ( + lowestPriorityPendingInteractiveExpirationTime === NoWork || + expirationTime < lowestPriorityPendingInteractiveExpirationTime + ) { lowestPriorityPendingInteractiveExpirationTime = expirationTime; } } @@ -14827,7 +16172,7 @@ function renderDidError() { nextRenderDidError = true; } -function retrySuspendedRoot(root, fiber, suspendedTime) { +function retrySuspendedRoot(root, boundaryFiber, sourceFiber, suspendedTime) { var retryTime = void 0; if (isPriorityLevelSuspended(root, suspendedTime)) { @@ -14838,18 +16183,18 @@ function retrySuspendedRoot(root, fiber, suspendedTime) { } else { // Suspense already timed out. Compute a new expiration time var currentTime = requestCurrentTime(); - retryTime = computeExpirationForFiber(currentTime, fiber); + retryTime = computeExpirationForFiber(currentTime, boundaryFiber); markPendingPriorityLevel(root, retryTime); } - // TODO: If the placeholder fiber has already rendered the primary children + // TODO: If the suspense fiber has already rendered the primary children // without suspending (that is, all of the promises have already resolved), // we should not trigger another update here. One case this happens is when // we are in sync mode and a single promise is thrown both on initial render // and on update; we attach two .then(retrySuspendedRoot) callbacks and each // one performs Sync work, rerendering the Suspense. - if ((fiber.mode & ConcurrentMode) !== NoContext) { + if ((boundaryFiber.mode & ConcurrentMode) !== NoContext) { if (root === nextRoot && nextRenderExpirationTime === suspendedTime) { // Received a ping at the same priority level at which we're currently // rendering. Restart from the root. @@ -14857,7 +16202,23 @@ function retrySuspendedRoot(root, fiber, suspendedTime) { } } - scheduleWorkToRoot(fiber, retryTime); + scheduleWorkToRoot(boundaryFiber, retryTime); + if ((boundaryFiber.mode & ConcurrentMode) === NoContext) { + // Outside of concurrent mode, we must schedule an update on the source + // fiber, too, since it already committed in an inconsistent state and + // therefore does not have any pending work. + scheduleWorkToRoot(sourceFiber, retryTime); + var sourceTag = sourceFiber.tag; + if (sourceTag === ClassComponent && sourceFiber.stateNode !== null) { + // When we try rendering again, we should not reuse the current fiber, + // since it's known to be in an inconsistent state. Use a force updte to + // prevent a bail out. + var update = createUpdate(retryTime); + update.tag = ForceUpdate; + enqueueUpdate(sourceFiber, update); + } + } + var rootExpirationTime = root.expirationTime; if (rootExpirationTime !== NoWork) { requestWork(root, rootExpirationTime); @@ -14868,25 +16229,18 @@ function scheduleWorkToRoot(fiber, expirationTime) { recordScheduleUpdate(); { - if (fiber.tag === ClassComponent || fiber.tag === ClassComponentLazy) { + if (fiber.tag === ClassComponent) { var instance = fiber.stateNode; warnAboutInvalidUpdates(instance); } } // Update the source fiber's expiration time - if ( - fiber.expirationTime === NoWork || - fiber.expirationTime > expirationTime - ) { + if (fiber.expirationTime < expirationTime) { fiber.expirationTime = expirationTime; } var alternate = fiber.alternate; - if ( - alternate !== null && - (alternate.expirationTime === NoWork || - alternate.expirationTime > expirationTime) - ) { + if (alternate !== null && alternate.expirationTime < expirationTime) { alternate.expirationTime = expirationTime; } // Walk the parent path to the root and update the child expiration time. @@ -14897,22 +16251,17 @@ function scheduleWorkToRoot(fiber, expirationTime) { } else { while (node !== null) { alternate = node.alternate; - if ( - node.childExpirationTime === NoWork || - node.childExpirationTime > expirationTime - ) { + if (node.childExpirationTime < expirationTime) { node.childExpirationTime = expirationTime; if ( alternate !== null && - (alternate.childExpirationTime === NoWork || - alternate.childExpirationTime > expirationTime) + alternate.childExpirationTime < expirationTime ) { alternate.childExpirationTime = expirationTime; } } else if ( alternate !== null && - (alternate.childExpirationTime === NoWork || - alternate.childExpirationTime > expirationTime) + alternate.childExpirationTime < expirationTime ) { alternate.childExpirationTime = expirationTime; } @@ -14925,11 +16274,18 @@ function scheduleWorkToRoot(fiber, expirationTime) { } if (root === null) { - if ( - true && - (fiber.tag === ClassComponent || fiber.tag === ClassComponentLazy) - ) { - warnAboutUpdateOnUnmounted(fiber); + { + switch (fiber.tag) { + case ClassComponent: + warnAboutUpdateOnUnmounted(fiber, true); + break; + case FunctionComponent: + case ForwardRef: + case MemoComponent: + case SimpleMemoComponent: + warnAboutUpdateOnUnmounted(fiber, false); + break; + } } return null; } @@ -14980,7 +16336,7 @@ function scheduleWork(fiber, expirationTime) { if ( !isWorking && nextRenderExpirationTime !== NoWork && - expirationTime < nextRenderExpirationTime + expirationTime > nextRenderExpirationTime ) { // This is an interruption. (Used for performance tracking.) interruptedBy = fiber; @@ -15024,10 +16380,8 @@ var isRendering = false; var nextFlushedRoot = null; var nextFlushedExpirationTime = NoWork; var lowestPriorityPendingInteractiveExpirationTime = NoWork; -var deadlineDidExpire = false; var hasUnhandledError = false; var unhandledError = null; -var deadline = null; var isBatchingUpdates = false; var isUnbatchingUpdates = false; @@ -15044,8 +16398,6 @@ var NESTED_UPDATE_LIMIT = 50; var nestedUpdateCount = 0; var lastCommittedRootDuringThisBatch = null; -var timeHeuristicForUnitOfWork = 1; - function recomputeCurrentRendererTime() { var currentTimeMs = now() - originalStartTimeMs; currentRendererTime = msToExpirationTime(currentTimeMs); @@ -15054,7 +16406,7 @@ function recomputeCurrentRendererTime() { function scheduleCallbackWithExpirationTime(root, expirationTime) { if (callbackExpirationTime !== NoWork) { // A callback is already scheduled. Check its expiration time (timeout). - if (expirationTime > callbackExpirationTime) { + if (expirationTime < callbackExpirationTime) { // Existing callback has sufficient timeout. Exit. return; } else { @@ -15097,7 +16449,7 @@ function onSuspend( msUntilTimeout ) { root.expirationTime = rootExpirationTime; - if (msUntilTimeout === 0 && !shouldYield()) { + if (msUntilTimeout === 0 && !shouldYieldToRenderer()) { // Don't wait an additional tick. Commit the tree immediately. root.pendingCommitExpirationTime = suspendedExpirationTime; root.finishedWork = finishedWork; @@ -15192,7 +16544,7 @@ function requestWork(root, expirationTime) { // flush it now. nextFlushedRoot = root; nextFlushedExpirationTime = Sync; - performWorkOnRoot(root, Sync, true); + performWorkOnRoot(root, Sync, false); } return; } @@ -15222,10 +16574,7 @@ function addRootToSchedule(root, expirationTime) { } else { // This root is already scheduled, but its priority may have increased. var remainingExpirationTime = root.expirationTime; - if ( - remainingExpirationTime === NoWork || - expirationTime < remainingExpirationTime - ) { + if (expirationTime > remainingExpirationTime) { // Update the priority. root.expirationTime = expirationTime; } @@ -15274,10 +16623,7 @@ function findHighestPriorityRoot() { } root = previousScheduledRoot.nextScheduledRoot; } else { - if ( - highestPriorityWork === NoWork || - remainingExpirationTime < highestPriorityWork - ) { + if (remainingExpirationTime > highestPriorityWork) { // Update the priority, if it's higher highestPriorityWork = remainingExpirationTime; highestPriorityRoot = root; @@ -15300,43 +16646,60 @@ function findHighestPriorityRoot() { nextFlushedExpirationTime = highestPriorityWork; } -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); - } +// TODO: This wrapper exists because many of the older tests (the ones that use +// flushDeferredPri) rely on the number of times `shouldYield` is called. We +// should get rid of it. +var didYield = false; +function shouldYieldToRenderer() { + if (didYield) { + return true; + } + if (shouldYield()) { + didYield = true; + return true; + } + return false; +} + +function performAsyncWork() { + try { + if (!shouldYieldToRenderer()) { + // 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, true); + } finally { + didYield = false; } - performWork(NoWork, dl); } function performSyncWork() { - performWork(Sync, null); + performWork(Sync, false); } -function performWork(minExpirationTime, dl) { - deadline = dl; - - // Keep working on roots until there's no more work, or until we reach - // the deadline. +function performWork(minExpirationTime, isYieldy) { + // Keep working on roots until there's no more work, or until there's a higher + // priority event. findHighestPriorityRoot(); - if (deadline !== null) { + if (isYieldy) { recomputeCurrentRendererTime(); currentSchedulerTime = currentRendererTime; if (enableUserTimingAPI) { - var didExpire = nextFlushedExpirationTime < currentRendererTime; + var didExpire = nextFlushedExpirationTime > currentRendererTime; var timeout = expirationTimeToMs(nextFlushedExpirationTime); stopRequestCallbackTimer(didExpire, timeout); } @@ -15344,14 +16707,13 @@ function performWork(minExpirationTime, dl) { while ( nextFlushedRoot !== null && nextFlushedExpirationTime !== NoWork && - (minExpirationTime === NoWork || - minExpirationTime >= nextFlushedExpirationTime) && - (!deadlineDidExpire || currentRendererTime >= nextFlushedExpirationTime) + minExpirationTime <= nextFlushedExpirationTime && + !(didYield && currentRendererTime > nextFlushedExpirationTime) ) { performWorkOnRoot( nextFlushedRoot, nextFlushedExpirationTime, - currentRendererTime >= nextFlushedExpirationTime + currentRendererTime > nextFlushedExpirationTime ); findHighestPriorityRoot(); recomputeCurrentRendererTime(); @@ -15361,10 +16723,9 @@ function performWork(minExpirationTime, dl) { while ( nextFlushedRoot !== null && nextFlushedExpirationTime !== NoWork && - (minExpirationTime === NoWork || - minExpirationTime >= nextFlushedExpirationTime) + minExpirationTime <= nextFlushedExpirationTime ) { - performWorkOnRoot(nextFlushedRoot, nextFlushedExpirationTime, true); + performWorkOnRoot(nextFlushedRoot, nextFlushedExpirationTime, false); findHighestPriorityRoot(); } } @@ -15373,7 +16734,7 @@ function performWork(minExpirationTime, dl) { // or there's no more work left with sufficient priority. // If we're inside a callback, set this to false since we just completed it. - if (deadline !== null) { + if (isYieldy) { callbackExpirationTime = NoWork; callbackID = null; } @@ -15386,9 +16747,6 @@ function performWork(minExpirationTime, dl) { } // Clean-up. - deadline = null; - deadlineDidExpire = false; - finishRendering(); } @@ -15403,7 +16761,7 @@ function flushRoot(root, expirationTime) { // including the given time. nextFlushedRoot = root; nextFlushedExpirationTime = expirationTime; - performWorkOnRoot(root, expirationTime, true); + performWorkOnRoot(root, expirationTime, false); // Flush any sync work that was scheduled by lifecycles performSyncWork(); } @@ -15436,7 +16794,7 @@ function finishRendering() { } } -function performWorkOnRoot(root, expirationTime, isExpired) { +function performWorkOnRoot(root, expirationTime, isYieldy) { invariant( !isRendering, "performWorkOnRoot was called recursively. This error is likely caused " + @@ -15446,7 +16804,7 @@ function performWorkOnRoot(root, expirationTime, isExpired) { isRendering = true; // Check if this is async work or sync/expired work. - if (deadline === null || isExpired) { + if (!isYieldy) { // Flush work without yielding. // TODO: Non-yieldy work does not necessarily imply expired work. A renderer // may want to perform some work without yielding, but also without @@ -15466,8 +16824,7 @@ function performWorkOnRoot(root, expirationTime, isExpired) { // $FlowFixMe Complains noTimeout is not a TimeoutID, despite the check above cancelTimeout(timeoutHandle); } - var isYieldy = false; - renderRoot(root, isYieldy, isExpired); + renderRoot(root, isYieldy); finishedWork = root.finishedWork; if (finishedWork !== null) { // We've completed the root. Commit it. @@ -15490,13 +16847,12 @@ function performWorkOnRoot(root, expirationTime, isExpired) { // $FlowFixMe Complains noTimeout is not a TimeoutID, despite the check above cancelTimeout(_timeoutHandle); } - var _isYieldy = true; - renderRoot(root, _isYieldy, isExpired); + renderRoot(root, isYieldy); _finishedWork = root.finishedWork; if (_finishedWork !== null) { - // We've completed the root. Check the deadline one more time + // We've completed the root. Check the if we should yield one more time // before committing. - if (!shouldYield()) { + if (!shouldYieldToRenderer()) { // Still time left. Commit the root. completeRoot(root, _finishedWork, expirationTime); } else { @@ -15514,7 +16870,7 @@ function performWorkOnRoot(root, expirationTime, isExpired) { function completeRoot(root, finishedWork, expirationTime) { // Check if there's a batch that matches this expiration time. var firstBatch = root.firstBatch; - if (firstBatch !== null && firstBatch._expirationTime <= expirationTime) { + if (firstBatch !== null && firstBatch._expirationTime >= expirationTime) { if (completedBatches === null) { completedBatches = [firstBatch]; } else { @@ -15546,24 +16902,6 @@ function completeRoot(root, finishedWork, expirationTime) { commitRoot(root, finishedWork); } -// When working on async work, the reconciler asks the renderer if it should -// yield execution. For DOM, we implement this with requestIdleCallback. -function shouldYield() { - if (deadlineDidExpire) { - return true; - } - if ( - deadline === null || - deadline.timeRemaining() > timeHeuristicForUnitOfWork - ) { - // Disregard deadline.didTimeout. Only expired work should be flushed - // during a timeout. This path is only hit for non-expired work. - return false; - } - deadlineDidExpire = true; - return true; -} - function onUncaughtError(error) { invariant( nextFlushedRoot !== null, @@ -15608,7 +16946,7 @@ function interactiveUpdates$1(fn, a, b) { lowestPriorityPendingInteractiveExpirationTime !== NoWork ) { // Synchronously flush pending interactive updates. - performWork(lowestPriorityPendingInteractiveExpirationTime, null); + performWork(lowestPriorityPendingInteractiveExpirationTime, false); lowestPriorityPendingInteractiveExpirationTime = NoWork; } var previousIsBatchingInteractiveUpdates = isBatchingInteractiveUpdates; @@ -15632,7 +16970,7 @@ function flushInteractiveUpdates$1() { lowestPriorityPendingInteractiveExpirationTime !== NoWork ) { // Synchronously flush pending interactive updates. - performWork(lowestPriorityPendingInteractiveExpirationTime, null); + performWork(lowestPriorityPendingInteractiveExpirationTime, false); lowestPriorityPendingInteractiveExpirationTime = NoWork; } } @@ -15661,11 +16999,6 @@ function getContextForSubtree(parentComponent) { 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; @@ -15703,9 +17036,11 @@ function scheduleRootUpdate(current$$1, element, expirationTime, callback) { : void 0; update.callback = callback; } - enqueueUpdate(current$$1, update); + flushPassiveEffects(); + enqueueUpdate(current$$1, update); scheduleWork(current$$1, expirationTime); + return expirationTime; } @@ -15896,7 +17231,7 @@ function createPortal( // TODO: this is special because it gets imported during build. -var ReactVersion = "16.6.0-alpha.8af6728"; +var ReactVersion = "16.6.0"; // Modules provided by RN: var NativeMethodsMixin = function(findNodeHandle, findHostInstance) { @@ -16292,9 +17627,9 @@ var ReactNativeComponent = function(findNodeHandle, findHostInstance) { }; // Module provided by RN: -var emptyObject$2 = {}; +var emptyObject$1 = {}; { - Object.freeze(emptyObject$2); + Object.freeze(emptyObject$1); } var getInspectorDataForViewTag = void 0; @@ -16327,9 +17662,9 @@ var getInspectorDataForViewTag = void 0; var getHostProps = function(fiber) { var host = findCurrentHostFiber(fiber); if (host) { - return host.memoizedProps || emptyObject$2; + return host.memoizedProps || emptyObject$1; } - return emptyObject$2; + return emptyObject$1; }; var getHostNode = function(fiber, findNodeHandle) { @@ -16375,7 +17710,7 @@ var getInspectorDataForViewTag = void 0; if (!closestInstance) { return { hierarchy: [], - props: emptyObject$2, + props: emptyObject$1, selection: null, source: null }; diff --git a/Libraries/Renderer/oss/ReactNativeRenderer-prod.js b/Libraries/Renderer/oss/ReactNativeRenderer-prod.js index 3fcf10330..d62282e85 100644 --- a/Libraries/Renderer/oss/ReactNativeRenderer-prod.js +++ b/Libraries/Renderer/oss/ReactNativeRenderer-prod.js @@ -19,7 +19,8 @@ var ReactNativeViewConfigRegistry = require("ReactNativeViewConfigRegistry"), deepDiffer = require("deepDiffer"), flattenStyle = require("flattenStyle"), TextInputState = require("TextInputState"); -var ExceptionsManager = require("ExceptionsManager"); +var scheduler = require("scheduler"), + ExceptionsManager = require("ExceptionsManager"); function invariant(condition, format, a, b, c, d, e, f) { if (!condition) { condition = void 0; @@ -293,7 +294,7 @@ function getListener(inst, registrationName) { } function getParent(inst) { do inst = inst.return; - while (inst && 7 !== inst.tag); + while (inst && 5 !== inst.tag); return inst ? inst : null; } function traverseTwoPhase(inst, fn, arg) { @@ -1147,7 +1148,8 @@ var ReactSharedInternals = : 60111, REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for("react.forward_ref") : 60112, REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for("react.suspense") : 60113, - REACT_PURE_TYPE = hasSymbol ? Symbol.for("react.pure") : 60115, + REACT_MEMO_TYPE = hasSymbol ? Symbol.for("react.memo") : 60115, + REACT_LAZY_TYPE = hasSymbol ? Symbol.for("react.lazy") : 60116, MAYBE_ITERATOR_SYMBOL = "function" === typeof Symbol && Symbol.iterator; function getIteratorFn(maybeIterable) { if (null === maybeIterable || "object" !== typeof maybeIterable) return null; @@ -1156,13 +1158,6 @@ function getIteratorFn(maybeIterable) { maybeIterable["@@iterator"]; return "function" === typeof maybeIterable ? maybeIterable : null; } -function getWrappedName(outerType, innerType, wrapperName) { - innerType = innerType.displayName || innerType.name || ""; - return ( - outerType.displayName || - ("" !== innerType ? wrapperName + "(" + innerType + ")" : wrapperName) - ); -} function getComponentName(type) { if (null == type) return null; if ("function" === typeof type) return type.displayName || type.name || null; @@ -1181,23 +1176,25 @@ function getComponentName(type) { case REACT_SUSPENSE_TYPE: return "Suspense"; } - if ("object" === typeof type) { + if ("object" === typeof type) switch (type.$$typeof) { case REACT_CONTEXT_TYPE: return "Context.Consumer"; case REACT_PROVIDER_TYPE: return "Context.Provider"; case REACT_FORWARD_REF_TYPE: - return getWrappedName(type, type.render, "ForwardRef"); - case REACT_PURE_TYPE: - return getWrappedName(type, type.render, "Pure"); + var innerType = type.render; + innerType = innerType.displayName || innerType.name || ""; + return ( + type.displayName || + ("" !== innerType ? "ForwardRef(" + innerType + ")" : "ForwardRef") + ); + case REACT_MEMO_TYPE: + return getComponentName(type.type); + case REACT_LAZY_TYPE: + if ((type = 1 === type._status ? type._result : null)) + return getComponentName(type); } - if ( - "function" === typeof type.then && - (type = 1 === type._reactStatus ? type._reactResult : null) - ) - return getComponentName(type); - } return null; } function isFiberMountedImpl(fiber) { @@ -1208,7 +1205,7 @@ function isFiberMountedImpl(fiber) { for (; node.return; ) if (((node = node.return), 0 !== (node.effectTag & 2))) return 1; } - return 5 === node.tag ? 2 : 3; + return 3 === node.tag ? 2 : 3; } function assertIsMounted(fiber) { invariant( @@ -1284,14 +1281,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(5 === a.tag, "Unable to find node on an unmounted component."); + invariant(3 === 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 (7 === node.tag || 8 === node.tag) return node; + if (5 === node.tag || 6 === node.tag) return node; if (node.child) (node.child.return = node), (node = node.child); else { if (node === parent) break; @@ -1599,18 +1596,12 @@ var ReactNativeFiberHostComponent = (function() { return Date.now(); }, scheduledCallback = null, - frameDeadline = 0, - frameDeadlineObject = { - timeRemaining: function() { - return frameDeadline - now$1(); - }, - didTimeout: !1 - }; + frameDeadline = 0; function setTimeoutCallback() { frameDeadline = now$1() + 5; var callback = scheduledCallback; scheduledCallback = null; - null !== callback && callback(frameDeadlineObject); + null !== callback && callback(); } function shim$1() { invariant( @@ -1651,13 +1642,13 @@ function getStackByFiberInDevAndProd(workInProgress) { var info = ""; do { a: switch (workInProgress.tag) { - case 4: + case 2: + case 16: case 0: case 1: - case 2: - case 3: - case 7: - case 10: + case 5: + case 8: + case 13: var owner = workInProgress._debugOwner, source = workInProgress._debugSource, name = getComponentName(workInProgress.type); @@ -1808,7 +1799,7 @@ function injectInternals(internals) { function FiberNode(tag, pendingProps, key, mode) { this.tag = tag; this.key = key; - this.sibling = this.child = this.return = this.stateNode = this.type = null; + this.sibling = this.child = this.return = this.stateNode = this.type = this.elementType = null; this.index = 0; this.ref = null; this.pendingProps = pendingProps; @@ -1819,29 +1810,33 @@ function FiberNode(tag, pendingProps, key, mode) { this.childExpirationTime = this.expirationTime = 0; this.alternate = null; } +function createFiber(tag, pendingProps, key, mode) { + return new FiberNode(tag, pendingProps, key, mode); +} function shouldConstruct(Component) { Component = Component.prototype; return !(!Component || !Component.isReactComponent); } -function resolveLazyComponentTag(fiber, Component) { +function resolveLazyComponentTag(Component) { if ("function" === typeof Component) - return shouldConstruct(Component) ? 3 : 1; + return shouldConstruct(Component) ? 1 : 0; if (void 0 !== Component && null !== Component) { - fiber = Component.$$typeof; - if (fiber === REACT_FORWARD_REF_TYPE) return 14; - if (fiber === REACT_PURE_TYPE) return 18; + Component = Component.$$typeof; + if (Component === REACT_FORWARD_REF_TYPE) return 11; + if (Component === REACT_MEMO_TYPE) return 14; } - return 4; + return 2; } function createWorkInProgress(current, pendingProps) { var workInProgress = current.alternate; null === workInProgress - ? ((workInProgress = new FiberNode( + ? ((workInProgress = createFiber( current.tag, pendingProps, current.key, current.mode )), + (workInProgress.elementType = current.elementType), (workInProgress.type = current.type), (workInProgress.stateNode = current.stateNode), (workInProgress.alternate = current), @@ -1863,60 +1858,66 @@ function createWorkInProgress(current, pendingProps) { workInProgress.ref = current.ref; return workInProgress; } -function createFiberFromElement(element, mode, expirationTime) { - var type = element.type, - key = element.key; - element = element.props; - var fiberTag = void 0; - if ("function" === typeof type) fiberTag = shouldConstruct(type) ? 2 : 4; - else if ("string" === typeof type) fiberTag = 7; +function createFiberFromTypeAndProps( + type, + key, + pendingProps, + owner, + mode, + expirationTime +) { + var fiberTag = 2; + owner = type; + if ("function" === typeof type) shouldConstruct(type) && (fiberTag = 1); + else if ("string" === typeof type) fiberTag = 5; else a: switch (type) { case REACT_FRAGMENT_TYPE: return createFiberFromFragment( - element.children, + pendingProps.children, mode, expirationTime, key ); case REACT_CONCURRENT_MODE_TYPE: - fiberTag = 10; - mode |= 3; - break; + return createFiberFromMode(pendingProps, mode | 3, expirationTime, key); case REACT_STRICT_MODE_TYPE: - fiberTag = 10; - mode |= 2; - break; + return createFiberFromMode(pendingProps, mode | 2, expirationTime, key); case REACT_PROFILER_TYPE: return ( - (type = new FiberNode(15, element, key, mode | 4)), + (type = createFiber(12, pendingProps, key, mode | 4)), + (type.elementType = REACT_PROFILER_TYPE), (type.type = REACT_PROFILER_TYPE), (type.expirationTime = expirationTime), type ); case REACT_SUSPENSE_TYPE: - fiberTag = 16; - break; + return ( + (type = createFiber(13, pendingProps, key, mode)), + (type.elementType = REACT_SUSPENSE_TYPE), + (type.type = REACT_SUSPENSE_TYPE), + (type.expirationTime = expirationTime), + type + ); default: if ("object" === typeof type && null !== type) switch (type.$$typeof) { case REACT_PROVIDER_TYPE: - fiberTag = 12; + fiberTag = 10; break a; case REACT_CONTEXT_TYPE: - fiberTag = 11; + fiberTag = 9; break a; case REACT_FORWARD_REF_TYPE: - fiberTag = 13; + fiberTag = 11; break a; - case REACT_PURE_TYPE: - fiberTag = 17; + case REACT_MEMO_TYPE: + fiberTag = 14; + break a; + case REACT_LAZY_TYPE: + fiberTag = 16; + owner = null; break a; - default: - if ("function" === typeof type.then) { - fiberTag = 4; - break a; - } } invariant( !1, @@ -1925,24 +1926,33 @@ function createFiberFromElement(element, mode, expirationTime) { "" ); } - mode = new FiberNode(fiberTag, element, key, mode); - mode.type = type; - mode.expirationTime = expirationTime; - return mode; + key = createFiber(fiberTag, pendingProps, key, mode); + key.elementType = type; + key.type = owner; + key.expirationTime = expirationTime; + return key; } function createFiberFromFragment(elements, mode, expirationTime, key) { - elements = new FiberNode(9, elements, key, mode); + elements = createFiber(7, elements, key, mode); elements.expirationTime = expirationTime; return elements; } +function createFiberFromMode(pendingProps, mode, expirationTime, key) { + pendingProps = createFiber(8, pendingProps, key, mode); + mode = 0 === (mode & 1) ? REACT_STRICT_MODE_TYPE : REACT_CONCURRENT_MODE_TYPE; + pendingProps.elementType = mode; + pendingProps.type = mode; + pendingProps.expirationTime = expirationTime; + return pendingProps; +} function createFiberFromText(content, mode, expirationTime) { - content = new FiberNode(8, content, null, mode); + content = createFiber(6, content, null, mode); content.expirationTime = expirationTime; return content; } function createFiberFromPortal(portal, mode, expirationTime) { - mode = new FiberNode( - 6, + mode = createFiber( + 4, null !== portal.children ? portal.children : [], portal.key, mode @@ -1960,9 +1970,9 @@ function markPendingPriorityLevel(root, expirationTime) { var earliestPendingTime = root.earliestPendingTime; 0 === earliestPendingTime ? (root.earliestPendingTime = root.latestPendingTime = expirationTime) - : earliestPendingTime > expirationTime + : earliestPendingTime < expirationTime ? (root.earliestPendingTime = expirationTime) - : root.latestPendingTime < expirationTime && + : root.latestPendingTime > expirationTime && (root.latestPendingTime = expirationTime); findNextExpirationTimeToWorkOn(expirationTime, root); } @@ -1970,7 +1980,7 @@ function markSuspendedPriorityLevel(root, suspendedTime) { root.didError = !1; var latestPingedTime = root.latestPingedTime; 0 !== latestPingedTime && - latestPingedTime <= suspendedTime && + latestPingedTime >= suspendedTime && (root.latestPingedTime = 0); latestPingedTime = root.earliestPendingTime; var latestPendingTime = root.latestPendingTime; @@ -1985,22 +1995,18 @@ function markSuspendedPriorityLevel(root, suspendedTime) { latestPendingTime = root.latestSuspendedTime; 0 === latestPingedTime ? (root.earliestSuspendedTime = root.latestSuspendedTime = suspendedTime) - : latestPingedTime > suspendedTime + : latestPingedTime < suspendedTime ? (root.earliestSuspendedTime = suspendedTime) - : latestPendingTime < suspendedTime && + : latestPendingTime > suspendedTime && (root.latestSuspendedTime = suspendedTime); findNextExpirationTimeToWorkOn(suspendedTime, root); } function findEarliestOutstandingPriorityLevel(root, renderExpirationTime) { var earliestPendingTime = root.earliestPendingTime; root = root.earliestSuspendedTime; - if ( - 0 === renderExpirationTime || - (0 !== earliestPendingTime && earliestPendingTime < renderExpirationTime) - ) - renderExpirationTime = earliestPendingTime; - if (0 === renderExpirationTime || (0 !== root && root < renderExpirationTime)) - renderExpirationTime = root; + earliestPendingTime > renderExpirationTime && + (renderExpirationTime = earliestPendingTime); + root > renderExpirationTime && (renderExpirationTime = root); return renderExpirationTime; } function findNextExpirationTimeToWorkOn(completedExpirationTime, root) { @@ -2012,12 +2018,11 @@ function findNextExpirationTimeToWorkOn(completedExpirationTime, root) { 0 !== earliestPendingTime ? earliestPendingTime : latestPingedTime; 0 === earliestPendingTime && (0 === completedExpirationTime || - latestSuspendedTime > completedExpirationTime) && + latestSuspendedTime < completedExpirationTime) && (earliestPendingTime = latestSuspendedTime); completedExpirationTime = earliestPendingTime; 0 !== completedExpirationTime && - 0 !== earliestSuspendedTime && - earliestSuspendedTime < completedExpirationTime && + earliestSuspendedTime > completedExpirationTime && (completedExpirationTime = earliestSuspendedTime); root.nextExpirationTimeToWorkOn = earliestPendingTime; root.expirationTime = completedExpirationTime; @@ -2129,7 +2134,7 @@ function getStateFromUpdate( : workInProgress ); case 3: - workInProgress.effectTag = (workInProgress.effectTag & -1025) | 64; + workInProgress.effectTag = (workInProgress.effectTag & -2049) | 64; case 0: workInProgress = update.payload; nextProps = @@ -2162,58 +2167,52 @@ function processUpdateQueue( ) { var updateExpirationTime = update.expirationTime; - if (updateExpirationTime > renderExpirationTime) { - if ( - (null === newFirstUpdate && + updateExpirationTime < renderExpirationTime + ? (null === newFirstUpdate && ((newFirstUpdate = update), (newBaseState = resultState)), - 0 === newExpirationTime || newExpirationTime > updateExpirationTime) - ) - newExpirationTime = updateExpirationTime; - } else - (resultState = getStateFromUpdate( - workInProgress, - queue, - update, - resultState, - props, - instance - )), + newExpirationTime < updateExpirationTime && + (newExpirationTime = updateExpirationTime)) + : ((resultState = getStateFromUpdate( + workInProgress, + queue, + update, + resultState, + props, + instance + )), null !== update.callback && ((workInProgress.effectTag |= 32), (update.nextEffect = null), null === queue.lastEffect ? (queue.firstEffect = queue.lastEffect = update) : ((queue.lastEffect.nextEffect = update), - (queue.lastEffect = update))); + (queue.lastEffect = update)))); update = update.next; } updateExpirationTime = null; for (update = queue.firstCapturedUpdate; null !== update; ) { var _updateExpirationTime = update.expirationTime; - if (_updateExpirationTime > renderExpirationTime) { - if ( - (null === updateExpirationTime && + _updateExpirationTime < renderExpirationTime + ? (null === updateExpirationTime && ((updateExpirationTime = update), null === newFirstUpdate && (newBaseState = resultState)), - 0 === newExpirationTime || newExpirationTime > _updateExpirationTime) - ) - newExpirationTime = _updateExpirationTime; - } else - (resultState = getStateFromUpdate( - workInProgress, - queue, - update, - resultState, - props, - instance - )), + newExpirationTime < _updateExpirationTime && + (newExpirationTime = _updateExpirationTime)) + : ((resultState = getStateFromUpdate( + workInProgress, + queue, + update, + resultState, + props, + instance + )), null !== update.callback && ((workInProgress.effectTag |= 32), (update.nextEffect = null), null === queue.lastCapturedEffect ? (queue.firstCapturedEffect = queue.lastCapturedEffect = update) : ((queue.lastCapturedEffect.nextEffect = update), - (queue.lastCapturedEffect = update))); + (queue.lastCapturedEffect = update)))); update = update.next; } null === newFirstUpdate && (queue.lastUpdate = null); @@ -2294,13 +2293,277 @@ function readContext(context, observedBits) { null === lastContextDependency ? (invariant( null !== currentlyRenderingFiber, - "Context.unstable_read(): Context can only be read while React is rendering, e.g. inside the render method or getDerivedStateFromProps." + "Context can only be read while React is rendering, e.g. inside the render method or getDerivedStateFromProps." ), (currentlyRenderingFiber.firstContextDependency = lastContextDependency = observedBits)) : (lastContextDependency = lastContextDependency.next = observedBits); } return context._currentValue; } +var renderExpirationTime = 0, + currentlyRenderingFiber$1 = null, + firstCurrentHook = null, + currentHook = null, + firstWorkInProgressHook = null, + workInProgressHook = null, + remainingExpirationTime = 0, + componentUpdateQueue = null, + isReRender = !1, + didScheduleRenderPhaseUpdate = !1, + renderPhaseUpdates = null, + numberOfReRenders = 0; +function resolveCurrentlyRenderingFiber() { + invariant( + null !== currentlyRenderingFiber$1, + "Hooks can only be called inside the body of a function component." + ); + return currentlyRenderingFiber$1; +} +function finishHooks(Component, props, children, refOrContext) { + for (; didScheduleRenderPhaseUpdate; ) + (didScheduleRenderPhaseUpdate = !1), + (numberOfReRenders += 1), + (componentUpdateQueue = workInProgressHook = currentHook = null), + (children = Component(props, refOrContext)); + renderPhaseUpdates = null; + numberOfReRenders = 0; + Component = currentlyRenderingFiber$1; + Component.memoizedState = firstWorkInProgressHook; + Component.expirationTime = remainingExpirationTime; + Component.updateQueue = componentUpdateQueue; + Component = null !== currentHook && null !== currentHook.next; + renderExpirationTime = 0; + workInProgressHook = firstWorkInProgressHook = currentHook = firstCurrentHook = currentlyRenderingFiber$1 = null; + remainingExpirationTime = 0; + componentUpdateQueue = null; + invariant( + !Component, + "Rendered fewer hooks than expected. This may be caused by an accidental early return statement." + ); + return children; +} +function resetHooks() { + renderExpirationTime = 0; + workInProgressHook = firstWorkInProgressHook = currentHook = firstCurrentHook = currentlyRenderingFiber$1 = null; + remainingExpirationTime = 0; + componentUpdateQueue = null; + didScheduleRenderPhaseUpdate = !1; + renderPhaseUpdates = null; + numberOfReRenders = 0; +} +function createHook() { + return { + memoizedState: null, + baseState: null, + queue: null, + baseUpdate: null, + next: null + }; +} +function cloneHook(hook) { + return { + memoizedState: hook.memoizedState, + baseState: hook.memoizedState, + queue: hook.queue, + baseUpdate: hook.baseUpdate, + next: null + }; +} +function createWorkInProgressHook() { + if (null === workInProgressHook) + null === firstWorkInProgressHook + ? ((isReRender = !1), + (currentHook = firstCurrentHook), + (firstWorkInProgressHook = workInProgressHook = + null === currentHook ? createHook() : cloneHook(currentHook))) + : ((isReRender = !0), + (currentHook = firstCurrentHook), + (workInProgressHook = firstWorkInProgressHook)); + else if (null === workInProgressHook.next) { + isReRender = !1; + if (null === currentHook) var hook = createHook(); + else + (currentHook = currentHook.next), + (hook = null === currentHook ? createHook() : cloneHook(currentHook)); + workInProgressHook = workInProgressHook.next = hook; + } else + (isReRender = !0), + (workInProgressHook = workInProgressHook.next), + (currentHook = null !== currentHook ? currentHook.next : null); + return workInProgressHook; +} +function basicStateReducer(state, action) { + return "function" === typeof action ? action(state) : action; +} +function useReducer(reducer, initialState, initialAction) { + currentlyRenderingFiber$1 = resolveCurrentlyRenderingFiber(); + workInProgressHook = createWorkInProgressHook(); + var queue = workInProgressHook.queue; + if (null !== queue) { + if (isReRender) { + initialState = queue.dispatch; + if (null !== renderPhaseUpdates) { + var firstRenderPhaseUpdate = renderPhaseUpdates.get(queue); + if (void 0 !== firstRenderPhaseUpdate) { + renderPhaseUpdates.delete(queue); + initialAction = workInProgressHook.memoizedState; + do + (initialAction = reducer( + initialAction, + firstRenderPhaseUpdate.action + )), + (firstRenderPhaseUpdate = firstRenderPhaseUpdate.next); + while (null !== firstRenderPhaseUpdate); + workInProgressHook.memoizedState = initialAction; + workInProgressHook.baseUpdate === queue.last && + (workInProgressHook.baseState = initialAction); + return [initialAction, initialState]; + } + } + return [workInProgressHook.memoizedState, initialState]; + } + initialState = queue.last; + var _baseUpdate = workInProgressHook.baseUpdate; + null !== _baseUpdate + ? (null !== initialState && (initialState.next = null), + (initialState = _baseUpdate.next)) + : (initialState = null !== initialState ? initialState.next : null); + if (null !== initialState) { + initialAction = workInProgressHook.baseState; + var newBaseUpdate = (firstRenderPhaseUpdate = null), + _update = initialState, + didSkip = !1; + do { + var updateExpirationTime = _update.expirationTime; + updateExpirationTime < renderExpirationTime + ? (didSkip || + ((didSkip = !0), + (newBaseUpdate = _baseUpdate), + (firstRenderPhaseUpdate = initialAction)), + updateExpirationTime > remainingExpirationTime && + (remainingExpirationTime = updateExpirationTime)) + : (initialAction = reducer(initialAction, _update.action)); + _baseUpdate = _update; + _update = _update.next; + } while (null !== _update && _update !== initialState); + didSkip || + ((newBaseUpdate = _baseUpdate), + (firstRenderPhaseUpdate = initialAction)); + workInProgressHook.memoizedState = initialAction; + workInProgressHook.baseUpdate = newBaseUpdate; + workInProgressHook.baseState = firstRenderPhaseUpdate; + } + return [workInProgressHook.memoizedState, queue.dispatch]; + } + reducer === basicStateReducer + ? "function" === typeof initialState && (initialState = initialState()) + : void 0 !== initialAction && + null !== initialAction && + (initialState = reducer(initialState, initialAction)); + workInProgressHook.memoizedState = workInProgressHook.baseState = initialState; + queue = workInProgressHook.queue = { last: null, dispatch: null }; + reducer = queue.dispatch = dispatchAction.bind( + null, + currentlyRenderingFiber$1, + queue + ); + return [workInProgressHook.memoizedState, reducer]; +} +function pushEffect(tag, create, destroy, inputs) { + tag = { + tag: tag, + create: create, + destroy: destroy, + inputs: inputs, + next: null + }; + null === componentUpdateQueue + ? ((componentUpdateQueue = { lastEffect: null }), + (componentUpdateQueue.lastEffect = tag.next = tag)) + : ((create = componentUpdateQueue.lastEffect), + null === create + ? (componentUpdateQueue.lastEffect = tag.next = tag) + : ((destroy = create.next), + (create.next = tag), + (tag.next = destroy), + (componentUpdateQueue.lastEffect = tag))); + return tag; +} +function useEffectImpl(fiberEffectTag, hookEffectTag, create, inputs) { + currentlyRenderingFiber$1 = resolveCurrentlyRenderingFiber(); + workInProgressHook = createWorkInProgressHook(); + inputs = void 0 !== inputs && null !== inputs ? inputs : [create]; + var destroy = null; + if (null !== currentHook) { + var prevEffect = currentHook.memoizedState; + destroy = prevEffect.destroy; + if (inputsAreEqual(inputs, prevEffect.inputs)) { + pushEffect(0, create, destroy, inputs); + return; + } + } + currentlyRenderingFiber$1.effectTag |= fiberEffectTag; + workInProgressHook.memoizedState = pushEffect( + hookEffectTag, + create, + destroy, + inputs + ); +} +function dispatchAction(fiber, queue, action) { + invariant( + 25 > numberOfReRenders, + "Too many re-renders. React limits the number of renders to prevent an infinite loop." + ); + var alternate = fiber.alternate; + if ( + fiber === currentlyRenderingFiber$1 || + (null !== alternate && alternate === currentlyRenderingFiber$1) + ) + if ( + ((didScheduleRenderPhaseUpdate = !0), + (fiber = { + expirationTime: renderExpirationTime, + action: action, + next: null + }), + null === renderPhaseUpdates && (renderPhaseUpdates = new Map()), + (alternate = renderPhaseUpdates.get(queue)), + void 0 === alternate) + ) + renderPhaseUpdates.set(queue, fiber); + else { + for (queue = alternate; null !== queue.next; ) queue = queue.next; + queue.next = fiber; + } + else { + alternate = requestCurrentTime(); + alternate = computeExpirationForFiber(alternate, fiber); + action = { expirationTime: alternate, action: action, next: null }; + flushPassiveEffects(); + var _last2 = queue.last; + if (null === _last2) action.next = action; + else { + var first = _last2.next; + null !== first && (action.next = first); + _last2.next = action; + } + queue.last = action; + scheduleWork(fiber, alternate); + } +} +function inputsAreEqual(arr1, arr2) { + for (var i = 0; i < arr1.length; i++) { + var val1 = arr1[i], + val2 = arr2[i]; + if ( + (val1 !== val2 || (0 === val1 && 1 / val1 !== 1 / val2)) && + (val1 === val1 || val2 === val2) + ) + return !1; + } + return !0; +} var NO_CONTEXT = {}, contextStackCursor$1 = { current: NO_CONTEXT }, contextFiberStackCursor = { current: NO_CONTEXT }, @@ -2370,7 +2633,8 @@ function shallowEqual(objA, objB) { return !1; return !0; } -var emptyRefsObject = new React.Component().refs; +var ReactCurrentOwner$4 = ReactSharedInternals.ReactCurrentOwner, + emptyRefsObject = new React.Component().refs; function applyDerivedStateFromProps( workInProgress, ctor, @@ -2402,6 +2666,7 @@ var classComponentUpdater = { var update = createUpdate(currentTime); update.payload = payload; void 0 !== callback && null !== callback && (update.callback = callback); + flushPassiveEffects(); enqueueUpdate(inst, update); scheduleWork(inst, currentTime); }, @@ -2413,6 +2678,7 @@ var classComponentUpdater = { update.tag = 1; update.payload = payload; void 0 !== callback && null !== callback && (update.callback = callback); + flushPassiveEffects(); enqueueUpdate(inst, update); scheduleWork(inst, currentTime); }, @@ -2423,6 +2689,7 @@ var classComponentUpdater = { var update = createUpdate(currentTime); update.tag = 2; void 0 !== callback && null !== callback && (update.callback = callback); + flushPassiveEffects(); enqueueUpdate(inst, update); scheduleWork(inst, currentTime); } @@ -2443,6 +2710,32 @@ function checkShouldComponentUpdate( ? !shallowEqual(oldProps, newProps) || !shallowEqual(oldState, newState) : !0; } +function constructClassInstance(workInProgress, ctor, props) { + var isLegacyContextConsumer = !1, + unmaskedContext = emptyContextObject; + var context = ctor.contextType; + "object" === typeof context && null !== context + ? (context = ReactCurrentOwner$4.currentDispatcher.readContext(context)) + : ((unmaskedContext = isContextProvider(ctor) + ? previousContext + : contextStackCursor.current), + (isLegacyContextConsumer = ctor.contextTypes), + (context = (isLegacyContextConsumer = + null !== isLegacyContextConsumer && void 0 !== isLegacyContextConsumer) + ? getMaskedContext(workInProgress, unmaskedContext) + : emptyContextObject)); + ctor = new ctor(props, context); + workInProgress.memoizedState = + null !== ctor.state && void 0 !== ctor.state ? ctor.state : null; + ctor.updater = classComponentUpdater; + workInProgress.stateNode = ctor; + ctor._reactInternalFiber = workInProgress; + isLegacyContextConsumer && + ((workInProgress = workInProgress.stateNode), + (workInProgress.__reactInternalMemoizedUnmaskedChildContext = unmaskedContext), + (workInProgress.__reactInternalMemoizedMaskedChildContext = context)); + return ctor; +} function callComponentWillReceiveProps( workInProgress, instance, @@ -2469,7 +2762,9 @@ function mountClassInstance( instance.refs = emptyRefsObject; var contextType = ctor.contextType; "object" === typeof contextType && null !== contextType - ? (instance.context = contextType.unstable_read()) + ? (instance.context = ReactCurrentOwner$4.currentDispatcher.readContext( + contextType + )) : ((contextType = isContextProvider(ctor) ? previousContext : contextStackCursor.current), @@ -2524,10 +2819,7 @@ function coerceRef(returnFiber, current$$1, element) { element = element._owner; var inst = void 0; element && - (invariant( - 2 === element.tag || 3 === element.tag, - "Function components cannot have refs." - ), + (invariant(1 === element.tag, "Function components cannot have refs."), (inst = element.stateNode)); invariant( inst, @@ -2632,7 +2924,7 @@ function ChildReconciler(shouldTrackSideEffects) { textContent, expirationTime ) { - if (null === current$$1 || 8 !== current$$1.tag) + if (null === current$$1 || 6 !== current$$1.tag) return ( (current$$1 = createFiberFromText( textContent, @@ -2647,15 +2939,18 @@ function ChildReconciler(shouldTrackSideEffects) { return current$$1; } function updateElement(returnFiber, current$$1, element, expirationTime) { - if (null !== current$$1 && current$$1.type === element.type) + if (null !== current$$1 && current$$1.elementType === element.type) return ( (expirationTime = useFiber(current$$1, element.props, expirationTime)), (expirationTime.ref = coerceRef(returnFiber, current$$1, element)), (expirationTime.return = returnFiber), expirationTime ); - expirationTime = createFiberFromElement( - element, + expirationTime = createFiberFromTypeAndProps( + element.type, + element.key, + element.props, + null, returnFiber.mode, expirationTime ); @@ -2666,7 +2961,7 @@ function ChildReconciler(shouldTrackSideEffects) { function updatePortal(returnFiber, current$$1, portal, expirationTime) { if ( null === current$$1 || - 6 !== current$$1.tag || + 4 !== current$$1.tag || current$$1.stateNode.containerInfo !== portal.containerInfo || current$$1.stateNode.implementation !== portal.implementation ) @@ -2690,7 +2985,7 @@ function ChildReconciler(shouldTrackSideEffects) { expirationTime, key ) { - if (null === current$$1 || 9 !== current$$1.tag) + if (null === current$$1 || 7 !== current$$1.tag) return ( (current$$1 = createFiberFromFragment( fragment, @@ -2720,8 +3015,11 @@ function ChildReconciler(shouldTrackSideEffects) { switch (newChild.$$typeof) { case REACT_ELEMENT_TYPE: return ( - (expirationTime = createFiberFromElement( - newChild, + (expirationTime = createFiberFromTypeAndProps( + newChild.type, + newChild.key, + newChild.props, + null, returnFiber.mode, expirationTime )), @@ -3065,9 +3363,9 @@ function ChildReconciler(shouldTrackSideEffects) { ) { if (isUnkeyedTopLevelFragment.key === isObject) if ( - 9 === isUnkeyedTopLevelFragment.tag + 7 === isUnkeyedTopLevelFragment.tag ? newChild.type === REACT_FRAGMENT_TYPE - : isUnkeyedTopLevelFragment.type === newChild.type + : isUnkeyedTopLevelFragment.elementType === newChild.type ) { deleteRemainingChildren( returnFiber, @@ -3107,8 +3405,11 @@ function ChildReconciler(shouldTrackSideEffects) { )), (currentFirstChild.return = returnFiber), (returnFiber = currentFirstChild)) - : ((expirationTime = createFiberFromElement( - newChild, + : ((expirationTime = createFiberFromTypeAndProps( + newChild.type, + newChild.key, + newChild.props, + null, returnFiber.mode, expirationTime )), @@ -3130,7 +3431,7 @@ function ChildReconciler(shouldTrackSideEffects) { ) { if (currentFirstChild.key === isUnkeyedTopLevelFragment) if ( - 6 === currentFirstChild.tag && + 4 === currentFirstChild.tag && currentFirstChild.stateNode.containerInfo === newChild.containerInfo && currentFirstChild.stateNode.implementation === @@ -3168,7 +3469,7 @@ function ChildReconciler(shouldTrackSideEffects) { if ("string" === typeof newChild || "number" === typeof newChild) return ( (newChild = "" + newChild), - null !== currentFirstChild && 8 === currentFirstChild.tag + null !== currentFirstChild && 6 === currentFirstChild.tag ? (deleteRemainingChildren(returnFiber, currentFirstChild.sibling), (currentFirstChild = useFiber( currentFirstChild, @@ -3204,8 +3505,7 @@ function ChildReconciler(shouldTrackSideEffects) { isObject && throwOnInvalidObjectType(returnFiber, newChild); if ("undefined" === typeof newChild && !isUnkeyedTopLevelFragment) switch (returnFiber.tag) { - case 2: - case 3: + case 1: case 0: (expirationTime = returnFiber.type), invariant( @@ -3224,12 +3524,12 @@ var reconcileChildFibers = ChildReconciler(!0), isHydrating = !1; function tryHydrate(fiber, nextInstance) { switch (fiber.tag) { - case 7: + case 5: return ( (nextInstance = shim$1(nextInstance, fiber.type, fiber.pendingProps)), null !== nextInstance ? ((fiber.stateNode = nextInstance), !0) : !1 ); - case 8: + case 6: return ( (nextInstance = shim$1(nextInstance, fiber.pendingProps)), null !== nextInstance ? ((fiber.stateNode = nextInstance), !0) : !1 @@ -3252,7 +3552,8 @@ function tryToClaimNextHydratableInstance(fiber$jscomp$0) { return; } var returnFiber = hydrationParentFiber, - fiber = new FiberNode(7, null, null, 0); + fiber = createFiber(5, null, null, 0); + fiber.elementType = "DELETED"; fiber.type = "DELETED"; fiber.stateNode = firstAttemptedInstance; fiber.return = returnFiber; @@ -3270,36 +3571,33 @@ function tryToClaimNextHydratableInstance(fiber$jscomp$0) { (hydrationParentFiber = fiber$jscomp$0); } } -function readLazyComponentType(thenable) { - switch (thenable._reactStatus) { +function readLazyComponentType(lazyComponent) { + var result = lazyComponent._result; + switch (lazyComponent._status) { case 1: - return thenable._reactResult; + return result; case 2: - throw thenable._reactResult; + throw result; case 0: - throw thenable; + throw result; 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; - } + throw ((lazyComponent._status = 0), + (result = lazyComponent._ctor), + (result = result()), + result.then( + function(moduleObject) { + 0 === lazyComponent._status && + ((moduleObject = moduleObject.default), + (lazyComponent._status = 1), + (lazyComponent._result = moduleObject)); }, function(error) { - 0 === thenable._reactStatus && - ((thenable._reactStatus = 2), (thenable._reactResult = error)); + 0 === lazyComponent._status && + ((lazyComponent._status = 2), (lazyComponent._result = error)); } ), - thenable); + (lazyComponent._result = result), + result); } } var ReactCurrentOwner$3 = ReactSharedInternals.ReactCurrentOwner; @@ -3327,28 +3625,28 @@ function reconcileChildren( function updateForwardRef( current$$1, workInProgress, - type, + Component, nextProps, - renderExpirationTime + renderExpirationTime$jscomp$0 ) { - type = type.render; + Component = Component.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; + prepareToReadContext(workInProgress, renderExpirationTime$jscomp$0); + renderExpirationTime = renderExpirationTime$jscomp$0; + currentlyRenderingFiber$1 = workInProgress; + firstCurrentHook = null !== current$$1 ? current$$1.memoizedState : null; + var nextChildren = Component(nextProps, ref); + nextChildren = finishHooks(Component, nextProps, nextChildren, ref); + workInProgress.effectTag |= 1; + reconcileChildren( + current$$1, + workInProgress, + nextChildren, + renderExpirationTime$jscomp$0 + ); return workInProgress.child; } -function updatePureComponent( +function updateMemoComponent( current$$1, workInProgress, Component, @@ -3356,29 +3654,81 @@ function updatePureComponent( updateExpirationTime, renderExpirationTime ) { - var render = Component.render, - ref = workInProgress.ref; + if (null === current$$1) { + var type = Component.type; + if ( + "function" === typeof type && + !shouldConstruct(type) && + void 0 === type.defaultProps && + null === Component.compare + ) + return ( + (workInProgress.tag = 15), + (workInProgress.type = type), + updateSimpleMemoComponent( + current$$1, + workInProgress, + type, + nextProps, + updateExpirationTime, + renderExpirationTime + ) + ); + current$$1 = createFiberFromTypeAndProps( + Component.type, + null, + nextProps, + null, + workInProgress.mode, + renderExpirationTime + ); + current$$1.ref = workInProgress.ref; + current$$1.return = workInProgress; + return (workInProgress.child = current$$1); + } + type = current$$1.child; if ( - null !== current$$1 && - (0 === updateExpirationTime || - updateExpirationTime > renderExpirationTime) && - ((updateExpirationTime = current$$1.memoizedProps), + updateExpirationTime < renderExpirationTime && + ((updateExpirationTime = type.memoizedProps), (Component = Component.compare), (Component = null !== Component ? Component : shallowEqual), - workInProgress.ref === current$$1.ref && - Component(updateExpirationTime, nextProps)) + Component(updateExpirationTime, nextProps) && + current$$1.ref === workInProgress.ref) ) return bailoutOnAlreadyFinishedWork( current$$1, workInProgress, renderExpirationTime ); - prepareToReadContext(workInProgress, renderExpirationTime); - render = render(nextProps, ref); - workInProgress.effectTag |= 1; - reconcileChildren(current$$1, workInProgress, render, renderExpirationTime); - workInProgress.memoizedProps = nextProps; - return workInProgress.child; + current$$1 = createWorkInProgress(type, nextProps, renderExpirationTime); + current$$1.ref = workInProgress.ref; + current$$1.return = workInProgress; + return (workInProgress.child = current$$1); +} +function updateSimpleMemoComponent( + current$$1, + workInProgress, + Component, + nextProps, + updateExpirationTime, + renderExpirationTime +) { + return null !== current$$1 && + updateExpirationTime < renderExpirationTime && + shallowEqual(current$$1.memoizedProps, nextProps) && + current$$1.ref === workInProgress.ref + ? bailoutOnAlreadyFinishedWork( + current$$1, + workInProgress, + renderExpirationTime + ) + : updateFunctionComponent( + current$$1, + workInProgress, + Component, + nextProps, + renderExpirationTime + ); } function markRef(current$$1, workInProgress) { var ref = workInProgress.ref; @@ -3393,22 +3743,30 @@ function updateFunctionComponent( workInProgress, Component, nextProps, - renderExpirationTime + renderExpirationTime$jscomp$0 ) { var unmaskedContext = isContextProvider(Component) ? previousContext : contextStackCursor.current; unmaskedContext = getMaskedContext(workInProgress, unmaskedContext); - prepareToReadContext(workInProgress, renderExpirationTime); - Component = Component(nextProps, unmaskedContext); + prepareToReadContext(workInProgress, renderExpirationTime$jscomp$0); + renderExpirationTime = renderExpirationTime$jscomp$0; + currentlyRenderingFiber$1 = workInProgress; + firstCurrentHook = null !== current$$1 ? current$$1.memoizedState : null; + var nextChildren = Component(nextProps, unmaskedContext); + nextChildren = finishHooks( + Component, + nextProps, + nextChildren, + unmaskedContext + ); workInProgress.effectTag |= 1; reconcileChildren( current$$1, workInProgress, - Component, - renderExpirationTime + nextChildren, + renderExpirationTime$jscomp$0 ); - workInProgress.memoizedProps = nextProps; return workInProgress.child; } function updateClassComponent( @@ -3423,166 +3781,149 @@ function updateClassComponent( pushContextProvider(workInProgress); } else hasContext = !1; prepareToReadContext(workInProgress, renderExpirationTime); - if (null === current$$1) - if (null === workInProgress.stateNode) { - var isLegacyContextConsumer = !1, - unmaskedContext = emptyContextObject; - var context = Component.contextType; - "object" === typeof context && null !== context - ? (context = context.unstable_read()) - : ((unmaskedContext = isContextProvider(Component) - ? previousContext - : contextStackCursor.current), - (isLegacyContextConsumer = Component.contextTypes), - (context = (isLegacyContextConsumer = - null !== isLegacyContextConsumer && - void 0 !== isLegacyContextConsumer) - ? getMaskedContext(workInProgress, unmaskedContext) - : emptyContextObject)); - var instance = new Component(nextProps, context); - workInProgress.memoizedState = - null !== instance.state && void 0 !== instance.state - ? instance.state - : null; - instance.updater = classComponentUpdater; - workInProgress.stateNode = instance; - instance._reactInternalFiber = workInProgress; - isLegacyContextConsumer && - ((isLegacyContextConsumer = workInProgress.stateNode), - (isLegacyContextConsumer.__reactInternalMemoizedUnmaskedChildContext = unmaskedContext), - (isLegacyContextConsumer.__reactInternalMemoizedMaskedChildContext = context)); + if (null === workInProgress.stateNode) + null !== current$$1 && + ((current$$1.alternate = null), + (workInProgress.alternate = null), + (workInProgress.effectTag |= 2)), + constructClassInstance( + workInProgress, + Component, + nextProps, + renderExpirationTime + ), mountClassInstance( workInProgress, Component, nextProps, renderExpirationTime - ); - nextProps = !0; - } else { - unmaskedContext = workInProgress.stateNode; - isLegacyContextConsumer = workInProgress.memoizedProps; - unmaskedContext.props = isLegacyContextConsumer; - var oldContext = unmaskedContext.context; - context = Component.contextType; - "object" === typeof context && null !== context - ? (context = context.unstable_read()) - : ((context = isContextProvider(Component) - ? previousContext - : contextStackCursor.current), - (context = getMaskedContext(workInProgress, context))); - var getDerivedStateFromProps = Component.getDerivedStateFromProps; - (instance = + ), + (nextProps = !0); + else if (null === current$$1) { + var instance = workInProgress.stateNode, + oldProps = workInProgress.memoizedProps; + instance.props = oldProps; + var oldContext = instance.context, + contextType = Component.contextType; + "object" === typeof contextType && null !== contextType + ? (contextType = ReactCurrentOwner$4.currentDispatcher.readContext( + contextType + )) + : ((contextType = isContextProvider(Component) + ? previousContext + : contextStackCursor.current), + (contextType = getMaskedContext(workInProgress, contextType))); + var getDerivedStateFromProps = Component.getDerivedStateFromProps, + hasNewLifecycles = "function" === typeof getDerivedStateFromProps || - "function" === typeof unmaskedContext.getSnapshotBeforeUpdate) || - ("function" !== - typeof unmaskedContext.UNSAFE_componentWillReceiveProps && - "function" !== typeof unmaskedContext.componentWillReceiveProps) || - ((isLegacyContextConsumer !== nextProps || oldContext !== context) && - callComponentWillReceiveProps( - workInProgress, - unmaskedContext, - nextProps, - context - )); - hasForceUpdate = !1; - var oldState = workInProgress.memoizedState; - oldContext = unmaskedContext.state = oldState; - var updateQueue = workInProgress.updateQueue; - null !== updateQueue && - (processUpdateQueue( + "function" === typeof instance.getSnapshotBeforeUpdate; + hasNewLifecycles || + ("function" !== typeof instance.UNSAFE_componentWillReceiveProps && + "function" !== typeof instance.componentWillReceiveProps) || + ((oldProps !== nextProps || oldContext !== contextType) && + callComponentWillReceiveProps( workInProgress, - updateQueue, + instance, nextProps, - unmaskedContext, - renderExpirationTime - ), - (oldContext = workInProgress.memoizedState)); - isLegacyContextConsumer !== nextProps || - oldState !== oldContext || - didPerformWorkStackCursor.current || - hasForceUpdate - ? ("function" === typeof getDerivedStateFromProps && - (applyDerivedStateFromProps( - workInProgress, - Component, - getDerivedStateFromProps, - nextProps - ), - (oldContext = workInProgress.memoizedState)), - (isLegacyContextConsumer = - hasForceUpdate || - checkShouldComponentUpdate( - workInProgress, - Component, - isLegacyContextConsumer, - nextProps, - oldState, - oldContext, - context - )) - ? (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 = context), - (nextProps = isLegacyContextConsumer)) - : ("function" === typeof unmaskedContext.componentDidMount && - (workInProgress.effectTag |= 4), - (nextProps = !1)); - } - else - (unmaskedContext = workInProgress.stateNode), - (isLegacyContextConsumer = workInProgress.memoizedProps), - (unmaskedContext.props = isLegacyContextConsumer), - (oldContext = unmaskedContext.context), - (context = Component.contextType), - "object" === typeof context && null !== context - ? (context = context.unstable_read()) - : ((context = isContextProvider(Component) + contextType + )); + hasForceUpdate = !1; + var oldState = workInProgress.memoizedState; + oldContext = instance.state = oldState; + var updateQueue = workInProgress.updateQueue; + null !== updateQueue && + (processUpdateQueue( + workInProgress, + updateQueue, + nextProps, + instance, + renderExpirationTime + ), + (oldContext = workInProgress.memoizedState)); + oldProps !== nextProps || + oldState !== oldContext || + didPerformWorkStackCursor.current || + hasForceUpdate + ? ("function" === typeof getDerivedStateFromProps && + (applyDerivedStateFromProps( + workInProgress, + Component, + getDerivedStateFromProps, + nextProps + ), + (oldContext = workInProgress.memoizedState)), + (oldProps = + hasForceUpdate || + checkShouldComponentUpdate( + workInProgress, + Component, + oldProps, + nextProps, + oldState, + oldContext, + contextType + )) + ? (hasNewLifecycles || + ("function" !== typeof instance.UNSAFE_componentWillMount && + "function" !== typeof instance.componentWillMount) || + ("function" === typeof instance.componentWillMount && + instance.componentWillMount(), + "function" === typeof instance.UNSAFE_componentWillMount && + instance.UNSAFE_componentWillMount()), + "function" === typeof instance.componentDidMount && + (workInProgress.effectTag |= 4)) + : ("function" === typeof instance.componentDidMount && + (workInProgress.effectTag |= 4), + (workInProgress.memoizedProps = nextProps), + (workInProgress.memoizedState = oldContext)), + (instance.props = nextProps), + (instance.state = oldContext), + (instance.context = contextType), + (nextProps = oldProps)) + : ("function" === typeof instance.componentDidMount && + (workInProgress.effectTag |= 4), + (nextProps = !1)); + } else + (instance = workInProgress.stateNode), + (oldProps = workInProgress.memoizedProps), + (instance.props = oldProps), + (oldContext = instance.context), + (contextType = Component.contextType), + "object" === typeof contextType && null !== contextType + ? (contextType = ReactCurrentOwner$4.currentDispatcher.readContext( + contextType + )) + : ((contextType = isContextProvider(Component) ? previousContext : contextStackCursor.current), - (context = getMaskedContext(workInProgress, context))), + (contextType = getMaskedContext(workInProgress, contextType))), (getDerivedStateFromProps = Component.getDerivedStateFromProps), - (instance = + (hasNewLifecycles = "function" === typeof getDerivedStateFromProps || - "function" === typeof unmaskedContext.getSnapshotBeforeUpdate) || - ("function" !== - typeof unmaskedContext.UNSAFE_componentWillReceiveProps && - "function" !== typeof unmaskedContext.componentWillReceiveProps) || - ((isLegacyContextConsumer !== nextProps || oldContext !== context) && + "function" === typeof instance.getSnapshotBeforeUpdate) || + ("function" !== typeof instance.UNSAFE_componentWillReceiveProps && + "function" !== typeof instance.componentWillReceiveProps) || + ((oldProps !== nextProps || oldContext !== contextType) && callComponentWillReceiveProps( workInProgress, - unmaskedContext, + instance, nextProps, - context + contextType )), (hasForceUpdate = !1), (oldContext = workInProgress.memoizedState), - (oldState = unmaskedContext.state = oldContext), + (oldState = instance.state = oldContext), (updateQueue = workInProgress.updateQueue), null !== updateQueue && (processUpdateQueue( workInProgress, updateQueue, nextProps, - unmaskedContext, + instance, renderExpirationTime ), (oldState = workInProgress.memoizedState)), - isLegacyContextConsumer !== nextProps || + oldProps !== nextProps || oldContext !== oldState || didPerformWorkStackCursor.current || hasForceUpdate @@ -3599,53 +3940,51 @@ function updateClassComponent( checkShouldComponentUpdate( workInProgress, Component, - isLegacyContextConsumer, + oldProps, nextProps, oldContext, oldState, - context + contextType )) - ? (instance || - ("function" !== - typeof unmaskedContext.UNSAFE_componentWillUpdate && - "function" !== typeof unmaskedContext.componentWillUpdate) || - ("function" === typeof unmaskedContext.componentWillUpdate && - unmaskedContext.componentWillUpdate( + ? (hasNewLifecycles || + ("function" !== typeof instance.UNSAFE_componentWillUpdate && + "function" !== typeof instance.componentWillUpdate) || + ("function" === typeof instance.componentWillUpdate && + instance.componentWillUpdate( nextProps, oldState, - context + contextType ), - "function" === - typeof unmaskedContext.UNSAFE_componentWillUpdate && - unmaskedContext.UNSAFE_componentWillUpdate( + "function" === typeof instance.UNSAFE_componentWillUpdate && + instance.UNSAFE_componentWillUpdate( nextProps, oldState, - context + contextType )), - "function" === typeof unmaskedContext.componentDidUpdate && + "function" === typeof instance.componentDidUpdate && (workInProgress.effectTag |= 4), - "function" === typeof unmaskedContext.getSnapshotBeforeUpdate && + "function" === typeof instance.getSnapshotBeforeUpdate && (workInProgress.effectTag |= 256)) - : ("function" !== typeof unmaskedContext.componentDidUpdate || - (isLegacyContextConsumer === current$$1.memoizedProps && + : ("function" !== typeof instance.componentDidUpdate || + (oldProps === current$$1.memoizedProps && oldContext === current$$1.memoizedState) || (workInProgress.effectTag |= 4), - "function" !== typeof unmaskedContext.getSnapshotBeforeUpdate || - (isLegacyContextConsumer === current$$1.memoizedProps && + "function" !== typeof instance.getSnapshotBeforeUpdate || + (oldProps === current$$1.memoizedProps && oldContext === current$$1.memoizedState) || (workInProgress.effectTag |= 256), (workInProgress.memoizedProps = nextProps), (workInProgress.memoizedState = oldState)), - (unmaskedContext.props = nextProps), - (unmaskedContext.state = oldState), - (unmaskedContext.context = context), + (instance.props = nextProps), + (instance.state = oldState), + (instance.context = contextType), (nextProps = getDerivedStateFromProps)) - : ("function" !== typeof unmaskedContext.componentDidUpdate || - (isLegacyContextConsumer === current$$1.memoizedProps && + : ("function" !== typeof instance.componentDidUpdate || + (oldProps === current$$1.memoizedProps && oldContext === current$$1.memoizedState) || (workInProgress.effectTag |= 4), - "function" !== typeof unmaskedContext.getSnapshotBeforeUpdate || - (isLegacyContextConsumer === current$$1.memoizedProps && + "function" !== typeof instance.getSnapshotBeforeUpdate || + (oldProps === current$$1.memoizedProps && oldContext === current$$1.memoizedState) || (workInProgress.effectTag |= 256), (nextProps = !1)); @@ -3704,7 +4043,6 @@ function finishClassComponent( renderExpirationTime ); workInProgress.memoizedState = shouldUpdate.state; - workInProgress.memoizedProps = shouldUpdate.props; hasContext && invalidateContextProvider(workInProgress, Component, !0); return workInProgress.child; } @@ -3730,6 +4068,105 @@ function resolveDefaultProps(Component, baseProps) { } return baseProps; } +function updateSuspenseComponent( + current$$1, + workInProgress, + renderExpirationTime +) { + var mode = workInProgress.mode, + nextProps = workInProgress.pendingProps, + nextState = workInProgress.memoizedState; + null !== nextState && + (nextState.alreadyCaptured + ? null !== current$$1 && nextState === current$$1.memoizedState + ? (nextState = { + alreadyCaptured: !0, + didTimeout: !0, + timedOutAt: nextState.timedOutAt + }) + : ((nextState.alreadyCaptured = !0), (nextState.didTimeout = !0)) + : (nextState = null)); + var nextDidTimeout = null !== nextState && nextState.didTimeout; + if (null === current$$1) + nextDidTimeout + ? ((nextDidTimeout = nextProps.fallback), + (nextProps = createFiberFromFragment(null, mode, 0, null)), + (mode = createFiberFromFragment( + nextDidTimeout, + mode, + renderExpirationTime, + null + )), + (nextProps.sibling = mode), + (renderExpirationTime = nextProps), + (renderExpirationTime.return = mode.return = workInProgress)) + : (renderExpirationTime = mode = mountChildFibers( + workInProgress, + null, + nextProps.children, + renderExpirationTime + )); + else { + var prevState = current$$1.memoizedState; + null !== prevState && prevState.didTimeout + ? ((mode = current$$1.child), + (current$$1 = mode.sibling), + nextDidTimeout + ? ((renderExpirationTime = nextProps.fallback), + (mode = createWorkInProgress(mode, mode.pendingProps, 0)), + (mode.effectTag |= 2), + (nextProps = mode.sibling = createWorkInProgress( + current$$1, + renderExpirationTime, + current$$1.expirationTime + )), + (nextProps.effectTag |= 2), + (renderExpirationTime = mode), + (mode.childExpirationTime = 0), + (mode = nextProps), + (renderExpirationTime.return = mode.return = workInProgress)) + : ((nextDidTimeout = current$$1.child), + (mode = reconcileChildFibers( + workInProgress, + mode.child, + nextProps.children, + renderExpirationTime + )), + reconcileChildFibers( + workInProgress, + nextDidTimeout, + null, + renderExpirationTime + ), + (renderExpirationTime = mode))) + : ((current$$1 = current$$1.child), + nextDidTimeout + ? ((nextDidTimeout = nextProps.fallback), + (nextProps = createFiberFromFragment(null, mode, 0, null)), + (nextProps.effectTag |= 2), + (nextProps.child = current$$1), + (current$$1.return = nextProps), + (mode = nextProps.sibling = createFiberFromFragment( + nextDidTimeout, + mode, + renderExpirationTime, + null + )), + (mode.effectTag |= 2), + (renderExpirationTime = nextProps), + (nextProps.childExpirationTime = 0), + (renderExpirationTime.return = mode.return = workInProgress)) + : (mode = renderExpirationTime = reconcileChildFibers( + workInProgress, + current$$1, + nextProps.children, + renderExpirationTime + ))); + } + workInProgress.memoizedState = nextState; + workInProgress.child = renderExpirationTime; + return mode; +} function bailoutOnAlreadyFinishedWork( current$$1, workInProgress, @@ -3737,9 +4174,7 @@ function bailoutOnAlreadyFinishedWork( ) { null !== current$$1 && (workInProgress.firstContextDependency = current$$1.firstContextDependency); - var childExpirationTime = workInProgress.childExpirationTime; - if (0 === childExpirationTime || childExpirationTime > renderExpirationTime) - return null; + if (workInProgress.childExpirationTime < renderExpirationTime) return null; invariant( null === current$$1 || workInProgress.child === current$$1.child, "Resuming work not yet implemented." @@ -3768,557 +4203,562 @@ function bailoutOnAlreadyFinishedWork( } return workInProgress.child; } -function beginWork(current$$1, workInProgress, renderExpirationTime) { +function beginWork(current$$1, workInProgress, renderExpirationTime$jscomp$0) { var updateExpirationTime = workInProgress.expirationTime; if ( null !== current$$1 && current$$1.memoizedProps === workInProgress.pendingProps && !didPerformWorkStackCursor.current && - (0 === updateExpirationTime || updateExpirationTime > renderExpirationTime) + updateExpirationTime < renderExpirationTime$jscomp$0 ) { switch (workInProgress.tag) { - case 5: + case 3: pushHostRootContext(workInProgress); break; - case 7: + case 5: pushHostContext(workInProgress); break; - case 2: + case 1: isContextProvider(workInProgress.type) && pushContextProvider(workInProgress); break; - case 3: - isContextProvider(workInProgress.type._reactResult) && - pushContextProvider(workInProgress); - break; - case 6: + case 4: pushHostContainer( workInProgress, workInProgress.stateNode.containerInfo ); break; - case 12: + case 10: pushProvider(workInProgress, workInProgress.memoizedProps.value); + break; + case 13: + if ( + ((updateExpirationTime = workInProgress.memoizedState), + null !== updateExpirationTime && updateExpirationTime.didTimeout) + ) { + updateExpirationTime = workInProgress.child.childExpirationTime; + if ( + 0 !== updateExpirationTime && + updateExpirationTime >= renderExpirationTime$jscomp$0 + ) + return updateSuspenseComponent( + current$$1, + workInProgress, + renderExpirationTime$jscomp$0 + ); + workInProgress = bailoutOnAlreadyFinishedWork( + current$$1, + workInProgress, + renderExpirationTime$jscomp$0 + ); + return null !== workInProgress ? workInProgress.sibling : null; + } } return bailoutOnAlreadyFinishedWork( current$$1, workInProgress, - renderExpirationTime + renderExpirationTime$jscomp$0 ); } workInProgress.expirationTime = 0; switch (workInProgress.tag) { - case 4: - var Component = workInProgress.type; - 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 resolvedTag = (workInProgress.tag = resolveLazyComponentTag( - workInProgress, - Component - )), - resolvedProps = resolveDefaultProps(Component, props), - child = void 0; - switch (resolvedTag) { - case 1: - child = updateFunctionComponent( - current$$1, - workInProgress, - Component, - resolvedProps, - renderExpirationTime - ); - break; - case 3: - child = updateClassComponent( - current$$1, - workInProgress, - Component, - resolvedProps, - renderExpirationTime - ); - break; - case 14: - child = updateForwardRef( - current$$1, - workInProgress, - Component, - resolvedProps, - renderExpirationTime - ); - break; - case 18: - child = updatePureComponent( - current$$1, - workInProgress, - Component, - resolvedProps, - updateExpirationTime, - renderExpirationTime - ); - break; - default: - invariant( - !1, - "Element type is invalid. Received a promise that resolves to: %s. Promise elements must resolve to a class or function.", - Component - ); - } - workInProgress.memoizedProps = props; - workInProgress = child; - } else - (updateExpirationTime = getMaskedContext( - workInProgress, - contextStackCursor.current - )), - prepareToReadContext(workInProgress, renderExpirationTime), - (updateExpirationTime = Component(props, updateExpirationTime)), - (workInProgress.effectTag |= 1), - "object" === typeof updateExpirationTime && - null !== updateExpirationTime && - "function" === typeof updateExpirationTime.render && - void 0 === updateExpirationTime.$$typeof - ? ((workInProgress.tag = 2), - isContextProvider(Component) - ? ((resolvedTag = !0), pushContextProvider(workInProgress)) - : (resolvedTag = !1), - (workInProgress.memoizedState = - null !== updateExpirationTime.state && - void 0 !== updateExpirationTime.state - ? updateExpirationTime.state - : null), - (resolvedProps = Component.getDerivedStateFromProps), - "function" === typeof resolvedProps && - applyDerivedStateFromProps( - workInProgress, - Component, - resolvedProps, - props - ), - (updateExpirationTime.updater = classComponentUpdater), - (workInProgress.stateNode = updateExpirationTime), - (updateExpirationTime._reactInternalFiber = workInProgress), - mountClassInstance( - workInProgress, - Component, - props, - renderExpirationTime - ), - (workInProgress = finishClassComponent( - current$$1, - workInProgress, - Component, - !0, - resolvedTag, - renderExpirationTime - ))) - : ((workInProgress.tag = 0), - reconcileChildren( - current$$1, - workInProgress, - updateExpirationTime, - renderExpirationTime - ), - (workInProgress.memoizedProps = props), - (workInProgress = workInProgress.child)); - return workInProgress; - case 0: - return updateFunctionComponent( - current$$1, + case 2: + updateExpirationTime = workInProgress.elementType; + null !== current$$1 && + ((current$$1.alternate = null), + (workInProgress.alternate = null), + (workInProgress.effectTag |= 2)); + current$$1 = workInProgress.pendingProps; + var context = getMaskedContext( workInProgress, - workInProgress.type, - workInProgress.pendingProps, - renderExpirationTime + contextStackCursor.current + ); + prepareToReadContext(workInProgress, renderExpirationTime$jscomp$0); + renderExpirationTime = renderExpirationTime$jscomp$0; + currentlyRenderingFiber$1 = workInProgress; + firstCurrentHook = null; + var value = updateExpirationTime(current$$1, context); + workInProgress.effectTag |= 1; + if ( + "object" === typeof value && + null !== value && + "function" === typeof value.render && + void 0 === value.$$typeof + ) { + workInProgress.tag = 1; + resetHooks(); + isContextProvider(updateExpirationTime) + ? ((context = !0), pushContextProvider(workInProgress)) + : (context = !1); + workInProgress.memoizedState = + null !== value.state && void 0 !== value.state ? value.state : null; + var getDerivedStateFromProps = + updateExpirationTime.getDerivedStateFromProps; + "function" === typeof getDerivedStateFromProps && + applyDerivedStateFromProps( + workInProgress, + updateExpirationTime, + getDerivedStateFromProps, + current$$1 + ); + value.updater = classComponentUpdater; + workInProgress.stateNode = value; + value._reactInternalFiber = workInProgress; + mountClassInstance( + workInProgress, + updateExpirationTime, + current$$1, + renderExpirationTime$jscomp$0 + ); + workInProgress = finishClassComponent( + null, + workInProgress, + updateExpirationTime, + !0, + context, + renderExpirationTime$jscomp$0 + ); + } else + (workInProgress.tag = 0), + (value = finishHooks( + updateExpirationTime, + current$$1, + value, + context + )), + reconcileChildren( + null, + workInProgress, + value, + renderExpirationTime$jscomp$0 + ), + (workInProgress = workInProgress.child); + return workInProgress; + case 16: + value = workInProgress.elementType; + null !== current$$1 && + ((current$$1.alternate = null), + (workInProgress.alternate = null), + (workInProgress.effectTag |= 2)); + context = workInProgress.pendingProps; + current$$1 = readLazyComponentType(value); + workInProgress.type = current$$1; + value = workInProgress.tag = resolveLazyComponentTag(current$$1); + context = resolveDefaultProps(current$$1, context); + getDerivedStateFromProps = void 0; + switch (value) { + case 0: + getDerivedStateFromProps = updateFunctionComponent( + null, + workInProgress, + current$$1, + context, + renderExpirationTime$jscomp$0 + ); + break; + case 1: + getDerivedStateFromProps = updateClassComponent( + null, + workInProgress, + current$$1, + context, + renderExpirationTime$jscomp$0 + ); + break; + case 11: + getDerivedStateFromProps = updateForwardRef( + null, + workInProgress, + current$$1, + context, + renderExpirationTime$jscomp$0 + ); + break; + case 14: + getDerivedStateFromProps = updateMemoComponent( + null, + workInProgress, + current$$1, + resolveDefaultProps(current$$1.type, context), + updateExpirationTime, + renderExpirationTime$jscomp$0 + ); + break; + default: + invariant( + !1, + "Element type is invalid. Received a promise that resolves to: %s. Promise elements must resolve to a class or function.", + current$$1 + ); + } + return getDerivedStateFromProps; + case 0: + return ( + (updateExpirationTime = workInProgress.type), + (value = workInProgress.pendingProps), + (value = + workInProgress.elementType === updateExpirationTime + ? value + : resolveDefaultProps(updateExpirationTime, value)), + updateFunctionComponent( + current$$1, + workInProgress, + updateExpirationTime, + value, + renderExpirationTime$jscomp$0 + ) ); case 1: return ( - (props = workInProgress.type._reactResult), - (Component = workInProgress.pendingProps), - (current$$1 = updateFunctionComponent( + (updateExpirationTime = workInProgress.type), + (value = workInProgress.pendingProps), + (value = + workInProgress.elementType === updateExpirationTime + ? value + : resolveDefaultProps(updateExpirationTime, value)), + updateClassComponent( current$$1, workInProgress, - props, - resolveDefaultProps(props, Component), - renderExpirationTime - )), - (workInProgress.memoizedProps = Component), - current$$1 - ); - case 2: - return updateClassComponent( - current$$1, - workInProgress, - workInProgress.type, - workInProgress.pendingProps, - renderExpirationTime + updateExpirationTime, + value, + renderExpirationTime$jscomp$0 + ) ); case 3: - return ( - (props = workInProgress.type._reactResult), - (Component = workInProgress.pendingProps), - (current$$1 = updateClassComponent( - current$$1, - workInProgress, - props, - resolveDefaultProps(props, Component), - renderExpirationTime - )), - (workInProgress.memoizedProps = Component), - current$$1 - ); - case 5: return ( pushHostRootContext(workInProgress), - (Component = workInProgress.updateQueue), + (updateExpirationTime = workInProgress.updateQueue), invariant( - null !== Component, + 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." ), - (props = workInProgress.memoizedState), - (props = null !== props ? props.element : null), + (value = workInProgress.memoizedState), + (value = null !== value ? value.element : null), processUpdateQueue( workInProgress, - Component, + updateExpirationTime, workInProgress.pendingProps, null, - renderExpirationTime + renderExpirationTime$jscomp$0 ), - (Component = workInProgress.memoizedState.element), - Component === props + (updateExpirationTime = workInProgress.memoizedState.element), + updateExpirationTime === value ? (workInProgress = bailoutOnAlreadyFinishedWork( current$$1, workInProgress, - renderExpirationTime + renderExpirationTime$jscomp$0 )) : (reconcileChildren( current$$1, workInProgress, - Component, - renderExpirationTime + updateExpirationTime, + renderExpirationTime$jscomp$0 ), (workInProgress = workInProgress.child)), workInProgress ); - case 7: + case 5: return ( pushHostContext(workInProgress), null === current$$1 && tryToClaimNextHydratableInstance(workInProgress), - (Component = workInProgress.pendingProps), - (props = Component.children), + (updateExpirationTime = workInProgress.pendingProps.children), markRef(current$$1, workInProgress), reconcileChildren( current$$1, workInProgress, - props, - renderExpirationTime + updateExpirationTime, + renderExpirationTime$jscomp$0 ), - (workInProgress.memoizedProps = Component), (workInProgress = workInProgress.child), workInProgress ); - case 8: + case 6: return ( null === current$$1 && tryToClaimNextHydratableInstance(workInProgress), - (workInProgress.memoizedProps = workInProgress.pendingProps), null ); - case 16: - return ( - (Component = workInProgress.pendingProps), - (props = 0 === (workInProgress.effectTag & 64)), - null !== current$$1 && null !== workInProgress.updateQueue - ? ((workInProgress.updateQueue = null), (props = !0)) - : (props = !props), - 0 !== (workInProgress.mode & 2) && - (props - ? (workInProgress.effectTag |= 4) - : (workInProgress.stateNode = null)), - (updateExpirationTime = Component.children), - (updateExpirationTime = - "function" === typeof updateExpirationTime - ? updateExpirationTime(props) - : props - ? Component.fallback - : updateExpirationTime), - null !== current$$1 && props !== workInProgress.memoizedState - ? ((workInProgress.child = reconcileChildFibers( - workInProgress, - current$$1.child, - null, - renderExpirationTime - )), - (workInProgress.child = reconcileChildFibers( - workInProgress, - null, - updateExpirationTime, - renderExpirationTime - ))) - : reconcileChildren( - current$$1, - workInProgress, - updateExpirationTime, - renderExpirationTime - ), - (workInProgress.memoizedProps = Component), - (workInProgress.memoizedState = props), - workInProgress.child + case 13: + return updateSuspenseComponent( + current$$1, + workInProgress, + renderExpirationTime$jscomp$0 ); - case 6: + case 4: return ( pushHostContainer( workInProgress, workInProgress.stateNode.containerInfo ), - (Component = workInProgress.pendingProps), + (updateExpirationTime = workInProgress.pendingProps), null === current$$1 ? (workInProgress.child = reconcileChildFibers( workInProgress, null, - Component, - renderExpirationTime + updateExpirationTime, + renderExpirationTime$jscomp$0 )) : reconcileChildren( current$$1, workInProgress, - Component, - renderExpirationTime + updateExpirationTime, + renderExpirationTime$jscomp$0 ), - (workInProgress.memoizedProps = Component), workInProgress.child ); - case 13: - return updateForwardRef( - current$$1, - workInProgress, - workInProgress.type, - workInProgress.pendingProps, - renderExpirationTime - ); - case 14: + case 11: return ( - (props = workInProgress.type._reactResult), - (Component = workInProgress.pendingProps), - (current$$1 = updateForwardRef( + (updateExpirationTime = workInProgress.type), + (value = workInProgress.pendingProps), + (value = + workInProgress.elementType === updateExpirationTime + ? value + : resolveDefaultProps(updateExpirationTime, value)), + updateForwardRef( current$$1, workInProgress, - props, - resolveDefaultProps(props, Component), - renderExpirationTime - )), - (workInProgress.memoizedProps = Component), - current$$1 + updateExpirationTime, + value, + renderExpirationTime$jscomp$0 + ) ); - case 9: + case 7: return ( - (Component = workInProgress.pendingProps), reconcileChildren( current$$1, workInProgress, - Component, - renderExpirationTime + workInProgress.pendingProps, + renderExpirationTime$jscomp$0 ), - (workInProgress.memoizedProps = Component), workInProgress.child ); - case 10: + case 8: return ( - (Component = workInProgress.pendingProps.children), reconcileChildren( current$$1, workInProgress, - Component, - renderExpirationTime + workInProgress.pendingProps.children, + renderExpirationTime$jscomp$0 ), - (workInProgress.memoizedProps = Component), - workInProgress.child - ); - case 15: - return ( - (Component = workInProgress.pendingProps), - reconcileChildren( - current$$1, - workInProgress, - Component.children, - renderExpirationTime - ), - (workInProgress.memoizedProps = Component), workInProgress.child ); case 12: + return ( + reconcileChildren( + current$$1, + workInProgress, + workInProgress.pendingProps.children, + renderExpirationTime$jscomp$0 + ), + workInProgress.child + ); + case 10: a: { - Component = workInProgress.type._context; - props = workInProgress.pendingProps; - resolvedTag = workInProgress.memoizedProps; - updateExpirationTime = props.value; - workInProgress.memoizedProps = props; - pushProvider(workInProgress, updateExpirationTime); - if (null !== resolvedTag) - if ( - ((resolvedProps = resolvedTag.value), - (updateExpirationTime = - (resolvedProps === updateExpirationTime && - (0 !== resolvedProps || - 1 / resolvedProps === 1 / updateExpirationTime)) || - (resolvedProps !== resolvedProps && - updateExpirationTime !== updateExpirationTime) - ? 0 - : ("function" === typeof Component._calculateChangedBits - ? Component._calculateChangedBits( - resolvedProps, - updateExpirationTime - ) - : 1073741823) | 0), - 0 === updateExpirationTime) - ) { + updateExpirationTime = workInProgress.type._context; + value = workInProgress.pendingProps; + getDerivedStateFromProps = workInProgress.memoizedProps; + context = value.value; + pushProvider(workInProgress, context); + if (null !== getDerivedStateFromProps) { + var oldValue = getDerivedStateFromProps.value; + context = + (oldValue === context && + (0 !== oldValue || 1 / oldValue === 1 / context)) || + (oldValue !== oldValue && context !== context) + ? 0 + : ("function" === + typeof updateExpirationTime._calculateChangedBits + ? updateExpirationTime._calculateChangedBits( + oldValue, + context + ) + : 1073741823) | 0; + if (0 === context) { if ( - resolvedTag.children === props.children && + getDerivedStateFromProps.children === value.children && !didPerformWorkStackCursor.current ) { workInProgress = bailoutOnAlreadyFinishedWork( current$$1, workInProgress, - renderExpirationTime + renderExpirationTime$jscomp$0 ); break a; } } else for ( - resolvedTag = workInProgress.child, - null !== resolvedTag && (resolvedTag.return = workInProgress); - null !== resolvedTag; + getDerivedStateFromProps = workInProgress.child, + null !== getDerivedStateFromProps && + (getDerivedStateFromProps.return = workInProgress); + null !== getDerivedStateFromProps; ) { - resolvedProps = resolvedTag.firstContextDependency; - if (null !== resolvedProps) { + oldValue = getDerivedStateFromProps.firstContextDependency; + if (null !== oldValue) { do { if ( - resolvedProps.context === Component && - 0 !== (resolvedProps.observedBits & updateExpirationTime) + oldValue.context === updateExpirationTime && + 0 !== (oldValue.observedBits & context) ) { - if (2 === resolvedTag.tag || 3 === resolvedTag.tag) - (child = createUpdate(renderExpirationTime)), - (child.tag = 2), - enqueueUpdate(resolvedTag, child); - if ( - 0 === resolvedTag.expirationTime || - resolvedTag.expirationTime > renderExpirationTime - ) - resolvedTag.expirationTime = renderExpirationTime; - child = resolvedTag.alternate; - null !== child && - (0 === child.expirationTime || - child.expirationTime > renderExpirationTime) && - (child.expirationTime = renderExpirationTime); - for (var node = resolvedTag.return; null !== node; ) { - child = node.alternate; + if (1 === getDerivedStateFromProps.tag) { + var nextFiber = createUpdate( + renderExpirationTime$jscomp$0 + ); + nextFiber.tag = 2; + enqueueUpdate(getDerivedStateFromProps, nextFiber); + } + getDerivedStateFromProps.expirationTime < + renderExpirationTime$jscomp$0 && + (getDerivedStateFromProps.expirationTime = renderExpirationTime$jscomp$0); + nextFiber = getDerivedStateFromProps.alternate; + null !== nextFiber && + nextFiber.expirationTime < + renderExpirationTime$jscomp$0 && + (nextFiber.expirationTime = renderExpirationTime$jscomp$0); + for ( + var node = getDerivedStateFromProps.return; + null !== node; + + ) { + nextFiber = node.alternate; if ( - 0 === node.childExpirationTime || - node.childExpirationTime > renderExpirationTime + node.childExpirationTime < renderExpirationTime$jscomp$0 ) - (node.childExpirationTime = renderExpirationTime), - null !== child && - (0 === child.childExpirationTime || - child.childExpirationTime > - renderExpirationTime) && - (child.childExpirationTime = renderExpirationTime); + (node.childExpirationTime = renderExpirationTime$jscomp$0), + null !== nextFiber && + nextFiber.childExpirationTime < + renderExpirationTime$jscomp$0 && + (nextFiber.childExpirationTime = renderExpirationTime$jscomp$0); else if ( - null !== child && - (0 === child.childExpirationTime || - child.childExpirationTime > renderExpirationTime) + null !== nextFiber && + nextFiber.childExpirationTime < + renderExpirationTime$jscomp$0 ) - child.childExpirationTime = renderExpirationTime; + nextFiber.childExpirationTime = renderExpirationTime$jscomp$0; else break; node = node.return; } } - child = resolvedTag.child; - resolvedProps = resolvedProps.next; - } while (null !== resolvedProps); + nextFiber = getDerivedStateFromProps.child; + oldValue = oldValue.next; + } while (null !== oldValue); } else - child = - 12 === resolvedTag.tag - ? resolvedTag.type === workInProgress.type + nextFiber = + 10 === getDerivedStateFromProps.tag + ? getDerivedStateFromProps.type === workInProgress.type ? null - : resolvedTag.child - : resolvedTag.child; - if (null !== child) child.return = resolvedTag; + : getDerivedStateFromProps.child + : getDerivedStateFromProps.child; + if (null !== nextFiber) + nextFiber.return = getDerivedStateFromProps; else - for (child = resolvedTag; null !== child; ) { - if (child === workInProgress) { - child = null; + for ( + nextFiber = getDerivedStateFromProps; + null !== nextFiber; + + ) { + if (nextFiber === workInProgress) { + nextFiber = null; break; } - resolvedTag = child.sibling; - if (null !== resolvedTag) { - resolvedTag.return = child.return; - child = resolvedTag; + getDerivedStateFromProps = nextFiber.sibling; + if (null !== getDerivedStateFromProps) { + getDerivedStateFromProps.return = nextFiber.return; + nextFiber = getDerivedStateFromProps; break; } - child = child.return; + nextFiber = nextFiber.return; } - resolvedTag = child; + getDerivedStateFromProps = nextFiber; } + } reconcileChildren( current$$1, workInProgress, - props.children, - renderExpirationTime + value.children, + renderExpirationTime$jscomp$0 ); workInProgress = workInProgress.child; } return workInProgress; - case 11: + case 9: return ( - (updateExpirationTime = workInProgress.type), - (Component = workInProgress.pendingProps), - (props = Component.children), - prepareToReadContext(workInProgress, renderExpirationTime), - (updateExpirationTime = readContext( - updateExpirationTime, - Component.unstable_observedBits - )), - (props = props(updateExpirationTime)), + (value = workInProgress.type), + (context = workInProgress.pendingProps), + (updateExpirationTime = context.children), + prepareToReadContext(workInProgress, renderExpirationTime$jscomp$0), + (value = readContext(value, context.unstable_observedBits)), + (updateExpirationTime = updateExpirationTime(value)), (workInProgress.effectTag |= 1), reconcileChildren( current$$1, workInProgress, - props, - renderExpirationTime + updateExpirationTime, + renderExpirationTime$jscomp$0 ), - (workInProgress.memoizedProps = Component), workInProgress.child ); - case 17: - return updatePureComponent( + case 14: + return ( + (value = workInProgress.type), + (context = resolveDefaultProps( + value.type, + workInProgress.pendingProps + )), + updateMemoComponent( + current$$1, + workInProgress, + value, + context, + updateExpirationTime, + renderExpirationTime$jscomp$0 + ) + ); + case 15: + return updateSimpleMemoComponent( current$$1, workInProgress, workInProgress.type, workInProgress.pendingProps, updateExpirationTime, - renderExpirationTime + renderExpirationTime$jscomp$0 ); - case 18: + case 17: return ( - (props = workInProgress.type._reactResult), - (Component = workInProgress.pendingProps), - (current$$1 = updatePureComponent( - current$$1, + (updateExpirationTime = workInProgress.type), + (value = workInProgress.pendingProps), + (value = + workInProgress.elementType === updateExpirationTime + ? value + : resolveDefaultProps(updateExpirationTime, value)), + null !== current$$1 && + ((current$$1.alternate = null), + (workInProgress.alternate = null), + (workInProgress.effectTag |= 2)), + (workInProgress.tag = 1), + isContextProvider(updateExpirationTime) + ? ((current$$1 = !0), pushContextProvider(workInProgress)) + : (current$$1 = !1), + prepareToReadContext(workInProgress, renderExpirationTime$jscomp$0), + constructClassInstance( workInProgress, - props, - resolveDefaultProps(props, Component), updateExpirationTime, - renderExpirationTime - )), - (workInProgress.memoizedProps = Component), - current$$1 + value, + renderExpirationTime$jscomp$0 + ), + mountClassInstance( + workInProgress, + updateExpirationTime, + value, + renderExpirationTime$jscomp$0 + ), + finishClassComponent( + null, + workInProgress, + updateExpirationTime, + !0, + current$$1, + renderExpirationTime$jscomp$0 + ) ); default: invariant( @@ -4327,9 +4767,27 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { ); } } -var updateHostContainer = void 0, +var appendAllChildren = void 0, + updateHostContainer = void 0, updateHostComponent$1 = void 0, updateHostText$1 = void 0; +appendAllChildren = function(parent, workInProgress) { + for (var node = workInProgress.child; null !== node; ) { + if (5 === node.tag || 6 === node.tag) parent._children.push(node.stateNode); + else if (4 !== node.tag && null !== node.child) { + node.child.return = node; + node = node.child; + continue; + } + if (node === workInProgress) break; + for (; null === node.sibling; ) { + if (null === node.return || node.return === workInProgress) return; + node = node.return; + } + node.sibling.return = node.return; + node = node.sibling; + } +}; updateHostContainer = function() {}; updateHostComponent$1 = function(current, workInProgress, type, newProps) { current.memoizedProps !== newProps && @@ -4359,7 +4817,6 @@ function logCapturedError(capturedError) { : Error("Unspecified error at:" + componentStack); ExceptionsManager.handleException(error, !1); } -var emptyObject$1 = {}; function logError(boundary, errorInfo) { var source = errorInfo.source, stack = errorInfo.stack; @@ -4376,7 +4833,7 @@ function logError(boundary, errorInfo) { willRetry: !1 }; null !== boundary && - 2 === boundary.tag && + 1 === boundary.tag && ((errorInfo.errorBoundary = boundary.stateNode), (errorInfo.errorBoundaryName = getComponentName(boundary.type)), (errorInfo.errorBoundaryFound = !0), @@ -4400,32 +4857,74 @@ function safelyDetachRef(current$$1) { } else ref.current = null; } -function commitUnmount(current$$1) { +function commitHookEffectList(unmountTag, mountTag, finishedWork) { + finishedWork = finishedWork.updateQueue; + finishedWork = null !== finishedWork ? finishedWork.lastEffect : null; + if (null !== finishedWork) { + var effect = (finishedWork = finishedWork.next); + do { + if (0 !== (effect.tag & unmountTag)) { + var destroy = effect.destroy; + effect.destroy = null; + null !== destroy && destroy(); + } + 0 !== (effect.tag & mountTag) && + ((destroy = effect.create), + (destroy = destroy()), + (effect.destroy = "function" === typeof destroy ? destroy : null)); + effect = effect.next; + } while (effect !== finishedWork); + } +} +function commitUnmount(current$$1$jscomp$0) { "function" === typeof onCommitFiberUnmount && - onCommitFiberUnmount(current$$1); - switch (current$$1.tag) { - case 2: - case 3: - safelyDetachRef(current$$1); - var instance = current$$1.stateNode; - if ("function" === typeof instance.componentWillUnmount) + onCommitFiberUnmount(current$$1$jscomp$0); + switch (current$$1$jscomp$0.tag) { + case 0: + case 11: + case 14: + case 15: + var updateQueue = current$$1$jscomp$0.updateQueue; + if ( + null !== updateQueue && + ((updateQueue = updateQueue.lastEffect), null !== updateQueue) + ) { + var effect = (updateQueue = updateQueue.next); + do { + var destroy = effect.destroy; + if (null !== destroy) { + var current$$1 = current$$1$jscomp$0; + try { + destroy(); + } catch (error) { + captureCommitPhaseError(current$$1, error); + } + } + effect = effect.next; + } while (effect !== updateQueue); + } + break; + case 1: + safelyDetachRef(current$$1$jscomp$0); + updateQueue = current$$1$jscomp$0.stateNode; + if ("function" === typeof updateQueue.componentWillUnmount) try { - (instance.props = current$$1.memoizedProps), - (instance.state = current$$1.memoizedState), - instance.componentWillUnmount(); + (updateQueue.props = current$$1$jscomp$0.memoizedProps), + (updateQueue.state = current$$1$jscomp$0.memoizedState), + updateQueue.componentWillUnmount(); } catch (unmountError) { - captureCommitPhaseError(current$$1, unmountError); + captureCommitPhaseError(current$$1$jscomp$0, unmountError); } break; - case 7: - safelyDetachRef(current$$1); + case 5: + safelyDetachRef(current$$1$jscomp$0); break; - case 6: - unmountHostComponents(current$$1); + case 4: + unmountHostComponents(current$$1$jscomp$0); } } function isHostParent(fiber) { - return 7 === fiber.tag || 5 === fiber.tag || 6 === fiber.tag; + return 5 === fiber.tag || 3 === fiber.tag || 4 === fiber.tag; } function commitPlacement(finishedWork) { a: { @@ -4444,15 +4943,15 @@ function commitPlacement(finishedWork) { } var isContainer = (parent = void 0); switch (parentFiber.tag) { - case 7: + case 5: parent = parentFiber.stateNode; isContainer = !1; break; - case 5: + case 3: parent = parentFiber.stateNode.containerInfo; isContainer = !0; break; - case 6: + case 4: parent = parentFiber.stateNode.containerInfo; isContainer = !0; break; @@ -4474,11 +4973,11 @@ function commitPlacement(finishedWork) { parentFiber.sibling.return = parentFiber.return; for ( parentFiber = parentFiber.sibling; - 7 !== parentFiber.tag && 8 !== parentFiber.tag; + 5 !== parentFiber.tag && 6 !== parentFiber.tag; ) { if (parentFiber.effectTag & 2) continue b; - if (null === parentFiber.child || 6 === parentFiber.tag) continue b; + if (null === parentFiber.child || 4 === parentFiber.tag) continue b; else (parentFiber.child.return = parentFiber), (parentFiber = parentFiber.child); @@ -4489,7 +4988,7 @@ function commitPlacement(finishedWork) { } } for (var node = finishedWork; ; ) { - if (7 === node.tag || 8 === node.tag) + if (5 === node.tag || 6 === node.tag) if (parentFiber) if (isContainer) invariant( @@ -4558,7 +5057,7 @@ function commitPlacement(finishedWork) { [index.length - 1], [] ))); - else if (6 !== node.tag && null !== node.child) { + else if (4 !== node.tag && null !== node.child) { node.child.return = node; node = node.child; continue; @@ -4589,15 +5088,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 7: + case 5: currentParent = currentParentIsValid.stateNode; currentParentIsContainer = !1; break a; - case 5: + case 3: currentParent = currentParentIsValid.stateNode.containerInfo; currentParentIsContainer = !0; break a; - case 6: + case 4: currentParent = currentParentIsValid.stateNode.containerInfo; currentParentIsContainer = !0; break a; @@ -4606,11 +5105,11 @@ function unmountHostComponents(current$$1) { } currentParentIsValid = !0; } - if (7 === node.tag || 8 === node.tag) { + if (5 === node.tag || 6 === node.tag) { a: for (var root = node, node$jscomp$0 = root; ; ) if ( (commitUnmount(node$jscomp$0), - null !== node$jscomp$0.child && 6 !== node$jscomp$0.tag) + null !== node$jscomp$0.child && 4 !== node$jscomp$0.tag) ) (node$jscomp$0.child.return = node$jscomp$0), (node$jscomp$0 = node$jscomp$0.child); @@ -4638,7 +5137,7 @@ function unmountHostComponents(current$$1) { UIManager.manageChildren(root._nativeTag, [], [], [], [], [child]); } } else if ( - (6 === node.tag + (4 === node.tag ? ((currentParent = node.stateNode.containerInfo), (currentParentIsContainer = !0)) : commitUnmount(node), @@ -4652,7 +5151,7 @@ function unmountHostComponents(current$$1) { for (; null === node.sibling; ) { if (null === node.return || node.return === current$$1) return; node = node.return; - 6 === node.tag && (currentParentIsValid = !1); + 4 === node.tag && (currentParentIsValid = !1); } node.sibling.return = node.return; node = node.sibling; @@ -4660,10 +5159,15 @@ function unmountHostComponents(current$$1) { } function commitWork(current$$1, finishedWork) { switch (finishedWork.tag) { - case 2: - case 3: + case 0: + case 11: + case 14: + case 15: + commitHookEffectList(4, 8, finishedWork); break; - case 7: + case 1: + break; + case 5: var instance = finishedWork.stateNode; if (null != instance) { var newProps = finishedWork.memoizedProps; @@ -4687,7 +5191,7 @@ function commitWork(current$$1, finishedWork) { )); } break; - case 8: + case 6: 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." @@ -4696,11 +5200,13 @@ function commitWork(current$$1, finishedWork) { text: finishedWork.memoizedProps }); break; - case 5: + case 3: break; - case 15: + case 12: break; - case 16: + case 13: + break; + case 17: break; default: invariant( @@ -4709,9 +5215,6 @@ function commitWork(current$$1, finishedWork) { ); } } -function NoopComponent() { - return null; -} function createRootErrorUpdate(fiber, errorInfo, expirationTime) { expirationTime = createUpdate(expirationTime); expirationTime.tag = 3; @@ -4752,24 +5255,14 @@ function createClassErrorUpdate(fiber, errorInfo, expirationTime) { } function unwindWork(workInProgress) { switch (workInProgress.tag) { - case 2: + case 1: isContextProvider(workInProgress.type) && popContext(workInProgress); var effectTag = workInProgress.effectTag; - return effectTag & 1024 - ? ((workInProgress.effectTag = (effectTag & -1025) | 64), + return effectTag & 2048 + ? ((workInProgress.effectTag = (effectTag & -2049) | 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), @@ -4778,28 +5271,117 @@ function unwindWork(workInProgress) { 0 === (effectTag & 64), "The root failed to unmount after an error. This is likely a bug in React. Please file an issue." ), - (workInProgress.effectTag = (effectTag & -1025) | 64), + (workInProgress.effectTag = (effectTag & -2049) | 64), workInProgress ); - case 7: + case 5: return popHostContext(workInProgress), null; - case 16: - return ( - (effectTag = workInProgress.effectTag), - effectTag & 1024 - ? ((workInProgress.effectTag = (effectTag & -1025) | 64), - workInProgress) - : null - ); - case 6: + case 13: + effectTag = workInProgress.effectTag; + if (effectTag & 2048) { + workInProgress.effectTag = (effectTag & -2049) | 64; + effectTag = workInProgress.alternate; + effectTag = null !== effectTag ? effectTag.memoizedState : null; + var nextState = workInProgress.memoizedState; + null === nextState + ? (nextState = { alreadyCaptured: !0, didTimeout: !1, timedOutAt: 0 }) + : effectTag === nextState + ? (nextState = { + alreadyCaptured: !0, + didTimeout: nextState.didTimeout, + timedOutAt: nextState.timedOutAt + }) + : (nextState.alreadyCaptured = !0); + workInProgress.memoizedState = nextState; + return workInProgress; + } + return null; + case 4: return popHostContainer(workInProgress), null; - case 12: + case 10: return popProvider(workInProgress), null; default: return null; } } -var Dispatcher = { readContext: readContext }, +var Dispatcher = { + readContext: readContext, + useCallback: function(callback, inputs) { + currentlyRenderingFiber$1 = resolveCurrentlyRenderingFiber(); + workInProgressHook = createWorkInProgressHook(); + inputs = void 0 !== inputs && null !== inputs ? inputs : [callback]; + var prevState = workInProgressHook.memoizedState; + if (null !== prevState && inputsAreEqual(inputs, prevState[1])) + return prevState[0]; + workInProgressHook.memoizedState = [callback, inputs]; + return callback; + }, + useContext: function(context, observedBits) { + resolveCurrentlyRenderingFiber(); + return readContext(context, observedBits); + }, + useEffect: function(create, inputs) { + useEffectImpl(516, 192, create, inputs); + }, + useImperativeMethods: function(ref, create, inputs) { + inputs = + null !== inputs && void 0 !== inputs + ? inputs.concat([ref]) + : [ref, create]; + useEffectImpl( + 4, + 36, + function() { + if ("function" === typeof ref) { + var _inst = create(); + ref(_inst); + return function() { + return ref(null); + }; + } + if (null !== ref && void 0 !== ref) + return ( + (_inst = create()), + (ref.current = _inst), + function() { + ref.current = null; + } + ); + }, + inputs + ); + }, + useLayoutEffect: function(create, inputs) { + useEffectImpl(4, 36, create, inputs); + }, + useMemo: function(nextCreate, inputs) { + currentlyRenderingFiber$1 = resolveCurrentlyRenderingFiber(); + workInProgressHook = createWorkInProgressHook(); + inputs = void 0 !== inputs && null !== inputs ? inputs : [nextCreate]; + var prevState = workInProgressHook.memoizedState; + if (null !== prevState && inputsAreEqual(inputs, prevState[1])) + return prevState[0]; + nextCreate = nextCreate(); + workInProgressHook.memoizedState = [nextCreate, inputs]; + return nextCreate; + }, + useMutationEffect: function(create, inputs) { + useEffectImpl(260, 10, create, inputs); + }, + useReducer: useReducer, + useRef: function(initialValue) { + currentlyRenderingFiber$1 = resolveCurrentlyRenderingFiber(); + workInProgressHook = createWorkInProgressHook(); + null === workInProgressHook.memoizedState + ? ((initialValue = { current: initialValue }), + (workInProgressHook.memoizedState = initialValue)) + : (initialValue = workInProgressHook.memoizedState); + return initialValue; + }, + useState: function(initialState) { + return useReducer(basicStateReducer, initialState); + } + }, ReactCurrentOwner$2 = ReactSharedInternals.ReactCurrentOwner, isWorking = !1, nextUnitOfWork = null, @@ -4809,6 +5391,9 @@ var Dispatcher = { readContext: readContext }, nextRenderDidError = !1, nextEffect = null, isCommitting$1 = !1, + rootWithPendingPassiveEffects = null, + passiveEffectCallbackHandle = null, + passiveEffectCallback = null, legacyErrorBoundariesThatAlreadyFailed = null; function resetStack() { if (null !== nextUnitOfWork) @@ -4819,7 +5404,7 @@ function resetStack() { ) { var interruptedWork$jscomp$0 = interruptedWork; switch (interruptedWork$jscomp$0.tag) { - case 2: + case 1: var childContextTypes = interruptedWork$jscomp$0.type.childContextTypes; null !== childContextTypes && @@ -4827,23 +5412,16 @@ function resetStack() { 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 7: + case 5: popHostContext(interruptedWork$jscomp$0); break; - case 6: + case 4: popHostContainer(interruptedWork$jscomp$0); break; - case 12: + case 10: popProvider(interruptedWork$jscomp$0); } interruptedWork = interruptedWork.return; @@ -4854,27 +5432,55 @@ function resetStack() { nextRenderDidError = !1; nextUnitOfWork = null; } +function commitPassiveEffects(root, firstEffect) { + passiveEffectCallback = passiveEffectCallbackHandle = rootWithPendingPassiveEffects = null; + var previousIsRendering = isRendering; + isRendering = !0; + do { + if (firstEffect.effectTag & 512) { + var didError = !1, + error = void 0; + try { + var finishedWork = firstEffect; + commitHookEffectList(128, 0, finishedWork); + commitHookEffectList(0, 64, finishedWork); + } catch (e) { + (didError = !0), (error = e); + } + didError && captureCommitPhaseError(firstEffect, error); + } + firstEffect = firstEffect.nextEffect; + } while (null !== firstEffect); + isRendering = previousIsRendering; + previousIsRendering = root.expirationTime; + 0 !== previousIsRendering && requestWork(root, previousIsRendering); +} +function flushPassiveEffects() { + null !== passiveEffectCallback && + (scheduler.unstable_cancelCallback(passiveEffectCallbackHandle), + passiveEffectCallback()); +} function completeUnitOfWork(workInProgress) { for (;;) { var current$$1 = workInProgress.alternate, returnFiber = workInProgress.return, siblingFiber = workInProgress.sibling; - if (0 === (workInProgress.effectTag & 512)) { + if (0 === (workInProgress.effectTag & 1024)) { var current = current$$1; current$$1 = workInProgress; var newProps = current$$1.pendingProps; switch (current$$1.tag) { - case 0: - case 1: - break; case 2: + break; + case 16: + break; + case 15: + case 0: + break; + case 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; @@ -4885,7 +5491,7 @@ function completeUnitOfWork(workInProgress) { current$$1.effectTag &= -3; updateHostContainer(current$$1); break; - case 7: + case 5: popHostContext(current$$1); var rootContainerInstance = requiredContext( rootInstanceStackCursor.current @@ -4924,35 +5530,7 @@ function completeUnitOfWork(workInProgress) { viewConfig = new ReactNativeFiberHostComponent(tag, viewConfig); instanceCache[tag] = internalInstanceHandle; instanceProps[tag] = newProps; - a: for ( - internalInstanceHandle = viewConfig, - tag = current$$1, - updatePayload = tag.child; - null !== updatePayload; - - ) { - if (7 === updatePayload.tag || 8 === updatePayload.tag) - internalInstanceHandle._children.push(updatePayload.stateNode); - else if ( - 6 !== updatePayload.tag && - null !== updatePayload.child - ) { - updatePayload.child.return = updatePayload; - updatePayload = updatePayload.child; - continue; - } - if (updatePayload === tag) break; - for (; null === updatePayload.sibling; ) { - if ( - null === updatePayload.return || - updatePayload.return === tag - ) - break a; - updatePayload = updatePayload.return; - } - updatePayload.sibling.return = updatePayload.return; - updatePayload = updatePayload.sibling; - } + appendAllChildren(viewConfig, current$$1, !1, !1); finalizeInitialChildren( viewConfig, type, @@ -4968,7 +5546,7 @@ 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 8: + case 6: current && null != current$$1.stateNode ? updateHostText$1( current, @@ -4995,34 +5573,36 @@ function completeUnitOfWork(workInProgress) { (instanceCache[type] = current$$1), (rootContainerInstance.stateNode = type)); break; + case 11: + break; case 13: - case 14: + newProps = current$$1.memoizedState; + rootContainerInstance = + null !== current ? current.memoizedState : null; + (null !== newProps && newProps.didTimeout) !== + (null !== rootContainerInstance && + rootContainerInstance.didTimeout) && (current$$1.effectTag |= 4); break; - case 16: + case 7: break; - case 9: + case 8: break; - case 10: + case 12: break; - case 15: - break; - case 6: + case 4: popHostContainer(current$$1); updateHostContainer(current$$1); break; - case 12: + case 10: popProvider(current$$1); break; - case 11: + case 9: + break; + case 14: break; case 17: - case 18: + isContextProvider(current$$1.type) && popContext(current$$1); break; - 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." - ); default: invariant( !1, @@ -5032,27 +5612,24 @@ function completeUnitOfWork(workInProgress) { nextUnitOfWork = null; current$$1 = workInProgress; if ( - 1073741823 === nextRenderExpirationTime || - 1073741823 !== current$$1.childExpirationTime + 1 === nextRenderExpirationTime || + 1 !== current$$1.childExpirationTime ) { newProps = 0; for ( rootContainerInstance = current$$1.child; null !== rootContainerInstance; - ) { - type = rootContainerInstance.expirationTime; - current = rootContainerInstance.childExpirationTime; - if (0 === newProps || (0 !== type && type < newProps)) - newProps = type; - if (0 === newProps || (0 !== current && current < newProps)) - newProps = current; - rootContainerInstance = rootContainerInstance.sibling; - } + ) + (type = rootContainerInstance.expirationTime), + (current = rootContainerInstance.childExpirationTime), + type > newProps && (newProps = type), + current > newProps && (newProps = current), + (rootContainerInstance = rootContainerInstance.sibling); current$$1.childExpirationTime = newProps; } null !== returnFiber && - 0 === (returnFiber.effectTag & 512) && + 0 === (returnFiber.effectTag & 1024) && (null === returnFiber.firstEffect && (returnFiber.firstEffect = workInProgress.firstEffect), null !== workInProgress.lastEffect && @@ -5067,10 +5644,10 @@ function completeUnitOfWork(workInProgress) { } else { workInProgress = unwindWork(workInProgress, nextRenderExpirationTime); if (null !== workInProgress) - return (workInProgress.effectTag &= 511), workInProgress; + return (workInProgress.effectTag &= 1023), workInProgress; null !== returnFiber && ((returnFiber.firstEffect = returnFiber.lastEffect = null), - (returnFiber.effectTag |= 512)); + (returnFiber.effectTag |= 1024)); } if (null !== siblingFiber) return siblingFiber; if (null !== returnFiber) workInProgress = returnFiber; @@ -5084,15 +5661,17 @@ function performUnitOfWork(workInProgress) { workInProgress, nextRenderExpirationTime ); + workInProgress.memoizedProps = workInProgress.pendingProps; null === next && (next = completeUnitOfWork(workInProgress)); ReactCurrentOwner$2.current = null; return next; } -function renderRoot(root$jscomp$0, isYieldy, isExpired) { +function renderRoot(root$jscomp$0, isYieldy) { invariant( !isWorking, "renderRoot was called recursively. This error is likely caused by a bug in React. Please file an issue." ); + flushPassiveEffects(); isWorking = !0; ReactCurrentOwner$2.currentDispatcher = Dispatcher; var expirationTime = root$jscomp$0.nextExpirationTimeToWorkOn; @@ -5114,13 +5693,17 @@ function renderRoot(root$jscomp$0, isYieldy, isExpired) { do { try { if (isYieldy) - for (; null !== nextUnitOfWork && !shouldYield(); ) + for (; null !== nextUnitOfWork && !shouldYieldToRenderer(); ) nextUnitOfWork = performUnitOfWork(nextUnitOfWork); else for (; null !== nextUnitOfWork; ) nextUnitOfWork = performUnitOfWork(nextUnitOfWork); } catch (thrownValue) { - if (null === nextUnitOfWork) + if ( + ((lastContextWithAllBitsObserved = lastContextDependency = currentlyRenderingFiber = null), + resetHooks(), + null === nextUnitOfWork) + ) (didFatal = !0), onUncaughtError(thrownValue); else { invariant( @@ -5137,7 +5720,7 @@ function renderRoot(root$jscomp$0, isYieldy, isExpired) { sourceFiber$jscomp$0 = sourceFiber, value = thrownValue; returnFiber = nextRenderExpirationTime; - sourceFiber$jscomp$0.effectTag |= 512; + sourceFiber$jscomp$0.effectTag |= 1024; sourceFiber$jscomp$0.firstEffect = sourceFiber$jscomp$0.lastEffect = null; if ( null !== value && @@ -5149,56 +5732,57 @@ function renderRoot(root$jscomp$0, isYieldy, isExpired) { var earliestTimeoutMs = -1, startTimeMs = -1; do { - if (16 === value.tag) { - var current = value.alternate; + if (13 === value.tag) { + var current$$1 = value.alternate; if ( - null !== current && - !0 === current.memoizedState && - null !== current.stateNode + null !== current$$1 && + ((current$$1 = current$$1.memoizedState), + null !== current$$1 && current$$1.didTimeout) ) { - startTimeMs = 10 * (current.stateNode.timedOutAt - 2); + startTimeMs = 10 * (1073741822 - current$$1.timedOutAt); break; } - current = value.pendingProps.maxDuration; - if ("number" === typeof current) - if (0 >= current) earliestTimeoutMs = 0; + current$$1 = value.pendingProps.maxDuration; + if ("number" === typeof current$$1) + if (0 >= current$$1) earliestTimeoutMs = 0; else if ( -1 === earliestTimeoutMs || - current < earliestTimeoutMs + current$$1 < earliestTimeoutMs ) - earliestTimeoutMs = current; + earliestTimeoutMs = current$$1; } value = value.return; } while (null !== value); value = returnFiber$jscomp$0; do { - if (16 === value.tag && !value.memoizedState) { + if ((current$$1 = 13 === value.tag)) + void 0 === value.memoizedProps.fallback + ? (current$$1 = !1) + : ((current$$1 = value.memoizedState), + (current$$1 = + null === current$$1 || !current$$1.didTimeout)); + if (current$$1) { returnFiber$jscomp$0 = retrySuspendedRoot.bind( null, root, value, - 0 === (value.mode & 1) ? 1 : returnFiber + sourceFiber$jscomp$0, + 0 === (value.mode & 1) ? 1073741823 : returnFiber ); thenable.then(returnFiber$jscomp$0, returnFiber$jscomp$0); - if (0 === (value.mode & 2)) { - value.effectTag |= 4; + if (0 === (value.mode & 1)) { + value.effectTag |= 32; reconcileChildren( sourceFiber$jscomp$0.alternate, sourceFiber$jscomp$0, null, returnFiber ); - sourceFiber$jscomp$0.effectTag &= -513; - 4 === sourceFiber$jscomp$0.tag && - (sourceFiber$jscomp$0.tag = 0); - if ( - 2 === sourceFiber$jscomp$0.tag || - 3 === sourceFiber$jscomp$0.tag - ) - (sourceFiber$jscomp$0.effectTag &= -421), - null === sourceFiber$jscomp$0.alternate && - ((sourceFiber$jscomp$0.tag = 0), - (sourceFiber$jscomp$0.type = NoopComponent)); + sourceFiber$jscomp$0.effectTag &= -1025; + sourceFiber$jscomp$0.effectTag &= -933; + 1 === sourceFiber$jscomp$0.tag && + null === sourceFiber$jscomp$0.alternate && + (sourceFiber$jscomp$0.tag = 17); break a; } -1 === earliestTimeoutMs @@ -5206,24 +5790,27 @@ function renderRoot(root$jscomp$0, isYieldy, isExpired) { : (-1 === startTimeMs && (startTimeMs = 10 * - (findEarliestOutstandingPriorityLevel( - root, - returnFiber - ) - - 2) - + (1073741822 - + findEarliestOutstandingPriorityLevel( + root, + returnFiber + )) - 5e3), (root = startTimeMs + earliestTimeoutMs)); 0 <= root && nextLatestAbsoluteTimeoutMs < root && (nextLatestAbsoluteTimeoutMs = root); - value.effectTag |= 1024; + value.effectTag |= 2048; value.expirationTime = returnFiber; break a; } value = value.return; } while (null !== value); value = Error( - "An update was suspended, but no placeholder UI was provided." + (getComponentName(sourceFiber$jscomp$0.type) || + "A React component") + + " suspended while rendering, but no fallback UI was specified.\n\nAdd a component higher in the tree to provide a loading indicator or placeholder to display." + + getStackByFiberInDevAndProd(sourceFiber$jscomp$0) ); } nextRenderDidError = !0; @@ -5231,9 +5818,9 @@ function renderRoot(root$jscomp$0, isYieldy, isExpired) { root = returnFiber$jscomp$0; do { switch (root.tag) { - case 5: + case 3: sourceFiber$jscomp$0 = value; - root.effectTag |= 1024; + root.effectTag |= 2048; root.expirationTime = returnFiber; returnFiber = createRootErrorUpdate( root, @@ -5242,8 +5829,7 @@ function renderRoot(root$jscomp$0, isYieldy, isExpired) { ); enqueueCapturedUpdate(root, returnFiber); break a; - case 2: - case 3: + case 1: if ( ((sourceFiber$jscomp$0 = value), (returnFiber$jscomp$0 = root.type), @@ -5258,7 +5844,7 @@ function renderRoot(root$jscomp$0, isYieldy, isExpired) { thenable ))))) ) { - root.effectTag |= 1024; + root.effectTag |= 2048; root.expirationTime = returnFiber; returnFiber = createClassErrorUpdate( root, @@ -5281,183 +5867,170 @@ function renderRoot(root$jscomp$0, isYieldy, isExpired) { } while (1); isWorking = !1; lastContextWithAllBitsObserved = lastContextDependency = currentlyRenderingFiber = ReactCurrentOwner$2.currentDispatcher = null; + resetHooks(); if (didFatal) (nextRoot = null), (root$jscomp$0.finishedWork = null); else if (null !== nextUnitOfWork) root$jscomp$0.finishedWork = null; else { - isYieldy = root$jscomp$0.current.alternate; + didFatal = root$jscomp$0.current.alternate; invariant( - null !== isYieldy, + null !== didFatal, "Finished root should have a work-in-progress. This error is likely caused by a bug in React. Please file an issue." ); nextRoot = null; if (nextRenderDidError) { - didFatal = root$jscomp$0.latestPendingTime; - sourceFiber = root$jscomp$0.latestSuspendedTime; - returnFiber = root$jscomp$0.latestPingedTime; + sourceFiber = root$jscomp$0.latestPendingTime; + returnFiber = root$jscomp$0.latestSuspendedTime; + root = root$jscomp$0.latestPingedTime; if ( - (0 !== didFatal && didFatal > expirationTime) || - (0 !== sourceFiber && sourceFiber > expirationTime) || - (0 !== returnFiber && returnFiber > expirationTime) + (0 !== sourceFiber && sourceFiber < expirationTime) || + (0 !== returnFiber && returnFiber < expirationTime) || + (0 !== root && root < expirationTime) ) { markSuspendedPriorityLevel(root$jscomp$0, expirationTime); onSuspend( root$jscomp$0, - isYieldy, + didFatal, expirationTime, root$jscomp$0.expirationTime, -1 ); return; } - if (!root$jscomp$0.didError && !isExpired) { + if (!root$jscomp$0.didError && isYieldy) { root$jscomp$0.didError = !0; expirationTime = root$jscomp$0.nextExpirationTimeToWorkOn = expirationTime; - isExpired = root$jscomp$0.expirationTime = 1; - onSuspend(root$jscomp$0, isYieldy, expirationTime, isExpired, -1); + isYieldy = root$jscomp$0.expirationTime = 1073741823; + onSuspend(root$jscomp$0, didFatal, expirationTime, isYieldy, -1); return; } } - isExpired || -1 === nextLatestAbsoluteTimeoutMs - ? ((root$jscomp$0.pendingCommitExpirationTime = expirationTime), - (root$jscomp$0.finishedWork = isYieldy)) - : (markSuspendedPriorityLevel(root$jscomp$0, expirationTime), - (isExpired = + isYieldy && -1 !== nextLatestAbsoluteTimeoutMs + ? (markSuspendedPriorityLevel(root$jscomp$0, expirationTime), + (isYieldy = 10 * - (findEarliestOutstandingPriorityLevel(root$jscomp$0, expirationTime) - - 2)), - isExpired < nextLatestAbsoluteTimeoutMs && - (nextLatestAbsoluteTimeoutMs = isExpired), - (isExpired = 10 * (requestCurrentTime() - 2)), - (isExpired = nextLatestAbsoluteTimeoutMs - isExpired), + (1073741822 - + findEarliestOutstandingPriorityLevel( + root$jscomp$0, + expirationTime + ))), + isYieldy < nextLatestAbsoluteTimeoutMs && + (nextLatestAbsoluteTimeoutMs = isYieldy), + (isYieldy = 10 * (1073741822 - requestCurrentTime())), + (isYieldy = nextLatestAbsoluteTimeoutMs - isYieldy), onSuspend( root$jscomp$0, - isYieldy, + didFatal, expirationTime, root$jscomp$0.expirationTime, - 0 > isExpired ? 0 : isExpired - )); + 0 > isYieldy ? 0 : isYieldy + )) + : ((root$jscomp$0.pendingCommitExpirationTime = expirationTime), + (root$jscomp$0.finishedWork = didFatal)); } } -function captureCommitPhaseError(fiber, error) { - var JSCompiler_inline_result; - a: { - invariant( - !isWorking || isCommitting$1, - "dispatch: Cannot dispatch during the render phase." - ); - for ( - JSCompiler_inline_result = fiber.return; - null !== JSCompiler_inline_result; - - ) { - switch (JSCompiler_inline_result.tag) { - case 2: - case 3: - var instance = JSCompiler_inline_result.stateNode; - if ( - "function" === - typeof JSCompiler_inline_result.type.getDerivedStateFromError || - ("function" === typeof instance.componentDidCatch && - (null === legacyErrorBoundariesThatAlreadyFailed || - !legacyErrorBoundariesThatAlreadyFailed.has(instance))) - ) { - fiber = createCapturedValue(error, fiber); - fiber = createClassErrorUpdate(JSCompiler_inline_result, fiber, 1); - enqueueUpdate(JSCompiler_inline_result, fiber); - scheduleWork(JSCompiler_inline_result, 1); - JSCompiler_inline_result = void 0; - break a; - } - break; - case 5: - fiber = createCapturedValue(error, fiber); - fiber = createRootErrorUpdate(JSCompiler_inline_result, fiber, 1); - enqueueUpdate(JSCompiler_inline_result, fiber); - scheduleWork(JSCompiler_inline_result, 1); - JSCompiler_inline_result = void 0; - break a; - } - JSCompiler_inline_result = JSCompiler_inline_result.return; +function captureCommitPhaseError(sourceFiber, value) { + for (var fiber = sourceFiber.return; null !== fiber; ) { + switch (fiber.tag) { + case 1: + var instance = fiber.stateNode; + if ( + "function" === typeof fiber.type.getDerivedStateFromError || + ("function" === typeof instance.componentDidCatch && + (null === legacyErrorBoundariesThatAlreadyFailed || + !legacyErrorBoundariesThatAlreadyFailed.has(instance))) + ) { + sourceFiber = createCapturedValue(value, sourceFiber); + sourceFiber = createClassErrorUpdate(fiber, sourceFiber, 1073741823); + enqueueUpdate(fiber, sourceFiber); + scheduleWork(fiber, 1073741823); + return; + } + break; + case 3: + sourceFiber = createCapturedValue(value, sourceFiber); + sourceFiber = createRootErrorUpdate(fiber, sourceFiber, 1073741823); + enqueueUpdate(fiber, sourceFiber); + scheduleWork(fiber, 1073741823); + return; } - 5 === fiber.tag && - ((JSCompiler_inline_result = createCapturedValue(error, fiber)), - (JSCompiler_inline_result = createRootErrorUpdate( - fiber, - JSCompiler_inline_result, - 1 - )), - enqueueUpdate(fiber, JSCompiler_inline_result), - scheduleWork(fiber, 1)); - JSCompiler_inline_result = void 0; + fiber = fiber.return; } - return JSCompiler_inline_result; + 3 === sourceFiber.tag && + ((fiber = createCapturedValue(value, sourceFiber)), + (fiber = createRootErrorUpdate(sourceFiber, fiber, 1073741823)), + enqueueUpdate(sourceFiber, fiber), + scheduleWork(sourceFiber, 1073741823)); } function computeExpirationForFiber(currentTime, fiber) { isWorking - ? (currentTime = isCommitting$1 ? 1 : nextRenderExpirationTime) + ? (currentTime = isCommitting$1 ? 1073741823 : nextRenderExpirationTime) : fiber.mode & 1 ? ((currentTime = isBatchingInteractiveUpdates - ? 2 + 10 * ((((currentTime - 2 + 15) / 10) | 0) + 1) - : 2 + 25 * ((((currentTime - 2 + 500) / 25) | 0) + 1)), + ? 1073741822 - 10 * ((((1073741822 - currentTime + 15) / 10) | 0) + 1) + : 1073741822 - + 25 * ((((1073741822 - currentTime + 500) / 25) | 0) + 1)), null !== nextRoot && currentTime === nextRenderExpirationTime && - (currentTime += 1)) - : (currentTime = 1); + --currentTime) + : (currentTime = 1073741823); isBatchingInteractiveUpdates && - currentTime > lowestPriorityPendingInteractiveExpirationTime && + (0 === lowestPriorityPendingInteractiveExpirationTime || + currentTime < lowestPriorityPendingInteractiveExpirationTime) && (lowestPriorityPendingInteractiveExpirationTime = currentTime); return currentTime; } -function retrySuspendedRoot(root, fiber, suspendedTime) { +function retrySuspendedRoot(root, boundaryFiber, sourceFiber, suspendedTime) { var retryTime = root.earliestSuspendedTime; var latestSuspendedTime = root.latestSuspendedTime; if ( 0 !== retryTime && - suspendedTime >= retryTime && - suspendedTime <= latestSuspendedTime + suspendedTime <= retryTime && + suspendedTime >= latestSuspendedTime ) { latestSuspendedTime = retryTime = suspendedTime; root.didError = !1; var latestPingedTime = root.latestPingedTime; - if (0 === latestPingedTime || latestPingedTime < latestSuspendedTime) + if (0 === latestPingedTime || latestPingedTime > latestSuspendedTime) root.latestPingedTime = latestSuspendedTime; findNextExpirationTimeToWorkOn(latestSuspendedTime, root); } else (retryTime = requestCurrentTime()), - (retryTime = computeExpirationForFiber(retryTime, fiber)), + (retryTime = computeExpirationForFiber(retryTime, boundaryFiber)), markPendingPriorityLevel(root, retryTime); - 0 !== (fiber.mode & 1) && + 0 !== (boundaryFiber.mode & 1) && root === nextRoot && nextRenderExpirationTime === suspendedTime && (nextRoot = null); - scheduleWorkToRoot(fiber, retryTime); - fiber = root.expirationTime; - 0 !== fiber && requestWork(root, fiber); + scheduleWorkToRoot(boundaryFiber, retryTime); + 0 === (boundaryFiber.mode & 1) && + (scheduleWorkToRoot(sourceFiber, retryTime), + 1 === sourceFiber.tag && + null !== sourceFiber.stateNode && + ((boundaryFiber = createUpdate(retryTime)), + (boundaryFiber.tag = 2), + enqueueUpdate(sourceFiber, boundaryFiber))); + sourceFiber = root.expirationTime; + 0 !== sourceFiber && requestWork(root, sourceFiber); } function scheduleWorkToRoot(fiber, expirationTime) { - if (0 === fiber.expirationTime || fiber.expirationTime > expirationTime) - fiber.expirationTime = expirationTime; + fiber.expirationTime < expirationTime && + (fiber.expirationTime = expirationTime); var alternate = fiber.alternate; null !== alternate && - (0 === alternate.expirationTime || - alternate.expirationTime > expirationTime) && + alternate.expirationTime < expirationTime && (alternate.expirationTime = expirationTime); var node = fiber.return, root = null; - if (null === node && 5 === fiber.tag) root = fiber.stateNode; + if (null === node && 3 === fiber.tag) root = fiber.stateNode; else for (; null !== node; ) { alternate = node.alternate; - if ( - 0 === node.childExpirationTime || - node.childExpirationTime > expirationTime - ) - node.childExpirationTime = expirationTime; + node.childExpirationTime < expirationTime && + (node.childExpirationTime = expirationTime); null !== alternate && - (0 === alternate.childExpirationTime || - alternate.childExpirationTime > expirationTime) && + alternate.childExpirationTime < expirationTime && (alternate.childExpirationTime = expirationTime); - if (null === node.return && 5 === node.tag) { + if (null === node.return && 3 === node.tag) { root = node.stateNode; break; } @@ -5470,7 +6043,7 @@ function scheduleWork(fiber, expirationTime) { null !== fiber && (!isWorking && 0 !== nextRenderExpirationTime && - expirationTime < nextRenderExpirationTime && + expirationTime > nextRenderExpirationTime && resetStack(), markPendingPriorityLevel(fiber, expirationTime), (isWorking && !isCommitting$1 && nextRoot === fiber) || @@ -5490,27 +6063,25 @@ var firstScheduledRoot = null, nextFlushedRoot = null, nextFlushedExpirationTime = 0, lowestPriorityPendingInteractiveExpirationTime = 0, - deadlineDidExpire = !1, hasUnhandledError = !1, unhandledError = null, - deadline = null, isBatchingUpdates = !1, isUnbatchingUpdates = !1, isBatchingInteractiveUpdates = !1, completedBatches = null, originalStartTimeMs = now$1(), - currentRendererTime = ((originalStartTimeMs / 10) | 0) + 2, + currentRendererTime = 1073741822 - ((originalStartTimeMs / 10) | 0), currentSchedulerTime = currentRendererTime, NESTED_UPDATE_LIMIT = 50, nestedUpdateCount = 0, - lastCommittedRootDuringThisBatch = null, - timeHeuristicForUnitOfWork = 1; + lastCommittedRootDuringThisBatch = null; function recomputeCurrentRendererTime() { - currentRendererTime = (((now$1() - originalStartTimeMs) / 10) | 0) + 2; + currentRendererTime = + 1073741822 - (((now$1() - originalStartTimeMs) / 10) | 0); } function scheduleCallbackWithExpirationTime(root, expirationTime) { if (0 !== callbackExpirationTime) { - if (expirationTime > callbackExpirationTime) return; + if (expirationTime < callbackExpirationTime) return; null !== callbackID && ((root = callbackID), (scheduledCallback = null), clearTimeout(root)); } @@ -5527,7 +6098,7 @@ function onSuspend( msUntilTimeout ) { root.expirationTime = rootExpirationTime; - 0 !== msUntilTimeout || shouldYield() + 0 !== msUntilTimeout || shouldYieldToRenderer() ? 0 < msUntilTimeout && (root.timeoutHandle = scheduleTimeout( onTimeout.bind(null, root, finishedWork, suspendedExpirationTime), @@ -5547,44 +6118,35 @@ function onTimeout(root, finishedWork, suspendedExpirationTime) { ); nextFlushedRoot = root; nextFlushedExpirationTime = suspendedExpirationTime; - performWorkOnRoot(root, suspendedExpirationTime, !0); - performWork(1, null); + performWorkOnRoot(root, suspendedExpirationTime, !1); + performWork(1073741823, !1); } function requestCurrentTime() { if (isRendering) return currentSchedulerTime; findHighestPriorityRoot(); - if ( - 0 === nextFlushedExpirationTime || - 1073741823 === nextFlushedExpirationTime - ) + if (0 === nextFlushedExpirationTime || 1 === nextFlushedExpirationTime) recomputeCurrentRendererTime(), (currentSchedulerTime = currentRendererTime); return currentSchedulerTime; } function requestWork(root, expirationTime) { - if (null === root.nextScheduledRoot) - (root.expirationTime = expirationTime), + 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; - } + (lastScheduledRoot.nextScheduledRoot = firstScheduledRoot))) + : expirationTime > root.expirationTime && + (root.expirationTime = expirationTime); isRendering || (isBatchingUpdates ? isUnbatchingUpdates && ((nextFlushedRoot = root), - (nextFlushedExpirationTime = 1), - performWorkOnRoot(root, 1, !0)) - : 1 === expirationTime - ? performWork(1, null) + (nextFlushedExpirationTime = 1073741823), + performWorkOnRoot(root, 1073741823, !1)) + : 1073741823 === expirationTime + ? performWork(1073741823, !1) : scheduleCallbackWithExpirationTime(root, expirationTime)); } function findHighestPriorityRoot() { @@ -5620,14 +6182,11 @@ function findHighestPriorityRoot() { (root.nextScheduledRoot = null); root = previousScheduledRoot.nextScheduledRoot; } else { - if ( - 0 === highestPriorityWork || - remainingExpirationTime < highestPriorityWork - ) - (highestPriorityWork = remainingExpirationTime), - (highestPriorityRoot = root); + remainingExpirationTime > highestPriorityWork && + ((highestPriorityWork = remainingExpirationTime), + (highestPriorityRoot = root)); if (root === lastScheduledRoot) break; - if (1 === highestPriorityWork) break; + if (1073741823 === highestPriorityWork) break; previousScheduledRoot = root; root = root.nextScheduledRoot; } @@ -5635,38 +6194,44 @@ function findHighestPriorityRoot() { nextFlushedRoot = highestPriorityRoot; 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); +var didYield = !1; +function shouldYieldToRenderer() { + return didYield ? !0 : frameDeadline <= now$1() ? (didYield = !0) : !1; } -function performWork(minExpirationTime, dl) { - deadline = dl; +function performAsyncWork() { + try { + if (!shouldYieldToRenderer() && 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, !0); + } finally { + didYield = !1; + } +} +function performWork(minExpirationTime, isYieldy) { findHighestPriorityRoot(); - if (null !== deadline) + if (isYieldy) for ( recomputeCurrentRendererTime(), currentSchedulerTime = currentRendererTime; null !== nextFlushedRoot && 0 !== nextFlushedExpirationTime && - (0 === minExpirationTime || - minExpirationTime >= nextFlushedExpirationTime) && - (!deadlineDidExpire || currentRendererTime >= nextFlushedExpirationTime); + minExpirationTime <= nextFlushedExpirationTime && + !(didYield && currentRendererTime > nextFlushedExpirationTime); ) performWorkOnRoot( nextFlushedRoot, nextFlushedExpirationTime, - currentRendererTime >= nextFlushedExpirationTime + currentRendererTime > nextFlushedExpirationTime ), findHighestPriorityRoot(), recomputeCurrentRendererTime(), @@ -5676,29 +6241,28 @@ function performWork(minExpirationTime, dl) { ; null !== nextFlushedRoot && 0 !== nextFlushedExpirationTime && - (0 === minExpirationTime || - minExpirationTime >= nextFlushedExpirationTime); + minExpirationTime <= nextFlushedExpirationTime; ) - performWorkOnRoot(nextFlushedRoot, nextFlushedExpirationTime, !0), + performWorkOnRoot(nextFlushedRoot, nextFlushedExpirationTime, !1), findHighestPriorityRoot(); - null !== deadline && ((callbackExpirationTime = 0), (callbackID = null)); + isYieldy && ((callbackExpirationTime = 0), (callbackID = null)); 0 !== nextFlushedExpirationTime && scheduleCallbackWithExpirationTime( nextFlushedRoot, nextFlushedExpirationTime ); - deadline = null; - deadlineDidExpire = !1; nestedUpdateCount = 0; lastCommittedRootDuringThisBatch = null; if (null !== completedBatches) for ( - minExpirationTime = completedBatches, completedBatches = null, dl = 0; - dl < minExpirationTime.length; - dl++ + minExpirationTime = completedBatches, + completedBatches = null, + isYieldy = 0; + isYieldy < minExpirationTime.length; + isYieldy++ ) { - var batch = minExpirationTime[dl]; + var batch = minExpirationTime[isYieldy]; try { batch._onComplete(); } catch (error) { @@ -5712,45 +6276,45 @@ function performWork(minExpirationTime, dl) { (hasUnhandledError = !1), minExpirationTime); } -function performWorkOnRoot(root, expirationTime, isExpired) { +function performWorkOnRoot(root, expirationTime, isYieldy) { invariant( !isRendering, "performWorkOnRoot was called recursively. This error is likely caused by a bug in React. Please file an issue." ); isRendering = !0; - if (null === deadline || isExpired) { - var finishedWork = root.finishedWork; - null !== finishedWork - ? completeRoot(root, finishedWork, expirationTime) + if (isYieldy) { + var _finishedWork = root.finishedWork; + null !== _finishedWork + ? completeRoot(root, _finishedWork, expirationTime) : ((root.finishedWork = null), - (finishedWork = root.timeoutHandle), - -1 !== finishedWork && - ((root.timeoutHandle = -1), cancelTimeout(finishedWork)), - renderRoot(root, !1, isExpired), - (finishedWork = root.finishedWork), - null !== finishedWork && - completeRoot(root, finishedWork, expirationTime)); + (_finishedWork = root.timeoutHandle), + -1 !== _finishedWork && + ((root.timeoutHandle = -1), cancelTimeout(_finishedWork)), + renderRoot(root, isYieldy), + (_finishedWork = root.finishedWork), + null !== _finishedWork && + (shouldYieldToRenderer() + ? (root.finishedWork = _finishedWork) + : completeRoot(root, _finishedWork, expirationTime))); } else - (finishedWork = root.finishedWork), - null !== finishedWork - ? completeRoot(root, finishedWork, expirationTime) + (_finishedWork = root.finishedWork), + null !== _finishedWork + ? completeRoot(root, _finishedWork, expirationTime) : ((root.finishedWork = null), - (finishedWork = root.timeoutHandle), - -1 !== finishedWork && - ((root.timeoutHandle = -1), cancelTimeout(finishedWork)), - renderRoot(root, !0, isExpired), - (finishedWork = root.finishedWork), - null !== finishedWork && - (shouldYield() - ? (root.finishedWork = finishedWork) - : completeRoot(root, finishedWork, expirationTime))); + (_finishedWork = root.timeoutHandle), + -1 !== _finishedWork && + ((root.timeoutHandle = -1), cancelTimeout(_finishedWork)), + renderRoot(root, isYieldy), + (_finishedWork = root.finishedWork), + null !== _finishedWork && + completeRoot(root, _finishedWork, expirationTime)); isRendering = !1; } function completeRoot(root, finishedWork$jscomp$0, expirationTime) { var firstBatch = root.firstBatch; if ( null !== firstBatch && - firstBatch._expirationTime <= expirationTime && + firstBatch._expirationTime >= expirationTime && (null === completedBatches ? (completedBatches = [firstBatch]) : completedBatches.push(firstBatch), @@ -5779,9 +6343,7 @@ function completeRoot(root, finishedWork$jscomp$0, expirationTime) { var childExpirationTimeBeforeCommit = finishedWork$jscomp$0.childExpirationTime; firstBatch = - 0 === firstBatch || - (0 !== childExpirationTimeBeforeCommit && - childExpirationTimeBeforeCommit < firstBatch) + childExpirationTimeBeforeCommit > firstBatch ? childExpirationTimeBeforeCommit : firstBatch; root.didError = !1; @@ -5793,19 +6355,19 @@ function completeRoot(root, finishedWork$jscomp$0, expirationTime) { (root.latestPingedTime = 0)) : ((childExpirationTimeBeforeCommit = root.latestPendingTime), 0 !== childExpirationTimeBeforeCommit && - (childExpirationTimeBeforeCommit < firstBatch + (childExpirationTimeBeforeCommit > firstBatch ? (root.earliestPendingTime = root.latestPendingTime = 0) - : root.earliestPendingTime < firstBatch && + : root.earliestPendingTime > firstBatch && (root.earliestPendingTime = root.latestPendingTime)), (childExpirationTimeBeforeCommit = root.earliestSuspendedTime), 0 === childExpirationTimeBeforeCommit ? markPendingPriorityLevel(root, firstBatch) - : firstBatch > root.latestSuspendedTime + : firstBatch < root.latestSuspendedTime ? ((root.earliestSuspendedTime = 0), (root.latestSuspendedTime = 0), (root.latestPingedTime = 0), markPendingPriorityLevel(root, firstBatch)) - : firstBatch < childExpirationTimeBeforeCommit && + : firstBatch > childExpirationTimeBeforeCommit && markPendingPriorityLevel(root, firstBatch)); findNextExpirationTimeToWorkOn(0, root); ReactCurrentOwner$2.current = null; @@ -5820,13 +6382,17 @@ function completeRoot(root, finishedWork$jscomp$0, expirationTime) { var error = void 0; try { for (; null !== nextEffect; ) { - if (nextEffect.effectTag & 256) { - var current$$1 = nextEffect.alternate; + if (nextEffect.effectTag & 256) a: { - var finishedWork = nextEffect; + var current$$1 = nextEffect.alternate, + finishedWork = nextEffect; switch (finishedWork.tag) { - case 2: - case 3: + case 0: + case 11: + case 15: + commitHookEffectList(2, 0, finishedWork); + break a; + case 1: if (finishedWork.effectTag & 256 && null !== current$$1) { var prevProps = current$$1.memoizedProps, prevState = current$$1.memoizedState, @@ -5840,10 +6406,11 @@ function completeRoot(root, finishedWork$jscomp$0, expirationTime) { instance.__reactInternalSnapshotBeforeUpdate = snapshot; } break a; + case 3: case 5: - case 7: - case 8: case 6: + case 4: + case 17: break a; default: invariant( @@ -5852,7 +6419,6 @@ function completeRoot(root, finishedWork$jscomp$0, expirationTime) { ); } } - } nextEffect = nextEffect.nextEffect; } } catch (e) { @@ -5922,80 +6488,122 @@ function completeRoot(root, finishedWork$jscomp$0, expirationTime) { effectTag = !1; current$$1$jscomp$0 = void 0; try { - for (currentRef = expirationTime; null !== nextEffect; ) { + for ( + currentRef = root, current$$1 = expirationTime; + null !== nextEffect; + + ) { var effectTag$jscomp$0 = nextEffect.effectTag; if (effectTag$jscomp$0 & 36) { + prevState = void 0; var current$$1$jscomp$1 = nextEffect.alternate; - current$$1 = nextEffect; - prevProps = currentRef; - switch (current$$1.tag) { - case 2: - case 3: - var instance$jscomp$0 = current$$1.stateNode; - if (current$$1.effectTag & 4) + prevProps = nextEffect; + instance = current$$1; + switch (prevProps.tag) { + case 0: + case 11: + case 15: + commitHookEffectList(16, 32, prevProps); + break; + case 1: + var instance$jscomp$0 = prevProps.stateNode; + if (prevProps.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.props = prevProps.memoizedProps), + (instance$jscomp$0.state = prevProps.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.props = prevProps.memoizedProps; + instance$jscomp$0.state = prevProps.memoizedState; instance$jscomp$0.componentDidUpdate( prevProps$jscomp$0, prevState$jscomp$0, instance$jscomp$0.__reactInternalSnapshotBeforeUpdate ); } - var updateQueue = current$$1.updateQueue; + var updateQueue = prevProps.updateQueue; null !== updateQueue && - ((instance$jscomp$0.props = current$$1.memoizedProps), - (instance$jscomp$0.state = current$$1.memoizedState), + ((instance$jscomp$0.props = prevProps.memoizedProps), + (instance$jscomp$0.state = prevProps.memoizedState), commitUpdateQueue( - current$$1, + prevProps, updateQueue, instance$jscomp$0, - prevProps + instance )); break; - case 5: - var _updateQueue = current$$1.updateQueue; + case 3: + var _updateQueue = prevProps.updateQueue; if (null !== _updateQueue) { prevState = null; - if (null !== current$$1.child) - switch (current$$1.child.tag) { - case 7: - prevState = current$$1.child.stateNode; + if (null !== prevProps.child) + switch (prevProps.child.tag) { + case 5: + prevState = prevProps.child.stateNode; break; - case 2: - case 3: - prevState = current$$1.child.stateNode; + case 1: + prevState = prevProps.child.stateNode; } - commitUpdateQueue( - current$$1, - _updateQueue, - prevState, - prevProps - ); + commitUpdateQueue(prevProps, _updateQueue, prevState, instance); } break; - case 7: - break; - case 8: + case 5: break; case 6: break; - case 15: + case 4: break; - case 16: - if (0 === (current$$1.mode & 2)) - (current$$1.updateQueue = emptyObject$1), - scheduleWork(current$$1, 1); - else { - var currentTime = requestCurrentTime(); - current$$1.stateNode = { timedOutAt: currentTime }; + case 12: + break; + case 13: + if (prevProps.effectTag & 32) { + prevProps.memoizedState = { + alreadyCaptured: !0, + didTimeout: !1, + timedOutAt: 0 + }; + flushPassiveEffects(); + scheduleWork(prevProps, 1073741823); + break; } + var oldState = + null !== current$$1$jscomp$1 + ? current$$1$jscomp$1.memoizedState + : null, + newState = prevProps.memoizedState, + oldDidTimeout = null !== oldState ? oldState.didTimeout : !1; + instance = prevProps; + if (null === newState) prevState = !1; + else if ((prevState = newState.didTimeout)) + (instance = prevProps.child), + (newState.alreadyCaptured = !1), + 0 === newState.timedOutAt && + (newState.timedOutAt = requestCurrentTime()); + if (prevState !== oldDidTimeout && null !== instance) + a: for (prevState = prevProps = instance; ; ) { + if (5 === prevState.tag) throw Error("Not yet implemented."); + if (6 === prevState.tag) throw Error("Not yet implemented."); + if (null !== prevState.child) + (prevState.child.return = prevState), + (prevState = prevState.child); + else { + if (prevState === prevProps) break a; + for (; null === prevState.sibling; ) { + if ( + null === prevState.return || + prevState.return === prevProps + ) + break a; + prevState = prevState.return; + } + prevState.sibling.return = prevState.return; + prevState = prevState.sibling; + } + } + break; + case 17: break; default: invariant( @@ -6009,7 +6617,7 @@ function completeRoot(root, finishedWork$jscomp$0, expirationTime) { if (null !== ref) { var instance$jscomp$1 = nextEffect.stateNode; switch (nextEffect.tag) { - case 7: + case 5: var instanceToUse = instance$jscomp$1; break; default: @@ -6020,9 +6628,9 @@ function completeRoot(root, finishedWork$jscomp$0, expirationTime) { : (ref.current = instanceToUse); } } - var next = nextEffect.nextEffect; - nextEffect.nextEffect = null; - nextEffect = next; + effectTag$jscomp$0 & 512 && + (rootWithPendingPassiveEffects = currentRef); + nextEffect = nextEffect.nextEffect; } } catch (e) { (effectTag = !0), (current$$1$jscomp$0 = e); @@ -6035,14 +6643,20 @@ function completeRoot(root, finishedWork$jscomp$0, expirationTime) { captureCommitPhaseError(nextEffect, current$$1$jscomp$0), null !== nextEffect && (nextEffect = nextEffect.nextEffect)); } + null !== firstBatch && + null !== rootWithPendingPassiveEffects && + ((effectTag$jscomp$0 = commitPassiveEffects.bind(null, root, firstBatch)), + (passiveEffectCallbackHandle = scheduler.unstable_scheduleCallback( + effectTag$jscomp$0 + )), + (passiveEffectCallback = effectTag$jscomp$0)); 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 ? finishedWork$jscomp$0 : effectTag$jscomp$0; 0 === finishedWork$jscomp$0 && @@ -6050,13 +6664,6 @@ function completeRoot(root, finishedWork$jscomp$0, expirationTime) { root.expirationTime = finishedWork$jscomp$0; root.finishedWork = null; } -function shouldYield() { - return deadlineDidExpire - ? !0 - : null === deadline || deadline.timeRemaining() > timeHeuristicForUnitOfWork - ? !1 - : (deadlineDidExpire = !0); -} function onUncaughtError(error) { invariant( null !== nextFlushedRoot, @@ -6065,55 +6672,6 @@ function onUncaughtError(error) { nextFlushedRoot.expirationTime = 0; hasUnhandledError || ((hasUnhandledError = !0), (unhandledError = error)); } -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.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; void 0 === fiber && @@ -6132,7 +6690,48 @@ function updateContainer(element, container, parentComponent, callback) { currentTime = requestCurrentTime(); current$$1 = computeExpirationForFiber(currentTime, current$$1); currentTime = container.current; - parentComponent = getContextForSubtree(parentComponent); + a: if (parentComponent) { + parentComponent = parentComponent._reactInternalFiber; + b: { + invariant( + 2 === isFiberMountedImpl(parentComponent) && 1 === 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 3: + parentContext = parentContext.stateNode.context; + break b; + case 1: + if (isContextProvider(parentContext.type)) { + parentContext = + parentContext.stateNode + .__reactInternalMemoizedMergedChildContext; + break b; + } + } + 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 (1 === parentComponent.tag) { + var Component = parentComponent.type; + if (isContextProvider(Component)) { + parentComponent = processChildContext( + parentComponent, + Component, + parentContext + ); + break a; + } + } + parentComponent = parentContext; + } else parentComponent = emptyContextObject; null === container.context ? (container.context = parentComponent) : (container.pendingContext = parentComponent); @@ -6141,6 +6740,7 @@ function updateContainer(element, container, parentComponent, callback) { callback.payload = { element: element }; container = void 0 === container ? null : container; null !== container && (callback.callback = container); + flushPassiveEffects(); enqueueUpdate(currentTime, callback); scheduleWork(currentTime, current$$1); return current$$1; @@ -6200,13 +6800,13 @@ _batchedUpdatesImpl = function(fn, a) { } finally { (isBatchingUpdates = previousIsBatchingUpdates) || isRendering || - performWork(1, null); + performWork(1073741823, !1); } }; _flushInteractiveUpdatesImpl = function() { isRendering || 0 === lowestPriorityPendingInteractiveExpirationTime || - (performWork(lowestPriorityPendingInteractiveExpirationTime, null), + (performWork(lowestPriorityPendingInteractiveExpirationTime, !1), (lowestPriorityPendingInteractiveExpirationTime = 0)); }; var roots = new Map(), @@ -6286,7 +6886,7 @@ var roots = new Map(), render: function(element, containerTag, callback) { var root = roots.get(containerTag); if (!root) { - root = new FiberNode(5, null, null, 0); + root = createFiber(3, null, null, 0); var root$jscomp$0 = { current: root, containerInfo: containerTag, @@ -6314,7 +6914,7 @@ var roots = new Map(), updateContainer(element, root, null, callback); a: if (((element = root.current), element.child)) switch (element.child.tag) { - case 7: + case 5: element = element.child.stateNode; break a; default: @@ -6421,7 +7021,7 @@ var roots = new Map(), findFiberByHostInstance: getInstanceFromTag, getInspectorDataForViewTag: getInspectorDataForViewTag, bundleType: 0, - version: "16.6.0-alpha.8af6728", + version: "16.6.0", rendererPackageName: "react-native-renderer" }); var ReactNativeRenderer$2 = { default: ReactNativeRenderer }, diff --git a/Libraries/Renderer/oss/ReactNativeRenderer-profiling.js b/Libraries/Renderer/oss/ReactNativeRenderer-profiling.js index 3a9645d82..c13dbcc37 100644 --- a/Libraries/Renderer/oss/ReactNativeRenderer-profiling.js +++ b/Libraries/Renderer/oss/ReactNativeRenderer-profiling.js @@ -20,6 +20,7 @@ var ReactNativeViewConfigRegistry = require("ReactNativeViewConfigRegistry"), flattenStyle = require("flattenStyle"), TextInputState = require("TextInputState"), tracing = require("scheduler/tracing"), + scheduler = require("scheduler"), ExceptionsManager = require("ExceptionsManager"); function invariant(condition, format, a, b, c, d, e, f) { if (!condition) { @@ -294,7 +295,7 @@ function getListener(inst, registrationName) { } function getParent(inst) { do inst = inst.return; - while (inst && 7 !== inst.tag); + while (inst && 5 !== inst.tag); return inst ? inst : null; } function traverseTwoPhase(inst, fn, arg) { @@ -1148,7 +1149,8 @@ var ReactSharedInternals = : 60111, REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for("react.forward_ref") : 60112, REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for("react.suspense") : 60113, - REACT_PURE_TYPE = hasSymbol ? Symbol.for("react.pure") : 60115, + REACT_MEMO_TYPE = hasSymbol ? Symbol.for("react.memo") : 60115, + REACT_LAZY_TYPE = hasSymbol ? Symbol.for("react.lazy") : 60116, MAYBE_ITERATOR_SYMBOL = "function" === typeof Symbol && Symbol.iterator; function getIteratorFn(maybeIterable) { if (null === maybeIterable || "object" !== typeof maybeIterable) return null; @@ -1157,13 +1159,6 @@ function getIteratorFn(maybeIterable) { maybeIterable["@@iterator"]; return "function" === typeof maybeIterable ? maybeIterable : null; } -function getWrappedName(outerType, innerType, wrapperName) { - innerType = innerType.displayName || innerType.name || ""; - return ( - outerType.displayName || - ("" !== innerType ? wrapperName + "(" + innerType + ")" : wrapperName) - ); -} function getComponentName(type) { if (null == type) return null; if ("function" === typeof type) return type.displayName || type.name || null; @@ -1182,23 +1177,25 @@ function getComponentName(type) { case REACT_SUSPENSE_TYPE: return "Suspense"; } - if ("object" === typeof type) { + if ("object" === typeof type) switch (type.$$typeof) { case REACT_CONTEXT_TYPE: return "Context.Consumer"; case REACT_PROVIDER_TYPE: return "Context.Provider"; case REACT_FORWARD_REF_TYPE: - return getWrappedName(type, type.render, "ForwardRef"); - case REACT_PURE_TYPE: - return getWrappedName(type, type.render, "Pure"); + var innerType = type.render; + innerType = innerType.displayName || innerType.name || ""; + return ( + type.displayName || + ("" !== innerType ? "ForwardRef(" + innerType + ")" : "ForwardRef") + ); + case REACT_MEMO_TYPE: + return getComponentName(type.type); + case REACT_LAZY_TYPE: + if ((type = 1 === type._status ? type._result : null)) + return getComponentName(type); } - if ( - "function" === typeof type.then && - (type = 1 === type._reactStatus ? type._reactResult : null) - ) - return getComponentName(type); - } return null; } function isFiberMountedImpl(fiber) { @@ -1209,7 +1206,7 @@ function isFiberMountedImpl(fiber) { for (; node.return; ) if (((node = node.return), 0 !== (node.effectTag & 2))) return 1; } - return 5 === node.tag ? 2 : 3; + return 3 === node.tag ? 2 : 3; } function assertIsMounted(fiber) { invariant( @@ -1285,14 +1282,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(5 === a.tag, "Unable to find node on an unmounted component."); + invariant(3 === 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 (7 === node.tag || 8 === node.tag) return node; + if (5 === node.tag || 6 === node.tag) return node; if (node.child) (node.child.return = node), (node = node.child); else { if (node === parent) break; @@ -1600,18 +1597,12 @@ var ReactNativeFiberHostComponent = (function() { return Date.now(); }, scheduledCallback = null, - frameDeadline = 0, - frameDeadlineObject = { - timeRemaining: function() { - return frameDeadline - now$1(); - }, - didTimeout: !1 - }; + frameDeadline = 0; function setTimeoutCallback() { frameDeadline = now$1() + 5; var callback = scheduledCallback; scheduledCallback = null; - null !== callback && callback(frameDeadlineObject); + null !== callback && callback(); } function shim$1() { invariant( @@ -1652,13 +1643,13 @@ function getStackByFiberInDevAndProd(workInProgress) { var info = ""; do { a: switch (workInProgress.tag) { - case 4: + case 2: + case 16: case 0: case 1: - case 2: - case 3: - case 7: - case 10: + case 5: + case 8: + case 13: var owner = workInProgress._debugOwner, source = workInProgress._debugSource, name = getComponentName(workInProgress.type); @@ -1810,7 +1801,7 @@ function injectInternals(internals) { function FiberNode(tag, pendingProps, key, mode) { this.tag = tag; this.key = key; - this.sibling = this.child = this.return = this.stateNode = this.type = null; + this.sibling = this.child = this.return = this.stateNode = this.type = this.elementType = null; this.index = 0; this.ref = null; this.pendingProps = pendingProps; @@ -1824,29 +1815,33 @@ function FiberNode(tag, pendingProps, key, mode) { this.actualStartTime = -1; this.treeBaseDuration = this.selfBaseDuration = 0; } +function createFiber(tag, pendingProps, key, mode) { + return new FiberNode(tag, pendingProps, key, mode); +} function shouldConstruct(Component) { Component = Component.prototype; return !(!Component || !Component.isReactComponent); } -function resolveLazyComponentTag(fiber, Component) { +function resolveLazyComponentTag(Component) { if ("function" === typeof Component) - return shouldConstruct(Component) ? 3 : 1; + return shouldConstruct(Component) ? 1 : 0; if (void 0 !== Component && null !== Component) { - fiber = Component.$$typeof; - if (fiber === REACT_FORWARD_REF_TYPE) return 14; - if (fiber === REACT_PURE_TYPE) return 18; + Component = Component.$$typeof; + if (Component === REACT_FORWARD_REF_TYPE) return 11; + if (Component === REACT_MEMO_TYPE) return 14; } - return 4; + return 2; } function createWorkInProgress(current, pendingProps) { var workInProgress = current.alternate; null === workInProgress - ? ((workInProgress = new FiberNode( + ? ((workInProgress = createFiber( current.tag, pendingProps, current.key, current.mode )), + (workInProgress.elementType = current.elementType), (workInProgress.type = current.type), (workInProgress.stateNode = current.stateNode), (workInProgress.alternate = current), @@ -1872,60 +1867,66 @@ function createWorkInProgress(current, pendingProps) { workInProgress.treeBaseDuration = current.treeBaseDuration; return workInProgress; } -function createFiberFromElement(element, mode, expirationTime) { - var type = element.type, - key = element.key; - element = element.props; - var fiberTag = void 0; - if ("function" === typeof type) fiberTag = shouldConstruct(type) ? 2 : 4; - else if ("string" === typeof type) fiberTag = 7; +function createFiberFromTypeAndProps( + type, + key, + pendingProps, + owner, + mode, + expirationTime +) { + var fiberTag = 2; + owner = type; + if ("function" === typeof type) shouldConstruct(type) && (fiberTag = 1); + else if ("string" === typeof type) fiberTag = 5; else a: switch (type) { case REACT_FRAGMENT_TYPE: return createFiberFromFragment( - element.children, + pendingProps.children, mode, expirationTime, key ); case REACT_CONCURRENT_MODE_TYPE: - fiberTag = 10; - mode |= 3; - break; + return createFiberFromMode(pendingProps, mode | 3, expirationTime, key); case REACT_STRICT_MODE_TYPE: - fiberTag = 10; - mode |= 2; - break; + return createFiberFromMode(pendingProps, mode | 2, expirationTime, key); case REACT_PROFILER_TYPE: return ( - (type = new FiberNode(15, element, key, mode | 4)), + (type = createFiber(12, pendingProps, key, mode | 4)), + (type.elementType = REACT_PROFILER_TYPE), (type.type = REACT_PROFILER_TYPE), (type.expirationTime = expirationTime), type ); case REACT_SUSPENSE_TYPE: - fiberTag = 16; - break; + return ( + (type = createFiber(13, pendingProps, key, mode)), + (type.elementType = REACT_SUSPENSE_TYPE), + (type.type = REACT_SUSPENSE_TYPE), + (type.expirationTime = expirationTime), + type + ); default: if ("object" === typeof type && null !== type) switch (type.$$typeof) { case REACT_PROVIDER_TYPE: - fiberTag = 12; + fiberTag = 10; break a; case REACT_CONTEXT_TYPE: - fiberTag = 11; + fiberTag = 9; break a; case REACT_FORWARD_REF_TYPE: - fiberTag = 13; + fiberTag = 11; break a; - case REACT_PURE_TYPE: - fiberTag = 17; + case REACT_MEMO_TYPE: + fiberTag = 14; + break a; + case REACT_LAZY_TYPE: + fiberTag = 16; + owner = null; break a; - default: - if ("function" === typeof type.then) { - fiberTag = 4; - break a; - } } invariant( !1, @@ -1934,24 +1935,33 @@ function createFiberFromElement(element, mode, expirationTime) { "" ); } - mode = new FiberNode(fiberTag, element, key, mode); - mode.type = type; - mode.expirationTime = expirationTime; - return mode; + key = createFiber(fiberTag, pendingProps, key, mode); + key.elementType = type; + key.type = owner; + key.expirationTime = expirationTime; + return key; } function createFiberFromFragment(elements, mode, expirationTime, key) { - elements = new FiberNode(9, elements, key, mode); + elements = createFiber(7, elements, key, mode); elements.expirationTime = expirationTime; return elements; } +function createFiberFromMode(pendingProps, mode, expirationTime, key) { + pendingProps = createFiber(8, pendingProps, key, mode); + mode = 0 === (mode & 1) ? REACT_STRICT_MODE_TYPE : REACT_CONCURRENT_MODE_TYPE; + pendingProps.elementType = mode; + pendingProps.type = mode; + pendingProps.expirationTime = expirationTime; + return pendingProps; +} function createFiberFromText(content, mode, expirationTime) { - content = new FiberNode(8, content, null, mode); + content = createFiber(6, content, null, mode); content.expirationTime = expirationTime; return content; } function createFiberFromPortal(portal, mode, expirationTime) { - mode = new FiberNode( - 6, + mode = createFiber( + 4, null !== portal.children ? portal.children : [], portal.key, mode @@ -1969,9 +1979,9 @@ function markPendingPriorityLevel(root, expirationTime) { var earliestPendingTime = root.earliestPendingTime; 0 === earliestPendingTime ? (root.earliestPendingTime = root.latestPendingTime = expirationTime) - : earliestPendingTime > expirationTime + : earliestPendingTime < expirationTime ? (root.earliestPendingTime = expirationTime) - : root.latestPendingTime < expirationTime && + : root.latestPendingTime > expirationTime && (root.latestPendingTime = expirationTime); findNextExpirationTimeToWorkOn(expirationTime, root); } @@ -1986,19 +1996,19 @@ function markCommittedPriorityLevels(root, earliestRemainingTime) { else { var latestPendingTime = root.latestPendingTime; 0 !== latestPendingTime && - (latestPendingTime < earliestRemainingTime + (latestPendingTime > earliestRemainingTime ? (root.earliestPendingTime = root.latestPendingTime = 0) - : root.earliestPendingTime < earliestRemainingTime && + : root.earliestPendingTime > earliestRemainingTime && (root.earliestPendingTime = root.latestPendingTime)); latestPendingTime = root.earliestSuspendedTime; 0 === latestPendingTime ? markPendingPriorityLevel(root, earliestRemainingTime) - : earliestRemainingTime > root.latestSuspendedTime + : earliestRemainingTime < root.latestSuspendedTime ? ((root.earliestSuspendedTime = 0), (root.latestSuspendedTime = 0), (root.latestPingedTime = 0), markPendingPriorityLevel(root, earliestRemainingTime)) - : earliestRemainingTime < latestPendingTime && + : earliestRemainingTime > latestPendingTime && markPendingPriorityLevel(root, earliestRemainingTime); } findNextExpirationTimeToWorkOn(0, root); @@ -2008,17 +2018,17 @@ function hasLowerPriorityWork(root, erroredExpirationTime) { latestSuspendedTime = root.latestSuspendedTime; root = root.latestPingedTime; return ( - (0 !== latestPendingTime && latestPendingTime > erroredExpirationTime) || + (0 !== latestPendingTime && latestPendingTime < erroredExpirationTime) || (0 !== latestSuspendedTime && - latestSuspendedTime > erroredExpirationTime) || - (0 !== root && root > erroredExpirationTime) + latestSuspendedTime < erroredExpirationTime) || + (0 !== root && root < erroredExpirationTime) ); } function markSuspendedPriorityLevel(root, suspendedTime) { root.didError = !1; var latestPingedTime = root.latestPingedTime; 0 !== latestPingedTime && - latestPingedTime <= suspendedTime && + latestPingedTime >= suspendedTime && (root.latestPingedTime = 0); latestPingedTime = root.earliestPendingTime; var latestPendingTime = root.latestPendingTime; @@ -2033,22 +2043,18 @@ function markSuspendedPriorityLevel(root, suspendedTime) { latestPendingTime = root.latestSuspendedTime; 0 === latestPingedTime ? (root.earliestSuspendedTime = root.latestSuspendedTime = suspendedTime) - : latestPingedTime > suspendedTime + : latestPingedTime < suspendedTime ? (root.earliestSuspendedTime = suspendedTime) - : latestPendingTime < suspendedTime && + : latestPendingTime > suspendedTime && (root.latestSuspendedTime = suspendedTime); findNextExpirationTimeToWorkOn(suspendedTime, root); } function findEarliestOutstandingPriorityLevel(root, renderExpirationTime) { var earliestPendingTime = root.earliestPendingTime; root = root.earliestSuspendedTime; - if ( - 0 === renderExpirationTime || - (0 !== earliestPendingTime && earliestPendingTime < renderExpirationTime) - ) - renderExpirationTime = earliestPendingTime; - if (0 === renderExpirationTime || (0 !== root && root < renderExpirationTime)) - renderExpirationTime = root; + earliestPendingTime > renderExpirationTime && + (renderExpirationTime = earliestPendingTime); + root > renderExpirationTime && (renderExpirationTime = root); return renderExpirationTime; } function findNextExpirationTimeToWorkOn(completedExpirationTime, root) { @@ -2060,12 +2066,11 @@ function findNextExpirationTimeToWorkOn(completedExpirationTime, root) { 0 !== earliestPendingTime ? earliestPendingTime : latestPingedTime; 0 === earliestPendingTime && (0 === completedExpirationTime || - latestSuspendedTime > completedExpirationTime) && + latestSuspendedTime < completedExpirationTime) && (earliestPendingTime = latestSuspendedTime); completedExpirationTime = earliestPendingTime; 0 !== completedExpirationTime && - 0 !== earliestSuspendedTime && - earliestSuspendedTime < completedExpirationTime && + earliestSuspendedTime > completedExpirationTime && (completedExpirationTime = earliestSuspendedTime); root.nextExpirationTimeToWorkOn = earliestPendingTime; root.expirationTime = completedExpirationTime; @@ -2177,7 +2182,7 @@ function getStateFromUpdate( : workInProgress ); case 3: - workInProgress.effectTag = (workInProgress.effectTag & -1025) | 64; + workInProgress.effectTag = (workInProgress.effectTag & -2049) | 64; case 0: workInProgress = update.payload; nextProps = @@ -2210,58 +2215,52 @@ function processUpdateQueue( ) { var updateExpirationTime = update.expirationTime; - if (updateExpirationTime > renderExpirationTime) { - if ( - (null === newFirstUpdate && + updateExpirationTime < renderExpirationTime + ? (null === newFirstUpdate && ((newFirstUpdate = update), (newBaseState = resultState)), - 0 === newExpirationTime || newExpirationTime > updateExpirationTime) - ) - newExpirationTime = updateExpirationTime; - } else - (resultState = getStateFromUpdate( - workInProgress, - queue, - update, - resultState, - props, - instance - )), + newExpirationTime < updateExpirationTime && + (newExpirationTime = updateExpirationTime)) + : ((resultState = getStateFromUpdate( + workInProgress, + queue, + update, + resultState, + props, + instance + )), null !== update.callback && ((workInProgress.effectTag |= 32), (update.nextEffect = null), null === queue.lastEffect ? (queue.firstEffect = queue.lastEffect = update) : ((queue.lastEffect.nextEffect = update), - (queue.lastEffect = update))); + (queue.lastEffect = update)))); update = update.next; } updateExpirationTime = null; for (update = queue.firstCapturedUpdate; null !== update; ) { var _updateExpirationTime = update.expirationTime; - if (_updateExpirationTime > renderExpirationTime) { - if ( - (null === updateExpirationTime && + _updateExpirationTime < renderExpirationTime + ? (null === updateExpirationTime && ((updateExpirationTime = update), null === newFirstUpdate && (newBaseState = resultState)), - 0 === newExpirationTime || newExpirationTime > _updateExpirationTime) - ) - newExpirationTime = _updateExpirationTime; - } else - (resultState = getStateFromUpdate( - workInProgress, - queue, - update, - resultState, - props, - instance - )), + newExpirationTime < _updateExpirationTime && + (newExpirationTime = _updateExpirationTime)) + : ((resultState = getStateFromUpdate( + workInProgress, + queue, + update, + resultState, + props, + instance + )), null !== update.callback && ((workInProgress.effectTag |= 32), (update.nextEffect = null), null === queue.lastCapturedEffect ? (queue.firstCapturedEffect = queue.lastCapturedEffect = update) : ((queue.lastCapturedEffect.nextEffect = update), - (queue.lastCapturedEffect = update))); + (queue.lastCapturedEffect = update)))); update = update.next; } null === newFirstUpdate && (queue.lastUpdate = null); @@ -2342,13 +2341,277 @@ function readContext(context, observedBits) { null === lastContextDependency ? (invariant( null !== currentlyRenderingFiber, - "Context.unstable_read(): Context can only be read while React is rendering, e.g. inside the render method or getDerivedStateFromProps." + "Context can only be read while React is rendering, e.g. inside the render method or getDerivedStateFromProps." ), (currentlyRenderingFiber.firstContextDependency = lastContextDependency = observedBits)) : (lastContextDependency = lastContextDependency.next = observedBits); } return context._currentValue; } +var renderExpirationTime = 0, + currentlyRenderingFiber$1 = null, + firstCurrentHook = null, + currentHook = null, + firstWorkInProgressHook = null, + workInProgressHook = null, + remainingExpirationTime = 0, + componentUpdateQueue = null, + isReRender = !1, + didScheduleRenderPhaseUpdate = !1, + renderPhaseUpdates = null, + numberOfReRenders = 0; +function resolveCurrentlyRenderingFiber() { + invariant( + null !== currentlyRenderingFiber$1, + "Hooks can only be called inside the body of a function component." + ); + return currentlyRenderingFiber$1; +} +function finishHooks(Component, props, children, refOrContext) { + for (; didScheduleRenderPhaseUpdate; ) + (didScheduleRenderPhaseUpdate = !1), + (numberOfReRenders += 1), + (componentUpdateQueue = workInProgressHook = currentHook = null), + (children = Component(props, refOrContext)); + renderPhaseUpdates = null; + numberOfReRenders = 0; + Component = currentlyRenderingFiber$1; + Component.memoizedState = firstWorkInProgressHook; + Component.expirationTime = remainingExpirationTime; + Component.updateQueue = componentUpdateQueue; + Component = null !== currentHook && null !== currentHook.next; + renderExpirationTime = 0; + workInProgressHook = firstWorkInProgressHook = currentHook = firstCurrentHook = currentlyRenderingFiber$1 = null; + remainingExpirationTime = 0; + componentUpdateQueue = null; + invariant( + !Component, + "Rendered fewer hooks than expected. This may be caused by an accidental early return statement." + ); + return children; +} +function resetHooks() { + renderExpirationTime = 0; + workInProgressHook = firstWorkInProgressHook = currentHook = firstCurrentHook = currentlyRenderingFiber$1 = null; + remainingExpirationTime = 0; + componentUpdateQueue = null; + didScheduleRenderPhaseUpdate = !1; + renderPhaseUpdates = null; + numberOfReRenders = 0; +} +function createHook() { + return { + memoizedState: null, + baseState: null, + queue: null, + baseUpdate: null, + next: null + }; +} +function cloneHook(hook) { + return { + memoizedState: hook.memoizedState, + baseState: hook.memoizedState, + queue: hook.queue, + baseUpdate: hook.baseUpdate, + next: null + }; +} +function createWorkInProgressHook() { + if (null === workInProgressHook) + null === firstWorkInProgressHook + ? ((isReRender = !1), + (currentHook = firstCurrentHook), + (firstWorkInProgressHook = workInProgressHook = + null === currentHook ? createHook() : cloneHook(currentHook))) + : ((isReRender = !0), + (currentHook = firstCurrentHook), + (workInProgressHook = firstWorkInProgressHook)); + else if (null === workInProgressHook.next) { + isReRender = !1; + if (null === currentHook) var hook = createHook(); + else + (currentHook = currentHook.next), + (hook = null === currentHook ? createHook() : cloneHook(currentHook)); + workInProgressHook = workInProgressHook.next = hook; + } else + (isReRender = !0), + (workInProgressHook = workInProgressHook.next), + (currentHook = null !== currentHook ? currentHook.next : null); + return workInProgressHook; +} +function basicStateReducer(state, action) { + return "function" === typeof action ? action(state) : action; +} +function useReducer(reducer, initialState, initialAction) { + currentlyRenderingFiber$1 = resolveCurrentlyRenderingFiber(); + workInProgressHook = createWorkInProgressHook(); + var queue = workInProgressHook.queue; + if (null !== queue) { + if (isReRender) { + initialState = queue.dispatch; + if (null !== renderPhaseUpdates) { + var firstRenderPhaseUpdate = renderPhaseUpdates.get(queue); + if (void 0 !== firstRenderPhaseUpdate) { + renderPhaseUpdates.delete(queue); + initialAction = workInProgressHook.memoizedState; + do + (initialAction = reducer( + initialAction, + firstRenderPhaseUpdate.action + )), + (firstRenderPhaseUpdate = firstRenderPhaseUpdate.next); + while (null !== firstRenderPhaseUpdate); + workInProgressHook.memoizedState = initialAction; + workInProgressHook.baseUpdate === queue.last && + (workInProgressHook.baseState = initialAction); + return [initialAction, initialState]; + } + } + return [workInProgressHook.memoizedState, initialState]; + } + initialState = queue.last; + var _baseUpdate = workInProgressHook.baseUpdate; + null !== _baseUpdate + ? (null !== initialState && (initialState.next = null), + (initialState = _baseUpdate.next)) + : (initialState = null !== initialState ? initialState.next : null); + if (null !== initialState) { + initialAction = workInProgressHook.baseState; + var newBaseUpdate = (firstRenderPhaseUpdate = null), + _update = initialState, + didSkip = !1; + do { + var updateExpirationTime = _update.expirationTime; + updateExpirationTime < renderExpirationTime + ? (didSkip || + ((didSkip = !0), + (newBaseUpdate = _baseUpdate), + (firstRenderPhaseUpdate = initialAction)), + updateExpirationTime > remainingExpirationTime && + (remainingExpirationTime = updateExpirationTime)) + : (initialAction = reducer(initialAction, _update.action)); + _baseUpdate = _update; + _update = _update.next; + } while (null !== _update && _update !== initialState); + didSkip || + ((newBaseUpdate = _baseUpdate), + (firstRenderPhaseUpdate = initialAction)); + workInProgressHook.memoizedState = initialAction; + workInProgressHook.baseUpdate = newBaseUpdate; + workInProgressHook.baseState = firstRenderPhaseUpdate; + } + return [workInProgressHook.memoizedState, queue.dispatch]; + } + reducer === basicStateReducer + ? "function" === typeof initialState && (initialState = initialState()) + : void 0 !== initialAction && + null !== initialAction && + (initialState = reducer(initialState, initialAction)); + workInProgressHook.memoizedState = workInProgressHook.baseState = initialState; + queue = workInProgressHook.queue = { last: null, dispatch: null }; + reducer = queue.dispatch = dispatchAction.bind( + null, + currentlyRenderingFiber$1, + queue + ); + return [workInProgressHook.memoizedState, reducer]; +} +function pushEffect(tag, create, destroy, inputs) { + tag = { + tag: tag, + create: create, + destroy: destroy, + inputs: inputs, + next: null + }; + null === componentUpdateQueue + ? ((componentUpdateQueue = { lastEffect: null }), + (componentUpdateQueue.lastEffect = tag.next = tag)) + : ((create = componentUpdateQueue.lastEffect), + null === create + ? (componentUpdateQueue.lastEffect = tag.next = tag) + : ((destroy = create.next), + (create.next = tag), + (tag.next = destroy), + (componentUpdateQueue.lastEffect = tag))); + return tag; +} +function useEffectImpl(fiberEffectTag, hookEffectTag, create, inputs) { + currentlyRenderingFiber$1 = resolveCurrentlyRenderingFiber(); + workInProgressHook = createWorkInProgressHook(); + inputs = void 0 !== inputs && null !== inputs ? inputs : [create]; + var destroy = null; + if (null !== currentHook) { + var prevEffect = currentHook.memoizedState; + destroy = prevEffect.destroy; + if (inputsAreEqual(inputs, prevEffect.inputs)) { + pushEffect(0, create, destroy, inputs); + return; + } + } + currentlyRenderingFiber$1.effectTag |= fiberEffectTag; + workInProgressHook.memoizedState = pushEffect( + hookEffectTag, + create, + destroy, + inputs + ); +} +function dispatchAction(fiber, queue, action) { + invariant( + 25 > numberOfReRenders, + "Too many re-renders. React limits the number of renders to prevent an infinite loop." + ); + var alternate = fiber.alternate; + if ( + fiber === currentlyRenderingFiber$1 || + (null !== alternate && alternate === currentlyRenderingFiber$1) + ) + if ( + ((didScheduleRenderPhaseUpdate = !0), + (fiber = { + expirationTime: renderExpirationTime, + action: action, + next: null + }), + null === renderPhaseUpdates && (renderPhaseUpdates = new Map()), + (alternate = renderPhaseUpdates.get(queue)), + void 0 === alternate) + ) + renderPhaseUpdates.set(queue, fiber); + else { + for (queue = alternate; null !== queue.next; ) queue = queue.next; + queue.next = fiber; + } + else { + alternate = requestCurrentTime(); + alternate = computeExpirationForFiber(alternate, fiber); + action = { expirationTime: alternate, action: action, next: null }; + flushPassiveEffects(); + var _last2 = queue.last; + if (null === _last2) action.next = action; + else { + var first = _last2.next; + null !== first && (action.next = first); + _last2.next = action; + } + queue.last = action; + scheduleWork(fiber, alternate); + } +} +function inputsAreEqual(arr1, arr2) { + for (var i = 0; i < arr1.length; i++) { + var val1 = arr1[i], + val2 = arr2[i]; + if ( + (val1 !== val2 || (0 === val1 && 1 / val1 !== 1 / val2)) && + (val1 === val1 || val2 === val2) + ) + return !1; + } + return !0; +} var NO_CONTEXT = {}, contextStackCursor$1 = { current: NO_CONTEXT }, contextFiberStackCursor = { current: NO_CONTEXT }, @@ -2428,7 +2691,8 @@ function shallowEqual(objA, objB) { return !1; return !0; } -var emptyRefsObject = new React.Component().refs; +var ReactCurrentOwner$4 = ReactSharedInternals.ReactCurrentOwner, + emptyRefsObject = new React.Component().refs; function applyDerivedStateFromProps( workInProgress, ctor, @@ -2460,6 +2724,7 @@ var classComponentUpdater = { var update = createUpdate(currentTime); update.payload = payload; void 0 !== callback && null !== callback && (update.callback = callback); + flushPassiveEffects(); enqueueUpdate(inst, update); scheduleWork(inst, currentTime); }, @@ -2471,6 +2736,7 @@ var classComponentUpdater = { update.tag = 1; update.payload = payload; void 0 !== callback && null !== callback && (update.callback = callback); + flushPassiveEffects(); enqueueUpdate(inst, update); scheduleWork(inst, currentTime); }, @@ -2481,6 +2747,7 @@ var classComponentUpdater = { var update = createUpdate(currentTime); update.tag = 2; void 0 !== callback && null !== callback && (update.callback = callback); + flushPassiveEffects(); enqueueUpdate(inst, update); scheduleWork(inst, currentTime); } @@ -2501,6 +2768,32 @@ function checkShouldComponentUpdate( ? !shallowEqual(oldProps, newProps) || !shallowEqual(oldState, newState) : !0; } +function constructClassInstance(workInProgress, ctor, props) { + var isLegacyContextConsumer = !1, + unmaskedContext = emptyContextObject; + var context = ctor.contextType; + "object" === typeof context && null !== context + ? (context = ReactCurrentOwner$4.currentDispatcher.readContext(context)) + : ((unmaskedContext = isContextProvider(ctor) + ? previousContext + : contextStackCursor.current), + (isLegacyContextConsumer = ctor.contextTypes), + (context = (isLegacyContextConsumer = + null !== isLegacyContextConsumer && void 0 !== isLegacyContextConsumer) + ? getMaskedContext(workInProgress, unmaskedContext) + : emptyContextObject)); + ctor = new ctor(props, context); + workInProgress.memoizedState = + null !== ctor.state && void 0 !== ctor.state ? ctor.state : null; + ctor.updater = classComponentUpdater; + workInProgress.stateNode = ctor; + ctor._reactInternalFiber = workInProgress; + isLegacyContextConsumer && + ((workInProgress = workInProgress.stateNode), + (workInProgress.__reactInternalMemoizedUnmaskedChildContext = unmaskedContext), + (workInProgress.__reactInternalMemoizedMaskedChildContext = context)); + return ctor; +} function callComponentWillReceiveProps( workInProgress, instance, @@ -2527,7 +2820,9 @@ function mountClassInstance( instance.refs = emptyRefsObject; var contextType = ctor.contextType; "object" === typeof contextType && null !== contextType - ? (instance.context = contextType.unstable_read()) + ? (instance.context = ReactCurrentOwner$4.currentDispatcher.readContext( + contextType + )) : ((contextType = isContextProvider(ctor) ? previousContext : contextStackCursor.current), @@ -2582,10 +2877,7 @@ function coerceRef(returnFiber, current$$1, element) { element = element._owner; var inst = void 0; element && - (invariant( - 2 === element.tag || 3 === element.tag, - "Function components cannot have refs." - ), + (invariant(1 === element.tag, "Function components cannot have refs."), (inst = element.stateNode)); invariant( inst, @@ -2690,7 +2982,7 @@ function ChildReconciler(shouldTrackSideEffects) { textContent, expirationTime ) { - if (null === current$$1 || 8 !== current$$1.tag) + if (null === current$$1 || 6 !== current$$1.tag) return ( (current$$1 = createFiberFromText( textContent, @@ -2705,15 +2997,18 @@ function ChildReconciler(shouldTrackSideEffects) { return current$$1; } function updateElement(returnFiber, current$$1, element, expirationTime) { - if (null !== current$$1 && current$$1.type === element.type) + if (null !== current$$1 && current$$1.elementType === element.type) return ( (expirationTime = useFiber(current$$1, element.props, expirationTime)), (expirationTime.ref = coerceRef(returnFiber, current$$1, element)), (expirationTime.return = returnFiber), expirationTime ); - expirationTime = createFiberFromElement( - element, + expirationTime = createFiberFromTypeAndProps( + element.type, + element.key, + element.props, + null, returnFiber.mode, expirationTime ); @@ -2724,7 +3019,7 @@ function ChildReconciler(shouldTrackSideEffects) { function updatePortal(returnFiber, current$$1, portal, expirationTime) { if ( null === current$$1 || - 6 !== current$$1.tag || + 4 !== current$$1.tag || current$$1.stateNode.containerInfo !== portal.containerInfo || current$$1.stateNode.implementation !== portal.implementation ) @@ -2748,7 +3043,7 @@ function ChildReconciler(shouldTrackSideEffects) { expirationTime, key ) { - if (null === current$$1 || 9 !== current$$1.tag) + if (null === current$$1 || 7 !== current$$1.tag) return ( (current$$1 = createFiberFromFragment( fragment, @@ -2778,8 +3073,11 @@ function ChildReconciler(shouldTrackSideEffects) { switch (newChild.$$typeof) { case REACT_ELEMENT_TYPE: return ( - (expirationTime = createFiberFromElement( - newChild, + (expirationTime = createFiberFromTypeAndProps( + newChild.type, + newChild.key, + newChild.props, + null, returnFiber.mode, expirationTime )), @@ -3123,9 +3421,9 @@ function ChildReconciler(shouldTrackSideEffects) { ) { if (isUnkeyedTopLevelFragment.key === isObject) if ( - 9 === isUnkeyedTopLevelFragment.tag + 7 === isUnkeyedTopLevelFragment.tag ? newChild.type === REACT_FRAGMENT_TYPE - : isUnkeyedTopLevelFragment.type === newChild.type + : isUnkeyedTopLevelFragment.elementType === newChild.type ) { deleteRemainingChildren( returnFiber, @@ -3165,8 +3463,11 @@ function ChildReconciler(shouldTrackSideEffects) { )), (currentFirstChild.return = returnFiber), (returnFiber = currentFirstChild)) - : ((expirationTime = createFiberFromElement( - newChild, + : ((expirationTime = createFiberFromTypeAndProps( + newChild.type, + newChild.key, + newChild.props, + null, returnFiber.mode, expirationTime )), @@ -3188,7 +3489,7 @@ function ChildReconciler(shouldTrackSideEffects) { ) { if (currentFirstChild.key === isUnkeyedTopLevelFragment) if ( - 6 === currentFirstChild.tag && + 4 === currentFirstChild.tag && currentFirstChild.stateNode.containerInfo === newChild.containerInfo && currentFirstChild.stateNode.implementation === @@ -3226,7 +3527,7 @@ function ChildReconciler(shouldTrackSideEffects) { if ("string" === typeof newChild || "number" === typeof newChild) return ( (newChild = "" + newChild), - null !== currentFirstChild && 8 === currentFirstChild.tag + null !== currentFirstChild && 6 === currentFirstChild.tag ? (deleteRemainingChildren(returnFiber, currentFirstChild.sibling), (currentFirstChild = useFiber( currentFirstChild, @@ -3262,8 +3563,7 @@ function ChildReconciler(shouldTrackSideEffects) { isObject && throwOnInvalidObjectType(returnFiber, newChild); if ("undefined" === typeof newChild && !isUnkeyedTopLevelFragment) switch (returnFiber.tag) { - case 2: - case 3: + case 1: case 0: (expirationTime = returnFiber.type), invariant( @@ -3282,12 +3582,12 @@ var reconcileChildFibers = ChildReconciler(!0), isHydrating = !1; function tryHydrate(fiber, nextInstance) { switch (fiber.tag) { - case 7: + case 5: return ( (nextInstance = shim$1(nextInstance, fiber.type, fiber.pendingProps)), null !== nextInstance ? ((fiber.stateNode = nextInstance), !0) : !1 ); - case 8: + case 6: return ( (nextInstance = shim$1(nextInstance, fiber.pendingProps)), null !== nextInstance ? ((fiber.stateNode = nextInstance), !0) : !1 @@ -3310,7 +3610,8 @@ function tryToClaimNextHydratableInstance(fiber$jscomp$0) { return; } var returnFiber = hydrationParentFiber, - fiber = new FiberNode(7, null, null, 0); + fiber = createFiber(5, null, null, 0); + fiber.elementType = "DELETED"; fiber.type = "DELETED"; fiber.stateNode = firstAttemptedInstance; fiber.return = returnFiber; @@ -3328,36 +3629,33 @@ function tryToClaimNextHydratableInstance(fiber$jscomp$0) { (hydrationParentFiber = fiber$jscomp$0); } } -function readLazyComponentType(thenable) { - switch (thenable._reactStatus) { +function readLazyComponentType(lazyComponent) { + var result = lazyComponent._result; + switch (lazyComponent._status) { case 1: - return thenable._reactResult; + return result; case 2: - throw thenable._reactResult; + throw result; case 0: - throw thenable; + throw result; 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; - } + throw ((lazyComponent._status = 0), + (result = lazyComponent._ctor), + (result = result()), + result.then( + function(moduleObject) { + 0 === lazyComponent._status && + ((moduleObject = moduleObject.default), + (lazyComponent._status = 1), + (lazyComponent._result = moduleObject)); }, function(error) { - 0 === thenable._reactStatus && - ((thenable._reactStatus = 2), (thenable._reactResult = error)); + 0 === lazyComponent._status && + ((lazyComponent._status = 2), (lazyComponent._result = error)); } ), - thenable); + (lazyComponent._result = result), + result); } } var ReactCurrentOwner$3 = ReactSharedInternals.ReactCurrentOwner; @@ -3385,28 +3683,28 @@ function reconcileChildren( function updateForwardRef( current$$1, workInProgress, - type, + Component, nextProps, - renderExpirationTime + renderExpirationTime$jscomp$0 ) { - type = type.render; + Component = Component.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; + prepareToReadContext(workInProgress, renderExpirationTime$jscomp$0); + renderExpirationTime = renderExpirationTime$jscomp$0; + currentlyRenderingFiber$1 = workInProgress; + firstCurrentHook = null !== current$$1 ? current$$1.memoizedState : null; + var nextChildren = Component(nextProps, ref); + nextChildren = finishHooks(Component, nextProps, nextChildren, ref); + workInProgress.effectTag |= 1; + reconcileChildren( + current$$1, + workInProgress, + nextChildren, + renderExpirationTime$jscomp$0 + ); return workInProgress.child; } -function updatePureComponent( +function updateMemoComponent( current$$1, workInProgress, Component, @@ -3414,29 +3712,81 @@ function updatePureComponent( updateExpirationTime, renderExpirationTime ) { - var render = Component.render, - ref = workInProgress.ref; + if (null === current$$1) { + var type = Component.type; + if ( + "function" === typeof type && + !shouldConstruct(type) && + void 0 === type.defaultProps && + null === Component.compare + ) + return ( + (workInProgress.tag = 15), + (workInProgress.type = type), + updateSimpleMemoComponent( + current$$1, + workInProgress, + type, + nextProps, + updateExpirationTime, + renderExpirationTime + ) + ); + current$$1 = createFiberFromTypeAndProps( + Component.type, + null, + nextProps, + null, + workInProgress.mode, + renderExpirationTime + ); + current$$1.ref = workInProgress.ref; + current$$1.return = workInProgress; + return (workInProgress.child = current$$1); + } + type = current$$1.child; if ( - null !== current$$1 && - (0 === updateExpirationTime || - updateExpirationTime > renderExpirationTime) && - ((updateExpirationTime = current$$1.memoizedProps), + updateExpirationTime < renderExpirationTime && + ((updateExpirationTime = type.memoizedProps), (Component = Component.compare), (Component = null !== Component ? Component : shallowEqual), - workInProgress.ref === current$$1.ref && - Component(updateExpirationTime, nextProps)) + Component(updateExpirationTime, nextProps) && + current$$1.ref === workInProgress.ref) ) return bailoutOnAlreadyFinishedWork( current$$1, workInProgress, renderExpirationTime ); - prepareToReadContext(workInProgress, renderExpirationTime); - render = render(nextProps, ref); - workInProgress.effectTag |= 1; - reconcileChildren(current$$1, workInProgress, render, renderExpirationTime); - workInProgress.memoizedProps = nextProps; - return workInProgress.child; + current$$1 = createWorkInProgress(type, nextProps, renderExpirationTime); + current$$1.ref = workInProgress.ref; + current$$1.return = workInProgress; + return (workInProgress.child = current$$1); +} +function updateSimpleMemoComponent( + current$$1, + workInProgress, + Component, + nextProps, + updateExpirationTime, + renderExpirationTime +) { + return null !== current$$1 && + updateExpirationTime < renderExpirationTime && + shallowEqual(current$$1.memoizedProps, nextProps) && + current$$1.ref === workInProgress.ref + ? bailoutOnAlreadyFinishedWork( + current$$1, + workInProgress, + renderExpirationTime + ) + : updateFunctionComponent( + current$$1, + workInProgress, + Component, + nextProps, + renderExpirationTime + ); } function markRef(current$$1, workInProgress) { var ref = workInProgress.ref; @@ -3451,22 +3801,30 @@ function updateFunctionComponent( workInProgress, Component, nextProps, - renderExpirationTime + renderExpirationTime$jscomp$0 ) { var unmaskedContext = isContextProvider(Component) ? previousContext : contextStackCursor.current; unmaskedContext = getMaskedContext(workInProgress, unmaskedContext); - prepareToReadContext(workInProgress, renderExpirationTime); - Component = Component(nextProps, unmaskedContext); + prepareToReadContext(workInProgress, renderExpirationTime$jscomp$0); + renderExpirationTime = renderExpirationTime$jscomp$0; + currentlyRenderingFiber$1 = workInProgress; + firstCurrentHook = null !== current$$1 ? current$$1.memoizedState : null; + var nextChildren = Component(nextProps, unmaskedContext); + nextChildren = finishHooks( + Component, + nextProps, + nextChildren, + unmaskedContext + ); workInProgress.effectTag |= 1; reconcileChildren( current$$1, workInProgress, - Component, - renderExpirationTime + nextChildren, + renderExpirationTime$jscomp$0 ); - workInProgress.memoizedProps = nextProps; return workInProgress.child; } function updateClassComponent( @@ -3481,166 +3839,149 @@ function updateClassComponent( pushContextProvider(workInProgress); } else hasContext = !1; prepareToReadContext(workInProgress, renderExpirationTime); - if (null === current$$1) - if (null === workInProgress.stateNode) { - var isLegacyContextConsumer = !1, - unmaskedContext = emptyContextObject; - var context = Component.contextType; - "object" === typeof context && null !== context - ? (context = context.unstable_read()) - : ((unmaskedContext = isContextProvider(Component) - ? previousContext - : contextStackCursor.current), - (isLegacyContextConsumer = Component.contextTypes), - (context = (isLegacyContextConsumer = - null !== isLegacyContextConsumer && - void 0 !== isLegacyContextConsumer) - ? getMaskedContext(workInProgress, unmaskedContext) - : emptyContextObject)); - var instance = new Component(nextProps, context); - workInProgress.memoizedState = - null !== instance.state && void 0 !== instance.state - ? instance.state - : null; - instance.updater = classComponentUpdater; - workInProgress.stateNode = instance; - instance._reactInternalFiber = workInProgress; - isLegacyContextConsumer && - ((isLegacyContextConsumer = workInProgress.stateNode), - (isLegacyContextConsumer.__reactInternalMemoizedUnmaskedChildContext = unmaskedContext), - (isLegacyContextConsumer.__reactInternalMemoizedMaskedChildContext = context)); + if (null === workInProgress.stateNode) + null !== current$$1 && + ((current$$1.alternate = null), + (workInProgress.alternate = null), + (workInProgress.effectTag |= 2)), + constructClassInstance( + workInProgress, + Component, + nextProps, + renderExpirationTime + ), mountClassInstance( workInProgress, Component, nextProps, renderExpirationTime - ); - nextProps = !0; - } else { - unmaskedContext = workInProgress.stateNode; - isLegacyContextConsumer = workInProgress.memoizedProps; - unmaskedContext.props = isLegacyContextConsumer; - var oldContext = unmaskedContext.context; - context = Component.contextType; - "object" === typeof context && null !== context - ? (context = context.unstable_read()) - : ((context = isContextProvider(Component) - ? previousContext - : contextStackCursor.current), - (context = getMaskedContext(workInProgress, context))); - var getDerivedStateFromProps = Component.getDerivedStateFromProps; - (instance = + ), + (nextProps = !0); + else if (null === current$$1) { + var instance = workInProgress.stateNode, + oldProps = workInProgress.memoizedProps; + instance.props = oldProps; + var oldContext = instance.context, + contextType = Component.contextType; + "object" === typeof contextType && null !== contextType + ? (contextType = ReactCurrentOwner$4.currentDispatcher.readContext( + contextType + )) + : ((contextType = isContextProvider(Component) + ? previousContext + : contextStackCursor.current), + (contextType = getMaskedContext(workInProgress, contextType))); + var getDerivedStateFromProps = Component.getDerivedStateFromProps, + hasNewLifecycles = "function" === typeof getDerivedStateFromProps || - "function" === typeof unmaskedContext.getSnapshotBeforeUpdate) || - ("function" !== - typeof unmaskedContext.UNSAFE_componentWillReceiveProps && - "function" !== typeof unmaskedContext.componentWillReceiveProps) || - ((isLegacyContextConsumer !== nextProps || oldContext !== context) && - callComponentWillReceiveProps( - workInProgress, - unmaskedContext, - nextProps, - context - )); - hasForceUpdate = !1; - var oldState = workInProgress.memoizedState; - oldContext = unmaskedContext.state = oldState; - var updateQueue = workInProgress.updateQueue; - null !== updateQueue && - (processUpdateQueue( + "function" === typeof instance.getSnapshotBeforeUpdate; + hasNewLifecycles || + ("function" !== typeof instance.UNSAFE_componentWillReceiveProps && + "function" !== typeof instance.componentWillReceiveProps) || + ((oldProps !== nextProps || oldContext !== contextType) && + callComponentWillReceiveProps( workInProgress, - updateQueue, + instance, nextProps, - unmaskedContext, - renderExpirationTime - ), - (oldContext = workInProgress.memoizedState)); - isLegacyContextConsumer !== nextProps || - oldState !== oldContext || - didPerformWorkStackCursor.current || - hasForceUpdate - ? ("function" === typeof getDerivedStateFromProps && - (applyDerivedStateFromProps( - workInProgress, - Component, - getDerivedStateFromProps, - nextProps - ), - (oldContext = workInProgress.memoizedState)), - (isLegacyContextConsumer = - hasForceUpdate || - checkShouldComponentUpdate( - workInProgress, - Component, - isLegacyContextConsumer, - nextProps, - oldState, - oldContext, - context - )) - ? (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 = context), - (nextProps = isLegacyContextConsumer)) - : ("function" === typeof unmaskedContext.componentDidMount && - (workInProgress.effectTag |= 4), - (nextProps = !1)); - } - else - (unmaskedContext = workInProgress.stateNode), - (isLegacyContextConsumer = workInProgress.memoizedProps), - (unmaskedContext.props = isLegacyContextConsumer), - (oldContext = unmaskedContext.context), - (context = Component.contextType), - "object" === typeof context && null !== context - ? (context = context.unstable_read()) - : ((context = isContextProvider(Component) + contextType + )); + hasForceUpdate = !1; + var oldState = workInProgress.memoizedState; + oldContext = instance.state = oldState; + var updateQueue = workInProgress.updateQueue; + null !== updateQueue && + (processUpdateQueue( + workInProgress, + updateQueue, + nextProps, + instance, + renderExpirationTime + ), + (oldContext = workInProgress.memoizedState)); + oldProps !== nextProps || + oldState !== oldContext || + didPerformWorkStackCursor.current || + hasForceUpdate + ? ("function" === typeof getDerivedStateFromProps && + (applyDerivedStateFromProps( + workInProgress, + Component, + getDerivedStateFromProps, + nextProps + ), + (oldContext = workInProgress.memoizedState)), + (oldProps = + hasForceUpdate || + checkShouldComponentUpdate( + workInProgress, + Component, + oldProps, + nextProps, + oldState, + oldContext, + contextType + )) + ? (hasNewLifecycles || + ("function" !== typeof instance.UNSAFE_componentWillMount && + "function" !== typeof instance.componentWillMount) || + ("function" === typeof instance.componentWillMount && + instance.componentWillMount(), + "function" === typeof instance.UNSAFE_componentWillMount && + instance.UNSAFE_componentWillMount()), + "function" === typeof instance.componentDidMount && + (workInProgress.effectTag |= 4)) + : ("function" === typeof instance.componentDidMount && + (workInProgress.effectTag |= 4), + (workInProgress.memoizedProps = nextProps), + (workInProgress.memoizedState = oldContext)), + (instance.props = nextProps), + (instance.state = oldContext), + (instance.context = contextType), + (nextProps = oldProps)) + : ("function" === typeof instance.componentDidMount && + (workInProgress.effectTag |= 4), + (nextProps = !1)); + } else + (instance = workInProgress.stateNode), + (oldProps = workInProgress.memoizedProps), + (instance.props = oldProps), + (oldContext = instance.context), + (contextType = Component.contextType), + "object" === typeof contextType && null !== contextType + ? (contextType = ReactCurrentOwner$4.currentDispatcher.readContext( + contextType + )) + : ((contextType = isContextProvider(Component) ? previousContext : contextStackCursor.current), - (context = getMaskedContext(workInProgress, context))), + (contextType = getMaskedContext(workInProgress, contextType))), (getDerivedStateFromProps = Component.getDerivedStateFromProps), - (instance = + (hasNewLifecycles = "function" === typeof getDerivedStateFromProps || - "function" === typeof unmaskedContext.getSnapshotBeforeUpdate) || - ("function" !== - typeof unmaskedContext.UNSAFE_componentWillReceiveProps && - "function" !== typeof unmaskedContext.componentWillReceiveProps) || - ((isLegacyContextConsumer !== nextProps || oldContext !== context) && + "function" === typeof instance.getSnapshotBeforeUpdate) || + ("function" !== typeof instance.UNSAFE_componentWillReceiveProps && + "function" !== typeof instance.componentWillReceiveProps) || + ((oldProps !== nextProps || oldContext !== contextType) && callComponentWillReceiveProps( workInProgress, - unmaskedContext, + instance, nextProps, - context + contextType )), (hasForceUpdate = !1), (oldContext = workInProgress.memoizedState), - (oldState = unmaskedContext.state = oldContext), + (oldState = instance.state = oldContext), (updateQueue = workInProgress.updateQueue), null !== updateQueue && (processUpdateQueue( workInProgress, updateQueue, nextProps, - unmaskedContext, + instance, renderExpirationTime ), (oldState = workInProgress.memoizedState)), - isLegacyContextConsumer !== nextProps || + oldProps !== nextProps || oldContext !== oldState || didPerformWorkStackCursor.current || hasForceUpdate @@ -3657,53 +3998,51 @@ function updateClassComponent( checkShouldComponentUpdate( workInProgress, Component, - isLegacyContextConsumer, + oldProps, nextProps, oldContext, oldState, - context + contextType )) - ? (instance || - ("function" !== - typeof unmaskedContext.UNSAFE_componentWillUpdate && - "function" !== typeof unmaskedContext.componentWillUpdate) || - ("function" === typeof unmaskedContext.componentWillUpdate && - unmaskedContext.componentWillUpdate( + ? (hasNewLifecycles || + ("function" !== typeof instance.UNSAFE_componentWillUpdate && + "function" !== typeof instance.componentWillUpdate) || + ("function" === typeof instance.componentWillUpdate && + instance.componentWillUpdate( nextProps, oldState, - context + contextType ), - "function" === - typeof unmaskedContext.UNSAFE_componentWillUpdate && - unmaskedContext.UNSAFE_componentWillUpdate( + "function" === typeof instance.UNSAFE_componentWillUpdate && + instance.UNSAFE_componentWillUpdate( nextProps, oldState, - context + contextType )), - "function" === typeof unmaskedContext.componentDidUpdate && + "function" === typeof instance.componentDidUpdate && (workInProgress.effectTag |= 4), - "function" === typeof unmaskedContext.getSnapshotBeforeUpdate && + "function" === typeof instance.getSnapshotBeforeUpdate && (workInProgress.effectTag |= 256)) - : ("function" !== typeof unmaskedContext.componentDidUpdate || - (isLegacyContextConsumer === current$$1.memoizedProps && + : ("function" !== typeof instance.componentDidUpdate || + (oldProps === current$$1.memoizedProps && oldContext === current$$1.memoizedState) || (workInProgress.effectTag |= 4), - "function" !== typeof unmaskedContext.getSnapshotBeforeUpdate || - (isLegacyContextConsumer === current$$1.memoizedProps && + "function" !== typeof instance.getSnapshotBeforeUpdate || + (oldProps === current$$1.memoizedProps && oldContext === current$$1.memoizedState) || (workInProgress.effectTag |= 256), (workInProgress.memoizedProps = nextProps), (workInProgress.memoizedState = oldState)), - (unmaskedContext.props = nextProps), - (unmaskedContext.state = oldState), - (unmaskedContext.context = context), + (instance.props = nextProps), + (instance.state = oldState), + (instance.context = contextType), (nextProps = getDerivedStateFromProps)) - : ("function" !== typeof unmaskedContext.componentDidUpdate || - (isLegacyContextConsumer === current$$1.memoizedProps && + : ("function" !== typeof instance.componentDidUpdate || + (oldProps === current$$1.memoizedProps && oldContext === current$$1.memoizedState) || (workInProgress.effectTag |= 4), - "function" !== typeof unmaskedContext.getSnapshotBeforeUpdate || - (isLegacyContextConsumer === current$$1.memoizedProps && + "function" !== typeof instance.getSnapshotBeforeUpdate || + (oldProps === current$$1.memoizedProps && oldContext === current$$1.memoizedState) || (workInProgress.effectTag |= 256), (nextProps = !1)); @@ -3766,7 +4105,6 @@ function finishClassComponent( renderExpirationTime ); workInProgress.memoizedState = shouldUpdate.state; - workInProgress.memoizedProps = shouldUpdate.props; hasContext && invalidateContextProvider(workInProgress, Component, !0); return workInProgress.child; } @@ -3792,6 +4130,105 @@ function resolveDefaultProps(Component, baseProps) { } return baseProps; } +function updateSuspenseComponent( + current$$1, + workInProgress, + renderExpirationTime +) { + var mode = workInProgress.mode, + nextProps = workInProgress.pendingProps, + nextState = workInProgress.memoizedState; + null !== nextState && + (nextState.alreadyCaptured + ? null !== current$$1 && nextState === current$$1.memoizedState + ? (nextState = { + alreadyCaptured: !0, + didTimeout: !0, + timedOutAt: nextState.timedOutAt + }) + : ((nextState.alreadyCaptured = !0), (nextState.didTimeout = !0)) + : (nextState = null)); + var nextDidTimeout = null !== nextState && nextState.didTimeout; + if (null === current$$1) + nextDidTimeout + ? ((nextDidTimeout = nextProps.fallback), + (nextProps = createFiberFromFragment(null, mode, 0, null)), + (mode = createFiberFromFragment( + nextDidTimeout, + mode, + renderExpirationTime, + null + )), + (nextProps.sibling = mode), + (renderExpirationTime = nextProps), + (renderExpirationTime.return = mode.return = workInProgress)) + : (renderExpirationTime = mode = mountChildFibers( + workInProgress, + null, + nextProps.children, + renderExpirationTime + )); + else { + var prevState = current$$1.memoizedState; + null !== prevState && prevState.didTimeout + ? ((mode = current$$1.child), + (current$$1 = mode.sibling), + nextDidTimeout + ? ((renderExpirationTime = nextProps.fallback), + (mode = createWorkInProgress(mode, mode.pendingProps, 0)), + (mode.effectTag |= 2), + (nextProps = mode.sibling = createWorkInProgress( + current$$1, + renderExpirationTime, + current$$1.expirationTime + )), + (nextProps.effectTag |= 2), + (renderExpirationTime = mode), + (mode.childExpirationTime = 0), + (mode = nextProps), + (renderExpirationTime.return = mode.return = workInProgress)) + : ((nextDidTimeout = current$$1.child), + (mode = reconcileChildFibers( + workInProgress, + mode.child, + nextProps.children, + renderExpirationTime + )), + reconcileChildFibers( + workInProgress, + nextDidTimeout, + null, + renderExpirationTime + ), + (renderExpirationTime = mode))) + : ((current$$1 = current$$1.child), + nextDidTimeout + ? ((nextDidTimeout = nextProps.fallback), + (nextProps = createFiberFromFragment(null, mode, 0, null)), + (nextProps.effectTag |= 2), + (nextProps.child = current$$1), + (current$$1.return = nextProps), + (mode = nextProps.sibling = createFiberFromFragment( + nextDidTimeout, + mode, + renderExpirationTime, + null + )), + (mode.effectTag |= 2), + (renderExpirationTime = nextProps), + (nextProps.childExpirationTime = 0), + (renderExpirationTime.return = mode.return = workInProgress)) + : (mode = renderExpirationTime = reconcileChildFibers( + workInProgress, + current$$1, + nextProps.children, + renderExpirationTime + ))); + } + workInProgress.memoizedState = nextState; + workInProgress.child = renderExpirationTime; + return mode; +} function bailoutOnAlreadyFinishedWork( current$$1, workInProgress, @@ -3800,9 +4237,7 @@ function bailoutOnAlreadyFinishedWork( null !== current$$1 && (workInProgress.firstContextDependency = current$$1.firstContextDependency); profilerStartTime = -1; - var childExpirationTime = workInProgress.childExpirationTime; - if (0 === childExpirationTime || childExpirationTime > renderExpirationTime) - return null; + if (workInProgress.childExpirationTime < renderExpirationTime) return null; invariant( null === current$$1 || workInProgress.child === current$$1.child, "Resuming work not yet implemented." @@ -3831,561 +4266,566 @@ function bailoutOnAlreadyFinishedWork( } return workInProgress.child; } -function beginWork(current$$1, workInProgress, renderExpirationTime) { +function beginWork(current$$1, workInProgress, renderExpirationTime$jscomp$0) { var updateExpirationTime = workInProgress.expirationTime; if ( null !== current$$1 && current$$1.memoizedProps === workInProgress.pendingProps && !didPerformWorkStackCursor.current && - (0 === updateExpirationTime || updateExpirationTime > renderExpirationTime) + updateExpirationTime < renderExpirationTime$jscomp$0 ) { switch (workInProgress.tag) { - case 5: + case 3: pushHostRootContext(workInProgress); break; - case 7: + case 5: pushHostContext(workInProgress); break; - case 2: + case 1: isContextProvider(workInProgress.type) && pushContextProvider(workInProgress); break; - case 3: - isContextProvider(workInProgress.type._reactResult) && - pushContextProvider(workInProgress); - break; - case 6: + case 4: pushHostContainer( workInProgress, workInProgress.stateNode.containerInfo ); break; - case 12: + case 10: pushProvider(workInProgress, workInProgress.memoizedProps.value); break; - case 15: + case 12: workInProgress.effectTag |= 4; + break; + case 13: + if ( + ((updateExpirationTime = workInProgress.memoizedState), + null !== updateExpirationTime && updateExpirationTime.didTimeout) + ) { + updateExpirationTime = workInProgress.child.childExpirationTime; + if ( + 0 !== updateExpirationTime && + updateExpirationTime >= renderExpirationTime$jscomp$0 + ) + return updateSuspenseComponent( + current$$1, + workInProgress, + renderExpirationTime$jscomp$0 + ); + workInProgress = bailoutOnAlreadyFinishedWork( + current$$1, + workInProgress, + renderExpirationTime$jscomp$0 + ); + return null !== workInProgress ? workInProgress.sibling : null; + } } return bailoutOnAlreadyFinishedWork( current$$1, workInProgress, - renderExpirationTime + renderExpirationTime$jscomp$0 ); } workInProgress.expirationTime = 0; switch (workInProgress.tag) { - case 4: - var Component = workInProgress.type; - 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 resolvedTag = (workInProgress.tag = resolveLazyComponentTag( - workInProgress, - Component - )), - resolvedProps = resolveDefaultProps(Component, props), - child = void 0; - switch (resolvedTag) { - case 1: - child = updateFunctionComponent( - current$$1, - workInProgress, - Component, - resolvedProps, - renderExpirationTime - ); - break; - case 3: - child = updateClassComponent( - current$$1, - workInProgress, - Component, - resolvedProps, - renderExpirationTime - ); - break; - case 14: - child = updateForwardRef( - current$$1, - workInProgress, - Component, - resolvedProps, - renderExpirationTime - ); - break; - case 18: - child = updatePureComponent( - current$$1, - workInProgress, - Component, - resolvedProps, - updateExpirationTime, - renderExpirationTime - ); - break; - default: - invariant( - !1, - "Element type is invalid. Received a promise that resolves to: %s. Promise elements must resolve to a class or function.", - Component - ); - } - workInProgress.memoizedProps = props; - workInProgress = child; - } else - (updateExpirationTime = getMaskedContext( - workInProgress, - contextStackCursor.current - )), - prepareToReadContext(workInProgress, renderExpirationTime), - (updateExpirationTime = Component(props, updateExpirationTime)), - (workInProgress.effectTag |= 1), - "object" === typeof updateExpirationTime && - null !== updateExpirationTime && - "function" === typeof updateExpirationTime.render && - void 0 === updateExpirationTime.$$typeof - ? ((workInProgress.tag = 2), - isContextProvider(Component) - ? ((resolvedTag = !0), pushContextProvider(workInProgress)) - : (resolvedTag = !1), - (workInProgress.memoizedState = - null !== updateExpirationTime.state && - void 0 !== updateExpirationTime.state - ? updateExpirationTime.state - : null), - (resolvedProps = Component.getDerivedStateFromProps), - "function" === typeof resolvedProps && - applyDerivedStateFromProps( - workInProgress, - Component, - resolvedProps, - props - ), - (updateExpirationTime.updater = classComponentUpdater), - (workInProgress.stateNode = updateExpirationTime), - (updateExpirationTime._reactInternalFiber = workInProgress), - mountClassInstance( - workInProgress, - Component, - props, - renderExpirationTime - ), - (workInProgress = finishClassComponent( - current$$1, - workInProgress, - Component, - !0, - resolvedTag, - renderExpirationTime - ))) - : ((workInProgress.tag = 0), - reconcileChildren( - current$$1, - workInProgress, - updateExpirationTime, - renderExpirationTime - ), - (workInProgress.memoizedProps = props), - (workInProgress = workInProgress.child)); - return workInProgress; - case 0: - return updateFunctionComponent( - current$$1, + case 2: + updateExpirationTime = workInProgress.elementType; + null !== current$$1 && + ((current$$1.alternate = null), + (workInProgress.alternate = null), + (workInProgress.effectTag |= 2)); + current$$1 = workInProgress.pendingProps; + var context = getMaskedContext( workInProgress, - workInProgress.type, - workInProgress.pendingProps, - renderExpirationTime + contextStackCursor.current + ); + prepareToReadContext(workInProgress, renderExpirationTime$jscomp$0); + renderExpirationTime = renderExpirationTime$jscomp$0; + currentlyRenderingFiber$1 = workInProgress; + firstCurrentHook = null; + var value = updateExpirationTime(current$$1, context); + workInProgress.effectTag |= 1; + if ( + "object" === typeof value && + null !== value && + "function" === typeof value.render && + void 0 === value.$$typeof + ) { + workInProgress.tag = 1; + resetHooks(); + isContextProvider(updateExpirationTime) + ? ((context = !0), pushContextProvider(workInProgress)) + : (context = !1); + workInProgress.memoizedState = + null !== value.state && void 0 !== value.state ? value.state : null; + var getDerivedStateFromProps = + updateExpirationTime.getDerivedStateFromProps; + "function" === typeof getDerivedStateFromProps && + applyDerivedStateFromProps( + workInProgress, + updateExpirationTime, + getDerivedStateFromProps, + current$$1 + ); + value.updater = classComponentUpdater; + workInProgress.stateNode = value; + value._reactInternalFiber = workInProgress; + mountClassInstance( + workInProgress, + updateExpirationTime, + current$$1, + renderExpirationTime$jscomp$0 + ); + workInProgress = finishClassComponent( + null, + workInProgress, + updateExpirationTime, + !0, + context, + renderExpirationTime$jscomp$0 + ); + } else + (workInProgress.tag = 0), + (value = finishHooks( + updateExpirationTime, + current$$1, + value, + context + )), + reconcileChildren( + null, + workInProgress, + value, + renderExpirationTime$jscomp$0 + ), + (workInProgress = workInProgress.child); + return workInProgress; + case 16: + value = workInProgress.elementType; + null !== current$$1 && + ((current$$1.alternate = null), + (workInProgress.alternate = null), + (workInProgress.effectTag |= 2)); + context = workInProgress.pendingProps; + current$$1 = readLazyComponentType(value); + workInProgress.type = current$$1; + value = workInProgress.tag = resolveLazyComponentTag(current$$1); + context = resolveDefaultProps(current$$1, context); + getDerivedStateFromProps = void 0; + switch (value) { + case 0: + getDerivedStateFromProps = updateFunctionComponent( + null, + workInProgress, + current$$1, + context, + renderExpirationTime$jscomp$0 + ); + break; + case 1: + getDerivedStateFromProps = updateClassComponent( + null, + workInProgress, + current$$1, + context, + renderExpirationTime$jscomp$0 + ); + break; + case 11: + getDerivedStateFromProps = updateForwardRef( + null, + workInProgress, + current$$1, + context, + renderExpirationTime$jscomp$0 + ); + break; + case 14: + getDerivedStateFromProps = updateMemoComponent( + null, + workInProgress, + current$$1, + resolveDefaultProps(current$$1.type, context), + updateExpirationTime, + renderExpirationTime$jscomp$0 + ); + break; + default: + invariant( + !1, + "Element type is invalid. Received a promise that resolves to: %s. Promise elements must resolve to a class or function.", + current$$1 + ); + } + return getDerivedStateFromProps; + case 0: + return ( + (updateExpirationTime = workInProgress.type), + (value = workInProgress.pendingProps), + (value = + workInProgress.elementType === updateExpirationTime + ? value + : resolveDefaultProps(updateExpirationTime, value)), + updateFunctionComponent( + current$$1, + workInProgress, + updateExpirationTime, + value, + renderExpirationTime$jscomp$0 + ) ); case 1: return ( - (props = workInProgress.type._reactResult), - (Component = workInProgress.pendingProps), - (current$$1 = updateFunctionComponent( + (updateExpirationTime = workInProgress.type), + (value = workInProgress.pendingProps), + (value = + workInProgress.elementType === updateExpirationTime + ? value + : resolveDefaultProps(updateExpirationTime, value)), + updateClassComponent( current$$1, workInProgress, - props, - resolveDefaultProps(props, Component), - renderExpirationTime - )), - (workInProgress.memoizedProps = Component), - current$$1 - ); - case 2: - return updateClassComponent( - current$$1, - workInProgress, - workInProgress.type, - workInProgress.pendingProps, - renderExpirationTime + updateExpirationTime, + value, + renderExpirationTime$jscomp$0 + ) ); case 3: - return ( - (props = workInProgress.type._reactResult), - (Component = workInProgress.pendingProps), - (current$$1 = updateClassComponent( - current$$1, - workInProgress, - props, - resolveDefaultProps(props, Component), - renderExpirationTime - )), - (workInProgress.memoizedProps = Component), - current$$1 - ); - case 5: return ( pushHostRootContext(workInProgress), - (Component = workInProgress.updateQueue), + (updateExpirationTime = workInProgress.updateQueue), invariant( - null !== Component, + 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." ), - (props = workInProgress.memoizedState), - (props = null !== props ? props.element : null), + (value = workInProgress.memoizedState), + (value = null !== value ? value.element : null), processUpdateQueue( workInProgress, - Component, + updateExpirationTime, workInProgress.pendingProps, null, - renderExpirationTime + renderExpirationTime$jscomp$0 ), - (Component = workInProgress.memoizedState.element), - Component === props + (updateExpirationTime = workInProgress.memoizedState.element), + updateExpirationTime === value ? (workInProgress = bailoutOnAlreadyFinishedWork( current$$1, workInProgress, - renderExpirationTime + renderExpirationTime$jscomp$0 )) : (reconcileChildren( current$$1, workInProgress, - Component, - renderExpirationTime + updateExpirationTime, + renderExpirationTime$jscomp$0 ), (workInProgress = workInProgress.child)), workInProgress ); - case 7: + case 5: return ( pushHostContext(workInProgress), null === current$$1 && tryToClaimNextHydratableInstance(workInProgress), - (Component = workInProgress.pendingProps), - (props = Component.children), + (updateExpirationTime = workInProgress.pendingProps.children), markRef(current$$1, workInProgress), reconcileChildren( current$$1, workInProgress, - props, - renderExpirationTime + updateExpirationTime, + renderExpirationTime$jscomp$0 ), - (workInProgress.memoizedProps = Component), (workInProgress = workInProgress.child), workInProgress ); - case 8: + case 6: return ( null === current$$1 && tryToClaimNextHydratableInstance(workInProgress), - (workInProgress.memoizedProps = workInProgress.pendingProps), null ); - case 16: - return ( - (Component = workInProgress.pendingProps), - (props = 0 === (workInProgress.effectTag & 64)), - null !== current$$1 && null !== workInProgress.updateQueue - ? ((workInProgress.updateQueue = null), (props = !0)) - : (props = !props), - 0 !== (workInProgress.mode & 2) && - (props - ? (workInProgress.effectTag |= 4) - : (workInProgress.stateNode = null)), - (updateExpirationTime = Component.children), - (updateExpirationTime = - "function" === typeof updateExpirationTime - ? updateExpirationTime(props) - : props - ? Component.fallback - : updateExpirationTime), - null !== current$$1 && props !== workInProgress.memoizedState - ? ((workInProgress.child = reconcileChildFibers( - workInProgress, - current$$1.child, - null, - renderExpirationTime - )), - (workInProgress.child = reconcileChildFibers( - workInProgress, - null, - updateExpirationTime, - renderExpirationTime - ))) - : reconcileChildren( - current$$1, - workInProgress, - updateExpirationTime, - renderExpirationTime - ), - (workInProgress.memoizedProps = Component), - (workInProgress.memoizedState = props), - workInProgress.child + case 13: + return updateSuspenseComponent( + current$$1, + workInProgress, + renderExpirationTime$jscomp$0 ); - case 6: + case 4: return ( pushHostContainer( workInProgress, workInProgress.stateNode.containerInfo ), - (Component = workInProgress.pendingProps), + (updateExpirationTime = workInProgress.pendingProps), null === current$$1 ? (workInProgress.child = reconcileChildFibers( workInProgress, null, - Component, - renderExpirationTime + updateExpirationTime, + renderExpirationTime$jscomp$0 )) : reconcileChildren( current$$1, workInProgress, - Component, - renderExpirationTime + updateExpirationTime, + renderExpirationTime$jscomp$0 ), - (workInProgress.memoizedProps = Component), workInProgress.child ); - case 13: - return updateForwardRef( - current$$1, - workInProgress, - workInProgress.type, - workInProgress.pendingProps, - renderExpirationTime - ); - case 14: + case 11: return ( - (props = workInProgress.type._reactResult), - (Component = workInProgress.pendingProps), - (current$$1 = updateForwardRef( + (updateExpirationTime = workInProgress.type), + (value = workInProgress.pendingProps), + (value = + workInProgress.elementType === updateExpirationTime + ? value + : resolveDefaultProps(updateExpirationTime, value)), + updateForwardRef( current$$1, workInProgress, - props, - resolveDefaultProps(props, Component), - renderExpirationTime - )), - (workInProgress.memoizedProps = Component), - current$$1 + updateExpirationTime, + value, + renderExpirationTime$jscomp$0 + ) ); - case 9: + case 7: return ( - (Component = workInProgress.pendingProps), reconcileChildren( current$$1, workInProgress, - Component, - renderExpirationTime + workInProgress.pendingProps, + renderExpirationTime$jscomp$0 ), - (workInProgress.memoizedProps = Component), workInProgress.child ); - case 10: + case 8: return ( - (Component = workInProgress.pendingProps.children), reconcileChildren( current$$1, workInProgress, - Component, - renderExpirationTime + workInProgress.pendingProps.children, + renderExpirationTime$jscomp$0 ), - (workInProgress.memoizedProps = Component), - workInProgress.child - ); - case 15: - return ( - (workInProgress.effectTag |= 4), - (Component = workInProgress.pendingProps), - reconcileChildren( - current$$1, - workInProgress, - Component.children, - renderExpirationTime - ), - (workInProgress.memoizedProps = Component), workInProgress.child ); case 12: + return ( + (workInProgress.effectTag |= 4), + reconcileChildren( + current$$1, + workInProgress, + workInProgress.pendingProps.children, + renderExpirationTime$jscomp$0 + ), + workInProgress.child + ); + case 10: a: { - Component = workInProgress.type._context; - props = workInProgress.pendingProps; - resolvedTag = workInProgress.memoizedProps; - updateExpirationTime = props.value; - workInProgress.memoizedProps = props; - pushProvider(workInProgress, updateExpirationTime); - if (null !== resolvedTag) - if ( - ((resolvedProps = resolvedTag.value), - (updateExpirationTime = - (resolvedProps === updateExpirationTime && - (0 !== resolvedProps || - 1 / resolvedProps === 1 / updateExpirationTime)) || - (resolvedProps !== resolvedProps && - updateExpirationTime !== updateExpirationTime) - ? 0 - : ("function" === typeof Component._calculateChangedBits - ? Component._calculateChangedBits( - resolvedProps, - updateExpirationTime - ) - : 1073741823) | 0), - 0 === updateExpirationTime) - ) { + updateExpirationTime = workInProgress.type._context; + value = workInProgress.pendingProps; + getDerivedStateFromProps = workInProgress.memoizedProps; + context = value.value; + pushProvider(workInProgress, context); + if (null !== getDerivedStateFromProps) { + var oldValue = getDerivedStateFromProps.value; + context = + (oldValue === context && + (0 !== oldValue || 1 / oldValue === 1 / context)) || + (oldValue !== oldValue && context !== context) + ? 0 + : ("function" === + typeof updateExpirationTime._calculateChangedBits + ? updateExpirationTime._calculateChangedBits( + oldValue, + context + ) + : 1073741823) | 0; + if (0 === context) { if ( - resolvedTag.children === props.children && + getDerivedStateFromProps.children === value.children && !didPerformWorkStackCursor.current ) { workInProgress = bailoutOnAlreadyFinishedWork( current$$1, workInProgress, - renderExpirationTime + renderExpirationTime$jscomp$0 ); break a; } } else for ( - resolvedTag = workInProgress.child, - null !== resolvedTag && (resolvedTag.return = workInProgress); - null !== resolvedTag; + getDerivedStateFromProps = workInProgress.child, + null !== getDerivedStateFromProps && + (getDerivedStateFromProps.return = workInProgress); + null !== getDerivedStateFromProps; ) { - resolvedProps = resolvedTag.firstContextDependency; - if (null !== resolvedProps) { + oldValue = getDerivedStateFromProps.firstContextDependency; + if (null !== oldValue) { do { if ( - resolvedProps.context === Component && - 0 !== (resolvedProps.observedBits & updateExpirationTime) + oldValue.context === updateExpirationTime && + 0 !== (oldValue.observedBits & context) ) { - if (2 === resolvedTag.tag || 3 === resolvedTag.tag) - (child = createUpdate(renderExpirationTime)), - (child.tag = 2), - enqueueUpdate(resolvedTag, child); - if ( - 0 === resolvedTag.expirationTime || - resolvedTag.expirationTime > renderExpirationTime - ) - resolvedTag.expirationTime = renderExpirationTime; - child = resolvedTag.alternate; - null !== child && - (0 === child.expirationTime || - child.expirationTime > renderExpirationTime) && - (child.expirationTime = renderExpirationTime); - for (var node = resolvedTag.return; null !== node; ) { - child = node.alternate; + if (1 === getDerivedStateFromProps.tag) { + var nextFiber = createUpdate( + renderExpirationTime$jscomp$0 + ); + nextFiber.tag = 2; + enqueueUpdate(getDerivedStateFromProps, nextFiber); + } + getDerivedStateFromProps.expirationTime < + renderExpirationTime$jscomp$0 && + (getDerivedStateFromProps.expirationTime = renderExpirationTime$jscomp$0); + nextFiber = getDerivedStateFromProps.alternate; + null !== nextFiber && + nextFiber.expirationTime < + renderExpirationTime$jscomp$0 && + (nextFiber.expirationTime = renderExpirationTime$jscomp$0); + for ( + var node = getDerivedStateFromProps.return; + null !== node; + + ) { + nextFiber = node.alternate; if ( - 0 === node.childExpirationTime || - node.childExpirationTime > renderExpirationTime + node.childExpirationTime < renderExpirationTime$jscomp$0 ) - (node.childExpirationTime = renderExpirationTime), - null !== child && - (0 === child.childExpirationTime || - child.childExpirationTime > - renderExpirationTime) && - (child.childExpirationTime = renderExpirationTime); + (node.childExpirationTime = renderExpirationTime$jscomp$0), + null !== nextFiber && + nextFiber.childExpirationTime < + renderExpirationTime$jscomp$0 && + (nextFiber.childExpirationTime = renderExpirationTime$jscomp$0); else if ( - null !== child && - (0 === child.childExpirationTime || - child.childExpirationTime > renderExpirationTime) + null !== nextFiber && + nextFiber.childExpirationTime < + renderExpirationTime$jscomp$0 ) - child.childExpirationTime = renderExpirationTime; + nextFiber.childExpirationTime = renderExpirationTime$jscomp$0; else break; node = node.return; } } - child = resolvedTag.child; - resolvedProps = resolvedProps.next; - } while (null !== resolvedProps); + nextFiber = getDerivedStateFromProps.child; + oldValue = oldValue.next; + } while (null !== oldValue); } else - child = - 12 === resolvedTag.tag - ? resolvedTag.type === workInProgress.type + nextFiber = + 10 === getDerivedStateFromProps.tag + ? getDerivedStateFromProps.type === workInProgress.type ? null - : resolvedTag.child - : resolvedTag.child; - if (null !== child) child.return = resolvedTag; + : getDerivedStateFromProps.child + : getDerivedStateFromProps.child; + if (null !== nextFiber) + nextFiber.return = getDerivedStateFromProps; else - for (child = resolvedTag; null !== child; ) { - if (child === workInProgress) { - child = null; + for ( + nextFiber = getDerivedStateFromProps; + null !== nextFiber; + + ) { + if (nextFiber === workInProgress) { + nextFiber = null; break; } - resolvedTag = child.sibling; - if (null !== resolvedTag) { - resolvedTag.return = child.return; - child = resolvedTag; + getDerivedStateFromProps = nextFiber.sibling; + if (null !== getDerivedStateFromProps) { + getDerivedStateFromProps.return = nextFiber.return; + nextFiber = getDerivedStateFromProps; break; } - child = child.return; + nextFiber = nextFiber.return; } - resolvedTag = child; + getDerivedStateFromProps = nextFiber; } + } reconcileChildren( current$$1, workInProgress, - props.children, - renderExpirationTime + value.children, + renderExpirationTime$jscomp$0 ); workInProgress = workInProgress.child; } return workInProgress; - case 11: + case 9: return ( - (updateExpirationTime = workInProgress.type), - (Component = workInProgress.pendingProps), - (props = Component.children), - prepareToReadContext(workInProgress, renderExpirationTime), - (updateExpirationTime = readContext( - updateExpirationTime, - Component.unstable_observedBits - )), - (props = props(updateExpirationTime)), + (value = workInProgress.type), + (context = workInProgress.pendingProps), + (updateExpirationTime = context.children), + prepareToReadContext(workInProgress, renderExpirationTime$jscomp$0), + (value = readContext(value, context.unstable_observedBits)), + (updateExpirationTime = updateExpirationTime(value)), (workInProgress.effectTag |= 1), reconcileChildren( current$$1, workInProgress, - props, - renderExpirationTime + updateExpirationTime, + renderExpirationTime$jscomp$0 ), - (workInProgress.memoizedProps = Component), workInProgress.child ); - case 17: - return updatePureComponent( + case 14: + return ( + (value = workInProgress.type), + (context = resolveDefaultProps( + value.type, + workInProgress.pendingProps + )), + updateMemoComponent( + current$$1, + workInProgress, + value, + context, + updateExpirationTime, + renderExpirationTime$jscomp$0 + ) + ); + case 15: + return updateSimpleMemoComponent( current$$1, workInProgress, workInProgress.type, workInProgress.pendingProps, updateExpirationTime, - renderExpirationTime + renderExpirationTime$jscomp$0 ); - case 18: + case 17: return ( - (props = workInProgress.type._reactResult), - (Component = workInProgress.pendingProps), - (current$$1 = updatePureComponent( - current$$1, + (updateExpirationTime = workInProgress.type), + (value = workInProgress.pendingProps), + (value = + workInProgress.elementType === updateExpirationTime + ? value + : resolveDefaultProps(updateExpirationTime, value)), + null !== current$$1 && + ((current$$1.alternate = null), + (workInProgress.alternate = null), + (workInProgress.effectTag |= 2)), + (workInProgress.tag = 1), + isContextProvider(updateExpirationTime) + ? ((current$$1 = !0), pushContextProvider(workInProgress)) + : (current$$1 = !1), + prepareToReadContext(workInProgress, renderExpirationTime$jscomp$0), + constructClassInstance( workInProgress, - props, - resolveDefaultProps(props, Component), updateExpirationTime, - renderExpirationTime - )), - (workInProgress.memoizedProps = Component), - current$$1 + value, + renderExpirationTime$jscomp$0 + ), + mountClassInstance( + workInProgress, + updateExpirationTime, + value, + renderExpirationTime$jscomp$0 + ), + finishClassComponent( + null, + workInProgress, + updateExpirationTime, + !0, + current$$1, + renderExpirationTime$jscomp$0 + ) ); default: invariant( @@ -4394,9 +4834,27 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { ); } } -var updateHostContainer = void 0, +var appendAllChildren = void 0, + updateHostContainer = void 0, updateHostComponent$1 = void 0, updateHostText$1 = void 0; +appendAllChildren = function(parent, workInProgress) { + for (var node = workInProgress.child; null !== node; ) { + if (5 === node.tag || 6 === node.tag) parent._children.push(node.stateNode); + else if (4 !== node.tag && null !== node.child) { + node.child.return = node; + node = node.child; + continue; + } + if (node === workInProgress) break; + for (; null === node.sibling; ) { + if (null === node.return || node.return === workInProgress) return; + node = node.return; + } + node.sibling.return = node.return; + node = node.sibling; + } +}; updateHostContainer = function() {}; updateHostComponent$1 = function(current, workInProgress, type, newProps) { current.memoizedProps !== newProps && @@ -4426,7 +4884,6 @@ function logCapturedError(capturedError) { : Error("Unspecified error at:" + componentStack); ExceptionsManager.handleException(error, !1); } -var emptyObject$1 = {}; function logError(boundary, errorInfo) { var source = errorInfo.source, stack = errorInfo.stack; @@ -4443,7 +4900,7 @@ function logError(boundary, errorInfo) { willRetry: !1 }; null !== boundary && - 2 === boundary.tag && + 1 === boundary.tag && ((errorInfo.errorBoundary = boundary.stateNode), (errorInfo.errorBoundaryName = getComponentName(boundary.type)), (errorInfo.errorBoundaryFound = !0), @@ -4467,32 +4924,74 @@ function safelyDetachRef(current$$1) { } else ref.current = null; } -function commitUnmount(current$$1) { +function commitHookEffectList(unmountTag, mountTag, finishedWork) { + finishedWork = finishedWork.updateQueue; + finishedWork = null !== finishedWork ? finishedWork.lastEffect : null; + if (null !== finishedWork) { + var effect = (finishedWork = finishedWork.next); + do { + if (0 !== (effect.tag & unmountTag)) { + var destroy = effect.destroy; + effect.destroy = null; + null !== destroy && destroy(); + } + 0 !== (effect.tag & mountTag) && + ((destroy = effect.create), + (destroy = destroy()), + (effect.destroy = "function" === typeof destroy ? destroy : null)); + effect = effect.next; + } while (effect !== finishedWork); + } +} +function commitUnmount(current$$1$jscomp$0) { "function" === typeof onCommitFiberUnmount && - onCommitFiberUnmount(current$$1); - switch (current$$1.tag) { - case 2: - case 3: - safelyDetachRef(current$$1); - var instance = current$$1.stateNode; - if ("function" === typeof instance.componentWillUnmount) + onCommitFiberUnmount(current$$1$jscomp$0); + switch (current$$1$jscomp$0.tag) { + case 0: + case 11: + case 14: + case 15: + var updateQueue = current$$1$jscomp$0.updateQueue; + if ( + null !== updateQueue && + ((updateQueue = updateQueue.lastEffect), null !== updateQueue) + ) { + var effect = (updateQueue = updateQueue.next); + do { + var destroy = effect.destroy; + if (null !== destroy) { + var current$$1 = current$$1$jscomp$0; + try { + destroy(); + } catch (error) { + captureCommitPhaseError(current$$1, error); + } + } + effect = effect.next; + } while (effect !== updateQueue); + } + break; + case 1: + safelyDetachRef(current$$1$jscomp$0); + updateQueue = current$$1$jscomp$0.stateNode; + if ("function" === typeof updateQueue.componentWillUnmount) try { - (instance.props = current$$1.memoizedProps), - (instance.state = current$$1.memoizedState), - instance.componentWillUnmount(); + (updateQueue.props = current$$1$jscomp$0.memoizedProps), + (updateQueue.state = current$$1$jscomp$0.memoizedState), + updateQueue.componentWillUnmount(); } catch (unmountError) { - captureCommitPhaseError(current$$1, unmountError); + captureCommitPhaseError(current$$1$jscomp$0, unmountError); } break; - case 7: - safelyDetachRef(current$$1); + case 5: + safelyDetachRef(current$$1$jscomp$0); break; - case 6: - unmountHostComponents(current$$1); + case 4: + unmountHostComponents(current$$1$jscomp$0); } } function isHostParent(fiber) { - return 7 === fiber.tag || 5 === fiber.tag || 6 === fiber.tag; + return 5 === fiber.tag || 3 === fiber.tag || 4 === fiber.tag; } function commitPlacement(finishedWork) { a: { @@ -4511,15 +5010,15 @@ function commitPlacement(finishedWork) { } var isContainer = (parent = void 0); switch (parentFiber.tag) { - case 7: + case 5: parent = parentFiber.stateNode; isContainer = !1; break; - case 5: + case 3: parent = parentFiber.stateNode.containerInfo; isContainer = !0; break; - case 6: + case 4: parent = parentFiber.stateNode.containerInfo; isContainer = !0; break; @@ -4541,11 +5040,11 @@ function commitPlacement(finishedWork) { parentFiber.sibling.return = parentFiber.return; for ( parentFiber = parentFiber.sibling; - 7 !== parentFiber.tag && 8 !== parentFiber.tag; + 5 !== parentFiber.tag && 6 !== parentFiber.tag; ) { if (parentFiber.effectTag & 2) continue b; - if (null === parentFiber.child || 6 === parentFiber.tag) continue b; + if (null === parentFiber.child || 4 === parentFiber.tag) continue b; else (parentFiber.child.return = parentFiber), (parentFiber = parentFiber.child); @@ -4556,7 +5055,7 @@ function commitPlacement(finishedWork) { } } for (var node = finishedWork; ; ) { - if (7 === node.tag || 8 === node.tag) + if (5 === node.tag || 6 === node.tag) if (parentFiber) if (isContainer) invariant( @@ -4625,7 +5124,7 @@ function commitPlacement(finishedWork) { [index.length - 1], [] ))); - else if (6 !== node.tag && null !== node.child) { + else if (4 !== node.tag && null !== node.child) { node.child.return = node; node = node.child; continue; @@ -4656,15 +5155,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 7: + case 5: currentParent = currentParentIsValid.stateNode; currentParentIsContainer = !1; break a; - case 5: + case 3: currentParent = currentParentIsValid.stateNode.containerInfo; currentParentIsContainer = !0; break a; - case 6: + case 4: currentParent = currentParentIsValid.stateNode.containerInfo; currentParentIsContainer = !0; break a; @@ -4673,11 +5172,11 @@ function unmountHostComponents(current$$1) { } currentParentIsValid = !0; } - if (7 === node.tag || 8 === node.tag) { + if (5 === node.tag || 6 === node.tag) { a: for (var root = node, node$jscomp$0 = root; ; ) if ( (commitUnmount(node$jscomp$0), - null !== node$jscomp$0.child && 6 !== node$jscomp$0.tag) + null !== node$jscomp$0.child && 4 !== node$jscomp$0.tag) ) (node$jscomp$0.child.return = node$jscomp$0), (node$jscomp$0 = node$jscomp$0.child); @@ -4705,7 +5204,7 @@ function unmountHostComponents(current$$1) { UIManager.manageChildren(root._nativeTag, [], [], [], [], [child]); } } else if ( - (6 === node.tag + (4 === node.tag ? ((currentParent = node.stateNode.containerInfo), (currentParentIsContainer = !0)) : commitUnmount(node), @@ -4719,7 +5218,7 @@ function unmountHostComponents(current$$1) { for (; null === node.sibling; ) { if (null === node.return || node.return === current$$1) return; node = node.return; - 6 === node.tag && (currentParentIsValid = !1); + 4 === node.tag && (currentParentIsValid = !1); } node.sibling.return = node.return; node = node.sibling; @@ -4727,10 +5226,15 @@ function unmountHostComponents(current$$1) { } function commitWork(current$$1, finishedWork) { switch (finishedWork.tag) { - case 2: - case 3: + case 0: + case 11: + case 14: + case 15: + commitHookEffectList(4, 8, finishedWork); break; - case 7: + case 1: + break; + case 5: var instance = finishedWork.stateNode; if (null != instance) { var newProps = finishedWork.memoizedProps; @@ -4754,7 +5258,7 @@ function commitWork(current$$1, finishedWork) { )); } break; - case 8: + case 6: 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." @@ -4763,11 +5267,13 @@ function commitWork(current$$1, finishedWork) { text: finishedWork.memoizedProps }); break; - case 5: + case 3: break; - case 15: + case 12: break; - case 16: + case 13: + break; + case 17: break; default: invariant( @@ -4776,9 +5282,6 @@ function commitWork(current$$1, finishedWork) { ); } } -function NoopComponent() { - return null; -} function createRootErrorUpdate(fiber, errorInfo, expirationTime) { expirationTime = createUpdate(expirationTime); expirationTime.tag = 3; @@ -4824,7 +5327,7 @@ function throwException( value, renderExpirationTime ) { - sourceFiber.effectTag |= 512; + sourceFiber.effectTag |= 1024; sourceFiber.firstEffect = sourceFiber.lastEffect = null; if ( null !== value && @@ -4836,49 +5339,54 @@ function throwException( var earliestTimeoutMs = -1, startTimeMs = -1; do { - if (16 === value.tag) { - var current = value.alternate; + if (13 === value.tag) { + var current$$1 = value.alternate; if ( - null !== current && - !0 === current.memoizedState && - null !== current.stateNode + null !== current$$1 && + ((current$$1 = current$$1.memoizedState), + null !== current$$1 && current$$1.didTimeout) ) { - startTimeMs = 10 * (current.stateNode.timedOutAt - 2); + startTimeMs = 10 * (1073741822 - current$$1.timedOutAt); break; } - current = value.pendingProps.maxDuration; - if ("number" === typeof current) - if (0 >= current) earliestTimeoutMs = 0; - else if (-1 === earliestTimeoutMs || current < earliestTimeoutMs) - earliestTimeoutMs = current; + current$$1 = value.pendingProps.maxDuration; + if ("number" === typeof current$$1) + if (0 >= current$$1) earliestTimeoutMs = 0; + else if (-1 === earliestTimeoutMs || current$$1 < earliestTimeoutMs) + earliestTimeoutMs = current$$1; } value = value.return; } while (null !== value); value = returnFiber; do { - if (16 === value.tag && !value.memoizedState) { + if ((current$$1 = 13 === value.tag)) + void 0 === value.memoizedProps.fallback + ? (current$$1 = !1) + : ((current$$1 = value.memoizedState), + (current$$1 = null === current$$1 || !current$$1.didTimeout)); + if (current$$1) { returnFiber = retrySuspendedRoot.bind( null, root, value, - 0 === (value.mode & 1) ? 1 : renderExpirationTime + sourceFiber, + 0 === (value.mode & 1) ? 1073741823 : renderExpirationTime ); returnFiber = tracing.unstable_wrap(returnFiber); thenable.then(returnFiber, returnFiber); - if (0 === (value.mode & 2)) { - value.effectTag |= 4; + if (0 === (value.mode & 1)) { + value.effectTag |= 32; reconcileChildren( sourceFiber.alternate, sourceFiber, null, renderExpirationTime ); - sourceFiber.effectTag &= -513; - 4 === sourceFiber.tag && (sourceFiber.tag = 0); - if (2 === sourceFiber.tag || 3 === sourceFiber.tag) - (sourceFiber.effectTag &= -421), - null === sourceFiber.alternate && - ((sourceFiber.tag = 0), (sourceFiber.type = NoopComponent)); + sourceFiber.effectTag &= -1025; + sourceFiber.effectTag &= -933; + 1 === sourceFiber.tag && + null === sourceFiber.alternate && + (sourceFiber.tag = 17); return; } -1 === earliestTimeoutMs @@ -4886,24 +5394,26 @@ function throwException( : (-1 === startTimeMs && (startTimeMs = 10 * - (findEarliestOutstandingPriorityLevel( - root, - renderExpirationTime - ) - - 2) - + (1073741822 - + findEarliestOutstandingPriorityLevel( + root, + renderExpirationTime + )) - 5e3), (root = startTimeMs + earliestTimeoutMs)); 0 <= root && nextLatestAbsoluteTimeoutMs < root && (nextLatestAbsoluteTimeoutMs = root); - value.effectTag |= 1024; + value.effectTag |= 2048; value.expirationTime = renderExpirationTime; return; } value = value.return; } while (null !== value); value = Error( - "An update was suspended, but no placeholder UI was provided." + (getComponentName(sourceFiber.type) || "A React component") + + " suspended while rendering, but no fallback UI was specified.\n\nAdd a component higher in the tree to provide a loading indicator or placeholder to display." + + getStackByFiberInDevAndProd(sourceFiber) ); } nextRenderDidError = !0; @@ -4911,9 +5421,9 @@ function throwException( root = returnFiber; do { switch (root.tag) { - case 5: + case 3: sourceFiber = value; - root.effectTag |= 1024; + root.effectTag |= 2048; root.expirationTime = renderExpirationTime; renderExpirationTime = createRootErrorUpdate( root, @@ -4922,8 +5432,7 @@ function throwException( ); enqueueCapturedUpdate(root, renderExpirationTime); return; - case 2: - case 3: + case 1: if ( ((sourceFiber = value), (returnFiber = root.type), @@ -4935,7 +5444,7 @@ function throwException( (null === legacyErrorBoundariesThatAlreadyFailed || !legacyErrorBoundariesThatAlreadyFailed.has(thenable))))) ) { - root.effectTag |= 1024; + root.effectTag |= 2048; root.expirationTime = renderExpirationTime; renderExpirationTime = createClassErrorUpdate( root, @@ -4951,24 +5460,14 @@ function throwException( } function unwindWork(workInProgress) { switch (workInProgress.tag) { - case 2: + case 1: isContextProvider(workInProgress.type) && popContext(workInProgress); var effectTag = workInProgress.effectTag; - return effectTag & 1024 - ? ((workInProgress.effectTag = (effectTag & -1025) | 64), + return effectTag & 2048 + ? ((workInProgress.effectTag = (effectTag & -2049) | 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), @@ -4977,28 +5476,117 @@ function unwindWork(workInProgress) { 0 === (effectTag & 64), "The root failed to unmount after an error. This is likely a bug in React. Please file an issue." ), - (workInProgress.effectTag = (effectTag & -1025) | 64), + (workInProgress.effectTag = (effectTag & -2049) | 64), workInProgress ); - case 7: + case 5: return popHostContext(workInProgress), null; - case 16: - return ( - (effectTag = workInProgress.effectTag), - effectTag & 1024 - ? ((workInProgress.effectTag = (effectTag & -1025) | 64), - workInProgress) - : null - ); - case 6: + case 13: + effectTag = workInProgress.effectTag; + if (effectTag & 2048) { + workInProgress.effectTag = (effectTag & -2049) | 64; + effectTag = workInProgress.alternate; + effectTag = null !== effectTag ? effectTag.memoizedState : null; + var nextState = workInProgress.memoizedState; + null === nextState + ? (nextState = { alreadyCaptured: !0, didTimeout: !1, timedOutAt: 0 }) + : effectTag === nextState + ? (nextState = { + alreadyCaptured: !0, + didTimeout: nextState.didTimeout, + timedOutAt: nextState.timedOutAt + }) + : (nextState.alreadyCaptured = !0); + workInProgress.memoizedState = nextState; + return workInProgress; + } + return null; + case 4: return popHostContainer(workInProgress), null; - case 12: + case 10: return popProvider(workInProgress), null; default: return null; } } -var Dispatcher = { readContext: readContext }, +var Dispatcher = { + readContext: readContext, + useCallback: function(callback, inputs) { + currentlyRenderingFiber$1 = resolveCurrentlyRenderingFiber(); + workInProgressHook = createWorkInProgressHook(); + inputs = void 0 !== inputs && null !== inputs ? inputs : [callback]; + var prevState = workInProgressHook.memoizedState; + if (null !== prevState && inputsAreEqual(inputs, prevState[1])) + return prevState[0]; + workInProgressHook.memoizedState = [callback, inputs]; + return callback; + }, + useContext: function(context, observedBits) { + resolveCurrentlyRenderingFiber(); + return readContext(context, observedBits); + }, + useEffect: function(create, inputs) { + useEffectImpl(516, 192, create, inputs); + }, + useImperativeMethods: function(ref, create, inputs) { + inputs = + null !== inputs && void 0 !== inputs + ? inputs.concat([ref]) + : [ref, create]; + useEffectImpl( + 4, + 36, + function() { + if ("function" === typeof ref) { + var _inst = create(); + ref(_inst); + return function() { + return ref(null); + }; + } + if (null !== ref && void 0 !== ref) + return ( + (_inst = create()), + (ref.current = _inst), + function() { + ref.current = null; + } + ); + }, + inputs + ); + }, + useLayoutEffect: function(create, inputs) { + useEffectImpl(4, 36, create, inputs); + }, + useMemo: function(nextCreate, inputs) { + currentlyRenderingFiber$1 = resolveCurrentlyRenderingFiber(); + workInProgressHook = createWorkInProgressHook(); + inputs = void 0 !== inputs && null !== inputs ? inputs : [nextCreate]; + var prevState = workInProgressHook.memoizedState; + if (null !== prevState && inputsAreEqual(inputs, prevState[1])) + return prevState[0]; + nextCreate = nextCreate(); + workInProgressHook.memoizedState = [nextCreate, inputs]; + return nextCreate; + }, + useMutationEffect: function(create, inputs) { + useEffectImpl(260, 10, create, inputs); + }, + useReducer: useReducer, + useRef: function(initialValue) { + currentlyRenderingFiber$1 = resolveCurrentlyRenderingFiber(); + workInProgressHook = createWorkInProgressHook(); + null === workInProgressHook.memoizedState + ? ((initialValue = { current: initialValue }), + (workInProgressHook.memoizedState = initialValue)) + : (initialValue = workInProgressHook.memoizedState); + return initialValue; + }, + useState: function(initialState) { + return useReducer(basicStateReducer, initialState); + } + }, ReactCurrentOwner$2 = ReactSharedInternals.ReactCurrentOwner; invariant( null != tracing.__interactionsRef && @@ -5013,6 +5601,9 @@ var isWorking = !1, nextRenderDidError = !1, nextEffect = null, isCommitting$1 = !1, + rootWithPendingPassiveEffects = null, + passiveEffectCallbackHandle = null, + passiveEffectCallback = null, legacyErrorBoundariesThatAlreadyFailed = null; function resetStack() { if (null !== nextUnitOfWork) @@ -5023,7 +5614,7 @@ function resetStack() { ) { var interruptedWork$jscomp$0 = interruptedWork; switch (interruptedWork$jscomp$0.tag) { - case 2: + case 1: var childContextTypes = interruptedWork$jscomp$0.type.childContextTypes; null !== childContextTypes && @@ -5031,23 +5622,16 @@ function resetStack() { 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 7: + case 5: popHostContext(interruptedWork$jscomp$0); break; - case 6: + case 4: popHostContainer(interruptedWork$jscomp$0); break; - case 12: + case 10: popProvider(interruptedWork$jscomp$0); } interruptedWork = interruptedWork.return; @@ -5097,13 +5681,17 @@ function commitAllHostEffects() { } function commitBeforeMutationLifecycles() { for (; null !== nextEffect; ) { - if (nextEffect.effectTag & 256) { - var current$$1 = nextEffect.alternate; + if (nextEffect.effectTag & 256) a: { - var finishedWork = nextEffect; + var current$$1 = nextEffect.alternate, + finishedWork = nextEffect; switch (finishedWork.tag) { - case 2: - case 3: + case 0: + case 11: + case 15: + commitHookEffectList(2, 0, finishedWork); + break a; + case 1: if (finishedWork.effectTag & 256 && null !== current$$1) { var prevProps = current$$1.memoizedProps, prevState = current$$1.memoizedState; @@ -5117,10 +5705,11 @@ function commitBeforeMutationLifecycles() { current$$1.__reactInternalSnapshotBeforeUpdate = finishedWork; } break a; + case 3: case 5: - case 7: - case 8: case 6: + case 4: + case 17: break a; default: invariant( @@ -5129,7 +5718,6 @@ function commitBeforeMutationLifecycles() { ); } } - } nextEffect = nextEffect.nextEffect; } } @@ -5140,73 +5728,76 @@ function commitAllLifeCycles( for (; null !== nextEffect; ) { var effectTag = nextEffect.effectTag; if (effectTag & 36) { - var finishedRoot = finishedRoot$jscomp$0, - current$$1 = nextEffect.alternate, - finishedWork = nextEffect, + var finishedRoot = finishedRoot$jscomp$0; + var newDidTimeout = nextEffect.alternate; + var finishedWork = nextEffect, committedExpirationTime = committedExpirationTime$jscomp$0; switch (finishedWork.tag) { - case 2: - case 3: + case 0: + case 11: + case 15: + commitHookEffectList(16, 32, finishedWork); + break; + case 1: finishedRoot = finishedWork.stateNode; if (finishedWork.effectTag & 4) - if (null === current$$1) + if (null === newDidTimeout) (finishedRoot.props = finishedWork.memoizedProps), (finishedRoot.state = finishedWork.memoizedState), finishedRoot.componentDidMount(); else { - var prevProps = current$$1.memoizedProps; - current$$1 = current$$1.memoizedState; + var prevProps = newDidTimeout.memoizedProps; + newDidTimeout = newDidTimeout.memoizedState; finishedRoot.props = finishedWork.memoizedProps; finishedRoot.state = finishedWork.memoizedState; finishedRoot.componentDidUpdate( prevProps, - current$$1, + newDidTimeout, finishedRoot.__reactInternalSnapshotBeforeUpdate ); } - current$$1 = finishedWork.updateQueue; - null !== current$$1 && + newDidTimeout = finishedWork.updateQueue; + null !== newDidTimeout && ((finishedRoot.props = finishedWork.memoizedProps), (finishedRoot.state = finishedWork.memoizedState), commitUpdateQueue( finishedWork, - current$$1, + newDidTimeout, finishedRoot, committedExpirationTime )); break; - case 5: - current$$1 = finishedWork.updateQueue; - if (null !== current$$1) { + case 3: + newDidTimeout = finishedWork.updateQueue; + if (null !== newDidTimeout) { finishedRoot = null; if (null !== finishedWork.child) switch (finishedWork.child.tag) { - case 7: + case 5: finishedRoot = finishedWork.child.stateNode; break; - case 2: - case 3: + case 1: finishedRoot = finishedWork.child.stateNode; } commitUpdateQueue( finishedWork, - current$$1, + newDidTimeout, finishedRoot, committedExpirationTime ); } break; - case 7: - break; - case 8: + case 5: break; case 6: break; - case 15: + case 4: + break; + case 12: committedExpirationTime = finishedWork.memoizedProps.onRender; committedExpirationTime( finishedWork.memoizedProps.id, - null === current$$1 ? "mount" : "update", + null === newDidTimeout ? "mount" : "update", finishedWork.actualDuration, finishedWork.treeBaseDuration, finishedWork.actualStartTime, @@ -5214,14 +5805,54 @@ function commitAllLifeCycles( finishedRoot.memoizedInteractions ); break; - case 16: - 0 === (finishedWork.mode & 2) - ? ((finishedWork.updateQueue = emptyObject$1), - scheduleWork(finishedWork, 1)) - : ((committedExpirationTime = requestCurrentTime()), - (finishedWork.stateNode = { - timedOutAt: committedExpirationTime - })); + case 13: + if (finishedWork.effectTag & 32) { + finishedWork.memoizedState = { + alreadyCaptured: !0, + didTimeout: !1, + timedOutAt: 0 + }; + flushPassiveEffects(); + scheduleWork(finishedWork, 1073741823); + break; + } + newDidTimeout = + null !== newDidTimeout ? newDidTimeout.memoizedState : null; + committedExpirationTime = finishedWork.memoizedState; + finishedRoot = null !== newDidTimeout ? newDidTimeout.didTimeout : !1; + prevProps = finishedWork; + if (null === committedExpirationTime) newDidTimeout = !1; + else if ((newDidTimeout = committedExpirationTime.didTimeout)) + (prevProps = finishedWork.child), + (committedExpirationTime.alreadyCaptured = !1), + 0 === committedExpirationTime.timedOutAt && + (committedExpirationTime.timedOutAt = requestCurrentTime()); + if (newDidTimeout !== finishedRoot && null !== prevProps) + a: for (committedExpirationTime = finishedWork = prevProps; ; ) { + if (5 === committedExpirationTime.tag) + throw Error("Not yet implemented."); + if (6 === committedExpirationTime.tag) + throw Error("Not yet implemented."); + if (null !== committedExpirationTime.child) + (committedExpirationTime.child.return = committedExpirationTime), + (committedExpirationTime = committedExpirationTime.child); + else { + if (committedExpirationTime === finishedWork) break a; + for (; null === committedExpirationTime.sibling; ) { + if ( + null === committedExpirationTime.return || + committedExpirationTime.return === finishedWork + ) + break a; + committedExpirationTime = committedExpirationTime.return; + } + committedExpirationTime.sibling.return = + committedExpirationTime.return; + committedExpirationTime = committedExpirationTime.sibling; + } + } + break; + case 17: break; default: invariant( @@ -5231,17 +5862,44 @@ function commitAllLifeCycles( } } 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; + ((finishedWork = nextEffect.ref), + null !== finishedWork && + ((committedExpirationTime = nextEffect.stateNode), + "function" === typeof finishedWork + ? finishedWork(committedExpirationTime) + : (finishedWork.current = committedExpirationTime))); + effectTag & 512 && (rootWithPendingPassiveEffects = finishedRoot$jscomp$0); + nextEffect = nextEffect.nextEffect; } } +function commitPassiveEffects(root, firstEffect) { + passiveEffectCallback = passiveEffectCallbackHandle = rootWithPendingPassiveEffects = null; + var previousIsRendering = isRendering; + isRendering = !0; + do { + if (firstEffect.effectTag & 512) { + var didError = !1, + error = void 0; + try { + var finishedWork = firstEffect; + commitHookEffectList(128, 0, finishedWork); + commitHookEffectList(0, 64, finishedWork); + } catch (e) { + (didError = !0), (error = e); + } + didError && captureCommitPhaseError(firstEffect, error); + } + firstEffect = firstEffect.nextEffect; + } while (null !== firstEffect); + isRendering = previousIsRendering; + previousIsRendering = root.expirationTime; + 0 !== previousIsRendering && requestWork(root, previousIsRendering); +} +function flushPassiveEffects() { + null !== passiveEffectCallback && + (scheduler.unstable_cancelCallback(passiveEffectCallbackHandle), + passiveEffectCallback()); +} function commitRoot(root, finishedWork) { isCommitting$1 = isWorking = !0; invariant( @@ -5258,9 +5916,7 @@ function commitRoot(root, finishedWork) { childExpirationTimeBeforeCommit = finishedWork.childExpirationTime; markCommittedPriorityLevels( root, - 0 === updateExpirationTimeBeforeCommit || - (0 !== childExpirationTimeBeforeCommit && - childExpirationTimeBeforeCommit < updateExpirationTimeBeforeCommit) + childExpirationTimeBeforeCommit > updateExpirationTimeBeforeCommit ? childExpirationTimeBeforeCommit : updateExpirationTimeBeforeCommit ); @@ -5310,29 +5966,42 @@ function commitRoot(root, finishedWork) { } root.current = finishedWork; for (nextEffect = childExpirationTimeBeforeCommit; null !== nextEffect; ) { - childExpirationTimeBeforeCommit = !1; - didError = void 0; + didError = !1; + error$jscomp$0 = void 0; try { commitAllLifeCycles(root, committedExpirationTime); } catch (e) { - (childExpirationTimeBeforeCommit = !0), (didError = e); + (didError = !0), (error$jscomp$0 = e); } - childExpirationTimeBeforeCommit && + didError && (invariant( null !== nextEffect, "Should have next effect. This error is likely caused by a bug in React. Please file an issue." ), - captureCommitPhaseError(nextEffect, didError), + captureCommitPhaseError(nextEffect, error$jscomp$0), null !== nextEffect && (nextEffect = nextEffect.nextEffect)); } + null !== childExpirationTimeBeforeCommit && + null !== rootWithPendingPassiveEffects && + ((childExpirationTimeBeforeCommit = commitPassiveEffects.bind( + null, + root, + childExpirationTimeBeforeCommit + )), + (childExpirationTimeBeforeCommit = tracing.unstable_wrap( + childExpirationTimeBeforeCommit + )), + (passiveEffectCallbackHandle = scheduler.unstable_scheduleCallback( + childExpirationTimeBeforeCommit + )), + (passiveEffectCallback = childExpirationTimeBeforeCommit)); isWorking = isCommitting$1 = !1; "function" === typeof onCommitFiberRoot && onCommitFiberRoot(finishedWork.stateNode); childExpirationTimeBeforeCommit = finishedWork.expirationTime; finishedWork = finishedWork.childExpirationTime; var earliestRemainingTimeAfterCommit = - 0 === childExpirationTimeBeforeCommit || - (0 !== finishedWork && finishedWork < childExpirationTimeBeforeCommit) + finishedWork > childExpirationTimeBeforeCommit ? finishedWork : childExpirationTimeBeforeCommit; 0 === earliestRemainingTimeAfterCommit && @@ -5357,21 +6026,18 @@ function commitRoot(root, finishedWork) { scheduledInteractions, scheduledExpirationTime ) { - if ( - 0 === earliestRemainingTimeAfterCommit || - scheduledExpirationTime < earliestRemainingTimeAfterCommit - ) - pendingInteractionMap.delete(scheduledExpirationTime), - scheduledInteractions.forEach(function(interaction) { - interaction.__count--; - if (null !== subscriber && 0 === interaction.__count) - try { - subscriber.onInteractionScheduledWorkCompleted(interaction); - } catch (error) { - hasUnhandledError || - ((hasUnhandledError = !0), (unhandledError = error)); - } - }); + scheduledExpirationTime > earliestRemainingTimeAfterCommit && + (pendingInteractionMap.delete(scheduledExpirationTime), + scheduledInteractions.forEach(function(interaction) { + interaction.__count--; + if (null !== subscriber && 0 === interaction.__count) + try { + subscriber.onInteractionScheduledWorkCompleted(interaction); + } catch (error) { + hasUnhandledError || + ((hasUnhandledError = !0), (unhandledError = error)); + } + })); }); } } @@ -5380,7 +6046,7 @@ function completeUnitOfWork(workInProgress) { var current$$1 = workInProgress.alternate, returnFiber = workInProgress.return, siblingFiber = workInProgress.sibling; - if (0 === (workInProgress.effectTag & 512)) { + if (0 === (workInProgress.effectTag & 1024)) { if (workInProgress.mode & 4) { var fiber = workInProgress; profilerStartTime = now$1(); @@ -5390,17 +6056,17 @@ function completeUnitOfWork(workInProgress) { current$$1 = workInProgress; fiber = current$$1.pendingProps; switch (current$$1.tag) { - case 0: - case 1: - break; case 2: + break; + case 16: + break; + case 15: + case 0: + break; + case 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); fiber = current$$1.stateNode; @@ -5411,7 +6077,7 @@ function completeUnitOfWork(workInProgress) { current$$1.effectTag &= -3; updateHostContainer(current$$1); break; - case 7: + case 5: popHostContext(current$$1); var rootContainerInstance = requiredContext( rootInstanceStackCursor.current @@ -5450,35 +6116,7 @@ function completeUnitOfWork(workInProgress) { viewConfig = new ReactNativeFiberHostComponent(tag, viewConfig); instanceCache[tag] = internalInstanceHandle; instanceProps[tag] = fiber; - a: for ( - internalInstanceHandle = viewConfig, - tag = current$$1, - updatePayload = tag.child; - null !== updatePayload; - - ) { - if (7 === updatePayload.tag || 8 === updatePayload.tag) - internalInstanceHandle._children.push(updatePayload.stateNode); - else if ( - 6 !== updatePayload.tag && - null !== updatePayload.child - ) { - updatePayload.child.return = updatePayload; - updatePayload = updatePayload.child; - continue; - } - if (updatePayload === tag) break; - for (; null === updatePayload.sibling; ) { - if ( - null === updatePayload.return || - updatePayload.return === tag - ) - break a; - updatePayload = updatePayload.return; - } - updatePayload.sibling.return = updatePayload.return; - updatePayload = updatePayload.sibling; - } + appendAllChildren(viewConfig, current$$1, !1, !1); finalizeInitialChildren( viewConfig, type, @@ -5494,7 +6132,7 @@ 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 8: + case 6: current && null != current$$1.stateNode ? updateHostText$1( current, @@ -5521,34 +6159,36 @@ function completeUnitOfWork(workInProgress) { (instanceCache[type] = current$$1), (rootContainerInstance.stateNode = type)); break; + case 11: + break; case 13: - case 14: + fiber = current$$1.memoizedState; + rootContainerInstance = + null !== current ? current.memoizedState : null; + (null !== fiber && fiber.didTimeout) !== + (null !== rootContainerInstance && + rootContainerInstance.didTimeout) && (current$$1.effectTag |= 4); break; - case 16: + case 7: break; - case 9: + case 8: break; - case 10: + case 12: break; - case 15: - break; - case 6: + case 4: popHostContainer(current$$1); updateHostContainer(current$$1); break; - case 12: + case 10: popProvider(current$$1); break; - case 11: + case 9: + break; + case 14: break; case 17: - case 18: + isContextProvider(current$$1.type) && popContext(current$$1); break; - 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." - ); default: invariant( !1, @@ -5560,8 +6200,8 @@ function completeUnitOfWork(workInProgress) { stopProfilerTimerIfRunningAndRecordDelta(workInProgress, !1); current$$1 = workInProgress; if ( - 1073741823 === nextRenderExpirationTime || - 1073741823 !== current$$1.childExpirationTime + 1 === nextRenderExpirationTime || + 1 !== current$$1.childExpirationTime ) { fiber = 0; if (current$$1.mode & 4) { @@ -5570,19 +6210,20 @@ function completeUnitOfWork(workInProgress) { current = null === current$$1.alternate || current$$1.child !== current$$1.alternate.child; - for (viewConfig = current$$1.child; null !== viewConfig; ) { - internalInstanceHandle = viewConfig.expirationTime; - tag = viewConfig.childExpirationTime; - if ( - 0 === fiber || - (0 !== internalInstanceHandle && internalInstanceHandle < fiber) - ) - fiber = internalInstanceHandle; - if (0 === fiber || (0 !== tag && tag < fiber)) fiber = tag; - current && (rootContainerInstance += viewConfig.actualDuration); - type += viewConfig.treeBaseDuration; - viewConfig = viewConfig.sibling; - } + for ( + internalInstanceHandle = current$$1.child; + null !== internalInstanceHandle; + + ) + (tag = internalInstanceHandle.expirationTime), + (viewConfig = internalInstanceHandle.childExpirationTime), + tag > fiber && (fiber = tag), + viewConfig > fiber && (fiber = viewConfig), + current && + (rootContainerInstance += + internalInstanceHandle.actualDuration), + (type += internalInstanceHandle.treeBaseDuration), + (internalInstanceHandle = internalInstanceHandle.sibling); current$$1.actualDuration = rootContainerInstance; current$$1.treeBaseDuration = type; } else @@ -5590,18 +6231,16 @@ function completeUnitOfWork(workInProgress) { rootContainerInstance = current$$1.child; null !== rootContainerInstance; - ) { - type = rootContainerInstance.expirationTime; - current = rootContainerInstance.childExpirationTime; - if (0 === fiber || (0 !== type && type < fiber)) fiber = type; - if (0 === fiber || (0 !== current && current < fiber)) - fiber = current; - rootContainerInstance = rootContainerInstance.sibling; - } + ) + (type = rootContainerInstance.expirationTime), + (current = rootContainerInstance.childExpirationTime), + type > fiber && (fiber = type), + current > fiber && (fiber = current), + (rootContainerInstance = rootContainerInstance.sibling); current$$1.childExpirationTime = fiber; } null !== returnFiber && - 0 === (returnFiber.effectTag & 512) && + 0 === (returnFiber.effectTag & 1024) && (null === returnFiber.firstEffect && (returnFiber.firstEffect = workInProgress.firstEffect), null !== workInProgress.lastEffect && @@ -5625,12 +6264,12 @@ function completeUnitOfWork(workInProgress) { (siblingFiber = siblingFiber.sibling); workInProgress.actualDuration = returnFiber; } - workInProgress.effectTag &= 511; + workInProgress.effectTag &= 1023; return workInProgress; } null !== returnFiber && ((returnFiber.firstEffect = returnFiber.lastEffect = null), - (returnFiber.effectTag |= 512)); + (returnFiber.effectTag |= 1024)); } if (null !== siblingFiber) return siblingFiber; if (null !== returnFiber) workInProgress = returnFiber; @@ -5645,17 +6284,19 @@ function performUnitOfWork(workInProgress) { 0 > workInProgress.actualStartTime && (workInProgress.actualStartTime = now$1())); current$$1 = beginWork(current$$1, workInProgress, nextRenderExpirationTime); + workInProgress.memoizedProps = workInProgress.pendingProps; workInProgress.mode & 4 && stopProfilerTimerIfRunningAndRecordDelta(workInProgress, !0); null === current$$1 && (current$$1 = completeUnitOfWork(workInProgress)); ReactCurrentOwner$2.current = null; return current$$1; } -function renderRoot(root, isYieldy, isExpired) { +function renderRoot(root, isYieldy) { invariant( !isWorking, "renderRoot was called recursively. This error is likely caused by a bug in React. Please file an issue." ); + flushPassiveEffects(); isWorking = !0; ReactCurrentOwner$2.currentDispatcher = Dispatcher; var expirationTime = root.nextExpirationTimeToWorkOn; @@ -5678,7 +6319,7 @@ function renderRoot(root, isYieldy, isExpired) { scheduledInteractions, scheduledExpirationTime ) { - scheduledExpirationTime <= expirationTime && + scheduledExpirationTime >= expirationTime && scheduledInteractions.forEach(function(interaction) { return interactions.add(interaction); }); @@ -5704,13 +6345,17 @@ function renderRoot(root, isYieldy, isExpired) { do { try { if (isYieldy) - for (; null !== nextUnitOfWork && !shouldYield(); ) + for (; null !== nextUnitOfWork && !shouldYieldToRenderer(); ) nextUnitOfWork = performUnitOfWork(nextUnitOfWork); else for (; null !== nextUnitOfWork; ) nextUnitOfWork = performUnitOfWork(nextUnitOfWork); } catch (thrownValue) { - if (null === nextUnitOfWork) + if ( + ((lastContextWithAllBitsObserved = lastContextDependency = currentlyRenderingFiber = null), + resetHooks(), + null === nextUnitOfWork) + ) (threadID = !0), onUncaughtError(thrownValue); else { invariant( @@ -5738,168 +6383,153 @@ function renderRoot(root, isYieldy, isExpired) { tracing.__interactionsRef.current = subscriber; isWorking = !1; lastContextWithAllBitsObserved = lastContextDependency = currentlyRenderingFiber = ReactCurrentOwner$2.currentDispatcher = null; + resetHooks(); if (threadID) (nextRoot = null), (root.finishedWork = null); else if (null !== nextUnitOfWork) root.finishedWork = null; else { - isYieldy = root.current.alternate; + subscriber = root.current.alternate; invariant( - null !== isYieldy, + null !== subscriber, "Finished root should have a work-in-progress. This error is likely caused by a bug in React. Please file an issue." ); nextRoot = null; if (nextRenderDidError) { if (hasLowerPriorityWork(root, expirationTime)) { markSuspendedPriorityLevel(root, expirationTime); - onSuspend(root, isYieldy, expirationTime, root.expirationTime, -1); + onSuspend(root, subscriber, expirationTime, root.expirationTime, -1); return; } - if (!root.didError && !isExpired) { + if (!root.didError && isYieldy) { root.didError = !0; - isExpired = root.nextExpirationTimeToWorkOn = expirationTime; - subscriber = root.expirationTime = 1; - onSuspend(root, isYieldy, isExpired, subscriber, -1); + isYieldy = root.nextExpirationTimeToWorkOn = expirationTime; + threadID = root.expirationTime = 1073741823; + onSuspend(root, subscriber, isYieldy, threadID, -1); return; } } - isExpired || -1 === nextLatestAbsoluteTimeoutMs - ? onComplete(root, isYieldy, expirationTime) - : (markSuspendedPriorityLevel(root, expirationTime), - (isExpired = + isYieldy && -1 !== nextLatestAbsoluteTimeoutMs + ? (markSuspendedPriorityLevel(root, expirationTime), + (isYieldy = 10 * - (findEarliestOutstandingPriorityLevel(root, expirationTime) - 2)), - isExpired < nextLatestAbsoluteTimeoutMs && - (nextLatestAbsoluteTimeoutMs = isExpired), - (isExpired = 10 * (requestCurrentTime() - 2)), - (isExpired = nextLatestAbsoluteTimeoutMs - isExpired), + (1073741822 - + findEarliestOutstandingPriorityLevel(root, expirationTime))), + isYieldy < nextLatestAbsoluteTimeoutMs && + (nextLatestAbsoluteTimeoutMs = isYieldy), + (isYieldy = 10 * (1073741822 - requestCurrentTime())), + (isYieldy = nextLatestAbsoluteTimeoutMs - isYieldy), onSuspend( root, - isYieldy, + subscriber, expirationTime, root.expirationTime, - 0 > isExpired ? 0 : isExpired - )); + 0 > isYieldy ? 0 : isYieldy + )) + : onComplete(root, subscriber, expirationTime); } } -function captureCommitPhaseError(fiber, error) { - var JSCompiler_inline_result; - a: { - invariant( - !isWorking || isCommitting$1, - "dispatch: Cannot dispatch during the render phase." - ); - for ( - JSCompiler_inline_result = fiber.return; - null !== JSCompiler_inline_result; - - ) { - switch (JSCompiler_inline_result.tag) { - case 2: - case 3: - var instance = JSCompiler_inline_result.stateNode; - if ( - "function" === - typeof JSCompiler_inline_result.type.getDerivedStateFromError || - ("function" === typeof instance.componentDidCatch && - (null === legacyErrorBoundariesThatAlreadyFailed || - !legacyErrorBoundariesThatAlreadyFailed.has(instance))) - ) { - fiber = createCapturedValue(error, fiber); - fiber = createClassErrorUpdate(JSCompiler_inline_result, fiber, 1); - enqueueUpdate(JSCompiler_inline_result, fiber); - scheduleWork(JSCompiler_inline_result, 1); - JSCompiler_inline_result = void 0; - break a; - } - break; - case 5: - fiber = createCapturedValue(error, fiber); - fiber = createRootErrorUpdate(JSCompiler_inline_result, fiber, 1); - enqueueUpdate(JSCompiler_inline_result, fiber); - scheduleWork(JSCompiler_inline_result, 1); - JSCompiler_inline_result = void 0; - break a; - } - JSCompiler_inline_result = JSCompiler_inline_result.return; +function captureCommitPhaseError(sourceFiber, value) { + for (var fiber = sourceFiber.return; null !== fiber; ) { + switch (fiber.tag) { + case 1: + var instance = fiber.stateNode; + if ( + "function" === typeof fiber.type.getDerivedStateFromError || + ("function" === typeof instance.componentDidCatch && + (null === legacyErrorBoundariesThatAlreadyFailed || + !legacyErrorBoundariesThatAlreadyFailed.has(instance))) + ) { + sourceFiber = createCapturedValue(value, sourceFiber); + sourceFiber = createClassErrorUpdate(fiber, sourceFiber, 1073741823); + enqueueUpdate(fiber, sourceFiber); + scheduleWork(fiber, 1073741823); + return; + } + break; + case 3: + sourceFiber = createCapturedValue(value, sourceFiber); + sourceFiber = createRootErrorUpdate(fiber, sourceFiber, 1073741823); + enqueueUpdate(fiber, sourceFiber); + scheduleWork(fiber, 1073741823); + return; } - 5 === fiber.tag && - ((JSCompiler_inline_result = createCapturedValue(error, fiber)), - (JSCompiler_inline_result = createRootErrorUpdate( - fiber, - JSCompiler_inline_result, - 1 - )), - enqueueUpdate(fiber, JSCompiler_inline_result), - scheduleWork(fiber, 1)); - JSCompiler_inline_result = void 0; + fiber = fiber.return; } - return JSCompiler_inline_result; + 3 === sourceFiber.tag && + ((fiber = createCapturedValue(value, sourceFiber)), + (fiber = createRootErrorUpdate(sourceFiber, fiber, 1073741823)), + enqueueUpdate(sourceFiber, fiber), + scheduleWork(sourceFiber, 1073741823)); } function computeExpirationForFiber(currentTime, fiber) { isWorking - ? (currentTime = isCommitting$1 ? 1 : nextRenderExpirationTime) + ? (currentTime = isCommitting$1 ? 1073741823 : nextRenderExpirationTime) : fiber.mode & 1 ? ((currentTime = isBatchingInteractiveUpdates - ? 2 + 10 * ((((currentTime - 2 + 15) / 10) | 0) + 1) - : 2 + 25 * ((((currentTime - 2 + 500) / 25) | 0) + 1)), + ? 1073741822 - 10 * ((((1073741822 - currentTime + 15) / 10) | 0) + 1) + : 1073741822 - + 25 * ((((1073741822 - currentTime + 500) / 25) | 0) + 1)), null !== nextRoot && currentTime === nextRenderExpirationTime && - (currentTime += 1)) - : (currentTime = 1); + --currentTime) + : (currentTime = 1073741823); isBatchingInteractiveUpdates && - currentTime > lowestPriorityPendingInteractiveExpirationTime && + (0 === lowestPriorityPendingInteractiveExpirationTime || + currentTime < lowestPriorityPendingInteractiveExpirationTime) && (lowestPriorityPendingInteractiveExpirationTime = currentTime); return currentTime; } -function retrySuspendedRoot(root, fiber, suspendedTime) { +function retrySuspendedRoot(root, boundaryFiber, sourceFiber, suspendedTime) { var retryTime = root.earliestSuspendedTime; var latestSuspendedTime = root.latestSuspendedTime; if ( 0 !== retryTime && - suspendedTime >= retryTime && - suspendedTime <= latestSuspendedTime + suspendedTime <= retryTime && + suspendedTime >= latestSuspendedTime ) { latestSuspendedTime = retryTime = suspendedTime; root.didError = !1; var latestPingedTime = root.latestPingedTime; - if (0 === latestPingedTime || latestPingedTime < latestSuspendedTime) + if (0 === latestPingedTime || latestPingedTime > latestSuspendedTime) root.latestPingedTime = latestSuspendedTime; findNextExpirationTimeToWorkOn(latestSuspendedTime, root); } else (retryTime = requestCurrentTime()), - (retryTime = computeExpirationForFiber(retryTime, fiber)), + (retryTime = computeExpirationForFiber(retryTime, boundaryFiber)), markPendingPriorityLevel(root, retryTime); - 0 !== (fiber.mode & 1) && + 0 !== (boundaryFiber.mode & 1) && root === nextRoot && nextRenderExpirationTime === suspendedTime && (nextRoot = null); - scheduleWorkToRoot(fiber, retryTime); - fiber = root.expirationTime; - 0 !== fiber && requestWork(root, fiber); + scheduleWorkToRoot(boundaryFiber, retryTime); + 0 === (boundaryFiber.mode & 1) && + (scheduleWorkToRoot(sourceFiber, retryTime), + 1 === sourceFiber.tag && + null !== sourceFiber.stateNode && + ((boundaryFiber = createUpdate(retryTime)), + (boundaryFiber.tag = 2), + enqueueUpdate(sourceFiber, boundaryFiber))); + sourceFiber = root.expirationTime; + 0 !== sourceFiber && requestWork(root, sourceFiber); } function scheduleWorkToRoot(fiber, expirationTime) { - if (0 === fiber.expirationTime || fiber.expirationTime > expirationTime) - fiber.expirationTime = expirationTime; + fiber.expirationTime < expirationTime && + (fiber.expirationTime = expirationTime); var alternate = fiber.alternate; null !== alternate && - (0 === alternate.expirationTime || - alternate.expirationTime > expirationTime) && + alternate.expirationTime < expirationTime && (alternate.expirationTime = expirationTime); var node = fiber.return, root = null; - if (null === node && 5 === fiber.tag) root = fiber.stateNode; + if (null === node && 3 === fiber.tag) root = fiber.stateNode; else for (; null !== node; ) { alternate = node.alternate; - if ( - 0 === node.childExpirationTime || - node.childExpirationTime > expirationTime - ) - node.childExpirationTime = expirationTime; + node.childExpirationTime < expirationTime && + (node.childExpirationTime = expirationTime); null !== alternate && - (0 === alternate.childExpirationTime || - alternate.childExpirationTime > expirationTime) && + alternate.childExpirationTime < expirationTime && (alternate.childExpirationTime = expirationTime); - if (null === node.return && 5 === node.tag) { + if (null === node.return && 3 === node.tag) { root = node.stateNode; break; } @@ -5933,7 +6563,7 @@ function scheduleWork(fiber, expirationTime) { null !== fiber && (!isWorking && 0 !== nextRenderExpirationTime && - expirationTime < nextRenderExpirationTime && + expirationTime > nextRenderExpirationTime && resetStack(), markPendingPriorityLevel(fiber, expirationTime), (isWorking && !isCommitting$1 && nextRoot === fiber) || @@ -5953,27 +6583,25 @@ var firstScheduledRoot = null, nextFlushedRoot = null, nextFlushedExpirationTime = 0, lowestPriorityPendingInteractiveExpirationTime = 0, - deadlineDidExpire = !1, hasUnhandledError = !1, unhandledError = null, - deadline = null, isBatchingUpdates = !1, isUnbatchingUpdates = !1, isBatchingInteractiveUpdates = !1, completedBatches = null, originalStartTimeMs = now$1(), - currentRendererTime = ((originalStartTimeMs / 10) | 0) + 2, + currentRendererTime = 1073741822 - ((originalStartTimeMs / 10) | 0), currentSchedulerTime = currentRendererTime, NESTED_UPDATE_LIMIT = 50, nestedUpdateCount = 0, - lastCommittedRootDuringThisBatch = null, - timeHeuristicForUnitOfWork = 1; + lastCommittedRootDuringThisBatch = null; function recomputeCurrentRendererTime() { - currentRendererTime = (((now$1() - originalStartTimeMs) / 10) | 0) + 2; + currentRendererTime = + 1073741822 - (((now$1() - originalStartTimeMs) / 10) | 0); } function scheduleCallbackWithExpirationTime(root, expirationTime) { if (0 !== callbackExpirationTime) { - if (expirationTime > callbackExpirationTime) return; + if (expirationTime < callbackExpirationTime) return; null !== callbackID && ((root = callbackID), (scheduledCallback = null), clearTimeout(root)); } @@ -5994,7 +6622,7 @@ function onSuspend( msUntilTimeout ) { root.expirationTime = rootExpirationTime; - 0 !== msUntilTimeout || shouldYield() + 0 !== msUntilTimeout || shouldYieldToRenderer() ? 0 < msUntilTimeout && (root.timeoutHandle = scheduleTimeout( onTimeout.bind(null, root, finishedWork, suspendedExpirationTime), @@ -6014,8 +6642,8 @@ function onTimeout(root, finishedWork, suspendedExpirationTime) { ); nextFlushedRoot = root; nextFlushedExpirationTime = suspendedExpirationTime; - performWorkOnRoot(root, suspendedExpirationTime, !0); - performWork(1, null); + performWorkOnRoot(root, suspendedExpirationTime, !1); + performWork(1073741823, !1); } function onCommit(root, expirationTime) { root.expirationTime = expirationTime; @@ -6024,38 +6652,29 @@ function onCommit(root, expirationTime) { function requestCurrentTime() { if (isRendering) return currentSchedulerTime; findHighestPriorityRoot(); - if ( - 0 === nextFlushedExpirationTime || - 1073741823 === nextFlushedExpirationTime - ) + if (0 === nextFlushedExpirationTime || 1 === nextFlushedExpirationTime) recomputeCurrentRendererTime(), (currentSchedulerTime = currentRendererTime); return currentSchedulerTime; } function requestWork(root, expirationTime) { - if (null === root.nextScheduledRoot) - (root.expirationTime = expirationTime), + 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; - } + (lastScheduledRoot.nextScheduledRoot = firstScheduledRoot))) + : expirationTime > root.expirationTime && + (root.expirationTime = expirationTime); isRendering || (isBatchingUpdates ? isUnbatchingUpdates && ((nextFlushedRoot = root), - (nextFlushedExpirationTime = 1), - performWorkOnRoot(root, 1, !0)) - : 1 === expirationTime - ? performWork(1, null) + (nextFlushedExpirationTime = 1073741823), + performWorkOnRoot(root, 1073741823, !1)) + : 1073741823 === expirationTime + ? performWork(1073741823, !1) : scheduleCallbackWithExpirationTime(root, expirationTime)); } function findHighestPriorityRoot() { @@ -6091,14 +6710,11 @@ function findHighestPriorityRoot() { (root.nextScheduledRoot = null); root = previousScheduledRoot.nextScheduledRoot; } else { - if ( - 0 === highestPriorityWork || - remainingExpirationTime < highestPriorityWork - ) - (highestPriorityWork = remainingExpirationTime), - (highestPriorityRoot = root); + remainingExpirationTime > highestPriorityWork && + ((highestPriorityWork = remainingExpirationTime), + (highestPriorityRoot = root)); if (root === lastScheduledRoot) break; - if (1 === highestPriorityWork) break; + if (1073741823 === highestPriorityWork) break; previousScheduledRoot = root; root = root.nextScheduledRoot; } @@ -6106,38 +6722,44 @@ function findHighestPriorityRoot() { nextFlushedRoot = highestPriorityRoot; 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); +var didYield = !1; +function shouldYieldToRenderer() { + return didYield ? !0 : frameDeadline <= now$1() ? (didYield = !0) : !1; } -function performWork(minExpirationTime, dl) { - deadline = dl; +function performAsyncWork() { + try { + if (!shouldYieldToRenderer() && 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, !0); + } finally { + didYield = !1; + } +} +function performWork(minExpirationTime, isYieldy) { findHighestPriorityRoot(); - if (null !== deadline) + if (isYieldy) for ( recomputeCurrentRendererTime(), currentSchedulerTime = currentRendererTime; null !== nextFlushedRoot && 0 !== nextFlushedExpirationTime && - (0 === minExpirationTime || - minExpirationTime >= nextFlushedExpirationTime) && - (!deadlineDidExpire || currentRendererTime >= nextFlushedExpirationTime); + minExpirationTime <= nextFlushedExpirationTime && + !(didYield && currentRendererTime > nextFlushedExpirationTime); ) performWorkOnRoot( nextFlushedRoot, nextFlushedExpirationTime, - currentRendererTime >= nextFlushedExpirationTime + currentRendererTime > nextFlushedExpirationTime ), findHighestPriorityRoot(), recomputeCurrentRendererTime(), @@ -6147,29 +6769,28 @@ function performWork(minExpirationTime, dl) { ; null !== nextFlushedRoot && 0 !== nextFlushedExpirationTime && - (0 === minExpirationTime || - minExpirationTime >= nextFlushedExpirationTime); + minExpirationTime <= nextFlushedExpirationTime; ) - performWorkOnRoot(nextFlushedRoot, nextFlushedExpirationTime, !0), + performWorkOnRoot(nextFlushedRoot, nextFlushedExpirationTime, !1), findHighestPriorityRoot(); - null !== deadline && ((callbackExpirationTime = 0), (callbackID = null)); + isYieldy && ((callbackExpirationTime = 0), (callbackID = null)); 0 !== nextFlushedExpirationTime && scheduleCallbackWithExpirationTime( nextFlushedRoot, nextFlushedExpirationTime ); - deadline = null; - deadlineDidExpire = !1; nestedUpdateCount = 0; lastCommittedRootDuringThisBatch = null; if (null !== completedBatches) for ( - minExpirationTime = completedBatches, completedBatches = null, dl = 0; - dl < minExpirationTime.length; - dl++ + minExpirationTime = completedBatches, + completedBatches = null, + isYieldy = 0; + isYieldy < minExpirationTime.length; + isYieldy++ ) { - var batch = minExpirationTime[dl]; + var batch = minExpirationTime[isYieldy]; try { batch._onComplete(); } catch (error) { @@ -6183,45 +6804,45 @@ function performWork(minExpirationTime, dl) { (hasUnhandledError = !1), minExpirationTime); } -function performWorkOnRoot(root, expirationTime, isExpired) { +function performWorkOnRoot(root, expirationTime, isYieldy) { invariant( !isRendering, "performWorkOnRoot was called recursively. This error is likely caused by a bug in React. Please file an issue." ); isRendering = !0; - if (null === deadline || isExpired) { - var finishedWork = root.finishedWork; - null !== finishedWork - ? completeRoot(root, finishedWork, expirationTime) + if (isYieldy) { + var _finishedWork = root.finishedWork; + null !== _finishedWork + ? completeRoot(root, _finishedWork, expirationTime) : ((root.finishedWork = null), - (finishedWork = root.timeoutHandle), - -1 !== finishedWork && - ((root.timeoutHandle = -1), cancelTimeout(finishedWork)), - renderRoot(root, !1, isExpired), - (finishedWork = root.finishedWork), - null !== finishedWork && - completeRoot(root, finishedWork, expirationTime)); + (_finishedWork = root.timeoutHandle), + -1 !== _finishedWork && + ((root.timeoutHandle = -1), cancelTimeout(_finishedWork)), + renderRoot(root, isYieldy), + (_finishedWork = root.finishedWork), + null !== _finishedWork && + (shouldYieldToRenderer() + ? (root.finishedWork = _finishedWork) + : completeRoot(root, _finishedWork, expirationTime))); } else - (finishedWork = root.finishedWork), - null !== finishedWork - ? completeRoot(root, finishedWork, expirationTime) + (_finishedWork = root.finishedWork), + null !== _finishedWork + ? completeRoot(root, _finishedWork, expirationTime) : ((root.finishedWork = null), - (finishedWork = root.timeoutHandle), - -1 !== finishedWork && - ((root.timeoutHandle = -1), cancelTimeout(finishedWork)), - renderRoot(root, !0, isExpired), - (finishedWork = root.finishedWork), - null !== finishedWork && - (shouldYield() - ? (root.finishedWork = finishedWork) - : completeRoot(root, finishedWork, expirationTime))); + (_finishedWork = root.timeoutHandle), + -1 !== _finishedWork && + ((root.timeoutHandle = -1), cancelTimeout(_finishedWork)), + renderRoot(root, isYieldy), + (_finishedWork = root.finishedWork), + null !== _finishedWork && + completeRoot(root, _finishedWork, expirationTime)); isRendering = !1; } function completeRoot(root, finishedWork, expirationTime) { var firstBatch = root.firstBatch; if ( null !== firstBatch && - firstBatch._expirationTime <= expirationTime && + firstBatch._expirationTime >= expirationTime && (null === completedBatches ? (completedBatches = [firstBatch]) : completedBatches.push(firstBatch), @@ -6237,13 +6858,6 @@ function completeRoot(root, finishedWork, expirationTime) { : ((lastCommittedRootDuringThisBatch = root), (nestedUpdateCount = 0)); commitRoot(root, finishedWork); } -function shouldYield() { - return deadlineDidExpire - ? !0 - : null === deadline || deadline.timeRemaining() > timeHeuristicForUnitOfWork - ? !1 - : (deadlineDidExpire = !0); -} function onUncaughtError(error) { invariant( null !== nextFlushedRoot, @@ -6252,55 +6866,6 @@ function onUncaughtError(error) { nextFlushedRoot.expirationTime = 0; hasUnhandledError || ((hasUnhandledError = !0), (unhandledError = error)); } -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.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; void 0 === fiber && @@ -6319,7 +6884,48 @@ function updateContainer(element, container, parentComponent, callback) { currentTime = requestCurrentTime(); current$$1 = computeExpirationForFiber(currentTime, current$$1); currentTime = container.current; - parentComponent = getContextForSubtree(parentComponent); + a: if (parentComponent) { + parentComponent = parentComponent._reactInternalFiber; + b: { + invariant( + 2 === isFiberMountedImpl(parentComponent) && 1 === 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 3: + parentContext = parentContext.stateNode.context; + break b; + case 1: + if (isContextProvider(parentContext.type)) { + parentContext = + parentContext.stateNode + .__reactInternalMemoizedMergedChildContext; + break b; + } + } + 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 (1 === parentComponent.tag) { + var Component = parentComponent.type; + if (isContextProvider(Component)) { + parentComponent = processChildContext( + parentComponent, + Component, + parentContext + ); + break a; + } + } + parentComponent = parentContext; + } else parentComponent = emptyContextObject; null === container.context ? (container.context = parentComponent) : (container.pendingContext = parentComponent); @@ -6328,6 +6934,7 @@ function updateContainer(element, container, parentComponent, callback) { callback.payload = { element: element }; container = void 0 === container ? null : container; null !== container && (callback.callback = container); + flushPassiveEffects(); enqueueUpdate(currentTime, callback); scheduleWork(currentTime, current$$1); return current$$1; @@ -6387,13 +6994,13 @@ _batchedUpdatesImpl = function(fn, a) { } finally { (isBatchingUpdates = previousIsBatchingUpdates) || isRendering || - performWork(1, null); + performWork(1073741823, !1); } }; _flushInteractiveUpdatesImpl = function() { isRendering || 0 === lowestPriorityPendingInteractiveExpirationTime || - (performWork(lowestPriorityPendingInteractiveExpirationTime, null), + (performWork(lowestPriorityPendingInteractiveExpirationTime, !1), (lowestPriorityPendingInteractiveExpirationTime = 0)); }; var roots = new Map(), @@ -6475,7 +7082,7 @@ var roots = new Map(), if (!root) { root = 0; isDevToolsPresent && (root |= 4); - root = new FiberNode(5, null, null, root); + root = createFiber(3, null, null, root); var root$jscomp$0 = { current: root, containerInfo: containerTag, @@ -6506,7 +7113,7 @@ var roots = new Map(), updateContainer(element, root, null, callback); a: if (((element = root.current), element.child)) switch (element.child.tag) { - case 7: + case 5: element = element.child.stateNode; break a; default: @@ -6613,7 +7220,7 @@ var roots = new Map(), findFiberByHostInstance: getInstanceFromTag, getInspectorDataForViewTag: getInspectorDataForViewTag, bundleType: 0, - version: "16.6.0-alpha.8af6728", + version: "16.6.0", rendererPackageName: "react-native-renderer" }); var ReactNativeRenderer$2 = { default: ReactNativeRenderer }, diff --git a/Libraries/Renderer/shims/ReactTypes.js b/Libraries/Renderer/shims/ReactTypes.js index 20f76eef3..080ade12b 100644 --- a/Libraries/Renderer/shims/ReactTypes.js +++ b/Libraries/Renderer/shims/ReactTypes.js @@ -54,7 +54,6 @@ export type ReactContext = { $$typeof: Symbol | number, Consumer: ReactContext, Provider: ReactProviderType, - unstable_read: () => T, _calculateChangedBits: ((a: T, b: T) => number) | null, diff --git a/package.json b/package.json index 6d46a6477..e9b894df7 100644 --- a/package.json +++ b/package.json @@ -146,7 +146,7 @@ "react-native": "local-cli/wrong-react-native.js" }, "peerDependencies": { - "react": "16.6.0-alpha.8af6728" + "react": "16.6.0" }, "dependencies": { "@babel/runtime": "^7.0.0", @@ -221,9 +221,9 @@ "jest": "24.0.0-alpha.4", "jest-junit": "5.1.0", "prettier": "1.13.6", - "react": "16.6.0-alpha.8af6728", + "react": "16.6.0", "react-native-dummy": "0.1.0", - "react-test-renderer": "16.6.0-alpha.8af6728", + "react-test-renderer": "16.6.0", "shelljs": "^0.7.8" }, "detox": { diff --git a/yarn.lock b/yarn.lock index 232d8f9de..f6e999ad0 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5223,10 +5223,10 @@ react-devtools-core@^3.4.0: shell-quote "^1.6.1" ws "^3.3.1" -react-is@^16.6.0-alpha.8af6728: - version "16.6.0-alpha.8af6728" - resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.6.0-alpha.8af6728.tgz#3ce01f13f164b90a76ad902735834fc12d06e30e" - integrity sha512-F65AeMavskvRglteO7dC0Nvq3Br1ESnpCOG5M6fenQX52Uhpt6eCI0vL3ICM/hnVhIOQY2fwnSWtST33OlgxVA== +react-is@^16.6.0: + version "16.6.0" + resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.6.0.tgz#456645144581a6e99f6816ae2bd24ee94bdd0c01" + integrity sha512-q8U7k0Fi7oxF1HvQgyBjPwDXeMplEsArnKt2iYhuIF86+GBbgLHdAmokL3XUFjTd7Q363OSNG55FOGUdONVn1g== react-native-dummy@0.1.0: version "0.1.0" @@ -5241,15 +5241,15 @@ react-proxy@^1.1.7: lodash "^4.6.1" react-deep-force-update "^1.0.0" -react-test-renderer@16.6.0-alpha.8af6728: - version "16.6.0-alpha.8af6728" - resolved "https://registry.yarnpkg.com/react-test-renderer/-/react-test-renderer-16.6.0-alpha.8af6728.tgz#5b9eaa972f0016c95d1ef5d93f727c5dc4a5a0ee" - integrity sha512-42RB1hvEjVuJGrGddGqVj1obs9NhWiuijkz+qsuY0qRzF0ygD5xg4eRdm0H4YNtkp+332g6OWO9O2ussu67cFQ== +react-test-renderer@16.6.0: + version "16.6.0" + resolved "https://registry.yarnpkg.com/react-test-renderer/-/react-test-renderer-16.6.0.tgz#fe490096bed55c3f4e92c023da3b89f9d03fceb3" + integrity sha512-w+Y3YT7OX1LP5KO7HCd0YR34Ol1qmISHaooPNMRYa6QzmwtcWhEGuZPr34wO8UCBIokswuhyLQUq7rjPDcEtJA== dependencies: object-assign "^4.1.1" prop-types "^15.6.2" - react-is "^16.6.0-alpha.8af6728" - scheduler "^0.10.0-alpha.8af6728" + react-is "^16.6.0" + scheduler "^0.10.0" react-transform-hmr@^1.0.4: version "1.0.4" @@ -5259,15 +5259,15 @@ react-transform-hmr@^1.0.4: global "^4.3.0" react-proxy "^1.1.7" -react@16.6.0-alpha.8af6728: - version "16.6.0-alpha.8af6728" - resolved "https://registry.yarnpkg.com/react/-/react-16.6.0-alpha.8af6728.tgz#b97b6453c252a1f6ad185acc81aca1485cd3e120" - integrity sha512-W5NwSMey/JjF4wdeB7ek/+qG4bJJhgM1O/NaHvhUswgJxBMcFLUroODPELbq6IVolgua+anEirtOCx3fMXHZjw== +react@16.6.0: + version "16.6.0" + resolved "https://registry.yarnpkg.com/react/-/react-16.6.0.tgz#b34761cfaf3e30f5508bc732fb4736730b7da246" + integrity sha512-zJPnx/jKtuOEXCbQ9BKaxDMxR0001/hzxXwYxG8septeyYGfsgAei6NgfbVgOhbY1WOP2o3VPs/E9HaN+9hV3Q== dependencies: loose-envify "^1.1.0" object-assign "^4.1.1" prop-types "^15.6.2" - scheduler "^0.10.0-alpha.8af6728" + scheduler "^0.10.0" read-pkg-up@^1.0.1: version "1.0.1" @@ -5650,10 +5650,10 @@ sax@~1.1.1: resolved "http://registry.npmjs.org/sax/-/sax-1.1.6.tgz#5d616be8a5e607d54e114afae55b7eaf2fcc3240" integrity sha1-XWFr6KXmB9VOEUr65Vt+ry/MMkA= -scheduler@^0.10.0-alpha.8af6728: - version "0.10.0-alpha.f47a958" - resolved "https://registry.yarnpkg.com/scheduler/-/scheduler-0.10.0-alpha.f47a958.tgz#0063a5c21aad2038111c316e417e9702d1ca7007" - integrity sha512-GVz1gvEU4JhqqiLB+DhRwd17sqKCmVsmdrsDoKMOIRCu0z+qYhimF6PvA3q61BgCqHDWJZiAidom6saiE8ZrOQ== +scheduler@^0.10.0: + version "0.10.0" + resolved "https://registry.yarnpkg.com/scheduler/-/scheduler-0.10.0.tgz#7988de90fe7edccc774ea175a783e69c40c521e1" + integrity sha512-+TSTVTCBAA3h8Anei3haDc1IRwMeDmtI/y/o3iBe3Mjl2vwYF9DtPDt929HyRmV/e7au7CLu8sc4C4W0VOs29w== dependencies: loose-envify "^1.1.0" object-assign "^4.1.1"