diff --git a/Libraries/Renderer/REVISION b/Libraries/Renderer/REVISION index 21b691427f48aa..4d4a836a18ad74 100644 --- a/Libraries/Renderer/REVISION +++ b/Libraries/Renderer/REVISION @@ -1 +1 @@ -4773fdf7cdf5d6d775ad0960f23ee1a830e7b82b \ No newline at end of file +3ff2c7ccd4d174786aed0f16cc0dd784816ae977 \ No newline at end of file diff --git a/Libraries/Renderer/oss/ReactFabric-dev.js b/Libraries/Renderer/oss/ReactFabric-dev.js index de566d72b49386..1b716029b4ac87 100644 --- a/Libraries/Renderer/oss/ReactFabric-dev.js +++ b/Libraries/Renderer/oss/ReactFabric-dev.js @@ -27,6 +27,7 @@ var TextInputState = require("TextInputState"); var FabricUIManager = require("FabricUIManager"); var checkPropTypes = require("prop-types/checkPropTypes"); var tracing = require("scheduler/tracing"); +var scheduler = require("scheduler"); var ExceptionsManager = require("ExceptionsManager"); /** @@ -627,67 +628,26 @@ var warningWithoutStack = function() {}; return; } if (typeof console !== "undefined") { - var _args$map = args.map(function(item) { - return "" + item; - }), - a = _args$map[0], - b = _args$map[1], - c = _args$map[2], - d = _args$map[3], - e = _args$map[4], - f = _args$map[5], - g = _args$map[6], - h = _args$map[7]; - - var message = "Warning: " + format; - - // We intentionally don't use spread (or .apply) because it breaks IE9: - // https://github.com/facebook/react/issues/13610 - switch (args.length) { - case 0: - console.error(message); - break; - case 1: - console.error(message, a); - break; - case 2: - console.error(message, a, b); - break; - case 3: - console.error(message, a, b, c); - break; - case 4: - console.error(message, a, b, c, d); - break; - case 5: - console.error(message, a, b, c, d, e); - break; - case 6: - console.error(message, a, b, c, d, e, f); - break; - case 7: - console.error(message, a, b, c, d, e, f, g); - break; - case 8: - console.error(message, a, b, c, d, e, f, g, h); - break; - default: - throw new Error( - "warningWithoutStack() currently supports at most 8 arguments." - ); - } + var argsWithFormat = args.map(function(item) { + return "" + item; + }); + argsWithFormat.unshift("Warning: " + format); + + // We intentionally don't use spread (or .apply) directly because it + // breaks IE9: https://github.com/facebook/react/issues/13610 + Function.prototype.apply.call(console.error, console, argsWithFormat); } try { // --- Welcome to debugging React --- // This error was thrown as a convenience so that you can use this stack // to find the callsite that caused this warning to fire. var argIndex = 0; - var _message = + var message = "Warning: " + format.replace(/%s/g, function() { return args[argIndex++]; }); - throw new Error(_message); + throw new Error(message); } catch (x) {} }; } @@ -746,11 +706,10 @@ var validateEventDispatches = void 0; /** * Dispatch the event to the listener. * @param {SyntheticEvent} event SyntheticEvent to handle - * @param {boolean} simulated If the event is simulated (changes exn behavior) * @param {function} listener Application-level callback * @param {*} inst Internal component instance */ -function executeDispatch(event, simulated, listener, inst) { +function executeDispatch(event, listener, inst) { var type = event.type || "unknown-event"; event.currentTarget = getNodeFromInstance(inst); invokeGuardedCallbackAndCatchFirstError(type, listener, undefined, event); @@ -760,7 +719,7 @@ function executeDispatch(event, simulated, listener, inst) { /** * Standard/simple iteration through an event's collected dispatches. */ -function executeDispatchesInOrder(event, simulated) { +function executeDispatchesInOrder(event) { var dispatchListeners = event._dispatchListeners; var dispatchInstances = event._dispatchInstances; { @@ -772,15 +731,10 @@ function executeDispatchesInOrder(event, simulated) { break; } // Listeners and Instances are two parallel arrays that are always in sync. - executeDispatch( - event, - simulated, - dispatchListeners[i], - dispatchInstances[i] - ); + executeDispatch(event, dispatchListeners[i], dispatchInstances[i]); } } else if (dispatchListeners) { - executeDispatch(event, simulated, dispatchListeners, dispatchInstances); + executeDispatch(event, dispatchListeners, dispatchInstances); } event._dispatchListeners = null; event._dispatchInstances = null; @@ -933,23 +887,19 @@ var eventQueue = null; * Dispatches an event and releases it back into the pool, unless persistent. * * @param {?object} event Synthetic event to be dispatched. - * @param {boolean} simulated If the event is simulated (changes exn behavior) * @private */ -var executeDispatchesAndRelease = function(event, simulated) { +var executeDispatchesAndRelease = function(event) { if (event) { - executeDispatchesInOrder(event, simulated); + executeDispatchesInOrder(event); if (!event.isPersistent()) { event.constructor.release(event); } } }; -var executeDispatchesAndReleaseSimulated = function(e) { - return executeDispatchesAndRelease(e, true); -}; var executeDispatchesAndReleaseTopLevel = function(e) { - return executeDispatchesAndRelease(e, false); + return executeDispatchesAndRelease(e); }; function isInteractive(tag) { @@ -1083,7 +1033,7 @@ function extractEvents( return events; } -function runEventsInBatch(events, simulated) { +function runEventsInBatch(events) { if (events !== null) { eventQueue = accumulateInto(eventQueue, events); } @@ -1097,17 +1047,7 @@ function runEventsInBatch(events, simulated) { return; } - if (simulated) { - forEachAccumulated( - processingEventQueue, - executeDispatchesAndReleaseSimulated - ); - } else { - forEachAccumulated( - processingEventQueue, - executeDispatchesAndReleaseTopLevel - ); - } + forEachAccumulated(processingEventQueue, executeDispatchesAndReleaseTopLevel); invariant( !eventQueue, "processEventQueue(): Additional events were enqueued while processing " + @@ -1129,28 +1069,27 @@ function runExtractedEventsInBatch( nativeEvent, nativeEventTarget ); - runEventsInBatch(events, false); + runEventsInBatch(events); } var FunctionComponent = 0; -var FunctionComponentLazy = 1; -var ClassComponent = 2; -var ClassComponentLazy = 3; -var IndeterminateComponent = 4; // Before we know whether it is function or class -var HostRoot = 5; // Root of a host tree. Could be nested inside another node. -var HostPortal = 6; // A subtree. Could be an entry point to a different renderer. -var HostComponent = 7; -var HostText = 8; -var Fragment = 9; -var Mode = 10; -var ContextConsumer = 11; -var ContextProvider = 12; -var ForwardRef = 13; -var ForwardRefLazy = 14; -var Profiler = 15; -var SuspenseComponent = 16; -var PureComponent = 17; -var PureComponentLazy = 18; +var ClassComponent = 1; +var IndeterminateComponent = 2; // Before we know whether it is function or class +var HostRoot = 3; // Root of a host tree. Could be nested inside another node. +var HostPortal = 4; // A subtree. Could be an entry point to a different renderer. +var HostComponent = 5; +var HostText = 6; +var Fragment = 7; +var Mode = 8; +var ContextConsumer = 9; +var ContextProvider = 10; +var ForwardRef = 11; +var Profiler = 12; +var SuspenseComponent = 13; +var MemoComponent = 14; +var SimpleMemoComponent = 15; +var LazyComponent = 16; +var IncompleteClassComponent = 17; function getParent(inst) { do { @@ -2650,6 +2589,7 @@ var REACT_STRICT_MODE_TYPE = hasSymbol var REACT_PROFILER_TYPE = hasSymbol ? Symbol.for("react.profiler") : 0xead2; var REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for("react.provider") : 0xeacd; var REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for("react.context") : 0xeace; + var REACT_CONCURRENT_MODE_TYPE = hasSymbol ? Symbol.for("react.concurrent_mode") : 0xeacf; @@ -2657,7 +2597,8 @@ var REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for("react.forward_ref") : 0xead0; var REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for("react.suspense") : 0xead1; -var REACT_PURE_TYPE = hasSymbol ? Symbol.for("react.pure") : 0xead3; +var REACT_MEMO_TYPE = hasSymbol ? Symbol.for("react.memo") : 0xead3; +var REACT_LAZY_TYPE = hasSymbol ? Symbol.for("react.lazy") : 0xead4; var MAYBE_ITERATOR_SYMBOL = typeof Symbol === "function" && Symbol.iterator; var FAUX_ITERATOR_SYMBOL = "@@iterator"; @@ -2679,12 +2620,8 @@ var Pending = 0; var Resolved = 1; var Rejected = 2; -function getResultFromResolvedThenable(thenable) { - return thenable._reactResult; -} - -function refineResolvedThenable(thenable) { - return thenable._reactStatus === Resolved ? thenable._reactResult : null; +function refineResolvedLazyComponent(lazyComponent) { + return lazyComponent._status === Resolved ? lazyComponent._result : null; } function getWrappedName(outerType, innerType, wrapperName) { @@ -2737,14 +2674,14 @@ function getComponentName(type) { return "Context.Provider"; case REACT_FORWARD_REF_TYPE: return getWrappedName(type, type.render, "ForwardRef"); - case REACT_PURE_TYPE: - return getWrappedName(type, type.render, "Pure"); - } - if (typeof type.then === "function") { - var thenable = type; - var resolvedThenable = refineResolvedThenable(thenable); - if (resolvedThenable) { - return getComponentName(resolvedThenable); + case REACT_MEMO_TYPE: + return getComponentName(type.type); + case REACT_LAZY_TYPE: { + var thenable = type; + var resolvedThenable = refineResolvedLazyComponent(thenable); + if (resolvedThenable) { + return getComponentName(resolvedThenable); + } } } } @@ -2765,15 +2702,16 @@ var Callback = /* */ 32; var DidCapture = /* */ 64; var Ref = /* */ 128; var Snapshot = /* */ 256; +var Passive = /* */ 512; -// Update & Callback & Ref & Snapshot -var LifecycleEffectMask = /* */ 420; +// Passive & Update & Callback & Ref & Snapshot +var LifecycleEffectMask = /* */ 932; // Union of all host effects -var HostEffectMask = /* */ 511; +var HostEffectMask = /* */ 1023; -var Incomplete = /* */ 512; -var ShouldCapture = /* */ 1024; +var Incomplete = /* */ 1024; +var ShouldCapture = /* */ 2048; var ReactCurrentOwner$1 = ReactSharedInternals.ReactCurrentOwner; @@ -2817,10 +2755,7 @@ function isFiberMounted(fiber) { function isMounted(component) { { var owner = ReactCurrentOwner$1.current; - if ( - owner !== null && - (owner.tag === ClassComponent || owner.tag === ClassComponentLazy) - ) { + if (owner !== null && owner.tag === ClassComponent) { var ownerFiber = owner; var instance = ownerFiber.stateNode; !instance._warnedAboutRefsInRender @@ -3530,13 +3465,6 @@ var now$1 = hasNativePerformanceNow var scheduledCallback = null; var frameDeadline = 0; -var frameDeadlineObject = { - timeRemaining: function() { - return frameDeadline - now$1(); - }, - didTimeout: false -}; - function setTimeoutCallback() { // TODO (bvaughn) Hard-coded 5ms unblocks initial async testing. // React API probably changing to boolean rather than time remaining. @@ -3547,7 +3475,7 @@ function setTimeoutCallback() { var callback = scheduledCallback; scheduledCallback = null; if (callback !== null) { - callback(frameDeadlineObject); + callback(); } } @@ -3566,6 +3494,10 @@ function cancelDeferredCallback$1(callbackID) { clearTimeout(callbackID); // Timeouts are always numbers on RN } +function shouldYield$1() { + return frameDeadline <= now$1(); +} + // Use to restore controlled state after a change event has fired. var restoreImpl = null; @@ -3696,6 +3628,10 @@ var insertInContainerBefore = shim; var removeChild = shim; var removeChildFromContainer = shim; var resetTextContent = shim; +var hideInstance = shim; +var hideTextInstance = shim; +var unhideInstance = shim; +var unhideTextInstance = shim; // Renderers that don't support hydration // can re-export everything from this module. @@ -3973,6 +3909,7 @@ var isPrimaryRenderer = false; var now = now$1; var scheduleDeferredCallback = scheduleDeferredCallback$1; var cancelDeferredCallback = cancelDeferredCallback$1; +var shouldYield = shouldYield$1; var scheduleTimeout = setTimeout; var cancelTimeout = clearTimeout; @@ -4018,6 +3955,42 @@ function cloneInstance( }; } +function cloneHiddenInstance(instance, type, props, internalInstanceHandle) { + var viewConfig = instance.canonical.viewConfig; + var node = instance.node; + var updatePayload = create( + { style: { display: "none" } }, + viewConfig.validAttributes + ); + return { + node: FabricUIManager.cloneNodeWithNewProps(node, updatePayload), + canonical: instance.canonical + }; +} + +function cloneUnhiddenInstance(instance, type, props, internalInstanceHandle) { + var viewConfig = instance.canonical.viewConfig; + var node = instance.node; + var updatePayload = diff( + Object.assign({}, props, { style: [props.style, { display: "none" }] }), + props, + viewConfig.validAttributes + ); + return { + node: FabricUIManager.cloneNodeWithNewProps(node, updatePayload), + canonical: instance.canonical + }; +} + +function createHiddenTextInstance( + text, + rootContainerInstance, + hostContext, + internalInstanceHandle +) { + throw new Error("Not yet implemented."); +} + function createContainerChildSet(container) { return FabricUIManager.createChildSet(container); } @@ -4063,12 +4036,12 @@ var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame; function describeFiber(fiber) { switch (fiber.tag) { case IndeterminateComponent: + case LazyComponent: case FunctionComponent: - case FunctionComponentLazy: case ClassComponent: - case ClassComponentLazy: case HostComponent: case Mode: + case SuspenseComponent: var owner = fiber._debugOwner; var source = fiber._debugSource; var name = getComponentName(fiber.type); @@ -4145,6 +4118,7 @@ function setCurrentPhase(lifeCyclePhase) { var debugRenderPhaseSideEffects = false; var debugRenderPhaseSideEffectsForStrictMode = false; var enableUserTimingAPI = true; +var enableHooks = false; var warnAboutDeprecatedLifecycles = false; var replayFailedUnitOfWorkWithInvokeGuardedCallback = true; var enableProfilerTimer = true; @@ -4916,8 +4890,7 @@ function findCurrentUnmaskedContext(fiber) { // Currently this is only used with renderSubtreeIntoContainer; not sure if it // makes sense elsewhere invariant( - isFiberMounted(fiber) && - (fiber.tag === ClassComponent || fiber.tag === ClassComponentLazy), + isFiberMounted(fiber) && fiber.tag === ClassComponent, "Expected subtree parent to be a mounted class component. " + "This error is likely caused by a bug in React. Please file an issue." ); @@ -4934,13 +4907,6 @@ function findCurrentUnmaskedContext(fiber) { } break; } - case ClassComponentLazy: { - var _Component = getResultFromResolvedThenable(node.type); - if (isContextProvider(_Component)) { - return node.stateNode.__reactInternalMemoizedMergedChildContext; - } - break; - } } node = node.return; } while (node !== null); @@ -5039,20 +5005,20 @@ function onCommitUnmount(fiber) { var maxSigned31BitInt = 1073741823; var NoWork = 0; -var Sync = 1; -var Never = maxSigned31BitInt; +var Never = 1; +var Sync = maxSigned31BitInt; var UNIT_SIZE = 10; -var MAGIC_NUMBER_OFFSET = 2; +var MAGIC_NUMBER_OFFSET = maxSigned31BitInt - 1; // 1 unit of expiration time represents 10ms. function msToExpirationTime(ms) { // Always add an offset so that we don't clash with the magic number for NoWork. - return ((ms / UNIT_SIZE) | 0) + MAGIC_NUMBER_OFFSET; + return MAGIC_NUMBER_OFFSET - ((ms / UNIT_SIZE) | 0); } function expirationTimeToMs(expirationTime) { - return (expirationTime - MAGIC_NUMBER_OFFSET) * UNIT_SIZE; + return (MAGIC_NUMBER_OFFSET - expirationTime) * UNIT_SIZE; } function ceiling(num, precision) { @@ -5061,9 +5027,9 @@ function ceiling(num, precision) { function computeExpirationBucket(currentTime, expirationInMs, bucketSizeMs) { return ( - MAGIC_NUMBER_OFFSET + + MAGIC_NUMBER_OFFSET - ceiling( - currentTime - MAGIC_NUMBER_OFFSET + expirationInMs / UNIT_SIZE, + MAGIC_NUMBER_OFFSET - currentTime + expirationInMs / UNIT_SIZE, bucketSizeMs / UNIT_SIZE ) ); @@ -5139,6 +5105,7 @@ function FiberNode(tag, pendingProps, key, mode) { // Instance this.tag = tag; this.key = key; + this.elementType = null; this.type = null; this.stateNode = null; @@ -5211,18 +5178,24 @@ function shouldConstruct(Component) { return !!(prototype && prototype.isReactComponent); } -function resolveLazyComponentTag(fiber, Component) { +function isSimpleFunctionComponent(type) { + return ( + typeof type === "function" && + !shouldConstruct(type) && + type.defaultProps === undefined + ); +} + +function resolveLazyComponentTag(Component) { if (typeof Component === "function") { - return shouldConstruct(Component) - ? ClassComponentLazy - : FunctionComponentLazy; + return shouldConstruct(Component) ? ClassComponent : FunctionComponent; } else if (Component !== undefined && Component !== null) { var $$typeof = Component.$$typeof; if ($$typeof === REACT_FORWARD_REF_TYPE) { - return ForwardRefLazy; + return ForwardRef; } - if ($$typeof === REACT_PURE_TYPE) { - return PureComponentLazy; + if ($$typeof === REACT_MEMO_TYPE) { + return MemoComponent; } } return IndeterminateComponent; @@ -5243,6 +5216,7 @@ function createWorkInProgress(current, pendingProps, expirationTime) { current.key, current.mode ); + workInProgress.elementType = current.elementType; workInProgress.type = current.type; workInProgress.stateNode = current.stateNode; @@ -5312,20 +5286,23 @@ function createHostRootFiber(isConcurrent) { return createFiber(HostRoot, null, null, mode); } -function createFiberFromElement(element, mode, expirationTime) { - var owner = null; - { - owner = element._owner; - } - +function createFiberFromTypeAndProps( + type, // React$ElementType + key, + pendingProps, + owner, + mode, + expirationTime +) { var fiber = void 0; - var type = element.type; - var key = element.key; - var pendingProps = element.props; - var fiberTag = void 0; + var fiberTag = IndeterminateComponent; + // The resolved type is set if we know what the final type will be. I.e. it's not lazy. + var resolvedType = type; if (typeof type === "function") { - fiberTag = shouldConstruct(type) ? ClassComponent : IndeterminateComponent; + if (shouldConstruct(type)) { + fiberTag = ClassComponent; + } } else if (typeof type === "string") { fiberTag = HostComponent; } else { @@ -5338,18 +5315,23 @@ function createFiberFromElement(element, mode, expirationTime) { key ); case REACT_CONCURRENT_MODE_TYPE: - fiberTag = Mode; - mode |= ConcurrentMode | StrictMode; - break; + return createFiberFromMode( + pendingProps, + mode | ConcurrentMode | StrictMode, + expirationTime, + key + ); case REACT_STRICT_MODE_TYPE: - fiberTag = Mode; - mode |= StrictMode; - break; + return createFiberFromMode( + pendingProps, + mode | StrictMode, + expirationTime, + key + ); case REACT_PROFILER_TYPE: return createFiberFromProfiler(pendingProps, mode, expirationTime, key); case REACT_SUSPENSE_TYPE: - fiberTag = SuspenseComponent; - break; + return createFiberFromSuspense(pendingProps, mode, expirationTime, key); default: { if (typeof type === "object" && type !== null) { switch (type.$$typeof) { @@ -5363,15 +5345,13 @@ function createFiberFromElement(element, mode, expirationTime) { case REACT_FORWARD_REF_TYPE: fiberTag = ForwardRef; break getTag; - case REACT_PURE_TYPE: - fiberTag = PureComponent; + case REACT_MEMO_TYPE: + fiberTag = MemoComponent; + break getTag; + case REACT_LAZY_TYPE: + fiberTag = LazyComponent; + resolvedType = null; break getTag; - default: { - if (typeof type.then === "function") { - fiberTag = IndeterminateComponent; - break getTag; - } - } } } var info = ""; @@ -5405,14 +5385,33 @@ function createFiberFromElement(element, mode, expirationTime) { } fiber = createFiber(fiberTag, pendingProps, key, mode); - fiber.type = type; + fiber.elementType = type; + fiber.type = resolvedType; fiber.expirationTime = expirationTime; + return fiber; +} + +function createFiberFromElement(element, mode, expirationTime) { + var owner = null; + { + owner = element._owner; + } + var type = element.type; + var key = element.key; + var pendingProps = element.props; + var fiber = createFiberFromTypeAndProps( + type, + key, + pendingProps, + owner, + mode, + expirationTime + ); { fiber._debugSource = element._source; fiber._debugOwner = element._owner; } - return fiber; } @@ -5436,12 +5435,41 @@ function createFiberFromProfiler(pendingProps, mode, expirationTime, key) { } var fiber = createFiber(Profiler, pendingProps, key, mode | ProfileMode); + // TODO: The Profiler fiber shouldn't have a type. It has a tag. + fiber.elementType = REACT_PROFILER_TYPE; fiber.type = REACT_PROFILER_TYPE; fiber.expirationTime = expirationTime; return fiber; } +function createFiberFromMode(pendingProps, mode, expirationTime, key) { + var fiber = createFiber(Mode, pendingProps, key, mode); + + // TODO: The Mode fiber shouldn't have a type. It has a tag. + var type = + (mode & ConcurrentMode) === NoContext + ? REACT_STRICT_MODE_TYPE + : REACT_CONCURRENT_MODE_TYPE; + fiber.elementType = type; + fiber.type = type; + + fiber.expirationTime = expirationTime; + return fiber; +} + +function createFiberFromSuspense(pendingProps, mode, expirationTime, key) { + var fiber = createFiber(SuspenseComponent, pendingProps, key, mode); + + // TODO: The SuspenseComponent fiber shouldn't have a type. It has a tag. + var type = REACT_SUSPENSE_TYPE; + fiber.elementType = type; + fiber.type = type; + + fiber.expirationTime = expirationTime; + return fiber; +} + function createFiberFromText(content, mode, expirationTime) { var fiber = createFiber(HostText, content, null, mode); fiber.expirationTime = expirationTime; @@ -5450,6 +5478,8 @@ function createFiberFromText(content, mode, expirationTime) { function createFiberFromHostInstanceForDeletion() { var fiber = createFiber(HostComponent, null, null, NoContext); + // TODO: These should not need a type. + fiber.elementType = "DELETED"; fiber.type = "DELETED"; return fiber; } @@ -5482,6 +5512,7 @@ function assignFiberPropertiesInDEV(target, source) { target.tag = source.tag; target.key = source.key; + target.elementType = source.elementType; target.type = source.type; target.stateNode = source.stateNode; target.return = source.return; @@ -6024,12 +6055,12 @@ function markPendingPriorityLevel(root, expirationTime) { // No other pending updates. root.earliestPendingTime = root.latestPendingTime = expirationTime; } else { - if (earliestPendingTime > expirationTime) { + if (earliestPendingTime < expirationTime) { // This is the earliest pending update. root.earliestPendingTime = expirationTime; } else { var latestPendingTime = root.latestPendingTime; - if (latestPendingTime < expirationTime) { + if (latestPendingTime > expirationTime) { // This is the latest pending update root.latestPendingTime = expirationTime; } @@ -6055,12 +6086,12 @@ function markCommittedPriorityLevels(root, earliestRemainingTime) { // Let's see if the previous latest known pending level was just flushed. var latestPendingTime = root.latestPendingTime; if (latestPendingTime !== NoWork) { - if (latestPendingTime < earliestRemainingTime) { + if (latestPendingTime > earliestRemainingTime) { // We've flushed all the known pending levels. root.earliestPendingTime = root.latestPendingTime = NoWork; } else { var earliestPendingTime = root.earliestPendingTime; - if (earliestPendingTime < earliestRemainingTime) { + if (earliestPendingTime > earliestRemainingTime) { // We've flushed the earliest known pending level. Set this to the // latest pending time. root.earliestPendingTime = root.latestPendingTime; @@ -6082,7 +6113,7 @@ function markCommittedPriorityLevels(root, earliestRemainingTime) { } var latestSuspendedTime = root.latestSuspendedTime; - if (earliestRemainingTime > latestSuspendedTime) { + if (earliestRemainingTime < latestSuspendedTime) { // The earliest remaining level is later than all the suspended work. That // means we've flushed all the suspended work. root.earliestSuspendedTime = NoWork; @@ -6096,7 +6127,7 @@ function markCommittedPriorityLevels(root, earliestRemainingTime) { return; } - if (earliestRemainingTime < earliestSuspendedTime) { + if (earliestRemainingTime > earliestSuspendedTime) { // The earliest remaining time is earlier than all the suspended work. // Treat it as a pending update. markPendingPriorityLevel(root, earliestRemainingTime); @@ -6115,10 +6146,10 @@ function hasLowerPriorityWork(root, erroredExpirationTime) { var latestPingedTime = root.latestPingedTime; return ( (latestPendingTime !== NoWork && - latestPendingTime > erroredExpirationTime) || + latestPendingTime < erroredExpirationTime) || (latestSuspendedTime !== NoWork && - latestSuspendedTime > erroredExpirationTime) || - (latestPingedTime !== NoWork && latestPingedTime > erroredExpirationTime) + latestSuspendedTime < erroredExpirationTime) || + (latestPingedTime !== NoWork && latestPingedTime < erroredExpirationTime) ); } @@ -6127,8 +6158,8 @@ function isPriorityLevelSuspended(root, expirationTime) { var latestSuspendedTime = root.latestSuspendedTime; return ( earliestSuspendedTime !== NoWork && - expirationTime >= earliestSuspendedTime && - expirationTime <= latestSuspendedTime + expirationTime <= earliestSuspendedTime && + expirationTime >= latestSuspendedTime ); } @@ -6161,10 +6192,10 @@ function markSuspendedPriorityLevel(root, suspendedTime) { // No other suspended levels. root.earliestSuspendedTime = root.latestSuspendedTime = suspendedTime; } else { - if (earliestSuspendedTime > suspendedTime) { + if (earliestSuspendedTime < suspendedTime) { // This is the earliest suspended level. root.earliestSuspendedTime = suspendedTime; - } else if (latestSuspendedTime < suspendedTime) { + } else if (latestSuspendedTime > suspendedTime) { // This is the latest suspended level root.latestSuspendedTime = suspendedTime; } @@ -6180,7 +6211,7 @@ function markPingedPriorityLevel(root, pingedTime) { // is thrown out and not reused during the restarted render. One way to // invalidate the progressed work is to restart at expirationTime + 1. var latestPingedTime = root.latestPingedTime; - if (latestPingedTime === NoWork || latestPingedTime < pingedTime) { + if (latestPingedTime === NoWork || latestPingedTime > pingedTime) { root.latestPingedTime = pingedTime; } findNextExpirationTimeToWorkOn(pingedTime, root); @@ -6190,7 +6221,7 @@ function clearPing(root, completedTime) { // TODO: Track whether the root was pinged during the render phase. If so, // we need to make sure we don't lose track of it. var latestPingedTime = root.latestPingedTime; - if (latestPingedTime !== NoWork && latestPingedTime <= completedTime) { + if (latestPingedTime !== NoWork && latestPingedTime >= completedTime) { root.latestPingedTime = NoWork; } } @@ -6200,18 +6231,10 @@ function findEarliestOutstandingPriorityLevel(root, renderExpirationTime) { var earliestPendingTime = root.earliestPendingTime; var earliestSuspendedTime = root.earliestSuspendedTime; - if ( - earliestExpirationTime === NoWork || - (earliestPendingTime !== NoWork && - earliestPendingTime < earliestExpirationTime) - ) { + if (earliestPendingTime > earliestExpirationTime) { earliestExpirationTime = earliestPendingTime; } - if ( - earliestExpirationTime === NoWork || - (earliestSuspendedTime !== NoWork && - earliestSuspendedTime < earliestExpirationTime) - ) { + if (earliestSuspendedTime > earliestExpirationTime) { earliestExpirationTime = earliestSuspendedTime; } return earliestExpirationTime; @@ -6219,7 +6242,7 @@ function findEarliestOutstandingPriorityLevel(root, renderExpirationTime) { function didExpireAtExpirationTime(root, currentTime) { var expirationTime = root.expirationTime; - if (expirationTime !== NoWork && currentTime >= expirationTime) { + if (expirationTime !== NoWork && currentTime <= expirationTime) { // The root has expired. Flush all work up to the current time. root.nextExpirationTimeToWorkOn = currentTime; } @@ -6241,7 +6264,7 @@ function findNextExpirationTimeToWorkOn(completedExpirationTime, root) { if ( nextExpirationTimeToWorkOn === NoWork && (completedExpirationTime === NoWork || - latestSuspendedTime > completedExpirationTime) + latestSuspendedTime < completedExpirationTime) ) { // The lowest priority suspended work is the work most likely to be // committed next. Let's start rendering it again, so that if it times out, @@ -6250,11 +6273,7 @@ function findNextExpirationTimeToWorkOn(completedExpirationTime, root) { } var expirationTime = nextExpirationTimeToWorkOn; - if ( - expirationTime !== NoWork && - earliestSuspendedTime !== NoWork && - earliestSuspendedTime < expirationTime - ) { + if (expirationTime !== NoWork && earliestSuspendedTime > expirationTime) { // Expire using the earliest known expiration time. expirationTime = earliestSuspendedTime; } @@ -6478,7 +6497,7 @@ function enqueueUpdate(fiber, update) { { if ( - (fiber.tag === ClassComponent || fiber.tag === ClassComponentLazy) && + fiber.tag === ClassComponent && (currentlyProcessingQueue === queue1 || (queue2 !== null && currentlyProcessingQueue === queue2)) && !didWarnUpdateInsideUpdate @@ -6626,7 +6645,7 @@ function processUpdateQueue( var resultState = newBaseState; while (update !== null) { var updateExpirationTime = update.expirationTime; - if (updateExpirationTime > renderExpirationTime) { + if (updateExpirationTime < renderExpirationTime) { // This update does not have sufficient priority. Skip it. if (newFirstUpdate === null) { // This is the first skipped update. It will be the first update in @@ -6638,10 +6657,7 @@ function processUpdateQueue( } // Since this update will remain in the list, update the remaining // expiration time. - if ( - newExpirationTime === NoWork || - newExpirationTime > updateExpirationTime - ) { + if (newExpirationTime < updateExpirationTime) { newExpirationTime = updateExpirationTime; } } else { @@ -6677,7 +6693,7 @@ function processUpdateQueue( update = queue.firstCapturedUpdate; while (update !== null) { var _updateExpirationTime = update.expirationTime; - if (_updateExpirationTime > renderExpirationTime) { + if (_updateExpirationTime < renderExpirationTime) { // This update does not have sufficient priority. Skip it. if (newFirstCapturedUpdate === null) { // This is the first skipped captured update. It will be the first @@ -6691,10 +6707,7 @@ function processUpdateQueue( } // Since this update will remain in the list, update the remaining // expiration time. - if ( - newExpirationTime === NoWork || - newExpirationTime > _updateExpirationTime - ) { + if (newExpirationTime < _updateExpirationTime) { newExpirationTime = _updateExpirationTime; } } else { @@ -6992,10 +7005,7 @@ function propagateContextChange( ) { // Match! Schedule an update on this fiber. - if ( - fiber.tag === ClassComponent || - fiber.tag === ClassComponentLazy - ) { + if (fiber.tag === ClassComponent) { // Schedule a force update on the work-in-progress. var update = createUpdate(renderExpirationTime); update.tag = ForceUpdate; @@ -7006,17 +7016,13 @@ function propagateContextChange( enqueueUpdate(fiber, update); } - if ( - fiber.expirationTime === NoWork || - fiber.expirationTime > renderExpirationTime - ) { + if (fiber.expirationTime < renderExpirationTime) { fiber.expirationTime = renderExpirationTime; } var alternate = fiber.alternate; if ( alternate !== null && - (alternate.expirationTime === NoWork || - alternate.expirationTime > renderExpirationTime) + alternate.expirationTime < renderExpirationTime ) { alternate.expirationTime = renderExpirationTime; } @@ -7025,22 +7031,17 @@ function propagateContextChange( var node = fiber.return; while (node !== null) { alternate = node.alternate; - if ( - node.childExpirationTime === NoWork || - node.childExpirationTime > renderExpirationTime - ) { + if (node.childExpirationTime < renderExpirationTime) { node.childExpirationTime = renderExpirationTime; if ( alternate !== null && - (alternate.childExpirationTime === NoWork || - alternate.childExpirationTime > renderExpirationTime) + alternate.childExpirationTime < renderExpirationTime ) { alternate.childExpirationTime = renderExpirationTime; } } else if ( alternate !== null && - (alternate.childExpirationTime === NoWork || - alternate.childExpirationTime > renderExpirationTime) + alternate.childExpirationTime < renderExpirationTime ) { alternate.childExpirationTime = renderExpirationTime; } else { @@ -7125,7 +7126,7 @@ function readContext(context, observedBits) { if (lastContextDependency === null) { invariant( currentlyRenderingFiber !== null, - "Context.unstable_read(): Context can only be read while React is " + + "Context can only be read while React is " + "rendering, e.g. inside the render method or getDerivedStateFromProps." ); // This is the first dependency in the list @@ -7138,138 +7139,780 @@ function readContext(context, observedBits) { return isPrimaryRenderer ? context._currentValue : context._currentValue2; } -var NO_CONTEXT = {}; +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; -var contextStackCursor$1 = createCursor(NO_CONTEXT); -var contextFiberStackCursor = createCursor(NO_CONTEXT); -var rootInstanceStackCursor = createCursor(NO_CONTEXT); +function areHookInputsEqual(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; +} -function requiredContext(c) { +// 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( - c !== NO_CONTEXT, - "Expected host context to exist. This error is likely caused by a bug " + - "in React. Please file an issue." + currentlyRenderingFiber$1 !== null, + "Hooks can only be called inside the body of a function component." ); - return c; + return currentlyRenderingFiber$1; } -function getRootHostContainer() { - var rootInstance = requiredContext(rootInstanceStackCursor.current); - return rootInstance; -} +function prepareToUseHooks(current, workInProgress, nextRenderExpirationTime) { + if (!enableHooks) { + return; + } + renderExpirationTime = nextRenderExpirationTime; + currentlyRenderingFiber$1 = workInProgress; + firstCurrentHook = current !== null ? current.memoizedState : null; -function pushHostContainer(fiber, nextRootInstance) { - // Push current root instance onto the stack; - // This allows us to reset root when portals are popped. - push(rootInstanceStackCursor, nextRootInstance, fiber); - // Track the context and the Fiber that provided it. - // This enables us to pop only Fibers that provide unique contexts. - push(contextFiberStackCursor, fiber, fiber); + // The following should have already been reset + // currentHook = null; + // workInProgressHook = null; - // Finally, we need to push the host context to the stack. - // However, we can't just call getRootHostContext() and push it because - // we'd have a different number of entries on the stack depending on - // whether getRootHostContext() throws somewhere in renderer code or not. - // So we push an empty value first. This lets us safely unwind on errors. - push(contextStackCursor$1, NO_CONTEXT, fiber); - var nextRootContext = getRootHostContext(nextRootInstance); - // Now that we know this function doesn't throw, replace it. - pop(contextStackCursor$1, fiber); - push(contextStackCursor$1, nextRootContext, fiber); -} + // remainingExpirationTime = NoWork; + // componentUpdateQueue = null; -function popHostContainer(fiber) { - pop(contextStackCursor$1, fiber); - pop(contextFiberStackCursor, fiber); - pop(rootInstanceStackCursor, fiber); + // isReRender = false; + // didScheduleRenderPhaseUpdate = false; + // renderPhaseUpdates = null; + // numberOfReRenders = 0; } -function getHostContext() { - var context = requiredContext(contextStackCursor$1.current); - return context; -} +function finishHooks(Component, props, children, refOrContext) { + if (!enableHooks) { + return children; + } -function pushHostContext(fiber) { - var rootInstance = requiredContext(rootInstanceStackCursor.current); - var context = requiredContext(contextStackCursor$1.current); - var nextContext = getChildHostContext(context, fiber.type, rootInstance); + // This must be called after every function component to prevent hooks from + // being used in classes. - // Don't push this Fiber's context unless it's unique. - if (context === nextContext) { - return; - } + 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; - // Track the context and the Fiber that provided it. - // This enables us to pop only Fibers that provide unique contexts. - push(contextFiberStackCursor, fiber, fiber); - push(contextStackCursor$1, nextContext, fiber); -} + // Start over from the beginning of the list + currentHook = null; + workInProgressHook = null; + componentUpdateQueue = null; -function popHostContext(fiber) { - // Do not pop unless this Fiber provided the current context. - // pushHostContext() only pushes Fibers that provide unique contexts. - if (contextFiberStackCursor.current !== fiber) { - return; + children = Component(props, refOrContext); } + renderPhaseUpdates = null; + numberOfReRenders = 0; - pop(contextStackCursor$1, fiber); - pop(contextFiberStackCursor, fiber); -} + var renderedWork = currentlyRenderingFiber$1; -var commitTime = 0; -var profilerStartTime = -1; + renderedWork.memoizedState = firstWorkInProgressHook; + renderedWork.expirationTime = remainingExpirationTime; + renderedWork.updateQueue = componentUpdateQueue; -function getCommitTime() { - return commitTime; -} + var didRenderTooFewHooks = currentHook !== null && currentHook.next !== null; -function recordCommitTime() { - if (!enableProfilerTimer) { - return; - } - commitTime = now(); -} + renderExpirationTime = NoWork; + currentlyRenderingFiber$1 = null; -function startProfilerTimer(fiber) { - if (!enableProfilerTimer) { - return; - } + firstCurrentHook = null; + currentHook = null; + firstWorkInProgressHook = null; + workInProgressHook = null; - profilerStartTime = now(); + remainingExpirationTime = NoWork; + componentUpdateQueue = null; - if (fiber.actualStartTime < 0) { - fiber.actualStartTime = now(); - } -} + // Always set during createWorkInProgress + // isReRender = false; -function stopProfilerTimerIfRunning(fiber) { - if (!enableProfilerTimer) { - return; - } - profilerStartTime = -1; + // 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 stopProfilerTimerIfRunningAndRecordDelta(fiber, overrideBaseTime) { - if (!enableProfilerTimer) { +function resetHooks() { + if (!enableHooks) { return; } - if (profilerStartTime >= 0) { - var elapsedTime = now() - profilerStartTime; - fiber.actualDuration += elapsedTime; - if (overrideBaseTime) { - fiber.selfBaseDuration = elapsedTime; - } - profilerStartTime = -1; - } -} + // 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; -/*eslint-disable no-self-compare */ + firstCurrentHook = null; + currentHook = null; + firstWorkInProgressHook = null; + workInProgressHook = null; -var hasOwnProperty = Object.prototype.hasOwnProperty; + remainingExpirationTime = NoWork; + componentUpdateQueue = null; -/** - * inlined Object.is polyfill to avoid requiring consumers ship their own + // 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 (areHookInputsEqual(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 (areHookInputsEqual(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 (areHookInputsEqual(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); + } +} + +var NO_CONTEXT = {}; + +var contextStackCursor$1 = createCursor(NO_CONTEXT); +var contextFiberStackCursor = createCursor(NO_CONTEXT); +var rootInstanceStackCursor = createCursor(NO_CONTEXT); + +function requiredContext(c) { + invariant( + c !== NO_CONTEXT, + "Expected host context to exist. This error is likely caused by a bug " + + "in React. Please file an issue." + ); + return c; +} + +function getRootHostContainer() { + var rootInstance = requiredContext(rootInstanceStackCursor.current); + return rootInstance; +} + +function pushHostContainer(fiber, nextRootInstance) { + // Push current root instance onto the stack; + // This allows us to reset root when portals are popped. + push(rootInstanceStackCursor, nextRootInstance, fiber); + // Track the context and the Fiber that provided it. + // This enables us to pop only Fibers that provide unique contexts. + push(contextFiberStackCursor, fiber, fiber); + + // Finally, we need to push the host context to the stack. + // However, we can't just call getRootHostContext() and push it because + // we'd have a different number of entries on the stack depending on + // whether getRootHostContext() throws somewhere in renderer code or not. + // So we push an empty value first. This lets us safely unwind on errors. + push(contextStackCursor$1, NO_CONTEXT, fiber); + var nextRootContext = getRootHostContext(nextRootInstance); + // Now that we know this function doesn't throw, replace it. + pop(contextStackCursor$1, fiber); + push(contextStackCursor$1, nextRootContext, fiber); +} + +function popHostContainer(fiber) { + pop(contextStackCursor$1, fiber); + pop(contextFiberStackCursor, fiber); + pop(rootInstanceStackCursor, fiber); +} + +function getHostContext() { + var context = requiredContext(contextStackCursor$1.current); + return context; +} + +function pushHostContext(fiber) { + var rootInstance = requiredContext(rootInstanceStackCursor.current); + var context = requiredContext(contextStackCursor$1.current); + var nextContext = getChildHostContext(context, fiber.type, rootInstance); + + // Don't push this Fiber's context unless it's unique. + if (context === nextContext) { + return; + } + + // Track the context and the Fiber that provided it. + // This enables us to pop only Fibers that provide unique contexts. + push(contextFiberStackCursor, fiber, fiber); + push(contextStackCursor$1, nextContext, fiber); +} + +function popHostContext(fiber) { + // Do not pop unless this Fiber provided the current context. + // pushHostContext() only pushes Fibers that provide unique contexts. + if (contextFiberStackCursor.current !== fiber) { + return; + } + + pop(contextStackCursor$1, fiber); + pop(contextFiberStackCursor, fiber); +} + +var commitTime = 0; +var profilerStartTime = -1; + +function getCommitTime() { + return commitTime; +} + +function recordCommitTime() { + if (!enableProfilerTimer) { + return; + } + commitTime = now(); +} + +function startProfilerTimer(fiber) { + if (!enableProfilerTimer) { + return; + } + + profilerStartTime = now(); + + if (fiber.actualStartTime < 0) { + fiber.actualStartTime = now(); + } +} + +function stopProfilerTimerIfRunning(fiber) { + if (!enableProfilerTimer) { + return; + } + profilerStartTime = -1; +} + +function stopProfilerTimerIfRunningAndRecordDelta(fiber, overrideBaseTime) { + if (!enableProfilerTimer) { + return; + } + + if (profilerStartTime >= 0) { + var elapsedTime = now() - profilerStartTime; + fiber.actualDuration += elapsedTime; + if (overrideBaseTime) { + fiber.selfBaseDuration = elapsedTime; + } + profilerStartTime = -1; + } +} + +/*eslint-disable no-self-compare */ + +var hasOwnProperty = Object.prototype.hasOwnProperty; + +/** + * inlined Object.is polyfill to avoid requiring consumers ship their own * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is */ function is(x, y) { @@ -7324,6 +7967,80 @@ function shallowEqual(objA, objB) { return true; } +function resolveDefaultProps(Component, baseProps) { + if (Component && Component.defaultProps) { + // Resolve default props. Taken from ReactElement + var props = Object.assign({}, baseProps); + var defaultProps = Component.defaultProps; + for (var propName in defaultProps) { + if (props[propName] === undefined) { + props[propName] = defaultProps[propName]; + } + } + return props; + } + return baseProps; +} + +function readLazyComponentType(lazyComponent) { + var status = lazyComponent._status; + var result = lazyComponent._result; + switch (status) { + case Resolved: { + var Component = result; + return Component; + } + case Rejected: { + var error = result; + throw error; + } + case Pending: { + var thenable = result; + 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 + ); + } + } + lazyComponent._status = Resolved; + lazyComponent._result = defaultExport; + } + }, + function(error) { + if (lazyComponent._status === Pending) { + lazyComponent._status = Rejected; + lazyComponent._result = error; + } + } + ); + lazyComponent._result = _thenable; + throw _thenable; + } + } +} + +var ReactCurrentOwner$4 = ReactSharedInternals.ReactCurrentOwner; + +function readContext$1(contextType) { + var dispatcher = ReactCurrentOwner$4.currentDispatcher; + return dispatcher.readContext(contextType); +} + var fakeInternalInstance = {}; var isArray$1 = Array.isArray; @@ -7463,6 +8180,7 @@ var classComponentUpdater = { update.callback = callback; } + flushPassiveEffects(); enqueueUpdate(fiber, update); scheduleWork(fiber, expirationTime); }, @@ -7482,6 +8200,7 @@ var classComponentUpdater = { update.callback = callback; } + flushPassiveEffects(); enqueueUpdate(fiber, update); scheduleWork(fiber, expirationTime); }, @@ -7500,6 +8219,7 @@ var classComponentUpdater = { update.callback = callback; } + flushPassiveEffects(); enqueueUpdate(fiber, update); scheduleWork(fiber, expirationTime); } @@ -7816,7 +8536,7 @@ function constructClassInstance( if (typeof contextType === "object" && contextType !== null) { { if ( - typeof contextType.unstable_read !== "function" && + contextType.$$typeof !== REACT_CONTEXT_TYPE && !didWarnAboutInvalidateContextType.has(ctor) ) { didWarnAboutInvalidateContextType.add(ctor); @@ -7830,7 +8550,7 @@ function constructClassInstance( } } - context = contextType.unstable_read(); + context = readContext$1(contextType); } else { unmaskedContext = getUnmaskedContext(workInProgress, ctor, true); var contextTypes = ctor.contextTypes; @@ -8032,7 +8752,7 @@ function mountClassInstance( var contextType = ctor.contextType; if (typeof contextType === "object" && contextType !== null) { - instance.context = contextType.unstable_read(); + instance.context = readContext$1(contextType); } else { var unmaskedContext = getUnmaskedContext(workInProgress, ctor, true); instance.context = getMaskedContext(workInProgress, unmaskedContext); @@ -8140,7 +8860,7 @@ function resumeMountClassInstance( var contextType = ctor.contextType; var nextContext = void 0; if (typeof contextType === "object" && contextType !== null) { - nextContext = contextType.unstable_read(); + nextContext = readContext$1(contextType); } else { var nextLegacyUnmaskedContext = getUnmaskedContext( workInProgress, @@ -8280,13 +9000,16 @@ function updateClassInstance( var instance = workInProgress.stateNode; var oldProps = workInProgress.memoizedProps; - instance.props = oldProps; + instance.props = + workInProgress.type === workInProgress.elementType + ? oldProps + : resolveDefaultProps(workInProgress.type, oldProps); var oldContext = instance.context; var contextType = ctor.contextType; var nextContext = void 0; if (typeof contextType === "object" && contextType !== null) { - nextContext = contextType.unstable_read(); + nextContext = readContext$1(contextType); } else { var nextUnmaskedContext = getUnmaskedContext(workInProgress, ctor, true); nextContext = getMaskedContext(workInProgress, nextUnmaskedContext); @@ -8529,8 +9252,7 @@ function coerceRef(returnFiber, current$$1, element) { if (owner) { var ownerFiber = owner; invariant( - ownerFiber.tag === ClassComponent || - ownerFiber.tag === ClassComponentLazy, + ownerFiber.tag === ClassComponent, "Function components cannot have refs." ); inst = ownerFiber.stateNode; @@ -8750,7 +9472,7 @@ function ChildReconciler(shouldTrackSideEffects) { } function updateElement(returnFiber, current$$1, element, expirationTime) { - if (current$$1 !== null && current$$1.type === element.type) { + if (current$$1 !== null && current$$1.elementType === element.type) { // Move based on index var existing = useFiber(current$$1, element.props, expirationTime); existing.ref = coerceRef(returnFiber, current$$1, element); @@ -9488,7 +10210,7 @@ function ChildReconciler(shouldTrackSideEffects) { if ( child.tag === Fragment ? element.type === REACT_FRAGMENT_TYPE - : child.type === element.type + : child.elementType === element.type ) { deleteRemainingChildren(returnFiber, child.sibling); var existing = useFiber( @@ -9671,8 +10393,7 @@ function ChildReconciler(shouldTrackSideEffects) { // component, throw an error. If Fiber return types are disabled, // we already threw above. switch (returnFiber.tag) { - case ClassComponent: - case ClassComponentLazy: { + case ClassComponent: { { var instance = returnFiber.stateNode; if (instance.render._isMockFunction) { @@ -10055,49 +10776,6 @@ function resetHydrationState() { isHydrating = false; } -function readLazyComponentType(thenable) { - var status = thenable._reactStatus; - switch (status) { - case Resolved: - var Component = thenable._reactResult; - return Component; - case Rejected: - throw thenable._reactResult; - case Pending: - throw thenable; - default: { - thenable._reactStatus = Pending; - thenable.then( - function(resolvedValue) { - if (thenable._reactStatus === Pending) { - thenable._reactStatus = Resolved; - if (typeof resolvedValue === "object" && resolvedValue !== null) { - // If the `default` property is not empty, assume it's the result - // of an async import() and use that. Otherwise, use the - // resolved value itself. - var defaultExport = resolvedValue.default; - resolvedValue = - defaultExport !== undefined && defaultExport !== null - ? defaultExport - : resolvedValue; - } else { - resolvedValue = resolvedValue; - } - thenable._reactResult = resolvedValue; - } - }, - function(error) { - if (thenable._reactStatus === Pending) { - thenable._reactStatus = Rejected; - thenable._reactResult = error; - } - } - ); - throw thenable; - } - } -} - var ReactCurrentOwner$3 = ReactSharedInternals.ReactCurrentOwner; var didWarnAboutBadClass = void 0; @@ -10180,45 +10858,37 @@ function forceUnmountCurrentAndReconcile( function updateForwardRef( current$$1, workInProgress, - type, + Component, nextProps, renderExpirationTime ) { - var render = type.render; + var render = Component.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); + // React DevTools reads this flag. + workInProgress.effectTag |= PerformedWork; reconcileChildren( current$$1, workInProgress, nextChildren, renderExpirationTime ); - memoizeProps(workInProgress, nextProps); return workInProgress.child; } -function updatePureComponent( +function updateMemoComponent( current$$1, workInProgress, Component, @@ -10226,21 +10896,47 @@ function updatePureComponent( updateExpirationTime, renderExpirationTime ) { - var render = Component.render; - var ref = workInProgress.ref; - - if ( - current$$1 !== null && - (updateExpirationTime === NoWork || - updateExpirationTime > renderExpirationTime) - ) { - var prevProps = current$$1.memoizedProps; + 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 ( - workInProgress.ref === current$$1.ref && - compare(prevProps, nextProps) + compare(prevProps, nextProps) && + current$$1.ref === workInProgress.ref ) { return bailoutOnAlreadyFinishedWork( current$$1, @@ -10249,27 +10945,47 @@ function updatePureComponent( ); } } - - // 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; - reconcileChildren( + 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, - nextChildren, + Component, + nextProps, renderExpirationTime ); - memoizeProps(workInProgress, nextProps); - return workInProgress.child; } function updateFragment(current$$1, workInProgress, renderExpirationTime) { @@ -10280,7 +10996,6 @@ function updateFragment(current$$1, workInProgress, renderExpirationTime) { nextChildren, renderExpirationTime ); - memoizeProps(workInProgress, nextChildren); return workInProgress.child; } @@ -10292,7 +11007,6 @@ function updateMode(current$$1, workInProgress, renderExpirationTime) { nextChildren, renderExpirationTime ); - memoizeProps(workInProgress, nextChildren); return workInProgress.child; } @@ -10308,7 +11022,6 @@ function updateProfiler(current$$1, workInProgress, renderExpirationTime) { nextChildren, renderExpirationTime ); - memoizeProps(workInProgress, nextProps); return workInProgress.child; } @@ -10335,12 +11048,14 @@ function updateFunctionComponent( var nextChildren = void 0; prepareToReadContext(workInProgress, renderExpirationTime); + prepareToUseHooks(current$$1, workInProgress, renderExpirationTime); { ReactCurrentOwner$3.current = workInProgress; setCurrentPhase("render"); nextChildren = Component(nextProps, context); setCurrentPhase(null); } + nextChildren = finishHooks(Component, nextProps, nextChildren, context); // React DevTools reads this flag. workInProgress.effectTag |= PerformedWork; @@ -10350,7 +11065,6 @@ function updateFunctionComponent( nextChildren, renderExpirationTime ); - memoizeProps(workInProgress, nextProps); return workInProgress.child; } @@ -10373,32 +11087,41 @@ function updateClassComponent( } prepareToReadContext(workInProgress, renderExpirationTime); - var shouldUpdate = void 0; - if (current$$1 === null) { - if (workInProgress.stateNode === null) { - // In the initial pass we might need to construct the instance. - constructClassInstance( - workInProgress, - Component, - nextProps, - renderExpirationTime - ); - mountClassInstance( - workInProgress, - Component, - nextProps, - renderExpirationTime - ); - shouldUpdate = true; - } else { - // In a resume, we'll already have an instance we can reuse. - shouldUpdate = resumeMountClassInstance( - workInProgress, - Component, - nextProps, - renderExpirationTime - ); - } + 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; + } + // In the initial pass we might need to construct the instance. + constructClassInstance( + workInProgress, + Component, + nextProps, + renderExpirationTime + ); + mountClassInstance( + workInProgress, + Component, + nextProps, + renderExpirationTime + ); + shouldUpdate = true; + } else if (current$$1 === null) { + // In a resume, we'll already have an instance we can reuse. + shouldUpdate = resumeMountClassInstance( + workInProgress, + Component, + nextProps, + renderExpirationTime + ); } else { shouldUpdate = updateClassInstance( current$$1, @@ -10500,10 +11223,9 @@ function finishClassComponent( ); } - // Memoize props and state using the values we just used to render. + // Memoize state using the values we just used to render. // TODO: Restructure so we never read values from the instance. - memoizeState(workInProgress, instance.state); - memoizeProps(workInProgress, instance.props); + workInProgress.memoizedState = instance.state; // The context might have changed so we need to recalculate it. if (hasContext) { @@ -10637,7 +11359,6 @@ function updateHostComponent(current$$1, workInProgress, renderExpirationTime) { ) { // Schedule this fiber to re-render at offscreen priority. Then bailout. workInProgress.expirationTime = Never; - workInProgress.memoizedProps = nextProps; return null; } @@ -10647,7 +11368,6 @@ function updateHostComponent(current$$1, workInProgress, renderExpirationTime) { nextChildren, renderExpirationTime ); - memoizeProps(workInProgress, nextProps); return workInProgress.child; } @@ -10655,120 +11375,178 @@ 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; } -function resolveDefaultProps(Component, baseProps) { - if (Component && Component.defaultProps) { - // Resolve default props. Taken from ReactElement - var props = Object.assign({}, baseProps); - var defaultProps = Component.defaultProps; - for (var propName in defaultProps) { - if (props[propName] === undefined) { - props[propName] = defaultProps[propName]; - } +function mountLazyComponent( + _current, + workInProgress, + elementType, + 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 treat it like + // a new mount, even though an empty version of it already committed. + // Disconnect the alternate pointers. + _current.alternate = null; + workInProgress.alternate = null; + // Since this is conceptually a new fiber, schedule a Placement effect + workInProgress.effectTag |= Placement; + } + + var props = workInProgress.pendingProps; + // We can't start a User Timing measurement with correct label yet. + // Cancel and resume right after we know the tag. + cancelWorkTimer(workInProgress); + var Component = readLazyComponentType(elementType); + // Store the unwrapped component in the type. + workInProgress.type = Component; + var resolvedTag = (workInProgress.tag = resolveLazyComponentTag(Component)); + startWorkTimer(workInProgress); + var resolvedProps = resolveDefaultProps(Component, props); + var child = void 0; + switch (resolvedTag) { + case FunctionComponent: { + child = updateFunctionComponent( + null, + workInProgress, + Component, + resolvedProps, + renderExpirationTime + ); + break; + } + case ClassComponent: { + child = updateClassComponent( + null, + workInProgress, + Component, + resolvedProps, + renderExpirationTime + ); + break; + } + case ForwardRef: { + child = updateForwardRef( + null, + workInProgress, + Component, + resolvedProps, + renderExpirationTime + ); + break; + } + case MemoComponent: { + child = updateMemoComponent( + null, + workInProgress, + Component, + resolveDefaultProps(Component.type, resolvedProps), // The inner type can have defaults too + updateExpirationTime, + renderExpirationTime + ); + break; + } + default: { + // This message intentionally doesn't metion ForwardRef or MemoComponent + // because the fact that it's a separate type of work is an + // implementation detail. + invariant( + false, + "Element type is invalid. Received a promise that resolves to: %s. " + + "Promise elements must resolve to a class or function.", + Component + ); } - return props; } - return baseProps; + return child; } -function mountIndeterminateComponent( - current$$1, +function mountIncompleteClassComponent( + _current, workInProgress, Component, - updateExpirationTime, + nextProps, renderExpirationTime ) { - invariant( - current$$1 === null, - "An indeterminate component should never have mounted. This error is " + - "likely caused by a bug in React. Please file an issue." + if (_current !== null) { + // An incomplete component only mounts if it suspended inside a non- + // concurrent tree, in an inconsistent state. We want to treat it like + // a new mount, even though an empty version of it already committed. + // Disconnect the alternate pointers. + _current.alternate = null; + workInProgress.alternate = null; + // Since this is conceptually a new fiber, schedule a Placement effect + workInProgress.effectTag |= Placement; + } + + // Promote the fiber to a class and try rendering again. + workInProgress.tag = ClassComponent; + + // The rest of this function is a fork of `updateClassComponent` + + // Push context providers early to prevent context stack mismatches. + // During mounting we don't know the child context yet as the instance doesn't exist. + // We will invalidate the child context in finishClassComponent() right after rendering. + var hasContext = void 0; + if (isContextProvider(Component)) { + hasContext = true; + pushContextProvider(workInProgress); + } else { + hasContext = false; + } + prepareToReadContext(workInProgress, renderExpirationTime); + + constructClassInstance( + workInProgress, + Component, + nextProps, + renderExpirationTime + ); + mountClassInstance( + workInProgress, + Component, + nextProps, + renderExpirationTime ); - var props = workInProgress.pendingProps; - if ( - typeof Component === "object" && - Component !== null && - typeof Component.then === "function" - ) { - // We can't start a User Timing measurement with correct label yet. - // Cancel and resume right after we know the tag. - cancelWorkTimer(workInProgress); - Component = readLazyComponentType(Component); - var resolvedTag = (workInProgress.tag = resolveLazyComponentTag( - workInProgress, - Component - )); - startWorkTimer(workInProgress); - var resolvedProps = resolveDefaultProps(Component, props); - var child = void 0; - switch (resolvedTag) { - case FunctionComponentLazy: { - child = updateFunctionComponent( - current$$1, - workInProgress, - Component, - resolvedProps, - renderExpirationTime - ); - break; - } - case ClassComponentLazy: { - child = updateClassComponent( - current$$1, - workInProgress, - Component, - resolvedProps, - renderExpirationTime - ); - break; - } - case ForwardRefLazy: { - child = updateForwardRef( - current$$1, - workInProgress, - Component, - resolvedProps, - renderExpirationTime - ); - break; - } - case PureComponentLazy: { - child = updatePureComponent( - current$$1, - workInProgress, - Component, - resolvedProps, - updateExpirationTime, - renderExpirationTime - ); - break; - } - default: { - // This message intentionally doesn't metion ForwardRef or PureComponent - // because the fact that it's a separate type of work is an - // implementation detail. - invariant( - false, - "Element type is invalid. Received a promise that resolves to: %s. " + - "Promise elements must resolve to a class or function.", - Component - ); - } - } - workInProgress.memoizedProps = props; - return child; + 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 treat it like + // a new mount, even though an empty version of it already committed. + // Disconnect the alternate pointers. + _current.alternate = null; + workInProgress.alternate = null; + // Since this is conceptually a new fiber, schedule a Placement effect + workInProgress.effectTag |= Placement; } + var props = workInProgress.pendingProps; var unmaskedContext = getUnmaskedContext(workInProgress, Component, false); var context = getMaskedContext(workInProgress, unmaskedContext); prepareToReadContext(workInProgress, renderExpirationTime); + prepareToUseHooks(null, workInProgress, renderExpirationTime); var value = void 0; @@ -10810,6 +11588,9 @@ function mountIndeterminateComponent( // Proceed under the assumption that this is a class instance workInProgress.tag = ClassComponent; + // Throw out any hooks that were used. + resetHooks(); + // Push context providers early to prevent context stack mismatches. // During mounting we don't know the child context yet as the instance doesn't exist. // We will invalidate the child context in finishClassComponent() right after rendering. @@ -10837,7 +11618,7 @@ function mountIndeterminateComponent( adoptClassInstance(workInProgress, value); mountClassInstance(workInProgress, Component, props, renderExpirationTime); return finishClassComponent( - current$$1, + null, workInProgress, Component, true, @@ -10847,6 +11628,7 @@ function mountIndeterminateComponent( } else { // Proceed under the assumption that this is a function component workInProgress.tag = FunctionComponent; + value = finishHooks(Component, props, value, context); { if (Component) { !!Component.childContextTypes @@ -10909,8 +11691,7 @@ function mountIndeterminateComponent( } } } - reconcileChildren(current$$1, workInProgress, value, renderExpirationTime); - memoizeProps(workInProgress, props); + reconcileChildren(null, workInProgress, value, renderExpirationTime); return workInProgress.child; } } @@ -10920,67 +11701,258 @@ function updateSuspenseComponent( workInProgress, renderExpirationTime ) { + var mode = workInProgress.mode; var nextProps = workInProgress.pendingProps; - // Check if we already attempted to render the normal state. If we did, - // and we timed out, render the placeholder state. - var alreadyCaptured = (workInProgress.effectTag & DidCapture) === NoEffect; + // We should attempt to render the primary children unless this boundary + // already suspended during this render (`alreadyCaptured` is true). + var nextState = workInProgress.memoizedState; 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; + if ((workInProgress.effectTag & DidCapture) === NoEffect) { + // This is the first attempt. + nextState = null; + nextDidTimeout = false; } else { - nextDidTimeout = !alreadyCaptured; + // Something in this boundary's subtree already suspended. Switch to + // rendering the fallback children. + nextState = { + timedOutAt: nextState !== null ? nextState.timedOutAt : NoWork + }; + nextDidTimeout = true; + workInProgress.effectTag &= ~DidCapture; } - if ((workInProgress.mode & StrictMode) !== NoEffect) { + // This next part is a bit confusing. If the children timeout, we switch to + // showing the fallback children in place of the "primary" children. + // However, we don't want to delete the primary children because then their + // state will be lost (both the React state and the host state, e.g. + // uncontrolled form inputs). Instead we keep them mounted and hide them. + // Both the fallback children AND the primary children are rendered at the + // same time. Once the primary children are un-suspended, we can delete + // the fallback children — don't need to preserve their state. + // + // The two sets of children are siblings in the host environment, but + // semantically, for purposes of reconciliation, they are two separate sets. + // So we store them using two fragment fibers. + // + // However, we want to avoid allocating extra fibers for every placeholder. + // They're only necessary when the children time out, because that's the + // only time when both sets are mounted. + // + // So, the extra fragment fibers are only used if the children time out. + // Otherwise, we render the primary children directly. This requires some + // custom reconciliation logic to preserve the state of the primary + // children. It's essentially a very basic form of re-parenting. + + // `child` points to the child fiber. In the normal case, this is the first + // fiber of the primary children set. In the timed-out case, it's a + // a fragment fiber containing the primary children. + var child = void 0; + // `next` points to the next fiber React should render. In the normal case, + // it's the same as `child`: the first fiber of the primary children set. + // In the timed-out case, it's a fragment fiber containing the *fallback* + // children -- we skip over the primary children entirely. + var next = void 0; + if (current$$1 === null) { + // This is the initial mount. This branch is pretty simple because there's + // no previous state that needs to be preserved. if (nextDidTimeout) { - // If the timed-out view commits, schedule an update effect to record - // the committed time. - workInProgress.effectTag |= Update; + // Mount separate fragments for primary and fallback children. + var nextFallbackChildren = nextProps.fallback; + var primaryChildFragment = createFiberFromFragment( + null, + mode, + NoWork, + null + ); + + if ((workInProgress.mode & ConcurrentMode) === NoContext) { + // Outside of concurrent mode, we commit the effects from the + var progressedState = workInProgress.memoizedState; + var progressedPrimaryChild = + progressedState !== null + ? workInProgress.child.child + : workInProgress.child; + primaryChildFragment.child = progressedPrimaryChild; + } + + var fallbackChildFragment = createFiberFromFragment( + nextFallbackChildren, + mode, + renderExpirationTime, + null + ); + primaryChildFragment.sibling = fallbackChildFragment; + child = primaryChildFragment; + // Skip the primary children, and continue working on the + // fallback children. + next = fallbackChildFragment; + child.return = next.return = workInProgress; } else { - // 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; + // Mount the primary children without an intermediate fragment fiber. + var nextPrimaryChildren = nextProps.children; + child = next = mountChildFibers( + workInProgress, + null, + nextPrimaryChildren, + renderExpirationTime + ); } - } - - // If the `children` prop is a function, treat it like a render prop. - // TODO: This is temporary until we finalize a lower level API. - var children = nextProps.children; - var nextChildren = void 0; - if (typeof children === "function") { - nextChildren = children(nextDidTimeout); } else { - nextChildren = nextDidTimeout ? nextProps.fallback : children; - } + // 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; + 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; + + if ((workInProgress.mode & ConcurrentMode) === NoContext) { + // Outside of concurrent mode, we commit the effects from the + var _progressedState = workInProgress.memoizedState; + var _progressedPrimaryChild = + _progressedState !== null + ? workInProgress.child.child + : workInProgress.child; + if (_progressedPrimaryChild !== currentPrimaryChildFragment.child) { + _primaryChildFragment.child = _progressedPrimaryChild; + } + } - 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 - ); + // Because primaryChildFragment is a new fiber that we're inserting as the + // parent of a new tree, we need to set its treeBaseDuration. + if (enableProfilerTimer && workInProgress.mode & ProfileMode) { + // treeBaseDuration is the sum of all the child tree base durations. + var treeBaseDuration = 0; + var hiddenChild = _primaryChildFragment.child; + while (hiddenChild !== null) { + treeBaseDuration += hiddenChild.treeBaseDuration; + hiddenChild = hiddenChild.sibling; + } + _primaryChildFragment.treeBaseDuration = treeBaseDuration; + } + + // 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 primaryChild = reconcileChildFibers( + workInProgress, + currentPrimaryChild, + _nextPrimaryChildren, + renderExpirationTime + ); + + // If this render doesn't suspend, we need to delete the fallback + // children. Wait until the complete phase, after we've confirmed the + // fallback is no longer needed. + // TODO: Would it be better to store the fallback fragment on + // the stateNode? + + // 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; + + if ((workInProgress.mode & ConcurrentMode) === NoContext) { + // Outside of concurrent mode, we commit the effects from the + var _progressedState2 = workInProgress.memoizedState; + var _progressedPrimaryChild2 = + _progressedState2 !== null + ? workInProgress.child.child + : workInProgress.child; + _primaryChildFragment2.child = _progressedPrimaryChild2; + } + + // Because primaryChildFragment is a new fiber that we're inserting as the + // parent of a new tree, we need to set its treeBaseDuration. + if (enableProfilerTimer && workInProgress.mode & ProfileMode) { + // treeBaseDuration is the sum of all the child tree base durations. + var _treeBaseDuration = 0; + var _hiddenChild = _primaryChildFragment2.child; + while (_hiddenChild !== null) { + _treeBaseDuration += _hiddenChild.treeBaseDuration; + _hiddenChild = _hiddenChild.sibling; + } + _primaryChildFragment2.treeBaseDuration = _treeBaseDuration; + } + + // 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 + ); + } + } } - workInProgress.memoizedProps = nextProps; - workInProgress.memoizedState = nextDidTimeout; - return workInProgress.child; + + workInProgress.memoizedState = nextState; + workInProgress.child = child; + return next; } function updatePortalComponent( @@ -11002,7 +11974,6 @@ function updatePortalComponent( nextChildren, renderExpirationTime ); - memoizeProps(workInProgress, nextChildren); } else { reconcileChildren( current$$1, @@ -11010,7 +11981,6 @@ function updatePortalComponent( nextChildren, renderExpirationTime ); - memoizeProps(workInProgress, nextChildren); } return workInProgress.child; } @@ -11027,7 +11997,6 @@ function updateContextProvider( var oldProps = workInProgress.memoizedProps; var newValue = newProps.value; - workInProgress.memoizedProps = newProps; { var providerPropTypes = workInProgress.type.propTypes; @@ -11096,13 +12065,18 @@ function updateContextConsumer( // in DEV mode if this property exists or not and warn if it does not. { if (context._context === undefined) { - if (!hasWarnedAboutUsingContextAsConsumer) { - hasWarnedAboutUsingContextAsConsumer = true; - warning$1( - false, - "Rendering directly is not supported and will be removed in " + - "a future major release. Did you mean to render instead?" - ); + // This may be because it's a Context (rather than a Consumer). + // Or it may be because it's older React where they're the same thing. + // We only want to warn if we're sure it's a new React. + if (context !== context.Consumer) { + if (!hasWarnedAboutUsingContextAsConsumer) { + hasWarnedAboutUsingContextAsConsumer = true; + warning$1( + false, + "Rendering directly is not supported and will be removed in " + + "a future major release. Did you mean to render instead?" + ); + } } } else { context = context._context; @@ -11141,29 +12115,9 @@ function updateContextConsumer( newChildren, renderExpirationTime ); - workInProgress.memoizedProps = newProps; return workInProgress.child; } -/* - function reuseChildrenEffects(returnFiber : Fiber, firstChild : Fiber) { - let child = firstChild; - do { - // Ensure that the first and last effect of the parent corresponds - // to the children's first and last effect. - if (!returnFiber.firstEffect) { - returnFiber.firstEffect = child.firstEffect; - } - if (child.lastEffect) { - if (returnFiber.lastEffect) { - returnFiber.lastEffect.nextEffect = child.firstEffect; - } - returnFiber.lastEffect = child.lastEffect; - } - } while (child = child.sibling); - } - */ - function bailoutOnAlreadyFinishedWork( current$$1, workInProgress, @@ -11183,10 +12137,7 @@ function bailoutOnAlreadyFinishedWork( // Check if the children have any pending work. var childExpirationTime = workInProgress.childExpirationTime; - if ( - childExpirationTime === NoWork || - childExpirationTime > renderExpirationTime - ) { + if (childExpirationTime < renderExpirationTime) { // The children don't have any work either. We can skip them. // TODO: Once we add back resuming, we should check if the children are // a work-in-progress set. If so, we need to transfer their effects. @@ -11199,17 +12150,6 @@ function bailoutOnAlreadyFinishedWork( } } -// TODO: Delete memoizeProps/State and move to reconcile/bailout instead -function memoizeProps(workInProgress, nextProps) { - workInProgress.memoizedProps = nextProps; -} - -function memoizeState(workInProgress, nextState) { - workInProgress.memoizedState = nextState; - // Don't reset the updateQueue, in case there are pending updates. Resetting - // is handled by processUpdateQueue. -} - function beginWork(current$$1, workInProgress, renderExpirationTime) { var updateExpirationTime = workInProgress.expirationTime; @@ -11219,8 +12159,7 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { if ( oldProps === newProps && !hasContextChanged() && - (updateExpirationTime === NoWork || - updateExpirationTime > renderExpirationTime) + updateExpirationTime < renderExpirationTime ) { // This fiber does not have any pending work. Bailout without entering // the begin phase. There's still some bookkeeping we that needs to be done @@ -11235,15 +12174,7 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { break; case ClassComponent: { var Component = workInProgress.type; - if (isContextProvider(Component)) { - pushContextProvider(workInProgress); - } - break; - } - case ClassComponentLazy: { - var thenable = workInProgress.type; - var _Component = getResultFromResolvedThenable(thenable); - if (isContextProvider(_Component)) { + if (isContextProvider(Component)) { pushContextProvider(workInProgress); } break; @@ -11264,6 +12195,46 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { workInProgress.effectTag |= Update; } break; + case SuspenseComponent: { + var state = workInProgress.memoizedState; + var didTimeout = state !== null; + if (didTimeout) { + // If this boundary is currently timed out, we need to decide + // whether to retry the primary children, or to skip over it and + // go straight to the fallback. Check the priority of the primary + var primaryChildFragment = workInProgress.child; + var primaryChildExpirationTime = + primaryChildFragment.childExpirationTime; + if ( + primaryChildExpirationTime !== NoWork && + primaryChildExpirationTime >= renderExpirationTime + ) { + // The primary children have pending work. Use the normal path + // to attempt to render the primary children again. + return updateSuspenseComponent( + current$$1, + workInProgress, + renderExpirationTime + ); + } else { + // The primary children do not have pending work with sufficient + // priority. Bailout. + var child = bailoutOnAlreadyFinishedWork( + current$$1, + workInProgress, + renderExpirationTime + ); + if (child !== null) { + // The fallback children have pending work. Skip over the + // primary children and work on the fallback. + return child.sibling; + } else { + return null; + } + } + } + break; + } } return bailoutOnAlreadyFinishedWork( current$$1, @@ -11278,64 +12249,53 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { switch (workInProgress.tag) { case IndeterminateComponent: { - var _Component2 = workInProgress.type; + var elementType = workInProgress.elementType; return mountIndeterminateComponent( current$$1, workInProgress, - _Component2, - updateExpirationTime, + elementType, renderExpirationTime ); } - case FunctionComponent: { - var _Component3 = workInProgress.type; - var unresolvedProps = workInProgress.pendingProps; - return updateFunctionComponent( + case LazyComponent: { + var _elementType = workInProgress.elementType; + return mountLazyComponent( current$$1, workInProgress, - _Component3, - unresolvedProps, + _elementType, + updateExpirationTime, renderExpirationTime ); } - case FunctionComponentLazy: { - var _thenable = workInProgress.type; - var _Component4 = getResultFromResolvedThenable(_thenable); - var _unresolvedProps = workInProgress.pendingProps; - var child = updateFunctionComponent( + case FunctionComponent: { + var _Component = workInProgress.type; + var unresolvedProps = workInProgress.pendingProps; + var resolvedProps = + workInProgress.elementType === _Component + ? unresolvedProps + : resolveDefaultProps(_Component, unresolvedProps); + return updateFunctionComponent( current$$1, workInProgress, - _Component4, - resolveDefaultProps(_Component4, _unresolvedProps), + _Component, + resolvedProps, renderExpirationTime ); - workInProgress.memoizedProps = _unresolvedProps; - return child; } case ClassComponent: { - var _Component5 = workInProgress.type; - var _unresolvedProps2 = workInProgress.pendingProps; + var _Component2 = workInProgress.type; + var _unresolvedProps = workInProgress.pendingProps; + var _resolvedProps = + workInProgress.elementType === _Component2 + ? _unresolvedProps + : resolveDefaultProps(_Component2, _unresolvedProps); return updateClassComponent( current$$1, workInProgress, - _Component5, - _unresolvedProps2, - 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), + _Component2, + _resolvedProps, renderExpirationTime ); - workInProgress.memoizedProps = _unresolvedProps3; - return _child; } case HostRoot: return updateHostRoot(current$$1, workInProgress, renderExpirationTime); @@ -11361,27 +12321,18 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { ); case ForwardRef: { var type = workInProgress.type; + var _unresolvedProps2 = workInProgress.pendingProps; + var _resolvedProps2 = + workInProgress.elementType === type + ? _unresolvedProps2 + : resolveDefaultProps(type, _unresolvedProps2); return updateForwardRef( current$$1, workInProgress, type, - workInProgress.pendingProps, - 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), + _resolvedProps2, renderExpirationTime ); - workInProgress.memoizedProps = _unresolvedProps4; - return _child2; } case Fragment: return updateFragment(current$$1, workInProgress, renderExpirationTime); @@ -11401,31 +12352,43 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { workInProgress, renderExpirationTime ); - case PureComponent: { + case MemoComponent: { var _type = workInProgress.type; - return updatePureComponent( + var _unresolvedProps3 = workInProgress.pendingProps; + var _resolvedProps3 = resolveDefaultProps(_type.type, _unresolvedProps3); + return updateMemoComponent( current$$1, workInProgress, _type, - workInProgress.pendingProps, + _resolvedProps3, updateExpirationTime, renderExpirationTime ); } - case PureComponentLazy: { - var _thenable4 = workInProgress.type; - var _Component8 = getResultFromResolvedThenable(_thenable4); - var _unresolvedProps5 = workInProgress.pendingProps; - var _child3 = updatePureComponent( + case SimpleMemoComponent: { + return updateSimpleMemoComponent( current$$1, workInProgress, - _Component8, - resolveDefaultProps(_Component8, _unresolvedProps5), + workInProgress.type, + workInProgress.pendingProps, updateExpirationTime, renderExpirationTime ); - workInProgress.memoizedProps = _unresolvedProps5; - return _child3; + } + case IncompleteClassComponent: { + var _Component3 = workInProgress.type; + var _unresolvedProps4 = workInProgress.pendingProps; + var _resolvedProps4 = + workInProgress.elementType === _Component3 + ? _unresolvedProps4 + : resolveDefaultProps(_Component3, _unresolvedProps4); + return mountIncompleteClassComponent( + current$$1, + workInProgress, + _Component3, + _resolvedProps4, + renderExpirationTime + ); } default: invariant( @@ -11446,42 +12409,48 @@ function markRef$1(workInProgress) { workInProgress.effectTag |= Ref; } -function appendAllChildren(parent, workInProgress) { - // We only have the top Fiber that was created but we need recurse down its - // children to find all the terminal nodes. - var node = workInProgress.child; - while (node !== null) { - if (node.tag === HostComponent || node.tag === HostText) { - appendInitialChild(parent, node.stateNode); - } else if (node.tag === HostPortal) { - // If we have a portal child, then we don't want to traverse - // down its children. Instead, we'll get insertions from each child in - // the portal directly. - } else if (node.child !== null) { - node.child.return = node; - node = node.child; - continue; - } - if (node === workInProgress) { - return; - } - while (node.sibling === null) { - if (node.return === null || node.return === workInProgress) { - return; - } - node = node.return; - } - node.sibling.return = node.return; - node = node.sibling; - } -} - +var appendAllChildren = void 0; var updateHostContainer = void 0; var updateHostComponent$1 = void 0; var updateHostText$1 = void 0; if (supportsMutation) { // Mutation mode + appendAllChildren = function( + parent, + workInProgress, + needsVisibilityToggle, + isHidden + ) { + // We only have the top Fiber that was created but we need recurse down its + // children to find all the terminal nodes. + var node = workInProgress.child; + while (node !== null) { + if (node.tag === HostComponent || node.tag === HostText) { + appendInitialChild(parent, node.stateNode); + } else if (node.tag === HostPortal) { + // If we have a portal child, then we don't want to traverse + // down its children. Instead, we'll get insertions from each child in + // the portal directly. + } else if (node.child !== null) { + node.child.return = node; + node = node.child; + continue; + } + if (node === workInProgress) { + return; + } + while (node.sibling === null) { + if (node.return === null || node.return === workInProgress) { + return; + } + node = node.return; + } + node.sibling.return = node.return; + node = node.sibling; + } + }; + updateHostContainer = function(workInProgress) { // Noop }; @@ -11535,26 +12504,202 @@ 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; + var newIsHidden = newState !== null; + 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 + workInProgress, + needsVisibilityToggle, + isHidden ) { // We only have the top Fiber that was created but we need recurse down its // children to find all the terminal nodes. var node = workInProgress.child; while (node !== null) { - if (node.tag === HostComponent || node.tag === HostText) { - appendChildToContainerChildSet(containerChildSet, node.stateNode); + // eslint-disable-next-line no-labels + branches: if (node.tag === HostComponent) { + var instance = node.stateNode; + if (needsVisibilityToggle) { + var props = node.memoizedProps; + var type = node.type; + if (isHidden) { + // This child is inside a timed out tree. Hide it. + instance = cloneHiddenInstance(instance, type, props, node); + } else { + // This child was previously inside a timed out tree. If it was not + // updated during this render, it may need to be unhidden. Clone + // again to be sure. + instance = cloneUnhiddenInstance(instance, type, props, node); + } + node.stateNode = instance; + } + appendChildToContainerChildSet(containerChildSet, instance); + } else if (node.tag === HostText) { + var _instance2 = node.stateNode; + if (needsVisibilityToggle) { + var text = node.memoizedProps; + var rootContainerInstance = getRootHostContainer(); + var currentHostContext = getHostContext(); + if (isHidden) { + _instance2 = createHiddenTextInstance( + text, + rootContainerInstance, + currentHostContext, + workInProgress + ); + } else { + _instance2 = createTextInstance( + text, + rootContainerInstance, + currentHostContext, + workInProgress + ); + } + node.stateNode = _instance2; + } + appendChildToContainerChildSet(containerChildSet, _instance2); } else if (node.tag === HostPortal) { // If we have a portal child, then we don't want to traverse // down its children. Instead, we'll get insertions from each child in // the portal directly. + } else if (node.tag === SuspenseComponent) { + var current = node.alternate; + if (current !== null) { + var oldState = current.memoizedState; + var newState = node.memoizedState; + var oldIsHidden = oldState !== null; + var newIsHidden = newState !== null; + if (oldIsHidden !== newIsHidden) { + // The placeholder either just timed out or switched back to the normal + // children after having previously timed out. Toggle the visibility of + // the direct host children. + var primaryChildParent = newIsHidden ? node.child : node; + if (primaryChildParent !== null) { + appendAllChildrenToContainer( + containerChildSet, + primaryChildParent, + true, + newIsHidden + ); + } + // eslint-disable-next-line no-labels + break branches; + } + } + if (node.child !== null) { + // Continue traversing like normal + node.child.return = node; + node = node.child; + continue; + } } else if (node.child !== null) { node.child.return = node; node = node.child; continue; } + // $FlowFixMe This is correct but Flow is confused by the labeled break. + node = node; if (node === workInProgress) { return; } @@ -11577,7 +12722,7 @@ if (supportsMutation) { var container = portalOrRoot.containerInfo; var newChildSet = createContainerChildSet(container); // If children might have changed, we have to add them all to the set. - appendAllChildrenToContainer(newChildSet, workInProgress); + appendAllChildrenToContainer(newChildSet, workInProgress, false, false); portalOrRoot.pendingChildren = newChildSet; // Schedule an update on the container to swap out the container. markUpdate(workInProgress); @@ -11650,7 +12795,7 @@ if (supportsMutation) { markUpdate(workInProgress); } else { // If children might have changed, we have to add them all to the set. - appendAllChildren(newInstance, workInProgress); + appendAllChildren(newInstance, workInProgress, false, false); } }; updateHostText$1 = function(current, workInProgress, oldText, newText) { @@ -11692,8 +12837,12 @@ function completeWork(current, workInProgress, renderExpirationTime) { var newProps = workInProgress.pendingProps; switch (workInProgress.tag) { + case IndeterminateComponent: + break; + case LazyComponent: + break; + case SimpleMemoComponent: case FunctionComponent: - case FunctionComponentLazy: break; case ClassComponent: { var Component = workInProgress.type; @@ -11702,13 +12851,6 @@ function completeWork(current, workInProgress, renderExpirationTime) { } break; } - case ClassComponentLazy: { - var _Component = getResultFromResolvedThenable(workInProgress.type); - if (isContextProvider(_Component)) { - popContext(workInProgress); - } - break; - } case HostRoot: { popHostContainer(workInProgress); popTopLevelContextObject(workInProgress); @@ -11784,7 +12926,7 @@ function completeWork(current, workInProgress, renderExpirationTime) { workInProgress ); - appendAllChildren(instance, workInProgress); + appendAllChildren(instance, workInProgress, false, false); // Certain renderers require commit-time effects for initial mount. // (eg DOM renderer supports auto-focus for certain elements). @@ -11845,10 +12987,50 @@ function completeWork(current, workInProgress, renderExpirationTime) { break; } case ForwardRef: - case ForwardRefLazy: break; - case SuspenseComponent: + case SuspenseComponent: { + var nextState = workInProgress.memoizedState; + if ((workInProgress.effectTag & DidCapture) !== NoEffect) { + // Something suspended. Re-render with the fallback children. + workInProgress.expirationTime = renderExpirationTime; + // Do not reset the effect list. + return workInProgress; + } + + var nextDidTimeout = nextState !== null; + var prevDidTimeout = current !== null && current.memoizedState !== null; + + if (current !== null && !nextDidTimeout && prevDidTimeout) { + // We just switched from the fallback to the normal children. Delete + // the fallback. + // TODO: Would it be better to store the fallback fragment on + var currentFallbackChild = current.child.sibling; + if (currentFallbackChild !== null) { + reconcileChildFibers( + workInProgress, + currentFallbackChild, + null, + renderExpirationTime + ); + } + } + + // The children either timed out after previously being visible, or + // were restored after previously being hidden. Schedule an effect + // to update their visiblity. + if ( + // + nextDidTimeout !== prevDidTimeout || + // Outside concurrent mode, the primary children commit in an + // inconsistent state, even if they are hidden. So if they are hidden, + // we need to schedule an effect to re-hide them, just in case. + ((workInProgress.effectTag & ConcurrentMode) === NoContext && + nextDidTimeout) + ) { + workInProgress.effectTag |= Update; + } break; + } case Fragment: break; case Mode: @@ -11865,18 +13047,17 @@ function completeWork(current, workInProgress, renderExpirationTime) { break; case ContextConsumer: break; - case PureComponent: - case PureComponentLazy: + case MemoComponent: break; - // Error cases - case IndeterminateComponent: - invariant( - false, - "An indeterminate component should have become determinate before " + - "completing. This error is likely caused by a bug in React. Please " + - "file an issue." - ); - // eslint-disable-next-line no-fallthrough + case IncompleteClassComponent: { + // Same as class component case. I put it down here so that the tags are + // sequential to ensure this switch is compiled to a jump table. + var _Component = workInProgress.type; + if (isContextProvider(_Component)) { + popContext(workInProgress); + } + break; + } default: invariant( false, @@ -11888,6 +13069,17 @@ function completeWork(current, workInProgress, renderExpirationTime) { return null; } +function shouldCaptureSuspense(current, workInProgress) { + // In order to capture, the Suspense component must have a fallback prop. + if (workInProgress.memoizedProps.fallback === undefined) { + return false; + } + // If it was the primary children that just suspended, capture and render the + // fallback. Otherwise, don't capture and bubble to the next boundary. + var nextState = workInProgress.memoizedState; + return nextState === null; +} + // Module provided by RN: /** * Intercept lifecycle errors and ensure they are shown with the correct stack @@ -12004,8 +13196,6 @@ function logCapturedError(capturedError) { } } -var emptyObject$1 = {}; - var didWarnAboutUndefinedSnapshotBeforeUpdate = null; { didWarnAboutUndefinedSnapshotBeforeUpdate = new Set(); @@ -12090,19 +13280,60 @@ function safelyDetachRef(current$$1) { } } +function safelyCallDestroy(current$$1, destroy) { + { + invokeGuardedCallback(null, destroy, null); + if (hasCaughtError()) { + var error = clearCaughtError(); + captureCommitPhaseError(current$$1, error); + } + } +} + function commitBeforeMutationLifeCycles(current$$1, finishedWork) { switch (finishedWork.tag) { - case ClassComponent: - case ClassComponentLazy: { + case FunctionComponent: + case ForwardRef: + case SimpleMemoComponent: { + commitHookEffectList(UnmountSnapshot, NoEffect$1, finishedWork); + return; + } + case ClassComponent: { if (finishedWork.effectTag & Snapshot) { if (current$$1 !== null) { var prevProps = current$$1.memoizedProps; var prevState = current$$1.memoizedState; startPhaseTimer(finishedWork, "getSnapshotBeforeUpdate"); var instance = finishedWork.stateNode; - instance.props = finishedWork.memoizedProps; - instance.state = finishedWork.memoizedState; - var snapshot = instance.getSnapshotBeforeUpdate(prevProps, prevState); + // We could update instance props and state here, + // but instead we rely on them being set during last render. + // TODO: revisit this when we implement resuming. + { + if (finishedWork.type === finishedWork.elementType) { + !(instance.props === finishedWork.memoizedProps) + ? warning$1( + false, + "Expected instance props to match memoized props before " + + "getSnapshotBeforeUpdate. This is likely due to a bug in React. " + + "Please file an issue." + ) + : void 0; + !(instance.state === finishedWork.memoizedState) + ? warning$1( + false, + "Expected instance state to match memoized state before " + + "getSnapshotBeforeUpdate. This is likely due to a bug in React. " + + "Please file an issue." + ) + : void 0; + } + } + var snapshot = instance.getSnapshotBeforeUpdate( + finishedWork.elementType === finishedWork.type + ? prevProps + : resolveDefaultProps(finishedWork.type, prevProps), + prevState + ); { var didWarnSet = didWarnAboutUndefinedSnapshotBeforeUpdate; if (snapshot === undefined && !didWarnSet.has(finishedWork.type)) { @@ -12125,6 +13356,7 @@ function commitBeforeMutationLifeCycles(current$$1, finishedWork) { case HostComponent: case HostText: case HostPortal: + case IncompleteClassComponent: // Nothing to do for these component types return; default: { @@ -12137,6 +13369,58 @@ function commitBeforeMutationLifeCycles(current$$1, finishedWork) { } } +function commitHookEffectList(unmountTag, mountTag, finishedWork) { + if (!enableHooks) { + return; + } + 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(); + if (typeof _destroy !== "function") { + { + if (_destroy !== null && _destroy !== undefined) { + warningWithoutStack$1( + false, + "useEffect function must return a cleanup function or " + + "nothing.%s%s", + typeof _destroy.then === "function" + ? " Promises and useEffect(async () => ...) are not " + + "supported, but you can call an async function inside an " + + "effect." + : "", + getStackByFiberInDevAndProd(finishedWork) + ); + } + } + _destroy = null; + } + effect.destroy = _destroy; + } + effect = effect.next; + } while (effect !== firstEffect); + } +} + +function commitPassiveHookEffects(finishedWork) { + commitHookEffectList(UnmountPassive, NoEffect$1, finishedWork); + commitHookEffectList(NoEffect$1, MountPassive, finishedWork); +} + function commitLifeCycles( finishedRoot, current$$1, @@ -12144,22 +13428,75 @@ function commitLifeCycles( committedExpirationTime ) { switch (finishedWork.tag) { - case ClassComponent: - case ClassComponentLazy: { + case FunctionComponent: + case ForwardRef: + case SimpleMemoComponent: { + commitHookEffectList(UnmountLayout, MountLayout, finishedWork); + break; + } + case ClassComponent: { var instance = finishedWork.stateNode; if (finishedWork.effectTag & Update) { if (current$$1 === null) { startPhaseTimer(finishedWork, "componentDidMount"); - instance.props = finishedWork.memoizedProps; - instance.state = finishedWork.memoizedState; + // We could update instance props and state here, + // but instead we rely on them being set during last render. + // TODO: revisit this when we implement resuming. + { + if (finishedWork.type === finishedWork.elementType) { + !(instance.props === finishedWork.memoizedProps) + ? warning$1( + false, + "Expected instance props to match memoized props before " + + "componentDidMount. This is likely due to a bug in React. " + + "Please file an issue." + ) + : void 0; + !(instance.state === finishedWork.memoizedState) + ? warning$1( + false, + "Expected instance state to match memoized state before " + + "componentDidMount. This is likely due to a bug in React. " + + "Please file an issue." + ) + : void 0; + } + } instance.componentDidMount(); stopPhaseTimer(); } else { - var prevProps = current$$1.memoizedProps; + var prevProps = + finishedWork.elementType === finishedWork.type + ? current$$1.memoizedProps + : resolveDefaultProps( + finishedWork.type, + current$$1.memoizedProps + ); var prevState = current$$1.memoizedState; startPhaseTimer(finishedWork, "componentDidUpdate"); - instance.props = finishedWork.memoizedProps; - instance.state = finishedWork.memoizedState; + // We could update instance props and state here, + // but instead we rely on them being set during last render. + // TODO: revisit this when we implement resuming. + { + if (finishedWork.type === finishedWork.elementType) { + !(instance.props === finishedWork.memoizedProps) + ? warning$1( + false, + "Expected instance props to match memoized props before " + + "componentDidUpdate. This is likely due to a bug in React. " + + "Please file an issue." + ) + : void 0; + !(instance.state === finishedWork.memoizedState) + ? warning$1( + false, + "Expected instance state to match memoized state before " + + "componentDidUpdate. This is likely due to a bug in React. " + + "Please file an issue." + ) + : void 0; + } + } instance.componentDidUpdate( prevProps, prevState, @@ -12170,8 +13507,29 @@ function commitLifeCycles( } var updateQueue = finishedWork.updateQueue; if (updateQueue !== null) { - instance.props = finishedWork.memoizedProps; - instance.state = finishedWork.memoizedState; + { + if (finishedWork.type === finishedWork.elementType) { + !(instance.props === finishedWork.memoizedProps) + ? warning$1( + false, + "Expected instance props to match memoized props before " + + "processing the update queue. This is likely due to a bug in React. " + + "Please file an issue." + ) + : void 0; + !(instance.state === finishedWork.memoizedState) + ? warning$1( + false, + "Expected instance state to match memoized state before " + + "processing the update queue. This is likely due to a bug in React. " + + "Please file an issue." + ) + : void 0; + } + } + // We could update instance props and state here, + // but instead we rely on them being set during last render. + // TODO: revisit this when we implement resuming. commitUpdateQueue( finishedWork, updateQueue, @@ -12191,7 +13549,6 @@ function commitLifeCycles( _instance = getPublicInstance(finishedWork.child.stateNode); break; case ClassComponent: - case ClassComponentLazy: _instance = finishedWork.child.stateNode; break; } @@ -12255,23 +13612,10 @@ function commitLifeCycles( } return; } - case SuspenseComponent: { - if ((finishedWork.mode & StrictMode) === NoEffect) { - // In loose mode, a placeholder times out by scheduling a synchronous - // update in the commit phase. Use `updateQueue` field to signal that - // the Timeout needs to switch to the placeholder. We don't need an - // entire queue. Any non-null value works. - // $FlowFixMe - Intentionally using a value other than an UpdateQueue. - finishedWork.updateQueue = emptyObject$1; - scheduleWork(finishedWork, Sync); - } else { - // In strict mode, the Update effect is used to record the time at - // which the placeholder timed out. - var currentTime = requestCurrentTime(); - finishedWork.stateNode = { timedOutAt: currentTime }; - } - return; - } + case SuspenseComponent: + break; + case IncompleteClassComponent: + break; default: { invariant( false, @@ -12282,6 +13626,45 @@ function commitLifeCycles( } } +function hideOrUnhideAllChildren(finishedWork, isHidden) { + if (supportsMutation) { + // We only have the top Fiber that was inserted but we need recurse down its + var node = finishedWork; + while (true) { + if (node.tag === HostComponent) { + var instance = node.stateNode; + if (isHidden) { + hideInstance(instance); + } else { + unhideInstance(node.stateNode, node.memoizedProps); + } + } else if (node.tag === HostText) { + var _instance3 = node.stateNode; + if (isHidden) { + hideTextInstance(_instance3); + } else { + unhideTextInstance(_instance3, node.memoizedProps); + } + } else if (node.child !== null) { + node.child.return = node; + node = node.child; + continue; + } + if (node === finishedWork) { + return; + } + while (node.sibling === null) { + if (node.return === null || node.return === finishedWork) { + return; + } + node = node.return; + } + node.sibling.return = node.return; + node = node.sibling; + } + } +} + function commitAttachRef(finishedWork) { var ref = finishedWork.ref; if (ref !== null) { @@ -12332,8 +13715,28 @@ function commitUnmount(current$$1) { onCommitUnmount(current$$1); switch (current$$1.tag) { - case ClassComponent: - case ClassComponentLazy: { + case FunctionComponent: + case ForwardRef: + case MemoComponent: + case SimpleMemoComponent: { + var updateQueue = current$$1.updateQueue; + if (updateQueue !== null) { + var lastEffect = updateQueue.lastEffect; + if (lastEffect !== null) { + var firstEffect = lastEffect.next; + var effect = firstEffect; + do { + var destroy = effect.destroy; + if (destroy !== null) { + safelyCallDestroy(current$$1, destroy); + } + effect = effect.next; + } while (effect !== firstEffect); + } + } + break; + } + case ClassComponent: { safelyDetachRef(current$$1); var instance = current$$1.stateNode; if (typeof instance.componentWillUnmount === "function") { @@ -12424,8 +13827,7 @@ function commitContainer(finishedWork) { } switch (finishedWork.tag) { - case ClassComponent: - case ClassComponentLazy: { + case ClassComponent: { return; } case HostComponent: { @@ -12700,13 +14102,29 @@ function commitDeletion(current$$1) { function commitWork(current$$1, finishedWork) { if (!supportsMutation) { + switch (finishedWork.tag) { + case FunctionComponent: + case ForwardRef: + case MemoComponent: + case SimpleMemoComponent: { + commitHookEffectList(UnmountMutation, MountMutation, finishedWork); + return; + } + } + commitContainer(finishedWork); return; } switch (finishedWork.tag) { - case ClassComponent: - case ClassComponentLazy: { + case FunctionComponent: + case ForwardRef: + case MemoComponent: + case SimpleMemoComponent: { + commitHookEffectList(UnmountMutation, MountMutation, finishedWork); + return; + } + case ClassComponent: { return; } case HostComponent: { @@ -12758,6 +14176,29 @@ function commitWork(current$$1, finishedWork) { return; } case SuspenseComponent: { + var newState = finishedWork.memoizedState; + + var newDidTimeout = void 0; + var primaryChildParent = finishedWork; + if (newState === null) { + newDidTimeout = false; + } else { + newDidTimeout = true; + primaryChildParent = finishedWork.child; + 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 (primaryChildParent !== null) { + hideOrUnhideAllChildren(primaryChildParent, newDidTimeout); + } + return; + } + case IncompleteClassComponent: { return; } default: { @@ -12777,10 +14218,6 @@ function commitResetTextContent(current$$1) { resetTextContent(current$$1.stateNode); } -function NoopComponent() { - return null; -} - function createRootErrorUpdate(fiber, errorInfo, expirationTime) { var update = createUpdate(expirationTime); // Unmount the root by rendering null. @@ -12874,22 +14311,17 @@ function throwException( var startTimeMs = -1; do { if (_workInProgress.tag === SuspenseComponent) { - var current = _workInProgress.alternate; - if ( - current !== null && - current.memoizedState === true && - current.stateNode !== null - ) { - // Reached a placeholder that already timed out. Each timed out - // placeholder acts as the root of a new suspense boundary. - - // Use the time at which the placeholder timed out as the start time - // for the current render. - var timedOutAt = current.stateNode.timedOutAt; - startTimeMs = expirationTimeToMs(timedOutAt); - - // Do not search any further. - break; + var current$$1 = _workInProgress.alternate; + if (current$$1 !== null) { + var currentState = current$$1.memoizedState; + if (currentState !== null) { + // Reached a boundary that already timed out. Do not search + // any further. + var timedOutAt = currentState.timedOutAt; + startTimeMs = expirationTimeToMs(timedOutAt); + // Do not search any further. + break; + } } var timeoutPropMs = _workInProgress.pendingProps.maxDuration; if (typeof timeoutPropMs === "number") { @@ -12909,129 +14341,131 @@ function throwException( // Schedule the nearest Suspense to re-render the timed out view. _workInProgress = returnFiber; do { - if (_workInProgress.tag === SuspenseComponent) { - var didTimeout = _workInProgress.memoizedState; - if (!didTimeout) { - // Found the nearest boundary. - - // If the boundary is not in concurrent mode, we should not suspend, and - // likewise, when the promise resolves, we should ping synchronously. - var pingTime = - (_workInProgress.mode & ConcurrentMode) === NoEffect - ? Sync - : renderExpirationTime; - - // Attach a listener to the promise to "ping" the root and retry. - var onResolveOrReject = retrySuspendedRoot.bind( - null, - root, - _workInProgress, - pingTime + if ( + _workInProgress.tag === SuspenseComponent && + shouldCaptureSuspense(_workInProgress.alternate, _workInProgress) + ) { + // Found the nearest boundary. + + // If the boundary is not in concurrent mode, we should not suspend, and + // likewise, when the promise resolves, we should ping synchronously. + var pingTime = + (_workInProgress.mode & ConcurrentMode) === NoEffect + ? Sync + : renderExpirationTime; + + // 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 |= DidCapture; + + // Unmount the source fiber's children + var nextChildren = null; + reconcileChildren( + sourceFiber.alternate, + sourceFiber, + nextChildren, + renderExpirationTime ); - if (enableSchedulerTracing) { - onResolveOrReject = tracing.unstable_wrap(onResolveOrReject); - } - thenable.then(onResolveOrReject, onResolveOrReject); - - // 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; - - // Unmount the source fiber's children - var nextChildren = null; - reconcileChildren( - sourceFiber.alternate, - sourceFiber, - nextChildren, - renderExpirationTime - ); - sourceFiber.effectTag &= ~Incomplete; - if (sourceFiber.tag === IndeterminateComponent) { - // Let's just assume it's a function component. This fiber will - // be unmounted in the immediate next commit, anyway. - sourceFiber.tag = FunctionComponent; + 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 ( - 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; - } - } + // The source fiber did not complete. Mark it with the current + // render priority to indicate that it still has pending work. + sourceFiber.expirationTime = renderExpirationTime; - // Exit without suspending. - return; - } + // Exit without suspending. + return; + } - // Confirmed that the boundary is in a strict mode tree. Continue with - // the normal suspend path. + // Confirmed that the boundary is in a concurrent mode tree. Continue + // with the normal suspend path. - var absoluteTimeoutMs = void 0; - if (earliestTimeoutMs === -1) { - // If no explicit threshold is given, default to an abitrarily large - // value. The actual size doesn't matter because the threshold for the - // whole tree will be clamped to the expiration time. - absoluteTimeoutMs = maxSigned31BitInt; - } else { - if (startTimeMs === -1) { - // This suspend happened outside of any already timed-out - // placeholders. We don't know exactly when the update was scheduled, - // but we can infer an approximate start time from the expiration - // time. First, find the earliest uncommitted expiration time in the - // tree, including work that is suspended. Then subtract the offset - // used to compute an async update's expiration time. This will cause - // high priority (interactive) work to expire earlier than necessary, - // but we can account for this by adjusting for the Just Noticeable - // Difference. - var earliestExpirationTime = findEarliestOutstandingPriorityLevel( - root, - renderExpirationTime - ); - var earliestExpirationTimeMs = expirationTimeToMs( - earliestExpirationTime - ); - startTimeMs = earliestExpirationTimeMs - LOW_PRIORITY_EXPIRATION; - } - absoluteTimeoutMs = startTimeMs + earliestTimeoutMs; + 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); + // Mark the earliest timeout in the suspended fiber's ancestor path. + // After completing the root, we'll take the largest of all the + // suspended fiber's timeouts and use it to compute a timeout for the + // whole tree. + renderDidSuspend(root, absoluteTimeoutMs, renderExpirationTime); - _workInProgress.effectTag |= ShouldCapture; - _workInProgress.expirationTime = renderExpirationTime; - return; - } - // This boundary already captured during this render. Continue to the - // next boundary. + _workInProgress.effectTag |= ShouldCapture; + _workInProgress.expirationTime = renderExpirationTime; + return; } + // This boundary already captured during this render. Continue to the next + // boundary. _workInProgress = _workInProgress.return; } while (_workInProgress !== null); // No boundary was found. Fallthrough to error mode. + // TODO: Use invariant so the message is stripped in prod? value = new Error( - "An update was suspended, but no placeholder UI was provided." + (getComponentName(sourceFiber.type) || "A React component") + + " suspended while rendering, but no fallback UI was specified.\n" + + "\n" + + "Add a component higher in the tree to " + + "provide a loading indicator or placeholder to display." + + getStackByFiberInDevAndProd(sourceFiber) ); } @@ -13056,7 +14490,6 @@ function throwException( return; } case ClassComponent: - case ClassComponentLazy: // Capture and retry var errorInfo = value; var ctor = workInProgress.type; @@ -13101,28 +14534,16 @@ function unwindWork(workInProgress, renderExpirationTime) { } return null; } - case ClassComponentLazy: { - var _Component = workInProgress.type._reactResult; - if (isContextProvider(_Component)) { - popContext(workInProgress); - } - var _effectTag = workInProgress.effectTag; - if (_effectTag & ShouldCapture) { - workInProgress.effectTag = (_effectTag & ~ShouldCapture) | DidCapture; - return workInProgress; - } - return null; - } case HostRoot: { popHostContainer(workInProgress); popTopLevelContextObject(workInProgress); - var _effectTag2 = workInProgress.effectTag; + var _effectTag = workInProgress.effectTag; invariant( - (_effectTag2 & DidCapture) === NoEffect, + (_effectTag & DidCapture) === NoEffect, "The root failed to unmount after an error. This is likely a bug in " + "React. Please file an issue." ); - workInProgress.effectTag = (_effectTag2 & ~ShouldCapture) | DidCapture; + workInProgress.effectTag = (_effectTag & ~ShouldCapture) | DidCapture; return workInProgress; } case HostComponent: { @@ -13130,9 +14551,10 @@ function unwindWork(workInProgress, renderExpirationTime) { return null; } case SuspenseComponent: { - var _effectTag3 = workInProgress.effectTag; - if (_effectTag3 & ShouldCapture) { - workInProgress.effectTag = (_effectTag3 & ~ShouldCapture) | DidCapture; + var _effectTag2 = workInProgress.effectTag; + if (_effectTag2 & ShouldCapture) { + workInProgress.effectTag = (_effectTag2 & ~ShouldCapture) | DidCapture; + // Captured a suspense effect. Re-render the boundary. return workInProgress; } return null; @@ -13157,14 +14579,6 @@ function unwindInterruptedWork(interruptedWork) { } break; } - case ClassComponentLazy: { - var _childContextTypes = - interruptedWork.type._reactResult.childContextTypes; - if (_childContextTypes !== null && _childContextTypes !== undefined) { - popContext(interruptedWork); - } - break; - } case HostRoot: { popHostContainer(interruptedWork); popTopLevelContextObject(interruptedWork); @@ -13186,6 +14600,19 @@ 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 +}; +var DispatcherWithoutHooks = { readContext: readContext }; @@ -13214,19 +14641,21 @@ if (enableSchedulerTracing) { didWarnSetStateChildContext = false; var didWarnStateUpdateForUnmountedComponent = {}; - warnAboutUpdateOnUnmounted = function(fiber) { + warnAboutUpdateOnUnmounted = function(fiber, isClass) { // We show the whole stack but dedupe on the top component's name because // the problematic code almost always lies inside that component. - var componentName = getComponentName(fiber.type) || "ReactClass"; + var componentName = getComponentName(fiber.type) || "ReactComponent"; if (didWarnStateUpdateForUnmountedComponent[componentName]) { return; } warningWithoutStack$1( false, - "Can't call setState (or forceUpdate) on an unmounted component. This " + + "Can't perform a React state update on an unmounted component. This " + "is a no-op, but it indicates a memory leak in your application. To " + - "fix, cancel all subscriptions and asynchronous tasks in the " + - "componentWillUnmount method.%s", + "fix, cancel all subscriptions and asynchronous tasks in %s.%s", + isClass + ? "the componentWillUnmount method" + : "a useEffect cleanup function", getStackByFiberInDevAndProd(fiber) ); didWarnStateUpdateForUnmountedComponent[componentName] = true; @@ -13278,6 +14707,9 @@ var nextRenderDidError = false; var nextEffect = null; var isCommitting$1 = false; +var rootWithPendingPassiveEffects = null; +var passiveEffectCallbackHandle = null; +var passiveEffectCallback = null; var legacyErrorBoundariesThatAlreadyFailed = null; @@ -13286,11 +14718,13 @@ var interruptedBy = null; var stashedWorkInProgressProperties = void 0; var replayUnitOfWork = void 0; +var mayReplayFailedUnitOfWork = void 0; var isReplayingFailedUnitOfWork = void 0; var originalReplayError = void 0; var rethrowOriginalError = void 0; if (true && replayFailedUnitOfWorkWithInvokeGuardedCallback) { stashedWorkInProgressProperties = null; + mayReplayFailedUnitOfWork = true; isReplayingFailedUnitOfWork = false; originalReplayError = null; replayUnitOfWork = function(failedUnitOfWork, thrownValue, isYieldy) { @@ -13335,13 +14769,6 @@ if (true && replayFailedUnitOfWorkWithInvokeGuardedCallback) { } break; } - case ClassComponentLazy: { - var _Component = getResultFromResolvedThenable(failedUnitOfWork.type); - if (isContextProvider(_Component)) { - popContext(failedUnitOfWork); - } - break; - } case HostPortal: popHostContainer(failedUnitOfWork); break; @@ -13480,8 +14907,6 @@ function commitBeforeMutationLifecycles() { commitBeforeMutationLifeCycles(current$$1, nextEffect); } - // Don't cleanup effects yet; - // This will be done by commitAllLifeCycles() nextEffect = nextEffect.nextEffect; } @@ -13518,15 +14943,48 @@ function commitAllLifeCycles(finishedRoot, committedExpirationTime) { commitAttachRef(nextEffect); } - var next = nextEffect.nextEffect; - // Ensure that we clean these up so that we don't accidentally keep them. - // I'm not actually sure this matters because we can't reset firstEffect - // and lastEffect since they're on every node, not just the effectful - // ones. So we have to clean everything as we reuse nodes anyway. - nextEffect.nextEffect = null; - // Ensure that we reset the effectTag here so that we can rely on effect - // tags to reason about the current life-cycle. - nextEffect = next; + if (enableHooks && effectTag & Passive) { + rootWithPendingPassiveEffects = finishedRoot; + } + + nextEffect = nextEffect.nextEffect; + } +} + +function commitPassiveEffects(root, firstEffect) { + rootWithPendingPassiveEffects = null; + passiveEffectCallbackHandle = null; + passiveEffectCallback = null; + + // Set this to true to prevent re-entrancy + var previousIsRendering = isRendering; + isRendering = true; + + var effect = firstEffect; + do { + if (effect.effectTag & Passive) { + var didError = false; + var error = void 0; + { + invokeGuardedCallback(null, commitPassiveHookEffects, null, effect); + if (hasCaughtError()) { + didError = true; + error = clearCaughtError(); + } + } + if (didError) { + captureCommitPhaseError(effect, error); + } + } + effect = effect.nextEffect; + } while (effect !== null); + + isRendering = previousIsRendering; + + // Check if work was scheduled by one of the effects + var rootExpirationTime = root.expirationTime; + if (rootExpirationTime !== NoWork) { + requestWork(root, rootExpirationTime); } } @@ -13545,6 +15003,15 @@ function markLegacyErrorBoundaryAsFailed(instance) { } } +function flushPassiveEffects() { + if (passiveEffectCallback !== null) { + scheduler.unstable_cancelCallback(passiveEffectCallbackHandle); + // We call the scheduled callback instead of commitPassiveEffects directly + // to ensure tracing works correctly. + passiveEffectCallback(); + } +} + function commitRoot(root, finishedWork) { isWorking = true; isCommitting$1 = true; @@ -13570,9 +15037,7 @@ function commitRoot(root, finishedWork) { var updateExpirationTimeBeforeCommit = finishedWork.expirationTime; var childExpirationTimeBeforeCommit = finishedWork.childExpirationTime; var earliestRemainingTimeBeforeCommit = - updateExpirationTimeBeforeCommit === NoWork || - (childExpirationTimeBeforeCommit !== NoWork && - childExpirationTimeBeforeCommit < updateExpirationTimeBeforeCommit) + childExpirationTimeBeforeCommit > updateExpirationTimeBeforeCommit ? childExpirationTimeBeforeCommit : updateExpirationTimeBeforeCommit; markCommittedPriorityLevels(root, earliestRemainingTimeBeforeCommit); @@ -13714,6 +15179,26 @@ function commitRoot(root, finishedWork) { } } + if ( + enableHooks && + firstEffect !== null && + rootWithPendingPassiveEffects !== null + ) { + // This commit included a passive effect. These do not need to fire until + // after the next paint. Schedule an callback to fire them in an async + // event. To ensure serial execution, the callback will be flushed early if + // we enter rootWithPendingPassiveEffects commit phase before then. + var callback = commitPassiveEffects.bind(null, root, firstEffect); + if (enableSchedulerTracing) { + // TODO: Avoid this extra callback by mutating the tracing ref directly, + // like we do at the beginning of commitRoot. I've opted not to do that + // here because that code is still in flux. + callback = tracing.unstable_wrap(callback); + } + passiveEffectCallbackHandle = scheduler.unstable_scheduleCallback(callback); + passiveEffectCallback = callback; + } + isCommitting$1 = false; isWorking = false; stopCommitLifeCyclesTimer(); @@ -13726,9 +15211,7 @@ function commitRoot(root, finishedWork) { var updateExpirationTimeAfterCommit = finishedWork.expirationTime; var childExpirationTimeAfterCommit = finishedWork.childExpirationTime; var earliestRemainingTimeAfterCommit = - updateExpirationTimeAfterCommit === NoWork || - (childExpirationTimeAfterCommit !== NoWork && - childExpirationTimeAfterCommit < updateExpirationTimeAfterCommit) + childExpirationTimeAfterCommit > updateExpirationTimeAfterCommit ? childExpirationTimeAfterCommit : updateExpirationTimeAfterCommit; if (earliestRemainingTimeAfterCommit === NoWork) { @@ -13771,10 +15254,7 @@ function commitRoot(root, finishedWork) { // Only decrement the pending interaction count if we're done. // If there's still work at the current priority, // That indicates that we are waiting for suspense data. - if ( - earliestRemainingTimeAfterCommit === NoWork || - scheduledExpirationTime < earliestRemainingTimeAfterCommit - ) { + if (scheduledExpirationTime > earliestRemainingTimeAfterCommit) { pendingInteractionMap.delete(scheduledExpirationTime); scheduledInteractions.forEach(function(interaction) { @@ -13830,18 +15310,10 @@ function resetChildExpirationTime(workInProgress, renderTime) { while (child !== null) { var childUpdateExpirationTime = child.expirationTime; var childChildExpirationTime = child.childExpirationTime; - if ( - newChildExpirationTime === NoWork || - (childUpdateExpirationTime !== NoWork && - childUpdateExpirationTime < newChildExpirationTime) - ) { + if (childUpdateExpirationTime > newChildExpirationTime) { newChildExpirationTime = childUpdateExpirationTime; } - if ( - newChildExpirationTime === NoWork || - (childChildExpirationTime !== NoWork && - childChildExpirationTime < newChildExpirationTime) - ) { + if (childChildExpirationTime > newChildExpirationTime) { newChildExpirationTime = childChildExpirationTime; } if (shouldBubbleActualDurations) { @@ -13857,18 +15329,10 @@ function resetChildExpirationTime(workInProgress, renderTime) { while (_child !== null) { var _childUpdateExpirationTime = _child.expirationTime; var _childChildExpirationTime = _child.childExpirationTime; - if ( - newChildExpirationTime === NoWork || - (_childUpdateExpirationTime !== NoWork && - _childUpdateExpirationTime < newChildExpirationTime) - ) { + if (_childUpdateExpirationTime > newChildExpirationTime) { newChildExpirationTime = _childUpdateExpirationTime; } - if ( - newChildExpirationTime === NoWork || - (_childChildExpirationTime !== NoWork && - _childChildExpirationTime < newChildExpirationTime) - ) { + if (_childChildExpirationTime > newChildExpirationTime) { newChildExpirationTime = _childChildExpirationTime; } _child = _child.sibling; @@ -13896,18 +15360,22 @@ function completeUnitOfWork(workInProgress) { var siblingFiber = workInProgress.sibling; if ((workInProgress.effectTag & Incomplete) === NoEffect) { + if (true && replayFailedUnitOfWorkWithInvokeGuardedCallback) { + // Don't replay if it fails during completion phase. + mayReplayFailedUnitOfWork = false; + } // This fiber completed. + // Remember we're completing this unit so we can find a boundary if it fails. + nextUnitOfWork = workInProgress; if (enableProfilerTimer) { if (workInProgress.mode & ProfileMode) { startProfilerTimer(workInProgress); } - nextUnitOfWork = completeWork( current$$1, workInProgress, nextRenderExpirationTime ); - if (workInProgress.mode & ProfileMode) { // Update render duration assuming we didn't error. stopProfilerTimerIfRunningAndRecordDelta(workInProgress, false); @@ -13919,12 +15387,21 @@ function completeUnitOfWork(workInProgress) { nextRenderExpirationTime ); } + if (true && replayFailedUnitOfWorkWithInvokeGuardedCallback) { + // We're out of completion phase so replaying is fine now. + mayReplayFailedUnitOfWork = true; + } stopWorkTimer(workInProgress); resetChildExpirationTime(workInProgress, nextRenderExpirationTime); { resetCurrentFiber(); } + if (nextUnitOfWork !== null) { + // Completing this fiber spawned new work. Work on that next. + return nextUnitOfWork; + } + if ( returnFiber !== null && // Do not append effects to parents if a sibling failed to complete @@ -13978,9 +15455,18 @@ function completeUnitOfWork(workInProgress) { return null; } } else { - if (workInProgress.mode & ProfileMode) { + if (enableProfilerTimer && workInProgress.mode & ProfileMode) { // Record the render duration for the fiber that errored. stopProfilerTimerIfRunningAndRecordDelta(workInProgress, false); + + // Include the time spent working on failed children before continuing. + var actualDuration = workInProgress.actualDuration; + var child = workInProgress.child; + while (child !== null) { + actualDuration += child.actualDuration; + child = child.sibling; + } + workInProgress.actualDuration = actualDuration; } // This fiber did not complete because something threw. Pop values off @@ -14005,19 +15491,6 @@ function completeUnitOfWork(workInProgress) { ReactFiberInstrumentation_1.debugTool.onCompleteWork(workInProgress); } - if (enableProfilerTimer) { - // Include the time spent working on failed children before continuing. - if (next.mode & ProfileMode) { - var actualDuration = next.actualDuration; - var child = next.child; - while (child !== null) { - actualDuration += child.actualDuration; - child = child.sibling; - } - next.actualDuration = actualDuration; - } - } - // If completing this work spawned new work, do that next. We'll come // back here again. // Since we're restarting, remove anything that is not a host effect @@ -14082,6 +15555,7 @@ function performUnitOfWork(workInProgress) { } next = beginWork(current$$1, workInProgress, nextRenderExpirationTime); + workInProgress.memoizedProps = workInProgress.pendingProps; if (workInProgress.mode & ProfileMode) { // Record the render duration assuming we didn't bailout (or error). @@ -14089,6 +15563,7 @@ function performUnitOfWork(workInProgress) { } } else { next = beginWork(current$$1, workInProgress, nextRenderExpirationTime); + workInProgress.memoizedProps = workInProgress.pendingProps; } { @@ -14122,21 +15597,28 @@ function workLoop(isYieldy) { nextUnitOfWork = performUnitOfWork(nextUnitOfWork); } } else { - // Flush asynchronous work until the deadline runs out of time. - while (nextUnitOfWork !== null && !shouldYield()) { + // Flush asynchronous work until there's a higher priority event + while (nextUnitOfWork !== null && !shouldYieldToRenderer()) { nextUnitOfWork = performUnitOfWork(nextUnitOfWork); } } } -function renderRoot(root, isYieldy, isExpired) { +function renderRoot(root, isYieldy) { invariant( !isWorking, "renderRoot was called recursively. This error is likely caused " + "by a bug in React. Please file an issue." ); + + flushPassiveEffects(); + isWorking = true; - ReactCurrentOwner$2.currentDispatcher = Dispatcher; + if (enableHooks) { + ReactCurrentOwner$2.currentDispatcher = Dispatcher; + } else { + ReactCurrentOwner$2.currentDispatcher = DispatcherWithoutHooks; + } var expirationTime = root.nextExpirationTimeToWorkOn; @@ -14166,7 +15648,7 @@ function renderRoot(root, isYieldy, isExpired) { scheduledInteractions, scheduledExpirationTime ) { - if (scheduledExpirationTime <= expirationTime) { + if (scheduledExpirationTime >= expirationTime) { scheduledInteractions.forEach(function(interaction) { return interactions.add(interaction); }); @@ -14218,20 +15700,39 @@ function renderRoot(root, isYieldy, isExpired) { try { workLoop(isYieldy); } catch (thrownValue) { + resetContextDependences(); + resetHooks(); + + // Reset in case completion throws. + // This is only used in DEV and when replaying is on. + var mayReplay = void 0; + if (true && replayFailedUnitOfWorkWithInvokeGuardedCallback) { + mayReplay = mayReplayFailedUnitOfWork; + mayReplayFailedUnitOfWork = true; + } + if (nextUnitOfWork === null) { // This is a fatal error. didFatal = true; onUncaughtError(thrownValue); } else { + if (enableProfilerTimer && nextUnitOfWork.mode & ProfileMode) { + // Record the time spent rendering before an error was thrown. + // This avoids inaccurate Profiler durations in the case of a suspended render. + stopProfilerTimerIfRunningAndRecordDelta(nextUnitOfWork, true); + } + { // Reset global debug state // We assume this is defined in DEV resetCurrentlyProcessingQueue(); } - var failedUnitOfWork = nextUnitOfWork; if (true && replayFailedUnitOfWorkWithInvokeGuardedCallback) { - replayUnitOfWork(failedUnitOfWork, thrownValue, isYieldy); + if (mayReplay) { + var failedUnitOfWork = nextUnitOfWork; + replayUnitOfWork(failedUnitOfWork, thrownValue, isYieldy); + } } // TODO: we already know this isn't true in some cases. @@ -14280,6 +15781,7 @@ function renderRoot(root, isYieldy, isExpired) { isWorking = false; ReactCurrentOwner$2.currentDispatcher = null; resetContextDependences(); + resetHooks(); // Yield back to main thread. if (didFatal) { @@ -14351,7 +15853,7 @@ function renderRoot(root, isYieldy, isExpired) { // similar to a suspend, but without a timeout because we're not waiting // for a promise to resolve. !root.didError && - !isExpired + isYieldy ) { root.didError = true; var _suspendedExpirationTime = (root.nextExpirationTimeToWorkOn = expirationTime); @@ -14367,7 +15869,7 @@ function renderRoot(root, isYieldy, isExpired) { } } - if (!isExpired && nextLatestAbsoluteTimeoutMs !== -1) { + if (isYieldy && nextLatestAbsoluteTimeoutMs !== -1) { // The tree was suspended. var _suspendedExpirationTime2 = expirationTime; markSuspendedPriorityLevel(root, _suspendedExpirationTime2); @@ -14409,17 +15911,12 @@ function renderRoot(root, isYieldy, isExpired) { onComplete(root, rootWorkInProgress, expirationTime); } -function dispatch(sourceFiber, value, expirationTime) { - invariant( - !isWorking || isCommitting$1, - "dispatch: Cannot dispatch during the render phase." - ); - +function captureCommitPhaseError(sourceFiber, value) { + var expirationTime = Sync; var fiber = sourceFiber.return; while (fiber !== null) { switch (fiber.tag) { case ClassComponent: - case ClassComponentLazy: var ctor = fiber.type; var instance = fiber.stateNode; if ( @@ -14460,10 +15957,6 @@ function dispatch(sourceFiber, value, expirationTime) { } } -function captureCommitPhaseError(fiber, error) { - return dispatch(fiber, error, Sync); -} - function computeThreadID(expirationTime, interactionThreadID) { // Interaction threads are unique per root and expiration time. return expirationTime * 1000 + interactionThreadID; @@ -14498,7 +15991,7 @@ function computeExpirationForFiber(currentTime, fiber) { // If we're in the middle of rendering a tree, do not update at the same // expiration time that is already rendering. if (nextRoot !== null && expirationTime === nextRenderExpirationTime) { - expirationTime += 1; + expirationTime -= 1; } } else { // This is a sync update @@ -14509,7 +16002,10 @@ function computeExpirationForFiber(currentTime, fiber) { // This is an interactive update. Keep track of the lowest pending // interactive expiration time. This allows us to synchronously flush // all interactive updates when needed. - if (expirationTime > lowestPriorityPendingInteractiveExpirationTime) { + if ( + lowestPriorityPendingInteractiveExpirationTime === NoWork || + expirationTime < lowestPriorityPendingInteractiveExpirationTime + ) { lowestPriorityPendingInteractiveExpirationTime = expirationTime; } } @@ -14530,7 +16026,7 @@ function renderDidError() { nextRenderDidError = true; } -function retrySuspendedRoot(root, fiber, suspendedTime) { +function retrySuspendedRoot(root, boundaryFiber, sourceFiber, suspendedTime) { var retryTime = void 0; if (isPriorityLevelSuspended(root, suspendedTime)) { @@ -14541,18 +16037,18 @@ function retrySuspendedRoot(root, fiber, suspendedTime) { } else { // Suspense already timed out. Compute a new expiration time var currentTime = requestCurrentTime(); - retryTime = computeExpirationForFiber(currentTime, fiber); + retryTime = computeExpirationForFiber(currentTime, boundaryFiber); markPendingPriorityLevel(root, retryTime); } - // TODO: If the placeholder fiber has already rendered the primary children + // TODO: If the suspense fiber has already rendered the primary children // without suspending (that is, all of the promises have already resolved), // we should not trigger another update here. One case this happens is when // we are in sync mode and a single promise is thrown both on initial render // and on update; we attach two .then(retrySuspendedRoot) callbacks and each // one performs Sync work, rerendering the Suspense. - if ((fiber.mode & ConcurrentMode) !== NoContext) { + if ((boundaryFiber.mode & ConcurrentMode) !== NoContext) { if (root === nextRoot && nextRenderExpirationTime === suspendedTime) { // Received a ping at the same priority level at which we're currently // rendering. Restart from the root. @@ -14560,7 +16056,23 @@ function retrySuspendedRoot(root, fiber, suspendedTime) { } } - scheduleWorkToRoot(fiber, retryTime); + scheduleWorkToRoot(boundaryFiber, retryTime); + if ((boundaryFiber.mode & ConcurrentMode) === NoContext) { + // Outside of concurrent mode, we must schedule an update on the source + // fiber, too, since it already committed in an inconsistent state and + // therefore does not have any pending work. + scheduleWorkToRoot(sourceFiber, retryTime); + var sourceTag = sourceFiber.tag; + if (sourceTag === ClassComponent && sourceFiber.stateNode !== null) { + // When we try rendering again, we should not reuse the current fiber, + // since it's known to be in an inconsistent state. Use a force updte to + // prevent a bail out. + var update = createUpdate(retryTime); + update.tag = ForceUpdate; + enqueueUpdate(sourceFiber, update); + } + } + var rootExpirationTime = root.expirationTime; if (rootExpirationTime !== NoWork) { requestWork(root, rootExpirationTime); @@ -14571,25 +16083,18 @@ function scheduleWorkToRoot(fiber, expirationTime) { recordScheduleUpdate(); { - if (fiber.tag === ClassComponent || fiber.tag === ClassComponentLazy) { + if (fiber.tag === ClassComponent) { var instance = fiber.stateNode; warnAboutInvalidUpdates(instance); } } // Update the source fiber's expiration time - if ( - fiber.expirationTime === NoWork || - fiber.expirationTime > expirationTime - ) { + if (fiber.expirationTime < expirationTime) { fiber.expirationTime = expirationTime; } var alternate = fiber.alternate; - if ( - alternate !== null && - (alternate.expirationTime === NoWork || - alternate.expirationTime > expirationTime) - ) { + if (alternate !== null && alternate.expirationTime < expirationTime) { alternate.expirationTime = expirationTime; } // Walk the parent path to the root and update the child expiration time. @@ -14600,22 +16105,17 @@ function scheduleWorkToRoot(fiber, expirationTime) { } else { while (node !== null) { alternate = node.alternate; - if ( - node.childExpirationTime === NoWork || - node.childExpirationTime > expirationTime - ) { + if (node.childExpirationTime < expirationTime) { node.childExpirationTime = expirationTime; if ( alternate !== null && - (alternate.childExpirationTime === NoWork || - alternate.childExpirationTime > expirationTime) + alternate.childExpirationTime < expirationTime ) { alternate.childExpirationTime = expirationTime; } } else if ( alternate !== null && - (alternate.childExpirationTime === NoWork || - alternate.childExpirationTime > expirationTime) + alternate.childExpirationTime < expirationTime ) { alternate.childExpirationTime = expirationTime; } @@ -14628,11 +16128,18 @@ function scheduleWorkToRoot(fiber, expirationTime) { } if (root === null) { - if ( - true && - (fiber.tag === ClassComponent || fiber.tag === ClassComponentLazy) - ) { - warnAboutUpdateOnUnmounted(fiber); + { + switch (fiber.tag) { + case ClassComponent: + warnAboutUpdateOnUnmounted(fiber, true); + break; + case FunctionComponent: + case ForwardRef: + case MemoComponent: + case SimpleMemoComponent: + warnAboutUpdateOnUnmounted(fiber, false); + break; + } } return null; } @@ -14683,7 +16190,7 @@ function scheduleWork(fiber, expirationTime) { if ( !isWorking && nextRenderExpirationTime !== NoWork && - expirationTime < nextRenderExpirationTime + expirationTime > nextRenderExpirationTime ) { // This is an interruption. (Used for performance tracking.) interruptedBy = fiber; @@ -14727,10 +16234,8 @@ var isRendering = false; var nextFlushedRoot = null; var nextFlushedExpirationTime = NoWork; var lowestPriorityPendingInteractiveExpirationTime = NoWork; -var deadlineDidExpire = false; var hasUnhandledError = false; var unhandledError = null; -var deadline = null; var isBatchingUpdates = false; var isUnbatchingUpdates = false; @@ -14747,8 +16252,6 @@ var NESTED_UPDATE_LIMIT = 50; var nestedUpdateCount = 0; var lastCommittedRootDuringThisBatch = null; -var timeHeuristicForUnitOfWork = 1; - function recomputeCurrentRendererTime() { var currentTimeMs = now() - originalStartTimeMs; currentRendererTime = msToExpirationTime(currentTimeMs); @@ -14757,7 +16260,7 @@ function recomputeCurrentRendererTime() { function scheduleCallbackWithExpirationTime(root, expirationTime) { if (callbackExpirationTime !== NoWork) { // A callback is already scheduled. Check its expiration time (timeout). - if (expirationTime > callbackExpirationTime) { + if (expirationTime < callbackExpirationTime) { // Existing callback has sufficient timeout. Exit. return; } else { @@ -14800,7 +16303,7 @@ function onSuspend( msUntilTimeout ) { root.expirationTime = rootExpirationTime; - if (msUntilTimeout === 0 && !shouldYield()) { + if (msUntilTimeout === 0 && !shouldYieldToRenderer()) { // Don't wait an additional tick. Commit the tree immediately. root.pendingCommitExpirationTime = suspendedExpirationTime; root.finishedWork = finishedWork; @@ -14895,7 +16398,7 @@ function requestWork(root, expirationTime) { // flush it now. nextFlushedRoot = root; nextFlushedExpirationTime = Sync; - performWorkOnRoot(root, Sync, true); + performWorkOnRoot(root, Sync, false); } return; } @@ -14925,10 +16428,7 @@ function addRootToSchedule(root, expirationTime) { } else { // This root is already scheduled, but its priority may have increased. var remainingExpirationTime = root.expirationTime; - if ( - remainingExpirationTime === NoWork || - expirationTime < remainingExpirationTime - ) { + if (expirationTime > remainingExpirationTime) { // Update the priority. root.expirationTime = expirationTime; } @@ -14977,10 +16477,7 @@ function findHighestPriorityRoot() { } root = previousScheduledRoot.nextScheduledRoot; } else { - if ( - highestPriorityWork === NoWork || - remainingExpirationTime < highestPriorityWork - ) { + if (remainingExpirationTime > highestPriorityWork) { // Update the priority, if it's higher highestPriorityWork = remainingExpirationTime; highestPriorityRoot = root; @@ -15003,43 +16500,60 @@ function findHighestPriorityRoot() { nextFlushedExpirationTime = highestPriorityWork; } -function performAsyncWork(dl) { - if (dl.didTimeout) { - // The callback timed out. That means at least one update has expired. - // Iterate through the root schedule. If they contain expired work, set - // the next render expiration time to the current time. This has the effect - // of flushing all expired work in a single batch, instead of flushing each - // level one at a time. - if (firstScheduledRoot !== null) { - recomputeCurrentRendererTime(); - var root = firstScheduledRoot; - do { - didExpireAtExpirationTime(root, currentRendererTime); - // The root schedule is circular, so this is never null. - root = root.nextScheduledRoot; - } while (root !== firstScheduledRoot); +// TODO: This wrapper exists because many of the older tests (the ones that use +// flushDeferredPri) rely on the number of times `shouldYield` is called. We +// should get rid of it. +var didYield = false; +function shouldYieldToRenderer() { + if (didYield) { + return true; + } + if (shouldYield()) { + didYield = true; + return true; + } + return false; +} + +function performAsyncWork() { + try { + if (!shouldYieldToRenderer()) { + // The callback timed out. That means at least one update has expired. + // Iterate through the root schedule. If they contain expired work, set + // the next render expiration time to the current time. This has the effect + // of flushing all expired work in a single batch, instead of flushing each + // level one at a time. + if (firstScheduledRoot !== null) { + recomputeCurrentRendererTime(); + var root = firstScheduledRoot; + do { + didExpireAtExpirationTime(root, currentRendererTime); + // The root schedule is circular, so this is never null. + root = root.nextScheduledRoot; + } while (root !== firstScheduledRoot); + } } + performWork(NoWork, true); + } finally { + didYield = false; } - performWork(NoWork, dl); } function performSyncWork() { - performWork(Sync, null); + performWork(Sync, false); } -function performWork(minExpirationTime, dl) { - deadline = dl; - - // Keep working on roots until there's no more work, or until we reach - // the deadline. +function performWork(minExpirationTime, isYieldy) { + // Keep working on roots until there's no more work, or until there's a higher + // priority event. findHighestPriorityRoot(); - if (deadline !== null) { + if (isYieldy) { recomputeCurrentRendererTime(); currentSchedulerTime = currentRendererTime; if (enableUserTimingAPI) { - var didExpire = nextFlushedExpirationTime < currentRendererTime; + var didExpire = nextFlushedExpirationTime > currentRendererTime; var timeout = expirationTimeToMs(nextFlushedExpirationTime); stopRequestCallbackTimer(didExpire, timeout); } @@ -15047,14 +16561,13 @@ function performWork(minExpirationTime, dl) { while ( nextFlushedRoot !== null && nextFlushedExpirationTime !== NoWork && - (minExpirationTime === NoWork || - minExpirationTime >= nextFlushedExpirationTime) && - (!deadlineDidExpire || currentRendererTime >= nextFlushedExpirationTime) + minExpirationTime <= nextFlushedExpirationTime && + !(didYield && currentRendererTime > nextFlushedExpirationTime) ) { performWorkOnRoot( nextFlushedRoot, nextFlushedExpirationTime, - currentRendererTime >= nextFlushedExpirationTime + currentRendererTime > nextFlushedExpirationTime ); findHighestPriorityRoot(); recomputeCurrentRendererTime(); @@ -15064,10 +16577,9 @@ function performWork(minExpirationTime, dl) { while ( nextFlushedRoot !== null && nextFlushedExpirationTime !== NoWork && - (minExpirationTime === NoWork || - minExpirationTime >= nextFlushedExpirationTime) + minExpirationTime <= nextFlushedExpirationTime ) { - performWorkOnRoot(nextFlushedRoot, nextFlushedExpirationTime, true); + performWorkOnRoot(nextFlushedRoot, nextFlushedExpirationTime, false); findHighestPriorityRoot(); } } @@ -15076,7 +16588,7 @@ function performWork(minExpirationTime, dl) { // or there's no more work left with sufficient priority. // If we're inside a callback, set this to false since we just completed it. - if (deadline !== null) { + if (isYieldy) { callbackExpirationTime = NoWork; callbackID = null; } @@ -15089,9 +16601,6 @@ function performWork(minExpirationTime, dl) { } // Clean-up. - deadline = null; - deadlineDidExpire = false; - finishRendering(); } @@ -15106,7 +16615,7 @@ function flushRoot(root, expirationTime) { // including the given time. nextFlushedRoot = root; nextFlushedExpirationTime = expirationTime; - performWorkOnRoot(root, expirationTime, true); + performWorkOnRoot(root, expirationTime, false); // Flush any sync work that was scheduled by lifecycles performSyncWork(); } @@ -15139,7 +16648,7 @@ function finishRendering() { } } -function performWorkOnRoot(root, expirationTime, isExpired) { +function performWorkOnRoot(root, expirationTime, isYieldy) { invariant( !isRendering, "performWorkOnRoot was called recursively. This error is likely caused " + @@ -15149,7 +16658,7 @@ function performWorkOnRoot(root, expirationTime, isExpired) { isRendering = true; // Check if this is async work or sync/expired work. - if (deadline === null || isExpired) { + if (!isYieldy) { // Flush work without yielding. // TODO: Non-yieldy work does not necessarily imply expired work. A renderer // may want to perform some work without yielding, but also without @@ -15169,8 +16678,7 @@ function performWorkOnRoot(root, expirationTime, isExpired) { // $FlowFixMe Complains noTimeout is not a TimeoutID, despite the check above cancelTimeout(timeoutHandle); } - var isYieldy = false; - renderRoot(root, isYieldy, isExpired); + renderRoot(root, isYieldy); finishedWork = root.finishedWork; if (finishedWork !== null) { // We've completed the root. Commit it. @@ -15193,13 +16701,12 @@ function performWorkOnRoot(root, expirationTime, isExpired) { // $FlowFixMe Complains noTimeout is not a TimeoutID, despite the check above cancelTimeout(_timeoutHandle); } - var _isYieldy = true; - renderRoot(root, _isYieldy, isExpired); + renderRoot(root, isYieldy); _finishedWork = root.finishedWork; if (_finishedWork !== null) { - // We've completed the root. Check the deadline one more time + // We've completed the root. Check the if we should yield one more time // before committing. - if (!shouldYield()) { + if (!shouldYieldToRenderer()) { // Still time left. Commit the root. completeRoot$1(root, _finishedWork, expirationTime); } else { @@ -15217,7 +16724,7 @@ function performWorkOnRoot(root, expirationTime, isExpired) { function completeRoot$1(root, finishedWork, expirationTime) { // Check if there's a batch that matches this expiration time. var firstBatch = root.firstBatch; - if (firstBatch !== null && firstBatch._expirationTime <= expirationTime) { + if (firstBatch !== null && firstBatch._expirationTime >= expirationTime) { if (completedBatches === null) { completedBatches = [firstBatch]; } else { @@ -15249,24 +16756,6 @@ function completeRoot$1(root, finishedWork, expirationTime) { commitRoot(root, finishedWork); } -// When working on async work, the reconciler asks the renderer if it should -// yield execution. For DOM, we implement this with requestIdleCallback. -function shouldYield() { - if (deadlineDidExpire) { - return true; - } - if ( - deadline === null || - deadline.timeRemaining() > timeHeuristicForUnitOfWork - ) { - // Disregard deadline.didTimeout. Only expired work should be flushed - // during a timeout. This path is only hit for non-expired work. - return false; - } - deadlineDidExpire = true; - return true; -} - function onUncaughtError(error) { invariant( nextFlushedRoot !== null, @@ -15311,7 +16800,7 @@ function interactiveUpdates$1(fn, a, b) { lowestPriorityPendingInteractiveExpirationTime !== NoWork ) { // Synchronously flush pending interactive updates. - performWork(lowestPriorityPendingInteractiveExpirationTime, null); + performWork(lowestPriorityPendingInteractiveExpirationTime, false); lowestPriorityPendingInteractiveExpirationTime = NoWork; } var previousIsBatchingInteractiveUpdates = isBatchingInteractiveUpdates; @@ -15335,7 +16824,7 @@ function flushInteractiveUpdates$1() { lowestPriorityPendingInteractiveExpirationTime !== NoWork ) { // Synchronously flush pending interactive updates. - performWork(lowestPriorityPendingInteractiveExpirationTime, null); + performWork(lowestPriorityPendingInteractiveExpirationTime, false); lowestPriorityPendingInteractiveExpirationTime = NoWork; } } @@ -15364,11 +16853,6 @@ function getContextForSubtree(parentComponent) { if (isContextProvider(Component)) { return processChildContext(fiber, Component, parentContext); } - } else if (fiber.tag === ClassComponentLazy) { - var _Component = getResultFromResolvedThenable(fiber.type); - if (isContextProvider(_Component)) { - return processChildContext(fiber, _Component, parentContext); - } } return parentContext; @@ -15406,9 +16890,11 @@ function scheduleRootUpdate(current$$1, element, expirationTime, callback) { : void 0; update.callback = callback; } - enqueueUpdate(current$$1, update); + flushPassiveEffects(); + enqueueUpdate(current$$1, update); scheduleWork(current$$1, expirationTime); + return expirationTime; } @@ -15599,7 +17085,7 @@ function createPortal( // TODO: this is special because it gets imported during build. -var ReactVersion = "16.6.0-alpha.8af6728"; +var ReactVersion = "16.6.1"; // Modules provided by RN: var NativeMethodsMixin = function(findNodeHandle, findHostInstance) { @@ -16001,9 +17487,9 @@ function getInstanceFromTag(tag) { } // Module provided by RN: -var emptyObject$2 = {}; +var emptyObject$1 = {}; { - Object.freeze(emptyObject$2); + Object.freeze(emptyObject$1); } var getInspectorDataForViewTag = void 0; @@ -16036,9 +17522,9 @@ var getInspectorDataForViewTag = void 0; var getHostProps = function(fiber) { var host = findCurrentHostFiber(fiber); if (host) { - return host.memoizedProps || emptyObject$2; + return host.memoizedProps || emptyObject$1; } - return emptyObject$2; + return emptyObject$1; }; var getHostNode = function(fiber, findNodeHandle) { @@ -16084,7 +17570,7 @@ var getInspectorDataForViewTag = void 0; if (!closestInstance) { return { hierarchy: [], - props: emptyObject$2, + props: emptyObject$1, selection: null, source: null }; diff --git a/Libraries/Renderer/oss/ReactFabric-prod.js b/Libraries/Renderer/oss/ReactFabric-prod.js index 9bd0a470b98875..cc9b81203f0a70 100644 --- a/Libraries/Renderer/oss/ReactFabric-prod.js +++ b/Libraries/Renderer/oss/ReactFabric-prod.js @@ -19,7 +19,8 @@ var ReactNativeViewConfigRegistry = require("ReactNativeViewConfigRegistry"), flattenStyle = require("flattenStyle"), TextInputState = require("TextInputState"), FabricUIManager = require("FabricUIManager"); -var ExceptionsManager = require("ExceptionsManager"); +var scheduler = require("scheduler"), + ExceptionsManager = require("ExceptionsManager"); function invariant(condition, format, a, b, c, d, e, f) { if (!condition) { condition = void 0; @@ -166,10 +167,10 @@ var plugins = [], getFiberCurrentPropsFromNode = null, getInstanceFromNode = null, getNodeFromInstance = null; -function executeDispatch(event, simulated, listener, inst) { - simulated = event.type || "unknown-event"; +function executeDispatch(event, listener, inst) { + var type = event.type || "unknown-event"; event.currentTarget = getNodeFromInstance(inst); - invokeGuardedCallbackAndCatchFirstError(simulated, listener, void 0, event); + invokeGuardedCallbackAndCatchFirstError(type, listener, void 0, event); event.currentTarget = null; } function executeDirectDispatch(event) { @@ -215,10 +216,10 @@ function executeDispatchesAndReleaseTopLevel(e) { i < dispatchListeners.length && !e.isPropagationStopped(); i++ ) - executeDispatch(e, !1, dispatchListeners[i], dispatchInstances[i]); + executeDispatch(e, dispatchListeners[i], dispatchInstances[i]); else dispatchListeners && - executeDispatch(e, !1, dispatchListeners, dispatchInstances); + executeDispatch(e, dispatchListeners, dispatchInstances); e._dispatchListeners = null; e._dispatchInstances = null; e.isPersistent() || e.constructor.release(e); @@ -293,7 +294,7 @@ function getListener(inst, registrationName) { } function getParent(inst) { do inst = inst.return; - while (inst && 7 !== inst.tag); + while (inst && 5 !== inst.tag); return inst ? inst : null; } function traverseTwoPhase(inst, fn, arg) { @@ -1034,7 +1035,8 @@ var ReactSharedInternals = : 60111, REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for("react.forward_ref") : 60112, REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for("react.suspense") : 60113, - REACT_PURE_TYPE = hasSymbol ? Symbol.for("react.pure") : 60115, + REACT_MEMO_TYPE = hasSymbol ? Symbol.for("react.memo") : 60115, + REACT_LAZY_TYPE = hasSymbol ? Symbol.for("react.lazy") : 60116, MAYBE_ITERATOR_SYMBOL = "function" === typeof Symbol && Symbol.iterator; function getIteratorFn(maybeIterable) { if (null === maybeIterable || "object" !== typeof maybeIterable) return null; @@ -1043,13 +1045,6 @@ function getIteratorFn(maybeIterable) { maybeIterable["@@iterator"]; return "function" === typeof maybeIterable ? maybeIterable : null; } -function getWrappedName(outerType, innerType, wrapperName) { - innerType = innerType.displayName || innerType.name || ""; - return ( - outerType.displayName || - ("" !== innerType ? wrapperName + "(" + innerType + ")" : wrapperName) - ); -} function getComponentName(type) { if (null == type) return null; if ("function" === typeof type) return type.displayName || type.name || null; @@ -1068,23 +1063,25 @@ function getComponentName(type) { case REACT_SUSPENSE_TYPE: return "Suspense"; } - if ("object" === typeof type) { + if ("object" === typeof type) switch (type.$$typeof) { case REACT_CONTEXT_TYPE: return "Context.Consumer"; case REACT_PROVIDER_TYPE: return "Context.Provider"; case REACT_FORWARD_REF_TYPE: - return getWrappedName(type, type.render, "ForwardRef"); - case REACT_PURE_TYPE: - return getWrappedName(type, type.render, "Pure"); + var innerType = type.render; + innerType = innerType.displayName || innerType.name || ""; + return ( + type.displayName || + ("" !== innerType ? "ForwardRef(" + innerType + ")" : "ForwardRef") + ); + case REACT_MEMO_TYPE: + return getComponentName(type.type); + case REACT_LAZY_TYPE: + if ((type = 1 === type._status ? type._result : null)) + return getComponentName(type); } - if ( - "function" === typeof type.then && - (type = 1 === type._reactStatus ? type._reactResult : null) - ) - return getComponentName(type); - } return null; } function isFiberMountedImpl(fiber) { @@ -1095,7 +1092,7 @@ function isFiberMountedImpl(fiber) { for (; node.return; ) if (((node = node.return), 0 !== (node.effectTag & 2))) return 1; } - return 5 === node.tag ? 2 : 3; + return 3 === node.tag ? 2 : 3; } function assertIsMounted(fiber) { invariant( @@ -1171,14 +1168,14 @@ function findCurrentFiberUsingSlowPath(fiber) { "Return fibers should always be each others' alternates. This error is likely caused by a bug in React. Please file an issue." ); } - invariant(5 === a.tag, "Unable to find node on an unmounted component."); + invariant(3 === a.tag, "Unable to find node on an unmounted component."); return a.stateNode.current === a ? fiber : alternate; } function findCurrentHostFiber(parent) { parent = findCurrentFiberUsingSlowPath(parent); if (!parent) return null; for (var node = parent; ; ) { - if (7 === node.tag || 8 === node.tag) return node; + if (5 === node.tag || 6 === node.tag) return node; if (node.child) (node.child.return = node), (node = node.child); else { if (node === parent) break; @@ -1428,18 +1425,12 @@ var now$1 = return Date.now(); }, scheduledCallback = null, - frameDeadline = 0, - frameDeadlineObject = { - timeRemaining: function() { - return frameDeadline - now$1(); - }, - didTimeout: !1 - }; + frameDeadline = 0; function setTimeoutCallback() { frameDeadline = now$1() + 5; var callback = scheduledCallback; scheduledCallback = null; - null !== callback && callback(frameDeadlineObject); + null !== callback && callback(); } var restoreTarget = null, restoreQueue = null; @@ -1597,19 +1588,44 @@ function createTextInstance( }; } var scheduleTimeout = setTimeout, - cancelTimeout = clearTimeout, - BEFORE_SLASH_RE = /^(.*)[\\\/]/; + cancelTimeout = clearTimeout; +function cloneHiddenInstance(instance) { + var node = instance.node; + var updatePayload = diffProperties( + null, + emptyObject, + { style: { display: "none" } }, + instance.canonical.viewConfig.validAttributes + ); + return { + node: FabricUIManager.cloneNodeWithNewProps(node, updatePayload), + canonical: instance.canonical + }; +} +function cloneUnhiddenInstance(instance, type, props) { + var viewConfig = instance.canonical.viewConfig; + type = instance.node; + var prevProps = Object.assign({}, props, { + style: [props.style, { display: "none" }] + }); + props = diffProperties(null, prevProps, props, viewConfig.validAttributes); + return { + node: FabricUIManager.cloneNodeWithNewProps(type, props), + canonical: instance.canonical + }; +} +var BEFORE_SLASH_RE = /^(.*)[\\\/]/; function getStackByFiberInDevAndProd(workInProgress) { var info = ""; do { a: switch (workInProgress.tag) { - case 4: + case 2: + case 16: case 0: case 1: - case 2: - case 3: - case 7: - case 10: + case 5: + case 8: + case 13: var owner = workInProgress._debugOwner, source = workInProgress._debugSource, name = getComponentName(workInProgress.type); @@ -1760,7 +1776,7 @@ function injectInternals(internals) { function FiberNode(tag, pendingProps, key, mode) { this.tag = tag; this.key = key; - this.sibling = this.child = this.return = this.stateNode = this.type = null; + this.sibling = this.child = this.return = this.stateNode = this.type = this.elementType = null; this.index = 0; this.ref = null; this.pendingProps = pendingProps; @@ -1771,29 +1787,33 @@ function FiberNode(tag, pendingProps, key, mode) { this.childExpirationTime = this.expirationTime = 0; this.alternate = null; } +function createFiber(tag, pendingProps, key, mode) { + return new FiberNode(tag, pendingProps, key, mode); +} function shouldConstruct(Component) { Component = Component.prototype; return !(!Component || !Component.isReactComponent); } -function resolveLazyComponentTag(fiber, Component) { +function resolveLazyComponentTag(Component) { if ("function" === typeof Component) - return shouldConstruct(Component) ? 3 : 1; + return shouldConstruct(Component) ? 1 : 0; if (void 0 !== Component && null !== Component) { - fiber = Component.$$typeof; - if (fiber === REACT_FORWARD_REF_TYPE) return 14; - if (fiber === REACT_PURE_TYPE) return 18; + Component = Component.$$typeof; + if (Component === REACT_FORWARD_REF_TYPE) return 11; + if (Component === REACT_MEMO_TYPE) return 14; } - return 4; + return 2; } function createWorkInProgress(current, pendingProps) { var workInProgress = current.alternate; null === workInProgress - ? ((workInProgress = new FiberNode( + ? ((workInProgress = createFiber( current.tag, pendingProps, current.key, current.mode )), + (workInProgress.elementType = current.elementType), (workInProgress.type = current.type), (workInProgress.stateNode = current.stateNode), (workInProgress.alternate = current), @@ -1815,60 +1835,66 @@ function createWorkInProgress(current, pendingProps) { workInProgress.ref = current.ref; return workInProgress; } -function createFiberFromElement(element, mode, expirationTime) { - var type = element.type, - key = element.key; - element = element.props; - var fiberTag = void 0; - if ("function" === typeof type) fiberTag = shouldConstruct(type) ? 2 : 4; - else if ("string" === typeof type) fiberTag = 7; +function createFiberFromTypeAndProps( + type, + key, + pendingProps, + owner, + mode, + expirationTime +) { + var fiberTag = 2; + owner = type; + if ("function" === typeof type) shouldConstruct(type) && (fiberTag = 1); + else if ("string" === typeof type) fiberTag = 5; else a: switch (type) { case REACT_FRAGMENT_TYPE: return createFiberFromFragment( - element.children, + pendingProps.children, mode, expirationTime, key ); case REACT_CONCURRENT_MODE_TYPE: - fiberTag = 10; - mode |= 3; - break; + return createFiberFromMode(pendingProps, mode | 3, expirationTime, key); case REACT_STRICT_MODE_TYPE: - fiberTag = 10; - mode |= 2; - break; + return createFiberFromMode(pendingProps, mode | 2, expirationTime, key); case REACT_PROFILER_TYPE: return ( - (type = new FiberNode(15, element, key, mode | 4)), + (type = createFiber(12, pendingProps, key, mode | 4)), + (type.elementType = REACT_PROFILER_TYPE), (type.type = REACT_PROFILER_TYPE), (type.expirationTime = expirationTime), type ); case REACT_SUSPENSE_TYPE: - fiberTag = 16; - break; + return ( + (type = createFiber(13, pendingProps, key, mode)), + (type.elementType = REACT_SUSPENSE_TYPE), + (type.type = REACT_SUSPENSE_TYPE), + (type.expirationTime = expirationTime), + type + ); default: if ("object" === typeof type && null !== type) switch (type.$$typeof) { case REACT_PROVIDER_TYPE: - fiberTag = 12; + fiberTag = 10; break a; case REACT_CONTEXT_TYPE: - fiberTag = 11; + fiberTag = 9; break a; case REACT_FORWARD_REF_TYPE: - fiberTag = 13; + fiberTag = 11; break a; - case REACT_PURE_TYPE: - fiberTag = 17; + case REACT_MEMO_TYPE: + fiberTag = 14; + break a; + case REACT_LAZY_TYPE: + fiberTag = 16; + owner = null; break a; - default: - if ("function" === typeof type.then) { - fiberTag = 4; - break a; - } } invariant( !1, @@ -1877,24 +1903,33 @@ function createFiberFromElement(element, mode, expirationTime) { "" ); } - mode = new FiberNode(fiberTag, element, key, mode); - mode.type = type; - mode.expirationTime = expirationTime; - return mode; + key = createFiber(fiberTag, pendingProps, key, mode); + key.elementType = type; + key.type = owner; + key.expirationTime = expirationTime; + return key; } function createFiberFromFragment(elements, mode, expirationTime, key) { - elements = new FiberNode(9, elements, key, mode); + elements = createFiber(7, elements, key, mode); elements.expirationTime = expirationTime; return elements; } +function createFiberFromMode(pendingProps, mode, expirationTime, key) { + pendingProps = createFiber(8, pendingProps, key, mode); + mode = 0 === (mode & 1) ? REACT_STRICT_MODE_TYPE : REACT_CONCURRENT_MODE_TYPE; + pendingProps.elementType = mode; + pendingProps.type = mode; + pendingProps.expirationTime = expirationTime; + return pendingProps; +} function createFiberFromText(content, mode, expirationTime) { - content = new FiberNode(8, content, null, mode); + content = createFiber(6, content, null, mode); content.expirationTime = expirationTime; return content; } function createFiberFromPortal(portal, mode, expirationTime) { - mode = new FiberNode( - 6, + mode = createFiber( + 4, null !== portal.children ? portal.children : [], portal.key, mode @@ -1912,9 +1947,9 @@ function markPendingPriorityLevel(root, expirationTime) { var earliestPendingTime = root.earliestPendingTime; 0 === earliestPendingTime ? (root.earliestPendingTime = root.latestPendingTime = expirationTime) - : earliestPendingTime > expirationTime + : earliestPendingTime < expirationTime ? (root.earliestPendingTime = expirationTime) - : root.latestPendingTime < expirationTime && + : root.latestPendingTime > expirationTime && (root.latestPendingTime = expirationTime); findNextExpirationTimeToWorkOn(expirationTime, root); } @@ -1922,7 +1957,7 @@ function markSuspendedPriorityLevel(root, suspendedTime) { root.didError = !1; var latestPingedTime = root.latestPingedTime; 0 !== latestPingedTime && - latestPingedTime <= suspendedTime && + latestPingedTime >= suspendedTime && (root.latestPingedTime = 0); latestPingedTime = root.earliestPendingTime; var latestPendingTime = root.latestPendingTime; @@ -1937,22 +1972,18 @@ function markSuspendedPriorityLevel(root, suspendedTime) { latestPendingTime = root.latestSuspendedTime; 0 === latestPingedTime ? (root.earliestSuspendedTime = root.latestSuspendedTime = suspendedTime) - : latestPingedTime > suspendedTime + : latestPingedTime < suspendedTime ? (root.earliestSuspendedTime = suspendedTime) - : latestPendingTime < suspendedTime && + : latestPendingTime > suspendedTime && (root.latestSuspendedTime = suspendedTime); findNextExpirationTimeToWorkOn(suspendedTime, root); } function findEarliestOutstandingPriorityLevel(root, renderExpirationTime) { var earliestPendingTime = root.earliestPendingTime; root = root.earliestSuspendedTime; - if ( - 0 === renderExpirationTime || - (0 !== earliestPendingTime && earliestPendingTime < renderExpirationTime) - ) - renderExpirationTime = earliestPendingTime; - if (0 === renderExpirationTime || (0 !== root && root < renderExpirationTime)) - renderExpirationTime = root; + earliestPendingTime > renderExpirationTime && + (renderExpirationTime = earliestPendingTime); + root > renderExpirationTime && (renderExpirationTime = root); return renderExpirationTime; } function findNextExpirationTimeToWorkOn(completedExpirationTime, root) { @@ -1964,12 +1995,11 @@ function findNextExpirationTimeToWorkOn(completedExpirationTime, root) { 0 !== earliestPendingTime ? earliestPendingTime : latestPingedTime; 0 === earliestPendingTime && (0 === completedExpirationTime || - latestSuspendedTime > completedExpirationTime) && + latestSuspendedTime < completedExpirationTime) && (earliestPendingTime = latestSuspendedTime); completedExpirationTime = earliestPendingTime; 0 !== completedExpirationTime && - 0 !== earliestSuspendedTime && - earliestSuspendedTime < completedExpirationTime && + earliestSuspendedTime > completedExpirationTime && (completedExpirationTime = earliestSuspendedTime); root.nextExpirationTimeToWorkOn = earliestPendingTime; root.expirationTime = completedExpirationTime; @@ -2081,7 +2111,7 @@ function getStateFromUpdate( : workInProgress ); case 3: - workInProgress.effectTag = (workInProgress.effectTag & -1025) | 64; + workInProgress.effectTag = (workInProgress.effectTag & -2049) | 64; case 0: workInProgress = update.payload; nextProps = @@ -2114,58 +2144,52 @@ function processUpdateQueue( ) { var updateExpirationTime = update.expirationTime; - if (updateExpirationTime > renderExpirationTime) { - if ( - (null === newFirstUpdate && + updateExpirationTime < renderExpirationTime + ? (null === newFirstUpdate && ((newFirstUpdate = update), (newBaseState = resultState)), - 0 === newExpirationTime || newExpirationTime > updateExpirationTime) - ) - newExpirationTime = updateExpirationTime; - } else - (resultState = getStateFromUpdate( - workInProgress, - queue, - update, - resultState, - props, - instance - )), + newExpirationTime < updateExpirationTime && + (newExpirationTime = updateExpirationTime)) + : ((resultState = getStateFromUpdate( + workInProgress, + queue, + update, + resultState, + props, + instance + )), null !== update.callback && ((workInProgress.effectTag |= 32), (update.nextEffect = null), null === queue.lastEffect ? (queue.firstEffect = queue.lastEffect = update) : ((queue.lastEffect.nextEffect = update), - (queue.lastEffect = update))); + (queue.lastEffect = update)))); update = update.next; } updateExpirationTime = null; for (update = queue.firstCapturedUpdate; null !== update; ) { var _updateExpirationTime = update.expirationTime; - if (_updateExpirationTime > renderExpirationTime) { - if ( - (null === updateExpirationTime && + _updateExpirationTime < renderExpirationTime + ? (null === updateExpirationTime && ((updateExpirationTime = update), null === newFirstUpdate && (newBaseState = resultState)), - 0 === newExpirationTime || newExpirationTime > _updateExpirationTime) - ) - newExpirationTime = _updateExpirationTime; - } else - (resultState = getStateFromUpdate( - workInProgress, - queue, - update, - resultState, - props, - instance - )), + newExpirationTime < _updateExpirationTime && + (newExpirationTime = _updateExpirationTime)) + : ((resultState = getStateFromUpdate( + workInProgress, + queue, + update, + resultState, + props, + instance + )), null !== update.callback && ((workInProgress.effectTag |= 32), (update.nextEffect = null), null === queue.lastCapturedEffect ? (queue.firstCapturedEffect = queue.lastCapturedEffect = update) : ((queue.lastCapturedEffect.nextEffect = update), - (queue.lastCapturedEffect = update))); + (queue.lastCapturedEffect = update)))); update = update.next; } null === newFirstUpdate && (queue.lastUpdate = null); @@ -2246,7 +2270,7 @@ function readContext(context, observedBits) { null === lastContextDependency ? (invariant( null !== currentlyRenderingFiber, - "Context.unstable_read(): Context can only be read while React is rendering, e.g. inside the render method or getDerivedStateFromProps." + "Context can only be read while React is rendering, e.g. inside the render method or getDerivedStateFromProps." ), (currentlyRenderingFiber.firstContextDependency = lastContextDependency = observedBits)) : (lastContextDependency = lastContextDependency.next = observedBits); @@ -2322,7 +2346,47 @@ function shallowEqual(objA, objB) { return !1; return !0; } -var emptyRefsObject = new React.Component().refs; +function resolveDefaultProps(Component, baseProps) { + if (Component && Component.defaultProps) { + baseProps = Object.assign({}, baseProps); + Component = Component.defaultProps; + for (var propName in Component) + void 0 === baseProps[propName] && + (baseProps[propName] = Component[propName]); + } + return baseProps; +} +function readLazyComponentType(lazyComponent) { + var result = lazyComponent._result; + switch (lazyComponent._status) { + case 1: + return result; + case 2: + throw result; + case 0: + throw result; + 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)); + }, + function(error) { + 0 === lazyComponent._status && + ((lazyComponent._status = 2), (lazyComponent._result = error)); + } + ), + (lazyComponent._result = result), + result); + } +} +var ReactCurrentOwner$4 = ReactSharedInternals.ReactCurrentOwner, + emptyRefsObject = new React.Component().refs; function applyDerivedStateFromProps( workInProgress, ctor, @@ -2354,6 +2418,7 @@ var classComponentUpdater = { var update = createUpdate(currentTime); update.payload = payload; void 0 !== callback && null !== callback && (update.callback = callback); + flushPassiveEffects(); enqueueUpdate(inst, update); scheduleWork(inst, currentTime); }, @@ -2365,6 +2430,7 @@ var classComponentUpdater = { update.tag = 1; update.payload = payload; void 0 !== callback && null !== callback && (update.callback = callback); + flushPassiveEffects(); enqueueUpdate(inst, update); scheduleWork(inst, currentTime); }, @@ -2375,6 +2441,7 @@ var classComponentUpdater = { var update = createUpdate(currentTime); update.tag = 2; void 0 !== callback && null !== callback && (update.callback = callback); + flushPassiveEffects(); enqueueUpdate(inst, update); scheduleWork(inst, currentTime); } @@ -2395,6 +2462,32 @@ function checkShouldComponentUpdate( ? !shallowEqual(oldProps, newProps) || !shallowEqual(oldState, newState) : !0; } +function constructClassInstance(workInProgress, ctor, props) { + var isLegacyContextConsumer = !1, + unmaskedContext = emptyContextObject; + var context = ctor.contextType; + "object" === typeof context && null !== context + ? (context = ReactCurrentOwner$4.currentDispatcher.readContext(context)) + : ((unmaskedContext = isContextProvider(ctor) + ? previousContext + : contextStackCursor.current), + (isLegacyContextConsumer = ctor.contextTypes), + (context = (isLegacyContextConsumer = + null !== isLegacyContextConsumer && void 0 !== isLegacyContextConsumer) + ? getMaskedContext(workInProgress, unmaskedContext) + : emptyContextObject)); + ctor = new ctor(props, context); + workInProgress.memoizedState = + null !== ctor.state && void 0 !== ctor.state ? ctor.state : null; + ctor.updater = classComponentUpdater; + workInProgress.stateNode = ctor; + ctor._reactInternalFiber = workInProgress; + isLegacyContextConsumer && + ((workInProgress = workInProgress.stateNode), + (workInProgress.__reactInternalMemoizedUnmaskedChildContext = unmaskedContext), + (workInProgress.__reactInternalMemoizedMaskedChildContext = context)); + return ctor; +} function callComponentWillReceiveProps( workInProgress, instance, @@ -2421,7 +2514,9 @@ function mountClassInstance( instance.refs = emptyRefsObject; var contextType = ctor.contextType; "object" === typeof contextType && null !== contextType - ? (instance.context = contextType.unstable_read()) + ? (instance.context = ReactCurrentOwner$4.currentDispatcher.readContext( + contextType + )) : ((contextType = isContextProvider(ctor) ? previousContext : contextStackCursor.current), @@ -2476,10 +2571,7 @@ function coerceRef(returnFiber, current$$1, element) { element = element._owner; var inst = void 0; element && - (invariant( - 2 === element.tag || 3 === element.tag, - "Function components cannot have refs." - ), + (invariant(1 === element.tag, "Function components cannot have refs."), (inst = element.stateNode)); invariant( inst, @@ -2584,7 +2676,7 @@ function ChildReconciler(shouldTrackSideEffects) { textContent, expirationTime ) { - if (null === current$$1 || 8 !== current$$1.tag) + if (null === current$$1 || 6 !== current$$1.tag) return ( (current$$1 = createFiberFromText( textContent, @@ -2599,15 +2691,18 @@ function ChildReconciler(shouldTrackSideEffects) { return current$$1; } function updateElement(returnFiber, current$$1, element, expirationTime) { - if (null !== current$$1 && current$$1.type === element.type) + if (null !== current$$1 && current$$1.elementType === element.type) return ( (expirationTime = useFiber(current$$1, element.props, expirationTime)), (expirationTime.ref = coerceRef(returnFiber, current$$1, element)), (expirationTime.return = returnFiber), expirationTime ); - expirationTime = createFiberFromElement( - element, + expirationTime = createFiberFromTypeAndProps( + element.type, + element.key, + element.props, + null, returnFiber.mode, expirationTime ); @@ -2618,7 +2713,7 @@ function ChildReconciler(shouldTrackSideEffects) { function updatePortal(returnFiber, current$$1, portal, expirationTime) { if ( null === current$$1 || - 6 !== current$$1.tag || + 4 !== current$$1.tag || current$$1.stateNode.containerInfo !== portal.containerInfo || current$$1.stateNode.implementation !== portal.implementation ) @@ -2642,7 +2737,7 @@ function ChildReconciler(shouldTrackSideEffects) { expirationTime, key ) { - if (null === current$$1 || 9 !== current$$1.tag) + if (null === current$$1 || 7 !== current$$1.tag) return ( (current$$1 = createFiberFromFragment( fragment, @@ -2672,8 +2767,11 @@ function ChildReconciler(shouldTrackSideEffects) { switch (newChild.$$typeof) { case REACT_ELEMENT_TYPE: return ( - (expirationTime = createFiberFromElement( - newChild, + (expirationTime = createFiberFromTypeAndProps( + newChild.type, + newChild.key, + newChild.props, + null, returnFiber.mode, expirationTime )), @@ -3017,9 +3115,9 @@ function ChildReconciler(shouldTrackSideEffects) { ) { if (isUnkeyedTopLevelFragment.key === isObject) if ( - 9 === isUnkeyedTopLevelFragment.tag + 7 === isUnkeyedTopLevelFragment.tag ? newChild.type === REACT_FRAGMENT_TYPE - : isUnkeyedTopLevelFragment.type === newChild.type + : isUnkeyedTopLevelFragment.elementType === newChild.type ) { deleteRemainingChildren( returnFiber, @@ -3059,8 +3157,11 @@ function ChildReconciler(shouldTrackSideEffects) { )), (currentFirstChild.return = returnFiber), (returnFiber = currentFirstChild)) - : ((expirationTime = createFiberFromElement( - newChild, + : ((expirationTime = createFiberFromTypeAndProps( + newChild.type, + newChild.key, + newChild.props, + null, returnFiber.mode, expirationTime )), @@ -3082,7 +3183,7 @@ function ChildReconciler(shouldTrackSideEffects) { ) { if (currentFirstChild.key === isUnkeyedTopLevelFragment) if ( - 6 === currentFirstChild.tag && + 4 === currentFirstChild.tag && currentFirstChild.stateNode.containerInfo === newChild.containerInfo && currentFirstChild.stateNode.implementation === @@ -3120,7 +3221,7 @@ function ChildReconciler(shouldTrackSideEffects) { if ("string" === typeof newChild || "number" === typeof newChild) return ( (newChild = "" + newChild), - null !== currentFirstChild && 8 === currentFirstChild.tag + null !== currentFirstChild && 6 === currentFirstChild.tag ? (deleteRemainingChildren(returnFiber, currentFirstChild.sibling), (currentFirstChild = useFiber( currentFirstChild, @@ -3156,8 +3257,7 @@ function ChildReconciler(shouldTrackSideEffects) { isObject && throwOnInvalidObjectType(returnFiber, newChild); if ("undefined" === typeof newChild && !isUnkeyedTopLevelFragment) switch (returnFiber.tag) { - case 2: - case 3: + case 1: case 0: (expirationTime = returnFiber.type), invariant( @@ -3176,12 +3276,12 @@ var reconcileChildFibers = ChildReconciler(!0), isHydrating = !1; function tryHydrate(fiber, nextInstance) { switch (fiber.tag) { - case 7: + case 5: return ( (nextInstance = shim$1(nextInstance, fiber.type, fiber.pendingProps)), null !== nextInstance ? ((fiber.stateNode = nextInstance), !0) : !1 ); - case 8: + case 6: return ( (nextInstance = shim$1(nextInstance, fiber.pendingProps)), null !== nextInstance ? ((fiber.stateNode = nextInstance), !0) : !1 @@ -3204,7 +3304,8 @@ function tryToClaimNextHydratableInstance(fiber$jscomp$0) { return; } var returnFiber = hydrationParentFiber, - fiber = new FiberNode(7, null, null, 0); + fiber = createFiber(5, null, null, 0); + fiber.elementType = "DELETED"; fiber.type = "DELETED"; fiber.stateNode = firstAttemptedInstance; fiber.return = returnFiber; @@ -3222,38 +3323,6 @@ function tryToClaimNextHydratableInstance(fiber$jscomp$0) { (hydrationParentFiber = fiber$jscomp$0); } } -function readLazyComponentType(thenable) { - switch (thenable._reactStatus) { - case 1: - return thenable._reactResult; - case 2: - throw thenable._reactResult; - case 0: - throw thenable; - default: - throw ((thenable._reactStatus = 0), - thenable.then( - function(resolvedValue) { - if (0 === thenable._reactStatus) { - thenable._reactStatus = 1; - if ("object" === typeof resolvedValue && null !== resolvedValue) { - var defaultExport = resolvedValue.default; - resolvedValue = - void 0 !== defaultExport && null !== defaultExport - ? defaultExport - : resolvedValue; - } - thenable._reactResult = resolvedValue; - } - }, - function(error) { - 0 === thenable._reactStatus && - ((thenable._reactStatus = 2), (thenable._reactResult = error)); - } - ), - thenable); - } -} var ReactCurrentOwner$3 = ReactSharedInternals.ReactCurrentOwner; function reconcileChildren( current$$1, @@ -3279,28 +3348,24 @@ function reconcileChildren( function updateForwardRef( current$$1, workInProgress, - type, + Component, nextProps, renderExpirationTime ) { - type = type.render; + Component = Component.render; var ref = workInProgress.ref; - if ( - !didPerformWorkStackCursor.current && - workInProgress.memoizedProps === nextProps && - ref === (null !== current$$1 ? current$$1.ref : null) - ) - return bailoutOnAlreadyFinishedWork( - current$$1, - workInProgress, - renderExpirationTime - ); - type = type(nextProps, ref); - reconcileChildren(current$$1, workInProgress, type, renderExpirationTime); - workInProgress.memoizedProps = nextProps; + prepareToReadContext(workInProgress, renderExpirationTime); + nextProps = Component(nextProps, ref); + workInProgress.effectTag |= 1; + reconcileChildren( + current$$1, + workInProgress, + nextProps, + renderExpirationTime + ); return workInProgress.child; } -function updatePureComponent( +function updateMemoComponent( current$$1, workInProgress, Component, @@ -3308,29 +3373,82 @@ function updatePureComponent( updateExpirationTime, renderExpirationTime ) { - var render = Component.render, - ref = workInProgress.ref; + if (null === current$$1) { + var type = Component.type; + if ( + "function" === typeof type && + !shouldConstruct(type) && + void 0 === type.defaultProps && + null === Component.compare + ) + return ( + (workInProgress.tag = 15), + (workInProgress.type = type), + updateSimpleMemoComponent( + current$$1, + workInProgress, + type, + nextProps, + updateExpirationTime, + renderExpirationTime + ) + ); + current$$1 = createFiberFromTypeAndProps( + Component.type, + null, + nextProps, + null, + workInProgress.mode, + renderExpirationTime + ); + current$$1.ref = workInProgress.ref; + current$$1.return = workInProgress; + return (workInProgress.child = current$$1); + } + type = current$$1.child; if ( - null !== current$$1 && - (0 === updateExpirationTime || - updateExpirationTime > renderExpirationTime) && - ((updateExpirationTime = current$$1.memoizedProps), + updateExpirationTime < renderExpirationTime && + ((updateExpirationTime = type.memoizedProps), (Component = Component.compare), (Component = null !== Component ? Component : shallowEqual), - workInProgress.ref === current$$1.ref && - Component(updateExpirationTime, nextProps)) + Component(updateExpirationTime, nextProps) && + current$$1.ref === workInProgress.ref) ) return bailoutOnAlreadyFinishedWork( current$$1, workInProgress, renderExpirationTime ); - prepareToReadContext(workInProgress, renderExpirationTime); - render = render(nextProps, ref); workInProgress.effectTag |= 1; - reconcileChildren(current$$1, workInProgress, render, renderExpirationTime); - workInProgress.memoizedProps = nextProps; - return workInProgress.child; + current$$1 = createWorkInProgress(type, nextProps, renderExpirationTime); + current$$1.ref = workInProgress.ref; + current$$1.return = workInProgress; + return (workInProgress.child = current$$1); +} +function updateSimpleMemoComponent( + current$$1, + workInProgress, + Component, + nextProps, + updateExpirationTime, + renderExpirationTime +) { + return null !== current$$1 && + updateExpirationTime < renderExpirationTime && + shallowEqual(current$$1.memoizedProps, nextProps) && + current$$1.ref === workInProgress.ref + ? bailoutOnAlreadyFinishedWork( + current$$1, + workInProgress, + renderExpirationTime + ) + : updateFunctionComponent( + current$$1, + workInProgress, + Component, + nextProps, + renderExpirationTime + ); } function markRef(current$$1, workInProgress) { var ref = workInProgress.ref; @@ -3360,7 +3478,6 @@ function updateFunctionComponent( Component, renderExpirationTime ); - workInProgress.memoizedProps = nextProps; return workInProgress.child; } function updateClassComponent( @@ -3375,166 +3492,152 @@ function updateClassComponent( pushContextProvider(workInProgress); } else hasContext = !1; prepareToReadContext(workInProgress, renderExpirationTime); - if (null === current$$1) - if (null === workInProgress.stateNode) { - var isLegacyContextConsumer = !1, - unmaskedContext = emptyContextObject; - var context = Component.contextType; - "object" === typeof context && null !== context - ? (context = context.unstable_read()) - : ((unmaskedContext = isContextProvider(Component) - ? previousContext - : contextStackCursor.current), - (isLegacyContextConsumer = Component.contextTypes), - (context = (isLegacyContextConsumer = - null !== isLegacyContextConsumer && - void 0 !== isLegacyContextConsumer) - ? getMaskedContext(workInProgress, unmaskedContext) - : emptyContextObject)); - var instance = new Component(nextProps, context); - workInProgress.memoizedState = - null !== instance.state && void 0 !== instance.state - ? instance.state - : null; - instance.updater = classComponentUpdater; - workInProgress.stateNode = instance; - instance._reactInternalFiber = workInProgress; - isLegacyContextConsumer && - ((isLegacyContextConsumer = workInProgress.stateNode), - (isLegacyContextConsumer.__reactInternalMemoizedUnmaskedChildContext = unmaskedContext), - (isLegacyContextConsumer.__reactInternalMemoizedMaskedChildContext = context)); + if (null === workInProgress.stateNode) + null !== current$$1 && + ((current$$1.alternate = null), + (workInProgress.alternate = null), + (workInProgress.effectTag |= 2)), + constructClassInstance( + workInProgress, + Component, + nextProps, + renderExpirationTime + ), mountClassInstance( workInProgress, Component, nextProps, renderExpirationTime - ); - nextProps = !0; - } else { - unmaskedContext = workInProgress.stateNode; - isLegacyContextConsumer = workInProgress.memoizedProps; - unmaskedContext.props = isLegacyContextConsumer; - var oldContext = unmaskedContext.context; - context = Component.contextType; - "object" === typeof context && null !== context - ? (context = context.unstable_read()) - : ((context = isContextProvider(Component) - ? previousContext - : contextStackCursor.current), - (context = getMaskedContext(workInProgress, context))); - var getDerivedStateFromProps = Component.getDerivedStateFromProps; - (instance = + ), + (nextProps = !0); + else if (null === current$$1) { + var instance = workInProgress.stateNode, + oldProps = workInProgress.memoizedProps; + instance.props = oldProps; + var oldContext = instance.context, + contextType = Component.contextType; + "object" === typeof contextType && null !== contextType + ? (contextType = ReactCurrentOwner$4.currentDispatcher.readContext( + contextType + )) + : ((contextType = isContextProvider(Component) + ? previousContext + : contextStackCursor.current), + (contextType = getMaskedContext(workInProgress, contextType))); + var getDerivedStateFromProps = Component.getDerivedStateFromProps, + hasNewLifecycles = "function" === typeof getDerivedStateFromProps || - "function" === typeof unmaskedContext.getSnapshotBeforeUpdate) || - ("function" !== - typeof unmaskedContext.UNSAFE_componentWillReceiveProps && - "function" !== typeof unmaskedContext.componentWillReceiveProps) || - ((isLegacyContextConsumer !== nextProps || oldContext !== context) && - callComponentWillReceiveProps( - workInProgress, - unmaskedContext, - nextProps, - context - )); - hasForceUpdate = !1; - var oldState = workInProgress.memoizedState; - oldContext = unmaskedContext.state = oldState; - var updateQueue = workInProgress.updateQueue; - null !== updateQueue && - (processUpdateQueue( + "function" === typeof instance.getSnapshotBeforeUpdate; + hasNewLifecycles || + ("function" !== typeof instance.UNSAFE_componentWillReceiveProps && + "function" !== typeof instance.componentWillReceiveProps) || + ((oldProps !== nextProps || oldContext !== contextType) && + callComponentWillReceiveProps( workInProgress, - updateQueue, + instance, nextProps, - unmaskedContext, - renderExpirationTime - ), - (oldContext = workInProgress.memoizedState)); - isLegacyContextConsumer !== nextProps || - oldState !== oldContext || - didPerformWorkStackCursor.current || - hasForceUpdate - ? ("function" === typeof getDerivedStateFromProps && - (applyDerivedStateFromProps( - workInProgress, - Component, - getDerivedStateFromProps, - nextProps - ), - (oldContext = workInProgress.memoizedState)), - (isLegacyContextConsumer = - hasForceUpdate || - checkShouldComponentUpdate( - workInProgress, - Component, - isLegacyContextConsumer, - nextProps, - oldState, - oldContext, - context - )) - ? (instance || - ("function" !== - typeof unmaskedContext.UNSAFE_componentWillMount && - "function" !== typeof unmaskedContext.componentWillMount) || - ("function" === typeof unmaskedContext.componentWillMount && - unmaskedContext.componentWillMount(), - "function" === - typeof unmaskedContext.UNSAFE_componentWillMount && - unmaskedContext.UNSAFE_componentWillMount()), - "function" === typeof unmaskedContext.componentDidMount && - (workInProgress.effectTag |= 4)) - : ("function" === typeof unmaskedContext.componentDidMount && - (workInProgress.effectTag |= 4), - (workInProgress.memoizedProps = nextProps), - (workInProgress.memoizedState = oldContext)), - (unmaskedContext.props = nextProps), - (unmaskedContext.state = oldContext), - (unmaskedContext.context = context), - (nextProps = isLegacyContextConsumer)) - : ("function" === typeof unmaskedContext.componentDidMount && - (workInProgress.effectTag |= 4), - (nextProps = !1)); - } - else - (unmaskedContext = workInProgress.stateNode), - (isLegacyContextConsumer = workInProgress.memoizedProps), - (unmaskedContext.props = isLegacyContextConsumer), - (oldContext = unmaskedContext.context), - (context = Component.contextType), - "object" === typeof context && null !== context - ? (context = context.unstable_read()) - : ((context = isContextProvider(Component) + contextType + )); + hasForceUpdate = !1; + var oldState = workInProgress.memoizedState; + oldContext = instance.state = oldState; + var updateQueue = workInProgress.updateQueue; + null !== updateQueue && + (processUpdateQueue( + workInProgress, + updateQueue, + nextProps, + instance, + renderExpirationTime + ), + (oldContext = workInProgress.memoizedState)); + oldProps !== nextProps || + oldState !== oldContext || + didPerformWorkStackCursor.current || + hasForceUpdate + ? ("function" === typeof getDerivedStateFromProps && + (applyDerivedStateFromProps( + workInProgress, + Component, + getDerivedStateFromProps, + nextProps + ), + (oldContext = workInProgress.memoizedState)), + (oldProps = + hasForceUpdate || + checkShouldComponentUpdate( + workInProgress, + Component, + oldProps, + nextProps, + oldState, + oldContext, + contextType + )) + ? (hasNewLifecycles || + ("function" !== typeof instance.UNSAFE_componentWillMount && + "function" !== typeof instance.componentWillMount) || + ("function" === typeof instance.componentWillMount && + instance.componentWillMount(), + "function" === typeof instance.UNSAFE_componentWillMount && + instance.UNSAFE_componentWillMount()), + "function" === typeof instance.componentDidMount && + (workInProgress.effectTag |= 4)) + : ("function" === typeof instance.componentDidMount && + (workInProgress.effectTag |= 4), + (workInProgress.memoizedProps = nextProps), + (workInProgress.memoizedState = oldContext)), + (instance.props = nextProps), + (instance.state = oldContext), + (instance.context = contextType), + (nextProps = oldProps)) + : ("function" === typeof instance.componentDidMount && + (workInProgress.effectTag |= 4), + (nextProps = !1)); + } else + (instance = workInProgress.stateNode), + (oldProps = workInProgress.memoizedProps), + (instance.props = + workInProgress.type === workInProgress.elementType + ? oldProps + : resolveDefaultProps(workInProgress.type, oldProps)), + (oldContext = instance.context), + (contextType = Component.contextType), + "object" === typeof contextType && null !== contextType + ? (contextType = ReactCurrentOwner$4.currentDispatcher.readContext( + contextType + )) + : ((contextType = isContextProvider(Component) ? previousContext : contextStackCursor.current), - (context = getMaskedContext(workInProgress, context))), + (contextType = getMaskedContext(workInProgress, contextType))), (getDerivedStateFromProps = Component.getDerivedStateFromProps), - (instance = + (hasNewLifecycles = "function" === typeof getDerivedStateFromProps || - "function" === typeof unmaskedContext.getSnapshotBeforeUpdate) || - ("function" !== - typeof unmaskedContext.UNSAFE_componentWillReceiveProps && - "function" !== typeof unmaskedContext.componentWillReceiveProps) || - ((isLegacyContextConsumer !== nextProps || oldContext !== context) && + "function" === typeof instance.getSnapshotBeforeUpdate) || + ("function" !== typeof instance.UNSAFE_componentWillReceiveProps && + "function" !== typeof instance.componentWillReceiveProps) || + ((oldProps !== nextProps || oldContext !== contextType) && callComponentWillReceiveProps( workInProgress, - unmaskedContext, + instance, nextProps, - context + contextType )), (hasForceUpdate = !1), (oldContext = workInProgress.memoizedState), - (oldState = unmaskedContext.state = oldContext), + (oldState = instance.state = oldContext), (updateQueue = workInProgress.updateQueue), null !== updateQueue && (processUpdateQueue( workInProgress, updateQueue, nextProps, - unmaskedContext, + instance, renderExpirationTime ), (oldState = workInProgress.memoizedState)), - isLegacyContextConsumer !== nextProps || + oldProps !== nextProps || oldContext !== oldState || didPerformWorkStackCursor.current || hasForceUpdate @@ -3551,53 +3654,51 @@ function updateClassComponent( checkShouldComponentUpdate( workInProgress, Component, - isLegacyContextConsumer, + oldProps, nextProps, oldContext, oldState, - context + contextType )) - ? (instance || - ("function" !== - typeof unmaskedContext.UNSAFE_componentWillUpdate && - "function" !== typeof unmaskedContext.componentWillUpdate) || - ("function" === typeof unmaskedContext.componentWillUpdate && - unmaskedContext.componentWillUpdate( + ? (hasNewLifecycles || + ("function" !== typeof instance.UNSAFE_componentWillUpdate && + "function" !== typeof instance.componentWillUpdate) || + ("function" === typeof instance.componentWillUpdate && + instance.componentWillUpdate( nextProps, oldState, - context + contextType ), - "function" === - typeof unmaskedContext.UNSAFE_componentWillUpdate && - unmaskedContext.UNSAFE_componentWillUpdate( + "function" === typeof instance.UNSAFE_componentWillUpdate && + instance.UNSAFE_componentWillUpdate( nextProps, oldState, - context + contextType )), - "function" === typeof unmaskedContext.componentDidUpdate && + "function" === typeof instance.componentDidUpdate && (workInProgress.effectTag |= 4), - "function" === typeof unmaskedContext.getSnapshotBeforeUpdate && + "function" === typeof instance.getSnapshotBeforeUpdate && (workInProgress.effectTag |= 256)) - : ("function" !== typeof unmaskedContext.componentDidUpdate || - (isLegacyContextConsumer === current$$1.memoizedProps && + : ("function" !== typeof instance.componentDidUpdate || + (oldProps === current$$1.memoizedProps && oldContext === current$$1.memoizedState) || (workInProgress.effectTag |= 4), - "function" !== typeof unmaskedContext.getSnapshotBeforeUpdate || - (isLegacyContextConsumer === current$$1.memoizedProps && + "function" !== typeof instance.getSnapshotBeforeUpdate || + (oldProps === current$$1.memoizedProps && oldContext === current$$1.memoizedState) || (workInProgress.effectTag |= 256), (workInProgress.memoizedProps = nextProps), (workInProgress.memoizedState = oldState)), - (unmaskedContext.props = nextProps), - (unmaskedContext.state = oldState), - (unmaskedContext.context = context), + (instance.props = nextProps), + (instance.state = oldState), + (instance.context = contextType), (nextProps = getDerivedStateFromProps)) - : ("function" !== typeof unmaskedContext.componentDidUpdate || - (isLegacyContextConsumer === current$$1.memoizedProps && + : ("function" !== typeof instance.componentDidUpdate || + (oldProps === current$$1.memoizedProps && oldContext === current$$1.memoizedState) || (workInProgress.effectTag |= 4), - "function" !== typeof unmaskedContext.getSnapshotBeforeUpdate || - (isLegacyContextConsumer === current$$1.memoizedProps && + "function" !== typeof instance.getSnapshotBeforeUpdate || + (oldProps === current$$1.memoizedProps && oldContext === current$$1.memoizedState) || (workInProgress.effectTag |= 256), (nextProps = !1)); @@ -3656,7 +3757,6 @@ function finishClassComponent( renderExpirationTime ); workInProgress.memoizedState = shouldUpdate.state; - workInProgress.memoizedProps = shouldUpdate.props; hasContext && invalidateContextProvider(workInProgress, Component, !0); return workInProgress.child; } @@ -3672,15 +3772,105 @@ function pushHostRootContext(workInProgress) { pushTopLevelContextObject(workInProgress, root.context, !1); pushHostContainer(workInProgress, root.containerInfo); } -function resolveDefaultProps(Component, baseProps) { - if (Component && Component.defaultProps) { - baseProps = Object.assign({}, baseProps); - Component = Component.defaultProps; - for (var propName in Component) - void 0 === baseProps[propName] && - (baseProps[propName] = Component[propName]); - } - return baseProps; +function updateSuspenseComponent( + current$$1, + workInProgress, + renderExpirationTime +) { + var mode = workInProgress.mode, + nextProps = workInProgress.pendingProps, + nextState = workInProgress.memoizedState; + if (0 === (workInProgress.effectTag & 64)) { + nextState = null; + var nextDidTimeout = !1; + } else + (nextState = { timedOutAt: null !== nextState ? nextState.timedOutAt : 0 }), + (nextDidTimeout = !0), + (workInProgress.effectTag &= -65); + null === current$$1 + ? nextDidTimeout + ? ((nextDidTimeout = nextProps.fallback), + (nextProps = createFiberFromFragment(null, mode, 0, null)), + 0 === (workInProgress.mode & 1) && + (nextProps.child = + null !== workInProgress.memoizedState + ? workInProgress.child.child + : workInProgress.child), + (mode = createFiberFromFragment( + nextDidTimeout, + mode, + renderExpirationTime, + null + )), + (nextProps.sibling = mode), + (renderExpirationTime = nextProps), + (renderExpirationTime.return = mode.return = workInProgress)) + : (renderExpirationTime = mode = mountChildFibers( + workInProgress, + null, + nextProps.children, + renderExpirationTime + )) + : null !== current$$1.memoizedState + ? ((mode = current$$1.child), + (current$$1 = mode.sibling), + nextDidTimeout + ? ((renderExpirationTime = nextProps.fallback), + (nextProps = createWorkInProgress(mode, mode.pendingProps, 0)), + (nextProps.effectTag |= 2), + 0 === (workInProgress.mode & 1) && + ((nextDidTimeout = + null !== workInProgress.memoizedState + ? workInProgress.child.child + : workInProgress.child), + nextDidTimeout !== mode.child && + (nextProps.child = nextDidTimeout)), + (mode = nextProps.sibling = createWorkInProgress( + current$$1, + renderExpirationTime, + current$$1.expirationTime + )), + (mode.effectTag |= 2), + (renderExpirationTime = nextProps), + (nextProps.childExpirationTime = 0), + (renderExpirationTime.return = mode.return = workInProgress)) + : (renderExpirationTime = mode = reconcileChildFibers( + workInProgress, + mode.child, + nextProps.children, + renderExpirationTime + ))) + : ((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), + 0 === (workInProgress.mode & 1) && + (nextProps.child = + null !== workInProgress.memoizedState + ? workInProgress.child.child + : workInProgress.child), + (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, @@ -3689,9 +3879,7 @@ function bailoutOnAlreadyFinishedWork( ) { null !== current$$1 && (workInProgress.firstContextDependency = current$$1.firstContextDependency); - var childExpirationTime = workInProgress.childExpirationTime; - if (0 === childExpirationTime || childExpirationTime > renderExpirationTime) - return null; + if (workInProgress.childExpirationTime < renderExpirationTime) return null; invariant( null === current$$1 || workInProgress.child === current$$1.child, "Resuming work not yet implemented." @@ -3726,31 +3914,47 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { null !== current$$1 && current$$1.memoizedProps === workInProgress.pendingProps && !didPerformWorkStackCursor.current && - (0 === updateExpirationTime || updateExpirationTime > renderExpirationTime) + updateExpirationTime < renderExpirationTime ) { switch (workInProgress.tag) { - case 5: + case 3: pushHostRootContext(workInProgress); break; - case 7: + case 5: pushHostContext(workInProgress); break; - case 2: + case 1: isContextProvider(workInProgress.type) && pushContextProvider(workInProgress); break; - case 3: - isContextProvider(workInProgress.type._reactResult) && - pushContextProvider(workInProgress); - break; - case 6: + case 4: pushHostContainer( workInProgress, workInProgress.stateNode.containerInfo ); break; - case 12: + case 10: pushProvider(workInProgress, workInProgress.memoizedProps.value); + break; + case 13: + if (null !== workInProgress.memoizedState) { + updateExpirationTime = workInProgress.child.childExpirationTime; + if ( + 0 !== updateExpirationTime && + updateExpirationTime >= renderExpirationTime + ) + return updateSuspenseComponent( + current$$1, + workInProgress, + renderExpirationTime + ); + workInProgress = bailoutOnAlreadyFinishedWork( + current$$1, + workInProgress, + renderExpirationTime + ); + return null !== workInProgress ? workInProgress.sibling : null; + } } return bailoutOnAlreadyFinishedWork( current$$1, @@ -3760,191 +3964,180 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { } workInProgress.expirationTime = 0; switch (workInProgress.tag) { - case 4: - var Component = workInProgress.type; - invariant( - null === current$$1, - "An indeterminate component should never have mounted. This error is likely caused by a bug in React. Please file an issue." + 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 ); - var props = workInProgress.pendingProps; + prepareToReadContext(workInProgress, renderExpirationTime); + context = updateExpirationTime(current$$1, context); + workInProgress.effectTag |= 1; if ( - "object" === typeof Component && - null !== Component && - "function" === typeof Component.then + "object" === typeof context && + null !== context && + "function" === typeof context.render && + void 0 === context.$$typeof ) { - Component = readLazyComponentType(Component); - var resolvedTag = (workInProgress.tag = resolveLazyComponentTag( + workInProgress.tag = 1; + if (isContextProvider(updateExpirationTime)) { + var hasContext = !0; + pushContextProvider(workInProgress); + } else hasContext = !1; + workInProgress.memoizedState = + null !== context.state && void 0 !== context.state + ? context.state + : null; + var getDerivedStateFromProps = + updateExpirationTime.getDerivedStateFromProps; + "function" === typeof getDerivedStateFromProps && + applyDerivedStateFromProps( workInProgress, - Component - )), - resolvedProps = resolveDefaultProps(Component, props), - child = void 0; - switch (resolvedTag) { - case 1: - child = updateFunctionComponent( - current$$1, - workInProgress, - Component, - resolvedProps, - renderExpirationTime - ); - break; - case 3: - child = updateClassComponent( - current$$1, - workInProgress, - Component, - resolvedProps, - renderExpirationTime - ); - break; - case 14: - child = updateForwardRef( - current$$1, - workInProgress, - Component, - resolvedProps, - renderExpirationTime - ); - break; - case 18: - child = updatePureComponent( - current$$1, - workInProgress, - Component, - resolvedProps, - updateExpirationTime, - renderExpirationTime - ); - break; - default: - invariant( - !1, - "Element type is invalid. Received a promise that resolves to: %s. Promise elements must resolve to a class or function.", - Component - ); - } - workInProgress.memoizedProps = props; - workInProgress = child; - } else - (updateExpirationTime = getMaskedContext( + updateExpirationTime, + getDerivedStateFromProps, + current$$1 + ); + context.updater = classComponentUpdater; + workInProgress.stateNode = context; + context._reactInternalFiber = workInProgress; + mountClassInstance( workInProgress, - contextStackCursor.current - )), - prepareToReadContext(workInProgress, renderExpirationTime), - (updateExpirationTime = Component(props, updateExpirationTime)), - (workInProgress.effectTag |= 1), - "object" === typeof updateExpirationTime && - null !== updateExpirationTime && - "function" === typeof updateExpirationTime.render && - void 0 === updateExpirationTime.$$typeof - ? ((workInProgress.tag = 2), - isContextProvider(Component) - ? ((resolvedTag = !0), pushContextProvider(workInProgress)) - : (resolvedTag = !1), - (workInProgress.memoizedState = - null !== updateExpirationTime.state && - void 0 !== updateExpirationTime.state - ? updateExpirationTime.state - : null), - (resolvedProps = Component.getDerivedStateFromProps), - "function" === typeof resolvedProps && - applyDerivedStateFromProps( - workInProgress, - Component, - resolvedProps, - props - ), - (updateExpirationTime.updater = classComponentUpdater), - (workInProgress.stateNode = updateExpirationTime), - (updateExpirationTime._reactInternalFiber = workInProgress), - mountClassInstance( - workInProgress, - Component, - props, - renderExpirationTime - ), - (workInProgress = finishClassComponent( - current$$1, - workInProgress, - Component, - !0, - resolvedTag, - renderExpirationTime - ))) - : ((workInProgress.tag = 0), - reconcileChildren( - current$$1, - workInProgress, - updateExpirationTime, - renderExpirationTime - ), - (workInProgress.memoizedProps = props), - (workInProgress = workInProgress.child)); + updateExpirationTime, + current$$1, + renderExpirationTime + ); + workInProgress = finishClassComponent( + null, + workInProgress, + updateExpirationTime, + !0, + hasContext, + renderExpirationTime + ); + } else + (workInProgress.tag = 0), + reconcileChildren( + null, + workInProgress, + context, + renderExpirationTime + ), + (workInProgress = workInProgress.child); return workInProgress; + case 16: + context = workInProgress.elementType; + null !== current$$1 && + ((current$$1.alternate = null), + (workInProgress.alternate = null), + (workInProgress.effectTag |= 2)); + hasContext = workInProgress.pendingProps; + current$$1 = readLazyComponentType(context); + workInProgress.type = current$$1; + context = workInProgress.tag = resolveLazyComponentTag(current$$1); + hasContext = resolveDefaultProps(current$$1, hasContext); + getDerivedStateFromProps = void 0; + switch (context) { + case 0: + getDerivedStateFromProps = updateFunctionComponent( + null, + workInProgress, + current$$1, + hasContext, + renderExpirationTime + ); + break; + case 1: + getDerivedStateFromProps = updateClassComponent( + null, + workInProgress, + current$$1, + hasContext, + renderExpirationTime + ); + break; + case 11: + getDerivedStateFromProps = updateForwardRef( + null, + workInProgress, + current$$1, + hasContext, + renderExpirationTime + ); + break; + case 14: + getDerivedStateFromProps = updateMemoComponent( + null, + workInProgress, + current$$1, + resolveDefaultProps(current$$1.type, hasContext), + 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.", + current$$1 + ); + } + return getDerivedStateFromProps; case 0: - return updateFunctionComponent( - current$$1, - workInProgress, - workInProgress.type, - workInProgress.pendingProps, - renderExpirationTime - ); - case 1: return ( - (props = workInProgress.type._reactResult), - (Component = workInProgress.pendingProps), - (current$$1 = updateFunctionComponent( + (updateExpirationTime = workInProgress.type), + (context = workInProgress.pendingProps), + (context = + workInProgress.elementType === updateExpirationTime + ? context + : resolveDefaultProps(updateExpirationTime, context)), + updateFunctionComponent( current$$1, workInProgress, - props, - resolveDefaultProps(props, Component), + updateExpirationTime, + context, renderExpirationTime - )), - (workInProgress.memoizedProps = Component), - current$$1 - ); - case 2: - return updateClassComponent( - current$$1, - workInProgress, - workInProgress.type, - workInProgress.pendingProps, - renderExpirationTime + ) ); - case 3: + case 1: return ( - (props = workInProgress.type._reactResult), - (Component = workInProgress.pendingProps), - (current$$1 = updateClassComponent( + (updateExpirationTime = workInProgress.type), + (context = workInProgress.pendingProps), + (context = + workInProgress.elementType === updateExpirationTime + ? context + : resolveDefaultProps(updateExpirationTime, context)), + updateClassComponent( current$$1, workInProgress, - props, - resolveDefaultProps(props, Component), + updateExpirationTime, + context, renderExpirationTime - )), - (workInProgress.memoizedProps = Component), - current$$1 + ) ); - case 5: + case 3: return ( pushHostRootContext(workInProgress), - (Component = workInProgress.updateQueue), + (updateExpirationTime = workInProgress.updateQueue), invariant( - null !== Component, + null !== updateExpirationTime, "If the root does not have an updateQueue, we should have already bailed out. This error is likely caused by a bug in React. Please file an issue." ), - (props = workInProgress.memoizedState), - (props = null !== props ? props.element : null), + (context = workInProgress.memoizedState), + (context = null !== context ? context.element : null), processUpdateQueue( workInProgress, - Component, + updateExpirationTime, workInProgress.pendingProps, null, renderExpirationTime ), - (Component = workInProgress.memoizedState.element), - Component === props + (updateExpirationTime = workInProgress.memoizedState.element), + updateExpirationTime === context ? (workInProgress = bailoutOnAlreadyFinishedWork( current$$1, workInProgress, @@ -3953,185 +4146,130 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { : (reconcileChildren( current$$1, workInProgress, - Component, + updateExpirationTime, renderExpirationTime ), (workInProgress = workInProgress.child)), workInProgress ); - case 7: + case 5: return ( pushHostContext(workInProgress), null === current$$1 && tryToClaimNextHydratableInstance(workInProgress), - (Component = workInProgress.pendingProps), - (props = Component.children), + (updateExpirationTime = workInProgress.pendingProps.children), markRef(current$$1, workInProgress), reconcileChildren( current$$1, workInProgress, - props, + updateExpirationTime, renderExpirationTime ), - (workInProgress.memoizedProps = Component), (workInProgress = workInProgress.child), workInProgress ); - case 8: + case 6: return ( null === current$$1 && tryToClaimNextHydratableInstance(workInProgress), - (workInProgress.memoizedProps = workInProgress.pendingProps), null ); - case 16: - return ( - (Component = workInProgress.pendingProps), - (props = 0 === (workInProgress.effectTag & 64)), - null !== current$$1 && null !== workInProgress.updateQueue - ? ((workInProgress.updateQueue = null), (props = !0)) - : (props = !props), - 0 !== (workInProgress.mode & 2) && - (props - ? (workInProgress.effectTag |= 4) - : (workInProgress.stateNode = null)), - (updateExpirationTime = Component.children), - (updateExpirationTime = - "function" === typeof updateExpirationTime - ? updateExpirationTime(props) - : props - ? Component.fallback - : updateExpirationTime), - null !== current$$1 && props !== workInProgress.memoizedState - ? ((workInProgress.child = reconcileChildFibers( - workInProgress, - current$$1.child, - null, - renderExpirationTime - )), - (workInProgress.child = reconcileChildFibers( - workInProgress, - null, - updateExpirationTime, - renderExpirationTime - ))) - : reconcileChildren( - current$$1, - workInProgress, - updateExpirationTime, - renderExpirationTime - ), - (workInProgress.memoizedProps = Component), - (workInProgress.memoizedState = props), - workInProgress.child + case 13: + return updateSuspenseComponent( + current$$1, + workInProgress, + renderExpirationTime ); - case 6: + case 4: return ( pushHostContainer( workInProgress, workInProgress.stateNode.containerInfo ), - (Component = workInProgress.pendingProps), + (updateExpirationTime = workInProgress.pendingProps), null === current$$1 ? (workInProgress.child = reconcileChildFibers( workInProgress, null, - Component, + updateExpirationTime, renderExpirationTime )) : reconcileChildren( current$$1, workInProgress, - Component, + updateExpirationTime, renderExpirationTime ), - (workInProgress.memoizedProps = Component), workInProgress.child ); - case 13: - return updateForwardRef( - current$$1, - workInProgress, - workInProgress.type, - workInProgress.pendingProps, - renderExpirationTime - ); - case 14: + case 11: return ( - (props = workInProgress.type._reactResult), - (Component = workInProgress.pendingProps), - (current$$1 = updateForwardRef( + (updateExpirationTime = workInProgress.type), + (context = workInProgress.pendingProps), + (context = + workInProgress.elementType === updateExpirationTime + ? context + : resolveDefaultProps(updateExpirationTime, context)), + updateForwardRef( current$$1, workInProgress, - props, - resolveDefaultProps(props, Component), + updateExpirationTime, + context, renderExpirationTime - )), - (workInProgress.memoizedProps = Component), - current$$1 + ) ); - case 9: + case 7: return ( - (Component = workInProgress.pendingProps), reconcileChildren( current$$1, workInProgress, - Component, + workInProgress.pendingProps, renderExpirationTime ), - (workInProgress.memoizedProps = Component), workInProgress.child ); - case 10: + case 8: return ( - (Component = workInProgress.pendingProps.children), reconcileChildren( current$$1, workInProgress, - Component, + workInProgress.pendingProps.children, renderExpirationTime ), - (workInProgress.memoizedProps = Component), workInProgress.child ); - case 15: + case 12: return ( - (Component = workInProgress.pendingProps), reconcileChildren( current$$1, workInProgress, - Component.children, + workInProgress.pendingProps.children, renderExpirationTime ), - (workInProgress.memoizedProps = Component), workInProgress.child ); - case 12: + case 10: a: { - Component = workInProgress.type._context; - props = workInProgress.pendingProps; - resolvedTag = workInProgress.memoizedProps; - updateExpirationTime = props.value; - workInProgress.memoizedProps = props; - pushProvider(workInProgress, updateExpirationTime); - if (null !== resolvedTag) - if ( - ((resolvedProps = resolvedTag.value), - (updateExpirationTime = - (resolvedProps === updateExpirationTime && - (0 !== resolvedProps || - 1 / resolvedProps === 1 / updateExpirationTime)) || - (resolvedProps !== resolvedProps && - updateExpirationTime !== updateExpirationTime) - ? 0 - : ("function" === typeof Component._calculateChangedBits - ? Component._calculateChangedBits( - resolvedProps, - updateExpirationTime - ) - : 1073741823) | 0), - 0 === updateExpirationTime) - ) { + updateExpirationTime = workInProgress.type._context; + context = workInProgress.pendingProps; + getDerivedStateFromProps = workInProgress.memoizedProps; + hasContext = context.value; + pushProvider(workInProgress, hasContext); + if (null !== getDerivedStateFromProps) { + var oldValue = getDerivedStateFromProps.value; + hasContext = + (oldValue === hasContext && + (0 !== oldValue || 1 / oldValue === 1 / hasContext)) || + (oldValue !== oldValue && hasContext !== hasContext) + ? 0 + : ("function" === + typeof updateExpirationTime._calculateChangedBits + ? updateExpirationTime._calculateChangedBits( + oldValue, + hasContext + ) + : 1073741823) | 0; + if (0 === hasContext) { if ( - resolvedTag.children === props.children && + getDerivedStateFromProps.children === context.children && !didPerformWorkStackCursor.current ) { workInProgress = bailoutOnAlreadyFinishedWork( @@ -4143,113 +4281,129 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { } } else for ( - resolvedTag = workInProgress.child, - null !== resolvedTag && (resolvedTag.return = workInProgress); - null !== resolvedTag; + getDerivedStateFromProps = workInProgress.child, + null !== getDerivedStateFromProps && + (getDerivedStateFromProps.return = workInProgress); + null !== getDerivedStateFromProps; ) { - resolvedProps = resolvedTag.firstContextDependency; - if (null !== resolvedProps) { + oldValue = getDerivedStateFromProps.firstContextDependency; + if (null !== oldValue) { do { if ( - resolvedProps.context === Component && - 0 !== (resolvedProps.observedBits & updateExpirationTime) + oldValue.context === updateExpirationTime && + 0 !== (oldValue.observedBits & hasContext) ) { - 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 ( - 0 === node.childExpirationTime || - node.childExpirationTime > renderExpirationTime - ) + if (1 === getDerivedStateFromProps.tag) { + var nextFiber = createUpdate(renderExpirationTime); + nextFiber.tag = 2; + enqueueUpdate(getDerivedStateFromProps, nextFiber); + } + getDerivedStateFromProps.expirationTime < + renderExpirationTime && + (getDerivedStateFromProps.expirationTime = renderExpirationTime); + nextFiber = getDerivedStateFromProps.alternate; + null !== nextFiber && + nextFiber.expirationTime < renderExpirationTime && + (nextFiber.expirationTime = renderExpirationTime); + for ( + var node = getDerivedStateFromProps.return; + null !== node; + + ) { + nextFiber = node.alternate; + if (node.childExpirationTime < renderExpirationTime) (node.childExpirationTime = renderExpirationTime), - null !== child && - (0 === child.childExpirationTime || - child.childExpirationTime > - renderExpirationTime) && - (child.childExpirationTime = renderExpirationTime); + null !== nextFiber && + nextFiber.childExpirationTime < + renderExpirationTime && + (nextFiber.childExpirationTime = renderExpirationTime); else if ( - null !== child && - (0 === child.childExpirationTime || - child.childExpirationTime > renderExpirationTime) + null !== nextFiber && + nextFiber.childExpirationTime < renderExpirationTime ) - child.childExpirationTime = renderExpirationTime; + nextFiber.childExpirationTime = renderExpirationTime; else break; node = node.return; } } - child = resolvedTag.child; - resolvedProps = resolvedProps.next; - } while (null !== resolvedProps); + nextFiber = getDerivedStateFromProps.child; + oldValue = oldValue.next; + } while (null !== oldValue); } else - child = - 12 === resolvedTag.tag - ? resolvedTag.type === workInProgress.type + nextFiber = + 10 === getDerivedStateFromProps.tag + ? getDerivedStateFromProps.type === workInProgress.type ? null - : resolvedTag.child - : resolvedTag.child; - if (null !== child) child.return = resolvedTag; + : getDerivedStateFromProps.child + : getDerivedStateFromProps.child; + if (null !== nextFiber) + nextFiber.return = getDerivedStateFromProps; else - for (child = resolvedTag; null !== child; ) { - if (child === workInProgress) { - child = null; + for ( + nextFiber = getDerivedStateFromProps; + null !== nextFiber; + + ) { + if (nextFiber === workInProgress) { + nextFiber = null; break; } - resolvedTag = child.sibling; - if (null !== resolvedTag) { - resolvedTag.return = child.return; - child = resolvedTag; + getDerivedStateFromProps = nextFiber.sibling; + if (null !== getDerivedStateFromProps) { + getDerivedStateFromProps.return = nextFiber.return; + nextFiber = getDerivedStateFromProps; break; } - child = child.return; + nextFiber = nextFiber.return; } - resolvedTag = child; + getDerivedStateFromProps = nextFiber; } + } reconcileChildren( current$$1, workInProgress, - props.children, + context.children, renderExpirationTime ); workInProgress = workInProgress.child; } return workInProgress; - case 11: + case 9: return ( - (updateExpirationTime = workInProgress.type), - (Component = workInProgress.pendingProps), - (props = Component.children), + (context = workInProgress.type), + (hasContext = workInProgress.pendingProps), + (updateExpirationTime = hasContext.children), prepareToReadContext(workInProgress, renderExpirationTime), - (updateExpirationTime = readContext( - updateExpirationTime, - Component.unstable_observedBits - )), - (props = props(updateExpirationTime)), + (context = readContext(context, hasContext.unstable_observedBits)), + (updateExpirationTime = updateExpirationTime(context)), (workInProgress.effectTag |= 1), reconcileChildren( current$$1, workInProgress, - props, + updateExpirationTime, renderExpirationTime ), - (workInProgress.memoizedProps = Component), workInProgress.child ); - case 17: - return updatePureComponent( + case 14: + return ( + (context = workInProgress.type), + (hasContext = resolveDefaultProps( + context.type, + workInProgress.pendingProps + )), + updateMemoComponent( + current$$1, + workInProgress, + context, + hasContext, + updateExpirationTime, + renderExpirationTime + ) + ); + case 15: + return updateSimpleMemoComponent( current$$1, workInProgress, workInProgress.type, @@ -4257,20 +4411,43 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { updateExpirationTime, renderExpirationTime ); - case 18: + case 17: return ( - (props = workInProgress.type._reactResult), - (Component = workInProgress.pendingProps), - (current$$1 = updatePureComponent( - current$$1, + (updateExpirationTime = workInProgress.type), + (context = workInProgress.pendingProps), + (context = + workInProgress.elementType === updateExpirationTime + ? context + : resolveDefaultProps(updateExpirationTime, context)), + 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), + constructClassInstance( workInProgress, - props, - resolveDefaultProps(props, Component), updateExpirationTime, + context, renderExpirationTime - )), - (workInProgress.memoizedProps = Component), - current$$1 + ), + mountClassInstance( + workInProgress, + updateExpirationTime, + context, + renderExpirationTime + ), + finishClassComponent( + null, + workInProgress, + updateExpirationTime, + !0, + current$$1, + renderExpirationTime + ) ); default: invariant( @@ -4279,14 +4456,113 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { ); } } -function appendAllChildren(parent, workInProgress) { +var appendAllChildren = void 0, + updateHostContainer = void 0, + updateHostComponent$1 = void 0, + updateHostText$1 = void 0; +appendAllChildren = function( + parent, + workInProgress, + needsVisibilityToggle, + isHidden +) { + for (var node = workInProgress.child; null !== node; ) { + a: if (5 === node.tag) { + var instance = node.stateNode; + if (needsVisibilityToggle) { + var props = node.memoizedProps, + type = node.type; + instance = isHidden + ? cloneHiddenInstance(instance, type, props, node) + : cloneUnhiddenInstance(instance, type, props, node); + node.stateNode = instance; + } + FabricUIManager.appendChild(parent.node, instance.node); + } else if (6 === node.tag) { + instance = node.stateNode; + if (needsVisibilityToggle) { + instance = node.memoizedProps; + props = requiredContext(rootInstanceStackCursor.current); + type = requiredContext(contextStackCursor$1.current); + if (isHidden) throw Error("Not yet implemented."); + instance = createTextInstance(instance, props, type, workInProgress); + node.stateNode = instance; + } + FabricUIManager.appendChild(parent.node, instance.node); + } else if (4 !== node.tag) { + if ( + 13 === node.tag && + ((props = node.alternate), + null !== props && + ((instance = null !== node.memoizedState), + (null !== props.memoizedState) !== instance)) + ) { + props = instance ? node.child : node; + null !== props && appendAllChildren(parent, props, !0, instance); + 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; ) { - if (7 === node.tag || 8 === node.tag) - FabricUIManager.appendChild(parent.node, node.stateNode.node); - else if (6 !== node.tag && null !== node.child) { - node.child.return = node; - node = node.child; - continue; + a: if (5 === node.tag) { + var instance = node.stateNode; + if (needsVisibilityToggle) { + var props = node.memoizedProps, + type = node.type; + instance = isHidden + ? cloneHiddenInstance(instance, type, props, node) + : cloneUnhiddenInstance(instance, type, props, node); + node.stateNode = instance; + } + FabricUIManager.appendChildToSet(containerChildSet, instance.node); + } else if (6 === node.tag) { + instance = node.stateNode; + if (needsVisibilityToggle) { + instance = node.memoizedProps; + props = requiredContext(rootInstanceStackCursor.current); + type = requiredContext(contextStackCursor$1.current); + if (isHidden) throw Error("Not yet implemented."); + instance = createTextInstance(instance, props, type, workInProgress); + node.stateNode = instance; + } + FabricUIManager.appendChildToSet(containerChildSet, instance.node); + } else if (4 !== node.tag) { + if ( + 13 === node.tag && + ((props = node.alternate), + null !== props && + ((instance = null !== node.memoizedState), + (null !== props.memoizedState) !== instance)) + ) { + props = instance ? node.child : node; + null !== props && + appendAllChildrenToContainer(containerChildSet, props, !0, instance); + break a; + } + if (null !== node.child) { + node.child.return = node; + node = node.child; + continue; + } } if (node === workInProgress) break; for (; null === node.sibling; ) { @@ -4297,30 +4573,12 @@ function appendAllChildren(parent, workInProgress) { node = node.sibling; } } -var updateHostContainer = void 0, - updateHostComponent$1 = void 0, - updateHostText$1 = void 0; updateHostContainer = function(workInProgress) { var portalOrRoot = workInProgress.stateNode; if (null !== workInProgress.firstEffect) { var container = portalOrRoot.containerInfo, newChildSet = FabricUIManager.createChildSet(container); - a: for (var node = workInProgress.child; null !== node; ) { - if (7 === node.tag || 8 === node.tag) - FabricUIManager.appendChildToSet(newChildSet, node.stateNode.node); - else if (6 !== node.tag && null !== node.child) { - node.child.return = node; - node = node.child; - continue; - } - if (node === workInProgress) break a; - for (; null === node.sibling; ) { - if (null === node.return || node.return === workInProgress) break a; - node = node.return; - } - node.sibling.return = node.return; - node = node.sibling; - } + appendAllChildrenToContainer(newChildSet, workInProgress, !1, !1); portalOrRoot.pendingChildren = newChildSet; workInProgress.effectTag |= 4; FabricUIManager.completeRoot(container, newChildSet); @@ -4367,7 +4625,7 @@ updateHostComponent$1 = function(current, workInProgress, type, newProps) { (workInProgress.stateNode = type), current ? (workInProgress.effectTag |= 4) - : appendAllChildren(type, workInProgress)); + : appendAllChildren(type, workInProgress, !1, !1)); } }; updateHostText$1 = function(current, workInProgress, oldText, newText) { @@ -4401,7 +4659,6 @@ function logCapturedError(capturedError) { : Error("Unspecified error at:" + componentStack); ExceptionsManager.handleException(error, !1); } -var emptyObject$1 = {}; function logError(boundary, errorInfo) { var source = errorInfo.source, stack = errorInfo.stack; @@ -4418,7 +4675,7 @@ function logError(boundary, errorInfo) { willRetry: !1 }; null !== boundary && - 2 === boundary.tag && + 1 === boundary.tag && ((errorInfo.errorBoundary = boundary.stateNode), (errorInfo.errorBoundaryName = getComponentName(boundary.type)), (errorInfo.errorBoundaryFound = !0), @@ -4444,16 +4701,22 @@ function safelyDetachRef(current$$1) { } function commitWork(current$$1, finishedWork) { switch (finishedWork.tag) { - case 2: - case 3: - break; - case 7: - break; - case 8: + case 0: + case 11: + case 14: + case 15: + return; + } + switch (finishedWork.tag) { + case 1: break; case 5: + break; case 6: break; + case 3: + case 4: + break; default: invariant( !1, @@ -4461,9 +4724,6 @@ function commitWork(current$$1, finishedWork) { ); } } -function NoopComponent() { - return null; -} function createRootErrorUpdate(fiber, errorInfo, expirationTime) { expirationTime = createUpdate(expirationTime); expirationTime.tag = 3; @@ -4504,24 +4764,14 @@ function createClassErrorUpdate(fiber, errorInfo, expirationTime) { } function unwindWork(workInProgress) { switch (workInProgress.tag) { - case 2: + case 1: isContextProvider(workInProgress.type) && popContext(workInProgress); var effectTag = workInProgress.effectTag; - return effectTag & 1024 - ? ((workInProgress.effectTag = (effectTag & -1025) | 64), + return effectTag & 2048 + ? ((workInProgress.effectTag = (effectTag & -2049) | 64), workInProgress) : null; case 3: - return ( - isContextProvider(workInProgress.type._reactResult) && - popContext(workInProgress), - (effectTag = workInProgress.effectTag), - effectTag & 1024 - ? ((workInProgress.effectTag = (effectTag & -1025) | 64), - workInProgress) - : null - ); - case 5: return ( popHostContainer(workInProgress), popTopLevelContextObject(workInProgress), @@ -4530,28 +4780,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 & -1025) | 64), + (workInProgress.effectTag = (effectTag & -2049) | 64), workInProgress ); - case 7: + case 5: return popHostContext(workInProgress), null; - case 16: + case 13: return ( (effectTag = workInProgress.effectTag), - effectTag & 1024 - ? ((workInProgress.effectTag = (effectTag & -1025) | 64), + effectTag & 2048 + ? ((workInProgress.effectTag = (effectTag & -2049) | 64), workInProgress) : null ); - case 6: + case 4: return popHostContainer(workInProgress), null; - case 12: + case 10: return popProvider(workInProgress), null; default: return null; } } -var Dispatcher = { readContext: readContext }, +var DispatcherWithoutHooks = { readContext: readContext }, ReactCurrentOwner$2 = ReactSharedInternals.ReactCurrentOwner, isWorking = !1, nextUnitOfWork = null, @@ -4561,6 +4811,8 @@ var Dispatcher = { readContext: readContext }, nextRenderDidError = !1, nextEffect = null, isCommitting$1 = !1, + passiveEffectCallbackHandle = null, + passiveEffectCallback = null, legacyErrorBoundariesThatAlreadyFailed = null; function resetStack() { if (null !== nextUnitOfWork) @@ -4571,7 +4823,7 @@ function resetStack() { ) { var interruptedWork$jscomp$0 = interruptedWork; switch (interruptedWork$jscomp$0.tag) { - case 2: + case 1: var childContextTypes = interruptedWork$jscomp$0.type.childContextTypes; null !== childContextTypes && @@ -4579,23 +4831,16 @@ function resetStack() { popContext(interruptedWork$jscomp$0); break; case 3: - childContextTypes = - interruptedWork$jscomp$0.type._reactResult.childContextTypes; - null !== childContextTypes && - void 0 !== childContextTypes && - popContext(interruptedWork$jscomp$0); - break; - case 5: popHostContainer(interruptedWork$jscomp$0); popTopLevelContextObject(interruptedWork$jscomp$0); break; - case 7: + case 5: popHostContext(interruptedWork$jscomp$0); break; - case 6: + case 4: popHostContainer(interruptedWork$jscomp$0); break; - case 12: + case 10: popProvider(interruptedWork$jscomp$0); } interruptedWork = interruptedWork.return; @@ -4606,174 +4851,198 @@ function resetStack() { nextRenderDidError = !1; nextUnitOfWork = null; } +function flushPassiveEffects() { + null !== passiveEffectCallback && + (scheduler.unstable_cancelCallback(passiveEffectCallbackHandle), + passiveEffectCallback()); +} function completeUnitOfWork(workInProgress) { for (;;) { var current$$1 = workInProgress.alternate, returnFiber = workInProgress.return, siblingFiber = workInProgress.sibling; - if (0 === (workInProgress.effectTag & 512)) { - var current = current$$1; - current$$1 = workInProgress; - var instance = current$$1.pendingProps; - switch (current$$1.tag) { - case 0: - 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; - instance.pendingContext && - ((instance.context = instance.pendingContext), - (instance.pendingContext = null)); - if (null === current || null === current.child) - current$$1.effectTag &= -3; - updateHostContainer(current$$1); - break; - case 7: - popHostContext(current$$1); - var rootContainerInstance = requiredContext( + if (0 === (workInProgress.effectTag & 1024)) { + nextUnitOfWork = workInProgress; + a: { + var current = current$$1; + current$$1 = workInProgress; + var renderExpirationTime = nextRenderExpirationTime; + var instance = current$$1.pendingProps; + switch (current$$1.tag) { + case 2: + break; + case 16: + break; + case 15: + case 0: + break; + case 1: + isContextProvider(current$$1.type) && popContext(current$$1); + break; + case 3: + popHostContainer(current$$1); + popTopLevelContextObject(current$$1); + instance = current$$1.stateNode; + instance.pendingContext && + ((instance.context = instance.pendingContext), + (instance.pendingContext = null)); + if (null === current || null === current.child) + current$$1.effectTag &= -3; + updateHostContainer(current$$1); + break; + case 5: + popHostContext(current$$1); + renderExpirationTime = requiredContext( rootInstanceStackCursor.current - ), - type = current$$1.type; - if (null !== current && null != current$$1.stateNode) - updateHostComponent$1( - current, - current$$1, - type, - instance, - rootContainerInstance - ), - current.ref !== current$$1.ref && (current$$1.effectTag |= 128); - else if (instance) { - var currentHostContext = requiredContext( - contextStackCursor$1.current - ), - internalInstanceHandle = current$$1; - current = nextReactTag; - nextReactTag += 2; - var viewConfig = ReactNativeViewConfigRegistry.get(type); - invariant( - "RCTView" !== type || !currentHostContext.isInAParentText, - "Nesting of within is not currently supported." - ); - type = diffProperties( - null, - emptyObject, - instance, - viewConfig.validAttributes ); - rootContainerInstance = FabricUIManager.createNode( - current, - viewConfig.uiViewClassName, - rootContainerInstance, - type, - internalInstanceHandle - ); - instance = new ReactFabricHostComponent( - current, - viewConfig, - instance - ); - instance = { node: rootContainerInstance, canonical: instance }; - appendAllChildren(instance, current$$1); - current$$1.stateNode = instance; - null !== current$$1.ref && (current$$1.effectTag |= 128); - } else - invariant( - null !== current$$1.stateNode, - "We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue." - ); - break; - case 8: - current && null != current$$1.stateNode - ? updateHostText$1( + var type = current$$1.type; + if (null !== current && null != current$$1.stateNode) + updateHostComponent$1( current, current$$1, - current.memoizedProps, - instance - ) - : ("string" !== typeof instance && - invariant( - null !== current$$1.stateNode, - "We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue." + type, + instance, + renderExpirationTime + ), + current.ref !== current$$1.ref && (current$$1.effectTag |= 128); + else if (instance) { + var currentHostContext = requiredContext( + contextStackCursor$1.current ), - (rootContainerInstance = requiredContext( - rootInstanceStackCursor.current - )), - (current = requiredContext(contextStackCursor$1.current)), - (current$$1.stateNode = createTextInstance( + internalInstanceHandle = current$$1; + current = nextReactTag; + nextReactTag += 2; + var viewConfig = ReactNativeViewConfigRegistry.get(type); + invariant( + "RCTView" !== type || !currentHostContext.isInAParentText, + "Nesting of within is not currently supported." + ); + type = diffProperties( + null, + emptyObject, instance, - rootContainerInstance, + viewConfig.validAttributes + ); + renderExpirationTime = FabricUIManager.createNode( current, - current$$1 - ))); - break; - case 13: - case 14: - break; - case 16: - break; - case 9: - break; - 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: - 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, - "Unknown unit of work tag. This error is likely caused by a bug in React. Please file an issue." - ); + viewConfig.uiViewClassName, + renderExpirationTime, + type, + internalInstanceHandle + ); + instance = new ReactFabricHostComponent( + current, + viewConfig, + instance + ); + instance = { node: renderExpirationTime, canonical: instance }; + appendAllChildren(instance, current$$1, !1, !1); + current$$1.stateNode = instance; + null !== current$$1.ref && (current$$1.effectTag |= 128); + } else + invariant( + null !== current$$1.stateNode, + "We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue." + ); + break; + case 6: + current && null != current$$1.stateNode + ? updateHostText$1( + current, + current$$1, + current.memoizedProps, + instance + ) + : ("string" !== typeof instance && + invariant( + null !== current$$1.stateNode, + "We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue." + ), + (current = requiredContext(rootInstanceStackCursor.current)), + (renderExpirationTime = requiredContext( + contextStackCursor$1.current + )), + (current$$1.stateNode = createTextInstance( + instance, + current, + renderExpirationTime, + current$$1 + ))); + break; + case 11: + break; + case 13: + instance = current$$1.memoizedState; + if (0 !== (current$$1.effectTag & 64)) { + current$$1.expirationTime = renderExpirationTime; + nextUnitOfWork = current$$1; + break a; + } + instance = null !== instance; + viewConfig = null !== current && null !== current.memoizedState; + null !== current && + !instance && + viewConfig && + ((current = current.child.sibling), + null !== current && + reconcileChildFibers( + current$$1, + current, + null, + renderExpirationTime + )); + if ( + instance !== viewConfig || + (0 === (current$$1.effectTag & 1) && instance) + ) + current$$1.effectTag |= 4; + break; + case 7: + break; + case 8: + break; + case 12: + break; + case 4: + popHostContainer(current$$1); + updateHostContainer(current$$1); + break; + case 10: + popProvider(current$$1); + break; + case 9: + break; + case 14: + break; + case 17: + isContextProvider(current$$1.type) && popContext(current$$1); + break; + default: + invariant( + !1, + "Unknown unit of work tag. This error is likely caused by a bug in React. Please file an issue." + ); + } + nextUnitOfWork = null; } - nextUnitOfWork = null; current$$1 = workInProgress; if ( - 1073741823 === nextRenderExpirationTime || - 1073741823 !== current$$1.childExpirationTime + 1 === nextRenderExpirationTime || + 1 !== current$$1.childExpirationTime ) { instance = 0; - for ( - rootContainerInstance = current$$1.child; - null !== rootContainerInstance; - - ) { - current = rootContainerInstance.expirationTime; - viewConfig = rootContainerInstance.childExpirationTime; - if (0 === instance || (0 !== current && current < instance)) - instance = current; - if (0 === instance || (0 !== viewConfig && viewConfig < instance)) - instance = viewConfig; - rootContainerInstance = rootContainerInstance.sibling; - } + for (current = current$$1.child; null !== current; ) + (renderExpirationTime = current.expirationTime), + (viewConfig = current.childExpirationTime), + renderExpirationTime > instance && + (instance = renderExpirationTime), + viewConfig > instance && (instance = viewConfig), + (current = current.sibling); current$$1.childExpirationTime = instance; } + if (null !== nextUnitOfWork) return nextUnitOfWork; null !== returnFiber && - 0 === (returnFiber.effectTag & 512) && + 0 === (returnFiber.effectTag & 1024) && (null === returnFiber.firstEffect && (returnFiber.firstEffect = workInProgress.firstEffect), null !== workInProgress.lastEffect && @@ -4788,10 +5057,10 @@ function completeUnitOfWork(workInProgress) { } else { workInProgress = unwindWork(workInProgress, nextRenderExpirationTime); if (null !== workInProgress) - return (workInProgress.effectTag &= 511), workInProgress; + return (workInProgress.effectTag &= 1023), workInProgress; null !== returnFiber && ((returnFiber.firstEffect = returnFiber.lastEffect = null), - (returnFiber.effectTag |= 512)); + (returnFiber.effectTag |= 1024)); } if (null !== siblingFiber) return siblingFiber; if (null !== returnFiber) workInProgress = returnFiber; @@ -4805,17 +5074,19 @@ function performUnitOfWork(workInProgress) { workInProgress, nextRenderExpirationTime ); + workInProgress.memoizedProps = workInProgress.pendingProps; null === next && (next = completeUnitOfWork(workInProgress)); ReactCurrentOwner$2.current = null; return next; } -function renderRoot(root$jscomp$0, isYieldy, isExpired) { +function renderRoot(root$jscomp$0, isYieldy) { invariant( !isWorking, "renderRoot was called recursively. This error is likely caused by a bug in React. Please file an issue." ); + flushPassiveEffects(); isWorking = !0; - ReactCurrentOwner$2.currentDispatcher = Dispatcher; + ReactCurrentOwner$2.currentDispatcher = DispatcherWithoutHooks; var expirationTime = root$jscomp$0.nextExpirationTimeToWorkOn; if ( expirationTime !== nextRenderExpirationTime || @@ -4835,13 +5106,16 @@ function renderRoot(root$jscomp$0, isYieldy, isExpired) { do { try { if (isYieldy) - for (; null !== nextUnitOfWork && !shouldYield(); ) + for (; null !== nextUnitOfWork && !shouldYieldToRenderer(); ) nextUnitOfWork = performUnitOfWork(nextUnitOfWork); else for (; null !== nextUnitOfWork; ) nextUnitOfWork = performUnitOfWork(nextUnitOfWork); } catch (thrownValue) { - if (null === nextUnitOfWork) + if ( + ((lastContextWithAllBitsObserved = lastContextDependency = currentlyRenderingFiber = null), + null === nextUnitOfWork) + ) (didFatal = !0), onUncaughtError(thrownValue); else { invariant( @@ -4858,7 +5132,7 @@ function renderRoot(root$jscomp$0, isYieldy, isExpired) { sourceFiber$jscomp$0 = sourceFiber, value = thrownValue; returnFiber = nextRenderExpirationTime; - sourceFiber$jscomp$0.effectTag |= 512; + sourceFiber$jscomp$0.effectTag |= 1024; sourceFiber$jscomp$0.firstEffect = sourceFiber$jscomp$0.lastEffect = null; if ( null !== value && @@ -4870,56 +5144,57 @@ function renderRoot(root$jscomp$0, isYieldy, isExpired) { var earliestTimeoutMs = -1, startTimeMs = -1; do { - if (16 === value.tag) { - var current = value.alternate; + if (13 === value.tag) { + var current$$1 = value.alternate; if ( - null !== current && - !0 === current.memoizedState && - null !== current.stateNode + null !== current$$1 && + ((current$$1 = current$$1.memoizedState), + null !== current$$1) ) { - startTimeMs = 10 * (current.stateNode.timedOutAt - 2); + startTimeMs = 10 * (1073741822 - current$$1.timedOutAt); break; } - current = value.pendingProps.maxDuration; - if ("number" === typeof current) - if (0 >= current) earliestTimeoutMs = 0; + current$$1 = value.pendingProps.maxDuration; + if ("number" === typeof current$$1) + if (0 >= current$$1) earliestTimeoutMs = 0; else if ( -1 === earliestTimeoutMs || - current < earliestTimeoutMs + current$$1 < earliestTimeoutMs ) - earliestTimeoutMs = current; + earliestTimeoutMs = current$$1; } value = value.return; } while (null !== value); value = returnFiber$jscomp$0; do { - if (16 === value.tag && !value.memoizedState) { + if ((current$$1 = 13 === value.tag)) + current$$1 = + void 0 === value.memoizedProps.fallback + ? !1 + : null === value.memoizedState; + if (current$$1) { returnFiber$jscomp$0 = retrySuspendedRoot.bind( null, root, value, - 0 === (value.mode & 1) ? 1 : returnFiber + sourceFiber$jscomp$0, + 0 === (value.mode & 1) ? 1073741823 : returnFiber ); thenable.then(returnFiber$jscomp$0, returnFiber$jscomp$0); - if (0 === (value.mode & 2)) { - value.effectTag |= 4; + if (0 === (value.mode & 1)) { + value.effectTag |= 64; reconcileChildren( sourceFiber$jscomp$0.alternate, sourceFiber$jscomp$0, null, returnFiber ); - sourceFiber$jscomp$0.effectTag &= -513; - 4 === sourceFiber$jscomp$0.tag && - (sourceFiber$jscomp$0.tag = 0); - if ( - 2 === sourceFiber$jscomp$0.tag || - 3 === sourceFiber$jscomp$0.tag - ) - (sourceFiber$jscomp$0.effectTag &= -421), - null === sourceFiber$jscomp$0.alternate && - ((sourceFiber$jscomp$0.tag = 0), - (sourceFiber$jscomp$0.type = NoopComponent)); + sourceFiber$jscomp$0.effectTag &= -1025; + sourceFiber$jscomp$0.effectTag &= -933; + 1 === sourceFiber$jscomp$0.tag && + null === sourceFiber$jscomp$0.alternate && + (sourceFiber$jscomp$0.tag = 17); + sourceFiber$jscomp$0.expirationTime = returnFiber; break a; } -1 === earliestTimeoutMs @@ -4927,24 +5202,27 @@ function renderRoot(root$jscomp$0, isYieldy, isExpired) { : (-1 === startTimeMs && (startTimeMs = 10 * - (findEarliestOutstandingPriorityLevel( - root, - returnFiber - ) - - 2) - + (1073741822 - + findEarliestOutstandingPriorityLevel( + root, + returnFiber + )) - 5e3), (root = startTimeMs + earliestTimeoutMs)); 0 <= root && nextLatestAbsoluteTimeoutMs < root && (nextLatestAbsoluteTimeoutMs = root); - value.effectTag |= 1024; + value.effectTag |= 2048; value.expirationTime = returnFiber; break a; } value = value.return; } while (null !== value); value = Error( - "An update was suspended, but no placeholder UI was provided." + (getComponentName(sourceFiber$jscomp$0.type) || + "A React component") + + " suspended while rendering, but no fallback UI was specified.\n\nAdd a component higher in the tree to provide a loading indicator or placeholder to display." + + getStackByFiberInDevAndProd(sourceFiber$jscomp$0) ); } nextRenderDidError = !0; @@ -4952,9 +5230,9 @@ function renderRoot(root$jscomp$0, isYieldy, isExpired) { root = returnFiber$jscomp$0; do { switch (root.tag) { - case 5: + case 3: sourceFiber$jscomp$0 = value; - root.effectTag |= 1024; + root.effectTag |= 2048; root.expirationTime = returnFiber; returnFiber = createRootErrorUpdate( root, @@ -4963,8 +5241,7 @@ function renderRoot(root$jscomp$0, isYieldy, isExpired) { ); enqueueCapturedUpdate(root, returnFiber); break a; - case 2: - case 3: + case 1: if ( ((sourceFiber$jscomp$0 = value), (returnFiber$jscomp$0 = root.type), @@ -4979,7 +5256,7 @@ function renderRoot(root$jscomp$0, isYieldy, isExpired) { thenable ))))) ) { - root.effectTag |= 1024; + root.effectTag |= 2048; root.expirationTime = returnFiber; returnFiber = createClassErrorUpdate( root, @@ -5005,180 +5282,166 @@ function renderRoot(root$jscomp$0, isYieldy, isExpired) { if (didFatal) (nextRoot = null), (root$jscomp$0.finishedWork = null); else if (null !== nextUnitOfWork) root$jscomp$0.finishedWork = null; else { - isYieldy = root$jscomp$0.current.alternate; + didFatal = root$jscomp$0.current.alternate; invariant( - null !== isYieldy, + null !== didFatal, "Finished root should have a work-in-progress. This error is likely caused by a bug in React. Please file an issue." ); nextRoot = null; if (nextRenderDidError) { - didFatal = root$jscomp$0.latestPendingTime; - sourceFiber = root$jscomp$0.latestSuspendedTime; - returnFiber = root$jscomp$0.latestPingedTime; + sourceFiber = root$jscomp$0.latestPendingTime; + returnFiber = root$jscomp$0.latestSuspendedTime; + root = root$jscomp$0.latestPingedTime; if ( - (0 !== didFatal && didFatal > expirationTime) || - (0 !== sourceFiber && sourceFiber > expirationTime) || - (0 !== returnFiber && returnFiber > expirationTime) + (0 !== sourceFiber && sourceFiber < expirationTime) || + (0 !== returnFiber && returnFiber < expirationTime) || + (0 !== root && root < expirationTime) ) { markSuspendedPriorityLevel(root$jscomp$0, expirationTime); onSuspend( root$jscomp$0, - isYieldy, + didFatal, expirationTime, root$jscomp$0.expirationTime, -1 ); return; } - if (!root$jscomp$0.didError && !isExpired) { + if (!root$jscomp$0.didError && isYieldy) { root$jscomp$0.didError = !0; expirationTime = root$jscomp$0.nextExpirationTimeToWorkOn = expirationTime; - isExpired = root$jscomp$0.expirationTime = 1; - onSuspend(root$jscomp$0, isYieldy, expirationTime, isExpired, -1); + isYieldy = root$jscomp$0.expirationTime = 1073741823; + onSuspend(root$jscomp$0, didFatal, expirationTime, isYieldy, -1); return; } } - isExpired || -1 === nextLatestAbsoluteTimeoutMs - ? ((root$jscomp$0.pendingCommitExpirationTime = expirationTime), - (root$jscomp$0.finishedWork = isYieldy)) - : (markSuspendedPriorityLevel(root$jscomp$0, expirationTime), - (isExpired = + isYieldy && -1 !== nextLatestAbsoluteTimeoutMs + ? (markSuspendedPriorityLevel(root$jscomp$0, expirationTime), + (isYieldy = 10 * - (findEarliestOutstandingPriorityLevel(root$jscomp$0, expirationTime) - - 2)), - isExpired < nextLatestAbsoluteTimeoutMs && - (nextLatestAbsoluteTimeoutMs = isExpired), - (isExpired = 10 * (requestCurrentTime() - 2)), - (isExpired = nextLatestAbsoluteTimeoutMs - isExpired), + (1073741822 - + findEarliestOutstandingPriorityLevel( + root$jscomp$0, + expirationTime + ))), + isYieldy < nextLatestAbsoluteTimeoutMs && + (nextLatestAbsoluteTimeoutMs = isYieldy), + (isYieldy = 10 * (1073741822 - requestCurrentTime())), + (isYieldy = nextLatestAbsoluteTimeoutMs - isYieldy), onSuspend( root$jscomp$0, - isYieldy, + didFatal, expirationTime, root$jscomp$0.expirationTime, - 0 > isExpired ? 0 : isExpired - )); + 0 > isYieldy ? 0 : isYieldy + )) + : ((root$jscomp$0.pendingCommitExpirationTime = expirationTime), + (root$jscomp$0.finishedWork = didFatal)); } } -function captureCommitPhaseError(fiber, error) { - var JSCompiler_inline_result; - a: { - invariant( - !isWorking || isCommitting$1, - "dispatch: Cannot dispatch during the render phase." - ); - for ( - JSCompiler_inline_result = fiber.return; - null !== JSCompiler_inline_result; - - ) { - switch (JSCompiler_inline_result.tag) { - case 2: - case 3: - var instance = JSCompiler_inline_result.stateNode; - if ( - "function" === - typeof JSCompiler_inline_result.type.getDerivedStateFromError || - ("function" === typeof instance.componentDidCatch && - (null === legacyErrorBoundariesThatAlreadyFailed || - !legacyErrorBoundariesThatAlreadyFailed.has(instance))) - ) { - fiber = createCapturedValue(error, fiber); - fiber = createClassErrorUpdate(JSCompiler_inline_result, fiber, 1); - enqueueUpdate(JSCompiler_inline_result, fiber); - scheduleWork(JSCompiler_inline_result, 1); - JSCompiler_inline_result = void 0; - break a; - } - break; - case 5: - fiber = createCapturedValue(error, fiber); - fiber = createRootErrorUpdate(JSCompiler_inline_result, fiber, 1); - enqueueUpdate(JSCompiler_inline_result, fiber); - scheduleWork(JSCompiler_inline_result, 1); - JSCompiler_inline_result = void 0; - break a; - } - JSCompiler_inline_result = JSCompiler_inline_result.return; +function captureCommitPhaseError(sourceFiber, value) { + for (var fiber = sourceFiber.return; null !== fiber; ) { + switch (fiber.tag) { + case 1: + var instance = fiber.stateNode; + if ( + "function" === typeof fiber.type.getDerivedStateFromError || + ("function" === typeof instance.componentDidCatch && + (null === legacyErrorBoundariesThatAlreadyFailed || + !legacyErrorBoundariesThatAlreadyFailed.has(instance))) + ) { + sourceFiber = createCapturedValue(value, sourceFiber); + sourceFiber = createClassErrorUpdate(fiber, sourceFiber, 1073741823); + enqueueUpdate(fiber, sourceFiber); + scheduleWork(fiber, 1073741823); + return; + } + break; + case 3: + sourceFiber = createCapturedValue(value, sourceFiber); + sourceFiber = createRootErrorUpdate(fiber, sourceFiber, 1073741823); + enqueueUpdate(fiber, sourceFiber); + scheduleWork(fiber, 1073741823); + return; } - 5 === fiber.tag && - ((JSCompiler_inline_result = createCapturedValue(error, fiber)), - (JSCompiler_inline_result = createRootErrorUpdate( - fiber, - JSCompiler_inline_result, - 1 - )), - enqueueUpdate(fiber, JSCompiler_inline_result), - scheduleWork(fiber, 1)); - JSCompiler_inline_result = void 0; + fiber = fiber.return; } - return JSCompiler_inline_result; + 3 === sourceFiber.tag && + ((fiber = createCapturedValue(value, sourceFiber)), + (fiber = createRootErrorUpdate(sourceFiber, fiber, 1073741823)), + enqueueUpdate(sourceFiber, fiber), + scheduleWork(sourceFiber, 1073741823)); } function computeExpirationForFiber(currentTime, fiber) { isWorking - ? (currentTime = isCommitting$1 ? 1 : nextRenderExpirationTime) + ? (currentTime = isCommitting$1 ? 1073741823 : nextRenderExpirationTime) : fiber.mode & 1 ? ((currentTime = isBatchingInteractiveUpdates - ? 2 + 10 * ((((currentTime - 2 + 15) / 10) | 0) + 1) - : 2 + 25 * ((((currentTime - 2 + 500) / 25) | 0) + 1)), + ? 1073741822 - 10 * ((((1073741822 - currentTime + 15) / 10) | 0) + 1) + : 1073741822 - + 25 * ((((1073741822 - currentTime + 500) / 25) | 0) + 1)), null !== nextRoot && currentTime === nextRenderExpirationTime && - (currentTime += 1)) - : (currentTime = 1); + --currentTime) + : (currentTime = 1073741823); isBatchingInteractiveUpdates && - currentTime > lowestPriorityPendingInteractiveExpirationTime && + (0 === lowestPriorityPendingInteractiveExpirationTime || + currentTime < lowestPriorityPendingInteractiveExpirationTime) && (lowestPriorityPendingInteractiveExpirationTime = currentTime); return currentTime; } -function retrySuspendedRoot(root, fiber, suspendedTime) { +function retrySuspendedRoot(root, boundaryFiber, sourceFiber, suspendedTime) { var retryTime = root.earliestSuspendedTime; var latestSuspendedTime = root.latestSuspendedTime; if ( 0 !== retryTime && - suspendedTime >= retryTime && - suspendedTime <= latestSuspendedTime + suspendedTime <= retryTime && + suspendedTime >= latestSuspendedTime ) { latestSuspendedTime = retryTime = suspendedTime; root.didError = !1; var latestPingedTime = root.latestPingedTime; - if (0 === latestPingedTime || latestPingedTime < latestSuspendedTime) + if (0 === latestPingedTime || latestPingedTime > latestSuspendedTime) root.latestPingedTime = latestSuspendedTime; findNextExpirationTimeToWorkOn(latestSuspendedTime, root); } else (retryTime = requestCurrentTime()), - (retryTime = computeExpirationForFiber(retryTime, fiber)), + (retryTime = computeExpirationForFiber(retryTime, boundaryFiber)), markPendingPriorityLevel(root, retryTime); - 0 !== (fiber.mode & 1) && + 0 !== (boundaryFiber.mode & 1) && root === nextRoot && nextRenderExpirationTime === suspendedTime && (nextRoot = null); - scheduleWorkToRoot(fiber, retryTime); - fiber = root.expirationTime; - 0 !== fiber && requestWork(root, fiber); + scheduleWorkToRoot(boundaryFiber, retryTime); + 0 === (boundaryFiber.mode & 1) && + (scheduleWorkToRoot(sourceFiber, retryTime), + 1 === sourceFiber.tag && + null !== sourceFiber.stateNode && + ((boundaryFiber = createUpdate(retryTime)), + (boundaryFiber.tag = 2), + enqueueUpdate(sourceFiber, boundaryFiber))); + sourceFiber = root.expirationTime; + 0 !== sourceFiber && requestWork(root, sourceFiber); } function scheduleWorkToRoot(fiber, expirationTime) { - if (0 === fiber.expirationTime || fiber.expirationTime > expirationTime) - fiber.expirationTime = expirationTime; + fiber.expirationTime < expirationTime && + (fiber.expirationTime = expirationTime); var alternate = fiber.alternate; null !== alternate && - (0 === alternate.expirationTime || - alternate.expirationTime > expirationTime) && + alternate.expirationTime < expirationTime && (alternate.expirationTime = expirationTime); var node = fiber.return, root = null; - if (null === node && 5 === fiber.tag) root = fiber.stateNode; + if (null === node && 3 === fiber.tag) root = fiber.stateNode; else for (; null !== node; ) { alternate = node.alternate; - if ( - 0 === node.childExpirationTime || - node.childExpirationTime > expirationTime - ) - node.childExpirationTime = expirationTime; + node.childExpirationTime < expirationTime && + (node.childExpirationTime = expirationTime); null !== alternate && - (0 === alternate.childExpirationTime || - alternate.childExpirationTime > expirationTime) && + alternate.childExpirationTime < expirationTime && (alternate.childExpirationTime = expirationTime); - if (null === node.return && 5 === node.tag) { + if (null === node.return && 3 === node.tag) { root = node.stateNode; break; } @@ -5191,7 +5454,7 @@ function scheduleWork(fiber, expirationTime) { null !== fiber && (!isWorking && 0 !== nextRenderExpirationTime && - expirationTime < nextRenderExpirationTime && + expirationTime > nextRenderExpirationTime && resetStack(), markPendingPriorityLevel(fiber, expirationTime), (isWorking && !isCommitting$1 && nextRoot === fiber) || @@ -5211,27 +5474,25 @@ var firstScheduledRoot = null, nextFlushedRoot = null, nextFlushedExpirationTime = 0, lowestPriorityPendingInteractiveExpirationTime = 0, - deadlineDidExpire = !1, hasUnhandledError = !1, unhandledError = null, - deadline = null, isBatchingUpdates = !1, isUnbatchingUpdates = !1, isBatchingInteractiveUpdates = !1, completedBatches = null, originalStartTimeMs = now$1(), - currentRendererTime = ((originalStartTimeMs / 10) | 0) + 2, + currentRendererTime = 1073741822 - ((originalStartTimeMs / 10) | 0), currentSchedulerTime = currentRendererTime, NESTED_UPDATE_LIMIT = 50, nestedUpdateCount = 0, - lastCommittedRootDuringThisBatch = null, - timeHeuristicForUnitOfWork = 1; + lastCommittedRootDuringThisBatch = null; function recomputeCurrentRendererTime() { - currentRendererTime = (((now$1() - originalStartTimeMs) / 10) | 0) + 2; + currentRendererTime = + 1073741822 - (((now$1() - originalStartTimeMs) / 10) | 0); } function scheduleCallbackWithExpirationTime(root, expirationTime) { if (0 !== callbackExpirationTime) { - if (expirationTime > callbackExpirationTime) return; + if (expirationTime < callbackExpirationTime) return; null !== callbackID && ((root = callbackID), (scheduledCallback = null), clearTimeout(root)); } @@ -5248,7 +5509,7 @@ function onSuspend( msUntilTimeout ) { root.expirationTime = rootExpirationTime; - 0 !== msUntilTimeout || shouldYield() + 0 !== msUntilTimeout || shouldYieldToRenderer() ? 0 < msUntilTimeout && (root.timeoutHandle = scheduleTimeout( onTimeout.bind(null, root, finishedWork, suspendedExpirationTime), @@ -5268,44 +5529,35 @@ function onTimeout(root, finishedWork, suspendedExpirationTime) { ); nextFlushedRoot = root; nextFlushedExpirationTime = suspendedExpirationTime; - performWorkOnRoot(root, suspendedExpirationTime, !0); - performWork(1, null); + performWorkOnRoot(root, suspendedExpirationTime, !1); + performWork(1073741823, !1); } function requestCurrentTime() { if (isRendering) return currentSchedulerTime; findHighestPriorityRoot(); - if ( - 0 === nextFlushedExpirationTime || - 1073741823 === nextFlushedExpirationTime - ) + if (0 === nextFlushedExpirationTime || 1 === nextFlushedExpirationTime) recomputeCurrentRendererTime(), (currentSchedulerTime = currentRendererTime); return currentSchedulerTime; } function requestWork(root, expirationTime) { - if (null === root.nextScheduledRoot) - (root.expirationTime = expirationTime), + null === root.nextScheduledRoot + ? ((root.expirationTime = expirationTime), null === lastScheduledRoot ? ((firstScheduledRoot = lastScheduledRoot = root), (root.nextScheduledRoot = root)) : ((lastScheduledRoot = lastScheduledRoot.nextScheduledRoot = root), - (lastScheduledRoot.nextScheduledRoot = firstScheduledRoot)); - else { - var remainingExpirationTime = root.expirationTime; - if ( - 0 === remainingExpirationTime || - expirationTime < remainingExpirationTime - ) - root.expirationTime = expirationTime; - } + (lastScheduledRoot.nextScheduledRoot = firstScheduledRoot))) + : expirationTime > root.expirationTime && + (root.expirationTime = expirationTime); isRendering || (isBatchingUpdates ? isUnbatchingUpdates && ((nextFlushedRoot = root), - (nextFlushedExpirationTime = 1), - performWorkOnRoot(root, 1, !0)) - : 1 === expirationTime - ? performWork(1, null) + (nextFlushedExpirationTime = 1073741823), + performWorkOnRoot(root, 1073741823, !1)) + : 1073741823 === expirationTime + ? performWork(1073741823, !1) : scheduleCallbackWithExpirationTime(root, expirationTime)); } function findHighestPriorityRoot() { @@ -5341,14 +5593,11 @@ function findHighestPriorityRoot() { (root.nextScheduledRoot = null); root = previousScheduledRoot.nextScheduledRoot; } else { - if ( - 0 === highestPriorityWork || - remainingExpirationTime < highestPriorityWork - ) - (highestPriorityWork = remainingExpirationTime), - (highestPriorityRoot = root); + remainingExpirationTime > highestPriorityWork && + ((highestPriorityWork = remainingExpirationTime), + (highestPriorityRoot = root)); if (root === lastScheduledRoot) break; - if (1 === highestPriorityWork) break; + if (1073741823 === highestPriorityWork) break; previousScheduledRoot = root; root = root.nextScheduledRoot; } @@ -5356,38 +5605,44 @@ function findHighestPriorityRoot() { nextFlushedRoot = highestPriorityRoot; nextFlushedExpirationTime = highestPriorityWork; } -function performAsyncWork(dl) { - if (dl.didTimeout && null !== firstScheduledRoot) { - recomputeCurrentRendererTime(); - var root = firstScheduledRoot; - do { - var expirationTime = root.expirationTime; - 0 !== expirationTime && - currentRendererTime >= expirationTime && - (root.nextExpirationTimeToWorkOn = currentRendererTime); - root = root.nextScheduledRoot; - } while (root !== firstScheduledRoot); +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; } - performWork(0, dl); } -function performWork(minExpirationTime, dl) { - deadline = dl; +function performWork(minExpirationTime, isYieldy) { findHighestPriorityRoot(); - if (null !== deadline) + if (isYieldy) for ( recomputeCurrentRendererTime(), currentSchedulerTime = currentRendererTime; null !== nextFlushedRoot && 0 !== nextFlushedExpirationTime && - (0 === minExpirationTime || - minExpirationTime >= nextFlushedExpirationTime) && - (!deadlineDidExpire || currentRendererTime >= nextFlushedExpirationTime); + minExpirationTime <= nextFlushedExpirationTime && + !(didYield && currentRendererTime > nextFlushedExpirationTime); ) performWorkOnRoot( nextFlushedRoot, nextFlushedExpirationTime, - currentRendererTime >= nextFlushedExpirationTime + currentRendererTime > nextFlushedExpirationTime ), findHighestPriorityRoot(), recomputeCurrentRendererTime(), @@ -5397,29 +5652,28 @@ function performWork(minExpirationTime, dl) { ; null !== nextFlushedRoot && 0 !== nextFlushedExpirationTime && - (0 === minExpirationTime || - minExpirationTime >= nextFlushedExpirationTime); + minExpirationTime <= nextFlushedExpirationTime; ) - performWorkOnRoot(nextFlushedRoot, nextFlushedExpirationTime, !0), + performWorkOnRoot(nextFlushedRoot, nextFlushedExpirationTime, !1), findHighestPriorityRoot(); - null !== deadline && ((callbackExpirationTime = 0), (callbackID = null)); + isYieldy && ((callbackExpirationTime = 0), (callbackID = null)); 0 !== nextFlushedExpirationTime && scheduleCallbackWithExpirationTime( nextFlushedRoot, nextFlushedExpirationTime ); - deadline = null; - deadlineDidExpire = !1; nestedUpdateCount = 0; lastCommittedRootDuringThisBatch = null; if (null !== completedBatches) for ( - minExpirationTime = completedBatches, completedBatches = null, dl = 0; - dl < minExpirationTime.length; - dl++ + minExpirationTime = completedBatches, + completedBatches = null, + isYieldy = 0; + isYieldy < minExpirationTime.length; + isYieldy++ ) { - var batch = minExpirationTime[dl]; + var batch = minExpirationTime[isYieldy]; try { batch._onComplete(); } catch (error) { @@ -5433,45 +5687,45 @@ function performWork(minExpirationTime, dl) { (hasUnhandledError = !1), minExpirationTime); } -function performWorkOnRoot(root, expirationTime, isExpired) { +function performWorkOnRoot(root, expirationTime, isYieldy) { invariant( !isRendering, "performWorkOnRoot was called recursively. This error is likely caused by a bug in React. Please file an issue." ); isRendering = !0; - if (null === deadline || isExpired) { - var finishedWork = root.finishedWork; - null !== finishedWork - ? completeRoot$1(root, finishedWork, expirationTime) + if (isYieldy) { + var _finishedWork = root.finishedWork; + null !== _finishedWork + ? completeRoot$1(root, _finishedWork, expirationTime) : ((root.finishedWork = null), - (finishedWork = root.timeoutHandle), - -1 !== finishedWork && - ((root.timeoutHandle = -1), cancelTimeout(finishedWork)), - renderRoot(root, !1, isExpired), - (finishedWork = root.finishedWork), - null !== finishedWork && - completeRoot$1(root, finishedWork, expirationTime)); + (_finishedWork = root.timeoutHandle), + -1 !== _finishedWork && + ((root.timeoutHandle = -1), cancelTimeout(_finishedWork)), + renderRoot(root, isYieldy), + (_finishedWork = root.finishedWork), + null !== _finishedWork && + (shouldYieldToRenderer() + ? (root.finishedWork = _finishedWork) + : completeRoot$1(root, _finishedWork, expirationTime))); } else - (finishedWork = root.finishedWork), - null !== finishedWork - ? completeRoot$1(root, finishedWork, expirationTime) + (_finishedWork = root.finishedWork), + null !== _finishedWork + ? completeRoot$1(root, _finishedWork, expirationTime) : ((root.finishedWork = null), - (finishedWork = root.timeoutHandle), - -1 !== finishedWork && - ((root.timeoutHandle = -1), cancelTimeout(finishedWork)), - renderRoot(root, !0, isExpired), - (finishedWork = root.finishedWork), - null !== finishedWork && - (shouldYield() - ? (root.finishedWork = finishedWork) - : completeRoot$1(root, finishedWork, expirationTime))); + (_finishedWork = root.timeoutHandle), + -1 !== _finishedWork && + ((root.timeoutHandle = -1), cancelTimeout(_finishedWork)), + renderRoot(root, isYieldy), + (_finishedWork = root.finishedWork), + null !== _finishedWork && + completeRoot$1(root, _finishedWork, expirationTime)); isRendering = !1; } function completeRoot$1(root, finishedWork$jscomp$0, expirationTime) { var firstBatch = root.firstBatch; if ( null !== firstBatch && - firstBatch._expirationTime <= expirationTime && + firstBatch._expirationTime >= expirationTime && (null === completedBatches ? (completedBatches = [firstBatch]) : completedBatches.push(firstBatch), @@ -5500,9 +5754,7 @@ function completeRoot$1(root, finishedWork$jscomp$0, expirationTime) { var childExpirationTimeBeforeCommit = finishedWork$jscomp$0.childExpirationTime; firstBatch = - 0 === firstBatch || - (0 !== childExpirationTimeBeforeCommit && - childExpirationTimeBeforeCommit < firstBatch) + childExpirationTimeBeforeCommit > firstBatch ? childExpirationTimeBeforeCommit : firstBatch; root.didError = !1; @@ -5514,19 +5766,19 @@ function completeRoot$1(root, finishedWork$jscomp$0, expirationTime) { (root.latestPingedTime = 0)) : ((childExpirationTimeBeforeCommit = root.latestPendingTime), 0 !== childExpirationTimeBeforeCommit && - (childExpirationTimeBeforeCommit < firstBatch + (childExpirationTimeBeforeCommit > firstBatch ? (root.earliestPendingTime = root.latestPendingTime = 0) - : root.earliestPendingTime < firstBatch && + : root.earliestPendingTime > firstBatch && (root.earliestPendingTime = root.latestPendingTime)), (childExpirationTimeBeforeCommit = root.earliestSuspendedTime), 0 === childExpirationTimeBeforeCommit ? markPendingPriorityLevel(root, firstBatch) - : firstBatch > root.latestSuspendedTime + : firstBatch < root.latestSuspendedTime ? ((root.earliestSuspendedTime = 0), (root.latestSuspendedTime = 0), (root.latestPingedTime = 0), markPendingPriorityLevel(root, firstBatch)) - : firstBatch < childExpirationTimeBeforeCommit && + : firstBatch > childExpirationTimeBeforeCommit && markPendingPriorityLevel(root, firstBatch)); findNextExpirationTimeToWorkOn(0, root); ReactCurrentOwner$2.current = null; @@ -5538,33 +5790,37 @@ function completeRoot$1(root, finishedWork$jscomp$0, expirationTime) { : (firstBatch = finishedWork$jscomp$0.firstEffect); for (nextEffect = firstBatch; null !== nextEffect; ) { childExpirationTimeBeforeCommit = !1; - var error = void 0; + var error$jscomp$0 = void 0; try { for (; null !== nextEffect; ) { - if (nextEffect.effectTag & 256) { - var current$$1 = nextEffect.alternate; + if (nextEffect.effectTag & 256) a: { - var finishedWork = nextEffect; + var current$$1 = nextEffect.alternate, + finishedWork = nextEffect; switch (finishedWork.tag) { - case 2: - case 3: + case 0: + case 11: + case 15: + break a; + case 1: if (finishedWork.effectTag & 256 && null !== current$$1) { var prevProps = current$$1.memoizedProps, prevState = current$$1.memoizedState, - instance = finishedWork.stateNode; - instance.props = finishedWork.memoizedProps; - instance.state = finishedWork.memoizedState; - var snapshot = instance.getSnapshotBeforeUpdate( - prevProps, - prevState - ); + instance = finishedWork.stateNode, + snapshot = instance.getSnapshotBeforeUpdate( + finishedWork.elementType === finishedWork.type + ? prevProps + : resolveDefaultProps(finishedWork.type, prevProps), + prevState + ); instance.__reactInternalSnapshotBeforeUpdate = snapshot; } break a; + case 3: case 5: - case 7: - case 8: case 6: + case 4: + case 17: break a; default: invariant( @@ -5573,18 +5829,17 @@ function completeRoot$1(root, finishedWork$jscomp$0, expirationTime) { ); } } - } nextEffect = nextEffect.nextEffect; } } catch (e) { - (childExpirationTimeBeforeCommit = !0), (error = e); + (childExpirationTimeBeforeCommit = !0), (error$jscomp$0 = e); } childExpirationTimeBeforeCommit && (invariant( null !== nextEffect, "Should have next effect. This error is likely caused by a bug in React. Please file an issue." ), - captureCommitPhaseError(nextEffect, error), + captureCommitPhaseError(nextEffect, error$jscomp$0), null !== nextEffect && (nextEffect = nextEffect.nextEffect)); } for (nextEffect = firstBatch; null !== nextEffect; ) { @@ -5621,8 +5876,32 @@ function completeRoot$1(root, finishedWork$jscomp$0, expirationTime) { "function" === typeof onCommitFiberUnmount && onCommitFiberUnmount(childExpirationTimeBeforeCommit); switch (childExpirationTimeBeforeCommit.tag) { - case 2: - case 3: + case 0: + case 11: + case 14: + case 15: + var updateQueue = childExpirationTimeBeforeCommit.updateQueue; + if (null !== updateQueue) { + var lastEffect = updateQueue.lastEffect; + if (null !== lastEffect) { + var firstEffect = lastEffect.next; + error$jscomp$0 = firstEffect; + do { + var destroy = error$jscomp$0.destroy; + if (null !== destroy) { + finishedWork = childExpirationTimeBeforeCommit; + try { + destroy(); + } catch (error) { + captureCommitPhaseError(finishedWork, error); + } + } + error$jscomp$0 = error$jscomp$0.next; + } while (error$jscomp$0 !== firstEffect); + } + } + break; + case 1: safelyDetachRef(childExpirationTimeBeforeCommit); var instance$jscomp$0 = childExpirationTimeBeforeCommit.stateNode; @@ -5642,10 +5921,10 @@ function completeRoot$1(root, finishedWork$jscomp$0, expirationTime) { ); } break; - case 7: + case 5: safelyDetachRef(childExpirationTimeBeforeCommit); break; - case 6: + case 4: FabricUIManager.createChildSet( childExpirationTimeBeforeCommit.stateNode.containerInfo ); @@ -5691,82 +5970,78 @@ function completeRoot$1(root, finishedWork$jscomp$0, expirationTime) { var effectTag$jscomp$0 = nextEffect.effectTag; if (effectTag$jscomp$0 & 36) { var current$$1$jscomp$1 = nextEffect.alternate; - instance$jscomp$0 = nextEffect; - firstBatch = currentRef; - switch (instance$jscomp$0.tag) { - case 2: - case 3: - var instance$jscomp$1 = instance$jscomp$0.stateNode; - if (instance$jscomp$0.effectTag & 4) + updateQueue = nextEffect; + lastEffect = currentRef; + switch (updateQueue.tag) { + case 0: + case 11: + case 15: + break; + case 1: + var instance$jscomp$1 = updateQueue.stateNode; + if (updateQueue.effectTag & 4) if (null === current$$1$jscomp$1) - (instance$jscomp$1.props = instance$jscomp$0.memoizedProps), - (instance$jscomp$1.state = instance$jscomp$0.memoizedState), - instance$jscomp$1.componentDidMount(); + instance$jscomp$1.componentDidMount(); else { - var prevProps$jscomp$0 = current$$1$jscomp$1.memoizedProps, - prevState$jscomp$0 = current$$1$jscomp$1.memoizedState; - instance$jscomp$1.props = instance$jscomp$0.memoizedProps; - instance$jscomp$1.state = instance$jscomp$0.memoizedState; + var prevProps$jscomp$0 = + updateQueue.elementType === updateQueue.type + ? current$$1$jscomp$1.memoizedProps + : resolveDefaultProps( + updateQueue.type, + current$$1$jscomp$1.memoizedProps + ); instance$jscomp$1.componentDidUpdate( prevProps$jscomp$0, - prevState$jscomp$0, + current$$1$jscomp$1.memoizedState, instance$jscomp$1.__reactInternalSnapshotBeforeUpdate ); } - var updateQueue = instance$jscomp$0.updateQueue; - null !== updateQueue && - ((instance$jscomp$1.props = instance$jscomp$0.memoizedProps), - (instance$jscomp$1.state = instance$jscomp$0.memoizedState), + var updateQueue$jscomp$0 = updateQueue.updateQueue; + null !== updateQueue$jscomp$0 && commitUpdateQueue( - instance$jscomp$0, updateQueue, + updateQueue$jscomp$0, instance$jscomp$1, - firstBatch - )); + lastEffect + ); break; - case 5: - var _updateQueue = instance$jscomp$0.updateQueue; + case 3: + var _updateQueue = updateQueue.updateQueue; if (null !== _updateQueue) { - current$$1 = null; - if (null !== instance$jscomp$0.child) - switch (instance$jscomp$0.child.tag) { - case 7: - current$$1 = instance$jscomp$0.child.stateNode.canonical; + firstEffect = null; + if (null !== updateQueue.child) + switch (updateQueue.child.tag) { + case 5: + firstEffect = updateQueue.child.stateNode.canonical; break; - case 2: - case 3: - current$$1 = instance$jscomp$0.child.stateNode; + case 1: + firstEffect = updateQueue.child.stateNode; } commitUpdateQueue( - instance$jscomp$0, + updateQueue, _updateQueue, - current$$1, - firstBatch + firstEffect, + lastEffect ); } break; - case 7: + case 5: null === current$$1$jscomp$1 && - instance$jscomp$0.effectTag & 4 && + updateQueue.effectTag & 4 && invariant( !1, "The current renderer does not support mutation. This error is likely caused by a bug in React. Please file an issue." ); break; - case 8: - break; case 6: break; - case 15: + case 4: break; - case 16: - if (0 === (instance$jscomp$0.mode & 2)) - (instance$jscomp$0.updateQueue = emptyObject$1), - scheduleWork(instance$jscomp$0, 1); - else { - var currentTime = requestCurrentTime(); - instance$jscomp$0.stateNode = { timedOutAt: currentTime }; - } + case 12: + break; + case 13: + break; + case 17: break; default: invariant( @@ -5780,7 +6055,7 @@ function completeRoot$1(root, finishedWork$jscomp$0, expirationTime) { if (null !== ref) { var instance$jscomp$2 = nextEffect.stateNode; switch (nextEffect.tag) { - case 7: + case 5: var instanceToUse = instance$jscomp$2.canonical; break; default: @@ -5791,9 +6066,7 @@ function completeRoot$1(root, finishedWork$jscomp$0, expirationTime) { : (ref.current = instanceToUse); } } - var next = nextEffect.nextEffect; - nextEffect.nextEffect = null; - nextEffect = next; + nextEffect = nextEffect.nextEffect; } } catch (e) { (effectTag = !0), (current$$1$jscomp$0 = e); @@ -5812,8 +6085,7 @@ function completeRoot$1(root, finishedWork$jscomp$0, expirationTime) { effectTag$jscomp$0 = finishedWork$jscomp$0.expirationTime; finishedWork$jscomp$0 = finishedWork$jscomp$0.childExpirationTime; finishedWork$jscomp$0 = - 0 === effectTag$jscomp$0 || - (0 !== finishedWork$jscomp$0 && finishedWork$jscomp$0 < effectTag$jscomp$0) + finishedWork$jscomp$0 > effectTag$jscomp$0 ? finishedWork$jscomp$0 : effectTag$jscomp$0; 0 === finishedWork$jscomp$0 && @@ -5821,13 +6093,6 @@ function completeRoot$1(root, finishedWork$jscomp$0, expirationTime) { root.expirationTime = finishedWork$jscomp$0; root.finishedWork = null; } -function shouldYield() { - return deadlineDidExpire - ? !0 - : null === deadline || deadline.timeRemaining() > timeHeuristicForUnitOfWork - ? !1 - : (deadlineDidExpire = !0); -} function onUncaughtError(error) { invariant( null !== nextFlushedRoot, @@ -5836,55 +6101,6 @@ function onUncaughtError(error) { nextFlushedRoot.expirationTime = 0; hasUnhandledError || ((hasUnhandledError = !0), (unhandledError = error)); } -function getContextForSubtree(parentComponent) { - if (!parentComponent) return emptyContextObject; - parentComponent = parentComponent._reactInternalFiber; - a: { - invariant( - 2 === isFiberMountedImpl(parentComponent) && - (2 === parentComponent.tag || 3 === parentComponent.tag), - "Expected subtree parent to be a mounted class component. This error is likely caused by a bug in React. Please file an issue." - ); - var parentContext = parentComponent; - do { - switch (parentContext.tag) { - case 5: - parentContext = parentContext.stateNode.context; - break a; - case 2: - if (isContextProvider(parentContext.type)) { - parentContext = - parentContext.stateNode.__reactInternalMemoizedMergedChildContext; - break a; - } - break; - case 3: - if (isContextProvider(parentContext.type._reactResult)) { - parentContext = - parentContext.stateNode.__reactInternalMemoizedMergedChildContext; - break a; - } - } - parentContext = parentContext.return; - } while (null !== parentContext); - invariant( - !1, - "Found unexpected detached subtree parent. This error is likely caused by a bug in React. Please file an issue." - ); - parentContext = void 0; - } - if (2 === parentComponent.tag) { - var Component = parentComponent.type; - if (isContextProvider(Component)) - return processChildContext(parentComponent, Component, parentContext); - } else if ( - 3 === parentComponent.tag && - ((Component = parentComponent.type._reactResult), - isContextProvider(Component)) - ) - return processChildContext(parentComponent, Component, parentContext); - return parentContext; -} function findHostInstance$1(component) { var fiber = component._reactInternalFiber; void 0 === fiber && @@ -5903,7 +6119,48 @@ function updateContainer(element, container, parentComponent, callback) { currentTime = requestCurrentTime(); current$$1 = computeExpirationForFiber(currentTime, current$$1); currentTime = container.current; - parentComponent = getContextForSubtree(parentComponent); + a: if (parentComponent) { + parentComponent = parentComponent._reactInternalFiber; + b: { + invariant( + 2 === isFiberMountedImpl(parentComponent) && 1 === parentComponent.tag, + "Expected subtree parent to be a mounted class component. This error is likely caused by a bug in React. Please file an issue." + ); + var parentContext = parentComponent; + do { + switch (parentContext.tag) { + case 3: + parentContext = parentContext.stateNode.context; + break b; + case 1: + if (isContextProvider(parentContext.type)) { + parentContext = + parentContext.stateNode + .__reactInternalMemoizedMergedChildContext; + break b; + } + } + parentContext = parentContext.return; + } while (null !== parentContext); + invariant( + !1, + "Found unexpected detached subtree parent. This error is likely caused by a bug in React. Please file an issue." + ); + parentContext = void 0; + } + if (1 === parentComponent.tag) { + var Component = parentComponent.type; + if (isContextProvider(Component)) { + parentComponent = processChildContext( + parentComponent, + Component, + parentContext + ); + break a; + } + } + parentComponent = parentContext; + } else parentComponent = emptyContextObject; null === container.context ? (container.context = parentComponent) : (container.pendingContext = parentComponent); @@ -5912,6 +6169,7 @@ function updateContainer(element, container, parentComponent, callback) { callback.payload = { element: element }; container = void 0 === container ? null : container; null !== container && (callback.callback = container); + flushPassiveEffects(); enqueueUpdate(currentTime, callback); scheduleWork(currentTime, current$$1); return current$$1; @@ -5971,13 +6229,13 @@ _batchedUpdatesImpl = function(fn, a) { } finally { (isBatchingUpdates = previousIsBatchingUpdates) || isRendering || - performWork(1, null); + performWork(1073741823, !1); } }; _flushInteractiveUpdatesImpl = function() { isRendering || 0 === lowestPriorityPendingInteractiveExpirationTime || - (performWork(lowestPriorityPendingInteractiveExpirationTime, null), + (performWork(lowestPriorityPendingInteractiveExpirationTime, !1), (lowestPriorityPendingInteractiveExpirationTime = 0)); }; var roots = new Map(), @@ -6057,7 +6315,7 @@ var roots = new Map(), render: function(element, containerTag, callback) { var root = roots.get(containerTag); if (!root) { - root = new FiberNode(5, null, null, 0); + root = createFiber(3, null, null, 0); var root$jscomp$0 = { current: root, containerInfo: containerTag, @@ -6085,7 +6343,7 @@ var roots = new Map(), updateContainer(element, root, null, callback); a: if (((element = root.current), element.child)) switch (element.child.tag) { - case 7: + case 5: element = element.child.stateNode.canonical; break a; default: @@ -6182,7 +6440,7 @@ var roots = new Map(), findFiberByHostInstance: getInstanceFromInstance, getInspectorDataForViewTag: getInspectorDataForViewTag, bundleType: 0, - version: "16.6.0-alpha.8af6728", + version: "16.6.1", 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 0ca23993737641..8f3f835d7c0a10 100644 --- a/Libraries/Renderer/oss/ReactFabric-profiling.js +++ b/Libraries/Renderer/oss/ReactFabric-profiling.js @@ -20,6 +20,7 @@ var ReactNativeViewConfigRegistry = require("ReactNativeViewConfigRegistry"), TextInputState = require("TextInputState"), FabricUIManager = require("FabricUIManager"), tracing = require("scheduler/tracing"), + scheduler = require("scheduler"), ExceptionsManager = require("ExceptionsManager"); function invariant(condition, format, a, b, c, d, e, f) { if (!condition) { @@ -167,10 +168,10 @@ var plugins = [], getFiberCurrentPropsFromNode = null, getInstanceFromNode = null, getNodeFromInstance = null; -function executeDispatch(event, simulated, listener, inst) { - simulated = event.type || "unknown-event"; +function executeDispatch(event, listener, inst) { + var type = event.type || "unknown-event"; event.currentTarget = getNodeFromInstance(inst); - invokeGuardedCallbackAndCatchFirstError(simulated, listener, void 0, event); + invokeGuardedCallbackAndCatchFirstError(type, listener, void 0, event); event.currentTarget = null; } function executeDirectDispatch(event) { @@ -216,10 +217,10 @@ function executeDispatchesAndReleaseTopLevel(e) { i < dispatchListeners.length && !e.isPropagationStopped(); i++ ) - executeDispatch(e, !1, dispatchListeners[i], dispatchInstances[i]); + executeDispatch(e, dispatchListeners[i], dispatchInstances[i]); else dispatchListeners && - executeDispatch(e, !1, dispatchListeners, dispatchInstances); + executeDispatch(e, dispatchListeners, dispatchInstances); e._dispatchListeners = null; e._dispatchInstances = null; e.isPersistent() || e.constructor.release(e); @@ -294,7 +295,7 @@ function getListener(inst, registrationName) { } function getParent(inst) { do inst = inst.return; - while (inst && 7 !== inst.tag); + while (inst && 5 !== inst.tag); return inst ? inst : null; } function traverseTwoPhase(inst, fn, arg) { @@ -1035,7 +1036,8 @@ var ReactSharedInternals = : 60111, REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for("react.forward_ref") : 60112, REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for("react.suspense") : 60113, - REACT_PURE_TYPE = hasSymbol ? Symbol.for("react.pure") : 60115, + REACT_MEMO_TYPE = hasSymbol ? Symbol.for("react.memo") : 60115, + REACT_LAZY_TYPE = hasSymbol ? Symbol.for("react.lazy") : 60116, MAYBE_ITERATOR_SYMBOL = "function" === typeof Symbol && Symbol.iterator; function getIteratorFn(maybeIterable) { if (null === maybeIterable || "object" !== typeof maybeIterable) return null; @@ -1044,13 +1046,6 @@ function getIteratorFn(maybeIterable) { maybeIterable["@@iterator"]; return "function" === typeof maybeIterable ? maybeIterable : null; } -function getWrappedName(outerType, innerType, wrapperName) { - innerType = innerType.displayName || innerType.name || ""; - return ( - outerType.displayName || - ("" !== innerType ? wrapperName + "(" + innerType + ")" : wrapperName) - ); -} function getComponentName(type) { if (null == type) return null; if ("function" === typeof type) return type.displayName || type.name || null; @@ -1069,23 +1064,25 @@ function getComponentName(type) { case REACT_SUSPENSE_TYPE: return "Suspense"; } - if ("object" === typeof type) { + if ("object" === typeof type) switch (type.$$typeof) { case REACT_CONTEXT_TYPE: return "Context.Consumer"; case REACT_PROVIDER_TYPE: return "Context.Provider"; case REACT_FORWARD_REF_TYPE: - return getWrappedName(type, type.render, "ForwardRef"); - case REACT_PURE_TYPE: - return getWrappedName(type, type.render, "Pure"); + var innerType = type.render; + innerType = innerType.displayName || innerType.name || ""; + return ( + type.displayName || + ("" !== innerType ? "ForwardRef(" + innerType + ")" : "ForwardRef") + ); + case REACT_MEMO_TYPE: + return getComponentName(type.type); + case REACT_LAZY_TYPE: + if ((type = 1 === type._status ? type._result : null)) + return getComponentName(type); } - if ( - "function" === typeof type.then && - (type = 1 === type._reactStatus ? type._reactResult : null) - ) - return getComponentName(type); - } return null; } function isFiberMountedImpl(fiber) { @@ -1096,7 +1093,7 @@ function isFiberMountedImpl(fiber) { for (; node.return; ) if (((node = node.return), 0 !== (node.effectTag & 2))) return 1; } - return 5 === node.tag ? 2 : 3; + return 3 === node.tag ? 2 : 3; } function assertIsMounted(fiber) { invariant( @@ -1172,14 +1169,14 @@ function findCurrentFiberUsingSlowPath(fiber) { "Return fibers should always be each others' alternates. This error is likely caused by a bug in React. Please file an issue." ); } - invariant(5 === a.tag, "Unable to find node on an unmounted component."); + invariant(3 === a.tag, "Unable to find node on an unmounted component."); return a.stateNode.current === a ? fiber : alternate; } function findCurrentHostFiber(parent) { parent = findCurrentFiberUsingSlowPath(parent); if (!parent) return null; for (var node = parent; ; ) { - if (7 === node.tag || 8 === node.tag) return node; + if (5 === node.tag || 6 === node.tag) return node; if (node.child) (node.child.return = node), (node = node.child); else { if (node === parent) break; @@ -1429,18 +1426,12 @@ var now$1 = return Date.now(); }, scheduledCallback = null, - frameDeadline = 0, - frameDeadlineObject = { - timeRemaining: function() { - return frameDeadline - now$1(); - }, - didTimeout: !1 - }; + frameDeadline = 0; function setTimeoutCallback() { frameDeadline = now$1() + 5; var callback = scheduledCallback; scheduledCallback = null; - null !== callback && callback(frameDeadlineObject); + null !== callback && callback(); } var restoreTarget = null, restoreQueue = null; @@ -1598,19 +1589,44 @@ function createTextInstance( }; } var scheduleTimeout = setTimeout, - cancelTimeout = clearTimeout, - BEFORE_SLASH_RE = /^(.*)[\\\/]/; + cancelTimeout = clearTimeout; +function cloneHiddenInstance(instance) { + var node = instance.node; + var updatePayload = diffProperties( + null, + emptyObject, + { style: { display: "none" } }, + instance.canonical.viewConfig.validAttributes + ); + return { + node: FabricUIManager.cloneNodeWithNewProps(node, updatePayload), + canonical: instance.canonical + }; +} +function cloneUnhiddenInstance(instance, type, props) { + var viewConfig = instance.canonical.viewConfig; + type = instance.node; + var prevProps = Object.assign({}, props, { + style: [props.style, { display: "none" }] + }); + props = diffProperties(null, prevProps, props, viewConfig.validAttributes); + return { + node: FabricUIManager.cloneNodeWithNewProps(type, props), + canonical: instance.canonical + }; +} +var BEFORE_SLASH_RE = /^(.*)[\\\/]/; function getStackByFiberInDevAndProd(workInProgress) { var info = ""; do { a: switch (workInProgress.tag) { - case 4: + case 2: + case 16: case 0: case 1: - case 2: - case 3: - case 7: - case 10: + case 5: + case 8: + case 13: var owner = workInProgress._debugOwner, source = workInProgress._debugSource, name = getComponentName(workInProgress.type); @@ -1762,7 +1778,7 @@ function injectInternals(internals) { function FiberNode(tag, pendingProps, key, mode) { this.tag = tag; this.key = key; - this.sibling = this.child = this.return = this.stateNode = this.type = null; + this.sibling = this.child = this.return = this.stateNode = this.type = this.elementType = null; this.index = 0; this.ref = null; this.pendingProps = pendingProps; @@ -1776,29 +1792,33 @@ function FiberNode(tag, pendingProps, key, mode) { this.actualStartTime = -1; this.treeBaseDuration = this.selfBaseDuration = 0; } +function createFiber(tag, pendingProps, key, mode) { + return new FiberNode(tag, pendingProps, key, mode); +} function shouldConstruct(Component) { Component = Component.prototype; return !(!Component || !Component.isReactComponent); } -function resolveLazyComponentTag(fiber, Component) { +function resolveLazyComponentTag(Component) { if ("function" === typeof Component) - return shouldConstruct(Component) ? 3 : 1; + return shouldConstruct(Component) ? 1 : 0; if (void 0 !== Component && null !== Component) { - fiber = Component.$$typeof; - if (fiber === REACT_FORWARD_REF_TYPE) return 14; - if (fiber === REACT_PURE_TYPE) return 18; + Component = Component.$$typeof; + if (Component === REACT_FORWARD_REF_TYPE) return 11; + if (Component === REACT_MEMO_TYPE) return 14; } - return 4; + return 2; } function createWorkInProgress(current, pendingProps) { var workInProgress = current.alternate; null === workInProgress - ? ((workInProgress = new FiberNode( + ? ((workInProgress = createFiber( current.tag, pendingProps, current.key, current.mode )), + (workInProgress.elementType = current.elementType), (workInProgress.type = current.type), (workInProgress.stateNode = current.stateNode), (workInProgress.alternate = current), @@ -1824,60 +1844,66 @@ function createWorkInProgress(current, pendingProps) { workInProgress.treeBaseDuration = current.treeBaseDuration; return workInProgress; } -function createFiberFromElement(element, mode, expirationTime) { - var type = element.type, - key = element.key; - element = element.props; - var fiberTag = void 0; - if ("function" === typeof type) fiberTag = shouldConstruct(type) ? 2 : 4; - else if ("string" === typeof type) fiberTag = 7; +function createFiberFromTypeAndProps( + type, + key, + pendingProps, + owner, + mode, + expirationTime +) { + var fiberTag = 2; + owner = type; + if ("function" === typeof type) shouldConstruct(type) && (fiberTag = 1); + else if ("string" === typeof type) fiberTag = 5; else a: switch (type) { case REACT_FRAGMENT_TYPE: return createFiberFromFragment( - element.children, + pendingProps.children, mode, expirationTime, key ); case REACT_CONCURRENT_MODE_TYPE: - fiberTag = 10; - mode |= 3; - break; + return createFiberFromMode(pendingProps, mode | 3, expirationTime, key); case REACT_STRICT_MODE_TYPE: - fiberTag = 10; - mode |= 2; - break; + return createFiberFromMode(pendingProps, mode | 2, expirationTime, key); case REACT_PROFILER_TYPE: return ( - (type = new FiberNode(15, element, key, mode | 4)), + (type = createFiber(12, pendingProps, key, mode | 4)), + (type.elementType = REACT_PROFILER_TYPE), (type.type = REACT_PROFILER_TYPE), (type.expirationTime = expirationTime), type ); case REACT_SUSPENSE_TYPE: - fiberTag = 16; - break; + return ( + (type = createFiber(13, pendingProps, key, mode)), + (type.elementType = REACT_SUSPENSE_TYPE), + (type.type = REACT_SUSPENSE_TYPE), + (type.expirationTime = expirationTime), + type + ); default: if ("object" === typeof type && null !== type) switch (type.$$typeof) { case REACT_PROVIDER_TYPE: - fiberTag = 12; + fiberTag = 10; break a; case REACT_CONTEXT_TYPE: - fiberTag = 11; + fiberTag = 9; break a; case REACT_FORWARD_REF_TYPE: - fiberTag = 13; + fiberTag = 11; break a; - case REACT_PURE_TYPE: - fiberTag = 17; + case REACT_MEMO_TYPE: + fiberTag = 14; + break a; + case REACT_LAZY_TYPE: + fiberTag = 16; + owner = null; break a; - default: - if ("function" === typeof type.then) { - fiberTag = 4; - break a; - } } invariant( !1, @@ -1886,24 +1912,33 @@ function createFiberFromElement(element, mode, expirationTime) { "" ); } - mode = new FiberNode(fiberTag, element, key, mode); - mode.type = type; - mode.expirationTime = expirationTime; - return mode; + key = createFiber(fiberTag, pendingProps, key, mode); + key.elementType = type; + key.type = owner; + key.expirationTime = expirationTime; + return key; } function createFiberFromFragment(elements, mode, expirationTime, key) { - elements = new FiberNode(9, elements, key, mode); + elements = createFiber(7, elements, key, mode); elements.expirationTime = expirationTime; return elements; } +function createFiberFromMode(pendingProps, mode, expirationTime, key) { + pendingProps = createFiber(8, pendingProps, key, mode); + mode = 0 === (mode & 1) ? REACT_STRICT_MODE_TYPE : REACT_CONCURRENT_MODE_TYPE; + pendingProps.elementType = mode; + pendingProps.type = mode; + pendingProps.expirationTime = expirationTime; + return pendingProps; +} function createFiberFromText(content, mode, expirationTime) { - content = new FiberNode(8, content, null, mode); + content = createFiber(6, content, null, mode); content.expirationTime = expirationTime; return content; } function createFiberFromPortal(portal, mode, expirationTime) { - mode = new FiberNode( - 6, + mode = createFiber( + 4, null !== portal.children ? portal.children : [], portal.key, mode @@ -1921,9 +1956,9 @@ function markPendingPriorityLevel(root, expirationTime) { var earliestPendingTime = root.earliestPendingTime; 0 === earliestPendingTime ? (root.earliestPendingTime = root.latestPendingTime = expirationTime) - : earliestPendingTime > expirationTime + : earliestPendingTime < expirationTime ? (root.earliestPendingTime = expirationTime) - : root.latestPendingTime < expirationTime && + : root.latestPendingTime > expirationTime && (root.latestPendingTime = expirationTime); findNextExpirationTimeToWorkOn(expirationTime, root); } @@ -1938,19 +1973,19 @@ function markCommittedPriorityLevels(root, earliestRemainingTime) { else { var latestPendingTime = root.latestPendingTime; 0 !== latestPendingTime && - (latestPendingTime < earliestRemainingTime + (latestPendingTime > earliestRemainingTime ? (root.earliestPendingTime = root.latestPendingTime = 0) - : root.earliestPendingTime < earliestRemainingTime && + : root.earliestPendingTime > earliestRemainingTime && (root.earliestPendingTime = root.latestPendingTime)); latestPendingTime = root.earliestSuspendedTime; 0 === latestPendingTime ? markPendingPriorityLevel(root, earliestRemainingTime) - : earliestRemainingTime > root.latestSuspendedTime + : earliestRemainingTime < root.latestSuspendedTime ? ((root.earliestSuspendedTime = 0), (root.latestSuspendedTime = 0), (root.latestPingedTime = 0), markPendingPriorityLevel(root, earliestRemainingTime)) - : earliestRemainingTime < latestPendingTime && + : earliestRemainingTime > latestPendingTime && markPendingPriorityLevel(root, earliestRemainingTime); } findNextExpirationTimeToWorkOn(0, root); @@ -1960,17 +1995,17 @@ function hasLowerPriorityWork(root, erroredExpirationTime) { latestSuspendedTime = root.latestSuspendedTime; root = root.latestPingedTime; return ( - (0 !== latestPendingTime && latestPendingTime > erroredExpirationTime) || + (0 !== latestPendingTime && latestPendingTime < erroredExpirationTime) || (0 !== latestSuspendedTime && - latestSuspendedTime > erroredExpirationTime) || - (0 !== root && root > erroredExpirationTime) + latestSuspendedTime < erroredExpirationTime) || + (0 !== root && root < erroredExpirationTime) ); } function markSuspendedPriorityLevel(root, suspendedTime) { root.didError = !1; var latestPingedTime = root.latestPingedTime; 0 !== latestPingedTime && - latestPingedTime <= suspendedTime && + latestPingedTime >= suspendedTime && (root.latestPingedTime = 0); latestPingedTime = root.earliestPendingTime; var latestPendingTime = root.latestPendingTime; @@ -1985,22 +2020,18 @@ function markSuspendedPriorityLevel(root, suspendedTime) { latestPendingTime = root.latestSuspendedTime; 0 === latestPingedTime ? (root.earliestSuspendedTime = root.latestSuspendedTime = suspendedTime) - : latestPingedTime > suspendedTime + : latestPingedTime < suspendedTime ? (root.earliestSuspendedTime = suspendedTime) - : latestPendingTime < suspendedTime && + : latestPendingTime > suspendedTime && (root.latestSuspendedTime = suspendedTime); findNextExpirationTimeToWorkOn(suspendedTime, root); } function findEarliestOutstandingPriorityLevel(root, renderExpirationTime) { var earliestPendingTime = root.earliestPendingTime; root = root.earliestSuspendedTime; - if ( - 0 === renderExpirationTime || - (0 !== earliestPendingTime && earliestPendingTime < renderExpirationTime) - ) - renderExpirationTime = earliestPendingTime; - if (0 === renderExpirationTime || (0 !== root && root < renderExpirationTime)) - renderExpirationTime = root; + earliestPendingTime > renderExpirationTime && + (renderExpirationTime = earliestPendingTime); + root > renderExpirationTime && (renderExpirationTime = root); return renderExpirationTime; } function findNextExpirationTimeToWorkOn(completedExpirationTime, root) { @@ -2012,12 +2043,11 @@ function findNextExpirationTimeToWorkOn(completedExpirationTime, root) { 0 !== earliestPendingTime ? earliestPendingTime : latestPingedTime; 0 === earliestPendingTime && (0 === completedExpirationTime || - latestSuspendedTime > completedExpirationTime) && + latestSuspendedTime < completedExpirationTime) && (earliestPendingTime = latestSuspendedTime); completedExpirationTime = earliestPendingTime; 0 !== completedExpirationTime && - 0 !== earliestSuspendedTime && - earliestSuspendedTime < completedExpirationTime && + earliestSuspendedTime > completedExpirationTime && (completedExpirationTime = earliestSuspendedTime); root.nextExpirationTimeToWorkOn = earliestPendingTime; root.expirationTime = completedExpirationTime; @@ -2129,7 +2159,7 @@ function getStateFromUpdate( : workInProgress ); case 3: - workInProgress.effectTag = (workInProgress.effectTag & -1025) | 64; + workInProgress.effectTag = (workInProgress.effectTag & -2049) | 64; case 0: workInProgress = update.payload; nextProps = @@ -2162,58 +2192,52 @@ function processUpdateQueue( ) { var updateExpirationTime = update.expirationTime; - if (updateExpirationTime > renderExpirationTime) { - if ( - (null === newFirstUpdate && + updateExpirationTime < renderExpirationTime + ? (null === newFirstUpdate && ((newFirstUpdate = update), (newBaseState = resultState)), - 0 === newExpirationTime || newExpirationTime > updateExpirationTime) - ) - newExpirationTime = updateExpirationTime; - } else - (resultState = getStateFromUpdate( - workInProgress, - queue, - update, - resultState, - props, - instance - )), + newExpirationTime < updateExpirationTime && + (newExpirationTime = updateExpirationTime)) + : ((resultState = getStateFromUpdate( + workInProgress, + queue, + update, + resultState, + props, + instance + )), null !== update.callback && ((workInProgress.effectTag |= 32), (update.nextEffect = null), null === queue.lastEffect ? (queue.firstEffect = queue.lastEffect = update) : ((queue.lastEffect.nextEffect = update), - (queue.lastEffect = update))); + (queue.lastEffect = update)))); update = update.next; } updateExpirationTime = null; for (update = queue.firstCapturedUpdate; null !== update; ) { var _updateExpirationTime = update.expirationTime; - if (_updateExpirationTime > renderExpirationTime) { - if ( - (null === updateExpirationTime && + _updateExpirationTime < renderExpirationTime + ? (null === updateExpirationTime && ((updateExpirationTime = update), null === newFirstUpdate && (newBaseState = resultState)), - 0 === newExpirationTime || newExpirationTime > _updateExpirationTime) - ) - newExpirationTime = _updateExpirationTime; - } else - (resultState = getStateFromUpdate( - workInProgress, - queue, - update, - resultState, - props, - instance - )), + newExpirationTime < _updateExpirationTime && + (newExpirationTime = _updateExpirationTime)) + : ((resultState = getStateFromUpdate( + workInProgress, + queue, + update, + resultState, + props, + instance + )), null !== update.callback && ((workInProgress.effectTag |= 32), (update.nextEffect = null), null === queue.lastCapturedEffect ? (queue.firstCapturedEffect = queue.lastCapturedEffect = update) : ((queue.lastCapturedEffect.nextEffect = update), - (queue.lastCapturedEffect = update))); + (queue.lastCapturedEffect = update)))); update = update.next; } null === newFirstUpdate && (queue.lastUpdate = null); @@ -2294,7 +2318,7 @@ function readContext(context, observedBits) { null === lastContextDependency ? (invariant( null !== currentlyRenderingFiber, - "Context.unstable_read(): Context can only be read while React is rendering, e.g. inside the render method or getDerivedStateFromProps." + "Context can only be read while React is rendering, e.g. inside the render method or getDerivedStateFromProps." ), (currentlyRenderingFiber.firstContextDependency = lastContextDependency = observedBits)) : (lastContextDependency = lastContextDependency.next = observedBits); @@ -2380,7 +2404,47 @@ function shallowEqual(objA, objB) { return !1; return !0; } -var emptyRefsObject = new React.Component().refs; +function resolveDefaultProps(Component, baseProps) { + if (Component && Component.defaultProps) { + baseProps = Object.assign({}, baseProps); + Component = Component.defaultProps; + for (var propName in Component) + void 0 === baseProps[propName] && + (baseProps[propName] = Component[propName]); + } + return baseProps; +} +function readLazyComponentType(lazyComponent) { + var result = lazyComponent._result; + switch (lazyComponent._status) { + case 1: + return result; + case 2: + throw result; + case 0: + throw result; + 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)); + }, + function(error) { + 0 === lazyComponent._status && + ((lazyComponent._status = 2), (lazyComponent._result = error)); + } + ), + (lazyComponent._result = result), + result); + } +} +var ReactCurrentOwner$4 = ReactSharedInternals.ReactCurrentOwner, + emptyRefsObject = new React.Component().refs; function applyDerivedStateFromProps( workInProgress, ctor, @@ -2412,6 +2476,7 @@ var classComponentUpdater = { var update = createUpdate(currentTime); update.payload = payload; void 0 !== callback && null !== callback && (update.callback = callback); + flushPassiveEffects(); enqueueUpdate(inst, update); scheduleWork(inst, currentTime); }, @@ -2423,6 +2488,7 @@ var classComponentUpdater = { update.tag = 1; update.payload = payload; void 0 !== callback && null !== callback && (update.callback = callback); + flushPassiveEffects(); enqueueUpdate(inst, update); scheduleWork(inst, currentTime); }, @@ -2433,6 +2499,7 @@ var classComponentUpdater = { var update = createUpdate(currentTime); update.tag = 2; void 0 !== callback && null !== callback && (update.callback = callback); + flushPassiveEffects(); enqueueUpdate(inst, update); scheduleWork(inst, currentTime); } @@ -2453,6 +2520,32 @@ function checkShouldComponentUpdate( ? !shallowEqual(oldProps, newProps) || !shallowEqual(oldState, newState) : !0; } +function constructClassInstance(workInProgress, ctor, props) { + var isLegacyContextConsumer = !1, + unmaskedContext = emptyContextObject; + var context = ctor.contextType; + "object" === typeof context && null !== context + ? (context = ReactCurrentOwner$4.currentDispatcher.readContext(context)) + : ((unmaskedContext = isContextProvider(ctor) + ? previousContext + : contextStackCursor.current), + (isLegacyContextConsumer = ctor.contextTypes), + (context = (isLegacyContextConsumer = + null !== isLegacyContextConsumer && void 0 !== isLegacyContextConsumer) + ? getMaskedContext(workInProgress, unmaskedContext) + : emptyContextObject)); + ctor = new ctor(props, context); + workInProgress.memoizedState = + null !== ctor.state && void 0 !== ctor.state ? ctor.state : null; + ctor.updater = classComponentUpdater; + workInProgress.stateNode = ctor; + ctor._reactInternalFiber = workInProgress; + isLegacyContextConsumer && + ((workInProgress = workInProgress.stateNode), + (workInProgress.__reactInternalMemoizedUnmaskedChildContext = unmaskedContext), + (workInProgress.__reactInternalMemoizedMaskedChildContext = context)); + return ctor; +} function callComponentWillReceiveProps( workInProgress, instance, @@ -2479,7 +2572,9 @@ function mountClassInstance( instance.refs = emptyRefsObject; var contextType = ctor.contextType; "object" === typeof contextType && null !== contextType - ? (instance.context = contextType.unstable_read()) + ? (instance.context = ReactCurrentOwner$4.currentDispatcher.readContext( + contextType + )) : ((contextType = isContextProvider(ctor) ? previousContext : contextStackCursor.current), @@ -2534,10 +2629,7 @@ function coerceRef(returnFiber, current$$1, element) { element = element._owner; var inst = void 0; element && - (invariant( - 2 === element.tag || 3 === element.tag, - "Function components cannot have refs." - ), + (invariant(1 === element.tag, "Function components cannot have refs."), (inst = element.stateNode)); invariant( inst, @@ -2642,7 +2734,7 @@ function ChildReconciler(shouldTrackSideEffects) { textContent, expirationTime ) { - if (null === current$$1 || 8 !== current$$1.tag) + if (null === current$$1 || 6 !== current$$1.tag) return ( (current$$1 = createFiberFromText( textContent, @@ -2657,15 +2749,18 @@ function ChildReconciler(shouldTrackSideEffects) { return current$$1; } function updateElement(returnFiber, current$$1, element, expirationTime) { - if (null !== current$$1 && current$$1.type === element.type) + if (null !== current$$1 && current$$1.elementType === element.type) return ( (expirationTime = useFiber(current$$1, element.props, expirationTime)), (expirationTime.ref = coerceRef(returnFiber, current$$1, element)), (expirationTime.return = returnFiber), expirationTime ); - expirationTime = createFiberFromElement( - element, + expirationTime = createFiberFromTypeAndProps( + element.type, + element.key, + element.props, + null, returnFiber.mode, expirationTime ); @@ -2676,7 +2771,7 @@ function ChildReconciler(shouldTrackSideEffects) { function updatePortal(returnFiber, current$$1, portal, expirationTime) { if ( null === current$$1 || - 6 !== current$$1.tag || + 4 !== current$$1.tag || current$$1.stateNode.containerInfo !== portal.containerInfo || current$$1.stateNode.implementation !== portal.implementation ) @@ -2700,7 +2795,7 @@ function ChildReconciler(shouldTrackSideEffects) { expirationTime, key ) { - if (null === current$$1 || 9 !== current$$1.tag) + if (null === current$$1 || 7 !== current$$1.tag) return ( (current$$1 = createFiberFromFragment( fragment, @@ -2730,8 +2825,11 @@ function ChildReconciler(shouldTrackSideEffects) { switch (newChild.$$typeof) { case REACT_ELEMENT_TYPE: return ( - (expirationTime = createFiberFromElement( - newChild, + (expirationTime = createFiberFromTypeAndProps( + newChild.type, + newChild.key, + newChild.props, + null, returnFiber.mode, expirationTime )), @@ -3075,9 +3173,9 @@ function ChildReconciler(shouldTrackSideEffects) { ) { if (isUnkeyedTopLevelFragment.key === isObject) if ( - 9 === isUnkeyedTopLevelFragment.tag + 7 === isUnkeyedTopLevelFragment.tag ? newChild.type === REACT_FRAGMENT_TYPE - : isUnkeyedTopLevelFragment.type === newChild.type + : isUnkeyedTopLevelFragment.elementType === newChild.type ) { deleteRemainingChildren( returnFiber, @@ -3117,8 +3215,11 @@ function ChildReconciler(shouldTrackSideEffects) { )), (currentFirstChild.return = returnFiber), (returnFiber = currentFirstChild)) - : ((expirationTime = createFiberFromElement( - newChild, + : ((expirationTime = createFiberFromTypeAndProps( + newChild.type, + newChild.key, + newChild.props, + null, returnFiber.mode, expirationTime )), @@ -3140,7 +3241,7 @@ function ChildReconciler(shouldTrackSideEffects) { ) { if (currentFirstChild.key === isUnkeyedTopLevelFragment) if ( - 6 === currentFirstChild.tag && + 4 === currentFirstChild.tag && currentFirstChild.stateNode.containerInfo === newChild.containerInfo && currentFirstChild.stateNode.implementation === @@ -3178,7 +3279,7 @@ function ChildReconciler(shouldTrackSideEffects) { if ("string" === typeof newChild || "number" === typeof newChild) return ( (newChild = "" + newChild), - null !== currentFirstChild && 8 === currentFirstChild.tag + null !== currentFirstChild && 6 === currentFirstChild.tag ? (deleteRemainingChildren(returnFiber, currentFirstChild.sibling), (currentFirstChild = useFiber( currentFirstChild, @@ -3214,8 +3315,7 @@ function ChildReconciler(shouldTrackSideEffects) { isObject && throwOnInvalidObjectType(returnFiber, newChild); if ("undefined" === typeof newChild && !isUnkeyedTopLevelFragment) switch (returnFiber.tag) { - case 2: - case 3: + case 1: case 0: (expirationTime = returnFiber.type), invariant( @@ -3234,12 +3334,12 @@ var reconcileChildFibers = ChildReconciler(!0), isHydrating = !1; function tryHydrate(fiber, nextInstance) { switch (fiber.tag) { - case 7: + case 5: return ( (nextInstance = shim$1(nextInstance, fiber.type, fiber.pendingProps)), null !== nextInstance ? ((fiber.stateNode = nextInstance), !0) : !1 ); - case 8: + case 6: return ( (nextInstance = shim$1(nextInstance, fiber.pendingProps)), null !== nextInstance ? ((fiber.stateNode = nextInstance), !0) : !1 @@ -3262,7 +3362,8 @@ function tryToClaimNextHydratableInstance(fiber$jscomp$0) { return; } var returnFiber = hydrationParentFiber, - fiber = new FiberNode(7, null, null, 0); + fiber = createFiber(5, null, null, 0); + fiber.elementType = "DELETED"; fiber.type = "DELETED"; fiber.stateNode = firstAttemptedInstance; fiber.return = returnFiber; @@ -3280,38 +3381,6 @@ function tryToClaimNextHydratableInstance(fiber$jscomp$0) { (hydrationParentFiber = fiber$jscomp$0); } } -function readLazyComponentType(thenable) { - switch (thenable._reactStatus) { - case 1: - return thenable._reactResult; - case 2: - throw thenable._reactResult; - case 0: - throw thenable; - default: - throw ((thenable._reactStatus = 0), - thenable.then( - function(resolvedValue) { - if (0 === thenable._reactStatus) { - thenable._reactStatus = 1; - if ("object" === typeof resolvedValue && null !== resolvedValue) { - var defaultExport = resolvedValue.default; - resolvedValue = - void 0 !== defaultExport && null !== defaultExport - ? defaultExport - : resolvedValue; - } - thenable._reactResult = resolvedValue; - } - }, - function(error) { - 0 === thenable._reactStatus && - ((thenable._reactStatus = 2), (thenable._reactResult = error)); - } - ), - thenable); - } -} var ReactCurrentOwner$3 = ReactSharedInternals.ReactCurrentOwner; function reconcileChildren( current$$1, @@ -3337,28 +3406,24 @@ function reconcileChildren( function updateForwardRef( current$$1, workInProgress, - type, + Component, nextProps, renderExpirationTime ) { - type = type.render; + Component = Component.render; var ref = workInProgress.ref; - if ( - !didPerformWorkStackCursor.current && - workInProgress.memoizedProps === nextProps && - ref === (null !== current$$1 ? current$$1.ref : null) - ) - return bailoutOnAlreadyFinishedWork( - current$$1, - workInProgress, - renderExpirationTime - ); - type = type(nextProps, ref); - reconcileChildren(current$$1, workInProgress, type, renderExpirationTime); - workInProgress.memoizedProps = nextProps; + prepareToReadContext(workInProgress, renderExpirationTime); + nextProps = Component(nextProps, ref); + workInProgress.effectTag |= 1; + reconcileChildren( + current$$1, + workInProgress, + nextProps, + renderExpirationTime + ); return workInProgress.child; } -function updatePureComponent( +function updateMemoComponent( current$$1, workInProgress, Component, @@ -3366,29 +3431,82 @@ function updatePureComponent( updateExpirationTime, renderExpirationTime ) { - var render = Component.render, - ref = workInProgress.ref; + if (null === current$$1) { + var type = Component.type; + if ( + "function" === typeof type && + !shouldConstruct(type) && + void 0 === type.defaultProps && + null === Component.compare + ) + return ( + (workInProgress.tag = 15), + (workInProgress.type = type), + updateSimpleMemoComponent( + current$$1, + workInProgress, + type, + nextProps, + updateExpirationTime, + renderExpirationTime + ) + ); + current$$1 = createFiberFromTypeAndProps( + Component.type, + null, + nextProps, + null, + workInProgress.mode, + renderExpirationTime + ); + current$$1.ref = workInProgress.ref; + current$$1.return = workInProgress; + return (workInProgress.child = current$$1); + } + type = current$$1.child; if ( - null !== current$$1 && - (0 === updateExpirationTime || - updateExpirationTime > renderExpirationTime) && - ((updateExpirationTime = current$$1.memoizedProps), + updateExpirationTime < renderExpirationTime && + ((updateExpirationTime = type.memoizedProps), (Component = Component.compare), (Component = null !== Component ? Component : shallowEqual), - workInProgress.ref === current$$1.ref && - Component(updateExpirationTime, nextProps)) + Component(updateExpirationTime, nextProps) && + current$$1.ref === workInProgress.ref) ) return bailoutOnAlreadyFinishedWork( current$$1, workInProgress, renderExpirationTime ); - prepareToReadContext(workInProgress, renderExpirationTime); - render = render(nextProps, ref); workInProgress.effectTag |= 1; - reconcileChildren(current$$1, workInProgress, render, renderExpirationTime); - workInProgress.memoizedProps = nextProps; - return workInProgress.child; + current$$1 = createWorkInProgress(type, nextProps, renderExpirationTime); + current$$1.ref = workInProgress.ref; + current$$1.return = workInProgress; + return (workInProgress.child = current$$1); +} +function updateSimpleMemoComponent( + current$$1, + workInProgress, + Component, + nextProps, + updateExpirationTime, + renderExpirationTime +) { + return null !== current$$1 && + updateExpirationTime < renderExpirationTime && + shallowEqual(current$$1.memoizedProps, nextProps) && + current$$1.ref === workInProgress.ref + ? bailoutOnAlreadyFinishedWork( + current$$1, + workInProgress, + renderExpirationTime + ) + : updateFunctionComponent( + current$$1, + workInProgress, + Component, + nextProps, + renderExpirationTime + ); } function markRef(current$$1, workInProgress) { var ref = workInProgress.ref; @@ -3418,7 +3536,6 @@ function updateFunctionComponent( Component, renderExpirationTime ); - workInProgress.memoizedProps = nextProps; return workInProgress.child; } function updateClassComponent( @@ -3433,166 +3550,152 @@ function updateClassComponent( pushContextProvider(workInProgress); } else hasContext = !1; prepareToReadContext(workInProgress, renderExpirationTime); - if (null === current$$1) - if (null === workInProgress.stateNode) { - var isLegacyContextConsumer = !1, - unmaskedContext = emptyContextObject; - var context = Component.contextType; - "object" === typeof context && null !== context - ? (context = context.unstable_read()) - : ((unmaskedContext = isContextProvider(Component) - ? previousContext - : contextStackCursor.current), - (isLegacyContextConsumer = Component.contextTypes), - (context = (isLegacyContextConsumer = - null !== isLegacyContextConsumer && - void 0 !== isLegacyContextConsumer) - ? getMaskedContext(workInProgress, unmaskedContext) - : emptyContextObject)); - var instance = new Component(nextProps, context); - workInProgress.memoizedState = - null !== instance.state && void 0 !== instance.state - ? instance.state - : null; - instance.updater = classComponentUpdater; - workInProgress.stateNode = instance; - instance._reactInternalFiber = workInProgress; - isLegacyContextConsumer && - ((isLegacyContextConsumer = workInProgress.stateNode), - (isLegacyContextConsumer.__reactInternalMemoizedUnmaskedChildContext = unmaskedContext), - (isLegacyContextConsumer.__reactInternalMemoizedMaskedChildContext = context)); + if (null === workInProgress.stateNode) + null !== current$$1 && + ((current$$1.alternate = null), + (workInProgress.alternate = null), + (workInProgress.effectTag |= 2)), + constructClassInstance( + workInProgress, + Component, + nextProps, + renderExpirationTime + ), mountClassInstance( workInProgress, Component, nextProps, renderExpirationTime - ); - nextProps = !0; - } else { - unmaskedContext = workInProgress.stateNode; - isLegacyContextConsumer = workInProgress.memoizedProps; - unmaskedContext.props = isLegacyContextConsumer; - var oldContext = unmaskedContext.context; - context = Component.contextType; - "object" === typeof context && null !== context - ? (context = context.unstable_read()) - : ((context = isContextProvider(Component) - ? previousContext - : contextStackCursor.current), - (context = getMaskedContext(workInProgress, context))); - var getDerivedStateFromProps = Component.getDerivedStateFromProps; - (instance = + ), + (nextProps = !0); + else if (null === current$$1) { + var instance = workInProgress.stateNode, + oldProps = workInProgress.memoizedProps; + instance.props = oldProps; + var oldContext = instance.context, + contextType = Component.contextType; + "object" === typeof contextType && null !== contextType + ? (contextType = ReactCurrentOwner$4.currentDispatcher.readContext( + contextType + )) + : ((contextType = isContextProvider(Component) + ? previousContext + : contextStackCursor.current), + (contextType = getMaskedContext(workInProgress, contextType))); + var getDerivedStateFromProps = Component.getDerivedStateFromProps, + hasNewLifecycles = "function" === typeof getDerivedStateFromProps || - "function" === typeof unmaskedContext.getSnapshotBeforeUpdate) || - ("function" !== - typeof unmaskedContext.UNSAFE_componentWillReceiveProps && - "function" !== typeof unmaskedContext.componentWillReceiveProps) || - ((isLegacyContextConsumer !== nextProps || oldContext !== context) && - callComponentWillReceiveProps( - workInProgress, - unmaskedContext, - nextProps, - context - )); - hasForceUpdate = !1; - var oldState = workInProgress.memoizedState; - oldContext = unmaskedContext.state = oldState; - var updateQueue = workInProgress.updateQueue; - null !== updateQueue && - (processUpdateQueue( + "function" === typeof instance.getSnapshotBeforeUpdate; + hasNewLifecycles || + ("function" !== typeof instance.UNSAFE_componentWillReceiveProps && + "function" !== typeof instance.componentWillReceiveProps) || + ((oldProps !== nextProps || oldContext !== contextType) && + callComponentWillReceiveProps( workInProgress, - updateQueue, + instance, nextProps, - unmaskedContext, - renderExpirationTime - ), - (oldContext = workInProgress.memoizedState)); - isLegacyContextConsumer !== nextProps || - oldState !== oldContext || - didPerformWorkStackCursor.current || - hasForceUpdate - ? ("function" === typeof getDerivedStateFromProps && - (applyDerivedStateFromProps( - workInProgress, - Component, - getDerivedStateFromProps, - nextProps - ), - (oldContext = workInProgress.memoizedState)), - (isLegacyContextConsumer = - hasForceUpdate || - checkShouldComponentUpdate( - workInProgress, - Component, - isLegacyContextConsumer, - nextProps, - oldState, - oldContext, - context - )) - ? (instance || - ("function" !== - typeof unmaskedContext.UNSAFE_componentWillMount && - "function" !== typeof unmaskedContext.componentWillMount) || - ("function" === typeof unmaskedContext.componentWillMount && - unmaskedContext.componentWillMount(), - "function" === - typeof unmaskedContext.UNSAFE_componentWillMount && - unmaskedContext.UNSAFE_componentWillMount()), - "function" === typeof unmaskedContext.componentDidMount && - (workInProgress.effectTag |= 4)) - : ("function" === typeof unmaskedContext.componentDidMount && - (workInProgress.effectTag |= 4), - (workInProgress.memoizedProps = nextProps), - (workInProgress.memoizedState = oldContext)), - (unmaskedContext.props = nextProps), - (unmaskedContext.state = oldContext), - (unmaskedContext.context = context), - (nextProps = isLegacyContextConsumer)) - : ("function" === typeof unmaskedContext.componentDidMount && - (workInProgress.effectTag |= 4), - (nextProps = !1)); - } - else - (unmaskedContext = workInProgress.stateNode), - (isLegacyContextConsumer = workInProgress.memoizedProps), - (unmaskedContext.props = isLegacyContextConsumer), - (oldContext = unmaskedContext.context), - (context = Component.contextType), - "object" === typeof context && null !== context - ? (context = context.unstable_read()) - : ((context = isContextProvider(Component) + contextType + )); + hasForceUpdate = !1; + var oldState = workInProgress.memoizedState; + oldContext = instance.state = oldState; + var updateQueue = workInProgress.updateQueue; + null !== updateQueue && + (processUpdateQueue( + workInProgress, + updateQueue, + nextProps, + instance, + renderExpirationTime + ), + (oldContext = workInProgress.memoizedState)); + oldProps !== nextProps || + oldState !== oldContext || + didPerformWorkStackCursor.current || + hasForceUpdate + ? ("function" === typeof getDerivedStateFromProps && + (applyDerivedStateFromProps( + workInProgress, + Component, + getDerivedStateFromProps, + nextProps + ), + (oldContext = workInProgress.memoizedState)), + (oldProps = + hasForceUpdate || + checkShouldComponentUpdate( + workInProgress, + Component, + oldProps, + nextProps, + oldState, + oldContext, + contextType + )) + ? (hasNewLifecycles || + ("function" !== typeof instance.UNSAFE_componentWillMount && + "function" !== typeof instance.componentWillMount) || + ("function" === typeof instance.componentWillMount && + instance.componentWillMount(), + "function" === typeof instance.UNSAFE_componentWillMount && + instance.UNSAFE_componentWillMount()), + "function" === typeof instance.componentDidMount && + (workInProgress.effectTag |= 4)) + : ("function" === typeof instance.componentDidMount && + (workInProgress.effectTag |= 4), + (workInProgress.memoizedProps = nextProps), + (workInProgress.memoizedState = oldContext)), + (instance.props = nextProps), + (instance.state = oldContext), + (instance.context = contextType), + (nextProps = oldProps)) + : ("function" === typeof instance.componentDidMount && + (workInProgress.effectTag |= 4), + (nextProps = !1)); + } else + (instance = workInProgress.stateNode), + (oldProps = workInProgress.memoizedProps), + (instance.props = + workInProgress.type === workInProgress.elementType + ? oldProps + : resolveDefaultProps(workInProgress.type, oldProps)), + (oldContext = instance.context), + (contextType = Component.contextType), + "object" === typeof contextType && null !== contextType + ? (contextType = ReactCurrentOwner$4.currentDispatcher.readContext( + contextType + )) + : ((contextType = isContextProvider(Component) ? previousContext : contextStackCursor.current), - (context = getMaskedContext(workInProgress, context))), + (contextType = getMaskedContext(workInProgress, contextType))), (getDerivedStateFromProps = Component.getDerivedStateFromProps), - (instance = + (hasNewLifecycles = "function" === typeof getDerivedStateFromProps || - "function" === typeof unmaskedContext.getSnapshotBeforeUpdate) || - ("function" !== - typeof unmaskedContext.UNSAFE_componentWillReceiveProps && - "function" !== typeof unmaskedContext.componentWillReceiveProps) || - ((isLegacyContextConsumer !== nextProps || oldContext !== context) && + "function" === typeof instance.getSnapshotBeforeUpdate) || + ("function" !== typeof instance.UNSAFE_componentWillReceiveProps && + "function" !== typeof instance.componentWillReceiveProps) || + ((oldProps !== nextProps || oldContext !== contextType) && callComponentWillReceiveProps( workInProgress, - unmaskedContext, + instance, nextProps, - context + contextType )), (hasForceUpdate = !1), (oldContext = workInProgress.memoizedState), - (oldState = unmaskedContext.state = oldContext), + (oldState = instance.state = oldContext), (updateQueue = workInProgress.updateQueue), null !== updateQueue && (processUpdateQueue( workInProgress, updateQueue, nextProps, - unmaskedContext, + instance, renderExpirationTime ), (oldState = workInProgress.memoizedState)), - isLegacyContextConsumer !== nextProps || + oldProps !== nextProps || oldContext !== oldState || didPerformWorkStackCursor.current || hasForceUpdate @@ -3609,53 +3712,51 @@ function updateClassComponent( checkShouldComponentUpdate( workInProgress, Component, - isLegacyContextConsumer, + oldProps, nextProps, oldContext, oldState, - context + contextType )) - ? (instance || - ("function" !== - typeof unmaskedContext.UNSAFE_componentWillUpdate && - "function" !== typeof unmaskedContext.componentWillUpdate) || - ("function" === typeof unmaskedContext.componentWillUpdate && - unmaskedContext.componentWillUpdate( + ? (hasNewLifecycles || + ("function" !== typeof instance.UNSAFE_componentWillUpdate && + "function" !== typeof instance.componentWillUpdate) || + ("function" === typeof instance.componentWillUpdate && + instance.componentWillUpdate( nextProps, oldState, - context + contextType ), - "function" === - typeof unmaskedContext.UNSAFE_componentWillUpdate && - unmaskedContext.UNSAFE_componentWillUpdate( + "function" === typeof instance.UNSAFE_componentWillUpdate && + instance.UNSAFE_componentWillUpdate( nextProps, oldState, - context + contextType )), - "function" === typeof unmaskedContext.componentDidUpdate && + "function" === typeof instance.componentDidUpdate && (workInProgress.effectTag |= 4), - "function" === typeof unmaskedContext.getSnapshotBeforeUpdate && + "function" === typeof instance.getSnapshotBeforeUpdate && (workInProgress.effectTag |= 256)) - : ("function" !== typeof unmaskedContext.componentDidUpdate || - (isLegacyContextConsumer === current$$1.memoizedProps && + : ("function" !== typeof instance.componentDidUpdate || + (oldProps === current$$1.memoizedProps && oldContext === current$$1.memoizedState) || (workInProgress.effectTag |= 4), - "function" !== typeof unmaskedContext.getSnapshotBeforeUpdate || - (isLegacyContextConsumer === current$$1.memoizedProps && + "function" !== typeof instance.getSnapshotBeforeUpdate || + (oldProps === current$$1.memoizedProps && oldContext === current$$1.memoizedState) || (workInProgress.effectTag |= 256), (workInProgress.memoizedProps = nextProps), (workInProgress.memoizedState = oldState)), - (unmaskedContext.props = nextProps), - (unmaskedContext.state = oldState), - (unmaskedContext.context = context), + (instance.props = nextProps), + (instance.state = oldState), + (instance.context = contextType), (nextProps = getDerivedStateFromProps)) - : ("function" !== typeof unmaskedContext.componentDidUpdate || - (isLegacyContextConsumer === current$$1.memoizedProps && + : ("function" !== typeof instance.componentDidUpdate || + (oldProps === current$$1.memoizedProps && oldContext === current$$1.memoizedState) || (workInProgress.effectTag |= 4), - "function" !== typeof unmaskedContext.getSnapshotBeforeUpdate || - (isLegacyContextConsumer === current$$1.memoizedProps && + "function" !== typeof instance.getSnapshotBeforeUpdate || + (oldProps === current$$1.memoizedProps && oldContext === current$$1.memoizedState) || (workInProgress.effectTag |= 256), (nextProps = !1)); @@ -3718,7 +3819,6 @@ function finishClassComponent( renderExpirationTime ); workInProgress.memoizedState = shouldUpdate.state; - workInProgress.memoizedProps = shouldUpdate.props; hasContext && invalidateContextProvider(workInProgress, Component, !0); return workInProgress.child; } @@ -3734,42 +3834,152 @@ function pushHostRootContext(workInProgress) { pushTopLevelContextObject(workInProgress, root.context, !1); pushHostContainer(workInProgress, root.containerInfo); } -function resolveDefaultProps(Component, baseProps) { - if (Component && Component.defaultProps) { - baseProps = Object.assign({}, baseProps); - Component = Component.defaultProps; - for (var propName in Component) - void 0 === baseProps[propName] && - (baseProps[propName] = Component[propName]); - } - return baseProps; -} -function bailoutOnAlreadyFinishedWork( +function updateSuspenseComponent( current$$1, workInProgress, renderExpirationTime ) { - null !== current$$1 && - (workInProgress.firstContextDependency = current$$1.firstContextDependency); - profilerStartTime = -1; - 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." - ); - if (null !== workInProgress.child) { - current$$1 = workInProgress.child; - renderExpirationTime = createWorkInProgress( - current$$1, - current$$1.pendingProps, - current$$1.expirationTime - ); - workInProgress.child = renderExpirationTime; - for ( - renderExpirationTime.return = workInProgress; - null !== current$$1.sibling; + var mode = workInProgress.mode, + nextProps = workInProgress.pendingProps, + nextState = workInProgress.memoizedState; + if (0 === (workInProgress.effectTag & 64)) { + nextState = null; + var nextDidTimeout = !1; + } else + (nextState = { timedOutAt: null !== nextState ? nextState.timedOutAt : 0 }), + (nextDidTimeout = !0), + (workInProgress.effectTag &= -65); + if (null === current$$1) + nextDidTimeout + ? ((nextDidTimeout = nextProps.fallback), + (nextProps = createFiberFromFragment(null, mode, 0, null)), + 0 === (workInProgress.mode & 1) && + (nextProps.child = + null !== workInProgress.memoizedState + ? workInProgress.child.child + : workInProgress.child), + (renderExpirationTime = createFiberFromFragment( + nextDidTimeout, + mode, + renderExpirationTime, + null + )), + (nextProps.sibling = renderExpirationTime), + (mode = nextProps), + (mode.return = renderExpirationTime.return = workInProgress)) + : (mode = renderExpirationTime = mountChildFibers( + workInProgress, + null, + nextProps.children, + renderExpirationTime + )); + else if (null !== current$$1.memoizedState) + if ( + ((current$$1 = current$$1.child), + (mode = current$$1.sibling), + nextDidTimeout) + ) { + nextProps = nextProps.fallback; + renderExpirationTime = createWorkInProgress( + current$$1, + current$$1.pendingProps, + 0 + ); + renderExpirationTime.effectTag |= 2; + 0 === (workInProgress.mode & 1) && + ((nextDidTimeout = + null !== workInProgress.memoizedState + ? workInProgress.child.child + : workInProgress.child), + nextDidTimeout !== current$$1.child && + (renderExpirationTime.child = nextDidTimeout)); + if (workInProgress.mode & 4) { + nextDidTimeout = 0; + for (current$$1 = renderExpirationTime.child; null !== current$$1; ) + (nextDidTimeout += current$$1.treeBaseDuration), + (current$$1 = current$$1.sibling); + renderExpirationTime.treeBaseDuration = nextDidTimeout; + } + nextProps = renderExpirationTime.sibling = createWorkInProgress( + mode, + nextProps, + mode.expirationTime + ); + nextProps.effectTag |= 2; + mode = renderExpirationTime; + renderExpirationTime.childExpirationTime = 0; + renderExpirationTime = nextProps; + mode.return = renderExpirationTime.return = workInProgress; + } else + mode = renderExpirationTime = reconcileChildFibers( + workInProgress, + current$$1.child, + nextProps.children, + renderExpirationTime + ); + else if (((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; + 0 === (workInProgress.mode & 1) && + (nextProps.child = + null !== workInProgress.memoizedState + ? workInProgress.child.child + : workInProgress.child); + if (workInProgress.mode & 4) { + current$$1 = 0; + for (var _hiddenChild = nextProps.child; null !== _hiddenChild; ) + (current$$1 += _hiddenChild.treeBaseDuration), + (_hiddenChild = _hiddenChild.sibling); + nextProps.treeBaseDuration = current$$1; + } + renderExpirationTime = nextProps.sibling = createFiberFromFragment( + nextDidTimeout, + mode, + renderExpirationTime, + null + ); + renderExpirationTime.effectTag |= 2; + mode = nextProps; + nextProps.childExpirationTime = 0; + mode.return = renderExpirationTime.return = workInProgress; + } else + renderExpirationTime = mode = reconcileChildFibers( + workInProgress, + current$$1, + nextProps.children, + renderExpirationTime + ); + workInProgress.memoizedState = nextState; + workInProgress.child = mode; + return renderExpirationTime; +} +function bailoutOnAlreadyFinishedWork( + current$$1, + workInProgress, + renderExpirationTime +) { + null !== current$$1 && + (workInProgress.firstContextDependency = current$$1.firstContextDependency); + profilerStartTime = -1; + if (workInProgress.childExpirationTime < renderExpirationTime) return null; + invariant( + null === current$$1 || workInProgress.child === current$$1.child, + "Resuming work not yet implemented." + ); + if (null !== workInProgress.child) { + current$$1 = workInProgress.child; + renderExpirationTime = createWorkInProgress( + current$$1, + current$$1.pendingProps, + current$$1.expirationTime + ); + workInProgress.child = renderExpirationTime; + for ( + renderExpirationTime.return = workInProgress; + null !== current$$1.sibling; ) (current$$1 = current$$1.sibling), @@ -3789,34 +3999,50 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { null !== current$$1 && current$$1.memoizedProps === workInProgress.pendingProps && !didPerformWorkStackCursor.current && - (0 === updateExpirationTime || updateExpirationTime > renderExpirationTime) + updateExpirationTime < renderExpirationTime ) { switch (workInProgress.tag) { - case 5: + case 3: pushHostRootContext(workInProgress); break; - case 7: + case 5: pushHostContext(workInProgress); break; - case 2: + case 1: isContextProvider(workInProgress.type) && pushContextProvider(workInProgress); break; - case 3: - isContextProvider(workInProgress.type._reactResult) && - pushContextProvider(workInProgress); - break; - case 6: + case 4: pushHostContainer( workInProgress, workInProgress.stateNode.containerInfo ); break; - case 12: + case 10: pushProvider(workInProgress, workInProgress.memoizedProps.value); break; - case 15: + case 12: workInProgress.effectTag |= 4; + break; + case 13: + if (null !== workInProgress.memoizedState) { + updateExpirationTime = workInProgress.child.childExpirationTime; + if ( + 0 !== updateExpirationTime && + updateExpirationTime >= renderExpirationTime + ) + return updateSuspenseComponent( + current$$1, + workInProgress, + renderExpirationTime + ); + workInProgress = bailoutOnAlreadyFinishedWork( + current$$1, + workInProgress, + renderExpirationTime + ); + return null !== workInProgress ? workInProgress.sibling : null; + } } return bailoutOnAlreadyFinishedWork( current$$1, @@ -3826,191 +4052,180 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { } workInProgress.expirationTime = 0; switch (workInProgress.tag) { - case 4: - var Component = workInProgress.type; - invariant( - null === current$$1, - "An indeterminate component should never have mounted. This error is likely caused by a bug in React. Please file an issue." + 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 ); - var props = workInProgress.pendingProps; + prepareToReadContext(workInProgress, renderExpirationTime); + context = updateExpirationTime(current$$1, context); + workInProgress.effectTag |= 1; if ( - "object" === typeof Component && - null !== Component && - "function" === typeof Component.then + "object" === typeof context && + null !== context && + "function" === typeof context.render && + void 0 === context.$$typeof ) { - Component = readLazyComponentType(Component); - var resolvedTag = (workInProgress.tag = resolveLazyComponentTag( + workInProgress.tag = 1; + if (isContextProvider(updateExpirationTime)) { + var hasContext = !0; + pushContextProvider(workInProgress); + } else hasContext = !1; + workInProgress.memoizedState = + null !== context.state && void 0 !== context.state + ? context.state + : null; + var getDerivedStateFromProps = + updateExpirationTime.getDerivedStateFromProps; + "function" === typeof getDerivedStateFromProps && + applyDerivedStateFromProps( workInProgress, - Component - )), - resolvedProps = resolveDefaultProps(Component, props), - child = void 0; - switch (resolvedTag) { - case 1: - child = updateFunctionComponent( - current$$1, - workInProgress, - Component, - resolvedProps, - renderExpirationTime - ); - break; - case 3: - child = updateClassComponent( - current$$1, - workInProgress, - Component, - resolvedProps, - renderExpirationTime - ); - break; - case 14: - child = updateForwardRef( - current$$1, - workInProgress, - Component, - resolvedProps, - renderExpirationTime - ); - break; - case 18: - child = updatePureComponent( - current$$1, - workInProgress, - Component, - resolvedProps, - updateExpirationTime, - renderExpirationTime - ); - break; - default: - invariant( - !1, - "Element type is invalid. Received a promise that resolves to: %s. Promise elements must resolve to a class or function.", - Component - ); - } - workInProgress.memoizedProps = props; - workInProgress = child; - } else - (updateExpirationTime = getMaskedContext( + updateExpirationTime, + getDerivedStateFromProps, + current$$1 + ); + context.updater = classComponentUpdater; + workInProgress.stateNode = context; + context._reactInternalFiber = workInProgress; + mountClassInstance( workInProgress, - contextStackCursor.current - )), - prepareToReadContext(workInProgress, renderExpirationTime), - (updateExpirationTime = Component(props, updateExpirationTime)), - (workInProgress.effectTag |= 1), - "object" === typeof updateExpirationTime && - null !== updateExpirationTime && - "function" === typeof updateExpirationTime.render && - void 0 === updateExpirationTime.$$typeof - ? ((workInProgress.tag = 2), - isContextProvider(Component) - ? ((resolvedTag = !0), pushContextProvider(workInProgress)) - : (resolvedTag = !1), - (workInProgress.memoizedState = - null !== updateExpirationTime.state && - void 0 !== updateExpirationTime.state - ? updateExpirationTime.state - : null), - (resolvedProps = Component.getDerivedStateFromProps), - "function" === typeof resolvedProps && - applyDerivedStateFromProps( - workInProgress, - Component, - resolvedProps, - props - ), - (updateExpirationTime.updater = classComponentUpdater), - (workInProgress.stateNode = updateExpirationTime), - (updateExpirationTime._reactInternalFiber = workInProgress), - mountClassInstance( - workInProgress, - Component, - props, - renderExpirationTime - ), - (workInProgress = finishClassComponent( - current$$1, - workInProgress, - Component, - !0, - resolvedTag, - renderExpirationTime - ))) - : ((workInProgress.tag = 0), - reconcileChildren( - current$$1, - workInProgress, - updateExpirationTime, - renderExpirationTime - ), - (workInProgress.memoizedProps = props), - (workInProgress = workInProgress.child)); + updateExpirationTime, + current$$1, + renderExpirationTime + ); + workInProgress = finishClassComponent( + null, + workInProgress, + updateExpirationTime, + !0, + hasContext, + renderExpirationTime + ); + } else + (workInProgress.tag = 0), + reconcileChildren( + null, + workInProgress, + context, + renderExpirationTime + ), + (workInProgress = workInProgress.child); return workInProgress; + case 16: + context = workInProgress.elementType; + null !== current$$1 && + ((current$$1.alternate = null), + (workInProgress.alternate = null), + (workInProgress.effectTag |= 2)); + hasContext = workInProgress.pendingProps; + current$$1 = readLazyComponentType(context); + workInProgress.type = current$$1; + context = workInProgress.tag = resolveLazyComponentTag(current$$1); + hasContext = resolveDefaultProps(current$$1, hasContext); + getDerivedStateFromProps = void 0; + switch (context) { + case 0: + getDerivedStateFromProps = updateFunctionComponent( + null, + workInProgress, + current$$1, + hasContext, + renderExpirationTime + ); + break; + case 1: + getDerivedStateFromProps = updateClassComponent( + null, + workInProgress, + current$$1, + hasContext, + renderExpirationTime + ); + break; + case 11: + getDerivedStateFromProps = updateForwardRef( + null, + workInProgress, + current$$1, + hasContext, + renderExpirationTime + ); + break; + case 14: + getDerivedStateFromProps = updateMemoComponent( + null, + workInProgress, + current$$1, + resolveDefaultProps(current$$1.type, hasContext), + 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.", + current$$1 + ); + } + return getDerivedStateFromProps; case 0: - return updateFunctionComponent( - current$$1, - workInProgress, - workInProgress.type, - workInProgress.pendingProps, - renderExpirationTime - ); - case 1: return ( - (props = workInProgress.type._reactResult), - (Component = workInProgress.pendingProps), - (current$$1 = updateFunctionComponent( + (updateExpirationTime = workInProgress.type), + (context = workInProgress.pendingProps), + (context = + workInProgress.elementType === updateExpirationTime + ? context + : resolveDefaultProps(updateExpirationTime, context)), + updateFunctionComponent( current$$1, workInProgress, - props, - resolveDefaultProps(props, Component), + updateExpirationTime, + context, renderExpirationTime - )), - (workInProgress.memoizedProps = Component), - current$$1 - ); - case 2: - return updateClassComponent( - current$$1, - workInProgress, - workInProgress.type, - workInProgress.pendingProps, - renderExpirationTime + ) ); - case 3: + case 1: return ( - (props = workInProgress.type._reactResult), - (Component = workInProgress.pendingProps), - (current$$1 = updateClassComponent( + (updateExpirationTime = workInProgress.type), + (context = workInProgress.pendingProps), + (context = + workInProgress.elementType === updateExpirationTime + ? context + : resolveDefaultProps(updateExpirationTime, context)), + updateClassComponent( current$$1, workInProgress, - props, - resolveDefaultProps(props, Component), + updateExpirationTime, + context, renderExpirationTime - )), - (workInProgress.memoizedProps = Component), - current$$1 + ) ); - case 5: + case 3: return ( pushHostRootContext(workInProgress), - (Component = workInProgress.updateQueue), + (updateExpirationTime = workInProgress.updateQueue), invariant( - null !== Component, + null !== updateExpirationTime, "If the root does not have an updateQueue, we should have already bailed out. This error is likely caused by a bug in React. Please file an issue." ), - (props = workInProgress.memoizedState), - (props = null !== props ? props.element : null), + (context = workInProgress.memoizedState), + (context = null !== context ? context.element : null), processUpdateQueue( workInProgress, - Component, + updateExpirationTime, workInProgress.pendingProps, null, renderExpirationTime ), - (Component = workInProgress.memoizedState.element), - Component === props + (updateExpirationTime = workInProgress.memoizedState.element), + updateExpirationTime === context ? (workInProgress = bailoutOnAlreadyFinishedWork( current$$1, workInProgress, @@ -4019,186 +4234,131 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { : (reconcileChildren( current$$1, workInProgress, - Component, + updateExpirationTime, renderExpirationTime ), (workInProgress = workInProgress.child)), workInProgress ); - case 7: + case 5: return ( pushHostContext(workInProgress), null === current$$1 && tryToClaimNextHydratableInstance(workInProgress), - (Component = workInProgress.pendingProps), - (props = Component.children), + (updateExpirationTime = workInProgress.pendingProps.children), markRef(current$$1, workInProgress), reconcileChildren( current$$1, workInProgress, - props, + updateExpirationTime, renderExpirationTime ), - (workInProgress.memoizedProps = Component), (workInProgress = workInProgress.child), workInProgress ); - case 8: + case 6: return ( null === current$$1 && tryToClaimNextHydratableInstance(workInProgress), - (workInProgress.memoizedProps = workInProgress.pendingProps), null ); - case 16: - return ( - (Component = workInProgress.pendingProps), - (props = 0 === (workInProgress.effectTag & 64)), - null !== current$$1 && null !== workInProgress.updateQueue - ? ((workInProgress.updateQueue = null), (props = !0)) - : (props = !props), - 0 !== (workInProgress.mode & 2) && - (props - ? (workInProgress.effectTag |= 4) - : (workInProgress.stateNode = null)), - (updateExpirationTime = Component.children), - (updateExpirationTime = - "function" === typeof updateExpirationTime - ? updateExpirationTime(props) - : props - ? Component.fallback - : updateExpirationTime), - null !== current$$1 && props !== workInProgress.memoizedState - ? ((workInProgress.child = reconcileChildFibers( - workInProgress, - current$$1.child, - null, - renderExpirationTime - )), - (workInProgress.child = reconcileChildFibers( - workInProgress, - null, - updateExpirationTime, - renderExpirationTime - ))) - : reconcileChildren( - current$$1, - workInProgress, - updateExpirationTime, - renderExpirationTime - ), - (workInProgress.memoizedProps = Component), - (workInProgress.memoizedState = props), - workInProgress.child + case 13: + return updateSuspenseComponent( + current$$1, + workInProgress, + renderExpirationTime ); - case 6: + case 4: return ( pushHostContainer( workInProgress, workInProgress.stateNode.containerInfo ), - (Component = workInProgress.pendingProps), + (updateExpirationTime = workInProgress.pendingProps), null === current$$1 ? (workInProgress.child = reconcileChildFibers( workInProgress, null, - Component, + updateExpirationTime, renderExpirationTime )) : reconcileChildren( current$$1, workInProgress, - Component, + updateExpirationTime, renderExpirationTime ), - (workInProgress.memoizedProps = Component), workInProgress.child ); - case 13: - return updateForwardRef( - current$$1, - workInProgress, - workInProgress.type, - workInProgress.pendingProps, - renderExpirationTime - ); - case 14: + case 11: return ( - (props = workInProgress.type._reactResult), - (Component = workInProgress.pendingProps), - (current$$1 = updateForwardRef( + (updateExpirationTime = workInProgress.type), + (context = workInProgress.pendingProps), + (context = + workInProgress.elementType === updateExpirationTime + ? context + : resolveDefaultProps(updateExpirationTime, context)), + updateForwardRef( current$$1, workInProgress, - props, - resolveDefaultProps(props, Component), + updateExpirationTime, + context, renderExpirationTime - )), - (workInProgress.memoizedProps = Component), - current$$1 + ) ); - case 9: + case 7: return ( - (Component = workInProgress.pendingProps), reconcileChildren( current$$1, workInProgress, - Component, + workInProgress.pendingProps, renderExpirationTime ), - (workInProgress.memoizedProps = Component), workInProgress.child ); - case 10: + case 8: return ( - (Component = workInProgress.pendingProps.children), reconcileChildren( current$$1, workInProgress, - Component, + workInProgress.pendingProps.children, renderExpirationTime ), - (workInProgress.memoizedProps = Component), workInProgress.child ); - case 15: + case 12: return ( (workInProgress.effectTag |= 4), - (Component = workInProgress.pendingProps), reconcileChildren( current$$1, workInProgress, - Component.children, + workInProgress.pendingProps.children, renderExpirationTime ), - (workInProgress.memoizedProps = Component), workInProgress.child ); - case 12: + case 10: a: { - Component = workInProgress.type._context; - props = workInProgress.pendingProps; - resolvedTag = workInProgress.memoizedProps; - updateExpirationTime = props.value; - workInProgress.memoizedProps = props; - pushProvider(workInProgress, updateExpirationTime); - if (null !== resolvedTag) - if ( - ((resolvedProps = resolvedTag.value), - (updateExpirationTime = - (resolvedProps === updateExpirationTime && - (0 !== resolvedProps || - 1 / resolvedProps === 1 / updateExpirationTime)) || - (resolvedProps !== resolvedProps && - updateExpirationTime !== updateExpirationTime) - ? 0 - : ("function" === typeof Component._calculateChangedBits - ? Component._calculateChangedBits( - resolvedProps, - updateExpirationTime - ) - : 1073741823) | 0), - 0 === updateExpirationTime) - ) { + updateExpirationTime = workInProgress.type._context; + context = workInProgress.pendingProps; + getDerivedStateFromProps = workInProgress.memoizedProps; + hasContext = context.value; + pushProvider(workInProgress, hasContext); + if (null !== getDerivedStateFromProps) { + var oldValue = getDerivedStateFromProps.value; + hasContext = + (oldValue === hasContext && + (0 !== oldValue || 1 / oldValue === 1 / hasContext)) || + (oldValue !== oldValue && hasContext !== hasContext) + ? 0 + : ("function" === + typeof updateExpirationTime._calculateChangedBits + ? updateExpirationTime._calculateChangedBits( + oldValue, + hasContext + ) + : 1073741823) | 0; + if (0 === hasContext) { if ( - resolvedTag.children === props.children && + getDerivedStateFromProps.children === context.children && !didPerformWorkStackCursor.current ) { workInProgress = bailoutOnAlreadyFinishedWork( @@ -4210,113 +4370,129 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { } } else for ( - resolvedTag = workInProgress.child, - null !== resolvedTag && (resolvedTag.return = workInProgress); - null !== resolvedTag; + getDerivedStateFromProps = workInProgress.child, + null !== getDerivedStateFromProps && + (getDerivedStateFromProps.return = workInProgress); + null !== getDerivedStateFromProps; ) { - resolvedProps = resolvedTag.firstContextDependency; - if (null !== resolvedProps) { + oldValue = getDerivedStateFromProps.firstContextDependency; + if (null !== oldValue) { do { if ( - resolvedProps.context === Component && - 0 !== (resolvedProps.observedBits & updateExpirationTime) + oldValue.context === updateExpirationTime && + 0 !== (oldValue.observedBits & hasContext) ) { - 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 ( - 0 === node.childExpirationTime || - node.childExpirationTime > renderExpirationTime - ) + if (1 === getDerivedStateFromProps.tag) { + var nextFiber = createUpdate(renderExpirationTime); + nextFiber.tag = 2; + enqueueUpdate(getDerivedStateFromProps, nextFiber); + } + getDerivedStateFromProps.expirationTime < + renderExpirationTime && + (getDerivedStateFromProps.expirationTime = renderExpirationTime); + nextFiber = getDerivedStateFromProps.alternate; + null !== nextFiber && + nextFiber.expirationTime < renderExpirationTime && + (nextFiber.expirationTime = renderExpirationTime); + for ( + var node = getDerivedStateFromProps.return; + null !== node; + + ) { + nextFiber = node.alternate; + if (node.childExpirationTime < renderExpirationTime) (node.childExpirationTime = renderExpirationTime), - null !== child && - (0 === child.childExpirationTime || - child.childExpirationTime > - renderExpirationTime) && - (child.childExpirationTime = renderExpirationTime); + null !== nextFiber && + nextFiber.childExpirationTime < + renderExpirationTime && + (nextFiber.childExpirationTime = renderExpirationTime); else if ( - null !== child && - (0 === child.childExpirationTime || - child.childExpirationTime > renderExpirationTime) + null !== nextFiber && + nextFiber.childExpirationTime < renderExpirationTime ) - child.childExpirationTime = renderExpirationTime; + nextFiber.childExpirationTime = renderExpirationTime; else break; node = node.return; } } - child = resolvedTag.child; - resolvedProps = resolvedProps.next; - } while (null !== resolvedProps); + nextFiber = getDerivedStateFromProps.child; + oldValue = oldValue.next; + } while (null !== oldValue); } else - child = - 12 === resolvedTag.tag - ? resolvedTag.type === workInProgress.type + nextFiber = + 10 === getDerivedStateFromProps.tag + ? getDerivedStateFromProps.type === workInProgress.type ? null - : resolvedTag.child - : resolvedTag.child; - if (null !== child) child.return = resolvedTag; + : getDerivedStateFromProps.child + : getDerivedStateFromProps.child; + if (null !== nextFiber) + nextFiber.return = getDerivedStateFromProps; else - for (child = resolvedTag; null !== child; ) { - if (child === workInProgress) { - child = null; + for ( + nextFiber = getDerivedStateFromProps; + null !== nextFiber; + + ) { + if (nextFiber === workInProgress) { + nextFiber = null; break; } - resolvedTag = child.sibling; - if (null !== resolvedTag) { - resolvedTag.return = child.return; - child = resolvedTag; + getDerivedStateFromProps = nextFiber.sibling; + if (null !== getDerivedStateFromProps) { + getDerivedStateFromProps.return = nextFiber.return; + nextFiber = getDerivedStateFromProps; break; } - child = child.return; + nextFiber = nextFiber.return; } - resolvedTag = child; + getDerivedStateFromProps = nextFiber; } + } reconcileChildren( current$$1, workInProgress, - props.children, + context.children, renderExpirationTime ); workInProgress = workInProgress.child; } return workInProgress; - case 11: + case 9: return ( - (updateExpirationTime = workInProgress.type), - (Component = workInProgress.pendingProps), - (props = Component.children), + (context = workInProgress.type), + (hasContext = workInProgress.pendingProps), + (updateExpirationTime = hasContext.children), prepareToReadContext(workInProgress, renderExpirationTime), - (updateExpirationTime = readContext( - updateExpirationTime, - Component.unstable_observedBits - )), - (props = props(updateExpirationTime)), + (context = readContext(context, hasContext.unstable_observedBits)), + (updateExpirationTime = updateExpirationTime(context)), (workInProgress.effectTag |= 1), reconcileChildren( current$$1, workInProgress, - props, + updateExpirationTime, renderExpirationTime ), - (workInProgress.memoizedProps = Component), workInProgress.child ); - case 17: - return updatePureComponent( + case 14: + return ( + (context = workInProgress.type), + (hasContext = resolveDefaultProps( + context.type, + workInProgress.pendingProps + )), + updateMemoComponent( + current$$1, + workInProgress, + context, + hasContext, + updateExpirationTime, + renderExpirationTime + ) + ); + case 15: + return updateSimpleMemoComponent( current$$1, workInProgress, workInProgress.type, @@ -4324,20 +4500,43 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { updateExpirationTime, renderExpirationTime ); - case 18: + case 17: return ( - (props = workInProgress.type._reactResult), - (Component = workInProgress.pendingProps), - (current$$1 = updatePureComponent( - current$$1, + (updateExpirationTime = workInProgress.type), + (context = workInProgress.pendingProps), + (context = + workInProgress.elementType === updateExpirationTime + ? context + : resolveDefaultProps(updateExpirationTime, context)), + 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), + constructClassInstance( workInProgress, - props, - resolveDefaultProps(props, Component), updateExpirationTime, + context, renderExpirationTime - )), - (workInProgress.memoizedProps = Component), - current$$1 + ), + mountClassInstance( + workInProgress, + updateExpirationTime, + context, + renderExpirationTime + ), + finishClassComponent( + null, + workInProgress, + updateExpirationTime, + !0, + current$$1, + renderExpirationTime + ) ); default: invariant( @@ -4346,14 +4545,113 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { ); } } -function appendAllChildren(parent, workInProgress) { +var appendAllChildren = void 0, + updateHostContainer = void 0, + updateHostComponent$1 = void 0, + updateHostText$1 = void 0; +appendAllChildren = function( + parent, + workInProgress, + needsVisibilityToggle, + isHidden +) { + for (var node = workInProgress.child; null !== node; ) { + a: if (5 === node.tag) { + var instance = node.stateNode; + if (needsVisibilityToggle) { + var props = node.memoizedProps, + type = node.type; + instance = isHidden + ? cloneHiddenInstance(instance, type, props, node) + : cloneUnhiddenInstance(instance, type, props, node); + node.stateNode = instance; + } + FabricUIManager.appendChild(parent.node, instance.node); + } else if (6 === node.tag) { + instance = node.stateNode; + if (needsVisibilityToggle) { + instance = node.memoizedProps; + props = requiredContext(rootInstanceStackCursor.current); + type = requiredContext(contextStackCursor$1.current); + if (isHidden) throw Error("Not yet implemented."); + instance = createTextInstance(instance, props, type, workInProgress); + node.stateNode = instance; + } + FabricUIManager.appendChild(parent.node, instance.node); + } else if (4 !== node.tag) { + if ( + 13 === node.tag && + ((props = node.alternate), + null !== props && + ((instance = null !== node.memoizedState), + (null !== props.memoizedState) !== instance)) + ) { + props = instance ? node.child : node; + null !== props && appendAllChildren(parent, props, !0, instance); + 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; ) { - if (7 === node.tag || 8 === node.tag) - FabricUIManager.appendChild(parent.node, node.stateNode.node); - else if (6 !== node.tag && null !== node.child) { - node.child.return = node; - node = node.child; - continue; + a: if (5 === node.tag) { + var instance = node.stateNode; + if (needsVisibilityToggle) { + var props = node.memoizedProps, + type = node.type; + instance = isHidden + ? cloneHiddenInstance(instance, type, props, node) + : cloneUnhiddenInstance(instance, type, props, node); + node.stateNode = instance; + } + FabricUIManager.appendChildToSet(containerChildSet, instance.node); + } else if (6 === node.tag) { + instance = node.stateNode; + if (needsVisibilityToggle) { + instance = node.memoizedProps; + props = requiredContext(rootInstanceStackCursor.current); + type = requiredContext(contextStackCursor$1.current); + if (isHidden) throw Error("Not yet implemented."); + instance = createTextInstance(instance, props, type, workInProgress); + node.stateNode = instance; + } + FabricUIManager.appendChildToSet(containerChildSet, instance.node); + } else if (4 !== node.tag) { + if ( + 13 === node.tag && + ((props = node.alternate), + null !== props && + ((instance = null !== node.memoizedState), + (null !== props.memoizedState) !== instance)) + ) { + props = instance ? node.child : node; + null !== props && + appendAllChildrenToContainer(containerChildSet, props, !0, instance); + break a; + } + if (null !== node.child) { + node.child.return = node; + node = node.child; + continue; + } } if (node === workInProgress) break; for (; null === node.sibling; ) { @@ -4364,30 +4662,12 @@ function appendAllChildren(parent, workInProgress) { node = node.sibling; } } -var updateHostContainer = void 0, - updateHostComponent$1 = void 0, - updateHostText$1 = void 0; updateHostContainer = function(workInProgress) { var portalOrRoot = workInProgress.stateNode; if (null !== workInProgress.firstEffect) { var container = portalOrRoot.containerInfo, newChildSet = FabricUIManager.createChildSet(container); - a: for (var node = workInProgress.child; null !== node; ) { - if (7 === node.tag || 8 === node.tag) - FabricUIManager.appendChildToSet(newChildSet, node.stateNode.node); - else if (6 !== node.tag && null !== node.child) { - node.child.return = node; - node = node.child; - continue; - } - if (node === workInProgress) break a; - for (; null === node.sibling; ) { - if (null === node.return || node.return === workInProgress) break a; - node = node.return; - } - node.sibling.return = node.return; - node = node.sibling; - } + appendAllChildrenToContainer(newChildSet, workInProgress, !1, !1); portalOrRoot.pendingChildren = newChildSet; workInProgress.effectTag |= 4; FabricUIManager.completeRoot(container, newChildSet); @@ -4434,7 +4714,7 @@ updateHostComponent$1 = function(current, workInProgress, type, newProps) { (workInProgress.stateNode = type), current ? (workInProgress.effectTag |= 4) - : appendAllChildren(type, workInProgress)); + : appendAllChildren(type, workInProgress, !1, !1)); } }; updateHostText$1 = function(current, workInProgress, oldText, newText) { @@ -4468,7 +4748,6 @@ function logCapturedError(capturedError) { : Error("Unspecified error at:" + componentStack); ExceptionsManager.handleException(error, !1); } -var emptyObject$1 = {}; function logError(boundary, errorInfo) { var source = errorInfo.source, stack = errorInfo.stack; @@ -4485,7 +4764,7 @@ function logError(boundary, errorInfo) { willRetry: !1 }; null !== boundary && - 2 === boundary.tag && + 1 === boundary.tag && ((errorInfo.errorBoundary = boundary.stateNode), (errorInfo.errorBoundaryName = getComponentName(boundary.type)), (errorInfo.errorBoundaryFound = !0), @@ -4511,16 +4790,22 @@ function safelyDetachRef(current$$1) { } function commitWork(current$$1, finishedWork) { switch (finishedWork.tag) { - case 2: - case 3: - break; - case 7: - break; - case 8: + case 0: + case 11: + case 14: + case 15: + return; + } + switch (finishedWork.tag) { + case 1: break; case 5: + break; case 6: break; + case 3: + case 4: + break; default: invariant( !1, @@ -4528,9 +4813,6 @@ function commitWork(current$$1, finishedWork) { ); } } -function NoopComponent() { - return null; -} function createRootErrorUpdate(fiber, errorInfo, expirationTime) { expirationTime = createUpdate(expirationTime); expirationTime.tag = 3; @@ -4576,7 +4858,7 @@ function throwException( value, renderExpirationTime ) { - sourceFiber.effectTag |= 512; + sourceFiber.effectTag |= 1024; sourceFiber.firstEffect = sourceFiber.lastEffect = null; if ( null !== value && @@ -4588,49 +4870,54 @@ function throwException( var earliestTimeoutMs = -1, startTimeMs = -1; do { - if (16 === value.tag) { - var current = value.alternate; + if (13 === value.tag) { + var current$$1 = value.alternate; if ( - null !== current && - !0 === current.memoizedState && - null !== current.stateNode + null !== current$$1 && + ((current$$1 = current$$1.memoizedState), null !== current$$1) ) { - startTimeMs = 10 * (current.stateNode.timedOutAt - 2); + startTimeMs = 10 * (1073741822 - current$$1.timedOutAt); break; } - current = value.pendingProps.maxDuration; - if ("number" === typeof current) - if (0 >= current) earliestTimeoutMs = 0; - else if (-1 === earliestTimeoutMs || current < earliestTimeoutMs) - earliestTimeoutMs = current; + current$$1 = value.pendingProps.maxDuration; + if ("number" === typeof current$$1) + if (0 >= current$$1) earliestTimeoutMs = 0; + else if (-1 === earliestTimeoutMs || current$$1 < earliestTimeoutMs) + earliestTimeoutMs = current$$1; } value = value.return; } while (null !== value); value = returnFiber; do { - if (16 === value.tag && !value.memoizedState) { + if ((current$$1 = 13 === value.tag)) + current$$1 = + void 0 === value.memoizedProps.fallback + ? !1 + : null === value.memoizedState; + if (current$$1) { returnFiber = retrySuspendedRoot.bind( null, root, value, - 0 === (value.mode & 1) ? 1 : renderExpirationTime + sourceFiber, + 0 === (value.mode & 1) ? 1073741823 : renderExpirationTime ); returnFiber = tracing.unstable_wrap(returnFiber); thenable.then(returnFiber, returnFiber); - if (0 === (value.mode & 2)) { - value.effectTag |= 4; + if (0 === (value.mode & 1)) { + value.effectTag |= 64; reconcileChildren( sourceFiber.alternate, sourceFiber, null, renderExpirationTime ); - sourceFiber.effectTag &= -513; - 4 === sourceFiber.tag && (sourceFiber.tag = 0); - if (2 === sourceFiber.tag || 3 === sourceFiber.tag) - (sourceFiber.effectTag &= -421), - null === sourceFiber.alternate && - ((sourceFiber.tag = 0), (sourceFiber.type = NoopComponent)); + sourceFiber.effectTag &= -1025; + sourceFiber.effectTag &= -933; + 1 === sourceFiber.tag && + null === sourceFiber.alternate && + (sourceFiber.tag = 17); + sourceFiber.expirationTime = renderExpirationTime; return; } -1 === earliestTimeoutMs @@ -4638,24 +4925,26 @@ function throwException( : (-1 === startTimeMs && (startTimeMs = 10 * - (findEarliestOutstandingPriorityLevel( - root, - renderExpirationTime - ) - - 2) - + (1073741822 - + findEarliestOutstandingPriorityLevel( + root, + renderExpirationTime + )) - 5e3), (root = startTimeMs + earliestTimeoutMs)); 0 <= root && nextLatestAbsoluteTimeoutMs < root && (nextLatestAbsoluteTimeoutMs = root); - value.effectTag |= 1024; + value.effectTag |= 2048; value.expirationTime = renderExpirationTime; return; } value = value.return; } while (null !== value); value = Error( - "An update was suspended, but no placeholder UI was provided." + (getComponentName(sourceFiber.type) || "A React component") + + " suspended while rendering, but no fallback UI was specified.\n\nAdd a component higher in the tree to provide a loading indicator or placeholder to display." + + getStackByFiberInDevAndProd(sourceFiber) ); } nextRenderDidError = !0; @@ -4663,9 +4952,9 @@ function throwException( root = returnFiber; do { switch (root.tag) { - case 5: + case 3: sourceFiber = value; - root.effectTag |= 1024; + root.effectTag |= 2048; root.expirationTime = renderExpirationTime; renderExpirationTime = createRootErrorUpdate( root, @@ -4674,8 +4963,7 @@ function throwException( ); enqueueCapturedUpdate(root, renderExpirationTime); return; - case 2: - case 3: + case 1: if ( ((sourceFiber = value), (returnFiber = root.type), @@ -4687,7 +4975,7 @@ function throwException( (null === legacyErrorBoundariesThatAlreadyFailed || !legacyErrorBoundariesThatAlreadyFailed.has(thenable))))) ) { - root.effectTag |= 1024; + root.effectTag |= 2048; root.expirationTime = renderExpirationTime; renderExpirationTime = createClassErrorUpdate( root, @@ -4703,24 +4991,14 @@ function throwException( } function unwindWork(workInProgress) { switch (workInProgress.tag) { - case 2: + case 1: isContextProvider(workInProgress.type) && popContext(workInProgress); var effectTag = workInProgress.effectTag; - return effectTag & 1024 - ? ((workInProgress.effectTag = (effectTag & -1025) | 64), + return effectTag & 2048 + ? ((workInProgress.effectTag = (effectTag & -2049) | 64), workInProgress) : null; case 3: - return ( - isContextProvider(workInProgress.type._reactResult) && - popContext(workInProgress), - (effectTag = workInProgress.effectTag), - effectTag & 1024 - ? ((workInProgress.effectTag = (effectTag & -1025) | 64), - workInProgress) - : null - ); - case 5: return ( popHostContainer(workInProgress), popTopLevelContextObject(workInProgress), @@ -4729,28 +5007,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 & -1025) | 64), + (workInProgress.effectTag = (effectTag & -2049) | 64), workInProgress ); - case 7: + case 5: return popHostContext(workInProgress), null; - case 16: + case 13: return ( (effectTag = workInProgress.effectTag), - effectTag & 1024 - ? ((workInProgress.effectTag = (effectTag & -1025) | 64), + effectTag & 2048 + ? ((workInProgress.effectTag = (effectTag & -2049) | 64), workInProgress) : null ); - case 6: + case 4: return popHostContainer(workInProgress), null; - case 12: + case 10: return popProvider(workInProgress), null; default: return null; } } -var Dispatcher = { readContext: readContext }, +var DispatcherWithoutHooks = { readContext: readContext }, ReactCurrentOwner$2 = ReactSharedInternals.ReactCurrentOwner; invariant( null != tracing.__interactionsRef && @@ -4765,6 +5043,8 @@ var isWorking = !1, nextRenderDidError = !1, nextEffect = null, isCommitting$1 = !1, + passiveEffectCallbackHandle = null, + passiveEffectCallback = null, legacyErrorBoundariesThatAlreadyFailed = null; function resetStack() { if (null !== nextUnitOfWork) @@ -4775,7 +5055,7 @@ function resetStack() { ) { var interruptedWork$jscomp$0 = interruptedWork; switch (interruptedWork$jscomp$0.tag) { - case 2: + case 1: var childContextTypes = interruptedWork$jscomp$0.type.childContextTypes; null !== childContextTypes && @@ -4783,23 +5063,16 @@ function resetStack() { popContext(interruptedWork$jscomp$0); break; case 3: - childContextTypes = - interruptedWork$jscomp$0.type._reactResult.childContextTypes; - null !== childContextTypes && - void 0 !== childContextTypes && - popContext(interruptedWork$jscomp$0); - break; - case 5: popHostContainer(interruptedWork$jscomp$0); popTopLevelContextObject(interruptedWork$jscomp$0); break; - case 7: + case 5: popHostContext(interruptedWork$jscomp$0); break; - case 6: + case 4: popHostContainer(interruptedWork$jscomp$0); break; - case 12: + case 10: popProvider(interruptedWork$jscomp$0); } interruptedWork = interruptedWork.return; @@ -4840,23 +5113,46 @@ function commitAllHostEffects() { "function" === typeof onCommitFiberUnmount && onCommitFiberUnmount(current$$1$jscomp$0); switch (current$$1$jscomp$0.tag) { - case 2: - case 3: + case 0: + case 11: + case 14: + case 15: + var updateQueue = current$$1$jscomp$0.updateQueue; + if ( + null !== updateQueue && + ((updateQueue = updateQueue.lastEffect), null !== updateQueue) + ) { + var effect = (updateQueue = updateQueue.next); + do { + var destroy = effect.destroy; + if (null !== destroy) { + var current$$1$jscomp$1 = current$$1$jscomp$0; + try { + destroy(); + } catch (error) { + captureCommitPhaseError(current$$1$jscomp$1, error); + } + } + effect = effect.next; + } while (effect !== updateQueue); + } + break; + case 1: safelyDetachRef(current$$1$jscomp$0); - var instance = current$$1$jscomp$0.stateNode; - if ("function" === typeof instance.componentWillUnmount) + updateQueue = current$$1$jscomp$0.stateNode; + if ("function" === typeof updateQueue.componentWillUnmount) try { - (instance.props = current$$1$jscomp$0.memoizedProps), - (instance.state = current$$1$jscomp$0.memoizedState), - instance.componentWillUnmount(); + (updateQueue.props = current$$1$jscomp$0.memoizedProps), + (updateQueue.state = current$$1$jscomp$0.memoizedState), + updateQueue.componentWillUnmount(); } catch (unmountError) { captureCommitPhaseError(current$$1$jscomp$0, unmountError); } break; - case 7: + case 5: safelyDetachRef(current$$1$jscomp$0); break; - case 6: + case 4: FabricUIManager.createChildSet( current$$1$jscomp$0.stateNode.containerInfo ); @@ -4884,30 +5180,34 @@ function commitAllHostEffects() { } function commitBeforeMutationLifecycles() { for (; null !== nextEffect; ) { - if (nextEffect.effectTag & 256) { - var current$$1 = nextEffect.alternate; + if (nextEffect.effectTag & 256) a: { - var finishedWork = nextEffect; + var current$$1 = nextEffect.alternate, + finishedWork = nextEffect; switch (finishedWork.tag) { - case 2: - case 3: + case 0: + case 11: + case 15: + break a; + case 1: if (finishedWork.effectTag & 256 && null !== current$$1) { var prevProps = current$$1.memoizedProps, prevState = current$$1.memoizedState; current$$1 = finishedWork.stateNode; - current$$1.props = finishedWork.memoizedProps; - current$$1.state = finishedWork.memoizedState; finishedWork = current$$1.getSnapshotBeforeUpdate( - prevProps, + finishedWork.elementType === finishedWork.type + ? prevProps + : resolveDefaultProps(finishedWork.type, prevProps), prevState ); current$$1.__reactInternalSnapshotBeforeUpdate = finishedWork; } break a; + case 3: case 5: - case 7: - case 8: case 6: + case 4: + case 17: break a; default: invariant( @@ -4916,7 +5216,6 @@ function commitBeforeMutationLifecycles() { ); } } - } nextEffect = nextEffect.nextEffect; } } @@ -4932,47 +5231,47 @@ function commitAllLifeCycles( finishedWork = nextEffect, committedExpirationTime = committedExpirationTime$jscomp$0; switch (finishedWork.tag) { - case 2: - case 3: + case 0: + case 11: + case 15: + break; + case 1: finishedRoot = finishedWork.stateNode; if (finishedWork.effectTag & 4) - if (null === current$$1) - (finishedRoot.props = finishedWork.memoizedProps), - (finishedRoot.state = finishedWork.memoizedState), - finishedRoot.componentDidMount(); + if (null === current$$1) finishedRoot.componentDidMount(); else { - var prevProps = current$$1.memoizedProps; - current$$1 = current$$1.memoizedState; - finishedRoot.props = finishedWork.memoizedProps; - finishedRoot.state = finishedWork.memoizedState; + var prevProps = + finishedWork.elementType === finishedWork.type + ? current$$1.memoizedProps + : resolveDefaultProps( + finishedWork.type, + current$$1.memoizedProps + ); finishedRoot.componentDidUpdate( prevProps, - current$$1, + current$$1.memoizedState, finishedRoot.__reactInternalSnapshotBeforeUpdate ); } current$$1 = finishedWork.updateQueue; null !== current$$1 && - ((finishedRoot.props = finishedWork.memoizedProps), - (finishedRoot.state = finishedWork.memoizedState), commitUpdateQueue( finishedWork, current$$1, finishedRoot, committedExpirationTime - )); + ); break; - case 5: + case 3: current$$1 = finishedWork.updateQueue; if (null !== current$$1) { finishedRoot = null; if (null !== finishedWork.child) switch (finishedWork.child.tag) { - case 7: + case 5: finishedRoot = finishedWork.child.stateNode.canonical; break; - case 2: - case 3: + case 1: finishedRoot = finishedWork.child.stateNode; } commitUpdateQueue( @@ -4983,7 +5282,7 @@ function commitAllLifeCycles( ); } break; - case 7: + case 5: null === current$$1 && finishedWork.effectTag & 4 && invariant( @@ -4991,11 +5290,11 @@ function commitAllLifeCycles( "The current renderer does not support mutation. This error is likely caused by a bug in React. Please file an issue." ); break; - case 8: - break; case 6: break; - case 15: + case 4: + break; + case 12: committedExpirationTime = finishedWork.memoizedProps.onRender; committedExpirationTime( finishedWork.memoizedProps.id, @@ -5007,14 +5306,9 @@ function commitAllLifeCycles( finishedRoot.memoizedInteractions ); break; - case 16: - 0 === (finishedWork.mode & 2) - ? ((finishedWork.updateQueue = emptyObject$1), - scheduleWork(finishedWork, 1)) - : ((committedExpirationTime = requestCurrentTime()), - (finishedWork.stateNode = { - timedOutAt: committedExpirationTime - })); + case 13: + break; + case 17: break; default: invariant( @@ -5026,18 +5320,21 @@ function commitAllLifeCycles( if (effectTag & 128 && ((effectTag = nextEffect.ref), null !== effectTag)) { finishedWork = nextEffect.stateNode; switch (nextEffect.tag) { - case 7: + case 5: finishedWork = finishedWork.canonical; } "function" === typeof effectTag ? effectTag(finishedWork) : (effectTag.current = finishedWork); } - effectTag = nextEffect.nextEffect; - nextEffect.nextEffect = null; - nextEffect = effectTag; + nextEffect = nextEffect.nextEffect; } } +function flushPassiveEffects() { + null !== passiveEffectCallback && + (scheduler.unstable_cancelCallback(passiveEffectCallbackHandle), + passiveEffectCallback()); +} function commitRoot(root, finishedWork) { isCommitting$1 = isWorking = !0; invariant( @@ -5054,9 +5351,7 @@ function commitRoot(root, finishedWork) { childExpirationTimeBeforeCommit = finishedWork.childExpirationTime; markCommittedPriorityLevels( root, - 0 === updateExpirationTimeBeforeCommit || - (0 !== childExpirationTimeBeforeCommit && - childExpirationTimeBeforeCommit < updateExpirationTimeBeforeCommit) + childExpirationTimeBeforeCommit > updateExpirationTimeBeforeCommit ? childExpirationTimeBeforeCommit : updateExpirationTimeBeforeCommit ); @@ -5127,8 +5422,7 @@ function commitRoot(root, finishedWork) { childExpirationTimeBeforeCommit = finishedWork.expirationTime; finishedWork = finishedWork.childExpirationTime; var earliestRemainingTimeAfterCommit = - 0 === childExpirationTimeBeforeCommit || - (0 !== finishedWork && finishedWork < childExpirationTimeBeforeCommit) + finishedWork > childExpirationTimeBeforeCommit ? finishedWork : childExpirationTimeBeforeCommit; 0 === earliestRemainingTimeAfterCommit && @@ -5153,21 +5447,18 @@ function commitRoot(root, finishedWork) { scheduledInteractions, scheduledExpirationTime ) { - if ( - 0 === earliestRemainingTimeAfterCommit || - scheduledExpirationTime < earliestRemainingTimeAfterCommit - ) - pendingInteractionMap.delete(scheduledExpirationTime), - scheduledInteractions.forEach(function(interaction) { - interaction.__count--; - if (null !== subscriber && 0 === interaction.__count) - try { - subscriber.onInteractionScheduledWorkCompleted(interaction); - } catch (error) { - hasUnhandledError || - ((hasUnhandledError = !0), (unhandledError = error)); - } - }); + scheduledExpirationTime > earliestRemainingTimeAfterCommit && + (pendingInteractionMap.delete(scheduledExpirationTime), + scheduledInteractions.forEach(function(interaction) { + interaction.__count--; + if (null !== subscriber && 0 === interaction.__count) + try { + subscriber.onInteractionScheduledWorkCompleted(interaction); + } catch (error) { + hasUnhandledError || + ((hasUnhandledError = !0), (unhandledError = error)); + } + })); }); } } @@ -5176,198 +5467,208 @@ function completeUnitOfWork(workInProgress) { var current$$1 = workInProgress.alternate, returnFiber = workInProgress.return, siblingFiber = workInProgress.sibling; - if (0 === (workInProgress.effectTag & 512)) { + if (0 === (workInProgress.effectTag & 1024)) { + nextUnitOfWork = workInProgress; if (workInProgress.mode & 4) { var fiber = workInProgress; profilerStartTime = now$1(); 0 > fiber.actualStartTime && (fiber.actualStartTime = now$1()); } - var current = current$$1; - current$$1 = workInProgress; - fiber = current$$1.pendingProps; - switch (current$$1.tag) { - case 0: - 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; - fiber.pendingContext && - ((fiber.context = fiber.pendingContext), - (fiber.pendingContext = null)); - if (null === current || null === current.child) - current$$1.effectTag &= -3; - updateHostContainer(current$$1); - break; - case 7: - popHostContext(current$$1); - var rootContainerInstance = requiredContext( + a: { + var current = current$$1; + current$$1 = workInProgress; + var renderExpirationTime = nextRenderExpirationTime; + fiber = current$$1.pendingProps; + switch (current$$1.tag) { + case 2: + break; + case 16: + break; + case 15: + case 0: + break; + case 1: + isContextProvider(current$$1.type) && popContext(current$$1); + break; + case 3: + popHostContainer(current$$1); + popTopLevelContextObject(current$$1); + fiber = current$$1.stateNode; + fiber.pendingContext && + ((fiber.context = fiber.pendingContext), + (fiber.pendingContext = null)); + if (null === current || null === current.child) + current$$1.effectTag &= -3; + updateHostContainer(current$$1); + break; + case 5: + popHostContext(current$$1); + renderExpirationTime = requiredContext( rootInstanceStackCursor.current - ), - type = current$$1.type; - if (null !== current && null != current$$1.stateNode) - updateHostComponent$1( - current, - current$$1, - type, - fiber, - rootContainerInstance - ), - current.ref !== current$$1.ref && (current$$1.effectTag |= 128); - else if (fiber) { - var currentHostContext = requiredContext( - contextStackCursor$1.current - ), - internalInstanceHandle = current$$1; - current = nextReactTag; - nextReactTag += 2; - var viewConfig = ReactNativeViewConfigRegistry.get(type); - invariant( - "RCTView" !== type || !currentHostContext.isInAParentText, - "Nesting of within is not currently supported." - ); - type = diffProperties( - null, - emptyObject, - fiber, - viewConfig.validAttributes - ); - rootContainerInstance = FabricUIManager.createNode( - current, - viewConfig.uiViewClassName, - rootContainerInstance, - type, - internalInstanceHandle - ); - fiber = new ReactFabricHostComponent(current, viewConfig, fiber); - fiber = { node: rootContainerInstance, canonical: fiber }; - appendAllChildren(fiber, current$$1); - current$$1.stateNode = fiber; - null !== current$$1.ref && (current$$1.effectTag |= 128); - } else - invariant( - null !== current$$1.stateNode, - "We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue." ); - break; - case 8: - current && null != current$$1.stateNode - ? updateHostText$1( + var type = current$$1.type; + if (null !== current && null != current$$1.stateNode) + updateHostComponent$1( current, current$$1, - current.memoizedProps, - fiber - ) - : ("string" !== typeof fiber && - invariant( - null !== current$$1.stateNode, - "We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue." + type, + fiber, + renderExpirationTime + ), + current.ref !== current$$1.ref && (current$$1.effectTag |= 128); + else if (fiber) { + var currentHostContext = requiredContext( + contextStackCursor$1.current ), - (rootContainerInstance = requiredContext( - rootInstanceStackCursor.current - )), - (current = requiredContext(contextStackCursor$1.current)), - (current$$1.stateNode = createTextInstance( + internalInstanceHandle = current$$1; + current = nextReactTag; + nextReactTag += 2; + var viewConfig = ReactNativeViewConfigRegistry.get(type); + invariant( + "RCTView" !== type || !currentHostContext.isInAParentText, + "Nesting of within is not currently supported." + ); + type = diffProperties( + null, + emptyObject, fiber, - rootContainerInstance, + viewConfig.validAttributes + ); + renderExpirationTime = FabricUIManager.createNode( current, - current$$1 - ))); - break; - case 13: - case 14: - break; - case 16: - break; - case 9: - break; - 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: - 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, - "Unknown unit of work tag. This error is likely caused by a bug in React. Please file an issue." - ); + viewConfig.uiViewClassName, + renderExpirationTime, + type, + internalInstanceHandle + ); + fiber = new ReactFabricHostComponent(current, viewConfig, fiber); + fiber = { node: renderExpirationTime, canonical: fiber }; + appendAllChildren(fiber, current$$1, !1, !1); + current$$1.stateNode = fiber; + null !== current$$1.ref && (current$$1.effectTag |= 128); + } else + invariant( + null !== current$$1.stateNode, + "We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue." + ); + break; + case 6: + current && null != current$$1.stateNode + ? updateHostText$1( + current, + current$$1, + current.memoizedProps, + fiber + ) + : ("string" !== typeof fiber && + invariant( + null !== current$$1.stateNode, + "We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue." + ), + (current = requiredContext(rootInstanceStackCursor.current)), + (renderExpirationTime = requiredContext( + contextStackCursor$1.current + )), + (current$$1.stateNode = createTextInstance( + fiber, + current, + renderExpirationTime, + current$$1 + ))); + break; + case 11: + break; + case 13: + fiber = current$$1.memoizedState; + if (0 !== (current$$1.effectTag & 64)) { + current$$1.expirationTime = renderExpirationTime; + nextUnitOfWork = current$$1; + break a; + } + fiber = null !== fiber; + viewConfig = null !== current && null !== current.memoizedState; + null !== current && + !fiber && + viewConfig && + ((current = current.child.sibling), + null !== current && + reconcileChildFibers( + current$$1, + current, + null, + renderExpirationTime + )); + if ( + fiber !== viewConfig || + (0 === (current$$1.effectTag & 1) && fiber) + ) + current$$1.effectTag |= 4; + break; + case 7: + break; + case 8: + break; + case 12: + break; + case 4: + popHostContainer(current$$1); + updateHostContainer(current$$1); + break; + case 10: + popProvider(current$$1); + break; + case 9: + break; + case 14: + break; + case 17: + isContextProvider(current$$1.type) && popContext(current$$1); + break; + default: + invariant( + !1, + "Unknown unit of work tag. This error is likely caused by a bug in React. Please file an issue." + ); + } + nextUnitOfWork = null; } - nextUnitOfWork = null; workInProgress.mode & 4 && stopProfilerTimerIfRunningAndRecordDelta(workInProgress, !1); current$$1 = workInProgress; if ( - 1073741823 === nextRenderExpirationTime || - 1073741823 !== current$$1.childExpirationTime + 1 === nextRenderExpirationTime || + 1 !== current$$1.childExpirationTime ) { fiber = 0; if (current$$1.mode & 4) { - rootContainerInstance = current$$1.actualDuration; - current = current$$1.selfBaseDuration; + current = current$$1.actualDuration; + renderExpirationTime = current$$1.selfBaseDuration; viewConfig = null === current$$1.alternate || current$$1.child !== current$$1.alternate.child; - for (type = current$$1.child; null !== type; ) { - internalInstanceHandle = type.expirationTime; - currentHostContext = type.childExpirationTime; - if ( - 0 === fiber || - (0 !== internalInstanceHandle && internalInstanceHandle < fiber) - ) - fiber = internalInstanceHandle; - if ( - 0 === fiber || - (0 !== currentHostContext && currentHostContext < fiber) - ) - fiber = currentHostContext; - viewConfig && (rootContainerInstance += type.actualDuration); - current += type.treeBaseDuration; - type = type.sibling; - } - current$$1.actualDuration = rootContainerInstance; - current$$1.treeBaseDuration = current; + for (type = current$$1.child; null !== type; ) + (internalInstanceHandle = type.expirationTime), + (currentHostContext = type.childExpirationTime), + internalInstanceHandle > fiber && + (fiber = internalInstanceHandle), + currentHostContext > fiber && (fiber = currentHostContext), + viewConfig && (current += type.actualDuration), + (renderExpirationTime += type.treeBaseDuration), + (type = type.sibling); + current$$1.actualDuration = current; + current$$1.treeBaseDuration = renderExpirationTime; } else - for ( - rootContainerInstance = current$$1.child; - null !== rootContainerInstance; - - ) { - current = rootContainerInstance.expirationTime; - viewConfig = rootContainerInstance.childExpirationTime; - if (0 === fiber || (0 !== current && current < fiber)) - fiber = current; - if (0 === fiber || (0 !== viewConfig && viewConfig < fiber)) - fiber = viewConfig; - rootContainerInstance = rootContainerInstance.sibling; - } + for (current = current$$1.child; null !== current; ) + (renderExpirationTime = current.expirationTime), + (viewConfig = current.childExpirationTime), + renderExpirationTime > fiber && (fiber = renderExpirationTime), + viewConfig > fiber && (fiber = viewConfig), + (current = current.sibling); current$$1.childExpirationTime = fiber; } + if (null !== nextUnitOfWork) return nextUnitOfWork; null !== returnFiber && - 0 === (returnFiber.effectTag & 512) && + 0 === (returnFiber.effectTag & 1024) && (null === returnFiber.firstEffect && (returnFiber.firstEffect = workInProgress.firstEffect), null !== workInProgress.lastEffect && @@ -5380,23 +5681,19 @@ function completeUnitOfWork(workInProgress) { : (returnFiber.firstEffect = workInProgress), (returnFiber.lastEffect = workInProgress))); } else { - workInProgress.mode & 4 && + if (workInProgress.mode & 4) { stopProfilerTimerIfRunningAndRecordDelta(workInProgress, !1); - workInProgress = unwindWork(workInProgress, nextRenderExpirationTime); - if (null !== workInProgress) { - if (workInProgress.mode & 4) { - returnFiber = workInProgress.actualDuration; - for (siblingFiber = workInProgress.child; null !== siblingFiber; ) - (returnFiber += siblingFiber.actualDuration), - (siblingFiber = siblingFiber.sibling); - workInProgress.actualDuration = returnFiber; - } - workInProgress.effectTag &= 511; - return workInProgress; + current$$1 = workInProgress.actualDuration; + for (fiber = workInProgress.child; null !== fiber; ) + (current$$1 += fiber.actualDuration), (fiber = fiber.sibling); + workInProgress.actualDuration = current$$1; } + workInProgress = unwindWork(workInProgress, nextRenderExpirationTime); + if (null !== workInProgress) + return (workInProgress.effectTag &= 1023), workInProgress; null !== returnFiber && ((returnFiber.firstEffect = returnFiber.lastEffect = null), - (returnFiber.effectTag |= 512)); + (returnFiber.effectTag |= 1024)); } if (null !== siblingFiber) return siblingFiber; if (null !== returnFiber) workInProgress = returnFiber; @@ -5411,19 +5708,21 @@ function performUnitOfWork(workInProgress) { 0 > workInProgress.actualStartTime && (workInProgress.actualStartTime = now$1())); current$$1 = beginWork(current$$1, workInProgress, nextRenderExpirationTime); + workInProgress.memoizedProps = workInProgress.pendingProps; workInProgress.mode & 4 && stopProfilerTimerIfRunningAndRecordDelta(workInProgress, !0); null === current$$1 && (current$$1 = completeUnitOfWork(workInProgress)); ReactCurrentOwner$2.current = null; return current$$1; } -function renderRoot(root, isYieldy, isExpired) { +function renderRoot(root, isYieldy) { invariant( !isWorking, "renderRoot was called recursively. This error is likely caused by a bug in React. Please file an issue." ); + flushPassiveEffects(); isWorking = !0; - ReactCurrentOwner$2.currentDispatcher = Dispatcher; + ReactCurrentOwner$2.currentDispatcher = DispatcherWithoutHooks; var expirationTime = root.nextExpirationTimeToWorkOn; if ( expirationTime !== nextRenderExpirationTime || @@ -5444,7 +5743,7 @@ function renderRoot(root, isYieldy, isExpired) { scheduledInteractions, scheduledExpirationTime ) { - scheduledExpirationTime <= expirationTime && + scheduledExpirationTime >= expirationTime && scheduledInteractions.forEach(function(interaction) { return interactions.add(interaction); }); @@ -5470,15 +5769,20 @@ function renderRoot(root, isYieldy, isExpired) { do { try { if (isYieldy) - for (; null !== nextUnitOfWork && !shouldYield(); ) + for (; null !== nextUnitOfWork && !shouldYieldToRenderer(); ) nextUnitOfWork = performUnitOfWork(nextUnitOfWork); else for (; null !== nextUnitOfWork; ) nextUnitOfWork = performUnitOfWork(nextUnitOfWork); } catch (thrownValue) { - if (null === nextUnitOfWork) + if ( + ((lastContextWithAllBitsObserved = lastContextDependency = currentlyRenderingFiber = null), + null === nextUnitOfWork) + ) (threadID = !0), onUncaughtError(thrownValue); else { + nextUnitOfWork.mode & 4 && + stopProfilerTimerIfRunningAndRecordDelta(nextUnitOfWork, !0); invariant( null !== nextUnitOfWork, "Failed to replay rendering after an error. This is likely caused by a bug in React. Please file an issue with a reproducing case to help us find it." @@ -5507,165 +5811,149 @@ function renderRoot(root, isYieldy, isExpired) { if (threadID) (nextRoot = null), (root.finishedWork = null); else if (null !== nextUnitOfWork) root.finishedWork = null; else { - isYieldy = root.current.alternate; + subscriber = root.current.alternate; invariant( - null !== isYieldy, + null !== subscriber, "Finished root should have a work-in-progress. This error is likely caused by a bug in React. Please file an issue." ); nextRoot = null; if (nextRenderDidError) { if (hasLowerPriorityWork(root, expirationTime)) { markSuspendedPriorityLevel(root, expirationTime); - onSuspend(root, isYieldy, expirationTime, root.expirationTime, -1); + onSuspend(root, subscriber, expirationTime, root.expirationTime, -1); return; } - if (!root.didError && !isExpired) { + if (!root.didError && isYieldy) { root.didError = !0; - isExpired = root.nextExpirationTimeToWorkOn = expirationTime; - subscriber = root.expirationTime = 1; - onSuspend(root, isYieldy, isExpired, subscriber, -1); + isYieldy = root.nextExpirationTimeToWorkOn = expirationTime; + threadID = root.expirationTime = 1073741823; + onSuspend(root, subscriber, isYieldy, threadID, -1); return; } } - isExpired || -1 === nextLatestAbsoluteTimeoutMs - ? onComplete(root, isYieldy, expirationTime) - : (markSuspendedPriorityLevel(root, expirationTime), - (isExpired = + isYieldy && -1 !== nextLatestAbsoluteTimeoutMs + ? (markSuspendedPriorityLevel(root, expirationTime), + (isYieldy = 10 * - (findEarliestOutstandingPriorityLevel(root, expirationTime) - 2)), - isExpired < nextLatestAbsoluteTimeoutMs && - (nextLatestAbsoluteTimeoutMs = isExpired), - (isExpired = 10 * (requestCurrentTime() - 2)), - (isExpired = nextLatestAbsoluteTimeoutMs - isExpired), + (1073741822 - + findEarliestOutstandingPriorityLevel(root, expirationTime))), + isYieldy < nextLatestAbsoluteTimeoutMs && + (nextLatestAbsoluteTimeoutMs = isYieldy), + (isYieldy = 10 * (1073741822 - requestCurrentTime())), + (isYieldy = nextLatestAbsoluteTimeoutMs - isYieldy), onSuspend( root, - isYieldy, + subscriber, expirationTime, root.expirationTime, - 0 > isExpired ? 0 : isExpired - )); + 0 > isYieldy ? 0 : isYieldy + )) + : onComplete(root, subscriber, expirationTime); } } -function captureCommitPhaseError(fiber, error) { - var JSCompiler_inline_result; - a: { - invariant( - !isWorking || isCommitting$1, - "dispatch: Cannot dispatch during the render phase." - ); - for ( - JSCompiler_inline_result = fiber.return; - null !== JSCompiler_inline_result; - - ) { - switch (JSCompiler_inline_result.tag) { - case 2: - case 3: - var instance = JSCompiler_inline_result.stateNode; - if ( - "function" === - typeof JSCompiler_inline_result.type.getDerivedStateFromError || - ("function" === typeof instance.componentDidCatch && - (null === legacyErrorBoundariesThatAlreadyFailed || - !legacyErrorBoundariesThatAlreadyFailed.has(instance))) - ) { - fiber = createCapturedValue(error, fiber); - fiber = createClassErrorUpdate(JSCompiler_inline_result, fiber, 1); - enqueueUpdate(JSCompiler_inline_result, fiber); - scheduleWork(JSCompiler_inline_result, 1); - JSCompiler_inline_result = void 0; - break a; - } - break; - case 5: - fiber = createCapturedValue(error, fiber); - fiber = createRootErrorUpdate(JSCompiler_inline_result, fiber, 1); - enqueueUpdate(JSCompiler_inline_result, fiber); - scheduleWork(JSCompiler_inline_result, 1); - JSCompiler_inline_result = void 0; - break a; - } - JSCompiler_inline_result = JSCompiler_inline_result.return; +function captureCommitPhaseError(sourceFiber, value) { + for (var fiber = sourceFiber.return; null !== fiber; ) { + switch (fiber.tag) { + case 1: + var instance = fiber.stateNode; + if ( + "function" === typeof fiber.type.getDerivedStateFromError || + ("function" === typeof instance.componentDidCatch && + (null === legacyErrorBoundariesThatAlreadyFailed || + !legacyErrorBoundariesThatAlreadyFailed.has(instance))) + ) { + sourceFiber = createCapturedValue(value, sourceFiber); + sourceFiber = createClassErrorUpdate(fiber, sourceFiber, 1073741823); + enqueueUpdate(fiber, sourceFiber); + scheduleWork(fiber, 1073741823); + return; + } + break; + case 3: + sourceFiber = createCapturedValue(value, sourceFiber); + sourceFiber = createRootErrorUpdate(fiber, sourceFiber, 1073741823); + enqueueUpdate(fiber, sourceFiber); + scheduleWork(fiber, 1073741823); + return; } - 5 === fiber.tag && - ((JSCompiler_inline_result = createCapturedValue(error, fiber)), - (JSCompiler_inline_result = createRootErrorUpdate( - fiber, - JSCompiler_inline_result, - 1 - )), - enqueueUpdate(fiber, JSCompiler_inline_result), - scheduleWork(fiber, 1)); - JSCompiler_inline_result = void 0; + fiber = fiber.return; } - return JSCompiler_inline_result; + 3 === sourceFiber.tag && + ((fiber = createCapturedValue(value, sourceFiber)), + (fiber = createRootErrorUpdate(sourceFiber, fiber, 1073741823)), + enqueueUpdate(sourceFiber, fiber), + scheduleWork(sourceFiber, 1073741823)); } function computeExpirationForFiber(currentTime, fiber) { isWorking - ? (currentTime = isCommitting$1 ? 1 : nextRenderExpirationTime) + ? (currentTime = isCommitting$1 ? 1073741823 : nextRenderExpirationTime) : fiber.mode & 1 ? ((currentTime = isBatchingInteractiveUpdates - ? 2 + 10 * ((((currentTime - 2 + 15) / 10) | 0) + 1) - : 2 + 25 * ((((currentTime - 2 + 500) / 25) | 0) + 1)), + ? 1073741822 - 10 * ((((1073741822 - currentTime + 15) / 10) | 0) + 1) + : 1073741822 - + 25 * ((((1073741822 - currentTime + 500) / 25) | 0) + 1)), null !== nextRoot && currentTime === nextRenderExpirationTime && - (currentTime += 1)) - : (currentTime = 1); + --currentTime) + : (currentTime = 1073741823); isBatchingInteractiveUpdates && - currentTime > lowestPriorityPendingInteractiveExpirationTime && + (0 === lowestPriorityPendingInteractiveExpirationTime || + currentTime < lowestPriorityPendingInteractiveExpirationTime) && (lowestPriorityPendingInteractiveExpirationTime = currentTime); return currentTime; } -function retrySuspendedRoot(root, fiber, suspendedTime) { +function retrySuspendedRoot(root, boundaryFiber, sourceFiber, suspendedTime) { var retryTime = root.earliestSuspendedTime; var latestSuspendedTime = root.latestSuspendedTime; if ( 0 !== retryTime && - suspendedTime >= retryTime && - suspendedTime <= latestSuspendedTime + suspendedTime <= retryTime && + suspendedTime >= latestSuspendedTime ) { latestSuspendedTime = retryTime = suspendedTime; root.didError = !1; var latestPingedTime = root.latestPingedTime; - if (0 === latestPingedTime || latestPingedTime < latestSuspendedTime) + if (0 === latestPingedTime || latestPingedTime > latestSuspendedTime) root.latestPingedTime = latestSuspendedTime; findNextExpirationTimeToWorkOn(latestSuspendedTime, root); } else (retryTime = requestCurrentTime()), - (retryTime = computeExpirationForFiber(retryTime, fiber)), + (retryTime = computeExpirationForFiber(retryTime, boundaryFiber)), markPendingPriorityLevel(root, retryTime); - 0 !== (fiber.mode & 1) && + 0 !== (boundaryFiber.mode & 1) && root === nextRoot && nextRenderExpirationTime === suspendedTime && (nextRoot = null); - scheduleWorkToRoot(fiber, retryTime); - fiber = root.expirationTime; - 0 !== fiber && requestWork(root, fiber); + scheduleWorkToRoot(boundaryFiber, retryTime); + 0 === (boundaryFiber.mode & 1) && + (scheduleWorkToRoot(sourceFiber, retryTime), + 1 === sourceFiber.tag && + null !== sourceFiber.stateNode && + ((boundaryFiber = createUpdate(retryTime)), + (boundaryFiber.tag = 2), + enqueueUpdate(sourceFiber, boundaryFiber))); + sourceFiber = root.expirationTime; + 0 !== sourceFiber && requestWork(root, sourceFiber); } function scheduleWorkToRoot(fiber, expirationTime) { - if (0 === fiber.expirationTime || fiber.expirationTime > expirationTime) - fiber.expirationTime = expirationTime; + fiber.expirationTime < expirationTime && + (fiber.expirationTime = expirationTime); var alternate = fiber.alternate; null !== alternate && - (0 === alternate.expirationTime || - alternate.expirationTime > expirationTime) && + alternate.expirationTime < expirationTime && (alternate.expirationTime = expirationTime); var node = fiber.return, root = null; - if (null === node && 5 === fiber.tag) root = fiber.stateNode; + if (null === node && 3 === fiber.tag) root = fiber.stateNode; else for (; null !== node; ) { alternate = node.alternate; - if ( - 0 === node.childExpirationTime || - node.childExpirationTime > expirationTime - ) - node.childExpirationTime = expirationTime; + node.childExpirationTime < expirationTime && + (node.childExpirationTime = expirationTime); null !== alternate && - (0 === alternate.childExpirationTime || - alternate.childExpirationTime > expirationTime) && + alternate.childExpirationTime < expirationTime && (alternate.childExpirationTime = expirationTime); - if (null === node.return && 5 === node.tag) { + if (null === node.return && 3 === node.tag) { root = node.stateNode; break; } @@ -5699,7 +5987,7 @@ function scheduleWork(fiber, expirationTime) { null !== fiber && (!isWorking && 0 !== nextRenderExpirationTime && - expirationTime < nextRenderExpirationTime && + expirationTime > nextRenderExpirationTime && resetStack(), markPendingPriorityLevel(fiber, expirationTime), (isWorking && !isCommitting$1 && nextRoot === fiber) || @@ -5719,27 +6007,25 @@ var firstScheduledRoot = null, nextFlushedRoot = null, nextFlushedExpirationTime = 0, lowestPriorityPendingInteractiveExpirationTime = 0, - deadlineDidExpire = !1, hasUnhandledError = !1, unhandledError = null, - deadline = null, isBatchingUpdates = !1, isUnbatchingUpdates = !1, isBatchingInteractiveUpdates = !1, completedBatches = null, originalStartTimeMs = now$1(), - currentRendererTime = ((originalStartTimeMs / 10) | 0) + 2, + currentRendererTime = 1073741822 - ((originalStartTimeMs / 10) | 0), currentSchedulerTime = currentRendererTime, NESTED_UPDATE_LIMIT = 50, nestedUpdateCount = 0, - lastCommittedRootDuringThisBatch = null, - timeHeuristicForUnitOfWork = 1; + lastCommittedRootDuringThisBatch = null; function recomputeCurrentRendererTime() { - currentRendererTime = (((now$1() - originalStartTimeMs) / 10) | 0) + 2; + currentRendererTime = + 1073741822 - (((now$1() - originalStartTimeMs) / 10) | 0); } function scheduleCallbackWithExpirationTime(root, expirationTime) { if (0 !== callbackExpirationTime) { - if (expirationTime > callbackExpirationTime) return; + if (expirationTime < callbackExpirationTime) return; null !== callbackID && ((root = callbackID), (scheduledCallback = null), clearTimeout(root)); } @@ -5760,7 +6046,7 @@ function onSuspend( msUntilTimeout ) { root.expirationTime = rootExpirationTime; - 0 !== msUntilTimeout || shouldYield() + 0 !== msUntilTimeout || shouldYieldToRenderer() ? 0 < msUntilTimeout && (root.timeoutHandle = scheduleTimeout( onTimeout.bind(null, root, finishedWork, suspendedExpirationTime), @@ -5780,8 +6066,8 @@ function onTimeout(root, finishedWork, suspendedExpirationTime) { ); nextFlushedRoot = root; nextFlushedExpirationTime = suspendedExpirationTime; - performWorkOnRoot(root, suspendedExpirationTime, !0); - performWork(1, null); + performWorkOnRoot(root, suspendedExpirationTime, !1); + performWork(1073741823, !1); } function onCommit(root, expirationTime) { root.expirationTime = expirationTime; @@ -5790,38 +6076,29 @@ function onCommit(root, expirationTime) { function requestCurrentTime() { if (isRendering) return currentSchedulerTime; findHighestPriorityRoot(); - if ( - 0 === nextFlushedExpirationTime || - 1073741823 === nextFlushedExpirationTime - ) + if (0 === nextFlushedExpirationTime || 1 === nextFlushedExpirationTime) recomputeCurrentRendererTime(), (currentSchedulerTime = currentRendererTime); return currentSchedulerTime; } function requestWork(root, expirationTime) { - if (null === root.nextScheduledRoot) - (root.expirationTime = expirationTime), + null === root.nextScheduledRoot + ? ((root.expirationTime = expirationTime), null === lastScheduledRoot ? ((firstScheduledRoot = lastScheduledRoot = root), (root.nextScheduledRoot = root)) : ((lastScheduledRoot = lastScheduledRoot.nextScheduledRoot = root), - (lastScheduledRoot.nextScheduledRoot = firstScheduledRoot)); - else { - var remainingExpirationTime = root.expirationTime; - if ( - 0 === remainingExpirationTime || - expirationTime < remainingExpirationTime - ) - root.expirationTime = expirationTime; - } + (lastScheduledRoot.nextScheduledRoot = firstScheduledRoot))) + : expirationTime > root.expirationTime && + (root.expirationTime = expirationTime); isRendering || (isBatchingUpdates ? isUnbatchingUpdates && ((nextFlushedRoot = root), - (nextFlushedExpirationTime = 1), - performWorkOnRoot(root, 1, !0)) - : 1 === expirationTime - ? performWork(1, null) + (nextFlushedExpirationTime = 1073741823), + performWorkOnRoot(root, 1073741823, !1)) + : 1073741823 === expirationTime + ? performWork(1073741823, !1) : scheduleCallbackWithExpirationTime(root, expirationTime)); } function findHighestPriorityRoot() { @@ -5857,14 +6134,11 @@ function findHighestPriorityRoot() { (root.nextScheduledRoot = null); root = previousScheduledRoot.nextScheduledRoot; } else { - if ( - 0 === highestPriorityWork || - remainingExpirationTime < highestPriorityWork - ) - (highestPriorityWork = remainingExpirationTime), - (highestPriorityRoot = root); + remainingExpirationTime > highestPriorityWork && + ((highestPriorityWork = remainingExpirationTime), + (highestPriorityRoot = root)); if (root === lastScheduledRoot) break; - if (1 === highestPriorityWork) break; + if (1073741823 === highestPriorityWork) break; previousScheduledRoot = root; root = root.nextScheduledRoot; } @@ -5872,38 +6146,44 @@ function findHighestPriorityRoot() { nextFlushedRoot = highestPriorityRoot; nextFlushedExpirationTime = highestPriorityWork; } -function performAsyncWork(dl) { - if (dl.didTimeout && null !== firstScheduledRoot) { - recomputeCurrentRendererTime(); - var root = firstScheduledRoot; - do { - var expirationTime = root.expirationTime; - 0 !== expirationTime && - currentRendererTime >= expirationTime && - (root.nextExpirationTimeToWorkOn = currentRendererTime); - root = root.nextScheduledRoot; - } while (root !== firstScheduledRoot); +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; } - performWork(0, dl); } -function performWork(minExpirationTime, dl) { - deadline = dl; +function performWork(minExpirationTime, isYieldy) { findHighestPriorityRoot(); - if (null !== deadline) + if (isYieldy) for ( recomputeCurrentRendererTime(), currentSchedulerTime = currentRendererTime; null !== nextFlushedRoot && 0 !== nextFlushedExpirationTime && - (0 === minExpirationTime || - minExpirationTime >= nextFlushedExpirationTime) && - (!deadlineDidExpire || currentRendererTime >= nextFlushedExpirationTime); + minExpirationTime <= nextFlushedExpirationTime && + !(didYield && currentRendererTime > nextFlushedExpirationTime); ) performWorkOnRoot( nextFlushedRoot, nextFlushedExpirationTime, - currentRendererTime >= nextFlushedExpirationTime + currentRendererTime > nextFlushedExpirationTime ), findHighestPriorityRoot(), recomputeCurrentRendererTime(), @@ -5913,29 +6193,28 @@ function performWork(minExpirationTime, dl) { ; null !== nextFlushedRoot && 0 !== nextFlushedExpirationTime && - (0 === minExpirationTime || - minExpirationTime >= nextFlushedExpirationTime); + minExpirationTime <= nextFlushedExpirationTime; ) - performWorkOnRoot(nextFlushedRoot, nextFlushedExpirationTime, !0), + performWorkOnRoot(nextFlushedRoot, nextFlushedExpirationTime, !1), findHighestPriorityRoot(); - null !== deadline && ((callbackExpirationTime = 0), (callbackID = null)); + isYieldy && ((callbackExpirationTime = 0), (callbackID = null)); 0 !== nextFlushedExpirationTime && scheduleCallbackWithExpirationTime( nextFlushedRoot, nextFlushedExpirationTime ); - deadline = null; - deadlineDidExpire = !1; nestedUpdateCount = 0; lastCommittedRootDuringThisBatch = null; if (null !== completedBatches) for ( - minExpirationTime = completedBatches, completedBatches = null, dl = 0; - dl < minExpirationTime.length; - dl++ + minExpirationTime = completedBatches, + completedBatches = null, + isYieldy = 0; + isYieldy < minExpirationTime.length; + isYieldy++ ) { - var batch = minExpirationTime[dl]; + var batch = minExpirationTime[isYieldy]; try { batch._onComplete(); } catch (error) { @@ -5949,45 +6228,45 @@ function performWork(minExpirationTime, dl) { (hasUnhandledError = !1), minExpirationTime); } -function performWorkOnRoot(root, expirationTime, isExpired) { +function performWorkOnRoot(root, expirationTime, isYieldy) { invariant( !isRendering, "performWorkOnRoot was called recursively. This error is likely caused by a bug in React. Please file an issue." ); isRendering = !0; - if (null === deadline || isExpired) { - var finishedWork = root.finishedWork; - null !== finishedWork - ? completeRoot$1(root, finishedWork, expirationTime) + if (isYieldy) { + var _finishedWork = root.finishedWork; + null !== _finishedWork + ? completeRoot$1(root, _finishedWork, expirationTime) : ((root.finishedWork = null), - (finishedWork = root.timeoutHandle), - -1 !== finishedWork && - ((root.timeoutHandle = -1), cancelTimeout(finishedWork)), - renderRoot(root, !1, isExpired), - (finishedWork = root.finishedWork), - null !== finishedWork && - completeRoot$1(root, finishedWork, expirationTime)); + (_finishedWork = root.timeoutHandle), + -1 !== _finishedWork && + ((root.timeoutHandle = -1), cancelTimeout(_finishedWork)), + renderRoot(root, isYieldy), + (_finishedWork = root.finishedWork), + null !== _finishedWork && + (shouldYieldToRenderer() + ? (root.finishedWork = _finishedWork) + : completeRoot$1(root, _finishedWork, expirationTime))); } else - (finishedWork = root.finishedWork), - null !== finishedWork - ? completeRoot$1(root, finishedWork, expirationTime) + (_finishedWork = root.finishedWork), + null !== _finishedWork + ? completeRoot$1(root, _finishedWork, expirationTime) : ((root.finishedWork = null), - (finishedWork = root.timeoutHandle), - -1 !== finishedWork && - ((root.timeoutHandle = -1), cancelTimeout(finishedWork)), - renderRoot(root, !0, isExpired), - (finishedWork = root.finishedWork), - null !== finishedWork && - (shouldYield() - ? (root.finishedWork = finishedWork) - : completeRoot$1(root, finishedWork, expirationTime))); + (_finishedWork = root.timeoutHandle), + -1 !== _finishedWork && + ((root.timeoutHandle = -1), cancelTimeout(_finishedWork)), + renderRoot(root, isYieldy), + (_finishedWork = root.finishedWork), + null !== _finishedWork && + completeRoot$1(root, _finishedWork, expirationTime)); isRendering = !1; } function completeRoot$1(root, finishedWork, expirationTime) { var firstBatch = root.firstBatch; if ( null !== firstBatch && - firstBatch._expirationTime <= expirationTime && + firstBatch._expirationTime >= expirationTime && (null === completedBatches ? (completedBatches = [firstBatch]) : completedBatches.push(firstBatch), @@ -6003,13 +6282,6 @@ function completeRoot$1(root, finishedWork, expirationTime) { : ((lastCommittedRootDuringThisBatch = root), (nestedUpdateCount = 0)); commitRoot(root, finishedWork); } -function shouldYield() { - return deadlineDidExpire - ? !0 - : null === deadline || deadline.timeRemaining() > timeHeuristicForUnitOfWork - ? !1 - : (deadlineDidExpire = !0); -} function onUncaughtError(error) { invariant( null !== nextFlushedRoot, @@ -6018,55 +6290,6 @@ function onUncaughtError(error) { nextFlushedRoot.expirationTime = 0; hasUnhandledError || ((hasUnhandledError = !0), (unhandledError = error)); } -function getContextForSubtree(parentComponent) { - if (!parentComponent) return emptyContextObject; - parentComponent = parentComponent._reactInternalFiber; - a: { - invariant( - 2 === isFiberMountedImpl(parentComponent) && - (2 === parentComponent.tag || 3 === parentComponent.tag), - "Expected subtree parent to be a mounted class component. This error is likely caused by a bug in React. Please file an issue." - ); - var parentContext = parentComponent; - do { - switch (parentContext.tag) { - case 5: - parentContext = parentContext.stateNode.context; - break a; - case 2: - if (isContextProvider(parentContext.type)) { - parentContext = - parentContext.stateNode.__reactInternalMemoizedMergedChildContext; - break a; - } - break; - case 3: - if (isContextProvider(parentContext.type._reactResult)) { - parentContext = - parentContext.stateNode.__reactInternalMemoizedMergedChildContext; - break a; - } - } - parentContext = parentContext.return; - } while (null !== parentContext); - invariant( - !1, - "Found unexpected detached subtree parent. This error is likely caused by a bug in React. Please file an issue." - ); - parentContext = void 0; - } - if (2 === parentComponent.tag) { - var Component = parentComponent.type; - if (isContextProvider(Component)) - return processChildContext(parentComponent, Component, parentContext); - } else if ( - 3 === parentComponent.tag && - ((Component = parentComponent.type._reactResult), - isContextProvider(Component)) - ) - return processChildContext(parentComponent, Component, parentContext); - return parentContext; -} function findHostInstance$1(component) { var fiber = component._reactInternalFiber; void 0 === fiber && @@ -6085,7 +6308,48 @@ function updateContainer(element, container, parentComponent, callback) { currentTime = requestCurrentTime(); current$$1 = computeExpirationForFiber(currentTime, current$$1); currentTime = container.current; - parentComponent = getContextForSubtree(parentComponent); + a: if (parentComponent) { + parentComponent = parentComponent._reactInternalFiber; + b: { + invariant( + 2 === isFiberMountedImpl(parentComponent) && 1 === parentComponent.tag, + "Expected subtree parent to be a mounted class component. This error is likely caused by a bug in React. Please file an issue." + ); + var parentContext = parentComponent; + do { + switch (parentContext.tag) { + case 3: + parentContext = parentContext.stateNode.context; + break b; + case 1: + if (isContextProvider(parentContext.type)) { + parentContext = + parentContext.stateNode + .__reactInternalMemoizedMergedChildContext; + break b; + } + } + parentContext = parentContext.return; + } while (null !== parentContext); + invariant( + !1, + "Found unexpected detached subtree parent. This error is likely caused by a bug in React. Please file an issue." + ); + parentContext = void 0; + } + if (1 === parentComponent.tag) { + var Component = parentComponent.type; + if (isContextProvider(Component)) { + parentComponent = processChildContext( + parentComponent, + Component, + parentContext + ); + break a; + } + } + parentComponent = parentContext; + } else parentComponent = emptyContextObject; null === container.context ? (container.context = parentComponent) : (container.pendingContext = parentComponent); @@ -6094,6 +6358,7 @@ function updateContainer(element, container, parentComponent, callback) { callback.payload = { element: element }; container = void 0 === container ? null : container; null !== container && (callback.callback = container); + flushPassiveEffects(); enqueueUpdate(currentTime, callback); scheduleWork(currentTime, current$$1); return current$$1; @@ -6153,13 +6418,13 @@ _batchedUpdatesImpl = function(fn, a) { } finally { (isBatchingUpdates = previousIsBatchingUpdates) || isRendering || - performWork(1, null); + performWork(1073741823, !1); } }; _flushInteractiveUpdatesImpl = function() { isRendering || 0 === lowestPriorityPendingInteractiveExpirationTime || - (performWork(lowestPriorityPendingInteractiveExpirationTime, null), + (performWork(lowestPriorityPendingInteractiveExpirationTime, !1), (lowestPriorityPendingInteractiveExpirationTime = 0)); }; var roots = new Map(), @@ -6241,7 +6506,7 @@ var roots = new Map(), if (!root) { root = 0; isDevToolsPresent && (root |= 4); - root = new FiberNode(5, null, null, root); + root = createFiber(3, null, null, root); var root$jscomp$0 = { current: root, containerInfo: containerTag, @@ -6272,7 +6537,7 @@ var roots = new Map(), updateContainer(element, root, null, callback); a: if (((element = root.current), element.child)) switch (element.child.tag) { - case 7: + case 5: element = element.child.stateNode.canonical; break a; default: @@ -6369,7 +6634,7 @@ var roots = new Map(), findFiberByHostInstance: getInstanceFromInstance, getInspectorDataForViewTag: getInspectorDataForViewTag, bundleType: 0, - version: "16.6.0-alpha.8af6728", + version: "16.6.1", 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 e77e96de3e20ea..e2929210ac6f1d 100644 --- a/Libraries/Renderer/oss/ReactNativeRenderer-dev.js +++ b/Libraries/Renderer/oss/ReactNativeRenderer-dev.js @@ -27,6 +27,7 @@ var flattenStyle = require("flattenStyle"); var TextInputState = require("TextInputState"); var checkPropTypes = require("prop-types/checkPropTypes"); var tracing = require("scheduler/tracing"); +var scheduler = require("scheduler"); var ExceptionsManager = require("ExceptionsManager"); /** @@ -627,67 +628,26 @@ var warningWithoutStack = function() {}; return; } if (typeof console !== "undefined") { - var _args$map = args.map(function(item) { - return "" + item; - }), - a = _args$map[0], - b = _args$map[1], - c = _args$map[2], - d = _args$map[3], - e = _args$map[4], - f = _args$map[5], - g = _args$map[6], - h = _args$map[7]; - - var message = "Warning: " + format; - - // We intentionally don't use spread (or .apply) because it breaks IE9: - // https://github.com/facebook/react/issues/13610 - switch (args.length) { - case 0: - console.error(message); - break; - case 1: - console.error(message, a); - break; - case 2: - console.error(message, a, b); - break; - case 3: - console.error(message, a, b, c); - break; - case 4: - console.error(message, a, b, c, d); - break; - case 5: - console.error(message, a, b, c, d, e); - break; - case 6: - console.error(message, a, b, c, d, e, f); - break; - case 7: - console.error(message, a, b, c, d, e, f, g); - break; - case 8: - console.error(message, a, b, c, d, e, f, g, h); - break; - default: - throw new Error( - "warningWithoutStack() currently supports at most 8 arguments." - ); - } + var argsWithFormat = args.map(function(item) { + return "" + item; + }); + argsWithFormat.unshift("Warning: " + format); + + // We intentionally don't use spread (or .apply) directly because it + // breaks IE9: https://github.com/facebook/react/issues/13610 + Function.prototype.apply.call(console.error, console, argsWithFormat); } try { // --- Welcome to debugging React --- // This error was thrown as a convenience so that you can use this stack // to find the callsite that caused this warning to fire. var argIndex = 0; - var _message = + var message = "Warning: " + format.replace(/%s/g, function() { return args[argIndex++]; }); - throw new Error(_message); + throw new Error(message); } catch (x) {} }; } @@ -746,11 +706,10 @@ var validateEventDispatches = void 0; /** * Dispatch the event to the listener. * @param {SyntheticEvent} event SyntheticEvent to handle - * @param {boolean} simulated If the event is simulated (changes exn behavior) * @param {function} listener Application-level callback * @param {*} inst Internal component instance */ -function executeDispatch(event, simulated, listener, inst) { +function executeDispatch(event, listener, inst) { var type = event.type || "unknown-event"; event.currentTarget = getNodeFromInstance(inst); invokeGuardedCallbackAndCatchFirstError(type, listener, undefined, event); @@ -760,7 +719,7 @@ function executeDispatch(event, simulated, listener, inst) { /** * Standard/simple iteration through an event's collected dispatches. */ -function executeDispatchesInOrder(event, simulated) { +function executeDispatchesInOrder(event) { var dispatchListeners = event._dispatchListeners; var dispatchInstances = event._dispatchInstances; { @@ -772,15 +731,10 @@ function executeDispatchesInOrder(event, simulated) { break; } // Listeners and Instances are two parallel arrays that are always in sync. - executeDispatch( - event, - simulated, - dispatchListeners[i], - dispatchInstances[i] - ); + executeDispatch(event, dispatchListeners[i], dispatchInstances[i]); } } else if (dispatchListeners) { - executeDispatch(event, simulated, dispatchListeners, dispatchInstances); + executeDispatch(event, dispatchListeners, dispatchInstances); } event._dispatchListeners = null; event._dispatchInstances = null; @@ -933,23 +887,19 @@ var eventQueue = null; * Dispatches an event and releases it back into the pool, unless persistent. * * @param {?object} event Synthetic event to be dispatched. - * @param {boolean} simulated If the event is simulated (changes exn behavior) * @private */ -var executeDispatchesAndRelease = function(event, simulated) { +var executeDispatchesAndRelease = function(event) { if (event) { - executeDispatchesInOrder(event, simulated); + executeDispatchesInOrder(event); if (!event.isPersistent()) { event.constructor.release(event); } } }; -var executeDispatchesAndReleaseSimulated = function(e) { - return executeDispatchesAndRelease(e, true); -}; var executeDispatchesAndReleaseTopLevel = function(e) { - return executeDispatchesAndRelease(e, false); + return executeDispatchesAndRelease(e); }; function isInteractive(tag) { @@ -1083,7 +1033,7 @@ function extractEvents( return events; } -function runEventsInBatch(events, simulated) { +function runEventsInBatch(events) { if (events !== null) { eventQueue = accumulateInto(eventQueue, events); } @@ -1097,17 +1047,7 @@ function runEventsInBatch(events, simulated) { return; } - if (simulated) { - forEachAccumulated( - processingEventQueue, - executeDispatchesAndReleaseSimulated - ); - } else { - forEachAccumulated( - processingEventQueue, - executeDispatchesAndReleaseTopLevel - ); - } + forEachAccumulated(processingEventQueue, executeDispatchesAndReleaseTopLevel); invariant( !eventQueue, "processEventQueue(): Additional events were enqueued while processing " + @@ -1129,28 +1069,27 @@ function runExtractedEventsInBatch( nativeEvent, nativeEventTarget ); - runEventsInBatch(events, false); + runEventsInBatch(events); } var FunctionComponent = 0; -var FunctionComponentLazy = 1; -var ClassComponent = 2; -var ClassComponentLazy = 3; -var IndeterminateComponent = 4; // Before we know whether it is function or class -var HostRoot = 5; // Root of a host tree. Could be nested inside another node. -var HostPortal = 6; // A subtree. Could be an entry point to a different renderer. -var HostComponent = 7; -var HostText = 8; -var Fragment = 9; -var Mode = 10; -var ContextConsumer = 11; -var ContextProvider = 12; -var ForwardRef = 13; -var ForwardRefLazy = 14; -var Profiler = 15; -var SuspenseComponent = 16; -var PureComponent = 17; -var PureComponentLazy = 18; +var ClassComponent = 1; +var IndeterminateComponent = 2; // Before we know whether it is function or class +var HostRoot = 3; // Root of a host tree. Could be nested inside another node. +var HostPortal = 4; // A subtree. Could be an entry point to a different renderer. +var HostComponent = 5; +var HostText = 6; +var Fragment = 7; +var Mode = 8; +var ContextConsumer = 9; +var ContextProvider = 10; +var ForwardRef = 11; +var Profiler = 12; +var SuspenseComponent = 13; +var MemoComponent = 14; +var SimpleMemoComponent = 15; +var LazyComponent = 16; +var IncompleteClassComponent = 17; function getParent(inst) { do { @@ -2923,6 +2862,7 @@ var REACT_STRICT_MODE_TYPE = hasSymbol var REACT_PROFILER_TYPE = hasSymbol ? Symbol.for("react.profiler") : 0xead2; var REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for("react.provider") : 0xeacd; var REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for("react.context") : 0xeace; + var REACT_CONCURRENT_MODE_TYPE = hasSymbol ? Symbol.for("react.concurrent_mode") : 0xeacf; @@ -2930,7 +2870,8 @@ var REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for("react.forward_ref") : 0xead0; var REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for("react.suspense") : 0xead1; -var REACT_PURE_TYPE = hasSymbol ? Symbol.for("react.pure") : 0xead3; +var REACT_MEMO_TYPE = hasSymbol ? Symbol.for("react.memo") : 0xead3; +var REACT_LAZY_TYPE = hasSymbol ? Symbol.for("react.lazy") : 0xead4; var MAYBE_ITERATOR_SYMBOL = typeof Symbol === "function" && Symbol.iterator; var FAUX_ITERATOR_SYMBOL = "@@iterator"; @@ -2952,12 +2893,8 @@ var Pending = 0; var Resolved = 1; var Rejected = 2; -function getResultFromResolvedThenable(thenable) { - return thenable._reactResult; -} - -function refineResolvedThenable(thenable) { - return thenable._reactStatus === Resolved ? thenable._reactResult : null; +function refineResolvedLazyComponent(lazyComponent) { + return lazyComponent._status === Resolved ? lazyComponent._result : null; } function getWrappedName(outerType, innerType, wrapperName) { @@ -3010,14 +2947,14 @@ function getComponentName(type) { return "Context.Provider"; case REACT_FORWARD_REF_TYPE: return getWrappedName(type, type.render, "ForwardRef"); - case REACT_PURE_TYPE: - return getWrappedName(type, type.render, "Pure"); - } - if (typeof type.then === "function") { - var thenable = type; - var resolvedThenable = refineResolvedThenable(thenable); - if (resolvedThenable) { - return getComponentName(resolvedThenable); + case REACT_MEMO_TYPE: + return getComponentName(type.type); + case REACT_LAZY_TYPE: { + var thenable = type; + var resolvedThenable = refineResolvedLazyComponent(thenable); + if (resolvedThenable) { + return getComponentName(resolvedThenable); + } } } } @@ -3038,15 +2975,16 @@ var Callback = /* */ 32; var DidCapture = /* */ 64; var Ref = /* */ 128; var Snapshot = /* */ 256; +var Passive = /* */ 512; -// Update & Callback & Ref & Snapshot -var LifecycleEffectMask = /* */ 420; +// Passive & Update & Callback & Ref & Snapshot +var LifecycleEffectMask = /* */ 932; // Union of all host effects -var HostEffectMask = /* */ 511; +var HostEffectMask = /* */ 1023; -var Incomplete = /* */ 512; -var ShouldCapture = /* */ 1024; +var Incomplete = /* */ 1024; +var ShouldCapture = /* */ 2048; var ReactCurrentOwner$1 = ReactSharedInternals.ReactCurrentOwner; @@ -3090,10 +3028,7 @@ function isFiberMounted(fiber) { function isMounted(component) { { var owner = ReactCurrentOwner$1.current; - if ( - owner !== null && - (owner.tag === ClassComponent || owner.tag === ClassComponentLazy) - ) { + if (owner !== null && owner.tag === ClassComponent) { var ownerFiber = owner; var instance = ownerFiber.stateNode; !instance._warnedAboutRefsInRender @@ -3888,13 +3823,6 @@ var now$1 = hasNativePerformanceNow var scheduledCallback = null; var frameDeadline = 0; -var frameDeadlineObject = { - timeRemaining: function() { - return frameDeadline - now$1(); - }, - didTimeout: false -}; - function setTimeoutCallback() { // TODO (bvaughn) Hard-coded 5ms unblocks initial async testing. // React API probably changing to boolean rather than time remaining. @@ -3905,7 +3833,7 @@ function setTimeoutCallback() { var callback = scheduledCallback; scheduledCallback = null; if (callback !== null) { - callback(frameDeadlineObject); + callback(); } } @@ -3924,6 +3852,10 @@ function cancelDeferredCallback$1(callbackID) { clearTimeout(callbackID); // Timeouts are always numbers on RN } +function shouldYield$1() { + return frameDeadline <= now$1(); +} + // Renderers that don't support persistence // can re-export everything from this module. @@ -3943,6 +3875,9 @@ var createContainerChildSet = shim; var appendChildToContainerChildSet = shim; var finalizeContainerChildren = shim; var replaceContainerChildren = shim; +var cloneHiddenInstance = shim; +var cloneUnhiddenInstance = shim; +var createHiddenTextInstance = shim; // Renderers that don't support hydration // can re-export everything from this module. @@ -4151,6 +4086,7 @@ var now = now$1; var isPrimaryRenderer = true; var scheduleDeferredCallback = scheduleDeferredCallback$1; var cancelDeferredCallback = cancelDeferredCallback$1; +var shouldYield = shouldYield$1; var scheduleTimeout = setTimeout; var cancelTimeout = clearTimeout; @@ -4328,6 +4264,41 @@ function resetTextContent(instance) { // Noop } +function hideInstance(instance) { + var viewConfig = instance.viewConfig; + var updatePayload = create( + { style: { display: "none" } }, + viewConfig.validAttributes + ); + UIManager.updateView( + instance._nativeTag, + viewConfig.uiViewClassName, + updatePayload + ); +} + +function hideTextInstance(textInstance) { + throw new Error("Not yet implemented."); +} + +function unhideInstance(instance, props) { + var viewConfig = instance.viewConfig; + var updatePayload = diff( + Object.assign({}, props, { style: [props.style, { display: "none" }] }), + props, + viewConfig.validAttributes + ); + UIManager.updateView( + instance._nativeTag, + viewConfig.uiViewClassName, + updatePayload + ); +} + +function unhideTextInstance(textInstance, text) { + throw new Error("Not yet implemented."); +} + var BEFORE_SLASH_RE = /^(.*)[\\\/]/; var describeComponentFrame = function(name, source, ownerName) { @@ -4361,12 +4332,12 @@ var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame; function describeFiber(fiber) { switch (fiber.tag) { case IndeterminateComponent: + case LazyComponent: case FunctionComponent: - case FunctionComponentLazy: case ClassComponent: - case ClassComponentLazy: case HostComponent: case Mode: + case SuspenseComponent: var owner = fiber._debugOwner; var source = fiber._debugSource; var name = getComponentName(fiber.type); @@ -4442,6 +4413,7 @@ function setCurrentPhase(lifeCyclePhase) { var debugRenderPhaseSideEffects = false; var debugRenderPhaseSideEffectsForStrictMode = false; +var enableHooks = false; var enableUserTimingAPI = true; var replayFailedUnitOfWorkWithInvokeGuardedCallback = true; var warnAboutDeprecatedLifecycles = false; @@ -5214,8 +5186,7 @@ function findCurrentUnmaskedContext(fiber) { // Currently this is only used with renderSubtreeIntoContainer; not sure if it // makes sense elsewhere invariant( - isFiberMounted(fiber) && - (fiber.tag === ClassComponent || fiber.tag === ClassComponentLazy), + isFiberMounted(fiber) && fiber.tag === ClassComponent, "Expected subtree parent to be a mounted class component. " + "This error is likely caused by a bug in React. Please file an issue." ); @@ -5232,13 +5203,6 @@ function findCurrentUnmaskedContext(fiber) { } break; } - case ClassComponentLazy: { - var _Component = getResultFromResolvedThenable(node.type); - if (isContextProvider(_Component)) { - return node.stateNode.__reactInternalMemoizedMergedChildContext; - } - break; - } } node = node.return; } while (node !== null); @@ -5337,20 +5301,20 @@ function onCommitUnmount(fiber) { var maxSigned31BitInt = 1073741823; var NoWork = 0; -var Sync = 1; -var Never = maxSigned31BitInt; +var Never = 1; +var Sync = maxSigned31BitInt; var UNIT_SIZE = 10; -var MAGIC_NUMBER_OFFSET = 2; +var MAGIC_NUMBER_OFFSET = maxSigned31BitInt - 1; // 1 unit of expiration time represents 10ms. function msToExpirationTime(ms) { // Always add an offset so that we don't clash with the magic number for NoWork. - return ((ms / UNIT_SIZE) | 0) + MAGIC_NUMBER_OFFSET; + return MAGIC_NUMBER_OFFSET - ((ms / UNIT_SIZE) | 0); } function expirationTimeToMs(expirationTime) { - return (expirationTime - MAGIC_NUMBER_OFFSET) * UNIT_SIZE; + return (MAGIC_NUMBER_OFFSET - expirationTime) * UNIT_SIZE; } function ceiling(num, precision) { @@ -5359,9 +5323,9 @@ function ceiling(num, precision) { function computeExpirationBucket(currentTime, expirationInMs, bucketSizeMs) { return ( - MAGIC_NUMBER_OFFSET + + MAGIC_NUMBER_OFFSET - ceiling( - currentTime - MAGIC_NUMBER_OFFSET + expirationInMs / UNIT_SIZE, + MAGIC_NUMBER_OFFSET - currentTime + expirationInMs / UNIT_SIZE, bucketSizeMs / UNIT_SIZE ) ); @@ -5437,6 +5401,7 @@ function FiberNode(tag, pendingProps, key, mode) { // Instance this.tag = tag; this.key = key; + this.elementType = null; this.type = null; this.stateNode = null; @@ -5509,18 +5474,24 @@ function shouldConstruct(Component) { return !!(prototype && prototype.isReactComponent); } -function resolveLazyComponentTag(fiber, Component) { +function isSimpleFunctionComponent(type) { + return ( + typeof type === "function" && + !shouldConstruct(type) && + type.defaultProps === undefined + ); +} + +function resolveLazyComponentTag(Component) { if (typeof Component === "function") { - return shouldConstruct(Component) - ? ClassComponentLazy - : FunctionComponentLazy; + return shouldConstruct(Component) ? ClassComponent : FunctionComponent; } else if (Component !== undefined && Component !== null) { var $$typeof = Component.$$typeof; if ($$typeof === REACT_FORWARD_REF_TYPE) { - return ForwardRefLazy; + return ForwardRef; } - if ($$typeof === REACT_PURE_TYPE) { - return PureComponentLazy; + if ($$typeof === REACT_MEMO_TYPE) { + return MemoComponent; } } return IndeterminateComponent; @@ -5541,6 +5512,7 @@ function createWorkInProgress(current, pendingProps, expirationTime) { current.key, current.mode ); + workInProgress.elementType = current.elementType; workInProgress.type = current.type; workInProgress.stateNode = current.stateNode; @@ -5610,20 +5582,23 @@ function createHostRootFiber(isConcurrent) { return createFiber(HostRoot, null, null, mode); } -function createFiberFromElement(element, mode, expirationTime) { - var owner = null; - { - owner = element._owner; - } - +function createFiberFromTypeAndProps( + type, // React$ElementType + key, + pendingProps, + owner, + mode, + expirationTime +) { var fiber = void 0; - var type = element.type; - var key = element.key; - var pendingProps = element.props; - var fiberTag = void 0; + var fiberTag = IndeterminateComponent; + // The resolved type is set if we know what the final type will be. I.e. it's not lazy. + var resolvedType = type; if (typeof type === "function") { - fiberTag = shouldConstruct(type) ? ClassComponent : IndeterminateComponent; + if (shouldConstruct(type)) { + fiberTag = ClassComponent; + } } else if (typeof type === "string") { fiberTag = HostComponent; } else { @@ -5636,18 +5611,23 @@ function createFiberFromElement(element, mode, expirationTime) { key ); case REACT_CONCURRENT_MODE_TYPE: - fiberTag = Mode; - mode |= ConcurrentMode | StrictMode; - break; + return createFiberFromMode( + pendingProps, + mode | ConcurrentMode | StrictMode, + expirationTime, + key + ); case REACT_STRICT_MODE_TYPE: - fiberTag = Mode; - mode |= StrictMode; - break; + return createFiberFromMode( + pendingProps, + mode | StrictMode, + expirationTime, + key + ); case REACT_PROFILER_TYPE: return createFiberFromProfiler(pendingProps, mode, expirationTime, key); case REACT_SUSPENSE_TYPE: - fiberTag = SuspenseComponent; - break; + return createFiberFromSuspense(pendingProps, mode, expirationTime, key); default: { if (typeof type === "object" && type !== null) { switch (type.$$typeof) { @@ -5661,15 +5641,13 @@ function createFiberFromElement(element, mode, expirationTime) { case REACT_FORWARD_REF_TYPE: fiberTag = ForwardRef; break getTag; - case REACT_PURE_TYPE: - fiberTag = PureComponent; + case REACT_MEMO_TYPE: + fiberTag = MemoComponent; + break getTag; + case REACT_LAZY_TYPE: + fiberTag = LazyComponent; + resolvedType = null; break getTag; - default: { - if (typeof type.then === "function") { - fiberTag = IndeterminateComponent; - break getTag; - } - } } } var info = ""; @@ -5703,14 +5681,33 @@ function createFiberFromElement(element, mode, expirationTime) { } fiber = createFiber(fiberTag, pendingProps, key, mode); - fiber.type = type; + fiber.elementType = type; + fiber.type = resolvedType; fiber.expirationTime = expirationTime; + return fiber; +} + +function createFiberFromElement(element, mode, expirationTime) { + var owner = null; + { + owner = element._owner; + } + var type = element.type; + var key = element.key; + var pendingProps = element.props; + var fiber = createFiberFromTypeAndProps( + type, + key, + pendingProps, + owner, + mode, + expirationTime + ); { fiber._debugSource = element._source; fiber._debugOwner = element._owner; } - return fiber; } @@ -5734,12 +5731,41 @@ function createFiberFromProfiler(pendingProps, mode, expirationTime, key) { } var fiber = createFiber(Profiler, pendingProps, key, mode | ProfileMode); + // TODO: The Profiler fiber shouldn't have a type. It has a tag. + fiber.elementType = REACT_PROFILER_TYPE; fiber.type = REACT_PROFILER_TYPE; fiber.expirationTime = expirationTime; return fiber; } +function createFiberFromMode(pendingProps, mode, expirationTime, key) { + var fiber = createFiber(Mode, pendingProps, key, mode); + + // TODO: The Mode fiber shouldn't have a type. It has a tag. + var type = + (mode & ConcurrentMode) === NoContext + ? REACT_STRICT_MODE_TYPE + : REACT_CONCURRENT_MODE_TYPE; + fiber.elementType = type; + fiber.type = type; + + fiber.expirationTime = expirationTime; + return fiber; +} + +function createFiberFromSuspense(pendingProps, mode, expirationTime, key) { + var fiber = createFiber(SuspenseComponent, pendingProps, key, mode); + + // TODO: The SuspenseComponent fiber shouldn't have a type. It has a tag. + var type = REACT_SUSPENSE_TYPE; + fiber.elementType = type; + fiber.type = type; + + fiber.expirationTime = expirationTime; + return fiber; +} + function createFiberFromText(content, mode, expirationTime) { var fiber = createFiber(HostText, content, null, mode); fiber.expirationTime = expirationTime; @@ -5748,6 +5774,8 @@ function createFiberFromText(content, mode, expirationTime) { function createFiberFromHostInstanceForDeletion() { var fiber = createFiber(HostComponent, null, null, NoContext); + // TODO: These should not need a type. + fiber.elementType = "DELETED"; fiber.type = "DELETED"; return fiber; } @@ -5780,6 +5808,7 @@ function assignFiberPropertiesInDEV(target, source) { target.tag = source.tag; target.key = source.key; + target.elementType = source.elementType; target.type = source.type; target.stateNode = source.stateNode; target.return = source.return; @@ -6322,12 +6351,12 @@ function markPendingPriorityLevel(root, expirationTime) { // No other pending updates. root.earliestPendingTime = root.latestPendingTime = expirationTime; } else { - if (earliestPendingTime > expirationTime) { + if (earliestPendingTime < expirationTime) { // This is the earliest pending update. root.earliestPendingTime = expirationTime; } else { var latestPendingTime = root.latestPendingTime; - if (latestPendingTime < expirationTime) { + if (latestPendingTime > expirationTime) { // This is the latest pending update root.latestPendingTime = expirationTime; } @@ -6353,12 +6382,12 @@ function markCommittedPriorityLevels(root, earliestRemainingTime) { // Let's see if the previous latest known pending level was just flushed. var latestPendingTime = root.latestPendingTime; if (latestPendingTime !== NoWork) { - if (latestPendingTime < earliestRemainingTime) { + if (latestPendingTime > earliestRemainingTime) { // We've flushed all the known pending levels. root.earliestPendingTime = root.latestPendingTime = NoWork; } else { var earliestPendingTime = root.earliestPendingTime; - if (earliestPendingTime < earliestRemainingTime) { + if (earliestPendingTime > earliestRemainingTime) { // We've flushed the earliest known pending level. Set this to the // latest pending time. root.earliestPendingTime = root.latestPendingTime; @@ -6380,7 +6409,7 @@ function markCommittedPriorityLevels(root, earliestRemainingTime) { } var latestSuspendedTime = root.latestSuspendedTime; - if (earliestRemainingTime > latestSuspendedTime) { + if (earliestRemainingTime < latestSuspendedTime) { // The earliest remaining level is later than all the suspended work. That // means we've flushed all the suspended work. root.earliestSuspendedTime = NoWork; @@ -6394,7 +6423,7 @@ function markCommittedPriorityLevels(root, earliestRemainingTime) { return; } - if (earliestRemainingTime < earliestSuspendedTime) { + if (earliestRemainingTime > earliestSuspendedTime) { // The earliest remaining time is earlier than all the suspended work. // Treat it as a pending update. markPendingPriorityLevel(root, earliestRemainingTime); @@ -6413,10 +6442,10 @@ function hasLowerPriorityWork(root, erroredExpirationTime) { var latestPingedTime = root.latestPingedTime; return ( (latestPendingTime !== NoWork && - latestPendingTime > erroredExpirationTime) || + latestPendingTime < erroredExpirationTime) || (latestSuspendedTime !== NoWork && - latestSuspendedTime > erroredExpirationTime) || - (latestPingedTime !== NoWork && latestPingedTime > erroredExpirationTime) + latestSuspendedTime < erroredExpirationTime) || + (latestPingedTime !== NoWork && latestPingedTime < erroredExpirationTime) ); } @@ -6425,8 +6454,8 @@ function isPriorityLevelSuspended(root, expirationTime) { var latestSuspendedTime = root.latestSuspendedTime; return ( earliestSuspendedTime !== NoWork && - expirationTime >= earliestSuspendedTime && - expirationTime <= latestSuspendedTime + expirationTime <= earliestSuspendedTime && + expirationTime >= latestSuspendedTime ); } @@ -6459,10 +6488,10 @@ function markSuspendedPriorityLevel(root, suspendedTime) { // No other suspended levels. root.earliestSuspendedTime = root.latestSuspendedTime = suspendedTime; } else { - if (earliestSuspendedTime > suspendedTime) { + if (earliestSuspendedTime < suspendedTime) { // This is the earliest suspended level. root.earliestSuspendedTime = suspendedTime; - } else if (latestSuspendedTime < suspendedTime) { + } else if (latestSuspendedTime > suspendedTime) { // This is the latest suspended level root.latestSuspendedTime = suspendedTime; } @@ -6478,7 +6507,7 @@ function markPingedPriorityLevel(root, pingedTime) { // is thrown out and not reused during the restarted render. One way to // invalidate the progressed work is to restart at expirationTime + 1. var latestPingedTime = root.latestPingedTime; - if (latestPingedTime === NoWork || latestPingedTime < pingedTime) { + if (latestPingedTime === NoWork || latestPingedTime > pingedTime) { root.latestPingedTime = pingedTime; } findNextExpirationTimeToWorkOn(pingedTime, root); @@ -6488,7 +6517,7 @@ function clearPing(root, completedTime) { // TODO: Track whether the root was pinged during the render phase. If so, // we need to make sure we don't lose track of it. var latestPingedTime = root.latestPingedTime; - if (latestPingedTime !== NoWork && latestPingedTime <= completedTime) { + if (latestPingedTime !== NoWork && latestPingedTime >= completedTime) { root.latestPingedTime = NoWork; } } @@ -6498,18 +6527,10 @@ function findEarliestOutstandingPriorityLevel(root, renderExpirationTime) { var earliestPendingTime = root.earliestPendingTime; var earliestSuspendedTime = root.earliestSuspendedTime; - if ( - earliestExpirationTime === NoWork || - (earliestPendingTime !== NoWork && - earliestPendingTime < earliestExpirationTime) - ) { + if (earliestPendingTime > earliestExpirationTime) { earliestExpirationTime = earliestPendingTime; } - if ( - earliestExpirationTime === NoWork || - (earliestSuspendedTime !== NoWork && - earliestSuspendedTime < earliestExpirationTime) - ) { + if (earliestSuspendedTime > earliestExpirationTime) { earliestExpirationTime = earliestSuspendedTime; } return earliestExpirationTime; @@ -6517,7 +6538,7 @@ function findEarliestOutstandingPriorityLevel(root, renderExpirationTime) { function didExpireAtExpirationTime(root, currentTime) { var expirationTime = root.expirationTime; - if (expirationTime !== NoWork && currentTime >= expirationTime) { + if (expirationTime !== NoWork && currentTime <= expirationTime) { // The root has expired. Flush all work up to the current time. root.nextExpirationTimeToWorkOn = currentTime; } @@ -6539,7 +6560,7 @@ function findNextExpirationTimeToWorkOn(completedExpirationTime, root) { if ( nextExpirationTimeToWorkOn === NoWork && (completedExpirationTime === NoWork || - latestSuspendedTime > completedExpirationTime) + latestSuspendedTime < completedExpirationTime) ) { // The lowest priority suspended work is the work most likely to be // committed next. Let's start rendering it again, so that if it times out, @@ -6548,11 +6569,7 @@ function findNextExpirationTimeToWorkOn(completedExpirationTime, root) { } var expirationTime = nextExpirationTimeToWorkOn; - if ( - expirationTime !== NoWork && - earliestSuspendedTime !== NoWork && - earliestSuspendedTime < expirationTime - ) { + if (expirationTime !== NoWork && earliestSuspendedTime > expirationTime) { // Expire using the earliest known expiration time. expirationTime = earliestSuspendedTime; } @@ -6776,7 +6793,7 @@ function enqueueUpdate(fiber, update) { { if ( - (fiber.tag === ClassComponent || fiber.tag === ClassComponentLazy) && + fiber.tag === ClassComponent && (currentlyProcessingQueue === queue1 || (queue2 !== null && currentlyProcessingQueue === queue2)) && !didWarnUpdateInsideUpdate @@ -6924,7 +6941,7 @@ function processUpdateQueue( var resultState = newBaseState; while (update !== null) { var updateExpirationTime = update.expirationTime; - if (updateExpirationTime > renderExpirationTime) { + if (updateExpirationTime < renderExpirationTime) { // This update does not have sufficient priority. Skip it. if (newFirstUpdate === null) { // This is the first skipped update. It will be the first update in @@ -6936,10 +6953,7 @@ function processUpdateQueue( } // Since this update will remain in the list, update the remaining // expiration time. - if ( - newExpirationTime === NoWork || - newExpirationTime > updateExpirationTime - ) { + if (newExpirationTime < updateExpirationTime) { newExpirationTime = updateExpirationTime; } } else { @@ -6975,7 +6989,7 @@ function processUpdateQueue( update = queue.firstCapturedUpdate; while (update !== null) { var _updateExpirationTime = update.expirationTime; - if (_updateExpirationTime > renderExpirationTime) { + if (_updateExpirationTime < renderExpirationTime) { // This update does not have sufficient priority. Skip it. if (newFirstCapturedUpdate === null) { // This is the first skipped captured update. It will be the first @@ -6989,10 +7003,7 @@ function processUpdateQueue( } // Since this update will remain in the list, update the remaining // expiration time. - if ( - newExpirationTime === NoWork || - newExpirationTime > _updateExpirationTime - ) { + if (newExpirationTime < _updateExpirationTime) { newExpirationTime = _updateExpirationTime; } } else { @@ -7290,10 +7301,7 @@ function propagateContextChange( ) { // Match! Schedule an update on this fiber. - if ( - fiber.tag === ClassComponent || - fiber.tag === ClassComponentLazy - ) { + if (fiber.tag === ClassComponent) { // Schedule a force update on the work-in-progress. var update = createUpdate(renderExpirationTime); update.tag = ForceUpdate; @@ -7304,17 +7312,13 @@ function propagateContextChange( enqueueUpdate(fiber, update); } - if ( - fiber.expirationTime === NoWork || - fiber.expirationTime > renderExpirationTime - ) { + if (fiber.expirationTime < renderExpirationTime) { fiber.expirationTime = renderExpirationTime; } var alternate = fiber.alternate; if ( alternate !== null && - (alternate.expirationTime === NoWork || - alternate.expirationTime > renderExpirationTime) + alternate.expirationTime < renderExpirationTime ) { alternate.expirationTime = renderExpirationTime; } @@ -7323,22 +7327,17 @@ function propagateContextChange( var node = fiber.return; while (node !== null) { alternate = node.alternate; - if ( - node.childExpirationTime === NoWork || - node.childExpirationTime > renderExpirationTime - ) { + if (node.childExpirationTime < renderExpirationTime) { node.childExpirationTime = renderExpirationTime; if ( alternate !== null && - (alternate.childExpirationTime === NoWork || - alternate.childExpirationTime > renderExpirationTime) + alternate.childExpirationTime < renderExpirationTime ) { alternate.childExpirationTime = renderExpirationTime; } } else if ( alternate !== null && - (alternate.childExpirationTime === NoWork || - alternate.childExpirationTime > renderExpirationTime) + alternate.childExpirationTime < renderExpirationTime ) { alternate.childExpirationTime = renderExpirationTime; } else { @@ -7423,7 +7422,7 @@ function readContext(context, observedBits) { if (lastContextDependency === null) { invariant( currentlyRenderingFiber !== null, - "Context.unstable_read(): Context can only be read while React is " + + "Context can only be read while React is " + "rendering, e.g. inside the render method or getDerivedStateFromProps." ); // This is the first dependency in the list @@ -7436,137 +7435,779 @@ function readContext(context, observedBits) { return isPrimaryRenderer ? context._currentValue : context._currentValue2; } -var NO_CONTEXT = {}; +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; -var contextStackCursor$1 = createCursor(NO_CONTEXT); -var contextFiberStackCursor = createCursor(NO_CONTEXT); -var rootInstanceStackCursor = createCursor(NO_CONTEXT); +function areHookInputsEqual(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; +} -function requiredContext(c) { +// 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( - c !== NO_CONTEXT, - "Expected host context to exist. This error is likely caused by a bug " + - "in React. Please file an issue." + currentlyRenderingFiber$1 !== null, + "Hooks can only be called inside the body of a function component." ); - return c; + return currentlyRenderingFiber$1; } -function getRootHostContainer() { - var rootInstance = requiredContext(rootInstanceStackCursor.current); - return rootInstance; -} +function prepareToUseHooks(current, workInProgress, nextRenderExpirationTime) { + if (!enableHooks) { + return; + } + renderExpirationTime = nextRenderExpirationTime; + currentlyRenderingFiber$1 = workInProgress; + firstCurrentHook = current !== null ? current.memoizedState : null; -function pushHostContainer(fiber, nextRootInstance) { - // Push current root instance onto the stack; - // This allows us to reset root when portals are popped. - push(rootInstanceStackCursor, nextRootInstance, fiber); - // Track the context and the Fiber that provided it. - // This enables us to pop only Fibers that provide unique contexts. - push(contextFiberStackCursor, fiber, fiber); + // The following should have already been reset + // currentHook = null; + // workInProgressHook = null; - // Finally, we need to push the host context to the stack. - // However, we can't just call getRootHostContext() and push it because - // we'd have a different number of entries on the stack depending on - // whether getRootHostContext() throws somewhere in renderer code or not. - // So we push an empty value first. This lets us safely unwind on errors. - push(contextStackCursor$1, NO_CONTEXT, fiber); - var nextRootContext = getRootHostContext(nextRootInstance); - // Now that we know this function doesn't throw, replace it. - pop(contextStackCursor$1, fiber); - push(contextStackCursor$1, nextRootContext, fiber); -} + // remainingExpirationTime = NoWork; + // componentUpdateQueue = null; -function popHostContainer(fiber) { - pop(contextStackCursor$1, fiber); - pop(contextFiberStackCursor, fiber); - pop(rootInstanceStackCursor, fiber); + // isReRender = false; + // didScheduleRenderPhaseUpdate = false; + // renderPhaseUpdates = null; + // numberOfReRenders = 0; } -function getHostContext() { - var context = requiredContext(contextStackCursor$1.current); - return context; -} +function finishHooks(Component, props, children, refOrContext) { + if (!enableHooks) { + return children; + } -function pushHostContext(fiber) { - var rootInstance = requiredContext(rootInstanceStackCursor.current); - var context = requiredContext(contextStackCursor$1.current); - var nextContext = getChildHostContext(context, fiber.type, rootInstance); + // This must be called after every function component to prevent hooks from + // being used in classes. - // Don't push this Fiber's context unless it's unique. - if (context === nextContext) { - return; - } + 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; - // Track the context and the Fiber that provided it. - // This enables us to pop only Fibers that provide unique contexts. - push(contextFiberStackCursor, fiber, fiber); - push(contextStackCursor$1, nextContext, fiber); -} + // Start over from the beginning of the list + currentHook = null; + workInProgressHook = null; + componentUpdateQueue = null; -function popHostContext(fiber) { - // Do not pop unless this Fiber provided the current context. - // pushHostContext() only pushes Fibers that provide unique contexts. - if (contextFiberStackCursor.current !== fiber) { - return; + children = Component(props, refOrContext); } + renderPhaseUpdates = null; + numberOfReRenders = 0; - pop(contextStackCursor$1, fiber); - pop(contextFiberStackCursor, fiber); -} + var renderedWork = currentlyRenderingFiber$1; -var commitTime = 0; -var profilerStartTime = -1; + renderedWork.memoizedState = firstWorkInProgressHook; + renderedWork.expirationTime = remainingExpirationTime; + renderedWork.updateQueue = componentUpdateQueue; -function getCommitTime() { - return commitTime; -} + var didRenderTooFewHooks = currentHook !== null && currentHook.next !== null; -function recordCommitTime() { - if (!enableProfilerTimer) { - return; - } - commitTime = now(); -} + renderExpirationTime = NoWork; + currentlyRenderingFiber$1 = null; -function startProfilerTimer(fiber) { - if (!enableProfilerTimer) { - return; - } + firstCurrentHook = null; + currentHook = null; + firstWorkInProgressHook = null; + workInProgressHook = null; - profilerStartTime = now(); + remainingExpirationTime = NoWork; + componentUpdateQueue = null; - if (fiber.actualStartTime < 0) { - fiber.actualStartTime = now(); - } + // 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 stopProfilerTimerIfRunning(fiber) { - if (!enableProfilerTimer) { +function resetHooks() { + if (!enableHooks) { return; } - profilerStartTime = -1; + + // 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 stopProfilerTimerIfRunningAndRecordDelta(fiber, overrideBaseTime) { - if (!enableProfilerTimer) { - return; - } +function createHook() { + return { + memoizedState: null, - if (profilerStartTime >= 0) { - var elapsedTime = now() - profilerStartTime; - fiber.actualDuration += elapsedTime; - if (overrideBaseTime) { - fiber.selfBaseDuration = elapsedTime; - } - profilerStartTime = -1; - } + baseState: null, + queue: null, + baseUpdate: null, + + next: null + }; } -/*eslint-disable no-self-compare */ +function cloneHook(hook) { + return { + memoizedState: hook.memoizedState, -var hasOwnProperty = Object.prototype.hasOwnProperty; + 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 (areHookInputsEqual(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 (areHookInputsEqual(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 (areHookInputsEqual(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); + } +} + +var NO_CONTEXT = {}; + +var contextStackCursor$1 = createCursor(NO_CONTEXT); +var contextFiberStackCursor = createCursor(NO_CONTEXT); +var rootInstanceStackCursor = createCursor(NO_CONTEXT); + +function requiredContext(c) { + invariant( + c !== NO_CONTEXT, + "Expected host context to exist. This error is likely caused by a bug " + + "in React. Please file an issue." + ); + return c; +} + +function getRootHostContainer() { + var rootInstance = requiredContext(rootInstanceStackCursor.current); + return rootInstance; +} + +function pushHostContainer(fiber, nextRootInstance) { + // Push current root instance onto the stack; + // This allows us to reset root when portals are popped. + push(rootInstanceStackCursor, nextRootInstance, fiber); + // Track the context and the Fiber that provided it. + // This enables us to pop only Fibers that provide unique contexts. + push(contextFiberStackCursor, fiber, fiber); + + // Finally, we need to push the host context to the stack. + // However, we can't just call getRootHostContext() and push it because + // we'd have a different number of entries on the stack depending on + // whether getRootHostContext() throws somewhere in renderer code or not. + // So we push an empty value first. This lets us safely unwind on errors. + push(contextStackCursor$1, NO_CONTEXT, fiber); + var nextRootContext = getRootHostContext(nextRootInstance); + // Now that we know this function doesn't throw, replace it. + pop(contextStackCursor$1, fiber); + push(contextStackCursor$1, nextRootContext, fiber); +} + +function popHostContainer(fiber) { + pop(contextStackCursor$1, fiber); + pop(contextFiberStackCursor, fiber); + pop(rootInstanceStackCursor, fiber); +} + +function getHostContext() { + var context = requiredContext(contextStackCursor$1.current); + return context; +} + +function pushHostContext(fiber) { + var rootInstance = requiredContext(rootInstanceStackCursor.current); + var context = requiredContext(contextStackCursor$1.current); + var nextContext = getChildHostContext(context, fiber.type, rootInstance); + + // Don't push this Fiber's context unless it's unique. + if (context === nextContext) { + return; + } + + // Track the context and the Fiber that provided it. + // This enables us to pop only Fibers that provide unique contexts. + push(contextFiberStackCursor, fiber, fiber); + push(contextStackCursor$1, nextContext, fiber); +} + +function popHostContext(fiber) { + // Do not pop unless this Fiber provided the current context. + // pushHostContext() only pushes Fibers that provide unique contexts. + if (contextFiberStackCursor.current !== fiber) { + return; + } + + pop(contextStackCursor$1, fiber); + pop(contextFiberStackCursor, fiber); +} + +var commitTime = 0; +var profilerStartTime = -1; + +function getCommitTime() { + return commitTime; +} + +function recordCommitTime() { + if (!enableProfilerTimer) { + return; + } + commitTime = now(); +} + +function startProfilerTimer(fiber) { + if (!enableProfilerTimer) { + return; + } + + profilerStartTime = now(); + + if (fiber.actualStartTime < 0) { + fiber.actualStartTime = now(); + } +} + +function stopProfilerTimerIfRunning(fiber) { + if (!enableProfilerTimer) { + return; + } + profilerStartTime = -1; +} + +function stopProfilerTimerIfRunningAndRecordDelta(fiber, overrideBaseTime) { + if (!enableProfilerTimer) { + return; + } + + if (profilerStartTime >= 0) { + var elapsedTime = now() - profilerStartTime; + fiber.actualDuration += elapsedTime; + if (overrideBaseTime) { + fiber.selfBaseDuration = elapsedTime; + } + profilerStartTime = -1; + } +} + +/*eslint-disable no-self-compare */ + +var hasOwnProperty = Object.prototype.hasOwnProperty; + +/** * inlined Object.is polyfill to avoid requiring consumers ship their own * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is */ @@ -7622,6 +8263,80 @@ function shallowEqual(objA, objB) { return true; } +function resolveDefaultProps(Component, baseProps) { + if (Component && Component.defaultProps) { + // Resolve default props. Taken from ReactElement + var props = Object.assign({}, baseProps); + var defaultProps = Component.defaultProps; + for (var propName in defaultProps) { + if (props[propName] === undefined) { + props[propName] = defaultProps[propName]; + } + } + return props; + } + return baseProps; +} + +function readLazyComponentType(lazyComponent) { + var status = lazyComponent._status; + var result = lazyComponent._result; + switch (status) { + case Resolved: { + var Component = result; + return Component; + } + case Rejected: { + var error = result; + throw error; + } + case Pending: { + var thenable = result; + 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 + ); + } + } + lazyComponent._status = Resolved; + lazyComponent._result = defaultExport; + } + }, + function(error) { + if (lazyComponent._status === Pending) { + lazyComponent._status = Rejected; + lazyComponent._result = error; + } + } + ); + lazyComponent._result = _thenable; + throw _thenable; + } + } +} + +var ReactCurrentOwner$4 = ReactSharedInternals.ReactCurrentOwner; + +function readContext$1(contextType) { + var dispatcher = ReactCurrentOwner$4.currentDispatcher; + return dispatcher.readContext(contextType); +} + var fakeInternalInstance = {}; var isArray$1 = Array.isArray; @@ -7761,6 +8476,7 @@ var classComponentUpdater = { update.callback = callback; } + flushPassiveEffects(); enqueueUpdate(fiber, update); scheduleWork(fiber, expirationTime); }, @@ -7780,6 +8496,7 @@ var classComponentUpdater = { update.callback = callback; } + flushPassiveEffects(); enqueueUpdate(fiber, update); scheduleWork(fiber, expirationTime); }, @@ -7798,6 +8515,7 @@ var classComponentUpdater = { update.callback = callback; } + flushPassiveEffects(); enqueueUpdate(fiber, update); scheduleWork(fiber, expirationTime); } @@ -8114,7 +8832,7 @@ function constructClassInstance( if (typeof contextType === "object" && contextType !== null) { { if ( - typeof contextType.unstable_read !== "function" && + contextType.$$typeof !== REACT_CONTEXT_TYPE && !didWarnAboutInvalidateContextType.has(ctor) ) { didWarnAboutInvalidateContextType.add(ctor); @@ -8128,7 +8846,7 @@ function constructClassInstance( } } - context = contextType.unstable_read(); + context = readContext$1(contextType); } else { unmaskedContext = getUnmaskedContext(workInProgress, ctor, true); var contextTypes = ctor.contextTypes; @@ -8330,7 +9048,7 @@ function mountClassInstance( var contextType = ctor.contextType; if (typeof contextType === "object" && contextType !== null) { - instance.context = contextType.unstable_read(); + instance.context = readContext$1(contextType); } else { var unmaskedContext = getUnmaskedContext(workInProgress, ctor, true); instance.context = getMaskedContext(workInProgress, unmaskedContext); @@ -8438,7 +9156,7 @@ function resumeMountClassInstance( var contextType = ctor.contextType; var nextContext = void 0; if (typeof contextType === "object" && contextType !== null) { - nextContext = contextType.unstable_read(); + nextContext = readContext$1(contextType); } else { var nextLegacyUnmaskedContext = getUnmaskedContext( workInProgress, @@ -8578,13 +9296,16 @@ function updateClassInstance( var instance = workInProgress.stateNode; var oldProps = workInProgress.memoizedProps; - instance.props = oldProps; + instance.props = + workInProgress.type === workInProgress.elementType + ? oldProps + : resolveDefaultProps(workInProgress.type, oldProps); var oldContext = instance.context; var contextType = ctor.contextType; var nextContext = void 0; if (typeof contextType === "object" && contextType !== null) { - nextContext = contextType.unstable_read(); + nextContext = readContext$1(contextType); } else { var nextUnmaskedContext = getUnmaskedContext(workInProgress, ctor, true); nextContext = getMaskedContext(workInProgress, nextUnmaskedContext); @@ -8827,8 +9548,7 @@ function coerceRef(returnFiber, current$$1, element) { if (owner) { var ownerFiber = owner; invariant( - ownerFiber.tag === ClassComponent || - ownerFiber.tag === ClassComponentLazy, + ownerFiber.tag === ClassComponent, "Function components cannot have refs." ); inst = ownerFiber.stateNode; @@ -9048,7 +9768,7 @@ function ChildReconciler(shouldTrackSideEffects) { } function updateElement(returnFiber, current$$1, element, expirationTime) { - if (current$$1 !== null && current$$1.type === element.type) { + if (current$$1 !== null && current$$1.elementType === element.type) { // Move based on index var existing = useFiber(current$$1, element.props, expirationTime); existing.ref = coerceRef(returnFiber, current$$1, element); @@ -9786,7 +10506,7 @@ function ChildReconciler(shouldTrackSideEffects) { if ( child.tag === Fragment ? element.type === REACT_FRAGMENT_TYPE - : child.type === element.type + : child.elementType === element.type ) { deleteRemainingChildren(returnFiber, child.sibling); var existing = useFiber( @@ -9969,8 +10689,7 @@ function ChildReconciler(shouldTrackSideEffects) { // component, throw an error. If Fiber return types are disabled, // we already threw above. switch (returnFiber.tag) { - case ClassComponent: - case ClassComponentLazy: { + case ClassComponent: { { var instance = returnFiber.stateNode; if (instance.render._isMockFunction) { @@ -10353,49 +11072,6 @@ function resetHydrationState() { isHydrating = false; } -function readLazyComponentType(thenable) { - var status = thenable._reactStatus; - switch (status) { - case Resolved: - var Component = thenable._reactResult; - return Component; - case Rejected: - throw thenable._reactResult; - case Pending: - throw thenable; - default: { - thenable._reactStatus = Pending; - thenable.then( - function(resolvedValue) { - if (thenable._reactStatus === Pending) { - thenable._reactStatus = Resolved; - if (typeof resolvedValue === "object" && resolvedValue !== null) { - // If the `default` property is not empty, assume it's the result - // of an async import() and use that. Otherwise, use the - // resolved value itself. - var defaultExport = resolvedValue.default; - resolvedValue = - defaultExport !== undefined && defaultExport !== null - ? defaultExport - : resolvedValue; - } else { - resolvedValue = resolvedValue; - } - thenable._reactResult = resolvedValue; - } - }, - function(error) { - if (thenable._reactStatus === Pending) { - thenable._reactStatus = Rejected; - thenable._reactResult = error; - } - } - ); - throw thenable; - } - } -} - var ReactCurrentOwner$3 = ReactSharedInternals.ReactCurrentOwner; var didWarnAboutBadClass = void 0; @@ -10478,45 +11154,37 @@ function forceUnmountCurrentAndReconcile( function updateForwardRef( current$$1, workInProgress, - type, + Component, nextProps, renderExpirationTime ) { - var render = type.render; + var render = Component.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); + // React DevTools reads this flag. + workInProgress.effectTag |= PerformedWork; reconcileChildren( current$$1, workInProgress, nextChildren, renderExpirationTime ); - memoizeProps(workInProgress, nextProps); return workInProgress.child; } -function updatePureComponent( +function updateMemoComponent( current$$1, workInProgress, Component, @@ -10524,21 +11192,47 @@ function updatePureComponent( updateExpirationTime, renderExpirationTime ) { - var render = Component.render; - var ref = workInProgress.ref; - - if ( - current$$1 !== null && - (updateExpirationTime === NoWork || - updateExpirationTime > renderExpirationTime) - ) { - var prevProps = current$$1.memoizedProps; + 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 ( - workInProgress.ref === current$$1.ref && - compare(prevProps, nextProps) + compare(prevProps, nextProps) && + current$$1.ref === workInProgress.ref ) { return bailoutOnAlreadyFinishedWork( current$$1, @@ -10547,27 +11241,47 @@ function updatePureComponent( ); } } - - // 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; - reconcileChildren( + 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, - nextChildren, + Component, + nextProps, renderExpirationTime ); - memoizeProps(workInProgress, nextProps); - return workInProgress.child; } function updateFragment(current$$1, workInProgress, renderExpirationTime) { @@ -10578,7 +11292,6 @@ function updateFragment(current$$1, workInProgress, renderExpirationTime) { nextChildren, renderExpirationTime ); - memoizeProps(workInProgress, nextChildren); return workInProgress.child; } @@ -10590,7 +11303,6 @@ function updateMode(current$$1, workInProgress, renderExpirationTime) { nextChildren, renderExpirationTime ); - memoizeProps(workInProgress, nextChildren); return workInProgress.child; } @@ -10606,7 +11318,6 @@ function updateProfiler(current$$1, workInProgress, renderExpirationTime) { nextChildren, renderExpirationTime ); - memoizeProps(workInProgress, nextProps); return workInProgress.child; } @@ -10633,12 +11344,14 @@ function updateFunctionComponent( var nextChildren = void 0; prepareToReadContext(workInProgress, renderExpirationTime); + prepareToUseHooks(current$$1, workInProgress, renderExpirationTime); { ReactCurrentOwner$3.current = workInProgress; setCurrentPhase("render"); nextChildren = Component(nextProps, context); setCurrentPhase(null); } + nextChildren = finishHooks(Component, nextProps, nextChildren, context); // React DevTools reads this flag. workInProgress.effectTag |= PerformedWork; @@ -10648,7 +11361,6 @@ function updateFunctionComponent( nextChildren, renderExpirationTime ); - memoizeProps(workInProgress, nextProps); return workInProgress.child; } @@ -10668,35 +11380,44 @@ function updateClassComponent( pushContextProvider(workInProgress); } else { hasContext = false; - } - prepareToReadContext(workInProgress, renderExpirationTime); - - var shouldUpdate = void 0; - if (current$$1 === null) { - if (workInProgress.stateNode === null) { - // In the initial pass we might need to construct the instance. - constructClassInstance( - workInProgress, - Component, - nextProps, - renderExpirationTime - ); - mountClassInstance( - workInProgress, - Component, - nextProps, - renderExpirationTime - ); - shouldUpdate = true; - } else { - // In a resume, we'll already have an instance we can reuse. - shouldUpdate = resumeMountClassInstance( - workInProgress, - Component, - nextProps, - renderExpirationTime - ); - } + } + 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; + } + // In the initial pass we might need to construct the instance. + constructClassInstance( + workInProgress, + Component, + nextProps, + renderExpirationTime + ); + mountClassInstance( + workInProgress, + Component, + nextProps, + renderExpirationTime + ); + shouldUpdate = true; + } else if (current$$1 === null) { + // In a resume, we'll already have an instance we can reuse. + shouldUpdate = resumeMountClassInstance( + workInProgress, + Component, + nextProps, + renderExpirationTime + ); } else { shouldUpdate = updateClassInstance( current$$1, @@ -10798,10 +11519,9 @@ function finishClassComponent( ); } - // Memoize props and state using the values we just used to render. + // Memoize state using the values we just used to render. // TODO: Restructure so we never read values from the instance. - memoizeState(workInProgress, instance.state); - memoizeProps(workInProgress, instance.props); + workInProgress.memoizedState = instance.state; // The context might have changed so we need to recalculate it. if (hasContext) { @@ -10935,7 +11655,6 @@ function updateHostComponent(current$$1, workInProgress, renderExpirationTime) { ) { // Schedule this fiber to re-render at offscreen priority. Then bailout. workInProgress.expirationTime = Never; - workInProgress.memoizedProps = nextProps; return null; } @@ -10945,7 +11664,6 @@ function updateHostComponent(current$$1, workInProgress, renderExpirationTime) { nextChildren, renderExpirationTime ); - memoizeProps(workInProgress, nextProps); return workInProgress.child; } @@ -10953,120 +11671,178 @@ 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; } -function resolveDefaultProps(Component, baseProps) { - if (Component && Component.defaultProps) { - // Resolve default props. Taken from ReactElement - var props = Object.assign({}, baseProps); - var defaultProps = Component.defaultProps; - for (var propName in defaultProps) { - if (props[propName] === undefined) { - props[propName] = defaultProps[propName]; - } +function mountLazyComponent( + _current, + workInProgress, + elementType, + 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 treat it like + // a new mount, even though an empty version of it already committed. + // Disconnect the alternate pointers. + _current.alternate = null; + workInProgress.alternate = null; + // Since this is conceptually a new fiber, schedule a Placement effect + workInProgress.effectTag |= Placement; + } + + var props = workInProgress.pendingProps; + // We can't start a User Timing measurement with correct label yet. + // Cancel and resume right after we know the tag. + cancelWorkTimer(workInProgress); + var Component = readLazyComponentType(elementType); + // Store the unwrapped component in the type. + workInProgress.type = Component; + var resolvedTag = (workInProgress.tag = resolveLazyComponentTag(Component)); + startWorkTimer(workInProgress); + var resolvedProps = resolveDefaultProps(Component, props); + var child = void 0; + switch (resolvedTag) { + case FunctionComponent: { + child = updateFunctionComponent( + null, + workInProgress, + Component, + resolvedProps, + renderExpirationTime + ); + break; + } + case ClassComponent: { + child = updateClassComponent( + null, + workInProgress, + Component, + resolvedProps, + renderExpirationTime + ); + break; + } + case ForwardRef: { + child = updateForwardRef( + null, + workInProgress, + Component, + resolvedProps, + renderExpirationTime + ); + break; + } + case MemoComponent: { + child = updateMemoComponent( + null, + workInProgress, + Component, + resolveDefaultProps(Component.type, resolvedProps), // The inner type can have defaults too + updateExpirationTime, + renderExpirationTime + ); + break; + } + default: { + // This message intentionally doesn't metion ForwardRef or MemoComponent + // because the fact that it's a separate type of work is an + // implementation detail. + invariant( + false, + "Element type is invalid. Received a promise that resolves to: %s. " + + "Promise elements must resolve to a class or function.", + Component + ); } - return props; } - return baseProps; + return child; } -function mountIndeterminateComponent( - current$$1, +function mountIncompleteClassComponent( + _current, workInProgress, Component, - updateExpirationTime, + nextProps, renderExpirationTime ) { - invariant( - current$$1 === null, - "An indeterminate component should never have mounted. This error is " + - "likely caused by a bug in React. Please file an issue." + if (_current !== null) { + // An incomplete component only mounts if it suspended inside a non- + // concurrent tree, in an inconsistent state. We want to treat it like + // a new mount, even though an empty version of it already committed. + // Disconnect the alternate pointers. + _current.alternate = null; + workInProgress.alternate = null; + // Since this is conceptually a new fiber, schedule a Placement effect + workInProgress.effectTag |= Placement; + } + + // Promote the fiber to a class and try rendering again. + workInProgress.tag = ClassComponent; + + // The rest of this function is a fork of `updateClassComponent` + + // Push context providers early to prevent context stack mismatches. + // During mounting we don't know the child context yet as the instance doesn't exist. + // We will invalidate the child context in finishClassComponent() right after rendering. + var hasContext = void 0; + if (isContextProvider(Component)) { + hasContext = true; + pushContextProvider(workInProgress); + } else { + hasContext = false; + } + prepareToReadContext(workInProgress, renderExpirationTime); + + constructClassInstance( + workInProgress, + Component, + nextProps, + renderExpirationTime + ); + mountClassInstance( + workInProgress, + Component, + nextProps, + renderExpirationTime ); - var props = workInProgress.pendingProps; - if ( - typeof Component === "object" && - Component !== null && - typeof Component.then === "function" - ) { - // We can't start a User Timing measurement with correct label yet. - // Cancel and resume right after we know the tag. - cancelWorkTimer(workInProgress); - Component = readLazyComponentType(Component); - var resolvedTag = (workInProgress.tag = resolveLazyComponentTag( - workInProgress, - Component - )); - startWorkTimer(workInProgress); - var resolvedProps = resolveDefaultProps(Component, props); - var child = void 0; - switch (resolvedTag) { - case FunctionComponentLazy: { - child = updateFunctionComponent( - current$$1, - workInProgress, - Component, - resolvedProps, - renderExpirationTime - ); - break; - } - case ClassComponentLazy: { - child = updateClassComponent( - current$$1, - workInProgress, - Component, - resolvedProps, - renderExpirationTime - ); - break; - } - case ForwardRefLazy: { - child = updateForwardRef( - current$$1, - workInProgress, - Component, - resolvedProps, - renderExpirationTime - ); - break; - } - case PureComponentLazy: { - child = updatePureComponent( - current$$1, - workInProgress, - Component, - resolvedProps, - updateExpirationTime, - renderExpirationTime - ); - break; - } - default: { - // This message intentionally doesn't metion ForwardRef or PureComponent - // because the fact that it's a separate type of work is an - // implementation detail. - invariant( - false, - "Element type is invalid. Received a promise that resolves to: %s. " + - "Promise elements must resolve to a class or function.", - Component - ); - } - } - workInProgress.memoizedProps = props; - return child; + 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 treat it like + // a new mount, even though an empty version of it already committed. + // Disconnect the alternate pointers. + _current.alternate = null; + workInProgress.alternate = null; + // Since this is conceptually a new fiber, schedule a Placement effect + workInProgress.effectTag |= Placement; } + var props = workInProgress.pendingProps; var unmaskedContext = getUnmaskedContext(workInProgress, Component, false); var context = getMaskedContext(workInProgress, unmaskedContext); prepareToReadContext(workInProgress, renderExpirationTime); + prepareToUseHooks(null, workInProgress, renderExpirationTime); var value = void 0; @@ -11108,6 +11884,9 @@ function mountIndeterminateComponent( // Proceed under the assumption that this is a class instance workInProgress.tag = ClassComponent; + // Throw out any hooks that were used. + resetHooks(); + // Push context providers early to prevent context stack mismatches. // During mounting we don't know the child context yet as the instance doesn't exist. // We will invalidate the child context in finishClassComponent() right after rendering. @@ -11135,7 +11914,7 @@ function mountIndeterminateComponent( adoptClassInstance(workInProgress, value); mountClassInstance(workInProgress, Component, props, renderExpirationTime); return finishClassComponent( - current$$1, + null, workInProgress, Component, true, @@ -11145,6 +11924,7 @@ function mountIndeterminateComponent( } else { // Proceed under the assumption that this is a function component workInProgress.tag = FunctionComponent; + value = finishHooks(Component, props, value, context); { if (Component) { !!Component.childContextTypes @@ -11207,8 +11987,7 @@ function mountIndeterminateComponent( } } } - reconcileChildren(current$$1, workInProgress, value, renderExpirationTime); - memoizeProps(workInProgress, props); + reconcileChildren(null, workInProgress, value, renderExpirationTime); return workInProgress.child; } } @@ -11218,67 +11997,258 @@ function updateSuspenseComponent( workInProgress, renderExpirationTime ) { + var mode = workInProgress.mode; var nextProps = workInProgress.pendingProps; - // Check if we already attempted to render the normal state. If we did, - // and we timed out, render the placeholder state. - var alreadyCaptured = (workInProgress.effectTag & DidCapture) === NoEffect; + // We should attempt to render the primary children unless this boundary + // already suspended during this render (`alreadyCaptured` is true). + var nextState = workInProgress.memoizedState; 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; + if ((workInProgress.effectTag & DidCapture) === NoEffect) { + // This is the first attempt. + nextState = null; + nextDidTimeout = false; } else { - nextDidTimeout = !alreadyCaptured; + // Something in this boundary's subtree already suspended. Switch to + // rendering the fallback children. + nextState = { + timedOutAt: nextState !== null ? nextState.timedOutAt : NoWork + }; + nextDidTimeout = true; + workInProgress.effectTag &= ~DidCapture; } - if ((workInProgress.mode & StrictMode) !== NoEffect) { + // This next part is a bit confusing. If the children timeout, we switch to + // showing the fallback children in place of the "primary" children. + // However, we don't want to delete the primary children because then their + // state will be lost (both the React state and the host state, e.g. + // uncontrolled form inputs). Instead we keep them mounted and hide them. + // Both the fallback children AND the primary children are rendered at the + // same time. Once the primary children are un-suspended, we can delete + // the fallback children — don't need to preserve their state. + // + // The two sets of children are siblings in the host environment, but + // semantically, for purposes of reconciliation, they are two separate sets. + // So we store them using two fragment fibers. + // + // However, we want to avoid allocating extra fibers for every placeholder. + // They're only necessary when the children time out, because that's the + // only time when both sets are mounted. + // + // So, the extra fragment fibers are only used if the children time out. + // Otherwise, we render the primary children directly. This requires some + // custom reconciliation logic to preserve the state of the primary + // children. It's essentially a very basic form of re-parenting. + + // `child` points to the child fiber. In the normal case, this is the first + // fiber of the primary children set. In the timed-out case, it's a + // a fragment fiber containing the primary children. + var child = void 0; + // `next` points to the next fiber React should render. In the normal case, + // it's the same as `child`: the first fiber of the primary children set. + // In the timed-out case, it's a fragment fiber containing the *fallback* + // children -- we skip over the primary children entirely. + var next = void 0; + if (current$$1 === null) { + // This is the initial mount. This branch is pretty simple because there's + // no previous state that needs to be preserved. if (nextDidTimeout) { - // If the timed-out view commits, schedule an update effect to record - // the committed time. - workInProgress.effectTag |= Update; + // Mount separate fragments for primary and fallback children. + var nextFallbackChildren = nextProps.fallback; + var primaryChildFragment = createFiberFromFragment( + null, + mode, + NoWork, + null + ); + + if ((workInProgress.mode & ConcurrentMode) === NoContext) { + // Outside of concurrent mode, we commit the effects from the + var progressedState = workInProgress.memoizedState; + var progressedPrimaryChild = + progressedState !== null + ? workInProgress.child.child + : workInProgress.child; + primaryChildFragment.child = progressedPrimaryChild; + } + + var fallbackChildFragment = createFiberFromFragment( + nextFallbackChildren, + mode, + renderExpirationTime, + null + ); + primaryChildFragment.sibling = fallbackChildFragment; + child = primaryChildFragment; + // Skip the primary children, and continue working on the + // fallback children. + next = fallbackChildFragment; + child.return = next.return = workInProgress; } else { - // 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; + // Mount the primary children without an intermediate fragment fiber. + var nextPrimaryChildren = nextProps.children; + child = next = mountChildFibers( + workInProgress, + null, + nextPrimaryChildren, + renderExpirationTime + ); } - } - - // If the `children` prop is a function, treat it like a render prop. - // TODO: This is temporary until we finalize a lower level API. - var children = nextProps.children; - var nextChildren = void 0; - if (typeof children === "function") { - nextChildren = children(nextDidTimeout); } else { - nextChildren = nextDidTimeout ? nextProps.fallback : children; - } + // 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; + 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; + + if ((workInProgress.mode & ConcurrentMode) === NoContext) { + // Outside of concurrent mode, we commit the effects from the + var _progressedState = workInProgress.memoizedState; + var _progressedPrimaryChild = + _progressedState !== null + ? workInProgress.child.child + : workInProgress.child; + if (_progressedPrimaryChild !== currentPrimaryChildFragment.child) { + _primaryChildFragment.child = _progressedPrimaryChild; + } + } - 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 - ); + // Because primaryChildFragment is a new fiber that we're inserting as the + // parent of a new tree, we need to set its treeBaseDuration. + if (enableProfilerTimer && workInProgress.mode & ProfileMode) { + // treeBaseDuration is the sum of all the child tree base durations. + var treeBaseDuration = 0; + var hiddenChild = _primaryChildFragment.child; + while (hiddenChild !== null) { + treeBaseDuration += hiddenChild.treeBaseDuration; + hiddenChild = hiddenChild.sibling; + } + _primaryChildFragment.treeBaseDuration = treeBaseDuration; + } + + // 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 primaryChild = reconcileChildFibers( + workInProgress, + currentPrimaryChild, + _nextPrimaryChildren, + renderExpirationTime + ); + + // If this render doesn't suspend, we need to delete the fallback + // children. Wait until the complete phase, after we've confirmed the + // fallback is no longer needed. + // TODO: Would it be better to store the fallback fragment on + // the stateNode? + + // 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; + + if ((workInProgress.mode & ConcurrentMode) === NoContext) { + // Outside of concurrent mode, we commit the effects from the + var _progressedState2 = workInProgress.memoizedState; + var _progressedPrimaryChild2 = + _progressedState2 !== null + ? workInProgress.child.child + : workInProgress.child; + _primaryChildFragment2.child = _progressedPrimaryChild2; + } + + // Because primaryChildFragment is a new fiber that we're inserting as the + // parent of a new tree, we need to set its treeBaseDuration. + if (enableProfilerTimer && workInProgress.mode & ProfileMode) { + // treeBaseDuration is the sum of all the child tree base durations. + var _treeBaseDuration = 0; + var _hiddenChild = _primaryChildFragment2.child; + while (_hiddenChild !== null) { + _treeBaseDuration += _hiddenChild.treeBaseDuration; + _hiddenChild = _hiddenChild.sibling; + } + _primaryChildFragment2.treeBaseDuration = _treeBaseDuration; + } + + // 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 + ); + } + } } - workInProgress.memoizedProps = nextProps; - workInProgress.memoizedState = nextDidTimeout; - return workInProgress.child; + + workInProgress.memoizedState = nextState; + workInProgress.child = child; + return next; } function updatePortalComponent( @@ -11300,7 +12270,6 @@ function updatePortalComponent( nextChildren, renderExpirationTime ); - memoizeProps(workInProgress, nextChildren); } else { reconcileChildren( current$$1, @@ -11308,7 +12277,6 @@ function updatePortalComponent( nextChildren, renderExpirationTime ); - memoizeProps(workInProgress, nextChildren); } return workInProgress.child; } @@ -11325,7 +12293,6 @@ function updateContextProvider( var oldProps = workInProgress.memoizedProps; var newValue = newProps.value; - workInProgress.memoizedProps = newProps; { var providerPropTypes = workInProgress.type.propTypes; @@ -11394,13 +12361,18 @@ function updateContextConsumer( // in DEV mode if this property exists or not and warn if it does not. { if (context._context === undefined) { - if (!hasWarnedAboutUsingContextAsConsumer) { - hasWarnedAboutUsingContextAsConsumer = true; - warning$1( - false, - "Rendering directly is not supported and will be removed in " + - "a future major release. Did you mean to render instead?" - ); + // This may be because it's a Context (rather than a Consumer). + // Or it may be because it's older React where they're the same thing. + // We only want to warn if we're sure it's a new React. + if (context !== context.Consumer) { + if (!hasWarnedAboutUsingContextAsConsumer) { + hasWarnedAboutUsingContextAsConsumer = true; + warning$1( + false, + "Rendering directly is not supported and will be removed in " + + "a future major release. Did you mean to render instead?" + ); + } } } else { context = context._context; @@ -11439,29 +12411,9 @@ function updateContextConsumer( newChildren, renderExpirationTime ); - workInProgress.memoizedProps = newProps; return workInProgress.child; } -/* - function reuseChildrenEffects(returnFiber : Fiber, firstChild : Fiber) { - let child = firstChild; - do { - // Ensure that the first and last effect of the parent corresponds - // to the children's first and last effect. - if (!returnFiber.firstEffect) { - returnFiber.firstEffect = child.firstEffect; - } - if (child.lastEffect) { - if (returnFiber.lastEffect) { - returnFiber.lastEffect.nextEffect = child.firstEffect; - } - returnFiber.lastEffect = child.lastEffect; - } - } while (child = child.sibling); - } - */ - function bailoutOnAlreadyFinishedWork( current$$1, workInProgress, @@ -11481,10 +12433,7 @@ function bailoutOnAlreadyFinishedWork( // Check if the children have any pending work. var childExpirationTime = workInProgress.childExpirationTime; - if ( - childExpirationTime === NoWork || - childExpirationTime > renderExpirationTime - ) { + if (childExpirationTime < renderExpirationTime) { // The children don't have any work either. We can skip them. // TODO: Once we add back resuming, we should check if the children are // a work-in-progress set. If so, we need to transfer their effects. @@ -11497,17 +12446,6 @@ function bailoutOnAlreadyFinishedWork( } } -// TODO: Delete memoizeProps/State and move to reconcile/bailout instead -function memoizeProps(workInProgress, nextProps) { - workInProgress.memoizedProps = nextProps; -} - -function memoizeState(workInProgress, nextState) { - workInProgress.memoizedState = nextState; - // Don't reset the updateQueue, in case there are pending updates. Resetting - // is handled by processUpdateQueue. -} - function beginWork(current$$1, workInProgress, renderExpirationTime) { var updateExpirationTime = workInProgress.expirationTime; @@ -11517,8 +12455,7 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { if ( oldProps === newProps && !hasContextChanged() && - (updateExpirationTime === NoWork || - updateExpirationTime > renderExpirationTime) + updateExpirationTime < renderExpirationTime ) { // This fiber does not have any pending work. Bailout without entering // the begin phase. There's still some bookkeeping we that needs to be done @@ -11538,14 +12475,6 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { } break; } - case ClassComponentLazy: { - var thenable = workInProgress.type; - var _Component = getResultFromResolvedThenable(thenable); - if (isContextProvider(_Component)) { - pushContextProvider(workInProgress); - } - break; - } case HostPortal: pushHostContainer( workInProgress, @@ -11562,6 +12491,46 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { workInProgress.effectTag |= Update; } break; + case SuspenseComponent: { + var state = workInProgress.memoizedState; + var didTimeout = state !== null; + if (didTimeout) { + // If this boundary is currently timed out, we need to decide + // whether to retry the primary children, or to skip over it and + // go straight to the fallback. Check the priority of the primary + var primaryChildFragment = workInProgress.child; + var primaryChildExpirationTime = + primaryChildFragment.childExpirationTime; + if ( + primaryChildExpirationTime !== NoWork && + primaryChildExpirationTime >= renderExpirationTime + ) { + // The primary children have pending work. Use the normal path + // to attempt to render the primary children again. + return updateSuspenseComponent( + current$$1, + workInProgress, + renderExpirationTime + ); + } else { + // The primary children do not have pending work with sufficient + // priority. Bailout. + var child = bailoutOnAlreadyFinishedWork( + current$$1, + workInProgress, + renderExpirationTime + ); + if (child !== null) { + // The fallback children have pending work. Skip over the + // primary children and work on the fallback. + return child.sibling; + } else { + return null; + } + } + } + break; + } } return bailoutOnAlreadyFinishedWork( current$$1, @@ -11576,64 +12545,53 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { switch (workInProgress.tag) { case IndeterminateComponent: { - var _Component2 = workInProgress.type; + var elementType = workInProgress.elementType; return mountIndeterminateComponent( current$$1, workInProgress, - _Component2, - updateExpirationTime, + elementType, renderExpirationTime ); } - case FunctionComponent: { - var _Component3 = workInProgress.type; - var unresolvedProps = workInProgress.pendingProps; - return updateFunctionComponent( + case LazyComponent: { + var _elementType = workInProgress.elementType; + return mountLazyComponent( current$$1, workInProgress, - _Component3, - unresolvedProps, + _elementType, + updateExpirationTime, renderExpirationTime ); } - case FunctionComponentLazy: { - var _thenable = workInProgress.type; - var _Component4 = getResultFromResolvedThenable(_thenable); - var _unresolvedProps = workInProgress.pendingProps; - var child = updateFunctionComponent( + case FunctionComponent: { + var _Component = workInProgress.type; + var unresolvedProps = workInProgress.pendingProps; + var resolvedProps = + workInProgress.elementType === _Component + ? unresolvedProps + : resolveDefaultProps(_Component, unresolvedProps); + return updateFunctionComponent( current$$1, workInProgress, - _Component4, - resolveDefaultProps(_Component4, _unresolvedProps), + _Component, + resolvedProps, renderExpirationTime ); - workInProgress.memoizedProps = _unresolvedProps; - return child; } case ClassComponent: { - var _Component5 = workInProgress.type; - var _unresolvedProps2 = workInProgress.pendingProps; + var _Component2 = workInProgress.type; + var _unresolvedProps = workInProgress.pendingProps; + var _resolvedProps = + workInProgress.elementType === _Component2 + ? _unresolvedProps + : resolveDefaultProps(_Component2, _unresolvedProps); return updateClassComponent( current$$1, workInProgress, - _Component5, - _unresolvedProps2, - 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), + _Component2, + _resolvedProps, renderExpirationTime ); - workInProgress.memoizedProps = _unresolvedProps3; - return _child; } case HostRoot: return updateHostRoot(current$$1, workInProgress, renderExpirationTime); @@ -11659,27 +12617,18 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { ); case ForwardRef: { var type = workInProgress.type; + var _unresolvedProps2 = workInProgress.pendingProps; + var _resolvedProps2 = + workInProgress.elementType === type + ? _unresolvedProps2 + : resolveDefaultProps(type, _unresolvedProps2); return updateForwardRef( current$$1, workInProgress, type, - workInProgress.pendingProps, - 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), + _resolvedProps2, renderExpirationTime ); - workInProgress.memoizedProps = _unresolvedProps4; - return _child2; } case Fragment: return updateFragment(current$$1, workInProgress, renderExpirationTime); @@ -11699,31 +12648,43 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { workInProgress, renderExpirationTime ); - case PureComponent: { + case MemoComponent: { var _type = workInProgress.type; - return updatePureComponent( + var _unresolvedProps3 = workInProgress.pendingProps; + var _resolvedProps3 = resolveDefaultProps(_type.type, _unresolvedProps3); + return updateMemoComponent( current$$1, workInProgress, _type, - workInProgress.pendingProps, + _resolvedProps3, updateExpirationTime, renderExpirationTime ); } - case PureComponentLazy: { - var _thenable4 = workInProgress.type; - var _Component8 = getResultFromResolvedThenable(_thenable4); - var _unresolvedProps5 = workInProgress.pendingProps; - var _child3 = updatePureComponent( + case SimpleMemoComponent: { + return updateSimpleMemoComponent( current$$1, workInProgress, - _Component8, - resolveDefaultProps(_Component8, _unresolvedProps5), + workInProgress.type, + workInProgress.pendingProps, updateExpirationTime, renderExpirationTime ); - workInProgress.memoizedProps = _unresolvedProps5; - return _child3; + } + case IncompleteClassComponent: { + var _Component3 = workInProgress.type; + var _unresolvedProps4 = workInProgress.pendingProps; + var _resolvedProps4 = + workInProgress.elementType === _Component3 + ? _unresolvedProps4 + : resolveDefaultProps(_Component3, _unresolvedProps4); + return mountIncompleteClassComponent( + current$$1, + workInProgress, + _Component3, + _resolvedProps4, + renderExpirationTime + ); } default: invariant( @@ -11744,42 +12705,48 @@ function markRef$1(workInProgress) { workInProgress.effectTag |= Ref; } -function appendAllChildren(parent, workInProgress) { - // We only have the top Fiber that was created but we need recurse down its - // children to find all the terminal nodes. - var node = workInProgress.child; - while (node !== null) { - if (node.tag === HostComponent || node.tag === HostText) { - appendInitialChild(parent, node.stateNode); - } else if (node.tag === HostPortal) { - // If we have a portal child, then we don't want to traverse - // down its children. Instead, we'll get insertions from each child in - // the portal directly. - } else if (node.child !== null) { - node.child.return = node; - node = node.child; - continue; - } - if (node === workInProgress) { - return; - } - while (node.sibling === null) { - if (node.return === null || node.return === workInProgress) { - return; - } - node = node.return; - } - node.sibling.return = node.return; - node = node.sibling; - } -} - +var appendAllChildren = void 0; var updateHostContainer = void 0; var updateHostComponent$1 = void 0; var updateHostText$1 = void 0; if (supportsMutation) { // Mutation mode + appendAllChildren = function( + parent, + workInProgress, + needsVisibilityToggle, + isHidden + ) { + // We only have the top Fiber that was created but we need recurse down its + // children to find all the terminal nodes. + var node = workInProgress.child; + while (node !== null) { + if (node.tag === HostComponent || node.tag === HostText) { + appendInitialChild(parent, node.stateNode); + } else if (node.tag === HostPortal) { + // If we have a portal child, then we don't want to traverse + // down its children. Instead, we'll get insertions from each child in + // the portal directly. + } else if (node.child !== null) { + node.child.return = node; + node = node.child; + continue; + } + if (node === workInProgress) { + return; + } + while (node.sibling === null) { + if (node.return === null || node.return === workInProgress) { + return; + } + node = node.return; + } + node.sibling.return = node.return; + node = node.sibling; + } + }; + updateHostContainer = function(workInProgress) { // Noop }; @@ -11833,26 +12800,202 @@ 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; + var newIsHidden = newState !== null; + 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 + workInProgress, + needsVisibilityToggle, + isHidden ) { // We only have the top Fiber that was created but we need recurse down its // children to find all the terminal nodes. var node = workInProgress.child; while (node !== null) { - if (node.tag === HostComponent || node.tag === HostText) { - appendChildToContainerChildSet(containerChildSet, node.stateNode); + // eslint-disable-next-line no-labels + branches: if (node.tag === HostComponent) { + var instance = node.stateNode; + if (needsVisibilityToggle) { + var props = node.memoizedProps; + var type = node.type; + if (isHidden) { + // This child is inside a timed out tree. Hide it. + instance = cloneHiddenInstance(instance, type, props, node); + } else { + // This child was previously inside a timed out tree. If it was not + // updated during this render, it may need to be unhidden. Clone + // again to be sure. + instance = cloneUnhiddenInstance(instance, type, props, node); + } + node.stateNode = instance; + } + appendChildToContainerChildSet(containerChildSet, instance); + } else if (node.tag === HostText) { + var _instance2 = node.stateNode; + if (needsVisibilityToggle) { + var text = node.memoizedProps; + var rootContainerInstance = getRootHostContainer(); + var currentHostContext = getHostContext(); + if (isHidden) { + _instance2 = createHiddenTextInstance( + text, + rootContainerInstance, + currentHostContext, + workInProgress + ); + } else { + _instance2 = createTextInstance( + text, + rootContainerInstance, + currentHostContext, + workInProgress + ); + } + node.stateNode = _instance2; + } + appendChildToContainerChildSet(containerChildSet, _instance2); } else if (node.tag === HostPortal) { // If we have a portal child, then we don't want to traverse // down its children. Instead, we'll get insertions from each child in // the portal directly. + } else if (node.tag === SuspenseComponent) { + var current = node.alternate; + if (current !== null) { + var oldState = current.memoizedState; + var newState = node.memoizedState; + var oldIsHidden = oldState !== null; + var newIsHidden = newState !== null; + if (oldIsHidden !== newIsHidden) { + // The placeholder either just timed out or switched back to the normal + // children after having previously timed out. Toggle the visibility of + // the direct host children. + var primaryChildParent = newIsHidden ? node.child : node; + if (primaryChildParent !== null) { + appendAllChildrenToContainer( + containerChildSet, + primaryChildParent, + true, + newIsHidden + ); + } + // eslint-disable-next-line no-labels + break branches; + } + } + if (node.child !== null) { + // Continue traversing like normal + node.child.return = node; + node = node.child; + continue; + } } else if (node.child !== null) { node.child.return = node; node = node.child; continue; } + // $FlowFixMe This is correct but Flow is confused by the labeled break. + node = node; if (node === workInProgress) { return; } @@ -11875,7 +13018,7 @@ if (supportsMutation) { var container = portalOrRoot.containerInfo; var newChildSet = createContainerChildSet(container); // If children might have changed, we have to add them all to the set. - appendAllChildrenToContainer(newChildSet, workInProgress); + appendAllChildrenToContainer(newChildSet, workInProgress, false, false); portalOrRoot.pendingChildren = newChildSet; // Schedule an update on the container to swap out the container. markUpdate(workInProgress); @@ -11948,7 +13091,7 @@ if (supportsMutation) { markUpdate(workInProgress); } else { // If children might have changed, we have to add them all to the set. - appendAllChildren(newInstance, workInProgress); + appendAllChildren(newInstance, workInProgress, false, false); } }; updateHostText$1 = function(current, workInProgress, oldText, newText) { @@ -11990,8 +13133,12 @@ function completeWork(current, workInProgress, renderExpirationTime) { var newProps = workInProgress.pendingProps; switch (workInProgress.tag) { + case IndeterminateComponent: + break; + case LazyComponent: + break; + case SimpleMemoComponent: case FunctionComponent: - case FunctionComponentLazy: break; case ClassComponent: { var Component = workInProgress.type; @@ -12000,13 +13147,6 @@ function completeWork(current, workInProgress, renderExpirationTime) { } break; } - case ClassComponentLazy: { - var _Component = getResultFromResolvedThenable(workInProgress.type); - if (isContextProvider(_Component)) { - popContext(workInProgress); - } - break; - } case HostRoot: { popHostContainer(workInProgress); popTopLevelContextObject(workInProgress); @@ -12082,7 +13222,7 @@ function completeWork(current, workInProgress, renderExpirationTime) { workInProgress ); - appendAllChildren(instance, workInProgress); + appendAllChildren(instance, workInProgress, false, false); // Certain renderers require commit-time effects for initial mount. // (eg DOM renderer supports auto-focus for certain elements). @@ -12143,10 +13283,50 @@ function completeWork(current, workInProgress, renderExpirationTime) { break; } case ForwardRef: - case ForwardRefLazy: break; - case SuspenseComponent: + case SuspenseComponent: { + var nextState = workInProgress.memoizedState; + if ((workInProgress.effectTag & DidCapture) !== NoEffect) { + // Something suspended. Re-render with the fallback children. + workInProgress.expirationTime = renderExpirationTime; + // Do not reset the effect list. + return workInProgress; + } + + var nextDidTimeout = nextState !== null; + var prevDidTimeout = current !== null && current.memoizedState !== null; + + if (current !== null && !nextDidTimeout && prevDidTimeout) { + // We just switched from the fallback to the normal children. Delete + // the fallback. + // TODO: Would it be better to store the fallback fragment on + var currentFallbackChild = current.child.sibling; + if (currentFallbackChild !== null) { + reconcileChildFibers( + workInProgress, + currentFallbackChild, + null, + renderExpirationTime + ); + } + } + + // The children either timed out after previously being visible, or + // were restored after previously being hidden. Schedule an effect + // to update their visiblity. + if ( + // + nextDidTimeout !== prevDidTimeout || + // Outside concurrent mode, the primary children commit in an + // inconsistent state, even if they are hidden. So if they are hidden, + // we need to schedule an effect to re-hide them, just in case. + ((workInProgress.effectTag & ConcurrentMode) === NoContext && + nextDidTimeout) + ) { + workInProgress.effectTag |= Update; + } break; + } case Fragment: break; case Mode: @@ -12163,18 +13343,17 @@ function completeWork(current, workInProgress, renderExpirationTime) { break; case ContextConsumer: break; - case PureComponent: - case PureComponentLazy: + case MemoComponent: break; - // Error cases - case IndeterminateComponent: - invariant( - false, - "An indeterminate component should have become determinate before " + - "completing. This error is likely caused by a bug in React. Please " + - "file an issue." - ); - // eslint-disable-next-line no-fallthrough + case IncompleteClassComponent: { + // Same as class component case. I put it down here so that the tags are + // sequential to ensure this switch is compiled to a jump table. + var _Component = workInProgress.type; + if (isContextProvider(_Component)) { + popContext(workInProgress); + } + break; + } default: invariant( false, @@ -12186,6 +13365,17 @@ function completeWork(current, workInProgress, renderExpirationTime) { return null; } +function shouldCaptureSuspense(current, workInProgress) { + // In order to capture, the Suspense component must have a fallback prop. + if (workInProgress.memoizedProps.fallback === undefined) { + return false; + } + // If it was the primary children that just suspended, capture and render the + // fallback. Otherwise, don't capture and bubble to the next boundary. + var nextState = workInProgress.memoizedState; + return nextState === null; +} + // Module provided by RN: /** * Intercept lifecycle errors and ensure they are shown with the correct stack @@ -12302,8 +13492,6 @@ function logCapturedError(capturedError) { } } -var emptyObject$1 = {}; - var didWarnAboutUndefinedSnapshotBeforeUpdate = null; { didWarnAboutUndefinedSnapshotBeforeUpdate = new Set(); @@ -12388,19 +13576,60 @@ function safelyDetachRef(current$$1) { } } +function safelyCallDestroy(current$$1, destroy) { + { + invokeGuardedCallback(null, destroy, null); + if (hasCaughtError()) { + var error = clearCaughtError(); + captureCommitPhaseError(current$$1, error); + } + } +} + function commitBeforeMutationLifeCycles(current$$1, finishedWork) { switch (finishedWork.tag) { - case ClassComponent: - case ClassComponentLazy: { + case FunctionComponent: + case ForwardRef: + case SimpleMemoComponent: { + commitHookEffectList(UnmountSnapshot, NoEffect$1, finishedWork); + return; + } + case ClassComponent: { if (finishedWork.effectTag & Snapshot) { if (current$$1 !== null) { var prevProps = current$$1.memoizedProps; var prevState = current$$1.memoizedState; startPhaseTimer(finishedWork, "getSnapshotBeforeUpdate"); var instance = finishedWork.stateNode; - instance.props = finishedWork.memoizedProps; - instance.state = finishedWork.memoizedState; - var snapshot = instance.getSnapshotBeforeUpdate(prevProps, prevState); + // We could update instance props and state here, + // but instead we rely on them being set during last render. + // TODO: revisit this when we implement resuming. + { + if (finishedWork.type === finishedWork.elementType) { + !(instance.props === finishedWork.memoizedProps) + ? warning$1( + false, + "Expected instance props to match memoized props before " + + "getSnapshotBeforeUpdate. This is likely due to a bug in React. " + + "Please file an issue." + ) + : void 0; + !(instance.state === finishedWork.memoizedState) + ? warning$1( + false, + "Expected instance state to match memoized state before " + + "getSnapshotBeforeUpdate. This is likely due to a bug in React. " + + "Please file an issue." + ) + : void 0; + } + } + var snapshot = instance.getSnapshotBeforeUpdate( + finishedWork.elementType === finishedWork.type + ? prevProps + : resolveDefaultProps(finishedWork.type, prevProps), + prevState + ); { var didWarnSet = didWarnAboutUndefinedSnapshotBeforeUpdate; if (snapshot === undefined && !didWarnSet.has(finishedWork.type)) { @@ -12423,6 +13652,7 @@ function commitBeforeMutationLifeCycles(current$$1, finishedWork) { case HostComponent: case HostText: case HostPortal: + case IncompleteClassComponent: // Nothing to do for these component types return; default: { @@ -12435,6 +13665,58 @@ function commitBeforeMutationLifeCycles(current$$1, finishedWork) { } } +function commitHookEffectList(unmountTag, mountTag, finishedWork) { + if (!enableHooks) { + return; + } + 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(); + if (typeof _destroy !== "function") { + { + if (_destroy !== null && _destroy !== undefined) { + warningWithoutStack$1( + false, + "useEffect function must return a cleanup function or " + + "nothing.%s%s", + typeof _destroy.then === "function" + ? " Promises and useEffect(async () => ...) are not " + + "supported, but you can call an async function inside an " + + "effect." + : "", + getStackByFiberInDevAndProd(finishedWork) + ); + } + } + _destroy = null; + } + effect.destroy = _destroy; + } + effect = effect.next; + } while (effect !== firstEffect); + } +} + +function commitPassiveHookEffects(finishedWork) { + commitHookEffectList(UnmountPassive, NoEffect$1, finishedWork); + commitHookEffectList(NoEffect$1, MountPassive, finishedWork); +} + function commitLifeCycles( finishedRoot, current$$1, @@ -12442,22 +13724,75 @@ function commitLifeCycles( committedExpirationTime ) { switch (finishedWork.tag) { - case ClassComponent: - case ClassComponentLazy: { + case FunctionComponent: + case ForwardRef: + case SimpleMemoComponent: { + commitHookEffectList(UnmountLayout, MountLayout, finishedWork); + break; + } + case ClassComponent: { var instance = finishedWork.stateNode; if (finishedWork.effectTag & Update) { if (current$$1 === null) { startPhaseTimer(finishedWork, "componentDidMount"); - instance.props = finishedWork.memoizedProps; - instance.state = finishedWork.memoizedState; + // We could update instance props and state here, + // but instead we rely on them being set during last render. + // TODO: revisit this when we implement resuming. + { + if (finishedWork.type === finishedWork.elementType) { + !(instance.props === finishedWork.memoizedProps) + ? warning$1( + false, + "Expected instance props to match memoized props before " + + "componentDidMount. This is likely due to a bug in React. " + + "Please file an issue." + ) + : void 0; + !(instance.state === finishedWork.memoizedState) + ? warning$1( + false, + "Expected instance state to match memoized state before " + + "componentDidMount. This is likely due to a bug in React. " + + "Please file an issue." + ) + : void 0; + } + } instance.componentDidMount(); stopPhaseTimer(); } else { - var prevProps = current$$1.memoizedProps; + var prevProps = + finishedWork.elementType === finishedWork.type + ? current$$1.memoizedProps + : resolveDefaultProps( + finishedWork.type, + current$$1.memoizedProps + ); var prevState = current$$1.memoizedState; startPhaseTimer(finishedWork, "componentDidUpdate"); - instance.props = finishedWork.memoizedProps; - instance.state = finishedWork.memoizedState; + // We could update instance props and state here, + // but instead we rely on them being set during last render. + // TODO: revisit this when we implement resuming. + { + if (finishedWork.type === finishedWork.elementType) { + !(instance.props === finishedWork.memoizedProps) + ? warning$1( + false, + "Expected instance props to match memoized props before " + + "componentDidUpdate. This is likely due to a bug in React. " + + "Please file an issue." + ) + : void 0; + !(instance.state === finishedWork.memoizedState) + ? warning$1( + false, + "Expected instance state to match memoized state before " + + "componentDidUpdate. This is likely due to a bug in React. " + + "Please file an issue." + ) + : void 0; + } + } instance.componentDidUpdate( prevProps, prevState, @@ -12468,8 +13803,29 @@ function commitLifeCycles( } var updateQueue = finishedWork.updateQueue; if (updateQueue !== null) { - instance.props = finishedWork.memoizedProps; - instance.state = finishedWork.memoizedState; + { + if (finishedWork.type === finishedWork.elementType) { + !(instance.props === finishedWork.memoizedProps) + ? warning$1( + false, + "Expected instance props to match memoized props before " + + "processing the update queue. This is likely due to a bug in React. " + + "Please file an issue." + ) + : void 0; + !(instance.state === finishedWork.memoizedState) + ? warning$1( + false, + "Expected instance state to match memoized state before " + + "processing the update queue. This is likely due to a bug in React. " + + "Please file an issue." + ) + : void 0; + } + } + // We could update instance props and state here, + // but instead we rely on them being set during last render. + // TODO: revisit this when we implement resuming. commitUpdateQueue( finishedWork, updateQueue, @@ -12489,7 +13845,6 @@ function commitLifeCycles( _instance = getPublicInstance(finishedWork.child.stateNode); break; case ClassComponent: - case ClassComponentLazy: _instance = finishedWork.child.stateNode; break; } @@ -12552,23 +13907,10 @@ function commitLifeCycles( } return; } - case SuspenseComponent: { - if ((finishedWork.mode & StrictMode) === NoEffect) { - // In loose mode, a placeholder times out by scheduling a synchronous - // update in the commit phase. Use `updateQueue` field to signal that - // the Timeout needs to switch to the placeholder. We don't need an - // entire queue. Any non-null value works. - // $FlowFixMe - Intentionally using a value other than an UpdateQueue. - finishedWork.updateQueue = emptyObject$1; - scheduleWork(finishedWork, Sync); - } else { - // In strict mode, the Update effect is used to record the time at - // which the placeholder timed out. - var currentTime = requestCurrentTime(); - finishedWork.stateNode = { timedOutAt: currentTime }; - } - return; - } + case SuspenseComponent: + break; + case IncompleteClassComponent: + break; default: { invariant( false, @@ -12579,6 +13921,45 @@ function commitLifeCycles( } } +function hideOrUnhideAllChildren(finishedWork, isHidden) { + if (supportsMutation) { + // We only have the top Fiber that was inserted but we need recurse down its + var node = finishedWork; + while (true) { + if (node.tag === HostComponent) { + var instance = node.stateNode; + if (isHidden) { + hideInstance(instance); + } else { + unhideInstance(node.stateNode, node.memoizedProps); + } + } else if (node.tag === HostText) { + var _instance3 = node.stateNode; + if (isHidden) { + hideTextInstance(_instance3); + } else { + unhideTextInstance(_instance3, node.memoizedProps); + } + } else if (node.child !== null) { + node.child.return = node; + node = node.child; + continue; + } + if (node === finishedWork) { + return; + } + while (node.sibling === null) { + if (node.return === null || node.return === finishedWork) { + return; + } + node = node.return; + } + node.sibling.return = node.return; + node = node.sibling; + } + } +} + function commitAttachRef(finishedWork) { var ref = finishedWork.ref; if (ref !== null) { @@ -12629,8 +14010,28 @@ function commitUnmount(current$$1) { onCommitUnmount(current$$1); switch (current$$1.tag) { - case ClassComponent: - case ClassComponentLazy: { + case FunctionComponent: + case ForwardRef: + case MemoComponent: + case SimpleMemoComponent: { + var updateQueue = current$$1.updateQueue; + if (updateQueue !== null) { + var lastEffect = updateQueue.lastEffect; + if (lastEffect !== null) { + var firstEffect = lastEffect.next; + var effect = firstEffect; + do { + var destroy = effect.destroy; + if (destroy !== null) { + safelyCallDestroy(current$$1, destroy); + } + effect = effect.next; + } while (effect !== firstEffect); + } + } + break; + } + case ClassComponent: { safelyDetachRef(current$$1); var instance = current$$1.stateNode; if (typeof instance.componentWillUnmount === "function") { @@ -12722,8 +14123,7 @@ function commitContainer(finishedWork) { } switch (finishedWork.tag) { - case ClassComponent: - case ClassComponentLazy: { + case ClassComponent: { return; } case HostComponent: { @@ -12997,13 +14397,29 @@ function commitDeletion(current$$1) { function commitWork(current$$1, finishedWork) { if (!supportsMutation) { + switch (finishedWork.tag) { + case FunctionComponent: + case ForwardRef: + case MemoComponent: + case SimpleMemoComponent: { + commitHookEffectList(UnmountMutation, MountMutation, finishedWork); + return; + } + } + commitContainer(finishedWork); return; } switch (finishedWork.tag) { - case ClassComponent: - case ClassComponentLazy: { + case FunctionComponent: + case ForwardRef: + case MemoComponent: + case SimpleMemoComponent: { + commitHookEffectList(UnmountMutation, MountMutation, finishedWork); + return; + } + case ClassComponent: { return; } case HostComponent: { @@ -13055,6 +14471,29 @@ function commitWork(current$$1, finishedWork) { return; } case SuspenseComponent: { + var newState = finishedWork.memoizedState; + + var newDidTimeout = void 0; + var primaryChildParent = finishedWork; + if (newState === null) { + newDidTimeout = false; + } else { + newDidTimeout = true; + primaryChildParent = finishedWork.child; + 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 (primaryChildParent !== null) { + hideOrUnhideAllChildren(primaryChildParent, newDidTimeout); + } + return; + } + case IncompleteClassComponent: { return; } default: { @@ -13074,10 +14513,6 @@ function commitResetTextContent(current$$1) { resetTextContent(current$$1.stateNode); } -function NoopComponent() { - return null; -} - function createRootErrorUpdate(fiber, errorInfo, expirationTime) { var update = createUpdate(expirationTime); // Unmount the root by rendering null. @@ -13171,22 +14606,17 @@ function throwException( var startTimeMs = -1; do { if (_workInProgress.tag === SuspenseComponent) { - var current = _workInProgress.alternate; - if ( - current !== null && - current.memoizedState === true && - current.stateNode !== null - ) { - // Reached a placeholder that already timed out. Each timed out - // placeholder acts as the root of a new suspense boundary. - - // Use the time at which the placeholder timed out as the start time - // for the current render. - var timedOutAt = current.stateNode.timedOutAt; - startTimeMs = expirationTimeToMs(timedOutAt); - - // Do not search any further. - break; + var current$$1 = _workInProgress.alternate; + if (current$$1 !== null) { + var currentState = current$$1.memoizedState; + if (currentState !== null) { + // Reached a boundary that already timed out. Do not search + // any further. + var timedOutAt = currentState.timedOutAt; + startTimeMs = expirationTimeToMs(timedOutAt); + // Do not search any further. + break; + } } var timeoutPropMs = _workInProgress.pendingProps.maxDuration; if (typeof timeoutPropMs === "number") { @@ -13206,129 +14636,131 @@ function throwException( // Schedule the nearest Suspense to re-render the timed out view. _workInProgress = returnFiber; do { - if (_workInProgress.tag === SuspenseComponent) { - var didTimeout = _workInProgress.memoizedState; - if (!didTimeout) { - // Found the nearest boundary. - - // If the boundary is not in concurrent mode, we should not suspend, and - // likewise, when the promise resolves, we should ping synchronously. - var pingTime = - (_workInProgress.mode & ConcurrentMode) === NoEffect - ? Sync - : renderExpirationTime; - - // Attach a listener to the promise to "ping" the root and retry. - var onResolveOrReject = retrySuspendedRoot.bind( - null, - root, - _workInProgress, - pingTime + if ( + _workInProgress.tag === SuspenseComponent && + shouldCaptureSuspense(_workInProgress.alternate, _workInProgress) + ) { + // Found the nearest boundary. + + // If the boundary is not in concurrent mode, we should not suspend, and + // likewise, when the promise resolves, we should ping synchronously. + var pingTime = + (_workInProgress.mode & ConcurrentMode) === NoEffect + ? Sync + : renderExpirationTime; + + // 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 |= DidCapture; + + // Unmount the source fiber's children + var nextChildren = null; + reconcileChildren( + sourceFiber.alternate, + sourceFiber, + nextChildren, + renderExpirationTime ); - if (enableSchedulerTracing) { - onResolveOrReject = tracing.unstable_wrap(onResolveOrReject); - } - thenable.then(onResolveOrReject, onResolveOrReject); - - // 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; - - // Unmount the source fiber's children - var nextChildren = null; - reconcileChildren( - sourceFiber.alternate, - sourceFiber, - nextChildren, - renderExpirationTime - ); - sourceFiber.effectTag &= ~Incomplete; - if (sourceFiber.tag === IndeterminateComponent) { - // Let's just assume it's a function component. This fiber will - // be unmounted in the immediate next commit, anyway. - sourceFiber.tag = FunctionComponent; + 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 ( - 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; - } - } + // The source fiber did not complete. Mark it with the current + // render priority to indicate that it still has pending work. + sourceFiber.expirationTime = renderExpirationTime; - // Exit without suspending. - return; - } + // Exit without suspending. + return; + } - // Confirmed that the boundary is in a strict mode tree. Continue with - // the normal suspend path. + // Confirmed that the boundary is in a concurrent mode tree. Continue + // with the normal suspend path. - var absoluteTimeoutMs = void 0; - if (earliestTimeoutMs === -1) { - // If no explicit threshold is given, default to an abitrarily large - // value. The actual size doesn't matter because the threshold for the - // whole tree will be clamped to the expiration time. - absoluteTimeoutMs = maxSigned31BitInt; - } else { - if (startTimeMs === -1) { - // This suspend happened outside of any already timed-out - // placeholders. We don't know exactly when the update was scheduled, - // but we can infer an approximate start time from the expiration - // time. First, find the earliest uncommitted expiration time in the - // tree, including work that is suspended. Then subtract the offset - // used to compute an async update's expiration time. This will cause - // high priority (interactive) work to expire earlier than necessary, - // but we can account for this by adjusting for the Just Noticeable - // Difference. - var earliestExpirationTime = findEarliestOutstandingPriorityLevel( - root, - renderExpirationTime - ); - var earliestExpirationTimeMs = expirationTimeToMs( - earliestExpirationTime - ); - startTimeMs = earliestExpirationTimeMs - LOW_PRIORITY_EXPIRATION; - } - absoluteTimeoutMs = startTimeMs + earliestTimeoutMs; + 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); + // Mark the earliest timeout in the suspended fiber's ancestor path. + // After completing the root, we'll take the largest of all the + // suspended fiber's timeouts and use it to compute a timeout for the + // whole tree. + renderDidSuspend(root, absoluteTimeoutMs, renderExpirationTime); - _workInProgress.effectTag |= ShouldCapture; - _workInProgress.expirationTime = renderExpirationTime; - return; - } - // This boundary already captured during this render. Continue to the - // next boundary. + _workInProgress.effectTag |= ShouldCapture; + _workInProgress.expirationTime = renderExpirationTime; + return; } + // This boundary already captured during this render. Continue to the next + // boundary. _workInProgress = _workInProgress.return; } while (_workInProgress !== null); // No boundary was found. Fallthrough to error mode. + // TODO: Use invariant so the message is stripped in prod? value = new Error( - "An update was suspended, but no placeholder UI was provided." + (getComponentName(sourceFiber.type) || "A React component") + + " suspended while rendering, but no fallback UI was specified.\n" + + "\n" + + "Add a component higher in the tree to " + + "provide a loading indicator or placeholder to display." + + getStackByFiberInDevAndProd(sourceFiber) ); } @@ -13353,7 +14785,6 @@ function throwException( return; } case ClassComponent: - case ClassComponentLazy: // Capture and retry var errorInfo = value; var ctor = workInProgress.type; @@ -13398,28 +14829,16 @@ function unwindWork(workInProgress, renderExpirationTime) { } return null; } - case ClassComponentLazy: { - var _Component = workInProgress.type._reactResult; - if (isContextProvider(_Component)) { - popContext(workInProgress); - } - var _effectTag = workInProgress.effectTag; - if (_effectTag & ShouldCapture) { - workInProgress.effectTag = (_effectTag & ~ShouldCapture) | DidCapture; - return workInProgress; - } - return null; - } case HostRoot: { popHostContainer(workInProgress); popTopLevelContextObject(workInProgress); - var _effectTag2 = workInProgress.effectTag; + var _effectTag = workInProgress.effectTag; invariant( - (_effectTag2 & DidCapture) === NoEffect, + (_effectTag & DidCapture) === NoEffect, "The root failed to unmount after an error. This is likely a bug in " + "React. Please file an issue." ); - workInProgress.effectTag = (_effectTag2 & ~ShouldCapture) | DidCapture; + workInProgress.effectTag = (_effectTag & ~ShouldCapture) | DidCapture; return workInProgress; } case HostComponent: { @@ -13427,9 +14846,10 @@ function unwindWork(workInProgress, renderExpirationTime) { return null; } case SuspenseComponent: { - var _effectTag3 = workInProgress.effectTag; - if (_effectTag3 & ShouldCapture) { - workInProgress.effectTag = (_effectTag3 & ~ShouldCapture) | DidCapture; + var _effectTag2 = workInProgress.effectTag; + if (_effectTag2 & ShouldCapture) { + workInProgress.effectTag = (_effectTag2 & ~ShouldCapture) | DidCapture; + // Captured a suspense effect. Re-render the boundary. return workInProgress; } return null; @@ -13454,14 +14874,6 @@ function unwindInterruptedWork(interruptedWork) { } break; } - case ClassComponentLazy: { - var _childContextTypes = - interruptedWork.type._reactResult.childContextTypes; - if (_childContextTypes !== null && _childContextTypes !== undefined) { - popContext(interruptedWork); - } - break; - } case HostRoot: { popHostContainer(interruptedWork); popTopLevelContextObject(interruptedWork); @@ -13483,6 +14895,19 @@ 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 +}; +var DispatcherWithoutHooks = { readContext: readContext }; @@ -13511,19 +14936,21 @@ if (enableSchedulerTracing) { didWarnSetStateChildContext = false; var didWarnStateUpdateForUnmountedComponent = {}; - warnAboutUpdateOnUnmounted = function(fiber) { + warnAboutUpdateOnUnmounted = function(fiber, isClass) { // We show the whole stack but dedupe on the top component's name because // the problematic code almost always lies inside that component. - var componentName = getComponentName(fiber.type) || "ReactClass"; + var componentName = getComponentName(fiber.type) || "ReactComponent"; if (didWarnStateUpdateForUnmountedComponent[componentName]) { return; } warningWithoutStack$1( false, - "Can't call setState (or forceUpdate) on an unmounted component. This " + + "Can't perform a React state update on an unmounted component. This " + "is a no-op, but it indicates a memory leak in your application. To " + - "fix, cancel all subscriptions and asynchronous tasks in the " + - "componentWillUnmount method.%s", + "fix, cancel all subscriptions and asynchronous tasks in %s.%s", + isClass + ? "the componentWillUnmount method" + : "a useEffect cleanup function", getStackByFiberInDevAndProd(fiber) ); didWarnStateUpdateForUnmountedComponent[componentName] = true; @@ -13575,6 +15002,9 @@ var nextRenderDidError = false; var nextEffect = null; var isCommitting$1 = false; +var rootWithPendingPassiveEffects = null; +var passiveEffectCallbackHandle = null; +var passiveEffectCallback = null; var legacyErrorBoundariesThatAlreadyFailed = null; @@ -13583,11 +15013,13 @@ var interruptedBy = null; var stashedWorkInProgressProperties = void 0; var replayUnitOfWork = void 0; +var mayReplayFailedUnitOfWork = void 0; var isReplayingFailedUnitOfWork = void 0; var originalReplayError = void 0; var rethrowOriginalError = void 0; if (true && replayFailedUnitOfWorkWithInvokeGuardedCallback) { stashedWorkInProgressProperties = null; + mayReplayFailedUnitOfWork = true; isReplayingFailedUnitOfWork = false; originalReplayError = null; replayUnitOfWork = function(failedUnitOfWork, thrownValue, isYieldy) { @@ -13632,13 +15064,6 @@ if (true && replayFailedUnitOfWorkWithInvokeGuardedCallback) { } break; } - case ClassComponentLazy: { - var _Component = getResultFromResolvedThenable(failedUnitOfWork.type); - if (isContextProvider(_Component)) { - popContext(failedUnitOfWork); - } - break; - } case HostPortal: popHostContainer(failedUnitOfWork); break; @@ -13777,8 +15202,6 @@ function commitBeforeMutationLifecycles() { commitBeforeMutationLifeCycles(current$$1, nextEffect); } - // Don't cleanup effects yet; - // This will be done by commitAllLifeCycles() nextEffect = nextEffect.nextEffect; } @@ -13815,15 +15238,48 @@ function commitAllLifeCycles(finishedRoot, committedExpirationTime) { commitAttachRef(nextEffect); } - var next = nextEffect.nextEffect; - // Ensure that we clean these up so that we don't accidentally keep them. - // I'm not actually sure this matters because we can't reset firstEffect - // and lastEffect since they're on every node, not just the effectful - // ones. So we have to clean everything as we reuse nodes anyway. - nextEffect.nextEffect = null; - // Ensure that we reset the effectTag here so that we can rely on effect - // tags to reason about the current life-cycle. - nextEffect = next; + if (enableHooks && effectTag & Passive) { + rootWithPendingPassiveEffects = finishedRoot; + } + + nextEffect = nextEffect.nextEffect; + } +} + +function commitPassiveEffects(root, firstEffect) { + rootWithPendingPassiveEffects = null; + passiveEffectCallbackHandle = null; + passiveEffectCallback = null; + + // Set this to true to prevent re-entrancy + var previousIsRendering = isRendering; + isRendering = true; + + var effect = firstEffect; + do { + if (effect.effectTag & Passive) { + var didError = false; + var error = void 0; + { + invokeGuardedCallback(null, commitPassiveHookEffects, null, effect); + if (hasCaughtError()) { + didError = true; + error = clearCaughtError(); + } + } + if (didError) { + captureCommitPhaseError(effect, error); + } + } + effect = effect.nextEffect; + } while (effect !== null); + + isRendering = previousIsRendering; + + // Check if work was scheduled by one of the effects + var rootExpirationTime = root.expirationTime; + if (rootExpirationTime !== NoWork) { + requestWork(root, rootExpirationTime); } } @@ -13842,6 +15298,15 @@ function markLegacyErrorBoundaryAsFailed(instance) { } } +function flushPassiveEffects() { + if (passiveEffectCallback !== null) { + scheduler.unstable_cancelCallback(passiveEffectCallbackHandle); + // We call the scheduled callback instead of commitPassiveEffects directly + // to ensure tracing works correctly. + passiveEffectCallback(); + } +} + function commitRoot(root, finishedWork) { isWorking = true; isCommitting$1 = true; @@ -13867,9 +15332,7 @@ function commitRoot(root, finishedWork) { var updateExpirationTimeBeforeCommit = finishedWork.expirationTime; var childExpirationTimeBeforeCommit = finishedWork.childExpirationTime; var earliestRemainingTimeBeforeCommit = - updateExpirationTimeBeforeCommit === NoWork || - (childExpirationTimeBeforeCommit !== NoWork && - childExpirationTimeBeforeCommit < updateExpirationTimeBeforeCommit) + childExpirationTimeBeforeCommit > updateExpirationTimeBeforeCommit ? childExpirationTimeBeforeCommit : updateExpirationTimeBeforeCommit; markCommittedPriorityLevels(root, earliestRemainingTimeBeforeCommit); @@ -14011,6 +15474,26 @@ function commitRoot(root, finishedWork) { } } + if ( + enableHooks && + firstEffect !== null && + rootWithPendingPassiveEffects !== null + ) { + // This commit included a passive effect. These do not need to fire until + // after the next paint. Schedule an callback to fire them in an async + // event. To ensure serial execution, the callback will be flushed early if + // we enter rootWithPendingPassiveEffects commit phase before then. + var callback = commitPassiveEffects.bind(null, root, firstEffect); + if (enableSchedulerTracing) { + // TODO: Avoid this extra callback by mutating the tracing ref directly, + // like we do at the beginning of commitRoot. I've opted not to do that + // here because that code is still in flux. + callback = tracing.unstable_wrap(callback); + } + passiveEffectCallbackHandle = scheduler.unstable_scheduleCallback(callback); + passiveEffectCallback = callback; + } + isCommitting$1 = false; isWorking = false; stopCommitLifeCyclesTimer(); @@ -14023,9 +15506,7 @@ function commitRoot(root, finishedWork) { var updateExpirationTimeAfterCommit = finishedWork.expirationTime; var childExpirationTimeAfterCommit = finishedWork.childExpirationTime; var earliestRemainingTimeAfterCommit = - updateExpirationTimeAfterCommit === NoWork || - (childExpirationTimeAfterCommit !== NoWork && - childExpirationTimeAfterCommit < updateExpirationTimeAfterCommit) + childExpirationTimeAfterCommit > updateExpirationTimeAfterCommit ? childExpirationTimeAfterCommit : updateExpirationTimeAfterCommit; if (earliestRemainingTimeAfterCommit === NoWork) { @@ -14068,10 +15549,7 @@ function commitRoot(root, finishedWork) { // Only decrement the pending interaction count if we're done. // If there's still work at the current priority, // That indicates that we are waiting for suspense data. - if ( - earliestRemainingTimeAfterCommit === NoWork || - scheduledExpirationTime < earliestRemainingTimeAfterCommit - ) { + if (scheduledExpirationTime > earliestRemainingTimeAfterCommit) { pendingInteractionMap.delete(scheduledExpirationTime); scheduledInteractions.forEach(function(interaction) { @@ -14127,18 +15605,10 @@ function resetChildExpirationTime(workInProgress, renderTime) { while (child !== null) { var childUpdateExpirationTime = child.expirationTime; var childChildExpirationTime = child.childExpirationTime; - if ( - newChildExpirationTime === NoWork || - (childUpdateExpirationTime !== NoWork && - childUpdateExpirationTime < newChildExpirationTime) - ) { + if (childUpdateExpirationTime > newChildExpirationTime) { newChildExpirationTime = childUpdateExpirationTime; } - if ( - newChildExpirationTime === NoWork || - (childChildExpirationTime !== NoWork && - childChildExpirationTime < newChildExpirationTime) - ) { + if (childChildExpirationTime > newChildExpirationTime) { newChildExpirationTime = childChildExpirationTime; } if (shouldBubbleActualDurations) { @@ -14154,18 +15624,10 @@ function resetChildExpirationTime(workInProgress, renderTime) { while (_child !== null) { var _childUpdateExpirationTime = _child.expirationTime; var _childChildExpirationTime = _child.childExpirationTime; - if ( - newChildExpirationTime === NoWork || - (_childUpdateExpirationTime !== NoWork && - _childUpdateExpirationTime < newChildExpirationTime) - ) { + if (_childUpdateExpirationTime > newChildExpirationTime) { newChildExpirationTime = _childUpdateExpirationTime; } - if ( - newChildExpirationTime === NoWork || - (_childChildExpirationTime !== NoWork && - _childChildExpirationTime < newChildExpirationTime) - ) { + if (_childChildExpirationTime > newChildExpirationTime) { newChildExpirationTime = _childChildExpirationTime; } _child = _child.sibling; @@ -14193,18 +15655,22 @@ function completeUnitOfWork(workInProgress) { var siblingFiber = workInProgress.sibling; if ((workInProgress.effectTag & Incomplete) === NoEffect) { + if (true && replayFailedUnitOfWorkWithInvokeGuardedCallback) { + // Don't replay if it fails during completion phase. + mayReplayFailedUnitOfWork = false; + } // This fiber completed. + // Remember we're completing this unit so we can find a boundary if it fails. + nextUnitOfWork = workInProgress; if (enableProfilerTimer) { if (workInProgress.mode & ProfileMode) { startProfilerTimer(workInProgress); } - nextUnitOfWork = completeWork( current$$1, workInProgress, nextRenderExpirationTime ); - if (workInProgress.mode & ProfileMode) { // Update render duration assuming we didn't error. stopProfilerTimerIfRunningAndRecordDelta(workInProgress, false); @@ -14216,12 +15682,21 @@ function completeUnitOfWork(workInProgress) { nextRenderExpirationTime ); } + if (true && replayFailedUnitOfWorkWithInvokeGuardedCallback) { + // We're out of completion phase so replaying is fine now. + mayReplayFailedUnitOfWork = true; + } stopWorkTimer(workInProgress); resetChildExpirationTime(workInProgress, nextRenderExpirationTime); { resetCurrentFiber(); } + if (nextUnitOfWork !== null) { + // Completing this fiber spawned new work. Work on that next. + return nextUnitOfWork; + } + if ( returnFiber !== null && // Do not append effects to parents if a sibling failed to complete @@ -14275,9 +15750,18 @@ function completeUnitOfWork(workInProgress) { return null; } } else { - if (workInProgress.mode & ProfileMode) { + if (enableProfilerTimer && workInProgress.mode & ProfileMode) { // Record the render duration for the fiber that errored. stopProfilerTimerIfRunningAndRecordDelta(workInProgress, false); + + // Include the time spent working on failed children before continuing. + var actualDuration = workInProgress.actualDuration; + var child = workInProgress.child; + while (child !== null) { + actualDuration += child.actualDuration; + child = child.sibling; + } + workInProgress.actualDuration = actualDuration; } // This fiber did not complete because something threw. Pop values off @@ -14302,19 +15786,6 @@ function completeUnitOfWork(workInProgress) { ReactFiberInstrumentation_1.debugTool.onCompleteWork(workInProgress); } - if (enableProfilerTimer) { - // Include the time spent working on failed children before continuing. - if (next.mode & ProfileMode) { - var actualDuration = next.actualDuration; - var child = next.child; - while (child !== null) { - actualDuration += child.actualDuration; - child = child.sibling; - } - next.actualDuration = actualDuration; - } - } - // If completing this work spawned new work, do that next. We'll come // back here again. // Since we're restarting, remove anything that is not a host effect @@ -14379,6 +15850,7 @@ function performUnitOfWork(workInProgress) { } next = beginWork(current$$1, workInProgress, nextRenderExpirationTime); + workInProgress.memoizedProps = workInProgress.pendingProps; if (workInProgress.mode & ProfileMode) { // Record the render duration assuming we didn't bailout (or error). @@ -14386,6 +15858,7 @@ function performUnitOfWork(workInProgress) { } } else { next = beginWork(current$$1, workInProgress, nextRenderExpirationTime); + workInProgress.memoizedProps = workInProgress.pendingProps; } { @@ -14419,21 +15892,28 @@ function workLoop(isYieldy) { nextUnitOfWork = performUnitOfWork(nextUnitOfWork); } } else { - // Flush asynchronous work until the deadline runs out of time. - while (nextUnitOfWork !== null && !shouldYield()) { + // Flush asynchronous work until there's a higher priority event + while (nextUnitOfWork !== null && !shouldYieldToRenderer()) { nextUnitOfWork = performUnitOfWork(nextUnitOfWork); } } } -function renderRoot(root, isYieldy, isExpired) { +function renderRoot(root, isYieldy) { invariant( !isWorking, "renderRoot was called recursively. This error is likely caused " + "by a bug in React. Please file an issue." ); + + flushPassiveEffects(); + isWorking = true; - ReactCurrentOwner$2.currentDispatcher = Dispatcher; + if (enableHooks) { + ReactCurrentOwner$2.currentDispatcher = Dispatcher; + } else { + ReactCurrentOwner$2.currentDispatcher = DispatcherWithoutHooks; + } var expirationTime = root.nextExpirationTimeToWorkOn; @@ -14463,7 +15943,7 @@ function renderRoot(root, isYieldy, isExpired) { scheduledInteractions, scheduledExpirationTime ) { - if (scheduledExpirationTime <= expirationTime) { + if (scheduledExpirationTime >= expirationTime) { scheduledInteractions.forEach(function(interaction) { return interactions.add(interaction); }); @@ -14515,20 +15995,39 @@ function renderRoot(root, isYieldy, isExpired) { try { workLoop(isYieldy); } catch (thrownValue) { + resetContextDependences(); + resetHooks(); + + // Reset in case completion throws. + // This is only used in DEV and when replaying is on. + var mayReplay = void 0; + if (true && replayFailedUnitOfWorkWithInvokeGuardedCallback) { + mayReplay = mayReplayFailedUnitOfWork; + mayReplayFailedUnitOfWork = true; + } + if (nextUnitOfWork === null) { // This is a fatal error. didFatal = true; onUncaughtError(thrownValue); } else { + if (enableProfilerTimer && nextUnitOfWork.mode & ProfileMode) { + // Record the time spent rendering before an error was thrown. + // This avoids inaccurate Profiler durations in the case of a suspended render. + stopProfilerTimerIfRunningAndRecordDelta(nextUnitOfWork, true); + } + { // Reset global debug state // We assume this is defined in DEV resetCurrentlyProcessingQueue(); } - var failedUnitOfWork = nextUnitOfWork; if (true && replayFailedUnitOfWorkWithInvokeGuardedCallback) { - replayUnitOfWork(failedUnitOfWork, thrownValue, isYieldy); + if (mayReplay) { + var failedUnitOfWork = nextUnitOfWork; + replayUnitOfWork(failedUnitOfWork, thrownValue, isYieldy); + } } // TODO: we already know this isn't true in some cases. @@ -14577,6 +16076,7 @@ function renderRoot(root, isYieldy, isExpired) { isWorking = false; ReactCurrentOwner$2.currentDispatcher = null; resetContextDependences(); + resetHooks(); // Yield back to main thread. if (didFatal) { @@ -14648,7 +16148,7 @@ function renderRoot(root, isYieldy, isExpired) { // similar to a suspend, but without a timeout because we're not waiting // for a promise to resolve. !root.didError && - !isExpired + isYieldy ) { root.didError = true; var _suspendedExpirationTime = (root.nextExpirationTimeToWorkOn = expirationTime); @@ -14664,7 +16164,7 @@ function renderRoot(root, isYieldy, isExpired) { } } - if (!isExpired && nextLatestAbsoluteTimeoutMs !== -1) { + if (isYieldy && nextLatestAbsoluteTimeoutMs !== -1) { // The tree was suspended. var _suspendedExpirationTime2 = expirationTime; markSuspendedPriorityLevel(root, _suspendedExpirationTime2); @@ -14706,17 +16206,12 @@ function renderRoot(root, isYieldy, isExpired) { onComplete(root, rootWorkInProgress, expirationTime); } -function dispatch(sourceFiber, value, expirationTime) { - invariant( - !isWorking || isCommitting$1, - "dispatch: Cannot dispatch during the render phase." - ); - +function captureCommitPhaseError(sourceFiber, value) { + var expirationTime = Sync; var fiber = sourceFiber.return; while (fiber !== null) { switch (fiber.tag) { case ClassComponent: - case ClassComponentLazy: var ctor = fiber.type; var instance = fiber.stateNode; if ( @@ -14757,10 +16252,6 @@ function dispatch(sourceFiber, value, expirationTime) { } } -function captureCommitPhaseError(fiber, error) { - return dispatch(fiber, error, Sync); -} - function computeThreadID(expirationTime, interactionThreadID) { // Interaction threads are unique per root and expiration time. return expirationTime * 1000 + interactionThreadID; @@ -14795,7 +16286,7 @@ function computeExpirationForFiber(currentTime, fiber) { // If we're in the middle of rendering a tree, do not update at the same // expiration time that is already rendering. if (nextRoot !== null && expirationTime === nextRenderExpirationTime) { - expirationTime += 1; + expirationTime -= 1; } } else { // This is a sync update @@ -14806,7 +16297,10 @@ function computeExpirationForFiber(currentTime, fiber) { // This is an interactive update. Keep track of the lowest pending // interactive expiration time. This allows us to synchronously flush // all interactive updates when needed. - if (expirationTime > lowestPriorityPendingInteractiveExpirationTime) { + if ( + lowestPriorityPendingInteractiveExpirationTime === NoWork || + expirationTime < lowestPriorityPendingInteractiveExpirationTime + ) { lowestPriorityPendingInteractiveExpirationTime = expirationTime; } } @@ -14827,7 +16321,7 @@ function renderDidError() { nextRenderDidError = true; } -function retrySuspendedRoot(root, fiber, suspendedTime) { +function retrySuspendedRoot(root, boundaryFiber, sourceFiber, suspendedTime) { var retryTime = void 0; if (isPriorityLevelSuspended(root, suspendedTime)) { @@ -14838,18 +16332,18 @@ function retrySuspendedRoot(root, fiber, suspendedTime) { } else { // Suspense already timed out. Compute a new expiration time var currentTime = requestCurrentTime(); - retryTime = computeExpirationForFiber(currentTime, fiber); + retryTime = computeExpirationForFiber(currentTime, boundaryFiber); markPendingPriorityLevel(root, retryTime); } - // TODO: If the placeholder fiber has already rendered the primary children + // TODO: If the suspense fiber has already rendered the primary children // without suspending (that is, all of the promises have already resolved), // we should not trigger another update here. One case this happens is when // we are in sync mode and a single promise is thrown both on initial render // and on update; we attach two .then(retrySuspendedRoot) callbacks and each // one performs Sync work, rerendering the Suspense. - if ((fiber.mode & ConcurrentMode) !== NoContext) { + if ((boundaryFiber.mode & ConcurrentMode) !== NoContext) { if (root === nextRoot && nextRenderExpirationTime === suspendedTime) { // Received a ping at the same priority level at which we're currently // rendering. Restart from the root. @@ -14857,7 +16351,23 @@ function retrySuspendedRoot(root, fiber, suspendedTime) { } } - scheduleWorkToRoot(fiber, retryTime); + scheduleWorkToRoot(boundaryFiber, retryTime); + if ((boundaryFiber.mode & ConcurrentMode) === NoContext) { + // Outside of concurrent mode, we must schedule an update on the source + // fiber, too, since it already committed in an inconsistent state and + // therefore does not have any pending work. + scheduleWorkToRoot(sourceFiber, retryTime); + var sourceTag = sourceFiber.tag; + if (sourceTag === ClassComponent && sourceFiber.stateNode !== null) { + // When we try rendering again, we should not reuse the current fiber, + // since it's known to be in an inconsistent state. Use a force updte to + // prevent a bail out. + var update = createUpdate(retryTime); + update.tag = ForceUpdate; + enqueueUpdate(sourceFiber, update); + } + } + var rootExpirationTime = root.expirationTime; if (rootExpirationTime !== NoWork) { requestWork(root, rootExpirationTime); @@ -14868,25 +16378,18 @@ function scheduleWorkToRoot(fiber, expirationTime) { recordScheduleUpdate(); { - if (fiber.tag === ClassComponent || fiber.tag === ClassComponentLazy) { + if (fiber.tag === ClassComponent) { var instance = fiber.stateNode; warnAboutInvalidUpdates(instance); } } // Update the source fiber's expiration time - if ( - fiber.expirationTime === NoWork || - fiber.expirationTime > expirationTime - ) { + if (fiber.expirationTime < expirationTime) { fiber.expirationTime = expirationTime; } var alternate = fiber.alternate; - if ( - alternate !== null && - (alternate.expirationTime === NoWork || - alternate.expirationTime > expirationTime) - ) { + if (alternate !== null && alternate.expirationTime < expirationTime) { alternate.expirationTime = expirationTime; } // Walk the parent path to the root and update the child expiration time. @@ -14897,22 +16400,17 @@ function scheduleWorkToRoot(fiber, expirationTime) { } else { while (node !== null) { alternate = node.alternate; - if ( - node.childExpirationTime === NoWork || - node.childExpirationTime > expirationTime - ) { + if (node.childExpirationTime < expirationTime) { node.childExpirationTime = expirationTime; if ( alternate !== null && - (alternate.childExpirationTime === NoWork || - alternate.childExpirationTime > expirationTime) + alternate.childExpirationTime < expirationTime ) { alternate.childExpirationTime = expirationTime; } } else if ( alternate !== null && - (alternate.childExpirationTime === NoWork || - alternate.childExpirationTime > expirationTime) + alternate.childExpirationTime < expirationTime ) { alternate.childExpirationTime = expirationTime; } @@ -14925,11 +16423,18 @@ function scheduleWorkToRoot(fiber, expirationTime) { } if (root === null) { - if ( - true && - (fiber.tag === ClassComponent || fiber.tag === ClassComponentLazy) - ) { - warnAboutUpdateOnUnmounted(fiber); + { + switch (fiber.tag) { + case ClassComponent: + warnAboutUpdateOnUnmounted(fiber, true); + break; + case FunctionComponent: + case ForwardRef: + case MemoComponent: + case SimpleMemoComponent: + warnAboutUpdateOnUnmounted(fiber, false); + break; + } } return null; } @@ -14980,7 +16485,7 @@ function scheduleWork(fiber, expirationTime) { if ( !isWorking && nextRenderExpirationTime !== NoWork && - expirationTime < nextRenderExpirationTime + expirationTime > nextRenderExpirationTime ) { // This is an interruption. (Used for performance tracking.) interruptedBy = fiber; @@ -15024,10 +16529,8 @@ var isRendering = false; var nextFlushedRoot = null; var nextFlushedExpirationTime = NoWork; var lowestPriorityPendingInteractiveExpirationTime = NoWork; -var deadlineDidExpire = false; var hasUnhandledError = false; var unhandledError = null; -var deadline = null; var isBatchingUpdates = false; var isUnbatchingUpdates = false; @@ -15044,8 +16547,6 @@ var NESTED_UPDATE_LIMIT = 50; var nestedUpdateCount = 0; var lastCommittedRootDuringThisBatch = null; -var timeHeuristicForUnitOfWork = 1; - function recomputeCurrentRendererTime() { var currentTimeMs = now() - originalStartTimeMs; currentRendererTime = msToExpirationTime(currentTimeMs); @@ -15054,7 +16555,7 @@ function recomputeCurrentRendererTime() { function scheduleCallbackWithExpirationTime(root, expirationTime) { if (callbackExpirationTime !== NoWork) { // A callback is already scheduled. Check its expiration time (timeout). - if (expirationTime > callbackExpirationTime) { + if (expirationTime < callbackExpirationTime) { // Existing callback has sufficient timeout. Exit. return; } else { @@ -15097,7 +16598,7 @@ function onSuspend( msUntilTimeout ) { root.expirationTime = rootExpirationTime; - if (msUntilTimeout === 0 && !shouldYield()) { + if (msUntilTimeout === 0 && !shouldYieldToRenderer()) { // Don't wait an additional tick. Commit the tree immediately. root.pendingCommitExpirationTime = suspendedExpirationTime; root.finishedWork = finishedWork; @@ -15192,7 +16693,7 @@ function requestWork(root, expirationTime) { // flush it now. nextFlushedRoot = root; nextFlushedExpirationTime = Sync; - performWorkOnRoot(root, Sync, true); + performWorkOnRoot(root, Sync, false); } return; } @@ -15222,10 +16723,7 @@ function addRootToSchedule(root, expirationTime) { } else { // This root is already scheduled, but its priority may have increased. var remainingExpirationTime = root.expirationTime; - if ( - remainingExpirationTime === NoWork || - expirationTime < remainingExpirationTime - ) { + if (expirationTime > remainingExpirationTime) { // Update the priority. root.expirationTime = expirationTime; } @@ -15274,10 +16772,7 @@ function findHighestPriorityRoot() { } root = previousScheduledRoot.nextScheduledRoot; } else { - if ( - highestPriorityWork === NoWork || - remainingExpirationTime < highestPriorityWork - ) { + if (remainingExpirationTime > highestPriorityWork) { // Update the priority, if it's higher highestPriorityWork = remainingExpirationTime; highestPriorityRoot = root; @@ -15300,43 +16795,60 @@ function findHighestPriorityRoot() { nextFlushedExpirationTime = highestPriorityWork; } -function performAsyncWork(dl) { - if (dl.didTimeout) { - // The callback timed out. That means at least one update has expired. - // Iterate through the root schedule. If they contain expired work, set - // the next render expiration time to the current time. This has the effect - // of flushing all expired work in a single batch, instead of flushing each - // level one at a time. - if (firstScheduledRoot !== null) { - recomputeCurrentRendererTime(); - var root = firstScheduledRoot; - do { - didExpireAtExpirationTime(root, currentRendererTime); - // The root schedule is circular, so this is never null. - root = root.nextScheduledRoot; - } while (root !== firstScheduledRoot); - } +// TODO: This wrapper exists because many of the older tests (the ones that use +// flushDeferredPri) rely on the number of times `shouldYield` is called. We +// should get rid of it. +var didYield = false; +function shouldYieldToRenderer() { + if (didYield) { + return true; + } + if (shouldYield()) { + didYield = true; + return true; } - performWork(NoWork, dl); + return false; } -function performSyncWork() { - performWork(Sync, null); +function performAsyncWork() { + try { + if (!shouldYieldToRenderer()) { + // The callback timed out. That means at least one update has expired. + // Iterate through the root schedule. If they contain expired work, set + // the next render expiration time to the current time. This has the effect + // of flushing all expired work in a single batch, instead of flushing each + // level one at a time. + if (firstScheduledRoot !== null) { + recomputeCurrentRendererTime(); + var root = firstScheduledRoot; + do { + didExpireAtExpirationTime(root, currentRendererTime); + // The root schedule is circular, so this is never null. + root = root.nextScheduledRoot; + } while (root !== firstScheduledRoot); + } + } + performWork(NoWork, true); + } finally { + didYield = false; + } } -function performWork(minExpirationTime, dl) { - deadline = dl; +function performSyncWork() { + performWork(Sync, false); +} - // Keep working on roots until there's no more work, or until we reach - // the deadline. +function performWork(minExpirationTime, isYieldy) { + // Keep working on roots until there's no more work, or until there's a higher + // priority event. findHighestPriorityRoot(); - if (deadline !== null) { + if (isYieldy) { recomputeCurrentRendererTime(); currentSchedulerTime = currentRendererTime; if (enableUserTimingAPI) { - var didExpire = nextFlushedExpirationTime < currentRendererTime; + var didExpire = nextFlushedExpirationTime > currentRendererTime; var timeout = expirationTimeToMs(nextFlushedExpirationTime); stopRequestCallbackTimer(didExpire, timeout); } @@ -15344,14 +16856,13 @@ function performWork(minExpirationTime, dl) { while ( nextFlushedRoot !== null && nextFlushedExpirationTime !== NoWork && - (minExpirationTime === NoWork || - minExpirationTime >= nextFlushedExpirationTime) && - (!deadlineDidExpire || currentRendererTime >= nextFlushedExpirationTime) + minExpirationTime <= nextFlushedExpirationTime && + !(didYield && currentRendererTime > nextFlushedExpirationTime) ) { performWorkOnRoot( nextFlushedRoot, nextFlushedExpirationTime, - currentRendererTime >= nextFlushedExpirationTime + currentRendererTime > nextFlushedExpirationTime ); findHighestPriorityRoot(); recomputeCurrentRendererTime(); @@ -15361,10 +16872,9 @@ function performWork(minExpirationTime, dl) { while ( nextFlushedRoot !== null && nextFlushedExpirationTime !== NoWork && - (minExpirationTime === NoWork || - minExpirationTime >= nextFlushedExpirationTime) + minExpirationTime <= nextFlushedExpirationTime ) { - performWorkOnRoot(nextFlushedRoot, nextFlushedExpirationTime, true); + performWorkOnRoot(nextFlushedRoot, nextFlushedExpirationTime, false); findHighestPriorityRoot(); } } @@ -15373,7 +16883,7 @@ function performWork(minExpirationTime, dl) { // or there's no more work left with sufficient priority. // If we're inside a callback, set this to false since we just completed it. - if (deadline !== null) { + if (isYieldy) { callbackExpirationTime = NoWork; callbackID = null; } @@ -15386,9 +16896,6 @@ function performWork(minExpirationTime, dl) { } // Clean-up. - deadline = null; - deadlineDidExpire = false; - finishRendering(); } @@ -15403,7 +16910,7 @@ function flushRoot(root, expirationTime) { // including the given time. nextFlushedRoot = root; nextFlushedExpirationTime = expirationTime; - performWorkOnRoot(root, expirationTime, true); + performWorkOnRoot(root, expirationTime, false); // Flush any sync work that was scheduled by lifecycles performSyncWork(); } @@ -15436,7 +16943,7 @@ function finishRendering() { } } -function performWorkOnRoot(root, expirationTime, isExpired) { +function performWorkOnRoot(root, expirationTime, isYieldy) { invariant( !isRendering, "performWorkOnRoot was called recursively. This error is likely caused " + @@ -15446,7 +16953,7 @@ function performWorkOnRoot(root, expirationTime, isExpired) { isRendering = true; // Check if this is async work or sync/expired work. - if (deadline === null || isExpired) { + if (!isYieldy) { // Flush work without yielding. // TODO: Non-yieldy work does not necessarily imply expired work. A renderer // may want to perform some work without yielding, but also without @@ -15466,8 +16973,7 @@ function performWorkOnRoot(root, expirationTime, isExpired) { // $FlowFixMe Complains noTimeout is not a TimeoutID, despite the check above cancelTimeout(timeoutHandle); } - var isYieldy = false; - renderRoot(root, isYieldy, isExpired); + renderRoot(root, isYieldy); finishedWork = root.finishedWork; if (finishedWork !== null) { // We've completed the root. Commit it. @@ -15490,13 +16996,12 @@ function performWorkOnRoot(root, expirationTime, isExpired) { // $FlowFixMe Complains noTimeout is not a TimeoutID, despite the check above cancelTimeout(_timeoutHandle); } - var _isYieldy = true; - renderRoot(root, _isYieldy, isExpired); + renderRoot(root, isYieldy); _finishedWork = root.finishedWork; if (_finishedWork !== null) { - // We've completed the root. Check the deadline one more time + // We've completed the root. Check the if we should yield one more time // before committing. - if (!shouldYield()) { + if (!shouldYieldToRenderer()) { // Still time left. Commit the root. completeRoot(root, _finishedWork, expirationTime); } else { @@ -15514,7 +17019,7 @@ function performWorkOnRoot(root, expirationTime, isExpired) { function completeRoot(root, finishedWork, expirationTime) { // Check if there's a batch that matches this expiration time. var firstBatch = root.firstBatch; - if (firstBatch !== null && firstBatch._expirationTime <= expirationTime) { + if (firstBatch !== null && firstBatch._expirationTime >= expirationTime) { if (completedBatches === null) { completedBatches = [firstBatch]; } else { @@ -15546,24 +17051,6 @@ function completeRoot(root, finishedWork, expirationTime) { commitRoot(root, finishedWork); } -// When working on async work, the reconciler asks the renderer if it should -// yield execution. For DOM, we implement this with requestIdleCallback. -function shouldYield() { - if (deadlineDidExpire) { - return true; - } - if ( - deadline === null || - deadline.timeRemaining() > timeHeuristicForUnitOfWork - ) { - // Disregard deadline.didTimeout. Only expired work should be flushed - // during a timeout. This path is only hit for non-expired work. - return false; - } - deadlineDidExpire = true; - return true; -} - function onUncaughtError(error) { invariant( nextFlushedRoot !== null, @@ -15608,7 +17095,7 @@ function interactiveUpdates$1(fn, a, b) { lowestPriorityPendingInteractiveExpirationTime !== NoWork ) { // Synchronously flush pending interactive updates. - performWork(lowestPriorityPendingInteractiveExpirationTime, null); + performWork(lowestPriorityPendingInteractiveExpirationTime, false); lowestPriorityPendingInteractiveExpirationTime = NoWork; } var previousIsBatchingInteractiveUpdates = isBatchingInteractiveUpdates; @@ -15632,7 +17119,7 @@ function flushInteractiveUpdates$1() { lowestPriorityPendingInteractiveExpirationTime !== NoWork ) { // Synchronously flush pending interactive updates. - performWork(lowestPriorityPendingInteractiveExpirationTime, null); + performWork(lowestPriorityPendingInteractiveExpirationTime, false); lowestPriorityPendingInteractiveExpirationTime = NoWork; } } @@ -15661,11 +17148,6 @@ function getContextForSubtree(parentComponent) { if (isContextProvider(Component)) { return processChildContext(fiber, Component, parentContext); } - } else if (fiber.tag === ClassComponentLazy) { - var _Component = getResultFromResolvedThenable(fiber.type); - if (isContextProvider(_Component)) { - return processChildContext(fiber, _Component, parentContext); - } } return parentContext; @@ -15703,9 +17185,11 @@ function scheduleRootUpdate(current$$1, element, expirationTime, callback) { : void 0; update.callback = callback; } - enqueueUpdate(current$$1, update); + flushPassiveEffects(); + enqueueUpdate(current$$1, update); scheduleWork(current$$1, expirationTime); + return expirationTime; } @@ -15896,7 +17380,7 @@ function createPortal( // TODO: this is special because it gets imported during build. -var ReactVersion = "16.6.0-alpha.8af6728"; +var ReactVersion = "16.6.1"; // Modules provided by RN: var NativeMethodsMixin = function(findNodeHandle, findHostInstance) { @@ -16292,9 +17776,9 @@ var ReactNativeComponent = function(findNodeHandle, findHostInstance) { }; // Module provided by RN: -var emptyObject$2 = {}; +var emptyObject$1 = {}; { - Object.freeze(emptyObject$2); + Object.freeze(emptyObject$1); } var getInspectorDataForViewTag = void 0; @@ -16327,9 +17811,9 @@ var getInspectorDataForViewTag = void 0; var getHostProps = function(fiber) { var host = findCurrentHostFiber(fiber); if (host) { - return host.memoizedProps || emptyObject$2; + return host.memoizedProps || emptyObject$1; } - return emptyObject$2; + return emptyObject$1; }; var getHostNode = function(fiber, findNodeHandle) { @@ -16375,7 +17859,7 @@ var getInspectorDataForViewTag = void 0; if (!closestInstance) { return { hierarchy: [], - props: emptyObject$2, + props: emptyObject$1, selection: null, source: null }; diff --git a/Libraries/Renderer/oss/ReactNativeRenderer-prod.js b/Libraries/Renderer/oss/ReactNativeRenderer-prod.js index 3fcf1033033884..8b5e42b7dcee1d 100644 --- a/Libraries/Renderer/oss/ReactNativeRenderer-prod.js +++ b/Libraries/Renderer/oss/ReactNativeRenderer-prod.js @@ -19,7 +19,8 @@ var ReactNativeViewConfigRegistry = require("ReactNativeViewConfigRegistry"), deepDiffer = require("deepDiffer"), flattenStyle = require("flattenStyle"), TextInputState = require("TextInputState"); -var ExceptionsManager = require("ExceptionsManager"); +var scheduler = require("scheduler"), + ExceptionsManager = require("ExceptionsManager"); function invariant(condition, format, a, b, c, d, e, f) { if (!condition) { condition = void 0; @@ -166,10 +167,10 @@ var plugins = [], getFiberCurrentPropsFromNode = null, getInstanceFromNode = null, getNodeFromInstance = null; -function executeDispatch(event, simulated, listener, inst) { - simulated = event.type || "unknown-event"; +function executeDispatch(event, listener, inst) { + var type = event.type || "unknown-event"; event.currentTarget = getNodeFromInstance(inst); - invokeGuardedCallbackAndCatchFirstError(simulated, listener, void 0, event); + invokeGuardedCallbackAndCatchFirstError(type, listener, void 0, event); event.currentTarget = null; } function executeDirectDispatch(event) { @@ -215,10 +216,10 @@ function executeDispatchesAndReleaseTopLevel(e) { i < dispatchListeners.length && !e.isPropagationStopped(); i++ ) - executeDispatch(e, !1, dispatchListeners[i], dispatchInstances[i]); + executeDispatch(e, dispatchListeners[i], dispatchInstances[i]); else dispatchListeners && - executeDispatch(e, !1, dispatchListeners, dispatchInstances); + executeDispatch(e, dispatchListeners, dispatchInstances); e._dispatchListeners = null; e._dispatchInstances = null; e.isPersistent() || e.constructor.release(e); @@ -293,7 +294,7 @@ function getListener(inst, registrationName) { } function getParent(inst) { do inst = inst.return; - while (inst && 7 !== inst.tag); + while (inst && 5 !== inst.tag); return inst ? inst : null; } function traverseTwoPhase(inst, fn, arg) { @@ -1147,7 +1148,8 @@ var ReactSharedInternals = : 60111, REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for("react.forward_ref") : 60112, REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for("react.suspense") : 60113, - REACT_PURE_TYPE = hasSymbol ? Symbol.for("react.pure") : 60115, + REACT_MEMO_TYPE = hasSymbol ? Symbol.for("react.memo") : 60115, + REACT_LAZY_TYPE = hasSymbol ? Symbol.for("react.lazy") : 60116, MAYBE_ITERATOR_SYMBOL = "function" === typeof Symbol && Symbol.iterator; function getIteratorFn(maybeIterable) { if (null === maybeIterable || "object" !== typeof maybeIterable) return null; @@ -1156,13 +1158,6 @@ function getIteratorFn(maybeIterable) { maybeIterable["@@iterator"]; return "function" === typeof maybeIterable ? maybeIterable : null; } -function getWrappedName(outerType, innerType, wrapperName) { - innerType = innerType.displayName || innerType.name || ""; - return ( - outerType.displayName || - ("" !== innerType ? wrapperName + "(" + innerType + ")" : wrapperName) - ); -} function getComponentName(type) { if (null == type) return null; if ("function" === typeof type) return type.displayName || type.name || null; @@ -1181,23 +1176,25 @@ function getComponentName(type) { case REACT_SUSPENSE_TYPE: return "Suspense"; } - if ("object" === typeof type) { + if ("object" === typeof type) switch (type.$$typeof) { case REACT_CONTEXT_TYPE: return "Context.Consumer"; case REACT_PROVIDER_TYPE: return "Context.Provider"; case REACT_FORWARD_REF_TYPE: - return getWrappedName(type, type.render, "ForwardRef"); - case REACT_PURE_TYPE: - return getWrappedName(type, type.render, "Pure"); + var innerType = type.render; + innerType = innerType.displayName || innerType.name || ""; + return ( + type.displayName || + ("" !== innerType ? "ForwardRef(" + innerType + ")" : "ForwardRef") + ); + case REACT_MEMO_TYPE: + return getComponentName(type.type); + case REACT_LAZY_TYPE: + if ((type = 1 === type._status ? type._result : null)) + return getComponentName(type); } - if ( - "function" === typeof type.then && - (type = 1 === type._reactStatus ? type._reactResult : null) - ) - return getComponentName(type); - } return null; } function isFiberMountedImpl(fiber) { @@ -1208,7 +1205,7 @@ function isFiberMountedImpl(fiber) { for (; node.return; ) if (((node = node.return), 0 !== (node.effectTag & 2))) return 1; } - return 5 === node.tag ? 2 : 3; + return 3 === node.tag ? 2 : 3; } function assertIsMounted(fiber) { invariant( @@ -1284,14 +1281,14 @@ function findCurrentFiberUsingSlowPath(fiber) { "Return fibers should always be each others' alternates. This error is likely caused by a bug in React. Please file an issue." ); } - invariant(5 === a.tag, "Unable to find node on an unmounted component."); + invariant(3 === a.tag, "Unable to find node on an unmounted component."); return a.stateNode.current === a ? fiber : alternate; } function findCurrentHostFiber(parent) { parent = findCurrentFiberUsingSlowPath(parent); if (!parent) return null; for (var node = parent; ; ) { - if (7 === node.tag || 8 === node.tag) return node; + if (5 === node.tag || 6 === node.tag) return node; if (node.child) (node.child.return = node), (node = node.child); else { if (node === parent) break; @@ -1599,18 +1596,12 @@ var ReactNativeFiberHostComponent = (function() { return Date.now(); }, scheduledCallback = null, - frameDeadline = 0, - frameDeadlineObject = { - timeRemaining: function() { - return frameDeadline - now$1(); - }, - didTimeout: !1 - }; + frameDeadline = 0; function setTimeoutCallback() { frameDeadline = now$1() + 5; var callback = scheduledCallback; scheduledCallback = null; - null !== callback && callback(frameDeadlineObject); + null !== callback && callback(); } function shim$1() { invariant( @@ -1651,13 +1642,13 @@ function getStackByFiberInDevAndProd(workInProgress) { var info = ""; do { a: switch (workInProgress.tag) { - case 4: + case 2: + case 16: case 0: case 1: - case 2: - case 3: - case 7: - case 10: + case 5: + case 8: + case 13: var owner = workInProgress._debugOwner, source = workInProgress._debugSource, name = getComponentName(workInProgress.type); @@ -1808,7 +1799,7 @@ function injectInternals(internals) { function FiberNode(tag, pendingProps, key, mode) { this.tag = tag; this.key = key; - this.sibling = this.child = this.return = this.stateNode = this.type = null; + this.sibling = this.child = this.return = this.stateNode = this.type = this.elementType = null; this.index = 0; this.ref = null; this.pendingProps = pendingProps; @@ -1819,29 +1810,33 @@ function FiberNode(tag, pendingProps, key, mode) { this.childExpirationTime = this.expirationTime = 0; this.alternate = null; } +function createFiber(tag, pendingProps, key, mode) { + return new FiberNode(tag, pendingProps, key, mode); +} function shouldConstruct(Component) { Component = Component.prototype; return !(!Component || !Component.isReactComponent); } -function resolveLazyComponentTag(fiber, Component) { +function resolveLazyComponentTag(Component) { if ("function" === typeof Component) - return shouldConstruct(Component) ? 3 : 1; + return shouldConstruct(Component) ? 1 : 0; if (void 0 !== Component && null !== Component) { - fiber = Component.$$typeof; - if (fiber === REACT_FORWARD_REF_TYPE) return 14; - if (fiber === REACT_PURE_TYPE) return 18; + Component = Component.$$typeof; + if (Component === REACT_FORWARD_REF_TYPE) return 11; + if (Component === REACT_MEMO_TYPE) return 14; } - return 4; + return 2; } function createWorkInProgress(current, pendingProps) { var workInProgress = current.alternate; null === workInProgress - ? ((workInProgress = new FiberNode( + ? ((workInProgress = createFiber( current.tag, pendingProps, current.key, current.mode )), + (workInProgress.elementType = current.elementType), (workInProgress.type = current.type), (workInProgress.stateNode = current.stateNode), (workInProgress.alternate = current), @@ -1863,60 +1858,66 @@ function createWorkInProgress(current, pendingProps) { workInProgress.ref = current.ref; return workInProgress; } -function createFiberFromElement(element, mode, expirationTime) { - var type = element.type, - key = element.key; - element = element.props; - var fiberTag = void 0; - if ("function" === typeof type) fiberTag = shouldConstruct(type) ? 2 : 4; - else if ("string" === typeof type) fiberTag = 7; +function createFiberFromTypeAndProps( + type, + key, + pendingProps, + owner, + mode, + expirationTime +) { + var fiberTag = 2; + owner = type; + if ("function" === typeof type) shouldConstruct(type) && (fiberTag = 1); + else if ("string" === typeof type) fiberTag = 5; else a: switch (type) { case REACT_FRAGMENT_TYPE: return createFiberFromFragment( - element.children, + pendingProps.children, mode, expirationTime, key ); case REACT_CONCURRENT_MODE_TYPE: - fiberTag = 10; - mode |= 3; - break; + return createFiberFromMode(pendingProps, mode | 3, expirationTime, key); case REACT_STRICT_MODE_TYPE: - fiberTag = 10; - mode |= 2; - break; + return createFiberFromMode(pendingProps, mode | 2, expirationTime, key); case REACT_PROFILER_TYPE: return ( - (type = new FiberNode(15, element, key, mode | 4)), + (type = createFiber(12, pendingProps, key, mode | 4)), + (type.elementType = REACT_PROFILER_TYPE), (type.type = REACT_PROFILER_TYPE), (type.expirationTime = expirationTime), type ); case REACT_SUSPENSE_TYPE: - fiberTag = 16; - break; + return ( + (type = createFiber(13, pendingProps, key, mode)), + (type.elementType = REACT_SUSPENSE_TYPE), + (type.type = REACT_SUSPENSE_TYPE), + (type.expirationTime = expirationTime), + type + ); default: if ("object" === typeof type && null !== type) switch (type.$$typeof) { case REACT_PROVIDER_TYPE: - fiberTag = 12; + fiberTag = 10; break a; case REACT_CONTEXT_TYPE: - fiberTag = 11; + fiberTag = 9; break a; case REACT_FORWARD_REF_TYPE: - fiberTag = 13; + fiberTag = 11; break a; - case REACT_PURE_TYPE: - fiberTag = 17; + case REACT_MEMO_TYPE: + fiberTag = 14; + break a; + case REACT_LAZY_TYPE: + fiberTag = 16; + owner = null; break a; - default: - if ("function" === typeof type.then) { - fiberTag = 4; - break a; - } } invariant( !1, @@ -1925,24 +1926,33 @@ function createFiberFromElement(element, mode, expirationTime) { "" ); } - mode = new FiberNode(fiberTag, element, key, mode); - mode.type = type; - mode.expirationTime = expirationTime; - return mode; + key = createFiber(fiberTag, pendingProps, key, mode); + key.elementType = type; + key.type = owner; + key.expirationTime = expirationTime; + return key; } function createFiberFromFragment(elements, mode, expirationTime, key) { - elements = new FiberNode(9, elements, key, mode); + elements = createFiber(7, elements, key, mode); elements.expirationTime = expirationTime; return elements; } +function createFiberFromMode(pendingProps, mode, expirationTime, key) { + pendingProps = createFiber(8, pendingProps, key, mode); + mode = 0 === (mode & 1) ? REACT_STRICT_MODE_TYPE : REACT_CONCURRENT_MODE_TYPE; + pendingProps.elementType = mode; + pendingProps.type = mode; + pendingProps.expirationTime = expirationTime; + return pendingProps; +} function createFiberFromText(content, mode, expirationTime) { - content = new FiberNode(8, content, null, mode); + content = createFiber(6, content, null, mode); content.expirationTime = expirationTime; return content; } function createFiberFromPortal(portal, mode, expirationTime) { - mode = new FiberNode( - 6, + mode = createFiber( + 4, null !== portal.children ? portal.children : [], portal.key, mode @@ -1960,9 +1970,9 @@ function markPendingPriorityLevel(root, expirationTime) { var earliestPendingTime = root.earliestPendingTime; 0 === earliestPendingTime ? (root.earliestPendingTime = root.latestPendingTime = expirationTime) - : earliestPendingTime > expirationTime + : earliestPendingTime < expirationTime ? (root.earliestPendingTime = expirationTime) - : root.latestPendingTime < expirationTime && + : root.latestPendingTime > expirationTime && (root.latestPendingTime = expirationTime); findNextExpirationTimeToWorkOn(expirationTime, root); } @@ -1970,7 +1980,7 @@ function markSuspendedPriorityLevel(root, suspendedTime) { root.didError = !1; var latestPingedTime = root.latestPingedTime; 0 !== latestPingedTime && - latestPingedTime <= suspendedTime && + latestPingedTime >= suspendedTime && (root.latestPingedTime = 0); latestPingedTime = root.earliestPendingTime; var latestPendingTime = root.latestPendingTime; @@ -1985,22 +1995,18 @@ function markSuspendedPriorityLevel(root, suspendedTime) { latestPendingTime = root.latestSuspendedTime; 0 === latestPingedTime ? (root.earliestSuspendedTime = root.latestSuspendedTime = suspendedTime) - : latestPingedTime > suspendedTime + : latestPingedTime < suspendedTime ? (root.earliestSuspendedTime = suspendedTime) - : latestPendingTime < suspendedTime && + : latestPendingTime > suspendedTime && (root.latestSuspendedTime = suspendedTime); findNextExpirationTimeToWorkOn(suspendedTime, root); } function findEarliestOutstandingPriorityLevel(root, renderExpirationTime) { var earliestPendingTime = root.earliestPendingTime; root = root.earliestSuspendedTime; - if ( - 0 === renderExpirationTime || - (0 !== earliestPendingTime && earliestPendingTime < renderExpirationTime) - ) - renderExpirationTime = earliestPendingTime; - if (0 === renderExpirationTime || (0 !== root && root < renderExpirationTime)) - renderExpirationTime = root; + earliestPendingTime > renderExpirationTime && + (renderExpirationTime = earliestPendingTime); + root > renderExpirationTime && (renderExpirationTime = root); return renderExpirationTime; } function findNextExpirationTimeToWorkOn(completedExpirationTime, root) { @@ -2012,12 +2018,11 @@ function findNextExpirationTimeToWorkOn(completedExpirationTime, root) { 0 !== earliestPendingTime ? earliestPendingTime : latestPingedTime; 0 === earliestPendingTime && (0 === completedExpirationTime || - latestSuspendedTime > completedExpirationTime) && + latestSuspendedTime < completedExpirationTime) && (earliestPendingTime = latestSuspendedTime); completedExpirationTime = earliestPendingTime; 0 !== completedExpirationTime && - 0 !== earliestSuspendedTime && - earliestSuspendedTime < completedExpirationTime && + earliestSuspendedTime > completedExpirationTime && (completedExpirationTime = earliestSuspendedTime); root.nextExpirationTimeToWorkOn = earliestPendingTime; root.expirationTime = completedExpirationTime; @@ -2129,7 +2134,7 @@ function getStateFromUpdate( : workInProgress ); case 3: - workInProgress.effectTag = (workInProgress.effectTag & -1025) | 64; + workInProgress.effectTag = (workInProgress.effectTag & -2049) | 64; case 0: workInProgress = update.payload; nextProps = @@ -2162,58 +2167,52 @@ function processUpdateQueue( ) { var updateExpirationTime = update.expirationTime; - if (updateExpirationTime > renderExpirationTime) { - if ( - (null === newFirstUpdate && + updateExpirationTime < renderExpirationTime + ? (null === newFirstUpdate && ((newFirstUpdate = update), (newBaseState = resultState)), - 0 === newExpirationTime || newExpirationTime > updateExpirationTime) - ) - newExpirationTime = updateExpirationTime; - } else - (resultState = getStateFromUpdate( - workInProgress, - queue, - update, - resultState, - props, - instance - )), + newExpirationTime < updateExpirationTime && + (newExpirationTime = updateExpirationTime)) + : ((resultState = getStateFromUpdate( + workInProgress, + queue, + update, + resultState, + props, + instance + )), null !== update.callback && ((workInProgress.effectTag |= 32), (update.nextEffect = null), null === queue.lastEffect ? (queue.firstEffect = queue.lastEffect = update) : ((queue.lastEffect.nextEffect = update), - (queue.lastEffect = update))); + (queue.lastEffect = update)))); update = update.next; } updateExpirationTime = null; for (update = queue.firstCapturedUpdate; null !== update; ) { var _updateExpirationTime = update.expirationTime; - if (_updateExpirationTime > renderExpirationTime) { - if ( - (null === updateExpirationTime && + _updateExpirationTime < renderExpirationTime + ? (null === updateExpirationTime && ((updateExpirationTime = update), null === newFirstUpdate && (newBaseState = resultState)), - 0 === newExpirationTime || newExpirationTime > _updateExpirationTime) - ) - newExpirationTime = _updateExpirationTime; - } else - (resultState = getStateFromUpdate( - workInProgress, - queue, - update, - resultState, - props, - instance - )), + newExpirationTime < _updateExpirationTime && + (newExpirationTime = _updateExpirationTime)) + : ((resultState = getStateFromUpdate( + workInProgress, + queue, + update, + resultState, + props, + instance + )), null !== update.callback && ((workInProgress.effectTag |= 32), (update.nextEffect = null), null === queue.lastCapturedEffect ? (queue.firstCapturedEffect = queue.lastCapturedEffect = update) : ((queue.lastCapturedEffect.nextEffect = update), - (queue.lastCapturedEffect = update))); + (queue.lastCapturedEffect = update)))); update = update.next; } null === newFirstUpdate && (queue.lastUpdate = null); @@ -2294,7 +2293,7 @@ function readContext(context, observedBits) { null === lastContextDependency ? (invariant( null !== currentlyRenderingFiber, - "Context.unstable_read(): Context can only be read while React is rendering, e.g. inside the render method or getDerivedStateFromProps." + "Context can only be read while React is rendering, e.g. inside the render method or getDerivedStateFromProps." ), (currentlyRenderingFiber.firstContextDependency = lastContextDependency = observedBits)) : (lastContextDependency = lastContextDependency.next = observedBits); @@ -2370,7 +2369,47 @@ function shallowEqual(objA, objB) { return !1; return !0; } -var emptyRefsObject = new React.Component().refs; +function resolveDefaultProps(Component, baseProps) { + if (Component && Component.defaultProps) { + baseProps = Object.assign({}, baseProps); + Component = Component.defaultProps; + for (var propName in Component) + void 0 === baseProps[propName] && + (baseProps[propName] = Component[propName]); + } + return baseProps; +} +function readLazyComponentType(lazyComponent) { + var result = lazyComponent._result; + switch (lazyComponent._status) { + case 1: + return result; + case 2: + throw result; + case 0: + throw result; + 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)); + }, + function(error) { + 0 === lazyComponent._status && + ((lazyComponent._status = 2), (lazyComponent._result = error)); + } + ), + (lazyComponent._result = result), + result); + } +} +var ReactCurrentOwner$4 = ReactSharedInternals.ReactCurrentOwner, + emptyRefsObject = new React.Component().refs; function applyDerivedStateFromProps( workInProgress, ctor, @@ -2402,6 +2441,7 @@ var classComponentUpdater = { var update = createUpdate(currentTime); update.payload = payload; void 0 !== callback && null !== callback && (update.callback = callback); + flushPassiveEffects(); enqueueUpdate(inst, update); scheduleWork(inst, currentTime); }, @@ -2413,6 +2453,7 @@ var classComponentUpdater = { update.tag = 1; update.payload = payload; void 0 !== callback && null !== callback && (update.callback = callback); + flushPassiveEffects(); enqueueUpdate(inst, update); scheduleWork(inst, currentTime); }, @@ -2423,6 +2464,7 @@ var classComponentUpdater = { var update = createUpdate(currentTime); update.tag = 2; void 0 !== callback && null !== callback && (update.callback = callback); + flushPassiveEffects(); enqueueUpdate(inst, update); scheduleWork(inst, currentTime); } @@ -2443,6 +2485,32 @@ function checkShouldComponentUpdate( ? !shallowEqual(oldProps, newProps) || !shallowEqual(oldState, newState) : !0; } +function constructClassInstance(workInProgress, ctor, props) { + var isLegacyContextConsumer = !1, + unmaskedContext = emptyContextObject; + var context = ctor.contextType; + "object" === typeof context && null !== context + ? (context = ReactCurrentOwner$4.currentDispatcher.readContext(context)) + : ((unmaskedContext = isContextProvider(ctor) + ? previousContext + : contextStackCursor.current), + (isLegacyContextConsumer = ctor.contextTypes), + (context = (isLegacyContextConsumer = + null !== isLegacyContextConsumer && void 0 !== isLegacyContextConsumer) + ? getMaskedContext(workInProgress, unmaskedContext) + : emptyContextObject)); + ctor = new ctor(props, context); + workInProgress.memoizedState = + null !== ctor.state && void 0 !== ctor.state ? ctor.state : null; + ctor.updater = classComponentUpdater; + workInProgress.stateNode = ctor; + ctor._reactInternalFiber = workInProgress; + isLegacyContextConsumer && + ((workInProgress = workInProgress.stateNode), + (workInProgress.__reactInternalMemoizedUnmaskedChildContext = unmaskedContext), + (workInProgress.__reactInternalMemoizedMaskedChildContext = context)); + return ctor; +} function callComponentWillReceiveProps( workInProgress, instance, @@ -2469,7 +2537,9 @@ function mountClassInstance( instance.refs = emptyRefsObject; var contextType = ctor.contextType; "object" === typeof contextType && null !== contextType - ? (instance.context = contextType.unstable_read()) + ? (instance.context = ReactCurrentOwner$4.currentDispatcher.readContext( + contextType + )) : ((contextType = isContextProvider(ctor) ? previousContext : contextStackCursor.current), @@ -2524,10 +2594,7 @@ function coerceRef(returnFiber, current$$1, element) { element = element._owner; var inst = void 0; element && - (invariant( - 2 === element.tag || 3 === element.tag, - "Function components cannot have refs." - ), + (invariant(1 === element.tag, "Function components cannot have refs."), (inst = element.stateNode)); invariant( inst, @@ -2632,7 +2699,7 @@ function ChildReconciler(shouldTrackSideEffects) { textContent, expirationTime ) { - if (null === current$$1 || 8 !== current$$1.tag) + if (null === current$$1 || 6 !== current$$1.tag) return ( (current$$1 = createFiberFromText( textContent, @@ -2647,15 +2714,18 @@ function ChildReconciler(shouldTrackSideEffects) { return current$$1; } function updateElement(returnFiber, current$$1, element, expirationTime) { - if (null !== current$$1 && current$$1.type === element.type) + if (null !== current$$1 && current$$1.elementType === element.type) return ( (expirationTime = useFiber(current$$1, element.props, expirationTime)), (expirationTime.ref = coerceRef(returnFiber, current$$1, element)), (expirationTime.return = returnFiber), expirationTime ); - expirationTime = createFiberFromElement( - element, + expirationTime = createFiberFromTypeAndProps( + element.type, + element.key, + element.props, + null, returnFiber.mode, expirationTime ); @@ -2666,7 +2736,7 @@ function ChildReconciler(shouldTrackSideEffects) { function updatePortal(returnFiber, current$$1, portal, expirationTime) { if ( null === current$$1 || - 6 !== current$$1.tag || + 4 !== current$$1.tag || current$$1.stateNode.containerInfo !== portal.containerInfo || current$$1.stateNode.implementation !== portal.implementation ) @@ -2690,7 +2760,7 @@ function ChildReconciler(shouldTrackSideEffects) { expirationTime, key ) { - if (null === current$$1 || 9 !== current$$1.tag) + if (null === current$$1 || 7 !== current$$1.tag) return ( (current$$1 = createFiberFromFragment( fragment, @@ -2720,8 +2790,11 @@ function ChildReconciler(shouldTrackSideEffects) { switch (newChild.$$typeof) { case REACT_ELEMENT_TYPE: return ( - (expirationTime = createFiberFromElement( - newChild, + (expirationTime = createFiberFromTypeAndProps( + newChild.type, + newChild.key, + newChild.props, + null, returnFiber.mode, expirationTime )), @@ -3065,9 +3138,9 @@ function ChildReconciler(shouldTrackSideEffects) { ) { if (isUnkeyedTopLevelFragment.key === isObject) if ( - 9 === isUnkeyedTopLevelFragment.tag + 7 === isUnkeyedTopLevelFragment.tag ? newChild.type === REACT_FRAGMENT_TYPE - : isUnkeyedTopLevelFragment.type === newChild.type + : isUnkeyedTopLevelFragment.elementType === newChild.type ) { deleteRemainingChildren( returnFiber, @@ -3107,8 +3180,11 @@ function ChildReconciler(shouldTrackSideEffects) { )), (currentFirstChild.return = returnFiber), (returnFiber = currentFirstChild)) - : ((expirationTime = createFiberFromElement( - newChild, + : ((expirationTime = createFiberFromTypeAndProps( + newChild.type, + newChild.key, + newChild.props, + null, returnFiber.mode, expirationTime )), @@ -3130,7 +3206,7 @@ function ChildReconciler(shouldTrackSideEffects) { ) { if (currentFirstChild.key === isUnkeyedTopLevelFragment) if ( - 6 === currentFirstChild.tag && + 4 === currentFirstChild.tag && currentFirstChild.stateNode.containerInfo === newChild.containerInfo && currentFirstChild.stateNode.implementation === @@ -3168,7 +3244,7 @@ function ChildReconciler(shouldTrackSideEffects) { if ("string" === typeof newChild || "number" === typeof newChild) return ( (newChild = "" + newChild), - null !== currentFirstChild && 8 === currentFirstChild.tag + null !== currentFirstChild && 6 === currentFirstChild.tag ? (deleteRemainingChildren(returnFiber, currentFirstChild.sibling), (currentFirstChild = useFiber( currentFirstChild, @@ -3204,8 +3280,7 @@ function ChildReconciler(shouldTrackSideEffects) { isObject && throwOnInvalidObjectType(returnFiber, newChild); if ("undefined" === typeof newChild && !isUnkeyedTopLevelFragment) switch (returnFiber.tag) { - case 2: - case 3: + case 1: case 0: (expirationTime = returnFiber.type), invariant( @@ -3224,12 +3299,12 @@ var reconcileChildFibers = ChildReconciler(!0), isHydrating = !1; function tryHydrate(fiber, nextInstance) { switch (fiber.tag) { - case 7: + case 5: return ( (nextInstance = shim$1(nextInstance, fiber.type, fiber.pendingProps)), null !== nextInstance ? ((fiber.stateNode = nextInstance), !0) : !1 ); - case 8: + case 6: return ( (nextInstance = shim$1(nextInstance, fiber.pendingProps)), null !== nextInstance ? ((fiber.stateNode = nextInstance), !0) : !1 @@ -3252,7 +3327,8 @@ function tryToClaimNextHydratableInstance(fiber$jscomp$0) { return; } var returnFiber = hydrationParentFiber, - fiber = new FiberNode(7, null, null, 0); + fiber = createFiber(5, null, null, 0); + fiber.elementType = "DELETED"; fiber.type = "DELETED"; fiber.stateNode = firstAttemptedInstance; fiber.return = returnFiber; @@ -3270,38 +3346,6 @@ function tryToClaimNextHydratableInstance(fiber$jscomp$0) { (hydrationParentFiber = fiber$jscomp$0); } } -function readLazyComponentType(thenable) { - switch (thenable._reactStatus) { - case 1: - return thenable._reactResult; - case 2: - throw thenable._reactResult; - case 0: - throw thenable; - default: - throw ((thenable._reactStatus = 0), - thenable.then( - function(resolvedValue) { - if (0 === thenable._reactStatus) { - thenable._reactStatus = 1; - if ("object" === typeof resolvedValue && null !== resolvedValue) { - var defaultExport = resolvedValue.default; - resolvedValue = - void 0 !== defaultExport && null !== defaultExport - ? defaultExport - : resolvedValue; - } - thenable._reactResult = resolvedValue; - } - }, - function(error) { - 0 === thenable._reactStatus && - ((thenable._reactStatus = 2), (thenable._reactResult = error)); - } - ), - thenable); - } -} var ReactCurrentOwner$3 = ReactSharedInternals.ReactCurrentOwner; function reconcileChildren( current$$1, @@ -3327,28 +3371,24 @@ function reconcileChildren( function updateForwardRef( current$$1, workInProgress, - type, + Component, nextProps, renderExpirationTime ) { - type = type.render; + Component = Component.render; var ref = workInProgress.ref; - if ( - !didPerformWorkStackCursor.current && - workInProgress.memoizedProps === nextProps && - ref === (null !== current$$1 ? current$$1.ref : null) - ) - return bailoutOnAlreadyFinishedWork( - current$$1, - workInProgress, - renderExpirationTime - ); - type = type(nextProps, ref); - reconcileChildren(current$$1, workInProgress, type, renderExpirationTime); - workInProgress.memoizedProps = nextProps; + prepareToReadContext(workInProgress, renderExpirationTime); + nextProps = Component(nextProps, ref); + workInProgress.effectTag |= 1; + reconcileChildren( + current$$1, + workInProgress, + nextProps, + renderExpirationTime + ); return workInProgress.child; } -function updatePureComponent( +function updateMemoComponent( current$$1, workInProgress, Component, @@ -3356,29 +3396,82 @@ function updatePureComponent( updateExpirationTime, renderExpirationTime ) { - var render = Component.render, - ref = workInProgress.ref; + if (null === current$$1) { + var type = Component.type; + if ( + "function" === typeof type && + !shouldConstruct(type) && + void 0 === type.defaultProps && + null === Component.compare + ) + return ( + (workInProgress.tag = 15), + (workInProgress.type = type), + updateSimpleMemoComponent( + current$$1, + workInProgress, + type, + nextProps, + updateExpirationTime, + renderExpirationTime + ) + ); + current$$1 = createFiberFromTypeAndProps( + Component.type, + null, + nextProps, + null, + workInProgress.mode, + renderExpirationTime + ); + current$$1.ref = workInProgress.ref; + current$$1.return = workInProgress; + return (workInProgress.child = current$$1); + } + type = current$$1.child; if ( - null !== current$$1 && - (0 === updateExpirationTime || - updateExpirationTime > renderExpirationTime) && - ((updateExpirationTime = current$$1.memoizedProps), + updateExpirationTime < renderExpirationTime && + ((updateExpirationTime = type.memoizedProps), (Component = Component.compare), (Component = null !== Component ? Component : shallowEqual), - workInProgress.ref === current$$1.ref && - Component(updateExpirationTime, nextProps)) + Component(updateExpirationTime, nextProps) && + current$$1.ref === workInProgress.ref) ) return bailoutOnAlreadyFinishedWork( current$$1, workInProgress, renderExpirationTime ); - prepareToReadContext(workInProgress, renderExpirationTime); - render = render(nextProps, ref); workInProgress.effectTag |= 1; - reconcileChildren(current$$1, workInProgress, render, renderExpirationTime); - workInProgress.memoizedProps = nextProps; - return workInProgress.child; + current$$1 = createWorkInProgress(type, nextProps, renderExpirationTime); + current$$1.ref = workInProgress.ref; + current$$1.return = workInProgress; + return (workInProgress.child = current$$1); +} +function updateSimpleMemoComponent( + current$$1, + workInProgress, + Component, + nextProps, + updateExpirationTime, + renderExpirationTime +) { + return null !== current$$1 && + updateExpirationTime < renderExpirationTime && + shallowEqual(current$$1.memoizedProps, nextProps) && + current$$1.ref === workInProgress.ref + ? bailoutOnAlreadyFinishedWork( + current$$1, + workInProgress, + renderExpirationTime + ) + : updateFunctionComponent( + current$$1, + workInProgress, + Component, + nextProps, + renderExpirationTime + ); } function markRef(current$$1, workInProgress) { var ref = workInProgress.ref; @@ -3408,7 +3501,6 @@ function updateFunctionComponent( Component, renderExpirationTime ); - workInProgress.memoizedProps = nextProps; return workInProgress.child; } function updateClassComponent( @@ -3423,166 +3515,152 @@ function updateClassComponent( pushContextProvider(workInProgress); } else hasContext = !1; prepareToReadContext(workInProgress, renderExpirationTime); - if (null === current$$1) - if (null === workInProgress.stateNode) { - var isLegacyContextConsumer = !1, - unmaskedContext = emptyContextObject; - var context = Component.contextType; - "object" === typeof context && null !== context - ? (context = context.unstable_read()) - : ((unmaskedContext = isContextProvider(Component) - ? previousContext - : contextStackCursor.current), - (isLegacyContextConsumer = Component.contextTypes), - (context = (isLegacyContextConsumer = - null !== isLegacyContextConsumer && - void 0 !== isLegacyContextConsumer) - ? getMaskedContext(workInProgress, unmaskedContext) - : emptyContextObject)); - var instance = new Component(nextProps, context); - workInProgress.memoizedState = - null !== instance.state && void 0 !== instance.state - ? instance.state - : null; - instance.updater = classComponentUpdater; - workInProgress.stateNode = instance; - instance._reactInternalFiber = workInProgress; - isLegacyContextConsumer && - ((isLegacyContextConsumer = workInProgress.stateNode), - (isLegacyContextConsumer.__reactInternalMemoizedUnmaskedChildContext = unmaskedContext), - (isLegacyContextConsumer.__reactInternalMemoizedMaskedChildContext = context)); + if (null === workInProgress.stateNode) + null !== current$$1 && + ((current$$1.alternate = null), + (workInProgress.alternate = null), + (workInProgress.effectTag |= 2)), + constructClassInstance( + workInProgress, + Component, + nextProps, + renderExpirationTime + ), mountClassInstance( workInProgress, Component, nextProps, renderExpirationTime - ); - nextProps = !0; - } else { - unmaskedContext = workInProgress.stateNode; - isLegacyContextConsumer = workInProgress.memoizedProps; - unmaskedContext.props = isLegacyContextConsumer; - var oldContext = unmaskedContext.context; - context = Component.contextType; - "object" === typeof context && null !== context - ? (context = context.unstable_read()) - : ((context = isContextProvider(Component) - ? previousContext - : contextStackCursor.current), - (context = getMaskedContext(workInProgress, context))); - var getDerivedStateFromProps = Component.getDerivedStateFromProps; - (instance = + ), + (nextProps = !0); + else if (null === current$$1) { + var instance = workInProgress.stateNode, + oldProps = workInProgress.memoizedProps; + instance.props = oldProps; + var oldContext = instance.context, + contextType = Component.contextType; + "object" === typeof contextType && null !== contextType + ? (contextType = ReactCurrentOwner$4.currentDispatcher.readContext( + contextType + )) + : ((contextType = isContextProvider(Component) + ? previousContext + : contextStackCursor.current), + (contextType = getMaskedContext(workInProgress, contextType))); + var getDerivedStateFromProps = Component.getDerivedStateFromProps, + hasNewLifecycles = "function" === typeof getDerivedStateFromProps || - "function" === typeof unmaskedContext.getSnapshotBeforeUpdate) || - ("function" !== - typeof unmaskedContext.UNSAFE_componentWillReceiveProps && - "function" !== typeof unmaskedContext.componentWillReceiveProps) || - ((isLegacyContextConsumer !== nextProps || oldContext !== context) && - callComponentWillReceiveProps( - workInProgress, - unmaskedContext, - nextProps, - context - )); - hasForceUpdate = !1; - var oldState = workInProgress.memoizedState; - oldContext = unmaskedContext.state = oldState; - var updateQueue = workInProgress.updateQueue; - null !== updateQueue && - (processUpdateQueue( + "function" === typeof instance.getSnapshotBeforeUpdate; + hasNewLifecycles || + ("function" !== typeof instance.UNSAFE_componentWillReceiveProps && + "function" !== typeof instance.componentWillReceiveProps) || + ((oldProps !== nextProps || oldContext !== contextType) && + callComponentWillReceiveProps( workInProgress, - updateQueue, + instance, nextProps, - unmaskedContext, - renderExpirationTime - ), - (oldContext = workInProgress.memoizedState)); - isLegacyContextConsumer !== nextProps || - oldState !== oldContext || - didPerformWorkStackCursor.current || - hasForceUpdate - ? ("function" === typeof getDerivedStateFromProps && - (applyDerivedStateFromProps( - workInProgress, - Component, - getDerivedStateFromProps, - nextProps - ), - (oldContext = workInProgress.memoizedState)), - (isLegacyContextConsumer = - hasForceUpdate || - checkShouldComponentUpdate( - workInProgress, - Component, - isLegacyContextConsumer, - nextProps, - oldState, - oldContext, - context - )) - ? (instance || - ("function" !== - typeof unmaskedContext.UNSAFE_componentWillMount && - "function" !== typeof unmaskedContext.componentWillMount) || - ("function" === typeof unmaskedContext.componentWillMount && - unmaskedContext.componentWillMount(), - "function" === - typeof unmaskedContext.UNSAFE_componentWillMount && - unmaskedContext.UNSAFE_componentWillMount()), - "function" === typeof unmaskedContext.componentDidMount && - (workInProgress.effectTag |= 4)) - : ("function" === typeof unmaskedContext.componentDidMount && - (workInProgress.effectTag |= 4), - (workInProgress.memoizedProps = nextProps), - (workInProgress.memoizedState = oldContext)), - (unmaskedContext.props = nextProps), - (unmaskedContext.state = oldContext), - (unmaskedContext.context = context), - (nextProps = isLegacyContextConsumer)) - : ("function" === typeof unmaskedContext.componentDidMount && - (workInProgress.effectTag |= 4), - (nextProps = !1)); - } - else - (unmaskedContext = workInProgress.stateNode), - (isLegacyContextConsumer = workInProgress.memoizedProps), - (unmaskedContext.props = isLegacyContextConsumer), - (oldContext = unmaskedContext.context), - (context = Component.contextType), - "object" === typeof context && null !== context - ? (context = context.unstable_read()) - : ((context = isContextProvider(Component) + contextType + )); + hasForceUpdate = !1; + var oldState = workInProgress.memoizedState; + oldContext = instance.state = oldState; + var updateQueue = workInProgress.updateQueue; + null !== updateQueue && + (processUpdateQueue( + workInProgress, + updateQueue, + nextProps, + instance, + renderExpirationTime + ), + (oldContext = workInProgress.memoizedState)); + oldProps !== nextProps || + oldState !== oldContext || + didPerformWorkStackCursor.current || + hasForceUpdate + ? ("function" === typeof getDerivedStateFromProps && + (applyDerivedStateFromProps( + workInProgress, + Component, + getDerivedStateFromProps, + nextProps + ), + (oldContext = workInProgress.memoizedState)), + (oldProps = + hasForceUpdate || + checkShouldComponentUpdate( + workInProgress, + Component, + oldProps, + nextProps, + oldState, + oldContext, + contextType + )) + ? (hasNewLifecycles || + ("function" !== typeof instance.UNSAFE_componentWillMount && + "function" !== typeof instance.componentWillMount) || + ("function" === typeof instance.componentWillMount && + instance.componentWillMount(), + "function" === typeof instance.UNSAFE_componentWillMount && + instance.UNSAFE_componentWillMount()), + "function" === typeof instance.componentDidMount && + (workInProgress.effectTag |= 4)) + : ("function" === typeof instance.componentDidMount && + (workInProgress.effectTag |= 4), + (workInProgress.memoizedProps = nextProps), + (workInProgress.memoizedState = oldContext)), + (instance.props = nextProps), + (instance.state = oldContext), + (instance.context = contextType), + (nextProps = oldProps)) + : ("function" === typeof instance.componentDidMount && + (workInProgress.effectTag |= 4), + (nextProps = !1)); + } else + (instance = workInProgress.stateNode), + (oldProps = workInProgress.memoizedProps), + (instance.props = + workInProgress.type === workInProgress.elementType + ? oldProps + : resolveDefaultProps(workInProgress.type, oldProps)), + (oldContext = instance.context), + (contextType = Component.contextType), + "object" === typeof contextType && null !== contextType + ? (contextType = ReactCurrentOwner$4.currentDispatcher.readContext( + contextType + )) + : ((contextType = isContextProvider(Component) ? previousContext : contextStackCursor.current), - (context = getMaskedContext(workInProgress, context))), + (contextType = getMaskedContext(workInProgress, contextType))), (getDerivedStateFromProps = Component.getDerivedStateFromProps), - (instance = + (hasNewLifecycles = "function" === typeof getDerivedStateFromProps || - "function" === typeof unmaskedContext.getSnapshotBeforeUpdate) || - ("function" !== - typeof unmaskedContext.UNSAFE_componentWillReceiveProps && - "function" !== typeof unmaskedContext.componentWillReceiveProps) || - ((isLegacyContextConsumer !== nextProps || oldContext !== context) && + "function" === typeof instance.getSnapshotBeforeUpdate) || + ("function" !== typeof instance.UNSAFE_componentWillReceiveProps && + "function" !== typeof instance.componentWillReceiveProps) || + ((oldProps !== nextProps || oldContext !== contextType) && callComponentWillReceiveProps( workInProgress, - unmaskedContext, + instance, nextProps, - context + contextType )), (hasForceUpdate = !1), (oldContext = workInProgress.memoizedState), - (oldState = unmaskedContext.state = oldContext), + (oldState = instance.state = oldContext), (updateQueue = workInProgress.updateQueue), null !== updateQueue && (processUpdateQueue( workInProgress, updateQueue, nextProps, - unmaskedContext, + instance, renderExpirationTime ), (oldState = workInProgress.memoizedState)), - isLegacyContextConsumer !== nextProps || + oldProps !== nextProps || oldContext !== oldState || didPerformWorkStackCursor.current || hasForceUpdate @@ -3599,53 +3677,51 @@ function updateClassComponent( checkShouldComponentUpdate( workInProgress, Component, - isLegacyContextConsumer, + oldProps, nextProps, oldContext, oldState, - context + contextType )) - ? (instance || - ("function" !== - typeof unmaskedContext.UNSAFE_componentWillUpdate && - "function" !== typeof unmaskedContext.componentWillUpdate) || - ("function" === typeof unmaskedContext.componentWillUpdate && - unmaskedContext.componentWillUpdate( + ? (hasNewLifecycles || + ("function" !== typeof instance.UNSAFE_componentWillUpdate && + "function" !== typeof instance.componentWillUpdate) || + ("function" === typeof instance.componentWillUpdate && + instance.componentWillUpdate( nextProps, oldState, - context + contextType ), - "function" === - typeof unmaskedContext.UNSAFE_componentWillUpdate && - unmaskedContext.UNSAFE_componentWillUpdate( + "function" === typeof instance.UNSAFE_componentWillUpdate && + instance.UNSAFE_componentWillUpdate( nextProps, oldState, - context + contextType )), - "function" === typeof unmaskedContext.componentDidUpdate && + "function" === typeof instance.componentDidUpdate && (workInProgress.effectTag |= 4), - "function" === typeof unmaskedContext.getSnapshotBeforeUpdate && + "function" === typeof instance.getSnapshotBeforeUpdate && (workInProgress.effectTag |= 256)) - : ("function" !== typeof unmaskedContext.componentDidUpdate || - (isLegacyContextConsumer === current$$1.memoizedProps && + : ("function" !== typeof instance.componentDidUpdate || + (oldProps === current$$1.memoizedProps && oldContext === current$$1.memoizedState) || (workInProgress.effectTag |= 4), - "function" !== typeof unmaskedContext.getSnapshotBeforeUpdate || - (isLegacyContextConsumer === current$$1.memoizedProps && + "function" !== typeof instance.getSnapshotBeforeUpdate || + (oldProps === current$$1.memoizedProps && oldContext === current$$1.memoizedState) || (workInProgress.effectTag |= 256), (workInProgress.memoizedProps = nextProps), (workInProgress.memoizedState = oldState)), - (unmaskedContext.props = nextProps), - (unmaskedContext.state = oldState), - (unmaskedContext.context = context), + (instance.props = nextProps), + (instance.state = oldState), + (instance.context = contextType), (nextProps = getDerivedStateFromProps)) - : ("function" !== typeof unmaskedContext.componentDidUpdate || - (isLegacyContextConsumer === current$$1.memoizedProps && + : ("function" !== typeof instance.componentDidUpdate || + (oldProps === current$$1.memoizedProps && oldContext === current$$1.memoizedState) || (workInProgress.effectTag |= 4), - "function" !== typeof unmaskedContext.getSnapshotBeforeUpdate || - (isLegacyContextConsumer === current$$1.memoizedProps && + "function" !== typeof instance.getSnapshotBeforeUpdate || + (oldProps === current$$1.memoizedProps && oldContext === current$$1.memoizedState) || (workInProgress.effectTag |= 256), (nextProps = !1)); @@ -3704,7 +3780,6 @@ function finishClassComponent( renderExpirationTime ); workInProgress.memoizedState = shouldUpdate.state; - workInProgress.memoizedProps = shouldUpdate.props; hasContext && invalidateContextProvider(workInProgress, Component, !0); return workInProgress.child; } @@ -3720,15 +3795,105 @@ function pushHostRootContext(workInProgress) { pushTopLevelContextObject(workInProgress, root.context, !1); pushHostContainer(workInProgress, root.containerInfo); } -function resolveDefaultProps(Component, baseProps) { - if (Component && Component.defaultProps) { - baseProps = Object.assign({}, baseProps); - Component = Component.defaultProps; - for (var propName in Component) - void 0 === baseProps[propName] && - (baseProps[propName] = Component[propName]); - } - return baseProps; +function updateSuspenseComponent( + current$$1, + workInProgress, + renderExpirationTime +) { + var mode = workInProgress.mode, + nextProps = workInProgress.pendingProps, + nextState = workInProgress.memoizedState; + if (0 === (workInProgress.effectTag & 64)) { + nextState = null; + var nextDidTimeout = !1; + } else + (nextState = { timedOutAt: null !== nextState ? nextState.timedOutAt : 0 }), + (nextDidTimeout = !0), + (workInProgress.effectTag &= -65); + null === current$$1 + ? nextDidTimeout + ? ((nextDidTimeout = nextProps.fallback), + (nextProps = createFiberFromFragment(null, mode, 0, null)), + 0 === (workInProgress.mode & 1) && + (nextProps.child = + null !== workInProgress.memoizedState + ? workInProgress.child.child + : workInProgress.child), + (mode = createFiberFromFragment( + nextDidTimeout, + mode, + renderExpirationTime, + null + )), + (nextProps.sibling = mode), + (renderExpirationTime = nextProps), + (renderExpirationTime.return = mode.return = workInProgress)) + : (renderExpirationTime = mode = mountChildFibers( + workInProgress, + null, + nextProps.children, + renderExpirationTime + )) + : null !== current$$1.memoizedState + ? ((mode = current$$1.child), + (current$$1 = mode.sibling), + nextDidTimeout + ? ((renderExpirationTime = nextProps.fallback), + (nextProps = createWorkInProgress(mode, mode.pendingProps, 0)), + (nextProps.effectTag |= 2), + 0 === (workInProgress.mode & 1) && + ((nextDidTimeout = + null !== workInProgress.memoizedState + ? workInProgress.child.child + : workInProgress.child), + nextDidTimeout !== mode.child && + (nextProps.child = nextDidTimeout)), + (mode = nextProps.sibling = createWorkInProgress( + current$$1, + renderExpirationTime, + current$$1.expirationTime + )), + (mode.effectTag |= 2), + (renderExpirationTime = nextProps), + (nextProps.childExpirationTime = 0), + (renderExpirationTime.return = mode.return = workInProgress)) + : (renderExpirationTime = mode = reconcileChildFibers( + workInProgress, + mode.child, + nextProps.children, + renderExpirationTime + ))) + : ((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), + 0 === (workInProgress.mode & 1) && + (nextProps.child = + null !== workInProgress.memoizedState + ? workInProgress.child.child + : workInProgress.child), + (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, @@ -3737,9 +3902,7 @@ function bailoutOnAlreadyFinishedWork( ) { null !== current$$1 && (workInProgress.firstContextDependency = current$$1.firstContextDependency); - var childExpirationTime = workInProgress.childExpirationTime; - if (0 === childExpirationTime || childExpirationTime > renderExpirationTime) - return null; + if (workInProgress.childExpirationTime < renderExpirationTime) return null; invariant( null === current$$1 || workInProgress.child === current$$1.child, "Resuming work not yet implemented." @@ -3774,31 +3937,47 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { null !== current$$1 && current$$1.memoizedProps === workInProgress.pendingProps && !didPerformWorkStackCursor.current && - (0 === updateExpirationTime || updateExpirationTime > renderExpirationTime) + updateExpirationTime < renderExpirationTime ) { switch (workInProgress.tag) { - case 5: + case 3: pushHostRootContext(workInProgress); break; - case 7: + case 5: pushHostContext(workInProgress); break; - case 2: + case 1: isContextProvider(workInProgress.type) && pushContextProvider(workInProgress); break; - case 3: - isContextProvider(workInProgress.type._reactResult) && - pushContextProvider(workInProgress); - break; - case 6: + case 4: pushHostContainer( workInProgress, workInProgress.stateNode.containerInfo ); break; - case 12: + case 10: pushProvider(workInProgress, workInProgress.memoizedProps.value); + break; + case 13: + if (null !== workInProgress.memoizedState) { + updateExpirationTime = workInProgress.child.childExpirationTime; + if ( + 0 !== updateExpirationTime && + updateExpirationTime >= renderExpirationTime + ) + return updateSuspenseComponent( + current$$1, + workInProgress, + renderExpirationTime + ); + workInProgress = bailoutOnAlreadyFinishedWork( + current$$1, + workInProgress, + renderExpirationTime + ); + return null !== workInProgress ? workInProgress.sibling : null; + } } return bailoutOnAlreadyFinishedWork( current$$1, @@ -3808,191 +3987,180 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { } workInProgress.expirationTime = 0; switch (workInProgress.tag) { - case 4: - var Component = workInProgress.type; - invariant( - null === current$$1, - "An indeterminate component should never have mounted. This error is likely caused by a bug in React. Please file an issue." + 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 ); - var props = workInProgress.pendingProps; + prepareToReadContext(workInProgress, renderExpirationTime); + context = updateExpirationTime(current$$1, context); + workInProgress.effectTag |= 1; if ( - "object" === typeof Component && - null !== Component && - "function" === typeof Component.then + "object" === typeof context && + null !== context && + "function" === typeof context.render && + void 0 === context.$$typeof ) { - Component = readLazyComponentType(Component); - var resolvedTag = (workInProgress.tag = resolveLazyComponentTag( + workInProgress.tag = 1; + if (isContextProvider(updateExpirationTime)) { + var hasContext = !0; + pushContextProvider(workInProgress); + } else hasContext = !1; + workInProgress.memoizedState = + null !== context.state && void 0 !== context.state + ? context.state + : null; + var getDerivedStateFromProps = + updateExpirationTime.getDerivedStateFromProps; + "function" === typeof getDerivedStateFromProps && + applyDerivedStateFromProps( workInProgress, - Component - )), - resolvedProps = resolveDefaultProps(Component, props), - child = void 0; - switch (resolvedTag) { - case 1: - child = updateFunctionComponent( - current$$1, - workInProgress, - Component, - resolvedProps, - renderExpirationTime - ); - break; - case 3: - child = updateClassComponent( - current$$1, - workInProgress, - Component, - resolvedProps, - renderExpirationTime - ); - break; - case 14: - child = updateForwardRef( - current$$1, - workInProgress, - Component, - resolvedProps, - renderExpirationTime - ); - break; - case 18: - child = updatePureComponent( - current$$1, - workInProgress, - Component, - resolvedProps, - updateExpirationTime, - renderExpirationTime - ); - break; - default: - invariant( - !1, - "Element type is invalid. Received a promise that resolves to: %s. Promise elements must resolve to a class or function.", - Component - ); - } - workInProgress.memoizedProps = props; - workInProgress = child; - } else - (updateExpirationTime = getMaskedContext( + updateExpirationTime, + getDerivedStateFromProps, + current$$1 + ); + context.updater = classComponentUpdater; + workInProgress.stateNode = context; + context._reactInternalFiber = workInProgress; + mountClassInstance( workInProgress, - contextStackCursor.current - )), - prepareToReadContext(workInProgress, renderExpirationTime), - (updateExpirationTime = Component(props, updateExpirationTime)), - (workInProgress.effectTag |= 1), - "object" === typeof updateExpirationTime && - null !== updateExpirationTime && - "function" === typeof updateExpirationTime.render && - void 0 === updateExpirationTime.$$typeof - ? ((workInProgress.tag = 2), - isContextProvider(Component) - ? ((resolvedTag = !0), pushContextProvider(workInProgress)) - : (resolvedTag = !1), - (workInProgress.memoizedState = - null !== updateExpirationTime.state && - void 0 !== updateExpirationTime.state - ? updateExpirationTime.state - : null), - (resolvedProps = Component.getDerivedStateFromProps), - "function" === typeof resolvedProps && - applyDerivedStateFromProps( - workInProgress, - Component, - resolvedProps, - props - ), - (updateExpirationTime.updater = classComponentUpdater), - (workInProgress.stateNode = updateExpirationTime), - (updateExpirationTime._reactInternalFiber = workInProgress), - mountClassInstance( - workInProgress, - Component, - props, - renderExpirationTime - ), - (workInProgress = finishClassComponent( - current$$1, - workInProgress, - Component, - !0, - resolvedTag, - renderExpirationTime - ))) - : ((workInProgress.tag = 0), - reconcileChildren( - current$$1, - workInProgress, - updateExpirationTime, - renderExpirationTime - ), - (workInProgress.memoizedProps = props), - (workInProgress = workInProgress.child)); + updateExpirationTime, + current$$1, + renderExpirationTime + ); + workInProgress = finishClassComponent( + null, + workInProgress, + updateExpirationTime, + !0, + hasContext, + renderExpirationTime + ); + } else + (workInProgress.tag = 0), + reconcileChildren( + null, + workInProgress, + context, + renderExpirationTime + ), + (workInProgress = workInProgress.child); return workInProgress; + case 16: + context = workInProgress.elementType; + null !== current$$1 && + ((current$$1.alternate = null), + (workInProgress.alternate = null), + (workInProgress.effectTag |= 2)); + hasContext = workInProgress.pendingProps; + current$$1 = readLazyComponentType(context); + workInProgress.type = current$$1; + context = workInProgress.tag = resolveLazyComponentTag(current$$1); + hasContext = resolveDefaultProps(current$$1, hasContext); + getDerivedStateFromProps = void 0; + switch (context) { + case 0: + getDerivedStateFromProps = updateFunctionComponent( + null, + workInProgress, + current$$1, + hasContext, + renderExpirationTime + ); + break; + case 1: + getDerivedStateFromProps = updateClassComponent( + null, + workInProgress, + current$$1, + hasContext, + renderExpirationTime + ); + break; + case 11: + getDerivedStateFromProps = updateForwardRef( + null, + workInProgress, + current$$1, + hasContext, + renderExpirationTime + ); + break; + case 14: + getDerivedStateFromProps = updateMemoComponent( + null, + workInProgress, + current$$1, + resolveDefaultProps(current$$1.type, hasContext), + 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.", + current$$1 + ); + } + return getDerivedStateFromProps; case 0: - return updateFunctionComponent( - current$$1, - workInProgress, - workInProgress.type, - workInProgress.pendingProps, - renderExpirationTime - ); - case 1: return ( - (props = workInProgress.type._reactResult), - (Component = workInProgress.pendingProps), - (current$$1 = updateFunctionComponent( + (updateExpirationTime = workInProgress.type), + (context = workInProgress.pendingProps), + (context = + workInProgress.elementType === updateExpirationTime + ? context + : resolveDefaultProps(updateExpirationTime, context)), + updateFunctionComponent( current$$1, workInProgress, - props, - resolveDefaultProps(props, Component), + updateExpirationTime, + context, renderExpirationTime - )), - (workInProgress.memoizedProps = Component), - current$$1 - ); - case 2: - return updateClassComponent( - current$$1, - workInProgress, - workInProgress.type, - workInProgress.pendingProps, - renderExpirationTime + ) ); - case 3: + case 1: return ( - (props = workInProgress.type._reactResult), - (Component = workInProgress.pendingProps), - (current$$1 = updateClassComponent( + (updateExpirationTime = workInProgress.type), + (context = workInProgress.pendingProps), + (context = + workInProgress.elementType === updateExpirationTime + ? context + : resolveDefaultProps(updateExpirationTime, context)), + updateClassComponent( current$$1, workInProgress, - props, - resolveDefaultProps(props, Component), + updateExpirationTime, + context, renderExpirationTime - )), - (workInProgress.memoizedProps = Component), - current$$1 + ) ); - case 5: + case 3: return ( pushHostRootContext(workInProgress), - (Component = workInProgress.updateQueue), + (updateExpirationTime = workInProgress.updateQueue), invariant( - null !== Component, + null !== updateExpirationTime, "If the root does not have an updateQueue, we should have already bailed out. This error is likely caused by a bug in React. Please file an issue." ), - (props = workInProgress.memoizedState), - (props = null !== props ? props.element : null), + (context = workInProgress.memoizedState), + (context = null !== context ? context.element : null), processUpdateQueue( workInProgress, - Component, + updateExpirationTime, workInProgress.pendingProps, null, renderExpirationTime ), - (Component = workInProgress.memoizedState.element), - Component === props + (updateExpirationTime = workInProgress.memoizedState.element), + updateExpirationTime === context ? (workInProgress = bailoutOnAlreadyFinishedWork( current$$1, workInProgress, @@ -4001,185 +4169,130 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { : (reconcileChildren( current$$1, workInProgress, - Component, + updateExpirationTime, renderExpirationTime ), (workInProgress = workInProgress.child)), workInProgress ); - case 7: + case 5: return ( pushHostContext(workInProgress), null === current$$1 && tryToClaimNextHydratableInstance(workInProgress), - (Component = workInProgress.pendingProps), - (props = Component.children), + (updateExpirationTime = workInProgress.pendingProps.children), markRef(current$$1, workInProgress), reconcileChildren( current$$1, workInProgress, - props, + updateExpirationTime, renderExpirationTime ), - (workInProgress.memoizedProps = Component), (workInProgress = workInProgress.child), workInProgress ); - case 8: + case 6: return ( null === current$$1 && tryToClaimNextHydratableInstance(workInProgress), - (workInProgress.memoizedProps = workInProgress.pendingProps), null ); - case 16: - return ( - (Component = workInProgress.pendingProps), - (props = 0 === (workInProgress.effectTag & 64)), - null !== current$$1 && null !== workInProgress.updateQueue - ? ((workInProgress.updateQueue = null), (props = !0)) - : (props = !props), - 0 !== (workInProgress.mode & 2) && - (props - ? (workInProgress.effectTag |= 4) - : (workInProgress.stateNode = null)), - (updateExpirationTime = Component.children), - (updateExpirationTime = - "function" === typeof updateExpirationTime - ? updateExpirationTime(props) - : props - ? Component.fallback - : updateExpirationTime), - null !== current$$1 && props !== workInProgress.memoizedState - ? ((workInProgress.child = reconcileChildFibers( - workInProgress, - current$$1.child, - null, - renderExpirationTime - )), - (workInProgress.child = reconcileChildFibers( - workInProgress, - null, - updateExpirationTime, - renderExpirationTime - ))) - : reconcileChildren( - current$$1, - workInProgress, - updateExpirationTime, - renderExpirationTime - ), - (workInProgress.memoizedProps = Component), - (workInProgress.memoizedState = props), - workInProgress.child + case 13: + return updateSuspenseComponent( + current$$1, + workInProgress, + renderExpirationTime ); - case 6: + case 4: return ( pushHostContainer( workInProgress, workInProgress.stateNode.containerInfo ), - (Component = workInProgress.pendingProps), + (updateExpirationTime = workInProgress.pendingProps), null === current$$1 ? (workInProgress.child = reconcileChildFibers( workInProgress, null, - Component, + updateExpirationTime, renderExpirationTime )) : reconcileChildren( current$$1, workInProgress, - Component, + updateExpirationTime, renderExpirationTime ), - (workInProgress.memoizedProps = Component), workInProgress.child ); - case 13: - return updateForwardRef( - current$$1, - workInProgress, - workInProgress.type, - workInProgress.pendingProps, - renderExpirationTime - ); - case 14: + case 11: return ( - (props = workInProgress.type._reactResult), - (Component = workInProgress.pendingProps), - (current$$1 = updateForwardRef( + (updateExpirationTime = workInProgress.type), + (context = workInProgress.pendingProps), + (context = + workInProgress.elementType === updateExpirationTime + ? context + : resolveDefaultProps(updateExpirationTime, context)), + updateForwardRef( current$$1, workInProgress, - props, - resolveDefaultProps(props, Component), + updateExpirationTime, + context, renderExpirationTime - )), - (workInProgress.memoizedProps = Component), - current$$1 + ) ); - case 9: + case 7: return ( - (Component = workInProgress.pendingProps), reconcileChildren( current$$1, workInProgress, - Component, + workInProgress.pendingProps, renderExpirationTime ), - (workInProgress.memoizedProps = Component), workInProgress.child ); - case 10: + case 8: return ( - (Component = workInProgress.pendingProps.children), reconcileChildren( current$$1, workInProgress, - Component, + workInProgress.pendingProps.children, renderExpirationTime ), - (workInProgress.memoizedProps = Component), workInProgress.child ); - case 15: + case 12: return ( - (Component = workInProgress.pendingProps), reconcileChildren( current$$1, workInProgress, - Component.children, + workInProgress.pendingProps.children, renderExpirationTime ), - (workInProgress.memoizedProps = Component), workInProgress.child ); - case 12: + case 10: a: { - Component = workInProgress.type._context; - props = workInProgress.pendingProps; - resolvedTag = workInProgress.memoizedProps; - updateExpirationTime = props.value; - workInProgress.memoizedProps = props; - pushProvider(workInProgress, updateExpirationTime); - if (null !== resolvedTag) - if ( - ((resolvedProps = resolvedTag.value), - (updateExpirationTime = - (resolvedProps === updateExpirationTime && - (0 !== resolvedProps || - 1 / resolvedProps === 1 / updateExpirationTime)) || - (resolvedProps !== resolvedProps && - updateExpirationTime !== updateExpirationTime) - ? 0 - : ("function" === typeof Component._calculateChangedBits - ? Component._calculateChangedBits( - resolvedProps, - updateExpirationTime - ) - : 1073741823) | 0), - 0 === updateExpirationTime) - ) { + updateExpirationTime = workInProgress.type._context; + context = workInProgress.pendingProps; + getDerivedStateFromProps = workInProgress.memoizedProps; + hasContext = context.value; + pushProvider(workInProgress, hasContext); + if (null !== getDerivedStateFromProps) { + var oldValue = getDerivedStateFromProps.value; + hasContext = + (oldValue === hasContext && + (0 !== oldValue || 1 / oldValue === 1 / hasContext)) || + (oldValue !== oldValue && hasContext !== hasContext) + ? 0 + : ("function" === + typeof updateExpirationTime._calculateChangedBits + ? updateExpirationTime._calculateChangedBits( + oldValue, + hasContext + ) + : 1073741823) | 0; + if (0 === hasContext) { if ( - resolvedTag.children === props.children && + getDerivedStateFromProps.children === context.children && !didPerformWorkStackCursor.current ) { workInProgress = bailoutOnAlreadyFinishedWork( @@ -4191,113 +4304,129 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { } } else for ( - resolvedTag = workInProgress.child, - null !== resolvedTag && (resolvedTag.return = workInProgress); - null !== resolvedTag; + getDerivedStateFromProps = workInProgress.child, + null !== getDerivedStateFromProps && + (getDerivedStateFromProps.return = workInProgress); + null !== getDerivedStateFromProps; ) { - resolvedProps = resolvedTag.firstContextDependency; - if (null !== resolvedProps) { + oldValue = getDerivedStateFromProps.firstContextDependency; + if (null !== oldValue) { do { if ( - resolvedProps.context === Component && - 0 !== (resolvedProps.observedBits & updateExpirationTime) + oldValue.context === updateExpirationTime && + 0 !== (oldValue.observedBits & hasContext) ) { - 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 ( - 0 === node.childExpirationTime || - node.childExpirationTime > renderExpirationTime - ) + if (1 === getDerivedStateFromProps.tag) { + var nextFiber = createUpdate(renderExpirationTime); + nextFiber.tag = 2; + enqueueUpdate(getDerivedStateFromProps, nextFiber); + } + getDerivedStateFromProps.expirationTime < + renderExpirationTime && + (getDerivedStateFromProps.expirationTime = renderExpirationTime); + nextFiber = getDerivedStateFromProps.alternate; + null !== nextFiber && + nextFiber.expirationTime < renderExpirationTime && + (nextFiber.expirationTime = renderExpirationTime); + for ( + var node = getDerivedStateFromProps.return; + null !== node; + + ) { + nextFiber = node.alternate; + if (node.childExpirationTime < renderExpirationTime) (node.childExpirationTime = renderExpirationTime), - null !== child && - (0 === child.childExpirationTime || - child.childExpirationTime > - renderExpirationTime) && - (child.childExpirationTime = renderExpirationTime); + null !== nextFiber && + nextFiber.childExpirationTime < + renderExpirationTime && + (nextFiber.childExpirationTime = renderExpirationTime); else if ( - null !== child && - (0 === child.childExpirationTime || - child.childExpirationTime > renderExpirationTime) + null !== nextFiber && + nextFiber.childExpirationTime < renderExpirationTime ) - child.childExpirationTime = renderExpirationTime; + nextFiber.childExpirationTime = renderExpirationTime; else break; node = node.return; } } - child = resolvedTag.child; - resolvedProps = resolvedProps.next; - } while (null !== resolvedProps); + nextFiber = getDerivedStateFromProps.child; + oldValue = oldValue.next; + } while (null !== oldValue); } else - child = - 12 === resolvedTag.tag - ? resolvedTag.type === workInProgress.type + nextFiber = + 10 === getDerivedStateFromProps.tag + ? getDerivedStateFromProps.type === workInProgress.type ? null - : resolvedTag.child - : resolvedTag.child; - if (null !== child) child.return = resolvedTag; + : getDerivedStateFromProps.child + : getDerivedStateFromProps.child; + if (null !== nextFiber) + nextFiber.return = getDerivedStateFromProps; else - for (child = resolvedTag; null !== child; ) { - if (child === workInProgress) { - child = null; + for ( + nextFiber = getDerivedStateFromProps; + null !== nextFiber; + + ) { + if (nextFiber === workInProgress) { + nextFiber = null; break; } - resolvedTag = child.sibling; - if (null !== resolvedTag) { - resolvedTag.return = child.return; - child = resolvedTag; + getDerivedStateFromProps = nextFiber.sibling; + if (null !== getDerivedStateFromProps) { + getDerivedStateFromProps.return = nextFiber.return; + nextFiber = getDerivedStateFromProps; break; } - child = child.return; + nextFiber = nextFiber.return; } - resolvedTag = child; + getDerivedStateFromProps = nextFiber; } + } reconcileChildren( current$$1, workInProgress, - props.children, + context.children, renderExpirationTime ); workInProgress = workInProgress.child; } return workInProgress; - case 11: + case 9: return ( - (updateExpirationTime = workInProgress.type), - (Component = workInProgress.pendingProps), - (props = Component.children), + (context = workInProgress.type), + (hasContext = workInProgress.pendingProps), + (updateExpirationTime = hasContext.children), prepareToReadContext(workInProgress, renderExpirationTime), - (updateExpirationTime = readContext( - updateExpirationTime, - Component.unstable_observedBits - )), - (props = props(updateExpirationTime)), + (context = readContext(context, hasContext.unstable_observedBits)), + (updateExpirationTime = updateExpirationTime(context)), (workInProgress.effectTag |= 1), reconcileChildren( current$$1, workInProgress, - props, + updateExpirationTime, renderExpirationTime ), - (workInProgress.memoizedProps = Component), workInProgress.child ); - case 17: - return updatePureComponent( + case 14: + return ( + (context = workInProgress.type), + (hasContext = resolveDefaultProps( + context.type, + workInProgress.pendingProps + )), + updateMemoComponent( + current$$1, + workInProgress, + context, + hasContext, + updateExpirationTime, + renderExpirationTime + ) + ); + case 15: + return updateSimpleMemoComponent( current$$1, workInProgress, workInProgress.type, @@ -4305,20 +4434,43 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { updateExpirationTime, renderExpirationTime ); - case 18: + case 17: return ( - (props = workInProgress.type._reactResult), - (Component = workInProgress.pendingProps), - (current$$1 = updatePureComponent( - current$$1, + (updateExpirationTime = workInProgress.type), + (context = workInProgress.pendingProps), + (context = + workInProgress.elementType === updateExpirationTime + ? context + : resolveDefaultProps(updateExpirationTime, context)), + 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), + constructClassInstance( workInProgress, - props, - resolveDefaultProps(props, Component), updateExpirationTime, + context, renderExpirationTime - )), - (workInProgress.memoizedProps = Component), - current$$1 + ), + mountClassInstance( + workInProgress, + updateExpirationTime, + context, + renderExpirationTime + ), + finishClassComponent( + null, + workInProgress, + updateExpirationTime, + !0, + current$$1, + renderExpirationTime + ) ); default: invariant( @@ -4327,9 +4479,27 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { ); } } -var updateHostContainer = void 0, +var appendAllChildren = void 0, + updateHostContainer = void 0, updateHostComponent$1 = void 0, updateHostText$1 = void 0; +appendAllChildren = function(parent, workInProgress) { + for (var node = workInProgress.child; null !== node; ) { + if (5 === node.tag || 6 === node.tag) parent._children.push(node.stateNode); + else if (4 !== node.tag && null !== node.child) { + node.child.return = node; + node = node.child; + continue; + } + if (node === workInProgress) break; + for (; null === node.sibling; ) { + if (null === node.return || node.return === workInProgress) return; + node = node.return; + } + node.sibling.return = node.return; + node = node.sibling; + } +}; updateHostContainer = function() {}; updateHostComponent$1 = function(current, workInProgress, type, newProps) { current.memoizedProps !== newProps && @@ -4359,7 +4529,6 @@ function logCapturedError(capturedError) { : Error("Unspecified error at:" + componentStack); ExceptionsManager.handleException(error, !1); } -var emptyObject$1 = {}; function logError(boundary, errorInfo) { var source = errorInfo.source, stack = errorInfo.stack; @@ -4376,7 +4545,7 @@ function logError(boundary, errorInfo) { willRetry: !1 }; null !== boundary && - 2 === boundary.tag && + 1 === boundary.tag && ((errorInfo.errorBoundary = boundary.stateNode), (errorInfo.errorBoundaryName = getComponentName(boundary.type)), (errorInfo.errorBoundaryFound = !0), @@ -4400,32 +4569,55 @@ function safelyDetachRef(current$$1) { } else ref.current = null; } -function commitUnmount(current$$1) { +function commitUnmount(current$$1$jscomp$0) { "function" === typeof onCommitFiberUnmount && - onCommitFiberUnmount(current$$1); - switch (current$$1.tag) { - case 2: - case 3: - safelyDetachRef(current$$1); - var instance = current$$1.stateNode; - if ("function" === typeof instance.componentWillUnmount) + onCommitFiberUnmount(current$$1$jscomp$0); + switch (current$$1$jscomp$0.tag) { + case 0: + case 11: + case 14: + case 15: + var updateQueue = current$$1$jscomp$0.updateQueue; + if ( + null !== updateQueue && + ((updateQueue = updateQueue.lastEffect), null !== updateQueue) + ) { + var effect = (updateQueue = updateQueue.next); + do { + var destroy = effect.destroy; + if (null !== destroy) { + var current$$1 = current$$1$jscomp$0; + try { + destroy(); + } catch (error) { + captureCommitPhaseError(current$$1, error); + } + } + effect = effect.next; + } while (effect !== updateQueue); + } + break; + case 1: + safelyDetachRef(current$$1$jscomp$0); + updateQueue = current$$1$jscomp$0.stateNode; + if ("function" === typeof updateQueue.componentWillUnmount) try { - (instance.props = current$$1.memoizedProps), - (instance.state = current$$1.memoizedState), - instance.componentWillUnmount(); + (updateQueue.props = current$$1$jscomp$0.memoizedProps), + (updateQueue.state = current$$1$jscomp$0.memoizedState), + updateQueue.componentWillUnmount(); } catch (unmountError) { - captureCommitPhaseError(current$$1, unmountError); + captureCommitPhaseError(current$$1$jscomp$0, unmountError); } break; - case 7: - safelyDetachRef(current$$1); + case 5: + safelyDetachRef(current$$1$jscomp$0); break; - case 6: - unmountHostComponents(current$$1); + case 4: + unmountHostComponents(current$$1$jscomp$0); } } function isHostParent(fiber) { - return 7 === fiber.tag || 5 === fiber.tag || 6 === fiber.tag; + return 5 === fiber.tag || 3 === fiber.tag || 4 === fiber.tag; } function commitPlacement(finishedWork) { a: { @@ -4444,15 +4636,15 @@ function commitPlacement(finishedWork) { } var isContainer = (parent = void 0); switch (parentFiber.tag) { - case 7: + case 5: parent = parentFiber.stateNode; isContainer = !1; break; - case 5: + case 3: parent = parentFiber.stateNode.containerInfo; isContainer = !0; break; - case 6: + case 4: parent = parentFiber.stateNode.containerInfo; isContainer = !0; break; @@ -4474,11 +4666,11 @@ function commitPlacement(finishedWork) { parentFiber.sibling.return = parentFiber.return; for ( parentFiber = parentFiber.sibling; - 7 !== parentFiber.tag && 8 !== parentFiber.tag; + 5 !== parentFiber.tag && 6 !== parentFiber.tag; ) { if (parentFiber.effectTag & 2) continue b; - if (null === parentFiber.child || 6 === parentFiber.tag) continue b; + if (null === parentFiber.child || 4 === parentFiber.tag) continue b; else (parentFiber.child.return = parentFiber), (parentFiber = parentFiber.child); @@ -4489,7 +4681,7 @@ function commitPlacement(finishedWork) { } } for (var node = finishedWork; ; ) { - if (7 === node.tag || 8 === node.tag) + if (5 === node.tag || 6 === node.tag) if (parentFiber) if (isContainer) invariant( @@ -4558,7 +4750,7 @@ function commitPlacement(finishedWork) { [index.length - 1], [] ))); - else if (6 !== node.tag && null !== node.child) { + else if (4 !== node.tag && null !== node.child) { node.child.return = node; node = node.child; continue; @@ -4589,15 +4781,15 @@ function unmountHostComponents(current$$1) { "Expected to find a host parent. This error is likely caused by a bug in React. Please file an issue." ); switch (currentParentIsValid.tag) { - case 7: + case 5: currentParent = currentParentIsValid.stateNode; currentParentIsContainer = !1; break a; - case 5: + case 3: currentParent = currentParentIsValid.stateNode.containerInfo; currentParentIsContainer = !0; break a; - case 6: + case 4: currentParent = currentParentIsValid.stateNode.containerInfo; currentParentIsContainer = !0; break a; @@ -4606,11 +4798,11 @@ function unmountHostComponents(current$$1) { } currentParentIsValid = !0; } - if (7 === node.tag || 8 === node.tag) { + if (5 === node.tag || 6 === node.tag) { a: for (var root = node, node$jscomp$0 = root; ; ) if ( (commitUnmount(node$jscomp$0), - null !== node$jscomp$0.child && 6 !== node$jscomp$0.tag) + null !== node$jscomp$0.child && 4 !== node$jscomp$0.tag) ) (node$jscomp$0.child.return = node$jscomp$0), (node$jscomp$0 = node$jscomp$0.child); @@ -4638,7 +4830,7 @@ function unmountHostComponents(current$$1) { UIManager.manageChildren(root._nativeTag, [], [], [], [], [child]); } } else if ( - (6 === node.tag + (4 === node.tag ? ((currentParent = node.stateNode.containerInfo), (currentParentIsContainer = !0)) : commitUnmount(node), @@ -4652,7 +4844,7 @@ function unmountHostComponents(current$$1) { for (; null === node.sibling; ) { if (null === node.return || node.return === current$$1) return; node = node.return; - 6 === node.tag && (currentParentIsValid = !1); + 4 === node.tag && (currentParentIsValid = !1); } node.sibling.return = node.return; node = node.sibling; @@ -4660,10 +4852,14 @@ function unmountHostComponents(current$$1) { } function commitWork(current$$1, finishedWork) { switch (finishedWork.tag) { - case 2: - case 3: + case 0: + case 11: + case 14: + case 15: break; - case 7: + case 1: + break; + case 5: var instance = finishedWork.stateNode; if (null != instance) { var newProps = finishedWork.memoizedProps; @@ -4687,7 +4883,7 @@ function commitWork(current$$1, finishedWork) { )); } break; - case 8: + case 6: invariant( null !== finishedWork.stateNode, "This should have a text node initialized. This error is likely caused by a bug in React. Please file an issue." @@ -4696,11 +4892,73 @@ function commitWork(current$$1, finishedWork) { text: finishedWork.memoizedProps }); break; - case 5: + case 3: break; - case 15: + case 12: + break; + case 13: + newProps = finishedWork.memoizedState; + current$$1 = finishedWork; + null === newProps + ? (instance = !1) + : ((instance = !0), + (current$$1 = finishedWork.child), + 0 === newProps.timedOutAt && + (newProps.timedOutAt = requestCurrentTime())); + if (null !== current$$1) + a: for (newProps = finishedWork = current$$1; ; ) { + if (5 === newProps.tag) + if (((current$$1 = newProps.stateNode), instance)) { + updatePayload = current$$1.viewConfig; + var updatePayload$jscomp$0 = diffProperties( + null, + emptyObject, + { style: { display: "none" } }, + updatePayload.validAttributes + ); + UIManager.updateView( + current$$1._nativeTag, + updatePayload.uiViewClassName, + updatePayload$jscomp$0 + ); + } else { + current$$1 = newProps.stateNode; + updatePayload$jscomp$0 = newProps.memoizedProps; + updatePayload = current$$1.viewConfig; + var prevProps = Object.assign({}, updatePayload$jscomp$0, { + style: [updatePayload$jscomp$0.style, { display: "none" }] + }); + updatePayload$jscomp$0 = diffProperties( + null, + prevProps, + updatePayload$jscomp$0, + updatePayload.validAttributes + ); + UIManager.updateView( + current$$1._nativeTag, + updatePayload.uiViewClassName, + updatePayload$jscomp$0 + ); + } + else { + if (6 === newProps.tag) throw Error("Not yet implemented."); + if (null !== newProps.child) { + newProps.child.return = newProps; + newProps = newProps.child; + continue; + } + } + if (newProps === finishedWork) break a; + for (; null === newProps.sibling; ) { + if (null === newProps.return || newProps.return === finishedWork) + break a; + newProps = newProps.return; + } + newProps.sibling.return = newProps.return; + newProps = newProps.sibling; + } break; - case 16: + case 17: break; default: invariant( @@ -4709,9 +4967,6 @@ function commitWork(current$$1, finishedWork) { ); } } -function NoopComponent() { - return null; -} function createRootErrorUpdate(fiber, errorInfo, expirationTime) { expirationTime = createUpdate(expirationTime); expirationTime.tag = 3; @@ -4752,24 +5007,14 @@ function createClassErrorUpdate(fiber, errorInfo, expirationTime) { } function unwindWork(workInProgress) { switch (workInProgress.tag) { - case 2: + case 1: isContextProvider(workInProgress.type) && popContext(workInProgress); var effectTag = workInProgress.effectTag; - return effectTag & 1024 - ? ((workInProgress.effectTag = (effectTag & -1025) | 64), + return effectTag & 2048 + ? ((workInProgress.effectTag = (effectTag & -2049) | 64), workInProgress) : null; case 3: - return ( - isContextProvider(workInProgress.type._reactResult) && - popContext(workInProgress), - (effectTag = workInProgress.effectTag), - effectTag & 1024 - ? ((workInProgress.effectTag = (effectTag & -1025) | 64), - workInProgress) - : null - ); - case 5: return ( popHostContainer(workInProgress), popTopLevelContextObject(workInProgress), @@ -4778,28 +5023,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 & -1025) | 64), + (workInProgress.effectTag = (effectTag & -2049) | 64), workInProgress ); - case 7: + case 5: return popHostContext(workInProgress), null; - case 16: + case 13: return ( (effectTag = workInProgress.effectTag), - effectTag & 1024 - ? ((workInProgress.effectTag = (effectTag & -1025) | 64), + effectTag & 2048 + ? ((workInProgress.effectTag = (effectTag & -2049) | 64), workInProgress) : null ); - case 6: + case 4: return popHostContainer(workInProgress), null; - case 12: + case 10: return popProvider(workInProgress), null; default: return null; } } -var Dispatcher = { readContext: readContext }, +var DispatcherWithoutHooks = { readContext: readContext }, ReactCurrentOwner$2 = ReactSharedInternals.ReactCurrentOwner, isWorking = !1, nextUnitOfWork = null, @@ -4809,6 +5054,8 @@ var Dispatcher = { readContext: readContext }, nextRenderDidError = !1, nextEffect = null, isCommitting$1 = !1, + passiveEffectCallbackHandle = null, + passiveEffectCallback = null, legacyErrorBoundariesThatAlreadyFailed = null; function resetStack() { if (null !== nextUnitOfWork) @@ -4819,7 +5066,7 @@ function resetStack() { ) { var interruptedWork$jscomp$0 = interruptedWork; switch (interruptedWork$jscomp$0.tag) { - case 2: + case 1: var childContextTypes = interruptedWork$jscomp$0.type.childContextTypes; null !== childContextTypes && @@ -4827,23 +5074,16 @@ function resetStack() { popContext(interruptedWork$jscomp$0); break; case 3: - childContextTypes = - interruptedWork$jscomp$0.type._reactResult.childContextTypes; - null !== childContextTypes && - void 0 !== childContextTypes && - popContext(interruptedWork$jscomp$0); - break; - case 5: popHostContainer(interruptedWork$jscomp$0); popTopLevelContextObject(interruptedWork$jscomp$0); break; - case 7: + case 5: popHostContext(interruptedWork$jscomp$0); break; - case 6: + case 4: popHostContainer(interruptedWork$jscomp$0); break; - case 12: + case 10: popProvider(interruptedWork$jscomp$0); } interruptedWork = interruptedWork.return; @@ -4854,205 +5094,204 @@ function resetStack() { nextRenderDidError = !1; nextUnitOfWork = null; } +function flushPassiveEffects() { + null !== passiveEffectCallback && + (scheduler.unstable_cancelCallback(passiveEffectCallbackHandle), + passiveEffectCallback()); +} function completeUnitOfWork(workInProgress) { for (;;) { var current$$1 = workInProgress.alternate, returnFiber = workInProgress.return, siblingFiber = workInProgress.sibling; - if (0 === (workInProgress.effectTag & 512)) { - var current = current$$1; - current$$1 = workInProgress; - var newProps = current$$1.pendingProps; - switch (current$$1.tag) { - case 0: - 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; - newProps.pendingContext && - ((newProps.context = newProps.pendingContext), - (newProps.pendingContext = null)); - if (null === current || null === current.child) - current$$1.effectTag &= -3; - updateHostContainer(current$$1); - break; - case 7: - popHostContext(current$$1); - var rootContainerInstance = requiredContext( + if (0 === (workInProgress.effectTag & 1024)) { + nextUnitOfWork = workInProgress; + a: { + var current = current$$1; + current$$1 = workInProgress; + var renderExpirationTime = nextRenderExpirationTime, + newProps = current$$1.pendingProps; + switch (current$$1.tag) { + case 2: + break; + case 16: + break; + case 15: + case 0: + break; + case 1: + isContextProvider(current$$1.type) && popContext(current$$1); + break; + case 3: + popHostContainer(current$$1); + popTopLevelContextObject(current$$1); + newProps = current$$1.stateNode; + newProps.pendingContext && + ((newProps.context = newProps.pendingContext), + (newProps.pendingContext = null)); + if (null === current || null === current.child) + current$$1.effectTag &= -3; + updateHostContainer(current$$1); + break; + case 5: + popHostContext(current$$1); + renderExpirationTime = requiredContext( rootInstanceStackCursor.current - ), - type = current$$1.type; - if (null !== current && null != current$$1.stateNode) - updateHostComponent$1( - current, - current$$1, - type, - newProps, - rootContainerInstance - ), - current.ref !== current$$1.ref && (current$$1.effectTag |= 128); - else if (newProps) { - current = requiredContext(contextStackCursor$1.current); - var internalInstanceHandle = current$$1, - tag = allocateTag(), - viewConfig = ReactNativeViewConfigRegistry.get(type); - invariant( - "RCTView" !== type || !current.isInAParentText, - "Nesting of within is not currently supported." - ); - var updatePayload = diffProperties( - null, - emptyObject, - newProps, - viewConfig.validAttributes - ); - UIManager.createView( - tag, - viewConfig.uiViewClassName, - rootContainerInstance, - updatePayload - ); - viewConfig = new ReactNativeFiberHostComponent(tag, viewConfig); - instanceCache[tag] = internalInstanceHandle; - instanceProps[tag] = newProps; - a: for ( - internalInstanceHandle = viewConfig, - tag = current$$1, - updatePayload = tag.child; - null !== updatePayload; - - ) { - if (7 === updatePayload.tag || 8 === updatePayload.tag) - internalInstanceHandle._children.push(updatePayload.stateNode); - else if ( - 6 !== updatePayload.tag && - null !== updatePayload.child - ) { - updatePayload.child.return = updatePayload; - updatePayload = updatePayload.child; - continue; - } - if (updatePayload === tag) break; - for (; null === updatePayload.sibling; ) { - if ( - null === updatePayload.return || - updatePayload.return === tag - ) - break a; - updatePayload = updatePayload.return; - } - updatePayload.sibling.return = updatePayload.return; - updatePayload = updatePayload.sibling; - } - finalizeInitialChildren( - viewConfig, - type, - newProps, - rootContainerInstance, - current - ) && (current$$1.effectTag |= 4); - current$$1.stateNode = viewConfig; - null !== current$$1.ref && (current$$1.effectTag |= 128); - } else - invariant( - null !== current$$1.stateNode, - "We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue." ); - break; - case 8: - current && null != current$$1.stateNode - ? updateHostText$1( + var type = current$$1.type; + if (null !== current && null != current$$1.stateNode) + updateHostComponent$1( current, current$$1, - current.memoizedProps, - newProps - ) - : ("string" !== typeof newProps && + type, + newProps, + renderExpirationTime + ), + current.ref !== current$$1.ref && (current$$1.effectTag |= 128); + else if (newProps) { + current = requiredContext(contextStackCursor$1.current); + var internalInstanceHandle = current$$1, + tag = allocateTag(), + viewConfig = ReactNativeViewConfigRegistry.get(type); + invariant( + "RCTView" !== type || !current.isInAParentText, + "Nesting of within is not currently supported." + ); + var updatePayload = diffProperties( + null, + emptyObject, + newProps, + viewConfig.validAttributes + ); + UIManager.createView( + tag, + viewConfig.uiViewClassName, + renderExpirationTime, + updatePayload + ); + viewConfig = new ReactNativeFiberHostComponent(tag, viewConfig); + instanceCache[tag] = internalInstanceHandle; + instanceProps[tag] = newProps; + appendAllChildren(viewConfig, current$$1, !1, !1); + finalizeInitialChildren( + viewConfig, + type, + newProps, + renderExpirationTime, + current + ) && (current$$1.effectTag |= 4); + current$$1.stateNode = viewConfig; + null !== current$$1.ref && (current$$1.effectTag |= 128); + } else + invariant( + null !== current$$1.stateNode, + "We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue." + ); + break; + case 6: + current && null != current$$1.stateNode + ? updateHostText$1( + current, + current$$1, + current.memoizedProps, + newProps + ) + : ("string" !== typeof newProps && + invariant( + null !== current$$1.stateNode, + "We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue." + ), + (current = requiredContext(rootInstanceStackCursor.current)), + (type = requiredContext(contextStackCursor$1.current)), + (renderExpirationTime = current$$1), invariant( - null !== current$$1.stateNode, - "We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue." + type.isInAParentText, + "Text strings must be rendered within a component." ), - (current = requiredContext(rootInstanceStackCursor.current)), - (type = requiredContext(contextStackCursor$1.current)), - (rootContainerInstance = current$$1), - invariant( - type.isInAParentText, - "Text strings must be rendered within a component." - ), - (type = allocateTag()), - UIManager.createView(type, "RCTRawText", current, { - text: newProps - }), - (instanceCache[type] = current$$1), - (rootContainerInstance.stateNode = type)); - break; - case 13: - case 14: - break; - case 16: - break; - case 9: - break; - 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: - 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, - "Unknown unit of work tag. This error is likely caused by a bug in React. Please file an issue." - ); + (type = allocateTag()), + UIManager.createView(type, "RCTRawText", current, { + text: newProps + }), + (instanceCache[type] = current$$1), + (renderExpirationTime.stateNode = type)); + break; + case 11: + break; + case 13: + newProps = current$$1.memoizedState; + if (0 !== (current$$1.effectTag & 64)) { + current$$1.expirationTime = renderExpirationTime; + nextUnitOfWork = current$$1; + break a; + } + newProps = null !== newProps; + type = null !== current && null !== current.memoizedState; + null !== current && + !newProps && + type && + ((current = current.child.sibling), + null !== current && + reconcileChildFibers( + current$$1, + current, + null, + renderExpirationTime + )); + if ( + newProps !== type || + (0 === (current$$1.effectTag & 1) && newProps) + ) + current$$1.effectTag |= 4; + break; + case 7: + break; + case 8: + break; + case 12: + break; + case 4: + popHostContainer(current$$1); + updateHostContainer(current$$1); + break; + case 10: + popProvider(current$$1); + break; + case 9: + break; + case 14: + break; + case 17: + isContextProvider(current$$1.type) && popContext(current$$1); + break; + default: + invariant( + !1, + "Unknown unit of work tag. This error is likely caused by a bug in React. Please file an issue." + ); + } + nextUnitOfWork = null; } - nextUnitOfWork = null; current$$1 = workInProgress; if ( - 1073741823 === nextRenderExpirationTime || - 1073741823 !== current$$1.childExpirationTime + 1 === nextRenderExpirationTime || + 1 !== current$$1.childExpirationTime ) { newProps = 0; for ( - rootContainerInstance = current$$1.child; - null !== rootContainerInstance; + renderExpirationTime = current$$1.child; + null !== renderExpirationTime; - ) { - type = rootContainerInstance.expirationTime; - current = rootContainerInstance.childExpirationTime; - if (0 === newProps || (0 !== type && type < newProps)) - newProps = type; - if (0 === newProps || (0 !== current && current < newProps)) - newProps = current; - rootContainerInstance = rootContainerInstance.sibling; - } + ) + (type = renderExpirationTime.expirationTime), + (current = renderExpirationTime.childExpirationTime), + type > newProps && (newProps = type), + current > newProps && (newProps = current), + (renderExpirationTime = renderExpirationTime.sibling); current$$1.childExpirationTime = newProps; } + if (null !== nextUnitOfWork) return nextUnitOfWork; null !== returnFiber && - 0 === (returnFiber.effectTag & 512) && + 0 === (returnFiber.effectTag & 1024) && (null === returnFiber.firstEffect && (returnFiber.firstEffect = workInProgress.firstEffect), null !== workInProgress.lastEffect && @@ -5067,10 +5306,10 @@ function completeUnitOfWork(workInProgress) { } else { workInProgress = unwindWork(workInProgress, nextRenderExpirationTime); if (null !== workInProgress) - return (workInProgress.effectTag &= 511), workInProgress; + return (workInProgress.effectTag &= 1023), workInProgress; null !== returnFiber && ((returnFiber.firstEffect = returnFiber.lastEffect = null), - (returnFiber.effectTag |= 512)); + (returnFiber.effectTag |= 1024)); } if (null !== siblingFiber) return siblingFiber; if (null !== returnFiber) workInProgress = returnFiber; @@ -5084,17 +5323,19 @@ function performUnitOfWork(workInProgress) { workInProgress, nextRenderExpirationTime ); + workInProgress.memoizedProps = workInProgress.pendingProps; null === next && (next = completeUnitOfWork(workInProgress)); ReactCurrentOwner$2.current = null; return next; } -function renderRoot(root$jscomp$0, isYieldy, isExpired) { +function renderRoot(root$jscomp$0, isYieldy) { invariant( !isWorking, "renderRoot was called recursively. This error is likely caused by a bug in React. Please file an issue." ); + flushPassiveEffects(); isWorking = !0; - ReactCurrentOwner$2.currentDispatcher = Dispatcher; + ReactCurrentOwner$2.currentDispatcher = DispatcherWithoutHooks; var expirationTime = root$jscomp$0.nextExpirationTimeToWorkOn; if ( expirationTime !== nextRenderExpirationTime || @@ -5114,13 +5355,16 @@ function renderRoot(root$jscomp$0, isYieldy, isExpired) { do { try { if (isYieldy) - for (; null !== nextUnitOfWork && !shouldYield(); ) + for (; null !== nextUnitOfWork && !shouldYieldToRenderer(); ) nextUnitOfWork = performUnitOfWork(nextUnitOfWork); else for (; null !== nextUnitOfWork; ) nextUnitOfWork = performUnitOfWork(nextUnitOfWork); } catch (thrownValue) { - if (null === nextUnitOfWork) + if ( + ((lastContextWithAllBitsObserved = lastContextDependency = currentlyRenderingFiber = null), + null === nextUnitOfWork) + ) (didFatal = !0), onUncaughtError(thrownValue); else { invariant( @@ -5137,7 +5381,7 @@ function renderRoot(root$jscomp$0, isYieldy, isExpired) { sourceFiber$jscomp$0 = sourceFiber, value = thrownValue; returnFiber = nextRenderExpirationTime; - sourceFiber$jscomp$0.effectTag |= 512; + sourceFiber$jscomp$0.effectTag |= 1024; sourceFiber$jscomp$0.firstEffect = sourceFiber$jscomp$0.lastEffect = null; if ( null !== value && @@ -5149,56 +5393,57 @@ function renderRoot(root$jscomp$0, isYieldy, isExpired) { var earliestTimeoutMs = -1, startTimeMs = -1; do { - if (16 === value.tag) { - var current = value.alternate; + if (13 === value.tag) { + var current$$1 = value.alternate; if ( - null !== current && - !0 === current.memoizedState && - null !== current.stateNode + null !== current$$1 && + ((current$$1 = current$$1.memoizedState), + null !== current$$1) ) { - startTimeMs = 10 * (current.stateNode.timedOutAt - 2); + startTimeMs = 10 * (1073741822 - current$$1.timedOutAt); break; } - current = value.pendingProps.maxDuration; - if ("number" === typeof current) - if (0 >= current) earliestTimeoutMs = 0; + current$$1 = value.pendingProps.maxDuration; + if ("number" === typeof current$$1) + if (0 >= current$$1) earliestTimeoutMs = 0; else if ( -1 === earliestTimeoutMs || - current < earliestTimeoutMs + current$$1 < earliestTimeoutMs ) - earliestTimeoutMs = current; + earliestTimeoutMs = current$$1; } value = value.return; } while (null !== value); value = returnFiber$jscomp$0; do { - if (16 === value.tag && !value.memoizedState) { + if ((current$$1 = 13 === value.tag)) + current$$1 = + void 0 === value.memoizedProps.fallback + ? !1 + : null === value.memoizedState; + if (current$$1) { returnFiber$jscomp$0 = retrySuspendedRoot.bind( null, root, value, - 0 === (value.mode & 1) ? 1 : returnFiber + sourceFiber$jscomp$0, + 0 === (value.mode & 1) ? 1073741823 : returnFiber ); thenable.then(returnFiber$jscomp$0, returnFiber$jscomp$0); - if (0 === (value.mode & 2)) { - value.effectTag |= 4; + if (0 === (value.mode & 1)) { + value.effectTag |= 64; reconcileChildren( sourceFiber$jscomp$0.alternate, sourceFiber$jscomp$0, null, returnFiber ); - sourceFiber$jscomp$0.effectTag &= -513; - 4 === sourceFiber$jscomp$0.tag && - (sourceFiber$jscomp$0.tag = 0); - if ( - 2 === sourceFiber$jscomp$0.tag || - 3 === sourceFiber$jscomp$0.tag - ) - (sourceFiber$jscomp$0.effectTag &= -421), - null === sourceFiber$jscomp$0.alternate && - ((sourceFiber$jscomp$0.tag = 0), - (sourceFiber$jscomp$0.type = NoopComponent)); + sourceFiber$jscomp$0.effectTag &= -1025; + sourceFiber$jscomp$0.effectTag &= -933; + 1 === sourceFiber$jscomp$0.tag && + null === sourceFiber$jscomp$0.alternate && + (sourceFiber$jscomp$0.tag = 17); + sourceFiber$jscomp$0.expirationTime = returnFiber; break a; } -1 === earliestTimeoutMs @@ -5206,24 +5451,27 @@ function renderRoot(root$jscomp$0, isYieldy, isExpired) { : (-1 === startTimeMs && (startTimeMs = 10 * - (findEarliestOutstandingPriorityLevel( - root, - returnFiber - ) - - 2) - + (1073741822 - + findEarliestOutstandingPriorityLevel( + root, + returnFiber + )) - 5e3), (root = startTimeMs + earliestTimeoutMs)); 0 <= root && nextLatestAbsoluteTimeoutMs < root && (nextLatestAbsoluteTimeoutMs = root); - value.effectTag |= 1024; + value.effectTag |= 2048; value.expirationTime = returnFiber; break a; } value = value.return; } while (null !== value); value = Error( - "An update was suspended, but no placeholder UI was provided." + (getComponentName(sourceFiber$jscomp$0.type) || + "A React component") + + " suspended while rendering, but no fallback UI was specified.\n\nAdd a component higher in the tree to provide a loading indicator or placeholder to display." + + getStackByFiberInDevAndProd(sourceFiber$jscomp$0) ); } nextRenderDidError = !0; @@ -5231,9 +5479,9 @@ function renderRoot(root$jscomp$0, isYieldy, isExpired) { root = returnFiber$jscomp$0; do { switch (root.tag) { - case 5: + case 3: sourceFiber$jscomp$0 = value; - root.effectTag |= 1024; + root.effectTag |= 2048; root.expirationTime = returnFiber; returnFiber = createRootErrorUpdate( root, @@ -5242,8 +5490,7 @@ function renderRoot(root$jscomp$0, isYieldy, isExpired) { ); enqueueCapturedUpdate(root, returnFiber); break a; - case 2: - case 3: + case 1: if ( ((sourceFiber$jscomp$0 = value), (returnFiber$jscomp$0 = root.type), @@ -5258,7 +5505,7 @@ function renderRoot(root$jscomp$0, isYieldy, isExpired) { thenable ))))) ) { - root.effectTag |= 1024; + root.effectTag |= 2048; root.expirationTime = returnFiber; returnFiber = createClassErrorUpdate( root, @@ -5284,180 +5531,166 @@ function renderRoot(root$jscomp$0, isYieldy, isExpired) { if (didFatal) (nextRoot = null), (root$jscomp$0.finishedWork = null); else if (null !== nextUnitOfWork) root$jscomp$0.finishedWork = null; else { - isYieldy = root$jscomp$0.current.alternate; + didFatal = root$jscomp$0.current.alternate; invariant( - null !== isYieldy, + null !== didFatal, "Finished root should have a work-in-progress. This error is likely caused by a bug in React. Please file an issue." ); nextRoot = null; if (nextRenderDidError) { - didFatal = root$jscomp$0.latestPendingTime; - sourceFiber = root$jscomp$0.latestSuspendedTime; - returnFiber = root$jscomp$0.latestPingedTime; + sourceFiber = root$jscomp$0.latestPendingTime; + returnFiber = root$jscomp$0.latestSuspendedTime; + root = root$jscomp$0.latestPingedTime; if ( - (0 !== didFatal && didFatal > expirationTime) || - (0 !== sourceFiber && sourceFiber > expirationTime) || - (0 !== returnFiber && returnFiber > expirationTime) + (0 !== sourceFiber && sourceFiber < expirationTime) || + (0 !== returnFiber && returnFiber < expirationTime) || + (0 !== root && root < expirationTime) ) { markSuspendedPriorityLevel(root$jscomp$0, expirationTime); onSuspend( root$jscomp$0, - isYieldy, + didFatal, expirationTime, root$jscomp$0.expirationTime, -1 ); return; } - if (!root$jscomp$0.didError && !isExpired) { + if (!root$jscomp$0.didError && isYieldy) { root$jscomp$0.didError = !0; expirationTime = root$jscomp$0.nextExpirationTimeToWorkOn = expirationTime; - isExpired = root$jscomp$0.expirationTime = 1; - onSuspend(root$jscomp$0, isYieldy, expirationTime, isExpired, -1); + isYieldy = root$jscomp$0.expirationTime = 1073741823; + onSuspend(root$jscomp$0, didFatal, expirationTime, isYieldy, -1); return; } } - isExpired || -1 === nextLatestAbsoluteTimeoutMs - ? ((root$jscomp$0.pendingCommitExpirationTime = expirationTime), - (root$jscomp$0.finishedWork = isYieldy)) - : (markSuspendedPriorityLevel(root$jscomp$0, expirationTime), - (isExpired = + isYieldy && -1 !== nextLatestAbsoluteTimeoutMs + ? (markSuspendedPriorityLevel(root$jscomp$0, expirationTime), + (isYieldy = 10 * - (findEarliestOutstandingPriorityLevel(root$jscomp$0, expirationTime) - - 2)), - isExpired < nextLatestAbsoluteTimeoutMs && - (nextLatestAbsoluteTimeoutMs = isExpired), - (isExpired = 10 * (requestCurrentTime() - 2)), - (isExpired = nextLatestAbsoluteTimeoutMs - isExpired), + (1073741822 - + findEarliestOutstandingPriorityLevel( + root$jscomp$0, + expirationTime + ))), + isYieldy < nextLatestAbsoluteTimeoutMs && + (nextLatestAbsoluteTimeoutMs = isYieldy), + (isYieldy = 10 * (1073741822 - requestCurrentTime())), + (isYieldy = nextLatestAbsoluteTimeoutMs - isYieldy), onSuspend( root$jscomp$0, - isYieldy, + didFatal, expirationTime, root$jscomp$0.expirationTime, - 0 > isExpired ? 0 : isExpired - )); + 0 > isYieldy ? 0 : isYieldy + )) + : ((root$jscomp$0.pendingCommitExpirationTime = expirationTime), + (root$jscomp$0.finishedWork = didFatal)); } } -function captureCommitPhaseError(fiber, error) { - var JSCompiler_inline_result; - a: { - invariant( - !isWorking || isCommitting$1, - "dispatch: Cannot dispatch during the render phase." - ); - for ( - JSCompiler_inline_result = fiber.return; - null !== JSCompiler_inline_result; - - ) { - switch (JSCompiler_inline_result.tag) { - case 2: - case 3: - var instance = JSCompiler_inline_result.stateNode; - if ( - "function" === - typeof JSCompiler_inline_result.type.getDerivedStateFromError || - ("function" === typeof instance.componentDidCatch && - (null === legacyErrorBoundariesThatAlreadyFailed || - !legacyErrorBoundariesThatAlreadyFailed.has(instance))) - ) { - fiber = createCapturedValue(error, fiber); - fiber = createClassErrorUpdate(JSCompiler_inline_result, fiber, 1); - enqueueUpdate(JSCompiler_inline_result, fiber); - scheduleWork(JSCompiler_inline_result, 1); - JSCompiler_inline_result = void 0; - break a; - } - break; - case 5: - fiber = createCapturedValue(error, fiber); - fiber = createRootErrorUpdate(JSCompiler_inline_result, fiber, 1); - enqueueUpdate(JSCompiler_inline_result, fiber); - scheduleWork(JSCompiler_inline_result, 1); - JSCompiler_inline_result = void 0; - break a; - } - JSCompiler_inline_result = JSCompiler_inline_result.return; +function captureCommitPhaseError(sourceFiber, value) { + for (var fiber = sourceFiber.return; null !== fiber; ) { + switch (fiber.tag) { + case 1: + var instance = fiber.stateNode; + if ( + "function" === typeof fiber.type.getDerivedStateFromError || + ("function" === typeof instance.componentDidCatch && + (null === legacyErrorBoundariesThatAlreadyFailed || + !legacyErrorBoundariesThatAlreadyFailed.has(instance))) + ) { + sourceFiber = createCapturedValue(value, sourceFiber); + sourceFiber = createClassErrorUpdate(fiber, sourceFiber, 1073741823); + enqueueUpdate(fiber, sourceFiber); + scheduleWork(fiber, 1073741823); + return; + } + break; + case 3: + sourceFiber = createCapturedValue(value, sourceFiber); + sourceFiber = createRootErrorUpdate(fiber, sourceFiber, 1073741823); + enqueueUpdate(fiber, sourceFiber); + scheduleWork(fiber, 1073741823); + return; } - 5 === fiber.tag && - ((JSCompiler_inline_result = createCapturedValue(error, fiber)), - (JSCompiler_inline_result = createRootErrorUpdate( - fiber, - JSCompiler_inline_result, - 1 - )), - enqueueUpdate(fiber, JSCompiler_inline_result), - scheduleWork(fiber, 1)); - JSCompiler_inline_result = void 0; + fiber = fiber.return; } - return JSCompiler_inline_result; + 3 === sourceFiber.tag && + ((fiber = createCapturedValue(value, sourceFiber)), + (fiber = createRootErrorUpdate(sourceFiber, fiber, 1073741823)), + enqueueUpdate(sourceFiber, fiber), + scheduleWork(sourceFiber, 1073741823)); } function computeExpirationForFiber(currentTime, fiber) { isWorking - ? (currentTime = isCommitting$1 ? 1 : nextRenderExpirationTime) + ? (currentTime = isCommitting$1 ? 1073741823 : nextRenderExpirationTime) : fiber.mode & 1 ? ((currentTime = isBatchingInteractiveUpdates - ? 2 + 10 * ((((currentTime - 2 + 15) / 10) | 0) + 1) - : 2 + 25 * ((((currentTime - 2 + 500) / 25) | 0) + 1)), + ? 1073741822 - 10 * ((((1073741822 - currentTime + 15) / 10) | 0) + 1) + : 1073741822 - + 25 * ((((1073741822 - currentTime + 500) / 25) | 0) + 1)), null !== nextRoot && currentTime === nextRenderExpirationTime && - (currentTime += 1)) - : (currentTime = 1); + --currentTime) + : (currentTime = 1073741823); isBatchingInteractiveUpdates && - currentTime > lowestPriorityPendingInteractiveExpirationTime && + (0 === lowestPriorityPendingInteractiveExpirationTime || + currentTime < lowestPriorityPendingInteractiveExpirationTime) && (lowestPriorityPendingInteractiveExpirationTime = currentTime); return currentTime; } -function retrySuspendedRoot(root, fiber, suspendedTime) { +function retrySuspendedRoot(root, boundaryFiber, sourceFiber, suspendedTime) { var retryTime = root.earliestSuspendedTime; var latestSuspendedTime = root.latestSuspendedTime; if ( 0 !== retryTime && - suspendedTime >= retryTime && - suspendedTime <= latestSuspendedTime + suspendedTime <= retryTime && + suspendedTime >= latestSuspendedTime ) { latestSuspendedTime = retryTime = suspendedTime; root.didError = !1; var latestPingedTime = root.latestPingedTime; - if (0 === latestPingedTime || latestPingedTime < latestSuspendedTime) + if (0 === latestPingedTime || latestPingedTime > latestSuspendedTime) root.latestPingedTime = latestSuspendedTime; findNextExpirationTimeToWorkOn(latestSuspendedTime, root); } else (retryTime = requestCurrentTime()), - (retryTime = computeExpirationForFiber(retryTime, fiber)), + (retryTime = computeExpirationForFiber(retryTime, boundaryFiber)), markPendingPriorityLevel(root, retryTime); - 0 !== (fiber.mode & 1) && + 0 !== (boundaryFiber.mode & 1) && root === nextRoot && nextRenderExpirationTime === suspendedTime && (nextRoot = null); - scheduleWorkToRoot(fiber, retryTime); - fiber = root.expirationTime; - 0 !== fiber && requestWork(root, fiber); + scheduleWorkToRoot(boundaryFiber, retryTime); + 0 === (boundaryFiber.mode & 1) && + (scheduleWorkToRoot(sourceFiber, retryTime), + 1 === sourceFiber.tag && + null !== sourceFiber.stateNode && + ((boundaryFiber = createUpdate(retryTime)), + (boundaryFiber.tag = 2), + enqueueUpdate(sourceFiber, boundaryFiber))); + sourceFiber = root.expirationTime; + 0 !== sourceFiber && requestWork(root, sourceFiber); } function scheduleWorkToRoot(fiber, expirationTime) { - if (0 === fiber.expirationTime || fiber.expirationTime > expirationTime) - fiber.expirationTime = expirationTime; + fiber.expirationTime < expirationTime && + (fiber.expirationTime = expirationTime); var alternate = fiber.alternate; null !== alternate && - (0 === alternate.expirationTime || - alternate.expirationTime > expirationTime) && + alternate.expirationTime < expirationTime && (alternate.expirationTime = expirationTime); var node = fiber.return, root = null; - if (null === node && 5 === fiber.tag) root = fiber.stateNode; + if (null === node && 3 === fiber.tag) root = fiber.stateNode; else for (; null !== node; ) { alternate = node.alternate; - if ( - 0 === node.childExpirationTime || - node.childExpirationTime > expirationTime - ) - node.childExpirationTime = expirationTime; + node.childExpirationTime < expirationTime && + (node.childExpirationTime = expirationTime); null !== alternate && - (0 === alternate.childExpirationTime || - alternate.childExpirationTime > expirationTime) && + alternate.childExpirationTime < expirationTime && (alternate.childExpirationTime = expirationTime); - if (null === node.return && 5 === node.tag) { + if (null === node.return && 3 === node.tag) { root = node.stateNode; break; } @@ -5470,7 +5703,7 @@ function scheduleWork(fiber, expirationTime) { null !== fiber && (!isWorking && 0 !== nextRenderExpirationTime && - expirationTime < nextRenderExpirationTime && + expirationTime > nextRenderExpirationTime && resetStack(), markPendingPriorityLevel(fiber, expirationTime), (isWorking && !isCommitting$1 && nextRoot === fiber) || @@ -5490,27 +5723,25 @@ var firstScheduledRoot = null, nextFlushedRoot = null, nextFlushedExpirationTime = 0, lowestPriorityPendingInteractiveExpirationTime = 0, - deadlineDidExpire = !1, hasUnhandledError = !1, unhandledError = null, - deadline = null, isBatchingUpdates = !1, isUnbatchingUpdates = !1, isBatchingInteractiveUpdates = !1, completedBatches = null, originalStartTimeMs = now$1(), - currentRendererTime = ((originalStartTimeMs / 10) | 0) + 2, + currentRendererTime = 1073741822 - ((originalStartTimeMs / 10) | 0), currentSchedulerTime = currentRendererTime, NESTED_UPDATE_LIMIT = 50, nestedUpdateCount = 0, - lastCommittedRootDuringThisBatch = null, - timeHeuristicForUnitOfWork = 1; + lastCommittedRootDuringThisBatch = null; function recomputeCurrentRendererTime() { - currentRendererTime = (((now$1() - originalStartTimeMs) / 10) | 0) + 2; + currentRendererTime = + 1073741822 - (((now$1() - originalStartTimeMs) / 10) | 0); } function scheduleCallbackWithExpirationTime(root, expirationTime) { if (0 !== callbackExpirationTime) { - if (expirationTime > callbackExpirationTime) return; + if (expirationTime < callbackExpirationTime) return; null !== callbackID && ((root = callbackID), (scheduledCallback = null), clearTimeout(root)); } @@ -5527,7 +5758,7 @@ function onSuspend( msUntilTimeout ) { root.expirationTime = rootExpirationTime; - 0 !== msUntilTimeout || shouldYield() + 0 !== msUntilTimeout || shouldYieldToRenderer() ? 0 < msUntilTimeout && (root.timeoutHandle = scheduleTimeout( onTimeout.bind(null, root, finishedWork, suspendedExpirationTime), @@ -5547,44 +5778,35 @@ function onTimeout(root, finishedWork, suspendedExpirationTime) { ); nextFlushedRoot = root; nextFlushedExpirationTime = suspendedExpirationTime; - performWorkOnRoot(root, suspendedExpirationTime, !0); - performWork(1, null); + performWorkOnRoot(root, suspendedExpirationTime, !1); + performWork(1073741823, !1); } function requestCurrentTime() { if (isRendering) return currentSchedulerTime; findHighestPriorityRoot(); - if ( - 0 === nextFlushedExpirationTime || - 1073741823 === nextFlushedExpirationTime - ) + if (0 === nextFlushedExpirationTime || 1 === nextFlushedExpirationTime) recomputeCurrentRendererTime(), (currentSchedulerTime = currentRendererTime); return currentSchedulerTime; } function requestWork(root, expirationTime) { - if (null === root.nextScheduledRoot) - (root.expirationTime = expirationTime), + null === root.nextScheduledRoot + ? ((root.expirationTime = expirationTime), null === lastScheduledRoot ? ((firstScheduledRoot = lastScheduledRoot = root), (root.nextScheduledRoot = root)) : ((lastScheduledRoot = lastScheduledRoot.nextScheduledRoot = root), - (lastScheduledRoot.nextScheduledRoot = firstScheduledRoot)); - else { - var remainingExpirationTime = root.expirationTime; - if ( - 0 === remainingExpirationTime || - expirationTime < remainingExpirationTime - ) - root.expirationTime = expirationTime; - } + (lastScheduledRoot.nextScheduledRoot = firstScheduledRoot))) + : expirationTime > root.expirationTime && + (root.expirationTime = expirationTime); isRendering || (isBatchingUpdates ? isUnbatchingUpdates && ((nextFlushedRoot = root), - (nextFlushedExpirationTime = 1), - performWorkOnRoot(root, 1, !0)) - : 1 === expirationTime - ? performWork(1, null) + (nextFlushedExpirationTime = 1073741823), + performWorkOnRoot(root, 1073741823, !1)) + : 1073741823 === expirationTime + ? performWork(1073741823, !1) : scheduleCallbackWithExpirationTime(root, expirationTime)); } function findHighestPriorityRoot() { @@ -5620,14 +5842,11 @@ function findHighestPriorityRoot() { (root.nextScheduledRoot = null); root = previousScheduledRoot.nextScheduledRoot; } else { - if ( - 0 === highestPriorityWork || - remainingExpirationTime < highestPriorityWork - ) - (highestPriorityWork = remainingExpirationTime), - (highestPriorityRoot = root); + remainingExpirationTime > highestPriorityWork && + ((highestPriorityWork = remainingExpirationTime), + (highestPriorityRoot = root)); if (root === lastScheduledRoot) break; - if (1 === highestPriorityWork) break; + if (1073741823 === highestPriorityWork) break; previousScheduledRoot = root; root = root.nextScheduledRoot; } @@ -5635,38 +5854,44 @@ function findHighestPriorityRoot() { nextFlushedRoot = highestPriorityRoot; nextFlushedExpirationTime = highestPriorityWork; } -function performAsyncWork(dl) { - if (dl.didTimeout && null !== firstScheduledRoot) { - recomputeCurrentRendererTime(); - var root = firstScheduledRoot; - do { - var expirationTime = root.expirationTime; - 0 !== expirationTime && - currentRendererTime >= expirationTime && - (root.nextExpirationTimeToWorkOn = currentRendererTime); - root = root.nextScheduledRoot; - } while (root !== firstScheduledRoot); +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; } - performWork(0, dl); } -function performWork(minExpirationTime, dl) { - deadline = dl; +function performWork(minExpirationTime, isYieldy) { findHighestPriorityRoot(); - if (null !== deadline) + if (isYieldy) for ( recomputeCurrentRendererTime(), currentSchedulerTime = currentRendererTime; null !== nextFlushedRoot && 0 !== nextFlushedExpirationTime && - (0 === minExpirationTime || - minExpirationTime >= nextFlushedExpirationTime) && - (!deadlineDidExpire || currentRendererTime >= nextFlushedExpirationTime); + minExpirationTime <= nextFlushedExpirationTime && + !(didYield && currentRendererTime > nextFlushedExpirationTime); ) performWorkOnRoot( nextFlushedRoot, nextFlushedExpirationTime, - currentRendererTime >= nextFlushedExpirationTime + currentRendererTime > nextFlushedExpirationTime ), findHighestPriorityRoot(), recomputeCurrentRendererTime(), @@ -5676,29 +5901,28 @@ function performWork(minExpirationTime, dl) { ; null !== nextFlushedRoot && 0 !== nextFlushedExpirationTime && - (0 === minExpirationTime || - minExpirationTime >= nextFlushedExpirationTime); + minExpirationTime <= nextFlushedExpirationTime; ) - performWorkOnRoot(nextFlushedRoot, nextFlushedExpirationTime, !0), + performWorkOnRoot(nextFlushedRoot, nextFlushedExpirationTime, !1), findHighestPriorityRoot(); - null !== deadline && ((callbackExpirationTime = 0), (callbackID = null)); + isYieldy && ((callbackExpirationTime = 0), (callbackID = null)); 0 !== nextFlushedExpirationTime && scheduleCallbackWithExpirationTime( nextFlushedRoot, nextFlushedExpirationTime ); - deadline = null; - deadlineDidExpire = !1; nestedUpdateCount = 0; lastCommittedRootDuringThisBatch = null; if (null !== completedBatches) for ( - minExpirationTime = completedBatches, completedBatches = null, dl = 0; - dl < minExpirationTime.length; - dl++ + minExpirationTime = completedBatches, + completedBatches = null, + isYieldy = 0; + isYieldy < minExpirationTime.length; + isYieldy++ ) { - var batch = minExpirationTime[dl]; + var batch = minExpirationTime[isYieldy]; try { batch._onComplete(); } catch (error) { @@ -5712,45 +5936,45 @@ function performWork(minExpirationTime, dl) { (hasUnhandledError = !1), minExpirationTime); } -function performWorkOnRoot(root, expirationTime, isExpired) { +function performWorkOnRoot(root, expirationTime, isYieldy) { invariant( !isRendering, "performWorkOnRoot was called recursively. This error is likely caused by a bug in React. Please file an issue." ); isRendering = !0; - if (null === deadline || isExpired) { - var finishedWork = root.finishedWork; - null !== finishedWork - ? completeRoot(root, finishedWork, expirationTime) + if (isYieldy) { + var _finishedWork = root.finishedWork; + null !== _finishedWork + ? completeRoot(root, _finishedWork, expirationTime) : ((root.finishedWork = null), - (finishedWork = root.timeoutHandle), - -1 !== finishedWork && - ((root.timeoutHandle = -1), cancelTimeout(finishedWork)), - renderRoot(root, !1, isExpired), - (finishedWork = root.finishedWork), - null !== finishedWork && - completeRoot(root, finishedWork, expirationTime)); + (_finishedWork = root.timeoutHandle), + -1 !== _finishedWork && + ((root.timeoutHandle = -1), cancelTimeout(_finishedWork)), + renderRoot(root, isYieldy), + (_finishedWork = root.finishedWork), + null !== _finishedWork && + (shouldYieldToRenderer() + ? (root.finishedWork = _finishedWork) + : completeRoot(root, _finishedWork, expirationTime))); } else - (finishedWork = root.finishedWork), - null !== finishedWork - ? completeRoot(root, finishedWork, expirationTime) + (_finishedWork = root.finishedWork), + null !== _finishedWork + ? completeRoot(root, _finishedWork, expirationTime) : ((root.finishedWork = null), - (finishedWork = root.timeoutHandle), - -1 !== finishedWork && - ((root.timeoutHandle = -1), cancelTimeout(finishedWork)), - renderRoot(root, !0, isExpired), - (finishedWork = root.finishedWork), - null !== finishedWork && - (shouldYield() - ? (root.finishedWork = finishedWork) - : completeRoot(root, finishedWork, expirationTime))); + (_finishedWork = root.timeoutHandle), + -1 !== _finishedWork && + ((root.timeoutHandle = -1), cancelTimeout(_finishedWork)), + renderRoot(root, isYieldy), + (_finishedWork = root.finishedWork), + null !== _finishedWork && + completeRoot(root, _finishedWork, expirationTime)); isRendering = !1; } function completeRoot(root, finishedWork$jscomp$0, expirationTime) { var firstBatch = root.firstBatch; if ( null !== firstBatch && - firstBatch._expirationTime <= expirationTime && + firstBatch._expirationTime >= expirationTime && (null === completedBatches ? (completedBatches = [firstBatch]) : completedBatches.push(firstBatch), @@ -5779,9 +6003,7 @@ function completeRoot(root, finishedWork$jscomp$0, expirationTime) { var childExpirationTimeBeforeCommit = finishedWork$jscomp$0.childExpirationTime; firstBatch = - 0 === firstBatch || - (0 !== childExpirationTimeBeforeCommit && - childExpirationTimeBeforeCommit < firstBatch) + childExpirationTimeBeforeCommit > firstBatch ? childExpirationTimeBeforeCommit : firstBatch; root.didError = !1; @@ -5793,19 +6015,19 @@ function completeRoot(root, finishedWork$jscomp$0, expirationTime) { (root.latestPingedTime = 0)) : ((childExpirationTimeBeforeCommit = root.latestPendingTime), 0 !== childExpirationTimeBeforeCommit && - (childExpirationTimeBeforeCommit < firstBatch + (childExpirationTimeBeforeCommit > firstBatch ? (root.earliestPendingTime = root.latestPendingTime = 0) - : root.earliestPendingTime < firstBatch && + : root.earliestPendingTime > firstBatch && (root.earliestPendingTime = root.latestPendingTime)), (childExpirationTimeBeforeCommit = root.earliestSuspendedTime), 0 === childExpirationTimeBeforeCommit ? markPendingPriorityLevel(root, firstBatch) - : firstBatch > root.latestSuspendedTime + : firstBatch < root.latestSuspendedTime ? ((root.earliestSuspendedTime = 0), (root.latestSuspendedTime = 0), (root.latestPingedTime = 0), markPendingPriorityLevel(root, firstBatch)) - : firstBatch < childExpirationTimeBeforeCommit && + : firstBatch > childExpirationTimeBeforeCommit && markPendingPriorityLevel(root, firstBatch)); findNextExpirationTimeToWorkOn(0, root); ReactCurrentOwner$2.current = null; @@ -5820,30 +6042,34 @@ function completeRoot(root, finishedWork$jscomp$0, expirationTime) { var error = void 0; try { for (; null !== nextEffect; ) { - if (nextEffect.effectTag & 256) { - var current$$1 = nextEffect.alternate; + if (nextEffect.effectTag & 256) a: { - var finishedWork = nextEffect; + var current$$1 = nextEffect.alternate, + finishedWork = nextEffect; switch (finishedWork.tag) { - case 2: - case 3: + case 0: + case 11: + case 15: + break a; + case 1: if (finishedWork.effectTag & 256 && null !== current$$1) { var prevProps = current$$1.memoizedProps, prevState = current$$1.memoizedState, - instance = finishedWork.stateNode; - instance.props = finishedWork.memoizedProps; - instance.state = finishedWork.memoizedState; - var snapshot = instance.getSnapshotBeforeUpdate( - prevProps, - prevState - ); + instance = finishedWork.stateNode, + snapshot = instance.getSnapshotBeforeUpdate( + finishedWork.elementType === finishedWork.type + ? prevProps + : resolveDefaultProps(finishedWork.type, prevProps), + prevState + ); instance.__reactInternalSnapshotBeforeUpdate = snapshot; } break a; + case 3: case 5: - case 7: - case 8: case 6: + case 4: + case 17: break a; default: invariant( @@ -5852,7 +6078,6 @@ function completeRoot(root, finishedWork$jscomp$0, expirationTime) { ); } } - } nextEffect = nextEffect.nextEffect; } } catch (e) { @@ -5929,47 +6154,48 @@ function completeRoot(root, finishedWork$jscomp$0, expirationTime) { current$$1 = nextEffect; prevProps = currentRef; switch (current$$1.tag) { - case 2: - case 3: + case 0: + case 11: + case 15: + break; + case 1: var instance$jscomp$0 = current$$1.stateNode; if (current$$1.effectTag & 4) if (null === current$$1$jscomp$1) - (instance$jscomp$0.props = current$$1.memoizedProps), - (instance$jscomp$0.state = current$$1.memoizedState), - instance$jscomp$0.componentDidMount(); + instance$jscomp$0.componentDidMount(); else { - var prevProps$jscomp$0 = current$$1$jscomp$1.memoizedProps, - prevState$jscomp$0 = current$$1$jscomp$1.memoizedState; - instance$jscomp$0.props = current$$1.memoizedProps; - instance$jscomp$0.state = current$$1.memoizedState; + var prevProps$jscomp$0 = + current$$1.elementType === current$$1.type + ? current$$1$jscomp$1.memoizedProps + : resolveDefaultProps( + current$$1.type, + current$$1$jscomp$1.memoizedProps + ); instance$jscomp$0.componentDidUpdate( prevProps$jscomp$0, - prevState$jscomp$0, + current$$1$jscomp$1.memoizedState, instance$jscomp$0.__reactInternalSnapshotBeforeUpdate ); } var updateQueue = current$$1.updateQueue; null !== updateQueue && - ((instance$jscomp$0.props = current$$1.memoizedProps), - (instance$jscomp$0.state = current$$1.memoizedState), commitUpdateQueue( current$$1, updateQueue, instance$jscomp$0, prevProps - )); + ); break; - case 5: + case 3: var _updateQueue = current$$1.updateQueue; if (null !== _updateQueue) { prevState = null; if (null !== current$$1.child) switch (current$$1.child.tag) { - case 7: + case 5: prevState = current$$1.child.stateNode; break; - case 2: - case 3: + case 1: prevState = current$$1.child.stateNode; } commitUpdateQueue( @@ -5980,22 +6206,17 @@ function completeRoot(root, finishedWork$jscomp$0, expirationTime) { ); } break; - case 7: - break; - case 8: + case 5: break; case 6: break; - case 15: + case 4: break; - case 16: - if (0 === (current$$1.mode & 2)) - (current$$1.updateQueue = emptyObject$1), - scheduleWork(current$$1, 1); - else { - var currentTime = requestCurrentTime(); - current$$1.stateNode = { timedOutAt: currentTime }; - } + case 12: + break; + case 13: + break; + case 17: break; default: invariant( @@ -6009,7 +6230,7 @@ function completeRoot(root, finishedWork$jscomp$0, expirationTime) { if (null !== ref) { var instance$jscomp$1 = nextEffect.stateNode; switch (nextEffect.tag) { - case 7: + case 5: var instanceToUse = instance$jscomp$1; break; default: @@ -6020,9 +6241,7 @@ function completeRoot(root, finishedWork$jscomp$0, expirationTime) { : (ref.current = instanceToUse); } } - var next = nextEffect.nextEffect; - nextEffect.nextEffect = null; - nextEffect = next; + nextEffect = nextEffect.nextEffect; } } catch (e) { (effectTag = !0), (current$$1$jscomp$0 = e); @@ -6041,8 +6260,7 @@ function completeRoot(root, finishedWork$jscomp$0, expirationTime) { effectTag$jscomp$0 = finishedWork$jscomp$0.expirationTime; finishedWork$jscomp$0 = finishedWork$jscomp$0.childExpirationTime; finishedWork$jscomp$0 = - 0 === effectTag$jscomp$0 || - (0 !== finishedWork$jscomp$0 && finishedWork$jscomp$0 < effectTag$jscomp$0) + finishedWork$jscomp$0 > effectTag$jscomp$0 ? finishedWork$jscomp$0 : effectTag$jscomp$0; 0 === finishedWork$jscomp$0 && @@ -6050,13 +6268,6 @@ function completeRoot(root, finishedWork$jscomp$0, expirationTime) { root.expirationTime = finishedWork$jscomp$0; root.finishedWork = null; } -function shouldYield() { - return deadlineDidExpire - ? !0 - : null === deadline || deadline.timeRemaining() > timeHeuristicForUnitOfWork - ? !1 - : (deadlineDidExpire = !0); -} function onUncaughtError(error) { invariant( null !== nextFlushedRoot, @@ -6065,55 +6276,6 @@ function onUncaughtError(error) { nextFlushedRoot.expirationTime = 0; hasUnhandledError || ((hasUnhandledError = !0), (unhandledError = error)); } -function getContextForSubtree(parentComponent) { - if (!parentComponent) return emptyContextObject; - parentComponent = parentComponent._reactInternalFiber; - a: { - invariant( - 2 === isFiberMountedImpl(parentComponent) && - (2 === parentComponent.tag || 3 === parentComponent.tag), - "Expected subtree parent to be a mounted class component. This error is likely caused by a bug in React. Please file an issue." - ); - var parentContext = parentComponent; - do { - switch (parentContext.tag) { - case 5: - parentContext = parentContext.stateNode.context; - break a; - case 2: - if (isContextProvider(parentContext.type)) { - parentContext = - parentContext.stateNode.__reactInternalMemoizedMergedChildContext; - break a; - } - break; - case 3: - if (isContextProvider(parentContext.type._reactResult)) { - parentContext = - parentContext.stateNode.__reactInternalMemoizedMergedChildContext; - break a; - } - } - parentContext = parentContext.return; - } while (null !== parentContext); - invariant( - !1, - "Found unexpected detached subtree parent. This error is likely caused by a bug in React. Please file an issue." - ); - parentContext = void 0; - } - if (2 === parentComponent.tag) { - var Component = parentComponent.type; - if (isContextProvider(Component)) - return processChildContext(parentComponent, Component, parentContext); - } else if ( - 3 === parentComponent.tag && - ((Component = parentComponent.type._reactResult), - isContextProvider(Component)) - ) - return processChildContext(parentComponent, Component, parentContext); - return parentContext; -} function findHostInstance$1(component) { var fiber = component._reactInternalFiber; void 0 === fiber && @@ -6132,7 +6294,48 @@ function updateContainer(element, container, parentComponent, callback) { currentTime = requestCurrentTime(); current$$1 = computeExpirationForFiber(currentTime, current$$1); currentTime = container.current; - parentComponent = getContextForSubtree(parentComponent); + a: if (parentComponent) { + parentComponent = parentComponent._reactInternalFiber; + b: { + invariant( + 2 === isFiberMountedImpl(parentComponent) && 1 === parentComponent.tag, + "Expected subtree parent to be a mounted class component. This error is likely caused by a bug in React. Please file an issue." + ); + var parentContext = parentComponent; + do { + switch (parentContext.tag) { + case 3: + parentContext = parentContext.stateNode.context; + break b; + case 1: + if (isContextProvider(parentContext.type)) { + parentContext = + parentContext.stateNode + .__reactInternalMemoizedMergedChildContext; + break b; + } + } + parentContext = parentContext.return; + } while (null !== parentContext); + invariant( + !1, + "Found unexpected detached subtree parent. This error is likely caused by a bug in React. Please file an issue." + ); + parentContext = void 0; + } + if (1 === parentComponent.tag) { + var Component = parentComponent.type; + if (isContextProvider(Component)) { + parentComponent = processChildContext( + parentComponent, + Component, + parentContext + ); + break a; + } + } + parentComponent = parentContext; + } else parentComponent = emptyContextObject; null === container.context ? (container.context = parentComponent) : (container.pendingContext = parentComponent); @@ -6141,6 +6344,7 @@ function updateContainer(element, container, parentComponent, callback) { callback.payload = { element: element }; container = void 0 === container ? null : container; null !== container && (callback.callback = container); + flushPassiveEffects(); enqueueUpdate(currentTime, callback); scheduleWork(currentTime, current$$1); return current$$1; @@ -6200,13 +6404,13 @@ _batchedUpdatesImpl = function(fn, a) { } finally { (isBatchingUpdates = previousIsBatchingUpdates) || isRendering || - performWork(1, null); + performWork(1073741823, !1); } }; _flushInteractiveUpdatesImpl = function() { isRendering || 0 === lowestPriorityPendingInteractiveExpirationTime || - (performWork(lowestPriorityPendingInteractiveExpirationTime, null), + (performWork(lowestPriorityPendingInteractiveExpirationTime, !1), (lowestPriorityPendingInteractiveExpirationTime = 0)); }; var roots = new Map(), @@ -6286,7 +6490,7 @@ var roots = new Map(), render: function(element, containerTag, callback) { var root = roots.get(containerTag); if (!root) { - root = new FiberNode(5, null, null, 0); + root = createFiber(3, null, null, 0); var root$jscomp$0 = { current: root, containerInfo: containerTag, @@ -6314,7 +6518,7 @@ var roots = new Map(), updateContainer(element, root, null, callback); a: if (((element = root.current), element.child)) switch (element.child.tag) { - case 7: + case 5: element = element.child.stateNode; break a; default: @@ -6421,7 +6625,7 @@ var roots = new Map(), findFiberByHostInstance: getInstanceFromTag, getInspectorDataForViewTag: getInspectorDataForViewTag, bundleType: 0, - version: "16.6.0-alpha.8af6728", + version: "16.6.1", 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 3a9645d82e6bb4..7a8ebe32ee53c9 100644 --- a/Libraries/Renderer/oss/ReactNativeRenderer-profiling.js +++ b/Libraries/Renderer/oss/ReactNativeRenderer-profiling.js @@ -20,6 +20,7 @@ var ReactNativeViewConfigRegistry = require("ReactNativeViewConfigRegistry"), flattenStyle = require("flattenStyle"), TextInputState = require("TextInputState"), tracing = require("scheduler/tracing"), + scheduler = require("scheduler"), ExceptionsManager = require("ExceptionsManager"); function invariant(condition, format, a, b, c, d, e, f) { if (!condition) { @@ -167,10 +168,10 @@ var plugins = [], getFiberCurrentPropsFromNode = null, getInstanceFromNode = null, getNodeFromInstance = null; -function executeDispatch(event, simulated, listener, inst) { - simulated = event.type || "unknown-event"; +function executeDispatch(event, listener, inst) { + var type = event.type || "unknown-event"; event.currentTarget = getNodeFromInstance(inst); - invokeGuardedCallbackAndCatchFirstError(simulated, listener, void 0, event); + invokeGuardedCallbackAndCatchFirstError(type, listener, void 0, event); event.currentTarget = null; } function executeDirectDispatch(event) { @@ -216,10 +217,10 @@ function executeDispatchesAndReleaseTopLevel(e) { i < dispatchListeners.length && !e.isPropagationStopped(); i++ ) - executeDispatch(e, !1, dispatchListeners[i], dispatchInstances[i]); + executeDispatch(e, dispatchListeners[i], dispatchInstances[i]); else dispatchListeners && - executeDispatch(e, !1, dispatchListeners, dispatchInstances); + executeDispatch(e, dispatchListeners, dispatchInstances); e._dispatchListeners = null; e._dispatchInstances = null; e.isPersistent() || e.constructor.release(e); @@ -294,7 +295,7 @@ function getListener(inst, registrationName) { } function getParent(inst) { do inst = inst.return; - while (inst && 7 !== inst.tag); + while (inst && 5 !== inst.tag); return inst ? inst : null; } function traverseTwoPhase(inst, fn, arg) { @@ -1148,7 +1149,8 @@ var ReactSharedInternals = : 60111, REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for("react.forward_ref") : 60112, REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for("react.suspense") : 60113, - REACT_PURE_TYPE = hasSymbol ? Symbol.for("react.pure") : 60115, + REACT_MEMO_TYPE = hasSymbol ? Symbol.for("react.memo") : 60115, + REACT_LAZY_TYPE = hasSymbol ? Symbol.for("react.lazy") : 60116, MAYBE_ITERATOR_SYMBOL = "function" === typeof Symbol && Symbol.iterator; function getIteratorFn(maybeIterable) { if (null === maybeIterable || "object" !== typeof maybeIterable) return null; @@ -1157,13 +1159,6 @@ function getIteratorFn(maybeIterable) { maybeIterable["@@iterator"]; return "function" === typeof maybeIterable ? maybeIterable : null; } -function getWrappedName(outerType, innerType, wrapperName) { - innerType = innerType.displayName || innerType.name || ""; - return ( - outerType.displayName || - ("" !== innerType ? wrapperName + "(" + innerType + ")" : wrapperName) - ); -} function getComponentName(type) { if (null == type) return null; if ("function" === typeof type) return type.displayName || type.name || null; @@ -1182,23 +1177,25 @@ function getComponentName(type) { case REACT_SUSPENSE_TYPE: return "Suspense"; } - if ("object" === typeof type) { + if ("object" === typeof type) switch (type.$$typeof) { case REACT_CONTEXT_TYPE: return "Context.Consumer"; case REACT_PROVIDER_TYPE: return "Context.Provider"; case REACT_FORWARD_REF_TYPE: - return getWrappedName(type, type.render, "ForwardRef"); - case REACT_PURE_TYPE: - return getWrappedName(type, type.render, "Pure"); + var innerType = type.render; + innerType = innerType.displayName || innerType.name || ""; + return ( + type.displayName || + ("" !== innerType ? "ForwardRef(" + innerType + ")" : "ForwardRef") + ); + case REACT_MEMO_TYPE: + return getComponentName(type.type); + case REACT_LAZY_TYPE: + if ((type = 1 === type._status ? type._result : null)) + return getComponentName(type); } - if ( - "function" === typeof type.then && - (type = 1 === type._reactStatus ? type._reactResult : null) - ) - return getComponentName(type); - } return null; } function isFiberMountedImpl(fiber) { @@ -1209,7 +1206,7 @@ function isFiberMountedImpl(fiber) { for (; node.return; ) if (((node = node.return), 0 !== (node.effectTag & 2))) return 1; } - return 5 === node.tag ? 2 : 3; + return 3 === node.tag ? 2 : 3; } function assertIsMounted(fiber) { invariant( @@ -1285,14 +1282,14 @@ function findCurrentFiberUsingSlowPath(fiber) { "Return fibers should always be each others' alternates. This error is likely caused by a bug in React. Please file an issue." ); } - invariant(5 === a.tag, "Unable to find node on an unmounted component."); + invariant(3 === a.tag, "Unable to find node on an unmounted component."); return a.stateNode.current === a ? fiber : alternate; } function findCurrentHostFiber(parent) { parent = findCurrentFiberUsingSlowPath(parent); if (!parent) return null; for (var node = parent; ; ) { - if (7 === node.tag || 8 === node.tag) return node; + if (5 === node.tag || 6 === node.tag) return node; if (node.child) (node.child.return = node), (node = node.child); else { if (node === parent) break; @@ -1600,18 +1597,12 @@ var ReactNativeFiberHostComponent = (function() { return Date.now(); }, scheduledCallback = null, - frameDeadline = 0, - frameDeadlineObject = { - timeRemaining: function() { - return frameDeadline - now$1(); - }, - didTimeout: !1 - }; + frameDeadline = 0; function setTimeoutCallback() { frameDeadline = now$1() + 5; var callback = scheduledCallback; scheduledCallback = null; - null !== callback && callback(frameDeadlineObject); + null !== callback && callback(); } function shim$1() { invariant( @@ -1652,13 +1643,13 @@ function getStackByFiberInDevAndProd(workInProgress) { var info = ""; do { a: switch (workInProgress.tag) { - case 4: + case 2: + case 16: case 0: case 1: - case 2: - case 3: - case 7: - case 10: + case 5: + case 8: + case 13: var owner = workInProgress._debugOwner, source = workInProgress._debugSource, name = getComponentName(workInProgress.type); @@ -1810,7 +1801,7 @@ function injectInternals(internals) { function FiberNode(tag, pendingProps, key, mode) { this.tag = tag; this.key = key; - this.sibling = this.child = this.return = this.stateNode = this.type = null; + this.sibling = this.child = this.return = this.stateNode = this.type = this.elementType = null; this.index = 0; this.ref = null; this.pendingProps = pendingProps; @@ -1824,29 +1815,33 @@ function FiberNode(tag, pendingProps, key, mode) { this.actualStartTime = -1; this.treeBaseDuration = this.selfBaseDuration = 0; } +function createFiber(tag, pendingProps, key, mode) { + return new FiberNode(tag, pendingProps, key, mode); +} function shouldConstruct(Component) { Component = Component.prototype; return !(!Component || !Component.isReactComponent); } -function resolveLazyComponentTag(fiber, Component) { +function resolveLazyComponentTag(Component) { if ("function" === typeof Component) - return shouldConstruct(Component) ? 3 : 1; + return shouldConstruct(Component) ? 1 : 0; if (void 0 !== Component && null !== Component) { - fiber = Component.$$typeof; - if (fiber === REACT_FORWARD_REF_TYPE) return 14; - if (fiber === REACT_PURE_TYPE) return 18; + Component = Component.$$typeof; + if (Component === REACT_FORWARD_REF_TYPE) return 11; + if (Component === REACT_MEMO_TYPE) return 14; } - return 4; + return 2; } function createWorkInProgress(current, pendingProps) { var workInProgress = current.alternate; null === workInProgress - ? ((workInProgress = new FiberNode( + ? ((workInProgress = createFiber( current.tag, pendingProps, current.key, current.mode )), + (workInProgress.elementType = current.elementType), (workInProgress.type = current.type), (workInProgress.stateNode = current.stateNode), (workInProgress.alternate = current), @@ -1872,60 +1867,66 @@ function createWorkInProgress(current, pendingProps) { workInProgress.treeBaseDuration = current.treeBaseDuration; return workInProgress; } -function createFiberFromElement(element, mode, expirationTime) { - var type = element.type, - key = element.key; - element = element.props; - var fiberTag = void 0; - if ("function" === typeof type) fiberTag = shouldConstruct(type) ? 2 : 4; - else if ("string" === typeof type) fiberTag = 7; +function createFiberFromTypeAndProps( + type, + key, + pendingProps, + owner, + mode, + expirationTime +) { + var fiberTag = 2; + owner = type; + if ("function" === typeof type) shouldConstruct(type) && (fiberTag = 1); + else if ("string" === typeof type) fiberTag = 5; else a: switch (type) { case REACT_FRAGMENT_TYPE: return createFiberFromFragment( - element.children, + pendingProps.children, mode, expirationTime, key ); case REACT_CONCURRENT_MODE_TYPE: - fiberTag = 10; - mode |= 3; - break; + return createFiberFromMode(pendingProps, mode | 3, expirationTime, key); case REACT_STRICT_MODE_TYPE: - fiberTag = 10; - mode |= 2; - break; + return createFiberFromMode(pendingProps, mode | 2, expirationTime, key); case REACT_PROFILER_TYPE: return ( - (type = new FiberNode(15, element, key, mode | 4)), + (type = createFiber(12, pendingProps, key, mode | 4)), + (type.elementType = REACT_PROFILER_TYPE), (type.type = REACT_PROFILER_TYPE), (type.expirationTime = expirationTime), type ); case REACT_SUSPENSE_TYPE: - fiberTag = 16; - break; + return ( + (type = createFiber(13, pendingProps, key, mode)), + (type.elementType = REACT_SUSPENSE_TYPE), + (type.type = REACT_SUSPENSE_TYPE), + (type.expirationTime = expirationTime), + type + ); default: if ("object" === typeof type && null !== type) switch (type.$$typeof) { case REACT_PROVIDER_TYPE: - fiberTag = 12; + fiberTag = 10; break a; case REACT_CONTEXT_TYPE: - fiberTag = 11; + fiberTag = 9; break a; case REACT_FORWARD_REF_TYPE: - fiberTag = 13; + fiberTag = 11; break a; - case REACT_PURE_TYPE: - fiberTag = 17; + case REACT_MEMO_TYPE: + fiberTag = 14; + break a; + case REACT_LAZY_TYPE: + fiberTag = 16; + owner = null; break a; - default: - if ("function" === typeof type.then) { - fiberTag = 4; - break a; - } } invariant( !1, @@ -1934,24 +1935,33 @@ function createFiberFromElement(element, mode, expirationTime) { "" ); } - mode = new FiberNode(fiberTag, element, key, mode); - mode.type = type; - mode.expirationTime = expirationTime; - return mode; + key = createFiber(fiberTag, pendingProps, key, mode); + key.elementType = type; + key.type = owner; + key.expirationTime = expirationTime; + return key; } function createFiberFromFragment(elements, mode, expirationTime, key) { - elements = new FiberNode(9, elements, key, mode); + elements = createFiber(7, elements, key, mode); elements.expirationTime = expirationTime; return elements; } +function createFiberFromMode(pendingProps, mode, expirationTime, key) { + pendingProps = createFiber(8, pendingProps, key, mode); + mode = 0 === (mode & 1) ? REACT_STRICT_MODE_TYPE : REACT_CONCURRENT_MODE_TYPE; + pendingProps.elementType = mode; + pendingProps.type = mode; + pendingProps.expirationTime = expirationTime; + return pendingProps; +} function createFiberFromText(content, mode, expirationTime) { - content = new FiberNode(8, content, null, mode); + content = createFiber(6, content, null, mode); content.expirationTime = expirationTime; return content; } function createFiberFromPortal(portal, mode, expirationTime) { - mode = new FiberNode( - 6, + mode = createFiber( + 4, null !== portal.children ? portal.children : [], portal.key, mode @@ -1969,9 +1979,9 @@ function markPendingPriorityLevel(root, expirationTime) { var earliestPendingTime = root.earliestPendingTime; 0 === earliestPendingTime ? (root.earliestPendingTime = root.latestPendingTime = expirationTime) - : earliestPendingTime > expirationTime + : earliestPendingTime < expirationTime ? (root.earliestPendingTime = expirationTime) - : root.latestPendingTime < expirationTime && + : root.latestPendingTime > expirationTime && (root.latestPendingTime = expirationTime); findNextExpirationTimeToWorkOn(expirationTime, root); } @@ -1986,19 +1996,19 @@ function markCommittedPriorityLevels(root, earliestRemainingTime) { else { var latestPendingTime = root.latestPendingTime; 0 !== latestPendingTime && - (latestPendingTime < earliestRemainingTime + (latestPendingTime > earliestRemainingTime ? (root.earliestPendingTime = root.latestPendingTime = 0) - : root.earliestPendingTime < earliestRemainingTime && + : root.earliestPendingTime > earliestRemainingTime && (root.earliestPendingTime = root.latestPendingTime)); latestPendingTime = root.earliestSuspendedTime; 0 === latestPendingTime ? markPendingPriorityLevel(root, earliestRemainingTime) - : earliestRemainingTime > root.latestSuspendedTime + : earliestRemainingTime < root.latestSuspendedTime ? ((root.earliestSuspendedTime = 0), (root.latestSuspendedTime = 0), (root.latestPingedTime = 0), markPendingPriorityLevel(root, earliestRemainingTime)) - : earliestRemainingTime < latestPendingTime && + : earliestRemainingTime > latestPendingTime && markPendingPriorityLevel(root, earliestRemainingTime); } findNextExpirationTimeToWorkOn(0, root); @@ -2008,17 +2018,17 @@ function hasLowerPriorityWork(root, erroredExpirationTime) { latestSuspendedTime = root.latestSuspendedTime; root = root.latestPingedTime; return ( - (0 !== latestPendingTime && latestPendingTime > erroredExpirationTime) || + (0 !== latestPendingTime && latestPendingTime < erroredExpirationTime) || (0 !== latestSuspendedTime && - latestSuspendedTime > erroredExpirationTime) || - (0 !== root && root > erroredExpirationTime) + latestSuspendedTime < erroredExpirationTime) || + (0 !== root && root < erroredExpirationTime) ); } function markSuspendedPriorityLevel(root, suspendedTime) { root.didError = !1; var latestPingedTime = root.latestPingedTime; 0 !== latestPingedTime && - latestPingedTime <= suspendedTime && + latestPingedTime >= suspendedTime && (root.latestPingedTime = 0); latestPingedTime = root.earliestPendingTime; var latestPendingTime = root.latestPendingTime; @@ -2033,22 +2043,18 @@ function markSuspendedPriorityLevel(root, suspendedTime) { latestPendingTime = root.latestSuspendedTime; 0 === latestPingedTime ? (root.earliestSuspendedTime = root.latestSuspendedTime = suspendedTime) - : latestPingedTime > suspendedTime + : latestPingedTime < suspendedTime ? (root.earliestSuspendedTime = suspendedTime) - : latestPendingTime < suspendedTime && + : latestPendingTime > suspendedTime && (root.latestSuspendedTime = suspendedTime); findNextExpirationTimeToWorkOn(suspendedTime, root); } function findEarliestOutstandingPriorityLevel(root, renderExpirationTime) { var earliestPendingTime = root.earliestPendingTime; root = root.earliestSuspendedTime; - if ( - 0 === renderExpirationTime || - (0 !== earliestPendingTime && earliestPendingTime < renderExpirationTime) - ) - renderExpirationTime = earliestPendingTime; - if (0 === renderExpirationTime || (0 !== root && root < renderExpirationTime)) - renderExpirationTime = root; + earliestPendingTime > renderExpirationTime && + (renderExpirationTime = earliestPendingTime); + root > renderExpirationTime && (renderExpirationTime = root); return renderExpirationTime; } function findNextExpirationTimeToWorkOn(completedExpirationTime, root) { @@ -2060,12 +2066,11 @@ function findNextExpirationTimeToWorkOn(completedExpirationTime, root) { 0 !== earliestPendingTime ? earliestPendingTime : latestPingedTime; 0 === earliestPendingTime && (0 === completedExpirationTime || - latestSuspendedTime > completedExpirationTime) && + latestSuspendedTime < completedExpirationTime) && (earliestPendingTime = latestSuspendedTime); completedExpirationTime = earliestPendingTime; 0 !== completedExpirationTime && - 0 !== earliestSuspendedTime && - earliestSuspendedTime < completedExpirationTime && + earliestSuspendedTime > completedExpirationTime && (completedExpirationTime = earliestSuspendedTime); root.nextExpirationTimeToWorkOn = earliestPendingTime; root.expirationTime = completedExpirationTime; @@ -2177,7 +2182,7 @@ function getStateFromUpdate( : workInProgress ); case 3: - workInProgress.effectTag = (workInProgress.effectTag & -1025) | 64; + workInProgress.effectTag = (workInProgress.effectTag & -2049) | 64; case 0: workInProgress = update.payload; nextProps = @@ -2210,58 +2215,52 @@ function processUpdateQueue( ) { var updateExpirationTime = update.expirationTime; - if (updateExpirationTime > renderExpirationTime) { - if ( - (null === newFirstUpdate && + updateExpirationTime < renderExpirationTime + ? (null === newFirstUpdate && ((newFirstUpdate = update), (newBaseState = resultState)), - 0 === newExpirationTime || newExpirationTime > updateExpirationTime) - ) - newExpirationTime = updateExpirationTime; - } else - (resultState = getStateFromUpdate( - workInProgress, - queue, - update, - resultState, - props, - instance - )), + newExpirationTime < updateExpirationTime && + (newExpirationTime = updateExpirationTime)) + : ((resultState = getStateFromUpdate( + workInProgress, + queue, + update, + resultState, + props, + instance + )), null !== update.callback && ((workInProgress.effectTag |= 32), (update.nextEffect = null), null === queue.lastEffect ? (queue.firstEffect = queue.lastEffect = update) : ((queue.lastEffect.nextEffect = update), - (queue.lastEffect = update))); + (queue.lastEffect = update)))); update = update.next; } updateExpirationTime = null; for (update = queue.firstCapturedUpdate; null !== update; ) { var _updateExpirationTime = update.expirationTime; - if (_updateExpirationTime > renderExpirationTime) { - if ( - (null === updateExpirationTime && + _updateExpirationTime < renderExpirationTime + ? (null === updateExpirationTime && ((updateExpirationTime = update), null === newFirstUpdate && (newBaseState = resultState)), - 0 === newExpirationTime || newExpirationTime > _updateExpirationTime) - ) - newExpirationTime = _updateExpirationTime; - } else - (resultState = getStateFromUpdate( - workInProgress, - queue, - update, - resultState, - props, - instance - )), + newExpirationTime < _updateExpirationTime && + (newExpirationTime = _updateExpirationTime)) + : ((resultState = getStateFromUpdate( + workInProgress, + queue, + update, + resultState, + props, + instance + )), null !== update.callback && ((workInProgress.effectTag |= 32), (update.nextEffect = null), null === queue.lastCapturedEffect ? (queue.firstCapturedEffect = queue.lastCapturedEffect = update) : ((queue.lastCapturedEffect.nextEffect = update), - (queue.lastCapturedEffect = update))); + (queue.lastCapturedEffect = update)))); update = update.next; } null === newFirstUpdate && (queue.lastUpdate = null); @@ -2342,7 +2341,7 @@ function readContext(context, observedBits) { null === lastContextDependency ? (invariant( null !== currentlyRenderingFiber, - "Context.unstable_read(): Context can only be read while React is rendering, e.g. inside the render method or getDerivedStateFromProps." + "Context can only be read while React is rendering, e.g. inside the render method or getDerivedStateFromProps." ), (currentlyRenderingFiber.firstContextDependency = lastContextDependency = observedBits)) : (lastContextDependency = lastContextDependency.next = observedBits); @@ -2428,7 +2427,47 @@ function shallowEqual(objA, objB) { return !1; return !0; } -var emptyRefsObject = new React.Component().refs; +function resolveDefaultProps(Component, baseProps) { + if (Component && Component.defaultProps) { + baseProps = Object.assign({}, baseProps); + Component = Component.defaultProps; + for (var propName in Component) + void 0 === baseProps[propName] && + (baseProps[propName] = Component[propName]); + } + return baseProps; +} +function readLazyComponentType(lazyComponent) { + var result = lazyComponent._result; + switch (lazyComponent._status) { + case 1: + return result; + case 2: + throw result; + case 0: + throw result; + 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)); + }, + function(error) { + 0 === lazyComponent._status && + ((lazyComponent._status = 2), (lazyComponent._result = error)); + } + ), + (lazyComponent._result = result), + result); + } +} +var ReactCurrentOwner$4 = ReactSharedInternals.ReactCurrentOwner, + emptyRefsObject = new React.Component().refs; function applyDerivedStateFromProps( workInProgress, ctor, @@ -2460,6 +2499,7 @@ var classComponentUpdater = { var update = createUpdate(currentTime); update.payload = payload; void 0 !== callback && null !== callback && (update.callback = callback); + flushPassiveEffects(); enqueueUpdate(inst, update); scheduleWork(inst, currentTime); }, @@ -2471,6 +2511,7 @@ var classComponentUpdater = { update.tag = 1; update.payload = payload; void 0 !== callback && null !== callback && (update.callback = callback); + flushPassiveEffects(); enqueueUpdate(inst, update); scheduleWork(inst, currentTime); }, @@ -2481,6 +2522,7 @@ var classComponentUpdater = { var update = createUpdate(currentTime); update.tag = 2; void 0 !== callback && null !== callback && (update.callback = callback); + flushPassiveEffects(); enqueueUpdate(inst, update); scheduleWork(inst, currentTime); } @@ -2501,6 +2543,32 @@ function checkShouldComponentUpdate( ? !shallowEqual(oldProps, newProps) || !shallowEqual(oldState, newState) : !0; } +function constructClassInstance(workInProgress, ctor, props) { + var isLegacyContextConsumer = !1, + unmaskedContext = emptyContextObject; + var context = ctor.contextType; + "object" === typeof context && null !== context + ? (context = ReactCurrentOwner$4.currentDispatcher.readContext(context)) + : ((unmaskedContext = isContextProvider(ctor) + ? previousContext + : contextStackCursor.current), + (isLegacyContextConsumer = ctor.contextTypes), + (context = (isLegacyContextConsumer = + null !== isLegacyContextConsumer && void 0 !== isLegacyContextConsumer) + ? getMaskedContext(workInProgress, unmaskedContext) + : emptyContextObject)); + ctor = new ctor(props, context); + workInProgress.memoizedState = + null !== ctor.state && void 0 !== ctor.state ? ctor.state : null; + ctor.updater = classComponentUpdater; + workInProgress.stateNode = ctor; + ctor._reactInternalFiber = workInProgress; + isLegacyContextConsumer && + ((workInProgress = workInProgress.stateNode), + (workInProgress.__reactInternalMemoizedUnmaskedChildContext = unmaskedContext), + (workInProgress.__reactInternalMemoizedMaskedChildContext = context)); + return ctor; +} function callComponentWillReceiveProps( workInProgress, instance, @@ -2527,7 +2595,9 @@ function mountClassInstance( instance.refs = emptyRefsObject; var contextType = ctor.contextType; "object" === typeof contextType && null !== contextType - ? (instance.context = contextType.unstable_read()) + ? (instance.context = ReactCurrentOwner$4.currentDispatcher.readContext( + contextType + )) : ((contextType = isContextProvider(ctor) ? previousContext : contextStackCursor.current), @@ -2582,10 +2652,7 @@ function coerceRef(returnFiber, current$$1, element) { element = element._owner; var inst = void 0; element && - (invariant( - 2 === element.tag || 3 === element.tag, - "Function components cannot have refs." - ), + (invariant(1 === element.tag, "Function components cannot have refs."), (inst = element.stateNode)); invariant( inst, @@ -2690,7 +2757,7 @@ function ChildReconciler(shouldTrackSideEffects) { textContent, expirationTime ) { - if (null === current$$1 || 8 !== current$$1.tag) + if (null === current$$1 || 6 !== current$$1.tag) return ( (current$$1 = createFiberFromText( textContent, @@ -2705,15 +2772,18 @@ function ChildReconciler(shouldTrackSideEffects) { return current$$1; } function updateElement(returnFiber, current$$1, element, expirationTime) { - if (null !== current$$1 && current$$1.type === element.type) + if (null !== current$$1 && current$$1.elementType === element.type) return ( (expirationTime = useFiber(current$$1, element.props, expirationTime)), (expirationTime.ref = coerceRef(returnFiber, current$$1, element)), (expirationTime.return = returnFiber), expirationTime ); - expirationTime = createFiberFromElement( - element, + expirationTime = createFiberFromTypeAndProps( + element.type, + element.key, + element.props, + null, returnFiber.mode, expirationTime ); @@ -2724,7 +2794,7 @@ function ChildReconciler(shouldTrackSideEffects) { function updatePortal(returnFiber, current$$1, portal, expirationTime) { if ( null === current$$1 || - 6 !== current$$1.tag || + 4 !== current$$1.tag || current$$1.stateNode.containerInfo !== portal.containerInfo || current$$1.stateNode.implementation !== portal.implementation ) @@ -2748,7 +2818,7 @@ function ChildReconciler(shouldTrackSideEffects) { expirationTime, key ) { - if (null === current$$1 || 9 !== current$$1.tag) + if (null === current$$1 || 7 !== current$$1.tag) return ( (current$$1 = createFiberFromFragment( fragment, @@ -2778,8 +2848,11 @@ function ChildReconciler(shouldTrackSideEffects) { switch (newChild.$$typeof) { case REACT_ELEMENT_TYPE: return ( - (expirationTime = createFiberFromElement( - newChild, + (expirationTime = createFiberFromTypeAndProps( + newChild.type, + newChild.key, + newChild.props, + null, returnFiber.mode, expirationTime )), @@ -3123,9 +3196,9 @@ function ChildReconciler(shouldTrackSideEffects) { ) { if (isUnkeyedTopLevelFragment.key === isObject) if ( - 9 === isUnkeyedTopLevelFragment.tag + 7 === isUnkeyedTopLevelFragment.tag ? newChild.type === REACT_FRAGMENT_TYPE - : isUnkeyedTopLevelFragment.type === newChild.type + : isUnkeyedTopLevelFragment.elementType === newChild.type ) { deleteRemainingChildren( returnFiber, @@ -3165,8 +3238,11 @@ function ChildReconciler(shouldTrackSideEffects) { )), (currentFirstChild.return = returnFiber), (returnFiber = currentFirstChild)) - : ((expirationTime = createFiberFromElement( - newChild, + : ((expirationTime = createFiberFromTypeAndProps( + newChild.type, + newChild.key, + newChild.props, + null, returnFiber.mode, expirationTime )), @@ -3188,7 +3264,7 @@ function ChildReconciler(shouldTrackSideEffects) { ) { if (currentFirstChild.key === isUnkeyedTopLevelFragment) if ( - 6 === currentFirstChild.tag && + 4 === currentFirstChild.tag && currentFirstChild.stateNode.containerInfo === newChild.containerInfo && currentFirstChild.stateNode.implementation === @@ -3226,7 +3302,7 @@ function ChildReconciler(shouldTrackSideEffects) { if ("string" === typeof newChild || "number" === typeof newChild) return ( (newChild = "" + newChild), - null !== currentFirstChild && 8 === currentFirstChild.tag + null !== currentFirstChild && 6 === currentFirstChild.tag ? (deleteRemainingChildren(returnFiber, currentFirstChild.sibling), (currentFirstChild = useFiber( currentFirstChild, @@ -3262,8 +3338,7 @@ function ChildReconciler(shouldTrackSideEffects) { isObject && throwOnInvalidObjectType(returnFiber, newChild); if ("undefined" === typeof newChild && !isUnkeyedTopLevelFragment) switch (returnFiber.tag) { - case 2: - case 3: + case 1: case 0: (expirationTime = returnFiber.type), invariant( @@ -3282,12 +3357,12 @@ var reconcileChildFibers = ChildReconciler(!0), isHydrating = !1; function tryHydrate(fiber, nextInstance) { switch (fiber.tag) { - case 7: + case 5: return ( (nextInstance = shim$1(nextInstance, fiber.type, fiber.pendingProps)), null !== nextInstance ? ((fiber.stateNode = nextInstance), !0) : !1 ); - case 8: + case 6: return ( (nextInstance = shim$1(nextInstance, fiber.pendingProps)), null !== nextInstance ? ((fiber.stateNode = nextInstance), !0) : !1 @@ -3310,7 +3385,8 @@ function tryToClaimNextHydratableInstance(fiber$jscomp$0) { return; } var returnFiber = hydrationParentFiber, - fiber = new FiberNode(7, null, null, 0); + fiber = createFiber(5, null, null, 0); + fiber.elementType = "DELETED"; fiber.type = "DELETED"; fiber.stateNode = firstAttemptedInstance; fiber.return = returnFiber; @@ -3328,38 +3404,6 @@ function tryToClaimNextHydratableInstance(fiber$jscomp$0) { (hydrationParentFiber = fiber$jscomp$0); } } -function readLazyComponentType(thenable) { - switch (thenable._reactStatus) { - case 1: - return thenable._reactResult; - case 2: - throw thenable._reactResult; - case 0: - throw thenable; - default: - throw ((thenable._reactStatus = 0), - thenable.then( - function(resolvedValue) { - if (0 === thenable._reactStatus) { - thenable._reactStatus = 1; - if ("object" === typeof resolvedValue && null !== resolvedValue) { - var defaultExport = resolvedValue.default; - resolvedValue = - void 0 !== defaultExport && null !== defaultExport - ? defaultExport - : resolvedValue; - } - thenable._reactResult = resolvedValue; - } - }, - function(error) { - 0 === thenable._reactStatus && - ((thenable._reactStatus = 2), (thenable._reactResult = error)); - } - ), - thenable); - } -} var ReactCurrentOwner$3 = ReactSharedInternals.ReactCurrentOwner; function reconcileChildren( current$$1, @@ -3385,28 +3429,24 @@ function reconcileChildren( function updateForwardRef( current$$1, workInProgress, - type, + Component, nextProps, renderExpirationTime ) { - type = type.render; + Component = Component.render; var ref = workInProgress.ref; - if ( - !didPerformWorkStackCursor.current && - workInProgress.memoizedProps === nextProps && - ref === (null !== current$$1 ? current$$1.ref : null) - ) - return bailoutOnAlreadyFinishedWork( - current$$1, - workInProgress, - renderExpirationTime - ); - type = type(nextProps, ref); - reconcileChildren(current$$1, workInProgress, type, renderExpirationTime); - workInProgress.memoizedProps = nextProps; + prepareToReadContext(workInProgress, renderExpirationTime); + nextProps = Component(nextProps, ref); + workInProgress.effectTag |= 1; + reconcileChildren( + current$$1, + workInProgress, + nextProps, + renderExpirationTime + ); return workInProgress.child; } -function updatePureComponent( +function updateMemoComponent( current$$1, workInProgress, Component, @@ -3414,29 +3454,82 @@ function updatePureComponent( updateExpirationTime, renderExpirationTime ) { - var render = Component.render, - ref = workInProgress.ref; + if (null === current$$1) { + var type = Component.type; + if ( + "function" === typeof type && + !shouldConstruct(type) && + void 0 === type.defaultProps && + null === Component.compare + ) + return ( + (workInProgress.tag = 15), + (workInProgress.type = type), + updateSimpleMemoComponent( + current$$1, + workInProgress, + type, + nextProps, + updateExpirationTime, + renderExpirationTime + ) + ); + current$$1 = createFiberFromTypeAndProps( + Component.type, + null, + nextProps, + null, + workInProgress.mode, + renderExpirationTime + ); + current$$1.ref = workInProgress.ref; + current$$1.return = workInProgress; + return (workInProgress.child = current$$1); + } + type = current$$1.child; if ( - null !== current$$1 && - (0 === updateExpirationTime || - updateExpirationTime > renderExpirationTime) && - ((updateExpirationTime = current$$1.memoizedProps), + updateExpirationTime < renderExpirationTime && + ((updateExpirationTime = type.memoizedProps), (Component = Component.compare), (Component = null !== Component ? Component : shallowEqual), - workInProgress.ref === current$$1.ref && - Component(updateExpirationTime, nextProps)) + Component(updateExpirationTime, nextProps) && + current$$1.ref === workInProgress.ref) ) return bailoutOnAlreadyFinishedWork( current$$1, workInProgress, renderExpirationTime ); - prepareToReadContext(workInProgress, renderExpirationTime); - render = render(nextProps, ref); workInProgress.effectTag |= 1; - reconcileChildren(current$$1, workInProgress, render, renderExpirationTime); - workInProgress.memoizedProps = nextProps; - return workInProgress.child; + current$$1 = createWorkInProgress(type, nextProps, renderExpirationTime); + current$$1.ref = workInProgress.ref; + current$$1.return = workInProgress; + return (workInProgress.child = current$$1); +} +function updateSimpleMemoComponent( + current$$1, + workInProgress, + Component, + nextProps, + updateExpirationTime, + renderExpirationTime +) { + return null !== current$$1 && + updateExpirationTime < renderExpirationTime && + shallowEqual(current$$1.memoizedProps, nextProps) && + current$$1.ref === workInProgress.ref + ? bailoutOnAlreadyFinishedWork( + current$$1, + workInProgress, + renderExpirationTime + ) + : updateFunctionComponent( + current$$1, + workInProgress, + Component, + nextProps, + renderExpirationTime + ); } function markRef(current$$1, workInProgress) { var ref = workInProgress.ref; @@ -3466,7 +3559,6 @@ function updateFunctionComponent( Component, renderExpirationTime ); - workInProgress.memoizedProps = nextProps; return workInProgress.child; } function updateClassComponent( @@ -3481,166 +3573,152 @@ function updateClassComponent( pushContextProvider(workInProgress); } else hasContext = !1; prepareToReadContext(workInProgress, renderExpirationTime); - if (null === current$$1) - if (null === workInProgress.stateNode) { - var isLegacyContextConsumer = !1, - unmaskedContext = emptyContextObject; - var context = Component.contextType; - "object" === typeof context && null !== context - ? (context = context.unstable_read()) - : ((unmaskedContext = isContextProvider(Component) - ? previousContext - : contextStackCursor.current), - (isLegacyContextConsumer = Component.contextTypes), - (context = (isLegacyContextConsumer = - null !== isLegacyContextConsumer && - void 0 !== isLegacyContextConsumer) - ? getMaskedContext(workInProgress, unmaskedContext) - : emptyContextObject)); - var instance = new Component(nextProps, context); - workInProgress.memoizedState = - null !== instance.state && void 0 !== instance.state - ? instance.state - : null; - instance.updater = classComponentUpdater; - workInProgress.stateNode = instance; - instance._reactInternalFiber = workInProgress; - isLegacyContextConsumer && - ((isLegacyContextConsumer = workInProgress.stateNode), - (isLegacyContextConsumer.__reactInternalMemoizedUnmaskedChildContext = unmaskedContext), - (isLegacyContextConsumer.__reactInternalMemoizedMaskedChildContext = context)); + if (null === workInProgress.stateNode) + null !== current$$1 && + ((current$$1.alternate = null), + (workInProgress.alternate = null), + (workInProgress.effectTag |= 2)), + constructClassInstance( + workInProgress, + Component, + nextProps, + renderExpirationTime + ), mountClassInstance( workInProgress, Component, nextProps, renderExpirationTime - ); - nextProps = !0; - } else { - unmaskedContext = workInProgress.stateNode; - isLegacyContextConsumer = workInProgress.memoizedProps; - unmaskedContext.props = isLegacyContextConsumer; - var oldContext = unmaskedContext.context; - context = Component.contextType; - "object" === typeof context && null !== context - ? (context = context.unstable_read()) - : ((context = isContextProvider(Component) - ? previousContext - : contextStackCursor.current), - (context = getMaskedContext(workInProgress, context))); - var getDerivedStateFromProps = Component.getDerivedStateFromProps; - (instance = + ), + (nextProps = !0); + else if (null === current$$1) { + var instance = workInProgress.stateNode, + oldProps = workInProgress.memoizedProps; + instance.props = oldProps; + var oldContext = instance.context, + contextType = Component.contextType; + "object" === typeof contextType && null !== contextType + ? (contextType = ReactCurrentOwner$4.currentDispatcher.readContext( + contextType + )) + : ((contextType = isContextProvider(Component) + ? previousContext + : contextStackCursor.current), + (contextType = getMaskedContext(workInProgress, contextType))); + var getDerivedStateFromProps = Component.getDerivedStateFromProps, + hasNewLifecycles = "function" === typeof getDerivedStateFromProps || - "function" === typeof unmaskedContext.getSnapshotBeforeUpdate) || - ("function" !== - typeof unmaskedContext.UNSAFE_componentWillReceiveProps && - "function" !== typeof unmaskedContext.componentWillReceiveProps) || - ((isLegacyContextConsumer !== nextProps || oldContext !== context) && - callComponentWillReceiveProps( - workInProgress, - unmaskedContext, - nextProps, - context - )); - hasForceUpdate = !1; - var oldState = workInProgress.memoizedState; - oldContext = unmaskedContext.state = oldState; - var updateQueue = workInProgress.updateQueue; - null !== updateQueue && - (processUpdateQueue( + "function" === typeof instance.getSnapshotBeforeUpdate; + hasNewLifecycles || + ("function" !== typeof instance.UNSAFE_componentWillReceiveProps && + "function" !== typeof instance.componentWillReceiveProps) || + ((oldProps !== nextProps || oldContext !== contextType) && + callComponentWillReceiveProps( workInProgress, - updateQueue, + instance, nextProps, - unmaskedContext, - renderExpirationTime - ), - (oldContext = workInProgress.memoizedState)); - isLegacyContextConsumer !== nextProps || - oldState !== oldContext || - didPerformWorkStackCursor.current || - hasForceUpdate - ? ("function" === typeof getDerivedStateFromProps && - (applyDerivedStateFromProps( - workInProgress, - Component, - getDerivedStateFromProps, - nextProps - ), - (oldContext = workInProgress.memoizedState)), - (isLegacyContextConsumer = - hasForceUpdate || - checkShouldComponentUpdate( - workInProgress, - Component, - isLegacyContextConsumer, - nextProps, - oldState, - oldContext, - context - )) - ? (instance || - ("function" !== - typeof unmaskedContext.UNSAFE_componentWillMount && - "function" !== typeof unmaskedContext.componentWillMount) || - ("function" === typeof unmaskedContext.componentWillMount && - unmaskedContext.componentWillMount(), - "function" === - typeof unmaskedContext.UNSAFE_componentWillMount && - unmaskedContext.UNSAFE_componentWillMount()), - "function" === typeof unmaskedContext.componentDidMount && - (workInProgress.effectTag |= 4)) - : ("function" === typeof unmaskedContext.componentDidMount && - (workInProgress.effectTag |= 4), - (workInProgress.memoizedProps = nextProps), - (workInProgress.memoizedState = oldContext)), - (unmaskedContext.props = nextProps), - (unmaskedContext.state = oldContext), - (unmaskedContext.context = context), - (nextProps = isLegacyContextConsumer)) - : ("function" === typeof unmaskedContext.componentDidMount && - (workInProgress.effectTag |= 4), - (nextProps = !1)); - } - else - (unmaskedContext = workInProgress.stateNode), - (isLegacyContextConsumer = workInProgress.memoizedProps), - (unmaskedContext.props = isLegacyContextConsumer), - (oldContext = unmaskedContext.context), - (context = Component.contextType), - "object" === typeof context && null !== context - ? (context = context.unstable_read()) - : ((context = isContextProvider(Component) + contextType + )); + hasForceUpdate = !1; + var oldState = workInProgress.memoizedState; + oldContext = instance.state = oldState; + var updateQueue = workInProgress.updateQueue; + null !== updateQueue && + (processUpdateQueue( + workInProgress, + updateQueue, + nextProps, + instance, + renderExpirationTime + ), + (oldContext = workInProgress.memoizedState)); + oldProps !== nextProps || + oldState !== oldContext || + didPerformWorkStackCursor.current || + hasForceUpdate + ? ("function" === typeof getDerivedStateFromProps && + (applyDerivedStateFromProps( + workInProgress, + Component, + getDerivedStateFromProps, + nextProps + ), + (oldContext = workInProgress.memoizedState)), + (oldProps = + hasForceUpdate || + checkShouldComponentUpdate( + workInProgress, + Component, + oldProps, + nextProps, + oldState, + oldContext, + contextType + )) + ? (hasNewLifecycles || + ("function" !== typeof instance.UNSAFE_componentWillMount && + "function" !== typeof instance.componentWillMount) || + ("function" === typeof instance.componentWillMount && + instance.componentWillMount(), + "function" === typeof instance.UNSAFE_componentWillMount && + instance.UNSAFE_componentWillMount()), + "function" === typeof instance.componentDidMount && + (workInProgress.effectTag |= 4)) + : ("function" === typeof instance.componentDidMount && + (workInProgress.effectTag |= 4), + (workInProgress.memoizedProps = nextProps), + (workInProgress.memoizedState = oldContext)), + (instance.props = nextProps), + (instance.state = oldContext), + (instance.context = contextType), + (nextProps = oldProps)) + : ("function" === typeof instance.componentDidMount && + (workInProgress.effectTag |= 4), + (nextProps = !1)); + } else + (instance = workInProgress.stateNode), + (oldProps = workInProgress.memoizedProps), + (instance.props = + workInProgress.type === workInProgress.elementType + ? oldProps + : resolveDefaultProps(workInProgress.type, oldProps)), + (oldContext = instance.context), + (contextType = Component.contextType), + "object" === typeof contextType && null !== contextType + ? (contextType = ReactCurrentOwner$4.currentDispatcher.readContext( + contextType + )) + : ((contextType = isContextProvider(Component) ? previousContext : contextStackCursor.current), - (context = getMaskedContext(workInProgress, context))), + (contextType = getMaskedContext(workInProgress, contextType))), (getDerivedStateFromProps = Component.getDerivedStateFromProps), - (instance = + (hasNewLifecycles = "function" === typeof getDerivedStateFromProps || - "function" === typeof unmaskedContext.getSnapshotBeforeUpdate) || - ("function" !== - typeof unmaskedContext.UNSAFE_componentWillReceiveProps && - "function" !== typeof unmaskedContext.componentWillReceiveProps) || - ((isLegacyContextConsumer !== nextProps || oldContext !== context) && + "function" === typeof instance.getSnapshotBeforeUpdate) || + ("function" !== typeof instance.UNSAFE_componentWillReceiveProps && + "function" !== typeof instance.componentWillReceiveProps) || + ((oldProps !== nextProps || oldContext !== contextType) && callComponentWillReceiveProps( workInProgress, - unmaskedContext, + instance, nextProps, - context + contextType )), (hasForceUpdate = !1), (oldContext = workInProgress.memoizedState), - (oldState = unmaskedContext.state = oldContext), + (oldState = instance.state = oldContext), (updateQueue = workInProgress.updateQueue), null !== updateQueue && (processUpdateQueue( workInProgress, updateQueue, nextProps, - unmaskedContext, + instance, renderExpirationTime ), (oldState = workInProgress.memoizedState)), - isLegacyContextConsumer !== nextProps || + oldProps !== nextProps || oldContext !== oldState || didPerformWorkStackCursor.current || hasForceUpdate @@ -3657,53 +3735,51 @@ function updateClassComponent( checkShouldComponentUpdate( workInProgress, Component, - isLegacyContextConsumer, + oldProps, nextProps, oldContext, oldState, - context + contextType )) - ? (instance || - ("function" !== - typeof unmaskedContext.UNSAFE_componentWillUpdate && - "function" !== typeof unmaskedContext.componentWillUpdate) || - ("function" === typeof unmaskedContext.componentWillUpdate && - unmaskedContext.componentWillUpdate( + ? (hasNewLifecycles || + ("function" !== typeof instance.UNSAFE_componentWillUpdate && + "function" !== typeof instance.componentWillUpdate) || + ("function" === typeof instance.componentWillUpdate && + instance.componentWillUpdate( nextProps, oldState, - context + contextType ), - "function" === - typeof unmaskedContext.UNSAFE_componentWillUpdate && - unmaskedContext.UNSAFE_componentWillUpdate( + "function" === typeof instance.UNSAFE_componentWillUpdate && + instance.UNSAFE_componentWillUpdate( nextProps, oldState, - context + contextType )), - "function" === typeof unmaskedContext.componentDidUpdate && + "function" === typeof instance.componentDidUpdate && (workInProgress.effectTag |= 4), - "function" === typeof unmaskedContext.getSnapshotBeforeUpdate && + "function" === typeof instance.getSnapshotBeforeUpdate && (workInProgress.effectTag |= 256)) - : ("function" !== typeof unmaskedContext.componentDidUpdate || - (isLegacyContextConsumer === current$$1.memoizedProps && + : ("function" !== typeof instance.componentDidUpdate || + (oldProps === current$$1.memoizedProps && oldContext === current$$1.memoizedState) || (workInProgress.effectTag |= 4), - "function" !== typeof unmaskedContext.getSnapshotBeforeUpdate || - (isLegacyContextConsumer === current$$1.memoizedProps && + "function" !== typeof instance.getSnapshotBeforeUpdate || + (oldProps === current$$1.memoizedProps && oldContext === current$$1.memoizedState) || (workInProgress.effectTag |= 256), (workInProgress.memoizedProps = nextProps), (workInProgress.memoizedState = oldState)), - (unmaskedContext.props = nextProps), - (unmaskedContext.state = oldState), - (unmaskedContext.context = context), + (instance.props = nextProps), + (instance.state = oldState), + (instance.context = contextType), (nextProps = getDerivedStateFromProps)) - : ("function" !== typeof unmaskedContext.componentDidUpdate || - (isLegacyContextConsumer === current$$1.memoizedProps && + : ("function" !== typeof instance.componentDidUpdate || + (oldProps === current$$1.memoizedProps && oldContext === current$$1.memoizedState) || (workInProgress.effectTag |= 4), - "function" !== typeof unmaskedContext.getSnapshotBeforeUpdate || - (isLegacyContextConsumer === current$$1.memoizedProps && + "function" !== typeof instance.getSnapshotBeforeUpdate || + (oldProps === current$$1.memoizedProps && oldContext === current$$1.memoizedState) || (workInProgress.effectTag |= 256), (nextProps = !1)); @@ -3766,7 +3842,6 @@ function finishClassComponent( renderExpirationTime ); workInProgress.memoizedState = shouldUpdate.state; - workInProgress.memoizedProps = shouldUpdate.props; hasContext && invalidateContextProvider(workInProgress, Component, !0); return workInProgress.child; } @@ -3782,50 +3857,160 @@ function pushHostRootContext(workInProgress) { pushTopLevelContextObject(workInProgress, root.context, !1); pushHostContainer(workInProgress, root.containerInfo); } -function resolveDefaultProps(Component, baseProps) { - if (Component && Component.defaultProps) { - baseProps = Object.assign({}, baseProps); - Component = Component.defaultProps; - for (var propName in Component) - void 0 === baseProps[propName] && - (baseProps[propName] = Component[propName]); - } - return baseProps; -} -function bailoutOnAlreadyFinishedWork( +function updateSuspenseComponent( current$$1, workInProgress, renderExpirationTime ) { - null !== current$$1 && - (workInProgress.firstContextDependency = current$$1.firstContextDependency); - profilerStartTime = -1; - 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." - ); - if (null !== workInProgress.child) { - current$$1 = workInProgress.child; - renderExpirationTime = createWorkInProgress( - current$$1, - current$$1.pendingProps, - current$$1.expirationTime - ); - workInProgress.child = renderExpirationTime; - for ( - renderExpirationTime.return = workInProgress; - null !== current$$1.sibling; - - ) - (current$$1 = current$$1.sibling), - (renderExpirationTime = renderExpirationTime.sibling = createWorkInProgress( - current$$1, - current$$1.pendingProps, - current$$1.expirationTime - )), + var mode = workInProgress.mode, + nextProps = workInProgress.pendingProps, + nextState = workInProgress.memoizedState; + if (0 === (workInProgress.effectTag & 64)) { + nextState = null; + var nextDidTimeout = !1; + } else + (nextState = { timedOutAt: null !== nextState ? nextState.timedOutAt : 0 }), + (nextDidTimeout = !0), + (workInProgress.effectTag &= -65); + if (null === current$$1) + nextDidTimeout + ? ((nextDidTimeout = nextProps.fallback), + (nextProps = createFiberFromFragment(null, mode, 0, null)), + 0 === (workInProgress.mode & 1) && + (nextProps.child = + null !== workInProgress.memoizedState + ? workInProgress.child.child + : workInProgress.child), + (renderExpirationTime = createFiberFromFragment( + nextDidTimeout, + mode, + renderExpirationTime, + null + )), + (nextProps.sibling = renderExpirationTime), + (mode = nextProps), + (mode.return = renderExpirationTime.return = workInProgress)) + : (mode = renderExpirationTime = mountChildFibers( + workInProgress, + null, + nextProps.children, + renderExpirationTime + )); + else if (null !== current$$1.memoizedState) + if ( + ((current$$1 = current$$1.child), + (mode = current$$1.sibling), + nextDidTimeout) + ) { + nextProps = nextProps.fallback; + renderExpirationTime = createWorkInProgress( + current$$1, + current$$1.pendingProps, + 0 + ); + renderExpirationTime.effectTag |= 2; + 0 === (workInProgress.mode & 1) && + ((nextDidTimeout = + null !== workInProgress.memoizedState + ? workInProgress.child.child + : workInProgress.child), + nextDidTimeout !== current$$1.child && + (renderExpirationTime.child = nextDidTimeout)); + if (workInProgress.mode & 4) { + nextDidTimeout = 0; + for (current$$1 = renderExpirationTime.child; null !== current$$1; ) + (nextDidTimeout += current$$1.treeBaseDuration), + (current$$1 = current$$1.sibling); + renderExpirationTime.treeBaseDuration = nextDidTimeout; + } + nextProps = renderExpirationTime.sibling = createWorkInProgress( + mode, + nextProps, + mode.expirationTime + ); + nextProps.effectTag |= 2; + mode = renderExpirationTime; + renderExpirationTime.childExpirationTime = 0; + renderExpirationTime = nextProps; + mode.return = renderExpirationTime.return = workInProgress; + } else + mode = renderExpirationTime = reconcileChildFibers( + workInProgress, + current$$1.child, + nextProps.children, + renderExpirationTime + ); + else if (((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; + 0 === (workInProgress.mode & 1) && + (nextProps.child = + null !== workInProgress.memoizedState + ? workInProgress.child.child + : workInProgress.child); + if (workInProgress.mode & 4) { + current$$1 = 0; + for (var _hiddenChild = nextProps.child; null !== _hiddenChild; ) + (current$$1 += _hiddenChild.treeBaseDuration), + (_hiddenChild = _hiddenChild.sibling); + nextProps.treeBaseDuration = current$$1; + } + renderExpirationTime = nextProps.sibling = createFiberFromFragment( + nextDidTimeout, + mode, + renderExpirationTime, + null + ); + renderExpirationTime.effectTag |= 2; + mode = nextProps; + nextProps.childExpirationTime = 0; + mode.return = renderExpirationTime.return = workInProgress; + } else + renderExpirationTime = mode = reconcileChildFibers( + workInProgress, + current$$1, + nextProps.children, + renderExpirationTime + ); + workInProgress.memoizedState = nextState; + workInProgress.child = mode; + return renderExpirationTime; +} +function bailoutOnAlreadyFinishedWork( + current$$1, + workInProgress, + renderExpirationTime +) { + null !== current$$1 && + (workInProgress.firstContextDependency = current$$1.firstContextDependency); + profilerStartTime = -1; + if (workInProgress.childExpirationTime < renderExpirationTime) return null; + invariant( + null === current$$1 || workInProgress.child === current$$1.child, + "Resuming work not yet implemented." + ); + if (null !== workInProgress.child) { + current$$1 = workInProgress.child; + renderExpirationTime = createWorkInProgress( + current$$1, + current$$1.pendingProps, + current$$1.expirationTime + ); + workInProgress.child = renderExpirationTime; + for ( + renderExpirationTime.return = workInProgress; + null !== current$$1.sibling; + + ) + (current$$1 = current$$1.sibling), + (renderExpirationTime = renderExpirationTime.sibling = createWorkInProgress( + current$$1, + current$$1.pendingProps, + current$$1.expirationTime + )), (renderExpirationTime.return = workInProgress); renderExpirationTime.sibling = null; } @@ -3837,34 +4022,50 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { null !== current$$1 && current$$1.memoizedProps === workInProgress.pendingProps && !didPerformWorkStackCursor.current && - (0 === updateExpirationTime || updateExpirationTime > renderExpirationTime) + updateExpirationTime < renderExpirationTime ) { switch (workInProgress.tag) { - case 5: + case 3: pushHostRootContext(workInProgress); break; - case 7: + case 5: pushHostContext(workInProgress); break; - case 2: + case 1: isContextProvider(workInProgress.type) && pushContextProvider(workInProgress); break; - case 3: - isContextProvider(workInProgress.type._reactResult) && - pushContextProvider(workInProgress); - break; - case 6: + case 4: pushHostContainer( workInProgress, workInProgress.stateNode.containerInfo ); break; - case 12: + case 10: pushProvider(workInProgress, workInProgress.memoizedProps.value); break; - case 15: + case 12: workInProgress.effectTag |= 4; + break; + case 13: + if (null !== workInProgress.memoizedState) { + updateExpirationTime = workInProgress.child.childExpirationTime; + if ( + 0 !== updateExpirationTime && + updateExpirationTime >= renderExpirationTime + ) + return updateSuspenseComponent( + current$$1, + workInProgress, + renderExpirationTime + ); + workInProgress = bailoutOnAlreadyFinishedWork( + current$$1, + workInProgress, + renderExpirationTime + ); + return null !== workInProgress ? workInProgress.sibling : null; + } } return bailoutOnAlreadyFinishedWork( current$$1, @@ -3874,191 +4075,180 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { } workInProgress.expirationTime = 0; switch (workInProgress.tag) { - case 4: - var Component = workInProgress.type; - invariant( - null === current$$1, - "An indeterminate component should never have mounted. This error is likely caused by a bug in React. Please file an issue." + 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 ); - var props = workInProgress.pendingProps; + prepareToReadContext(workInProgress, renderExpirationTime); + context = updateExpirationTime(current$$1, context); + workInProgress.effectTag |= 1; if ( - "object" === typeof Component && - null !== Component && - "function" === typeof Component.then + "object" === typeof context && + null !== context && + "function" === typeof context.render && + void 0 === context.$$typeof ) { - Component = readLazyComponentType(Component); - var resolvedTag = (workInProgress.tag = resolveLazyComponentTag( + workInProgress.tag = 1; + if (isContextProvider(updateExpirationTime)) { + var hasContext = !0; + pushContextProvider(workInProgress); + } else hasContext = !1; + workInProgress.memoizedState = + null !== context.state && void 0 !== context.state + ? context.state + : null; + var getDerivedStateFromProps = + updateExpirationTime.getDerivedStateFromProps; + "function" === typeof getDerivedStateFromProps && + applyDerivedStateFromProps( workInProgress, - Component - )), - resolvedProps = resolveDefaultProps(Component, props), - child = void 0; - switch (resolvedTag) { - case 1: - child = updateFunctionComponent( - current$$1, - workInProgress, - Component, - resolvedProps, - renderExpirationTime - ); - break; - case 3: - child = updateClassComponent( - current$$1, - workInProgress, - Component, - resolvedProps, - renderExpirationTime - ); - break; - case 14: - child = updateForwardRef( - current$$1, - workInProgress, - Component, - resolvedProps, - renderExpirationTime - ); - break; - case 18: - child = updatePureComponent( - current$$1, - workInProgress, - Component, - resolvedProps, - updateExpirationTime, - renderExpirationTime - ); - break; - default: - invariant( - !1, - "Element type is invalid. Received a promise that resolves to: %s. Promise elements must resolve to a class or function.", - Component - ); - } - workInProgress.memoizedProps = props; - workInProgress = child; - } else - (updateExpirationTime = getMaskedContext( + updateExpirationTime, + getDerivedStateFromProps, + current$$1 + ); + context.updater = classComponentUpdater; + workInProgress.stateNode = context; + context._reactInternalFiber = workInProgress; + mountClassInstance( workInProgress, - contextStackCursor.current - )), - prepareToReadContext(workInProgress, renderExpirationTime), - (updateExpirationTime = Component(props, updateExpirationTime)), - (workInProgress.effectTag |= 1), - "object" === typeof updateExpirationTime && - null !== updateExpirationTime && - "function" === typeof updateExpirationTime.render && - void 0 === updateExpirationTime.$$typeof - ? ((workInProgress.tag = 2), - isContextProvider(Component) - ? ((resolvedTag = !0), pushContextProvider(workInProgress)) - : (resolvedTag = !1), - (workInProgress.memoizedState = - null !== updateExpirationTime.state && - void 0 !== updateExpirationTime.state - ? updateExpirationTime.state - : null), - (resolvedProps = Component.getDerivedStateFromProps), - "function" === typeof resolvedProps && - applyDerivedStateFromProps( - workInProgress, - Component, - resolvedProps, - props - ), - (updateExpirationTime.updater = classComponentUpdater), - (workInProgress.stateNode = updateExpirationTime), - (updateExpirationTime._reactInternalFiber = workInProgress), - mountClassInstance( - workInProgress, - Component, - props, - renderExpirationTime - ), - (workInProgress = finishClassComponent( - current$$1, - workInProgress, - Component, - !0, - resolvedTag, - renderExpirationTime - ))) - : ((workInProgress.tag = 0), - reconcileChildren( - current$$1, - workInProgress, - updateExpirationTime, - renderExpirationTime - ), - (workInProgress.memoizedProps = props), - (workInProgress = workInProgress.child)); + updateExpirationTime, + current$$1, + renderExpirationTime + ); + workInProgress = finishClassComponent( + null, + workInProgress, + updateExpirationTime, + !0, + hasContext, + renderExpirationTime + ); + } else + (workInProgress.tag = 0), + reconcileChildren( + null, + workInProgress, + context, + renderExpirationTime + ), + (workInProgress = workInProgress.child); return workInProgress; + case 16: + context = workInProgress.elementType; + null !== current$$1 && + ((current$$1.alternate = null), + (workInProgress.alternate = null), + (workInProgress.effectTag |= 2)); + hasContext = workInProgress.pendingProps; + current$$1 = readLazyComponentType(context); + workInProgress.type = current$$1; + context = workInProgress.tag = resolveLazyComponentTag(current$$1); + hasContext = resolveDefaultProps(current$$1, hasContext); + getDerivedStateFromProps = void 0; + switch (context) { + case 0: + getDerivedStateFromProps = updateFunctionComponent( + null, + workInProgress, + current$$1, + hasContext, + renderExpirationTime + ); + break; + case 1: + getDerivedStateFromProps = updateClassComponent( + null, + workInProgress, + current$$1, + hasContext, + renderExpirationTime + ); + break; + case 11: + getDerivedStateFromProps = updateForwardRef( + null, + workInProgress, + current$$1, + hasContext, + renderExpirationTime + ); + break; + case 14: + getDerivedStateFromProps = updateMemoComponent( + null, + workInProgress, + current$$1, + resolveDefaultProps(current$$1.type, hasContext), + 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.", + current$$1 + ); + } + return getDerivedStateFromProps; case 0: - return updateFunctionComponent( - current$$1, - workInProgress, - workInProgress.type, - workInProgress.pendingProps, - renderExpirationTime - ); - case 1: return ( - (props = workInProgress.type._reactResult), - (Component = workInProgress.pendingProps), - (current$$1 = updateFunctionComponent( + (updateExpirationTime = workInProgress.type), + (context = workInProgress.pendingProps), + (context = + workInProgress.elementType === updateExpirationTime + ? context + : resolveDefaultProps(updateExpirationTime, context)), + updateFunctionComponent( current$$1, workInProgress, - props, - resolveDefaultProps(props, Component), + updateExpirationTime, + context, renderExpirationTime - )), - (workInProgress.memoizedProps = Component), - current$$1 - ); - case 2: - return updateClassComponent( - current$$1, - workInProgress, - workInProgress.type, - workInProgress.pendingProps, - renderExpirationTime + ) ); - case 3: + case 1: return ( - (props = workInProgress.type._reactResult), - (Component = workInProgress.pendingProps), - (current$$1 = updateClassComponent( + (updateExpirationTime = workInProgress.type), + (context = workInProgress.pendingProps), + (context = + workInProgress.elementType === updateExpirationTime + ? context + : resolveDefaultProps(updateExpirationTime, context)), + updateClassComponent( current$$1, workInProgress, - props, - resolveDefaultProps(props, Component), + updateExpirationTime, + context, renderExpirationTime - )), - (workInProgress.memoizedProps = Component), - current$$1 + ) ); - case 5: + case 3: return ( pushHostRootContext(workInProgress), - (Component = workInProgress.updateQueue), + (updateExpirationTime = workInProgress.updateQueue), invariant( - null !== Component, + null !== updateExpirationTime, "If the root does not have an updateQueue, we should have already bailed out. This error is likely caused by a bug in React. Please file an issue." ), - (props = workInProgress.memoizedState), - (props = null !== props ? props.element : null), + (context = workInProgress.memoizedState), + (context = null !== context ? context.element : null), processUpdateQueue( workInProgress, - Component, + updateExpirationTime, workInProgress.pendingProps, null, renderExpirationTime ), - (Component = workInProgress.memoizedState.element), - Component === props + (updateExpirationTime = workInProgress.memoizedState.element), + updateExpirationTime === context ? (workInProgress = bailoutOnAlreadyFinishedWork( current$$1, workInProgress, @@ -4067,186 +4257,131 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { : (reconcileChildren( current$$1, workInProgress, - Component, + updateExpirationTime, renderExpirationTime ), (workInProgress = workInProgress.child)), workInProgress ); - case 7: + case 5: return ( pushHostContext(workInProgress), null === current$$1 && tryToClaimNextHydratableInstance(workInProgress), - (Component = workInProgress.pendingProps), - (props = Component.children), + (updateExpirationTime = workInProgress.pendingProps.children), markRef(current$$1, workInProgress), reconcileChildren( current$$1, workInProgress, - props, + updateExpirationTime, renderExpirationTime ), - (workInProgress.memoizedProps = Component), (workInProgress = workInProgress.child), workInProgress ); - case 8: + case 6: return ( null === current$$1 && tryToClaimNextHydratableInstance(workInProgress), - (workInProgress.memoizedProps = workInProgress.pendingProps), null ); - case 16: - return ( - (Component = workInProgress.pendingProps), - (props = 0 === (workInProgress.effectTag & 64)), - null !== current$$1 && null !== workInProgress.updateQueue - ? ((workInProgress.updateQueue = null), (props = !0)) - : (props = !props), - 0 !== (workInProgress.mode & 2) && - (props - ? (workInProgress.effectTag |= 4) - : (workInProgress.stateNode = null)), - (updateExpirationTime = Component.children), - (updateExpirationTime = - "function" === typeof updateExpirationTime - ? updateExpirationTime(props) - : props - ? Component.fallback - : updateExpirationTime), - null !== current$$1 && props !== workInProgress.memoizedState - ? ((workInProgress.child = reconcileChildFibers( - workInProgress, - current$$1.child, - null, - renderExpirationTime - )), - (workInProgress.child = reconcileChildFibers( - workInProgress, - null, - updateExpirationTime, - renderExpirationTime - ))) - : reconcileChildren( - current$$1, - workInProgress, - updateExpirationTime, - renderExpirationTime - ), - (workInProgress.memoizedProps = Component), - (workInProgress.memoizedState = props), - workInProgress.child + case 13: + return updateSuspenseComponent( + current$$1, + workInProgress, + renderExpirationTime ); - case 6: + case 4: return ( pushHostContainer( workInProgress, workInProgress.stateNode.containerInfo ), - (Component = workInProgress.pendingProps), + (updateExpirationTime = workInProgress.pendingProps), null === current$$1 ? (workInProgress.child = reconcileChildFibers( workInProgress, null, - Component, + updateExpirationTime, renderExpirationTime )) : reconcileChildren( current$$1, workInProgress, - Component, + updateExpirationTime, renderExpirationTime ), - (workInProgress.memoizedProps = Component), workInProgress.child ); - case 13: - return updateForwardRef( - current$$1, - workInProgress, - workInProgress.type, - workInProgress.pendingProps, - renderExpirationTime - ); - case 14: + case 11: return ( - (props = workInProgress.type._reactResult), - (Component = workInProgress.pendingProps), - (current$$1 = updateForwardRef( + (updateExpirationTime = workInProgress.type), + (context = workInProgress.pendingProps), + (context = + workInProgress.elementType === updateExpirationTime + ? context + : resolveDefaultProps(updateExpirationTime, context)), + updateForwardRef( current$$1, workInProgress, - props, - resolveDefaultProps(props, Component), + updateExpirationTime, + context, renderExpirationTime - )), - (workInProgress.memoizedProps = Component), - current$$1 + ) ); - case 9: + case 7: return ( - (Component = workInProgress.pendingProps), reconcileChildren( current$$1, workInProgress, - Component, + workInProgress.pendingProps, renderExpirationTime ), - (workInProgress.memoizedProps = Component), workInProgress.child ); - case 10: + case 8: return ( - (Component = workInProgress.pendingProps.children), reconcileChildren( current$$1, workInProgress, - Component, + workInProgress.pendingProps.children, renderExpirationTime ), - (workInProgress.memoizedProps = Component), workInProgress.child ); - case 15: + case 12: return ( (workInProgress.effectTag |= 4), - (Component = workInProgress.pendingProps), reconcileChildren( current$$1, workInProgress, - Component.children, + workInProgress.pendingProps.children, renderExpirationTime ), - (workInProgress.memoizedProps = Component), workInProgress.child ); - case 12: + case 10: a: { - Component = workInProgress.type._context; - props = workInProgress.pendingProps; - resolvedTag = workInProgress.memoizedProps; - updateExpirationTime = props.value; - workInProgress.memoizedProps = props; - pushProvider(workInProgress, updateExpirationTime); - if (null !== resolvedTag) - if ( - ((resolvedProps = resolvedTag.value), - (updateExpirationTime = - (resolvedProps === updateExpirationTime && - (0 !== resolvedProps || - 1 / resolvedProps === 1 / updateExpirationTime)) || - (resolvedProps !== resolvedProps && - updateExpirationTime !== updateExpirationTime) - ? 0 - : ("function" === typeof Component._calculateChangedBits - ? Component._calculateChangedBits( - resolvedProps, - updateExpirationTime - ) - : 1073741823) | 0), - 0 === updateExpirationTime) - ) { + updateExpirationTime = workInProgress.type._context; + context = workInProgress.pendingProps; + getDerivedStateFromProps = workInProgress.memoizedProps; + hasContext = context.value; + pushProvider(workInProgress, hasContext); + if (null !== getDerivedStateFromProps) { + var oldValue = getDerivedStateFromProps.value; + hasContext = + (oldValue === hasContext && + (0 !== oldValue || 1 / oldValue === 1 / hasContext)) || + (oldValue !== oldValue && hasContext !== hasContext) + ? 0 + : ("function" === + typeof updateExpirationTime._calculateChangedBits + ? updateExpirationTime._calculateChangedBits( + oldValue, + hasContext + ) + : 1073741823) | 0; + if (0 === hasContext) { if ( - resolvedTag.children === props.children && + getDerivedStateFromProps.children === context.children && !didPerformWorkStackCursor.current ) { workInProgress = bailoutOnAlreadyFinishedWork( @@ -4258,113 +4393,129 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { } } else for ( - resolvedTag = workInProgress.child, - null !== resolvedTag && (resolvedTag.return = workInProgress); - null !== resolvedTag; + getDerivedStateFromProps = workInProgress.child, + null !== getDerivedStateFromProps && + (getDerivedStateFromProps.return = workInProgress); + null !== getDerivedStateFromProps; ) { - resolvedProps = resolvedTag.firstContextDependency; - if (null !== resolvedProps) { + oldValue = getDerivedStateFromProps.firstContextDependency; + if (null !== oldValue) { do { if ( - resolvedProps.context === Component && - 0 !== (resolvedProps.observedBits & updateExpirationTime) + oldValue.context === updateExpirationTime && + 0 !== (oldValue.observedBits & hasContext) ) { - 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 ( - 0 === node.childExpirationTime || - node.childExpirationTime > renderExpirationTime - ) + if (1 === getDerivedStateFromProps.tag) { + var nextFiber = createUpdate(renderExpirationTime); + nextFiber.tag = 2; + enqueueUpdate(getDerivedStateFromProps, nextFiber); + } + getDerivedStateFromProps.expirationTime < + renderExpirationTime && + (getDerivedStateFromProps.expirationTime = renderExpirationTime); + nextFiber = getDerivedStateFromProps.alternate; + null !== nextFiber && + nextFiber.expirationTime < renderExpirationTime && + (nextFiber.expirationTime = renderExpirationTime); + for ( + var node = getDerivedStateFromProps.return; + null !== node; + + ) { + nextFiber = node.alternate; + if (node.childExpirationTime < renderExpirationTime) (node.childExpirationTime = renderExpirationTime), - null !== child && - (0 === child.childExpirationTime || - child.childExpirationTime > - renderExpirationTime) && - (child.childExpirationTime = renderExpirationTime); + null !== nextFiber && + nextFiber.childExpirationTime < + renderExpirationTime && + (nextFiber.childExpirationTime = renderExpirationTime); else if ( - null !== child && - (0 === child.childExpirationTime || - child.childExpirationTime > renderExpirationTime) + null !== nextFiber && + nextFiber.childExpirationTime < renderExpirationTime ) - child.childExpirationTime = renderExpirationTime; + nextFiber.childExpirationTime = renderExpirationTime; else break; node = node.return; } } - child = resolvedTag.child; - resolvedProps = resolvedProps.next; - } while (null !== resolvedProps); + nextFiber = getDerivedStateFromProps.child; + oldValue = oldValue.next; + } while (null !== oldValue); } else - child = - 12 === resolvedTag.tag - ? resolvedTag.type === workInProgress.type + nextFiber = + 10 === getDerivedStateFromProps.tag + ? getDerivedStateFromProps.type === workInProgress.type ? null - : resolvedTag.child - : resolvedTag.child; - if (null !== child) child.return = resolvedTag; + : getDerivedStateFromProps.child + : getDerivedStateFromProps.child; + if (null !== nextFiber) + nextFiber.return = getDerivedStateFromProps; else - for (child = resolvedTag; null !== child; ) { - if (child === workInProgress) { - child = null; + for ( + nextFiber = getDerivedStateFromProps; + null !== nextFiber; + + ) { + if (nextFiber === workInProgress) { + nextFiber = null; break; } - resolvedTag = child.sibling; - if (null !== resolvedTag) { - resolvedTag.return = child.return; - child = resolvedTag; + getDerivedStateFromProps = nextFiber.sibling; + if (null !== getDerivedStateFromProps) { + getDerivedStateFromProps.return = nextFiber.return; + nextFiber = getDerivedStateFromProps; break; } - child = child.return; + nextFiber = nextFiber.return; } - resolvedTag = child; + getDerivedStateFromProps = nextFiber; } + } reconcileChildren( current$$1, workInProgress, - props.children, + context.children, renderExpirationTime ); workInProgress = workInProgress.child; } return workInProgress; - case 11: + case 9: return ( - (updateExpirationTime = workInProgress.type), - (Component = workInProgress.pendingProps), - (props = Component.children), + (context = workInProgress.type), + (hasContext = workInProgress.pendingProps), + (updateExpirationTime = hasContext.children), prepareToReadContext(workInProgress, renderExpirationTime), - (updateExpirationTime = readContext( - updateExpirationTime, - Component.unstable_observedBits - )), - (props = props(updateExpirationTime)), + (context = readContext(context, hasContext.unstable_observedBits)), + (updateExpirationTime = updateExpirationTime(context)), (workInProgress.effectTag |= 1), reconcileChildren( current$$1, workInProgress, - props, + updateExpirationTime, renderExpirationTime ), - (workInProgress.memoizedProps = Component), workInProgress.child ); - case 17: - return updatePureComponent( + case 14: + return ( + (context = workInProgress.type), + (hasContext = resolveDefaultProps( + context.type, + workInProgress.pendingProps + )), + updateMemoComponent( + current$$1, + workInProgress, + context, + hasContext, + updateExpirationTime, + renderExpirationTime + ) + ); + case 15: + return updateSimpleMemoComponent( current$$1, workInProgress, workInProgress.type, @@ -4372,20 +4523,43 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { updateExpirationTime, renderExpirationTime ); - case 18: + case 17: return ( - (props = workInProgress.type._reactResult), - (Component = workInProgress.pendingProps), - (current$$1 = updatePureComponent( - current$$1, + (updateExpirationTime = workInProgress.type), + (context = workInProgress.pendingProps), + (context = + workInProgress.elementType === updateExpirationTime + ? context + : resolveDefaultProps(updateExpirationTime, context)), + 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), + constructClassInstance( workInProgress, - props, - resolveDefaultProps(props, Component), updateExpirationTime, + context, renderExpirationTime - )), - (workInProgress.memoizedProps = Component), - current$$1 + ), + mountClassInstance( + workInProgress, + updateExpirationTime, + context, + renderExpirationTime + ), + finishClassComponent( + null, + workInProgress, + updateExpirationTime, + !0, + current$$1, + renderExpirationTime + ) ); default: invariant( @@ -4394,9 +4568,27 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { ); } } -var updateHostContainer = void 0, +var appendAllChildren = void 0, + updateHostContainer = void 0, updateHostComponent$1 = void 0, updateHostText$1 = void 0; +appendAllChildren = function(parent, workInProgress) { + for (var node = workInProgress.child; null !== node; ) { + if (5 === node.tag || 6 === node.tag) parent._children.push(node.stateNode); + else if (4 !== node.tag && null !== node.child) { + node.child.return = node; + node = node.child; + continue; + } + if (node === workInProgress) break; + for (; null === node.sibling; ) { + if (null === node.return || node.return === workInProgress) return; + node = node.return; + } + node.sibling.return = node.return; + node = node.sibling; + } +}; updateHostContainer = function() {}; updateHostComponent$1 = function(current, workInProgress, type, newProps) { current.memoizedProps !== newProps && @@ -4426,7 +4618,6 @@ function logCapturedError(capturedError) { : Error("Unspecified error at:" + componentStack); ExceptionsManager.handleException(error, !1); } -var emptyObject$1 = {}; function logError(boundary, errorInfo) { var source = errorInfo.source, stack = errorInfo.stack; @@ -4443,7 +4634,7 @@ function logError(boundary, errorInfo) { willRetry: !1 }; null !== boundary && - 2 === boundary.tag && + 1 === boundary.tag && ((errorInfo.errorBoundary = boundary.stateNode), (errorInfo.errorBoundaryName = getComponentName(boundary.type)), (errorInfo.errorBoundaryFound = !0), @@ -4467,32 +4658,55 @@ function safelyDetachRef(current$$1) { } else ref.current = null; } -function commitUnmount(current$$1) { +function commitUnmount(current$$1$jscomp$0) { "function" === typeof onCommitFiberUnmount && - onCommitFiberUnmount(current$$1); - switch (current$$1.tag) { - case 2: - case 3: - safelyDetachRef(current$$1); - var instance = current$$1.stateNode; - if ("function" === typeof instance.componentWillUnmount) + onCommitFiberUnmount(current$$1$jscomp$0); + switch (current$$1$jscomp$0.tag) { + case 0: + case 11: + case 14: + case 15: + var updateQueue = current$$1$jscomp$0.updateQueue; + if ( + null !== updateQueue && + ((updateQueue = updateQueue.lastEffect), null !== updateQueue) + ) { + var effect = (updateQueue = updateQueue.next); + do { + var destroy = effect.destroy; + if (null !== destroy) { + var current$$1 = current$$1$jscomp$0; + try { + destroy(); + } catch (error) { + captureCommitPhaseError(current$$1, error); + } + } + effect = effect.next; + } while (effect !== updateQueue); + } + break; + case 1: + safelyDetachRef(current$$1$jscomp$0); + updateQueue = current$$1$jscomp$0.stateNode; + if ("function" === typeof updateQueue.componentWillUnmount) try { - (instance.props = current$$1.memoizedProps), - (instance.state = current$$1.memoizedState), - instance.componentWillUnmount(); + (updateQueue.props = current$$1$jscomp$0.memoizedProps), + (updateQueue.state = current$$1$jscomp$0.memoizedState), + updateQueue.componentWillUnmount(); } catch (unmountError) { - captureCommitPhaseError(current$$1, unmountError); + captureCommitPhaseError(current$$1$jscomp$0, unmountError); } break; - case 7: - safelyDetachRef(current$$1); + case 5: + safelyDetachRef(current$$1$jscomp$0); break; - case 6: - unmountHostComponents(current$$1); + case 4: + unmountHostComponents(current$$1$jscomp$0); } } function isHostParent(fiber) { - return 7 === fiber.tag || 5 === fiber.tag || 6 === fiber.tag; + return 5 === fiber.tag || 3 === fiber.tag || 4 === fiber.tag; } function commitPlacement(finishedWork) { a: { @@ -4511,15 +4725,15 @@ function commitPlacement(finishedWork) { } var isContainer = (parent = void 0); switch (parentFiber.tag) { - case 7: + case 5: parent = parentFiber.stateNode; isContainer = !1; break; - case 5: + case 3: parent = parentFiber.stateNode.containerInfo; isContainer = !0; break; - case 6: + case 4: parent = parentFiber.stateNode.containerInfo; isContainer = !0; break; @@ -4541,11 +4755,11 @@ function commitPlacement(finishedWork) { parentFiber.sibling.return = parentFiber.return; for ( parentFiber = parentFiber.sibling; - 7 !== parentFiber.tag && 8 !== parentFiber.tag; + 5 !== parentFiber.tag && 6 !== parentFiber.tag; ) { if (parentFiber.effectTag & 2) continue b; - if (null === parentFiber.child || 6 === parentFiber.tag) continue b; + if (null === parentFiber.child || 4 === parentFiber.tag) continue b; else (parentFiber.child.return = parentFiber), (parentFiber = parentFiber.child); @@ -4556,7 +4770,7 @@ function commitPlacement(finishedWork) { } } for (var node = finishedWork; ; ) { - if (7 === node.tag || 8 === node.tag) + if (5 === node.tag || 6 === node.tag) if (parentFiber) if (isContainer) invariant( @@ -4625,7 +4839,7 @@ function commitPlacement(finishedWork) { [index.length - 1], [] ))); - else if (6 !== node.tag && null !== node.child) { + else if (4 !== node.tag && null !== node.child) { node.child.return = node; node = node.child; continue; @@ -4656,15 +4870,15 @@ function unmountHostComponents(current$$1) { "Expected to find a host parent. This error is likely caused by a bug in React. Please file an issue." ); switch (currentParentIsValid.tag) { - case 7: + case 5: currentParent = currentParentIsValid.stateNode; currentParentIsContainer = !1; break a; - case 5: + case 3: currentParent = currentParentIsValid.stateNode.containerInfo; currentParentIsContainer = !0; break a; - case 6: + case 4: currentParent = currentParentIsValid.stateNode.containerInfo; currentParentIsContainer = !0; break a; @@ -4673,11 +4887,11 @@ function unmountHostComponents(current$$1) { } currentParentIsValid = !0; } - if (7 === node.tag || 8 === node.tag) { + if (5 === node.tag || 6 === node.tag) { a: for (var root = node, node$jscomp$0 = root; ; ) if ( (commitUnmount(node$jscomp$0), - null !== node$jscomp$0.child && 6 !== node$jscomp$0.tag) + null !== node$jscomp$0.child && 4 !== node$jscomp$0.tag) ) (node$jscomp$0.child.return = node$jscomp$0), (node$jscomp$0 = node$jscomp$0.child); @@ -4705,7 +4919,7 @@ function unmountHostComponents(current$$1) { UIManager.manageChildren(root._nativeTag, [], [], [], [], [child]); } } else if ( - (6 === node.tag + (4 === node.tag ? ((currentParent = node.stateNode.containerInfo), (currentParentIsContainer = !0)) : commitUnmount(node), @@ -4719,7 +4933,7 @@ function unmountHostComponents(current$$1) { for (; null === node.sibling; ) { if (null === node.return || node.return === current$$1) return; node = node.return; - 6 === node.tag && (currentParentIsValid = !1); + 4 === node.tag && (currentParentIsValid = !1); } node.sibling.return = node.return; node = node.sibling; @@ -4727,10 +4941,14 @@ function unmountHostComponents(current$$1) { } function commitWork(current$$1, finishedWork) { switch (finishedWork.tag) { - case 2: - case 3: + case 0: + case 11: + case 14: + case 15: break; - case 7: + case 1: + break; + case 5: var instance = finishedWork.stateNode; if (null != instance) { var newProps = finishedWork.memoizedProps; @@ -4754,7 +4972,7 @@ function commitWork(current$$1, finishedWork) { )); } break; - case 8: + case 6: invariant( null !== finishedWork.stateNode, "This should have a text node initialized. This error is likely caused by a bug in React. Please file an issue." @@ -4763,11 +4981,73 @@ function commitWork(current$$1, finishedWork) { text: finishedWork.memoizedProps }); break; - case 5: + case 3: break; - case 15: + case 12: break; - case 16: + case 13: + newProps = finishedWork.memoizedState; + current$$1 = finishedWork; + null === newProps + ? (instance = !1) + : ((instance = !0), + (current$$1 = finishedWork.child), + 0 === newProps.timedOutAt && + (newProps.timedOutAt = requestCurrentTime())); + if (null !== current$$1) + a: for (newProps = finishedWork = current$$1; ; ) { + if (5 === newProps.tag) + if (((current$$1 = newProps.stateNode), instance)) { + updatePayload = current$$1.viewConfig; + var updatePayload$jscomp$0 = diffProperties( + null, + emptyObject, + { style: { display: "none" } }, + updatePayload.validAttributes + ); + UIManager.updateView( + current$$1._nativeTag, + updatePayload.uiViewClassName, + updatePayload$jscomp$0 + ); + } else { + current$$1 = newProps.stateNode; + updatePayload$jscomp$0 = newProps.memoizedProps; + updatePayload = current$$1.viewConfig; + var prevProps = Object.assign({}, updatePayload$jscomp$0, { + style: [updatePayload$jscomp$0.style, { display: "none" }] + }); + updatePayload$jscomp$0 = diffProperties( + null, + prevProps, + updatePayload$jscomp$0, + updatePayload.validAttributes + ); + UIManager.updateView( + current$$1._nativeTag, + updatePayload.uiViewClassName, + updatePayload$jscomp$0 + ); + } + else { + if (6 === newProps.tag) throw Error("Not yet implemented."); + if (null !== newProps.child) { + newProps.child.return = newProps; + newProps = newProps.child; + continue; + } + } + if (newProps === finishedWork) break a; + for (; null === newProps.sibling; ) { + if (null === newProps.return || newProps.return === finishedWork) + break a; + newProps = newProps.return; + } + newProps.sibling.return = newProps.return; + newProps = newProps.sibling; + } + break; + case 17: break; default: invariant( @@ -4776,9 +5056,6 @@ function commitWork(current$$1, finishedWork) { ); } } -function NoopComponent() { - return null; -} function createRootErrorUpdate(fiber, errorInfo, expirationTime) { expirationTime = createUpdate(expirationTime); expirationTime.tag = 3; @@ -4824,7 +5101,7 @@ function throwException( value, renderExpirationTime ) { - sourceFiber.effectTag |= 512; + sourceFiber.effectTag |= 1024; sourceFiber.firstEffect = sourceFiber.lastEffect = null; if ( null !== value && @@ -4836,49 +5113,54 @@ function throwException( var earliestTimeoutMs = -1, startTimeMs = -1; do { - if (16 === value.tag) { - var current = value.alternate; + if (13 === value.tag) { + var current$$1 = value.alternate; if ( - null !== current && - !0 === current.memoizedState && - null !== current.stateNode + null !== current$$1 && + ((current$$1 = current$$1.memoizedState), null !== current$$1) ) { - startTimeMs = 10 * (current.stateNode.timedOutAt - 2); + startTimeMs = 10 * (1073741822 - current$$1.timedOutAt); break; } - current = value.pendingProps.maxDuration; - if ("number" === typeof current) - if (0 >= current) earliestTimeoutMs = 0; - else if (-1 === earliestTimeoutMs || current < earliestTimeoutMs) - earliestTimeoutMs = current; + current$$1 = value.pendingProps.maxDuration; + if ("number" === typeof current$$1) + if (0 >= current$$1) earliestTimeoutMs = 0; + else if (-1 === earliestTimeoutMs || current$$1 < earliestTimeoutMs) + earliestTimeoutMs = current$$1; } value = value.return; } while (null !== value); value = returnFiber; do { - if (16 === value.tag && !value.memoizedState) { + if ((current$$1 = 13 === value.tag)) + current$$1 = + void 0 === value.memoizedProps.fallback + ? !1 + : null === value.memoizedState; + if (current$$1) { returnFiber = retrySuspendedRoot.bind( null, root, value, - 0 === (value.mode & 1) ? 1 : renderExpirationTime + sourceFiber, + 0 === (value.mode & 1) ? 1073741823 : renderExpirationTime ); returnFiber = tracing.unstable_wrap(returnFiber); thenable.then(returnFiber, returnFiber); - if (0 === (value.mode & 2)) { - value.effectTag |= 4; + if (0 === (value.mode & 1)) { + value.effectTag |= 64; reconcileChildren( sourceFiber.alternate, sourceFiber, null, renderExpirationTime ); - sourceFiber.effectTag &= -513; - 4 === sourceFiber.tag && (sourceFiber.tag = 0); - if (2 === sourceFiber.tag || 3 === sourceFiber.tag) - (sourceFiber.effectTag &= -421), - null === sourceFiber.alternate && - ((sourceFiber.tag = 0), (sourceFiber.type = NoopComponent)); + sourceFiber.effectTag &= -1025; + sourceFiber.effectTag &= -933; + 1 === sourceFiber.tag && + null === sourceFiber.alternate && + (sourceFiber.tag = 17); + sourceFiber.expirationTime = renderExpirationTime; return; } -1 === earliestTimeoutMs @@ -4886,24 +5168,26 @@ function throwException( : (-1 === startTimeMs && (startTimeMs = 10 * - (findEarliestOutstandingPriorityLevel( - root, - renderExpirationTime - ) - - 2) - + (1073741822 - + findEarliestOutstandingPriorityLevel( + root, + renderExpirationTime + )) - 5e3), (root = startTimeMs + earliestTimeoutMs)); 0 <= root && nextLatestAbsoluteTimeoutMs < root && (nextLatestAbsoluteTimeoutMs = root); - value.effectTag |= 1024; + value.effectTag |= 2048; value.expirationTime = renderExpirationTime; return; } value = value.return; } while (null !== value); value = Error( - "An update was suspended, but no placeholder UI was provided." + (getComponentName(sourceFiber.type) || "A React component") + + " suspended while rendering, but no fallback UI was specified.\n\nAdd a component higher in the tree to provide a loading indicator or placeholder to display." + + getStackByFiberInDevAndProd(sourceFiber) ); } nextRenderDidError = !0; @@ -4911,9 +5195,9 @@ function throwException( root = returnFiber; do { switch (root.tag) { - case 5: + case 3: sourceFiber = value; - root.effectTag |= 1024; + root.effectTag |= 2048; root.expirationTime = renderExpirationTime; renderExpirationTime = createRootErrorUpdate( root, @@ -4922,8 +5206,7 @@ function throwException( ); enqueueCapturedUpdate(root, renderExpirationTime); return; - case 2: - case 3: + case 1: if ( ((sourceFiber = value), (returnFiber = root.type), @@ -4935,7 +5218,7 @@ function throwException( (null === legacyErrorBoundariesThatAlreadyFailed || !legacyErrorBoundariesThatAlreadyFailed.has(thenable))))) ) { - root.effectTag |= 1024; + root.effectTag |= 2048; root.expirationTime = renderExpirationTime; renderExpirationTime = createClassErrorUpdate( root, @@ -4951,24 +5234,14 @@ function throwException( } function unwindWork(workInProgress) { switch (workInProgress.tag) { - case 2: + case 1: isContextProvider(workInProgress.type) && popContext(workInProgress); var effectTag = workInProgress.effectTag; - return effectTag & 1024 - ? ((workInProgress.effectTag = (effectTag & -1025) | 64), + return effectTag & 2048 + ? ((workInProgress.effectTag = (effectTag & -2049) | 64), workInProgress) : null; case 3: - return ( - isContextProvider(workInProgress.type._reactResult) && - popContext(workInProgress), - (effectTag = workInProgress.effectTag), - effectTag & 1024 - ? ((workInProgress.effectTag = (effectTag & -1025) | 64), - workInProgress) - : null - ); - case 5: return ( popHostContainer(workInProgress), popTopLevelContextObject(workInProgress), @@ -4977,28 +5250,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 & -1025) | 64), + (workInProgress.effectTag = (effectTag & -2049) | 64), workInProgress ); - case 7: + case 5: return popHostContext(workInProgress), null; - case 16: + case 13: return ( (effectTag = workInProgress.effectTag), - effectTag & 1024 - ? ((workInProgress.effectTag = (effectTag & -1025) | 64), + effectTag & 2048 + ? ((workInProgress.effectTag = (effectTag & -2049) | 64), workInProgress) : null ); - case 6: + case 4: return popHostContainer(workInProgress), null; - case 12: + case 10: return popProvider(workInProgress), null; default: return null; } } -var Dispatcher = { readContext: readContext }, +var DispatcherWithoutHooks = { readContext: readContext }, ReactCurrentOwner$2 = ReactSharedInternals.ReactCurrentOwner; invariant( null != tracing.__interactionsRef && @@ -5013,6 +5286,8 @@ var isWorking = !1, nextRenderDidError = !1, nextEffect = null, isCommitting$1 = !1, + passiveEffectCallbackHandle = null, + passiveEffectCallback = null, legacyErrorBoundariesThatAlreadyFailed = null; function resetStack() { if (null !== nextUnitOfWork) @@ -5023,7 +5298,7 @@ function resetStack() { ) { var interruptedWork$jscomp$0 = interruptedWork; switch (interruptedWork$jscomp$0.tag) { - case 2: + case 1: var childContextTypes = interruptedWork$jscomp$0.type.childContextTypes; null !== childContextTypes && @@ -5031,23 +5306,16 @@ function resetStack() { popContext(interruptedWork$jscomp$0); break; case 3: - childContextTypes = - interruptedWork$jscomp$0.type._reactResult.childContextTypes; - null !== childContextTypes && - void 0 !== childContextTypes && - popContext(interruptedWork$jscomp$0); - break; - case 5: popHostContainer(interruptedWork$jscomp$0); popTopLevelContextObject(interruptedWork$jscomp$0); break; - case 7: + case 5: popHostContext(interruptedWork$jscomp$0); break; - case 6: + case 4: popHostContainer(interruptedWork$jscomp$0); break; - case 12: + case 10: popProvider(interruptedWork$jscomp$0); } interruptedWork = interruptedWork.return; @@ -5097,30 +5365,34 @@ function commitAllHostEffects() { } function commitBeforeMutationLifecycles() { for (; null !== nextEffect; ) { - if (nextEffect.effectTag & 256) { - var current$$1 = nextEffect.alternate; + if (nextEffect.effectTag & 256) a: { - var finishedWork = nextEffect; + var current$$1 = nextEffect.alternate, + finishedWork = nextEffect; switch (finishedWork.tag) { - case 2: - case 3: + case 0: + case 11: + case 15: + break a; + case 1: if (finishedWork.effectTag & 256 && null !== current$$1) { var prevProps = current$$1.memoizedProps, prevState = current$$1.memoizedState; current$$1 = finishedWork.stateNode; - current$$1.props = finishedWork.memoizedProps; - current$$1.state = finishedWork.memoizedState; finishedWork = current$$1.getSnapshotBeforeUpdate( - prevProps, + finishedWork.elementType === finishedWork.type + ? prevProps + : resolveDefaultProps(finishedWork.type, prevProps), prevState ); current$$1.__reactInternalSnapshotBeforeUpdate = finishedWork; } break a; + case 3: case 5: - case 7: - case 8: case 6: + case 4: + case 17: break a; default: invariant( @@ -5129,7 +5401,6 @@ function commitBeforeMutationLifecycles() { ); } } - } nextEffect = nextEffect.nextEffect; } } @@ -5145,47 +5416,47 @@ function commitAllLifeCycles( finishedWork = nextEffect, committedExpirationTime = committedExpirationTime$jscomp$0; switch (finishedWork.tag) { - case 2: - case 3: + case 0: + case 11: + case 15: + break; + case 1: finishedRoot = finishedWork.stateNode; if (finishedWork.effectTag & 4) - if (null === current$$1) - (finishedRoot.props = finishedWork.memoizedProps), - (finishedRoot.state = finishedWork.memoizedState), - finishedRoot.componentDidMount(); + if (null === current$$1) finishedRoot.componentDidMount(); else { - var prevProps = current$$1.memoizedProps; - current$$1 = current$$1.memoizedState; - finishedRoot.props = finishedWork.memoizedProps; - finishedRoot.state = finishedWork.memoizedState; + var prevProps = + finishedWork.elementType === finishedWork.type + ? current$$1.memoizedProps + : resolveDefaultProps( + finishedWork.type, + current$$1.memoizedProps + ); finishedRoot.componentDidUpdate( prevProps, - current$$1, + current$$1.memoizedState, finishedRoot.__reactInternalSnapshotBeforeUpdate ); } current$$1 = finishedWork.updateQueue; null !== current$$1 && - ((finishedRoot.props = finishedWork.memoizedProps), - (finishedRoot.state = finishedWork.memoizedState), commitUpdateQueue( finishedWork, current$$1, finishedRoot, committedExpirationTime - )); + ); break; - case 5: + case 3: current$$1 = finishedWork.updateQueue; if (null !== current$$1) { finishedRoot = null; if (null !== finishedWork.child) switch (finishedWork.child.tag) { - case 7: + case 5: finishedRoot = finishedWork.child.stateNode; break; - case 2: - case 3: + case 1: finishedRoot = finishedWork.child.stateNode; } commitUpdateQueue( @@ -5196,13 +5467,13 @@ function commitAllLifeCycles( ); } break; - case 7: - break; - case 8: + case 5: break; case 6: break; - case 15: + case 4: + break; + case 12: committedExpirationTime = finishedWork.memoizedProps.onRender; committedExpirationTime( finishedWork.memoizedProps.id, @@ -5214,14 +5485,9 @@ function commitAllLifeCycles( finishedRoot.memoizedInteractions ); break; - case 16: - 0 === (finishedWork.mode & 2) - ? ((finishedWork.updateQueue = emptyObject$1), - scheduleWork(finishedWork, 1)) - : ((committedExpirationTime = requestCurrentTime()), - (finishedWork.stateNode = { - timedOutAt: committedExpirationTime - })); + case 13: + break; + case 17: break; default: invariant( @@ -5237,11 +5503,14 @@ function commitAllLifeCycles( "function" === typeof effectTag ? effectTag(finishedWork) : (effectTag.current = finishedWork))); - effectTag = nextEffect.nextEffect; - nextEffect.nextEffect = null; - nextEffect = effectTag; + nextEffect = nextEffect.nextEffect; } } +function flushPassiveEffects() { + null !== passiveEffectCallback && + (scheduler.unstable_cancelCallback(passiveEffectCallbackHandle), + passiveEffectCallback()); +} function commitRoot(root, finishedWork) { isCommitting$1 = isWorking = !0; invariant( @@ -5258,9 +5527,7 @@ function commitRoot(root, finishedWork) { childExpirationTimeBeforeCommit = finishedWork.childExpirationTime; markCommittedPriorityLevels( root, - 0 === updateExpirationTimeBeforeCommit || - (0 !== childExpirationTimeBeforeCommit && - childExpirationTimeBeforeCommit < updateExpirationTimeBeforeCommit) + childExpirationTimeBeforeCommit > updateExpirationTimeBeforeCommit ? childExpirationTimeBeforeCommit : updateExpirationTimeBeforeCommit ); @@ -5331,8 +5598,7 @@ function commitRoot(root, finishedWork) { childExpirationTimeBeforeCommit = finishedWork.expirationTime; finishedWork = finishedWork.childExpirationTime; var earliestRemainingTimeAfterCommit = - 0 === childExpirationTimeBeforeCommit || - (0 !== finishedWork && finishedWork < childExpirationTimeBeforeCommit) + finishedWork > childExpirationTimeBeforeCommit ? finishedWork : childExpirationTimeBeforeCommit; 0 === earliestRemainingTimeAfterCommit && @@ -5357,21 +5623,18 @@ function commitRoot(root, finishedWork) { scheduledInteractions, scheduledExpirationTime ) { - if ( - 0 === earliestRemainingTimeAfterCommit || - scheduledExpirationTime < earliestRemainingTimeAfterCommit - ) - pendingInteractionMap.delete(scheduledExpirationTime), - scheduledInteractions.forEach(function(interaction) { - interaction.__count--; - if (null !== subscriber && 0 === interaction.__count) - try { - subscriber.onInteractionScheduledWorkCompleted(interaction); - } catch (error) { - hasUnhandledError || - ((hasUnhandledError = !0), (unhandledError = error)); - } - }); + scheduledExpirationTime > earliestRemainingTimeAfterCommit && + (pendingInteractionMap.delete(scheduledExpirationTime), + scheduledInteractions.forEach(function(interaction) { + interaction.__count--; + if (null !== subscriber && 0 === interaction.__count) + try { + subscriber.onInteractionScheduledWorkCompleted(interaction); + } catch (error) { + hasUnhandledError || + ((hasUnhandledError = !0), (unhandledError = error)); + } + })); }); } } @@ -5380,228 +5643,220 @@ function completeUnitOfWork(workInProgress) { var current$$1 = workInProgress.alternate, returnFiber = workInProgress.return, siblingFiber = workInProgress.sibling; - if (0 === (workInProgress.effectTag & 512)) { + if (0 === (workInProgress.effectTag & 1024)) { + nextUnitOfWork = workInProgress; if (workInProgress.mode & 4) { var fiber = workInProgress; profilerStartTime = now$1(); 0 > fiber.actualStartTime && (fiber.actualStartTime = now$1()); } - var current = current$$1; - current$$1 = workInProgress; - fiber = current$$1.pendingProps; - switch (current$$1.tag) { - case 0: - 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; - fiber.pendingContext && - ((fiber.context = fiber.pendingContext), - (fiber.pendingContext = null)); - if (null === current || null === current.child) - current$$1.effectTag &= -3; - updateHostContainer(current$$1); - break; - case 7: - popHostContext(current$$1); - var rootContainerInstance = requiredContext( + a: { + var current = current$$1; + current$$1 = workInProgress; + var renderExpirationTime = nextRenderExpirationTime; + fiber = current$$1.pendingProps; + switch (current$$1.tag) { + case 2: + break; + case 16: + break; + case 15: + case 0: + break; + case 1: + isContextProvider(current$$1.type) && popContext(current$$1); + break; + case 3: + popHostContainer(current$$1); + popTopLevelContextObject(current$$1); + fiber = current$$1.stateNode; + fiber.pendingContext && + ((fiber.context = fiber.pendingContext), + (fiber.pendingContext = null)); + if (null === current || null === current.child) + current$$1.effectTag &= -3; + updateHostContainer(current$$1); + break; + case 5: + popHostContext(current$$1); + renderExpirationTime = requiredContext( rootInstanceStackCursor.current - ), - type = current$$1.type; - if (null !== current && null != current$$1.stateNode) - updateHostComponent$1( - current, - current$$1, - type, - fiber, - rootContainerInstance - ), - current.ref !== current$$1.ref && (current$$1.effectTag |= 128); - else if (fiber) { - current = requiredContext(contextStackCursor$1.current); - var internalInstanceHandle = current$$1, - tag = allocateTag(), - viewConfig = ReactNativeViewConfigRegistry.get(type); - invariant( - "RCTView" !== type || !current.isInAParentText, - "Nesting of within is not currently supported." - ); - var updatePayload = diffProperties( - null, - emptyObject, - fiber, - viewConfig.validAttributes ); - UIManager.createView( - tag, - viewConfig.uiViewClassName, - rootContainerInstance, - updatePayload - ); - viewConfig = new ReactNativeFiberHostComponent(tag, viewConfig); - instanceCache[tag] = internalInstanceHandle; - instanceProps[tag] = fiber; - a: for ( - internalInstanceHandle = viewConfig, - tag = current$$1, - updatePayload = tag.child; - null !== updatePayload; - - ) { - if (7 === updatePayload.tag || 8 === updatePayload.tag) - internalInstanceHandle._children.push(updatePayload.stateNode); - else if ( - 6 !== updatePayload.tag && - null !== updatePayload.child - ) { - updatePayload.child.return = updatePayload; - updatePayload = updatePayload.child; - continue; - } - if (updatePayload === tag) break; - for (; null === updatePayload.sibling; ) { - if ( - null === updatePayload.return || - updatePayload.return === tag - ) - break a; - updatePayload = updatePayload.return; - } - updatePayload.sibling.return = updatePayload.return; - updatePayload = updatePayload.sibling; - } - finalizeInitialChildren( - viewConfig, - type, - fiber, - rootContainerInstance, - current - ) && (current$$1.effectTag |= 4); - current$$1.stateNode = viewConfig; - null !== current$$1.ref && (current$$1.effectTag |= 128); - } else - invariant( - null !== current$$1.stateNode, - "We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue." - ); - break; - case 8: - current && null != current$$1.stateNode - ? updateHostText$1( + var type = current$$1.type; + if (null !== current && null != current$$1.stateNode) + updateHostComponent$1( current, current$$1, - current.memoizedProps, - fiber - ) - : ("string" !== typeof fiber && + type, + fiber, + renderExpirationTime + ), + current.ref !== current$$1.ref && (current$$1.effectTag |= 128); + else if (fiber) { + current = requiredContext(contextStackCursor$1.current); + var internalInstanceHandle = current$$1, + tag = allocateTag(), + viewConfig = ReactNativeViewConfigRegistry.get(type); + invariant( + "RCTView" !== type || !current.isInAParentText, + "Nesting of within is not currently supported." + ); + var updatePayload = diffProperties( + null, + emptyObject, + fiber, + viewConfig.validAttributes + ); + UIManager.createView( + tag, + viewConfig.uiViewClassName, + renderExpirationTime, + updatePayload + ); + viewConfig = new ReactNativeFiberHostComponent(tag, viewConfig); + instanceCache[tag] = internalInstanceHandle; + instanceProps[tag] = fiber; + appendAllChildren(viewConfig, current$$1, !1, !1); + finalizeInitialChildren( + viewConfig, + type, + fiber, + renderExpirationTime, + current + ) && (current$$1.effectTag |= 4); + current$$1.stateNode = viewConfig; + null !== current$$1.ref && (current$$1.effectTag |= 128); + } else + invariant( + null !== current$$1.stateNode, + "We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue." + ); + break; + case 6: + current && null != current$$1.stateNode + ? updateHostText$1( + current, + current$$1, + current.memoizedProps, + fiber + ) + : ("string" !== typeof fiber && + invariant( + null !== current$$1.stateNode, + "We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue." + ), + (current = requiredContext(rootInstanceStackCursor.current)), + (type = requiredContext(contextStackCursor$1.current)), + (renderExpirationTime = current$$1), invariant( - null !== current$$1.stateNode, - "We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue." + type.isInAParentText, + "Text strings must be rendered within a component." ), - (current = requiredContext(rootInstanceStackCursor.current)), - (type = requiredContext(contextStackCursor$1.current)), - (rootContainerInstance = current$$1), - invariant( - type.isInAParentText, - "Text strings must be rendered within a component." - ), - (type = allocateTag()), - UIManager.createView(type, "RCTRawText", current, { - text: fiber - }), - (instanceCache[type] = current$$1), - (rootContainerInstance.stateNode = type)); - break; - case 13: - case 14: - break; - case 16: - break; - case 9: - break; - 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: - 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, - "Unknown unit of work tag. This error is likely caused by a bug in React. Please file an issue." - ); + (type = allocateTag()), + UIManager.createView(type, "RCTRawText", current, { + text: fiber + }), + (instanceCache[type] = current$$1), + (renderExpirationTime.stateNode = type)); + break; + case 11: + break; + case 13: + fiber = current$$1.memoizedState; + if (0 !== (current$$1.effectTag & 64)) { + current$$1.expirationTime = renderExpirationTime; + nextUnitOfWork = current$$1; + break a; + } + fiber = null !== fiber; + type = null !== current && null !== current.memoizedState; + null !== current && + !fiber && + type && + ((current = current.child.sibling), + null !== current && + reconcileChildFibers( + current$$1, + current, + null, + renderExpirationTime + )); + if (fiber !== type || (0 === (current$$1.effectTag & 1) && fiber)) + current$$1.effectTag |= 4; + break; + case 7: + break; + case 8: + break; + case 12: + break; + case 4: + popHostContainer(current$$1); + updateHostContainer(current$$1); + break; + case 10: + popProvider(current$$1); + break; + case 9: + break; + case 14: + break; + case 17: + isContextProvider(current$$1.type) && popContext(current$$1); + break; + default: + invariant( + !1, + "Unknown unit of work tag. This error is likely caused by a bug in React. Please file an issue." + ); + } + nextUnitOfWork = null; } - nextUnitOfWork = null; workInProgress.mode & 4 && stopProfilerTimerIfRunningAndRecordDelta(workInProgress, !1); current$$1 = workInProgress; if ( - 1073741823 === nextRenderExpirationTime || - 1073741823 !== current$$1.childExpirationTime + 1 === nextRenderExpirationTime || + 1 !== current$$1.childExpirationTime ) { fiber = 0; if (current$$1.mode & 4) { - rootContainerInstance = current$$1.actualDuration; + renderExpirationTime = current$$1.actualDuration; type = current$$1.selfBaseDuration; current = null === current$$1.alternate || current$$1.child !== current$$1.alternate.child; - for (viewConfig = current$$1.child; null !== viewConfig; ) { - internalInstanceHandle = viewConfig.expirationTime; - tag = viewConfig.childExpirationTime; - if ( - 0 === fiber || - (0 !== internalInstanceHandle && internalInstanceHandle < fiber) - ) - fiber = internalInstanceHandle; - if (0 === fiber || (0 !== tag && tag < fiber)) fiber = tag; - current && (rootContainerInstance += viewConfig.actualDuration); - type += viewConfig.treeBaseDuration; - viewConfig = viewConfig.sibling; - } - current$$1.actualDuration = rootContainerInstance; + for ( + internalInstanceHandle = current$$1.child; + null !== internalInstanceHandle; + + ) + (tag = internalInstanceHandle.expirationTime), + (viewConfig = internalInstanceHandle.childExpirationTime), + tag > fiber && (fiber = tag), + viewConfig > fiber && (fiber = viewConfig), + current && + (renderExpirationTime += internalInstanceHandle.actualDuration), + (type += internalInstanceHandle.treeBaseDuration), + (internalInstanceHandle = internalInstanceHandle.sibling); + current$$1.actualDuration = renderExpirationTime; current$$1.treeBaseDuration = type; } else for ( - rootContainerInstance = current$$1.child; - null !== rootContainerInstance; + renderExpirationTime = current$$1.child; + null !== renderExpirationTime; - ) { - type = rootContainerInstance.expirationTime; - current = rootContainerInstance.childExpirationTime; - if (0 === fiber || (0 !== type && type < fiber)) fiber = type; - if (0 === fiber || (0 !== current && current < fiber)) - fiber = current; - rootContainerInstance = rootContainerInstance.sibling; - } + ) + (type = renderExpirationTime.expirationTime), + (current = renderExpirationTime.childExpirationTime), + type > fiber && (fiber = type), + current > fiber && (fiber = current), + (renderExpirationTime = renderExpirationTime.sibling); current$$1.childExpirationTime = fiber; } + if (null !== nextUnitOfWork) return nextUnitOfWork; null !== returnFiber && - 0 === (returnFiber.effectTag & 512) && + 0 === (returnFiber.effectTag & 1024) && (null === returnFiber.firstEffect && (returnFiber.firstEffect = workInProgress.firstEffect), null !== workInProgress.lastEffect && @@ -5614,23 +5869,19 @@ function completeUnitOfWork(workInProgress) { : (returnFiber.firstEffect = workInProgress), (returnFiber.lastEffect = workInProgress))); } else { - workInProgress.mode & 4 && + if (workInProgress.mode & 4) { stopProfilerTimerIfRunningAndRecordDelta(workInProgress, !1); - workInProgress = unwindWork(workInProgress, nextRenderExpirationTime); - if (null !== workInProgress) { - if (workInProgress.mode & 4) { - returnFiber = workInProgress.actualDuration; - for (siblingFiber = workInProgress.child; null !== siblingFiber; ) - (returnFiber += siblingFiber.actualDuration), - (siblingFiber = siblingFiber.sibling); - workInProgress.actualDuration = returnFiber; - } - workInProgress.effectTag &= 511; - return workInProgress; + current$$1 = workInProgress.actualDuration; + for (fiber = workInProgress.child; null !== fiber; ) + (current$$1 += fiber.actualDuration), (fiber = fiber.sibling); + workInProgress.actualDuration = current$$1; } + workInProgress = unwindWork(workInProgress, nextRenderExpirationTime); + if (null !== workInProgress) + return (workInProgress.effectTag &= 1023), workInProgress; null !== returnFiber && ((returnFiber.firstEffect = returnFiber.lastEffect = null), - (returnFiber.effectTag |= 512)); + (returnFiber.effectTag |= 1024)); } if (null !== siblingFiber) return siblingFiber; if (null !== returnFiber) workInProgress = returnFiber; @@ -5645,19 +5896,21 @@ function performUnitOfWork(workInProgress) { 0 > workInProgress.actualStartTime && (workInProgress.actualStartTime = now$1())); current$$1 = beginWork(current$$1, workInProgress, nextRenderExpirationTime); + workInProgress.memoizedProps = workInProgress.pendingProps; workInProgress.mode & 4 && stopProfilerTimerIfRunningAndRecordDelta(workInProgress, !0); null === current$$1 && (current$$1 = completeUnitOfWork(workInProgress)); ReactCurrentOwner$2.current = null; return current$$1; } -function renderRoot(root, isYieldy, isExpired) { +function renderRoot(root, isYieldy) { invariant( !isWorking, "renderRoot was called recursively. This error is likely caused by a bug in React. Please file an issue." ); + flushPassiveEffects(); isWorking = !0; - ReactCurrentOwner$2.currentDispatcher = Dispatcher; + ReactCurrentOwner$2.currentDispatcher = DispatcherWithoutHooks; var expirationTime = root.nextExpirationTimeToWorkOn; if ( expirationTime !== nextRenderExpirationTime || @@ -5678,7 +5931,7 @@ function renderRoot(root, isYieldy, isExpired) { scheduledInteractions, scheduledExpirationTime ) { - scheduledExpirationTime <= expirationTime && + scheduledExpirationTime >= expirationTime && scheduledInteractions.forEach(function(interaction) { return interactions.add(interaction); }); @@ -5704,15 +5957,20 @@ function renderRoot(root, isYieldy, isExpired) { do { try { if (isYieldy) - for (; null !== nextUnitOfWork && !shouldYield(); ) + for (; null !== nextUnitOfWork && !shouldYieldToRenderer(); ) nextUnitOfWork = performUnitOfWork(nextUnitOfWork); else for (; null !== nextUnitOfWork; ) nextUnitOfWork = performUnitOfWork(nextUnitOfWork); } catch (thrownValue) { - if (null === nextUnitOfWork) + if ( + ((lastContextWithAllBitsObserved = lastContextDependency = currentlyRenderingFiber = null), + null === nextUnitOfWork) + ) (threadID = !0), onUncaughtError(thrownValue); else { + nextUnitOfWork.mode & 4 && + stopProfilerTimerIfRunningAndRecordDelta(nextUnitOfWork, !0); invariant( null !== nextUnitOfWork, "Failed to replay rendering after an error. This is likely caused by a bug in React. Please file an issue with a reproducing case to help us find it." @@ -5741,165 +5999,149 @@ function renderRoot(root, isYieldy, isExpired) { if (threadID) (nextRoot = null), (root.finishedWork = null); else if (null !== nextUnitOfWork) root.finishedWork = null; else { - isYieldy = root.current.alternate; + subscriber = root.current.alternate; invariant( - null !== isYieldy, + null !== subscriber, "Finished root should have a work-in-progress. This error is likely caused by a bug in React. Please file an issue." ); nextRoot = null; if (nextRenderDidError) { if (hasLowerPriorityWork(root, expirationTime)) { markSuspendedPriorityLevel(root, expirationTime); - onSuspend(root, isYieldy, expirationTime, root.expirationTime, -1); + onSuspend(root, subscriber, expirationTime, root.expirationTime, -1); return; } - if (!root.didError && !isExpired) { + if (!root.didError && isYieldy) { root.didError = !0; - isExpired = root.nextExpirationTimeToWorkOn = expirationTime; - subscriber = root.expirationTime = 1; - onSuspend(root, isYieldy, isExpired, subscriber, -1); + isYieldy = root.nextExpirationTimeToWorkOn = expirationTime; + threadID = root.expirationTime = 1073741823; + onSuspend(root, subscriber, isYieldy, threadID, -1); return; } } - isExpired || -1 === nextLatestAbsoluteTimeoutMs - ? onComplete(root, isYieldy, expirationTime) - : (markSuspendedPriorityLevel(root, expirationTime), - (isExpired = + isYieldy && -1 !== nextLatestAbsoluteTimeoutMs + ? (markSuspendedPriorityLevel(root, expirationTime), + (isYieldy = 10 * - (findEarliestOutstandingPriorityLevel(root, expirationTime) - 2)), - isExpired < nextLatestAbsoluteTimeoutMs && - (nextLatestAbsoluteTimeoutMs = isExpired), - (isExpired = 10 * (requestCurrentTime() - 2)), - (isExpired = nextLatestAbsoluteTimeoutMs - isExpired), + (1073741822 - + findEarliestOutstandingPriorityLevel(root, expirationTime))), + isYieldy < nextLatestAbsoluteTimeoutMs && + (nextLatestAbsoluteTimeoutMs = isYieldy), + (isYieldy = 10 * (1073741822 - requestCurrentTime())), + (isYieldy = nextLatestAbsoluteTimeoutMs - isYieldy), onSuspend( root, - isYieldy, + subscriber, expirationTime, root.expirationTime, - 0 > isExpired ? 0 : isExpired - )); + 0 > isYieldy ? 0 : isYieldy + )) + : onComplete(root, subscriber, expirationTime); } } -function captureCommitPhaseError(fiber, error) { - var JSCompiler_inline_result; - a: { - invariant( - !isWorking || isCommitting$1, - "dispatch: Cannot dispatch during the render phase." - ); - for ( - JSCompiler_inline_result = fiber.return; - null !== JSCompiler_inline_result; - - ) { - switch (JSCompiler_inline_result.tag) { - case 2: - case 3: - var instance = JSCompiler_inline_result.stateNode; - if ( - "function" === - typeof JSCompiler_inline_result.type.getDerivedStateFromError || - ("function" === typeof instance.componentDidCatch && - (null === legacyErrorBoundariesThatAlreadyFailed || - !legacyErrorBoundariesThatAlreadyFailed.has(instance))) - ) { - fiber = createCapturedValue(error, fiber); - fiber = createClassErrorUpdate(JSCompiler_inline_result, fiber, 1); - enqueueUpdate(JSCompiler_inline_result, fiber); - scheduleWork(JSCompiler_inline_result, 1); - JSCompiler_inline_result = void 0; - break a; - } - break; - case 5: - fiber = createCapturedValue(error, fiber); - fiber = createRootErrorUpdate(JSCompiler_inline_result, fiber, 1); - enqueueUpdate(JSCompiler_inline_result, fiber); - scheduleWork(JSCompiler_inline_result, 1); - JSCompiler_inline_result = void 0; - break a; - } - JSCompiler_inline_result = JSCompiler_inline_result.return; +function captureCommitPhaseError(sourceFiber, value) { + for (var fiber = sourceFiber.return; null !== fiber; ) { + switch (fiber.tag) { + case 1: + var instance = fiber.stateNode; + if ( + "function" === typeof fiber.type.getDerivedStateFromError || + ("function" === typeof instance.componentDidCatch && + (null === legacyErrorBoundariesThatAlreadyFailed || + !legacyErrorBoundariesThatAlreadyFailed.has(instance))) + ) { + sourceFiber = createCapturedValue(value, sourceFiber); + sourceFiber = createClassErrorUpdate(fiber, sourceFiber, 1073741823); + enqueueUpdate(fiber, sourceFiber); + scheduleWork(fiber, 1073741823); + return; + } + break; + case 3: + sourceFiber = createCapturedValue(value, sourceFiber); + sourceFiber = createRootErrorUpdate(fiber, sourceFiber, 1073741823); + enqueueUpdate(fiber, sourceFiber); + scheduleWork(fiber, 1073741823); + return; } - 5 === fiber.tag && - ((JSCompiler_inline_result = createCapturedValue(error, fiber)), - (JSCompiler_inline_result = createRootErrorUpdate( - fiber, - JSCompiler_inline_result, - 1 - )), - enqueueUpdate(fiber, JSCompiler_inline_result), - scheduleWork(fiber, 1)); - JSCompiler_inline_result = void 0; + fiber = fiber.return; } - return JSCompiler_inline_result; + 3 === sourceFiber.tag && + ((fiber = createCapturedValue(value, sourceFiber)), + (fiber = createRootErrorUpdate(sourceFiber, fiber, 1073741823)), + enqueueUpdate(sourceFiber, fiber), + scheduleWork(sourceFiber, 1073741823)); } function computeExpirationForFiber(currentTime, fiber) { isWorking - ? (currentTime = isCommitting$1 ? 1 : nextRenderExpirationTime) + ? (currentTime = isCommitting$1 ? 1073741823 : nextRenderExpirationTime) : fiber.mode & 1 ? ((currentTime = isBatchingInteractiveUpdates - ? 2 + 10 * ((((currentTime - 2 + 15) / 10) | 0) + 1) - : 2 + 25 * ((((currentTime - 2 + 500) / 25) | 0) + 1)), + ? 1073741822 - 10 * ((((1073741822 - currentTime + 15) / 10) | 0) + 1) + : 1073741822 - + 25 * ((((1073741822 - currentTime + 500) / 25) | 0) + 1)), null !== nextRoot && currentTime === nextRenderExpirationTime && - (currentTime += 1)) - : (currentTime = 1); + --currentTime) + : (currentTime = 1073741823); isBatchingInteractiveUpdates && - currentTime > lowestPriorityPendingInteractiveExpirationTime && + (0 === lowestPriorityPendingInteractiveExpirationTime || + currentTime < lowestPriorityPendingInteractiveExpirationTime) && (lowestPriorityPendingInteractiveExpirationTime = currentTime); return currentTime; } -function retrySuspendedRoot(root, fiber, suspendedTime) { +function retrySuspendedRoot(root, boundaryFiber, sourceFiber, suspendedTime) { var retryTime = root.earliestSuspendedTime; var latestSuspendedTime = root.latestSuspendedTime; if ( 0 !== retryTime && - suspendedTime >= retryTime && - suspendedTime <= latestSuspendedTime + suspendedTime <= retryTime && + suspendedTime >= latestSuspendedTime ) { latestSuspendedTime = retryTime = suspendedTime; root.didError = !1; var latestPingedTime = root.latestPingedTime; - if (0 === latestPingedTime || latestPingedTime < latestSuspendedTime) + if (0 === latestPingedTime || latestPingedTime > latestSuspendedTime) root.latestPingedTime = latestSuspendedTime; findNextExpirationTimeToWorkOn(latestSuspendedTime, root); } else (retryTime = requestCurrentTime()), - (retryTime = computeExpirationForFiber(retryTime, fiber)), + (retryTime = computeExpirationForFiber(retryTime, boundaryFiber)), markPendingPriorityLevel(root, retryTime); - 0 !== (fiber.mode & 1) && + 0 !== (boundaryFiber.mode & 1) && root === nextRoot && nextRenderExpirationTime === suspendedTime && (nextRoot = null); - scheduleWorkToRoot(fiber, retryTime); - fiber = root.expirationTime; - 0 !== fiber && requestWork(root, fiber); + scheduleWorkToRoot(boundaryFiber, retryTime); + 0 === (boundaryFiber.mode & 1) && + (scheduleWorkToRoot(sourceFiber, retryTime), + 1 === sourceFiber.tag && + null !== sourceFiber.stateNode && + ((boundaryFiber = createUpdate(retryTime)), + (boundaryFiber.tag = 2), + enqueueUpdate(sourceFiber, boundaryFiber))); + sourceFiber = root.expirationTime; + 0 !== sourceFiber && requestWork(root, sourceFiber); } function scheduleWorkToRoot(fiber, expirationTime) { - if (0 === fiber.expirationTime || fiber.expirationTime > expirationTime) - fiber.expirationTime = expirationTime; + fiber.expirationTime < expirationTime && + (fiber.expirationTime = expirationTime); var alternate = fiber.alternate; null !== alternate && - (0 === alternate.expirationTime || - alternate.expirationTime > expirationTime) && + alternate.expirationTime < expirationTime && (alternate.expirationTime = expirationTime); var node = fiber.return, root = null; - if (null === node && 5 === fiber.tag) root = fiber.stateNode; + if (null === node && 3 === fiber.tag) root = fiber.stateNode; else for (; null !== node; ) { alternate = node.alternate; - if ( - 0 === node.childExpirationTime || - node.childExpirationTime > expirationTime - ) - node.childExpirationTime = expirationTime; + node.childExpirationTime < expirationTime && + (node.childExpirationTime = expirationTime); null !== alternate && - (0 === alternate.childExpirationTime || - alternate.childExpirationTime > expirationTime) && + alternate.childExpirationTime < expirationTime && (alternate.childExpirationTime = expirationTime); - if (null === node.return && 5 === node.tag) { + if (null === node.return && 3 === node.tag) { root = node.stateNode; break; } @@ -5933,7 +6175,7 @@ function scheduleWork(fiber, expirationTime) { null !== fiber && (!isWorking && 0 !== nextRenderExpirationTime && - expirationTime < nextRenderExpirationTime && + expirationTime > nextRenderExpirationTime && resetStack(), markPendingPriorityLevel(fiber, expirationTime), (isWorking && !isCommitting$1 && nextRoot === fiber) || @@ -5953,27 +6195,25 @@ var firstScheduledRoot = null, nextFlushedRoot = null, nextFlushedExpirationTime = 0, lowestPriorityPendingInteractiveExpirationTime = 0, - deadlineDidExpire = !1, hasUnhandledError = !1, unhandledError = null, - deadline = null, isBatchingUpdates = !1, isUnbatchingUpdates = !1, isBatchingInteractiveUpdates = !1, completedBatches = null, originalStartTimeMs = now$1(), - currentRendererTime = ((originalStartTimeMs / 10) | 0) + 2, + currentRendererTime = 1073741822 - ((originalStartTimeMs / 10) | 0), currentSchedulerTime = currentRendererTime, NESTED_UPDATE_LIMIT = 50, nestedUpdateCount = 0, - lastCommittedRootDuringThisBatch = null, - timeHeuristicForUnitOfWork = 1; + lastCommittedRootDuringThisBatch = null; function recomputeCurrentRendererTime() { - currentRendererTime = (((now$1() - originalStartTimeMs) / 10) | 0) + 2; + currentRendererTime = + 1073741822 - (((now$1() - originalStartTimeMs) / 10) | 0); } function scheduleCallbackWithExpirationTime(root, expirationTime) { if (0 !== callbackExpirationTime) { - if (expirationTime > callbackExpirationTime) return; + if (expirationTime < callbackExpirationTime) return; null !== callbackID && ((root = callbackID), (scheduledCallback = null), clearTimeout(root)); } @@ -5994,7 +6234,7 @@ function onSuspend( msUntilTimeout ) { root.expirationTime = rootExpirationTime; - 0 !== msUntilTimeout || shouldYield() + 0 !== msUntilTimeout || shouldYieldToRenderer() ? 0 < msUntilTimeout && (root.timeoutHandle = scheduleTimeout( onTimeout.bind(null, root, finishedWork, suspendedExpirationTime), @@ -6014,8 +6254,8 @@ function onTimeout(root, finishedWork, suspendedExpirationTime) { ); nextFlushedRoot = root; nextFlushedExpirationTime = suspendedExpirationTime; - performWorkOnRoot(root, suspendedExpirationTime, !0); - performWork(1, null); + performWorkOnRoot(root, suspendedExpirationTime, !1); + performWork(1073741823, !1); } function onCommit(root, expirationTime) { root.expirationTime = expirationTime; @@ -6024,38 +6264,29 @@ function onCommit(root, expirationTime) { function requestCurrentTime() { if (isRendering) return currentSchedulerTime; findHighestPriorityRoot(); - if ( - 0 === nextFlushedExpirationTime || - 1073741823 === nextFlushedExpirationTime - ) + if (0 === nextFlushedExpirationTime || 1 === nextFlushedExpirationTime) recomputeCurrentRendererTime(), (currentSchedulerTime = currentRendererTime); return currentSchedulerTime; } function requestWork(root, expirationTime) { - if (null === root.nextScheduledRoot) - (root.expirationTime = expirationTime), + null === root.nextScheduledRoot + ? ((root.expirationTime = expirationTime), null === lastScheduledRoot ? ((firstScheduledRoot = lastScheduledRoot = root), (root.nextScheduledRoot = root)) : ((lastScheduledRoot = lastScheduledRoot.nextScheduledRoot = root), - (lastScheduledRoot.nextScheduledRoot = firstScheduledRoot)); - else { - var remainingExpirationTime = root.expirationTime; - if ( - 0 === remainingExpirationTime || - expirationTime < remainingExpirationTime - ) - root.expirationTime = expirationTime; - } + (lastScheduledRoot.nextScheduledRoot = firstScheduledRoot))) + : expirationTime > root.expirationTime && + (root.expirationTime = expirationTime); isRendering || (isBatchingUpdates ? isUnbatchingUpdates && ((nextFlushedRoot = root), - (nextFlushedExpirationTime = 1), - performWorkOnRoot(root, 1, !0)) - : 1 === expirationTime - ? performWork(1, null) + (nextFlushedExpirationTime = 1073741823), + performWorkOnRoot(root, 1073741823, !1)) + : 1073741823 === expirationTime + ? performWork(1073741823, !1) : scheduleCallbackWithExpirationTime(root, expirationTime)); } function findHighestPriorityRoot() { @@ -6091,14 +6322,11 @@ function findHighestPriorityRoot() { (root.nextScheduledRoot = null); root = previousScheduledRoot.nextScheduledRoot; } else { - if ( - 0 === highestPriorityWork || - remainingExpirationTime < highestPriorityWork - ) - (highestPriorityWork = remainingExpirationTime), - (highestPriorityRoot = root); + remainingExpirationTime > highestPriorityWork && + ((highestPriorityWork = remainingExpirationTime), + (highestPriorityRoot = root)); if (root === lastScheduledRoot) break; - if (1 === highestPriorityWork) break; + if (1073741823 === highestPriorityWork) break; previousScheduledRoot = root; root = root.nextScheduledRoot; } @@ -6106,38 +6334,44 @@ function findHighestPriorityRoot() { nextFlushedRoot = highestPriorityRoot; nextFlushedExpirationTime = highestPriorityWork; } -function performAsyncWork(dl) { - if (dl.didTimeout && null !== firstScheduledRoot) { - recomputeCurrentRendererTime(); - var root = firstScheduledRoot; - do { - var expirationTime = root.expirationTime; - 0 !== expirationTime && - currentRendererTime >= expirationTime && - (root.nextExpirationTimeToWorkOn = currentRendererTime); - root = root.nextScheduledRoot; - } while (root !== firstScheduledRoot); +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; } - performWork(0, dl); } -function performWork(minExpirationTime, dl) { - deadline = dl; +function performWork(minExpirationTime, isYieldy) { findHighestPriorityRoot(); - if (null !== deadline) + if (isYieldy) for ( recomputeCurrentRendererTime(), currentSchedulerTime = currentRendererTime; null !== nextFlushedRoot && 0 !== nextFlushedExpirationTime && - (0 === minExpirationTime || - minExpirationTime >= nextFlushedExpirationTime) && - (!deadlineDidExpire || currentRendererTime >= nextFlushedExpirationTime); + minExpirationTime <= nextFlushedExpirationTime && + !(didYield && currentRendererTime > nextFlushedExpirationTime); ) performWorkOnRoot( nextFlushedRoot, nextFlushedExpirationTime, - currentRendererTime >= nextFlushedExpirationTime + currentRendererTime > nextFlushedExpirationTime ), findHighestPriorityRoot(), recomputeCurrentRendererTime(), @@ -6147,29 +6381,28 @@ function performWork(minExpirationTime, dl) { ; null !== nextFlushedRoot && 0 !== nextFlushedExpirationTime && - (0 === minExpirationTime || - minExpirationTime >= nextFlushedExpirationTime); + minExpirationTime <= nextFlushedExpirationTime; ) - performWorkOnRoot(nextFlushedRoot, nextFlushedExpirationTime, !0), + performWorkOnRoot(nextFlushedRoot, nextFlushedExpirationTime, !1), findHighestPriorityRoot(); - null !== deadline && ((callbackExpirationTime = 0), (callbackID = null)); + isYieldy && ((callbackExpirationTime = 0), (callbackID = null)); 0 !== nextFlushedExpirationTime && scheduleCallbackWithExpirationTime( nextFlushedRoot, nextFlushedExpirationTime ); - deadline = null; - deadlineDidExpire = !1; nestedUpdateCount = 0; lastCommittedRootDuringThisBatch = null; if (null !== completedBatches) for ( - minExpirationTime = completedBatches, completedBatches = null, dl = 0; - dl < minExpirationTime.length; - dl++ + minExpirationTime = completedBatches, + completedBatches = null, + isYieldy = 0; + isYieldy < minExpirationTime.length; + isYieldy++ ) { - var batch = minExpirationTime[dl]; + var batch = minExpirationTime[isYieldy]; try { batch._onComplete(); } catch (error) { @@ -6183,45 +6416,45 @@ function performWork(minExpirationTime, dl) { (hasUnhandledError = !1), minExpirationTime); } -function performWorkOnRoot(root, expirationTime, isExpired) { +function performWorkOnRoot(root, expirationTime, isYieldy) { invariant( !isRendering, "performWorkOnRoot was called recursively. This error is likely caused by a bug in React. Please file an issue." ); isRendering = !0; - if (null === deadline || isExpired) { - var finishedWork = root.finishedWork; - null !== finishedWork - ? completeRoot(root, finishedWork, expirationTime) + if (isYieldy) { + var _finishedWork = root.finishedWork; + null !== _finishedWork + ? completeRoot(root, _finishedWork, expirationTime) : ((root.finishedWork = null), - (finishedWork = root.timeoutHandle), - -1 !== finishedWork && - ((root.timeoutHandle = -1), cancelTimeout(finishedWork)), - renderRoot(root, !1, isExpired), - (finishedWork = root.finishedWork), - null !== finishedWork && - completeRoot(root, finishedWork, expirationTime)); + (_finishedWork = root.timeoutHandle), + -1 !== _finishedWork && + ((root.timeoutHandle = -1), cancelTimeout(_finishedWork)), + renderRoot(root, isYieldy), + (_finishedWork = root.finishedWork), + null !== _finishedWork && + (shouldYieldToRenderer() + ? (root.finishedWork = _finishedWork) + : completeRoot(root, _finishedWork, expirationTime))); } else - (finishedWork = root.finishedWork), - null !== finishedWork - ? completeRoot(root, finishedWork, expirationTime) + (_finishedWork = root.finishedWork), + null !== _finishedWork + ? completeRoot(root, _finishedWork, expirationTime) : ((root.finishedWork = null), - (finishedWork = root.timeoutHandle), - -1 !== finishedWork && - ((root.timeoutHandle = -1), cancelTimeout(finishedWork)), - renderRoot(root, !0, isExpired), - (finishedWork = root.finishedWork), - null !== finishedWork && - (shouldYield() - ? (root.finishedWork = finishedWork) - : completeRoot(root, finishedWork, expirationTime))); + (_finishedWork = root.timeoutHandle), + -1 !== _finishedWork && + ((root.timeoutHandle = -1), cancelTimeout(_finishedWork)), + renderRoot(root, isYieldy), + (_finishedWork = root.finishedWork), + null !== _finishedWork && + completeRoot(root, _finishedWork, expirationTime)); isRendering = !1; } function completeRoot(root, finishedWork, expirationTime) { var firstBatch = root.firstBatch; if ( null !== firstBatch && - firstBatch._expirationTime <= expirationTime && + firstBatch._expirationTime >= expirationTime && (null === completedBatches ? (completedBatches = [firstBatch]) : completedBatches.push(firstBatch), @@ -6237,13 +6470,6 @@ function completeRoot(root, finishedWork, expirationTime) { : ((lastCommittedRootDuringThisBatch = root), (nestedUpdateCount = 0)); commitRoot(root, finishedWork); } -function shouldYield() { - return deadlineDidExpire - ? !0 - : null === deadline || deadline.timeRemaining() > timeHeuristicForUnitOfWork - ? !1 - : (deadlineDidExpire = !0); -} function onUncaughtError(error) { invariant( null !== nextFlushedRoot, @@ -6252,55 +6478,6 @@ function onUncaughtError(error) { nextFlushedRoot.expirationTime = 0; hasUnhandledError || ((hasUnhandledError = !0), (unhandledError = error)); } -function getContextForSubtree(parentComponent) { - if (!parentComponent) return emptyContextObject; - parentComponent = parentComponent._reactInternalFiber; - a: { - invariant( - 2 === isFiberMountedImpl(parentComponent) && - (2 === parentComponent.tag || 3 === parentComponent.tag), - "Expected subtree parent to be a mounted class component. This error is likely caused by a bug in React. Please file an issue." - ); - var parentContext = parentComponent; - do { - switch (parentContext.tag) { - case 5: - parentContext = parentContext.stateNode.context; - break a; - case 2: - if (isContextProvider(parentContext.type)) { - parentContext = - parentContext.stateNode.__reactInternalMemoizedMergedChildContext; - break a; - } - break; - case 3: - if (isContextProvider(parentContext.type._reactResult)) { - parentContext = - parentContext.stateNode.__reactInternalMemoizedMergedChildContext; - break a; - } - } - parentContext = parentContext.return; - } while (null !== parentContext); - invariant( - !1, - "Found unexpected detached subtree parent. This error is likely caused by a bug in React. Please file an issue." - ); - parentContext = void 0; - } - if (2 === parentComponent.tag) { - var Component = parentComponent.type; - if (isContextProvider(Component)) - return processChildContext(parentComponent, Component, parentContext); - } else if ( - 3 === parentComponent.tag && - ((Component = parentComponent.type._reactResult), - isContextProvider(Component)) - ) - return processChildContext(parentComponent, Component, parentContext); - return parentContext; -} function findHostInstance$1(component) { var fiber = component._reactInternalFiber; void 0 === fiber && @@ -6319,7 +6496,48 @@ function updateContainer(element, container, parentComponent, callback) { currentTime = requestCurrentTime(); current$$1 = computeExpirationForFiber(currentTime, current$$1); currentTime = container.current; - parentComponent = getContextForSubtree(parentComponent); + a: if (parentComponent) { + parentComponent = parentComponent._reactInternalFiber; + b: { + invariant( + 2 === isFiberMountedImpl(parentComponent) && 1 === parentComponent.tag, + "Expected subtree parent to be a mounted class component. This error is likely caused by a bug in React. Please file an issue." + ); + var parentContext = parentComponent; + do { + switch (parentContext.tag) { + case 3: + parentContext = parentContext.stateNode.context; + break b; + case 1: + if (isContextProvider(parentContext.type)) { + parentContext = + parentContext.stateNode + .__reactInternalMemoizedMergedChildContext; + break b; + } + } + parentContext = parentContext.return; + } while (null !== parentContext); + invariant( + !1, + "Found unexpected detached subtree parent. This error is likely caused by a bug in React. Please file an issue." + ); + parentContext = void 0; + } + if (1 === parentComponent.tag) { + var Component = parentComponent.type; + if (isContextProvider(Component)) { + parentComponent = processChildContext( + parentComponent, + Component, + parentContext + ); + break a; + } + } + parentComponent = parentContext; + } else parentComponent = emptyContextObject; null === container.context ? (container.context = parentComponent) : (container.pendingContext = parentComponent); @@ -6328,6 +6546,7 @@ function updateContainer(element, container, parentComponent, callback) { callback.payload = { element: element }; container = void 0 === container ? null : container; null !== container && (callback.callback = container); + flushPassiveEffects(); enqueueUpdate(currentTime, callback); scheduleWork(currentTime, current$$1); return current$$1; @@ -6387,13 +6606,13 @@ _batchedUpdatesImpl = function(fn, a) { } finally { (isBatchingUpdates = previousIsBatchingUpdates) || isRendering || - performWork(1, null); + performWork(1073741823, !1); } }; _flushInteractiveUpdatesImpl = function() { isRendering || 0 === lowestPriorityPendingInteractiveExpirationTime || - (performWork(lowestPriorityPendingInteractiveExpirationTime, null), + (performWork(lowestPriorityPendingInteractiveExpirationTime, !1), (lowestPriorityPendingInteractiveExpirationTime = 0)); }; var roots = new Map(), @@ -6475,7 +6694,7 @@ var roots = new Map(), if (!root) { root = 0; isDevToolsPresent && (root |= 4); - root = new FiberNode(5, null, null, root); + root = createFiber(3, null, null, root); var root$jscomp$0 = { current: root, containerInfo: containerTag, @@ -6506,7 +6725,7 @@ var roots = new Map(), updateContainer(element, root, null, callback); a: if (((element = root.current), element.child)) switch (element.child.tag) { - case 7: + case 5: element = element.child.stateNode; break a; default: @@ -6613,7 +6832,7 @@ var roots = new Map(), findFiberByHostInstance: getInstanceFromTag, getInspectorDataForViewTag: getInspectorDataForViewTag, bundleType: 0, - version: "16.6.0-alpha.8af6728", + version: "16.6.1", rendererPackageName: "react-native-renderer" }); var ReactNativeRenderer$2 = { default: ReactNativeRenderer }, diff --git a/Libraries/Renderer/shims/ReactTypes.js b/Libraries/Renderer/shims/ReactTypes.js index 20f76eef30f8c2..080ade12b807b0 100644 --- a/Libraries/Renderer/shims/ReactTypes.js +++ b/Libraries/Renderer/shims/ReactTypes.js @@ -54,7 +54,6 @@ export type ReactContext = { $$typeof: Symbol | number, Consumer: ReactContext, Provider: ReactProviderType, - unstable_read: () => T, _calculateChangedBits: ((a: T, b: T) => number) | null, diff --git a/package.json b/package.json index d119a0e6660853..0f332491b88895 100644 --- a/package.json +++ b/package.json @@ -145,7 +145,7 @@ "react-native": "local-cli/wrong-react-native.js" }, "peerDependencies": { - "react": "16.6.0-alpha.8af6728" + "react": "16.6.1" }, "dependencies": { "@babel/runtime": "^7.0.0", @@ -220,9 +220,9 @@ "jest": "23.4.1", "jest-junit": "5.1.0", "prettier": "1.13.6", - "react": "16.6.0-alpha.8af6728", + "react": "16.6.1", "react-native-dummy": "0.1.0", - "react-test-renderer": "16.6.0-alpha.8af6728", + "react-test-renderer": "16.6.1", "shelljs": "^0.7.8" }, "detox": { diff --git a/yarn.lock b/yarn.lock index 7cf4bdfe60751d..e196f5b2adbd28 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1643,6 +1643,11 @@ bser@^2.0.0: dependencies: node-int64 "^0.4.0" +buffer-crc32@^0.2.13: + version "0.2.13" + resolved "https://registry.yarnpkg.com/buffer-crc32/-/buffer-crc32-0.2.13.tgz#0d333e3f00eac50aa1454abd30ef8c2a5d9a7242" + integrity sha1-DTM+PwDqxQqhRUq9MO+MKl2ackI= + buffer-from@^1.0.0: version "1.1.1" resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.1.1.tgz#32713bc028f75c02fdb710d7c7bcec1f2c6070ef" @@ -2005,7 +2010,7 @@ cross-spawn@^5.0.1, cross-spawn@^5.1.0: shebang-command "^1.2.0" which "^1.2.9" -cross-spawn@^6.0.5: +cross-spawn@^6.0.0, cross-spawn@^6.0.5: version "6.0.5" resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-6.0.5.tgz#4a5ec7c64dfae22c3a14124dbacdee846d80cbc4" integrity sha512-eTVLrBSt7fjbDygz805pMnstIs2VTBNkRm0qxZd+M7A5XDdxVRWO5MxGBXZhjY4cqLYLdtrGqRf8mBPmzwSpWQ== @@ -2191,7 +2196,7 @@ detox@9.0.4: tempfile "^2.0.0" ws "^1.1.1" -diff@^3.1.0, diff@^3.2.0: +diff@^3.2.0: version "3.5.0" resolved "https://registry.yarnpkg.com/diff/-/diff-3.5.0.tgz#800c0dd1e0a8bfbc95835c202ad220fe317e5a12" integrity sha512-A46qtFgd+g7pDZinpnwiRJtxbC1hpgf0uzP3iG89scHk0AUC7A1TGxf5OiiOUv/JMZR8GOt8hL900hV0bOy5xA== @@ -2247,6 +2252,13 @@ encoding@^0.1.11: dependencies: iconv-lite "~0.4.13" +end-of-stream@^1.1.0: + version "1.4.1" + resolved "https://registry.yarnpkg.com/end-of-stream/-/end-of-stream-1.4.1.tgz#ed29634d19baba463b6ce6b80a37213eab71ec43" + integrity sha512-1MkrZNvWTKCaigbn+W15elq2BB/L22nqrSY5DKlo3X6+vclJm8Bb5djXJBmEX6fS3+zCh/F4VBK5Z2KxJt4s2Q== + dependencies: + once "^1.4.0" + envinfo@^5.7.0: version "5.10.0" resolved "https://registry.yarnpkg.com/envinfo/-/envinfo-5.10.0.tgz#503a9774ae15b93ea68bdfae2ccd6306624ea6df" @@ -2531,6 +2543,19 @@ execa@^0.7.0: signal-exit "^3.0.0" strip-eof "^1.0.0" +execa@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/execa/-/execa-1.0.0.tgz#c6236a5bb4df6d6f15e88e7f017798216749ddd8" + integrity sha512-adbxcyWV46qiHyvSp50TKt05tB4tK3HcmF7/nxfAdhnox83seTDbwnaqKO4sXRy7roHAIFqJP/Rw/AuEbX61LA== + dependencies: + cross-spawn "^6.0.0" + get-stream "^4.0.0" + is-stream "^1.1.0" + npm-run-path "^2.0.0" + p-finally "^1.0.0" + signal-exit "^3.0.0" + strip-eof "^1.0.0" + exit@^0.1.2: version "0.1.2" resolved "https://registry.yarnpkg.com/exit/-/exit-0.1.2.tgz#0632638f8d877cc82107d30a0fff1a17cba1cd0c" @@ -2827,10 +2852,10 @@ flat-cache@^1.2.1: graceful-fs "^4.1.2" write "^0.2.1" -flow-bin@^0.82.0: - version "0.82.0" - resolved "https://registry.yarnpkg.com/flow-bin/-/flow-bin-0.82.0.tgz#fbec84c0d6cab7877565eca8214d655f3aefb8db" - integrity sha512-D7ViTCVJSVv19CB6dFWS9k2iKQlavtkRXn9el0ofVTTpGuybe+EPE8DZwdyohzEt6wRhHV8gwkteWvxdcVuOzg== +flow-bin@^0.78.0: + version "0.78.0" + resolved "https://registry.yarnpkg.com/flow-bin/-/flow-bin-0.78.0.tgz#df9fe7f9c9a2dfaff39083949fe2d831b41627b7" + integrity sha512-LV55tE+ItkC9HQAbEK+VxpBe54Ryp/dj4q9KmqDIfhV7mtP+hbvc/1AUf/AaWFIve3eURO0cxoGN4ZQQ3o2HTg== for-in@^1.0.1, for-in@^1.0.2: version "1.0.2" @@ -2858,13 +2883,6 @@ form-data@~2.3.2: combined-stream "1.0.6" mime-types "^2.1.12" -formatio@1.2.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/formatio/-/formatio-1.2.0.tgz#f3b2167d9068c4698a8d51f4f760a39a54d818eb" - integrity sha1-87IWfZBoxGmKjVH092CjmlTYGOs= - dependencies: - samsam "1.x" - fragment-cache@^0.2.1: version "0.2.1" resolved "https://registry.yarnpkg.com/fragment-cache/-/fragment-cache-0.2.1.tgz#4290fad27f13e89be7f33799c6bc5a0abfff0d19" @@ -2967,6 +2985,13 @@ get-stream@^3.0.0: resolved "https://registry.yarnpkg.com/get-stream/-/get-stream-3.0.0.tgz#8e943d1358dc37555054ecbe2edb05aa174ede14" integrity sha1-jpQ9E1jcN1VQVOy+LtsFqhdO3hQ= +get-stream@^4.0.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/get-stream/-/get-stream-4.1.0.tgz#c1b255575f3dc21d59bfc79cd3d2b46b1c3a54b5" + integrity sha512-GMat4EJ5161kIy2HevLlr4luNjBgvmj413KaQA7jt4V8B4RDsfpHk7WQ9GVqfYyyx8OS/L66Kox+rJRNklLK7w== + dependencies: + pump "^3.0.0" + get-value@^2.0.3, get-value@^2.0.6: version "2.0.6" resolved "https://registry.yarnpkg.com/get-value/-/get-value-2.0.6.tgz#dc15ca1c672387ca76bd37ac0a395ba2042a2c28" @@ -3550,11 +3575,6 @@ is-windows@^1.0.2: resolved "https://registry.yarnpkg.com/is-windows/-/is-windows-1.0.2.tgz#d1850eb9791ecd18e6182ce12a30f396634bb19d" integrity sha512-eXK1UInq2bPmjyX6e3VHIzMLobc4J94i4AWn+Hpq3OU5KkrRC96OAcR3PRJ/pGu6m8TRnBHP9dkXQVsT/COVIA== -isarray@0.0.1: - version "0.0.1" - resolved "https://registry.yarnpkg.com/isarray/-/isarray-0.0.1.tgz#8a18acfca9a8f4177e09abfc6038939b05d1eedf" - integrity sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8= - isarray@1.0.0, isarray@~1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/isarray/-/isarray-1.0.0.tgz#bb935d48582cba168c06834957a54a3e07124f11" @@ -3739,17 +3759,24 @@ jest-diff@^23.6.0: jest-get-type "^22.1.0" pretty-format "^23.6.0" -jest-docblock@23.2.0, jest-docblock@^23.2.0: +jest-docblock@^21.0.0: + version "21.2.0" + resolved "https://registry.yarnpkg.com/jest-docblock/-/jest-docblock-21.2.0.tgz#51529c3b30d5fd159da60c27ceedc195faf8d414" + integrity sha512-5IZ7sY9dBAYSV+YjQ0Ovb540Ku7AO9Z5o2Cg789xj167iQuZ2cG+z0f3Uct6WeYLbU6aQiM2pCs7sZ+4dotydw== + +jest-docblock@^23.2.0: version "23.2.0" resolved "https://registry.yarnpkg.com/jest-docblock/-/jest-docblock-23.2.0.tgz#f085e1f18548d99fdd69b20207e6fd55d91383a7" integrity sha1-8IXh8YVI2Z/dabICB+b9VdkTg6c= dependencies: detect-newline "^2.1.0" -jest-docblock@^21.0.0: - version "21.2.0" - resolved "https://registry.yarnpkg.com/jest-docblock/-/jest-docblock-21.2.0.tgz#51529c3b30d5fd159da60c27ceedc195faf8d414" - integrity sha512-5IZ7sY9dBAYSV+YjQ0Ovb540Ku7AO9Z5o2Cg789xj167iQuZ2cG+z0f3Uct6WeYLbU6aQiM2pCs7sZ+4dotydw== +jest-docblock@^24.0.0-alpha.2: + version "24.0.0-alpha.5" + resolved "https://registry.yarnpkg.com/jest-docblock/-/jest-docblock-24.0.0-alpha.5.tgz#4d41cde48074c15a9167838ce36b122c05b311a9" + integrity sha512-IrLbRQIW0dE3OAoRiQ2BPJBz6M8OatpuyB8RxaBWEtXQzPV7nN5ZmnKdW7laajX4pQ7EkxLITClWMWBdWEfFTQ== + dependencies: + detect-newline "^2.1.0" jest-each@^23.6.0: version "23.6.0" @@ -3781,19 +3808,19 @@ jest-get-type@^22.1.0: resolved "https://registry.yarnpkg.com/jest-get-type/-/jest-get-type-22.4.3.tgz#e3a8504d8479342dd4420236b322869f18900ce4" integrity sha512-/jsz0Y+V29w1chdXVygEKSz2nBoHoYqNShPe+QgxSNjAuP1i8+k4LbQNrfoliKej0P45sivkSCh7yiD6ubHS3w== -jest-haste-map@23.5.0: - version "23.5.0" - resolved "https://registry.yarnpkg.com/jest-haste-map/-/jest-haste-map-23.5.0.tgz#d4ca618188bd38caa6cb20349ce6610e194a8065" - integrity sha512-bt9Swigb6KZ6ZQq/fQDUwdUeHenVvZ6G/lKwJjwRGp+Fap8D4B3bND3FaeJg7vXVsLX8hXshRArbVxLop/5wLw== +jest-haste-map@24.0.0-alpha.2: + version "24.0.0-alpha.2" + resolved "https://registry.yarnpkg.com/jest-haste-map/-/jest-haste-map-24.0.0-alpha.2.tgz#bc1d498536c395699a44b1e61a3e901c95a2e5a6" + integrity sha512-FTSIbJdmaddjgpcaXOq+sPGegcE28w7uOHonpsCuEwBQcB0REhkNYY9Wj/e1w+q3SBmEK1++ChgTMEXEzAf0yQ== dependencies: fb-watchman "^2.0.0" graceful-fs "^4.1.11" invariant "^2.2.4" - jest-docblock "^23.2.0" - jest-serializer "^23.0.1" - jest-worker "^23.2.0" + jest-docblock "^24.0.0-alpha.2" + jest-serializer "^24.0.0-alpha.2" + jest-worker "^24.0.0-alpha.2" micromatch "^2.3.11" - sane "^2.0.0" + sane "^3.0.0" jest-haste-map@^23.6.0: version "23.6.0" @@ -3937,11 +3964,21 @@ jest-runtime@^23.6.0: write-file-atomic "^2.1.0" yargs "^11.0.0" -jest-serializer@23.0.1, jest-serializer@^23.0.1: +jest-serializer@24.0.0-alpha.2: + version "24.0.0-alpha.2" + resolved "https://registry.yarnpkg.com/jest-serializer/-/jest-serializer-24.0.0-alpha.2.tgz#adcaa73ef49e56377f7fada19921c300b576e7f9" + integrity sha512-jLHHT71gyYdgMH5sFWP/e8bZjq/TC5iz9DQZlLsRE/7Er//m8WqyiNJs022FEc18PLq3jyk/z06N0xS6YlbsUA== + +jest-serializer@^23.0.1: version "23.0.1" resolved "https://registry.yarnpkg.com/jest-serializer/-/jest-serializer-23.0.1.tgz#a3776aeb311e90fe83fab9e533e85102bd164165" integrity sha1-o3dq6zEekP6D+rnlM+hRAr0WQWU= +jest-serializer@^24.0.0-alpha.2: + version "24.0.0-alpha.5" + resolved "https://registry.yarnpkg.com/jest-serializer/-/jest-serializer-24.0.0-alpha.5.tgz#23899c258aedb1220b203b5d5f19af0d359ef29e" + integrity sha512-7ALgCVX1mgnJB2DWkWEGku0fkwPwbuRNFgyXUnrGeLpUONd6GdebByshE1w8l9W0q0v9ARibaaFa0VpqudcHZQ== + jest-snapshot@^23.6.0: version "23.6.0" resolved "https://registry.yarnpkg.com/jest-snapshot/-/jest-snapshot-23.6.0.tgz#f9c2625d1b18acda01ec2d2b826c0ce58a5aa17a" @@ -3991,13 +4028,27 @@ jest-watcher@^23.4.0: chalk "^2.0.1" string-length "^2.0.0" -jest-worker@23.2.0, jest-worker@^23.2.0: +jest-worker@24.0.0-alpha.2: + version "24.0.0-alpha.2" + resolved "https://registry.yarnpkg.com/jest-worker/-/jest-worker-24.0.0-alpha.2.tgz#d376b328094dd5f1e0c6156b4f41b308a99a35bd" + integrity sha512-77YRl8eI4rrtdJ4mzzo4LVABecQmmy7lXsXc00rIJ9oiXJYbz4R4eL6RXcxZcRbwwqYjFL0g9h6H9iQaWqC/Kg== + dependencies: + merge-stream "^1.0.1" + +jest-worker@^23.2.0: version "23.2.0" resolved "https://registry.yarnpkg.com/jest-worker/-/jest-worker-23.2.0.tgz#faf706a8da36fae60eb26957257fa7b5d8ea02b9" integrity sha1-+vcGqNo2+uYOsmlXJX+ntdjqArk= dependencies: merge-stream "^1.0.1" +jest-worker@^24.0.0-alpha.2: + version "24.0.0-alpha.5" + resolved "https://registry.yarnpkg.com/jest-worker/-/jest-worker-24.0.0-alpha.5.tgz#82c3d64274f5134ec9df03d1a159ee4dd710c03d" + integrity sha512-JL6nOBzVxF7f5Nc2/Cpek2fjKjjuRtQkNIP0G+eu0i787oX6xvibsSASVONaavY6D+hxppk4aYrgJh8/UTgkuA== + dependencies: + merge-stream "^1.0.1" + jest@23.4.1: version "23.4.1" resolved "https://registry.yarnpkg.com/jest/-/jest-23.4.1.tgz#39550c72f3237f63ae1b434d8d122cdf6fa007b6" @@ -4279,11 +4330,6 @@ lodash@4.x.x, lodash@^4.13.1, lodash@^4.15.0, lodash@^4.17.10, lodash@^4.17.4, l resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.11.tgz#b39ea6229ef607ecd89e2c8df12536891cac9b8d" integrity sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg== -lolex@^1.6.0: - version "1.6.0" - resolved "https://registry.yarnpkg.com/lolex/-/lolex-1.6.0.tgz#3a9a0283452a47d7439e72731b9e07d7386e49f6" - integrity sha1-OpoCg0UqR9dDnnJzG54H1zhuSfY= - loose-envify@^1.0.0, loose-envify@^1.1.0, loose-envify@^1.3.1: version "1.4.0" resolved "https://registry.yarnpkg.com/loose-envify/-/loose-envify-1.4.0.tgz#71ee51fa7be4caec1a63839f7e682d8132d30caf" @@ -4349,10 +4395,10 @@ merge@^1.2.0: resolved "https://registry.yarnpkg.com/merge/-/merge-1.2.0.tgz#7531e39d4949c281a66b8c5a6e0265e8b05894da" integrity sha1-dTHjnUlJwoGma4xabgJl6LBYlNo= -metro-babel-register@^0.48.0: - version "0.48.0" - resolved "https://registry.yarnpkg.com/metro-babel-register/-/metro-babel-register-0.48.0.tgz#51ac2eaf1733346f131bba4e801f9573428c818c" - integrity sha512-1hi+FxAgaUspuEQ32G79541PCMIWGhDtmPWusSUN6zfrvTVYYPmUIE+E/QLVj+6o0I1S8GkgNIm0f622sufF6g== +metro-babel-register@^0.48.1: + version "0.48.3" + resolved "https://registry.yarnpkg.com/metro-babel-register/-/metro-babel-register-0.48.3.tgz#459b9e5bd635775e342109b6acd70fd63c731f57" + integrity sha512-KCuapWsM9Nrwb2XHQ0NhiTGZ9PrQfai8drhDrU5+A/aFGQ33N2wOvKet5OVRRyEuUvJ79Hbq0xs4UpFM13tQig== dependencies: "@babel/core" "^7.0.0" "@babel/plugin-proposal-class-properties" "^7.0.0" @@ -4367,60 +4413,60 @@ metro-babel-register@^0.48.0: core-js "^2.2.2" escape-string-regexp "^1.0.5" -metro-babel7-plugin-react-transform@0.48.0: - version "0.48.0" - resolved "https://registry.yarnpkg.com/metro-babel7-plugin-react-transform/-/metro-babel7-plugin-react-transform-0.48.0.tgz#3aabfbd695833bd3aad0713668e89ad91627f207" - integrity sha512-0z0fj9lj2F1F3/yLdSdsCR2r2wBbvjJdHtUW+5eb4kr0B6ZDq9aBuaple2u7/srghRsqG89kfTZHgRgOQ15oIw== +metro-babel7-plugin-react-transform@0.48.3: + version "0.48.3" + resolved "https://registry.yarnpkg.com/metro-babel7-plugin-react-transform/-/metro-babel7-plugin-react-transform-0.48.3.tgz#c3e43c99173c143537fb234b44cdd6e6b511d511" + integrity sha512-F3fjKig7KJl+5iqjWUStx/Sv3Oryw1cftIx0MhaXOgq4emdd1NYoC1sMYrGdDY8aLPDysH9J7sIeErH805oFUg== dependencies: "@babel/helper-module-imports" "^7.0.0" -metro-cache@0.48.0: - version "0.48.0" - resolved "https://registry.yarnpkg.com/metro-cache/-/metro-cache-0.48.0.tgz#2a3fbd2ae4fca90f067440b5dec02989a6e9ba20" - integrity sha512-Bv0GN2TwCDny2LYlHbOnWZxw9I2fLIh+UZdg606QKCu67C0jZIP2JF+9EwIOGuSL6iBBYhA5TN69O8xsYFZ7Tw== +metro-cache@0.48.3: + version "0.48.3" + resolved "https://registry.yarnpkg.com/metro-cache/-/metro-cache-0.48.3.tgz#8c2818d3cd6b79570cd7750da4685e9c7c061577" + integrity sha512-q49ult2PW2BYTuGCS5RXmMB+ejdOWtNHWh9yZS5XvI/xlfLZjJL47yakcOz3C8UImdRhWV8X890/+rQU7nALCg== dependencies: - jest-serializer "23.0.1" - metro-core "0.48.0" + jest-serializer "24.0.0-alpha.2" + metro-core "0.48.3" mkdirp "^0.5.1" rimraf "^2.5.4" -metro-config@0.48.0: - version "0.48.0" - resolved "https://registry.yarnpkg.com/metro-config/-/metro-config-0.48.0.tgz#faac7ea7c272f399b13421013afeea49eb2b0300" - integrity sha512-YRe7tE+BJ8WLcNMuegSHRmOYtmGkmNqXQtPUgMuUiamXHDFXvLdU4cAOaE+0bybF0egAw8GoOomTKROKRJbxjQ== +metro-config@0.48.3: + version "0.48.3" + resolved "https://registry.yarnpkg.com/metro-config/-/metro-config-0.48.3.tgz#71f9f27911582e960a660ed2b08cb4ee5d58724d" + integrity sha512-rpO0Edy6H7N2RnEUPQufIG6DdU/lXZcMIRP3UHR93Q7IuZEwkSd3lS0trCMqdkj5Hx7eIx+gj/MQrNDSa0L0gw== dependencies: cosmiconfig "^5.0.5" - metro "0.48.0" - metro-cache "0.48.0" - metro-core "0.48.0" + metro "0.48.3" + metro-cache "0.48.3" + metro-core "0.48.3" pretty-format "^23.4.1" -metro-core@0.48.0, metro-core@^0.48.0: - version "0.48.0" - resolved "https://registry.yarnpkg.com/metro-core/-/metro-core-0.48.0.tgz#9c6acc2ec0d4be2fe7a0b7b4ac76cf56d0de411c" - integrity sha512-edIEeKbOJRTMWvG3/gbPgsmH6MZ8v0Oh2yJYK90BKhh71zweIk0vhhTlesxMF2LzdWWBxs9B6vq2M9hiz0D3zA== +metro-core@0.48.3, metro-core@^0.48.1: + version "0.48.3" + resolved "https://registry.yarnpkg.com/metro-core/-/metro-core-0.48.3.tgz#be2d615eaec759c8d01559e8685554cbdf8e7c4f" + integrity sha512-bLIikpGBvdaZhwvmnpY5OwS2XhOWGX7YUvRN4IegfTOYo88TzL/SAB5Osr7lpYGvTmGdJFJ5Mqr3Xy4bVGFEvA== dependencies: - jest-haste-map "23.5.0" + jest-haste-map "24.0.0-alpha.2" lodash.throttle "^4.1.1" - metro-resolver "0.48.0" + metro-resolver "0.48.3" wordwrap "^1.0.0" -metro-memory-fs@^0.48.0: - version "0.48.0" - resolved "https://registry.yarnpkg.com/metro-memory-fs/-/metro-memory-fs-0.48.0.tgz#a18dec484a91f1b951de2af0e7af1cf754fb7290" - integrity sha512-wpSVOo/8foAur5w8S/CiTM4et6L3qOljnRHA2PG7POEjM3d33zO6292cWEnvZ/Uus08SBfhOQP6t65I/jGaY1A== +metro-memory-fs@^0.48.1: + version "0.48.3" + resolved "https://registry.yarnpkg.com/metro-memory-fs/-/metro-memory-fs-0.48.3.tgz#2d180a73992daf08e242ea49682f72e6f0f7f094" + integrity sha512-Ku6k0JHZZ/EIHlIJZZEAJ7ItDq/AdIOpmgt4ebkQ6WJRUOc0960K3BQdRFiwL8riQKWJMlKZcXc4/2ktoY3U9A== -metro-minify-uglify@0.48.0: - version "0.48.0" - resolved "https://registry.yarnpkg.com/metro-minify-uglify/-/metro-minify-uglify-0.48.0.tgz#aefe8f353cdf20fdfb14049aaa271b5384d638f1" - integrity sha512-wdMC3Xzgr7o/eGkAvWq7G/w9DIgHFh6yAQBW4LLSMJ1Y1laTnr4BvXfeodLFD91Z6GRFJR7kQiO6yf0jbPmoJg== +metro-minify-uglify@0.48.3: + version "0.48.3" + resolved "https://registry.yarnpkg.com/metro-minify-uglify/-/metro-minify-uglify-0.48.3.tgz#493baadb65f6a1d8cab9fd157ac80c5801b23149" + integrity sha512-EvzoqPMbm839T6AXSYWF76b/VNqoY3E1oAbZoyZbN/J7EHHgz2xEVt4M49fI6tEKPCPzpEpGnJKoxjnkV9XdrA== dependencies: uglify-es "^3.1.9" -metro-react-native-babel-preset@0.48.0: - version "0.48.0" - resolved "https://registry.yarnpkg.com/metro-react-native-babel-preset/-/metro-react-native-babel-preset-0.48.0.tgz#edb9d88d8e0a2e47865a08be0ba81b5fe31e8b8e" - integrity sha512-HjHWmbpvistlC/UuaTKh+AkVmNxw5pqUhb/RSL7isxLrOgxFCG063P0aHl+GwT8EFA4ZnHL9YCqceop1Ewfq9w== +metro-react-native-babel-preset@0.48.3: + version "0.48.3" + resolved "https://registry.yarnpkg.com/metro-react-native-babel-preset/-/metro-react-native-babel-preset-0.48.3.tgz#839dbd0d9e4012f550861d2295b998144a61bcc8" + integrity sha512-GDW4yWk8z5RGk8A67OTS05luxCHZFDHbEuzesyxG1SlE/W6ODfJOPQpIFlFuPUEvVDunG0lYn3dGBL2VcaVVpQ== dependencies: "@babel/plugin-proposal-class-properties" "^7.0.0" "@babel/plugin-proposal-export-default-from" "^7.0.0" @@ -4455,27 +4501,27 @@ metro-react-native-babel-preset@0.48.0: "@babel/plugin-transform-typescript" "^7.0.0" "@babel/plugin-transform-unicode-regex" "^7.0.0" "@babel/template" "^7.0.0" - metro-babel7-plugin-react-transform "0.48.0" + metro-babel7-plugin-react-transform "0.48.3" react-transform-hmr "^1.0.4" -metro-resolver@0.48.0: - version "0.48.0" - resolved "https://registry.yarnpkg.com/metro-resolver/-/metro-resolver-0.48.0.tgz#52eae2b7a5accf788fc26e461ef6b3e39a3b7544" - integrity sha512-e7yJ7g/OxZflNEiV1ewPa7iFxiZAx/dfL291tNxZWFXVUbkJ3/gbY2Qt8HTr3KGwiZmQP+XHh6m5KISr9fuyCg== +metro-resolver@0.48.3: + version "0.48.3" + resolved "https://registry.yarnpkg.com/metro-resolver/-/metro-resolver-0.48.3.tgz#3459c117f25a6d91d501eb1c81fdc98fcfea1cc0" + integrity sha512-aXZdd4SWVPnTlnJ55f918QLvGOE8zlrGt8y8/BS0EktzPORkkXnouzC0dtkq5lTpFSX7b1OD2z3ZtZLxM5sQVg== dependencies: absolute-path "^0.0.0" -metro-source-map@0.48.0: - version "0.48.0" - resolved "https://registry.yarnpkg.com/metro-source-map/-/metro-source-map-0.48.0.tgz#578bdf0676b4d9d73b0a9ff363b6ec80d5b7ef35" - integrity sha512-DByXLAwvwyE7524QytWva2rw8C/LXaNaG5byrbNNgp84fd8wJX2TObHJpY3140b0vwoOsDJcjwfnnn3+fdLGgw== +metro-source-map@0.48.3: + version "0.48.3" + resolved "https://registry.yarnpkg.com/metro-source-map/-/metro-source-map-0.48.3.tgz#ab102bf71c83754e6d5a04c3faf612a88e7f5dcf" + integrity sha512-TAIn1c/G69PHa+p4CUl7myXw5gOT4J1xXXLKAjIOA6xjxttMEa1S5co6fsXzvTMR+psK9OAsgBW3VAaEcJGEcw== dependencies: source-map "^0.5.6" -metro@0.48.0, metro@^0.48.0: - version "0.48.0" - resolved "https://registry.yarnpkg.com/metro/-/metro-0.48.0.tgz#52e2ca1fb220ed8c03977f17f63447178f339967" - integrity sha512-iJGsn7M9IKDXCyUXQRHSkUk3Oees7mV4dDTpDtgmzWUDo+pA0dGyxApE1obWNzAYltp6yKdJw1mcQoEMDZdfVw== +metro@0.48.3, metro@^0.48.1: + version "0.48.3" + resolved "https://registry.yarnpkg.com/metro/-/metro-0.48.3.tgz#43639828dc22fd75e0d31ce75a6dc4615feaf5f7" + integrity sha512-sf4Q95Zk7cvqi537WbQTvaPbPXflAk1zGWA50uchkF+frJHZWop5kwtbtWwvDGlPHgptjjXc3yTvIo5Y0LTkqQ== dependencies: "@babel/core" "^7.0.0" "@babel/generator" "^7.0.0" @@ -4487,6 +4533,7 @@ metro@0.48.0, metro@^0.48.0: absolute-path "^0.0.0" async "^2.4.0" babel-preset-fbjs "^3.0.1" + buffer-crc32 "^0.2.13" chalk "^1.1.1" concat-stream "^1.6.0" connect "^3.6.5" @@ -4497,19 +4544,18 @@ metro@0.48.0, metro@^0.48.0: fs-extra "^1.0.0" graceful-fs "^4.1.3" image-size "^0.6.0" - jest-docblock "23.2.0" - jest-haste-map "23.5.0" - jest-worker "23.2.0" + jest-haste-map "24.0.0-alpha.2" + jest-worker "24.0.0-alpha.2" json-stable-stringify "^1.0.1" lodash.throttle "^4.1.1" merge-stream "^1.0.1" - metro-cache "0.48.0" - metro-config "0.48.0" - metro-core "0.48.0" - metro-minify-uglify "0.48.0" - metro-react-native-babel-preset "0.48.0" - metro-resolver "0.48.0" - metro-source-map "0.48.0" + metro-cache "0.48.3" + metro-config "0.48.3" + metro-core "0.48.3" + metro-minify-uglify "0.48.3" + metro-react-native-babel-preset "0.48.3" + metro-resolver "0.48.3" + metro-source-map "0.48.3" mime-types "2.1.11" mkdirp "^0.5.1" node-fetch "^2.2.0" @@ -4725,11 +4771,6 @@ nanomatch@^1.2.9: snapdragon "^0.8.1" to-regex "^3.0.1" -native-promise-only@^0.8.1: - version "0.8.1" - resolved "https://registry.yarnpkg.com/native-promise-only/-/native-promise-only-0.8.1.tgz#20a318c30cb45f71fe7adfbf7b21c99c1472ef11" - integrity sha1-IKMYwwy0X3H+et+/eyHJnBRy7xE= - natural-compare@^1.4.0: version "1.4.0" resolved "https://registry.yarnpkg.com/natural-compare/-/natural-compare-1.4.0.tgz#4abebfeed7541f2c27acfb29bdbbd15c8d5ba4f7" @@ -4958,7 +4999,7 @@ on-headers@~1.0.1: resolved "https://registry.yarnpkg.com/on-headers/-/on-headers-1.0.1.tgz#928f5d0f470d49342651ea6794b0857c100693f7" integrity sha1-ko9dD0cNSTQmUepnlLCFfBAGk/c= -once@^1.3.0, once@^1.4.0: +once@^1.3.0, once@^1.3.1, once@^1.4.0: version "1.4.0" resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1" integrity sha1-WDsap3WWHUsROsF9nFC6753Xa9E= @@ -5127,13 +5168,6 @@ path-parse@^1.0.5: resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.6.tgz#d62dbb5679405d72c4737ec58600e9ddcf06d24c" integrity sha512-GSmOT2EbHrINBf9SR7CDELwlJ8AENk3Qn7OikK4nFYAu3Ote2+JYNVvkpAEQm3/TLNEJFD/xZJjzyxg3KBWOzw== -path-to-regexp@^1.7.0: - version "1.7.0" - resolved "https://registry.yarnpkg.com/path-to-regexp/-/path-to-regexp-1.7.0.tgz#59fde0f435badacba103a84e9d3bc64e96b9937d" - integrity sha1-Wf3g9DW62suhA6hOnTvGTpa5k30= - dependencies: - isarray "0.0.1" - path-type@^1.0.0: version "1.1.0" resolved "https://registry.yarnpkg.com/path-type/-/path-type-1.1.0.tgz#59c44f7ee491da704da415da5a4070ba4f8fe441" @@ -5263,6 +5297,11 @@ pretty-format@^23.4.1, pretty-format@^23.6.0: ansi-regex "^3.0.0" ansi-styles "^3.2.0" +pretty-format@^4.2.1: + version "4.3.1" + resolved "https://registry.yarnpkg.com/pretty-format/-/pretty-format-4.3.1.tgz#530be5c42b3c05b36414a7a2a4337aa80acd0e8d" + integrity sha1-UwvlxCs8BbNkFKeipDN6qArNDo0= + private@^0.1.6, private@^0.1.8: version "0.1.8" resolved "https://registry.yarnpkg.com/private/-/private-0.1.8.tgz#2381edb3689f7a53d653190060fcf822d2f368ff" @@ -5329,6 +5368,14 @@ psl@^1.1.24: resolved "https://registry.yarnpkg.com/psl/-/psl-1.1.29.tgz#60f580d360170bb722a797cc704411e6da850c67" integrity sha512-AeUmQ0oLN02flVHXWh9sSJF7mcdFq0ppid/JkErufc3hGIV/AMa8Fo9VgDo/cT2jFdOWoFvHp90qqBH54W+gjQ== +pump@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/pump/-/pump-3.0.0.tgz#b4a2116815bde2f4e1ea602354e8c75565107a64" + integrity sha512-LwZy+p3SFs1Pytd/jYct4wpv49HiYCqd9Rlc5ZVdk0V+8Yzv6jR5Blk3TRmPL1ft69TxP0IMZGJ+WPFU2BFhww== + dependencies: + end-of-stream "^1.1.0" + once "^1.3.1" + punycode@^1.4.1: version "1.4.1" resolved "https://registry.yarnpkg.com/punycode/-/punycode-1.4.1.tgz#c0d5a63b2718800ad8e1eb0fa5269c84dd41845e" @@ -5386,10 +5433,10 @@ react-devtools-core@^3.4.0: shell-quote "^1.6.1" ws "^3.3.1" -react-is@^16.6.0-alpha.400d197: - version "16.6.0-alpha.400d197" - resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.6.0-alpha.400d197.tgz#2ca008cdc80ebc1cdd706ce59dadbd2e3774b30a" - integrity sha512-ZmcGAxIHbjEydr+3lswKHHyBwfSMIcISdo8jzPKEhW3ikAUGtJcim/P19iBDxTkrqMVwZZYoGIsc/u7B9KLv0w== +react-is@^16.6.1: + version "16.6.1" + resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.6.1.tgz#f77b1c3d901be300abe8d58645b7a59e794e5982" + integrity sha512-wOKsGtvTMYs7WAscmwwdM8sfRRvE17Ym30zFj3n37Qx5tHRfhenPKEPILHaHob6WoLFADmQm1ZNrE5xMCM6sCw== react-native-dummy@0.1.0: version "0.1.0" @@ -5404,15 +5451,15 @@ react-proxy@^1.1.7: lodash "^4.6.1" react-deep-force-update "^1.0.0" -react-test-renderer@16.6.0-alpha.400d197: - version "16.6.0-alpha.400d197" - resolved "https://registry.yarnpkg.com/react-test-renderer/-/react-test-renderer-16.6.0-alpha.400d197.tgz#f0f5c703fef5685a66fd5bcb43e059994ebaed54" - integrity sha512-wGv0xcq/dGInTtsF+LwwBEawprtIbjMTCgJEinZzOW2R8+Izx12PRBPr8pZmAoNCuJVyB/y8fdJsvZdABsQ33w== +react-test-renderer@16.6.1: + version "16.6.1" + resolved "https://registry.yarnpkg.com/react-test-renderer/-/react-test-renderer-16.6.1.tgz#8ea357652be3cf81cbd6b2f686e74ebe67c17b78" + integrity sha512-sgZwJZYIgQptRi2qk5+gB8FBQGk4gLSs0gmKZPMfhd3dLkdxIUwVLHteLN3Bnj4LokIZd3U+V2NEJUqeV2PT2w== dependencies: object-assign "^4.1.1" prop-types "^15.6.2" - react-is "^16.6.0-alpha.400d197" - scheduler "^0.10.0-alpha.400d197" + react-is "^16.6.1" + scheduler "^0.11.0" react-timer-mixin@^0.13.2: version "0.13.4" @@ -5427,15 +5474,15 @@ react-transform-hmr@^1.0.4: global "^4.3.0" react-proxy "^1.1.7" -react@16.6.0-alpha.400d197: - version "16.6.0-alpha.400d197" - resolved "https://registry.yarnpkg.com/react/-/react-16.6.0-alpha.400d197.tgz#250974bc3abc0327c34088fdcd10e3a62130d195" - integrity sha512-Ve8p2P2D9SZTTLro7jrW+pkO1NZkB2lWq8qvyO4c5NEi/OlaLDwQStKcPJGkw2kpMLu8mxBZ4ERDcwrAIwMSdw== +react@16.6.1: + version "16.6.1" + resolved "https://registry.yarnpkg.com/react/-/react-16.6.1.tgz#ee2aef4f0a09e494594882029821049772f915fe" + integrity sha512-OtawJThYlvRgm9BXK+xTL7BIlDx8vv21j+fbQDjRRUyok6y7NyjlweGorielTahLZHYIdKUoK2Dp9ByVWuMqxw== dependencies: loose-envify "^1.1.0" object-assign "^4.1.1" prop-types "^15.6.2" - scheduler "^0.10.0-alpha.400d197" + scheduler "^0.11.0" read-pkg-up@^1.0.1: version "1.0.1" @@ -5784,11 +5831,6 @@ safe-regex@^1.1.0: resolved "https://registry.yarnpkg.com/safer-buffer/-/safer-buffer-2.1.2.tgz#44fa161b0187b9549dd84bb91802f9bd8385cd6a" integrity sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg== -samsam@1.x, samsam@^1.1.3: - version "1.3.0" - resolved "https://registry.yarnpkg.com/samsam/-/samsam-1.3.0.tgz#8d1d9350e25622da30de3e44ba692b5221ab7c50" - integrity sha512-1HwIYD/8UlOtFS3QO3w7ey+SdSDFE4HRNLZoZRYVQefrOY3l17epswImeB1ijgJFQJodIaHcwkp3r/myBjFVbg== - sane@^2.0.0: version "2.5.2" resolved "https://registry.yarnpkg.com/sane/-/sane-2.5.2.tgz#b4dc1861c21b427e929507a3e751e2a2cb8ab3fa" @@ -5805,6 +5847,23 @@ sane@^2.0.0: optionalDependencies: fsevents "^1.2.3" +sane@^3.0.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/sane/-/sane-3.1.0.tgz#995193b7dc1445ef1fe41ddfca2faf9f111854c6" + integrity sha512-G5GClRRxT1cELXfdAq7UKtUsv8q/ZC5k8lQGmjEm4HcAl3HzBy68iglyNCmw4+0tiXPCBZntslHlRhbnsSws+Q== + dependencies: + anymatch "^2.0.0" + capture-exit "^1.2.0" + exec-sh "^0.2.0" + execa "^1.0.0" + fb-watchman "^2.0.0" + micromatch "^3.1.4" + minimist "^1.1.1" + walker "~1.0.5" + watch "~0.18.0" + optionalDependencies: + fsevents "^1.2.3" + sanitize-filename@^1.6.1: version "1.6.1" resolved "https://registry.yarnpkg.com/sanitize-filename/-/sanitize-filename-1.6.1.tgz#612da1c96473fa02dccda92dcd5b4ab164a6772a" @@ -5822,10 +5881,10 @@ sax@~1.1.1: resolved "http://registry.npmjs.org/sax/-/sax-1.1.6.tgz#5d616be8a5e607d54e114afae55b7eaf2fcc3240" integrity sha1-XWFr6KXmB9VOEUr65Vt+ry/MMkA= -scheduler@^0.10.0-alpha.400d197: - version "0.10.0-alpha.400d197" - resolved "https://registry.yarnpkg.com/scheduler/-/scheduler-0.10.0-alpha.400d197.tgz#9eeea8bd403bba465e177b4a8d30fb846af20b79" - integrity sha512-PLCKZLDzUG+b1dIECw6UW35lgrA+OO+VRfHshMbths5qXzlapPTPNmZb9F25FOJy+H288RRqpp21MSZhofXVNQ== +scheduler@^0.11.0: + version "0.11.0" + resolved "https://registry.yarnpkg.com/scheduler/-/scheduler-0.11.0.tgz#def1f1bfa6550cc57981a87106e65e8aea41a6b5" + integrity sha512-MAYbBfmiEHxF0W+c4CxMpEqMYK+rYF584VP/qMKSiHM6lTkBKKYOJaDiSILpJHla6hBOsVd6GucPL46o2Uq3sg== dependencies: loose-envify "^1.1.0" object-assign "^4.1.1" @@ -5961,20 +6020,6 @@ simple-plist@^0.2.1: bplist-parser "0.1.1" plist "2.0.1" -sinon@^2.2.0: - version "2.4.1" - resolved "https://registry.yarnpkg.com/sinon/-/sinon-2.4.1.tgz#021fd64b54cb77d9d2fb0d43cdedfae7629c3a36" - integrity sha512-vFTrO9Wt0ECffDYIPSP/E5bBugt0UjcBQOfQUMh66xzkyPEnhl/vM2LRZi2ajuTdkH07sA6DzrM6KvdvGIH8xw== - dependencies: - diff "^3.1.0" - formatio "1.2.0" - lolex "^1.6.0" - native-promise-only "^0.8.1" - path-to-regexp "^1.7.0" - samsam "^1.1.3" - text-encoding "0.6.4" - type-detect "^4.0.0" - sisteransi@^0.1.1: version "0.1.1" resolved "https://registry.yarnpkg.com/sisteransi/-/sisteransi-0.1.1.tgz#5431447d5f7d1675aac667ccd0b865a4994cb3ce" @@ -6342,11 +6387,6 @@ test-exclude@^4.2.1: read-pkg-up "^1.0.1" require-main-filename "^1.0.1" -text-encoding@0.6.4: - version "0.6.4" - resolved "https://registry.yarnpkg.com/text-encoding/-/text-encoding-0.6.4.tgz#e399a982257a276dae428bb92845cb71bdc26d19" - integrity sha1-45mpgiV6J22uQou5KEXLcb3CbRk= - text-table@^0.2.0: version "0.2.0" resolved "https://registry.yarnpkg.com/text-table/-/text-table-0.2.0.tgz#7f5ee823ae805207c00af2df4a84ec3fcfa570b4" @@ -6468,11 +6508,6 @@ type-check@~0.3.2: dependencies: prelude-ls "~1.1.2" -type-detect@^4.0.0: - version "4.0.8" - resolved "https://registry.yarnpkg.com/type-detect/-/type-detect-4.0.8.tgz#7646fb5f18871cfbb7749e69bd39a6388eb7450c" - integrity sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g== - typedarray@^0.0.6: version "0.0.6" resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777"