From 6448f4e2f1ff87600c559208f0f31c8e9fcedd9a Mon Sep 17 00:00:00 2001 From: Tim Yung Date: Sun, 4 Nov 2018 01:06:38 -0700 Subject: [PATCH] RN: Revert React 16.6 Sync Summary: There are some critical bugs that require further investigation in the most recent upgrade to React 16.6 (and ReactNativeRenderer changes). This revision reverts the sync until these issues have been resolved. Reviewed By: mdvacca Differential Revision: D12918541 fbshipit-source-id: 5c1ada185851ba599f3c86387158a2b41f3dcf3e --- Libraries/Renderer/REVISION | 2 +- Libraries/Renderer/oss/ReactFabric-dev.js | 3281 +++++------------ Libraries/Renderer/oss/ReactFabric-prod.js | 3203 +++++++--------- .../Renderer/oss/ReactFabric-profiling.js | 3272 +++++++--------- .../Renderer/oss/ReactNativeRenderer-dev.js | 3279 +++++----------- .../Renderer/oss/ReactNativeRenderer-prod.js | 3174 +++++++--------- .../oss/ReactNativeRenderer-profiling.js | 3219 +++++++--------- Libraries/Renderer/shims/ReactTypes.js | 1 + package.json | 6 +- yarn.lock | 38 +- 10 files changed, 7121 insertions(+), 12354 deletions(-) diff --git a/Libraries/Renderer/REVISION b/Libraries/Renderer/REVISION index 7274d4dc474..21b691427f4 100644 --- a/Libraries/Renderer/REVISION +++ b/Libraries/Renderer/REVISION @@ -1 +1 @@ -c84b9bf828c38e0b24042ebb9cd859292146a6fb \ No newline at end of file +4773fdf7cdf5d6d775ad0960f23ee1a830e7b82b \ No newline at end of file diff --git a/Libraries/Renderer/oss/ReactFabric-dev.js b/Libraries/Renderer/oss/ReactFabric-dev.js index 0d10490736c..de566d72b49 100644 --- a/Libraries/Renderer/oss/ReactFabric-dev.js +++ b/Libraries/Renderer/oss/ReactFabric-dev.js @@ -27,7 +27,6 @@ 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"); /** @@ -1134,23 +1133,24 @@ function runExtractedEventsInBatch( } var FunctionComponent = 0; -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; +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; function getParent(inst) { do { @@ -2650,7 +2650,6 @@ 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; @@ -2658,8 +2657,7 @@ var REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for("react.forward_ref") : 0xead0; var REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for("react.suspense") : 0xead1; -var REACT_MEMO_TYPE = hasSymbol ? Symbol.for("react.memo") : 0xead3; -var REACT_LAZY_TYPE = hasSymbol ? Symbol.for("react.lazy") : 0xead4; +var REACT_PURE_TYPE = hasSymbol ? Symbol.for("react.pure") : 0xead3; var MAYBE_ITERATOR_SYMBOL = typeof Symbol === "function" && Symbol.iterator; var FAUX_ITERATOR_SYMBOL = "@@iterator"; @@ -2681,8 +2679,12 @@ var Pending = 0; var Resolved = 1; var Rejected = 2; -function refineResolvedLazyComponent(lazyComponent) { - return lazyComponent._status === Resolved ? lazyComponent._result : null; +function getResultFromResolvedThenable(thenable) { + return thenable._reactResult; +} + +function refineResolvedThenable(thenable) { + return thenable._reactStatus === Resolved ? thenable._reactResult : null; } function getWrappedName(outerType, innerType, wrapperName) { @@ -2735,14 +2737,14 @@ function getComponentName(type) { return "Context.Provider"; case REACT_FORWARD_REF_TYPE: return getWrappedName(type, type.render, "ForwardRef"); - case REACT_MEMO_TYPE: - return getComponentName(type.type); - case REACT_LAZY_TYPE: { - var thenable = type; - var resolvedThenable = refineResolvedLazyComponent(thenable); - if (resolvedThenable) { - return getComponentName(resolvedThenable); - } + 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); } } } @@ -2763,16 +2765,15 @@ var Callback = /* */ 32; var DidCapture = /* */ 64; var Ref = /* */ 128; var Snapshot = /* */ 256; -var Passive = /* */ 512; -// Passive & Update & Callback & Ref & Snapshot -var LifecycleEffectMask = /* */ 932; +// Update & Callback & Ref & Snapshot +var LifecycleEffectMask = /* */ 420; // Union of all host effects -var HostEffectMask = /* */ 1023; +var HostEffectMask = /* */ 511; -var Incomplete = /* */ 1024; -var ShouldCapture = /* */ 2048; +var Incomplete = /* */ 512; +var ShouldCapture = /* */ 1024; var ReactCurrentOwner$1 = ReactSharedInternals.ReactCurrentOwner; @@ -2816,7 +2817,10 @@ function isFiberMounted(fiber) { function isMounted(component) { { var owner = ReactCurrentOwner$1.current; - if (owner !== null && owner.tag === ClassComponent) { + if ( + owner !== null && + (owner.tag === ClassComponent || owner.tag === ClassComponentLazy) + ) { var ownerFiber = owner; var instance = ownerFiber.stateNode; !instance._warnedAboutRefsInRender @@ -3526,6 +3530,13 @@ 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. @@ -3536,7 +3547,7 @@ function setTimeoutCallback() { var callback = scheduledCallback; scheduledCallback = null; if (callback !== null) { - callback(); + callback(frameDeadlineObject); } } @@ -3555,10 +3566,6 @@ 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; @@ -3689,10 +3696,6 @@ 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. @@ -3970,7 +3973,6 @@ 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; @@ -4016,23 +4018,6 @@ 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); } @@ -4078,12 +4063,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); @@ -4160,7 +4145,6 @@ function setCurrentPhase(lifeCyclePhase) { var debugRenderPhaseSideEffects = false; var debugRenderPhaseSideEffectsForStrictMode = false; var enableUserTimingAPI = true; - var warnAboutDeprecatedLifecycles = false; var replayFailedUnitOfWorkWithInvokeGuardedCallback = true; var enableProfilerTimer = true; @@ -4932,7 +4916,8 @@ function findCurrentUnmaskedContext(fiber) { // Currently this is only used with renderSubtreeIntoContainer; not sure if it // makes sense elsewhere invariant( - isFiberMounted(fiber) && fiber.tag === ClassComponent, + isFiberMounted(fiber) && + (fiber.tag === ClassComponent || fiber.tag === ClassComponentLazy), "Expected subtree parent to be a mounted class component. " + "This error is likely caused by a bug in React. Please file an issue." ); @@ -4949,6 +4934,13 @@ 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); @@ -5047,20 +5039,20 @@ function onCommitUnmount(fiber) { var maxSigned31BitInt = 1073741823; var NoWork = 0; -var Never = 1; -var Sync = maxSigned31BitInt; +var Sync = 1; +var Never = maxSigned31BitInt; var UNIT_SIZE = 10; -var MAGIC_NUMBER_OFFSET = maxSigned31BitInt - 1; +var MAGIC_NUMBER_OFFSET = 2; // 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 MAGIC_NUMBER_OFFSET - ((ms / UNIT_SIZE) | 0); + return ((ms / UNIT_SIZE) | 0) + MAGIC_NUMBER_OFFSET; } function expirationTimeToMs(expirationTime) { - return (MAGIC_NUMBER_OFFSET - expirationTime) * UNIT_SIZE; + return (expirationTime - MAGIC_NUMBER_OFFSET) * UNIT_SIZE; } function ceiling(num, precision) { @@ -5069,9 +5061,9 @@ function ceiling(num, precision) { function computeExpirationBucket(currentTime, expirationInMs, bucketSizeMs) { return ( - MAGIC_NUMBER_OFFSET - + MAGIC_NUMBER_OFFSET + ceiling( - MAGIC_NUMBER_OFFSET - currentTime + expirationInMs / UNIT_SIZE, + currentTime - MAGIC_NUMBER_OFFSET + expirationInMs / UNIT_SIZE, bucketSizeMs / UNIT_SIZE ) ); @@ -5147,7 +5139,6 @@ function FiberNode(tag, pendingProps, key, mode) { // Instance this.tag = tag; this.key = key; - this.elementType = null; this.type = null; this.stateNode = null; @@ -5220,24 +5211,18 @@ function shouldConstruct(Component) { return !!(prototype && prototype.isReactComponent); } -function isSimpleFunctionComponent(type) { - return ( - typeof type === "function" && - !shouldConstruct(type) && - type.defaultProps === undefined - ); -} - -function resolveLazyComponentTag(Component) { +function resolveLazyComponentTag(fiber, Component) { if (typeof Component === "function") { - return shouldConstruct(Component) ? ClassComponent : FunctionComponent; + return shouldConstruct(Component) + ? ClassComponentLazy + : FunctionComponentLazy; } else if (Component !== undefined && Component !== null) { var $$typeof = Component.$$typeof; if ($$typeof === REACT_FORWARD_REF_TYPE) { - return ForwardRef; + return ForwardRefLazy; } - if ($$typeof === REACT_MEMO_TYPE) { - return MemoComponent; + if ($$typeof === REACT_PURE_TYPE) { + return PureComponentLazy; } } return IndeterminateComponent; @@ -5258,7 +5243,6 @@ function createWorkInProgress(current, pendingProps, expirationTime) { current.key, current.mode ); - workInProgress.elementType = current.elementType; workInProgress.type = current.type; workInProgress.stateNode = current.stateNode; @@ -5328,23 +5312,20 @@ function createHostRootFiber(isConcurrent) { return createFiber(HostRoot, null, null, mode); } -function createFiberFromTypeAndProps( - type, // React$ElementType - key, - pendingProps, - owner, - mode, - expirationTime -) { - var fiber = void 0; +function createFiberFromElement(element, mode, expirationTime) { + var owner = null; + { + owner = element._owner; + } - 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; + var fiber = void 0; + var type = element.type; + var key = element.key; + var pendingProps = element.props; + + var fiberTag = void 0; if (typeof type === "function") { - if (shouldConstruct(type)) { - fiberTag = ClassComponent; - } + fiberTag = shouldConstruct(type) ? ClassComponent : IndeterminateComponent; } else if (typeof type === "string") { fiberTag = HostComponent; } else { @@ -5357,23 +5338,18 @@ function createFiberFromTypeAndProps( key ); case REACT_CONCURRENT_MODE_TYPE: - return createFiberFromMode( - pendingProps, - mode | ConcurrentMode | StrictMode, - expirationTime, - key - ); + fiberTag = Mode; + mode |= ConcurrentMode | StrictMode; + break; case REACT_STRICT_MODE_TYPE: - return createFiberFromMode( - pendingProps, - mode | StrictMode, - expirationTime, - key - ); + fiberTag = Mode; + mode |= StrictMode; + break; case REACT_PROFILER_TYPE: return createFiberFromProfiler(pendingProps, mode, expirationTime, key); case REACT_SUSPENSE_TYPE: - return createFiberFromSuspense(pendingProps, mode, expirationTime, key); + fiberTag = SuspenseComponent; + break; default: { if (typeof type === "object" && type !== null) { switch (type.$$typeof) { @@ -5387,13 +5363,15 @@ function createFiberFromTypeAndProps( case REACT_FORWARD_REF_TYPE: fiberTag = ForwardRef; break getTag; - case REACT_MEMO_TYPE: - fiberTag = MemoComponent; - break getTag; - case REACT_LAZY_TYPE: - fiberTag = LazyComponent; - resolvedType = null; + case REACT_PURE_TYPE: + fiberTag = PureComponent; break getTag; + default: { + if (typeof type.then === "function") { + fiberTag = IndeterminateComponent; + break getTag; + } + } } } var info = ""; @@ -5427,33 +5405,14 @@ function createFiberFromTypeAndProps( } fiber = createFiber(fiberTag, pendingProps, key, mode); - fiber.elementType = type; - fiber.type = resolvedType; + fiber.type = type; 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; } @@ -5477,41 +5436,12 @@ 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; @@ -5520,8 +5450,6 @@ 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; } @@ -5554,7 +5482,6 @@ 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; @@ -6097,12 +6024,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; } @@ -6128,12 +6055,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; @@ -6155,7 +6082,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; @@ -6169,7 +6096,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); @@ -6188,10 +6115,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) ); } @@ -6200,8 +6127,8 @@ function isPriorityLevelSuspended(root, expirationTime) { var latestSuspendedTime = root.latestSuspendedTime; return ( earliestSuspendedTime !== NoWork && - expirationTime <= earliestSuspendedTime && - expirationTime >= latestSuspendedTime + expirationTime >= earliestSuspendedTime && + expirationTime <= latestSuspendedTime ); } @@ -6234,10 +6161,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; } @@ -6253,7 +6180,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); @@ -6263,7 +6190,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; } } @@ -6273,10 +6200,18 @@ function findEarliestOutstandingPriorityLevel(root, renderExpirationTime) { var earliestPendingTime = root.earliestPendingTime; var earliestSuspendedTime = root.earliestSuspendedTime; - if (earliestPendingTime > earliestExpirationTime) { + if ( + earliestExpirationTime === NoWork || + (earliestPendingTime !== NoWork && + earliestPendingTime < earliestExpirationTime) + ) { earliestExpirationTime = earliestPendingTime; } - if (earliestSuspendedTime > earliestExpirationTime) { + if ( + earliestExpirationTime === NoWork || + (earliestSuspendedTime !== NoWork && + earliestSuspendedTime < earliestExpirationTime) + ) { earliestExpirationTime = earliestSuspendedTime; } return earliestExpirationTime; @@ -6284,7 +6219,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; } @@ -6306,7 +6241,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, @@ -6315,7 +6250,11 @@ function findNextExpirationTimeToWorkOn(completedExpirationTime, root) { } var expirationTime = nextExpirationTimeToWorkOn; - if (expirationTime !== NoWork && earliestSuspendedTime > expirationTime) { + if ( + expirationTime !== NoWork && + earliestSuspendedTime !== NoWork && + earliestSuspendedTime < expirationTime + ) { // Expire using the earliest known expiration time. expirationTime = earliestSuspendedTime; } @@ -6539,7 +6478,7 @@ function enqueueUpdate(fiber, update) { { if ( - fiber.tag === ClassComponent && + (fiber.tag === ClassComponent || fiber.tag === ClassComponentLazy) && (currentlyProcessingQueue === queue1 || (queue2 !== null && currentlyProcessingQueue === queue2)) && !didWarnUpdateInsideUpdate @@ -6687,7 +6626,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 @@ -6699,7 +6638,10 @@ function processUpdateQueue( } // Since this update will remain in the list, update the remaining // expiration time. - if (newExpirationTime < updateExpirationTime) { + if ( + newExpirationTime === NoWork || + newExpirationTime > updateExpirationTime + ) { newExpirationTime = updateExpirationTime; } } else { @@ -6735,7 +6677,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 @@ -6749,7 +6691,10 @@ function processUpdateQueue( } // Since this update will remain in the list, update the remaining // expiration time. - if (newExpirationTime < _updateExpirationTime) { + if ( + newExpirationTime === NoWork || + newExpirationTime > _updateExpirationTime + ) { newExpirationTime = _updateExpirationTime; } } else { @@ -7047,7 +6992,10 @@ function propagateContextChange( ) { // Match! Schedule an update on this fiber. - if (fiber.tag === ClassComponent) { + if ( + fiber.tag === ClassComponent || + fiber.tag === ClassComponentLazy + ) { // Schedule a force update on the work-in-progress. var update = createUpdate(renderExpirationTime); update.tag = ForceUpdate; @@ -7058,13 +7006,17 @@ function propagateContextChange( enqueueUpdate(fiber, update); } - if (fiber.expirationTime < renderExpirationTime) { + if ( + fiber.expirationTime === NoWork || + fiber.expirationTime > renderExpirationTime + ) { fiber.expirationTime = renderExpirationTime; } var alternate = fiber.alternate; if ( alternate !== null && - alternate.expirationTime < renderExpirationTime + (alternate.expirationTime === NoWork || + alternate.expirationTime > renderExpirationTime) ) { alternate.expirationTime = renderExpirationTime; } @@ -7073,17 +7025,22 @@ function propagateContextChange( var node = fiber.return; while (node !== null) { alternate = node.alternate; - if (node.childExpirationTime < renderExpirationTime) { + if ( + node.childExpirationTime === NoWork || + node.childExpirationTime > renderExpirationTime + ) { node.childExpirationTime = renderExpirationTime; if ( alternate !== null && - alternate.childExpirationTime < renderExpirationTime + (alternate.childExpirationTime === NoWork || + alternate.childExpirationTime > renderExpirationTime) ) { alternate.childExpirationTime = renderExpirationTime; } } else if ( alternate !== null && - alternate.childExpirationTime < renderExpirationTime + (alternate.childExpirationTime === NoWork || + alternate.childExpirationTime > renderExpirationTime) ) { alternate.childExpirationTime = renderExpirationTime; } else { @@ -7168,7 +7125,7 @@ function readContext(context, observedBits) { if (lastContextDependency === null) { invariant( currentlyRenderingFiber !== null, - "Context can only be read while React is " + + "Context.unstable_read(): 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 @@ -7181,637 +7138,6 @@ 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); @@ -7998,13 +7324,6 @@ 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; @@ -8144,7 +7463,6 @@ var classComponentUpdater = { update.callback = callback; } - flushPassiveEffects(); enqueueUpdate(fiber, update); scheduleWork(fiber, expirationTime); }, @@ -8164,7 +7482,6 @@ var classComponentUpdater = { update.callback = callback; } - flushPassiveEffects(); enqueueUpdate(fiber, update); scheduleWork(fiber, expirationTime); }, @@ -8183,7 +7500,6 @@ var classComponentUpdater = { update.callback = callback; } - flushPassiveEffects(); enqueueUpdate(fiber, update); scheduleWork(fiber, expirationTime); } @@ -8500,7 +7816,7 @@ function constructClassInstance( if (typeof contextType === "object" && contextType !== null) { { if ( - contextType.$$typeof !== REACT_CONTEXT_TYPE && + typeof contextType.unstable_read !== "function" && !didWarnAboutInvalidateContextType.has(ctor) ) { didWarnAboutInvalidateContextType.add(ctor); @@ -8514,7 +7830,7 @@ function constructClassInstance( } } - context = readContext$1(contextType); + context = contextType.unstable_read(); } else { unmaskedContext = getUnmaskedContext(workInProgress, ctor, true); var contextTypes = ctor.contextTypes; @@ -8716,7 +8032,7 @@ function mountClassInstance( var contextType = ctor.contextType; if (typeof contextType === "object" && contextType !== null) { - instance.context = readContext$1(contextType); + instance.context = contextType.unstable_read(); } else { var unmaskedContext = getUnmaskedContext(workInProgress, ctor, true); instance.context = getMaskedContext(workInProgress, unmaskedContext); @@ -8824,7 +8140,7 @@ function resumeMountClassInstance( var contextType = ctor.contextType; var nextContext = void 0; if (typeof contextType === "object" && contextType !== null) { - nextContext = readContext$1(contextType); + nextContext = contextType.unstable_read(); } else { var nextLegacyUnmaskedContext = getUnmaskedContext( workInProgress, @@ -8970,7 +8286,7 @@ function updateClassInstance( var contextType = ctor.contextType; var nextContext = void 0; if (typeof contextType === "object" && contextType !== null) { - nextContext = readContext$1(contextType); + nextContext = contextType.unstable_read(); } else { var nextUnmaskedContext = getUnmaskedContext(workInProgress, ctor, true); nextContext = getMaskedContext(workInProgress, nextUnmaskedContext); @@ -9213,7 +8529,8 @@ function coerceRef(returnFiber, current$$1, element) { if (owner) { var ownerFiber = owner; invariant( - ownerFiber.tag === ClassComponent, + ownerFiber.tag === ClassComponent || + ownerFiber.tag === ClassComponentLazy, "Function components cannot have refs." ); inst = ownerFiber.stateNode; @@ -9433,7 +8750,7 @@ function ChildReconciler(shouldTrackSideEffects) { } function updateElement(returnFiber, current$$1, element, expirationTime) { - if (current$$1 !== null && current$$1.elementType === element.type) { + if (current$$1 !== null && current$$1.type === element.type) { // Move based on index var existing = useFiber(current$$1, element.props, expirationTime); existing.ref = coerceRef(returnFiber, current$$1, element); @@ -10171,7 +9488,7 @@ function ChildReconciler(shouldTrackSideEffects) { if ( child.tag === Fragment ? element.type === REACT_FRAGMENT_TYPE - : child.elementType === element.type + : child.type === element.type ) { deleteRemainingChildren(returnFiber, child.sibling); var existing = useFiber( @@ -10354,7 +9671,8 @@ function ChildReconciler(shouldTrackSideEffects) { // component, throw an error. If Fiber return types are disabled, // we already threw above. switch (returnFiber.tag) { - case ClassComponent: { + case ClassComponent: + case ClassComponentLazy: { { var instance = returnFiber.stateNode; if (instance.render._isMockFunction) { @@ -10737,54 +10055,45 @@ function resetHydrationState() { isHydrating = false; } -function readLazyComponentType(lazyComponent) { - var status = lazyComponent._status; - var result = lazyComponent._result; +function readLazyComponentType(thenable) { + var status = thenable._reactStatus; switch (status) { - case Resolved: { - var Component = result; + case Resolved: + var Component = thenable._reactResult; return Component; - } - case Rejected: { - var error = result; - throw error; - } - case Pending: { - var thenable = result; + case Rejected: + throw thenable._reactResult; + case Pending: throw thenable; - } default: { - 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._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 = Resolved; - lazyComponent._result = defaultExport; + thenable._reactResult = resolvedValue; } }, function(error) { - if (lazyComponent._status === Pending) { - lazyComponent._status = Rejected; - lazyComponent._result = error; + if (thenable._reactStatus === Pending) { + thenable._reactStatus = Rejected; + thenable._reactResult = error; } } ); - lazyComponent._result = _thenable; - throw _thenable; + throw thenable; } } } @@ -10871,24 +10180,85 @@ function forceUnmountCurrentAndReconcile( function updateForwardRef( current$$1, workInProgress, - Component, + type, nextProps, renderExpirationTime ) { - var render = Component.render; + 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 + ); + } + } - // 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); + + 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); + { + ReactCurrentOwner$3.current = workInProgress; + setCurrentPhase("render"); + nextChildren = render(nextProps, ref); + setCurrentPhase(null); + } // React DevTools reads this flag. workInProgress.effectTag |= PerformedWork; @@ -10898,107 +10268,10 @@ function updateForwardRef( 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( @@ -11007,6 +10280,7 @@ function updateFragment(current$$1, workInProgress, renderExpirationTime) { nextChildren, renderExpirationTime ); + memoizeProps(workInProgress, nextChildren); return workInProgress.child; } @@ -11018,6 +10292,7 @@ function updateMode(current$$1, workInProgress, renderExpirationTime) { nextChildren, renderExpirationTime ); + memoizeProps(workInProgress, nextChildren); return workInProgress.child; } @@ -11033,6 +10308,7 @@ function updateProfiler(current$$1, workInProgress, renderExpirationTime) { nextChildren, renderExpirationTime ); + memoizeProps(workInProgress, nextProps); return workInProgress.child; } @@ -11059,14 +10335,12 @@ 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; @@ -11076,6 +10350,7 @@ function updateFunctionComponent( nextChildren, renderExpirationTime ); + memoizeProps(workInProgress, nextProps); return workInProgress.child; } @@ -11098,41 +10373,32 @@ function updateClassComponent( } prepareToReadContext(workInProgress, renderExpirationTime); - var instance = workInProgress.stateNode; var shouldUpdate = void 0; - 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; + 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 + ); } - // 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, @@ -11234,9 +10500,10 @@ function finishClassComponent( ); } - // Memoize state using the values we just used to render. + // Memoize props and state using the values we just used to render. // TODO: Restructure so we never read values from the instance. - workInProgress.memoizedState = instance.state; + memoizeState(workInProgress, instance.state); + memoizeProps(workInProgress, instance.props); // The context might have changed so we need to recalculate it. if (hasContext) { @@ -11370,6 +10637,7 @@ 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; } @@ -11379,6 +10647,7 @@ function updateHostComponent(current$$1, workInProgress, renderExpirationTime) { nextChildren, renderExpirationTime ); + memoizeProps(workInProgress, nextProps); return workInProgress.child; } @@ -11386,6 +10655,8 @@ 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; @@ -11406,173 +10677,98 @@ function resolveDefaultProps(Component, baseProps) { return baseProps; } -function mountLazyComponent( - _current, +function mountIndeterminateComponent( + current$$1, workInProgress, - elementType, + Component, updateExpirationTime, renderExpirationTime ) { - 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; - } + 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; - // 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; + 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 + ); + } } - 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; + workInProgress.memoizedProps = props; + return child; } - // 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; @@ -11614,9 +10810,6 @@ 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. @@ -11644,7 +10837,7 @@ function mountIndeterminateComponent( adoptClassInstance(workInProgress, value); mountClassInstance(workInProgress, Component, props, renderExpirationTime); return finishClassComponent( - null, + current$$1, workInProgress, Component, true, @@ -11654,7 +10847,6 @@ 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 @@ -11717,7 +10909,8 @@ function mountIndeterminateComponent( } } } - reconcileChildren(null, workInProgress, value, renderExpirationTime); + reconcileChildren(current$$1, workInProgress, value, renderExpirationTime); + memoizeProps(workInProgress, props); return workInProgress.child; } } @@ -11727,207 +10920,67 @@ function updateSuspenseComponent( workInProgress, renderExpirationTime ) { - var mode = workInProgress.mode; var nextProps = workInProgress.pendingProps; - // 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. + // 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; } else { - 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 { - // 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; - } - } + nextDidTimeout = !alreadyCaptured; } - 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 ((workInProgress.mode & StrictMode) !== NoEffect) { 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; + // If the timed-out view commits, schedule an update effect to record + // the committed time. + workInProgress.effectTag |= Update; } 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 - ); - } + // 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; } } - workInProgress.memoizedState = nextState; - workInProgress.child = child; - return next; + // 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; } function updatePortalComponent( @@ -11949,6 +11002,7 @@ function updatePortalComponent( nextChildren, renderExpirationTime ); + memoizeProps(workInProgress, nextChildren); } else { reconcileChildren( current$$1, @@ -11956,6 +11010,7 @@ function updatePortalComponent( nextChildren, renderExpirationTime ); + memoizeProps(workInProgress, nextChildren); } return workInProgress.child; } @@ -11972,6 +11027,7 @@ function updateContextProvider( var oldProps = workInProgress.memoizedProps; var newValue = newProps.value; + workInProgress.memoizedProps = newProps; { var providerPropTypes = workInProgress.type.propTypes; @@ -12040,18 +11096,13 @@ function updateContextConsumer( // in DEV mode if this property exists or not and warn if it does not. { if (context._context === undefined) { - // 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?" - ); - } + 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; @@ -12090,6 +11141,7 @@ function updateContextConsumer( newChildren, renderExpirationTime ); + workInProgress.memoizedProps = newProps; return workInProgress.child; } @@ -12131,7 +11183,10 @@ function bailoutOnAlreadyFinishedWork( // Check if the children have any pending work. var childExpirationTime = workInProgress.childExpirationTime; - if (childExpirationTime < renderExpirationTime) { + if ( + childExpirationTime === NoWork || + 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. @@ -12144,6 +11199,17 @@ 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; @@ -12153,7 +11219,8 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { if ( oldProps === newProps && !hasContextChanged() && - updateExpirationTime < renderExpirationTime + (updateExpirationTime === NoWork || + 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 @@ -12173,6 +11240,14 @@ 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, @@ -12189,46 +11264,6 @@ 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, @@ -12243,54 +11278,65 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { switch (workInProgress.tag) { case IndeterminateComponent: { - var elementType = workInProgress.elementType; + var _Component2 = workInProgress.type; return mountIndeterminateComponent( current$$1, workInProgress, - elementType, - renderExpirationTime - ); - } - case LazyComponent: { - var _elementType = workInProgress.elementType; - return mountLazyComponent( - current$$1, - workInProgress, - _elementType, + _Component2, updateExpirationTime, renderExpirationTime ); } case FunctionComponent: { - var _Component = workInProgress.type; + var _Component3 = workInProgress.type; var unresolvedProps = workInProgress.pendingProps; - var resolvedProps = - workInProgress.elementType === _Component - ? unresolvedProps - : resolveDefaultProps(_Component, unresolvedProps); return updateFunctionComponent( current$$1, workInProgress, - _Component, - resolvedProps, + _Component3, + unresolvedProps, renderExpirationTime ); } - case ClassComponent: { - var _Component2 = workInProgress.type; + case FunctionComponentLazy: { + var _thenable = workInProgress.type; + var _Component4 = getResultFromResolvedThenable(_thenable); var _unresolvedProps = workInProgress.pendingProps; - var _resolvedProps = - workInProgress.elementType === _Component2 - ? _unresolvedProps - : resolveDefaultProps(_Component2, _unresolvedProps); + 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; return updateClassComponent( current$$1, workInProgress, - _Component2, - _resolvedProps, + _Component5, + _unresolvedProps2, 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: @@ -12315,19 +11361,28 @@ 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, - _resolvedProps2, + workInProgress.pendingProps, 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: @@ -12346,43 +11401,31 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { workInProgress, renderExpirationTime ); - case MemoComponent: { + case PureComponent: { var _type = workInProgress.type; - var _unresolvedProps3 = workInProgress.pendingProps; - var _resolvedProps3 = resolveDefaultProps(_type.type, _unresolvedProps3); - return updateMemoComponent( + return updatePureComponent( current$$1, workInProgress, _type, - _resolvedProps3, - updateExpirationTime, - renderExpirationTime - ); - } - case SimpleMemoComponent: { - return updateSimpleMemoComponent( - current$$1, - workInProgress, - workInProgress.type, workInProgress.pendingProps, updateExpirationTime, renderExpirationTime ); } - case IncompleteClassComponent: { - var _Component3 = workInProgress.type; - var _unresolvedProps4 = workInProgress.pendingProps; - var _resolvedProps4 = - workInProgress.elementType === _Component3 - ? _unresolvedProps4 - : resolveDefaultProps(_Component3, _unresolvedProps4); - return mountIncompleteClassComponent( + case PureComponentLazy: { + var _thenable4 = workInProgress.type; + var _Component8 = getResultFromResolvedThenable(_thenable4); + var _unresolvedProps5 = workInProgress.pendingProps; + var _child3 = updatePureComponent( current$$1, workInProgress, - _Component3, - _resolvedProps4, + _Component8, + resolveDefaultProps(_Component8, _unresolvedProps5), + updateExpirationTime, renderExpirationTime ); + workInProgress.memoizedProps = _unresolvedProps5; + return _child3; } default: invariant( @@ -12403,48 +11446,42 @@ function markRef$1(workInProgress) { workInProgress.effectTag |= Ref; } -var appendAllChildren = void 0; +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 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 }; @@ -12498,202 +11535,26 @@ if (supportsMutation) { } else if (supportsPersistence) { // Persistent host tree 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) { - // 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 + 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) { - // 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); + if (node.tag === HostComponent || node.tag === HostText) { + appendChildToContainerChildSet(containerChildSet, 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.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; } @@ -12716,7 +11577,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, false, false); + appendAllChildrenToContainer(newChildSet, workInProgress); portalOrRoot.pendingChildren = newChildSet; // Schedule an update on the container to swap out the container. markUpdate(workInProgress); @@ -12789,7 +11650,7 @@ if (supportsMutation) { markUpdate(workInProgress); } else { // If children might have changed, we have to add them all to the set. - appendAllChildren(newInstance, workInProgress, false, false); + appendAllChildren(newInstance, workInProgress); } }; updateHostText$1 = function(current, workInProgress, oldText, newText) { @@ -12831,12 +11692,8 @@ 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; @@ -12845,6 +11702,13 @@ 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); @@ -12920,7 +11784,7 @@ function completeWork(current, workInProgress, renderExpirationTime) { workInProgress ); - appendAllChildren(instance, workInProgress, false, false); + appendAllChildren(instance, workInProgress); // Certain renderers require commit-time effects for initial mount. // (eg DOM renderer supports auto-focus for certain elements). @@ -12981,19 +11845,10 @@ function completeWork(current, workInProgress, renderExpirationTime) { break; } case ForwardRef: + case ForwardRefLazy: break; - 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; - } + case SuspenseComponent: break; - } case Fragment: break; case Mode: @@ -13010,17 +11865,18 @@ function completeWork(current, workInProgress, renderExpirationTime) { break; case ContextConsumer: break; - case MemoComponent: + case PureComponent: + case PureComponentLazy: break; - 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; - } + // 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 default: invariant( false, @@ -13032,17 +11888,6 @@ 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 @@ -13159,6 +12004,8 @@ function logCapturedError(capturedError) { } } +var emptyObject$1 = {}; + var didWarnAboutUndefinedSnapshotBeforeUpdate = null; { didWarnAboutUndefinedSnapshotBeforeUpdate = new Set(); @@ -13243,25 +12090,10 @@ 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 FunctionComponent: - case ForwardRef: - case SimpleMemoComponent: { - commitHookEffectList(UnmountSnapshot, NoEffect$1, finishedWork); - return; - } - case ClassComponent: { + case ClassComponent: + case ClassComponentLazy: { if (finishedWork.effectTag & Snapshot) { if (current$$1 !== null) { var prevProps = current$$1.memoizedProps; @@ -13293,7 +12125,6 @@ function commitBeforeMutationLifeCycles(current$$1, finishedWork) { case HostComponent: case HostText: case HostPortal: - case IncompleteClassComponent: // Nothing to do for these component types return; default: { @@ -13306,37 +12137,6 @@ 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, @@ -13344,13 +12144,8 @@ function commitLifeCycles( committedExpirationTime ) { switch (finishedWork.tag) { - case FunctionComponent: - case ForwardRef: - case SimpleMemoComponent: { - commitHookEffectList(UnmountLayout, MountLayout, finishedWork); - break; - } - case ClassComponent: { + case ClassComponent: + case ClassComponentLazy: { var instance = finishedWork.stateNode; if (finishedWork.effectTag & Update) { if (current$$1 === null) { @@ -13396,6 +12191,7 @@ function commitLifeCycles( _instance = getPublicInstance(finishedWork.child.stateNode); break; case ClassComponent: + case ClassComponentLazy: _instance = finishedWork.child.stateNode; break; } @@ -13460,49 +12256,22 @@ function commitLifeCycles( return; } case SuspenseComponent: { - 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(); + 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; 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 { - 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); + // 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 }; } return; } - case IncompleteClassComponent: - break; default: { invariant( false, @@ -13513,45 +12282,6 @@ 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) { @@ -13602,28 +12332,8 @@ function commitUnmount(current$$1) { onCommitUnmount(current$$1); switch (current$$1.tag) { - 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: { + case ClassComponent: + case ClassComponentLazy: { safelyDetachRef(current$$1); var instance = current$$1.stateNode; if (typeof instance.componentWillUnmount === "function") { @@ -13714,7 +12424,8 @@ function commitContainer(finishedWork) { } switch (finishedWork.tag) { - case ClassComponent: { + case ClassComponent: + case ClassComponentLazy: { return; } case HostComponent: { @@ -13989,29 +12700,13 @@ 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 FunctionComponent: - case ForwardRef: - case MemoComponent: - case SimpleMemoComponent: { - commitHookEffectList(UnmountMutation, MountMutation, finishedWork); - return; - } - case ClassComponent: { + case ClassComponent: + case ClassComponentLazy: { return; } case HostComponent: { @@ -14065,9 +12760,6 @@ function commitWork(current$$1, finishedWork) { case SuspenseComponent: { return; } - case IncompleteClassComponent: { - return; - } default: { invariant( false, @@ -14085,6 +12777,10 @@ 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. @@ -14178,17 +12874,22 @@ function throwException( var startTimeMs = -1; do { if (_workInProgress.tag === SuspenseComponent) { - 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 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 timeoutPropMs = _workInProgress.pendingProps.maxDuration; if (typeof timeoutPropMs === "number") { @@ -14208,127 +12909,129 @@ function throwException( // Schedule the nearest Suspense to re-render the timed out view. _workInProgress = returnFiber; do { - if ( - _workInProgress.tag === SuspenseComponent && - shouldCaptureSuspense(_workInProgress.alternate, _workInProgress) - ) { - // Found the nearest boundary. + if (_workInProgress.tag === SuspenseComponent) { + var didTimeout = _workInProgress.memoizedState; + if (!didTimeout) { + // 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, - 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 + // Attach a listener to the promise to "ping" the root and retry. + var onResolveOrReject = retrySuspendedRoot.bind( + null, + root, + _workInProgress, + pingTime ); - sourceFiber.effectTag &= ~Incomplete; - - // 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.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 (enableSchedulerTracing) { + onResolveOrReject = tracing.unstable_wrap(onResolveOrReject); } + thenable.then(onResolveOrReject, onResolveOrReject); - // Exit without suspending. - return; - } + // 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; - // 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, + // Unmount the source fiber's children + var nextChildren = null; + reconcileChildren( + sourceFiber.alternate, + sourceFiber, + nextChildren, renderExpirationTime ); - var earliestExpirationTimeMs = expirationTimeToMs( - earliestExpirationTime - ); - startTimeMs = earliestExpirationTimeMs - LOW_PRIORITY_EXPIRATION; + 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 || + 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; } - absoluteTimeoutMs = startTimeMs + earliestTimeoutMs; + + // 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; + return; } - - // 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. } - // 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( - (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) + "An update was suspended, but no placeholder UI was provided." ); } @@ -14353,6 +13056,7 @@ function throwException( return; } case ClassComponent: + case ClassComponentLazy: // Capture and retry var errorInfo = value; var ctor = workInProgress.type; @@ -14397,16 +13101,28 @@ function unwindWork(workInProgress, renderExpirationTime) { } return null; } + case ClassComponentLazy: { + var _Component = workInProgress.type._reactResult; + if (isContextProvider(_Component)) { + popContext(workInProgress); + } + var _effectTag = workInProgress.effectTag; + if (_effectTag & ShouldCapture) { + workInProgress.effectTag = (_effectTag & ~ShouldCapture) | DidCapture; + return workInProgress; + } + return null; + } case HostRoot: { popHostContainer(workInProgress); popTopLevelContextObject(workInProgress); - var _effectTag = workInProgress.effectTag; + var _effectTag2 = workInProgress.effectTag; invariant( - (_effectTag & DidCapture) === NoEffect, + (_effectTag2 & DidCapture) === NoEffect, "The root failed to unmount after an error. This is likely a bug in " + "React. Please file an issue." ); - workInProgress.effectTag = (_effectTag & ~ShouldCapture) | DidCapture; + workInProgress.effectTag = (_effectTag2 & ~ShouldCapture) | DidCapture; return workInProgress; } case HostComponent: { @@ -14414,36 +13130,9 @@ function unwindWork(workInProgress, renderExpirationTime) { return null; } case SuspenseComponent: { - 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. + var _effectTag3 = workInProgress.effectTag; + if (_effectTag3 & ShouldCapture) { + workInProgress.effectTag = (_effectTag3 & ~ShouldCapture) | DidCapture; return workInProgress; } return null; @@ -14468,6 +13157,14 @@ 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); @@ -14489,17 +13186,7 @@ function unwindInterruptedWork(interruptedWork) { } var Dispatcher = { - readContext: readContext, - useCallback: useCallback, - useContext: useContext, - useEffect: useEffect, - useImperativeMethods: useImperativeMethods, - useLayoutEffect: useLayoutEffect, - useMemo: useMemo, - useMutationEffect: useMutationEffect, - useReducer: useReducer, - useRef: useRef, - useState: useState + readContext: readContext }; var ReactCurrentOwner$2 = ReactSharedInternals.ReactCurrentOwner; @@ -14527,21 +13214,19 @@ if (enableSchedulerTracing) { didWarnSetStateChildContext = false; var didWarnStateUpdateForUnmountedComponent = {}; - warnAboutUpdateOnUnmounted = function(fiber, isClass) { + warnAboutUpdateOnUnmounted = function(fiber) { // 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) || "ReactComponent"; + var componentName = getComponentName(fiber.type) || "ReactClass"; if (didWarnStateUpdateForUnmountedComponent[componentName]) { return; } warningWithoutStack$1( false, - "Can't perform a React state update on an unmounted component. This " + + "Can't call setState (or forceUpdate) 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 %s.%s", - isClass - ? "the componentWillUnmount method" - : "a useEffect cleanup function", + "fix, cancel all subscriptions and asynchronous tasks in the " + + "componentWillUnmount method.%s", getStackByFiberInDevAndProd(fiber) ); didWarnStateUpdateForUnmountedComponent[componentName] = true; @@ -14593,9 +13278,6 @@ var nextRenderDidError = false; var nextEffect = null; var isCommitting$1 = false; -var rootWithPendingPassiveEffects = null; -var passiveEffectCallbackHandle = null; -var passiveEffectCallback = null; var legacyErrorBoundariesThatAlreadyFailed = null; @@ -14653,6 +13335,13 @@ if (true && replayFailedUnitOfWorkWithInvokeGuardedCallback) { } break; } + case ClassComponentLazy: { + var _Component = getResultFromResolvedThenable(failedUnitOfWork.type); + if (isContextProvider(_Component)) { + popContext(failedUnitOfWork); + } + break; + } case HostPortal: popHostContainer(failedUnitOfWork); break; @@ -14791,6 +13480,8 @@ function commitBeforeMutationLifecycles() { commitBeforeMutationLifeCycles(current$$1, nextEffect); } + // Don't cleanup effects yet; + // This will be done by commitAllLifeCycles() nextEffect = nextEffect.nextEffect; } @@ -14827,48 +13518,15 @@ function commitAllLifeCycles(finishedRoot, committedExpirationTime) { commitAttachRef(nextEffect); } - 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); + 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; } } @@ -14887,15 +13545,6 @@ 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; @@ -14921,7 +13570,9 @@ function commitRoot(root, finishedWork) { var updateExpirationTimeBeforeCommit = finishedWork.expirationTime; var childExpirationTimeBeforeCommit = finishedWork.childExpirationTime; var earliestRemainingTimeBeforeCommit = - childExpirationTimeBeforeCommit > updateExpirationTimeBeforeCommit + updateExpirationTimeBeforeCommit === NoWork || + (childExpirationTimeBeforeCommit !== NoWork && + childExpirationTimeBeforeCommit < updateExpirationTimeBeforeCommit) ? childExpirationTimeBeforeCommit : updateExpirationTimeBeforeCommit; markCommittedPriorityLevels(root, earliestRemainingTimeBeforeCommit); @@ -15063,22 +13714,6 @@ 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(); @@ -15091,7 +13726,9 @@ function commitRoot(root, finishedWork) { var updateExpirationTimeAfterCommit = finishedWork.expirationTime; var childExpirationTimeAfterCommit = finishedWork.childExpirationTime; var earliestRemainingTimeAfterCommit = - childExpirationTimeAfterCommit > updateExpirationTimeAfterCommit + updateExpirationTimeAfterCommit === NoWork || + (childExpirationTimeAfterCommit !== NoWork && + childExpirationTimeAfterCommit < updateExpirationTimeAfterCommit) ? childExpirationTimeAfterCommit : updateExpirationTimeAfterCommit; if (earliestRemainingTimeAfterCommit === NoWork) { @@ -15134,7 +13771,10 @@ 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 (scheduledExpirationTime > earliestRemainingTimeAfterCommit) { + if ( + earliestRemainingTimeAfterCommit === NoWork || + scheduledExpirationTime < earliestRemainingTimeAfterCommit + ) { pendingInteractionMap.delete(scheduledExpirationTime); scheduledInteractions.forEach(function(interaction) { @@ -15190,10 +13830,18 @@ function resetChildExpirationTime(workInProgress, renderTime) { while (child !== null) { var childUpdateExpirationTime = child.expirationTime; var childChildExpirationTime = child.childExpirationTime; - if (childUpdateExpirationTime > newChildExpirationTime) { + if ( + newChildExpirationTime === NoWork || + (childUpdateExpirationTime !== NoWork && + childUpdateExpirationTime < newChildExpirationTime) + ) { newChildExpirationTime = childUpdateExpirationTime; } - if (childChildExpirationTime > newChildExpirationTime) { + if ( + newChildExpirationTime === NoWork || + (childChildExpirationTime !== NoWork && + childChildExpirationTime < newChildExpirationTime) + ) { newChildExpirationTime = childChildExpirationTime; } if (shouldBubbleActualDurations) { @@ -15209,10 +13857,18 @@ function resetChildExpirationTime(workInProgress, renderTime) { while (_child !== null) { var _childUpdateExpirationTime = _child.expirationTime; var _childChildExpirationTime = _child.childExpirationTime; - if (_childUpdateExpirationTime > newChildExpirationTime) { + if ( + newChildExpirationTime === NoWork || + (_childUpdateExpirationTime !== NoWork && + _childUpdateExpirationTime < newChildExpirationTime) + ) { newChildExpirationTime = _childUpdateExpirationTime; } - if (_childChildExpirationTime > newChildExpirationTime) { + if ( + newChildExpirationTime === NoWork || + (_childChildExpirationTime !== NoWork && + _childChildExpirationTime < newChildExpirationTime) + ) { newChildExpirationTime = _childChildExpirationTime; } _child = _child.sibling; @@ -15426,7 +14082,6 @@ 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). @@ -15434,7 +14089,6 @@ function performUnitOfWork(workInProgress) { } } else { next = beginWork(current$$1, workInProgress, nextRenderExpirationTime); - workInProgress.memoizedProps = workInProgress.pendingProps; } { @@ -15468,22 +14122,19 @@ function workLoop(isYieldy) { nextUnitOfWork = performUnitOfWork(nextUnitOfWork); } } else { - // Flush asynchronous work until there's a higher priority event - while (nextUnitOfWork !== null && !shouldYieldToRenderer()) { + // Flush asynchronous work until the deadline runs out of time. + while (nextUnitOfWork !== null && !shouldYield()) { nextUnitOfWork = performUnitOfWork(nextUnitOfWork); } } } -function renderRoot(root, isYieldy) { +function renderRoot(root, isYieldy, isExpired) { 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; @@ -15515,7 +14166,7 @@ function renderRoot(root, isYieldy) { scheduledInteractions, scheduledExpirationTime ) { - if (scheduledExpirationTime >= expirationTime) { + if (scheduledExpirationTime <= expirationTime) { scheduledInteractions.forEach(function(interaction) { return interactions.add(interaction); }); @@ -15567,9 +14218,6 @@ function renderRoot(root, isYieldy) { try { workLoop(isYieldy); } catch (thrownValue) { - resetContextDependences(); - resetHooks(); - if (nextUnitOfWork === null) { // This is a fatal error. didFatal = true; @@ -15632,7 +14280,6 @@ function renderRoot(root, isYieldy) { isWorking = false; ReactCurrentOwner$2.currentDispatcher = null; resetContextDependences(); - resetHooks(); // Yield back to main thread. if (didFatal) { @@ -15704,7 +14351,7 @@ function renderRoot(root, isYieldy) { // similar to a suspend, but without a timeout because we're not waiting // for a promise to resolve. !root.didError && - isYieldy + !isExpired ) { root.didError = true; var _suspendedExpirationTime = (root.nextExpirationTimeToWorkOn = expirationTime); @@ -15720,7 +14367,7 @@ function renderRoot(root, isYieldy) { } } - if (isYieldy && nextLatestAbsoluteTimeoutMs !== -1) { + if (!isExpired && nextLatestAbsoluteTimeoutMs !== -1) { // The tree was suspended. var _suspendedExpirationTime2 = expirationTime; markSuspendedPriorityLevel(root, _suspendedExpirationTime2); @@ -15762,12 +14409,17 @@ function renderRoot(root, isYieldy) { onComplete(root, rootWorkInProgress, expirationTime); } -function captureCommitPhaseError(sourceFiber, value) { - var expirationTime = Sync; +function dispatch(sourceFiber, value, expirationTime) { + invariant( + !isWorking || isCommitting$1, + "dispatch: Cannot dispatch during the render phase." + ); + var fiber = sourceFiber.return; while (fiber !== null) { switch (fiber.tag) { case ClassComponent: + case ClassComponentLazy: var ctor = fiber.type; var instance = fiber.stateNode; if ( @@ -15808,6 +14460,10 @@ function captureCommitPhaseError(sourceFiber, value) { } } +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; @@ -15842,7 +14498,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 @@ -15853,10 +14509,7 @@ 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 ( - lowestPriorityPendingInteractiveExpirationTime === NoWork || - expirationTime < lowestPriorityPendingInteractiveExpirationTime - ) { + if (expirationTime > lowestPriorityPendingInteractiveExpirationTime) { lowestPriorityPendingInteractiveExpirationTime = expirationTime; } } @@ -15877,7 +14530,7 @@ function renderDidError() { nextRenderDidError = true; } -function retrySuspendedRoot(root, boundaryFiber, sourceFiber, suspendedTime) { +function retrySuspendedRoot(root, fiber, suspendedTime) { var retryTime = void 0; if (isPriorityLevelSuspended(root, suspendedTime)) { @@ -15888,18 +14541,18 @@ function retrySuspendedRoot(root, boundaryFiber, sourceFiber, suspendedTime) { } else { // Suspense already timed out. Compute a new expiration time var currentTime = requestCurrentTime(); - retryTime = computeExpirationForFiber(currentTime, boundaryFiber); + retryTime = computeExpirationForFiber(currentTime, fiber); markPendingPriorityLevel(root, retryTime); } - // TODO: If the suspense fiber has already rendered the primary children + // TODO: If the placeholder 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 ((boundaryFiber.mode & ConcurrentMode) !== NoContext) { + if ((fiber.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. @@ -15907,23 +14560,7 @@ function retrySuspendedRoot(root, boundaryFiber, sourceFiber, suspendedTime) { } } - 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); - } - } - + scheduleWorkToRoot(fiber, retryTime); var rootExpirationTime = root.expirationTime; if (rootExpirationTime !== NoWork) { requestWork(root, rootExpirationTime); @@ -15934,18 +14571,25 @@ function scheduleWorkToRoot(fiber, expirationTime) { recordScheduleUpdate(); { - if (fiber.tag === ClassComponent) { + if (fiber.tag === ClassComponent || fiber.tag === ClassComponentLazy) { var instance = fiber.stateNode; warnAboutInvalidUpdates(instance); } } // Update the source fiber's expiration time - if (fiber.expirationTime < expirationTime) { + if ( + fiber.expirationTime === NoWork || + fiber.expirationTime > expirationTime + ) { fiber.expirationTime = expirationTime; } var alternate = fiber.alternate; - if (alternate !== null && alternate.expirationTime < expirationTime) { + if ( + alternate !== null && + (alternate.expirationTime === NoWork || + alternate.expirationTime > expirationTime) + ) { alternate.expirationTime = expirationTime; } // Walk the parent path to the root and update the child expiration time. @@ -15956,17 +14600,22 @@ function scheduleWorkToRoot(fiber, expirationTime) { } else { while (node !== null) { alternate = node.alternate; - if (node.childExpirationTime < expirationTime) { + if ( + node.childExpirationTime === NoWork || + node.childExpirationTime > expirationTime + ) { node.childExpirationTime = expirationTime; if ( alternate !== null && - alternate.childExpirationTime < expirationTime + (alternate.childExpirationTime === NoWork || + alternate.childExpirationTime > expirationTime) ) { alternate.childExpirationTime = expirationTime; } } else if ( alternate !== null && - alternate.childExpirationTime < expirationTime + (alternate.childExpirationTime === NoWork || + alternate.childExpirationTime > expirationTime) ) { alternate.childExpirationTime = expirationTime; } @@ -15979,18 +14628,11 @@ function scheduleWorkToRoot(fiber, expirationTime) { } if (root === null) { - { - switch (fiber.tag) { - case ClassComponent: - warnAboutUpdateOnUnmounted(fiber, true); - break; - case FunctionComponent: - case ForwardRef: - case MemoComponent: - case SimpleMemoComponent: - warnAboutUpdateOnUnmounted(fiber, false); - break; - } + if ( + true && + (fiber.tag === ClassComponent || fiber.tag === ClassComponentLazy) + ) { + warnAboutUpdateOnUnmounted(fiber); } return null; } @@ -16041,7 +14683,7 @@ function scheduleWork(fiber, expirationTime) { if ( !isWorking && nextRenderExpirationTime !== NoWork && - expirationTime > nextRenderExpirationTime + expirationTime < nextRenderExpirationTime ) { // This is an interruption. (Used for performance tracking.) interruptedBy = fiber; @@ -16085,8 +14727,10 @@ 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; @@ -16103,6 +14747,8 @@ var NESTED_UPDATE_LIMIT = 50; var nestedUpdateCount = 0; var lastCommittedRootDuringThisBatch = null; +var timeHeuristicForUnitOfWork = 1; + function recomputeCurrentRendererTime() { var currentTimeMs = now() - originalStartTimeMs; currentRendererTime = msToExpirationTime(currentTimeMs); @@ -16111,7 +14757,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 { @@ -16154,7 +14800,7 @@ function onSuspend( msUntilTimeout ) { root.expirationTime = rootExpirationTime; - if (msUntilTimeout === 0 && !shouldYieldToRenderer()) { + if (msUntilTimeout === 0 && !shouldYield()) { // Don't wait an additional tick. Commit the tree immediately. root.pendingCommitExpirationTime = suspendedExpirationTime; root.finishedWork = finishedWork; @@ -16249,7 +14895,7 @@ function requestWork(root, expirationTime) { // flush it now. nextFlushedRoot = root; nextFlushedExpirationTime = Sync; - performWorkOnRoot(root, Sync, false); + performWorkOnRoot(root, Sync, true); } return; } @@ -16279,7 +14925,10 @@ function addRootToSchedule(root, expirationTime) { } else { // This root is already scheduled, but its priority may have increased. var remainingExpirationTime = root.expirationTime; - if (expirationTime > remainingExpirationTime) { + if ( + remainingExpirationTime === NoWork || + expirationTime < remainingExpirationTime + ) { // Update the priority. root.expirationTime = expirationTime; } @@ -16328,7 +14977,10 @@ function findHighestPriorityRoot() { } root = previousScheduledRoot.nextScheduledRoot; } else { - if (remainingExpirationTime > highestPriorityWork) { + if ( + highestPriorityWork === NoWork || + remainingExpirationTime < highestPriorityWork + ) { // Update the priority, if it's higher highestPriorityWork = remainingExpirationTime; highestPriorityRoot = root; @@ -16351,60 +15003,43 @@ function findHighestPriorityRoot() { nextFlushedExpirationTime = highestPriorityWork; } -// 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); - } +function performAsyncWork(dl) { + if (dl.didTimeout) { + // The callback timed out. That means at least one update has expired. + // Iterate through the root schedule. If they contain expired work, set + // the next render expiration time to the current time. This has the effect + // of flushing all expired work in a single batch, instead of flushing each + // level one at a time. + if (firstScheduledRoot !== null) { + recomputeCurrentRendererTime(); + var root = firstScheduledRoot; + do { + didExpireAtExpirationTime(root, currentRendererTime); + // The root schedule is circular, so this is never null. + root = root.nextScheduledRoot; + } while (root !== firstScheduledRoot); } - performWork(NoWork, true); - } finally { - didYield = false; } + performWork(NoWork, dl); } function performSyncWork() { - performWork(Sync, false); + performWork(Sync, null); } -function performWork(minExpirationTime, isYieldy) { - // Keep working on roots until there's no more work, or until there's a higher - // priority event. +function performWork(minExpirationTime, dl) { + deadline = dl; + + // Keep working on roots until there's no more work, or until we reach + // the deadline. findHighestPriorityRoot(); - if (isYieldy) { + if (deadline !== null) { recomputeCurrentRendererTime(); currentSchedulerTime = currentRendererTime; if (enableUserTimingAPI) { - var didExpire = nextFlushedExpirationTime > currentRendererTime; + var didExpire = nextFlushedExpirationTime < currentRendererTime; var timeout = expirationTimeToMs(nextFlushedExpirationTime); stopRequestCallbackTimer(didExpire, timeout); } @@ -16412,13 +15047,14 @@ function performWork(minExpirationTime, isYieldy) { while ( nextFlushedRoot !== null && nextFlushedExpirationTime !== NoWork && - minExpirationTime <= nextFlushedExpirationTime && - !(didYield && currentRendererTime > nextFlushedExpirationTime) + (minExpirationTime === NoWork || + minExpirationTime >= nextFlushedExpirationTime) && + (!deadlineDidExpire || currentRendererTime >= nextFlushedExpirationTime) ) { performWorkOnRoot( nextFlushedRoot, nextFlushedExpirationTime, - currentRendererTime > nextFlushedExpirationTime + currentRendererTime >= nextFlushedExpirationTime ); findHighestPriorityRoot(); recomputeCurrentRendererTime(); @@ -16428,9 +15064,10 @@ function performWork(minExpirationTime, isYieldy) { while ( nextFlushedRoot !== null && nextFlushedExpirationTime !== NoWork && - minExpirationTime <= nextFlushedExpirationTime + (minExpirationTime === NoWork || + minExpirationTime >= nextFlushedExpirationTime) ) { - performWorkOnRoot(nextFlushedRoot, nextFlushedExpirationTime, false); + performWorkOnRoot(nextFlushedRoot, nextFlushedExpirationTime, true); findHighestPriorityRoot(); } } @@ -16439,7 +15076,7 @@ function performWork(minExpirationTime, isYieldy) { // 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 (isYieldy) { + if (deadline !== null) { callbackExpirationTime = NoWork; callbackID = null; } @@ -16452,6 +15089,9 @@ function performWork(minExpirationTime, isYieldy) { } // Clean-up. + deadline = null; + deadlineDidExpire = false; + finishRendering(); } @@ -16466,7 +15106,7 @@ function flushRoot(root, expirationTime) { // including the given time. nextFlushedRoot = root; nextFlushedExpirationTime = expirationTime; - performWorkOnRoot(root, expirationTime, false); + performWorkOnRoot(root, expirationTime, true); // Flush any sync work that was scheduled by lifecycles performSyncWork(); } @@ -16499,7 +15139,7 @@ function finishRendering() { } } -function performWorkOnRoot(root, expirationTime, isYieldy) { +function performWorkOnRoot(root, expirationTime, isExpired) { invariant( !isRendering, "performWorkOnRoot was called recursively. This error is likely caused " + @@ -16509,7 +15149,7 @@ function performWorkOnRoot(root, expirationTime, isYieldy) { isRendering = true; // Check if this is async work or sync/expired work. - if (!isYieldy) { + if (deadline === null || isExpired) { // 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 @@ -16529,7 +15169,8 @@ function performWorkOnRoot(root, expirationTime, isYieldy) { // $FlowFixMe Complains noTimeout is not a TimeoutID, despite the check above cancelTimeout(timeoutHandle); } - renderRoot(root, isYieldy); + var isYieldy = false; + renderRoot(root, isYieldy, isExpired); finishedWork = root.finishedWork; if (finishedWork !== null) { // We've completed the root. Commit it. @@ -16552,12 +15193,13 @@ function performWorkOnRoot(root, expirationTime, isYieldy) { // $FlowFixMe Complains noTimeout is not a TimeoutID, despite the check above cancelTimeout(_timeoutHandle); } - renderRoot(root, isYieldy); + var _isYieldy = true; + renderRoot(root, _isYieldy, isExpired); _finishedWork = root.finishedWork; if (_finishedWork !== null) { - // We've completed the root. Check the if we should yield one more time + // We've completed the root. Check the deadline one more time // before committing. - if (!shouldYieldToRenderer()) { + if (!shouldYield()) { // Still time left. Commit the root. completeRoot$1(root, _finishedWork, expirationTime); } else { @@ -16575,7 +15217,7 @@ function performWorkOnRoot(root, expirationTime, isYieldy) { 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 { @@ -16607,6 +15249,24 @@ 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, @@ -16651,7 +15311,7 @@ function interactiveUpdates$1(fn, a, b) { lowestPriorityPendingInteractiveExpirationTime !== NoWork ) { // Synchronously flush pending interactive updates. - performWork(lowestPriorityPendingInteractiveExpirationTime, false); + performWork(lowestPriorityPendingInteractiveExpirationTime, null); lowestPriorityPendingInteractiveExpirationTime = NoWork; } var previousIsBatchingInteractiveUpdates = isBatchingInteractiveUpdates; @@ -16675,7 +15335,7 @@ function flushInteractiveUpdates$1() { lowestPriorityPendingInteractiveExpirationTime !== NoWork ) { // Synchronously flush pending interactive updates. - performWork(lowestPriorityPendingInteractiveExpirationTime, false); + performWork(lowestPriorityPendingInteractiveExpirationTime, null); lowestPriorityPendingInteractiveExpirationTime = NoWork; } } @@ -16704,6 +15364,11 @@ 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; @@ -16741,11 +15406,9 @@ function scheduleRootUpdate(current$$1, element, expirationTime, callback) { : void 0; update.callback = callback; } - - flushPassiveEffects(); enqueueUpdate(current$$1, update); - scheduleWork(current$$1, expirationTime); + scheduleWork(current$$1, expirationTime); return expirationTime; } @@ -16936,7 +15599,7 @@ function createPortal( // TODO: this is special because it gets imported during build. -var ReactVersion = "16.6.0"; +var ReactVersion = "16.6.0-alpha.8af6728"; // Modules provided by RN: var NativeMethodsMixin = function(findNodeHandle, findHostInstance) { @@ -17338,9 +16001,9 @@ function getInstanceFromTag(tag) { } // Module provided by RN: -var emptyObject$1 = {}; +var emptyObject$2 = {}; { - Object.freeze(emptyObject$1); + Object.freeze(emptyObject$2); } var getInspectorDataForViewTag = void 0; @@ -17373,9 +16036,9 @@ var getInspectorDataForViewTag = void 0; var getHostProps = function(fiber) { var host = findCurrentHostFiber(fiber); if (host) { - return host.memoizedProps || emptyObject$1; + return host.memoizedProps || emptyObject$2; } - return emptyObject$1; + return emptyObject$2; }; var getHostNode = function(fiber, findNodeHandle) { @@ -17421,7 +16084,7 @@ var getInspectorDataForViewTag = void 0; if (!closestInstance) { return { hierarchy: [], - props: emptyObject$1, + props: emptyObject$2, selection: null, source: null }; diff --git a/Libraries/Renderer/oss/ReactFabric-prod.js b/Libraries/Renderer/oss/ReactFabric-prod.js index 58700577f97..9bd0a470b98 100644 --- a/Libraries/Renderer/oss/ReactFabric-prod.js +++ b/Libraries/Renderer/oss/ReactFabric-prod.js @@ -19,8 +19,7 @@ var ReactNativeViewConfigRegistry = require("ReactNativeViewConfigRegistry"), flattenStyle = require("flattenStyle"), TextInputState = require("TextInputState"), FabricUIManager = require("FabricUIManager"); -var scheduler = require("scheduler"), - ExceptionsManager = require("ExceptionsManager"); +var ExceptionsManager = require("ExceptionsManager"); function invariant(condition, format, a, b, c, d, e, f) { if (!condition) { condition = void 0; @@ -294,7 +293,7 @@ function getListener(inst, registrationName) { } function getParent(inst) { do inst = inst.return; - while (inst && 5 !== inst.tag); + while (inst && 7 !== inst.tag); return inst ? inst : null; } function traverseTwoPhase(inst, fn, arg) { @@ -1035,8 +1034,7 @@ var ReactSharedInternals = : 60111, REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for("react.forward_ref") : 60112, REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for("react.suspense") : 60113, - REACT_MEMO_TYPE = hasSymbol ? Symbol.for("react.memo") : 60115, - REACT_LAZY_TYPE = hasSymbol ? Symbol.for("react.lazy") : 60116, + REACT_PURE_TYPE = hasSymbol ? Symbol.for("react.pure") : 60115, MAYBE_ITERATOR_SYMBOL = "function" === typeof Symbol && Symbol.iterator; function getIteratorFn(maybeIterable) { if (null === maybeIterable || "object" !== typeof maybeIterable) return null; @@ -1045,6 +1043,13 @@ 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; @@ -1063,25 +1068,23 @@ 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: - 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); + return getWrappedName(type, type.render, "ForwardRef"); + case REACT_PURE_TYPE: + return getWrappedName(type, type.render, "Pure"); } + if ( + "function" === typeof type.then && + (type = 1 === type._reactStatus ? type._reactResult : null) + ) + return getComponentName(type); + } return null; } function isFiberMountedImpl(fiber) { @@ -1092,7 +1095,7 @@ function isFiberMountedImpl(fiber) { for (; node.return; ) if (((node = node.return), 0 !== (node.effectTag & 2))) return 1; } - return 3 === node.tag ? 2 : 3; + return 5 === node.tag ? 2 : 3; } function assertIsMounted(fiber) { invariant( @@ -1168,14 +1171,14 @@ function findCurrentFiberUsingSlowPath(fiber) { "Return fibers should always be each others' alternates. This error is likely caused by a bug in React. Please file an issue." ); } - invariant(3 === a.tag, "Unable to find node on an unmounted component."); + invariant(5 === a.tag, "Unable to find node on an unmounted component."); return a.stateNode.current === a ? fiber : alternate; } function findCurrentHostFiber(parent) { parent = findCurrentFiberUsingSlowPath(parent); if (!parent) return null; for (var node = parent; ; ) { - if (5 === node.tag || 6 === node.tag) return node; + if (7 === node.tag || 8 === node.tag) return node; if (node.child) (node.child.return = node), (node = node.child); else { if (node === parent) break; @@ -1425,12 +1428,18 @@ var now$1 = return Date.now(); }, scheduledCallback = null, - frameDeadline = 0; + frameDeadline = 0, + frameDeadlineObject = { + timeRemaining: function() { + return frameDeadline - now$1(); + }, + didTimeout: !1 + }; function setTimeoutCallback() { frameDeadline = now$1() + 5; var callback = scheduledCallback; scheduledCallback = null; - null !== callback && callback(); + null !== callback && callback(frameDeadlineObject); } var restoreTarget = null, restoreQueue = null; @@ -1594,13 +1603,13 @@ function getStackByFiberInDevAndProd(workInProgress) { var info = ""; do { a: switch (workInProgress.tag) { - case 2: - case 16: + case 4: case 0: case 1: - case 5: - case 8: - case 13: + case 2: + case 3: + case 7: + case 10: var owner = workInProgress._debugOwner, source = workInProgress._debugSource, name = getComponentName(workInProgress.type); @@ -1751,7 +1760,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 = this.elementType = null; + this.sibling = this.child = this.return = this.stateNode = this.type = null; this.index = 0; this.ref = null; this.pendingProps = pendingProps; @@ -1762,33 +1771,29 @@ 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(Component) { +function resolveLazyComponentTag(fiber, Component) { if ("function" === typeof Component) - return shouldConstruct(Component) ? 1 : 0; + return shouldConstruct(Component) ? 3 : 1; if (void 0 !== Component && null !== Component) { - Component = Component.$$typeof; - if (Component === REACT_FORWARD_REF_TYPE) return 11; - if (Component === REACT_MEMO_TYPE) return 14; + fiber = Component.$$typeof; + if (fiber === REACT_FORWARD_REF_TYPE) return 14; + if (fiber === REACT_PURE_TYPE) return 18; } - return 2; + return 4; } function createWorkInProgress(current, pendingProps) { var workInProgress = current.alternate; null === workInProgress - ? ((workInProgress = createFiber( + ? ((workInProgress = new FiberNode( current.tag, pendingProps, current.key, current.mode )), - (workInProgress.elementType = current.elementType), (workInProgress.type = current.type), (workInProgress.stateNode = current.stateNode), (workInProgress.alternate = current), @@ -1810,66 +1815,60 @@ function createWorkInProgress(current, pendingProps) { workInProgress.ref = current.ref; return workInProgress; } -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; +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; else a: switch (type) { case REACT_FRAGMENT_TYPE: return createFiberFromFragment( - pendingProps.children, + element.children, mode, expirationTime, key ); case REACT_CONCURRENT_MODE_TYPE: - return createFiberFromMode(pendingProps, mode | 3, expirationTime, key); + fiberTag = 10; + mode |= 3; + break; case REACT_STRICT_MODE_TYPE: - return createFiberFromMode(pendingProps, mode | 2, expirationTime, key); + fiberTag = 10; + mode |= 2; + break; case REACT_PROFILER_TYPE: return ( - (type = createFiber(12, pendingProps, key, mode | 4)), - (type.elementType = REACT_PROFILER_TYPE), + (type = new FiberNode(15, element, key, mode | 4)), (type.type = REACT_PROFILER_TYPE), (type.expirationTime = expirationTime), type ); case REACT_SUSPENSE_TYPE: - return ( - (type = createFiber(13, pendingProps, key, mode)), - (type.elementType = REACT_SUSPENSE_TYPE), - (type.type = REACT_SUSPENSE_TYPE), - (type.expirationTime = expirationTime), - type - ); + fiberTag = 16; + break; default: if ("object" === typeof type && null !== type) switch (type.$$typeof) { case REACT_PROVIDER_TYPE: - fiberTag = 10; + fiberTag = 12; break a; case REACT_CONTEXT_TYPE: - fiberTag = 9; - break a; - case REACT_FORWARD_REF_TYPE: fiberTag = 11; break a; - case REACT_MEMO_TYPE: - fiberTag = 14; + case REACT_FORWARD_REF_TYPE: + fiberTag = 13; break a; - case REACT_LAZY_TYPE: - fiberTag = 16; - owner = null; + case REACT_PURE_TYPE: + fiberTag = 17; break a; + default: + if ("function" === typeof type.then) { + fiberTag = 4; + break a; + } } invariant( !1, @@ -1878,33 +1877,24 @@ function createFiberFromTypeAndProps( "" ); } - key = createFiber(fiberTag, pendingProps, key, mode); - key.elementType = type; - key.type = owner; - key.expirationTime = expirationTime; - return key; + mode = new FiberNode(fiberTag, element, key, mode); + mode.type = type; + mode.expirationTime = expirationTime; + return mode; } function createFiberFromFragment(elements, mode, expirationTime, key) { - elements = createFiber(7, elements, key, mode); + elements = new FiberNode(9, 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 = createFiber(6, content, null, mode); + content = new FiberNode(8, content, null, mode); content.expirationTime = expirationTime; return content; } function createFiberFromPortal(portal, mode, expirationTime) { - mode = createFiber( - 4, + mode = new FiberNode( + 6, null !== portal.children ? portal.children : [], portal.key, mode @@ -1922,9 +1912,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); } @@ -1932,7 +1922,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; @@ -1947,18 +1937,22 @@ 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; - earliestPendingTime > renderExpirationTime && - (renderExpirationTime = earliestPendingTime); - root > renderExpirationTime && (renderExpirationTime = root); + if ( + 0 === renderExpirationTime || + (0 !== earliestPendingTime && earliestPendingTime < renderExpirationTime) + ) + renderExpirationTime = earliestPendingTime; + if (0 === renderExpirationTime || (0 !== root && root < renderExpirationTime)) + renderExpirationTime = root; return renderExpirationTime; } function findNextExpirationTimeToWorkOn(completedExpirationTime, root) { @@ -1970,11 +1964,12 @@ function findNextExpirationTimeToWorkOn(completedExpirationTime, root) { 0 !== earliestPendingTime ? earliestPendingTime : latestPingedTime; 0 === earliestPendingTime && (0 === completedExpirationTime || - latestSuspendedTime < completedExpirationTime) && + latestSuspendedTime > completedExpirationTime) && (earliestPendingTime = latestSuspendedTime); completedExpirationTime = earliestPendingTime; 0 !== completedExpirationTime && - earliestSuspendedTime > completedExpirationTime && + 0 !== earliestSuspendedTime && + earliestSuspendedTime < completedExpirationTime && (completedExpirationTime = earliestSuspendedTime); root.nextExpirationTimeToWorkOn = earliestPendingTime; root.expirationTime = completedExpirationTime; @@ -2086,7 +2081,7 @@ function getStateFromUpdate( : workInProgress ); case 3: - workInProgress.effectTag = (workInProgress.effectTag & -2049) | 64; + workInProgress.effectTag = (workInProgress.effectTag & -1025) | 64; case 0: workInProgress = update.payload; nextProps = @@ -2119,52 +2114,58 @@ function processUpdateQueue( ) { var updateExpirationTime = update.expirationTime; - updateExpirationTime < renderExpirationTime - ? (null === newFirstUpdate && + if (updateExpirationTime > renderExpirationTime) { + if ( + (null === newFirstUpdate && ((newFirstUpdate = update), (newBaseState = resultState)), - newExpirationTime < updateExpirationTime && - (newExpirationTime = updateExpirationTime)) - : ((resultState = getStateFromUpdate( - workInProgress, - queue, - update, - resultState, - props, - instance - )), + 0 === newExpirationTime || newExpirationTime > updateExpirationTime) + ) + newExpirationTime = updateExpirationTime; + } else + (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; - _updateExpirationTime < renderExpirationTime - ? (null === updateExpirationTime && + if (_updateExpirationTime > renderExpirationTime) { + if ( + (null === updateExpirationTime && ((updateExpirationTime = update), null === newFirstUpdate && (newBaseState = resultState)), - newExpirationTime < _updateExpirationTime && - (newExpirationTime = _updateExpirationTime)) - : ((resultState = getStateFromUpdate( - workInProgress, - queue, - update, - resultState, - props, - instance - )), + 0 === newExpirationTime || newExpirationTime > _updateExpirationTime) + ) + newExpirationTime = _updateExpirationTime; + } else + (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); @@ -2245,277 +2246,13 @@ function readContext(context, observedBits) { null === lastContextDependency ? (invariant( null !== currentlyRenderingFiber, - "Context can only be read while React is rendering, e.g. inside the render method or getDerivedStateFromProps." + "Context.unstable_read(): 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 }, @@ -2585,8 +2322,7 @@ function shallowEqual(objA, objB) { return !1; return !0; } -var ReactCurrentOwner$4 = ReactSharedInternals.ReactCurrentOwner, - emptyRefsObject = new React.Component().refs; +var emptyRefsObject = new React.Component().refs; function applyDerivedStateFromProps( workInProgress, ctor, @@ -2618,7 +2354,6 @@ var classComponentUpdater = { var update = createUpdate(currentTime); update.payload = payload; void 0 !== callback && null !== callback && (update.callback = callback); - flushPassiveEffects(); enqueueUpdate(inst, update); scheduleWork(inst, currentTime); }, @@ -2630,7 +2365,6 @@ var classComponentUpdater = { update.tag = 1; update.payload = payload; void 0 !== callback && null !== callback && (update.callback = callback); - flushPassiveEffects(); enqueueUpdate(inst, update); scheduleWork(inst, currentTime); }, @@ -2641,7 +2375,6 @@ var classComponentUpdater = { var update = createUpdate(currentTime); update.tag = 2; void 0 !== callback && null !== callback && (update.callback = callback); - flushPassiveEffects(); enqueueUpdate(inst, update); scheduleWork(inst, currentTime); } @@ -2662,32 +2395,6 @@ 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, @@ -2714,9 +2421,7 @@ function mountClassInstance( instance.refs = emptyRefsObject; var contextType = ctor.contextType; "object" === typeof contextType && null !== contextType - ? (instance.context = ReactCurrentOwner$4.currentDispatcher.readContext( - contextType - )) + ? (instance.context = contextType.unstable_read()) : ((contextType = isContextProvider(ctor) ? previousContext : contextStackCursor.current), @@ -2771,7 +2476,10 @@ function coerceRef(returnFiber, current$$1, element) { element = element._owner; var inst = void 0; element && - (invariant(1 === element.tag, "Function components cannot have refs."), + (invariant( + 2 === element.tag || 3 === element.tag, + "Function components cannot have refs." + ), (inst = element.stateNode)); invariant( inst, @@ -2876,7 +2584,7 @@ function ChildReconciler(shouldTrackSideEffects) { textContent, expirationTime ) { - if (null === current$$1 || 6 !== current$$1.tag) + if (null === current$$1 || 8 !== current$$1.tag) return ( (current$$1 = createFiberFromText( textContent, @@ -2891,18 +2599,15 @@ function ChildReconciler(shouldTrackSideEffects) { return current$$1; } function updateElement(returnFiber, current$$1, element, expirationTime) { - if (null !== current$$1 && current$$1.elementType === element.type) + if (null !== current$$1 && current$$1.type === element.type) return ( (expirationTime = useFiber(current$$1, element.props, expirationTime)), (expirationTime.ref = coerceRef(returnFiber, current$$1, element)), (expirationTime.return = returnFiber), expirationTime ); - expirationTime = createFiberFromTypeAndProps( - element.type, - element.key, - element.props, - null, + expirationTime = createFiberFromElement( + element, returnFiber.mode, expirationTime ); @@ -2913,7 +2618,7 @@ function ChildReconciler(shouldTrackSideEffects) { function updatePortal(returnFiber, current$$1, portal, expirationTime) { if ( null === current$$1 || - 4 !== current$$1.tag || + 6 !== current$$1.tag || current$$1.stateNode.containerInfo !== portal.containerInfo || current$$1.stateNode.implementation !== portal.implementation ) @@ -2937,7 +2642,7 @@ function ChildReconciler(shouldTrackSideEffects) { expirationTime, key ) { - if (null === current$$1 || 7 !== current$$1.tag) + if (null === current$$1 || 9 !== current$$1.tag) return ( (current$$1 = createFiberFromFragment( fragment, @@ -2967,11 +2672,8 @@ function ChildReconciler(shouldTrackSideEffects) { switch (newChild.$$typeof) { case REACT_ELEMENT_TYPE: return ( - (expirationTime = createFiberFromTypeAndProps( - newChild.type, - newChild.key, - newChild.props, - null, + (expirationTime = createFiberFromElement( + newChild, returnFiber.mode, expirationTime )), @@ -3315,9 +3017,9 @@ function ChildReconciler(shouldTrackSideEffects) { ) { if (isUnkeyedTopLevelFragment.key === isObject) if ( - 7 === isUnkeyedTopLevelFragment.tag + 9 === isUnkeyedTopLevelFragment.tag ? newChild.type === REACT_FRAGMENT_TYPE - : isUnkeyedTopLevelFragment.elementType === newChild.type + : isUnkeyedTopLevelFragment.type === newChild.type ) { deleteRemainingChildren( returnFiber, @@ -3357,11 +3059,8 @@ function ChildReconciler(shouldTrackSideEffects) { )), (currentFirstChild.return = returnFiber), (returnFiber = currentFirstChild)) - : ((expirationTime = createFiberFromTypeAndProps( - newChild.type, - newChild.key, - newChild.props, - null, + : ((expirationTime = createFiberFromElement( + newChild, returnFiber.mode, expirationTime )), @@ -3383,7 +3082,7 @@ function ChildReconciler(shouldTrackSideEffects) { ) { if (currentFirstChild.key === isUnkeyedTopLevelFragment) if ( - 4 === currentFirstChild.tag && + 6 === currentFirstChild.tag && currentFirstChild.stateNode.containerInfo === newChild.containerInfo && currentFirstChild.stateNode.implementation === @@ -3421,7 +3120,7 @@ function ChildReconciler(shouldTrackSideEffects) { if ("string" === typeof newChild || "number" === typeof newChild) return ( (newChild = "" + newChild), - null !== currentFirstChild && 6 === currentFirstChild.tag + null !== currentFirstChild && 8 === currentFirstChild.tag ? (deleteRemainingChildren(returnFiber, currentFirstChild.sibling), (currentFirstChild = useFiber( currentFirstChild, @@ -3457,7 +3156,8 @@ function ChildReconciler(shouldTrackSideEffects) { isObject && throwOnInvalidObjectType(returnFiber, newChild); if ("undefined" === typeof newChild && !isUnkeyedTopLevelFragment) switch (returnFiber.tag) { - case 1: + case 2: + case 3: case 0: (expirationTime = returnFiber.type), invariant( @@ -3476,12 +3176,12 @@ var reconcileChildFibers = ChildReconciler(!0), isHydrating = !1; function tryHydrate(fiber, nextInstance) { switch (fiber.tag) { - case 5: + case 7: return ( (nextInstance = shim$1(nextInstance, fiber.type, fiber.pendingProps)), null !== nextInstance ? ((fiber.stateNode = nextInstance), !0) : !1 ); - case 6: + case 8: return ( (nextInstance = shim$1(nextInstance, fiber.pendingProps)), null !== nextInstance ? ((fiber.stateNode = nextInstance), !0) : !1 @@ -3504,8 +3204,7 @@ function tryToClaimNextHydratableInstance(fiber$jscomp$0) { return; } var returnFiber = hydrationParentFiber, - fiber = createFiber(5, null, null, 0); - fiber.elementType = "DELETED"; + fiber = new FiberNode(7, null, null, 0); fiber.type = "DELETED"; fiber.stateNode = firstAttemptedInstance; fiber.return = returnFiber; @@ -3523,33 +3222,36 @@ function tryToClaimNextHydratableInstance(fiber$jscomp$0) { (hydrationParentFiber = fiber$jscomp$0); } } -function readLazyComponentType(lazyComponent) { - var result = lazyComponent._result; - switch (lazyComponent._status) { +function readLazyComponentType(thenable) { + switch (thenable._reactStatus) { case 1: - return result; + return thenable._reactResult; case 2: - throw result; + throw thenable._reactResult; case 0: - throw result; + throw thenable; default: - 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)); + throw ((thenable._reactStatus = 0), + thenable.then( + function(resolvedValue) { + if (0 === thenable._reactStatus) { + thenable._reactStatus = 1; + if ("object" === typeof resolvedValue && null !== resolvedValue) { + var defaultExport = resolvedValue.default; + resolvedValue = + void 0 !== defaultExport && null !== defaultExport + ? defaultExport + : resolvedValue; + } + thenable._reactResult = resolvedValue; + } }, function(error) { - 0 === lazyComponent._status && - ((lazyComponent._status = 2), (lazyComponent._result = error)); + 0 === thenable._reactStatus && + ((thenable._reactStatus = 2), (thenable._reactResult = error)); } ), - (lazyComponent._result = result), - result); + thenable); } } var ReactCurrentOwner$3 = ReactSharedInternals.ReactCurrentOwner; @@ -3577,87 +3279,28 @@ function reconcileChildren( function updateForwardRef( current$$1, workInProgress, - Component, + type, nextProps, - renderExpirationTime$jscomp$0 -) { - Component = Component.render; - var ref = workInProgress.ref; - 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 updateMemoComponent( - current$$1, - workInProgress, - Component, - nextProps, - updateExpirationTime, renderExpirationTime ) { - 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; + type = type.render; + var ref = workInProgress.ref; if ( - updateExpirationTime < renderExpirationTime && - ((updateExpirationTime = type.memoizedProps), - (Component = Component.compare), - (Component = null !== Component ? Component : shallowEqual), - Component(updateExpirationTime, nextProps) && - current$$1.ref === workInProgress.ref) + !didPerformWorkStackCursor.current && + workInProgress.memoizedProps === nextProps && + ref === (null !== current$$1 ? current$$1.ref : null) ) return bailoutOnAlreadyFinishedWork( current$$1, workInProgress, renderExpirationTime ); - current$$1 = createWorkInProgress(type, nextProps, renderExpirationTime); - current$$1.ref = workInProgress.ref; - current$$1.return = workInProgress; - return (workInProgress.child = current$$1); + type = type(nextProps, ref); + reconcileChildren(current$$1, workInProgress, type, renderExpirationTime); + workInProgress.memoizedProps = nextProps; + return workInProgress.child; } -function updateSimpleMemoComponent( +function updatePureComponent( current$$1, workInProgress, Component, @@ -3665,22 +3308,29 @@ function updateSimpleMemoComponent( 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 - ); + var render = Component.render, + ref = workInProgress.ref; + if ( + null !== current$$1 && + (0 === updateExpirationTime || + updateExpirationTime > renderExpirationTime) && + ((updateExpirationTime = current$$1.memoizedProps), + (Component = Component.compare), + (Component = null !== Component ? Component : shallowEqual), + workInProgress.ref === current$$1.ref && + Component(updateExpirationTime, nextProps)) + ) + 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; } function markRef(current$$1, workInProgress) { var ref = workInProgress.ref; @@ -3695,30 +3345,22 @@ function updateFunctionComponent( workInProgress, Component, nextProps, - renderExpirationTime$jscomp$0 + renderExpirationTime ) { var unmaskedContext = isContextProvider(Component) ? previousContext : contextStackCursor.current; unmaskedContext = getMaskedContext(workInProgress, 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 - ); + prepareToReadContext(workInProgress, renderExpirationTime); + Component = Component(nextProps, unmaskedContext); workInProgress.effectTag |= 1; reconcileChildren( current$$1, workInProgress, - nextChildren, - renderExpirationTime$jscomp$0 + Component, + renderExpirationTime ); + workInProgress.memoizedProps = nextProps; return workInProgress.child; } function updateClassComponent( @@ -3733,149 +3375,166 @@ function updateClassComponent( pushContextProvider(workInProgress); } else hasContext = !1; prepareToReadContext(workInProgress, renderExpirationTime); - if (null === workInProgress.stateNode) - null !== current$$1 && - ((current$$1.alternate = null), - (workInProgress.alternate = null), - (workInProgress.effectTag |= 2)), - constructClassInstance( - workInProgress, - Component, - nextProps, - 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)); mountClassInstance( workInProgress, Component, nextProps, renderExpirationTime - ), - (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 instance.getSnapshotBeforeUpdate; - hasNewLifecycles || - ("function" !== typeof instance.UNSAFE_componentWillReceiveProps && - "function" !== typeof instance.componentWillReceiveProps) || - ((oldProps !== nextProps || oldContext !== contextType) && - callComponentWillReceiveProps( - workInProgress, - instance, - nextProps, - 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) + ); + 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), - (contextType = getMaskedContext(workInProgress, contextType))), - (getDerivedStateFromProps = Component.getDerivedStateFromProps), - (hasNewLifecycles = + (context = getMaskedContext(workInProgress, context))); + var getDerivedStateFromProps = Component.getDerivedStateFromProps; + (instance = "function" === typeof getDerivedStateFromProps || - "function" === typeof instance.getSnapshotBeforeUpdate) || - ("function" !== typeof instance.UNSAFE_componentWillReceiveProps && - "function" !== typeof instance.componentWillReceiveProps) || - ((oldProps !== nextProps || oldContext !== contextType) && + "function" === typeof unmaskedContext.getSnapshotBeforeUpdate) || + ("function" !== + typeof unmaskedContext.UNSAFE_componentWillReceiveProps && + "function" !== typeof unmaskedContext.componentWillReceiveProps) || + ((isLegacyContextConsumer !== nextProps || oldContext !== context) && callComponentWillReceiveProps( workInProgress, - instance, + unmaskedContext, nextProps, - contextType + context + )); + hasForceUpdate = !1; + var oldState = workInProgress.memoizedState; + oldContext = unmaskedContext.state = oldState; + var updateQueue = workInProgress.updateQueue; + null !== updateQueue && + (processUpdateQueue( + workInProgress, + updateQueue, + nextProps, + unmaskedContext, + renderExpirationTime + ), + (oldContext = workInProgress.memoizedState)); + 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) + ? previousContext + : contextStackCursor.current), + (context = getMaskedContext(workInProgress, context))), + (getDerivedStateFromProps = Component.getDerivedStateFromProps), + (instance = + "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), (oldContext = workInProgress.memoizedState), - (oldState = instance.state = oldContext), + (oldState = unmaskedContext.state = oldContext), (updateQueue = workInProgress.updateQueue), null !== updateQueue && (processUpdateQueue( workInProgress, updateQueue, nextProps, - instance, + unmaskedContext, renderExpirationTime ), (oldState = workInProgress.memoizedState)), - oldProps !== nextProps || + isLegacyContextConsumer !== nextProps || oldContext !== oldState || didPerformWorkStackCursor.current || hasForceUpdate @@ -3892,51 +3551,53 @@ function updateClassComponent( checkShouldComponentUpdate( workInProgress, Component, - oldProps, + isLegacyContextConsumer, nextProps, oldContext, oldState, - contextType + context )) - ? (hasNewLifecycles || - ("function" !== typeof instance.UNSAFE_componentWillUpdate && - "function" !== typeof instance.componentWillUpdate) || - ("function" === typeof instance.componentWillUpdate && - instance.componentWillUpdate( + ? (instance || + ("function" !== + typeof unmaskedContext.UNSAFE_componentWillUpdate && + "function" !== typeof unmaskedContext.componentWillUpdate) || + ("function" === typeof unmaskedContext.componentWillUpdate && + unmaskedContext.componentWillUpdate( nextProps, oldState, - contextType + context ), - "function" === typeof instance.UNSAFE_componentWillUpdate && - instance.UNSAFE_componentWillUpdate( + "function" === + typeof unmaskedContext.UNSAFE_componentWillUpdate && + unmaskedContext.UNSAFE_componentWillUpdate( nextProps, oldState, - contextType + context )), - "function" === typeof instance.componentDidUpdate && + "function" === typeof unmaskedContext.componentDidUpdate && (workInProgress.effectTag |= 4), - "function" === typeof instance.getSnapshotBeforeUpdate && + "function" === typeof unmaskedContext.getSnapshotBeforeUpdate && (workInProgress.effectTag |= 256)) - : ("function" !== typeof instance.componentDidUpdate || - (oldProps === current$$1.memoizedProps && + : ("function" !== typeof unmaskedContext.componentDidUpdate || + (isLegacyContextConsumer === current$$1.memoizedProps && oldContext === current$$1.memoizedState) || (workInProgress.effectTag |= 4), - "function" !== typeof instance.getSnapshotBeforeUpdate || - (oldProps === current$$1.memoizedProps && + "function" !== typeof unmaskedContext.getSnapshotBeforeUpdate || + (isLegacyContextConsumer === current$$1.memoizedProps && oldContext === current$$1.memoizedState) || (workInProgress.effectTag |= 256), (workInProgress.memoizedProps = nextProps), (workInProgress.memoizedState = oldState)), - (instance.props = nextProps), - (instance.state = oldState), - (instance.context = contextType), + (unmaskedContext.props = nextProps), + (unmaskedContext.state = oldState), + (unmaskedContext.context = context), (nextProps = getDerivedStateFromProps)) - : ("function" !== typeof instance.componentDidUpdate || - (oldProps === current$$1.memoizedProps && + : ("function" !== typeof unmaskedContext.componentDidUpdate || + (isLegacyContextConsumer === current$$1.memoizedProps && oldContext === current$$1.memoizedState) || (workInProgress.effectTag |= 4), - "function" !== typeof instance.getSnapshotBeforeUpdate || - (oldProps === current$$1.memoizedProps && + "function" !== typeof unmaskedContext.getSnapshotBeforeUpdate || + (isLegacyContextConsumer === current$$1.memoizedProps && oldContext === current$$1.memoizedState) || (workInProgress.effectTag |= 256), (nextProps = !1)); @@ -3995,6 +3656,7 @@ function finishClassComponent( renderExpirationTime ); workInProgress.memoizedState = shouldUpdate.state; + workInProgress.memoizedProps = shouldUpdate.props; hasContext && invalidateContextProvider(workInProgress, Component, !0); return workInProgress.child; } @@ -4020,105 +3682,6 @@ 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, @@ -4126,7 +3689,9 @@ function bailoutOnAlreadyFinishedWork( ) { null !== current$$1 && (workInProgress.firstContextDependency = current$$1.firstContextDependency); - if (workInProgress.childExpirationTime < renderExpirationTime) return null; + var childExpirationTime = workInProgress.childExpirationTime; + if (0 === childExpirationTime || childExpirationTime > renderExpirationTime) + return null; invariant( null === current$$1 || workInProgress.child === current$$1.child, "Resuming work not yet implemented." @@ -4155,562 +3720,557 @@ function bailoutOnAlreadyFinishedWork( } return workInProgress.child; } -function beginWork(current$$1, workInProgress, renderExpirationTime$jscomp$0) { +function beginWork(current$$1, workInProgress, renderExpirationTime) { var updateExpirationTime = workInProgress.expirationTime; if ( null !== current$$1 && current$$1.memoizedProps === workInProgress.pendingProps && !didPerformWorkStackCursor.current && - updateExpirationTime < renderExpirationTime$jscomp$0 + (0 === updateExpirationTime || updateExpirationTime > renderExpirationTime) ) { switch (workInProgress.tag) { - case 3: + case 5: pushHostRootContext(workInProgress); break; - case 5: + case 7: pushHostContext(workInProgress); break; - case 1: + case 2: isContextProvider(workInProgress.type) && pushContextProvider(workInProgress); break; - case 4: + case 3: + isContextProvider(workInProgress.type._reactResult) && + pushContextProvider(workInProgress); + break; + case 6: pushHostContainer( workInProgress, workInProgress.stateNode.containerInfo ); break; - case 10: + case 12: 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$jscomp$0 + renderExpirationTime ); } workInProgress.expirationTime = 0; switch (workInProgress.tag) { - 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, - contextStackCursor.current + 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." ); - prepareToReadContext(workInProgress, renderExpirationTime$jscomp$0); - renderExpirationTime = renderExpirationTime$jscomp$0; - currentlyRenderingFiber$1 = workInProgress; - firstCurrentHook = null; - var value = updateExpirationTime(current$$1, context); - workInProgress.effectTag |= 1; + var props = workInProgress.pendingProps; if ( - "object" === typeof value && - null !== value && - "function" === typeof value.render && - void 0 === value.$$typeof + "object" === typeof Component && + null !== Component && + "function" === typeof Component.then ) { - 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( + Component = readLazyComponentType(Component); + var resolvedTag = (workInProgress.tag = resolveLazyComponentTag( 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 + Component )), - 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, + 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, - updateExpirationTime, - value, - renderExpirationTime$jscomp$0 - ) + 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, + workInProgress, + workInProgress.type, + workInProgress.pendingProps, + renderExpirationTime ); case 1: return ( - (updateExpirationTime = workInProgress.type), - (value = workInProgress.pendingProps), - (value = - workInProgress.elementType === updateExpirationTime - ? value - : resolveDefaultProps(updateExpirationTime, value)), - updateClassComponent( + (props = workInProgress.type._reactResult), + (Component = workInProgress.pendingProps), + (current$$1 = updateFunctionComponent( current$$1, workInProgress, - updateExpirationTime, - value, - renderExpirationTime$jscomp$0 - ) + props, + resolveDefaultProps(props, Component), + renderExpirationTime + )), + (workInProgress.memoizedProps = Component), + current$$1 + ); + case 2: + return updateClassComponent( + current$$1, + workInProgress, + workInProgress.type, + workInProgress.pendingProps, + renderExpirationTime ); 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), - (updateExpirationTime = workInProgress.updateQueue), + (Component = workInProgress.updateQueue), invariant( - null !== updateExpirationTime, + null !== Component, "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." ), - (value = workInProgress.memoizedState), - (value = null !== value ? value.element : null), + (props = workInProgress.memoizedState), + (props = null !== props ? props.element : null), processUpdateQueue( workInProgress, - updateExpirationTime, + Component, workInProgress.pendingProps, null, - renderExpirationTime$jscomp$0 + renderExpirationTime ), - (updateExpirationTime = workInProgress.memoizedState.element), - updateExpirationTime === value + (Component = workInProgress.memoizedState.element), + Component === props ? (workInProgress = bailoutOnAlreadyFinishedWork( current$$1, workInProgress, - renderExpirationTime$jscomp$0 + renderExpirationTime )) : (reconcileChildren( current$$1, workInProgress, - updateExpirationTime, - renderExpirationTime$jscomp$0 + Component, + renderExpirationTime ), (workInProgress = workInProgress.child)), workInProgress ); - case 5: + case 7: return ( pushHostContext(workInProgress), null === current$$1 && tryToClaimNextHydratableInstance(workInProgress), - (updateExpirationTime = workInProgress.pendingProps.children), + (Component = workInProgress.pendingProps), + (props = Component.children), markRef(current$$1, workInProgress), reconcileChildren( current$$1, workInProgress, - updateExpirationTime, - renderExpirationTime$jscomp$0 + props, + renderExpirationTime ), + (workInProgress.memoizedProps = Component), (workInProgress = workInProgress.child), workInProgress ); - case 6: + case 8: return ( null === current$$1 && tryToClaimNextHydratableInstance(workInProgress), + (workInProgress.memoizedProps = workInProgress.pendingProps), null ); - case 13: - return updateSuspenseComponent( - current$$1, - workInProgress, - renderExpirationTime$jscomp$0 + 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 4: + case 6: return ( pushHostContainer( workInProgress, workInProgress.stateNode.containerInfo ), - (updateExpirationTime = workInProgress.pendingProps), + (Component = workInProgress.pendingProps), null === current$$1 ? (workInProgress.child = reconcileChildFibers( workInProgress, null, - updateExpirationTime, - renderExpirationTime$jscomp$0 + Component, + renderExpirationTime )) : reconcileChildren( current$$1, workInProgress, - updateExpirationTime, - renderExpirationTime$jscomp$0 + Component, + renderExpirationTime ), + (workInProgress.memoizedProps = Component), workInProgress.child ); - case 11: + case 13: + return updateForwardRef( + current$$1, + workInProgress, + workInProgress.type, + workInProgress.pendingProps, + renderExpirationTime + ); + case 14: return ( - (updateExpirationTime = workInProgress.type), - (value = workInProgress.pendingProps), - (value = - workInProgress.elementType === updateExpirationTime - ? value - : resolveDefaultProps(updateExpirationTime, value)), - updateForwardRef( + (props = workInProgress.type._reactResult), + (Component = workInProgress.pendingProps), + (current$$1 = updateForwardRef( current$$1, workInProgress, - updateExpirationTime, - value, - renderExpirationTime$jscomp$0 - ) + props, + resolveDefaultProps(props, Component), + renderExpirationTime + )), + (workInProgress.memoizedProps = Component), + current$$1 ); - case 7: + case 9: return ( + (Component = workInProgress.pendingProps), reconcileChildren( current$$1, workInProgress, - workInProgress.pendingProps, - renderExpirationTime$jscomp$0 - ), - workInProgress.child - ); - case 8: - return ( - reconcileChildren( - current$$1, - workInProgress, - workInProgress.pendingProps.children, - renderExpirationTime$jscomp$0 - ), - workInProgress.child - ); - case 12: - return ( - reconcileChildren( - current$$1, - workInProgress, - workInProgress.pendingProps.children, - renderExpirationTime$jscomp$0 + Component, + renderExpirationTime ), + (workInProgress.memoizedProps = Component), workInProgress.child ); case 10: + return ( + (Component = workInProgress.pendingProps.children), + reconcileChildren( + current$$1, + workInProgress, + Component, + renderExpirationTime + ), + (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: a: { - 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) { + 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) + ) { if ( - getDerivedStateFromProps.children === value.children && + resolvedTag.children === props.children && !didPerformWorkStackCursor.current ) { workInProgress = bailoutOnAlreadyFinishedWork( current$$1, workInProgress, - renderExpirationTime$jscomp$0 + renderExpirationTime ); break a; } } else for ( - getDerivedStateFromProps = workInProgress.child, - null !== getDerivedStateFromProps && - (getDerivedStateFromProps.return = workInProgress); - null !== getDerivedStateFromProps; + resolvedTag = workInProgress.child, + null !== resolvedTag && (resolvedTag.return = workInProgress); + null !== resolvedTag; ) { - oldValue = getDerivedStateFromProps.firstContextDependency; - if (null !== oldValue) { + resolvedProps = resolvedTag.firstContextDependency; + if (null !== resolvedProps) { do { if ( - oldValue.context === updateExpirationTime && - 0 !== (oldValue.observedBits & context) + resolvedProps.context === Component && + 0 !== (resolvedProps.observedBits & updateExpirationTime) ) { - 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 (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 ( - node.childExpirationTime < renderExpirationTime$jscomp$0 + 0 === node.childExpirationTime || + node.childExpirationTime > renderExpirationTime ) - (node.childExpirationTime = renderExpirationTime$jscomp$0), - null !== nextFiber && - nextFiber.childExpirationTime < - renderExpirationTime$jscomp$0 && - (nextFiber.childExpirationTime = renderExpirationTime$jscomp$0); + (node.childExpirationTime = renderExpirationTime), + null !== child && + (0 === child.childExpirationTime || + child.childExpirationTime > + renderExpirationTime) && + (child.childExpirationTime = renderExpirationTime); else if ( - null !== nextFiber && - nextFiber.childExpirationTime < - renderExpirationTime$jscomp$0 + null !== child && + (0 === child.childExpirationTime || + child.childExpirationTime > renderExpirationTime) ) - nextFiber.childExpirationTime = renderExpirationTime$jscomp$0; + child.childExpirationTime = renderExpirationTime; else break; node = node.return; } } - nextFiber = getDerivedStateFromProps.child; - oldValue = oldValue.next; - } while (null !== oldValue); + child = resolvedTag.child; + resolvedProps = resolvedProps.next; + } while (null !== resolvedProps); } else - nextFiber = - 10 === getDerivedStateFromProps.tag - ? getDerivedStateFromProps.type === workInProgress.type + child = + 12 === resolvedTag.tag + ? resolvedTag.type === workInProgress.type ? null - : getDerivedStateFromProps.child - : getDerivedStateFromProps.child; - if (null !== nextFiber) - nextFiber.return = getDerivedStateFromProps; + : resolvedTag.child + : resolvedTag.child; + if (null !== child) child.return = resolvedTag; else - for ( - nextFiber = getDerivedStateFromProps; - null !== nextFiber; - - ) { - if (nextFiber === workInProgress) { - nextFiber = null; + for (child = resolvedTag; null !== child; ) { + if (child === workInProgress) { + child = null; break; } - getDerivedStateFromProps = nextFiber.sibling; - if (null !== getDerivedStateFromProps) { - getDerivedStateFromProps.return = nextFiber.return; - nextFiber = getDerivedStateFromProps; + resolvedTag = child.sibling; + if (null !== resolvedTag) { + resolvedTag.return = child.return; + child = resolvedTag; break; } - nextFiber = nextFiber.return; + child = child.return; } - getDerivedStateFromProps = nextFiber; + resolvedTag = child; } - } reconcileChildren( current$$1, workInProgress, - value.children, - renderExpirationTime$jscomp$0 + props.children, + renderExpirationTime ); workInProgress = workInProgress.child; } return workInProgress; - case 9: + case 11: return ( - (value = workInProgress.type), - (context = workInProgress.pendingProps), - (updateExpirationTime = context.children), - prepareToReadContext(workInProgress, renderExpirationTime$jscomp$0), - (value = readContext(value, context.unstable_observedBits)), - (updateExpirationTime = updateExpirationTime(value)), + (updateExpirationTime = workInProgress.type), + (Component = workInProgress.pendingProps), + (props = Component.children), + prepareToReadContext(workInProgress, renderExpirationTime), + (updateExpirationTime = readContext( + updateExpirationTime, + Component.unstable_observedBits + )), + (props = props(updateExpirationTime)), (workInProgress.effectTag |= 1), reconcileChildren( current$$1, workInProgress, - updateExpirationTime, - renderExpirationTime$jscomp$0 + props, + renderExpirationTime ), + (workInProgress.memoizedProps = Component), workInProgress.child ); - 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( + case 17: + return updatePureComponent( current$$1, workInProgress, workInProgress.type, workInProgress.pendingProps, updateExpirationTime, - renderExpirationTime$jscomp$0 + renderExpirationTime ); - case 17: + case 18: return ( - (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, - updateExpirationTime, - value, - renderExpirationTime$jscomp$0 - ), - mountClassInstance( - workInProgress, - updateExpirationTime, - value, - renderExpirationTime$jscomp$0 - ), - finishClassComponent( - null, - workInProgress, - updateExpirationTime, - !0, + (props = workInProgress.type._reactResult), + (Component = workInProgress.pendingProps), + (current$$1 = updatePureComponent( current$$1, - renderExpirationTime$jscomp$0 - ) + workInProgress, + props, + resolveDefaultProps(props, Component), + updateExpirationTime, + renderExpirationTime + )), + (workInProgress.memoizedProps = Component), + current$$1 ); default: invariant( @@ -4719,125 +4279,14 @@ function beginWork(current$$1, workInProgress, renderExpirationTime$jscomp$0) { ); } } -var appendAllChildren = void 0, - updateHostContainer = void 0, - updateHostComponent$1 = void 0, - updateHostText$1 = void 0; -appendAllChildren = function( - parent, - workInProgress, - needsVisibilityToggle, - isHidden -) { +function appendAllChildren(parent, workInProgress) { for (var node = workInProgress.child; null !== node; ) { - 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 (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; } if (node === workInProgress) break; for (; null === node.sibling; ) { @@ -4848,12 +4297,30 @@ function appendAllChildrenToContainer( 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); - appendAllChildrenToContainer(newChildSet, workInProgress, !1, !1); + 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; + } portalOrRoot.pendingChildren = newChildSet; workInProgress.effectTag |= 4; FabricUIManager.completeRoot(container, newChildSet); @@ -4900,7 +4367,7 @@ updateHostComponent$1 = function(current, workInProgress, type, newProps) { (workInProgress.stateNode = type), current ? (workInProgress.effectTag |= 4) - : appendAllChildren(type, workInProgress, !1, !1)); + : appendAllChildren(type, workInProgress)); } }; updateHostText$1 = function(current, workInProgress, oldText, newText) { @@ -4934,6 +4401,7 @@ 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; @@ -4950,7 +4418,7 @@ function logError(boundary, errorInfo) { willRetry: !1 }; null !== boundary && - 1 === boundary.tag && + 2 === boundary.tag && ((errorInfo.errorBoundary = boundary.stateNode), (errorInfo.errorBoundaryName = getComponentName(boundary.type)), (errorInfo.errorBoundaryFound = !0), @@ -4974,44 +4442,18 @@ 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 0: - case 11: - case 14: - case 15: - commitHookEffectList(4, 8, finishedWork); - return; - } - switch (finishedWork.tag) { - case 1: + case 2: + case 3: + break; + case 7: + break; + case 8: break; case 5: - break; case 6: break; - case 3: - case 4: - break; default: invariant( !1, @@ -5019,6 +4461,9 @@ function commitWork(current$$1, finishedWork) { ); } } +function NoopComponent() { + return null; +} function createRootErrorUpdate(fiber, errorInfo, expirationTime) { expirationTime = createUpdate(expirationTime); expirationTime.tag = 3; @@ -5059,14 +4504,24 @@ function createClassErrorUpdate(fiber, errorInfo, expirationTime) { } function unwindWork(workInProgress) { switch (workInProgress.tag) { - case 1: + case 2: isContextProvider(workInProgress.type) && popContext(workInProgress); var effectTag = workInProgress.effectTag; - return effectTag & 2048 - ? ((workInProgress.effectTag = (effectTag & -2049) | 64), + return effectTag & 1024 + ? ((workInProgress.effectTag = (effectTag & -1025) | 64), workInProgress) : null; case 3: + return ( + isContextProvider(workInProgress.type._reactResult) && + popContext(workInProgress), + (effectTag = workInProgress.effectTag), + effectTag & 1024 + ? ((workInProgress.effectTag = (effectTag & -1025) | 64), + workInProgress) + : null + ); + case 5: return ( popHostContainer(workInProgress), popTopLevelContextObject(workInProgress), @@ -5075,117 +4530,28 @@ 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 & -2049) | 64), + (workInProgress.effectTag = (effectTag & -1025) | 64), workInProgress ); - case 5: + case 7: return popHostContext(workInProgress), null; - 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: + case 16: + return ( + (effectTag = workInProgress.effectTag), + effectTag & 1024 + ? ((workInProgress.effectTag = (effectTag & -1025) | 64), + workInProgress) + : null + ); + case 6: return popHostContainer(workInProgress), null; - case 10: + case 12: return popProvider(workInProgress), null; default: return null; } } -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); - } - }, +var Dispatcher = { readContext: readContext }, ReactCurrentOwner$2 = ReactSharedInternals.ReactCurrentOwner, isWorking = !1, nextUnitOfWork = null, @@ -5195,9 +4561,6 @@ var Dispatcher = { nextRenderDidError = !1, nextEffect = null, isCommitting$1 = !1, - rootWithPendingPassiveEffects = null, - passiveEffectCallbackHandle = null, - passiveEffectCallback = null, legacyErrorBoundariesThatAlreadyFailed = null; function resetStack() { if (null !== nextUnitOfWork) @@ -5208,7 +4571,7 @@ function resetStack() { ) { var interruptedWork$jscomp$0 = interruptedWork; switch (interruptedWork$jscomp$0.tag) { - case 1: + case 2: var childContextTypes = interruptedWork$jscomp$0.type.childContextTypes; null !== childContextTypes && @@ -5216,16 +4579,23 @@ 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 5: + case 7: popHostContext(interruptedWork$jscomp$0); break; - case 4: + case 6: popHostContainer(interruptedWork$jscomp$0); break; - case 10: + case 12: popProvider(interruptedWork$jscomp$0); } interruptedWork = interruptedWork.return; @@ -5236,55 +4606,27 @@ 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 & 1024)) { + if (0 === (workInProgress.effectTag & 512)) { var current = current$$1; current$$1 = workInProgress; var instance = current$$1.pendingProps; switch (current$$1.tag) { - case 2: - break; - case 16: - break; - case 15: case 0: - break; case 1: + break; + case 2: 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; @@ -5295,7 +4637,7 @@ function completeUnitOfWork(workInProgress) { current$$1.effectTag &= -3; updateHostContainer(current$$1); break; - case 5: + case 7: popHostContext(current$$1); var rootContainerInstance = requiredContext( rootInstanceStackCursor.current @@ -5341,7 +4683,7 @@ function completeUnitOfWork(workInProgress) { instance ); instance = { node: rootContainerInstance, canonical: instance }; - appendAllChildren(instance, current$$1, !1, !1); + appendAllChildren(instance, current$$1); current$$1.stateNode = instance; null !== current$$1.ref && (current$$1.effectTag |= 128); } else @@ -5350,7 +4692,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 6: + case 8: current && null != current$$1.stateNode ? updateHostText$1( current, @@ -5374,36 +4716,34 @@ function completeUnitOfWork(workInProgress) { current$$1 ))); break; - case 11: - break; case 13: - instance = current$$1.memoizedState; - rootContainerInstance = - null !== current ? current.memoizedState : null; - (null !== instance && instance.didTimeout) !== - (null !== rootContainerInstance && - rootContainerInstance.didTimeout) && (current$$1.effectTag |= 4); + case 14: break; - case 7: - break; - case 8: - break; - case 12: - break; - case 4: - popHostContainer(current$$1); - updateHostContainer(current$$1); - break; - case 10: - popProvider(current$$1); + case 16: break; case 9: break; - case 14: + case 10: + break; + case 15: + break; + case 6: + popHostContainer(current$$1); + updateHostContainer(current$$1); + break; + case 12: + popProvider(current$$1); + break; + case 11: break; case 17: - isContextProvider(current$$1.type) && popContext(current$$1); + case 18: 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, @@ -5413,24 +4753,27 @@ function completeUnitOfWork(workInProgress) { nextUnitOfWork = null; current$$1 = workInProgress; if ( - 1 === nextRenderExpirationTime || - 1 !== current$$1.childExpirationTime + 1073741823 === nextRenderExpirationTime || + 1073741823 !== current$$1.childExpirationTime ) { instance = 0; for ( rootContainerInstance = current$$1.child; null !== rootContainerInstance; - ) - (current = rootContainerInstance.expirationTime), - (viewConfig = rootContainerInstance.childExpirationTime), - current > instance && (instance = current), - viewConfig > instance && (instance = viewConfig), - (rootContainerInstance = rootContainerInstance.sibling); + ) { + 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$$1.childExpirationTime = instance; } null !== returnFiber && - 0 === (returnFiber.effectTag & 1024) && + 0 === (returnFiber.effectTag & 512) && (null === returnFiber.firstEffect && (returnFiber.firstEffect = workInProgress.firstEffect), null !== workInProgress.lastEffect && @@ -5445,10 +4788,10 @@ function completeUnitOfWork(workInProgress) { } else { workInProgress = unwindWork(workInProgress, nextRenderExpirationTime); if (null !== workInProgress) - return (workInProgress.effectTag &= 1023), workInProgress; + return (workInProgress.effectTag &= 511), workInProgress; null !== returnFiber && ((returnFiber.firstEffect = returnFiber.lastEffect = null), - (returnFiber.effectTag |= 1024)); + (returnFiber.effectTag |= 512)); } if (null !== siblingFiber) return siblingFiber; if (null !== returnFiber) workInProgress = returnFiber; @@ -5462,17 +4805,15 @@ 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) { +function renderRoot(root$jscomp$0, isYieldy, isExpired) { 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; @@ -5494,17 +4835,13 @@ function renderRoot(root$jscomp$0, isYieldy) { do { try { if (isYieldy) - for (; null !== nextUnitOfWork && !shouldYieldToRenderer(); ) + for (; null !== nextUnitOfWork && !shouldYield(); ) nextUnitOfWork = performUnitOfWork(nextUnitOfWork); else for (; null !== nextUnitOfWork; ) nextUnitOfWork = performUnitOfWork(nextUnitOfWork); } catch (thrownValue) { - if ( - ((lastContextWithAllBitsObserved = lastContextDependency = currentlyRenderingFiber = null), - resetHooks(), - null === nextUnitOfWork) - ) + if (null === nextUnitOfWork) (didFatal = !0), onUncaughtError(thrownValue); else { invariant( @@ -5521,7 +4858,7 @@ function renderRoot(root$jscomp$0, isYieldy) { sourceFiber$jscomp$0 = sourceFiber, value = thrownValue; returnFiber = nextRenderExpirationTime; - sourceFiber$jscomp$0.effectTag |= 1024; + sourceFiber$jscomp$0.effectTag |= 512; sourceFiber$jscomp$0.firstEffect = sourceFiber$jscomp$0.lastEffect = null; if ( null !== value && @@ -5533,57 +4870,56 @@ function renderRoot(root$jscomp$0, isYieldy) { var earliestTimeoutMs = -1, startTimeMs = -1; do { - if (13 === value.tag) { - var current$$1 = value.alternate; + if (16 === value.tag) { + var current = value.alternate; if ( - null !== current$$1 && - ((current$$1 = current$$1.memoizedState), - null !== current$$1 && current$$1.didTimeout) + null !== current && + !0 === current.memoizedState && + null !== current.stateNode ) { - startTimeMs = 10 * (1073741822 - current$$1.timedOutAt); + startTimeMs = 10 * (current.stateNode.timedOutAt - 2); break; } - current$$1 = value.pendingProps.maxDuration; - if ("number" === typeof current$$1) - if (0 >= current$$1) earliestTimeoutMs = 0; + current = value.pendingProps.maxDuration; + if ("number" === typeof current) + if (0 >= current) earliestTimeoutMs = 0; else if ( -1 === earliestTimeoutMs || - current$$1 < earliestTimeoutMs + current < earliestTimeoutMs ) - earliestTimeoutMs = current$$1; + earliestTimeoutMs = current; } value = value.return; } while (null !== value); value = returnFiber$jscomp$0; do { - 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) { + if (16 === value.tag && !value.memoizedState) { returnFiber$jscomp$0 = retrySuspendedRoot.bind( null, root, value, - sourceFiber$jscomp$0, - 0 === (value.mode & 1) ? 1073741823 : returnFiber + 0 === (value.mode & 1) ? 1 : returnFiber ); thenable.then(returnFiber$jscomp$0, returnFiber$jscomp$0); - if (0 === (value.mode & 1)) { - value.effectTag |= 32; + if (0 === (value.mode & 2)) { + value.effectTag |= 4; reconcileChildren( sourceFiber$jscomp$0.alternate, sourceFiber$jscomp$0, null, returnFiber ); - 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); + 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)); break a; } -1 === earliestTimeoutMs @@ -5591,27 +4927,24 @@ function renderRoot(root$jscomp$0, isYieldy) { : (-1 === startTimeMs && (startTimeMs = 10 * - (1073741822 - - findEarliestOutstandingPriorityLevel( - root, - returnFiber - )) - + (findEarliestOutstandingPriorityLevel( + root, + returnFiber + ) - + 2) - 5e3), (root = startTimeMs + earliestTimeoutMs)); 0 <= root && nextLatestAbsoluteTimeoutMs < root && (nextLatestAbsoluteTimeoutMs = root); - value.effectTag |= 2048; + value.effectTag |= 1024; value.expirationTime = returnFiber; break a; } value = value.return; } while (null !== value); value = Error( - (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) + "An update was suspended, but no placeholder UI was provided." ); } nextRenderDidError = !0; @@ -5619,9 +4952,9 @@ function renderRoot(root$jscomp$0, isYieldy) { root = returnFiber$jscomp$0; do { switch (root.tag) { - case 3: + case 5: sourceFiber$jscomp$0 = value; - root.effectTag |= 2048; + root.effectTag |= 1024; root.expirationTime = returnFiber; returnFiber = createRootErrorUpdate( root, @@ -5630,7 +4963,8 @@ function renderRoot(root$jscomp$0, isYieldy) { ); enqueueCapturedUpdate(root, returnFiber); break a; - case 1: + case 2: + case 3: if ( ((sourceFiber$jscomp$0 = value), (returnFiber$jscomp$0 = root.type), @@ -5645,7 +4979,7 @@ function renderRoot(root$jscomp$0, isYieldy) { thenable ))))) ) { - root.effectTag |= 2048; + root.effectTag |= 1024; root.expirationTime = returnFiber; returnFiber = createClassErrorUpdate( root, @@ -5668,170 +5002,183 @@ function renderRoot(root$jscomp$0, isYieldy) { } 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 { - didFatal = root$jscomp$0.current.alternate; + isYieldy = root$jscomp$0.current.alternate; invariant( - null !== didFatal, + null !== isYieldy, "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) { - sourceFiber = root$jscomp$0.latestPendingTime; - returnFiber = root$jscomp$0.latestSuspendedTime; - root = root$jscomp$0.latestPingedTime; + didFatal = root$jscomp$0.latestPendingTime; + sourceFiber = root$jscomp$0.latestSuspendedTime; + returnFiber = root$jscomp$0.latestPingedTime; if ( - (0 !== sourceFiber && sourceFiber < expirationTime) || - (0 !== returnFiber && returnFiber < expirationTime) || - (0 !== root && root < expirationTime) + (0 !== didFatal && didFatal > expirationTime) || + (0 !== sourceFiber && sourceFiber > expirationTime) || + (0 !== returnFiber && returnFiber > expirationTime) ) { markSuspendedPriorityLevel(root$jscomp$0, expirationTime); onSuspend( root$jscomp$0, - didFatal, + isYieldy, expirationTime, root$jscomp$0.expirationTime, -1 ); return; } - if (!root$jscomp$0.didError && isYieldy) { + if (!root$jscomp$0.didError && !isExpired) { root$jscomp$0.didError = !0; expirationTime = root$jscomp$0.nextExpirationTimeToWorkOn = expirationTime; - isYieldy = root$jscomp$0.expirationTime = 1073741823; - onSuspend(root$jscomp$0, didFatal, expirationTime, isYieldy, -1); + isExpired = root$jscomp$0.expirationTime = 1; + onSuspend(root$jscomp$0, isYieldy, expirationTime, isExpired, -1); return; } } - isYieldy && -1 !== nextLatestAbsoluteTimeoutMs - ? (markSuspendedPriorityLevel(root$jscomp$0, expirationTime), - (isYieldy = + isExpired || -1 === nextLatestAbsoluteTimeoutMs + ? ((root$jscomp$0.pendingCommitExpirationTime = expirationTime), + (root$jscomp$0.finishedWork = isYieldy)) + : (markSuspendedPriorityLevel(root$jscomp$0, expirationTime), + (isExpired = 10 * - (1073741822 - - findEarliestOutstandingPriorityLevel( - root$jscomp$0, - expirationTime - ))), - isYieldy < nextLatestAbsoluteTimeoutMs && - (nextLatestAbsoluteTimeoutMs = isYieldy), - (isYieldy = 10 * (1073741822 - requestCurrentTime())), - (isYieldy = nextLatestAbsoluteTimeoutMs - isYieldy), + (findEarliestOutstandingPriorityLevel(root$jscomp$0, expirationTime) - + 2)), + isExpired < nextLatestAbsoluteTimeoutMs && + (nextLatestAbsoluteTimeoutMs = isExpired), + (isExpired = 10 * (requestCurrentTime() - 2)), + (isExpired = nextLatestAbsoluteTimeoutMs - isExpired), onSuspend( root$jscomp$0, - didFatal, + isYieldy, expirationTime, root$jscomp$0.expirationTime, - 0 > isYieldy ? 0 : isYieldy - )) - : ((root$jscomp$0.pendingCommitExpirationTime = expirationTime), - (root$jscomp$0.finishedWork = didFatal)); + 0 > isExpired ? 0 : isExpired + )); } } -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; +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; } - fiber = fiber.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; } - 3 === sourceFiber.tag && - ((fiber = createCapturedValue(value, sourceFiber)), - (fiber = createRootErrorUpdate(sourceFiber, fiber, 1073741823)), - enqueueUpdate(sourceFiber, fiber), - scheduleWork(sourceFiber, 1073741823)); + return JSCompiler_inline_result; } function computeExpirationForFiber(currentTime, fiber) { isWorking - ? (currentTime = isCommitting$1 ? 1073741823 : nextRenderExpirationTime) + ? (currentTime = isCommitting$1 ? 1 : nextRenderExpirationTime) : fiber.mode & 1 ? ((currentTime = isBatchingInteractiveUpdates - ? 1073741822 - 10 * ((((1073741822 - currentTime + 15) / 10) | 0) + 1) - : 1073741822 - - 25 * ((((1073741822 - currentTime + 500) / 25) | 0) + 1)), + ? 2 + 10 * ((((currentTime - 2 + 15) / 10) | 0) + 1) + : 2 + 25 * ((((currentTime - 2 + 500) / 25) | 0) + 1)), null !== nextRoot && currentTime === nextRenderExpirationTime && - --currentTime) - : (currentTime = 1073741823); + (currentTime += 1)) + : (currentTime = 1); isBatchingInteractiveUpdates && - (0 === lowestPriorityPendingInteractiveExpirationTime || - currentTime < lowestPriorityPendingInteractiveExpirationTime) && + currentTime > lowestPriorityPendingInteractiveExpirationTime && (lowestPriorityPendingInteractiveExpirationTime = currentTime); return currentTime; } -function retrySuspendedRoot(root, boundaryFiber, sourceFiber, suspendedTime) { +function retrySuspendedRoot(root, fiber, 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, boundaryFiber)), + (retryTime = computeExpirationForFiber(retryTime, fiber)), markPendingPriorityLevel(root, retryTime); - 0 !== (boundaryFiber.mode & 1) && + 0 !== (fiber.mode & 1) && root === nextRoot && nextRenderExpirationTime === suspendedTime && (nextRoot = null); - 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); + scheduleWorkToRoot(fiber, retryTime); + fiber = root.expirationTime; + 0 !== fiber && requestWork(root, fiber); } function scheduleWorkToRoot(fiber, expirationTime) { - fiber.expirationTime < expirationTime && - (fiber.expirationTime = expirationTime); + if (0 === fiber.expirationTime || fiber.expirationTime > expirationTime) + fiber.expirationTime = expirationTime; var alternate = fiber.alternate; null !== alternate && - alternate.expirationTime < expirationTime && + (0 === alternate.expirationTime || + alternate.expirationTime > expirationTime) && (alternate.expirationTime = expirationTime); var node = fiber.return, root = null; - if (null === node && 3 === fiber.tag) root = fiber.stateNode; + if (null === node && 5 === fiber.tag) root = fiber.stateNode; else for (; null !== node; ) { alternate = node.alternate; - node.childExpirationTime < expirationTime && - (node.childExpirationTime = expirationTime); + if ( + 0 === node.childExpirationTime || + node.childExpirationTime > expirationTime + ) + node.childExpirationTime = expirationTime; null !== alternate && - alternate.childExpirationTime < expirationTime && + (0 === alternate.childExpirationTime || + alternate.childExpirationTime > expirationTime) && (alternate.childExpirationTime = expirationTime); - if (null === node.return && 3 === node.tag) { + if (null === node.return && 5 === node.tag) { root = node.stateNode; break; } @@ -5844,7 +5191,7 @@ function scheduleWork(fiber, expirationTime) { null !== fiber && (!isWorking && 0 !== nextRenderExpirationTime && - expirationTime > nextRenderExpirationTime && + expirationTime < nextRenderExpirationTime && resetStack(), markPendingPriorityLevel(fiber, expirationTime), (isWorking && !isCommitting$1 && nextRoot === fiber) || @@ -5864,25 +5211,27 @@ 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 = 1073741822 - ((originalStartTimeMs / 10) | 0), + currentRendererTime = ((originalStartTimeMs / 10) | 0) + 2, currentSchedulerTime = currentRendererTime, NESTED_UPDATE_LIMIT = 50, nestedUpdateCount = 0, - lastCommittedRootDuringThisBatch = null; + lastCommittedRootDuringThisBatch = null, + timeHeuristicForUnitOfWork = 1; function recomputeCurrentRendererTime() { - currentRendererTime = - 1073741822 - (((now$1() - originalStartTimeMs) / 10) | 0); + currentRendererTime = (((now$1() - originalStartTimeMs) / 10) | 0) + 2; } function scheduleCallbackWithExpirationTime(root, expirationTime) { if (0 !== callbackExpirationTime) { - if (expirationTime < callbackExpirationTime) return; + if (expirationTime > callbackExpirationTime) return; null !== callbackID && ((root = callbackID), (scheduledCallback = null), clearTimeout(root)); } @@ -5899,7 +5248,7 @@ function onSuspend( msUntilTimeout ) { root.expirationTime = rootExpirationTime; - 0 !== msUntilTimeout || shouldYieldToRenderer() + 0 !== msUntilTimeout || shouldYield() ? 0 < msUntilTimeout && (root.timeoutHandle = scheduleTimeout( onTimeout.bind(null, root, finishedWork, suspendedExpirationTime), @@ -5919,35 +5268,44 @@ function onTimeout(root, finishedWork, suspendedExpirationTime) { ); nextFlushedRoot = root; nextFlushedExpirationTime = suspendedExpirationTime; - performWorkOnRoot(root, suspendedExpirationTime, !1); - performWork(1073741823, !1); + performWorkOnRoot(root, suspendedExpirationTime, !0); + performWork(1, null); } function requestCurrentTime() { if (isRendering) return currentSchedulerTime; findHighestPriorityRoot(); - if (0 === nextFlushedExpirationTime || 1 === nextFlushedExpirationTime) + if ( + 0 === nextFlushedExpirationTime || + 1073741823 === nextFlushedExpirationTime + ) recomputeCurrentRendererTime(), (currentSchedulerTime = currentRendererTime); return currentSchedulerTime; } function requestWork(root, expirationTime) { - null === root.nextScheduledRoot - ? ((root.expirationTime = expirationTime), + if (null === root.nextScheduledRoot) + (root.expirationTime = expirationTime), null === lastScheduledRoot ? ((firstScheduledRoot = lastScheduledRoot = root), (root.nextScheduledRoot = root)) : ((lastScheduledRoot = lastScheduledRoot.nextScheduledRoot = root), - (lastScheduledRoot.nextScheduledRoot = firstScheduledRoot))) - : expirationTime > root.expirationTime && - (root.expirationTime = expirationTime); + (lastScheduledRoot.nextScheduledRoot = firstScheduledRoot)); + else { + var remainingExpirationTime = root.expirationTime; + if ( + 0 === remainingExpirationTime || + expirationTime < remainingExpirationTime + ) + root.expirationTime = expirationTime; + } isRendering || (isBatchingUpdates ? isUnbatchingUpdates && ((nextFlushedRoot = root), - (nextFlushedExpirationTime = 1073741823), - performWorkOnRoot(root, 1073741823, !1)) - : 1073741823 === expirationTime - ? performWork(1073741823, !1) + (nextFlushedExpirationTime = 1), + performWorkOnRoot(root, 1, !0)) + : 1 === expirationTime + ? performWork(1, null) : scheduleCallbackWithExpirationTime(root, expirationTime)); } function findHighestPriorityRoot() { @@ -5983,11 +5341,14 @@ function findHighestPriorityRoot() { (root.nextScheduledRoot = null); root = previousScheduledRoot.nextScheduledRoot; } else { - remainingExpirationTime > highestPriorityWork && - ((highestPriorityWork = remainingExpirationTime), - (highestPriorityRoot = root)); + if ( + 0 === highestPriorityWork || + remainingExpirationTime < highestPriorityWork + ) + (highestPriorityWork = remainingExpirationTime), + (highestPriorityRoot = root); if (root === lastScheduledRoot) break; - if (1073741823 === highestPriorityWork) break; + if (1 === highestPriorityWork) break; previousScheduledRoot = root; root = root.nextScheduledRoot; } @@ -5995,44 +5356,38 @@ function findHighestPriorityRoot() { nextFlushedRoot = highestPriorityRoot; nextFlushedExpirationTime = highestPriorityWork; } -var didYield = !1; -function shouldYieldToRenderer() { - return didYield ? !0 : frameDeadline <= now$1() ? (didYield = !0) : !1; -} -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 performAsyncWork(dl) { + if (dl.didTimeout && null !== firstScheduledRoot) { + recomputeCurrentRendererTime(); + var root = firstScheduledRoot; + do { + var expirationTime = root.expirationTime; + 0 !== expirationTime && + currentRendererTime >= expirationTime && + (root.nextExpirationTimeToWorkOn = currentRendererTime); + root = root.nextScheduledRoot; + } while (root !== firstScheduledRoot); } + performWork(0, dl); } -function performWork(minExpirationTime, isYieldy) { +function performWork(minExpirationTime, dl) { + deadline = dl; findHighestPriorityRoot(); - if (isYieldy) + if (null !== deadline) for ( recomputeCurrentRendererTime(), currentSchedulerTime = currentRendererTime; null !== nextFlushedRoot && 0 !== nextFlushedExpirationTime && - minExpirationTime <= nextFlushedExpirationTime && - !(didYield && currentRendererTime > nextFlushedExpirationTime); + (0 === minExpirationTime || + minExpirationTime >= nextFlushedExpirationTime) && + (!deadlineDidExpire || currentRendererTime >= nextFlushedExpirationTime); ) performWorkOnRoot( nextFlushedRoot, nextFlushedExpirationTime, - currentRendererTime > nextFlushedExpirationTime + currentRendererTime >= nextFlushedExpirationTime ), findHighestPriorityRoot(), recomputeCurrentRendererTime(), @@ -6042,28 +5397,29 @@ function performWork(minExpirationTime, isYieldy) { ; null !== nextFlushedRoot && 0 !== nextFlushedExpirationTime && - minExpirationTime <= nextFlushedExpirationTime; + (0 === minExpirationTime || + minExpirationTime >= nextFlushedExpirationTime); ) - performWorkOnRoot(nextFlushedRoot, nextFlushedExpirationTime, !1), + performWorkOnRoot(nextFlushedRoot, nextFlushedExpirationTime, !0), findHighestPriorityRoot(); - isYieldy && ((callbackExpirationTime = 0), (callbackID = null)); + null !== deadline && ((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, - isYieldy = 0; - isYieldy < minExpirationTime.length; - isYieldy++ + minExpirationTime = completedBatches, completedBatches = null, dl = 0; + dl < minExpirationTime.length; + dl++ ) { - var batch = minExpirationTime[isYieldy]; + var batch = minExpirationTime[dl]; try { batch._onComplete(); } catch (error) { @@ -6077,45 +5433,45 @@ function performWork(minExpirationTime, isYieldy) { (hasUnhandledError = !1), minExpirationTime); } -function performWorkOnRoot(root, expirationTime, isYieldy) { +function performWorkOnRoot(root, expirationTime, isExpired) { invariant( !isRendering, "performWorkOnRoot was called recursively. This error is likely caused by a bug in React. Please file an issue." ); isRendering = !0; - if (isYieldy) { - var _finishedWork = root.finishedWork; - null !== _finishedWork - ? completeRoot$1(root, _finishedWork, expirationTime) + if (null === deadline || isExpired) { + 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, isYieldy), - (_finishedWork = root.finishedWork), - null !== _finishedWork && - (shouldYieldToRenderer() - ? (root.finishedWork = _finishedWork) - : completeRoot$1(root, _finishedWork, expirationTime))); + (finishedWork = root.timeoutHandle), + -1 !== finishedWork && + ((root.timeoutHandle = -1), cancelTimeout(finishedWork)), + renderRoot(root, !1, isExpired), + (finishedWork = root.finishedWork), + null !== 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, isYieldy), - (_finishedWork = root.finishedWork), - null !== _finishedWork && - completeRoot$1(root, _finishedWork, expirationTime)); + (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))); 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), @@ -6144,7 +5500,9 @@ function completeRoot$1(root, finishedWork$jscomp$0, expirationTime) { var childExpirationTimeBeforeCommit = finishedWork$jscomp$0.childExpirationTime; firstBatch = - childExpirationTimeBeforeCommit > firstBatch + 0 === firstBatch || + (0 !== childExpirationTimeBeforeCommit && + childExpirationTimeBeforeCommit < firstBatch) ? childExpirationTimeBeforeCommit : firstBatch; root.didError = !1; @@ -6156,19 +5514,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; @@ -6180,20 +5538,16 @@ function completeRoot$1(root, finishedWork$jscomp$0, expirationTime) { : (firstBatch = finishedWork$jscomp$0.firstEffect); for (nextEffect = firstBatch; null !== nextEffect; ) { childExpirationTimeBeforeCommit = !1; - var error$jscomp$0 = void 0; + var error = void 0; try { for (; null !== nextEffect; ) { - if (nextEffect.effectTag & 256) + if (nextEffect.effectTag & 256) { + var current$$1 = nextEffect.alternate; a: { - var current$$1 = nextEffect.alternate, - finishedWork = nextEffect; + var finishedWork = nextEffect; switch (finishedWork.tag) { - case 0: - case 11: - case 15: - commitHookEffectList(2, 0, finishedWork); - break a; - case 1: + case 2: + case 3: if (finishedWork.effectTag & 256 && null !== current$$1) { var prevProps = current$$1.memoizedProps, prevState = current$$1.memoizedState, @@ -6207,11 +5561,10 @@ 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( @@ -6220,17 +5573,18 @@ function completeRoot$1(root, finishedWork$jscomp$0, expirationTime) { ); } } + } nextEffect = nextEffect.nextEffect; } } catch (e) { - (childExpirationTimeBeforeCommit = !0), (error$jscomp$0 = e); + (childExpirationTimeBeforeCommit = !0), (error = e); } childExpirationTimeBeforeCommit && (invariant( null !== nextEffect, "Should have next effect. This error is likely caused by a bug in React. Please file an issue." ), - captureCommitPhaseError(nextEffect, error$jscomp$0), + captureCommitPhaseError(nextEffect, error), null !== nextEffect && (nextEffect = nextEffect.nextEffect)); } for (nextEffect = firstBatch; null !== nextEffect; ) { @@ -6267,32 +5621,8 @@ function completeRoot$1(root, finishedWork$jscomp$0, expirationTime) { "function" === typeof onCommitFiberUnmount && onCommitFiberUnmount(childExpirationTimeBeforeCommit); switch (childExpirationTimeBeforeCommit.tag) { - 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: + case 2: + case 3: safelyDetachRef(childExpirationTimeBeforeCommit); var instance$jscomp$0 = childExpirationTimeBeforeCommit.stateNode; @@ -6312,10 +5642,10 @@ function completeRoot$1(root, finishedWork$jscomp$0, expirationTime) { ); } break; - case 5: + case 7: safelyDetachRef(childExpirationTimeBeforeCommit); break; - case 4: + case 6: FabricUIManager.createChildSet( childExpirationTimeBeforeCommit.stateNode.containerInfo ); @@ -6357,105 +5687,86 @@ function completeRoot$1(root, finishedWork$jscomp$0, expirationTime) { effectTag = !1; current$$1$jscomp$0 = void 0; try { - for ( - currentRef = root, updateQueue = expirationTime; - null !== nextEffect; - - ) { + for (currentRef = expirationTime; null !== nextEffect; ) { var effectTag$jscomp$0 = nextEffect.effectTag; if (effectTag$jscomp$0 & 36) { - destroy = void 0; var current$$1$jscomp$1 = nextEffect.alternate; - 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) + 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) if (null === current$$1$jscomp$1) - (instance$jscomp$1.props = lastEffect.memoizedProps), - (instance$jscomp$1.state = lastEffect.memoizedState), + (instance$jscomp$1.props = instance$jscomp$0.memoizedProps), + (instance$jscomp$1.state = instance$jscomp$0.memoizedState), instance$jscomp$1.componentDidMount(); else { var prevProps$jscomp$0 = current$$1$jscomp$1.memoizedProps, prevState$jscomp$0 = current$$1$jscomp$1.memoizedState; - instance$jscomp$1.props = lastEffect.memoizedProps; - instance$jscomp$1.state = lastEffect.memoizedState; + instance$jscomp$1.props = instance$jscomp$0.memoizedProps; + instance$jscomp$1.state = instance$jscomp$0.memoizedState; instance$jscomp$1.componentDidUpdate( prevProps$jscomp$0, prevState$jscomp$0, instance$jscomp$1.__reactInternalSnapshotBeforeUpdate ); } - var updateQueue$jscomp$0 = lastEffect.updateQueue; - null !== updateQueue$jscomp$0 && - ((instance$jscomp$1.props = lastEffect.memoizedProps), - (instance$jscomp$1.state = lastEffect.memoizedState), + var updateQueue = instance$jscomp$0.updateQueue; + null !== updateQueue && + ((instance$jscomp$1.props = instance$jscomp$0.memoizedProps), + (instance$jscomp$1.state = instance$jscomp$0.memoizedState), commitUpdateQueue( - lastEffect, - updateQueue$jscomp$0, + instance$jscomp$0, + updateQueue, instance$jscomp$1, - firstEffect + firstBatch )); break; - case 3: - var _updateQueue = lastEffect.updateQueue; + case 5: + var _updateQueue = instance$jscomp$0.updateQueue; if (null !== _updateQueue) { - destroy = null; - if (null !== lastEffect.child) - switch (lastEffect.child.tag) { - case 5: - destroy = lastEffect.child.stateNode.canonical; + 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; break; - case 1: - destroy = lastEffect.child.stateNode; + case 2: + case 3: + current$$1 = instance$jscomp$0.child.stateNode; } commitUpdateQueue( - lastEffect, + instance$jscomp$0, _updateQueue, - destroy, - firstEffect + current$$1, + firstBatch ); } break; - case 5: + case 7: null === current$$1$jscomp$1 && - lastEffect.effectTag & 4 && + instance$jscomp$0.effectTag & 4 && invariant( !1, "The current renderer does not support mutation. This error is likely caused by a bug in React. Please file an issue." ); break; + case 8: + break; case 6: break; - case 4: + case 15: break; - case 12: - break; - case 13: - if (lastEffect.effectTag & 32) { - lastEffect.memoizedState = { - alreadyCaptured: !0, - didTimeout: !1, - timedOutAt: 0 - }; - flushPassiveEffects(); - scheduleWork(lastEffect, 1073741823); - 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 }; } - var newState = lastEffect.memoizedState; - null !== newState && - (destroy = newState.didTimeout) && - ((newState.alreadyCaptured = !1), - 0 === newState.timedOutAt && - (newState.timedOutAt = requestCurrentTime())); - break; - case 17: break; default: invariant( @@ -6469,7 +5780,7 @@ function completeRoot$1(root, finishedWork$jscomp$0, expirationTime) { if (null !== ref) { var instance$jscomp$2 = nextEffect.stateNode; switch (nextEffect.tag) { - case 5: + case 7: var instanceToUse = instance$jscomp$2.canonical; break; default: @@ -6480,9 +5791,9 @@ function completeRoot$1(root, finishedWork$jscomp$0, expirationTime) { : (ref.current = instanceToUse); } } - effectTag$jscomp$0 & 512 && - (rootWithPendingPassiveEffects = currentRef); - nextEffect = nextEffect.nextEffect; + var next = nextEffect.nextEffect; + nextEffect.nextEffect = null; + nextEffect = next; } } catch (e) { (effectTag = !0), (current$$1$jscomp$0 = e); @@ -6495,20 +5806,14 @@ 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 = - finishedWork$jscomp$0 > effectTag$jscomp$0 + 0 === effectTag$jscomp$0 || + (0 !== finishedWork$jscomp$0 && finishedWork$jscomp$0 < effectTag$jscomp$0) ? finishedWork$jscomp$0 : effectTag$jscomp$0; 0 === finishedWork$jscomp$0 && @@ -6516,6 +5821,13 @@ 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, @@ -6524,6 +5836,55 @@ 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 && @@ -6542,48 +5903,7 @@ function updateContainer(element, container, parentComponent, callback) { currentTime = requestCurrentTime(); current$$1 = computeExpirationForFiber(currentTime, current$$1); currentTime = container.current; - 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; + parentComponent = getContextForSubtree(parentComponent); null === container.context ? (container.context = parentComponent) : (container.pendingContext = parentComponent); @@ -6592,7 +5912,6 @@ 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; @@ -6652,13 +5971,13 @@ _batchedUpdatesImpl = function(fn, a) { } finally { (isBatchingUpdates = previousIsBatchingUpdates) || isRendering || - performWork(1073741823, !1); + performWork(1, null); } }; _flushInteractiveUpdatesImpl = function() { isRendering || 0 === lowestPriorityPendingInteractiveExpirationTime || - (performWork(lowestPriorityPendingInteractiveExpirationTime, !1), + (performWork(lowestPriorityPendingInteractiveExpirationTime, null), (lowestPriorityPendingInteractiveExpirationTime = 0)); }; var roots = new Map(), @@ -6738,7 +6057,7 @@ var roots = new Map(), render: function(element, containerTag, callback) { var root = roots.get(containerTag); if (!root) { - root = createFiber(3, null, null, 0); + root = new FiberNode(5, null, null, 0); var root$jscomp$0 = { current: root, containerInfo: containerTag, @@ -6766,7 +6085,7 @@ var roots = new Map(), updateContainer(element, root, null, callback); a: if (((element = root.current), element.child)) switch (element.child.tag) { - case 5: + case 7: element = element.child.stateNode.canonical; break a; default: @@ -6863,7 +6182,7 @@ var roots = new Map(), findFiberByHostInstance: getInstanceFromInstance, getInspectorDataForViewTag: getInspectorDataForViewTag, bundleType: 0, - version: "16.6.0", + version: "16.6.0-alpha.8af6728", 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 f877b504ef0..0ca23993737 100644 --- a/Libraries/Renderer/oss/ReactFabric-profiling.js +++ b/Libraries/Renderer/oss/ReactFabric-profiling.js @@ -20,7 +20,6 @@ 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) { @@ -295,7 +294,7 @@ function getListener(inst, registrationName) { } function getParent(inst) { do inst = inst.return; - while (inst && 5 !== inst.tag); + while (inst && 7 !== inst.tag); return inst ? inst : null; } function traverseTwoPhase(inst, fn, arg) { @@ -1036,8 +1035,7 @@ var ReactSharedInternals = : 60111, REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for("react.forward_ref") : 60112, REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for("react.suspense") : 60113, - REACT_MEMO_TYPE = hasSymbol ? Symbol.for("react.memo") : 60115, - REACT_LAZY_TYPE = hasSymbol ? Symbol.for("react.lazy") : 60116, + REACT_PURE_TYPE = hasSymbol ? Symbol.for("react.pure") : 60115, MAYBE_ITERATOR_SYMBOL = "function" === typeof Symbol && Symbol.iterator; function getIteratorFn(maybeIterable) { if (null === maybeIterable || "object" !== typeof maybeIterable) return null; @@ -1046,6 +1044,13 @@ 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; @@ -1064,25 +1069,23 @@ 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: - 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); + return getWrappedName(type, type.render, "ForwardRef"); + case REACT_PURE_TYPE: + return getWrappedName(type, type.render, "Pure"); } + if ( + "function" === typeof type.then && + (type = 1 === type._reactStatus ? type._reactResult : null) + ) + return getComponentName(type); + } return null; } function isFiberMountedImpl(fiber) { @@ -1093,7 +1096,7 @@ function isFiberMountedImpl(fiber) { for (; node.return; ) if (((node = node.return), 0 !== (node.effectTag & 2))) return 1; } - return 3 === node.tag ? 2 : 3; + return 5 === node.tag ? 2 : 3; } function assertIsMounted(fiber) { invariant( @@ -1169,14 +1172,14 @@ function findCurrentFiberUsingSlowPath(fiber) { "Return fibers should always be each others' alternates. This error is likely caused by a bug in React. Please file an issue." ); } - invariant(3 === a.tag, "Unable to find node on an unmounted component."); + invariant(5 === a.tag, "Unable to find node on an unmounted component."); return a.stateNode.current === a ? fiber : alternate; } function findCurrentHostFiber(parent) { parent = findCurrentFiberUsingSlowPath(parent); if (!parent) return null; for (var node = parent; ; ) { - if (5 === node.tag || 6 === node.tag) return node; + if (7 === node.tag || 8 === node.tag) return node; if (node.child) (node.child.return = node), (node = node.child); else { if (node === parent) break; @@ -1426,12 +1429,18 @@ var now$1 = return Date.now(); }, scheduledCallback = null, - frameDeadline = 0; + frameDeadline = 0, + frameDeadlineObject = { + timeRemaining: function() { + return frameDeadline - now$1(); + }, + didTimeout: !1 + }; function setTimeoutCallback() { frameDeadline = now$1() + 5; var callback = scheduledCallback; scheduledCallback = null; - null !== callback && callback(); + null !== callback && callback(frameDeadlineObject); } var restoreTarget = null, restoreQueue = null; @@ -1595,13 +1604,13 @@ function getStackByFiberInDevAndProd(workInProgress) { var info = ""; do { a: switch (workInProgress.tag) { - case 2: - case 16: + case 4: case 0: case 1: - case 5: - case 8: - case 13: + case 2: + case 3: + case 7: + case 10: var owner = workInProgress._debugOwner, source = workInProgress._debugSource, name = getComponentName(workInProgress.type); @@ -1753,7 +1762,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 = this.elementType = null; + this.sibling = this.child = this.return = this.stateNode = this.type = null; this.index = 0; this.ref = null; this.pendingProps = pendingProps; @@ -1767,33 +1776,29 @@ 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(Component) { +function resolveLazyComponentTag(fiber, Component) { if ("function" === typeof Component) - return shouldConstruct(Component) ? 1 : 0; + return shouldConstruct(Component) ? 3 : 1; if (void 0 !== Component && null !== Component) { - Component = Component.$$typeof; - if (Component === REACT_FORWARD_REF_TYPE) return 11; - if (Component === REACT_MEMO_TYPE) return 14; + fiber = Component.$$typeof; + if (fiber === REACT_FORWARD_REF_TYPE) return 14; + if (fiber === REACT_PURE_TYPE) return 18; } - return 2; + return 4; } function createWorkInProgress(current, pendingProps) { var workInProgress = current.alternate; null === workInProgress - ? ((workInProgress = createFiber( + ? ((workInProgress = new FiberNode( current.tag, pendingProps, current.key, current.mode )), - (workInProgress.elementType = current.elementType), (workInProgress.type = current.type), (workInProgress.stateNode = current.stateNode), (workInProgress.alternate = current), @@ -1819,66 +1824,60 @@ function createWorkInProgress(current, pendingProps) { workInProgress.treeBaseDuration = current.treeBaseDuration; return workInProgress; } -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; +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; else a: switch (type) { case REACT_FRAGMENT_TYPE: return createFiberFromFragment( - pendingProps.children, + element.children, mode, expirationTime, key ); case REACT_CONCURRENT_MODE_TYPE: - return createFiberFromMode(pendingProps, mode | 3, expirationTime, key); + fiberTag = 10; + mode |= 3; + break; case REACT_STRICT_MODE_TYPE: - return createFiberFromMode(pendingProps, mode | 2, expirationTime, key); + fiberTag = 10; + mode |= 2; + break; case REACT_PROFILER_TYPE: return ( - (type = createFiber(12, pendingProps, key, mode | 4)), - (type.elementType = REACT_PROFILER_TYPE), + (type = new FiberNode(15, element, key, mode | 4)), (type.type = REACT_PROFILER_TYPE), (type.expirationTime = expirationTime), type ); case REACT_SUSPENSE_TYPE: - return ( - (type = createFiber(13, pendingProps, key, mode)), - (type.elementType = REACT_SUSPENSE_TYPE), - (type.type = REACT_SUSPENSE_TYPE), - (type.expirationTime = expirationTime), - type - ); + fiberTag = 16; + break; default: if ("object" === typeof type && null !== type) switch (type.$$typeof) { case REACT_PROVIDER_TYPE: - fiberTag = 10; + fiberTag = 12; break a; case REACT_CONTEXT_TYPE: - fiberTag = 9; - break a; - case REACT_FORWARD_REF_TYPE: fiberTag = 11; break a; - case REACT_MEMO_TYPE: - fiberTag = 14; + case REACT_FORWARD_REF_TYPE: + fiberTag = 13; break a; - case REACT_LAZY_TYPE: - fiberTag = 16; - owner = null; + case REACT_PURE_TYPE: + fiberTag = 17; break a; + default: + if ("function" === typeof type.then) { + fiberTag = 4; + break a; + } } invariant( !1, @@ -1887,33 +1886,24 @@ function createFiberFromTypeAndProps( "" ); } - key = createFiber(fiberTag, pendingProps, key, mode); - key.elementType = type; - key.type = owner; - key.expirationTime = expirationTime; - return key; + mode = new FiberNode(fiberTag, element, key, mode); + mode.type = type; + mode.expirationTime = expirationTime; + return mode; } function createFiberFromFragment(elements, mode, expirationTime, key) { - elements = createFiber(7, elements, key, mode); + elements = new FiberNode(9, 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 = createFiber(6, content, null, mode); + content = new FiberNode(8, content, null, mode); content.expirationTime = expirationTime; return content; } function createFiberFromPortal(portal, mode, expirationTime) { - mode = createFiber( - 4, + mode = new FiberNode( + 6, null !== portal.children ? portal.children : [], portal.key, mode @@ -1931,9 +1921,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); } @@ -1948,19 +1938,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); @@ -1970,17 +1960,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; @@ -1995,18 +1985,22 @@ 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; - earliestPendingTime > renderExpirationTime && - (renderExpirationTime = earliestPendingTime); - root > renderExpirationTime && (renderExpirationTime = root); + if ( + 0 === renderExpirationTime || + (0 !== earliestPendingTime && earliestPendingTime < renderExpirationTime) + ) + renderExpirationTime = earliestPendingTime; + if (0 === renderExpirationTime || (0 !== root && root < renderExpirationTime)) + renderExpirationTime = root; return renderExpirationTime; } function findNextExpirationTimeToWorkOn(completedExpirationTime, root) { @@ -2018,11 +2012,12 @@ function findNextExpirationTimeToWorkOn(completedExpirationTime, root) { 0 !== earliestPendingTime ? earliestPendingTime : latestPingedTime; 0 === earliestPendingTime && (0 === completedExpirationTime || - latestSuspendedTime < completedExpirationTime) && + latestSuspendedTime > completedExpirationTime) && (earliestPendingTime = latestSuspendedTime); completedExpirationTime = earliestPendingTime; 0 !== completedExpirationTime && - earliestSuspendedTime > completedExpirationTime && + 0 !== earliestSuspendedTime && + earliestSuspendedTime < completedExpirationTime && (completedExpirationTime = earliestSuspendedTime); root.nextExpirationTimeToWorkOn = earliestPendingTime; root.expirationTime = completedExpirationTime; @@ -2134,7 +2129,7 @@ function getStateFromUpdate( : workInProgress ); case 3: - workInProgress.effectTag = (workInProgress.effectTag & -2049) | 64; + workInProgress.effectTag = (workInProgress.effectTag & -1025) | 64; case 0: workInProgress = update.payload; nextProps = @@ -2167,52 +2162,58 @@ function processUpdateQueue( ) { var updateExpirationTime = update.expirationTime; - updateExpirationTime < renderExpirationTime - ? (null === newFirstUpdate && + if (updateExpirationTime > renderExpirationTime) { + if ( + (null === newFirstUpdate && ((newFirstUpdate = update), (newBaseState = resultState)), - newExpirationTime < updateExpirationTime && - (newExpirationTime = updateExpirationTime)) - : ((resultState = getStateFromUpdate( - workInProgress, - queue, - update, - resultState, - props, - instance - )), + 0 === newExpirationTime || newExpirationTime > updateExpirationTime) + ) + newExpirationTime = updateExpirationTime; + } else + (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; - _updateExpirationTime < renderExpirationTime - ? (null === updateExpirationTime && + if (_updateExpirationTime > renderExpirationTime) { + if ( + (null === updateExpirationTime && ((updateExpirationTime = update), null === newFirstUpdate && (newBaseState = resultState)), - newExpirationTime < _updateExpirationTime && - (newExpirationTime = _updateExpirationTime)) - : ((resultState = getStateFromUpdate( - workInProgress, - queue, - update, - resultState, - props, - instance - )), + 0 === newExpirationTime || newExpirationTime > _updateExpirationTime) + ) + newExpirationTime = _updateExpirationTime; + } else + (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); @@ -2293,277 +2294,13 @@ function readContext(context, observedBits) { null === lastContextDependency ? (invariant( null !== currentlyRenderingFiber, - "Context can only be read while React is rendering, e.g. inside the render method or getDerivedStateFromProps." + "Context.unstable_read(): 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 }, @@ -2643,8 +2380,7 @@ function shallowEqual(objA, objB) { return !1; return !0; } -var ReactCurrentOwner$4 = ReactSharedInternals.ReactCurrentOwner, - emptyRefsObject = new React.Component().refs; +var emptyRefsObject = new React.Component().refs; function applyDerivedStateFromProps( workInProgress, ctor, @@ -2676,7 +2412,6 @@ var classComponentUpdater = { var update = createUpdate(currentTime); update.payload = payload; void 0 !== callback && null !== callback && (update.callback = callback); - flushPassiveEffects(); enqueueUpdate(inst, update); scheduleWork(inst, currentTime); }, @@ -2688,7 +2423,6 @@ var classComponentUpdater = { update.tag = 1; update.payload = payload; void 0 !== callback && null !== callback && (update.callback = callback); - flushPassiveEffects(); enqueueUpdate(inst, update); scheduleWork(inst, currentTime); }, @@ -2699,7 +2433,6 @@ var classComponentUpdater = { var update = createUpdate(currentTime); update.tag = 2; void 0 !== callback && null !== callback && (update.callback = callback); - flushPassiveEffects(); enqueueUpdate(inst, update); scheduleWork(inst, currentTime); } @@ -2720,32 +2453,6 @@ 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, @@ -2772,9 +2479,7 @@ function mountClassInstance( instance.refs = emptyRefsObject; var contextType = ctor.contextType; "object" === typeof contextType && null !== contextType - ? (instance.context = ReactCurrentOwner$4.currentDispatcher.readContext( - contextType - )) + ? (instance.context = contextType.unstable_read()) : ((contextType = isContextProvider(ctor) ? previousContext : contextStackCursor.current), @@ -2829,7 +2534,10 @@ function coerceRef(returnFiber, current$$1, element) { element = element._owner; var inst = void 0; element && - (invariant(1 === element.tag, "Function components cannot have refs."), + (invariant( + 2 === element.tag || 3 === element.tag, + "Function components cannot have refs." + ), (inst = element.stateNode)); invariant( inst, @@ -2934,7 +2642,7 @@ function ChildReconciler(shouldTrackSideEffects) { textContent, expirationTime ) { - if (null === current$$1 || 6 !== current$$1.tag) + if (null === current$$1 || 8 !== current$$1.tag) return ( (current$$1 = createFiberFromText( textContent, @@ -2949,18 +2657,15 @@ function ChildReconciler(shouldTrackSideEffects) { return current$$1; } function updateElement(returnFiber, current$$1, element, expirationTime) { - if (null !== current$$1 && current$$1.elementType === element.type) + if (null !== current$$1 && current$$1.type === element.type) return ( (expirationTime = useFiber(current$$1, element.props, expirationTime)), (expirationTime.ref = coerceRef(returnFiber, current$$1, element)), (expirationTime.return = returnFiber), expirationTime ); - expirationTime = createFiberFromTypeAndProps( - element.type, - element.key, - element.props, - null, + expirationTime = createFiberFromElement( + element, returnFiber.mode, expirationTime ); @@ -2971,7 +2676,7 @@ function ChildReconciler(shouldTrackSideEffects) { function updatePortal(returnFiber, current$$1, portal, expirationTime) { if ( null === current$$1 || - 4 !== current$$1.tag || + 6 !== current$$1.tag || current$$1.stateNode.containerInfo !== portal.containerInfo || current$$1.stateNode.implementation !== portal.implementation ) @@ -2995,7 +2700,7 @@ function ChildReconciler(shouldTrackSideEffects) { expirationTime, key ) { - if (null === current$$1 || 7 !== current$$1.tag) + if (null === current$$1 || 9 !== current$$1.tag) return ( (current$$1 = createFiberFromFragment( fragment, @@ -3025,11 +2730,8 @@ function ChildReconciler(shouldTrackSideEffects) { switch (newChild.$$typeof) { case REACT_ELEMENT_TYPE: return ( - (expirationTime = createFiberFromTypeAndProps( - newChild.type, - newChild.key, - newChild.props, - null, + (expirationTime = createFiberFromElement( + newChild, returnFiber.mode, expirationTime )), @@ -3373,9 +3075,9 @@ function ChildReconciler(shouldTrackSideEffects) { ) { if (isUnkeyedTopLevelFragment.key === isObject) if ( - 7 === isUnkeyedTopLevelFragment.tag + 9 === isUnkeyedTopLevelFragment.tag ? newChild.type === REACT_FRAGMENT_TYPE - : isUnkeyedTopLevelFragment.elementType === newChild.type + : isUnkeyedTopLevelFragment.type === newChild.type ) { deleteRemainingChildren( returnFiber, @@ -3415,11 +3117,8 @@ function ChildReconciler(shouldTrackSideEffects) { )), (currentFirstChild.return = returnFiber), (returnFiber = currentFirstChild)) - : ((expirationTime = createFiberFromTypeAndProps( - newChild.type, - newChild.key, - newChild.props, - null, + : ((expirationTime = createFiberFromElement( + newChild, returnFiber.mode, expirationTime )), @@ -3441,7 +3140,7 @@ function ChildReconciler(shouldTrackSideEffects) { ) { if (currentFirstChild.key === isUnkeyedTopLevelFragment) if ( - 4 === currentFirstChild.tag && + 6 === currentFirstChild.tag && currentFirstChild.stateNode.containerInfo === newChild.containerInfo && currentFirstChild.stateNode.implementation === @@ -3479,7 +3178,7 @@ function ChildReconciler(shouldTrackSideEffects) { if ("string" === typeof newChild || "number" === typeof newChild) return ( (newChild = "" + newChild), - null !== currentFirstChild && 6 === currentFirstChild.tag + null !== currentFirstChild && 8 === currentFirstChild.tag ? (deleteRemainingChildren(returnFiber, currentFirstChild.sibling), (currentFirstChild = useFiber( currentFirstChild, @@ -3515,7 +3214,8 @@ function ChildReconciler(shouldTrackSideEffects) { isObject && throwOnInvalidObjectType(returnFiber, newChild); if ("undefined" === typeof newChild && !isUnkeyedTopLevelFragment) switch (returnFiber.tag) { - case 1: + case 2: + case 3: case 0: (expirationTime = returnFiber.type), invariant( @@ -3534,12 +3234,12 @@ var reconcileChildFibers = ChildReconciler(!0), isHydrating = !1; function tryHydrate(fiber, nextInstance) { switch (fiber.tag) { - case 5: + case 7: return ( (nextInstance = shim$1(nextInstance, fiber.type, fiber.pendingProps)), null !== nextInstance ? ((fiber.stateNode = nextInstance), !0) : !1 ); - case 6: + case 8: return ( (nextInstance = shim$1(nextInstance, fiber.pendingProps)), null !== nextInstance ? ((fiber.stateNode = nextInstance), !0) : !1 @@ -3562,8 +3262,7 @@ function tryToClaimNextHydratableInstance(fiber$jscomp$0) { return; } var returnFiber = hydrationParentFiber, - fiber = createFiber(5, null, null, 0); - fiber.elementType = "DELETED"; + fiber = new FiberNode(7, null, null, 0); fiber.type = "DELETED"; fiber.stateNode = firstAttemptedInstance; fiber.return = returnFiber; @@ -3581,33 +3280,36 @@ function tryToClaimNextHydratableInstance(fiber$jscomp$0) { (hydrationParentFiber = fiber$jscomp$0); } } -function readLazyComponentType(lazyComponent) { - var result = lazyComponent._result; - switch (lazyComponent._status) { +function readLazyComponentType(thenable) { + switch (thenable._reactStatus) { case 1: - return result; + return thenable._reactResult; case 2: - throw result; + throw thenable._reactResult; case 0: - throw result; + throw thenable; default: - 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)); + throw ((thenable._reactStatus = 0), + thenable.then( + function(resolvedValue) { + if (0 === thenable._reactStatus) { + thenable._reactStatus = 1; + if ("object" === typeof resolvedValue && null !== resolvedValue) { + var defaultExport = resolvedValue.default; + resolvedValue = + void 0 !== defaultExport && null !== defaultExport + ? defaultExport + : resolvedValue; + } + thenable._reactResult = resolvedValue; + } }, function(error) { - 0 === lazyComponent._status && - ((lazyComponent._status = 2), (lazyComponent._result = error)); + 0 === thenable._reactStatus && + ((thenable._reactStatus = 2), (thenable._reactResult = error)); } ), - (lazyComponent._result = result), - result); + thenable); } } var ReactCurrentOwner$3 = ReactSharedInternals.ReactCurrentOwner; @@ -3635,87 +3337,28 @@ function reconcileChildren( function updateForwardRef( current$$1, workInProgress, - Component, + type, nextProps, - renderExpirationTime$jscomp$0 -) { - Component = Component.render; - var ref = workInProgress.ref; - 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 updateMemoComponent( - current$$1, - workInProgress, - Component, - nextProps, - updateExpirationTime, renderExpirationTime ) { - 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; + type = type.render; + var ref = workInProgress.ref; if ( - updateExpirationTime < renderExpirationTime && - ((updateExpirationTime = type.memoizedProps), - (Component = Component.compare), - (Component = null !== Component ? Component : shallowEqual), - Component(updateExpirationTime, nextProps) && - current$$1.ref === workInProgress.ref) + !didPerformWorkStackCursor.current && + workInProgress.memoizedProps === nextProps && + ref === (null !== current$$1 ? current$$1.ref : null) ) return bailoutOnAlreadyFinishedWork( current$$1, workInProgress, renderExpirationTime ); - current$$1 = createWorkInProgress(type, nextProps, renderExpirationTime); - current$$1.ref = workInProgress.ref; - current$$1.return = workInProgress; - return (workInProgress.child = current$$1); + type = type(nextProps, ref); + reconcileChildren(current$$1, workInProgress, type, renderExpirationTime); + workInProgress.memoizedProps = nextProps; + return workInProgress.child; } -function updateSimpleMemoComponent( +function updatePureComponent( current$$1, workInProgress, Component, @@ -3723,22 +3366,29 @@ function updateSimpleMemoComponent( 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 - ); + var render = Component.render, + ref = workInProgress.ref; + if ( + null !== current$$1 && + (0 === updateExpirationTime || + updateExpirationTime > renderExpirationTime) && + ((updateExpirationTime = current$$1.memoizedProps), + (Component = Component.compare), + (Component = null !== Component ? Component : shallowEqual), + workInProgress.ref === current$$1.ref && + Component(updateExpirationTime, nextProps)) + ) + 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; } function markRef(current$$1, workInProgress) { var ref = workInProgress.ref; @@ -3753,30 +3403,22 @@ function updateFunctionComponent( workInProgress, Component, nextProps, - renderExpirationTime$jscomp$0 + renderExpirationTime ) { var unmaskedContext = isContextProvider(Component) ? previousContext : contextStackCursor.current; unmaskedContext = getMaskedContext(workInProgress, 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 - ); + prepareToReadContext(workInProgress, renderExpirationTime); + Component = Component(nextProps, unmaskedContext); workInProgress.effectTag |= 1; reconcileChildren( current$$1, workInProgress, - nextChildren, - renderExpirationTime$jscomp$0 + Component, + renderExpirationTime ); + workInProgress.memoizedProps = nextProps; return workInProgress.child; } function updateClassComponent( @@ -3791,149 +3433,166 @@ function updateClassComponent( pushContextProvider(workInProgress); } else hasContext = !1; prepareToReadContext(workInProgress, renderExpirationTime); - if (null === workInProgress.stateNode) - null !== current$$1 && - ((current$$1.alternate = null), - (workInProgress.alternate = null), - (workInProgress.effectTag |= 2)), - constructClassInstance( - workInProgress, - Component, - nextProps, - 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)); mountClassInstance( workInProgress, Component, nextProps, renderExpirationTime - ), - (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 instance.getSnapshotBeforeUpdate; - hasNewLifecycles || - ("function" !== typeof instance.UNSAFE_componentWillReceiveProps && - "function" !== typeof instance.componentWillReceiveProps) || - ((oldProps !== nextProps || oldContext !== contextType) && - callComponentWillReceiveProps( - workInProgress, - instance, - nextProps, - 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) + ); + 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), - (contextType = getMaskedContext(workInProgress, contextType))), - (getDerivedStateFromProps = Component.getDerivedStateFromProps), - (hasNewLifecycles = + (context = getMaskedContext(workInProgress, context))); + var getDerivedStateFromProps = Component.getDerivedStateFromProps; + (instance = "function" === typeof getDerivedStateFromProps || - "function" === typeof instance.getSnapshotBeforeUpdate) || - ("function" !== typeof instance.UNSAFE_componentWillReceiveProps && - "function" !== typeof instance.componentWillReceiveProps) || - ((oldProps !== nextProps || oldContext !== contextType) && + "function" === typeof unmaskedContext.getSnapshotBeforeUpdate) || + ("function" !== + typeof unmaskedContext.UNSAFE_componentWillReceiveProps && + "function" !== typeof unmaskedContext.componentWillReceiveProps) || + ((isLegacyContextConsumer !== nextProps || oldContext !== context) && callComponentWillReceiveProps( workInProgress, - instance, + unmaskedContext, nextProps, - contextType + context + )); + hasForceUpdate = !1; + var oldState = workInProgress.memoizedState; + oldContext = unmaskedContext.state = oldState; + var updateQueue = workInProgress.updateQueue; + null !== updateQueue && + (processUpdateQueue( + workInProgress, + updateQueue, + nextProps, + unmaskedContext, + renderExpirationTime + ), + (oldContext = workInProgress.memoizedState)); + 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) + ? previousContext + : contextStackCursor.current), + (context = getMaskedContext(workInProgress, context))), + (getDerivedStateFromProps = Component.getDerivedStateFromProps), + (instance = + "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), (oldContext = workInProgress.memoizedState), - (oldState = instance.state = oldContext), + (oldState = unmaskedContext.state = oldContext), (updateQueue = workInProgress.updateQueue), null !== updateQueue && (processUpdateQueue( workInProgress, updateQueue, nextProps, - instance, + unmaskedContext, renderExpirationTime ), (oldState = workInProgress.memoizedState)), - oldProps !== nextProps || + isLegacyContextConsumer !== nextProps || oldContext !== oldState || didPerformWorkStackCursor.current || hasForceUpdate @@ -3950,51 +3609,53 @@ function updateClassComponent( checkShouldComponentUpdate( workInProgress, Component, - oldProps, + isLegacyContextConsumer, nextProps, oldContext, oldState, - contextType + context )) - ? (hasNewLifecycles || - ("function" !== typeof instance.UNSAFE_componentWillUpdate && - "function" !== typeof instance.componentWillUpdate) || - ("function" === typeof instance.componentWillUpdate && - instance.componentWillUpdate( + ? (instance || + ("function" !== + typeof unmaskedContext.UNSAFE_componentWillUpdate && + "function" !== typeof unmaskedContext.componentWillUpdate) || + ("function" === typeof unmaskedContext.componentWillUpdate && + unmaskedContext.componentWillUpdate( nextProps, oldState, - contextType + context ), - "function" === typeof instance.UNSAFE_componentWillUpdate && - instance.UNSAFE_componentWillUpdate( + "function" === + typeof unmaskedContext.UNSAFE_componentWillUpdate && + unmaskedContext.UNSAFE_componentWillUpdate( nextProps, oldState, - contextType + context )), - "function" === typeof instance.componentDidUpdate && + "function" === typeof unmaskedContext.componentDidUpdate && (workInProgress.effectTag |= 4), - "function" === typeof instance.getSnapshotBeforeUpdate && + "function" === typeof unmaskedContext.getSnapshotBeforeUpdate && (workInProgress.effectTag |= 256)) - : ("function" !== typeof instance.componentDidUpdate || - (oldProps === current$$1.memoizedProps && + : ("function" !== typeof unmaskedContext.componentDidUpdate || + (isLegacyContextConsumer === current$$1.memoizedProps && oldContext === current$$1.memoizedState) || (workInProgress.effectTag |= 4), - "function" !== typeof instance.getSnapshotBeforeUpdate || - (oldProps === current$$1.memoizedProps && + "function" !== typeof unmaskedContext.getSnapshotBeforeUpdate || + (isLegacyContextConsumer === current$$1.memoizedProps && oldContext === current$$1.memoizedState) || (workInProgress.effectTag |= 256), (workInProgress.memoizedProps = nextProps), (workInProgress.memoizedState = oldState)), - (instance.props = nextProps), - (instance.state = oldState), - (instance.context = contextType), + (unmaskedContext.props = nextProps), + (unmaskedContext.state = oldState), + (unmaskedContext.context = context), (nextProps = getDerivedStateFromProps)) - : ("function" !== typeof instance.componentDidUpdate || - (oldProps === current$$1.memoizedProps && + : ("function" !== typeof unmaskedContext.componentDidUpdate || + (isLegacyContextConsumer === current$$1.memoizedProps && oldContext === current$$1.memoizedState) || (workInProgress.effectTag |= 4), - "function" !== typeof instance.getSnapshotBeforeUpdate || - (oldProps === current$$1.memoizedProps && + "function" !== typeof unmaskedContext.getSnapshotBeforeUpdate || + (isLegacyContextConsumer === current$$1.memoizedProps && oldContext === current$$1.memoizedState) || (workInProgress.effectTag |= 256), (nextProps = !1)); @@ -4057,6 +3718,7 @@ function finishClassComponent( renderExpirationTime ); workInProgress.memoizedState = shouldUpdate.state; + workInProgress.memoizedProps = shouldUpdate.props; hasContext && invalidateContextProvider(workInProgress, Component, !0); return workInProgress.child; } @@ -4082,105 +3744,6 @@ 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, @@ -4189,7 +3752,9 @@ function bailoutOnAlreadyFinishedWork( null !== current$$1 && (workInProgress.firstContextDependency = current$$1.firstContextDependency); profilerStartTime = -1; - if (workInProgress.childExpirationTime < renderExpirationTime) return null; + var childExpirationTime = workInProgress.childExpirationTime; + if (0 === childExpirationTime || childExpirationTime > renderExpirationTime) + return null; invariant( null === current$$1 || workInProgress.child === current$$1.child, "Resuming work not yet implemented." @@ -4218,566 +3783,561 @@ function bailoutOnAlreadyFinishedWork( } return workInProgress.child; } -function beginWork(current$$1, workInProgress, renderExpirationTime$jscomp$0) { +function beginWork(current$$1, workInProgress, renderExpirationTime) { var updateExpirationTime = workInProgress.expirationTime; if ( null !== current$$1 && current$$1.memoizedProps === workInProgress.pendingProps && !didPerformWorkStackCursor.current && - updateExpirationTime < renderExpirationTime$jscomp$0 + (0 === updateExpirationTime || updateExpirationTime > renderExpirationTime) ) { switch (workInProgress.tag) { - case 3: + case 5: pushHostRootContext(workInProgress); break; - case 5: + case 7: pushHostContext(workInProgress); break; - case 1: + case 2: isContextProvider(workInProgress.type) && pushContextProvider(workInProgress); break; - case 4: + case 3: + isContextProvider(workInProgress.type._reactResult) && + pushContextProvider(workInProgress); + break; + case 6: pushHostContainer( workInProgress, workInProgress.stateNode.containerInfo ); break; - case 10: + case 12: pushProvider(workInProgress, workInProgress.memoizedProps.value); break; - case 12: + case 15: 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$jscomp$0 + renderExpirationTime ); } workInProgress.expirationTime = 0; switch (workInProgress.tag) { - 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, - contextStackCursor.current + 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." ); - prepareToReadContext(workInProgress, renderExpirationTime$jscomp$0); - renderExpirationTime = renderExpirationTime$jscomp$0; - currentlyRenderingFiber$1 = workInProgress; - firstCurrentHook = null; - var value = updateExpirationTime(current$$1, context); - workInProgress.effectTag |= 1; + var props = workInProgress.pendingProps; if ( - "object" === typeof value && - null !== value && - "function" === typeof value.render && - void 0 === value.$$typeof + "object" === typeof Component && + null !== Component && + "function" === typeof Component.then ) { - 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( + Component = readLazyComponentType(Component); + var resolvedTag = (workInProgress.tag = resolveLazyComponentTag( 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 + Component )), - 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, + 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, - updateExpirationTime, - value, - renderExpirationTime$jscomp$0 - ) + 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, + workInProgress, + workInProgress.type, + workInProgress.pendingProps, + renderExpirationTime ); case 1: return ( - (updateExpirationTime = workInProgress.type), - (value = workInProgress.pendingProps), - (value = - workInProgress.elementType === updateExpirationTime - ? value - : resolveDefaultProps(updateExpirationTime, value)), - updateClassComponent( + (props = workInProgress.type._reactResult), + (Component = workInProgress.pendingProps), + (current$$1 = updateFunctionComponent( current$$1, workInProgress, - updateExpirationTime, - value, - renderExpirationTime$jscomp$0 - ) + props, + resolveDefaultProps(props, Component), + renderExpirationTime + )), + (workInProgress.memoizedProps = Component), + current$$1 + ); + case 2: + return updateClassComponent( + current$$1, + workInProgress, + workInProgress.type, + workInProgress.pendingProps, + renderExpirationTime ); 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), - (updateExpirationTime = workInProgress.updateQueue), + (Component = workInProgress.updateQueue), invariant( - null !== updateExpirationTime, + null !== Component, "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." ), - (value = workInProgress.memoizedState), - (value = null !== value ? value.element : null), + (props = workInProgress.memoizedState), + (props = null !== props ? props.element : null), processUpdateQueue( workInProgress, - updateExpirationTime, + Component, workInProgress.pendingProps, null, - renderExpirationTime$jscomp$0 + renderExpirationTime ), - (updateExpirationTime = workInProgress.memoizedState.element), - updateExpirationTime === value + (Component = workInProgress.memoizedState.element), + Component === props ? (workInProgress = bailoutOnAlreadyFinishedWork( current$$1, workInProgress, - renderExpirationTime$jscomp$0 + renderExpirationTime )) : (reconcileChildren( current$$1, workInProgress, - updateExpirationTime, - renderExpirationTime$jscomp$0 + Component, + renderExpirationTime ), (workInProgress = workInProgress.child)), workInProgress ); - case 5: + case 7: return ( pushHostContext(workInProgress), null === current$$1 && tryToClaimNextHydratableInstance(workInProgress), - (updateExpirationTime = workInProgress.pendingProps.children), + (Component = workInProgress.pendingProps), + (props = Component.children), markRef(current$$1, workInProgress), reconcileChildren( current$$1, workInProgress, - updateExpirationTime, - renderExpirationTime$jscomp$0 + props, + renderExpirationTime ), + (workInProgress.memoizedProps = Component), (workInProgress = workInProgress.child), workInProgress ); - case 6: + case 8: return ( null === current$$1 && tryToClaimNextHydratableInstance(workInProgress), + (workInProgress.memoizedProps = workInProgress.pendingProps), null ); - case 13: - return updateSuspenseComponent( - current$$1, - workInProgress, - renderExpirationTime$jscomp$0 + 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 4: + case 6: return ( pushHostContainer( workInProgress, workInProgress.stateNode.containerInfo ), - (updateExpirationTime = workInProgress.pendingProps), + (Component = workInProgress.pendingProps), null === current$$1 ? (workInProgress.child = reconcileChildFibers( workInProgress, null, - updateExpirationTime, - renderExpirationTime$jscomp$0 + Component, + renderExpirationTime )) : reconcileChildren( current$$1, workInProgress, - updateExpirationTime, - renderExpirationTime$jscomp$0 + Component, + renderExpirationTime ), + (workInProgress.memoizedProps = Component), workInProgress.child ); - case 11: + case 13: + return updateForwardRef( + current$$1, + workInProgress, + workInProgress.type, + workInProgress.pendingProps, + renderExpirationTime + ); + case 14: return ( - (updateExpirationTime = workInProgress.type), - (value = workInProgress.pendingProps), - (value = - workInProgress.elementType === updateExpirationTime - ? value - : resolveDefaultProps(updateExpirationTime, value)), - updateForwardRef( + (props = workInProgress.type._reactResult), + (Component = workInProgress.pendingProps), + (current$$1 = updateForwardRef( current$$1, workInProgress, - updateExpirationTime, - value, - renderExpirationTime$jscomp$0 - ) + props, + resolveDefaultProps(props, Component), + renderExpirationTime + )), + (workInProgress.memoizedProps = Component), + current$$1 ); - case 7: + case 9: return ( + (Component = workInProgress.pendingProps), reconcileChildren( current$$1, workInProgress, - workInProgress.pendingProps, - renderExpirationTime$jscomp$0 - ), - workInProgress.child - ); - case 8: - return ( - reconcileChildren( - current$$1, - workInProgress, - workInProgress.pendingProps.children, - renderExpirationTime$jscomp$0 - ), - workInProgress.child - ); - case 12: - return ( - (workInProgress.effectTag |= 4), - reconcileChildren( - current$$1, - workInProgress, - workInProgress.pendingProps.children, - renderExpirationTime$jscomp$0 + Component, + renderExpirationTime ), + (workInProgress.memoizedProps = Component), workInProgress.child ); case 10: + return ( + (Component = workInProgress.pendingProps.children), + reconcileChildren( + current$$1, + workInProgress, + Component, + renderExpirationTime + ), + (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: a: { - 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) { + 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) + ) { if ( - getDerivedStateFromProps.children === value.children && + resolvedTag.children === props.children && !didPerformWorkStackCursor.current ) { workInProgress = bailoutOnAlreadyFinishedWork( current$$1, workInProgress, - renderExpirationTime$jscomp$0 + renderExpirationTime ); break a; } } else for ( - getDerivedStateFromProps = workInProgress.child, - null !== getDerivedStateFromProps && - (getDerivedStateFromProps.return = workInProgress); - null !== getDerivedStateFromProps; + resolvedTag = workInProgress.child, + null !== resolvedTag && (resolvedTag.return = workInProgress); + null !== resolvedTag; ) { - oldValue = getDerivedStateFromProps.firstContextDependency; - if (null !== oldValue) { + resolvedProps = resolvedTag.firstContextDependency; + if (null !== resolvedProps) { do { if ( - oldValue.context === updateExpirationTime && - 0 !== (oldValue.observedBits & context) + resolvedProps.context === Component && + 0 !== (resolvedProps.observedBits & updateExpirationTime) ) { - 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 (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 ( - node.childExpirationTime < renderExpirationTime$jscomp$0 + 0 === node.childExpirationTime || + node.childExpirationTime > renderExpirationTime ) - (node.childExpirationTime = renderExpirationTime$jscomp$0), - null !== nextFiber && - nextFiber.childExpirationTime < - renderExpirationTime$jscomp$0 && - (nextFiber.childExpirationTime = renderExpirationTime$jscomp$0); + (node.childExpirationTime = renderExpirationTime), + null !== child && + (0 === child.childExpirationTime || + child.childExpirationTime > + renderExpirationTime) && + (child.childExpirationTime = renderExpirationTime); else if ( - null !== nextFiber && - nextFiber.childExpirationTime < - renderExpirationTime$jscomp$0 + null !== child && + (0 === child.childExpirationTime || + child.childExpirationTime > renderExpirationTime) ) - nextFiber.childExpirationTime = renderExpirationTime$jscomp$0; + child.childExpirationTime = renderExpirationTime; else break; node = node.return; } } - nextFiber = getDerivedStateFromProps.child; - oldValue = oldValue.next; - } while (null !== oldValue); + child = resolvedTag.child; + resolvedProps = resolvedProps.next; + } while (null !== resolvedProps); } else - nextFiber = - 10 === getDerivedStateFromProps.tag - ? getDerivedStateFromProps.type === workInProgress.type + child = + 12 === resolvedTag.tag + ? resolvedTag.type === workInProgress.type ? null - : getDerivedStateFromProps.child - : getDerivedStateFromProps.child; - if (null !== nextFiber) - nextFiber.return = getDerivedStateFromProps; + : resolvedTag.child + : resolvedTag.child; + if (null !== child) child.return = resolvedTag; else - for ( - nextFiber = getDerivedStateFromProps; - null !== nextFiber; - - ) { - if (nextFiber === workInProgress) { - nextFiber = null; + for (child = resolvedTag; null !== child; ) { + if (child === workInProgress) { + child = null; break; } - getDerivedStateFromProps = nextFiber.sibling; - if (null !== getDerivedStateFromProps) { - getDerivedStateFromProps.return = nextFiber.return; - nextFiber = getDerivedStateFromProps; + resolvedTag = child.sibling; + if (null !== resolvedTag) { + resolvedTag.return = child.return; + child = resolvedTag; break; } - nextFiber = nextFiber.return; + child = child.return; } - getDerivedStateFromProps = nextFiber; + resolvedTag = child; } - } reconcileChildren( current$$1, workInProgress, - value.children, - renderExpirationTime$jscomp$0 + props.children, + renderExpirationTime ); workInProgress = workInProgress.child; } return workInProgress; - case 9: + case 11: return ( - (value = workInProgress.type), - (context = workInProgress.pendingProps), - (updateExpirationTime = context.children), - prepareToReadContext(workInProgress, renderExpirationTime$jscomp$0), - (value = readContext(value, context.unstable_observedBits)), - (updateExpirationTime = updateExpirationTime(value)), + (updateExpirationTime = workInProgress.type), + (Component = workInProgress.pendingProps), + (props = Component.children), + prepareToReadContext(workInProgress, renderExpirationTime), + (updateExpirationTime = readContext( + updateExpirationTime, + Component.unstable_observedBits + )), + (props = props(updateExpirationTime)), (workInProgress.effectTag |= 1), reconcileChildren( current$$1, workInProgress, - updateExpirationTime, - renderExpirationTime$jscomp$0 + props, + renderExpirationTime ), + (workInProgress.memoizedProps = Component), workInProgress.child ); - 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( + case 17: + return updatePureComponent( current$$1, workInProgress, workInProgress.type, workInProgress.pendingProps, updateExpirationTime, - renderExpirationTime$jscomp$0 + renderExpirationTime ); - case 17: + case 18: return ( - (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, - updateExpirationTime, - value, - renderExpirationTime$jscomp$0 - ), - mountClassInstance( - workInProgress, - updateExpirationTime, - value, - renderExpirationTime$jscomp$0 - ), - finishClassComponent( - null, - workInProgress, - updateExpirationTime, - !0, + (props = workInProgress.type._reactResult), + (Component = workInProgress.pendingProps), + (current$$1 = updatePureComponent( current$$1, - renderExpirationTime$jscomp$0 - ) + workInProgress, + props, + resolveDefaultProps(props, Component), + updateExpirationTime, + renderExpirationTime + )), + (workInProgress.memoizedProps = Component), + current$$1 ); default: invariant( @@ -4786,125 +4346,14 @@ function beginWork(current$$1, workInProgress, renderExpirationTime$jscomp$0) { ); } } -var appendAllChildren = void 0, - updateHostContainer = void 0, - updateHostComponent$1 = void 0, - updateHostText$1 = void 0; -appendAllChildren = function( - parent, - workInProgress, - needsVisibilityToggle, - isHidden -) { +function appendAllChildren(parent, workInProgress) { for (var node = workInProgress.child; null !== node; ) { - 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 (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; } if (node === workInProgress) break; for (; null === node.sibling; ) { @@ -4915,12 +4364,30 @@ function appendAllChildrenToContainer( 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); - appendAllChildrenToContainer(newChildSet, workInProgress, !1, !1); + 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; + } portalOrRoot.pendingChildren = newChildSet; workInProgress.effectTag |= 4; FabricUIManager.completeRoot(container, newChildSet); @@ -4967,7 +4434,7 @@ updateHostComponent$1 = function(current, workInProgress, type, newProps) { (workInProgress.stateNode = type), current ? (workInProgress.effectTag |= 4) - : appendAllChildren(type, workInProgress, !1, !1)); + : appendAllChildren(type, workInProgress)); } }; updateHostText$1 = function(current, workInProgress, oldText, newText) { @@ -5001,6 +4468,7 @@ 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; @@ -5017,7 +4485,7 @@ function logError(boundary, errorInfo) { willRetry: !1 }; null !== boundary && - 1 === boundary.tag && + 2 === boundary.tag && ((errorInfo.errorBoundary = boundary.stateNode), (errorInfo.errorBoundaryName = getComponentName(boundary.type)), (errorInfo.errorBoundaryFound = !0), @@ -5041,44 +4509,18 @@ 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 0: - case 11: - case 14: - case 15: - commitHookEffectList(4, 8, finishedWork); - return; - } - switch (finishedWork.tag) { - case 1: + case 2: + case 3: + break; + case 7: + break; + case 8: break; case 5: - break; case 6: break; - case 3: - case 4: - break; default: invariant( !1, @@ -5086,6 +4528,9 @@ function commitWork(current$$1, finishedWork) { ); } } +function NoopComponent() { + return null; +} function createRootErrorUpdate(fiber, errorInfo, expirationTime) { expirationTime = createUpdate(expirationTime); expirationTime.tag = 3; @@ -5131,7 +4576,7 @@ function throwException( value, renderExpirationTime ) { - sourceFiber.effectTag |= 1024; + sourceFiber.effectTag |= 512; sourceFiber.firstEffect = sourceFiber.lastEffect = null; if ( null !== value && @@ -5143,54 +4588,49 @@ function throwException( var earliestTimeoutMs = -1, startTimeMs = -1; do { - if (13 === value.tag) { - var current$$1 = value.alternate; + if (16 === value.tag) { + var current = value.alternate; if ( - null !== current$$1 && - ((current$$1 = current$$1.memoizedState), - null !== current$$1 && current$$1.didTimeout) + null !== current && + !0 === current.memoizedState && + null !== current.stateNode ) { - startTimeMs = 10 * (1073741822 - current$$1.timedOutAt); + startTimeMs = 10 * (current.stateNode.timedOutAt - 2); break; } - 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; + current = value.pendingProps.maxDuration; + if ("number" === typeof current) + if (0 >= current) earliestTimeoutMs = 0; + else if (-1 === earliestTimeoutMs || current < earliestTimeoutMs) + earliestTimeoutMs = current; } value = value.return; } while (null !== value); value = returnFiber; do { - 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) { + if (16 === value.tag && !value.memoizedState) { returnFiber = retrySuspendedRoot.bind( null, root, value, - sourceFiber, - 0 === (value.mode & 1) ? 1073741823 : renderExpirationTime + 0 === (value.mode & 1) ? 1 : renderExpirationTime ); returnFiber = tracing.unstable_wrap(returnFiber); thenable.then(returnFiber, returnFiber); - if (0 === (value.mode & 1)) { - value.effectTag |= 32; + if (0 === (value.mode & 2)) { + value.effectTag |= 4; reconcileChildren( sourceFiber.alternate, sourceFiber, null, renderExpirationTime ); - sourceFiber.effectTag &= -1025; - sourceFiber.effectTag &= -933; - 1 === sourceFiber.tag && - null === sourceFiber.alternate && - (sourceFiber.tag = 17); + 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)); return; } -1 === earliestTimeoutMs @@ -5198,26 +4638,24 @@ function throwException( : (-1 === startTimeMs && (startTimeMs = 10 * - (1073741822 - - findEarliestOutstandingPriorityLevel( - root, - renderExpirationTime - )) - + (findEarliestOutstandingPriorityLevel( + root, + renderExpirationTime + ) - + 2) - 5e3), (root = startTimeMs + earliestTimeoutMs)); 0 <= root && nextLatestAbsoluteTimeoutMs < root && (nextLatestAbsoluteTimeoutMs = root); - value.effectTag |= 2048; + value.effectTag |= 1024; value.expirationTime = renderExpirationTime; return; } value = value.return; } while (null !== value); value = Error( - (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) + "An update was suspended, but no placeholder UI was provided." ); } nextRenderDidError = !0; @@ -5225,9 +4663,9 @@ function throwException( root = returnFiber; do { switch (root.tag) { - case 3: + case 5: sourceFiber = value; - root.effectTag |= 2048; + root.effectTag |= 1024; root.expirationTime = renderExpirationTime; renderExpirationTime = createRootErrorUpdate( root, @@ -5236,7 +4674,8 @@ function throwException( ); enqueueCapturedUpdate(root, renderExpirationTime); return; - case 1: + case 2: + case 3: if ( ((sourceFiber = value), (returnFiber = root.type), @@ -5248,7 +4687,7 @@ function throwException( (null === legacyErrorBoundariesThatAlreadyFailed || !legacyErrorBoundariesThatAlreadyFailed.has(thenable))))) ) { - root.effectTag |= 2048; + root.effectTag |= 1024; root.expirationTime = renderExpirationTime; renderExpirationTime = createClassErrorUpdate( root, @@ -5264,14 +4703,24 @@ function throwException( } function unwindWork(workInProgress) { switch (workInProgress.tag) { - case 1: + case 2: isContextProvider(workInProgress.type) && popContext(workInProgress); var effectTag = workInProgress.effectTag; - return effectTag & 2048 - ? ((workInProgress.effectTag = (effectTag & -2049) | 64), + return effectTag & 1024 + ? ((workInProgress.effectTag = (effectTag & -1025) | 64), workInProgress) : null; case 3: + return ( + isContextProvider(workInProgress.type._reactResult) && + popContext(workInProgress), + (effectTag = workInProgress.effectTag), + effectTag & 1024 + ? ((workInProgress.effectTag = (effectTag & -1025) | 64), + workInProgress) + : null + ); + case 5: return ( popHostContainer(workInProgress), popTopLevelContextObject(workInProgress), @@ -5280,117 +4729,28 @@ 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 & -2049) | 64), + (workInProgress.effectTag = (effectTag & -1025) | 64), workInProgress ); - case 5: + case 7: return popHostContext(workInProgress), null; - 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: + case 16: + return ( + (effectTag = workInProgress.effectTag), + effectTag & 1024 + ? ((workInProgress.effectTag = (effectTag & -1025) | 64), + workInProgress) + : null + ); + case 6: return popHostContainer(workInProgress), null; - case 10: + case 12: return popProvider(workInProgress), null; default: return null; } } -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); - } - }, +var Dispatcher = { readContext: readContext }, ReactCurrentOwner$2 = ReactSharedInternals.ReactCurrentOwner; invariant( null != tracing.__interactionsRef && @@ -5405,9 +4765,6 @@ var isWorking = !1, nextRenderDidError = !1, nextEffect = null, isCommitting$1 = !1, - rootWithPendingPassiveEffects = null, - passiveEffectCallbackHandle = null, - passiveEffectCallback = null, legacyErrorBoundariesThatAlreadyFailed = null; function resetStack() { if (null !== nextUnitOfWork) @@ -5418,7 +4775,7 @@ function resetStack() { ) { var interruptedWork$jscomp$0 = interruptedWork; switch (interruptedWork$jscomp$0.tag) { - case 1: + case 2: var childContextTypes = interruptedWork$jscomp$0.type.childContextTypes; null !== childContextTypes && @@ -5426,16 +4783,23 @@ 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 5: + case 7: popHostContext(interruptedWork$jscomp$0); break; - case 4: + case 6: popHostContainer(interruptedWork$jscomp$0); break; - case 10: + case 12: popProvider(interruptedWork$jscomp$0); } interruptedWork = interruptedWork.return; @@ -5476,46 +4840,23 @@ function commitAllHostEffects() { "function" === typeof onCommitFiberUnmount && 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$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: + case 2: + case 3: safelyDetachRef(current$$1$jscomp$0); - updateQueue = current$$1$jscomp$0.stateNode; - if ("function" === typeof updateQueue.componentWillUnmount) + var instance = current$$1$jscomp$0.stateNode; + if ("function" === typeof instance.componentWillUnmount) try { - (updateQueue.props = current$$1$jscomp$0.memoizedProps), - (updateQueue.state = current$$1$jscomp$0.memoizedState), - updateQueue.componentWillUnmount(); + (instance.props = current$$1$jscomp$0.memoizedProps), + (instance.state = current$$1$jscomp$0.memoizedState), + instance.componentWillUnmount(); } catch (unmountError) { captureCommitPhaseError(current$$1$jscomp$0, unmountError); } break; - case 5: + case 7: safelyDetachRef(current$$1$jscomp$0); break; - case 4: + case 6: FabricUIManager.createChildSet( current$$1$jscomp$0.stateNode.containerInfo ); @@ -5543,17 +4884,13 @@ function commitAllHostEffects() { } function commitBeforeMutationLifecycles() { for (; null !== nextEffect; ) { - if (nextEffect.effectTag & 256) + if (nextEffect.effectTag & 256) { + var current$$1 = nextEffect.alternate; a: { - var current$$1 = nextEffect.alternate, - finishedWork = nextEffect; + var finishedWork = nextEffect; switch (finishedWork.tag) { - case 0: - case 11: - case 15: - commitHookEffectList(2, 0, finishedWork); - break a; - case 1: + case 2: + case 3: if (finishedWork.effectTag & 256 && null !== current$$1) { var prevProps = current$$1.memoizedProps, prevState = current$$1.memoizedState; @@ -5567,11 +4904,10 @@ 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( @@ -5580,6 +4916,7 @@ function commitBeforeMutationLifecycles() { ); } } + } nextEffect = nextEffect.nextEffect; } } @@ -5591,107 +4928,93 @@ function commitAllLifeCycles( var effectTag = nextEffect.effectTag; if (effectTag & 36) { var finishedRoot = finishedRoot$jscomp$0, - 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) + current$$1 = nextEffect.alternate, + finishedWork = nextEffect, + committedExpirationTime = committedExpirationTime$jscomp$0; + switch (finishedWork.tag) { + case 2: + case 3: + finishedRoot = finishedWork.stateNode; + if (finishedWork.effectTag & 4) if (null === current$$1) - (finishedRoot.props = newDidTimeout.memoizedProps), - (finishedRoot.state = newDidTimeout.memoizedState), + (finishedRoot.props = finishedWork.memoizedProps), + (finishedRoot.state = finishedWork.memoizedState), finishedRoot.componentDidMount(); else { var prevProps = current$$1.memoizedProps; current$$1 = current$$1.memoizedState; - finishedRoot.props = newDidTimeout.memoizedProps; - finishedRoot.state = newDidTimeout.memoizedState; + finishedRoot.props = finishedWork.memoizedProps; + finishedRoot.state = finishedWork.memoizedState; finishedRoot.componentDidUpdate( prevProps, current$$1, finishedRoot.__reactInternalSnapshotBeforeUpdate ); } - current$$1 = newDidTimeout.updateQueue; + current$$1 = finishedWork.updateQueue; null !== current$$1 && - ((finishedRoot.props = newDidTimeout.memoizedProps), - (finishedRoot.state = newDidTimeout.memoizedState), + ((finishedRoot.props = finishedWork.memoizedProps), + (finishedRoot.state = finishedWork.memoizedState), commitUpdateQueue( - newDidTimeout, + finishedWork, current$$1, finishedRoot, committedExpirationTime )); break; - case 3: - current$$1 = newDidTimeout.updateQueue; + case 5: + current$$1 = finishedWork.updateQueue; if (null !== current$$1) { finishedRoot = null; - if (null !== newDidTimeout.child) - switch (newDidTimeout.child.tag) { - case 5: - finishedRoot = newDidTimeout.child.stateNode.canonical; + if (null !== finishedWork.child) + switch (finishedWork.child.tag) { + case 7: + finishedRoot = finishedWork.child.stateNode.canonical; break; - case 1: - finishedRoot = newDidTimeout.child.stateNode; + case 2: + case 3: + finishedRoot = finishedWork.child.stateNode; } commitUpdateQueue( - newDidTimeout, + finishedWork, current$$1, finishedRoot, committedExpirationTime ); } break; - case 5: + case 7: null === current$$1 && - newDidTimeout.effectTag & 4 && + finishedWork.effectTag & 4 && invariant( !1, "The current renderer does not support mutation. This error is likely caused by a bug in React. Please file an issue." ); break; + case 8: + break; case 6: break; - case 4: - break; - case 12: - committedExpirationTime = newDidTimeout.memoizedProps.onRender; + case 15: + committedExpirationTime = finishedWork.memoizedProps.onRender; committedExpirationTime( - newDidTimeout.memoizedProps.id, + finishedWork.memoizedProps.id, null === current$$1 ? "mount" : "update", - newDidTimeout.actualDuration, - newDidTimeout.treeBaseDuration, - newDidTimeout.actualStartTime, + finishedWork.actualDuration, + finishedWork.treeBaseDuration, + finishedWork.actualStartTime, commitTime, finishedRoot.memoizedInteractions ); break; - 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: + case 16: + 0 === (finishedWork.mode & 2) + ? ((finishedWork.updateQueue = emptyObject$1), + scheduleWork(finishedWork, 1)) + : ((committedExpirationTime = requestCurrentTime()), + (finishedWork.stateNode = { + timedOutAt: committedExpirationTime + })); break; default: invariant( @@ -5700,51 +5023,21 @@ function commitAllLifeCycles( ); } } - if ( - effectTag & 128 && - ((newDidTimeout = nextEffect.ref), null !== newDidTimeout) - ) { - committedExpirationTime = nextEffect.stateNode; + if (effectTag & 128 && ((effectTag = nextEffect.ref), null !== effectTag)) { + finishedWork = nextEffect.stateNode; switch (nextEffect.tag) { - case 5: - committedExpirationTime = committedExpirationTime.canonical; + case 7: + finishedWork = finishedWork.canonical; } - "function" === typeof newDidTimeout - ? newDidTimeout(committedExpirationTime) - : (newDidTimeout.current = committedExpirationTime); + "function" === typeof effectTag + ? effectTag(finishedWork) + : (effectTag.current = finishedWork); } - effectTag & 512 && (rootWithPendingPassiveEffects = finishedRoot$jscomp$0); - nextEffect = nextEffect.nextEffect; + effectTag = nextEffect.nextEffect; + nextEffect.nextEffect = null; + nextEffect = effectTag; } } -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( @@ -5761,7 +5054,9 @@ function commitRoot(root, finishedWork) { childExpirationTimeBeforeCommit = finishedWork.childExpirationTime; markCommittedPriorityLevels( root, - childExpirationTimeBeforeCommit > updateExpirationTimeBeforeCommit + 0 === updateExpirationTimeBeforeCommit || + (0 !== childExpirationTimeBeforeCommit && + childExpirationTimeBeforeCommit < updateExpirationTimeBeforeCommit) ? childExpirationTimeBeforeCommit : updateExpirationTimeBeforeCommit ); @@ -5811,42 +5106,29 @@ function commitRoot(root, finishedWork) { } root.current = finishedWork; for (nextEffect = childExpirationTimeBeforeCommit; null !== nextEffect; ) { - didError = !1; - error$jscomp$0 = void 0; + childExpirationTimeBeforeCommit = !1; + didError = void 0; try { commitAllLifeCycles(root, committedExpirationTime); } catch (e) { - (didError = !0), (error$jscomp$0 = e); + (childExpirationTimeBeforeCommit = !0), (didError = e); } - didError && + 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$jscomp$0), + captureCommitPhaseError(nextEffect, didError), 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 = - finishedWork > childExpirationTimeBeforeCommit + 0 === childExpirationTimeBeforeCommit || + (0 !== finishedWork && finishedWork < childExpirationTimeBeforeCommit) ? finishedWork : childExpirationTimeBeforeCommit; 0 === earliestRemainingTimeAfterCommit && @@ -5871,18 +5153,21 @@ function commitRoot(root, finishedWork) { scheduledInteractions, scheduledExpirationTime ) { - 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)); - } - })); + 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)); + } + }); }); } } @@ -5891,7 +5176,7 @@ function completeUnitOfWork(workInProgress) { var current$$1 = workInProgress.alternate, returnFiber = workInProgress.return, siblingFiber = workInProgress.sibling; - if (0 === (workInProgress.effectTag & 1024)) { + if (0 === (workInProgress.effectTag & 512)) { if (workInProgress.mode & 4) { var fiber = workInProgress; profilerStartTime = now$1(); @@ -5901,17 +5186,17 @@ function completeUnitOfWork(workInProgress) { current$$1 = workInProgress; fiber = current$$1.pendingProps; switch (current$$1.tag) { - case 2: - break; - case 16: - break; - case 15: case 0: - break; case 1: + break; + case 2: 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; @@ -5922,7 +5207,7 @@ function completeUnitOfWork(workInProgress) { current$$1.effectTag &= -3; updateHostContainer(current$$1); break; - case 5: + case 7: popHostContext(current$$1); var rootContainerInstance = requiredContext( rootInstanceStackCursor.current @@ -5964,7 +5249,7 @@ function completeUnitOfWork(workInProgress) { ); fiber = new ReactFabricHostComponent(current, viewConfig, fiber); fiber = { node: rootContainerInstance, canonical: fiber }; - appendAllChildren(fiber, current$$1, !1, !1); + appendAllChildren(fiber, current$$1); current$$1.stateNode = fiber; null !== current$$1.ref && (current$$1.effectTag |= 128); } else @@ -5973,7 +5258,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 6: + case 8: current && null != current$$1.stateNode ? updateHostText$1( current, @@ -5997,36 +5282,34 @@ function completeUnitOfWork(workInProgress) { current$$1 ))); break; - case 11: - break; case 13: - fiber = current$$1.memoizedState; - rootContainerInstance = - null !== current ? current.memoizedState : null; - (null !== fiber && fiber.didTimeout) !== - (null !== rootContainerInstance && - rootContainerInstance.didTimeout) && (current$$1.effectTag |= 4); + case 14: break; - case 7: - break; - case 8: - break; - case 12: - break; - case 4: - popHostContainer(current$$1); - updateHostContainer(current$$1); - break; - case 10: - popProvider(current$$1); + case 16: break; case 9: break; - case 14: + case 10: + break; + case 15: + break; + case 6: + popHostContainer(current$$1); + updateHostContainer(current$$1); + break; + case 12: + popProvider(current$$1); + break; + case 11: break; case 17: - isContextProvider(current$$1.type) && popContext(current$$1); + case 18: 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, @@ -6038,8 +5321,8 @@ function completeUnitOfWork(workInProgress) { stopProfilerTimerIfRunningAndRecordDelta(workInProgress, !1); current$$1 = workInProgress; if ( - 1 === nextRenderExpirationTime || - 1 !== current$$1.childExpirationTime + 1073741823 === nextRenderExpirationTime || + 1073741823 !== current$$1.childExpirationTime ) { fiber = 0; if (current$$1.mode & 4) { @@ -6048,15 +5331,23 @@ 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), - internalInstanceHandle > fiber && - (fiber = internalInstanceHandle), - 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; + 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; + } current$$1.actualDuration = rootContainerInstance; current$$1.treeBaseDuration = current; } else @@ -6064,16 +5355,19 @@ function completeUnitOfWork(workInProgress) { rootContainerInstance = current$$1.child; null !== rootContainerInstance; - ) - (current = rootContainerInstance.expirationTime), - (viewConfig = rootContainerInstance.childExpirationTime), - current > fiber && (fiber = current), - viewConfig > fiber && (fiber = viewConfig), - (rootContainerInstance = rootContainerInstance.sibling); + ) { + 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$$1.childExpirationTime = fiber; } null !== returnFiber && - 0 === (returnFiber.effectTag & 1024) && + 0 === (returnFiber.effectTag & 512) && (null === returnFiber.firstEffect && (returnFiber.firstEffect = workInProgress.firstEffect), null !== workInProgress.lastEffect && @@ -6097,12 +5391,12 @@ function completeUnitOfWork(workInProgress) { (siblingFiber = siblingFiber.sibling); workInProgress.actualDuration = returnFiber; } - workInProgress.effectTag &= 1023; + workInProgress.effectTag &= 511; return workInProgress; } null !== returnFiber && ((returnFiber.firstEffect = returnFiber.lastEffect = null), - (returnFiber.effectTag |= 1024)); + (returnFiber.effectTag |= 512)); } if (null !== siblingFiber) return siblingFiber; if (null !== returnFiber) workInProgress = returnFiber; @@ -6117,19 +5411,17 @@ 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) { +function renderRoot(root, isYieldy, isExpired) { 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; @@ -6152,7 +5444,7 @@ function renderRoot(root, isYieldy) { scheduledInteractions, scheduledExpirationTime ) { - scheduledExpirationTime >= expirationTime && + scheduledExpirationTime <= expirationTime && scheduledInteractions.forEach(function(interaction) { return interactions.add(interaction); }); @@ -6178,17 +5470,13 @@ function renderRoot(root, isYieldy) { do { try { if (isYieldy) - for (; null !== nextUnitOfWork && !shouldYieldToRenderer(); ) + for (; null !== nextUnitOfWork && !shouldYield(); ) nextUnitOfWork = performUnitOfWork(nextUnitOfWork); else for (; null !== nextUnitOfWork; ) nextUnitOfWork = performUnitOfWork(nextUnitOfWork); } catch (thrownValue) { - if ( - ((lastContextWithAllBitsObserved = lastContextDependency = currentlyRenderingFiber = null), - resetHooks(), - null === nextUnitOfWork) - ) + if (null === nextUnitOfWork) (threadID = !0), onUncaughtError(thrownValue); else { invariant( @@ -6216,153 +5504,168 @@ function renderRoot(root, isYieldy) { 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 { - subscriber = root.current.alternate; + isYieldy = root.current.alternate; invariant( - null !== subscriber, + null !== isYieldy, "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, subscriber, expirationTime, root.expirationTime, -1); + onSuspend(root, isYieldy, expirationTime, root.expirationTime, -1); return; } - if (!root.didError && isYieldy) { + if (!root.didError && !isExpired) { root.didError = !0; - isYieldy = root.nextExpirationTimeToWorkOn = expirationTime; - threadID = root.expirationTime = 1073741823; - onSuspend(root, subscriber, isYieldy, threadID, -1); + isExpired = root.nextExpirationTimeToWorkOn = expirationTime; + subscriber = root.expirationTime = 1; + onSuspend(root, isYieldy, isExpired, subscriber, -1); return; } } - isYieldy && -1 !== nextLatestAbsoluteTimeoutMs - ? (markSuspendedPriorityLevel(root, expirationTime), - (isYieldy = + isExpired || -1 === nextLatestAbsoluteTimeoutMs + ? onComplete(root, isYieldy, expirationTime) + : (markSuspendedPriorityLevel(root, expirationTime), + (isExpired = 10 * - (1073741822 - - findEarliestOutstandingPriorityLevel(root, expirationTime))), - isYieldy < nextLatestAbsoluteTimeoutMs && - (nextLatestAbsoluteTimeoutMs = isYieldy), - (isYieldy = 10 * (1073741822 - requestCurrentTime())), - (isYieldy = nextLatestAbsoluteTimeoutMs - isYieldy), + (findEarliestOutstandingPriorityLevel(root, expirationTime) - 2)), + isExpired < nextLatestAbsoluteTimeoutMs && + (nextLatestAbsoluteTimeoutMs = isExpired), + (isExpired = 10 * (requestCurrentTime() - 2)), + (isExpired = nextLatestAbsoluteTimeoutMs - isExpired), onSuspend( root, - subscriber, + isYieldy, expirationTime, root.expirationTime, - 0 > isYieldy ? 0 : isYieldy - )) - : onComplete(root, subscriber, expirationTime); + 0 > isExpired ? 0 : isExpired + )); } } -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; +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; } - fiber = fiber.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; } - 3 === sourceFiber.tag && - ((fiber = createCapturedValue(value, sourceFiber)), - (fiber = createRootErrorUpdate(sourceFiber, fiber, 1073741823)), - enqueueUpdate(sourceFiber, fiber), - scheduleWork(sourceFiber, 1073741823)); + return JSCompiler_inline_result; } function computeExpirationForFiber(currentTime, fiber) { isWorking - ? (currentTime = isCommitting$1 ? 1073741823 : nextRenderExpirationTime) + ? (currentTime = isCommitting$1 ? 1 : nextRenderExpirationTime) : fiber.mode & 1 ? ((currentTime = isBatchingInteractiveUpdates - ? 1073741822 - 10 * ((((1073741822 - currentTime + 15) / 10) | 0) + 1) - : 1073741822 - - 25 * ((((1073741822 - currentTime + 500) / 25) | 0) + 1)), + ? 2 + 10 * ((((currentTime - 2 + 15) / 10) | 0) + 1) + : 2 + 25 * ((((currentTime - 2 + 500) / 25) | 0) + 1)), null !== nextRoot && currentTime === nextRenderExpirationTime && - --currentTime) - : (currentTime = 1073741823); + (currentTime += 1)) + : (currentTime = 1); isBatchingInteractiveUpdates && - (0 === lowestPriorityPendingInteractiveExpirationTime || - currentTime < lowestPriorityPendingInteractiveExpirationTime) && + currentTime > lowestPriorityPendingInteractiveExpirationTime && (lowestPriorityPendingInteractiveExpirationTime = currentTime); return currentTime; } -function retrySuspendedRoot(root, boundaryFiber, sourceFiber, suspendedTime) { +function retrySuspendedRoot(root, fiber, 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, boundaryFiber)), + (retryTime = computeExpirationForFiber(retryTime, fiber)), markPendingPriorityLevel(root, retryTime); - 0 !== (boundaryFiber.mode & 1) && + 0 !== (fiber.mode & 1) && root === nextRoot && nextRenderExpirationTime === suspendedTime && (nextRoot = null); - 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); + scheduleWorkToRoot(fiber, retryTime); + fiber = root.expirationTime; + 0 !== fiber && requestWork(root, fiber); } function scheduleWorkToRoot(fiber, expirationTime) { - fiber.expirationTime < expirationTime && - (fiber.expirationTime = expirationTime); + if (0 === fiber.expirationTime || fiber.expirationTime > expirationTime) + fiber.expirationTime = expirationTime; var alternate = fiber.alternate; null !== alternate && - alternate.expirationTime < expirationTime && + (0 === alternate.expirationTime || + alternate.expirationTime > expirationTime) && (alternate.expirationTime = expirationTime); var node = fiber.return, root = null; - if (null === node && 3 === fiber.tag) root = fiber.stateNode; + if (null === node && 5 === fiber.tag) root = fiber.stateNode; else for (; null !== node; ) { alternate = node.alternate; - node.childExpirationTime < expirationTime && - (node.childExpirationTime = expirationTime); + if ( + 0 === node.childExpirationTime || + node.childExpirationTime > expirationTime + ) + node.childExpirationTime = expirationTime; null !== alternate && - alternate.childExpirationTime < expirationTime && + (0 === alternate.childExpirationTime || + alternate.childExpirationTime > expirationTime) && (alternate.childExpirationTime = expirationTime); - if (null === node.return && 3 === node.tag) { + if (null === node.return && 5 === node.tag) { root = node.stateNode; break; } @@ -6396,7 +5699,7 @@ function scheduleWork(fiber, expirationTime) { null !== fiber && (!isWorking && 0 !== nextRenderExpirationTime && - expirationTime > nextRenderExpirationTime && + expirationTime < nextRenderExpirationTime && resetStack(), markPendingPriorityLevel(fiber, expirationTime), (isWorking && !isCommitting$1 && nextRoot === fiber) || @@ -6416,25 +5719,27 @@ 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 = 1073741822 - ((originalStartTimeMs / 10) | 0), + currentRendererTime = ((originalStartTimeMs / 10) | 0) + 2, currentSchedulerTime = currentRendererTime, NESTED_UPDATE_LIMIT = 50, nestedUpdateCount = 0, - lastCommittedRootDuringThisBatch = null; + lastCommittedRootDuringThisBatch = null, + timeHeuristicForUnitOfWork = 1; function recomputeCurrentRendererTime() { - currentRendererTime = - 1073741822 - (((now$1() - originalStartTimeMs) / 10) | 0); + currentRendererTime = (((now$1() - originalStartTimeMs) / 10) | 0) + 2; } function scheduleCallbackWithExpirationTime(root, expirationTime) { if (0 !== callbackExpirationTime) { - if (expirationTime < callbackExpirationTime) return; + if (expirationTime > callbackExpirationTime) return; null !== callbackID && ((root = callbackID), (scheduledCallback = null), clearTimeout(root)); } @@ -6455,7 +5760,7 @@ function onSuspend( msUntilTimeout ) { root.expirationTime = rootExpirationTime; - 0 !== msUntilTimeout || shouldYieldToRenderer() + 0 !== msUntilTimeout || shouldYield() ? 0 < msUntilTimeout && (root.timeoutHandle = scheduleTimeout( onTimeout.bind(null, root, finishedWork, suspendedExpirationTime), @@ -6475,8 +5780,8 @@ function onTimeout(root, finishedWork, suspendedExpirationTime) { ); nextFlushedRoot = root; nextFlushedExpirationTime = suspendedExpirationTime; - performWorkOnRoot(root, suspendedExpirationTime, !1); - performWork(1073741823, !1); + performWorkOnRoot(root, suspendedExpirationTime, !0); + performWork(1, null); } function onCommit(root, expirationTime) { root.expirationTime = expirationTime; @@ -6485,29 +5790,38 @@ function onCommit(root, expirationTime) { function requestCurrentTime() { if (isRendering) return currentSchedulerTime; findHighestPriorityRoot(); - if (0 === nextFlushedExpirationTime || 1 === nextFlushedExpirationTime) + if ( + 0 === nextFlushedExpirationTime || + 1073741823 === nextFlushedExpirationTime + ) recomputeCurrentRendererTime(), (currentSchedulerTime = currentRendererTime); return currentSchedulerTime; } function requestWork(root, expirationTime) { - null === root.nextScheduledRoot - ? ((root.expirationTime = expirationTime), + if (null === root.nextScheduledRoot) + (root.expirationTime = expirationTime), null === lastScheduledRoot ? ((firstScheduledRoot = lastScheduledRoot = root), (root.nextScheduledRoot = root)) : ((lastScheduledRoot = lastScheduledRoot.nextScheduledRoot = root), - (lastScheduledRoot.nextScheduledRoot = firstScheduledRoot))) - : expirationTime > root.expirationTime && - (root.expirationTime = expirationTime); + (lastScheduledRoot.nextScheduledRoot = firstScheduledRoot)); + else { + var remainingExpirationTime = root.expirationTime; + if ( + 0 === remainingExpirationTime || + expirationTime < remainingExpirationTime + ) + root.expirationTime = expirationTime; + } isRendering || (isBatchingUpdates ? isUnbatchingUpdates && ((nextFlushedRoot = root), - (nextFlushedExpirationTime = 1073741823), - performWorkOnRoot(root, 1073741823, !1)) - : 1073741823 === expirationTime - ? performWork(1073741823, !1) + (nextFlushedExpirationTime = 1), + performWorkOnRoot(root, 1, !0)) + : 1 === expirationTime + ? performWork(1, null) : scheduleCallbackWithExpirationTime(root, expirationTime)); } function findHighestPriorityRoot() { @@ -6543,11 +5857,14 @@ function findHighestPriorityRoot() { (root.nextScheduledRoot = null); root = previousScheduledRoot.nextScheduledRoot; } else { - remainingExpirationTime > highestPriorityWork && - ((highestPriorityWork = remainingExpirationTime), - (highestPriorityRoot = root)); + if ( + 0 === highestPriorityWork || + remainingExpirationTime < highestPriorityWork + ) + (highestPriorityWork = remainingExpirationTime), + (highestPriorityRoot = root); if (root === lastScheduledRoot) break; - if (1073741823 === highestPriorityWork) break; + if (1 === highestPriorityWork) break; previousScheduledRoot = root; root = root.nextScheduledRoot; } @@ -6555,44 +5872,38 @@ function findHighestPriorityRoot() { nextFlushedRoot = highestPriorityRoot; nextFlushedExpirationTime = highestPriorityWork; } -var didYield = !1; -function shouldYieldToRenderer() { - return didYield ? !0 : frameDeadline <= now$1() ? (didYield = !0) : !1; -} -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 performAsyncWork(dl) { + if (dl.didTimeout && null !== firstScheduledRoot) { + recomputeCurrentRendererTime(); + var root = firstScheduledRoot; + do { + var expirationTime = root.expirationTime; + 0 !== expirationTime && + currentRendererTime >= expirationTime && + (root.nextExpirationTimeToWorkOn = currentRendererTime); + root = root.nextScheduledRoot; + } while (root !== firstScheduledRoot); } + performWork(0, dl); } -function performWork(minExpirationTime, isYieldy) { +function performWork(minExpirationTime, dl) { + deadline = dl; findHighestPriorityRoot(); - if (isYieldy) + if (null !== deadline) for ( recomputeCurrentRendererTime(), currentSchedulerTime = currentRendererTime; null !== nextFlushedRoot && 0 !== nextFlushedExpirationTime && - minExpirationTime <= nextFlushedExpirationTime && - !(didYield && currentRendererTime > nextFlushedExpirationTime); + (0 === minExpirationTime || + minExpirationTime >= nextFlushedExpirationTime) && + (!deadlineDidExpire || currentRendererTime >= nextFlushedExpirationTime); ) performWorkOnRoot( nextFlushedRoot, nextFlushedExpirationTime, - currentRendererTime > nextFlushedExpirationTime + currentRendererTime >= nextFlushedExpirationTime ), findHighestPriorityRoot(), recomputeCurrentRendererTime(), @@ -6602,28 +5913,29 @@ function performWork(minExpirationTime, isYieldy) { ; null !== nextFlushedRoot && 0 !== nextFlushedExpirationTime && - minExpirationTime <= nextFlushedExpirationTime; + (0 === minExpirationTime || + minExpirationTime >= nextFlushedExpirationTime); ) - performWorkOnRoot(nextFlushedRoot, nextFlushedExpirationTime, !1), + performWorkOnRoot(nextFlushedRoot, nextFlushedExpirationTime, !0), findHighestPriorityRoot(); - isYieldy && ((callbackExpirationTime = 0), (callbackID = null)); + null !== deadline && ((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, - isYieldy = 0; - isYieldy < minExpirationTime.length; - isYieldy++ + minExpirationTime = completedBatches, completedBatches = null, dl = 0; + dl < minExpirationTime.length; + dl++ ) { - var batch = minExpirationTime[isYieldy]; + var batch = minExpirationTime[dl]; try { batch._onComplete(); } catch (error) { @@ -6637,45 +5949,45 @@ function performWork(minExpirationTime, isYieldy) { (hasUnhandledError = !1), minExpirationTime); } -function performWorkOnRoot(root, expirationTime, isYieldy) { +function performWorkOnRoot(root, expirationTime, isExpired) { invariant( !isRendering, "performWorkOnRoot was called recursively. This error is likely caused by a bug in React. Please file an issue." ); isRendering = !0; - if (isYieldy) { - var _finishedWork = root.finishedWork; - null !== _finishedWork - ? completeRoot$1(root, _finishedWork, expirationTime) + if (null === deadline || isExpired) { + 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, isYieldy), - (_finishedWork = root.finishedWork), - null !== _finishedWork && - (shouldYieldToRenderer() - ? (root.finishedWork = _finishedWork) - : completeRoot$1(root, _finishedWork, expirationTime))); + (finishedWork = root.timeoutHandle), + -1 !== finishedWork && + ((root.timeoutHandle = -1), cancelTimeout(finishedWork)), + renderRoot(root, !1, isExpired), + (finishedWork = root.finishedWork), + null !== 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, isYieldy), - (_finishedWork = root.finishedWork), - null !== _finishedWork && - completeRoot$1(root, _finishedWork, expirationTime)); + (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))); 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), @@ -6691,6 +6003,13 @@ 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, @@ -6699,6 +6018,55 @@ 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 && @@ -6717,48 +6085,7 @@ function updateContainer(element, container, parentComponent, callback) { currentTime = requestCurrentTime(); current$$1 = computeExpirationForFiber(currentTime, current$$1); currentTime = container.current; - 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; + parentComponent = getContextForSubtree(parentComponent); null === container.context ? (container.context = parentComponent) : (container.pendingContext = parentComponent); @@ -6767,7 +6094,6 @@ 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; @@ -6827,13 +6153,13 @@ _batchedUpdatesImpl = function(fn, a) { } finally { (isBatchingUpdates = previousIsBatchingUpdates) || isRendering || - performWork(1073741823, !1); + performWork(1, null); } }; _flushInteractiveUpdatesImpl = function() { isRendering || 0 === lowestPriorityPendingInteractiveExpirationTime || - (performWork(lowestPriorityPendingInteractiveExpirationTime, !1), + (performWork(lowestPriorityPendingInteractiveExpirationTime, null), (lowestPriorityPendingInteractiveExpirationTime = 0)); }; var roots = new Map(), @@ -6915,7 +6241,7 @@ var roots = new Map(), if (!root) { root = 0; isDevToolsPresent && (root |= 4); - root = createFiber(3, null, null, root); + root = new FiberNode(5, null, null, root); var root$jscomp$0 = { current: root, containerInfo: containerTag, @@ -6946,7 +6272,7 @@ var roots = new Map(), updateContainer(element, root, null, callback); a: if (((element = root.current), element.child)) switch (element.child.tag) { - case 5: + case 7: element = element.child.stateNode.canonical; break a; default: @@ -7043,7 +6369,7 @@ var roots = new Map(), findFiberByHostInstance: getInstanceFromInstance, getInspectorDataForViewTag: getInspectorDataForViewTag, bundleType: 0, - version: "16.6.0", + version: "16.6.0-alpha.8af6728", 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 9c112c83dcd..e77e96de3e2 100644 --- a/Libraries/Renderer/oss/ReactNativeRenderer-dev.js +++ b/Libraries/Renderer/oss/ReactNativeRenderer-dev.js @@ -27,7 +27,6 @@ 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"); /** @@ -1134,23 +1133,24 @@ function runExtractedEventsInBatch( } var FunctionComponent = 0; -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; +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; function getParent(inst) { do { @@ -2923,7 +2923,6 @@ 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; @@ -2931,8 +2930,7 @@ var REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for("react.forward_ref") : 0xead0; var REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for("react.suspense") : 0xead1; -var REACT_MEMO_TYPE = hasSymbol ? Symbol.for("react.memo") : 0xead3; -var REACT_LAZY_TYPE = hasSymbol ? Symbol.for("react.lazy") : 0xead4; +var REACT_PURE_TYPE = hasSymbol ? Symbol.for("react.pure") : 0xead3; var MAYBE_ITERATOR_SYMBOL = typeof Symbol === "function" && Symbol.iterator; var FAUX_ITERATOR_SYMBOL = "@@iterator"; @@ -2954,8 +2952,12 @@ var Pending = 0; var Resolved = 1; var Rejected = 2; -function refineResolvedLazyComponent(lazyComponent) { - return lazyComponent._status === Resolved ? lazyComponent._result : null; +function getResultFromResolvedThenable(thenable) { + return thenable._reactResult; +} + +function refineResolvedThenable(thenable) { + return thenable._reactStatus === Resolved ? thenable._reactResult : null; } function getWrappedName(outerType, innerType, wrapperName) { @@ -3008,14 +3010,14 @@ function getComponentName(type) { return "Context.Provider"; case REACT_FORWARD_REF_TYPE: return getWrappedName(type, type.render, "ForwardRef"); - case REACT_MEMO_TYPE: - return getComponentName(type.type); - case REACT_LAZY_TYPE: { - var thenable = type; - var resolvedThenable = refineResolvedLazyComponent(thenable); - if (resolvedThenable) { - return getComponentName(resolvedThenable); - } + 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); } } } @@ -3036,16 +3038,15 @@ var Callback = /* */ 32; var DidCapture = /* */ 64; var Ref = /* */ 128; var Snapshot = /* */ 256; -var Passive = /* */ 512; -// Passive & Update & Callback & Ref & Snapshot -var LifecycleEffectMask = /* */ 932; +// Update & Callback & Ref & Snapshot +var LifecycleEffectMask = /* */ 420; // Union of all host effects -var HostEffectMask = /* */ 1023; +var HostEffectMask = /* */ 511; -var Incomplete = /* */ 1024; -var ShouldCapture = /* */ 2048; +var Incomplete = /* */ 512; +var ShouldCapture = /* */ 1024; var ReactCurrentOwner$1 = ReactSharedInternals.ReactCurrentOwner; @@ -3089,7 +3090,10 @@ function isFiberMounted(fiber) { function isMounted(component) { { var owner = ReactCurrentOwner$1.current; - if (owner !== null && owner.tag === ClassComponent) { + if ( + owner !== null && + (owner.tag === ClassComponent || owner.tag === ClassComponentLazy) + ) { var ownerFiber = owner; var instance = ownerFiber.stateNode; !instance._warnedAboutRefsInRender @@ -3884,6 +3888,13 @@ 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. @@ -3894,7 +3905,7 @@ function setTimeoutCallback() { var callback = scheduledCallback; scheduledCallback = null; if (callback !== null) { - callback(); + callback(frameDeadlineObject); } } @@ -3913,10 +3924,6 @@ 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. @@ -3936,9 +3943,6 @@ 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. @@ -4147,7 +4151,6 @@ 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; @@ -4325,22 +4328,6 @@ 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) { @@ -4374,12 +4361,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); @@ -4455,7 +4442,6 @@ function setCurrentPhase(lifeCyclePhase) { var debugRenderPhaseSideEffects = false; var debugRenderPhaseSideEffectsForStrictMode = false; - var enableUserTimingAPI = true; var replayFailedUnitOfWorkWithInvokeGuardedCallback = true; var warnAboutDeprecatedLifecycles = false; @@ -5228,7 +5214,8 @@ function findCurrentUnmaskedContext(fiber) { // Currently this is only used with renderSubtreeIntoContainer; not sure if it // makes sense elsewhere invariant( - isFiberMounted(fiber) && fiber.tag === ClassComponent, + isFiberMounted(fiber) && + (fiber.tag === ClassComponent || fiber.tag === ClassComponentLazy), "Expected subtree parent to be a mounted class component. " + "This error is likely caused by a bug in React. Please file an issue." ); @@ -5245,6 +5232,13 @@ 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); @@ -5343,20 +5337,20 @@ function onCommitUnmount(fiber) { var maxSigned31BitInt = 1073741823; var NoWork = 0; -var Never = 1; -var Sync = maxSigned31BitInt; +var Sync = 1; +var Never = maxSigned31BitInt; var UNIT_SIZE = 10; -var MAGIC_NUMBER_OFFSET = maxSigned31BitInt - 1; +var MAGIC_NUMBER_OFFSET = 2; // 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 MAGIC_NUMBER_OFFSET - ((ms / UNIT_SIZE) | 0); + return ((ms / UNIT_SIZE) | 0) + MAGIC_NUMBER_OFFSET; } function expirationTimeToMs(expirationTime) { - return (MAGIC_NUMBER_OFFSET - expirationTime) * UNIT_SIZE; + return (expirationTime - MAGIC_NUMBER_OFFSET) * UNIT_SIZE; } function ceiling(num, precision) { @@ -5365,9 +5359,9 @@ function ceiling(num, precision) { function computeExpirationBucket(currentTime, expirationInMs, bucketSizeMs) { return ( - MAGIC_NUMBER_OFFSET - + MAGIC_NUMBER_OFFSET + ceiling( - MAGIC_NUMBER_OFFSET - currentTime + expirationInMs / UNIT_SIZE, + currentTime - MAGIC_NUMBER_OFFSET + expirationInMs / UNIT_SIZE, bucketSizeMs / UNIT_SIZE ) ); @@ -5443,7 +5437,6 @@ function FiberNode(tag, pendingProps, key, mode) { // Instance this.tag = tag; this.key = key; - this.elementType = null; this.type = null; this.stateNode = null; @@ -5516,24 +5509,18 @@ function shouldConstruct(Component) { return !!(prototype && prototype.isReactComponent); } -function isSimpleFunctionComponent(type) { - return ( - typeof type === "function" && - !shouldConstruct(type) && - type.defaultProps === undefined - ); -} - -function resolveLazyComponentTag(Component) { +function resolveLazyComponentTag(fiber, Component) { if (typeof Component === "function") { - return shouldConstruct(Component) ? ClassComponent : FunctionComponent; + return shouldConstruct(Component) + ? ClassComponentLazy + : FunctionComponentLazy; } else if (Component !== undefined && Component !== null) { var $$typeof = Component.$$typeof; if ($$typeof === REACT_FORWARD_REF_TYPE) { - return ForwardRef; + return ForwardRefLazy; } - if ($$typeof === REACT_MEMO_TYPE) { - return MemoComponent; + if ($$typeof === REACT_PURE_TYPE) { + return PureComponentLazy; } } return IndeterminateComponent; @@ -5554,7 +5541,6 @@ function createWorkInProgress(current, pendingProps, expirationTime) { current.key, current.mode ); - workInProgress.elementType = current.elementType; workInProgress.type = current.type; workInProgress.stateNode = current.stateNode; @@ -5624,23 +5610,20 @@ function createHostRootFiber(isConcurrent) { return createFiber(HostRoot, null, null, mode); } -function createFiberFromTypeAndProps( - type, // React$ElementType - key, - pendingProps, - owner, - mode, - expirationTime -) { - var fiber = void 0; +function createFiberFromElement(element, mode, expirationTime) { + var owner = null; + { + owner = element._owner; + } - 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; + var fiber = void 0; + var type = element.type; + var key = element.key; + var pendingProps = element.props; + + var fiberTag = void 0; if (typeof type === "function") { - if (shouldConstruct(type)) { - fiberTag = ClassComponent; - } + fiberTag = shouldConstruct(type) ? ClassComponent : IndeterminateComponent; } else if (typeof type === "string") { fiberTag = HostComponent; } else { @@ -5653,23 +5636,18 @@ function createFiberFromTypeAndProps( key ); case REACT_CONCURRENT_MODE_TYPE: - return createFiberFromMode( - pendingProps, - mode | ConcurrentMode | StrictMode, - expirationTime, - key - ); + fiberTag = Mode; + mode |= ConcurrentMode | StrictMode; + break; case REACT_STRICT_MODE_TYPE: - return createFiberFromMode( - pendingProps, - mode | StrictMode, - expirationTime, - key - ); + fiberTag = Mode; + mode |= StrictMode; + break; case REACT_PROFILER_TYPE: return createFiberFromProfiler(pendingProps, mode, expirationTime, key); case REACT_SUSPENSE_TYPE: - return createFiberFromSuspense(pendingProps, mode, expirationTime, key); + fiberTag = SuspenseComponent; + break; default: { if (typeof type === "object" && type !== null) { switch (type.$$typeof) { @@ -5683,13 +5661,15 @@ function createFiberFromTypeAndProps( case REACT_FORWARD_REF_TYPE: fiberTag = ForwardRef; break getTag; - case REACT_MEMO_TYPE: - fiberTag = MemoComponent; - break getTag; - case REACT_LAZY_TYPE: - fiberTag = LazyComponent; - resolvedType = null; + case REACT_PURE_TYPE: + fiberTag = PureComponent; break getTag; + default: { + if (typeof type.then === "function") { + fiberTag = IndeterminateComponent; + break getTag; + } + } } } var info = ""; @@ -5723,33 +5703,14 @@ function createFiberFromTypeAndProps( } fiber = createFiber(fiberTag, pendingProps, key, mode); - fiber.elementType = type; - fiber.type = resolvedType; + fiber.type = type; 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; } @@ -5773,41 +5734,12 @@ 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; @@ -5816,8 +5748,6 @@ 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; } @@ -5850,7 +5780,6 @@ 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; @@ -6393,12 +6322,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; } @@ -6424,12 +6353,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; @@ -6451,7 +6380,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; @@ -6465,7 +6394,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); @@ -6484,10 +6413,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) ); } @@ -6496,8 +6425,8 @@ function isPriorityLevelSuspended(root, expirationTime) { var latestSuspendedTime = root.latestSuspendedTime; return ( earliestSuspendedTime !== NoWork && - expirationTime <= earliestSuspendedTime && - expirationTime >= latestSuspendedTime + expirationTime >= earliestSuspendedTime && + expirationTime <= latestSuspendedTime ); } @@ -6530,10 +6459,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; } @@ -6549,7 +6478,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); @@ -6559,7 +6488,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; } } @@ -6569,10 +6498,18 @@ function findEarliestOutstandingPriorityLevel(root, renderExpirationTime) { var earliestPendingTime = root.earliestPendingTime; var earliestSuspendedTime = root.earliestSuspendedTime; - if (earliestPendingTime > earliestExpirationTime) { + if ( + earliestExpirationTime === NoWork || + (earliestPendingTime !== NoWork && + earliestPendingTime < earliestExpirationTime) + ) { earliestExpirationTime = earliestPendingTime; } - if (earliestSuspendedTime > earliestExpirationTime) { + if ( + earliestExpirationTime === NoWork || + (earliestSuspendedTime !== NoWork && + earliestSuspendedTime < earliestExpirationTime) + ) { earliestExpirationTime = earliestSuspendedTime; } return earliestExpirationTime; @@ -6580,7 +6517,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; } @@ -6602,7 +6539,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, @@ -6611,7 +6548,11 @@ function findNextExpirationTimeToWorkOn(completedExpirationTime, root) { } var expirationTime = nextExpirationTimeToWorkOn; - if (expirationTime !== NoWork && earliestSuspendedTime > expirationTime) { + if ( + expirationTime !== NoWork && + earliestSuspendedTime !== NoWork && + earliestSuspendedTime < expirationTime + ) { // Expire using the earliest known expiration time. expirationTime = earliestSuspendedTime; } @@ -6835,7 +6776,7 @@ function enqueueUpdate(fiber, update) { { if ( - fiber.tag === ClassComponent && + (fiber.tag === ClassComponent || fiber.tag === ClassComponentLazy) && (currentlyProcessingQueue === queue1 || (queue2 !== null && currentlyProcessingQueue === queue2)) && !didWarnUpdateInsideUpdate @@ -6983,7 +6924,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 @@ -6995,7 +6936,10 @@ function processUpdateQueue( } // Since this update will remain in the list, update the remaining // expiration time. - if (newExpirationTime < updateExpirationTime) { + if ( + newExpirationTime === NoWork || + newExpirationTime > updateExpirationTime + ) { newExpirationTime = updateExpirationTime; } } else { @@ -7031,7 +6975,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 @@ -7045,7 +6989,10 @@ function processUpdateQueue( } // Since this update will remain in the list, update the remaining // expiration time. - if (newExpirationTime < _updateExpirationTime) { + if ( + newExpirationTime === NoWork || + newExpirationTime > _updateExpirationTime + ) { newExpirationTime = _updateExpirationTime; } } else { @@ -7343,7 +7290,10 @@ function propagateContextChange( ) { // Match! Schedule an update on this fiber. - if (fiber.tag === ClassComponent) { + if ( + fiber.tag === ClassComponent || + fiber.tag === ClassComponentLazy + ) { // Schedule a force update on the work-in-progress. var update = createUpdate(renderExpirationTime); update.tag = ForceUpdate; @@ -7354,13 +7304,17 @@ function propagateContextChange( enqueueUpdate(fiber, update); } - if (fiber.expirationTime < renderExpirationTime) { + if ( + fiber.expirationTime === NoWork || + fiber.expirationTime > renderExpirationTime + ) { fiber.expirationTime = renderExpirationTime; } var alternate = fiber.alternate; if ( alternate !== null && - alternate.expirationTime < renderExpirationTime + (alternate.expirationTime === NoWork || + alternate.expirationTime > renderExpirationTime) ) { alternate.expirationTime = renderExpirationTime; } @@ -7369,17 +7323,22 @@ function propagateContextChange( var node = fiber.return; while (node !== null) { alternate = node.alternate; - if (node.childExpirationTime < renderExpirationTime) { + if ( + node.childExpirationTime === NoWork || + node.childExpirationTime > renderExpirationTime + ) { node.childExpirationTime = renderExpirationTime; if ( alternate !== null && - alternate.childExpirationTime < renderExpirationTime + (alternate.childExpirationTime === NoWork || + alternate.childExpirationTime > renderExpirationTime) ) { alternate.childExpirationTime = renderExpirationTime; } } else if ( alternate !== null && - alternate.childExpirationTime < renderExpirationTime + (alternate.childExpirationTime === NoWork || + alternate.childExpirationTime > renderExpirationTime) ) { alternate.childExpirationTime = renderExpirationTime; } else { @@ -7464,7 +7423,7 @@ function readContext(context, observedBits) { if (lastContextDependency === null) { invariant( currentlyRenderingFiber !== null, - "Context can only be read while React is " + + "Context.unstable_read(): 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 @@ -7477,637 +7436,6 @@ 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); @@ -8294,13 +7622,6 @@ 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; @@ -8440,7 +7761,6 @@ var classComponentUpdater = { update.callback = callback; } - flushPassiveEffects(); enqueueUpdate(fiber, update); scheduleWork(fiber, expirationTime); }, @@ -8460,7 +7780,6 @@ var classComponentUpdater = { update.callback = callback; } - flushPassiveEffects(); enqueueUpdate(fiber, update); scheduleWork(fiber, expirationTime); }, @@ -8479,7 +7798,6 @@ var classComponentUpdater = { update.callback = callback; } - flushPassiveEffects(); enqueueUpdate(fiber, update); scheduleWork(fiber, expirationTime); } @@ -8796,7 +8114,7 @@ function constructClassInstance( if (typeof contextType === "object" && contextType !== null) { { if ( - contextType.$$typeof !== REACT_CONTEXT_TYPE && + typeof contextType.unstable_read !== "function" && !didWarnAboutInvalidateContextType.has(ctor) ) { didWarnAboutInvalidateContextType.add(ctor); @@ -8810,7 +8128,7 @@ function constructClassInstance( } } - context = readContext$1(contextType); + context = contextType.unstable_read(); } else { unmaskedContext = getUnmaskedContext(workInProgress, ctor, true); var contextTypes = ctor.contextTypes; @@ -9012,7 +8330,7 @@ function mountClassInstance( var contextType = ctor.contextType; if (typeof contextType === "object" && contextType !== null) { - instance.context = readContext$1(contextType); + instance.context = contextType.unstable_read(); } else { var unmaskedContext = getUnmaskedContext(workInProgress, ctor, true); instance.context = getMaskedContext(workInProgress, unmaskedContext); @@ -9120,7 +8438,7 @@ function resumeMountClassInstance( var contextType = ctor.contextType; var nextContext = void 0; if (typeof contextType === "object" && contextType !== null) { - nextContext = readContext$1(contextType); + nextContext = contextType.unstable_read(); } else { var nextLegacyUnmaskedContext = getUnmaskedContext( workInProgress, @@ -9266,7 +8584,7 @@ function updateClassInstance( var contextType = ctor.contextType; var nextContext = void 0; if (typeof contextType === "object" && contextType !== null) { - nextContext = readContext$1(contextType); + nextContext = contextType.unstable_read(); } else { var nextUnmaskedContext = getUnmaskedContext(workInProgress, ctor, true); nextContext = getMaskedContext(workInProgress, nextUnmaskedContext); @@ -9509,7 +8827,8 @@ function coerceRef(returnFiber, current$$1, element) { if (owner) { var ownerFiber = owner; invariant( - ownerFiber.tag === ClassComponent, + ownerFiber.tag === ClassComponent || + ownerFiber.tag === ClassComponentLazy, "Function components cannot have refs." ); inst = ownerFiber.stateNode; @@ -9729,7 +9048,7 @@ function ChildReconciler(shouldTrackSideEffects) { } function updateElement(returnFiber, current$$1, element, expirationTime) { - if (current$$1 !== null && current$$1.elementType === element.type) { + if (current$$1 !== null && current$$1.type === element.type) { // Move based on index var existing = useFiber(current$$1, element.props, expirationTime); existing.ref = coerceRef(returnFiber, current$$1, element); @@ -10467,7 +9786,7 @@ function ChildReconciler(shouldTrackSideEffects) { if ( child.tag === Fragment ? element.type === REACT_FRAGMENT_TYPE - : child.elementType === element.type + : child.type === element.type ) { deleteRemainingChildren(returnFiber, child.sibling); var existing = useFiber( @@ -10650,7 +9969,8 @@ function ChildReconciler(shouldTrackSideEffects) { // component, throw an error. If Fiber return types are disabled, // we already threw above. switch (returnFiber.tag) { - case ClassComponent: { + case ClassComponent: + case ClassComponentLazy: { { var instance = returnFiber.stateNode; if (instance.render._isMockFunction) { @@ -11033,54 +10353,45 @@ function resetHydrationState() { isHydrating = false; } -function readLazyComponentType(lazyComponent) { - var status = lazyComponent._status; - var result = lazyComponent._result; +function readLazyComponentType(thenable) { + var status = thenable._reactStatus; switch (status) { - case Resolved: { - var Component = result; + case Resolved: + var Component = thenable._reactResult; return Component; - } - case Rejected: { - var error = result; - throw error; - } - case Pending: { - var thenable = result; + case Rejected: + throw thenable._reactResult; + case Pending: throw thenable; - } default: { - 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._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 = Resolved; - lazyComponent._result = defaultExport; + thenable._reactResult = resolvedValue; } }, function(error) { - if (lazyComponent._status === Pending) { - lazyComponent._status = Rejected; - lazyComponent._result = error; + if (thenable._reactStatus === Pending) { + thenable._reactStatus = Rejected; + thenable._reactResult = error; } } ); - lazyComponent._result = _thenable; - throw _thenable; + throw thenable; } } } @@ -11167,24 +10478,85 @@ function forceUnmountCurrentAndReconcile( function updateForwardRef( current$$1, workInProgress, - Component, + type, nextProps, renderExpirationTime ) { - var render = Component.render; + 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 + ); + } + } - // 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); + + 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); + { + ReactCurrentOwner$3.current = workInProgress; + setCurrentPhase("render"); + nextChildren = render(nextProps, ref); + setCurrentPhase(null); + } // React DevTools reads this flag. workInProgress.effectTag |= PerformedWork; @@ -11194,107 +10566,10 @@ function updateForwardRef( 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( @@ -11303,6 +10578,7 @@ function updateFragment(current$$1, workInProgress, renderExpirationTime) { nextChildren, renderExpirationTime ); + memoizeProps(workInProgress, nextChildren); return workInProgress.child; } @@ -11314,6 +10590,7 @@ function updateMode(current$$1, workInProgress, renderExpirationTime) { nextChildren, renderExpirationTime ); + memoizeProps(workInProgress, nextChildren); return workInProgress.child; } @@ -11329,6 +10606,7 @@ function updateProfiler(current$$1, workInProgress, renderExpirationTime) { nextChildren, renderExpirationTime ); + memoizeProps(workInProgress, nextProps); return workInProgress.child; } @@ -11355,14 +10633,12 @@ 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; @@ -11372,6 +10648,7 @@ function updateFunctionComponent( nextChildren, renderExpirationTime ); + memoizeProps(workInProgress, nextProps); return workInProgress.child; } @@ -11394,41 +10671,32 @@ function updateClassComponent( } prepareToReadContext(workInProgress, renderExpirationTime); - var instance = workInProgress.stateNode; var shouldUpdate = void 0; - 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; + 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 + ); } - // 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, @@ -11530,9 +10798,10 @@ function finishClassComponent( ); } - // Memoize state using the values we just used to render. + // Memoize props and state using the values we just used to render. // TODO: Restructure so we never read values from the instance. - workInProgress.memoizedState = instance.state; + memoizeState(workInProgress, instance.state); + memoizeProps(workInProgress, instance.props); // The context might have changed so we need to recalculate it. if (hasContext) { @@ -11666,6 +10935,7 @@ 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; } @@ -11675,6 +10945,7 @@ function updateHostComponent(current$$1, workInProgress, renderExpirationTime) { nextChildren, renderExpirationTime ); + memoizeProps(workInProgress, nextProps); return workInProgress.child; } @@ -11682,6 +10953,8 @@ 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; @@ -11702,173 +10975,98 @@ function resolveDefaultProps(Component, baseProps) { return baseProps; } -function mountLazyComponent( - _current, +function mountIndeterminateComponent( + current$$1, workInProgress, - elementType, + Component, updateExpirationTime, renderExpirationTime ) { - 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; - } + 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; - // 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; + 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 + ); + } } - 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; + workInProgress.memoizedProps = props; + return child; } - // 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; @@ -11910,9 +11108,6 @@ 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. @@ -11940,7 +11135,7 @@ function mountIndeterminateComponent( adoptClassInstance(workInProgress, value); mountClassInstance(workInProgress, Component, props, renderExpirationTime); return finishClassComponent( - null, + current$$1, workInProgress, Component, true, @@ -11950,7 +11145,6 @@ 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 @@ -12013,7 +11207,8 @@ function mountIndeterminateComponent( } } } - reconcileChildren(null, workInProgress, value, renderExpirationTime); + reconcileChildren(current$$1, workInProgress, value, renderExpirationTime); + memoizeProps(workInProgress, props); return workInProgress.child; } } @@ -12023,207 +11218,67 @@ function updateSuspenseComponent( workInProgress, renderExpirationTime ) { - var mode = workInProgress.mode; var nextProps = workInProgress.pendingProps; - // 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. + // 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; } else { - 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 { - // 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; - } - } + nextDidTimeout = !alreadyCaptured; } - 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 ((workInProgress.mode & StrictMode) !== NoEffect) { 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; + // If the timed-out view commits, schedule an update effect to record + // the committed time. + workInProgress.effectTag |= Update; } 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 - ); - } + // 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; } } - workInProgress.memoizedState = nextState; - workInProgress.child = child; - return next; + // 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; } function updatePortalComponent( @@ -12245,6 +11300,7 @@ function updatePortalComponent( nextChildren, renderExpirationTime ); + memoizeProps(workInProgress, nextChildren); } else { reconcileChildren( current$$1, @@ -12252,6 +11308,7 @@ function updatePortalComponent( nextChildren, renderExpirationTime ); + memoizeProps(workInProgress, nextChildren); } return workInProgress.child; } @@ -12268,6 +11325,7 @@ function updateContextProvider( var oldProps = workInProgress.memoizedProps; var newValue = newProps.value; + workInProgress.memoizedProps = newProps; { var providerPropTypes = workInProgress.type.propTypes; @@ -12336,18 +11394,13 @@ function updateContextConsumer( // in DEV mode if this property exists or not and warn if it does not. { if (context._context === undefined) { - // 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?" - ); - } + 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; @@ -12386,6 +11439,7 @@ function updateContextConsumer( newChildren, renderExpirationTime ); + workInProgress.memoizedProps = newProps; return workInProgress.child; } @@ -12427,7 +11481,10 @@ function bailoutOnAlreadyFinishedWork( // Check if the children have any pending work. var childExpirationTime = workInProgress.childExpirationTime; - if (childExpirationTime < renderExpirationTime) { + if ( + childExpirationTime === NoWork || + 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. @@ -12440,6 +11497,17 @@ 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; @@ -12449,7 +11517,8 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { if ( oldProps === newProps && !hasContextChanged() && - updateExpirationTime < renderExpirationTime + (updateExpirationTime === NoWork || + 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 @@ -12469,6 +11538,14 @@ 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, @@ -12485,46 +11562,6 @@ 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, @@ -12539,54 +11576,65 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { switch (workInProgress.tag) { case IndeterminateComponent: { - var elementType = workInProgress.elementType; + var _Component2 = workInProgress.type; return mountIndeterminateComponent( current$$1, workInProgress, - elementType, - renderExpirationTime - ); - } - case LazyComponent: { - var _elementType = workInProgress.elementType; - return mountLazyComponent( - current$$1, - workInProgress, - _elementType, + _Component2, updateExpirationTime, renderExpirationTime ); } case FunctionComponent: { - var _Component = workInProgress.type; + var _Component3 = workInProgress.type; var unresolvedProps = workInProgress.pendingProps; - var resolvedProps = - workInProgress.elementType === _Component - ? unresolvedProps - : resolveDefaultProps(_Component, unresolvedProps); return updateFunctionComponent( current$$1, workInProgress, - _Component, - resolvedProps, + _Component3, + unresolvedProps, renderExpirationTime ); } - case ClassComponent: { - var _Component2 = workInProgress.type; + case FunctionComponentLazy: { + var _thenable = workInProgress.type; + var _Component4 = getResultFromResolvedThenable(_thenable); var _unresolvedProps = workInProgress.pendingProps; - var _resolvedProps = - workInProgress.elementType === _Component2 - ? _unresolvedProps - : resolveDefaultProps(_Component2, _unresolvedProps); + 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; return updateClassComponent( current$$1, workInProgress, - _Component2, - _resolvedProps, + _Component5, + _unresolvedProps2, 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: @@ -12611,19 +11659,28 @@ 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, - _resolvedProps2, + workInProgress.pendingProps, 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: @@ -12642,43 +11699,31 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { workInProgress, renderExpirationTime ); - case MemoComponent: { + case PureComponent: { var _type = workInProgress.type; - var _unresolvedProps3 = workInProgress.pendingProps; - var _resolvedProps3 = resolveDefaultProps(_type.type, _unresolvedProps3); - return updateMemoComponent( + return updatePureComponent( current$$1, workInProgress, _type, - _resolvedProps3, - updateExpirationTime, - renderExpirationTime - ); - } - case SimpleMemoComponent: { - return updateSimpleMemoComponent( - current$$1, - workInProgress, - workInProgress.type, workInProgress.pendingProps, updateExpirationTime, renderExpirationTime ); } - case IncompleteClassComponent: { - var _Component3 = workInProgress.type; - var _unresolvedProps4 = workInProgress.pendingProps; - var _resolvedProps4 = - workInProgress.elementType === _Component3 - ? _unresolvedProps4 - : resolveDefaultProps(_Component3, _unresolvedProps4); - return mountIncompleteClassComponent( + case PureComponentLazy: { + var _thenable4 = workInProgress.type; + var _Component8 = getResultFromResolvedThenable(_thenable4); + var _unresolvedProps5 = workInProgress.pendingProps; + var _child3 = updatePureComponent( current$$1, workInProgress, - _Component3, - _resolvedProps4, + _Component8, + resolveDefaultProps(_Component8, _unresolvedProps5), + updateExpirationTime, renderExpirationTime ); + workInProgress.memoizedProps = _unresolvedProps5; + return _child3; } default: invariant( @@ -12699,48 +11744,42 @@ function markRef$1(workInProgress) { workInProgress.effectTag |= Ref; } -var appendAllChildren = void 0; +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 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 }; @@ -12794,202 +11833,26 @@ if (supportsMutation) { } else if (supportsPersistence) { // Persistent host tree 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) { - // 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 + 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) { - // 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); + if (node.tag === HostComponent || node.tag === HostText) { + appendChildToContainerChildSet(containerChildSet, 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.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; } @@ -13012,7 +11875,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, false, false); + appendAllChildrenToContainer(newChildSet, workInProgress); portalOrRoot.pendingChildren = newChildSet; // Schedule an update on the container to swap out the container. markUpdate(workInProgress); @@ -13085,7 +11948,7 @@ if (supportsMutation) { markUpdate(workInProgress); } else { // If children might have changed, we have to add them all to the set. - appendAllChildren(newInstance, workInProgress, false, false); + appendAllChildren(newInstance, workInProgress); } }; updateHostText$1 = function(current, workInProgress, oldText, newText) { @@ -13127,12 +11990,8 @@ 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; @@ -13141,6 +12000,13 @@ 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); @@ -13216,7 +12082,7 @@ function completeWork(current, workInProgress, renderExpirationTime) { workInProgress ); - appendAllChildren(instance, workInProgress, false, false); + appendAllChildren(instance, workInProgress); // Certain renderers require commit-time effects for initial mount. // (eg DOM renderer supports auto-focus for certain elements). @@ -13277,19 +12143,10 @@ function completeWork(current, workInProgress, renderExpirationTime) { break; } case ForwardRef: + case ForwardRefLazy: break; - 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; - } + case SuspenseComponent: break; - } case Fragment: break; case Mode: @@ -13306,17 +12163,18 @@ function completeWork(current, workInProgress, renderExpirationTime) { break; case ContextConsumer: break; - case MemoComponent: + case PureComponent: + case PureComponentLazy: break; - 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; - } + // 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 default: invariant( false, @@ -13328,17 +12186,6 @@ 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 @@ -13455,6 +12302,8 @@ function logCapturedError(capturedError) { } } +var emptyObject$1 = {}; + var didWarnAboutUndefinedSnapshotBeforeUpdate = null; { didWarnAboutUndefinedSnapshotBeforeUpdate = new Set(); @@ -13539,25 +12388,10 @@ 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 FunctionComponent: - case ForwardRef: - case SimpleMemoComponent: { - commitHookEffectList(UnmountSnapshot, NoEffect$1, finishedWork); - return; - } - case ClassComponent: { + case ClassComponent: + case ClassComponentLazy: { if (finishedWork.effectTag & Snapshot) { if (current$$1 !== null) { var prevProps = current$$1.memoizedProps; @@ -13589,7 +12423,6 @@ function commitBeforeMutationLifeCycles(current$$1, finishedWork) { case HostComponent: case HostText: case HostPortal: - case IncompleteClassComponent: // Nothing to do for these component types return; default: { @@ -13602,37 +12435,6 @@ 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, @@ -13640,13 +12442,8 @@ function commitLifeCycles( committedExpirationTime ) { switch (finishedWork.tag) { - case FunctionComponent: - case ForwardRef: - case SimpleMemoComponent: { - commitHookEffectList(UnmountLayout, MountLayout, finishedWork); - break; - } - case ClassComponent: { + case ClassComponent: + case ClassComponentLazy: { var instance = finishedWork.stateNode; if (finishedWork.effectTag & Update) { if (current$$1 === null) { @@ -13692,6 +12489,7 @@ function commitLifeCycles( _instance = getPublicInstance(finishedWork.child.stateNode); break; case ClassComponent: + case ClassComponentLazy: _instance = finishedWork.child.stateNode; break; } @@ -13755,49 +12553,22 @@ function commitLifeCycles( return; } case SuspenseComponent: { - 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(); + 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; 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 { - 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); + // 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 }; } return; } - case IncompleteClassComponent: - break; default: { invariant( false, @@ -13808,45 +12579,6 @@ 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) { @@ -13897,28 +12629,8 @@ function commitUnmount(current$$1) { onCommitUnmount(current$$1); switch (current$$1.tag) { - 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: { + case ClassComponent: + case ClassComponentLazy: { safelyDetachRef(current$$1); var instance = current$$1.stateNode; if (typeof instance.componentWillUnmount === "function") { @@ -14010,7 +12722,8 @@ function commitContainer(finishedWork) { } switch (finishedWork.tag) { - case ClassComponent: { + case ClassComponent: + case ClassComponentLazy: { return; } case HostComponent: { @@ -14284,29 +12997,13 @@ 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 FunctionComponent: - case ForwardRef: - case MemoComponent: - case SimpleMemoComponent: { - commitHookEffectList(UnmountMutation, MountMutation, finishedWork); - return; - } - case ClassComponent: { + case ClassComponent: + case ClassComponentLazy: { return; } case HostComponent: { @@ -14360,9 +13057,6 @@ function commitWork(current$$1, finishedWork) { case SuspenseComponent: { return; } - case IncompleteClassComponent: { - return; - } default: { invariant( false, @@ -14380,6 +13074,10 @@ 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. @@ -14473,17 +13171,22 @@ function throwException( var startTimeMs = -1; do { if (_workInProgress.tag === SuspenseComponent) { - 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 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 timeoutPropMs = _workInProgress.pendingProps.maxDuration; if (typeof timeoutPropMs === "number") { @@ -14503,127 +13206,129 @@ function throwException( // Schedule the nearest Suspense to re-render the timed out view. _workInProgress = returnFiber; do { - if ( - _workInProgress.tag === SuspenseComponent && - shouldCaptureSuspense(_workInProgress.alternate, _workInProgress) - ) { - // Found the nearest boundary. + if (_workInProgress.tag === SuspenseComponent) { + var didTimeout = _workInProgress.memoizedState; + if (!didTimeout) { + // 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, - 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 + // Attach a listener to the promise to "ping" the root and retry. + var onResolveOrReject = retrySuspendedRoot.bind( + null, + root, + _workInProgress, + pingTime ); - sourceFiber.effectTag &= ~Incomplete; - - // 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.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 (enableSchedulerTracing) { + onResolveOrReject = tracing.unstable_wrap(onResolveOrReject); } + thenable.then(onResolveOrReject, onResolveOrReject); - // Exit without suspending. - return; - } + // 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; - // 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, + // Unmount the source fiber's children + var nextChildren = null; + reconcileChildren( + sourceFiber.alternate, + sourceFiber, + nextChildren, renderExpirationTime ); - var earliestExpirationTimeMs = expirationTimeToMs( - earliestExpirationTime - ); - startTimeMs = earliestExpirationTimeMs - LOW_PRIORITY_EXPIRATION; + 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 || + 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; } - absoluteTimeoutMs = startTimeMs + earliestTimeoutMs; + + // 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; + return; } - - // 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. } - // 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( - (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) + "An update was suspended, but no placeholder UI was provided." ); } @@ -14648,6 +13353,7 @@ function throwException( return; } case ClassComponent: + case ClassComponentLazy: // Capture and retry var errorInfo = value; var ctor = workInProgress.type; @@ -14692,16 +13398,28 @@ function unwindWork(workInProgress, renderExpirationTime) { } return null; } + case ClassComponentLazy: { + var _Component = workInProgress.type._reactResult; + if (isContextProvider(_Component)) { + popContext(workInProgress); + } + var _effectTag = workInProgress.effectTag; + if (_effectTag & ShouldCapture) { + workInProgress.effectTag = (_effectTag & ~ShouldCapture) | DidCapture; + return workInProgress; + } + return null; + } case HostRoot: { popHostContainer(workInProgress); popTopLevelContextObject(workInProgress); - var _effectTag = workInProgress.effectTag; + var _effectTag2 = workInProgress.effectTag; invariant( - (_effectTag & DidCapture) === NoEffect, + (_effectTag2 & DidCapture) === NoEffect, "The root failed to unmount after an error. This is likely a bug in " + "React. Please file an issue." ); - workInProgress.effectTag = (_effectTag & ~ShouldCapture) | DidCapture; + workInProgress.effectTag = (_effectTag2 & ~ShouldCapture) | DidCapture; return workInProgress; } case HostComponent: { @@ -14709,36 +13427,9 @@ function unwindWork(workInProgress, renderExpirationTime) { return null; } case SuspenseComponent: { - 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. + var _effectTag3 = workInProgress.effectTag; + if (_effectTag3 & ShouldCapture) { + workInProgress.effectTag = (_effectTag3 & ~ShouldCapture) | DidCapture; return workInProgress; } return null; @@ -14763,6 +13454,14 @@ 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); @@ -14784,17 +13483,7 @@ function unwindInterruptedWork(interruptedWork) { } var Dispatcher = { - readContext: readContext, - useCallback: useCallback, - useContext: useContext, - useEffect: useEffect, - useImperativeMethods: useImperativeMethods, - useLayoutEffect: useLayoutEffect, - useMemo: useMemo, - useMutationEffect: useMutationEffect, - useReducer: useReducer, - useRef: useRef, - useState: useState + readContext: readContext }; var ReactCurrentOwner$2 = ReactSharedInternals.ReactCurrentOwner; @@ -14822,21 +13511,19 @@ if (enableSchedulerTracing) { didWarnSetStateChildContext = false; var didWarnStateUpdateForUnmountedComponent = {}; - warnAboutUpdateOnUnmounted = function(fiber, isClass) { + warnAboutUpdateOnUnmounted = function(fiber) { // 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) || "ReactComponent"; + var componentName = getComponentName(fiber.type) || "ReactClass"; if (didWarnStateUpdateForUnmountedComponent[componentName]) { return; } warningWithoutStack$1( false, - "Can't perform a React state update on an unmounted component. This " + + "Can't call setState (or forceUpdate) 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 %s.%s", - isClass - ? "the componentWillUnmount method" - : "a useEffect cleanup function", + "fix, cancel all subscriptions and asynchronous tasks in the " + + "componentWillUnmount method.%s", getStackByFiberInDevAndProd(fiber) ); didWarnStateUpdateForUnmountedComponent[componentName] = true; @@ -14888,9 +13575,6 @@ var nextRenderDidError = false; var nextEffect = null; var isCommitting$1 = false; -var rootWithPendingPassiveEffects = null; -var passiveEffectCallbackHandle = null; -var passiveEffectCallback = null; var legacyErrorBoundariesThatAlreadyFailed = null; @@ -14948,6 +13632,13 @@ if (true && replayFailedUnitOfWorkWithInvokeGuardedCallback) { } break; } + case ClassComponentLazy: { + var _Component = getResultFromResolvedThenable(failedUnitOfWork.type); + if (isContextProvider(_Component)) { + popContext(failedUnitOfWork); + } + break; + } case HostPortal: popHostContainer(failedUnitOfWork); break; @@ -15086,6 +13777,8 @@ function commitBeforeMutationLifecycles() { commitBeforeMutationLifeCycles(current$$1, nextEffect); } + // Don't cleanup effects yet; + // This will be done by commitAllLifeCycles() nextEffect = nextEffect.nextEffect; } @@ -15122,48 +13815,15 @@ function commitAllLifeCycles(finishedRoot, committedExpirationTime) { commitAttachRef(nextEffect); } - 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); + 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; } } @@ -15182,15 +13842,6 @@ 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; @@ -15216,7 +13867,9 @@ function commitRoot(root, finishedWork) { var updateExpirationTimeBeforeCommit = finishedWork.expirationTime; var childExpirationTimeBeforeCommit = finishedWork.childExpirationTime; var earliestRemainingTimeBeforeCommit = - childExpirationTimeBeforeCommit > updateExpirationTimeBeforeCommit + updateExpirationTimeBeforeCommit === NoWork || + (childExpirationTimeBeforeCommit !== NoWork && + childExpirationTimeBeforeCommit < updateExpirationTimeBeforeCommit) ? childExpirationTimeBeforeCommit : updateExpirationTimeBeforeCommit; markCommittedPriorityLevels(root, earliestRemainingTimeBeforeCommit); @@ -15358,22 +14011,6 @@ 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(); @@ -15386,7 +14023,9 @@ function commitRoot(root, finishedWork) { var updateExpirationTimeAfterCommit = finishedWork.expirationTime; var childExpirationTimeAfterCommit = finishedWork.childExpirationTime; var earliestRemainingTimeAfterCommit = - childExpirationTimeAfterCommit > updateExpirationTimeAfterCommit + updateExpirationTimeAfterCommit === NoWork || + (childExpirationTimeAfterCommit !== NoWork && + childExpirationTimeAfterCommit < updateExpirationTimeAfterCommit) ? childExpirationTimeAfterCommit : updateExpirationTimeAfterCommit; if (earliestRemainingTimeAfterCommit === NoWork) { @@ -15429,7 +14068,10 @@ 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 (scheduledExpirationTime > earliestRemainingTimeAfterCommit) { + if ( + earliestRemainingTimeAfterCommit === NoWork || + scheduledExpirationTime < earliestRemainingTimeAfterCommit + ) { pendingInteractionMap.delete(scheduledExpirationTime); scheduledInteractions.forEach(function(interaction) { @@ -15485,10 +14127,18 @@ function resetChildExpirationTime(workInProgress, renderTime) { while (child !== null) { var childUpdateExpirationTime = child.expirationTime; var childChildExpirationTime = child.childExpirationTime; - if (childUpdateExpirationTime > newChildExpirationTime) { + if ( + newChildExpirationTime === NoWork || + (childUpdateExpirationTime !== NoWork && + childUpdateExpirationTime < newChildExpirationTime) + ) { newChildExpirationTime = childUpdateExpirationTime; } - if (childChildExpirationTime > newChildExpirationTime) { + if ( + newChildExpirationTime === NoWork || + (childChildExpirationTime !== NoWork && + childChildExpirationTime < newChildExpirationTime) + ) { newChildExpirationTime = childChildExpirationTime; } if (shouldBubbleActualDurations) { @@ -15504,10 +14154,18 @@ function resetChildExpirationTime(workInProgress, renderTime) { while (_child !== null) { var _childUpdateExpirationTime = _child.expirationTime; var _childChildExpirationTime = _child.childExpirationTime; - if (_childUpdateExpirationTime > newChildExpirationTime) { + if ( + newChildExpirationTime === NoWork || + (_childUpdateExpirationTime !== NoWork && + _childUpdateExpirationTime < newChildExpirationTime) + ) { newChildExpirationTime = _childUpdateExpirationTime; } - if (_childChildExpirationTime > newChildExpirationTime) { + if ( + newChildExpirationTime === NoWork || + (_childChildExpirationTime !== NoWork && + _childChildExpirationTime < newChildExpirationTime) + ) { newChildExpirationTime = _childChildExpirationTime; } _child = _child.sibling; @@ -15721,7 +14379,6 @@ 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). @@ -15729,7 +14386,6 @@ function performUnitOfWork(workInProgress) { } } else { next = beginWork(current$$1, workInProgress, nextRenderExpirationTime); - workInProgress.memoizedProps = workInProgress.pendingProps; } { @@ -15763,22 +14419,19 @@ function workLoop(isYieldy) { nextUnitOfWork = performUnitOfWork(nextUnitOfWork); } } else { - // Flush asynchronous work until there's a higher priority event - while (nextUnitOfWork !== null && !shouldYieldToRenderer()) { + // Flush asynchronous work until the deadline runs out of time. + while (nextUnitOfWork !== null && !shouldYield()) { nextUnitOfWork = performUnitOfWork(nextUnitOfWork); } } } -function renderRoot(root, isYieldy) { +function renderRoot(root, isYieldy, isExpired) { 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; @@ -15810,7 +14463,7 @@ function renderRoot(root, isYieldy) { scheduledInteractions, scheduledExpirationTime ) { - if (scheduledExpirationTime >= expirationTime) { + if (scheduledExpirationTime <= expirationTime) { scheduledInteractions.forEach(function(interaction) { return interactions.add(interaction); }); @@ -15862,9 +14515,6 @@ function renderRoot(root, isYieldy) { try { workLoop(isYieldy); } catch (thrownValue) { - resetContextDependences(); - resetHooks(); - if (nextUnitOfWork === null) { // This is a fatal error. didFatal = true; @@ -15927,7 +14577,6 @@ function renderRoot(root, isYieldy) { isWorking = false; ReactCurrentOwner$2.currentDispatcher = null; resetContextDependences(); - resetHooks(); // Yield back to main thread. if (didFatal) { @@ -15999,7 +14648,7 @@ function renderRoot(root, isYieldy) { // similar to a suspend, but without a timeout because we're not waiting // for a promise to resolve. !root.didError && - isYieldy + !isExpired ) { root.didError = true; var _suspendedExpirationTime = (root.nextExpirationTimeToWorkOn = expirationTime); @@ -16015,7 +14664,7 @@ function renderRoot(root, isYieldy) { } } - if (isYieldy && nextLatestAbsoluteTimeoutMs !== -1) { + if (!isExpired && nextLatestAbsoluteTimeoutMs !== -1) { // The tree was suspended. var _suspendedExpirationTime2 = expirationTime; markSuspendedPriorityLevel(root, _suspendedExpirationTime2); @@ -16057,12 +14706,17 @@ function renderRoot(root, isYieldy) { onComplete(root, rootWorkInProgress, expirationTime); } -function captureCommitPhaseError(sourceFiber, value) { - var expirationTime = Sync; +function dispatch(sourceFiber, value, expirationTime) { + invariant( + !isWorking || isCommitting$1, + "dispatch: Cannot dispatch during the render phase." + ); + var fiber = sourceFiber.return; while (fiber !== null) { switch (fiber.tag) { case ClassComponent: + case ClassComponentLazy: var ctor = fiber.type; var instance = fiber.stateNode; if ( @@ -16103,6 +14757,10 @@ function captureCommitPhaseError(sourceFiber, value) { } } +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; @@ -16137,7 +14795,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 @@ -16148,10 +14806,7 @@ 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 ( - lowestPriorityPendingInteractiveExpirationTime === NoWork || - expirationTime < lowestPriorityPendingInteractiveExpirationTime - ) { + if (expirationTime > lowestPriorityPendingInteractiveExpirationTime) { lowestPriorityPendingInteractiveExpirationTime = expirationTime; } } @@ -16172,7 +14827,7 @@ function renderDidError() { nextRenderDidError = true; } -function retrySuspendedRoot(root, boundaryFiber, sourceFiber, suspendedTime) { +function retrySuspendedRoot(root, fiber, suspendedTime) { var retryTime = void 0; if (isPriorityLevelSuspended(root, suspendedTime)) { @@ -16183,18 +14838,18 @@ function retrySuspendedRoot(root, boundaryFiber, sourceFiber, suspendedTime) { } else { // Suspense already timed out. Compute a new expiration time var currentTime = requestCurrentTime(); - retryTime = computeExpirationForFiber(currentTime, boundaryFiber); + retryTime = computeExpirationForFiber(currentTime, fiber); markPendingPriorityLevel(root, retryTime); } - // TODO: If the suspense fiber has already rendered the primary children + // TODO: If the placeholder 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 ((boundaryFiber.mode & ConcurrentMode) !== NoContext) { + if ((fiber.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. @@ -16202,23 +14857,7 @@ function retrySuspendedRoot(root, boundaryFiber, sourceFiber, suspendedTime) { } } - 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); - } - } - + scheduleWorkToRoot(fiber, retryTime); var rootExpirationTime = root.expirationTime; if (rootExpirationTime !== NoWork) { requestWork(root, rootExpirationTime); @@ -16229,18 +14868,25 @@ function scheduleWorkToRoot(fiber, expirationTime) { recordScheduleUpdate(); { - if (fiber.tag === ClassComponent) { + if (fiber.tag === ClassComponent || fiber.tag === ClassComponentLazy) { var instance = fiber.stateNode; warnAboutInvalidUpdates(instance); } } // Update the source fiber's expiration time - if (fiber.expirationTime < expirationTime) { + if ( + fiber.expirationTime === NoWork || + fiber.expirationTime > expirationTime + ) { fiber.expirationTime = expirationTime; } var alternate = fiber.alternate; - if (alternate !== null && alternate.expirationTime < expirationTime) { + if ( + alternate !== null && + (alternate.expirationTime === NoWork || + alternate.expirationTime > expirationTime) + ) { alternate.expirationTime = expirationTime; } // Walk the parent path to the root and update the child expiration time. @@ -16251,17 +14897,22 @@ function scheduleWorkToRoot(fiber, expirationTime) { } else { while (node !== null) { alternate = node.alternate; - if (node.childExpirationTime < expirationTime) { + if ( + node.childExpirationTime === NoWork || + node.childExpirationTime > expirationTime + ) { node.childExpirationTime = expirationTime; if ( alternate !== null && - alternate.childExpirationTime < expirationTime + (alternate.childExpirationTime === NoWork || + alternate.childExpirationTime > expirationTime) ) { alternate.childExpirationTime = expirationTime; } } else if ( alternate !== null && - alternate.childExpirationTime < expirationTime + (alternate.childExpirationTime === NoWork || + alternate.childExpirationTime > expirationTime) ) { alternate.childExpirationTime = expirationTime; } @@ -16274,18 +14925,11 @@ function scheduleWorkToRoot(fiber, expirationTime) { } if (root === null) { - { - switch (fiber.tag) { - case ClassComponent: - warnAboutUpdateOnUnmounted(fiber, true); - break; - case FunctionComponent: - case ForwardRef: - case MemoComponent: - case SimpleMemoComponent: - warnAboutUpdateOnUnmounted(fiber, false); - break; - } + if ( + true && + (fiber.tag === ClassComponent || fiber.tag === ClassComponentLazy) + ) { + warnAboutUpdateOnUnmounted(fiber); } return null; } @@ -16336,7 +14980,7 @@ function scheduleWork(fiber, expirationTime) { if ( !isWorking && nextRenderExpirationTime !== NoWork && - expirationTime > nextRenderExpirationTime + expirationTime < nextRenderExpirationTime ) { // This is an interruption. (Used for performance tracking.) interruptedBy = fiber; @@ -16380,8 +15024,10 @@ 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; @@ -16398,6 +15044,8 @@ var NESTED_UPDATE_LIMIT = 50; var nestedUpdateCount = 0; var lastCommittedRootDuringThisBatch = null; +var timeHeuristicForUnitOfWork = 1; + function recomputeCurrentRendererTime() { var currentTimeMs = now() - originalStartTimeMs; currentRendererTime = msToExpirationTime(currentTimeMs); @@ -16406,7 +15054,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 { @@ -16449,7 +15097,7 @@ function onSuspend( msUntilTimeout ) { root.expirationTime = rootExpirationTime; - if (msUntilTimeout === 0 && !shouldYieldToRenderer()) { + if (msUntilTimeout === 0 && !shouldYield()) { // Don't wait an additional tick. Commit the tree immediately. root.pendingCommitExpirationTime = suspendedExpirationTime; root.finishedWork = finishedWork; @@ -16544,7 +15192,7 @@ function requestWork(root, expirationTime) { // flush it now. nextFlushedRoot = root; nextFlushedExpirationTime = Sync; - performWorkOnRoot(root, Sync, false); + performWorkOnRoot(root, Sync, true); } return; } @@ -16574,7 +15222,10 @@ function addRootToSchedule(root, expirationTime) { } else { // This root is already scheduled, but its priority may have increased. var remainingExpirationTime = root.expirationTime; - if (expirationTime > remainingExpirationTime) { + if ( + remainingExpirationTime === NoWork || + expirationTime < remainingExpirationTime + ) { // Update the priority. root.expirationTime = expirationTime; } @@ -16623,7 +15274,10 @@ function findHighestPriorityRoot() { } root = previousScheduledRoot.nextScheduledRoot; } else { - if (remainingExpirationTime > highestPriorityWork) { + if ( + highestPriorityWork === NoWork || + remainingExpirationTime < highestPriorityWork + ) { // Update the priority, if it's higher highestPriorityWork = remainingExpirationTime; highestPriorityRoot = root; @@ -16646,60 +15300,43 @@ function findHighestPriorityRoot() { nextFlushedExpirationTime = highestPriorityWork; } -// 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); - } +function performAsyncWork(dl) { + if (dl.didTimeout) { + // The callback timed out. That means at least one update has expired. + // Iterate through the root schedule. If they contain expired work, set + // the next render expiration time to the current time. This has the effect + // of flushing all expired work in a single batch, instead of flushing each + // level one at a time. + if (firstScheduledRoot !== null) { + recomputeCurrentRendererTime(); + var root = firstScheduledRoot; + do { + didExpireAtExpirationTime(root, currentRendererTime); + // The root schedule is circular, so this is never null. + root = root.nextScheduledRoot; + } while (root !== firstScheduledRoot); } - performWork(NoWork, true); - } finally { - didYield = false; } + performWork(NoWork, dl); } function performSyncWork() { - performWork(Sync, false); + performWork(Sync, null); } -function performWork(minExpirationTime, isYieldy) { - // Keep working on roots until there's no more work, or until there's a higher - // priority event. +function performWork(minExpirationTime, dl) { + deadline = dl; + + // Keep working on roots until there's no more work, or until we reach + // the deadline. findHighestPriorityRoot(); - if (isYieldy) { + if (deadline !== null) { recomputeCurrentRendererTime(); currentSchedulerTime = currentRendererTime; if (enableUserTimingAPI) { - var didExpire = nextFlushedExpirationTime > currentRendererTime; + var didExpire = nextFlushedExpirationTime < currentRendererTime; var timeout = expirationTimeToMs(nextFlushedExpirationTime); stopRequestCallbackTimer(didExpire, timeout); } @@ -16707,13 +15344,14 @@ function performWork(minExpirationTime, isYieldy) { while ( nextFlushedRoot !== null && nextFlushedExpirationTime !== NoWork && - minExpirationTime <= nextFlushedExpirationTime && - !(didYield && currentRendererTime > nextFlushedExpirationTime) + (minExpirationTime === NoWork || + minExpirationTime >= nextFlushedExpirationTime) && + (!deadlineDidExpire || currentRendererTime >= nextFlushedExpirationTime) ) { performWorkOnRoot( nextFlushedRoot, nextFlushedExpirationTime, - currentRendererTime > nextFlushedExpirationTime + currentRendererTime >= nextFlushedExpirationTime ); findHighestPriorityRoot(); recomputeCurrentRendererTime(); @@ -16723,9 +15361,10 @@ function performWork(minExpirationTime, isYieldy) { while ( nextFlushedRoot !== null && nextFlushedExpirationTime !== NoWork && - minExpirationTime <= nextFlushedExpirationTime + (minExpirationTime === NoWork || + minExpirationTime >= nextFlushedExpirationTime) ) { - performWorkOnRoot(nextFlushedRoot, nextFlushedExpirationTime, false); + performWorkOnRoot(nextFlushedRoot, nextFlushedExpirationTime, true); findHighestPriorityRoot(); } } @@ -16734,7 +15373,7 @@ function performWork(minExpirationTime, isYieldy) { // 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 (isYieldy) { + if (deadline !== null) { callbackExpirationTime = NoWork; callbackID = null; } @@ -16747,6 +15386,9 @@ function performWork(minExpirationTime, isYieldy) { } // Clean-up. + deadline = null; + deadlineDidExpire = false; + finishRendering(); } @@ -16761,7 +15403,7 @@ function flushRoot(root, expirationTime) { // including the given time. nextFlushedRoot = root; nextFlushedExpirationTime = expirationTime; - performWorkOnRoot(root, expirationTime, false); + performWorkOnRoot(root, expirationTime, true); // Flush any sync work that was scheduled by lifecycles performSyncWork(); } @@ -16794,7 +15436,7 @@ function finishRendering() { } } -function performWorkOnRoot(root, expirationTime, isYieldy) { +function performWorkOnRoot(root, expirationTime, isExpired) { invariant( !isRendering, "performWorkOnRoot was called recursively. This error is likely caused " + @@ -16804,7 +15446,7 @@ function performWorkOnRoot(root, expirationTime, isYieldy) { isRendering = true; // Check if this is async work or sync/expired work. - if (!isYieldy) { + if (deadline === null || isExpired) { // 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 @@ -16824,7 +15466,8 @@ function performWorkOnRoot(root, expirationTime, isYieldy) { // $FlowFixMe Complains noTimeout is not a TimeoutID, despite the check above cancelTimeout(timeoutHandle); } - renderRoot(root, isYieldy); + var isYieldy = false; + renderRoot(root, isYieldy, isExpired); finishedWork = root.finishedWork; if (finishedWork !== null) { // We've completed the root. Commit it. @@ -16847,12 +15490,13 @@ function performWorkOnRoot(root, expirationTime, isYieldy) { // $FlowFixMe Complains noTimeout is not a TimeoutID, despite the check above cancelTimeout(_timeoutHandle); } - renderRoot(root, isYieldy); + var _isYieldy = true; + renderRoot(root, _isYieldy, isExpired); _finishedWork = root.finishedWork; if (_finishedWork !== null) { - // We've completed the root. Check the if we should yield one more time + // We've completed the root. Check the deadline one more time // before committing. - if (!shouldYieldToRenderer()) { + if (!shouldYield()) { // Still time left. Commit the root. completeRoot(root, _finishedWork, expirationTime); } else { @@ -16870,7 +15514,7 @@ function performWorkOnRoot(root, expirationTime, isYieldy) { 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 { @@ -16902,6 +15546,24 @@ 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, @@ -16946,7 +15608,7 @@ function interactiveUpdates$1(fn, a, b) { lowestPriorityPendingInteractiveExpirationTime !== NoWork ) { // Synchronously flush pending interactive updates. - performWork(lowestPriorityPendingInteractiveExpirationTime, false); + performWork(lowestPriorityPendingInteractiveExpirationTime, null); lowestPriorityPendingInteractiveExpirationTime = NoWork; } var previousIsBatchingInteractiveUpdates = isBatchingInteractiveUpdates; @@ -16970,7 +15632,7 @@ function flushInteractiveUpdates$1() { lowestPriorityPendingInteractiveExpirationTime !== NoWork ) { // Synchronously flush pending interactive updates. - performWork(lowestPriorityPendingInteractiveExpirationTime, false); + performWork(lowestPriorityPendingInteractiveExpirationTime, null); lowestPriorityPendingInteractiveExpirationTime = NoWork; } } @@ -16999,6 +15661,11 @@ 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; @@ -17036,11 +15703,9 @@ function scheduleRootUpdate(current$$1, element, expirationTime, callback) { : void 0; update.callback = callback; } - - flushPassiveEffects(); enqueueUpdate(current$$1, update); - scheduleWork(current$$1, expirationTime); + scheduleWork(current$$1, expirationTime); return expirationTime; } @@ -17231,7 +15896,7 @@ function createPortal( // TODO: this is special because it gets imported during build. -var ReactVersion = "16.6.0"; +var ReactVersion = "16.6.0-alpha.8af6728"; // Modules provided by RN: var NativeMethodsMixin = function(findNodeHandle, findHostInstance) { @@ -17627,9 +16292,9 @@ var ReactNativeComponent = function(findNodeHandle, findHostInstance) { }; // Module provided by RN: -var emptyObject$1 = {}; +var emptyObject$2 = {}; { - Object.freeze(emptyObject$1); + Object.freeze(emptyObject$2); } var getInspectorDataForViewTag = void 0; @@ -17662,9 +16327,9 @@ var getInspectorDataForViewTag = void 0; var getHostProps = function(fiber) { var host = findCurrentHostFiber(fiber); if (host) { - return host.memoizedProps || emptyObject$1; + return host.memoizedProps || emptyObject$2; } - return emptyObject$1; + return emptyObject$2; }; var getHostNode = function(fiber, findNodeHandle) { @@ -17710,7 +16375,7 @@ var getInspectorDataForViewTag = void 0; if (!closestInstance) { return { hierarchy: [], - props: emptyObject$1, + props: emptyObject$2, selection: null, source: null }; diff --git a/Libraries/Renderer/oss/ReactNativeRenderer-prod.js b/Libraries/Renderer/oss/ReactNativeRenderer-prod.js index d62282e858f..3fcf1033033 100644 --- a/Libraries/Renderer/oss/ReactNativeRenderer-prod.js +++ b/Libraries/Renderer/oss/ReactNativeRenderer-prod.js @@ -19,8 +19,7 @@ var ReactNativeViewConfigRegistry = require("ReactNativeViewConfigRegistry"), deepDiffer = require("deepDiffer"), flattenStyle = require("flattenStyle"), TextInputState = require("TextInputState"); -var scheduler = require("scheduler"), - ExceptionsManager = require("ExceptionsManager"); +var ExceptionsManager = require("ExceptionsManager"); function invariant(condition, format, a, b, c, d, e, f) { if (!condition) { condition = void 0; @@ -294,7 +293,7 @@ function getListener(inst, registrationName) { } function getParent(inst) { do inst = inst.return; - while (inst && 5 !== inst.tag); + while (inst && 7 !== inst.tag); return inst ? inst : null; } function traverseTwoPhase(inst, fn, arg) { @@ -1148,8 +1147,7 @@ var ReactSharedInternals = : 60111, REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for("react.forward_ref") : 60112, REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for("react.suspense") : 60113, - REACT_MEMO_TYPE = hasSymbol ? Symbol.for("react.memo") : 60115, - REACT_LAZY_TYPE = hasSymbol ? Symbol.for("react.lazy") : 60116, + REACT_PURE_TYPE = hasSymbol ? Symbol.for("react.pure") : 60115, MAYBE_ITERATOR_SYMBOL = "function" === typeof Symbol && Symbol.iterator; function getIteratorFn(maybeIterable) { if (null === maybeIterable || "object" !== typeof maybeIterable) return null; @@ -1158,6 +1156,13 @@ 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; @@ -1176,25 +1181,23 @@ 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: - 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); + return getWrappedName(type, type.render, "ForwardRef"); + case REACT_PURE_TYPE: + return getWrappedName(type, type.render, "Pure"); } + if ( + "function" === typeof type.then && + (type = 1 === type._reactStatus ? type._reactResult : null) + ) + return getComponentName(type); + } return null; } function isFiberMountedImpl(fiber) { @@ -1205,7 +1208,7 @@ function isFiberMountedImpl(fiber) { for (; node.return; ) if (((node = node.return), 0 !== (node.effectTag & 2))) return 1; } - return 3 === node.tag ? 2 : 3; + return 5 === node.tag ? 2 : 3; } function assertIsMounted(fiber) { invariant( @@ -1281,14 +1284,14 @@ function findCurrentFiberUsingSlowPath(fiber) { "Return fibers should always be each others' alternates. This error is likely caused by a bug in React. Please file an issue." ); } - invariant(3 === a.tag, "Unable to find node on an unmounted component."); + invariant(5 === a.tag, "Unable to find node on an unmounted component."); return a.stateNode.current === a ? fiber : alternate; } function findCurrentHostFiber(parent) { parent = findCurrentFiberUsingSlowPath(parent); if (!parent) return null; for (var node = parent; ; ) { - if (5 === node.tag || 6 === node.tag) return node; + if (7 === node.tag || 8 === node.tag) return node; if (node.child) (node.child.return = node), (node = node.child); else { if (node === parent) break; @@ -1596,12 +1599,18 @@ var ReactNativeFiberHostComponent = (function() { return Date.now(); }, scheduledCallback = null, - frameDeadline = 0; + frameDeadline = 0, + frameDeadlineObject = { + timeRemaining: function() { + return frameDeadline - now$1(); + }, + didTimeout: !1 + }; function setTimeoutCallback() { frameDeadline = now$1() + 5; var callback = scheduledCallback; scheduledCallback = null; - null !== callback && callback(); + null !== callback && callback(frameDeadlineObject); } function shim$1() { invariant( @@ -1642,13 +1651,13 @@ function getStackByFiberInDevAndProd(workInProgress) { var info = ""; do { a: switch (workInProgress.tag) { - case 2: - case 16: + case 4: case 0: case 1: - case 5: - case 8: - case 13: + case 2: + case 3: + case 7: + case 10: var owner = workInProgress._debugOwner, source = workInProgress._debugSource, name = getComponentName(workInProgress.type); @@ -1799,7 +1808,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 = this.elementType = null; + this.sibling = this.child = this.return = this.stateNode = this.type = null; this.index = 0; this.ref = null; this.pendingProps = pendingProps; @@ -1810,33 +1819,29 @@ 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(Component) { +function resolveLazyComponentTag(fiber, Component) { if ("function" === typeof Component) - return shouldConstruct(Component) ? 1 : 0; + return shouldConstruct(Component) ? 3 : 1; if (void 0 !== Component && null !== Component) { - Component = Component.$$typeof; - if (Component === REACT_FORWARD_REF_TYPE) return 11; - if (Component === REACT_MEMO_TYPE) return 14; + fiber = Component.$$typeof; + if (fiber === REACT_FORWARD_REF_TYPE) return 14; + if (fiber === REACT_PURE_TYPE) return 18; } - return 2; + return 4; } function createWorkInProgress(current, pendingProps) { var workInProgress = current.alternate; null === workInProgress - ? ((workInProgress = createFiber( + ? ((workInProgress = new FiberNode( current.tag, pendingProps, current.key, current.mode )), - (workInProgress.elementType = current.elementType), (workInProgress.type = current.type), (workInProgress.stateNode = current.stateNode), (workInProgress.alternate = current), @@ -1858,66 +1863,60 @@ function createWorkInProgress(current, pendingProps) { workInProgress.ref = current.ref; return workInProgress; } -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; +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; else a: switch (type) { case REACT_FRAGMENT_TYPE: return createFiberFromFragment( - pendingProps.children, + element.children, mode, expirationTime, key ); case REACT_CONCURRENT_MODE_TYPE: - return createFiberFromMode(pendingProps, mode | 3, expirationTime, key); + fiberTag = 10; + mode |= 3; + break; case REACT_STRICT_MODE_TYPE: - return createFiberFromMode(pendingProps, mode | 2, expirationTime, key); + fiberTag = 10; + mode |= 2; + break; case REACT_PROFILER_TYPE: return ( - (type = createFiber(12, pendingProps, key, mode | 4)), - (type.elementType = REACT_PROFILER_TYPE), + (type = new FiberNode(15, element, key, mode | 4)), (type.type = REACT_PROFILER_TYPE), (type.expirationTime = expirationTime), type ); case REACT_SUSPENSE_TYPE: - return ( - (type = createFiber(13, pendingProps, key, mode)), - (type.elementType = REACT_SUSPENSE_TYPE), - (type.type = REACT_SUSPENSE_TYPE), - (type.expirationTime = expirationTime), - type - ); + fiberTag = 16; + break; default: if ("object" === typeof type && null !== type) switch (type.$$typeof) { case REACT_PROVIDER_TYPE: - fiberTag = 10; + fiberTag = 12; break a; case REACT_CONTEXT_TYPE: - fiberTag = 9; - break a; - case REACT_FORWARD_REF_TYPE: fiberTag = 11; break a; - case REACT_MEMO_TYPE: - fiberTag = 14; + case REACT_FORWARD_REF_TYPE: + fiberTag = 13; break a; - case REACT_LAZY_TYPE: - fiberTag = 16; - owner = null; + case REACT_PURE_TYPE: + fiberTag = 17; break a; + default: + if ("function" === typeof type.then) { + fiberTag = 4; + break a; + } } invariant( !1, @@ -1926,33 +1925,24 @@ function createFiberFromTypeAndProps( "" ); } - key = createFiber(fiberTag, pendingProps, key, mode); - key.elementType = type; - key.type = owner; - key.expirationTime = expirationTime; - return key; + mode = new FiberNode(fiberTag, element, key, mode); + mode.type = type; + mode.expirationTime = expirationTime; + return mode; } function createFiberFromFragment(elements, mode, expirationTime, key) { - elements = createFiber(7, elements, key, mode); + elements = new FiberNode(9, 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 = createFiber(6, content, null, mode); + content = new FiberNode(8, content, null, mode); content.expirationTime = expirationTime; return content; } function createFiberFromPortal(portal, mode, expirationTime) { - mode = createFiber( - 4, + mode = new FiberNode( + 6, null !== portal.children ? portal.children : [], portal.key, mode @@ -1970,9 +1960,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); } @@ -1980,7 +1970,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; @@ -1995,18 +1985,22 @@ 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; - earliestPendingTime > renderExpirationTime && - (renderExpirationTime = earliestPendingTime); - root > renderExpirationTime && (renderExpirationTime = root); + if ( + 0 === renderExpirationTime || + (0 !== earliestPendingTime && earliestPendingTime < renderExpirationTime) + ) + renderExpirationTime = earliestPendingTime; + if (0 === renderExpirationTime || (0 !== root && root < renderExpirationTime)) + renderExpirationTime = root; return renderExpirationTime; } function findNextExpirationTimeToWorkOn(completedExpirationTime, root) { @@ -2018,11 +2012,12 @@ function findNextExpirationTimeToWorkOn(completedExpirationTime, root) { 0 !== earliestPendingTime ? earliestPendingTime : latestPingedTime; 0 === earliestPendingTime && (0 === completedExpirationTime || - latestSuspendedTime < completedExpirationTime) && + latestSuspendedTime > completedExpirationTime) && (earliestPendingTime = latestSuspendedTime); completedExpirationTime = earliestPendingTime; 0 !== completedExpirationTime && - earliestSuspendedTime > completedExpirationTime && + 0 !== earliestSuspendedTime && + earliestSuspendedTime < completedExpirationTime && (completedExpirationTime = earliestSuspendedTime); root.nextExpirationTimeToWorkOn = earliestPendingTime; root.expirationTime = completedExpirationTime; @@ -2134,7 +2129,7 @@ function getStateFromUpdate( : workInProgress ); case 3: - workInProgress.effectTag = (workInProgress.effectTag & -2049) | 64; + workInProgress.effectTag = (workInProgress.effectTag & -1025) | 64; case 0: workInProgress = update.payload; nextProps = @@ -2167,52 +2162,58 @@ function processUpdateQueue( ) { var updateExpirationTime = update.expirationTime; - updateExpirationTime < renderExpirationTime - ? (null === newFirstUpdate && + if (updateExpirationTime > renderExpirationTime) { + if ( + (null === newFirstUpdate && ((newFirstUpdate = update), (newBaseState = resultState)), - newExpirationTime < updateExpirationTime && - (newExpirationTime = updateExpirationTime)) - : ((resultState = getStateFromUpdate( - workInProgress, - queue, - update, - resultState, - props, - instance - )), + 0 === newExpirationTime || newExpirationTime > updateExpirationTime) + ) + newExpirationTime = updateExpirationTime; + } else + (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; - _updateExpirationTime < renderExpirationTime - ? (null === updateExpirationTime && + if (_updateExpirationTime > renderExpirationTime) { + if ( + (null === updateExpirationTime && ((updateExpirationTime = update), null === newFirstUpdate && (newBaseState = resultState)), - newExpirationTime < _updateExpirationTime && - (newExpirationTime = _updateExpirationTime)) - : ((resultState = getStateFromUpdate( - workInProgress, - queue, - update, - resultState, - props, - instance - )), + 0 === newExpirationTime || newExpirationTime > _updateExpirationTime) + ) + newExpirationTime = _updateExpirationTime; + } else + (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); @@ -2293,277 +2294,13 @@ function readContext(context, observedBits) { null === lastContextDependency ? (invariant( null !== currentlyRenderingFiber, - "Context can only be read while React is rendering, e.g. inside the render method or getDerivedStateFromProps." + "Context.unstable_read(): 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 }, @@ -2633,8 +2370,7 @@ function shallowEqual(objA, objB) { return !1; return !0; } -var ReactCurrentOwner$4 = ReactSharedInternals.ReactCurrentOwner, - emptyRefsObject = new React.Component().refs; +var emptyRefsObject = new React.Component().refs; function applyDerivedStateFromProps( workInProgress, ctor, @@ -2666,7 +2402,6 @@ var classComponentUpdater = { var update = createUpdate(currentTime); update.payload = payload; void 0 !== callback && null !== callback && (update.callback = callback); - flushPassiveEffects(); enqueueUpdate(inst, update); scheduleWork(inst, currentTime); }, @@ -2678,7 +2413,6 @@ var classComponentUpdater = { update.tag = 1; update.payload = payload; void 0 !== callback && null !== callback && (update.callback = callback); - flushPassiveEffects(); enqueueUpdate(inst, update); scheduleWork(inst, currentTime); }, @@ -2689,7 +2423,6 @@ var classComponentUpdater = { var update = createUpdate(currentTime); update.tag = 2; void 0 !== callback && null !== callback && (update.callback = callback); - flushPassiveEffects(); enqueueUpdate(inst, update); scheduleWork(inst, currentTime); } @@ -2710,32 +2443,6 @@ 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, @@ -2762,9 +2469,7 @@ function mountClassInstance( instance.refs = emptyRefsObject; var contextType = ctor.contextType; "object" === typeof contextType && null !== contextType - ? (instance.context = ReactCurrentOwner$4.currentDispatcher.readContext( - contextType - )) + ? (instance.context = contextType.unstable_read()) : ((contextType = isContextProvider(ctor) ? previousContext : contextStackCursor.current), @@ -2819,7 +2524,10 @@ function coerceRef(returnFiber, current$$1, element) { element = element._owner; var inst = void 0; element && - (invariant(1 === element.tag, "Function components cannot have refs."), + (invariant( + 2 === element.tag || 3 === element.tag, + "Function components cannot have refs." + ), (inst = element.stateNode)); invariant( inst, @@ -2924,7 +2632,7 @@ function ChildReconciler(shouldTrackSideEffects) { textContent, expirationTime ) { - if (null === current$$1 || 6 !== current$$1.tag) + if (null === current$$1 || 8 !== current$$1.tag) return ( (current$$1 = createFiberFromText( textContent, @@ -2939,18 +2647,15 @@ function ChildReconciler(shouldTrackSideEffects) { return current$$1; } function updateElement(returnFiber, current$$1, element, expirationTime) { - if (null !== current$$1 && current$$1.elementType === element.type) + if (null !== current$$1 && current$$1.type === element.type) return ( (expirationTime = useFiber(current$$1, element.props, expirationTime)), (expirationTime.ref = coerceRef(returnFiber, current$$1, element)), (expirationTime.return = returnFiber), expirationTime ); - expirationTime = createFiberFromTypeAndProps( - element.type, - element.key, - element.props, - null, + expirationTime = createFiberFromElement( + element, returnFiber.mode, expirationTime ); @@ -2961,7 +2666,7 @@ function ChildReconciler(shouldTrackSideEffects) { function updatePortal(returnFiber, current$$1, portal, expirationTime) { if ( null === current$$1 || - 4 !== current$$1.tag || + 6 !== current$$1.tag || current$$1.stateNode.containerInfo !== portal.containerInfo || current$$1.stateNode.implementation !== portal.implementation ) @@ -2985,7 +2690,7 @@ function ChildReconciler(shouldTrackSideEffects) { expirationTime, key ) { - if (null === current$$1 || 7 !== current$$1.tag) + if (null === current$$1 || 9 !== current$$1.tag) return ( (current$$1 = createFiberFromFragment( fragment, @@ -3015,11 +2720,8 @@ function ChildReconciler(shouldTrackSideEffects) { switch (newChild.$$typeof) { case REACT_ELEMENT_TYPE: return ( - (expirationTime = createFiberFromTypeAndProps( - newChild.type, - newChild.key, - newChild.props, - null, + (expirationTime = createFiberFromElement( + newChild, returnFiber.mode, expirationTime )), @@ -3363,9 +3065,9 @@ function ChildReconciler(shouldTrackSideEffects) { ) { if (isUnkeyedTopLevelFragment.key === isObject) if ( - 7 === isUnkeyedTopLevelFragment.tag + 9 === isUnkeyedTopLevelFragment.tag ? newChild.type === REACT_FRAGMENT_TYPE - : isUnkeyedTopLevelFragment.elementType === newChild.type + : isUnkeyedTopLevelFragment.type === newChild.type ) { deleteRemainingChildren( returnFiber, @@ -3405,11 +3107,8 @@ function ChildReconciler(shouldTrackSideEffects) { )), (currentFirstChild.return = returnFiber), (returnFiber = currentFirstChild)) - : ((expirationTime = createFiberFromTypeAndProps( - newChild.type, - newChild.key, - newChild.props, - null, + : ((expirationTime = createFiberFromElement( + newChild, returnFiber.mode, expirationTime )), @@ -3431,7 +3130,7 @@ function ChildReconciler(shouldTrackSideEffects) { ) { if (currentFirstChild.key === isUnkeyedTopLevelFragment) if ( - 4 === currentFirstChild.tag && + 6 === currentFirstChild.tag && currentFirstChild.stateNode.containerInfo === newChild.containerInfo && currentFirstChild.stateNode.implementation === @@ -3469,7 +3168,7 @@ function ChildReconciler(shouldTrackSideEffects) { if ("string" === typeof newChild || "number" === typeof newChild) return ( (newChild = "" + newChild), - null !== currentFirstChild && 6 === currentFirstChild.tag + null !== currentFirstChild && 8 === currentFirstChild.tag ? (deleteRemainingChildren(returnFiber, currentFirstChild.sibling), (currentFirstChild = useFiber( currentFirstChild, @@ -3505,7 +3204,8 @@ function ChildReconciler(shouldTrackSideEffects) { isObject && throwOnInvalidObjectType(returnFiber, newChild); if ("undefined" === typeof newChild && !isUnkeyedTopLevelFragment) switch (returnFiber.tag) { - case 1: + case 2: + case 3: case 0: (expirationTime = returnFiber.type), invariant( @@ -3524,12 +3224,12 @@ var reconcileChildFibers = ChildReconciler(!0), isHydrating = !1; function tryHydrate(fiber, nextInstance) { switch (fiber.tag) { - case 5: + case 7: return ( (nextInstance = shim$1(nextInstance, fiber.type, fiber.pendingProps)), null !== nextInstance ? ((fiber.stateNode = nextInstance), !0) : !1 ); - case 6: + case 8: return ( (nextInstance = shim$1(nextInstance, fiber.pendingProps)), null !== nextInstance ? ((fiber.stateNode = nextInstance), !0) : !1 @@ -3552,8 +3252,7 @@ function tryToClaimNextHydratableInstance(fiber$jscomp$0) { return; } var returnFiber = hydrationParentFiber, - fiber = createFiber(5, null, null, 0); - fiber.elementType = "DELETED"; + fiber = new FiberNode(7, null, null, 0); fiber.type = "DELETED"; fiber.stateNode = firstAttemptedInstance; fiber.return = returnFiber; @@ -3571,33 +3270,36 @@ function tryToClaimNextHydratableInstance(fiber$jscomp$0) { (hydrationParentFiber = fiber$jscomp$0); } } -function readLazyComponentType(lazyComponent) { - var result = lazyComponent._result; - switch (lazyComponent._status) { +function readLazyComponentType(thenable) { + switch (thenable._reactStatus) { case 1: - return result; + return thenable._reactResult; case 2: - throw result; + throw thenable._reactResult; case 0: - throw result; + throw thenable; default: - 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)); + throw ((thenable._reactStatus = 0), + thenable.then( + function(resolvedValue) { + if (0 === thenable._reactStatus) { + thenable._reactStatus = 1; + if ("object" === typeof resolvedValue && null !== resolvedValue) { + var defaultExport = resolvedValue.default; + resolvedValue = + void 0 !== defaultExport && null !== defaultExport + ? defaultExport + : resolvedValue; + } + thenable._reactResult = resolvedValue; + } }, function(error) { - 0 === lazyComponent._status && - ((lazyComponent._status = 2), (lazyComponent._result = error)); + 0 === thenable._reactStatus && + ((thenable._reactStatus = 2), (thenable._reactResult = error)); } ), - (lazyComponent._result = result), - result); + thenable); } } var ReactCurrentOwner$3 = ReactSharedInternals.ReactCurrentOwner; @@ -3625,87 +3327,28 @@ function reconcileChildren( function updateForwardRef( current$$1, workInProgress, - Component, + type, nextProps, - renderExpirationTime$jscomp$0 -) { - Component = Component.render; - var ref = workInProgress.ref; - 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 updateMemoComponent( - current$$1, - workInProgress, - Component, - nextProps, - updateExpirationTime, renderExpirationTime ) { - 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; + type = type.render; + var ref = workInProgress.ref; if ( - updateExpirationTime < renderExpirationTime && - ((updateExpirationTime = type.memoizedProps), - (Component = Component.compare), - (Component = null !== Component ? Component : shallowEqual), - Component(updateExpirationTime, nextProps) && - current$$1.ref === workInProgress.ref) + !didPerformWorkStackCursor.current && + workInProgress.memoizedProps === nextProps && + ref === (null !== current$$1 ? current$$1.ref : null) ) return bailoutOnAlreadyFinishedWork( current$$1, workInProgress, renderExpirationTime ); - current$$1 = createWorkInProgress(type, nextProps, renderExpirationTime); - current$$1.ref = workInProgress.ref; - current$$1.return = workInProgress; - return (workInProgress.child = current$$1); + type = type(nextProps, ref); + reconcileChildren(current$$1, workInProgress, type, renderExpirationTime); + workInProgress.memoizedProps = nextProps; + return workInProgress.child; } -function updateSimpleMemoComponent( +function updatePureComponent( current$$1, workInProgress, Component, @@ -3713,22 +3356,29 @@ function updateSimpleMemoComponent( 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 - ); + var render = Component.render, + ref = workInProgress.ref; + if ( + null !== current$$1 && + (0 === updateExpirationTime || + updateExpirationTime > renderExpirationTime) && + ((updateExpirationTime = current$$1.memoizedProps), + (Component = Component.compare), + (Component = null !== Component ? Component : shallowEqual), + workInProgress.ref === current$$1.ref && + Component(updateExpirationTime, nextProps)) + ) + 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; } function markRef(current$$1, workInProgress) { var ref = workInProgress.ref; @@ -3743,30 +3393,22 @@ function updateFunctionComponent( workInProgress, Component, nextProps, - renderExpirationTime$jscomp$0 + renderExpirationTime ) { var unmaskedContext = isContextProvider(Component) ? previousContext : contextStackCursor.current; unmaskedContext = getMaskedContext(workInProgress, 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 - ); + prepareToReadContext(workInProgress, renderExpirationTime); + Component = Component(nextProps, unmaskedContext); workInProgress.effectTag |= 1; reconcileChildren( current$$1, workInProgress, - nextChildren, - renderExpirationTime$jscomp$0 + Component, + renderExpirationTime ); + workInProgress.memoizedProps = nextProps; return workInProgress.child; } function updateClassComponent( @@ -3781,149 +3423,166 @@ function updateClassComponent( pushContextProvider(workInProgress); } else hasContext = !1; prepareToReadContext(workInProgress, renderExpirationTime); - if (null === workInProgress.stateNode) - null !== current$$1 && - ((current$$1.alternate = null), - (workInProgress.alternate = null), - (workInProgress.effectTag |= 2)), - constructClassInstance( - workInProgress, - Component, - nextProps, - 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)); mountClassInstance( workInProgress, Component, nextProps, renderExpirationTime - ), - (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 instance.getSnapshotBeforeUpdate; - hasNewLifecycles || - ("function" !== typeof instance.UNSAFE_componentWillReceiveProps && - "function" !== typeof instance.componentWillReceiveProps) || - ((oldProps !== nextProps || oldContext !== contextType) && - callComponentWillReceiveProps( - workInProgress, - instance, - nextProps, - 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) + ); + 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), - (contextType = getMaskedContext(workInProgress, contextType))), - (getDerivedStateFromProps = Component.getDerivedStateFromProps), - (hasNewLifecycles = + (context = getMaskedContext(workInProgress, context))); + var getDerivedStateFromProps = Component.getDerivedStateFromProps; + (instance = "function" === typeof getDerivedStateFromProps || - "function" === typeof instance.getSnapshotBeforeUpdate) || - ("function" !== typeof instance.UNSAFE_componentWillReceiveProps && - "function" !== typeof instance.componentWillReceiveProps) || - ((oldProps !== nextProps || oldContext !== contextType) && + "function" === typeof unmaskedContext.getSnapshotBeforeUpdate) || + ("function" !== + typeof unmaskedContext.UNSAFE_componentWillReceiveProps && + "function" !== typeof unmaskedContext.componentWillReceiveProps) || + ((isLegacyContextConsumer !== nextProps || oldContext !== context) && callComponentWillReceiveProps( workInProgress, - instance, + unmaskedContext, nextProps, - contextType + context + )); + hasForceUpdate = !1; + var oldState = workInProgress.memoizedState; + oldContext = unmaskedContext.state = oldState; + var updateQueue = workInProgress.updateQueue; + null !== updateQueue && + (processUpdateQueue( + workInProgress, + updateQueue, + nextProps, + unmaskedContext, + renderExpirationTime + ), + (oldContext = workInProgress.memoizedState)); + 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) + ? previousContext + : contextStackCursor.current), + (context = getMaskedContext(workInProgress, context))), + (getDerivedStateFromProps = Component.getDerivedStateFromProps), + (instance = + "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), (oldContext = workInProgress.memoizedState), - (oldState = instance.state = oldContext), + (oldState = unmaskedContext.state = oldContext), (updateQueue = workInProgress.updateQueue), null !== updateQueue && (processUpdateQueue( workInProgress, updateQueue, nextProps, - instance, + unmaskedContext, renderExpirationTime ), (oldState = workInProgress.memoizedState)), - oldProps !== nextProps || + isLegacyContextConsumer !== nextProps || oldContext !== oldState || didPerformWorkStackCursor.current || hasForceUpdate @@ -3940,51 +3599,53 @@ function updateClassComponent( checkShouldComponentUpdate( workInProgress, Component, - oldProps, + isLegacyContextConsumer, nextProps, oldContext, oldState, - contextType + context )) - ? (hasNewLifecycles || - ("function" !== typeof instance.UNSAFE_componentWillUpdate && - "function" !== typeof instance.componentWillUpdate) || - ("function" === typeof instance.componentWillUpdate && - instance.componentWillUpdate( + ? (instance || + ("function" !== + typeof unmaskedContext.UNSAFE_componentWillUpdate && + "function" !== typeof unmaskedContext.componentWillUpdate) || + ("function" === typeof unmaskedContext.componentWillUpdate && + unmaskedContext.componentWillUpdate( nextProps, oldState, - contextType + context ), - "function" === typeof instance.UNSAFE_componentWillUpdate && - instance.UNSAFE_componentWillUpdate( + "function" === + typeof unmaskedContext.UNSAFE_componentWillUpdate && + unmaskedContext.UNSAFE_componentWillUpdate( nextProps, oldState, - contextType + context )), - "function" === typeof instance.componentDidUpdate && + "function" === typeof unmaskedContext.componentDidUpdate && (workInProgress.effectTag |= 4), - "function" === typeof instance.getSnapshotBeforeUpdate && + "function" === typeof unmaskedContext.getSnapshotBeforeUpdate && (workInProgress.effectTag |= 256)) - : ("function" !== typeof instance.componentDidUpdate || - (oldProps === current$$1.memoizedProps && + : ("function" !== typeof unmaskedContext.componentDidUpdate || + (isLegacyContextConsumer === current$$1.memoizedProps && oldContext === current$$1.memoizedState) || (workInProgress.effectTag |= 4), - "function" !== typeof instance.getSnapshotBeforeUpdate || - (oldProps === current$$1.memoizedProps && + "function" !== typeof unmaskedContext.getSnapshotBeforeUpdate || + (isLegacyContextConsumer === current$$1.memoizedProps && oldContext === current$$1.memoizedState) || (workInProgress.effectTag |= 256), (workInProgress.memoizedProps = nextProps), (workInProgress.memoizedState = oldState)), - (instance.props = nextProps), - (instance.state = oldState), - (instance.context = contextType), + (unmaskedContext.props = nextProps), + (unmaskedContext.state = oldState), + (unmaskedContext.context = context), (nextProps = getDerivedStateFromProps)) - : ("function" !== typeof instance.componentDidUpdate || - (oldProps === current$$1.memoizedProps && + : ("function" !== typeof unmaskedContext.componentDidUpdate || + (isLegacyContextConsumer === current$$1.memoizedProps && oldContext === current$$1.memoizedState) || (workInProgress.effectTag |= 4), - "function" !== typeof instance.getSnapshotBeforeUpdate || - (oldProps === current$$1.memoizedProps && + "function" !== typeof unmaskedContext.getSnapshotBeforeUpdate || + (isLegacyContextConsumer === current$$1.memoizedProps && oldContext === current$$1.memoizedState) || (workInProgress.effectTag |= 256), (nextProps = !1)); @@ -4043,6 +3704,7 @@ function finishClassComponent( renderExpirationTime ); workInProgress.memoizedState = shouldUpdate.state; + workInProgress.memoizedProps = shouldUpdate.props; hasContext && invalidateContextProvider(workInProgress, Component, !0); return workInProgress.child; } @@ -4068,105 +3730,6 @@ 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, @@ -4174,7 +3737,9 @@ function bailoutOnAlreadyFinishedWork( ) { null !== current$$1 && (workInProgress.firstContextDependency = current$$1.firstContextDependency); - if (workInProgress.childExpirationTime < renderExpirationTime) return null; + var childExpirationTime = workInProgress.childExpirationTime; + if (0 === childExpirationTime || childExpirationTime > renderExpirationTime) + return null; invariant( null === current$$1 || workInProgress.child === current$$1.child, "Resuming work not yet implemented." @@ -4203,562 +3768,557 @@ function bailoutOnAlreadyFinishedWork( } return workInProgress.child; } -function beginWork(current$$1, workInProgress, renderExpirationTime$jscomp$0) { +function beginWork(current$$1, workInProgress, renderExpirationTime) { var updateExpirationTime = workInProgress.expirationTime; if ( null !== current$$1 && current$$1.memoizedProps === workInProgress.pendingProps && !didPerformWorkStackCursor.current && - updateExpirationTime < renderExpirationTime$jscomp$0 + (0 === updateExpirationTime || updateExpirationTime > renderExpirationTime) ) { switch (workInProgress.tag) { - case 3: + case 5: pushHostRootContext(workInProgress); break; - case 5: + case 7: pushHostContext(workInProgress); break; - case 1: + case 2: isContextProvider(workInProgress.type) && pushContextProvider(workInProgress); break; - case 4: + case 3: + isContextProvider(workInProgress.type._reactResult) && + pushContextProvider(workInProgress); + break; + case 6: pushHostContainer( workInProgress, workInProgress.stateNode.containerInfo ); break; - case 10: + case 12: 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$jscomp$0 + renderExpirationTime ); } workInProgress.expirationTime = 0; switch (workInProgress.tag) { - 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, - contextStackCursor.current + 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." ); - prepareToReadContext(workInProgress, renderExpirationTime$jscomp$0); - renderExpirationTime = renderExpirationTime$jscomp$0; - currentlyRenderingFiber$1 = workInProgress; - firstCurrentHook = null; - var value = updateExpirationTime(current$$1, context); - workInProgress.effectTag |= 1; + var props = workInProgress.pendingProps; if ( - "object" === typeof value && - null !== value && - "function" === typeof value.render && - void 0 === value.$$typeof + "object" === typeof Component && + null !== Component && + "function" === typeof Component.then ) { - 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( + Component = readLazyComponentType(Component); + var resolvedTag = (workInProgress.tag = resolveLazyComponentTag( 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 + Component )), - 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, + 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, - updateExpirationTime, - value, - renderExpirationTime$jscomp$0 - ) + 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, + workInProgress, + workInProgress.type, + workInProgress.pendingProps, + renderExpirationTime ); case 1: return ( - (updateExpirationTime = workInProgress.type), - (value = workInProgress.pendingProps), - (value = - workInProgress.elementType === updateExpirationTime - ? value - : resolveDefaultProps(updateExpirationTime, value)), - updateClassComponent( + (props = workInProgress.type._reactResult), + (Component = workInProgress.pendingProps), + (current$$1 = updateFunctionComponent( current$$1, workInProgress, - updateExpirationTime, - value, - renderExpirationTime$jscomp$0 - ) + props, + resolveDefaultProps(props, Component), + renderExpirationTime + )), + (workInProgress.memoizedProps = Component), + current$$1 + ); + case 2: + return updateClassComponent( + current$$1, + workInProgress, + workInProgress.type, + workInProgress.pendingProps, + renderExpirationTime ); 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), - (updateExpirationTime = workInProgress.updateQueue), + (Component = workInProgress.updateQueue), invariant( - null !== updateExpirationTime, + null !== Component, "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." ), - (value = workInProgress.memoizedState), - (value = null !== value ? value.element : null), + (props = workInProgress.memoizedState), + (props = null !== props ? props.element : null), processUpdateQueue( workInProgress, - updateExpirationTime, + Component, workInProgress.pendingProps, null, - renderExpirationTime$jscomp$0 + renderExpirationTime ), - (updateExpirationTime = workInProgress.memoizedState.element), - updateExpirationTime === value + (Component = workInProgress.memoizedState.element), + Component === props ? (workInProgress = bailoutOnAlreadyFinishedWork( current$$1, workInProgress, - renderExpirationTime$jscomp$0 + renderExpirationTime )) : (reconcileChildren( current$$1, workInProgress, - updateExpirationTime, - renderExpirationTime$jscomp$0 + Component, + renderExpirationTime ), (workInProgress = workInProgress.child)), workInProgress ); - case 5: + case 7: return ( pushHostContext(workInProgress), null === current$$1 && tryToClaimNextHydratableInstance(workInProgress), - (updateExpirationTime = workInProgress.pendingProps.children), + (Component = workInProgress.pendingProps), + (props = Component.children), markRef(current$$1, workInProgress), reconcileChildren( current$$1, workInProgress, - updateExpirationTime, - renderExpirationTime$jscomp$0 + props, + renderExpirationTime ), + (workInProgress.memoizedProps = Component), (workInProgress = workInProgress.child), workInProgress ); - case 6: + case 8: return ( null === current$$1 && tryToClaimNextHydratableInstance(workInProgress), + (workInProgress.memoizedProps = workInProgress.pendingProps), null ); - case 13: - return updateSuspenseComponent( - current$$1, - workInProgress, - renderExpirationTime$jscomp$0 + 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 4: + case 6: return ( pushHostContainer( workInProgress, workInProgress.stateNode.containerInfo ), - (updateExpirationTime = workInProgress.pendingProps), + (Component = workInProgress.pendingProps), null === current$$1 ? (workInProgress.child = reconcileChildFibers( workInProgress, null, - updateExpirationTime, - renderExpirationTime$jscomp$0 + Component, + renderExpirationTime )) : reconcileChildren( current$$1, workInProgress, - updateExpirationTime, - renderExpirationTime$jscomp$0 + Component, + renderExpirationTime ), + (workInProgress.memoizedProps = Component), workInProgress.child ); - case 11: + case 13: + return updateForwardRef( + current$$1, + workInProgress, + workInProgress.type, + workInProgress.pendingProps, + renderExpirationTime + ); + case 14: return ( - (updateExpirationTime = workInProgress.type), - (value = workInProgress.pendingProps), - (value = - workInProgress.elementType === updateExpirationTime - ? value - : resolveDefaultProps(updateExpirationTime, value)), - updateForwardRef( + (props = workInProgress.type._reactResult), + (Component = workInProgress.pendingProps), + (current$$1 = updateForwardRef( current$$1, workInProgress, - updateExpirationTime, - value, - renderExpirationTime$jscomp$0 - ) + props, + resolveDefaultProps(props, Component), + renderExpirationTime + )), + (workInProgress.memoizedProps = Component), + current$$1 ); - case 7: + case 9: return ( + (Component = workInProgress.pendingProps), reconcileChildren( current$$1, workInProgress, - workInProgress.pendingProps, - renderExpirationTime$jscomp$0 - ), - workInProgress.child - ); - case 8: - return ( - reconcileChildren( - current$$1, - workInProgress, - workInProgress.pendingProps.children, - renderExpirationTime$jscomp$0 - ), - workInProgress.child - ); - case 12: - return ( - reconcileChildren( - current$$1, - workInProgress, - workInProgress.pendingProps.children, - renderExpirationTime$jscomp$0 + Component, + renderExpirationTime ), + (workInProgress.memoizedProps = Component), workInProgress.child ); case 10: + return ( + (Component = workInProgress.pendingProps.children), + reconcileChildren( + current$$1, + workInProgress, + Component, + renderExpirationTime + ), + (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: a: { - 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) { + 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) + ) { if ( - getDerivedStateFromProps.children === value.children && + resolvedTag.children === props.children && !didPerformWorkStackCursor.current ) { workInProgress = bailoutOnAlreadyFinishedWork( current$$1, workInProgress, - renderExpirationTime$jscomp$0 + renderExpirationTime ); break a; } } else for ( - getDerivedStateFromProps = workInProgress.child, - null !== getDerivedStateFromProps && - (getDerivedStateFromProps.return = workInProgress); - null !== getDerivedStateFromProps; + resolvedTag = workInProgress.child, + null !== resolvedTag && (resolvedTag.return = workInProgress); + null !== resolvedTag; ) { - oldValue = getDerivedStateFromProps.firstContextDependency; - if (null !== oldValue) { + resolvedProps = resolvedTag.firstContextDependency; + if (null !== resolvedProps) { do { if ( - oldValue.context === updateExpirationTime && - 0 !== (oldValue.observedBits & context) + resolvedProps.context === Component && + 0 !== (resolvedProps.observedBits & updateExpirationTime) ) { - 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 (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 ( - node.childExpirationTime < renderExpirationTime$jscomp$0 + 0 === node.childExpirationTime || + node.childExpirationTime > renderExpirationTime ) - (node.childExpirationTime = renderExpirationTime$jscomp$0), - null !== nextFiber && - nextFiber.childExpirationTime < - renderExpirationTime$jscomp$0 && - (nextFiber.childExpirationTime = renderExpirationTime$jscomp$0); + (node.childExpirationTime = renderExpirationTime), + null !== child && + (0 === child.childExpirationTime || + child.childExpirationTime > + renderExpirationTime) && + (child.childExpirationTime = renderExpirationTime); else if ( - null !== nextFiber && - nextFiber.childExpirationTime < - renderExpirationTime$jscomp$0 + null !== child && + (0 === child.childExpirationTime || + child.childExpirationTime > renderExpirationTime) ) - nextFiber.childExpirationTime = renderExpirationTime$jscomp$0; + child.childExpirationTime = renderExpirationTime; else break; node = node.return; } } - nextFiber = getDerivedStateFromProps.child; - oldValue = oldValue.next; - } while (null !== oldValue); + child = resolvedTag.child; + resolvedProps = resolvedProps.next; + } while (null !== resolvedProps); } else - nextFiber = - 10 === getDerivedStateFromProps.tag - ? getDerivedStateFromProps.type === workInProgress.type + child = + 12 === resolvedTag.tag + ? resolvedTag.type === workInProgress.type ? null - : getDerivedStateFromProps.child - : getDerivedStateFromProps.child; - if (null !== nextFiber) - nextFiber.return = getDerivedStateFromProps; + : resolvedTag.child + : resolvedTag.child; + if (null !== child) child.return = resolvedTag; else - for ( - nextFiber = getDerivedStateFromProps; - null !== nextFiber; - - ) { - if (nextFiber === workInProgress) { - nextFiber = null; + for (child = resolvedTag; null !== child; ) { + if (child === workInProgress) { + child = null; break; } - getDerivedStateFromProps = nextFiber.sibling; - if (null !== getDerivedStateFromProps) { - getDerivedStateFromProps.return = nextFiber.return; - nextFiber = getDerivedStateFromProps; + resolvedTag = child.sibling; + if (null !== resolvedTag) { + resolvedTag.return = child.return; + child = resolvedTag; break; } - nextFiber = nextFiber.return; + child = child.return; } - getDerivedStateFromProps = nextFiber; + resolvedTag = child; } - } reconcileChildren( current$$1, workInProgress, - value.children, - renderExpirationTime$jscomp$0 + props.children, + renderExpirationTime ); workInProgress = workInProgress.child; } return workInProgress; - case 9: + case 11: return ( - (value = workInProgress.type), - (context = workInProgress.pendingProps), - (updateExpirationTime = context.children), - prepareToReadContext(workInProgress, renderExpirationTime$jscomp$0), - (value = readContext(value, context.unstable_observedBits)), - (updateExpirationTime = updateExpirationTime(value)), + (updateExpirationTime = workInProgress.type), + (Component = workInProgress.pendingProps), + (props = Component.children), + prepareToReadContext(workInProgress, renderExpirationTime), + (updateExpirationTime = readContext( + updateExpirationTime, + Component.unstable_observedBits + )), + (props = props(updateExpirationTime)), (workInProgress.effectTag |= 1), reconcileChildren( current$$1, workInProgress, - updateExpirationTime, - renderExpirationTime$jscomp$0 + props, + renderExpirationTime ), + (workInProgress.memoizedProps = Component), workInProgress.child ); - 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( + case 17: + return updatePureComponent( current$$1, workInProgress, workInProgress.type, workInProgress.pendingProps, updateExpirationTime, - renderExpirationTime$jscomp$0 + renderExpirationTime ); - case 17: + case 18: return ( - (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, - updateExpirationTime, - value, - renderExpirationTime$jscomp$0 - ), - mountClassInstance( - workInProgress, - updateExpirationTime, - value, - renderExpirationTime$jscomp$0 - ), - finishClassComponent( - null, - workInProgress, - updateExpirationTime, - !0, + (props = workInProgress.type._reactResult), + (Component = workInProgress.pendingProps), + (current$$1 = updatePureComponent( current$$1, - renderExpirationTime$jscomp$0 - ) + workInProgress, + props, + resolveDefaultProps(props, Component), + updateExpirationTime, + renderExpirationTime + )), + (workInProgress.memoizedProps = Component), + current$$1 ); default: invariant( @@ -4767,27 +4327,9 @@ function beginWork(current$$1, workInProgress, renderExpirationTime$jscomp$0) { ); } } -var appendAllChildren = void 0, - updateHostContainer = void 0, +var 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 && @@ -4817,6 +4359,7 @@ 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; @@ -4833,7 +4376,7 @@ function logError(boundary, errorInfo) { willRetry: !1 }; null !== boundary && - 1 === boundary.tag && + 2 === boundary.tag && ((errorInfo.errorBoundary = boundary.stateNode), (errorInfo.errorBoundaryName = getComponentName(boundary.type)), (errorInfo.errorBoundaryFound = !0), @@ -4857,74 +4400,32 @@ 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 commitUnmount(current$$1$jscomp$0) { +function commitUnmount(current$$1) { "function" === typeof onCommitFiberUnmount && - 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) + onCommitFiberUnmount(current$$1); + switch (current$$1.tag) { + case 2: + case 3: + safelyDetachRef(current$$1); + var instance = current$$1.stateNode; + if ("function" === typeof instance.componentWillUnmount) try { - (updateQueue.props = current$$1$jscomp$0.memoizedProps), - (updateQueue.state = current$$1$jscomp$0.memoizedState), - updateQueue.componentWillUnmount(); + (instance.props = current$$1.memoizedProps), + (instance.state = current$$1.memoizedState), + instance.componentWillUnmount(); } catch (unmountError) { - captureCommitPhaseError(current$$1$jscomp$0, unmountError); + captureCommitPhaseError(current$$1, unmountError); } break; - case 5: - safelyDetachRef(current$$1$jscomp$0); + case 7: + safelyDetachRef(current$$1); break; - case 4: - unmountHostComponents(current$$1$jscomp$0); + case 6: + unmountHostComponents(current$$1); } } function isHostParent(fiber) { - return 5 === fiber.tag || 3 === fiber.tag || 4 === fiber.tag; + return 7 === fiber.tag || 5 === fiber.tag || 6 === fiber.tag; } function commitPlacement(finishedWork) { a: { @@ -4943,15 +4444,15 @@ function commitPlacement(finishedWork) { } var isContainer = (parent = void 0); switch (parentFiber.tag) { - case 5: + case 7: parent = parentFiber.stateNode; isContainer = !1; break; - case 3: + case 5: parent = parentFiber.stateNode.containerInfo; isContainer = !0; break; - case 4: + case 6: parent = parentFiber.stateNode.containerInfo; isContainer = !0; break; @@ -4973,11 +4474,11 @@ function commitPlacement(finishedWork) { parentFiber.sibling.return = parentFiber.return; for ( parentFiber = parentFiber.sibling; - 5 !== parentFiber.tag && 6 !== parentFiber.tag; + 7 !== parentFiber.tag && 8 !== parentFiber.tag; ) { if (parentFiber.effectTag & 2) continue b; - if (null === parentFiber.child || 4 === parentFiber.tag) continue b; + if (null === parentFiber.child || 6 === parentFiber.tag) continue b; else (parentFiber.child.return = parentFiber), (parentFiber = parentFiber.child); @@ -4988,7 +4489,7 @@ function commitPlacement(finishedWork) { } } for (var node = finishedWork; ; ) { - if (5 === node.tag || 6 === node.tag) + if (7 === node.tag || 8 === node.tag) if (parentFiber) if (isContainer) invariant( @@ -5057,7 +4558,7 @@ function commitPlacement(finishedWork) { [index.length - 1], [] ))); - else if (4 !== node.tag && null !== node.child) { + else if (6 !== node.tag && null !== node.child) { node.child.return = node; node = node.child; continue; @@ -5088,15 +4589,15 @@ function unmountHostComponents(current$$1) { "Expected to find a host parent. This error is likely caused by a bug in React. Please file an issue." ); switch (currentParentIsValid.tag) { - case 5: + case 7: currentParent = currentParentIsValid.stateNode; currentParentIsContainer = !1; break a; - case 3: + case 5: currentParent = currentParentIsValid.stateNode.containerInfo; currentParentIsContainer = !0; break a; - case 4: + case 6: currentParent = currentParentIsValid.stateNode.containerInfo; currentParentIsContainer = !0; break a; @@ -5105,11 +4606,11 @@ function unmountHostComponents(current$$1) { } currentParentIsValid = !0; } - if (5 === node.tag || 6 === node.tag) { + if (7 === node.tag || 8 === node.tag) { a: for (var root = node, node$jscomp$0 = root; ; ) if ( (commitUnmount(node$jscomp$0), - null !== node$jscomp$0.child && 4 !== node$jscomp$0.tag) + null !== node$jscomp$0.child && 6 !== node$jscomp$0.tag) ) (node$jscomp$0.child.return = node$jscomp$0), (node$jscomp$0 = node$jscomp$0.child); @@ -5137,7 +4638,7 @@ function unmountHostComponents(current$$1) { UIManager.manageChildren(root._nativeTag, [], [], [], [], [child]); } } else if ( - (4 === node.tag + (6 === node.tag ? ((currentParent = node.stateNode.containerInfo), (currentParentIsContainer = !0)) : commitUnmount(node), @@ -5151,7 +4652,7 @@ function unmountHostComponents(current$$1) { for (; null === node.sibling; ) { if (null === node.return || node.return === current$$1) return; node = node.return; - 4 === node.tag && (currentParentIsValid = !1); + 6 === node.tag && (currentParentIsValid = !1); } node.sibling.return = node.return; node = node.sibling; @@ -5159,15 +4660,10 @@ function unmountHostComponents(current$$1) { } function commitWork(current$$1, finishedWork) { switch (finishedWork.tag) { - case 0: - case 11: - case 14: - case 15: - commitHookEffectList(4, 8, finishedWork); + case 2: + case 3: break; - case 1: - break; - case 5: + case 7: var instance = finishedWork.stateNode; if (null != instance) { var newProps = finishedWork.memoizedProps; @@ -5191,7 +4687,7 @@ function commitWork(current$$1, finishedWork) { )); } break; - case 6: + case 8: invariant( null !== finishedWork.stateNode, "This should have a text node initialized. This error is likely caused by a bug in React. Please file an issue." @@ -5200,13 +4696,11 @@ function commitWork(current$$1, finishedWork) { text: finishedWork.memoizedProps }); break; - case 3: + case 5: break; - case 12: + case 15: break; - case 13: - break; - case 17: + case 16: break; default: invariant( @@ -5215,6 +4709,9 @@ function commitWork(current$$1, finishedWork) { ); } } +function NoopComponent() { + return null; +} function createRootErrorUpdate(fiber, errorInfo, expirationTime) { expirationTime = createUpdate(expirationTime); expirationTime.tag = 3; @@ -5255,14 +4752,24 @@ function createClassErrorUpdate(fiber, errorInfo, expirationTime) { } function unwindWork(workInProgress) { switch (workInProgress.tag) { - case 1: + case 2: isContextProvider(workInProgress.type) && popContext(workInProgress); var effectTag = workInProgress.effectTag; - return effectTag & 2048 - ? ((workInProgress.effectTag = (effectTag & -2049) | 64), + return effectTag & 1024 + ? ((workInProgress.effectTag = (effectTag & -1025) | 64), workInProgress) : null; case 3: + return ( + isContextProvider(workInProgress.type._reactResult) && + popContext(workInProgress), + (effectTag = workInProgress.effectTag), + effectTag & 1024 + ? ((workInProgress.effectTag = (effectTag & -1025) | 64), + workInProgress) + : null + ); + case 5: return ( popHostContainer(workInProgress), popTopLevelContextObject(workInProgress), @@ -5271,117 +4778,28 @@ 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 & -2049) | 64), + (workInProgress.effectTag = (effectTag & -1025) | 64), workInProgress ); - case 5: + case 7: return popHostContext(workInProgress), null; - 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: + case 16: + return ( + (effectTag = workInProgress.effectTag), + effectTag & 1024 + ? ((workInProgress.effectTag = (effectTag & -1025) | 64), + workInProgress) + : null + ); + case 6: return popHostContainer(workInProgress), null; - case 10: + case 12: return popProvider(workInProgress), null; default: return null; } } -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); - } - }, +var Dispatcher = { readContext: readContext }, ReactCurrentOwner$2 = ReactSharedInternals.ReactCurrentOwner, isWorking = !1, nextUnitOfWork = null, @@ -5391,9 +4809,6 @@ var Dispatcher = { nextRenderDidError = !1, nextEffect = null, isCommitting$1 = !1, - rootWithPendingPassiveEffects = null, - passiveEffectCallbackHandle = null, - passiveEffectCallback = null, legacyErrorBoundariesThatAlreadyFailed = null; function resetStack() { if (null !== nextUnitOfWork) @@ -5404,7 +4819,7 @@ function resetStack() { ) { var interruptedWork$jscomp$0 = interruptedWork; switch (interruptedWork$jscomp$0.tag) { - case 1: + case 2: var childContextTypes = interruptedWork$jscomp$0.type.childContextTypes; null !== childContextTypes && @@ -5412,16 +4827,23 @@ 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 5: + case 7: popHostContext(interruptedWork$jscomp$0); break; - case 4: + case 6: popHostContainer(interruptedWork$jscomp$0); break; - case 10: + case 12: popProvider(interruptedWork$jscomp$0); } interruptedWork = interruptedWork.return; @@ -5432,55 +4854,27 @@ 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 & 1024)) { + if (0 === (workInProgress.effectTag & 512)) { var current = current$$1; current$$1 = workInProgress; var newProps = current$$1.pendingProps; switch (current$$1.tag) { - case 2: - break; - case 16: - break; - case 15: case 0: - break; case 1: + break; + case 2: 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; @@ -5491,7 +4885,7 @@ function completeUnitOfWork(workInProgress) { current$$1.effectTag &= -3; updateHostContainer(current$$1); break; - case 5: + case 7: popHostContext(current$$1); var rootContainerInstance = requiredContext( rootInstanceStackCursor.current @@ -5530,7 +4924,35 @@ function completeUnitOfWork(workInProgress) { viewConfig = new ReactNativeFiberHostComponent(tag, viewConfig); instanceCache[tag] = internalInstanceHandle; instanceProps[tag] = newProps; - appendAllChildren(viewConfig, current$$1, !1, !1); + 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; + } finalizeInitialChildren( viewConfig, type, @@ -5546,7 +4968,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 6: + case 8: current && null != current$$1.stateNode ? updateHostText$1( current, @@ -5573,36 +4995,34 @@ function completeUnitOfWork(workInProgress) { (instanceCache[type] = current$$1), (rootContainerInstance.stateNode = type)); break; - case 11: - break; case 13: - newProps = current$$1.memoizedState; - rootContainerInstance = - null !== current ? current.memoizedState : null; - (null !== newProps && newProps.didTimeout) !== - (null !== rootContainerInstance && - rootContainerInstance.didTimeout) && (current$$1.effectTag |= 4); + case 14: break; - case 7: - break; - case 8: - break; - case 12: - break; - case 4: - popHostContainer(current$$1); - updateHostContainer(current$$1); - break; - case 10: - popProvider(current$$1); + case 16: break; case 9: break; - case 14: + case 10: + break; + case 15: + break; + case 6: + popHostContainer(current$$1); + updateHostContainer(current$$1); + break; + case 12: + popProvider(current$$1); + break; + case 11: break; case 17: - isContextProvider(current$$1.type) && popContext(current$$1); + case 18: 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, @@ -5612,24 +5032,27 @@ function completeUnitOfWork(workInProgress) { nextUnitOfWork = null; current$$1 = workInProgress; if ( - 1 === nextRenderExpirationTime || - 1 !== current$$1.childExpirationTime + 1073741823 === nextRenderExpirationTime || + 1073741823 !== current$$1.childExpirationTime ) { newProps = 0; for ( rootContainerInstance = current$$1.child; null !== rootContainerInstance; - ) - (type = rootContainerInstance.expirationTime), - (current = rootContainerInstance.childExpirationTime), - type > newProps && (newProps = type), - current > newProps && (newProps = current), - (rootContainerInstance = rootContainerInstance.sibling); + ) { + 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; + } current$$1.childExpirationTime = newProps; } null !== returnFiber && - 0 === (returnFiber.effectTag & 1024) && + 0 === (returnFiber.effectTag & 512) && (null === returnFiber.firstEffect && (returnFiber.firstEffect = workInProgress.firstEffect), null !== workInProgress.lastEffect && @@ -5644,10 +5067,10 @@ function completeUnitOfWork(workInProgress) { } else { workInProgress = unwindWork(workInProgress, nextRenderExpirationTime); if (null !== workInProgress) - return (workInProgress.effectTag &= 1023), workInProgress; + return (workInProgress.effectTag &= 511), workInProgress; null !== returnFiber && ((returnFiber.firstEffect = returnFiber.lastEffect = null), - (returnFiber.effectTag |= 1024)); + (returnFiber.effectTag |= 512)); } if (null !== siblingFiber) return siblingFiber; if (null !== returnFiber) workInProgress = returnFiber; @@ -5661,17 +5084,15 @@ 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) { +function renderRoot(root$jscomp$0, isYieldy, isExpired) { 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; @@ -5693,17 +5114,13 @@ function renderRoot(root$jscomp$0, isYieldy) { do { try { if (isYieldy) - for (; null !== nextUnitOfWork && !shouldYieldToRenderer(); ) + for (; null !== nextUnitOfWork && !shouldYield(); ) nextUnitOfWork = performUnitOfWork(nextUnitOfWork); else for (; null !== nextUnitOfWork; ) nextUnitOfWork = performUnitOfWork(nextUnitOfWork); } catch (thrownValue) { - if ( - ((lastContextWithAllBitsObserved = lastContextDependency = currentlyRenderingFiber = null), - resetHooks(), - null === nextUnitOfWork) - ) + if (null === nextUnitOfWork) (didFatal = !0), onUncaughtError(thrownValue); else { invariant( @@ -5720,7 +5137,7 @@ function renderRoot(root$jscomp$0, isYieldy) { sourceFiber$jscomp$0 = sourceFiber, value = thrownValue; returnFiber = nextRenderExpirationTime; - sourceFiber$jscomp$0.effectTag |= 1024; + sourceFiber$jscomp$0.effectTag |= 512; sourceFiber$jscomp$0.firstEffect = sourceFiber$jscomp$0.lastEffect = null; if ( null !== value && @@ -5732,57 +5149,56 @@ function renderRoot(root$jscomp$0, isYieldy) { var earliestTimeoutMs = -1, startTimeMs = -1; do { - if (13 === value.tag) { - var current$$1 = value.alternate; + if (16 === value.tag) { + var current = value.alternate; if ( - null !== current$$1 && - ((current$$1 = current$$1.memoizedState), - null !== current$$1 && current$$1.didTimeout) + null !== current && + !0 === current.memoizedState && + null !== current.stateNode ) { - startTimeMs = 10 * (1073741822 - current$$1.timedOutAt); + startTimeMs = 10 * (current.stateNode.timedOutAt - 2); break; } - current$$1 = value.pendingProps.maxDuration; - if ("number" === typeof current$$1) - if (0 >= current$$1) earliestTimeoutMs = 0; + current = value.pendingProps.maxDuration; + if ("number" === typeof current) + if (0 >= current) earliestTimeoutMs = 0; else if ( -1 === earliestTimeoutMs || - current$$1 < earliestTimeoutMs + current < earliestTimeoutMs ) - earliestTimeoutMs = current$$1; + earliestTimeoutMs = current; } value = value.return; } while (null !== value); value = returnFiber$jscomp$0; do { - 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) { + if (16 === value.tag && !value.memoizedState) { returnFiber$jscomp$0 = retrySuspendedRoot.bind( null, root, value, - sourceFiber$jscomp$0, - 0 === (value.mode & 1) ? 1073741823 : returnFiber + 0 === (value.mode & 1) ? 1 : returnFiber ); thenable.then(returnFiber$jscomp$0, returnFiber$jscomp$0); - if (0 === (value.mode & 1)) { - value.effectTag |= 32; + if (0 === (value.mode & 2)) { + value.effectTag |= 4; reconcileChildren( sourceFiber$jscomp$0.alternate, sourceFiber$jscomp$0, null, returnFiber ); - 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); + 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)); break a; } -1 === earliestTimeoutMs @@ -5790,27 +5206,24 @@ function renderRoot(root$jscomp$0, isYieldy) { : (-1 === startTimeMs && (startTimeMs = 10 * - (1073741822 - - findEarliestOutstandingPriorityLevel( - root, - returnFiber - )) - + (findEarliestOutstandingPriorityLevel( + root, + returnFiber + ) - + 2) - 5e3), (root = startTimeMs + earliestTimeoutMs)); 0 <= root && nextLatestAbsoluteTimeoutMs < root && (nextLatestAbsoluteTimeoutMs = root); - value.effectTag |= 2048; + value.effectTag |= 1024; value.expirationTime = returnFiber; break a; } value = value.return; } while (null !== value); value = Error( - (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) + "An update was suspended, but no placeholder UI was provided." ); } nextRenderDidError = !0; @@ -5818,9 +5231,9 @@ function renderRoot(root$jscomp$0, isYieldy) { root = returnFiber$jscomp$0; do { switch (root.tag) { - case 3: + case 5: sourceFiber$jscomp$0 = value; - root.effectTag |= 2048; + root.effectTag |= 1024; root.expirationTime = returnFiber; returnFiber = createRootErrorUpdate( root, @@ -5829,7 +5242,8 @@ function renderRoot(root$jscomp$0, isYieldy) { ); enqueueCapturedUpdate(root, returnFiber); break a; - case 1: + case 2: + case 3: if ( ((sourceFiber$jscomp$0 = value), (returnFiber$jscomp$0 = root.type), @@ -5844,7 +5258,7 @@ function renderRoot(root$jscomp$0, isYieldy) { thenable ))))) ) { - root.effectTag |= 2048; + root.effectTag |= 1024; root.expirationTime = returnFiber; returnFiber = createClassErrorUpdate( root, @@ -5867,170 +5281,183 @@ function renderRoot(root$jscomp$0, isYieldy) { } 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 { - didFatal = root$jscomp$0.current.alternate; + isYieldy = root$jscomp$0.current.alternate; invariant( - null !== didFatal, + null !== isYieldy, "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) { - sourceFiber = root$jscomp$0.latestPendingTime; - returnFiber = root$jscomp$0.latestSuspendedTime; - root = root$jscomp$0.latestPingedTime; + didFatal = root$jscomp$0.latestPendingTime; + sourceFiber = root$jscomp$0.latestSuspendedTime; + returnFiber = root$jscomp$0.latestPingedTime; if ( - (0 !== sourceFiber && sourceFiber < expirationTime) || - (0 !== returnFiber && returnFiber < expirationTime) || - (0 !== root && root < expirationTime) + (0 !== didFatal && didFatal > expirationTime) || + (0 !== sourceFiber && sourceFiber > expirationTime) || + (0 !== returnFiber && returnFiber > expirationTime) ) { markSuspendedPriorityLevel(root$jscomp$0, expirationTime); onSuspend( root$jscomp$0, - didFatal, + isYieldy, expirationTime, root$jscomp$0.expirationTime, -1 ); return; } - if (!root$jscomp$0.didError && isYieldy) { + if (!root$jscomp$0.didError && !isExpired) { root$jscomp$0.didError = !0; expirationTime = root$jscomp$0.nextExpirationTimeToWorkOn = expirationTime; - isYieldy = root$jscomp$0.expirationTime = 1073741823; - onSuspend(root$jscomp$0, didFatal, expirationTime, isYieldy, -1); + isExpired = root$jscomp$0.expirationTime = 1; + onSuspend(root$jscomp$0, isYieldy, expirationTime, isExpired, -1); return; } } - isYieldy && -1 !== nextLatestAbsoluteTimeoutMs - ? (markSuspendedPriorityLevel(root$jscomp$0, expirationTime), - (isYieldy = + isExpired || -1 === nextLatestAbsoluteTimeoutMs + ? ((root$jscomp$0.pendingCommitExpirationTime = expirationTime), + (root$jscomp$0.finishedWork = isYieldy)) + : (markSuspendedPriorityLevel(root$jscomp$0, expirationTime), + (isExpired = 10 * - (1073741822 - - findEarliestOutstandingPriorityLevel( - root$jscomp$0, - expirationTime - ))), - isYieldy < nextLatestAbsoluteTimeoutMs && - (nextLatestAbsoluteTimeoutMs = isYieldy), - (isYieldy = 10 * (1073741822 - requestCurrentTime())), - (isYieldy = nextLatestAbsoluteTimeoutMs - isYieldy), + (findEarliestOutstandingPriorityLevel(root$jscomp$0, expirationTime) - + 2)), + isExpired < nextLatestAbsoluteTimeoutMs && + (nextLatestAbsoluteTimeoutMs = isExpired), + (isExpired = 10 * (requestCurrentTime() - 2)), + (isExpired = nextLatestAbsoluteTimeoutMs - isExpired), onSuspend( root$jscomp$0, - didFatal, + isYieldy, expirationTime, root$jscomp$0.expirationTime, - 0 > isYieldy ? 0 : isYieldy - )) - : ((root$jscomp$0.pendingCommitExpirationTime = expirationTime), - (root$jscomp$0.finishedWork = didFatal)); + 0 > isExpired ? 0 : isExpired + )); } } -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; +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; } - fiber = fiber.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; } - 3 === sourceFiber.tag && - ((fiber = createCapturedValue(value, sourceFiber)), - (fiber = createRootErrorUpdate(sourceFiber, fiber, 1073741823)), - enqueueUpdate(sourceFiber, fiber), - scheduleWork(sourceFiber, 1073741823)); + return JSCompiler_inline_result; } function computeExpirationForFiber(currentTime, fiber) { isWorking - ? (currentTime = isCommitting$1 ? 1073741823 : nextRenderExpirationTime) + ? (currentTime = isCommitting$1 ? 1 : nextRenderExpirationTime) : fiber.mode & 1 ? ((currentTime = isBatchingInteractiveUpdates - ? 1073741822 - 10 * ((((1073741822 - currentTime + 15) / 10) | 0) + 1) - : 1073741822 - - 25 * ((((1073741822 - currentTime + 500) / 25) | 0) + 1)), + ? 2 + 10 * ((((currentTime - 2 + 15) / 10) | 0) + 1) + : 2 + 25 * ((((currentTime - 2 + 500) / 25) | 0) + 1)), null !== nextRoot && currentTime === nextRenderExpirationTime && - --currentTime) - : (currentTime = 1073741823); + (currentTime += 1)) + : (currentTime = 1); isBatchingInteractiveUpdates && - (0 === lowestPriorityPendingInteractiveExpirationTime || - currentTime < lowestPriorityPendingInteractiveExpirationTime) && + currentTime > lowestPriorityPendingInteractiveExpirationTime && (lowestPriorityPendingInteractiveExpirationTime = currentTime); return currentTime; } -function retrySuspendedRoot(root, boundaryFiber, sourceFiber, suspendedTime) { +function retrySuspendedRoot(root, fiber, 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, boundaryFiber)), + (retryTime = computeExpirationForFiber(retryTime, fiber)), markPendingPriorityLevel(root, retryTime); - 0 !== (boundaryFiber.mode & 1) && + 0 !== (fiber.mode & 1) && root === nextRoot && nextRenderExpirationTime === suspendedTime && (nextRoot = null); - 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); + scheduleWorkToRoot(fiber, retryTime); + fiber = root.expirationTime; + 0 !== fiber && requestWork(root, fiber); } function scheduleWorkToRoot(fiber, expirationTime) { - fiber.expirationTime < expirationTime && - (fiber.expirationTime = expirationTime); + if (0 === fiber.expirationTime || fiber.expirationTime > expirationTime) + fiber.expirationTime = expirationTime; var alternate = fiber.alternate; null !== alternate && - alternate.expirationTime < expirationTime && + (0 === alternate.expirationTime || + alternate.expirationTime > expirationTime) && (alternate.expirationTime = expirationTime); var node = fiber.return, root = null; - if (null === node && 3 === fiber.tag) root = fiber.stateNode; + if (null === node && 5 === fiber.tag) root = fiber.stateNode; else for (; null !== node; ) { alternate = node.alternate; - node.childExpirationTime < expirationTime && - (node.childExpirationTime = expirationTime); + if ( + 0 === node.childExpirationTime || + node.childExpirationTime > expirationTime + ) + node.childExpirationTime = expirationTime; null !== alternate && - alternate.childExpirationTime < expirationTime && + (0 === alternate.childExpirationTime || + alternate.childExpirationTime > expirationTime) && (alternate.childExpirationTime = expirationTime); - if (null === node.return && 3 === node.tag) { + if (null === node.return && 5 === node.tag) { root = node.stateNode; break; } @@ -6043,7 +5470,7 @@ function scheduleWork(fiber, expirationTime) { null !== fiber && (!isWorking && 0 !== nextRenderExpirationTime && - expirationTime > nextRenderExpirationTime && + expirationTime < nextRenderExpirationTime && resetStack(), markPendingPriorityLevel(fiber, expirationTime), (isWorking && !isCommitting$1 && nextRoot === fiber) || @@ -6063,25 +5490,27 @@ 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 = 1073741822 - ((originalStartTimeMs / 10) | 0), + currentRendererTime = ((originalStartTimeMs / 10) | 0) + 2, currentSchedulerTime = currentRendererTime, NESTED_UPDATE_LIMIT = 50, nestedUpdateCount = 0, - lastCommittedRootDuringThisBatch = null; + lastCommittedRootDuringThisBatch = null, + timeHeuristicForUnitOfWork = 1; function recomputeCurrentRendererTime() { - currentRendererTime = - 1073741822 - (((now$1() - originalStartTimeMs) / 10) | 0); + currentRendererTime = (((now$1() - originalStartTimeMs) / 10) | 0) + 2; } function scheduleCallbackWithExpirationTime(root, expirationTime) { if (0 !== callbackExpirationTime) { - if (expirationTime < callbackExpirationTime) return; + if (expirationTime > callbackExpirationTime) return; null !== callbackID && ((root = callbackID), (scheduledCallback = null), clearTimeout(root)); } @@ -6098,7 +5527,7 @@ function onSuspend( msUntilTimeout ) { root.expirationTime = rootExpirationTime; - 0 !== msUntilTimeout || shouldYieldToRenderer() + 0 !== msUntilTimeout || shouldYield() ? 0 < msUntilTimeout && (root.timeoutHandle = scheduleTimeout( onTimeout.bind(null, root, finishedWork, suspendedExpirationTime), @@ -6118,35 +5547,44 @@ function onTimeout(root, finishedWork, suspendedExpirationTime) { ); nextFlushedRoot = root; nextFlushedExpirationTime = suspendedExpirationTime; - performWorkOnRoot(root, suspendedExpirationTime, !1); - performWork(1073741823, !1); + performWorkOnRoot(root, suspendedExpirationTime, !0); + performWork(1, null); } function requestCurrentTime() { if (isRendering) return currentSchedulerTime; findHighestPriorityRoot(); - if (0 === nextFlushedExpirationTime || 1 === nextFlushedExpirationTime) + if ( + 0 === nextFlushedExpirationTime || + 1073741823 === nextFlushedExpirationTime + ) recomputeCurrentRendererTime(), (currentSchedulerTime = currentRendererTime); return currentSchedulerTime; } function requestWork(root, expirationTime) { - null === root.nextScheduledRoot - ? ((root.expirationTime = expirationTime), + if (null === root.nextScheduledRoot) + (root.expirationTime = expirationTime), null === lastScheduledRoot ? ((firstScheduledRoot = lastScheduledRoot = root), (root.nextScheduledRoot = root)) : ((lastScheduledRoot = lastScheduledRoot.nextScheduledRoot = root), - (lastScheduledRoot.nextScheduledRoot = firstScheduledRoot))) - : expirationTime > root.expirationTime && - (root.expirationTime = expirationTime); + (lastScheduledRoot.nextScheduledRoot = firstScheduledRoot)); + else { + var remainingExpirationTime = root.expirationTime; + if ( + 0 === remainingExpirationTime || + expirationTime < remainingExpirationTime + ) + root.expirationTime = expirationTime; + } isRendering || (isBatchingUpdates ? isUnbatchingUpdates && ((nextFlushedRoot = root), - (nextFlushedExpirationTime = 1073741823), - performWorkOnRoot(root, 1073741823, !1)) - : 1073741823 === expirationTime - ? performWork(1073741823, !1) + (nextFlushedExpirationTime = 1), + performWorkOnRoot(root, 1, !0)) + : 1 === expirationTime + ? performWork(1, null) : scheduleCallbackWithExpirationTime(root, expirationTime)); } function findHighestPriorityRoot() { @@ -6182,11 +5620,14 @@ function findHighestPriorityRoot() { (root.nextScheduledRoot = null); root = previousScheduledRoot.nextScheduledRoot; } else { - remainingExpirationTime > highestPriorityWork && - ((highestPriorityWork = remainingExpirationTime), - (highestPriorityRoot = root)); + if ( + 0 === highestPriorityWork || + remainingExpirationTime < highestPriorityWork + ) + (highestPriorityWork = remainingExpirationTime), + (highestPriorityRoot = root); if (root === lastScheduledRoot) break; - if (1073741823 === highestPriorityWork) break; + if (1 === highestPriorityWork) break; previousScheduledRoot = root; root = root.nextScheduledRoot; } @@ -6194,44 +5635,38 @@ function findHighestPriorityRoot() { nextFlushedRoot = highestPriorityRoot; nextFlushedExpirationTime = highestPriorityWork; } -var didYield = !1; -function shouldYieldToRenderer() { - return didYield ? !0 : frameDeadline <= now$1() ? (didYield = !0) : !1; -} -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 performAsyncWork(dl) { + if (dl.didTimeout && null !== firstScheduledRoot) { + recomputeCurrentRendererTime(); + var root = firstScheduledRoot; + do { + var expirationTime = root.expirationTime; + 0 !== expirationTime && + currentRendererTime >= expirationTime && + (root.nextExpirationTimeToWorkOn = currentRendererTime); + root = root.nextScheduledRoot; + } while (root !== firstScheduledRoot); } + performWork(0, dl); } -function performWork(minExpirationTime, isYieldy) { +function performWork(minExpirationTime, dl) { + deadline = dl; findHighestPriorityRoot(); - if (isYieldy) + if (null !== deadline) for ( recomputeCurrentRendererTime(), currentSchedulerTime = currentRendererTime; null !== nextFlushedRoot && 0 !== nextFlushedExpirationTime && - minExpirationTime <= nextFlushedExpirationTime && - !(didYield && currentRendererTime > nextFlushedExpirationTime); + (0 === minExpirationTime || + minExpirationTime >= nextFlushedExpirationTime) && + (!deadlineDidExpire || currentRendererTime >= nextFlushedExpirationTime); ) performWorkOnRoot( nextFlushedRoot, nextFlushedExpirationTime, - currentRendererTime > nextFlushedExpirationTime + currentRendererTime >= nextFlushedExpirationTime ), findHighestPriorityRoot(), recomputeCurrentRendererTime(), @@ -6241,28 +5676,29 @@ function performWork(minExpirationTime, isYieldy) { ; null !== nextFlushedRoot && 0 !== nextFlushedExpirationTime && - minExpirationTime <= nextFlushedExpirationTime; + (0 === minExpirationTime || + minExpirationTime >= nextFlushedExpirationTime); ) - performWorkOnRoot(nextFlushedRoot, nextFlushedExpirationTime, !1), + performWorkOnRoot(nextFlushedRoot, nextFlushedExpirationTime, !0), findHighestPriorityRoot(); - isYieldy && ((callbackExpirationTime = 0), (callbackID = null)); + null !== deadline && ((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, - isYieldy = 0; - isYieldy < minExpirationTime.length; - isYieldy++ + minExpirationTime = completedBatches, completedBatches = null, dl = 0; + dl < minExpirationTime.length; + dl++ ) { - var batch = minExpirationTime[isYieldy]; + var batch = minExpirationTime[dl]; try { batch._onComplete(); } catch (error) { @@ -6276,45 +5712,45 @@ function performWork(minExpirationTime, isYieldy) { (hasUnhandledError = !1), minExpirationTime); } -function performWorkOnRoot(root, expirationTime, isYieldy) { +function performWorkOnRoot(root, expirationTime, isExpired) { invariant( !isRendering, "performWorkOnRoot was called recursively. This error is likely caused by a bug in React. Please file an issue." ); isRendering = !0; - if (isYieldy) { - var _finishedWork = root.finishedWork; - null !== _finishedWork - ? completeRoot(root, _finishedWork, expirationTime) + if (null === deadline || isExpired) { + 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, isYieldy), - (_finishedWork = root.finishedWork), - null !== _finishedWork && - (shouldYieldToRenderer() - ? (root.finishedWork = _finishedWork) - : completeRoot(root, _finishedWork, expirationTime))); + (finishedWork = root.timeoutHandle), + -1 !== finishedWork && + ((root.timeoutHandle = -1), cancelTimeout(finishedWork)), + renderRoot(root, !1, isExpired), + (finishedWork = root.finishedWork), + null !== 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, isYieldy), - (_finishedWork = root.finishedWork), - null !== _finishedWork && - completeRoot(root, _finishedWork, expirationTime)); + (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))); 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), @@ -6343,7 +5779,9 @@ function completeRoot(root, finishedWork$jscomp$0, expirationTime) { var childExpirationTimeBeforeCommit = finishedWork$jscomp$0.childExpirationTime; firstBatch = - childExpirationTimeBeforeCommit > firstBatch + 0 === firstBatch || + (0 !== childExpirationTimeBeforeCommit && + childExpirationTimeBeforeCommit < firstBatch) ? childExpirationTimeBeforeCommit : firstBatch; root.didError = !1; @@ -6355,19 +5793,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; @@ -6382,17 +5820,13 @@ function completeRoot(root, finishedWork$jscomp$0, expirationTime) { var error = void 0; try { for (; null !== nextEffect; ) { - if (nextEffect.effectTag & 256) + if (nextEffect.effectTag & 256) { + var current$$1 = nextEffect.alternate; a: { - var current$$1 = nextEffect.alternate, - finishedWork = nextEffect; + var finishedWork = nextEffect; switch (finishedWork.tag) { - case 0: - case 11: - case 15: - commitHookEffectList(2, 0, finishedWork); - break a; - case 1: + case 2: + case 3: if (finishedWork.effectTag & 256 && null !== current$$1) { var prevProps = current$$1.memoizedProps, prevState = current$$1.memoizedState, @@ -6406,11 +5840,10 @@ 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( @@ -6419,6 +5852,7 @@ function completeRoot(root, finishedWork$jscomp$0, expirationTime) { ); } } + } nextEffect = nextEffect.nextEffect; } } catch (e) { @@ -6488,122 +5922,80 @@ function completeRoot(root, finishedWork$jscomp$0, expirationTime) { effectTag = !1; current$$1$jscomp$0 = void 0; try { - for ( - currentRef = root, current$$1 = expirationTime; - null !== nextEffect; - - ) { + for (currentRef = expirationTime; null !== nextEffect; ) { var effectTag$jscomp$0 = nextEffect.effectTag; if (effectTag$jscomp$0 & 36) { - prevState = void 0; var current$$1$jscomp$1 = nextEffect.alternate; - 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) + 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) if (null === current$$1$jscomp$1) - (instance$jscomp$0.props = prevProps.memoizedProps), - (instance$jscomp$0.state = prevProps.memoizedState), + (instance$jscomp$0.props = current$$1.memoizedProps), + (instance$jscomp$0.state = current$$1.memoizedState), instance$jscomp$0.componentDidMount(); else { var prevProps$jscomp$0 = current$$1$jscomp$1.memoizedProps, prevState$jscomp$0 = current$$1$jscomp$1.memoizedState; - instance$jscomp$0.props = prevProps.memoizedProps; - instance$jscomp$0.state = prevProps.memoizedState; + instance$jscomp$0.props = current$$1.memoizedProps; + instance$jscomp$0.state = current$$1.memoizedState; instance$jscomp$0.componentDidUpdate( prevProps$jscomp$0, prevState$jscomp$0, instance$jscomp$0.__reactInternalSnapshotBeforeUpdate ); } - var updateQueue = prevProps.updateQueue; + var updateQueue = current$$1.updateQueue; null !== updateQueue && - ((instance$jscomp$0.props = prevProps.memoizedProps), - (instance$jscomp$0.state = prevProps.memoizedState), + ((instance$jscomp$0.props = current$$1.memoizedProps), + (instance$jscomp$0.state = current$$1.memoizedState), commitUpdateQueue( - prevProps, + current$$1, updateQueue, instance$jscomp$0, - instance + prevProps )); break; - case 3: - var _updateQueue = prevProps.updateQueue; + case 5: + var _updateQueue = current$$1.updateQueue; if (null !== _updateQueue) { prevState = null; - if (null !== prevProps.child) - switch (prevProps.child.tag) { - case 5: - prevState = prevProps.child.stateNode; + if (null !== current$$1.child) + switch (current$$1.child.tag) { + case 7: + prevState = current$$1.child.stateNode; break; - case 1: - prevState = prevProps.child.stateNode; + case 2: + case 3: + prevState = current$$1.child.stateNode; } - commitUpdateQueue(prevProps, _updateQueue, prevState, instance); + commitUpdateQueue( + current$$1, + _updateQueue, + prevState, + prevProps + ); } break; - case 5: + case 7: + break; + case 8: break; case 6: break; - case 4: + case 15: break; - case 12: - break; - case 13: - if (prevProps.effectTag & 32) { - prevProps.memoizedState = { - alreadyCaptured: !0, - didTimeout: !1, - timedOutAt: 0 - }; - flushPassiveEffects(); - scheduleWork(prevProps, 1073741823); - 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 }; } - 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( @@ -6617,7 +6009,7 @@ function completeRoot(root, finishedWork$jscomp$0, expirationTime) { if (null !== ref) { var instance$jscomp$1 = nextEffect.stateNode; switch (nextEffect.tag) { - case 5: + case 7: var instanceToUse = instance$jscomp$1; break; default: @@ -6628,9 +6020,9 @@ function completeRoot(root, finishedWork$jscomp$0, expirationTime) { : (ref.current = instanceToUse); } } - effectTag$jscomp$0 & 512 && - (rootWithPendingPassiveEffects = currentRef); - nextEffect = nextEffect.nextEffect; + var next = nextEffect.nextEffect; + nextEffect.nextEffect = null; + nextEffect = next; } } catch (e) { (effectTag = !0), (current$$1$jscomp$0 = e); @@ -6643,20 +6035,14 @@ 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 = - finishedWork$jscomp$0 > effectTag$jscomp$0 + 0 === effectTag$jscomp$0 || + (0 !== finishedWork$jscomp$0 && finishedWork$jscomp$0 < effectTag$jscomp$0) ? finishedWork$jscomp$0 : effectTag$jscomp$0; 0 === finishedWork$jscomp$0 && @@ -6664,6 +6050,13 @@ 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, @@ -6672,6 +6065,55 @@ 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 && @@ -6690,48 +6132,7 @@ function updateContainer(element, container, parentComponent, callback) { currentTime = requestCurrentTime(); current$$1 = computeExpirationForFiber(currentTime, current$$1); currentTime = container.current; - 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; + parentComponent = getContextForSubtree(parentComponent); null === container.context ? (container.context = parentComponent) : (container.pendingContext = parentComponent); @@ -6740,7 +6141,6 @@ 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; @@ -6800,13 +6200,13 @@ _batchedUpdatesImpl = function(fn, a) { } finally { (isBatchingUpdates = previousIsBatchingUpdates) || isRendering || - performWork(1073741823, !1); + performWork(1, null); } }; _flushInteractiveUpdatesImpl = function() { isRendering || 0 === lowestPriorityPendingInteractiveExpirationTime || - (performWork(lowestPriorityPendingInteractiveExpirationTime, !1), + (performWork(lowestPriorityPendingInteractiveExpirationTime, null), (lowestPriorityPendingInteractiveExpirationTime = 0)); }; var roots = new Map(), @@ -6886,7 +6286,7 @@ var roots = new Map(), render: function(element, containerTag, callback) { var root = roots.get(containerTag); if (!root) { - root = createFiber(3, null, null, 0); + root = new FiberNode(5, null, null, 0); var root$jscomp$0 = { current: root, containerInfo: containerTag, @@ -6914,7 +6314,7 @@ var roots = new Map(), updateContainer(element, root, null, callback); a: if (((element = root.current), element.child)) switch (element.child.tag) { - case 5: + case 7: element = element.child.stateNode; break a; default: @@ -7021,7 +6421,7 @@ var roots = new Map(), findFiberByHostInstance: getInstanceFromTag, getInspectorDataForViewTag: getInspectorDataForViewTag, bundleType: 0, - version: "16.6.0", + version: "16.6.0-alpha.8af6728", 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 c13dbcc3708..3a9645d82e6 100644 --- a/Libraries/Renderer/oss/ReactNativeRenderer-profiling.js +++ b/Libraries/Renderer/oss/ReactNativeRenderer-profiling.js @@ -20,7 +20,6 @@ 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) { @@ -295,7 +294,7 @@ function getListener(inst, registrationName) { } function getParent(inst) { do inst = inst.return; - while (inst && 5 !== inst.tag); + while (inst && 7 !== inst.tag); return inst ? inst : null; } function traverseTwoPhase(inst, fn, arg) { @@ -1149,8 +1148,7 @@ var ReactSharedInternals = : 60111, REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for("react.forward_ref") : 60112, REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for("react.suspense") : 60113, - REACT_MEMO_TYPE = hasSymbol ? Symbol.for("react.memo") : 60115, - REACT_LAZY_TYPE = hasSymbol ? Symbol.for("react.lazy") : 60116, + REACT_PURE_TYPE = hasSymbol ? Symbol.for("react.pure") : 60115, MAYBE_ITERATOR_SYMBOL = "function" === typeof Symbol && Symbol.iterator; function getIteratorFn(maybeIterable) { if (null === maybeIterable || "object" !== typeof maybeIterable) return null; @@ -1159,6 +1157,13 @@ 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; @@ -1177,25 +1182,23 @@ 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: - 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); + return getWrappedName(type, type.render, "ForwardRef"); + case REACT_PURE_TYPE: + return getWrappedName(type, type.render, "Pure"); } + if ( + "function" === typeof type.then && + (type = 1 === type._reactStatus ? type._reactResult : null) + ) + return getComponentName(type); + } return null; } function isFiberMountedImpl(fiber) { @@ -1206,7 +1209,7 @@ function isFiberMountedImpl(fiber) { for (; node.return; ) if (((node = node.return), 0 !== (node.effectTag & 2))) return 1; } - return 3 === node.tag ? 2 : 3; + return 5 === node.tag ? 2 : 3; } function assertIsMounted(fiber) { invariant( @@ -1282,14 +1285,14 @@ function findCurrentFiberUsingSlowPath(fiber) { "Return fibers should always be each others' alternates. This error is likely caused by a bug in React. Please file an issue." ); } - invariant(3 === a.tag, "Unable to find node on an unmounted component."); + invariant(5 === a.tag, "Unable to find node on an unmounted component."); return a.stateNode.current === a ? fiber : alternate; } function findCurrentHostFiber(parent) { parent = findCurrentFiberUsingSlowPath(parent); if (!parent) return null; for (var node = parent; ; ) { - if (5 === node.tag || 6 === node.tag) return node; + if (7 === node.tag || 8 === node.tag) return node; if (node.child) (node.child.return = node), (node = node.child); else { if (node === parent) break; @@ -1597,12 +1600,18 @@ var ReactNativeFiberHostComponent = (function() { return Date.now(); }, scheduledCallback = null, - frameDeadline = 0; + frameDeadline = 0, + frameDeadlineObject = { + timeRemaining: function() { + return frameDeadline - now$1(); + }, + didTimeout: !1 + }; function setTimeoutCallback() { frameDeadline = now$1() + 5; var callback = scheduledCallback; scheduledCallback = null; - null !== callback && callback(); + null !== callback && callback(frameDeadlineObject); } function shim$1() { invariant( @@ -1643,13 +1652,13 @@ function getStackByFiberInDevAndProd(workInProgress) { var info = ""; do { a: switch (workInProgress.tag) { - case 2: - case 16: + case 4: case 0: case 1: - case 5: - case 8: - case 13: + case 2: + case 3: + case 7: + case 10: var owner = workInProgress._debugOwner, source = workInProgress._debugSource, name = getComponentName(workInProgress.type); @@ -1801,7 +1810,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 = this.elementType = null; + this.sibling = this.child = this.return = this.stateNode = this.type = null; this.index = 0; this.ref = null; this.pendingProps = pendingProps; @@ -1815,33 +1824,29 @@ 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(Component) { +function resolveLazyComponentTag(fiber, Component) { if ("function" === typeof Component) - return shouldConstruct(Component) ? 1 : 0; + return shouldConstruct(Component) ? 3 : 1; if (void 0 !== Component && null !== Component) { - Component = Component.$$typeof; - if (Component === REACT_FORWARD_REF_TYPE) return 11; - if (Component === REACT_MEMO_TYPE) return 14; + fiber = Component.$$typeof; + if (fiber === REACT_FORWARD_REF_TYPE) return 14; + if (fiber === REACT_PURE_TYPE) return 18; } - return 2; + return 4; } function createWorkInProgress(current, pendingProps) { var workInProgress = current.alternate; null === workInProgress - ? ((workInProgress = createFiber( + ? ((workInProgress = new FiberNode( current.tag, pendingProps, current.key, current.mode )), - (workInProgress.elementType = current.elementType), (workInProgress.type = current.type), (workInProgress.stateNode = current.stateNode), (workInProgress.alternate = current), @@ -1867,66 +1872,60 @@ function createWorkInProgress(current, pendingProps) { workInProgress.treeBaseDuration = current.treeBaseDuration; return workInProgress; } -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; +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; else a: switch (type) { case REACT_FRAGMENT_TYPE: return createFiberFromFragment( - pendingProps.children, + element.children, mode, expirationTime, key ); case REACT_CONCURRENT_MODE_TYPE: - return createFiberFromMode(pendingProps, mode | 3, expirationTime, key); + fiberTag = 10; + mode |= 3; + break; case REACT_STRICT_MODE_TYPE: - return createFiberFromMode(pendingProps, mode | 2, expirationTime, key); + fiberTag = 10; + mode |= 2; + break; case REACT_PROFILER_TYPE: return ( - (type = createFiber(12, pendingProps, key, mode | 4)), - (type.elementType = REACT_PROFILER_TYPE), + (type = new FiberNode(15, element, key, mode | 4)), (type.type = REACT_PROFILER_TYPE), (type.expirationTime = expirationTime), type ); case REACT_SUSPENSE_TYPE: - return ( - (type = createFiber(13, pendingProps, key, mode)), - (type.elementType = REACT_SUSPENSE_TYPE), - (type.type = REACT_SUSPENSE_TYPE), - (type.expirationTime = expirationTime), - type - ); + fiberTag = 16; + break; default: if ("object" === typeof type && null !== type) switch (type.$$typeof) { case REACT_PROVIDER_TYPE: - fiberTag = 10; + fiberTag = 12; break a; case REACT_CONTEXT_TYPE: - fiberTag = 9; - break a; - case REACT_FORWARD_REF_TYPE: fiberTag = 11; break a; - case REACT_MEMO_TYPE: - fiberTag = 14; + case REACT_FORWARD_REF_TYPE: + fiberTag = 13; break a; - case REACT_LAZY_TYPE: - fiberTag = 16; - owner = null; + case REACT_PURE_TYPE: + fiberTag = 17; break a; + default: + if ("function" === typeof type.then) { + fiberTag = 4; + break a; + } } invariant( !1, @@ -1935,33 +1934,24 @@ function createFiberFromTypeAndProps( "" ); } - key = createFiber(fiberTag, pendingProps, key, mode); - key.elementType = type; - key.type = owner; - key.expirationTime = expirationTime; - return key; + mode = new FiberNode(fiberTag, element, key, mode); + mode.type = type; + mode.expirationTime = expirationTime; + return mode; } function createFiberFromFragment(elements, mode, expirationTime, key) { - elements = createFiber(7, elements, key, mode); + elements = new FiberNode(9, 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 = createFiber(6, content, null, mode); + content = new FiberNode(8, content, null, mode); content.expirationTime = expirationTime; return content; } function createFiberFromPortal(portal, mode, expirationTime) { - mode = createFiber( - 4, + mode = new FiberNode( + 6, null !== portal.children ? portal.children : [], portal.key, mode @@ -1979,9 +1969,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); } @@ -1996,19 +1986,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); @@ -2018,17 +2008,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; @@ -2043,18 +2033,22 @@ 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; - earliestPendingTime > renderExpirationTime && - (renderExpirationTime = earliestPendingTime); - root > renderExpirationTime && (renderExpirationTime = root); + if ( + 0 === renderExpirationTime || + (0 !== earliestPendingTime && earliestPendingTime < renderExpirationTime) + ) + renderExpirationTime = earliestPendingTime; + if (0 === renderExpirationTime || (0 !== root && root < renderExpirationTime)) + renderExpirationTime = root; return renderExpirationTime; } function findNextExpirationTimeToWorkOn(completedExpirationTime, root) { @@ -2066,11 +2060,12 @@ function findNextExpirationTimeToWorkOn(completedExpirationTime, root) { 0 !== earliestPendingTime ? earliestPendingTime : latestPingedTime; 0 === earliestPendingTime && (0 === completedExpirationTime || - latestSuspendedTime < completedExpirationTime) && + latestSuspendedTime > completedExpirationTime) && (earliestPendingTime = latestSuspendedTime); completedExpirationTime = earliestPendingTime; 0 !== completedExpirationTime && - earliestSuspendedTime > completedExpirationTime && + 0 !== earliestSuspendedTime && + earliestSuspendedTime < completedExpirationTime && (completedExpirationTime = earliestSuspendedTime); root.nextExpirationTimeToWorkOn = earliestPendingTime; root.expirationTime = completedExpirationTime; @@ -2182,7 +2177,7 @@ function getStateFromUpdate( : workInProgress ); case 3: - workInProgress.effectTag = (workInProgress.effectTag & -2049) | 64; + workInProgress.effectTag = (workInProgress.effectTag & -1025) | 64; case 0: workInProgress = update.payload; nextProps = @@ -2215,52 +2210,58 @@ function processUpdateQueue( ) { var updateExpirationTime = update.expirationTime; - updateExpirationTime < renderExpirationTime - ? (null === newFirstUpdate && + if (updateExpirationTime > renderExpirationTime) { + if ( + (null === newFirstUpdate && ((newFirstUpdate = update), (newBaseState = resultState)), - newExpirationTime < updateExpirationTime && - (newExpirationTime = updateExpirationTime)) - : ((resultState = getStateFromUpdate( - workInProgress, - queue, - update, - resultState, - props, - instance - )), + 0 === newExpirationTime || newExpirationTime > updateExpirationTime) + ) + newExpirationTime = updateExpirationTime; + } else + (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; - _updateExpirationTime < renderExpirationTime - ? (null === updateExpirationTime && + if (_updateExpirationTime > renderExpirationTime) { + if ( + (null === updateExpirationTime && ((updateExpirationTime = update), null === newFirstUpdate && (newBaseState = resultState)), - newExpirationTime < _updateExpirationTime && - (newExpirationTime = _updateExpirationTime)) - : ((resultState = getStateFromUpdate( - workInProgress, - queue, - update, - resultState, - props, - instance - )), + 0 === newExpirationTime || newExpirationTime > _updateExpirationTime) + ) + newExpirationTime = _updateExpirationTime; + } else + (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); @@ -2341,277 +2342,13 @@ function readContext(context, observedBits) { null === lastContextDependency ? (invariant( null !== currentlyRenderingFiber, - "Context can only be read while React is rendering, e.g. inside the render method or getDerivedStateFromProps." + "Context.unstable_read(): 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 }, @@ -2691,8 +2428,7 @@ function shallowEqual(objA, objB) { return !1; return !0; } -var ReactCurrentOwner$4 = ReactSharedInternals.ReactCurrentOwner, - emptyRefsObject = new React.Component().refs; +var emptyRefsObject = new React.Component().refs; function applyDerivedStateFromProps( workInProgress, ctor, @@ -2724,7 +2460,6 @@ var classComponentUpdater = { var update = createUpdate(currentTime); update.payload = payload; void 0 !== callback && null !== callback && (update.callback = callback); - flushPassiveEffects(); enqueueUpdate(inst, update); scheduleWork(inst, currentTime); }, @@ -2736,7 +2471,6 @@ var classComponentUpdater = { update.tag = 1; update.payload = payload; void 0 !== callback && null !== callback && (update.callback = callback); - flushPassiveEffects(); enqueueUpdate(inst, update); scheduleWork(inst, currentTime); }, @@ -2747,7 +2481,6 @@ var classComponentUpdater = { var update = createUpdate(currentTime); update.tag = 2; void 0 !== callback && null !== callback && (update.callback = callback); - flushPassiveEffects(); enqueueUpdate(inst, update); scheduleWork(inst, currentTime); } @@ -2768,32 +2501,6 @@ 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, @@ -2820,9 +2527,7 @@ function mountClassInstance( instance.refs = emptyRefsObject; var contextType = ctor.contextType; "object" === typeof contextType && null !== contextType - ? (instance.context = ReactCurrentOwner$4.currentDispatcher.readContext( - contextType - )) + ? (instance.context = contextType.unstable_read()) : ((contextType = isContextProvider(ctor) ? previousContext : contextStackCursor.current), @@ -2877,7 +2582,10 @@ function coerceRef(returnFiber, current$$1, element) { element = element._owner; var inst = void 0; element && - (invariant(1 === element.tag, "Function components cannot have refs."), + (invariant( + 2 === element.tag || 3 === element.tag, + "Function components cannot have refs." + ), (inst = element.stateNode)); invariant( inst, @@ -2982,7 +2690,7 @@ function ChildReconciler(shouldTrackSideEffects) { textContent, expirationTime ) { - if (null === current$$1 || 6 !== current$$1.tag) + if (null === current$$1 || 8 !== current$$1.tag) return ( (current$$1 = createFiberFromText( textContent, @@ -2997,18 +2705,15 @@ function ChildReconciler(shouldTrackSideEffects) { return current$$1; } function updateElement(returnFiber, current$$1, element, expirationTime) { - if (null !== current$$1 && current$$1.elementType === element.type) + if (null !== current$$1 && current$$1.type === element.type) return ( (expirationTime = useFiber(current$$1, element.props, expirationTime)), (expirationTime.ref = coerceRef(returnFiber, current$$1, element)), (expirationTime.return = returnFiber), expirationTime ); - expirationTime = createFiberFromTypeAndProps( - element.type, - element.key, - element.props, - null, + expirationTime = createFiberFromElement( + element, returnFiber.mode, expirationTime ); @@ -3019,7 +2724,7 @@ function ChildReconciler(shouldTrackSideEffects) { function updatePortal(returnFiber, current$$1, portal, expirationTime) { if ( null === current$$1 || - 4 !== current$$1.tag || + 6 !== current$$1.tag || current$$1.stateNode.containerInfo !== portal.containerInfo || current$$1.stateNode.implementation !== portal.implementation ) @@ -3043,7 +2748,7 @@ function ChildReconciler(shouldTrackSideEffects) { expirationTime, key ) { - if (null === current$$1 || 7 !== current$$1.tag) + if (null === current$$1 || 9 !== current$$1.tag) return ( (current$$1 = createFiberFromFragment( fragment, @@ -3073,11 +2778,8 @@ function ChildReconciler(shouldTrackSideEffects) { switch (newChild.$$typeof) { case REACT_ELEMENT_TYPE: return ( - (expirationTime = createFiberFromTypeAndProps( - newChild.type, - newChild.key, - newChild.props, - null, + (expirationTime = createFiberFromElement( + newChild, returnFiber.mode, expirationTime )), @@ -3421,9 +3123,9 @@ function ChildReconciler(shouldTrackSideEffects) { ) { if (isUnkeyedTopLevelFragment.key === isObject) if ( - 7 === isUnkeyedTopLevelFragment.tag + 9 === isUnkeyedTopLevelFragment.tag ? newChild.type === REACT_FRAGMENT_TYPE - : isUnkeyedTopLevelFragment.elementType === newChild.type + : isUnkeyedTopLevelFragment.type === newChild.type ) { deleteRemainingChildren( returnFiber, @@ -3463,11 +3165,8 @@ function ChildReconciler(shouldTrackSideEffects) { )), (currentFirstChild.return = returnFiber), (returnFiber = currentFirstChild)) - : ((expirationTime = createFiberFromTypeAndProps( - newChild.type, - newChild.key, - newChild.props, - null, + : ((expirationTime = createFiberFromElement( + newChild, returnFiber.mode, expirationTime )), @@ -3489,7 +3188,7 @@ function ChildReconciler(shouldTrackSideEffects) { ) { if (currentFirstChild.key === isUnkeyedTopLevelFragment) if ( - 4 === currentFirstChild.tag && + 6 === currentFirstChild.tag && currentFirstChild.stateNode.containerInfo === newChild.containerInfo && currentFirstChild.stateNode.implementation === @@ -3527,7 +3226,7 @@ function ChildReconciler(shouldTrackSideEffects) { if ("string" === typeof newChild || "number" === typeof newChild) return ( (newChild = "" + newChild), - null !== currentFirstChild && 6 === currentFirstChild.tag + null !== currentFirstChild && 8 === currentFirstChild.tag ? (deleteRemainingChildren(returnFiber, currentFirstChild.sibling), (currentFirstChild = useFiber( currentFirstChild, @@ -3563,7 +3262,8 @@ function ChildReconciler(shouldTrackSideEffects) { isObject && throwOnInvalidObjectType(returnFiber, newChild); if ("undefined" === typeof newChild && !isUnkeyedTopLevelFragment) switch (returnFiber.tag) { - case 1: + case 2: + case 3: case 0: (expirationTime = returnFiber.type), invariant( @@ -3582,12 +3282,12 @@ var reconcileChildFibers = ChildReconciler(!0), isHydrating = !1; function tryHydrate(fiber, nextInstance) { switch (fiber.tag) { - case 5: + case 7: return ( (nextInstance = shim$1(nextInstance, fiber.type, fiber.pendingProps)), null !== nextInstance ? ((fiber.stateNode = nextInstance), !0) : !1 ); - case 6: + case 8: return ( (nextInstance = shim$1(nextInstance, fiber.pendingProps)), null !== nextInstance ? ((fiber.stateNode = nextInstance), !0) : !1 @@ -3610,8 +3310,7 @@ function tryToClaimNextHydratableInstance(fiber$jscomp$0) { return; } var returnFiber = hydrationParentFiber, - fiber = createFiber(5, null, null, 0); - fiber.elementType = "DELETED"; + fiber = new FiberNode(7, null, null, 0); fiber.type = "DELETED"; fiber.stateNode = firstAttemptedInstance; fiber.return = returnFiber; @@ -3629,33 +3328,36 @@ function tryToClaimNextHydratableInstance(fiber$jscomp$0) { (hydrationParentFiber = fiber$jscomp$0); } } -function readLazyComponentType(lazyComponent) { - var result = lazyComponent._result; - switch (lazyComponent._status) { +function readLazyComponentType(thenable) { + switch (thenable._reactStatus) { case 1: - return result; + return thenable._reactResult; case 2: - throw result; + throw thenable._reactResult; case 0: - throw result; + throw thenable; default: - 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)); + throw ((thenable._reactStatus = 0), + thenable.then( + function(resolvedValue) { + if (0 === thenable._reactStatus) { + thenable._reactStatus = 1; + if ("object" === typeof resolvedValue && null !== resolvedValue) { + var defaultExport = resolvedValue.default; + resolvedValue = + void 0 !== defaultExport && null !== defaultExport + ? defaultExport + : resolvedValue; + } + thenable._reactResult = resolvedValue; + } }, function(error) { - 0 === lazyComponent._status && - ((lazyComponent._status = 2), (lazyComponent._result = error)); + 0 === thenable._reactStatus && + ((thenable._reactStatus = 2), (thenable._reactResult = error)); } ), - (lazyComponent._result = result), - result); + thenable); } } var ReactCurrentOwner$3 = ReactSharedInternals.ReactCurrentOwner; @@ -3683,87 +3385,28 @@ function reconcileChildren( function updateForwardRef( current$$1, workInProgress, - Component, + type, nextProps, - renderExpirationTime$jscomp$0 -) { - Component = Component.render; - var ref = workInProgress.ref; - 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 updateMemoComponent( - current$$1, - workInProgress, - Component, - nextProps, - updateExpirationTime, renderExpirationTime ) { - 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; + type = type.render; + var ref = workInProgress.ref; if ( - updateExpirationTime < renderExpirationTime && - ((updateExpirationTime = type.memoizedProps), - (Component = Component.compare), - (Component = null !== Component ? Component : shallowEqual), - Component(updateExpirationTime, nextProps) && - current$$1.ref === workInProgress.ref) + !didPerformWorkStackCursor.current && + workInProgress.memoizedProps === nextProps && + ref === (null !== current$$1 ? current$$1.ref : null) ) return bailoutOnAlreadyFinishedWork( current$$1, workInProgress, renderExpirationTime ); - current$$1 = createWorkInProgress(type, nextProps, renderExpirationTime); - current$$1.ref = workInProgress.ref; - current$$1.return = workInProgress; - return (workInProgress.child = current$$1); + type = type(nextProps, ref); + reconcileChildren(current$$1, workInProgress, type, renderExpirationTime); + workInProgress.memoizedProps = nextProps; + return workInProgress.child; } -function updateSimpleMemoComponent( +function updatePureComponent( current$$1, workInProgress, Component, @@ -3771,22 +3414,29 @@ function updateSimpleMemoComponent( 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 - ); + var render = Component.render, + ref = workInProgress.ref; + if ( + null !== current$$1 && + (0 === updateExpirationTime || + updateExpirationTime > renderExpirationTime) && + ((updateExpirationTime = current$$1.memoizedProps), + (Component = Component.compare), + (Component = null !== Component ? Component : shallowEqual), + workInProgress.ref === current$$1.ref && + Component(updateExpirationTime, nextProps)) + ) + 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; } function markRef(current$$1, workInProgress) { var ref = workInProgress.ref; @@ -3801,30 +3451,22 @@ function updateFunctionComponent( workInProgress, Component, nextProps, - renderExpirationTime$jscomp$0 + renderExpirationTime ) { var unmaskedContext = isContextProvider(Component) ? previousContext : contextStackCursor.current; unmaskedContext = getMaskedContext(workInProgress, 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 - ); + prepareToReadContext(workInProgress, renderExpirationTime); + Component = Component(nextProps, unmaskedContext); workInProgress.effectTag |= 1; reconcileChildren( current$$1, workInProgress, - nextChildren, - renderExpirationTime$jscomp$0 + Component, + renderExpirationTime ); + workInProgress.memoizedProps = nextProps; return workInProgress.child; } function updateClassComponent( @@ -3839,149 +3481,166 @@ function updateClassComponent( pushContextProvider(workInProgress); } else hasContext = !1; prepareToReadContext(workInProgress, renderExpirationTime); - if (null === workInProgress.stateNode) - null !== current$$1 && - ((current$$1.alternate = null), - (workInProgress.alternate = null), - (workInProgress.effectTag |= 2)), - constructClassInstance( - workInProgress, - Component, - nextProps, - 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)); mountClassInstance( workInProgress, Component, nextProps, renderExpirationTime - ), - (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 instance.getSnapshotBeforeUpdate; - hasNewLifecycles || - ("function" !== typeof instance.UNSAFE_componentWillReceiveProps && - "function" !== typeof instance.componentWillReceiveProps) || - ((oldProps !== nextProps || oldContext !== contextType) && - callComponentWillReceiveProps( - workInProgress, - instance, - nextProps, - 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) + ); + 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), - (contextType = getMaskedContext(workInProgress, contextType))), - (getDerivedStateFromProps = Component.getDerivedStateFromProps), - (hasNewLifecycles = + (context = getMaskedContext(workInProgress, context))); + var getDerivedStateFromProps = Component.getDerivedStateFromProps; + (instance = "function" === typeof getDerivedStateFromProps || - "function" === typeof instance.getSnapshotBeforeUpdate) || - ("function" !== typeof instance.UNSAFE_componentWillReceiveProps && - "function" !== typeof instance.componentWillReceiveProps) || - ((oldProps !== nextProps || oldContext !== contextType) && + "function" === typeof unmaskedContext.getSnapshotBeforeUpdate) || + ("function" !== + typeof unmaskedContext.UNSAFE_componentWillReceiveProps && + "function" !== typeof unmaskedContext.componentWillReceiveProps) || + ((isLegacyContextConsumer !== nextProps || oldContext !== context) && callComponentWillReceiveProps( workInProgress, - instance, + unmaskedContext, nextProps, - contextType + context + )); + hasForceUpdate = !1; + var oldState = workInProgress.memoizedState; + oldContext = unmaskedContext.state = oldState; + var updateQueue = workInProgress.updateQueue; + null !== updateQueue && + (processUpdateQueue( + workInProgress, + updateQueue, + nextProps, + unmaskedContext, + renderExpirationTime + ), + (oldContext = workInProgress.memoizedState)); + 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) + ? previousContext + : contextStackCursor.current), + (context = getMaskedContext(workInProgress, context))), + (getDerivedStateFromProps = Component.getDerivedStateFromProps), + (instance = + "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), (oldContext = workInProgress.memoizedState), - (oldState = instance.state = oldContext), + (oldState = unmaskedContext.state = oldContext), (updateQueue = workInProgress.updateQueue), null !== updateQueue && (processUpdateQueue( workInProgress, updateQueue, nextProps, - instance, + unmaskedContext, renderExpirationTime ), (oldState = workInProgress.memoizedState)), - oldProps !== nextProps || + isLegacyContextConsumer !== nextProps || oldContext !== oldState || didPerformWorkStackCursor.current || hasForceUpdate @@ -3998,51 +3657,53 @@ function updateClassComponent( checkShouldComponentUpdate( workInProgress, Component, - oldProps, + isLegacyContextConsumer, nextProps, oldContext, oldState, - contextType + context )) - ? (hasNewLifecycles || - ("function" !== typeof instance.UNSAFE_componentWillUpdate && - "function" !== typeof instance.componentWillUpdate) || - ("function" === typeof instance.componentWillUpdate && - instance.componentWillUpdate( + ? (instance || + ("function" !== + typeof unmaskedContext.UNSAFE_componentWillUpdate && + "function" !== typeof unmaskedContext.componentWillUpdate) || + ("function" === typeof unmaskedContext.componentWillUpdate && + unmaskedContext.componentWillUpdate( nextProps, oldState, - contextType + context ), - "function" === typeof instance.UNSAFE_componentWillUpdate && - instance.UNSAFE_componentWillUpdate( + "function" === + typeof unmaskedContext.UNSAFE_componentWillUpdate && + unmaskedContext.UNSAFE_componentWillUpdate( nextProps, oldState, - contextType + context )), - "function" === typeof instance.componentDidUpdate && + "function" === typeof unmaskedContext.componentDidUpdate && (workInProgress.effectTag |= 4), - "function" === typeof instance.getSnapshotBeforeUpdate && + "function" === typeof unmaskedContext.getSnapshotBeforeUpdate && (workInProgress.effectTag |= 256)) - : ("function" !== typeof instance.componentDidUpdate || - (oldProps === current$$1.memoizedProps && + : ("function" !== typeof unmaskedContext.componentDidUpdate || + (isLegacyContextConsumer === current$$1.memoizedProps && oldContext === current$$1.memoizedState) || (workInProgress.effectTag |= 4), - "function" !== typeof instance.getSnapshotBeforeUpdate || - (oldProps === current$$1.memoizedProps && + "function" !== typeof unmaskedContext.getSnapshotBeforeUpdate || + (isLegacyContextConsumer === current$$1.memoizedProps && oldContext === current$$1.memoizedState) || (workInProgress.effectTag |= 256), (workInProgress.memoizedProps = nextProps), (workInProgress.memoizedState = oldState)), - (instance.props = nextProps), - (instance.state = oldState), - (instance.context = contextType), + (unmaskedContext.props = nextProps), + (unmaskedContext.state = oldState), + (unmaskedContext.context = context), (nextProps = getDerivedStateFromProps)) - : ("function" !== typeof instance.componentDidUpdate || - (oldProps === current$$1.memoizedProps && + : ("function" !== typeof unmaskedContext.componentDidUpdate || + (isLegacyContextConsumer === current$$1.memoizedProps && oldContext === current$$1.memoizedState) || (workInProgress.effectTag |= 4), - "function" !== typeof instance.getSnapshotBeforeUpdate || - (oldProps === current$$1.memoizedProps && + "function" !== typeof unmaskedContext.getSnapshotBeforeUpdate || + (isLegacyContextConsumer === current$$1.memoizedProps && oldContext === current$$1.memoizedState) || (workInProgress.effectTag |= 256), (nextProps = !1)); @@ -4105,6 +3766,7 @@ function finishClassComponent( renderExpirationTime ); workInProgress.memoizedState = shouldUpdate.state; + workInProgress.memoizedProps = shouldUpdate.props; hasContext && invalidateContextProvider(workInProgress, Component, !0); return workInProgress.child; } @@ -4130,105 +3792,6 @@ 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, @@ -4237,7 +3800,9 @@ function bailoutOnAlreadyFinishedWork( null !== current$$1 && (workInProgress.firstContextDependency = current$$1.firstContextDependency); profilerStartTime = -1; - if (workInProgress.childExpirationTime < renderExpirationTime) return null; + var childExpirationTime = workInProgress.childExpirationTime; + if (0 === childExpirationTime || childExpirationTime > renderExpirationTime) + return null; invariant( null === current$$1 || workInProgress.child === current$$1.child, "Resuming work not yet implemented." @@ -4266,566 +3831,561 @@ function bailoutOnAlreadyFinishedWork( } return workInProgress.child; } -function beginWork(current$$1, workInProgress, renderExpirationTime$jscomp$0) { +function beginWork(current$$1, workInProgress, renderExpirationTime) { var updateExpirationTime = workInProgress.expirationTime; if ( null !== current$$1 && current$$1.memoizedProps === workInProgress.pendingProps && !didPerformWorkStackCursor.current && - updateExpirationTime < renderExpirationTime$jscomp$0 + (0 === updateExpirationTime || updateExpirationTime > renderExpirationTime) ) { switch (workInProgress.tag) { - case 3: + case 5: pushHostRootContext(workInProgress); break; - case 5: + case 7: pushHostContext(workInProgress); break; - case 1: + case 2: isContextProvider(workInProgress.type) && pushContextProvider(workInProgress); break; - case 4: + case 3: + isContextProvider(workInProgress.type._reactResult) && + pushContextProvider(workInProgress); + break; + case 6: pushHostContainer( workInProgress, workInProgress.stateNode.containerInfo ); break; - case 10: + case 12: pushProvider(workInProgress, workInProgress.memoizedProps.value); break; - case 12: + case 15: 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$jscomp$0 + renderExpirationTime ); } workInProgress.expirationTime = 0; switch (workInProgress.tag) { - 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, - contextStackCursor.current + 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." ); - prepareToReadContext(workInProgress, renderExpirationTime$jscomp$0); - renderExpirationTime = renderExpirationTime$jscomp$0; - currentlyRenderingFiber$1 = workInProgress; - firstCurrentHook = null; - var value = updateExpirationTime(current$$1, context); - workInProgress.effectTag |= 1; + var props = workInProgress.pendingProps; if ( - "object" === typeof value && - null !== value && - "function" === typeof value.render && - void 0 === value.$$typeof + "object" === typeof Component && + null !== Component && + "function" === typeof Component.then ) { - 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( + Component = readLazyComponentType(Component); + var resolvedTag = (workInProgress.tag = resolveLazyComponentTag( 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 + Component )), - 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, + 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, - updateExpirationTime, - value, - renderExpirationTime$jscomp$0 - ) + 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, + workInProgress, + workInProgress.type, + workInProgress.pendingProps, + renderExpirationTime ); case 1: return ( - (updateExpirationTime = workInProgress.type), - (value = workInProgress.pendingProps), - (value = - workInProgress.elementType === updateExpirationTime - ? value - : resolveDefaultProps(updateExpirationTime, value)), - updateClassComponent( + (props = workInProgress.type._reactResult), + (Component = workInProgress.pendingProps), + (current$$1 = updateFunctionComponent( current$$1, workInProgress, - updateExpirationTime, - value, - renderExpirationTime$jscomp$0 - ) + props, + resolveDefaultProps(props, Component), + renderExpirationTime + )), + (workInProgress.memoizedProps = Component), + current$$1 + ); + case 2: + return updateClassComponent( + current$$1, + workInProgress, + workInProgress.type, + workInProgress.pendingProps, + renderExpirationTime ); 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), - (updateExpirationTime = workInProgress.updateQueue), + (Component = workInProgress.updateQueue), invariant( - null !== updateExpirationTime, + null !== Component, "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." ), - (value = workInProgress.memoizedState), - (value = null !== value ? value.element : null), + (props = workInProgress.memoizedState), + (props = null !== props ? props.element : null), processUpdateQueue( workInProgress, - updateExpirationTime, + Component, workInProgress.pendingProps, null, - renderExpirationTime$jscomp$0 + renderExpirationTime ), - (updateExpirationTime = workInProgress.memoizedState.element), - updateExpirationTime === value + (Component = workInProgress.memoizedState.element), + Component === props ? (workInProgress = bailoutOnAlreadyFinishedWork( current$$1, workInProgress, - renderExpirationTime$jscomp$0 + renderExpirationTime )) : (reconcileChildren( current$$1, workInProgress, - updateExpirationTime, - renderExpirationTime$jscomp$0 + Component, + renderExpirationTime ), (workInProgress = workInProgress.child)), workInProgress ); - case 5: + case 7: return ( pushHostContext(workInProgress), null === current$$1 && tryToClaimNextHydratableInstance(workInProgress), - (updateExpirationTime = workInProgress.pendingProps.children), + (Component = workInProgress.pendingProps), + (props = Component.children), markRef(current$$1, workInProgress), reconcileChildren( current$$1, workInProgress, - updateExpirationTime, - renderExpirationTime$jscomp$0 + props, + renderExpirationTime ), + (workInProgress.memoizedProps = Component), (workInProgress = workInProgress.child), workInProgress ); - case 6: + case 8: return ( null === current$$1 && tryToClaimNextHydratableInstance(workInProgress), + (workInProgress.memoizedProps = workInProgress.pendingProps), null ); - case 13: - return updateSuspenseComponent( - current$$1, - workInProgress, - renderExpirationTime$jscomp$0 + 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 4: + case 6: return ( pushHostContainer( workInProgress, workInProgress.stateNode.containerInfo ), - (updateExpirationTime = workInProgress.pendingProps), + (Component = workInProgress.pendingProps), null === current$$1 ? (workInProgress.child = reconcileChildFibers( workInProgress, null, - updateExpirationTime, - renderExpirationTime$jscomp$0 + Component, + renderExpirationTime )) : reconcileChildren( current$$1, workInProgress, - updateExpirationTime, - renderExpirationTime$jscomp$0 + Component, + renderExpirationTime ), + (workInProgress.memoizedProps = Component), workInProgress.child ); - case 11: + case 13: + return updateForwardRef( + current$$1, + workInProgress, + workInProgress.type, + workInProgress.pendingProps, + renderExpirationTime + ); + case 14: return ( - (updateExpirationTime = workInProgress.type), - (value = workInProgress.pendingProps), - (value = - workInProgress.elementType === updateExpirationTime - ? value - : resolveDefaultProps(updateExpirationTime, value)), - updateForwardRef( + (props = workInProgress.type._reactResult), + (Component = workInProgress.pendingProps), + (current$$1 = updateForwardRef( current$$1, workInProgress, - updateExpirationTime, - value, - renderExpirationTime$jscomp$0 - ) + props, + resolveDefaultProps(props, Component), + renderExpirationTime + )), + (workInProgress.memoizedProps = Component), + current$$1 ); - case 7: + case 9: return ( + (Component = workInProgress.pendingProps), reconcileChildren( current$$1, workInProgress, - workInProgress.pendingProps, - renderExpirationTime$jscomp$0 - ), - workInProgress.child - ); - case 8: - return ( - reconcileChildren( - current$$1, - workInProgress, - workInProgress.pendingProps.children, - renderExpirationTime$jscomp$0 - ), - workInProgress.child - ); - case 12: - return ( - (workInProgress.effectTag |= 4), - reconcileChildren( - current$$1, - workInProgress, - workInProgress.pendingProps.children, - renderExpirationTime$jscomp$0 + Component, + renderExpirationTime ), + (workInProgress.memoizedProps = Component), workInProgress.child ); case 10: + return ( + (Component = workInProgress.pendingProps.children), + reconcileChildren( + current$$1, + workInProgress, + Component, + renderExpirationTime + ), + (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: a: { - 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) { + 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) + ) { if ( - getDerivedStateFromProps.children === value.children && + resolvedTag.children === props.children && !didPerformWorkStackCursor.current ) { workInProgress = bailoutOnAlreadyFinishedWork( current$$1, workInProgress, - renderExpirationTime$jscomp$0 + renderExpirationTime ); break a; } } else for ( - getDerivedStateFromProps = workInProgress.child, - null !== getDerivedStateFromProps && - (getDerivedStateFromProps.return = workInProgress); - null !== getDerivedStateFromProps; + resolvedTag = workInProgress.child, + null !== resolvedTag && (resolvedTag.return = workInProgress); + null !== resolvedTag; ) { - oldValue = getDerivedStateFromProps.firstContextDependency; - if (null !== oldValue) { + resolvedProps = resolvedTag.firstContextDependency; + if (null !== resolvedProps) { do { if ( - oldValue.context === updateExpirationTime && - 0 !== (oldValue.observedBits & context) + resolvedProps.context === Component && + 0 !== (resolvedProps.observedBits & updateExpirationTime) ) { - 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 (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 ( - node.childExpirationTime < renderExpirationTime$jscomp$0 + 0 === node.childExpirationTime || + node.childExpirationTime > renderExpirationTime ) - (node.childExpirationTime = renderExpirationTime$jscomp$0), - null !== nextFiber && - nextFiber.childExpirationTime < - renderExpirationTime$jscomp$0 && - (nextFiber.childExpirationTime = renderExpirationTime$jscomp$0); + (node.childExpirationTime = renderExpirationTime), + null !== child && + (0 === child.childExpirationTime || + child.childExpirationTime > + renderExpirationTime) && + (child.childExpirationTime = renderExpirationTime); else if ( - null !== nextFiber && - nextFiber.childExpirationTime < - renderExpirationTime$jscomp$0 + null !== child && + (0 === child.childExpirationTime || + child.childExpirationTime > renderExpirationTime) ) - nextFiber.childExpirationTime = renderExpirationTime$jscomp$0; + child.childExpirationTime = renderExpirationTime; else break; node = node.return; } } - nextFiber = getDerivedStateFromProps.child; - oldValue = oldValue.next; - } while (null !== oldValue); + child = resolvedTag.child; + resolvedProps = resolvedProps.next; + } while (null !== resolvedProps); } else - nextFiber = - 10 === getDerivedStateFromProps.tag - ? getDerivedStateFromProps.type === workInProgress.type + child = + 12 === resolvedTag.tag + ? resolvedTag.type === workInProgress.type ? null - : getDerivedStateFromProps.child - : getDerivedStateFromProps.child; - if (null !== nextFiber) - nextFiber.return = getDerivedStateFromProps; + : resolvedTag.child + : resolvedTag.child; + if (null !== child) child.return = resolvedTag; else - for ( - nextFiber = getDerivedStateFromProps; - null !== nextFiber; - - ) { - if (nextFiber === workInProgress) { - nextFiber = null; + for (child = resolvedTag; null !== child; ) { + if (child === workInProgress) { + child = null; break; } - getDerivedStateFromProps = nextFiber.sibling; - if (null !== getDerivedStateFromProps) { - getDerivedStateFromProps.return = nextFiber.return; - nextFiber = getDerivedStateFromProps; + resolvedTag = child.sibling; + if (null !== resolvedTag) { + resolvedTag.return = child.return; + child = resolvedTag; break; } - nextFiber = nextFiber.return; + child = child.return; } - getDerivedStateFromProps = nextFiber; + resolvedTag = child; } - } reconcileChildren( current$$1, workInProgress, - value.children, - renderExpirationTime$jscomp$0 + props.children, + renderExpirationTime ); workInProgress = workInProgress.child; } return workInProgress; - case 9: + case 11: return ( - (value = workInProgress.type), - (context = workInProgress.pendingProps), - (updateExpirationTime = context.children), - prepareToReadContext(workInProgress, renderExpirationTime$jscomp$0), - (value = readContext(value, context.unstable_observedBits)), - (updateExpirationTime = updateExpirationTime(value)), + (updateExpirationTime = workInProgress.type), + (Component = workInProgress.pendingProps), + (props = Component.children), + prepareToReadContext(workInProgress, renderExpirationTime), + (updateExpirationTime = readContext( + updateExpirationTime, + Component.unstable_observedBits + )), + (props = props(updateExpirationTime)), (workInProgress.effectTag |= 1), reconcileChildren( current$$1, workInProgress, - updateExpirationTime, - renderExpirationTime$jscomp$0 + props, + renderExpirationTime ), + (workInProgress.memoizedProps = Component), workInProgress.child ); - 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( + case 17: + return updatePureComponent( current$$1, workInProgress, workInProgress.type, workInProgress.pendingProps, updateExpirationTime, - renderExpirationTime$jscomp$0 + renderExpirationTime ); - case 17: + case 18: return ( - (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, - updateExpirationTime, - value, - renderExpirationTime$jscomp$0 - ), - mountClassInstance( - workInProgress, - updateExpirationTime, - value, - renderExpirationTime$jscomp$0 - ), - finishClassComponent( - null, - workInProgress, - updateExpirationTime, - !0, + (props = workInProgress.type._reactResult), + (Component = workInProgress.pendingProps), + (current$$1 = updatePureComponent( current$$1, - renderExpirationTime$jscomp$0 - ) + workInProgress, + props, + resolveDefaultProps(props, Component), + updateExpirationTime, + renderExpirationTime + )), + (workInProgress.memoizedProps = Component), + current$$1 ); default: invariant( @@ -4834,27 +4394,9 @@ function beginWork(current$$1, workInProgress, renderExpirationTime$jscomp$0) { ); } } -var appendAllChildren = void 0, - updateHostContainer = void 0, +var 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 && @@ -4884,6 +4426,7 @@ 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; @@ -4900,7 +4443,7 @@ function logError(boundary, errorInfo) { willRetry: !1 }; null !== boundary && - 1 === boundary.tag && + 2 === boundary.tag && ((errorInfo.errorBoundary = boundary.stateNode), (errorInfo.errorBoundaryName = getComponentName(boundary.type)), (errorInfo.errorBoundaryFound = !0), @@ -4924,74 +4467,32 @@ 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 commitUnmount(current$$1$jscomp$0) { +function commitUnmount(current$$1) { "function" === typeof onCommitFiberUnmount && - 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) + onCommitFiberUnmount(current$$1); + switch (current$$1.tag) { + case 2: + case 3: + safelyDetachRef(current$$1); + var instance = current$$1.stateNode; + if ("function" === typeof instance.componentWillUnmount) try { - (updateQueue.props = current$$1$jscomp$0.memoizedProps), - (updateQueue.state = current$$1$jscomp$0.memoizedState), - updateQueue.componentWillUnmount(); + (instance.props = current$$1.memoizedProps), + (instance.state = current$$1.memoizedState), + instance.componentWillUnmount(); } catch (unmountError) { - captureCommitPhaseError(current$$1$jscomp$0, unmountError); + captureCommitPhaseError(current$$1, unmountError); } break; - case 5: - safelyDetachRef(current$$1$jscomp$0); + case 7: + safelyDetachRef(current$$1); break; - case 4: - unmountHostComponents(current$$1$jscomp$0); + case 6: + unmountHostComponents(current$$1); } } function isHostParent(fiber) { - return 5 === fiber.tag || 3 === fiber.tag || 4 === fiber.tag; + return 7 === fiber.tag || 5 === fiber.tag || 6 === fiber.tag; } function commitPlacement(finishedWork) { a: { @@ -5010,15 +4511,15 @@ function commitPlacement(finishedWork) { } var isContainer = (parent = void 0); switch (parentFiber.tag) { - case 5: + case 7: parent = parentFiber.stateNode; isContainer = !1; break; - case 3: + case 5: parent = parentFiber.stateNode.containerInfo; isContainer = !0; break; - case 4: + case 6: parent = parentFiber.stateNode.containerInfo; isContainer = !0; break; @@ -5040,11 +4541,11 @@ function commitPlacement(finishedWork) { parentFiber.sibling.return = parentFiber.return; for ( parentFiber = parentFiber.sibling; - 5 !== parentFiber.tag && 6 !== parentFiber.tag; + 7 !== parentFiber.tag && 8 !== parentFiber.tag; ) { if (parentFiber.effectTag & 2) continue b; - if (null === parentFiber.child || 4 === parentFiber.tag) continue b; + if (null === parentFiber.child || 6 === parentFiber.tag) continue b; else (parentFiber.child.return = parentFiber), (parentFiber = parentFiber.child); @@ -5055,7 +4556,7 @@ function commitPlacement(finishedWork) { } } for (var node = finishedWork; ; ) { - if (5 === node.tag || 6 === node.tag) + if (7 === node.tag || 8 === node.tag) if (parentFiber) if (isContainer) invariant( @@ -5124,7 +4625,7 @@ function commitPlacement(finishedWork) { [index.length - 1], [] ))); - else if (4 !== node.tag && null !== node.child) { + else if (6 !== node.tag && null !== node.child) { node.child.return = node; node = node.child; continue; @@ -5155,15 +4656,15 @@ function unmountHostComponents(current$$1) { "Expected to find a host parent. This error is likely caused by a bug in React. Please file an issue." ); switch (currentParentIsValid.tag) { - case 5: + case 7: currentParent = currentParentIsValid.stateNode; currentParentIsContainer = !1; break a; - case 3: + case 5: currentParent = currentParentIsValid.stateNode.containerInfo; currentParentIsContainer = !0; break a; - case 4: + case 6: currentParent = currentParentIsValid.stateNode.containerInfo; currentParentIsContainer = !0; break a; @@ -5172,11 +4673,11 @@ function unmountHostComponents(current$$1) { } currentParentIsValid = !0; } - if (5 === node.tag || 6 === node.tag) { + if (7 === node.tag || 8 === node.tag) { a: for (var root = node, node$jscomp$0 = root; ; ) if ( (commitUnmount(node$jscomp$0), - null !== node$jscomp$0.child && 4 !== node$jscomp$0.tag) + null !== node$jscomp$0.child && 6 !== node$jscomp$0.tag) ) (node$jscomp$0.child.return = node$jscomp$0), (node$jscomp$0 = node$jscomp$0.child); @@ -5204,7 +4705,7 @@ function unmountHostComponents(current$$1) { UIManager.manageChildren(root._nativeTag, [], [], [], [], [child]); } } else if ( - (4 === node.tag + (6 === node.tag ? ((currentParent = node.stateNode.containerInfo), (currentParentIsContainer = !0)) : commitUnmount(node), @@ -5218,7 +4719,7 @@ function unmountHostComponents(current$$1) { for (; null === node.sibling; ) { if (null === node.return || node.return === current$$1) return; node = node.return; - 4 === node.tag && (currentParentIsValid = !1); + 6 === node.tag && (currentParentIsValid = !1); } node.sibling.return = node.return; node = node.sibling; @@ -5226,15 +4727,10 @@ function unmountHostComponents(current$$1) { } function commitWork(current$$1, finishedWork) { switch (finishedWork.tag) { - case 0: - case 11: - case 14: - case 15: - commitHookEffectList(4, 8, finishedWork); + case 2: + case 3: break; - case 1: - break; - case 5: + case 7: var instance = finishedWork.stateNode; if (null != instance) { var newProps = finishedWork.memoizedProps; @@ -5258,7 +4754,7 @@ function commitWork(current$$1, finishedWork) { )); } break; - case 6: + case 8: invariant( null !== finishedWork.stateNode, "This should have a text node initialized. This error is likely caused by a bug in React. Please file an issue." @@ -5267,13 +4763,11 @@ function commitWork(current$$1, finishedWork) { text: finishedWork.memoizedProps }); break; - case 3: + case 5: break; - case 12: + case 15: break; - case 13: - break; - case 17: + case 16: break; default: invariant( @@ -5282,6 +4776,9 @@ function commitWork(current$$1, finishedWork) { ); } } +function NoopComponent() { + return null; +} function createRootErrorUpdate(fiber, errorInfo, expirationTime) { expirationTime = createUpdate(expirationTime); expirationTime.tag = 3; @@ -5327,7 +4824,7 @@ function throwException( value, renderExpirationTime ) { - sourceFiber.effectTag |= 1024; + sourceFiber.effectTag |= 512; sourceFiber.firstEffect = sourceFiber.lastEffect = null; if ( null !== value && @@ -5339,54 +4836,49 @@ function throwException( var earliestTimeoutMs = -1, startTimeMs = -1; do { - if (13 === value.tag) { - var current$$1 = value.alternate; + if (16 === value.tag) { + var current = value.alternate; if ( - null !== current$$1 && - ((current$$1 = current$$1.memoizedState), - null !== current$$1 && current$$1.didTimeout) + null !== current && + !0 === current.memoizedState && + null !== current.stateNode ) { - startTimeMs = 10 * (1073741822 - current$$1.timedOutAt); + startTimeMs = 10 * (current.stateNode.timedOutAt - 2); break; } - 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; + current = value.pendingProps.maxDuration; + if ("number" === typeof current) + if (0 >= current) earliestTimeoutMs = 0; + else if (-1 === earliestTimeoutMs || current < earliestTimeoutMs) + earliestTimeoutMs = current; } value = value.return; } while (null !== value); value = returnFiber; do { - 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) { + if (16 === value.tag && !value.memoizedState) { returnFiber = retrySuspendedRoot.bind( null, root, value, - sourceFiber, - 0 === (value.mode & 1) ? 1073741823 : renderExpirationTime + 0 === (value.mode & 1) ? 1 : renderExpirationTime ); returnFiber = tracing.unstable_wrap(returnFiber); thenable.then(returnFiber, returnFiber); - if (0 === (value.mode & 1)) { - value.effectTag |= 32; + if (0 === (value.mode & 2)) { + value.effectTag |= 4; reconcileChildren( sourceFiber.alternate, sourceFiber, null, renderExpirationTime ); - sourceFiber.effectTag &= -1025; - sourceFiber.effectTag &= -933; - 1 === sourceFiber.tag && - null === sourceFiber.alternate && - (sourceFiber.tag = 17); + 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)); return; } -1 === earliestTimeoutMs @@ -5394,26 +4886,24 @@ function throwException( : (-1 === startTimeMs && (startTimeMs = 10 * - (1073741822 - - findEarliestOutstandingPriorityLevel( - root, - renderExpirationTime - )) - + (findEarliestOutstandingPriorityLevel( + root, + renderExpirationTime + ) - + 2) - 5e3), (root = startTimeMs + earliestTimeoutMs)); 0 <= root && nextLatestAbsoluteTimeoutMs < root && (nextLatestAbsoluteTimeoutMs = root); - value.effectTag |= 2048; + value.effectTag |= 1024; value.expirationTime = renderExpirationTime; return; } value = value.return; } while (null !== value); value = Error( - (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) + "An update was suspended, but no placeholder UI was provided." ); } nextRenderDidError = !0; @@ -5421,9 +4911,9 @@ function throwException( root = returnFiber; do { switch (root.tag) { - case 3: + case 5: sourceFiber = value; - root.effectTag |= 2048; + root.effectTag |= 1024; root.expirationTime = renderExpirationTime; renderExpirationTime = createRootErrorUpdate( root, @@ -5432,7 +4922,8 @@ function throwException( ); enqueueCapturedUpdate(root, renderExpirationTime); return; - case 1: + case 2: + case 3: if ( ((sourceFiber = value), (returnFiber = root.type), @@ -5444,7 +4935,7 @@ function throwException( (null === legacyErrorBoundariesThatAlreadyFailed || !legacyErrorBoundariesThatAlreadyFailed.has(thenable))))) ) { - root.effectTag |= 2048; + root.effectTag |= 1024; root.expirationTime = renderExpirationTime; renderExpirationTime = createClassErrorUpdate( root, @@ -5460,14 +4951,24 @@ function throwException( } function unwindWork(workInProgress) { switch (workInProgress.tag) { - case 1: + case 2: isContextProvider(workInProgress.type) && popContext(workInProgress); var effectTag = workInProgress.effectTag; - return effectTag & 2048 - ? ((workInProgress.effectTag = (effectTag & -2049) | 64), + return effectTag & 1024 + ? ((workInProgress.effectTag = (effectTag & -1025) | 64), workInProgress) : null; case 3: + return ( + isContextProvider(workInProgress.type._reactResult) && + popContext(workInProgress), + (effectTag = workInProgress.effectTag), + effectTag & 1024 + ? ((workInProgress.effectTag = (effectTag & -1025) | 64), + workInProgress) + : null + ); + case 5: return ( popHostContainer(workInProgress), popTopLevelContextObject(workInProgress), @@ -5476,117 +4977,28 @@ 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 & -2049) | 64), + (workInProgress.effectTag = (effectTag & -1025) | 64), workInProgress ); - case 5: + case 7: return popHostContext(workInProgress), null; - 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: + case 16: + return ( + (effectTag = workInProgress.effectTag), + effectTag & 1024 + ? ((workInProgress.effectTag = (effectTag & -1025) | 64), + workInProgress) + : null + ); + case 6: return popHostContainer(workInProgress), null; - case 10: + case 12: return popProvider(workInProgress), null; default: return null; } } -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); - } - }, +var Dispatcher = { readContext: readContext }, ReactCurrentOwner$2 = ReactSharedInternals.ReactCurrentOwner; invariant( null != tracing.__interactionsRef && @@ -5601,9 +5013,6 @@ var isWorking = !1, nextRenderDidError = !1, nextEffect = null, isCommitting$1 = !1, - rootWithPendingPassiveEffects = null, - passiveEffectCallbackHandle = null, - passiveEffectCallback = null, legacyErrorBoundariesThatAlreadyFailed = null; function resetStack() { if (null !== nextUnitOfWork) @@ -5614,7 +5023,7 @@ function resetStack() { ) { var interruptedWork$jscomp$0 = interruptedWork; switch (interruptedWork$jscomp$0.tag) { - case 1: + case 2: var childContextTypes = interruptedWork$jscomp$0.type.childContextTypes; null !== childContextTypes && @@ -5622,16 +5031,23 @@ 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 5: + case 7: popHostContext(interruptedWork$jscomp$0); break; - case 4: + case 6: popHostContainer(interruptedWork$jscomp$0); break; - case 10: + case 12: popProvider(interruptedWork$jscomp$0); } interruptedWork = interruptedWork.return; @@ -5681,17 +5097,13 @@ function commitAllHostEffects() { } function commitBeforeMutationLifecycles() { for (; null !== nextEffect; ) { - if (nextEffect.effectTag & 256) + if (nextEffect.effectTag & 256) { + var current$$1 = nextEffect.alternate; a: { - var current$$1 = nextEffect.alternate, - finishedWork = nextEffect; + var finishedWork = nextEffect; switch (finishedWork.tag) { - case 0: - case 11: - case 15: - commitHookEffectList(2, 0, finishedWork); - break a; - case 1: + case 2: + case 3: if (finishedWork.effectTag & 256 && null !== current$$1) { var prevProps = current$$1.memoizedProps, prevState = current$$1.memoizedState; @@ -5705,11 +5117,10 @@ 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( @@ -5718,6 +5129,7 @@ function commitBeforeMutationLifecycles() { ); } } + } nextEffect = nextEffect.nextEffect; } } @@ -5728,76 +5140,73 @@ function commitAllLifeCycles( for (; null !== nextEffect; ) { var effectTag = nextEffect.effectTag; if (effectTag & 36) { - var finishedRoot = finishedRoot$jscomp$0; - var newDidTimeout = nextEffect.alternate; - var finishedWork = nextEffect, + var finishedRoot = finishedRoot$jscomp$0, + current$$1 = nextEffect.alternate, + finishedWork = nextEffect, committedExpirationTime = committedExpirationTime$jscomp$0; switch (finishedWork.tag) { - case 0: - case 11: - case 15: - commitHookEffectList(16, 32, finishedWork); - break; - case 1: + case 2: + case 3: finishedRoot = finishedWork.stateNode; if (finishedWork.effectTag & 4) - if (null === newDidTimeout) + if (null === current$$1) (finishedRoot.props = finishedWork.memoizedProps), (finishedRoot.state = finishedWork.memoizedState), finishedRoot.componentDidMount(); else { - var prevProps = newDidTimeout.memoizedProps; - newDidTimeout = newDidTimeout.memoizedState; + var prevProps = current$$1.memoizedProps; + current$$1 = current$$1.memoizedState; finishedRoot.props = finishedWork.memoizedProps; finishedRoot.state = finishedWork.memoizedState; finishedRoot.componentDidUpdate( prevProps, - newDidTimeout, + current$$1, finishedRoot.__reactInternalSnapshotBeforeUpdate ); } - newDidTimeout = finishedWork.updateQueue; - null !== newDidTimeout && + current$$1 = finishedWork.updateQueue; + null !== current$$1 && ((finishedRoot.props = finishedWork.memoizedProps), (finishedRoot.state = finishedWork.memoizedState), commitUpdateQueue( finishedWork, - newDidTimeout, + current$$1, finishedRoot, committedExpirationTime )); break; - case 3: - newDidTimeout = finishedWork.updateQueue; - if (null !== newDidTimeout) { + case 5: + current$$1 = finishedWork.updateQueue; + if (null !== current$$1) { finishedRoot = null; if (null !== finishedWork.child) switch (finishedWork.child.tag) { - case 5: + case 7: finishedRoot = finishedWork.child.stateNode; break; - case 1: + case 2: + case 3: finishedRoot = finishedWork.child.stateNode; } commitUpdateQueue( finishedWork, - newDidTimeout, + current$$1, finishedRoot, committedExpirationTime ); } break; - case 5: + case 7: + break; + case 8: break; case 6: break; - case 4: - break; - case 12: + case 15: committedExpirationTime = finishedWork.memoizedProps.onRender; committedExpirationTime( finishedWork.memoizedProps.id, - null === newDidTimeout ? "mount" : "update", + null === current$$1 ? "mount" : "update", finishedWork.actualDuration, finishedWork.treeBaseDuration, finishedWork.actualStartTime, @@ -5805,54 +5214,14 @@ function commitAllLifeCycles( finishedRoot.memoizedInteractions ); break; - 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: + case 16: + 0 === (finishedWork.mode & 2) + ? ((finishedWork.updateQueue = emptyObject$1), + scheduleWork(finishedWork, 1)) + : ((committedExpirationTime = requestCurrentTime()), + (finishedWork.stateNode = { + timedOutAt: committedExpirationTime + })); break; default: invariant( @@ -5862,44 +5231,17 @@ function commitAllLifeCycles( } } effectTag & 128 && - ((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; + ((effectTag = nextEffect.ref), + null !== effectTag && + ((finishedWork = nextEffect.stateNode), + "function" === typeof effectTag + ? effectTag(finishedWork) + : (effectTag.current = finishedWork))); + effectTag = nextEffect.nextEffect; + nextEffect.nextEffect = null; + nextEffect = effectTag; } } -function 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( @@ -5916,7 +5258,9 @@ function commitRoot(root, finishedWork) { childExpirationTimeBeforeCommit = finishedWork.childExpirationTime; markCommittedPriorityLevels( root, - childExpirationTimeBeforeCommit > updateExpirationTimeBeforeCommit + 0 === updateExpirationTimeBeforeCommit || + (0 !== childExpirationTimeBeforeCommit && + childExpirationTimeBeforeCommit < updateExpirationTimeBeforeCommit) ? childExpirationTimeBeforeCommit : updateExpirationTimeBeforeCommit ); @@ -5966,42 +5310,29 @@ function commitRoot(root, finishedWork) { } root.current = finishedWork; for (nextEffect = childExpirationTimeBeforeCommit; null !== nextEffect; ) { - didError = !1; - error$jscomp$0 = void 0; + childExpirationTimeBeforeCommit = !1; + didError = void 0; try { commitAllLifeCycles(root, committedExpirationTime); } catch (e) { - (didError = !0), (error$jscomp$0 = e); + (childExpirationTimeBeforeCommit = !0), (didError = e); } - didError && + 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$jscomp$0), + captureCommitPhaseError(nextEffect, didError), 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 = - finishedWork > childExpirationTimeBeforeCommit + 0 === childExpirationTimeBeforeCommit || + (0 !== finishedWork && finishedWork < childExpirationTimeBeforeCommit) ? finishedWork : childExpirationTimeBeforeCommit; 0 === earliestRemainingTimeAfterCommit && @@ -6026,18 +5357,21 @@ function commitRoot(root, finishedWork) { scheduledInteractions, scheduledExpirationTime ) { - 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)); - } - })); + 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)); + } + }); }); } } @@ -6046,7 +5380,7 @@ function completeUnitOfWork(workInProgress) { var current$$1 = workInProgress.alternate, returnFiber = workInProgress.return, siblingFiber = workInProgress.sibling; - if (0 === (workInProgress.effectTag & 1024)) { + if (0 === (workInProgress.effectTag & 512)) { if (workInProgress.mode & 4) { var fiber = workInProgress; profilerStartTime = now$1(); @@ -6056,17 +5390,17 @@ function completeUnitOfWork(workInProgress) { current$$1 = workInProgress; fiber = current$$1.pendingProps; switch (current$$1.tag) { - case 2: - break; - case 16: - break; - case 15: case 0: - break; case 1: + break; + case 2: 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; @@ -6077,7 +5411,7 @@ function completeUnitOfWork(workInProgress) { current$$1.effectTag &= -3; updateHostContainer(current$$1); break; - case 5: + case 7: popHostContext(current$$1); var rootContainerInstance = requiredContext( rootInstanceStackCursor.current @@ -6116,7 +5450,35 @@ function completeUnitOfWork(workInProgress) { viewConfig = new ReactNativeFiberHostComponent(tag, viewConfig); instanceCache[tag] = internalInstanceHandle; instanceProps[tag] = fiber; - appendAllChildren(viewConfig, current$$1, !1, !1); + 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; + } finalizeInitialChildren( viewConfig, type, @@ -6132,7 +5494,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 6: + case 8: current && null != current$$1.stateNode ? updateHostText$1( current, @@ -6159,36 +5521,34 @@ function completeUnitOfWork(workInProgress) { (instanceCache[type] = current$$1), (rootContainerInstance.stateNode = type)); break; - case 11: - break; case 13: - fiber = current$$1.memoizedState; - rootContainerInstance = - null !== current ? current.memoizedState : null; - (null !== fiber && fiber.didTimeout) !== - (null !== rootContainerInstance && - rootContainerInstance.didTimeout) && (current$$1.effectTag |= 4); + case 14: break; - case 7: - break; - case 8: - break; - case 12: - break; - case 4: - popHostContainer(current$$1); - updateHostContainer(current$$1); - break; - case 10: - popProvider(current$$1); + case 16: break; case 9: break; - case 14: + case 10: + break; + case 15: + break; + case 6: + popHostContainer(current$$1); + updateHostContainer(current$$1); + break; + case 12: + popProvider(current$$1); + break; + case 11: break; case 17: - isContextProvider(current$$1.type) && popContext(current$$1); + case 18: 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, @@ -6200,8 +5560,8 @@ function completeUnitOfWork(workInProgress) { stopProfilerTimerIfRunningAndRecordDelta(workInProgress, !1); current$$1 = workInProgress; if ( - 1 === nextRenderExpirationTime || - 1 !== current$$1.childExpirationTime + 1073741823 === nextRenderExpirationTime || + 1073741823 !== current$$1.childExpirationTime ) { fiber = 0; if (current$$1.mode & 4) { @@ -6210,20 +5570,19 @@ function completeUnitOfWork(workInProgress) { current = null === current$$1.alternate || current$$1.child !== current$$1.alternate.child; - 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); + 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; + } current$$1.actualDuration = rootContainerInstance; current$$1.treeBaseDuration = type; } else @@ -6231,16 +5590,18 @@ function completeUnitOfWork(workInProgress) { rootContainerInstance = current$$1.child; null !== rootContainerInstance; - ) - (type = rootContainerInstance.expirationTime), - (current = rootContainerInstance.childExpirationTime), - type > fiber && (fiber = type), - current > fiber && (fiber = current), - (rootContainerInstance = rootContainerInstance.sibling); + ) { + 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; + } current$$1.childExpirationTime = fiber; } null !== returnFiber && - 0 === (returnFiber.effectTag & 1024) && + 0 === (returnFiber.effectTag & 512) && (null === returnFiber.firstEffect && (returnFiber.firstEffect = workInProgress.firstEffect), null !== workInProgress.lastEffect && @@ -6264,12 +5625,12 @@ function completeUnitOfWork(workInProgress) { (siblingFiber = siblingFiber.sibling); workInProgress.actualDuration = returnFiber; } - workInProgress.effectTag &= 1023; + workInProgress.effectTag &= 511; return workInProgress; } null !== returnFiber && ((returnFiber.firstEffect = returnFiber.lastEffect = null), - (returnFiber.effectTag |= 1024)); + (returnFiber.effectTag |= 512)); } if (null !== siblingFiber) return siblingFiber; if (null !== returnFiber) workInProgress = returnFiber; @@ -6284,19 +5645,17 @@ 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) { +function renderRoot(root, isYieldy, isExpired) { 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; @@ -6319,7 +5678,7 @@ function renderRoot(root, isYieldy) { scheduledInteractions, scheduledExpirationTime ) { - scheduledExpirationTime >= expirationTime && + scheduledExpirationTime <= expirationTime && scheduledInteractions.forEach(function(interaction) { return interactions.add(interaction); }); @@ -6345,17 +5704,13 @@ function renderRoot(root, isYieldy) { do { try { if (isYieldy) - for (; null !== nextUnitOfWork && !shouldYieldToRenderer(); ) + for (; null !== nextUnitOfWork && !shouldYield(); ) nextUnitOfWork = performUnitOfWork(nextUnitOfWork); else for (; null !== nextUnitOfWork; ) nextUnitOfWork = performUnitOfWork(nextUnitOfWork); } catch (thrownValue) { - if ( - ((lastContextWithAllBitsObserved = lastContextDependency = currentlyRenderingFiber = null), - resetHooks(), - null === nextUnitOfWork) - ) + if (null === nextUnitOfWork) (threadID = !0), onUncaughtError(thrownValue); else { invariant( @@ -6383,153 +5738,168 @@ function renderRoot(root, isYieldy) { 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 { - subscriber = root.current.alternate; + isYieldy = root.current.alternate; invariant( - null !== subscriber, + null !== isYieldy, "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, subscriber, expirationTime, root.expirationTime, -1); + onSuspend(root, isYieldy, expirationTime, root.expirationTime, -1); return; } - if (!root.didError && isYieldy) { + if (!root.didError && !isExpired) { root.didError = !0; - isYieldy = root.nextExpirationTimeToWorkOn = expirationTime; - threadID = root.expirationTime = 1073741823; - onSuspend(root, subscriber, isYieldy, threadID, -1); + isExpired = root.nextExpirationTimeToWorkOn = expirationTime; + subscriber = root.expirationTime = 1; + onSuspend(root, isYieldy, isExpired, subscriber, -1); return; } } - isYieldy && -1 !== nextLatestAbsoluteTimeoutMs - ? (markSuspendedPriorityLevel(root, expirationTime), - (isYieldy = + isExpired || -1 === nextLatestAbsoluteTimeoutMs + ? onComplete(root, isYieldy, expirationTime) + : (markSuspendedPriorityLevel(root, expirationTime), + (isExpired = 10 * - (1073741822 - - findEarliestOutstandingPriorityLevel(root, expirationTime))), - isYieldy < nextLatestAbsoluteTimeoutMs && - (nextLatestAbsoluteTimeoutMs = isYieldy), - (isYieldy = 10 * (1073741822 - requestCurrentTime())), - (isYieldy = nextLatestAbsoluteTimeoutMs - isYieldy), + (findEarliestOutstandingPriorityLevel(root, expirationTime) - 2)), + isExpired < nextLatestAbsoluteTimeoutMs && + (nextLatestAbsoluteTimeoutMs = isExpired), + (isExpired = 10 * (requestCurrentTime() - 2)), + (isExpired = nextLatestAbsoluteTimeoutMs - isExpired), onSuspend( root, - subscriber, + isYieldy, expirationTime, root.expirationTime, - 0 > isYieldy ? 0 : isYieldy - )) - : onComplete(root, subscriber, expirationTime); + 0 > isExpired ? 0 : isExpired + )); } } -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; +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; } - fiber = fiber.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; } - 3 === sourceFiber.tag && - ((fiber = createCapturedValue(value, sourceFiber)), - (fiber = createRootErrorUpdate(sourceFiber, fiber, 1073741823)), - enqueueUpdate(sourceFiber, fiber), - scheduleWork(sourceFiber, 1073741823)); + return JSCompiler_inline_result; } function computeExpirationForFiber(currentTime, fiber) { isWorking - ? (currentTime = isCommitting$1 ? 1073741823 : nextRenderExpirationTime) + ? (currentTime = isCommitting$1 ? 1 : nextRenderExpirationTime) : fiber.mode & 1 ? ((currentTime = isBatchingInteractiveUpdates - ? 1073741822 - 10 * ((((1073741822 - currentTime + 15) / 10) | 0) + 1) - : 1073741822 - - 25 * ((((1073741822 - currentTime + 500) / 25) | 0) + 1)), + ? 2 + 10 * ((((currentTime - 2 + 15) / 10) | 0) + 1) + : 2 + 25 * ((((currentTime - 2 + 500) / 25) | 0) + 1)), null !== nextRoot && currentTime === nextRenderExpirationTime && - --currentTime) - : (currentTime = 1073741823); + (currentTime += 1)) + : (currentTime = 1); isBatchingInteractiveUpdates && - (0 === lowestPriorityPendingInteractiveExpirationTime || - currentTime < lowestPriorityPendingInteractiveExpirationTime) && + currentTime > lowestPriorityPendingInteractiveExpirationTime && (lowestPriorityPendingInteractiveExpirationTime = currentTime); return currentTime; } -function retrySuspendedRoot(root, boundaryFiber, sourceFiber, suspendedTime) { +function retrySuspendedRoot(root, fiber, 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, boundaryFiber)), + (retryTime = computeExpirationForFiber(retryTime, fiber)), markPendingPriorityLevel(root, retryTime); - 0 !== (boundaryFiber.mode & 1) && + 0 !== (fiber.mode & 1) && root === nextRoot && nextRenderExpirationTime === suspendedTime && (nextRoot = null); - 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); + scheduleWorkToRoot(fiber, retryTime); + fiber = root.expirationTime; + 0 !== fiber && requestWork(root, fiber); } function scheduleWorkToRoot(fiber, expirationTime) { - fiber.expirationTime < expirationTime && - (fiber.expirationTime = expirationTime); + if (0 === fiber.expirationTime || fiber.expirationTime > expirationTime) + fiber.expirationTime = expirationTime; var alternate = fiber.alternate; null !== alternate && - alternate.expirationTime < expirationTime && + (0 === alternate.expirationTime || + alternate.expirationTime > expirationTime) && (alternate.expirationTime = expirationTime); var node = fiber.return, root = null; - if (null === node && 3 === fiber.tag) root = fiber.stateNode; + if (null === node && 5 === fiber.tag) root = fiber.stateNode; else for (; null !== node; ) { alternate = node.alternate; - node.childExpirationTime < expirationTime && - (node.childExpirationTime = expirationTime); + if ( + 0 === node.childExpirationTime || + node.childExpirationTime > expirationTime + ) + node.childExpirationTime = expirationTime; null !== alternate && - alternate.childExpirationTime < expirationTime && + (0 === alternate.childExpirationTime || + alternate.childExpirationTime > expirationTime) && (alternate.childExpirationTime = expirationTime); - if (null === node.return && 3 === node.tag) { + if (null === node.return && 5 === node.tag) { root = node.stateNode; break; } @@ -6563,7 +5933,7 @@ function scheduleWork(fiber, expirationTime) { null !== fiber && (!isWorking && 0 !== nextRenderExpirationTime && - expirationTime > nextRenderExpirationTime && + expirationTime < nextRenderExpirationTime && resetStack(), markPendingPriorityLevel(fiber, expirationTime), (isWorking && !isCommitting$1 && nextRoot === fiber) || @@ -6583,25 +5953,27 @@ 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 = 1073741822 - ((originalStartTimeMs / 10) | 0), + currentRendererTime = ((originalStartTimeMs / 10) | 0) + 2, currentSchedulerTime = currentRendererTime, NESTED_UPDATE_LIMIT = 50, nestedUpdateCount = 0, - lastCommittedRootDuringThisBatch = null; + lastCommittedRootDuringThisBatch = null, + timeHeuristicForUnitOfWork = 1; function recomputeCurrentRendererTime() { - currentRendererTime = - 1073741822 - (((now$1() - originalStartTimeMs) / 10) | 0); + currentRendererTime = (((now$1() - originalStartTimeMs) / 10) | 0) + 2; } function scheduleCallbackWithExpirationTime(root, expirationTime) { if (0 !== callbackExpirationTime) { - if (expirationTime < callbackExpirationTime) return; + if (expirationTime > callbackExpirationTime) return; null !== callbackID && ((root = callbackID), (scheduledCallback = null), clearTimeout(root)); } @@ -6622,7 +5994,7 @@ function onSuspend( msUntilTimeout ) { root.expirationTime = rootExpirationTime; - 0 !== msUntilTimeout || shouldYieldToRenderer() + 0 !== msUntilTimeout || shouldYield() ? 0 < msUntilTimeout && (root.timeoutHandle = scheduleTimeout( onTimeout.bind(null, root, finishedWork, suspendedExpirationTime), @@ -6642,8 +6014,8 @@ function onTimeout(root, finishedWork, suspendedExpirationTime) { ); nextFlushedRoot = root; nextFlushedExpirationTime = suspendedExpirationTime; - performWorkOnRoot(root, suspendedExpirationTime, !1); - performWork(1073741823, !1); + performWorkOnRoot(root, suspendedExpirationTime, !0); + performWork(1, null); } function onCommit(root, expirationTime) { root.expirationTime = expirationTime; @@ -6652,29 +6024,38 @@ function onCommit(root, expirationTime) { function requestCurrentTime() { if (isRendering) return currentSchedulerTime; findHighestPriorityRoot(); - if (0 === nextFlushedExpirationTime || 1 === nextFlushedExpirationTime) + if ( + 0 === nextFlushedExpirationTime || + 1073741823 === nextFlushedExpirationTime + ) recomputeCurrentRendererTime(), (currentSchedulerTime = currentRendererTime); return currentSchedulerTime; } function requestWork(root, expirationTime) { - null === root.nextScheduledRoot - ? ((root.expirationTime = expirationTime), + if (null === root.nextScheduledRoot) + (root.expirationTime = expirationTime), null === lastScheduledRoot ? ((firstScheduledRoot = lastScheduledRoot = root), (root.nextScheduledRoot = root)) : ((lastScheduledRoot = lastScheduledRoot.nextScheduledRoot = root), - (lastScheduledRoot.nextScheduledRoot = firstScheduledRoot))) - : expirationTime > root.expirationTime && - (root.expirationTime = expirationTime); + (lastScheduledRoot.nextScheduledRoot = firstScheduledRoot)); + else { + var remainingExpirationTime = root.expirationTime; + if ( + 0 === remainingExpirationTime || + expirationTime < remainingExpirationTime + ) + root.expirationTime = expirationTime; + } isRendering || (isBatchingUpdates ? isUnbatchingUpdates && ((nextFlushedRoot = root), - (nextFlushedExpirationTime = 1073741823), - performWorkOnRoot(root, 1073741823, !1)) - : 1073741823 === expirationTime - ? performWork(1073741823, !1) + (nextFlushedExpirationTime = 1), + performWorkOnRoot(root, 1, !0)) + : 1 === expirationTime + ? performWork(1, null) : scheduleCallbackWithExpirationTime(root, expirationTime)); } function findHighestPriorityRoot() { @@ -6710,11 +6091,14 @@ function findHighestPriorityRoot() { (root.nextScheduledRoot = null); root = previousScheduledRoot.nextScheduledRoot; } else { - remainingExpirationTime > highestPriorityWork && - ((highestPriorityWork = remainingExpirationTime), - (highestPriorityRoot = root)); + if ( + 0 === highestPriorityWork || + remainingExpirationTime < highestPriorityWork + ) + (highestPriorityWork = remainingExpirationTime), + (highestPriorityRoot = root); if (root === lastScheduledRoot) break; - if (1073741823 === highestPriorityWork) break; + if (1 === highestPriorityWork) break; previousScheduledRoot = root; root = root.nextScheduledRoot; } @@ -6722,44 +6106,38 @@ function findHighestPriorityRoot() { nextFlushedRoot = highestPriorityRoot; nextFlushedExpirationTime = highestPriorityWork; } -var didYield = !1; -function shouldYieldToRenderer() { - return didYield ? !0 : frameDeadline <= now$1() ? (didYield = !0) : !1; -} -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 performAsyncWork(dl) { + if (dl.didTimeout && null !== firstScheduledRoot) { + recomputeCurrentRendererTime(); + var root = firstScheduledRoot; + do { + var expirationTime = root.expirationTime; + 0 !== expirationTime && + currentRendererTime >= expirationTime && + (root.nextExpirationTimeToWorkOn = currentRendererTime); + root = root.nextScheduledRoot; + } while (root !== firstScheduledRoot); } + performWork(0, dl); } -function performWork(minExpirationTime, isYieldy) { +function performWork(minExpirationTime, dl) { + deadline = dl; findHighestPriorityRoot(); - if (isYieldy) + if (null !== deadline) for ( recomputeCurrentRendererTime(), currentSchedulerTime = currentRendererTime; null !== nextFlushedRoot && 0 !== nextFlushedExpirationTime && - minExpirationTime <= nextFlushedExpirationTime && - !(didYield && currentRendererTime > nextFlushedExpirationTime); + (0 === minExpirationTime || + minExpirationTime >= nextFlushedExpirationTime) && + (!deadlineDidExpire || currentRendererTime >= nextFlushedExpirationTime); ) performWorkOnRoot( nextFlushedRoot, nextFlushedExpirationTime, - currentRendererTime > nextFlushedExpirationTime + currentRendererTime >= nextFlushedExpirationTime ), findHighestPriorityRoot(), recomputeCurrentRendererTime(), @@ -6769,28 +6147,29 @@ function performWork(minExpirationTime, isYieldy) { ; null !== nextFlushedRoot && 0 !== nextFlushedExpirationTime && - minExpirationTime <= nextFlushedExpirationTime; + (0 === minExpirationTime || + minExpirationTime >= nextFlushedExpirationTime); ) - performWorkOnRoot(nextFlushedRoot, nextFlushedExpirationTime, !1), + performWorkOnRoot(nextFlushedRoot, nextFlushedExpirationTime, !0), findHighestPriorityRoot(); - isYieldy && ((callbackExpirationTime = 0), (callbackID = null)); + null !== deadline && ((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, - isYieldy = 0; - isYieldy < minExpirationTime.length; - isYieldy++ + minExpirationTime = completedBatches, completedBatches = null, dl = 0; + dl < minExpirationTime.length; + dl++ ) { - var batch = minExpirationTime[isYieldy]; + var batch = minExpirationTime[dl]; try { batch._onComplete(); } catch (error) { @@ -6804,45 +6183,45 @@ function performWork(minExpirationTime, isYieldy) { (hasUnhandledError = !1), minExpirationTime); } -function performWorkOnRoot(root, expirationTime, isYieldy) { +function performWorkOnRoot(root, expirationTime, isExpired) { invariant( !isRendering, "performWorkOnRoot was called recursively. This error is likely caused by a bug in React. Please file an issue." ); isRendering = !0; - if (isYieldy) { - var _finishedWork = root.finishedWork; - null !== _finishedWork - ? completeRoot(root, _finishedWork, expirationTime) + if (null === deadline || isExpired) { + 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, isYieldy), - (_finishedWork = root.finishedWork), - null !== _finishedWork && - (shouldYieldToRenderer() - ? (root.finishedWork = _finishedWork) - : completeRoot(root, _finishedWork, expirationTime))); + (finishedWork = root.timeoutHandle), + -1 !== finishedWork && + ((root.timeoutHandle = -1), cancelTimeout(finishedWork)), + renderRoot(root, !1, isExpired), + (finishedWork = root.finishedWork), + null !== 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, isYieldy), - (_finishedWork = root.finishedWork), - null !== _finishedWork && - completeRoot(root, _finishedWork, expirationTime)); + (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))); 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), @@ -6858,6 +6237,13 @@ 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, @@ -6866,6 +6252,55 @@ 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 && @@ -6884,48 +6319,7 @@ function updateContainer(element, container, parentComponent, callback) { currentTime = requestCurrentTime(); current$$1 = computeExpirationForFiber(currentTime, current$$1); currentTime = container.current; - 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; + parentComponent = getContextForSubtree(parentComponent); null === container.context ? (container.context = parentComponent) : (container.pendingContext = parentComponent); @@ -6934,7 +6328,6 @@ 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; @@ -6994,13 +6387,13 @@ _batchedUpdatesImpl = function(fn, a) { } finally { (isBatchingUpdates = previousIsBatchingUpdates) || isRendering || - performWork(1073741823, !1); + performWork(1, null); } }; _flushInteractiveUpdatesImpl = function() { isRendering || 0 === lowestPriorityPendingInteractiveExpirationTime || - (performWork(lowestPriorityPendingInteractiveExpirationTime, !1), + (performWork(lowestPriorityPendingInteractiveExpirationTime, null), (lowestPriorityPendingInteractiveExpirationTime = 0)); }; var roots = new Map(), @@ -7082,7 +6475,7 @@ var roots = new Map(), if (!root) { root = 0; isDevToolsPresent && (root |= 4); - root = createFiber(3, null, null, root); + root = new FiberNode(5, null, null, root); var root$jscomp$0 = { current: root, containerInfo: containerTag, @@ -7113,7 +6506,7 @@ var roots = new Map(), updateContainer(element, root, null, callback); a: if (((element = root.current), element.child)) switch (element.child.tag) { - case 5: + case 7: element = element.child.stateNode; break a; default: @@ -7220,7 +6613,7 @@ var roots = new Map(), findFiberByHostInstance: getInstanceFromTag, getInspectorDataForViewTag: getInspectorDataForViewTag, bundleType: 0, - version: "16.6.0", + version: "16.6.0-alpha.8af6728", rendererPackageName: "react-native-renderer" }); var ReactNativeRenderer$2 = { default: ReactNativeRenderer }, diff --git a/Libraries/Renderer/shims/ReactTypes.js b/Libraries/Renderer/shims/ReactTypes.js index 080ade12b80..20f76eef30f 100644 --- a/Libraries/Renderer/shims/ReactTypes.js +++ b/Libraries/Renderer/shims/ReactTypes.js @@ -54,6 +54,7 @@ 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 e9b894df7a3..6d46a647719 100644 --- a/package.json +++ b/package.json @@ -146,7 +146,7 @@ "react-native": "local-cli/wrong-react-native.js" }, "peerDependencies": { - "react": "16.6.0" + "react": "16.6.0-alpha.8af6728" }, "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", + "react": "16.6.0-alpha.8af6728", "react-native-dummy": "0.1.0", - "react-test-renderer": "16.6.0", + "react-test-renderer": "16.6.0-alpha.8af6728", "shelljs": "^0.7.8" }, "detox": { diff --git a/yarn.lock b/yarn.lock index f6e999ad06e..232d8f9de1e 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: - version "16.6.0" - resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.6.0.tgz#456645144581a6e99f6816ae2bd24ee94bdd0c01" - integrity sha512-q8U7k0Fi7oxF1HvQgyBjPwDXeMplEsArnKt2iYhuIF86+GBbgLHdAmokL3XUFjTd7Q363OSNG55FOGUdONVn1g== +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-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: - version "16.6.0" - resolved "https://registry.yarnpkg.com/react-test-renderer/-/react-test-renderer-16.6.0.tgz#fe490096bed55c3f4e92c023da3b89f9d03fceb3" - integrity sha512-w+Y3YT7OX1LP5KO7HCd0YR34Ol1qmISHaooPNMRYa6QzmwtcWhEGuZPr34wO8UCBIokswuhyLQUq7rjPDcEtJA== +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== dependencies: object-assign "^4.1.1" prop-types "^15.6.2" - react-is "^16.6.0" - scheduler "^0.10.0" + react-is "^16.6.0-alpha.8af6728" + scheduler "^0.10.0-alpha.8af6728" 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: - version "16.6.0" - resolved "https://registry.yarnpkg.com/react/-/react-16.6.0.tgz#b34761cfaf3e30f5508bc732fb4736730b7da246" - integrity sha512-zJPnx/jKtuOEXCbQ9BKaxDMxR0001/hzxXwYxG8septeyYGfsgAei6NgfbVgOhbY1WOP2o3VPs/E9HaN+9hV3Q== +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== dependencies: loose-envify "^1.1.0" object-assign "^4.1.1" prop-types "^15.6.2" - scheduler "^0.10.0" + scheduler "^0.10.0-alpha.8af6728" 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: - version "0.10.0" - resolved "https://registry.yarnpkg.com/scheduler/-/scheduler-0.10.0.tgz#7988de90fe7edccc774ea175a783e69c40c521e1" - integrity sha512-+TSTVTCBAA3h8Anei3haDc1IRwMeDmtI/y/o3iBe3Mjl2vwYF9DtPDt929HyRmV/e7au7CLu8sc4C4W0VOs29w== +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== dependencies: loose-envify "^1.1.0" object-assign "^4.1.1"