From 4cdb1951b460f91ef52a674d8ebdb11680a8257a Mon Sep 17 00:00:00 2001 From: Rick Hanlon Date: Wed, 5 Aug 2020 10:26:39 -0700 Subject: [PATCH] Back out ""React Native sync for revisions b5c6dd2...a437f3ff3"" Summary: Original commit changeset: c3c146b87fa5 Changelog: [Internal] Reviewed By: makovkastar Differential Revision: D22949053 fbshipit-source-id: 746719e44cd5d960dc14d7398f093a288ab61d88 --- .../__tests__/LogBox-integration-test.js | 5 +- .../LogBox-integration-test.js.snap | 94 + Libraries/Renderer/REVISION | 2 +- .../implementations/ReactFabric-dev.fb.js | 10525 +++++++-------- .../implementations/ReactFabric-prod.fb.js | 5076 ++++---- .../ReactFabric-profiling.fb.js | 5354 ++++---- .../ReactNativeRenderer-dev.fb.js | 10689 +++++++--------- .../ReactNativeRenderer-prod.fb.js | 5182 ++++---- .../ReactNativeRenderer-profiling.fb.js | 5461 ++++---- Libraries/Renderer/shims/ReactNativeTypes.js | 1 + package.json | 8 +- template/package.json | 4 +- yarn.lock | 43 +- 13 files changed, 19292 insertions(+), 23152 deletions(-) create mode 100644 Libraries/LogBox/__tests__/__snapshots__/LogBox-integration-test.js.snap diff --git a/Libraries/LogBox/__tests__/LogBox-integration-test.js b/Libraries/LogBox/__tests__/LogBox-integration-test.js index 8a02754df3d..f8187a4e5cb 100644 --- a/Libraries/LogBox/__tests__/LogBox-integration-test.js +++ b/Libraries/LogBox/__tests__/LogBox-integration-test.js @@ -49,10 +49,7 @@ const cleanLog = logs => { }); }; -// TODO(T71117418): Re-enable skipped LogBox integration tests once React component -// stack frames are the same internally and in open source. -// eslint-disable-next-line jest/no-disabled-tests -describe.skip('LogBox', () => { +describe('LogBox', () => { const {error, warn} = console; const mockError = jest.fn(); const mockWarn = jest.fn(); diff --git a/Libraries/LogBox/__tests__/__snapshots__/LogBox-integration-test.js.snap b/Libraries/LogBox/__tests__/__snapshots__/LogBox-integration-test.js.snap new file mode 100644 index 00000000000..9209ee6be5f --- /dev/null +++ b/Libraries/LogBox/__tests__/__snapshots__/LogBox-integration-test.js.snap @@ -0,0 +1,94 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`LogBox integrates with React and handles a fragment warning in LogBox: Log added to LogBox 1`] = ` +Array [ + Object { + "category": "Warning: Invalid prop \`%s\` supplied to \`React.Fragment\`. React.Fragment can only have \`key\` and \`children\` props.", + "componentStack": Array [ + Object { + "content": "Fragment", + "fileName": "ReactWarningFixtures.js", + "location": Object { + "column": -1, + "row": 28, + }, + }, + ], + "level": "warn", + "message": Object { + "content": "Warning: Invalid prop \`invalid\` supplied to \`React.Fragment\`. React.Fragment can only have \`key\` and \`children\` props.", + "substitutions": Array [ + Object { + "length": 7, + "offset": 23, + }, + ], + }, + }, +] +`; + +exports[`LogBox integrates with React and handles a fragment warning in LogBox: Log passed to console error 1`] = ` +Array [ + "Warning: Invalid prop \`invalid\` supplied to \`React.Fragment\`. React.Fragment can only have \`key\` and \`children\` props. + in Fragment (at ReactWarningFixtures.js:28)", +] +`; + +exports[`LogBox integrates with React and handles a fragment warning in LogBox: Log sent from React 1`] = ` +Array [ + "Warning: Invalid prop \`%s\` supplied to \`React.Fragment\`. React.Fragment can only have \`key\` and \`children\` props.%s", + "invalid", + " + in Fragment (at ReactWarningFixtures.js:28)", +] +`; + +exports[`LogBox integrates with React and handles a key error in LogBox: Log added to LogBox 1`] = ` +Array [ + Object { + "category": "Warning: Each child in a list should have a unique \\"key\\" prop.%s%s See https://fb.me/react-warning-keys for more information.", + "componentStack": Array [ + Object { + "content": "Text", + "fileName": "ReactWarningFixtures.js", + "location": Object { + "column": -1, + "row": 20, + }, + }, + ], + "level": "warn", + "message": Object { + "content": "Warning: Each child in a list should have a unique \\"key\\" prop. See https://fb.me/react-warning-keys for more information.", + "substitutions": Array [ + Object { + "length": 0, + "offset": 62, + }, + Object { + "length": 0, + "offset": 62, + }, + ], + }, + }, +] +`; + +exports[`LogBox integrates with React and handles a key error in LogBox: Log passed to console error 1`] = ` +Array [ + "Warning: Each child in a list should have a unique \\"key\\" prop. See https://fb.me/react-warning-keys for more information. + in Text (at ReactWarningFixtures.js:20)", +] +`; + +exports[`LogBox integrates with React and handles a key error in LogBox: Log sent from React 1`] = ` +Array [ + "Warning: Each child in a list should have a unique \\"key\\" prop.%s%s See https://fb.me/react-warning-keys for more information.%s", + "", + "", + " + in Text (at ReactWarningFixtures.js:20)", +] +`; diff --git a/Libraries/Renderer/REVISION b/Libraries/Renderer/REVISION index bb3889c8379..55c9a60f3d6 100644 --- a/Libraries/Renderer/REVISION +++ b/Libraries/Renderer/REVISION @@ -1 +1 @@ -a437f3ff302dc92347d812d518c9a9659d9aa546 \ No newline at end of file +b5c6dd2de557428974855b5aa88bf9c6595beb2b \ No newline at end of file diff --git a/Libraries/Renderer/implementations/ReactFabric-dev.fb.js b/Libraries/Renderer/implementations/ReactFabric-dev.fb.js index 58a9f4d2b2d..2a462f48ee4 100644 --- a/Libraries/Renderer/implementations/ReactFabric-dev.fb.js +++ b/Libraries/Renderer/implementations/ReactFabric-dev.fb.js @@ -23,7 +23,21 @@ var Scheduler = require("scheduler"); var tracing = require("scheduler/tracing"); var ReactSharedInternals = - React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED; + React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED; // Prevent newer renderers from RTE when used with older react package versions. +// Current owner and dispatcher used to share the same ref, +// but PR #14548 split them out to better support the react-debug-tools package. + +if (!ReactSharedInternals.hasOwnProperty("ReactCurrentDispatcher")) { + ReactSharedInternals.ReactCurrentDispatcher = { + current: null + }; +} + +if (!ReactSharedInternals.hasOwnProperty("ReactCurrentBatchConfig")) { + ReactSharedInternals.ReactCurrentBatchConfig = { + suspense: null + }; +} // by calls to these methods by a Babel plugin. // @@ -65,12 +79,19 @@ function printWarning(level, format, args) { // When changing this logic, you might want to also // update consoleWithStackDev.www.js as well. { - var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame; - var stack = ReactDebugCurrentFrame.getStackAddendum(); + var hasExistingStack = + args.length > 0 && + typeof args[args.length - 1] === "string" && + args[args.length - 1].indexOf("\n in") === 0; - if (stack !== "") { - format += "%s"; - args = args.concat([stack]); + if (!hasExistingStack) { + var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame; + var stack = ReactDebugCurrentFrame.getStackAddendum(); + + if (stack !== "") { + format += "%s"; + args = args.concat([stack]); + } } var argsWithFormat = args.map(function(item) { @@ -82,10 +103,161 @@ function printWarning(level, format, args) { // eslint-disable-next-line react-internal/no-production-logging Function.prototype.apply.call(console[level], 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 = + "Warning: " + + format.replace(/%s/g, function() { + return args[argIndex++]; + }); + throw new Error(message); + } catch (x) {} } } -function invokeGuardedCallbackProd(name, func, context, a, b, c, d, e, f) { +var FunctionComponent = 0; +var ClassComponent = 1; +var IndeterminateComponent = 2; // Before we know whether it is function or class + +var HostRoot = 3; // Root of a host tree. Could be nested inside another node. + +var HostPortal = 4; // A subtree. Could be an entry point to a different renderer. + +var HostComponent = 5; +var HostText = 6; +var Fragment = 7; +var Mode = 8; +var ContextConsumer = 9; +var ContextProvider = 10; +var ForwardRef = 11; +var Profiler = 12; +var SuspenseComponent = 13; +var MemoComponent = 14; +var SimpleMemoComponent = 15; +var LazyComponent = 16; +var IncompleteClassComponent = 17; +var DehydratedFragment = 18; +var SuspenseListComponent = 19; +var FundamentalComponent = 20; +var ScopeComponent = 21; +var Block = 22; + +function getParent(inst) { + do { + inst = inst.return; // TODO: If this is a HostRoot we might want to bail out. + // That is depending on if we want nested subtrees (layers) to bubble + // events to their parent. We could also go through parentNode on the + // host node but that wouldn't work for React Native and doesn't let us + // do the portal feature. + } while (inst && inst.tag !== HostComponent); + + if (inst) { + return inst; + } + + return null; +} +/** + * Return the lowest common ancestor of A and B, or null if they are in + * different trees. + */ + +function getLowestCommonAncestor(instA, instB) { + var depthA = 0; + + for (var tempA = instA; tempA; tempA = getParent(tempA)) { + depthA++; + } + + var depthB = 0; + + for (var tempB = instB; tempB; tempB = getParent(tempB)) { + depthB++; + } // If A is deeper, crawl up. + + while (depthA - depthB > 0) { + instA = getParent(instA); + depthA--; + } // If B is deeper, crawl up. + + while (depthB - depthA > 0) { + instB = getParent(instB); + depthB--; + } // Walk in lockstep until we find a match. + + var depth = depthA; + + while (depth--) { + if (instA === instB || instA === instB.alternate) { + return instA; + } + + instA = getParent(instA); + instB = getParent(instB); + } + + return null; +} +/** + * Return if A is an ancestor of B. + */ + +function isAncestor(instA, instB) { + while (instB) { + if (instA === instB || instA === instB.alternate) { + return true; + } + + instB = getParent(instB); + } + + return false; +} +/** + * Return the parent instance of the passed-in instance. + */ + +function getParentInstance(inst) { + return getParent(inst); +} +/** + * Simulates the traversal of a two-phase, capture/bubble event dispatch. + */ + +function traverseTwoPhase(inst, fn, arg) { + var path = []; + + while (inst) { + path.push(inst); + inst = getParent(inst); + } + + var i; + + for (i = path.length; i-- > 0; ) { + fn(path[i], "captured", arg); + } + + for (i = 0; i < path.length; i++) { + fn(path[i], "bubbled", arg); + } +} + +var invokeGuardedCallbackImpl = function( + name, + func, + context, + a, + b, + c, + d, + e, + f +) { var funcArgs = Array.prototype.slice.call(arguments, 3); try { @@ -93,9 +265,7 @@ function invokeGuardedCallbackProd(name, func, context, a, b, c, d, e, f) { } catch (error) { this.onError(error); } -} - -var invokeGuardedCallbackImpl = invokeGuardedCallbackProd; +}; { // In DEV mode, we swap out invokeGuardedCallback for a special version @@ -126,7 +296,7 @@ var invokeGuardedCallbackImpl = invokeGuardedCallbackProd; ) { var fakeNode = document.createElement("react"); - invokeGuardedCallbackImpl = function invokeGuardedCallbackDev( + var invokeGuardedCallbackDev = function( name, func, context, @@ -147,8 +317,7 @@ var invokeGuardedCallbackImpl = invokeGuardedCallbackProd; ); } - var evt = document.createEvent("Event"); - var didCall = false; // Keeps track of whether the user-provided callback threw an error. We + var evt = document.createEvent("Event"); // Keeps track of whether the user-provided callback threw an error. We // set this to true at the beginning, then set it to false right after // calling the function. If the function errors, `didError` will never be // set to false. This strategy works even if the browser is flaky and @@ -165,9 +334,13 @@ var invokeGuardedCallbackImpl = invokeGuardedCallbackProd; var windowEventDescriptor = Object.getOwnPropertyDescriptor( window, "event" - ); + ); // Create an event handler for our fake event. We will synchronously + // dispatch our fake event using `dispatchEvent`. Inside the handler, we + // call the user-provided callback. - function restoreAfterDispatch() { + var funcArgs = Array.prototype.slice.call(arguments, 3); + + function callCallback() { // We immediately remove the callback from event listeners so that // nested `invokeGuardedCallback` calls do not clash. Otherwise, a // nested call would trigger the fake event handlers of any call higher @@ -183,15 +356,7 @@ var invokeGuardedCallbackImpl = invokeGuardedCallbackProd; ) { window.event = windowEvent; } - } // Create an event handler for our fake event. We will synchronously - // dispatch our fake event using `dispatchEvent`. Inside the handler, we - // call the user-provided callback. - var funcArgs = Array.prototype.slice.call(arguments, 3); - - function callCallback() { - didCall = true; - restoreAfterDispatch(); func.apply(context, funcArgs); didError = false; } // Create a global error event handler. We use this to capture the value @@ -246,7 +411,7 @@ var invokeGuardedCallbackImpl = invokeGuardedCallbackProd; Object.defineProperty(window, "event", windowEventDescriptor); } - if (didCall && didError) { + if (didError) { if (!didSetError) { // The callback errored, but the error event never fired. error = new Error( @@ -271,16 +436,9 @@ var invokeGuardedCallbackImpl = invokeGuardedCallbackProd; } // Remove our event listeners window.removeEventListener("error", handleWindowError); - - if (!didCall) { - // Something went really wrong, and our event was not dispatched. - // https://github.com/facebook/react/issues/16734 - // https://github.com/facebook/react/issues/16585 - // Fall back to the production implementation. - restoreAfterDispatch(); - return invokeGuardedCallbackProd.apply(this, arguments); - } }; + + invokeGuardedCallbackImpl = invokeGuardedCallbackDev; } } @@ -549,6 +707,246 @@ function hasDispatches(event) { return !!event._dispatchListeners; } +function isInteractive(tag) { + return ( + tag === "button" || + tag === "input" || + tag === "select" || + tag === "textarea" + ); +} + +function shouldPreventMouseEvent(name, type, props) { + switch (name) { + case "onClick": + case "onClickCapture": + case "onDoubleClick": + case "onDoubleClickCapture": + case "onMouseDown": + case "onMouseDownCapture": + case "onMouseMove": + case "onMouseMoveCapture": + case "onMouseUp": + case "onMouseUpCapture": + case "onMouseEnter": + return !!(props.disabled && isInteractive(type)); + + default: + return false; + } +} +/** + * @param {object} inst The instance, which is the source of events. + * @param {string} registrationName Name of listener (e.g. `onClick`). + * @return {?function} The stored callback. + */ + +function getListener(inst, registrationName) { + var listener; // TODO: shouldPreventMouseEvent is DOM-specific and definitely should not + // live here; needs to be moved to a better place soon + + var stateNode = inst.stateNode; + + if (!stateNode) { + // Work in progress (ex: onload events in incremental mode). + return null; + } + + var props = getFiberCurrentPropsFromNode(stateNode); + + if (!props) { + // Work in progress. + return null; + } + + listener = props[registrationName]; + + if (shouldPreventMouseEvent(registrationName, inst.type, props)) { + return null; + } + + if (!(!listener || typeof listener === "function")) { + throw Error( + "Expected `" + + registrationName + + "` listener to be a function, instead got a value of `" + + typeof listener + + "` type." + ); + } + + return listener; +} + +/** + * Accumulates items that must not be null or undefined into the first one. This + * is used to conserve memory by avoiding array allocations, and thus sacrifices + * API cleanness. Since `current` can be null before being passed in and not + * null after this function, make sure to assign it back to `current`: + * + * `a = accumulateInto(a, b);` + * + * This API should be sparingly used. Try `accumulate` for something cleaner. + * + * @return {*|array<*>} An accumulation of items. + */ + +function accumulateInto(current, next) { + if (!(next != null)) { + throw Error( + "accumulateInto(...): Accumulated items must not be null or undefined." + ); + } + + if (current == null) { + return next; + } // Both are not empty. Warning: Never call x.concat(y) when you are not + // certain that x is an Array (x could be a string with concat method). + + if (Array.isArray(current)) { + if (Array.isArray(next)) { + current.push.apply(current, next); + return current; + } + + current.push(next); + return current; + } + + if (Array.isArray(next)) { + // A bit too dangerous to mutate `next`. + return [current].concat(next); + } + + return [current, next]; +} + +/** + * @param {array} arr an "accumulation" of items which is either an Array or + * a single item. Useful when paired with the `accumulate` module. This is a + * simple utility that allows us to reason about a collection of items, but + * handling the case when there is exactly one item (and we do not need to + * allocate an array). + * @param {function} cb Callback invoked with each element or a collection. + * @param {?} [scope] Scope used as `this` in a callback. + */ +function forEachAccumulated(arr, cb, scope) { + if (Array.isArray(arr)) { + arr.forEach(cb, scope); + } else if (arr) { + cb.call(scope, arr); + } +} + +/** + * Some event types have a notion of different registration names for different + * "phases" of propagation. This finds listeners by a given phase. + */ +function listenerAtPhase(inst, event, propagationPhase) { + var registrationName = + event.dispatchConfig.phasedRegistrationNames[propagationPhase]; + return getListener(inst, registrationName); +} +/** + * A small set of propagation patterns, each of which will accept a small amount + * of information, and generate a set of "dispatch ready event objects" - which + * are sets of events that have already been annotated with a set of dispatched + * listener functions/ids. The API is designed this way to discourage these + * propagation strategies from actually executing the dispatches, since we + * always want to collect the entire set of dispatches before executing even a + * single one. + */ + +/** + * Tags a `SyntheticEvent` with dispatched listeners. Creating this function + * here, allows us to not have to bind or create functions for each event. + * Mutating the event's members allows us to not have to create a wrapping + * "dispatch" object that pairs the event with the listener. + */ + +function accumulateDirectionalDispatches(inst, phase, event) { + { + if (!inst) { + error("Dispatching inst must not be null"); + } + } + + var listener = listenerAtPhase(inst, event, phase); + + if (listener) { + event._dispatchListeners = accumulateInto( + event._dispatchListeners, + listener + ); + event._dispatchInstances = accumulateInto(event._dispatchInstances, inst); + } +} +/** + * Collect dispatches (must be entirely collected before dispatching - see unit + * tests). Lazily allocate the array to conserve memory. We must loop through + * each event and perform the traversal for each one. We cannot perform a + * single traversal for the entire collection of events because each event may + * have a different target. + */ + +function accumulateTwoPhaseDispatchesSingle(event) { + if (event && event.dispatchConfig.phasedRegistrationNames) { + traverseTwoPhase(event._targetInst, accumulateDirectionalDispatches, event); + } +} +/** + * Same as `accumulateTwoPhaseDispatchesSingle`, but skips over the targetID. + */ + +function accumulateTwoPhaseDispatchesSingleSkipTarget(event) { + if (event && event.dispatchConfig.phasedRegistrationNames) { + var targetInst = event._targetInst; + var parentInst = targetInst ? getParentInstance(targetInst) : null; + traverseTwoPhase(parentInst, accumulateDirectionalDispatches, event); + } +} +/** + * Accumulates without regard to direction, does not look for phased + * registration names. Same as `accumulateDirectDispatchesSingle` but without + * requiring that the `dispatchMarker` be the same as the dispatched ID. + */ + +function accumulateDispatches(inst, ignoredDirection, event) { + if (inst && event && event.dispatchConfig.registrationName) { + var registrationName = event.dispatchConfig.registrationName; + var listener = getListener(inst, registrationName); + + if (listener) { + event._dispatchListeners = accumulateInto( + event._dispatchListeners, + listener + ); + event._dispatchInstances = accumulateInto(event._dispatchInstances, inst); + } + } +} +/** + * Accumulates dispatches on an `SyntheticEvent`, but only for the + * `dispatchMarker`. + * @param {SyntheticEvent} event + */ + +function accumulateDirectDispatchesSingle(event) { + if (event && event.dispatchConfig.registrationName) { + accumulateDispatches(event._targetInst, null, event); + } +} + +function accumulateTwoPhaseDispatches(events) { + forEachAccumulated(events, accumulateTwoPhaseDispatchesSingle); +} +function accumulateTwoPhaseDispatchesSkipTarget(events) { + forEachAccumulated(events, accumulateTwoPhaseDispatchesSingleSkipTarget); +} +function accumulateDirectDispatches(events) { + forEachAccumulated(events, accumulateDirectDispatchesSingle); +} + var EVENT_POOL_SIZE = 10; /** * @interface Event @@ -616,8 +1014,6 @@ function SyntheticEvent( this.dispatchConfig = dispatchConfig; this._targetInst = targetInst; this.nativeEvent = nativeEvent; - this._dispatchListeners = null; - this._dispatchInstances = null; var Interface = this.constructor.Interface; for (var propName in Interface) { @@ -843,12 +1239,7 @@ function getPooledWarningPropertyDefinition(propName, getVal) { } } -function createOrGetPooledEvent( - dispatchConfig, - targetInst, - nativeEvent, - nativeInst -) { +function getPooledEvent(dispatchConfig, targetInst, nativeEvent, nativeInst) { var EventConstructor = this; if (EventConstructor.eventPool.length) { @@ -888,8 +1279,8 @@ function releasePooledEvent(event) { } function addEventPoolingTo(EventConstructor) { - EventConstructor.getPooled = createOrGetPooledEvent; EventConstructor.eventPool = []; + EventConstructor.getPooled = getPooledEvent; EventConstructor.release = releasePooledEvent; } @@ -1154,95 +1545,6 @@ function accumulate(current, next) { return [current, next]; } -/** - * Accumulates items that must not be null or undefined into the first one. This - * is used to conserve memory by avoiding array allocations, and thus sacrifices - * API cleanness. Since `current` can be null before being passed in and not - * null after this function, make sure to assign it back to `current`: - * - * `a = accumulateInto(a, b);` - * - * This API should be sparingly used. Try `accumulate` for something cleaner. - * - * @return {*|array<*>} An accumulation of items. - */ - -function accumulateInto(current, next) { - if (!(next != null)) { - throw Error( - "accumulateInto(...): Accumulated items must not be null or undefined." - ); - } - - if (current == null) { - return next; - } // Both are not empty. Warning: Never call x.concat(y) when you are not - // certain that x is an Array (x could be a string with concat method). - - if (Array.isArray(current)) { - if (Array.isArray(next)) { - current.push.apply(current, next); - return current; - } - - current.push(next); - return current; - } - - if (Array.isArray(next)) { - // A bit too dangerous to mutate `next`. - return [current].concat(next); - } - - return [current, next]; -} - -/** - * @param {array} arr an "accumulation" of items which is either an Array or - * a single item. Useful when paired with the `accumulate` module. This is a - * simple utility that allows us to reason about a collection of items, but - * handling the case when there is exactly one item (and we do not need to - * allocate an array). - * @param {function} cb Callback invoked with each element or a collection. - * @param {?} [scope] Scope used as `this` in a callback. - */ -function forEachAccumulated(arr, cb, scope) { - if (Array.isArray(arr)) { - arr.forEach(cb, scope); - } else if (arr) { - cb.call(scope, arr); - } -} - -var FunctionComponent = 0; -var ClassComponent = 1; -var IndeterminateComponent = 2; // Before we know whether it is function or class - -var HostRoot = 3; // Root of a host tree. Could be nested inside another node. - -var HostPortal = 4; // A subtree. Could be an entry point to a different renderer. - -var HostComponent = 5; -var HostText = 6; -var Fragment = 7; -var Mode = 8; -var ContextConsumer = 9; -var ContextProvider = 10; -var ForwardRef = 11; -var Profiler = 12; -var SuspenseComponent = 13; -var MemoComponent = 14; -var SimpleMemoComponent = 15; -var LazyComponent = 16; -var IncompleteClassComponent = 17; -var DehydratedFragment = 18; -var SuspenseListComponent = 19; -var FundamentalComponent = 20; -var ScopeComponent = 21; -var Block = 22; -var OffscreenComponent = 23; -var LegacyHiddenComponent = 24; - /** * Instance of element that should respond to touch/move types of interactions, * as indicated explicitly by relevant callbacks. @@ -1361,215 +1663,7 @@ var eventTypes = { registrationName: "onResponderTerminate", dependencies: [] } -}; // Start of inline: the below functions were inlined from -// EventPropagator.js, as they deviated from ReactDOM's newer -// implementations. - -function getParent(inst) { - do { - inst = inst.return; // TODO: If this is a HostRoot we might want to bail out. - // That is depending on if we want nested subtrees (layers) to bubble - // events to their parent. We could also go through parentNode on the - // host node but that wouldn't work for React Native and doesn't let us - // do the portal feature. - } while (inst && inst.tag !== HostComponent); - - if (inst) { - return inst; - } - - return null; -} -/** - * Return the lowest common ancestor of A and B, or null if they are in - * different trees. - */ - -function getLowestCommonAncestor(instA, instB) { - var depthA = 0; - - for (var tempA = instA; tempA; tempA = getParent(tempA)) { - depthA++; - } - - var depthB = 0; - - for (var tempB = instB; tempB; tempB = getParent(tempB)) { - depthB++; - } // If A is deeper, crawl up. - - while (depthA - depthB > 0) { - instA = getParent(instA); - depthA--; - } // If B is deeper, crawl up. - - while (depthB - depthA > 0) { - instB = getParent(instB); - depthB--; - } // Walk in lockstep until we find a match. - - var depth = depthA; - - while (depth--) { - if (instA === instB || instA === instB.alternate) { - return instA; - } - - instA = getParent(instA); - instB = getParent(instB); - } - - return null; -} -/** - * Return if A is an ancestor of B. - */ - -function isAncestor(instA, instB) { - while (instB) { - if (instA === instB || instA === instB.alternate) { - return true; - } - - instB = getParent(instB); - } - - return false; -} -/** - * Simulates the traversal of a two-phase, capture/bubble event dispatch. - */ - -function traverseTwoPhase(inst, fn, arg) { - var path = []; - - while (inst) { - path.push(inst); - inst = getParent(inst); - } - - var i; - - for (i = path.length; i-- > 0; ) { - fn(path[i], "captured", arg); - } - - for (i = 0; i < path.length; i++) { - fn(path[i], "bubbled", arg); - } -} - -function getListener(inst, registrationName) { - var stateNode = inst.stateNode; - - if (stateNode === null) { - // Work in progress (ex: onload events in incremental mode). - return null; - } - - var props = getFiberCurrentPropsFromNode(stateNode); - - if (props === null) { - // Work in progress. - return null; - } - - var listener = props[registrationName]; - - if (!(!listener || typeof listener === "function")) { - throw Error( - "Expected `" + - registrationName + - "` listener to be a function, instead got a value of `" + - typeof listener + - "` type." - ); - } - - return listener; -} - -function listenerAtPhase(inst, event, propagationPhase) { - var registrationName = - event.dispatchConfig.phasedRegistrationNames[propagationPhase]; - return getListener(inst, registrationName); -} - -function accumulateDirectionalDispatches(inst, phase, event) { - { - if (!inst) { - error("Dispatching inst must not be null"); - } - } - - var listener = listenerAtPhase(inst, event, phase); - - if (listener) { - event._dispatchListeners = accumulateInto( - event._dispatchListeners, - listener - ); - event._dispatchInstances = accumulateInto(event._dispatchInstances, inst); - } -} -/** - * Accumulates without regard to direction, does not look for phased - * registration names. Same as `accumulateDirectDispatchesSingle` but without - * requiring that the `dispatchMarker` be the same as the dispatched ID. - */ - -function accumulateDispatches(inst, ignoredDirection, event) { - if (inst && event && event.dispatchConfig.registrationName) { - var registrationName = event.dispatchConfig.registrationName; - var listener = getListener(inst, registrationName); - - if (listener) { - event._dispatchListeners = accumulateInto( - event._dispatchListeners, - listener - ); - event._dispatchInstances = accumulateInto(event._dispatchInstances, inst); - } - } -} -/** - * Accumulates dispatches on an `SyntheticEvent`, but only for the - * `dispatchMarker`. - * @param {SyntheticEvent} event - */ - -function accumulateDirectDispatchesSingle(event) { - if (event && event.dispatchConfig.registrationName) { - accumulateDispatches(event._targetInst, null, event); - } -} - -function accumulateDirectDispatches(events) { - forEachAccumulated(events, accumulateDirectDispatchesSingle); -} - -function accumulateTwoPhaseDispatchesSingleSkipTarget(event) { - if (event && event.dispatchConfig.phasedRegistrationNames) { - var targetInst = event._targetInst; - var parentInst = targetInst ? getParent(targetInst) : null; - traverseTwoPhase(parentInst, accumulateDirectionalDispatches, event); - } -} - -function accumulateTwoPhaseDispatchesSkipTarget(events) { - forEachAccumulated(events, accumulateTwoPhaseDispatchesSingleSkipTarget); -} - -function accumulateTwoPhaseDispatchesSingle(event) { - if (event && event.dispatchConfig.phasedRegistrationNames) { - traverseTwoPhase(event._targetInst, accumulateDirectionalDispatches, event); - } -} - -function accumulateTwoPhaseDispatches(events) { - forEachAccumulated(events, accumulateTwoPhaseDispatchesSingle); -} // End of inline - +}; /** * * Responder System: @@ -2257,163 +2351,20 @@ function injectEventPluginsByName(injectedNamesToPlugins) { } } -function getListener$1(inst, registrationName) { - var stateNode = inst.stateNode; - - if (stateNode === null) { - // Work in progress (ex: onload events in incremental mode). - return null; - } - - var props = getFiberCurrentPropsFromNode(stateNode); - - if (props === null) { - // Work in progress. - return null; - } - - var listener = props[registrationName]; - - if (!(!listener || typeof listener === "function")) { - throw Error( - "Expected `" + - registrationName + - "` listener to be a function, instead got a value of `" + - typeof listener + - "` type." - ); - } - - return listener; -} - var customBubblingEventTypes = ReactNativePrivateInterface.ReactNativeViewConfigRegistry .customBubblingEventTypes, customDirectEventTypes = ReactNativePrivateInterface.ReactNativeViewConfigRegistry - .customDirectEventTypes; // Start of inline: the below functions were inlined from -// EventPropagator.js, as they deviated from ReactDOM's newer -// implementations. - -function listenerAtPhase$1(inst, event, propagationPhase) { - var registrationName = - event.dispatchConfig.phasedRegistrationNames[propagationPhase]; - return getListener$1(inst, registrationName); -} - -function accumulateDirectionalDispatches$1(inst, phase, event) { - { - if (!inst) { - error("Dispatching inst must not be null"); - } - } - - var listener = listenerAtPhase$1(inst, event, phase); - - if (listener) { - event._dispatchListeners = accumulateInto( - event._dispatchListeners, - listener - ); - event._dispatchInstances = accumulateInto(event._dispatchInstances, inst); - } -} - -function getParent$1(inst) { - do { - inst = inst.return; // TODO: If this is a HostRoot we might want to bail out. - // That is depending on if we want nested subtrees (layers) to bubble - // events to their parent. We could also go through parentNode on the - // host node but that wouldn't work for React Native and doesn't let us - // do the portal feature. - } while (inst && inst.tag !== HostComponent); - - if (inst) { - return inst; - } - - return null; -} -/** - * Simulates the traversal of a two-phase, capture/bubble event dispatch. - */ - -function traverseTwoPhase$1(inst, fn, arg) { - var path = []; - - while (inst) { - path.push(inst); - inst = getParent$1(inst); - } - - var i; - - for (i = path.length; i-- > 0; ) { - fn(path[i], "captured", arg); - } - - for (i = 0; i < path.length; i++) { - fn(path[i], "bubbled", arg); - } -} - -function accumulateTwoPhaseDispatchesSingle$1(event) { - if (event && event.dispatchConfig.phasedRegistrationNames) { - traverseTwoPhase$1( - event._targetInst, - accumulateDirectionalDispatches$1, - event - ); - } -} - -function accumulateTwoPhaseDispatches$1(events) { - forEachAccumulated(events, accumulateTwoPhaseDispatchesSingle$1); -} -/** - * Accumulates without regard to direction, does not look for phased - * registration names. Same as `accumulateDirectDispatchesSingle` but without - * requiring that the `dispatchMarker` be the same as the dispatched ID. - */ - -function accumulateDispatches$1(inst, ignoredDirection, event) { - if (inst && event && event.dispatchConfig.registrationName) { - var registrationName = event.dispatchConfig.registrationName; - var listener = getListener$1(inst, registrationName); - - if (listener) { - event._dispatchListeners = accumulateInto( - event._dispatchListeners, - listener - ); - event._dispatchInstances = accumulateInto(event._dispatchInstances, inst); - } - } -} -/** - * Accumulates dispatches on an `SyntheticEvent`, but only for the - * `dispatchMarker`. - * @param {SyntheticEvent} event - */ - -function accumulateDirectDispatchesSingle$1(event) { - if (event && event.dispatchConfig.registrationName) { - accumulateDispatches$1(event._targetInst, null, event); - } -} - -function accumulateDirectDispatches$1(events) { - forEachAccumulated(events, accumulateDirectDispatchesSingle$1); -} // End of inline - + .customDirectEventTypes; var ReactNativeBridgeEventPlugin = { eventTypes: {}, extractEvents: function( topLevelType, targetInst, nativeEvent, - nativeEventTarget + nativeEventTarget, + eventSystemFlags ) { if (targetInst == null) { // Probably a node belonging to another renderer's tree. @@ -2437,9 +2388,9 @@ var ReactNativeBridgeEventPlugin = { ); if (bubbleDispatchConfig) { - accumulateTwoPhaseDispatches$1(event); + accumulateTwoPhaseDispatches(event); } else if (directDispatchConfig) { - accumulateDirectDispatches$1(event); + accumulateDirectDispatches(event); } else { return null; } @@ -2525,64 +2476,37 @@ ResponderEventPlugin.injection.injectGlobalResponderHandler( * If this becomes an actual Map, that will break. */ function get(key) { - return key._reactInternals; + return key._reactInternalFiber; } function set(key, value) { - key._reactInternals = value; + key._reactInternalFiber = value; } -// ATTENTION -// When adding new symbols to this file, -// Please consider also adding to 'react-devtools-shared/src/backend/ReactSymbols' // The Symbol used to tag the ReactElement-like types. If there is no native Symbol // nor polyfill, then a plain number is used for performance. -var REACT_ELEMENT_TYPE = 0xeac7; -var REACT_PORTAL_TYPE = 0xeaca; -var REACT_FRAGMENT_TYPE = 0xeacb; -var REACT_STRICT_MODE_TYPE = 0xeacc; -var REACT_PROFILER_TYPE = 0xead2; -var REACT_PROVIDER_TYPE = 0xeacd; -var REACT_CONTEXT_TYPE = 0xeace; -var REACT_FORWARD_REF_TYPE = 0xead0; -var REACT_SUSPENSE_TYPE = 0xead1; -var REACT_SUSPENSE_LIST_TYPE = 0xead8; -var REACT_MEMO_TYPE = 0xead3; -var REACT_LAZY_TYPE = 0xead4; -var REACT_BLOCK_TYPE = 0xead9; -var REACT_SERVER_BLOCK_TYPE = 0xeada; -var REACT_FUNDAMENTAL_TYPE = 0xead5; -var REACT_RESPONDER_TYPE = 0xead6; -var REACT_SCOPE_TYPE = 0xead7; -var REACT_OPAQUE_ID_TYPE = 0xeae0; -var REACT_DEBUG_TRACING_MODE_TYPE = 0xeae1; -var REACT_OFFSCREEN_TYPE = 0xeae2; -var REACT_LEGACY_HIDDEN_TYPE = 0xeae3; - -if (typeof Symbol === "function" && Symbol.for) { - var symbolFor = Symbol.for; - REACT_ELEMENT_TYPE = symbolFor("react.element"); - REACT_PORTAL_TYPE = symbolFor("react.portal"); - REACT_FRAGMENT_TYPE = symbolFor("react.fragment"); - REACT_STRICT_MODE_TYPE = symbolFor("react.strict_mode"); - REACT_PROFILER_TYPE = symbolFor("react.profiler"); - REACT_PROVIDER_TYPE = symbolFor("react.provider"); - REACT_CONTEXT_TYPE = symbolFor("react.context"); - REACT_FORWARD_REF_TYPE = symbolFor("react.forward_ref"); - REACT_SUSPENSE_TYPE = symbolFor("react.suspense"); - REACT_SUSPENSE_LIST_TYPE = symbolFor("react.suspense_list"); - REACT_MEMO_TYPE = symbolFor("react.memo"); - REACT_LAZY_TYPE = symbolFor("react.lazy"); - REACT_BLOCK_TYPE = symbolFor("react.block"); - REACT_SERVER_BLOCK_TYPE = symbolFor("react.server.block"); - REACT_FUNDAMENTAL_TYPE = symbolFor("react.fundamental"); - REACT_RESPONDER_TYPE = symbolFor("react.responder"); - REACT_SCOPE_TYPE = symbolFor("react.scope"); - REACT_OPAQUE_ID_TYPE = symbolFor("react.opaque.id"); - REACT_DEBUG_TRACING_MODE_TYPE = symbolFor("react.debug_trace_mode"); - REACT_OFFSCREEN_TYPE = symbolFor("react.offscreen"); - REACT_LEGACY_HIDDEN_TYPE = symbolFor("react.legacy_hidden"); -} - +var hasSymbol = typeof Symbol === "function" && Symbol.for; +var REACT_ELEMENT_TYPE = hasSymbol ? Symbol.for("react.element") : 0xeac7; +var REACT_PORTAL_TYPE = hasSymbol ? Symbol.for("react.portal") : 0xeaca; +var REACT_FRAGMENT_TYPE = hasSymbol ? Symbol.for("react.fragment") : 0xeacb; +var REACT_STRICT_MODE_TYPE = hasSymbol + ? Symbol.for("react.strict_mode") + : 0xeacc; +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; // TODO: We don't use AsyncMode or ConcurrentMode anymore. They were temporary +var REACT_CONCURRENT_MODE_TYPE = hasSymbol + ? Symbol.for("react.concurrent_mode") + : 0xeacf; +var REACT_FORWARD_REF_TYPE = hasSymbol + ? Symbol.for("react.forward_ref") + : 0xead0; +var REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for("react.suspense") : 0xead1; +var REACT_SUSPENSE_LIST_TYPE = hasSymbol + ? Symbol.for("react.suspense_list") + : 0xead8; +var REACT_MEMO_TYPE = hasSymbol ? Symbol.for("react.memo") : 0xead3; +var REACT_LAZY_TYPE = hasSymbol ? Symbol.for("react.lazy") : 0xead4; +var REACT_BLOCK_TYPE = hasSymbol ? Symbol.for("react.block") : 0xead9; var MAYBE_ITERATOR_SYMBOL = typeof Symbol === "function" && Symbol.iterator; var FAUX_ITERATOR_SYMBOL = "@@iterator"; function getIteratorFn(maybeIterable) { @@ -2601,6 +2525,63 @@ function getIteratorFn(maybeIterable) { return null; } +// TODO: Move this to "react" once we can import from externals. +var Uninitialized = -1; +var Pending = 0; +var Resolved = 1; +var Rejected = 2; + +function refineResolvedLazyComponent(lazyComponent) { + return lazyComponent._status === Resolved ? lazyComponent._result : null; +} +function initializeLazyComponentType(lazyComponent) { + if (lazyComponent._status === Uninitialized) { + var ctor = lazyComponent._result; + + if (!ctor) { + // TODO: Remove this later. THis only exists in case you use an older "react" package. + ctor = lazyComponent._ctor; + } + + var thenable = ctor(); // Transition to the next state. + + var pending = lazyComponent; + pending._status = Pending; + pending._result = thenable; + thenable.then( + function(moduleObject) { + if (lazyComponent._status === Pending) { + var defaultExport = moduleObject.default; + + { + if (defaultExport === undefined) { + error( + "lazy: Expected the result of a dynamic import() call. " + + "Instead received: %s\n\nYour code should look like: \n " + // Break up imports to avoid accidentally parsing them as dependencies. + "const MyComponent = lazy(() => imp" + + "ort('./MyComponent'))", + moduleObject + ); + } + } // Transition to the next state. + + var resolved = lazyComponent; + resolved._status = Resolved; + resolved._result = defaultExport; + } + }, + function(error) { + if (lazyComponent._status === Pending) { + // Transition to the next state. + var rejected = lazyComponent; + rejected._status = Rejected; + rejected._result = error; + } + } + ); + } +} + function getWrappedName(outerType, innerType, wrapperName) { var functionName = innerType.displayName || innerType.name || ""; return ( @@ -2673,18 +2654,17 @@ function getComponentName(type) { return getComponentName(type.type); case REACT_BLOCK_TYPE: - return getComponentName(type._render); + return getComponentName(type.render); case REACT_LAZY_TYPE: { - var lazyComponent = type; - var payload = lazyComponent._payload; - var init = lazyComponent._init; + var thenable = type; + var resolvedThenable = refineResolvedLazyComponent(thenable); - try { - return getComponentName(init(payload)); - } catch (x) { - return null; + if (resolvedThenable) { + return getComponentName(resolvedThenable); } + + break; } } } @@ -2694,75 +2674,65 @@ function getComponentName(type) { // Don't change these two values. They're used by React Dev Tools. var NoEffect = - /* */ + /* */ 0; var PerformedWork = - /* */ + /* */ 1; // You can change the rest (and add more). var Placement = - /* */ + /* */ 2; var Update = - /* */ + /* */ 4; var PlacementAndUpdate = - /* */ + /* */ 6; var Deletion = - /* */ + /* */ 8; var ContentReset = - /* */ + /* */ 16; var Callback = - /* */ + /* */ 32; var DidCapture = - /* */ + /* */ 64; var Ref = - /* */ + /* */ 128; var Snapshot = - /* */ + /* */ 256; var Passive = - /* */ - 512; // TODO (effects) Remove this bit once the new reconciler is synced to the old. - -var PassiveUnmountPendingDev = - /* */ - 8192; + /* */ + 512; var Hydrating = - /* */ + /* */ 1024; var HydratingAndUpdate = - /* */ + /* */ 1028; // Passive & Update & Callback & Ref & Snapshot var LifecycleEffectMask = - /* */ + /* */ 932; // Union of all host effects var HostEffectMask = - /* */ - 2047; // These are not really side effects, but we still reuse this field. - + /* */ + 2047; var Incomplete = - /* */ + /* */ 2048; var ShouldCapture = - /* */ + /* */ 4096; -var ForceUpdateForLegacySuspense = - /* */ - 16384; // Static tags describe aspects of a fiber that are not specific to a render, -// The rest of the flags are static for better dead code elimination. var enableProfilerTimer = true; var warnAboutStringRefs = false; -var enableNewReconciler = false; var ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner; function getNearestMountedFiber(fiber) { @@ -3037,20 +3007,6 @@ function findCurrentHostFiber(parent) { return null; } -function doesFiberContain(parentFiber, childFiber) { - var node = childFiber; - var parentFiberAlternate = parentFiber.alternate; - - while (node !== null) { - if (node === parentFiber || node === parentFiberAlternate) { - return true; - } - - node = node.return; - } - - return false; -} /** * In the future, we should cleanup callbacks by cancelling them instead of @@ -3540,16 +3496,19 @@ function diff(prevProps, nextProps, validAttributes) { ); } -// Used as a way to call batchedUpdates when we don't have a reference to +var PLUGIN_EVENT_SYSTEM = 1; + // the renderer. Such as when we're dispatching events or if third party // libraries need to call batchedUpdates. Eventually, this API will go away when // everything is batched by default. We'll then have a similar API to opt-out of // scheduled work and instead do synchronous work. // Defaults + var batchedUpdatesImpl = function(fn, bookkeeping) { return fn(bookkeeping); }; var isInsideEventHandler = false; + function batchedUpdates(fn, bookkeeping) { if (isInsideEventHandler) { // If we are currently inside another batch, we need to wait until it @@ -3637,21 +3596,22 @@ function extractPluginEvents( topLevelType, targetInst, nativeEvent, - nativeEventTarget + nativeEventTarget, + eventSystemFlags ) { var events = null; - var legacyPlugins = plugins; - for (var i = 0; i < legacyPlugins.length; i++) { + for (var i = 0; i < plugins.length; i++) { // Not every plugin in the ordering may be loaded at runtime. - var possiblePlugin = legacyPlugins[i]; + var possiblePlugin = plugins[i]; if (possiblePlugin) { var extractedEvents = possiblePlugin.extractEvents( topLevelType, targetInst, nativeEvent, - nativeEventTarget + nativeEventTarget, + eventSystemFlags ); if (extractedEvents) { @@ -3667,13 +3627,15 @@ function runExtractedPluginEventsInBatch( topLevelType, targetInst, nativeEvent, - nativeEventTarget + nativeEventTarget, + eventSystemFlags ) { var events = extractPluginEvents( topLevelType, targetInst, nativeEvent, - nativeEventTarget + nativeEventTarget, + eventSystemFlags ); runEventsInBatch(events); } @@ -3696,7 +3658,8 @@ function dispatchEvent(target, topLevelType, nativeEvent) { topLevelType, targetFiber, nativeEvent, - eventTarget + eventTarget, + PLUGIN_EVENT_SYSTEM ); }); // React Native doesn't use ReactControlledComponent but if it did, here's // where it would do it. @@ -3714,7 +3677,6 @@ function shim() { var supportsMutation = false; var commitMount = shim; -var clearContainer = shim; // can re-export everything from this module. @@ -3934,7 +3896,6 @@ function getPublicInstance(instance) { } function prepareForCommit(containerInfo) { // Noop - return null; } function prepareUpdate( instance, @@ -3955,6 +3916,9 @@ function prepareUpdate( function resetAfterCommit(containerInfo) { // Noop } +function shouldDeprioritizeSubtree(type, props) { + return false; +} function shouldSetTextContent(type, props) { // TODO (bvaughn) Revisit this decision. // Always returning false simplifies the createInstance() implementation, @@ -4027,256 +3991,9 @@ function appendChildToContainerChildSet(childSet, child) { function finalizeContainerChildren(container, newChildren) { completeRoot(container, newChildren); } -function makeClientIdInDEV(warnOnAccessInDEV) { - throw new Error("Not yet implemented"); -} -function preparePortalMount(portalInstance) { - // noop -} - -// Helpers to patch console.logs to avoid logging during side-effect free -// replaying on render function. This currently only patches the object -// lazily which won't cover if the log function was extracted eagerly. -// We could also eagerly patch the method. -var disabledDepth = 0; -var prevLog; -var prevInfo; -var prevWarn; -var prevError; -var prevGroup; -var prevGroupCollapsed; -var prevGroupEnd; - -function disabledLog() {} - -disabledLog.__reactDisabledLog = true; -function disableLogs() { - { - if (disabledDepth === 0) { - /* eslint-disable react-internal/no-production-logging */ - prevLog = console.log; - prevInfo = console.info; - prevWarn = console.warn; - prevError = console.error; - prevGroup = console.group; - prevGroupCollapsed = console.groupCollapsed; - prevGroupEnd = console.groupEnd; // https://github.com/facebook/react/issues/19099 - - var props = { - configurable: true, - enumerable: true, - value: disabledLog, - writable: true - }; // $FlowFixMe Flow thinks console is immutable. - - Object.defineProperties(console, { - info: props, - log: props, - warn: props, - error: props, - group: props, - groupCollapsed: props, - groupEnd: props - }); - /* eslint-enable react-internal/no-production-logging */ - } - - disabledDepth++; - } -} -function reenableLogs() { - { - disabledDepth--; - - if (disabledDepth === 0) { - /* eslint-disable react-internal/no-production-logging */ - var props = { - configurable: true, - enumerable: true, - writable: true - }; // $FlowFixMe Flow thinks console is immutable. - - Object.defineProperties(console, { - log: Object.assign({}, props, { - value: prevLog - }), - info: Object.assign({}, props, { - value: prevInfo - }), - warn: Object.assign({}, props, { - value: prevWarn - }), - error: Object.assign({}, props, { - value: prevError - }), - group: Object.assign({}, props, { - value: prevGroup - }), - groupCollapsed: Object.assign({}, props, { - value: prevGroupCollapsed - }), - groupEnd: Object.assign({}, props, { - value: prevGroupEnd - }) - }); - /* eslint-enable react-internal/no-production-logging */ - } - - if (disabledDepth < 0) { - error( - "disabledDepth fell below zero. " + - "This is a bug in React. Please file an issue." - ); - } - } -} - -var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher; -function describeBuiltInComponentFrame(name, source, ownerFn) { - { - var ownerName = null; - - if (ownerFn) { - ownerName = ownerFn.displayName || ownerFn.name || null; - } - - return describeComponentFrame(name, source, ownerName); - } -} -var componentFrameCache; - -{ - var PossiblyWeakMap = typeof WeakMap === "function" ? WeakMap : Map; - componentFrameCache = new PossiblyWeakMap(); -} -var BEFORE_SLASH_RE = /^(.*)[\\\/]/; - -function describeComponentFrame(name, source, ownerName) { - var sourceInfo = ""; - - if (source) { - var path = source.fileName; - var fileName = path.replace(BEFORE_SLASH_RE, ""); // In DEV, include code for a common special case: - // prefer "folder/index.js" instead of just "index.js". - - if (/^index\./.test(fileName)) { - var match = path.match(BEFORE_SLASH_RE); - - if (match) { - var pathBeforeSlash = match[1]; - - if (pathBeforeSlash) { - var folderName = pathBeforeSlash.replace(BEFORE_SLASH_RE, ""); - fileName = folderName + "/" + fileName; - } - } - } - - sourceInfo = " (at " + fileName + ":" + source.lineNumber + ")"; - } else if (ownerName) { - sourceInfo = " (created by " + ownerName + ")"; - } - - return "\n in " + (name || "Unknown") + sourceInfo; -} - -function describeClassComponentFrame(ctor, source, ownerFn) { - { - return describeFunctionComponentFrame(ctor, source, ownerFn); - } -} -function describeFunctionComponentFrame(fn, source, ownerFn) { - { - if (!fn) { - return ""; - } - - var name = fn.displayName || fn.name || null; - var ownerName = null; - - if (ownerFn) { - ownerName = ownerFn.displayName || ownerFn.name || null; - } - - return describeComponentFrame(name, source, ownerName); - } -} - -function describeUnknownElementTypeFrameInDEV(type, source, ownerFn) { - if (type == null) { - return ""; - } - - if (typeof type === "function") { - { - return describeFunctionComponentFrame(type, source, ownerFn); - } - } - - if (typeof type === "string") { - return describeBuiltInComponentFrame(type, source, ownerFn); - } - - switch (type) { - case REACT_SUSPENSE_TYPE: - return describeBuiltInComponentFrame("Suspense", source, ownerFn); - - case REACT_SUSPENSE_LIST_TYPE: - return describeBuiltInComponentFrame("SuspenseList", source, ownerFn); - } - - if (typeof type === "object") { - switch (type.$$typeof) { - case REACT_FORWARD_REF_TYPE: - return describeFunctionComponentFrame(type.render, source, ownerFn); - - case REACT_MEMO_TYPE: - // Memo may contain any component type so we recursively resolve it. - return describeUnknownElementTypeFrameInDEV(type.type, source, ownerFn); - - case REACT_BLOCK_TYPE: - return describeFunctionComponentFrame(type._render, source, ownerFn); - - case REACT_LAZY_TYPE: { - var lazyComponent = type; - var payload = lazyComponent._payload; - var init = lazyComponent._init; - - try { - // Lazy may contain any component type so we recursively resolve it. - return describeUnknownElementTypeFrameInDEV( - init(payload), - source, - ownerFn - ); - } catch (x) {} - } - } - } - - return ""; -} var loggedTypeFailures = {}; -var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame; - -function setCurrentlyValidatingElement(element) { - { - if (element) { - var owner = element._owner; - var stack = describeUnknownElementTypeFrameInDEV( - element.type, - element._source, - owner ? owner.type : null - ); - ReactDebugCurrentFrame.setExtraStackFrame(stack); - } else { - ReactDebugCurrentFrame.setExtraStackFrame(null); - } - } -} - -function checkPropTypes(typeSpecs, values, location, componentName, element) { +function checkPropTypes(typeSpecs, values, location, componentName) { { // $FlowFixMe This is okay but Flow doesn't know it. var has = Function.call.bind(Object.prototype.hasOwnProperty); @@ -4320,8 +4037,6 @@ function checkPropTypes(typeSpecs, values, location, componentName, element) { } if (error$1 && !(error$1 instanceof Error)) { - setCurrentlyValidatingElement(element); - error( "%s: type specification of %s" + " `%s` is invalid; the type checker " + @@ -4334,8 +4049,6 @@ function checkPropTypes(typeSpecs, values, location, componentName, element) { typeSpecName, typeof error$1 ); - - setCurrentlyValidatingElement(null); } if ( @@ -4345,17 +4058,458 @@ function checkPropTypes(typeSpecs, values, location, componentName, element) { // Only monitor this failure once because there tends to be a lot of the // same error. loggedTypeFailures[error$1.message] = true; - setCurrentlyValidatingElement(element); error("Failed %s type: %s", location, error$1.message); - - setCurrentlyValidatingElement(null); } } } } } +// Prefix measurements so that it's possible to filter them. +// Longer prefixes are hard to read in DevTools. +var reactEmoji = "\u269B"; +var warningEmoji = "\u26D4"; +var supportsUserTiming = + typeof performance !== "undefined" && + typeof performance.mark === "function" && + typeof performance.clearMarks === "function" && + typeof performance.measure === "function" && + typeof performance.clearMeasures === "function"; // Keep track of current fiber so that we know the path to unwind on pause. +// TODO: this looks the same as nextUnitOfWork in scheduler. Can we unify them? + +var currentFiber = null; // If we're in the middle of user code, which fiber and method is it? +// Reusing `currentFiber` would be confusing for this because user code fiber +// can change during commit phase too, but we don't need to unwind it (since +// lifecycles in the commit phase don't resemble a tree). + +var currentPhase = null; +var currentPhaseFiber = null; // Did lifecycle hook schedule an update? This is often a performance problem, +// so we will keep track of it, and include it in the report. +// Track commits caused by cascading updates. + +var isCommitting = false; +var hasScheduledUpdateInCurrentCommit = false; +var hasScheduledUpdateInCurrentPhase = false; +var commitCountInCurrentWorkLoop = 0; +var effectCountInCurrentCommit = 0; +// to avoid stretch the commit phase with measurement overhead. + +var labelsInCurrentCommit = new Set(); + +var formatMarkName = function(markName) { + return reactEmoji + " " + markName; +}; + +var formatLabel = function(label, warning) { + var prefix = warning ? warningEmoji + " " : reactEmoji + " "; + var suffix = warning ? " Warning: " + warning : ""; + return "" + prefix + label + suffix; +}; + +var beginMark = function(markName) { + performance.mark(formatMarkName(markName)); +}; + +var clearMark = function(markName) { + performance.clearMarks(formatMarkName(markName)); +}; + +var endMark = function(label, markName, warning) { + var formattedMarkName = formatMarkName(markName); + var formattedLabel = formatLabel(label, warning); + + try { + performance.measure(formattedLabel, formattedMarkName); + } catch (err) {} // If previous mark was missing for some reason, this will throw. + // This could only happen if React crashed in an unexpected place earlier. + // Don't pile on with more errors. + // Clear marks immediately to avoid growing buffer. + + performance.clearMarks(formattedMarkName); + performance.clearMeasures(formattedLabel); +}; + +var getFiberMarkName = function(label, debugID) { + return label + " (#" + debugID + ")"; +}; + +var getFiberLabel = function(componentName, isMounted, phase) { + if (phase === null) { + // These are composite component total time measurements. + return componentName + " [" + (isMounted ? "update" : "mount") + "]"; + } else { + // Composite component methods. + return componentName + "." + phase; + } +}; + +var beginFiberMark = function(fiber, phase) { + var componentName = getComponentName(fiber.type) || "Unknown"; + var debugID = fiber._debugID; + var isMounted = fiber.alternate !== null; + var label = getFiberLabel(componentName, isMounted, phase); + + if (isCommitting && labelsInCurrentCommit.has(label)) { + // During the commit phase, we don't show duplicate labels because + // there is a fixed overhead for every measurement, and we don't + // want to stretch the commit phase beyond necessary. + return false; + } + + labelsInCurrentCommit.add(label); + var markName = getFiberMarkName(label, debugID); + beginMark(markName); + return true; +}; + +var clearFiberMark = function(fiber, phase) { + var componentName = getComponentName(fiber.type) || "Unknown"; + var debugID = fiber._debugID; + var isMounted = fiber.alternate !== null; + var label = getFiberLabel(componentName, isMounted, phase); + var markName = getFiberMarkName(label, debugID); + clearMark(markName); +}; + +var endFiberMark = function(fiber, phase, warning) { + var componentName = getComponentName(fiber.type) || "Unknown"; + var debugID = fiber._debugID; + var isMounted = fiber.alternate !== null; + var label = getFiberLabel(componentName, isMounted, phase); + var markName = getFiberMarkName(label, debugID); + endMark(label, markName, warning); +}; + +var shouldIgnoreFiber = function(fiber) { + // Host components should be skipped in the timeline. + // We could check typeof fiber.type, but does this work with RN? + switch (fiber.tag) { + case HostRoot: + case HostComponent: + case HostText: + case HostPortal: + case Fragment: + case ContextProvider: + case ContextConsumer: + case Mode: + return true; + + default: + return false; + } +}; + +var clearPendingPhaseMeasurement = function() { + if (currentPhase !== null && currentPhaseFiber !== null) { + clearFiberMark(currentPhaseFiber, currentPhase); + } + + currentPhaseFiber = null; + currentPhase = null; + hasScheduledUpdateInCurrentPhase = false; +}; + +var pauseTimers = function() { + // Stops all currently active measurements so that they can be resumed + // if we continue in a later deferred loop from the same unit of work. + var fiber = currentFiber; + + while (fiber) { + if (fiber._debugIsCurrentlyTiming) { + endFiberMark(fiber, null, null); + } + + fiber = fiber.return; + } +}; + +var resumeTimersRecursively = function(fiber) { + if (fiber.return !== null) { + resumeTimersRecursively(fiber.return); + } + + if (fiber._debugIsCurrentlyTiming) { + beginFiberMark(fiber, null); + } +}; + +var resumeTimers = function() { + // Resumes all measurements that were active during the last deferred loop. + if (currentFiber !== null) { + resumeTimersRecursively(currentFiber); + } +}; + +function recordEffect() { + { + effectCountInCurrentCommit++; + } +} +function recordScheduleUpdate() { + { + if (isCommitting) { + hasScheduledUpdateInCurrentCommit = true; + } + + if ( + currentPhase !== null && + currentPhase !== "componentWillMount" && + currentPhase !== "componentWillReceiveProps" + ) { + hasScheduledUpdateInCurrentPhase = true; + } + } +} +function startWorkTimer(fiber) { + { + if (!supportsUserTiming || shouldIgnoreFiber(fiber)) { + return; + } // If we pause, this is the fiber to unwind from. + + currentFiber = fiber; + + if (!beginFiberMark(fiber, null)) { + return; + } + + fiber._debugIsCurrentlyTiming = true; + } +} +function cancelWorkTimer(fiber) { + { + if (!supportsUserTiming || shouldIgnoreFiber(fiber)) { + return; + } // Remember we shouldn't complete measurement for this fiber. + // Otherwise flamechart will be deep even for small updates. + + fiber._debugIsCurrentlyTiming = false; + clearFiberMark(fiber, null); + } +} +function stopWorkTimer(fiber) { + { + if (!supportsUserTiming || shouldIgnoreFiber(fiber)) { + return; + } // If we pause, its parent is the fiber to unwind from. + + currentFiber = fiber.return; + + if (!fiber._debugIsCurrentlyTiming) { + return; + } + + fiber._debugIsCurrentlyTiming = false; + endFiberMark(fiber, null, null); + } +} +function stopFailedWorkTimer(fiber) { + { + if (!supportsUserTiming || shouldIgnoreFiber(fiber)) { + return; + } // If we pause, its parent is the fiber to unwind from. + + currentFiber = fiber.return; + + if (!fiber._debugIsCurrentlyTiming) { + return; + } + + fiber._debugIsCurrentlyTiming = false; + var warning = + fiber.tag === SuspenseComponent + ? "Rendering was suspended" + : "An error was thrown inside this error boundary"; + endFiberMark(fiber, null, warning); + } +} +function startPhaseTimer(fiber, phase) { + { + if (!supportsUserTiming) { + return; + } + + clearPendingPhaseMeasurement(); + + if (!beginFiberMark(fiber, phase)) { + return; + } + + currentPhaseFiber = fiber; + currentPhase = phase; + } +} +function stopPhaseTimer() { + { + if (!supportsUserTiming) { + return; + } + + if (currentPhase !== null && currentPhaseFiber !== null) { + var warning = hasScheduledUpdateInCurrentPhase + ? "Scheduled a cascading update" + : null; + endFiberMark(currentPhaseFiber, currentPhase, warning); + } + + currentPhase = null; + currentPhaseFiber = null; + } +} +function startWorkLoopTimer(nextUnitOfWork) { + { + currentFiber = nextUnitOfWork; + + if (!supportsUserTiming) { + return; + } + + commitCountInCurrentWorkLoop = 0; // This is top level call. + // Any other measurements are performed within. + + beginMark("(React Tree Reconciliation)"); // Resume any measurements that were in progress during the last loop. + + resumeTimers(); + } +} +function stopWorkLoopTimer(interruptedBy, didCompleteRoot) { + { + if (!supportsUserTiming) { + return; + } + + var warning = null; + + if (interruptedBy !== null) { + if (interruptedBy.tag === HostRoot) { + warning = "A top-level update interrupted the previous render"; + } else { + var componentName = getComponentName(interruptedBy.type) || "Unknown"; + warning = + "An update to " + componentName + " interrupted the previous render"; + } + } else if (commitCountInCurrentWorkLoop > 1) { + warning = "There were cascading updates"; + } + + commitCountInCurrentWorkLoop = 0; + var label = didCompleteRoot + ? "(React Tree Reconciliation: Completed Root)" + : "(React Tree Reconciliation: Yielded)"; // Pause any measurements until the next loop. + + pauseTimers(); + endMark(label, "(React Tree Reconciliation)", warning); + } +} +function startCommitTimer() { + { + if (!supportsUserTiming) { + return; + } + + isCommitting = true; + hasScheduledUpdateInCurrentCommit = false; + labelsInCurrentCommit.clear(); + beginMark("(Committing Changes)"); + } +} +function stopCommitTimer() { + { + if (!supportsUserTiming) { + return; + } + + var warning = null; + + if (hasScheduledUpdateInCurrentCommit) { + warning = "Lifecycle hook scheduled a cascading update"; + } else if (commitCountInCurrentWorkLoop > 0) { + warning = "Caused by a cascading update in earlier commit"; + } + + hasScheduledUpdateInCurrentCommit = false; + commitCountInCurrentWorkLoop++; + isCommitting = false; + labelsInCurrentCommit.clear(); + endMark("(Committing Changes)", "(Committing Changes)", warning); + } +} +function startCommitSnapshotEffectsTimer() { + { + if (!supportsUserTiming) { + return; + } + + effectCountInCurrentCommit = 0; + beginMark("(Committing Snapshot Effects)"); + } +} +function stopCommitSnapshotEffectsTimer() { + { + if (!supportsUserTiming) { + return; + } + + var count = effectCountInCurrentCommit; + effectCountInCurrentCommit = 0; + endMark( + "(Committing Snapshot Effects: " + count + " Total)", + "(Committing Snapshot Effects)", + null + ); + } +} +function startCommitHostEffectsTimer() { + { + if (!supportsUserTiming) { + return; + } + + effectCountInCurrentCommit = 0; + beginMark("(Committing Host Effects)"); + } +} +function stopCommitHostEffectsTimer() { + { + if (!supportsUserTiming) { + return; + } + + var count = effectCountInCurrentCommit; + effectCountInCurrentCommit = 0; + endMark( + "(Committing Host Effects: " + count + " Total)", + "(Committing Host Effects)", + null + ); + } +} +function startCommitLifeCyclesTimer() { + { + if (!supportsUserTiming) { + return; + } + + effectCountInCurrentCommit = 0; + beginMark("(Calling Lifecycle Methods)"); + } +} +function stopCommitLifeCyclesTimer() { + { + if (!supportsUserTiming) { + return; + } + + var count = effectCountInCurrentCommit; + effectCountInCurrentCommit = 0; + endMark( + "(Calling Lifecycle Methods: " + count + " Total)", + "(Calling Lifecycle Methods)", + null + ); + } +} + var valueStack = []; var fiberStack; @@ -4559,7 +4713,10 @@ function processChildContext(fiber, type, parentContext) { return parentContext; } - var childContext = instance.getChildContext(); + var childContext; + startPhaseTimer(fiber, "getChildContext"); + childContext = instance.getChildContext(); + stopPhaseTimer(); for (var contextKey in childContext) { if (!(contextKey in childContextTypes)) { @@ -4680,897 +4837,13 @@ var LegacyRoot = 0; var BlockingRoot = 1; var ConcurrentRoot = 2; -var rendererID = null; -var injectedHook = null; -var hasLoggedError = false; -var isDevToolsPresent = typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== "undefined"; -function injectInternals(internals) { - if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ === "undefined") { - // No DevTools - return false; - } - - var hook = __REACT_DEVTOOLS_GLOBAL_HOOK__; - - if (hook.isDisabled) { - // This isn't a real property on the hook, but it can be set to opt out - // of DevTools integration and associated warnings and logs. - // https://github.com/facebook/react/issues/3877 - return true; - } - - if (!hook.supportsFiber) { - { - error( - "The installed version of React DevTools is too old and will not work " + - "with the current version of React. Please update React DevTools. " + - "https://fb.me/react-devtools" - ); - } // DevTools exists, even though it doesn't support Fiber. - - return true; - } - - try { - rendererID = hook.inject(internals); // We have successfully injected, so now it is safe to set up hooks. - - injectedHook = hook; - } catch (err) { - // Catch all errors because it is unsafe to throw during initialization. - { - error("React instrumentation encountered an error: %s.", err); - } - } // DevTools exists - - return true; -} -function onScheduleRoot(root, children) { - { - if ( - injectedHook && - typeof injectedHook.onScheduleFiberRoot === "function" - ) { - try { - injectedHook.onScheduleFiberRoot(rendererID, root, children); - } catch (err) { - if (!hasLoggedError) { - hasLoggedError = true; - - error("React instrumentation encountered an error: %s", err); - } - } - } - } -} -function onCommitRoot(root, priorityLevel) { - if (injectedHook && typeof injectedHook.onCommitFiberRoot === "function") { - try { - var didError = (root.current.effectTag & DidCapture) === DidCapture; - - if (enableProfilerTimer) { - injectedHook.onCommitFiberRoot( - rendererID, - root, - priorityLevel, - didError - ); - } else { - injectedHook.onCommitFiberRoot(rendererID, root, undefined, didError); - } - } catch (err) { - { - if (!hasLoggedError) { - hasLoggedError = true; - - error("React instrumentation encountered an error: %s", err); - } - } - } - } -} -function onCommitUnmount(fiber) { - if (injectedHook && typeof injectedHook.onCommitFiberUnmount === "function") { - try { - injectedHook.onCommitFiberUnmount(rendererID, fiber); - } catch (err) { - { - if (!hasLoggedError) { - hasLoggedError = true; - - error("React instrumentation encountered an error: %s", err); - } - } - } - } -} - -// Intentionally not named imports because Rollup would use dynamic dispatch for -var Scheduler_now = Scheduler.unstable_now; - -{ - // Provide explicit error message when production+profiling bundle of e.g. - // react-dom is used with production (non-profiling) bundle of - // scheduler/tracing - if ( - !( - tracing.__interactionsRef != null && - tracing.__interactionsRef.current != null - ) - ) { - throw Error( - "It is not supported to run the profiling version of a renderer (for example, `react-dom/profiling`) without also replacing the `scheduler/tracing` module with `scheduler/tracing-profiling`. Your bundler might have a setting for aliasing both modules. Learn more at http://fb.me/react-profiling" - ); - } -} -// ascending numbers so we can compare them like numbers. They start at 90 to -// avoid clashing with Scheduler's priorities. - -var ImmediatePriority = 99; -var UserBlockingPriority = 98; -var NormalPriority = 97; -var LowPriority = 96; -var IdlePriority = 95; // NoPriority is the absence of priority. Also React-only. - -var NoPriority = 90; -var initialTimeMs = Scheduler_now(); // If the initial timestamp is reasonably small, use Scheduler's `now` directly. - -var SyncLanePriority = 17; -var SyncBatchedLanePriority = 16; -var InputDiscreteHydrationLanePriority = 15; -var InputDiscreteLanePriority = 14; -var InputContinuousHydrationLanePriority = 13; -var InputContinuousLanePriority = 12; -var DefaultHydrationLanePriority = 11; -var DefaultLanePriority = 10; -var TransitionShortHydrationLanePriority = 9; -var TransitionShortLanePriority = 8; -var TransitionLongHydrationLanePriority = 7; -var TransitionLongLanePriority = 6; -var RetryLanePriority = 5; -var SelectiveHydrationLanePriority = 4; -var IdleHydrationLanePriority = 3; -var IdleLanePriority = 2; -var OffscreenLanePriority = 1; -var NoLanePriority = 0; -var TotalLanes = 31; -var NoLanes = - /* */ - 0; -var NoLane = - /* */ - 0; -var SyncLane = - /* */ - 1; -var SyncBatchedLane = - /* */ - 2; -var InputDiscreteHydrationLane = - /* */ - 4; -var InputDiscreteLanes = - /* */ - 24; -var InputContinuousHydrationLane = - /* */ - 32; -var InputContinuousLanes = - /* */ - 192; -var DefaultHydrationLane = - /* */ - 256; -var DefaultLanes = - /* */ - 3584; -var TransitionShortHydrationLane = - /* */ - 4096; -var TransitionShortLanes = - /* */ - 122880; -var TransitionLongHydrationLane = - /* */ - 131072; -var TransitionLongLanes = - /* */ - 3932160; -var RetryLanes = - /* */ - 62914560; -var SelectiveHydrationLane = - /* */ - 67108864; -var NonIdleLanes = - /* */ - 134217727; -var IdleHydrationLane = - /* */ - 134217728; -var IdleLanes = - /* */ - 805306368; -var OffscreenLane = - /* */ - 1073741824; -var NoTimestamp = -1; -function setCurrentUpdateLanePriority(newLanePriority) {} // "Registers" used to "return" multiple values -// Used by getHighestPriorityLanes and getNextLanes: - -var return_highestLanePriority = DefaultLanePriority; - -function getHighestPriorityLanes(lanes) { - if ((SyncLane & lanes) !== NoLanes) { - return_highestLanePriority = SyncLanePriority; - return SyncLane; - } - - if ((SyncBatchedLane & lanes) !== NoLanes) { - return_highestLanePriority = SyncBatchedLanePriority; - return SyncBatchedLane; - } - - if ((InputDiscreteHydrationLane & lanes) !== NoLanes) { - return_highestLanePriority = InputDiscreteHydrationLanePriority; - return InputDiscreteHydrationLane; - } - - var inputDiscreteLanes = InputDiscreteLanes & lanes; - - if (inputDiscreteLanes !== NoLanes) { - return_highestLanePriority = InputDiscreteLanePriority; - return inputDiscreteLanes; - } - - if ((lanes & InputContinuousHydrationLane) !== NoLanes) { - return_highestLanePriority = InputContinuousHydrationLanePriority; - return InputContinuousHydrationLane; - } - - var inputContinuousLanes = InputContinuousLanes & lanes; - - if (inputContinuousLanes !== NoLanes) { - return_highestLanePriority = InputContinuousLanePriority; - return inputContinuousLanes; - } - - if ((lanes & DefaultHydrationLane) !== NoLanes) { - return_highestLanePriority = DefaultHydrationLanePriority; - return DefaultHydrationLane; - } - - var defaultLanes = DefaultLanes & lanes; - - if (defaultLanes !== NoLanes) { - return_highestLanePriority = DefaultLanePriority; - return defaultLanes; - } - - if ((lanes & TransitionShortHydrationLane) !== NoLanes) { - return_highestLanePriority = TransitionShortHydrationLanePriority; - return TransitionShortHydrationLane; - } - - var transitionShortLanes = TransitionShortLanes & lanes; - - if (transitionShortLanes !== NoLanes) { - return_highestLanePriority = TransitionShortLanePriority; - return transitionShortLanes; - } - - if ((lanes & TransitionLongHydrationLane) !== NoLanes) { - return_highestLanePriority = TransitionLongHydrationLanePriority; - return TransitionLongHydrationLane; - } - - var transitionLongLanes = TransitionLongLanes & lanes; - - if (transitionLongLanes !== NoLanes) { - return_highestLanePriority = TransitionLongLanePriority; - return transitionLongLanes; - } - - var retryLanes = RetryLanes & lanes; - - if (retryLanes !== NoLanes) { - return_highestLanePriority = RetryLanePriority; - return retryLanes; - } - - if (lanes & SelectiveHydrationLane) { - return_highestLanePriority = SelectiveHydrationLanePriority; - return SelectiveHydrationLane; - } - - if ((lanes & IdleHydrationLane) !== NoLanes) { - return_highestLanePriority = IdleHydrationLanePriority; - return IdleHydrationLane; - } - - var idleLanes = IdleLanes & lanes; - - if (idleLanes !== NoLanes) { - return_highestLanePriority = IdleLanePriority; - return idleLanes; - } - - if ((OffscreenLane & lanes) !== NoLanes) { - return_highestLanePriority = OffscreenLanePriority; - return OffscreenLane; - } - - { - error("Should have found matching lanes. This is a bug in React."); - } // This shouldn't be reachable, but as a fallback, return the entire bitmask. - - return_highestLanePriority = DefaultLanePriority; - return lanes; -} - -function schedulerPriorityToLanePriority(schedulerPriorityLevel) { - switch (schedulerPriorityLevel) { - case ImmediatePriority: - return SyncLanePriority; - - case UserBlockingPriority: - return InputContinuousLanePriority; - - case NormalPriority: - case LowPriority: - // TODO: Handle LowSchedulerPriority, somehow. Maybe the same lane as hydration. - return DefaultLanePriority; - - case IdlePriority: - return IdleLanePriority; - - default: - return NoLanePriority; - } -} -function lanePriorityToSchedulerPriority(lanePriority) { - switch (lanePriority) { - case SyncLanePriority: - case SyncBatchedLanePriority: - return ImmediatePriority; - - case InputDiscreteHydrationLanePriority: - case InputDiscreteLanePriority: - case InputContinuousHydrationLanePriority: - case InputContinuousLanePriority: - return UserBlockingPriority; - - case DefaultHydrationLanePriority: - case DefaultLanePriority: - case TransitionShortHydrationLanePriority: - case TransitionShortLanePriority: - case TransitionLongHydrationLanePriority: - case TransitionLongLanePriority: - case SelectiveHydrationLanePriority: - case RetryLanePriority: - return NormalPriority; - - case IdleHydrationLanePriority: - case IdleLanePriority: - case OffscreenLanePriority: - return IdlePriority; - - case NoLanePriority: - return NoPriority; - - default: { - throw Error( - "Invalid update priority: " + lanePriority + ". This is a bug in React." - ); - } - } -} -function getNextLanes(root, wipLanes) { - // Early bailout if there's no pending work left. - var pendingLanes = root.pendingLanes; - - if (pendingLanes === NoLanes) { - return_highestLanePriority = NoLanePriority; - return NoLanes; - } - - var nextLanes = NoLanes; - var nextLanePriority = NoLanePriority; - var expiredLanes = root.expiredLanes; - var suspendedLanes = root.suspendedLanes; - var pingedLanes = root.pingedLanes; // Check if any work has expired. - - if (expiredLanes !== NoLanes) { - nextLanes = expiredLanes; - nextLanePriority = return_highestLanePriority = SyncLanePriority; - } else { - // Do not work on any idle work until all the non-idle work has finished, - // even if the work is suspended. - var nonIdlePendingLanes = pendingLanes & NonIdleLanes; - - if (nonIdlePendingLanes !== NoLanes) { - var nonIdleUnblockedLanes = nonIdlePendingLanes & ~suspendedLanes; - - if (nonIdleUnblockedLanes !== NoLanes) { - nextLanes = getHighestPriorityLanes(nonIdleUnblockedLanes); - nextLanePriority = return_highestLanePriority; - } else { - var nonIdlePingedLanes = nonIdlePendingLanes & pingedLanes; - - if (nonIdlePingedLanes !== NoLanes) { - nextLanes = getHighestPriorityLanes(nonIdlePingedLanes); - nextLanePriority = return_highestLanePriority; - } - } - } else { - // The only remaining work is Idle. - var unblockedLanes = pendingLanes & ~suspendedLanes; - - if (unblockedLanes !== NoLanes) { - nextLanes = getHighestPriorityLanes(unblockedLanes); - nextLanePriority = return_highestLanePriority; - } else { - if (pingedLanes !== NoLanes) { - nextLanes = getHighestPriorityLanes(pingedLanes); - nextLanePriority = return_highestLanePriority; - } - } - } - } - - if (nextLanes === NoLanes) { - // This should only be reachable if we're suspended - // TODO: Consider warning in this path if a fallback timer is not scheduled. - return NoLanes; - } // If there are higher priority lanes, we'll include them even if they - // are suspended. - - nextLanes = pendingLanes & getEqualOrHigherPriorityLanes(nextLanes); // If we're already in the middle of a render, switching lanes will interrupt - // it and we'll lose our progress. We should only do this if the new lanes are - // higher priority. - - if ( - wipLanes !== NoLanes && - wipLanes !== nextLanes && // If we already suspended with a delay, then interrupting is fine. Don't - // bother waiting until the root is complete. - (wipLanes & suspendedLanes) === NoLanes - ) { - getHighestPriorityLanes(wipLanes); - var wipLanePriority = return_highestLanePriority; - - if (nextLanePriority <= wipLanePriority) { - return wipLanes; - } else { - return_highestLanePriority = nextLanePriority; - } - } // Check for entangled lanes and add them to the batch. - // - // A lane is said to be entangled with another when it's not allowed to render - // in a batch that does not also include the other lane. Typically we do this - // when multiple updates have the same source, and we only want to respond to - // the most recent event from that source. - // - // Note that we apply entanglements *after* checking for partial work above. - // This means that if a lane is entangled during an interleaved event while - // it's already rendering, we won't interrupt it. This is intentional, since - // entanglement is usually "best effort": we'll try our best to render the - // lanes in the same batch, but it's not worth throwing out partially - // completed work in order to do it. - // - // For those exceptions where entanglement is semantically important, like - // useMutableSource, we should ensure that there is no partial work at the - // time we apply the entanglement. - - var entangledLanes = root.entangledLanes; - - if (entangledLanes !== NoLanes) { - var entanglements = root.entanglements; - var lanes = nextLanes & entangledLanes; - - while (lanes > 0) { - var index = pickArbitraryLaneIndex(lanes); - var lane = 1 << index; - nextLanes |= entanglements[index]; - lanes &= ~lane; - } - } - - return nextLanes; -} -function getMostRecentEventTime(root, lanes) { - var eventTimes = root.eventTimes; - var mostRecentEventTime = NoTimestamp; - - while (lanes > 0) { - var index = pickArbitraryLaneIndex(lanes); - var lane = 1 << index; - var eventTime = eventTimes[index]; - - if (eventTime > mostRecentEventTime) { - mostRecentEventTime = eventTime; - } - - lanes &= ~lane; - } - - return mostRecentEventTime; -} - -function computeExpirationTime(lane, currentTime) { - // TODO: Expiration heuristic is constant per lane, so could use a map. - getHighestPriorityLanes(lane); - var priority = return_highestLanePriority; - - if (priority >= InputContinuousLanePriority) { - // User interactions should expire slightly more quickly. - return currentTime + 1000; - } else if (priority >= TransitionLongLanePriority) { - return currentTime + 5000; - } else { - // Anything idle priority or lower should never expire. - return NoTimestamp; - } -} - -function markStarvedLanesAsExpired(root, currentTime) { - // TODO: This gets called every time we yield. We can optimize by storing - // the earliest expiration time on the root. Then use that to quickly bail out - // of this function. - var pendingLanes = root.pendingLanes; - var suspendedLanes = root.suspendedLanes; - var pingedLanes = root.pingedLanes; - var expirationTimes = root.expirationTimes; // Iterate through the pending lanes and check if we've reached their - // expiration time. If so, we'll assume the update is being starved and mark - // it as expired to force it to finish. - - var lanes = pendingLanes; - - while (lanes > 0) { - var index = pickArbitraryLaneIndex(lanes); - var lane = 1 << index; - var expirationTime = expirationTimes[index]; - - if (expirationTime === NoTimestamp) { - // Found a pending lane with no expiration time. If it's not suspended, or - // if it's pinged, assume it's CPU-bound. Compute a new expiration time - // using the current time. - if ( - (lane & suspendedLanes) === NoLanes || - (lane & pingedLanes) !== NoLanes - ) { - // Assumes timestamps are monotonically increasing. - expirationTimes[index] = computeExpirationTime(lane, currentTime); - } - } else if (expirationTime <= currentTime) { - // This lane expired - root.expiredLanes |= lane; - } - - lanes &= ~lane; - } -} // This returns the highest priority pending lanes regardless of whether they -function getLanesToRetrySynchronouslyOnError(root) { - var everythingButOffscreen = root.pendingLanes & ~OffscreenLane; - - if (everythingButOffscreen !== NoLanes) { - return everythingButOffscreen; - } - - if (everythingButOffscreen & OffscreenLane) { - return OffscreenLane; - } - - return NoLanes; -} -function returnNextLanesPriority() { - return return_highestLanePriority; -} -function includesNonIdleWork(lanes) { - return (lanes & NonIdleLanes) !== NoLanes; -} -function includesOnlyRetries(lanes) { - return (lanes & RetryLanes) === lanes; -} // To ensure consistency across multiple updates in the same event, this should -// be a pure function, so that it always returns the same lane for given inputs. - -function findUpdateLane(lanePriority, wipLanes) { - switch (lanePriority) { - case NoLanePriority: - break; - - case SyncLanePriority: - return SyncLane; - - case SyncBatchedLanePriority: - return SyncBatchedLane; - - case InputDiscreteLanePriority: { - var _lane = pickArbitraryLane(InputDiscreteLanes & ~wipLanes); - - if (_lane === NoLane) { - // Shift to the next priority level - return findUpdateLane(InputContinuousLanePriority, wipLanes); - } - - return _lane; - } - - case InputContinuousLanePriority: { - var _lane2 = pickArbitraryLane(InputContinuousLanes & ~wipLanes); - - if (_lane2 === NoLane) { - // Shift to the next priority level - return findUpdateLane(DefaultLanePriority, wipLanes); - } - - return _lane2; - } - - case DefaultLanePriority: { - var _lane3 = pickArbitraryLane(DefaultLanes & ~wipLanes); - - if (_lane3 === NoLane) { - // If all the default lanes are already being worked on, look for a - // lane in the transition range. - _lane3 = pickArbitraryLane( - (TransitionShortLanes | TransitionLongLanes) & ~wipLanes - ); - - if (_lane3 === NoLane) { - // All the transition lanes are taken, too. This should be very - // rare, but as a last resort, pick a default lane. This will have - // the effect of interrupting the current work-in-progress render. - _lane3 = pickArbitraryLane(DefaultLanes); - } - } - - return _lane3; - } - - case TransitionShortLanePriority: // Should be handled by findTransitionLane instead - - case TransitionLongLanePriority: - case RetryLanePriority: - // Should be handled by findRetryLane instead - break; - - case IdleLanePriority: - var lane = pickArbitraryLane(IdleLanes & ~wipLanes); - - if (lane === NoLane) { - lane = pickArbitraryLane(IdleLanes); - } - - return lane; - } - - { - throw Error( - "Invalid update priority: " + lanePriority + ". This is a bug in React." - ); - } -} // To ensure consistency across multiple updates in the same event, this should -// be pure function, so that it always returns the same lane for given inputs. - -function findTransitionLane(lanePriority, wipLanes, pendingLanes) { - if (lanePriority === TransitionShortLanePriority) { - // First look for lanes that are completely unclaimed, i.e. have no - // pending work. - var lane = pickArbitraryLane(TransitionShortLanes & ~pendingLanes); - - if (lane === NoLane) { - // If all lanes have pending work, look for a lane that isn't currently - // being worked on. - lane = pickArbitraryLane(TransitionShortLanes & ~wipLanes); - - if (lane === NoLane) { - // If everything is being worked on, pick any lane. This has the - // effect of interrupting the current work-in-progress. - lane = pickArbitraryLane(TransitionShortLanes); - } - } - - return lane; - } - - if (lanePriority === TransitionLongLanePriority) { - // First look for lanes that are completely unclaimed, i.e. have no - // pending work. - var _lane4 = pickArbitraryLane(TransitionLongLanes & ~pendingLanes); - - if (_lane4 === NoLane) { - // If all lanes have pending work, look for a lane that isn't currently - // being worked on. - _lane4 = pickArbitraryLane(TransitionLongLanes & ~wipLanes); - - if (_lane4 === NoLane) { - // If everything is being worked on, pick any lane. This has the - // effect of interrupting the current work-in-progress. - _lane4 = pickArbitraryLane(TransitionLongLanes); - } - } - - return _lane4; - } - - { - throw Error( - "Invalid transition priority: " + - lanePriority + - ". This is a bug in React." - ); - } -} // To ensure consistency across multiple updates in the same event, this should -// be pure function, so that it always returns the same lane for given inputs. - -function findRetryLane(wipLanes) { - // This is a fork of `findUpdateLane` designed specifically for Suspense - // "retries" — a special update that attempts to flip a Suspense boundary - // from its placeholder state to its primary/resolved state. - var lane = pickArbitraryLane(RetryLanes & ~wipLanes); - - if (lane === NoLane) { - lane = pickArbitraryLane(RetryLanes); - } - - return lane; -} - -function getHighestPriorityLane(lanes) { - return lanes & -lanes; -} - -function getLowestPriorityLane(lanes) { - // This finds the most significant non-zero bit. - var index = 31 - clz32(lanes); - return index < 0 ? NoLanes : 1 << index; -} - -function getEqualOrHigherPriorityLanes(lanes) { - return (getLowestPriorityLane(lanes) << 1) - 1; -} - -function pickArbitraryLane(lanes) { - // This wrapper function gets inlined. Only exists so to communicate that it - // doesn't matter which bit is selected; you can pick any bit without - // affecting the algorithms where its used. Here I'm using - // getHighestPriorityLane because it requires the fewest operations. - return getHighestPriorityLane(lanes); -} - -function pickArbitraryLaneIndex(lanes) { - return 31 - clz32(lanes); -} - -function laneToIndex(lane) { - return pickArbitraryLaneIndex(lane); -} - -function includesSomeLane(a, b) { - return (a & b) !== NoLanes; -} -function isSubsetOfLanes(set, subset) { - return (set & subset) === subset; -} -function mergeLanes(a, b) { - return a | b; -} -function removeLanes(set, subset) { - return set & ~subset; -} // Seems redundant, but it changes the type from a single lane (used for -// updates) to a group of lanes (used for flushing work). - -function laneToLanes(lane) { - return lane; -} -function createLaneMap(initial) { - return new Array(TotalLanes).fill(initial); -} -function markRootUpdated(root, updateLane, eventTime) { - root.pendingLanes |= updateLane; // TODO: Theoretically, any update to any lane can unblock any other lane. But - // it's not practical to try every single possible combination. We need a - // heuristic to decide which lanes to attempt to render, and in which batches. - // For now, we use the same heuristic as in the old ExpirationTimes model: - // retry any lane at equal or lower priority, but don't try updates at higher - // priority without also including the lower priority updates. This works well - // when considering updates across different priority levels, but isn't - // sufficient for updates within the same priority, since we want to treat - // those updates as parallel. - // Unsuspend any update at equal or lower priority. - - var higherPriorityLanes = updateLane - 1; // Turns 0b1000 into 0b0111 - - root.suspendedLanes &= higherPriorityLanes; - root.pingedLanes &= higherPriorityLanes; - var eventTimes = root.eventTimes; - var index = laneToIndex(updateLane); // We can always overwrite an existing timestamp because we prefer the most - // recent event, and we assume time is monotonically increasing. - - eventTimes[index] = eventTime; -} -function markRootSuspended(root, suspendedLanes) { - root.suspendedLanes |= suspendedLanes; - root.pingedLanes &= ~suspendedLanes; // The suspended lanes are no longer CPU-bound. Clear their expiration times. - - var expirationTimes = root.expirationTimes; - var lanes = suspendedLanes; - - while (lanes > 0) { - var index = pickArbitraryLaneIndex(lanes); - var lane = 1 << index; - expirationTimes[index] = NoTimestamp; - lanes &= ~lane; - } -} -function markRootPinged(root, pingedLanes, eventTime) { - root.pingedLanes |= root.suspendedLanes & pingedLanes; -} -function markRootExpired(root, expiredLanes) { - root.expiredLanes |= expiredLanes & root.pendingLanes; -} -function hasDiscreteLanes(lanes) { - return (lanes & InputDiscreteLanes) !== NoLanes; -} -function markRootMutableRead(root, updateLane) { - root.mutableReadLanes |= updateLane & root.pendingLanes; -} -function markRootFinished(root, remainingLanes) { - var noLongerPendingLanes = root.pendingLanes & ~remainingLanes; - root.pendingLanes = remainingLanes; // Let's try everything again - - root.suspendedLanes = 0; - root.pingedLanes = 0; - root.expiredLanes &= remainingLanes; - root.mutableReadLanes &= remainingLanes; - root.entangledLanes &= remainingLanes; - var entanglements = root.entanglements; - var eventTimes = root.eventTimes; - var expirationTimes = root.expirationTimes; // Clear the lanes that no longer have pending work - - var lanes = noLongerPendingLanes; - - while (lanes > 0) { - var index = pickArbitraryLaneIndex(lanes); - var lane = 1 << index; - entanglements[index] = NoLanes; - eventTimes[index] = NoTimestamp; - expirationTimes[index] = NoTimestamp; - lanes &= ~lane; - } -} -function markRootEntangled(root, entangledLanes) { - root.entangledLanes |= entangledLanes; - var entanglements = root.entanglements; - var lanes = entangledLanes; - - while (lanes > 0) { - var index = pickArbitraryLaneIndex(lanes); - var lane = 1 << index; - entanglements[index] |= entangledLanes; - lanes &= ~lane; - } -} -var clz32 = Math.clz32 ? Math.clz32 : clz32Fallback; // Count leading zeros. Only used on lanes, so assume input is an integer. -// Based on: -// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/clz32 - -var log = Math.log; -var LN2 = Math.LN2; - -function clz32Fallback(lanes) { - if (lanes === 0) { - return 32; - } - - return (31 - ((log(lanes) / LN2) | 0)) | 0; -} - // Intentionally not named imports because Rollup would use dynamic dispatch for var Scheduler_runWithPriority = Scheduler.unstable_runWithPriority, Scheduler_scheduleCallback = Scheduler.unstable_scheduleCallback, Scheduler_cancelCallback = Scheduler.unstable_cancelCallback, Scheduler_shouldYield = Scheduler.unstable_shouldYield, Scheduler_requestPaint = Scheduler.unstable_requestPaint, - Scheduler_now$1 = Scheduler.unstable_now, + Scheduler_now = Scheduler.unstable_now, Scheduler_getCurrentPriorityLevel = Scheduler.unstable_getCurrentPriorityLevel, Scheduler_ImmediatePriority = Scheduler.unstable_ImmediatePriority, @@ -5599,20 +4872,20 @@ var fakeCallbackNode = {}; // Except for NoPriority, these correspond to Schedul // ascending numbers so we can compare them like numbers. They start at 90 to // avoid clashing with Scheduler's priorities. -var ImmediatePriority$1 = 99; -var UserBlockingPriority$1 = 98; -var NormalPriority$1 = 97; -var LowPriority$1 = 96; -var IdlePriority$1 = 95; // NoPriority is the absence of priority. Also React-only. +var ImmediatePriority = 99; +var UserBlockingPriority = 98; +var NormalPriority = 97; +var LowPriority = 96; +var IdlePriority = 95; // NoPriority is the absence of priority. Also React-only. -var NoPriority$1 = 90; +var NoPriority = 90; var shouldYield = Scheduler_shouldYield; var requestPaint = // Fall back gracefully if we're running an older version of Scheduler. Scheduler_requestPaint !== undefined ? Scheduler_requestPaint : function() {}; var syncQueue = null; var immediateQueueCallbackNode = null; var isFlushingSyncQueue = false; -var initialTimeMs$1 = Scheduler_now$1(); // If the initial timestamp is reasonably small, use Scheduler's `now` directly. +var initialTimeMs = Scheduler_now(); // If the initial timestamp is reasonably small, use Scheduler's `now` directly. // This will be the case for modern browsers that support `performance.now`. In // older browsers, Scheduler falls back to `Date.now`, which returns a Unix // timestamp. In that case, subtract the module initialization time to simulate @@ -5621,27 +4894,27 @@ var initialTimeMs$1 = Scheduler_now$1(); // If the initial timestamp is reasonab // TODO: Consider lifting this into Scheduler. var now = - initialTimeMs$1 < 10000 - ? Scheduler_now$1 + initialTimeMs < 10000 + ? Scheduler_now : function() { - return Scheduler_now$1() - initialTimeMs$1; + return Scheduler_now() - initialTimeMs; }; function getCurrentPriorityLevel() { switch (Scheduler_getCurrentPriorityLevel()) { case Scheduler_ImmediatePriority: - return ImmediatePriority$1; + return ImmediatePriority; case Scheduler_UserBlockingPriority: - return UserBlockingPriority$1; + return UserBlockingPriority; case Scheduler_NormalPriority: - return NormalPriority$1; + return NormalPriority; case Scheduler_LowPriority: - return LowPriority$1; + return LowPriority; case Scheduler_IdlePriority: - return IdlePriority$1; + return IdlePriority; default: { throw Error("Unknown priority level."); @@ -5651,19 +4924,19 @@ function getCurrentPriorityLevel() { function reactPriorityToSchedulerPriority(reactPriorityLevel) { switch (reactPriorityLevel) { - case ImmediatePriority$1: + case ImmediatePriority: return Scheduler_ImmediatePriority; - case UserBlockingPriority$1: + case UserBlockingPriority: return Scheduler_UserBlockingPriority; - case NormalPriority$1: + case NormalPriority: return Scheduler_NormalPriority; - case LowPriority$1: + case LowPriority: return Scheduler_LowPriority; - case IdlePriority$1: + case IdlePriority: return Scheduler_IdlePriority; default: { @@ -5722,8 +4995,7 @@ function flushSyncCallbackQueueImpl() { try { var _isSync = true; var queue = syncQueue; - setCurrentUpdateLanePriority(SyncLanePriority); - runWithPriority(ImmediatePriority$1, function() { + runWithPriority(ImmediatePriority, function() { for (; i < queue.length; i++) { var callback = queue[i]; @@ -5750,58 +5022,6 @@ function flushSyncCallbackQueueImpl() { } } -function describeFiber(fiber) { - var owner = fiber._debugOwner ? fiber._debugOwner.type : null; - var source = fiber._debugSource; - - switch (fiber.tag) { - case HostComponent: - return describeBuiltInComponentFrame(fiber.type, source, owner); - - case LazyComponent: - return describeBuiltInComponentFrame("Lazy", source, owner); - - case SuspenseComponent: - return describeBuiltInComponentFrame("Suspense", source, owner); - - case SuspenseListComponent: - return describeBuiltInComponentFrame("SuspenseList", source, owner); - - case FunctionComponent: - case IndeterminateComponent: - case SimpleMemoComponent: - return describeFunctionComponentFrame(fiber.type, source, owner); - - case ForwardRef: - return describeFunctionComponentFrame(fiber.type.render, source, owner); - - case Block: - return describeFunctionComponentFrame(fiber.type._render, source, owner); - - case ClassComponent: - return describeClassComponentFrame(fiber.type, source, owner); - - default: - return ""; - } -} - -function getStackByFiberInDevAndProd(workInProgress) { - try { - var info = ""; - var node = workInProgress; - - do { - info += describeFiber(node); - node = node.return; - } while (node); - - return info; - } catch (x) { - return "\nError generating stack: " + x.message + "\n" + x.stack; - } -} - var NoMode = 0; var StrictMode = 1; // TODO: Remove BlockingMode and ConcurrentMode by reading from the root // tag instead @@ -5809,7 +5029,116 @@ var StrictMode = 1; // TODO: Remove BlockingMode and ConcurrentMode by reading f var BlockingMode = 2; var ConcurrentMode = 4; var ProfileMode = 8; -var DebugTracingMode = 16; + +// Max 31 bit integer. The max integer size in V8 for 32-bit systems. +// Math.pow(2, 30) - 1 +// 0b111111111111111111111111111111 +var MAX_SIGNED_31_BIT_INT = 1073741823; + +var NoWork = 0; // TODO: Think of a better name for Never. The key difference with Idle is that +// Never work can be committed in an inconsistent state without tearing the UI. +// The main example is offscreen content, like a hidden subtree. So one possible +// name is Offscreen. However, it also includes dehydrated Suspense boundaries, +// which are inconsistent in the sense that they haven't finished yet, but +// aren't visibly inconsistent because the server rendered HTML matches what the +// hydrated tree would look like. + +var Never = 1; // Idle is slightly higher priority than Never. It must completely finish in +// order to be consistent. + +var Idle = 2; // Continuous Hydration is slightly higher than Idle and is used to increase +var Sync = MAX_SIGNED_31_BIT_INT; +var Batched = Sync - 1; +var UNIT_SIZE = 10; +var MAGIC_NUMBER_OFFSET = Batched - 1; // 1 unit of expiration time represents 10ms. + +function msToExpirationTime(ms) { + // Always subtract from the offset so that we don't clash with the magic number for NoWork. + return MAGIC_NUMBER_OFFSET - ((ms / UNIT_SIZE) | 0); +} +function expirationTimeToMs(expirationTime) { + return (MAGIC_NUMBER_OFFSET - expirationTime) * UNIT_SIZE; +} + +function ceiling(num, precision) { + return (((num / precision) | 0) + 1) * precision; +} + +function computeExpirationBucket(currentTime, expirationInMs, bucketSizeMs) { + return ( + MAGIC_NUMBER_OFFSET - + ceiling( + MAGIC_NUMBER_OFFSET - currentTime + expirationInMs / UNIT_SIZE, + bucketSizeMs / UNIT_SIZE + ) + ); +} // TODO: This corresponds to Scheduler's NormalPriority, not LowPriority. Update +// the names to reflect. + +var LOW_PRIORITY_EXPIRATION = 5000; +var LOW_PRIORITY_BATCH_SIZE = 250; +function computeAsyncExpiration(currentTime) { + return computeExpirationBucket( + currentTime, + LOW_PRIORITY_EXPIRATION, + LOW_PRIORITY_BATCH_SIZE + ); +} +function computeSuspenseExpiration(currentTime, timeoutMs) { + // TODO: Should we warn if timeoutMs is lower than the normal pri expiration time? + return computeExpirationBucket( + currentTime, + timeoutMs, + LOW_PRIORITY_BATCH_SIZE + ); +} // We intentionally set a higher expiration time for interactive updates in +// dev than in production. +// +// If the main thread is being blocked so long that you hit the expiration, +// it's a problem that could be solved with better scheduling. +// +// People will be more likely to notice this and fix it with the long +// expiration time in development. +// +// In production we opt for better UX at the risk of masking scheduling +// problems, by expiring fast. + +var HIGH_PRIORITY_EXPIRATION = 500; +var HIGH_PRIORITY_BATCH_SIZE = 100; +function computeInteractiveExpiration(currentTime) { + return computeExpirationBucket( + currentTime, + HIGH_PRIORITY_EXPIRATION, + HIGH_PRIORITY_BATCH_SIZE + ); +} +function inferPriorityFromExpirationTime(currentTime, expirationTime) { + if (expirationTime === Sync) { + return ImmediatePriority; + } + + if (expirationTime === Never || expirationTime === Idle) { + return IdlePriority; + } + + var msUntil = + expirationTimeToMs(expirationTime) - expirationTimeToMs(currentTime); + + if (msUntil <= 0) { + return ImmediatePriority; + } + + if (msUntil <= HIGH_PRIORITY_EXPIRATION + HIGH_PRIORITY_BATCH_SIZE) { + return UserBlockingPriority; + } + + if (msUntil <= LOW_PRIORITY_EXPIRATION + LOW_PRIORITY_BATCH_SIZE) { + return NormalPriority; + } // TODO: Handle LowPriority + // Assume anything lower has idle priority + + return IdlePriority; +} /** * inlined Object.is polyfill to avoid requiring consumers ship their own @@ -5863,7 +5192,76 @@ function shallowEqual(objA, objB) { return true; } -var ReactDebugCurrentFrame$1 = ReactSharedInternals.ReactDebugCurrentFrame; +var BEFORE_SLASH_RE = /^(.*)[\\\/]/; +function describeComponentFrame(name, source, ownerName) { + var sourceInfo = ""; + + if (source) { + var path = source.fileName; + var fileName = path.replace(BEFORE_SLASH_RE, ""); + + { + // In DEV, include code for a common special case: + // prefer "folder/index.js" instead of just "index.js". + if (/^index\./.test(fileName)) { + var match = path.match(BEFORE_SLASH_RE); + + if (match) { + var pathBeforeSlash = match[1]; + + if (pathBeforeSlash) { + var folderName = pathBeforeSlash.replace(BEFORE_SLASH_RE, ""); + fileName = folderName + "/" + fileName; + } + } + } + } + + sourceInfo = " (at " + fileName + ":" + source.lineNumber + ")"; + } else if (ownerName) { + sourceInfo = " (created by " + ownerName + ")"; + } + + return "\n in " + (name || "Unknown") + sourceInfo; +} + +var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame; + +function describeFiber(fiber) { + switch (fiber.tag) { + case HostRoot: + case HostPortal: + case HostText: + case Fragment: + case ContextProvider: + case ContextConsumer: + return ""; + + default: + var owner = fiber._debugOwner; + var source = fiber._debugSource; + var name = getComponentName(fiber.type); + var ownerName = null; + + if (owner) { + ownerName = getComponentName(owner.type); + } + + return describeComponentFrame(name, source, ownerName); + } +} + +function getStackByFiberInDevAndProd(workInProgress) { + var info = ""; + var node = workInProgress; + + do { + info += describeFiber(node); + node = node.return; + } while (node); + + return info; +} var current = null; var isRendering = false; function getCurrentFiberOwnerNameInDevOrNull() { @@ -5881,7 +5279,6 @@ function getCurrentFiberOwnerNameInDevOrNull() { return null; } - function getCurrentFiberStackInDev() { { if (current === null) { @@ -5892,17 +5289,16 @@ function getCurrentFiberStackInDev() { return getStackByFiberInDevAndProd(current); } } - function resetCurrentFiber() { { - ReactDebugCurrentFrame$1.getCurrentStack = null; + ReactDebugCurrentFrame.getCurrentStack = null; current = null; isRendering = false; } } function setCurrentFiber(fiber) { { - ReactDebugCurrentFrame$1.getCurrentStack = getCurrentFiberStackInDev; + ReactDebugCurrentFrame.getCurrentStack = getCurrentFiberStackInDev; current = fiber; isRendering = false; } @@ -5912,11 +5308,6 @@ function setIsRendering(rendering) { isRendering = rendering; } } -function getIsRendering() { - { - return isRendering; - } -} var ReactStrictModeWarnings = { recordUnsafeLifecycleWarnings: function(fiber, instance) {}, @@ -6139,7 +5530,7 @@ var ReactStrictModeWarnings = { "See https://fb.me/react-unsafe-component-lifecycles for details.\n\n" + "* Move code with side effects to componentDidMount, and set initial state in the constructor.\n" + "* Rename componentWillMount to UNSAFE_componentWillMount to suppress " + - "this warning in non-strict mode. In React 18.x, only the UNSAFE_ name will work. " + + "this warning in non-strict mode. In React 17.x, only the UNSAFE_ name will work. " + "To rename all deprecated lifecycles to their new names, you can run " + "`npx react-codemod rename-unsafe-lifecycles` in your project source folder.\n" + "\nPlease update the following components: %s", @@ -6160,7 +5551,7 @@ var ReactStrictModeWarnings = { "code to use memoization techniques or move it to " + "static getDerivedStateFromProps. Learn more at: https://fb.me/react-derived-state\n" + "* Rename componentWillReceiveProps to UNSAFE_componentWillReceiveProps to suppress " + - "this warning in non-strict mode. In React 18.x, only the UNSAFE_ name will work. " + + "this warning in non-strict mode. In React 17.x, only the UNSAFE_ name will work. " + "To rename all deprecated lifecycles to their new names, you can run " + "`npx react-codemod rename-unsafe-lifecycles` in your project source folder.\n" + "\nPlease update the following components: %s", @@ -6176,7 +5567,7 @@ var ReactStrictModeWarnings = { "See https://fb.me/react-unsafe-component-lifecycles for details.\n\n" + "* Move data fetching code or side effects to componentDidUpdate.\n" + "* Rename componentWillUpdate to UNSAFE_componentWillUpdate to suppress " + - "this warning in non-strict mode. In React 18.x, only the UNSAFE_ name will work. " + + "this warning in non-strict mode. In React 17.x, only the UNSAFE_ name will work. " + "To rename all deprecated lifecycles to their new names, you can run " + "`npx react-codemod rename-unsafe-lifecycles` in your project source folder.\n" + "\nPlease update the following components: %s", @@ -6237,21 +5628,18 @@ var ReactStrictModeWarnings = { didWarnAboutLegacyContext.add(fiber.type); }); var sortedNames = setToSortedString(uniqueNames); + var firstComponentStack = getStackByFiberInDevAndProd(firstFiber); - try { - setCurrentFiber(firstFiber); - - error( - "Legacy context API has been detected within a strict-mode tree." + - "\n\nThe old API will be supported in all 16.x releases, but applications " + - "using it should migrate to the new version." + - "\n\nPlease update the following components: %s" + - "\n\nLearn more about this warning here: https://fb.me/react-legacy-context", - sortedNames - ); - } finally { - resetCurrentFiber(); - } + error( + "Legacy context API has been detected within a strict-mode tree." + + "\n\nThe old API will be supported in all 16.x releases, but applications " + + "using it should migrate to the new version." + + "\n\nPlease update the following components: %s" + + "\n\nLearn more about this warning here: https://fb.me/react-legacy-context" + + "%s", + sortedNames, + firstComponentStack + ); }); }; @@ -6266,6 +5654,441 @@ var ReactStrictModeWarnings = { }; } +var resolveFamily = null; // $FlowFixMe Flow gets confused by a WeakSet feature check below. + +var failedBoundaries = null; +var setRefreshHandler = function(handler) { + { + resolveFamily = handler; + } +}; +function resolveFunctionForHotReloading(type) { + { + if (resolveFamily === null) { + // Hot reloading is disabled. + return type; + } + + var family = resolveFamily(type); + + if (family === undefined) { + return type; + } // Use the latest known implementation. + + return family.current; + } +} +function resolveClassForHotReloading(type) { + // No implementation differences. + return resolveFunctionForHotReloading(type); +} +function resolveForwardRefForHotReloading(type) { + { + if (resolveFamily === null) { + // Hot reloading is disabled. + return type; + } + + var family = resolveFamily(type); + + if (family === undefined) { + // Check if we're dealing with a real forwardRef. Don't want to crash early. + if ( + type !== null && + type !== undefined && + typeof type.render === "function" + ) { + // ForwardRef is special because its resolved .type is an object, + // but it's possible that we only have its inner render function in the map. + // If that inner render function is different, we'll build a new forwardRef type. + var currentRender = resolveFunctionForHotReloading(type.render); + + if (type.render !== currentRender) { + var syntheticType = { + $$typeof: REACT_FORWARD_REF_TYPE, + render: currentRender + }; + + if (type.displayName !== undefined) { + syntheticType.displayName = type.displayName; + } + + return syntheticType; + } + } + + return type; + } // Use the latest known implementation. + + return family.current; + } +} +function isCompatibleFamilyForHotReloading(fiber, element) { + { + if (resolveFamily === null) { + // Hot reloading is disabled. + return false; + } + + var prevType = fiber.elementType; + var nextType = element.type; // If we got here, we know types aren't === equal. + + var needsCompareFamilies = false; + var $$typeofNextType = + typeof nextType === "object" && nextType !== null + ? nextType.$$typeof + : null; + + switch (fiber.tag) { + case ClassComponent: { + if (typeof nextType === "function") { + needsCompareFamilies = true; + } + + break; + } + + case FunctionComponent: { + if (typeof nextType === "function") { + needsCompareFamilies = true; + } else if ($$typeofNextType === REACT_LAZY_TYPE) { + // We don't know the inner type yet. + // We're going to assume that the lazy inner type is stable, + // and so it is sufficient to avoid reconciling it away. + // We're not going to unwrap or actually use the new lazy type. + needsCompareFamilies = true; + } + + break; + } + + case ForwardRef: { + if ($$typeofNextType === REACT_FORWARD_REF_TYPE) { + needsCompareFamilies = true; + } else if ($$typeofNextType === REACT_LAZY_TYPE) { + needsCompareFamilies = true; + } + + break; + } + + case MemoComponent: + case SimpleMemoComponent: { + if ($$typeofNextType === REACT_MEMO_TYPE) { + // TODO: if it was but can no longer be simple, + // we shouldn't set this. + needsCompareFamilies = true; + } else if ($$typeofNextType === REACT_LAZY_TYPE) { + needsCompareFamilies = true; + } + + break; + } + + default: + return false; + } // Check if both types have a family and it's the same one. + + if (needsCompareFamilies) { + // Note: memo() and forwardRef() we'll compare outer rather than inner type. + // This means both of them need to be registered to preserve state. + // If we unwrapped and compared the inner types for wrappers instead, + // then we would risk falsely saying two separate memo(Foo) + // calls are equivalent because they wrap the same Foo function. + var prevFamily = resolveFamily(prevType); + + if (prevFamily !== undefined && prevFamily === resolveFamily(nextType)) { + return true; + } + } + + return false; + } +} +function markFailedErrorBoundaryForHotReloading(fiber) { + { + if (resolveFamily === null) { + // Hot reloading is disabled. + return; + } + + if (typeof WeakSet !== "function") { + return; + } + + if (failedBoundaries === null) { + failedBoundaries = new WeakSet(); + } + + failedBoundaries.add(fiber); + } +} +var scheduleRefresh = function(root, update) { + { + if (resolveFamily === null) { + // Hot reloading is disabled. + return; + } + + var staleFamilies = update.staleFamilies, + updatedFamilies = update.updatedFamilies; + flushPassiveEffects(); + flushSync(function() { + scheduleFibersWithFamiliesRecursively( + root.current, + updatedFamilies, + staleFamilies + ); + }); + } +}; +var scheduleRoot = function(root, element) { + { + if (root.context !== emptyContextObject) { + // Super edge case: root has a legacy _renderSubtree context + // but we don't know the parentComponent so we can't pass it. + // Just ignore. We'll delete this with _renderSubtree code path later. + return; + } + + flushPassiveEffects(); + syncUpdates(function() { + updateContainer(element, root, null, null); + }); + } +}; + +function scheduleFibersWithFamiliesRecursively( + fiber, + updatedFamilies, + staleFamilies +) { + { + var alternate = fiber.alternate, + child = fiber.child, + sibling = fiber.sibling, + tag = fiber.tag, + type = fiber.type; + var candidateType = null; + + switch (tag) { + case FunctionComponent: + case SimpleMemoComponent: + case ClassComponent: + candidateType = type; + break; + + case ForwardRef: + candidateType = type.render; + break; + } + + if (resolveFamily === null) { + throw new Error("Expected resolveFamily to be set during hot reload."); + } + + var needsRender = false; + var needsRemount = false; + + if (candidateType !== null) { + var family = resolveFamily(candidateType); + + if (family !== undefined) { + if (staleFamilies.has(family)) { + needsRemount = true; + } else if (updatedFamilies.has(family)) { + if (tag === ClassComponent) { + needsRemount = true; + } else { + needsRender = true; + } + } + } + } + + if (failedBoundaries !== null) { + if ( + failedBoundaries.has(fiber) || + (alternate !== null && failedBoundaries.has(alternate)) + ) { + needsRemount = true; + } + } + + if (needsRemount) { + fiber._debugNeedsRemount = true; + } + + if (needsRemount || needsRender) { + scheduleWork(fiber, Sync); + } + + if (child !== null && !needsRemount) { + scheduleFibersWithFamiliesRecursively( + child, + updatedFamilies, + staleFamilies + ); + } + + if (sibling !== null) { + scheduleFibersWithFamiliesRecursively( + sibling, + updatedFamilies, + staleFamilies + ); + } + } +} + +var findHostInstancesForRefresh = function(root, families) { + { + var hostInstances = new Set(); + var types = new Set( + families.map(function(family) { + return family.current; + }) + ); + findHostInstancesForMatchingFibersRecursively( + root.current, + types, + hostInstances + ); + return hostInstances; + } +}; + +function findHostInstancesForMatchingFibersRecursively( + fiber, + types, + hostInstances +) { + { + var child = fiber.child, + sibling = fiber.sibling, + tag = fiber.tag, + type = fiber.type; + var candidateType = null; + + switch (tag) { + case FunctionComponent: + case SimpleMemoComponent: + case ClassComponent: + candidateType = type; + break; + + case ForwardRef: + candidateType = type.render; + break; + } + + var didMatch = false; + + if (candidateType !== null) { + if (types.has(candidateType)) { + didMatch = true; + } + } + + if (didMatch) { + // We have a match. This only drills down to the closest host components. + // There's no need to search deeper because for the purpose of giving + // visual feedback, "flashing" outermost parent rectangles is sufficient. + findHostInstancesForFiberShallowly(fiber, hostInstances); + } else { + // If there's no match, maybe there will be one further down in the child tree. + if (child !== null) { + findHostInstancesForMatchingFibersRecursively( + child, + types, + hostInstances + ); + } + } + + if (sibling !== null) { + findHostInstancesForMatchingFibersRecursively( + sibling, + types, + hostInstances + ); + } + } +} + +function findHostInstancesForFiberShallowly(fiber, hostInstances) { + { + var foundHostInstances = findChildHostInstancesForFiberShallowly( + fiber, + hostInstances + ); + + if (foundHostInstances) { + return; + } // If we didn't find any host children, fallback to closest host parent. + + var node = fiber; + + while (true) { + switch (node.tag) { + case HostComponent: + hostInstances.add(node.stateNode); + return; + + case HostPortal: + hostInstances.add(node.stateNode.containerInfo); + return; + + case HostRoot: + hostInstances.add(node.stateNode.containerInfo); + return; + } + + if (node.return === null) { + throw new Error("Expected to reach root first."); + } + + node = node.return; + } + } +} + +function findChildHostInstancesForFiberShallowly(fiber, hostInstances) { + { + var node = fiber; + var foundHostInstances = false; + + while (true) { + if (node.tag === HostComponent) { + // We got a match. + foundHostInstances = true; + hostInstances.add(node.stateNode); // There may still be more, so keep searching. + } else if (node.child !== null) { + node.child.return = node; + node = node.child; + continue; + } + + if (node === fiber) { + return foundHostInstances; + } + + while (node.sibling === null) { + if (node.return === null || node.return === fiber) { + return foundHostInstances; + } + + node = node.return; + } + + node.sibling.return = node.return; + node = node.sibling; + } + } + + return false; +} + function resolveDefaultProps(Component, baseProps) { if (Component && Component.defaultProps) { // Resolve default props. Taken from ReactElement @@ -6283,11 +6106,15 @@ function resolveDefaultProps(Component, baseProps) { return baseProps; } +function readLazyComponentType(lazyComponent) { + initializeLazyComponentType(lazyComponent); -// Max 31 bit integer. The max integer size in V8 for 32-bit systems. -// Math.pow(2, 30) - 1 -// 0b111111111111111111111111111111 -var MAX_SIGNED_31_BIT_INT = 1073741823; + if (lazyComponent._status !== Resolved) { + throw lazyComponent._result; + } + + return lazyComponent._result; +} var valueCursor = createCursor(null); var rendererSigil; @@ -6377,24 +6204,28 @@ function calculateChangedBits(context, newValue, oldValue) { return changedBits | 0; } } -function scheduleWorkOnParentPath(parent, renderLanes) { - // Update the child lanes of all the ancestors, including the alternates. +function scheduleWorkOnParentPath(parent, renderExpirationTime) { + // Update the child expiration time of all the ancestors, including + // the alternates. var node = parent; while (node !== null) { var alternate = node.alternate; - if (!isSubsetOfLanes(node.childLanes, renderLanes)) { - node.childLanes = mergeLanes(node.childLanes, renderLanes); + if (node.childExpirationTime < renderExpirationTime) { + node.childExpirationTime = renderExpirationTime; - if (alternate !== null) { - alternate.childLanes = mergeLanes(alternate.childLanes, renderLanes); + if ( + alternate !== null && + alternate.childExpirationTime < renderExpirationTime + ) { + alternate.childExpirationTime = renderExpirationTime; } } else if ( alternate !== null && - !isSubsetOfLanes(alternate.childLanes, renderLanes) + alternate.childExpirationTime < renderExpirationTime ) { - alternate.childLanes = mergeLanes(alternate.childLanes, renderLanes); + alternate.childExpirationTime = renderExpirationTime; } else { // Neither alternate was updated, which means the rest of the // ancestor path already has sufficient priority. @@ -6408,7 +6239,7 @@ function propagateContextChange( workInProgress, context, changedBits, - renderLanes + renderExpirationTime ) { var fiber = workInProgress.child; @@ -6435,11 +6266,7 @@ function propagateContextChange( // Match! Schedule an update on this fiber. if (fiber.tag === ClassComponent) { // Schedule a force update on the work-in-progress. - var update = createUpdate( - NoTimestamp, - pickArbitraryLane(renderLanes), - null - ); + var update = createUpdate(renderExpirationTime, null); update.tag = ForceUpdate; // TODO: Because we don't have a work-in-progress, this will add the // update to the current fiber, too, which means it will persist even if // this render is thrown away. Since it's a race condition, not sure it's @@ -6448,16 +6275,24 @@ function propagateContextChange( enqueueUpdate(fiber, update); } - fiber.lanes = mergeLanes(fiber.lanes, renderLanes); - var alternate = fiber.alternate; - - if (alternate !== null) { - alternate.lanes = mergeLanes(alternate.lanes, renderLanes); + if (fiber.expirationTime < renderExpirationTime) { + fiber.expirationTime = renderExpirationTime; } - scheduleWorkOnParentPath(fiber.return, renderLanes); // Mark the updated lanes on the list, too. + var alternate = fiber.alternate; - list.lanes = mergeLanes(list.lanes, renderLanes); // Since we already found a match, we can stop traversing the + if ( + alternate !== null && + alternate.expirationTime < renderExpirationTime + ) { + alternate.expirationTime = renderExpirationTime; + } + + scheduleWorkOnParentPath(fiber.return, renderExpirationTime); // Mark the expiration time on the list, too. + + if (list.expirationTime < renderExpirationTime) { + list.expirationTime = renderExpirationTime; + } // Since we already found a match, we can stop traversing the // dependency list. break; @@ -6503,7 +6338,7 @@ function propagateContextChange( fiber = nextFiber; } } -function prepareToReadContext(workInProgress, renderLanes) { +function prepareToReadContext(workInProgress, renderExpirationTime) { currentlyRenderingFiber = workInProgress; lastContextDependency = null; lastContextWithAllBitsObserved = null; @@ -6513,7 +6348,7 @@ function prepareToReadContext(workInProgress, renderLanes) { var firstContext = dependencies.firstContext; if (firstContext !== null) { - if (includesSomeLane(dependencies.lanes, renderLanes)) { + if (dependencies.expirationTime >= renderExpirationTime) { // Context list has a pending update. Mark that this fiber performed work. markWorkInProgressReceivedUpdate(); } // Reset the work-in-progress list @@ -6567,7 +6402,7 @@ function readContext(context, observedBits) { lastContextDependency = contextItem; currentlyRenderingFiber.dependencies = { - lanes: NoLanes, + expirationTime: NoWork, firstContext: contextItem, responders: null }; @@ -6599,8 +6434,7 @@ var currentlyProcessingQueue; function initializeUpdateQueue(fiber) { var queue = { baseState: fiber.memoizedState, - firstBaseUpdate: null, - lastBaseUpdate: null, + baseQueue: null, shared: { pending: null }, @@ -6616,24 +6450,28 @@ function cloneUpdateQueue(current, workInProgress) { if (queue === currentQueue) { var clone = { baseState: currentQueue.baseState, - firstBaseUpdate: currentQueue.firstBaseUpdate, - lastBaseUpdate: currentQueue.lastBaseUpdate, + baseQueue: currentQueue.baseQueue, shared: currentQueue.shared, effects: currentQueue.effects }; workInProgress.updateQueue = clone; } } -function createUpdate(eventTime, lane, suspenseConfig) { +function createUpdate(expirationTime, suspenseConfig) { var update = { - eventTime: eventTime, - lane: lane, + expirationTime: expirationTime, suspenseConfig: suspenseConfig, tag: UpdateState, payload: null, callback: null, next: null }; + update.next = update; + + { + update.priority = getCurrentPriorityLevel(); + } + return update; } function enqueueUpdate(fiber, update) { @@ -6673,85 +6511,25 @@ function enqueueUpdate(fiber, update) { } } } -function enqueueCapturedUpdate(workInProgress, capturedUpdate) { - // Captured updates are updates that are thrown by a child during the render - // phase. They should be discarded if the render is aborted. Therefore, - // we should only put them on the work-in-progress queue, not the current one. - var queue = workInProgress.updateQueue; // Check if the work-in-progress queue is a clone. - +function enqueueCapturedUpdate(workInProgress, update) { var current = workInProgress.alternate; if (current !== null) { - var currentQueue = current.updateQueue; + // Ensure the work-in-progress queue is a clone + cloneUpdateQueue(current, workInProgress); + } // Captured updates go only on the work-in-progress queue. - if (queue === currentQueue) { - // The work-in-progress queue is the same as current. This happens when - // we bail out on a parent fiber that then captures an error thrown by - // a child. Since we want to append the update only to the work-in - // -progress queue, we need to clone the updates. We usually clone during - // processUpdateQueue, but that didn't happen in this case because we - // skipped over the parent when we bailed out. - var newFirst = null; - var newLast = null; - var firstBaseUpdate = queue.firstBaseUpdate; + var queue = workInProgress.updateQueue; // Append the update to the end of the list. - if (firstBaseUpdate !== null) { - // Loop through the updates and clone them. - var update = firstBaseUpdate; + var last = queue.baseQueue; - do { - var clone = { - eventTime: update.eventTime, - lane: update.lane, - suspenseConfig: update.suspenseConfig, - tag: update.tag, - payload: update.payload, - callback: update.callback, - next: null - }; - - if (newLast === null) { - newFirst = newLast = clone; - } else { - newLast.next = clone; - newLast = clone; - } - - update = update.next; - } while (update !== null); // Append the captured update the end of the cloned list. - - if (newLast === null) { - newFirst = newLast = capturedUpdate; - } else { - newLast.next = capturedUpdate; - newLast = capturedUpdate; - } - } else { - // There are no base updates. - newFirst = newLast = capturedUpdate; - } - - queue = { - baseState: currentQueue.baseState, - firstBaseUpdate: newFirst, - lastBaseUpdate: newLast, - shared: currentQueue.shared, - effects: currentQueue.effects - }; - workInProgress.updateQueue = queue; - return; - } - } // Append the update to the end of the list. - - var lastBaseUpdate = queue.lastBaseUpdate; - - if (lastBaseUpdate === null) { - queue.firstBaseUpdate = capturedUpdate; + if (last === null) { + queue.baseQueue = update.next = update; + update.next = update; } else { - lastBaseUpdate.next = capturedUpdate; + update.next = last.next; + last.next = update; } - - queue.lastBaseUpdate = capturedUpdate; } function getStateFromUpdate( @@ -6770,21 +6548,15 @@ function getStateFromUpdate( // Updater function { enterDisallowedContextReadInDEV(); + + if (workInProgress.mode & StrictMode) { + payload.call(instance, prevState, nextProps); + } } var nextState = payload.call(instance, prevState, nextProps); { - if (workInProgress.mode & StrictMode) { - disableLogs(); - - try { - payload.call(instance, prevState, nextProps); - } finally { - reenableLogs(); - } - } - exitDisallowedContextReadInDEV(); } @@ -6808,21 +6580,15 @@ function getStateFromUpdate( // Updater function { enterDisallowedContextReadInDEV(); + + if (workInProgress.mode & StrictMode) { + _payload.call(instance, prevState, nextProps); + } } partialState = _payload.call(instance, prevState, nextProps); { - if (workInProgress.mode & StrictMode) { - disableLogs(); - - try { - _payload.call(instance, prevState, nextProps); - } finally { - reenableLogs(); - } - } - exitDisallowedContextReadInDEV(); } } else { @@ -6847,172 +6613,161 @@ function getStateFromUpdate( return prevState; } -function processUpdateQueue(workInProgress, props, instance, renderLanes) { +function processUpdateQueue( + workInProgress, + props, + instance, + renderExpirationTime +) { // This is always non-null on a ClassComponent or HostRoot var queue = workInProgress.updateQueue; hasForceUpdate = false; { currentlyProcessingQueue = queue.shared; - } + } // The last rebase update that is NOT part of the base state. - var firstBaseUpdate = queue.firstBaseUpdate; - var lastBaseUpdate = queue.lastBaseUpdate; // Check if there are pending updates. If so, transfer them to the base queue. + var baseQueue = queue.baseQueue; // The last pending update that hasn't been processed yet. var pendingQueue = queue.shared.pending; if (pendingQueue !== null) { - queue.shared.pending = null; // The pending queue is circular. Disconnect the pointer between first - // and last so that it's non-circular. - - var lastPendingUpdate = pendingQueue; - var firstPendingUpdate = lastPendingUpdate.next; - lastPendingUpdate.next = null; // Append pending updates to base queue - - if (lastBaseUpdate === null) { - firstBaseUpdate = firstPendingUpdate; - } else { - lastBaseUpdate.next = firstPendingUpdate; + // We have new updates that haven't been processed yet. + // We'll add them to the base queue. + if (baseQueue !== null) { + // Merge the pending queue and the base queue. + var baseFirst = baseQueue.next; + var pendingFirst = pendingQueue.next; + baseQueue.next = pendingFirst; + pendingQueue.next = baseFirst; } - lastBaseUpdate = lastPendingUpdate; // If there's a current queue, and it's different from the base queue, then - // we need to transfer the updates to that queue, too. Because the base - // queue is a singly-linked list with no cycles, we can append to both - // lists and take advantage of structural sharing. - // TODO: Pass `current` as argument + baseQueue = pendingQueue; + queue.shared.pending = null; // TODO: Pass `current` as argument var current = workInProgress.alternate; if (current !== null) { - // This is always non-null on a ClassComponent or HostRoot var currentQueue = current.updateQueue; - var currentLastBaseUpdate = currentQueue.lastBaseUpdate; - if (currentLastBaseUpdate !== lastBaseUpdate) { - if (currentLastBaseUpdate === null) { - currentQueue.firstBaseUpdate = firstPendingUpdate; - } else { - currentLastBaseUpdate.next = firstPendingUpdate; - } - - currentQueue.lastBaseUpdate = lastPendingUpdate; + if (currentQueue !== null) { + currentQueue.baseQueue = pendingQueue; } } } // These values may change as we process the queue. - if (firstBaseUpdate !== null) { - // Iterate through the list of updates to compute the result. - var newState = queue.baseState; // TODO: Don't need to accumulate this. Instead, we can remove renderLanes - // from the original lanes. + if (baseQueue !== null) { + var first = baseQueue.next; // Iterate through the list of updates to compute the result. - var newLanes = NoLanes; + var newState = queue.baseState; + var newExpirationTime = NoWork; var newBaseState = null; - var newFirstBaseUpdate = null; - var newLastBaseUpdate = null; - var update = firstBaseUpdate; + var newBaseQueueFirst = null; + var newBaseQueueLast = null; - do { - var updateLane = update.lane; - var updateEventTime = update.eventTime; + if (first !== null) { + var update = first; - if (!isSubsetOfLanes(renderLanes, updateLane)) { - // Priority is insufficient. Skip this update. If this is the first - // skipped update, the previous update/state is the new base - // update/state. - var clone = { - eventTime: updateEventTime, - lane: updateLane, - suspenseConfig: update.suspenseConfig, - tag: update.tag, - payload: update.payload, - callback: update.callback, - next: null - }; + do { + var updateExpirationTime = update.expirationTime; - if (newLastBaseUpdate === null) { - newFirstBaseUpdate = newLastBaseUpdate = clone; - newBaseState = newState; - } else { - newLastBaseUpdate = newLastBaseUpdate.next = clone; - } // Update the remaining priority in the queue. - - newLanes = mergeLanes(newLanes, updateLane); - } else { - // This update does have sufficient priority. - if (newLastBaseUpdate !== null) { - var _clone = { - eventTime: updateEventTime, - // This update is going to be committed so we never want uncommit - // it. Using NoLane works because 0 is a subset of all bitmasks, so - // this will never be skipped by the check above. - lane: NoLane, + 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. + var clone = { + expirationTime: update.expirationTime, suspenseConfig: update.suspenseConfig, tag: update.tag, payload: update.payload, callback: update.callback, next: null }; - newLastBaseUpdate = newLastBaseUpdate.next = _clone; - } // Mark the event time of this update as relevant to this render pass. - // TODO: This should ideally use the true event time of this update rather than - // its priority which is a derived and not reversible value. - // TODO: We should skip this update if it was already committed but currently - // we have no way of detecting the difference between a committed and suspended - // update here. - markRenderEventTimeAndConfig(updateEventTime, update.suspenseConfig); // Process this update. - - newState = getStateFromUpdate( - workInProgress, - queue, - update, - newState, - props, - instance - ); - var callback = update.callback; - - if (callback !== null) { - workInProgress.effectTag |= Callback; - var effects = queue.effects; - - if (effects === null) { - queue.effects = [update]; + if (newBaseQueueLast === null) { + newBaseQueueFirst = newBaseQueueLast = clone; + newBaseState = newState; } else { - effects.push(update); + newBaseQueueLast = newBaseQueueLast.next = clone; + } // Update the remaining priority in the queue. + + if (updateExpirationTime > newExpirationTime) { + newExpirationTime = updateExpirationTime; + } + } else { + // This update does have sufficient priority. + if (newBaseQueueLast !== null) { + var _clone = { + expirationTime: Sync, + // This update is going to be committed so we never want uncommit it. + suspenseConfig: update.suspenseConfig, + tag: update.tag, + payload: update.payload, + callback: update.callback, + next: null + }; + newBaseQueueLast = newBaseQueueLast.next = _clone; + } // Mark the event time of this update as relevant to this render pass. + // TODO: This should ideally use the true event time of this update rather than + // its priority which is a derived and not reverseable value. + // TODO: We should skip this update if it was already committed but currently + // we have no way of detecting the difference between a committed and suspended + // update here. + + markRenderEventTimeAndConfig( + updateExpirationTime, + update.suspenseConfig + ); // Process this update. + + newState = getStateFromUpdate( + workInProgress, + queue, + update, + newState, + props, + instance + ); + var callback = update.callback; + + if (callback !== null) { + workInProgress.effectTag |= Callback; + var effects = queue.effects; + + if (effects === null) { + queue.effects = [update]; + } else { + effects.push(update); + } } } - } - update = update.next; + update = update.next; - if (update === null) { - pendingQueue = queue.shared.pending; + if (update === null || update === first) { + pendingQueue = queue.shared.pending; - if (pendingQueue === null) { - break; - } else { - // An update was scheduled from inside a reducer. Add the new - // pending updates to the end of the list and keep processing. - var _lastPendingUpdate = pendingQueue; // Intentionally unsound. Pending updates form a circular list, but we - // unravel them when transferring them to the base queue. - - var _firstPendingUpdate = _lastPendingUpdate.next; - _lastPendingUpdate.next = null; - update = _firstPendingUpdate; - queue.lastBaseUpdate = _lastPendingUpdate; - queue.shared.pending = null; + if (pendingQueue === null) { + break; + } else { + // An update was scheduled from inside a reducer. Add the new + // pending updates to the end of the list and keep processing. + update = baseQueue.next = pendingQueue.next; + pendingQueue.next = first; + queue.baseQueue = baseQueue = pendingQueue; + queue.shared.pending = null; + } } - } - } while (true); + } while (true); + } - if (newLastBaseUpdate === null) { + if (newBaseQueueLast === null) { newBaseState = newState; + } else { + newBaseQueueLast.next = newBaseQueueFirst; } queue.baseState = newBaseState; - queue.firstBaseUpdate = newFirstBaseUpdate; - queue.lastBaseUpdate = newLastBaseUpdate; // Set the remaining expiration time to be whatever is remaining in the queue. + queue.baseQueue = newBaseQueueLast; // Set the remaining expiration time to be whatever is remaining in the queue. // This should be fine because the only two other things that contribute to // expiration time are props and context. We're already in the middle of the // begin phase by the time we start processing the queue, so we've already @@ -7020,8 +6775,8 @@ function processUpdateQueue(workInProgress, props, instance, renderLanes) { // shouldComponentUpdate is tricky; but we'll have to account for // that regardless. - markSkippedUpdateLanes(newLanes); - workInProgress.lanes = newLanes; + markUnprocessedUpdateTime(newExpirationTime); + workInProgress.expirationTime = newExpirationTime; workInProgress.memoizedState = newState; } @@ -7159,14 +6914,8 @@ function applyDerivedStateFromProps( { if (workInProgress.mode & StrictMode) { - disableLogs(); - - try { - // Invoke the function an extra time to help detect side-effects. - getDerivedStateFromProps(nextProps, prevState); - } finally { - reenableLogs(); - } + // Invoke the function an extra time to help detect side-effects. + getDerivedStateFromProps(nextProps, prevState); } } @@ -7183,7 +6932,7 @@ function applyDerivedStateFromProps( workInProgress.memoizedState = memoizedState; // Once the update queue is empty, persist the derived state onto the // base state. - if (workInProgress.lanes === NoLanes) { + if (workInProgress.expirationTime === NoWork) { // Queue is always non-null for classes var updateQueue = workInProgress.updateQueue; updateQueue.baseState = memoizedState; @@ -7193,10 +6942,14 @@ var classComponentUpdater = { isMounted: isMounted, enqueueSetState: function(inst, payload, callback) { var fiber = get(inst); - var eventTime = requestEventTime(); + var currentTime = requestCurrentTimeForUpdate(); var suspenseConfig = requestCurrentSuspenseConfig(); - var lane = requestUpdateLane(fiber, suspenseConfig); - var update = createUpdate(eventTime, lane, suspenseConfig); + var expirationTime = computeExpirationForFiber( + currentTime, + fiber, + suspenseConfig + ); + var update = createUpdate(expirationTime, suspenseConfig); update.payload = payload; if (callback !== undefined && callback !== null) { @@ -7208,14 +6961,18 @@ var classComponentUpdater = { } enqueueUpdate(fiber, update); - scheduleUpdateOnFiber(fiber, lane, eventTime); + scheduleWork(fiber, expirationTime); }, enqueueReplaceState: function(inst, payload, callback) { var fiber = get(inst); - var eventTime = requestEventTime(); + var currentTime = requestCurrentTimeForUpdate(); var suspenseConfig = requestCurrentSuspenseConfig(); - var lane = requestUpdateLane(fiber, suspenseConfig); - var update = createUpdate(eventTime, lane, suspenseConfig); + var expirationTime = computeExpirationForFiber( + currentTime, + fiber, + suspenseConfig + ); + var update = createUpdate(expirationTime, suspenseConfig); update.tag = ReplaceState; update.payload = payload; @@ -7228,14 +6985,18 @@ var classComponentUpdater = { } enqueueUpdate(fiber, update); - scheduleUpdateOnFiber(fiber, lane, eventTime); + scheduleWork(fiber, expirationTime); }, enqueueForceUpdate: function(inst, callback) { var fiber = get(inst); - var eventTime = requestEventTime(); + var currentTime = requestCurrentTimeForUpdate(); var suspenseConfig = requestCurrentSuspenseConfig(); - var lane = requestUpdateLane(fiber, suspenseConfig); - var update = createUpdate(eventTime, lane, suspenseConfig); + var expirationTime = computeExpirationForFiber( + currentTime, + fiber, + suspenseConfig + ); + var update = createUpdate(expirationTime, suspenseConfig); update.tag = ForceUpdate; if (callback !== undefined && callback !== null) { @@ -7247,7 +7008,7 @@ var classComponentUpdater = { } enqueueUpdate(fiber, update); - scheduleUpdateOnFiber(fiber, lane, eventTime); + scheduleWork(fiber, expirationTime); } }; @@ -7265,22 +7026,18 @@ function checkShouldComponentUpdate( if (typeof instance.shouldComponentUpdate === "function") { { if (workInProgress.mode & StrictMode) { - disableLogs(); - - try { - // Invoke the function an extra time to help detect side-effects. - instance.shouldComponentUpdate(newProps, newState, nextContext); - } finally { - reenableLogs(); - } + // Invoke the function an extra time to help detect side-effects. + instance.shouldComponentUpdate(newProps, newState, nextContext); } } + startPhaseTimer(workInProgress, "shouldComponentUpdate"); var shouldUpdate = instance.shouldComponentUpdate( newProps, newState, nextContext ); + stopPhaseTimer(); { if (shouldUpdate === undefined) { @@ -7601,13 +7358,7 @@ function constructClassInstance(workInProgress, ctor, props) { { if (workInProgress.mode & StrictMode) { - disableLogs(); - - try { - new ctor(props, context); // eslint-disable-line no-new - } finally { - reenableLogs(); - } + new ctor(props, context); // eslint-disable-line no-new } } @@ -7718,6 +7469,7 @@ function constructClassInstance(workInProgress, ctor, props) { } function callComponentWillMount(workInProgress, instance) { + startPhaseTimer(workInProgress, "componentWillMount"); var oldState = instance.state; if (typeof instance.componentWillMount === "function") { @@ -7728,6 +7480,8 @@ function callComponentWillMount(workInProgress, instance) { instance.UNSAFE_componentWillMount(); } + stopPhaseTimer(); + if (oldState !== instance.state) { { error( @@ -7749,6 +7503,7 @@ function callComponentWillReceiveProps( nextContext ) { var oldState = instance.state; + startPhaseTimer(workInProgress, "componentWillReceiveProps"); if (typeof instance.componentWillReceiveProps === "function") { instance.componentWillReceiveProps(newProps, nextContext); @@ -7758,6 +7513,8 @@ function callComponentWillReceiveProps( instance.UNSAFE_componentWillReceiveProps(newProps, nextContext); } + stopPhaseTimer(); + if (instance.state !== oldState) { { var componentName = getComponentName(workInProgress.type) || "Component"; @@ -7778,7 +7535,12 @@ function callComponentWillReceiveProps( } } // Invokes the mount life-cycles on a previously never rendered instance. -function mountClassInstance(workInProgress, ctor, newProps, renderLanes) { +function mountClassInstance( + workInProgress, + ctor, + newProps, + renderExpirationTime +) { { checkClassInstance(workInProgress, ctor, newProps); } @@ -7828,7 +7590,7 @@ function mountClassInstance(workInProgress, ctor, newProps, renderLanes) { } } - processUpdateQueue(workInProgress, newProps, instance, renderLanes); + processUpdateQueue(workInProgress, newProps, instance, renderExpirationTime); instance.state = workInProgress.memoizedState; var getDerivedStateFromProps = ctor.getDerivedStateFromProps; @@ -7852,7 +7614,12 @@ function mountClassInstance(workInProgress, ctor, newProps, renderLanes) { callComponentWillMount(workInProgress, instance); // If we had additional state updates during this life-cycle, let's // process them now. - processUpdateQueue(workInProgress, newProps, instance, renderLanes); + processUpdateQueue( + workInProgress, + newProps, + instance, + renderExpirationTime + ); instance.state = workInProgress.memoizedState; } @@ -7861,7 +7628,12 @@ function mountClassInstance(workInProgress, ctor, newProps, renderLanes) { } } -function resumeMountClassInstance(workInProgress, ctor, newProps, renderLanes) { +function resumeMountClassInstance( + workInProgress, + ctor, + newProps, + renderExpirationTime +) { var instance = workInProgress.stateNode; var oldProps = workInProgress.memoizedProps; instance.props = oldProps; @@ -7907,7 +7679,7 @@ function resumeMountClassInstance(workInProgress, ctor, newProps, renderLanes) { resetHasForceUpdateBeforeProcessing(); var oldState = workInProgress.memoizedState; var newState = (instance.state = oldState); - processUpdateQueue(workInProgress, newProps, instance, renderLanes); + processUpdateQueue(workInProgress, newProps, instance, renderExpirationTime); newState = workInProgress.memoizedState; if ( @@ -7955,6 +7727,8 @@ function resumeMountClassInstance(workInProgress, ctor, newProps, renderLanes) { (typeof instance.UNSAFE_componentWillMount === "function" || typeof instance.componentWillMount === "function") ) { + startPhaseTimer(workInProgress, "componentWillMount"); + if (typeof instance.componentWillMount === "function") { instance.componentWillMount(); } @@ -7962,6 +7736,8 @@ function resumeMountClassInstance(workInProgress, ctor, newProps, renderLanes) { if (typeof instance.UNSAFE_componentWillMount === "function") { instance.UNSAFE_componentWillMount(); } + + stopPhaseTimer(); } if (typeof instance.componentDidMount === "function") { @@ -7991,17 +7767,15 @@ function updateClassInstance( workInProgress, ctor, newProps, - renderLanes + renderExpirationTime ) { var instance = workInProgress.stateNode; cloneUpdateQueue(current, workInProgress); - var unresolvedOldProps = workInProgress.memoizedProps; - var oldProps = + var oldProps = workInProgress.memoizedProps; + instance.props = workInProgress.type === workInProgress.elementType - ? unresolvedOldProps - : resolveDefaultProps(workInProgress.type, unresolvedOldProps); - instance.props = oldProps; - var unresolvedNewProps = workInProgress.pendingProps; + ? oldProps + : resolveDefaultProps(workInProgress.type, oldProps); var oldContext = instance.context; var contextType = ctor.contextType; var nextContext = emptyContextObject; @@ -8027,10 +7801,7 @@ function updateClassInstance( (typeof instance.UNSAFE_componentWillReceiveProps === "function" || typeof instance.componentWillReceiveProps === "function") ) { - if ( - unresolvedOldProps !== unresolvedNewProps || - oldContext !== nextContext - ) { + if (oldProps !== newProps || oldContext !== nextContext) { callComponentWillReceiveProps( workInProgress, instance, @@ -8043,11 +7814,11 @@ function updateClassInstance( resetHasForceUpdateBeforeProcessing(); var oldState = workInProgress.memoizedState; var newState = (instance.state = oldState); - processUpdateQueue(workInProgress, newProps, instance, renderLanes); + processUpdateQueue(workInProgress, newProps, instance, renderExpirationTime); newState = workInProgress.memoizedState; if ( - unresolvedOldProps === unresolvedNewProps && + oldProps === newProps && oldState === newState && !hasContextChanged() && !checkHasForceUpdateAfterProcessing() @@ -8056,7 +7827,7 @@ function updateClassInstance( // effect even though we're bailing out, so that cWU/cDU are called. if (typeof instance.componentDidUpdate === "function") { if ( - unresolvedOldProps !== current.memoizedProps || + oldProps !== current.memoizedProps || oldState !== current.memoizedState ) { workInProgress.effectTag |= Update; @@ -8065,7 +7836,7 @@ function updateClassInstance( if (typeof instance.getSnapshotBeforeUpdate === "function") { if ( - unresolvedOldProps !== current.memoizedProps || + oldProps !== current.memoizedProps || oldState !== current.memoizedState ) { workInProgress.effectTag |= Snapshot; @@ -8105,6 +7876,8 @@ function updateClassInstance( (typeof instance.UNSAFE_componentWillUpdate === "function" || typeof instance.componentWillUpdate === "function") ) { + startPhaseTimer(workInProgress, "componentWillUpdate"); + if (typeof instance.componentWillUpdate === "function") { instance.componentWillUpdate(newProps, newState, nextContext); } @@ -8112,6 +7885,8 @@ function updateClassInstance( if (typeof instance.UNSAFE_componentWillUpdate === "function") { instance.UNSAFE_componentWillUpdate(newProps, newState, nextContext); } + + stopPhaseTimer(); } if (typeof instance.componentDidUpdate === "function") { @@ -8126,7 +7901,7 @@ function updateClassInstance( // effect even though we're bailing out, so that cWU/cDU are called. if (typeof instance.componentDidUpdate === "function") { if ( - unresolvedOldProps !== current.memoizedProps || + oldProps !== current.memoizedProps || oldState !== current.memoizedState ) { workInProgress.effectTag |= Update; @@ -8135,7 +7910,7 @@ function updateClassInstance( if (typeof instance.getSnapshotBeforeUpdate === "function") { if ( - unresolvedOldProps !== current.memoizedProps || + oldProps !== current.memoizedProps || oldState !== current.memoizedState ) { workInProgress.effectTag |= Snapshot; @@ -8160,7 +7935,7 @@ var didWarnAboutStringRefs; var ownerHasKeyUseWarning; var ownerHasFunctionTypeWarning; -var warnForMissingKey = function(child, returnFiber) {}; +var warnForMissingKey = function(child) {}; { didWarnAboutMaps = false; @@ -8175,7 +7950,7 @@ var warnForMissingKey = function(child, returnFiber) {}; ownerHasKeyUseWarning = {}; ownerHasFunctionTypeWarning = {}; - warnForMissingKey = function(child, returnFiber) { + warnForMissingKey = function(child) { if (child === null || typeof child !== "object") { return; } @@ -8191,13 +7966,17 @@ var warnForMissingKey = function(child, returnFiber) {}; } child._store.validated = true; - var componentName = getComponentName(returnFiber.type) || "Component"; + var currentComponentErrorInfo = + "Each child in a list should have a unique " + + '"key" prop. See https://fb.me/react-warning-keys for ' + + "more information." + + getCurrentFiberStackInDev(); - if (ownerHasKeyUseWarning[componentName]) { + if (ownerHasKeyUseWarning[currentComponentErrorInfo]) { return; } - ownerHasKeyUseWarning[componentName] = true; + ownerHasKeyUseWarning[currentComponentErrorInfo] = true; error( "Each child in a list should have a unique " + @@ -8239,8 +8018,9 @@ function coerceRef(returnFiber, current, element) { "String refs are a source of potential bugs and should be avoided. " + "We recommend using useRef() or createRef() instead. " + "Learn more about using refs safely here: " + - "https://fb.me/react-strict-mode-string-ref", - mixedRef + "https://fb.me/react-strict-mode-string-ref%s", + mixedRef, + getStackByFiberInDevAndProd(returnFiber) ); } @@ -8323,27 +8103,41 @@ function coerceRef(returnFiber, current, element) { function throwOnInvalidObjectType(returnFiber, newChild) { if (returnFiber.type !== "textarea") { + var addendum = ""; + + { + addendum = + " If you meant to render a collection of children, use an array " + + "instead." + + getCurrentFiberStackInDev(); + } + { throw Error( "Objects are not valid as a React child (found: " + (Object.prototype.toString.call(newChild) === "[object Object]" ? "object with keys {" + Object.keys(newChild).join(", ") + "}" : newChild) + - "). If you meant to render a collection of children, use an array instead." + ")." + + addendum ); } } } -function warnOnFunctionType(returnFiber) { +function warnOnFunctionType() { { - var componentName = getComponentName(returnFiber.type) || "Component"; + var currentComponentErrorInfo = + "Functions are not valid as a React child. This may happen if " + + "you return a Component instead of from render. " + + "Or maybe you meant to call this function rather than return it." + + getCurrentFiberStackInDev(); - if (ownerHasFunctionTypeWarning[componentName]) { + if (ownerHasFunctionTypeWarning[currentComponentErrorInfo]) { return; } - ownerHasFunctionTypeWarning[componentName] = true; + ownerHasFunctionTypeWarning[currentComponentErrorInfo] = true; error( "Functions are not valid as a React child. This may happen if " + @@ -8351,7 +8145,7 @@ function warnOnFunctionType(returnFiber) { "Or maybe you meant to call this function rather than return it." ); } -} // We avoid inlining this to avoid potential deopts from using try/catch. +} // This wrapper function exists because I expect to clone the code in each path // to be able to optimize each path individually by branching early. This needs // a compiler or we can do it manually. Helpers that don't need this branching // live outside of this function. @@ -8464,10 +8258,14 @@ function ChildReconciler(shouldTrackSideEffects) { return newFiber; } - function updateTextNode(returnFiber, current, textContent, lanes) { + function updateTextNode(returnFiber, current, textContent, expirationTime) { if (current === null || current.tag !== HostText) { // Insert - var created = createFiberFromText(textContent, returnFiber.mode, lanes); + var created = createFiberFromText( + textContent, + returnFiber.mode, + expirationTime + ); created.return = returnFiber; return created; } else { @@ -8478,7 +8276,7 @@ function ChildReconciler(shouldTrackSideEffects) { } } - function updateElement(returnFiber, current, element, lanes) { + function updateElement(returnFiber, current, element, expirationTime) { if (current !== null) { if ( current.elementType === element.type || // Keep this check inline so it only runs on the false path: @@ -8498,13 +8296,17 @@ function ChildReconciler(shouldTrackSideEffects) { } } // Insert - var created = createFiberFromElement(element, returnFiber.mode, lanes); + var created = createFiberFromElement( + element, + returnFiber.mode, + expirationTime + ); created.ref = coerceRef(returnFiber, current, element); created.return = returnFiber; return created; } - function updatePortal(returnFiber, current, portal, lanes) { + function updatePortal(returnFiber, current, portal, expirationTime) { if ( current === null || current.tag !== HostPortal || @@ -8512,7 +8314,11 @@ function ChildReconciler(shouldTrackSideEffects) { current.stateNode.implementation !== portal.implementation ) { // Insert - var created = createFiberFromPortal(portal, returnFiber.mode, lanes); + var created = createFiberFromPortal( + portal, + returnFiber.mode, + expirationTime + ); created.return = returnFiber; return created; } else { @@ -8523,13 +8329,13 @@ function ChildReconciler(shouldTrackSideEffects) { } } - function updateFragment(returnFiber, current, fragment, lanes, key) { + function updateFragment(returnFiber, current, fragment, expirationTime, key) { if (current === null || current.tag !== Fragment) { // Insert var created = createFiberFromFragment( fragment, returnFiber.mode, - lanes, + expirationTime, key ); created.return = returnFiber; @@ -8542,12 +8348,16 @@ function ChildReconciler(shouldTrackSideEffects) { } } - function createChild(returnFiber, newChild, lanes) { + function createChild(returnFiber, newChild, expirationTime) { if (typeof newChild === "string" || typeof newChild === "number") { // Text nodes don't have keys. If the previous node is implicitly keyed // we can continue to replace it without aborting even if it is not a text // node. - var created = createFiberFromText("" + newChild, returnFiber.mode, lanes); + var created = createFiberFromText( + "" + newChild, + returnFiber.mode, + expirationTime + ); created.return = returnFiber; return created; } @@ -8558,7 +8368,7 @@ function ChildReconciler(shouldTrackSideEffects) { var _created = createFiberFromElement( newChild, returnFiber.mode, - lanes + expirationTime ); _created.ref = coerceRef(returnFiber, null, newChild); @@ -8570,7 +8380,7 @@ function ChildReconciler(shouldTrackSideEffects) { var _created2 = createFiberFromPortal( newChild, returnFiber.mode, - lanes + expirationTime ); _created2.return = returnFiber; @@ -8582,7 +8392,7 @@ function ChildReconciler(shouldTrackSideEffects) { var _created3 = createFiberFromFragment( newChild, returnFiber.mode, - lanes, + expirationTime, null ); @@ -8595,14 +8405,14 @@ function ChildReconciler(shouldTrackSideEffects) { { if (typeof newChild === "function") { - warnOnFunctionType(returnFiber); + warnOnFunctionType(); } } return null; } - function updateSlot(returnFiber, oldFiber, newChild, lanes) { + function updateSlot(returnFiber, oldFiber, newChild, expirationTime) { // Update the fiber if the keys match, otherwise return null. var key = oldFiber !== null ? oldFiber.key : null; @@ -8614,7 +8424,12 @@ function ChildReconciler(shouldTrackSideEffects) { return null; } - return updateTextNode(returnFiber, oldFiber, "" + newChild, lanes); + return updateTextNode( + returnFiber, + oldFiber, + "" + newChild, + expirationTime + ); } if (typeof newChild === "object" && newChild !== null) { @@ -8626,12 +8441,17 @@ function ChildReconciler(shouldTrackSideEffects) { returnFiber, oldFiber, newChild.props.children, - lanes, + expirationTime, key ); } - return updateElement(returnFiber, oldFiber, newChild, lanes); + return updateElement( + returnFiber, + oldFiber, + newChild, + expirationTime + ); } else { return null; } @@ -8639,7 +8459,12 @@ function ChildReconciler(shouldTrackSideEffects) { case REACT_PORTAL_TYPE: { if (newChild.key === key) { - return updatePortal(returnFiber, oldFiber, newChild, lanes); + return updatePortal( + returnFiber, + oldFiber, + newChild, + expirationTime + ); } else { return null; } @@ -8651,7 +8476,13 @@ function ChildReconciler(shouldTrackSideEffects) { return null; } - return updateFragment(returnFiber, oldFiber, newChild, lanes, null); + return updateFragment( + returnFiber, + oldFiber, + newChild, + expirationTime, + null + ); } throwOnInvalidObjectType(returnFiber, newChild); @@ -8659,7 +8490,7 @@ function ChildReconciler(shouldTrackSideEffects) { { if (typeof newChild === "function") { - warnOnFunctionType(returnFiber); + warnOnFunctionType(); } } @@ -8671,13 +8502,18 @@ function ChildReconciler(shouldTrackSideEffects) { returnFiber, newIdx, newChild, - lanes + expirationTime ) { if (typeof newChild === "string" || typeof newChild === "number") { // Text nodes don't have keys, so we neither have to check the old nor // new node for the key. If both are text nodes, they match. var matchedFiber = existingChildren.get(newIdx) || null; - return updateTextNode(returnFiber, matchedFiber, "" + newChild, lanes); + return updateTextNode( + returnFiber, + matchedFiber, + "" + newChild, + expirationTime + ); } if (typeof newChild === "object" && newChild !== null) { @@ -8693,12 +8529,17 @@ function ChildReconciler(shouldTrackSideEffects) { returnFiber, _matchedFiber, newChild.props.children, - lanes, + expirationTime, newChild.key ); } - return updateElement(returnFiber, _matchedFiber, newChild, lanes); + return updateElement( + returnFiber, + _matchedFiber, + newChild, + expirationTime + ); } case REACT_PORTAL_TYPE: { @@ -8707,7 +8548,12 @@ function ChildReconciler(shouldTrackSideEffects) { newChild.key === null ? newIdx : newChild.key ) || null; - return updatePortal(returnFiber, _matchedFiber2, newChild, lanes); + return updatePortal( + returnFiber, + _matchedFiber2, + newChild, + expirationTime + ); } } @@ -8718,7 +8564,7 @@ function ChildReconciler(shouldTrackSideEffects) { returnFiber, _matchedFiber3, newChild, - lanes, + expirationTime, null ); } @@ -8728,7 +8574,7 @@ function ChildReconciler(shouldTrackSideEffects) { { if (typeof newChild === "function") { - warnOnFunctionType(returnFiber); + warnOnFunctionType(); } } @@ -8738,7 +8584,7 @@ function ChildReconciler(shouldTrackSideEffects) { * Warns if there is a duplicate or missing key */ - function warnOnInvalidKey(child, knownKeys, returnFiber) { + function warnOnInvalidKey(child, knownKeys) { { if (typeof child !== "object" || child === null) { return knownKeys; @@ -8747,7 +8593,7 @@ function ChildReconciler(shouldTrackSideEffects) { switch (child.$$typeof) { case REACT_ELEMENT_TYPE: case REACT_PORTAL_TYPE: - warnForMissingKey(child, returnFiber); + warnForMissingKey(child); var key = child.key; if (typeof key !== "string") { @@ -8785,7 +8631,7 @@ function ChildReconciler(shouldTrackSideEffects) { returnFiber, currentFirstChild, newChildren, - lanes + expirationTime ) { // This algorithm can't optimize by searching from both ends since we // don't have backpointers on fibers. I'm trying to see how far we can get @@ -8808,7 +8654,7 @@ function ChildReconciler(shouldTrackSideEffects) { for (var i = 0; i < newChildren.length; i++) { var child = newChildren[i]; - knownKeys = warnOnInvalidKey(child, knownKeys, returnFiber); + knownKeys = warnOnInvalidKey(child, knownKeys); } } @@ -8831,7 +8677,7 @@ function ChildReconciler(shouldTrackSideEffects) { returnFiber, oldFiber, newChildren[newIdx], - lanes + expirationTime ); if (newFiber === null) { @@ -8881,7 +8727,11 @@ function ChildReconciler(shouldTrackSideEffects) { // If we don't have any more existing children we can choose a fast path // since the rest will all be insertions. for (; newIdx < newChildren.length; newIdx++) { - var _newFiber = createChild(returnFiber, newChildren[newIdx], lanes); + var _newFiber = createChild( + returnFiber, + newChildren[newIdx], + expirationTime + ); if (_newFiber === null) { continue; @@ -8910,7 +8760,7 @@ function ChildReconciler(shouldTrackSideEffects) { returnFiber, newIdx, newChildren[newIdx], - lanes + expirationTime ); if (_newFiber2 !== null) { @@ -8953,7 +8803,7 @@ function ChildReconciler(shouldTrackSideEffects) { returnFiber, currentFirstChild, newChildrenIterable, - lanes + expirationTime ) { // This is the same implementation as reconcileChildrenArray(), // but using the iterator instead. @@ -8988,8 +8838,9 @@ function ChildReconciler(shouldTrackSideEffects) { if (newChildrenIterable.entries === iteratorFn) { if (!didWarnAboutMaps) { error( - "Using Maps as children is not supported. " + - "Use an array of keyed ReactElements instead." + "Using Maps as children is unsupported and will likely yield " + + "unexpected results. Convert it to a sequence/iterable of keyed " + + "ReactElements instead." ); } @@ -9006,7 +8857,7 @@ function ChildReconciler(shouldTrackSideEffects) { for (; !_step.done; _step = _newChildren.next()) { var child = _step.value; - knownKeys = warnOnInvalidKey(child, knownKeys, returnFiber); + knownKeys = warnOnInvalidKey(child, knownKeys); } } } @@ -9037,7 +8888,12 @@ function ChildReconciler(shouldTrackSideEffects) { nextOldFiber = oldFiber.sibling; } - var newFiber = updateSlot(returnFiber, oldFiber, step.value, lanes); + var newFiber = updateSlot( + returnFiber, + oldFiber, + step.value, + expirationTime + ); if (newFiber === null) { // TODO: This breaks on empty slots like null children. That's @@ -9086,7 +8942,7 @@ function ChildReconciler(shouldTrackSideEffects) { // If we don't have any more existing children we can choose a fast path // since the rest will all be insertions. for (; !step.done; newIdx++, step = newChildren.next()) { - var _newFiber3 = createChild(returnFiber, step.value, lanes); + var _newFiber3 = createChild(returnFiber, step.value, expirationTime); if (_newFiber3 === null) { continue; @@ -9115,7 +8971,7 @@ function ChildReconciler(shouldTrackSideEffects) { returnFiber, newIdx, step.value, - lanes + expirationTime ); if (_newFiber4 !== null) { @@ -9158,7 +9014,7 @@ function ChildReconciler(shouldTrackSideEffects) { returnFiber, currentFirstChild, textContent, - lanes + expirationTime ) { // There's no need to check for keys on text nodes since we don't have a // way to define them. @@ -9173,7 +9029,11 @@ function ChildReconciler(shouldTrackSideEffects) { // and delete the existing ones. deleteRemainingChildren(returnFiber, currentFirstChild); - var created = createFiberFromText(textContent, returnFiber.mode, lanes); + var created = createFiberFromText( + textContent, + returnFiber.mode, + expirationTime + ); created.return = returnFiber; return created; } @@ -9182,7 +9042,7 @@ function ChildReconciler(shouldTrackSideEffects) { returnFiber, currentFirstChild, element, - lanes + expirationTime ) { var key = element.key; var child = currentFirstChild; @@ -9251,13 +9111,17 @@ function ChildReconciler(shouldTrackSideEffects) { var created = createFiberFromFragment( element.props.children, returnFiber.mode, - lanes, + expirationTime, element.key ); created.return = returnFiber; return created; } else { - var _created4 = createFiberFromElement(element, returnFiber.mode, lanes); + var _created4 = createFiberFromElement( + element, + returnFiber.mode, + expirationTime + ); _created4.ref = coerceRef(returnFiber, currentFirstChild, element); _created4.return = returnFiber; @@ -9269,7 +9133,7 @@ function ChildReconciler(shouldTrackSideEffects) { returnFiber, currentFirstChild, portal, - lanes + expirationTime ) { var key = portal.key; var child = currentFirstChild; @@ -9298,7 +9162,11 @@ function ChildReconciler(shouldTrackSideEffects) { child = child.sibling; } - var created = createFiberFromPortal(portal, returnFiber.mode, lanes); + var created = createFiberFromPortal( + portal, + returnFiber.mode, + expirationTime + ); created.return = returnFiber; return created; } // This API will tag the children with the side-effect of the reconciliation @@ -9309,7 +9177,7 @@ function ChildReconciler(shouldTrackSideEffects) { returnFiber, currentFirstChild, newChild, - lanes + expirationTime ) { // This function is not recursive. // If the top level item is an array, we treat it as a set of children, @@ -9338,7 +9206,7 @@ function ChildReconciler(shouldTrackSideEffects) { returnFiber, currentFirstChild, newChild, - lanes + expirationTime ) ); @@ -9348,7 +9216,7 @@ function ChildReconciler(shouldTrackSideEffects) { returnFiber, currentFirstChild, newChild, - lanes + expirationTime ) ); } @@ -9360,7 +9228,7 @@ function ChildReconciler(shouldTrackSideEffects) { returnFiber, currentFirstChild, "" + newChild, - lanes + expirationTime ) ); } @@ -9370,7 +9238,7 @@ function ChildReconciler(shouldTrackSideEffects) { returnFiber, currentFirstChild, newChild, - lanes + expirationTime ); } @@ -9379,7 +9247,7 @@ function ChildReconciler(shouldTrackSideEffects) { returnFiber, currentFirstChild, newChild, - lanes + expirationTime ); } @@ -9389,7 +9257,7 @@ function ChildReconciler(shouldTrackSideEffects) { { if (typeof newChild === "function") { - warnOnFunctionType(returnFiber); + warnOnFunctionType(); } } @@ -9459,11 +9327,11 @@ function cloneChildFibers(current, workInProgress) { newChild.sibling = null; } // Reset a workInProgress child set to prepare it for a second pass. -function resetChildFibers(workInProgress, lanes) { +function resetChildFibers(workInProgress, renderExpirationTime) { var child = workInProgress.child; while (child !== null) { - resetWorkInProgress(child, lanes); + resetWorkInProgress(child, renderExpirationTime); child = child.sibling; } } @@ -9581,13 +9449,6 @@ function popSuspenseContext(fiber) { pop(suspenseStackCursor, fiber); } -// A non-null SuspenseState means that it is blocked for one reason or another. -// - A non-null dehydrated field means it's blocked pending hydration. -// - A non-null dehydrated field can use isSuspenseInstancePending or -// isSuspenseInstanceFallback to query the reason for being dehydrated. -// - A null dehydrated field means it's blocked by something suspending and -// we're currently showing a fallback instead. - function shouldCaptureSuspense(workInProgress, hasInvisibleParent) { // If it was the primary children that just suspended, capture and render the // fallback. Otherwise, don't capture and bubble to the next boundary. @@ -9685,10 +9546,6 @@ function createDeprecatedResponderListener(responder, props) { return eventResponderListener; } -var NoEffect$1 = - /* */ - 0; // Represents whether effect should fire. - var HasEffect = /* */ 1; // Represents the phase in which the effect (not the clean-up) fires. @@ -9700,113 +9557,16 @@ var Passive$1 = /* */ 4; -var isHydrating = false; - -function enterHydrationState(fiber) { - { - return false; - } -} - -function prepareToHydrateHostInstance( - fiber, - rootContainerInstance, - hostContext -) { - { - { - throw Error( - "Expected prepareToHydrateHostInstance() to never be called. This error is likely caused by a bug in React. Please file an issue." - ); - } - } -} - -function prepareToHydrateHostTextInstance(fiber) { - { - { - throw Error( - "Expected prepareToHydrateHostTextInstance() to never be called. This error is likely caused by a bug in React. Please file an issue." - ); - } - } - var shouldUpdate = hydrateTextInstance(); -} - -function popHydrationState(fiber) { - { - return false; - } -} - -function getIsHydrating() { - return isHydrating; -} - -// and should be reset before starting a new render. -// This tracks which mutable sources need to be reset after a render. - -var workInProgressSources = []; -var rendererSigil$1; - -{ - // Used to detect multiple renderers using the same mutable source. - rendererSigil$1 = {}; -} - -function markSourceAsDirty(mutableSource) { - workInProgressSources.push(mutableSource); -} -function resetWorkInProgressVersions() { - for (var i = 0; i < workInProgressSources.length; i++) { - var mutableSource = workInProgressSources[i]; - - { - mutableSource._workInProgressVersionSecondary = null; - } - } - - workInProgressSources.length = 0; -} -function getWorkInProgressVersion(mutableSource) { - { - return mutableSource._workInProgressVersionSecondary; - } -} -function setWorkInProgressVersion(mutableSource, version) { - { - mutableSource._workInProgressVersionSecondary = version; - } - - workInProgressSources.push(mutableSource); -} -function warnAboutMultipleRenderersDEV(mutableSource) { - { - { - if (mutableSource._currentSecondaryRenderer == null) { - mutableSource._currentSecondaryRenderer = rendererSigil$1; - } else if (mutableSource._currentSecondaryRenderer !== rendererSigil$1) { - error( - "Detected multiple renderers concurrently rendering the " + - "same mutable source. This is currently unsupported." - ); - } - } - } -} // Eager reads the version of a mutable source and stores it on the root. - -var ReactCurrentDispatcher$1 = ReactSharedInternals.ReactCurrentDispatcher, +var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher, ReactCurrentBatchConfig$1 = ReactSharedInternals.ReactCurrentBatchConfig; var didWarnAboutMismatchedHooksForComponent; -var didWarnAboutUseOpaqueIdentifier; { - didWarnAboutUseOpaqueIdentifier = {}; didWarnAboutMismatchedHooksForComponent = new Set(); } // These are set right before calling the component. -var renderLanes = NoLanes; // The work-in-progress fiber. I've named it differently to distinguish it from +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 @@ -9820,12 +9580,7 @@ var workInProgressHook = null; // Whether an update was scheduled at any point d // finished evaluating this component. This is an optimization so we know // whether we need to clear render phase updates after a throw. -var didScheduleRenderPhaseUpdate = false; // Where an update was scheduled only during the current render pass. This -// gets reset after each attempt. -// TODO: Maybe there's some way to consolidate this with -// `didScheduleRenderPhaseUpdate`. Or with `numberOfReRenders`. - -var didScheduleRenderPhaseUpdateDuringThisPass = false; +var didScheduleRenderPhaseUpdate = false; var RE_RENDER_LIMIT = 25; // In DEV, this is the name of the currently executing primitive hook var currentHookNameInDev = null; // In DEV, this list ensures that hooks are called in the same order between renders. @@ -9984,9 +9739,9 @@ function renderWithHooks( Component, props, secondArg, - nextRenderLanes + nextRenderExpirationTime ) { - renderLanes = nextRenderLanes; + renderExpirationTime = nextRenderExpirationTime; currentlyRenderingFiber$1 = workInProgress; { @@ -9999,7 +9754,7 @@ function renderWithHooks( workInProgress.memoizedState = null; workInProgress.updateQueue = null; - workInProgress.lanes = NoLanes; // The following should have already been reset + workInProgress.expirationTime = NoWork; // The following should have already been reset // currentHook = null; // workInProgressHook = null; // didScheduleRenderPhaseUpdate = false; @@ -10012,28 +9767,28 @@ function renderWithHooks( { if (current !== null && current.memoizedState !== null) { - ReactCurrentDispatcher$1.current = HooksDispatcherOnUpdateInDEV; + ReactCurrentDispatcher.current = HooksDispatcherOnUpdateInDEV; } else if (hookTypesDev !== null) { // This dispatcher handles an edge case where a component is updating, // but no stateful hooks have been used. // We want to match the production code behavior (which will use HooksDispatcherOnMount), // but with the extra DEV validation to ensure hooks ordering hasn't changed. // This dispatcher does that. - ReactCurrentDispatcher$1.current = HooksDispatcherOnMountWithHookTypesInDEV; + ReactCurrentDispatcher.current = HooksDispatcherOnMountWithHookTypesInDEV; } else { - ReactCurrentDispatcher$1.current = HooksDispatcherOnMountInDEV; + ReactCurrentDispatcher.current = HooksDispatcherOnMountInDEV; } } var children = Component(props, secondArg); // Check if there was a render phase update - if (didScheduleRenderPhaseUpdateDuringThisPass) { + if (workInProgress.expirationTime === renderExpirationTime) { // Keep rendering in a loop for as long as render phase updates continue to // be scheduled. Use a counter to prevent infinite loops. var numberOfReRenders = 0; do { - didScheduleRenderPhaseUpdateDuringThisPass = false; + workInProgress.expirationTime = NoWork; if (!(numberOfReRenders < RE_RENDER_LIMIT)) { throw Error( @@ -10058,13 +9813,13 @@ function renderWithHooks( hookTypesUpdateIndexDev = -1; } - ReactCurrentDispatcher$1.current = HooksDispatcherOnRerenderInDEV; + ReactCurrentDispatcher.current = HooksDispatcherOnRerenderInDEV; children = Component(props, secondArg); - } while (didScheduleRenderPhaseUpdateDuringThisPass); + } while (workInProgress.expirationTime === renderExpirationTime); } // We can assume the previous dispatcher is always this one, since we set it // at the beginning of the render phase and there's no re-entrancy. - ReactCurrentDispatcher$1.current = ContextOnlyDispatcher; + ReactCurrentDispatcher.current = ContextOnlyDispatcher; { workInProgress._debugHookTypes = hookTypesDev; @@ -10072,7 +9827,7 @@ function renderWithHooks( // hookTypesDev could catch more cases (e.g. context) but only in DEV bundles. var didRenderTooFewHooks = currentHook !== null && currentHook.next !== null; - renderLanes = NoLanes; + renderExpirationTime = NoWork; currentlyRenderingFiber$1 = null; currentHook = null; workInProgressHook = null; @@ -10093,15 +9848,18 @@ function renderWithHooks( return children; } -function bailoutHooks(current, workInProgress, lanes) { +function bailoutHooks(current, workInProgress, expirationTime) { workInProgress.updateQueue = current.updateQueue; workInProgress.effectTag &= ~(Passive | Update); - current.lanes = removeLanes(current.lanes, lanes); + + if (current.expirationTime <= expirationTime) { + current.expirationTime = NoWork; + } } function resetHooksAfterThrow() { // We can assume the previous dispatcher is always this one, since we set it // at the beginning of the render phase and there's no re-entrancy. - ReactCurrentDispatcher$1.current = ContextOnlyDispatcher; + ReactCurrentDispatcher.current = ContextOnlyDispatcher; if (didScheduleRenderPhaseUpdate) { // There were render phase updates. These are only valid for this render @@ -10123,11 +9881,9 @@ function resetHooksAfterThrow() { hook = hook.next; } - - didScheduleRenderPhaseUpdate = false; } - renderLanes = NoLanes; + renderExpirationTime = NoWork; currentlyRenderingFiber$1 = null; currentHook = null; workInProgressHook = null; @@ -10136,10 +9892,9 @@ function resetHooksAfterThrow() { hookTypesDev = null; hookTypesUpdateIndexDev = -1; currentHookNameInDev = null; - isUpdatingOpaqueValueInRenderPhase = false; } - didScheduleRenderPhaseUpdateDuringThisPass = false; + didScheduleRenderPhaseUpdate = false; } function mountWorkInProgressHook() { @@ -10286,17 +10041,6 @@ function updateReducer(reducer, initialArg, init) { pendingQueue.next = baseFirst; } - { - if (current.baseQueue !== baseQueue) { - // Internal invariant that should never happen, but feasibly could in - // the future if we implement resuming, or some form of that. - error( - "Internal error: Expected work-in-progress queue to be a clone. " + - "This is a bug in React." - ); - } - } - current.baseQueue = baseQueue = pendingQueue; queue.pending = null; } @@ -10311,18 +10055,15 @@ function updateReducer(reducer, initialArg, init) { var update = first; do { - var suspenseConfig = update.suspenseConfig; - var updateLane = update.lane; - var updateEventTime = update.eventTime; + var updateExpirationTime = update.expirationTime; - if (!isSubsetOfLanes(renderLanes, updateLane)) { + 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. var clone = { - eventTime: updateEventTime, - lane: updateLane, - suspenseConfig: suspenseConfig, + expirationTime: update.expirationTime, + suspenseConfig: update.suspenseConfig, action: update.action, eagerReducer: update.eagerReducer, eagerState: update.eagerState, @@ -10335,23 +10076,17 @@ function updateReducer(reducer, initialArg, init) { } else { newBaseQueueLast = newBaseQueueLast.next = clone; } // Update the remaining priority in the queue. - // TODO: Don't need to accumulate this. Instead, we can remove - // renderLanes from the original lanes. - currentlyRenderingFiber$1.lanes = mergeLanes( - currentlyRenderingFiber$1.lanes, - updateLane - ); - markSkippedUpdateLanes(updateLane); + if (updateExpirationTime > currentlyRenderingFiber$1.expirationTime) { + currentlyRenderingFiber$1.expirationTime = updateExpirationTime; + markUnprocessedUpdateTime(updateExpirationTime); + } } else { // This update does have sufficient priority. if (newBaseQueueLast !== null) { var _clone = { - eventTime: updateEventTime, - // This update is going to be committed so we never want uncommit - // it. Using NoLane works because 0 is a subset of all bitmasks, so - // this will never be skipped by the check above. - lane: NoLane, + expirationTime: Sync, + // This update is going to be committed so we never want uncommit it. suspenseConfig: update.suspenseConfig, action: update.action, eagerReducer: update.eagerReducer, @@ -10361,12 +10096,15 @@ function updateReducer(reducer, initialArg, init) { newBaseQueueLast = newBaseQueueLast.next = _clone; } // Mark the event time of this update as relevant to this render pass. // TODO: This should ideally use the true event time of this update rather than - // its priority which is a derived and not reversible value. + // its priority which is a derived and not reverseable value. // TODO: We should skip this update if it was already committed but currently // we have no way of detecting the difference between a committed and suspended // update here. - markRenderEventTimeAndConfig(updateEventTime, suspenseConfig); // Process this update. + markRenderEventTimeAndConfig( + updateExpirationTime, + update.suspenseConfig + ); // Process this update. if (update.eagerReducer === reducer) { // If this update was processed eagerly, and its reducer matches the @@ -10454,253 +10192,6 @@ function rerenderReducer(reducer, initialArg, init) { return [newState, dispatch]; } -function readFromUnsubcribedMutableSource(root, source, getSnapshot) { - { - warnAboutMultipleRenderersDEV(source); - } - - var getVersion = source._getVersion; - var version = getVersion(source._source); // Is it safe for this component to read from this source during the current render? - - var isSafeToReadFromSource = false; // Check the version first. - // If this render has already been started with a specific version, - // we can use it alone to determine if we can safely read from the source. - - var currentRenderVersion = getWorkInProgressVersion(source); - - if (currentRenderVersion !== null) { - // It's safe to read if the store hasn't been mutated since the last time - // we read something. - isSafeToReadFromSource = currentRenderVersion === version; - } else { - // If there's no version, then this is the first time we've read from the - // source during the current render pass, so we need to do a bit more work. - // What we need to determine is if there are any hooks that already - // subscribed to the source, and if so, whether there are any pending - // mutations that haven't been synchronized yet. - // - // If there are no pending mutations, then `root.mutableReadLanes` will be - // empty, and we know we can safely read. - // - // If there *are* pending mutations, we may still be able to safely read - // if the currently rendering lanes are inclusive of the pending mutation - // lanes, since that guarantees that the value we're about to read from - // the source is consistent with the values that we read during the most - // recent mutation. - isSafeToReadFromSource = isSubsetOfLanes( - renderLanes, - root.mutableReadLanes - ); - - if (isSafeToReadFromSource) { - // If it's safe to read from this source during the current render, - // store the version in case other components read from it. - // A changed version number will let those components know to throw and restart the render. - setWorkInProgressVersion(source, version); - } - } - - if (isSafeToReadFromSource) { - var snapshot = getSnapshot(source._source); - - { - if (typeof snapshot === "function") { - error( - "Mutable source should not return a function as the snapshot value. " + - "Functions may close over mutable values and cause tearing." - ); - } - } - - return snapshot; - } else { - // This handles the special case of a mutable source being shared between renderers. - // In that case, if the source is mutated between the first and second renderer, - // The second renderer don't know that it needs to reset the WIP version during unwind, - // (because the hook only marks sources as dirty if it's written to their WIP version). - // That would cause this tear check to throw again and eventually be visible to the user. - // We can avoid this infinite loop by explicitly marking the source as dirty. - // - // This can lead to tearing in the first renderer when it resumes, - // but there's nothing we can do about that (short of throwing here and refusing to continue the render). - markSourceAsDirty(source); - - { - throw Error( - "Cannot read from mutable source during the current render without tearing. This is a bug in React. Please file an issue." - ); - } - } -} - -function useMutableSource(hook, source, getSnapshot, subscribe) { - var root = getWorkInProgressRoot(); - - if (!(root !== null)) { - throw Error( - "Expected a work-in-progress root. This is a bug in React. Please file an issue." - ); - } - - var getVersion = source._getVersion; - var version = getVersion(source._source); - var dispatcher = ReactCurrentDispatcher$1.current; // eslint-disable-next-line prefer-const - - var _dispatcher$useState = dispatcher.useState(function() { - return readFromUnsubcribedMutableSource(root, source, getSnapshot); - }), - currentSnapshot = _dispatcher$useState[0], - setSnapshot = _dispatcher$useState[1]; - - var snapshot = currentSnapshot; // Grab a handle to the state hook as well. - // We use it to clear the pending update queue if we have a new source. - - var stateHook = workInProgressHook; - var memoizedState = hook.memoizedState; - var refs = memoizedState.refs; - var prevGetSnapshot = refs.getSnapshot; - var prevSource = memoizedState.source; - var prevSubscribe = memoizedState.subscribe; - var fiber = currentlyRenderingFiber$1; - hook.memoizedState = { - refs: refs, - source: source, - subscribe: subscribe - }; // Sync the values needed by our subscription handler after each commit. - - dispatcher.useEffect( - function() { - refs.getSnapshot = getSnapshot; // Normally the dispatch function for a state hook never changes, - // but this hook recreates the queue in certain cases to avoid updates from stale sources. - // handleChange() below needs to reference the dispatch function without re-subscribing, - // so we use a ref to ensure that it always has the latest version. - - refs.setSnapshot = setSnapshot; // Check for a possible change between when we last rendered now. - - var maybeNewVersion = getVersion(source._source); - - if (!objectIs(version, maybeNewVersion)) { - var maybeNewSnapshot = getSnapshot(source._source); - - { - if (typeof maybeNewSnapshot === "function") { - error( - "Mutable source should not return a function as the snapshot value. " + - "Functions may close over mutable values and cause tearing." - ); - } - } - - if (!objectIs(snapshot, maybeNewSnapshot)) { - setSnapshot(maybeNewSnapshot); - var suspenseConfig = requestCurrentSuspenseConfig(); - var lane = requestUpdateLane(fiber, suspenseConfig); - markRootMutableRead(root, lane); - } // If the source mutated between render and now, - // there may be state updates already scheduled from the old source. - // Entangle the updates so that they render in the same batch. - - markRootEntangled(root, root.mutableReadLanes); - } - }, - [getSnapshot, source, subscribe] - ); // If we got a new source or subscribe function, re-subscribe in a passive effect. - - dispatcher.useEffect( - function() { - var handleChange = function() { - var latestGetSnapshot = refs.getSnapshot; - var latestSetSnapshot = refs.setSnapshot; - - try { - latestSetSnapshot(latestGetSnapshot(source._source)); // Record a pending mutable source update with the same expiration time. - - var suspenseConfig = requestCurrentSuspenseConfig(); - var lane = requestUpdateLane(fiber, suspenseConfig); - markRootMutableRead(root, lane); - } catch (error) { - // A selector might throw after a source mutation. - // e.g. it might try to read from a part of the store that no longer exists. - // In this case we should still schedule an update with React. - // Worst case the selector will throw again and then an error boundary will handle it. - latestSetSnapshot(function() { - throw error; - }); - } - }; - - var unsubscribe = subscribe(source._source, handleChange); - - { - if (typeof unsubscribe !== "function") { - error( - "Mutable source subscribe function must return an unsubscribe function." - ); - } - } - - return unsubscribe; - }, - [source, subscribe] - ); // If any of the inputs to useMutableSource change, reading is potentially unsafe. - // - // If either the source or the subscription have changed we can't can't trust the update queue. - // Maybe the source changed in a way that the old subscription ignored but the new one depends on. - // - // If the getSnapshot function changed, we also shouldn't rely on the update queue. - // It's possible that the underlying source was mutated between the when the last "change" event fired, - // and when the current render (with the new getSnapshot function) is processed. - // - // In both cases, we need to throw away pending updates (since they are no longer relevant) - // and treat reading from the source as we do in the mount case. - - if ( - !objectIs(prevGetSnapshot, getSnapshot) || - !objectIs(prevSource, source) || - !objectIs(prevSubscribe, subscribe) - ) { - // Create a new queue and setState method, - // So if there are interleaved updates, they get pushed to the older queue. - // When this becomes current, the previous queue and dispatch method will be discarded, - // including any interleaving updates that occur. - var newQueue = { - pending: null, - dispatch: null, - lastRenderedReducer: basicStateReducer, - lastRenderedState: snapshot - }; - newQueue.dispatch = setSnapshot = dispatchAction.bind( - null, - currentlyRenderingFiber$1, - newQueue - ); - stateHook.queue = newQueue; - stateHook.baseQueue = null; - snapshot = readFromUnsubcribedMutableSource(root, source, getSnapshot); - stateHook.memoizedState = stateHook.baseState = snapshot; - } - - return snapshot; -} - -function mountMutableSource(source, getSnapshot, subscribe) { - var hook = mountWorkInProgressHook(); - hook.memoizedState = { - refs: { - getSnapshot: getSnapshot, - setSnapshot: null - }, - source: source, - subscribe: subscribe - }; - return useMutableSource(hook, source, getSnapshot, subscribe); -} - -function updateMutableSource(source, getSnapshot, subscribe) { - var hook = updateWorkInProgressHook(); - return useMutableSource(hook, source, getSnapshot, subscribe); -} - function mountState(initialState) { var hook = mountWorkInProgressHook(); @@ -11041,15 +10532,13 @@ function rerenderDeferredValue(value, config) { function startTransition(setPending, config, callback) { var priorityLevel = getCurrentPriorityLevel(); runWithPriority( - priorityLevel < UserBlockingPriority$1 - ? UserBlockingPriority$1 - : priorityLevel, + priorityLevel < UserBlockingPriority ? UserBlockingPriority : priorityLevel, function() { setPending(true); } - ); // If there's no SuspenseConfig set, we'll use the DefaultLanePriority for this transition. + ); runWithPriority( - priorityLevel > NormalPriority$1 ? NormalPriority$1 : priorityLevel, + priorityLevel > NormalPriority ? NormalPriority : priorityLevel, function() { var previousConfig = ReactCurrentBatchConfig$1.suspense; ReactCurrentBatchConfig$1.suspense = config === undefined ? null : config; @@ -11100,54 +10589,6 @@ function rerenderTransition(config) { return [start, isPending]; } -var isUpdatingOpaqueValueInRenderPhase = false; -function getIsUpdatingOpaqueValueInRenderPhaseInDEV() { - { - return isUpdatingOpaqueValueInRenderPhase; - } -} - -function warnOnOpaqueIdentifierAccessInDEV(fiber) { - { - // TODO: Should warn in effects and callbacks, too - var name = getComponentName(fiber.type) || "Unknown"; - - if (getIsRendering() && !didWarnAboutUseOpaqueIdentifier[name]) { - error( - "The object passed back from useOpaqueIdentifier is meant to be " + - "passed through to attributes only. Do not read the " + - "value directly." - ); - - didWarnAboutUseOpaqueIdentifier[name] = true; - } - } -} - -function mountOpaqueIdentifier() { - var makeId = makeClientIdInDEV.bind( - null, - warnOnOpaqueIdentifierAccessInDEV.bind(null, currentlyRenderingFiber$1) - ); - - { - var _id = makeId(); - - mountState(_id); - return _id; - } -} - -function updateOpaqueIdentifier() { - var id = updateState()[0]; - return id; -} - -function rerenderOpaqueIdentifier() { - var id = rerenderState()[0]; - return id; -} - function dispatchAction(fiber, queue, action) { { if (typeof arguments[3] === "function") { @@ -11159,18 +10600,25 @@ function dispatchAction(fiber, queue, action) { } } - var eventTime = requestEventTime(); + var currentTime = requestCurrentTimeForUpdate(); var suspenseConfig = requestCurrentSuspenseConfig(); - var lane = requestUpdateLane(fiber, suspenseConfig); + var expirationTime = computeExpirationForFiber( + currentTime, + fiber, + suspenseConfig + ); var update = { - eventTime: eventTime, - lane: lane, + expirationTime: expirationTime, suspenseConfig: suspenseConfig, action: action, eagerReducer: null, eagerState: null, next: null - }; // Append the update to the end of the list. + }; + + { + update.priority = getCurrentPriorityLevel(); + } // Append the update to the end of the list. var pending = queue.pending; @@ -11192,11 +10640,13 @@ function dispatchAction(fiber, queue, action) { // 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. - didScheduleRenderPhaseUpdateDuringThisPass = didScheduleRenderPhaseUpdate = true; + didScheduleRenderPhaseUpdate = true; + update.expirationTime = renderExpirationTime; + currentlyRenderingFiber$1.expirationTime = renderExpirationTime; } else { if ( - fiber.lanes === NoLanes && - (alternate === null || alternate.lanes === NoLanes) + fiber.expirationTime === NoWork && + (alternate === null || alternate.expirationTime === NoWork) ) { // The queue is currently empty, which means we can eagerly compute the // next state before entering the render phase. If the new state is the @@ -11207,8 +10657,8 @@ function dispatchAction(fiber, queue, action) { var prevDispatcher; { - prevDispatcher = ReactCurrentDispatcher$1.current; - ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV; + prevDispatcher = ReactCurrentDispatcher.current; + ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnUpdateInDEV; } try { @@ -11232,16 +10682,24 @@ function dispatchAction(fiber, queue, action) { // Suppress the error. It will throw again in the render phase. } finally { { - ReactCurrentDispatcher$1.current = prevDispatcher; + ReactCurrentDispatcher.current = prevDispatcher; } } } } - scheduleUpdateOnFiber(fiber, lane, eventTime); + scheduleWork(fiber, expirationTime); } } +function mountEventListener(event) { + return undefined; +} + +function updateEventListener(event) { + return undefined; +} + var ContextOnlyDispatcher = { readContext: readContext, useCallback: throwInvalidHookError, @@ -11257,9 +10715,7 @@ var ContextOnlyDispatcher = { useResponder: throwInvalidHookError, useDeferredValue: throwInvalidHookError, useTransition: throwInvalidHookError, - useMutableSource: throwInvalidHookError, - useOpaqueIdentifier: throwInvalidHookError, - unstable_isNewReconciler: enableNewReconciler + useEvent: throwInvalidHookError }; var HooksDispatcherOnMountInDEV = null; var HooksDispatcherOnMountWithHookTypesInDEV = null; @@ -11325,25 +10781,25 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; currentHookNameInDev = "useMemo"; mountHookTypesDev(); checkDepsAreArrayDev(deps); - var prevDispatcher = ReactCurrentDispatcher$1.current; - ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV; + var prevDispatcher = ReactCurrentDispatcher.current; + ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnMountInDEV; try { return mountMemo(create, deps); } finally { - ReactCurrentDispatcher$1.current = prevDispatcher; + ReactCurrentDispatcher.current = prevDispatcher; } }, useReducer: function(reducer, initialArg, init) { currentHookNameInDev = "useReducer"; mountHookTypesDev(); - var prevDispatcher = ReactCurrentDispatcher$1.current; - ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV; + var prevDispatcher = ReactCurrentDispatcher.current; + ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnMountInDEV; try { return mountReducer(reducer, initialArg, init); } finally { - ReactCurrentDispatcher$1.current = prevDispatcher; + ReactCurrentDispatcher.current = prevDispatcher; } }, useRef: function(initialValue) { @@ -11354,13 +10810,13 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; useState: function(initialState) { currentHookNameInDev = "useState"; mountHookTypesDev(); - var prevDispatcher = ReactCurrentDispatcher$1.current; - ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV; + var prevDispatcher = ReactCurrentDispatcher.current; + ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnMountInDEV; try { return mountState(initialState); } finally { - ReactCurrentDispatcher$1.current = prevDispatcher; + ReactCurrentDispatcher.current = prevDispatcher; } }, useDebugValue: function(value, formatterFn) { @@ -11383,17 +10839,11 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; mountHookTypesDev(); return mountTransition(config); }, - useMutableSource: function(source, getSnapshot, subscribe) { - currentHookNameInDev = "useMutableSource"; + useEvent: function(event) { + currentHookNameInDev = "useEvent"; mountHookTypesDev(); - return mountMutableSource(source, getSnapshot, subscribe); - }, - useOpaqueIdentifier: function() { - currentHookNameInDev = "useOpaqueIdentifier"; - mountHookTypesDev(); - return mountOpaqueIdentifier(); - }, - unstable_isNewReconciler: enableNewReconciler + return mountEventListener(); + } }; HooksDispatcherOnMountWithHookTypesInDEV = { readContext: function(context, observedBits) { @@ -11427,25 +10877,25 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; useMemo: function(create, deps) { currentHookNameInDev = "useMemo"; updateHookTypesDev(); - var prevDispatcher = ReactCurrentDispatcher$1.current; - ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV; + var prevDispatcher = ReactCurrentDispatcher.current; + ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnMountInDEV; try { return mountMemo(create, deps); } finally { - ReactCurrentDispatcher$1.current = prevDispatcher; + ReactCurrentDispatcher.current = prevDispatcher; } }, useReducer: function(reducer, initialArg, init) { currentHookNameInDev = "useReducer"; updateHookTypesDev(); - var prevDispatcher = ReactCurrentDispatcher$1.current; - ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV; + var prevDispatcher = ReactCurrentDispatcher.current; + ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnMountInDEV; try { return mountReducer(reducer, initialArg, init); } finally { - ReactCurrentDispatcher$1.current = prevDispatcher; + ReactCurrentDispatcher.current = prevDispatcher; } }, useRef: function(initialValue) { @@ -11456,13 +10906,13 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; useState: function(initialState) { currentHookNameInDev = "useState"; updateHookTypesDev(); - var prevDispatcher = ReactCurrentDispatcher$1.current; - ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV; + var prevDispatcher = ReactCurrentDispatcher.current; + ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnMountInDEV; try { return mountState(initialState); } finally { - ReactCurrentDispatcher$1.current = prevDispatcher; + ReactCurrentDispatcher.current = prevDispatcher; } }, useDebugValue: function(value, formatterFn) { @@ -11485,17 +10935,11 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; updateHookTypesDev(); return mountTransition(config); }, - useMutableSource: function(source, getSnapshot, subscribe) { - currentHookNameInDev = "useMutableSource"; + useEvent: function(event) { + currentHookNameInDev = "useEvent"; updateHookTypesDev(); - return mountMutableSource(source, getSnapshot, subscribe); - }, - useOpaqueIdentifier: function() { - currentHookNameInDev = "useOpaqueIdentifier"; - updateHookTypesDev(); - return mountOpaqueIdentifier(); - }, - unstable_isNewReconciler: enableNewReconciler + return mountEventListener(); + } }; HooksDispatcherOnUpdateInDEV = { readContext: function(context, observedBits) { @@ -11529,25 +10973,25 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; useMemo: function(create, deps) { currentHookNameInDev = "useMemo"; updateHookTypesDev(); - var prevDispatcher = ReactCurrentDispatcher$1.current; - ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV; + var prevDispatcher = ReactCurrentDispatcher.current; + ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnUpdateInDEV; try { return updateMemo(create, deps); } finally { - ReactCurrentDispatcher$1.current = prevDispatcher; + ReactCurrentDispatcher.current = prevDispatcher; } }, useReducer: function(reducer, initialArg, init) { currentHookNameInDev = "useReducer"; updateHookTypesDev(); - var prevDispatcher = ReactCurrentDispatcher$1.current; - ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV; + var prevDispatcher = ReactCurrentDispatcher.current; + ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnUpdateInDEV; try { return updateReducer(reducer, initialArg, init); } finally { - ReactCurrentDispatcher$1.current = prevDispatcher; + ReactCurrentDispatcher.current = prevDispatcher; } }, useRef: function(initialValue) { @@ -11558,13 +11002,13 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; useState: function(initialState) { currentHookNameInDev = "useState"; updateHookTypesDev(); - var prevDispatcher = ReactCurrentDispatcher$1.current; - ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV; + var prevDispatcher = ReactCurrentDispatcher.current; + ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnUpdateInDEV; try { return updateState(initialState); } finally { - ReactCurrentDispatcher$1.current = prevDispatcher; + ReactCurrentDispatcher.current = prevDispatcher; } }, useDebugValue: function(value, formatterFn) { @@ -11587,17 +11031,11 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; updateHookTypesDev(); return updateTransition(config); }, - useMutableSource: function(source, getSnapshot, subscribe) { - currentHookNameInDev = "useMutableSource"; + useEvent: function(event) { + currentHookNameInDev = "useEvent"; updateHookTypesDev(); - return updateMutableSource(source, getSnapshot, subscribe); - }, - useOpaqueIdentifier: function() { - currentHookNameInDev = "useOpaqueIdentifier"; - updateHookTypesDev(); - return updateOpaqueIdentifier(); - }, - unstable_isNewReconciler: enableNewReconciler + return updateEventListener(); + } }; HooksDispatcherOnRerenderInDEV = { readContext: function(context, observedBits) { @@ -11631,25 +11069,25 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; useMemo: function(create, deps) { currentHookNameInDev = "useMemo"; updateHookTypesDev(); - var prevDispatcher = ReactCurrentDispatcher$1.current; - ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnRerenderInDEV; + var prevDispatcher = ReactCurrentDispatcher.current; + ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnRerenderInDEV; try { return updateMemo(create, deps); } finally { - ReactCurrentDispatcher$1.current = prevDispatcher; + ReactCurrentDispatcher.current = prevDispatcher; } }, useReducer: function(reducer, initialArg, init) { currentHookNameInDev = "useReducer"; updateHookTypesDev(); - var prevDispatcher = ReactCurrentDispatcher$1.current; - ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnRerenderInDEV; + var prevDispatcher = ReactCurrentDispatcher.current; + ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnRerenderInDEV; try { return rerenderReducer(reducer, initialArg, init); } finally { - ReactCurrentDispatcher$1.current = prevDispatcher; + ReactCurrentDispatcher.current = prevDispatcher; } }, useRef: function(initialValue) { @@ -11660,13 +11098,13 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; useState: function(initialState) { currentHookNameInDev = "useState"; updateHookTypesDev(); - var prevDispatcher = ReactCurrentDispatcher$1.current; - ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnRerenderInDEV; + var prevDispatcher = ReactCurrentDispatcher.current; + ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnRerenderInDEV; try { return rerenderState(initialState); } finally { - ReactCurrentDispatcher$1.current = prevDispatcher; + ReactCurrentDispatcher.current = prevDispatcher; } }, useDebugValue: function(value, formatterFn) { @@ -11689,17 +11127,11 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; updateHookTypesDev(); return rerenderTransition(config); }, - useMutableSource: function(source, getSnapshot, subscribe) { - currentHookNameInDev = "useMutableSource"; + useEvent: function(event) { + currentHookNameInDev = "useEvent"; updateHookTypesDev(); - return updateMutableSource(source, getSnapshot, subscribe); - }, - useOpaqueIdentifier: function() { - currentHookNameInDev = "useOpaqueIdentifier"; - updateHookTypesDev(); - return rerenderOpaqueIdentifier(); - }, - unstable_isNewReconciler: enableNewReconciler + return updateEventListener(); + } }; InvalidNestedHooksDispatcherOnMountInDEV = { readContext: function(context, observedBits) { @@ -11740,26 +11172,26 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; currentHookNameInDev = "useMemo"; warnInvalidHookAccess(); mountHookTypesDev(); - var prevDispatcher = ReactCurrentDispatcher$1.current; - ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV; + var prevDispatcher = ReactCurrentDispatcher.current; + ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnMountInDEV; try { return mountMemo(create, deps); } finally { - ReactCurrentDispatcher$1.current = prevDispatcher; + ReactCurrentDispatcher.current = prevDispatcher; } }, useReducer: function(reducer, initialArg, init) { currentHookNameInDev = "useReducer"; warnInvalidHookAccess(); mountHookTypesDev(); - var prevDispatcher = ReactCurrentDispatcher$1.current; - ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV; + var prevDispatcher = ReactCurrentDispatcher.current; + ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnMountInDEV; try { return mountReducer(reducer, initialArg, init); } finally { - ReactCurrentDispatcher$1.current = prevDispatcher; + ReactCurrentDispatcher.current = prevDispatcher; } }, useRef: function(initialValue) { @@ -11772,13 +11204,13 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; currentHookNameInDev = "useState"; warnInvalidHookAccess(); mountHookTypesDev(); - var prevDispatcher = ReactCurrentDispatcher$1.current; - ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV; + var prevDispatcher = ReactCurrentDispatcher.current; + ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnMountInDEV; try { return mountState(initialState); } finally { - ReactCurrentDispatcher$1.current = prevDispatcher; + ReactCurrentDispatcher.current = prevDispatcher; } }, useDebugValue: function(value, formatterFn) { @@ -11805,19 +11237,12 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; mountHookTypesDev(); return mountTransition(config); }, - useMutableSource: function(source, getSnapshot, subscribe) { - currentHookNameInDev = "useMutableSource"; + useEvent: function(event) { + currentHookNameInDev = "useEvent"; warnInvalidHookAccess(); mountHookTypesDev(); - return mountMutableSource(source, getSnapshot, subscribe); - }, - useOpaqueIdentifier: function() { - currentHookNameInDev = "useOpaqueIdentifier"; - warnInvalidHookAccess(); - mountHookTypesDev(); - return mountOpaqueIdentifier(); - }, - unstable_isNewReconciler: enableNewReconciler + return mountEventListener(); + } }; InvalidNestedHooksDispatcherOnUpdateInDEV = { readContext: function(context, observedBits) { @@ -11858,26 +11283,26 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; currentHookNameInDev = "useMemo"; warnInvalidHookAccess(); updateHookTypesDev(); - var prevDispatcher = ReactCurrentDispatcher$1.current; - ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV; + var prevDispatcher = ReactCurrentDispatcher.current; + ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnUpdateInDEV; try { return updateMemo(create, deps); } finally { - ReactCurrentDispatcher$1.current = prevDispatcher; + ReactCurrentDispatcher.current = prevDispatcher; } }, useReducer: function(reducer, initialArg, init) { currentHookNameInDev = "useReducer"; warnInvalidHookAccess(); updateHookTypesDev(); - var prevDispatcher = ReactCurrentDispatcher$1.current; - ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV; + var prevDispatcher = ReactCurrentDispatcher.current; + ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnUpdateInDEV; try { return updateReducer(reducer, initialArg, init); } finally { - ReactCurrentDispatcher$1.current = prevDispatcher; + ReactCurrentDispatcher.current = prevDispatcher; } }, useRef: function(initialValue) { @@ -11890,13 +11315,13 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; currentHookNameInDev = "useState"; warnInvalidHookAccess(); updateHookTypesDev(); - var prevDispatcher = ReactCurrentDispatcher$1.current; - ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV; + var prevDispatcher = ReactCurrentDispatcher.current; + ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnUpdateInDEV; try { return updateState(initialState); } finally { - ReactCurrentDispatcher$1.current = prevDispatcher; + ReactCurrentDispatcher.current = prevDispatcher; } }, useDebugValue: function(value, formatterFn) { @@ -11923,19 +11348,12 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; updateHookTypesDev(); return updateTransition(config); }, - useMutableSource: function(source, getSnapshot, subscribe) { - currentHookNameInDev = "useMutableSource"; + useEvent: function(event) { + currentHookNameInDev = "useEvent"; warnInvalidHookAccess(); updateHookTypesDev(); - return updateMutableSource(source, getSnapshot, subscribe); - }, - useOpaqueIdentifier: function() { - currentHookNameInDev = "useOpaqueIdentifier"; - warnInvalidHookAccess(); - updateHookTypesDev(); - return updateOpaqueIdentifier(); - }, - unstable_isNewReconciler: enableNewReconciler + return updateEventListener(); + } }; InvalidNestedHooksDispatcherOnRerenderInDEV = { readContext: function(context, observedBits) { @@ -11976,26 +11394,26 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; currentHookNameInDev = "useMemo"; warnInvalidHookAccess(); updateHookTypesDev(); - var prevDispatcher = ReactCurrentDispatcher$1.current; - ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV; + var prevDispatcher = ReactCurrentDispatcher.current; + ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnUpdateInDEV; try { return updateMemo(create, deps); } finally { - ReactCurrentDispatcher$1.current = prevDispatcher; + ReactCurrentDispatcher.current = prevDispatcher; } }, useReducer: function(reducer, initialArg, init) { currentHookNameInDev = "useReducer"; warnInvalidHookAccess(); updateHookTypesDev(); - var prevDispatcher = ReactCurrentDispatcher$1.current; - ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV; + var prevDispatcher = ReactCurrentDispatcher.current; + ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnUpdateInDEV; try { return rerenderReducer(reducer, initialArg, init); } finally { - ReactCurrentDispatcher$1.current = prevDispatcher; + ReactCurrentDispatcher.current = prevDispatcher; } }, useRef: function(initialValue) { @@ -12008,13 +11426,13 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; currentHookNameInDev = "useState"; warnInvalidHookAccess(); updateHookTypesDev(); - var prevDispatcher = ReactCurrentDispatcher$1.current; - ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV; + var prevDispatcher = ReactCurrentDispatcher.current; + ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnUpdateInDEV; try { return rerenderState(initialState); } finally { - ReactCurrentDispatcher$1.current = prevDispatcher; + ReactCurrentDispatcher.current = prevDispatcher; } }, useDebugValue: function(value, formatterFn) { @@ -12041,19 +11459,12 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; updateHookTypesDev(); return rerenderTransition(config); }, - useMutableSource: function(source, getSnapshot, subscribe) { - currentHookNameInDev = "useMutableSource"; + useEvent: function(event) { + currentHookNameInDev = "useEvent"; warnInvalidHookAccess(); updateHookTypesDev(); - return updateMutableSource(source, getSnapshot, subscribe); - }, - useOpaqueIdentifier: function() { - currentHookNameInDev = "useOpaqueIdentifier"; - warnInvalidHookAccess(); - updateHookTypesDev(); - return rerenderOpaqueIdentifier(); - }, - unstable_isNewReconciler: enableNewReconciler + return updateEventListener(); + } }; } @@ -12094,15 +11505,40 @@ function stopProfilerTimerIfRunningAndRecordDelta(fiber, overrideBaseTime) { } } -function transferActualDuration(fiber) { - // Transfer time spent rendering these children so we don't lose it - // after we rerender. This is used as a helper in special cases - // where we should count the work of multiple passes. - var child = fiber.child; +function enterHydrationState(fiber) { + { + return false; + } +} - while (child) { - fiber.actualDuration += child.actualDuration; - child = child.sibling; +function prepareToHydrateHostInstance( + fiber, + rootContainerInstance, + hostContext +) { + { + { + throw Error( + "Expected prepareToHydrateHostInstance() to never be called. This error is likely caused by a bug in React. Please file an issue." + ); + } + } +} + +function prepareToHydrateHostTextInstance(fiber) { + { + { + throw Error( + "Expected prepareToHydrateHostTextInstance() to never be called. This error is likely caused by a bug in React. Please file an issue." + ); + } + } + var shouldUpdate = hydrateTextInstance(); +} + +function popHydrationState(fiber) { + { + return false; } } @@ -12128,7 +11564,12 @@ var didWarnAboutTailOptions; didWarnAboutTailOptions = {}; } -function reconcileChildren(current, workInProgress, nextChildren, renderLanes) { +function reconcileChildren( + current, + workInProgress, + nextChildren, + renderExpirationTime +) { if (current === null) { // If this is a fresh new component that hasn't been rendered yet, we // won't update its child set by applying minimal side-effects. Instead, @@ -12138,7 +11579,7 @@ function reconcileChildren(current, workInProgress, nextChildren, renderLanes) { workInProgress, null, nextChildren, - renderLanes + renderExpirationTime ); } else { // If the current child is the same as the work in progress, it means that @@ -12150,7 +11591,7 @@ function reconcileChildren(current, workInProgress, nextChildren, renderLanes) { workInProgress, current.child, nextChildren, - renderLanes + renderExpirationTime ); } } @@ -12159,7 +11600,7 @@ function forceUnmountCurrentAndReconcile( current, workInProgress, nextChildren, - renderLanes + renderExpirationTime ) { // This function is fork of reconcileChildren. It's used in cases where we // want to reconcile without matching against the existing set. This has the @@ -12173,7 +11614,7 @@ function forceUnmountCurrentAndReconcile( workInProgress, current.child, null, - renderLanes + renderExpirationTime ); // In the second pass, we mount the new children. The trick here is that we // pass null in place of where we usually pass the current child set. This has // the effect of remounting all children regardless of whether their @@ -12183,7 +11624,7 @@ function forceUnmountCurrentAndReconcile( workInProgress, null, nextChildren, - renderLanes + renderExpirationTime ); } @@ -12192,7 +11633,7 @@ function updateForwardRef( workInProgress, Component, nextProps, - renderLanes + renderExpirationTime ) { // TODO: current can be non-null here even if the component // hasn't yet mounted. This happens after the first render suspends. @@ -12218,7 +11659,7 @@ function updateForwardRef( var ref = workInProgress.ref; // The rest is a fork of updateFunctionComponent var nextChildren; - prepareToReadContext(workInProgress, renderLanes); + prepareToReadContext(workInProgress, renderExpirationTime); { ReactCurrentOwner$1.current = workInProgress; @@ -12229,23 +11670,20 @@ function updateForwardRef( render, nextProps, ref, - renderLanes + renderExpirationTime ); if (workInProgress.mode & StrictMode) { - disableLogs(); - - try { + // Only double-render components with Hooks + if (workInProgress.memoizedState !== null) { nextChildren = renderWithHooks( current, workInProgress, render, nextProps, ref, - renderLanes + renderExpirationTime ); - } finally { - reenableLogs(); } } @@ -12253,12 +11691,21 @@ function updateForwardRef( } if (current !== null && !didReceiveUpdate) { - bailoutHooks(current, workInProgress, renderLanes); - return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes); + bailoutHooks(current, workInProgress, renderExpirationTime); + return bailoutOnAlreadyFinishedWork( + current, + workInProgress, + renderExpirationTime + ); } // React DevTools reads this flag. workInProgress.effectTag |= PerformedWork; - reconcileChildren(current, workInProgress, nextChildren, renderLanes); + reconcileChildren( + current, + workInProgress, + nextChildren, + renderExpirationTime + ); return workInProgress.child; } @@ -12267,8 +11714,8 @@ function updateMemoComponent( workInProgress, Component, nextProps, - updateLanes, - renderLanes + updateExpirationTime, + renderExpirationTime ) { if (current === null) { var type = Component.type; @@ -12298,8 +11745,8 @@ function updateMemoComponent( workInProgress, resolvedType, nextProps, - updateLanes, - renderLanes + updateExpirationTime, + renderExpirationTime ); } @@ -12324,7 +11771,7 @@ function updateMemoComponent( nextProps, null, workInProgress.mode, - renderLanes + renderExpirationTime ); child.ref = workInProgress.ref; child.return = workInProgress; @@ -12350,7 +11797,7 @@ function updateMemoComponent( var currentChild = current.child; // This is always exactly one child - if (!includesSomeLane(updateLanes, renderLanes)) { + 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 @@ -12359,7 +11806,11 @@ function updateMemoComponent( compare = compare !== null ? compare : shallowEqual; if (compare(prevProps, nextProps) && current.ref === workInProgress.ref) { - return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes); + return bailoutOnAlreadyFinishedWork( + current, + workInProgress, + renderExpirationTime + ); } } // React DevTools reads this flag. @@ -12376,8 +11827,8 @@ function updateSimpleMemoComponent( workInProgress, Component, nextProps, - updateLanes, - renderLanes + updateExpirationTime, + renderExpirationTime ) { // TODO: current can be non-null here even if the component // hasn't yet mounted. This happens when the inner render suspends. @@ -12392,27 +11843,19 @@ function updateSimpleMemoComponent( // We warn when you define propTypes on lazy() // so let's just skip over it to find memo() outer wrapper. // Inner props for memo are validated later. - var lazyComponent = outerMemoType; - var payload = lazyComponent._payload; - var init = lazyComponent._init; - - try { - outerMemoType = init(payload); - } catch (x) { - outerMemoType = null; - } // Inner propTypes will be validated in the function component path. - - var outerPropTypes = outerMemoType && outerMemoType.propTypes; - - if (outerPropTypes) { - checkPropTypes( - outerPropTypes, - nextProps, // Resolved (SimpleMemoComponent has no defaultProps) - "prop", - getComponentName(outerMemoType) - ); - } + outerMemoType = refineResolvedLazyComponent(outerMemoType); } + + var outerPropTypes = outerMemoType && outerMemoType.propTypes; + + if (outerPropTypes) { + checkPropTypes( + outerPropTypes, + nextProps, // Resolved (SimpleMemoComponent has no defaultProps) + "prop", + getComponentName(outerMemoType) + ); + } // Inner propTypes will be validated in the function component path. } } @@ -12426,10 +11869,10 @@ function updateSimpleMemoComponent( ) { didReceiveUpdate = false; - if (!includesSomeLane(renderLanes, updateLanes)) { - // The pending lanes were cleared at the beginning of beginWork. We're - // about to bail out, but there might be other lanes that weren't - // included in the current render. Usually, the priority level of the + if (updateExpirationTime < renderExpirationTime) { + // The pending update priority was cleared at the beginning of + // beginWork. We're about to bail out, but there might be additional + // updates at a lower priority. Usually, the priority level of the // remaining updates is accumlated during the evaluation of the // component (i.e. when processing the update queue). But since since // we're bailing out early *without* evaluating the component, we need @@ -12440,19 +11883,12 @@ function updateSimpleMemoComponent( // contains hooks. // TODO: Move the reset at in beginWork out of the common path so that // this is no longer necessary. - workInProgress.lanes = current.lanes; + workInProgress.expirationTime = current.expirationTime; return bailoutOnAlreadyFinishedWork( current, workInProgress, - renderLanes + renderExpirationTime ); - } else if ( - (current.effectTag & ForceUpdateForLegacySuspense) !== - NoEffect - ) { - // This is a special case that only exists for legacy mode. - // See https://github.com/facebook/react/pull/19216. - didReceiveUpdate = true; } } } @@ -12462,101 +11898,33 @@ function updateSimpleMemoComponent( workInProgress, Component, nextProps, - renderLanes + renderExpirationTime ); } -function updateOffscreenComponent(current, workInProgress, renderLanes) { - var nextProps = workInProgress.pendingProps; - var nextChildren = nextProps.children; - var prevState = current !== null ? current.memoizedState : null; - - if ( - nextProps.mode === "hidden" || - nextProps.mode === "unstable-defer-without-hiding" - ) { - if ((workInProgress.mode & ConcurrentMode) === NoMode) { - // In legacy sync mode, don't defer the subtree. Render it now. - // TODO: Figure out what we should do in Blocking mode. - var nextState = { - baseLanes: NoLanes - }; - workInProgress.memoizedState = nextState; - pushRenderLanes(workInProgress, renderLanes); - } else if (!includesSomeLane(renderLanes, OffscreenLane)) { - var nextBaseLanes; - - if (prevState !== null) { - var prevBaseLanes = prevState.baseLanes; - nextBaseLanes = mergeLanes(prevBaseLanes, renderLanes); - } else { - nextBaseLanes = renderLanes; - } // Schedule this fiber to re-render at offscreen priority. Then bailout. - - { - markSpawnedWork(OffscreenLane); - } - - workInProgress.lanes = workInProgress.childLanes = laneToLanes( - OffscreenLane - ); - var _nextState = { - baseLanes: nextBaseLanes - }; - workInProgress.memoizedState = _nextState; // We're about to bail out, but we need to push this to the stack anyway - // to avoid a push/pop misalignment. - - pushRenderLanes(workInProgress, nextBaseLanes); - return null; - } else { - // Rendering at offscreen, so we can clear the base lanes. - var _nextState2 = { - baseLanes: NoLanes - }; - workInProgress.memoizedState = _nextState2; // Push the lanes that were skipped when we bailed out. - - var subtreeRenderLanes = - prevState !== null ? prevState.baseLanes : renderLanes; - pushRenderLanes(workInProgress, subtreeRenderLanes); - } - } else { - var _subtreeRenderLanes; - - if (prevState !== null) { - _subtreeRenderLanes = mergeLanes(prevState.baseLanes, renderLanes); // Since we're not hidden anymore, reset the state - - workInProgress.memoizedState = null; - } else { - // We weren't previously hidden, and we still aren't, so there's nothing - // special to do. Need to push to the stack regardless, though, to avoid - // a push/pop misalignment. - _subtreeRenderLanes = renderLanes; - } - - pushRenderLanes(workInProgress, _subtreeRenderLanes); - } - - reconcileChildren(current, workInProgress, nextChildren, renderLanes); - return workInProgress.child; -} // Note: These happen to have identical begin phases, for now. We shouldn't hold -// ourselves to this constraint, though. If the behavior diverges, we should -// fork the function. - -var updateLegacyHiddenComponent = updateOffscreenComponent; - -function updateFragment(current, workInProgress, renderLanes) { +function updateFragment(current, workInProgress, renderExpirationTime) { var nextChildren = workInProgress.pendingProps; - reconcileChildren(current, workInProgress, nextChildren, renderLanes); + reconcileChildren( + current, + workInProgress, + nextChildren, + renderExpirationTime + ); return workInProgress.child; } -function updateMode(current, workInProgress, renderLanes) { +function updateMode(current, workInProgress, renderExpirationTime) { var nextChildren = workInProgress.pendingProps.children; - reconcileChildren(current, workInProgress, nextChildren, renderLanes); + reconcileChildren( + current, + workInProgress, + nextChildren, + renderExpirationTime + ); return workInProgress.child; } -function updateProfiler(current, workInProgress, renderLanes) { +function updateProfiler(current, workInProgress, renderExpirationTime) { { workInProgress.effectTag |= Update; // Reset effect durations for the next eventual effect phase. // These are reset during render to allow the DevTools commit hook a chance to read them, @@ -12568,7 +11936,12 @@ function updateProfiler(current, workInProgress, renderLanes) { var nextProps = workInProgress.pendingProps; var nextChildren = nextProps.children; - reconcileChildren(current, workInProgress, nextChildren, renderLanes); + reconcileChildren( + current, + workInProgress, + nextChildren, + renderExpirationTime + ); return workInProgress.child; } @@ -12589,7 +11962,7 @@ function updateFunctionComponent( workInProgress, Component, nextProps, - renderLanes + renderExpirationTime ) { { if (workInProgress.type !== workInProgress.elementType) { @@ -12616,7 +11989,7 @@ function updateFunctionComponent( } var nextChildren; - prepareToReadContext(workInProgress, renderLanes); + prepareToReadContext(workInProgress, renderExpirationTime); { ReactCurrentOwner$1.current = workInProgress; @@ -12627,23 +12000,20 @@ function updateFunctionComponent( Component, nextProps, context, - renderLanes + renderExpirationTime ); if (workInProgress.mode & StrictMode) { - disableLogs(); - - try { + // Only double-render components with Hooks + if (workInProgress.memoizedState !== null) { nextChildren = renderWithHooks( current, workInProgress, Component, nextProps, context, - renderLanes + renderExpirationTime ); - } finally { - reenableLogs(); } } @@ -12651,12 +12021,21 @@ function updateFunctionComponent( } if (current !== null && !didReceiveUpdate) { - bailoutHooks(current, workInProgress, renderLanes); - return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes); + bailoutHooks(current, workInProgress, renderExpirationTime); + return bailoutOnAlreadyFinishedWork( + current, + workInProgress, + renderExpirationTime + ); } // React DevTools reads this flag. workInProgress.effectTag |= PerformedWork; - reconcileChildren(current, workInProgress, nextChildren, renderLanes); + reconcileChildren( + current, + workInProgress, + nextChildren, + renderExpirationTime + ); return workInProgress.child; } @@ -12665,7 +12044,7 @@ function updateClassComponent( workInProgress, Component, nextProps, - renderLanes + renderExpirationTime ) { { if (workInProgress.type !== workInProgress.elementType) { @@ -12695,7 +12074,7 @@ function updateClassComponent( hasContext = false; } - prepareToReadContext(workInProgress, renderLanes); + prepareToReadContext(workInProgress, renderExpirationTime); var instance = workInProgress.stateNode; var shouldUpdate; @@ -12712,7 +12091,12 @@ function updateClassComponent( } // In the initial pass we might need to construct the instance. constructClassInstance(workInProgress, Component, nextProps); - mountClassInstance(workInProgress, Component, nextProps, renderLanes); + mountClassInstance( + workInProgress, + Component, + nextProps, + renderExpirationTime + ); shouldUpdate = true; } else if (current === null) { // In a resume, we'll already have an instance we can reuse. @@ -12720,7 +12104,7 @@ function updateClassComponent( workInProgress, Component, nextProps, - renderLanes + renderExpirationTime ); } else { shouldUpdate = updateClassInstance( @@ -12728,7 +12112,7 @@ function updateClassComponent( workInProgress, Component, nextProps, - renderLanes + renderExpirationTime ); } @@ -12738,13 +12122,13 @@ function updateClassComponent( Component, shouldUpdate, hasContext, - renderLanes + renderExpirationTime ); { var inst = workInProgress.stateNode; - if (shouldUpdate && inst.props !== nextProps) { + if (inst.props !== nextProps) { if (!didWarnAboutReassigningProps) { error( "It looks like %s is reassigning its own `this.props` while rendering. " + @@ -12766,7 +12150,7 @@ function finishClassComponent( Component, shouldUpdate, hasContext, - renderLanes + renderExpirationTime ) { // Refs should update even if shouldComponentUpdate returns false markRef(current, workInProgress); @@ -12778,7 +12162,11 @@ function finishClassComponent( invalidateContextProvider(workInProgress, Component, false); } - return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes); + return bailoutOnAlreadyFinishedWork( + current, + workInProgress, + renderExpirationTime + ); } var instance = workInProgress.stateNode; // Rerender @@ -12806,13 +12194,7 @@ function finishClassComponent( nextChildren = instance.render(); if (workInProgress.mode & StrictMode) { - disableLogs(); - - try { - instance.render(); - } finally { - reenableLogs(); - } + instance.render(); } setIsRendering(false); @@ -12830,10 +12212,15 @@ function finishClassComponent( current, workInProgress, nextChildren, - renderLanes + renderExpirationTime ); } else { - reconcileChildren(current, workInProgress, nextChildren, renderLanes); + reconcileChildren( + current, + workInProgress, + nextChildren, + renderExpirationTime + ); } // Memoize state using the values we just used to render. // TODO: Restructure so we never read values from the instance. @@ -12863,7 +12250,7 @@ function pushHostRootContext(workInProgress) { pushHostContainer(workInProgress, root.containerInfo); } -function updateHostRoot(current, workInProgress, renderLanes) { +function updateHostRoot(current, workInProgress, renderExpirationTime) { pushHostRootContext(workInProgress); var updateQueue = workInProgress.updateQueue; @@ -12877,24 +12264,32 @@ function updateHostRoot(current, workInProgress, renderLanes) { var prevState = workInProgress.memoizedState; var prevChildren = prevState !== null ? prevState.element : null; cloneUpdateQueue(current, workInProgress); - processUpdateQueue(workInProgress, nextProps, null, renderLanes); + processUpdateQueue(workInProgress, nextProps, null, renderExpirationTime); var nextState = workInProgress.memoizedState; // Caution: React DevTools currently depends on this property // being called "element". var nextChildren = nextState.element; if (nextChildren === prevChildren) { - return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes); + return bailoutOnAlreadyFinishedWork( + current, + workInProgress, + renderExpirationTime + ); } var root = workInProgress.stateNode; if (root.hydrate && enterHydrationState()) { + // If we don't have any current children this might be the first pass. + // We always try to hydrate. If this isn't a hydration pass there won't + // be any children to hydrate which is effectively the same thing as + // not hydrating. var child = mountChildFibers( workInProgress, null, nextChildren, - renderLanes + renderExpirationTime ); workInProgress.child = child; var node = child; @@ -12912,13 +12307,18 @@ function updateHostRoot(current, workInProgress, renderLanes) { } else { // Otherwise reset hydration state in case we aborted and resumed another // root. - reconcileChildren(current, workInProgress, nextChildren, renderLanes); + reconcileChildren( + current, + workInProgress, + nextChildren, + renderExpirationTime + ); } return workInProgress.child; } -function updateHostComponent(current, workInProgress, renderLanes) { +function updateHostComponent(current, workInProgress, renderExpirationTime) { pushHostContext(workInProgress); var type = workInProgress.type; @@ -12932,8 +12332,27 @@ function updateHostComponent(current, workInProgress, renderLanes) { workInProgress.effectTag |= ContentReset; } - markRef(current, workInProgress); - reconcileChildren(current, workInProgress, nextChildren, renderLanes); + markRef(current, workInProgress); // Check the host config to see if the children are offscreen/hidden. + + if ( + workInProgress.mode & ConcurrentMode && + renderExpirationTime !== Never && + shouldDeprioritizeSubtree() + ) { + { + markSpawnedWork(Never); + } // Schedule this fiber to re-render at offscreen priority. Then bailout. + + workInProgress.expirationTime = workInProgress.childExpirationTime = Never; + return null; + } + + reconcileChildren( + current, + workInProgress, + nextChildren, + renderExpirationTime + ); return workInProgress.child; } @@ -12947,8 +12366,8 @@ function mountLazyComponent( _current, workInProgress, elementType, - updateLanes, - renderLanes + updateExpirationTime, + renderExpirationTime ) { if (_current !== null) { // A lazy component only mounts if it suspended inside a non- @@ -12961,14 +12380,15 @@ function mountLazyComponent( workInProgress.effectTag |= Placement; } - var props = workInProgress.pendingProps; - var lazyComponent = elementType; - var payload = lazyComponent._payload; - var init = lazyComponent._init; - var Component = init(payload); // Store the unwrapped component in the type. + 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; @@ -12986,7 +12406,7 @@ function mountLazyComponent( workInProgress, Component, resolvedProps, - renderLanes + renderExpirationTime ); return child; } @@ -13003,7 +12423,7 @@ function mountLazyComponent( workInProgress, Component, resolvedProps, - renderLanes + renderExpirationTime ); return child; } @@ -13020,7 +12440,7 @@ function mountLazyComponent( workInProgress, Component, resolvedProps, - renderLanes + renderExpirationTime ); return child; } @@ -13046,8 +12466,8 @@ function mountLazyComponent( workInProgress, Component, resolveDefaultProps(Component.type, resolvedProps), // The inner type can have defaults too - updateLanes, - renderLanes + updateExpirationTime, + renderExpirationTime ); return child; } @@ -13082,7 +12502,7 @@ function mountIncompleteClassComponent( workInProgress, Component, nextProps, - renderLanes + renderExpirationTime ) { if (_current !== null) { // An incomplete component only mounts if it suspended inside a non- @@ -13109,16 +12529,21 @@ function mountIncompleteClassComponent( hasContext = false; } - prepareToReadContext(workInProgress, renderLanes); + prepareToReadContext(workInProgress, renderExpirationTime); constructClassInstance(workInProgress, Component, nextProps); - mountClassInstance(workInProgress, Component, nextProps, renderLanes); + mountClassInstance( + workInProgress, + Component, + nextProps, + renderExpirationTime + ); return finishClassComponent( null, workInProgress, Component, true, hasContext, - renderLanes + renderExpirationTime ); } @@ -13126,7 +12551,7 @@ function mountIndeterminateComponent( _current, workInProgress, Component, - renderLanes + renderExpirationTime ) { if (_current !== null) { // An indeterminate component only mounts if it suspended inside a non- @@ -13147,7 +12572,7 @@ function mountIndeterminateComponent( context = getMaskedContext(workInProgress, unmaskedContext); } - prepareToReadContext(workInProgress, renderLanes); + prepareToReadContext(workInProgress, renderExpirationTime); var value; { @@ -13173,7 +12598,6 @@ function mountIndeterminateComponent( ReactStrictModeWarnings.recordLegacyContextWarning(workInProgress, null); } - setIsRendering(true); ReactCurrentOwner$1.current = workInProgress; value = renderWithHooks( null, @@ -13181,22 +12605,19 @@ function mountIndeterminateComponent( Component, props, context, - renderLanes + renderExpirationTime ); - setIsRendering(false); } // React DevTools reads this flag. workInProgress.effectTag |= PerformedWork; - { - // Support for module components is deprecated and is removed behind a flag. - // Whether or not it would crash later, we want to show a good message in DEV first. - if ( - typeof value === "object" && - value !== null && - typeof value.render === "function" && - value.$$typeof === undefined - ) { + if ( + typeof value === "object" && + value !== null && + typeof value.render === "function" && + value.$$typeof === undefined + ) { + { var _componentName = getComponentName(Component) || "Unknown"; if (!didWarnAboutModulePatternComponent[_componentName]) { @@ -13213,34 +12634,6 @@ function mountIndeterminateComponent( didWarnAboutModulePatternComponent[_componentName] = true; } - } - } - - if ( - // Run these checks in production only if the flag is off. - // Eventually we'll delete this branch altogether. - typeof value === "object" && - value !== null && - typeof value.render === "function" && - value.$$typeof === undefined - ) { - { - var _componentName2 = getComponentName(Component) || "Unknown"; - - if (!didWarnAboutModulePatternComponent[_componentName2]) { - error( - "The <%s /> component appears to be a function component that returns a class instance. " + - "Change %s to a class that extends React.Component instead. " + - "If you can't use a class try assigning the prototype on the function as a workaround. " + - "`%s.prototype = React.Component.prototype`. Don't use an arrow function since it " + - "cannot be called with `new` by React.", - _componentName2, - _componentName2, - _componentName2 - ); - - didWarnAboutModulePatternComponent[_componentName2] = true; - } } // Proceed under the assumption that this is a class instance workInProgress.tag = ClassComponent; // Throw out any hooks that were used. @@ -13274,14 +12667,14 @@ function mountIndeterminateComponent( } adoptClassInstance(workInProgress, value); - mountClassInstance(workInProgress, Component, props, renderLanes); + mountClassInstance(workInProgress, Component, props, renderExpirationTime); return finishClassComponent( null, workInProgress, Component, true, hasContext, - renderLanes + renderExpirationTime ); } else { // Proceed under the assumption that this is a function component @@ -13289,24 +12682,21 @@ function mountIndeterminateComponent( { if (workInProgress.mode & StrictMode) { - disableLogs(); - - try { + // Only double-render components with Hooks + if (workInProgress.memoizedState !== null) { value = renderWithHooks( null, workInProgress, Component, props, context, - renderLanes + renderExpirationTime ); - } finally { - reenableLogs(); } } } - reconcileChildren(null, workInProgress, value, renderLanes); + reconcileChildren(null, workInProgress, value, renderExpirationTime); { validateFunctionComponentInDev(workInProgress, Component); @@ -13355,15 +12745,15 @@ function validateFunctionComponentInDev(workInProgress, Component) { } if (typeof Component.getDerivedStateFromProps === "function") { - var _componentName3 = getComponentName(Component) || "Unknown"; + var _componentName2 = getComponentName(Component) || "Unknown"; - if (!didWarnAboutGetDerivedStateOnFunctionComponent[_componentName3]) { + if (!didWarnAboutGetDerivedStateOnFunctionComponent[_componentName2]) { error( "%s: Function components do not support getDerivedStateFromProps.", - _componentName3 + _componentName2 ); - didWarnAboutGetDerivedStateOnFunctionComponent[_componentName3] = true; + didWarnAboutGetDerivedStateOnFunctionComponent[_componentName2] = true; } } @@ -13371,15 +12761,15 @@ function validateFunctionComponentInDev(workInProgress, Component) { typeof Component.contextType === "object" && Component.contextType !== null ) { - var _componentName4 = getComponentName(Component) || "Unknown"; + var _componentName3 = getComponentName(Component) || "Unknown"; - if (!didWarnAboutContextTypeOnFunctionComponent[_componentName4]) { + if (!didWarnAboutContextTypeOnFunctionComponent[_componentName3]) { error( "%s: Function components do not support contextType.", - _componentName4 + _componentName3 ); - didWarnAboutContextTypeOnFunctionComponent[_componentName4] = true; + didWarnAboutContextTypeOnFunctionComponent[_componentName3] = true; } } } @@ -13387,51 +12777,24 @@ function validateFunctionComponentInDev(workInProgress, Component) { var SUSPENDED_MARKER = { dehydrated: null, - retryLane: NoLane + retryTime: NoWork }; -function mountSuspenseOffscreenState(renderLanes) { - return { - baseLanes: renderLanes - }; +function shouldRemainOnFallback(suspenseContext, current, workInProgress) { + // If the context is telling us that we should show a fallback, and we're not + // already showing content, then we should show the fallback instead. + return ( + hasSuspenseContext(suspenseContext, ForceSuspenseFallback) && + (current === null || current.memoizedState !== null) + ); } -function updateSuspenseOffscreenState(prevOffscreenState, renderLanes) { - return { - baseLanes: mergeLanes(prevOffscreenState.baseLanes, renderLanes) - }; -} - -function shouldRemainOnFallback( - suspenseContext, +function updateSuspenseComponent( current, workInProgress, - renderLanes + renderExpirationTime ) { - // If we're already showing a fallback, there are cases where we need to - // remain on that fallback regardless of whether the content has resolved. - // For example, SuspenseList coordinates when nested content appears. - if (current !== null) { - var suspenseState = current.memoizedState; - - if (suspenseState === null) { - // Currently showing content. Don't hide it, even if ForceSuspenseFallack - // is true. More precise name might be "ForceRemainSuspenseFallback". - // Note: This is a factoring smell. Can't remain on a fallback if there's - // no fallback to remain on. - return false; - } - } // Not currently showing content. Consult the Suspense context. - - return hasSuspenseContext(suspenseContext, ForceSuspenseFallback); -} - -function getRemainingWorkInPrimaryTree(current, renderLanes) { - // TODO: Should not remove render lanes that were pinged during this render - return removeLanes(current.childLanes, renderLanes); -} - -function updateSuspenseComponent(current, workInProgress, renderLanes) { + var mode = workInProgress.mode; var nextProps = workInProgress.pendingProps; // This is used by DevTools to force a boundary to suspend. { @@ -13441,13 +12804,13 @@ function updateSuspenseComponent(current, workInProgress, renderLanes) { } var suspenseContext = suspenseStackCursor.current; - var showFallback = false; + var nextDidTimeout = false; var didSuspend = (workInProgress.effectTag & DidCapture) !== NoEffect; if (didSuspend || shouldRemainOnFallback(suspenseContext, current)) { // Something in this boundary's subtree already suspended. Switch to // rendering the fallback children. - showFallback = true; + nextDidTimeout = true; workInProgress.effectTag &= ~DidCapture; } else { // Attempting the main content @@ -13470,380 +12833,290 @@ function updateSuspenseComponent(current, workInProgress, renderLanes) { } suspenseContext = setDefaultShallowSuspenseContext(suspenseContext); - pushSuspenseContext(workInProgress, suspenseContext); // OK, the next part is confusing. We're about to reconcile the Suspense - // boundary's children. This involves some custom reconcilation logic. Two - // main reasons this is so complicated. + pushSuspenseContext(workInProgress, suspenseContext); // 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. // - // First, Legacy Mode has different semantics for backwards compatibility. The - // primary tree will commit in an inconsistent state, so when we do the - // second pass to render the fallback, we do some exceedingly, uh, clever - // hacks to make that not totally break. Like transferring effects and - // deletions from hidden tree. In Concurrent Mode, it's much simpler, - // because we bailout on the primary tree completely and leave it in its old - // state, no effects. Same as what we do for Offscreen (except that - // Offscreen doesn't have the first render pass). + // 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. // - // Second is hydration. During hydration, the Suspense fiber has a slightly - // different layout, where the child points to a dehydrated fragment, which - // contains the DOM rendered by the server. + // 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. // - // Third, even if you set all that aside, Suspense is like error boundaries in - // that we first we try to render one tree, and if that fails, we render again - // and switch to a different tree. Like a try/catch block. So we have to track - // which branch we're currently rendering. Ideally we would model this using - // a stack. + // 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. if (current === null) { - // Initial mount // If we're currently hydrating, try to hydrate this boundary. // But only if this has a fallback. - if (nextProps.fallback !== undefined); + if (nextProps.fallback !== undefined); // This is the initial mount. This branch is pretty simple because there's + // no previous state that needs to be preserved. - if (showFallback) { - var nextPrimaryChildren = nextProps.children; + if (nextDidTimeout) { + // Mount separate fragments for primary and fallback children. var nextFallbackChildren = nextProps.fallback; - var fallbackFragment = mountSuspenseFallbackChildren( - workInProgress, - nextPrimaryChildren, + var primaryChildFragment = createFiberFromFragment( + null, + mode, + NoWork, + null + ); + primaryChildFragment.return = workInProgress; + + if ((workInProgress.mode & BlockingMode) === NoMode) { + // Outside of blocking mode, we commit the effects from the + // partially completed, timed-out tree, too. + var progressedState = workInProgress.memoizedState; + var progressedPrimaryChild = + progressedState !== null + ? workInProgress.child.child + : workInProgress.child; + primaryChildFragment.child = progressedPrimaryChild; + var progressedChild = progressedPrimaryChild; + + while (progressedChild !== null) { + progressedChild.return = primaryChildFragment; + progressedChild = progressedChild.sibling; + } + } + + var fallbackChildFragment = createFiberFromFragment( nextFallbackChildren, - renderLanes - ); - var primaryChildFragment = workInProgress.child; - primaryChildFragment.memoizedState = mountSuspenseOffscreenState( - renderLanes + mode, + renderExpirationTime, + null ); + fallbackChildFragment.return = workInProgress; + primaryChildFragment.sibling = fallbackChildFragment; // Skip the primary children, and continue working on the + // fallback children. + workInProgress.memoizedState = SUSPENDED_MARKER; - return fallbackFragment; + workInProgress.child = primaryChildFragment; + return fallbackChildFragment; } else { - var _nextPrimaryChildren = nextProps.children; - return mountSuspensePrimaryChildren( + // Mount the primary children without an intermediate fragment fiber. + var nextPrimaryChildren = nextProps.children; + workInProgress.memoizedState = null; + return (workInProgress.child = mountChildFibers( workInProgress, - _nextPrimaryChildren, - renderLanes - ); + null, + nextPrimaryChildren, + renderExpirationTime + )); } } else { - // This is an update. - // If the current fiber has a SuspenseState, that means it's already showing - // a fallback. + // 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.memoizedState; if (prevState !== null) { - if (showFallback) { + // wrapped in a fragment fiber. + + var currentPrimaryChildFragment = current.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 _nextFallbackChildren2 = nextProps.fallback; - var _nextPrimaryChildren3 = nextProps.children; - var _fallbackChildFragment = updateSuspenseFallbackChildren( - current, - workInProgress, - _nextPrimaryChildren3, - _nextFallbackChildren2, - renderLanes + var _primaryChildFragment2 = createWorkInProgress( + currentPrimaryChildFragment, + currentPrimaryChildFragment.pendingProps ); - var _primaryChildFragment2 = workInProgress.child; - var prevOffscreenState = current.child.memoizedState; - _primaryChildFragment2.memoizedState = - prevOffscreenState === null - ? mountSuspenseOffscreenState(renderLanes) - : updateSuspenseOffscreenState(prevOffscreenState, renderLanes); - _primaryChildFragment2.childLanes = getRemainingWorkInPrimaryTree( - current, - renderLanes - ); - workInProgress.memoizedState = SUSPENDED_MARKER; - return _fallbackChildFragment; - } else { - var _nextPrimaryChildren4 = nextProps.children; + _primaryChildFragment2.return = workInProgress; - var _primaryChildFragment3 = updateSuspensePrimaryChildren( - current, - workInProgress, - _nextPrimaryChildren4, - renderLanes + if ((workInProgress.mode & BlockingMode) === NoMode) { + // Outside of blocking mode, we commit the effects from the + // partially completed, timed-out tree, too. + var _progressedState = workInProgress.memoizedState; + + var _progressedPrimaryChild = + _progressedState !== null + ? workInProgress.child.child + : workInProgress.child; + + if (_progressedPrimaryChild !== currentPrimaryChildFragment.child) { + _primaryChildFragment2.child = _progressedPrimaryChild; + var _progressedChild2 = _progressedPrimaryChild; + + while (_progressedChild2 !== null) { + _progressedChild2.return = _primaryChildFragment2; + _progressedChild2 = _progressedChild2.sibling; + } + } + } // Because primaryChildFragment is a new fiber that we're inserting as the + // parent of a new tree, we need to set its treeBaseDuration. + + if (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; + } // Clone the fallback child fragment, too. These we'll continue + // working on. + + var _fallbackChildFragment2 = createWorkInProgress( + currentFallbackChildFragment, + _nextFallbackChildren2 ); - workInProgress.memoizedState = null; - return _primaryChildFragment3; - } - } else { - // The current tree is not already showing a fallback. - if (showFallback) { - // Timed out. - var _nextFallbackChildren3 = nextProps.fallback; - var _nextPrimaryChildren5 = nextProps.children; - - var _fallbackChildFragment2 = updateSuspenseFallbackChildren( - current, - workInProgress, - _nextPrimaryChildren5, - _nextFallbackChildren3, - renderLanes - ); - - var _primaryChildFragment4 = workInProgress.child; - var _prevOffscreenState = current.child.memoizedState; - _primaryChildFragment4.memoizedState = - _prevOffscreenState === null - ? mountSuspenseOffscreenState(renderLanes) - : updateSuspenseOffscreenState(_prevOffscreenState, renderLanes); - _primaryChildFragment4.childLanes = getRemainingWorkInPrimaryTree( - current, - renderLanes - ); // Skip the primary children, and continue working on the + _fallbackChildFragment2.return = workInProgress; + _primaryChildFragment2.sibling = _fallbackChildFragment2; + _primaryChildFragment2.childExpirationTime = NoWork; // Skip the primary children, and continue working on the // fallback children. workInProgress.memoizedState = SUSPENDED_MARKER; + workInProgress.child = _primaryChildFragment2; return _fallbackChildFragment2; + } 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. + + workInProgress.memoizedState = null; + return (workInProgress.child = primaryChild); + } + } else { + // The current tree has not already timed out. That means the primary + // children are not wrapped in a fragment fiber. + var _currentPrimaryChild = current.child; + + if (nextDidTimeout) { + // Timed out. Wrap the children in a fragment fiber to keep them + // separate from the fallback children. + var _nextFallbackChildren3 = nextProps.fallback; + + var _primaryChildFragment3 = createFiberFromFragment( + // It shouldn't matter what the pending props are because we aren't + // going to render this fragment. + null, + mode, + NoWork, + null + ); + + _primaryChildFragment3.return = workInProgress; + _primaryChildFragment3.child = _currentPrimaryChild; + + if (_currentPrimaryChild !== null) { + _currentPrimaryChild.return = _primaryChildFragment3; + } // Even though we're creating a new fiber, there are no new children, + // because we're reusing an already mounted tree. So we don't need to + // schedule a placement. + // primaryChildFragment.effectTag |= Placement; + + if ((workInProgress.mode & BlockingMode) === NoMode) { + // Outside of blocking mode, we commit the effects from the + // partially completed, timed-out tree, too. + var _progressedState2 = workInProgress.memoizedState; + + var _progressedPrimaryChild2 = + _progressedState2 !== null + ? workInProgress.child.child + : workInProgress.child; + + _primaryChildFragment3.child = _progressedPrimaryChild2; + var _progressedChild3 = _progressedPrimaryChild2; + + while (_progressedChild3 !== null) { + _progressedChild3.return = _primaryChildFragment3; + _progressedChild3 = _progressedChild3.sibling; + } + } // Because primaryChildFragment is a new fiber that we're inserting as the + // parent of a new tree, we need to set its treeBaseDuration. + + if (workInProgress.mode & ProfileMode) { + // treeBaseDuration is the sum of all the child tree base durations. + var _treeBaseDuration2 = 0; + var _hiddenChild2 = _primaryChildFragment3.child; + + while (_hiddenChild2 !== null) { + _treeBaseDuration2 += _hiddenChild2.treeBaseDuration; + _hiddenChild2 = _hiddenChild2.sibling; + } + + _primaryChildFragment3.treeBaseDuration = _treeBaseDuration2; + } // Create a fragment from the fallback children, too. + + var _fallbackChildFragment3 = createFiberFromFragment( + _nextFallbackChildren3, + mode, + renderExpirationTime, + null + ); + + _fallbackChildFragment3.return = workInProgress; + _primaryChildFragment3.sibling = _fallbackChildFragment3; + _fallbackChildFragment3.effectTag |= Placement; + _primaryChildFragment3.childExpirationTime = NoWork; // Skip the primary children, and continue working on the + // fallback children. + + workInProgress.memoizedState = SUSPENDED_MARKER; + workInProgress.child = _primaryChildFragment3; + return _fallbackChildFragment3; } else { // Still haven't timed out. Continue rendering the children, like we // normally do. - var _nextPrimaryChildren6 = nextProps.children; - - var _primaryChildFragment5 = updateSuspensePrimaryChildren( - current, - workInProgress, - _nextPrimaryChildren6, - renderLanes - ); - workInProgress.memoizedState = null; - return _primaryChildFragment5; + var _nextPrimaryChildren2 = nextProps.children; + return (workInProgress.child = reconcileChildFibers( + workInProgress, + _currentPrimaryChild, + _nextPrimaryChildren2, + renderExpirationTime + )); } } } } -function mountSuspensePrimaryChildren( - workInProgress, - primaryChildren, - renderLanes -) { - var mode = workInProgress.mode; - var primaryChildProps = { - mode: "visible", - children: primaryChildren - }; - var primaryChildFragment = createFiberFromOffscreen( - primaryChildProps, - mode, - renderLanes, - null - ); - primaryChildFragment.return = workInProgress; - workInProgress.child = primaryChildFragment; - return primaryChildFragment; -} - -function mountSuspenseFallbackChildren( - workInProgress, - primaryChildren, - fallbackChildren, - renderLanes -) { - var mode = workInProgress.mode; - var progressedPrimaryFragment = workInProgress.child; - var primaryChildProps = { - mode: "hidden", - children: primaryChildren - }; - var primaryChildFragment; - var fallbackChildFragment; - - if ((mode & BlockingMode) === NoMode && progressedPrimaryFragment !== null) { - // In legacy mode, we commit the primary tree as if it successfully - // completed, even though it's in an inconsistent state. - primaryChildFragment = progressedPrimaryFragment; - primaryChildFragment.childLanes = NoLanes; - primaryChildFragment.pendingProps = primaryChildProps; - - if (workInProgress.mode & ProfileMode) { - // Reset the durations from the first pass so they aren't included in the - // final amounts. This seems counterintuitive, since we're intentionally - // not measuring part of the render phase, but this makes it match what we - // do in Concurrent Mode. - primaryChildFragment.actualDuration = 0; - primaryChildFragment.actualStartTime = -1; - primaryChildFragment.selfBaseDuration = 0; - primaryChildFragment.treeBaseDuration = 0; - } - - fallbackChildFragment = createFiberFromFragment( - fallbackChildren, - mode, - renderLanes, - null - ); - } else { - primaryChildFragment = createFiberFromOffscreen( - primaryChildProps, - mode, - NoLanes, - null - ); - fallbackChildFragment = createFiberFromFragment( - fallbackChildren, - mode, - renderLanes, - null - ); +function scheduleWorkOnFiber(fiber, renderExpirationTime) { + if (fiber.expirationTime < renderExpirationTime) { + fiber.expirationTime = renderExpirationTime; } - primaryChildFragment.return = workInProgress; - fallbackChildFragment.return = workInProgress; - primaryChildFragment.sibling = fallbackChildFragment; - workInProgress.child = primaryChildFragment; - return fallbackChildFragment; -} - -function createWorkInProgressOffscreenFiber(current, offscreenProps) { - // The props argument to `createWorkInProgress` is `any` typed, so we use this - // wrapper function to constrain it. - return createWorkInProgress(current, offscreenProps); -} - -function updateSuspensePrimaryChildren( - current, - workInProgress, - primaryChildren, - renderLanes -) { - var currentPrimaryChildFragment = current.child; - var currentFallbackChildFragment = currentPrimaryChildFragment.sibling; - var primaryChildFragment = createWorkInProgressOffscreenFiber( - currentPrimaryChildFragment, - { - mode: "visible", - children: primaryChildren - } - ); - - if ((workInProgress.mode & BlockingMode) === NoMode) { - primaryChildFragment.lanes = renderLanes; - } - - primaryChildFragment.return = workInProgress; - primaryChildFragment.sibling = null; - - if (currentFallbackChildFragment !== null) { - // Delete the fallback child fragment - currentFallbackChildFragment.nextEffect = null; - currentFallbackChildFragment.effectTag = Deletion; - workInProgress.firstEffect = workInProgress.lastEffect = currentFallbackChildFragment; - } - - workInProgress.child = primaryChildFragment; - return primaryChildFragment; -} - -function updateSuspenseFallbackChildren( - current, - workInProgress, - primaryChildren, - fallbackChildren, - renderLanes -) { - var mode = workInProgress.mode; - var currentPrimaryChildFragment = current.child; - var currentFallbackChildFragment = currentPrimaryChildFragment.sibling; - var primaryChildProps = { - mode: "hidden", - children: primaryChildren - }; - var primaryChildFragment; - - if ( - // In legacy mode, we commit the primary tree as if it successfully - // completed, even though it's in an inconsistent state. - (mode & BlockingMode) === NoMode && // Make sure we're on the second pass, i.e. the primary child fragment was - // already cloned. In legacy mode, the only case where this isn't true is - // when DevTools forces us to display a fallback; we skip the first render - // pass entirely and go straight to rendering the fallback. (In Concurrent - // Mode, SuspenseList can also trigger this scenario, but this is a legacy- - // only codepath.) - workInProgress.child !== currentPrimaryChildFragment - ) { - var progressedPrimaryFragment = workInProgress.child; - primaryChildFragment = progressedPrimaryFragment; - primaryChildFragment.childLanes = NoLanes; - primaryChildFragment.pendingProps = primaryChildProps; - - if (workInProgress.mode & ProfileMode) { - // Reset the durations from the first pass so they aren't included in the - // final amounts. This seems counterintuitive, since we're intentionally - // not measuring part of the render phase, but this makes it match what we - // do in Concurrent Mode. - primaryChildFragment.actualDuration = 0; - primaryChildFragment.actualStartTime = -1; - primaryChildFragment.selfBaseDuration = - currentPrimaryChildFragment.selfBaseDuration; - primaryChildFragment.treeBaseDuration = - currentPrimaryChildFragment.treeBaseDuration; - } // The fallback fiber was added as a deletion effect during the first pass. - // However, since we're going to remain on the fallback, we no longer want - // to delete it. So we need to remove it from the list. Deletions are stored - // on the same list as effects. We want to keep the effects from the primary - // tree. So we copy the primary child fragment's effect list, which does not - // include the fallback deletion effect. - - var progressedLastEffect = primaryChildFragment.lastEffect; - - if (progressedLastEffect !== null) { - workInProgress.firstEffect = primaryChildFragment.firstEffect; - workInProgress.lastEffect = progressedLastEffect; - progressedLastEffect.nextEffect = null; - } else { - // TODO: Reset this somewhere else? Lol legacy mode is so weird. - workInProgress.firstEffect = workInProgress.lastEffect = null; - } - } else { - primaryChildFragment = createWorkInProgressOffscreenFiber( - currentPrimaryChildFragment, - primaryChildProps - ); - } - - var fallbackChildFragment; - - if (currentFallbackChildFragment !== null) { - fallbackChildFragment = createWorkInProgress( - currentFallbackChildFragment, - fallbackChildren - ); - } else { - fallbackChildFragment = createFiberFromFragment( - fallbackChildren, - mode, - renderLanes, - null - ); // Needs a placement effect because the parent (the Suspense boundary) already - // mounted but this is a new fiber. - - fallbackChildFragment.effectTag |= Placement; - } - - fallbackChildFragment.return = workInProgress; - primaryChildFragment.return = workInProgress; - primaryChildFragment.sibling = fallbackChildFragment; - workInProgress.child = primaryChildFragment; - return fallbackChildFragment; -} - -function scheduleWorkOnFiber(fiber, renderLanes) { - fiber.lanes = mergeLanes(fiber.lanes, renderLanes); var alternate = fiber.alternate; - if (alternate !== null) { - alternate.lanes = mergeLanes(alternate.lanes, renderLanes); + if (alternate !== null && alternate.expirationTime < renderExpirationTime) { + alternate.expirationTime = renderExpirationTime; } - scheduleWorkOnParentPath(fiber.return, renderLanes); + scheduleWorkOnParentPath(fiber.return, renderExpirationTime); } function propagateSuspenseContextChange( workInProgress, firstChild, - renderLanes + renderExpirationTime ) { // Mark any Suspense boundaries with fallbacks as having work to do. // If they were previously forced into fallbacks, they may now be able @@ -13855,7 +13128,7 @@ function propagateSuspenseContextChange( var state = node.memoizedState; if (state !== null) { - scheduleWorkOnFiber(node, renderLanes); + scheduleWorkOnFiber(node, renderExpirationTime); } } else if (node.tag === SuspenseListComponent) { // If the tail is hidden there might not be an Suspense boundaries @@ -13863,7 +13136,7 @@ function propagateSuspenseContextChange( // list itself. // We don't have to traverse to the children of the list since // the list will propagate the change when it rerenders. - scheduleWorkOnFiber(node, renderLanes); + scheduleWorkOnFiber(node, renderExpirationTime); } else if (node.child !== null) { node.child.return = node; node = node.child; @@ -14105,7 +13378,11 @@ function initSuspenseListRenderState( // in fallback state. Then we render each row in the tail one-by-one. // That happens in the completeWork phase without going back to beginWork. -function updateSuspenseListComponent(current, workInProgress, renderLanes) { +function updateSuspenseListComponent( + current, + workInProgress, + renderExpirationTime +) { var nextProps = workInProgress.pendingProps; var revealOrder = nextProps.revealOrder; var tailMode = nextProps.tail; @@ -14113,7 +13390,7 @@ function updateSuspenseListComponent(current, workInProgress, renderLanes) { validateRevealOrder(revealOrder); validateTailOptions(tailMode, revealOrder); validateSuspenseListChildren(newChildren, revealOrder); - reconcileChildren(current, workInProgress, newChildren, renderLanes); + reconcileChildren(current, workInProgress, newChildren, renderExpirationTime); var suspenseContext = suspenseStackCursor.current; var shouldForceFallback = hasSuspenseContext( suspenseContext, @@ -14137,7 +13414,7 @@ function updateSuspenseListComponent(current, workInProgress, renderLanes) { propagateSuspenseContextChange( workInProgress, workInProgress.child, - renderLanes + renderExpirationTime ); } @@ -14147,7 +13424,7 @@ function updateSuspenseListComponent(current, workInProgress, renderLanes) { pushSuspenseContext(workInProgress, suspenseContext); if ((workInProgress.mode & BlockingMode) === NoMode) { - // In legacy mode, SuspenseList doesn't work so we just + // Outside of blocking mode, SuspenseList doesn't work so we just // use make it a noop by treating it as the default revealOrder. workInProgress.memoizedState = null; } else { @@ -14237,7 +13514,7 @@ function updateSuspenseListComponent(current, workInProgress, renderLanes) { return workInProgress.child; } -function updatePortalComponent(current, workInProgress, renderLanes) { +function updatePortalComponent(current, workInProgress, renderExpirationTime) { pushHostContainer(workInProgress, workInProgress.stateNode.containerInfo); var nextChildren = workInProgress.pendingProps; @@ -14251,18 +13528,21 @@ function updatePortalComponent(current, workInProgress, renderLanes) { workInProgress, null, nextChildren, - renderLanes + renderExpirationTime ); } else { - reconcileChildren(current, workInProgress, nextChildren, renderLanes); + reconcileChildren( + current, + workInProgress, + nextChildren, + renderExpirationTime + ); } return workInProgress.child; } -var hasWarnedAboutUsingNoValuePropOnContextProvider = false; - -function updateContextProvider(current, workInProgress, renderLanes) { +function updateContextProvider(current, workInProgress, renderExpirationTime) { var providerType = workInProgress.type; var context = providerType._context; var newProps = workInProgress.pendingProps; @@ -14270,16 +13550,6 @@ function updateContextProvider(current, workInProgress, renderLanes) { var newValue = newProps.value; { - if (!("value" in newProps)) { - if (!hasWarnedAboutUsingNoValuePropOnContextProvider) { - hasWarnedAboutUsingNoValuePropOnContextProvider = true; - - error( - "The `value` prop is required for the ``. Did you misspell it or forget to pass it?" - ); - } - } - var providerPropTypes = workInProgress.type.propTypes; if (providerPropTypes) { @@ -14299,24 +13569,29 @@ function updateContextProvider(current, workInProgress, renderLanes) { return bailoutOnAlreadyFinishedWork( current, workInProgress, - renderLanes + renderExpirationTime ); } } else { // The context value changed. Search for matching consumers and schedule // them to update. - propagateContextChange(workInProgress, context, changedBits, renderLanes); + propagateContextChange( + workInProgress, + context, + changedBits, + renderExpirationTime + ); } } var newChildren = newProps.children; - reconcileChildren(current, workInProgress, newChildren, renderLanes); + reconcileChildren(current, workInProgress, newChildren, renderExpirationTime); return workInProgress.child; } var hasWarnedAboutUsingContextAsConsumer = false; -function updateContextConsumer(current, workInProgress, renderLanes) { +function updateContextConsumer(current, workInProgress, renderExpirationTime) { var context = workInProgress.type; // The logic below for Context differs depending on PROD or DEV mode. In // DEV mode, we create a separate object for Context.Consumer that acts // like a proxy to Context. This proxy object adds unnecessary code in PROD @@ -14359,7 +13634,7 @@ function updateContextConsumer(current, workInProgress, renderLanes) { } } - prepareToReadContext(workInProgress, renderLanes); + prepareToReadContext(workInProgress, renderExpirationTime); var newValue = readContext(context, newProps.unstable_observedBits); var newChildren; @@ -14371,7 +13646,7 @@ function updateContextConsumer(current, workInProgress, renderLanes) { } // React DevTools reads this flag. workInProgress.effectTag |= PerformedWork; - reconcileChildren(current, workInProgress, newChildren, renderLanes); + reconcileChildren(current, workInProgress, newChildren, renderExpirationTime); return workInProgress.child; } @@ -14379,7 +13654,13 @@ function markWorkInProgressReceivedUpdate() { didReceiveUpdate = true; } -function bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes) { +function bailoutOnAlreadyFinishedWork( + current, + workInProgress, + renderExpirationTime +) { + cancelWorkTimer(workInProgress); + if (current !== null) { // Reuse previous dependencies workInProgress.dependencies = current.dependencies; @@ -14390,9 +13671,15 @@ function bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes) { stopProfilerTimerIfRunning(); } - markSkippedUpdateLanes(workInProgress.lanes); // Check if the children have any pending work. + var updateExpirationTime = workInProgress.expirationTime; - if (!includesSomeLane(renderLanes, workInProgress.childLanes)) { + if (updateExpirationTime !== NoWork) { + markUnprocessedUpdateTime(updateExpirationTime); + } // Check if the children have any pending work. + + var childExpirationTime = workInProgress.childExpirationTime; + + 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. @@ -14460,8 +13747,8 @@ function remountFiber(current, oldWorkInProgress, newWorkInProgress) { } } -function beginWork(current, workInProgress, renderLanes) { - var updateLanes = workInProgress.lanes; +function beginWork(current, workInProgress, renderExpirationTime) { + var updateExpirationTime = workInProgress.expirationTime; { if (workInProgress._debugNeedsRemount && current !== null) { @@ -14475,7 +13762,7 @@ function beginWork(current, workInProgress, renderLanes) { workInProgress.pendingProps, workInProgress._debugOwner || null, workInProgress.mode, - workInProgress.lanes + workInProgress.expirationTime ) ); } @@ -14493,7 +13780,7 @@ function beginWork(current, workInProgress, renderLanes) { // If props or context changed, mark the fiber as having performed work. // This may be unset if the props are determined to be equal later (memo). didReceiveUpdate = true; - } else if (!includesSomeLane(renderLanes, updateLanes)) { + } else if (updateExpirationTime < renderExpirationTime) { didReceiveUpdate = false; // 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 // in this optimized path, mostly pushing stuff onto the stack. @@ -14505,6 +13792,20 @@ function beginWork(current, workInProgress, renderLanes) { case HostComponent: pushHostContext(workInProgress); + + if ( + workInProgress.mode & ConcurrentMode && + renderExpirationTime !== Never && + shouldDeprioritizeSubtree(workInProgress.type) + ) { + { + markSpawnedWork(Never); + } // Schedule this fiber to re-render at offscreen priority. Then bailout. + + workInProgress.expirationTime = workInProgress.childExpirationTime = Never; + return null; + } + break; case ClassComponent: { @@ -14533,10 +13834,8 @@ function beginWork(current, workInProgress, renderLanes) { case Profiler: { // Profiler should only call onRender when one of its descendants actually rendered. - var hasChildWork = includesSomeLane( - renderLanes, - workInProgress.childLanes - ); + var hasChildWork = + workInProgress.childExpirationTime >= renderExpirationTime; if (hasChildWork) { workInProgress.effectTag |= Update; @@ -14559,19 +13858,21 @@ function beginWork(current, workInProgress, renderLanes) { // child fragment. var primaryChildFragment = workInProgress.child; - var primaryChildLanes = primaryChildFragment.childLanes; + var primaryChildExpirationTime = + primaryChildFragment.childExpirationTime; - if (includesSomeLane(renderLanes, primaryChildLanes)) { + 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, workInProgress, - renderLanes + renderExpirationTime ); } else { - // The primary child fragment does not have pending work marked - // on it pushSuspenseContext( workInProgress, setDefaultShallowSuspenseContext(suspenseStackCursor.current) @@ -14581,7 +13882,7 @@ function beginWork(current, workInProgress, renderLanes) { var child = bailoutOnAlreadyFinishedWork( current, workInProgress, - renderLanes + renderExpirationTime ); if (child !== null) { @@ -14605,10 +13906,8 @@ function beginWork(current, workInProgress, renderLanes) { case SuspenseListComponent: { var didSuspendBefore = (current.effectTag & DidCapture) !== NoEffect; - var _hasChildWork = includesSomeLane( - renderLanes, - workInProgress.childLanes - ); + var _hasChildWork = + workInProgress.childExpirationTime >= renderExpirationTime; if (didSuspendBefore) { if (_hasChildWork) { @@ -14620,7 +13919,7 @@ function beginWork(current, workInProgress, renderLanes) { return updateSuspenseListComponent( current, workInProgress, - renderLanes + renderExpirationTime ); } // If none of the children had any work, that means that none of // them got retried so they'll still be blocked in the same way @@ -14638,7 +13937,6 @@ function beginWork(current, workInProgress, renderLanes) { // update in the past but didn't complete it. renderState.rendering = null; renderState.tail = null; - renderState.lastEffect = null; } pushSuspenseContext(workInProgress, suspenseStackCursor.current); @@ -14652,35 +13950,19 @@ function beginWork(current, workInProgress, renderLanes) { return null; } } - - case OffscreenComponent: - case LegacyHiddenComponent: { - // Need to check if the tree still needs to be deferred. This is - // almost identical to the logic used in the normal update path, - // so we'll just enter that. The only difference is we'll bail out - // at the next level instead of this one, because the child props - // have not changed. Which is fine. - // TODO: Probably should refactor `beginWork` to split the bailout - // path from the normal path. I'm tempted to do a labeled break here - // but I won't :) - workInProgress.lanes = NoLanes; - return updateOffscreenComponent(current, workInProgress, renderLanes); - } } - return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes); + return bailoutOnAlreadyFinishedWork( + current, + workInProgress, + renderExpirationTime + ); } else { - if ((current.effectTag & ForceUpdateForLegacySuspense) !== NoEffect) { - // This is a special case that only exists for legacy mode. - // See https://github.com/facebook/react/pull/19216. - didReceiveUpdate = true; - } else { - // An update was scheduled on this fiber, but there are no new props - // nor legacy context. Set this to false. If an update queue or context - // consumer produces a changed value, it will set this to true. Otherwise, - // the component will assume the children have not changed and bail out. - didReceiveUpdate = false; - } + // An update was scheduled on this fiber, but there are no new props + // nor legacy context. Set this to false. If an update queue or context + // consumer produces a changed value, it will set this to true. Otherwise, + // the component will assume the children have not changed and bail out. + didReceiveUpdate = false; } } else { didReceiveUpdate = false; @@ -14690,7 +13972,7 @@ function beginWork(current, workInProgress, renderLanes) { // sometimes bails out later in the begin phase. This indicates that we should // move this assignment out of the common path and into each branch. - workInProgress.lanes = NoLanes; + workInProgress.expirationTime = NoWork; switch (workInProgress.tag) { case IndeterminateComponent: { @@ -14698,7 +13980,7 @@ function beginWork(current, workInProgress, renderLanes) { current, workInProgress, workInProgress.type, - renderLanes + renderExpirationTime ); } @@ -14708,8 +13990,8 @@ function beginWork(current, workInProgress, renderLanes) { current, workInProgress, elementType, - updateLanes, - renderLanes + updateExpirationTime, + renderExpirationTime ); } @@ -14725,7 +14007,7 @@ function beginWork(current, workInProgress, renderLanes) { workInProgress, _Component, resolvedProps, - renderLanes + renderExpirationTime ); } @@ -14743,24 +14025,32 @@ function beginWork(current, workInProgress, renderLanes) { workInProgress, _Component2, _resolvedProps, - renderLanes + renderExpirationTime ); } case HostRoot: - return updateHostRoot(current, workInProgress, renderLanes); + return updateHostRoot(current, workInProgress, renderExpirationTime); case HostComponent: - return updateHostComponent(current, workInProgress, renderLanes); + return updateHostComponent(current, workInProgress, renderExpirationTime); case HostText: return updateHostText(); case SuspenseComponent: - return updateSuspenseComponent(current, workInProgress, renderLanes); + return updateSuspenseComponent( + current, + workInProgress, + renderExpirationTime + ); case HostPortal: - return updatePortalComponent(current, workInProgress, renderLanes); + return updatePortalComponent( + current, + workInProgress, + renderExpirationTime + ); case ForwardRef: { var type = workInProgress.type; @@ -14776,24 +14066,32 @@ function beginWork(current, workInProgress, renderLanes) { workInProgress, type, _resolvedProps2, - renderLanes + renderExpirationTime ); } case Fragment: - return updateFragment(current, workInProgress, renderLanes); + return updateFragment(current, workInProgress, renderExpirationTime); case Mode: - return updateMode(current, workInProgress, renderLanes); + return updateMode(current, workInProgress, renderExpirationTime); case Profiler: - return updateProfiler(current, workInProgress, renderLanes); + return updateProfiler(current, workInProgress, renderExpirationTime); case ContextProvider: - return updateContextProvider(current, workInProgress, renderLanes); + return updateContextProvider( + current, + workInProgress, + renderExpirationTime + ); case ContextConsumer: - return updateContextConsumer(current, workInProgress, renderLanes); + return updateContextConsumer( + current, + workInProgress, + renderExpirationTime + ); case MemoComponent: { var _type2 = workInProgress.type; @@ -14822,8 +14120,8 @@ function beginWork(current, workInProgress, renderLanes) { workInProgress, _type2, _resolvedProps3, - updateLanes, - renderLanes + updateExpirationTime, + renderExpirationTime ); } @@ -14833,8 +14131,8 @@ function beginWork(current, workInProgress, renderLanes) { workInProgress, workInProgress.type, workInProgress.pendingProps, - updateLanes, - renderLanes + updateExpirationTime, + renderExpirationTime ); } @@ -14852,32 +14150,16 @@ function beginWork(current, workInProgress, renderLanes) { workInProgress, _Component3, _resolvedProps4, - renderLanes + renderExpirationTime ); } case SuspenseListComponent: { - return updateSuspenseListComponent(current, workInProgress, renderLanes); - } - - case FundamentalComponent: { - break; - } - - case ScopeComponent: { - break; - } - - case Block: { - break; - } - - case OffscreenComponent: { - return updateOffscreenComponent(current, workInProgress, renderLanes); - } - - case LegacyHiddenComponent: { - return updateLegacyHiddenComponent(current, workInProgress, renderLanes); + return updateSuspenseListComponent( + current, + workInProgress, + renderExpirationTime + ); } } @@ -15267,7 +14549,7 @@ function cutOffTailIfNeeded(renderState, hasRenderedATailFallback) { } } -function completeWork(current, workInProgress, renderLanes) { +function completeWork(current, workInProgress, renderExpirationTime) { var newProps = workInProgress.pendingProps; switch (workInProgress.tag) { @@ -15296,7 +14578,6 @@ function completeWork(current, workInProgress, renderLanes) { case HostRoot: { popHostContainer(workInProgress); popTopLevelContextObject(workInProgress); - resetWorkInProgressVersions(); var fiberRoot = workInProgress.stateNode; if (fiberRoot.pendingContext) { @@ -15313,12 +14594,6 @@ function completeWork(current, workInProgress, renderLanes) { // If we hydrated, then we'll need to schedule an update for // the commit side-effects on the root. markUpdate(workInProgress); - } else if (!fiberRoot.hydrate) { - // Schedule an effect to clear this container at the start of the next commit. - // This handles the case of React rendering into a container with previous children. - // It's also safe to do for updates too, because current.child would only be null - // if the previous render was null (so the the container would already be empty). - workInProgress.effectTag |= Snapshot; } } @@ -15437,11 +14712,7 @@ function completeWork(current, workInProgress, renderLanes) { if ((workInProgress.effectTag & DidCapture) !== NoEffect) { // Something suspended. Re-render with the fallback children. - workInProgress.lanes = renderLanes; // Do not reset the effect list. - - if ((workInProgress.mode & ProfileMode) !== NoMode) { - transferActualDuration(workInProgress); - } + workInProgress.expirationTime = renderExpirationTime; // Do not reset the effect list. return workInProgress; } @@ -15454,6 +14725,29 @@ function completeWork(current, workInProgress, renderLanes) { } else { var prevState = current.memoizedState; prevDidTimeout = prevState !== null; + + if (!nextDidTimeout && prevState !== null) { + // We just switched from the fallback to the normal children. + // Delete the fallback. + // TODO: Would it be better to store the fallback fragment on + // the stateNode during the begin phase? + var currentFallbackChild = current.child.sibling; + + if (currentFallbackChild !== null) { + // Deletions go at the beginning of the return fiber's effect list + var first = workInProgress.firstEffect; + + if (first !== null) { + workInProgress.firstEffect = currentFallbackChild; + currentFallbackChild.nextEffect = first; + } else { + workInProgress.firstEffect = workInProgress.lastEffect = currentFallbackChild; + currentFallbackChild.nextEffect = null; + } + + currentFallbackChild.effectTag = Deletion; + } + } } if (nextDidTimeout && !prevDidTimeout) { @@ -15508,11 +14802,6 @@ function completeWork(current, workInProgress, renderLanes) { case HostPortal: popHostContainer(workInProgress); updateHostContainer(workInProgress); - - if (current === null) { - preparePortalMount(workInProgress.stateNode.containerInfo); - } - return null; case ContextProvider: @@ -15599,7 +14888,7 @@ function completeWork(current, workInProgress, renderLanes) { workInProgress.lastEffect = renderState.lastEffect; // Reset the child fibers to their original state. - resetChildFibers(workInProgress, renderLanes); // Set up the Suspense Context to force suspense and immediately + resetChildFibers(workInProgress, renderExpirationTime); // Set up the Suspense Context to force suspense and immediately // rerender the children. pushSuspenseContext( @@ -15640,8 +14929,7 @@ function completeWork(current, workInProgress, renderLanes) { if ( renderState.tail === null && renderState.tailMode === "hidden" && - !renderedTail.alternate && - !getIsHydrating() // We don't cut it if we're hydrating. + !renderedTail.alternate ) { // We need to delete the row we just rendered. // Reset the effect list to what it was before we rendered this @@ -15660,7 +14948,7 @@ function completeWork(current, workInProgress, renderLanes) { // the expiration. now() * 2 - renderState.renderingStartTime > renderState.tailExpiration && - renderLanes !== OffscreenLane + renderExpirationTime > Never ) { // We have now passed our CPU deadline and we'll just give up further // attempts to render the main content and only render fallbacks. @@ -15673,10 +14961,11 @@ function completeWork(current, workInProgress, renderLanes) { // So we'll pick it back up the very next render pass once we've had // an opportunity to yield for paint. - workInProgress.lanes = renderLanes; + var nextPriority = renderExpirationTime - 1; + workInProgress.expirationTime = workInProgress.childExpirationTime = nextPriority; { - markSpawnedWork(renderLanes); + markSpawnedWork(nextPriority); } } } @@ -15743,38 +15032,6 @@ function completeWork(current, workInProgress, renderLanes) { return null; } - - case FundamentalComponent: { - break; - } - - case ScopeComponent: { - break; - } - - case Block: - break; - - case OffscreenComponent: - case LegacyHiddenComponent: { - popRenderLanes(workInProgress); - - if (current !== null) { - var _nextState = workInProgress.memoizedState; - var _prevState = current.memoizedState; - var prevIsHidden = _prevState !== null; - var nextIsHidden = _nextState !== null; - - if ( - prevIsHidden !== nextIsHidden && - newProps.mode !== "unstable-defer-without-hiding" - ) { - workInProgress.effectTag |= Update; - } - } - - return null; - } } { @@ -15786,7 +15043,7 @@ function completeWork(current, workInProgress, renderLanes) { } } -function unwindWork(workInProgress, renderLanes) { +function unwindWork(workInProgress, renderExpirationTime) { switch (workInProgress.tag) { case ClassComponent: { var Component = workInProgress.type; @@ -15799,11 +15056,6 @@ function unwindWork(workInProgress, renderLanes) { if (effectTag & ShouldCapture) { workInProgress.effectTag = (effectTag & ~ShouldCapture) | DidCapture; - - if ((workInProgress.mode & ProfileMode) !== NoMode) { - transferActualDuration(workInProgress); - } - return workInProgress; } @@ -15813,7 +15065,6 @@ function unwindWork(workInProgress, renderLanes) { case HostRoot: { popHostContainer(workInProgress); popTopLevelContextObject(workInProgress); - resetWorkInProgressVersions(); var _effectTag = workInProgress.effectTag; if (!((_effectTag & DidCapture) === NoEffect)) { @@ -15840,10 +15091,6 @@ function unwindWork(workInProgress, renderLanes) { if (_effectTag2 & ShouldCapture) { workInProgress.effectTag = (_effectTag2 & ~ShouldCapture) | DidCapture; // Captured a suspense effect. Re-render the boundary. - if ((workInProgress.mode & ProfileMode) !== NoMode) { - transferActualDuration(workInProgress); - } - return workInProgress; } @@ -15865,11 +15112,6 @@ function unwindWork(workInProgress, renderLanes) { popProvider(workInProgress); return null; - case OffscreenComponent: - case LegacyHiddenComponent: - popRenderLanes(workInProgress); - return null; - default: return null; } @@ -15890,7 +15132,6 @@ function unwindInterruptedWork(interruptedWork) { case HostRoot: { popHostContainer(interruptedWork); popTopLevelContextObject(interruptedWork); - resetWorkInProgressVersions(); break; } @@ -15914,11 +15155,6 @@ function unwindInterruptedWork(interruptedWork) { case ContextProvider: popProvider(interruptedWork); break; - - case OffscreenComponent: - case LegacyHiddenComponent: - popRenderLanes(interruptedWork); - break; } } @@ -15932,6 +15168,8 @@ function createCapturedValue(value, source) { }; } +// Module provided by RN: + if ( !( typeof ReactNativePrivateInterface.ReactFiberErrorDialog.showErrorDialog === @@ -15943,88 +15181,118 @@ if ( ); } -function showErrorDialog(boundary, errorInfo) { - var capturedError = { - componentStack: errorInfo.stack !== null ? errorInfo.stack : "", - error: errorInfo.value, - errorBoundary: - boundary !== null && boundary.tag === ClassComponent - ? boundary.stateNode - : null - }; +function showErrorDialog(capturedError) { return ReactNativePrivateInterface.ReactFiberErrorDialog.showErrorDialog( capturedError ); } -function logCapturedError(boundary, errorInfo) { - try { - var logError = showErrorDialog(boundary, errorInfo); // Allow injected showErrorDialog() to prevent default console.error logging. - // This enables renderers like ReactNative to better manage redbox behavior. +function logCapturedError(capturedError) { + var logError = showErrorDialog(capturedError); // Allow injected showErrorDialog() to prevent default console.error logging. + // This enables renderers like ReactNative to better manage redbox behavior. - if (logError === false) { - return; + if (logError === false) { + return; + } + + var error = capturedError.error; + + { + var componentName = capturedError.componentName, + componentStack = capturedError.componentStack, + errorBoundaryName = capturedError.errorBoundaryName, + errorBoundaryFound = capturedError.errorBoundaryFound, + willRetry = capturedError.willRetry; // Browsers support silencing uncaught errors by calling + // `preventDefault()` in window `error` handler. + // We record this information as an expando on the error. + + if (error != null && error._suppressLogging) { + if (errorBoundaryFound && willRetry) { + // The error is recoverable and was silenced. + // Ignore it and don't print the stack addendum. + // This is handy for testing error boundaries without noise. + return; + } // The error is fatal. Since the silencing might have + // been accidental, we'll surface it anyway. + // However, the browser would have silenced the original error + // so we'll print it first, and then print the stack addendum. + + console["error"](error); // Don't transform to our wrapper + // For a more detailed description of this block, see: + // https://github.com/facebook/react/pull/13384 } - var error = errorInfo.value; + var componentNameMessage = componentName + ? "The above error occurred in the <" + componentName + "> component:" + : "The above error occurred in one of your React components:"; + var errorBoundaryMessage; // errorBoundaryFound check is sufficient; errorBoundaryName check is to satisfy Flow. - if (true) { - var source = errorInfo.source; - var stack = errorInfo.stack; - var componentStack = stack !== null ? stack : ""; // Browsers support silencing uncaught errors by calling - // `preventDefault()` in window `error` handler. - // We record this information as an expando on the error. - - if (error != null && error._suppressLogging) { - if (boundary.tag === ClassComponent) { - // The error is recoverable and was silenced. - // Ignore it and don't print the stack addendum. - // This is handy for testing error boundaries without noise. - return; - } // The error is fatal. Since the silencing might have - // been accidental, we'll surface it anyway. - // However, the browser would have silenced the original error - // so we'll print it first, and then print the stack addendum. - - console["error"](error); // Don't transform to our wrapper - // For a more detailed description of this block, see: - // https://github.com/facebook/react/pull/13384 - } - - var componentName = source ? getComponentName(source.type) : null; - var componentNameMessage = componentName - ? "The above error occurred in the <" + componentName + "> component:" - : "The above error occurred in one of your React components:"; - var errorBoundaryMessage; - var errorBoundaryName = getComponentName(boundary.type); - - if (errorBoundaryName) { + if (errorBoundaryFound && errorBoundaryName) { + if (willRetry) { errorBoundaryMessage = "React will try to recreate this component tree from scratch " + ("using the error boundary you provided, " + errorBoundaryName + "."); } else { errorBoundaryMessage = - "Consider adding an error boundary to your tree to customize error handling behavior.\n" + - "Visit https://fb.me/react-error-boundaries to learn more about error boundaries."; + "This error was initially handled by the error boundary " + + errorBoundaryName + + ".\n" + + "Recreating the tree from scratch failed so React will unmount the tree."; } - - var combinedMessage = - componentNameMessage + - "\n" + - componentStack + - "\n\n" + - ("" + errorBoundaryMessage); // In development, we provide our own message with just the component stack. - // We don't include the original error message and JS stack because the browser - // has already printed it. Even if the application swallows the error, it is still - // displayed by the browser thanks to the DEV-only fake event trick in ReactErrorUtils. - - console["error"](combinedMessage); // Don't transform to our wrapper } else { - // In production, we print the error directly. - // This will include the message, the JS stack, and anything the browser wants to show. - // We pass the error object instead of custom message so that the browser displays the error natively. - console["error"](error); // Don't transform to our wrapper + errorBoundaryMessage = + "Consider adding an error boundary to your tree to customize error handling behavior.\n" + + "Visit https://fb.me/react-error-boundaries to learn more about error boundaries."; } + + var combinedMessage = + "" + + componentNameMessage + + componentStack + + "\n\n" + + ("" + errorBoundaryMessage); // In development, we provide our own message with just the component stack. + // We don't include the original error message and JS stack because the browser + // has already printed it. Even if the application swallows the error, it is still + // displayed by the browser thanks to the DEV-only fake event trick in ReactErrorUtils. + + console["error"](combinedMessage); // Don't transform to our wrapper + } +} + +var didWarnAboutUndefinedSnapshotBeforeUpdate = null; + +{ + didWarnAboutUndefinedSnapshotBeforeUpdate = new Set(); +} + +var PossiblyWeakSet = typeof WeakSet === "function" ? WeakSet : Set; +function logError(boundary, errorInfo) { + var source = errorInfo.source; + var stack = errorInfo.stack; + + if (stack === null && source !== null) { + stack = getStackByFiberInDevAndProd(source); + } + + var capturedError = { + componentName: source !== null ? getComponentName(source.type) : null, + componentStack: stack !== null ? stack : "", + error: errorInfo.value, + errorBoundary: null, + errorBoundaryName: null, + errorBoundaryFound: false, + willRetry: false + }; + + if (boundary !== null && boundary.tag === ClassComponent) { + capturedError.errorBoundary = boundary.stateNode; + capturedError.errorBoundaryName = getComponentName(boundary.type); + capturedError.errorBoundaryFound = true; + capturedError.willRetry = true; + } + + try { + logCapturedError(capturedError); } catch (e) { // This method must not throw, or React internal state will get messed up. // If console.error is overridden, or logCapturedError() shows a dialog that throws, @@ -16036,347 +15304,16 @@ function logCapturedError(boundary, errorInfo) { } } -var PossiblyWeakMap$1 = typeof WeakMap === "function" ? WeakMap : Map; - -function createRootErrorUpdate(fiber, errorInfo, lane) { - var update = createUpdate(NoTimestamp, lane, null); // Unmount the root by rendering null. - - update.tag = CaptureUpdate; // Caution: React DevTools currently depends on this property - // being called "element". - - update.payload = { - element: null - }; - var error = errorInfo.value; - - update.callback = function() { - onUncaughtError(error); - logCapturedError(fiber, errorInfo); - }; - - return update; -} - -function createClassErrorUpdate(fiber, errorInfo, lane) { - var update = createUpdate(NoTimestamp, lane, null); - update.tag = CaptureUpdate; - var getDerivedStateFromError = fiber.type.getDerivedStateFromError; - - if (typeof getDerivedStateFromError === "function") { - var error$1 = errorInfo.value; - - update.payload = function() { - logCapturedError(fiber, errorInfo); - return getDerivedStateFromError(error$1); - }; - } - - var inst = fiber.stateNode; - - if (inst !== null && typeof inst.componentDidCatch === "function") { - update.callback = function callback() { - { - markFailedErrorBoundaryForHotReloading(fiber); - } - - if (typeof getDerivedStateFromError !== "function") { - // To preserve the preexisting retry behavior of error boundaries, - // we keep track of which ones already failed during this batch. - // This gets reset before we yield back to the browser. - // TODO: Warn in strict mode if getDerivedStateFromError is - // not defined. - markLegacyErrorBoundaryAsFailed(this); // Only log here if componentDidCatch is the only error boundary method defined - - logCapturedError(fiber, errorInfo); - } - - var error$1 = errorInfo.value; - var stack = errorInfo.stack; - this.componentDidCatch(error$1, { - componentStack: stack !== null ? stack : "" - }); - - { - if (typeof getDerivedStateFromError !== "function") { - // If componentDidCatch is the only error boundary method defined, - // then it needs to call setState to recover from errors. - // If no state update is scheduled then the boundary will swallow the error. - if (!includesSomeLane(fiber.lanes, SyncLane)) { - error( - "%s: Error boundaries should implement getDerivedStateFromError(). " + - "In that method, return a state update to display an error message or fallback UI.", - getComponentName(fiber.type) || "Unknown" - ); - } - } - } - }; - } else { - update.callback = function() { - markFailedErrorBoundaryForHotReloading(fiber); - }; - } - - return update; -} - -function attachPingListener(root, wakeable, lanes) { - // Attach a listener to the promise to "ping" the root and retry. But only if - // one does not already exist for the lanes we're currently rendering (which - // acts like a "thread ID" here). - var pingCache = root.pingCache; - var threadIDs; - - if (pingCache === null) { - pingCache = root.pingCache = new PossiblyWeakMap$1(); - threadIDs = new Set(); - pingCache.set(wakeable, threadIDs); - } else { - threadIDs = pingCache.get(wakeable); - - if (threadIDs === undefined) { - threadIDs = new Set(); - pingCache.set(wakeable, threadIDs); - } - } - - if (!threadIDs.has(lanes)) { - // Memoize using the thread ID to prevent redundant listeners. - threadIDs.add(lanes); - var ping = pingSuspendedRoot.bind(null, root, wakeable, lanes); - wakeable.then(ping, ping); - } -} - -function throwException( - root, - returnFiber, - sourceFiber, - value, - rootRenderLanes -) { - // The source fiber did not complete. - sourceFiber.effectTag |= Incomplete; // Its effect list is no longer valid. - - sourceFiber.firstEffect = sourceFiber.lastEffect = null; - - if ( - value !== null && - typeof value === "object" && - typeof value.then === "function" - ) { - // This is a wakeable. - var wakeable = value; - - if ((sourceFiber.mode & BlockingMode) === NoMode) { - // Reset the memoizedState to what it was before we attempted - // to render it. - var currentSource = sourceFiber.alternate; - - if (currentSource) { - sourceFiber.updateQueue = currentSource.updateQueue; - sourceFiber.memoizedState = currentSource.memoizedState; - sourceFiber.lanes = currentSource.lanes; - } else { - sourceFiber.updateQueue = null; - sourceFiber.memoizedState = null; - } - } - - var hasInvisibleParentBoundary = hasSuspenseContext( - suspenseStackCursor.current, - InvisibleParentSuspenseContext - ); // Schedule the nearest Suspense to re-render the timed out view. - - var _workInProgress = returnFiber; - - do { - if ( - _workInProgress.tag === SuspenseComponent && - shouldCaptureSuspense(_workInProgress, hasInvisibleParentBoundary) - ) { - // Found the nearest boundary. - // Stash the promise on the boundary fiber. If the boundary times out, we'll - // attach another listener to flip the boundary back to its normal state. - var wakeables = _workInProgress.updateQueue; - - if (wakeables === null) { - var updateQueue = new Set(); - updateQueue.add(wakeable); - _workInProgress.updateQueue = updateQueue; - } else { - wakeables.add(wakeable); - } // If the boundary is outside of blocking 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 blocking mode tree. If the Suspense is outside of it, we - // should *not* suspend the commit. - - if ((_workInProgress.mode & BlockingMode) === NoMode) { - _workInProgress.effectTag |= DidCapture; - sourceFiber.effectTag |= ForceUpdateForLegacySuspense; // 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 | Incomplete); - - if (sourceFiber.tag === ClassComponent) { - var currentSourceFiber = sourceFiber.alternate; - - if (currentSourceFiber === 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; - } else { - // 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 update to - // prevent a bail out. - var update = createUpdate(NoTimestamp, SyncLane, null); - update.tag = ForceUpdate; - enqueueUpdate(sourceFiber, update); - } - } // The source fiber did not complete. Mark it with Sync priority to - // indicate that it still has pending work. - - sourceFiber.lanes = mergeLanes(sourceFiber.lanes, SyncLane); // Exit without suspending. - - return; - } // Confirmed that the boundary is in a concurrent mode tree. Continue - // with the normal suspend path. - // - // After this we'll use a set of heuristics to determine whether this - // render pass will run to completion or restart or "suspend" the commit. - // The actual logic for this is spread out in different places. - // - // This first principle is that if we're going to suspend when we complete - // a root, then we should also restart if we get an update or ping that - // might unsuspend it, and vice versa. The only reason to suspend is - // because you think you might want to restart before committing. However, - // it doesn't make sense to restart only while in the period we're suspended. - // - // Restarting too aggressively is also not good because it starves out any - // intermediate loading state. So we use heuristics to determine when. - // Suspense Heuristics - // - // If nothing threw a Promise or all the same fallbacks are already showing, - // then don't suspend/restart. - // - // If this is an initial render of a new tree of Suspense boundaries and - // those trigger a fallback, then don't suspend/restart. We want to ensure - // that we can show the initial loading state as quickly as possible. - // - // If we hit a "Delayed" case, such as when we'd switch from content back into - // a fallback, then we should always suspend/restart. SuspenseConfig applies to - // this case. If none is defined, JND is used instead. - // - // If we're already showing a fallback and it gets "retried", allowing us to show - // another level, but there's still an inner boundary that would show a fallback, - // then we suspend/restart for 500ms since the last time we showed a fallback - // anywhere in the tree. This effectively throttles progressive loading into a - // consistent train of commits. This also gives us an opportunity to restart to - // get to the completed state slightly earlier. - // - // If there's ambiguity due to batching it's resolved in preference of: - // 1) "delayed", 2) "initial render", 3) "retry". - // - // We want to ensure that a "busy" state doesn't get force committed. We want to - // ensure that new initial loading states can commit as soon as possible. - - attachPingListener(root, wakeable, rootRenderLanes); - _workInProgress.effectTag |= ShouldCapture; - _workInProgress.lanes = rootRenderLanes; - 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( - (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." - ); - } // We didn't find a boundary that could handle this type of exception. Start - // over and traverse parent path again, this time treating the exception - // as an error. - - renderDidError(); - value = createCapturedValue(value, sourceFiber); - var workInProgress = returnFiber; - - do { - switch (workInProgress.tag) { - case HostRoot: { - var _errorInfo = value; - workInProgress.effectTag |= ShouldCapture; - var lane = pickArbitraryLane(rootRenderLanes); - workInProgress.lanes = mergeLanes(workInProgress.lanes, lane); - - var _update = createRootErrorUpdate(workInProgress, _errorInfo, lane); - - enqueueCapturedUpdate(workInProgress, _update); - return; - } - - case ClassComponent: - // Capture and retry - var errorInfo = value; - var ctor = workInProgress.type; - var instance = workInProgress.stateNode; - - if ( - (workInProgress.effectTag & DidCapture) === NoEffect && - (typeof ctor.getDerivedStateFromError === "function" || - (instance !== null && - typeof instance.componentDidCatch === "function" && - !isAlreadyFailedLegacyErrorBoundary(instance))) - ) { - workInProgress.effectTag |= ShouldCapture; - - var _lane = pickArbitraryLane(rootRenderLanes); - - workInProgress.lanes = mergeLanes(workInProgress.lanes, _lane); // Schedule the error boundary to re-render using updated state - - var _update2 = createClassErrorUpdate( - workInProgress, - errorInfo, - _lane - ); - - enqueueCapturedUpdate(workInProgress, _update2); - return; - } - - break; - } - - workInProgress = workInProgress.return; - } while (workInProgress !== null); -} - -var didWarnAboutUndefinedSnapshotBeforeUpdate = null; - -{ - didWarnAboutUndefinedSnapshotBeforeUpdate = new Set(); -} - -var PossiblyWeakSet = typeof WeakSet === "function" ? WeakSet : Set; - var callComponentWillUnmountWithTimer = function(current, instance) { + startPhaseTimer(current, "componentWillUnmount"); instance.props = current.memoizedProps; instance.state = current.memoizedState; { instance.componentWillUnmount(); } + + stopPhaseTimer(); }; // Capture errors so they don't interrupt unmounting. function safelyCallComponentWillUnmount(current, instance) { @@ -16440,6 +15377,7 @@ function commitBeforeMutationLifeCycles(current, finishedWork) { if (current !== null) { var prevProps = current.memoizedProps; var prevState = current.memoizedState; + startPhaseTimer(finishedWork, "getSnapshotBeforeUpdate"); var instance = finishedWork.stateNode; // 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. @@ -16495,16 +15433,14 @@ function commitBeforeMutationLifeCycles(current, finishedWork) { } instance.__reactInternalSnapshotBeforeUpdate = snapshot; + stopPhaseTimer(); } } return; } - case HostRoot: { - return; - } - + case HostRoot: case HostComponent: case HostText: case HostPortal: @@ -16588,8 +15524,9 @@ function commitHookEffectListMount(tag, finishedWork) { error( "An effect function must not return anything besides a function, " + - "which is used for clean-up.%s", - addendum + "which is used for clean-up.%s%s", + addendum, + getStackByFiberInDevAndProd(finishedWork) ); } } @@ -16600,33 +15537,33 @@ function commitHookEffectListMount(tag, finishedWork) { } } -function schedulePassiveEffects(finishedWork) { - var updateQueue = finishedWork.updateQueue; - var lastEffect = updateQueue !== null ? updateQueue.lastEffect : null; +function commitPassiveHookEffects(finishedWork) { + if ((finishedWork.effectTag & Passive) !== NoEffect) { + switch (finishedWork.tag) { + case FunctionComponent: + case ForwardRef: + case SimpleMemoComponent: + case Block: { + // TODO (#17945) We should call all passive destroy functions (for all fibers) + // before calling any create functions. The current approach only serializes + // these for a single fiber. + { + commitHookEffectListUnmount(Passive$1 | HasEffect, finishedWork); + commitHookEffectListMount(Passive$1 | HasEffect, finishedWork); + } - if (lastEffect !== null) { - var firstEffect = lastEffect.next; - var effect = firstEffect; - - do { - var _effect = effect, - next = _effect.next, - tag = _effect.tag; - - if ( - (tag & Passive$1) !== NoEffect$1 && - (tag & HasEffect) !== NoEffect$1 - ) { - enqueuePendingPassiveHookEffectUnmount(finishedWork, effect); - enqueuePendingPassiveHookEffectMount(finishedWork, effect); + break; } - - effect = next; - } while (effect !== firstEffect); + } } } -function commitLifeCycles(finishedRoot, current, finishedWork, committedLanes) { +function commitLifeCycles( + finishedRoot, + current, + finishedWork, + committedExpirationTime +) { switch (finishedWork.tag) { case FunctionComponent: case ForwardRef: @@ -16640,7 +15577,6 @@ function commitLifeCycles(finishedRoot, current, finishedWork, committedLanes) { commitHookEffectListMount(Layout | HasEffect, finishedWork); } - schedulePassiveEffects(finishedWork); return; } @@ -16649,9 +15585,10 @@ function commitLifeCycles(finishedRoot, current, finishedWork, committedLanes) { if (finishedWork.effectTag & Update) { if (current === null) { - // We could update instance props and state here, + startPhaseTimer(finishedWork, "componentDidMount"); // 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 && @@ -16684,12 +15621,15 @@ function commitLifeCycles(finishedRoot, current, finishedWork, committedLanes) { { instance.componentDidMount(); } + + stopPhaseTimer(); } else { var prevProps = finishedWork.elementType === finishedWork.type ? current.memoizedProps : resolveDefaultProps(finishedWork.type, current.memoizedProps); - var prevState = current.memoizedState; // We could update instance props and state here, + var prevState = current.memoizedState; + startPhaseTimer(finishedWork, "componentDidUpdate"); // 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. @@ -16729,9 +15669,10 @@ function commitLifeCycles(finishedRoot, current, finishedWork, committedLanes) { instance.__reactInternalSnapshotBeforeUpdate ); } + + stopPhaseTimer(); } - } // TODO: I think this is now always non-null by the time it reaches the - // commit phase. Consider removing the type check. + } var updateQueue = finishedWork.updateQueue; @@ -16774,8 +15715,6 @@ function commitLifeCycles(finishedRoot, current, finishedWork, committedLanes) { } case HostRoot: { - // TODO: I think this is now always non-null by the time it reaches the - // commit phase. Consider removing the type check. var _updateQueue = finishedWork.updateQueue; if (_updateQueue !== null) { @@ -16858,8 +15797,6 @@ function commitLifeCycles(finishedRoot, current, finishedWork, committedLanes) { case IncompleteClassComponent: case FundamentalComponent: case ScopeComponent: - case OffscreenComponent: - case LegacyHiddenComponent: return; } @@ -16893,8 +15830,9 @@ function commitAttachRef(finishedWork) { if (!ref.hasOwnProperty("current")) { error( "Unexpected ref object provided for %s. " + - "Use either a ref-setter function or React.createRef().", - getComponentName(finishedWork.type) + "Use either a ref-setter function or React.createRef().%s", + getComponentName(finishedWork.type), + getStackByFiberInDevAndProd(finishedWork) ); } } @@ -16934,25 +15872,42 @@ function commitUnmount(finishedRoot, current, renderPriorityLevel) { if (lastEffect !== null) { var firstEffect = lastEffect.next; - var effect = firstEffect; - do { - var _effect2 = effect, - destroy = _effect2.destroy, - tag = _effect2.tag; + { + // When the owner fiber is deleted, the destroy function of a passive + // effect hook is called during the synchronous commit phase. This is + // a concession to implementation complexity. Calling it in the + // passive effect phase (like they usually are, when dependencies + // change during an update) would require either traversing the + // children of the deleted fiber again, or including unmount effects + // as part of the fiber effect list. + // + // Because this is during the sync commit phase, we need to change + // the priority. + // + // TODO: Reconsider this implementation trade off. + var priorityLevel = + renderPriorityLevel > NormalPriority + ? NormalPriority + : renderPriorityLevel; + runWithPriority(priorityLevel, function() { + var effect = firstEffect; - if (destroy !== undefined) { - if ((tag & Passive$1) !== NoEffect$1) { - enqueuePendingPassiveHookEffectUnmount(current, effect); - } else { - { - safelyCallDestroy(current, destroy); + do { + var _effect3 = effect, + _destroy = _effect3.destroy, + _tag = _effect3.tag; + + if (_destroy !== undefined) { + { + safelyCallDestroy(current, _destroy); + } } - } - } - effect = effect.next; - } while (effect !== firstEffect); + effect = effect.next; + } while (effect !== firstEffect); + }); + } } } @@ -17009,7 +15964,7 @@ function commitNestedUnmounts(finishedRoot, root, renderPriorityLevel) { var node = root; while (true) { - commitUnmount(finishedRoot, node); // Visit children because they may contain more composite or host nodes. + commitUnmount(finishedRoot, node, renderPriorityLevel); // Visit children because they may contain more composite or host nodes. // Skip portals because commitUnmount() currently visits them recursively. if ( @@ -17039,30 +15994,27 @@ function commitNestedUnmounts(finishedRoot, root, renderPriorityLevel) { } } -function detachFiberMutation(fiber) { - // Cut off the return pointers to disconnect it from the tree. Ideally, we +function detachFiber(current) { + var alternate = current.alternate; // Cut off the return pointers to disconnect it from the tree. Ideally, we // should clear the child pointer of the parent alternate to let this // get GC:ed but we don't know which for sure which parent is the current // one so we'll settle for GC:ing the subtree of this child. This child // itself will be GC:ed when the parent updates the next time. - // Note: we cannot null out sibling here, otherwise it can cause issues - // with findDOMNode and how it requires the sibling field to carry out - // traversal in a later effect. See PR #16820. We now clear the sibling - // field after effects, see: detachFiberAfterEffects. - fiber.alternate = null; - fiber.child = null; - fiber.dependencies = null; - fiber.firstEffect = null; - fiber.lastEffect = null; - fiber.memoizedProps = null; - fiber.memoizedState = null; - fiber.pendingProps = null; - fiber.return = null; - fiber.stateNode = null; - fiber.updateQueue = null; - { - fiber._debugOwner = null; + current.return = null; + current.child = null; + current.memoizedState = null; + current.updateQueue = null; + current.dependencies = null; + current.alternate = null; + current.firstEffect = null; + current.lastEffect = null; + current.pendingProps = null; + current.memoizedProps = null; + current.stateNode = null; + + if (alternate !== null) { + detachFiber(alternate); } } @@ -17100,15 +16052,10 @@ function commitContainer(finishedWork) { function commitDeletion(finishedRoot, current, renderPriorityLevel) { { // Detach refs and call componentWillUnmount() on the whole subtree. - commitNestedUnmounts(finishedRoot, current); + commitNestedUnmounts(finishedRoot, current, renderPriorityLevel); } - var alternate = current.alternate; - detachFiberMutation(current); - - if (alternate !== null) { - detachFiberMutation(alternate); - } + detachFiber(current); } function commitWork(current, finishedWork) { @@ -17145,15 +16092,6 @@ function commitWork(current, finishedWork) { attachSuspenseRetryListeners(finishedWork); return; } - - case HostRoot: { - break; - } - - case OffscreenComponent: - case LegacyHiddenComponent: { - return; - } } commitContainer(finishedWork); @@ -17163,19 +16101,22 @@ function commitWork(current, finishedWork) { function commitSuspenseComponent(finishedWork) { var newState = finishedWork.memoizedState; + var primaryChildParent = finishedWork; - if (newState !== null) { + if (newState === null); + else { + primaryChildParent = finishedWork.child; markCommitTimeOfFallback(); } } function attachSuspenseRetryListeners(finishedWork) { - // If this boundary just timed out, then it will have a set of wakeables. - // For each wakeable, attach a listener so that when it resolves, React + // If this boundary just timed out, then it will have a set of thenables. + // For each thenable, attach a listener so that when it resolves, React // attempts to re-render the boundary in the primary (pre-timeout) state. - var wakeables = finishedWork.updateQueue; + var thenables = finishedWork.updateQueue; - if (wakeables !== null) { + if (thenables !== null) { finishedWork.updateQueue = null; var retryCache = finishedWork.stateNode; @@ -17183,60 +16124,361 @@ function attachSuspenseRetryListeners(finishedWork) { retryCache = finishedWork.stateNode = new PossiblyWeakSet(); } - wakeables.forEach(function(wakeable) { + thenables.forEach(function(thenable) { // Memoize using the boundary fiber to prevent redundant listeners. - var retry = resolveRetryWakeable.bind(null, finishedWork, wakeable); + var retry = resolveRetryThenable.bind(null, finishedWork, thenable); - if (!retryCache.has(wakeable)) { + if (!retryCache.has(thenable)) { { - if (wakeable.__reactDoNotTraceInteractions !== true) { + if (thenable.__reactDoNotTraceInteractions !== true) { retry = tracing.unstable_wrap(retry); } } - retryCache.add(wakeable); - wakeable.then(retry, retry); + retryCache.add(thenable); + thenable.then(retry, retry); } }); } -} // This function detects when a Suspense boundary goes from visible to hidden. -// It returns false if the boundary is already hidden. -// TODO: Use an effect tag. +} -function isSuspenseBoundaryBeingHidden(current, finishedWork) { - if (current !== null) { - var oldState = current.memoizedState; +var PossiblyWeakMap = typeof WeakMap === "function" ? WeakMap : Map; - if (oldState === null || oldState.dehydrated !== null) { - var newState = finishedWork.memoizedState; - return newState !== null && newState.dehydrated === null; +function createRootErrorUpdate(fiber, errorInfo, expirationTime) { + var update = createUpdate(expirationTime, null); // Unmount the root by rendering null. + + update.tag = CaptureUpdate; // Caution: React DevTools currently depends on this property + // being called "element". + + update.payload = { + element: null + }; + var error = errorInfo.value; + + update.callback = function() { + onUncaughtError(error); + logError(fiber, errorInfo); + }; + + return update; +} + +function createClassErrorUpdate(fiber, errorInfo, expirationTime) { + var update = createUpdate(expirationTime, null); + update.tag = CaptureUpdate; + var getDerivedStateFromError = fiber.type.getDerivedStateFromError; + + if (typeof getDerivedStateFromError === "function") { + var error$1 = errorInfo.value; + + update.payload = function() { + logError(fiber, errorInfo); + return getDerivedStateFromError(error$1); + }; + } + + var inst = fiber.stateNode; + + if (inst !== null && typeof inst.componentDidCatch === "function") { + update.callback = function callback() { + { + markFailedErrorBoundaryForHotReloading(fiber); + } + + if (typeof getDerivedStateFromError !== "function") { + // To preserve the preexisting retry behavior of error boundaries, + // we keep track of which ones already failed during this batch. + // This gets reset before we yield back to the browser. + // TODO: Warn in strict mode if getDerivedStateFromError is + // not defined. + markLegacyErrorBoundaryAsFailed(this); // Only log here if componentDidCatch is the only error boundary method defined + + logError(fiber, errorInfo); + } + + var error$1 = errorInfo.value; + var stack = errorInfo.stack; + this.componentDidCatch(error$1, { + componentStack: stack !== null ? stack : "" + }); + + { + if (typeof getDerivedStateFromError !== "function") { + // If componentDidCatch is the only error boundary method defined, + // then it needs to call setState to recover from errors. + // If no state update is scheduled then the boundary will swallow the error. + if (fiber.expirationTime !== Sync) { + error( + "%s: Error boundaries should implement getDerivedStateFromError(). " + + "In that method, return a state update to display an error message or fallback UI.", + getComponentName(fiber.type) || "Unknown" + ); + } + } + } + }; + } else { + update.callback = function() { + markFailedErrorBoundaryForHotReloading(fiber); + }; + } + + return update; +} + +function attachPingListener(root, renderExpirationTime, thenable) { + // Attach a listener to the promise to "ping" the root and retry. But + // only if one does not already exist for the current render expiration + // time (which acts like a "thread ID" here). + var pingCache = root.pingCache; + var threadIDs; + + if (pingCache === null) { + pingCache = root.pingCache = new PossiblyWeakMap(); + threadIDs = new Set(); + pingCache.set(thenable, threadIDs); + } else { + threadIDs = pingCache.get(thenable); + + if (threadIDs === undefined) { + threadIDs = new Set(); + pingCache.set(thenable, threadIDs); } } - return false; + if (!threadIDs.has(renderExpirationTime)) { + // Memoize using the thread ID to prevent redundant listeners. + threadIDs.add(renderExpirationTime); + var ping = pingSuspendedRoot.bind( + null, + root, + thenable, + renderExpirationTime + ); + thenable.then(ping, ping); + } } -var COMPONENT_TYPE = 0; -var HAS_PSEUDO_CLASS_TYPE = 1; -var ROLE_TYPE = 2; -var TEST_NAME_TYPE = 3; -var TEXT_TYPE = 4; +function throwException( + root, + returnFiber, + sourceFiber, + value, + renderExpirationTime +) { + // The source fiber did not complete. + sourceFiber.effectTag |= Incomplete; // Its effect list is no longer valid. -if (typeof Symbol === "function" && Symbol.for) { - var symbolFor$1 = Symbol.for; - COMPONENT_TYPE = symbolFor$1("selector.component"); - HAS_PSEUDO_CLASS_TYPE = symbolFor$1("selector.has_pseudo_class"); - ROLE_TYPE = symbolFor$1("selector.role"); - TEST_NAME_TYPE = symbolFor$1("selector.test_id"); - TEXT_TYPE = symbolFor$1("selector.text"); + sourceFiber.firstEffect = sourceFiber.lastEffect = null; + + if ( + value !== null && + typeof value === "object" && + typeof value.then === "function" + ) { + // This is a thenable. + var thenable = value; + + if ((sourceFiber.mode & BlockingMode) === NoMode) { + // Reset the memoizedState to what it was before we attempted + // to render it. + var currentSource = sourceFiber.alternate; + + if (currentSource) { + sourceFiber.updateQueue = currentSource.updateQueue; + sourceFiber.memoizedState = currentSource.memoizedState; + sourceFiber.expirationTime = currentSource.expirationTime; + } else { + sourceFiber.updateQueue = null; + sourceFiber.memoizedState = null; + } + } + + var hasInvisibleParentBoundary = hasSuspenseContext( + suspenseStackCursor.current, + InvisibleParentSuspenseContext + ); // Schedule the nearest Suspense to re-render the timed out view. + + var _workInProgress = returnFiber; + + do { + if ( + _workInProgress.tag === SuspenseComponent && + shouldCaptureSuspense(_workInProgress, hasInvisibleParentBoundary) + ) { + // Found the nearest boundary. + // Stash the promise on the boundary fiber. If the boundary times out, we'll + // attach another listener to flip the boundary back to its normal state. + var thenables = _workInProgress.updateQueue; + + if (thenables === null) { + var updateQueue = new Set(); + updateQueue.add(thenable); + _workInProgress.updateQueue = updateQueue; + } else { + thenables.add(thenable); + } // If the boundary is outside of blocking 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 blocking mode tree. If the Suspense is outside of it, we + // should *not* suspend the commit. + + if ((_workInProgress.mode & BlockingMode) === NoMode) { + _workInProgress.effectTag |= DidCapture; // 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 | Incomplete); + + if (sourceFiber.tag === ClassComponent) { + var currentSourceFiber = sourceFiber.alternate; + + if (currentSourceFiber === 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; + } else { + // 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 update to + // prevent a bail out. + var update = createUpdate(Sync, null); + update.tag = ForceUpdate; + enqueueUpdate(sourceFiber, update); + } + } // The source fiber did not complete. Mark it with Sync priority to + // indicate that it still has pending work. + + sourceFiber.expirationTime = Sync; // Exit without suspending. + + return; + } // Confirmed that the boundary is in a concurrent mode tree. Continue + // with the normal suspend path. + // + // After this we'll use a set of heuristics to determine whether this + // render pass will run to completion or restart or "suspend" the commit. + // The actual logic for this is spread out in different places. + // + // This first principle is that if we're going to suspend when we complete + // a root, then we should also restart if we get an update or ping that + // might unsuspend it, and vice versa. The only reason to suspend is + // because you think you might want to restart before committing. However, + // it doesn't make sense to restart only while in the period we're suspended. + // + // Restarting too aggressively is also not good because it starves out any + // intermediate loading state. So we use heuristics to determine when. + // Suspense Heuristics + // + // If nothing threw a Promise or all the same fallbacks are already showing, + // then don't suspend/restart. + // + // If this is an initial render of a new tree of Suspense boundaries and + // those trigger a fallback, then don't suspend/restart. We want to ensure + // that we can show the initial loading state as quickly as possible. + // + // If we hit a "Delayed" case, such as when we'd switch from content back into + // a fallback, then we should always suspend/restart. SuspenseConfig applies to + // this case. If none is defined, JND is used instead. + // + // If we're already showing a fallback and it gets "retried", allowing us to show + // another level, but there's still an inner boundary that would show a fallback, + // then we suspend/restart for 500ms since the last time we showed a fallback + // anywhere in the tree. This effectively throttles progressive loading into a + // consistent train of commits. This also gives us an opportunity to restart to + // get to the completed state slightly earlier. + // + // If there's ambiguity due to batching it's resolved in preference of: + // 1) "delayed", 2) "initial render", 3) "retry". + // + // We want to ensure that a "busy" state doesn't get force committed. We want to + // ensure that new initial loading states can commit as soon as possible. + + attachPingListener(root, renderExpirationTime, thenable); + _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( + (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) + ); + } // We didn't find a boundary that could handle this type of exception. Start + // over and traverse parent path again, this time treating the exception + // as an error. + + renderDidError(); + value = createCapturedValue(value, sourceFiber); + var workInProgress = returnFiber; + + do { + switch (workInProgress.tag) { + case HostRoot: { + var _errorInfo = value; + workInProgress.effectTag |= ShouldCapture; + workInProgress.expirationTime = renderExpirationTime; + + var _update = createRootErrorUpdate( + workInProgress, + _errorInfo, + renderExpirationTime + ); + + enqueueCapturedUpdate(workInProgress, _update); + return; + } + + case ClassComponent: + // Capture and retry + var errorInfo = value; + var ctor = workInProgress.type; + var instance = workInProgress.stateNode; + + if ( + (workInProgress.effectTag & DidCapture) === NoEffect && + (typeof ctor.getDerivedStateFromError === "function" || + (instance !== null && + typeof instance.componentDidCatch === "function" && + !isAlreadyFailedLegacyErrorBoundary(instance))) + ) { + workInProgress.effectTag |= ShouldCapture; + workInProgress.expirationTime = renderExpirationTime; // Schedule the error boundary to re-render using updated state + + var _update2 = createClassErrorUpdate( + workInProgress, + errorInfo, + renderExpirationTime + ); + + enqueueCapturedUpdate(workInProgress, _update2); + return; + } + + break; + } + + workInProgress = workInProgress.return; + } while (workInProgress !== null); } var ceil = Math.ceil; -var ReactCurrentDispatcher$2 = ReactSharedInternals.ReactCurrentDispatcher, +var ReactCurrentDispatcher$1 = ReactSharedInternals.ReactCurrentDispatcher, ReactCurrentOwner$2 = ReactSharedInternals.ReactCurrentOwner, IsSomeRendererActing = ReactSharedInternals.IsSomeRendererActing; var NoContext = - /* */ + /* */ 0; var BatchedContext = /* */ @@ -17253,264 +16495,189 @@ var RenderContext = var CommitContext = /* */ 32; -var RetryAfterError = - /* */ - 64; var RootIncomplete = 0; var RootFatalErrored = 1; var RootErrored = 2; var RootSuspended = 3; var RootSuspendedWithDelay = 4; -var RootCompleted = 5; // Describes where we are in the React execution stack - +var RootCompleted = 5; +// Describes where we are in the React execution stack var executionContext = NoContext; // The root we're working on var workInProgressRoot = null; // The fiber we're working on -var workInProgress = null; // The lanes we're rendering +var workInProgress = null; // The expiration time we're rendering -var workInProgressRootRenderLanes = NoLanes; // Stack that allows components to change the render lanes for its subtree -// This is a superset of the lanes we started working on at the root. The only -// case where it's different from `workInProgressRootRenderLanes` is when we -// enter a subtree that is hidden and needs to be unhidden: Suspense and -// Offscreen component. -// -// Most things in the work loop should deal with workInProgressRootRenderLanes. -// Most things in begin/complete phases should deal with subtreeRenderLanes. - -var subtreeRenderLanes = NoLanes; -var subtreeRenderLanesCursor = createCursor(NoLanes); // Whether to root completed, errored, suspended, etc. +var renderExpirationTime$1 = NoWork; // Whether to root completed, errored, suspended, etc. var workInProgressRootExitStatus = RootIncomplete; // A fatal error, if one is thrown -var workInProgressRootFatalError = null; -var workInProgressRootLatestSuspenseTimeout = NoTimestamp; -var workInProgressRootCanSuspendUsingConfig = null; // "Included" lanes refer to lanes that were worked on during this render. It's -// slightly different than `renderLanes` because `renderLanes` can change as you -// enter and exit an Offscreen tree. This value is the combination of all render -// lanes for the entire render phase. +var workInProgressRootFatalError = null; // Most recent event time among processed updates during this render. +// This is conceptually a time stamp but expressed in terms of an ExpirationTime +// because we deal mostly with expiration times in the hot path, so this avoids +// the conversion happening in the hot path. -var workInProgressRootIncludedLanes = NoLanes; // The work left over by components that were visited during this render. Only +var workInProgressRootLatestProcessedExpirationTime = Sync; +var workInProgressRootLatestSuspenseTimeout = Sync; +var workInProgressRootCanSuspendUsingConfig = null; // The work left over by components that were visited during this render. Only // includes unprocessed updates, not work in bailed out children. -var workInProgressRootSkippedLanes = NoLanes; // Lanes that were updated (in an interleaved event) during this render. +var workInProgressRootNextUnprocessedUpdateTime = NoWork; // If we're pinged while rendering we don't always restart immediately. +// This flag determines if it might be worthwhile to restart if an opportunity +// happens latere. -var workInProgressRootUpdatedLanes = NoLanes; // Lanes that were pinged (in an interleaved event) during this render. - -var workInProgressRootPingedLanes = NoLanes; -var mostRecentlyUpdatedRoot = null; // The most recent time we committed a fallback. This lets us ensure a train +var workInProgressRootHasPendingPing = false; // The most recent time we committed a fallback. This lets us ensure a train // model where we don't commit new loading states in too quick succession. var globalMostRecentFallbackTime = 0; var FALLBACK_THROTTLE_MS = 500; -var DEFAULT_TIMEOUT_MS = 5000; var nextEffect = null; var hasUncaughtError = false; var firstUncaughtError = null; var legacyErrorBoundariesThatAlreadyFailed = null; var rootDoesHavePassiveEffects = false; var rootWithPendingPassiveEffects = null; -var pendingPassiveEffectsRenderPriority = NoPriority$1; -var pendingPassiveEffectsLanes = NoLanes; -var pendingPassiveHookEffectsMount = []; -var pendingPassiveHookEffectsUnmount = []; +var pendingPassiveEffectsRenderPriority = NoPriority; +var pendingPassiveEffectsExpirationTime = NoWork; var rootsWithPendingDiscreteUpdates = null; // Use these to prevent an infinite loop of nested updates var NESTED_UPDATE_LIMIT = 50; var nestedUpdateCount = 0; var rootWithNestedUpdates = null; var NESTED_PASSIVE_UPDATE_LIMIT = 50; -var nestedPassiveUpdateCount = 0; // Marks the need to reschedule pending interactions at these lanes +var nestedPassiveUpdateCount = 0; +var interruptedBy = null; // Marks the need to reschedule pending interactions at these expiration times // during the commit phase. This enables them to be traced across components // that spawn new work during render. E.g. hidden boundaries, suspended SSR // hydration or SuspenseList. -// TODO: Can use a bitmask instead of an array -var spawnedWorkDuringRender = null; // If two updates are scheduled within the same event, we should treat their -// event times as simultaneous, even if the actual clock time has advanced -// between the first and second call. +var spawnedWorkDuringRender = null; // Expiration times are computed by adding to the current time (the start +// time). However, if two updates are scheduled within the same event, we +// should treat their start times as simultaneous, even if the actual clock +// time has advanced between the first and second call. +// In other words, because expiration times determine how updates are batched, +// we want all updates of like priority that occur within the same event to +// receive the same expiration time. Otherwise we get tearing. -var currentEventTime = NoTimestamp; -var currentEventWipLanes = NoLanes; -var currentEventPendingLanes = NoLanes; // Dev only flag that tracks if passive effects are currently being flushed. -// We warn about state updates for unmounted components differently in this case. - -var isFlushingPassiveEffects = false; -var focusedInstanceHandle = null; -var shouldFireAfterActiveInstanceBlur = false; -function getWorkInProgressRoot() { - return workInProgressRoot; -} -function requestEventTime() { +var currentEventTime = NoWork; +function requestCurrentTimeForUpdate() { if ((executionContext & (RenderContext | CommitContext)) !== NoContext) { // We're inside React, so it's fine to read the actual time. - return now(); + return msToExpirationTime(now()); } // We're not inside React, so we may be in the middle of a browser event. - if (currentEventTime !== NoTimestamp) { + if (currentEventTime !== NoWork) { // Use the same start time for all updates until we enter React again. return currentEventTime; } // This is the first update since React yielded. Compute a new start time. - currentEventTime = now(); + currentEventTime = msToExpirationTime(now()); return currentEventTime; } -function requestUpdateLane(fiber, suspenseConfig) { - // Special cases +function getCurrentTime() { + return msToExpirationTime(now()); +} +function computeExpirationForFiber(currentTime, fiber, suspenseConfig) { var mode = fiber.mode; if ((mode & BlockingMode) === NoMode) { - return SyncLane; - } else if ((mode & ConcurrentMode) === NoMode) { - return getCurrentPriorityLevel() === ImmediatePriority$1 - ? SyncLane - : SyncBatchedLane; - } // The algorithm for assigning an update to a lane should be stable for all - // updates at the same priority within the same event. To do this, the inputs - // to the algorithm must be the same. For example, we use the `renderLanes` - // to avoid choosing a lane that is already in the middle of rendering. - // - // However, the "included" lanes could be mutated in between updates in the - // same event, like if you perform an update inside `flushSync`. Or any other - // code path that might call `prepareFreshStack`. - // - // The trick we use is to cache the first of each of these inputs within an - // event. Then reset the cached values once we can be sure the event is over. - // Our heuristic for that is whenever we enter a concurrent work loop. - // - // We'll do the same for `currentEventPendingLanes` below. - - if (currentEventWipLanes === NoLanes) { - currentEventWipLanes = workInProgressRootIncludedLanes; + return Sync; } + var priorityLevel = getCurrentPriorityLevel(); + + if ((mode & ConcurrentMode) === NoMode) { + return priorityLevel === ImmediatePriority ? Sync : Batched; + } + + if ((executionContext & RenderContext) !== NoContext) { + // Use whatever time we're already rendering + // TODO: Should there be a way to opt out, like with `runWithPriority`? + return renderExpirationTime$1; + } + + var expirationTime; + if (suspenseConfig !== null) { - // Use the size of the timeout as a heuristic to prioritize shorter - // transitions over longer ones. - // TODO: This will coerce numbers larger than 31 bits to 0. - var timeoutMs = suspenseConfig.timeoutMs; - var transitionLanePriority = - timeoutMs === undefined || (timeoutMs | 0) < 10000 - ? TransitionShortLanePriority - : TransitionLongLanePriority; - - if (currentEventPendingLanes !== NoLanes) { - currentEventPendingLanes = - mostRecentlyUpdatedRoot !== null - ? mostRecentlyUpdatedRoot.pendingLanes - : NoLanes; - } - - return findTransitionLane( - transitionLanePriority, - currentEventWipLanes, - currentEventPendingLanes + // Compute an expiration time based on the Suspense timeout. + expirationTime = computeSuspenseExpiration( + currentTime, + suspenseConfig.timeoutMs | 0 || LOW_PRIORITY_EXPIRATION ); - } // TODO: Remove this dependency on the Scheduler priority. - // To do that, we're replacing it with an update lane priority. + } else { + // Compute an expiration time based on the Scheduler priority. + switch (priorityLevel) { + case ImmediatePriority: + expirationTime = Sync; + break; - var schedulerPriority = getCurrentPriorityLevel(); // The old behavior was using the priority level of the Scheduler. - // This couples React to the Scheduler internals, so we're replacing it - // with the currentUpdateLanePriority above. As an example of how this - // could be problematic, if we're not inside `Scheduler.runWithPriority`, - // then we'll get the priority of the current running Scheduler task, - // which is probably not what we want. + case UserBlockingPriority: + // TODO: Rename this to computeUserBlockingExpiration + expirationTime = computeInteractiveExpiration(currentTime); + break; - var lane; + case NormalPriority: + case LowPriority: + // TODO: Handle LowPriority + // TODO: Rename this to... something better. + expirationTime = computeAsyncExpiration(currentTime); + break; + + case IdlePriority: + expirationTime = Idle; + break; + + default: { + throw Error("Expected a valid priority level"); + } + } + } // If we're in the middle of rendering a tree, do not update at the same + // expiration time that is already rendering. + // TODO: We shouldn't have to do this if the update is on a different root. + // Refactor computeExpirationForFiber + scheduleUpdate so we have access to + // the root when we check for this condition. if ( - // TODO: Temporary. We're removing the concept of discrete updates. - (executionContext & DiscreteEventContext) !== NoContext && - schedulerPriority === UserBlockingPriority$1 + workInProgressRoot !== null && + expirationTime === renderExpirationTime$1 ) { - lane = findUpdateLane(InputDiscreteLanePriority, currentEventWipLanes); - } else { - var schedulerLanePriority = schedulerPriorityToLanePriority( - schedulerPriority - ); - - lane = findUpdateLane(schedulerLanePriority, currentEventWipLanes); + // This is a trick to move this update into a separate batch + expirationTime -= 1; } - return lane; + return expirationTime; } - -function requestRetryLane(fiber) { - // This is a fork of `requestUpdateLane` designed specifically for Suspense - // "retries" — a special update that attempts to flip a Suspense boundary - // from its placeholder state to its primary/resolved state. - // Special cases - var mode = fiber.mode; - - if ((mode & BlockingMode) === NoMode) { - return SyncLane; - } else if ((mode & ConcurrentMode) === NoMode) { - return getCurrentPriorityLevel() === ImmediatePriority$1 - ? SyncLane - : SyncBatchedLane; - } // See `requestUpdateLane` for explanation of `currentEventWipLanes` - - if (currentEventWipLanes === NoLanes) { - currentEventWipLanes = workInProgressRootIncludedLanes; - } - - return findRetryLane(currentEventWipLanes); -} - -function scheduleUpdateOnFiber(fiber, lane, eventTime) { +function scheduleUpdateOnFiber(fiber, expirationTime) { checkForNestedUpdates(); warnAboutRenderPhaseUpdatesInDEV(fiber); - var root = markUpdateLaneFromFiberToRoot(fiber, lane); + var root = markUpdateTimeFromFiberToRoot(fiber, expirationTime); if (root === null) { warnAboutUpdateOnUnmountedFiberInDEV(fiber); - return null; - } // Mark that the root has a pending update. + return; + } - markRootUpdated(root, lane, eventTime); - - if (root === workInProgressRoot) { - // Received an update to a tree that's in the middle of rendering. Mark - // that there was an interleaved update work on this root. Unless the - // `deferRenderPhaseUpdateToNextBatch` flag is off and this is a render - // phase update. In that case, we don't treat render phase updates as if - // they were interleaved, for backwards compat reasons. - { - workInProgressRootUpdatedLanes = mergeLanes( - workInProgressRootUpdatedLanes, - lane - ); - } - - if (workInProgressRootExitStatus === RootSuspendedWithDelay) { - // The root already suspended with a delay, which means this render - // definitely won't finish. Since we have a new update, let's mark it as - // suspended now, right before marking the incoming update. This has the - // effect of interrupting the current render and switching to the update. - // TODO: Make sure this doesn't override pings that happen while we've - // already started rendering. - markRootSuspended$1(root, workInProgressRootRenderLanes); - } - } // TODO: requestUpdateLanePriority also reads the priority. Pass the + checkForInterruption(fiber, expirationTime); + recordScheduleUpdate(); // TODO: computeExpirationForFiber also reads the priority. Pass the // priority as an argument to that function and this one. var priorityLevel = getCurrentPriorityLevel(); - if (lane === SyncLane) { + if (expirationTime === Sync) { if ( // Check if we're inside unbatchedUpdates (executionContext & LegacyUnbatchedContext) !== NoContext && // Check if we're not already rendering (executionContext & (RenderContext | CommitContext)) === NoContext ) { // Register pending interactions on the root to avoid losing traced interaction data. - schedulePendingInteractions(root, lane); // This is a legacy edge case. The initial mount of a ReactDOM.render-ed + schedulePendingInteractions(root, expirationTime); // This is a legacy edge case. The initial mount of a ReactDOM.render-ed // root inside of batchedUpdates should be synchronous, but layout updates // should be deferred until the end of the batch. performSyncWorkOnRoot(root); } else { - ensureRootIsScheduled(root, eventTime); - schedulePendingInteractions(root, lane); + ensureRootIsScheduled(root); + schedulePendingInteractions(root, expirationTime); if (executionContext === NoContext) { // Flush the synchronous work now, unless we're already working or inside @@ -17522,251 +16689,281 @@ function scheduleUpdateOnFiber(fiber, lane, eventTime) { } } } else { - // Schedule a discrete update but only if it's not Sync. - if ( - (executionContext & DiscreteEventContext) !== NoContext && // Only updates at user-blocking priority or greater are considered - // discrete, even inside a discrete event. - (priorityLevel === UserBlockingPriority$1 || - priorityLevel === ImmediatePriority$1) - ) { - // This is the result of a discrete event. Track the lowest priority - // discrete update per root so we can flush them early, if needed. - if (rootsWithPendingDiscreteUpdates === null) { - rootsWithPendingDiscreteUpdates = new Set([root]); - } else { - rootsWithPendingDiscreteUpdates.add(root); + ensureRootIsScheduled(root); + schedulePendingInteractions(root, expirationTime); + } + + if ( + (executionContext & DiscreteEventContext) !== NoContext && // Only updates at user-blocking priority or greater are considered + // discrete, even inside a discrete event. + (priorityLevel === UserBlockingPriority || + priorityLevel === ImmediatePriority) + ) { + // This is the result of a discrete event. Track the lowest priority + // discrete update per root so we can flush them early, if needed. + if (rootsWithPendingDiscreteUpdates === null) { + rootsWithPendingDiscreteUpdates = new Map([[root, expirationTime]]); + } else { + var lastDiscreteTime = rootsWithPendingDiscreteUpdates.get(root); + + if (lastDiscreteTime === undefined || lastDiscreteTime > expirationTime) { + rootsWithPendingDiscreteUpdates.set(root, expirationTime); } - } // Schedule other updates after in case the callback is sync. - - ensureRootIsScheduled(root, eventTime); - schedulePendingInteractions(root, lane); - } // We use this when assigning a lane for a transition inside - // `requestUpdateLane`. We assume it's the same as the root being updated, - // since in the common case of a single root app it probably is. If it's not - // the same root, then it's not a huge deal, we just might batch more stuff - // together more than necessary. - - mostRecentlyUpdatedRoot = root; -} // This is split into a separate function so we can mark a fiber with pending + } + } +} +var scheduleWork = scheduleUpdateOnFiber; // This is split into a separate function so we can mark a fiber with pending // work without treating it as a typical update that originates from an event; // e.g. retrying a Suspense boundary isn't an update, but it does schedule work // on a fiber. -function markUpdateLaneFromFiberToRoot(sourceFiber, lane) { - // Update the source fiber's lanes - sourceFiber.lanes = mergeLanes(sourceFiber.lanes, lane); - var alternate = sourceFiber.alternate; - - if (alternate !== null) { - alternate.lanes = mergeLanes(alternate.lanes, lane); +function markUpdateTimeFromFiberToRoot(fiber, expirationTime) { + // Update the source fiber's expiration time + if (fiber.expirationTime < expirationTime) { + fiber.expirationTime = expirationTime; } - { - if ( - alternate === null && - (sourceFiber.effectTag & (Placement | Hydrating)) !== NoEffect - ) { - warnAboutUpdateOnNotYetMountedFiberInDEV(sourceFiber); - } + var alternate = fiber.alternate; + + if (alternate !== null && alternate.expirationTime < expirationTime) { + alternate.expirationTime = expirationTime; } // Walk the parent path to the root and update the child expiration time. - var node = sourceFiber; - var parent = sourceFiber.return; + var node = fiber.return; + var root = null; - while (parent !== null) { - parent.childLanes = mergeLanes(parent.childLanes, lane); - alternate = parent.alternate; - - if (alternate !== null) { - alternate.childLanes = mergeLanes(alternate.childLanes, lane); - } else { - { - if ((parent.effectTag & (Placement | Hydrating)) !== NoEffect) { - warnAboutUpdateOnNotYetMountedFiberInDEV(sourceFiber); - } - } - } - - node = parent; - parent = parent.return; - } - - if (node.tag === HostRoot) { - var root = node.stateNode; - return root; + if (node === null && fiber.tag === HostRoot) { + root = fiber.stateNode; } else { - return null; + while (node !== null) { + alternate = node.alternate; + + if (node.childExpirationTime < expirationTime) { + node.childExpirationTime = expirationTime; + + if ( + alternate !== null && + alternate.childExpirationTime < expirationTime + ) { + alternate.childExpirationTime = expirationTime; + } + } else if ( + alternate !== null && + alternate.childExpirationTime < expirationTime + ) { + alternate.childExpirationTime = expirationTime; + } + + if (node.return === null && node.tag === HostRoot) { + root = node.stateNode; + break; + } + + node = node.return; + } } + + if (root !== null) { + if (workInProgressRoot === root) { + // Received an update to a tree that's in the middle of rendering. Mark + // that's unprocessed work on this root. + markUnprocessedUpdateTime(expirationTime); + + if (workInProgressRootExitStatus === RootSuspendedWithDelay) { + // The root already suspended with a delay, which means this render + // definitely won't finish. Since we have a new update, let's mark it as + // suspended now, right before marking the incoming update. This has the + // effect of interrupting the current render and switching to the update. + // TODO: This happens to work when receiving an update during the render + // phase, because of the trick inside computeExpirationForFiber to + // subtract 1 from `renderExpirationTime` to move it into a + // separate bucket. But we should probably model it with an exception, + // using the same mechanism we use to force hydration of a subtree. + // TODO: This does not account for low pri updates that were already + // scheduled before the root started rendering. Need to track the next + // pending expiration time (perhaps by backtracking the return path) and + // then trigger a restart in the `renderDidSuspendDelayIfPossible` path. + markRootSuspendedAtTime(root, renderExpirationTime$1); + } + } // Mark that the root has a pending update. + + markRootUpdatedAtTime(root, expirationTime); + } + + return root; +} + +function getNextRootExpirationTimeToWorkOn(root) { + // Determines the next expiration time that the root should render, taking + // into account levels that may be suspended, or levels that may have + // received a ping. + var lastExpiredTime = root.lastExpiredTime; + + if (lastExpiredTime !== NoWork) { + return lastExpiredTime; + } // "Pending" refers to any update that hasn't committed yet, including if it + // suspended. The "suspended" range is therefore a subset. + + var firstPendingTime = root.firstPendingTime; + + if (!isRootSuspendedAtTime(root, firstPendingTime)) { + // The highest priority pending time is not suspended. Let's work on that. + return firstPendingTime; + } // If the first pending time is suspended, check if there's a lower priority + // pending level that we know about. Or check if we received a ping. Work + // on whichever is higher priority. + + var lastPingedTime = root.lastPingedTime; + var nextKnownPendingLevel = root.nextKnownPendingLevel; + var nextLevel = + lastPingedTime > nextKnownPendingLevel + ? lastPingedTime + : nextKnownPendingLevel; + + if (nextLevel <= Idle && firstPendingTime !== nextLevel) { + // Don't work on Idle/Never priority unless everything else is committed. + return NoWork; + } + + return nextLevel; } // Use this function to schedule a task for a root. There's only one task per -// root; if a task was already scheduled, we'll check to make sure the priority -// of the existing task is the same as the priority of the next level that the -// root has work on. This function is called on every update, and right before -// exiting a task. +// root; if a task was already scheduled, we'll check to make sure the +// expiration time of the existing task is the same as the expiration time of +// the next level that the root has work on. This function is called on every +// update, and right before exiting a task. -function ensureRootIsScheduled(root, currentTime) { - var existingCallbackNode = root.callbackNode; // Check if any lanes are being starved by other work. If so, mark them as - // expired so we know to work on those next. +function ensureRootIsScheduled(root) { + var lastExpiredTime = root.lastExpiredTime; - markStarvedLanesAsExpired(root, currentTime); // Determine the next lanes to work on, and their priority. + if (lastExpiredTime !== NoWork) { + // Special case: Expired work should flush synchronously. + root.callbackExpirationTime = Sync; + root.callbackPriority = ImmediatePriority; + root.callbackNode = scheduleSyncCallback( + performSyncWorkOnRoot.bind(null, root) + ); + return; + } - var nextLanes = getNextLanes( - root, - root === workInProgressRoot ? workInProgressRootRenderLanes : NoLanes - ); // This returns the priority level computed during the `getNextLanes` call. + var expirationTime = getNextRootExpirationTimeToWorkOn(root); + var existingCallbackNode = root.callbackNode; - var newCallbackPriority = returnNextLanesPriority(); - - if (nextLanes === NoLanes) { - // Special case: There's nothing to work on. + if (expirationTime === NoWork) { + // There's nothing to work on. if (existingCallbackNode !== null) { - cancelCallback(existingCallbackNode); root.callbackNode = null; - root.callbackPriority = NoLanePriority; + root.callbackExpirationTime = NoWork; + root.callbackPriority = NoPriority; } return; - } // Check if there's an existing task. We may be able to reuse it. + } // TODO: If this is an update, we already read the current time. Pass the + // time as an argument. + + var currentTime = requestCurrentTimeForUpdate(); + var priorityLevel = inferPriorityFromExpirationTime( + currentTime, + expirationTime + ); // If there's an existing render task, confirm it has the correct priority and + // expiration time. Otherwise, we'll cancel it and schedule a new one. if (existingCallbackNode !== null) { var existingCallbackPriority = root.callbackPriority; + var existingCallbackExpirationTime = root.callbackExpirationTime; - if (existingCallbackPriority === newCallbackPriority) { - // The priority hasn't changed. We can reuse the existing task. Exit. + if ( + // Callback must have the exact same expiration time. + existingCallbackExpirationTime === expirationTime && // Callback must have greater or equal priority. + existingCallbackPriority >= priorityLevel + ) { + // Existing callback is sufficient. return; - } // The priority changed. Cancel the existing callback. We'll schedule a new - // one below. + } // Need to schedule a new task. + // TODO: Instead of scheduling a new task, we should be able to change the + // priority of the existing one. cancelCallback(existingCallbackNode); - } // Schedule a new callback. + } - var newCallbackNode; + root.callbackExpirationTime = expirationTime; + root.callbackPriority = priorityLevel; + var callbackNode; - if (newCallbackPriority === SyncLanePriority) { - // Special case: Sync React callbacks are scheduled on a special - // internal queue - newCallbackNode = scheduleSyncCallback( - performSyncWorkOnRoot.bind(null, root) - ); - } else if (newCallbackPriority === SyncBatchedLanePriority) { - newCallbackNode = scheduleCallback( - ImmediatePriority$1, - performSyncWorkOnRoot.bind(null, root) - ); + if (expirationTime === Sync) { + // Sync React callbacks are scheduled on a special internal queue + callbackNode = scheduleSyncCallback(performSyncWorkOnRoot.bind(null, root)); } else { - var schedulerPriorityLevel = lanePriorityToSchedulerPriority( - newCallbackPriority - ); - newCallbackNode = scheduleCallback( - schedulerPriorityLevel, - performConcurrentWorkOnRoot.bind(null, root) + callbackNode = scheduleCallback( + priorityLevel, + performConcurrentWorkOnRoot.bind(null, root), // Compute a task timeout based on the expiration time. This also affects + // ordering because tasks are processed in timeout order. + { + timeout: expirationTimeToMs(expirationTime) - now() + } ); } - root.callbackPriority = newCallbackPriority; - root.callbackNode = newCallbackNode; + root.callbackNode = callbackNode; } // This is the entry point for every concurrent task, i.e. anything that // goes through Scheduler. function performConcurrentWorkOnRoot(root, didTimeout) { // Since we know we're in a React event, we can clear the current // event time. The next update will compute a new event time. - currentEventTime = NoTimestamp; - currentEventWipLanes = NoLanes; - currentEventPendingLanes = NoLanes; + currentEventTime = NoWork; // Check if the render expired. - if (!((executionContext & (RenderContext | CommitContext)) === NoContext)) { - throw Error("Should not already be working."); - } // Flush any pending passive effects before deciding which lanes to work on, - // in case they schedule additional work. + if (didTimeout) { + // The render task took too long to complete. Mark the current time as + // expired to synchronously render all expired work in a single batch. + var currentTime = requestCurrentTimeForUpdate(); + markRootExpiredAtTime(root, currentTime); // This will schedule a synchronous callback. - var originalCallbackNode = root.callbackNode; - var didFlushPassiveEffects = flushPassiveEffects(); - - if (didFlushPassiveEffects) { - // Something in the passive effect phase may have canceled the current task. - // Check if the task node for this root was changed. - if (root.callbackNode !== originalCallbackNode) { - // The current task was canceled. Exit. We don't need to call - // `ensureRootIsScheduled` because the check above implies either that - // there's a new task, or that there's no remaining work on this root. - return null; - } + ensureRootIsScheduled(root); + return null; } // Determine the next expiration time to work on, using the fields stored // on the root. - var lanes = getNextLanes( - root, - root === workInProgressRoot ? workInProgressRootRenderLanes : NoLanes - ); + var expirationTime = getNextRootExpirationTimeToWorkOn(root); - if (lanes === NoLanes) { - // Defensive coding. This is never expected to happen. - return null; - } // TODO: We only check `didTimeout` defensively, to account for a Scheduler - // bug where `shouldYield` sometimes returns `true` even if `didTimeout` is - // true, which leads to an infinite loop. Once the bug in Scheduler is - // fixed, we can remove this, since we track expiration ourselves. - - if (didTimeout) { - // Something expired. Flush synchronously until there's no expired - // work left. - markRootExpired(root, lanes); // This will schedule a synchronous callback. - - ensureRootIsScheduled(root, now()); + if (expirationTime === NoWork) { return null; } - var exitStatus = renderRootConcurrent(root, lanes); + var originalCallbackNode = root.callbackNode; - if ( - includesSomeLane( - workInProgressRootIncludedLanes, - workInProgressRootUpdatedLanes - ) - ) { - // The render included lanes that were updated during the render phase. - // For example, when unhiding a hidden tree, we include all the lanes - // that were previously skipped when the tree was hidden. That set of - // lanes is a superset of the lanes we started rendering with. - // - // So we'll throw out the current work and restart. - prepareFreshStack(root, NoLanes); - } else if (exitStatus !== RootIncomplete) { + if (!((executionContext & (RenderContext | CommitContext)) === NoContext)) { + throw Error("Should not already be working."); + } + + flushPassiveEffects(); + var exitStatus = renderRootConcurrent(root, expirationTime); + + if (exitStatus !== RootIncomplete) { if (exitStatus === RootErrored) { - executionContext |= RetryAfterError; // If an error occurred during hydration, - // discard server response and fall back to client side render. - - if (root.hydrate) { - root.hydrate = false; - clearContainer(root.containerInfo); - } // If something threw an error, try rendering one more time. We'll render - // synchronously to block concurrent data mutations, and we'll includes - // all pending updates are included. If it still fails after the second - // attempt, we'll give up and commit the resulting tree. - - lanes = getLanesToRetrySynchronouslyOnError(root); - - if (lanes !== NoLanes) { - exitStatus = renderRootSync(root, lanes); - } + // If something threw an error, try rendering one more time. We'll + // render synchronously to block concurrent data mutations, and we'll + // render at Idle (or lower) so that all pending updates are included. + // If it still fails after the second attempt, we'll give up and commit + // the resulting tree. + expirationTime = expirationTime > Idle ? Idle : expirationTime; + exitStatus = renderRootSync(root, expirationTime); } if (exitStatus === RootFatalErrored) { var fatalError = workInProgressRootFatalError; - prepareFreshStack(root, NoLanes); - markRootSuspended$1(root, lanes); - ensureRootIsScheduled(root, now()); + prepareFreshStack(root, expirationTime); + markRootSuspendedAtTime(root, expirationTime); + ensureRootIsScheduled(root); throw fatalError; } // We now have a consistent tree. The next step is either to commit it, // or, if something suspended, wait to commit it after a timeout. - var finishedWork = root.current.alternate; - root.finishedWork = finishedWork; - root.finishedLanes = lanes; - finishConcurrentRender(root, finishedWork, exitStatus, lanes); + var finishedWork = (root.finishedWork = root.current.alternate); + root.finishedExpirationTime = expirationTime; + finishConcurrentRender(root, finishedWork, exitStatus, expirationTime); } - ensureRootIsScheduled(root, now()); + ensureRootIsScheduled(root); if (root.callbackNode === originalCallbackNode) { // The task node scheduled for this root is the same one that's @@ -17777,7 +16974,12 @@ function performConcurrentWorkOnRoot(root, didTimeout) { return null; } -function finishConcurrentRender(root, finishedWork, exitStatus, lanes) { +function finishConcurrentRender( + root, + finishedWork, + exitStatus, + expirationTime +) { switch (exitStatus) { case RootIncomplete: case RootFatalErrored: { @@ -17797,35 +16999,61 @@ function finishConcurrentRender(root, finishedWork, exitStatus, lanes) { } case RootSuspended: { - markRootSuspended$1(root, lanes); // We have an acceptable loading state. We need to figure out if we + markRootSuspendedAtTime(root, expirationTime); + var lastSuspendedTime = root.lastSuspendedTime; + + if (expirationTime === lastSuspendedTime) { + root.nextKnownPendingLevel = getRemainingExpirationTime(finishedWork); + } // We have an acceptable loading state. We need to figure out if we // should immediately commit it or wait a bit. + // If we have processed new updates during this render, we may now + // have a new loading state ready. We want to ensure that we commit + // that as soon as possible. + + var hasNotProcessedNewUpdates = + workInProgressRootLatestProcessedExpirationTime === Sync; if ( - includesOnlyRetries(lanes) && // do not delay if we're inside an act() scope - !shouldForceFlushFallbacksInDEV() + hasNotProcessedNewUpdates && // do not delay if we're inside an act() scope + !IsThisRendererActing.current ) { - // This render only included retries, no updates. Throttle committing - // retries so that we don't show too many loading states too quickly. + // If we have not processed any new updates during this pass, then + // this is either a retry of an existing fallback state or a + // hidden tree. Hidden trees shouldn't be batched with other work + // and after that's fixed it can only be a retry. We're going to + // throttle committing retries so that we don't show too many + // loading states too quickly. var msUntilTimeout = globalMostRecentFallbackTime + FALLBACK_THROTTLE_MS - now(); // Don't bother with a very short suspense time. if (msUntilTimeout > 10) { - var nextLanes = getNextLanes(root, NoLanes); + if (workInProgressRootHasPendingPing) { + var lastPingedTime = root.lastPingedTime; - if (nextLanes !== NoLanes) { + if (lastPingedTime === NoWork || lastPingedTime >= expirationTime) { + // This render was pinged but we didn't get to restart + // earlier so try restarting now instead. + root.lastPingedTime = expirationTime; + prepareFreshStack(root, expirationTime); + break; + } + } + + var nextTime = getNextRootExpirationTimeToWorkOn(root); + + if (nextTime !== NoWork && nextTime !== expirationTime) { // There's additional work on this root. break; } - var suspendedLanes = root.suspendedLanes; - - if (!isSubsetOfLanes(suspendedLanes, lanes)) { + if ( + lastSuspendedTime !== NoWork && + lastSuspendedTime !== expirationTime + ) { // We should prefer to render the fallback of at the last // suspended level. Ping the last suspended level to try // rendering it again. - // FIXME: What if the suspended lanes are Idle? Should not restart. - var eventTime = requestEventTime(); - markRootPinged(root, suspendedLanes); + root.lastPingedTime = lastSuspendedTime; break; } // The render is suspended, it hasn't timed out, and there's no // lower priority work to do. Instead of committing the fallback @@ -17844,53 +17072,81 @@ function finishConcurrentRender(root, finishedWork, exitStatus, lanes) { } case RootSuspendedWithDelay: { - markRootSuspended$1(root, lanes); + markRootSuspendedAtTime(root, expirationTime); + var _lastSuspendedTime = root.lastSuspendedTime; - if ( - // do not delay if we're inside an act() scope - !shouldForceFlushFallbacksInDEV() - ) { + if (expirationTime === _lastSuspendedTime) { + root.nextKnownPendingLevel = getRemainingExpirationTime(finishedWork); + } + + { // We're suspended in a state that should be avoided. We'll try to // avoid committing it for as long as the timeouts let us. - var _nextLanes = getNextLanes(root, NoLanes); + if (workInProgressRootHasPendingPing) { + var _lastPingedTime = root.lastPingedTime; - if (_nextLanes !== NoLanes) { + if (_lastPingedTime === NoWork || _lastPingedTime >= expirationTime) { + // This render was pinged but we didn't get to restart earlier + // so try restarting now instead. + root.lastPingedTime = expirationTime; + prepareFreshStack(root, expirationTime); + break; + } + } + + var _nextTime = getNextRootExpirationTimeToWorkOn(root); + + if (_nextTime !== NoWork && _nextTime !== expirationTime) { // There's additional work on this root. break; } - var _suspendedLanes = root.suspendedLanes; - - if (!isSubsetOfLanes(_suspendedLanes, lanes)) { + if ( + _lastSuspendedTime !== NoWork && + _lastSuspendedTime !== expirationTime + ) { // We should prefer to render the fallback of at the last // suspended level. Ping the last suspended level to try // rendering it again. - // FIXME: What if the suspended lanes are Idle? Should not restart. - var _eventTime = requestEventTime(); - - markRootPinged(root, _suspendedLanes); + root.lastPingedTime = _lastSuspendedTime; break; } - var mostRecentEventTime = getMostRecentEventTime(root, lanes); - var _msUntilTimeout; - if (workInProgressRootLatestSuspenseTimeout !== NoTimestamp) { + if (workInProgressRootLatestSuspenseTimeout !== Sync) { // We have processed a suspense config whose expiration time we // can use as the timeout. - _msUntilTimeout = workInProgressRootLatestSuspenseTimeout - now(); - } else if (mostRecentEventTime === NoTimestamp) { + _msUntilTimeout = + expirationTimeToMs(workInProgressRootLatestSuspenseTimeout) - now(); + } else if (workInProgressRootLatestProcessedExpirationTime === Sync) { // This should never normally happen because only new updates // cause delayed states, so we should have processed something. // However, this could also happen in an offscreen tree. _msUntilTimeout = 0; } else { - // If we didn't process a suspense config, compute a JND based on - // the amount of time elapsed since the most recent event time. - var eventTimeMs = mostRecentEventTime; - var timeElapsedMs = now() - eventTimeMs; - _msUntilTimeout = jnd(timeElapsedMs) - timeElapsedMs; + // If we don't have a suspense config, we're going to use a + // heuristic to determine how long we can suspend. + var eventTimeMs = inferTimeFromExpirationTime( + workInProgressRootLatestProcessedExpirationTime + ); + var currentTimeMs = now(); + var timeUntilExpirationMs = + expirationTimeToMs(expirationTime) - currentTimeMs; + var timeElapsed = currentTimeMs - eventTimeMs; + + if (timeElapsed < 0) { + // We get this wrong some time since we estimate the time. + timeElapsed = 0; + } + + _msUntilTimeout = jnd(timeElapsed) - timeElapsed; // Clamp the timeout to the expiration time. TODO: Once the + // event time is exact instead of inferred from expiration time + // we don't need this. + + if (timeUntilExpirationMs < _msUntilTimeout) { + _msUntilTimeout = timeUntilExpirationMs; + } } // Don't bother with a very short suspense time. if (_msUntilTimeout > 10) { @@ -17911,12 +17167,9 @@ function finishConcurrentRender(root, finishedWork, exitStatus, lanes) { case RootCompleted: { // The work completed. Ready to commit. - var _mostRecentEventTime = getMostRecentEventTime(root, lanes); - if ( // do not delay if we're inside an act() scope - !shouldForceFlushFallbacksInDEV() && - _mostRecentEventTime !== NoTimestamp && + workInProgressRootLatestProcessedExpirationTime !== Sync && workInProgressRootCanSuspendUsingConfig !== null ) { // If we have exceeded the minimum loading delay, which probably @@ -17924,12 +17177,13 @@ function finishConcurrentRender(root, finishedWork, exitStatus, lanes) { // a bit longer to ensure that the spinner is shown for // enough time. var _msUntilTimeout2 = computeMsUntilSuspenseLoadingDelay( - _mostRecentEventTime, + workInProgressRootLatestProcessedExpirationTime, + expirationTime, workInProgressRootCanSuspendUsingConfig ); if (_msUntilTimeout2 > 10) { - markRootSuspended$1(root, lanes); + markRootSuspendedAtTime(root, expirationTime); root.timeoutHandle = scheduleTimeout( commitRoot.bind(null, root), _msUntilTimeout2 @@ -17948,16 +17202,6 @@ function finishConcurrentRender(root, finishedWork, exitStatus, lanes) { } } } -} - -function markRootSuspended$1(root, suspendedLanes) { - // When suspending, we should always exclude lanes that were pinged or (more - // rarely, since we try to avoid it) updated during the render phase. - // TODO: Lol maybe there's a better way to factor this besides this - // obnoxiously named function :) - suspendedLanes = removeLanes(suspendedLanes, workInProgressRootPingedLanes); - suspendedLanes = removeLanes(suspendedLanes, workInProgressRootUpdatedLanes); - markRootSuspended(root, suspendedLanes); } // This is the entry point for synchronous tasks that don't go // through Scheduler @@ -17967,77 +17211,61 @@ function performSyncWorkOnRoot(root) { } flushPassiveEffects(); - var lanes; - var exitStatus; - - if ( - root === workInProgressRoot && - includesSomeLane(root.expiredLanes, workInProgressRootRenderLanes) - ) { - // There's a partial tree, and at least one of its lanes has expired. Finish - // rendering it before rendering the rest of the expired work. - lanes = workInProgressRootRenderLanes; - exitStatus = renderRootSync(root, lanes); + var lastExpiredTime = root.lastExpiredTime; + var expirationTime; + if (lastExpiredTime !== NoWork) { + // There's expired work on this root. Check if we have a partial tree + // that we can reuse. if ( - includesSomeLane( - workInProgressRootIncludedLanes, - workInProgressRootUpdatedLanes - ) + root === workInProgressRoot && + renderExpirationTime$1 >= lastExpiredTime ) { - // The render included lanes that were updated during the render phase. - // For example, when unhiding a hidden tree, we include all the lanes - // that were previously skipped when the tree was hidden. That set of - // lanes is a superset of the lanes we started rendering with. - // - // Note that this only happens when part of the tree is rendered - // concurrently. If the whole tree is rendered synchronously, then there - // are no interleaved events. - lanes = getNextLanes(root, lanes); - exitStatus = renderRootSync(root, lanes); + // There's a partial tree with equal or greater than priority than the + // expired level. Finish rendering it before rendering the rest of the + // expired work. + expirationTime = renderExpirationTime$1; + } else { + // Start a fresh tree. + expirationTime = lastExpiredTime; } } else { - lanes = getNextLanes(root, NoLanes); - exitStatus = renderRootSync(root, lanes); + // There's no expired work. This must be a new, synchronous render. + expirationTime = Sync; } + var exitStatus = renderRootSync(root, expirationTime); + if (root.tag !== LegacyRoot && exitStatus === RootErrored) { - executionContext |= RetryAfterError; // If an error occurred during hydration, - // discard server response and fall back to client side render. - - if (root.hydrate) { - root.hydrate = false; - clearContainer(root.containerInfo); - } // If something threw an error, try rendering one more time. We'll render - // synchronously to block concurrent data mutations, and we'll includes - // all pending updates are included. If it still fails after the second - // attempt, we'll give up and commit the resulting tree. - - lanes = getLanesToRetrySynchronouslyOnError(root); - - if (lanes !== NoLanes) { - exitStatus = renderRootSync(root, lanes); - } + // If something threw an error, try rendering one more time. We'll + // render synchronously to block concurrent data mutations, and we'll + // render at Idle (or lower) so that all pending updates are included. + // If it still fails after the second attempt, we'll give up and commit + // the resulting tree. + expirationTime = expirationTime > Idle ? Idle : expirationTime; + exitStatus = renderRootSync(root, expirationTime); } if (exitStatus === RootFatalErrored) { var fatalError = workInProgressRootFatalError; - prepareFreshStack(root, NoLanes); - markRootSuspended$1(root, lanes); - ensureRootIsScheduled(root, now()); + prepareFreshStack(root, expirationTime); + markRootSuspendedAtTime(root, expirationTime); + ensureRootIsScheduled(root); throw fatalError; } // We now have a consistent tree. Because this is a sync render, we // will commit it even if something suspended. - var finishedWork = root.current.alternate; - root.finishedWork = finishedWork; - root.finishedLanes = lanes; + root.finishedWork = root.current.alternate; + root.finishedExpirationTime = expirationTime; commitRoot(root); // Before exiting, make sure there's a callback scheduled for the next // pending level. - ensureRootIsScheduled(root, now()); + ensureRootIsScheduled(root); return null; } +function syncUpdates(fn, a, b, c) { + return runWithPriority(ImmediatePriority, fn.bind(null, a, b, c)); +} function batchedUpdates$1(fn, a) { var prevExecutionContext = executionContext; @@ -18055,30 +17283,19 @@ function batchedUpdates$1(fn, a) { } } function flushSync(fn, a) { - var prevExecutionContext = executionContext; - - if ((prevExecutionContext & (RenderContext | CommitContext)) !== NoContext) { + if ((executionContext & (RenderContext | CommitContext)) !== NoContext) { { - error( - "flushSync was called from inside a lifecycle method. React cannot " + - "flush when React is already rendering. Consider moving this call to " + - "a scheduler task or micro task." + throw Error( + "flushSync was called from inside a lifecycle method. It cannot be called when React is already rendering." ); } - - return fn(a); } + var prevExecutionContext = executionContext; executionContext |= BatchedContext; try { - setCurrentUpdateLanePriority(SyncLanePriority); - - if (fn) { - return runWithPriority(ImmediatePriority$1, fn.bind(null, a)); - } else { - return undefined; - } + return runWithPriority(ImmediatePriority, fn.bind(null, a)); } finally { executionContext = prevExecutionContext; // Flush the immediate callbacks that were scheduled during this batch. // Note that this will happen even if batchedUpdates is higher up @@ -18087,22 +17304,10 @@ function flushSync(fn, a) { flushSyncCallbackQueue(); } } -function pushRenderLanes(fiber, lanes) { - push(subtreeRenderLanesCursor, subtreeRenderLanes, fiber); - subtreeRenderLanes = mergeLanes(subtreeRenderLanes, lanes); - workInProgressRootIncludedLanes = mergeLanes( - workInProgressRootIncludedLanes, - lanes - ); -} -function popRenderLanes(fiber) { - subtreeRenderLanes = subtreeRenderLanesCursor.current; - pop(subtreeRenderLanesCursor, fiber); -} -function prepareFreshStack(root, lanes) { +function prepareFreshStack(root, expirationTime) { root.finishedWork = null; - root.finishedLanes = NoLanes; + root.finishedExpirationTime = NoWork; var timeoutHandle = root.timeoutHandle; if (timeoutHandle !== noTimeout) { @@ -18124,14 +17329,14 @@ function prepareFreshStack(root, lanes) { workInProgressRoot = root; workInProgress = createWorkInProgress(root.current, null); - workInProgressRootRenderLanes = subtreeRenderLanes = workInProgressRootIncludedLanes = lanes; + renderExpirationTime$1 = expirationTime; workInProgressRootExitStatus = RootIncomplete; workInProgressRootFatalError = null; - workInProgressRootLatestSuspenseTimeout = NoTimestamp; + workInProgressRootLatestProcessedExpirationTime = Sync; + workInProgressRootLatestSuspenseTimeout = Sync; workInProgressRootCanSuspendUsingConfig = null; - workInProgressRootSkippedLanes = NoLanes; - workInProgressRootUpdatedLanes = NoLanes; - workInProgressRootPingedLanes = NoLanes; + workInProgressRootNextUnprocessedUpdateTime = NoWork; + workInProgressRootHasPendingPing = false; { spawnedWorkDuringRender = null; @@ -18144,18 +17349,13 @@ function prepareFreshStack(root, lanes) { function handleError(root, thrownValue) { do { - var erroredWork = workInProgress; - try { // Reset module-level state that was set during the render phase. resetContextDependencies(); resetHooksAfterThrow(); - resetCurrentFiber(); // TODO: I found and added this missing line while investigating a - // separate issue. Write a regression test using string refs. + resetCurrentFiber(); - ReactCurrentOwner$2.current = null; - - if (erroredWork === null || erroredWork.return === null) { + if (workInProgress === null || workInProgress.return === null) { // Expected to be working on a non-root fiber. This is a fatal error // because there's no ancestor that can handle it; the root is // supposed to capture all errors that weren't caught by an error @@ -18165,41 +17365,31 @@ function handleError(root, thrownValue) { // sibling, or the parent if there are no siblings. But since the root // has no siblings nor a parent, we set it to null. Usually this is // handled by `completeUnitOfWork` or `unwindWork`, but since we're - // intentionally not calling those, we need set it here. + // interntionally not calling those, we need set it here. // TODO: Consider calling `unwindWork` to pop the contexts. workInProgress = null; - return; + return null; } - if (enableProfilerTimer && erroredWork.mode & ProfileMode) { + if (enableProfilerTimer && workInProgress.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(erroredWork, true); + stopProfilerTimerIfRunningAndRecordDelta(workInProgress, true); } throwException( root, - erroredWork.return, - erroredWork, + workInProgress.return, + workInProgress, thrownValue, - workInProgressRootRenderLanes + renderExpirationTime$1 ); - completeUnitOfWork(erroredWork); + workInProgress = completeUnitOfWork(workInProgress); } catch (yetAnotherThrownValue) { // Something in the return path also threw. thrownValue = yetAnotherThrownValue; - - if (workInProgress === erroredWork && erroredWork !== null) { - // If this boundary has already errored, then we had trouble processing - // the error. Bubble it to the next boundary. - erroredWork = erroredWork.return; - workInProgress = erroredWork; - } else { - erroredWork = workInProgress; - } - continue; } // Return to the normal work loop. @@ -18208,8 +17398,8 @@ function handleError(root, thrownValue) { } function pushDispatcher(root) { - var prevDispatcher = ReactCurrentDispatcher$2.current; - ReactCurrentDispatcher$2.current = ContextOnlyDispatcher; + var prevDispatcher = ReactCurrentDispatcher$1.current; + ReactCurrentDispatcher$1.current = ContextOnlyDispatcher; if (prevDispatcher === null) { // The React isomorphic package does not include a default dispatcher. @@ -18222,7 +17412,7 @@ function pushDispatcher(root) { } function popDispatcher(prevDispatcher) { - ReactCurrentDispatcher$2.current = prevDispatcher; + ReactCurrentDispatcher$1.current = prevDispatcher; } function pushInteractions(root) { @@ -18242,32 +17432,29 @@ function popInteractions(prevInteractions) { function markCommitTimeOfFallback() { globalMostRecentFallbackTime = now(); } -function markRenderEventTimeAndConfig(eventTime, suspenseConfig) { - // Track the largest/latest timeout deadline in this batch. - // TODO: If there are two transitions in the same batch, shouldn't we - // choose the smaller one? Maybe this is because when an intermediate - // transition is superseded, we should ignore its suspense config, but - // we don't currently. +function markRenderEventTimeAndConfig(expirationTime, suspenseConfig) { + if ( + expirationTime < workInProgressRootLatestProcessedExpirationTime && + expirationTime > Idle + ) { + workInProgressRootLatestProcessedExpirationTime = expirationTime; + } + if (suspenseConfig !== null) { - // If `timeoutMs` is not specified, we default to 5 seconds. We have to - // resolve this default here because `suspenseConfig` is owned - // by userspace. - // TODO: Store this on the root instead (transition -> timeoutMs) - // TODO: Should this default to a JND instead? - var timeoutMs = suspenseConfig.timeoutMs | 0 || DEFAULT_TIMEOUT_MS; - var timeoutTime = eventTime + timeoutMs; + if ( + expirationTime < workInProgressRootLatestSuspenseTimeout && + expirationTime > Idle + ) { + workInProgressRootLatestSuspenseTimeout = expirationTime; // Most of the time we only have one config and getting wrong is not bad. - if (timeoutTime > workInProgressRootLatestSuspenseTimeout) { - workInProgressRootLatestSuspenseTimeout = timeoutTime; workInProgressRootCanSuspendUsingConfig = suspenseConfig; } } } -function markSkippedUpdateLanes(lane) { - workInProgressRootSkippedLanes = mergeLanes( - lane, - workInProgressRootSkippedLanes - ); +function markUnprocessedUpdateTime(expirationTime) { + if (expirationTime > workInProgressRootNextUnprocessedUpdateTime) { + workInProgressRootNextUnprocessedUpdateTime = expirationTime; + } } function renderDidSuspend() { if (workInProgressRootExitStatus === RootIncomplete) { @@ -18280,22 +17467,21 @@ function renderDidSuspendDelayIfPossible() { workInProgressRootExitStatus === RootSuspended ) { workInProgressRootExitStatus = RootSuspendedWithDelay; - } // Check if there are updates that we skipped tree that might have unblocked - // this render. + } // Check if there's a lower priority update somewhere else in the tree. if ( - workInProgressRoot !== null && - (includesNonIdleWork(workInProgressRootSkippedLanes) || - includesNonIdleWork(workInProgressRootUpdatedLanes)) + workInProgressRootNextUnprocessedUpdateTime !== NoWork && + workInProgressRoot !== null ) { - // Mark the current render as suspended so that we switch to working on - // the updates that were skipped. Usually we only suspend at the end of - // the render phase. - // TODO: We should probably always mark the root as suspended immediately - // (inside this function), since by suspending at the end of the render - // phase introduces a potential mistake where we suspend lanes that were - // pinged or updated while we were rendering. - markRootSuspended$1(workInProgressRoot, workInProgressRootRenderLanes); + // Mark the current render as suspended, and then mark that there's a + // pending update. + // TODO: This should immediately interrupt the current render, instead + // of waiting until the next time we yield. + markRootSuspendedAtTime(workInProgressRoot, renderExpirationTime$1); + markRootUpdatedAtTime( + workInProgressRoot, + workInProgressRootNextUnprocessedUpdateTime + ); } } function renderDidError() { @@ -18311,18 +17497,43 @@ function renderHasNotSuspendedYet() { return workInProgressRootExitStatus === RootIncomplete; } -function renderRootSync(root, lanes) { +function inferTimeFromExpirationTime(expirationTime) { + // We don't know exactly when the update was scheduled, but we can infer an + // approximate start time from the expiration time. + var earliestExpirationTimeMs = expirationTimeToMs(expirationTime); + return earliestExpirationTimeMs - LOW_PRIORITY_EXPIRATION; +} + +function inferTimeFromExpirationTimeWithSuspenseConfig( + expirationTime, + suspenseConfig +) { + // We don't know exactly when the update was scheduled, but we can infer an + // approximate start time from the expiration time by subtracting the timeout + // that was added to the event time. + var earliestExpirationTimeMs = expirationTimeToMs(expirationTime); + return ( + earliestExpirationTimeMs - + (suspenseConfig.timeoutMs | 0 || LOW_PRIORITY_EXPIRATION) + ); +} + +function renderRootSync(root, expirationTime) { var prevExecutionContext = executionContext; executionContext |= RenderContext; - var prevDispatcher = pushDispatcher(); // If the root or lanes have changed, throw out the existing stack + var prevDispatcher = pushDispatcher(); // If the root or expiration time have changed, throw out the existing stack // and prepare a fresh one. Otherwise we'll continue where we left off. - if (workInProgressRoot !== root || workInProgressRootRenderLanes !== lanes) { - prepareFreshStack(root, lanes); - startWorkOnPendingInteractions(root, lanes); + if ( + root !== workInProgressRoot || + expirationTime !== renderExpirationTime$1 + ) { + prepareFreshStack(root, expirationTime); + startWorkOnPendingInteractions(root, expirationTime); } var prevInteractions = pushInteractions(root); + startWorkLoopTimer(workInProgress); do { try { @@ -18351,8 +17562,9 @@ function renderRootSync(root, lanes) { } } + stopFinishedWorkLoopTimer(); // Set this to null to indicate there's no in-progress render. + workInProgressRoot = null; - workInProgressRootRenderLanes = NoLanes; return workInProgressRootExitStatus; } // The work loop is an extremely hot path. Tell Closure not to inline it. @@ -18361,22 +17573,26 @@ function renderRootSync(root, lanes) { function workLoopSync() { // Already timed out, so perform work without checking if we need to yield. while (workInProgress !== null) { - performUnitOfWork(workInProgress); + workInProgress = performUnitOfWork(workInProgress); } } -function renderRootConcurrent(root, lanes) { +function renderRootConcurrent(root, expirationTime) { var prevExecutionContext = executionContext; executionContext |= RenderContext; - var prevDispatcher = pushDispatcher(); // If the root or lanes have changed, throw out the existing stack + var prevDispatcher = pushDispatcher(); // If the root or expiration time have changed, throw out the existing stack // and prepare a fresh one. Otherwise we'll continue where we left off. - if (workInProgressRoot !== root || workInProgressRootRenderLanes !== lanes) { - prepareFreshStack(root, lanes); - startWorkOnPendingInteractions(root, lanes); + if ( + root !== workInProgressRoot || + expirationTime !== renderExpirationTime$1 + ) { + prepareFreshStack(root, expirationTime); + startWorkOnPendingInteractions(root, expirationTime); } var prevInteractions = pushInteractions(root); + startWorkLoopTimer(workInProgress); do { try { @@ -18394,13 +17610,17 @@ function renderRootConcurrent(root, lanes) { } popDispatcher(prevDispatcher); - executionContext = prevExecutionContext; + executionContext = prevExecutionContext; // Check if the tree has completed. if (workInProgress !== null) { + // Still work remaining. + stopInterruptedWorkLoopTimer(); return RootIncomplete; } else { - workInProgressRoot = null; - workInProgressRootRenderLanes = NoLanes; // Return the final exit status. + // Completed the tree. + stopFinishedWorkLoopTimer(); // Set this to null to indicate there's no in-progress render. + + workInProgressRoot = null; // Return the final exit status. return workInProgressRootExitStatus; } @@ -18410,7 +17630,7 @@ function renderRootConcurrent(root, lanes) { function workLoopConcurrent() { // Perform work until Scheduler asks us to yield while (workInProgress !== null && !shouldYield()) { - performUnitOfWork(workInProgress); + workInProgress = performUnitOfWork(workInProgress); } } @@ -18419,15 +17639,16 @@ function performUnitOfWork(unitOfWork) { // nothing should rely on this, but relying on it here means that we don't // need an additional field on the work in progress. var current = unitOfWork.alternate; + startWorkTimer(unitOfWork); setCurrentFiber(unitOfWork); var next; if ((unitOfWork.mode & ProfileMode) !== NoMode) { startProfilerTimer(unitOfWork); - next = beginWork$1(current, unitOfWork, subtreeRenderLanes); + next = beginWork$1(current, unitOfWork, renderExpirationTime$1); stopProfilerTimerIfRunningAndRecordDelta(unitOfWork, true); } else { - next = beginWork$1(current, unitOfWork, subtreeRenderLanes); + next = beginWork$1(current, unitOfWork, renderExpirationTime$1); } resetCurrentFiber(); @@ -18435,49 +17656,47 @@ function performUnitOfWork(unitOfWork) { if (next === null) { // If this doesn't spawn new work, complete the current work. - completeUnitOfWork(unitOfWork); - } else { - workInProgress = next; + next = completeUnitOfWork(unitOfWork); } ReactCurrentOwner$2.current = null; + return next; } function completeUnitOfWork(unitOfWork) { // Attempt to complete the current unit of work, then move to the next // sibling. If there are no more siblings, return to the parent fiber. - var completedWork = unitOfWork; + workInProgress = unitOfWork; do { // The current, flushed, state of this fiber is the alternate. Ideally // nothing should rely on this, but relying on it here means that we don't // need an additional field on the work in progress. - var current = completedWork.alternate; - var returnFiber = completedWork.return; // Check if the work completed or if something threw. + var current = workInProgress.alternate; + var returnFiber = workInProgress.return; // Check if the work completed or if something threw. - if ((completedWork.effectTag & Incomplete) === NoEffect) { - setCurrentFiber(completedWork); + if ((workInProgress.effectTag & Incomplete) === NoEffect) { + setCurrentFiber(workInProgress); var next = void 0; - if ((completedWork.mode & ProfileMode) === NoMode) { - next = completeWork(current, completedWork, subtreeRenderLanes); + if ((workInProgress.mode & ProfileMode) === NoMode) { + next = completeWork(current, workInProgress, renderExpirationTime$1); } else { - startProfilerTimer(completedWork); - next = completeWork(current, completedWork, subtreeRenderLanes); // Update render duration assuming we didn't error. + startProfilerTimer(workInProgress); + next = completeWork(current, workInProgress, renderExpirationTime$1); // Update render duration assuming we didn't error. - stopProfilerTimerIfRunningAndRecordDelta(completedWork, false); + stopProfilerTimerIfRunningAndRecordDelta(workInProgress, false); } + stopWorkTimer(workInProgress); resetCurrentFiber(); + resetChildExpirationTime(workInProgress); if (next !== null) { // Completing this fiber spawned new work. Work on that next. - workInProgress = next; - return; + return next; } - resetChildLanes(completedWork); - if ( returnFiber !== null && // Do not append effects to parents if a sibling failed to complete (returnFiber.effectTag & Incomplete) === NoEffect @@ -18486,15 +17705,15 @@ function completeUnitOfWork(unitOfWork) { // list of the parent. The completion order of the children affects the // side-effect order. if (returnFiber.firstEffect === null) { - returnFiber.firstEffect = completedWork.firstEffect; + returnFiber.firstEffect = workInProgress.firstEffect; } - if (completedWork.lastEffect !== null) { + if (workInProgress.lastEffect !== null) { if (returnFiber.lastEffect !== null) { - returnFiber.lastEffect.nextEffect = completedWork.firstEffect; + returnFiber.lastEffect.nextEffect = workInProgress.firstEffect; } - returnFiber.lastEffect = completedWork.lastEffect; + returnFiber.lastEffect = workInProgress.lastEffect; } // If this fiber had side-effects, we append it AFTER the children's // side-effects. We can perform certain side-effects earlier if needed, // by doing multiple passes over the effect list. We don't want to @@ -18502,51 +17721,55 @@ function completeUnitOfWork(unitOfWork) { // reusing children we'll schedule this effect onto itself since we're // at the end. - var effectTag = completedWork.effectTag; // Skip both NoWork and PerformedWork tags when creating the effect + var effectTag = workInProgress.effectTag; // Skip both NoWork and PerformedWork tags when creating the effect // list. PerformedWork effect is read by React DevTools but shouldn't be // committed. if (effectTag > PerformedWork) { if (returnFiber.lastEffect !== null) { - returnFiber.lastEffect.nextEffect = completedWork; + returnFiber.lastEffect.nextEffect = workInProgress; } else { - returnFiber.firstEffect = completedWork; + returnFiber.firstEffect = workInProgress; } - returnFiber.lastEffect = completedWork; + returnFiber.lastEffect = workInProgress; } } } else { // This fiber did not complete because something threw. Pop values off // the stack without entering the complete phase. If this is a boundary, // capture values if possible. - var _next = unwindWork(completedWork); // Because this fiber did not complete, don't reset its expiration time. + var _next = unwindWork(workInProgress); // Because this fiber did not complete, don't reset its expiration time. - if (_next !== null) { - // 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 - // from the effect tag. - _next.effectTag &= HostEffectMask; - workInProgress = _next; - return; - } - - if ((completedWork.mode & ProfileMode) !== NoMode) { + if ((workInProgress.mode & ProfileMode) !== NoMode) { // Record the render duration for the fiber that errored. - stopProfilerTimerIfRunningAndRecordDelta(completedWork, false); // Include the time spent working on failed children before continuing. + stopProfilerTimerIfRunningAndRecordDelta(workInProgress, false); // Include the time spent working on failed children before continuing. - var actualDuration = completedWork.actualDuration; - var child = completedWork.child; + var actualDuration = workInProgress.actualDuration; + var child = workInProgress.child; while (child !== null) { actualDuration += child.actualDuration; child = child.sibling; } - completedWork.actualDuration = actualDuration; + workInProgress.actualDuration = actualDuration; } + if (_next !== null) { + // 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 + // from the effect tag. + // TODO: The name stopFailedWorkTimer is misleading because Suspense + // also captures and restarts. + stopFailedWorkTimer(workInProgress); + _next.effectTag &= HostEffectMask; + return _next; + } + + stopWorkTimer(workInProgress); + if (returnFiber !== null) { // Mark the parent fiber as incomplete and clear its effect list. returnFiber.firstEffect = returnFiber.lastEffect = null; @@ -18554,40 +17777,42 @@ function completeUnitOfWork(unitOfWork) { } } - var siblingFiber = completedWork.sibling; + var siblingFiber = workInProgress.sibling; if (siblingFiber !== null) { // If there is more work to do in this returnFiber, do that next. - workInProgress = siblingFiber; - return; + return siblingFiber; } // Otherwise, return to the parent - completedWork = returnFiber; // Update the next thing we're working on in case something throws. - - workInProgress = completedWork; - } while (completedWork !== null); // We've reached the root. + workInProgress = returnFiber; + } while (workInProgress !== null); // We've reached the root. if (workInProgressRootExitStatus === RootIncomplete) { workInProgressRootExitStatus = RootCompleted; } + + return null; } -function resetChildLanes(completedWork) { +function getRemainingExpirationTime(fiber) { + var updateExpirationTime = fiber.expirationTime; + var childExpirationTime = fiber.childExpirationTime; + return updateExpirationTime > childExpirationTime + ? updateExpirationTime + : childExpirationTime; +} + +function resetChildExpirationTime(completedWork) { if ( - // TODO: Move this check out of the hot path by moving `resetChildLanes` - // to switch statement in `completeWork`. - (completedWork.tag === LegacyHiddenComponent || - completedWork.tag === OffscreenComponent) && - completedWork.memoizedState !== null && - !includesSomeLane(subtreeRenderLanes, OffscreenLane) && - (completedWork.mode & ConcurrentMode) !== NoLanes + renderExpirationTime$1 !== Never && + completedWork.childExpirationTime === Never ) { // The children of this component are hidden. Don't bubble their // expiration times. return; } - var newChildLanes = NoLanes; // Bubble up the earliest expiration time. + var newChildExpirationTime = NoWork; // Bubble up the earliest expiration time. if ((completedWork.mode & ProfileMode) !== NoMode) { // In profiling mode, resetChildExpirationTime is also used to reset @@ -18607,10 +17832,16 @@ function resetChildLanes(completedWork) { var child = completedWork.child; while (child !== null) { - newChildLanes = mergeLanes( - newChildLanes, - mergeLanes(child.lanes, child.childLanes) - ); + var childUpdateExpirationTime = child.expirationTime; + var childChildExpirationTime = child.childExpirationTime; + + if (childUpdateExpirationTime > newChildExpirationTime) { + newChildExpirationTime = childUpdateExpirationTime; + } + + if (childChildExpirationTime > newChildExpirationTime) { + newChildExpirationTime = childChildExpirationTime; + } if (shouldBubbleActualDurations) { actualDuration += child.actualDuration; @@ -18620,40 +17851,34 @@ function resetChildLanes(completedWork) { child = child.sibling; } - var isTimedOutSuspense = - completedWork.tag === SuspenseComponent && - completedWork.memoizedState !== null; - - if (isTimedOutSuspense) { - // Don't count time spent in a timed out Suspense subtree as part of the base duration. - var primaryChildFragment = completedWork.child; - - if (primaryChildFragment !== null) { - treeBaseDuration -= primaryChildFragment.treeBaseDuration; - } - } - completedWork.actualDuration = actualDuration; completedWork.treeBaseDuration = treeBaseDuration; } else { var _child = completedWork.child; while (_child !== null) { - newChildLanes = mergeLanes( - newChildLanes, - mergeLanes(_child.lanes, _child.childLanes) - ); + var _childUpdateExpirationTime = _child.expirationTime; + var _childChildExpirationTime = _child.childExpirationTime; + + if (_childUpdateExpirationTime > newChildExpirationTime) { + newChildExpirationTime = _childUpdateExpirationTime; + } + + if (_childChildExpirationTime > newChildExpirationTime) { + newChildExpirationTime = _childChildExpirationTime; + } + _child = _child.sibling; } } - completedWork.childLanes = newChildLanes; + completedWork.childExpirationTime = newChildExpirationTime; } function commitRoot(root) { var renderPriorityLevel = getCurrentPriorityLevel(); runWithPriority( - ImmediatePriority$1, + ImmediatePriority, commitRootImpl.bind(null, root, renderPriorityLevel) ); return null; @@ -18677,14 +17902,14 @@ function commitRootImpl(root, renderPriorityLevel) { } var finishedWork = root.finishedWork; - var lanes = root.finishedLanes; + var expirationTime = root.finishedExpirationTime; if (finishedWork === null) { return null; } root.finishedWork = null; - root.finishedLanes = NoLanes; + root.finishedExpirationTime = NoWork; if (!(finishedWork !== root.current)) { throw Error( @@ -18693,28 +17918,27 @@ function commitRootImpl(root, renderPriorityLevel) { } // commitRoot never returns a continuation; it always finishes synchronously. // So we can clear these now to allow a new callback to be scheduled. - root.callbackNode = null; // Update the first and last pending times on this root. The new first + root.callbackNode = null; + root.callbackExpirationTime = NoWork; + root.callbackPriority = NoPriority; + root.nextKnownPendingLevel = NoWork; + startCommitTimer(); // Update the first and last pending times on this root. The new first // pending time is whatever is left on the root fiber. - var remainingLanes = mergeLanes(finishedWork.lanes, finishedWork.childLanes); - markRootFinished(root, remainingLanes); // Clear already finished discrete updates in case that a later call of - // `flushDiscreteUpdates` starts a useless render pass which may cancels - // a scheduled timeout. - - if (rootsWithPendingDiscreteUpdates !== null) { - if ( - !hasDiscreteLanes(remainingLanes) && - rootsWithPendingDiscreteUpdates.has(root) - ) { - rootsWithPendingDiscreteUpdates.delete(root); - } - } + var remainingExpirationTimeBeforeCommit = getRemainingExpirationTime( + finishedWork + ); + markRootFinishedAtTime( + root, + expirationTime, + remainingExpirationTimeBeforeCommit + ); if (root === workInProgressRoot) { // We can reset these now that they are finished. workInProgressRoot = null; workInProgress = null; - workInProgressRootRenderLanes = NoLanes; + renderExpirationTime$1 = NoWork; } // This indicates that the last root we worked on is not the same one that // we're committing now. This most commonly happens when a suspended root // times out. @@ -18750,8 +17974,8 @@ function commitRootImpl(root, renderPriorityLevel) { // state of the host tree right before we mutate it. This is where // getSnapshotBeforeUpdate is called. - focusedInstanceHandle = prepareForCommit(root.containerInfo); - shouldFireAfterActiveInstanceBlur = false; + startCommitSnapshotEffectsTimer(); + prepareForCommit(root.containerInfo); nextEffect = firstEffect; do { @@ -18768,9 +17992,9 @@ function commitRootImpl(root, renderPriorityLevel) { nextEffect = nextEffect.nextEffect; } } - } while (nextEffect !== null); // We no longer need to track the active instance fiber + } while (nextEffect !== null); - focusedInstanceHandle = null; + stopCommitSnapshotEffectsTimer(); { // Mark the current commit time to be shared by all Profilers in this @@ -18778,6 +18002,7 @@ function commitRootImpl(root, renderPriorityLevel) { recordCommitTime(); } // The next phase is the mutation phase, where we mutate the host tree. + startCommitHostEffectsTimer(); nextEffect = firstEffect; do { @@ -18803,6 +18028,7 @@ function commitRootImpl(root, renderPriorityLevel) { } } while (nextEffect !== null); + stopCommitHostEffectsTimer(); resetAfterCommit(root.containerInfo); // The work-in-progress tree is now the current tree. This must come after // the mutation phase, so that the previous tree is still current during // componentWillUnmount, but before the layout phase, so that the finished @@ -18812,11 +18038,18 @@ function commitRootImpl(root, renderPriorityLevel) { // the host tree after it's been mutated. The idiomatic use case for this is // layout, but class component lifecycles also fire here for legacy reasons. + startCommitLifeCyclesTimer(); nextEffect = firstEffect; do { { - invokeGuardedCallback(null, commitLayoutEffects, null, root, lanes); + invokeGuardedCallback( + null, + commitLayoutEffects, + null, + root, + expirationTime + ); if (hasCaughtError()) { if (!(nextEffect !== null)) { @@ -18831,6 +18064,7 @@ function commitRootImpl(root, renderPriorityLevel) { } } while (nextEffect !== null); + stopCommitLifeCyclesTimer(); nextEffect = null; // Tell Scheduler to yield at the end of the frame, so the browser has an // opportunity to paint. @@ -18840,18 +18074,27 @@ function commitRootImpl(root, renderPriorityLevel) { popInteractions(prevInteractions); } - executionContext = prevExecutionContext; // Reset the priority to the previous non-sync value. + executionContext = prevExecutionContext; } else { // No effects. root.current = finishedWork; // Measure these anyway so the flamegraph explicitly shows that there were // no effects. // TODO: Maybe there's a better way to report this. + startCommitSnapshotEffectsTimer(); + stopCommitSnapshotEffectsTimer(); + { recordCommitTime(); } + + startCommitHostEffectsTimer(); + stopCommitHostEffectsTimer(); + startCommitLifeCyclesTimer(); + stopCommitLifeCyclesTimer(); } + stopCommitTimer(); var rootDidHavePassiveEffects = rootDoesHavePassiveEffects; if (rootDoesHavePassiveEffects) { @@ -18859,7 +18102,7 @@ function commitRootImpl(root, renderPriorityLevel) { // schedule a callback until after flushing layout work. rootDoesHavePassiveEffects = false; rootWithPendingPassiveEffects = root; - pendingPassiveEffectsLanes = lanes; + pendingPassiveEffectsExpirationTime = expirationTime; pendingPassiveEffectsRenderPriority = renderPriorityLevel; } else { // We are done with the effect chain at this point so let's clear the @@ -18870,18 +18113,13 @@ function commitRootImpl(root, renderPriorityLevel) { while (nextEffect !== null) { var nextNextEffect = nextEffect.nextEffect; nextEffect.nextEffect = null; - - if (nextEffect.effectTag & Deletion) { - detachFiberAfterEffects(nextEffect); - } - nextEffect = nextNextEffect; } - } // Read this again, since an effect might have updated it + } // Check if there's remaining work on this root - remainingLanes = root.pendingLanes; // Check if there's remaining work on this root + var remainingExpirationTime = root.firstPendingTime; - if (remainingLanes !== NoLanes) { + if (remainingExpirationTime !== NoWork) { { if (spawnedWorkDuringRender !== null) { var expirationTimes = spawnedWorkDuringRender; @@ -18896,7 +18134,7 @@ function commitRootImpl(root, renderPriorityLevel) { } } - schedulePendingInteractions(root, remainingLanes); + schedulePendingInteractions(root, remainingExpirationTime); } } else { // If there's no remaining work, we can clear the set of already failed @@ -18910,11 +18148,11 @@ function commitRootImpl(root, renderPriorityLevel) { // Otherwise, we'll wait until after the passive effects are flushed. // Wait to do this until after remaining work has been scheduled, // so that we don't prematurely signal complete for interactions when there's e.g. hidden work. - finishPendingInteractions(root, lanes); + finishPendingInteractions(root, expirationTime); } } - if (remainingLanes === SyncLane) { + if (remainingExpirationTime === Sync) { // Count the number of times the root synchronously re-renders without // finishing. If there are too many, it indicates an infinite update loop. if (root === rootWithNestedUpdates) { @@ -18927,10 +18165,10 @@ function commitRootImpl(root, renderPriorityLevel) { nestedUpdateCount = 0; } - onCommitRoot(finishedWork.stateNode, renderPriorityLevel); + onCommitRoot(finishedWork.stateNode, expirationTime); // Always call this before exiting `commitRoot`, to ensure that any // additional work on this root is scheduled. - ensureRootIsScheduled(root, now()); + ensureRootIsScheduled(root); if (hasUncaughtError) { hasUncaughtError = false; @@ -18940,43 +18178,25 @@ function commitRootImpl(root, renderPriorityLevel) { } if ((executionContext & LegacyUnbatchedContext) !== NoContext) { + // This is a legacy edge case. We just committed the initial mount of // a ReactDOM.render-ed root inside of batchedUpdates. The commit fired // synchronously, but layout updates should be deferred until the end // of the batch. - return null; } // If layout work was scheduled, flush it now. flushSyncCallbackQueue(); - return null; } function commitBeforeMutationEffects() { while (nextEffect !== null) { - var current = nextEffect.alternate; - - if (!shouldFireAfterActiveInstanceBlur && focusedInstanceHandle !== null) { - if ((nextEffect.effectTag & Deletion) !== NoEffect) { - if (doesFiberContain(nextEffect, focusedInstanceHandle)) { - shouldFireAfterActiveInstanceBlur = true; - } - } else { - // TODO: Move this out of the hot path using a dedicated effect tag. - if ( - nextEffect.tag === SuspenseComponent && - isSuspenseBoundaryBeingHidden(current, nextEffect) && - doesFiberContain(nextEffect, focusedInstanceHandle) - ) { - shouldFireAfterActiveInstanceBlur = true; - } - } - } - var effectTag = nextEffect.effectTag; if ((effectTag & Snapshot) !== NoEffect) { setCurrentFiber(nextEffect); + recordEffect(); + var current = nextEffect.alternate; commitBeforeMutationLifeCycles(current, nextEffect); resetCurrentFiber(); } @@ -18986,7 +18206,7 @@ function commitBeforeMutationEffects() { // the earliest opportunity. if (!rootDoesHavePassiveEffects) { rootDoesHavePassiveEffects = true; - scheduleCallback(NormalPriority$1, function() { + scheduleCallback(NormalPriority, function() { flushPassiveEffects(); return null; }); @@ -19057,30 +18277,32 @@ function commitMutationEffects(root, renderPriorityLevel) { } case Deletion: { - commitDeletion(root, nextEffect); + commitDeletion(root, nextEffect, renderPriorityLevel); break; } - } + } // TODO: Only record a mutation effect if primaryEffectTag is non-zero. + recordEffect(); resetCurrentFiber(); nextEffect = nextEffect.nextEffect; } } -function commitLayoutEffects(root, committedLanes) { +function commitLayoutEffects(root, committedExpirationTime) { + // TODO: Should probably move the bulk of this function to commitWork. while (nextEffect !== null) { setCurrentFiber(nextEffect); var effectTag = nextEffect.effectTag; if (effectTag & (Update | Callback)) { + recordEffect(); var current = nextEffect.alternate; commitLifeCycles(root, current, nextEffect); } - { - if (effectTag & Ref) { - commitAttachRef(nextEffect); - } + if (effectTag & Ref) { + recordEffect(); + commitAttachRef(nextEffect); } resetCurrentFiber(); @@ -19089,60 +18311,14 @@ function commitLayoutEffects(root, committedLanes) { } function flushPassiveEffects() { - // Returns whether passive effects were flushed. - if (pendingPassiveEffectsRenderPriority !== NoPriority$1) { + if (pendingPassiveEffectsRenderPriority !== NoPriority) { var priorityLevel = - pendingPassiveEffectsRenderPriority > NormalPriority$1 - ? NormalPriority$1 + pendingPassiveEffectsRenderPriority > NormalPriority + ? NormalPriority : pendingPassiveEffectsRenderPriority; - pendingPassiveEffectsRenderPriority = NoPriority$1; - - try { - setCurrentUpdateLanePriority( - schedulerPriorityToLanePriority(priorityLevel) - ); - return runWithPriority(priorityLevel, flushPassiveEffectsImpl); - } finally { - } + pendingPassiveEffectsRenderPriority = NoPriority; + return runWithPriority(priorityLevel, flushPassiveEffectsImpl); } - - return false; -} -function enqueuePendingPassiveHookEffectMount(fiber, effect) { - pendingPassiveHookEffectsMount.push(effect, fiber); - - if (!rootDoesHavePassiveEffects) { - rootDoesHavePassiveEffects = true; - scheduleCallback(NormalPriority$1, function() { - flushPassiveEffects(); - return null; - }); - } -} -function enqueuePendingPassiveHookEffectUnmount(fiber, effect) { - pendingPassiveHookEffectsUnmount.push(effect, fiber); - - { - fiber.effectTag |= PassiveUnmountPendingDev; - var alternate = fiber.alternate; - - if (alternate !== null) { - alternate.effectTag |= PassiveUnmountPendingDev; - } - } - - if (!rootDoesHavePassiveEffects) { - rootDoesHavePassiveEffects = true; - scheduleCallback(NormalPriority$1, function() { - flushPassiveEffects(); - return null; - }); - } -} - -function invokePassiveEffectCreate(effect) { - var create = effect.create; - effect.destroy = create(); } function flushPassiveEffectsImpl() { @@ -19151,119 +18327,52 @@ function flushPassiveEffectsImpl() { } var root = rootWithPendingPassiveEffects; - var lanes = pendingPassiveEffectsLanes; + var expirationTime = pendingPassiveEffectsExpirationTime; rootWithPendingPassiveEffects = null; - pendingPassiveEffectsLanes = NoLanes; + pendingPassiveEffectsExpirationTime = NoWork; if (!((executionContext & (RenderContext | CommitContext)) === NoContext)) { throw Error("Cannot flush passive effects while already rendering."); } - { - isFlushingPassiveEffects = true; - } - var prevExecutionContext = executionContext; executionContext |= CommitContext; - var prevInteractions = pushInteractions(root); // It's important that ALL pending passive effect destroy functions are called - // before ANY passive effect create functions are called. - // Otherwise effects in sibling components might interfere with each other. - // e.g. a destroy function in one component may unintentionally override a ref - // value set by a create function in another component. - // Layout effects have the same constraint. - // First pass: Destroy stale passive effects. + var prevInteractions = pushInteractions(root); - var unmountEffects = pendingPassiveHookEffectsUnmount; - pendingPassiveHookEffectsUnmount = []; + { + // Note: This currently assumes there are no passive effects on the root fiber + // because the root is not part of its own effect list. + // This could change in the future. + var _effect2 = root.current.firstEffect; - for (var i = 0; i < unmountEffects.length; i += 2) { - var _effect = unmountEffects[i]; - var fiber = unmountEffects[i + 1]; - var destroy = _effect.destroy; - _effect.destroy = undefined; - - { - fiber.effectTag &= ~PassiveUnmountPendingDev; - var alternate = fiber.alternate; - - if (alternate !== null) { - alternate.effectTag &= ~PassiveUnmountPendingDev; - } - } - - if (typeof destroy === "function") { + while (_effect2 !== null) { { - setCurrentFiber(fiber); - - { - invokeGuardedCallback(null, destroy, null); - } + setCurrentFiber(_effect2); + invokeGuardedCallback(null, commitPassiveHookEffects, null, _effect2); if (hasCaughtError()) { - if (!(fiber !== null)) { + if (!(_effect2 !== null)) { throw Error("Should be working on an effect."); } - var error = clearCaughtError(); - captureCommitPhaseError(fiber, error); + var _error5 = clearCaughtError(); + + captureCommitPhaseError(_effect2, _error5); } resetCurrentFiber(); } + + var nextNextEffect = _effect2.nextEffect; // Remove nextEffect pointer to assist GC + + _effect2.nextEffect = null; + _effect2 = nextNextEffect; } - } // Second pass: Create new passive effects. - - var mountEffects = pendingPassiveHookEffectsMount; - pendingPassiveHookEffectsMount = []; - - for (var _i = 0; _i < mountEffects.length; _i += 2) { - var _effect2 = mountEffects[_i]; - var _fiber = mountEffects[_i + 1]; - - { - setCurrentFiber(_fiber); - - { - invokeGuardedCallback(null, invokePassiveEffectCreate, null, _effect2); - } - - if (hasCaughtError()) { - if (!(_fiber !== null)) { - throw Error("Should be working on an effect."); - } - - var _error4 = clearCaughtError(); - - captureCommitPhaseError(_fiber, _error4); - } - - resetCurrentFiber(); - } - } // Note: This currently assumes there are no passive effects on the root fiber - // because the root is not part of its own effect list. - // This could change in the future. - - var effect = root.current.firstEffect; - - while (effect !== null) { - var nextNextEffect = effect.nextEffect; // Remove nextEffect pointer to assist GC - - effect.nextEffect = null; - - if (effect.effectTag & Deletion) { - detachFiberAfterEffects(effect); - } - - effect = nextNextEffect; } { popInteractions(prevInteractions); - finishPendingInteractions(root, lanes); - } - - { - isFlushingPassiveEffects = false; + finishPendingInteractions(root, expirationTime); } executionContext = prevExecutionContext; @@ -19300,15 +18409,13 @@ var onUncaughtError = prepareToThrowUncaughtError; function captureCommitPhaseErrorOnRoot(rootFiber, sourceFiber, error) { var errorInfo = createCapturedValue(error, sourceFiber); - var update = createRootErrorUpdate(rootFiber, errorInfo, SyncLane); + var update = createRootErrorUpdate(rootFiber, errorInfo, Sync); enqueueUpdate(rootFiber, update); - var eventTime = requestEventTime(); - var root = markUpdateLaneFromFiberToRoot(rootFiber, SyncLane); + var root = markUpdateTimeFromFiberToRoot(rootFiber, Sync); if (root !== null) { - markRootUpdated(root, SyncLane, eventTime); - ensureRootIsScheduled(root, eventTime); - schedulePendingInteractions(root, SyncLane); + ensureRootIsScheduled(root); + schedulePendingInteractions(root, Sync); } } @@ -19336,15 +18443,17 @@ function captureCommitPhaseError(sourceFiber, error) { !isAlreadyFailedLegacyErrorBoundary(instance)) ) { var errorInfo = createCapturedValue(error, sourceFiber); - var update = createClassErrorUpdate(fiber, errorInfo, SyncLane); + var update = createClassErrorUpdate( + fiber, + errorInfo, // TODO: This is always sync + Sync + ); enqueueUpdate(fiber, update); - var eventTime = requestEventTime(); - var root = markUpdateLaneFromFiberToRoot(fiber, SyncLane); + var root = markUpdateTimeFromFiberToRoot(fiber, Sync); if (root !== null) { - markRootUpdated(root, SyncLane, eventTime); - ensureRootIsScheduled(root, eventTime); - schedulePendingInteractions(root, SyncLane); + ensureRootIsScheduled(root); + schedulePendingInteractions(root, Sync); } return; @@ -19354,71 +18463,87 @@ function captureCommitPhaseError(sourceFiber, error) { fiber = fiber.return; } } -function pingSuspendedRoot(root, wakeable, pingedLanes) { +function pingSuspendedRoot(root, thenable, suspendedTime) { var pingCache = root.pingCache; if (pingCache !== null) { - // The wakeable resolved, so we no longer need to memoize, because it will + // The thenable resolved, so we no longer need to memoize, because it will // never be thrown again. - pingCache.delete(wakeable); + pingCache.delete(thenable); } - var eventTime = requestEventTime(); - markRootPinged(root, pingedLanes); - - if ( - workInProgressRoot === root && - isSubsetOfLanes(workInProgressRootRenderLanes, pingedLanes) - ) { + if (workInProgressRoot === root && renderExpirationTime$1 === suspendedTime) { // Received a ping at the same priority level at which we're currently // rendering. We might want to restart this render. This should mirror // the logic of whether or not a root suspends once it completes. // TODO: If we're rendering sync either due to Sync, Batched or expired, // we should probably never restart. - // If we're suspended with delay, or if it's a retry, we'll always suspend - // so we can always restart. + // If we're suspended with delay, we'll always suspend so we can always + // restart. If we're suspended without any updates, it might be a retry. + // If it's early in the retry we can restart. We can't know for sure + // whether we'll eventually process an update during this render pass, + // but it's somewhat unlikely that we get to a ping before that, since + // getting to the root most update is usually very fast. if ( workInProgressRootExitStatus === RootSuspendedWithDelay || (workInProgressRootExitStatus === RootSuspended && - includesOnlyRetries(workInProgressRootRenderLanes) && + workInProgressRootLatestProcessedExpirationTime === Sync && now() - globalMostRecentFallbackTime < FALLBACK_THROTTLE_MS) ) { - // Restart from the root. - prepareFreshStack(root, NoLanes); + // Restart from the root. Don't need to schedule a ping because + // we're already working on this tree. + prepareFreshStack(root, renderExpirationTime$1); } else { // Even though we can't restart right now, we might get an // opportunity later. So we mark this render as having a ping. - workInProgressRootPingedLanes = mergeLanes( - workInProgressRootPingedLanes, - pingedLanes - ); + workInProgressRootHasPendingPing = true; } + + return; } - ensureRootIsScheduled(root, eventTime); - schedulePendingInteractions(root, pingedLanes); + if (!isRootSuspendedAtTime(root, suspendedTime)) { + // The root is no longer suspended at this time. + return; + } + + var lastPingedTime = root.lastPingedTime; + + if (lastPingedTime !== NoWork && lastPingedTime < suspendedTime) { + // There's already a lower priority ping scheduled. + return; + } // Mark the time at which this ping was scheduled. + + root.lastPingedTime = suspendedTime; + ensureRootIsScheduled(root); + schedulePendingInteractions(root, suspendedTime); } -function retryTimedOutBoundary(boundaryFiber, retryLane) { +function retryTimedOutBoundary(boundaryFiber, retryTime) { // The boundary fiber (a Suspense component or SuspenseList component) // previously was rendered in its fallback state. One of the promises that // suspended it has resolved, which means at least part of the tree was // likely unblocked. Try rendering again, at a new expiration time. - if (retryLane === NoLane) { - retryLane = requestRetryLane(boundaryFiber); + if (retryTime === NoWork) { + var suspenseConfig = null; // Retries don't carry over the already committed update. + + var currentTime = requestCurrentTimeForUpdate(); + retryTime = computeExpirationForFiber( + currentTime, + boundaryFiber, + suspenseConfig + ); } // TODO: Special case idle priority? - var eventTime = requestEventTime(); - var root = markUpdateLaneFromFiberToRoot(boundaryFiber, retryLane); + var root = markUpdateTimeFromFiberToRoot(boundaryFiber, retryTime); if (root !== null) { - markRootUpdated(root, retryLane, eventTime); - ensureRootIsScheduled(root, eventTime); - schedulePendingInteractions(root, retryLane); + ensureRootIsScheduled(root); + schedulePendingInteractions(root, retryTime); } } -function resolveRetryWakeable(boundaryFiber, wakeable) { - var retryLane = NoLane; // Default +function resolveRetryThenable(boundaryFiber, thenable) { + var retryTime = NoWork; // Default var retryCache; @@ -19427,12 +18552,12 @@ function resolveRetryWakeable(boundaryFiber, wakeable) { } if (retryCache !== null) { - // The wakeable resolved, so we no longer need to memoize, because it will + // The thenable resolved, so we no longer need to memoize, because it will // never be thrown again. - retryCache.delete(wakeable); + retryCache.delete(thenable); } - retryTimedOutBoundary(boundaryFiber, retryLane); + retryTimedOutBoundary(boundaryFiber, retryTime); } // Computes the next Just Noticeable Difference (JND) boundary. // The theory is that a person can't tell the difference between small differences in time. // Therefore, if we wait a bit longer than necessary that won't translate to a noticeable @@ -19461,6 +18586,7 @@ function jnd(timeElapsed) { function computeMsUntilSuspenseLoadingDelay( mostRecentEventTime, + committedExpirationTime, suspenseConfig ) { var busyMinDurationMs = suspenseConfig.busyMinDurationMs | 0; @@ -19472,7 +18598,10 @@ function computeMsUntilSuspenseLoadingDelay( var busyDelayMs = suspenseConfig.busyDelayMs | 0; // Compute the time until this render pass would expire. var currentTimeMs = now(); - var eventTimeMs = mostRecentEventTime; + var eventTimeMs = inferTimeFromExpirationTimeWithSuspenseConfig( + mostRecentEventTime, + suspenseConfig + ); var timeElapsed = currentTimeMs - eventTimeMs; if (timeElapsed <= busyDelayMs) { @@ -19522,66 +18651,25 @@ function flushRenderPhaseStrictModeWarningsInDEV() { } } -var didWarnStateUpdateForNotYetMountedComponent = null; +function stopFinishedWorkLoopTimer() { + var didCompleteRoot = true; + stopWorkLoopTimer(interruptedBy, didCompleteRoot); + interruptedBy = null; +} -function warnAboutUpdateOnNotYetMountedFiberInDEV(fiber) { - { - if ((executionContext & RenderContext) !== NoContext) { - // We let the other warning about render phase updates deal with this one. - return; - } +function stopInterruptedWorkLoopTimer() { + // TODO: Track which fiber caused the interruption. + var didCompleteRoot = false; + stopWorkLoopTimer(interruptedBy, didCompleteRoot); + interruptedBy = null; +} - if (!(fiber.mode & (BlockingMode | ConcurrentMode))) { - return; - } - - var tag = fiber.tag; - - if ( - tag !== IndeterminateComponent && - tag !== HostRoot && - tag !== ClassComponent && - tag !== FunctionComponent && - tag !== ForwardRef && - tag !== MemoComponent && - tag !== SimpleMemoComponent && - tag !== Block - ) { - // Only warn for user-defined components, not internal ones like Suspense. - return; - } // We show the whole stack but dedupe on the top component's name because - // the problematic code almost always lies inside that component. - - var componentName = getComponentName(fiber.type) || "ReactComponent"; - - if (didWarnStateUpdateForNotYetMountedComponent !== null) { - if (didWarnStateUpdateForNotYetMountedComponent.has(componentName)) { - return; - } - - didWarnStateUpdateForNotYetMountedComponent.add(componentName); - } else { - didWarnStateUpdateForNotYetMountedComponent = new Set([componentName]); - } - - var previousFiber = current; - - try { - setCurrentFiber(fiber); - - error( - "Can't perform a React state update on a component that hasn't mounted yet. " + - "This indicates that you have a side-effect in your render function that " + - "asynchronously later calls tries to update the component. Move this work to " + - "useEffect instead." - ); - } finally { - if (previousFiber) { - setCurrentFiber(fiber); - } else { - resetCurrentFiber(); - } - } +function checkForInterruption(fiberThatReceivedUpdate, updateExpirationTime) { + if ( + workInProgressRoot !== null && + updateExpirationTime > renderExpirationTime$1 + ) { + interruptedBy = fiberThatReceivedUpdate; } } @@ -19602,12 +18690,7 @@ function warnAboutUpdateOnUnmountedFiberInDEV(fiber) { ) { // Only warn for user-defined components, not internal ones like Suspense. return; - } // If there are pending passive effects unmounts for this Fiber, - // we can assume that they would have prevented this update. - - if ((fiber.effectTag & PassiveUnmountPendingDev) !== NoEffect) { - return; - } // We show the whole stack but dedupe on the top component's name because + } // the problematic code almost always lies inside that component. var componentName = getComponentName(fiber.type) || "ReactComponent"; @@ -19622,29 +18705,15 @@ function warnAboutUpdateOnUnmountedFiberInDEV(fiber) { didWarnStateUpdateForUnmountedComponent = new Set([componentName]); } - if (isFlushingPassiveEffects); - else { - var previousFiber = current; - - try { - setCurrentFiber(fiber); - - error( - "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 %s.", - tag === ClassComponent - ? "the componentWillUnmount method" - : "a useEffect cleanup function" - ); - } finally { - if (previousFiber) { - setCurrentFiber(fiber); - } else { - resetCurrentFiber(); - } - } - } + error( + "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 %s.%s", + tag === ClassComponent + ? "the componentWillUnmount method" + : "a useEffect cleanup function", + getStackByFiberInDevAndProd(fiber) + ); } } @@ -19653,7 +18722,7 @@ var beginWork$1; { var dummyFiber = null; - beginWork$1 = function(current, unitOfWork, lanes) { + beginWork$1 = function(current, unitOfWork, expirationTime) { // If a component throws an error, we replay it again in a synchronously // dispatched event, so that the debugger will treat it as an uncaught // error See ReactErrorUtils for more information. @@ -19665,7 +18734,7 @@ var beginWork$1; ); try { - return beginWork(current, unitOfWork, lanes); + return beginWork(current, unitOfWork, expirationTime); } catch (originalError) { if ( originalError !== null && @@ -19691,7 +18760,14 @@ var beginWork$1; startProfilerTimer(unitOfWork); } // Run beginWork again. - invokeGuardedCallback(null, beginWork, null, current, unitOfWork, lanes); + invokeGuardedCallback( + null, + beginWork, + null, + current, + unitOfWork, + expirationTime + ); if (hasCaughtError()) { var replayError = clearCaughtError(); // `invokeGuardedCallback` sometimes sets an expando `_suppressLogging`. @@ -19707,49 +18783,24 @@ var beginWork$1; } var didWarnAboutUpdateInRender = false; -var didWarnAboutUpdateInRenderForAnotherComponent; - -{ - didWarnAboutUpdateInRenderForAnotherComponent = new Set(); -} function warnAboutRenderPhaseUpdatesInDEV(fiber) { { - if ( - isRendering && - (executionContext & RenderContext) !== NoContext && - !getIsUpdatingOpaqueValueInRenderPhaseInDEV() - ) { + if ((executionContext & RenderContext) !== NoContext) { switch (fiber.tag) { case FunctionComponent: case ForwardRef: case SimpleMemoComponent: { - var renderingComponentName = - (workInProgress && getComponentName(workInProgress.type)) || - "Unknown"; // Dedupe by the rendering component because it's the one that needs to be fixed. - - var dedupeKey = renderingComponentName; - - if (!didWarnAboutUpdateInRenderForAnotherComponent.has(dedupeKey)) { - didWarnAboutUpdateInRenderForAnotherComponent.add(dedupeKey); - var setStateComponentName = - getComponentName(fiber.type) || "Unknown"; - - error( - "Cannot update a component (`%s`) while rendering a " + - "different component (`%s`). To locate the bad setState() call inside `%s`, " + - "follow the stack trace as described in https://fb.me/setstate-in-render", - setStateComponentName, - renderingComponentName, - renderingComponentName - ); - } + error( + "Cannot update a component from inside the function body of a " + + "different component." + ); break; } case ClassComponent: { - if (!didWarnAboutUpdateInRender) { + if (isRendering && !didWarnAboutUpdateInRender) { error( "Cannot update during an existing state transition (such as " + "within `render`). Render methods should be a pure " + @@ -19757,15 +18808,18 @@ function warnAboutRenderPhaseUpdatesInDEV(fiber) { ); didWarnAboutUpdateInRender = true; + break; } - - break; } } } } } // a 'shared' variable that changes when act() opens/closes in tests. +var IsThisRendererActing = { + current: false +}; + var didWarnAboutUnmockedScheduler = false; // TODO Before we release concurrent mode, revisit this and decide whether a mocked // scheduler is the actual recommendation. The alternative could be a testing build, // a new lib, or whatever; we dunno just yet. This message is for early adopters @@ -19792,7 +18846,7 @@ function warnIfUnmockedScheduler(fiber) { didWarnAboutUnmockedScheduler = true; error( - 'Starting from React v18, the "scheduler" module will need to be mocked ' + + 'Starting from React v17, the "scheduler" module will need to be mocked ' + "to guarantee consistent behaviour across tests and browsers. " + "For example, with jest: \n" + // Break up requires to avoid accidentally parsing them as dependencies. "jest.mock('scheduler', () => require" + @@ -19804,26 +18858,23 @@ function warnIfUnmockedScheduler(fiber) { } } -function computeThreadID(root, lane) { +function computeThreadID(root, expirationTime) { // Interaction threads are unique per root and expiration time. - // NOTE: Intentionally unsound cast. All that matters is that it's a number - // and it represents a batch of work. Could make a helper function instead, - // but meh this is fine for now. - return lane * 1000 + root.interactionThreadID; + return expirationTime * 1000 + root.interactionThreadID; } -function markSpawnedWork(lane) { +function markSpawnedWork(expirationTime) { if (spawnedWorkDuringRender === null) { - spawnedWorkDuringRender = [lane]; + spawnedWorkDuringRender = [expirationTime]; } else { - spawnedWorkDuringRender.push(lane); + spawnedWorkDuringRender.push(expirationTime); } } -function scheduleInteractions(root, lane, interactions) { +function scheduleInteractions(root, expirationTime, interactions) { if (interactions.size > 0) { var pendingInteractionMap = root.pendingInteractionMap; - var pendingInteractions = pendingInteractionMap.get(lane); + var pendingInteractions = pendingInteractionMap.get(expirationTime); if (pendingInteractions != null) { interactions.forEach(function(interaction) { @@ -19835,7 +18886,7 @@ function scheduleInteractions(root, lane, interactions) { pendingInteractions.add(interaction); }); } else { - pendingInteractionMap.set(lane, new Set(interactions)); // Update the pending async work count for the current interactions. + pendingInteractionMap.set(expirationTime, new Set(interactions)); // Update the pending async work count for the current interactions. interactions.forEach(function(interaction) { interaction.__count++; @@ -19845,26 +18896,26 @@ function scheduleInteractions(root, lane, interactions) { var subscriber = tracing.__subscriberRef.current; if (subscriber !== null) { - var threadID = computeThreadID(root, lane); + var threadID = computeThreadID(root, expirationTime); subscriber.onWorkScheduled(interactions, threadID); } } } -function schedulePendingInteractions(root, lane) { - scheduleInteractions(root, lane, tracing.__interactionsRef.current); +function schedulePendingInteractions(root, expirationTime) { + scheduleInteractions(root, expirationTime, tracing.__interactionsRef.current); } -function startWorkOnPendingInteractions(root, lanes) { +function startWorkOnPendingInteractions(root, expirationTime) { // we can accurately attribute time spent working on it, And so that cascading // work triggered during the render phase will be associated with it. var interactions = new Set(); root.pendingInteractionMap.forEach(function( scheduledInteractions, - scheduledLane + scheduledExpirationTime ) { - if (includesSomeLane(lanes, scheduledLane)) { + if (scheduledExpirationTime >= expirationTime) { scheduledInteractions.forEach(function(interaction) { return interactions.add(interaction); }); @@ -19881,13 +18932,13 @@ function startWorkOnPendingInteractions(root, lanes) { var subscriber = tracing.__subscriberRef.current; if (subscriber !== null) { - var threadID = computeThreadID(root, lanes); + var threadID = computeThreadID(root, expirationTime); try { subscriber.onWorkStarted(interactions, threadID); } catch (error) { // If the subscriber throws, rethrow it in a separate task - scheduleCallback(ImmediatePriority$1, function() { + scheduleCallback(ImmediatePriority, function() { throw error; }); } @@ -19895,21 +18946,20 @@ function startWorkOnPendingInteractions(root, lanes) { } } -function finishPendingInteractions(root, committedLanes) { - var remainingLanesAfterCommit = root.pendingLanes; +function finishPendingInteractions(root, committedExpirationTime) { + var earliestRemainingTimeAfterCommit = root.firstPendingTime; var subscriber; try { subscriber = tracing.__subscriberRef.current; if (subscriber !== null && root.memoizedInteractions.size > 0) { - // FIXME: More than one lane can finish in a single commit. - var threadID = computeThreadID(root, committedLanes); + var threadID = computeThreadID(root, committedExpirationTime); subscriber.onWorkStopped(root.memoizedInteractions, threadID); } } catch (error) { // If the subscriber throws, rethrow it in a separate task - scheduleCallback(ImmediatePriority$1, function() { + scheduleCallback(ImmediatePriority, function() { throw error; }); } finally { @@ -19917,12 +18967,15 @@ function finishPendingInteractions(root, committedLanes) { // Unless the render was suspended or cascading work was scheduled, // In which case– leave pending interactions until the subsequent render. var pendingInteractionMap = root.pendingInteractionMap; - pendingInteractionMap.forEach(function(scheduledInteractions, lane) { + pendingInteractionMap.forEach(function( + scheduledInteractions, + scheduledExpirationTime + ) { // 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 (!includesSomeLane(remainingLanesAfterCommit, lane)) { - pendingInteractionMap.delete(lane); + if (scheduledExpirationTime > earliestRemainingTimeAfterCommit) { + pendingInteractionMap.delete(scheduledExpirationTime); scheduledInteractions.forEach(function(interaction) { interaction.__count--; @@ -19931,7 +18984,7 @@ function finishPendingInteractions(root, committedLanes) { subscriber.onInteractionScheduledWorkCompleted(interaction); } catch (error) { // If the subscriber throws, rethrow it in a separate task - scheduleCallback(ImmediatePriority$1, function() { + scheduleCallback(ImmediatePriority, function() { throw error; }); } @@ -19940,455 +18993,121 @@ function finishPendingInteractions(root, committedLanes) { } }); } -} // `act` testing API -// -// TODO: This is mostly a copy-paste from the legacy `act`, which does not have -// access to the same internals that we do here. Some trade offs in the -// implementation no longer make sense. - -var isFlushingAct = false; - -function shouldForceFlushFallbacksInDEV() { - return isFlushingAct; } -function detachFiberAfterEffects(fiber) { - fiber.sibling = null; -} - -var resolveFamily = null; // $FlowFixMe Flow gets confused by a WeakSet feature check below. - -var failedBoundaries = null; -var setRefreshHandler = function(handler) { - { - resolveFamily = handler; - } -}; -function resolveFunctionForHotReloading(type) { - { - if (resolveFamily === null) { - // Hot reloading is disabled. - return type; - } - - var family = resolveFamily(type); - - if (family === undefined) { - return type; - } // Use the latest known implementation. - - return family.current; - } -} -function resolveClassForHotReloading(type) { - // No implementation differences. - return resolveFunctionForHotReloading(type); -} -function resolveForwardRefForHotReloading(type) { - { - if (resolveFamily === null) { - // Hot reloading is disabled. - return type; - } - - var family = resolveFamily(type); - - if (family === undefined) { - // Check if we're dealing with a real forwardRef. Don't want to crash early. - if ( - type !== null && - type !== undefined && - typeof type.render === "function" - ) { - // ForwardRef is special because its resolved .type is an object, - // but it's possible that we only have its inner render function in the map. - // If that inner render function is different, we'll build a new forwardRef type. - var currentRender = resolveFunctionForHotReloading(type.render); - - if (type.render !== currentRender) { - var syntheticType = { - $$typeof: REACT_FORWARD_REF_TYPE, - render: currentRender - }; - - if (type.displayName !== undefined) { - syntheticType.displayName = type.displayName; - } - - return syntheticType; - } - } - - return type; - } // Use the latest known implementation. - - return family.current; - } -} -function isCompatibleFamilyForHotReloading(fiber, element) { - { - if (resolveFamily === null) { - // Hot reloading is disabled. - return false; - } - - var prevType = fiber.elementType; - var nextType = element.type; // If we got here, we know types aren't === equal. - - var needsCompareFamilies = false; - var $$typeofNextType = - typeof nextType === "object" && nextType !== null - ? nextType.$$typeof - : null; - - switch (fiber.tag) { - case ClassComponent: { - if (typeof nextType === "function") { - needsCompareFamilies = true; - } - - break; - } - - case FunctionComponent: { - if (typeof nextType === "function") { - needsCompareFamilies = true; - } else if ($$typeofNextType === REACT_LAZY_TYPE) { - // We don't know the inner type yet. - // We're going to assume that the lazy inner type is stable, - // and so it is sufficient to avoid reconciling it away. - // We're not going to unwrap or actually use the new lazy type. - needsCompareFamilies = true; - } - - break; - } - - case ForwardRef: { - if ($$typeofNextType === REACT_FORWARD_REF_TYPE) { - needsCompareFamilies = true; - } else if ($$typeofNextType === REACT_LAZY_TYPE) { - needsCompareFamilies = true; - } - - break; - } - - case MemoComponent: - case SimpleMemoComponent: { - if ($$typeofNextType === REACT_MEMO_TYPE) { - // TODO: if it was but can no longer be simple, - // we shouldn't set this. - needsCompareFamilies = true; - } else if ($$typeofNextType === REACT_LAZY_TYPE) { - needsCompareFamilies = true; - } - - break; - } - - default: - return false; - } // Check if both types have a family and it's the same one. - - if (needsCompareFamilies) { - // Note: memo() and forwardRef() we'll compare outer rather than inner type. - // This means both of them need to be registered to preserve state. - // If we unwrapped and compared the inner types for wrappers instead, - // then we would risk falsely saying two separate memo(Foo) - // calls are equivalent because they wrap the same Foo function. - var prevFamily = resolveFamily(prevType); - - if (prevFamily !== undefined && prevFamily === resolveFamily(nextType)) { - return true; - } - } - +var onScheduleFiberRoot = null; +var onCommitFiberRoot = null; +var onCommitFiberUnmount = null; +var hasLoggedError = false; +var isDevToolsPresent = typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== "undefined"; +function injectInternals(internals) { + if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ === "undefined") { + // No DevTools return false; } -} -function markFailedErrorBoundaryForHotReloading(fiber) { - { - if (resolveFamily === null) { - // Hot reloading is disabled. - return; - } - if (typeof WeakSet !== "function") { - return; - } + var hook = __REACT_DEVTOOLS_GLOBAL_HOOK__; - if (failedBoundaries === null) { - failedBoundaries = new WeakSet(); - } - - failedBoundaries.add(fiber); + if (hook.isDisabled) { + // This isn't a real property on the hook, but it can be set to opt out + // of DevTools integration and associated warnings and logs. + // https://github.com/facebook/react/issues/3877 + return true; } -} -var scheduleRefresh = function(root, update) { - { - if (resolveFamily === null) { - // Hot reloading is disabled. - return; - } - var staleFamilies = update.staleFamilies, - updatedFamilies = update.updatedFamilies; - flushPassiveEffects(); - flushSync(function() { - scheduleFibersWithFamiliesRecursively( - root.current, - updatedFamilies, - staleFamilies + if (!hook.supportsFiber) { + { + error( + "The installed version of React DevTools is too old and will not work " + + "with the current version of React. Please update React DevTools. " + + "https://fb.me/react-devtools" ); - }); + } // DevTools exists, even though it doesn't support Fiber. + + return true; } -}; -var scheduleRoot = function(root, element) { - { - if (root.context !== emptyContextObject) { - // Super edge case: root has a legacy _renderSubtree context - // but we don't know the parentComponent so we can't pass it. - // Just ignore. We'll delete this with _renderSubtree code path later. - return; + + try { + var rendererID = hook.inject(internals); // We have successfully injected, so now it is safe to set up hooks. + + if (true) { + // Only used by Fast Refresh + if (typeof hook.onScheduleFiberRoot === "function") { + onScheduleFiberRoot = function(root, children) { + try { + hook.onScheduleFiberRoot(rendererID, root, children); + } catch (err) { + if (true && !hasLoggedError) { + hasLoggedError = true; + + error("React instrumentation encountered an error: %s", err); + } + } + }; + } } - flushPassiveEffects(); - flushSync(function() { - updateContainer(element, root, null, null); - }); - } -}; + onCommitFiberRoot = function(root, expirationTime) { + try { + var didError = (root.current.effectTag & DidCapture) === DidCapture; -function scheduleFibersWithFamiliesRecursively( - fiber, - updatedFamilies, - staleFamilies -) { - { - var alternate = fiber.alternate, - child = fiber.child, - sibling = fiber.sibling, - tag = fiber.tag, - type = fiber.type; - var candidateType = null; + if (enableProfilerTimer) { + var currentTime = getCurrentTime(); + var priorityLevel = inferPriorityFromExpirationTime( + currentTime, + expirationTime + ); + hook.onCommitFiberRoot(rendererID, root, priorityLevel, didError); + } else { + hook.onCommitFiberRoot(rendererID, root, undefined, didError); + } + } catch (err) { + if (true) { + if (!hasLoggedError) { + hasLoggedError = true; - switch (tag) { - case FunctionComponent: - case SimpleMemoComponent: - case ClassComponent: - candidateType = type; - break; - - case ForwardRef: - candidateType = type.render; - break; - } - - if (resolveFamily === null) { - throw new Error("Expected resolveFamily to be set during hot reload."); - } - - var needsRender = false; - var needsRemount = false; - - if (candidateType !== null) { - var family = resolveFamily(candidateType); - - if (family !== undefined) { - if (staleFamilies.has(family)) { - needsRemount = true; - } else if (updatedFamilies.has(family)) { - if (tag === ClassComponent) { - needsRemount = true; - } else { - needsRender = true; + error("React instrumentation encountered an error: %s", err); } } } - } + }; - if (failedBoundaries !== null) { - if ( - failedBoundaries.has(fiber) || - (alternate !== null && failedBoundaries.has(alternate)) - ) { - needsRemount = true; - } - } + onCommitFiberUnmount = function(fiber) { + try { + hook.onCommitFiberUnmount(rendererID, fiber); + } catch (err) { + if (true) { + if (!hasLoggedError) { + hasLoggedError = true; - if (needsRemount) { - fiber._debugNeedsRemount = true; - } - - if (needsRemount || needsRender) { - scheduleUpdateOnFiber(fiber, SyncLane, NoTimestamp); - } - - if (child !== null && !needsRemount) { - scheduleFibersWithFamiliesRecursively( - child, - updatedFamilies, - staleFamilies - ); - } - - if (sibling !== null) { - scheduleFibersWithFamiliesRecursively( - sibling, - updatedFamilies, - staleFamilies - ); - } - } -} - -var findHostInstancesForRefresh = function(root, families) { - { - var hostInstances = new Set(); - var types = new Set( - families.map(function(family) { - return family.current; - }) - ); - findHostInstancesForMatchingFibersRecursively( - root.current, - types, - hostInstances - ); - return hostInstances; - } -}; - -function findHostInstancesForMatchingFibersRecursively( - fiber, - types, - hostInstances -) { - { - var child = fiber.child, - sibling = fiber.sibling, - tag = fiber.tag, - type = fiber.type; - var candidateType = null; - - switch (tag) { - case FunctionComponent: - case SimpleMemoComponent: - case ClassComponent: - candidateType = type; - break; - - case ForwardRef: - candidateType = type.render; - break; - } - - var didMatch = false; - - if (candidateType !== null) { - if (types.has(candidateType)) { - didMatch = true; - } - } - - if (didMatch) { - // We have a match. This only drills down to the closest host components. - // There's no need to search deeper because for the purpose of giving - // visual feedback, "flashing" outermost parent rectangles is sufficient. - findHostInstancesForFiberShallowly(fiber, hostInstances); - } else { - // If there's no match, maybe there will be one further down in the child tree. - if (child !== null) { - findHostInstancesForMatchingFibersRecursively( - child, - types, - hostInstances - ); - } - } - - if (sibling !== null) { - findHostInstancesForMatchingFibersRecursively( - sibling, - types, - hostInstances - ); - } - } -} - -function findHostInstancesForFiberShallowly(fiber, hostInstances) { - { - var foundHostInstances = findChildHostInstancesForFiberShallowly( - fiber, - hostInstances - ); - - if (foundHostInstances) { - return; - } // If we didn't find any host children, fallback to closest host parent. - - var node = fiber; - - while (true) { - switch (node.tag) { - case HostComponent: - hostInstances.add(node.stateNode); - return; - - case HostPortal: - hostInstances.add(node.stateNode.containerInfo); - return; - - case HostRoot: - hostInstances.add(node.stateNode.containerInfo); - return; - } - - if (node.return === null) { - throw new Error("Expected to reach root first."); - } - - node = node.return; - } - } -} - -function findChildHostInstancesForFiberShallowly(fiber, hostInstances) { - { - var node = fiber; - var foundHostInstances = false; - - while (true) { - if (node.tag === HostComponent) { - // We got a match. - foundHostInstances = true; - hostInstances.add(node.stateNode); // There may still be more, so keep searching. - } else if (node.child !== null) { - node.child.return = node; - node = node.child; - continue; - } - - if (node === fiber) { - return foundHostInstances; - } - - while (node.sibling === null) { - if (node.return === null || node.return === fiber) { - return foundHostInstances; + error("React instrumentation encountered an error: %s", err); + } } - - node = node.return; } - - node.sibling.return = node.return; - node = node.sibling; + }; + } catch (err) { + // Catch all errors because it is unsafe to throw during initialization. + { + error("React instrumentation encountered an error: %s.", err); } - } + } // DevTools exists - return false; + return true; +} +function onScheduleRoot(root, children) { + if (typeof onScheduleFiberRoot === "function") { + onScheduleFiberRoot(root, children); + } +} +function onCommitRoot(root, expirationTime) { + if (typeof onCommitFiberRoot === "function") { + onCommitFiberRoot(root, expirationTime); + } +} +function onCommitUnmount(fiber) { + if (typeof onCommitFiberUnmount === "function") { + onCommitFiberUnmount(fiber); + } } var hasBadMapPolyfill; @@ -20398,11 +19117,13 @@ var hasBadMapPolyfill; try { var nonExtensibleObject = Object.preventExtensions({}); - /* eslint-disable no-new */ + var testMap = new Map([[nonExtensibleObject, null]]); + var testSet = new Set([nonExtensibleObject]); // This is necessary for Rollup to not consider these unused. + // https://github.com/rollup/rollup/issues/1771 + // TODO: we can remove these if Rollup fixes the bug. - new Map([[nonExtensibleObject, null]]); - new Set([nonExtensibleObject]); - /* eslint-enable no-new */ + testMap.set(0, 0); + testSet.add(0); } catch (e) { // TODO: Consider warning about bad polyfills hasBadMapPolyfill = true; @@ -20435,8 +19156,8 @@ function FiberNode(tag, pendingProps, key, mode) { this.nextEffect = null; this.firstEffect = null; this.lastEffect = null; - this.lanes = NoLanes; - this.childLanes = NoLanes; + this.expirationTime = NoWork; + this.childExpirationTime = NoWork; this.alternate = null; { @@ -20463,11 +19184,15 @@ function FiberNode(tag, pendingProps, key, mode) { this.actualStartTime = -1; this.selfBaseDuration = 0; this.treeBaseDuration = 0; + } // This is normally DEV-only except www when it adds listeners. + // TODO: remove the User Timing integration in favor of Root Events. + + { + this._debugID = debugCounter++; + this._debugIsCurrentlyTiming = false; } { - // This isn't directly used but is handy for debugging internals: - this._debugID = debugCounter++; this._debugSource = null; this._debugOwner = null; this._debugNeedsRemount = false; @@ -20547,7 +19272,10 @@ function createWorkInProgress(current, pendingProps) { { // DEV-only fields - workInProgress._debugID = current._debugID; + { + workInProgress._debugID = current._debugID; + } + workInProgress._debugSource = current._debugSource; workInProgress._debugOwner = current._debugOwner; workInProgress._debugHookTypes = current._debugHookTypes; @@ -20556,9 +19284,7 @@ function createWorkInProgress(current, pendingProps) { workInProgress.alternate = current; current.alternate = workInProgress; } else { - workInProgress.pendingProps = pendingProps; // Needed because Blocks store data on type. - - workInProgress.type = current.type; // We already have an alternate. + workInProgress.pendingProps = pendingProps; // We already have an alternate. // Reset the effect tag. workInProgress.effectTag = NoEffect; // The effect list is no longer valid. @@ -20577,8 +19303,21 @@ function createWorkInProgress(current, pendingProps) { } } - workInProgress.childLanes = current.childLanes; - workInProgress.lanes = current.lanes; + { + // Trying to debug a mysterious internal-only production failure. + // See D20130868 and t62461245. + // This is only on for RN FB builds. + if (current == null) { + throw Error("current is " + current + " but it can't be"); + } + + if (workInProgress == null) { + throw Error("workInProgress is " + workInProgress + " but it can't be"); + } + } + + workInProgress.childExpirationTime = current.childExpirationTime; + workInProgress.expirationTime = current.expirationTime; workInProgress.child = current.child; workInProgress.memoizedProps = current.memoizedProps; workInProgress.memoizedState = current.memoizedState; @@ -20590,7 +19329,7 @@ function createWorkInProgress(current, pendingProps) { currentDependencies === null ? null : { - lanes: currentDependencies.lanes, + expirationTime: currentDependencies.expirationTime, firstContext: currentDependencies.firstContext, responders: currentDependencies.responders }; // These will be overridden during the parent's reconciliation @@ -20627,7 +19366,7 @@ function createWorkInProgress(current, pendingProps) { return workInProgress; } // Used to reuse a Fiber for a second pass. -function resetWorkInProgress(workInProgress, renderLanes) { +function resetWorkInProgress(workInProgress, renderExpirationTime) { // This resets the Fiber to what createFiber or createWorkInProgress would // have set the values to before during the first pass. Ideally this wouldn't // be necessary but unfortunately many code paths reads from the workInProgress @@ -20645,14 +19384,13 @@ function resetWorkInProgress(workInProgress, renderLanes) { if (current === null) { // Reset to createFiber's initial values. - workInProgress.childLanes = NoLanes; - workInProgress.lanes = renderLanes; + workInProgress.childExpirationTime = NoWork; + workInProgress.expirationTime = renderExpirationTime; workInProgress.child = null; workInProgress.memoizedProps = null; workInProgress.memoizedState = null; workInProgress.updateQueue = null; workInProgress.dependencies = null; - workInProgress.stateNode = null; { // Note: We don't reset the actualTime counts. It's useful to accumulate @@ -20662,14 +19400,12 @@ function resetWorkInProgress(workInProgress, renderLanes) { } } else { // Reset to the cloned values that createWorkInProgress would've. - workInProgress.childLanes = current.childLanes; - workInProgress.lanes = current.lanes; + workInProgress.childExpirationTime = current.childExpirationTime; + workInProgress.expirationTime = current.expirationTime; workInProgress.child = current.child; workInProgress.memoizedProps = current.memoizedProps; workInProgress.memoizedState = current.memoizedState; - workInProgress.updateQueue = current.updateQueue; // Needed because Blocks store data on type. - - workInProgress.type = current.type; // Clone the dependencies object. This is mutated during the render phase, so + workInProgress.updateQueue = current.updateQueue; // Clone the dependencies object. This is mutated during the render phase, so // it cannot be shared with the current fiber. var currentDependencies = current.dependencies; @@ -20677,7 +19413,7 @@ function resetWorkInProgress(workInProgress, renderLanes) { currentDependencies === null ? null : { - lanes: currentDependencies.lanes, + expirationTime: currentDependencies.expirationTime, firstContext: currentDependencies.firstContext, responders: currentDependencies.responders }; @@ -20718,8 +19454,9 @@ function createFiberFromTypeAndProps( pendingProps, owner, mode, - lanes + expirationTime ) { + var fiber; 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; @@ -20741,11 +19478,16 @@ function createFiberFromTypeAndProps( } else { getTag: switch (type) { case REACT_FRAGMENT_TYPE: - return createFiberFromFragment(pendingProps.children, mode, lanes, key); + return createFiberFromFragment( + pendingProps.children, + mode, + expirationTime, + key + ); - case REACT_DEBUG_TRACING_MODE_TYPE: + case REACT_CONCURRENT_MODE_TYPE: fiberTag = Mode; - mode |= DebugTracingMode; + mode |= ConcurrentMode | BlockingMode | StrictMode; break; case REACT_STRICT_MODE_TYPE: @@ -20754,23 +19496,18 @@ function createFiberFromTypeAndProps( break; case REACT_PROFILER_TYPE: - return createFiberFromProfiler(pendingProps, mode, lanes, key); + return createFiberFromProfiler(pendingProps, mode, expirationTime, key); case REACT_SUSPENSE_TYPE: - return createFiberFromSuspense(pendingProps, mode, lanes, key); + return createFiberFromSuspense(pendingProps, mode, expirationTime, key); case REACT_SUSPENSE_LIST_TYPE: - return createFiberFromSuspenseList(pendingProps, mode, lanes, key); - - case REACT_OFFSCREEN_TYPE: - return createFiberFromOffscreen(pendingProps, mode, lanes, key); - - case REACT_LEGACY_HIDDEN_TYPE: - return createFiberFromLegacyHidden(pendingProps, mode, lanes, key); - - case REACT_SCOPE_TYPE: - - // eslint-disable-next-line no-fallthrough + return createFiberFromSuspenseList( + pendingProps, + mode, + expirationTime, + key + ); default: { if (typeof type === "object" && type !== null) { @@ -20842,13 +19579,13 @@ function createFiberFromTypeAndProps( } } - var fiber = createFiber(fiberTag, pendingProps, key, mode); + fiber = createFiber(fiberTag, pendingProps, key, mode); fiber.elementType = type; fiber.type = resolvedType; - fiber.lanes = lanes; + fiber.expirationTime = expirationTime; return fiber; } -function createFiberFromElement(element, mode, lanes) { +function createFiberFromElement(element, mode, expirationTime) { var owner = null; { @@ -20864,7 +19601,7 @@ function createFiberFromElement(element, mode, lanes) { pendingProps, owner, mode, - lanes + expirationTime ); { @@ -20874,13 +19611,13 @@ function createFiberFromElement(element, mode, lanes) { return fiber; } -function createFiberFromFragment(elements, mode, lanes, key) { +function createFiberFromFragment(elements, mode, expirationTime, key) { var fiber = createFiber(Fragment, elements, key, mode); - fiber.lanes = lanes; + fiber.expirationTime = expirationTime; return fiber; } -function createFiberFromProfiler(pendingProps, mode, lanes, key) { +function createFiberFromProfiler(pendingProps, mode, expirationTime, key) { { if (typeof pendingProps.id !== "string") { error('Profiler must specify an "id" as a prop'); @@ -20891,7 +19628,7 @@ function createFiberFromProfiler(pendingProps, mode, lanes, key) { fiber.elementType = REACT_PROFILER_TYPE; fiber.type = REACT_PROFILER_TYPE; - fiber.lanes = lanes; + fiber.expirationTime = expirationTime; { fiber.stateNode = { @@ -20903,17 +19640,17 @@ function createFiberFromProfiler(pendingProps, mode, lanes, key) { return fiber; } -function createFiberFromSuspense(pendingProps, mode, lanes, key) { +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. // This needs to be fixed in getComponentName so that it relies on the tag // instead. fiber.type = REACT_SUSPENSE_TYPE; fiber.elementType = REACT_SUSPENSE_TYPE; - fiber.lanes = lanes; + fiber.expirationTime = expirationTime; return fiber; } -function createFiberFromSuspenseList(pendingProps, mode, lanes, key) { +function createFiberFromSuspenseList(pendingProps, mode, expirationTime, key) { var fiber = createFiber(SuspenseListComponent, pendingProps, key, mode); { @@ -20924,44 +19661,18 @@ function createFiberFromSuspenseList(pendingProps, mode, lanes, key) { } fiber.elementType = REACT_SUSPENSE_LIST_TYPE; - fiber.lanes = lanes; + fiber.expirationTime = expirationTime; return fiber; } -function createFiberFromOffscreen(pendingProps, mode, lanes, key) { - var fiber = createFiber(OffscreenComponent, pendingProps, key, mode); // TODO: The OffscreenComponent fiber shouldn't have a type. It has a tag. - // This needs to be fixed in getComponentName so that it relies on the tag - // instead. - - { - fiber.type = REACT_OFFSCREEN_TYPE; - } - - fiber.elementType = REACT_OFFSCREEN_TYPE; - fiber.lanes = lanes; - return fiber; -} -function createFiberFromLegacyHidden(pendingProps, mode, lanes, key) { - var fiber = createFiber(LegacyHiddenComponent, pendingProps, key, mode); // TODO: The LegacyHidden fiber shouldn't have a type. It has a tag. - // This needs to be fixed in getComponentName so that it relies on the tag - // instead. - - { - fiber.type = REACT_LEGACY_HIDDEN_TYPE; - } - - fiber.elementType = REACT_LEGACY_HIDDEN_TYPE; - fiber.lanes = lanes; - return fiber; -} -function createFiberFromText(content, mode, lanes) { +function createFiberFromText(content, mode, expirationTime) { var fiber = createFiber(HostText, content, null, mode); - fiber.lanes = lanes; + fiber.expirationTime = expirationTime; return fiber; } -function createFiberFromPortal(portal, mode, lanes) { +function createFiberFromPortal(portal, mode, expirationTime) { var pendingProps = portal.children !== null ? portal.children : []; var fiber = createFiber(HostPortal, pendingProps, portal.key, mode); - fiber.lanes = lanes; + fiber.expirationTime = expirationTime; fiber.stateNode = { containerInfo: portal.containerInfo, pendingChildren: null, @@ -21002,8 +19713,8 @@ function assignFiberPropertiesInDEV(target, source) { target.nextEffect = source.nextEffect; target.firstEffect = source.firstEffect; target.lastEffect = source.lastEffect; - target.lanes = source.lanes; - target.childLanes = source.childLanes; + target.expirationTime = source.expirationTime; + target.childExpirationTime = source.childExpirationTime; target.alternate = source.alternate; { @@ -21013,7 +19724,11 @@ function assignFiberPropertiesInDEV(target, source) { target.treeBaseDuration = source.treeBaseDuration; } - target._debugID = source._debugID; + { + target._debugID = source._debugID; + target._debugIsCurrentlyTiming = source._debugIsCurrentlyTiming; + } + target._debugSource = source._debugSource; target._debugOwner = source._debugOwner; target._debugNeedsRemount = source._debugNeedsRemount; @@ -21023,49 +19738,30 @@ function assignFiberPropertiesInDEV(target, source) { function FiberRootNode(containerInfo, tag, hydrate) { this.tag = tag; + this.current = null; this.containerInfo = containerInfo; this.pendingChildren = null; - this.current = null; this.pingCache = null; + this.finishedExpirationTime = NoWork; this.finishedWork = null; this.timeoutHandle = noTimeout; this.context = null; this.pendingContext = null; this.hydrate = hydrate; this.callbackNode = null; - this.callbackPriority = NoLanePriority; - this.eventTimes = createLaneMap(NoLanes); - this.expirationTimes = createLaneMap(NoTimestamp); - this.pendingLanes = NoLanes; - this.suspendedLanes = NoLanes; - this.pingedLanes = NoLanes; - this.expiredLanes = NoLanes; - this.mutableReadLanes = NoLanes; - this.finishedLanes = NoLanes; - this.entangledLanes = NoLanes; - this.entanglements = createLaneMap(NoLanes); + this.callbackPriority = NoPriority; + this.firstPendingTime = NoWork; + this.firstSuspendedTime = NoWork; + this.lastSuspendedTime = NoWork; + this.nextKnownPendingLevel = NoWork; + this.lastPingedTime = NoWork; + this.lastExpiredTime = NoWork; { this.interactionThreadID = tracing.unstable_getThreadID(); this.memoizedInteractions = new Set(); this.pendingInteractionMap = new Map(); } - - { - switch (tag) { - case BlockingRoot: - this._debugRootType = "createBlockingRoot()"; - break; - - case ConcurrentRoot: - this._debugRootType = "createRoot()"; - break; - - case LegacyRoot: - this._debugRootType = "createLegacyRoot()"; - break; - } - } } function createFiberRoot(containerInfo, tag, hydrate, hydrationCallbacks) { @@ -21078,22 +19774,95 @@ function createFiberRoot(containerInfo, tag, hydrate, hydrationCallbacks) { initializeUpdateQueue(uninitializedFiber); return root; } +function isRootSuspendedAtTime(root, expirationTime) { + var firstSuspendedTime = root.firstSuspendedTime; + var lastSuspendedTime = root.lastSuspendedTime; + return ( + firstSuspendedTime !== NoWork && + firstSuspendedTime >= expirationTime && + lastSuspendedTime <= expirationTime + ); +} +function markRootSuspendedAtTime(root, expirationTime) { + var firstSuspendedTime = root.firstSuspendedTime; + var lastSuspendedTime = root.lastSuspendedTime; -function createPortal( - children, - containerInfo, // TODO: figure out the API for cross-renderer implementation. - implementation + if (firstSuspendedTime < expirationTime) { + root.firstSuspendedTime = expirationTime; + } + + if (lastSuspendedTime > expirationTime || firstSuspendedTime === NoWork) { + root.lastSuspendedTime = expirationTime; + } + + if (expirationTime <= root.lastPingedTime) { + root.lastPingedTime = NoWork; + } + + if (expirationTime <= root.lastExpiredTime) { + root.lastExpiredTime = NoWork; + } +} +function markRootUpdatedAtTime(root, expirationTime) { + // Update the range of pending times + var firstPendingTime = root.firstPendingTime; + + if (expirationTime > firstPendingTime) { + root.firstPendingTime = expirationTime; + } // Update the range of suspended times. Treat everything lower priority or + // equal to this update as unsuspended. + + var firstSuspendedTime = root.firstSuspendedTime; + + if (firstSuspendedTime !== NoWork) { + if (expirationTime >= firstSuspendedTime) { + // The entire suspended range is now unsuspended. + root.firstSuspendedTime = root.lastSuspendedTime = root.nextKnownPendingLevel = NoWork; + } else if (expirationTime >= root.lastSuspendedTime) { + root.lastSuspendedTime = expirationTime + 1; + } // This is a pending level. Check if it's higher priority than the next + // known pending level. + + if (expirationTime > root.nextKnownPendingLevel) { + root.nextKnownPendingLevel = expirationTime; + } + } +} +function markRootFinishedAtTime( + root, + finishedExpirationTime, + remainingExpirationTime ) { - var key = - arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null; - return { - // This tag allow us to uniquely identify this as a React Portal - $$typeof: REACT_PORTAL_TYPE, - key: key == null ? null : "" + key, - children: children, - containerInfo: containerInfo, - implementation: implementation - }; + // Update the range of pending times + root.firstPendingTime = remainingExpirationTime; // Update the range of suspended times. Treat everything higher priority or + // equal to this update as unsuspended. + + if (finishedExpirationTime <= root.lastSuspendedTime) { + // The entire suspended range is now unsuspended. + root.firstSuspendedTime = root.lastSuspendedTime = root.nextKnownPendingLevel = NoWork; + } else if (finishedExpirationTime <= root.firstSuspendedTime) { + // Part of the suspended range is now unsuspended. Narrow the range to + // include everything between the unsuspended time (non-inclusive) and the + // last suspended time. + root.firstSuspendedTime = finishedExpirationTime - 1; + } + + if (finishedExpirationTime <= root.lastPingedTime) { + // Clear the pinged time + root.lastPingedTime = NoWork; + } + + if (finishedExpirationTime <= root.lastExpiredTime) { + // Clear the expired time + root.lastExpiredTime = NoWork; + } +} +function markRootExpiredAtTime(root, expirationTime) { + var lastExpiredTime = root.lastExpiredTime; + + if (lastExpiredTime === NoWork || lastExpiredTime > expirationTime) { + root.lastExpiredTime = expirationTime; + } } var didWarnAboutNestedUpdates; @@ -21153,42 +19922,31 @@ function findHostInstanceWithWarning(component, methodName) { if (!didWarnAboutFindNodeInStrictMode[componentName]) { didWarnAboutFindNodeInStrictMode[componentName] = true; - var previousFiber = current; - try { - setCurrentFiber(hostFiber); - - if (fiber.mode & StrictMode) { - error( - "%s is deprecated in StrictMode. " + - "%s was passed an instance of %s which is inside StrictMode. " + - "Instead, add a ref directly to the element you want to reference. " + - "Learn more about using refs safely here: " + - "https://fb.me/react-strict-mode-find-node", - methodName, - methodName, - componentName - ); - } else { - error( - "%s is deprecated in StrictMode. " + - "%s was passed an instance of %s which renders StrictMode children. " + - "Instead, add a ref directly to the element you want to reference. " + - "Learn more about using refs safely here: " + - "https://fb.me/react-strict-mode-find-node", - methodName, - methodName, - componentName - ); - } - } finally { - // Ideally this should reset to previous but this shouldn't be called in - // render and there's another warning for that anyway. - if (previousFiber) { - setCurrentFiber(previousFiber); - } else { - resetCurrentFiber(); - } + if (fiber.mode & StrictMode) { + error( + "%s is deprecated in StrictMode. " + + "%s was passed an instance of %s which is inside StrictMode. " + + "Instead, add a ref directly to the element you want to reference. " + + "Learn more about using refs safely here: " + + "https://fb.me/react-strict-mode-find-node%s", + methodName, + methodName, + componentName, + getStackByFiberInDevAndProd(hostFiber) + ); + } else { + error( + "%s is deprecated in StrictMode. " + + "%s was passed an instance of %s which renders StrictMode children. " + + "Instead, add a ref directly to the element you want to reference. " + + "Learn more about using refs safely here: " + + "https://fb.me/react-strict-mode-find-node%s", + methodName, + methodName, + componentName, + getStackByFiberInDevAndProd(hostFiber) + ); } } } @@ -21206,7 +19964,7 @@ function updateContainer(element, container, parentComponent, callback) { } var current$1 = container.current; - var eventTime = requestEventTime(); + var currentTime = requestCurrentTimeForUpdate(); { // $FlowExpectedError - jest isn't a global, and isn't recognized outside of tests @@ -21216,8 +19974,11 @@ function updateContainer(element, container, parentComponent, callback) { } var suspenseConfig = requestCurrentSuspenseConfig(); - var lane = requestUpdateLane(current$1, suspenseConfig); - + var expirationTime = computeExpirationForFiber( + currentTime, + current$1, + suspenseConfig + ); var context = getContextForSubtree(parentComponent); if (container.context === null) { @@ -21240,7 +20001,7 @@ function updateContainer(element, container, parentComponent, callback) { } } - var update = createUpdate(eventTime, lane, suspenseConfig); // Caution: React DevTools currently depends on this property + var update = createUpdate(expirationTime, suspenseConfig); // Caution: React DevTools currently depends on this property // being called "element". update.payload = { @@ -21263,8 +20024,8 @@ function updateContainer(element, container, parentComponent, callback) { } enqueueUpdate(current$1, update); - scheduleUpdateOnFiber(current$1, lane, eventTime); - return lane; + scheduleWork(current$1, expirationTime); + return expirationTime; } function getPublicRootInstance(container) { var containerFiber = container.current; @@ -21331,7 +20092,7 @@ var setSuspenseHandler = null; // Shallow cloning props works as a workaround for now to bypass the bailout check. fiber.memoizedProps = Object.assign({}, fiber.memoizedProps); - scheduleUpdateOnFiber(fiber, SyncLane, NoTimestamp); + scheduleWork(fiber, Sync); } }; // Support DevTools props for function components, forwardRef, memo, host components, etc. @@ -21342,11 +20103,11 @@ var setSuspenseHandler = null; fiber.alternate.pendingProps = fiber.pendingProps; } - scheduleUpdateOnFiber(fiber, SyncLane, NoTimestamp); + scheduleWork(fiber, Sync); }; scheduleUpdate = function(fiber) { - scheduleUpdateOnFiber(fiber, SyncLane, NoTimestamp); + scheduleWork(fiber, Sync); }; setSuspenseHandler = function(newShouldSuspendImpl) { @@ -21354,24 +20115,6 @@ var setSuspenseHandler = null; }; } -function findHostInstanceByFiber(fiber) { - var hostFiber = findCurrentHostFiber(fiber); - - if (hostFiber === null) { - return null; - } - - return hostFiber.stateNode; -} - -function emptyFindFiberByHostInstance(instance) { - return null; -} - -function getCurrentFiberForDevTools() { - return current; -} - function injectIntoDevTools(devToolsConfig) { var findFiberByHostInstance = devToolsConfig.findFiberByHostInstance; var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher; @@ -21385,21 +20128,55 @@ function injectIntoDevTools(devToolsConfig) { setSuspenseHandler: setSuspenseHandler, scheduleUpdate: scheduleUpdate, currentDispatcherRef: ReactCurrentDispatcher, - findHostInstanceByFiber: findHostInstanceByFiber, - findFiberByHostInstance: - findFiberByHostInstance || emptyFindFiberByHostInstance, + findHostInstanceByFiber: function(fiber) { + var hostFiber = findCurrentHostFiber(fiber); + + if (hostFiber === null) { + return null; + } + + return hostFiber.stateNode; + }, + findFiberByHostInstance: function(instance) { + if (!findFiberByHostInstance) { + // Might not be implemented by the renderer. + return null; + } + + return findFiberByHostInstance(instance); + }, // React Refresh findHostInstancesForRefresh: findHostInstancesForRefresh, scheduleRefresh: scheduleRefresh, scheduleRoot: scheduleRoot, setRefreshHandler: setRefreshHandler, // Enables DevTools to append owner stacks to error messages in DEV mode. - getCurrentFiber: getCurrentFiberForDevTools + getCurrentFiber: function() { + return current; + } }); } +var IsSomeRendererActing$1 = ReactSharedInternals.IsSomeRendererActing; + +function createPortal( + children, + containerInfo, // TODO: figure out the API for cross-renderer implementation. + implementation +) { + var key = + arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null; + return { + // This tag allow us to uniquely identify this as a React Portal + $$typeof: REACT_PORTAL_TYPE, + key: key == null ? null : "" + key, + children: children, + containerInfo: containerInfo, + implementation: implementation + }; +} // TODO: this is special because it gets imported during build. -var ReactVersion = "17.0.0-alpha.0"; +var ReactVersion = "16.13.0"; var instanceCache = new Map(); @@ -21636,7 +20413,7 @@ var getInspectorDataForViewAtPoint; ); } else { error( - "getInspectorDataForViewAtPoint expects to receive a host component" + "getInspectorDataForViewAtPoint expects to receieve a host component" ); return; diff --git a/Libraries/Renderer/implementations/ReactFabric-prod.fb.js b/Libraries/Renderer/implementations/ReactFabric-prod.fb.js index d8543ccecd0..278eba5fa3c 100644 --- a/Libraries/Renderer/implementations/ReactFabric-prod.fb.js +++ b/Libraries/Renderer/implementations/ReactFabric-prod.fb.js @@ -15,6 +15,16 @@ require("react-native/Libraries/ReactPrivate/ReactNativePrivateInitializeCore"); var ReactNativePrivateInterface = require("react-native/Libraries/ReactPrivate/ReactNativePrivateInterface"), React = require("react"), Scheduler = require("scheduler"); +function getParent(inst) { + do inst = inst.return; + while (inst && 5 !== inst.tag); + return inst ? inst : null; +} +function traverseTwoPhase(inst, fn, arg) { + for (var path = []; inst; ) path.push(inst), (inst = getParent(inst)); + for (inst = path.length; 0 < inst--; ) fn(path[inst], "captured", arg); + for (inst = 0; inst < path.length; inst++) fn(path[inst], "bubbled", arg); +} function invokeGuardedCallbackImpl(name, func, context, a, b, c, d, e, f) { var funcArgs = Array.prototype.slice.call(arguments, 3); try { @@ -85,6 +95,109 @@ function executeDirectDispatch(event) { event._dispatchInstances = null; return dispatchListener; } +function getListener(inst, registrationName) { + var listener = inst.stateNode; + if (!listener) return null; + var props = getFiberCurrentPropsFromNode(listener); + if (!props) return null; + listener = props[registrationName]; + a: switch (registrationName) { + case "onClick": + case "onClickCapture": + case "onDoubleClick": + case "onDoubleClickCapture": + case "onMouseDown": + case "onMouseDownCapture": + case "onMouseMove": + case "onMouseMoveCapture": + case "onMouseUp": + case "onMouseUpCapture": + case "onMouseEnter": + (props = !props.disabled) || + ((inst = inst.type), + (props = !( + "button" === inst || + "input" === inst || + "select" === inst || + "textarea" === inst + ))); + inst = !props; + break a; + default: + inst = !1; + } + if (inst) return null; + if (listener && "function" !== typeof listener) + throw Error( + "Expected `" + + registrationName + + "` listener to be a function, instead got a value of `" + + typeof listener + + "` type." + ); + return listener; +} +function accumulateInto(current, next) { + if (null == next) + throw Error( + "accumulateInto(...): Accumulated items must not be null or undefined." + ); + if (null == current) return next; + if (Array.isArray(current)) { + if (Array.isArray(next)) return current.push.apply(current, next), current; + current.push(next); + return current; + } + return Array.isArray(next) ? [current].concat(next) : [current, next]; +} +function forEachAccumulated(arr, cb, scope) { + Array.isArray(arr) ? arr.forEach(cb, scope) : arr && cb.call(scope, arr); +} +function accumulateDirectionalDispatches(inst, phase, event) { + if ( + (phase = getListener( + inst, + event.dispatchConfig.phasedRegistrationNames[phase] + )) + ) + (event._dispatchListeners = accumulateInto( + event._dispatchListeners, + phase + )), + (event._dispatchInstances = accumulateInto( + event._dispatchInstances, + inst + )); +} +function accumulateTwoPhaseDispatchesSingle(event) { + event && + event.dispatchConfig.phasedRegistrationNames && + traverseTwoPhase(event._targetInst, accumulateDirectionalDispatches, event); +} +function accumulateTwoPhaseDispatchesSingleSkipTarget(event) { + if (event && event.dispatchConfig.phasedRegistrationNames) { + var targetInst = event._targetInst; + targetInst = targetInst ? getParent(targetInst) : null; + traverseTwoPhase(targetInst, accumulateDirectionalDispatches, event); + } +} +function accumulateDirectDispatchesSingle(event) { + if (event && event.dispatchConfig.registrationName) { + var inst = event._targetInst; + if (inst && event && event.dispatchConfig.registrationName) { + var listener = getListener(inst, event.dispatchConfig.registrationName); + listener && + ((event._dispatchListeners = accumulateInto( + event._dispatchListeners, + listener + )), + (event._dispatchInstances = accumulateInto( + event._dispatchInstances, + inst + ))); + } + } +} function functionThatReturnsTrue() { return !0; } @@ -100,7 +213,6 @@ function SyntheticEvent( this.dispatchConfig = dispatchConfig; this._targetInst = targetInst; this.nativeEvent = nativeEvent; - this._dispatchInstances = this._dispatchListeners = null; dispatchConfig = this.constructor.Interface; for (var propName in dispatchConfig) dispatchConfig.hasOwnProperty(propName) && @@ -180,12 +292,7 @@ SyntheticEvent.extend = function(Interface) { return Class; }; addEventPoolingTo(SyntheticEvent); -function createOrGetPooledEvent( - dispatchConfig, - targetInst, - nativeEvent, - nativeInst -) { +function getPooledEvent(dispatchConfig, targetInst, nativeEvent, nativeInst) { if (this.eventPool.length) { var instance = this.eventPool.pop(); this.call(instance, dispatchConfig, targetInst, nativeEvent, nativeInst); @@ -202,8 +309,8 @@ function releasePooledEvent(event) { 10 > this.eventPool.length && this.eventPool.push(event); } function addEventPoolingTo(EventConstructor) { - EventConstructor.getPooled = createOrGetPooledEvent; EventConstructor.eventPool = []; + EventConstructor.getPooled = getPooledEvent; EventConstructor.release = releasePooledEvent; } var ResponderSyntheticEvent = SyntheticEvent.extend({ @@ -331,22 +438,6 @@ function accumulate(current, next) { ? [current].concat(next) : [current, next]; } -function accumulateInto(current, next) { - if (null == next) - throw Error( - "accumulateInto(...): Accumulated items must not be null or undefined." - ); - if (null == current) return next; - if (Array.isArray(current)) { - if (Array.isArray(next)) return current.push.apply(current, next), current; - current.push(next); - return current; - } - return Array.isArray(next) ? [current].concat(next) : [current, next]; -} -function forEachAccumulated(arr, cb, scope) { - Array.isArray(arr) ? arr.forEach(cb, scope) : arr && cb.call(scope, arr); -} var responderInst = null, trackedTouchCount = 0; function changeResponder(nextResponderInst, blockHostResponder) { @@ -360,132 +451,65 @@ function changeResponder(nextResponderInst, blockHostResponder) { ); } var eventTypes = { - startShouldSetResponder: { - phasedRegistrationNames: { - bubbled: "onStartShouldSetResponder", - captured: "onStartShouldSetResponderCapture" + startShouldSetResponder: { + phasedRegistrationNames: { + bubbled: "onStartShouldSetResponder", + captured: "onStartShouldSetResponderCapture" + }, + dependencies: startDependencies }, - dependencies: startDependencies - }, - scrollShouldSetResponder: { - phasedRegistrationNames: { - bubbled: "onScrollShouldSetResponder", - captured: "onScrollShouldSetResponderCapture" + scrollShouldSetResponder: { + phasedRegistrationNames: { + bubbled: "onScrollShouldSetResponder", + captured: "onScrollShouldSetResponderCapture" + }, + dependencies: ["topScroll"] }, - dependencies: ["topScroll"] - }, - selectionChangeShouldSetResponder: { - phasedRegistrationNames: { - bubbled: "onSelectionChangeShouldSetResponder", - captured: "onSelectionChangeShouldSetResponderCapture" + selectionChangeShouldSetResponder: { + phasedRegistrationNames: { + bubbled: "onSelectionChangeShouldSetResponder", + captured: "onSelectionChangeShouldSetResponderCapture" + }, + dependencies: ["topSelectionChange"] }, - dependencies: ["topSelectionChange"] - }, - moveShouldSetResponder: { - phasedRegistrationNames: { - bubbled: "onMoveShouldSetResponder", - captured: "onMoveShouldSetResponderCapture" + moveShouldSetResponder: { + phasedRegistrationNames: { + bubbled: "onMoveShouldSetResponder", + captured: "onMoveShouldSetResponderCapture" + }, + dependencies: moveDependencies }, - dependencies: moveDependencies - }, - responderStart: { - registrationName: "onResponderStart", - dependencies: startDependencies - }, - responderMove: { - registrationName: "onResponderMove", - dependencies: moveDependencies - }, - responderEnd: { - registrationName: "onResponderEnd", - dependencies: endDependencies - }, - responderRelease: { - registrationName: "onResponderRelease", - dependencies: endDependencies - }, - responderTerminationRequest: { - registrationName: "onResponderTerminationRequest", - dependencies: [] - }, - responderGrant: { registrationName: "onResponderGrant", dependencies: [] }, - responderReject: { registrationName: "onResponderReject", dependencies: [] }, - responderTerminate: { - registrationName: "onResponderTerminate", - dependencies: [] - } -}; -function getParent(inst) { - do inst = inst.return; - while (inst && 5 !== inst.tag); - return inst ? inst : null; -} -function traverseTwoPhase(inst, fn, arg) { - for (var path = []; inst; ) path.push(inst), (inst = getParent(inst)); - for (inst = path.length; 0 < inst--; ) fn(path[inst], "captured", arg); - for (inst = 0; inst < path.length; inst++) fn(path[inst], "bubbled", arg); -} -function getListener(inst, registrationName) { - inst = inst.stateNode; - if (null === inst) return null; - inst = getFiberCurrentPropsFromNode(inst); - if (null === inst) return null; - if ((inst = inst[registrationName]) && "function" !== typeof inst) - throw Error( - "Expected `" + - registrationName + - "` listener to be a function, instead got a value of `" + - typeof inst + - "` type." - ); - return inst; -} -function accumulateDirectionalDispatches(inst, phase, event) { - if ( - (phase = getListener( - inst, - event.dispatchConfig.phasedRegistrationNames[phase] - )) - ) - (event._dispatchListeners = accumulateInto( - event._dispatchListeners, - phase - )), - (event._dispatchInstances = accumulateInto( - event._dispatchInstances, - inst - )); -} -function accumulateDirectDispatchesSingle(event) { - if (event && event.dispatchConfig.registrationName) { - var inst = event._targetInst; - if (inst && event && event.dispatchConfig.registrationName) { - var listener = getListener(inst, event.dispatchConfig.registrationName); - listener && - ((event._dispatchListeners = accumulateInto( - event._dispatchListeners, - listener - )), - (event._dispatchInstances = accumulateInto( - event._dispatchInstances, - inst - ))); + responderStart: { + registrationName: "onResponderStart", + dependencies: startDependencies + }, + responderMove: { + registrationName: "onResponderMove", + dependencies: moveDependencies + }, + responderEnd: { + registrationName: "onResponderEnd", + dependencies: endDependencies + }, + responderRelease: { + registrationName: "onResponderRelease", + dependencies: endDependencies + }, + responderTerminationRequest: { + registrationName: "onResponderTerminationRequest", + dependencies: [] + }, + responderGrant: { registrationName: "onResponderGrant", dependencies: [] }, + responderReject: { + registrationName: "onResponderReject", + dependencies: [] + }, + responderTerminate: { + registrationName: "onResponderTerminate", + dependencies: [] } - } -} -function accumulateTwoPhaseDispatchesSingleSkipTarget(event) { - if (event && event.dispatchConfig.phasedRegistrationNames) { - var targetInst = event._targetInst; - targetInst = targetInst ? getParent(targetInst) : null; - traverseTwoPhase(targetInst, accumulateDirectionalDispatches, event); - } -} -function accumulateTwoPhaseDispatchesSingle(event) { - event && - event.dispatchConfig.phasedRegistrationNames && - traverseTwoPhase(event._targetInst, accumulateDirectionalDispatches, event); -} -var ResponderEventPlugin = { + }, + ResponderEventPlugin = { _getResponder: function() { return responderInst; }, @@ -546,70 +570,68 @@ var ResponderEventPlugin = { JSCompiler_temp = null; } else JSCompiler_temp = targetInst; - targetInst = JSCompiler_temp; - JSCompiler_temp = targetInst === responderInst; - shouldSetEventType = ResponderSyntheticEvent.getPooled( + targetInst = JSCompiler_temp === responderInst; + JSCompiler_temp = ResponderSyntheticEvent.getPooled( shouldSetEventType, - targetInst, + JSCompiler_temp, nativeEvent, nativeEventTarget ); - shouldSetEventType.touchHistory = - ResponderTouchHistoryStore.touchHistory; - JSCompiler_temp + JSCompiler_temp.touchHistory = ResponderTouchHistoryStore.touchHistory; + targetInst ? forEachAccumulated( - shouldSetEventType, + JSCompiler_temp, accumulateTwoPhaseDispatchesSingleSkipTarget ) : forEachAccumulated( - shouldSetEventType, + JSCompiler_temp, accumulateTwoPhaseDispatchesSingle ); b: { - JSCompiler_temp = shouldSetEventType._dispatchListeners; - targetInst = shouldSetEventType._dispatchInstances; - if (Array.isArray(JSCompiler_temp)) + shouldSetEventType = JSCompiler_temp._dispatchListeners; + targetInst = JSCompiler_temp._dispatchInstances; + if (Array.isArray(shouldSetEventType)) for ( depthA = 0; - depthA < JSCompiler_temp.length && - !shouldSetEventType.isPropagationStopped(); + depthA < shouldSetEventType.length && + !JSCompiler_temp.isPropagationStopped(); depthA++ ) { if ( - JSCompiler_temp[depthA](shouldSetEventType, targetInst[depthA]) + shouldSetEventType[depthA](JSCompiler_temp, targetInst[depthA]) ) { - JSCompiler_temp = targetInst[depthA]; + shouldSetEventType = targetInst[depthA]; break b; } } else if ( - JSCompiler_temp && - JSCompiler_temp(shouldSetEventType, targetInst) + shouldSetEventType && + shouldSetEventType(JSCompiler_temp, targetInst) ) { - JSCompiler_temp = targetInst; + shouldSetEventType = targetInst; break b; } - JSCompiler_temp = null; + shouldSetEventType = null; } - shouldSetEventType._dispatchInstances = null; - shouldSetEventType._dispatchListeners = null; - shouldSetEventType.isPersistent() || - shouldSetEventType.constructor.release(shouldSetEventType); - if (JSCompiler_temp && JSCompiler_temp !== responderInst) + JSCompiler_temp._dispatchInstances = null; + JSCompiler_temp._dispatchListeners = null; + JSCompiler_temp.isPersistent() || + JSCompiler_temp.constructor.release(JSCompiler_temp); + if (shouldSetEventType && shouldSetEventType !== responderInst) if ( - ((shouldSetEventType = ResponderSyntheticEvent.getPooled( + ((JSCompiler_temp = ResponderSyntheticEvent.getPooled( eventTypes.responderGrant, - JSCompiler_temp, + shouldSetEventType, nativeEvent, nativeEventTarget )), - (shouldSetEventType.touchHistory = + (JSCompiler_temp.touchHistory = ResponderTouchHistoryStore.touchHistory), forEachAccumulated( - shouldSetEventType, + JSCompiler_temp, accumulateDirectDispatchesSingle ), - (targetInst = !0 === executeDirectDispatch(shouldSetEventType)), + (targetInst = !0 === executeDirectDispatch(JSCompiler_temp)), responderInst) ) if ( @@ -636,13 +658,13 @@ var ResponderEventPlugin = { forEachAccumulated(depthA, accumulateDirectDispatchesSingle); var JSCompiler_temp$jscomp$0 = accumulate( JSCompiler_temp$jscomp$0, - [shouldSetEventType, depthA] + [JSCompiler_temp, depthA] ); - changeResponder(JSCompiler_temp, targetInst); + changeResponder(shouldSetEventType, targetInst); } else (shouldSetEventType = ResponderSyntheticEvent.getPooled( eventTypes.responderReject, - JSCompiler_temp, + shouldSetEventType, nativeEvent, nativeEventTarget )), @@ -659,9 +681,9 @@ var ResponderEventPlugin = { else (JSCompiler_temp$jscomp$0 = accumulate( JSCompiler_temp$jscomp$0, - shouldSetEventType + JSCompiler_temp )), - changeResponder(JSCompiler_temp, targetInst); + changeResponder(shouldSetEventType, targetInst); else JSCompiler_temp$jscomp$0 = null; } else JSCompiler_temp$jscomp$0 = null; shouldSetEventType = responderInst && isStartish(topLevelType); @@ -789,6 +811,7 @@ function recomputePluginOrdering() { for (var eventName in pluginIndex) { var JSCompiler_inline_result = void 0; var dispatchConfig = pluginIndex[eventName], + pluginModule$jscomp$0 = pluginModule, eventName$jscomp$0 = eventName; if (eventNameDispatchConfigs.hasOwnProperty(eventName$jscomp$0)) throw Error( @@ -805,7 +828,7 @@ function recomputePluginOrdering() { ) && publishRegistrationName( phasedRegistrationNames[JSCompiler_inline_result], - pluginModule, + pluginModule$jscomp$0, eventName$jscomp$0 ); JSCompiler_inline_result = !0; @@ -813,7 +836,7 @@ function recomputePluginOrdering() { dispatchConfig.registrationName ? (publishRegistrationName( dispatchConfig.registrationName, - pluginModule, + pluginModule$jscomp$0, eventName$jscomp$0 ), (JSCompiler_inline_result = !0)) @@ -841,75 +864,13 @@ function publishRegistrationName(registrationName, pluginModule) { } var plugins = [], eventNameDispatchConfigs = {}, - registrationNameModules = {}; -function getListener$1(inst, registrationName) { - inst = inst.stateNode; - if (null === inst) return null; - inst = getFiberCurrentPropsFromNode(inst); - if (null === inst) return null; - if ((inst = inst[registrationName]) && "function" !== typeof inst) - throw Error( - "Expected `" + - registrationName + - "` listener to be a function, instead got a value of `" + - typeof inst + - "` type." - ); - return inst; -} -var customBubblingEventTypes = + registrationNameModules = {}, + customBubblingEventTypes = ReactNativePrivateInterface.ReactNativeViewConfigRegistry .customBubblingEventTypes, customDirectEventTypes = ReactNativePrivateInterface.ReactNativeViewConfigRegistry .customDirectEventTypes; -function accumulateDirectionalDispatches$1(inst, phase, event) { - if ( - (phase = getListener$1( - inst, - event.dispatchConfig.phasedRegistrationNames[phase] - )) - ) - (event._dispatchListeners = accumulateInto( - event._dispatchListeners, - phase - )), - (event._dispatchInstances = accumulateInto( - event._dispatchInstances, - inst - )); -} -function accumulateTwoPhaseDispatchesSingle$1(event) { - if (event && event.dispatchConfig.phasedRegistrationNames) { - for (var inst = event._targetInst, path = []; inst; ) { - path.push(inst); - do inst = inst.return; - while (inst && 5 !== inst.tag); - inst = inst ? inst : null; - } - for (inst = path.length; 0 < inst--; ) - accumulateDirectionalDispatches$1(path[inst], "captured", event); - for (inst = 0; inst < path.length; inst++) - accumulateDirectionalDispatches$1(path[inst], "bubbled", event); - } -} -function accumulateDirectDispatchesSingle$1(event) { - if (event && event.dispatchConfig.registrationName) { - var inst = event._targetInst; - if (inst && event && event.dispatchConfig.registrationName) { - var listener = getListener$1(inst, event.dispatchConfig.registrationName); - listener && - ((event._dispatchListeners = accumulateInto( - event._dispatchListeners, - listener - )), - (event._dispatchInstances = accumulateInto( - event._dispatchInstances, - inst - ))); - } - } -} if (eventPluginOrder) throw Error( "EventPluginRegistry: Cannot inject event plugin ordering more than once. You are likely trying to load more than one copy of React." @@ -919,7 +880,7 @@ eventPluginOrder = Array.prototype.slice.call([ "ReactNativeBridgeEventPlugin" ]); recomputePluginOrdering(); -var injectedNamesToPlugins$jscomp$inline_225 = { +var injectedNamesToPlugins$jscomp$inline_92 = { ResponderEventPlugin: ResponderEventPlugin, ReactNativeBridgeEventPlugin: { eventTypes: {}, @@ -943,45 +904,42 @@ var injectedNamesToPlugins$jscomp$inline_225 = { nativeEventTarget ); if (bubbleDispatchConfig) - forEachAccumulated( - topLevelType, - accumulateTwoPhaseDispatchesSingle$1 - ); + forEachAccumulated(topLevelType, accumulateTwoPhaseDispatchesSingle); else if (directDispatchConfig) - forEachAccumulated(topLevelType, accumulateDirectDispatchesSingle$1); + forEachAccumulated(topLevelType, accumulateDirectDispatchesSingle); else return null; return topLevelType; } } }, - isOrderingDirty$jscomp$inline_226 = !1, - pluginName$jscomp$inline_227; -for (pluginName$jscomp$inline_227 in injectedNamesToPlugins$jscomp$inline_225) + isOrderingDirty$jscomp$inline_93 = !1, + pluginName$jscomp$inline_94; +for (pluginName$jscomp$inline_94 in injectedNamesToPlugins$jscomp$inline_92) if ( - injectedNamesToPlugins$jscomp$inline_225.hasOwnProperty( - pluginName$jscomp$inline_227 + injectedNamesToPlugins$jscomp$inline_92.hasOwnProperty( + pluginName$jscomp$inline_94 ) ) { - var pluginModule$jscomp$inline_228 = - injectedNamesToPlugins$jscomp$inline_225[pluginName$jscomp$inline_227]; + var pluginModule$jscomp$inline_95 = + injectedNamesToPlugins$jscomp$inline_92[pluginName$jscomp$inline_94]; if ( - !namesToPlugins.hasOwnProperty(pluginName$jscomp$inline_227) || - namesToPlugins[pluginName$jscomp$inline_227] !== - pluginModule$jscomp$inline_228 + !namesToPlugins.hasOwnProperty(pluginName$jscomp$inline_94) || + namesToPlugins[pluginName$jscomp$inline_94] !== + pluginModule$jscomp$inline_95 ) { - if (namesToPlugins[pluginName$jscomp$inline_227]) + if (namesToPlugins[pluginName$jscomp$inline_94]) throw Error( "EventPluginRegistry: Cannot inject two different event plugins using the same name, `" + - pluginName$jscomp$inline_227 + + pluginName$jscomp$inline_94 + "`." ); namesToPlugins[ - pluginName$jscomp$inline_227 - ] = pluginModule$jscomp$inline_228; - isOrderingDirty$jscomp$inline_226 = !0; + pluginName$jscomp$inline_94 + ] = pluginModule$jscomp$inline_95; + isOrderingDirty$jscomp$inline_93 = !0; } } -isOrderingDirty$jscomp$inline_226 && recomputePluginOrdering(); +isOrderingDirty$jscomp$inline_93 && recomputePluginOrdering(); function getInstanceFromInstance(instanceHandle) { return instanceHandle; } @@ -1005,44 +963,31 @@ ResponderEventPlugin.injection.injectGlobalResponderHandler({ } }); var ReactSharedInternals = - React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED, - REACT_ELEMENT_TYPE = 60103, - REACT_PORTAL_TYPE = 60106, - REACT_FRAGMENT_TYPE = 60107, - REACT_STRICT_MODE_TYPE = 60108, - REACT_PROFILER_TYPE = 60114, - REACT_PROVIDER_TYPE = 60109, - REACT_CONTEXT_TYPE = 60110, - REACT_FORWARD_REF_TYPE = 60112, - REACT_SUSPENSE_TYPE = 60113, - REACT_SUSPENSE_LIST_TYPE = 60120, - REACT_MEMO_TYPE = 60115, - REACT_LAZY_TYPE = 60116, - REACT_BLOCK_TYPE = 60121, - REACT_DEBUG_TRACING_MODE_TYPE = 60129, - REACT_OFFSCREEN_TYPE = 60130, - REACT_LEGACY_HIDDEN_TYPE = 60131; -if ("function" === typeof Symbol && Symbol.for) { - var symbolFor = Symbol.for; - REACT_ELEMENT_TYPE = symbolFor("react.element"); - REACT_PORTAL_TYPE = symbolFor("react.portal"); - REACT_FRAGMENT_TYPE = symbolFor("react.fragment"); - REACT_STRICT_MODE_TYPE = symbolFor("react.strict_mode"); - REACT_PROFILER_TYPE = symbolFor("react.profiler"); - REACT_PROVIDER_TYPE = symbolFor("react.provider"); - REACT_CONTEXT_TYPE = symbolFor("react.context"); - REACT_FORWARD_REF_TYPE = symbolFor("react.forward_ref"); - REACT_SUSPENSE_TYPE = symbolFor("react.suspense"); - REACT_SUSPENSE_LIST_TYPE = symbolFor("react.suspense_list"); - REACT_MEMO_TYPE = symbolFor("react.memo"); - REACT_LAZY_TYPE = symbolFor("react.lazy"); - REACT_BLOCK_TYPE = symbolFor("react.block"); - symbolFor("react.scope"); - REACT_DEBUG_TRACING_MODE_TYPE = symbolFor("react.debug_trace_mode"); - REACT_OFFSCREEN_TYPE = symbolFor("react.offscreen"); - REACT_LEGACY_HIDDEN_TYPE = symbolFor("react.legacy_hidden"); -} -var MAYBE_ITERATOR_SYMBOL = "function" === typeof Symbol && Symbol.iterator; + React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED; +ReactSharedInternals.hasOwnProperty("ReactCurrentDispatcher") || + (ReactSharedInternals.ReactCurrentDispatcher = { current: null }); +ReactSharedInternals.hasOwnProperty("ReactCurrentBatchConfig") || + (ReactSharedInternals.ReactCurrentBatchConfig = { suspense: null }); +var hasSymbol = "function" === typeof Symbol && Symbol.for, + REACT_ELEMENT_TYPE = hasSymbol ? Symbol.for("react.element") : 60103, + REACT_PORTAL_TYPE = hasSymbol ? Symbol.for("react.portal") : 60106, + REACT_FRAGMENT_TYPE = hasSymbol ? Symbol.for("react.fragment") : 60107, + REACT_STRICT_MODE_TYPE = hasSymbol ? Symbol.for("react.strict_mode") : 60108, + REACT_PROFILER_TYPE = hasSymbol ? Symbol.for("react.profiler") : 60114, + REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for("react.provider") : 60109, + REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for("react.context") : 60110, + REACT_CONCURRENT_MODE_TYPE = hasSymbol + ? Symbol.for("react.concurrent_mode") + : 60111, + REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for("react.forward_ref") : 60112, + REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for("react.suspense") : 60113, + REACT_SUSPENSE_LIST_TYPE = hasSymbol + ? Symbol.for("react.suspense_list") + : 60120, + REACT_MEMO_TYPE = hasSymbol ? Symbol.for("react.memo") : 60115, + REACT_LAZY_TYPE = hasSymbol ? Symbol.for("react.lazy") : 60116, + REACT_BLOCK_TYPE = hasSymbol ? Symbol.for("react.block") : 60121, + MAYBE_ITERATOR_SYMBOL = "function" === typeof Symbol && Symbol.iterator; function getIteratorFn(maybeIterable) { if (null === maybeIterable || "object" !== typeof maybeIterable) return null; maybeIterable = @@ -1050,6 +995,27 @@ function getIteratorFn(maybeIterable) { maybeIterable["@@iterator"]; return "function" === typeof maybeIterable ? maybeIterable : null; } +function initializeLazyComponentType(lazyComponent) { + if (-1 === lazyComponent._status) { + var ctor = lazyComponent._result; + ctor || (ctor = lazyComponent._ctor); + ctor = ctor(); + lazyComponent._status = 0; + lazyComponent._result = ctor; + ctor.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)); + } + ); + } +} function getComponentName(type) { if (null == type) return null; if ("function" === typeof type) return type.displayName || type.name || null; @@ -1084,13 +1050,10 @@ function getComponentName(type) { case REACT_MEMO_TYPE: return getComponentName(type.type); case REACT_BLOCK_TYPE: - return getComponentName(type._render); + return getComponentName(type.render); case REACT_LAZY_TYPE: - innerType = type._payload; - type = type._init; - try { - return getComponentName(type(innerType)); - } catch (x) {} + if ((type = 1 === type._status ? type._result : null)) + return getComponentName(type); } return null; } @@ -1142,36 +1105,36 @@ function findCurrentFiberUsingSlowPath(fiber) { } if (a.return !== b.return) (a = parentA), (b = parentB); else { - for (var didFindChild = !1, child$0 = parentA.child; child$0; ) { - if (child$0 === a) { + for (var didFindChild = !1, _child = parentA.child; _child; ) { + if (_child === a) { didFindChild = !0; a = parentA; b = parentB; break; } - if (child$0 === b) { + if (_child === b) { didFindChild = !0; b = parentA; a = parentB; break; } - child$0 = child$0.sibling; + _child = _child.sibling; } if (!didFindChild) { - for (child$0 = parentB.child; child$0; ) { - if (child$0 === a) { + for (_child = parentB.child; _child; ) { + if (_child === a) { didFindChild = !0; a = parentB; b = parentA; break; } - if (child$0 === b) { + if (_child === b) { didFindChild = !0; b = parentB; a = parentA; break; } - child$0 = child$0.sibling; + _child = _child.sibling; } if (!didFindChild) throw Error( @@ -1206,18 +1169,6 @@ function findCurrentHostFiber(parent) { } return null; } -function doesFiberContain(parentFiber, childFiber) { - for ( - var parentFiberAlternate = parentFiber.alternate; - null !== childFiber; - - ) { - if (childFiber === parentFiber || childFiber === parentFiberAlternate) - return !0; - childFiber = childFiber.return; - } - return !1; -} function mountSafeCallback_NOT_REALLY_SAFE(context, callback) { return function() { if ( @@ -1431,19 +1382,19 @@ function diffProperties(updatePayload, prevProps, nextProps, validAttributes) { ), (removedKeys = null)); } - for (var propKey$2 in prevProps) - void 0 === nextProps[propKey$2] && - (!(attributeConfig = validAttributes[propKey$2]) || - (updatePayload && void 0 !== updatePayload[propKey$2]) || - ((prevProp = prevProps[propKey$2]), + for (var _propKey in prevProps) + void 0 === nextProps[_propKey] && + (!(attributeConfig = validAttributes[_propKey]) || + (updatePayload && void 0 !== updatePayload[_propKey]) || + ((prevProp = prevProps[_propKey]), void 0 !== prevProp && ("object" !== typeof attributeConfig || "function" === typeof attributeConfig.diff || "function" === typeof attributeConfig.process - ? (((updatePayload || (updatePayload = {}))[propKey$2] = null), + ? (((updatePayload || (updatePayload = {}))[_propKey] = null), removedKeys || (removedKeys = {}), - removedKeys[propKey$2] || - ((removedKeys[propKey$2] = !0), removedKeyCount++)) + removedKeys[_propKey] || + ((removedKeys[_propKey] = !0), removedKeyCount++)) : (updatePayload = clearNestedProperty( updatePayload, prevProp, @@ -1491,49 +1442,37 @@ function dispatchEvent(target, topLevelType, nativeEvent) { null != stateNode && (eventTarget = stateNode.canonical); } batchedUpdates(function() { - var JSCompiler_inline_result = eventTarget; - for ( - var events = null, legacyPlugins = plugins, i = 0; - i < legacyPlugins.length; - i++ - ) { - var possiblePlugin = legacyPlugins[i]; + var events = eventTarget; + for (var events$jscomp$0 = null, i = 0; i < plugins.length; i++) { + var possiblePlugin = plugins[i]; possiblePlugin && (possiblePlugin = possiblePlugin.extractEvents( topLevelType, target, nativeEvent, - JSCompiler_inline_result + events, + 1 )) && - (events = accumulateInto(events, possiblePlugin)); + (events$jscomp$0 = accumulateInto(events$jscomp$0, possiblePlugin)); } - JSCompiler_inline_result = events; - null !== JSCompiler_inline_result && - (eventQueue = accumulateInto(eventQueue, JSCompiler_inline_result)); - JSCompiler_inline_result = eventQueue; + events = events$jscomp$0; + null !== events && (eventQueue = accumulateInto(eventQueue, events)); + events = eventQueue; eventQueue = null; - if (JSCompiler_inline_result) { - forEachAccumulated( - JSCompiler_inline_result, - executeDispatchesAndReleaseTopLevel - ); + if (events) { + forEachAccumulated(events, executeDispatchesAndReleaseTopLevel); if (eventQueue) throw Error( "processEventQueue(): Additional events were enqueued while processing an event queue. Support for this has not yet been implemented." ); if (hasRethrowError) - throw ((JSCompiler_inline_result = rethrowError), + throw ((events = rethrowError), (hasRethrowError = !1), (rethrowError = null), - JSCompiler_inline_result); + events); } }); } -function shim() { - throw Error( - "The current renderer does not support mutation. This error is likely caused by a bug in React. Please file an issue." - ); -} function shim$1() { throw Error( "The current renderer does not support hydration. This error is likely caused by a bug in React. Please file an issue." @@ -1626,32 +1565,19 @@ var scheduleTimeout = setTimeout, cancelTimeout = clearTimeout; function cloneHiddenInstance(instance) { var node = instance.node; - var JSCompiler_inline_result = diffProperties( + var updatePayload = diffProperties( null, emptyObject, { style: { display: "none" } }, instance.canonical.viewConfig.validAttributes ); return { - node: cloneNodeWithNewProps(node, JSCompiler_inline_result), + node: cloneNodeWithNewProps(node, updatePayload), canonical: instance.canonical }; } -function describeComponentFrame(name, source, ownerName) { - source = ""; - ownerName && (source = " (created by " + ownerName + ")"); - return "\n in " + (name || "Unknown") + source; -} -function describeFunctionComponentFrame(fn, source) { - return fn - ? describeComponentFrame(fn.displayName || fn.name || null, source, null) - : ""; -} var valueStack = [], index = -1; -function createCursor(defaultValue) { - return { current: defaultValue }; -} function pop(cursor) { 0 > index || ((cursor.current = valueStack[index]), (valueStack[index] = null), index--); @@ -1662,8 +1588,8 @@ function push(cursor, value) { cursor.current = value; } var emptyContextObject = {}, - contextStackCursor = createCursor(emptyContextObject), - didPerformWorkStackCursor = createCursor(!1), + contextStackCursor = { current: emptyContextObject }, + didPerformWorkStackCursor = { current: !1 }, previousContext = emptyContextObject; function getMaskedContext(workInProgress, unmaskedContext) { var contextTypes = workInProgress.type.contextTypes; @@ -1743,220 +1669,11 @@ function invalidateContextProvider(workInProgress, type, didChange) { : pop(didPerformWorkStackCursor); push(didPerformWorkStackCursor, didChange); } -var rendererID = null, - injectedHook = null, - Scheduler_now = Scheduler.unstable_now; -Scheduler_now(); -var return_highestLanePriority = 10; -function getHighestPriorityLanes(lanes) { - if (0 !== (1 & lanes)) return (return_highestLanePriority = 17), 1; - if (0 !== (2 & lanes)) return (return_highestLanePriority = 16), 2; - if (0 !== (4 & lanes)) return (return_highestLanePriority = 15), 4; - var inputDiscreteLanes = 24 & lanes; - if (0 !== inputDiscreteLanes) - return (return_highestLanePriority = 14), inputDiscreteLanes; - if (0 !== (lanes & 32)) return (return_highestLanePriority = 13), 32; - inputDiscreteLanes = 192 & lanes; - if (0 !== inputDiscreteLanes) - return (return_highestLanePriority = 12), inputDiscreteLanes; - if (0 !== (lanes & 256)) return (return_highestLanePriority = 11), 256; - inputDiscreteLanes = 3584 & lanes; - if (0 !== inputDiscreteLanes) - return (return_highestLanePriority = 10), inputDiscreteLanes; - if (0 !== (lanes & 4096)) return (return_highestLanePriority = 9), 4096; - inputDiscreteLanes = 122880 & lanes; - if (0 !== inputDiscreteLanes) - return (return_highestLanePriority = 8), inputDiscreteLanes; - if (0 !== (lanes & 131072)) return (return_highestLanePriority = 7), 131072; - inputDiscreteLanes = 3932160 & lanes; - if (0 !== inputDiscreteLanes) - return (return_highestLanePriority = 6), inputDiscreteLanes; - inputDiscreteLanes = 62914560 & lanes; - if (0 !== inputDiscreteLanes) - return (return_highestLanePriority = 5), inputDiscreteLanes; - if (lanes & 67108864) return (return_highestLanePriority = 4), 67108864; - if (0 !== (lanes & 134217728)) - return (return_highestLanePriority = 3), 134217728; - inputDiscreteLanes = 805306368 & lanes; - if (0 !== inputDiscreteLanes) - return (return_highestLanePriority = 2), inputDiscreteLanes; - if (0 !== (1073741824 & lanes)) - return (return_highestLanePriority = 1), 1073741824; - return_highestLanePriority = 10; - return lanes; -} -function schedulerPriorityToLanePriority(schedulerPriorityLevel) { - switch (schedulerPriorityLevel) { - case 99: - return 17; - case 98: - return 12; - case 97: - case 96: - return 10; - case 95: - return 2; - default: - return 0; - } -} -function lanePriorityToSchedulerPriority(lanePriority) { - switch (lanePriority) { - case 17: - case 16: - return 99; - case 15: - case 14: - case 13: - case 12: - return 98; - case 11: - case 10: - case 9: - case 8: - case 7: - case 6: - case 4: - case 5: - return 97; - case 3: - case 2: - case 1: - return 95; - case 0: - return 90; - default: - throw Error( - "Invalid update priority: " + lanePriority + ". This is a bug in React." - ); - } -} -function getNextLanes(root, wipLanes) { - var pendingLanes = root.pendingLanes; - if (0 === pendingLanes) return (return_highestLanePriority = 0); - var nextLanes = 0, - nextLanePriority = 0, - expiredLanes = root.expiredLanes, - suspendedLanes = root.suspendedLanes, - pingedLanes = root.pingedLanes; - if (0 !== expiredLanes) - (nextLanes = expiredLanes), - (nextLanePriority = return_highestLanePriority = 17); - else if (((expiredLanes = pendingLanes & 134217727), 0 !== expiredLanes)) { - var nonIdleUnblockedLanes = expiredLanes & ~suspendedLanes; - 0 !== nonIdleUnblockedLanes - ? ((nextLanes = getHighestPriorityLanes(nonIdleUnblockedLanes)), - (nextLanePriority = return_highestLanePriority)) - : ((pingedLanes &= expiredLanes), - 0 !== pingedLanes && - ((nextLanes = getHighestPriorityLanes(pingedLanes)), - (nextLanePriority = return_highestLanePriority))); - } else - (expiredLanes = pendingLanes & ~suspendedLanes), - 0 !== expiredLanes - ? ((nextLanes = getHighestPriorityLanes(expiredLanes)), - (nextLanePriority = return_highestLanePriority)) - : 0 !== pingedLanes && - ((nextLanes = getHighestPriorityLanes(pingedLanes)), - (nextLanePriority = return_highestLanePriority)); - if (0 === nextLanes) return 0; - nextLanes = 31 - clz32(nextLanes); - nextLanes = pendingLanes & (((0 > nextLanes ? 0 : 1 << nextLanes) << 1) - 1); - if ( - 0 !== wipLanes && - wipLanes !== nextLanes && - 0 === (wipLanes & suspendedLanes) - ) { - getHighestPriorityLanes(wipLanes); - if (nextLanePriority <= return_highestLanePriority) return wipLanes; - return_highestLanePriority = nextLanePriority; - } - wipLanes = root.entangledLanes; - if (0 !== wipLanes) - for (root = root.entanglements, wipLanes &= nextLanes; 0 < wipLanes; ) - (pendingLanes = 31 - clz32(wipLanes)), - (nextLanePriority = 1 << pendingLanes), - (nextLanes |= root[pendingLanes]), - (wipLanes &= ~nextLanePriority); - return nextLanes; -} -function getMostRecentEventTime(root, lanes) { - root = root.eventTimes; - for (var mostRecentEventTime = -1; 0 < lanes; ) { - var index$4 = 31 - clz32(lanes), - lane = 1 << index$4; - index$4 = root[index$4]; - index$4 > mostRecentEventTime && (mostRecentEventTime = index$4); - lanes &= ~lane; - } - return mostRecentEventTime; -} -function getLanesToRetrySynchronouslyOnError(root) { - root = root.pendingLanes & -1073741825; - return 0 !== root ? root : root & 1073741824 ? 1073741824 : 0; -} -function findUpdateLane(lanePriority, wipLanes) { - switch (lanePriority) { - case 17: - return 1; - case 16: - return 2; - case 14: - return ( - (lanePriority = getHighestPriorityLane(24 & ~wipLanes)), - 0 === lanePriority ? findUpdateLane(12, wipLanes) : lanePriority - ); - case 12: - return ( - (lanePriority = getHighestPriorityLane(192 & ~wipLanes)), - 0 === lanePriority ? findUpdateLane(10, wipLanes) : lanePriority - ); - case 10: - return ( - (lanePriority = getHighestPriorityLane(3584 & ~wipLanes)), - 0 === lanePriority && - ((lanePriority = getHighestPriorityLane(4055040 & ~wipLanes)), - 0 === lanePriority && (lanePriority = 512)), - lanePriority - ); - case 2: - return ( - (wipLanes = getHighestPriorityLane(805306368 & ~wipLanes)), - 0 === wipLanes && (wipLanes = 268435456), - wipLanes - ); - } - throw Error( - "Invalid update priority: " + lanePriority + ". This is a bug in React." - ); -} -function getHighestPriorityLane(lanes) { - return lanes & -lanes; -} -function pickArbitraryLane(lanes) { - return lanes & -lanes; -} -function markRootUpdated(root, updateLane, eventTime) { - root.pendingLanes |= updateLane; - var higherPriorityLanes = updateLane - 1; - root.suspendedLanes &= higherPriorityLanes; - root.pingedLanes &= higherPriorityLanes; - root = root.eventTimes; - updateLane = 31 - clz32(updateLane); - root[updateLane] = eventTime; -} -var clz32 = Math.clz32 ? Math.clz32 : clz32Fallback, - log = Math.log, - LN2 = Math.LN2; -function clz32Fallback(lanes) { - return 0 === lanes ? 32 : (31 - ((log(lanes) / LN2) | 0)) | 0; -} var Scheduler_runWithPriority = Scheduler.unstable_runWithPriority, Scheduler_scheduleCallback = Scheduler.unstable_scheduleCallback, Scheduler_cancelCallback = Scheduler.unstable_cancelCallback, - Scheduler_shouldYield = Scheduler.unstable_shouldYield, Scheduler_requestPaint = Scheduler.unstable_requestPaint, - Scheduler_now$1 = Scheduler.unstable_now, + Scheduler_now = Scheduler.unstable_now, Scheduler_getCurrentPriorityLevel = Scheduler.unstable_getCurrentPriorityLevel, Scheduler_ImmediatePriority = Scheduler.unstable_ImmediatePriority, @@ -1965,17 +1682,18 @@ var Scheduler_runWithPriority = Scheduler.unstable_runWithPriority, Scheduler_LowPriority = Scheduler.unstable_LowPriority, Scheduler_IdlePriority = Scheduler.unstable_IdlePriority, fakeCallbackNode = {}, + shouldYield = Scheduler.unstable_shouldYield, requestPaint = void 0 !== Scheduler_requestPaint ? Scheduler_requestPaint : function() {}, syncQueue = null, immediateQueueCallbackNode = null, isFlushingSyncQueue = !1, - initialTimeMs$1 = Scheduler_now$1(), + initialTimeMs = Scheduler_now(), now = - 1e4 > initialTimeMs$1 - ? Scheduler_now$1 + 1e4 > initialTimeMs + ? Scheduler_now : function() { - return Scheduler_now$1() - initialTimeMs$1; + return Scheduler_now() - initialTimeMs; }; function getCurrentPriorityLevel() { switch (Scheduler_getCurrentPriorityLevel()) { @@ -2017,6 +1735,16 @@ function scheduleCallback(reactPriorityLevel, callback, options) { reactPriorityLevel = reactPriorityToSchedulerPriority(reactPriorityLevel); return Scheduler_scheduleCallback(reactPriorityLevel, callback, options); } +function scheduleSyncCallback(callback) { + null === syncQueue + ? ((syncQueue = [callback]), + (immediateQueueCallbackNode = Scheduler_scheduleCallback( + Scheduler_ImmediatePriority, + flushSyncCallbackQueueImpl + ))) + : syncQueue.push(callback); + return fakeCallbackNode; +} function flushSyncCallbackQueue() { if (null !== immediateQueueCallbackNode) { var node = immediateQueueCallbackNode; @@ -2051,30 +1779,6 @@ function flushSyncCallbackQueueImpl() { } } } -function describeFiber(fiber) { - switch (fiber.tag) { - case 5: - return describeComponentFrame(fiber.type, null, null); - case 16: - return describeComponentFrame("Lazy", null, null); - case 13: - return describeComponentFrame("Suspense", null, null); - case 19: - return describeComponentFrame("SuspenseList", null, null); - case 0: - case 2: - case 15: - return describeFunctionComponentFrame(fiber.type, null); - case 11: - return describeFunctionComponentFrame(fiber.type.render, null); - case 22: - return describeFunctionComponentFrame(fiber.type._render, null); - case 1: - return (fiber = describeFunctionComponentFrame(fiber.type, null)), fiber; - default: - return ""; - } -} function is(x, y) { return (x === y && (0 !== x || 1 / x === 1 / y)) || (x !== x && y !== y); } @@ -2100,6 +1804,43 @@ function shallowEqual(objA, objB) { return !1; return !0; } +var BEFORE_SLASH_RE = /^(.*)[\\\/]/; +function getStackByFiberInDevAndProd(workInProgress) { + var info = ""; + do { + a: switch (workInProgress.tag) { + case 3: + case 4: + case 6: + case 7: + case 10: + case 9: + var JSCompiler_inline_result = ""; + break a; + default: + var owner = workInProgress._debugOwner, + source = workInProgress._debugSource, + name = getComponentName(workInProgress.type); + JSCompiler_inline_result = null; + owner && (JSCompiler_inline_result = getComponentName(owner.type)); + owner = name; + name = ""; + source + ? (name = + " (at " + + source.fileName.replace(BEFORE_SLASH_RE, "") + + ":" + + source.lineNumber + + ")") + : JSCompiler_inline_result && + (name = " (created by " + JSCompiler_inline_result + ")"); + JSCompiler_inline_result = "\n in " + (owner || "Unknown") + name; + } + info += JSCompiler_inline_result; + workInProgress = workInProgress.return; + } while (workInProgress); + return info; +} function resolveDefaultProps(Component, baseProps) { if (Component && Component.defaultProps) { baseProps = Object.assign({}, baseProps); @@ -2107,11 +1848,10 @@ function resolveDefaultProps(Component, baseProps) { for (var propName in Component) void 0 === baseProps[propName] && (baseProps[propName] = Component[propName]); - return baseProps; } return baseProps; } -var valueCursor = createCursor(null), +var valueCursor = { current: null }, currentlyRenderingFiber = null, lastContextDependency = null, lastContextWithAllBitsObserved = null; @@ -2123,29 +1863,31 @@ function popProvider(providerFiber) { pop(valueCursor); providerFiber.type._context._currentValue2 = currentValue; } -function scheduleWorkOnParentPath(parent, renderLanes) { +function scheduleWorkOnParentPath(parent, renderExpirationTime) { for (; null !== parent; ) { var alternate = parent.alternate; - if ((parent.childLanes & renderLanes) === renderLanes) - if ( - null === alternate || - (alternate.childLanes & renderLanes) === renderLanes - ) - break; - else alternate.childLanes |= renderLanes; - else - (parent.childLanes |= renderLanes), - null !== alternate && (alternate.childLanes |= renderLanes); + if (parent.childExpirationTime < renderExpirationTime) + (parent.childExpirationTime = renderExpirationTime), + null !== alternate && + alternate.childExpirationTime < renderExpirationTime && + (alternate.childExpirationTime = renderExpirationTime); + else if ( + null !== alternate && + alternate.childExpirationTime < renderExpirationTime + ) + alternate.childExpirationTime = renderExpirationTime; + else break; parent = parent.return; } } -function prepareToReadContext(workInProgress, renderLanes) { +function prepareToReadContext(workInProgress, renderExpirationTime) { currentlyRenderingFiber = workInProgress; lastContextWithAllBitsObserved = lastContextDependency = null; workInProgress = workInProgress.dependencies; null !== workInProgress && null !== workInProgress.firstContext && - (0 !== (workInProgress.lanes & renderLanes) && (didReceiveUpdate = !0), + (workInProgress.expirationTime >= renderExpirationTime && + (didReceiveUpdate = !0), (workInProgress.firstContext = null)); } function readContext(context, observedBits) { @@ -2164,7 +1906,7 @@ function readContext(context, observedBits) { ); lastContextDependency = observedBits; currentlyRenderingFiber.dependencies = { - lanes: 0, + expirationTime: 0, firstContext: observedBits, responders: null }; @@ -2176,8 +1918,7 @@ var hasForceUpdate = !1; function initializeUpdateQueue(fiber) { fiber.updateQueue = { baseState: fiber.memoizedState, - firstBaseUpdate: null, - lastBaseUpdate: null, + baseQueue: null, shared: { pending: null }, effects: null }; @@ -2187,22 +1928,21 @@ function cloneUpdateQueue(current, workInProgress) { workInProgress.updateQueue === current && (workInProgress.updateQueue = { baseState: current.baseState, - firstBaseUpdate: current.firstBaseUpdate, - lastBaseUpdate: current.lastBaseUpdate, + baseQueue: current.baseQueue, shared: current.shared, effects: current.effects }); } -function createUpdate(eventTime, lane, suspenseConfig) { - return { - eventTime: eventTime, - lane: lane, +function createUpdate(expirationTime, suspenseConfig) { + expirationTime = { + expirationTime: expirationTime, suspenseConfig: suspenseConfig, tag: 0, payload: null, callback: null, next: null }; + return (expirationTime.next = expirationTime); } function enqueueUpdate(fiber, update) { fiber = fiber.updateQueue; @@ -2215,185 +1955,132 @@ function enqueueUpdate(fiber, update) { fiber.pending = update; } } -function enqueueCapturedUpdate(workInProgress, capturedUpdate) { - var queue = workInProgress.updateQueue, - current = workInProgress.alternate; - if ( - null !== current && - ((current = current.updateQueue), queue === current) - ) { - var newFirst = null, - newLast = null; - queue = queue.firstBaseUpdate; - if (null !== queue) { - do { - var clone = { - eventTime: queue.eventTime, - lane: queue.lane, - suspenseConfig: queue.suspenseConfig, - tag: queue.tag, - payload: queue.payload, - callback: queue.callback, - next: null - }; - null === newLast - ? (newFirst = newLast = clone) - : (newLast = newLast.next = clone); - queue = queue.next; - } while (null !== queue); - null === newLast - ? (newFirst = newLast = capturedUpdate) - : (newLast = newLast.next = capturedUpdate); - } else newFirst = newLast = capturedUpdate; - queue = { - baseState: current.baseState, - firstBaseUpdate: newFirst, - lastBaseUpdate: newLast, - shared: current.shared, - effects: current.effects - }; - workInProgress.updateQueue = queue; - return; - } - workInProgress = queue.lastBaseUpdate; - null === workInProgress - ? (queue.firstBaseUpdate = capturedUpdate) - : (workInProgress.next = capturedUpdate); - queue.lastBaseUpdate = capturedUpdate; +function enqueueCapturedUpdate(workInProgress, update) { + var current = workInProgress.alternate; + null !== current && cloneUpdateQueue(current, workInProgress); + workInProgress = workInProgress.updateQueue; + current = workInProgress.baseQueue; + null === current + ? ((workInProgress.baseQueue = update.next = update), + (update.next = update)) + : ((update.next = current.next), (current.next = update)); } function processUpdateQueue( workInProgress$jscomp$0, props, instance, - renderLanes + renderExpirationTime ) { var queue = workInProgress$jscomp$0.updateQueue; hasForceUpdate = !1; - var firstBaseUpdate = queue.firstBaseUpdate, - lastBaseUpdate = queue.lastBaseUpdate, + var baseQueue = queue.baseQueue, pendingQueue = queue.shared.pending; if (null !== pendingQueue) { - queue.shared.pending = null; - var lastPendingUpdate = pendingQueue, - firstPendingUpdate = lastPendingUpdate.next; - lastPendingUpdate.next = null; - null === lastBaseUpdate - ? (firstBaseUpdate = firstPendingUpdate) - : (lastBaseUpdate.next = firstPendingUpdate); - lastBaseUpdate = lastPendingUpdate; - var current = workInProgress$jscomp$0.alternate; - if (null !== current) { - current = current.updateQueue; - var currentLastBaseUpdate = current.lastBaseUpdate; - currentLastBaseUpdate !== lastBaseUpdate && - (null === currentLastBaseUpdate - ? (current.firstBaseUpdate = firstPendingUpdate) - : (currentLastBaseUpdate.next = firstPendingUpdate), - (current.lastBaseUpdate = lastPendingUpdate)); + if (null !== baseQueue) { + var baseFirst = baseQueue.next; + baseQueue.next = pendingQueue.next; + pendingQueue.next = baseFirst; } + baseQueue = pendingQueue; + queue.shared.pending = null; + baseFirst = workInProgress$jscomp$0.alternate; + null !== baseFirst && + ((baseFirst = baseFirst.updateQueue), + null !== baseFirst && (baseFirst.baseQueue = pendingQueue)); } - if (null !== firstBaseUpdate) { - currentLastBaseUpdate = queue.baseState; - lastBaseUpdate = 0; - current = firstPendingUpdate = lastPendingUpdate = null; - do { - pendingQueue = firstBaseUpdate.lane; - var updateEventTime = firstBaseUpdate.eventTime; - if ((renderLanes & pendingQueue) === pendingQueue) { - null !== current && - (current = current.next = { - eventTime: updateEventTime, - lane: 0, - suspenseConfig: firstBaseUpdate.suspenseConfig, - tag: firstBaseUpdate.tag, - payload: firstBaseUpdate.payload, - callback: firstBaseUpdate.callback, + if (null !== baseQueue) { + baseFirst = baseQueue.next; + var newState = queue.baseState, + newExpirationTime = 0, + newBaseState = null, + newBaseQueueFirst = null, + newBaseQueueLast = null; + if (null !== baseFirst) { + var update = baseFirst; + do { + pendingQueue = update.expirationTime; + if (pendingQueue < renderExpirationTime) { + var clone = { + expirationTime: update.expirationTime, + suspenseConfig: update.suspenseConfig, + tag: update.tag, + payload: update.payload, + callback: update.callback, next: null - }); - markRenderEventTimeAndConfig( - updateEventTime, - firstBaseUpdate.suspenseConfig - ); - a: { - var workInProgress = workInProgress$jscomp$0, - update = firstBaseUpdate; - pendingQueue = props; - updateEventTime = instance; - switch (update.tag) { - case 1: - workInProgress = update.payload; - if ("function" === typeof workInProgress) { - currentLastBaseUpdate = workInProgress.call( - updateEventTime, - currentLastBaseUpdate, - pendingQueue - ); + }; + null === newBaseQueueLast + ? ((newBaseQueueFirst = newBaseQueueLast = clone), + (newBaseState = newState)) + : (newBaseQueueLast = newBaseQueueLast.next = clone); + pendingQueue > newExpirationTime && + (newExpirationTime = pendingQueue); + } else { + null !== newBaseQueueLast && + (newBaseQueueLast = newBaseQueueLast.next = { + expirationTime: 1073741823, + suspenseConfig: update.suspenseConfig, + tag: update.tag, + payload: update.payload, + callback: update.callback, + next: null + }); + markRenderEventTimeAndConfig(pendingQueue, update.suspenseConfig); + a: { + var workInProgress = workInProgress$jscomp$0, + update$jscomp$0 = update; + pendingQueue = props; + clone = instance; + switch (update$jscomp$0.tag) { + case 1: + workInProgress = update$jscomp$0.payload; + if ("function" === typeof workInProgress) { + newState = workInProgress.call(clone, newState, pendingQueue); + break a; + } + newState = workInProgress; break a; - } - currentLastBaseUpdate = workInProgress; - break a; - case 3: - workInProgress.effectTag = - (workInProgress.effectTag & -4097) | 64; - case 0: - workInProgress = update.payload; - pendingQueue = - "function" === typeof workInProgress - ? workInProgress.call( - updateEventTime, - currentLastBaseUpdate, - pendingQueue - ) - : workInProgress; - if (null === pendingQueue || void 0 === pendingQueue) break a; - currentLastBaseUpdate = Object.assign( - {}, - currentLastBaseUpdate, - pendingQueue - ); - break a; - case 2: - hasForceUpdate = !0; + case 3: + workInProgress.effectTag = + (workInProgress.effectTag & -4097) | 64; + case 0: + workInProgress = update$jscomp$0.payload; + pendingQueue = + "function" === typeof workInProgress + ? workInProgress.call(clone, newState, pendingQueue) + : workInProgress; + if (null === pendingQueue || void 0 === pendingQueue) break a; + newState = Object.assign({}, newState, pendingQueue); + break a; + case 2: + hasForceUpdate = !0; + } } + null !== update.callback && + ((workInProgress$jscomp$0.effectTag |= 32), + (pendingQueue = queue.effects), + null === pendingQueue + ? (queue.effects = [update]) + : pendingQueue.push(update)); } - null !== firstBaseUpdate.callback && - ((workInProgress$jscomp$0.effectTag |= 32), - (pendingQueue = queue.effects), - null === pendingQueue - ? (queue.effects = [firstBaseUpdate]) - : pendingQueue.push(firstBaseUpdate)); - } else - (updateEventTime = { - eventTime: updateEventTime, - lane: pendingQueue, - suspenseConfig: firstBaseUpdate.suspenseConfig, - tag: firstBaseUpdate.tag, - payload: firstBaseUpdate.payload, - callback: firstBaseUpdate.callback, - next: null - }), - null === current - ? ((firstPendingUpdate = current = updateEventTime), - (lastPendingUpdate = currentLastBaseUpdate)) - : (current = current.next = updateEventTime), - (lastBaseUpdate |= pendingQueue); - firstBaseUpdate = firstBaseUpdate.next; - if (null === firstBaseUpdate) - if (((pendingQueue = queue.shared.pending), null === pendingQueue)) - break; - else - (firstBaseUpdate = pendingQueue.next), - (pendingQueue.next = null), - (queue.lastBaseUpdate = pendingQueue), - (queue.shared.pending = null); - } while (1); - null === current && (lastPendingUpdate = currentLastBaseUpdate); - queue.baseState = lastPendingUpdate; - queue.firstBaseUpdate = firstPendingUpdate; - queue.lastBaseUpdate = current; - workInProgressRootSkippedLanes |= lastBaseUpdate; - workInProgress$jscomp$0.lanes = lastBaseUpdate; - workInProgress$jscomp$0.memoizedState = currentLastBaseUpdate; + update = update.next; + if (null === update || update === baseFirst) + if (((pendingQueue = queue.shared.pending), null === pendingQueue)) + break; + else + (update = baseQueue.next = pendingQueue.next), + (pendingQueue.next = baseFirst), + (queue.baseQueue = baseQueue = pendingQueue), + (queue.shared.pending = null); + } while (1); + } + null === newBaseQueueLast + ? (newBaseState = newState) + : (newBaseQueueLast.next = newBaseQueueFirst); + queue.baseState = newBaseState; + queue.baseQueue = newBaseQueueLast; + markUnprocessedUpdateTime(newExpirationTime); + workInProgress$jscomp$0.expirationTime = newExpirationTime; + workInProgress$jscomp$0.memoizedState = newState; } } function commitUpdateQueue(finishedWork, finishedQueue, instance) { @@ -2433,54 +2120,54 @@ function applyDerivedStateFromProps( ? ctor : Object.assign({}, ctor, getDerivedStateFromProps); workInProgress.memoizedState = getDerivedStateFromProps; - 0 === workInProgress.lanes && + 0 === workInProgress.expirationTime && (workInProgress.updateQueue.baseState = getDerivedStateFromProps); } var classComponentUpdater = { isMounted: function(component) { - return (component = component._reactInternals) + return (component = component._reactInternalFiber) ? getNearestMountedFiber(component) === component : !1; }, enqueueSetState: function(inst, payload, callback) { - inst = inst._reactInternals; - var eventTime = requestEventTime(), - suspenseConfig = ReactCurrentBatchConfig.suspense, - lane = requestUpdateLane(inst, suspenseConfig); - suspenseConfig = createUpdate(eventTime, lane, suspenseConfig); + inst = inst._reactInternalFiber; + var currentTime = requestCurrentTimeForUpdate(), + suspenseConfig = ReactCurrentBatchConfig.suspense; + currentTime = computeExpirationForFiber(currentTime, inst, suspenseConfig); + suspenseConfig = createUpdate(currentTime, suspenseConfig); suspenseConfig.payload = payload; void 0 !== callback && null !== callback && (suspenseConfig.callback = callback); enqueueUpdate(inst, suspenseConfig); - scheduleUpdateOnFiber(inst, lane, eventTime); + scheduleWork(inst, currentTime); }, enqueueReplaceState: function(inst, payload, callback) { - inst = inst._reactInternals; - var eventTime = requestEventTime(), - suspenseConfig = ReactCurrentBatchConfig.suspense, - lane = requestUpdateLane(inst, suspenseConfig); - suspenseConfig = createUpdate(eventTime, lane, suspenseConfig); + inst = inst._reactInternalFiber; + var currentTime = requestCurrentTimeForUpdate(), + suspenseConfig = ReactCurrentBatchConfig.suspense; + currentTime = computeExpirationForFiber(currentTime, inst, suspenseConfig); + suspenseConfig = createUpdate(currentTime, suspenseConfig); suspenseConfig.tag = 1; suspenseConfig.payload = payload; void 0 !== callback && null !== callback && (suspenseConfig.callback = callback); enqueueUpdate(inst, suspenseConfig); - scheduleUpdateOnFiber(inst, lane, eventTime); + scheduleWork(inst, currentTime); }, enqueueForceUpdate: function(inst, callback) { - inst = inst._reactInternals; - var eventTime = requestEventTime(), - suspenseConfig = ReactCurrentBatchConfig.suspense, - lane = requestUpdateLane(inst, suspenseConfig); - suspenseConfig = createUpdate(eventTime, lane, suspenseConfig); + inst = inst._reactInternalFiber; + var currentTime = requestCurrentTimeForUpdate(), + suspenseConfig = ReactCurrentBatchConfig.suspense; + currentTime = computeExpirationForFiber(currentTime, inst, suspenseConfig); + suspenseConfig = createUpdate(currentTime, suspenseConfig); suspenseConfig.tag = 2; void 0 !== callback && null !== callback && (suspenseConfig.callback = callback); enqueueUpdate(inst, suspenseConfig); - scheduleUpdateOnFiber(inst, lane, eventTime); + scheduleWork(inst, currentTime); } }; function checkShouldComponentUpdate( @@ -2518,7 +2205,7 @@ function constructClassInstance(workInProgress, ctor, props) { null !== ctor.state && void 0 !== ctor.state ? ctor.state : null; ctor.updater = classComponentUpdater; workInProgress.stateNode = ctor; - ctor._reactInternals = workInProgress; + ctor._reactInternalFiber = workInProgress; isLegacyContextConsumer && ((workInProgress = workInProgress.stateNode), (workInProgress.__reactInternalMemoizedUnmaskedChildContext = unmaskedContext), @@ -2539,7 +2226,12 @@ function callComponentWillReceiveProps( instance.state !== workInProgress && classComponentUpdater.enqueueReplaceState(instance, instance.state, null); } -function mountClassInstance(workInProgress, ctor, newProps, renderLanes) { +function mountClassInstance( + workInProgress, + ctor, + newProps, + renderExpirationTime +) { var instance = workInProgress.stateNode; instance.props = newProps; instance.state = workInProgress.memoizedState; @@ -2552,7 +2244,7 @@ function mountClassInstance(workInProgress, ctor, newProps, renderLanes) { ? previousContext : contextStackCursor.current), (instance.context = getMaskedContext(workInProgress, contextType))); - processUpdateQueue(workInProgress, newProps, instance, renderLanes); + processUpdateQueue(workInProgress, newProps, instance, renderExpirationTime); instance.state = workInProgress.memoizedState; contextType = ctor.getDerivedStateFromProps; "function" === typeof contextType && @@ -2569,7 +2261,12 @@ function mountClassInstance(workInProgress, ctor, newProps, renderLanes) { instance.UNSAFE_componentWillMount(), ctor !== instance.state && classComponentUpdater.enqueueReplaceState(instance, instance.state, null), - processUpdateQueue(workInProgress, newProps, instance, renderLanes), + processUpdateQueue( + workInProgress, + newProps, + instance, + renderExpirationTime + ), (instance.state = workInProgress.memoizedState)); "function" === typeof instance.componentDidMount && (workInProgress.effectTag |= 4); @@ -2633,7 +2330,7 @@ function throwOnInvalidObjectType(returnFiber, newChild) { ("[object Object]" === Object.prototype.toString.call(newChild) ? "object with keys {" + Object.keys(newChild).join(", ") + "}" : newChild) + - "). If you meant to render a collection of children, use an array instead." + ")." ); } function ChildReconciler(shouldTrackSideEffects) { @@ -2689,10 +2386,14 @@ function ChildReconciler(shouldTrackSideEffects) { (newFiber.effectTag = 2); return newFiber; } - function updateTextNode(returnFiber, current, textContent, lanes) { + function updateTextNode(returnFiber, current, textContent, expirationTime) { if (null === current || 6 !== current.tag) return ( - (current = createFiberFromText(textContent, returnFiber.mode, lanes)), + (current = createFiberFromText( + textContent, + returnFiber.mode, + expirationTime + )), (current.return = returnFiber), current ); @@ -2700,27 +2401,27 @@ function ChildReconciler(shouldTrackSideEffects) { current.return = returnFiber; return current; } - function updateElement(returnFiber, current, element, lanes) { + function updateElement(returnFiber, current, element, expirationTime) { if (null !== current && current.elementType === element.type) return ( - (lanes = useFiber(current, element.props)), - (lanes.ref = coerceRef(returnFiber, current, element)), - (lanes.return = returnFiber), - lanes + (expirationTime = useFiber(current, element.props)), + (expirationTime.ref = coerceRef(returnFiber, current, element)), + (expirationTime.return = returnFiber), + expirationTime ); - lanes = createFiberFromTypeAndProps( + expirationTime = createFiberFromTypeAndProps( element.type, element.key, element.props, null, returnFiber.mode, - lanes + expirationTime ); - lanes.ref = coerceRef(returnFiber, current, element); - lanes.return = returnFiber; - return lanes; + expirationTime.ref = coerceRef(returnFiber, current, element); + expirationTime.return = returnFiber; + return expirationTime; } - function updatePortal(returnFiber, current, portal, lanes) { + function updatePortal(returnFiber, current, portal, expirationTime) { if ( null === current || 4 !== current.tag || @@ -2728,7 +2429,11 @@ function ChildReconciler(shouldTrackSideEffects) { current.stateNode.implementation !== portal.implementation ) return ( - (current = createFiberFromPortal(portal, returnFiber.mode, lanes)), + (current = createFiberFromPortal( + portal, + returnFiber.mode, + expirationTime + )), (current.return = returnFiber), current ); @@ -2736,13 +2441,13 @@ function ChildReconciler(shouldTrackSideEffects) { current.return = returnFiber; return current; } - function updateFragment(returnFiber, current, fragment, lanes, key) { + function updateFragment(returnFiber, current, fragment, expirationTime, key) { if (null === current || 7 !== current.tag) return ( (current = createFiberFromFragment( fragment, returnFiber.mode, - lanes, + expirationTime, key )), (current.return = returnFiber), @@ -2752,13 +2457,13 @@ function ChildReconciler(shouldTrackSideEffects) { current.return = returnFiber; return current; } - function createChild(returnFiber, newChild, lanes) { + function createChild(returnFiber, newChild, expirationTime) { if ("string" === typeof newChild || "number" === typeof newChild) return ( (newChild = createFiberFromText( "" + newChild, returnFiber.mode, - lanes + expirationTime )), (newChild.return = returnFiber), newChild @@ -2767,24 +2472,24 @@ function ChildReconciler(shouldTrackSideEffects) { switch (newChild.$$typeof) { case REACT_ELEMENT_TYPE: return ( - (lanes = createFiberFromTypeAndProps( + (expirationTime = createFiberFromTypeAndProps( newChild.type, newChild.key, newChild.props, null, returnFiber.mode, - lanes + expirationTime )), - (lanes.ref = coerceRef(returnFiber, null, newChild)), - (lanes.return = returnFiber), - lanes + (expirationTime.ref = coerceRef(returnFiber, null, newChild)), + (expirationTime.return = returnFiber), + expirationTime ); case REACT_PORTAL_TYPE: return ( (newChild = createFiberFromPortal( newChild, returnFiber.mode, - lanes + expirationTime )), (newChild.return = returnFiber), newChild @@ -2795,7 +2500,7 @@ function ChildReconciler(shouldTrackSideEffects) { (newChild = createFiberFromFragment( newChild, returnFiber.mode, - lanes, + expirationTime, null )), (newChild.return = returnFiber), @@ -2805,12 +2510,12 @@ function ChildReconciler(shouldTrackSideEffects) { } return null; } - function updateSlot(returnFiber, oldFiber, newChild, lanes) { + function updateSlot(returnFiber, oldFiber, newChild, expirationTime) { var key = null !== oldFiber ? oldFiber.key : null; if ("string" === typeof newChild || "number" === typeof newChild) return null !== key ? null - : updateTextNode(returnFiber, oldFiber, "" + newChild, lanes); + : updateTextNode(returnFiber, oldFiber, "" + newChild, expirationTime); if ("object" === typeof newChild && null !== newChild) { switch (newChild.$$typeof) { case REACT_ELEMENT_TYPE: @@ -2820,20 +2525,26 @@ function ChildReconciler(shouldTrackSideEffects) { returnFiber, oldFiber, newChild.props.children, - lanes, + expirationTime, key ) - : updateElement(returnFiber, oldFiber, newChild, lanes) + : updateElement(returnFiber, oldFiber, newChild, expirationTime) : null; case REACT_PORTAL_TYPE: return newChild.key === key - ? updatePortal(returnFiber, oldFiber, newChild, lanes) + ? updatePortal(returnFiber, oldFiber, newChild, expirationTime) : null; } if (isArray(newChild) || getIteratorFn(newChild)) return null !== key ? null - : updateFragment(returnFiber, oldFiber, newChild, lanes, null); + : updateFragment( + returnFiber, + oldFiber, + newChild, + expirationTime, + null + ); throwOnInvalidObjectType(returnFiber, newChild); } return null; @@ -2843,12 +2554,17 @@ function ChildReconciler(shouldTrackSideEffects) { returnFiber, newIdx, newChild, - lanes + expirationTime ) { if ("string" === typeof newChild || "number" === typeof newChild) return ( (existingChildren = existingChildren.get(newIdx) || null), - updateTextNode(returnFiber, existingChildren, "" + newChild, lanes) + updateTextNode( + returnFiber, + existingChildren, + "" + newChild, + expirationTime + ) ); if ("object" === typeof newChild && null !== newChild) { switch (newChild.$$typeof) { @@ -2863,10 +2579,15 @@ function ChildReconciler(shouldTrackSideEffects) { returnFiber, existingChildren, newChild.props.children, - lanes, + expirationTime, newChild.key ) - : updateElement(returnFiber, existingChildren, newChild, lanes) + : updateElement( + returnFiber, + existingChildren, + newChild, + expirationTime + ) ); case REACT_PORTAL_TYPE: return ( @@ -2874,13 +2595,24 @@ function ChildReconciler(shouldTrackSideEffects) { existingChildren.get( null === newChild.key ? newIdx : newChild.key ) || null), - updatePortal(returnFiber, existingChildren, newChild, lanes) + updatePortal( + returnFiber, + existingChildren, + newChild, + expirationTime + ) ); } if (isArray(newChild) || getIteratorFn(newChild)) return ( (existingChildren = existingChildren.get(newIdx) || null), - updateFragment(returnFiber, existingChildren, newChild, lanes, null) + updateFragment( + returnFiber, + existingChildren, + newChild, + expirationTime, + null + ) ); throwOnInvalidObjectType(returnFiber, newChild); } @@ -2890,7 +2622,7 @@ function ChildReconciler(shouldTrackSideEffects) { returnFiber, currentFirstChild, newChildren, - lanes + expirationTime ) { for ( var resultingFirstChild = null, @@ -2908,7 +2640,7 @@ function ChildReconciler(shouldTrackSideEffects) { returnFiber, oldFiber, newChildren[newIdx], - lanes + expirationTime ); if (null === newFiber) { null === oldFiber && (oldFiber = nextOldFiber); @@ -2931,7 +2663,11 @@ function ChildReconciler(shouldTrackSideEffects) { ); if (null === oldFiber) { for (; newIdx < newChildren.length; newIdx++) - (oldFiber = createChild(returnFiber, newChildren[newIdx], lanes)), + (oldFiber = createChild( + returnFiber, + newChildren[newIdx], + expirationTime + )), null !== oldFiber && ((currentFirstChild = placeChild( oldFiber, @@ -2954,7 +2690,7 @@ function ChildReconciler(shouldTrackSideEffects) { returnFiber, newIdx, newChildren[newIdx], - lanes + expirationTime )), null !== nextOldFiber && (shouldTrackSideEffects && @@ -2981,7 +2717,7 @@ function ChildReconciler(shouldTrackSideEffects) { returnFiber, currentFirstChild, newChildrenIterable, - lanes + expirationTime ) { var iteratorFn = getIteratorFn(newChildrenIterable); if ("function" !== typeof iteratorFn) @@ -3003,7 +2739,12 @@ function ChildReconciler(shouldTrackSideEffects) { oldFiber.index > newIdx ? ((nextOldFiber = oldFiber), (oldFiber = null)) : (nextOldFiber = oldFiber.sibling); - var newFiber = updateSlot(returnFiber, oldFiber, step.value, lanes); + var newFiber = updateSlot( + returnFiber, + oldFiber, + step.value, + expirationTime + ); if (null === newFiber) { null === oldFiber && (oldFiber = nextOldFiber); break; @@ -3023,7 +2764,7 @@ function ChildReconciler(shouldTrackSideEffects) { return deleteRemainingChildren(returnFiber, oldFiber), iteratorFn; if (null === oldFiber) { for (; !step.done; newIdx++, step = newChildrenIterable.next()) - (step = createChild(returnFiber, step.value, lanes)), + (step = createChild(returnFiber, step.value, expirationTime)), null !== step && ((currentFirstChild = placeChild(step, currentFirstChild, newIdx)), null === previousNewFiber @@ -3037,7 +2778,13 @@ function ChildReconciler(shouldTrackSideEffects) { !step.done; newIdx++, step = newChildrenIterable.next() ) - (step = updateFromMap(oldFiber, returnFiber, newIdx, step.value, lanes)), + (step = updateFromMap( + oldFiber, + returnFiber, + newIdx, + step.value, + expirationTime + )), null !== step && (shouldTrackSideEffects && null !== step.alternate && @@ -3053,7 +2800,7 @@ function ChildReconciler(shouldTrackSideEffects) { }); return iteratorFn; } - return function(returnFiber, currentFirstChild, newChild, lanes) { + return function(returnFiber, currentFirstChild, newChild, expirationTime) { var isUnkeyedTopLevelFragment = "object" === typeof newChild && null !== newChild && @@ -3119,26 +2866,26 @@ function ChildReconciler(shouldTrackSideEffects) { ? ((currentFirstChild = createFiberFromFragment( newChild.props.children, returnFiber.mode, - lanes, + expirationTime, newChild.key )), (currentFirstChild.return = returnFiber), (returnFiber = currentFirstChild)) - : ((lanes = createFiberFromTypeAndProps( + : ((expirationTime = createFiberFromTypeAndProps( newChild.type, newChild.key, newChild.props, null, returnFiber.mode, - lanes + expirationTime )), - (lanes.ref = coerceRef( + (expirationTime.ref = coerceRef( returnFiber, currentFirstChild, newChild )), - (lanes.return = returnFiber), - (returnFiber = lanes)); + (expirationTime.return = returnFiber), + (returnFiber = expirationTime)); } return placeSingleChild(returnFiber); case REACT_PORTAL_TYPE: @@ -3177,7 +2924,7 @@ function ChildReconciler(shouldTrackSideEffects) { currentFirstChild = createFiberFromPortal( newChild, returnFiber.mode, - lanes + expirationTime ); currentFirstChild.return = returnFiber; returnFiber = currentFirstChild; @@ -3196,7 +2943,7 @@ function ChildReconciler(shouldTrackSideEffects) { (currentFirstChild = createFiberFromText( newChild, returnFiber.mode, - lanes + expirationTime )), (currentFirstChild.return = returnFiber), (returnFiber = currentFirstChild)), @@ -3207,14 +2954,14 @@ function ChildReconciler(shouldTrackSideEffects) { returnFiber, currentFirstChild, newChild, - lanes + expirationTime ); if (getIteratorFn(newChild)) return reconcileChildrenIterator( returnFiber, currentFirstChild, newChild, - lanes + expirationTime ); isObject && throwOnInvalidObjectType(returnFiber, newChild); if ("undefined" === typeof newChild && !isUnkeyedTopLevelFragment) @@ -3233,9 +2980,9 @@ function ChildReconciler(shouldTrackSideEffects) { var reconcileChildFibers = ChildReconciler(!0), mountChildFibers = ChildReconciler(!1), NO_CONTEXT = {}, - contextStackCursor$1 = createCursor(NO_CONTEXT), - contextFiberStackCursor = createCursor(NO_CONTEXT), - rootInstanceStackCursor = createCursor(NO_CONTEXT); + contextStackCursor$1 = { current: NO_CONTEXT }, + contextFiberStackCursor = { current: NO_CONTEXT }, + rootInstanceStackCursor = { current: NO_CONTEXT }; function requiredContext(c) { if (c === NO_CONTEXT) throw Error( @@ -3258,26 +3005,26 @@ function popHostContainer() { function pushHostContext(fiber) { requiredContext(rootInstanceStackCursor.current); var context = requiredContext(contextStackCursor$1.current); - var JSCompiler_inline_result = fiber.type; - JSCompiler_inline_result = - "AndroidTextInput" === JSCompiler_inline_result || - "RCTMultilineTextInputView" === JSCompiler_inline_result || - "RCTSinglelineTextInputView" === JSCompiler_inline_result || - "RCTText" === JSCompiler_inline_result || - "RCTVirtualText" === JSCompiler_inline_result; - JSCompiler_inline_result = - context.isInAParentText !== JSCompiler_inline_result - ? { isInAParentText: JSCompiler_inline_result } + var nextContext = fiber.type; + nextContext = + "AndroidTextInput" === nextContext || + "RCTMultilineTextInputView" === nextContext || + "RCTSinglelineTextInputView" === nextContext || + "RCTText" === nextContext || + "RCTVirtualText" === nextContext; + nextContext = + context.isInAParentText !== nextContext + ? { isInAParentText: nextContext } : context; - context !== JSCompiler_inline_result && + context !== nextContext && (push(contextFiberStackCursor, fiber), - push(contextStackCursor$1, JSCompiler_inline_result)); + push(contextStackCursor$1, nextContext)); } function popHostContext(fiber) { contextFiberStackCursor.current === fiber && (pop(contextStackCursor$1), pop(contextFiberStackCursor)); } -var suspenseStackCursor = createCursor(0); +var suspenseStackCursor = { current: 0 }; function findFirstSuspended(row) { for (var node = row; null !== node; ) { if (13 === node.tag) { @@ -3304,20 +3051,13 @@ function findFirstSuspended(row) { function createDeprecatedResponderListener(responder, props) { return { responder: responder, props: props }; } -var workInProgressSources = []; -function resetWorkInProgressVersions() { - for (var i = 0; i < workInProgressSources.length; i++) - workInProgressSources[i]._workInProgressVersionSecondary = null; - workInProgressSources.length = 0; -} -var ReactCurrentDispatcher$1 = ReactSharedInternals.ReactCurrentDispatcher, +var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher, ReactCurrentBatchConfig$1 = ReactSharedInternals.ReactCurrentBatchConfig, - renderLanes = 0, + renderExpirationTime = 0, currentlyRenderingFiber$1 = null, currentHook = null, workInProgressHook = null, - didScheduleRenderPhaseUpdate = !1, - didScheduleRenderPhaseUpdateDuringThisPass = !1; + didScheduleRenderPhaseUpdate = !1; function throwInvalidHookError() { throw Error( "Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:\n1. You might have mismatching versions of React and the renderer (such as React DOM)\n2. You might be breaking the Rules of Hooks\n3. You might have more than one copy of React in the same app\nSee https://fb.me/react-invalid-hook-call for tips about how to debug and fix this problem." @@ -3335,36 +3075,36 @@ function renderWithHooks( Component, props, secondArg, - nextRenderLanes + nextRenderExpirationTime ) { - renderLanes = nextRenderLanes; + renderExpirationTime = nextRenderExpirationTime; currentlyRenderingFiber$1 = workInProgress; workInProgress.memoizedState = null; workInProgress.updateQueue = null; - workInProgress.lanes = 0; - ReactCurrentDispatcher$1.current = + workInProgress.expirationTime = 0; + ReactCurrentDispatcher.current = null === current || null === current.memoizedState ? HooksDispatcherOnMount : HooksDispatcherOnUpdate; current = Component(props, secondArg); - if (didScheduleRenderPhaseUpdateDuringThisPass) { - nextRenderLanes = 0; + if (workInProgress.expirationTime === renderExpirationTime) { + nextRenderExpirationTime = 0; do { - didScheduleRenderPhaseUpdateDuringThisPass = !1; - if (!(25 > nextRenderLanes)) + workInProgress.expirationTime = 0; + if (!(25 > nextRenderExpirationTime)) throw Error( "Too many re-renders. React limits the number of renders to prevent an infinite loop." ); - nextRenderLanes += 1; + nextRenderExpirationTime += 1; workInProgressHook = currentHook = null; workInProgress.updateQueue = null; - ReactCurrentDispatcher$1.current = HooksDispatcherOnRerender; + ReactCurrentDispatcher.current = HooksDispatcherOnRerender; current = Component(props, secondArg); - } while (didScheduleRenderPhaseUpdateDuringThisPass); + } while (workInProgress.expirationTime === renderExpirationTime); } - ReactCurrentDispatcher$1.current = ContextOnlyDispatcher; + ReactCurrentDispatcher.current = ContextOnlyDispatcher; workInProgress = null !== currentHook && null !== currentHook.next; - renderLanes = 0; + renderExpirationTime = 0; workInProgressHook = currentHook = currentlyRenderingFiber$1 = null; didScheduleRenderPhaseUpdate = !1; if (workInProgress) @@ -3445,40 +3185,40 @@ function updateReducer(reducer) { var newBaseQueueLast = (baseFirst = pendingQueue = null), update = baseQueue; do { - var suspenseConfig = update.suspenseConfig, - updateLane = update.lane, - updateEventTime = update.eventTime; - (renderLanes & updateLane) === updateLane - ? (null !== newBaseQueueLast && - (newBaseQueueLast = newBaseQueueLast.next = { - eventTime: updateEventTime, - lane: 0, - suspenseConfig: update.suspenseConfig, - action: update.action, - eagerReducer: update.eagerReducer, - eagerState: update.eagerState, - next: null - }), - markRenderEventTimeAndConfig(updateEventTime, suspenseConfig), - (current = - update.eagerReducer === reducer - ? update.eagerState - : reducer(current, update.action))) - : ((suspenseConfig = { - eventTime: updateEventTime, - lane: updateLane, - suspenseConfig: suspenseConfig, + var updateExpirationTime = update.expirationTime; + if (updateExpirationTime < renderExpirationTime) { + var clone = { + expirationTime: update.expirationTime, + suspenseConfig: update.suspenseConfig, + action: update.action, + eagerReducer: update.eagerReducer, + eagerState: update.eagerState, + next: null + }; + null === newBaseQueueLast + ? ((baseFirst = newBaseQueueLast = clone), (pendingQueue = current)) + : (newBaseQueueLast = newBaseQueueLast.next = clone); + updateExpirationTime > currentlyRenderingFiber$1.expirationTime && + ((currentlyRenderingFiber$1.expirationTime = updateExpirationTime), + markUnprocessedUpdateTime(updateExpirationTime)); + } else + null !== newBaseQueueLast && + (newBaseQueueLast = newBaseQueueLast.next = { + expirationTime: 1073741823, + suspenseConfig: update.suspenseConfig, action: update.action, eagerReducer: update.eagerReducer, eagerState: update.eagerState, next: null }), - null === newBaseQueueLast - ? ((baseFirst = newBaseQueueLast = suspenseConfig), - (pendingQueue = current)) - : (newBaseQueueLast = newBaseQueueLast.next = suspenseConfig), - (currentlyRenderingFiber$1.lanes |= updateLane), - (workInProgressRootSkippedLanes |= updateLane)); + markRenderEventTimeAndConfig( + updateExpirationTime, + update.suspenseConfig + ), + (current = + update.eagerReducer === reducer + ? update.eagerState + : reducer(current, update.action)); update = update.next; } while (null !== update && update !== baseQueue); null === newBaseQueueLast @@ -3515,117 +3255,6 @@ function rerenderReducer(reducer) { } return [newState, dispatch]; } -function readFromUnsubcribedMutableSource(root, source, getSnapshot) { - var getVersion = source._getVersion; - getVersion = getVersion(source._source); - var JSCompiler_inline_result = source._workInProgressVersionSecondary; - if (null !== JSCompiler_inline_result) - root = JSCompiler_inline_result === getVersion; - else if ( - ((root = root.mutableReadLanes), (root = (renderLanes & root) === root)) - ) - (source._workInProgressVersionSecondary = getVersion), - workInProgressSources.push(source); - if (root) return getSnapshot(source._source); - workInProgressSources.push(source); - throw Error( - "Cannot read from mutable source during the current render without tearing. This is a bug in React. Please file an issue." - ); -} -function useMutableSource(hook, source, getSnapshot, subscribe) { - var root = workInProgressRoot; - if (null === root) - throw Error( - "Expected a work-in-progress root. This is a bug in React. Please file an issue." - ); - var getVersion = source._getVersion, - version = getVersion(source._source), - dispatcher = ReactCurrentDispatcher$1.current, - _dispatcher$useState = dispatcher.useState(function() { - return readFromUnsubcribedMutableSource(root, source, getSnapshot); - }), - setSnapshot = _dispatcher$useState[1], - snapshot = _dispatcher$useState[0]; - _dispatcher$useState = workInProgressHook; - var memoizedState = hook.memoizedState, - refs = memoizedState.refs, - prevGetSnapshot = refs.getSnapshot, - prevSource = memoizedState.source; - memoizedState = memoizedState.subscribe; - var fiber = currentlyRenderingFiber$1; - hook.memoizedState = { refs: refs, source: source, subscribe: subscribe }; - dispatcher.useEffect( - function() { - refs.getSnapshot = getSnapshot; - refs.setSnapshot = setSnapshot; - var maybeNewVersion = getVersion(source._source); - if (!objectIs(version, maybeNewVersion)) { - maybeNewVersion = getSnapshot(source._source); - objectIs(snapshot, maybeNewVersion) || - (setSnapshot(maybeNewVersion), - (maybeNewVersion = requestUpdateLane( - fiber, - ReactCurrentBatchConfig.suspense - )), - (root.mutableReadLanes |= maybeNewVersion & root.pendingLanes)); - maybeNewVersion = root.mutableReadLanes; - root.entangledLanes |= maybeNewVersion; - for ( - var entanglements = root.entanglements, lanes = maybeNewVersion; - 0 < lanes; - - ) { - var index$12 = 31 - clz32(lanes), - lane = 1 << index$12; - entanglements[index$12] |= maybeNewVersion; - lanes &= ~lane; - } - } - }, - [getSnapshot, source, subscribe] - ); - dispatcher.useEffect( - function() { - return subscribe(source._source, function() { - var latestGetSnapshot = refs.getSnapshot, - latestSetSnapshot = refs.setSnapshot; - try { - latestSetSnapshot(latestGetSnapshot(source._source)); - var lane = requestUpdateLane(fiber, ReactCurrentBatchConfig.suspense); - root.mutableReadLanes |= lane & root.pendingLanes; - } catch (error) { - latestSetSnapshot(function() { - throw error; - }); - } - }); - }, - [source, subscribe] - ); - (objectIs(prevGetSnapshot, getSnapshot) && - objectIs(prevSource, source) && - objectIs(memoizedState, subscribe)) || - ((hook = { - pending: null, - dispatch: null, - lastRenderedReducer: basicStateReducer, - lastRenderedState: snapshot - }), - (hook.dispatch = setSnapshot = dispatchAction.bind( - null, - currentlyRenderingFiber$1, - hook - )), - (_dispatcher$useState.queue = hook), - (_dispatcher$useState.baseQueue = null), - (snapshot = readFromUnsubcribedMutableSource(root, source, getSnapshot)), - (_dispatcher$useState.memoizedState = _dispatcher$useState.baseState = snapshot)); - return snapshot; -} -function updateMutableSource(source, getSnapshot, subscribe) { - var hook = updateWorkInProgressHook(); - return useMutableSource(hook, source, getSnapshot, subscribe); -} function mountState(initialState) { var hook = mountWorkInProgressHook(); "function" === typeof initialState && (initialState = initialState()); @@ -3774,12 +3403,11 @@ function startTransition(setPending, config, callback) { }); } function dispatchAction(fiber, queue, action) { - var eventTime = requestEventTime(), - suspenseConfig = ReactCurrentBatchConfig.suspense, - lane = requestUpdateLane(fiber, suspenseConfig); + var currentTime = requestCurrentTimeForUpdate(), + suspenseConfig = ReactCurrentBatchConfig.suspense; + currentTime = computeExpirationForFiber(currentTime, fiber, suspenseConfig); suspenseConfig = { - eventTime: eventTime, - lane: lane, + expirationTime: currentTime, suspenseConfig: suspenseConfig, action: action, eagerReducer: null, @@ -3796,11 +3424,13 @@ function dispatchAction(fiber, queue, action) { fiber === currentlyRenderingFiber$1 || (null !== pending && pending === currentlyRenderingFiber$1) ) - didScheduleRenderPhaseUpdateDuringThisPass = didScheduleRenderPhaseUpdate = !0; + (didScheduleRenderPhaseUpdate = !0), + (suspenseConfig.expirationTime = renderExpirationTime), + (currentlyRenderingFiber$1.expirationTime = renderExpirationTime); else { if ( - 0 === fiber.lanes && - (null === pending || 0 === pending.lanes) && + 0 === fiber.expirationTime && + (null === pending || 0 === pending.expirationTime) && ((pending = queue.lastRenderedReducer), null !== pending) ) try { @@ -3812,9 +3442,10 @@ function dispatchAction(fiber, queue, action) { } catch (error) { } finally { } - scheduleUpdateOnFiber(fiber, lane, eventTime); + scheduleWork(fiber, currentTime); } } +function updateEventListener() {} var ContextOnlyDispatcher = { readContext: readContext, useCallback: throwInvalidHookError, @@ -3830,9 +3461,7 @@ var ContextOnlyDispatcher = { useResponder: throwInvalidHookError, useDeferredValue: throwInvalidHookError, useTransition: throwInvalidHookError, - useMutableSource: throwInvalidHookError, - useOpaqueIdentifier: throwInvalidHookError, - unstable_isNewReconciler: !1 + useEvent: throwInvalidHookError }, HooksDispatcherOnMount = { readContext: readContext, @@ -3914,19 +3543,7 @@ var ContextOnlyDispatcher = { isPending ]; }, - useMutableSource: function(source, getSnapshot, subscribe) { - var hook = mountWorkInProgressHook(); - hook.memoizedState = { - refs: { getSnapshot: getSnapshot, setSnapshot: null }, - source: source, - subscribe: subscribe - }; - return useMutableSource(hook, source, getSnapshot, subscribe); - }, - useOpaqueIdentifier: function() { - throw Error("Not yet implemented"); - }, - unstable_isNewReconciler: !1 + useEvent: function() {} }, HooksDispatcherOnUpdate = { readContext: readContext, @@ -3974,11 +3591,7 @@ var ContextOnlyDispatcher = { isPending ]; }, - useMutableSource: updateMutableSource, - useOpaqueIdentifier: function() { - return updateReducer(basicStateReducer)[0]; - }, - unstable_isNewReconciler: !1 + useEvent: updateEventListener }, HooksDispatcherOnRerender = { readContext: readContext, @@ -4026,23 +3639,29 @@ var ContextOnlyDispatcher = { isPending ]; }, - useMutableSource: updateMutableSource, - useOpaqueIdentifier: function() { - return rerenderReducer(basicStateReducer)[0]; - }, - unstable_isNewReconciler: !1 + useEvent: updateEventListener }, ReactCurrentOwner$1 = ReactSharedInternals.ReactCurrentOwner, didReceiveUpdate = !1; -function reconcileChildren(current, workInProgress, nextChildren, renderLanes) { +function reconcileChildren( + current, + workInProgress, + nextChildren, + renderExpirationTime +) { workInProgress.child = null === current - ? mountChildFibers(workInProgress, null, nextChildren, renderLanes) + ? mountChildFibers( + workInProgress, + null, + nextChildren, + renderExpirationTime + ) : reconcileChildFibers( workInProgress, current.child, nextChildren, - renderLanes + renderExpirationTime ); } function updateForwardRef( @@ -4050,28 +3669,33 @@ function updateForwardRef( workInProgress, Component, nextProps, - renderLanes + renderExpirationTime ) { Component = Component.render; var ref = workInProgress.ref; - prepareToReadContext(workInProgress, renderLanes); + prepareToReadContext(workInProgress, renderExpirationTime); nextProps = renderWithHooks( current, workInProgress, Component, nextProps, ref, - renderLanes + renderExpirationTime ); if (null !== current && !didReceiveUpdate) return ( (workInProgress.updateQueue = current.updateQueue), (workInProgress.effectTag &= -517), - (current.lanes &= ~renderLanes), - bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes) + current.expirationTime <= renderExpirationTime && + (current.expirationTime = 0), + bailoutOnAlreadyFinishedWork( + current, + workInProgress, + renderExpirationTime + ) ); workInProgress.effectTag |= 1; - reconcileChildren(current, workInProgress, nextProps, renderLanes); + reconcileChildren(current, workInProgress, nextProps, renderExpirationTime); return workInProgress.child; } function updateMemoComponent( @@ -4079,8 +3703,8 @@ function updateMemoComponent( workInProgress, Component, nextProps, - updateLanes, - renderLanes + updateExpirationTime, + renderExpirationTime ) { if (null === current) { var type = Component.type; @@ -4099,8 +3723,8 @@ function updateMemoComponent( workInProgress, type, nextProps, - updateLanes, - renderLanes + updateExpirationTime, + renderExpirationTime ) ); current = createFiberFromTypeAndProps( @@ -4109,7 +3733,7 @@ function updateMemoComponent( nextProps, null, workInProgress.mode, - renderLanes + renderExpirationTime ); current.ref = workInProgress.ref; current.return = workInProgress; @@ -4117,13 +3741,18 @@ function updateMemoComponent( } type = current.child; if ( - 0 === (updateLanes & renderLanes) && - ((updateLanes = type.memoizedProps), + updateExpirationTime < renderExpirationTime && + ((updateExpirationTime = type.memoizedProps), (Component = Component.compare), (Component = null !== Component ? Component : shallowEqual), - Component(updateLanes, nextProps) && current.ref === workInProgress.ref) + Component(updateExpirationTime, nextProps) && + current.ref === workInProgress.ref) ) - return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes); + return bailoutOnAlreadyFinishedWork( + current, + workInProgress, + renderExpirationTime + ); workInProgress.effectTag |= 1; current = createWorkInProgress(type, nextProps); current.ref = workInProgress.ref; @@ -4135,63 +3764,26 @@ function updateSimpleMemoComponent( workInProgress, Component, nextProps, - updateLanes, - renderLanes + updateExpirationTime, + renderExpirationTime ) { - if ( - null !== current && + return null !== current && shallowEqual(current.memoizedProps, nextProps) && - current.ref === workInProgress.ref - ) - if (((didReceiveUpdate = !1), 0 !== (renderLanes & updateLanes))) - 0 !== (current.effectTag & 16384) && (didReceiveUpdate = !0); - else - return ( - (workInProgress.lanes = current.lanes), - bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes) + current.ref === workInProgress.ref && + ((didReceiveUpdate = !1), updateExpirationTime < renderExpirationTime) + ? ((workInProgress.expirationTime = current.expirationTime), + bailoutOnAlreadyFinishedWork( + current, + workInProgress, + renderExpirationTime + )) + : updateFunctionComponent( + current, + workInProgress, + Component, + nextProps, + renderExpirationTime ); - return updateFunctionComponent( - current, - workInProgress, - Component, - nextProps, - renderLanes - ); -} -function updateOffscreenComponent(current, workInProgress, renderLanes) { - var nextProps = workInProgress.pendingProps, - nextChildren = nextProps.children, - prevState = null !== current ? current.memoizedState : null; - if ( - "hidden" === nextProps.mode || - "unstable-defer-without-hiding" === nextProps.mode - ) - if (0 === (workInProgress.mode & 4)) - (workInProgress.memoizedState = { baseLanes: 0 }), - pushRenderLanes(workInProgress, renderLanes); - else if (0 !== (renderLanes & 1073741824)) - (workInProgress.memoizedState = { baseLanes: 0 }), - pushRenderLanes( - workInProgress, - null !== prevState ? prevState.baseLanes : renderLanes - ); - else - return ( - (current = - null !== prevState ? prevState.baseLanes | renderLanes : renderLanes), - (workInProgress.lanes = workInProgress.childLanes = 1073741824), - (workInProgress.memoizedState = { baseLanes: current }), - pushRenderLanes(workInProgress, current), - null - ); - else - null !== prevState - ? ((nextProps = prevState.baseLanes | renderLanes), - (workInProgress.memoizedState = null)) - : (nextProps = renderLanes), - pushRenderLanes(workInProgress, nextProps); - reconcileChildren(current, workInProgress, nextChildren, renderLanes); - return workInProgress.child; } function markRef(current, workInProgress) { var ref = workInProgress.ref; @@ -4206,30 +3798,35 @@ function updateFunctionComponent( workInProgress, Component, nextProps, - renderLanes + renderExpirationTime ) { var context = isContextProvider(Component) ? previousContext : contextStackCursor.current; context = getMaskedContext(workInProgress, context); - prepareToReadContext(workInProgress, renderLanes); + prepareToReadContext(workInProgress, renderExpirationTime); Component = renderWithHooks( current, workInProgress, Component, nextProps, context, - renderLanes + renderExpirationTime ); if (null !== current && !didReceiveUpdate) return ( (workInProgress.updateQueue = current.updateQueue), (workInProgress.effectTag &= -517), - (current.lanes &= ~renderLanes), - bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes) + current.expirationTime <= renderExpirationTime && + (current.expirationTime = 0), + bailoutOnAlreadyFinishedWork( + current, + workInProgress, + renderExpirationTime + ) ); workInProgress.effectTag |= 1; - reconcileChildren(current, workInProgress, Component, renderLanes); + reconcileChildren(current, workInProgress, Component, renderExpirationTime); return workInProgress.child; } function updateClassComponent( @@ -4237,20 +3834,25 @@ function updateClassComponent( workInProgress, Component, nextProps, - renderLanes + renderExpirationTime ) { if (isContextProvider(Component)) { var hasContext = !0; pushContextProvider(workInProgress); } else hasContext = !1; - prepareToReadContext(workInProgress, renderLanes); + prepareToReadContext(workInProgress, renderExpirationTime); if (null === workInProgress.stateNode) null !== current && ((current.alternate = null), (workInProgress.alternate = null), (workInProgress.effectTag |= 2)), constructClassInstance(workInProgress, Component, nextProps), - mountClassInstance(workInProgress, Component, nextProps, renderLanes), + mountClassInstance( + workInProgress, + Component, + nextProps, + renderExpirationTime + ), (nextProps = !0); else if (null === current) { var instance = workInProgress.stateNode, @@ -4281,7 +3883,12 @@ function updateClassComponent( hasForceUpdate = !1; var oldState = workInProgress.memoizedState; instance.state = oldState; - processUpdateQueue(workInProgress, nextProps, instance, renderLanes); + processUpdateQueue( + workInProgress, + nextProps, + instance, + renderExpirationTime + ); oldContext = workInProgress.memoizedState; oldProps !== nextProps || oldState !== oldContext || @@ -4326,111 +3933,117 @@ function updateClassComponent( : ("function" === typeof instance.componentDidMount && (workInProgress.effectTag |= 4), (nextProps = !1)); - } else { - instance = workInProgress.stateNode; - cloneUpdateQueue(current, workInProgress); - oldProps = workInProgress.memoizedProps; - contextType = - workInProgress.type === workInProgress.elementType - ? oldProps - : resolveDefaultProps(workInProgress.type, oldProps); - instance.props = contextType; - hasNewLifecycles = workInProgress.pendingProps; - oldState = instance.context; - oldContext = Component.contextType; - "object" === typeof oldContext && null !== oldContext - ? (oldContext = readContext(oldContext)) - : ((oldContext = isContextProvider(Component) - ? previousContext - : contextStackCursor.current), - (oldContext = getMaskedContext(workInProgress, oldContext))); - var getDerivedStateFromProps$jscomp$0 = Component.getDerivedStateFromProps; - (getDerivedStateFromProps = - "function" === typeof getDerivedStateFromProps$jscomp$0 || - "function" === typeof instance.getSnapshotBeforeUpdate) || - ("function" !== typeof instance.UNSAFE_componentWillReceiveProps && - "function" !== typeof instance.componentWillReceiveProps) || - ((oldProps !== hasNewLifecycles || oldState !== oldContext) && - callComponentWillReceiveProps( - workInProgress, - instance, - nextProps, - oldContext - )); - hasForceUpdate = !1; - oldState = workInProgress.memoizedState; - instance.state = oldState; - processUpdateQueue(workInProgress, nextProps, instance, renderLanes); - var newState = workInProgress.memoizedState; - oldProps !== hasNewLifecycles || - oldState !== newState || - didPerformWorkStackCursor.current || - hasForceUpdate - ? ("function" === typeof getDerivedStateFromProps$jscomp$0 && - (applyDerivedStateFromProps( + } else + (instance = workInProgress.stateNode), + cloneUpdateQueue(current, workInProgress), + (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 = readContext(contextType)) + : ((contextType = isContextProvider(Component) + ? previousContext + : contextStackCursor.current), + (contextType = getMaskedContext(workInProgress, contextType))), + (getDerivedStateFromProps = Component.getDerivedStateFromProps), + (hasNewLifecycles = + "function" === typeof getDerivedStateFromProps || + "function" === typeof instance.getSnapshotBeforeUpdate) || + ("function" !== typeof instance.UNSAFE_componentWillReceiveProps && + "function" !== typeof instance.componentWillReceiveProps) || + ((oldProps !== nextProps || oldContext !== contextType) && + callComponentWillReceiveProps( workInProgress, - Component, - getDerivedStateFromProps$jscomp$0, - nextProps - ), - (newState = workInProgress.memoizedState)), - (contextType = - hasForceUpdate || - checkShouldComponentUpdate( - workInProgress, - Component, - contextType, + instance, nextProps, - oldState, - newState, - oldContext - )) - ? (getDerivedStateFromProps || - ("function" !== typeof instance.UNSAFE_componentWillUpdate && - "function" !== typeof instance.componentWillUpdate) || - ("function" === typeof instance.componentWillUpdate && - instance.componentWillUpdate(nextProps, newState, oldContext), - "function" === typeof instance.UNSAFE_componentWillUpdate && - instance.UNSAFE_componentWillUpdate( - nextProps, - newState, - oldContext - )), - "function" === typeof instance.componentDidUpdate && - (workInProgress.effectTag |= 4), - "function" === typeof instance.getSnapshotBeforeUpdate && - (workInProgress.effectTag |= 256)) - : ("function" !== typeof instance.componentDidUpdate || - (oldProps === current.memoizedProps && - oldState === current.memoizedState) || - (workInProgress.effectTag |= 4), - "function" !== typeof instance.getSnapshotBeforeUpdate || - (oldProps === current.memoizedProps && - oldState === current.memoizedState) || - (workInProgress.effectTag |= 256), - (workInProgress.memoizedProps = nextProps), - (workInProgress.memoizedState = newState)), - (instance.props = nextProps), - (instance.state = newState), - (instance.context = oldContext), - (nextProps = contextType)) - : ("function" !== typeof instance.componentDidUpdate || - (oldProps === current.memoizedProps && - oldState === current.memoizedState) || - (workInProgress.effectTag |= 4), - "function" !== typeof instance.getSnapshotBeforeUpdate || - (oldProps === current.memoizedProps && - oldState === current.memoizedState) || - (workInProgress.effectTag |= 256), - (nextProps = !1)); - } + contextType + )), + (hasForceUpdate = !1), + (oldContext = workInProgress.memoizedState), + (instance.state = oldContext), + processUpdateQueue( + workInProgress, + nextProps, + instance, + renderExpirationTime + ), + (oldState = workInProgress.memoizedState), + oldProps !== nextProps || + oldContext !== oldState || + didPerformWorkStackCursor.current || + hasForceUpdate + ? ("function" === typeof getDerivedStateFromProps && + (applyDerivedStateFromProps( + workInProgress, + Component, + getDerivedStateFromProps, + nextProps + ), + (oldState = workInProgress.memoizedState)), + (getDerivedStateFromProps = + hasForceUpdate || + checkShouldComponentUpdate( + workInProgress, + Component, + oldProps, + nextProps, + oldContext, + oldState, + contextType + )) + ? (hasNewLifecycles || + ("function" !== typeof instance.UNSAFE_componentWillUpdate && + "function" !== typeof instance.componentWillUpdate) || + ("function" === typeof instance.componentWillUpdate && + instance.componentWillUpdate( + nextProps, + oldState, + contextType + ), + "function" === typeof instance.UNSAFE_componentWillUpdate && + instance.UNSAFE_componentWillUpdate( + nextProps, + oldState, + contextType + )), + "function" === typeof instance.componentDidUpdate && + (workInProgress.effectTag |= 4), + "function" === typeof instance.getSnapshotBeforeUpdate && + (workInProgress.effectTag |= 256)) + : ("function" !== typeof instance.componentDidUpdate || + (oldProps === current.memoizedProps && + oldContext === current.memoizedState) || + (workInProgress.effectTag |= 4), + "function" !== typeof instance.getSnapshotBeforeUpdate || + (oldProps === current.memoizedProps && + oldContext === current.memoizedState) || + (workInProgress.effectTag |= 256), + (workInProgress.memoizedProps = nextProps), + (workInProgress.memoizedState = oldState)), + (instance.props = nextProps), + (instance.state = oldState), + (instance.context = contextType), + (nextProps = getDerivedStateFromProps)) + : ("function" !== typeof instance.componentDidUpdate || + (oldProps === current.memoizedProps && + oldContext === current.memoizedState) || + (workInProgress.effectTag |= 4), + "function" !== typeof instance.getSnapshotBeforeUpdate || + (oldProps === current.memoizedProps && + oldContext === current.memoizedState) || + (workInProgress.effectTag |= 256), + (nextProps = !1)); return finishClassComponent( current, workInProgress, Component, nextProps, hasContext, - renderLanes + renderExpirationTime ); } function finishClassComponent( @@ -4439,14 +4052,18 @@ function finishClassComponent( Component, shouldUpdate, hasContext, - renderLanes + renderExpirationTime ) { markRef(current, workInProgress); var didCaptureError = 0 !== (workInProgress.effectTag & 64); if (!shouldUpdate && !didCaptureError) return ( hasContext && invalidateContextProvider(workInProgress, Component, !1), - bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes) + bailoutOnAlreadyFinishedWork( + current, + workInProgress, + renderExpirationTime + ) ); shouldUpdate = workInProgress.stateNode; ReactCurrentOwner$1.current = workInProgress; @@ -4460,15 +4077,20 @@ function finishClassComponent( workInProgress, current.child, null, - renderLanes + renderExpirationTime )), (workInProgress.child = reconcileChildFibers( workInProgress, null, nextChildren, - renderLanes + renderExpirationTime ))) - : reconcileChildren(current, workInProgress, nextChildren, renderLanes); + : reconcileChildren( + current, + workInProgress, + nextChildren, + renderExpirationTime + ); workInProgress.memoizedState = shouldUpdate.state; hasContext && invalidateContextProvider(workInProgress, Component, !0); return workInProgress.child; @@ -4485,186 +4107,155 @@ function pushHostRootContext(workInProgress) { pushTopLevelContextObject(workInProgress, root.context, !1); pushHostContainer(workInProgress, root.containerInfo); } -var SUSPENDED_MARKER = { dehydrated: null, retryLane: 0 }; -function updateSuspenseComponent(current, workInProgress, renderLanes) { - var nextProps = workInProgress.pendingProps, +var SUSPENDED_MARKER = { dehydrated: null, retryTime: 0 }; +function updateSuspenseComponent( + current, + workInProgress, + renderExpirationTime +) { + var mode = workInProgress.mode, + nextProps = workInProgress.pendingProps, suspenseContext = suspenseStackCursor.current, - showFallback = !1, + nextDidTimeout = !1, JSCompiler_temp; (JSCompiler_temp = 0 !== (workInProgress.effectTag & 64)) || (JSCompiler_temp = - null !== current && null === current.memoizedState - ? !1 - : 0 !== (suspenseContext & 2)); + 0 !== (suspenseContext & 2) && + (null === current || null !== current.memoizedState)); JSCompiler_temp - ? ((showFallback = !0), (workInProgress.effectTag &= -65)) + ? ((nextDidTimeout = !0), (workInProgress.effectTag &= -65)) : (null !== current && null === current.memoizedState) || void 0 === nextProps.fallback || !0 === nextProps.unstable_avoidThisFallback || (suspenseContext |= 1); push(suspenseStackCursor, suspenseContext & 1); if (null === current) { - if (showFallback) - return ( - (current = nextProps.fallback), - (suspenseContext = workInProgress.mode), - (showFallback = workInProgress.child), - (nextProps = { mode: "hidden", children: nextProps.children }), - 0 === (suspenseContext & 2) && null !== showFallback - ? ((showFallback.childLanes = 0), - (showFallback.pendingProps = nextProps)) - : (showFallback = createFiberFromOffscreen( - nextProps, - suspenseContext, - 0, - null - )), - (current = createFiberFromFragment( - current, - suspenseContext, - renderLanes, - null - )), - (showFallback.return = workInProgress), - (current.return = workInProgress), - (showFallback.sibling = current), - (workInProgress.child = showFallback), - (workInProgress.child.memoizedState = { baseLanes: renderLanes }), - (workInProgress.memoizedState = SUSPENDED_MARKER), - current + if (nextDidTimeout) { + nextDidTimeout = nextProps.fallback; + nextProps = createFiberFromFragment(null, mode, 0, null); + nextProps.return = workInProgress; + if (0 === (workInProgress.mode & 2)) + for ( + current = + null !== workInProgress.memoizedState + ? workInProgress.child.child + : workInProgress.child, + nextProps.child = current; + null !== current; + + ) + (current.return = nextProps), (current = current.sibling); + renderExpirationTime = createFiberFromFragment( + nextDidTimeout, + mode, + renderExpirationTime, + null ); - renderLanes = createFiberFromOffscreen( - { mode: "visible", children: nextProps.children }, - workInProgress.mode, - renderLanes, - null - ); - renderLanes.return = workInProgress; - return (workInProgress.child = renderLanes); + renderExpirationTime.return = workInProgress; + nextProps.sibling = renderExpirationTime; + workInProgress.memoizedState = SUSPENDED_MARKER; + workInProgress.child = nextProps; + return renderExpirationTime; + } + mode = nextProps.children; + workInProgress.memoizedState = null; + return (workInProgress.child = mountChildFibers( + workInProgress, + null, + mode, + renderExpirationTime + )); } if (null !== current.memoizedState) { - if (showFallback) - return ( - (nextProps = updateSuspenseFallbackChildren( - current, - workInProgress, - nextProps.children, - nextProps.fallback, - renderLanes - )), - (suspenseContext = workInProgress.child), - (showFallback = current.child.memoizedState), - (suspenseContext.memoizedState = - null === showFallback - ? { baseLanes: renderLanes } - : { baseLanes: showFallback.baseLanes | renderLanes }), - (suspenseContext.childLanes = current.childLanes & ~renderLanes), - (workInProgress.memoizedState = SUSPENDED_MARKER), - nextProps + current = current.child; + mode = current.sibling; + if (nextDidTimeout) { + nextProps = nextProps.fallback; + renderExpirationTime = createWorkInProgress( + current, + current.pendingProps ); - renderLanes = updateSuspensePrimaryChildren( - current, + renderExpirationTime.return = workInProgress; + if ( + 0 === (workInProgress.mode & 2) && + ((nextDidTimeout = + null !== workInProgress.memoizedState + ? workInProgress.child.child + : workInProgress.child), + nextDidTimeout !== current.child) + ) + for ( + renderExpirationTime.child = nextDidTimeout; + null !== nextDidTimeout; + + ) + (nextDidTimeout.return = renderExpirationTime), + (nextDidTimeout = nextDidTimeout.sibling); + mode = createWorkInProgress(mode, nextProps); + mode.return = workInProgress; + renderExpirationTime.sibling = mode; + renderExpirationTime.childExpirationTime = 0; + workInProgress.memoizedState = SUSPENDED_MARKER; + workInProgress.child = renderExpirationTime; + return mode; + } + renderExpirationTime = reconcileChildFibers( workInProgress, + current.child, nextProps.children, - renderLanes + renderExpirationTime ); workInProgress.memoizedState = null; - return renderLanes; + return (workInProgress.child = renderExpirationTime); } - if (showFallback) - return ( - (nextProps = updateSuspenseFallbackChildren( - current, - workInProgress, - nextProps.children, - nextProps.fallback, - renderLanes - )), - (suspenseContext = workInProgress.child), - (showFallback = current.child.memoizedState), - (suspenseContext.memoizedState = - null === showFallback - ? { baseLanes: renderLanes } - : { baseLanes: showFallback.baseLanes | renderLanes }), - (suspenseContext.childLanes = current.childLanes & ~renderLanes), - (workInProgress.memoizedState = SUSPENDED_MARKER), - nextProps + current = current.child; + if (nextDidTimeout) { + nextDidTimeout = nextProps.fallback; + nextProps = createFiberFromFragment(null, mode, 0, null); + nextProps.return = workInProgress; + nextProps.child = current; + null !== current && (current.return = nextProps); + if (0 === (workInProgress.mode & 2)) + for ( + current = + null !== workInProgress.memoizedState + ? workInProgress.child.child + : workInProgress.child, + nextProps.child = current; + null !== current; + + ) + (current.return = nextProps), (current = current.sibling); + renderExpirationTime = createFiberFromFragment( + nextDidTimeout, + mode, + renderExpirationTime, + null ); - renderLanes = updateSuspensePrimaryChildren( - current, - workInProgress, - nextProps.children, - renderLanes - ); + renderExpirationTime.return = workInProgress; + nextProps.sibling = renderExpirationTime; + renderExpirationTime.effectTag |= 2; + nextProps.childExpirationTime = 0; + workInProgress.memoizedState = SUSPENDED_MARKER; + workInProgress.child = nextProps; + return renderExpirationTime; + } workInProgress.memoizedState = null; - return renderLanes; + return (workInProgress.child = reconcileChildFibers( + workInProgress, + current, + nextProps.children, + renderExpirationTime + )); } -function updateSuspensePrimaryChildren( - current, - workInProgress, - primaryChildren, - renderLanes -) { - var currentPrimaryChildFragment = current.child; - current = currentPrimaryChildFragment.sibling; - primaryChildren = createWorkInProgress(currentPrimaryChildFragment, { - mode: "visible", - children: primaryChildren - }); - 0 === (workInProgress.mode & 2) && (primaryChildren.lanes = renderLanes); - primaryChildren.return = workInProgress; - primaryChildren.sibling = null; - null !== current && - ((current.nextEffect = null), - (current.effectTag = 8), - (workInProgress.firstEffect = workInProgress.lastEffect = current)); - return (workInProgress.child = primaryChildren); -} -function updateSuspenseFallbackChildren( - current, - workInProgress, - primaryChildren, - fallbackChildren, - renderLanes -) { - var mode = workInProgress.mode, - currentPrimaryChildFragment = current.child; - current = currentPrimaryChildFragment.sibling; - var primaryChildProps = { mode: "hidden", children: primaryChildren }; - 0 === (mode & 2) && workInProgress.child !== currentPrimaryChildFragment - ? ((primaryChildren = workInProgress.child), - (primaryChildren.childLanes = 0), - (primaryChildren.pendingProps = primaryChildProps), - (currentPrimaryChildFragment = primaryChildren.lastEffect), - null !== currentPrimaryChildFragment - ? ((workInProgress.firstEffect = primaryChildren.firstEffect), - (workInProgress.lastEffect = currentPrimaryChildFragment), - (currentPrimaryChildFragment.nextEffect = null)) - : (workInProgress.firstEffect = workInProgress.lastEffect = null)) - : (primaryChildren = createWorkInProgress( - currentPrimaryChildFragment, - primaryChildProps - )); - null !== current - ? (fallbackChildren = createWorkInProgress(current, fallbackChildren)) - : ((fallbackChildren = createFiberFromFragment( - fallbackChildren, - mode, - renderLanes, - null - )), - (fallbackChildren.effectTag |= 2)); - fallbackChildren.return = workInProgress; - primaryChildren.return = workInProgress; - primaryChildren.sibling = fallbackChildren; - workInProgress.child = primaryChildren; - return fallbackChildren; -} -function scheduleWorkOnFiber(fiber, renderLanes) { - fiber.lanes |= renderLanes; +function scheduleWorkOnFiber(fiber, renderExpirationTime) { + fiber.expirationTime < renderExpirationTime && + (fiber.expirationTime = renderExpirationTime); var alternate = fiber.alternate; - null !== alternate && (alternate.lanes |= renderLanes); - scheduleWorkOnParentPath(fiber.return, renderLanes); + null !== alternate && + alternate.expirationTime < renderExpirationTime && + (alternate.expirationTime = renderExpirationTime); + scheduleWorkOnParentPath(fiber.return, renderExpirationTime); } function initSuspenseListRenderState( workInProgress, @@ -4695,11 +4286,20 @@ function initSuspenseListRenderState( (renderState.tailMode = tailMode), (renderState.lastEffect = lastEffectBeforeRendering)); } -function updateSuspenseListComponent(current, workInProgress, renderLanes) { +function updateSuspenseListComponent( + current, + workInProgress, + renderExpirationTime +) { var nextProps = workInProgress.pendingProps, revealOrder = nextProps.revealOrder, tailMode = nextProps.tail; - reconcileChildren(current, workInProgress, nextProps.children, renderLanes); + reconcileChildren( + current, + workInProgress, + nextProps.children, + renderExpirationTime + ); nextProps = suspenseStackCursor.current; if (0 !== (nextProps & 2)) (nextProps = (nextProps & 1) | 2), (workInProgress.effectTag |= 64); @@ -4708,8 +4308,9 @@ function updateSuspenseListComponent(current, workInProgress, renderLanes) { a: for (current = workInProgress.child; null !== current; ) { if (13 === current.tag) null !== current.memoizedState && - scheduleWorkOnFiber(current, renderLanes); - else if (19 === current.tag) scheduleWorkOnFiber(current, renderLanes); + scheduleWorkOnFiber(current, renderExpirationTime); + else if (19 === current.tag) + scheduleWorkOnFiber(current, renderExpirationTime); else if (null !== current.child) { current.child.return = current; current = current.child; @@ -4731,29 +4332,30 @@ function updateSuspenseListComponent(current, workInProgress, renderLanes) { else switch (revealOrder) { case "forwards": - renderLanes = workInProgress.child; - for (revealOrder = null; null !== renderLanes; ) - (current = renderLanes.alternate), + renderExpirationTime = workInProgress.child; + for (revealOrder = null; null !== renderExpirationTime; ) + (current = renderExpirationTime.alternate), null !== current && null === findFirstSuspended(current) && - (revealOrder = renderLanes), - (renderLanes = renderLanes.sibling); - renderLanes = revealOrder; - null === renderLanes + (revealOrder = renderExpirationTime), + (renderExpirationTime = renderExpirationTime.sibling); + renderExpirationTime = revealOrder; + null === renderExpirationTime ? ((revealOrder = workInProgress.child), (workInProgress.child = null)) - : ((revealOrder = renderLanes.sibling), (renderLanes.sibling = null)); + : ((revealOrder = renderExpirationTime.sibling), + (renderExpirationTime.sibling = null)); initSuspenseListRenderState( workInProgress, !1, revealOrder, - renderLanes, + renderExpirationTime, tailMode, workInProgress.lastEffect ); break; case "backwards": - renderLanes = null; + renderExpirationTime = null; revealOrder = workInProgress.child; for (workInProgress.child = null; null !== revealOrder; ) { current = revealOrder.alternate; @@ -4762,14 +4364,14 @@ function updateSuspenseListComponent(current, workInProgress, renderLanes) { break; } current = revealOrder.sibling; - revealOrder.sibling = renderLanes; - renderLanes = revealOrder; + revealOrder.sibling = renderExpirationTime; + renderExpirationTime = revealOrder; revealOrder = current; } initSuspenseListRenderState( workInProgress, !0, - renderLanes, + renderExpirationTime, null, tailMode, workInProgress.lastEffect @@ -4790,28 +4392,35 @@ function updateSuspenseListComponent(current, workInProgress, renderLanes) { } return workInProgress.child; } -function bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes) { +function bailoutOnAlreadyFinishedWork( + current, + workInProgress, + renderExpirationTime +) { null !== current && (workInProgress.dependencies = current.dependencies); - workInProgressRootSkippedLanes |= workInProgress.lanes; - if (0 !== (renderLanes & workInProgress.childLanes)) { - if (null !== current && workInProgress.child !== current.child) - throw Error("Resuming work not yet implemented."); - if (null !== workInProgress.child) { - current = workInProgress.child; - renderLanes = createWorkInProgress(current, current.pendingProps); - workInProgress.child = renderLanes; - for (renderLanes.return = workInProgress; null !== current.sibling; ) - (current = current.sibling), - (renderLanes = renderLanes.sibling = createWorkInProgress( - current, - current.pendingProps - )), - (renderLanes.return = workInProgress); - renderLanes.sibling = null; - } - return workInProgress.child; + var updateExpirationTime = workInProgress.expirationTime; + 0 !== updateExpirationTime && markUnprocessedUpdateTime(updateExpirationTime); + if (workInProgress.childExpirationTime < renderExpirationTime) return null; + if (null !== current && workInProgress.child !== current.child) + throw Error("Resuming work not yet implemented."); + if (null !== workInProgress.child) { + current = workInProgress.child; + renderExpirationTime = createWorkInProgress(current, current.pendingProps); + workInProgress.child = renderExpirationTime; + for ( + renderExpirationTime.return = workInProgress; + null !== current.sibling; + + ) + (current = current.sibling), + (renderExpirationTime = renderExpirationTime.sibling = createWorkInProgress( + current, + current.pendingProps + )), + (renderExpirationTime.return = workInProgress); + renderExpirationTime.sibling = null; } - return null; + return workInProgress.child; } var appendAllChildren, updateHostContainer, @@ -5004,17 +4613,17 @@ function cutOffTailIfNeeded(renderState, hasRenderedATailFallback) { break; case "collapsed": lastTailNode = renderState.tail; - for (var lastTailNode$64 = null; null !== lastTailNode; ) - null !== lastTailNode.alternate && (lastTailNode$64 = lastTailNode), + for (var _lastTailNode = null; null !== lastTailNode; ) + null !== lastTailNode.alternate && (_lastTailNode = lastTailNode), (lastTailNode = lastTailNode.sibling); - null === lastTailNode$64 + null === _lastTailNode ? hasRenderedATailFallback || null === renderState.tail ? (renderState.tail = null) : (renderState.tail.sibling = null) - : (lastTailNode$64.sibling = null); + : (_lastTailNode.sibling = null); } } -function completeWork(current, workInProgress, renderLanes) { +function completeWork(current, workInProgress, renderExpirationTime) { var newProps = workInProgress.pendingProps; switch (workInProgress.tag) { case 2: @@ -5035,14 +4644,10 @@ function completeWork(current, workInProgress, renderLanes) { popHostContainer(), pop(didPerformWorkStackCursor), pop(contextStackCursor), - resetWorkInProgressVersions(), - (newProps = workInProgress.stateNode), - newProps.pendingContext && - ((newProps.context = newProps.pendingContext), - (newProps.pendingContext = null)), - (null !== current && null !== current.child) || - newProps.hydrate || - (workInProgress.effectTag |= 256), + (current = workInProgress.stateNode), + current.pendingContext && + ((current.context = current.pendingContext), + (current.pendingContext = null)), updateHostContainer(workInProgress), null ); @@ -5051,12 +4656,12 @@ function completeWork(current, workInProgress, renderLanes) { var rootContainerInstance = requiredContext( rootInstanceStackCursor.current ); - renderLanes = workInProgress.type; + renderExpirationTime = workInProgress.type; if (null !== current && null != workInProgress.stateNode) updateHostComponent$1( current, workInProgress, - renderLanes, + renderExpirationTime, newProps, rootContainerInstance ), @@ -5073,23 +4678,23 @@ function completeWork(current, workInProgress, renderLanes) { requiredContext(contextStackCursor$1.current); current = nextReactTag; nextReactTag += 2; - renderLanes = getViewConfigForType(renderLanes); + renderExpirationTime = getViewConfigForType(renderExpirationTime); var updatePayload = diffProperties( null, emptyObject, newProps, - renderLanes.validAttributes + renderExpirationTime.validAttributes ); rootContainerInstance = createNode( current, - renderLanes.uiViewClassName, + renderExpirationTime.uiViewClassName, rootContainerInstance, updatePayload, workInProgress ); current = new ReactFabricHostComponent( current, - renderLanes, + renderExpirationTime, newProps, workInProgress ); @@ -5126,32 +4731,49 @@ function completeWork(current, workInProgress, renderLanes) { pop(suspenseStackCursor); newProps = workInProgress.memoizedState; if (0 !== (workInProgress.effectTag & 64)) - return (workInProgress.lanes = renderLanes), workInProgress; + return ( + (workInProgress.expirationTime = renderExpirationTime), workInProgress + ); newProps = null !== newProps; rootContainerInstance = !1; null !== current && - (rootContainerInstance = null !== current.memoizedState); + ((renderExpirationTime = current.memoizedState), + (rootContainerInstance = null !== renderExpirationTime), + newProps || + null === renderExpirationTime || + ((renderExpirationTime = current.child.sibling), + null !== renderExpirationTime && + ((updatePayload = workInProgress.firstEffect), + null !== updatePayload + ? ((workInProgress.firstEffect = renderExpirationTime), + (renderExpirationTime.nextEffect = updatePayload)) + : ((workInProgress.firstEffect = workInProgress.lastEffect = renderExpirationTime), + (renderExpirationTime.nextEffect = null)), + (renderExpirationTime.effectTag = 8)))); if (newProps && !rootContainerInstance && 0 !== (workInProgress.mode & 2)) if ( (null === current && !0 !== workInProgress.memoizedProps.unstable_avoidThisFallback) || 0 !== (suspenseStackCursor.current & 1) ) - 0 === workInProgressRootExitStatus && - (workInProgressRootExitStatus = 3); + workInProgressRootExitStatus === RootIncomplete && + (workInProgressRootExitStatus = RootSuspended); else { if ( - 0 === workInProgressRootExitStatus || - 3 === workInProgressRootExitStatus + workInProgressRootExitStatus === RootIncomplete || + workInProgressRootExitStatus === RootSuspended ) - workInProgressRootExitStatus = 4; - null === workInProgressRoot || - (0 === (workInProgressRootSkippedLanes & 134217727) && - 0 === (workInProgressRootUpdatedLanes & 134217727)) || - markRootSuspended$1( + workInProgressRootExitStatus = RootSuspendedWithDelay; + 0 !== workInProgressRootNextUnprocessedUpdateTime && + null !== workInProgressRoot && + (markRootSuspendedAtTime( workInProgressRoot, - workInProgressRootRenderLanes - ); + renderExpirationTime$1 + ), + markRootUpdatedAtTime( + workInProgressRoot, + workInProgressRootNextUnprocessedUpdateTime + )); } newProps && (workInProgress.effectTag |= 4); return null; @@ -5171,7 +4793,7 @@ function completeWork(current, workInProgress, renderLanes) { if (rootContainerInstance) cutOffTailIfNeeded(newProps, !1); else { if ( - 0 !== workInProgressRootExitStatus || + workInProgressRootExitStatus !== RootIncomplete || (null !== current && 0 !== (current.effectTag & 64)) ) for (current = workInProgress.child; null !== current; ) { @@ -5186,27 +4808,27 @@ function completeWork(current, workInProgress, renderLanes) { null === newProps.lastEffect && (workInProgress.firstEffect = null); workInProgress.lastEffect = newProps.lastEffect; - current = renderLanes; + current = renderExpirationTime; for (newProps = workInProgress.child; null !== newProps; ) (rootContainerInstance = newProps), - (renderLanes = current), + (renderExpirationTime = current), (rootContainerInstance.effectTag &= 2), (rootContainerInstance.nextEffect = null), (rootContainerInstance.firstEffect = null), (rootContainerInstance.lastEffect = null), (updatePayload = rootContainerInstance.alternate), null === updatePayload - ? ((rootContainerInstance.childLanes = 0), - (rootContainerInstance.lanes = renderLanes), + ? ((rootContainerInstance.childExpirationTime = 0), + (rootContainerInstance.expirationTime = renderExpirationTime), (rootContainerInstance.child = null), (rootContainerInstance.memoizedProps = null), (rootContainerInstance.memoizedState = null), (rootContainerInstance.updateQueue = null), - (rootContainerInstance.dependencies = null), - (rootContainerInstance.stateNode = null)) - : ((rootContainerInstance.childLanes = - updatePayload.childLanes), - (rootContainerInstance.lanes = updatePayload.lanes), + (rootContainerInstance.dependencies = null)) + : ((rootContainerInstance.childExpirationTime = + updatePayload.childExpirationTime), + (rootContainerInstance.expirationTime = + updatePayload.expirationTime), (rootContainerInstance.child = updatePayload.child), (rootContainerInstance.memoizedProps = updatePayload.memoizedProps), @@ -5214,15 +4836,15 @@ function completeWork(current, workInProgress, renderLanes) { updatePayload.memoizedState), (rootContainerInstance.updateQueue = updatePayload.updateQueue), - (rootContainerInstance.type = updatePayload.type), - (renderLanes = updatePayload.dependencies), + (renderExpirationTime = updatePayload.dependencies), (rootContainerInstance.dependencies = - null === renderLanes + null === renderExpirationTime ? null : { - lanes: renderLanes.lanes, - firstContext: renderLanes.firstContext, - responders: renderLanes.responders + expirationTime: + renderExpirationTime.expirationTime, + firstContext: renderExpirationTime.firstContext, + responders: renderExpirationTime.responders })), (newProps = newProps.sibling); push( @@ -5259,11 +4881,12 @@ function completeWork(current, workInProgress, renderLanes) { ); } else 2 * now() - newProps.renderingStartTime > newProps.tailExpiration && - 1073741824 !== renderLanes && + 1 < renderExpirationTime && ((workInProgress.effectTag |= 64), (rootContainerInstance = !0), cutOffTailIfNeeded(newProps, !1), - (workInProgress.lanes = renderLanes)); + (workInProgress.expirationTime = workInProgress.childExpirationTime = + renderExpirationTime - 1)); newProps.isBackwards ? ((updatePayload.sibling = workInProgress.child), (workInProgress.child = updatePayload)) @@ -5291,17 +4914,6 @@ function completeWork(current, workInProgress, renderLanes) { ), current) : null; - case 23: - case 24: - return ( - popRenderLanes(), - null !== current && - (null !== current.memoizedState) !== - (null !== workInProgress.memoizedState) && - "unstable-defer-without-hiding" !== newProps.mode && - (workInProgress.effectTag |= 4), - null - ); } throw Error( "Unknown unit of work tag (" + @@ -5322,7 +4934,6 @@ function unwindWork(workInProgress) { popHostContainer(); pop(didPerformWorkStackCursor); pop(contextStackCursor); - resetWorkInProgressVersions(); effectTag = workInProgress.effectTag; if (0 !== (effectTag & 64)) throw Error( @@ -5347,25 +4958,16 @@ function unwindWork(workInProgress) { return popHostContainer(), null; case 10: return popProvider(workInProgress), null; - case 23: - case 24: - return popRenderLanes(), null; default: return null; } } function createCapturedValue(value, source) { - try { - var info = "", - node = source; - do (info += describeFiber(node)), (node = node.return); - while (node); - var JSCompiler_inline_result = info; - } catch (x) { - JSCompiler_inline_result = - "\nError generating stack: " + x.message + "\n" + x.stack; - } - return { value: value, source: source, stack: JSCompiler_inline_result }; + return { + value: value, + source: source, + stack: getStackByFiberInDevAndProd(source) + }; } if ( "function" !== @@ -5374,61 +4976,51 @@ if ( throw Error( "Expected ReactFiberErrorDialog.showErrorDialog to be a function." ); -function logCapturedError(boundary, errorInfo) { +function logCapturedError(capturedError) { + !1 !== + ReactNativePrivateInterface.ReactFiberErrorDialog.showErrorDialog( + capturedError + ) && console.error(capturedError.error); +} +var PossiblyWeakSet = "function" === typeof WeakSet ? WeakSet : Set; +function logError(boundary, errorInfo) { + var source = errorInfo.source, + stack = errorInfo.stack; + null === stack && + null !== source && + (stack = getStackByFiberInDevAndProd(source)); + errorInfo = { + componentName: null !== source ? getComponentName(source.type) : null, + componentStack: null !== stack ? stack : "", + error: errorInfo.value, + errorBoundary: null, + errorBoundaryName: null, + errorBoundaryFound: !1, + willRetry: !1 + }; + null !== boundary && + 1 === boundary.tag && + ((errorInfo.errorBoundary = boundary.stateNode), + (errorInfo.errorBoundaryName = getComponentName(boundary.type)), + (errorInfo.errorBoundaryFound = !0), + (errorInfo.willRetry = !0)); try { - !1 !== - ReactNativePrivateInterface.ReactFiberErrorDialog.showErrorDialog({ - componentStack: null !== errorInfo.stack ? errorInfo.stack : "", - error: errorInfo.value, - errorBoundary: - null !== boundary && 1 === boundary.tag ? boundary.stateNode : null - }) && console.error(errorInfo.value); + logCapturedError(errorInfo); } catch (e) { setTimeout(function() { throw e; }); } } -var PossiblyWeakMap = "function" === typeof WeakMap ? WeakMap : Map; -function createRootErrorUpdate(fiber, errorInfo, lane) { - lane = createUpdate(-1, lane, null); - lane.tag = 3; - lane.payload = { element: null }; - var error = errorInfo.value; - lane.callback = function() { - hasUncaughtError || ((hasUncaughtError = !0), (firstUncaughtError = error)); - logCapturedError(fiber, errorInfo); - }; - return lane; -} -function createClassErrorUpdate(fiber, errorInfo, lane) { - lane = createUpdate(-1, lane, null); - lane.tag = 3; - var getDerivedStateFromError = fiber.type.getDerivedStateFromError; - if ("function" === typeof getDerivedStateFromError) { - var error = errorInfo.value; - lane.payload = function() { - logCapturedError(fiber, errorInfo); - return getDerivedStateFromError(error); - }; +function safelyCallComponentWillUnmount(current, instance) { + try { + (instance.props = current.memoizedProps), + (instance.state = current.memoizedState), + instance.componentWillUnmount(); + } catch (unmountError) { + captureCommitPhaseError(current, unmountError); } - var inst = fiber.stateNode; - null !== inst && - "function" === typeof inst.componentDidCatch && - (lane.callback = function() { - "function" !== typeof getDerivedStateFromError && - (null === legacyErrorBoundariesThatAlreadyFailed - ? (legacyErrorBoundariesThatAlreadyFailed = new Set([this])) - : legacyErrorBoundariesThatAlreadyFailed.add(this), - logCapturedError(fiber, errorInfo)); - var stack = errorInfo.stack; - this.componentDidCatch(errorInfo.value, { - componentStack: null !== stack ? stack : "" - }); - }); - return lane; } -var PossiblyWeakSet = "function" === typeof WeakSet ? WeakSet : Set; function safelyDetachRef(current) { var ref = current.ref; if (null !== ref) @@ -5462,7 +5054,6 @@ function commitBeforeMutationLifeCycles(current, finishedWork) { } return; case 3: - return; case 5: case 6: case 4: @@ -5473,57 +5064,58 @@ function commitBeforeMutationLifeCycles(current, finishedWork) { "This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue." ); } +function commitHookEffectListUnmount(tag, finishedWork) { + finishedWork = finishedWork.updateQueue; + finishedWork = null !== finishedWork ? finishedWork.lastEffect : null; + if (null !== finishedWork) { + var effect = (finishedWork = finishedWork.next); + do { + if ((effect.tag & tag) === tag) { + var destroy = effect.destroy; + effect.destroy = void 0; + void 0 !== destroy && destroy(); + } + effect = effect.next; + } while (effect !== finishedWork); + } +} +function commitHookEffectListMount(tag, finishedWork) { + finishedWork = finishedWork.updateQueue; + finishedWork = null !== finishedWork ? finishedWork.lastEffect : null; + if (null !== finishedWork) { + var effect = (finishedWork = finishedWork.next); + do { + if ((effect.tag & tag) === tag) { + var create = effect.create; + effect.destroy = create(); + } + effect = effect.next; + } while (effect !== finishedWork); + } +} function commitLifeCycles(finishedRoot, current, finishedWork) { switch (finishedWork.tag) { case 0: case 11: case 15: case 22: - current = finishedWork.updateQueue; - current = null !== current ? current.lastEffect : null; - if (null !== current) { - finishedRoot = current = current.next; - do { - if (3 === (finishedRoot.tag & 3)) { - var create$81 = finishedRoot.create; - finishedRoot.destroy = create$81(); - } - finishedRoot = finishedRoot.next; - } while (finishedRoot !== current); - } - current = finishedWork.updateQueue; - current = null !== current ? current.lastEffect : null; - if (null !== current) { - finishedRoot = current = current.next; - do { - var _effect = finishedRoot; - create$81 = _effect.next; - _effect = _effect.tag; - 0 !== (_effect & 4) && - 0 !== (_effect & 1) && - (enqueuePendingPassiveHookEffectUnmount(finishedWork, finishedRoot), - enqueuePendingPassiveHookEffectMount(finishedWork, finishedRoot)); - finishedRoot = create$81; - } while (finishedRoot !== current); - } + commitHookEffectListMount(3, finishedWork); return; case 1: finishedRoot = finishedWork.stateNode; - finishedWork.effectTag & 4 && - (null === current - ? finishedRoot.componentDidMount() - : ((create$81 = - finishedWork.elementType === finishedWork.type - ? current.memoizedProps - : resolveDefaultProps( - finishedWork.type, - current.memoizedProps - )), - finishedRoot.componentDidUpdate( - create$81, - current.memoizedState, - finishedRoot.__reactInternalSnapshotBeforeUpdate - ))); + if (finishedWork.effectTag & 4) + if (null === current) finishedRoot.componentDidMount(); + else { + var prevProps = + finishedWork.elementType === finishedWork.type + ? current.memoizedProps + : resolveDefaultProps(finishedWork.type, current.memoizedProps); + finishedRoot.componentDidUpdate( + prevProps, + current.memoizedState, + finishedRoot.__reactInternalSnapshotBeforeUpdate + ); + } current = finishedWork.updateQueue; null !== current && commitUpdateQueue(finishedWork, current, finishedRoot); @@ -5544,7 +5136,10 @@ function commitLifeCycles(finishedRoot, current, finishedWork) { } return; case 5: - null === current && finishedWork.effectTag & 4 && shim(); + if (null === current && finishedWork.effectTag & 4) + throw Error( + "The current renderer does not support mutation. This error is likely caused by a bug in React. Please file an issue." + ); return; case 6: return; @@ -5558,26 +5153,74 @@ function commitLifeCycles(finishedRoot, current, finishedWork) { case 17: case 20: case 21: - case 23: - case 24: return; } throw Error( "This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue." ); } -function detachFiberMutation(fiber) { - fiber.alternate = null; - fiber.child = null; - fiber.dependencies = null; - fiber.firstEffect = null; - fiber.lastEffect = null; - fiber.memoizedProps = null; - fiber.memoizedState = null; - fiber.pendingProps = null; - fiber.return = null; - fiber.stateNode = null; - fiber.updateQueue = null; +function commitUnmount(finishedRoot, current$jscomp$0, renderPriorityLevel) { + "function" === typeof onCommitFiberUnmount && + onCommitFiberUnmount(current$jscomp$0); + switch (current$jscomp$0.tag) { + case 0: + case 11: + case 14: + case 15: + case 22: + finishedRoot = current$jscomp$0.updateQueue; + if ( + null !== finishedRoot && + ((finishedRoot = finishedRoot.lastEffect), null !== finishedRoot) + ) { + var firstEffect = finishedRoot.next; + runWithPriority( + 97 < renderPriorityLevel ? 97 : renderPriorityLevel, + function() { + var effect = firstEffect; + do { + var _destroy = effect.destroy; + if (void 0 !== _destroy) { + var current = current$jscomp$0; + try { + _destroy(); + } catch (error) { + captureCommitPhaseError(current, error); + } + } + effect = effect.next; + } while (effect !== firstEffect); + } + ); + } + break; + case 1: + safelyDetachRef(current$jscomp$0); + renderPriorityLevel = current$jscomp$0.stateNode; + "function" === typeof renderPriorityLevel.componentWillUnmount && + safelyCallComponentWillUnmount(current$jscomp$0, renderPriorityLevel); + break; + case 5: + safelyDetachRef(current$jscomp$0); + break; + case 4: + createChildNodeSet(current$jscomp$0.stateNode.containerInfo); + } +} +function detachFiber(current) { + var alternate = current.alternate; + current.return = null; + current.child = null; + current.memoizedState = null; + current.updateQueue = null; + current.dependencies = null; + current.alternate = null; + current.firstEffect = null; + current.lastEffect = null; + current.pendingProps = null; + current.memoizedProps = null; + current.stateNode = null; + null !== alternate && detachFiber(alternate); } function commitWork(current, finishedWork) { switch (finishedWork.tag) { @@ -5586,19 +5229,7 @@ function commitWork(current, finishedWork) { case 14: case 15: case 22: - current = finishedWork.updateQueue; - current = null !== current ? current.lastEffect : null; - if (null !== current) { - finishedWork = current = current.next; - do { - if (3 === (finishedWork.tag & 3)) { - var destroy = finishedWork.destroy; - finishedWork.destroy = void 0; - void 0 !== destroy && destroy(); - } - finishedWork = finishedWork.next; - } while (finishedWork !== current); - } + commitHookEffectListUnmount(3, finishedWork); return; case 12: return; @@ -5610,9 +5241,6 @@ function commitWork(current, finishedWork) { case 19: attachSuspenseRetryListeners(finishedWork); return; - case 23: - case 24: - return; } a: { switch (finishedWork.tag) { @@ -5631,46 +5259,84 @@ function commitWork(current, finishedWork) { } } function attachSuspenseRetryListeners(finishedWork) { - var wakeables = finishedWork.updateQueue; - if (null !== wakeables) { + var thenables = finishedWork.updateQueue; + if (null !== thenables) { finishedWork.updateQueue = null; var retryCache = finishedWork.stateNode; null === retryCache && (retryCache = finishedWork.stateNode = new PossiblyWeakSet()); - wakeables.forEach(function(wakeable) { - var retry = resolveRetryWakeable.bind(null, finishedWork, wakeable); - retryCache.has(wakeable) || - (retryCache.add(wakeable), wakeable.then(retry, retry)); + thenables.forEach(function(thenable) { + var retry = resolveRetryThenable.bind(null, finishedWork, thenable); + retryCache.has(thenable) || + (retryCache.add(thenable), thenable.then(retry, retry)); }); } } -function isSuspenseBoundaryBeingHidden(current, finishedWork) { - return null !== current && - ((current = current.memoizedState), - null === current || null !== current.dehydrated) - ? ((finishedWork = finishedWork.memoizedState), - null !== finishedWork && null === finishedWork.dehydrated) - : !1; +var PossiblyWeakMap = "function" === typeof WeakMap ? WeakMap : Map; +function createRootErrorUpdate(fiber, errorInfo, expirationTime) { + expirationTime = createUpdate(expirationTime, null); + expirationTime.tag = 3; + expirationTime.payload = { element: null }; + var error = errorInfo.value; + expirationTime.callback = function() { + hasUncaughtError || ((hasUncaughtError = !0), (firstUncaughtError = error)); + logError(fiber, errorInfo); + }; + return expirationTime; +} +function createClassErrorUpdate(fiber, errorInfo, expirationTime) { + expirationTime = createUpdate(expirationTime, null); + expirationTime.tag = 3; + var getDerivedStateFromError = fiber.type.getDerivedStateFromError; + if ("function" === typeof getDerivedStateFromError) { + var error = errorInfo.value; + expirationTime.payload = function() { + logError(fiber, errorInfo); + return getDerivedStateFromError(error); + }; + } + var inst = fiber.stateNode; + null !== inst && + "function" === typeof inst.componentDidCatch && + (expirationTime.callback = function() { + "function" !== typeof getDerivedStateFromError && + (null === legacyErrorBoundariesThatAlreadyFailed + ? (legacyErrorBoundariesThatAlreadyFailed = new Set([this])) + : legacyErrorBoundariesThatAlreadyFailed.add(this), + logError(fiber, errorInfo)); + var stack = errorInfo.stack; + this.componentDidCatch(errorInfo.value, { + componentStack: null !== stack ? stack : "" + }); + }); + return expirationTime; } var ceil = Math.ceil, - ReactCurrentDispatcher$2 = ReactSharedInternals.ReactCurrentDispatcher, + ReactCurrentDispatcher$1 = ReactSharedInternals.ReactCurrentDispatcher, ReactCurrentOwner$2 = ReactSharedInternals.ReactCurrentOwner, - executionContext = 0, + NoContext = 0, + LegacyUnbatchedContext = 8, + RenderContext = 16, + CommitContext = 32, + RootIncomplete = 0, + RootFatalErrored = 1, + RootErrored = 2, + RootSuspended = 3, + RootSuspendedWithDelay = 4, + RootCompleted = 5, + executionContext = NoContext, workInProgressRoot = null, workInProgress = null, - workInProgressRootRenderLanes = 0, - subtreeRenderLanes = 0, - subtreeRenderLanesCursor = createCursor(0), - workInProgressRootExitStatus = 0, + renderExpirationTime$1 = 0, + workInProgressRootExitStatus = RootIncomplete, workInProgressRootFatalError = null, - workInProgressRootLatestSuspenseTimeout = -1, + workInProgressRootLatestProcessedExpirationTime = 1073741823, + workInProgressRootLatestSuspenseTimeout = 1073741823, workInProgressRootCanSuspendUsingConfig = null, - workInProgressRootIncludedLanes = 0, - workInProgressRootSkippedLanes = 0, - workInProgressRootUpdatedLanes = 0, - workInProgressRootPingedLanes = 0, - mostRecentlyUpdatedRoot = null, + workInProgressRootNextUnprocessedUpdateTime = 0, + workInProgressRootHasPendingPing = !1, globalMostRecentFallbackTime = 0, + FALLBACK_THROTTLE_MS = 500, nextEffect = null, hasUncaughtError = !1, firstUncaughtError = null, @@ -5678,200 +5344,205 @@ var ceil = Math.ceil, rootDoesHavePassiveEffects = !1, rootWithPendingPassiveEffects = null, pendingPassiveEffectsRenderPriority = 90, - pendingPassiveHookEffectsMount = [], - pendingPassiveHookEffectsUnmount = [], rootsWithPendingDiscreteUpdates = null, nestedUpdateCount = 0, rootWithNestedUpdates = null, - currentEventTime = -1, - currentEventWipLanes = 0, - currentEventPendingLanes = 0, - focusedInstanceHandle = null, - shouldFireAfterActiveInstanceBlur = !1; -function requestEventTime() { - return 0 !== (executionContext & 48) - ? now() - : -1 !== currentEventTime + currentEventTime = 0; +function requestCurrentTimeForUpdate() { + return (executionContext & (RenderContext | CommitContext)) !== NoContext + ? 1073741821 - ((now() / 10) | 0) + : 0 !== currentEventTime ? currentEventTime - : (currentEventTime = now()); + : (currentEventTime = 1073741821 - ((now() / 10) | 0)); } -function requestUpdateLane(fiber, suspenseConfig) { +function computeExpirationForFiber(currentTime, fiber, suspenseConfig) { fiber = fiber.mode; - if (0 === (fiber & 2)) return 1; - if (0 === (fiber & 4)) return 99 === getCurrentPriorityLevel() ? 1 : 2; - 0 === currentEventWipLanes && - (currentEventWipLanes = workInProgressRootIncludedLanes); - if (null !== suspenseConfig) { - suspenseConfig = suspenseConfig.timeoutMs; - fiber = void 0 === suspenseConfig || 1e4 > (suspenseConfig | 0) ? 8 : 6; - 0 !== currentEventPendingLanes && - (currentEventPendingLanes = - null !== mostRecentlyUpdatedRoot - ? mostRecentlyUpdatedRoot.pendingLanes - : 0); - suspenseConfig = currentEventWipLanes; - var pendingLanes = currentEventPendingLanes; - if (8 === fiber) - (fiber = pickArbitraryLane(122880 & ~pendingLanes)), - 0 === fiber && - ((fiber = pickArbitraryLane(122880 & ~suspenseConfig)), - 0 === fiber && (fiber = 8192)), - (suspenseConfig = fiber); - else if (6 === fiber) - (fiber = pickArbitraryLane(3932160 & ~pendingLanes)), - 0 === fiber && - ((fiber = pickArbitraryLane(3932160 & ~suspenseConfig)), - 0 === fiber && (fiber = 262144)), - (suspenseConfig = fiber); - else - throw Error( - "Invalid transition priority: " + fiber + ". This is a bug in React." - ); - return suspenseConfig; - } - suspenseConfig = getCurrentPriorityLevel(); - 0 !== (executionContext & 4) && 98 === suspenseConfig - ? (suspenseConfig = findUpdateLane(14, currentEventWipLanes)) - : ((suspenseConfig = schedulerPriorityToLanePriority(suspenseConfig)), - (suspenseConfig = findUpdateLane(suspenseConfig, currentEventWipLanes))); - return suspenseConfig; + if (0 === (fiber & 2)) return 1073741823; + var priorityLevel = getCurrentPriorityLevel(); + if (0 === (fiber & 4)) return 99 === priorityLevel ? 1073741823 : 1073741822; + if ((executionContext & RenderContext) !== NoContext) + return renderExpirationTime$1; + if (null !== suspenseConfig) + currentTime = + 1073741821 - + 25 * + ((((1073741821 - + currentTime + + (suspenseConfig.timeoutMs | 0 || 5e3) / 10) / + 25) | + 0) + + 1); + else + switch (priorityLevel) { + case 99: + currentTime = 1073741823; + break; + case 98: + currentTime = + 1073741821 - 10 * ((((1073741821 - currentTime + 15) / 10) | 0) + 1); + break; + case 97: + case 96: + currentTime = + 1073741821 - 25 * ((((1073741821 - currentTime + 500) / 25) | 0) + 1); + break; + case 95: + currentTime = 2; + break; + default: + throw Error("Expected a valid priority level"); + } + null !== workInProgressRoot && + currentTime === renderExpirationTime$1 && + --currentTime; + return currentTime; } -function scheduleUpdateOnFiber(fiber, lane, eventTime) { +function scheduleWork(fiber, expirationTime) { if (50 < nestedUpdateCount) throw ((nestedUpdateCount = 0), (rootWithNestedUpdates = null), Error( "Maximum update depth exceeded. This can happen when a component repeatedly calls setState inside componentWillUpdate or componentDidUpdate. React limits the number of nested updates to prevent infinite loops." )); - fiber = markUpdateLaneFromFiberToRoot(fiber, lane); - if (null === fiber) return null; - markRootUpdated(fiber, lane, eventTime); - fiber === workInProgressRoot && - ((workInProgressRootUpdatedLanes |= lane), - 4 === workInProgressRootExitStatus && - markRootSuspended$1(fiber, workInProgressRootRenderLanes)); - var priorityLevel = getCurrentPriorityLevel(); - 1 === lane - ? 0 !== (executionContext & 8) && 0 === (executionContext & 48) - ? performSyncWorkOnRoot(fiber) - : (ensureRootIsScheduled(fiber, eventTime), - 0 === executionContext && flushSyncCallbackQueue()) - : (0 === (executionContext & 4) || - (98 !== priorityLevel && 99 !== priorityLevel) || - (null === rootsWithPendingDiscreteUpdates - ? (rootsWithPendingDiscreteUpdates = new Set([fiber])) - : rootsWithPendingDiscreteUpdates.add(fiber)), - ensureRootIsScheduled(fiber, eventTime)); - mostRecentlyUpdatedRoot = fiber; -} -function markUpdateLaneFromFiberToRoot(sourceFiber, lane) { - sourceFiber.lanes |= lane; - var alternate = sourceFiber.alternate; - null !== alternate && (alternate.lanes |= lane); - alternate = sourceFiber; - for (sourceFiber = sourceFiber.return; null !== sourceFiber; ) - (sourceFiber.childLanes |= lane), - (alternate = sourceFiber.alternate), - null !== alternate && (alternate.childLanes |= lane), - (alternate = sourceFiber), - (sourceFiber = sourceFiber.return); - return 3 === alternate.tag ? alternate.stateNode : null; -} -function ensureRootIsScheduled(root, currentTime) { - for ( - var existingCallbackNode = root.callbackNode, - suspendedLanes = root.suspendedLanes, - pingedLanes = root.pingedLanes, - expirationTimes = root.expirationTimes, - lanes = root.pendingLanes; - 0 < lanes; - - ) { - var index$5 = 31 - clz32(lanes), - lane = 1 << index$5, - expirationTime = expirationTimes[index$5]; - if (-1 === expirationTime) { - if (0 === (lane & suspendedLanes) || 0 !== (lane & pingedLanes)) { - expirationTime = currentTime; - getHighestPriorityLanes(lane); - var priority = return_highestLanePriority; - expirationTimes[index$5] = - 12 <= priority - ? expirationTime + 1e3 - : 6 <= priority - ? expirationTime + 5e3 - : -1; - } - } else expirationTime <= currentTime && (root.expiredLanes |= lane); - lanes &= ~lane; + fiber = markUpdateTimeFromFiberToRoot(fiber, expirationTime); + if (null !== fiber) { + var priorityLevel = getCurrentPriorityLevel(); + 1073741823 === expirationTime + ? (executionContext & LegacyUnbatchedContext) !== NoContext && + (executionContext & (RenderContext | CommitContext)) === NoContext + ? performSyncWorkOnRoot(fiber) + : (ensureRootIsScheduled(fiber), + executionContext === NoContext && flushSyncCallbackQueue()) + : ensureRootIsScheduled(fiber); + (executionContext & 4) === NoContext || + (98 !== priorityLevel && 99 !== priorityLevel) || + (null === rootsWithPendingDiscreteUpdates + ? (rootsWithPendingDiscreteUpdates = new Map([[fiber, expirationTime]])) + : ((priorityLevel = rootsWithPendingDiscreteUpdates.get(fiber)), + (void 0 === priorityLevel || priorityLevel > expirationTime) && + rootsWithPendingDiscreteUpdates.set(fiber, expirationTime))); } - suspendedLanes = getNextLanes( - root, - root === workInProgressRoot ? workInProgressRootRenderLanes : 0 - ); - currentTime = return_highestLanePriority; - if (0 === suspendedLanes) - null !== existingCallbackNode && - (existingCallbackNode !== fakeCallbackNode && - Scheduler_cancelCallback(existingCallbackNode), - (root.callbackNode = null), - (root.callbackPriority = 0)); +} +function markUpdateTimeFromFiberToRoot(fiber, expirationTime) { + fiber.expirationTime < expirationTime && + (fiber.expirationTime = expirationTime); + var alternate = fiber.alternate; + null !== alternate && + alternate.expirationTime < expirationTime && + (alternate.expirationTime = expirationTime); + var node = fiber.return, + root = null; + if (null === node && 3 === fiber.tag) root = fiber.stateNode; + else + for (; null !== node; ) { + alternate = node.alternate; + node.childExpirationTime < expirationTime && + (node.childExpirationTime = expirationTime); + null !== alternate && + alternate.childExpirationTime < expirationTime && + (alternate.childExpirationTime = expirationTime); + if (null === node.return && 3 === node.tag) { + root = node.stateNode; + break; + } + node = node.return; + } + null !== root && + (workInProgressRoot === root && + (markUnprocessedUpdateTime(expirationTime), + workInProgressRootExitStatus === RootSuspendedWithDelay && + markRootSuspendedAtTime(root, renderExpirationTime$1)), + markRootUpdatedAtTime(root, expirationTime)); + return root; +} +function getNextRootExpirationTimeToWorkOn(root) { + var lastExpiredTime = root.lastExpiredTime; + if (0 !== lastExpiredTime) return lastExpiredTime; + lastExpiredTime = root.firstPendingTime; + if (!isRootSuspendedAtTime(root, lastExpiredTime)) return lastExpiredTime; + var lastPingedTime = root.lastPingedTime; + root = root.nextKnownPendingLevel; + root = lastPingedTime > root ? lastPingedTime : root; + return 2 >= root && lastExpiredTime !== root ? 0 : root; +} +function ensureRootIsScheduled(root) { + if (0 !== root.lastExpiredTime) + (root.callbackExpirationTime = 1073741823), + (root.callbackPriority = 99), + (root.callbackNode = scheduleSyncCallback( + performSyncWorkOnRoot.bind(null, root) + )); else { - if (null !== existingCallbackNode) { - if (root.callbackPriority === currentTime) return; - existingCallbackNode !== fakeCallbackNode && - Scheduler_cancelCallback(existingCallbackNode); + var expirationTime = getNextRootExpirationTimeToWorkOn(root), + existingCallbackNode = root.callbackNode; + if (0 === expirationTime) + null !== existingCallbackNode && + ((root.callbackNode = null), + (root.callbackExpirationTime = 0), + (root.callbackPriority = 90)); + else { + var priorityLevel = requestCurrentTimeForUpdate(); + 1073741823 === expirationTime + ? (priorityLevel = 99) + : 1 === expirationTime || 2 === expirationTime + ? (priorityLevel = 95) + : ((priorityLevel = + 10 * (1073741821 - expirationTime) - + 10 * (1073741821 - priorityLevel)), + (priorityLevel = + 0 >= priorityLevel + ? 99 + : 250 >= priorityLevel + ? 98 + : 5250 >= priorityLevel + ? 97 + : 95)); + if (null !== existingCallbackNode) { + var existingCallbackPriority = root.callbackPriority; + if ( + root.callbackExpirationTime === expirationTime && + existingCallbackPriority >= priorityLevel + ) + return; + existingCallbackNode !== fakeCallbackNode && + Scheduler_cancelCallback(existingCallbackNode); + } + root.callbackExpirationTime = expirationTime; + root.callbackPriority = priorityLevel; + expirationTime = + 1073741823 === expirationTime + ? scheduleSyncCallback(performSyncWorkOnRoot.bind(null, root)) + : scheduleCallback( + priorityLevel, + performConcurrentWorkOnRoot.bind(null, root), + { timeout: 10 * (1073741821 - expirationTime) - now() } + ); + root.callbackNode = expirationTime; } - 17 === currentTime - ? ((existingCallbackNode = performSyncWorkOnRoot.bind(null, root)), - null === syncQueue - ? ((syncQueue = [existingCallbackNode]), - (immediateQueueCallbackNode = Scheduler_scheduleCallback( - Scheduler_ImmediatePriority, - flushSyncCallbackQueueImpl - ))) - : syncQueue.push(existingCallbackNode), - (existingCallbackNode = fakeCallbackNode)) - : 16 === currentTime - ? (existingCallbackNode = scheduleCallback( - 99, - performSyncWorkOnRoot.bind(null, root) - )) - : ((existingCallbackNode = lanePriorityToSchedulerPriority(currentTime)), - (existingCallbackNode = scheduleCallback( - existingCallbackNode, - performConcurrentWorkOnRoot.bind(null, root) - ))); - root.callbackPriority = currentTime; - root.callbackNode = existingCallbackNode; } } function performConcurrentWorkOnRoot(root, didTimeout) { - currentEventTime = -1; - currentEventPendingLanes = currentEventWipLanes = 0; - if (0 !== (executionContext & 48)) - throw Error("Should not already be working."); - var originalCallbackNode = root.callbackNode; - if (flushPassiveEffects() && root.callbackNode !== originalCallbackNode) + currentEventTime = 0; + if (didTimeout) { + didTimeout = requestCurrentTimeForUpdate(); + var lastExpiredTime = root.lastExpiredTime; + if (0 === lastExpiredTime || lastExpiredTime > didTimeout) + root.lastExpiredTime = didTimeout; + ensureRootIsScheduled(root); return null; - var lanes = getNextLanes( - root, - root === workInProgressRoot ? workInProgressRootRenderLanes : 0 - ); - if (0 === lanes) return null; - if (didTimeout) - return ( - (root.expiredLanes |= lanes & root.pendingLanes), - ensureRootIsScheduled(root, now()), - null - ); - didTimeout = lanes; - var prevExecutionContext = executionContext; - executionContext |= 16; + } + lastExpiredTime = getNextRootExpirationTimeToWorkOn(root); + if (0 === lastExpiredTime) return null; + didTimeout = root.callbackNode; + if ((executionContext & (RenderContext | CommitContext)) !== NoContext) + throw Error("Should not already be working."); + flushPassiveEffects(); + var expirationTime = lastExpiredTime; + var exitStatus = executionContext; + executionContext |= RenderContext; var prevDispatcher = pushDispatcher(); - (workInProgressRoot === root && - workInProgressRootRenderLanes === didTimeout) || - prepareFreshStack(root, didTimeout); + (root === workInProgressRoot && expirationTime === renderExpirationTime$1) || + prepareFreshStack(root, expirationTime); do try { workLoopConcurrent(); @@ -5881,189 +5552,199 @@ function performConcurrentWorkOnRoot(root, didTimeout) { } while (1); resetContextDependencies(); - ReactCurrentDispatcher$2.current = prevDispatcher; - executionContext = prevExecutionContext; + ReactCurrentDispatcher$1.current = prevDispatcher; + executionContext = exitStatus; null !== workInProgress - ? (didTimeout = 0) + ? (exitStatus = RootIncomplete) : ((workInProgressRoot = null), - (workInProgressRootRenderLanes = 0), - (didTimeout = workInProgressRootExitStatus)); - if (0 !== (workInProgressRootIncludedLanes & workInProgressRootUpdatedLanes)) - prepareFreshStack(root, 0); - else if (0 !== didTimeout) { - 2 === didTimeout && - ((executionContext |= 64), - root.hydrate && ((root.hydrate = !1), shim(root.containerInfo)), - (lanes = getLanesToRetrySynchronouslyOnError(root)), - 0 !== lanes && (didTimeout = renderRootSync(root, lanes))); - if (1 === didTimeout) - throw ((originalCallbackNode = workInProgressRootFatalError), - prepareFreshStack(root, 0), - markRootSuspended$1(root, lanes), - ensureRootIsScheduled(root, now()), - originalCallbackNode); - root.finishedWork = root.current.alternate; - root.finishedLanes = lanes; - switch (didTimeout) { - case 0: - case 1: + (exitStatus = workInProgressRootExitStatus)); + if (exitStatus !== RootIncomplete) { + exitStatus === RootErrored && + ((lastExpiredTime = 2 < lastExpiredTime ? 2 : lastExpiredTime), + (exitStatus = renderRootSync(root, lastExpiredTime))); + if (exitStatus === RootFatalErrored) + throw ((didTimeout = workInProgressRootFatalError), + prepareFreshStack(root, lastExpiredTime), + markRootSuspendedAtTime(root, lastExpiredTime), + ensureRootIsScheduled(root), + didTimeout); + expirationTime = root.finishedWork = root.current.alternate; + root.finishedExpirationTime = lastExpiredTime; + switch (exitStatus) { + case RootIncomplete: + case RootFatalErrored: throw Error("Root did not complete. This is a bug in React."); - case 2: + case RootErrored: commitRoot(root); break; - case 3: - markRootSuspended$1(root, lanes); + case RootSuspended: + markRootSuspendedAtTime(root, lastExpiredTime); + exitStatus = root.lastSuspendedTime; + lastExpiredTime === exitStatus && + (root.nextKnownPendingLevel = getRemainingExpirationTime( + expirationTime + )); if ( - (lanes & 62914560) === lanes && - ((didTimeout = globalMostRecentFallbackTime + 500 - now()), - 10 < didTimeout) + 1073741823 === workInProgressRootLatestProcessedExpirationTime && + ((expirationTime = + globalMostRecentFallbackTime + FALLBACK_THROTTLE_MS - now()), + 10 < expirationTime) ) { - if (0 !== getNextLanes(root, 0)) break; - prevExecutionContext = root.suspendedLanes; - if ((prevExecutionContext & lanes) !== lanes) { - requestEventTime(); - root.pingedLanes |= root.suspendedLanes & prevExecutionContext; + if ( + workInProgressRootHasPendingPing && + ((prevDispatcher = root.lastPingedTime), + 0 === prevDispatcher || prevDispatcher >= lastExpiredTime) + ) { + root.lastPingedTime = lastExpiredTime; + prepareFreshStack(root, lastExpiredTime); + break; + } + prevDispatcher = getNextRootExpirationTimeToWorkOn(root); + if (0 !== prevDispatcher && prevDispatcher !== lastExpiredTime) break; + if (0 !== exitStatus && exitStatus !== lastExpiredTime) { + root.lastPingedTime = exitStatus; break; } root.timeoutHandle = scheduleTimeout( commitRoot.bind(null, root), - didTimeout + expirationTime ); break; } commitRoot(root); break; - case 4: - markRootSuspended$1(root, lanes); - if (0 !== getNextLanes(root, 0)) break; - didTimeout = root.suspendedLanes; - if ((didTimeout & lanes) !== lanes) { - requestEventTime(); - root.pingedLanes |= root.suspendedLanes & didTimeout; - break; - } - lanes = getMostRecentEventTime(root, lanes); - -1 !== workInProgressRootLatestSuspenseTimeout - ? (lanes = workInProgressRootLatestSuspenseTimeout - now()) - : -1 === lanes - ? (lanes = 0) - : ((lanes = now() - lanes), - (lanes = - (120 > lanes - ? 120 - : 480 > lanes - ? 480 - : 1080 > lanes - ? 1080 - : 1920 > lanes - ? 1920 - : 3e3 > lanes - ? 3e3 - : 4320 > lanes - ? 4320 - : 1960 * ceil(lanes / 1960)) - lanes)); - if (10 < lanes) { - root.timeoutHandle = scheduleTimeout( - commitRoot.bind(null, root), - lanes - ); - break; - } - commitRoot(root); - break; - case 5: - prevDispatcher = getMostRecentEventTime(root, lanes); + case RootSuspendedWithDelay: + markRootSuspendedAtTime(root, lastExpiredTime); + exitStatus = root.lastSuspendedTime; + lastExpiredTime === exitStatus && + (root.nextKnownPendingLevel = getRemainingExpirationTime( + expirationTime + )); if ( - -1 !== prevDispatcher && - null !== workInProgressRootCanSuspendUsingConfig && - ((didTimeout = - workInProgressRootCanSuspendUsingConfig.busyMinDurationMs | 0), - 0 >= didTimeout - ? (didTimeout = 0) - : ((prevExecutionContext = - workInProgressRootCanSuspendUsingConfig.busyDelayMs | 0), - (prevDispatcher = now() - prevDispatcher), - (didTimeout = - prevDispatcher <= prevExecutionContext - ? 0 - : prevExecutionContext + didTimeout - prevDispatcher)), - 10 < didTimeout) + workInProgressRootHasPendingPing && + ((expirationTime = root.lastPingedTime), + 0 === expirationTime || expirationTime >= lastExpiredTime) ) { - markRootSuspended$1(root, lanes); + root.lastPingedTime = lastExpiredTime; + prepareFreshStack(root, lastExpiredTime); + break; + } + expirationTime = getNextRootExpirationTimeToWorkOn(root); + if (0 !== expirationTime && expirationTime !== lastExpiredTime) break; + if (0 !== exitStatus && exitStatus !== lastExpiredTime) { + root.lastPingedTime = exitStatus; + break; + } + 1073741823 !== workInProgressRootLatestSuspenseTimeout + ? (expirationTime = + 10 * (1073741821 - workInProgressRootLatestSuspenseTimeout) - + now()) + : 1073741823 === workInProgressRootLatestProcessedExpirationTime + ? (expirationTime = 0) + : ((expirationTime = + 10 * + (1073741821 - workInProgressRootLatestProcessedExpirationTime) - + 5e3), + (exitStatus = now()), + (lastExpiredTime = + 10 * (1073741821 - lastExpiredTime) - exitStatus), + (expirationTime = exitStatus - expirationTime), + 0 > expirationTime && (expirationTime = 0), + (expirationTime = + (120 > expirationTime + ? 120 + : 480 > expirationTime + ? 480 + : 1080 > expirationTime + ? 1080 + : 1920 > expirationTime + ? 1920 + : 3e3 > expirationTime + ? 3e3 + : 4320 > expirationTime + ? 4320 + : 1960 * ceil(expirationTime / 1960)) - expirationTime), + lastExpiredTime < expirationTime && + (expirationTime = lastExpiredTime)); + if (10 < expirationTime) { root.timeoutHandle = scheduleTimeout( commitRoot.bind(null, root), - didTimeout + expirationTime ); break; } commitRoot(root); break; + case RootCompleted: + if ( + 1073741823 !== workInProgressRootLatestProcessedExpirationTime && + null !== workInProgressRootCanSuspendUsingConfig + ) { + prevDispatcher = workInProgressRootLatestProcessedExpirationTime; + var suspenseConfig = workInProgressRootCanSuspendUsingConfig; + expirationTime = suspenseConfig.busyMinDurationMs | 0; + 0 >= expirationTime + ? (expirationTime = 0) + : ((exitStatus = suspenseConfig.busyDelayMs | 0), + (prevDispatcher = + now() - + (10 * (1073741821 - prevDispatcher) - + (suspenseConfig.timeoutMs | 0 || 5e3))), + (expirationTime = + prevDispatcher <= exitStatus + ? 0 + : exitStatus + expirationTime - prevDispatcher)); + if (10 < expirationTime) { + markRootSuspendedAtTime(root, lastExpiredTime); + root.timeoutHandle = scheduleTimeout( + commitRoot.bind(null, root), + expirationTime + ); + break; + } + } + commitRoot(root); + break; default: throw Error("Unknown root exit status."); } } - ensureRootIsScheduled(root, now()); - return root.callbackNode === originalCallbackNode + ensureRootIsScheduled(root); + return root.callbackNode === didTimeout ? performConcurrentWorkOnRoot.bind(null, root) : null; } -function markRootSuspended$1(root, suspendedLanes) { - suspendedLanes &= ~workInProgressRootPingedLanes; - suspendedLanes &= ~workInProgressRootUpdatedLanes; - root.suspendedLanes |= suspendedLanes; - root.pingedLanes &= ~suspendedLanes; - for (root = root.expirationTimes; 0 < suspendedLanes; ) { - var index$10 = 31 - clz32(suspendedLanes), - lane = 1 << index$10; - root[index$10] = -1; - suspendedLanes &= ~lane; - } -} function performSyncWorkOnRoot(root) { - if (0 !== (executionContext & 48)) + if ((executionContext & (RenderContext | CommitContext)) !== NoContext) throw Error("Should not already be working."); flushPassiveEffects(); - if ( - root === workInProgressRoot && - 0 !== (root.expiredLanes & workInProgressRootRenderLanes) - ) { - var lanes = workInProgressRootRenderLanes; - var exitStatus = renderRootSync(root, lanes); - 0 !== (workInProgressRootIncludedLanes & workInProgressRootUpdatedLanes) && - ((lanes = getNextLanes(root, lanes)), - (exitStatus = renderRootSync(root, lanes))); - } else - (lanes = getNextLanes(root, 0)), (exitStatus = renderRootSync(root, lanes)); + var lastExpiredTime = root.lastExpiredTime; + lastExpiredTime = + 0 !== lastExpiredTime + ? root === workInProgressRoot && renderExpirationTime$1 >= lastExpiredTime + ? renderExpirationTime$1 + : lastExpiredTime + : 1073741823; + var exitStatus = renderRootSync(root, lastExpiredTime); 0 !== root.tag && - 2 === exitStatus && - ((executionContext |= 64), - root.hydrate && ((root.hydrate = !1), shim(root.containerInfo)), - (lanes = getLanesToRetrySynchronouslyOnError(root)), - 0 !== lanes && (exitStatus = renderRootSync(root, lanes))); - if (1 === exitStatus) + exitStatus === RootErrored && + ((lastExpiredTime = 2 < lastExpiredTime ? 2 : lastExpiredTime), + (exitStatus = renderRootSync(root, lastExpiredTime))); + if (exitStatus === RootFatalErrored) throw ((exitStatus = workInProgressRootFatalError), - prepareFreshStack(root, 0), - markRootSuspended$1(root, lanes), - ensureRootIsScheduled(root, now()), + prepareFreshStack(root, lastExpiredTime), + markRootSuspendedAtTime(root, lastExpiredTime), + ensureRootIsScheduled(root), exitStatus); root.finishedWork = root.current.alternate; - root.finishedLanes = lanes; + root.finishedExpirationTime = lastExpiredTime; commitRoot(root); - ensureRootIsScheduled(root, now()); + ensureRootIsScheduled(root); return null; } -function pushRenderLanes(fiber, lanes) { - push(subtreeRenderLanesCursor, subtreeRenderLanes); - subtreeRenderLanes |= lanes; - workInProgressRootIncludedLanes |= lanes; -} -function popRenderLanes() { - subtreeRenderLanes = subtreeRenderLanesCursor.current; - pop(subtreeRenderLanesCursor); -} -function prepareFreshStack(root, lanes) { +function prepareFreshStack(root, expirationTime) { root.finishedWork = null; - root.finishedLanes = 0; + root.finishedExpirationTime = 0; var timeoutHandle = root.timeoutHandle; -1 !== timeoutHandle && ((root.timeoutHandle = -1), cancelTimeout(timeoutHandle)); @@ -6081,7 +5762,6 @@ function prepareFreshStack(root, lanes) { popHostContainer(); pop(didPerformWorkStackCursor); pop(contextStackCursor); - resetWorkInProgressVersions(); break; case 5: popHostContext(interruptedWork); @@ -6097,29 +5777,25 @@ function prepareFreshStack(root, lanes) { break; case 10: popProvider(interruptedWork); - break; - case 23: - case 24: - popRenderLanes(); } timeoutHandle = timeoutHandle.return; } workInProgressRoot = root; workInProgress = createWorkInProgress(root.current, null); - workInProgressRootRenderLanes = subtreeRenderLanes = workInProgressRootIncludedLanes = lanes; - workInProgressRootExitStatus = 0; + renderExpirationTime$1 = expirationTime; + workInProgressRootExitStatus = RootIncomplete; workInProgressRootFatalError = null; - workInProgressRootLatestSuspenseTimeout = -1; + workInProgressRootLatestSuspenseTimeout = workInProgressRootLatestProcessedExpirationTime = 1073741823; workInProgressRootCanSuspendUsingConfig = null; - workInProgressRootPingedLanes = workInProgressRootUpdatedLanes = workInProgressRootSkippedLanes = 0; + workInProgressRootNextUnprocessedUpdateTime = 0; + workInProgressRootHasPendingPing = !1; } function handleError(root$jscomp$0, thrownValue) { do { - var erroredWork = workInProgress; try { resetContextDependencies(); - ReactCurrentDispatcher$1.current = ContextOnlyDispatcher; - if (didScheduleRenderPhaseUpdate) { + ReactCurrentDispatcher.current = ContextOnlyDispatcher; + if (didScheduleRenderPhaseUpdate) for ( var hook = currentlyRenderingFiber$1.memoizedState; null !== hook; @@ -6129,24 +5805,21 @@ function handleError(root$jscomp$0, thrownValue) { null !== queue && (queue.pending = null); hook = hook.next; } - didScheduleRenderPhaseUpdate = !1; - } - renderLanes = 0; + renderExpirationTime = 0; workInProgressHook = currentHook = currentlyRenderingFiber$1 = null; - didScheduleRenderPhaseUpdateDuringThisPass = !1; - ReactCurrentOwner$2.current = null; - if (null === erroredWork || null === erroredWork.return) { - workInProgressRootExitStatus = 1; - workInProgressRootFatalError = thrownValue; - workInProgress = null; - break; - } + didScheduleRenderPhaseUpdate = !1; + if (null === workInProgress || null === workInProgress.return) + return ( + (workInProgressRootExitStatus = RootFatalErrored), + (workInProgressRootFatalError = thrownValue), + (workInProgress = null) + ); a: { var root = root$jscomp$0, - returnFiber = erroredWork.return, - sourceFiber = erroredWork, + returnFiber = workInProgress.return, + sourceFiber = workInProgress, value = thrownValue; - thrownValue = workInProgressRootRenderLanes; + thrownValue = renderExpirationTime$1; sourceFiber.effectTag |= 2048; sourceFiber.firstEffect = sourceFiber.lastEffect = null; if ( @@ -6154,27 +5827,27 @@ function handleError(root$jscomp$0, thrownValue) { "object" === typeof value && "function" === typeof value.then ) { - var wakeable = value; + var thenable = value; if (0 === (sourceFiber.mode & 2)) { var currentSource = sourceFiber.alternate; currentSource ? ((sourceFiber.updateQueue = currentSource.updateQueue), (sourceFiber.memoizedState = currentSource.memoizedState), - (sourceFiber.lanes = currentSource.lanes)) + (sourceFiber.expirationTime = currentSource.expirationTime)) : ((sourceFiber.updateQueue = null), (sourceFiber.memoizedState = null)); } var hasInvisibleParentBoundary = 0 !== (suspenseStackCursor.current & 1), - workInProgress$76 = returnFiber; + _workInProgress = returnFiber; do { var JSCompiler_temp; - if ((JSCompiler_temp = 13 === workInProgress$76.tag)) { - var nextState = workInProgress$76.memoizedState; + if ((JSCompiler_temp = 13 === _workInProgress.tag)) { + var nextState = _workInProgress.memoizedState; if (null !== nextState) JSCompiler_temp = null !== nextState.dehydrated ? !0 : !1; else { - var props = workInProgress$76.memoizedProps; + var props = _workInProgress.memoizedProps; JSCompiler_temp = void 0 === props.fallback ? !1 @@ -6186,24 +5859,23 @@ function handleError(root$jscomp$0, thrownValue) { } } if (JSCompiler_temp) { - var wakeables = workInProgress$76.updateQueue; - if (null === wakeables) { + var thenables = _workInProgress.updateQueue; + if (null === thenables) { var updateQueue = new Set(); - updateQueue.add(wakeable); - workInProgress$76.updateQueue = updateQueue; - } else wakeables.add(wakeable); - if (0 === (workInProgress$76.mode & 2)) { - workInProgress$76.effectTag |= 64; - sourceFiber.effectTag |= 16384; + updateQueue.add(thenable); + _workInProgress.updateQueue = updateQueue; + } else thenables.add(thenable); + if (0 === (_workInProgress.mode & 2)) { + _workInProgress.effectTag |= 64; sourceFiber.effectTag &= -2981; if (1 === sourceFiber.tag) if (null === sourceFiber.alternate) sourceFiber.tag = 17; else { - var update = createUpdate(-1, 1, null); + var update = createUpdate(1073741823, null); update.tag = 2; enqueueUpdate(sourceFiber, update); } - sourceFiber.lanes |= 1; + sourceFiber.expirationTime = 1073741823; break a; } value = void 0; @@ -6212,105 +5884,108 @@ function handleError(root$jscomp$0, thrownValue) { null === pingCache ? ((pingCache = root.pingCache = new PossiblyWeakMap()), (value = new Set()), - pingCache.set(wakeable, value)) - : ((value = pingCache.get(wakeable)), + pingCache.set(thenable, value)) + : ((value = pingCache.get(thenable)), void 0 === value && - ((value = new Set()), pingCache.set(wakeable, value))); + ((value = new Set()), pingCache.set(thenable, value))); if (!value.has(sourceFiber)) { value.add(sourceFiber); var ping = pingSuspendedRoot.bind( null, root, - wakeable, + thenable, sourceFiber ); - wakeable.then(ping, ping); + thenable.then(ping, ping); } - workInProgress$76.effectTag |= 4096; - workInProgress$76.lanes = thrownValue; + _workInProgress.effectTag |= 4096; + _workInProgress.expirationTime = thrownValue; break a; } - workInProgress$76 = workInProgress$76.return; - } while (null !== workInProgress$76); + _workInProgress = _workInProgress.return; + } while (null !== _workInProgress); value = Error( (getComponentName(sourceFiber.type) || "A React component") + - " suspended while rendering, but no fallback UI was specified.\n\nAdd a component higher in the tree to provide a loading indicator or placeholder to display." + " 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) ); } - 5 !== workInProgressRootExitStatus && - (workInProgressRootExitStatus = 2); + workInProgressRootExitStatus !== RootCompleted && + (workInProgressRootExitStatus = RootErrored); value = createCapturedValue(value, sourceFiber); - workInProgress$76 = returnFiber; + _workInProgress = returnFiber; do { - switch (workInProgress$76.tag) { + switch (_workInProgress.tag) { case 3: - root = value; - workInProgress$76.effectTag |= 4096; - thrownValue &= -thrownValue; - workInProgress$76.lanes |= thrownValue; - var update$77 = createRootErrorUpdate( - workInProgress$76, - root, + thenable = value; + _workInProgress.effectTag |= 4096; + _workInProgress.expirationTime = thrownValue; + var _update = createRootErrorUpdate( + _workInProgress, + thenable, thrownValue ); - enqueueCapturedUpdate(workInProgress$76, update$77); + enqueueCapturedUpdate(_workInProgress, _update); break a; case 1: - root = value; - var ctor = workInProgress$76.type, - instance = workInProgress$76.stateNode; + thenable = value; + var ctor = _workInProgress.type, + instance = _workInProgress.stateNode; if ( - 0 === (workInProgress$76.effectTag & 64) && + 0 === (_workInProgress.effectTag & 64) && ("function" === typeof ctor.getDerivedStateFromError || (null !== instance && "function" === typeof instance.componentDidCatch && (null === legacyErrorBoundariesThatAlreadyFailed || !legacyErrorBoundariesThatAlreadyFailed.has(instance)))) ) { - workInProgress$76.effectTag |= 4096; - thrownValue &= -thrownValue; - workInProgress$76.lanes |= thrownValue; - var update$80 = createClassErrorUpdate( - workInProgress$76, - root, + _workInProgress.effectTag |= 4096; + _workInProgress.expirationTime = thrownValue; + var _update2 = createClassErrorUpdate( + _workInProgress, + thenable, thrownValue ); - enqueueCapturedUpdate(workInProgress$76, update$80); + enqueueCapturedUpdate(_workInProgress, _update2); break a; } } - workInProgress$76 = workInProgress$76.return; - } while (null !== workInProgress$76); + _workInProgress = _workInProgress.return; + } while (null !== _workInProgress); } - completeUnitOfWork(erroredWork); + workInProgress = completeUnitOfWork(workInProgress); } catch (yetAnotherThrownValue) { thrownValue = yetAnotherThrownValue; - workInProgress === erroredWork && - null !== erroredWork && - (workInProgress = erroredWork = erroredWork.return); continue; } break; } while (1); } function pushDispatcher() { - var prevDispatcher = ReactCurrentDispatcher$2.current; - ReactCurrentDispatcher$2.current = ContextOnlyDispatcher; + var prevDispatcher = ReactCurrentDispatcher$1.current; + ReactCurrentDispatcher$1.current = ContextOnlyDispatcher; return null === prevDispatcher ? ContextOnlyDispatcher : prevDispatcher; } -function markRenderEventTimeAndConfig(eventTime, suspenseConfig) { +function markRenderEventTimeAndConfig(expirationTime, suspenseConfig) { + expirationTime < workInProgressRootLatestProcessedExpirationTime && + 2 < expirationTime && + (workInProgressRootLatestProcessedExpirationTime = expirationTime); null !== suspenseConfig && - ((eventTime += suspenseConfig.timeoutMs | 0 || 5e3), - eventTime > workInProgressRootLatestSuspenseTimeout && - ((workInProgressRootLatestSuspenseTimeout = eventTime), - (workInProgressRootCanSuspendUsingConfig = suspenseConfig))); + expirationTime < workInProgressRootLatestSuspenseTimeout && + 2 < expirationTime && + ((workInProgressRootLatestSuspenseTimeout = expirationTime), + (workInProgressRootCanSuspendUsingConfig = suspenseConfig)); } -function renderRootSync(root, lanes) { +function markUnprocessedUpdateTime(expirationTime) { + expirationTime > workInProgressRootNextUnprocessedUpdateTime && + (workInProgressRootNextUnprocessedUpdateTime = expirationTime); +} +function renderRootSync(root, expirationTime) { var prevExecutionContext = executionContext; - executionContext |= 16; + executionContext |= RenderContext; var prevDispatcher = pushDispatcher(); - (workInProgressRoot === root && workInProgressRootRenderLanes === lanes) || - prepareFreshStack(root, lanes); + (root === workInProgressRoot && expirationTime === renderExpirationTime$1) || + prepareFreshStack(root, expirationTime); do try { workLoopSync(); @@ -6321,144 +5996,142 @@ function renderRootSync(root, lanes) { while (1); resetContextDependencies(); executionContext = prevExecutionContext; - ReactCurrentDispatcher$2.current = prevDispatcher; + ReactCurrentDispatcher$1.current = prevDispatcher; if (null !== workInProgress) throw Error( "Cannot commit an incomplete root. This error is likely caused by a bug in React. Please file an issue." ); workInProgressRoot = null; - workInProgressRootRenderLanes = 0; return workInProgressRootExitStatus; } function workLoopSync() { - for (; null !== workInProgress; ) performUnitOfWork(workInProgress); + for (; null !== workInProgress; ) + workInProgress = performUnitOfWork(workInProgress); } function workLoopConcurrent() { - for (; null !== workInProgress && !Scheduler_shouldYield(); ) - performUnitOfWork(workInProgress); + for (; null !== workInProgress && !shouldYield(); ) + workInProgress = performUnitOfWork(workInProgress); } function performUnitOfWork(unitOfWork) { - var next = beginWork$1(unitOfWork.alternate, unitOfWork, subtreeRenderLanes); + var next = beginWork$1( + unitOfWork.alternate, + unitOfWork, + renderExpirationTime$1 + ); unitOfWork.memoizedProps = unitOfWork.pendingProps; - null === next ? completeUnitOfWork(unitOfWork) : (workInProgress = next); + null === next && (next = completeUnitOfWork(unitOfWork)); ReactCurrentOwner$2.current = null; + return next; } function completeUnitOfWork(unitOfWork) { - var completedWork = unitOfWork; + workInProgress = unitOfWork; do { - var current = completedWork.alternate; - unitOfWork = completedWork.return; - if (0 === (completedWork.effectTag & 2048)) { - current = completeWork(current, completedWork, subtreeRenderLanes); - if (null !== current) { - workInProgress = current; - return; - } - current = completedWork; + var current = workInProgress.alternate; + unitOfWork = workInProgress.return; + if (0 === (workInProgress.effectTag & 2048)) { + current = completeWork(current, workInProgress, renderExpirationTime$1); if ( - (24 !== current.tag && 23 !== current.tag) || - null === current.memoizedState || - 0 !== (subtreeRenderLanes & 1073741824) || - 0 === (current.mode & 4) + 1 === renderExpirationTime$1 || + 1 !== workInProgress.childExpirationTime ) { - for (var newChildLanes = 0, child = current.child; null !== child; ) - (newChildLanes |= child.lanes | child.childLanes), - (child = child.sibling); - current.childLanes = newChildLanes; + for ( + var newChildExpirationTime = 0, _child = workInProgress.child; + null !== _child; + + ) { + var _childUpdateExpirationTime = _child.expirationTime, + _childChildExpirationTime = _child.childExpirationTime; + _childUpdateExpirationTime > newChildExpirationTime && + (newChildExpirationTime = _childUpdateExpirationTime); + _childChildExpirationTime > newChildExpirationTime && + (newChildExpirationTime = _childChildExpirationTime); + _child = _child.sibling; + } + workInProgress.childExpirationTime = newChildExpirationTime; } + if (null !== current) return current; null !== unitOfWork && 0 === (unitOfWork.effectTag & 2048) && (null === unitOfWork.firstEffect && - (unitOfWork.firstEffect = completedWork.firstEffect), - null !== completedWork.lastEffect && + (unitOfWork.firstEffect = workInProgress.firstEffect), + null !== workInProgress.lastEffect && (null !== unitOfWork.lastEffect && - (unitOfWork.lastEffect.nextEffect = completedWork.firstEffect), - (unitOfWork.lastEffect = completedWork.lastEffect)), - 1 < completedWork.effectTag && + (unitOfWork.lastEffect.nextEffect = workInProgress.firstEffect), + (unitOfWork.lastEffect = workInProgress.lastEffect)), + 1 < workInProgress.effectTag && (null !== unitOfWork.lastEffect - ? (unitOfWork.lastEffect.nextEffect = completedWork) - : (unitOfWork.firstEffect = completedWork), - (unitOfWork.lastEffect = completedWork))); + ? (unitOfWork.lastEffect.nextEffect = workInProgress) + : (unitOfWork.firstEffect = workInProgress), + (unitOfWork.lastEffect = workInProgress))); } else { - current = unwindWork(completedWork); - if (null !== current) { - current.effectTag &= 2047; - workInProgress = current; - return; - } + current = unwindWork(workInProgress); + if (null !== current) return (current.effectTag &= 2047), current; null !== unitOfWork && ((unitOfWork.firstEffect = unitOfWork.lastEffect = null), (unitOfWork.effectTag |= 2048)); } - completedWork = completedWork.sibling; - if (null !== completedWork) { - workInProgress = completedWork; - return; - } - workInProgress = completedWork = unitOfWork; - } while (null !== completedWork); - 0 === workInProgressRootExitStatus && (workInProgressRootExitStatus = 5); + current = workInProgress.sibling; + if (null !== current) return current; + workInProgress = unitOfWork; + } while (null !== workInProgress); + workInProgressRootExitStatus === RootIncomplete && + (workInProgressRootExitStatus = RootCompleted); + return null; +} +function getRemainingExpirationTime(fiber) { + var updateExpirationTime = fiber.expirationTime; + fiber = fiber.childExpirationTime; + return updateExpirationTime > fiber ? updateExpirationTime : fiber; } function commitRoot(root) { var renderPriorityLevel = getCurrentPriorityLevel(); runWithPriority(99, commitRootImpl.bind(null, root, renderPriorityLevel)); return null; } -function commitRootImpl(root, renderPriorityLevel) { +function commitRootImpl(root$jscomp$1, renderPriorityLevel$jscomp$1) { do flushPassiveEffects(); while (null !== rootWithPendingPassiveEffects); - if (0 !== (executionContext & 48)) + if ((executionContext & (RenderContext | CommitContext)) !== NoContext) throw Error("Should not already be working."); - var finishedWork = root.finishedWork; + var finishedWork = root$jscomp$1.finishedWork, + expirationTime = root$jscomp$1.finishedExpirationTime; if (null === finishedWork) return null; - root.finishedWork = null; - root.finishedLanes = 0; - if (finishedWork === root.current) + root$jscomp$1.finishedWork = null; + root$jscomp$1.finishedExpirationTime = 0; + if (finishedWork === root$jscomp$1.current) throw Error( "Cannot commit the same tree as before. This error is likely caused by a bug in React. Please file an issue." ); - root.callbackNode = null; - var remainingLanes = finishedWork.lanes | finishedWork.childLanes, - remainingLanes$jscomp$0 = remainingLanes, - noLongerPendingLanes = root.pendingLanes & ~remainingLanes$jscomp$0; - root.pendingLanes = remainingLanes$jscomp$0; - root.suspendedLanes = 0; - root.pingedLanes = 0; - root.expiredLanes &= remainingLanes$jscomp$0; - root.mutableReadLanes &= remainingLanes$jscomp$0; - root.entangledLanes &= remainingLanes$jscomp$0; - remainingLanes$jscomp$0 = root.entanglements; - for ( - var eventTimes = root.eventTimes, expirationTimes = root.expirationTimes; - 0 < noLongerPendingLanes; - - ) { - var index$11 = 31 - clz32(noLongerPendingLanes), - lane = 1 << index$11; - remainingLanes$jscomp$0[index$11] = 0; - eventTimes[index$11] = -1; - expirationTimes[index$11] = -1; - noLongerPendingLanes &= ~lane; - } - null !== rootsWithPendingDiscreteUpdates && - 0 === (remainingLanes & 24) && - rootsWithPendingDiscreteUpdates.has(root) && - rootsWithPendingDiscreteUpdates.delete(root); - root === workInProgressRoot && + root$jscomp$1.callbackNode = null; + root$jscomp$1.callbackExpirationTime = 0; + root$jscomp$1.callbackPriority = 90; + root$jscomp$1.nextKnownPendingLevel = 0; + var remainingExpirationTimeBeforeCommit = getRemainingExpirationTime( + finishedWork + ); + root$jscomp$1.firstPendingTime = remainingExpirationTimeBeforeCommit; + expirationTime <= root$jscomp$1.lastSuspendedTime + ? (root$jscomp$1.firstSuspendedTime = root$jscomp$1.lastSuspendedTime = root$jscomp$1.nextKnownPendingLevel = 0) + : expirationTime <= root$jscomp$1.firstSuspendedTime && + (root$jscomp$1.firstSuspendedTime = expirationTime - 1); + expirationTime <= root$jscomp$1.lastPingedTime && + (root$jscomp$1.lastPingedTime = 0); + expirationTime <= root$jscomp$1.lastExpiredTime && + (root$jscomp$1.lastExpiredTime = 0); + root$jscomp$1 === workInProgressRoot && ((workInProgress = workInProgressRoot = null), - (workInProgressRootRenderLanes = 0)); + (renderExpirationTime$1 = 0)); 1 < finishedWork.effectTag ? null !== finishedWork.lastEffect ? ((finishedWork.lastEffect.nextEffect = finishedWork), - (remainingLanes = finishedWork.firstEffect)) - : (remainingLanes = finishedWork) - : (remainingLanes = finishedWork.firstEffect); - if (null !== remainingLanes) { - remainingLanes$jscomp$0 = executionContext; - executionContext |= 32; - focusedInstanceHandle = ReactCurrentOwner$2.current = null; - shouldFireAfterActiveInstanceBlur = !1; - nextEffect = remainingLanes; + (remainingExpirationTimeBeforeCommit = finishedWork.firstEffect)) + : (remainingExpirationTimeBeforeCommit = finishedWork) + : (remainingExpirationTimeBeforeCommit = finishedWork.firstEffect); + if (null !== remainingExpirationTimeBeforeCommit) { + var prevExecutionContext = executionContext; + executionContext |= CommitContext; + ReactCurrentOwner$2.current = null; + nextEffect = remainingExpirationTimeBeforeCommit; do try { commitBeforeMutationEffects(); @@ -6468,11 +6141,15 @@ function commitRootImpl(root, renderPriorityLevel) { nextEffect = nextEffect.nextEffect; } while (null !== nextEffect); - focusedInstanceHandle = null; - nextEffect = remainingLanes; + nextEffect = remainingExpirationTimeBeforeCommit; do try { - for (; null !== nextEffect; ) { + for ( + var root = root$jscomp$1, + renderPriorityLevel = renderPriorityLevel$jscomp$1; + null !== nextEffect; + + ) { var effectTag = nextEffect.effectTag; if (effectTag & 128) { var current = nextEffect.alternate; @@ -6503,106 +6180,49 @@ function commitRootImpl(root, renderPriorityLevel) { commitWork(nextEffect.alternate, nextEffect); break; case 8: - eventTimes = nextEffect; - a: for (noLongerPendingLanes = expirationTimes = eventTimes; ; ) { - index$11 = noLongerPendingLanes; + var current$jscomp$0 = nextEffect; + a: for ( + var finishedRoot = root, + root$jscomp$0 = current$jscomp$0, + renderPriorityLevel$jscomp$0 = renderPriorityLevel, + node = root$jscomp$0; + ; + + ) if ( - injectedHook && - "function" === typeof injectedHook.onCommitFiberUnmount + (commitUnmount( + finishedRoot, + node, + renderPriorityLevel$jscomp$0 + ), + null !== node.child) ) - try { - injectedHook.onCommitFiberUnmount(rendererID, index$11); - } catch (err) {} - switch (index$11.tag) { - case 0: - case 11: - case 14: - case 15: - case 22: - var updateQueue = index$11.updateQueue; - if (null !== updateQueue) { - var lastEffect = updateQueue.lastEffect; - if (null !== lastEffect) { - var firstEffect = lastEffect.next; - lane = firstEffect; - do { - var _effect2 = lane, - destroy = _effect2.destroy, - tag = _effect2.tag; - if (void 0 !== destroy) - if (0 !== (tag & 4)) - enqueuePendingPassiveHookEffectUnmount( - index$11, - lane - ); - else { - _effect2 = index$11; - try { - destroy(); - } catch (error) { - captureCommitPhaseError(_effect2, error); - } - } - lane = lane.next; - } while (lane !== firstEffect); - } - } - break; - case 1: - safelyDetachRef(index$11); - var instance = index$11.stateNode; - if ("function" === typeof instance.componentWillUnmount) - try { - (lane = index$11), - (_effect2 = instance), - (_effect2.props = lane.memoizedProps), - (_effect2.state = lane.memoizedState), - _effect2.componentWillUnmount(); - } catch (unmountError) { - captureCommitPhaseError(index$11, unmountError); - } - break; - case 5: - safelyDetachRef(index$11); - break; - case 4: - createChildNodeSet(index$11.stateNode.containerInfo); - } - if (null !== noLongerPendingLanes.child) - (noLongerPendingLanes.child.return = noLongerPendingLanes), - (noLongerPendingLanes = noLongerPendingLanes.child); + (node.child.return = node), (node = node.child); else { - if (noLongerPendingLanes === expirationTimes) break; - for (; null === noLongerPendingLanes.sibling; ) { - if ( - null === noLongerPendingLanes.return || - noLongerPendingLanes.return === expirationTimes - ) + if (node === root$jscomp$0) break; + for (; null === node.sibling; ) { + if (null === node.return || node.return === root$jscomp$0) break a; - noLongerPendingLanes = noLongerPendingLanes.return; + node = node.return; } - noLongerPendingLanes.sibling.return = - noLongerPendingLanes.return; - noLongerPendingLanes = noLongerPendingLanes.sibling; + node.sibling.return = node.return; + node = node.sibling; } - } - var alternate = eventTimes.alternate; - detachFiberMutation(eventTimes); - null !== alternate && detachFiberMutation(alternate); + detachFiber(current$jscomp$0); } nextEffect = nextEffect.nextEffect; } - } catch (error$92) { + } catch (error) { if (null === nextEffect) throw Error("Should be working on an effect."); - captureCommitPhaseError(nextEffect, error$92); + captureCommitPhaseError(nextEffect, error); nextEffect = nextEffect.nextEffect; } while (null !== nextEffect); - root.current = finishedWork; - nextEffect = remainingLanes; + root$jscomp$1.current = finishedWork; + nextEffect = remainingExpirationTimeBeforeCommit; do try { - for (effectTag = root; null !== nextEffect; ) { + for (effectTag = root$jscomp$1; null !== nextEffect; ) { var effectTag$jscomp$0 = nextEffect.effectTag; effectTag$jscomp$0 & 36 && commitLifeCycles(effectTag, nextEffect.alternate, nextEffect); @@ -6610,13 +6230,13 @@ function commitRootImpl(root, renderPriorityLevel) { current = void 0; var ref = nextEffect.ref; if (null !== ref) { - var instance$jscomp$0 = nextEffect.stateNode; + var instance = nextEffect.stateNode; switch (nextEffect.tag) { case 5: - current = instance$jscomp$0.canonical; + current = instance.canonical; break; default: - current = instance$jscomp$0; + current = instance; } "function" === typeof ref ? ref(current) @@ -6625,68 +6245,54 @@ function commitRootImpl(root, renderPriorityLevel) { } nextEffect = nextEffect.nextEffect; } - } catch (error$93) { + } catch (error) { if (null === nextEffect) throw Error("Should be working on an effect."); - captureCommitPhaseError(nextEffect, error$93); + captureCommitPhaseError(nextEffect, error); nextEffect = nextEffect.nextEffect; } while (null !== nextEffect); nextEffect = null; requestPaint(); - executionContext = remainingLanes$jscomp$0; - } else root.current = finishedWork; + executionContext = prevExecutionContext; + } else root$jscomp$1.current = finishedWork; if (rootDoesHavePassiveEffects) (rootDoesHavePassiveEffects = !1), - (rootWithPendingPassiveEffects = root), - (pendingPassiveEffectsRenderPriority = renderPriorityLevel); + (rootWithPendingPassiveEffects = root$jscomp$1), + (pendingPassiveEffectsRenderPriority = renderPriorityLevel$jscomp$1); else - for (nextEffect = remainingLanes; null !== nextEffect; ) - (renderPriorityLevel = nextEffect.nextEffect), + for ( + nextEffect = remainingExpirationTimeBeforeCommit; + null !== nextEffect; + + ) + (renderPriorityLevel$jscomp$1 = nextEffect.nextEffect), (nextEffect.nextEffect = null), - nextEffect.effectTag & 8 && (nextEffect.sibling = null), - (nextEffect = renderPriorityLevel); - remainingLanes = root.pendingLanes; - 0 === remainingLanes && (legacyErrorBoundariesThatAlreadyFailed = null); - 1 === remainingLanes - ? root === rootWithNestedUpdates + (nextEffect = renderPriorityLevel$jscomp$1); + renderPriorityLevel$jscomp$1 = root$jscomp$1.firstPendingTime; + 0 === renderPriorityLevel$jscomp$1 && + (legacyErrorBoundariesThatAlreadyFailed = null); + 1073741823 === renderPriorityLevel$jscomp$1 + ? root$jscomp$1 === rootWithNestedUpdates ? nestedUpdateCount++ - : ((nestedUpdateCount = 0), (rootWithNestedUpdates = root)) + : ((nestedUpdateCount = 0), (rootWithNestedUpdates = root$jscomp$1)) : (nestedUpdateCount = 0); - finishedWork = finishedWork.stateNode; - if (injectedHook && "function" === typeof injectedHook.onCommitFiberRoot) - try { - injectedHook.onCommitFiberRoot( - rendererID, - finishedWork, - void 0, - 64 === (finishedWork.current.effectTag & 64) - ); - } catch (err) {} - ensureRootIsScheduled(root, now()); + "function" === typeof onCommitFiberRoot && + onCommitFiberRoot(finishedWork.stateNode, expirationTime); + ensureRootIsScheduled(root$jscomp$1); if (hasUncaughtError) throw ((hasUncaughtError = !1), - (root = firstUncaughtError), + (root$jscomp$1 = firstUncaughtError), (firstUncaughtError = null), - root); - if (0 !== (executionContext & 8)) return null; + root$jscomp$1); + if ((executionContext & LegacyUnbatchedContext) !== NoContext) return null; flushSyncCallbackQueue(); return null; } function commitBeforeMutationEffects() { for (; null !== nextEffect; ) { - var current = nextEffect.alternate; - shouldFireAfterActiveInstanceBlur || - null === focusedInstanceHandle || - (0 !== (nextEffect.effectTag & 8) - ? doesFiberContain(nextEffect, focusedInstanceHandle) && - (shouldFireAfterActiveInstanceBlur = !0) - : 13 === nextEffect.tag && - isSuspenseBoundaryBeingHidden(current, nextEffect) && - doesFiberContain(nextEffect, focusedInstanceHandle) && - (shouldFireAfterActiveInstanceBlur = !0)); var effectTag = nextEffect.effectTag; 0 !== (effectTag & 256) && - commitBeforeMutationLifeCycles(current, nextEffect); + commitBeforeMutationLifeCycles(nextEffect.alternate, nextEffect); 0 === (effectTag & 512) || rootDoesHavePassiveEffects || ((rootDoesHavePassiveEffects = !0), @@ -6704,83 +6310,47 @@ function flushPassiveEffects() { ? 97 : pendingPassiveEffectsRenderPriority; pendingPassiveEffectsRenderPriority = 90; - schedulerPriorityToLanePriority(priorityLevel); return runWithPriority(priorityLevel, flushPassiveEffectsImpl); } - return !1; -} -function enqueuePendingPassiveHookEffectMount(fiber, effect) { - pendingPassiveHookEffectsMount.push(effect, fiber); - rootDoesHavePassiveEffects || - ((rootDoesHavePassiveEffects = !0), - scheduleCallback(97, function() { - flushPassiveEffects(); - return null; - })); -} -function enqueuePendingPassiveHookEffectUnmount(fiber, effect) { - pendingPassiveHookEffectsUnmount.push(effect, fiber); - rootDoesHavePassiveEffects || - ((rootDoesHavePassiveEffects = !0), - scheduleCallback(97, function() { - flushPassiveEffects(); - return null; - })); } function flushPassiveEffectsImpl() { if (null === rootWithPendingPassiveEffects) return !1; var root = rootWithPendingPassiveEffects; rootWithPendingPassiveEffects = null; - if (0 !== (executionContext & 48)) + if ((executionContext & (RenderContext | CommitContext)) !== NoContext) throw Error("Cannot flush passive effects while already rendering."); var prevExecutionContext = executionContext; - executionContext |= 32; - var unmountEffects = pendingPassiveHookEffectsUnmount; - pendingPassiveHookEffectsUnmount = []; - for (var i = 0; i < unmountEffects.length; i += 2) { - var effect$98 = unmountEffects[i], - fiber = unmountEffects[i + 1], - destroy = effect$98.destroy; - effect$98.destroy = void 0; - if ("function" === typeof destroy) - try { - destroy(); - } catch (error) { - if (null === fiber) throw Error("Should be working on an effect."); - captureCommitPhaseError(fiber, error); - } - } - unmountEffects = pendingPassiveHookEffectsMount; - pendingPassiveHookEffectsMount = []; - for (i = 0; i < unmountEffects.length; i += 2) { - effect$98 = unmountEffects[i]; - fiber = unmountEffects[i + 1]; + executionContext |= CommitContext; + for (root = root.current.firstEffect; null !== root; ) { try { - var create$102 = effect$98.create; - effect$98.destroy = create$102(); - } catch (error$103) { - if (null === fiber) throw Error("Should be working on an effect."); - captureCommitPhaseError(fiber, error$103); + var finishedWork = root; + if (0 !== (finishedWork.effectTag & 512)) + switch (finishedWork.tag) { + case 0: + case 11: + case 15: + case 22: + commitHookEffectListUnmount(5, finishedWork), + commitHookEffectListMount(5, finishedWork); + } + } catch (error) { + if (null === root) throw Error("Should be working on an effect."); + captureCommitPhaseError(root, error); } + finishedWork = root.nextEffect; + root.nextEffect = null; + root = finishedWork; } - for (root = root.current.firstEffect; null !== root; ) - (create$102 = root.nextEffect), - (root.nextEffect = null), - root.effectTag & 8 && (root.sibling = null), - (root = create$102); executionContext = prevExecutionContext; flushSyncCallbackQueue(); return !0; } function captureCommitPhaseErrorOnRoot(rootFiber, sourceFiber, error) { sourceFiber = createCapturedValue(error, sourceFiber); - sourceFiber = createRootErrorUpdate(rootFiber, sourceFiber, 1); + sourceFiber = createRootErrorUpdate(rootFiber, sourceFiber, 1073741823); enqueueUpdate(rootFiber, sourceFiber); - sourceFiber = requestEventTime(); - rootFiber = markUpdateLaneFromFiberToRoot(rootFiber, 1); - null !== rootFiber && - (markRootUpdated(rootFiber, 1, sourceFiber), - ensureRootIsScheduled(rootFiber, sourceFiber)); + rootFiber = markUpdateTimeFromFiberToRoot(rootFiber, 1073741823); + null !== rootFiber && ensureRootIsScheduled(rootFiber); } function captureCommitPhaseError(sourceFiber, error) { if (3 === sourceFiber.tag) @@ -6799,156 +6369,143 @@ function captureCommitPhaseError(sourceFiber, error) { !legacyErrorBoundariesThatAlreadyFailed.has(instance))) ) { sourceFiber = createCapturedValue(error, sourceFiber); - sourceFiber = createClassErrorUpdate(fiber, sourceFiber, 1); + sourceFiber = createClassErrorUpdate(fiber, sourceFiber, 1073741823); enqueueUpdate(fiber, sourceFiber); - sourceFiber = requestEventTime(); - fiber = markUpdateLaneFromFiberToRoot(fiber, 1); - null !== fiber && - (markRootUpdated(fiber, 1, sourceFiber), - ensureRootIsScheduled(fiber, sourceFiber)); + fiber = markUpdateTimeFromFiberToRoot(fiber, 1073741823); + null !== fiber && ensureRootIsScheduled(fiber); break; } } fiber = fiber.return; } } -function pingSuspendedRoot(root, wakeable, pingedLanes) { +function pingSuspendedRoot(root, thenable, suspendedTime) { var pingCache = root.pingCache; - null !== pingCache && pingCache.delete(wakeable); - wakeable = requestEventTime(); - root.pingedLanes |= root.suspendedLanes & pingedLanes; - workInProgressRoot === root && - (workInProgressRootRenderLanes & pingedLanes) === pingedLanes && - (4 === workInProgressRootExitStatus || - (3 === workInProgressRootExitStatus && - (workInProgressRootRenderLanes & 62914560) === - workInProgressRootRenderLanes && - 500 > now() - globalMostRecentFallbackTime) - ? prepareFreshStack(root, 0) - : (workInProgressRootPingedLanes |= pingedLanes)); - ensureRootIsScheduled(root, wakeable); + null !== pingCache && pingCache.delete(thenable); + workInProgressRoot === root && renderExpirationTime$1 === suspendedTime + ? workInProgressRootExitStatus === RootSuspendedWithDelay || + (workInProgressRootExitStatus === RootSuspended && + 1073741823 === workInProgressRootLatestProcessedExpirationTime && + now() - globalMostRecentFallbackTime < FALLBACK_THROTTLE_MS) + ? prepareFreshStack(root, renderExpirationTime$1) + : (workInProgressRootHasPendingPing = !0) + : isRootSuspendedAtTime(root, suspendedTime) && + ((thenable = root.lastPingedTime), + (0 !== thenable && thenable < suspendedTime) || + ((root.lastPingedTime = suspendedTime), ensureRootIsScheduled(root))); } -function resolveRetryWakeable(boundaryFiber, wakeable) { +function resolveRetryThenable(boundaryFiber, thenable) { var retryCache = boundaryFiber.stateNode; - null !== retryCache && retryCache.delete(wakeable); - wakeable = 0; - 0 === wakeable && - ((wakeable = boundaryFiber.mode), - 0 === (wakeable & 2) - ? (wakeable = 1) - : 0 === (wakeable & 4) - ? (wakeable = 99 === getCurrentPriorityLevel() ? 1 : 2) - : (0 === currentEventWipLanes && - (currentEventWipLanes = workInProgressRootIncludedLanes), - (wakeable = getHighestPriorityLane(62914560 & ~currentEventWipLanes)), - 0 === wakeable && (wakeable = 4194304))); - retryCache = requestEventTime(); - boundaryFiber = markUpdateLaneFromFiberToRoot(boundaryFiber, wakeable); - null !== boundaryFiber && - (markRootUpdated(boundaryFiber, wakeable, retryCache), - ensureRootIsScheduled(boundaryFiber, retryCache)); + null !== retryCache && retryCache.delete(thenable); + thenable = 0; + 0 === thenable && + ((thenable = requestCurrentTimeForUpdate()), + (thenable = computeExpirationForFiber(thenable, boundaryFiber, null))); + boundaryFiber = markUpdateTimeFromFiberToRoot(boundaryFiber, thenable); + null !== boundaryFiber && ensureRootIsScheduled(boundaryFiber); } var beginWork$1; -beginWork$1 = function(current, workInProgress, renderLanes) { - var updateLanes = workInProgress.lanes; +beginWork$1 = function(current, workInProgress, renderExpirationTime) { + var updateExpirationTime = workInProgress.expirationTime; if (null !== current) if ( current.memoizedProps !== workInProgress.pendingProps || didPerformWorkStackCursor.current ) didReceiveUpdate = !0; - else if (0 !== (renderLanes & updateLanes)) - didReceiveUpdate = 0 !== (current.effectTag & 16384) ? !0 : !1; else { - didReceiveUpdate = !1; - switch (workInProgress.tag) { - case 3: - pushHostRootContext(workInProgress); - break; - case 5: - pushHostContext(workInProgress); - break; - case 1: - isContextProvider(workInProgress.type) && - pushContextProvider(workInProgress); - break; - case 4: - pushHostContainer( - workInProgress, - workInProgress.stateNode.containerInfo - ); - break; - case 10: - updateLanes = workInProgress.memoizedProps.value; - var context = workInProgress.type._context; - push(valueCursor, context._currentValue2); - context._currentValue2 = updateLanes; - break; - case 13: - if (null !== workInProgress.memoizedState) { - if (0 !== (renderLanes & workInProgress.child.childLanes)) - return updateSuspenseComponent( - current, - workInProgress, - renderLanes - ); - push(suspenseStackCursor, suspenseStackCursor.current & 1); - workInProgress = bailoutOnAlreadyFinishedWork( - current, + if (updateExpirationTime < renderExpirationTime) { + didReceiveUpdate = !1; + switch (workInProgress.tag) { + case 3: + pushHostRootContext(workInProgress); + break; + case 5: + pushHostContext(workInProgress); + break; + case 1: + isContextProvider(workInProgress.type) && + pushContextProvider(workInProgress); + break; + case 4: + pushHostContainer( workInProgress, - renderLanes + workInProgress.stateNode.containerInfo ); - return null !== workInProgress ? workInProgress.sibling : null; - } - push(suspenseStackCursor, suspenseStackCursor.current & 1); - break; - case 19: - updateLanes = 0 !== (renderLanes & workInProgress.childLanes); - if (0 !== (current.effectTag & 64)) { - if (updateLanes) - return updateSuspenseListComponent( + break; + case 10: + updateExpirationTime = workInProgress.memoizedProps.value; + var context = workInProgress.type._context; + push(valueCursor, context._currentValue2); + context._currentValue2 = updateExpirationTime; + break; + case 13: + if (null !== workInProgress.memoizedState) { + updateExpirationTime = workInProgress.child.childExpirationTime; + if ( + 0 !== updateExpirationTime && + updateExpirationTime >= renderExpirationTime + ) + return updateSuspenseComponent( + current, + workInProgress, + renderExpirationTime + ); + push(suspenseStackCursor, suspenseStackCursor.current & 1); + workInProgress = bailoutOnAlreadyFinishedWork( current, workInProgress, - renderLanes + renderExpirationTime ); - workInProgress.effectTag |= 64; - } - context = workInProgress.memoizedState; - null !== context && - ((context.rendering = null), - (context.tail = null), - (context.lastEffect = null)); - push(suspenseStackCursor, suspenseStackCursor.current); - if (updateLanes) break; - else return null; - case 23: - case 24: - return ( - (workInProgress.lanes = 0), - updateOffscreenComponent(current, workInProgress, renderLanes) - ); + return null !== workInProgress ? workInProgress.sibling : null; + } + push(suspenseStackCursor, suspenseStackCursor.current & 1); + break; + case 19: + updateExpirationTime = + workInProgress.childExpirationTime >= renderExpirationTime; + if (0 !== (current.effectTag & 64)) { + if (updateExpirationTime) + return updateSuspenseListComponent( + current, + workInProgress, + renderExpirationTime + ); + workInProgress.effectTag |= 64; + } + context = workInProgress.memoizedState; + null !== context && + ((context.rendering = null), (context.tail = null)); + push(suspenseStackCursor, suspenseStackCursor.current); + if (!updateExpirationTime) return null; + } + return bailoutOnAlreadyFinishedWork( + current, + workInProgress, + renderExpirationTime + ); } - return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes); + didReceiveUpdate = !1; } else didReceiveUpdate = !1; - workInProgress.lanes = 0; + workInProgress.expirationTime = 0; switch (workInProgress.tag) { case 2: - updateLanes = workInProgress.type; + updateExpirationTime = workInProgress.type; null !== current && ((current.alternate = null), (workInProgress.alternate = null), (workInProgress.effectTag |= 2)); current = workInProgress.pendingProps; context = getMaskedContext(workInProgress, contextStackCursor.current); - prepareToReadContext(workInProgress, renderLanes); + prepareToReadContext(workInProgress, renderExpirationTime); context = renderWithHooks( null, workInProgress, - updateLanes, + updateExpirationTime, current, context, - renderLanes + renderExpirationTime ); workInProgress.effectTag |= 1; if ( @@ -6960,7 +6517,7 @@ beginWork$1 = function(current, workInProgress, renderLanes) { workInProgress.tag = 1; workInProgress.memoizedState = null; workInProgress.updateQueue = null; - if (isContextProvider(updateLanes)) { + if (isContextProvider(updateExpirationTime)) { var hasContext = !0; pushContextProvider(workInProgress); } else hasContext = !1; @@ -6969,41 +6526,53 @@ beginWork$1 = function(current, workInProgress, renderLanes) { ? context.state : null; initializeUpdateQueue(workInProgress); - var getDerivedStateFromProps = updateLanes.getDerivedStateFromProps; + var getDerivedStateFromProps = + updateExpirationTime.getDerivedStateFromProps; "function" === typeof getDerivedStateFromProps && applyDerivedStateFromProps( workInProgress, - updateLanes, + updateExpirationTime, getDerivedStateFromProps, current ); context.updater = classComponentUpdater; workInProgress.stateNode = context; - context._reactInternals = workInProgress; - mountClassInstance(workInProgress, updateLanes, current, renderLanes); + context._reactInternalFiber = workInProgress; + mountClassInstance( + workInProgress, + updateExpirationTime, + current, + renderExpirationTime + ); workInProgress = finishClassComponent( null, workInProgress, - updateLanes, + updateExpirationTime, !0, hasContext, - renderLanes + renderExpirationTime ); } else (workInProgress.tag = 0), - reconcileChildren(null, workInProgress, context, renderLanes), + reconcileChildren( + null, + workInProgress, + context, + renderExpirationTime + ), (workInProgress = workInProgress.child); return workInProgress; case 16: - context = workInProgress.elementType; a: { + context = workInProgress.elementType; null !== current && ((current.alternate = null), (workInProgress.alternate = null), (workInProgress.effectTag |= 2)); current = workInProgress.pendingProps; - hasContext = context._init; - context = hasContext(context._payload); + initializeLazyComponentType(context); + if (1 !== context._status) throw context._result; + context = context._result; workInProgress.type = context; hasContext = workInProgress.tag = resolveLazyComponentTag(context); current = resolveDefaultProps(context, current); @@ -7014,7 +6583,7 @@ beginWork$1 = function(current, workInProgress, renderLanes) { workInProgress, context, current, - renderLanes + renderExpirationTime ); break a; case 1: @@ -7023,7 +6592,7 @@ beginWork$1 = function(current, workInProgress, renderLanes) { workInProgress, context, current, - renderLanes + renderExpirationTime ); break a; case 11: @@ -7032,7 +6601,7 @@ beginWork$1 = function(current, workInProgress, renderLanes) { workInProgress, context, current, - renderLanes + renderExpirationTime ); break a; case 14: @@ -7041,8 +6610,8 @@ beginWork$1 = function(current, workInProgress, renderLanes) { workInProgress, context, resolveDefaultProps(context.type, current), - updateLanes, - renderLanes + updateExpirationTime, + renderExpirationTime ); break a; } @@ -7055,106 +6624,126 @@ beginWork$1 = function(current, workInProgress, renderLanes) { return workInProgress; case 0: return ( - (updateLanes = workInProgress.type), + (updateExpirationTime = workInProgress.type), (context = workInProgress.pendingProps), (context = - workInProgress.elementType === updateLanes + workInProgress.elementType === updateExpirationTime ? context - : resolveDefaultProps(updateLanes, context)), + : resolveDefaultProps(updateExpirationTime, context)), updateFunctionComponent( current, workInProgress, - updateLanes, + updateExpirationTime, context, - renderLanes + renderExpirationTime ) ); case 1: return ( - (updateLanes = workInProgress.type), + (updateExpirationTime = workInProgress.type), (context = workInProgress.pendingProps), (context = - workInProgress.elementType === updateLanes + workInProgress.elementType === updateExpirationTime ? context - : resolveDefaultProps(updateLanes, context)), + : resolveDefaultProps(updateExpirationTime, context)), updateClassComponent( current, workInProgress, - updateLanes, + updateExpirationTime, context, - renderLanes + renderExpirationTime ) ); case 3: pushHostRootContext(workInProgress); - updateLanes = workInProgress.updateQueue; - if (null === current || null === updateLanes) + updateExpirationTime = workInProgress.updateQueue; + if (null === current || null === updateExpirationTime) throw Error( "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." ); - updateLanes = workInProgress.pendingProps; + updateExpirationTime = workInProgress.pendingProps; context = workInProgress.memoizedState; context = null !== context ? context.element : null; cloneUpdateQueue(current, workInProgress); - processUpdateQueue(workInProgress, updateLanes, null, renderLanes); - updateLanes = workInProgress.memoizedState.element; - updateLanes === context + processUpdateQueue( + workInProgress, + updateExpirationTime, + null, + renderExpirationTime + ); + updateExpirationTime = workInProgress.memoizedState.element; + updateExpirationTime === context ? (workInProgress = bailoutOnAlreadyFinishedWork( current, workInProgress, - renderLanes + renderExpirationTime )) - : (reconcileChildren(current, workInProgress, updateLanes, renderLanes), + : (reconcileChildren( + current, + workInProgress, + updateExpirationTime, + renderExpirationTime + ), (workInProgress = workInProgress.child)); return workInProgress; case 5: return ( pushHostContext(workInProgress), - (updateLanes = workInProgress.pendingProps.children), + (updateExpirationTime = workInProgress.pendingProps.children), markRef(current, workInProgress), - reconcileChildren(current, workInProgress, updateLanes, renderLanes), - workInProgress.child + reconcileChildren( + current, + workInProgress, + updateExpirationTime, + renderExpirationTime + ), + (workInProgress = workInProgress.child), + workInProgress ); case 6: return null; case 13: - return updateSuspenseComponent(current, workInProgress, renderLanes); + return updateSuspenseComponent( + current, + workInProgress, + renderExpirationTime + ); case 4: return ( pushHostContainer( workInProgress, workInProgress.stateNode.containerInfo ), - (updateLanes = workInProgress.pendingProps), + (updateExpirationTime = workInProgress.pendingProps), null === current ? (workInProgress.child = reconcileChildFibers( workInProgress, null, - updateLanes, - renderLanes + updateExpirationTime, + renderExpirationTime )) : reconcileChildren( current, workInProgress, - updateLanes, - renderLanes + updateExpirationTime, + renderExpirationTime ), workInProgress.child ); case 11: return ( - (updateLanes = workInProgress.type), + (updateExpirationTime = workInProgress.type), (context = workInProgress.pendingProps), (context = - workInProgress.elementType === updateLanes + workInProgress.elementType === updateExpirationTime ? context - : resolveDefaultProps(updateLanes, context)), + : resolveDefaultProps(updateExpirationTime, context)), updateForwardRef( current, workInProgress, - updateLanes, + updateExpirationTime, context, - renderLanes + renderExpirationTime ) ); case 7: @@ -7163,7 +6752,7 @@ beginWork$1 = function(current, workInProgress, renderLanes) { current, workInProgress, workInProgress.pendingProps, - renderLanes + renderExpirationTime ), workInProgress.child ); @@ -7173,7 +6762,7 @@ beginWork$1 = function(current, workInProgress, renderLanes) { current, workInProgress, workInProgress.pendingProps.children, - renderLanes + renderExpirationTime ), workInProgress.child ); @@ -7183,13 +6772,13 @@ beginWork$1 = function(current, workInProgress, renderLanes) { current, workInProgress, workInProgress.pendingProps.children, - renderLanes + renderExpirationTime ), workInProgress.child ); case 10: a: { - updateLanes = workInProgress.type._context; + updateExpirationTime = workInProgress.type._context; context = workInProgress.pendingProps; getDerivedStateFromProps = workInProgress.memoizedProps; hasContext = context.value; @@ -7201,8 +6790,9 @@ beginWork$1 = function(current, workInProgress, renderLanes) { ((context$jscomp$0 = getDerivedStateFromProps.value), (hasContext = objectIs(context$jscomp$0, hasContext) ? 0 - : ("function" === typeof updateLanes._calculateChangedBits - ? updateLanes._calculateChangedBits( + : ("function" === + typeof updateExpirationTime._calculateChangedBits + ? updateExpirationTime._calculateChangedBits( context$jscomp$0, hasContext ) @@ -7216,7 +6806,7 @@ beginWork$1 = function(current, workInProgress, renderLanes) { workInProgress = bailoutOnAlreadyFinishedWork( current, workInProgress, - renderLanes + renderExpirationTime ); break a; } @@ -7237,25 +6827,25 @@ beginWork$1 = function(current, workInProgress, renderLanes) { ) { if ( - dependency.context === updateLanes && + dependency.context === updateExpirationTime && 0 !== (dependency.observedBits & hasContext) ) { 1 === context$jscomp$0.tag && - ((dependency = createUpdate( - -1, - renderLanes & -renderLanes, - null - )), + ((dependency = createUpdate(renderExpirationTime, null)), (dependency.tag = 2), enqueueUpdate(context$jscomp$0, dependency)); - context$jscomp$0.lanes |= renderLanes; + context$jscomp$0.expirationTime < renderExpirationTime && + (context$jscomp$0.expirationTime = renderExpirationTime); dependency = context$jscomp$0.alternate; - null !== dependency && (dependency.lanes |= renderLanes); + null !== dependency && + dependency.expirationTime < renderExpirationTime && + (dependency.expirationTime = renderExpirationTime); scheduleWorkOnParentPath( context$jscomp$0.return, - renderLanes + renderExpirationTime ); - list.lanes |= renderLanes; + list.expirationTime < renderExpirationTime && + (list.expirationTime = renderExpirationTime); break; } dependency = dependency.next; @@ -7293,7 +6883,7 @@ beginWork$1 = function(current, workInProgress, renderLanes) { current, workInProgress, context.children, - renderLanes + renderExpirationTime ); workInProgress = workInProgress.child; } @@ -7302,12 +6892,17 @@ beginWork$1 = function(current, workInProgress, renderLanes) { return ( (context = workInProgress.type), (hasContext = workInProgress.pendingProps), - (updateLanes = hasContext.children), - prepareToReadContext(workInProgress, renderLanes), + (updateExpirationTime = hasContext.children), + prepareToReadContext(workInProgress, renderExpirationTime), (context = readContext(context, hasContext.unstable_observedBits)), - (updateLanes = updateLanes(context)), + (updateExpirationTime = updateExpirationTime(context)), (workInProgress.effectTag |= 1), - reconcileChildren(current, workInProgress, updateLanes, renderLanes), + reconcileChildren( + current, + workInProgress, + updateExpirationTime, + renderExpirationTime + ), workInProgress.child ); case 14: @@ -7323,8 +6918,8 @@ beginWork$1 = function(current, workInProgress, renderLanes) { workInProgress, context, hasContext, - updateLanes, - renderLanes + updateExpirationTime, + renderExpirationTime ) ); case 15: @@ -7333,43 +6928,48 @@ beginWork$1 = function(current, workInProgress, renderLanes) { workInProgress, workInProgress.type, workInProgress.pendingProps, - updateLanes, - renderLanes + updateExpirationTime, + renderExpirationTime ); case 17: return ( - (updateLanes = workInProgress.type), + (updateExpirationTime = workInProgress.type), (context = workInProgress.pendingProps), (context = - workInProgress.elementType === updateLanes + workInProgress.elementType === updateExpirationTime ? context - : resolveDefaultProps(updateLanes, context)), + : resolveDefaultProps(updateExpirationTime, context)), null !== current && ((current.alternate = null), (workInProgress.alternate = null), (workInProgress.effectTag |= 2)), (workInProgress.tag = 1), - isContextProvider(updateLanes) + isContextProvider(updateExpirationTime) ? ((current = !0), pushContextProvider(workInProgress)) : (current = !1), - prepareToReadContext(workInProgress, renderLanes), - constructClassInstance(workInProgress, updateLanes, context), - mountClassInstance(workInProgress, updateLanes, context, renderLanes), + prepareToReadContext(workInProgress, renderExpirationTime), + constructClassInstance(workInProgress, updateExpirationTime, context), + mountClassInstance( + workInProgress, + updateExpirationTime, + context, + renderExpirationTime + ), finishClassComponent( null, workInProgress, - updateLanes, + updateExpirationTime, !0, current, - renderLanes + renderExpirationTime ) ); case 19: - return updateSuspenseListComponent(current, workInProgress, renderLanes); - case 23: - return updateOffscreenComponent(current, workInProgress, renderLanes); - case 24: - return updateOffscreenComponent(current, workInProgress, renderLanes); + return updateSuspenseListComponent( + current, + workInProgress, + renderExpirationTime + ); } throw Error( "Unknown unit of work tag (" + @@ -7377,6 +6977,32 @@ beginWork$1 = function(current, workInProgress, renderLanes) { "). This error is likely caused by a bug in React. Please file an issue." ); }; +var onCommitFiberRoot = null, + onCommitFiberUnmount = null; +function injectInternals(internals) { + if ("undefined" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) return !1; + var hook = __REACT_DEVTOOLS_GLOBAL_HOOK__; + if (hook.isDisabled || !hook.supportsFiber) return !0; + try { + var rendererID = hook.inject(internals); + onCommitFiberRoot = function(root) { + try { + hook.onCommitFiberRoot( + rendererID, + root, + void 0, + 64 === (root.current.effectTag & 64) + ); + } catch (err) {} + }; + onCommitFiberUnmount = function(fiber) { + try { + hook.onCommitFiberUnmount(rendererID, fiber); + } catch (err) {} + }; + } catch (err) {} + return !0; +} function FiberNode(tag, pendingProps, key, mode) { this.tag = tag; this.key = key; @@ -7388,12 +7014,9 @@ function FiberNode(tag, pendingProps, key, mode) { this.mode = mode; this.effectTag = 0; this.lastEffect = this.firstEffect = this.nextEffect = null; - this.childLanes = this.lanes = 0; + 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); @@ -7411,7 +7034,7 @@ function resolveLazyComponentTag(Component) { function createWorkInProgress(current, pendingProps) { var workInProgress = current.alternate; null === workInProgress - ? ((workInProgress = createFiber( + ? ((workInProgress = new FiberNode( current.tag, pendingProps, current.key, @@ -7423,13 +7046,16 @@ function createWorkInProgress(current, pendingProps) { (workInProgress.alternate = current), (current.alternate = workInProgress)) : ((workInProgress.pendingProps = pendingProps), - (workInProgress.type = current.type), (workInProgress.effectTag = 0), (workInProgress.nextEffect = null), (workInProgress.firstEffect = null), (workInProgress.lastEffect = null)); - workInProgress.childLanes = current.childLanes; - workInProgress.lanes = current.lanes; + if (null == current) + throw Error("current is " + current + " but it can't be"); + if (null == workInProgress) + throw Error("workInProgress is " + workInProgress + " but it can't be"); + workInProgress.childExpirationTime = current.childExpirationTime; + workInProgress.expirationTime = current.expirationTime; workInProgress.child = current.child; workInProgress.memoizedProps = current.memoizedProps; workInProgress.memoizedState = current.memoizedState; @@ -7439,7 +7065,7 @@ function createWorkInProgress(current, pendingProps) { null === pendingProps ? null : { - lanes: pendingProps.lanes, + expirationTime: pendingProps.expirationTime, firstContext: pendingProps.firstContext, responders: pendingProps.responders }; @@ -7454,7 +7080,7 @@ function createFiberFromTypeAndProps( pendingProps, owner, mode, - lanes + expirationTime ) { var fiberTag = 2; owner = type; @@ -7463,10 +7089,15 @@ function createFiberFromTypeAndProps( else a: switch (type) { case REACT_FRAGMENT_TYPE: - return createFiberFromFragment(pendingProps.children, mode, lanes, key); - case REACT_DEBUG_TRACING_MODE_TYPE: + return createFiberFromFragment( + pendingProps.children, + mode, + expirationTime, + key + ); + case REACT_CONCURRENT_MODE_TYPE: fiberTag = 8; - mode |= 16; + mode |= 7; break; case REACT_STRICT_MODE_TYPE: fiberTag = 8; @@ -7474,34 +7105,25 @@ function createFiberFromTypeAndProps( break; case REACT_PROFILER_TYPE: return ( - (type = createFiber(12, pendingProps, key, mode | 8)), + (type = new FiberNode(12, pendingProps, key, mode | 8)), (type.elementType = REACT_PROFILER_TYPE), (type.type = REACT_PROFILER_TYPE), - (type.lanes = lanes), + (type.expirationTime = expirationTime), type ); case REACT_SUSPENSE_TYPE: return ( - (type = createFiber(13, pendingProps, key, mode)), + (type = new FiberNode(13, pendingProps, key, mode)), (type.type = REACT_SUSPENSE_TYPE), (type.elementType = REACT_SUSPENSE_TYPE), - (type.lanes = lanes), + (type.expirationTime = expirationTime), type ); case REACT_SUSPENSE_LIST_TYPE: return ( - (type = createFiber(19, pendingProps, key, mode)), + (type = new FiberNode(19, pendingProps, key, mode)), (type.elementType = REACT_SUSPENSE_LIST_TYPE), - (type.lanes = lanes), - type - ); - case REACT_OFFSCREEN_TYPE: - return createFiberFromOffscreen(pendingProps, mode, lanes, key); - case REACT_LEGACY_HIDDEN_TYPE: - return ( - (type = createFiber(24, pendingProps, key, mode)), - (type.elementType = REACT_LEGACY_HIDDEN_TYPE), - (type.lanes = lanes), + (type.expirationTime = expirationTime), type ); default: @@ -7533,36 +7155,30 @@ function createFiberFromTypeAndProps( "." ); } - key = createFiber(fiberTag, pendingProps, key, mode); + key = new FiberNode(fiberTag, pendingProps, key, mode); key.elementType = type; key.type = owner; - key.lanes = lanes; + key.expirationTime = expirationTime; return key; } -function createFiberFromFragment(elements, mode, lanes, key) { - elements = createFiber(7, elements, key, mode); - elements.lanes = lanes; +function createFiberFromFragment(elements, mode, expirationTime, key) { + elements = new FiberNode(7, elements, key, mode); + elements.expirationTime = expirationTime; return elements; } -function createFiberFromOffscreen(pendingProps, mode, lanes, key) { - pendingProps = createFiber(23, pendingProps, key, mode); - pendingProps.elementType = REACT_OFFSCREEN_TYPE; - pendingProps.lanes = lanes; - return pendingProps; -} -function createFiberFromText(content, mode, lanes) { - content = createFiber(6, content, null, mode); - content.lanes = lanes; +function createFiberFromText(content, mode, expirationTime) { + content = new FiberNode(6, content, null, mode); + content.expirationTime = expirationTime; return content; } -function createFiberFromPortal(portal, mode, lanes) { - mode = createFiber( +function createFiberFromPortal(portal, mode, expirationTime) { + mode = new FiberNode( 4, null !== portal.children ? portal.children : [], portal.key, mode ); - mode.lanes = lanes; + mode.expirationTime = expirationTime; mode.stateNode = { containerInfo: portal.containerInfo, pendingChildren: null, @@ -7572,31 +7188,51 @@ function createFiberFromPortal(portal, mode, lanes) { } function FiberRootNode(containerInfo, tag, hydrate) { this.tag = tag; + this.current = null; this.containerInfo = containerInfo; - this.finishedWork = this.pingCache = this.current = this.pendingChildren = null; + this.pingCache = this.pendingChildren = null; + this.finishedExpirationTime = 0; + this.finishedWork = null; this.timeoutHandle = -1; this.pendingContext = this.context = null; this.hydrate = hydrate; this.callbackNode = null; - this.callbackPriority = 0; - this.eventTimes = Array(31).fill(0); - this.expirationTimes = Array(31).fill(-1); - this.entangledLanes = this.finishedLanes = this.mutableReadLanes = this.expiredLanes = this.pingedLanes = this.suspendedLanes = this.pendingLanes = 0; - this.entanglements = Array(31).fill(0); + this.callbackPriority = 90; + this.lastExpiredTime = this.lastPingedTime = this.nextKnownPendingLevel = this.lastSuspendedTime = this.firstSuspendedTime = this.firstPendingTime = 0; } -function createPortal(children, containerInfo, implementation) { - var key = - 3 < arguments.length && void 0 !== arguments[3] ? arguments[3] : null; - return { - $$typeof: REACT_PORTAL_TYPE, - key: null == key ? null : "" + key, - children: children, - containerInfo: containerInfo, - implementation: implementation - }; +function isRootSuspendedAtTime(root, expirationTime) { + var firstSuspendedTime = root.firstSuspendedTime; + root = root.lastSuspendedTime; + return ( + 0 !== firstSuspendedTime && + firstSuspendedTime >= expirationTime && + root <= expirationTime + ); +} +function markRootSuspendedAtTime(root, expirationTime) { + var firstSuspendedTime = root.firstSuspendedTime, + lastSuspendedTime = root.lastSuspendedTime; + firstSuspendedTime < expirationTime && + (root.firstSuspendedTime = expirationTime); + if (lastSuspendedTime > expirationTime || 0 === firstSuspendedTime) + root.lastSuspendedTime = expirationTime; + expirationTime <= root.lastPingedTime && (root.lastPingedTime = 0); + expirationTime <= root.lastExpiredTime && (root.lastExpiredTime = 0); +} +function markRootUpdatedAtTime(root, expirationTime) { + expirationTime > root.firstPendingTime && + (root.firstPendingTime = expirationTime); + var firstSuspendedTime = root.firstSuspendedTime; + 0 !== firstSuspendedTime && + (expirationTime >= firstSuspendedTime + ? (root.firstSuspendedTime = root.lastSuspendedTime = root.nextKnownPendingLevel = 0) + : expirationTime >= root.lastSuspendedTime && + (root.lastSuspendedTime = expirationTime + 1), + expirationTime > root.nextKnownPendingLevel && + (root.nextKnownPendingLevel = expirationTime)); } function findHostInstance(component) { - var fiber = component._reactInternals; + var fiber = component._reactInternalFiber; if (void 0 === fiber) { if ("function" === typeof component.render) throw Error("Unable to find node on an unmounted component."); @@ -7610,11 +7246,11 @@ function findHostInstance(component) { } function updateContainer(element, container, parentComponent, callback) { var current = container.current, - eventTime = requestEventTime(), - suspenseConfig = ReactCurrentBatchConfig.suspense, - lane = requestUpdateLane(current, suspenseConfig); + currentTime = requestCurrentTimeForUpdate(), + suspenseConfig = ReactCurrentBatchConfig.suspense; + currentTime = computeExpirationForFiber(currentTime, current, suspenseConfig); a: if (parentComponent) { - parentComponent = parentComponent._reactInternals; + parentComponent = parentComponent._reactInternalFiber; b: { if ( getNearestMountedFiber(parentComponent) !== parentComponent || @@ -7623,23 +7259,22 @@ function updateContainer(element, container, parentComponent, callback) { throw Error( "Expected subtree parent to be a mounted class component. This error is likely caused by a bug in React. Please file an issue." ); - var JSCompiler_inline_result = parentComponent; + var parentContext = parentComponent; do { - switch (JSCompiler_inline_result.tag) { + switch (parentContext.tag) { case 3: - JSCompiler_inline_result = - JSCompiler_inline_result.stateNode.context; + parentContext = parentContext.stateNode.context; break b; case 1: - if (isContextProvider(JSCompiler_inline_result.type)) { - JSCompiler_inline_result = - JSCompiler_inline_result.stateNode + if (isContextProvider(parentContext.type)) { + parentContext = + parentContext.stateNode .__reactInternalMemoizedMergedChildContext; break b; } } - JSCompiler_inline_result = JSCompiler_inline_result.return; - } while (null !== JSCompiler_inline_result); + parentContext = parentContext.return; + } while (null !== parentContext); throw Error( "Found unexpected detached subtree parent. This error is likely caused by a bug in React. Please file an issue." ); @@ -7650,26 +7285,34 @@ function updateContainer(element, container, parentComponent, callback) { parentComponent = processChildContext( parentComponent, Component, - JSCompiler_inline_result + parentContext ); break a; } } - parentComponent = JSCompiler_inline_result; + parentComponent = parentContext; } else parentComponent = emptyContextObject; null === container.context ? (container.context = parentComponent) : (container.pendingContext = parentComponent); - container = createUpdate(eventTime, lane, suspenseConfig); + container = createUpdate(currentTime, suspenseConfig); container.payload = { element: element }; callback = void 0 === callback ? null : callback; null !== callback && (container.callback = callback); enqueueUpdate(current, container); - scheduleUpdateOnFiber(current, lane, eventTime); - return lane; + scheduleWork(current, currentTime); + return currentTime; } -function emptyFindFiberByHostInstance() { - return null; +function createPortal(children, containerInfo, implementation) { + var key = + 3 < arguments.length && void 0 !== arguments[3] ? arguments[3] : null; + return { + $$typeof: REACT_PORTAL_TYPE, + key: null == key ? null : "" + key, + children: children, + containerInfo: containerInfo, + implementation: implementation + }; } function findNodeHandle(componentOrHandle) { if (null == componentOrHandle) return null; @@ -7691,64 +7334,53 @@ batchedUpdatesImpl = function(fn, a) { return fn(a); } finally { (executionContext = prevExecutionContext), - 0 === executionContext && flushSyncCallbackQueue(); + executionContext === NoContext && flushSyncCallbackQueue(); } }; -var roots = new Map(), - devToolsConfig$jscomp$inline_891 = { - findFiberByHostInstance: getInstanceFromInstance, - bundleType: 0, - version: "17.0.0-alpha.0", - rendererPackageName: "react-native-renderer", - rendererConfig: { - getInspectorDataForViewTag: function() { - throw Error( - "getInspectorDataForViewTag() is not available in production" - ); - }, - getInspectorDataForViewAtPoint: function() { - throw Error( - "getInspectorDataForViewAtPoint() is not available in production." - ); - }.bind(null, findNodeHandle) - } - }; -var internals$jscomp$inline_1074 = { - bundleType: devToolsConfig$jscomp$inline_891.bundleType, - version: devToolsConfig$jscomp$inline_891.version, - rendererPackageName: devToolsConfig$jscomp$inline_891.rendererPackageName, - rendererConfig: devToolsConfig$jscomp$inline_891.rendererConfig, - overrideHookState: null, - overrideProps: null, - setSuspenseHandler: null, - scheduleUpdate: null, - currentDispatcherRef: ReactSharedInternals.ReactCurrentDispatcher, - findHostInstanceByFiber: function(fiber) { - fiber = findCurrentHostFiber(fiber); - return null === fiber ? null : fiber.stateNode; - }, - findFiberByHostInstance: - devToolsConfig$jscomp$inline_891.findFiberByHostInstance || - emptyFindFiberByHostInstance, - findHostInstancesForRefresh: null, - scheduleRefresh: null, - scheduleRoot: null, - setRefreshHandler: null, - getCurrentFiber: null -}; -if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) { - var hook$jscomp$inline_1075 = __REACT_DEVTOOLS_GLOBAL_HOOK__; - if ( - !hook$jscomp$inline_1075.isDisabled && - hook$jscomp$inline_1075.supportsFiber - ) - try { - (rendererID = hook$jscomp$inline_1075.inject( - internals$jscomp$inline_1074 - )), - (injectedHook = hook$jscomp$inline_1075); - } catch (err) {} -} +var roots = new Map(); +(function(devToolsConfig) { + var findFiberByHostInstance = devToolsConfig.findFiberByHostInstance; + return injectInternals({ + bundleType: devToolsConfig.bundleType, + version: devToolsConfig.version, + rendererPackageName: devToolsConfig.rendererPackageName, + rendererConfig: devToolsConfig.rendererConfig, + overrideHookState: null, + overrideProps: null, + setSuspenseHandler: null, + scheduleUpdate: null, + currentDispatcherRef: ReactSharedInternals.ReactCurrentDispatcher, + findHostInstanceByFiber: function(fiber) { + fiber = findCurrentHostFiber(fiber); + return null === fiber ? null : fiber.stateNode; + }, + findFiberByHostInstance: function(instance) { + return findFiberByHostInstance ? findFiberByHostInstance(instance) : null; + }, + findHostInstancesForRefresh: null, + scheduleRefresh: null, + scheduleRoot: null, + setRefreshHandler: null, + getCurrentFiber: null + }); +})({ + findFiberByHostInstance: getInstanceFromInstance, + bundleType: 0, + version: "16.13.0", + rendererPackageName: "react-native-renderer", + rendererConfig: { + getInspectorDataForViewTag: function() { + throw Error( + "getInspectorDataForViewTag() is not available in production" + ); + }, + getInspectorDataForViewAtPoint: function() { + throw Error( + "getInspectorDataForViewAtPoint() is not available in production." + ); + }.bind(null, findNodeHandle) + } +}); exports.createPortal = function(children, containerTag) { return createPortal( children, @@ -7788,7 +7420,7 @@ exports.render = function(element, containerTag, callback) { var root = roots.get(containerTag); if (!root) { root = new FiberRootNode(containerTag, 0, !1); - var uninitializedFiber = createFiber(3, null, null, 0); + var uninitializedFiber = new FiberNode(3, null, null, 0); root.current = uninitializedFiber; uninitializedFiber.stateNode = root; initializeUpdateQueue(uninitializedFiber); diff --git a/Libraries/Renderer/implementations/ReactFabric-profiling.fb.js b/Libraries/Renderer/implementations/ReactFabric-profiling.fb.js index 5e573f43cf1..be0ac55a7b8 100644 --- a/Libraries/Renderer/implementations/ReactFabric-profiling.fb.js +++ b/Libraries/Renderer/implementations/ReactFabric-profiling.fb.js @@ -16,6 +16,16 @@ var ReactNativePrivateInterface = require("react-native/Libraries/ReactPrivate/R React = require("react"), Scheduler = require("scheduler"), tracing = require("scheduler/tracing"); +function getParent(inst) { + do inst = inst.return; + while (inst && 5 !== inst.tag); + return inst ? inst : null; +} +function traverseTwoPhase(inst, fn, arg) { + for (var path = []; inst; ) path.push(inst), (inst = getParent(inst)); + for (inst = path.length; 0 < inst--; ) fn(path[inst], "captured", arg); + for (inst = 0; inst < path.length; inst++) fn(path[inst], "bubbled", arg); +} function invokeGuardedCallbackImpl(name, func, context, a, b, c, d, e, f) { var funcArgs = Array.prototype.slice.call(arguments, 3); try { @@ -86,6 +96,109 @@ function executeDirectDispatch(event) { event._dispatchInstances = null; return dispatchListener; } +function getListener(inst, registrationName) { + var listener = inst.stateNode; + if (!listener) return null; + var props = getFiberCurrentPropsFromNode(listener); + if (!props) return null; + listener = props[registrationName]; + a: switch (registrationName) { + case "onClick": + case "onClickCapture": + case "onDoubleClick": + case "onDoubleClickCapture": + case "onMouseDown": + case "onMouseDownCapture": + case "onMouseMove": + case "onMouseMoveCapture": + case "onMouseUp": + case "onMouseUpCapture": + case "onMouseEnter": + (props = !props.disabled) || + ((inst = inst.type), + (props = !( + "button" === inst || + "input" === inst || + "select" === inst || + "textarea" === inst + ))); + inst = !props; + break a; + default: + inst = !1; + } + if (inst) return null; + if (listener && "function" !== typeof listener) + throw Error( + "Expected `" + + registrationName + + "` listener to be a function, instead got a value of `" + + typeof listener + + "` type." + ); + return listener; +} +function accumulateInto(current, next) { + if (null == next) + throw Error( + "accumulateInto(...): Accumulated items must not be null or undefined." + ); + if (null == current) return next; + if (Array.isArray(current)) { + if (Array.isArray(next)) return current.push.apply(current, next), current; + current.push(next); + return current; + } + return Array.isArray(next) ? [current].concat(next) : [current, next]; +} +function forEachAccumulated(arr, cb, scope) { + Array.isArray(arr) ? arr.forEach(cb, scope) : arr && cb.call(scope, arr); +} +function accumulateDirectionalDispatches(inst, phase, event) { + if ( + (phase = getListener( + inst, + event.dispatchConfig.phasedRegistrationNames[phase] + )) + ) + (event._dispatchListeners = accumulateInto( + event._dispatchListeners, + phase + )), + (event._dispatchInstances = accumulateInto( + event._dispatchInstances, + inst + )); +} +function accumulateTwoPhaseDispatchesSingle(event) { + event && + event.dispatchConfig.phasedRegistrationNames && + traverseTwoPhase(event._targetInst, accumulateDirectionalDispatches, event); +} +function accumulateTwoPhaseDispatchesSingleSkipTarget(event) { + if (event && event.dispatchConfig.phasedRegistrationNames) { + var targetInst = event._targetInst; + targetInst = targetInst ? getParent(targetInst) : null; + traverseTwoPhase(targetInst, accumulateDirectionalDispatches, event); + } +} +function accumulateDirectDispatchesSingle(event) { + if (event && event.dispatchConfig.registrationName) { + var inst = event._targetInst; + if (inst && event && event.dispatchConfig.registrationName) { + var listener = getListener(inst, event.dispatchConfig.registrationName); + listener && + ((event._dispatchListeners = accumulateInto( + event._dispatchListeners, + listener + )), + (event._dispatchInstances = accumulateInto( + event._dispatchInstances, + inst + ))); + } + } +} function functionThatReturnsTrue() { return !0; } @@ -101,7 +214,6 @@ function SyntheticEvent( this.dispatchConfig = dispatchConfig; this._targetInst = targetInst; this.nativeEvent = nativeEvent; - this._dispatchInstances = this._dispatchListeners = null; dispatchConfig = this.constructor.Interface; for (var propName in dispatchConfig) dispatchConfig.hasOwnProperty(propName) && @@ -181,12 +293,7 @@ SyntheticEvent.extend = function(Interface) { return Class; }; addEventPoolingTo(SyntheticEvent); -function createOrGetPooledEvent( - dispatchConfig, - targetInst, - nativeEvent, - nativeInst -) { +function getPooledEvent(dispatchConfig, targetInst, nativeEvent, nativeInst) { if (this.eventPool.length) { var instance = this.eventPool.pop(); this.call(instance, dispatchConfig, targetInst, nativeEvent, nativeInst); @@ -203,8 +310,8 @@ function releasePooledEvent(event) { 10 > this.eventPool.length && this.eventPool.push(event); } function addEventPoolingTo(EventConstructor) { - EventConstructor.getPooled = createOrGetPooledEvent; EventConstructor.eventPool = []; + EventConstructor.getPooled = getPooledEvent; EventConstructor.release = releasePooledEvent; } var ResponderSyntheticEvent = SyntheticEvent.extend({ @@ -332,22 +439,6 @@ function accumulate(current, next) { ? [current].concat(next) : [current, next]; } -function accumulateInto(current, next) { - if (null == next) - throw Error( - "accumulateInto(...): Accumulated items must not be null or undefined." - ); - if (null == current) return next; - if (Array.isArray(current)) { - if (Array.isArray(next)) return current.push.apply(current, next), current; - current.push(next); - return current; - } - return Array.isArray(next) ? [current].concat(next) : [current, next]; -} -function forEachAccumulated(arr, cb, scope) { - Array.isArray(arr) ? arr.forEach(cb, scope) : arr && cb.call(scope, arr); -} var responderInst = null, trackedTouchCount = 0; function changeResponder(nextResponderInst, blockHostResponder) { @@ -361,132 +452,65 @@ function changeResponder(nextResponderInst, blockHostResponder) { ); } var eventTypes = { - startShouldSetResponder: { - phasedRegistrationNames: { - bubbled: "onStartShouldSetResponder", - captured: "onStartShouldSetResponderCapture" + startShouldSetResponder: { + phasedRegistrationNames: { + bubbled: "onStartShouldSetResponder", + captured: "onStartShouldSetResponderCapture" + }, + dependencies: startDependencies }, - dependencies: startDependencies - }, - scrollShouldSetResponder: { - phasedRegistrationNames: { - bubbled: "onScrollShouldSetResponder", - captured: "onScrollShouldSetResponderCapture" + scrollShouldSetResponder: { + phasedRegistrationNames: { + bubbled: "onScrollShouldSetResponder", + captured: "onScrollShouldSetResponderCapture" + }, + dependencies: ["topScroll"] }, - dependencies: ["topScroll"] - }, - selectionChangeShouldSetResponder: { - phasedRegistrationNames: { - bubbled: "onSelectionChangeShouldSetResponder", - captured: "onSelectionChangeShouldSetResponderCapture" + selectionChangeShouldSetResponder: { + phasedRegistrationNames: { + bubbled: "onSelectionChangeShouldSetResponder", + captured: "onSelectionChangeShouldSetResponderCapture" + }, + dependencies: ["topSelectionChange"] }, - dependencies: ["topSelectionChange"] - }, - moveShouldSetResponder: { - phasedRegistrationNames: { - bubbled: "onMoveShouldSetResponder", - captured: "onMoveShouldSetResponderCapture" + moveShouldSetResponder: { + phasedRegistrationNames: { + bubbled: "onMoveShouldSetResponder", + captured: "onMoveShouldSetResponderCapture" + }, + dependencies: moveDependencies }, - dependencies: moveDependencies - }, - responderStart: { - registrationName: "onResponderStart", - dependencies: startDependencies - }, - responderMove: { - registrationName: "onResponderMove", - dependencies: moveDependencies - }, - responderEnd: { - registrationName: "onResponderEnd", - dependencies: endDependencies - }, - responderRelease: { - registrationName: "onResponderRelease", - dependencies: endDependencies - }, - responderTerminationRequest: { - registrationName: "onResponderTerminationRequest", - dependencies: [] - }, - responderGrant: { registrationName: "onResponderGrant", dependencies: [] }, - responderReject: { registrationName: "onResponderReject", dependencies: [] }, - responderTerminate: { - registrationName: "onResponderTerminate", - dependencies: [] - } -}; -function getParent(inst) { - do inst = inst.return; - while (inst && 5 !== inst.tag); - return inst ? inst : null; -} -function traverseTwoPhase(inst, fn, arg) { - for (var path = []; inst; ) path.push(inst), (inst = getParent(inst)); - for (inst = path.length; 0 < inst--; ) fn(path[inst], "captured", arg); - for (inst = 0; inst < path.length; inst++) fn(path[inst], "bubbled", arg); -} -function getListener(inst, registrationName) { - inst = inst.stateNode; - if (null === inst) return null; - inst = getFiberCurrentPropsFromNode(inst); - if (null === inst) return null; - if ((inst = inst[registrationName]) && "function" !== typeof inst) - throw Error( - "Expected `" + - registrationName + - "` listener to be a function, instead got a value of `" + - typeof inst + - "` type." - ); - return inst; -} -function accumulateDirectionalDispatches(inst, phase, event) { - if ( - (phase = getListener( - inst, - event.dispatchConfig.phasedRegistrationNames[phase] - )) - ) - (event._dispatchListeners = accumulateInto( - event._dispatchListeners, - phase - )), - (event._dispatchInstances = accumulateInto( - event._dispatchInstances, - inst - )); -} -function accumulateDirectDispatchesSingle(event) { - if (event && event.dispatchConfig.registrationName) { - var inst = event._targetInst; - if (inst && event && event.dispatchConfig.registrationName) { - var listener = getListener(inst, event.dispatchConfig.registrationName); - listener && - ((event._dispatchListeners = accumulateInto( - event._dispatchListeners, - listener - )), - (event._dispatchInstances = accumulateInto( - event._dispatchInstances, - inst - ))); + responderStart: { + registrationName: "onResponderStart", + dependencies: startDependencies + }, + responderMove: { + registrationName: "onResponderMove", + dependencies: moveDependencies + }, + responderEnd: { + registrationName: "onResponderEnd", + dependencies: endDependencies + }, + responderRelease: { + registrationName: "onResponderRelease", + dependencies: endDependencies + }, + responderTerminationRequest: { + registrationName: "onResponderTerminationRequest", + dependencies: [] + }, + responderGrant: { registrationName: "onResponderGrant", dependencies: [] }, + responderReject: { + registrationName: "onResponderReject", + dependencies: [] + }, + responderTerminate: { + registrationName: "onResponderTerminate", + dependencies: [] } - } -} -function accumulateTwoPhaseDispatchesSingleSkipTarget(event) { - if (event && event.dispatchConfig.phasedRegistrationNames) { - var targetInst = event._targetInst; - targetInst = targetInst ? getParent(targetInst) : null; - traverseTwoPhase(targetInst, accumulateDirectionalDispatches, event); - } -} -function accumulateTwoPhaseDispatchesSingle(event) { - event && - event.dispatchConfig.phasedRegistrationNames && - traverseTwoPhase(event._targetInst, accumulateDirectionalDispatches, event); -} -var ResponderEventPlugin = { + }, + ResponderEventPlugin = { _getResponder: function() { return responderInst; }, @@ -547,70 +571,68 @@ var ResponderEventPlugin = { JSCompiler_temp = null; } else JSCompiler_temp = targetInst; - targetInst = JSCompiler_temp; - JSCompiler_temp = targetInst === responderInst; - shouldSetEventType = ResponderSyntheticEvent.getPooled( + targetInst = JSCompiler_temp === responderInst; + JSCompiler_temp = ResponderSyntheticEvent.getPooled( shouldSetEventType, - targetInst, + JSCompiler_temp, nativeEvent, nativeEventTarget ); - shouldSetEventType.touchHistory = - ResponderTouchHistoryStore.touchHistory; - JSCompiler_temp + JSCompiler_temp.touchHistory = ResponderTouchHistoryStore.touchHistory; + targetInst ? forEachAccumulated( - shouldSetEventType, + JSCompiler_temp, accumulateTwoPhaseDispatchesSingleSkipTarget ) : forEachAccumulated( - shouldSetEventType, + JSCompiler_temp, accumulateTwoPhaseDispatchesSingle ); b: { - JSCompiler_temp = shouldSetEventType._dispatchListeners; - targetInst = shouldSetEventType._dispatchInstances; - if (Array.isArray(JSCompiler_temp)) + shouldSetEventType = JSCompiler_temp._dispatchListeners; + targetInst = JSCompiler_temp._dispatchInstances; + if (Array.isArray(shouldSetEventType)) for ( depthA = 0; - depthA < JSCompiler_temp.length && - !shouldSetEventType.isPropagationStopped(); + depthA < shouldSetEventType.length && + !JSCompiler_temp.isPropagationStopped(); depthA++ ) { if ( - JSCompiler_temp[depthA](shouldSetEventType, targetInst[depthA]) + shouldSetEventType[depthA](JSCompiler_temp, targetInst[depthA]) ) { - JSCompiler_temp = targetInst[depthA]; + shouldSetEventType = targetInst[depthA]; break b; } } else if ( - JSCompiler_temp && - JSCompiler_temp(shouldSetEventType, targetInst) + shouldSetEventType && + shouldSetEventType(JSCompiler_temp, targetInst) ) { - JSCompiler_temp = targetInst; + shouldSetEventType = targetInst; break b; } - JSCompiler_temp = null; + shouldSetEventType = null; } - shouldSetEventType._dispatchInstances = null; - shouldSetEventType._dispatchListeners = null; - shouldSetEventType.isPersistent() || - shouldSetEventType.constructor.release(shouldSetEventType); - if (JSCompiler_temp && JSCompiler_temp !== responderInst) + JSCompiler_temp._dispatchInstances = null; + JSCompiler_temp._dispatchListeners = null; + JSCompiler_temp.isPersistent() || + JSCompiler_temp.constructor.release(JSCompiler_temp); + if (shouldSetEventType && shouldSetEventType !== responderInst) if ( - ((shouldSetEventType = ResponderSyntheticEvent.getPooled( + ((JSCompiler_temp = ResponderSyntheticEvent.getPooled( eventTypes.responderGrant, - JSCompiler_temp, + shouldSetEventType, nativeEvent, nativeEventTarget )), - (shouldSetEventType.touchHistory = + (JSCompiler_temp.touchHistory = ResponderTouchHistoryStore.touchHistory), forEachAccumulated( - shouldSetEventType, + JSCompiler_temp, accumulateDirectDispatchesSingle ), - (targetInst = !0 === executeDirectDispatch(shouldSetEventType)), + (targetInst = !0 === executeDirectDispatch(JSCompiler_temp)), responderInst) ) if ( @@ -637,13 +659,13 @@ var ResponderEventPlugin = { forEachAccumulated(depthA, accumulateDirectDispatchesSingle); var JSCompiler_temp$jscomp$0 = accumulate( JSCompiler_temp$jscomp$0, - [shouldSetEventType, depthA] + [JSCompiler_temp, depthA] ); - changeResponder(JSCompiler_temp, targetInst); + changeResponder(shouldSetEventType, targetInst); } else (shouldSetEventType = ResponderSyntheticEvent.getPooled( eventTypes.responderReject, - JSCompiler_temp, + shouldSetEventType, nativeEvent, nativeEventTarget )), @@ -660,9 +682,9 @@ var ResponderEventPlugin = { else (JSCompiler_temp$jscomp$0 = accumulate( JSCompiler_temp$jscomp$0, - shouldSetEventType + JSCompiler_temp )), - changeResponder(JSCompiler_temp, targetInst); + changeResponder(shouldSetEventType, targetInst); else JSCompiler_temp$jscomp$0 = null; } else JSCompiler_temp$jscomp$0 = null; shouldSetEventType = responderInst && isStartish(topLevelType); @@ -790,6 +812,7 @@ function recomputePluginOrdering() { for (var eventName in pluginIndex) { var JSCompiler_inline_result = void 0; var dispatchConfig = pluginIndex[eventName], + pluginModule$jscomp$0 = pluginModule, eventName$jscomp$0 = eventName; if (eventNameDispatchConfigs.hasOwnProperty(eventName$jscomp$0)) throw Error( @@ -806,7 +829,7 @@ function recomputePluginOrdering() { ) && publishRegistrationName( phasedRegistrationNames[JSCompiler_inline_result], - pluginModule, + pluginModule$jscomp$0, eventName$jscomp$0 ); JSCompiler_inline_result = !0; @@ -814,7 +837,7 @@ function recomputePluginOrdering() { dispatchConfig.registrationName ? (publishRegistrationName( dispatchConfig.registrationName, - pluginModule, + pluginModule$jscomp$0, eventName$jscomp$0 ), (JSCompiler_inline_result = !0)) @@ -842,75 +865,13 @@ function publishRegistrationName(registrationName, pluginModule) { } var plugins = [], eventNameDispatchConfigs = {}, - registrationNameModules = {}; -function getListener$1(inst, registrationName) { - inst = inst.stateNode; - if (null === inst) return null; - inst = getFiberCurrentPropsFromNode(inst); - if (null === inst) return null; - if ((inst = inst[registrationName]) && "function" !== typeof inst) - throw Error( - "Expected `" + - registrationName + - "` listener to be a function, instead got a value of `" + - typeof inst + - "` type." - ); - return inst; -} -var customBubblingEventTypes = + registrationNameModules = {}, + customBubblingEventTypes = ReactNativePrivateInterface.ReactNativeViewConfigRegistry .customBubblingEventTypes, customDirectEventTypes = ReactNativePrivateInterface.ReactNativeViewConfigRegistry .customDirectEventTypes; -function accumulateDirectionalDispatches$1(inst, phase, event) { - if ( - (phase = getListener$1( - inst, - event.dispatchConfig.phasedRegistrationNames[phase] - )) - ) - (event._dispatchListeners = accumulateInto( - event._dispatchListeners, - phase - )), - (event._dispatchInstances = accumulateInto( - event._dispatchInstances, - inst - )); -} -function accumulateTwoPhaseDispatchesSingle$1(event) { - if (event && event.dispatchConfig.phasedRegistrationNames) { - for (var inst = event._targetInst, path = []; inst; ) { - path.push(inst); - do inst = inst.return; - while (inst && 5 !== inst.tag); - inst = inst ? inst : null; - } - for (inst = path.length; 0 < inst--; ) - accumulateDirectionalDispatches$1(path[inst], "captured", event); - for (inst = 0; inst < path.length; inst++) - accumulateDirectionalDispatches$1(path[inst], "bubbled", event); - } -} -function accumulateDirectDispatchesSingle$1(event) { - if (event && event.dispatchConfig.registrationName) { - var inst = event._targetInst; - if (inst && event && event.dispatchConfig.registrationName) { - var listener = getListener$1(inst, event.dispatchConfig.registrationName); - listener && - ((event._dispatchListeners = accumulateInto( - event._dispatchListeners, - listener - )), - (event._dispatchInstances = accumulateInto( - event._dispatchInstances, - inst - ))); - } - } -} if (eventPluginOrder) throw Error( "EventPluginRegistry: Cannot inject event plugin ordering more than once. You are likely trying to load more than one copy of React." @@ -920,7 +881,7 @@ eventPluginOrder = Array.prototype.slice.call([ "ReactNativeBridgeEventPlugin" ]); recomputePluginOrdering(); -var injectedNamesToPlugins$jscomp$inline_229 = { +var injectedNamesToPlugins$jscomp$inline_92 = { ResponderEventPlugin: ResponderEventPlugin, ReactNativeBridgeEventPlugin: { eventTypes: {}, @@ -944,45 +905,42 @@ var injectedNamesToPlugins$jscomp$inline_229 = { nativeEventTarget ); if (bubbleDispatchConfig) - forEachAccumulated( - topLevelType, - accumulateTwoPhaseDispatchesSingle$1 - ); + forEachAccumulated(topLevelType, accumulateTwoPhaseDispatchesSingle); else if (directDispatchConfig) - forEachAccumulated(topLevelType, accumulateDirectDispatchesSingle$1); + forEachAccumulated(topLevelType, accumulateDirectDispatchesSingle); else return null; return topLevelType; } } }, - isOrderingDirty$jscomp$inline_230 = !1, - pluginName$jscomp$inline_231; -for (pluginName$jscomp$inline_231 in injectedNamesToPlugins$jscomp$inline_229) + isOrderingDirty$jscomp$inline_93 = !1, + pluginName$jscomp$inline_94; +for (pluginName$jscomp$inline_94 in injectedNamesToPlugins$jscomp$inline_92) if ( - injectedNamesToPlugins$jscomp$inline_229.hasOwnProperty( - pluginName$jscomp$inline_231 + injectedNamesToPlugins$jscomp$inline_92.hasOwnProperty( + pluginName$jscomp$inline_94 ) ) { - var pluginModule$jscomp$inline_232 = - injectedNamesToPlugins$jscomp$inline_229[pluginName$jscomp$inline_231]; + var pluginModule$jscomp$inline_95 = + injectedNamesToPlugins$jscomp$inline_92[pluginName$jscomp$inline_94]; if ( - !namesToPlugins.hasOwnProperty(pluginName$jscomp$inline_231) || - namesToPlugins[pluginName$jscomp$inline_231] !== - pluginModule$jscomp$inline_232 + !namesToPlugins.hasOwnProperty(pluginName$jscomp$inline_94) || + namesToPlugins[pluginName$jscomp$inline_94] !== + pluginModule$jscomp$inline_95 ) { - if (namesToPlugins[pluginName$jscomp$inline_231]) + if (namesToPlugins[pluginName$jscomp$inline_94]) throw Error( "EventPluginRegistry: Cannot inject two different event plugins using the same name, `" + - pluginName$jscomp$inline_231 + + pluginName$jscomp$inline_94 + "`." ); namesToPlugins[ - pluginName$jscomp$inline_231 - ] = pluginModule$jscomp$inline_232; - isOrderingDirty$jscomp$inline_230 = !0; + pluginName$jscomp$inline_94 + ] = pluginModule$jscomp$inline_95; + isOrderingDirty$jscomp$inline_93 = !0; } } -isOrderingDirty$jscomp$inline_230 && recomputePluginOrdering(); +isOrderingDirty$jscomp$inline_93 && recomputePluginOrdering(); function getInstanceFromInstance(instanceHandle) { return instanceHandle; } @@ -1006,44 +964,31 @@ ResponderEventPlugin.injection.injectGlobalResponderHandler({ } }); var ReactSharedInternals = - React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED, - REACT_ELEMENT_TYPE = 60103, - REACT_PORTAL_TYPE = 60106, - REACT_FRAGMENT_TYPE = 60107, - REACT_STRICT_MODE_TYPE = 60108, - REACT_PROFILER_TYPE = 60114, - REACT_PROVIDER_TYPE = 60109, - REACT_CONTEXT_TYPE = 60110, - REACT_FORWARD_REF_TYPE = 60112, - REACT_SUSPENSE_TYPE = 60113, - REACT_SUSPENSE_LIST_TYPE = 60120, - REACT_MEMO_TYPE = 60115, - REACT_LAZY_TYPE = 60116, - REACT_BLOCK_TYPE = 60121, - REACT_DEBUG_TRACING_MODE_TYPE = 60129, - REACT_OFFSCREEN_TYPE = 60130, - REACT_LEGACY_HIDDEN_TYPE = 60131; -if ("function" === typeof Symbol && Symbol.for) { - var symbolFor = Symbol.for; - REACT_ELEMENT_TYPE = symbolFor("react.element"); - REACT_PORTAL_TYPE = symbolFor("react.portal"); - REACT_FRAGMENT_TYPE = symbolFor("react.fragment"); - REACT_STRICT_MODE_TYPE = symbolFor("react.strict_mode"); - REACT_PROFILER_TYPE = symbolFor("react.profiler"); - REACT_PROVIDER_TYPE = symbolFor("react.provider"); - REACT_CONTEXT_TYPE = symbolFor("react.context"); - REACT_FORWARD_REF_TYPE = symbolFor("react.forward_ref"); - REACT_SUSPENSE_TYPE = symbolFor("react.suspense"); - REACT_SUSPENSE_LIST_TYPE = symbolFor("react.suspense_list"); - REACT_MEMO_TYPE = symbolFor("react.memo"); - REACT_LAZY_TYPE = symbolFor("react.lazy"); - REACT_BLOCK_TYPE = symbolFor("react.block"); - symbolFor("react.scope"); - REACT_DEBUG_TRACING_MODE_TYPE = symbolFor("react.debug_trace_mode"); - REACT_OFFSCREEN_TYPE = symbolFor("react.offscreen"); - REACT_LEGACY_HIDDEN_TYPE = symbolFor("react.legacy_hidden"); -} -var MAYBE_ITERATOR_SYMBOL = "function" === typeof Symbol && Symbol.iterator; + React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED; +ReactSharedInternals.hasOwnProperty("ReactCurrentDispatcher") || + (ReactSharedInternals.ReactCurrentDispatcher = { current: null }); +ReactSharedInternals.hasOwnProperty("ReactCurrentBatchConfig") || + (ReactSharedInternals.ReactCurrentBatchConfig = { suspense: null }); +var hasSymbol = "function" === typeof Symbol && Symbol.for, + REACT_ELEMENT_TYPE = hasSymbol ? Symbol.for("react.element") : 60103, + REACT_PORTAL_TYPE = hasSymbol ? Symbol.for("react.portal") : 60106, + REACT_FRAGMENT_TYPE = hasSymbol ? Symbol.for("react.fragment") : 60107, + REACT_STRICT_MODE_TYPE = hasSymbol ? Symbol.for("react.strict_mode") : 60108, + REACT_PROFILER_TYPE = hasSymbol ? Symbol.for("react.profiler") : 60114, + REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for("react.provider") : 60109, + REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for("react.context") : 60110, + REACT_CONCURRENT_MODE_TYPE = hasSymbol + ? Symbol.for("react.concurrent_mode") + : 60111, + REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for("react.forward_ref") : 60112, + REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for("react.suspense") : 60113, + REACT_SUSPENSE_LIST_TYPE = hasSymbol + ? Symbol.for("react.suspense_list") + : 60120, + REACT_MEMO_TYPE = hasSymbol ? Symbol.for("react.memo") : 60115, + REACT_LAZY_TYPE = hasSymbol ? Symbol.for("react.lazy") : 60116, + REACT_BLOCK_TYPE = hasSymbol ? Symbol.for("react.block") : 60121, + MAYBE_ITERATOR_SYMBOL = "function" === typeof Symbol && Symbol.iterator; function getIteratorFn(maybeIterable) { if (null === maybeIterable || "object" !== typeof maybeIterable) return null; maybeIterable = @@ -1051,6 +996,27 @@ function getIteratorFn(maybeIterable) { maybeIterable["@@iterator"]; return "function" === typeof maybeIterable ? maybeIterable : null; } +function initializeLazyComponentType(lazyComponent) { + if (-1 === lazyComponent._status) { + var ctor = lazyComponent._result; + ctor || (ctor = lazyComponent._ctor); + ctor = ctor(); + lazyComponent._status = 0; + lazyComponent._result = ctor; + ctor.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)); + } + ); + } +} function getComponentName(type) { if (null == type) return null; if ("function" === typeof type) return type.displayName || type.name || null; @@ -1085,13 +1051,10 @@ function getComponentName(type) { case REACT_MEMO_TYPE: return getComponentName(type.type); case REACT_BLOCK_TYPE: - return getComponentName(type._render); + return getComponentName(type.render); case REACT_LAZY_TYPE: - innerType = type._payload; - type = type._init; - try { - return getComponentName(type(innerType)); - } catch (x) {} + if ((type = 1 === type._status ? type._result : null)) + return getComponentName(type); } return null; } @@ -1143,36 +1106,36 @@ function findCurrentFiberUsingSlowPath(fiber) { } if (a.return !== b.return) (a = parentA), (b = parentB); else { - for (var didFindChild = !1, child$0 = parentA.child; child$0; ) { - if (child$0 === a) { + for (var didFindChild = !1, _child = parentA.child; _child; ) { + if (_child === a) { didFindChild = !0; a = parentA; b = parentB; break; } - if (child$0 === b) { + if (_child === b) { didFindChild = !0; b = parentA; a = parentB; break; } - child$0 = child$0.sibling; + _child = _child.sibling; } if (!didFindChild) { - for (child$0 = parentB.child; child$0; ) { - if (child$0 === a) { + for (_child = parentB.child; _child; ) { + if (_child === a) { didFindChild = !0; a = parentB; b = parentA; break; } - if (child$0 === b) { + if (_child === b) { didFindChild = !0; b = parentB; a = parentA; break; } - child$0 = child$0.sibling; + _child = _child.sibling; } if (!didFindChild) throw Error( @@ -1207,18 +1170,6 @@ function findCurrentHostFiber(parent) { } return null; } -function doesFiberContain(parentFiber, childFiber) { - for ( - var parentFiberAlternate = parentFiber.alternate; - null !== childFiber; - - ) { - if (childFiber === parentFiber || childFiber === parentFiberAlternate) - return !0; - childFiber = childFiber.return; - } - return !1; -} function mountSafeCallback_NOT_REALLY_SAFE(context, callback) { return function() { if ( @@ -1432,19 +1383,19 @@ function diffProperties(updatePayload, prevProps, nextProps, validAttributes) { ), (removedKeys = null)); } - for (var propKey$2 in prevProps) - void 0 === nextProps[propKey$2] && - (!(attributeConfig = validAttributes[propKey$2]) || - (updatePayload && void 0 !== updatePayload[propKey$2]) || - ((prevProp = prevProps[propKey$2]), + for (var _propKey in prevProps) + void 0 === nextProps[_propKey] && + (!(attributeConfig = validAttributes[_propKey]) || + (updatePayload && void 0 !== updatePayload[_propKey]) || + ((prevProp = prevProps[_propKey]), void 0 !== prevProp && ("object" !== typeof attributeConfig || "function" === typeof attributeConfig.diff || "function" === typeof attributeConfig.process - ? (((updatePayload || (updatePayload = {}))[propKey$2] = null), + ? (((updatePayload || (updatePayload = {}))[_propKey] = null), removedKeys || (removedKeys = {}), - removedKeys[propKey$2] || - ((removedKeys[propKey$2] = !0), removedKeyCount++)) + removedKeys[_propKey] || + ((removedKeys[_propKey] = !0), removedKeyCount++)) : (updatePayload = clearNestedProperty( updatePayload, prevProp, @@ -1492,49 +1443,37 @@ function dispatchEvent(target, topLevelType, nativeEvent) { null != stateNode && (eventTarget = stateNode.canonical); } batchedUpdates(function() { - var JSCompiler_inline_result = eventTarget; - for ( - var events = null, legacyPlugins = plugins, i = 0; - i < legacyPlugins.length; - i++ - ) { - var possiblePlugin = legacyPlugins[i]; + var events = eventTarget; + for (var events$jscomp$0 = null, i = 0; i < plugins.length; i++) { + var possiblePlugin = plugins[i]; possiblePlugin && (possiblePlugin = possiblePlugin.extractEvents( topLevelType, target, nativeEvent, - JSCompiler_inline_result + events, + 1 )) && - (events = accumulateInto(events, possiblePlugin)); + (events$jscomp$0 = accumulateInto(events$jscomp$0, possiblePlugin)); } - JSCompiler_inline_result = events; - null !== JSCompiler_inline_result && - (eventQueue = accumulateInto(eventQueue, JSCompiler_inline_result)); - JSCompiler_inline_result = eventQueue; + events = events$jscomp$0; + null !== events && (eventQueue = accumulateInto(eventQueue, events)); + events = eventQueue; eventQueue = null; - if (JSCompiler_inline_result) { - forEachAccumulated( - JSCompiler_inline_result, - executeDispatchesAndReleaseTopLevel - ); + if (events) { + forEachAccumulated(events, executeDispatchesAndReleaseTopLevel); if (eventQueue) throw Error( "processEventQueue(): Additional events were enqueued while processing an event queue. Support for this has not yet been implemented." ); if (hasRethrowError) - throw ((JSCompiler_inline_result = rethrowError), + throw ((events = rethrowError), (hasRethrowError = !1), (rethrowError = null), - JSCompiler_inline_result); + events); } }); } -function shim() { - throw Error( - "The current renderer does not support mutation. This error is likely caused by a bug in React. Please file an issue." - ); -} function shim$1() { throw Error( "The current renderer does not support hydration. This error is likely caused by a bug in React. Please file an issue." @@ -1627,32 +1566,19 @@ var scheduleTimeout = setTimeout, cancelTimeout = clearTimeout; function cloneHiddenInstance(instance) { var node = instance.node; - var JSCompiler_inline_result = diffProperties( + var updatePayload = diffProperties( null, emptyObject, { style: { display: "none" } }, instance.canonical.viewConfig.validAttributes ); return { - node: cloneNodeWithNewProps(node, JSCompiler_inline_result), + node: cloneNodeWithNewProps(node, updatePayload), canonical: instance.canonical }; } -function describeComponentFrame(name, source, ownerName) { - source = ""; - ownerName && (source = " (created by " + ownerName + ")"); - return "\n in " + (name || "Unknown") + source; -} -function describeFunctionComponentFrame(fn, source) { - return fn - ? describeComponentFrame(fn.displayName || fn.name || null, source, null) - : ""; -} var valueStack = [], index = -1; -function createCursor(defaultValue) { - return { current: defaultValue }; -} function pop(cursor) { 0 > index || ((cursor.current = valueStack[index]), (valueStack[index] = null), index--); @@ -1663,8 +1589,8 @@ function push(cursor, value) { cursor.current = value; } var emptyContextObject = {}, - contextStackCursor = createCursor(emptyContextObject), - didPerformWorkStackCursor = createCursor(!1), + contextStackCursor = { current: emptyContextObject }, + didPerformWorkStackCursor = { current: !1 }, previousContext = emptyContextObject; function getMaskedContext(workInProgress, unmaskedContext) { var contextTypes = workInProgress.type.contextTypes; @@ -1744,228 +1670,12 @@ function invalidateContextProvider(workInProgress, type, didChange) { : pop(didPerformWorkStackCursor); push(didPerformWorkStackCursor, didChange); } -var rendererID = null, - injectedHook = null, - isDevToolsPresent = "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__, - Scheduler_now = Scheduler.unstable_now; -if ( - null == tracing.__interactionsRef || - null == tracing.__interactionsRef.current -) - throw Error( - "It is not supported to run the profiling version of a renderer (for example, `react-dom/profiling`) without also replacing the `scheduler/tracing` module with `scheduler/tracing-profiling`. Your bundler might have a setting for aliasing both modules. Learn more at http://fb.me/react-profiling" - ); -Scheduler_now(); -var return_highestLanePriority = 10; -function getHighestPriorityLanes(lanes) { - if (0 !== (1 & lanes)) return (return_highestLanePriority = 17), 1; - if (0 !== (2 & lanes)) return (return_highestLanePriority = 16), 2; - if (0 !== (4 & lanes)) return (return_highestLanePriority = 15), 4; - var inputDiscreteLanes = 24 & lanes; - if (0 !== inputDiscreteLanes) - return (return_highestLanePriority = 14), inputDiscreteLanes; - if (0 !== (lanes & 32)) return (return_highestLanePriority = 13), 32; - inputDiscreteLanes = 192 & lanes; - if (0 !== inputDiscreteLanes) - return (return_highestLanePriority = 12), inputDiscreteLanes; - if (0 !== (lanes & 256)) return (return_highestLanePriority = 11), 256; - inputDiscreteLanes = 3584 & lanes; - if (0 !== inputDiscreteLanes) - return (return_highestLanePriority = 10), inputDiscreteLanes; - if (0 !== (lanes & 4096)) return (return_highestLanePriority = 9), 4096; - inputDiscreteLanes = 122880 & lanes; - if (0 !== inputDiscreteLanes) - return (return_highestLanePriority = 8), inputDiscreteLanes; - if (0 !== (lanes & 131072)) return (return_highestLanePriority = 7), 131072; - inputDiscreteLanes = 3932160 & lanes; - if (0 !== inputDiscreteLanes) - return (return_highestLanePriority = 6), inputDiscreteLanes; - inputDiscreteLanes = 62914560 & lanes; - if (0 !== inputDiscreteLanes) - return (return_highestLanePriority = 5), inputDiscreteLanes; - if (lanes & 67108864) return (return_highestLanePriority = 4), 67108864; - if (0 !== (lanes & 134217728)) - return (return_highestLanePriority = 3), 134217728; - inputDiscreteLanes = 805306368 & lanes; - if (0 !== inputDiscreteLanes) - return (return_highestLanePriority = 2), inputDiscreteLanes; - if (0 !== (1073741824 & lanes)) - return (return_highestLanePriority = 1), 1073741824; - return_highestLanePriority = 10; - return lanes; -} -function schedulerPriorityToLanePriority(schedulerPriorityLevel) { - switch (schedulerPriorityLevel) { - case 99: - return 17; - case 98: - return 12; - case 97: - case 96: - return 10; - case 95: - return 2; - default: - return 0; - } -} -function lanePriorityToSchedulerPriority(lanePriority) { - switch (lanePriority) { - case 17: - case 16: - return 99; - case 15: - case 14: - case 13: - case 12: - return 98; - case 11: - case 10: - case 9: - case 8: - case 7: - case 6: - case 4: - case 5: - return 97; - case 3: - case 2: - case 1: - return 95; - case 0: - return 90; - default: - throw Error( - "Invalid update priority: " + lanePriority + ". This is a bug in React." - ); - } -} -function getNextLanes(root, wipLanes) { - var pendingLanes = root.pendingLanes; - if (0 === pendingLanes) return (return_highestLanePriority = 0); - var nextLanes = 0, - nextLanePriority = 0, - expiredLanes = root.expiredLanes, - suspendedLanes = root.suspendedLanes, - pingedLanes = root.pingedLanes; - if (0 !== expiredLanes) - (nextLanes = expiredLanes), - (nextLanePriority = return_highestLanePriority = 17); - else if (((expiredLanes = pendingLanes & 134217727), 0 !== expiredLanes)) { - var nonIdleUnblockedLanes = expiredLanes & ~suspendedLanes; - 0 !== nonIdleUnblockedLanes - ? ((nextLanes = getHighestPriorityLanes(nonIdleUnblockedLanes)), - (nextLanePriority = return_highestLanePriority)) - : ((pingedLanes &= expiredLanes), - 0 !== pingedLanes && - ((nextLanes = getHighestPriorityLanes(pingedLanes)), - (nextLanePriority = return_highestLanePriority))); - } else - (expiredLanes = pendingLanes & ~suspendedLanes), - 0 !== expiredLanes - ? ((nextLanes = getHighestPriorityLanes(expiredLanes)), - (nextLanePriority = return_highestLanePriority)) - : 0 !== pingedLanes && - ((nextLanes = getHighestPriorityLanes(pingedLanes)), - (nextLanePriority = return_highestLanePriority)); - if (0 === nextLanes) return 0; - nextLanes = 31 - clz32(nextLanes); - nextLanes = pendingLanes & (((0 > nextLanes ? 0 : 1 << nextLanes) << 1) - 1); - if ( - 0 !== wipLanes && - wipLanes !== nextLanes && - 0 === (wipLanes & suspendedLanes) - ) { - getHighestPriorityLanes(wipLanes); - if (nextLanePriority <= return_highestLanePriority) return wipLanes; - return_highestLanePriority = nextLanePriority; - } - wipLanes = root.entangledLanes; - if (0 !== wipLanes) - for (root = root.entanglements, wipLanes &= nextLanes; 0 < wipLanes; ) - (pendingLanes = 31 - clz32(wipLanes)), - (nextLanePriority = 1 << pendingLanes), - (nextLanes |= root[pendingLanes]), - (wipLanes &= ~nextLanePriority); - return nextLanes; -} -function getMostRecentEventTime(root, lanes) { - root = root.eventTimes; - for (var mostRecentEventTime = -1; 0 < lanes; ) { - var index$4 = 31 - clz32(lanes), - lane = 1 << index$4; - index$4 = root[index$4]; - index$4 > mostRecentEventTime && (mostRecentEventTime = index$4); - lanes &= ~lane; - } - return mostRecentEventTime; -} -function getLanesToRetrySynchronouslyOnError(root) { - root = root.pendingLanes & -1073741825; - return 0 !== root ? root : root & 1073741824 ? 1073741824 : 0; -} -function findUpdateLane(lanePriority, wipLanes) { - switch (lanePriority) { - case 17: - return 1; - case 16: - return 2; - case 14: - return ( - (lanePriority = getHighestPriorityLane(24 & ~wipLanes)), - 0 === lanePriority ? findUpdateLane(12, wipLanes) : lanePriority - ); - case 12: - return ( - (lanePriority = getHighestPriorityLane(192 & ~wipLanes)), - 0 === lanePriority ? findUpdateLane(10, wipLanes) : lanePriority - ); - case 10: - return ( - (lanePriority = getHighestPriorityLane(3584 & ~wipLanes)), - 0 === lanePriority && - ((lanePriority = getHighestPriorityLane(4055040 & ~wipLanes)), - 0 === lanePriority && (lanePriority = 512)), - lanePriority - ); - case 2: - return ( - (wipLanes = getHighestPriorityLane(805306368 & ~wipLanes)), - 0 === wipLanes && (wipLanes = 268435456), - wipLanes - ); - } - throw Error( - "Invalid update priority: " + lanePriority + ". This is a bug in React." - ); -} -function getHighestPriorityLane(lanes) { - return lanes & -lanes; -} -function pickArbitraryLane(lanes) { - return lanes & -lanes; -} -function markRootUpdated(root, updateLane, eventTime) { - root.pendingLanes |= updateLane; - var higherPriorityLanes = updateLane - 1; - root.suspendedLanes &= higherPriorityLanes; - root.pingedLanes &= higherPriorityLanes; - root = root.eventTimes; - updateLane = 31 - clz32(updateLane); - root[updateLane] = eventTime; -} -var clz32 = Math.clz32 ? Math.clz32 : clz32Fallback, - log = Math.log, - LN2 = Math.LN2; -function clz32Fallback(lanes) { - return 0 === lanes ? 32 : (31 - ((log(lanes) / LN2) | 0)) | 0; -} var Scheduler_runWithPriority = Scheduler.unstable_runWithPriority, Scheduler_scheduleCallback = Scheduler.unstable_scheduleCallback, Scheduler_cancelCallback = Scheduler.unstable_cancelCallback, Scheduler_shouldYield = Scheduler.unstable_shouldYield, Scheduler_requestPaint = Scheduler.unstable_requestPaint, - Scheduler_now$1 = Scheduler.unstable_now, + Scheduler_now = Scheduler.unstable_now, Scheduler_getCurrentPriorityLevel = Scheduler.unstable_getCurrentPriorityLevel, Scheduler_ImmediatePriority = Scheduler.unstable_ImmediatePriority, @@ -1986,12 +1696,12 @@ var fakeCallbackNode = {}, syncQueue = null, immediateQueueCallbackNode = null, isFlushingSyncQueue = !1, - initialTimeMs$1 = Scheduler_now$1(), + initialTimeMs = Scheduler_now(), now = - 1e4 > initialTimeMs$1 - ? Scheduler_now$1 + 1e4 > initialTimeMs + ? Scheduler_now : function() { - return Scheduler_now$1() - initialTimeMs$1; + return Scheduler_now() - initialTimeMs; }; function getCurrentPriorityLevel() { switch (Scheduler_getCurrentPriorityLevel()) { @@ -2033,6 +1743,16 @@ function scheduleCallback(reactPriorityLevel, callback, options) { reactPriorityLevel = reactPriorityToSchedulerPriority(reactPriorityLevel); return Scheduler_scheduleCallback(reactPriorityLevel, callback, options); } +function scheduleSyncCallback(callback) { + null === syncQueue + ? ((syncQueue = [callback]), + (immediateQueueCallbackNode = Scheduler_scheduleCallback( + Scheduler_ImmediatePriority, + flushSyncCallbackQueueImpl + ))) + : syncQueue.push(callback); + return fakeCallbackNode; +} function flushSyncCallbackQueue() { if (null !== immediateQueueCallbackNode) { var node = immediateQueueCallbackNode; @@ -2067,29 +1787,18 @@ function flushSyncCallbackQueueImpl() { } } } -function describeFiber(fiber) { - switch (fiber.tag) { - case 5: - return describeComponentFrame(fiber.type, null, null); - case 16: - return describeComponentFrame("Lazy", null, null); - case 13: - return describeComponentFrame("Suspense", null, null); - case 19: - return describeComponentFrame("SuspenseList", null, null); - case 0: - case 2: - case 15: - return describeFunctionComponentFrame(fiber.type, null); - case 11: - return describeFunctionComponentFrame(fiber.type.render, null); - case 22: - return describeFunctionComponentFrame(fiber.type._render, null); - case 1: - return (fiber = describeFunctionComponentFrame(fiber.type, null)), fiber; - default: - return ""; - } +function inferPriorityFromExpirationTime(currentTime, expirationTime) { + if (1073741823 === expirationTime) return 99; + if (1 === expirationTime || 2 === expirationTime) return 95; + currentTime = + 10 * (1073741821 - expirationTime) - 10 * (1073741821 - currentTime); + return 0 >= currentTime + ? 99 + : 250 >= currentTime + ? 98 + : 5250 >= currentTime + ? 97 + : 95; } function is(x, y) { return (x === y && (0 !== x || 1 / x === 1 / y)) || (x !== x && y !== y); @@ -2116,6 +1825,43 @@ function shallowEqual(objA, objB) { return !1; return !0; } +var BEFORE_SLASH_RE = /^(.*)[\\\/]/; +function getStackByFiberInDevAndProd(workInProgress) { + var info = ""; + do { + a: switch (workInProgress.tag) { + case 3: + case 4: + case 6: + case 7: + case 10: + case 9: + var JSCompiler_inline_result = ""; + break a; + default: + var owner = workInProgress._debugOwner, + source = workInProgress._debugSource, + name = getComponentName(workInProgress.type); + JSCompiler_inline_result = null; + owner && (JSCompiler_inline_result = getComponentName(owner.type)); + owner = name; + name = ""; + source + ? (name = + " (at " + + source.fileName.replace(BEFORE_SLASH_RE, "") + + ":" + + source.lineNumber + + ")") + : JSCompiler_inline_result && + (name = " (created by " + JSCompiler_inline_result + ")"); + JSCompiler_inline_result = "\n in " + (owner || "Unknown") + name; + } + info += JSCompiler_inline_result; + workInProgress = workInProgress.return; + } while (workInProgress); + return info; +} function resolveDefaultProps(Component, baseProps) { if (Component && Component.defaultProps) { baseProps = Object.assign({}, baseProps); @@ -2123,11 +1869,10 @@ function resolveDefaultProps(Component, baseProps) { for (var propName in Component) void 0 === baseProps[propName] && (baseProps[propName] = Component[propName]); - return baseProps; } return baseProps; } -var valueCursor = createCursor(null), +var valueCursor = { current: null }, currentlyRenderingFiber = null, lastContextDependency = null, lastContextWithAllBitsObserved = null; @@ -2139,29 +1884,31 @@ function popProvider(providerFiber) { pop(valueCursor); providerFiber.type._context._currentValue2 = currentValue; } -function scheduleWorkOnParentPath(parent, renderLanes) { +function scheduleWorkOnParentPath(parent, renderExpirationTime) { for (; null !== parent; ) { var alternate = parent.alternate; - if ((parent.childLanes & renderLanes) === renderLanes) - if ( - null === alternate || - (alternate.childLanes & renderLanes) === renderLanes - ) - break; - else alternate.childLanes |= renderLanes; - else - (parent.childLanes |= renderLanes), - null !== alternate && (alternate.childLanes |= renderLanes); + if (parent.childExpirationTime < renderExpirationTime) + (parent.childExpirationTime = renderExpirationTime), + null !== alternate && + alternate.childExpirationTime < renderExpirationTime && + (alternate.childExpirationTime = renderExpirationTime); + else if ( + null !== alternate && + alternate.childExpirationTime < renderExpirationTime + ) + alternate.childExpirationTime = renderExpirationTime; + else break; parent = parent.return; } } -function prepareToReadContext(workInProgress, renderLanes) { +function prepareToReadContext(workInProgress, renderExpirationTime) { currentlyRenderingFiber = workInProgress; lastContextWithAllBitsObserved = lastContextDependency = null; workInProgress = workInProgress.dependencies; null !== workInProgress && null !== workInProgress.firstContext && - (0 !== (workInProgress.lanes & renderLanes) && (didReceiveUpdate = !0), + (workInProgress.expirationTime >= renderExpirationTime && + (didReceiveUpdate = !0), (workInProgress.firstContext = null)); } function readContext(context, observedBits) { @@ -2180,7 +1927,7 @@ function readContext(context, observedBits) { ); lastContextDependency = observedBits; currentlyRenderingFiber.dependencies = { - lanes: 0, + expirationTime: 0, firstContext: observedBits, responders: null }; @@ -2192,8 +1939,7 @@ var hasForceUpdate = !1; function initializeUpdateQueue(fiber) { fiber.updateQueue = { baseState: fiber.memoizedState, - firstBaseUpdate: null, - lastBaseUpdate: null, + baseQueue: null, shared: { pending: null }, effects: null }; @@ -2203,22 +1949,21 @@ function cloneUpdateQueue(current, workInProgress) { workInProgress.updateQueue === current && (workInProgress.updateQueue = { baseState: current.baseState, - firstBaseUpdate: current.firstBaseUpdate, - lastBaseUpdate: current.lastBaseUpdate, + baseQueue: current.baseQueue, shared: current.shared, effects: current.effects }); } -function createUpdate(eventTime, lane, suspenseConfig) { - return { - eventTime: eventTime, - lane: lane, +function createUpdate(expirationTime, suspenseConfig) { + expirationTime = { + expirationTime: expirationTime, suspenseConfig: suspenseConfig, tag: 0, payload: null, callback: null, next: null }; + return (expirationTime.next = expirationTime); } function enqueueUpdate(fiber, update) { fiber = fiber.updateQueue; @@ -2231,185 +1976,132 @@ function enqueueUpdate(fiber, update) { fiber.pending = update; } } -function enqueueCapturedUpdate(workInProgress, capturedUpdate) { - var queue = workInProgress.updateQueue, - current = workInProgress.alternate; - if ( - null !== current && - ((current = current.updateQueue), queue === current) - ) { - var newFirst = null, - newLast = null; - queue = queue.firstBaseUpdate; - if (null !== queue) { - do { - var clone = { - eventTime: queue.eventTime, - lane: queue.lane, - suspenseConfig: queue.suspenseConfig, - tag: queue.tag, - payload: queue.payload, - callback: queue.callback, - next: null - }; - null === newLast - ? (newFirst = newLast = clone) - : (newLast = newLast.next = clone); - queue = queue.next; - } while (null !== queue); - null === newLast - ? (newFirst = newLast = capturedUpdate) - : (newLast = newLast.next = capturedUpdate); - } else newFirst = newLast = capturedUpdate; - queue = { - baseState: current.baseState, - firstBaseUpdate: newFirst, - lastBaseUpdate: newLast, - shared: current.shared, - effects: current.effects - }; - workInProgress.updateQueue = queue; - return; - } - workInProgress = queue.lastBaseUpdate; - null === workInProgress - ? (queue.firstBaseUpdate = capturedUpdate) - : (workInProgress.next = capturedUpdate); - queue.lastBaseUpdate = capturedUpdate; +function enqueueCapturedUpdate(workInProgress, update) { + var current = workInProgress.alternate; + null !== current && cloneUpdateQueue(current, workInProgress); + workInProgress = workInProgress.updateQueue; + current = workInProgress.baseQueue; + null === current + ? ((workInProgress.baseQueue = update.next = update), + (update.next = update)) + : ((update.next = current.next), (current.next = update)); } function processUpdateQueue( workInProgress$jscomp$0, props, instance, - renderLanes + renderExpirationTime ) { var queue = workInProgress$jscomp$0.updateQueue; hasForceUpdate = !1; - var firstBaseUpdate = queue.firstBaseUpdate, - lastBaseUpdate = queue.lastBaseUpdate, + var baseQueue = queue.baseQueue, pendingQueue = queue.shared.pending; if (null !== pendingQueue) { - queue.shared.pending = null; - var lastPendingUpdate = pendingQueue, - firstPendingUpdate = lastPendingUpdate.next; - lastPendingUpdate.next = null; - null === lastBaseUpdate - ? (firstBaseUpdate = firstPendingUpdate) - : (lastBaseUpdate.next = firstPendingUpdate); - lastBaseUpdate = lastPendingUpdate; - var current = workInProgress$jscomp$0.alternate; - if (null !== current) { - current = current.updateQueue; - var currentLastBaseUpdate = current.lastBaseUpdate; - currentLastBaseUpdate !== lastBaseUpdate && - (null === currentLastBaseUpdate - ? (current.firstBaseUpdate = firstPendingUpdate) - : (currentLastBaseUpdate.next = firstPendingUpdate), - (current.lastBaseUpdate = lastPendingUpdate)); + if (null !== baseQueue) { + var baseFirst = baseQueue.next; + baseQueue.next = pendingQueue.next; + pendingQueue.next = baseFirst; } + baseQueue = pendingQueue; + queue.shared.pending = null; + baseFirst = workInProgress$jscomp$0.alternate; + null !== baseFirst && + ((baseFirst = baseFirst.updateQueue), + null !== baseFirst && (baseFirst.baseQueue = pendingQueue)); } - if (null !== firstBaseUpdate) { - currentLastBaseUpdate = queue.baseState; - lastBaseUpdate = 0; - current = firstPendingUpdate = lastPendingUpdate = null; - do { - pendingQueue = firstBaseUpdate.lane; - var updateEventTime = firstBaseUpdate.eventTime; - if ((renderLanes & pendingQueue) === pendingQueue) { - null !== current && - (current = current.next = { - eventTime: updateEventTime, - lane: 0, - suspenseConfig: firstBaseUpdate.suspenseConfig, - tag: firstBaseUpdate.tag, - payload: firstBaseUpdate.payload, - callback: firstBaseUpdate.callback, + if (null !== baseQueue) { + baseFirst = baseQueue.next; + var newState = queue.baseState, + newExpirationTime = 0, + newBaseState = null, + newBaseQueueFirst = null, + newBaseQueueLast = null; + if (null !== baseFirst) { + var update = baseFirst; + do { + pendingQueue = update.expirationTime; + if (pendingQueue < renderExpirationTime) { + var clone = { + expirationTime: update.expirationTime, + suspenseConfig: update.suspenseConfig, + tag: update.tag, + payload: update.payload, + callback: update.callback, next: null - }); - markRenderEventTimeAndConfig( - updateEventTime, - firstBaseUpdate.suspenseConfig - ); - a: { - var workInProgress = workInProgress$jscomp$0, - update = firstBaseUpdate; - pendingQueue = props; - updateEventTime = instance; - switch (update.tag) { - case 1: - workInProgress = update.payload; - if ("function" === typeof workInProgress) { - currentLastBaseUpdate = workInProgress.call( - updateEventTime, - currentLastBaseUpdate, - pendingQueue - ); + }; + null === newBaseQueueLast + ? ((newBaseQueueFirst = newBaseQueueLast = clone), + (newBaseState = newState)) + : (newBaseQueueLast = newBaseQueueLast.next = clone); + pendingQueue > newExpirationTime && + (newExpirationTime = pendingQueue); + } else { + null !== newBaseQueueLast && + (newBaseQueueLast = newBaseQueueLast.next = { + expirationTime: 1073741823, + suspenseConfig: update.suspenseConfig, + tag: update.tag, + payload: update.payload, + callback: update.callback, + next: null + }); + markRenderEventTimeAndConfig(pendingQueue, update.suspenseConfig); + a: { + var workInProgress = workInProgress$jscomp$0, + update$jscomp$0 = update; + pendingQueue = props; + clone = instance; + switch (update$jscomp$0.tag) { + case 1: + workInProgress = update$jscomp$0.payload; + if ("function" === typeof workInProgress) { + newState = workInProgress.call(clone, newState, pendingQueue); + break a; + } + newState = workInProgress; break a; - } - currentLastBaseUpdate = workInProgress; - break a; - case 3: - workInProgress.effectTag = - (workInProgress.effectTag & -4097) | 64; - case 0: - workInProgress = update.payload; - pendingQueue = - "function" === typeof workInProgress - ? workInProgress.call( - updateEventTime, - currentLastBaseUpdate, - pendingQueue - ) - : workInProgress; - if (null === pendingQueue || void 0 === pendingQueue) break a; - currentLastBaseUpdate = Object.assign( - {}, - currentLastBaseUpdate, - pendingQueue - ); - break a; - case 2: - hasForceUpdate = !0; + case 3: + workInProgress.effectTag = + (workInProgress.effectTag & -4097) | 64; + case 0: + workInProgress = update$jscomp$0.payload; + pendingQueue = + "function" === typeof workInProgress + ? workInProgress.call(clone, newState, pendingQueue) + : workInProgress; + if (null === pendingQueue || void 0 === pendingQueue) break a; + newState = Object.assign({}, newState, pendingQueue); + break a; + case 2: + hasForceUpdate = !0; + } } + null !== update.callback && + ((workInProgress$jscomp$0.effectTag |= 32), + (pendingQueue = queue.effects), + null === pendingQueue + ? (queue.effects = [update]) + : pendingQueue.push(update)); } - null !== firstBaseUpdate.callback && - ((workInProgress$jscomp$0.effectTag |= 32), - (pendingQueue = queue.effects), - null === pendingQueue - ? (queue.effects = [firstBaseUpdate]) - : pendingQueue.push(firstBaseUpdate)); - } else - (updateEventTime = { - eventTime: updateEventTime, - lane: pendingQueue, - suspenseConfig: firstBaseUpdate.suspenseConfig, - tag: firstBaseUpdate.tag, - payload: firstBaseUpdate.payload, - callback: firstBaseUpdate.callback, - next: null - }), - null === current - ? ((firstPendingUpdate = current = updateEventTime), - (lastPendingUpdate = currentLastBaseUpdate)) - : (current = current.next = updateEventTime), - (lastBaseUpdate |= pendingQueue); - firstBaseUpdate = firstBaseUpdate.next; - if (null === firstBaseUpdate) - if (((pendingQueue = queue.shared.pending), null === pendingQueue)) - break; - else - (firstBaseUpdate = pendingQueue.next), - (pendingQueue.next = null), - (queue.lastBaseUpdate = pendingQueue), - (queue.shared.pending = null); - } while (1); - null === current && (lastPendingUpdate = currentLastBaseUpdate); - queue.baseState = lastPendingUpdate; - queue.firstBaseUpdate = firstPendingUpdate; - queue.lastBaseUpdate = current; - workInProgressRootSkippedLanes |= lastBaseUpdate; - workInProgress$jscomp$0.lanes = lastBaseUpdate; - workInProgress$jscomp$0.memoizedState = currentLastBaseUpdate; + update = update.next; + if (null === update || update === baseFirst) + if (((pendingQueue = queue.shared.pending), null === pendingQueue)) + break; + else + (update = baseQueue.next = pendingQueue.next), + (pendingQueue.next = baseFirst), + (queue.baseQueue = baseQueue = pendingQueue), + (queue.shared.pending = null); + } while (1); + } + null === newBaseQueueLast + ? (newBaseState = newState) + : (newBaseQueueLast.next = newBaseQueueFirst); + queue.baseState = newBaseState; + queue.baseQueue = newBaseQueueLast; + markUnprocessedUpdateTime(newExpirationTime); + workInProgress$jscomp$0.expirationTime = newExpirationTime; + workInProgress$jscomp$0.memoizedState = newState; } } function commitUpdateQueue(finishedWork, finishedQueue, instance) { @@ -2449,54 +2141,54 @@ function applyDerivedStateFromProps( ? ctor : Object.assign({}, ctor, getDerivedStateFromProps); workInProgress.memoizedState = getDerivedStateFromProps; - 0 === workInProgress.lanes && + 0 === workInProgress.expirationTime && (workInProgress.updateQueue.baseState = getDerivedStateFromProps); } var classComponentUpdater = { isMounted: function(component) { - return (component = component._reactInternals) + return (component = component._reactInternalFiber) ? getNearestMountedFiber(component) === component : !1; }, enqueueSetState: function(inst, payload, callback) { - inst = inst._reactInternals; - var eventTime = requestEventTime(), - suspenseConfig = ReactCurrentBatchConfig.suspense, - lane = requestUpdateLane(inst, suspenseConfig); - suspenseConfig = createUpdate(eventTime, lane, suspenseConfig); + inst = inst._reactInternalFiber; + var currentTime = requestCurrentTimeForUpdate(), + suspenseConfig = ReactCurrentBatchConfig.suspense; + currentTime = computeExpirationForFiber(currentTime, inst, suspenseConfig); + suspenseConfig = createUpdate(currentTime, suspenseConfig); suspenseConfig.payload = payload; void 0 !== callback && null !== callback && (suspenseConfig.callback = callback); enqueueUpdate(inst, suspenseConfig); - scheduleUpdateOnFiber(inst, lane, eventTime); + scheduleWork(inst, currentTime); }, enqueueReplaceState: function(inst, payload, callback) { - inst = inst._reactInternals; - var eventTime = requestEventTime(), - suspenseConfig = ReactCurrentBatchConfig.suspense, - lane = requestUpdateLane(inst, suspenseConfig); - suspenseConfig = createUpdate(eventTime, lane, suspenseConfig); + inst = inst._reactInternalFiber; + var currentTime = requestCurrentTimeForUpdate(), + suspenseConfig = ReactCurrentBatchConfig.suspense; + currentTime = computeExpirationForFiber(currentTime, inst, suspenseConfig); + suspenseConfig = createUpdate(currentTime, suspenseConfig); suspenseConfig.tag = 1; suspenseConfig.payload = payload; void 0 !== callback && null !== callback && (suspenseConfig.callback = callback); enqueueUpdate(inst, suspenseConfig); - scheduleUpdateOnFiber(inst, lane, eventTime); + scheduleWork(inst, currentTime); }, enqueueForceUpdate: function(inst, callback) { - inst = inst._reactInternals; - var eventTime = requestEventTime(), - suspenseConfig = ReactCurrentBatchConfig.suspense, - lane = requestUpdateLane(inst, suspenseConfig); - suspenseConfig = createUpdate(eventTime, lane, suspenseConfig); + inst = inst._reactInternalFiber; + var currentTime = requestCurrentTimeForUpdate(), + suspenseConfig = ReactCurrentBatchConfig.suspense; + currentTime = computeExpirationForFiber(currentTime, inst, suspenseConfig); + suspenseConfig = createUpdate(currentTime, suspenseConfig); suspenseConfig.tag = 2; void 0 !== callback && null !== callback && (suspenseConfig.callback = callback); enqueueUpdate(inst, suspenseConfig); - scheduleUpdateOnFiber(inst, lane, eventTime); + scheduleWork(inst, currentTime); } }; function checkShouldComponentUpdate( @@ -2534,7 +2226,7 @@ function constructClassInstance(workInProgress, ctor, props) { null !== ctor.state && void 0 !== ctor.state ? ctor.state : null; ctor.updater = classComponentUpdater; workInProgress.stateNode = ctor; - ctor._reactInternals = workInProgress; + ctor._reactInternalFiber = workInProgress; isLegacyContextConsumer && ((workInProgress = workInProgress.stateNode), (workInProgress.__reactInternalMemoizedUnmaskedChildContext = unmaskedContext), @@ -2555,7 +2247,12 @@ function callComponentWillReceiveProps( instance.state !== workInProgress && classComponentUpdater.enqueueReplaceState(instance, instance.state, null); } -function mountClassInstance(workInProgress, ctor, newProps, renderLanes) { +function mountClassInstance( + workInProgress, + ctor, + newProps, + renderExpirationTime +) { var instance = workInProgress.stateNode; instance.props = newProps; instance.state = workInProgress.memoizedState; @@ -2568,7 +2265,7 @@ function mountClassInstance(workInProgress, ctor, newProps, renderLanes) { ? previousContext : contextStackCursor.current), (instance.context = getMaskedContext(workInProgress, contextType))); - processUpdateQueue(workInProgress, newProps, instance, renderLanes); + processUpdateQueue(workInProgress, newProps, instance, renderExpirationTime); instance.state = workInProgress.memoizedState; contextType = ctor.getDerivedStateFromProps; "function" === typeof contextType && @@ -2585,7 +2282,12 @@ function mountClassInstance(workInProgress, ctor, newProps, renderLanes) { instance.UNSAFE_componentWillMount(), ctor !== instance.state && classComponentUpdater.enqueueReplaceState(instance, instance.state, null), - processUpdateQueue(workInProgress, newProps, instance, renderLanes), + processUpdateQueue( + workInProgress, + newProps, + instance, + renderExpirationTime + ), (instance.state = workInProgress.memoizedState)); "function" === typeof instance.componentDidMount && (workInProgress.effectTag |= 4); @@ -2649,7 +2351,7 @@ function throwOnInvalidObjectType(returnFiber, newChild) { ("[object Object]" === Object.prototype.toString.call(newChild) ? "object with keys {" + Object.keys(newChild).join(", ") + "}" : newChild) + - "). If you meant to render a collection of children, use an array instead." + ")." ); } function ChildReconciler(shouldTrackSideEffects) { @@ -2705,10 +2407,14 @@ function ChildReconciler(shouldTrackSideEffects) { (newFiber.effectTag = 2); return newFiber; } - function updateTextNode(returnFiber, current, textContent, lanes) { + function updateTextNode(returnFiber, current, textContent, expirationTime) { if (null === current || 6 !== current.tag) return ( - (current = createFiberFromText(textContent, returnFiber.mode, lanes)), + (current = createFiberFromText( + textContent, + returnFiber.mode, + expirationTime + )), (current.return = returnFiber), current ); @@ -2716,27 +2422,27 @@ function ChildReconciler(shouldTrackSideEffects) { current.return = returnFiber; return current; } - function updateElement(returnFiber, current, element, lanes) { + function updateElement(returnFiber, current, element, expirationTime) { if (null !== current && current.elementType === element.type) return ( - (lanes = useFiber(current, element.props)), - (lanes.ref = coerceRef(returnFiber, current, element)), - (lanes.return = returnFiber), - lanes + (expirationTime = useFiber(current, element.props)), + (expirationTime.ref = coerceRef(returnFiber, current, element)), + (expirationTime.return = returnFiber), + expirationTime ); - lanes = createFiberFromTypeAndProps( + expirationTime = createFiberFromTypeAndProps( element.type, element.key, element.props, null, returnFiber.mode, - lanes + expirationTime ); - lanes.ref = coerceRef(returnFiber, current, element); - lanes.return = returnFiber; - return lanes; + expirationTime.ref = coerceRef(returnFiber, current, element); + expirationTime.return = returnFiber; + return expirationTime; } - function updatePortal(returnFiber, current, portal, lanes) { + function updatePortal(returnFiber, current, portal, expirationTime) { if ( null === current || 4 !== current.tag || @@ -2744,7 +2450,11 @@ function ChildReconciler(shouldTrackSideEffects) { current.stateNode.implementation !== portal.implementation ) return ( - (current = createFiberFromPortal(portal, returnFiber.mode, lanes)), + (current = createFiberFromPortal( + portal, + returnFiber.mode, + expirationTime + )), (current.return = returnFiber), current ); @@ -2752,13 +2462,13 @@ function ChildReconciler(shouldTrackSideEffects) { current.return = returnFiber; return current; } - function updateFragment(returnFiber, current, fragment, lanes, key) { + function updateFragment(returnFiber, current, fragment, expirationTime, key) { if (null === current || 7 !== current.tag) return ( (current = createFiberFromFragment( fragment, returnFiber.mode, - lanes, + expirationTime, key )), (current.return = returnFiber), @@ -2768,13 +2478,13 @@ function ChildReconciler(shouldTrackSideEffects) { current.return = returnFiber; return current; } - function createChild(returnFiber, newChild, lanes) { + function createChild(returnFiber, newChild, expirationTime) { if ("string" === typeof newChild || "number" === typeof newChild) return ( (newChild = createFiberFromText( "" + newChild, returnFiber.mode, - lanes + expirationTime )), (newChild.return = returnFiber), newChild @@ -2783,24 +2493,24 @@ function ChildReconciler(shouldTrackSideEffects) { switch (newChild.$$typeof) { case REACT_ELEMENT_TYPE: return ( - (lanes = createFiberFromTypeAndProps( + (expirationTime = createFiberFromTypeAndProps( newChild.type, newChild.key, newChild.props, null, returnFiber.mode, - lanes + expirationTime )), - (lanes.ref = coerceRef(returnFiber, null, newChild)), - (lanes.return = returnFiber), - lanes + (expirationTime.ref = coerceRef(returnFiber, null, newChild)), + (expirationTime.return = returnFiber), + expirationTime ); case REACT_PORTAL_TYPE: return ( (newChild = createFiberFromPortal( newChild, returnFiber.mode, - lanes + expirationTime )), (newChild.return = returnFiber), newChild @@ -2811,7 +2521,7 @@ function ChildReconciler(shouldTrackSideEffects) { (newChild = createFiberFromFragment( newChild, returnFiber.mode, - lanes, + expirationTime, null )), (newChild.return = returnFiber), @@ -2821,12 +2531,12 @@ function ChildReconciler(shouldTrackSideEffects) { } return null; } - function updateSlot(returnFiber, oldFiber, newChild, lanes) { + function updateSlot(returnFiber, oldFiber, newChild, expirationTime) { var key = null !== oldFiber ? oldFiber.key : null; if ("string" === typeof newChild || "number" === typeof newChild) return null !== key ? null - : updateTextNode(returnFiber, oldFiber, "" + newChild, lanes); + : updateTextNode(returnFiber, oldFiber, "" + newChild, expirationTime); if ("object" === typeof newChild && null !== newChild) { switch (newChild.$$typeof) { case REACT_ELEMENT_TYPE: @@ -2836,20 +2546,26 @@ function ChildReconciler(shouldTrackSideEffects) { returnFiber, oldFiber, newChild.props.children, - lanes, + expirationTime, key ) - : updateElement(returnFiber, oldFiber, newChild, lanes) + : updateElement(returnFiber, oldFiber, newChild, expirationTime) : null; case REACT_PORTAL_TYPE: return newChild.key === key - ? updatePortal(returnFiber, oldFiber, newChild, lanes) + ? updatePortal(returnFiber, oldFiber, newChild, expirationTime) : null; } if (isArray(newChild) || getIteratorFn(newChild)) return null !== key ? null - : updateFragment(returnFiber, oldFiber, newChild, lanes, null); + : updateFragment( + returnFiber, + oldFiber, + newChild, + expirationTime, + null + ); throwOnInvalidObjectType(returnFiber, newChild); } return null; @@ -2859,12 +2575,17 @@ function ChildReconciler(shouldTrackSideEffects) { returnFiber, newIdx, newChild, - lanes + expirationTime ) { if ("string" === typeof newChild || "number" === typeof newChild) return ( (existingChildren = existingChildren.get(newIdx) || null), - updateTextNode(returnFiber, existingChildren, "" + newChild, lanes) + updateTextNode( + returnFiber, + existingChildren, + "" + newChild, + expirationTime + ) ); if ("object" === typeof newChild && null !== newChild) { switch (newChild.$$typeof) { @@ -2879,10 +2600,15 @@ function ChildReconciler(shouldTrackSideEffects) { returnFiber, existingChildren, newChild.props.children, - lanes, + expirationTime, newChild.key ) - : updateElement(returnFiber, existingChildren, newChild, lanes) + : updateElement( + returnFiber, + existingChildren, + newChild, + expirationTime + ) ); case REACT_PORTAL_TYPE: return ( @@ -2890,13 +2616,24 @@ function ChildReconciler(shouldTrackSideEffects) { existingChildren.get( null === newChild.key ? newIdx : newChild.key ) || null), - updatePortal(returnFiber, existingChildren, newChild, lanes) + updatePortal( + returnFiber, + existingChildren, + newChild, + expirationTime + ) ); } if (isArray(newChild) || getIteratorFn(newChild)) return ( (existingChildren = existingChildren.get(newIdx) || null), - updateFragment(returnFiber, existingChildren, newChild, lanes, null) + updateFragment( + returnFiber, + existingChildren, + newChild, + expirationTime, + null + ) ); throwOnInvalidObjectType(returnFiber, newChild); } @@ -2906,7 +2643,7 @@ function ChildReconciler(shouldTrackSideEffects) { returnFiber, currentFirstChild, newChildren, - lanes + expirationTime ) { for ( var resultingFirstChild = null, @@ -2924,7 +2661,7 @@ function ChildReconciler(shouldTrackSideEffects) { returnFiber, oldFiber, newChildren[newIdx], - lanes + expirationTime ); if (null === newFiber) { null === oldFiber && (oldFiber = nextOldFiber); @@ -2947,7 +2684,11 @@ function ChildReconciler(shouldTrackSideEffects) { ); if (null === oldFiber) { for (; newIdx < newChildren.length; newIdx++) - (oldFiber = createChild(returnFiber, newChildren[newIdx], lanes)), + (oldFiber = createChild( + returnFiber, + newChildren[newIdx], + expirationTime + )), null !== oldFiber && ((currentFirstChild = placeChild( oldFiber, @@ -2970,7 +2711,7 @@ function ChildReconciler(shouldTrackSideEffects) { returnFiber, newIdx, newChildren[newIdx], - lanes + expirationTime )), null !== nextOldFiber && (shouldTrackSideEffects && @@ -2997,7 +2738,7 @@ function ChildReconciler(shouldTrackSideEffects) { returnFiber, currentFirstChild, newChildrenIterable, - lanes + expirationTime ) { var iteratorFn = getIteratorFn(newChildrenIterable); if ("function" !== typeof iteratorFn) @@ -3019,7 +2760,12 @@ function ChildReconciler(shouldTrackSideEffects) { oldFiber.index > newIdx ? ((nextOldFiber = oldFiber), (oldFiber = null)) : (nextOldFiber = oldFiber.sibling); - var newFiber = updateSlot(returnFiber, oldFiber, step.value, lanes); + var newFiber = updateSlot( + returnFiber, + oldFiber, + step.value, + expirationTime + ); if (null === newFiber) { null === oldFiber && (oldFiber = nextOldFiber); break; @@ -3039,7 +2785,7 @@ function ChildReconciler(shouldTrackSideEffects) { return deleteRemainingChildren(returnFiber, oldFiber), iteratorFn; if (null === oldFiber) { for (; !step.done; newIdx++, step = newChildrenIterable.next()) - (step = createChild(returnFiber, step.value, lanes)), + (step = createChild(returnFiber, step.value, expirationTime)), null !== step && ((currentFirstChild = placeChild(step, currentFirstChild, newIdx)), null === previousNewFiber @@ -3053,7 +2799,13 @@ function ChildReconciler(shouldTrackSideEffects) { !step.done; newIdx++, step = newChildrenIterable.next() ) - (step = updateFromMap(oldFiber, returnFiber, newIdx, step.value, lanes)), + (step = updateFromMap( + oldFiber, + returnFiber, + newIdx, + step.value, + expirationTime + )), null !== step && (shouldTrackSideEffects && null !== step.alternate && @@ -3069,7 +2821,7 @@ function ChildReconciler(shouldTrackSideEffects) { }); return iteratorFn; } - return function(returnFiber, currentFirstChild, newChild, lanes) { + return function(returnFiber, currentFirstChild, newChild, expirationTime) { var isUnkeyedTopLevelFragment = "object" === typeof newChild && null !== newChild && @@ -3135,26 +2887,26 @@ function ChildReconciler(shouldTrackSideEffects) { ? ((currentFirstChild = createFiberFromFragment( newChild.props.children, returnFiber.mode, - lanes, + expirationTime, newChild.key )), (currentFirstChild.return = returnFiber), (returnFiber = currentFirstChild)) - : ((lanes = createFiberFromTypeAndProps( + : ((expirationTime = createFiberFromTypeAndProps( newChild.type, newChild.key, newChild.props, null, returnFiber.mode, - lanes + expirationTime )), - (lanes.ref = coerceRef( + (expirationTime.ref = coerceRef( returnFiber, currentFirstChild, newChild )), - (lanes.return = returnFiber), - (returnFiber = lanes)); + (expirationTime.return = returnFiber), + (returnFiber = expirationTime)); } return placeSingleChild(returnFiber); case REACT_PORTAL_TYPE: @@ -3193,7 +2945,7 @@ function ChildReconciler(shouldTrackSideEffects) { currentFirstChild = createFiberFromPortal( newChild, returnFiber.mode, - lanes + expirationTime ); currentFirstChild.return = returnFiber; returnFiber = currentFirstChild; @@ -3212,7 +2964,7 @@ function ChildReconciler(shouldTrackSideEffects) { (currentFirstChild = createFiberFromText( newChild, returnFiber.mode, - lanes + expirationTime )), (currentFirstChild.return = returnFiber), (returnFiber = currentFirstChild)), @@ -3223,14 +2975,14 @@ function ChildReconciler(shouldTrackSideEffects) { returnFiber, currentFirstChild, newChild, - lanes + expirationTime ); if (getIteratorFn(newChild)) return reconcileChildrenIterator( returnFiber, currentFirstChild, newChild, - lanes + expirationTime ); isObject && throwOnInvalidObjectType(returnFiber, newChild); if ("undefined" === typeof newChild && !isUnkeyedTopLevelFragment) @@ -3249,9 +3001,9 @@ function ChildReconciler(shouldTrackSideEffects) { var reconcileChildFibers = ChildReconciler(!0), mountChildFibers = ChildReconciler(!1), NO_CONTEXT = {}, - contextStackCursor$1 = createCursor(NO_CONTEXT), - contextFiberStackCursor = createCursor(NO_CONTEXT), - rootInstanceStackCursor = createCursor(NO_CONTEXT); + contextStackCursor$1 = { current: NO_CONTEXT }, + contextFiberStackCursor = { current: NO_CONTEXT }, + rootInstanceStackCursor = { current: NO_CONTEXT }; function requiredContext(c) { if (c === NO_CONTEXT) throw Error( @@ -3274,26 +3026,26 @@ function popHostContainer() { function pushHostContext(fiber) { requiredContext(rootInstanceStackCursor.current); var context = requiredContext(contextStackCursor$1.current); - var JSCompiler_inline_result = fiber.type; - JSCompiler_inline_result = - "AndroidTextInput" === JSCompiler_inline_result || - "RCTMultilineTextInputView" === JSCompiler_inline_result || - "RCTSinglelineTextInputView" === JSCompiler_inline_result || - "RCTText" === JSCompiler_inline_result || - "RCTVirtualText" === JSCompiler_inline_result; - JSCompiler_inline_result = - context.isInAParentText !== JSCompiler_inline_result - ? { isInAParentText: JSCompiler_inline_result } + var nextContext = fiber.type; + nextContext = + "AndroidTextInput" === nextContext || + "RCTMultilineTextInputView" === nextContext || + "RCTSinglelineTextInputView" === nextContext || + "RCTText" === nextContext || + "RCTVirtualText" === nextContext; + nextContext = + context.isInAParentText !== nextContext + ? { isInAParentText: nextContext } : context; - context !== JSCompiler_inline_result && + context !== nextContext && (push(contextFiberStackCursor, fiber), - push(contextStackCursor$1, JSCompiler_inline_result)); + push(contextStackCursor$1, nextContext)); } function popHostContext(fiber) { contextFiberStackCursor.current === fiber && (pop(contextStackCursor$1), pop(contextFiberStackCursor)); } -var suspenseStackCursor = createCursor(0); +var suspenseStackCursor = { current: 0 }; function findFirstSuspended(row) { for (var node = row; null !== node; ) { if (13 === node.tag) { @@ -3320,20 +3072,13 @@ function findFirstSuspended(row) { function createDeprecatedResponderListener(responder, props) { return { responder: responder, props: props }; } -var workInProgressSources = []; -function resetWorkInProgressVersions() { - for (var i = 0; i < workInProgressSources.length; i++) - workInProgressSources[i]._workInProgressVersionSecondary = null; - workInProgressSources.length = 0; -} -var ReactCurrentDispatcher$1 = ReactSharedInternals.ReactCurrentDispatcher, +var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher, ReactCurrentBatchConfig$1 = ReactSharedInternals.ReactCurrentBatchConfig, - renderLanes = 0, + renderExpirationTime = 0, currentlyRenderingFiber$1 = null, currentHook = null, workInProgressHook = null, - didScheduleRenderPhaseUpdate = !1, - didScheduleRenderPhaseUpdateDuringThisPass = !1; + didScheduleRenderPhaseUpdate = !1; function throwInvalidHookError() { throw Error( "Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:\n1. You might have mismatching versions of React and the renderer (such as React DOM)\n2. You might be breaking the Rules of Hooks\n3. You might have more than one copy of React in the same app\nSee https://fb.me/react-invalid-hook-call for tips about how to debug and fix this problem." @@ -3351,36 +3096,36 @@ function renderWithHooks( Component, props, secondArg, - nextRenderLanes + nextRenderExpirationTime ) { - renderLanes = nextRenderLanes; + renderExpirationTime = nextRenderExpirationTime; currentlyRenderingFiber$1 = workInProgress; workInProgress.memoizedState = null; workInProgress.updateQueue = null; - workInProgress.lanes = 0; - ReactCurrentDispatcher$1.current = + workInProgress.expirationTime = 0; + ReactCurrentDispatcher.current = null === current || null === current.memoizedState ? HooksDispatcherOnMount : HooksDispatcherOnUpdate; current = Component(props, secondArg); - if (didScheduleRenderPhaseUpdateDuringThisPass) { - nextRenderLanes = 0; + if (workInProgress.expirationTime === renderExpirationTime) { + nextRenderExpirationTime = 0; do { - didScheduleRenderPhaseUpdateDuringThisPass = !1; - if (!(25 > nextRenderLanes)) + workInProgress.expirationTime = 0; + if (!(25 > nextRenderExpirationTime)) throw Error( "Too many re-renders. React limits the number of renders to prevent an infinite loop." ); - nextRenderLanes += 1; + nextRenderExpirationTime += 1; workInProgressHook = currentHook = null; workInProgress.updateQueue = null; - ReactCurrentDispatcher$1.current = HooksDispatcherOnRerender; + ReactCurrentDispatcher.current = HooksDispatcherOnRerender; current = Component(props, secondArg); - } while (didScheduleRenderPhaseUpdateDuringThisPass); + } while (workInProgress.expirationTime === renderExpirationTime); } - ReactCurrentDispatcher$1.current = ContextOnlyDispatcher; + ReactCurrentDispatcher.current = ContextOnlyDispatcher; workInProgress = null !== currentHook && null !== currentHook.next; - renderLanes = 0; + renderExpirationTime = 0; workInProgressHook = currentHook = currentlyRenderingFiber$1 = null; didScheduleRenderPhaseUpdate = !1; if (workInProgress) @@ -3461,40 +3206,40 @@ function updateReducer(reducer) { var newBaseQueueLast = (baseFirst = pendingQueue = null), update = baseQueue; do { - var suspenseConfig = update.suspenseConfig, - updateLane = update.lane, - updateEventTime = update.eventTime; - (renderLanes & updateLane) === updateLane - ? (null !== newBaseQueueLast && - (newBaseQueueLast = newBaseQueueLast.next = { - eventTime: updateEventTime, - lane: 0, - suspenseConfig: update.suspenseConfig, - action: update.action, - eagerReducer: update.eagerReducer, - eagerState: update.eagerState, - next: null - }), - markRenderEventTimeAndConfig(updateEventTime, suspenseConfig), - (current = - update.eagerReducer === reducer - ? update.eagerState - : reducer(current, update.action))) - : ((suspenseConfig = { - eventTime: updateEventTime, - lane: updateLane, - suspenseConfig: suspenseConfig, + var updateExpirationTime = update.expirationTime; + if (updateExpirationTime < renderExpirationTime) { + var clone = { + expirationTime: update.expirationTime, + suspenseConfig: update.suspenseConfig, + action: update.action, + eagerReducer: update.eagerReducer, + eagerState: update.eagerState, + next: null + }; + null === newBaseQueueLast + ? ((baseFirst = newBaseQueueLast = clone), (pendingQueue = current)) + : (newBaseQueueLast = newBaseQueueLast.next = clone); + updateExpirationTime > currentlyRenderingFiber$1.expirationTime && + ((currentlyRenderingFiber$1.expirationTime = updateExpirationTime), + markUnprocessedUpdateTime(updateExpirationTime)); + } else + null !== newBaseQueueLast && + (newBaseQueueLast = newBaseQueueLast.next = { + expirationTime: 1073741823, + suspenseConfig: update.suspenseConfig, action: update.action, eagerReducer: update.eagerReducer, eagerState: update.eagerState, next: null }), - null === newBaseQueueLast - ? ((baseFirst = newBaseQueueLast = suspenseConfig), - (pendingQueue = current)) - : (newBaseQueueLast = newBaseQueueLast.next = suspenseConfig), - (currentlyRenderingFiber$1.lanes |= updateLane), - (workInProgressRootSkippedLanes |= updateLane)); + markRenderEventTimeAndConfig( + updateExpirationTime, + update.suspenseConfig + ), + (current = + update.eagerReducer === reducer + ? update.eagerState + : reducer(current, update.action)); update = update.next; } while (null !== update && update !== baseQueue); null === newBaseQueueLast @@ -3531,117 +3276,6 @@ function rerenderReducer(reducer) { } return [newState, dispatch]; } -function readFromUnsubcribedMutableSource(root, source, getSnapshot) { - var getVersion = source._getVersion; - getVersion = getVersion(source._source); - var JSCompiler_inline_result = source._workInProgressVersionSecondary; - if (null !== JSCompiler_inline_result) - root = JSCompiler_inline_result === getVersion; - else if ( - ((root = root.mutableReadLanes), (root = (renderLanes & root) === root)) - ) - (source._workInProgressVersionSecondary = getVersion), - workInProgressSources.push(source); - if (root) return getSnapshot(source._source); - workInProgressSources.push(source); - throw Error( - "Cannot read from mutable source during the current render without tearing. This is a bug in React. Please file an issue." - ); -} -function useMutableSource(hook, source, getSnapshot, subscribe) { - var root = workInProgressRoot; - if (null === root) - throw Error( - "Expected a work-in-progress root. This is a bug in React. Please file an issue." - ); - var getVersion = source._getVersion, - version = getVersion(source._source), - dispatcher = ReactCurrentDispatcher$1.current, - _dispatcher$useState = dispatcher.useState(function() { - return readFromUnsubcribedMutableSource(root, source, getSnapshot); - }), - setSnapshot = _dispatcher$useState[1], - snapshot = _dispatcher$useState[0]; - _dispatcher$useState = workInProgressHook; - var memoizedState = hook.memoizedState, - refs = memoizedState.refs, - prevGetSnapshot = refs.getSnapshot, - prevSource = memoizedState.source; - memoizedState = memoizedState.subscribe; - var fiber = currentlyRenderingFiber$1; - hook.memoizedState = { refs: refs, source: source, subscribe: subscribe }; - dispatcher.useEffect( - function() { - refs.getSnapshot = getSnapshot; - refs.setSnapshot = setSnapshot; - var maybeNewVersion = getVersion(source._source); - if (!objectIs(version, maybeNewVersion)) { - maybeNewVersion = getSnapshot(source._source); - objectIs(snapshot, maybeNewVersion) || - (setSnapshot(maybeNewVersion), - (maybeNewVersion = requestUpdateLane( - fiber, - ReactCurrentBatchConfig.suspense - )), - (root.mutableReadLanes |= maybeNewVersion & root.pendingLanes)); - maybeNewVersion = root.mutableReadLanes; - root.entangledLanes |= maybeNewVersion; - for ( - var entanglements = root.entanglements, lanes = maybeNewVersion; - 0 < lanes; - - ) { - var index$12 = 31 - clz32(lanes), - lane = 1 << index$12; - entanglements[index$12] |= maybeNewVersion; - lanes &= ~lane; - } - } - }, - [getSnapshot, source, subscribe] - ); - dispatcher.useEffect( - function() { - return subscribe(source._source, function() { - var latestGetSnapshot = refs.getSnapshot, - latestSetSnapshot = refs.setSnapshot; - try { - latestSetSnapshot(latestGetSnapshot(source._source)); - var lane = requestUpdateLane(fiber, ReactCurrentBatchConfig.suspense); - root.mutableReadLanes |= lane & root.pendingLanes; - } catch (error) { - latestSetSnapshot(function() { - throw error; - }); - } - }); - }, - [source, subscribe] - ); - (objectIs(prevGetSnapshot, getSnapshot) && - objectIs(prevSource, source) && - objectIs(memoizedState, subscribe)) || - ((hook = { - pending: null, - dispatch: null, - lastRenderedReducer: basicStateReducer, - lastRenderedState: snapshot - }), - (hook.dispatch = setSnapshot = dispatchAction.bind( - null, - currentlyRenderingFiber$1, - hook - )), - (_dispatcher$useState.queue = hook), - (_dispatcher$useState.baseQueue = null), - (snapshot = readFromUnsubcribedMutableSource(root, source, getSnapshot)), - (_dispatcher$useState.memoizedState = _dispatcher$useState.baseState = snapshot)); - return snapshot; -} -function updateMutableSource(source, getSnapshot, subscribe) { - var hook = updateWorkInProgressHook(); - return useMutableSource(hook, source, getSnapshot, subscribe); -} function mountState(initialState) { var hook = mountWorkInProgressHook(); "function" === typeof initialState && (initialState = initialState()); @@ -3790,12 +3424,11 @@ function startTransition(setPending, config, callback) { }); } function dispatchAction(fiber, queue, action) { - var eventTime = requestEventTime(), - suspenseConfig = ReactCurrentBatchConfig.suspense, - lane = requestUpdateLane(fiber, suspenseConfig); + var currentTime = requestCurrentTimeForUpdate(), + suspenseConfig = ReactCurrentBatchConfig.suspense; + currentTime = computeExpirationForFiber(currentTime, fiber, suspenseConfig); suspenseConfig = { - eventTime: eventTime, - lane: lane, + expirationTime: currentTime, suspenseConfig: suspenseConfig, action: action, eagerReducer: null, @@ -3812,11 +3445,13 @@ function dispatchAction(fiber, queue, action) { fiber === currentlyRenderingFiber$1 || (null !== pending && pending === currentlyRenderingFiber$1) ) - didScheduleRenderPhaseUpdateDuringThisPass = didScheduleRenderPhaseUpdate = !0; + (didScheduleRenderPhaseUpdate = !0), + (suspenseConfig.expirationTime = renderExpirationTime), + (currentlyRenderingFiber$1.expirationTime = renderExpirationTime); else { if ( - 0 === fiber.lanes && - (null === pending || 0 === pending.lanes) && + 0 === fiber.expirationTime && + (null === pending || 0 === pending.expirationTime) && ((pending = queue.lastRenderedReducer), null !== pending) ) try { @@ -3828,9 +3463,10 @@ function dispatchAction(fiber, queue, action) { } catch (error) { } finally { } - scheduleUpdateOnFiber(fiber, lane, eventTime); + scheduleWork(fiber, currentTime); } } +function updateEventListener() {} var ContextOnlyDispatcher = { readContext: readContext, useCallback: throwInvalidHookError, @@ -3846,9 +3482,7 @@ var ContextOnlyDispatcher = { useResponder: throwInvalidHookError, useDeferredValue: throwInvalidHookError, useTransition: throwInvalidHookError, - useMutableSource: throwInvalidHookError, - useOpaqueIdentifier: throwInvalidHookError, - unstable_isNewReconciler: !1 + useEvent: throwInvalidHookError }, HooksDispatcherOnMount = { readContext: readContext, @@ -3930,19 +3564,7 @@ var ContextOnlyDispatcher = { isPending ]; }, - useMutableSource: function(source, getSnapshot, subscribe) { - var hook = mountWorkInProgressHook(); - hook.memoizedState = { - refs: { getSnapshot: getSnapshot, setSnapshot: null }, - source: source, - subscribe: subscribe - }; - return useMutableSource(hook, source, getSnapshot, subscribe); - }, - useOpaqueIdentifier: function() { - throw Error("Not yet implemented"); - }, - unstable_isNewReconciler: !1 + useEvent: function() {} }, HooksDispatcherOnUpdate = { readContext: readContext, @@ -3990,11 +3612,7 @@ var ContextOnlyDispatcher = { isPending ]; }, - useMutableSource: updateMutableSource, - useOpaqueIdentifier: function() { - return updateReducer(basicStateReducer)[0]; - }, - unstable_isNewReconciler: !1 + useEvent: updateEventListener }, HooksDispatcherOnRerender = { readContext: readContext, @@ -4042,11 +3660,7 @@ var ContextOnlyDispatcher = { isPending ]; }, - useMutableSource: updateMutableSource, - useOpaqueIdentifier: function() { - return rerenderReducer(basicStateReducer)[0]; - }, - unstable_isNewReconciler: !1 + useEvent: updateEventListener }, now$1 = Scheduler.unstable_now, commitTime = 0, @@ -4059,21 +3673,27 @@ function stopProfilerTimerIfRunningAndRecordDelta(fiber, overrideBaseTime) { profilerStartTime = -1; } } -function transferActualDuration(fiber) { - for (var child = fiber.child; child; ) - (fiber.actualDuration += child.actualDuration), (child = child.sibling); -} var ReactCurrentOwner$1 = ReactSharedInternals.ReactCurrentOwner, didReceiveUpdate = !1; -function reconcileChildren(current, workInProgress, nextChildren, renderLanes) { +function reconcileChildren( + current, + workInProgress, + nextChildren, + renderExpirationTime +) { workInProgress.child = null === current - ? mountChildFibers(workInProgress, null, nextChildren, renderLanes) + ? mountChildFibers( + workInProgress, + null, + nextChildren, + renderExpirationTime + ) : reconcileChildFibers( workInProgress, current.child, nextChildren, - renderLanes + renderExpirationTime ); } function updateForwardRef( @@ -4081,28 +3701,33 @@ function updateForwardRef( workInProgress, Component, nextProps, - renderLanes + renderExpirationTime ) { Component = Component.render; var ref = workInProgress.ref; - prepareToReadContext(workInProgress, renderLanes); + prepareToReadContext(workInProgress, renderExpirationTime); nextProps = renderWithHooks( current, workInProgress, Component, nextProps, ref, - renderLanes + renderExpirationTime ); if (null !== current && !didReceiveUpdate) return ( (workInProgress.updateQueue = current.updateQueue), (workInProgress.effectTag &= -517), - (current.lanes &= ~renderLanes), - bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes) + current.expirationTime <= renderExpirationTime && + (current.expirationTime = 0), + bailoutOnAlreadyFinishedWork( + current, + workInProgress, + renderExpirationTime + ) ); workInProgress.effectTag |= 1; - reconcileChildren(current, workInProgress, nextProps, renderLanes); + reconcileChildren(current, workInProgress, nextProps, renderExpirationTime); return workInProgress.child; } function updateMemoComponent( @@ -4110,8 +3735,8 @@ function updateMemoComponent( workInProgress, Component, nextProps, - updateLanes, - renderLanes + updateExpirationTime, + renderExpirationTime ) { if (null === current) { var type = Component.type; @@ -4130,8 +3755,8 @@ function updateMemoComponent( workInProgress, type, nextProps, - updateLanes, - renderLanes + updateExpirationTime, + renderExpirationTime ) ); current = createFiberFromTypeAndProps( @@ -4140,7 +3765,7 @@ function updateMemoComponent( nextProps, null, workInProgress.mode, - renderLanes + renderExpirationTime ); current.ref = workInProgress.ref; current.return = workInProgress; @@ -4148,13 +3773,18 @@ function updateMemoComponent( } type = current.child; if ( - 0 === (updateLanes & renderLanes) && - ((updateLanes = type.memoizedProps), + updateExpirationTime < renderExpirationTime && + ((updateExpirationTime = type.memoizedProps), (Component = Component.compare), (Component = null !== Component ? Component : shallowEqual), - Component(updateLanes, nextProps) && current.ref === workInProgress.ref) + Component(updateExpirationTime, nextProps) && + current.ref === workInProgress.ref) ) - return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes); + return bailoutOnAlreadyFinishedWork( + current, + workInProgress, + renderExpirationTime + ); workInProgress.effectTag |= 1; current = createWorkInProgress(type, nextProps); current.ref = workInProgress.ref; @@ -4166,66 +3796,26 @@ function updateSimpleMemoComponent( workInProgress, Component, nextProps, - updateLanes, - renderLanes + updateExpirationTime, + renderExpirationTime ) { - if ( - null !== current && + return null !== current && shallowEqual(current.memoizedProps, nextProps) && - current.ref === workInProgress.ref - ) - if (((didReceiveUpdate = !1), 0 !== (renderLanes & updateLanes))) - 0 !== (current.effectTag & 16384) && (didReceiveUpdate = !0); - else - return ( - (workInProgress.lanes = current.lanes), - bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes) + current.ref === workInProgress.ref && + ((didReceiveUpdate = !1), updateExpirationTime < renderExpirationTime) + ? ((workInProgress.expirationTime = current.expirationTime), + bailoutOnAlreadyFinishedWork( + current, + workInProgress, + renderExpirationTime + )) + : updateFunctionComponent( + current, + workInProgress, + Component, + nextProps, + renderExpirationTime ); - return updateFunctionComponent( - current, - workInProgress, - Component, - nextProps, - renderLanes - ); -} -function updateOffscreenComponent(current, workInProgress, renderLanes) { - var nextProps = workInProgress.pendingProps, - nextChildren = nextProps.children, - prevState = null !== current ? current.memoizedState : null; - if ( - "hidden" === nextProps.mode || - "unstable-defer-without-hiding" === nextProps.mode - ) - if (0 === (workInProgress.mode & 4)) - (workInProgress.memoizedState = { baseLanes: 0 }), - pushRenderLanes(workInProgress, renderLanes); - else if (0 !== (renderLanes & 1073741824)) - (workInProgress.memoizedState = { baseLanes: 0 }), - pushRenderLanes( - workInProgress, - null !== prevState ? prevState.baseLanes : renderLanes - ); - else - return ( - (current = - null !== prevState ? prevState.baseLanes | renderLanes : renderLanes), - null === spawnedWorkDuringRender - ? (spawnedWorkDuringRender = [1073741824]) - : spawnedWorkDuringRender.push(1073741824), - (workInProgress.lanes = workInProgress.childLanes = 1073741824), - (workInProgress.memoizedState = { baseLanes: current }), - pushRenderLanes(workInProgress, current), - null - ); - else - null !== prevState - ? ((nextProps = prevState.baseLanes | renderLanes), - (workInProgress.memoizedState = null)) - : (nextProps = renderLanes), - pushRenderLanes(workInProgress, nextProps); - reconcileChildren(current, workInProgress, nextChildren, renderLanes); - return workInProgress.child; } function markRef(current, workInProgress) { var ref = workInProgress.ref; @@ -4240,30 +3830,35 @@ function updateFunctionComponent( workInProgress, Component, nextProps, - renderLanes + renderExpirationTime ) { var context = isContextProvider(Component) ? previousContext : contextStackCursor.current; context = getMaskedContext(workInProgress, context); - prepareToReadContext(workInProgress, renderLanes); + prepareToReadContext(workInProgress, renderExpirationTime); Component = renderWithHooks( current, workInProgress, Component, nextProps, context, - renderLanes + renderExpirationTime ); if (null !== current && !didReceiveUpdate) return ( (workInProgress.updateQueue = current.updateQueue), (workInProgress.effectTag &= -517), - (current.lanes &= ~renderLanes), - bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes) + current.expirationTime <= renderExpirationTime && + (current.expirationTime = 0), + bailoutOnAlreadyFinishedWork( + current, + workInProgress, + renderExpirationTime + ) ); workInProgress.effectTag |= 1; - reconcileChildren(current, workInProgress, Component, renderLanes); + reconcileChildren(current, workInProgress, Component, renderExpirationTime); return workInProgress.child; } function updateClassComponent( @@ -4271,20 +3866,25 @@ function updateClassComponent( workInProgress, Component, nextProps, - renderLanes + renderExpirationTime ) { if (isContextProvider(Component)) { var hasContext = !0; pushContextProvider(workInProgress); } else hasContext = !1; - prepareToReadContext(workInProgress, renderLanes); + prepareToReadContext(workInProgress, renderExpirationTime); if (null === workInProgress.stateNode) null !== current && ((current.alternate = null), (workInProgress.alternate = null), (workInProgress.effectTag |= 2)), constructClassInstance(workInProgress, Component, nextProps), - mountClassInstance(workInProgress, Component, nextProps, renderLanes), + mountClassInstance( + workInProgress, + Component, + nextProps, + renderExpirationTime + ), (nextProps = !0); else if (null === current) { var instance = workInProgress.stateNode, @@ -4315,7 +3915,12 @@ function updateClassComponent( hasForceUpdate = !1; var oldState = workInProgress.memoizedState; instance.state = oldState; - processUpdateQueue(workInProgress, nextProps, instance, renderLanes); + processUpdateQueue( + workInProgress, + nextProps, + instance, + renderExpirationTime + ); oldContext = workInProgress.memoizedState; oldProps !== nextProps || oldState !== oldContext || @@ -4360,111 +3965,117 @@ function updateClassComponent( : ("function" === typeof instance.componentDidMount && (workInProgress.effectTag |= 4), (nextProps = !1)); - } else { - instance = workInProgress.stateNode; - cloneUpdateQueue(current, workInProgress); - oldProps = workInProgress.memoizedProps; - contextType = - workInProgress.type === workInProgress.elementType - ? oldProps - : resolveDefaultProps(workInProgress.type, oldProps); - instance.props = contextType; - hasNewLifecycles = workInProgress.pendingProps; - oldState = instance.context; - oldContext = Component.contextType; - "object" === typeof oldContext && null !== oldContext - ? (oldContext = readContext(oldContext)) - : ((oldContext = isContextProvider(Component) - ? previousContext - : contextStackCursor.current), - (oldContext = getMaskedContext(workInProgress, oldContext))); - var getDerivedStateFromProps$jscomp$0 = Component.getDerivedStateFromProps; - (getDerivedStateFromProps = - "function" === typeof getDerivedStateFromProps$jscomp$0 || - "function" === typeof instance.getSnapshotBeforeUpdate) || - ("function" !== typeof instance.UNSAFE_componentWillReceiveProps && - "function" !== typeof instance.componentWillReceiveProps) || - ((oldProps !== hasNewLifecycles || oldState !== oldContext) && - callComponentWillReceiveProps( - workInProgress, - instance, - nextProps, - oldContext - )); - hasForceUpdate = !1; - oldState = workInProgress.memoizedState; - instance.state = oldState; - processUpdateQueue(workInProgress, nextProps, instance, renderLanes); - var newState = workInProgress.memoizedState; - oldProps !== hasNewLifecycles || - oldState !== newState || - didPerformWorkStackCursor.current || - hasForceUpdate - ? ("function" === typeof getDerivedStateFromProps$jscomp$0 && - (applyDerivedStateFromProps( + } else + (instance = workInProgress.stateNode), + cloneUpdateQueue(current, workInProgress), + (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 = readContext(contextType)) + : ((contextType = isContextProvider(Component) + ? previousContext + : contextStackCursor.current), + (contextType = getMaskedContext(workInProgress, contextType))), + (getDerivedStateFromProps = Component.getDerivedStateFromProps), + (hasNewLifecycles = + "function" === typeof getDerivedStateFromProps || + "function" === typeof instance.getSnapshotBeforeUpdate) || + ("function" !== typeof instance.UNSAFE_componentWillReceiveProps && + "function" !== typeof instance.componentWillReceiveProps) || + ((oldProps !== nextProps || oldContext !== contextType) && + callComponentWillReceiveProps( workInProgress, - Component, - getDerivedStateFromProps$jscomp$0, - nextProps - ), - (newState = workInProgress.memoizedState)), - (contextType = - hasForceUpdate || - checkShouldComponentUpdate( - workInProgress, - Component, - contextType, + instance, nextProps, - oldState, - newState, - oldContext - )) - ? (getDerivedStateFromProps || - ("function" !== typeof instance.UNSAFE_componentWillUpdate && - "function" !== typeof instance.componentWillUpdate) || - ("function" === typeof instance.componentWillUpdate && - instance.componentWillUpdate(nextProps, newState, oldContext), - "function" === typeof instance.UNSAFE_componentWillUpdate && - instance.UNSAFE_componentWillUpdate( - nextProps, - newState, - oldContext - )), - "function" === typeof instance.componentDidUpdate && - (workInProgress.effectTag |= 4), - "function" === typeof instance.getSnapshotBeforeUpdate && - (workInProgress.effectTag |= 256)) - : ("function" !== typeof instance.componentDidUpdate || - (oldProps === current.memoizedProps && - oldState === current.memoizedState) || - (workInProgress.effectTag |= 4), - "function" !== typeof instance.getSnapshotBeforeUpdate || - (oldProps === current.memoizedProps && - oldState === current.memoizedState) || - (workInProgress.effectTag |= 256), - (workInProgress.memoizedProps = nextProps), - (workInProgress.memoizedState = newState)), - (instance.props = nextProps), - (instance.state = newState), - (instance.context = oldContext), - (nextProps = contextType)) - : ("function" !== typeof instance.componentDidUpdate || - (oldProps === current.memoizedProps && - oldState === current.memoizedState) || - (workInProgress.effectTag |= 4), - "function" !== typeof instance.getSnapshotBeforeUpdate || - (oldProps === current.memoizedProps && - oldState === current.memoizedState) || - (workInProgress.effectTag |= 256), - (nextProps = !1)); - } + contextType + )), + (hasForceUpdate = !1), + (oldContext = workInProgress.memoizedState), + (instance.state = oldContext), + processUpdateQueue( + workInProgress, + nextProps, + instance, + renderExpirationTime + ), + (oldState = workInProgress.memoizedState), + oldProps !== nextProps || + oldContext !== oldState || + didPerformWorkStackCursor.current || + hasForceUpdate + ? ("function" === typeof getDerivedStateFromProps && + (applyDerivedStateFromProps( + workInProgress, + Component, + getDerivedStateFromProps, + nextProps + ), + (oldState = workInProgress.memoizedState)), + (getDerivedStateFromProps = + hasForceUpdate || + checkShouldComponentUpdate( + workInProgress, + Component, + oldProps, + nextProps, + oldContext, + oldState, + contextType + )) + ? (hasNewLifecycles || + ("function" !== typeof instance.UNSAFE_componentWillUpdate && + "function" !== typeof instance.componentWillUpdate) || + ("function" === typeof instance.componentWillUpdate && + instance.componentWillUpdate( + nextProps, + oldState, + contextType + ), + "function" === typeof instance.UNSAFE_componentWillUpdate && + instance.UNSAFE_componentWillUpdate( + nextProps, + oldState, + contextType + )), + "function" === typeof instance.componentDidUpdate && + (workInProgress.effectTag |= 4), + "function" === typeof instance.getSnapshotBeforeUpdate && + (workInProgress.effectTag |= 256)) + : ("function" !== typeof instance.componentDidUpdate || + (oldProps === current.memoizedProps && + oldContext === current.memoizedState) || + (workInProgress.effectTag |= 4), + "function" !== typeof instance.getSnapshotBeforeUpdate || + (oldProps === current.memoizedProps && + oldContext === current.memoizedState) || + (workInProgress.effectTag |= 256), + (workInProgress.memoizedProps = nextProps), + (workInProgress.memoizedState = oldState)), + (instance.props = nextProps), + (instance.state = oldState), + (instance.context = contextType), + (nextProps = getDerivedStateFromProps)) + : ("function" !== typeof instance.componentDidUpdate || + (oldProps === current.memoizedProps && + oldContext === current.memoizedState) || + (workInProgress.effectTag |= 4), + "function" !== typeof instance.getSnapshotBeforeUpdate || + (oldProps === current.memoizedProps && + oldContext === current.memoizedState) || + (workInProgress.effectTag |= 256), + (nextProps = !1)); return finishClassComponent( current, workInProgress, Component, nextProps, hasContext, - renderLanes + renderExpirationTime ); } function finishClassComponent( @@ -4473,14 +4084,18 @@ function finishClassComponent( Component, shouldUpdate, hasContext, - renderLanes + renderExpirationTime ) { markRef(current, workInProgress); var didCaptureError = 0 !== (workInProgress.effectTag & 64); if (!shouldUpdate && !didCaptureError) return ( hasContext && invalidateContextProvider(workInProgress, Component, !1), - bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes) + bailoutOnAlreadyFinishedWork( + current, + workInProgress, + renderExpirationTime + ) ); shouldUpdate = workInProgress.stateNode; ReactCurrentOwner$1.current = workInProgress; @@ -4498,15 +4113,20 @@ function finishClassComponent( workInProgress, current.child, null, - renderLanes + renderExpirationTime )), (workInProgress.child = reconcileChildFibers( workInProgress, null, didCaptureError, - renderLanes + renderExpirationTime ))) - : reconcileChildren(current, workInProgress, nextChildren, renderLanes); + : reconcileChildren( + current, + workInProgress, + nextChildren, + renderExpirationTime + ); workInProgress.memoizedState = shouldUpdate.state; hasContext && invalidateContextProvider(workInProgress, Component, !0); return workInProgress.child; @@ -4523,198 +4143,169 @@ function pushHostRootContext(workInProgress) { pushTopLevelContextObject(workInProgress, root.context, !1); pushHostContainer(workInProgress, root.containerInfo); } -var SUSPENDED_MARKER = { dehydrated: null, retryLane: 0 }; -function updateSuspenseComponent(current, workInProgress, renderLanes) { - var nextProps = workInProgress.pendingProps, +var SUSPENDED_MARKER = { dehydrated: null, retryTime: 0 }; +function updateSuspenseComponent( + current, + workInProgress, + renderExpirationTime +) { + var mode = workInProgress.mode, + nextProps = workInProgress.pendingProps, suspenseContext = suspenseStackCursor.current, - showFallback = !1, + nextDidTimeout = !1, JSCompiler_temp; (JSCompiler_temp = 0 !== (workInProgress.effectTag & 64)) || (JSCompiler_temp = - null !== current && null === current.memoizedState - ? !1 - : 0 !== (suspenseContext & 2)); + 0 !== (suspenseContext & 2) && + (null === current || null !== current.memoizedState)); JSCompiler_temp - ? ((showFallback = !0), (workInProgress.effectTag &= -65)) + ? ((nextDidTimeout = !0), (workInProgress.effectTag &= -65)) : (null !== current && null === current.memoizedState) || void 0 === nextProps.fallback || !0 === nextProps.unstable_avoidThisFallback || (suspenseContext |= 1); push(suspenseStackCursor, suspenseContext & 1); if (null === current) { - if (showFallback) - return ( - (current = nextProps.fallback), - (suspenseContext = workInProgress.mode), - (showFallback = workInProgress.child), - (nextProps = { mode: "hidden", children: nextProps.children }), - 0 === (suspenseContext & 2) && null !== showFallback - ? ((showFallback.childLanes = 0), - (showFallback.pendingProps = nextProps), - workInProgress.mode & 8 && - ((showFallback.actualDuration = 0), - (showFallback.actualStartTime = -1), - (showFallback.selfBaseDuration = 0), - (showFallback.treeBaseDuration = 0))) - : (showFallback = createFiberFromOffscreen( - nextProps, - suspenseContext, - 0, - null - )), - (current = createFiberFromFragment( - current, - suspenseContext, - renderLanes, - null - )), - (showFallback.return = workInProgress), - (current.return = workInProgress), - (showFallback.sibling = current), - (workInProgress.child = showFallback), - (workInProgress.child.memoizedState = { baseLanes: renderLanes }), - (workInProgress.memoizedState = SUSPENDED_MARKER), - current + if (nextDidTimeout) { + nextDidTimeout = nextProps.fallback; + nextProps = createFiberFromFragment(null, mode, 0, null); + nextProps.return = workInProgress; + if (0 === (workInProgress.mode & 2)) + for ( + current = + null !== workInProgress.memoizedState + ? workInProgress.child.child + : workInProgress.child, + nextProps.child = current; + null !== current; + + ) + (current.return = nextProps), (current = current.sibling); + renderExpirationTime = createFiberFromFragment( + nextDidTimeout, + mode, + renderExpirationTime, + null ); - renderLanes = createFiberFromOffscreen( - { mode: "visible", children: nextProps.children }, - workInProgress.mode, - renderLanes, - null - ); - renderLanes.return = workInProgress; - return (workInProgress.child = renderLanes); + renderExpirationTime.return = workInProgress; + nextProps.sibling = renderExpirationTime; + workInProgress.memoizedState = SUSPENDED_MARKER; + workInProgress.child = nextProps; + return renderExpirationTime; + } + mode = nextProps.children; + workInProgress.memoizedState = null; + return (workInProgress.child = mountChildFibers( + workInProgress, + null, + mode, + renderExpirationTime + )); } if (null !== current.memoizedState) { - if (showFallback) - return ( - (nextProps = updateSuspenseFallbackChildren( - current, - workInProgress, - nextProps.children, - nextProps.fallback, - renderLanes - )), - (suspenseContext = workInProgress.child), - (showFallback = current.child.memoizedState), - (suspenseContext.memoizedState = - null === showFallback - ? { baseLanes: renderLanes } - : { baseLanes: showFallback.baseLanes | renderLanes }), - (suspenseContext.childLanes = current.childLanes & ~renderLanes), - (workInProgress.memoizedState = SUSPENDED_MARKER), - nextProps + current = current.child; + mode = current.sibling; + if (nextDidTimeout) { + nextProps = nextProps.fallback; + renderExpirationTime = createWorkInProgress( + current, + current.pendingProps ); - renderLanes = updateSuspensePrimaryChildren( - current, + renderExpirationTime.return = workInProgress; + if ( + 0 === (workInProgress.mode & 2) && + ((nextDidTimeout = + null !== workInProgress.memoizedState + ? workInProgress.child.child + : workInProgress.child), + nextDidTimeout !== current.child) + ) + for ( + renderExpirationTime.child = nextDidTimeout; + null !== nextDidTimeout; + + ) + (nextDidTimeout.return = renderExpirationTime), + (nextDidTimeout = nextDidTimeout.sibling); + if (workInProgress.mode & 8) { + nextDidTimeout = 0; + for (current = renderExpirationTime.child; null !== current; ) + (nextDidTimeout += current.treeBaseDuration), + (current = current.sibling); + renderExpirationTime.treeBaseDuration = nextDidTimeout; + } + mode = createWorkInProgress(mode, nextProps); + mode.return = workInProgress; + renderExpirationTime.sibling = mode; + renderExpirationTime.childExpirationTime = 0; + workInProgress.memoizedState = SUSPENDED_MARKER; + workInProgress.child = renderExpirationTime; + return mode; + } + renderExpirationTime = reconcileChildFibers( workInProgress, + current.child, nextProps.children, - renderLanes + renderExpirationTime ); workInProgress.memoizedState = null; - return renderLanes; + return (workInProgress.child = renderExpirationTime); } - if (showFallback) - return ( - (nextProps = updateSuspenseFallbackChildren( - current, - workInProgress, - nextProps.children, - nextProps.fallback, - renderLanes - )), - (suspenseContext = workInProgress.child), - (showFallback = current.child.memoizedState), - (suspenseContext.memoizedState = - null === showFallback - ? { baseLanes: renderLanes } - : { baseLanes: showFallback.baseLanes | renderLanes }), - (suspenseContext.childLanes = current.childLanes & ~renderLanes), - (workInProgress.memoizedState = SUSPENDED_MARKER), - nextProps + current = current.child; + if (nextDidTimeout) { + nextDidTimeout = nextProps.fallback; + nextProps = createFiberFromFragment(null, mode, 0, null); + nextProps.return = workInProgress; + nextProps.child = current; + null !== current && (current.return = nextProps); + if (0 === (workInProgress.mode & 2)) + for ( + current = + null !== workInProgress.memoizedState + ? workInProgress.child.child + : workInProgress.child, + nextProps.child = current; + null !== current; + + ) + (current.return = nextProps), (current = current.sibling); + if (workInProgress.mode & 8) { + current = 0; + for (suspenseContext = nextProps.child; null !== suspenseContext; ) + (current += suspenseContext.treeBaseDuration), + (suspenseContext = suspenseContext.sibling); + nextProps.treeBaseDuration = current; + } + renderExpirationTime = createFiberFromFragment( + nextDidTimeout, + mode, + renderExpirationTime, + null ); - renderLanes = updateSuspensePrimaryChildren( - current, - workInProgress, - nextProps.children, - renderLanes - ); + renderExpirationTime.return = workInProgress; + nextProps.sibling = renderExpirationTime; + renderExpirationTime.effectTag |= 2; + nextProps.childExpirationTime = 0; + workInProgress.memoizedState = SUSPENDED_MARKER; + workInProgress.child = nextProps; + return renderExpirationTime; + } workInProgress.memoizedState = null; - return renderLanes; + return (workInProgress.child = reconcileChildFibers( + workInProgress, + current, + nextProps.children, + renderExpirationTime + )); } -function updateSuspensePrimaryChildren( - current, - workInProgress, - primaryChildren, - renderLanes -) { - var currentPrimaryChildFragment = current.child; - current = currentPrimaryChildFragment.sibling; - primaryChildren = createWorkInProgress(currentPrimaryChildFragment, { - mode: "visible", - children: primaryChildren - }); - 0 === (workInProgress.mode & 2) && (primaryChildren.lanes = renderLanes); - primaryChildren.return = workInProgress; - primaryChildren.sibling = null; - null !== current && - ((current.nextEffect = null), - (current.effectTag = 8), - (workInProgress.firstEffect = workInProgress.lastEffect = current)); - return (workInProgress.child = primaryChildren); -} -function updateSuspenseFallbackChildren( - current, - workInProgress, - primaryChildren, - fallbackChildren, - renderLanes -) { - var mode = workInProgress.mode, - currentPrimaryChildFragment = current.child; - current = currentPrimaryChildFragment.sibling; - var primaryChildProps = { mode: "hidden", children: primaryChildren }; - 0 === (mode & 2) && workInProgress.child !== currentPrimaryChildFragment - ? ((primaryChildren = workInProgress.child), - (primaryChildren.childLanes = 0), - (primaryChildren.pendingProps = primaryChildProps), - workInProgress.mode & 8 && - ((primaryChildren.actualDuration = 0), - (primaryChildren.actualStartTime = -1), - (primaryChildren.selfBaseDuration = - currentPrimaryChildFragment.selfBaseDuration), - (primaryChildren.treeBaseDuration = - currentPrimaryChildFragment.treeBaseDuration)), - (currentPrimaryChildFragment = primaryChildren.lastEffect), - null !== currentPrimaryChildFragment - ? ((workInProgress.firstEffect = primaryChildren.firstEffect), - (workInProgress.lastEffect = currentPrimaryChildFragment), - (currentPrimaryChildFragment.nextEffect = null)) - : (workInProgress.firstEffect = workInProgress.lastEffect = null)) - : (primaryChildren = createWorkInProgress( - currentPrimaryChildFragment, - primaryChildProps - )); - null !== current - ? (fallbackChildren = createWorkInProgress(current, fallbackChildren)) - : ((fallbackChildren = createFiberFromFragment( - fallbackChildren, - mode, - renderLanes, - null - )), - (fallbackChildren.effectTag |= 2)); - fallbackChildren.return = workInProgress; - primaryChildren.return = workInProgress; - primaryChildren.sibling = fallbackChildren; - workInProgress.child = primaryChildren; - return fallbackChildren; -} -function scheduleWorkOnFiber(fiber, renderLanes) { - fiber.lanes |= renderLanes; +function scheduleWorkOnFiber(fiber, renderExpirationTime) { + fiber.expirationTime < renderExpirationTime && + (fiber.expirationTime = renderExpirationTime); var alternate = fiber.alternate; - null !== alternate && (alternate.lanes |= renderLanes); - scheduleWorkOnParentPath(fiber.return, renderLanes); + null !== alternate && + alternate.expirationTime < renderExpirationTime && + (alternate.expirationTime = renderExpirationTime); + scheduleWorkOnParentPath(fiber.return, renderExpirationTime); } function initSuspenseListRenderState( workInProgress, @@ -4745,11 +4336,20 @@ function initSuspenseListRenderState( (renderState.tailMode = tailMode), (renderState.lastEffect = lastEffectBeforeRendering)); } -function updateSuspenseListComponent(current, workInProgress, renderLanes) { +function updateSuspenseListComponent( + current, + workInProgress, + renderExpirationTime +) { var nextProps = workInProgress.pendingProps, revealOrder = nextProps.revealOrder, tailMode = nextProps.tail; - reconcileChildren(current, workInProgress, nextProps.children, renderLanes); + reconcileChildren( + current, + workInProgress, + nextProps.children, + renderExpirationTime + ); nextProps = suspenseStackCursor.current; if (0 !== (nextProps & 2)) (nextProps = (nextProps & 1) | 2), (workInProgress.effectTag |= 64); @@ -4758,8 +4358,9 @@ function updateSuspenseListComponent(current, workInProgress, renderLanes) { a: for (current = workInProgress.child; null !== current; ) { if (13 === current.tag) null !== current.memoizedState && - scheduleWorkOnFiber(current, renderLanes); - else if (19 === current.tag) scheduleWorkOnFiber(current, renderLanes); + scheduleWorkOnFiber(current, renderExpirationTime); + else if (19 === current.tag) + scheduleWorkOnFiber(current, renderExpirationTime); else if (null !== current.child) { current.child.return = current; current = current.child; @@ -4781,29 +4382,30 @@ function updateSuspenseListComponent(current, workInProgress, renderLanes) { else switch (revealOrder) { case "forwards": - renderLanes = workInProgress.child; - for (revealOrder = null; null !== renderLanes; ) - (current = renderLanes.alternate), + renderExpirationTime = workInProgress.child; + for (revealOrder = null; null !== renderExpirationTime; ) + (current = renderExpirationTime.alternate), null !== current && null === findFirstSuspended(current) && - (revealOrder = renderLanes), - (renderLanes = renderLanes.sibling); - renderLanes = revealOrder; - null === renderLanes + (revealOrder = renderExpirationTime), + (renderExpirationTime = renderExpirationTime.sibling); + renderExpirationTime = revealOrder; + null === renderExpirationTime ? ((revealOrder = workInProgress.child), (workInProgress.child = null)) - : ((revealOrder = renderLanes.sibling), (renderLanes.sibling = null)); + : ((revealOrder = renderExpirationTime.sibling), + (renderExpirationTime.sibling = null)); initSuspenseListRenderState( workInProgress, !1, revealOrder, - renderLanes, + renderExpirationTime, tailMode, workInProgress.lastEffect ); break; case "backwards": - renderLanes = null; + renderExpirationTime = null; revealOrder = workInProgress.child; for (workInProgress.child = null; null !== revealOrder; ) { current = revealOrder.alternate; @@ -4812,14 +4414,14 @@ function updateSuspenseListComponent(current, workInProgress, renderLanes) { break; } current = revealOrder.sibling; - revealOrder.sibling = renderLanes; - renderLanes = revealOrder; + revealOrder.sibling = renderExpirationTime; + renderExpirationTime = revealOrder; revealOrder = current; } initSuspenseListRenderState( workInProgress, !0, - renderLanes, + renderExpirationTime, null, tailMode, workInProgress.lastEffect @@ -4840,29 +4442,36 @@ function updateSuspenseListComponent(current, workInProgress, renderLanes) { } return workInProgress.child; } -function bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes) { +function bailoutOnAlreadyFinishedWork( + current, + workInProgress, + renderExpirationTime +) { null !== current && (workInProgress.dependencies = current.dependencies); profilerStartTime = -1; - workInProgressRootSkippedLanes |= workInProgress.lanes; - if (0 !== (renderLanes & workInProgress.childLanes)) { - if (null !== current && workInProgress.child !== current.child) - throw Error("Resuming work not yet implemented."); - if (null !== workInProgress.child) { - current = workInProgress.child; - renderLanes = createWorkInProgress(current, current.pendingProps); - workInProgress.child = renderLanes; - for (renderLanes.return = workInProgress; null !== current.sibling; ) - (current = current.sibling), - (renderLanes = renderLanes.sibling = createWorkInProgress( - current, - current.pendingProps - )), - (renderLanes.return = workInProgress); - renderLanes.sibling = null; - } - return workInProgress.child; + var updateExpirationTime = workInProgress.expirationTime; + 0 !== updateExpirationTime && markUnprocessedUpdateTime(updateExpirationTime); + if (workInProgress.childExpirationTime < renderExpirationTime) return null; + if (null !== current && workInProgress.child !== current.child) + throw Error("Resuming work not yet implemented."); + if (null !== workInProgress.child) { + current = workInProgress.child; + renderExpirationTime = createWorkInProgress(current, current.pendingProps); + workInProgress.child = renderExpirationTime; + for ( + renderExpirationTime.return = workInProgress; + null !== current.sibling; + + ) + (current = current.sibling), + (renderExpirationTime = renderExpirationTime.sibling = createWorkInProgress( + current, + current.pendingProps + )), + (renderExpirationTime.return = workInProgress); + renderExpirationTime.sibling = null; } - return null; + return workInProgress.child; } var appendAllChildren, updateHostContainer, @@ -5055,17 +4664,17 @@ function cutOffTailIfNeeded(renderState, hasRenderedATailFallback) { break; case "collapsed": lastTailNode = renderState.tail; - for (var lastTailNode$65 = null; null !== lastTailNode; ) - null !== lastTailNode.alternate && (lastTailNode$65 = lastTailNode), + for (var _lastTailNode = null; null !== lastTailNode; ) + null !== lastTailNode.alternate && (_lastTailNode = lastTailNode), (lastTailNode = lastTailNode.sibling); - null === lastTailNode$65 + null === _lastTailNode ? hasRenderedATailFallback || null === renderState.tail ? (renderState.tail = null) : (renderState.tail.sibling = null) - : (lastTailNode$65.sibling = null); + : (_lastTailNode.sibling = null); } } -function completeWork(current, workInProgress, renderLanes) { +function completeWork(current, workInProgress, renderExpirationTime) { var newProps = workInProgress.pendingProps; switch (workInProgress.tag) { case 2: @@ -5086,14 +4695,10 @@ function completeWork(current, workInProgress, renderLanes) { popHostContainer(), pop(didPerformWorkStackCursor), pop(contextStackCursor), - resetWorkInProgressVersions(), - (newProps = workInProgress.stateNode), - newProps.pendingContext && - ((newProps.context = newProps.pendingContext), - (newProps.pendingContext = null)), - (null !== current && null !== current.child) || - newProps.hydrate || - (workInProgress.effectTag |= 256), + (current = workInProgress.stateNode), + current.pendingContext && + ((current.context = current.pendingContext), + (current.pendingContext = null)), updateHostContainer(workInProgress), null ); @@ -5102,12 +4707,12 @@ function completeWork(current, workInProgress, renderLanes) { var rootContainerInstance = requiredContext( rootInstanceStackCursor.current ); - renderLanes = workInProgress.type; + renderExpirationTime = workInProgress.type; if (null !== current && null != workInProgress.stateNode) updateHostComponent$1( current, workInProgress, - renderLanes, + renderExpirationTime, newProps, rootContainerInstance ), @@ -5124,23 +4729,23 @@ function completeWork(current, workInProgress, renderLanes) { requiredContext(contextStackCursor$1.current); current = nextReactTag; nextReactTag += 2; - renderLanes = getViewConfigForType(renderLanes); + renderExpirationTime = getViewConfigForType(renderExpirationTime); var updatePayload = diffProperties( null, emptyObject, newProps, - renderLanes.validAttributes + renderExpirationTime.validAttributes ); rootContainerInstance = createNode( current, - renderLanes.uiViewClassName, + renderExpirationTime.uiViewClassName, rootContainerInstance, updatePayload, workInProgress ); current = new ReactFabricHostComponent( current, - renderLanes, + renderExpirationTime, newProps, workInProgress ); @@ -5178,36 +4783,48 @@ function completeWork(current, workInProgress, renderLanes) { newProps = workInProgress.memoizedState; if (0 !== (workInProgress.effectTag & 64)) return ( - (workInProgress.lanes = renderLanes), - 0 !== (workInProgress.mode & 8) && - transferActualDuration(workInProgress), - workInProgress + (workInProgress.expirationTime = renderExpirationTime), workInProgress ); newProps = null !== newProps; rootContainerInstance = !1; null !== current && - (rootContainerInstance = null !== current.memoizedState); + ((renderExpirationTime = current.memoizedState), + (rootContainerInstance = null !== renderExpirationTime), + newProps || + null === renderExpirationTime || + ((renderExpirationTime = current.child.sibling), + null !== renderExpirationTime && + ((updatePayload = workInProgress.firstEffect), + null !== updatePayload + ? ((workInProgress.firstEffect = renderExpirationTime), + (renderExpirationTime.nextEffect = updatePayload)) + : ((workInProgress.firstEffect = workInProgress.lastEffect = renderExpirationTime), + (renderExpirationTime.nextEffect = null)), + (renderExpirationTime.effectTag = 8)))); if (newProps && !rootContainerInstance && 0 !== (workInProgress.mode & 2)) if ( (null === current && !0 !== workInProgress.memoizedProps.unstable_avoidThisFallback) || 0 !== (suspenseStackCursor.current & 1) ) - 0 === workInProgressRootExitStatus && - (workInProgressRootExitStatus = 3); + workInProgressRootExitStatus === RootIncomplete && + (workInProgressRootExitStatus = RootSuspended); else { if ( - 0 === workInProgressRootExitStatus || - 3 === workInProgressRootExitStatus + workInProgressRootExitStatus === RootIncomplete || + workInProgressRootExitStatus === RootSuspended ) - workInProgressRootExitStatus = 4; - null === workInProgressRoot || - (0 === (workInProgressRootSkippedLanes & 134217727) && - 0 === (workInProgressRootUpdatedLanes & 134217727)) || - markRootSuspended$1( + workInProgressRootExitStatus = RootSuspendedWithDelay; + 0 !== workInProgressRootNextUnprocessedUpdateTime && + null !== workInProgressRoot && + (markRootSuspendedAtTime( workInProgressRoot, - workInProgressRootRenderLanes - ); + renderExpirationTime$1 + ), + markRootUpdatedAtTime( + workInProgressRoot, + workInProgressRootNextUnprocessedUpdateTime + )); } newProps && (workInProgress.effectTag |= 4); return null; @@ -5227,7 +4844,7 @@ function completeWork(current, workInProgress, renderLanes) { if (rootContainerInstance) cutOffTailIfNeeded(newProps, !1); else { if ( - 0 !== workInProgressRootExitStatus || + workInProgressRootExitStatus !== RootIncomplete || (null !== current && 0 !== (current.effectTag & 64)) ) for (current = workInProgress.child; null !== current; ) { @@ -5242,7 +4859,7 @@ function completeWork(current, workInProgress, renderLanes) { null === newProps.lastEffect && (workInProgress.firstEffect = null); workInProgress.lastEffect = newProps.lastEffect; - current = renderLanes; + current = renderExpirationTime; for (newProps = workInProgress.child; null !== newProps; ) (rootContainerInstance = newProps), (updatePayload = current), @@ -5250,42 +4867,42 @@ function completeWork(current, workInProgress, renderLanes) { (rootContainerInstance.nextEffect = null), (rootContainerInstance.firstEffect = null), (rootContainerInstance.lastEffect = null), - (renderLanes = rootContainerInstance.alternate), - null === renderLanes - ? ((rootContainerInstance.childLanes = 0), - (rootContainerInstance.lanes = updatePayload), + (renderExpirationTime = rootContainerInstance.alternate), + null === renderExpirationTime + ? ((rootContainerInstance.childExpirationTime = 0), + (rootContainerInstance.expirationTime = updatePayload), (rootContainerInstance.child = null), (rootContainerInstance.memoizedProps = null), (rootContainerInstance.memoizedState = null), (rootContainerInstance.updateQueue = null), (rootContainerInstance.dependencies = null), - (rootContainerInstance.stateNode = null), (rootContainerInstance.selfBaseDuration = 0), (rootContainerInstance.treeBaseDuration = 0)) - : ((rootContainerInstance.childLanes = - renderLanes.childLanes), - (rootContainerInstance.lanes = renderLanes.lanes), - (rootContainerInstance.child = renderLanes.child), + : ((rootContainerInstance.childExpirationTime = + renderExpirationTime.childExpirationTime), + (rootContainerInstance.expirationTime = + renderExpirationTime.expirationTime), + (rootContainerInstance.child = + renderExpirationTime.child), (rootContainerInstance.memoizedProps = - renderLanes.memoizedProps), + renderExpirationTime.memoizedProps), (rootContainerInstance.memoizedState = - renderLanes.memoizedState), + renderExpirationTime.memoizedState), (rootContainerInstance.updateQueue = - renderLanes.updateQueue), - (rootContainerInstance.type = renderLanes.type), - (updatePayload = renderLanes.dependencies), + renderExpirationTime.updateQueue), + (updatePayload = renderExpirationTime.dependencies), (rootContainerInstance.dependencies = null === updatePayload ? null : { - lanes: updatePayload.lanes, + expirationTime: updatePayload.expirationTime, firstContext: updatePayload.firstContext, responders: updatePayload.responders }), (rootContainerInstance.selfBaseDuration = - renderLanes.selfBaseDuration), + renderExpirationTime.selfBaseDuration), (rootContainerInstance.treeBaseDuration = - renderLanes.treeBaseDuration)), + renderExpirationTime.treeBaseDuration)), (newProps = newProps.sibling); push( suspenseStackCursor, @@ -5321,14 +4938,15 @@ function completeWork(current, workInProgress, renderLanes) { ); } else 2 * now() - newProps.renderingStartTime > newProps.tailExpiration && - 1073741824 !== renderLanes && + 1 < renderExpirationTime && ((workInProgress.effectTag |= 64), (rootContainerInstance = !0), cutOffTailIfNeeded(newProps, !1), - (workInProgress.lanes = renderLanes), + (current = renderExpirationTime - 1), + (workInProgress.expirationTime = workInProgress.childExpirationTime = current), null === spawnedWorkDuringRender - ? (spawnedWorkDuringRender = [renderLanes]) - : spawnedWorkDuringRender.push(renderLanes)); + ? (spawnedWorkDuringRender = [current]) + : spawnedWorkDuringRender.push(current)); newProps.isBackwards ? ((updatePayload.sibling = workInProgress.child), (workInProgress.child = updatePayload)) @@ -5356,17 +4974,6 @@ function completeWork(current, workInProgress, renderLanes) { ), current) : null; - case 23: - case 24: - return ( - popRenderLanes(), - null !== current && - (null !== current.memoizedState) !== - (null !== workInProgress.memoizedState) && - "unstable-defer-without-hiding" !== newProps.mode && - (workInProgress.effectTag |= 4), - null - ); } throw Error( "Unknown unit of work tag (" + @@ -5381,15 +4988,12 @@ function unwindWork(workInProgress) { var effectTag = workInProgress.effectTag; return effectTag & 4096 ? ((workInProgress.effectTag = (effectTag & -4097) | 64), - 0 !== (workInProgress.mode & 8) && - transferActualDuration(workInProgress), workInProgress) : null; case 3: popHostContainer(); pop(didPerformWorkStackCursor); pop(contextStackCursor); - resetWorkInProgressVersions(); effectTag = workInProgress.effectTag; if (0 !== (effectTag & 64)) throw Error( @@ -5405,8 +5009,6 @@ function unwindWork(workInProgress) { (effectTag = workInProgress.effectTag), effectTag & 4096 ? ((workInProgress.effectTag = (effectTag & -4097) | 64), - 0 !== (workInProgress.mode & 8) && - transferActualDuration(workInProgress), workInProgress) : null ); @@ -5416,25 +5018,16 @@ function unwindWork(workInProgress) { return popHostContainer(), null; case 10: return popProvider(workInProgress), null; - case 23: - case 24: - return popRenderLanes(), null; default: return null; } } function createCapturedValue(value, source) { - try { - var info = "", - node = source; - do (info += describeFiber(node)), (node = node.return); - while (node); - var JSCompiler_inline_result = info; - } catch (x) { - JSCompiler_inline_result = - "\nError generating stack: " + x.message + "\n" + x.stack; - } - return { value: value, source: source, stack: JSCompiler_inline_result }; + return { + value: value, + source: source, + stack: getStackByFiberInDevAndProd(source) + }; } if ( "function" !== @@ -5443,61 +5036,51 @@ if ( throw Error( "Expected ReactFiberErrorDialog.showErrorDialog to be a function." ); -function logCapturedError(boundary, errorInfo) { +function logCapturedError(capturedError) { + !1 !== + ReactNativePrivateInterface.ReactFiberErrorDialog.showErrorDialog( + capturedError + ) && console.error(capturedError.error); +} +var PossiblyWeakSet = "function" === typeof WeakSet ? WeakSet : Set; +function logError(boundary, errorInfo) { + var source = errorInfo.source, + stack = errorInfo.stack; + null === stack && + null !== source && + (stack = getStackByFiberInDevAndProd(source)); + errorInfo = { + componentName: null !== source ? getComponentName(source.type) : null, + componentStack: null !== stack ? stack : "", + error: errorInfo.value, + errorBoundary: null, + errorBoundaryName: null, + errorBoundaryFound: !1, + willRetry: !1 + }; + null !== boundary && + 1 === boundary.tag && + ((errorInfo.errorBoundary = boundary.stateNode), + (errorInfo.errorBoundaryName = getComponentName(boundary.type)), + (errorInfo.errorBoundaryFound = !0), + (errorInfo.willRetry = !0)); try { - !1 !== - ReactNativePrivateInterface.ReactFiberErrorDialog.showErrorDialog({ - componentStack: null !== errorInfo.stack ? errorInfo.stack : "", - error: errorInfo.value, - errorBoundary: - null !== boundary && 1 === boundary.tag ? boundary.stateNode : null - }) && console.error(errorInfo.value); + logCapturedError(errorInfo); } catch (e) { setTimeout(function() { throw e; }); } } -var PossiblyWeakMap = "function" === typeof WeakMap ? WeakMap : Map; -function createRootErrorUpdate(fiber, errorInfo, lane) { - lane = createUpdate(-1, lane, null); - lane.tag = 3; - lane.payload = { element: null }; - var error = errorInfo.value; - lane.callback = function() { - hasUncaughtError || ((hasUncaughtError = !0), (firstUncaughtError = error)); - logCapturedError(fiber, errorInfo); - }; - return lane; -} -function createClassErrorUpdate(fiber, errorInfo, lane) { - lane = createUpdate(-1, lane, null); - lane.tag = 3; - var getDerivedStateFromError = fiber.type.getDerivedStateFromError; - if ("function" === typeof getDerivedStateFromError) { - var error = errorInfo.value; - lane.payload = function() { - logCapturedError(fiber, errorInfo); - return getDerivedStateFromError(error); - }; +function safelyCallComponentWillUnmount(current, instance) { + try { + (instance.props = current.memoizedProps), + (instance.state = current.memoizedState), + instance.componentWillUnmount(); + } catch (unmountError) { + captureCommitPhaseError(current, unmountError); } - var inst = fiber.stateNode; - null !== inst && - "function" === typeof inst.componentDidCatch && - (lane.callback = function() { - "function" !== typeof getDerivedStateFromError && - (null === legacyErrorBoundariesThatAlreadyFailed - ? (legacyErrorBoundariesThatAlreadyFailed = new Set([this])) - : legacyErrorBoundariesThatAlreadyFailed.add(this), - logCapturedError(fiber, errorInfo)); - var stack = errorInfo.stack; - this.componentDidCatch(errorInfo.value, { - componentStack: null !== stack ? stack : "" - }); - }); - return lane; } -var PossiblyWeakSet = "function" === typeof WeakSet ? WeakSet : Set; function safelyDetachRef(current) { var ref = current.ref; if (null !== ref) @@ -5531,7 +5114,6 @@ function commitBeforeMutationLifeCycles(current, finishedWork) { } return; case 3: - return; case 5: case 6: case 4: @@ -5542,57 +5124,58 @@ function commitBeforeMutationLifeCycles(current, finishedWork) { "This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue." ); } +function commitHookEffectListUnmount(tag, finishedWork) { + finishedWork = finishedWork.updateQueue; + finishedWork = null !== finishedWork ? finishedWork.lastEffect : null; + if (null !== finishedWork) { + var effect = (finishedWork = finishedWork.next); + do { + if ((effect.tag & tag) === tag) { + var destroy = effect.destroy; + effect.destroy = void 0; + void 0 !== destroy && destroy(); + } + effect = effect.next; + } while (effect !== finishedWork); + } +} +function commitHookEffectListMount(tag, finishedWork) { + finishedWork = finishedWork.updateQueue; + finishedWork = null !== finishedWork ? finishedWork.lastEffect : null; + if (null !== finishedWork) { + var effect = (finishedWork = finishedWork.next); + do { + if ((effect.tag & tag) === tag) { + var create = effect.create; + effect.destroy = create(); + } + effect = effect.next; + } while (effect !== finishedWork); + } +} function commitLifeCycles(finishedRoot, current, finishedWork) { switch (finishedWork.tag) { case 0: case 11: case 15: case 22: - current = finishedWork.updateQueue; - current = null !== current ? current.lastEffect : null; - if (null !== current) { - finishedRoot = current = current.next; - do { - if (3 === (finishedRoot.tag & 3)) { - var create$82 = finishedRoot.create; - finishedRoot.destroy = create$82(); - } - finishedRoot = finishedRoot.next; - } while (finishedRoot !== current); - } - current = finishedWork.updateQueue; - current = null !== current ? current.lastEffect : null; - if (null !== current) { - finishedRoot = current = current.next; - do { - var _effect = finishedRoot; - create$82 = _effect.next; - _effect = _effect.tag; - 0 !== (_effect & 4) && - 0 !== (_effect & 1) && - (enqueuePendingPassiveHookEffectUnmount(finishedWork, finishedRoot), - enqueuePendingPassiveHookEffectMount(finishedWork, finishedRoot)); - finishedRoot = create$82; - } while (finishedRoot !== current); - } + commitHookEffectListMount(3, finishedWork); return; case 1: finishedRoot = finishedWork.stateNode; - finishedWork.effectTag & 4 && - (null === current - ? finishedRoot.componentDidMount() - : ((create$82 = - finishedWork.elementType === finishedWork.type - ? current.memoizedProps - : resolveDefaultProps( - finishedWork.type, - current.memoizedProps - )), - finishedRoot.componentDidUpdate( - create$82, - current.memoizedState, - finishedRoot.__reactInternalSnapshotBeforeUpdate - ))); + if (finishedWork.effectTag & 4) + if (null === current) finishedRoot.componentDidMount(); + else { + var prevProps = + finishedWork.elementType === finishedWork.type + ? current.memoizedProps + : resolveDefaultProps(finishedWork.type, current.memoizedProps); + finishedRoot.componentDidUpdate( + prevProps, + current.memoizedState, + finishedRoot.__reactInternalSnapshotBeforeUpdate + ); + } current = finishedWork.updateQueue; null !== current && commitUpdateQueue(finishedWork, current, finishedRoot); @@ -5613,23 +5196,26 @@ function commitLifeCycles(finishedRoot, current, finishedWork) { } return; case 5: - null === current && finishedWork.effectTag & 4 && shim(); + if (null === current && finishedWork.effectTag & 4) + throw Error( + "The current renderer does not support mutation. This error is likely caused by a bug in React. Please file an issue." + ); return; case 6: return; case 4: return; case 12: - create$82 = finishedWork.memoizedProps.onRender; - _effect = commitTime; - "function" === typeof create$82 && - create$82( + prevProps = finishedWork.memoizedProps.onRender; + var commitTime$jscomp$0 = commitTime; + "function" === typeof prevProps && + prevProps( finishedWork.memoizedProps.id, null === current ? "mount" : "update", finishedWork.actualDuration, finishedWork.treeBaseDuration, finishedWork.actualStartTime, - _effect, + commitTime$jscomp$0, finishedRoot.memoizedInteractions ); return; @@ -5639,26 +5225,74 @@ function commitLifeCycles(finishedRoot, current, finishedWork) { case 17: case 20: case 21: - case 23: - case 24: return; } throw Error( "This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue." ); } -function detachFiberMutation(fiber) { - fiber.alternate = null; - fiber.child = null; - fiber.dependencies = null; - fiber.firstEffect = null; - fiber.lastEffect = null; - fiber.memoizedProps = null; - fiber.memoizedState = null; - fiber.pendingProps = null; - fiber.return = null; - fiber.stateNode = null; - fiber.updateQueue = null; +function commitUnmount(finishedRoot, current$jscomp$0, renderPriorityLevel) { + "function" === typeof onCommitFiberUnmount && + onCommitFiberUnmount(current$jscomp$0); + switch (current$jscomp$0.tag) { + case 0: + case 11: + case 14: + case 15: + case 22: + finishedRoot = current$jscomp$0.updateQueue; + if ( + null !== finishedRoot && + ((finishedRoot = finishedRoot.lastEffect), null !== finishedRoot) + ) { + var firstEffect = finishedRoot.next; + runWithPriority( + 97 < renderPriorityLevel ? 97 : renderPriorityLevel, + function() { + var effect = firstEffect; + do { + var _destroy = effect.destroy; + if (void 0 !== _destroy) { + var current = current$jscomp$0; + try { + _destroy(); + } catch (error) { + captureCommitPhaseError(current, error); + } + } + effect = effect.next; + } while (effect !== firstEffect); + } + ); + } + break; + case 1: + safelyDetachRef(current$jscomp$0); + renderPriorityLevel = current$jscomp$0.stateNode; + "function" === typeof renderPriorityLevel.componentWillUnmount && + safelyCallComponentWillUnmount(current$jscomp$0, renderPriorityLevel); + break; + case 5: + safelyDetachRef(current$jscomp$0); + break; + case 4: + createChildNodeSet(current$jscomp$0.stateNode.containerInfo); + } +} +function detachFiber(current) { + var alternate = current.alternate; + current.return = null; + current.child = null; + current.memoizedState = null; + current.updateQueue = null; + current.dependencies = null; + current.alternate = null; + current.firstEffect = null; + current.lastEffect = null; + current.pendingProps = null; + current.memoizedProps = null; + current.stateNode = null; + null !== alternate && detachFiber(alternate); } function commitWork(current, finishedWork) { switch (finishedWork.tag) { @@ -5667,19 +5301,7 @@ function commitWork(current, finishedWork) { case 14: case 15: case 22: - current = finishedWork.updateQueue; - current = null !== current ? current.lastEffect : null; - if (null !== current) { - finishedWork = current = current.next; - do { - if (3 === (finishedWork.tag & 3)) { - var destroy = finishedWork.destroy; - finishedWork.destroy = void 0; - void 0 !== destroy && destroy(); - } - finishedWork = finishedWork.next; - } while (finishedWork !== current); - } + commitHookEffectListUnmount(3, finishedWork); return; case 12: return; @@ -5691,9 +5313,6 @@ function commitWork(current, finishedWork) { case 19: attachSuspenseRetryListeners(finishedWork); return; - case 23: - case 24: - return; } a: { switch (finishedWork.tag) { @@ -5712,49 +5331,87 @@ function commitWork(current, finishedWork) { } } function attachSuspenseRetryListeners(finishedWork) { - var wakeables = finishedWork.updateQueue; - if (null !== wakeables) { + var thenables = finishedWork.updateQueue; + if (null !== thenables) { finishedWork.updateQueue = null; var retryCache = finishedWork.stateNode; null === retryCache && (retryCache = finishedWork.stateNode = new PossiblyWeakSet()); - wakeables.forEach(function(wakeable) { - var retry = resolveRetryWakeable.bind(null, finishedWork, wakeable); - retryCache.has(wakeable) || - (!0 !== wakeable.__reactDoNotTraceInteractions && + thenables.forEach(function(thenable) { + var retry = resolveRetryThenable.bind(null, finishedWork, thenable); + retryCache.has(thenable) || + (!0 !== thenable.__reactDoNotTraceInteractions && (retry = tracing.unstable_wrap(retry)), - retryCache.add(wakeable), - wakeable.then(retry, retry)); + retryCache.add(thenable), + thenable.then(retry, retry)); }); } } -function isSuspenseBoundaryBeingHidden(current, finishedWork) { - return null !== current && - ((current = current.memoizedState), - null === current || null !== current.dehydrated) - ? ((finishedWork = finishedWork.memoizedState), - null !== finishedWork && null === finishedWork.dehydrated) - : !1; +var PossiblyWeakMap = "function" === typeof WeakMap ? WeakMap : Map; +function createRootErrorUpdate(fiber, errorInfo, expirationTime) { + expirationTime = createUpdate(expirationTime, null); + expirationTime.tag = 3; + expirationTime.payload = { element: null }; + var error = errorInfo.value; + expirationTime.callback = function() { + hasUncaughtError || ((hasUncaughtError = !0), (firstUncaughtError = error)); + logError(fiber, errorInfo); + }; + return expirationTime; +} +function createClassErrorUpdate(fiber, errorInfo, expirationTime) { + expirationTime = createUpdate(expirationTime, null); + expirationTime.tag = 3; + var getDerivedStateFromError = fiber.type.getDerivedStateFromError; + if ("function" === typeof getDerivedStateFromError) { + var error = errorInfo.value; + expirationTime.payload = function() { + logError(fiber, errorInfo); + return getDerivedStateFromError(error); + }; + } + var inst = fiber.stateNode; + null !== inst && + "function" === typeof inst.componentDidCatch && + (expirationTime.callback = function() { + "function" !== typeof getDerivedStateFromError && + (null === legacyErrorBoundariesThatAlreadyFailed + ? (legacyErrorBoundariesThatAlreadyFailed = new Set([this])) + : legacyErrorBoundariesThatAlreadyFailed.add(this), + logError(fiber, errorInfo)); + var stack = errorInfo.stack; + this.componentDidCatch(errorInfo.value, { + componentStack: null !== stack ? stack : "" + }); + }); + return expirationTime; } var ceil = Math.ceil, - ReactCurrentDispatcher$2 = ReactSharedInternals.ReactCurrentDispatcher, + ReactCurrentDispatcher$1 = ReactSharedInternals.ReactCurrentDispatcher, ReactCurrentOwner$2 = ReactSharedInternals.ReactCurrentOwner, - executionContext = 0, + NoContext = 0, + LegacyUnbatchedContext = 8, + RenderContext = 16, + CommitContext = 32, + RootIncomplete = 0, + RootFatalErrored = 1, + RootErrored = 2, + RootSuspended = 3, + RootSuspendedWithDelay = 4, + RootCompleted = 5, + executionContext = NoContext, workInProgressRoot = null, workInProgress = null, - workInProgressRootRenderLanes = 0, - subtreeRenderLanes = 0, - subtreeRenderLanesCursor = createCursor(0), - workInProgressRootExitStatus = 0, + renderExpirationTime$1 = 0, + workInProgressRootExitStatus = RootIncomplete, workInProgressRootFatalError = null, - workInProgressRootLatestSuspenseTimeout = -1, + workInProgressRootLatestProcessedExpirationTime = 1073741823, + workInProgressRootLatestSuspenseTimeout = 1073741823, workInProgressRootCanSuspendUsingConfig = null, - workInProgressRootIncludedLanes = 0, - workInProgressRootSkippedLanes = 0, - workInProgressRootUpdatedLanes = 0, - workInProgressRootPingedLanes = 0, - mostRecentlyUpdatedRoot = null, + workInProgressRootNextUnprocessedUpdateTime = 0, + workInProgressRootHasPendingPing = !1, globalMostRecentFallbackTime = 0, + FALLBACK_THROTTLE_MS = 500, nextEffect = null, hasUncaughtError = !1, firstUncaughtError = null, @@ -5762,208 +5419,201 @@ var ceil = Math.ceil, rootDoesHavePassiveEffects = !1, rootWithPendingPassiveEffects = null, pendingPassiveEffectsRenderPriority = 90, - pendingPassiveEffectsLanes = 0, - pendingPassiveHookEffectsMount = [], - pendingPassiveHookEffectsUnmount = [], + pendingPassiveEffectsExpirationTime = 0, rootsWithPendingDiscreteUpdates = null, nestedUpdateCount = 0, rootWithNestedUpdates = null, spawnedWorkDuringRender = null, - currentEventTime = -1, - currentEventWipLanes = 0, - currentEventPendingLanes = 0, - focusedInstanceHandle = null, - shouldFireAfterActiveInstanceBlur = !1; -function requestEventTime() { - return 0 !== (executionContext & 48) - ? now() - : -1 !== currentEventTime + currentEventTime = 0; +function requestCurrentTimeForUpdate() { + return (executionContext & (RenderContext | CommitContext)) !== NoContext + ? 1073741821 - ((now() / 10) | 0) + : 0 !== currentEventTime ? currentEventTime - : (currentEventTime = now()); + : (currentEventTime = 1073741821 - ((now() / 10) | 0)); } -function requestUpdateLane(fiber, suspenseConfig) { +function computeExpirationForFiber(currentTime, fiber, suspenseConfig) { fiber = fiber.mode; - if (0 === (fiber & 2)) return 1; - if (0 === (fiber & 4)) return 99 === getCurrentPriorityLevel() ? 1 : 2; - 0 === currentEventWipLanes && - (currentEventWipLanes = workInProgressRootIncludedLanes); - if (null !== suspenseConfig) { - suspenseConfig = suspenseConfig.timeoutMs; - fiber = void 0 === suspenseConfig || 1e4 > (suspenseConfig | 0) ? 8 : 6; - 0 !== currentEventPendingLanes && - (currentEventPendingLanes = - null !== mostRecentlyUpdatedRoot - ? mostRecentlyUpdatedRoot.pendingLanes - : 0); - suspenseConfig = currentEventWipLanes; - var pendingLanes = currentEventPendingLanes; - if (8 === fiber) - (fiber = pickArbitraryLane(122880 & ~pendingLanes)), - 0 === fiber && - ((fiber = pickArbitraryLane(122880 & ~suspenseConfig)), - 0 === fiber && (fiber = 8192)), - (suspenseConfig = fiber); - else if (6 === fiber) - (fiber = pickArbitraryLane(3932160 & ~pendingLanes)), - 0 === fiber && - ((fiber = pickArbitraryLane(3932160 & ~suspenseConfig)), - 0 === fiber && (fiber = 262144)), - (suspenseConfig = fiber); - else - throw Error( - "Invalid transition priority: " + fiber + ". This is a bug in React." - ); - return suspenseConfig; - } - suspenseConfig = getCurrentPriorityLevel(); - 0 !== (executionContext & 4) && 98 === suspenseConfig - ? (suspenseConfig = findUpdateLane(14, currentEventWipLanes)) - : ((suspenseConfig = schedulerPriorityToLanePriority(suspenseConfig)), - (suspenseConfig = findUpdateLane(suspenseConfig, currentEventWipLanes))); - return suspenseConfig; + if (0 === (fiber & 2)) return 1073741823; + var priorityLevel = getCurrentPriorityLevel(); + if (0 === (fiber & 4)) return 99 === priorityLevel ? 1073741823 : 1073741822; + if ((executionContext & RenderContext) !== NoContext) + return renderExpirationTime$1; + if (null !== suspenseConfig) + currentTime = + 1073741821 - + 25 * + ((((1073741821 - + currentTime + + (suspenseConfig.timeoutMs | 0 || 5e3) / 10) / + 25) | + 0) + + 1); + else + switch (priorityLevel) { + case 99: + currentTime = 1073741823; + break; + case 98: + currentTime = + 1073741821 - 10 * ((((1073741821 - currentTime + 15) / 10) | 0) + 1); + break; + case 97: + case 96: + currentTime = + 1073741821 - 25 * ((((1073741821 - currentTime + 500) / 25) | 0) + 1); + break; + case 95: + currentTime = 2; + break; + default: + throw Error("Expected a valid priority level"); + } + null !== workInProgressRoot && + currentTime === renderExpirationTime$1 && + --currentTime; + return currentTime; } -function scheduleUpdateOnFiber(fiber, lane, eventTime) { +function scheduleWork(fiber, expirationTime) { if (50 < nestedUpdateCount) throw ((nestedUpdateCount = 0), (rootWithNestedUpdates = null), Error( "Maximum update depth exceeded. This can happen when a component repeatedly calls setState inside componentWillUpdate or componentDidUpdate. React limits the number of nested updates to prevent infinite loops." )); - fiber = markUpdateLaneFromFiberToRoot(fiber, lane); - if (null === fiber) return null; - markRootUpdated(fiber, lane, eventTime); - fiber === workInProgressRoot && - ((workInProgressRootUpdatedLanes |= lane), - 4 === workInProgressRootExitStatus && - markRootSuspended$1(fiber, workInProgressRootRenderLanes)); - var priorityLevel = getCurrentPriorityLevel(); - 1 === lane - ? 0 !== (executionContext & 8) && 0 === (executionContext & 48) - ? (schedulePendingInteractions(fiber, lane), performSyncWorkOnRoot(fiber)) - : (ensureRootIsScheduled(fiber, eventTime), - schedulePendingInteractions(fiber, lane), - 0 === executionContext && flushSyncCallbackQueue()) - : (0 === (executionContext & 4) || - (98 !== priorityLevel && 99 !== priorityLevel) || - (null === rootsWithPendingDiscreteUpdates - ? (rootsWithPendingDiscreteUpdates = new Set([fiber])) - : rootsWithPendingDiscreteUpdates.add(fiber)), - ensureRootIsScheduled(fiber, eventTime), - schedulePendingInteractions(fiber, lane)); - mostRecentlyUpdatedRoot = fiber; -} -function markUpdateLaneFromFiberToRoot(sourceFiber, lane) { - sourceFiber.lanes |= lane; - var alternate = sourceFiber.alternate; - null !== alternate && (alternate.lanes |= lane); - alternate = sourceFiber; - for (sourceFiber = sourceFiber.return; null !== sourceFiber; ) - (sourceFiber.childLanes |= lane), - (alternate = sourceFiber.alternate), - null !== alternate && (alternate.childLanes |= lane), - (alternate = sourceFiber), - (sourceFiber = sourceFiber.return); - return 3 === alternate.tag ? alternate.stateNode : null; -} -function ensureRootIsScheduled(root, currentTime) { - for ( - var existingCallbackNode = root.callbackNode, - suspendedLanes = root.suspendedLanes, - pingedLanes = root.pingedLanes, - expirationTimes = root.expirationTimes, - lanes = root.pendingLanes; - 0 < lanes; - - ) { - var index$5 = 31 - clz32(lanes), - lane = 1 << index$5, - expirationTime = expirationTimes[index$5]; - if (-1 === expirationTime) { - if (0 === (lane & suspendedLanes) || 0 !== (lane & pingedLanes)) { - expirationTime = currentTime; - getHighestPriorityLanes(lane); - var priority = return_highestLanePriority; - expirationTimes[index$5] = - 12 <= priority - ? expirationTime + 1e3 - : 6 <= priority - ? expirationTime + 5e3 - : -1; - } - } else expirationTime <= currentTime && (root.expiredLanes |= lane); - lanes &= ~lane; + fiber = markUpdateTimeFromFiberToRoot(fiber, expirationTime); + if (null !== fiber) { + var priorityLevel = getCurrentPriorityLevel(); + 1073741823 === expirationTime + ? (executionContext & LegacyUnbatchedContext) !== NoContext && + (executionContext & (RenderContext | CommitContext)) === NoContext + ? (schedulePendingInteractions(fiber, expirationTime), + performSyncWorkOnRoot(fiber)) + : (ensureRootIsScheduled(fiber), + schedulePendingInteractions(fiber, expirationTime), + executionContext === NoContext && flushSyncCallbackQueue()) + : (ensureRootIsScheduled(fiber), + schedulePendingInteractions(fiber, expirationTime)); + (executionContext & 4) === NoContext || + (98 !== priorityLevel && 99 !== priorityLevel) || + (null === rootsWithPendingDiscreteUpdates + ? (rootsWithPendingDiscreteUpdates = new Map([[fiber, expirationTime]])) + : ((priorityLevel = rootsWithPendingDiscreteUpdates.get(fiber)), + (void 0 === priorityLevel || priorityLevel > expirationTime) && + rootsWithPendingDiscreteUpdates.set(fiber, expirationTime))); } - suspendedLanes = getNextLanes( - root, - root === workInProgressRoot ? workInProgressRootRenderLanes : 0 - ); - currentTime = return_highestLanePriority; - if (0 === suspendedLanes) - null !== existingCallbackNode && - (existingCallbackNode !== fakeCallbackNode && - Scheduler_cancelCallback(existingCallbackNode), - (root.callbackNode = null), - (root.callbackPriority = 0)); +} +function markUpdateTimeFromFiberToRoot(fiber, expirationTime) { + fiber.expirationTime < expirationTime && + (fiber.expirationTime = expirationTime); + var alternate = fiber.alternate; + null !== alternate && + alternate.expirationTime < expirationTime && + (alternate.expirationTime = expirationTime); + var node = fiber.return, + root = null; + if (null === node && 3 === fiber.tag) root = fiber.stateNode; + else + for (; null !== node; ) { + alternate = node.alternate; + node.childExpirationTime < expirationTime && + (node.childExpirationTime = expirationTime); + null !== alternate && + alternate.childExpirationTime < expirationTime && + (alternate.childExpirationTime = expirationTime); + if (null === node.return && 3 === node.tag) { + root = node.stateNode; + break; + } + node = node.return; + } + null !== root && + (workInProgressRoot === root && + (markUnprocessedUpdateTime(expirationTime), + workInProgressRootExitStatus === RootSuspendedWithDelay && + markRootSuspendedAtTime(root, renderExpirationTime$1)), + markRootUpdatedAtTime(root, expirationTime)); + return root; +} +function getNextRootExpirationTimeToWorkOn(root) { + var lastExpiredTime = root.lastExpiredTime; + if (0 !== lastExpiredTime) return lastExpiredTime; + lastExpiredTime = root.firstPendingTime; + if (!isRootSuspendedAtTime(root, lastExpiredTime)) return lastExpiredTime; + var lastPingedTime = root.lastPingedTime; + root = root.nextKnownPendingLevel; + root = lastPingedTime > root ? lastPingedTime : root; + return 2 >= root && lastExpiredTime !== root ? 0 : root; +} +function ensureRootIsScheduled(root) { + if (0 !== root.lastExpiredTime) + (root.callbackExpirationTime = 1073741823), + (root.callbackPriority = 99), + (root.callbackNode = scheduleSyncCallback( + performSyncWorkOnRoot.bind(null, root) + )); else { - if (null !== existingCallbackNode) { - if (root.callbackPriority === currentTime) return; - existingCallbackNode !== fakeCallbackNode && - Scheduler_cancelCallback(existingCallbackNode); + var expirationTime = getNextRootExpirationTimeToWorkOn(root), + existingCallbackNode = root.callbackNode; + if (0 === expirationTime) + null !== existingCallbackNode && + ((root.callbackNode = null), + (root.callbackExpirationTime = 0), + (root.callbackPriority = 90)); + else { + var currentTime = requestCurrentTimeForUpdate(); + currentTime = inferPriorityFromExpirationTime( + currentTime, + expirationTime + ); + if (null !== existingCallbackNode) { + var existingCallbackPriority = root.callbackPriority; + if ( + root.callbackExpirationTime === expirationTime && + existingCallbackPriority >= currentTime + ) + return; + existingCallbackNode !== fakeCallbackNode && + Scheduler_cancelCallback(existingCallbackNode); + } + root.callbackExpirationTime = expirationTime; + root.callbackPriority = currentTime; + expirationTime = + 1073741823 === expirationTime + ? scheduleSyncCallback(performSyncWorkOnRoot.bind(null, root)) + : scheduleCallback( + currentTime, + performConcurrentWorkOnRoot.bind(null, root), + { timeout: 10 * (1073741821 - expirationTime) - now() } + ); + root.callbackNode = expirationTime; } - 17 === currentTime - ? ((existingCallbackNode = performSyncWorkOnRoot.bind(null, root)), - null === syncQueue - ? ((syncQueue = [existingCallbackNode]), - (immediateQueueCallbackNode = Scheduler_scheduleCallback( - Scheduler_ImmediatePriority, - flushSyncCallbackQueueImpl - ))) - : syncQueue.push(existingCallbackNode), - (existingCallbackNode = fakeCallbackNode)) - : 16 === currentTime - ? (existingCallbackNode = scheduleCallback( - 99, - performSyncWorkOnRoot.bind(null, root) - )) - : ((existingCallbackNode = lanePriorityToSchedulerPriority(currentTime)), - (existingCallbackNode = scheduleCallback( - existingCallbackNode, - performConcurrentWorkOnRoot.bind(null, root) - ))); - root.callbackPriority = currentTime; - root.callbackNode = existingCallbackNode; } } function performConcurrentWorkOnRoot(root, didTimeout) { - currentEventTime = -1; - currentEventPendingLanes = currentEventWipLanes = 0; - if (0 !== (executionContext & 48)) - throw Error("Should not already be working."); - var originalCallbackNode = root.callbackNode; - if (flushPassiveEffects() && root.callbackNode !== originalCallbackNode) + currentEventTime = 0; + if (didTimeout) { + didTimeout = requestCurrentTimeForUpdate(); + var lastExpiredTime = root.lastExpiredTime; + if (0 === lastExpiredTime || lastExpiredTime > didTimeout) + root.lastExpiredTime = didTimeout; + ensureRootIsScheduled(root); return null; - var lanes = getNextLanes( - root, - root === workInProgressRoot ? workInProgressRootRenderLanes : 0 - ); - if (0 === lanes) return null; - if (didTimeout) - return ( - (root.expiredLanes |= lanes & root.pendingLanes), - ensureRootIsScheduled(root, now()), - null - ); - var lanes$jscomp$0 = lanes; - didTimeout = executionContext; - executionContext |= 16; - var prevDispatcher = pushDispatcher(); - if ( - workInProgressRoot !== root || - workInProgressRootRenderLanes !== lanes$jscomp$0 - ) - prepareFreshStack(root, lanes$jscomp$0), - startWorkOnPendingInteractions(root, lanes$jscomp$0); - lanes$jscomp$0 = pushInteractions(root); + } + lastExpiredTime = getNextRootExpirationTimeToWorkOn(root); + if (0 === lastExpiredTime) return null; + didTimeout = root.callbackNode; + if ((executionContext & (RenderContext | CommitContext)) !== NoContext) + throw Error("Should not already be working."); + flushPassiveEffects(); + var expirationTime = lastExpiredTime, + prevExecutionContext = executionContext; + executionContext |= RenderContext; + var exitStatus = pushDispatcher(); + if (root !== workInProgressRoot || expirationTime !== renderExpirationTime$1) + prepareFreshStack(root, expirationTime), + startWorkOnPendingInteractions(root, expirationTime); + expirationTime = pushInteractions(root); do try { workLoopConcurrent(); @@ -5973,190 +5623,205 @@ function performConcurrentWorkOnRoot(root, didTimeout) { } while (1); resetContextDependencies(); - tracing.__interactionsRef.current = lanes$jscomp$0; - ReactCurrentDispatcher$2.current = prevDispatcher; - executionContext = didTimeout; + tracing.__interactionsRef.current = expirationTime; + ReactCurrentDispatcher$1.current = exitStatus; + executionContext = prevExecutionContext; null !== workInProgress - ? (didTimeout = 0) + ? (exitStatus = RootIncomplete) : ((workInProgressRoot = null), - (workInProgressRootRenderLanes = 0), - (didTimeout = workInProgressRootExitStatus)); - if (0 !== (workInProgressRootIncludedLanes & workInProgressRootUpdatedLanes)) - prepareFreshStack(root, 0); - else if (0 !== didTimeout) { - 2 === didTimeout && - ((executionContext |= 64), - root.hydrate && ((root.hydrate = !1), shim(root.containerInfo)), - (lanes = getLanesToRetrySynchronouslyOnError(root)), - 0 !== lanes && (didTimeout = renderRootSync(root, lanes))); - if (1 === didTimeout) - throw ((originalCallbackNode = workInProgressRootFatalError), - prepareFreshStack(root, 0), - markRootSuspended$1(root, lanes), - ensureRootIsScheduled(root, now()), - originalCallbackNode); - root.finishedWork = root.current.alternate; - root.finishedLanes = lanes; - switch (didTimeout) { - case 0: - case 1: + (exitStatus = workInProgressRootExitStatus)); + if (exitStatus !== RootIncomplete) { + exitStatus === RootErrored && + ((lastExpiredTime = 2 < lastExpiredTime ? 2 : lastExpiredTime), + (exitStatus = renderRootSync(root, lastExpiredTime))); + if (exitStatus === RootFatalErrored) + throw ((didTimeout = workInProgressRootFatalError), + prepareFreshStack(root, lastExpiredTime), + markRootSuspendedAtTime(root, lastExpiredTime), + ensureRootIsScheduled(root), + didTimeout); + prevExecutionContext = root.finishedWork = root.current.alternate; + root.finishedExpirationTime = lastExpiredTime; + switch (exitStatus) { + case RootIncomplete: + case RootFatalErrored: throw Error("Root did not complete. This is a bug in React."); - case 2: + case RootErrored: commitRoot(root); break; - case 3: - markRootSuspended$1(root, lanes); + case RootSuspended: + markRootSuspendedAtTime(root, lastExpiredTime); + exitStatus = root.lastSuspendedTime; + lastExpiredTime === exitStatus && + (root.nextKnownPendingLevel = getRemainingExpirationTime( + prevExecutionContext + )); if ( - (lanes & 62914560) === lanes && - ((didTimeout = globalMostRecentFallbackTime + 500 - now()), - 10 < didTimeout) + 1073741823 === workInProgressRootLatestProcessedExpirationTime && + ((prevExecutionContext = + globalMostRecentFallbackTime + FALLBACK_THROTTLE_MS - now()), + 10 < prevExecutionContext) ) { - if (0 !== getNextLanes(root, 0)) break; - prevDispatcher = root.suspendedLanes; - if ((prevDispatcher & lanes) !== lanes) { - requestEventTime(); - root.pingedLanes |= root.suspendedLanes & prevDispatcher; + if ( + workInProgressRootHasPendingPing && + ((expirationTime = root.lastPingedTime), + 0 === expirationTime || expirationTime >= lastExpiredTime) + ) { + root.lastPingedTime = lastExpiredTime; + prepareFreshStack(root, lastExpiredTime); + break; + } + expirationTime = getNextRootExpirationTimeToWorkOn(root); + if (0 !== expirationTime && expirationTime !== lastExpiredTime) break; + if (0 !== exitStatus && exitStatus !== lastExpiredTime) { + root.lastPingedTime = exitStatus; break; } root.timeoutHandle = scheduleTimeout( commitRoot.bind(null, root), - didTimeout + prevExecutionContext ); break; } commitRoot(root); break; - case 4: - markRootSuspended$1(root, lanes); - if (0 !== getNextLanes(root, 0)) break; - didTimeout = root.suspendedLanes; - if ((didTimeout & lanes) !== lanes) { - requestEventTime(); - root.pingedLanes |= root.suspendedLanes & didTimeout; - break; - } - lanes = getMostRecentEventTime(root, lanes); - -1 !== workInProgressRootLatestSuspenseTimeout - ? (lanes = workInProgressRootLatestSuspenseTimeout - now()) - : -1 === lanes - ? (lanes = 0) - : ((lanes = now() - lanes), - (lanes = - (120 > lanes - ? 120 - : 480 > lanes - ? 480 - : 1080 > lanes - ? 1080 - : 1920 > lanes - ? 1920 - : 3e3 > lanes - ? 3e3 - : 4320 > lanes - ? 4320 - : 1960 * ceil(lanes / 1960)) - lanes)); - if (10 < lanes) { - root.timeoutHandle = scheduleTimeout( - commitRoot.bind(null, root), - lanes - ); - break; - } - commitRoot(root); - break; - case 5: - lanes$jscomp$0 = getMostRecentEventTime(root, lanes); + case RootSuspendedWithDelay: + markRootSuspendedAtTime(root, lastExpiredTime); + exitStatus = root.lastSuspendedTime; + lastExpiredTime === exitStatus && + (root.nextKnownPendingLevel = getRemainingExpirationTime( + prevExecutionContext + )); if ( - -1 !== lanes$jscomp$0 && - null !== workInProgressRootCanSuspendUsingConfig && - ((didTimeout = - workInProgressRootCanSuspendUsingConfig.busyMinDurationMs | 0), - 0 >= didTimeout - ? (didTimeout = 0) - : ((prevDispatcher = - workInProgressRootCanSuspendUsingConfig.busyDelayMs | 0), - (lanes$jscomp$0 = now() - lanes$jscomp$0), - (didTimeout = - lanes$jscomp$0 <= prevDispatcher - ? 0 - : prevDispatcher + didTimeout - lanes$jscomp$0)), - 10 < didTimeout) + workInProgressRootHasPendingPing && + ((prevExecutionContext = root.lastPingedTime), + 0 === prevExecutionContext || prevExecutionContext >= lastExpiredTime) ) { - markRootSuspended$1(root, lanes); + root.lastPingedTime = lastExpiredTime; + prepareFreshStack(root, lastExpiredTime); + break; + } + prevExecutionContext = getNextRootExpirationTimeToWorkOn(root); + if ( + 0 !== prevExecutionContext && + prevExecutionContext !== lastExpiredTime + ) + break; + if (0 !== exitStatus && exitStatus !== lastExpiredTime) { + root.lastPingedTime = exitStatus; + break; + } + 1073741823 !== workInProgressRootLatestSuspenseTimeout + ? (prevExecutionContext = + 10 * (1073741821 - workInProgressRootLatestSuspenseTimeout) - + now()) + : 1073741823 === workInProgressRootLatestProcessedExpirationTime + ? (prevExecutionContext = 0) + : ((prevExecutionContext = + 10 * + (1073741821 - workInProgressRootLatestProcessedExpirationTime) - + 5e3), + (exitStatus = now()), + (lastExpiredTime = + 10 * (1073741821 - lastExpiredTime) - exitStatus), + (prevExecutionContext = exitStatus - prevExecutionContext), + 0 > prevExecutionContext && (prevExecutionContext = 0), + (prevExecutionContext = + (120 > prevExecutionContext + ? 120 + : 480 > prevExecutionContext + ? 480 + : 1080 > prevExecutionContext + ? 1080 + : 1920 > prevExecutionContext + ? 1920 + : 3e3 > prevExecutionContext + ? 3e3 + : 4320 > prevExecutionContext + ? 4320 + : 1960 * ceil(prevExecutionContext / 1960)) - + prevExecutionContext), + lastExpiredTime < prevExecutionContext && + (prevExecutionContext = lastExpiredTime)); + if (10 < prevExecutionContext) { root.timeoutHandle = scheduleTimeout( commitRoot.bind(null, root), - didTimeout + prevExecutionContext ); break; } commitRoot(root); break; + case RootCompleted: + if ( + 1073741823 !== workInProgressRootLatestProcessedExpirationTime && + null !== workInProgressRootCanSuspendUsingConfig + ) { + expirationTime = workInProgressRootLatestProcessedExpirationTime; + var suspenseConfig = workInProgressRootCanSuspendUsingConfig; + prevExecutionContext = suspenseConfig.busyMinDurationMs | 0; + 0 >= prevExecutionContext + ? (prevExecutionContext = 0) + : ((exitStatus = suspenseConfig.busyDelayMs | 0), + (expirationTime = + now() - + (10 * (1073741821 - expirationTime) - + (suspenseConfig.timeoutMs | 0 || 5e3))), + (prevExecutionContext = + expirationTime <= exitStatus + ? 0 + : exitStatus + prevExecutionContext - expirationTime)); + if (10 < prevExecutionContext) { + markRootSuspendedAtTime(root, lastExpiredTime); + root.timeoutHandle = scheduleTimeout( + commitRoot.bind(null, root), + prevExecutionContext + ); + break; + } + } + commitRoot(root); + break; default: throw Error("Unknown root exit status."); } } - ensureRootIsScheduled(root, now()); - return root.callbackNode === originalCallbackNode + ensureRootIsScheduled(root); + return root.callbackNode === didTimeout ? performConcurrentWorkOnRoot.bind(null, root) : null; } -function markRootSuspended$1(root, suspendedLanes) { - suspendedLanes &= ~workInProgressRootPingedLanes; - suspendedLanes &= ~workInProgressRootUpdatedLanes; - root.suspendedLanes |= suspendedLanes; - root.pingedLanes &= ~suspendedLanes; - for (root = root.expirationTimes; 0 < suspendedLanes; ) { - var index$10 = 31 - clz32(suspendedLanes), - lane = 1 << index$10; - root[index$10] = -1; - suspendedLanes &= ~lane; - } -} function performSyncWorkOnRoot(root) { - if (0 !== (executionContext & 48)) + if ((executionContext & (RenderContext | CommitContext)) !== NoContext) throw Error("Should not already be working."); flushPassiveEffects(); - if ( - root === workInProgressRoot && - 0 !== (root.expiredLanes & workInProgressRootRenderLanes) - ) { - var lanes = workInProgressRootRenderLanes; - var exitStatus = renderRootSync(root, lanes); - 0 !== (workInProgressRootIncludedLanes & workInProgressRootUpdatedLanes) && - ((lanes = getNextLanes(root, lanes)), - (exitStatus = renderRootSync(root, lanes))); - } else - (lanes = getNextLanes(root, 0)), (exitStatus = renderRootSync(root, lanes)); + var lastExpiredTime = root.lastExpiredTime; + lastExpiredTime = + 0 !== lastExpiredTime + ? root === workInProgressRoot && renderExpirationTime$1 >= lastExpiredTime + ? renderExpirationTime$1 + : lastExpiredTime + : 1073741823; + var exitStatus = renderRootSync(root, lastExpiredTime); 0 !== root.tag && - 2 === exitStatus && - ((executionContext |= 64), - root.hydrate && ((root.hydrate = !1), shim(root.containerInfo)), - (lanes = getLanesToRetrySynchronouslyOnError(root)), - 0 !== lanes && (exitStatus = renderRootSync(root, lanes))); - if (1 === exitStatus) + exitStatus === RootErrored && + ((lastExpiredTime = 2 < lastExpiredTime ? 2 : lastExpiredTime), + (exitStatus = renderRootSync(root, lastExpiredTime))); + if (exitStatus === RootFatalErrored) throw ((exitStatus = workInProgressRootFatalError), - prepareFreshStack(root, 0), - markRootSuspended$1(root, lanes), - ensureRootIsScheduled(root, now()), + prepareFreshStack(root, lastExpiredTime), + markRootSuspendedAtTime(root, lastExpiredTime), + ensureRootIsScheduled(root), exitStatus); root.finishedWork = root.current.alternate; - root.finishedLanes = lanes; + root.finishedExpirationTime = lastExpiredTime; commitRoot(root); - ensureRootIsScheduled(root, now()); + ensureRootIsScheduled(root); return null; } -function pushRenderLanes(fiber, lanes) { - push(subtreeRenderLanesCursor, subtreeRenderLanes); - subtreeRenderLanes |= lanes; - workInProgressRootIncludedLanes |= lanes; -} -function popRenderLanes() { - subtreeRenderLanes = subtreeRenderLanesCursor.current; - pop(subtreeRenderLanesCursor); -} -function prepareFreshStack(root, lanes) { +function prepareFreshStack(root, expirationTime) { root.finishedWork = null; - root.finishedLanes = 0; + root.finishedExpirationTime = 0; var timeoutHandle = root.timeoutHandle; -1 !== timeoutHandle && ((root.timeoutHandle = -1), cancelTimeout(timeoutHandle)); @@ -6174,7 +5839,6 @@ function prepareFreshStack(root, lanes) { popHostContainer(); pop(didPerformWorkStackCursor); pop(contextStackCursor); - resetWorkInProgressVersions(); break; case 5: popHostContext(interruptedWork); @@ -6190,30 +5854,26 @@ function prepareFreshStack(root, lanes) { break; case 10: popProvider(interruptedWork); - break; - case 23: - case 24: - popRenderLanes(); } timeoutHandle = timeoutHandle.return; } workInProgressRoot = root; workInProgress = createWorkInProgress(root.current, null); - workInProgressRootRenderLanes = subtreeRenderLanes = workInProgressRootIncludedLanes = lanes; - workInProgressRootExitStatus = 0; + renderExpirationTime$1 = expirationTime; + workInProgressRootExitStatus = RootIncomplete; workInProgressRootFatalError = null; - workInProgressRootLatestSuspenseTimeout = -1; + workInProgressRootLatestSuspenseTimeout = workInProgressRootLatestProcessedExpirationTime = 1073741823; workInProgressRootCanSuspendUsingConfig = null; - workInProgressRootPingedLanes = workInProgressRootUpdatedLanes = workInProgressRootSkippedLanes = 0; + workInProgressRootNextUnprocessedUpdateTime = 0; + workInProgressRootHasPendingPing = !1; spawnedWorkDuringRender = null; } function handleError(root$jscomp$0, thrownValue) { do { - var erroredWork = workInProgress; try { resetContextDependencies(); - ReactCurrentDispatcher$1.current = ContextOnlyDispatcher; - if (didScheduleRenderPhaseUpdate) { + ReactCurrentDispatcher.current = ContextOnlyDispatcher; + if (didScheduleRenderPhaseUpdate) for ( var hook = currentlyRenderingFiber$1.memoizedState; null !== hook; @@ -6223,26 +5883,23 @@ function handleError(root$jscomp$0, thrownValue) { null !== queue && (queue.pending = null); hook = hook.next; } - didScheduleRenderPhaseUpdate = !1; - } - renderLanes = 0; + renderExpirationTime = 0; workInProgressHook = currentHook = currentlyRenderingFiber$1 = null; - didScheduleRenderPhaseUpdateDuringThisPass = !1; - ReactCurrentOwner$2.current = null; - if (null === erroredWork || null === erroredWork.return) { - workInProgressRootExitStatus = 1; - workInProgressRootFatalError = thrownValue; - workInProgress = null; - break; - } - erroredWork.mode & 8 && - stopProfilerTimerIfRunningAndRecordDelta(erroredWork, !0); + didScheduleRenderPhaseUpdate = !1; + if (null === workInProgress || null === workInProgress.return) + return ( + (workInProgressRootExitStatus = RootFatalErrored), + (workInProgressRootFatalError = thrownValue), + (workInProgress = null) + ); + workInProgress.mode & 8 && + stopProfilerTimerIfRunningAndRecordDelta(workInProgress, !0); a: { var root = root$jscomp$0, - returnFiber = erroredWork.return, - sourceFiber = erroredWork, + returnFiber = workInProgress.return, + sourceFiber = workInProgress, value = thrownValue; - thrownValue = workInProgressRootRenderLanes; + thrownValue = renderExpirationTime$1; sourceFiber.effectTag |= 2048; sourceFiber.firstEffect = sourceFiber.lastEffect = null; if ( @@ -6250,27 +5907,27 @@ function handleError(root$jscomp$0, thrownValue) { "object" === typeof value && "function" === typeof value.then ) { - var wakeable = value; + var thenable = value; if (0 === (sourceFiber.mode & 2)) { var currentSource = sourceFiber.alternate; currentSource ? ((sourceFiber.updateQueue = currentSource.updateQueue), (sourceFiber.memoizedState = currentSource.memoizedState), - (sourceFiber.lanes = currentSource.lanes)) + (sourceFiber.expirationTime = currentSource.expirationTime)) : ((sourceFiber.updateQueue = null), (sourceFiber.memoizedState = null)); } var hasInvisibleParentBoundary = 0 !== (suspenseStackCursor.current & 1), - workInProgress$77 = returnFiber; + _workInProgress = returnFiber; do { var JSCompiler_temp; - if ((JSCompiler_temp = 13 === workInProgress$77.tag)) { - var nextState = workInProgress$77.memoizedState; + if ((JSCompiler_temp = 13 === _workInProgress.tag)) { + var nextState = _workInProgress.memoizedState; if (null !== nextState) JSCompiler_temp = null !== nextState.dehydrated ? !0 : !1; else { - var props = workInProgress$77.memoizedProps; + var props = _workInProgress.memoizedProps; JSCompiler_temp = void 0 === props.fallback ? !1 @@ -6282,24 +5939,23 @@ function handleError(root$jscomp$0, thrownValue) { } } if (JSCompiler_temp) { - var wakeables = workInProgress$77.updateQueue; - if (null === wakeables) { + var thenables = _workInProgress.updateQueue; + if (null === thenables) { var updateQueue = new Set(); - updateQueue.add(wakeable); - workInProgress$77.updateQueue = updateQueue; - } else wakeables.add(wakeable); - if (0 === (workInProgress$77.mode & 2)) { - workInProgress$77.effectTag |= 64; - sourceFiber.effectTag |= 16384; + updateQueue.add(thenable); + _workInProgress.updateQueue = updateQueue; + } else thenables.add(thenable); + if (0 === (_workInProgress.mode & 2)) { + _workInProgress.effectTag |= 64; sourceFiber.effectTag &= -2981; if (1 === sourceFiber.tag) if (null === sourceFiber.alternate) sourceFiber.tag = 17; else { - var update = createUpdate(-1, 1, null); + var update = createUpdate(1073741823, null); update.tag = 2; enqueueUpdate(sourceFiber, update); } - sourceFiber.lanes |= 1; + sourceFiber.expirationTime = 1073741823; break a; } value = void 0; @@ -6308,90 +5964,86 @@ function handleError(root$jscomp$0, thrownValue) { null === pingCache ? ((pingCache = root.pingCache = new PossiblyWeakMap()), (value = new Set()), - pingCache.set(wakeable, value)) - : ((value = pingCache.get(wakeable)), + pingCache.set(thenable, value)) + : ((value = pingCache.get(thenable)), void 0 === value && - ((value = new Set()), pingCache.set(wakeable, value))); + ((value = new Set()), pingCache.set(thenable, value))); if (!value.has(sourceFiber)) { value.add(sourceFiber); var ping = pingSuspendedRoot.bind( null, root, - wakeable, + thenable, sourceFiber ); - wakeable.then(ping, ping); + thenable.then(ping, ping); } - workInProgress$77.effectTag |= 4096; - workInProgress$77.lanes = thrownValue; + _workInProgress.effectTag |= 4096; + _workInProgress.expirationTime = thrownValue; break a; } - workInProgress$77 = workInProgress$77.return; - } while (null !== workInProgress$77); + _workInProgress = _workInProgress.return; + } while (null !== _workInProgress); value = Error( (getComponentName(sourceFiber.type) || "A React component") + - " suspended while rendering, but no fallback UI was specified.\n\nAdd a component higher in the tree to provide a loading indicator or placeholder to display." + " 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) ); } - 5 !== workInProgressRootExitStatus && - (workInProgressRootExitStatus = 2); + workInProgressRootExitStatus !== RootCompleted && + (workInProgressRootExitStatus = RootErrored); value = createCapturedValue(value, sourceFiber); - workInProgress$77 = returnFiber; + _workInProgress = returnFiber; do { - switch (workInProgress$77.tag) { + switch (_workInProgress.tag) { case 3: - root = value; - workInProgress$77.effectTag |= 4096; - thrownValue &= -thrownValue; - workInProgress$77.lanes |= thrownValue; - var update$78 = createRootErrorUpdate( - workInProgress$77, - root, + thenable = value; + _workInProgress.effectTag |= 4096; + _workInProgress.expirationTime = thrownValue; + var _update = createRootErrorUpdate( + _workInProgress, + thenable, thrownValue ); - enqueueCapturedUpdate(workInProgress$77, update$78); + enqueueCapturedUpdate(_workInProgress, _update); break a; case 1: - root = value; - var ctor = workInProgress$77.type, - instance = workInProgress$77.stateNode; + thenable = value; + var ctor = _workInProgress.type, + instance = _workInProgress.stateNode; if ( - 0 === (workInProgress$77.effectTag & 64) && + 0 === (_workInProgress.effectTag & 64) && ("function" === typeof ctor.getDerivedStateFromError || (null !== instance && "function" === typeof instance.componentDidCatch && (null === legacyErrorBoundariesThatAlreadyFailed || !legacyErrorBoundariesThatAlreadyFailed.has(instance)))) ) { - workInProgress$77.effectTag |= 4096; - thrownValue &= -thrownValue; - workInProgress$77.lanes |= thrownValue; - var update$81 = createClassErrorUpdate( - workInProgress$77, - root, + _workInProgress.effectTag |= 4096; + _workInProgress.expirationTime = thrownValue; + var _update2 = createClassErrorUpdate( + _workInProgress, + thenable, thrownValue ); - enqueueCapturedUpdate(workInProgress$77, update$81); + enqueueCapturedUpdate(_workInProgress, _update2); break a; } } - workInProgress$77 = workInProgress$77.return; - } while (null !== workInProgress$77); + _workInProgress = _workInProgress.return; + } while (null !== _workInProgress); } - completeUnitOfWork(erroredWork); + workInProgress = completeUnitOfWork(workInProgress); } catch (yetAnotherThrownValue) { thrownValue = yetAnotherThrownValue; - workInProgress === erroredWork && - null !== erroredWork && - (workInProgress = erroredWork = erroredWork.return); continue; } break; } while (1); } function pushDispatcher() { - var prevDispatcher = ReactCurrentDispatcher$2.current; - ReactCurrentDispatcher$2.current = ContextOnlyDispatcher; + var prevDispatcher = ReactCurrentDispatcher$1.current; + ReactCurrentDispatcher$1.current = ContextOnlyDispatcher; return null === prevDispatcher ? ContextOnlyDispatcher : prevDispatcher; } function pushInteractions(root) { @@ -6399,20 +6051,28 @@ function pushInteractions(root) { tracing.__interactionsRef.current = root.memoizedInteractions; return prevInteractions; } -function markRenderEventTimeAndConfig(eventTime, suspenseConfig) { +function markRenderEventTimeAndConfig(expirationTime, suspenseConfig) { + expirationTime < workInProgressRootLatestProcessedExpirationTime && + 2 < expirationTime && + (workInProgressRootLatestProcessedExpirationTime = expirationTime); null !== suspenseConfig && - ((eventTime += suspenseConfig.timeoutMs | 0 || 5e3), - eventTime > workInProgressRootLatestSuspenseTimeout && - ((workInProgressRootLatestSuspenseTimeout = eventTime), - (workInProgressRootCanSuspendUsingConfig = suspenseConfig))); + expirationTime < workInProgressRootLatestSuspenseTimeout && + 2 < expirationTime && + ((workInProgressRootLatestSuspenseTimeout = expirationTime), + (workInProgressRootCanSuspendUsingConfig = suspenseConfig)); } -function renderRootSync(root, lanes) { +function markUnprocessedUpdateTime(expirationTime) { + expirationTime > workInProgressRootNextUnprocessedUpdateTime && + (workInProgressRootNextUnprocessedUpdateTime = expirationTime); +} +function renderRootSync(root, expirationTime) { var prevExecutionContext = executionContext; - executionContext |= 16; + executionContext |= RenderContext; var prevDispatcher = pushDispatcher(); - if (workInProgressRoot !== root || workInProgressRootRenderLanes !== lanes) - prepareFreshStack(root, lanes), startWorkOnPendingInteractions(root, lanes); - lanes = pushInteractions(root); + if (root !== workInProgressRoot || expirationTime !== renderExpirationTime$1) + prepareFreshStack(root, expirationTime), + startWorkOnPendingInteractions(root, expirationTime); + expirationTime = pushInteractions(root); do try { workLoopSync(); @@ -6422,197 +6082,187 @@ function renderRootSync(root, lanes) { } while (1); resetContextDependencies(); - tracing.__interactionsRef.current = lanes; + tracing.__interactionsRef.current = expirationTime; executionContext = prevExecutionContext; - ReactCurrentDispatcher$2.current = prevDispatcher; + ReactCurrentDispatcher$1.current = prevDispatcher; if (null !== workInProgress) throw Error( "Cannot commit an incomplete root. This error is likely caused by a bug in React. Please file an issue." ); workInProgressRoot = null; - workInProgressRootRenderLanes = 0; return workInProgressRootExitStatus; } function workLoopSync() { - for (; null !== workInProgress; ) performUnitOfWork(workInProgress); + for (; null !== workInProgress; ) + workInProgress = performUnitOfWork(workInProgress); } function workLoopConcurrent() { for (; null !== workInProgress && !Scheduler_shouldYield(); ) - performUnitOfWork(workInProgress); + workInProgress = performUnitOfWork(workInProgress); } function performUnitOfWork(unitOfWork) { var current = unitOfWork.alternate; 0 !== (unitOfWork.mode & 8) ? ((profilerStartTime = now$1()), 0 > unitOfWork.actualStartTime && (unitOfWork.actualStartTime = now$1()), - (current = beginWork$1(current, unitOfWork, subtreeRenderLanes)), + (current = beginWork$1(current, unitOfWork, renderExpirationTime$1)), stopProfilerTimerIfRunningAndRecordDelta(unitOfWork, !0)) - : (current = beginWork$1(current, unitOfWork, subtreeRenderLanes)); + : (current = beginWork$1(current, unitOfWork, renderExpirationTime$1)); unitOfWork.memoizedProps = unitOfWork.pendingProps; - null === current - ? completeUnitOfWork(unitOfWork) - : (workInProgress = current); + null === current && (current = completeUnitOfWork(unitOfWork)); ReactCurrentOwner$2.current = null; + return current; } function completeUnitOfWork(unitOfWork) { - var completedWork = unitOfWork; + workInProgress = unitOfWork; do { - var current = completedWork.alternate; - unitOfWork = completedWork.return; - if (0 === (completedWork.effectTag & 2048)) { - if (0 === (completedWork.mode & 8)) - current = completeWork(current, completedWork, subtreeRenderLanes); + var current = workInProgress.alternate; + unitOfWork = workInProgress.return; + if (0 === (workInProgress.effectTag & 2048)) { + if (0 === (workInProgress.mode & 8)) + current = completeWork(current, workInProgress, renderExpirationTime$1); else { - var fiber = completedWork; + var fiber = workInProgress; profilerStartTime = now$1(); 0 > fiber.actualStartTime && (fiber.actualStartTime = now$1()); - current = completeWork(current, completedWork, subtreeRenderLanes); - stopProfilerTimerIfRunningAndRecordDelta(completedWork, !1); + current = completeWork(current, workInProgress, renderExpirationTime$1); + stopProfilerTimerIfRunningAndRecordDelta(workInProgress, !1); } - if (null !== current) { - workInProgress = current; - return; - } - current = completedWork; - if ( - (24 !== current.tag && 23 !== current.tag) || - null === current.memoizedState || - 0 !== (subtreeRenderLanes & 1073741824) || - 0 === (current.mode & 4) - ) { - fiber = 0; - if (0 !== (current.mode & 8)) { + fiber = workInProgress; + if (1 === renderExpirationTime$1 || 1 !== fiber.childExpirationTime) { + var newChildExpirationTime = 0; + if (0 !== (fiber.mode & 8)) { for ( - var actualDuration = current.actualDuration, - treeBaseDuration = current.selfBaseDuration, + var actualDuration = fiber.actualDuration, + treeBaseDuration = fiber.selfBaseDuration, shouldBubbleActualDurations = - null === current.alternate || - current.child !== current.alternate.child, - child = current.child; + null === fiber.alternate || + fiber.child !== fiber.alternate.child, + child = fiber.child; null !== child; - ) - (fiber |= child.lanes | child.childLanes), - shouldBubbleActualDurations && - (actualDuration += child.actualDuration), - (treeBaseDuration += child.treeBaseDuration), - (child = child.sibling); - 13 === current.tag && - null !== current.memoizedState && - ((shouldBubbleActualDurations = current.child), - null !== shouldBubbleActualDurations && - (treeBaseDuration -= - shouldBubbleActualDurations.treeBaseDuration)); - current.actualDuration = actualDuration; - current.treeBaseDuration = treeBaseDuration; + ) { + var childUpdateExpirationTime = child.expirationTime, + childChildExpirationTime = child.childExpirationTime; + childUpdateExpirationTime > newChildExpirationTime && + (newChildExpirationTime = childUpdateExpirationTime); + childChildExpirationTime > newChildExpirationTime && + (newChildExpirationTime = childChildExpirationTime); + shouldBubbleActualDurations && + (actualDuration += child.actualDuration); + treeBaseDuration += child.treeBaseDuration; + child = child.sibling; + } + fiber.actualDuration = actualDuration; + fiber.treeBaseDuration = treeBaseDuration; } else - for (actualDuration = current.child; null !== actualDuration; ) - (fiber |= actualDuration.lanes | actualDuration.childLanes), + for (actualDuration = fiber.child; null !== actualDuration; ) + (treeBaseDuration = actualDuration.expirationTime), + (shouldBubbleActualDurations = + actualDuration.childExpirationTime), + treeBaseDuration > newChildExpirationTime && + (newChildExpirationTime = treeBaseDuration), + shouldBubbleActualDurations > newChildExpirationTime && + (newChildExpirationTime = shouldBubbleActualDurations), (actualDuration = actualDuration.sibling); - current.childLanes = fiber; + fiber.childExpirationTime = newChildExpirationTime; } + if (null !== current) return current; null !== unitOfWork && 0 === (unitOfWork.effectTag & 2048) && (null === unitOfWork.firstEffect && - (unitOfWork.firstEffect = completedWork.firstEffect), - null !== completedWork.lastEffect && + (unitOfWork.firstEffect = workInProgress.firstEffect), + null !== workInProgress.lastEffect && (null !== unitOfWork.lastEffect && - (unitOfWork.lastEffect.nextEffect = completedWork.firstEffect), - (unitOfWork.lastEffect = completedWork.lastEffect)), - 1 < completedWork.effectTag && + (unitOfWork.lastEffect.nextEffect = workInProgress.firstEffect), + (unitOfWork.lastEffect = workInProgress.lastEffect)), + 1 < workInProgress.effectTag && (null !== unitOfWork.lastEffect - ? (unitOfWork.lastEffect.nextEffect = completedWork) - : (unitOfWork.firstEffect = completedWork), - (unitOfWork.lastEffect = completedWork))); + ? (unitOfWork.lastEffect.nextEffect = workInProgress) + : (unitOfWork.firstEffect = workInProgress), + (unitOfWork.lastEffect = workInProgress))); } else { - current = unwindWork(completedWork); - if (null !== current) { - current.effectTag &= 2047; - workInProgress = current; - return; - } - if (0 !== (completedWork.mode & 8)) { - stopProfilerTimerIfRunningAndRecordDelta(completedWork, !1); - current = completedWork.actualDuration; - for (fiber = completedWork.child; null !== fiber; ) - (current += fiber.actualDuration), (fiber = fiber.sibling); - completedWork.actualDuration = current; + current = unwindWork(workInProgress); + if (0 !== (workInProgress.mode & 8)) { + stopProfilerTimerIfRunningAndRecordDelta(workInProgress, !1); + fiber = workInProgress.actualDuration; + for ( + newChildExpirationTime = workInProgress.child; + null !== newChildExpirationTime; + + ) + (fiber += newChildExpirationTime.actualDuration), + (newChildExpirationTime = newChildExpirationTime.sibling); + workInProgress.actualDuration = fiber; } + if (null !== current) return (current.effectTag &= 2047), current; null !== unitOfWork && ((unitOfWork.firstEffect = unitOfWork.lastEffect = null), (unitOfWork.effectTag |= 2048)); } - completedWork = completedWork.sibling; - if (null !== completedWork) { - workInProgress = completedWork; - return; - } - workInProgress = completedWork = unitOfWork; - } while (null !== completedWork); - 0 === workInProgressRootExitStatus && (workInProgressRootExitStatus = 5); + current = workInProgress.sibling; + if (null !== current) return current; + workInProgress = unitOfWork; + } while (null !== workInProgress); + workInProgressRootExitStatus === RootIncomplete && + (workInProgressRootExitStatus = RootCompleted); + return null; +} +function getRemainingExpirationTime(fiber) { + var updateExpirationTime = fiber.expirationTime; + fiber = fiber.childExpirationTime; + return updateExpirationTime > fiber ? updateExpirationTime : fiber; } function commitRoot(root) { var renderPriorityLevel = getCurrentPriorityLevel(); runWithPriority(99, commitRootImpl.bind(null, root, renderPriorityLevel)); return null; } -function commitRootImpl(root, renderPriorityLevel) { +function commitRootImpl(root$jscomp$1, renderPriorityLevel$jscomp$1) { do flushPassiveEffects(); while (null !== rootWithPendingPassiveEffects); - if (0 !== (executionContext & 48)) + if ((executionContext & (RenderContext | CommitContext)) !== NoContext) throw Error("Should not already be working."); - var finishedWork = root.finishedWork, - lanes = root.finishedLanes; + var finishedWork = root$jscomp$1.finishedWork, + expirationTime = root$jscomp$1.finishedExpirationTime; if (null === finishedWork) return null; - root.finishedWork = null; - root.finishedLanes = 0; - if (finishedWork === root.current) + root$jscomp$1.finishedWork = null; + root$jscomp$1.finishedExpirationTime = 0; + if (finishedWork === root$jscomp$1.current) throw Error( "Cannot commit the same tree as before. This error is likely caused by a bug in React. Please file an issue." ); - root.callbackNode = null; - var remainingLanes = finishedWork.lanes | finishedWork.childLanes, - remainingLanes$jscomp$0 = remainingLanes, - noLongerPendingLanes = root.pendingLanes & ~remainingLanes$jscomp$0; - root.pendingLanes = remainingLanes$jscomp$0; - root.suspendedLanes = 0; - root.pingedLanes = 0; - root.expiredLanes &= remainingLanes$jscomp$0; - root.mutableReadLanes &= remainingLanes$jscomp$0; - root.entangledLanes &= remainingLanes$jscomp$0; - remainingLanes$jscomp$0 = root.entanglements; - for ( - var eventTimes = root.eventTimes, expirationTimes = root.expirationTimes; - 0 < noLongerPendingLanes; - - ) { - var index$11 = 31 - clz32(noLongerPendingLanes), - lane = 1 << index$11; - remainingLanes$jscomp$0[index$11] = 0; - eventTimes[index$11] = -1; - expirationTimes[index$11] = -1; - noLongerPendingLanes &= ~lane; - } - null !== rootsWithPendingDiscreteUpdates && - 0 === (remainingLanes & 24) && - rootsWithPendingDiscreteUpdates.has(root) && - rootsWithPendingDiscreteUpdates.delete(root); - root === workInProgressRoot && + root$jscomp$1.callbackNode = null; + root$jscomp$1.callbackExpirationTime = 0; + root$jscomp$1.callbackPriority = 90; + root$jscomp$1.nextKnownPendingLevel = 0; + var remainingExpirationTimeBeforeCommit = getRemainingExpirationTime( + finishedWork + ); + root$jscomp$1.firstPendingTime = remainingExpirationTimeBeforeCommit; + expirationTime <= root$jscomp$1.lastSuspendedTime + ? (root$jscomp$1.firstSuspendedTime = root$jscomp$1.lastSuspendedTime = root$jscomp$1.nextKnownPendingLevel = 0) + : expirationTime <= root$jscomp$1.firstSuspendedTime && + (root$jscomp$1.firstSuspendedTime = expirationTime - 1); + expirationTime <= root$jscomp$1.lastPingedTime && + (root$jscomp$1.lastPingedTime = 0); + expirationTime <= root$jscomp$1.lastExpiredTime && + (root$jscomp$1.lastExpiredTime = 0); + root$jscomp$1 === workInProgressRoot && ((workInProgress = workInProgressRoot = null), - (workInProgressRootRenderLanes = 0)); + (renderExpirationTime$1 = 0)); 1 < finishedWork.effectTag ? null !== finishedWork.lastEffect ? ((finishedWork.lastEffect.nextEffect = finishedWork), - (remainingLanes = finishedWork.firstEffect)) - : (remainingLanes = finishedWork) - : (remainingLanes = finishedWork.firstEffect); - if (null !== remainingLanes) { - remainingLanes$jscomp$0 = executionContext; - executionContext |= 32; - eventTimes = pushInteractions(root); - focusedInstanceHandle = ReactCurrentOwner$2.current = null; - shouldFireAfterActiveInstanceBlur = !1; - nextEffect = remainingLanes; + (remainingExpirationTimeBeforeCommit = finishedWork.firstEffect)) + : (remainingExpirationTimeBeforeCommit = finishedWork) + : (remainingExpirationTimeBeforeCommit = finishedWork.firstEffect); + if (null !== remainingExpirationTimeBeforeCommit) { + var prevExecutionContext = executionContext; + executionContext |= CommitContext; + var prevInteractions = pushInteractions(root$jscomp$1); + ReactCurrentOwner$2.current = null; + nextEffect = remainingExpirationTimeBeforeCommit; do try { commitBeforeMutationEffects(); @@ -6622,12 +6272,16 @@ function commitRootImpl(root, renderPriorityLevel) { nextEffect = nextEffect.nextEffect; } while (null !== nextEffect); - focusedInstanceHandle = null; commitTime = now$1(); - nextEffect = remainingLanes; + nextEffect = remainingExpirationTimeBeforeCommit; do try { - for (; null !== nextEffect; ) { + for ( + var root = root$jscomp$1, + renderPriorityLevel = renderPriorityLevel$jscomp$1; + null !== nextEffect; + + ) { var effectTag = nextEffect.effectTag; if (effectTag & 128) { var current = nextEffect.alternate; @@ -6658,105 +6312,49 @@ function commitRootImpl(root, renderPriorityLevel) { commitWork(nextEffect.alternate, nextEffect); break; case 8: - expirationTimes = nextEffect; - a: for (index$11 = noLongerPendingLanes = expirationTimes; ; ) { - lane = index$11; + var current$jscomp$0 = nextEffect; + a: for ( + var finishedRoot = root, + root$jscomp$0 = current$jscomp$0, + renderPriorityLevel$jscomp$0 = renderPriorityLevel, + node = root$jscomp$0; + ; + + ) if ( - injectedHook && - "function" === typeof injectedHook.onCommitFiberUnmount + (commitUnmount( + finishedRoot, + node, + renderPriorityLevel$jscomp$0 + ), + null !== node.child) ) - try { - injectedHook.onCommitFiberUnmount(rendererID, lane); - } catch (err) {} - switch (lane.tag) { - case 0: - case 11: - case 14: - case 15: - case 22: - var updateQueue = lane.updateQueue; - if (null !== updateQueue) { - var lastEffect = updateQueue.lastEffect; - if (null !== lastEffect) { - var firstEffect = lastEffect.next, - effect = firstEffect; - do { - var _effect2 = effect, - destroy = _effect2.destroy, - tag = _effect2.tag; - if (void 0 !== destroy) - if (0 !== (tag & 4)) - enqueuePendingPassiveHookEffectUnmount( - lane, - effect - ); - else { - _effect2 = lane; - try { - destroy(); - } catch (error) { - captureCommitPhaseError(_effect2, error); - } - } - effect = effect.next; - } while (effect !== firstEffect); - } - } - break; - case 1: - safelyDetachRef(lane); - var instance = lane.stateNode; - if ("function" === typeof instance.componentWillUnmount) - try { - (effect = lane), - (_effect2 = instance), - (_effect2.props = effect.memoizedProps), - (_effect2.state = effect.memoizedState), - _effect2.componentWillUnmount(); - } catch (unmountError) { - captureCommitPhaseError(lane, unmountError); - } - break; - case 5: - safelyDetachRef(lane); - break; - case 4: - createChildNodeSet(lane.stateNode.containerInfo); - } - if (null !== index$11.child) - (index$11.child.return = index$11), - (index$11 = index$11.child); + (node.child.return = node), (node = node.child); else { - if (index$11 === noLongerPendingLanes) break; - for (; null === index$11.sibling; ) { - if ( - null === index$11.return || - index$11.return === noLongerPendingLanes - ) + if (node === root$jscomp$0) break; + for (; null === node.sibling; ) { + if (null === node.return || node.return === root$jscomp$0) break a; - index$11 = index$11.return; + node = node.return; } - index$11.sibling.return = index$11.return; - index$11 = index$11.sibling; + node.sibling.return = node.return; + node = node.sibling; } - } - var alternate = expirationTimes.alternate; - detachFiberMutation(expirationTimes); - null !== alternate && detachFiberMutation(alternate); + detachFiber(current$jscomp$0); } nextEffect = nextEffect.nextEffect; } - } catch (error$95) { + } catch (error) { if (null === nextEffect) throw Error("Should be working on an effect."); - captureCommitPhaseError(nextEffect, error$95); + captureCommitPhaseError(nextEffect, error); nextEffect = nextEffect.nextEffect; } while (null !== nextEffect); - root.current = finishedWork; - nextEffect = remainingLanes; + root$jscomp$1.current = finishedWork; + nextEffect = remainingExpirationTimeBeforeCommit; do try { - for (effectTag = root; null !== nextEffect; ) { + for (effectTag = root$jscomp$1; null !== nextEffect; ) { var effectTag$jscomp$0 = nextEffect.effectTag; effectTag$jscomp$0 & 36 && commitLifeCycles(effectTag, nextEffect.alternate, nextEffect); @@ -6764,13 +6362,13 @@ function commitRootImpl(root, renderPriorityLevel) { current = void 0; var ref = nextEffect.ref; if (null !== ref) { - var instance$jscomp$0 = nextEffect.stateNode; + var instance = nextEffect.stateNode; switch (nextEffect.tag) { case 5: - current = instance$jscomp$0.canonical; + current = instance.canonical; break; default: - current = instance$jscomp$0; + current = instance; } "function" === typeof ref ? ref(current) @@ -6779,86 +6377,72 @@ function commitRootImpl(root, renderPriorityLevel) { } nextEffect = nextEffect.nextEffect; } - } catch (error$96) { + } catch (error) { if (null === nextEffect) throw Error("Should be working on an effect."); - captureCommitPhaseError(nextEffect, error$96); + captureCommitPhaseError(nextEffect, error); nextEffect = nextEffect.nextEffect; } while (null !== nextEffect); nextEffect = null; requestPaint(); - tracing.__interactionsRef.current = eventTimes; - executionContext = remainingLanes$jscomp$0; - } else (root.current = finishedWork), (commitTime = now$1()); + tracing.__interactionsRef.current = prevInteractions; + executionContext = prevExecutionContext; + } else (root$jscomp$1.current = finishedWork), (commitTime = now$1()); if ((effectTag$jscomp$0 = rootDoesHavePassiveEffects)) (rootDoesHavePassiveEffects = !1), - (rootWithPendingPassiveEffects = root), - (pendingPassiveEffectsLanes = lanes), - (pendingPassiveEffectsRenderPriority = renderPriorityLevel); + (rootWithPendingPassiveEffects = root$jscomp$1), + (pendingPassiveEffectsExpirationTime = expirationTime), + (pendingPassiveEffectsRenderPriority = renderPriorityLevel$jscomp$1); else - for (nextEffect = remainingLanes; null !== nextEffect; ) - (ref = nextEffect.nextEffect), + for ( + nextEffect = remainingExpirationTimeBeforeCommit; + null !== nextEffect; + + ) + (renderPriorityLevel$jscomp$1 = nextEffect.nextEffect), (nextEffect.nextEffect = null), - nextEffect.effectTag & 8 && (nextEffect.sibling = null), - (nextEffect = ref); - remainingLanes = root.pendingLanes; - if (0 !== remainingLanes) { + (nextEffect = renderPriorityLevel$jscomp$1); + renderPriorityLevel$jscomp$1 = root$jscomp$1.firstPendingTime; + if (0 !== renderPriorityLevel$jscomp$1) { if (null !== spawnedWorkDuringRender) for ( - ref = spawnedWorkDuringRender, + remainingExpirationTimeBeforeCommit = spawnedWorkDuringRender, spawnedWorkDuringRender = null, - instance$jscomp$0 = 0; - instance$jscomp$0 < ref.length; - instance$jscomp$0++ + ref = 0; + ref < remainingExpirationTimeBeforeCommit.length; + ref++ ) scheduleInteractions( - root, - ref[instance$jscomp$0], - root.memoizedInteractions + root$jscomp$1, + remainingExpirationTimeBeforeCommit[ref], + root$jscomp$1.memoizedInteractions ); - schedulePendingInteractions(root, remainingLanes); + schedulePendingInteractions(root$jscomp$1, renderPriorityLevel$jscomp$1); } else legacyErrorBoundariesThatAlreadyFailed = null; - effectTag$jscomp$0 || finishPendingInteractions(root, lanes); - 1 === remainingLanes - ? root === rootWithNestedUpdates + effectTag$jscomp$0 || + finishPendingInteractions(root$jscomp$1, expirationTime); + 1073741823 === renderPriorityLevel$jscomp$1 + ? root$jscomp$1 === rootWithNestedUpdates ? nestedUpdateCount++ - : ((nestedUpdateCount = 0), (rootWithNestedUpdates = root)) + : ((nestedUpdateCount = 0), (rootWithNestedUpdates = root$jscomp$1)) : (nestedUpdateCount = 0); - finishedWork = finishedWork.stateNode; - if (injectedHook && "function" === typeof injectedHook.onCommitFiberRoot) - try { - injectedHook.onCommitFiberRoot( - rendererID, - finishedWork, - renderPriorityLevel, - 64 === (finishedWork.current.effectTag & 64) - ); - } catch (err) {} - ensureRootIsScheduled(root, now()); + "function" === typeof onCommitFiberRoot && + onCommitFiberRoot(finishedWork.stateNode, expirationTime); + ensureRootIsScheduled(root$jscomp$1); if (hasUncaughtError) throw ((hasUncaughtError = !1), - (root = firstUncaughtError), + (root$jscomp$1 = firstUncaughtError), (firstUncaughtError = null), - root); - if (0 !== (executionContext & 8)) return null; + root$jscomp$1); + if ((executionContext & LegacyUnbatchedContext) !== NoContext) return null; flushSyncCallbackQueue(); return null; } function commitBeforeMutationEffects() { for (; null !== nextEffect; ) { - var current = nextEffect.alternate; - shouldFireAfterActiveInstanceBlur || - null === focusedInstanceHandle || - (0 !== (nextEffect.effectTag & 8) - ? doesFiberContain(nextEffect, focusedInstanceHandle) && - (shouldFireAfterActiveInstanceBlur = !0) - : 13 === nextEffect.tag && - isSuspenseBoundaryBeingHidden(current, nextEffect) && - doesFiberContain(nextEffect, focusedInstanceHandle) && - (shouldFireAfterActiveInstanceBlur = !0)); var effectTag = nextEffect.effectTag; 0 !== (effectTag & 256) && - commitBeforeMutationLifeCycles(current, nextEffect); + commitBeforeMutationLifeCycles(nextEffect.alternate, nextEffect); 0 === (effectTag & 512) || rootDoesHavePassiveEffects || ((rootDoesHavePassiveEffects = !0), @@ -6876,89 +6460,58 @@ function flushPassiveEffects() { ? 97 : pendingPassiveEffectsRenderPriority; pendingPassiveEffectsRenderPriority = 90; - schedulerPriorityToLanePriority(priorityLevel); return runWithPriority(priorityLevel, flushPassiveEffectsImpl); } - return !1; -} -function enqueuePendingPassiveHookEffectMount(fiber, effect) { - pendingPassiveHookEffectsMount.push(effect, fiber); - rootDoesHavePassiveEffects || - ((rootDoesHavePassiveEffects = !0), - scheduleCallback(97, function() { - flushPassiveEffects(); - return null; - })); -} -function enqueuePendingPassiveHookEffectUnmount(fiber, effect) { - pendingPassiveHookEffectsUnmount.push(effect, fiber); - rootDoesHavePassiveEffects || - ((rootDoesHavePassiveEffects = !0), - scheduleCallback(97, function() { - flushPassiveEffects(); - return null; - })); } function flushPassiveEffectsImpl() { if (null === rootWithPendingPassiveEffects) return !1; var root = rootWithPendingPassiveEffects, - lanes = pendingPassiveEffectsLanes; + expirationTime = pendingPassiveEffectsExpirationTime; rootWithPendingPassiveEffects = null; - pendingPassiveEffectsLanes = 0; - if (0 !== (executionContext & 48)) + pendingPassiveEffectsExpirationTime = 0; + if ((executionContext & (RenderContext | CommitContext)) !== NoContext) throw Error("Cannot flush passive effects while already rendering."); var prevExecutionContext = executionContext; - executionContext |= 32; - var prevInteractions = pushInteractions(root), - unmountEffects = pendingPassiveHookEffectsUnmount; - pendingPassiveHookEffectsUnmount = []; - for (var i = 0; i < unmountEffects.length; i += 2) { - var effect$101 = unmountEffects[i], - fiber = unmountEffects[i + 1], - destroy = effect$101.destroy; - effect$101.destroy = void 0; - if ("function" === typeof destroy) - try { - destroy(); - } catch (error) { - if (null === fiber) throw Error("Should be working on an effect."); - captureCommitPhaseError(fiber, error); - } - } - unmountEffects = pendingPassiveHookEffectsMount; - pendingPassiveHookEffectsMount = []; - for (i = 0; i < unmountEffects.length; i += 2) { - effect$101 = unmountEffects[i]; - fiber = unmountEffects[i + 1]; + executionContext |= CommitContext; + for ( + var prevInteractions = pushInteractions(root), + _effect2 = root.current.firstEffect; + null !== _effect2; + + ) { try { - var create$105 = effect$101.create; - effect$101.destroy = create$105(); - } catch (error$106) { - if (null === fiber) throw Error("Should be working on an effect."); - captureCommitPhaseError(fiber, error$106); + var finishedWork = _effect2; + if (0 !== (finishedWork.effectTag & 512)) + switch (finishedWork.tag) { + case 0: + case 11: + case 15: + case 22: + commitHookEffectListUnmount(5, finishedWork), + commitHookEffectListMount(5, finishedWork); + } + } catch (error) { + if (null === _effect2) throw Error("Should be working on an effect."); + captureCommitPhaseError(_effect2, error); } + finishedWork = _effect2.nextEffect; + _effect2.nextEffect = null; + _effect2 = finishedWork; } - for (create$105 = root.current.firstEffect; null !== create$105; ) - (unmountEffects = create$105.nextEffect), - (create$105.nextEffect = null), - create$105.effectTag & 8 && (create$105.sibling = null), - (create$105 = unmountEffects); tracing.__interactionsRef.current = prevInteractions; - finishPendingInteractions(root, lanes); + finishPendingInteractions(root, expirationTime); executionContext = prevExecutionContext; flushSyncCallbackQueue(); return !0; } function captureCommitPhaseErrorOnRoot(rootFiber, sourceFiber, error) { sourceFiber = createCapturedValue(error, sourceFiber); - sourceFiber = createRootErrorUpdate(rootFiber, sourceFiber, 1); + sourceFiber = createRootErrorUpdate(rootFiber, sourceFiber, 1073741823); enqueueUpdate(rootFiber, sourceFiber); - sourceFiber = requestEventTime(); - rootFiber = markUpdateLaneFromFiberToRoot(rootFiber, 1); + rootFiber = markUpdateTimeFromFiberToRoot(rootFiber, 1073741823); null !== rootFiber && - (markRootUpdated(rootFiber, 1, sourceFiber), - ensureRootIsScheduled(rootFiber, sourceFiber), - schedulePendingInteractions(rootFiber, 1)); + (ensureRootIsScheduled(rootFiber), + schedulePendingInteractions(rootFiber, 1073741823)); } function captureCommitPhaseError(sourceFiber, error) { if (3 === sourceFiber.tag) @@ -6977,166 +6530,156 @@ function captureCommitPhaseError(sourceFiber, error) { !legacyErrorBoundariesThatAlreadyFailed.has(instance))) ) { sourceFiber = createCapturedValue(error, sourceFiber); - sourceFiber = createClassErrorUpdate(fiber, sourceFiber, 1); + sourceFiber = createClassErrorUpdate(fiber, sourceFiber, 1073741823); enqueueUpdate(fiber, sourceFiber); - sourceFiber = requestEventTime(); - fiber = markUpdateLaneFromFiberToRoot(fiber, 1); + fiber = markUpdateTimeFromFiberToRoot(fiber, 1073741823); null !== fiber && - (markRootUpdated(fiber, 1, sourceFiber), - ensureRootIsScheduled(fiber, sourceFiber), - schedulePendingInteractions(fiber, 1)); + (ensureRootIsScheduled(fiber), + schedulePendingInteractions(fiber, 1073741823)); break; } } fiber = fiber.return; } } -function pingSuspendedRoot(root, wakeable, pingedLanes) { +function pingSuspendedRoot(root, thenable, suspendedTime) { var pingCache = root.pingCache; - null !== pingCache && pingCache.delete(wakeable); - wakeable = requestEventTime(); - root.pingedLanes |= root.suspendedLanes & pingedLanes; - workInProgressRoot === root && - (workInProgressRootRenderLanes & pingedLanes) === pingedLanes && - (4 === workInProgressRootExitStatus || - (3 === workInProgressRootExitStatus && - (workInProgressRootRenderLanes & 62914560) === - workInProgressRootRenderLanes && - 500 > now() - globalMostRecentFallbackTime) - ? prepareFreshStack(root, 0) - : (workInProgressRootPingedLanes |= pingedLanes)); - ensureRootIsScheduled(root, wakeable); - schedulePendingInteractions(root, pingedLanes); + null !== pingCache && pingCache.delete(thenable); + workInProgressRoot === root && renderExpirationTime$1 === suspendedTime + ? workInProgressRootExitStatus === RootSuspendedWithDelay || + (workInProgressRootExitStatus === RootSuspended && + 1073741823 === workInProgressRootLatestProcessedExpirationTime && + now() - globalMostRecentFallbackTime < FALLBACK_THROTTLE_MS) + ? prepareFreshStack(root, renderExpirationTime$1) + : (workInProgressRootHasPendingPing = !0) + : isRootSuspendedAtTime(root, suspendedTime) && + ((thenable = root.lastPingedTime), + (0 !== thenable && thenable < suspendedTime) || + ((root.lastPingedTime = suspendedTime), + ensureRootIsScheduled(root), + schedulePendingInteractions(root, suspendedTime))); } -function resolveRetryWakeable(boundaryFiber, wakeable) { +function resolveRetryThenable(boundaryFiber, thenable) { var retryCache = boundaryFiber.stateNode; - null !== retryCache && retryCache.delete(wakeable); - wakeable = 0; - 0 === wakeable && - ((wakeable = boundaryFiber.mode), - 0 === (wakeable & 2) - ? (wakeable = 1) - : 0 === (wakeable & 4) - ? (wakeable = 99 === getCurrentPriorityLevel() ? 1 : 2) - : (0 === currentEventWipLanes && - (currentEventWipLanes = workInProgressRootIncludedLanes), - (wakeable = getHighestPriorityLane(62914560 & ~currentEventWipLanes)), - 0 === wakeable && (wakeable = 4194304))); - retryCache = requestEventTime(); - boundaryFiber = markUpdateLaneFromFiberToRoot(boundaryFiber, wakeable); + null !== retryCache && retryCache.delete(thenable); + thenable = 0; + 0 === thenable && + ((thenable = requestCurrentTimeForUpdate()), + (thenable = computeExpirationForFiber(thenable, boundaryFiber, null))); + boundaryFiber = markUpdateTimeFromFiberToRoot(boundaryFiber, thenable); null !== boundaryFiber && - (markRootUpdated(boundaryFiber, wakeable, retryCache), - ensureRootIsScheduled(boundaryFiber, retryCache), - schedulePendingInteractions(boundaryFiber, wakeable)); + (ensureRootIsScheduled(boundaryFiber), + schedulePendingInteractions(boundaryFiber, thenable)); } var beginWork$1; -beginWork$1 = function(current, workInProgress, renderLanes) { - var updateLanes = workInProgress.lanes; +beginWork$1 = function(current, workInProgress, renderExpirationTime) { + var updateExpirationTime = workInProgress.expirationTime; if (null !== current) if ( current.memoizedProps !== workInProgress.pendingProps || didPerformWorkStackCursor.current ) didReceiveUpdate = !0; - else if (0 !== (renderLanes & updateLanes)) - didReceiveUpdate = 0 !== (current.effectTag & 16384) ? !0 : !1; else { - didReceiveUpdate = !1; - switch (workInProgress.tag) { - case 3: - pushHostRootContext(workInProgress); - break; - case 5: - pushHostContext(workInProgress); - break; - case 1: - isContextProvider(workInProgress.type) && - pushContextProvider(workInProgress); - break; - case 4: - pushHostContainer( - workInProgress, - workInProgress.stateNode.containerInfo - ); - break; - case 10: - updateLanes = workInProgress.memoizedProps.value; - var context = workInProgress.type._context; - push(valueCursor, context._currentValue2); - context._currentValue2 = updateLanes; - break; - case 12: - 0 !== (renderLanes & workInProgress.childLanes) && - (workInProgress.effectTag |= 4); - updateLanes = workInProgress.stateNode; - updateLanes.effectDuration = 0; - updateLanes.passiveEffectDuration = 0; - break; - case 13: - if (null !== workInProgress.memoizedState) { - if (0 !== (renderLanes & workInProgress.child.childLanes)) - return updateSuspenseComponent( - current, - workInProgress, - renderLanes - ); - push(suspenseStackCursor, suspenseStackCursor.current & 1); - workInProgress = bailoutOnAlreadyFinishedWork( - current, + if (updateExpirationTime < renderExpirationTime) { + didReceiveUpdate = !1; + switch (workInProgress.tag) { + case 3: + pushHostRootContext(workInProgress); + break; + case 5: + pushHostContext(workInProgress); + break; + case 1: + isContextProvider(workInProgress.type) && + pushContextProvider(workInProgress); + break; + case 4: + pushHostContainer( workInProgress, - renderLanes + workInProgress.stateNode.containerInfo ); - return null !== workInProgress ? workInProgress.sibling : null; - } - push(suspenseStackCursor, suspenseStackCursor.current & 1); - break; - case 19: - updateLanes = 0 !== (renderLanes & workInProgress.childLanes); - if (0 !== (current.effectTag & 64)) { - if (updateLanes) - return updateSuspenseListComponent( + break; + case 10: + updateExpirationTime = workInProgress.memoizedProps.value; + var context = workInProgress.type._context; + push(valueCursor, context._currentValue2); + context._currentValue2 = updateExpirationTime; + break; + case 12: + workInProgress.childExpirationTime >= renderExpirationTime && + (workInProgress.effectTag |= 4); + updateExpirationTime = workInProgress.stateNode; + updateExpirationTime.effectDuration = 0; + updateExpirationTime.passiveEffectDuration = 0; + break; + case 13: + if (null !== workInProgress.memoizedState) { + updateExpirationTime = workInProgress.child.childExpirationTime; + if ( + 0 !== updateExpirationTime && + updateExpirationTime >= renderExpirationTime + ) + return updateSuspenseComponent( + current, + workInProgress, + renderExpirationTime + ); + push(suspenseStackCursor, suspenseStackCursor.current & 1); + workInProgress = bailoutOnAlreadyFinishedWork( current, workInProgress, - renderLanes + renderExpirationTime ); - workInProgress.effectTag |= 64; - } - context = workInProgress.memoizedState; - null !== context && - ((context.rendering = null), - (context.tail = null), - (context.lastEffect = null)); - push(suspenseStackCursor, suspenseStackCursor.current); - if (updateLanes) break; - else return null; - case 23: - case 24: - return ( - (workInProgress.lanes = 0), - updateOffscreenComponent(current, workInProgress, renderLanes) - ); + return null !== workInProgress ? workInProgress.sibling : null; + } + push(suspenseStackCursor, suspenseStackCursor.current & 1); + break; + case 19: + updateExpirationTime = + workInProgress.childExpirationTime >= renderExpirationTime; + if (0 !== (current.effectTag & 64)) { + if (updateExpirationTime) + return updateSuspenseListComponent( + current, + workInProgress, + renderExpirationTime + ); + workInProgress.effectTag |= 64; + } + context = workInProgress.memoizedState; + null !== context && + ((context.rendering = null), (context.tail = null)); + push(suspenseStackCursor, suspenseStackCursor.current); + if (!updateExpirationTime) return null; + } + return bailoutOnAlreadyFinishedWork( + current, + workInProgress, + renderExpirationTime + ); } - return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes); + didReceiveUpdate = !1; } else didReceiveUpdate = !1; - workInProgress.lanes = 0; + workInProgress.expirationTime = 0; switch (workInProgress.tag) { case 2: - updateLanes = workInProgress.type; + updateExpirationTime = workInProgress.type; null !== current && ((current.alternate = null), (workInProgress.alternate = null), (workInProgress.effectTag |= 2)); current = workInProgress.pendingProps; context = getMaskedContext(workInProgress, contextStackCursor.current); - prepareToReadContext(workInProgress, renderLanes); + prepareToReadContext(workInProgress, renderExpirationTime); context = renderWithHooks( null, workInProgress, - updateLanes, + updateExpirationTime, current, context, - renderLanes + renderExpirationTime ); workInProgress.effectTag |= 1; if ( @@ -7148,7 +6691,7 @@ beginWork$1 = function(current, workInProgress, renderLanes) { workInProgress.tag = 1; workInProgress.memoizedState = null; workInProgress.updateQueue = null; - if (isContextProvider(updateLanes)) { + if (isContextProvider(updateExpirationTime)) { var hasContext = !0; pushContextProvider(workInProgress); } else hasContext = !1; @@ -7157,41 +6700,53 @@ beginWork$1 = function(current, workInProgress, renderLanes) { ? context.state : null; initializeUpdateQueue(workInProgress); - var getDerivedStateFromProps = updateLanes.getDerivedStateFromProps; + var getDerivedStateFromProps = + updateExpirationTime.getDerivedStateFromProps; "function" === typeof getDerivedStateFromProps && applyDerivedStateFromProps( workInProgress, - updateLanes, + updateExpirationTime, getDerivedStateFromProps, current ); context.updater = classComponentUpdater; workInProgress.stateNode = context; - context._reactInternals = workInProgress; - mountClassInstance(workInProgress, updateLanes, current, renderLanes); + context._reactInternalFiber = workInProgress; + mountClassInstance( + workInProgress, + updateExpirationTime, + current, + renderExpirationTime + ); workInProgress = finishClassComponent( null, workInProgress, - updateLanes, + updateExpirationTime, !0, hasContext, - renderLanes + renderExpirationTime ); } else (workInProgress.tag = 0), - reconcileChildren(null, workInProgress, context, renderLanes), + reconcileChildren( + null, + workInProgress, + context, + renderExpirationTime + ), (workInProgress = workInProgress.child); return workInProgress; case 16: - context = workInProgress.elementType; a: { + context = workInProgress.elementType; null !== current && ((current.alternate = null), (workInProgress.alternate = null), (workInProgress.effectTag |= 2)); current = workInProgress.pendingProps; - hasContext = context._init; - context = hasContext(context._payload); + initializeLazyComponentType(context); + if (1 !== context._status) throw context._result; + context = context._result; workInProgress.type = context; hasContext = workInProgress.tag = resolveLazyComponentTag(context); current = resolveDefaultProps(context, current); @@ -7202,7 +6757,7 @@ beginWork$1 = function(current, workInProgress, renderLanes) { workInProgress, context, current, - renderLanes + renderExpirationTime ); break a; case 1: @@ -7211,7 +6766,7 @@ beginWork$1 = function(current, workInProgress, renderLanes) { workInProgress, context, current, - renderLanes + renderExpirationTime ); break a; case 11: @@ -7220,7 +6775,7 @@ beginWork$1 = function(current, workInProgress, renderLanes) { workInProgress, context, current, - renderLanes + renderExpirationTime ); break a; case 14: @@ -7229,8 +6784,8 @@ beginWork$1 = function(current, workInProgress, renderLanes) { workInProgress, context, resolveDefaultProps(context.type, current), - updateLanes, - renderLanes + updateExpirationTime, + renderExpirationTime ); break a; } @@ -7243,106 +6798,126 @@ beginWork$1 = function(current, workInProgress, renderLanes) { return workInProgress; case 0: return ( - (updateLanes = workInProgress.type), + (updateExpirationTime = workInProgress.type), (context = workInProgress.pendingProps), (context = - workInProgress.elementType === updateLanes + workInProgress.elementType === updateExpirationTime ? context - : resolveDefaultProps(updateLanes, context)), + : resolveDefaultProps(updateExpirationTime, context)), updateFunctionComponent( current, workInProgress, - updateLanes, + updateExpirationTime, context, - renderLanes + renderExpirationTime ) ); case 1: return ( - (updateLanes = workInProgress.type), + (updateExpirationTime = workInProgress.type), (context = workInProgress.pendingProps), (context = - workInProgress.elementType === updateLanes + workInProgress.elementType === updateExpirationTime ? context - : resolveDefaultProps(updateLanes, context)), + : resolveDefaultProps(updateExpirationTime, context)), updateClassComponent( current, workInProgress, - updateLanes, + updateExpirationTime, context, - renderLanes + renderExpirationTime ) ); case 3: pushHostRootContext(workInProgress); - updateLanes = workInProgress.updateQueue; - if (null === current || null === updateLanes) + updateExpirationTime = workInProgress.updateQueue; + if (null === current || null === updateExpirationTime) throw Error( "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." ); - updateLanes = workInProgress.pendingProps; + updateExpirationTime = workInProgress.pendingProps; context = workInProgress.memoizedState; context = null !== context ? context.element : null; cloneUpdateQueue(current, workInProgress); - processUpdateQueue(workInProgress, updateLanes, null, renderLanes); - updateLanes = workInProgress.memoizedState.element; - updateLanes === context + processUpdateQueue( + workInProgress, + updateExpirationTime, + null, + renderExpirationTime + ); + updateExpirationTime = workInProgress.memoizedState.element; + updateExpirationTime === context ? (workInProgress = bailoutOnAlreadyFinishedWork( current, workInProgress, - renderLanes + renderExpirationTime )) - : (reconcileChildren(current, workInProgress, updateLanes, renderLanes), + : (reconcileChildren( + current, + workInProgress, + updateExpirationTime, + renderExpirationTime + ), (workInProgress = workInProgress.child)); return workInProgress; case 5: return ( pushHostContext(workInProgress), - (updateLanes = workInProgress.pendingProps.children), + (updateExpirationTime = workInProgress.pendingProps.children), markRef(current, workInProgress), - reconcileChildren(current, workInProgress, updateLanes, renderLanes), - workInProgress.child + reconcileChildren( + current, + workInProgress, + updateExpirationTime, + renderExpirationTime + ), + (workInProgress = workInProgress.child), + workInProgress ); case 6: return null; case 13: - return updateSuspenseComponent(current, workInProgress, renderLanes); + return updateSuspenseComponent( + current, + workInProgress, + renderExpirationTime + ); case 4: return ( pushHostContainer( workInProgress, workInProgress.stateNode.containerInfo ), - (updateLanes = workInProgress.pendingProps), + (updateExpirationTime = workInProgress.pendingProps), null === current ? (workInProgress.child = reconcileChildFibers( workInProgress, null, - updateLanes, - renderLanes + updateExpirationTime, + renderExpirationTime )) : reconcileChildren( current, workInProgress, - updateLanes, - renderLanes + updateExpirationTime, + renderExpirationTime ), workInProgress.child ); case 11: return ( - (updateLanes = workInProgress.type), + (updateExpirationTime = workInProgress.type), (context = workInProgress.pendingProps), (context = - workInProgress.elementType === updateLanes + workInProgress.elementType === updateExpirationTime ? context - : resolveDefaultProps(updateLanes, context)), + : resolveDefaultProps(updateExpirationTime, context)), updateForwardRef( current, workInProgress, - updateLanes, + updateExpirationTime, context, - renderLanes + renderExpirationTime ) ); case 7: @@ -7351,7 +6926,7 @@ beginWork$1 = function(current, workInProgress, renderLanes) { current, workInProgress, workInProgress.pendingProps, - renderLanes + renderExpirationTime ), workInProgress.child ); @@ -7361,27 +6936,27 @@ beginWork$1 = function(current, workInProgress, renderLanes) { current, workInProgress, workInProgress.pendingProps.children, - renderLanes + renderExpirationTime ), workInProgress.child ); case 12: return ( (workInProgress.effectTag |= 4), - (updateLanes = workInProgress.stateNode), - (updateLanes.effectDuration = 0), - (updateLanes.passiveEffectDuration = 0), + (updateExpirationTime = workInProgress.stateNode), + (updateExpirationTime.effectDuration = 0), + (updateExpirationTime.passiveEffectDuration = 0), reconcileChildren( current, workInProgress, workInProgress.pendingProps.children, - renderLanes + renderExpirationTime ), workInProgress.child ); case 10: a: { - updateLanes = workInProgress.type._context; + updateExpirationTime = workInProgress.type._context; context = workInProgress.pendingProps; getDerivedStateFromProps = workInProgress.memoizedProps; hasContext = context.value; @@ -7393,8 +6968,9 @@ beginWork$1 = function(current, workInProgress, renderLanes) { ((context$jscomp$0 = getDerivedStateFromProps.value), (hasContext = objectIs(context$jscomp$0, hasContext) ? 0 - : ("function" === typeof updateLanes._calculateChangedBits - ? updateLanes._calculateChangedBits( + : ("function" === + typeof updateExpirationTime._calculateChangedBits + ? updateExpirationTime._calculateChangedBits( context$jscomp$0, hasContext ) @@ -7408,7 +6984,7 @@ beginWork$1 = function(current, workInProgress, renderLanes) { workInProgress = bailoutOnAlreadyFinishedWork( current, workInProgress, - renderLanes + renderExpirationTime ); break a; } @@ -7429,25 +7005,25 @@ beginWork$1 = function(current, workInProgress, renderLanes) { ) { if ( - dependency.context === updateLanes && + dependency.context === updateExpirationTime && 0 !== (dependency.observedBits & hasContext) ) { 1 === context$jscomp$0.tag && - ((dependency = createUpdate( - -1, - renderLanes & -renderLanes, - null - )), + ((dependency = createUpdate(renderExpirationTime, null)), (dependency.tag = 2), enqueueUpdate(context$jscomp$0, dependency)); - context$jscomp$0.lanes |= renderLanes; + context$jscomp$0.expirationTime < renderExpirationTime && + (context$jscomp$0.expirationTime = renderExpirationTime); dependency = context$jscomp$0.alternate; - null !== dependency && (dependency.lanes |= renderLanes); + null !== dependency && + dependency.expirationTime < renderExpirationTime && + (dependency.expirationTime = renderExpirationTime); scheduleWorkOnParentPath( context$jscomp$0.return, - renderLanes + renderExpirationTime ); - list.lanes |= renderLanes; + list.expirationTime < renderExpirationTime && + (list.expirationTime = renderExpirationTime); break; } dependency = dependency.next; @@ -7485,7 +7061,7 @@ beginWork$1 = function(current, workInProgress, renderLanes) { current, workInProgress, context.children, - renderLanes + renderExpirationTime ); workInProgress = workInProgress.child; } @@ -7494,12 +7070,17 @@ beginWork$1 = function(current, workInProgress, renderLanes) { return ( (context = workInProgress.type), (hasContext = workInProgress.pendingProps), - (updateLanes = hasContext.children), - prepareToReadContext(workInProgress, renderLanes), + (updateExpirationTime = hasContext.children), + prepareToReadContext(workInProgress, renderExpirationTime), (context = readContext(context, hasContext.unstable_observedBits)), - (updateLanes = updateLanes(context)), + (updateExpirationTime = updateExpirationTime(context)), (workInProgress.effectTag |= 1), - reconcileChildren(current, workInProgress, updateLanes, renderLanes), + reconcileChildren( + current, + workInProgress, + updateExpirationTime, + renderExpirationTime + ), workInProgress.child ); case 14: @@ -7515,8 +7096,8 @@ beginWork$1 = function(current, workInProgress, renderLanes) { workInProgress, context, hasContext, - updateLanes, - renderLanes + updateExpirationTime, + renderExpirationTime ) ); case 15: @@ -7525,43 +7106,48 @@ beginWork$1 = function(current, workInProgress, renderLanes) { workInProgress, workInProgress.type, workInProgress.pendingProps, - updateLanes, - renderLanes + updateExpirationTime, + renderExpirationTime ); case 17: return ( - (updateLanes = workInProgress.type), + (updateExpirationTime = workInProgress.type), (context = workInProgress.pendingProps), (context = - workInProgress.elementType === updateLanes + workInProgress.elementType === updateExpirationTime ? context - : resolveDefaultProps(updateLanes, context)), + : resolveDefaultProps(updateExpirationTime, context)), null !== current && ((current.alternate = null), (workInProgress.alternate = null), (workInProgress.effectTag |= 2)), (workInProgress.tag = 1), - isContextProvider(updateLanes) + isContextProvider(updateExpirationTime) ? ((current = !0), pushContextProvider(workInProgress)) : (current = !1), - prepareToReadContext(workInProgress, renderLanes), - constructClassInstance(workInProgress, updateLanes, context), - mountClassInstance(workInProgress, updateLanes, context, renderLanes), + prepareToReadContext(workInProgress, renderExpirationTime), + constructClassInstance(workInProgress, updateExpirationTime, context), + mountClassInstance( + workInProgress, + updateExpirationTime, + context, + renderExpirationTime + ), finishClassComponent( null, workInProgress, - updateLanes, + updateExpirationTime, !0, current, - renderLanes + renderExpirationTime ) ); case 19: - return updateSuspenseListComponent(current, workInProgress, renderLanes); - case 23: - return updateOffscreenComponent(current, workInProgress, renderLanes); - case 24: - return updateOffscreenComponent(current, workInProgress, renderLanes); + return updateSuspenseListComponent( + current, + workInProgress, + renderExpirationTime + ); } throw Error( "Unknown unit of work tag (" + @@ -7569,16 +7155,16 @@ beginWork$1 = function(current, workInProgress, renderLanes) { "). This error is likely caused by a bug in React. Please file an issue." ); }; -function scheduleInteractions(root, lane, interactions) { +function scheduleInteractions(root, expirationTime, interactions) { if (0 < interactions.size) { var pendingInteractionMap = root.pendingInteractionMap, - pendingInteractions = pendingInteractionMap.get(lane); + pendingInteractions = pendingInteractionMap.get(expirationTime); null != pendingInteractions ? interactions.forEach(function(interaction) { pendingInteractions.has(interaction) || interaction.__count++; pendingInteractions.add(interaction); }) - : (pendingInteractionMap.set(lane, new Set(interactions)), + : (pendingInteractionMap.set(expirationTime, new Set(interactions)), interactions.forEach(function(interaction) { interaction.__count++; })); @@ -7586,20 +7172,20 @@ function scheduleInteractions(root, lane, interactions) { if (null !== pendingInteractionMap) pendingInteractionMap.onWorkScheduled( interactions, - 1e3 * lane + root.interactionThreadID + 1e3 * expirationTime + root.interactionThreadID ); } } -function schedulePendingInteractions(root, lane) { - scheduleInteractions(root, lane, tracing.__interactionsRef.current); +function schedulePendingInteractions(root, expirationTime) { + scheduleInteractions(root, expirationTime, tracing.__interactionsRef.current); } -function startWorkOnPendingInteractions(root, lanes) { +function startWorkOnPendingInteractions(root, expirationTime) { var interactions = new Set(); root.pendingInteractionMap.forEach(function( scheduledInteractions, - scheduledLane + scheduledExpirationTime ) { - 0 !== (lanes & scheduledLane) && + scheduledExpirationTime >= expirationTime && scheduledInteractions.forEach(function(interaction) { return interactions.add(interaction); }); @@ -7608,7 +7194,7 @@ function startWorkOnPendingInteractions(root, lanes) { if (0 < interactions.size) { var subscriber = tracing.__subscriberRef.current; if (null !== subscriber) { - root = 1e3 * lanes + root.interactionThreadID; + root = 1e3 * expirationTime + root.interactionThreadID; try { subscriber.onWorkStarted(interactions, root); } catch (error) { @@ -7619,14 +7205,14 @@ function startWorkOnPendingInteractions(root, lanes) { } } } -function finishPendingInteractions(root, committedLanes) { - var remainingLanesAfterCommit = root.pendingLanes; +function finishPendingInteractions(root, committedExpirationTime) { + var earliestRemainingTimeAfterCommit = root.firstPendingTime; try { var subscriber = tracing.__subscriberRef.current; if (null !== subscriber && 0 < root.memoizedInteractions.size) subscriber.onWorkStopped( root.memoizedInteractions, - 1e3 * committedLanes + root.interactionThreadID + 1e3 * committedExpirationTime + root.interactionThreadID ); } catch (error) { scheduleCallback(99, function() { @@ -7634,23 +7220,54 @@ function finishPendingInteractions(root, committedLanes) { }); } finally { var pendingInteractionMap = root.pendingInteractionMap; - pendingInteractionMap.forEach(function(scheduledInteractions, lane) { - 0 === (remainingLanesAfterCommit & lane) && - (pendingInteractionMap.delete(lane), + pendingInteractionMap.forEach(function( + scheduledInteractions, + scheduledExpirationTime + ) { + scheduledExpirationTime > earliestRemainingTimeAfterCommit && + (pendingInteractionMap.delete(scheduledExpirationTime), scheduledInteractions.forEach(function(interaction) { interaction.__count--; if (null !== subscriber && 0 === interaction.__count) try { subscriber.onInteractionScheduledWorkCompleted(interaction); - } catch (error$107) { + } catch (error) { scheduleCallback(99, function() { - throw error$107; + throw error; }); } })); }); } } +var onCommitFiberRoot = null, + onCommitFiberUnmount = null, + isDevToolsPresent = "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__; +function injectInternals(internals) { + if ("undefined" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) return !1; + var hook = __REACT_DEVTOOLS_GLOBAL_HOOK__; + if (hook.isDisabled || !hook.supportsFiber) return !0; + try { + var rendererID = hook.inject(internals); + onCommitFiberRoot = function(root, expirationTime) { + try { + var didError = 64 === (root.current.effectTag & 64), + currentTime = 1073741821 - ((now() / 10) | 0), + priorityLevel = inferPriorityFromExpirationTime( + currentTime, + expirationTime + ); + hook.onCommitFiberRoot(rendererID, root, priorityLevel, didError); + } catch (err) {} + }; + onCommitFiberUnmount = function(fiber) { + try { + hook.onCommitFiberUnmount(rendererID, fiber); + } catch (err) {} + }; + } catch (err) {} + return !0; +} function FiberNode(tag, pendingProps, key, mode) { this.tag = tag; this.key = key; @@ -7662,15 +7279,12 @@ function FiberNode(tag, pendingProps, key, mode) { this.mode = mode; this.effectTag = 0; this.lastEffect = this.firstEffect = this.nextEffect = null; - this.childLanes = this.lanes = 0; + this.childExpirationTime = this.expirationTime = 0; this.alternate = null; this.actualDuration = 0; 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); @@ -7688,7 +7302,7 @@ function resolveLazyComponentTag(Component) { function createWorkInProgress(current, pendingProps) { var workInProgress = current.alternate; null === workInProgress - ? ((workInProgress = createFiber( + ? ((workInProgress = new FiberNode( current.tag, pendingProps, current.key, @@ -7700,15 +7314,18 @@ function createWorkInProgress(current, pendingProps) { (workInProgress.alternate = current), (current.alternate = workInProgress)) : ((workInProgress.pendingProps = pendingProps), - (workInProgress.type = current.type), (workInProgress.effectTag = 0), (workInProgress.nextEffect = null), (workInProgress.firstEffect = null), (workInProgress.lastEffect = null), (workInProgress.actualDuration = 0), (workInProgress.actualStartTime = -1)); - workInProgress.childLanes = current.childLanes; - workInProgress.lanes = current.lanes; + if (null == current) + throw Error("current is " + current + " but it can't be"); + if (null == workInProgress) + throw Error("workInProgress is " + workInProgress + " but it can't be"); + workInProgress.childExpirationTime = current.childExpirationTime; + workInProgress.expirationTime = current.expirationTime; workInProgress.child = current.child; workInProgress.memoizedProps = current.memoizedProps; workInProgress.memoizedState = current.memoizedState; @@ -7718,7 +7335,7 @@ function createWorkInProgress(current, pendingProps) { null === pendingProps ? null : { - lanes: pendingProps.lanes, + expirationTime: pendingProps.expirationTime, firstContext: pendingProps.firstContext, responders: pendingProps.responders }; @@ -7735,7 +7352,7 @@ function createFiberFromTypeAndProps( pendingProps, owner, mode, - lanes + expirationTime ) { var fiberTag = 2; owner = type; @@ -7744,10 +7361,15 @@ function createFiberFromTypeAndProps( else a: switch (type) { case REACT_FRAGMENT_TYPE: - return createFiberFromFragment(pendingProps.children, mode, lanes, key); - case REACT_DEBUG_TRACING_MODE_TYPE: + return createFiberFromFragment( + pendingProps.children, + mode, + expirationTime, + key + ); + case REACT_CONCURRENT_MODE_TYPE: fiberTag = 8; - mode |= 16; + mode |= 7; break; case REACT_STRICT_MODE_TYPE: fiberTag = 8; @@ -7755,35 +7377,26 @@ function createFiberFromTypeAndProps( break; case REACT_PROFILER_TYPE: return ( - (type = createFiber(12, pendingProps, key, mode | 8)), + (type = new FiberNode(12, pendingProps, key, mode | 8)), (type.elementType = REACT_PROFILER_TYPE), (type.type = REACT_PROFILER_TYPE), - (type.lanes = lanes), + (type.expirationTime = expirationTime), (type.stateNode = { effectDuration: 0, passiveEffectDuration: 0 }), type ); case REACT_SUSPENSE_TYPE: return ( - (type = createFiber(13, pendingProps, key, mode)), + (type = new FiberNode(13, pendingProps, key, mode)), (type.type = REACT_SUSPENSE_TYPE), (type.elementType = REACT_SUSPENSE_TYPE), - (type.lanes = lanes), + (type.expirationTime = expirationTime), type ); case REACT_SUSPENSE_LIST_TYPE: return ( - (type = createFiber(19, pendingProps, key, mode)), + (type = new FiberNode(19, pendingProps, key, mode)), (type.elementType = REACT_SUSPENSE_LIST_TYPE), - (type.lanes = lanes), - type - ); - case REACT_OFFSCREEN_TYPE: - return createFiberFromOffscreen(pendingProps, mode, lanes, key); - case REACT_LEGACY_HIDDEN_TYPE: - return ( - (type = createFiber(24, pendingProps, key, mode)), - (type.elementType = REACT_LEGACY_HIDDEN_TYPE), - (type.lanes = lanes), + (type.expirationTime = expirationTime), type ); default: @@ -7815,36 +7428,30 @@ function createFiberFromTypeAndProps( "." ); } - key = createFiber(fiberTag, pendingProps, key, mode); + key = new FiberNode(fiberTag, pendingProps, key, mode); key.elementType = type; key.type = owner; - key.lanes = lanes; + key.expirationTime = expirationTime; return key; } -function createFiberFromFragment(elements, mode, lanes, key) { - elements = createFiber(7, elements, key, mode); - elements.lanes = lanes; +function createFiberFromFragment(elements, mode, expirationTime, key) { + elements = new FiberNode(7, elements, key, mode); + elements.expirationTime = expirationTime; return elements; } -function createFiberFromOffscreen(pendingProps, mode, lanes, key) { - pendingProps = createFiber(23, pendingProps, key, mode); - pendingProps.elementType = REACT_OFFSCREEN_TYPE; - pendingProps.lanes = lanes; - return pendingProps; -} -function createFiberFromText(content, mode, lanes) { - content = createFiber(6, content, null, mode); - content.lanes = lanes; +function createFiberFromText(content, mode, expirationTime) { + content = new FiberNode(6, content, null, mode); + content.expirationTime = expirationTime; return content; } -function createFiberFromPortal(portal, mode, lanes) { - mode = createFiber( +function createFiberFromPortal(portal, mode, expirationTime) { + mode = new FiberNode( 4, null !== portal.children ? portal.children : [], portal.key, mode ); - mode.lanes = lanes; + mode.expirationTime = expirationTime; mode.stateNode = { containerInfo: portal.containerInfo, pendingChildren: null, @@ -7854,34 +7461,54 @@ function createFiberFromPortal(portal, mode, lanes) { } function FiberRootNode(containerInfo, tag, hydrate) { this.tag = tag; + this.current = null; this.containerInfo = containerInfo; - this.finishedWork = this.pingCache = this.current = this.pendingChildren = null; + this.pingCache = this.pendingChildren = null; + this.finishedExpirationTime = 0; + this.finishedWork = null; this.timeoutHandle = -1; this.pendingContext = this.context = null; this.hydrate = hydrate; this.callbackNode = null; - this.callbackPriority = 0; - this.eventTimes = Array(31).fill(0); - this.expirationTimes = Array(31).fill(-1); - this.entangledLanes = this.finishedLanes = this.mutableReadLanes = this.expiredLanes = this.pingedLanes = this.suspendedLanes = this.pendingLanes = 0; - this.entanglements = Array(31).fill(0); + this.callbackPriority = 90; + this.lastExpiredTime = this.lastPingedTime = this.nextKnownPendingLevel = this.lastSuspendedTime = this.firstSuspendedTime = this.firstPendingTime = 0; this.interactionThreadID = tracing.unstable_getThreadID(); this.memoizedInteractions = new Set(); this.pendingInteractionMap = new Map(); } -function createPortal(children, containerInfo, implementation) { - var key = - 3 < arguments.length && void 0 !== arguments[3] ? arguments[3] : null; - return { - $$typeof: REACT_PORTAL_TYPE, - key: null == key ? null : "" + key, - children: children, - containerInfo: containerInfo, - implementation: implementation - }; +function isRootSuspendedAtTime(root, expirationTime) { + var firstSuspendedTime = root.firstSuspendedTime; + root = root.lastSuspendedTime; + return ( + 0 !== firstSuspendedTime && + firstSuspendedTime >= expirationTime && + root <= expirationTime + ); +} +function markRootSuspendedAtTime(root, expirationTime) { + var firstSuspendedTime = root.firstSuspendedTime, + lastSuspendedTime = root.lastSuspendedTime; + firstSuspendedTime < expirationTime && + (root.firstSuspendedTime = expirationTime); + if (lastSuspendedTime > expirationTime || 0 === firstSuspendedTime) + root.lastSuspendedTime = expirationTime; + expirationTime <= root.lastPingedTime && (root.lastPingedTime = 0); + expirationTime <= root.lastExpiredTime && (root.lastExpiredTime = 0); +} +function markRootUpdatedAtTime(root, expirationTime) { + expirationTime > root.firstPendingTime && + (root.firstPendingTime = expirationTime); + var firstSuspendedTime = root.firstSuspendedTime; + 0 !== firstSuspendedTime && + (expirationTime >= firstSuspendedTime + ? (root.firstSuspendedTime = root.lastSuspendedTime = root.nextKnownPendingLevel = 0) + : expirationTime >= root.lastSuspendedTime && + (root.lastSuspendedTime = expirationTime + 1), + expirationTime > root.nextKnownPendingLevel && + (root.nextKnownPendingLevel = expirationTime)); } function findHostInstance(component) { - var fiber = component._reactInternals; + var fiber = component._reactInternalFiber; if (void 0 === fiber) { if ("function" === typeof component.render) throw Error("Unable to find node on an unmounted component."); @@ -7895,11 +7522,11 @@ function findHostInstance(component) { } function updateContainer(element, container, parentComponent, callback) { var current = container.current, - eventTime = requestEventTime(), - suspenseConfig = ReactCurrentBatchConfig.suspense, - lane = requestUpdateLane(current, suspenseConfig); + currentTime = requestCurrentTimeForUpdate(), + suspenseConfig = ReactCurrentBatchConfig.suspense; + currentTime = computeExpirationForFiber(currentTime, current, suspenseConfig); a: if (parentComponent) { - parentComponent = parentComponent._reactInternals; + parentComponent = parentComponent._reactInternalFiber; b: { if ( getNearestMountedFiber(parentComponent) !== parentComponent || @@ -7908,23 +7535,22 @@ function updateContainer(element, container, parentComponent, callback) { throw Error( "Expected subtree parent to be a mounted class component. This error is likely caused by a bug in React. Please file an issue." ); - var JSCompiler_inline_result = parentComponent; + var parentContext = parentComponent; do { - switch (JSCompiler_inline_result.tag) { + switch (parentContext.tag) { case 3: - JSCompiler_inline_result = - JSCompiler_inline_result.stateNode.context; + parentContext = parentContext.stateNode.context; break b; case 1: - if (isContextProvider(JSCompiler_inline_result.type)) { - JSCompiler_inline_result = - JSCompiler_inline_result.stateNode + if (isContextProvider(parentContext.type)) { + parentContext = + parentContext.stateNode .__reactInternalMemoizedMergedChildContext; break b; } } - JSCompiler_inline_result = JSCompiler_inline_result.return; - } while (null !== JSCompiler_inline_result); + parentContext = parentContext.return; + } while (null !== parentContext); throw Error( "Found unexpected detached subtree parent. This error is likely caused by a bug in React. Please file an issue." ); @@ -7935,26 +7561,34 @@ function updateContainer(element, container, parentComponent, callback) { parentComponent = processChildContext( parentComponent, Component, - JSCompiler_inline_result + parentContext ); break a; } } - parentComponent = JSCompiler_inline_result; + parentComponent = parentContext; } else parentComponent = emptyContextObject; null === container.context ? (container.context = parentComponent) : (container.pendingContext = parentComponent); - container = createUpdate(eventTime, lane, suspenseConfig); + container = createUpdate(currentTime, suspenseConfig); container.payload = { element: element }; callback = void 0 === callback ? null : callback; null !== callback && (container.callback = callback); enqueueUpdate(current, container); - scheduleUpdateOnFiber(current, lane, eventTime); - return lane; + scheduleWork(current, currentTime); + return currentTime; } -function emptyFindFiberByHostInstance() { - return null; +function createPortal(children, containerInfo, implementation) { + var key = + 3 < arguments.length && void 0 !== arguments[3] ? arguments[3] : null; + return { + $$typeof: REACT_PORTAL_TYPE, + key: null == key ? null : "" + key, + children: children, + containerInfo: containerInfo, + implementation: implementation + }; } function findNodeHandle(componentOrHandle) { if (null == componentOrHandle) return null; @@ -7976,64 +7610,53 @@ batchedUpdatesImpl = function(fn, a) { return fn(a); } finally { (executionContext = prevExecutionContext), - 0 === executionContext && flushSyncCallbackQueue(); + executionContext === NoContext && flushSyncCallbackQueue(); } }; -var roots = new Map(), - devToolsConfig$jscomp$inline_913 = { - findFiberByHostInstance: getInstanceFromInstance, - bundleType: 0, - version: "17.0.0-alpha.0", - rendererPackageName: "react-native-renderer", - rendererConfig: { - getInspectorDataForViewTag: function() { - throw Error( - "getInspectorDataForViewTag() is not available in production" - ); - }, - getInspectorDataForViewAtPoint: function() { - throw Error( - "getInspectorDataForViewAtPoint() is not available in production." - ); - }.bind(null, findNodeHandle) - } - }; -var internals$jscomp$inline_1111 = { - bundleType: devToolsConfig$jscomp$inline_913.bundleType, - version: devToolsConfig$jscomp$inline_913.version, - rendererPackageName: devToolsConfig$jscomp$inline_913.rendererPackageName, - rendererConfig: devToolsConfig$jscomp$inline_913.rendererConfig, - overrideHookState: null, - overrideProps: null, - setSuspenseHandler: null, - scheduleUpdate: null, - currentDispatcherRef: ReactSharedInternals.ReactCurrentDispatcher, - findHostInstanceByFiber: function(fiber) { - fiber = findCurrentHostFiber(fiber); - return null === fiber ? null : fiber.stateNode; - }, - findFiberByHostInstance: - devToolsConfig$jscomp$inline_913.findFiberByHostInstance || - emptyFindFiberByHostInstance, - findHostInstancesForRefresh: null, - scheduleRefresh: null, - scheduleRoot: null, - setRefreshHandler: null, - getCurrentFiber: null -}; -if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) { - var hook$jscomp$inline_1112 = __REACT_DEVTOOLS_GLOBAL_HOOK__; - if ( - !hook$jscomp$inline_1112.isDisabled && - hook$jscomp$inline_1112.supportsFiber - ) - try { - (rendererID = hook$jscomp$inline_1112.inject( - internals$jscomp$inline_1111 - )), - (injectedHook = hook$jscomp$inline_1112); - } catch (err) {} -} +var roots = new Map(); +(function(devToolsConfig) { + var findFiberByHostInstance = devToolsConfig.findFiberByHostInstance; + return injectInternals({ + bundleType: devToolsConfig.bundleType, + version: devToolsConfig.version, + rendererPackageName: devToolsConfig.rendererPackageName, + rendererConfig: devToolsConfig.rendererConfig, + overrideHookState: null, + overrideProps: null, + setSuspenseHandler: null, + scheduleUpdate: null, + currentDispatcherRef: ReactSharedInternals.ReactCurrentDispatcher, + findHostInstanceByFiber: function(fiber) { + fiber = findCurrentHostFiber(fiber); + return null === fiber ? null : fiber.stateNode; + }, + findFiberByHostInstance: function(instance) { + return findFiberByHostInstance ? findFiberByHostInstance(instance) : null; + }, + findHostInstancesForRefresh: null, + scheduleRefresh: null, + scheduleRoot: null, + setRefreshHandler: null, + getCurrentFiber: null + }); +})({ + findFiberByHostInstance: getInstanceFromInstance, + bundleType: 0, + version: "16.13.0", + rendererPackageName: "react-native-renderer", + rendererConfig: { + getInspectorDataForViewTag: function() { + throw Error( + "getInspectorDataForViewTag() is not available in production" + ); + }, + getInspectorDataForViewAtPoint: function() { + throw Error( + "getInspectorDataForViewAtPoint() is not available in production." + ); + }.bind(null, findNodeHandle) + } +}); exports.createPortal = function(children, containerTag) { return createPortal( children, @@ -8073,17 +7696,12 @@ exports.render = function(element, containerTag, callback) { var root = roots.get(containerTag); if (!root) { root = new FiberRootNode(containerTag, 0, !1); - var JSCompiler_inline_result = 0; - isDevToolsPresent && (JSCompiler_inline_result |= 8); - JSCompiler_inline_result = createFiber( - 3, - null, - null, - JSCompiler_inline_result - ); - root.current = JSCompiler_inline_result; - JSCompiler_inline_result.stateNode = root; - initializeUpdateQueue(JSCompiler_inline_result); + var uninitializedFiber = 0; + isDevToolsPresent && (uninitializedFiber |= 8); + uninitializedFiber = new FiberNode(3, null, null, uninitializedFiber); + root.current = uninitializedFiber; + uninitializedFiber.stateNode = root; + initializeUpdateQueue(uninitializedFiber); roots.set(containerTag, root); } updateContainer(element, root, null, callback); diff --git a/Libraries/Renderer/implementations/ReactNativeRenderer-dev.fb.js b/Libraries/Renderer/implementations/ReactNativeRenderer-dev.fb.js index 73e4ee4fcce..8ef9be34609 100644 --- a/Libraries/Renderer/implementations/ReactNativeRenderer-dev.fb.js +++ b/Libraries/Renderer/implementations/ReactNativeRenderer-dev.fb.js @@ -23,7 +23,21 @@ var Scheduler = require("scheduler"); var tracing = require("scheduler/tracing"); var ReactSharedInternals = - React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED; + React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED; // Prevent newer renderers from RTE when used with older react package versions. +// Current owner and dispatcher used to share the same ref, +// but PR #14548 split them out to better support the react-debug-tools package. + +if (!ReactSharedInternals.hasOwnProperty("ReactCurrentDispatcher")) { + ReactSharedInternals.ReactCurrentDispatcher = { + current: null + }; +} + +if (!ReactSharedInternals.hasOwnProperty("ReactCurrentBatchConfig")) { + ReactSharedInternals.ReactCurrentBatchConfig = { + suspense: null + }; +} // by calls to these methods by a Babel plugin. // @@ -65,12 +79,19 @@ function printWarning(level, format, args) { // When changing this logic, you might want to also // update consoleWithStackDev.www.js as well. { - var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame; - var stack = ReactDebugCurrentFrame.getStackAddendum(); + var hasExistingStack = + args.length > 0 && + typeof args[args.length - 1] === "string" && + args[args.length - 1].indexOf("\n in") === 0; - if (stack !== "") { - format += "%s"; - args = args.concat([stack]); + if (!hasExistingStack) { + var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame; + var stack = ReactDebugCurrentFrame.getStackAddendum(); + + if (stack !== "") { + format += "%s"; + args = args.concat([stack]); + } } var argsWithFormat = args.map(function(item) { @@ -82,10 +103,161 @@ function printWarning(level, format, args) { // eslint-disable-next-line react-internal/no-production-logging Function.prototype.apply.call(console[level], 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 = + "Warning: " + + format.replace(/%s/g, function() { + return args[argIndex++]; + }); + throw new Error(message); + } catch (x) {} } } -function invokeGuardedCallbackProd(name, func, context, a, b, c, d, e, f) { +var FunctionComponent = 0; +var ClassComponent = 1; +var IndeterminateComponent = 2; // Before we know whether it is function or class + +var HostRoot = 3; // Root of a host tree. Could be nested inside another node. + +var HostPortal = 4; // A subtree. Could be an entry point to a different renderer. + +var HostComponent = 5; +var HostText = 6; +var Fragment = 7; +var Mode = 8; +var ContextConsumer = 9; +var ContextProvider = 10; +var ForwardRef = 11; +var Profiler = 12; +var SuspenseComponent = 13; +var MemoComponent = 14; +var SimpleMemoComponent = 15; +var LazyComponent = 16; +var IncompleteClassComponent = 17; +var DehydratedFragment = 18; +var SuspenseListComponent = 19; +var FundamentalComponent = 20; +var ScopeComponent = 21; +var Block = 22; + +function getParent(inst) { + do { + inst = inst.return; // TODO: If this is a HostRoot we might want to bail out. + // That is depending on if we want nested subtrees (layers) to bubble + // events to their parent. We could also go through parentNode on the + // host node but that wouldn't work for React Native and doesn't let us + // do the portal feature. + } while (inst && inst.tag !== HostComponent); + + if (inst) { + return inst; + } + + return null; +} +/** + * Return the lowest common ancestor of A and B, or null if they are in + * different trees. + */ + +function getLowestCommonAncestor(instA, instB) { + var depthA = 0; + + for (var tempA = instA; tempA; tempA = getParent(tempA)) { + depthA++; + } + + var depthB = 0; + + for (var tempB = instB; tempB; tempB = getParent(tempB)) { + depthB++; + } // If A is deeper, crawl up. + + while (depthA - depthB > 0) { + instA = getParent(instA); + depthA--; + } // If B is deeper, crawl up. + + while (depthB - depthA > 0) { + instB = getParent(instB); + depthB--; + } // Walk in lockstep until we find a match. + + var depth = depthA; + + while (depth--) { + if (instA === instB || instA === instB.alternate) { + return instA; + } + + instA = getParent(instA); + instB = getParent(instB); + } + + return null; +} +/** + * Return if A is an ancestor of B. + */ + +function isAncestor(instA, instB) { + while (instB) { + if (instA === instB || instA === instB.alternate) { + return true; + } + + instB = getParent(instB); + } + + return false; +} +/** + * Return the parent instance of the passed-in instance. + */ + +function getParentInstance(inst) { + return getParent(inst); +} +/** + * Simulates the traversal of a two-phase, capture/bubble event dispatch. + */ + +function traverseTwoPhase(inst, fn, arg) { + var path = []; + + while (inst) { + path.push(inst); + inst = getParent(inst); + } + + var i; + + for (i = path.length; i-- > 0; ) { + fn(path[i], "captured", arg); + } + + for (i = 0; i < path.length; i++) { + fn(path[i], "bubbled", arg); + } +} + +var invokeGuardedCallbackImpl = function( + name, + func, + context, + a, + b, + c, + d, + e, + f +) { var funcArgs = Array.prototype.slice.call(arguments, 3); try { @@ -93,9 +265,7 @@ function invokeGuardedCallbackProd(name, func, context, a, b, c, d, e, f) { } catch (error) { this.onError(error); } -} - -var invokeGuardedCallbackImpl = invokeGuardedCallbackProd; +}; { // In DEV mode, we swap out invokeGuardedCallback for a special version @@ -126,7 +296,7 @@ var invokeGuardedCallbackImpl = invokeGuardedCallbackProd; ) { var fakeNode = document.createElement("react"); - invokeGuardedCallbackImpl = function invokeGuardedCallbackDev( + var invokeGuardedCallbackDev = function( name, func, context, @@ -147,8 +317,7 @@ var invokeGuardedCallbackImpl = invokeGuardedCallbackProd; ); } - var evt = document.createEvent("Event"); - var didCall = false; // Keeps track of whether the user-provided callback threw an error. We + var evt = document.createEvent("Event"); // Keeps track of whether the user-provided callback threw an error. We // set this to true at the beginning, then set it to false right after // calling the function. If the function errors, `didError` will never be // set to false. This strategy works even if the browser is flaky and @@ -165,9 +334,13 @@ var invokeGuardedCallbackImpl = invokeGuardedCallbackProd; var windowEventDescriptor = Object.getOwnPropertyDescriptor( window, "event" - ); + ); // Create an event handler for our fake event. We will synchronously + // dispatch our fake event using `dispatchEvent`. Inside the handler, we + // call the user-provided callback. - function restoreAfterDispatch() { + var funcArgs = Array.prototype.slice.call(arguments, 3); + + function callCallback() { // We immediately remove the callback from event listeners so that // nested `invokeGuardedCallback` calls do not clash. Otherwise, a // nested call would trigger the fake event handlers of any call higher @@ -183,15 +356,7 @@ var invokeGuardedCallbackImpl = invokeGuardedCallbackProd; ) { window.event = windowEvent; } - } // Create an event handler for our fake event. We will synchronously - // dispatch our fake event using `dispatchEvent`. Inside the handler, we - // call the user-provided callback. - var funcArgs = Array.prototype.slice.call(arguments, 3); - - function callCallback() { - didCall = true; - restoreAfterDispatch(); func.apply(context, funcArgs); didError = false; } // Create a global error event handler. We use this to capture the value @@ -246,7 +411,7 @@ var invokeGuardedCallbackImpl = invokeGuardedCallbackProd; Object.defineProperty(window, "event", windowEventDescriptor); } - if (didCall && didError) { + if (didError) { if (!didSetError) { // The callback errored, but the error event never fired. error = new Error( @@ -271,16 +436,9 @@ var invokeGuardedCallbackImpl = invokeGuardedCallbackProd; } // Remove our event listeners window.removeEventListener("error", handleWindowError); - - if (!didCall) { - // Something went really wrong, and our event was not dispatched. - // https://github.com/facebook/react/issues/16734 - // https://github.com/facebook/react/issues/16585 - // Fall back to the production implementation. - restoreAfterDispatch(); - return invokeGuardedCallbackProd.apply(this, arguments); - } }; + + invokeGuardedCallbackImpl = invokeGuardedCallbackDev; } } @@ -549,6 +707,246 @@ function hasDispatches(event) { return !!event._dispatchListeners; } +function isInteractive(tag) { + return ( + tag === "button" || + tag === "input" || + tag === "select" || + tag === "textarea" + ); +} + +function shouldPreventMouseEvent(name, type, props) { + switch (name) { + case "onClick": + case "onClickCapture": + case "onDoubleClick": + case "onDoubleClickCapture": + case "onMouseDown": + case "onMouseDownCapture": + case "onMouseMove": + case "onMouseMoveCapture": + case "onMouseUp": + case "onMouseUpCapture": + case "onMouseEnter": + return !!(props.disabled && isInteractive(type)); + + default: + return false; + } +} +/** + * @param {object} inst The instance, which is the source of events. + * @param {string} registrationName Name of listener (e.g. `onClick`). + * @return {?function} The stored callback. + */ + +function getListener(inst, registrationName) { + var listener; // TODO: shouldPreventMouseEvent is DOM-specific and definitely should not + // live here; needs to be moved to a better place soon + + var stateNode = inst.stateNode; + + if (!stateNode) { + // Work in progress (ex: onload events in incremental mode). + return null; + } + + var props = getFiberCurrentPropsFromNode(stateNode); + + if (!props) { + // Work in progress. + return null; + } + + listener = props[registrationName]; + + if (shouldPreventMouseEvent(registrationName, inst.type, props)) { + return null; + } + + if (!(!listener || typeof listener === "function")) { + throw Error( + "Expected `" + + registrationName + + "` listener to be a function, instead got a value of `" + + typeof listener + + "` type." + ); + } + + return listener; +} + +/** + * Accumulates items that must not be null or undefined into the first one. This + * is used to conserve memory by avoiding array allocations, and thus sacrifices + * API cleanness. Since `current` can be null before being passed in and not + * null after this function, make sure to assign it back to `current`: + * + * `a = accumulateInto(a, b);` + * + * This API should be sparingly used. Try `accumulate` for something cleaner. + * + * @return {*|array<*>} An accumulation of items. + */ + +function accumulateInto(current, next) { + if (!(next != null)) { + throw Error( + "accumulateInto(...): Accumulated items must not be null or undefined." + ); + } + + if (current == null) { + return next; + } // Both are not empty. Warning: Never call x.concat(y) when you are not + // certain that x is an Array (x could be a string with concat method). + + if (Array.isArray(current)) { + if (Array.isArray(next)) { + current.push.apply(current, next); + return current; + } + + current.push(next); + return current; + } + + if (Array.isArray(next)) { + // A bit too dangerous to mutate `next`. + return [current].concat(next); + } + + return [current, next]; +} + +/** + * @param {array} arr an "accumulation" of items which is either an Array or + * a single item. Useful when paired with the `accumulate` module. This is a + * simple utility that allows us to reason about a collection of items, but + * handling the case when there is exactly one item (and we do not need to + * allocate an array). + * @param {function} cb Callback invoked with each element or a collection. + * @param {?} [scope] Scope used as `this` in a callback. + */ +function forEachAccumulated(arr, cb, scope) { + if (Array.isArray(arr)) { + arr.forEach(cb, scope); + } else if (arr) { + cb.call(scope, arr); + } +} + +/** + * Some event types have a notion of different registration names for different + * "phases" of propagation. This finds listeners by a given phase. + */ +function listenerAtPhase(inst, event, propagationPhase) { + var registrationName = + event.dispatchConfig.phasedRegistrationNames[propagationPhase]; + return getListener(inst, registrationName); +} +/** + * A small set of propagation patterns, each of which will accept a small amount + * of information, and generate a set of "dispatch ready event objects" - which + * are sets of events that have already been annotated with a set of dispatched + * listener functions/ids. The API is designed this way to discourage these + * propagation strategies from actually executing the dispatches, since we + * always want to collect the entire set of dispatches before executing even a + * single one. + */ + +/** + * Tags a `SyntheticEvent` with dispatched listeners. Creating this function + * here, allows us to not have to bind or create functions for each event. + * Mutating the event's members allows us to not have to create a wrapping + * "dispatch" object that pairs the event with the listener. + */ + +function accumulateDirectionalDispatches(inst, phase, event) { + { + if (!inst) { + error("Dispatching inst must not be null"); + } + } + + var listener = listenerAtPhase(inst, event, phase); + + if (listener) { + event._dispatchListeners = accumulateInto( + event._dispatchListeners, + listener + ); + event._dispatchInstances = accumulateInto(event._dispatchInstances, inst); + } +} +/** + * Collect dispatches (must be entirely collected before dispatching - see unit + * tests). Lazily allocate the array to conserve memory. We must loop through + * each event and perform the traversal for each one. We cannot perform a + * single traversal for the entire collection of events because each event may + * have a different target. + */ + +function accumulateTwoPhaseDispatchesSingle(event) { + if (event && event.dispatchConfig.phasedRegistrationNames) { + traverseTwoPhase(event._targetInst, accumulateDirectionalDispatches, event); + } +} +/** + * Same as `accumulateTwoPhaseDispatchesSingle`, but skips over the targetID. + */ + +function accumulateTwoPhaseDispatchesSingleSkipTarget(event) { + if (event && event.dispatchConfig.phasedRegistrationNames) { + var targetInst = event._targetInst; + var parentInst = targetInst ? getParentInstance(targetInst) : null; + traverseTwoPhase(parentInst, accumulateDirectionalDispatches, event); + } +} +/** + * Accumulates without regard to direction, does not look for phased + * registration names. Same as `accumulateDirectDispatchesSingle` but without + * requiring that the `dispatchMarker` be the same as the dispatched ID. + */ + +function accumulateDispatches(inst, ignoredDirection, event) { + if (inst && event && event.dispatchConfig.registrationName) { + var registrationName = event.dispatchConfig.registrationName; + var listener = getListener(inst, registrationName); + + if (listener) { + event._dispatchListeners = accumulateInto( + event._dispatchListeners, + listener + ); + event._dispatchInstances = accumulateInto(event._dispatchInstances, inst); + } + } +} +/** + * Accumulates dispatches on an `SyntheticEvent`, but only for the + * `dispatchMarker`. + * @param {SyntheticEvent} event + */ + +function accumulateDirectDispatchesSingle(event) { + if (event && event.dispatchConfig.registrationName) { + accumulateDispatches(event._targetInst, null, event); + } +} + +function accumulateTwoPhaseDispatches(events) { + forEachAccumulated(events, accumulateTwoPhaseDispatchesSingle); +} +function accumulateTwoPhaseDispatchesSkipTarget(events) { + forEachAccumulated(events, accumulateTwoPhaseDispatchesSingleSkipTarget); +} +function accumulateDirectDispatches(events) { + forEachAccumulated(events, accumulateDirectDispatchesSingle); +} + var EVENT_POOL_SIZE = 10; /** * @interface Event @@ -616,8 +1014,6 @@ function SyntheticEvent( this.dispatchConfig = dispatchConfig; this._targetInst = targetInst; this.nativeEvent = nativeEvent; - this._dispatchListeners = null; - this._dispatchInstances = null; var Interface = this.constructor.Interface; for (var propName in Interface) { @@ -843,12 +1239,7 @@ function getPooledWarningPropertyDefinition(propName, getVal) { } } -function createOrGetPooledEvent( - dispatchConfig, - targetInst, - nativeEvent, - nativeInst -) { +function getPooledEvent(dispatchConfig, targetInst, nativeEvent, nativeInst) { var EventConstructor = this; if (EventConstructor.eventPool.length) { @@ -888,8 +1279,8 @@ function releasePooledEvent(event) { } function addEventPoolingTo(EventConstructor) { - EventConstructor.getPooled = createOrGetPooledEvent; EventConstructor.eventPool = []; + EventConstructor.getPooled = getPooledEvent; EventConstructor.release = releasePooledEvent; } @@ -1154,95 +1545,6 @@ function accumulate(current, next) { return [current, next]; } -/** - * Accumulates items that must not be null or undefined into the first one. This - * is used to conserve memory by avoiding array allocations, and thus sacrifices - * API cleanness. Since `current` can be null before being passed in and not - * null after this function, make sure to assign it back to `current`: - * - * `a = accumulateInto(a, b);` - * - * This API should be sparingly used. Try `accumulate` for something cleaner. - * - * @return {*|array<*>} An accumulation of items. - */ - -function accumulateInto(current, next) { - if (!(next != null)) { - throw Error( - "accumulateInto(...): Accumulated items must not be null or undefined." - ); - } - - if (current == null) { - return next; - } // Both are not empty. Warning: Never call x.concat(y) when you are not - // certain that x is an Array (x could be a string with concat method). - - if (Array.isArray(current)) { - if (Array.isArray(next)) { - current.push.apply(current, next); - return current; - } - - current.push(next); - return current; - } - - if (Array.isArray(next)) { - // A bit too dangerous to mutate `next`. - return [current].concat(next); - } - - return [current, next]; -} - -/** - * @param {array} arr an "accumulation" of items which is either an Array or - * a single item. Useful when paired with the `accumulate` module. This is a - * simple utility that allows us to reason about a collection of items, but - * handling the case when there is exactly one item (and we do not need to - * allocate an array). - * @param {function} cb Callback invoked with each element or a collection. - * @param {?} [scope] Scope used as `this` in a callback. - */ -function forEachAccumulated(arr, cb, scope) { - if (Array.isArray(arr)) { - arr.forEach(cb, scope); - } else if (arr) { - cb.call(scope, arr); - } -} - -var FunctionComponent = 0; -var ClassComponent = 1; -var IndeterminateComponent = 2; // Before we know whether it is function or class - -var HostRoot = 3; // Root of a host tree. Could be nested inside another node. - -var HostPortal = 4; // A subtree. Could be an entry point to a different renderer. - -var HostComponent = 5; -var HostText = 6; -var Fragment = 7; -var Mode = 8; -var ContextConsumer = 9; -var ContextProvider = 10; -var ForwardRef = 11; -var Profiler = 12; -var SuspenseComponent = 13; -var MemoComponent = 14; -var SimpleMemoComponent = 15; -var LazyComponent = 16; -var IncompleteClassComponent = 17; -var DehydratedFragment = 18; -var SuspenseListComponent = 19; -var FundamentalComponent = 20; -var ScopeComponent = 21; -var Block = 22; -var OffscreenComponent = 23; -var LegacyHiddenComponent = 24; - /** * Instance of element that should respond to touch/move types of interactions, * as indicated explicitly by relevant callbacks. @@ -1361,215 +1663,7 @@ var eventTypes = { registrationName: "onResponderTerminate", dependencies: [] } -}; // Start of inline: the below functions were inlined from -// EventPropagator.js, as they deviated from ReactDOM's newer -// implementations. - -function getParent(inst) { - do { - inst = inst.return; // TODO: If this is a HostRoot we might want to bail out. - // That is depending on if we want nested subtrees (layers) to bubble - // events to their parent. We could also go through parentNode on the - // host node but that wouldn't work for React Native and doesn't let us - // do the portal feature. - } while (inst && inst.tag !== HostComponent); - - if (inst) { - return inst; - } - - return null; -} -/** - * Return the lowest common ancestor of A and B, or null if they are in - * different trees. - */ - -function getLowestCommonAncestor(instA, instB) { - var depthA = 0; - - for (var tempA = instA; tempA; tempA = getParent(tempA)) { - depthA++; - } - - var depthB = 0; - - for (var tempB = instB; tempB; tempB = getParent(tempB)) { - depthB++; - } // If A is deeper, crawl up. - - while (depthA - depthB > 0) { - instA = getParent(instA); - depthA--; - } // If B is deeper, crawl up. - - while (depthB - depthA > 0) { - instB = getParent(instB); - depthB--; - } // Walk in lockstep until we find a match. - - var depth = depthA; - - while (depth--) { - if (instA === instB || instA === instB.alternate) { - return instA; - } - - instA = getParent(instA); - instB = getParent(instB); - } - - return null; -} -/** - * Return if A is an ancestor of B. - */ - -function isAncestor(instA, instB) { - while (instB) { - if (instA === instB || instA === instB.alternate) { - return true; - } - - instB = getParent(instB); - } - - return false; -} -/** - * Simulates the traversal of a two-phase, capture/bubble event dispatch. - */ - -function traverseTwoPhase(inst, fn, arg) { - var path = []; - - while (inst) { - path.push(inst); - inst = getParent(inst); - } - - var i; - - for (i = path.length; i-- > 0; ) { - fn(path[i], "captured", arg); - } - - for (i = 0; i < path.length; i++) { - fn(path[i], "bubbled", arg); - } -} - -function getListener(inst, registrationName) { - var stateNode = inst.stateNode; - - if (stateNode === null) { - // Work in progress (ex: onload events in incremental mode). - return null; - } - - var props = getFiberCurrentPropsFromNode(stateNode); - - if (props === null) { - // Work in progress. - return null; - } - - var listener = props[registrationName]; - - if (!(!listener || typeof listener === "function")) { - throw Error( - "Expected `" + - registrationName + - "` listener to be a function, instead got a value of `" + - typeof listener + - "` type." - ); - } - - return listener; -} - -function listenerAtPhase(inst, event, propagationPhase) { - var registrationName = - event.dispatchConfig.phasedRegistrationNames[propagationPhase]; - return getListener(inst, registrationName); -} - -function accumulateDirectionalDispatches(inst, phase, event) { - { - if (!inst) { - error("Dispatching inst must not be null"); - } - } - - var listener = listenerAtPhase(inst, event, phase); - - if (listener) { - event._dispatchListeners = accumulateInto( - event._dispatchListeners, - listener - ); - event._dispatchInstances = accumulateInto(event._dispatchInstances, inst); - } -} -/** - * Accumulates without regard to direction, does not look for phased - * registration names. Same as `accumulateDirectDispatchesSingle` but without - * requiring that the `dispatchMarker` be the same as the dispatched ID. - */ - -function accumulateDispatches(inst, ignoredDirection, event) { - if (inst && event && event.dispatchConfig.registrationName) { - var registrationName = event.dispatchConfig.registrationName; - var listener = getListener(inst, registrationName); - - if (listener) { - event._dispatchListeners = accumulateInto( - event._dispatchListeners, - listener - ); - event._dispatchInstances = accumulateInto(event._dispatchInstances, inst); - } - } -} -/** - * Accumulates dispatches on an `SyntheticEvent`, but only for the - * `dispatchMarker`. - * @param {SyntheticEvent} event - */ - -function accumulateDirectDispatchesSingle(event) { - if (event && event.dispatchConfig.registrationName) { - accumulateDispatches(event._targetInst, null, event); - } -} - -function accumulateDirectDispatches(events) { - forEachAccumulated(events, accumulateDirectDispatchesSingle); -} - -function accumulateTwoPhaseDispatchesSingleSkipTarget(event) { - if (event && event.dispatchConfig.phasedRegistrationNames) { - var targetInst = event._targetInst; - var parentInst = targetInst ? getParent(targetInst) : null; - traverseTwoPhase(parentInst, accumulateDirectionalDispatches, event); - } -} - -function accumulateTwoPhaseDispatchesSkipTarget(events) { - forEachAccumulated(events, accumulateTwoPhaseDispatchesSingleSkipTarget); -} - -function accumulateTwoPhaseDispatchesSingle(event) { - if (event && event.dispatchConfig.phasedRegistrationNames) { - traverseTwoPhase(event._targetInst, accumulateDirectionalDispatches, event); - } -} - -function accumulateTwoPhaseDispatches(events) { - forEachAccumulated(events, accumulateTwoPhaseDispatchesSingle); -} // End of inline - +}; /** * * Responder System: @@ -2257,163 +2351,20 @@ function injectEventPluginsByName(injectedNamesToPlugins) { } } -function getListener$1(inst, registrationName) { - var stateNode = inst.stateNode; - - if (stateNode === null) { - // Work in progress (ex: onload events in incremental mode). - return null; - } - - var props = getFiberCurrentPropsFromNode(stateNode); - - if (props === null) { - // Work in progress. - return null; - } - - var listener = props[registrationName]; - - if (!(!listener || typeof listener === "function")) { - throw Error( - "Expected `" + - registrationName + - "` listener to be a function, instead got a value of `" + - typeof listener + - "` type." - ); - } - - return listener; -} - var customBubblingEventTypes = ReactNativePrivateInterface.ReactNativeViewConfigRegistry .customBubblingEventTypes, customDirectEventTypes = ReactNativePrivateInterface.ReactNativeViewConfigRegistry - .customDirectEventTypes; // Start of inline: the below functions were inlined from -// EventPropagator.js, as they deviated from ReactDOM's newer -// implementations. - -function listenerAtPhase$1(inst, event, propagationPhase) { - var registrationName = - event.dispatchConfig.phasedRegistrationNames[propagationPhase]; - return getListener$1(inst, registrationName); -} - -function accumulateDirectionalDispatches$1(inst, phase, event) { - { - if (!inst) { - error("Dispatching inst must not be null"); - } - } - - var listener = listenerAtPhase$1(inst, event, phase); - - if (listener) { - event._dispatchListeners = accumulateInto( - event._dispatchListeners, - listener - ); - event._dispatchInstances = accumulateInto(event._dispatchInstances, inst); - } -} - -function getParent$1(inst) { - do { - inst = inst.return; // TODO: If this is a HostRoot we might want to bail out. - // That is depending on if we want nested subtrees (layers) to bubble - // events to their parent. We could also go through parentNode on the - // host node but that wouldn't work for React Native and doesn't let us - // do the portal feature. - } while (inst && inst.tag !== HostComponent); - - if (inst) { - return inst; - } - - return null; -} -/** - * Simulates the traversal of a two-phase, capture/bubble event dispatch. - */ - -function traverseTwoPhase$1(inst, fn, arg) { - var path = []; - - while (inst) { - path.push(inst); - inst = getParent$1(inst); - } - - var i; - - for (i = path.length; i-- > 0; ) { - fn(path[i], "captured", arg); - } - - for (i = 0; i < path.length; i++) { - fn(path[i], "bubbled", arg); - } -} - -function accumulateTwoPhaseDispatchesSingle$1(event) { - if (event && event.dispatchConfig.phasedRegistrationNames) { - traverseTwoPhase$1( - event._targetInst, - accumulateDirectionalDispatches$1, - event - ); - } -} - -function accumulateTwoPhaseDispatches$1(events) { - forEachAccumulated(events, accumulateTwoPhaseDispatchesSingle$1); -} -/** - * Accumulates without regard to direction, does not look for phased - * registration names. Same as `accumulateDirectDispatchesSingle` but without - * requiring that the `dispatchMarker` be the same as the dispatched ID. - */ - -function accumulateDispatches$1(inst, ignoredDirection, event) { - if (inst && event && event.dispatchConfig.registrationName) { - var registrationName = event.dispatchConfig.registrationName; - var listener = getListener$1(inst, registrationName); - - if (listener) { - event._dispatchListeners = accumulateInto( - event._dispatchListeners, - listener - ); - event._dispatchInstances = accumulateInto(event._dispatchInstances, inst); - } - } -} -/** - * Accumulates dispatches on an `SyntheticEvent`, but only for the - * `dispatchMarker`. - * @param {SyntheticEvent} event - */ - -function accumulateDirectDispatchesSingle$1(event) { - if (event && event.dispatchConfig.registrationName) { - accumulateDispatches$1(event._targetInst, null, event); - } -} - -function accumulateDirectDispatches$1(events) { - forEachAccumulated(events, accumulateDirectDispatchesSingle$1); -} // End of inline - + .customDirectEventTypes; var ReactNativeBridgeEventPlugin = { eventTypes: {}, extractEvents: function( topLevelType, targetInst, nativeEvent, - nativeEventTarget + nativeEventTarget, + eventSystemFlags ) { if (targetInst == null) { // Probably a node belonging to another renderer's tree. @@ -2437,9 +2388,9 @@ var ReactNativeBridgeEventPlugin = { ); if (bubbleDispatchConfig) { - accumulateTwoPhaseDispatches$1(event); + accumulateTwoPhaseDispatches(event); } else if (directDispatchConfig) { - accumulateDirectDispatches$1(event); + accumulateDirectDispatches(event); } else { return null; } @@ -2510,16 +2461,23 @@ function updateFiberProps(tag, props) { instanceProps.set(tag, props); } -// Used as a way to call batchedUpdates when we don't have a reference to +var PLUGIN_EVENT_SYSTEM = 1; + +var enableProfilerTimer = true; +var enableFundamentalAPI = false; +var warnAboutStringRefs = false; + // the renderer. Such as when we're dispatching events or if third party // libraries need to call batchedUpdates. Eventually, this API will go away when // everything is batched by default. We'll then have a similar API to opt-out of // scheduled work and instead do synchronous work. // Defaults + var batchedUpdatesImpl = function(fn, bookkeeping) { return fn(bookkeeping); }; var isInsideEventHandler = false; + function batchedUpdates(fn, bookkeeping) { if (isInsideEventHandler) { // If we are currently inside another batch, we need to wait until it @@ -2677,7 +2635,13 @@ function _receiveRootNodeIDEvent(rootNodeID, topLevelType, nativeEventParam) { } batchedUpdates(function() { - runExtractedPluginEventsInBatch(topLevelType, inst, nativeEvent, target); + runExtractedPluginEventsInBatch( + topLevelType, + inst, + nativeEvent, + target, + PLUGIN_EVENT_SYSTEM + ); }); // React Native doesn't use ReactControlledComponent but if it did, here's // where it would do it. } @@ -2693,21 +2657,22 @@ function extractPluginEvents( topLevelType, targetInst, nativeEvent, - nativeEventTarget + nativeEventTarget, + eventSystemFlags ) { var events = null; - var legacyPlugins = plugins; - for (var i = 0; i < legacyPlugins.length; i++) { + for (var i = 0; i < plugins.length; i++) { // Not every plugin in the ordering may be loaded at runtime. - var possiblePlugin = legacyPlugins[i]; + var possiblePlugin = plugins[i]; if (possiblePlugin) { var extractedEvents = possiblePlugin.extractEvents( topLevelType, targetInst, nativeEvent, - nativeEventTarget + nativeEventTarget, + eventSystemFlags ); if (extractedEvents) { @@ -2723,13 +2688,15 @@ function runExtractedPluginEventsInBatch( topLevelType, targetInst, nativeEvent, - nativeEventTarget + nativeEventTarget, + eventSystemFlags ) { var events = extractPluginEvents( topLevelType, targetInst, nativeEvent, - nativeEventTarget + nativeEventTarget, + eventSystemFlags ); runEventsInBatch(events); } @@ -2842,64 +2809,37 @@ ResponderEventPlugin.injection.injectGlobalResponderHandler( * If this becomes an actual Map, that will break. */ function get(key) { - return key._reactInternals; + return key._reactInternalFiber; } function set(key, value) { - key._reactInternals = value; + key._reactInternalFiber = value; } -// ATTENTION -// When adding new symbols to this file, -// Please consider also adding to 'react-devtools-shared/src/backend/ReactSymbols' // The Symbol used to tag the ReactElement-like types. If there is no native Symbol // nor polyfill, then a plain number is used for performance. -var REACT_ELEMENT_TYPE = 0xeac7; -var REACT_PORTAL_TYPE = 0xeaca; -var REACT_FRAGMENT_TYPE = 0xeacb; -var REACT_STRICT_MODE_TYPE = 0xeacc; -var REACT_PROFILER_TYPE = 0xead2; -var REACT_PROVIDER_TYPE = 0xeacd; -var REACT_CONTEXT_TYPE = 0xeace; -var REACT_FORWARD_REF_TYPE = 0xead0; -var REACT_SUSPENSE_TYPE = 0xead1; -var REACT_SUSPENSE_LIST_TYPE = 0xead8; -var REACT_MEMO_TYPE = 0xead3; -var REACT_LAZY_TYPE = 0xead4; -var REACT_BLOCK_TYPE = 0xead9; -var REACT_SERVER_BLOCK_TYPE = 0xeada; -var REACT_FUNDAMENTAL_TYPE = 0xead5; -var REACT_RESPONDER_TYPE = 0xead6; -var REACT_SCOPE_TYPE = 0xead7; -var REACT_OPAQUE_ID_TYPE = 0xeae0; -var REACT_DEBUG_TRACING_MODE_TYPE = 0xeae1; -var REACT_OFFSCREEN_TYPE = 0xeae2; -var REACT_LEGACY_HIDDEN_TYPE = 0xeae3; - -if (typeof Symbol === "function" && Symbol.for) { - var symbolFor = Symbol.for; - REACT_ELEMENT_TYPE = symbolFor("react.element"); - REACT_PORTAL_TYPE = symbolFor("react.portal"); - REACT_FRAGMENT_TYPE = symbolFor("react.fragment"); - REACT_STRICT_MODE_TYPE = symbolFor("react.strict_mode"); - REACT_PROFILER_TYPE = symbolFor("react.profiler"); - REACT_PROVIDER_TYPE = symbolFor("react.provider"); - REACT_CONTEXT_TYPE = symbolFor("react.context"); - REACT_FORWARD_REF_TYPE = symbolFor("react.forward_ref"); - REACT_SUSPENSE_TYPE = symbolFor("react.suspense"); - REACT_SUSPENSE_LIST_TYPE = symbolFor("react.suspense_list"); - REACT_MEMO_TYPE = symbolFor("react.memo"); - REACT_LAZY_TYPE = symbolFor("react.lazy"); - REACT_BLOCK_TYPE = symbolFor("react.block"); - REACT_SERVER_BLOCK_TYPE = symbolFor("react.server.block"); - REACT_FUNDAMENTAL_TYPE = symbolFor("react.fundamental"); - REACT_RESPONDER_TYPE = symbolFor("react.responder"); - REACT_SCOPE_TYPE = symbolFor("react.scope"); - REACT_OPAQUE_ID_TYPE = symbolFor("react.opaque.id"); - REACT_DEBUG_TRACING_MODE_TYPE = symbolFor("react.debug_trace_mode"); - REACT_OFFSCREEN_TYPE = symbolFor("react.offscreen"); - REACT_LEGACY_HIDDEN_TYPE = symbolFor("react.legacy_hidden"); -} - +var hasSymbol = typeof Symbol === "function" && Symbol.for; +var REACT_ELEMENT_TYPE = hasSymbol ? Symbol.for("react.element") : 0xeac7; +var REACT_PORTAL_TYPE = hasSymbol ? Symbol.for("react.portal") : 0xeaca; +var REACT_FRAGMENT_TYPE = hasSymbol ? Symbol.for("react.fragment") : 0xeacb; +var REACT_STRICT_MODE_TYPE = hasSymbol + ? Symbol.for("react.strict_mode") + : 0xeacc; +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; // TODO: We don't use AsyncMode or ConcurrentMode anymore. They were temporary +var REACT_CONCURRENT_MODE_TYPE = hasSymbol + ? Symbol.for("react.concurrent_mode") + : 0xeacf; +var REACT_FORWARD_REF_TYPE = hasSymbol + ? Symbol.for("react.forward_ref") + : 0xead0; +var REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for("react.suspense") : 0xead1; +var REACT_SUSPENSE_LIST_TYPE = hasSymbol + ? Symbol.for("react.suspense_list") + : 0xead8; +var REACT_MEMO_TYPE = hasSymbol ? Symbol.for("react.memo") : 0xead3; +var REACT_LAZY_TYPE = hasSymbol ? Symbol.for("react.lazy") : 0xead4; +var REACT_BLOCK_TYPE = hasSymbol ? Symbol.for("react.block") : 0xead9; var MAYBE_ITERATOR_SYMBOL = typeof Symbol === "function" && Symbol.iterator; var FAUX_ITERATOR_SYMBOL = "@@iterator"; function getIteratorFn(maybeIterable) { @@ -2918,6 +2858,63 @@ function getIteratorFn(maybeIterable) { return null; } +// TODO: Move this to "react" once we can import from externals. +var Uninitialized = -1; +var Pending = 0; +var Resolved = 1; +var Rejected = 2; + +function refineResolvedLazyComponent(lazyComponent) { + return lazyComponent._status === Resolved ? lazyComponent._result : null; +} +function initializeLazyComponentType(lazyComponent) { + if (lazyComponent._status === Uninitialized) { + var ctor = lazyComponent._result; + + if (!ctor) { + // TODO: Remove this later. THis only exists in case you use an older "react" package. + ctor = lazyComponent._ctor; + } + + var thenable = ctor(); // Transition to the next state. + + var pending = lazyComponent; + pending._status = Pending; + pending._result = thenable; + thenable.then( + function(moduleObject) { + if (lazyComponent._status === Pending) { + var defaultExport = moduleObject.default; + + { + if (defaultExport === undefined) { + error( + "lazy: Expected the result of a dynamic import() call. " + + "Instead received: %s\n\nYour code should look like: \n " + // Break up imports to avoid accidentally parsing them as dependencies. + "const MyComponent = lazy(() => imp" + + "ort('./MyComponent'))", + moduleObject + ); + } + } // Transition to the next state. + + var resolved = lazyComponent; + resolved._status = Resolved; + resolved._result = defaultExport; + } + }, + function(error) { + if (lazyComponent._status === Pending) { + // Transition to the next state. + var rejected = lazyComponent; + rejected._status = Rejected; + rejected._result = error; + } + } + ); + } +} + function getWrappedName(outerType, innerType, wrapperName) { var functionName = innerType.displayName || innerType.name || ""; return ( @@ -2990,18 +2987,17 @@ function getComponentName(type) { return getComponentName(type.type); case REACT_BLOCK_TYPE: - return getComponentName(type._render); + return getComponentName(type.render); case REACT_LAZY_TYPE: { - var lazyComponent = type; - var payload = lazyComponent._payload; - var init = lazyComponent._init; + var thenable = type; + var resolvedThenable = refineResolvedLazyComponent(thenable); - try { - return getComponentName(init(payload)); - } catch (x) { - return null; + if (resolvedThenable) { + return getComponentName(resolvedThenable); } + + break; } } } @@ -3011,76 +3007,62 @@ function getComponentName(type) { // Don't change these two values. They're used by React Dev Tools. var NoEffect = - /* */ + /* */ 0; var PerformedWork = - /* */ + /* */ 1; // You can change the rest (and add more). var Placement = - /* */ + /* */ 2; var Update = - /* */ + /* */ 4; var PlacementAndUpdate = - /* */ + /* */ 6; var Deletion = - /* */ + /* */ 8; var ContentReset = - /* */ + /* */ 16; var Callback = - /* */ + /* */ 32; var DidCapture = - /* */ + /* */ 64; var Ref = - /* */ + /* */ 128; var Snapshot = - /* */ + /* */ 256; var Passive = - /* */ - 512; // TODO (effects) Remove this bit once the new reconciler is synced to the old. - -var PassiveUnmountPendingDev = - /* */ - 8192; + /* */ + 512; var Hydrating = - /* */ + /* */ 1024; var HydratingAndUpdate = - /* */ + /* */ 1028; // Passive & Update & Callback & Ref & Snapshot var LifecycleEffectMask = - /* */ + /* */ 932; // Union of all host effects var HostEffectMask = - /* */ - 2047; // These are not really side effects, but we still reuse this field. - + /* */ + 2047; var Incomplete = - /* */ + /* */ 2048; var ShouldCapture = - /* */ + /* */ 4096; -var ForceUpdateForLegacySuspense = - /* */ - 16384; // Static tags describe aspects of a fiber that are not specific to a render, - -// The rest of the flags are static for better dead code elimination. -var enableProfilerTimer = true; -var enableFundamentalAPI = false; -var warnAboutStringRefs = false; -var enableNewReconciler = false; var ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner; function getNearestMountedFiber(fiber) { @@ -3355,20 +3337,6 @@ function findCurrentHostFiber(parent) { return null; } -function doesFiberContain(parentFiber, childFiber) { - var node = childFiber; - var parentFiberAlternate = parentFiber.alternate; - - while (node !== null) { - if (node === parentFiber || node === parentFiberAlternate) { - return true; - } - - node = node.return; - } - - return false; -} // Modules provided by RN: var emptyObject = {}; @@ -4135,7 +4103,6 @@ function getPublicInstance(instance) { } function prepareForCommit(containerInfo) { // Noop - return null; } function prepareUpdate( instance, @@ -4153,6 +4120,9 @@ function resetAfterCommit(containerInfo) { var scheduleTimeout = setTimeout; var cancelTimeout = clearTimeout; var noTimeout = -1; +function shouldDeprioritizeSubtree(type, props) { + return false; +} function shouldSetTextContent(type, props) { // TODO (bvaughn) Revisit this decision. // Always returning false simplifies the createInstance() implementation, @@ -4335,263 +4305,12 @@ function unhideInstance(instance, props) { updatePayload ); } -function clearContainer(container) { - // TODO Implement this for React Native - // UIManager does not expose a "remove all" type method. -} function unhideTextInstance(textInstance, text) { throw new Error("Not yet implemented."); } -function makeClientIdInDEV(warnOnAccessInDEV) { - throw new Error("Not yet implemented"); -} -function preparePortalMount(portalInstance) { - // noop -} - -// Helpers to patch console.logs to avoid logging during side-effect free -// replaying on render function. This currently only patches the object -// lazily which won't cover if the log function was extracted eagerly. -// We could also eagerly patch the method. -var disabledDepth = 0; -var prevLog; -var prevInfo; -var prevWarn; -var prevError; -var prevGroup; -var prevGroupCollapsed; -var prevGroupEnd; - -function disabledLog() {} - -disabledLog.__reactDisabledLog = true; -function disableLogs() { - { - if (disabledDepth === 0) { - /* eslint-disable react-internal/no-production-logging */ - prevLog = console.log; - prevInfo = console.info; - prevWarn = console.warn; - prevError = console.error; - prevGroup = console.group; - prevGroupCollapsed = console.groupCollapsed; - prevGroupEnd = console.groupEnd; // https://github.com/facebook/react/issues/19099 - - var props = { - configurable: true, - enumerable: true, - value: disabledLog, - writable: true - }; // $FlowFixMe Flow thinks console is immutable. - - Object.defineProperties(console, { - info: props, - log: props, - warn: props, - error: props, - group: props, - groupCollapsed: props, - groupEnd: props - }); - /* eslint-enable react-internal/no-production-logging */ - } - - disabledDepth++; - } -} -function reenableLogs() { - { - disabledDepth--; - - if (disabledDepth === 0) { - /* eslint-disable react-internal/no-production-logging */ - var props = { - configurable: true, - enumerable: true, - writable: true - }; // $FlowFixMe Flow thinks console is immutable. - - Object.defineProperties(console, { - log: Object.assign({}, props, { - value: prevLog - }), - info: Object.assign({}, props, { - value: prevInfo - }), - warn: Object.assign({}, props, { - value: prevWarn - }), - error: Object.assign({}, props, { - value: prevError - }), - group: Object.assign({}, props, { - value: prevGroup - }), - groupCollapsed: Object.assign({}, props, { - value: prevGroupCollapsed - }), - groupEnd: Object.assign({}, props, { - value: prevGroupEnd - }) - }); - /* eslint-enable react-internal/no-production-logging */ - } - - if (disabledDepth < 0) { - error( - "disabledDepth fell below zero. " + - "This is a bug in React. Please file an issue." - ); - } - } -} - -var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher; -function describeBuiltInComponentFrame(name, source, ownerFn) { - { - var ownerName = null; - - if (ownerFn) { - ownerName = ownerFn.displayName || ownerFn.name || null; - } - - return describeComponentFrame(name, source, ownerName); - } -} -var componentFrameCache; - -{ - var PossiblyWeakMap = typeof WeakMap === "function" ? WeakMap : Map; - componentFrameCache = new PossiblyWeakMap(); -} -var BEFORE_SLASH_RE = /^(.*)[\\\/]/; - -function describeComponentFrame(name, source, ownerName) { - var sourceInfo = ""; - - if (source) { - var path = source.fileName; - var fileName = path.replace(BEFORE_SLASH_RE, ""); // In DEV, include code for a common special case: - // prefer "folder/index.js" instead of just "index.js". - - if (/^index\./.test(fileName)) { - var match = path.match(BEFORE_SLASH_RE); - - if (match) { - var pathBeforeSlash = match[1]; - - if (pathBeforeSlash) { - var folderName = pathBeforeSlash.replace(BEFORE_SLASH_RE, ""); - fileName = folderName + "/" + fileName; - } - } - } - - sourceInfo = " (at " + fileName + ":" + source.lineNumber + ")"; - } else if (ownerName) { - sourceInfo = " (created by " + ownerName + ")"; - } - - return "\n in " + (name || "Unknown") + sourceInfo; -} - -function describeClassComponentFrame(ctor, source, ownerFn) { - { - return describeFunctionComponentFrame(ctor, source, ownerFn); - } -} -function describeFunctionComponentFrame(fn, source, ownerFn) { - { - if (!fn) { - return ""; - } - - var name = fn.displayName || fn.name || null; - var ownerName = null; - - if (ownerFn) { - ownerName = ownerFn.displayName || ownerFn.name || null; - } - - return describeComponentFrame(name, source, ownerName); - } -} - -function describeUnknownElementTypeFrameInDEV(type, source, ownerFn) { - if (type == null) { - return ""; - } - - if (typeof type === "function") { - { - return describeFunctionComponentFrame(type, source, ownerFn); - } - } - - if (typeof type === "string") { - return describeBuiltInComponentFrame(type, source, ownerFn); - } - - switch (type) { - case REACT_SUSPENSE_TYPE: - return describeBuiltInComponentFrame("Suspense", source, ownerFn); - - case REACT_SUSPENSE_LIST_TYPE: - return describeBuiltInComponentFrame("SuspenseList", source, ownerFn); - } - - if (typeof type === "object") { - switch (type.$$typeof) { - case REACT_FORWARD_REF_TYPE: - return describeFunctionComponentFrame(type.render, source, ownerFn); - - case REACT_MEMO_TYPE: - // Memo may contain any component type so we recursively resolve it. - return describeUnknownElementTypeFrameInDEV(type.type, source, ownerFn); - - case REACT_BLOCK_TYPE: - return describeFunctionComponentFrame(type._render, source, ownerFn); - - case REACT_LAZY_TYPE: { - var lazyComponent = type; - var payload = lazyComponent._payload; - var init = lazyComponent._init; - - try { - // Lazy may contain any component type so we recursively resolve it. - return describeUnknownElementTypeFrameInDEV( - init(payload), - source, - ownerFn - ); - } catch (x) {} - } - } - } - - return ""; -} var loggedTypeFailures = {}; -var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame; - -function setCurrentlyValidatingElement(element) { - { - if (element) { - var owner = element._owner; - var stack = describeUnknownElementTypeFrameInDEV( - element.type, - element._source, - owner ? owner.type : null - ); - ReactDebugCurrentFrame.setExtraStackFrame(stack); - } else { - ReactDebugCurrentFrame.setExtraStackFrame(null); - } - } -} - -function checkPropTypes(typeSpecs, values, location, componentName, element) { +function checkPropTypes(typeSpecs, values, location, componentName) { { // $FlowFixMe This is okay but Flow doesn't know it. var has = Function.call.bind(Object.prototype.hasOwnProperty); @@ -4635,8 +4354,6 @@ function checkPropTypes(typeSpecs, values, location, componentName, element) { } if (error$1 && !(error$1 instanceof Error)) { - setCurrentlyValidatingElement(element); - error( "%s: type specification of %s" + " `%s` is invalid; the type checker " + @@ -4649,8 +4366,6 @@ function checkPropTypes(typeSpecs, values, location, componentName, element) { typeSpecName, typeof error$1 ); - - setCurrentlyValidatingElement(null); } if ( @@ -4660,17 +4375,458 @@ function checkPropTypes(typeSpecs, values, location, componentName, element) { // Only monitor this failure once because there tends to be a lot of the // same error. loggedTypeFailures[error$1.message] = true; - setCurrentlyValidatingElement(element); error("Failed %s type: %s", location, error$1.message); - - setCurrentlyValidatingElement(null); } } } } } +// Prefix measurements so that it's possible to filter them. +// Longer prefixes are hard to read in DevTools. +var reactEmoji = "\u269B"; +var warningEmoji = "\u26D4"; +var supportsUserTiming = + typeof performance !== "undefined" && + typeof performance.mark === "function" && + typeof performance.clearMarks === "function" && + typeof performance.measure === "function" && + typeof performance.clearMeasures === "function"; // Keep track of current fiber so that we know the path to unwind on pause. +// TODO: this looks the same as nextUnitOfWork in scheduler. Can we unify them? + +var currentFiber = null; // If we're in the middle of user code, which fiber and method is it? +// Reusing `currentFiber` would be confusing for this because user code fiber +// can change during commit phase too, but we don't need to unwind it (since +// lifecycles in the commit phase don't resemble a tree). + +var currentPhase = null; +var currentPhaseFiber = null; // Did lifecycle hook schedule an update? This is often a performance problem, +// so we will keep track of it, and include it in the report. +// Track commits caused by cascading updates. + +var isCommitting = false; +var hasScheduledUpdateInCurrentCommit = false; +var hasScheduledUpdateInCurrentPhase = false; +var commitCountInCurrentWorkLoop = 0; +var effectCountInCurrentCommit = 0; +// to avoid stretch the commit phase with measurement overhead. + +var labelsInCurrentCommit = new Set(); + +var formatMarkName = function(markName) { + return reactEmoji + " " + markName; +}; + +var formatLabel = function(label, warning) { + var prefix = warning ? warningEmoji + " " : reactEmoji + " "; + var suffix = warning ? " Warning: " + warning : ""; + return "" + prefix + label + suffix; +}; + +var beginMark = function(markName) { + performance.mark(formatMarkName(markName)); +}; + +var clearMark = function(markName) { + performance.clearMarks(formatMarkName(markName)); +}; + +var endMark = function(label, markName, warning) { + var formattedMarkName = formatMarkName(markName); + var formattedLabel = formatLabel(label, warning); + + try { + performance.measure(formattedLabel, formattedMarkName); + } catch (err) {} // If previous mark was missing for some reason, this will throw. + // This could only happen if React crashed in an unexpected place earlier. + // Don't pile on with more errors. + // Clear marks immediately to avoid growing buffer. + + performance.clearMarks(formattedMarkName); + performance.clearMeasures(formattedLabel); +}; + +var getFiberMarkName = function(label, debugID) { + return label + " (#" + debugID + ")"; +}; + +var getFiberLabel = function(componentName, isMounted, phase) { + if (phase === null) { + // These are composite component total time measurements. + return componentName + " [" + (isMounted ? "update" : "mount") + "]"; + } else { + // Composite component methods. + return componentName + "." + phase; + } +}; + +var beginFiberMark = function(fiber, phase) { + var componentName = getComponentName(fiber.type) || "Unknown"; + var debugID = fiber._debugID; + var isMounted = fiber.alternate !== null; + var label = getFiberLabel(componentName, isMounted, phase); + + if (isCommitting && labelsInCurrentCommit.has(label)) { + // During the commit phase, we don't show duplicate labels because + // there is a fixed overhead for every measurement, and we don't + // want to stretch the commit phase beyond necessary. + return false; + } + + labelsInCurrentCommit.add(label); + var markName = getFiberMarkName(label, debugID); + beginMark(markName); + return true; +}; + +var clearFiberMark = function(fiber, phase) { + var componentName = getComponentName(fiber.type) || "Unknown"; + var debugID = fiber._debugID; + var isMounted = fiber.alternate !== null; + var label = getFiberLabel(componentName, isMounted, phase); + var markName = getFiberMarkName(label, debugID); + clearMark(markName); +}; + +var endFiberMark = function(fiber, phase, warning) { + var componentName = getComponentName(fiber.type) || "Unknown"; + var debugID = fiber._debugID; + var isMounted = fiber.alternate !== null; + var label = getFiberLabel(componentName, isMounted, phase); + var markName = getFiberMarkName(label, debugID); + endMark(label, markName, warning); +}; + +var shouldIgnoreFiber = function(fiber) { + // Host components should be skipped in the timeline. + // We could check typeof fiber.type, but does this work with RN? + switch (fiber.tag) { + case HostRoot: + case HostComponent: + case HostText: + case HostPortal: + case Fragment: + case ContextProvider: + case ContextConsumer: + case Mode: + return true; + + default: + return false; + } +}; + +var clearPendingPhaseMeasurement = function() { + if (currentPhase !== null && currentPhaseFiber !== null) { + clearFiberMark(currentPhaseFiber, currentPhase); + } + + currentPhaseFiber = null; + currentPhase = null; + hasScheduledUpdateInCurrentPhase = false; +}; + +var pauseTimers = function() { + // Stops all currently active measurements so that they can be resumed + // if we continue in a later deferred loop from the same unit of work. + var fiber = currentFiber; + + while (fiber) { + if (fiber._debugIsCurrentlyTiming) { + endFiberMark(fiber, null, null); + } + + fiber = fiber.return; + } +}; + +var resumeTimersRecursively = function(fiber) { + if (fiber.return !== null) { + resumeTimersRecursively(fiber.return); + } + + if (fiber._debugIsCurrentlyTiming) { + beginFiberMark(fiber, null); + } +}; + +var resumeTimers = function() { + // Resumes all measurements that were active during the last deferred loop. + if (currentFiber !== null) { + resumeTimersRecursively(currentFiber); + } +}; + +function recordEffect() { + { + effectCountInCurrentCommit++; + } +} +function recordScheduleUpdate() { + { + if (isCommitting) { + hasScheduledUpdateInCurrentCommit = true; + } + + if ( + currentPhase !== null && + currentPhase !== "componentWillMount" && + currentPhase !== "componentWillReceiveProps" + ) { + hasScheduledUpdateInCurrentPhase = true; + } + } +} +function startWorkTimer(fiber) { + { + if (!supportsUserTiming || shouldIgnoreFiber(fiber)) { + return; + } // If we pause, this is the fiber to unwind from. + + currentFiber = fiber; + + if (!beginFiberMark(fiber, null)) { + return; + } + + fiber._debugIsCurrentlyTiming = true; + } +} +function cancelWorkTimer(fiber) { + { + if (!supportsUserTiming || shouldIgnoreFiber(fiber)) { + return; + } // Remember we shouldn't complete measurement for this fiber. + // Otherwise flamechart will be deep even for small updates. + + fiber._debugIsCurrentlyTiming = false; + clearFiberMark(fiber, null); + } +} +function stopWorkTimer(fiber) { + { + if (!supportsUserTiming || shouldIgnoreFiber(fiber)) { + return; + } // If we pause, its parent is the fiber to unwind from. + + currentFiber = fiber.return; + + if (!fiber._debugIsCurrentlyTiming) { + return; + } + + fiber._debugIsCurrentlyTiming = false; + endFiberMark(fiber, null, null); + } +} +function stopFailedWorkTimer(fiber) { + { + if (!supportsUserTiming || shouldIgnoreFiber(fiber)) { + return; + } // If we pause, its parent is the fiber to unwind from. + + currentFiber = fiber.return; + + if (!fiber._debugIsCurrentlyTiming) { + return; + } + + fiber._debugIsCurrentlyTiming = false; + var warning = + fiber.tag === SuspenseComponent + ? "Rendering was suspended" + : "An error was thrown inside this error boundary"; + endFiberMark(fiber, null, warning); + } +} +function startPhaseTimer(fiber, phase) { + { + if (!supportsUserTiming) { + return; + } + + clearPendingPhaseMeasurement(); + + if (!beginFiberMark(fiber, phase)) { + return; + } + + currentPhaseFiber = fiber; + currentPhase = phase; + } +} +function stopPhaseTimer() { + { + if (!supportsUserTiming) { + return; + } + + if (currentPhase !== null && currentPhaseFiber !== null) { + var warning = hasScheduledUpdateInCurrentPhase + ? "Scheduled a cascading update" + : null; + endFiberMark(currentPhaseFiber, currentPhase, warning); + } + + currentPhase = null; + currentPhaseFiber = null; + } +} +function startWorkLoopTimer(nextUnitOfWork) { + { + currentFiber = nextUnitOfWork; + + if (!supportsUserTiming) { + return; + } + + commitCountInCurrentWorkLoop = 0; // This is top level call. + // Any other measurements are performed within. + + beginMark("(React Tree Reconciliation)"); // Resume any measurements that were in progress during the last loop. + + resumeTimers(); + } +} +function stopWorkLoopTimer(interruptedBy, didCompleteRoot) { + { + if (!supportsUserTiming) { + return; + } + + var warning = null; + + if (interruptedBy !== null) { + if (interruptedBy.tag === HostRoot) { + warning = "A top-level update interrupted the previous render"; + } else { + var componentName = getComponentName(interruptedBy.type) || "Unknown"; + warning = + "An update to " + componentName + " interrupted the previous render"; + } + } else if (commitCountInCurrentWorkLoop > 1) { + warning = "There were cascading updates"; + } + + commitCountInCurrentWorkLoop = 0; + var label = didCompleteRoot + ? "(React Tree Reconciliation: Completed Root)" + : "(React Tree Reconciliation: Yielded)"; // Pause any measurements until the next loop. + + pauseTimers(); + endMark(label, "(React Tree Reconciliation)", warning); + } +} +function startCommitTimer() { + { + if (!supportsUserTiming) { + return; + } + + isCommitting = true; + hasScheduledUpdateInCurrentCommit = false; + labelsInCurrentCommit.clear(); + beginMark("(Committing Changes)"); + } +} +function stopCommitTimer() { + { + if (!supportsUserTiming) { + return; + } + + var warning = null; + + if (hasScheduledUpdateInCurrentCommit) { + warning = "Lifecycle hook scheduled a cascading update"; + } else if (commitCountInCurrentWorkLoop > 0) { + warning = "Caused by a cascading update in earlier commit"; + } + + hasScheduledUpdateInCurrentCommit = false; + commitCountInCurrentWorkLoop++; + isCommitting = false; + labelsInCurrentCommit.clear(); + endMark("(Committing Changes)", "(Committing Changes)", warning); + } +} +function startCommitSnapshotEffectsTimer() { + { + if (!supportsUserTiming) { + return; + } + + effectCountInCurrentCommit = 0; + beginMark("(Committing Snapshot Effects)"); + } +} +function stopCommitSnapshotEffectsTimer() { + { + if (!supportsUserTiming) { + return; + } + + var count = effectCountInCurrentCommit; + effectCountInCurrentCommit = 0; + endMark( + "(Committing Snapshot Effects: " + count + " Total)", + "(Committing Snapshot Effects)", + null + ); + } +} +function startCommitHostEffectsTimer() { + { + if (!supportsUserTiming) { + return; + } + + effectCountInCurrentCommit = 0; + beginMark("(Committing Host Effects)"); + } +} +function stopCommitHostEffectsTimer() { + { + if (!supportsUserTiming) { + return; + } + + var count = effectCountInCurrentCommit; + effectCountInCurrentCommit = 0; + endMark( + "(Committing Host Effects: " + count + " Total)", + "(Committing Host Effects)", + null + ); + } +} +function startCommitLifeCyclesTimer() { + { + if (!supportsUserTiming) { + return; + } + + effectCountInCurrentCommit = 0; + beginMark("(Calling Lifecycle Methods)"); + } +} +function stopCommitLifeCyclesTimer() { + { + if (!supportsUserTiming) { + return; + } + + var count = effectCountInCurrentCommit; + effectCountInCurrentCommit = 0; + endMark( + "(Calling Lifecycle Methods: " + count + " Total)", + "(Calling Lifecycle Methods)", + null + ); + } +} + var valueStack = []; var fiberStack; @@ -4874,7 +5030,10 @@ function processChildContext(fiber, type, parentContext) { return parentContext; } - var childContext = instance.getChildContext(); + var childContext; + startPhaseTimer(fiber, "getChildContext"); + childContext = instance.getChildContext(); + stopPhaseTimer(); for (var contextKey in childContext) { if (!(contextKey in childContextTypes)) { @@ -4995,897 +5154,13 @@ var LegacyRoot = 0; var BlockingRoot = 1; var ConcurrentRoot = 2; -var rendererID = null; -var injectedHook = null; -var hasLoggedError = false; -var isDevToolsPresent = typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== "undefined"; -function injectInternals(internals) { - if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ === "undefined") { - // No DevTools - return false; - } - - var hook = __REACT_DEVTOOLS_GLOBAL_HOOK__; - - if (hook.isDisabled) { - // This isn't a real property on the hook, but it can be set to opt out - // of DevTools integration and associated warnings and logs. - // https://github.com/facebook/react/issues/3877 - return true; - } - - if (!hook.supportsFiber) { - { - error( - "The installed version of React DevTools is too old and will not work " + - "with the current version of React. Please update React DevTools. " + - "https://fb.me/react-devtools" - ); - } // DevTools exists, even though it doesn't support Fiber. - - return true; - } - - try { - rendererID = hook.inject(internals); // We have successfully injected, so now it is safe to set up hooks. - - injectedHook = hook; - } catch (err) { - // Catch all errors because it is unsafe to throw during initialization. - { - error("React instrumentation encountered an error: %s.", err); - } - } // DevTools exists - - return true; -} -function onScheduleRoot(root, children) { - { - if ( - injectedHook && - typeof injectedHook.onScheduleFiberRoot === "function" - ) { - try { - injectedHook.onScheduleFiberRoot(rendererID, root, children); - } catch (err) { - if (!hasLoggedError) { - hasLoggedError = true; - - error("React instrumentation encountered an error: %s", err); - } - } - } - } -} -function onCommitRoot(root, priorityLevel) { - if (injectedHook && typeof injectedHook.onCommitFiberRoot === "function") { - try { - var didError = (root.current.effectTag & DidCapture) === DidCapture; - - if (enableProfilerTimer) { - injectedHook.onCommitFiberRoot( - rendererID, - root, - priorityLevel, - didError - ); - } else { - injectedHook.onCommitFiberRoot(rendererID, root, undefined, didError); - } - } catch (err) { - { - if (!hasLoggedError) { - hasLoggedError = true; - - error("React instrumentation encountered an error: %s", err); - } - } - } - } -} -function onCommitUnmount(fiber) { - if (injectedHook && typeof injectedHook.onCommitFiberUnmount === "function") { - try { - injectedHook.onCommitFiberUnmount(rendererID, fiber); - } catch (err) { - { - if (!hasLoggedError) { - hasLoggedError = true; - - error("React instrumentation encountered an error: %s", err); - } - } - } - } -} - -// Intentionally not named imports because Rollup would use dynamic dispatch for -var Scheduler_now = Scheduler.unstable_now; - -{ - // Provide explicit error message when production+profiling bundle of e.g. - // react-dom is used with production (non-profiling) bundle of - // scheduler/tracing - if ( - !( - tracing.__interactionsRef != null && - tracing.__interactionsRef.current != null - ) - ) { - throw Error( - "It is not supported to run the profiling version of a renderer (for example, `react-dom/profiling`) without also replacing the `scheduler/tracing` module with `scheduler/tracing-profiling`. Your bundler might have a setting for aliasing both modules. Learn more at http://fb.me/react-profiling" - ); - } -} -// ascending numbers so we can compare them like numbers. They start at 90 to -// avoid clashing with Scheduler's priorities. - -var ImmediatePriority = 99; -var UserBlockingPriority = 98; -var NormalPriority = 97; -var LowPriority = 96; -var IdlePriority = 95; // NoPriority is the absence of priority. Also React-only. - -var NoPriority = 90; -var initialTimeMs = Scheduler_now(); // If the initial timestamp is reasonably small, use Scheduler's `now` directly. - -var SyncLanePriority = 17; -var SyncBatchedLanePriority = 16; -var InputDiscreteHydrationLanePriority = 15; -var InputDiscreteLanePriority = 14; -var InputContinuousHydrationLanePriority = 13; -var InputContinuousLanePriority = 12; -var DefaultHydrationLanePriority = 11; -var DefaultLanePriority = 10; -var TransitionShortHydrationLanePriority = 9; -var TransitionShortLanePriority = 8; -var TransitionLongHydrationLanePriority = 7; -var TransitionLongLanePriority = 6; -var RetryLanePriority = 5; -var SelectiveHydrationLanePriority = 4; -var IdleHydrationLanePriority = 3; -var IdleLanePriority = 2; -var OffscreenLanePriority = 1; -var NoLanePriority = 0; -var TotalLanes = 31; -var NoLanes = - /* */ - 0; -var NoLane = - /* */ - 0; -var SyncLane = - /* */ - 1; -var SyncBatchedLane = - /* */ - 2; -var InputDiscreteHydrationLane = - /* */ - 4; -var InputDiscreteLanes = - /* */ - 24; -var InputContinuousHydrationLane = - /* */ - 32; -var InputContinuousLanes = - /* */ - 192; -var DefaultHydrationLane = - /* */ - 256; -var DefaultLanes = - /* */ - 3584; -var TransitionShortHydrationLane = - /* */ - 4096; -var TransitionShortLanes = - /* */ - 122880; -var TransitionLongHydrationLane = - /* */ - 131072; -var TransitionLongLanes = - /* */ - 3932160; -var RetryLanes = - /* */ - 62914560; -var SelectiveHydrationLane = - /* */ - 67108864; -var NonIdleLanes = - /* */ - 134217727; -var IdleHydrationLane = - /* */ - 134217728; -var IdleLanes = - /* */ - 805306368; -var OffscreenLane = - /* */ - 1073741824; -var NoTimestamp = -1; -function setCurrentUpdateLanePriority(newLanePriority) {} // "Registers" used to "return" multiple values -// Used by getHighestPriorityLanes and getNextLanes: - -var return_highestLanePriority = DefaultLanePriority; - -function getHighestPriorityLanes(lanes) { - if ((SyncLane & lanes) !== NoLanes) { - return_highestLanePriority = SyncLanePriority; - return SyncLane; - } - - if ((SyncBatchedLane & lanes) !== NoLanes) { - return_highestLanePriority = SyncBatchedLanePriority; - return SyncBatchedLane; - } - - if ((InputDiscreteHydrationLane & lanes) !== NoLanes) { - return_highestLanePriority = InputDiscreteHydrationLanePriority; - return InputDiscreteHydrationLane; - } - - var inputDiscreteLanes = InputDiscreteLanes & lanes; - - if (inputDiscreteLanes !== NoLanes) { - return_highestLanePriority = InputDiscreteLanePriority; - return inputDiscreteLanes; - } - - if ((lanes & InputContinuousHydrationLane) !== NoLanes) { - return_highestLanePriority = InputContinuousHydrationLanePriority; - return InputContinuousHydrationLane; - } - - var inputContinuousLanes = InputContinuousLanes & lanes; - - if (inputContinuousLanes !== NoLanes) { - return_highestLanePriority = InputContinuousLanePriority; - return inputContinuousLanes; - } - - if ((lanes & DefaultHydrationLane) !== NoLanes) { - return_highestLanePriority = DefaultHydrationLanePriority; - return DefaultHydrationLane; - } - - var defaultLanes = DefaultLanes & lanes; - - if (defaultLanes !== NoLanes) { - return_highestLanePriority = DefaultLanePriority; - return defaultLanes; - } - - if ((lanes & TransitionShortHydrationLane) !== NoLanes) { - return_highestLanePriority = TransitionShortHydrationLanePriority; - return TransitionShortHydrationLane; - } - - var transitionShortLanes = TransitionShortLanes & lanes; - - if (transitionShortLanes !== NoLanes) { - return_highestLanePriority = TransitionShortLanePriority; - return transitionShortLanes; - } - - if ((lanes & TransitionLongHydrationLane) !== NoLanes) { - return_highestLanePriority = TransitionLongHydrationLanePriority; - return TransitionLongHydrationLane; - } - - var transitionLongLanes = TransitionLongLanes & lanes; - - if (transitionLongLanes !== NoLanes) { - return_highestLanePriority = TransitionLongLanePriority; - return transitionLongLanes; - } - - var retryLanes = RetryLanes & lanes; - - if (retryLanes !== NoLanes) { - return_highestLanePriority = RetryLanePriority; - return retryLanes; - } - - if (lanes & SelectiveHydrationLane) { - return_highestLanePriority = SelectiveHydrationLanePriority; - return SelectiveHydrationLane; - } - - if ((lanes & IdleHydrationLane) !== NoLanes) { - return_highestLanePriority = IdleHydrationLanePriority; - return IdleHydrationLane; - } - - var idleLanes = IdleLanes & lanes; - - if (idleLanes !== NoLanes) { - return_highestLanePriority = IdleLanePriority; - return idleLanes; - } - - if ((OffscreenLane & lanes) !== NoLanes) { - return_highestLanePriority = OffscreenLanePriority; - return OffscreenLane; - } - - { - error("Should have found matching lanes. This is a bug in React."); - } // This shouldn't be reachable, but as a fallback, return the entire bitmask. - - return_highestLanePriority = DefaultLanePriority; - return lanes; -} - -function schedulerPriorityToLanePriority(schedulerPriorityLevel) { - switch (schedulerPriorityLevel) { - case ImmediatePriority: - return SyncLanePriority; - - case UserBlockingPriority: - return InputContinuousLanePriority; - - case NormalPriority: - case LowPriority: - // TODO: Handle LowSchedulerPriority, somehow. Maybe the same lane as hydration. - return DefaultLanePriority; - - case IdlePriority: - return IdleLanePriority; - - default: - return NoLanePriority; - } -} -function lanePriorityToSchedulerPriority(lanePriority) { - switch (lanePriority) { - case SyncLanePriority: - case SyncBatchedLanePriority: - return ImmediatePriority; - - case InputDiscreteHydrationLanePriority: - case InputDiscreteLanePriority: - case InputContinuousHydrationLanePriority: - case InputContinuousLanePriority: - return UserBlockingPriority; - - case DefaultHydrationLanePriority: - case DefaultLanePriority: - case TransitionShortHydrationLanePriority: - case TransitionShortLanePriority: - case TransitionLongHydrationLanePriority: - case TransitionLongLanePriority: - case SelectiveHydrationLanePriority: - case RetryLanePriority: - return NormalPriority; - - case IdleHydrationLanePriority: - case IdleLanePriority: - case OffscreenLanePriority: - return IdlePriority; - - case NoLanePriority: - return NoPriority; - - default: { - throw Error( - "Invalid update priority: " + lanePriority + ". This is a bug in React." - ); - } - } -} -function getNextLanes(root, wipLanes) { - // Early bailout if there's no pending work left. - var pendingLanes = root.pendingLanes; - - if (pendingLanes === NoLanes) { - return_highestLanePriority = NoLanePriority; - return NoLanes; - } - - var nextLanes = NoLanes; - var nextLanePriority = NoLanePriority; - var expiredLanes = root.expiredLanes; - var suspendedLanes = root.suspendedLanes; - var pingedLanes = root.pingedLanes; // Check if any work has expired. - - if (expiredLanes !== NoLanes) { - nextLanes = expiredLanes; - nextLanePriority = return_highestLanePriority = SyncLanePriority; - } else { - // Do not work on any idle work until all the non-idle work has finished, - // even if the work is suspended. - var nonIdlePendingLanes = pendingLanes & NonIdleLanes; - - if (nonIdlePendingLanes !== NoLanes) { - var nonIdleUnblockedLanes = nonIdlePendingLanes & ~suspendedLanes; - - if (nonIdleUnblockedLanes !== NoLanes) { - nextLanes = getHighestPriorityLanes(nonIdleUnblockedLanes); - nextLanePriority = return_highestLanePriority; - } else { - var nonIdlePingedLanes = nonIdlePendingLanes & pingedLanes; - - if (nonIdlePingedLanes !== NoLanes) { - nextLanes = getHighestPriorityLanes(nonIdlePingedLanes); - nextLanePriority = return_highestLanePriority; - } - } - } else { - // The only remaining work is Idle. - var unblockedLanes = pendingLanes & ~suspendedLanes; - - if (unblockedLanes !== NoLanes) { - nextLanes = getHighestPriorityLanes(unblockedLanes); - nextLanePriority = return_highestLanePriority; - } else { - if (pingedLanes !== NoLanes) { - nextLanes = getHighestPriorityLanes(pingedLanes); - nextLanePriority = return_highestLanePriority; - } - } - } - } - - if (nextLanes === NoLanes) { - // This should only be reachable if we're suspended - // TODO: Consider warning in this path if a fallback timer is not scheduled. - return NoLanes; - } // If there are higher priority lanes, we'll include them even if they - // are suspended. - - nextLanes = pendingLanes & getEqualOrHigherPriorityLanes(nextLanes); // If we're already in the middle of a render, switching lanes will interrupt - // it and we'll lose our progress. We should only do this if the new lanes are - // higher priority. - - if ( - wipLanes !== NoLanes && - wipLanes !== nextLanes && // If we already suspended with a delay, then interrupting is fine. Don't - // bother waiting until the root is complete. - (wipLanes & suspendedLanes) === NoLanes - ) { - getHighestPriorityLanes(wipLanes); - var wipLanePriority = return_highestLanePriority; - - if (nextLanePriority <= wipLanePriority) { - return wipLanes; - } else { - return_highestLanePriority = nextLanePriority; - } - } // Check for entangled lanes and add them to the batch. - // - // A lane is said to be entangled with another when it's not allowed to render - // in a batch that does not also include the other lane. Typically we do this - // when multiple updates have the same source, and we only want to respond to - // the most recent event from that source. - // - // Note that we apply entanglements *after* checking for partial work above. - // This means that if a lane is entangled during an interleaved event while - // it's already rendering, we won't interrupt it. This is intentional, since - // entanglement is usually "best effort": we'll try our best to render the - // lanes in the same batch, but it's not worth throwing out partially - // completed work in order to do it. - // - // For those exceptions where entanglement is semantically important, like - // useMutableSource, we should ensure that there is no partial work at the - // time we apply the entanglement. - - var entangledLanes = root.entangledLanes; - - if (entangledLanes !== NoLanes) { - var entanglements = root.entanglements; - var lanes = nextLanes & entangledLanes; - - while (lanes > 0) { - var index = pickArbitraryLaneIndex(lanes); - var lane = 1 << index; - nextLanes |= entanglements[index]; - lanes &= ~lane; - } - } - - return nextLanes; -} -function getMostRecentEventTime(root, lanes) { - var eventTimes = root.eventTimes; - var mostRecentEventTime = NoTimestamp; - - while (lanes > 0) { - var index = pickArbitraryLaneIndex(lanes); - var lane = 1 << index; - var eventTime = eventTimes[index]; - - if (eventTime > mostRecentEventTime) { - mostRecentEventTime = eventTime; - } - - lanes &= ~lane; - } - - return mostRecentEventTime; -} - -function computeExpirationTime(lane, currentTime) { - // TODO: Expiration heuristic is constant per lane, so could use a map. - getHighestPriorityLanes(lane); - var priority = return_highestLanePriority; - - if (priority >= InputContinuousLanePriority) { - // User interactions should expire slightly more quickly. - return currentTime + 1000; - } else if (priority >= TransitionLongLanePriority) { - return currentTime + 5000; - } else { - // Anything idle priority or lower should never expire. - return NoTimestamp; - } -} - -function markStarvedLanesAsExpired(root, currentTime) { - // TODO: This gets called every time we yield. We can optimize by storing - // the earliest expiration time on the root. Then use that to quickly bail out - // of this function. - var pendingLanes = root.pendingLanes; - var suspendedLanes = root.suspendedLanes; - var pingedLanes = root.pingedLanes; - var expirationTimes = root.expirationTimes; // Iterate through the pending lanes and check if we've reached their - // expiration time. If so, we'll assume the update is being starved and mark - // it as expired to force it to finish. - - var lanes = pendingLanes; - - while (lanes > 0) { - var index = pickArbitraryLaneIndex(lanes); - var lane = 1 << index; - var expirationTime = expirationTimes[index]; - - if (expirationTime === NoTimestamp) { - // Found a pending lane with no expiration time. If it's not suspended, or - // if it's pinged, assume it's CPU-bound. Compute a new expiration time - // using the current time. - if ( - (lane & suspendedLanes) === NoLanes || - (lane & pingedLanes) !== NoLanes - ) { - // Assumes timestamps are monotonically increasing. - expirationTimes[index] = computeExpirationTime(lane, currentTime); - } - } else if (expirationTime <= currentTime) { - // This lane expired - root.expiredLanes |= lane; - } - - lanes &= ~lane; - } -} // This returns the highest priority pending lanes regardless of whether they -function getLanesToRetrySynchronouslyOnError(root) { - var everythingButOffscreen = root.pendingLanes & ~OffscreenLane; - - if (everythingButOffscreen !== NoLanes) { - return everythingButOffscreen; - } - - if (everythingButOffscreen & OffscreenLane) { - return OffscreenLane; - } - - return NoLanes; -} -function returnNextLanesPriority() { - return return_highestLanePriority; -} -function includesNonIdleWork(lanes) { - return (lanes & NonIdleLanes) !== NoLanes; -} -function includesOnlyRetries(lanes) { - return (lanes & RetryLanes) === lanes; -} // To ensure consistency across multiple updates in the same event, this should -// be a pure function, so that it always returns the same lane for given inputs. - -function findUpdateLane(lanePriority, wipLanes) { - switch (lanePriority) { - case NoLanePriority: - break; - - case SyncLanePriority: - return SyncLane; - - case SyncBatchedLanePriority: - return SyncBatchedLane; - - case InputDiscreteLanePriority: { - var _lane = pickArbitraryLane(InputDiscreteLanes & ~wipLanes); - - if (_lane === NoLane) { - // Shift to the next priority level - return findUpdateLane(InputContinuousLanePriority, wipLanes); - } - - return _lane; - } - - case InputContinuousLanePriority: { - var _lane2 = pickArbitraryLane(InputContinuousLanes & ~wipLanes); - - if (_lane2 === NoLane) { - // Shift to the next priority level - return findUpdateLane(DefaultLanePriority, wipLanes); - } - - return _lane2; - } - - case DefaultLanePriority: { - var _lane3 = pickArbitraryLane(DefaultLanes & ~wipLanes); - - if (_lane3 === NoLane) { - // If all the default lanes are already being worked on, look for a - // lane in the transition range. - _lane3 = pickArbitraryLane( - (TransitionShortLanes | TransitionLongLanes) & ~wipLanes - ); - - if (_lane3 === NoLane) { - // All the transition lanes are taken, too. This should be very - // rare, but as a last resort, pick a default lane. This will have - // the effect of interrupting the current work-in-progress render. - _lane3 = pickArbitraryLane(DefaultLanes); - } - } - - return _lane3; - } - - case TransitionShortLanePriority: // Should be handled by findTransitionLane instead - - case TransitionLongLanePriority: - case RetryLanePriority: - // Should be handled by findRetryLane instead - break; - - case IdleLanePriority: - var lane = pickArbitraryLane(IdleLanes & ~wipLanes); - - if (lane === NoLane) { - lane = pickArbitraryLane(IdleLanes); - } - - return lane; - } - - { - throw Error( - "Invalid update priority: " + lanePriority + ". This is a bug in React." - ); - } -} // To ensure consistency across multiple updates in the same event, this should -// be pure function, so that it always returns the same lane for given inputs. - -function findTransitionLane(lanePriority, wipLanes, pendingLanes) { - if (lanePriority === TransitionShortLanePriority) { - // First look for lanes that are completely unclaimed, i.e. have no - // pending work. - var lane = pickArbitraryLane(TransitionShortLanes & ~pendingLanes); - - if (lane === NoLane) { - // If all lanes have pending work, look for a lane that isn't currently - // being worked on. - lane = pickArbitraryLane(TransitionShortLanes & ~wipLanes); - - if (lane === NoLane) { - // If everything is being worked on, pick any lane. This has the - // effect of interrupting the current work-in-progress. - lane = pickArbitraryLane(TransitionShortLanes); - } - } - - return lane; - } - - if (lanePriority === TransitionLongLanePriority) { - // First look for lanes that are completely unclaimed, i.e. have no - // pending work. - var _lane4 = pickArbitraryLane(TransitionLongLanes & ~pendingLanes); - - if (_lane4 === NoLane) { - // If all lanes have pending work, look for a lane that isn't currently - // being worked on. - _lane4 = pickArbitraryLane(TransitionLongLanes & ~wipLanes); - - if (_lane4 === NoLane) { - // If everything is being worked on, pick any lane. This has the - // effect of interrupting the current work-in-progress. - _lane4 = pickArbitraryLane(TransitionLongLanes); - } - } - - return _lane4; - } - - { - throw Error( - "Invalid transition priority: " + - lanePriority + - ". This is a bug in React." - ); - } -} // To ensure consistency across multiple updates in the same event, this should -// be pure function, so that it always returns the same lane for given inputs. - -function findRetryLane(wipLanes) { - // This is a fork of `findUpdateLane` designed specifically for Suspense - // "retries" — a special update that attempts to flip a Suspense boundary - // from its placeholder state to its primary/resolved state. - var lane = pickArbitraryLane(RetryLanes & ~wipLanes); - - if (lane === NoLane) { - lane = pickArbitraryLane(RetryLanes); - } - - return lane; -} - -function getHighestPriorityLane(lanes) { - return lanes & -lanes; -} - -function getLowestPriorityLane(lanes) { - // This finds the most significant non-zero bit. - var index = 31 - clz32(lanes); - return index < 0 ? NoLanes : 1 << index; -} - -function getEqualOrHigherPriorityLanes(lanes) { - return (getLowestPriorityLane(lanes) << 1) - 1; -} - -function pickArbitraryLane(lanes) { - // This wrapper function gets inlined. Only exists so to communicate that it - // doesn't matter which bit is selected; you can pick any bit without - // affecting the algorithms where its used. Here I'm using - // getHighestPriorityLane because it requires the fewest operations. - return getHighestPriorityLane(lanes); -} - -function pickArbitraryLaneIndex(lanes) { - return 31 - clz32(lanes); -} - -function laneToIndex(lane) { - return pickArbitraryLaneIndex(lane); -} - -function includesSomeLane(a, b) { - return (a & b) !== NoLanes; -} -function isSubsetOfLanes(set, subset) { - return (set & subset) === subset; -} -function mergeLanes(a, b) { - return a | b; -} -function removeLanes(set, subset) { - return set & ~subset; -} // Seems redundant, but it changes the type from a single lane (used for -// updates) to a group of lanes (used for flushing work). - -function laneToLanes(lane) { - return lane; -} -function createLaneMap(initial) { - return new Array(TotalLanes).fill(initial); -} -function markRootUpdated(root, updateLane, eventTime) { - root.pendingLanes |= updateLane; // TODO: Theoretically, any update to any lane can unblock any other lane. But - // it's not practical to try every single possible combination. We need a - // heuristic to decide which lanes to attempt to render, and in which batches. - // For now, we use the same heuristic as in the old ExpirationTimes model: - // retry any lane at equal or lower priority, but don't try updates at higher - // priority without also including the lower priority updates. This works well - // when considering updates across different priority levels, but isn't - // sufficient for updates within the same priority, since we want to treat - // those updates as parallel. - // Unsuspend any update at equal or lower priority. - - var higherPriorityLanes = updateLane - 1; // Turns 0b1000 into 0b0111 - - root.suspendedLanes &= higherPriorityLanes; - root.pingedLanes &= higherPriorityLanes; - var eventTimes = root.eventTimes; - var index = laneToIndex(updateLane); // We can always overwrite an existing timestamp because we prefer the most - // recent event, and we assume time is monotonically increasing. - - eventTimes[index] = eventTime; -} -function markRootSuspended(root, suspendedLanes) { - root.suspendedLanes |= suspendedLanes; - root.pingedLanes &= ~suspendedLanes; // The suspended lanes are no longer CPU-bound. Clear their expiration times. - - var expirationTimes = root.expirationTimes; - var lanes = suspendedLanes; - - while (lanes > 0) { - var index = pickArbitraryLaneIndex(lanes); - var lane = 1 << index; - expirationTimes[index] = NoTimestamp; - lanes &= ~lane; - } -} -function markRootPinged(root, pingedLanes, eventTime) { - root.pingedLanes |= root.suspendedLanes & pingedLanes; -} -function markRootExpired(root, expiredLanes) { - root.expiredLanes |= expiredLanes & root.pendingLanes; -} -function hasDiscreteLanes(lanes) { - return (lanes & InputDiscreteLanes) !== NoLanes; -} -function markRootMutableRead(root, updateLane) { - root.mutableReadLanes |= updateLane & root.pendingLanes; -} -function markRootFinished(root, remainingLanes) { - var noLongerPendingLanes = root.pendingLanes & ~remainingLanes; - root.pendingLanes = remainingLanes; // Let's try everything again - - root.suspendedLanes = 0; - root.pingedLanes = 0; - root.expiredLanes &= remainingLanes; - root.mutableReadLanes &= remainingLanes; - root.entangledLanes &= remainingLanes; - var entanglements = root.entanglements; - var eventTimes = root.eventTimes; - var expirationTimes = root.expirationTimes; // Clear the lanes that no longer have pending work - - var lanes = noLongerPendingLanes; - - while (lanes > 0) { - var index = pickArbitraryLaneIndex(lanes); - var lane = 1 << index; - entanglements[index] = NoLanes; - eventTimes[index] = NoTimestamp; - expirationTimes[index] = NoTimestamp; - lanes &= ~lane; - } -} -function markRootEntangled(root, entangledLanes) { - root.entangledLanes |= entangledLanes; - var entanglements = root.entanglements; - var lanes = entangledLanes; - - while (lanes > 0) { - var index = pickArbitraryLaneIndex(lanes); - var lane = 1 << index; - entanglements[index] |= entangledLanes; - lanes &= ~lane; - } -} -var clz32 = Math.clz32 ? Math.clz32 : clz32Fallback; // Count leading zeros. Only used on lanes, so assume input is an integer. -// Based on: -// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/clz32 - -var log = Math.log; -var LN2 = Math.LN2; - -function clz32Fallback(lanes) { - if (lanes === 0) { - return 32; - } - - return (31 - ((log(lanes) / LN2) | 0)) | 0; -} - // Intentionally not named imports because Rollup would use dynamic dispatch for var Scheduler_runWithPriority = Scheduler.unstable_runWithPriority, Scheduler_scheduleCallback = Scheduler.unstable_scheduleCallback, Scheduler_cancelCallback = Scheduler.unstable_cancelCallback, Scheduler_shouldYield = Scheduler.unstable_shouldYield, Scheduler_requestPaint = Scheduler.unstable_requestPaint, - Scheduler_now$1 = Scheduler.unstable_now, + Scheduler_now = Scheduler.unstable_now, Scheduler_getCurrentPriorityLevel = Scheduler.unstable_getCurrentPriorityLevel, Scheduler_ImmediatePriority = Scheduler.unstable_ImmediatePriority, @@ -5914,20 +5189,20 @@ var fakeCallbackNode = {}; // Except for NoPriority, these correspond to Schedul // ascending numbers so we can compare them like numbers. They start at 90 to // avoid clashing with Scheduler's priorities. -var ImmediatePriority$1 = 99; -var UserBlockingPriority$1 = 98; -var NormalPriority$1 = 97; -var LowPriority$1 = 96; -var IdlePriority$1 = 95; // NoPriority is the absence of priority. Also React-only. +var ImmediatePriority = 99; +var UserBlockingPriority = 98; +var NormalPriority = 97; +var LowPriority = 96; +var IdlePriority = 95; // NoPriority is the absence of priority. Also React-only. -var NoPriority$1 = 90; +var NoPriority = 90; var shouldYield = Scheduler_shouldYield; var requestPaint = // Fall back gracefully if we're running an older version of Scheduler. Scheduler_requestPaint !== undefined ? Scheduler_requestPaint : function() {}; var syncQueue = null; var immediateQueueCallbackNode = null; var isFlushingSyncQueue = false; -var initialTimeMs$1 = Scheduler_now$1(); // If the initial timestamp is reasonably small, use Scheduler's `now` directly. +var initialTimeMs = Scheduler_now(); // If the initial timestamp is reasonably small, use Scheduler's `now` directly. // This will be the case for modern browsers that support `performance.now`. In // older browsers, Scheduler falls back to `Date.now`, which returns a Unix // timestamp. In that case, subtract the module initialization time to simulate @@ -5936,27 +5211,27 @@ var initialTimeMs$1 = Scheduler_now$1(); // If the initial timestamp is reasonab // TODO: Consider lifting this into Scheduler. var now = - initialTimeMs$1 < 10000 - ? Scheduler_now$1 + initialTimeMs < 10000 + ? Scheduler_now : function() { - return Scheduler_now$1() - initialTimeMs$1; + return Scheduler_now() - initialTimeMs; }; function getCurrentPriorityLevel() { switch (Scheduler_getCurrentPriorityLevel()) { case Scheduler_ImmediatePriority: - return ImmediatePriority$1; + return ImmediatePriority; case Scheduler_UserBlockingPriority: - return UserBlockingPriority$1; + return UserBlockingPriority; case Scheduler_NormalPriority: - return NormalPriority$1; + return NormalPriority; case Scheduler_LowPriority: - return LowPriority$1; + return LowPriority; case Scheduler_IdlePriority: - return IdlePriority$1; + return IdlePriority; default: { throw Error("Unknown priority level."); @@ -5966,19 +5241,19 @@ function getCurrentPriorityLevel() { function reactPriorityToSchedulerPriority(reactPriorityLevel) { switch (reactPriorityLevel) { - case ImmediatePriority$1: + case ImmediatePriority: return Scheduler_ImmediatePriority; - case UserBlockingPriority$1: + case UserBlockingPriority: return Scheduler_UserBlockingPriority; - case NormalPriority$1: + case NormalPriority: return Scheduler_NormalPriority; - case LowPriority$1: + case LowPriority: return Scheduler_LowPriority; - case IdlePriority$1: + case IdlePriority: return Scheduler_IdlePriority; default: { @@ -6037,8 +5312,7 @@ function flushSyncCallbackQueueImpl() { try { var _isSync = true; var queue = syncQueue; - setCurrentUpdateLanePriority(SyncLanePriority); - runWithPriority(ImmediatePriority$1, function() { + runWithPriority(ImmediatePriority, function() { for (; i < queue.length; i++) { var callback = queue[i]; @@ -6065,58 +5339,6 @@ function flushSyncCallbackQueueImpl() { } } -function describeFiber(fiber) { - var owner = fiber._debugOwner ? fiber._debugOwner.type : null; - var source = fiber._debugSource; - - switch (fiber.tag) { - case HostComponent: - return describeBuiltInComponentFrame(fiber.type, source, owner); - - case LazyComponent: - return describeBuiltInComponentFrame("Lazy", source, owner); - - case SuspenseComponent: - return describeBuiltInComponentFrame("Suspense", source, owner); - - case SuspenseListComponent: - return describeBuiltInComponentFrame("SuspenseList", source, owner); - - case FunctionComponent: - case IndeterminateComponent: - case SimpleMemoComponent: - return describeFunctionComponentFrame(fiber.type, source, owner); - - case ForwardRef: - return describeFunctionComponentFrame(fiber.type.render, source, owner); - - case Block: - return describeFunctionComponentFrame(fiber.type._render, source, owner); - - case ClassComponent: - return describeClassComponentFrame(fiber.type, source, owner); - - default: - return ""; - } -} - -function getStackByFiberInDevAndProd(workInProgress) { - try { - var info = ""; - var node = workInProgress; - - do { - info += describeFiber(node); - node = node.return; - } while (node); - - return info; - } catch (x) { - return "\nError generating stack: " + x.message + "\n" + x.stack; - } -} - var NoMode = 0; var StrictMode = 1; // TODO: Remove BlockingMode and ConcurrentMode by reading from the root // tag instead @@ -6124,7 +5346,116 @@ var StrictMode = 1; // TODO: Remove BlockingMode and ConcurrentMode by reading f var BlockingMode = 2; var ConcurrentMode = 4; var ProfileMode = 8; -var DebugTracingMode = 16; + +// Max 31 bit integer. The max integer size in V8 for 32-bit systems. +// Math.pow(2, 30) - 1 +// 0b111111111111111111111111111111 +var MAX_SIGNED_31_BIT_INT = 1073741823; + +var NoWork = 0; // TODO: Think of a better name for Never. The key difference with Idle is that +// Never work can be committed in an inconsistent state without tearing the UI. +// The main example is offscreen content, like a hidden subtree. So one possible +// name is Offscreen. However, it also includes dehydrated Suspense boundaries, +// which are inconsistent in the sense that they haven't finished yet, but +// aren't visibly inconsistent because the server rendered HTML matches what the +// hydrated tree would look like. + +var Never = 1; // Idle is slightly higher priority than Never. It must completely finish in +// order to be consistent. + +var Idle = 2; // Continuous Hydration is slightly higher than Idle and is used to increase +var Sync = MAX_SIGNED_31_BIT_INT; +var Batched = Sync - 1; +var UNIT_SIZE = 10; +var MAGIC_NUMBER_OFFSET = Batched - 1; // 1 unit of expiration time represents 10ms. + +function msToExpirationTime(ms) { + // Always subtract from the offset so that we don't clash with the magic number for NoWork. + return MAGIC_NUMBER_OFFSET - ((ms / UNIT_SIZE) | 0); +} +function expirationTimeToMs(expirationTime) { + return (MAGIC_NUMBER_OFFSET - expirationTime) * UNIT_SIZE; +} + +function ceiling(num, precision) { + return (((num / precision) | 0) + 1) * precision; +} + +function computeExpirationBucket(currentTime, expirationInMs, bucketSizeMs) { + return ( + MAGIC_NUMBER_OFFSET - + ceiling( + MAGIC_NUMBER_OFFSET - currentTime + expirationInMs / UNIT_SIZE, + bucketSizeMs / UNIT_SIZE + ) + ); +} // TODO: This corresponds to Scheduler's NormalPriority, not LowPriority. Update +// the names to reflect. + +var LOW_PRIORITY_EXPIRATION = 5000; +var LOW_PRIORITY_BATCH_SIZE = 250; +function computeAsyncExpiration(currentTime) { + return computeExpirationBucket( + currentTime, + LOW_PRIORITY_EXPIRATION, + LOW_PRIORITY_BATCH_SIZE + ); +} +function computeSuspenseExpiration(currentTime, timeoutMs) { + // TODO: Should we warn if timeoutMs is lower than the normal pri expiration time? + return computeExpirationBucket( + currentTime, + timeoutMs, + LOW_PRIORITY_BATCH_SIZE + ); +} // We intentionally set a higher expiration time for interactive updates in +// dev than in production. +// +// If the main thread is being blocked so long that you hit the expiration, +// it's a problem that could be solved with better scheduling. +// +// People will be more likely to notice this and fix it with the long +// expiration time in development. +// +// In production we opt for better UX at the risk of masking scheduling +// problems, by expiring fast. + +var HIGH_PRIORITY_EXPIRATION = 500; +var HIGH_PRIORITY_BATCH_SIZE = 100; +function computeInteractiveExpiration(currentTime) { + return computeExpirationBucket( + currentTime, + HIGH_PRIORITY_EXPIRATION, + HIGH_PRIORITY_BATCH_SIZE + ); +} +function inferPriorityFromExpirationTime(currentTime, expirationTime) { + if (expirationTime === Sync) { + return ImmediatePriority; + } + + if (expirationTime === Never || expirationTime === Idle) { + return IdlePriority; + } + + var msUntil = + expirationTimeToMs(expirationTime) - expirationTimeToMs(currentTime); + + if (msUntil <= 0) { + return ImmediatePriority; + } + + if (msUntil <= HIGH_PRIORITY_EXPIRATION + HIGH_PRIORITY_BATCH_SIZE) { + return UserBlockingPriority; + } + + if (msUntil <= LOW_PRIORITY_EXPIRATION + LOW_PRIORITY_BATCH_SIZE) { + return NormalPriority; + } // TODO: Handle LowPriority + // Assume anything lower has idle priority + + return IdlePriority; +} /** * inlined Object.is polyfill to avoid requiring consumers ship their own @@ -6178,7 +5509,76 @@ function shallowEqual(objA, objB) { return true; } -var ReactDebugCurrentFrame$1 = ReactSharedInternals.ReactDebugCurrentFrame; +var BEFORE_SLASH_RE = /^(.*)[\\\/]/; +function describeComponentFrame(name, source, ownerName) { + var sourceInfo = ""; + + if (source) { + var path = source.fileName; + var fileName = path.replace(BEFORE_SLASH_RE, ""); + + { + // In DEV, include code for a common special case: + // prefer "folder/index.js" instead of just "index.js". + if (/^index\./.test(fileName)) { + var match = path.match(BEFORE_SLASH_RE); + + if (match) { + var pathBeforeSlash = match[1]; + + if (pathBeforeSlash) { + var folderName = pathBeforeSlash.replace(BEFORE_SLASH_RE, ""); + fileName = folderName + "/" + fileName; + } + } + } + } + + sourceInfo = " (at " + fileName + ":" + source.lineNumber + ")"; + } else if (ownerName) { + sourceInfo = " (created by " + ownerName + ")"; + } + + return "\n in " + (name || "Unknown") + sourceInfo; +} + +var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame; + +function describeFiber(fiber) { + switch (fiber.tag) { + case HostRoot: + case HostPortal: + case HostText: + case Fragment: + case ContextProvider: + case ContextConsumer: + return ""; + + default: + var owner = fiber._debugOwner; + var source = fiber._debugSource; + var name = getComponentName(fiber.type); + var ownerName = null; + + if (owner) { + ownerName = getComponentName(owner.type); + } + + return describeComponentFrame(name, source, ownerName); + } +} + +function getStackByFiberInDevAndProd(workInProgress) { + var info = ""; + var node = workInProgress; + + do { + info += describeFiber(node); + node = node.return; + } while (node); + + return info; +} var current = null; var isRendering = false; function getCurrentFiberOwnerNameInDevOrNull() { @@ -6196,7 +5596,6 @@ function getCurrentFiberOwnerNameInDevOrNull() { return null; } - function getCurrentFiberStackInDev() { { if (current === null) { @@ -6207,17 +5606,16 @@ function getCurrentFiberStackInDev() { return getStackByFiberInDevAndProd(current); } } - function resetCurrentFiber() { { - ReactDebugCurrentFrame$1.getCurrentStack = null; + ReactDebugCurrentFrame.getCurrentStack = null; current = null; isRendering = false; } } function setCurrentFiber(fiber) { { - ReactDebugCurrentFrame$1.getCurrentStack = getCurrentFiberStackInDev; + ReactDebugCurrentFrame.getCurrentStack = getCurrentFiberStackInDev; current = fiber; isRendering = false; } @@ -6227,11 +5625,6 @@ function setIsRendering(rendering) { isRendering = rendering; } } -function getIsRendering() { - { - return isRendering; - } -} var ReactStrictModeWarnings = { recordUnsafeLifecycleWarnings: function(fiber, instance) {}, @@ -6454,7 +5847,7 @@ var ReactStrictModeWarnings = { "See https://fb.me/react-unsafe-component-lifecycles for details.\n\n" + "* Move code with side effects to componentDidMount, and set initial state in the constructor.\n" + "* Rename componentWillMount to UNSAFE_componentWillMount to suppress " + - "this warning in non-strict mode. In React 18.x, only the UNSAFE_ name will work. " + + "this warning in non-strict mode. In React 17.x, only the UNSAFE_ name will work. " + "To rename all deprecated lifecycles to their new names, you can run " + "`npx react-codemod rename-unsafe-lifecycles` in your project source folder.\n" + "\nPlease update the following components: %s", @@ -6475,7 +5868,7 @@ var ReactStrictModeWarnings = { "code to use memoization techniques or move it to " + "static getDerivedStateFromProps. Learn more at: https://fb.me/react-derived-state\n" + "* Rename componentWillReceiveProps to UNSAFE_componentWillReceiveProps to suppress " + - "this warning in non-strict mode. In React 18.x, only the UNSAFE_ name will work. " + + "this warning in non-strict mode. In React 17.x, only the UNSAFE_ name will work. " + "To rename all deprecated lifecycles to their new names, you can run " + "`npx react-codemod rename-unsafe-lifecycles` in your project source folder.\n" + "\nPlease update the following components: %s", @@ -6491,7 +5884,7 @@ var ReactStrictModeWarnings = { "See https://fb.me/react-unsafe-component-lifecycles for details.\n\n" + "* Move data fetching code or side effects to componentDidUpdate.\n" + "* Rename componentWillUpdate to UNSAFE_componentWillUpdate to suppress " + - "this warning in non-strict mode. In React 18.x, only the UNSAFE_ name will work. " + + "this warning in non-strict mode. In React 17.x, only the UNSAFE_ name will work. " + "To rename all deprecated lifecycles to their new names, you can run " + "`npx react-codemod rename-unsafe-lifecycles` in your project source folder.\n" + "\nPlease update the following components: %s", @@ -6552,21 +5945,18 @@ var ReactStrictModeWarnings = { didWarnAboutLegacyContext.add(fiber.type); }); var sortedNames = setToSortedString(uniqueNames); + var firstComponentStack = getStackByFiberInDevAndProd(firstFiber); - try { - setCurrentFiber(firstFiber); - - error( - "Legacy context API has been detected within a strict-mode tree." + - "\n\nThe old API will be supported in all 16.x releases, but applications " + - "using it should migrate to the new version." + - "\n\nPlease update the following components: %s" + - "\n\nLearn more about this warning here: https://fb.me/react-legacy-context", - sortedNames - ); - } finally { - resetCurrentFiber(); - } + error( + "Legacy context API has been detected within a strict-mode tree." + + "\n\nThe old API will be supported in all 16.x releases, but applications " + + "using it should migrate to the new version." + + "\n\nPlease update the following components: %s" + + "\n\nLearn more about this warning here: https://fb.me/react-legacy-context" + + "%s", + sortedNames, + firstComponentStack + ); }); }; @@ -6581,6 +5971,441 @@ var ReactStrictModeWarnings = { }; } +var resolveFamily = null; // $FlowFixMe Flow gets confused by a WeakSet feature check below. + +var failedBoundaries = null; +var setRefreshHandler = function(handler) { + { + resolveFamily = handler; + } +}; +function resolveFunctionForHotReloading(type) { + { + if (resolveFamily === null) { + // Hot reloading is disabled. + return type; + } + + var family = resolveFamily(type); + + if (family === undefined) { + return type; + } // Use the latest known implementation. + + return family.current; + } +} +function resolveClassForHotReloading(type) { + // No implementation differences. + return resolveFunctionForHotReloading(type); +} +function resolveForwardRefForHotReloading(type) { + { + if (resolveFamily === null) { + // Hot reloading is disabled. + return type; + } + + var family = resolveFamily(type); + + if (family === undefined) { + // Check if we're dealing with a real forwardRef. Don't want to crash early. + if ( + type !== null && + type !== undefined && + typeof type.render === "function" + ) { + // ForwardRef is special because its resolved .type is an object, + // but it's possible that we only have its inner render function in the map. + // If that inner render function is different, we'll build a new forwardRef type. + var currentRender = resolveFunctionForHotReloading(type.render); + + if (type.render !== currentRender) { + var syntheticType = { + $$typeof: REACT_FORWARD_REF_TYPE, + render: currentRender + }; + + if (type.displayName !== undefined) { + syntheticType.displayName = type.displayName; + } + + return syntheticType; + } + } + + return type; + } // Use the latest known implementation. + + return family.current; + } +} +function isCompatibleFamilyForHotReloading(fiber, element) { + { + if (resolveFamily === null) { + // Hot reloading is disabled. + return false; + } + + var prevType = fiber.elementType; + var nextType = element.type; // If we got here, we know types aren't === equal. + + var needsCompareFamilies = false; + var $$typeofNextType = + typeof nextType === "object" && nextType !== null + ? nextType.$$typeof + : null; + + switch (fiber.tag) { + case ClassComponent: { + if (typeof nextType === "function") { + needsCompareFamilies = true; + } + + break; + } + + case FunctionComponent: { + if (typeof nextType === "function") { + needsCompareFamilies = true; + } else if ($$typeofNextType === REACT_LAZY_TYPE) { + // We don't know the inner type yet. + // We're going to assume that the lazy inner type is stable, + // and so it is sufficient to avoid reconciling it away. + // We're not going to unwrap or actually use the new lazy type. + needsCompareFamilies = true; + } + + break; + } + + case ForwardRef: { + if ($$typeofNextType === REACT_FORWARD_REF_TYPE) { + needsCompareFamilies = true; + } else if ($$typeofNextType === REACT_LAZY_TYPE) { + needsCompareFamilies = true; + } + + break; + } + + case MemoComponent: + case SimpleMemoComponent: { + if ($$typeofNextType === REACT_MEMO_TYPE) { + // TODO: if it was but can no longer be simple, + // we shouldn't set this. + needsCompareFamilies = true; + } else if ($$typeofNextType === REACT_LAZY_TYPE) { + needsCompareFamilies = true; + } + + break; + } + + default: + return false; + } // Check if both types have a family and it's the same one. + + if (needsCompareFamilies) { + // Note: memo() and forwardRef() we'll compare outer rather than inner type. + // This means both of them need to be registered to preserve state. + // If we unwrapped and compared the inner types for wrappers instead, + // then we would risk falsely saying two separate memo(Foo) + // calls are equivalent because they wrap the same Foo function. + var prevFamily = resolveFamily(prevType); + + if (prevFamily !== undefined && prevFamily === resolveFamily(nextType)) { + return true; + } + } + + return false; + } +} +function markFailedErrorBoundaryForHotReloading(fiber) { + { + if (resolveFamily === null) { + // Hot reloading is disabled. + return; + } + + if (typeof WeakSet !== "function") { + return; + } + + if (failedBoundaries === null) { + failedBoundaries = new WeakSet(); + } + + failedBoundaries.add(fiber); + } +} +var scheduleRefresh = function(root, update) { + { + if (resolveFamily === null) { + // Hot reloading is disabled. + return; + } + + var staleFamilies = update.staleFamilies, + updatedFamilies = update.updatedFamilies; + flushPassiveEffects(); + flushSync(function() { + scheduleFibersWithFamiliesRecursively( + root.current, + updatedFamilies, + staleFamilies + ); + }); + } +}; +var scheduleRoot = function(root, element) { + { + if (root.context !== emptyContextObject) { + // Super edge case: root has a legacy _renderSubtree context + // but we don't know the parentComponent so we can't pass it. + // Just ignore. We'll delete this with _renderSubtree code path later. + return; + } + + flushPassiveEffects(); + syncUpdates(function() { + updateContainer(element, root, null, null); + }); + } +}; + +function scheduleFibersWithFamiliesRecursively( + fiber, + updatedFamilies, + staleFamilies +) { + { + var alternate = fiber.alternate, + child = fiber.child, + sibling = fiber.sibling, + tag = fiber.tag, + type = fiber.type; + var candidateType = null; + + switch (tag) { + case FunctionComponent: + case SimpleMemoComponent: + case ClassComponent: + candidateType = type; + break; + + case ForwardRef: + candidateType = type.render; + break; + } + + if (resolveFamily === null) { + throw new Error("Expected resolveFamily to be set during hot reload."); + } + + var needsRender = false; + var needsRemount = false; + + if (candidateType !== null) { + var family = resolveFamily(candidateType); + + if (family !== undefined) { + if (staleFamilies.has(family)) { + needsRemount = true; + } else if (updatedFamilies.has(family)) { + if (tag === ClassComponent) { + needsRemount = true; + } else { + needsRender = true; + } + } + } + } + + if (failedBoundaries !== null) { + if ( + failedBoundaries.has(fiber) || + (alternate !== null && failedBoundaries.has(alternate)) + ) { + needsRemount = true; + } + } + + if (needsRemount) { + fiber._debugNeedsRemount = true; + } + + if (needsRemount || needsRender) { + scheduleWork(fiber, Sync); + } + + if (child !== null && !needsRemount) { + scheduleFibersWithFamiliesRecursively( + child, + updatedFamilies, + staleFamilies + ); + } + + if (sibling !== null) { + scheduleFibersWithFamiliesRecursively( + sibling, + updatedFamilies, + staleFamilies + ); + } + } +} + +var findHostInstancesForRefresh = function(root, families) { + { + var hostInstances = new Set(); + var types = new Set( + families.map(function(family) { + return family.current; + }) + ); + findHostInstancesForMatchingFibersRecursively( + root.current, + types, + hostInstances + ); + return hostInstances; + } +}; + +function findHostInstancesForMatchingFibersRecursively( + fiber, + types, + hostInstances +) { + { + var child = fiber.child, + sibling = fiber.sibling, + tag = fiber.tag, + type = fiber.type; + var candidateType = null; + + switch (tag) { + case FunctionComponent: + case SimpleMemoComponent: + case ClassComponent: + candidateType = type; + break; + + case ForwardRef: + candidateType = type.render; + break; + } + + var didMatch = false; + + if (candidateType !== null) { + if (types.has(candidateType)) { + didMatch = true; + } + } + + if (didMatch) { + // We have a match. This only drills down to the closest host components. + // There's no need to search deeper because for the purpose of giving + // visual feedback, "flashing" outermost parent rectangles is sufficient. + findHostInstancesForFiberShallowly(fiber, hostInstances); + } else { + // If there's no match, maybe there will be one further down in the child tree. + if (child !== null) { + findHostInstancesForMatchingFibersRecursively( + child, + types, + hostInstances + ); + } + } + + if (sibling !== null) { + findHostInstancesForMatchingFibersRecursively( + sibling, + types, + hostInstances + ); + } + } +} + +function findHostInstancesForFiberShallowly(fiber, hostInstances) { + { + var foundHostInstances = findChildHostInstancesForFiberShallowly( + fiber, + hostInstances + ); + + if (foundHostInstances) { + return; + } // If we didn't find any host children, fallback to closest host parent. + + var node = fiber; + + while (true) { + switch (node.tag) { + case HostComponent: + hostInstances.add(node.stateNode); + return; + + case HostPortal: + hostInstances.add(node.stateNode.containerInfo); + return; + + case HostRoot: + hostInstances.add(node.stateNode.containerInfo); + return; + } + + if (node.return === null) { + throw new Error("Expected to reach root first."); + } + + node = node.return; + } + } +} + +function findChildHostInstancesForFiberShallowly(fiber, hostInstances) { + { + var node = fiber; + var foundHostInstances = false; + + while (true) { + if (node.tag === HostComponent) { + // We got a match. + foundHostInstances = true; + hostInstances.add(node.stateNode); // There may still be more, so keep searching. + } else if (node.child !== null) { + node.child.return = node; + node = node.child; + continue; + } + + if (node === fiber) { + return foundHostInstances; + } + + while (node.sibling === null) { + if (node.return === null || node.return === fiber) { + return foundHostInstances; + } + + node = node.return; + } + + node.sibling.return = node.return; + node = node.sibling; + } + } + + return false; +} + function resolveDefaultProps(Component, baseProps) { if (Component && Component.defaultProps) { // Resolve default props. Taken from ReactElement @@ -6598,11 +6423,15 @@ function resolveDefaultProps(Component, baseProps) { return baseProps; } +function readLazyComponentType(lazyComponent) { + initializeLazyComponentType(lazyComponent); -// Max 31 bit integer. The max integer size in V8 for 32-bit systems. -// Math.pow(2, 30) - 1 -// 0b111111111111111111111111111111 -var MAX_SIGNED_31_BIT_INT = 1073741823; + if (lazyComponent._status !== Resolved) { + throw lazyComponent._result; + } + + return lazyComponent._result; +} var valueCursor = createCursor(null); var rendererSigil; @@ -6692,24 +6521,28 @@ function calculateChangedBits(context, newValue, oldValue) { return changedBits | 0; } } -function scheduleWorkOnParentPath(parent, renderLanes) { - // Update the child lanes of all the ancestors, including the alternates. +function scheduleWorkOnParentPath(parent, renderExpirationTime) { + // Update the child expiration time of all the ancestors, including + // the alternates. var node = parent; while (node !== null) { var alternate = node.alternate; - if (!isSubsetOfLanes(node.childLanes, renderLanes)) { - node.childLanes = mergeLanes(node.childLanes, renderLanes); + if (node.childExpirationTime < renderExpirationTime) { + node.childExpirationTime = renderExpirationTime; - if (alternate !== null) { - alternate.childLanes = mergeLanes(alternate.childLanes, renderLanes); + if ( + alternate !== null && + alternate.childExpirationTime < renderExpirationTime + ) { + alternate.childExpirationTime = renderExpirationTime; } } else if ( alternate !== null && - !isSubsetOfLanes(alternate.childLanes, renderLanes) + alternate.childExpirationTime < renderExpirationTime ) { - alternate.childLanes = mergeLanes(alternate.childLanes, renderLanes); + alternate.childExpirationTime = renderExpirationTime; } else { // Neither alternate was updated, which means the rest of the // ancestor path already has sufficient priority. @@ -6723,7 +6556,7 @@ function propagateContextChange( workInProgress, context, changedBits, - renderLanes + renderExpirationTime ) { var fiber = workInProgress.child; @@ -6750,11 +6583,7 @@ function propagateContextChange( // Match! Schedule an update on this fiber. if (fiber.tag === ClassComponent) { // Schedule a force update on the work-in-progress. - var update = createUpdate( - NoTimestamp, - pickArbitraryLane(renderLanes), - null - ); + var update = createUpdate(renderExpirationTime, null); update.tag = ForceUpdate; // TODO: Because we don't have a work-in-progress, this will add the // update to the current fiber, too, which means it will persist even if // this render is thrown away. Since it's a race condition, not sure it's @@ -6763,16 +6592,24 @@ function propagateContextChange( enqueueUpdate(fiber, update); } - fiber.lanes = mergeLanes(fiber.lanes, renderLanes); - var alternate = fiber.alternate; - - if (alternate !== null) { - alternate.lanes = mergeLanes(alternate.lanes, renderLanes); + if (fiber.expirationTime < renderExpirationTime) { + fiber.expirationTime = renderExpirationTime; } - scheduleWorkOnParentPath(fiber.return, renderLanes); // Mark the updated lanes on the list, too. + var alternate = fiber.alternate; - list.lanes = mergeLanes(list.lanes, renderLanes); // Since we already found a match, we can stop traversing the + if ( + alternate !== null && + alternate.expirationTime < renderExpirationTime + ) { + alternate.expirationTime = renderExpirationTime; + } + + scheduleWorkOnParentPath(fiber.return, renderExpirationTime); // Mark the expiration time on the list, too. + + if (list.expirationTime < renderExpirationTime) { + list.expirationTime = renderExpirationTime; + } // Since we already found a match, we can stop traversing the // dependency list. break; @@ -6818,7 +6655,7 @@ function propagateContextChange( fiber = nextFiber; } } -function prepareToReadContext(workInProgress, renderLanes) { +function prepareToReadContext(workInProgress, renderExpirationTime) { currentlyRenderingFiber = workInProgress; lastContextDependency = null; lastContextWithAllBitsObserved = null; @@ -6828,7 +6665,7 @@ function prepareToReadContext(workInProgress, renderLanes) { var firstContext = dependencies.firstContext; if (firstContext !== null) { - if (includesSomeLane(dependencies.lanes, renderLanes)) { + if (dependencies.expirationTime >= renderExpirationTime) { // Context list has a pending update. Mark that this fiber performed work. markWorkInProgressReceivedUpdate(); } // Reset the work-in-progress list @@ -6882,7 +6719,7 @@ function readContext(context, observedBits) { lastContextDependency = contextItem; currentlyRenderingFiber.dependencies = { - lanes: NoLanes, + expirationTime: NoWork, firstContext: contextItem, responders: null }; @@ -6914,8 +6751,7 @@ var currentlyProcessingQueue; function initializeUpdateQueue(fiber) { var queue = { baseState: fiber.memoizedState, - firstBaseUpdate: null, - lastBaseUpdate: null, + baseQueue: null, shared: { pending: null }, @@ -6931,24 +6767,28 @@ function cloneUpdateQueue(current, workInProgress) { if (queue === currentQueue) { var clone = { baseState: currentQueue.baseState, - firstBaseUpdate: currentQueue.firstBaseUpdate, - lastBaseUpdate: currentQueue.lastBaseUpdate, + baseQueue: currentQueue.baseQueue, shared: currentQueue.shared, effects: currentQueue.effects }; workInProgress.updateQueue = clone; } } -function createUpdate(eventTime, lane, suspenseConfig) { +function createUpdate(expirationTime, suspenseConfig) { var update = { - eventTime: eventTime, - lane: lane, + expirationTime: expirationTime, suspenseConfig: suspenseConfig, tag: UpdateState, payload: null, callback: null, next: null }; + update.next = update; + + { + update.priority = getCurrentPriorityLevel(); + } + return update; } function enqueueUpdate(fiber, update) { @@ -6988,85 +6828,25 @@ function enqueueUpdate(fiber, update) { } } } -function enqueueCapturedUpdate(workInProgress, capturedUpdate) { - // Captured updates are updates that are thrown by a child during the render - // phase. They should be discarded if the render is aborted. Therefore, - // we should only put them on the work-in-progress queue, not the current one. - var queue = workInProgress.updateQueue; // Check if the work-in-progress queue is a clone. - +function enqueueCapturedUpdate(workInProgress, update) { var current = workInProgress.alternate; if (current !== null) { - var currentQueue = current.updateQueue; + // Ensure the work-in-progress queue is a clone + cloneUpdateQueue(current, workInProgress); + } // Captured updates go only on the work-in-progress queue. - if (queue === currentQueue) { - // The work-in-progress queue is the same as current. This happens when - // we bail out on a parent fiber that then captures an error thrown by - // a child. Since we want to append the update only to the work-in - // -progress queue, we need to clone the updates. We usually clone during - // processUpdateQueue, but that didn't happen in this case because we - // skipped over the parent when we bailed out. - var newFirst = null; - var newLast = null; - var firstBaseUpdate = queue.firstBaseUpdate; + var queue = workInProgress.updateQueue; // Append the update to the end of the list. - if (firstBaseUpdate !== null) { - // Loop through the updates and clone them. - var update = firstBaseUpdate; + var last = queue.baseQueue; - do { - var clone = { - eventTime: update.eventTime, - lane: update.lane, - suspenseConfig: update.suspenseConfig, - tag: update.tag, - payload: update.payload, - callback: update.callback, - next: null - }; - - if (newLast === null) { - newFirst = newLast = clone; - } else { - newLast.next = clone; - newLast = clone; - } - - update = update.next; - } while (update !== null); // Append the captured update the end of the cloned list. - - if (newLast === null) { - newFirst = newLast = capturedUpdate; - } else { - newLast.next = capturedUpdate; - newLast = capturedUpdate; - } - } else { - // There are no base updates. - newFirst = newLast = capturedUpdate; - } - - queue = { - baseState: currentQueue.baseState, - firstBaseUpdate: newFirst, - lastBaseUpdate: newLast, - shared: currentQueue.shared, - effects: currentQueue.effects - }; - workInProgress.updateQueue = queue; - return; - } - } // Append the update to the end of the list. - - var lastBaseUpdate = queue.lastBaseUpdate; - - if (lastBaseUpdate === null) { - queue.firstBaseUpdate = capturedUpdate; + if (last === null) { + queue.baseQueue = update.next = update; + update.next = update; } else { - lastBaseUpdate.next = capturedUpdate; + update.next = last.next; + last.next = update; } - - queue.lastBaseUpdate = capturedUpdate; } function getStateFromUpdate( @@ -7085,21 +6865,15 @@ function getStateFromUpdate( // Updater function { enterDisallowedContextReadInDEV(); + + if (workInProgress.mode & StrictMode) { + payload.call(instance, prevState, nextProps); + } } var nextState = payload.call(instance, prevState, nextProps); { - if (workInProgress.mode & StrictMode) { - disableLogs(); - - try { - payload.call(instance, prevState, nextProps); - } finally { - reenableLogs(); - } - } - exitDisallowedContextReadInDEV(); } @@ -7123,21 +6897,15 @@ function getStateFromUpdate( // Updater function { enterDisallowedContextReadInDEV(); + + if (workInProgress.mode & StrictMode) { + _payload.call(instance, prevState, nextProps); + } } partialState = _payload.call(instance, prevState, nextProps); { - if (workInProgress.mode & StrictMode) { - disableLogs(); - - try { - _payload.call(instance, prevState, nextProps); - } finally { - reenableLogs(); - } - } - exitDisallowedContextReadInDEV(); } } else { @@ -7162,172 +6930,161 @@ function getStateFromUpdate( return prevState; } -function processUpdateQueue(workInProgress, props, instance, renderLanes) { +function processUpdateQueue( + workInProgress, + props, + instance, + renderExpirationTime +) { // This is always non-null on a ClassComponent or HostRoot var queue = workInProgress.updateQueue; hasForceUpdate = false; { currentlyProcessingQueue = queue.shared; - } + } // The last rebase update that is NOT part of the base state. - var firstBaseUpdate = queue.firstBaseUpdate; - var lastBaseUpdate = queue.lastBaseUpdate; // Check if there are pending updates. If so, transfer them to the base queue. + var baseQueue = queue.baseQueue; // The last pending update that hasn't been processed yet. var pendingQueue = queue.shared.pending; if (pendingQueue !== null) { - queue.shared.pending = null; // The pending queue is circular. Disconnect the pointer between first - // and last so that it's non-circular. - - var lastPendingUpdate = pendingQueue; - var firstPendingUpdate = lastPendingUpdate.next; - lastPendingUpdate.next = null; // Append pending updates to base queue - - if (lastBaseUpdate === null) { - firstBaseUpdate = firstPendingUpdate; - } else { - lastBaseUpdate.next = firstPendingUpdate; + // We have new updates that haven't been processed yet. + // We'll add them to the base queue. + if (baseQueue !== null) { + // Merge the pending queue and the base queue. + var baseFirst = baseQueue.next; + var pendingFirst = pendingQueue.next; + baseQueue.next = pendingFirst; + pendingQueue.next = baseFirst; } - lastBaseUpdate = lastPendingUpdate; // If there's a current queue, and it's different from the base queue, then - // we need to transfer the updates to that queue, too. Because the base - // queue is a singly-linked list with no cycles, we can append to both - // lists and take advantage of structural sharing. - // TODO: Pass `current` as argument + baseQueue = pendingQueue; + queue.shared.pending = null; // TODO: Pass `current` as argument var current = workInProgress.alternate; if (current !== null) { - // This is always non-null on a ClassComponent or HostRoot var currentQueue = current.updateQueue; - var currentLastBaseUpdate = currentQueue.lastBaseUpdate; - if (currentLastBaseUpdate !== lastBaseUpdate) { - if (currentLastBaseUpdate === null) { - currentQueue.firstBaseUpdate = firstPendingUpdate; - } else { - currentLastBaseUpdate.next = firstPendingUpdate; - } - - currentQueue.lastBaseUpdate = lastPendingUpdate; + if (currentQueue !== null) { + currentQueue.baseQueue = pendingQueue; } } } // These values may change as we process the queue. - if (firstBaseUpdate !== null) { - // Iterate through the list of updates to compute the result. - var newState = queue.baseState; // TODO: Don't need to accumulate this. Instead, we can remove renderLanes - // from the original lanes. + if (baseQueue !== null) { + var first = baseQueue.next; // Iterate through the list of updates to compute the result. - var newLanes = NoLanes; + var newState = queue.baseState; + var newExpirationTime = NoWork; var newBaseState = null; - var newFirstBaseUpdate = null; - var newLastBaseUpdate = null; - var update = firstBaseUpdate; + var newBaseQueueFirst = null; + var newBaseQueueLast = null; - do { - var updateLane = update.lane; - var updateEventTime = update.eventTime; + if (first !== null) { + var update = first; - if (!isSubsetOfLanes(renderLanes, updateLane)) { - // Priority is insufficient. Skip this update. If this is the first - // skipped update, the previous update/state is the new base - // update/state. - var clone = { - eventTime: updateEventTime, - lane: updateLane, - suspenseConfig: update.suspenseConfig, - tag: update.tag, - payload: update.payload, - callback: update.callback, - next: null - }; + do { + var updateExpirationTime = update.expirationTime; - if (newLastBaseUpdate === null) { - newFirstBaseUpdate = newLastBaseUpdate = clone; - newBaseState = newState; - } else { - newLastBaseUpdate = newLastBaseUpdate.next = clone; - } // Update the remaining priority in the queue. - - newLanes = mergeLanes(newLanes, updateLane); - } else { - // This update does have sufficient priority. - if (newLastBaseUpdate !== null) { - var _clone = { - eventTime: updateEventTime, - // This update is going to be committed so we never want uncommit - // it. Using NoLane works because 0 is a subset of all bitmasks, so - // this will never be skipped by the check above. - lane: NoLane, + 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. + var clone = { + expirationTime: update.expirationTime, suspenseConfig: update.suspenseConfig, tag: update.tag, payload: update.payload, callback: update.callback, next: null }; - newLastBaseUpdate = newLastBaseUpdate.next = _clone; - } // Mark the event time of this update as relevant to this render pass. - // TODO: This should ideally use the true event time of this update rather than - // its priority which is a derived and not reversible value. - // TODO: We should skip this update if it was already committed but currently - // we have no way of detecting the difference between a committed and suspended - // update here. - markRenderEventTimeAndConfig(updateEventTime, update.suspenseConfig); // Process this update. - - newState = getStateFromUpdate( - workInProgress, - queue, - update, - newState, - props, - instance - ); - var callback = update.callback; - - if (callback !== null) { - workInProgress.effectTag |= Callback; - var effects = queue.effects; - - if (effects === null) { - queue.effects = [update]; + if (newBaseQueueLast === null) { + newBaseQueueFirst = newBaseQueueLast = clone; + newBaseState = newState; } else { - effects.push(update); + newBaseQueueLast = newBaseQueueLast.next = clone; + } // Update the remaining priority in the queue. + + if (updateExpirationTime > newExpirationTime) { + newExpirationTime = updateExpirationTime; + } + } else { + // This update does have sufficient priority. + if (newBaseQueueLast !== null) { + var _clone = { + expirationTime: Sync, + // This update is going to be committed so we never want uncommit it. + suspenseConfig: update.suspenseConfig, + tag: update.tag, + payload: update.payload, + callback: update.callback, + next: null + }; + newBaseQueueLast = newBaseQueueLast.next = _clone; + } // Mark the event time of this update as relevant to this render pass. + // TODO: This should ideally use the true event time of this update rather than + // its priority which is a derived and not reverseable value. + // TODO: We should skip this update if it was already committed but currently + // we have no way of detecting the difference between a committed and suspended + // update here. + + markRenderEventTimeAndConfig( + updateExpirationTime, + update.suspenseConfig + ); // Process this update. + + newState = getStateFromUpdate( + workInProgress, + queue, + update, + newState, + props, + instance + ); + var callback = update.callback; + + if (callback !== null) { + workInProgress.effectTag |= Callback; + var effects = queue.effects; + + if (effects === null) { + queue.effects = [update]; + } else { + effects.push(update); + } } } - } - update = update.next; + update = update.next; - if (update === null) { - pendingQueue = queue.shared.pending; + if (update === null || update === first) { + pendingQueue = queue.shared.pending; - if (pendingQueue === null) { - break; - } else { - // An update was scheduled from inside a reducer. Add the new - // pending updates to the end of the list and keep processing. - var _lastPendingUpdate = pendingQueue; // Intentionally unsound. Pending updates form a circular list, but we - // unravel them when transferring them to the base queue. - - var _firstPendingUpdate = _lastPendingUpdate.next; - _lastPendingUpdate.next = null; - update = _firstPendingUpdate; - queue.lastBaseUpdate = _lastPendingUpdate; - queue.shared.pending = null; + if (pendingQueue === null) { + break; + } else { + // An update was scheduled from inside a reducer. Add the new + // pending updates to the end of the list and keep processing. + update = baseQueue.next = pendingQueue.next; + pendingQueue.next = first; + queue.baseQueue = baseQueue = pendingQueue; + queue.shared.pending = null; + } } - } - } while (true); + } while (true); + } - if (newLastBaseUpdate === null) { + if (newBaseQueueLast === null) { newBaseState = newState; + } else { + newBaseQueueLast.next = newBaseQueueFirst; } queue.baseState = newBaseState; - queue.firstBaseUpdate = newFirstBaseUpdate; - queue.lastBaseUpdate = newLastBaseUpdate; // Set the remaining expiration time to be whatever is remaining in the queue. + queue.baseQueue = newBaseQueueLast; // Set the remaining expiration time to be whatever is remaining in the queue. // This should be fine because the only two other things that contribute to // expiration time are props and context. We're already in the middle of the // begin phase by the time we start processing the queue, so we've already @@ -7335,8 +7092,8 @@ function processUpdateQueue(workInProgress, props, instance, renderLanes) { // shouldComponentUpdate is tricky; but we'll have to account for // that regardless. - markSkippedUpdateLanes(newLanes); - workInProgress.lanes = newLanes; + markUnprocessedUpdateTime(newExpirationTime); + workInProgress.expirationTime = newExpirationTime; workInProgress.memoizedState = newState; } @@ -7474,14 +7231,8 @@ function applyDerivedStateFromProps( { if (workInProgress.mode & StrictMode) { - disableLogs(); - - try { - // Invoke the function an extra time to help detect side-effects. - getDerivedStateFromProps(nextProps, prevState); - } finally { - reenableLogs(); - } + // Invoke the function an extra time to help detect side-effects. + getDerivedStateFromProps(nextProps, prevState); } } @@ -7498,7 +7249,7 @@ function applyDerivedStateFromProps( workInProgress.memoizedState = memoizedState; // Once the update queue is empty, persist the derived state onto the // base state. - if (workInProgress.lanes === NoLanes) { + if (workInProgress.expirationTime === NoWork) { // Queue is always non-null for classes var updateQueue = workInProgress.updateQueue; updateQueue.baseState = memoizedState; @@ -7508,10 +7259,14 @@ var classComponentUpdater = { isMounted: isMounted, enqueueSetState: function(inst, payload, callback) { var fiber = get(inst); - var eventTime = requestEventTime(); + var currentTime = requestCurrentTimeForUpdate(); var suspenseConfig = requestCurrentSuspenseConfig(); - var lane = requestUpdateLane(fiber, suspenseConfig); - var update = createUpdate(eventTime, lane, suspenseConfig); + var expirationTime = computeExpirationForFiber( + currentTime, + fiber, + suspenseConfig + ); + var update = createUpdate(expirationTime, suspenseConfig); update.payload = payload; if (callback !== undefined && callback !== null) { @@ -7523,14 +7278,18 @@ var classComponentUpdater = { } enqueueUpdate(fiber, update); - scheduleUpdateOnFiber(fiber, lane, eventTime); + scheduleWork(fiber, expirationTime); }, enqueueReplaceState: function(inst, payload, callback) { var fiber = get(inst); - var eventTime = requestEventTime(); + var currentTime = requestCurrentTimeForUpdate(); var suspenseConfig = requestCurrentSuspenseConfig(); - var lane = requestUpdateLane(fiber, suspenseConfig); - var update = createUpdate(eventTime, lane, suspenseConfig); + var expirationTime = computeExpirationForFiber( + currentTime, + fiber, + suspenseConfig + ); + var update = createUpdate(expirationTime, suspenseConfig); update.tag = ReplaceState; update.payload = payload; @@ -7543,14 +7302,18 @@ var classComponentUpdater = { } enqueueUpdate(fiber, update); - scheduleUpdateOnFiber(fiber, lane, eventTime); + scheduleWork(fiber, expirationTime); }, enqueueForceUpdate: function(inst, callback) { var fiber = get(inst); - var eventTime = requestEventTime(); + var currentTime = requestCurrentTimeForUpdate(); var suspenseConfig = requestCurrentSuspenseConfig(); - var lane = requestUpdateLane(fiber, suspenseConfig); - var update = createUpdate(eventTime, lane, suspenseConfig); + var expirationTime = computeExpirationForFiber( + currentTime, + fiber, + suspenseConfig + ); + var update = createUpdate(expirationTime, suspenseConfig); update.tag = ForceUpdate; if (callback !== undefined && callback !== null) { @@ -7562,7 +7325,7 @@ var classComponentUpdater = { } enqueueUpdate(fiber, update); - scheduleUpdateOnFiber(fiber, lane, eventTime); + scheduleWork(fiber, expirationTime); } }; @@ -7580,22 +7343,18 @@ function checkShouldComponentUpdate( if (typeof instance.shouldComponentUpdate === "function") { { if (workInProgress.mode & StrictMode) { - disableLogs(); - - try { - // Invoke the function an extra time to help detect side-effects. - instance.shouldComponentUpdate(newProps, newState, nextContext); - } finally { - reenableLogs(); - } + // Invoke the function an extra time to help detect side-effects. + instance.shouldComponentUpdate(newProps, newState, nextContext); } } + startPhaseTimer(workInProgress, "shouldComponentUpdate"); var shouldUpdate = instance.shouldComponentUpdate( newProps, newState, nextContext ); + stopPhaseTimer(); { if (shouldUpdate === undefined) { @@ -7916,13 +7675,7 @@ function constructClassInstance(workInProgress, ctor, props) { { if (workInProgress.mode & StrictMode) { - disableLogs(); - - try { - new ctor(props, context); // eslint-disable-line no-new - } finally { - reenableLogs(); - } + new ctor(props, context); // eslint-disable-line no-new } } @@ -8033,6 +7786,7 @@ function constructClassInstance(workInProgress, ctor, props) { } function callComponentWillMount(workInProgress, instance) { + startPhaseTimer(workInProgress, "componentWillMount"); var oldState = instance.state; if (typeof instance.componentWillMount === "function") { @@ -8043,6 +7797,8 @@ function callComponentWillMount(workInProgress, instance) { instance.UNSAFE_componentWillMount(); } + stopPhaseTimer(); + if (oldState !== instance.state) { { error( @@ -8064,6 +7820,7 @@ function callComponentWillReceiveProps( nextContext ) { var oldState = instance.state; + startPhaseTimer(workInProgress, "componentWillReceiveProps"); if (typeof instance.componentWillReceiveProps === "function") { instance.componentWillReceiveProps(newProps, nextContext); @@ -8073,6 +7830,8 @@ function callComponentWillReceiveProps( instance.UNSAFE_componentWillReceiveProps(newProps, nextContext); } + stopPhaseTimer(); + if (instance.state !== oldState) { { var componentName = getComponentName(workInProgress.type) || "Component"; @@ -8093,7 +7852,12 @@ function callComponentWillReceiveProps( } } // Invokes the mount life-cycles on a previously never rendered instance. -function mountClassInstance(workInProgress, ctor, newProps, renderLanes) { +function mountClassInstance( + workInProgress, + ctor, + newProps, + renderExpirationTime +) { { checkClassInstance(workInProgress, ctor, newProps); } @@ -8143,7 +7907,7 @@ function mountClassInstance(workInProgress, ctor, newProps, renderLanes) { } } - processUpdateQueue(workInProgress, newProps, instance, renderLanes); + processUpdateQueue(workInProgress, newProps, instance, renderExpirationTime); instance.state = workInProgress.memoizedState; var getDerivedStateFromProps = ctor.getDerivedStateFromProps; @@ -8167,7 +7931,12 @@ function mountClassInstance(workInProgress, ctor, newProps, renderLanes) { callComponentWillMount(workInProgress, instance); // If we had additional state updates during this life-cycle, let's // process them now. - processUpdateQueue(workInProgress, newProps, instance, renderLanes); + processUpdateQueue( + workInProgress, + newProps, + instance, + renderExpirationTime + ); instance.state = workInProgress.memoizedState; } @@ -8176,7 +7945,12 @@ function mountClassInstance(workInProgress, ctor, newProps, renderLanes) { } } -function resumeMountClassInstance(workInProgress, ctor, newProps, renderLanes) { +function resumeMountClassInstance( + workInProgress, + ctor, + newProps, + renderExpirationTime +) { var instance = workInProgress.stateNode; var oldProps = workInProgress.memoizedProps; instance.props = oldProps; @@ -8222,7 +7996,7 @@ function resumeMountClassInstance(workInProgress, ctor, newProps, renderLanes) { resetHasForceUpdateBeforeProcessing(); var oldState = workInProgress.memoizedState; var newState = (instance.state = oldState); - processUpdateQueue(workInProgress, newProps, instance, renderLanes); + processUpdateQueue(workInProgress, newProps, instance, renderExpirationTime); newState = workInProgress.memoizedState; if ( @@ -8270,6 +8044,8 @@ function resumeMountClassInstance(workInProgress, ctor, newProps, renderLanes) { (typeof instance.UNSAFE_componentWillMount === "function" || typeof instance.componentWillMount === "function") ) { + startPhaseTimer(workInProgress, "componentWillMount"); + if (typeof instance.componentWillMount === "function") { instance.componentWillMount(); } @@ -8277,6 +8053,8 @@ function resumeMountClassInstance(workInProgress, ctor, newProps, renderLanes) { if (typeof instance.UNSAFE_componentWillMount === "function") { instance.UNSAFE_componentWillMount(); } + + stopPhaseTimer(); } if (typeof instance.componentDidMount === "function") { @@ -8306,17 +8084,15 @@ function updateClassInstance( workInProgress, ctor, newProps, - renderLanes + renderExpirationTime ) { var instance = workInProgress.stateNode; cloneUpdateQueue(current, workInProgress); - var unresolvedOldProps = workInProgress.memoizedProps; - var oldProps = + var oldProps = workInProgress.memoizedProps; + instance.props = workInProgress.type === workInProgress.elementType - ? unresolvedOldProps - : resolveDefaultProps(workInProgress.type, unresolvedOldProps); - instance.props = oldProps; - var unresolvedNewProps = workInProgress.pendingProps; + ? oldProps + : resolveDefaultProps(workInProgress.type, oldProps); var oldContext = instance.context; var contextType = ctor.contextType; var nextContext = emptyContextObject; @@ -8342,10 +8118,7 @@ function updateClassInstance( (typeof instance.UNSAFE_componentWillReceiveProps === "function" || typeof instance.componentWillReceiveProps === "function") ) { - if ( - unresolvedOldProps !== unresolvedNewProps || - oldContext !== nextContext - ) { + if (oldProps !== newProps || oldContext !== nextContext) { callComponentWillReceiveProps( workInProgress, instance, @@ -8358,11 +8131,11 @@ function updateClassInstance( resetHasForceUpdateBeforeProcessing(); var oldState = workInProgress.memoizedState; var newState = (instance.state = oldState); - processUpdateQueue(workInProgress, newProps, instance, renderLanes); + processUpdateQueue(workInProgress, newProps, instance, renderExpirationTime); newState = workInProgress.memoizedState; if ( - unresolvedOldProps === unresolvedNewProps && + oldProps === newProps && oldState === newState && !hasContextChanged() && !checkHasForceUpdateAfterProcessing() @@ -8371,7 +8144,7 @@ function updateClassInstance( // effect even though we're bailing out, so that cWU/cDU are called. if (typeof instance.componentDidUpdate === "function") { if ( - unresolvedOldProps !== current.memoizedProps || + oldProps !== current.memoizedProps || oldState !== current.memoizedState ) { workInProgress.effectTag |= Update; @@ -8380,7 +8153,7 @@ function updateClassInstance( if (typeof instance.getSnapshotBeforeUpdate === "function") { if ( - unresolvedOldProps !== current.memoizedProps || + oldProps !== current.memoizedProps || oldState !== current.memoizedState ) { workInProgress.effectTag |= Snapshot; @@ -8420,6 +8193,8 @@ function updateClassInstance( (typeof instance.UNSAFE_componentWillUpdate === "function" || typeof instance.componentWillUpdate === "function") ) { + startPhaseTimer(workInProgress, "componentWillUpdate"); + if (typeof instance.componentWillUpdate === "function") { instance.componentWillUpdate(newProps, newState, nextContext); } @@ -8427,6 +8202,8 @@ function updateClassInstance( if (typeof instance.UNSAFE_componentWillUpdate === "function") { instance.UNSAFE_componentWillUpdate(newProps, newState, nextContext); } + + stopPhaseTimer(); } if (typeof instance.componentDidUpdate === "function") { @@ -8441,7 +8218,7 @@ function updateClassInstance( // effect even though we're bailing out, so that cWU/cDU are called. if (typeof instance.componentDidUpdate === "function") { if ( - unresolvedOldProps !== current.memoizedProps || + oldProps !== current.memoizedProps || oldState !== current.memoizedState ) { workInProgress.effectTag |= Update; @@ -8450,7 +8227,7 @@ function updateClassInstance( if (typeof instance.getSnapshotBeforeUpdate === "function") { if ( - unresolvedOldProps !== current.memoizedProps || + oldProps !== current.memoizedProps || oldState !== current.memoizedState ) { workInProgress.effectTag |= Snapshot; @@ -8475,7 +8252,7 @@ var didWarnAboutStringRefs; var ownerHasKeyUseWarning; var ownerHasFunctionTypeWarning; -var warnForMissingKey = function(child, returnFiber) {}; +var warnForMissingKey = function(child) {}; { didWarnAboutMaps = false; @@ -8490,7 +8267,7 @@ var warnForMissingKey = function(child, returnFiber) {}; ownerHasKeyUseWarning = {}; ownerHasFunctionTypeWarning = {}; - warnForMissingKey = function(child, returnFiber) { + warnForMissingKey = function(child) { if (child === null || typeof child !== "object") { return; } @@ -8506,13 +8283,17 @@ var warnForMissingKey = function(child, returnFiber) {}; } child._store.validated = true; - var componentName = getComponentName(returnFiber.type) || "Component"; + var currentComponentErrorInfo = + "Each child in a list should have a unique " + + '"key" prop. See https://fb.me/react-warning-keys for ' + + "more information." + + getCurrentFiberStackInDev(); - if (ownerHasKeyUseWarning[componentName]) { + if (ownerHasKeyUseWarning[currentComponentErrorInfo]) { return; } - ownerHasKeyUseWarning[componentName] = true; + ownerHasKeyUseWarning[currentComponentErrorInfo] = true; error( "Each child in a list should have a unique " + @@ -8554,8 +8335,9 @@ function coerceRef(returnFiber, current, element) { "String refs are a source of potential bugs and should be avoided. " + "We recommend using useRef() or createRef() instead. " + "Learn more about using refs safely here: " + - "https://fb.me/react-strict-mode-string-ref", - mixedRef + "https://fb.me/react-strict-mode-string-ref%s", + mixedRef, + getStackByFiberInDevAndProd(returnFiber) ); } @@ -8638,27 +8420,41 @@ function coerceRef(returnFiber, current, element) { function throwOnInvalidObjectType(returnFiber, newChild) { if (returnFiber.type !== "textarea") { + var addendum = ""; + + { + addendum = + " If you meant to render a collection of children, use an array " + + "instead." + + getCurrentFiberStackInDev(); + } + { throw Error( "Objects are not valid as a React child (found: " + (Object.prototype.toString.call(newChild) === "[object Object]" ? "object with keys {" + Object.keys(newChild).join(", ") + "}" : newChild) + - "). If you meant to render a collection of children, use an array instead." + ")." + + addendum ); } } } -function warnOnFunctionType(returnFiber) { +function warnOnFunctionType() { { - var componentName = getComponentName(returnFiber.type) || "Component"; + var currentComponentErrorInfo = + "Functions are not valid as a React child. This may happen if " + + "you return a Component instead of from render. " + + "Or maybe you meant to call this function rather than return it." + + getCurrentFiberStackInDev(); - if (ownerHasFunctionTypeWarning[componentName]) { + if (ownerHasFunctionTypeWarning[currentComponentErrorInfo]) { return; } - ownerHasFunctionTypeWarning[componentName] = true; + ownerHasFunctionTypeWarning[currentComponentErrorInfo] = true; error( "Functions are not valid as a React child. This may happen if " + @@ -8666,7 +8462,7 @@ function warnOnFunctionType(returnFiber) { "Or maybe you meant to call this function rather than return it." ); } -} // We avoid inlining this to avoid potential deopts from using try/catch. +} // This wrapper function exists because I expect to clone the code in each path // to be able to optimize each path individually by branching early. This needs // a compiler or we can do it manually. Helpers that don't need this branching // live outside of this function. @@ -8779,10 +8575,14 @@ function ChildReconciler(shouldTrackSideEffects) { return newFiber; } - function updateTextNode(returnFiber, current, textContent, lanes) { + function updateTextNode(returnFiber, current, textContent, expirationTime) { if (current === null || current.tag !== HostText) { // Insert - var created = createFiberFromText(textContent, returnFiber.mode, lanes); + var created = createFiberFromText( + textContent, + returnFiber.mode, + expirationTime + ); created.return = returnFiber; return created; } else { @@ -8793,7 +8593,7 @@ function ChildReconciler(shouldTrackSideEffects) { } } - function updateElement(returnFiber, current, element, lanes) { + function updateElement(returnFiber, current, element, expirationTime) { if (current !== null) { if ( current.elementType === element.type || // Keep this check inline so it only runs on the false path: @@ -8813,13 +8613,17 @@ function ChildReconciler(shouldTrackSideEffects) { } } // Insert - var created = createFiberFromElement(element, returnFiber.mode, lanes); + var created = createFiberFromElement( + element, + returnFiber.mode, + expirationTime + ); created.ref = coerceRef(returnFiber, current, element); created.return = returnFiber; return created; } - function updatePortal(returnFiber, current, portal, lanes) { + function updatePortal(returnFiber, current, portal, expirationTime) { if ( current === null || current.tag !== HostPortal || @@ -8827,7 +8631,11 @@ function ChildReconciler(shouldTrackSideEffects) { current.stateNode.implementation !== portal.implementation ) { // Insert - var created = createFiberFromPortal(portal, returnFiber.mode, lanes); + var created = createFiberFromPortal( + portal, + returnFiber.mode, + expirationTime + ); created.return = returnFiber; return created; } else { @@ -8838,13 +8646,13 @@ function ChildReconciler(shouldTrackSideEffects) { } } - function updateFragment(returnFiber, current, fragment, lanes, key) { + function updateFragment(returnFiber, current, fragment, expirationTime, key) { if (current === null || current.tag !== Fragment) { // Insert var created = createFiberFromFragment( fragment, returnFiber.mode, - lanes, + expirationTime, key ); created.return = returnFiber; @@ -8857,12 +8665,16 @@ function ChildReconciler(shouldTrackSideEffects) { } } - function createChild(returnFiber, newChild, lanes) { + function createChild(returnFiber, newChild, expirationTime) { if (typeof newChild === "string" || typeof newChild === "number") { // Text nodes don't have keys. If the previous node is implicitly keyed // we can continue to replace it without aborting even if it is not a text // node. - var created = createFiberFromText("" + newChild, returnFiber.mode, lanes); + var created = createFiberFromText( + "" + newChild, + returnFiber.mode, + expirationTime + ); created.return = returnFiber; return created; } @@ -8873,7 +8685,7 @@ function ChildReconciler(shouldTrackSideEffects) { var _created = createFiberFromElement( newChild, returnFiber.mode, - lanes + expirationTime ); _created.ref = coerceRef(returnFiber, null, newChild); @@ -8885,7 +8697,7 @@ function ChildReconciler(shouldTrackSideEffects) { var _created2 = createFiberFromPortal( newChild, returnFiber.mode, - lanes + expirationTime ); _created2.return = returnFiber; @@ -8897,7 +8709,7 @@ function ChildReconciler(shouldTrackSideEffects) { var _created3 = createFiberFromFragment( newChild, returnFiber.mode, - lanes, + expirationTime, null ); @@ -8910,14 +8722,14 @@ function ChildReconciler(shouldTrackSideEffects) { { if (typeof newChild === "function") { - warnOnFunctionType(returnFiber); + warnOnFunctionType(); } } return null; } - function updateSlot(returnFiber, oldFiber, newChild, lanes) { + function updateSlot(returnFiber, oldFiber, newChild, expirationTime) { // Update the fiber if the keys match, otherwise return null. var key = oldFiber !== null ? oldFiber.key : null; @@ -8929,7 +8741,12 @@ function ChildReconciler(shouldTrackSideEffects) { return null; } - return updateTextNode(returnFiber, oldFiber, "" + newChild, lanes); + return updateTextNode( + returnFiber, + oldFiber, + "" + newChild, + expirationTime + ); } if (typeof newChild === "object" && newChild !== null) { @@ -8941,12 +8758,17 @@ function ChildReconciler(shouldTrackSideEffects) { returnFiber, oldFiber, newChild.props.children, - lanes, + expirationTime, key ); } - return updateElement(returnFiber, oldFiber, newChild, lanes); + return updateElement( + returnFiber, + oldFiber, + newChild, + expirationTime + ); } else { return null; } @@ -8954,7 +8776,12 @@ function ChildReconciler(shouldTrackSideEffects) { case REACT_PORTAL_TYPE: { if (newChild.key === key) { - return updatePortal(returnFiber, oldFiber, newChild, lanes); + return updatePortal( + returnFiber, + oldFiber, + newChild, + expirationTime + ); } else { return null; } @@ -8966,7 +8793,13 @@ function ChildReconciler(shouldTrackSideEffects) { return null; } - return updateFragment(returnFiber, oldFiber, newChild, lanes, null); + return updateFragment( + returnFiber, + oldFiber, + newChild, + expirationTime, + null + ); } throwOnInvalidObjectType(returnFiber, newChild); @@ -8974,7 +8807,7 @@ function ChildReconciler(shouldTrackSideEffects) { { if (typeof newChild === "function") { - warnOnFunctionType(returnFiber); + warnOnFunctionType(); } } @@ -8986,13 +8819,18 @@ function ChildReconciler(shouldTrackSideEffects) { returnFiber, newIdx, newChild, - lanes + expirationTime ) { if (typeof newChild === "string" || typeof newChild === "number") { // Text nodes don't have keys, so we neither have to check the old nor // new node for the key. If both are text nodes, they match. var matchedFiber = existingChildren.get(newIdx) || null; - return updateTextNode(returnFiber, matchedFiber, "" + newChild, lanes); + return updateTextNode( + returnFiber, + matchedFiber, + "" + newChild, + expirationTime + ); } if (typeof newChild === "object" && newChild !== null) { @@ -9008,12 +8846,17 @@ function ChildReconciler(shouldTrackSideEffects) { returnFiber, _matchedFiber, newChild.props.children, - lanes, + expirationTime, newChild.key ); } - return updateElement(returnFiber, _matchedFiber, newChild, lanes); + return updateElement( + returnFiber, + _matchedFiber, + newChild, + expirationTime + ); } case REACT_PORTAL_TYPE: { @@ -9022,7 +8865,12 @@ function ChildReconciler(shouldTrackSideEffects) { newChild.key === null ? newIdx : newChild.key ) || null; - return updatePortal(returnFiber, _matchedFiber2, newChild, lanes); + return updatePortal( + returnFiber, + _matchedFiber2, + newChild, + expirationTime + ); } } @@ -9033,7 +8881,7 @@ function ChildReconciler(shouldTrackSideEffects) { returnFiber, _matchedFiber3, newChild, - lanes, + expirationTime, null ); } @@ -9043,7 +8891,7 @@ function ChildReconciler(shouldTrackSideEffects) { { if (typeof newChild === "function") { - warnOnFunctionType(returnFiber); + warnOnFunctionType(); } } @@ -9053,7 +8901,7 @@ function ChildReconciler(shouldTrackSideEffects) { * Warns if there is a duplicate or missing key */ - function warnOnInvalidKey(child, knownKeys, returnFiber) { + function warnOnInvalidKey(child, knownKeys) { { if (typeof child !== "object" || child === null) { return knownKeys; @@ -9062,7 +8910,7 @@ function ChildReconciler(shouldTrackSideEffects) { switch (child.$$typeof) { case REACT_ELEMENT_TYPE: case REACT_PORTAL_TYPE: - warnForMissingKey(child, returnFiber); + warnForMissingKey(child); var key = child.key; if (typeof key !== "string") { @@ -9100,7 +8948,7 @@ function ChildReconciler(shouldTrackSideEffects) { returnFiber, currentFirstChild, newChildren, - lanes + expirationTime ) { // This algorithm can't optimize by searching from both ends since we // don't have backpointers on fibers. I'm trying to see how far we can get @@ -9123,7 +8971,7 @@ function ChildReconciler(shouldTrackSideEffects) { for (var i = 0; i < newChildren.length; i++) { var child = newChildren[i]; - knownKeys = warnOnInvalidKey(child, knownKeys, returnFiber); + knownKeys = warnOnInvalidKey(child, knownKeys); } } @@ -9146,7 +8994,7 @@ function ChildReconciler(shouldTrackSideEffects) { returnFiber, oldFiber, newChildren[newIdx], - lanes + expirationTime ); if (newFiber === null) { @@ -9196,7 +9044,11 @@ function ChildReconciler(shouldTrackSideEffects) { // If we don't have any more existing children we can choose a fast path // since the rest will all be insertions. for (; newIdx < newChildren.length; newIdx++) { - var _newFiber = createChild(returnFiber, newChildren[newIdx], lanes); + var _newFiber = createChild( + returnFiber, + newChildren[newIdx], + expirationTime + ); if (_newFiber === null) { continue; @@ -9225,7 +9077,7 @@ function ChildReconciler(shouldTrackSideEffects) { returnFiber, newIdx, newChildren[newIdx], - lanes + expirationTime ); if (_newFiber2 !== null) { @@ -9268,7 +9120,7 @@ function ChildReconciler(shouldTrackSideEffects) { returnFiber, currentFirstChild, newChildrenIterable, - lanes + expirationTime ) { // This is the same implementation as reconcileChildrenArray(), // but using the iterator instead. @@ -9303,8 +9155,9 @@ function ChildReconciler(shouldTrackSideEffects) { if (newChildrenIterable.entries === iteratorFn) { if (!didWarnAboutMaps) { error( - "Using Maps as children is not supported. " + - "Use an array of keyed ReactElements instead." + "Using Maps as children is unsupported and will likely yield " + + "unexpected results. Convert it to a sequence/iterable of keyed " + + "ReactElements instead." ); } @@ -9321,7 +9174,7 @@ function ChildReconciler(shouldTrackSideEffects) { for (; !_step.done; _step = _newChildren.next()) { var child = _step.value; - knownKeys = warnOnInvalidKey(child, knownKeys, returnFiber); + knownKeys = warnOnInvalidKey(child, knownKeys); } } } @@ -9352,7 +9205,12 @@ function ChildReconciler(shouldTrackSideEffects) { nextOldFiber = oldFiber.sibling; } - var newFiber = updateSlot(returnFiber, oldFiber, step.value, lanes); + var newFiber = updateSlot( + returnFiber, + oldFiber, + step.value, + expirationTime + ); if (newFiber === null) { // TODO: This breaks on empty slots like null children. That's @@ -9401,7 +9259,7 @@ function ChildReconciler(shouldTrackSideEffects) { // If we don't have any more existing children we can choose a fast path // since the rest will all be insertions. for (; !step.done; newIdx++, step = newChildren.next()) { - var _newFiber3 = createChild(returnFiber, step.value, lanes); + var _newFiber3 = createChild(returnFiber, step.value, expirationTime); if (_newFiber3 === null) { continue; @@ -9430,7 +9288,7 @@ function ChildReconciler(shouldTrackSideEffects) { returnFiber, newIdx, step.value, - lanes + expirationTime ); if (_newFiber4 !== null) { @@ -9473,7 +9331,7 @@ function ChildReconciler(shouldTrackSideEffects) { returnFiber, currentFirstChild, textContent, - lanes + expirationTime ) { // There's no need to check for keys on text nodes since we don't have a // way to define them. @@ -9488,7 +9346,11 @@ function ChildReconciler(shouldTrackSideEffects) { // and delete the existing ones. deleteRemainingChildren(returnFiber, currentFirstChild); - var created = createFiberFromText(textContent, returnFiber.mode, lanes); + var created = createFiberFromText( + textContent, + returnFiber.mode, + expirationTime + ); created.return = returnFiber; return created; } @@ -9497,7 +9359,7 @@ function ChildReconciler(shouldTrackSideEffects) { returnFiber, currentFirstChild, element, - lanes + expirationTime ) { var key = element.key; var child = currentFirstChild; @@ -9566,13 +9428,17 @@ function ChildReconciler(shouldTrackSideEffects) { var created = createFiberFromFragment( element.props.children, returnFiber.mode, - lanes, + expirationTime, element.key ); created.return = returnFiber; return created; } else { - var _created4 = createFiberFromElement(element, returnFiber.mode, lanes); + var _created4 = createFiberFromElement( + element, + returnFiber.mode, + expirationTime + ); _created4.ref = coerceRef(returnFiber, currentFirstChild, element); _created4.return = returnFiber; @@ -9584,7 +9450,7 @@ function ChildReconciler(shouldTrackSideEffects) { returnFiber, currentFirstChild, portal, - lanes + expirationTime ) { var key = portal.key; var child = currentFirstChild; @@ -9613,7 +9479,11 @@ function ChildReconciler(shouldTrackSideEffects) { child = child.sibling; } - var created = createFiberFromPortal(portal, returnFiber.mode, lanes); + var created = createFiberFromPortal( + portal, + returnFiber.mode, + expirationTime + ); created.return = returnFiber; return created; } // This API will tag the children with the side-effect of the reconciliation @@ -9624,7 +9494,7 @@ function ChildReconciler(shouldTrackSideEffects) { returnFiber, currentFirstChild, newChild, - lanes + expirationTime ) { // This function is not recursive. // If the top level item is an array, we treat it as a set of children, @@ -9653,7 +9523,7 @@ function ChildReconciler(shouldTrackSideEffects) { returnFiber, currentFirstChild, newChild, - lanes + expirationTime ) ); @@ -9663,7 +9533,7 @@ function ChildReconciler(shouldTrackSideEffects) { returnFiber, currentFirstChild, newChild, - lanes + expirationTime ) ); } @@ -9675,7 +9545,7 @@ function ChildReconciler(shouldTrackSideEffects) { returnFiber, currentFirstChild, "" + newChild, - lanes + expirationTime ) ); } @@ -9685,7 +9555,7 @@ function ChildReconciler(shouldTrackSideEffects) { returnFiber, currentFirstChild, newChild, - lanes + expirationTime ); } @@ -9694,7 +9564,7 @@ function ChildReconciler(shouldTrackSideEffects) { returnFiber, currentFirstChild, newChild, - lanes + expirationTime ); } @@ -9704,7 +9574,7 @@ function ChildReconciler(shouldTrackSideEffects) { { if (typeof newChild === "function") { - warnOnFunctionType(returnFiber); + warnOnFunctionType(); } } @@ -9774,11 +9644,11 @@ function cloneChildFibers(current, workInProgress) { newChild.sibling = null; } // Reset a workInProgress child set to prepare it for a second pass. -function resetChildFibers(workInProgress, lanes) { +function resetChildFibers(workInProgress, renderExpirationTime) { var child = workInProgress.child; while (child !== null) { - resetWorkInProgress(child, lanes); + resetWorkInProgress(child, renderExpirationTime); child = child.sibling; } } @@ -9896,13 +9766,6 @@ function popSuspenseContext(fiber) { pop(suspenseStackCursor, fiber); } -// A non-null SuspenseState means that it is blocked for one reason or another. -// - A non-null dehydrated field means it's blocked pending hydration. -// - A non-null dehydrated field can use isSuspenseInstancePending or -// isSuspenseInstanceFallback to query the reason for being dehydrated. -// - A null dehydrated field means it's blocked by something suspending and -// we're currently showing a fallback instead. - function shouldCaptureSuspense(workInProgress, hasInvisibleParent) { // If it was the primary children that just suspended, capture and render the // fallback. Otherwise, don't capture and bubble to the next boundary. @@ -10000,10 +9863,6 @@ function createDeprecatedResponderListener(responder, props) { return eventResponderListener; } -var NoEffect$1 = - /* */ - 0; // Represents whether effect should fire. - var HasEffect = /* */ 1; // Represents the phase in which the effect (not the clean-up) fires. @@ -10015,113 +9874,16 @@ var Passive$1 = /* */ 4; -var isHydrating = false; - -function enterHydrationState(fiber) { - { - return false; - } -} - -function prepareToHydrateHostInstance( - fiber, - rootContainerInstance, - hostContext -) { - { - { - throw Error( - "Expected prepareToHydrateHostInstance() to never be called. This error is likely caused by a bug in React. Please file an issue." - ); - } - } -} - -function prepareToHydrateHostTextInstance(fiber) { - { - { - throw Error( - "Expected prepareToHydrateHostTextInstance() to never be called. This error is likely caused by a bug in React. Please file an issue." - ); - } - } - var shouldUpdate = hydrateTextInstance(); -} - -function popHydrationState(fiber) { - { - return false; - } -} - -function getIsHydrating() { - return isHydrating; -} - -// and should be reset before starting a new render. -// This tracks which mutable sources need to be reset after a render. - -var workInProgressSources = []; -var rendererSigil$1; - -{ - // Used to detect multiple renderers using the same mutable source. - rendererSigil$1 = {}; -} - -function markSourceAsDirty(mutableSource) { - workInProgressSources.push(mutableSource); -} -function resetWorkInProgressVersions() { - for (var i = 0; i < workInProgressSources.length; i++) { - var mutableSource = workInProgressSources[i]; - - { - mutableSource._workInProgressVersionPrimary = null; - } - } - - workInProgressSources.length = 0; -} -function getWorkInProgressVersion(mutableSource) { - { - return mutableSource._workInProgressVersionPrimary; - } -} -function setWorkInProgressVersion(mutableSource, version) { - { - mutableSource._workInProgressVersionPrimary = version; - } - - workInProgressSources.push(mutableSource); -} -function warnAboutMultipleRenderersDEV(mutableSource) { - { - { - if (mutableSource._currentPrimaryRenderer == null) { - mutableSource._currentPrimaryRenderer = rendererSigil$1; - } else if (mutableSource._currentPrimaryRenderer !== rendererSigil$1) { - error( - "Detected multiple renderers concurrently rendering the " + - "same mutable source. This is currently unsupported." - ); - } - } - } -} // Eager reads the version of a mutable source and stores it on the root. - -var ReactCurrentDispatcher$1 = ReactSharedInternals.ReactCurrentDispatcher, +var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher, ReactCurrentBatchConfig$1 = ReactSharedInternals.ReactCurrentBatchConfig; var didWarnAboutMismatchedHooksForComponent; -var didWarnAboutUseOpaqueIdentifier; { - didWarnAboutUseOpaqueIdentifier = {}; didWarnAboutMismatchedHooksForComponent = new Set(); } // These are set right before calling the component. -var renderLanes = NoLanes; // The work-in-progress fiber. I've named it differently to distinguish it from +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 @@ -10135,12 +9897,7 @@ var workInProgressHook = null; // Whether an update was scheduled at any point d // finished evaluating this component. This is an optimization so we know // whether we need to clear render phase updates after a throw. -var didScheduleRenderPhaseUpdate = false; // Where an update was scheduled only during the current render pass. This -// gets reset after each attempt. -// TODO: Maybe there's some way to consolidate this with -// `didScheduleRenderPhaseUpdate`. Or with `numberOfReRenders`. - -var didScheduleRenderPhaseUpdateDuringThisPass = false; +var didScheduleRenderPhaseUpdate = false; var RE_RENDER_LIMIT = 25; // In DEV, this is the name of the currently executing primitive hook var currentHookNameInDev = null; // In DEV, this list ensures that hooks are called in the same order between renders. @@ -10299,9 +10056,9 @@ function renderWithHooks( Component, props, secondArg, - nextRenderLanes + nextRenderExpirationTime ) { - renderLanes = nextRenderLanes; + renderExpirationTime = nextRenderExpirationTime; currentlyRenderingFiber$1 = workInProgress; { @@ -10314,7 +10071,7 @@ function renderWithHooks( workInProgress.memoizedState = null; workInProgress.updateQueue = null; - workInProgress.lanes = NoLanes; // The following should have already been reset + workInProgress.expirationTime = NoWork; // The following should have already been reset // currentHook = null; // workInProgressHook = null; // didScheduleRenderPhaseUpdate = false; @@ -10327,28 +10084,28 @@ function renderWithHooks( { if (current !== null && current.memoizedState !== null) { - ReactCurrentDispatcher$1.current = HooksDispatcherOnUpdateInDEV; + ReactCurrentDispatcher.current = HooksDispatcherOnUpdateInDEV; } else if (hookTypesDev !== null) { // This dispatcher handles an edge case where a component is updating, // but no stateful hooks have been used. // We want to match the production code behavior (which will use HooksDispatcherOnMount), // but with the extra DEV validation to ensure hooks ordering hasn't changed. // This dispatcher does that. - ReactCurrentDispatcher$1.current = HooksDispatcherOnMountWithHookTypesInDEV; + ReactCurrentDispatcher.current = HooksDispatcherOnMountWithHookTypesInDEV; } else { - ReactCurrentDispatcher$1.current = HooksDispatcherOnMountInDEV; + ReactCurrentDispatcher.current = HooksDispatcherOnMountInDEV; } } var children = Component(props, secondArg); // Check if there was a render phase update - if (didScheduleRenderPhaseUpdateDuringThisPass) { + if (workInProgress.expirationTime === renderExpirationTime) { // Keep rendering in a loop for as long as render phase updates continue to // be scheduled. Use a counter to prevent infinite loops. var numberOfReRenders = 0; do { - didScheduleRenderPhaseUpdateDuringThisPass = false; + workInProgress.expirationTime = NoWork; if (!(numberOfReRenders < RE_RENDER_LIMIT)) { throw Error( @@ -10373,13 +10130,13 @@ function renderWithHooks( hookTypesUpdateIndexDev = -1; } - ReactCurrentDispatcher$1.current = HooksDispatcherOnRerenderInDEV; + ReactCurrentDispatcher.current = HooksDispatcherOnRerenderInDEV; children = Component(props, secondArg); - } while (didScheduleRenderPhaseUpdateDuringThisPass); + } while (workInProgress.expirationTime === renderExpirationTime); } // We can assume the previous dispatcher is always this one, since we set it // at the beginning of the render phase and there's no re-entrancy. - ReactCurrentDispatcher$1.current = ContextOnlyDispatcher; + ReactCurrentDispatcher.current = ContextOnlyDispatcher; { workInProgress._debugHookTypes = hookTypesDev; @@ -10387,7 +10144,7 @@ function renderWithHooks( // hookTypesDev could catch more cases (e.g. context) but only in DEV bundles. var didRenderTooFewHooks = currentHook !== null && currentHook.next !== null; - renderLanes = NoLanes; + renderExpirationTime = NoWork; currentlyRenderingFiber$1 = null; currentHook = null; workInProgressHook = null; @@ -10408,15 +10165,18 @@ function renderWithHooks( return children; } -function bailoutHooks(current, workInProgress, lanes) { +function bailoutHooks(current, workInProgress, expirationTime) { workInProgress.updateQueue = current.updateQueue; workInProgress.effectTag &= ~(Passive | Update); - current.lanes = removeLanes(current.lanes, lanes); + + if (current.expirationTime <= expirationTime) { + current.expirationTime = NoWork; + } } function resetHooksAfterThrow() { // We can assume the previous dispatcher is always this one, since we set it // at the beginning of the render phase and there's no re-entrancy. - ReactCurrentDispatcher$1.current = ContextOnlyDispatcher; + ReactCurrentDispatcher.current = ContextOnlyDispatcher; if (didScheduleRenderPhaseUpdate) { // There were render phase updates. These are only valid for this render @@ -10438,11 +10198,9 @@ function resetHooksAfterThrow() { hook = hook.next; } - - didScheduleRenderPhaseUpdate = false; } - renderLanes = NoLanes; + renderExpirationTime = NoWork; currentlyRenderingFiber$1 = null; currentHook = null; workInProgressHook = null; @@ -10451,10 +10209,9 @@ function resetHooksAfterThrow() { hookTypesDev = null; hookTypesUpdateIndexDev = -1; currentHookNameInDev = null; - isUpdatingOpaqueValueInRenderPhase = false; } - didScheduleRenderPhaseUpdateDuringThisPass = false; + didScheduleRenderPhaseUpdate = false; } function mountWorkInProgressHook() { @@ -10601,17 +10358,6 @@ function updateReducer(reducer, initialArg, init) { pendingQueue.next = baseFirst; } - { - if (current.baseQueue !== baseQueue) { - // Internal invariant that should never happen, but feasibly could in - // the future if we implement resuming, or some form of that. - error( - "Internal error: Expected work-in-progress queue to be a clone. " + - "This is a bug in React." - ); - } - } - current.baseQueue = baseQueue = pendingQueue; queue.pending = null; } @@ -10626,18 +10372,15 @@ function updateReducer(reducer, initialArg, init) { var update = first; do { - var suspenseConfig = update.suspenseConfig; - var updateLane = update.lane; - var updateEventTime = update.eventTime; + var updateExpirationTime = update.expirationTime; - if (!isSubsetOfLanes(renderLanes, updateLane)) { + 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. var clone = { - eventTime: updateEventTime, - lane: updateLane, - suspenseConfig: suspenseConfig, + expirationTime: update.expirationTime, + suspenseConfig: update.suspenseConfig, action: update.action, eagerReducer: update.eagerReducer, eagerState: update.eagerState, @@ -10650,23 +10393,17 @@ function updateReducer(reducer, initialArg, init) { } else { newBaseQueueLast = newBaseQueueLast.next = clone; } // Update the remaining priority in the queue. - // TODO: Don't need to accumulate this. Instead, we can remove - // renderLanes from the original lanes. - currentlyRenderingFiber$1.lanes = mergeLanes( - currentlyRenderingFiber$1.lanes, - updateLane - ); - markSkippedUpdateLanes(updateLane); + if (updateExpirationTime > currentlyRenderingFiber$1.expirationTime) { + currentlyRenderingFiber$1.expirationTime = updateExpirationTime; + markUnprocessedUpdateTime(updateExpirationTime); + } } else { // This update does have sufficient priority. if (newBaseQueueLast !== null) { var _clone = { - eventTime: updateEventTime, - // This update is going to be committed so we never want uncommit - // it. Using NoLane works because 0 is a subset of all bitmasks, so - // this will never be skipped by the check above. - lane: NoLane, + expirationTime: Sync, + // This update is going to be committed so we never want uncommit it. suspenseConfig: update.suspenseConfig, action: update.action, eagerReducer: update.eagerReducer, @@ -10676,12 +10413,15 @@ function updateReducer(reducer, initialArg, init) { newBaseQueueLast = newBaseQueueLast.next = _clone; } // Mark the event time of this update as relevant to this render pass. // TODO: This should ideally use the true event time of this update rather than - // its priority which is a derived and not reversible value. + // its priority which is a derived and not reverseable value. // TODO: We should skip this update if it was already committed but currently // we have no way of detecting the difference between a committed and suspended // update here. - markRenderEventTimeAndConfig(updateEventTime, suspenseConfig); // Process this update. + markRenderEventTimeAndConfig( + updateExpirationTime, + update.suspenseConfig + ); // Process this update. if (update.eagerReducer === reducer) { // If this update was processed eagerly, and its reducer matches the @@ -10769,253 +10509,6 @@ function rerenderReducer(reducer, initialArg, init) { return [newState, dispatch]; } -function readFromUnsubcribedMutableSource(root, source, getSnapshot) { - { - warnAboutMultipleRenderersDEV(source); - } - - var getVersion = source._getVersion; - var version = getVersion(source._source); // Is it safe for this component to read from this source during the current render? - - var isSafeToReadFromSource = false; // Check the version first. - // If this render has already been started with a specific version, - // we can use it alone to determine if we can safely read from the source. - - var currentRenderVersion = getWorkInProgressVersion(source); - - if (currentRenderVersion !== null) { - // It's safe to read if the store hasn't been mutated since the last time - // we read something. - isSafeToReadFromSource = currentRenderVersion === version; - } else { - // If there's no version, then this is the first time we've read from the - // source during the current render pass, so we need to do a bit more work. - // What we need to determine is if there are any hooks that already - // subscribed to the source, and if so, whether there are any pending - // mutations that haven't been synchronized yet. - // - // If there are no pending mutations, then `root.mutableReadLanes` will be - // empty, and we know we can safely read. - // - // If there *are* pending mutations, we may still be able to safely read - // if the currently rendering lanes are inclusive of the pending mutation - // lanes, since that guarantees that the value we're about to read from - // the source is consistent with the values that we read during the most - // recent mutation. - isSafeToReadFromSource = isSubsetOfLanes( - renderLanes, - root.mutableReadLanes - ); - - if (isSafeToReadFromSource) { - // If it's safe to read from this source during the current render, - // store the version in case other components read from it. - // A changed version number will let those components know to throw and restart the render. - setWorkInProgressVersion(source, version); - } - } - - if (isSafeToReadFromSource) { - var snapshot = getSnapshot(source._source); - - { - if (typeof snapshot === "function") { - error( - "Mutable source should not return a function as the snapshot value. " + - "Functions may close over mutable values and cause tearing." - ); - } - } - - return snapshot; - } else { - // This handles the special case of a mutable source being shared between renderers. - // In that case, if the source is mutated between the first and second renderer, - // The second renderer don't know that it needs to reset the WIP version during unwind, - // (because the hook only marks sources as dirty if it's written to their WIP version). - // That would cause this tear check to throw again and eventually be visible to the user. - // We can avoid this infinite loop by explicitly marking the source as dirty. - // - // This can lead to tearing in the first renderer when it resumes, - // but there's nothing we can do about that (short of throwing here and refusing to continue the render). - markSourceAsDirty(source); - - { - throw Error( - "Cannot read from mutable source during the current render without tearing. This is a bug in React. Please file an issue." - ); - } - } -} - -function useMutableSource(hook, source, getSnapshot, subscribe) { - var root = getWorkInProgressRoot(); - - if (!(root !== null)) { - throw Error( - "Expected a work-in-progress root. This is a bug in React. Please file an issue." - ); - } - - var getVersion = source._getVersion; - var version = getVersion(source._source); - var dispatcher = ReactCurrentDispatcher$1.current; // eslint-disable-next-line prefer-const - - var _dispatcher$useState = dispatcher.useState(function() { - return readFromUnsubcribedMutableSource(root, source, getSnapshot); - }), - currentSnapshot = _dispatcher$useState[0], - setSnapshot = _dispatcher$useState[1]; - - var snapshot = currentSnapshot; // Grab a handle to the state hook as well. - // We use it to clear the pending update queue if we have a new source. - - var stateHook = workInProgressHook; - var memoizedState = hook.memoizedState; - var refs = memoizedState.refs; - var prevGetSnapshot = refs.getSnapshot; - var prevSource = memoizedState.source; - var prevSubscribe = memoizedState.subscribe; - var fiber = currentlyRenderingFiber$1; - hook.memoizedState = { - refs: refs, - source: source, - subscribe: subscribe - }; // Sync the values needed by our subscription handler after each commit. - - dispatcher.useEffect( - function() { - refs.getSnapshot = getSnapshot; // Normally the dispatch function for a state hook never changes, - // but this hook recreates the queue in certain cases to avoid updates from stale sources. - // handleChange() below needs to reference the dispatch function without re-subscribing, - // so we use a ref to ensure that it always has the latest version. - - refs.setSnapshot = setSnapshot; // Check for a possible change between when we last rendered now. - - var maybeNewVersion = getVersion(source._source); - - if (!objectIs(version, maybeNewVersion)) { - var maybeNewSnapshot = getSnapshot(source._source); - - { - if (typeof maybeNewSnapshot === "function") { - error( - "Mutable source should not return a function as the snapshot value. " + - "Functions may close over mutable values and cause tearing." - ); - } - } - - if (!objectIs(snapshot, maybeNewSnapshot)) { - setSnapshot(maybeNewSnapshot); - var suspenseConfig = requestCurrentSuspenseConfig(); - var lane = requestUpdateLane(fiber, suspenseConfig); - markRootMutableRead(root, lane); - } // If the source mutated between render and now, - // there may be state updates already scheduled from the old source. - // Entangle the updates so that they render in the same batch. - - markRootEntangled(root, root.mutableReadLanes); - } - }, - [getSnapshot, source, subscribe] - ); // If we got a new source or subscribe function, re-subscribe in a passive effect. - - dispatcher.useEffect( - function() { - var handleChange = function() { - var latestGetSnapshot = refs.getSnapshot; - var latestSetSnapshot = refs.setSnapshot; - - try { - latestSetSnapshot(latestGetSnapshot(source._source)); // Record a pending mutable source update with the same expiration time. - - var suspenseConfig = requestCurrentSuspenseConfig(); - var lane = requestUpdateLane(fiber, suspenseConfig); - markRootMutableRead(root, lane); - } catch (error) { - // A selector might throw after a source mutation. - // e.g. it might try to read from a part of the store that no longer exists. - // In this case we should still schedule an update with React. - // Worst case the selector will throw again and then an error boundary will handle it. - latestSetSnapshot(function() { - throw error; - }); - } - }; - - var unsubscribe = subscribe(source._source, handleChange); - - { - if (typeof unsubscribe !== "function") { - error( - "Mutable source subscribe function must return an unsubscribe function." - ); - } - } - - return unsubscribe; - }, - [source, subscribe] - ); // If any of the inputs to useMutableSource change, reading is potentially unsafe. - // - // If either the source or the subscription have changed we can't can't trust the update queue. - // Maybe the source changed in a way that the old subscription ignored but the new one depends on. - // - // If the getSnapshot function changed, we also shouldn't rely on the update queue. - // It's possible that the underlying source was mutated between the when the last "change" event fired, - // and when the current render (with the new getSnapshot function) is processed. - // - // In both cases, we need to throw away pending updates (since they are no longer relevant) - // and treat reading from the source as we do in the mount case. - - if ( - !objectIs(prevGetSnapshot, getSnapshot) || - !objectIs(prevSource, source) || - !objectIs(prevSubscribe, subscribe) - ) { - // Create a new queue and setState method, - // So if there are interleaved updates, they get pushed to the older queue. - // When this becomes current, the previous queue and dispatch method will be discarded, - // including any interleaving updates that occur. - var newQueue = { - pending: null, - dispatch: null, - lastRenderedReducer: basicStateReducer, - lastRenderedState: snapshot - }; - newQueue.dispatch = setSnapshot = dispatchAction.bind( - null, - currentlyRenderingFiber$1, - newQueue - ); - stateHook.queue = newQueue; - stateHook.baseQueue = null; - snapshot = readFromUnsubcribedMutableSource(root, source, getSnapshot); - stateHook.memoizedState = stateHook.baseState = snapshot; - } - - return snapshot; -} - -function mountMutableSource(source, getSnapshot, subscribe) { - var hook = mountWorkInProgressHook(); - hook.memoizedState = { - refs: { - getSnapshot: getSnapshot, - setSnapshot: null - }, - source: source, - subscribe: subscribe - }; - return useMutableSource(hook, source, getSnapshot, subscribe); -} - -function updateMutableSource(source, getSnapshot, subscribe) { - var hook = updateWorkInProgressHook(); - return useMutableSource(hook, source, getSnapshot, subscribe); -} - function mountState(initialState) { var hook = mountWorkInProgressHook(); @@ -11370,15 +10863,13 @@ function rerenderDeferredValue(value, config) { function startTransition(setPending, config, callback) { var priorityLevel = getCurrentPriorityLevel(); runWithPriority( - priorityLevel < UserBlockingPriority$1 - ? UserBlockingPriority$1 - : priorityLevel, + priorityLevel < UserBlockingPriority ? UserBlockingPriority : priorityLevel, function() { setPending(true); } - ); // If there's no SuspenseConfig set, we'll use the DefaultLanePriority for this transition. + ); runWithPriority( - priorityLevel > NormalPriority$1 ? NormalPriority$1 : priorityLevel, + priorityLevel > NormalPriority ? NormalPriority : priorityLevel, function() { var previousConfig = ReactCurrentBatchConfig$1.suspense; ReactCurrentBatchConfig$1.suspense = config === undefined ? null : config; @@ -11429,54 +10920,6 @@ function rerenderTransition(config) { return [start, isPending]; } -var isUpdatingOpaqueValueInRenderPhase = false; -function getIsUpdatingOpaqueValueInRenderPhaseInDEV() { - { - return isUpdatingOpaqueValueInRenderPhase; - } -} - -function warnOnOpaqueIdentifierAccessInDEV(fiber) { - { - // TODO: Should warn in effects and callbacks, too - var name = getComponentName(fiber.type) || "Unknown"; - - if (getIsRendering() && !didWarnAboutUseOpaqueIdentifier[name]) { - error( - "The object passed back from useOpaqueIdentifier is meant to be " + - "passed through to attributes only. Do not read the " + - "value directly." - ); - - didWarnAboutUseOpaqueIdentifier[name] = true; - } - } -} - -function mountOpaqueIdentifier() { - var makeId = makeClientIdInDEV.bind( - null, - warnOnOpaqueIdentifierAccessInDEV.bind(null, currentlyRenderingFiber$1) - ); - - { - var _id = makeId(); - - mountState(_id); - return _id; - } -} - -function updateOpaqueIdentifier() { - var id = updateState()[0]; - return id; -} - -function rerenderOpaqueIdentifier() { - var id = rerenderState()[0]; - return id; -} - function dispatchAction(fiber, queue, action) { { if (typeof arguments[3] === "function") { @@ -11488,18 +10931,25 @@ function dispatchAction(fiber, queue, action) { } } - var eventTime = requestEventTime(); + var currentTime = requestCurrentTimeForUpdate(); var suspenseConfig = requestCurrentSuspenseConfig(); - var lane = requestUpdateLane(fiber, suspenseConfig); + var expirationTime = computeExpirationForFiber( + currentTime, + fiber, + suspenseConfig + ); var update = { - eventTime: eventTime, - lane: lane, + expirationTime: expirationTime, suspenseConfig: suspenseConfig, action: action, eagerReducer: null, eagerState: null, next: null - }; // Append the update to the end of the list. + }; + + { + update.priority = getCurrentPriorityLevel(); + } // Append the update to the end of the list. var pending = queue.pending; @@ -11521,11 +10971,13 @@ function dispatchAction(fiber, queue, action) { // 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. - didScheduleRenderPhaseUpdateDuringThisPass = didScheduleRenderPhaseUpdate = true; + didScheduleRenderPhaseUpdate = true; + update.expirationTime = renderExpirationTime; + currentlyRenderingFiber$1.expirationTime = renderExpirationTime; } else { if ( - fiber.lanes === NoLanes && - (alternate === null || alternate.lanes === NoLanes) + fiber.expirationTime === NoWork && + (alternate === null || alternate.expirationTime === NoWork) ) { // The queue is currently empty, which means we can eagerly compute the // next state before entering the render phase. If the new state is the @@ -11536,8 +10988,8 @@ function dispatchAction(fiber, queue, action) { var prevDispatcher; { - prevDispatcher = ReactCurrentDispatcher$1.current; - ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV; + prevDispatcher = ReactCurrentDispatcher.current; + ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnUpdateInDEV; } try { @@ -11561,7 +11013,7 @@ function dispatchAction(fiber, queue, action) { // Suppress the error. It will throw again in the render phase. } finally { { - ReactCurrentDispatcher$1.current = prevDispatcher; + ReactCurrentDispatcher.current = prevDispatcher; } } } @@ -11575,10 +11027,18 @@ function dispatchAction(fiber, queue, action) { } } - scheduleUpdateOnFiber(fiber, lane, eventTime); + scheduleWork(fiber, expirationTime); } } +function mountEventListener(event) { + return undefined; +} + +function updateEventListener(event) { + return undefined; +} + var ContextOnlyDispatcher = { readContext: readContext, useCallback: throwInvalidHookError, @@ -11594,9 +11054,7 @@ var ContextOnlyDispatcher = { useResponder: throwInvalidHookError, useDeferredValue: throwInvalidHookError, useTransition: throwInvalidHookError, - useMutableSource: throwInvalidHookError, - useOpaqueIdentifier: throwInvalidHookError, - unstable_isNewReconciler: enableNewReconciler + useEvent: throwInvalidHookError }; var HooksDispatcherOnMountInDEV = null; var HooksDispatcherOnMountWithHookTypesInDEV = null; @@ -11662,25 +11120,25 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; currentHookNameInDev = "useMemo"; mountHookTypesDev(); checkDepsAreArrayDev(deps); - var prevDispatcher = ReactCurrentDispatcher$1.current; - ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV; + var prevDispatcher = ReactCurrentDispatcher.current; + ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnMountInDEV; try { return mountMemo(create, deps); } finally { - ReactCurrentDispatcher$1.current = prevDispatcher; + ReactCurrentDispatcher.current = prevDispatcher; } }, useReducer: function(reducer, initialArg, init) { currentHookNameInDev = "useReducer"; mountHookTypesDev(); - var prevDispatcher = ReactCurrentDispatcher$1.current; - ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV; + var prevDispatcher = ReactCurrentDispatcher.current; + ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnMountInDEV; try { return mountReducer(reducer, initialArg, init); } finally { - ReactCurrentDispatcher$1.current = prevDispatcher; + ReactCurrentDispatcher.current = prevDispatcher; } }, useRef: function(initialValue) { @@ -11691,13 +11149,13 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; useState: function(initialState) { currentHookNameInDev = "useState"; mountHookTypesDev(); - var prevDispatcher = ReactCurrentDispatcher$1.current; - ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV; + var prevDispatcher = ReactCurrentDispatcher.current; + ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnMountInDEV; try { return mountState(initialState); } finally { - ReactCurrentDispatcher$1.current = prevDispatcher; + ReactCurrentDispatcher.current = prevDispatcher; } }, useDebugValue: function(value, formatterFn) { @@ -11720,17 +11178,11 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; mountHookTypesDev(); return mountTransition(config); }, - useMutableSource: function(source, getSnapshot, subscribe) { - currentHookNameInDev = "useMutableSource"; + useEvent: function(event) { + currentHookNameInDev = "useEvent"; mountHookTypesDev(); - return mountMutableSource(source, getSnapshot, subscribe); - }, - useOpaqueIdentifier: function() { - currentHookNameInDev = "useOpaqueIdentifier"; - mountHookTypesDev(); - return mountOpaqueIdentifier(); - }, - unstable_isNewReconciler: enableNewReconciler + return mountEventListener(); + } }; HooksDispatcherOnMountWithHookTypesInDEV = { readContext: function(context, observedBits) { @@ -11764,25 +11216,25 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; useMemo: function(create, deps) { currentHookNameInDev = "useMemo"; updateHookTypesDev(); - var prevDispatcher = ReactCurrentDispatcher$1.current; - ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV; + var prevDispatcher = ReactCurrentDispatcher.current; + ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnMountInDEV; try { return mountMemo(create, deps); } finally { - ReactCurrentDispatcher$1.current = prevDispatcher; + ReactCurrentDispatcher.current = prevDispatcher; } }, useReducer: function(reducer, initialArg, init) { currentHookNameInDev = "useReducer"; updateHookTypesDev(); - var prevDispatcher = ReactCurrentDispatcher$1.current; - ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV; + var prevDispatcher = ReactCurrentDispatcher.current; + ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnMountInDEV; try { return mountReducer(reducer, initialArg, init); } finally { - ReactCurrentDispatcher$1.current = prevDispatcher; + ReactCurrentDispatcher.current = prevDispatcher; } }, useRef: function(initialValue) { @@ -11793,13 +11245,13 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; useState: function(initialState) { currentHookNameInDev = "useState"; updateHookTypesDev(); - var prevDispatcher = ReactCurrentDispatcher$1.current; - ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV; + var prevDispatcher = ReactCurrentDispatcher.current; + ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnMountInDEV; try { return mountState(initialState); } finally { - ReactCurrentDispatcher$1.current = prevDispatcher; + ReactCurrentDispatcher.current = prevDispatcher; } }, useDebugValue: function(value, formatterFn) { @@ -11822,17 +11274,11 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; updateHookTypesDev(); return mountTransition(config); }, - useMutableSource: function(source, getSnapshot, subscribe) { - currentHookNameInDev = "useMutableSource"; + useEvent: function(event) { + currentHookNameInDev = "useEvent"; updateHookTypesDev(); - return mountMutableSource(source, getSnapshot, subscribe); - }, - useOpaqueIdentifier: function() { - currentHookNameInDev = "useOpaqueIdentifier"; - updateHookTypesDev(); - return mountOpaqueIdentifier(); - }, - unstable_isNewReconciler: enableNewReconciler + return mountEventListener(); + } }; HooksDispatcherOnUpdateInDEV = { readContext: function(context, observedBits) { @@ -11866,25 +11312,25 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; useMemo: function(create, deps) { currentHookNameInDev = "useMemo"; updateHookTypesDev(); - var prevDispatcher = ReactCurrentDispatcher$1.current; - ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV; + var prevDispatcher = ReactCurrentDispatcher.current; + ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnUpdateInDEV; try { return updateMemo(create, deps); } finally { - ReactCurrentDispatcher$1.current = prevDispatcher; + ReactCurrentDispatcher.current = prevDispatcher; } }, useReducer: function(reducer, initialArg, init) { currentHookNameInDev = "useReducer"; updateHookTypesDev(); - var prevDispatcher = ReactCurrentDispatcher$1.current; - ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV; + var prevDispatcher = ReactCurrentDispatcher.current; + ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnUpdateInDEV; try { return updateReducer(reducer, initialArg, init); } finally { - ReactCurrentDispatcher$1.current = prevDispatcher; + ReactCurrentDispatcher.current = prevDispatcher; } }, useRef: function(initialValue) { @@ -11895,13 +11341,13 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; useState: function(initialState) { currentHookNameInDev = "useState"; updateHookTypesDev(); - var prevDispatcher = ReactCurrentDispatcher$1.current; - ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV; + var prevDispatcher = ReactCurrentDispatcher.current; + ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnUpdateInDEV; try { return updateState(initialState); } finally { - ReactCurrentDispatcher$1.current = prevDispatcher; + ReactCurrentDispatcher.current = prevDispatcher; } }, useDebugValue: function(value, formatterFn) { @@ -11924,17 +11370,11 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; updateHookTypesDev(); return updateTransition(config); }, - useMutableSource: function(source, getSnapshot, subscribe) { - currentHookNameInDev = "useMutableSource"; + useEvent: function(event) { + currentHookNameInDev = "useEvent"; updateHookTypesDev(); - return updateMutableSource(source, getSnapshot, subscribe); - }, - useOpaqueIdentifier: function() { - currentHookNameInDev = "useOpaqueIdentifier"; - updateHookTypesDev(); - return updateOpaqueIdentifier(); - }, - unstable_isNewReconciler: enableNewReconciler + return updateEventListener(); + } }; HooksDispatcherOnRerenderInDEV = { readContext: function(context, observedBits) { @@ -11968,25 +11408,25 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; useMemo: function(create, deps) { currentHookNameInDev = "useMemo"; updateHookTypesDev(); - var prevDispatcher = ReactCurrentDispatcher$1.current; - ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnRerenderInDEV; + var prevDispatcher = ReactCurrentDispatcher.current; + ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnRerenderInDEV; try { return updateMemo(create, deps); } finally { - ReactCurrentDispatcher$1.current = prevDispatcher; + ReactCurrentDispatcher.current = prevDispatcher; } }, useReducer: function(reducer, initialArg, init) { currentHookNameInDev = "useReducer"; updateHookTypesDev(); - var prevDispatcher = ReactCurrentDispatcher$1.current; - ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnRerenderInDEV; + var prevDispatcher = ReactCurrentDispatcher.current; + ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnRerenderInDEV; try { return rerenderReducer(reducer, initialArg, init); } finally { - ReactCurrentDispatcher$1.current = prevDispatcher; + ReactCurrentDispatcher.current = prevDispatcher; } }, useRef: function(initialValue) { @@ -11997,13 +11437,13 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; useState: function(initialState) { currentHookNameInDev = "useState"; updateHookTypesDev(); - var prevDispatcher = ReactCurrentDispatcher$1.current; - ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnRerenderInDEV; + var prevDispatcher = ReactCurrentDispatcher.current; + ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnRerenderInDEV; try { return rerenderState(initialState); } finally { - ReactCurrentDispatcher$1.current = prevDispatcher; + ReactCurrentDispatcher.current = prevDispatcher; } }, useDebugValue: function(value, formatterFn) { @@ -12026,17 +11466,11 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; updateHookTypesDev(); return rerenderTransition(config); }, - useMutableSource: function(source, getSnapshot, subscribe) { - currentHookNameInDev = "useMutableSource"; + useEvent: function(event) { + currentHookNameInDev = "useEvent"; updateHookTypesDev(); - return updateMutableSource(source, getSnapshot, subscribe); - }, - useOpaqueIdentifier: function() { - currentHookNameInDev = "useOpaqueIdentifier"; - updateHookTypesDev(); - return rerenderOpaqueIdentifier(); - }, - unstable_isNewReconciler: enableNewReconciler + return updateEventListener(); + } }; InvalidNestedHooksDispatcherOnMountInDEV = { readContext: function(context, observedBits) { @@ -12077,26 +11511,26 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; currentHookNameInDev = "useMemo"; warnInvalidHookAccess(); mountHookTypesDev(); - var prevDispatcher = ReactCurrentDispatcher$1.current; - ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV; + var prevDispatcher = ReactCurrentDispatcher.current; + ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnMountInDEV; try { return mountMemo(create, deps); } finally { - ReactCurrentDispatcher$1.current = prevDispatcher; + ReactCurrentDispatcher.current = prevDispatcher; } }, useReducer: function(reducer, initialArg, init) { currentHookNameInDev = "useReducer"; warnInvalidHookAccess(); mountHookTypesDev(); - var prevDispatcher = ReactCurrentDispatcher$1.current; - ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV; + var prevDispatcher = ReactCurrentDispatcher.current; + ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnMountInDEV; try { return mountReducer(reducer, initialArg, init); } finally { - ReactCurrentDispatcher$1.current = prevDispatcher; + ReactCurrentDispatcher.current = prevDispatcher; } }, useRef: function(initialValue) { @@ -12109,13 +11543,13 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; currentHookNameInDev = "useState"; warnInvalidHookAccess(); mountHookTypesDev(); - var prevDispatcher = ReactCurrentDispatcher$1.current; - ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV; + var prevDispatcher = ReactCurrentDispatcher.current; + ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnMountInDEV; try { return mountState(initialState); } finally { - ReactCurrentDispatcher$1.current = prevDispatcher; + ReactCurrentDispatcher.current = prevDispatcher; } }, useDebugValue: function(value, formatterFn) { @@ -12142,19 +11576,12 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; mountHookTypesDev(); return mountTransition(config); }, - useMutableSource: function(source, getSnapshot, subscribe) { - currentHookNameInDev = "useMutableSource"; + useEvent: function(event) { + currentHookNameInDev = "useEvent"; warnInvalidHookAccess(); mountHookTypesDev(); - return mountMutableSource(source, getSnapshot, subscribe); - }, - useOpaqueIdentifier: function() { - currentHookNameInDev = "useOpaqueIdentifier"; - warnInvalidHookAccess(); - mountHookTypesDev(); - return mountOpaqueIdentifier(); - }, - unstable_isNewReconciler: enableNewReconciler + return mountEventListener(); + } }; InvalidNestedHooksDispatcherOnUpdateInDEV = { readContext: function(context, observedBits) { @@ -12195,26 +11622,26 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; currentHookNameInDev = "useMemo"; warnInvalidHookAccess(); updateHookTypesDev(); - var prevDispatcher = ReactCurrentDispatcher$1.current; - ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV; + var prevDispatcher = ReactCurrentDispatcher.current; + ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnUpdateInDEV; try { return updateMemo(create, deps); } finally { - ReactCurrentDispatcher$1.current = prevDispatcher; + ReactCurrentDispatcher.current = prevDispatcher; } }, useReducer: function(reducer, initialArg, init) { currentHookNameInDev = "useReducer"; warnInvalidHookAccess(); updateHookTypesDev(); - var prevDispatcher = ReactCurrentDispatcher$1.current; - ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV; + var prevDispatcher = ReactCurrentDispatcher.current; + ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnUpdateInDEV; try { return updateReducer(reducer, initialArg, init); } finally { - ReactCurrentDispatcher$1.current = prevDispatcher; + ReactCurrentDispatcher.current = prevDispatcher; } }, useRef: function(initialValue) { @@ -12227,13 +11654,13 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; currentHookNameInDev = "useState"; warnInvalidHookAccess(); updateHookTypesDev(); - var prevDispatcher = ReactCurrentDispatcher$1.current; - ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV; + var prevDispatcher = ReactCurrentDispatcher.current; + ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnUpdateInDEV; try { return updateState(initialState); } finally { - ReactCurrentDispatcher$1.current = prevDispatcher; + ReactCurrentDispatcher.current = prevDispatcher; } }, useDebugValue: function(value, formatterFn) { @@ -12260,19 +11687,12 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; updateHookTypesDev(); return updateTransition(config); }, - useMutableSource: function(source, getSnapshot, subscribe) { - currentHookNameInDev = "useMutableSource"; + useEvent: function(event) { + currentHookNameInDev = "useEvent"; warnInvalidHookAccess(); updateHookTypesDev(); - return updateMutableSource(source, getSnapshot, subscribe); - }, - useOpaqueIdentifier: function() { - currentHookNameInDev = "useOpaqueIdentifier"; - warnInvalidHookAccess(); - updateHookTypesDev(); - return updateOpaqueIdentifier(); - }, - unstable_isNewReconciler: enableNewReconciler + return updateEventListener(); + } }; InvalidNestedHooksDispatcherOnRerenderInDEV = { readContext: function(context, observedBits) { @@ -12313,26 +11733,26 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; currentHookNameInDev = "useMemo"; warnInvalidHookAccess(); updateHookTypesDev(); - var prevDispatcher = ReactCurrentDispatcher$1.current; - ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV; + var prevDispatcher = ReactCurrentDispatcher.current; + ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnUpdateInDEV; try { return updateMemo(create, deps); } finally { - ReactCurrentDispatcher$1.current = prevDispatcher; + ReactCurrentDispatcher.current = prevDispatcher; } }, useReducer: function(reducer, initialArg, init) { currentHookNameInDev = "useReducer"; warnInvalidHookAccess(); updateHookTypesDev(); - var prevDispatcher = ReactCurrentDispatcher$1.current; - ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV; + var prevDispatcher = ReactCurrentDispatcher.current; + ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnUpdateInDEV; try { return rerenderReducer(reducer, initialArg, init); } finally { - ReactCurrentDispatcher$1.current = prevDispatcher; + ReactCurrentDispatcher.current = prevDispatcher; } }, useRef: function(initialValue) { @@ -12345,13 +11765,13 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; currentHookNameInDev = "useState"; warnInvalidHookAccess(); updateHookTypesDev(); - var prevDispatcher = ReactCurrentDispatcher$1.current; - ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV; + var prevDispatcher = ReactCurrentDispatcher.current; + ReactCurrentDispatcher.current = InvalidNestedHooksDispatcherOnUpdateInDEV; try { return rerenderState(initialState); } finally { - ReactCurrentDispatcher$1.current = prevDispatcher; + ReactCurrentDispatcher.current = prevDispatcher; } }, useDebugValue: function(value, formatterFn) { @@ -12378,19 +11798,12 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; updateHookTypesDev(); return rerenderTransition(config); }, - useMutableSource: function(source, getSnapshot, subscribe) { - currentHookNameInDev = "useMutableSource"; + useEvent: function(event) { + currentHookNameInDev = "useEvent"; warnInvalidHookAccess(); updateHookTypesDev(); - return updateMutableSource(source, getSnapshot, subscribe); - }, - useOpaqueIdentifier: function() { - currentHookNameInDev = "useOpaqueIdentifier"; - warnInvalidHookAccess(); - updateHookTypesDev(); - return rerenderOpaqueIdentifier(); - }, - unstable_isNewReconciler: enableNewReconciler + return updateEventListener(); + } }; } @@ -12431,15 +11844,40 @@ function stopProfilerTimerIfRunningAndRecordDelta(fiber, overrideBaseTime) { } } -function transferActualDuration(fiber) { - // Transfer time spent rendering these children so we don't lose it - // after we rerender. This is used as a helper in special cases - // where we should count the work of multiple passes. - var child = fiber.child; +function enterHydrationState(fiber) { + { + return false; + } +} - while (child) { - fiber.actualDuration += child.actualDuration; - child = child.sibling; +function prepareToHydrateHostInstance( + fiber, + rootContainerInstance, + hostContext +) { + { + { + throw Error( + "Expected prepareToHydrateHostInstance() to never be called. This error is likely caused by a bug in React. Please file an issue." + ); + } + } +} + +function prepareToHydrateHostTextInstance(fiber) { + { + { + throw Error( + "Expected prepareToHydrateHostTextInstance() to never be called. This error is likely caused by a bug in React. Please file an issue." + ); + } + } + var shouldUpdate = hydrateTextInstance(); +} + +function popHydrationState(fiber) { + { + return false; } } @@ -12465,7 +11903,12 @@ var didWarnAboutTailOptions; didWarnAboutTailOptions = {}; } -function reconcileChildren(current, workInProgress, nextChildren, renderLanes) { +function reconcileChildren( + current, + workInProgress, + nextChildren, + renderExpirationTime +) { if (current === null) { // If this is a fresh new component that hasn't been rendered yet, we // won't update its child set by applying minimal side-effects. Instead, @@ -12475,7 +11918,7 @@ function reconcileChildren(current, workInProgress, nextChildren, renderLanes) { workInProgress, null, nextChildren, - renderLanes + renderExpirationTime ); } else { // If the current child is the same as the work in progress, it means that @@ -12487,7 +11930,7 @@ function reconcileChildren(current, workInProgress, nextChildren, renderLanes) { workInProgress, current.child, nextChildren, - renderLanes + renderExpirationTime ); } } @@ -12496,7 +11939,7 @@ function forceUnmountCurrentAndReconcile( current, workInProgress, nextChildren, - renderLanes + renderExpirationTime ) { // This function is fork of reconcileChildren. It's used in cases where we // want to reconcile without matching against the existing set. This has the @@ -12510,7 +11953,7 @@ function forceUnmountCurrentAndReconcile( workInProgress, current.child, null, - renderLanes + renderExpirationTime ); // In the second pass, we mount the new children. The trick here is that we // pass null in place of where we usually pass the current child set. This has // the effect of remounting all children regardless of whether their @@ -12520,7 +11963,7 @@ function forceUnmountCurrentAndReconcile( workInProgress, null, nextChildren, - renderLanes + renderExpirationTime ); } @@ -12529,7 +11972,7 @@ function updateForwardRef( workInProgress, Component, nextProps, - renderLanes + renderExpirationTime ) { // TODO: current can be non-null here even if the component // hasn't yet mounted. This happens after the first render suspends. @@ -12555,7 +11998,7 @@ function updateForwardRef( var ref = workInProgress.ref; // The rest is a fork of updateFunctionComponent var nextChildren; - prepareToReadContext(workInProgress, renderLanes); + prepareToReadContext(workInProgress, renderExpirationTime); { ReactCurrentOwner$1.current = workInProgress; @@ -12566,23 +12009,20 @@ function updateForwardRef( render, nextProps, ref, - renderLanes + renderExpirationTime ); if (workInProgress.mode & StrictMode) { - disableLogs(); - - try { + // Only double-render components with Hooks + if (workInProgress.memoizedState !== null) { nextChildren = renderWithHooks( current, workInProgress, render, nextProps, ref, - renderLanes + renderExpirationTime ); - } finally { - reenableLogs(); } } @@ -12590,12 +12030,21 @@ function updateForwardRef( } if (current !== null && !didReceiveUpdate) { - bailoutHooks(current, workInProgress, renderLanes); - return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes); + bailoutHooks(current, workInProgress, renderExpirationTime); + return bailoutOnAlreadyFinishedWork( + current, + workInProgress, + renderExpirationTime + ); } // React DevTools reads this flag. workInProgress.effectTag |= PerformedWork; - reconcileChildren(current, workInProgress, nextChildren, renderLanes); + reconcileChildren( + current, + workInProgress, + nextChildren, + renderExpirationTime + ); return workInProgress.child; } @@ -12604,8 +12053,8 @@ function updateMemoComponent( workInProgress, Component, nextProps, - updateLanes, - renderLanes + updateExpirationTime, + renderExpirationTime ) { if (current === null) { var type = Component.type; @@ -12635,8 +12084,8 @@ function updateMemoComponent( workInProgress, resolvedType, nextProps, - updateLanes, - renderLanes + updateExpirationTime, + renderExpirationTime ); } @@ -12661,7 +12110,7 @@ function updateMemoComponent( nextProps, null, workInProgress.mode, - renderLanes + renderExpirationTime ); child.ref = workInProgress.ref; child.return = workInProgress; @@ -12687,7 +12136,7 @@ function updateMemoComponent( var currentChild = current.child; // This is always exactly one child - if (!includesSomeLane(updateLanes, renderLanes)) { + 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 @@ -12696,7 +12145,11 @@ function updateMemoComponent( compare = compare !== null ? compare : shallowEqual; if (compare(prevProps, nextProps) && current.ref === workInProgress.ref) { - return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes); + return bailoutOnAlreadyFinishedWork( + current, + workInProgress, + renderExpirationTime + ); } } // React DevTools reads this flag. @@ -12713,8 +12166,8 @@ function updateSimpleMemoComponent( workInProgress, Component, nextProps, - updateLanes, - renderLanes + updateExpirationTime, + renderExpirationTime ) { // TODO: current can be non-null here even if the component // hasn't yet mounted. This happens when the inner render suspends. @@ -12729,27 +12182,19 @@ function updateSimpleMemoComponent( // We warn when you define propTypes on lazy() // so let's just skip over it to find memo() outer wrapper. // Inner props for memo are validated later. - var lazyComponent = outerMemoType; - var payload = lazyComponent._payload; - var init = lazyComponent._init; - - try { - outerMemoType = init(payload); - } catch (x) { - outerMemoType = null; - } // Inner propTypes will be validated in the function component path. - - var outerPropTypes = outerMemoType && outerMemoType.propTypes; - - if (outerPropTypes) { - checkPropTypes( - outerPropTypes, - nextProps, // Resolved (SimpleMemoComponent has no defaultProps) - "prop", - getComponentName(outerMemoType) - ); - } + outerMemoType = refineResolvedLazyComponent(outerMemoType); } + + var outerPropTypes = outerMemoType && outerMemoType.propTypes; + + if (outerPropTypes) { + checkPropTypes( + outerPropTypes, + nextProps, // Resolved (SimpleMemoComponent has no defaultProps) + "prop", + getComponentName(outerMemoType) + ); + } // Inner propTypes will be validated in the function component path. } } @@ -12763,10 +12208,10 @@ function updateSimpleMemoComponent( ) { didReceiveUpdate = false; - if (!includesSomeLane(renderLanes, updateLanes)) { - // The pending lanes were cleared at the beginning of beginWork. We're - // about to bail out, but there might be other lanes that weren't - // included in the current render. Usually, the priority level of the + if (updateExpirationTime < renderExpirationTime) { + // The pending update priority was cleared at the beginning of + // beginWork. We're about to bail out, but there might be additional + // updates at a lower priority. Usually, the priority level of the // remaining updates is accumlated during the evaluation of the // component (i.e. when processing the update queue). But since since // we're bailing out early *without* evaluating the component, we need @@ -12777,19 +12222,12 @@ function updateSimpleMemoComponent( // contains hooks. // TODO: Move the reset at in beginWork out of the common path so that // this is no longer necessary. - workInProgress.lanes = current.lanes; + workInProgress.expirationTime = current.expirationTime; return bailoutOnAlreadyFinishedWork( current, workInProgress, - renderLanes + renderExpirationTime ); - } else if ( - (current.effectTag & ForceUpdateForLegacySuspense) !== - NoEffect - ) { - // This is a special case that only exists for legacy mode. - // See https://github.com/facebook/react/pull/19216. - didReceiveUpdate = true; } } } @@ -12799,101 +12237,33 @@ function updateSimpleMemoComponent( workInProgress, Component, nextProps, - renderLanes + renderExpirationTime ); } -function updateOffscreenComponent(current, workInProgress, renderLanes) { - var nextProps = workInProgress.pendingProps; - var nextChildren = nextProps.children; - var prevState = current !== null ? current.memoizedState : null; - - if ( - nextProps.mode === "hidden" || - nextProps.mode === "unstable-defer-without-hiding" - ) { - if ((workInProgress.mode & ConcurrentMode) === NoMode) { - // In legacy sync mode, don't defer the subtree. Render it now. - // TODO: Figure out what we should do in Blocking mode. - var nextState = { - baseLanes: NoLanes - }; - workInProgress.memoizedState = nextState; - pushRenderLanes(workInProgress, renderLanes); - } else if (!includesSomeLane(renderLanes, OffscreenLane)) { - var nextBaseLanes; - - if (prevState !== null) { - var prevBaseLanes = prevState.baseLanes; - nextBaseLanes = mergeLanes(prevBaseLanes, renderLanes); - } else { - nextBaseLanes = renderLanes; - } // Schedule this fiber to re-render at offscreen priority. Then bailout. - - { - markSpawnedWork(OffscreenLane); - } - - workInProgress.lanes = workInProgress.childLanes = laneToLanes( - OffscreenLane - ); - var _nextState = { - baseLanes: nextBaseLanes - }; - workInProgress.memoizedState = _nextState; // We're about to bail out, but we need to push this to the stack anyway - // to avoid a push/pop misalignment. - - pushRenderLanes(workInProgress, nextBaseLanes); - return null; - } else { - // Rendering at offscreen, so we can clear the base lanes. - var _nextState2 = { - baseLanes: NoLanes - }; - workInProgress.memoizedState = _nextState2; // Push the lanes that were skipped when we bailed out. - - var subtreeRenderLanes = - prevState !== null ? prevState.baseLanes : renderLanes; - pushRenderLanes(workInProgress, subtreeRenderLanes); - } - } else { - var _subtreeRenderLanes; - - if (prevState !== null) { - _subtreeRenderLanes = mergeLanes(prevState.baseLanes, renderLanes); // Since we're not hidden anymore, reset the state - - workInProgress.memoizedState = null; - } else { - // We weren't previously hidden, and we still aren't, so there's nothing - // special to do. Need to push to the stack regardless, though, to avoid - // a push/pop misalignment. - _subtreeRenderLanes = renderLanes; - } - - pushRenderLanes(workInProgress, _subtreeRenderLanes); - } - - reconcileChildren(current, workInProgress, nextChildren, renderLanes); - return workInProgress.child; -} // Note: These happen to have identical begin phases, for now. We shouldn't hold -// ourselves to this constraint, though. If the behavior diverges, we should -// fork the function. - -var updateLegacyHiddenComponent = updateOffscreenComponent; - -function updateFragment(current, workInProgress, renderLanes) { +function updateFragment(current, workInProgress, renderExpirationTime) { var nextChildren = workInProgress.pendingProps; - reconcileChildren(current, workInProgress, nextChildren, renderLanes); + reconcileChildren( + current, + workInProgress, + nextChildren, + renderExpirationTime + ); return workInProgress.child; } -function updateMode(current, workInProgress, renderLanes) { +function updateMode(current, workInProgress, renderExpirationTime) { var nextChildren = workInProgress.pendingProps.children; - reconcileChildren(current, workInProgress, nextChildren, renderLanes); + reconcileChildren( + current, + workInProgress, + nextChildren, + renderExpirationTime + ); return workInProgress.child; } -function updateProfiler(current, workInProgress, renderLanes) { +function updateProfiler(current, workInProgress, renderExpirationTime) { { workInProgress.effectTag |= Update; // Reset effect durations for the next eventual effect phase. // These are reset during render to allow the DevTools commit hook a chance to read them, @@ -12905,7 +12275,12 @@ function updateProfiler(current, workInProgress, renderLanes) { var nextProps = workInProgress.pendingProps; var nextChildren = nextProps.children; - reconcileChildren(current, workInProgress, nextChildren, renderLanes); + reconcileChildren( + current, + workInProgress, + nextChildren, + renderExpirationTime + ); return workInProgress.child; } @@ -12926,7 +12301,7 @@ function updateFunctionComponent( workInProgress, Component, nextProps, - renderLanes + renderExpirationTime ) { { if (workInProgress.type !== workInProgress.elementType) { @@ -12953,7 +12328,7 @@ function updateFunctionComponent( } var nextChildren; - prepareToReadContext(workInProgress, renderLanes); + prepareToReadContext(workInProgress, renderExpirationTime); { ReactCurrentOwner$1.current = workInProgress; @@ -12964,23 +12339,20 @@ function updateFunctionComponent( Component, nextProps, context, - renderLanes + renderExpirationTime ); if (workInProgress.mode & StrictMode) { - disableLogs(); - - try { + // Only double-render components with Hooks + if (workInProgress.memoizedState !== null) { nextChildren = renderWithHooks( current, workInProgress, Component, nextProps, context, - renderLanes + renderExpirationTime ); - } finally { - reenableLogs(); } } @@ -12988,12 +12360,21 @@ function updateFunctionComponent( } if (current !== null && !didReceiveUpdate) { - bailoutHooks(current, workInProgress, renderLanes); - return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes); + bailoutHooks(current, workInProgress, renderExpirationTime); + return bailoutOnAlreadyFinishedWork( + current, + workInProgress, + renderExpirationTime + ); } // React DevTools reads this flag. workInProgress.effectTag |= PerformedWork; - reconcileChildren(current, workInProgress, nextChildren, renderLanes); + reconcileChildren( + current, + workInProgress, + nextChildren, + renderExpirationTime + ); return workInProgress.child; } @@ -13002,7 +12383,7 @@ function updateClassComponent( workInProgress, Component, nextProps, - renderLanes + renderExpirationTime ) { { if (workInProgress.type !== workInProgress.elementType) { @@ -13032,7 +12413,7 @@ function updateClassComponent( hasContext = false; } - prepareToReadContext(workInProgress, renderLanes); + prepareToReadContext(workInProgress, renderExpirationTime); var instance = workInProgress.stateNode; var shouldUpdate; @@ -13049,7 +12430,12 @@ function updateClassComponent( } // In the initial pass we might need to construct the instance. constructClassInstance(workInProgress, Component, nextProps); - mountClassInstance(workInProgress, Component, nextProps, renderLanes); + mountClassInstance( + workInProgress, + Component, + nextProps, + renderExpirationTime + ); shouldUpdate = true; } else if (current === null) { // In a resume, we'll already have an instance we can reuse. @@ -13057,7 +12443,7 @@ function updateClassComponent( workInProgress, Component, nextProps, - renderLanes + renderExpirationTime ); } else { shouldUpdate = updateClassInstance( @@ -13065,7 +12451,7 @@ function updateClassComponent( workInProgress, Component, nextProps, - renderLanes + renderExpirationTime ); } @@ -13075,13 +12461,13 @@ function updateClassComponent( Component, shouldUpdate, hasContext, - renderLanes + renderExpirationTime ); { var inst = workInProgress.stateNode; - if (shouldUpdate && inst.props !== nextProps) { + if (inst.props !== nextProps) { if (!didWarnAboutReassigningProps) { error( "It looks like %s is reassigning its own `this.props` while rendering. " + @@ -13103,7 +12489,7 @@ function finishClassComponent( Component, shouldUpdate, hasContext, - renderLanes + renderExpirationTime ) { // Refs should update even if shouldComponentUpdate returns false markRef(current, workInProgress); @@ -13115,7 +12501,11 @@ function finishClassComponent( invalidateContextProvider(workInProgress, Component, false); } - return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes); + return bailoutOnAlreadyFinishedWork( + current, + workInProgress, + renderExpirationTime + ); } var instance = workInProgress.stateNode; // Rerender @@ -13143,13 +12533,7 @@ function finishClassComponent( nextChildren = instance.render(); if (workInProgress.mode & StrictMode) { - disableLogs(); - - try { - instance.render(); - } finally { - reenableLogs(); - } + instance.render(); } setIsRendering(false); @@ -13167,10 +12551,15 @@ function finishClassComponent( current, workInProgress, nextChildren, - renderLanes + renderExpirationTime ); } else { - reconcileChildren(current, workInProgress, nextChildren, renderLanes); + reconcileChildren( + current, + workInProgress, + nextChildren, + renderExpirationTime + ); } // Memoize state using the values we just used to render. // TODO: Restructure so we never read values from the instance. @@ -13200,7 +12589,7 @@ function pushHostRootContext(workInProgress) { pushHostContainer(workInProgress, root.containerInfo); } -function updateHostRoot(current, workInProgress, renderLanes) { +function updateHostRoot(current, workInProgress, renderExpirationTime) { pushHostRootContext(workInProgress); var updateQueue = workInProgress.updateQueue; @@ -13214,24 +12603,32 @@ function updateHostRoot(current, workInProgress, renderLanes) { var prevState = workInProgress.memoizedState; var prevChildren = prevState !== null ? prevState.element : null; cloneUpdateQueue(current, workInProgress); - processUpdateQueue(workInProgress, nextProps, null, renderLanes); + processUpdateQueue(workInProgress, nextProps, null, renderExpirationTime); var nextState = workInProgress.memoizedState; // Caution: React DevTools currently depends on this property // being called "element". var nextChildren = nextState.element; if (nextChildren === prevChildren) { - return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes); + return bailoutOnAlreadyFinishedWork( + current, + workInProgress, + renderExpirationTime + ); } var root = workInProgress.stateNode; if (root.hydrate && enterHydrationState()) { + // If we don't have any current children this might be the first pass. + // We always try to hydrate. If this isn't a hydration pass there won't + // be any children to hydrate which is effectively the same thing as + // not hydrating. var child = mountChildFibers( workInProgress, null, nextChildren, - renderLanes + renderExpirationTime ); workInProgress.child = child; var node = child; @@ -13249,13 +12646,18 @@ function updateHostRoot(current, workInProgress, renderLanes) { } else { // Otherwise reset hydration state in case we aborted and resumed another // root. - reconcileChildren(current, workInProgress, nextChildren, renderLanes); + reconcileChildren( + current, + workInProgress, + nextChildren, + renderExpirationTime + ); } return workInProgress.child; } -function updateHostComponent(current, workInProgress, renderLanes) { +function updateHostComponent(current, workInProgress, renderExpirationTime) { pushHostContext(workInProgress); var type = workInProgress.type; @@ -13269,8 +12671,27 @@ function updateHostComponent(current, workInProgress, renderLanes) { workInProgress.effectTag |= ContentReset; } - markRef(current, workInProgress); - reconcileChildren(current, workInProgress, nextChildren, renderLanes); + markRef(current, workInProgress); // Check the host config to see if the children are offscreen/hidden. + + if ( + workInProgress.mode & ConcurrentMode && + renderExpirationTime !== Never && + shouldDeprioritizeSubtree() + ) { + { + markSpawnedWork(Never); + } // Schedule this fiber to re-render at offscreen priority. Then bailout. + + workInProgress.expirationTime = workInProgress.childExpirationTime = Never; + return null; + } + + reconcileChildren( + current, + workInProgress, + nextChildren, + renderExpirationTime + ); return workInProgress.child; } @@ -13284,8 +12705,8 @@ function mountLazyComponent( _current, workInProgress, elementType, - updateLanes, - renderLanes + updateExpirationTime, + renderExpirationTime ) { if (_current !== null) { // A lazy component only mounts if it suspended inside a non- @@ -13298,14 +12719,15 @@ function mountLazyComponent( workInProgress.effectTag |= Placement; } - var props = workInProgress.pendingProps; - var lazyComponent = elementType; - var payload = lazyComponent._payload; - var init = lazyComponent._init; - var Component = init(payload); // Store the unwrapped component in the type. + 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; @@ -13323,7 +12745,7 @@ function mountLazyComponent( workInProgress, Component, resolvedProps, - renderLanes + renderExpirationTime ); return child; } @@ -13340,7 +12762,7 @@ function mountLazyComponent( workInProgress, Component, resolvedProps, - renderLanes + renderExpirationTime ); return child; } @@ -13357,7 +12779,7 @@ function mountLazyComponent( workInProgress, Component, resolvedProps, - renderLanes + renderExpirationTime ); return child; } @@ -13383,8 +12805,8 @@ function mountLazyComponent( workInProgress, Component, resolveDefaultProps(Component.type, resolvedProps), // The inner type can have defaults too - updateLanes, - renderLanes + updateExpirationTime, + renderExpirationTime ); return child; } @@ -13419,7 +12841,7 @@ function mountIncompleteClassComponent( workInProgress, Component, nextProps, - renderLanes + renderExpirationTime ) { if (_current !== null) { // An incomplete component only mounts if it suspended inside a non- @@ -13446,16 +12868,21 @@ function mountIncompleteClassComponent( hasContext = false; } - prepareToReadContext(workInProgress, renderLanes); + prepareToReadContext(workInProgress, renderExpirationTime); constructClassInstance(workInProgress, Component, nextProps); - mountClassInstance(workInProgress, Component, nextProps, renderLanes); + mountClassInstance( + workInProgress, + Component, + nextProps, + renderExpirationTime + ); return finishClassComponent( null, workInProgress, Component, true, hasContext, - renderLanes + renderExpirationTime ); } @@ -13463,7 +12890,7 @@ function mountIndeterminateComponent( _current, workInProgress, Component, - renderLanes + renderExpirationTime ) { if (_current !== null) { // An indeterminate component only mounts if it suspended inside a non- @@ -13484,7 +12911,7 @@ function mountIndeterminateComponent( context = getMaskedContext(workInProgress, unmaskedContext); } - prepareToReadContext(workInProgress, renderLanes); + prepareToReadContext(workInProgress, renderExpirationTime); var value; { @@ -13510,7 +12937,6 @@ function mountIndeterminateComponent( ReactStrictModeWarnings.recordLegacyContextWarning(workInProgress, null); } - setIsRendering(true); ReactCurrentOwner$1.current = workInProgress; value = renderWithHooks( null, @@ -13518,22 +12944,19 @@ function mountIndeterminateComponent( Component, props, context, - renderLanes + renderExpirationTime ); - setIsRendering(false); } // React DevTools reads this flag. workInProgress.effectTag |= PerformedWork; - { - // Support for module components is deprecated and is removed behind a flag. - // Whether or not it would crash later, we want to show a good message in DEV first. - if ( - typeof value === "object" && - value !== null && - typeof value.render === "function" && - value.$$typeof === undefined - ) { + if ( + typeof value === "object" && + value !== null && + typeof value.render === "function" && + value.$$typeof === undefined + ) { + { var _componentName = getComponentName(Component) || "Unknown"; if (!didWarnAboutModulePatternComponent[_componentName]) { @@ -13550,34 +12973,6 @@ function mountIndeterminateComponent( didWarnAboutModulePatternComponent[_componentName] = true; } - } - } - - if ( - // Run these checks in production only if the flag is off. - // Eventually we'll delete this branch altogether. - typeof value === "object" && - value !== null && - typeof value.render === "function" && - value.$$typeof === undefined - ) { - { - var _componentName2 = getComponentName(Component) || "Unknown"; - - if (!didWarnAboutModulePatternComponent[_componentName2]) { - error( - "The <%s /> component appears to be a function component that returns a class instance. " + - "Change %s to a class that extends React.Component instead. " + - "If you can't use a class try assigning the prototype on the function as a workaround. " + - "`%s.prototype = React.Component.prototype`. Don't use an arrow function since it " + - "cannot be called with `new` by React.", - _componentName2, - _componentName2, - _componentName2 - ); - - didWarnAboutModulePatternComponent[_componentName2] = true; - } } // Proceed under the assumption that this is a class instance workInProgress.tag = ClassComponent; // Throw out any hooks that were used. @@ -13611,14 +13006,14 @@ function mountIndeterminateComponent( } adoptClassInstance(workInProgress, value); - mountClassInstance(workInProgress, Component, props, renderLanes); + mountClassInstance(workInProgress, Component, props, renderExpirationTime); return finishClassComponent( null, workInProgress, Component, true, hasContext, - renderLanes + renderExpirationTime ); } else { // Proceed under the assumption that this is a function component @@ -13626,24 +13021,21 @@ function mountIndeterminateComponent( { if (workInProgress.mode & StrictMode) { - disableLogs(); - - try { + // Only double-render components with Hooks + if (workInProgress.memoizedState !== null) { value = renderWithHooks( null, workInProgress, Component, props, context, - renderLanes + renderExpirationTime ); - } finally { - reenableLogs(); } } } - reconcileChildren(null, workInProgress, value, renderLanes); + reconcileChildren(null, workInProgress, value, renderExpirationTime); { validateFunctionComponentInDev(workInProgress, Component); @@ -13692,15 +13084,15 @@ function validateFunctionComponentInDev(workInProgress, Component) { } if (typeof Component.getDerivedStateFromProps === "function") { - var _componentName3 = getComponentName(Component) || "Unknown"; + var _componentName2 = getComponentName(Component) || "Unknown"; - if (!didWarnAboutGetDerivedStateOnFunctionComponent[_componentName3]) { + if (!didWarnAboutGetDerivedStateOnFunctionComponent[_componentName2]) { error( "%s: Function components do not support getDerivedStateFromProps.", - _componentName3 + _componentName2 ); - didWarnAboutGetDerivedStateOnFunctionComponent[_componentName3] = true; + didWarnAboutGetDerivedStateOnFunctionComponent[_componentName2] = true; } } @@ -13708,15 +13100,15 @@ function validateFunctionComponentInDev(workInProgress, Component) { typeof Component.contextType === "object" && Component.contextType !== null ) { - var _componentName4 = getComponentName(Component) || "Unknown"; + var _componentName3 = getComponentName(Component) || "Unknown"; - if (!didWarnAboutContextTypeOnFunctionComponent[_componentName4]) { + if (!didWarnAboutContextTypeOnFunctionComponent[_componentName3]) { error( "%s: Function components do not support contextType.", - _componentName4 + _componentName3 ); - didWarnAboutContextTypeOnFunctionComponent[_componentName4] = true; + didWarnAboutContextTypeOnFunctionComponent[_componentName3] = true; } } } @@ -13724,51 +13116,24 @@ function validateFunctionComponentInDev(workInProgress, Component) { var SUSPENDED_MARKER = { dehydrated: null, - retryLane: NoLane + retryTime: NoWork }; -function mountSuspenseOffscreenState(renderLanes) { - return { - baseLanes: renderLanes - }; +function shouldRemainOnFallback(suspenseContext, current, workInProgress) { + // If the context is telling us that we should show a fallback, and we're not + // already showing content, then we should show the fallback instead. + return ( + hasSuspenseContext(suspenseContext, ForceSuspenseFallback) && + (current === null || current.memoizedState !== null) + ); } -function updateSuspenseOffscreenState(prevOffscreenState, renderLanes) { - return { - baseLanes: mergeLanes(prevOffscreenState.baseLanes, renderLanes) - }; -} - -function shouldRemainOnFallback( - suspenseContext, +function updateSuspenseComponent( current, workInProgress, - renderLanes + renderExpirationTime ) { - // If we're already showing a fallback, there are cases where we need to - // remain on that fallback regardless of whether the content has resolved. - // For example, SuspenseList coordinates when nested content appears. - if (current !== null) { - var suspenseState = current.memoizedState; - - if (suspenseState === null) { - // Currently showing content. Don't hide it, even if ForceSuspenseFallack - // is true. More precise name might be "ForceRemainSuspenseFallback". - // Note: This is a factoring smell. Can't remain on a fallback if there's - // no fallback to remain on. - return false; - } - } // Not currently showing content. Consult the Suspense context. - - return hasSuspenseContext(suspenseContext, ForceSuspenseFallback); -} - -function getRemainingWorkInPrimaryTree(current, renderLanes) { - // TODO: Should not remove render lanes that were pinged during this render - return removeLanes(current.childLanes, renderLanes); -} - -function updateSuspenseComponent(current, workInProgress, renderLanes) { + var mode = workInProgress.mode; var nextProps = workInProgress.pendingProps; // This is used by DevTools to force a boundary to suspend. { @@ -13778,13 +13143,13 @@ function updateSuspenseComponent(current, workInProgress, renderLanes) { } var suspenseContext = suspenseStackCursor.current; - var showFallback = false; + var nextDidTimeout = false; var didSuspend = (workInProgress.effectTag & DidCapture) !== NoEffect; if (didSuspend || shouldRemainOnFallback(suspenseContext, current)) { // Something in this boundary's subtree already suspended. Switch to // rendering the fallback children. - showFallback = true; + nextDidTimeout = true; workInProgress.effectTag &= ~DidCapture; } else { // Attempting the main content @@ -13807,380 +13172,290 @@ function updateSuspenseComponent(current, workInProgress, renderLanes) { } suspenseContext = setDefaultShallowSuspenseContext(suspenseContext); - pushSuspenseContext(workInProgress, suspenseContext); // OK, the next part is confusing. We're about to reconcile the Suspense - // boundary's children. This involves some custom reconcilation logic. Two - // main reasons this is so complicated. + pushSuspenseContext(workInProgress, suspenseContext); // 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. // - // First, Legacy Mode has different semantics for backwards compatibility. The - // primary tree will commit in an inconsistent state, so when we do the - // second pass to render the fallback, we do some exceedingly, uh, clever - // hacks to make that not totally break. Like transferring effects and - // deletions from hidden tree. In Concurrent Mode, it's much simpler, - // because we bailout on the primary tree completely and leave it in its old - // state, no effects. Same as what we do for Offscreen (except that - // Offscreen doesn't have the first render pass). + // 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. // - // Second is hydration. During hydration, the Suspense fiber has a slightly - // different layout, where the child points to a dehydrated fragment, which - // contains the DOM rendered by the server. + // 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. // - // Third, even if you set all that aside, Suspense is like error boundaries in - // that we first we try to render one tree, and if that fails, we render again - // and switch to a different tree. Like a try/catch block. So we have to track - // which branch we're currently rendering. Ideally we would model this using - // a stack. + // 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. if (current === null) { - // Initial mount // If we're currently hydrating, try to hydrate this boundary. // But only if this has a fallback. - if (nextProps.fallback !== undefined); + if (nextProps.fallback !== undefined); // This is the initial mount. This branch is pretty simple because there's + // no previous state that needs to be preserved. - if (showFallback) { - var nextPrimaryChildren = nextProps.children; + if (nextDidTimeout) { + // Mount separate fragments for primary and fallback children. var nextFallbackChildren = nextProps.fallback; - var fallbackFragment = mountSuspenseFallbackChildren( - workInProgress, - nextPrimaryChildren, + var primaryChildFragment = createFiberFromFragment( + null, + mode, + NoWork, + null + ); + primaryChildFragment.return = workInProgress; + + if ((workInProgress.mode & BlockingMode) === NoMode) { + // Outside of blocking mode, we commit the effects from the + // partially completed, timed-out tree, too. + var progressedState = workInProgress.memoizedState; + var progressedPrimaryChild = + progressedState !== null + ? workInProgress.child.child + : workInProgress.child; + primaryChildFragment.child = progressedPrimaryChild; + var progressedChild = progressedPrimaryChild; + + while (progressedChild !== null) { + progressedChild.return = primaryChildFragment; + progressedChild = progressedChild.sibling; + } + } + + var fallbackChildFragment = createFiberFromFragment( nextFallbackChildren, - renderLanes - ); - var primaryChildFragment = workInProgress.child; - primaryChildFragment.memoizedState = mountSuspenseOffscreenState( - renderLanes + mode, + renderExpirationTime, + null ); + fallbackChildFragment.return = workInProgress; + primaryChildFragment.sibling = fallbackChildFragment; // Skip the primary children, and continue working on the + // fallback children. + workInProgress.memoizedState = SUSPENDED_MARKER; - return fallbackFragment; + workInProgress.child = primaryChildFragment; + return fallbackChildFragment; } else { - var _nextPrimaryChildren = nextProps.children; - return mountSuspensePrimaryChildren( + // Mount the primary children without an intermediate fragment fiber. + var nextPrimaryChildren = nextProps.children; + workInProgress.memoizedState = null; + return (workInProgress.child = mountChildFibers( workInProgress, - _nextPrimaryChildren, - renderLanes - ); + null, + nextPrimaryChildren, + renderExpirationTime + )); } } else { - // This is an update. - // If the current fiber has a SuspenseState, that means it's already showing - // a fallback. + // 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.memoizedState; if (prevState !== null) { - if (showFallback) { + // wrapped in a fragment fiber. + + var currentPrimaryChildFragment = current.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 _nextFallbackChildren2 = nextProps.fallback; - var _nextPrimaryChildren3 = nextProps.children; - var _fallbackChildFragment = updateSuspenseFallbackChildren( - current, - workInProgress, - _nextPrimaryChildren3, - _nextFallbackChildren2, - renderLanes + var _primaryChildFragment2 = createWorkInProgress( + currentPrimaryChildFragment, + currentPrimaryChildFragment.pendingProps ); - var _primaryChildFragment2 = workInProgress.child; - var prevOffscreenState = current.child.memoizedState; - _primaryChildFragment2.memoizedState = - prevOffscreenState === null - ? mountSuspenseOffscreenState(renderLanes) - : updateSuspenseOffscreenState(prevOffscreenState, renderLanes); - _primaryChildFragment2.childLanes = getRemainingWorkInPrimaryTree( - current, - renderLanes - ); - workInProgress.memoizedState = SUSPENDED_MARKER; - return _fallbackChildFragment; - } else { - var _nextPrimaryChildren4 = nextProps.children; + _primaryChildFragment2.return = workInProgress; - var _primaryChildFragment3 = updateSuspensePrimaryChildren( - current, - workInProgress, - _nextPrimaryChildren4, - renderLanes + if ((workInProgress.mode & BlockingMode) === NoMode) { + // Outside of blocking mode, we commit the effects from the + // partially completed, timed-out tree, too. + var _progressedState = workInProgress.memoizedState; + + var _progressedPrimaryChild = + _progressedState !== null + ? workInProgress.child.child + : workInProgress.child; + + if (_progressedPrimaryChild !== currentPrimaryChildFragment.child) { + _primaryChildFragment2.child = _progressedPrimaryChild; + var _progressedChild2 = _progressedPrimaryChild; + + while (_progressedChild2 !== null) { + _progressedChild2.return = _primaryChildFragment2; + _progressedChild2 = _progressedChild2.sibling; + } + } + } // Because primaryChildFragment is a new fiber that we're inserting as the + // parent of a new tree, we need to set its treeBaseDuration. + + if (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; + } // Clone the fallback child fragment, too. These we'll continue + // working on. + + var _fallbackChildFragment2 = createWorkInProgress( + currentFallbackChildFragment, + _nextFallbackChildren2 ); - workInProgress.memoizedState = null; - return _primaryChildFragment3; - } - } else { - // The current tree is not already showing a fallback. - if (showFallback) { - // Timed out. - var _nextFallbackChildren3 = nextProps.fallback; - var _nextPrimaryChildren5 = nextProps.children; - - var _fallbackChildFragment2 = updateSuspenseFallbackChildren( - current, - workInProgress, - _nextPrimaryChildren5, - _nextFallbackChildren3, - renderLanes - ); - - var _primaryChildFragment4 = workInProgress.child; - var _prevOffscreenState = current.child.memoizedState; - _primaryChildFragment4.memoizedState = - _prevOffscreenState === null - ? mountSuspenseOffscreenState(renderLanes) - : updateSuspenseOffscreenState(_prevOffscreenState, renderLanes); - _primaryChildFragment4.childLanes = getRemainingWorkInPrimaryTree( - current, - renderLanes - ); // Skip the primary children, and continue working on the + _fallbackChildFragment2.return = workInProgress; + _primaryChildFragment2.sibling = _fallbackChildFragment2; + _primaryChildFragment2.childExpirationTime = NoWork; // Skip the primary children, and continue working on the // fallback children. workInProgress.memoizedState = SUSPENDED_MARKER; + workInProgress.child = _primaryChildFragment2; return _fallbackChildFragment2; + } 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. + + workInProgress.memoizedState = null; + return (workInProgress.child = primaryChild); + } + } else { + // The current tree has not already timed out. That means the primary + // children are not wrapped in a fragment fiber. + var _currentPrimaryChild = current.child; + + if (nextDidTimeout) { + // Timed out. Wrap the children in a fragment fiber to keep them + // separate from the fallback children. + var _nextFallbackChildren3 = nextProps.fallback; + + var _primaryChildFragment3 = createFiberFromFragment( + // It shouldn't matter what the pending props are because we aren't + // going to render this fragment. + null, + mode, + NoWork, + null + ); + + _primaryChildFragment3.return = workInProgress; + _primaryChildFragment3.child = _currentPrimaryChild; + + if (_currentPrimaryChild !== null) { + _currentPrimaryChild.return = _primaryChildFragment3; + } // Even though we're creating a new fiber, there are no new children, + // because we're reusing an already mounted tree. So we don't need to + // schedule a placement. + // primaryChildFragment.effectTag |= Placement; + + if ((workInProgress.mode & BlockingMode) === NoMode) { + // Outside of blocking mode, we commit the effects from the + // partially completed, timed-out tree, too. + var _progressedState2 = workInProgress.memoizedState; + + var _progressedPrimaryChild2 = + _progressedState2 !== null + ? workInProgress.child.child + : workInProgress.child; + + _primaryChildFragment3.child = _progressedPrimaryChild2; + var _progressedChild3 = _progressedPrimaryChild2; + + while (_progressedChild3 !== null) { + _progressedChild3.return = _primaryChildFragment3; + _progressedChild3 = _progressedChild3.sibling; + } + } // Because primaryChildFragment is a new fiber that we're inserting as the + // parent of a new tree, we need to set its treeBaseDuration. + + if (workInProgress.mode & ProfileMode) { + // treeBaseDuration is the sum of all the child tree base durations. + var _treeBaseDuration2 = 0; + var _hiddenChild2 = _primaryChildFragment3.child; + + while (_hiddenChild2 !== null) { + _treeBaseDuration2 += _hiddenChild2.treeBaseDuration; + _hiddenChild2 = _hiddenChild2.sibling; + } + + _primaryChildFragment3.treeBaseDuration = _treeBaseDuration2; + } // Create a fragment from the fallback children, too. + + var _fallbackChildFragment3 = createFiberFromFragment( + _nextFallbackChildren3, + mode, + renderExpirationTime, + null + ); + + _fallbackChildFragment3.return = workInProgress; + _primaryChildFragment3.sibling = _fallbackChildFragment3; + _fallbackChildFragment3.effectTag |= Placement; + _primaryChildFragment3.childExpirationTime = NoWork; // Skip the primary children, and continue working on the + // fallback children. + + workInProgress.memoizedState = SUSPENDED_MARKER; + workInProgress.child = _primaryChildFragment3; + return _fallbackChildFragment3; } else { // Still haven't timed out. Continue rendering the children, like we // normally do. - var _nextPrimaryChildren6 = nextProps.children; - - var _primaryChildFragment5 = updateSuspensePrimaryChildren( - current, - workInProgress, - _nextPrimaryChildren6, - renderLanes - ); - workInProgress.memoizedState = null; - return _primaryChildFragment5; + var _nextPrimaryChildren2 = nextProps.children; + return (workInProgress.child = reconcileChildFibers( + workInProgress, + _currentPrimaryChild, + _nextPrimaryChildren2, + renderExpirationTime + )); } } } } -function mountSuspensePrimaryChildren( - workInProgress, - primaryChildren, - renderLanes -) { - var mode = workInProgress.mode; - var primaryChildProps = { - mode: "visible", - children: primaryChildren - }; - var primaryChildFragment = createFiberFromOffscreen( - primaryChildProps, - mode, - renderLanes, - null - ); - primaryChildFragment.return = workInProgress; - workInProgress.child = primaryChildFragment; - return primaryChildFragment; -} - -function mountSuspenseFallbackChildren( - workInProgress, - primaryChildren, - fallbackChildren, - renderLanes -) { - var mode = workInProgress.mode; - var progressedPrimaryFragment = workInProgress.child; - var primaryChildProps = { - mode: "hidden", - children: primaryChildren - }; - var primaryChildFragment; - var fallbackChildFragment; - - if ((mode & BlockingMode) === NoMode && progressedPrimaryFragment !== null) { - // In legacy mode, we commit the primary tree as if it successfully - // completed, even though it's in an inconsistent state. - primaryChildFragment = progressedPrimaryFragment; - primaryChildFragment.childLanes = NoLanes; - primaryChildFragment.pendingProps = primaryChildProps; - - if (workInProgress.mode & ProfileMode) { - // Reset the durations from the first pass so they aren't included in the - // final amounts. This seems counterintuitive, since we're intentionally - // not measuring part of the render phase, but this makes it match what we - // do in Concurrent Mode. - primaryChildFragment.actualDuration = 0; - primaryChildFragment.actualStartTime = -1; - primaryChildFragment.selfBaseDuration = 0; - primaryChildFragment.treeBaseDuration = 0; - } - - fallbackChildFragment = createFiberFromFragment( - fallbackChildren, - mode, - renderLanes, - null - ); - } else { - primaryChildFragment = createFiberFromOffscreen( - primaryChildProps, - mode, - NoLanes, - null - ); - fallbackChildFragment = createFiberFromFragment( - fallbackChildren, - mode, - renderLanes, - null - ); +function scheduleWorkOnFiber(fiber, renderExpirationTime) { + if (fiber.expirationTime < renderExpirationTime) { + fiber.expirationTime = renderExpirationTime; } - primaryChildFragment.return = workInProgress; - fallbackChildFragment.return = workInProgress; - primaryChildFragment.sibling = fallbackChildFragment; - workInProgress.child = primaryChildFragment; - return fallbackChildFragment; -} - -function createWorkInProgressOffscreenFiber(current, offscreenProps) { - // The props argument to `createWorkInProgress` is `any` typed, so we use this - // wrapper function to constrain it. - return createWorkInProgress(current, offscreenProps); -} - -function updateSuspensePrimaryChildren( - current, - workInProgress, - primaryChildren, - renderLanes -) { - var currentPrimaryChildFragment = current.child; - var currentFallbackChildFragment = currentPrimaryChildFragment.sibling; - var primaryChildFragment = createWorkInProgressOffscreenFiber( - currentPrimaryChildFragment, - { - mode: "visible", - children: primaryChildren - } - ); - - if ((workInProgress.mode & BlockingMode) === NoMode) { - primaryChildFragment.lanes = renderLanes; - } - - primaryChildFragment.return = workInProgress; - primaryChildFragment.sibling = null; - - if (currentFallbackChildFragment !== null) { - // Delete the fallback child fragment - currentFallbackChildFragment.nextEffect = null; - currentFallbackChildFragment.effectTag = Deletion; - workInProgress.firstEffect = workInProgress.lastEffect = currentFallbackChildFragment; - } - - workInProgress.child = primaryChildFragment; - return primaryChildFragment; -} - -function updateSuspenseFallbackChildren( - current, - workInProgress, - primaryChildren, - fallbackChildren, - renderLanes -) { - var mode = workInProgress.mode; - var currentPrimaryChildFragment = current.child; - var currentFallbackChildFragment = currentPrimaryChildFragment.sibling; - var primaryChildProps = { - mode: "hidden", - children: primaryChildren - }; - var primaryChildFragment; - - if ( - // In legacy mode, we commit the primary tree as if it successfully - // completed, even though it's in an inconsistent state. - (mode & BlockingMode) === NoMode && // Make sure we're on the second pass, i.e. the primary child fragment was - // already cloned. In legacy mode, the only case where this isn't true is - // when DevTools forces us to display a fallback; we skip the first render - // pass entirely and go straight to rendering the fallback. (In Concurrent - // Mode, SuspenseList can also trigger this scenario, but this is a legacy- - // only codepath.) - workInProgress.child !== currentPrimaryChildFragment - ) { - var progressedPrimaryFragment = workInProgress.child; - primaryChildFragment = progressedPrimaryFragment; - primaryChildFragment.childLanes = NoLanes; - primaryChildFragment.pendingProps = primaryChildProps; - - if (workInProgress.mode & ProfileMode) { - // Reset the durations from the first pass so they aren't included in the - // final amounts. This seems counterintuitive, since we're intentionally - // not measuring part of the render phase, but this makes it match what we - // do in Concurrent Mode. - primaryChildFragment.actualDuration = 0; - primaryChildFragment.actualStartTime = -1; - primaryChildFragment.selfBaseDuration = - currentPrimaryChildFragment.selfBaseDuration; - primaryChildFragment.treeBaseDuration = - currentPrimaryChildFragment.treeBaseDuration; - } // The fallback fiber was added as a deletion effect during the first pass. - // However, since we're going to remain on the fallback, we no longer want - // to delete it. So we need to remove it from the list. Deletions are stored - // on the same list as effects. We want to keep the effects from the primary - // tree. So we copy the primary child fragment's effect list, which does not - // include the fallback deletion effect. - - var progressedLastEffect = primaryChildFragment.lastEffect; - - if (progressedLastEffect !== null) { - workInProgress.firstEffect = primaryChildFragment.firstEffect; - workInProgress.lastEffect = progressedLastEffect; - progressedLastEffect.nextEffect = null; - } else { - // TODO: Reset this somewhere else? Lol legacy mode is so weird. - workInProgress.firstEffect = workInProgress.lastEffect = null; - } - } else { - primaryChildFragment = createWorkInProgressOffscreenFiber( - currentPrimaryChildFragment, - primaryChildProps - ); - } - - var fallbackChildFragment; - - if (currentFallbackChildFragment !== null) { - fallbackChildFragment = createWorkInProgress( - currentFallbackChildFragment, - fallbackChildren - ); - } else { - fallbackChildFragment = createFiberFromFragment( - fallbackChildren, - mode, - renderLanes, - null - ); // Needs a placement effect because the parent (the Suspense boundary) already - // mounted but this is a new fiber. - - fallbackChildFragment.effectTag |= Placement; - } - - fallbackChildFragment.return = workInProgress; - primaryChildFragment.return = workInProgress; - primaryChildFragment.sibling = fallbackChildFragment; - workInProgress.child = primaryChildFragment; - return fallbackChildFragment; -} - -function scheduleWorkOnFiber(fiber, renderLanes) { - fiber.lanes = mergeLanes(fiber.lanes, renderLanes); var alternate = fiber.alternate; - if (alternate !== null) { - alternate.lanes = mergeLanes(alternate.lanes, renderLanes); + if (alternate !== null && alternate.expirationTime < renderExpirationTime) { + alternate.expirationTime = renderExpirationTime; } - scheduleWorkOnParentPath(fiber.return, renderLanes); + scheduleWorkOnParentPath(fiber.return, renderExpirationTime); } function propagateSuspenseContextChange( workInProgress, firstChild, - renderLanes + renderExpirationTime ) { // Mark any Suspense boundaries with fallbacks as having work to do. // If they were previously forced into fallbacks, they may now be able @@ -14192,7 +13467,7 @@ function propagateSuspenseContextChange( var state = node.memoizedState; if (state !== null) { - scheduleWorkOnFiber(node, renderLanes); + scheduleWorkOnFiber(node, renderExpirationTime); } } else if (node.tag === SuspenseListComponent) { // If the tail is hidden there might not be an Suspense boundaries @@ -14200,7 +13475,7 @@ function propagateSuspenseContextChange( // list itself. // We don't have to traverse to the children of the list since // the list will propagate the change when it rerenders. - scheduleWorkOnFiber(node, renderLanes); + scheduleWorkOnFiber(node, renderExpirationTime); } else if (node.child !== null) { node.child.return = node; node = node.child; @@ -14442,7 +13717,11 @@ function initSuspenseListRenderState( // in fallback state. Then we render each row in the tail one-by-one. // That happens in the completeWork phase without going back to beginWork. -function updateSuspenseListComponent(current, workInProgress, renderLanes) { +function updateSuspenseListComponent( + current, + workInProgress, + renderExpirationTime +) { var nextProps = workInProgress.pendingProps; var revealOrder = nextProps.revealOrder; var tailMode = nextProps.tail; @@ -14450,7 +13729,7 @@ function updateSuspenseListComponent(current, workInProgress, renderLanes) { validateRevealOrder(revealOrder); validateTailOptions(tailMode, revealOrder); validateSuspenseListChildren(newChildren, revealOrder); - reconcileChildren(current, workInProgress, newChildren, renderLanes); + reconcileChildren(current, workInProgress, newChildren, renderExpirationTime); var suspenseContext = suspenseStackCursor.current; var shouldForceFallback = hasSuspenseContext( suspenseContext, @@ -14474,7 +13753,7 @@ function updateSuspenseListComponent(current, workInProgress, renderLanes) { propagateSuspenseContextChange( workInProgress, workInProgress.child, - renderLanes + renderExpirationTime ); } @@ -14484,7 +13763,7 @@ function updateSuspenseListComponent(current, workInProgress, renderLanes) { pushSuspenseContext(workInProgress, suspenseContext); if ((workInProgress.mode & BlockingMode) === NoMode) { - // In legacy mode, SuspenseList doesn't work so we just + // Outside of blocking mode, SuspenseList doesn't work so we just // use make it a noop by treating it as the default revealOrder. workInProgress.memoizedState = null; } else { @@ -14574,7 +13853,7 @@ function updateSuspenseListComponent(current, workInProgress, renderLanes) { return workInProgress.child; } -function updatePortalComponent(current, workInProgress, renderLanes) { +function updatePortalComponent(current, workInProgress, renderExpirationTime) { pushHostContainer(workInProgress, workInProgress.stateNode.containerInfo); var nextChildren = workInProgress.pendingProps; @@ -14588,18 +13867,21 @@ function updatePortalComponent(current, workInProgress, renderLanes) { workInProgress, null, nextChildren, - renderLanes + renderExpirationTime ); } else { - reconcileChildren(current, workInProgress, nextChildren, renderLanes); + reconcileChildren( + current, + workInProgress, + nextChildren, + renderExpirationTime + ); } return workInProgress.child; } -var hasWarnedAboutUsingNoValuePropOnContextProvider = false; - -function updateContextProvider(current, workInProgress, renderLanes) { +function updateContextProvider(current, workInProgress, renderExpirationTime) { var providerType = workInProgress.type; var context = providerType._context; var newProps = workInProgress.pendingProps; @@ -14607,16 +13889,6 @@ function updateContextProvider(current, workInProgress, renderLanes) { var newValue = newProps.value; { - if (!("value" in newProps)) { - if (!hasWarnedAboutUsingNoValuePropOnContextProvider) { - hasWarnedAboutUsingNoValuePropOnContextProvider = true; - - error( - "The `value` prop is required for the ``. Did you misspell it or forget to pass it?" - ); - } - } - var providerPropTypes = workInProgress.type.propTypes; if (providerPropTypes) { @@ -14636,24 +13908,29 @@ function updateContextProvider(current, workInProgress, renderLanes) { return bailoutOnAlreadyFinishedWork( current, workInProgress, - renderLanes + renderExpirationTime ); } } else { // The context value changed. Search for matching consumers and schedule // them to update. - propagateContextChange(workInProgress, context, changedBits, renderLanes); + propagateContextChange( + workInProgress, + context, + changedBits, + renderExpirationTime + ); } } var newChildren = newProps.children; - reconcileChildren(current, workInProgress, newChildren, renderLanes); + reconcileChildren(current, workInProgress, newChildren, renderExpirationTime); return workInProgress.child; } var hasWarnedAboutUsingContextAsConsumer = false; -function updateContextConsumer(current, workInProgress, renderLanes) { +function updateContextConsumer(current, workInProgress, renderExpirationTime) { var context = workInProgress.type; // The logic below for Context differs depending on PROD or DEV mode. In // DEV mode, we create a separate object for Context.Consumer that acts // like a proxy to Context. This proxy object adds unnecessary code in PROD @@ -14696,7 +13973,7 @@ function updateContextConsumer(current, workInProgress, renderLanes) { } } - prepareToReadContext(workInProgress, renderLanes); + prepareToReadContext(workInProgress, renderExpirationTime); var newValue = readContext(context, newProps.unstable_observedBits); var newChildren; @@ -14708,7 +13985,7 @@ function updateContextConsumer(current, workInProgress, renderLanes) { } // React DevTools reads this flag. workInProgress.effectTag |= PerformedWork; - reconcileChildren(current, workInProgress, newChildren, renderLanes); + reconcileChildren(current, workInProgress, newChildren, renderExpirationTime); return workInProgress.child; } @@ -14716,7 +13993,13 @@ function markWorkInProgressReceivedUpdate() { didReceiveUpdate = true; } -function bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes) { +function bailoutOnAlreadyFinishedWork( + current, + workInProgress, + renderExpirationTime +) { + cancelWorkTimer(workInProgress); + if (current !== null) { // Reuse previous dependencies workInProgress.dependencies = current.dependencies; @@ -14727,9 +14010,15 @@ function bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes) { stopProfilerTimerIfRunning(); } - markSkippedUpdateLanes(workInProgress.lanes); // Check if the children have any pending work. + var updateExpirationTime = workInProgress.expirationTime; - if (!includesSomeLane(renderLanes, workInProgress.childLanes)) { + if (updateExpirationTime !== NoWork) { + markUnprocessedUpdateTime(updateExpirationTime); + } // Check if the children have any pending work. + + var childExpirationTime = workInProgress.childExpirationTime; + + 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. @@ -14797,8 +14086,8 @@ function remountFiber(current, oldWorkInProgress, newWorkInProgress) { } } -function beginWork(current, workInProgress, renderLanes) { - var updateLanes = workInProgress.lanes; +function beginWork(current, workInProgress, renderExpirationTime) { + var updateExpirationTime = workInProgress.expirationTime; { if (workInProgress._debugNeedsRemount && current !== null) { @@ -14812,7 +14101,7 @@ function beginWork(current, workInProgress, renderLanes) { workInProgress.pendingProps, workInProgress._debugOwner || null, workInProgress.mode, - workInProgress.lanes + workInProgress.expirationTime ) ); } @@ -14830,7 +14119,7 @@ function beginWork(current, workInProgress, renderLanes) { // If props or context changed, mark the fiber as having performed work. // This may be unset if the props are determined to be equal later (memo). didReceiveUpdate = true; - } else if (!includesSomeLane(renderLanes, updateLanes)) { + } else if (updateExpirationTime < renderExpirationTime) { didReceiveUpdate = false; // 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 // in this optimized path, mostly pushing stuff onto the stack. @@ -14842,6 +14131,20 @@ function beginWork(current, workInProgress, renderLanes) { case HostComponent: pushHostContext(workInProgress); + + if ( + workInProgress.mode & ConcurrentMode && + renderExpirationTime !== Never && + shouldDeprioritizeSubtree(workInProgress.type) + ) { + { + markSpawnedWork(Never); + } // Schedule this fiber to re-render at offscreen priority. Then bailout. + + workInProgress.expirationTime = workInProgress.childExpirationTime = Never; + return null; + } + break; case ClassComponent: { @@ -14870,10 +14173,8 @@ function beginWork(current, workInProgress, renderLanes) { case Profiler: { // Profiler should only call onRender when one of its descendants actually rendered. - var hasChildWork = includesSomeLane( - renderLanes, - workInProgress.childLanes - ); + var hasChildWork = + workInProgress.childExpirationTime >= renderExpirationTime; if (hasChildWork) { workInProgress.effectTag |= Update; @@ -14896,19 +14197,21 @@ function beginWork(current, workInProgress, renderLanes) { // child fragment. var primaryChildFragment = workInProgress.child; - var primaryChildLanes = primaryChildFragment.childLanes; + var primaryChildExpirationTime = + primaryChildFragment.childExpirationTime; - if (includesSomeLane(renderLanes, primaryChildLanes)) { + 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, workInProgress, - renderLanes + renderExpirationTime ); } else { - // The primary child fragment does not have pending work marked - // on it pushSuspenseContext( workInProgress, setDefaultShallowSuspenseContext(suspenseStackCursor.current) @@ -14918,7 +14221,7 @@ function beginWork(current, workInProgress, renderLanes) { var child = bailoutOnAlreadyFinishedWork( current, workInProgress, - renderLanes + renderExpirationTime ); if (child !== null) { @@ -14942,10 +14245,8 @@ function beginWork(current, workInProgress, renderLanes) { case SuspenseListComponent: { var didSuspendBefore = (current.effectTag & DidCapture) !== NoEffect; - var _hasChildWork = includesSomeLane( - renderLanes, - workInProgress.childLanes - ); + var _hasChildWork = + workInProgress.childExpirationTime >= renderExpirationTime; if (didSuspendBefore) { if (_hasChildWork) { @@ -14957,7 +14258,7 @@ function beginWork(current, workInProgress, renderLanes) { return updateSuspenseListComponent( current, workInProgress, - renderLanes + renderExpirationTime ); } // If none of the children had any work, that means that none of // them got retried so they'll still be blocked in the same way @@ -14975,7 +14276,6 @@ function beginWork(current, workInProgress, renderLanes) { // update in the past but didn't complete it. renderState.rendering = null; renderState.tail = null; - renderState.lastEffect = null; } pushSuspenseContext(workInProgress, suspenseStackCursor.current); @@ -14989,35 +14289,19 @@ function beginWork(current, workInProgress, renderLanes) { return null; } } - - case OffscreenComponent: - case LegacyHiddenComponent: { - // Need to check if the tree still needs to be deferred. This is - // almost identical to the logic used in the normal update path, - // so we'll just enter that. The only difference is we'll bail out - // at the next level instead of this one, because the child props - // have not changed. Which is fine. - // TODO: Probably should refactor `beginWork` to split the bailout - // path from the normal path. I'm tempted to do a labeled break here - // but I won't :) - workInProgress.lanes = NoLanes; - return updateOffscreenComponent(current, workInProgress, renderLanes); - } } - return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes); + return bailoutOnAlreadyFinishedWork( + current, + workInProgress, + renderExpirationTime + ); } else { - if ((current.effectTag & ForceUpdateForLegacySuspense) !== NoEffect) { - // This is a special case that only exists for legacy mode. - // See https://github.com/facebook/react/pull/19216. - didReceiveUpdate = true; - } else { - // An update was scheduled on this fiber, but there are no new props - // nor legacy context. Set this to false. If an update queue or context - // consumer produces a changed value, it will set this to true. Otherwise, - // the component will assume the children have not changed and bail out. - didReceiveUpdate = false; - } + // An update was scheduled on this fiber, but there are no new props + // nor legacy context. Set this to false. If an update queue or context + // consumer produces a changed value, it will set this to true. Otherwise, + // the component will assume the children have not changed and bail out. + didReceiveUpdate = false; } } else { didReceiveUpdate = false; @@ -15027,7 +14311,7 @@ function beginWork(current, workInProgress, renderLanes) { // sometimes bails out later in the begin phase. This indicates that we should // move this assignment out of the common path and into each branch. - workInProgress.lanes = NoLanes; + workInProgress.expirationTime = NoWork; switch (workInProgress.tag) { case IndeterminateComponent: { @@ -15035,7 +14319,7 @@ function beginWork(current, workInProgress, renderLanes) { current, workInProgress, workInProgress.type, - renderLanes + renderExpirationTime ); } @@ -15045,8 +14329,8 @@ function beginWork(current, workInProgress, renderLanes) { current, workInProgress, elementType, - updateLanes, - renderLanes + updateExpirationTime, + renderExpirationTime ); } @@ -15062,7 +14346,7 @@ function beginWork(current, workInProgress, renderLanes) { workInProgress, _Component, resolvedProps, - renderLanes + renderExpirationTime ); } @@ -15080,24 +14364,32 @@ function beginWork(current, workInProgress, renderLanes) { workInProgress, _Component2, _resolvedProps, - renderLanes + renderExpirationTime ); } case HostRoot: - return updateHostRoot(current, workInProgress, renderLanes); + return updateHostRoot(current, workInProgress, renderExpirationTime); case HostComponent: - return updateHostComponent(current, workInProgress, renderLanes); + return updateHostComponent(current, workInProgress, renderExpirationTime); case HostText: return updateHostText(); case SuspenseComponent: - return updateSuspenseComponent(current, workInProgress, renderLanes); + return updateSuspenseComponent( + current, + workInProgress, + renderExpirationTime + ); case HostPortal: - return updatePortalComponent(current, workInProgress, renderLanes); + return updatePortalComponent( + current, + workInProgress, + renderExpirationTime + ); case ForwardRef: { var type = workInProgress.type; @@ -15113,24 +14405,32 @@ function beginWork(current, workInProgress, renderLanes) { workInProgress, type, _resolvedProps2, - renderLanes + renderExpirationTime ); } case Fragment: - return updateFragment(current, workInProgress, renderLanes); + return updateFragment(current, workInProgress, renderExpirationTime); case Mode: - return updateMode(current, workInProgress, renderLanes); + return updateMode(current, workInProgress, renderExpirationTime); case Profiler: - return updateProfiler(current, workInProgress, renderLanes); + return updateProfiler(current, workInProgress, renderExpirationTime); case ContextProvider: - return updateContextProvider(current, workInProgress, renderLanes); + return updateContextProvider( + current, + workInProgress, + renderExpirationTime + ); case ContextConsumer: - return updateContextConsumer(current, workInProgress, renderLanes); + return updateContextConsumer( + current, + workInProgress, + renderExpirationTime + ); case MemoComponent: { var _type2 = workInProgress.type; @@ -15159,8 +14459,8 @@ function beginWork(current, workInProgress, renderLanes) { workInProgress, _type2, _resolvedProps3, - updateLanes, - renderLanes + updateExpirationTime, + renderExpirationTime ); } @@ -15170,8 +14470,8 @@ function beginWork(current, workInProgress, renderLanes) { workInProgress, workInProgress.type, workInProgress.pendingProps, - updateLanes, - renderLanes + updateExpirationTime, + renderExpirationTime ); } @@ -15189,32 +14489,16 @@ function beginWork(current, workInProgress, renderLanes) { workInProgress, _Component3, _resolvedProps4, - renderLanes + renderExpirationTime ); } case SuspenseListComponent: { - return updateSuspenseListComponent(current, workInProgress, renderLanes); - } - - case FundamentalComponent: { - break; - } - - case ScopeComponent: { - break; - } - - case Block: { - break; - } - - case OffscreenComponent: { - return updateOffscreenComponent(current, workInProgress, renderLanes); - } - - case LegacyHiddenComponent: { - return updateLegacyHiddenComponent(current, workInProgress, renderLanes); + return updateSuspenseListComponent( + current, + workInProgress, + renderExpirationTime + ); } } @@ -15398,7 +14682,7 @@ function cutOffTailIfNeeded(renderState, hasRenderedATailFallback) { } } -function completeWork(current, workInProgress, renderLanes) { +function completeWork(current, workInProgress, renderExpirationTime) { var newProps = workInProgress.pendingProps; switch (workInProgress.tag) { @@ -15427,7 +14711,6 @@ function completeWork(current, workInProgress, renderLanes) { case HostRoot: { popHostContainer(workInProgress); popTopLevelContextObject(workInProgress); - resetWorkInProgressVersions(); var fiberRoot = workInProgress.stateNode; if (fiberRoot.pendingContext) { @@ -15444,12 +14727,6 @@ function completeWork(current, workInProgress, renderLanes) { // If we hydrated, then we'll need to schedule an update for // the commit side-effects on the root. markUpdate(workInProgress); - } else if (!fiberRoot.hydrate) { - // Schedule an effect to clear this container at the start of the next commit. - // This handles the case of React rendering into a container with previous children. - // It's also safe to do for updates too, because current.child would only be null - // if the previous render was null (so the the container would already be empty). - workInProgress.effectTag |= Snapshot; } } @@ -15574,11 +14851,7 @@ function completeWork(current, workInProgress, renderLanes) { if ((workInProgress.effectTag & DidCapture) !== NoEffect) { // Something suspended. Re-render with the fallback children. - workInProgress.lanes = renderLanes; // Do not reset the effect list. - - if ((workInProgress.mode & ProfileMode) !== NoMode) { - transferActualDuration(workInProgress); - } + workInProgress.expirationTime = renderExpirationTime; // Do not reset the effect list. return workInProgress; } @@ -15591,6 +14864,29 @@ function completeWork(current, workInProgress, renderLanes) { } else { var prevState = current.memoizedState; prevDidTimeout = prevState !== null; + + if (!nextDidTimeout && prevState !== null) { + // We just switched from the fallback to the normal children. + // Delete the fallback. + // TODO: Would it be better to store the fallback fragment on + // the stateNode during the begin phase? + var currentFallbackChild = current.child.sibling; + + if (currentFallbackChild !== null) { + // Deletions go at the beginning of the return fiber's effect list + var first = workInProgress.firstEffect; + + if (first !== null) { + workInProgress.firstEffect = currentFallbackChild; + currentFallbackChild.nextEffect = first; + } else { + workInProgress.firstEffect = workInProgress.lastEffect = currentFallbackChild; + currentFallbackChild.nextEffect = null; + } + + currentFallbackChild.effectTag = Deletion; + } + } } if (nextDidTimeout && !prevDidTimeout) { @@ -15647,11 +14943,6 @@ function completeWork(current, workInProgress, renderLanes) { case HostPortal: popHostContainer(workInProgress); updateHostContainer(workInProgress); - - if (current === null) { - preparePortalMount(workInProgress.stateNode.containerInfo); - } - return null; case ContextProvider: @@ -15738,7 +15029,7 @@ function completeWork(current, workInProgress, renderLanes) { workInProgress.lastEffect = renderState.lastEffect; // Reset the child fibers to their original state. - resetChildFibers(workInProgress, renderLanes); // Set up the Suspense Context to force suspense and immediately + resetChildFibers(workInProgress, renderExpirationTime); // Set up the Suspense Context to force suspense and immediately // rerender the children. pushSuspenseContext( @@ -15779,8 +15070,7 @@ function completeWork(current, workInProgress, renderLanes) { if ( renderState.tail === null && renderState.tailMode === "hidden" && - !renderedTail.alternate && - !getIsHydrating() // We don't cut it if we're hydrating. + !renderedTail.alternate ) { // We need to delete the row we just rendered. // Reset the effect list to what it was before we rendered this @@ -15799,7 +15089,7 @@ function completeWork(current, workInProgress, renderLanes) { // the expiration. now() * 2 - renderState.renderingStartTime > renderState.tailExpiration && - renderLanes !== OffscreenLane + renderExpirationTime > Never ) { // We have now passed our CPU deadline and we'll just give up further // attempts to render the main content and only render fallbacks. @@ -15812,10 +15102,11 @@ function completeWork(current, workInProgress, renderLanes) { // So we'll pick it back up the very next render pass once we've had // an opportunity to yield for paint. - workInProgress.lanes = renderLanes; + var nextPriority = renderExpirationTime - 1; + workInProgress.expirationTime = workInProgress.childExpirationTime = nextPriority; { - markSpawnedWork(renderLanes); + markSpawnedWork(nextPriority); } } } @@ -15882,38 +15173,6 @@ function completeWork(current, workInProgress, renderLanes) { return null; } - - case FundamentalComponent: { - break; - } - - case ScopeComponent: { - break; - } - - case Block: - break; - - case OffscreenComponent: - case LegacyHiddenComponent: { - popRenderLanes(workInProgress); - - if (current !== null) { - var _nextState = workInProgress.memoizedState; - var _prevState = current.memoizedState; - var prevIsHidden = _prevState !== null; - var nextIsHidden = _nextState !== null; - - if ( - prevIsHidden !== nextIsHidden && - newProps.mode !== "unstable-defer-without-hiding" - ) { - workInProgress.effectTag |= Update; - } - } - - return null; - } } { @@ -15925,7 +15184,7 @@ function completeWork(current, workInProgress, renderLanes) { } } -function unwindWork(workInProgress, renderLanes) { +function unwindWork(workInProgress, renderExpirationTime) { switch (workInProgress.tag) { case ClassComponent: { var Component = workInProgress.type; @@ -15938,11 +15197,6 @@ function unwindWork(workInProgress, renderLanes) { if (effectTag & ShouldCapture) { workInProgress.effectTag = (effectTag & ~ShouldCapture) | DidCapture; - - if ((workInProgress.mode & ProfileMode) !== NoMode) { - transferActualDuration(workInProgress); - } - return workInProgress; } @@ -15952,7 +15206,6 @@ function unwindWork(workInProgress, renderLanes) { case HostRoot: { popHostContainer(workInProgress); popTopLevelContextObject(workInProgress); - resetWorkInProgressVersions(); var _effectTag = workInProgress.effectTag; if (!((_effectTag & DidCapture) === NoEffect)) { @@ -15979,10 +15232,6 @@ function unwindWork(workInProgress, renderLanes) { if (_effectTag2 & ShouldCapture) { workInProgress.effectTag = (_effectTag2 & ~ShouldCapture) | DidCapture; // Captured a suspense effect. Re-render the boundary. - if ((workInProgress.mode & ProfileMode) !== NoMode) { - transferActualDuration(workInProgress); - } - return workInProgress; } @@ -16004,11 +15253,6 @@ function unwindWork(workInProgress, renderLanes) { popProvider(workInProgress); return null; - case OffscreenComponent: - case LegacyHiddenComponent: - popRenderLanes(workInProgress); - return null; - default: return null; } @@ -16029,7 +15273,6 @@ function unwindInterruptedWork(interruptedWork) { case HostRoot: { popHostContainer(interruptedWork); popTopLevelContextObject(interruptedWork); - resetWorkInProgressVersions(); break; } @@ -16053,11 +15296,6 @@ function unwindInterruptedWork(interruptedWork) { case ContextProvider: popProvider(interruptedWork); break; - - case OffscreenComponent: - case LegacyHiddenComponent: - popRenderLanes(interruptedWork); - break; } } @@ -16071,6 +15309,8 @@ function createCapturedValue(value, source) { }; } +// Module provided by RN: + if ( !( typeof ReactNativePrivateInterface.ReactFiberErrorDialog.showErrorDialog === @@ -16082,88 +15322,118 @@ if ( ); } -function showErrorDialog(boundary, errorInfo) { - var capturedError = { - componentStack: errorInfo.stack !== null ? errorInfo.stack : "", - error: errorInfo.value, - errorBoundary: - boundary !== null && boundary.tag === ClassComponent - ? boundary.stateNode - : null - }; +function showErrorDialog(capturedError) { return ReactNativePrivateInterface.ReactFiberErrorDialog.showErrorDialog( capturedError ); } -function logCapturedError(boundary, errorInfo) { - try { - var logError = showErrorDialog(boundary, errorInfo); // Allow injected showErrorDialog() to prevent default console.error logging. - // This enables renderers like ReactNative to better manage redbox behavior. +function logCapturedError(capturedError) { + var logError = showErrorDialog(capturedError); // Allow injected showErrorDialog() to prevent default console.error logging. + // This enables renderers like ReactNative to better manage redbox behavior. - if (logError === false) { - return; + if (logError === false) { + return; + } + + var error = capturedError.error; + + { + var componentName = capturedError.componentName, + componentStack = capturedError.componentStack, + errorBoundaryName = capturedError.errorBoundaryName, + errorBoundaryFound = capturedError.errorBoundaryFound, + willRetry = capturedError.willRetry; // Browsers support silencing uncaught errors by calling + // `preventDefault()` in window `error` handler. + // We record this information as an expando on the error. + + if (error != null && error._suppressLogging) { + if (errorBoundaryFound && willRetry) { + // The error is recoverable and was silenced. + // Ignore it and don't print the stack addendum. + // This is handy for testing error boundaries without noise. + return; + } // The error is fatal. Since the silencing might have + // been accidental, we'll surface it anyway. + // However, the browser would have silenced the original error + // so we'll print it first, and then print the stack addendum. + + console["error"](error); // Don't transform to our wrapper + // For a more detailed description of this block, see: + // https://github.com/facebook/react/pull/13384 } - var error = errorInfo.value; + var componentNameMessage = componentName + ? "The above error occurred in the <" + componentName + "> component:" + : "The above error occurred in one of your React components:"; + var errorBoundaryMessage; // errorBoundaryFound check is sufficient; errorBoundaryName check is to satisfy Flow. - if (true) { - var source = errorInfo.source; - var stack = errorInfo.stack; - var componentStack = stack !== null ? stack : ""; // Browsers support silencing uncaught errors by calling - // `preventDefault()` in window `error` handler. - // We record this information as an expando on the error. - - if (error != null && error._suppressLogging) { - if (boundary.tag === ClassComponent) { - // The error is recoverable and was silenced. - // Ignore it and don't print the stack addendum. - // This is handy for testing error boundaries without noise. - return; - } // The error is fatal. Since the silencing might have - // been accidental, we'll surface it anyway. - // However, the browser would have silenced the original error - // so we'll print it first, and then print the stack addendum. - - console["error"](error); // Don't transform to our wrapper - // For a more detailed description of this block, see: - // https://github.com/facebook/react/pull/13384 - } - - var componentName = source ? getComponentName(source.type) : null; - var componentNameMessage = componentName - ? "The above error occurred in the <" + componentName + "> component:" - : "The above error occurred in one of your React components:"; - var errorBoundaryMessage; - var errorBoundaryName = getComponentName(boundary.type); - - if (errorBoundaryName) { + if (errorBoundaryFound && errorBoundaryName) { + if (willRetry) { errorBoundaryMessage = "React will try to recreate this component tree from scratch " + ("using the error boundary you provided, " + errorBoundaryName + "."); } else { errorBoundaryMessage = - "Consider adding an error boundary to your tree to customize error handling behavior.\n" + - "Visit https://fb.me/react-error-boundaries to learn more about error boundaries."; + "This error was initially handled by the error boundary " + + errorBoundaryName + + ".\n" + + "Recreating the tree from scratch failed so React will unmount the tree."; } - - var combinedMessage = - componentNameMessage + - "\n" + - componentStack + - "\n\n" + - ("" + errorBoundaryMessage); // In development, we provide our own message with just the component stack. - // We don't include the original error message and JS stack because the browser - // has already printed it. Even if the application swallows the error, it is still - // displayed by the browser thanks to the DEV-only fake event trick in ReactErrorUtils. - - console["error"](combinedMessage); // Don't transform to our wrapper } else { - // In production, we print the error directly. - // This will include the message, the JS stack, and anything the browser wants to show. - // We pass the error object instead of custom message so that the browser displays the error natively. - console["error"](error); // Don't transform to our wrapper + errorBoundaryMessage = + "Consider adding an error boundary to your tree to customize error handling behavior.\n" + + "Visit https://fb.me/react-error-boundaries to learn more about error boundaries."; } + + var combinedMessage = + "" + + componentNameMessage + + componentStack + + "\n\n" + + ("" + errorBoundaryMessage); // In development, we provide our own message with just the component stack. + // We don't include the original error message and JS stack because the browser + // has already printed it. Even if the application swallows the error, it is still + // displayed by the browser thanks to the DEV-only fake event trick in ReactErrorUtils. + + console["error"](combinedMessage); // Don't transform to our wrapper + } +} + +var didWarnAboutUndefinedSnapshotBeforeUpdate = null; + +{ + didWarnAboutUndefinedSnapshotBeforeUpdate = new Set(); +} + +var PossiblyWeakSet = typeof WeakSet === "function" ? WeakSet : Set; +function logError(boundary, errorInfo) { + var source = errorInfo.source; + var stack = errorInfo.stack; + + if (stack === null && source !== null) { + stack = getStackByFiberInDevAndProd(source); + } + + var capturedError = { + componentName: source !== null ? getComponentName(source.type) : null, + componentStack: stack !== null ? stack : "", + error: errorInfo.value, + errorBoundary: null, + errorBoundaryName: null, + errorBoundaryFound: false, + willRetry: false + }; + + if (boundary !== null && boundary.tag === ClassComponent) { + capturedError.errorBoundary = boundary.stateNode; + capturedError.errorBoundaryName = getComponentName(boundary.type); + capturedError.errorBoundaryFound = true; + capturedError.willRetry = true; + } + + try { + logCapturedError(capturedError); } catch (e) { // This method must not throw, or React internal state will get messed up. // If console.error is overridden, or logCapturedError() shows a dialog that throws, @@ -16175,347 +15445,16 @@ function logCapturedError(boundary, errorInfo) { } } -var PossiblyWeakMap$1 = typeof WeakMap === "function" ? WeakMap : Map; - -function createRootErrorUpdate(fiber, errorInfo, lane) { - var update = createUpdate(NoTimestamp, lane, null); // Unmount the root by rendering null. - - update.tag = CaptureUpdate; // Caution: React DevTools currently depends on this property - // being called "element". - - update.payload = { - element: null - }; - var error = errorInfo.value; - - update.callback = function() { - onUncaughtError(error); - logCapturedError(fiber, errorInfo); - }; - - return update; -} - -function createClassErrorUpdate(fiber, errorInfo, lane) { - var update = createUpdate(NoTimestamp, lane, null); - update.tag = CaptureUpdate; - var getDerivedStateFromError = fiber.type.getDerivedStateFromError; - - if (typeof getDerivedStateFromError === "function") { - var error$1 = errorInfo.value; - - update.payload = function() { - logCapturedError(fiber, errorInfo); - return getDerivedStateFromError(error$1); - }; - } - - var inst = fiber.stateNode; - - if (inst !== null && typeof inst.componentDidCatch === "function") { - update.callback = function callback() { - { - markFailedErrorBoundaryForHotReloading(fiber); - } - - if (typeof getDerivedStateFromError !== "function") { - // To preserve the preexisting retry behavior of error boundaries, - // we keep track of which ones already failed during this batch. - // This gets reset before we yield back to the browser. - // TODO: Warn in strict mode if getDerivedStateFromError is - // not defined. - markLegacyErrorBoundaryAsFailed(this); // Only log here if componentDidCatch is the only error boundary method defined - - logCapturedError(fiber, errorInfo); - } - - var error$1 = errorInfo.value; - var stack = errorInfo.stack; - this.componentDidCatch(error$1, { - componentStack: stack !== null ? stack : "" - }); - - { - if (typeof getDerivedStateFromError !== "function") { - // If componentDidCatch is the only error boundary method defined, - // then it needs to call setState to recover from errors. - // If no state update is scheduled then the boundary will swallow the error. - if (!includesSomeLane(fiber.lanes, SyncLane)) { - error( - "%s: Error boundaries should implement getDerivedStateFromError(). " + - "In that method, return a state update to display an error message or fallback UI.", - getComponentName(fiber.type) || "Unknown" - ); - } - } - } - }; - } else { - update.callback = function() { - markFailedErrorBoundaryForHotReloading(fiber); - }; - } - - return update; -} - -function attachPingListener(root, wakeable, lanes) { - // Attach a listener to the promise to "ping" the root and retry. But only if - // one does not already exist for the lanes we're currently rendering (which - // acts like a "thread ID" here). - var pingCache = root.pingCache; - var threadIDs; - - if (pingCache === null) { - pingCache = root.pingCache = new PossiblyWeakMap$1(); - threadIDs = new Set(); - pingCache.set(wakeable, threadIDs); - } else { - threadIDs = pingCache.get(wakeable); - - if (threadIDs === undefined) { - threadIDs = new Set(); - pingCache.set(wakeable, threadIDs); - } - } - - if (!threadIDs.has(lanes)) { - // Memoize using the thread ID to prevent redundant listeners. - threadIDs.add(lanes); - var ping = pingSuspendedRoot.bind(null, root, wakeable, lanes); - wakeable.then(ping, ping); - } -} - -function throwException( - root, - returnFiber, - sourceFiber, - value, - rootRenderLanes -) { - // The source fiber did not complete. - sourceFiber.effectTag |= Incomplete; // Its effect list is no longer valid. - - sourceFiber.firstEffect = sourceFiber.lastEffect = null; - - if ( - value !== null && - typeof value === "object" && - typeof value.then === "function" - ) { - // This is a wakeable. - var wakeable = value; - - if ((sourceFiber.mode & BlockingMode) === NoMode) { - // Reset the memoizedState to what it was before we attempted - // to render it. - var currentSource = sourceFiber.alternate; - - if (currentSource) { - sourceFiber.updateQueue = currentSource.updateQueue; - sourceFiber.memoizedState = currentSource.memoizedState; - sourceFiber.lanes = currentSource.lanes; - } else { - sourceFiber.updateQueue = null; - sourceFiber.memoizedState = null; - } - } - - var hasInvisibleParentBoundary = hasSuspenseContext( - suspenseStackCursor.current, - InvisibleParentSuspenseContext - ); // Schedule the nearest Suspense to re-render the timed out view. - - var _workInProgress = returnFiber; - - do { - if ( - _workInProgress.tag === SuspenseComponent && - shouldCaptureSuspense(_workInProgress, hasInvisibleParentBoundary) - ) { - // Found the nearest boundary. - // Stash the promise on the boundary fiber. If the boundary times out, we'll - // attach another listener to flip the boundary back to its normal state. - var wakeables = _workInProgress.updateQueue; - - if (wakeables === null) { - var updateQueue = new Set(); - updateQueue.add(wakeable); - _workInProgress.updateQueue = updateQueue; - } else { - wakeables.add(wakeable); - } // If the boundary is outside of blocking 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 blocking mode tree. If the Suspense is outside of it, we - // should *not* suspend the commit. - - if ((_workInProgress.mode & BlockingMode) === NoMode) { - _workInProgress.effectTag |= DidCapture; - sourceFiber.effectTag |= ForceUpdateForLegacySuspense; // 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 | Incomplete); - - if (sourceFiber.tag === ClassComponent) { - var currentSourceFiber = sourceFiber.alternate; - - if (currentSourceFiber === 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; - } else { - // 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 update to - // prevent a bail out. - var update = createUpdate(NoTimestamp, SyncLane, null); - update.tag = ForceUpdate; - enqueueUpdate(sourceFiber, update); - } - } // The source fiber did not complete. Mark it with Sync priority to - // indicate that it still has pending work. - - sourceFiber.lanes = mergeLanes(sourceFiber.lanes, SyncLane); // Exit without suspending. - - return; - } // Confirmed that the boundary is in a concurrent mode tree. Continue - // with the normal suspend path. - // - // After this we'll use a set of heuristics to determine whether this - // render pass will run to completion or restart or "suspend" the commit. - // The actual logic for this is spread out in different places. - // - // This first principle is that if we're going to suspend when we complete - // a root, then we should also restart if we get an update or ping that - // might unsuspend it, and vice versa. The only reason to suspend is - // because you think you might want to restart before committing. However, - // it doesn't make sense to restart only while in the period we're suspended. - // - // Restarting too aggressively is also not good because it starves out any - // intermediate loading state. So we use heuristics to determine when. - // Suspense Heuristics - // - // If nothing threw a Promise or all the same fallbacks are already showing, - // then don't suspend/restart. - // - // If this is an initial render of a new tree of Suspense boundaries and - // those trigger a fallback, then don't suspend/restart. We want to ensure - // that we can show the initial loading state as quickly as possible. - // - // If we hit a "Delayed" case, such as when we'd switch from content back into - // a fallback, then we should always suspend/restart. SuspenseConfig applies to - // this case. If none is defined, JND is used instead. - // - // If we're already showing a fallback and it gets "retried", allowing us to show - // another level, but there's still an inner boundary that would show a fallback, - // then we suspend/restart for 500ms since the last time we showed a fallback - // anywhere in the tree. This effectively throttles progressive loading into a - // consistent train of commits. This also gives us an opportunity to restart to - // get to the completed state slightly earlier. - // - // If there's ambiguity due to batching it's resolved in preference of: - // 1) "delayed", 2) "initial render", 3) "retry". - // - // We want to ensure that a "busy" state doesn't get force committed. We want to - // ensure that new initial loading states can commit as soon as possible. - - attachPingListener(root, wakeable, rootRenderLanes); - _workInProgress.effectTag |= ShouldCapture; - _workInProgress.lanes = rootRenderLanes; - 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( - (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." - ); - } // We didn't find a boundary that could handle this type of exception. Start - // over and traverse parent path again, this time treating the exception - // as an error. - - renderDidError(); - value = createCapturedValue(value, sourceFiber); - var workInProgress = returnFiber; - - do { - switch (workInProgress.tag) { - case HostRoot: { - var _errorInfo = value; - workInProgress.effectTag |= ShouldCapture; - var lane = pickArbitraryLane(rootRenderLanes); - workInProgress.lanes = mergeLanes(workInProgress.lanes, lane); - - var _update = createRootErrorUpdate(workInProgress, _errorInfo, lane); - - enqueueCapturedUpdate(workInProgress, _update); - return; - } - - case ClassComponent: - // Capture and retry - var errorInfo = value; - var ctor = workInProgress.type; - var instance = workInProgress.stateNode; - - if ( - (workInProgress.effectTag & DidCapture) === NoEffect && - (typeof ctor.getDerivedStateFromError === "function" || - (instance !== null && - typeof instance.componentDidCatch === "function" && - !isAlreadyFailedLegacyErrorBoundary(instance))) - ) { - workInProgress.effectTag |= ShouldCapture; - - var _lane = pickArbitraryLane(rootRenderLanes); - - workInProgress.lanes = mergeLanes(workInProgress.lanes, _lane); // Schedule the error boundary to re-render using updated state - - var _update2 = createClassErrorUpdate( - workInProgress, - errorInfo, - _lane - ); - - enqueueCapturedUpdate(workInProgress, _update2); - return; - } - - break; - } - - workInProgress = workInProgress.return; - } while (workInProgress !== null); -} - -var didWarnAboutUndefinedSnapshotBeforeUpdate = null; - -{ - didWarnAboutUndefinedSnapshotBeforeUpdate = new Set(); -} - -var PossiblyWeakSet = typeof WeakSet === "function" ? WeakSet : Set; - var callComponentWillUnmountWithTimer = function(current, instance) { + startPhaseTimer(current, "componentWillUnmount"); instance.props = current.memoizedProps; instance.state = current.memoizedState; { instance.componentWillUnmount(); } + + stopPhaseTimer(); }; // Capture errors so they don't interrupt unmounting. function safelyCallComponentWillUnmount(current, instance) { @@ -16579,6 +15518,7 @@ function commitBeforeMutationLifeCycles(current, finishedWork) { if (current !== null) { var prevProps = current.memoizedProps; var prevState = current.memoizedState; + startPhaseTimer(finishedWork, "getSnapshotBeforeUpdate"); var instance = finishedWork.stateNode; // 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. @@ -16634,23 +15574,14 @@ function commitBeforeMutationLifeCycles(current, finishedWork) { } instance.__reactInternalSnapshotBeforeUpdate = snapshot; + stopPhaseTimer(); } } return; } - case HostRoot: { - { - if (finishedWork.effectTag & Snapshot) { - var root = finishedWork.stateNode; - clearContainer(root.containerInfo); - } - } - - return; - } - + case HostRoot: case HostComponent: case HostText: case HostPortal: @@ -16734,8 +15665,9 @@ function commitHookEffectListMount(tag, finishedWork) { error( "An effect function must not return anything besides a function, " + - "which is used for clean-up.%s", - addendum + "which is used for clean-up.%s%s", + addendum, + getStackByFiberInDevAndProd(finishedWork) ); } } @@ -16746,33 +15678,33 @@ function commitHookEffectListMount(tag, finishedWork) { } } -function schedulePassiveEffects(finishedWork) { - var updateQueue = finishedWork.updateQueue; - var lastEffect = updateQueue !== null ? updateQueue.lastEffect : null; +function commitPassiveHookEffects(finishedWork) { + if ((finishedWork.effectTag & Passive) !== NoEffect) { + switch (finishedWork.tag) { + case FunctionComponent: + case ForwardRef: + case SimpleMemoComponent: + case Block: { + // TODO (#17945) We should call all passive destroy functions (for all fibers) + // before calling any create functions. The current approach only serializes + // these for a single fiber. + { + commitHookEffectListUnmount(Passive$1 | HasEffect, finishedWork); + commitHookEffectListMount(Passive$1 | HasEffect, finishedWork); + } - if (lastEffect !== null) { - var firstEffect = lastEffect.next; - var effect = firstEffect; - - do { - var _effect = effect, - next = _effect.next, - tag = _effect.tag; - - if ( - (tag & Passive$1) !== NoEffect$1 && - (tag & HasEffect) !== NoEffect$1 - ) { - enqueuePendingPassiveHookEffectUnmount(finishedWork, effect); - enqueuePendingPassiveHookEffectMount(finishedWork, effect); + break; } - - effect = next; - } while (effect !== firstEffect); + } } } -function commitLifeCycles(finishedRoot, current, finishedWork, committedLanes) { +function commitLifeCycles( + finishedRoot, + current, + finishedWork, + committedExpirationTime +) { switch (finishedWork.tag) { case FunctionComponent: case ForwardRef: @@ -16786,7 +15718,6 @@ function commitLifeCycles(finishedRoot, current, finishedWork, committedLanes) { commitHookEffectListMount(Layout | HasEffect, finishedWork); } - schedulePassiveEffects(finishedWork); return; } @@ -16795,9 +15726,10 @@ function commitLifeCycles(finishedRoot, current, finishedWork, committedLanes) { if (finishedWork.effectTag & Update) { if (current === null) { - // We could update instance props and state here, + startPhaseTimer(finishedWork, "componentDidMount"); // 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 && @@ -16830,12 +15762,15 @@ function commitLifeCycles(finishedRoot, current, finishedWork, committedLanes) { { instance.componentDidMount(); } + + stopPhaseTimer(); } else { var prevProps = finishedWork.elementType === finishedWork.type ? current.memoizedProps : resolveDefaultProps(finishedWork.type, current.memoizedProps); - var prevState = current.memoizedState; // We could update instance props and state here, + var prevState = current.memoizedState; + startPhaseTimer(finishedWork, "componentDidUpdate"); // 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. @@ -16875,9 +15810,10 @@ function commitLifeCycles(finishedRoot, current, finishedWork, committedLanes) { instance.__reactInternalSnapshotBeforeUpdate ); } + + stopPhaseTimer(); } - } // TODO: I think this is now always non-null by the time it reaches the - // commit phase. Consider removing the type check. + } var updateQueue = finishedWork.updateQueue; @@ -16920,8 +15856,6 @@ function commitLifeCycles(finishedRoot, current, finishedWork, committedLanes) { } case HostRoot: { - // TODO: I think this is now always non-null by the time it reaches the - // commit phase. Consider removing the type check. var _updateQueue = finishedWork.updateQueue; if (_updateQueue !== null) { @@ -17003,8 +15937,6 @@ function commitLifeCycles(finishedRoot, current, finishedWork, committedLanes) { case IncompleteClassComponent: case FundamentalComponent: case ScopeComponent: - case OffscreenComponent: - case LegacyHiddenComponent: return; } @@ -17039,12 +15971,17 @@ function hideOrUnhideAllChildren(finishedWork, isHidden) { unhideTextInstance(_instance3, node.memoizedProps); } } else if ( - (node.tag === OffscreenComponent || - node.tag === LegacyHiddenComponent) && + node.tag === SuspenseComponent && node.memoizedState !== null && - node !== finishedWork - ); - else if (node.child !== null) { + node.memoizedState.dehydrated === null + ) { + // Found a nested Suspense component that timed out. Skip over the + // primary child fragment, which should remain hidden. + var fallbackChildFragment = node.child.sibling; + fallbackChildFragment.return = node; + node = fallbackChildFragment; + continue; + } else if (node.child !== null) { node.child.return = node; node = node.child; continue; @@ -17091,8 +16028,9 @@ function commitAttachRef(finishedWork) { if (!ref.hasOwnProperty("current")) { error( "Unexpected ref object provided for %s. " + - "Use either a ref-setter function or React.createRef().", - getComponentName(finishedWork.type) + "Use either a ref-setter function or React.createRef().%s", + getComponentName(finishedWork.type), + getStackByFiberInDevAndProd(finishedWork) ); } } @@ -17132,25 +16070,42 @@ function commitUnmount(finishedRoot, current, renderPriorityLevel) { if (lastEffect !== null) { var firstEffect = lastEffect.next; - var effect = firstEffect; - do { - var _effect2 = effect, - destroy = _effect2.destroy, - tag = _effect2.tag; + { + // When the owner fiber is deleted, the destroy function of a passive + // effect hook is called during the synchronous commit phase. This is + // a concession to implementation complexity. Calling it in the + // passive effect phase (like they usually are, when dependencies + // change during an update) would require either traversing the + // children of the deleted fiber again, or including unmount effects + // as part of the fiber effect list. + // + // Because this is during the sync commit phase, we need to change + // the priority. + // + // TODO: Reconsider this implementation trade off. + var priorityLevel = + renderPriorityLevel > NormalPriority + ? NormalPriority + : renderPriorityLevel; + runWithPriority(priorityLevel, function() { + var effect = firstEffect; - if (destroy !== undefined) { - if ((tag & Passive$1) !== NoEffect$1) { - enqueuePendingPassiveHookEffectUnmount(current, effect); - } else { - { - safelyCallDestroy(current, destroy); + do { + var _effect3 = effect, + _destroy = _effect3.destroy, + _tag = _effect3.tag; + + if (_destroy !== undefined) { + { + safelyCallDestroy(current, _destroy); + } } - } - } - effect = effect.next; - } while (effect !== firstEffect); + effect = effect.next; + } while (effect !== firstEffect); + }); + } } } @@ -17178,7 +16133,7 @@ function commitUnmount(finishedRoot, current, renderPriorityLevel) { // We are also not using this parent because // the portal will get pushed immediately. { - unmountHostComponents(finishedRoot, current); + unmountHostComponents(finishedRoot, current, renderPriorityLevel); } return; @@ -17207,7 +16162,7 @@ function commitNestedUnmounts(finishedRoot, root, renderPriorityLevel) { var node = root; while (true) { - commitUnmount(finishedRoot, node); // Visit children because they may contain more composite or host nodes. + commitUnmount(finishedRoot, node, renderPriorityLevel); // Visit children because they may contain more composite or host nodes. // Skip portals because commitUnmount() currently visits them recursively. if ( @@ -17237,30 +16192,27 @@ function commitNestedUnmounts(finishedRoot, root, renderPriorityLevel) { } } -function detachFiberMutation(fiber) { - // Cut off the return pointers to disconnect it from the tree. Ideally, we +function detachFiber(current) { + var alternate = current.alternate; // Cut off the return pointers to disconnect it from the tree. Ideally, we // should clear the child pointer of the parent alternate to let this // get GC:ed but we don't know which for sure which parent is the current // one so we'll settle for GC:ing the subtree of this child. This child // itself will be GC:ed when the parent updates the next time. - // Note: we cannot null out sibling here, otherwise it can cause issues - // with findDOMNode and how it requires the sibling field to carry out - // traversal in a later effect. See PR #16820. We now clear the sibling - // field after effects, see: detachFiberAfterEffects. - fiber.alternate = null; - fiber.child = null; - fiber.dependencies = null; - fiber.firstEffect = null; - fiber.lastEffect = null; - fiber.memoizedProps = null; - fiber.memoizedState = null; - fiber.pendingProps = null; - fiber.return = null; - fiber.stateNode = null; - fiber.updateQueue = null; - { - fiber._debugOwner = null; + current.return = null; + current.child = null; + current.memoizedState = null; + current.updateQueue = null; + current.dependencies = null; + current.alternate = null; + current.firstEffect = null; + current.lastEffect = null; + current.pendingProps = null; + current.memoizedProps = null; + current.stateNode = null; + + if (alternate !== null) { + detachFiber(alternate); } } @@ -17492,7 +16444,7 @@ function unmountHostComponents(finishedRoot, current, renderPriorityLevel) { } if (node.tag === HostComponent || node.tag === HostText) { - commitNestedUnmounts(finishedRoot, node); // After all the children have unmounted, it is now safe to remove the + commitNestedUnmounts(finishedRoot, node, renderPriorityLevel); // After all the children have unmounted, it is now safe to remove the // node from the tree. if (currentParentIsContainer) { @@ -17512,7 +16464,7 @@ function unmountHostComponents(finishedRoot, current, renderPriorityLevel) { continue; } } else { - commitUnmount(finishedRoot, node); // Visit children because we may find more host components below. + commitUnmount(finishedRoot, node, renderPriorityLevel); // Visit children because we may find more host components below. if (node.child !== null) { node.child.return = node; @@ -17548,15 +16500,10 @@ function commitDeletion(finishedRoot, current, renderPriorityLevel) { { // Recursively delete all host nodes from the parent. // Detach refs and call componentWillUnmount() on the whole subtree. - unmountHostComponents(finishedRoot, current); + unmountHostComponents(finishedRoot, current, renderPriorityLevel); } - var alternate = current.alternate; - detachFiberMutation(current); - - if (alternate !== null) { - detachFiberMutation(alternate); - } + detachFiber(current); } function commitWork(current, finishedWork) { @@ -17644,22 +16591,6 @@ function commitWork(current, finishedWork) { case IncompleteClassComponent: { return; } - - case FundamentalComponent: { - break; - } - - case ScopeComponent: { - break; - } - - case OffscreenComponent: - case LegacyHiddenComponent: { - var newState = finishedWork.memoizedState; - var isHidden = newState !== null; - hideOrUnhideAllChildren(finishedWork, isHidden); - return; - } } { @@ -17671,33 +16602,29 @@ function commitWork(current, finishedWork) { function commitSuspenseComponent(finishedWork) { var newState = finishedWork.memoizedState; + var newDidTimeout; + var primaryChildParent = finishedWork; - if (newState !== null) { + if (newState === null) { + newDidTimeout = false; + } else { + newDidTimeout = true; + primaryChildParent = finishedWork.child; markCommitTimeOfFallback(); + } - { - // Hide the Offscreen component that contains the primary children. TODO: - // Ideally, this effect would have been scheduled on the Offscreen fiber - // itself. That's how unhiding works: the Offscreen component schedules an - // effect on itself. However, in this case, the component didn't complete, - // so the fiber was never added to the effect list in the normal path. We - // could have appended it to the effect list in the Suspense component's - // second pass, but doing it this way is less complicated. This would be - // simpler if we got rid of the effect list and traversed the tree, like - // we're planning to do. - var primaryChildParent = finishedWork.child; - hideOrUnhideAllChildren(primaryChildParent, true); - } + if (primaryChildParent !== null) { + hideOrUnhideAllChildren(primaryChildParent, newDidTimeout); } } function attachSuspenseRetryListeners(finishedWork) { - // If this boundary just timed out, then it will have a set of wakeables. - // For each wakeable, attach a listener so that when it resolves, React + // If this boundary just timed out, then it will have a set of thenables. + // For each thenable, attach a listener so that when it resolves, React // attempts to re-render the boundary in the primary (pre-timeout) state. - var wakeables = finishedWork.updateQueue; + var thenables = finishedWork.updateQueue; - if (wakeables !== null) { + if (thenables !== null) { finishedWork.updateQueue = null; var retryCache = finishedWork.stateNode; @@ -17705,64 +16632,365 @@ function attachSuspenseRetryListeners(finishedWork) { retryCache = finishedWork.stateNode = new PossiblyWeakSet(); } - wakeables.forEach(function(wakeable) { + thenables.forEach(function(thenable) { // Memoize using the boundary fiber to prevent redundant listeners. - var retry = resolveRetryWakeable.bind(null, finishedWork, wakeable); + var retry = resolveRetryThenable.bind(null, finishedWork, thenable); - if (!retryCache.has(wakeable)) { + if (!retryCache.has(thenable)) { { - if (wakeable.__reactDoNotTraceInteractions !== true) { + if (thenable.__reactDoNotTraceInteractions !== true) { retry = tracing.unstable_wrap(retry); } } - retryCache.add(wakeable); - wakeable.then(retry, retry); + retryCache.add(thenable); + thenable.then(retry, retry); } }); } -} // This function detects when a Suspense boundary goes from visible to hidden. -// It returns false if the boundary is already hidden. -// TODO: Use an effect tag. - -function isSuspenseBoundaryBeingHidden(current, finishedWork) { - if (current !== null) { - var oldState = current.memoizedState; - - if (oldState === null || oldState.dehydrated !== null) { - var newState = finishedWork.memoizedState; - return newState !== null && newState.dehydrated === null; - } - } - - return false; } function commitResetTextContent(current) { resetTextContent(current.stateNode); } -var COMPONENT_TYPE = 0; -var HAS_PSEUDO_CLASS_TYPE = 1; -var ROLE_TYPE = 2; -var TEST_NAME_TYPE = 3; -var TEXT_TYPE = 4; +var PossiblyWeakMap = typeof WeakMap === "function" ? WeakMap : Map; -if (typeof Symbol === "function" && Symbol.for) { - var symbolFor$1 = Symbol.for; - COMPONENT_TYPE = symbolFor$1("selector.component"); - HAS_PSEUDO_CLASS_TYPE = symbolFor$1("selector.has_pseudo_class"); - ROLE_TYPE = symbolFor$1("selector.role"); - TEST_NAME_TYPE = symbolFor$1("selector.test_id"); - TEXT_TYPE = symbolFor$1("selector.text"); +function createRootErrorUpdate(fiber, errorInfo, expirationTime) { + var update = createUpdate(expirationTime, null); // Unmount the root by rendering null. + + update.tag = CaptureUpdate; // Caution: React DevTools currently depends on this property + // being called "element". + + update.payload = { + element: null + }; + var error = errorInfo.value; + + update.callback = function() { + onUncaughtError(error); + logError(fiber, errorInfo); + }; + + return update; +} + +function createClassErrorUpdate(fiber, errorInfo, expirationTime) { + var update = createUpdate(expirationTime, null); + update.tag = CaptureUpdate; + var getDerivedStateFromError = fiber.type.getDerivedStateFromError; + + if (typeof getDerivedStateFromError === "function") { + var error$1 = errorInfo.value; + + update.payload = function() { + logError(fiber, errorInfo); + return getDerivedStateFromError(error$1); + }; + } + + var inst = fiber.stateNode; + + if (inst !== null && typeof inst.componentDidCatch === "function") { + update.callback = function callback() { + { + markFailedErrorBoundaryForHotReloading(fiber); + } + + if (typeof getDerivedStateFromError !== "function") { + // To preserve the preexisting retry behavior of error boundaries, + // we keep track of which ones already failed during this batch. + // This gets reset before we yield back to the browser. + // TODO: Warn in strict mode if getDerivedStateFromError is + // not defined. + markLegacyErrorBoundaryAsFailed(this); // Only log here if componentDidCatch is the only error boundary method defined + + logError(fiber, errorInfo); + } + + var error$1 = errorInfo.value; + var stack = errorInfo.stack; + this.componentDidCatch(error$1, { + componentStack: stack !== null ? stack : "" + }); + + { + if (typeof getDerivedStateFromError !== "function") { + // If componentDidCatch is the only error boundary method defined, + // then it needs to call setState to recover from errors. + // If no state update is scheduled then the boundary will swallow the error. + if (fiber.expirationTime !== Sync) { + error( + "%s: Error boundaries should implement getDerivedStateFromError(). " + + "In that method, return a state update to display an error message or fallback UI.", + getComponentName(fiber.type) || "Unknown" + ); + } + } + } + }; + } else { + update.callback = function() { + markFailedErrorBoundaryForHotReloading(fiber); + }; + } + + return update; +} + +function attachPingListener(root, renderExpirationTime, thenable) { + // Attach a listener to the promise to "ping" the root and retry. But + // only if one does not already exist for the current render expiration + // time (which acts like a "thread ID" here). + var pingCache = root.pingCache; + var threadIDs; + + if (pingCache === null) { + pingCache = root.pingCache = new PossiblyWeakMap(); + threadIDs = new Set(); + pingCache.set(thenable, threadIDs); + } else { + threadIDs = pingCache.get(thenable); + + if (threadIDs === undefined) { + threadIDs = new Set(); + pingCache.set(thenable, threadIDs); + } + } + + if (!threadIDs.has(renderExpirationTime)) { + // Memoize using the thread ID to prevent redundant listeners. + threadIDs.add(renderExpirationTime); + var ping = pingSuspendedRoot.bind( + null, + root, + thenable, + renderExpirationTime + ); + thenable.then(ping, ping); + } +} + +function throwException( + root, + returnFiber, + sourceFiber, + value, + renderExpirationTime +) { + // The source fiber did not complete. + sourceFiber.effectTag |= Incomplete; // Its effect list is no longer valid. + + sourceFiber.firstEffect = sourceFiber.lastEffect = null; + + if ( + value !== null && + typeof value === "object" && + typeof value.then === "function" + ) { + // This is a thenable. + var thenable = value; + + if ((sourceFiber.mode & BlockingMode) === NoMode) { + // Reset the memoizedState to what it was before we attempted + // to render it. + var currentSource = sourceFiber.alternate; + + if (currentSource) { + sourceFiber.updateQueue = currentSource.updateQueue; + sourceFiber.memoizedState = currentSource.memoizedState; + sourceFiber.expirationTime = currentSource.expirationTime; + } else { + sourceFiber.updateQueue = null; + sourceFiber.memoizedState = null; + } + } + + var hasInvisibleParentBoundary = hasSuspenseContext( + suspenseStackCursor.current, + InvisibleParentSuspenseContext + ); // Schedule the nearest Suspense to re-render the timed out view. + + var _workInProgress = returnFiber; + + do { + if ( + _workInProgress.tag === SuspenseComponent && + shouldCaptureSuspense(_workInProgress, hasInvisibleParentBoundary) + ) { + // Found the nearest boundary. + // Stash the promise on the boundary fiber. If the boundary times out, we'll + // attach another listener to flip the boundary back to its normal state. + var thenables = _workInProgress.updateQueue; + + if (thenables === null) { + var updateQueue = new Set(); + updateQueue.add(thenable); + _workInProgress.updateQueue = updateQueue; + } else { + thenables.add(thenable); + } // If the boundary is outside of blocking 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 blocking mode tree. If the Suspense is outside of it, we + // should *not* suspend the commit. + + if ((_workInProgress.mode & BlockingMode) === NoMode) { + _workInProgress.effectTag |= DidCapture; // 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 | Incomplete); + + if (sourceFiber.tag === ClassComponent) { + var currentSourceFiber = sourceFiber.alternate; + + if (currentSourceFiber === 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; + } else { + // 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 update to + // prevent a bail out. + var update = createUpdate(Sync, null); + update.tag = ForceUpdate; + enqueueUpdate(sourceFiber, update); + } + } // The source fiber did not complete. Mark it with Sync priority to + // indicate that it still has pending work. + + sourceFiber.expirationTime = Sync; // Exit without suspending. + + return; + } // Confirmed that the boundary is in a concurrent mode tree. Continue + // with the normal suspend path. + // + // After this we'll use a set of heuristics to determine whether this + // render pass will run to completion or restart or "suspend" the commit. + // The actual logic for this is spread out in different places. + // + // This first principle is that if we're going to suspend when we complete + // a root, then we should also restart if we get an update or ping that + // might unsuspend it, and vice versa. The only reason to suspend is + // because you think you might want to restart before committing. However, + // it doesn't make sense to restart only while in the period we're suspended. + // + // Restarting too aggressively is also not good because it starves out any + // intermediate loading state. So we use heuristics to determine when. + // Suspense Heuristics + // + // If nothing threw a Promise or all the same fallbacks are already showing, + // then don't suspend/restart. + // + // If this is an initial render of a new tree of Suspense boundaries and + // those trigger a fallback, then don't suspend/restart. We want to ensure + // that we can show the initial loading state as quickly as possible. + // + // If we hit a "Delayed" case, such as when we'd switch from content back into + // a fallback, then we should always suspend/restart. SuspenseConfig applies to + // this case. If none is defined, JND is used instead. + // + // If we're already showing a fallback and it gets "retried", allowing us to show + // another level, but there's still an inner boundary that would show a fallback, + // then we suspend/restart for 500ms since the last time we showed a fallback + // anywhere in the tree. This effectively throttles progressive loading into a + // consistent train of commits. This also gives us an opportunity to restart to + // get to the completed state slightly earlier. + // + // If there's ambiguity due to batching it's resolved in preference of: + // 1) "delayed", 2) "initial render", 3) "retry". + // + // We want to ensure that a "busy" state doesn't get force committed. We want to + // ensure that new initial loading states can commit as soon as possible. + + attachPingListener(root, renderExpirationTime, thenable); + _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( + (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) + ); + } // We didn't find a boundary that could handle this type of exception. Start + // over and traverse parent path again, this time treating the exception + // as an error. + + renderDidError(); + value = createCapturedValue(value, sourceFiber); + var workInProgress = returnFiber; + + do { + switch (workInProgress.tag) { + case HostRoot: { + var _errorInfo = value; + workInProgress.effectTag |= ShouldCapture; + workInProgress.expirationTime = renderExpirationTime; + + var _update = createRootErrorUpdate( + workInProgress, + _errorInfo, + renderExpirationTime + ); + + enqueueCapturedUpdate(workInProgress, _update); + return; + } + + case ClassComponent: + // Capture and retry + var errorInfo = value; + var ctor = workInProgress.type; + var instance = workInProgress.stateNode; + + if ( + (workInProgress.effectTag & DidCapture) === NoEffect && + (typeof ctor.getDerivedStateFromError === "function" || + (instance !== null && + typeof instance.componentDidCatch === "function" && + !isAlreadyFailedLegacyErrorBoundary(instance))) + ) { + workInProgress.effectTag |= ShouldCapture; + workInProgress.expirationTime = renderExpirationTime; // Schedule the error boundary to re-render using updated state + + var _update2 = createClassErrorUpdate( + workInProgress, + errorInfo, + renderExpirationTime + ); + + enqueueCapturedUpdate(workInProgress, _update2); + return; + } + + break; + } + + workInProgress = workInProgress.return; + } while (workInProgress !== null); } var ceil = Math.ceil; -var ReactCurrentDispatcher$2 = ReactSharedInternals.ReactCurrentDispatcher, +var ReactCurrentDispatcher$1 = ReactSharedInternals.ReactCurrentDispatcher, ReactCurrentOwner$2 = ReactSharedInternals.ReactCurrentOwner, IsSomeRendererActing = ReactSharedInternals.IsSomeRendererActing; var NoContext = - /* */ + /* */ 0; var BatchedContext = /* */ @@ -17779,264 +17007,189 @@ var RenderContext = var CommitContext = /* */ 32; -var RetryAfterError = - /* */ - 64; var RootIncomplete = 0; var RootFatalErrored = 1; var RootErrored = 2; var RootSuspended = 3; var RootSuspendedWithDelay = 4; -var RootCompleted = 5; // Describes where we are in the React execution stack - +var RootCompleted = 5; +// Describes where we are in the React execution stack var executionContext = NoContext; // The root we're working on var workInProgressRoot = null; // The fiber we're working on -var workInProgress = null; // The lanes we're rendering +var workInProgress = null; // The expiration time we're rendering -var workInProgressRootRenderLanes = NoLanes; // Stack that allows components to change the render lanes for its subtree -// This is a superset of the lanes we started working on at the root. The only -// case where it's different from `workInProgressRootRenderLanes` is when we -// enter a subtree that is hidden and needs to be unhidden: Suspense and -// Offscreen component. -// -// Most things in the work loop should deal with workInProgressRootRenderLanes. -// Most things in begin/complete phases should deal with subtreeRenderLanes. - -var subtreeRenderLanes = NoLanes; -var subtreeRenderLanesCursor = createCursor(NoLanes); // Whether to root completed, errored, suspended, etc. +var renderExpirationTime$1 = NoWork; // Whether to root completed, errored, suspended, etc. var workInProgressRootExitStatus = RootIncomplete; // A fatal error, if one is thrown -var workInProgressRootFatalError = null; -var workInProgressRootLatestSuspenseTimeout = NoTimestamp; -var workInProgressRootCanSuspendUsingConfig = null; // "Included" lanes refer to lanes that were worked on during this render. It's -// slightly different than `renderLanes` because `renderLanes` can change as you -// enter and exit an Offscreen tree. This value is the combination of all render -// lanes for the entire render phase. +var workInProgressRootFatalError = null; // Most recent event time among processed updates during this render. +// This is conceptually a time stamp but expressed in terms of an ExpirationTime +// because we deal mostly with expiration times in the hot path, so this avoids +// the conversion happening in the hot path. -var workInProgressRootIncludedLanes = NoLanes; // The work left over by components that were visited during this render. Only +var workInProgressRootLatestProcessedExpirationTime = Sync; +var workInProgressRootLatestSuspenseTimeout = Sync; +var workInProgressRootCanSuspendUsingConfig = null; // The work left over by components that were visited during this render. Only // includes unprocessed updates, not work in bailed out children. -var workInProgressRootSkippedLanes = NoLanes; // Lanes that were updated (in an interleaved event) during this render. +var workInProgressRootNextUnprocessedUpdateTime = NoWork; // If we're pinged while rendering we don't always restart immediately. +// This flag determines if it might be worthwhile to restart if an opportunity +// happens latere. -var workInProgressRootUpdatedLanes = NoLanes; // Lanes that were pinged (in an interleaved event) during this render. - -var workInProgressRootPingedLanes = NoLanes; -var mostRecentlyUpdatedRoot = null; // The most recent time we committed a fallback. This lets us ensure a train +var workInProgressRootHasPendingPing = false; // The most recent time we committed a fallback. This lets us ensure a train // model where we don't commit new loading states in too quick succession. var globalMostRecentFallbackTime = 0; var FALLBACK_THROTTLE_MS = 500; -var DEFAULT_TIMEOUT_MS = 5000; var nextEffect = null; var hasUncaughtError = false; var firstUncaughtError = null; var legacyErrorBoundariesThatAlreadyFailed = null; var rootDoesHavePassiveEffects = false; var rootWithPendingPassiveEffects = null; -var pendingPassiveEffectsRenderPriority = NoPriority$1; -var pendingPassiveEffectsLanes = NoLanes; -var pendingPassiveHookEffectsMount = []; -var pendingPassiveHookEffectsUnmount = []; +var pendingPassiveEffectsRenderPriority = NoPriority; +var pendingPassiveEffectsExpirationTime = NoWork; var rootsWithPendingDiscreteUpdates = null; // Use these to prevent an infinite loop of nested updates var NESTED_UPDATE_LIMIT = 50; var nestedUpdateCount = 0; var rootWithNestedUpdates = null; var NESTED_PASSIVE_UPDATE_LIMIT = 50; -var nestedPassiveUpdateCount = 0; // Marks the need to reschedule pending interactions at these lanes +var nestedPassiveUpdateCount = 0; +var interruptedBy = null; // Marks the need to reschedule pending interactions at these expiration times // during the commit phase. This enables them to be traced across components // that spawn new work during render. E.g. hidden boundaries, suspended SSR // hydration or SuspenseList. -// TODO: Can use a bitmask instead of an array -var spawnedWorkDuringRender = null; // If two updates are scheduled within the same event, we should treat their -// event times as simultaneous, even if the actual clock time has advanced -// between the first and second call. +var spawnedWorkDuringRender = null; // Expiration times are computed by adding to the current time (the start +// time). However, if two updates are scheduled within the same event, we +// should treat their start times as simultaneous, even if the actual clock +// time has advanced between the first and second call. +// In other words, because expiration times determine how updates are batched, +// we want all updates of like priority that occur within the same event to +// receive the same expiration time. Otherwise we get tearing. -var currentEventTime = NoTimestamp; -var currentEventWipLanes = NoLanes; -var currentEventPendingLanes = NoLanes; // Dev only flag that tracks if passive effects are currently being flushed. -// We warn about state updates for unmounted components differently in this case. - -var isFlushingPassiveEffects = false; -var focusedInstanceHandle = null; -var shouldFireAfterActiveInstanceBlur = false; -function getWorkInProgressRoot() { - return workInProgressRoot; -} -function requestEventTime() { +var currentEventTime = NoWork; +function requestCurrentTimeForUpdate() { if ((executionContext & (RenderContext | CommitContext)) !== NoContext) { // We're inside React, so it's fine to read the actual time. - return now(); + return msToExpirationTime(now()); } // We're not inside React, so we may be in the middle of a browser event. - if (currentEventTime !== NoTimestamp) { + if (currentEventTime !== NoWork) { // Use the same start time for all updates until we enter React again. return currentEventTime; } // This is the first update since React yielded. Compute a new start time. - currentEventTime = now(); + currentEventTime = msToExpirationTime(now()); return currentEventTime; } -function requestUpdateLane(fiber, suspenseConfig) { - // Special cases +function getCurrentTime() { + return msToExpirationTime(now()); +} +function computeExpirationForFiber(currentTime, fiber, suspenseConfig) { var mode = fiber.mode; if ((mode & BlockingMode) === NoMode) { - return SyncLane; - } else if ((mode & ConcurrentMode) === NoMode) { - return getCurrentPriorityLevel() === ImmediatePriority$1 - ? SyncLane - : SyncBatchedLane; - } // The algorithm for assigning an update to a lane should be stable for all - // updates at the same priority within the same event. To do this, the inputs - // to the algorithm must be the same. For example, we use the `renderLanes` - // to avoid choosing a lane that is already in the middle of rendering. - // - // However, the "included" lanes could be mutated in between updates in the - // same event, like if you perform an update inside `flushSync`. Or any other - // code path that might call `prepareFreshStack`. - // - // The trick we use is to cache the first of each of these inputs within an - // event. Then reset the cached values once we can be sure the event is over. - // Our heuristic for that is whenever we enter a concurrent work loop. - // - // We'll do the same for `currentEventPendingLanes` below. - - if (currentEventWipLanes === NoLanes) { - currentEventWipLanes = workInProgressRootIncludedLanes; + return Sync; } + var priorityLevel = getCurrentPriorityLevel(); + + if ((mode & ConcurrentMode) === NoMode) { + return priorityLevel === ImmediatePriority ? Sync : Batched; + } + + if ((executionContext & RenderContext) !== NoContext) { + // Use whatever time we're already rendering + // TODO: Should there be a way to opt out, like with `runWithPriority`? + return renderExpirationTime$1; + } + + var expirationTime; + if (suspenseConfig !== null) { - // Use the size of the timeout as a heuristic to prioritize shorter - // transitions over longer ones. - // TODO: This will coerce numbers larger than 31 bits to 0. - var timeoutMs = suspenseConfig.timeoutMs; - var transitionLanePriority = - timeoutMs === undefined || (timeoutMs | 0) < 10000 - ? TransitionShortLanePriority - : TransitionLongLanePriority; - - if (currentEventPendingLanes !== NoLanes) { - currentEventPendingLanes = - mostRecentlyUpdatedRoot !== null - ? mostRecentlyUpdatedRoot.pendingLanes - : NoLanes; - } - - return findTransitionLane( - transitionLanePriority, - currentEventWipLanes, - currentEventPendingLanes + // Compute an expiration time based on the Suspense timeout. + expirationTime = computeSuspenseExpiration( + currentTime, + suspenseConfig.timeoutMs | 0 || LOW_PRIORITY_EXPIRATION ); - } // TODO: Remove this dependency on the Scheduler priority. - // To do that, we're replacing it with an update lane priority. + } else { + // Compute an expiration time based on the Scheduler priority. + switch (priorityLevel) { + case ImmediatePriority: + expirationTime = Sync; + break; - var schedulerPriority = getCurrentPriorityLevel(); // The old behavior was using the priority level of the Scheduler. - // This couples React to the Scheduler internals, so we're replacing it - // with the currentUpdateLanePriority above. As an example of how this - // could be problematic, if we're not inside `Scheduler.runWithPriority`, - // then we'll get the priority of the current running Scheduler task, - // which is probably not what we want. + case UserBlockingPriority: + // TODO: Rename this to computeUserBlockingExpiration + expirationTime = computeInteractiveExpiration(currentTime); + break; - var lane; + case NormalPriority: + case LowPriority: + // TODO: Handle LowPriority + // TODO: Rename this to... something better. + expirationTime = computeAsyncExpiration(currentTime); + break; + + case IdlePriority: + expirationTime = Idle; + break; + + default: { + throw Error("Expected a valid priority level"); + } + } + } // If we're in the middle of rendering a tree, do not update at the same + // expiration time that is already rendering. + // TODO: We shouldn't have to do this if the update is on a different root. + // Refactor computeExpirationForFiber + scheduleUpdate so we have access to + // the root when we check for this condition. if ( - // TODO: Temporary. We're removing the concept of discrete updates. - (executionContext & DiscreteEventContext) !== NoContext && - schedulerPriority === UserBlockingPriority$1 + workInProgressRoot !== null && + expirationTime === renderExpirationTime$1 ) { - lane = findUpdateLane(InputDiscreteLanePriority, currentEventWipLanes); - } else { - var schedulerLanePriority = schedulerPriorityToLanePriority( - schedulerPriority - ); - - lane = findUpdateLane(schedulerLanePriority, currentEventWipLanes); + // This is a trick to move this update into a separate batch + expirationTime -= 1; } - return lane; + return expirationTime; } - -function requestRetryLane(fiber) { - // This is a fork of `requestUpdateLane` designed specifically for Suspense - // "retries" — a special update that attempts to flip a Suspense boundary - // from its placeholder state to its primary/resolved state. - // Special cases - var mode = fiber.mode; - - if ((mode & BlockingMode) === NoMode) { - return SyncLane; - } else if ((mode & ConcurrentMode) === NoMode) { - return getCurrentPriorityLevel() === ImmediatePriority$1 - ? SyncLane - : SyncBatchedLane; - } // See `requestUpdateLane` for explanation of `currentEventWipLanes` - - if (currentEventWipLanes === NoLanes) { - currentEventWipLanes = workInProgressRootIncludedLanes; - } - - return findRetryLane(currentEventWipLanes); -} - -function scheduleUpdateOnFiber(fiber, lane, eventTime) { +function scheduleUpdateOnFiber(fiber, expirationTime) { checkForNestedUpdates(); warnAboutRenderPhaseUpdatesInDEV(fiber); - var root = markUpdateLaneFromFiberToRoot(fiber, lane); + var root = markUpdateTimeFromFiberToRoot(fiber, expirationTime); if (root === null) { warnAboutUpdateOnUnmountedFiberInDEV(fiber); - return null; - } // Mark that the root has a pending update. + return; + } - markRootUpdated(root, lane, eventTime); - - if (root === workInProgressRoot) { - // Received an update to a tree that's in the middle of rendering. Mark - // that there was an interleaved update work on this root. Unless the - // `deferRenderPhaseUpdateToNextBatch` flag is off and this is a render - // phase update. In that case, we don't treat render phase updates as if - // they were interleaved, for backwards compat reasons. - { - workInProgressRootUpdatedLanes = mergeLanes( - workInProgressRootUpdatedLanes, - lane - ); - } - - if (workInProgressRootExitStatus === RootSuspendedWithDelay) { - // The root already suspended with a delay, which means this render - // definitely won't finish. Since we have a new update, let's mark it as - // suspended now, right before marking the incoming update. This has the - // effect of interrupting the current render and switching to the update. - // TODO: Make sure this doesn't override pings that happen while we've - // already started rendering. - markRootSuspended$1(root, workInProgressRootRenderLanes); - } - } // TODO: requestUpdateLanePriority also reads the priority. Pass the + checkForInterruption(fiber, expirationTime); + recordScheduleUpdate(); // TODO: computeExpirationForFiber also reads the priority. Pass the // priority as an argument to that function and this one. var priorityLevel = getCurrentPriorityLevel(); - if (lane === SyncLane) { + if (expirationTime === Sync) { if ( // Check if we're inside unbatchedUpdates (executionContext & LegacyUnbatchedContext) !== NoContext && // Check if we're not already rendering (executionContext & (RenderContext | CommitContext)) === NoContext ) { // Register pending interactions on the root to avoid losing traced interaction data. - schedulePendingInteractions(root, lane); // This is a legacy edge case. The initial mount of a ReactDOM.render-ed + schedulePendingInteractions(root, expirationTime); // This is a legacy edge case. The initial mount of a ReactDOM.render-ed // root inside of batchedUpdates should be synchronous, but layout updates // should be deferred until the end of the batch. performSyncWorkOnRoot(root); } else { - ensureRootIsScheduled(root, eventTime); - schedulePendingInteractions(root, lane); + ensureRootIsScheduled(root); + schedulePendingInteractions(root, expirationTime); if (executionContext === NoContext) { // Flush the synchronous work now, unless we're already working or inside @@ -18048,251 +17201,281 @@ function scheduleUpdateOnFiber(fiber, lane, eventTime) { } } } else { - // Schedule a discrete update but only if it's not Sync. - if ( - (executionContext & DiscreteEventContext) !== NoContext && // Only updates at user-blocking priority or greater are considered - // discrete, even inside a discrete event. - (priorityLevel === UserBlockingPriority$1 || - priorityLevel === ImmediatePriority$1) - ) { - // This is the result of a discrete event. Track the lowest priority - // discrete update per root so we can flush them early, if needed. - if (rootsWithPendingDiscreteUpdates === null) { - rootsWithPendingDiscreteUpdates = new Set([root]); - } else { - rootsWithPendingDiscreteUpdates.add(root); + ensureRootIsScheduled(root); + schedulePendingInteractions(root, expirationTime); + } + + if ( + (executionContext & DiscreteEventContext) !== NoContext && // Only updates at user-blocking priority or greater are considered + // discrete, even inside a discrete event. + (priorityLevel === UserBlockingPriority || + priorityLevel === ImmediatePriority) + ) { + // This is the result of a discrete event. Track the lowest priority + // discrete update per root so we can flush them early, if needed. + if (rootsWithPendingDiscreteUpdates === null) { + rootsWithPendingDiscreteUpdates = new Map([[root, expirationTime]]); + } else { + var lastDiscreteTime = rootsWithPendingDiscreteUpdates.get(root); + + if (lastDiscreteTime === undefined || lastDiscreteTime > expirationTime) { + rootsWithPendingDiscreteUpdates.set(root, expirationTime); } - } // Schedule other updates after in case the callback is sync. - - ensureRootIsScheduled(root, eventTime); - schedulePendingInteractions(root, lane); - } // We use this when assigning a lane for a transition inside - // `requestUpdateLane`. We assume it's the same as the root being updated, - // since in the common case of a single root app it probably is. If it's not - // the same root, then it's not a huge deal, we just might batch more stuff - // together more than necessary. - - mostRecentlyUpdatedRoot = root; -} // This is split into a separate function so we can mark a fiber with pending + } + } +} +var scheduleWork = scheduleUpdateOnFiber; // This is split into a separate function so we can mark a fiber with pending // work without treating it as a typical update that originates from an event; // e.g. retrying a Suspense boundary isn't an update, but it does schedule work // on a fiber. -function markUpdateLaneFromFiberToRoot(sourceFiber, lane) { - // Update the source fiber's lanes - sourceFiber.lanes = mergeLanes(sourceFiber.lanes, lane); - var alternate = sourceFiber.alternate; - - if (alternate !== null) { - alternate.lanes = mergeLanes(alternate.lanes, lane); +function markUpdateTimeFromFiberToRoot(fiber, expirationTime) { + // Update the source fiber's expiration time + if (fiber.expirationTime < expirationTime) { + fiber.expirationTime = expirationTime; } - { - if ( - alternate === null && - (sourceFiber.effectTag & (Placement | Hydrating)) !== NoEffect - ) { - warnAboutUpdateOnNotYetMountedFiberInDEV(sourceFiber); - } + var alternate = fiber.alternate; + + if (alternate !== null && alternate.expirationTime < expirationTime) { + alternate.expirationTime = expirationTime; } // Walk the parent path to the root and update the child expiration time. - var node = sourceFiber; - var parent = sourceFiber.return; + var node = fiber.return; + var root = null; - while (parent !== null) { - parent.childLanes = mergeLanes(parent.childLanes, lane); - alternate = parent.alternate; - - if (alternate !== null) { - alternate.childLanes = mergeLanes(alternate.childLanes, lane); - } else { - { - if ((parent.effectTag & (Placement | Hydrating)) !== NoEffect) { - warnAboutUpdateOnNotYetMountedFiberInDEV(sourceFiber); - } - } - } - - node = parent; - parent = parent.return; - } - - if (node.tag === HostRoot) { - var root = node.stateNode; - return root; + if (node === null && fiber.tag === HostRoot) { + root = fiber.stateNode; } else { - return null; + while (node !== null) { + alternate = node.alternate; + + if (node.childExpirationTime < expirationTime) { + node.childExpirationTime = expirationTime; + + if ( + alternate !== null && + alternate.childExpirationTime < expirationTime + ) { + alternate.childExpirationTime = expirationTime; + } + } else if ( + alternate !== null && + alternate.childExpirationTime < expirationTime + ) { + alternate.childExpirationTime = expirationTime; + } + + if (node.return === null && node.tag === HostRoot) { + root = node.stateNode; + break; + } + + node = node.return; + } } + + if (root !== null) { + if (workInProgressRoot === root) { + // Received an update to a tree that's in the middle of rendering. Mark + // that's unprocessed work on this root. + markUnprocessedUpdateTime(expirationTime); + + if (workInProgressRootExitStatus === RootSuspendedWithDelay) { + // The root already suspended with a delay, which means this render + // definitely won't finish. Since we have a new update, let's mark it as + // suspended now, right before marking the incoming update. This has the + // effect of interrupting the current render and switching to the update. + // TODO: This happens to work when receiving an update during the render + // phase, because of the trick inside computeExpirationForFiber to + // subtract 1 from `renderExpirationTime` to move it into a + // separate bucket. But we should probably model it with an exception, + // using the same mechanism we use to force hydration of a subtree. + // TODO: This does not account for low pri updates that were already + // scheduled before the root started rendering. Need to track the next + // pending expiration time (perhaps by backtracking the return path) and + // then trigger a restart in the `renderDidSuspendDelayIfPossible` path. + markRootSuspendedAtTime(root, renderExpirationTime$1); + } + } // Mark that the root has a pending update. + + markRootUpdatedAtTime(root, expirationTime); + } + + return root; +} + +function getNextRootExpirationTimeToWorkOn(root) { + // Determines the next expiration time that the root should render, taking + // into account levels that may be suspended, or levels that may have + // received a ping. + var lastExpiredTime = root.lastExpiredTime; + + if (lastExpiredTime !== NoWork) { + return lastExpiredTime; + } // "Pending" refers to any update that hasn't committed yet, including if it + // suspended. The "suspended" range is therefore a subset. + + var firstPendingTime = root.firstPendingTime; + + if (!isRootSuspendedAtTime(root, firstPendingTime)) { + // The highest priority pending time is not suspended. Let's work on that. + return firstPendingTime; + } // If the first pending time is suspended, check if there's a lower priority + // pending level that we know about. Or check if we received a ping. Work + // on whichever is higher priority. + + var lastPingedTime = root.lastPingedTime; + var nextKnownPendingLevel = root.nextKnownPendingLevel; + var nextLevel = + lastPingedTime > nextKnownPendingLevel + ? lastPingedTime + : nextKnownPendingLevel; + + if (nextLevel <= Idle && firstPendingTime !== nextLevel) { + // Don't work on Idle/Never priority unless everything else is committed. + return NoWork; + } + + return nextLevel; } // Use this function to schedule a task for a root. There's only one task per -// root; if a task was already scheduled, we'll check to make sure the priority -// of the existing task is the same as the priority of the next level that the -// root has work on. This function is called on every update, and right before -// exiting a task. +// root; if a task was already scheduled, we'll check to make sure the +// expiration time of the existing task is the same as the expiration time of +// the next level that the root has work on. This function is called on every +// update, and right before exiting a task. -function ensureRootIsScheduled(root, currentTime) { - var existingCallbackNode = root.callbackNode; // Check if any lanes are being starved by other work. If so, mark them as - // expired so we know to work on those next. +function ensureRootIsScheduled(root) { + var lastExpiredTime = root.lastExpiredTime; - markStarvedLanesAsExpired(root, currentTime); // Determine the next lanes to work on, and their priority. + if (lastExpiredTime !== NoWork) { + // Special case: Expired work should flush synchronously. + root.callbackExpirationTime = Sync; + root.callbackPriority = ImmediatePriority; + root.callbackNode = scheduleSyncCallback( + performSyncWorkOnRoot.bind(null, root) + ); + return; + } - var nextLanes = getNextLanes( - root, - root === workInProgressRoot ? workInProgressRootRenderLanes : NoLanes - ); // This returns the priority level computed during the `getNextLanes` call. + var expirationTime = getNextRootExpirationTimeToWorkOn(root); + var existingCallbackNode = root.callbackNode; - var newCallbackPriority = returnNextLanesPriority(); - - if (nextLanes === NoLanes) { - // Special case: There's nothing to work on. + if (expirationTime === NoWork) { + // There's nothing to work on. if (existingCallbackNode !== null) { - cancelCallback(existingCallbackNode); root.callbackNode = null; - root.callbackPriority = NoLanePriority; + root.callbackExpirationTime = NoWork; + root.callbackPriority = NoPriority; } return; - } // Check if there's an existing task. We may be able to reuse it. + } // TODO: If this is an update, we already read the current time. Pass the + // time as an argument. + + var currentTime = requestCurrentTimeForUpdate(); + var priorityLevel = inferPriorityFromExpirationTime( + currentTime, + expirationTime + ); // If there's an existing render task, confirm it has the correct priority and + // expiration time. Otherwise, we'll cancel it and schedule a new one. if (existingCallbackNode !== null) { var existingCallbackPriority = root.callbackPriority; + var existingCallbackExpirationTime = root.callbackExpirationTime; - if (existingCallbackPriority === newCallbackPriority) { - // The priority hasn't changed. We can reuse the existing task. Exit. + if ( + // Callback must have the exact same expiration time. + existingCallbackExpirationTime === expirationTime && // Callback must have greater or equal priority. + existingCallbackPriority >= priorityLevel + ) { + // Existing callback is sufficient. return; - } // The priority changed. Cancel the existing callback. We'll schedule a new - // one below. + } // Need to schedule a new task. + // TODO: Instead of scheduling a new task, we should be able to change the + // priority of the existing one. cancelCallback(existingCallbackNode); - } // Schedule a new callback. + } - var newCallbackNode; + root.callbackExpirationTime = expirationTime; + root.callbackPriority = priorityLevel; + var callbackNode; - if (newCallbackPriority === SyncLanePriority) { - // Special case: Sync React callbacks are scheduled on a special - // internal queue - newCallbackNode = scheduleSyncCallback( - performSyncWorkOnRoot.bind(null, root) - ); - } else if (newCallbackPriority === SyncBatchedLanePriority) { - newCallbackNode = scheduleCallback( - ImmediatePriority$1, - performSyncWorkOnRoot.bind(null, root) - ); + if (expirationTime === Sync) { + // Sync React callbacks are scheduled on a special internal queue + callbackNode = scheduleSyncCallback(performSyncWorkOnRoot.bind(null, root)); } else { - var schedulerPriorityLevel = lanePriorityToSchedulerPriority( - newCallbackPriority - ); - newCallbackNode = scheduleCallback( - schedulerPriorityLevel, - performConcurrentWorkOnRoot.bind(null, root) + callbackNode = scheduleCallback( + priorityLevel, + performConcurrentWorkOnRoot.bind(null, root), // Compute a task timeout based on the expiration time. This also affects + // ordering because tasks are processed in timeout order. + { + timeout: expirationTimeToMs(expirationTime) - now() + } ); } - root.callbackPriority = newCallbackPriority; - root.callbackNode = newCallbackNode; + root.callbackNode = callbackNode; } // This is the entry point for every concurrent task, i.e. anything that // goes through Scheduler. function performConcurrentWorkOnRoot(root, didTimeout) { // Since we know we're in a React event, we can clear the current // event time. The next update will compute a new event time. - currentEventTime = NoTimestamp; - currentEventWipLanes = NoLanes; - currentEventPendingLanes = NoLanes; + currentEventTime = NoWork; // Check if the render expired. - if (!((executionContext & (RenderContext | CommitContext)) === NoContext)) { - throw Error("Should not already be working."); - } // Flush any pending passive effects before deciding which lanes to work on, - // in case they schedule additional work. + if (didTimeout) { + // The render task took too long to complete. Mark the current time as + // expired to synchronously render all expired work in a single batch. + var currentTime = requestCurrentTimeForUpdate(); + markRootExpiredAtTime(root, currentTime); // This will schedule a synchronous callback. - var originalCallbackNode = root.callbackNode; - var didFlushPassiveEffects = flushPassiveEffects(); - - if (didFlushPassiveEffects) { - // Something in the passive effect phase may have canceled the current task. - // Check if the task node for this root was changed. - if (root.callbackNode !== originalCallbackNode) { - // The current task was canceled. Exit. We don't need to call - // `ensureRootIsScheduled` because the check above implies either that - // there's a new task, or that there's no remaining work on this root. - return null; - } + ensureRootIsScheduled(root); + return null; } // Determine the next expiration time to work on, using the fields stored // on the root. - var lanes = getNextLanes( - root, - root === workInProgressRoot ? workInProgressRootRenderLanes : NoLanes - ); + var expirationTime = getNextRootExpirationTimeToWorkOn(root); - if (lanes === NoLanes) { - // Defensive coding. This is never expected to happen. - return null; - } // TODO: We only check `didTimeout` defensively, to account for a Scheduler - // bug where `shouldYield` sometimes returns `true` even if `didTimeout` is - // true, which leads to an infinite loop. Once the bug in Scheduler is - // fixed, we can remove this, since we track expiration ourselves. - - if (didTimeout) { - // Something expired. Flush synchronously until there's no expired - // work left. - markRootExpired(root, lanes); // This will schedule a synchronous callback. - - ensureRootIsScheduled(root, now()); + if (expirationTime === NoWork) { return null; } - var exitStatus = renderRootConcurrent(root, lanes); + var originalCallbackNode = root.callbackNode; - if ( - includesSomeLane( - workInProgressRootIncludedLanes, - workInProgressRootUpdatedLanes - ) - ) { - // The render included lanes that were updated during the render phase. - // For example, when unhiding a hidden tree, we include all the lanes - // that were previously skipped when the tree was hidden. That set of - // lanes is a superset of the lanes we started rendering with. - // - // So we'll throw out the current work and restart. - prepareFreshStack(root, NoLanes); - } else if (exitStatus !== RootIncomplete) { + if (!((executionContext & (RenderContext | CommitContext)) === NoContext)) { + throw Error("Should not already be working."); + } + + flushPassiveEffects(); + var exitStatus = renderRootConcurrent(root, expirationTime); + + if (exitStatus !== RootIncomplete) { if (exitStatus === RootErrored) { - executionContext |= RetryAfterError; // If an error occurred during hydration, - // discard server response and fall back to client side render. - - if (root.hydrate) { - root.hydrate = false; - clearContainer(root.containerInfo); - } // If something threw an error, try rendering one more time. We'll render - // synchronously to block concurrent data mutations, and we'll includes - // all pending updates are included. If it still fails after the second - // attempt, we'll give up and commit the resulting tree. - - lanes = getLanesToRetrySynchronouslyOnError(root); - - if (lanes !== NoLanes) { - exitStatus = renderRootSync(root, lanes); - } + // If something threw an error, try rendering one more time. We'll + // render synchronously to block concurrent data mutations, and we'll + // render at Idle (or lower) so that all pending updates are included. + // If it still fails after the second attempt, we'll give up and commit + // the resulting tree. + expirationTime = expirationTime > Idle ? Idle : expirationTime; + exitStatus = renderRootSync(root, expirationTime); } if (exitStatus === RootFatalErrored) { var fatalError = workInProgressRootFatalError; - prepareFreshStack(root, NoLanes); - markRootSuspended$1(root, lanes); - ensureRootIsScheduled(root, now()); + prepareFreshStack(root, expirationTime); + markRootSuspendedAtTime(root, expirationTime); + ensureRootIsScheduled(root); throw fatalError; } // We now have a consistent tree. The next step is either to commit it, // or, if something suspended, wait to commit it after a timeout. - var finishedWork = root.current.alternate; - root.finishedWork = finishedWork; - root.finishedLanes = lanes; - finishConcurrentRender(root, finishedWork, exitStatus, lanes); + var finishedWork = (root.finishedWork = root.current.alternate); + root.finishedExpirationTime = expirationTime; + finishConcurrentRender(root, finishedWork, exitStatus, expirationTime); } - ensureRootIsScheduled(root, now()); + ensureRootIsScheduled(root); if (root.callbackNode === originalCallbackNode) { // The task node scheduled for this root is the same one that's @@ -18303,7 +17486,12 @@ function performConcurrentWorkOnRoot(root, didTimeout) { return null; } -function finishConcurrentRender(root, finishedWork, exitStatus, lanes) { +function finishConcurrentRender( + root, + finishedWork, + exitStatus, + expirationTime +) { switch (exitStatus) { case RootIncomplete: case RootFatalErrored: { @@ -18323,35 +17511,61 @@ function finishConcurrentRender(root, finishedWork, exitStatus, lanes) { } case RootSuspended: { - markRootSuspended$1(root, lanes); // We have an acceptable loading state. We need to figure out if we + markRootSuspendedAtTime(root, expirationTime); + var lastSuspendedTime = root.lastSuspendedTime; + + if (expirationTime === lastSuspendedTime) { + root.nextKnownPendingLevel = getRemainingExpirationTime(finishedWork); + } // We have an acceptable loading state. We need to figure out if we // should immediately commit it or wait a bit. + // If we have processed new updates during this render, we may now + // have a new loading state ready. We want to ensure that we commit + // that as soon as possible. + + var hasNotProcessedNewUpdates = + workInProgressRootLatestProcessedExpirationTime === Sync; if ( - includesOnlyRetries(lanes) && // do not delay if we're inside an act() scope - !shouldForceFlushFallbacksInDEV() + hasNotProcessedNewUpdates && // do not delay if we're inside an act() scope + !IsThisRendererActing.current ) { - // This render only included retries, no updates. Throttle committing - // retries so that we don't show too many loading states too quickly. + // If we have not processed any new updates during this pass, then + // this is either a retry of an existing fallback state or a + // hidden tree. Hidden trees shouldn't be batched with other work + // and after that's fixed it can only be a retry. We're going to + // throttle committing retries so that we don't show too many + // loading states too quickly. var msUntilTimeout = globalMostRecentFallbackTime + FALLBACK_THROTTLE_MS - now(); // Don't bother with a very short suspense time. if (msUntilTimeout > 10) { - var nextLanes = getNextLanes(root, NoLanes); + if (workInProgressRootHasPendingPing) { + var lastPingedTime = root.lastPingedTime; - if (nextLanes !== NoLanes) { + if (lastPingedTime === NoWork || lastPingedTime >= expirationTime) { + // This render was pinged but we didn't get to restart + // earlier so try restarting now instead. + root.lastPingedTime = expirationTime; + prepareFreshStack(root, expirationTime); + break; + } + } + + var nextTime = getNextRootExpirationTimeToWorkOn(root); + + if (nextTime !== NoWork && nextTime !== expirationTime) { // There's additional work on this root. break; } - var suspendedLanes = root.suspendedLanes; - - if (!isSubsetOfLanes(suspendedLanes, lanes)) { + if ( + lastSuspendedTime !== NoWork && + lastSuspendedTime !== expirationTime + ) { // We should prefer to render the fallback of at the last // suspended level. Ping the last suspended level to try // rendering it again. - // FIXME: What if the suspended lanes are Idle? Should not restart. - var eventTime = requestEventTime(); - markRootPinged(root, suspendedLanes); + root.lastPingedTime = lastSuspendedTime; break; } // The render is suspended, it hasn't timed out, and there's no // lower priority work to do. Instead of committing the fallback @@ -18370,53 +17584,81 @@ function finishConcurrentRender(root, finishedWork, exitStatus, lanes) { } case RootSuspendedWithDelay: { - markRootSuspended$1(root, lanes); + markRootSuspendedAtTime(root, expirationTime); + var _lastSuspendedTime = root.lastSuspendedTime; - if ( - // do not delay if we're inside an act() scope - !shouldForceFlushFallbacksInDEV() - ) { + if (expirationTime === _lastSuspendedTime) { + root.nextKnownPendingLevel = getRemainingExpirationTime(finishedWork); + } + + { // We're suspended in a state that should be avoided. We'll try to // avoid committing it for as long as the timeouts let us. - var _nextLanes = getNextLanes(root, NoLanes); + if (workInProgressRootHasPendingPing) { + var _lastPingedTime = root.lastPingedTime; - if (_nextLanes !== NoLanes) { + if (_lastPingedTime === NoWork || _lastPingedTime >= expirationTime) { + // This render was pinged but we didn't get to restart earlier + // so try restarting now instead. + root.lastPingedTime = expirationTime; + prepareFreshStack(root, expirationTime); + break; + } + } + + var _nextTime = getNextRootExpirationTimeToWorkOn(root); + + if (_nextTime !== NoWork && _nextTime !== expirationTime) { // There's additional work on this root. break; } - var _suspendedLanes = root.suspendedLanes; - - if (!isSubsetOfLanes(_suspendedLanes, lanes)) { + if ( + _lastSuspendedTime !== NoWork && + _lastSuspendedTime !== expirationTime + ) { // We should prefer to render the fallback of at the last // suspended level. Ping the last suspended level to try // rendering it again. - // FIXME: What if the suspended lanes are Idle? Should not restart. - var _eventTime = requestEventTime(); - - markRootPinged(root, _suspendedLanes); + root.lastPingedTime = _lastSuspendedTime; break; } - var mostRecentEventTime = getMostRecentEventTime(root, lanes); - var _msUntilTimeout; - if (workInProgressRootLatestSuspenseTimeout !== NoTimestamp) { + if (workInProgressRootLatestSuspenseTimeout !== Sync) { // We have processed a suspense config whose expiration time we // can use as the timeout. - _msUntilTimeout = workInProgressRootLatestSuspenseTimeout - now(); - } else if (mostRecentEventTime === NoTimestamp) { + _msUntilTimeout = + expirationTimeToMs(workInProgressRootLatestSuspenseTimeout) - now(); + } else if (workInProgressRootLatestProcessedExpirationTime === Sync) { // This should never normally happen because only new updates // cause delayed states, so we should have processed something. // However, this could also happen in an offscreen tree. _msUntilTimeout = 0; } else { - // If we didn't process a suspense config, compute a JND based on - // the amount of time elapsed since the most recent event time. - var eventTimeMs = mostRecentEventTime; - var timeElapsedMs = now() - eventTimeMs; - _msUntilTimeout = jnd(timeElapsedMs) - timeElapsedMs; + // If we don't have a suspense config, we're going to use a + // heuristic to determine how long we can suspend. + var eventTimeMs = inferTimeFromExpirationTime( + workInProgressRootLatestProcessedExpirationTime + ); + var currentTimeMs = now(); + var timeUntilExpirationMs = + expirationTimeToMs(expirationTime) - currentTimeMs; + var timeElapsed = currentTimeMs - eventTimeMs; + + if (timeElapsed < 0) { + // We get this wrong some time since we estimate the time. + timeElapsed = 0; + } + + _msUntilTimeout = jnd(timeElapsed) - timeElapsed; // Clamp the timeout to the expiration time. TODO: Once the + // event time is exact instead of inferred from expiration time + // we don't need this. + + if (timeUntilExpirationMs < _msUntilTimeout) { + _msUntilTimeout = timeUntilExpirationMs; + } } // Don't bother with a very short suspense time. if (_msUntilTimeout > 10) { @@ -18437,12 +17679,9 @@ function finishConcurrentRender(root, finishedWork, exitStatus, lanes) { case RootCompleted: { // The work completed. Ready to commit. - var _mostRecentEventTime = getMostRecentEventTime(root, lanes); - if ( // do not delay if we're inside an act() scope - !shouldForceFlushFallbacksInDEV() && - _mostRecentEventTime !== NoTimestamp && + workInProgressRootLatestProcessedExpirationTime !== Sync && workInProgressRootCanSuspendUsingConfig !== null ) { // If we have exceeded the minimum loading delay, which probably @@ -18450,12 +17689,13 @@ function finishConcurrentRender(root, finishedWork, exitStatus, lanes) { // a bit longer to ensure that the spinner is shown for // enough time. var _msUntilTimeout2 = computeMsUntilSuspenseLoadingDelay( - _mostRecentEventTime, + workInProgressRootLatestProcessedExpirationTime, + expirationTime, workInProgressRootCanSuspendUsingConfig ); if (_msUntilTimeout2 > 10) { - markRootSuspended$1(root, lanes); + markRootSuspendedAtTime(root, expirationTime); root.timeoutHandle = scheduleTimeout( commitRoot.bind(null, root), _msUntilTimeout2 @@ -18474,16 +17714,6 @@ function finishConcurrentRender(root, finishedWork, exitStatus, lanes) { } } } -} - -function markRootSuspended$1(root, suspendedLanes) { - // When suspending, we should always exclude lanes that were pinged or (more - // rarely, since we try to avoid it) updated during the render phase. - // TODO: Lol maybe there's a better way to factor this besides this - // obnoxiously named function :) - suspendedLanes = removeLanes(suspendedLanes, workInProgressRootPingedLanes); - suspendedLanes = removeLanes(suspendedLanes, workInProgressRootUpdatedLanes); - markRootSuspended(root, suspendedLanes); } // This is the entry point for synchronous tasks that don't go // through Scheduler @@ -18493,77 +17723,61 @@ function performSyncWorkOnRoot(root) { } flushPassiveEffects(); - var lanes; - var exitStatus; - - if ( - root === workInProgressRoot && - includesSomeLane(root.expiredLanes, workInProgressRootRenderLanes) - ) { - // There's a partial tree, and at least one of its lanes has expired. Finish - // rendering it before rendering the rest of the expired work. - lanes = workInProgressRootRenderLanes; - exitStatus = renderRootSync(root, lanes); + var lastExpiredTime = root.lastExpiredTime; + var expirationTime; + if (lastExpiredTime !== NoWork) { + // There's expired work on this root. Check if we have a partial tree + // that we can reuse. if ( - includesSomeLane( - workInProgressRootIncludedLanes, - workInProgressRootUpdatedLanes - ) + root === workInProgressRoot && + renderExpirationTime$1 >= lastExpiredTime ) { - // The render included lanes that were updated during the render phase. - // For example, when unhiding a hidden tree, we include all the lanes - // that were previously skipped when the tree was hidden. That set of - // lanes is a superset of the lanes we started rendering with. - // - // Note that this only happens when part of the tree is rendered - // concurrently. If the whole tree is rendered synchronously, then there - // are no interleaved events. - lanes = getNextLanes(root, lanes); - exitStatus = renderRootSync(root, lanes); + // There's a partial tree with equal or greater than priority than the + // expired level. Finish rendering it before rendering the rest of the + // expired work. + expirationTime = renderExpirationTime$1; + } else { + // Start a fresh tree. + expirationTime = lastExpiredTime; } } else { - lanes = getNextLanes(root, NoLanes); - exitStatus = renderRootSync(root, lanes); + // There's no expired work. This must be a new, synchronous render. + expirationTime = Sync; } + var exitStatus = renderRootSync(root, expirationTime); + if (root.tag !== LegacyRoot && exitStatus === RootErrored) { - executionContext |= RetryAfterError; // If an error occurred during hydration, - // discard server response and fall back to client side render. - - if (root.hydrate) { - root.hydrate = false; - clearContainer(root.containerInfo); - } // If something threw an error, try rendering one more time. We'll render - // synchronously to block concurrent data mutations, and we'll includes - // all pending updates are included. If it still fails after the second - // attempt, we'll give up and commit the resulting tree. - - lanes = getLanesToRetrySynchronouslyOnError(root); - - if (lanes !== NoLanes) { - exitStatus = renderRootSync(root, lanes); - } + // If something threw an error, try rendering one more time. We'll + // render synchronously to block concurrent data mutations, and we'll + // render at Idle (or lower) so that all pending updates are included. + // If it still fails after the second attempt, we'll give up and commit + // the resulting tree. + expirationTime = expirationTime > Idle ? Idle : expirationTime; + exitStatus = renderRootSync(root, expirationTime); } if (exitStatus === RootFatalErrored) { var fatalError = workInProgressRootFatalError; - prepareFreshStack(root, NoLanes); - markRootSuspended$1(root, lanes); - ensureRootIsScheduled(root, now()); + prepareFreshStack(root, expirationTime); + markRootSuspendedAtTime(root, expirationTime); + ensureRootIsScheduled(root); throw fatalError; } // We now have a consistent tree. Because this is a sync render, we // will commit it even if something suspended. - var finishedWork = root.current.alternate; - root.finishedWork = finishedWork; - root.finishedLanes = lanes; + root.finishedWork = root.current.alternate; + root.finishedExpirationTime = expirationTime; commitRoot(root); // Before exiting, make sure there's a callback scheduled for the next // pending level. - ensureRootIsScheduled(root, now()); + ensureRootIsScheduled(root); return null; } +function syncUpdates(fn, a, b, c) { + return runWithPriority(ImmediatePriority, fn.bind(null, a, b, c)); +} function batchedUpdates$1(fn, a) { var prevExecutionContext = executionContext; @@ -18581,30 +17795,19 @@ function batchedUpdates$1(fn, a) { } } function flushSync(fn, a) { - var prevExecutionContext = executionContext; - - if ((prevExecutionContext & (RenderContext | CommitContext)) !== NoContext) { + if ((executionContext & (RenderContext | CommitContext)) !== NoContext) { { - error( - "flushSync was called from inside a lifecycle method. React cannot " + - "flush when React is already rendering. Consider moving this call to " + - "a scheduler task or micro task." + throw Error( + "flushSync was called from inside a lifecycle method. It cannot be called when React is already rendering." ); } - - return fn(a); } + var prevExecutionContext = executionContext; executionContext |= BatchedContext; try { - setCurrentUpdateLanePriority(SyncLanePriority); - - if (fn) { - return runWithPriority(ImmediatePriority$1, fn.bind(null, a)); - } else { - return undefined; - } + return runWithPriority(ImmediatePriority, fn.bind(null, a)); } finally { executionContext = prevExecutionContext; // Flush the immediate callbacks that were scheduled during this batch. // Note that this will happen even if batchedUpdates is higher up @@ -18613,22 +17816,10 @@ function flushSync(fn, a) { flushSyncCallbackQueue(); } } -function pushRenderLanes(fiber, lanes) { - push(subtreeRenderLanesCursor, subtreeRenderLanes, fiber); - subtreeRenderLanes = mergeLanes(subtreeRenderLanes, lanes); - workInProgressRootIncludedLanes = mergeLanes( - workInProgressRootIncludedLanes, - lanes - ); -} -function popRenderLanes(fiber) { - subtreeRenderLanes = subtreeRenderLanesCursor.current; - pop(subtreeRenderLanesCursor, fiber); -} -function prepareFreshStack(root, lanes) { +function prepareFreshStack(root, expirationTime) { root.finishedWork = null; - root.finishedLanes = NoLanes; + root.finishedExpirationTime = NoWork; var timeoutHandle = root.timeoutHandle; if (timeoutHandle !== noTimeout) { @@ -18650,14 +17841,14 @@ function prepareFreshStack(root, lanes) { workInProgressRoot = root; workInProgress = createWorkInProgress(root.current, null); - workInProgressRootRenderLanes = subtreeRenderLanes = workInProgressRootIncludedLanes = lanes; + renderExpirationTime$1 = expirationTime; workInProgressRootExitStatus = RootIncomplete; workInProgressRootFatalError = null; - workInProgressRootLatestSuspenseTimeout = NoTimestamp; + workInProgressRootLatestProcessedExpirationTime = Sync; + workInProgressRootLatestSuspenseTimeout = Sync; workInProgressRootCanSuspendUsingConfig = null; - workInProgressRootSkippedLanes = NoLanes; - workInProgressRootUpdatedLanes = NoLanes; - workInProgressRootPingedLanes = NoLanes; + workInProgressRootNextUnprocessedUpdateTime = NoWork; + workInProgressRootHasPendingPing = false; { spawnedWorkDuringRender = null; @@ -18670,18 +17861,13 @@ function prepareFreshStack(root, lanes) { function handleError(root, thrownValue) { do { - var erroredWork = workInProgress; - try { // Reset module-level state that was set during the render phase. resetContextDependencies(); resetHooksAfterThrow(); - resetCurrentFiber(); // TODO: I found and added this missing line while investigating a - // separate issue. Write a regression test using string refs. + resetCurrentFiber(); - ReactCurrentOwner$2.current = null; - - if (erroredWork === null || erroredWork.return === null) { + if (workInProgress === null || workInProgress.return === null) { // Expected to be working on a non-root fiber. This is a fatal error // because there's no ancestor that can handle it; the root is // supposed to capture all errors that weren't caught by an error @@ -18691,41 +17877,31 @@ function handleError(root, thrownValue) { // sibling, or the parent if there are no siblings. But since the root // has no siblings nor a parent, we set it to null. Usually this is // handled by `completeUnitOfWork` or `unwindWork`, but since we're - // intentionally not calling those, we need set it here. + // interntionally not calling those, we need set it here. // TODO: Consider calling `unwindWork` to pop the contexts. workInProgress = null; - return; + return null; } - if (enableProfilerTimer && erroredWork.mode & ProfileMode) { + if (enableProfilerTimer && workInProgress.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(erroredWork, true); + stopProfilerTimerIfRunningAndRecordDelta(workInProgress, true); } throwException( root, - erroredWork.return, - erroredWork, + workInProgress.return, + workInProgress, thrownValue, - workInProgressRootRenderLanes + renderExpirationTime$1 ); - completeUnitOfWork(erroredWork); + workInProgress = completeUnitOfWork(workInProgress); } catch (yetAnotherThrownValue) { // Something in the return path also threw. thrownValue = yetAnotherThrownValue; - - if (workInProgress === erroredWork && erroredWork !== null) { - // If this boundary has already errored, then we had trouble processing - // the error. Bubble it to the next boundary. - erroredWork = erroredWork.return; - workInProgress = erroredWork; - } else { - erroredWork = workInProgress; - } - continue; } // Return to the normal work loop. @@ -18734,8 +17910,8 @@ function handleError(root, thrownValue) { } function pushDispatcher(root) { - var prevDispatcher = ReactCurrentDispatcher$2.current; - ReactCurrentDispatcher$2.current = ContextOnlyDispatcher; + var prevDispatcher = ReactCurrentDispatcher$1.current; + ReactCurrentDispatcher$1.current = ContextOnlyDispatcher; if (prevDispatcher === null) { // The React isomorphic package does not include a default dispatcher. @@ -18748,7 +17924,7 @@ function pushDispatcher(root) { } function popDispatcher(prevDispatcher) { - ReactCurrentDispatcher$2.current = prevDispatcher; + ReactCurrentDispatcher$1.current = prevDispatcher; } function pushInteractions(root) { @@ -18768,32 +17944,29 @@ function popInteractions(prevInteractions) { function markCommitTimeOfFallback() { globalMostRecentFallbackTime = now(); } -function markRenderEventTimeAndConfig(eventTime, suspenseConfig) { - // Track the largest/latest timeout deadline in this batch. - // TODO: If there are two transitions in the same batch, shouldn't we - // choose the smaller one? Maybe this is because when an intermediate - // transition is superseded, we should ignore its suspense config, but - // we don't currently. +function markRenderEventTimeAndConfig(expirationTime, suspenseConfig) { + if ( + expirationTime < workInProgressRootLatestProcessedExpirationTime && + expirationTime > Idle + ) { + workInProgressRootLatestProcessedExpirationTime = expirationTime; + } + if (suspenseConfig !== null) { - // If `timeoutMs` is not specified, we default to 5 seconds. We have to - // resolve this default here because `suspenseConfig` is owned - // by userspace. - // TODO: Store this on the root instead (transition -> timeoutMs) - // TODO: Should this default to a JND instead? - var timeoutMs = suspenseConfig.timeoutMs | 0 || DEFAULT_TIMEOUT_MS; - var timeoutTime = eventTime + timeoutMs; + if ( + expirationTime < workInProgressRootLatestSuspenseTimeout && + expirationTime > Idle + ) { + workInProgressRootLatestSuspenseTimeout = expirationTime; // Most of the time we only have one config and getting wrong is not bad. - if (timeoutTime > workInProgressRootLatestSuspenseTimeout) { - workInProgressRootLatestSuspenseTimeout = timeoutTime; workInProgressRootCanSuspendUsingConfig = suspenseConfig; } } } -function markSkippedUpdateLanes(lane) { - workInProgressRootSkippedLanes = mergeLanes( - lane, - workInProgressRootSkippedLanes - ); +function markUnprocessedUpdateTime(expirationTime) { + if (expirationTime > workInProgressRootNextUnprocessedUpdateTime) { + workInProgressRootNextUnprocessedUpdateTime = expirationTime; + } } function renderDidSuspend() { if (workInProgressRootExitStatus === RootIncomplete) { @@ -18806,22 +17979,21 @@ function renderDidSuspendDelayIfPossible() { workInProgressRootExitStatus === RootSuspended ) { workInProgressRootExitStatus = RootSuspendedWithDelay; - } // Check if there are updates that we skipped tree that might have unblocked - // this render. + } // Check if there's a lower priority update somewhere else in the tree. if ( - workInProgressRoot !== null && - (includesNonIdleWork(workInProgressRootSkippedLanes) || - includesNonIdleWork(workInProgressRootUpdatedLanes)) + workInProgressRootNextUnprocessedUpdateTime !== NoWork && + workInProgressRoot !== null ) { - // Mark the current render as suspended so that we switch to working on - // the updates that were skipped. Usually we only suspend at the end of - // the render phase. - // TODO: We should probably always mark the root as suspended immediately - // (inside this function), since by suspending at the end of the render - // phase introduces a potential mistake where we suspend lanes that were - // pinged or updated while we were rendering. - markRootSuspended$1(workInProgressRoot, workInProgressRootRenderLanes); + // Mark the current render as suspended, and then mark that there's a + // pending update. + // TODO: This should immediately interrupt the current render, instead + // of waiting until the next time we yield. + markRootSuspendedAtTime(workInProgressRoot, renderExpirationTime$1); + markRootUpdatedAtTime( + workInProgressRoot, + workInProgressRootNextUnprocessedUpdateTime + ); } } function renderDidError() { @@ -18837,18 +18009,43 @@ function renderHasNotSuspendedYet() { return workInProgressRootExitStatus === RootIncomplete; } -function renderRootSync(root, lanes) { +function inferTimeFromExpirationTime(expirationTime) { + // We don't know exactly when the update was scheduled, but we can infer an + // approximate start time from the expiration time. + var earliestExpirationTimeMs = expirationTimeToMs(expirationTime); + return earliestExpirationTimeMs - LOW_PRIORITY_EXPIRATION; +} + +function inferTimeFromExpirationTimeWithSuspenseConfig( + expirationTime, + suspenseConfig +) { + // We don't know exactly when the update was scheduled, but we can infer an + // approximate start time from the expiration time by subtracting the timeout + // that was added to the event time. + var earliestExpirationTimeMs = expirationTimeToMs(expirationTime); + return ( + earliestExpirationTimeMs - + (suspenseConfig.timeoutMs | 0 || LOW_PRIORITY_EXPIRATION) + ); +} + +function renderRootSync(root, expirationTime) { var prevExecutionContext = executionContext; executionContext |= RenderContext; - var prevDispatcher = pushDispatcher(); // If the root or lanes have changed, throw out the existing stack + var prevDispatcher = pushDispatcher(); // If the root or expiration time have changed, throw out the existing stack // and prepare a fresh one. Otherwise we'll continue where we left off. - if (workInProgressRoot !== root || workInProgressRootRenderLanes !== lanes) { - prepareFreshStack(root, lanes); - startWorkOnPendingInteractions(root, lanes); + if ( + root !== workInProgressRoot || + expirationTime !== renderExpirationTime$1 + ) { + prepareFreshStack(root, expirationTime); + startWorkOnPendingInteractions(root, expirationTime); } var prevInteractions = pushInteractions(root); + startWorkLoopTimer(workInProgress); do { try { @@ -18877,8 +18074,9 @@ function renderRootSync(root, lanes) { } } + stopFinishedWorkLoopTimer(); // Set this to null to indicate there's no in-progress render. + workInProgressRoot = null; - workInProgressRootRenderLanes = NoLanes; return workInProgressRootExitStatus; } // The work loop is an extremely hot path. Tell Closure not to inline it. @@ -18887,22 +18085,26 @@ function renderRootSync(root, lanes) { function workLoopSync() { // Already timed out, so perform work without checking if we need to yield. while (workInProgress !== null) { - performUnitOfWork(workInProgress); + workInProgress = performUnitOfWork(workInProgress); } } -function renderRootConcurrent(root, lanes) { +function renderRootConcurrent(root, expirationTime) { var prevExecutionContext = executionContext; executionContext |= RenderContext; - var prevDispatcher = pushDispatcher(); // If the root or lanes have changed, throw out the existing stack + var prevDispatcher = pushDispatcher(); // If the root or expiration time have changed, throw out the existing stack // and prepare a fresh one. Otherwise we'll continue where we left off. - if (workInProgressRoot !== root || workInProgressRootRenderLanes !== lanes) { - prepareFreshStack(root, lanes); - startWorkOnPendingInteractions(root, lanes); + if ( + root !== workInProgressRoot || + expirationTime !== renderExpirationTime$1 + ) { + prepareFreshStack(root, expirationTime); + startWorkOnPendingInteractions(root, expirationTime); } var prevInteractions = pushInteractions(root); + startWorkLoopTimer(workInProgress); do { try { @@ -18920,13 +18122,17 @@ function renderRootConcurrent(root, lanes) { } popDispatcher(prevDispatcher); - executionContext = prevExecutionContext; + executionContext = prevExecutionContext; // Check if the tree has completed. if (workInProgress !== null) { + // Still work remaining. + stopInterruptedWorkLoopTimer(); return RootIncomplete; } else { - workInProgressRoot = null; - workInProgressRootRenderLanes = NoLanes; // Return the final exit status. + // Completed the tree. + stopFinishedWorkLoopTimer(); // Set this to null to indicate there's no in-progress render. + + workInProgressRoot = null; // Return the final exit status. return workInProgressRootExitStatus; } @@ -18936,7 +18142,7 @@ function renderRootConcurrent(root, lanes) { function workLoopConcurrent() { // Perform work until Scheduler asks us to yield while (workInProgress !== null && !shouldYield()) { - performUnitOfWork(workInProgress); + workInProgress = performUnitOfWork(workInProgress); } } @@ -18945,15 +18151,16 @@ function performUnitOfWork(unitOfWork) { // nothing should rely on this, but relying on it here means that we don't // need an additional field on the work in progress. var current = unitOfWork.alternate; + startWorkTimer(unitOfWork); setCurrentFiber(unitOfWork); var next; if ((unitOfWork.mode & ProfileMode) !== NoMode) { startProfilerTimer(unitOfWork); - next = beginWork$1(current, unitOfWork, subtreeRenderLanes); + next = beginWork$1(current, unitOfWork, renderExpirationTime$1); stopProfilerTimerIfRunningAndRecordDelta(unitOfWork, true); } else { - next = beginWork$1(current, unitOfWork, subtreeRenderLanes); + next = beginWork$1(current, unitOfWork, renderExpirationTime$1); } resetCurrentFiber(); @@ -18961,49 +18168,47 @@ function performUnitOfWork(unitOfWork) { if (next === null) { // If this doesn't spawn new work, complete the current work. - completeUnitOfWork(unitOfWork); - } else { - workInProgress = next; + next = completeUnitOfWork(unitOfWork); } ReactCurrentOwner$2.current = null; + return next; } function completeUnitOfWork(unitOfWork) { // Attempt to complete the current unit of work, then move to the next // sibling. If there are no more siblings, return to the parent fiber. - var completedWork = unitOfWork; + workInProgress = unitOfWork; do { // The current, flushed, state of this fiber is the alternate. Ideally // nothing should rely on this, but relying on it here means that we don't // need an additional field on the work in progress. - var current = completedWork.alternate; - var returnFiber = completedWork.return; // Check if the work completed or if something threw. + var current = workInProgress.alternate; + var returnFiber = workInProgress.return; // Check if the work completed or if something threw. - if ((completedWork.effectTag & Incomplete) === NoEffect) { - setCurrentFiber(completedWork); + if ((workInProgress.effectTag & Incomplete) === NoEffect) { + setCurrentFiber(workInProgress); var next = void 0; - if ((completedWork.mode & ProfileMode) === NoMode) { - next = completeWork(current, completedWork, subtreeRenderLanes); + if ((workInProgress.mode & ProfileMode) === NoMode) { + next = completeWork(current, workInProgress, renderExpirationTime$1); } else { - startProfilerTimer(completedWork); - next = completeWork(current, completedWork, subtreeRenderLanes); // Update render duration assuming we didn't error. + startProfilerTimer(workInProgress); + next = completeWork(current, workInProgress, renderExpirationTime$1); // Update render duration assuming we didn't error. - stopProfilerTimerIfRunningAndRecordDelta(completedWork, false); + stopProfilerTimerIfRunningAndRecordDelta(workInProgress, false); } + stopWorkTimer(workInProgress); resetCurrentFiber(); + resetChildExpirationTime(workInProgress); if (next !== null) { // Completing this fiber spawned new work. Work on that next. - workInProgress = next; - return; + return next; } - resetChildLanes(completedWork); - if ( returnFiber !== null && // Do not append effects to parents if a sibling failed to complete (returnFiber.effectTag & Incomplete) === NoEffect @@ -19012,15 +18217,15 @@ function completeUnitOfWork(unitOfWork) { // list of the parent. The completion order of the children affects the // side-effect order. if (returnFiber.firstEffect === null) { - returnFiber.firstEffect = completedWork.firstEffect; + returnFiber.firstEffect = workInProgress.firstEffect; } - if (completedWork.lastEffect !== null) { + if (workInProgress.lastEffect !== null) { if (returnFiber.lastEffect !== null) { - returnFiber.lastEffect.nextEffect = completedWork.firstEffect; + returnFiber.lastEffect.nextEffect = workInProgress.firstEffect; } - returnFiber.lastEffect = completedWork.lastEffect; + returnFiber.lastEffect = workInProgress.lastEffect; } // If this fiber had side-effects, we append it AFTER the children's // side-effects. We can perform certain side-effects earlier if needed, // by doing multiple passes over the effect list. We don't want to @@ -19028,51 +18233,55 @@ function completeUnitOfWork(unitOfWork) { // reusing children we'll schedule this effect onto itself since we're // at the end. - var effectTag = completedWork.effectTag; // Skip both NoWork and PerformedWork tags when creating the effect + var effectTag = workInProgress.effectTag; // Skip both NoWork and PerformedWork tags when creating the effect // list. PerformedWork effect is read by React DevTools but shouldn't be // committed. if (effectTag > PerformedWork) { if (returnFiber.lastEffect !== null) { - returnFiber.lastEffect.nextEffect = completedWork; + returnFiber.lastEffect.nextEffect = workInProgress; } else { - returnFiber.firstEffect = completedWork; + returnFiber.firstEffect = workInProgress; } - returnFiber.lastEffect = completedWork; + returnFiber.lastEffect = workInProgress; } } } else { // This fiber did not complete because something threw. Pop values off // the stack without entering the complete phase. If this is a boundary, // capture values if possible. - var _next = unwindWork(completedWork); // Because this fiber did not complete, don't reset its expiration time. + var _next = unwindWork(workInProgress); // Because this fiber did not complete, don't reset its expiration time. - if (_next !== null) { - // 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 - // from the effect tag. - _next.effectTag &= HostEffectMask; - workInProgress = _next; - return; - } - - if ((completedWork.mode & ProfileMode) !== NoMode) { + if ((workInProgress.mode & ProfileMode) !== NoMode) { // Record the render duration for the fiber that errored. - stopProfilerTimerIfRunningAndRecordDelta(completedWork, false); // Include the time spent working on failed children before continuing. + stopProfilerTimerIfRunningAndRecordDelta(workInProgress, false); // Include the time spent working on failed children before continuing. - var actualDuration = completedWork.actualDuration; - var child = completedWork.child; + var actualDuration = workInProgress.actualDuration; + var child = workInProgress.child; while (child !== null) { actualDuration += child.actualDuration; child = child.sibling; } - completedWork.actualDuration = actualDuration; + workInProgress.actualDuration = actualDuration; } + if (_next !== null) { + // 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 + // from the effect tag. + // TODO: The name stopFailedWorkTimer is misleading because Suspense + // also captures and restarts. + stopFailedWorkTimer(workInProgress); + _next.effectTag &= HostEffectMask; + return _next; + } + + stopWorkTimer(workInProgress); + if (returnFiber !== null) { // Mark the parent fiber as incomplete and clear its effect list. returnFiber.firstEffect = returnFiber.lastEffect = null; @@ -19080,40 +18289,42 @@ function completeUnitOfWork(unitOfWork) { } } - var siblingFiber = completedWork.sibling; + var siblingFiber = workInProgress.sibling; if (siblingFiber !== null) { // If there is more work to do in this returnFiber, do that next. - workInProgress = siblingFiber; - return; + return siblingFiber; } // Otherwise, return to the parent - completedWork = returnFiber; // Update the next thing we're working on in case something throws. - - workInProgress = completedWork; - } while (completedWork !== null); // We've reached the root. + workInProgress = returnFiber; + } while (workInProgress !== null); // We've reached the root. if (workInProgressRootExitStatus === RootIncomplete) { workInProgressRootExitStatus = RootCompleted; } + + return null; } -function resetChildLanes(completedWork) { +function getRemainingExpirationTime(fiber) { + var updateExpirationTime = fiber.expirationTime; + var childExpirationTime = fiber.childExpirationTime; + return updateExpirationTime > childExpirationTime + ? updateExpirationTime + : childExpirationTime; +} + +function resetChildExpirationTime(completedWork) { if ( - // TODO: Move this check out of the hot path by moving `resetChildLanes` - // to switch statement in `completeWork`. - (completedWork.tag === LegacyHiddenComponent || - completedWork.tag === OffscreenComponent) && - completedWork.memoizedState !== null && - !includesSomeLane(subtreeRenderLanes, OffscreenLane) && - (completedWork.mode & ConcurrentMode) !== NoLanes + renderExpirationTime$1 !== Never && + completedWork.childExpirationTime === Never ) { // The children of this component are hidden. Don't bubble their // expiration times. return; } - var newChildLanes = NoLanes; // Bubble up the earliest expiration time. + var newChildExpirationTime = NoWork; // Bubble up the earliest expiration time. if ((completedWork.mode & ProfileMode) !== NoMode) { // In profiling mode, resetChildExpirationTime is also used to reset @@ -19133,10 +18344,16 @@ function resetChildLanes(completedWork) { var child = completedWork.child; while (child !== null) { - newChildLanes = mergeLanes( - newChildLanes, - mergeLanes(child.lanes, child.childLanes) - ); + var childUpdateExpirationTime = child.expirationTime; + var childChildExpirationTime = child.childExpirationTime; + + if (childUpdateExpirationTime > newChildExpirationTime) { + newChildExpirationTime = childUpdateExpirationTime; + } + + if (childChildExpirationTime > newChildExpirationTime) { + newChildExpirationTime = childChildExpirationTime; + } if (shouldBubbleActualDurations) { actualDuration += child.actualDuration; @@ -19146,40 +18363,34 @@ function resetChildLanes(completedWork) { child = child.sibling; } - var isTimedOutSuspense = - completedWork.tag === SuspenseComponent && - completedWork.memoizedState !== null; - - if (isTimedOutSuspense) { - // Don't count time spent in a timed out Suspense subtree as part of the base duration. - var primaryChildFragment = completedWork.child; - - if (primaryChildFragment !== null) { - treeBaseDuration -= primaryChildFragment.treeBaseDuration; - } - } - completedWork.actualDuration = actualDuration; completedWork.treeBaseDuration = treeBaseDuration; } else { var _child = completedWork.child; while (_child !== null) { - newChildLanes = mergeLanes( - newChildLanes, - mergeLanes(_child.lanes, _child.childLanes) - ); + var _childUpdateExpirationTime = _child.expirationTime; + var _childChildExpirationTime = _child.childExpirationTime; + + if (_childUpdateExpirationTime > newChildExpirationTime) { + newChildExpirationTime = _childUpdateExpirationTime; + } + + if (_childChildExpirationTime > newChildExpirationTime) { + newChildExpirationTime = _childChildExpirationTime; + } + _child = _child.sibling; } } - completedWork.childLanes = newChildLanes; + completedWork.childExpirationTime = newChildExpirationTime; } function commitRoot(root) { var renderPriorityLevel = getCurrentPriorityLevel(); runWithPriority( - ImmediatePriority$1, + ImmediatePriority, commitRootImpl.bind(null, root, renderPriorityLevel) ); return null; @@ -19203,14 +18414,14 @@ function commitRootImpl(root, renderPriorityLevel) { } var finishedWork = root.finishedWork; - var lanes = root.finishedLanes; + var expirationTime = root.finishedExpirationTime; if (finishedWork === null) { return null; } root.finishedWork = null; - root.finishedLanes = NoLanes; + root.finishedExpirationTime = NoWork; if (!(finishedWork !== root.current)) { throw Error( @@ -19219,28 +18430,27 @@ function commitRootImpl(root, renderPriorityLevel) { } // commitRoot never returns a continuation; it always finishes synchronously. // So we can clear these now to allow a new callback to be scheduled. - root.callbackNode = null; // Update the first and last pending times on this root. The new first + root.callbackNode = null; + root.callbackExpirationTime = NoWork; + root.callbackPriority = NoPriority; + root.nextKnownPendingLevel = NoWork; + startCommitTimer(); // Update the first and last pending times on this root. The new first // pending time is whatever is left on the root fiber. - var remainingLanes = mergeLanes(finishedWork.lanes, finishedWork.childLanes); - markRootFinished(root, remainingLanes); // Clear already finished discrete updates in case that a later call of - // `flushDiscreteUpdates` starts a useless render pass which may cancels - // a scheduled timeout. - - if (rootsWithPendingDiscreteUpdates !== null) { - if ( - !hasDiscreteLanes(remainingLanes) && - rootsWithPendingDiscreteUpdates.has(root) - ) { - rootsWithPendingDiscreteUpdates.delete(root); - } - } + var remainingExpirationTimeBeforeCommit = getRemainingExpirationTime( + finishedWork + ); + markRootFinishedAtTime( + root, + expirationTime, + remainingExpirationTimeBeforeCommit + ); if (root === workInProgressRoot) { // We can reset these now that they are finished. workInProgressRoot = null; workInProgress = null; - workInProgressRootRenderLanes = NoLanes; + renderExpirationTime$1 = NoWork; } // This indicates that the last root we worked on is not the same one that // we're committing now. This most commonly happens when a suspended root // times out. @@ -19276,8 +18486,8 @@ function commitRootImpl(root, renderPriorityLevel) { // state of the host tree right before we mutate it. This is where // getSnapshotBeforeUpdate is called. - focusedInstanceHandle = prepareForCommit(root.containerInfo); - shouldFireAfterActiveInstanceBlur = false; + startCommitSnapshotEffectsTimer(); + prepareForCommit(root.containerInfo); nextEffect = firstEffect; do { @@ -19294,9 +18504,9 @@ function commitRootImpl(root, renderPriorityLevel) { nextEffect = nextEffect.nextEffect; } } - } while (nextEffect !== null); // We no longer need to track the active instance fiber + } while (nextEffect !== null); - focusedInstanceHandle = null; + stopCommitSnapshotEffectsTimer(); { // Mark the current commit time to be shared by all Profilers in this @@ -19304,6 +18514,7 @@ function commitRootImpl(root, renderPriorityLevel) { recordCommitTime(); } // The next phase is the mutation phase, where we mutate the host tree. + startCommitHostEffectsTimer(); nextEffect = firstEffect; do { @@ -19329,6 +18540,7 @@ function commitRootImpl(root, renderPriorityLevel) { } } while (nextEffect !== null); + stopCommitHostEffectsTimer(); resetAfterCommit(root.containerInfo); // The work-in-progress tree is now the current tree. This must come after // the mutation phase, so that the previous tree is still current during // componentWillUnmount, but before the layout phase, so that the finished @@ -19338,11 +18550,18 @@ function commitRootImpl(root, renderPriorityLevel) { // the host tree after it's been mutated. The idiomatic use case for this is // layout, but class component lifecycles also fire here for legacy reasons. + startCommitLifeCyclesTimer(); nextEffect = firstEffect; do { { - invokeGuardedCallback(null, commitLayoutEffects, null, root, lanes); + invokeGuardedCallback( + null, + commitLayoutEffects, + null, + root, + expirationTime + ); if (hasCaughtError()) { if (!(nextEffect !== null)) { @@ -19357,6 +18576,7 @@ function commitRootImpl(root, renderPriorityLevel) { } } while (nextEffect !== null); + stopCommitLifeCyclesTimer(); nextEffect = null; // Tell Scheduler to yield at the end of the frame, so the browser has an // opportunity to paint. @@ -19366,18 +18586,27 @@ function commitRootImpl(root, renderPriorityLevel) { popInteractions(prevInteractions); } - executionContext = prevExecutionContext; // Reset the priority to the previous non-sync value. + executionContext = prevExecutionContext; } else { // No effects. root.current = finishedWork; // Measure these anyway so the flamegraph explicitly shows that there were // no effects. // TODO: Maybe there's a better way to report this. + startCommitSnapshotEffectsTimer(); + stopCommitSnapshotEffectsTimer(); + { recordCommitTime(); } + + startCommitHostEffectsTimer(); + stopCommitHostEffectsTimer(); + startCommitLifeCyclesTimer(); + stopCommitLifeCyclesTimer(); } + stopCommitTimer(); var rootDidHavePassiveEffects = rootDoesHavePassiveEffects; if (rootDoesHavePassiveEffects) { @@ -19385,7 +18614,7 @@ function commitRootImpl(root, renderPriorityLevel) { // schedule a callback until after flushing layout work. rootDoesHavePassiveEffects = false; rootWithPendingPassiveEffects = root; - pendingPassiveEffectsLanes = lanes; + pendingPassiveEffectsExpirationTime = expirationTime; pendingPassiveEffectsRenderPriority = renderPriorityLevel; } else { // We are done with the effect chain at this point so let's clear the @@ -19396,18 +18625,13 @@ function commitRootImpl(root, renderPriorityLevel) { while (nextEffect !== null) { var nextNextEffect = nextEffect.nextEffect; nextEffect.nextEffect = null; - - if (nextEffect.effectTag & Deletion) { - detachFiberAfterEffects(nextEffect); - } - nextEffect = nextNextEffect; } - } // Read this again, since an effect might have updated it + } // Check if there's remaining work on this root - remainingLanes = root.pendingLanes; // Check if there's remaining work on this root + var remainingExpirationTime = root.firstPendingTime; - if (remainingLanes !== NoLanes) { + if (remainingExpirationTime !== NoWork) { { if (spawnedWorkDuringRender !== null) { var expirationTimes = spawnedWorkDuringRender; @@ -19422,7 +18646,7 @@ function commitRootImpl(root, renderPriorityLevel) { } } - schedulePendingInteractions(root, remainingLanes); + schedulePendingInteractions(root, remainingExpirationTime); } } else { // If there's no remaining work, we can clear the set of already failed @@ -19436,11 +18660,11 @@ function commitRootImpl(root, renderPriorityLevel) { // Otherwise, we'll wait until after the passive effects are flushed. // Wait to do this until after remaining work has been scheduled, // so that we don't prematurely signal complete for interactions when there's e.g. hidden work. - finishPendingInteractions(root, lanes); + finishPendingInteractions(root, expirationTime); } } - if (remainingLanes === SyncLane) { + if (remainingExpirationTime === Sync) { // Count the number of times the root synchronously re-renders without // finishing. If there are too many, it indicates an infinite update loop. if (root === rootWithNestedUpdates) { @@ -19453,10 +18677,10 @@ function commitRootImpl(root, renderPriorityLevel) { nestedUpdateCount = 0; } - onCommitRoot(finishedWork.stateNode, renderPriorityLevel); + onCommitRoot(finishedWork.stateNode, expirationTime); // Always call this before exiting `commitRoot`, to ensure that any // additional work on this root is scheduled. - ensureRootIsScheduled(root, now()); + ensureRootIsScheduled(root); if (hasUncaughtError) { hasUncaughtError = false; @@ -19466,43 +18690,25 @@ function commitRootImpl(root, renderPriorityLevel) { } if ((executionContext & LegacyUnbatchedContext) !== NoContext) { + // This is a legacy edge case. We just committed the initial mount of // a ReactDOM.render-ed root inside of batchedUpdates. The commit fired // synchronously, but layout updates should be deferred until the end // of the batch. - return null; } // If layout work was scheduled, flush it now. flushSyncCallbackQueue(); - return null; } function commitBeforeMutationEffects() { while (nextEffect !== null) { - var current = nextEffect.alternate; - - if (!shouldFireAfterActiveInstanceBlur && focusedInstanceHandle !== null) { - if ((nextEffect.effectTag & Deletion) !== NoEffect) { - if (doesFiberContain(nextEffect, focusedInstanceHandle)) { - shouldFireAfterActiveInstanceBlur = true; - } - } else { - // TODO: Move this out of the hot path using a dedicated effect tag. - if ( - nextEffect.tag === SuspenseComponent && - isSuspenseBoundaryBeingHidden(current, nextEffect) && - doesFiberContain(nextEffect, focusedInstanceHandle) - ) { - shouldFireAfterActiveInstanceBlur = true; - } - } - } - var effectTag = nextEffect.effectTag; if ((effectTag & Snapshot) !== NoEffect) { setCurrentFiber(nextEffect); + recordEffect(); + var current = nextEffect.alternate; commitBeforeMutationLifeCycles(current, nextEffect); resetCurrentFiber(); } @@ -19512,7 +18718,7 @@ function commitBeforeMutationEffects() { // the earliest opportunity. if (!rootDoesHavePassiveEffects) { rootDoesHavePassiveEffects = true; - scheduleCallback(NormalPriority$1, function() { + scheduleCallback(NormalPriority, function() { flushPassiveEffects(); return null; }); @@ -19590,30 +18796,32 @@ function commitMutationEffects(root, renderPriorityLevel) { } case Deletion: { - commitDeletion(root, nextEffect); + commitDeletion(root, nextEffect, renderPriorityLevel); break; } - } + } // TODO: Only record a mutation effect if primaryEffectTag is non-zero. + recordEffect(); resetCurrentFiber(); nextEffect = nextEffect.nextEffect; } } -function commitLayoutEffects(root, committedLanes) { +function commitLayoutEffects(root, committedExpirationTime) { + // TODO: Should probably move the bulk of this function to commitWork. while (nextEffect !== null) { setCurrentFiber(nextEffect); var effectTag = nextEffect.effectTag; if (effectTag & (Update | Callback)) { + recordEffect(); var current = nextEffect.alternate; commitLifeCycles(root, current, nextEffect); } - { - if (effectTag & Ref) { - commitAttachRef(nextEffect); - } + if (effectTag & Ref) { + recordEffect(); + commitAttachRef(nextEffect); } resetCurrentFiber(); @@ -19622,60 +18830,14 @@ function commitLayoutEffects(root, committedLanes) { } function flushPassiveEffects() { - // Returns whether passive effects were flushed. - if (pendingPassiveEffectsRenderPriority !== NoPriority$1) { + if (pendingPassiveEffectsRenderPriority !== NoPriority) { var priorityLevel = - pendingPassiveEffectsRenderPriority > NormalPriority$1 - ? NormalPriority$1 + pendingPassiveEffectsRenderPriority > NormalPriority + ? NormalPriority : pendingPassiveEffectsRenderPriority; - pendingPassiveEffectsRenderPriority = NoPriority$1; - - try { - setCurrentUpdateLanePriority( - schedulerPriorityToLanePriority(priorityLevel) - ); - return runWithPriority(priorityLevel, flushPassiveEffectsImpl); - } finally { - } + pendingPassiveEffectsRenderPriority = NoPriority; + return runWithPriority(priorityLevel, flushPassiveEffectsImpl); } - - return false; -} -function enqueuePendingPassiveHookEffectMount(fiber, effect) { - pendingPassiveHookEffectsMount.push(effect, fiber); - - if (!rootDoesHavePassiveEffects) { - rootDoesHavePassiveEffects = true; - scheduleCallback(NormalPriority$1, function() { - flushPassiveEffects(); - return null; - }); - } -} -function enqueuePendingPassiveHookEffectUnmount(fiber, effect) { - pendingPassiveHookEffectsUnmount.push(effect, fiber); - - { - fiber.effectTag |= PassiveUnmountPendingDev; - var alternate = fiber.alternate; - - if (alternate !== null) { - alternate.effectTag |= PassiveUnmountPendingDev; - } - } - - if (!rootDoesHavePassiveEffects) { - rootDoesHavePassiveEffects = true; - scheduleCallback(NormalPriority$1, function() { - flushPassiveEffects(); - return null; - }); - } -} - -function invokePassiveEffectCreate(effect) { - var create = effect.create; - effect.destroy = create(); } function flushPassiveEffectsImpl() { @@ -19684,119 +18846,52 @@ function flushPassiveEffectsImpl() { } var root = rootWithPendingPassiveEffects; - var lanes = pendingPassiveEffectsLanes; + var expirationTime = pendingPassiveEffectsExpirationTime; rootWithPendingPassiveEffects = null; - pendingPassiveEffectsLanes = NoLanes; + pendingPassiveEffectsExpirationTime = NoWork; if (!((executionContext & (RenderContext | CommitContext)) === NoContext)) { throw Error("Cannot flush passive effects while already rendering."); } - { - isFlushingPassiveEffects = true; - } - var prevExecutionContext = executionContext; executionContext |= CommitContext; - var prevInteractions = pushInteractions(root); // It's important that ALL pending passive effect destroy functions are called - // before ANY passive effect create functions are called. - // Otherwise effects in sibling components might interfere with each other. - // e.g. a destroy function in one component may unintentionally override a ref - // value set by a create function in another component. - // Layout effects have the same constraint. - // First pass: Destroy stale passive effects. + var prevInteractions = pushInteractions(root); - var unmountEffects = pendingPassiveHookEffectsUnmount; - pendingPassiveHookEffectsUnmount = []; + { + // Note: This currently assumes there are no passive effects on the root fiber + // because the root is not part of its own effect list. + // This could change in the future. + var _effect2 = root.current.firstEffect; - for (var i = 0; i < unmountEffects.length; i += 2) { - var _effect = unmountEffects[i]; - var fiber = unmountEffects[i + 1]; - var destroy = _effect.destroy; - _effect.destroy = undefined; - - { - fiber.effectTag &= ~PassiveUnmountPendingDev; - var alternate = fiber.alternate; - - if (alternate !== null) { - alternate.effectTag &= ~PassiveUnmountPendingDev; - } - } - - if (typeof destroy === "function") { + while (_effect2 !== null) { { - setCurrentFiber(fiber); - - { - invokeGuardedCallback(null, destroy, null); - } + setCurrentFiber(_effect2); + invokeGuardedCallback(null, commitPassiveHookEffects, null, _effect2); if (hasCaughtError()) { - if (!(fiber !== null)) { + if (!(_effect2 !== null)) { throw Error("Should be working on an effect."); } - var error = clearCaughtError(); - captureCommitPhaseError(fiber, error); + var _error5 = clearCaughtError(); + + captureCommitPhaseError(_effect2, _error5); } resetCurrentFiber(); } + + var nextNextEffect = _effect2.nextEffect; // Remove nextEffect pointer to assist GC + + _effect2.nextEffect = null; + _effect2 = nextNextEffect; } - } // Second pass: Create new passive effects. - - var mountEffects = pendingPassiveHookEffectsMount; - pendingPassiveHookEffectsMount = []; - - for (var _i = 0; _i < mountEffects.length; _i += 2) { - var _effect2 = mountEffects[_i]; - var _fiber = mountEffects[_i + 1]; - - { - setCurrentFiber(_fiber); - - { - invokeGuardedCallback(null, invokePassiveEffectCreate, null, _effect2); - } - - if (hasCaughtError()) { - if (!(_fiber !== null)) { - throw Error("Should be working on an effect."); - } - - var _error4 = clearCaughtError(); - - captureCommitPhaseError(_fiber, _error4); - } - - resetCurrentFiber(); - } - } // Note: This currently assumes there are no passive effects on the root fiber - // because the root is not part of its own effect list. - // This could change in the future. - - var effect = root.current.firstEffect; - - while (effect !== null) { - var nextNextEffect = effect.nextEffect; // Remove nextEffect pointer to assist GC - - effect.nextEffect = null; - - if (effect.effectTag & Deletion) { - detachFiberAfterEffects(effect); - } - - effect = nextNextEffect; } { popInteractions(prevInteractions); - finishPendingInteractions(root, lanes); - } - - { - isFlushingPassiveEffects = false; + finishPendingInteractions(root, expirationTime); } executionContext = prevExecutionContext; @@ -19833,15 +18928,13 @@ var onUncaughtError = prepareToThrowUncaughtError; function captureCommitPhaseErrorOnRoot(rootFiber, sourceFiber, error) { var errorInfo = createCapturedValue(error, sourceFiber); - var update = createRootErrorUpdate(rootFiber, errorInfo, SyncLane); + var update = createRootErrorUpdate(rootFiber, errorInfo, Sync); enqueueUpdate(rootFiber, update); - var eventTime = requestEventTime(); - var root = markUpdateLaneFromFiberToRoot(rootFiber, SyncLane); + var root = markUpdateTimeFromFiberToRoot(rootFiber, Sync); if (root !== null) { - markRootUpdated(root, SyncLane, eventTime); - ensureRootIsScheduled(root, eventTime); - schedulePendingInteractions(root, SyncLane); + ensureRootIsScheduled(root); + schedulePendingInteractions(root, Sync); } } @@ -19869,15 +18962,17 @@ function captureCommitPhaseError(sourceFiber, error) { !isAlreadyFailedLegacyErrorBoundary(instance)) ) { var errorInfo = createCapturedValue(error, sourceFiber); - var update = createClassErrorUpdate(fiber, errorInfo, SyncLane); + var update = createClassErrorUpdate( + fiber, + errorInfo, // TODO: This is always sync + Sync + ); enqueueUpdate(fiber, update); - var eventTime = requestEventTime(); - var root = markUpdateLaneFromFiberToRoot(fiber, SyncLane); + var root = markUpdateTimeFromFiberToRoot(fiber, Sync); if (root !== null) { - markRootUpdated(root, SyncLane, eventTime); - ensureRootIsScheduled(root, eventTime); - schedulePendingInteractions(root, SyncLane); + ensureRootIsScheduled(root); + schedulePendingInteractions(root, Sync); } return; @@ -19887,71 +18982,87 @@ function captureCommitPhaseError(sourceFiber, error) { fiber = fiber.return; } } -function pingSuspendedRoot(root, wakeable, pingedLanes) { +function pingSuspendedRoot(root, thenable, suspendedTime) { var pingCache = root.pingCache; if (pingCache !== null) { - // The wakeable resolved, so we no longer need to memoize, because it will + // The thenable resolved, so we no longer need to memoize, because it will // never be thrown again. - pingCache.delete(wakeable); + pingCache.delete(thenable); } - var eventTime = requestEventTime(); - markRootPinged(root, pingedLanes); - - if ( - workInProgressRoot === root && - isSubsetOfLanes(workInProgressRootRenderLanes, pingedLanes) - ) { + if (workInProgressRoot === root && renderExpirationTime$1 === suspendedTime) { // Received a ping at the same priority level at which we're currently // rendering. We might want to restart this render. This should mirror // the logic of whether or not a root suspends once it completes. // TODO: If we're rendering sync either due to Sync, Batched or expired, // we should probably never restart. - // If we're suspended with delay, or if it's a retry, we'll always suspend - // so we can always restart. + // If we're suspended with delay, we'll always suspend so we can always + // restart. If we're suspended without any updates, it might be a retry. + // If it's early in the retry we can restart. We can't know for sure + // whether we'll eventually process an update during this render pass, + // but it's somewhat unlikely that we get to a ping before that, since + // getting to the root most update is usually very fast. if ( workInProgressRootExitStatus === RootSuspendedWithDelay || (workInProgressRootExitStatus === RootSuspended && - includesOnlyRetries(workInProgressRootRenderLanes) && + workInProgressRootLatestProcessedExpirationTime === Sync && now() - globalMostRecentFallbackTime < FALLBACK_THROTTLE_MS) ) { - // Restart from the root. - prepareFreshStack(root, NoLanes); + // Restart from the root. Don't need to schedule a ping because + // we're already working on this tree. + prepareFreshStack(root, renderExpirationTime$1); } else { // Even though we can't restart right now, we might get an // opportunity later. So we mark this render as having a ping. - workInProgressRootPingedLanes = mergeLanes( - workInProgressRootPingedLanes, - pingedLanes - ); + workInProgressRootHasPendingPing = true; } + + return; } - ensureRootIsScheduled(root, eventTime); - schedulePendingInteractions(root, pingedLanes); + if (!isRootSuspendedAtTime(root, suspendedTime)) { + // The root is no longer suspended at this time. + return; + } + + var lastPingedTime = root.lastPingedTime; + + if (lastPingedTime !== NoWork && lastPingedTime < suspendedTime) { + // There's already a lower priority ping scheduled. + return; + } // Mark the time at which this ping was scheduled. + + root.lastPingedTime = suspendedTime; + ensureRootIsScheduled(root); + schedulePendingInteractions(root, suspendedTime); } -function retryTimedOutBoundary(boundaryFiber, retryLane) { +function retryTimedOutBoundary(boundaryFiber, retryTime) { // The boundary fiber (a Suspense component or SuspenseList component) // previously was rendered in its fallback state. One of the promises that // suspended it has resolved, which means at least part of the tree was // likely unblocked. Try rendering again, at a new expiration time. - if (retryLane === NoLane) { - retryLane = requestRetryLane(boundaryFiber); + if (retryTime === NoWork) { + var suspenseConfig = null; // Retries don't carry over the already committed update. + + var currentTime = requestCurrentTimeForUpdate(); + retryTime = computeExpirationForFiber( + currentTime, + boundaryFiber, + suspenseConfig + ); } // TODO: Special case idle priority? - var eventTime = requestEventTime(); - var root = markUpdateLaneFromFiberToRoot(boundaryFiber, retryLane); + var root = markUpdateTimeFromFiberToRoot(boundaryFiber, retryTime); if (root !== null) { - markRootUpdated(root, retryLane, eventTime); - ensureRootIsScheduled(root, eventTime); - schedulePendingInteractions(root, retryLane); + ensureRootIsScheduled(root); + schedulePendingInteractions(root, retryTime); } } -function resolveRetryWakeable(boundaryFiber, wakeable) { - var retryLane = NoLane; // Default +function resolveRetryThenable(boundaryFiber, thenable) { + var retryTime = NoWork; // Default var retryCache; @@ -19960,12 +19071,12 @@ function resolveRetryWakeable(boundaryFiber, wakeable) { } if (retryCache !== null) { - // The wakeable resolved, so we no longer need to memoize, because it will + // The thenable resolved, so we no longer need to memoize, because it will // never be thrown again. - retryCache.delete(wakeable); + retryCache.delete(thenable); } - retryTimedOutBoundary(boundaryFiber, retryLane); + retryTimedOutBoundary(boundaryFiber, retryTime); } // Computes the next Just Noticeable Difference (JND) boundary. // The theory is that a person can't tell the difference between small differences in time. // Therefore, if we wait a bit longer than necessary that won't translate to a noticeable @@ -19994,6 +19105,7 @@ function jnd(timeElapsed) { function computeMsUntilSuspenseLoadingDelay( mostRecentEventTime, + committedExpirationTime, suspenseConfig ) { var busyMinDurationMs = suspenseConfig.busyMinDurationMs | 0; @@ -20005,7 +19117,10 @@ function computeMsUntilSuspenseLoadingDelay( var busyDelayMs = suspenseConfig.busyDelayMs | 0; // Compute the time until this render pass would expire. var currentTimeMs = now(); - var eventTimeMs = mostRecentEventTime; + var eventTimeMs = inferTimeFromExpirationTimeWithSuspenseConfig( + mostRecentEventTime, + suspenseConfig + ); var timeElapsed = currentTimeMs - eventTimeMs; if (timeElapsed <= busyDelayMs) { @@ -20055,66 +19170,25 @@ function flushRenderPhaseStrictModeWarningsInDEV() { } } -var didWarnStateUpdateForNotYetMountedComponent = null; +function stopFinishedWorkLoopTimer() { + var didCompleteRoot = true; + stopWorkLoopTimer(interruptedBy, didCompleteRoot); + interruptedBy = null; +} -function warnAboutUpdateOnNotYetMountedFiberInDEV(fiber) { - { - if ((executionContext & RenderContext) !== NoContext) { - // We let the other warning about render phase updates deal with this one. - return; - } +function stopInterruptedWorkLoopTimer() { + // TODO: Track which fiber caused the interruption. + var didCompleteRoot = false; + stopWorkLoopTimer(interruptedBy, didCompleteRoot); + interruptedBy = null; +} - if (!(fiber.mode & (BlockingMode | ConcurrentMode))) { - return; - } - - var tag = fiber.tag; - - if ( - tag !== IndeterminateComponent && - tag !== HostRoot && - tag !== ClassComponent && - tag !== FunctionComponent && - tag !== ForwardRef && - tag !== MemoComponent && - tag !== SimpleMemoComponent && - tag !== Block - ) { - // Only warn for user-defined components, not internal ones like Suspense. - return; - } // We show the whole stack but dedupe on the top component's name because - // the problematic code almost always lies inside that component. - - var componentName = getComponentName(fiber.type) || "ReactComponent"; - - if (didWarnStateUpdateForNotYetMountedComponent !== null) { - if (didWarnStateUpdateForNotYetMountedComponent.has(componentName)) { - return; - } - - didWarnStateUpdateForNotYetMountedComponent.add(componentName); - } else { - didWarnStateUpdateForNotYetMountedComponent = new Set([componentName]); - } - - var previousFiber = current; - - try { - setCurrentFiber(fiber); - - error( - "Can't perform a React state update on a component that hasn't mounted yet. " + - "This indicates that you have a side-effect in your render function that " + - "asynchronously later calls tries to update the component. Move this work to " + - "useEffect instead." - ); - } finally { - if (previousFiber) { - setCurrentFiber(fiber); - } else { - resetCurrentFiber(); - } - } +function checkForInterruption(fiberThatReceivedUpdate, updateExpirationTime) { + if ( + workInProgressRoot !== null && + updateExpirationTime > renderExpirationTime$1 + ) { + interruptedBy = fiberThatReceivedUpdate; } } @@ -20135,12 +19209,7 @@ function warnAboutUpdateOnUnmountedFiberInDEV(fiber) { ) { // Only warn for user-defined components, not internal ones like Suspense. return; - } // If there are pending passive effects unmounts for this Fiber, - // we can assume that they would have prevented this update. - - if ((fiber.effectTag & PassiveUnmountPendingDev) !== NoEffect) { - return; - } // We show the whole stack but dedupe on the top component's name because + } // the problematic code almost always lies inside that component. var componentName = getComponentName(fiber.type) || "ReactComponent"; @@ -20155,29 +19224,15 @@ function warnAboutUpdateOnUnmountedFiberInDEV(fiber) { didWarnStateUpdateForUnmountedComponent = new Set([componentName]); } - if (isFlushingPassiveEffects); - else { - var previousFiber = current; - - try { - setCurrentFiber(fiber); - - error( - "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 %s.", - tag === ClassComponent - ? "the componentWillUnmount method" - : "a useEffect cleanup function" - ); - } finally { - if (previousFiber) { - setCurrentFiber(fiber); - } else { - resetCurrentFiber(); - } - } - } + error( + "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 %s.%s", + tag === ClassComponent + ? "the componentWillUnmount method" + : "a useEffect cleanup function", + getStackByFiberInDevAndProd(fiber) + ); } } @@ -20186,7 +19241,7 @@ var beginWork$1; { var dummyFiber = null; - beginWork$1 = function(current, unitOfWork, lanes) { + beginWork$1 = function(current, unitOfWork, expirationTime) { // If a component throws an error, we replay it again in a synchronously // dispatched event, so that the debugger will treat it as an uncaught // error See ReactErrorUtils for more information. @@ -20198,7 +19253,7 @@ var beginWork$1; ); try { - return beginWork(current, unitOfWork, lanes); + return beginWork(current, unitOfWork, expirationTime); } catch (originalError) { if ( originalError !== null && @@ -20224,7 +19279,14 @@ var beginWork$1; startProfilerTimer(unitOfWork); } // Run beginWork again. - invokeGuardedCallback(null, beginWork, null, current, unitOfWork, lanes); + invokeGuardedCallback( + null, + beginWork, + null, + current, + unitOfWork, + expirationTime + ); if (hasCaughtError()) { var replayError = clearCaughtError(); // `invokeGuardedCallback` sometimes sets an expando `_suppressLogging`. @@ -20240,49 +19302,24 @@ var beginWork$1; } var didWarnAboutUpdateInRender = false; -var didWarnAboutUpdateInRenderForAnotherComponent; - -{ - didWarnAboutUpdateInRenderForAnotherComponent = new Set(); -} function warnAboutRenderPhaseUpdatesInDEV(fiber) { { - if ( - isRendering && - (executionContext & RenderContext) !== NoContext && - !getIsUpdatingOpaqueValueInRenderPhaseInDEV() - ) { + if ((executionContext & RenderContext) !== NoContext) { switch (fiber.tag) { case FunctionComponent: case ForwardRef: case SimpleMemoComponent: { - var renderingComponentName = - (workInProgress && getComponentName(workInProgress.type)) || - "Unknown"; // Dedupe by the rendering component because it's the one that needs to be fixed. - - var dedupeKey = renderingComponentName; - - if (!didWarnAboutUpdateInRenderForAnotherComponent.has(dedupeKey)) { - didWarnAboutUpdateInRenderForAnotherComponent.add(dedupeKey); - var setStateComponentName = - getComponentName(fiber.type) || "Unknown"; - - error( - "Cannot update a component (`%s`) while rendering a " + - "different component (`%s`). To locate the bad setState() call inside `%s`, " + - "follow the stack trace as described in https://fb.me/setstate-in-render", - setStateComponentName, - renderingComponentName, - renderingComponentName - ); - } + error( + "Cannot update a component from inside the function body of a " + + "different component." + ); break; } case ClassComponent: { - if (!didWarnAboutUpdateInRender) { + if (isRendering && !didWarnAboutUpdateInRender) { error( "Cannot update during an existing state transition (such as " + "within `render`). Render methods should be a pure " + @@ -20290,9 +19327,8 @@ function warnAboutRenderPhaseUpdatesInDEV(fiber) { ); didWarnAboutUpdateInRender = true; + break; } - - break; } } } @@ -20308,33 +19344,23 @@ function warnIfNotScopedWithMatchingAct(fiber) { IsSomeRendererActing.current === true && IsThisRendererActing.current !== true ) { - var previousFiber = current; - - try { - setCurrentFiber(fiber); - - error( - "It looks like you're using the wrong act() around your test interactions.\n" + - "Be sure to use the matching version of act() corresponding to your renderer:\n\n" + - "// for react-dom:\n" + // Break up imports to avoid accidentally parsing them as dependencies. - "import {act} fr" + - "om 'react-dom/test-utils';\n" + + error( + "It looks like you're using the wrong act() around your test interactions.\n" + + "Be sure to use the matching version of act() corresponding to your renderer:\n\n" + + "// for react-dom:\n" + // Break up imports to avoid accidentally parsing them as dependencies. + "import {act} fr" + + "om 'react-dom/test-utils';\n" + + "// ...\n" + + "act(() => ...);\n\n" + + "// for react-test-renderer:\n" + // Break up imports to avoid accidentally parsing them as dependencies. + "import TestRenderer fr" + + "om react-test-renderer';\n" + + "const {act} = TestRenderer;\n" + "// ...\n" + - "act(() => ...);\n\n" + - "// for react-test-renderer:\n" + // Break up imports to avoid accidentally parsing them as dependencies. - "import TestRenderer fr" + - "om react-test-renderer';\n" + - "const {act} = TestRenderer;\n" + - "// ...\n" + - "act(() => ...);" - ); - } finally { - if (previousFiber) { - setCurrentFiber(fiber); - } else { - resetCurrentFiber(); - } - } + "act(() => ...);" + + "%s", + getStackByFiberInDevAndProd(fiber) + ); } } } @@ -20355,8 +19381,10 @@ function warnIfNotCurrentlyActingEffectsInDEV(fiber) { "/* assert on the output */\n\n" + "This ensures that you're testing the behavior the user would see " + "in the browser." + - " Learn more at https://fb.me/react-wrap-tests-with-act", - getComponentName(fiber.type) + " Learn more at https://fb.me/react-wrap-tests-with-act" + + "%s", + getComponentName(fiber.type), + getStackByFiberInDevAndProd(fiber) ); } } @@ -20369,31 +19397,21 @@ function warnIfNotCurrentlyActingUpdatesInDEV(fiber) { IsSomeRendererActing.current === false && IsThisRendererActing.current === false ) { - var previousFiber = current; - - try { - setCurrentFiber(fiber); - - error( - "An update to %s inside a test was not wrapped in act(...).\n\n" + - "When testing, code that causes React state updates should be " + - "wrapped into act(...):\n\n" + - "act(() => {\n" + - " /* fire events that update state */\n" + - "});\n" + - "/* assert on the output */\n\n" + - "This ensures that you're testing the behavior the user would see " + - "in the browser." + - " Learn more at https://fb.me/react-wrap-tests-with-act", - getComponentName(fiber.type) - ); - } finally { - if (previousFiber) { - setCurrentFiber(fiber); - } else { - resetCurrentFiber(); - } - } + error( + "An update to %s inside a test was not wrapped in act(...).\n\n" + + "When testing, code that causes React state updates should be " + + "wrapped into act(...):\n\n" + + "act(() => {\n" + + " /* fire events that update state */\n" + + "});\n" + + "/* assert on the output */\n\n" + + "This ensures that you're testing the behavior the user would see " + + "in the browser." + + " Learn more at https://fb.me/react-wrap-tests-with-act" + + "%s", + getComponentName(fiber.type), + getStackByFiberInDevAndProd(fiber) + ); } } } @@ -20426,7 +19444,7 @@ function warnIfUnmockedScheduler(fiber) { didWarnAboutUnmockedScheduler = true; error( - 'Starting from React v18, the "scheduler" module will need to be mocked ' + + 'Starting from React v17, the "scheduler" module will need to be mocked ' + "to guarantee consistent behaviour across tests and browsers. " + "For example, with jest: \n" + // Break up requires to avoid accidentally parsing them as dependencies. "jest.mock('scheduler', () => require" + @@ -20438,26 +19456,23 @@ function warnIfUnmockedScheduler(fiber) { } } -function computeThreadID(root, lane) { +function computeThreadID(root, expirationTime) { // Interaction threads are unique per root and expiration time. - // NOTE: Intentionally unsound cast. All that matters is that it's a number - // and it represents a batch of work. Could make a helper function instead, - // but meh this is fine for now. - return lane * 1000 + root.interactionThreadID; + return expirationTime * 1000 + root.interactionThreadID; } -function markSpawnedWork(lane) { +function markSpawnedWork(expirationTime) { if (spawnedWorkDuringRender === null) { - spawnedWorkDuringRender = [lane]; + spawnedWorkDuringRender = [expirationTime]; } else { - spawnedWorkDuringRender.push(lane); + spawnedWorkDuringRender.push(expirationTime); } } -function scheduleInteractions(root, lane, interactions) { +function scheduleInteractions(root, expirationTime, interactions) { if (interactions.size > 0) { var pendingInteractionMap = root.pendingInteractionMap; - var pendingInteractions = pendingInteractionMap.get(lane); + var pendingInteractions = pendingInteractionMap.get(expirationTime); if (pendingInteractions != null) { interactions.forEach(function(interaction) { @@ -20469,7 +19484,7 @@ function scheduleInteractions(root, lane, interactions) { pendingInteractions.add(interaction); }); } else { - pendingInteractionMap.set(lane, new Set(interactions)); // Update the pending async work count for the current interactions. + pendingInteractionMap.set(expirationTime, new Set(interactions)); // Update the pending async work count for the current interactions. interactions.forEach(function(interaction) { interaction.__count++; @@ -20479,26 +19494,26 @@ function scheduleInteractions(root, lane, interactions) { var subscriber = tracing.__subscriberRef.current; if (subscriber !== null) { - var threadID = computeThreadID(root, lane); + var threadID = computeThreadID(root, expirationTime); subscriber.onWorkScheduled(interactions, threadID); } } } -function schedulePendingInteractions(root, lane) { - scheduleInteractions(root, lane, tracing.__interactionsRef.current); +function schedulePendingInteractions(root, expirationTime) { + scheduleInteractions(root, expirationTime, tracing.__interactionsRef.current); } -function startWorkOnPendingInteractions(root, lanes) { +function startWorkOnPendingInteractions(root, expirationTime) { // we can accurately attribute time spent working on it, And so that cascading // work triggered during the render phase will be associated with it. var interactions = new Set(); root.pendingInteractionMap.forEach(function( scheduledInteractions, - scheduledLane + scheduledExpirationTime ) { - if (includesSomeLane(lanes, scheduledLane)) { + if (scheduledExpirationTime >= expirationTime) { scheduledInteractions.forEach(function(interaction) { return interactions.add(interaction); }); @@ -20515,13 +19530,13 @@ function startWorkOnPendingInteractions(root, lanes) { var subscriber = tracing.__subscriberRef.current; if (subscriber !== null) { - var threadID = computeThreadID(root, lanes); + var threadID = computeThreadID(root, expirationTime); try { subscriber.onWorkStarted(interactions, threadID); } catch (error) { // If the subscriber throws, rethrow it in a separate task - scheduleCallback(ImmediatePriority$1, function() { + scheduleCallback(ImmediatePriority, function() { throw error; }); } @@ -20529,21 +19544,20 @@ function startWorkOnPendingInteractions(root, lanes) { } } -function finishPendingInteractions(root, committedLanes) { - var remainingLanesAfterCommit = root.pendingLanes; +function finishPendingInteractions(root, committedExpirationTime) { + var earliestRemainingTimeAfterCommit = root.firstPendingTime; var subscriber; try { subscriber = tracing.__subscriberRef.current; if (subscriber !== null && root.memoizedInteractions.size > 0) { - // FIXME: More than one lane can finish in a single commit. - var threadID = computeThreadID(root, committedLanes); + var threadID = computeThreadID(root, committedExpirationTime); subscriber.onWorkStopped(root.memoizedInteractions, threadID); } } catch (error) { // If the subscriber throws, rethrow it in a separate task - scheduleCallback(ImmediatePriority$1, function() { + scheduleCallback(ImmediatePriority, function() { throw error; }); } finally { @@ -20551,12 +19565,15 @@ function finishPendingInteractions(root, committedLanes) { // Unless the render was suspended or cascading work was scheduled, // In which case– leave pending interactions until the subsequent render. var pendingInteractionMap = root.pendingInteractionMap; - pendingInteractionMap.forEach(function(scheduledInteractions, lane) { + pendingInteractionMap.forEach(function( + scheduledInteractions, + scheduledExpirationTime + ) { // 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 (!includesSomeLane(remainingLanesAfterCommit, lane)) { - pendingInteractionMap.delete(lane); + if (scheduledExpirationTime > earliestRemainingTimeAfterCommit) { + pendingInteractionMap.delete(scheduledExpirationTime); scheduledInteractions.forEach(function(interaction) { interaction.__count--; @@ -20565,7 +19582,7 @@ function finishPendingInteractions(root, committedLanes) { subscriber.onInteractionScheduledWorkCompleted(interaction); } catch (error) { // If the subscriber throws, rethrow it in a separate task - scheduleCallback(ImmediatePriority$1, function() { + scheduleCallback(ImmediatePriority, function() { throw error; }); } @@ -20574,455 +19591,121 @@ function finishPendingInteractions(root, committedLanes) { } }); } -} // `act` testing API -// -// TODO: This is mostly a copy-paste from the legacy `act`, which does not have -// access to the same internals that we do here. Some trade offs in the -// implementation no longer make sense. - -var isFlushingAct = false; - -function shouldForceFlushFallbacksInDEV() { - return isFlushingAct; } -function detachFiberAfterEffects(fiber) { - fiber.sibling = null; -} - -var resolveFamily = null; // $FlowFixMe Flow gets confused by a WeakSet feature check below. - -var failedBoundaries = null; -var setRefreshHandler = function(handler) { - { - resolveFamily = handler; - } -}; -function resolveFunctionForHotReloading(type) { - { - if (resolveFamily === null) { - // Hot reloading is disabled. - return type; - } - - var family = resolveFamily(type); - - if (family === undefined) { - return type; - } // Use the latest known implementation. - - return family.current; - } -} -function resolveClassForHotReloading(type) { - // No implementation differences. - return resolveFunctionForHotReloading(type); -} -function resolveForwardRefForHotReloading(type) { - { - if (resolveFamily === null) { - // Hot reloading is disabled. - return type; - } - - var family = resolveFamily(type); - - if (family === undefined) { - // Check if we're dealing with a real forwardRef. Don't want to crash early. - if ( - type !== null && - type !== undefined && - typeof type.render === "function" - ) { - // ForwardRef is special because its resolved .type is an object, - // but it's possible that we only have its inner render function in the map. - // If that inner render function is different, we'll build a new forwardRef type. - var currentRender = resolveFunctionForHotReloading(type.render); - - if (type.render !== currentRender) { - var syntheticType = { - $$typeof: REACT_FORWARD_REF_TYPE, - render: currentRender - }; - - if (type.displayName !== undefined) { - syntheticType.displayName = type.displayName; - } - - return syntheticType; - } - } - - return type; - } // Use the latest known implementation. - - return family.current; - } -} -function isCompatibleFamilyForHotReloading(fiber, element) { - { - if (resolveFamily === null) { - // Hot reloading is disabled. - return false; - } - - var prevType = fiber.elementType; - var nextType = element.type; // If we got here, we know types aren't === equal. - - var needsCompareFamilies = false; - var $$typeofNextType = - typeof nextType === "object" && nextType !== null - ? nextType.$$typeof - : null; - - switch (fiber.tag) { - case ClassComponent: { - if (typeof nextType === "function") { - needsCompareFamilies = true; - } - - break; - } - - case FunctionComponent: { - if (typeof nextType === "function") { - needsCompareFamilies = true; - } else if ($$typeofNextType === REACT_LAZY_TYPE) { - // We don't know the inner type yet. - // We're going to assume that the lazy inner type is stable, - // and so it is sufficient to avoid reconciling it away. - // We're not going to unwrap or actually use the new lazy type. - needsCompareFamilies = true; - } - - break; - } - - case ForwardRef: { - if ($$typeofNextType === REACT_FORWARD_REF_TYPE) { - needsCompareFamilies = true; - } else if ($$typeofNextType === REACT_LAZY_TYPE) { - needsCompareFamilies = true; - } - - break; - } - - case MemoComponent: - case SimpleMemoComponent: { - if ($$typeofNextType === REACT_MEMO_TYPE) { - // TODO: if it was but can no longer be simple, - // we shouldn't set this. - needsCompareFamilies = true; - } else if ($$typeofNextType === REACT_LAZY_TYPE) { - needsCompareFamilies = true; - } - - break; - } - - default: - return false; - } // Check if both types have a family and it's the same one. - - if (needsCompareFamilies) { - // Note: memo() and forwardRef() we'll compare outer rather than inner type. - // This means both of them need to be registered to preserve state. - // If we unwrapped and compared the inner types for wrappers instead, - // then we would risk falsely saying two separate memo(Foo) - // calls are equivalent because they wrap the same Foo function. - var prevFamily = resolveFamily(prevType); - - if (prevFamily !== undefined && prevFamily === resolveFamily(nextType)) { - return true; - } - } - +var onScheduleFiberRoot = null; +var onCommitFiberRoot = null; +var onCommitFiberUnmount = null; +var hasLoggedError = false; +var isDevToolsPresent = typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== "undefined"; +function injectInternals(internals) { + if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ === "undefined") { + // No DevTools return false; } -} -function markFailedErrorBoundaryForHotReloading(fiber) { - { - if (resolveFamily === null) { - // Hot reloading is disabled. - return; - } - if (typeof WeakSet !== "function") { - return; - } + var hook = __REACT_DEVTOOLS_GLOBAL_HOOK__; - if (failedBoundaries === null) { - failedBoundaries = new WeakSet(); - } - - failedBoundaries.add(fiber); + if (hook.isDisabled) { + // This isn't a real property on the hook, but it can be set to opt out + // of DevTools integration and associated warnings and logs. + // https://github.com/facebook/react/issues/3877 + return true; } -} -var scheduleRefresh = function(root, update) { - { - if (resolveFamily === null) { - // Hot reloading is disabled. - return; - } - var staleFamilies = update.staleFamilies, - updatedFamilies = update.updatedFamilies; - flushPassiveEffects(); - flushSync(function() { - scheduleFibersWithFamiliesRecursively( - root.current, - updatedFamilies, - staleFamilies + if (!hook.supportsFiber) { + { + error( + "The installed version of React DevTools is too old and will not work " + + "with the current version of React. Please update React DevTools. " + + "https://fb.me/react-devtools" ); - }); + } // DevTools exists, even though it doesn't support Fiber. + + return true; } -}; -var scheduleRoot = function(root, element) { - { - if (root.context !== emptyContextObject) { - // Super edge case: root has a legacy _renderSubtree context - // but we don't know the parentComponent so we can't pass it. - // Just ignore. We'll delete this with _renderSubtree code path later. - return; + + try { + var rendererID = hook.inject(internals); // We have successfully injected, so now it is safe to set up hooks. + + if (true) { + // Only used by Fast Refresh + if (typeof hook.onScheduleFiberRoot === "function") { + onScheduleFiberRoot = function(root, children) { + try { + hook.onScheduleFiberRoot(rendererID, root, children); + } catch (err) { + if (true && !hasLoggedError) { + hasLoggedError = true; + + error("React instrumentation encountered an error: %s", err); + } + } + }; + } } - flushPassiveEffects(); - flushSync(function() { - updateContainer(element, root, null, null); - }); - } -}; + onCommitFiberRoot = function(root, expirationTime) { + try { + var didError = (root.current.effectTag & DidCapture) === DidCapture; -function scheduleFibersWithFamiliesRecursively( - fiber, - updatedFamilies, - staleFamilies -) { - { - var alternate = fiber.alternate, - child = fiber.child, - sibling = fiber.sibling, - tag = fiber.tag, - type = fiber.type; - var candidateType = null; + if (enableProfilerTimer) { + var currentTime = getCurrentTime(); + var priorityLevel = inferPriorityFromExpirationTime( + currentTime, + expirationTime + ); + hook.onCommitFiberRoot(rendererID, root, priorityLevel, didError); + } else { + hook.onCommitFiberRoot(rendererID, root, undefined, didError); + } + } catch (err) { + if (true) { + if (!hasLoggedError) { + hasLoggedError = true; - switch (tag) { - case FunctionComponent: - case SimpleMemoComponent: - case ClassComponent: - candidateType = type; - break; - - case ForwardRef: - candidateType = type.render; - break; - } - - if (resolveFamily === null) { - throw new Error("Expected resolveFamily to be set during hot reload."); - } - - var needsRender = false; - var needsRemount = false; - - if (candidateType !== null) { - var family = resolveFamily(candidateType); - - if (family !== undefined) { - if (staleFamilies.has(family)) { - needsRemount = true; - } else if (updatedFamilies.has(family)) { - if (tag === ClassComponent) { - needsRemount = true; - } else { - needsRender = true; + error("React instrumentation encountered an error: %s", err); } } } - } + }; - if (failedBoundaries !== null) { - if ( - failedBoundaries.has(fiber) || - (alternate !== null && failedBoundaries.has(alternate)) - ) { - needsRemount = true; - } - } + onCommitFiberUnmount = function(fiber) { + try { + hook.onCommitFiberUnmount(rendererID, fiber); + } catch (err) { + if (true) { + if (!hasLoggedError) { + hasLoggedError = true; - if (needsRemount) { - fiber._debugNeedsRemount = true; - } - - if (needsRemount || needsRender) { - scheduleUpdateOnFiber(fiber, SyncLane, NoTimestamp); - } - - if (child !== null && !needsRemount) { - scheduleFibersWithFamiliesRecursively( - child, - updatedFamilies, - staleFamilies - ); - } - - if (sibling !== null) { - scheduleFibersWithFamiliesRecursively( - sibling, - updatedFamilies, - staleFamilies - ); - } - } -} - -var findHostInstancesForRefresh = function(root, families) { - { - var hostInstances = new Set(); - var types = new Set( - families.map(function(family) { - return family.current; - }) - ); - findHostInstancesForMatchingFibersRecursively( - root.current, - types, - hostInstances - ); - return hostInstances; - } -}; - -function findHostInstancesForMatchingFibersRecursively( - fiber, - types, - hostInstances -) { - { - var child = fiber.child, - sibling = fiber.sibling, - tag = fiber.tag, - type = fiber.type; - var candidateType = null; - - switch (tag) { - case FunctionComponent: - case SimpleMemoComponent: - case ClassComponent: - candidateType = type; - break; - - case ForwardRef: - candidateType = type.render; - break; - } - - var didMatch = false; - - if (candidateType !== null) { - if (types.has(candidateType)) { - didMatch = true; - } - } - - if (didMatch) { - // We have a match. This only drills down to the closest host components. - // There's no need to search deeper because for the purpose of giving - // visual feedback, "flashing" outermost parent rectangles is sufficient. - findHostInstancesForFiberShallowly(fiber, hostInstances); - } else { - // If there's no match, maybe there will be one further down in the child tree. - if (child !== null) { - findHostInstancesForMatchingFibersRecursively( - child, - types, - hostInstances - ); - } - } - - if (sibling !== null) { - findHostInstancesForMatchingFibersRecursively( - sibling, - types, - hostInstances - ); - } - } -} - -function findHostInstancesForFiberShallowly(fiber, hostInstances) { - { - var foundHostInstances = findChildHostInstancesForFiberShallowly( - fiber, - hostInstances - ); - - if (foundHostInstances) { - return; - } // If we didn't find any host children, fallback to closest host parent. - - var node = fiber; - - while (true) { - switch (node.tag) { - case HostComponent: - hostInstances.add(node.stateNode); - return; - - case HostPortal: - hostInstances.add(node.stateNode.containerInfo); - return; - - case HostRoot: - hostInstances.add(node.stateNode.containerInfo); - return; - } - - if (node.return === null) { - throw new Error("Expected to reach root first."); - } - - node = node.return; - } - } -} - -function findChildHostInstancesForFiberShallowly(fiber, hostInstances) { - { - var node = fiber; - var foundHostInstances = false; - - while (true) { - if (node.tag === HostComponent) { - // We got a match. - foundHostInstances = true; - hostInstances.add(node.stateNode); // There may still be more, so keep searching. - } else if (node.child !== null) { - node.child.return = node; - node = node.child; - continue; - } - - if (node === fiber) { - return foundHostInstances; - } - - while (node.sibling === null) { - if (node.return === null || node.return === fiber) { - return foundHostInstances; + error("React instrumentation encountered an error: %s", err); + } } - - node = node.return; } - - node.sibling.return = node.return; - node = node.sibling; + }; + } catch (err) { + // Catch all errors because it is unsafe to throw during initialization. + { + error("React instrumentation encountered an error: %s.", err); } - } + } // DevTools exists - return false; + return true; +} +function onScheduleRoot(root, children) { + if (typeof onScheduleFiberRoot === "function") { + onScheduleFiberRoot(root, children); + } +} +function onCommitRoot(root, expirationTime) { + if (typeof onCommitFiberRoot === "function") { + onCommitFiberRoot(root, expirationTime); + } +} +function onCommitUnmount(fiber) { + if (typeof onCommitFiberUnmount === "function") { + onCommitFiberUnmount(fiber); + } } var hasBadMapPolyfill; @@ -21032,11 +19715,13 @@ var hasBadMapPolyfill; try { var nonExtensibleObject = Object.preventExtensions({}); - /* eslint-disable no-new */ + var testMap = new Map([[nonExtensibleObject, null]]); + var testSet = new Set([nonExtensibleObject]); // This is necessary for Rollup to not consider these unused. + // https://github.com/rollup/rollup/issues/1771 + // TODO: we can remove these if Rollup fixes the bug. - new Map([[nonExtensibleObject, null]]); - new Set([nonExtensibleObject]); - /* eslint-enable no-new */ + testMap.set(0, 0); + testSet.add(0); } catch (e) { // TODO: Consider warning about bad polyfills hasBadMapPolyfill = true; @@ -21069,8 +19754,8 @@ function FiberNode(tag, pendingProps, key, mode) { this.nextEffect = null; this.firstEffect = null; this.lastEffect = null; - this.lanes = NoLanes; - this.childLanes = NoLanes; + this.expirationTime = NoWork; + this.childExpirationTime = NoWork; this.alternate = null; { @@ -21097,11 +19782,15 @@ function FiberNode(tag, pendingProps, key, mode) { this.actualStartTime = -1; this.selfBaseDuration = 0; this.treeBaseDuration = 0; + } // This is normally DEV-only except www when it adds listeners. + // TODO: remove the User Timing integration in favor of Root Events. + + { + this._debugID = debugCounter++; + this._debugIsCurrentlyTiming = false; } { - // This isn't directly used but is handy for debugging internals: - this._debugID = debugCounter++; this._debugSource = null; this._debugOwner = null; this._debugNeedsRemount = false; @@ -21181,7 +19870,10 @@ function createWorkInProgress(current, pendingProps) { { // DEV-only fields - workInProgress._debugID = current._debugID; + { + workInProgress._debugID = current._debugID; + } + workInProgress._debugSource = current._debugSource; workInProgress._debugOwner = current._debugOwner; workInProgress._debugHookTypes = current._debugHookTypes; @@ -21190,9 +19882,7 @@ function createWorkInProgress(current, pendingProps) { workInProgress.alternate = current; current.alternate = workInProgress; } else { - workInProgress.pendingProps = pendingProps; // Needed because Blocks store data on type. - - workInProgress.type = current.type; // We already have an alternate. + workInProgress.pendingProps = pendingProps; // We already have an alternate. // Reset the effect tag. workInProgress.effectTag = NoEffect; // The effect list is no longer valid. @@ -21211,8 +19901,21 @@ function createWorkInProgress(current, pendingProps) { } } - workInProgress.childLanes = current.childLanes; - workInProgress.lanes = current.lanes; + { + // Trying to debug a mysterious internal-only production failure. + // See D20130868 and t62461245. + // This is only on for RN FB builds. + if (current == null) { + throw Error("current is " + current + " but it can't be"); + } + + if (workInProgress == null) { + throw Error("workInProgress is " + workInProgress + " but it can't be"); + } + } + + workInProgress.childExpirationTime = current.childExpirationTime; + workInProgress.expirationTime = current.expirationTime; workInProgress.child = current.child; workInProgress.memoizedProps = current.memoizedProps; workInProgress.memoizedState = current.memoizedState; @@ -21224,7 +19927,7 @@ function createWorkInProgress(current, pendingProps) { currentDependencies === null ? null : { - lanes: currentDependencies.lanes, + expirationTime: currentDependencies.expirationTime, firstContext: currentDependencies.firstContext, responders: currentDependencies.responders }; // These will be overridden during the parent's reconciliation @@ -21261,7 +19964,7 @@ function createWorkInProgress(current, pendingProps) { return workInProgress; } // Used to reuse a Fiber for a second pass. -function resetWorkInProgress(workInProgress, renderLanes) { +function resetWorkInProgress(workInProgress, renderExpirationTime) { // This resets the Fiber to what createFiber or createWorkInProgress would // have set the values to before during the first pass. Ideally this wouldn't // be necessary but unfortunately many code paths reads from the workInProgress @@ -21279,14 +19982,13 @@ function resetWorkInProgress(workInProgress, renderLanes) { if (current === null) { // Reset to createFiber's initial values. - workInProgress.childLanes = NoLanes; - workInProgress.lanes = renderLanes; + workInProgress.childExpirationTime = NoWork; + workInProgress.expirationTime = renderExpirationTime; workInProgress.child = null; workInProgress.memoizedProps = null; workInProgress.memoizedState = null; workInProgress.updateQueue = null; workInProgress.dependencies = null; - workInProgress.stateNode = null; { // Note: We don't reset the actualTime counts. It's useful to accumulate @@ -21296,14 +19998,12 @@ function resetWorkInProgress(workInProgress, renderLanes) { } } else { // Reset to the cloned values that createWorkInProgress would've. - workInProgress.childLanes = current.childLanes; - workInProgress.lanes = current.lanes; + workInProgress.childExpirationTime = current.childExpirationTime; + workInProgress.expirationTime = current.expirationTime; workInProgress.child = current.child; workInProgress.memoizedProps = current.memoizedProps; workInProgress.memoizedState = current.memoizedState; - workInProgress.updateQueue = current.updateQueue; // Needed because Blocks store data on type. - - workInProgress.type = current.type; // Clone the dependencies object. This is mutated during the render phase, so + workInProgress.updateQueue = current.updateQueue; // Clone the dependencies object. This is mutated during the render phase, so // it cannot be shared with the current fiber. var currentDependencies = current.dependencies; @@ -21311,7 +20011,7 @@ function resetWorkInProgress(workInProgress, renderLanes) { currentDependencies === null ? null : { - lanes: currentDependencies.lanes, + expirationTime: currentDependencies.expirationTime, firstContext: currentDependencies.firstContext, responders: currentDependencies.responders }; @@ -21352,8 +20052,9 @@ function createFiberFromTypeAndProps( pendingProps, owner, mode, - lanes + expirationTime ) { + var fiber; 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; @@ -21375,11 +20076,16 @@ function createFiberFromTypeAndProps( } else { getTag: switch (type) { case REACT_FRAGMENT_TYPE: - return createFiberFromFragment(pendingProps.children, mode, lanes, key); + return createFiberFromFragment( + pendingProps.children, + mode, + expirationTime, + key + ); - case REACT_DEBUG_TRACING_MODE_TYPE: + case REACT_CONCURRENT_MODE_TYPE: fiberTag = Mode; - mode |= DebugTracingMode; + mode |= ConcurrentMode | BlockingMode | StrictMode; break; case REACT_STRICT_MODE_TYPE: @@ -21388,23 +20094,18 @@ function createFiberFromTypeAndProps( break; case REACT_PROFILER_TYPE: - return createFiberFromProfiler(pendingProps, mode, lanes, key); + return createFiberFromProfiler(pendingProps, mode, expirationTime, key); case REACT_SUSPENSE_TYPE: - return createFiberFromSuspense(pendingProps, mode, lanes, key); + return createFiberFromSuspense(pendingProps, mode, expirationTime, key); case REACT_SUSPENSE_LIST_TYPE: - return createFiberFromSuspenseList(pendingProps, mode, lanes, key); - - case REACT_OFFSCREEN_TYPE: - return createFiberFromOffscreen(pendingProps, mode, lanes, key); - - case REACT_LEGACY_HIDDEN_TYPE: - return createFiberFromLegacyHidden(pendingProps, mode, lanes, key); - - case REACT_SCOPE_TYPE: - - // eslint-disable-next-line no-fallthrough + return createFiberFromSuspenseList( + pendingProps, + mode, + expirationTime, + key + ); default: { if (typeof type === "object" && type !== null) { @@ -21476,13 +20177,13 @@ function createFiberFromTypeAndProps( } } - var fiber = createFiber(fiberTag, pendingProps, key, mode); + fiber = createFiber(fiberTag, pendingProps, key, mode); fiber.elementType = type; fiber.type = resolvedType; - fiber.lanes = lanes; + fiber.expirationTime = expirationTime; return fiber; } -function createFiberFromElement(element, mode, lanes) { +function createFiberFromElement(element, mode, expirationTime) { var owner = null; { @@ -21498,7 +20199,7 @@ function createFiberFromElement(element, mode, lanes) { pendingProps, owner, mode, - lanes + expirationTime ); { @@ -21508,13 +20209,13 @@ function createFiberFromElement(element, mode, lanes) { return fiber; } -function createFiberFromFragment(elements, mode, lanes, key) { +function createFiberFromFragment(elements, mode, expirationTime, key) { var fiber = createFiber(Fragment, elements, key, mode); - fiber.lanes = lanes; + fiber.expirationTime = expirationTime; return fiber; } -function createFiberFromProfiler(pendingProps, mode, lanes, key) { +function createFiberFromProfiler(pendingProps, mode, expirationTime, key) { { if (typeof pendingProps.id !== "string") { error('Profiler must specify an "id" as a prop'); @@ -21525,7 +20226,7 @@ function createFiberFromProfiler(pendingProps, mode, lanes, key) { fiber.elementType = REACT_PROFILER_TYPE; fiber.type = REACT_PROFILER_TYPE; - fiber.lanes = lanes; + fiber.expirationTime = expirationTime; { fiber.stateNode = { @@ -21537,17 +20238,17 @@ function createFiberFromProfiler(pendingProps, mode, lanes, key) { return fiber; } -function createFiberFromSuspense(pendingProps, mode, lanes, key) { +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. // This needs to be fixed in getComponentName so that it relies on the tag // instead. fiber.type = REACT_SUSPENSE_TYPE; fiber.elementType = REACT_SUSPENSE_TYPE; - fiber.lanes = lanes; + fiber.expirationTime = expirationTime; return fiber; } -function createFiberFromSuspenseList(pendingProps, mode, lanes, key) { +function createFiberFromSuspenseList(pendingProps, mode, expirationTime, key) { var fiber = createFiber(SuspenseListComponent, pendingProps, key, mode); { @@ -21558,44 +20259,18 @@ function createFiberFromSuspenseList(pendingProps, mode, lanes, key) { } fiber.elementType = REACT_SUSPENSE_LIST_TYPE; - fiber.lanes = lanes; + fiber.expirationTime = expirationTime; return fiber; } -function createFiberFromOffscreen(pendingProps, mode, lanes, key) { - var fiber = createFiber(OffscreenComponent, pendingProps, key, mode); // TODO: The OffscreenComponent fiber shouldn't have a type. It has a tag. - // This needs to be fixed in getComponentName so that it relies on the tag - // instead. - - { - fiber.type = REACT_OFFSCREEN_TYPE; - } - - fiber.elementType = REACT_OFFSCREEN_TYPE; - fiber.lanes = lanes; - return fiber; -} -function createFiberFromLegacyHidden(pendingProps, mode, lanes, key) { - var fiber = createFiber(LegacyHiddenComponent, pendingProps, key, mode); // TODO: The LegacyHidden fiber shouldn't have a type. It has a tag. - // This needs to be fixed in getComponentName so that it relies on the tag - // instead. - - { - fiber.type = REACT_LEGACY_HIDDEN_TYPE; - } - - fiber.elementType = REACT_LEGACY_HIDDEN_TYPE; - fiber.lanes = lanes; - return fiber; -} -function createFiberFromText(content, mode, lanes) { +function createFiberFromText(content, mode, expirationTime) { var fiber = createFiber(HostText, content, null, mode); - fiber.lanes = lanes; + fiber.expirationTime = expirationTime; return fiber; } -function createFiberFromPortal(portal, mode, lanes) { +function createFiberFromPortal(portal, mode, expirationTime) { var pendingProps = portal.children !== null ? portal.children : []; var fiber = createFiber(HostPortal, pendingProps, portal.key, mode); - fiber.lanes = lanes; + fiber.expirationTime = expirationTime; fiber.stateNode = { containerInfo: portal.containerInfo, pendingChildren: null, @@ -21636,8 +20311,8 @@ function assignFiberPropertiesInDEV(target, source) { target.nextEffect = source.nextEffect; target.firstEffect = source.firstEffect; target.lastEffect = source.lastEffect; - target.lanes = source.lanes; - target.childLanes = source.childLanes; + target.expirationTime = source.expirationTime; + target.childExpirationTime = source.childExpirationTime; target.alternate = source.alternate; { @@ -21647,7 +20322,11 @@ function assignFiberPropertiesInDEV(target, source) { target.treeBaseDuration = source.treeBaseDuration; } - target._debugID = source._debugID; + { + target._debugID = source._debugID; + target._debugIsCurrentlyTiming = source._debugIsCurrentlyTiming; + } + target._debugSource = source._debugSource; target._debugOwner = source._debugOwner; target._debugNeedsRemount = source._debugNeedsRemount; @@ -21657,49 +20336,30 @@ function assignFiberPropertiesInDEV(target, source) { function FiberRootNode(containerInfo, tag, hydrate) { this.tag = tag; + this.current = null; this.containerInfo = containerInfo; this.pendingChildren = null; - this.current = null; this.pingCache = null; + this.finishedExpirationTime = NoWork; this.finishedWork = null; this.timeoutHandle = noTimeout; this.context = null; this.pendingContext = null; this.hydrate = hydrate; this.callbackNode = null; - this.callbackPriority = NoLanePriority; - this.eventTimes = createLaneMap(NoLanes); - this.expirationTimes = createLaneMap(NoTimestamp); - this.pendingLanes = NoLanes; - this.suspendedLanes = NoLanes; - this.pingedLanes = NoLanes; - this.expiredLanes = NoLanes; - this.mutableReadLanes = NoLanes; - this.finishedLanes = NoLanes; - this.entangledLanes = NoLanes; - this.entanglements = createLaneMap(NoLanes); + this.callbackPriority = NoPriority; + this.firstPendingTime = NoWork; + this.firstSuspendedTime = NoWork; + this.lastSuspendedTime = NoWork; + this.nextKnownPendingLevel = NoWork; + this.lastPingedTime = NoWork; + this.lastExpiredTime = NoWork; { this.interactionThreadID = tracing.unstable_getThreadID(); this.memoizedInteractions = new Set(); this.pendingInteractionMap = new Map(); } - - { - switch (tag) { - case BlockingRoot: - this._debugRootType = "createBlockingRoot()"; - break; - - case ConcurrentRoot: - this._debugRootType = "createRoot()"; - break; - - case LegacyRoot: - this._debugRootType = "createLegacyRoot()"; - break; - } - } } function createFiberRoot(containerInfo, tag, hydrate, hydrationCallbacks) { @@ -21712,22 +20372,95 @@ function createFiberRoot(containerInfo, tag, hydrate, hydrationCallbacks) { initializeUpdateQueue(uninitializedFiber); return root; } +function isRootSuspendedAtTime(root, expirationTime) { + var firstSuspendedTime = root.firstSuspendedTime; + var lastSuspendedTime = root.lastSuspendedTime; + return ( + firstSuspendedTime !== NoWork && + firstSuspendedTime >= expirationTime && + lastSuspendedTime <= expirationTime + ); +} +function markRootSuspendedAtTime(root, expirationTime) { + var firstSuspendedTime = root.firstSuspendedTime; + var lastSuspendedTime = root.lastSuspendedTime; -function createPortal( - children, - containerInfo, // TODO: figure out the API for cross-renderer implementation. - implementation + if (firstSuspendedTime < expirationTime) { + root.firstSuspendedTime = expirationTime; + } + + if (lastSuspendedTime > expirationTime || firstSuspendedTime === NoWork) { + root.lastSuspendedTime = expirationTime; + } + + if (expirationTime <= root.lastPingedTime) { + root.lastPingedTime = NoWork; + } + + if (expirationTime <= root.lastExpiredTime) { + root.lastExpiredTime = NoWork; + } +} +function markRootUpdatedAtTime(root, expirationTime) { + // Update the range of pending times + var firstPendingTime = root.firstPendingTime; + + if (expirationTime > firstPendingTime) { + root.firstPendingTime = expirationTime; + } // Update the range of suspended times. Treat everything lower priority or + // equal to this update as unsuspended. + + var firstSuspendedTime = root.firstSuspendedTime; + + if (firstSuspendedTime !== NoWork) { + if (expirationTime >= firstSuspendedTime) { + // The entire suspended range is now unsuspended. + root.firstSuspendedTime = root.lastSuspendedTime = root.nextKnownPendingLevel = NoWork; + } else if (expirationTime >= root.lastSuspendedTime) { + root.lastSuspendedTime = expirationTime + 1; + } // This is a pending level. Check if it's higher priority than the next + // known pending level. + + if (expirationTime > root.nextKnownPendingLevel) { + root.nextKnownPendingLevel = expirationTime; + } + } +} +function markRootFinishedAtTime( + root, + finishedExpirationTime, + remainingExpirationTime ) { - var key = - arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null; - return { - // This tag allow us to uniquely identify this as a React Portal - $$typeof: REACT_PORTAL_TYPE, - key: key == null ? null : "" + key, - children: children, - containerInfo: containerInfo, - implementation: implementation - }; + // Update the range of pending times + root.firstPendingTime = remainingExpirationTime; // Update the range of suspended times. Treat everything higher priority or + // equal to this update as unsuspended. + + if (finishedExpirationTime <= root.lastSuspendedTime) { + // The entire suspended range is now unsuspended. + root.firstSuspendedTime = root.lastSuspendedTime = root.nextKnownPendingLevel = NoWork; + } else if (finishedExpirationTime <= root.firstSuspendedTime) { + // Part of the suspended range is now unsuspended. Narrow the range to + // include everything between the unsuspended time (non-inclusive) and the + // last suspended time. + root.firstSuspendedTime = finishedExpirationTime - 1; + } + + if (finishedExpirationTime <= root.lastPingedTime) { + // Clear the pinged time + root.lastPingedTime = NoWork; + } + + if (finishedExpirationTime <= root.lastExpiredTime) { + // Clear the expired time + root.lastExpiredTime = NoWork; + } +} +function markRootExpiredAtTime(root, expirationTime) { + var lastExpiredTime = root.lastExpiredTime; + + if (lastExpiredTime === NoWork || lastExpiredTime > expirationTime) { + root.lastExpiredTime = expirationTime; + } } var didWarnAboutNestedUpdates; @@ -21787,42 +20520,31 @@ function findHostInstanceWithWarning(component, methodName) { if (!didWarnAboutFindNodeInStrictMode[componentName]) { didWarnAboutFindNodeInStrictMode[componentName] = true; - var previousFiber = current; - try { - setCurrentFiber(hostFiber); - - if (fiber.mode & StrictMode) { - error( - "%s is deprecated in StrictMode. " + - "%s was passed an instance of %s which is inside StrictMode. " + - "Instead, add a ref directly to the element you want to reference. " + - "Learn more about using refs safely here: " + - "https://fb.me/react-strict-mode-find-node", - methodName, - methodName, - componentName - ); - } else { - error( - "%s is deprecated in StrictMode. " + - "%s was passed an instance of %s which renders StrictMode children. " + - "Instead, add a ref directly to the element you want to reference. " + - "Learn more about using refs safely here: " + - "https://fb.me/react-strict-mode-find-node", - methodName, - methodName, - componentName - ); - } - } finally { - // Ideally this should reset to previous but this shouldn't be called in - // render and there's another warning for that anyway. - if (previousFiber) { - setCurrentFiber(previousFiber); - } else { - resetCurrentFiber(); - } + if (fiber.mode & StrictMode) { + error( + "%s is deprecated in StrictMode. " + + "%s was passed an instance of %s which is inside StrictMode. " + + "Instead, add a ref directly to the element you want to reference. " + + "Learn more about using refs safely here: " + + "https://fb.me/react-strict-mode-find-node%s", + methodName, + methodName, + componentName, + getStackByFiberInDevAndProd(hostFiber) + ); + } else { + error( + "%s is deprecated in StrictMode. " + + "%s was passed an instance of %s which renders StrictMode children. " + + "Instead, add a ref directly to the element you want to reference. " + + "Learn more about using refs safely here: " + + "https://fb.me/react-strict-mode-find-node%s", + methodName, + methodName, + componentName, + getStackByFiberInDevAndProd(hostFiber) + ); } } } @@ -21840,7 +20562,7 @@ function updateContainer(element, container, parentComponent, callback) { } var current$1 = container.current; - var eventTime = requestEventTime(); + var currentTime = requestCurrentTimeForUpdate(); { // $FlowExpectedError - jest isn't a global, and isn't recognized outside of tests @@ -21851,8 +20573,11 @@ function updateContainer(element, container, parentComponent, callback) { } var suspenseConfig = requestCurrentSuspenseConfig(); - var lane = requestUpdateLane(current$1, suspenseConfig); - + var expirationTime = computeExpirationForFiber( + currentTime, + current$1, + suspenseConfig + ); var context = getContextForSubtree(parentComponent); if (container.context === null) { @@ -21875,7 +20600,7 @@ function updateContainer(element, container, parentComponent, callback) { } } - var update = createUpdate(eventTime, lane, suspenseConfig); // Caution: React DevTools currently depends on this property + var update = createUpdate(expirationTime, suspenseConfig); // Caution: React DevTools currently depends on this property // being called "element". update.payload = { @@ -21898,8 +20623,8 @@ function updateContainer(element, container, parentComponent, callback) { } enqueueUpdate(current$1, update); - scheduleUpdateOnFiber(current$1, lane, eventTime); - return lane; + scheduleWork(current$1, expirationTime); + return expirationTime; } function getPublicRootInstance(container) { var containerFiber = container.current; @@ -21966,7 +20691,7 @@ var setSuspenseHandler = null; // Shallow cloning props works as a workaround for now to bypass the bailout check. fiber.memoizedProps = Object.assign({}, fiber.memoizedProps); - scheduleUpdateOnFiber(fiber, SyncLane, NoTimestamp); + scheduleWork(fiber, Sync); } }; // Support DevTools props for function components, forwardRef, memo, host components, etc. @@ -21977,11 +20702,11 @@ var setSuspenseHandler = null; fiber.alternate.pendingProps = fiber.pendingProps; } - scheduleUpdateOnFiber(fiber, SyncLane, NoTimestamp); + scheduleWork(fiber, Sync); }; scheduleUpdate = function(fiber) { - scheduleUpdateOnFiber(fiber, SyncLane, NoTimestamp); + scheduleWork(fiber, Sync); }; setSuspenseHandler = function(newShouldSuspendImpl) { @@ -21989,24 +20714,6 @@ var setSuspenseHandler = null; }; } -function findHostInstanceByFiber(fiber) { - var hostFiber = findCurrentHostFiber(fiber); - - if (hostFiber === null) { - return null; - } - - return hostFiber.stateNode; -} - -function emptyFindFiberByHostInstance(instance) { - return null; -} - -function getCurrentFiberForDevTools() { - return current; -} - function injectIntoDevTools(devToolsConfig) { var findFiberByHostInstance = devToolsConfig.findFiberByHostInstance; var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher; @@ -22020,21 +20727,55 @@ function injectIntoDevTools(devToolsConfig) { setSuspenseHandler: setSuspenseHandler, scheduleUpdate: scheduleUpdate, currentDispatcherRef: ReactCurrentDispatcher, - findHostInstanceByFiber: findHostInstanceByFiber, - findFiberByHostInstance: - findFiberByHostInstance || emptyFindFiberByHostInstance, + findHostInstanceByFiber: function(fiber) { + var hostFiber = findCurrentHostFiber(fiber); + + if (hostFiber === null) { + return null; + } + + return hostFiber.stateNode; + }, + findFiberByHostInstance: function(instance) { + if (!findFiberByHostInstance) { + // Might not be implemented by the renderer. + return null; + } + + return findFiberByHostInstance(instance); + }, // React Refresh findHostInstancesForRefresh: findHostInstancesForRefresh, scheduleRefresh: scheduleRefresh, scheduleRoot: scheduleRoot, setRefreshHandler: setRefreshHandler, // Enables DevTools to append owner stacks to error messages in DEV mode. - getCurrentFiber: getCurrentFiberForDevTools + getCurrentFiber: function() { + return current; + } }); } +var IsSomeRendererActing$1 = ReactSharedInternals.IsSomeRendererActing; + +function createPortal( + children, + containerInfo, // TODO: figure out the API for cross-renderer implementation. + implementation +) { + var key = + arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null; + return { + // This tag allow us to uniquely identify this as a React Portal + $$typeof: REACT_PORTAL_TYPE, + key: key == null ? null : "" + key, + children: children, + containerInfo: containerInfo, + implementation: implementation + }; +} // TODO: this is special because it gets imported during build. -var ReactVersion = "17.0.0-alpha.0"; +var ReactVersion = "16.13.0"; var emptyObject$1 = {}; @@ -22265,7 +21006,7 @@ var getInspectorDataForViewAtPoint; ); } else { error( - "getInspectorDataForViewAtPoint expects to receive a host component" + "getInspectorDataForViewAtPoint expects to receieve a host component" ); return; diff --git a/Libraries/Renderer/implementations/ReactNativeRenderer-prod.fb.js b/Libraries/Renderer/implementations/ReactNativeRenderer-prod.fb.js index d47d2375b6c..f32dc562752 100644 --- a/Libraries/Renderer/implementations/ReactNativeRenderer-prod.fb.js +++ b/Libraries/Renderer/implementations/ReactNativeRenderer-prod.fb.js @@ -15,6 +15,16 @@ require("react-native/Libraries/ReactPrivate/ReactNativePrivateInitializeCore"); var ReactNativePrivateInterface = require("react-native/Libraries/ReactPrivate/ReactNativePrivateInterface"), React = require("react"), Scheduler = require("scheduler"); +function getParent(inst) { + do inst = inst.return; + while (inst && 5 !== inst.tag); + return inst ? inst : null; +} +function traverseTwoPhase(inst, fn, arg) { + for (var path = []; inst; ) path.push(inst), (inst = getParent(inst)); + for (inst = path.length; 0 < inst--; ) fn(path[inst], "captured", arg); + for (inst = 0; inst < path.length; inst++) fn(path[inst], "bubbled", arg); +} function invokeGuardedCallbackImpl(name, func, context, a, b, c, d, e, f) { var funcArgs = Array.prototype.slice.call(arguments, 3); try { @@ -85,6 +95,109 @@ function executeDirectDispatch(event) { event._dispatchInstances = null; return dispatchListener; } +function getListener(inst, registrationName) { + var listener = inst.stateNode; + if (!listener) return null; + var props = getFiberCurrentPropsFromNode(listener); + if (!props) return null; + listener = props[registrationName]; + a: switch (registrationName) { + case "onClick": + case "onClickCapture": + case "onDoubleClick": + case "onDoubleClickCapture": + case "onMouseDown": + case "onMouseDownCapture": + case "onMouseMove": + case "onMouseMoveCapture": + case "onMouseUp": + case "onMouseUpCapture": + case "onMouseEnter": + (props = !props.disabled) || + ((inst = inst.type), + (props = !( + "button" === inst || + "input" === inst || + "select" === inst || + "textarea" === inst + ))); + inst = !props; + break a; + default: + inst = !1; + } + if (inst) return null; + if (listener && "function" !== typeof listener) + throw Error( + "Expected `" + + registrationName + + "` listener to be a function, instead got a value of `" + + typeof listener + + "` type." + ); + return listener; +} +function accumulateInto(current, next) { + if (null == next) + throw Error( + "accumulateInto(...): Accumulated items must not be null or undefined." + ); + if (null == current) return next; + if (Array.isArray(current)) { + if (Array.isArray(next)) return current.push.apply(current, next), current; + current.push(next); + return current; + } + return Array.isArray(next) ? [current].concat(next) : [current, next]; +} +function forEachAccumulated(arr, cb, scope) { + Array.isArray(arr) ? arr.forEach(cb, scope) : arr && cb.call(scope, arr); +} +function accumulateDirectionalDispatches(inst, phase, event) { + if ( + (phase = getListener( + inst, + event.dispatchConfig.phasedRegistrationNames[phase] + )) + ) + (event._dispatchListeners = accumulateInto( + event._dispatchListeners, + phase + )), + (event._dispatchInstances = accumulateInto( + event._dispatchInstances, + inst + )); +} +function accumulateTwoPhaseDispatchesSingle(event) { + event && + event.dispatchConfig.phasedRegistrationNames && + traverseTwoPhase(event._targetInst, accumulateDirectionalDispatches, event); +} +function accumulateTwoPhaseDispatchesSingleSkipTarget(event) { + if (event && event.dispatchConfig.phasedRegistrationNames) { + var targetInst = event._targetInst; + targetInst = targetInst ? getParent(targetInst) : null; + traverseTwoPhase(targetInst, accumulateDirectionalDispatches, event); + } +} +function accumulateDirectDispatchesSingle(event) { + if (event && event.dispatchConfig.registrationName) { + var inst = event._targetInst; + if (inst && event && event.dispatchConfig.registrationName) { + var listener = getListener(inst, event.dispatchConfig.registrationName); + listener && + ((event._dispatchListeners = accumulateInto( + event._dispatchListeners, + listener + )), + (event._dispatchInstances = accumulateInto( + event._dispatchInstances, + inst + ))); + } + } +} function functionThatReturnsTrue() { return !0; } @@ -100,7 +213,6 @@ function SyntheticEvent( this.dispatchConfig = dispatchConfig; this._targetInst = targetInst; this.nativeEvent = nativeEvent; - this._dispatchInstances = this._dispatchListeners = null; dispatchConfig = this.constructor.Interface; for (var propName in dispatchConfig) dispatchConfig.hasOwnProperty(propName) && @@ -180,12 +292,7 @@ SyntheticEvent.extend = function(Interface) { return Class; }; addEventPoolingTo(SyntheticEvent); -function createOrGetPooledEvent( - dispatchConfig, - targetInst, - nativeEvent, - nativeInst -) { +function getPooledEvent(dispatchConfig, targetInst, nativeEvent, nativeInst) { if (this.eventPool.length) { var instance = this.eventPool.pop(); this.call(instance, dispatchConfig, targetInst, nativeEvent, nativeInst); @@ -202,8 +309,8 @@ function releasePooledEvent(event) { 10 > this.eventPool.length && this.eventPool.push(event); } function addEventPoolingTo(EventConstructor) { - EventConstructor.getPooled = createOrGetPooledEvent; EventConstructor.eventPool = []; + EventConstructor.getPooled = getPooledEvent; EventConstructor.release = releasePooledEvent; } var ResponderSyntheticEvent = SyntheticEvent.extend({ @@ -331,22 +438,6 @@ function accumulate(current, next) { ? [current].concat(next) : [current, next]; } -function accumulateInto(current, next) { - if (null == next) - throw Error( - "accumulateInto(...): Accumulated items must not be null or undefined." - ); - if (null == current) return next; - if (Array.isArray(current)) { - if (Array.isArray(next)) return current.push.apply(current, next), current; - current.push(next); - return current; - } - return Array.isArray(next) ? [current].concat(next) : [current, next]; -} -function forEachAccumulated(arr, cb, scope) { - Array.isArray(arr) ? arr.forEach(cb, scope) : arr && cb.call(scope, arr); -} var responderInst = null, trackedTouchCount = 0; function changeResponder(nextResponderInst, blockHostResponder) { @@ -360,132 +451,65 @@ function changeResponder(nextResponderInst, blockHostResponder) { ); } var eventTypes = { - startShouldSetResponder: { - phasedRegistrationNames: { - bubbled: "onStartShouldSetResponder", - captured: "onStartShouldSetResponderCapture" + startShouldSetResponder: { + phasedRegistrationNames: { + bubbled: "onStartShouldSetResponder", + captured: "onStartShouldSetResponderCapture" + }, + dependencies: startDependencies }, - dependencies: startDependencies - }, - scrollShouldSetResponder: { - phasedRegistrationNames: { - bubbled: "onScrollShouldSetResponder", - captured: "onScrollShouldSetResponderCapture" + scrollShouldSetResponder: { + phasedRegistrationNames: { + bubbled: "onScrollShouldSetResponder", + captured: "onScrollShouldSetResponderCapture" + }, + dependencies: ["topScroll"] }, - dependencies: ["topScroll"] - }, - selectionChangeShouldSetResponder: { - phasedRegistrationNames: { - bubbled: "onSelectionChangeShouldSetResponder", - captured: "onSelectionChangeShouldSetResponderCapture" + selectionChangeShouldSetResponder: { + phasedRegistrationNames: { + bubbled: "onSelectionChangeShouldSetResponder", + captured: "onSelectionChangeShouldSetResponderCapture" + }, + dependencies: ["topSelectionChange"] }, - dependencies: ["topSelectionChange"] - }, - moveShouldSetResponder: { - phasedRegistrationNames: { - bubbled: "onMoveShouldSetResponder", - captured: "onMoveShouldSetResponderCapture" + moveShouldSetResponder: { + phasedRegistrationNames: { + bubbled: "onMoveShouldSetResponder", + captured: "onMoveShouldSetResponderCapture" + }, + dependencies: moveDependencies }, - dependencies: moveDependencies - }, - responderStart: { - registrationName: "onResponderStart", - dependencies: startDependencies - }, - responderMove: { - registrationName: "onResponderMove", - dependencies: moveDependencies - }, - responderEnd: { - registrationName: "onResponderEnd", - dependencies: endDependencies - }, - responderRelease: { - registrationName: "onResponderRelease", - dependencies: endDependencies - }, - responderTerminationRequest: { - registrationName: "onResponderTerminationRequest", - dependencies: [] - }, - responderGrant: { registrationName: "onResponderGrant", dependencies: [] }, - responderReject: { registrationName: "onResponderReject", dependencies: [] }, - responderTerminate: { - registrationName: "onResponderTerminate", - dependencies: [] - } -}; -function getParent(inst) { - do inst = inst.return; - while (inst && 5 !== inst.tag); - return inst ? inst : null; -} -function traverseTwoPhase(inst, fn, arg) { - for (var path = []; inst; ) path.push(inst), (inst = getParent(inst)); - for (inst = path.length; 0 < inst--; ) fn(path[inst], "captured", arg); - for (inst = 0; inst < path.length; inst++) fn(path[inst], "bubbled", arg); -} -function getListener(inst, registrationName) { - inst = inst.stateNode; - if (null === inst) return null; - inst = getFiberCurrentPropsFromNode(inst); - if (null === inst) return null; - if ((inst = inst[registrationName]) && "function" !== typeof inst) - throw Error( - "Expected `" + - registrationName + - "` listener to be a function, instead got a value of `" + - typeof inst + - "` type." - ); - return inst; -} -function accumulateDirectionalDispatches(inst, phase, event) { - if ( - (phase = getListener( - inst, - event.dispatchConfig.phasedRegistrationNames[phase] - )) - ) - (event._dispatchListeners = accumulateInto( - event._dispatchListeners, - phase - )), - (event._dispatchInstances = accumulateInto( - event._dispatchInstances, - inst - )); -} -function accumulateDirectDispatchesSingle(event) { - if (event && event.dispatchConfig.registrationName) { - var inst = event._targetInst; - if (inst && event && event.dispatchConfig.registrationName) { - var listener = getListener(inst, event.dispatchConfig.registrationName); - listener && - ((event._dispatchListeners = accumulateInto( - event._dispatchListeners, - listener - )), - (event._dispatchInstances = accumulateInto( - event._dispatchInstances, - inst - ))); + responderStart: { + registrationName: "onResponderStart", + dependencies: startDependencies + }, + responderMove: { + registrationName: "onResponderMove", + dependencies: moveDependencies + }, + responderEnd: { + registrationName: "onResponderEnd", + dependencies: endDependencies + }, + responderRelease: { + registrationName: "onResponderRelease", + dependencies: endDependencies + }, + responderTerminationRequest: { + registrationName: "onResponderTerminationRequest", + dependencies: [] + }, + responderGrant: { registrationName: "onResponderGrant", dependencies: [] }, + responderReject: { + registrationName: "onResponderReject", + dependencies: [] + }, + responderTerminate: { + registrationName: "onResponderTerminate", + dependencies: [] } - } -} -function accumulateTwoPhaseDispatchesSingleSkipTarget(event) { - if (event && event.dispatchConfig.phasedRegistrationNames) { - var targetInst = event._targetInst; - targetInst = targetInst ? getParent(targetInst) : null; - traverseTwoPhase(targetInst, accumulateDirectionalDispatches, event); - } -} -function accumulateTwoPhaseDispatchesSingle(event) { - event && - event.dispatchConfig.phasedRegistrationNames && - traverseTwoPhase(event._targetInst, accumulateDirectionalDispatches, event); -} -var ResponderEventPlugin = { + }, + ResponderEventPlugin = { _getResponder: function() { return responderInst; }, @@ -546,70 +570,68 @@ var ResponderEventPlugin = { JSCompiler_temp = null; } else JSCompiler_temp = targetInst; - targetInst = JSCompiler_temp; - JSCompiler_temp = targetInst === responderInst; - shouldSetEventType = ResponderSyntheticEvent.getPooled( + targetInst = JSCompiler_temp === responderInst; + JSCompiler_temp = ResponderSyntheticEvent.getPooled( shouldSetEventType, - targetInst, + JSCompiler_temp, nativeEvent, nativeEventTarget ); - shouldSetEventType.touchHistory = - ResponderTouchHistoryStore.touchHistory; - JSCompiler_temp + JSCompiler_temp.touchHistory = ResponderTouchHistoryStore.touchHistory; + targetInst ? forEachAccumulated( - shouldSetEventType, + JSCompiler_temp, accumulateTwoPhaseDispatchesSingleSkipTarget ) : forEachAccumulated( - shouldSetEventType, + JSCompiler_temp, accumulateTwoPhaseDispatchesSingle ); b: { - JSCompiler_temp = shouldSetEventType._dispatchListeners; - targetInst = shouldSetEventType._dispatchInstances; - if (Array.isArray(JSCompiler_temp)) + shouldSetEventType = JSCompiler_temp._dispatchListeners; + targetInst = JSCompiler_temp._dispatchInstances; + if (Array.isArray(shouldSetEventType)) for ( depthA = 0; - depthA < JSCompiler_temp.length && - !shouldSetEventType.isPropagationStopped(); + depthA < shouldSetEventType.length && + !JSCompiler_temp.isPropagationStopped(); depthA++ ) { if ( - JSCompiler_temp[depthA](shouldSetEventType, targetInst[depthA]) + shouldSetEventType[depthA](JSCompiler_temp, targetInst[depthA]) ) { - JSCompiler_temp = targetInst[depthA]; + shouldSetEventType = targetInst[depthA]; break b; } } else if ( - JSCompiler_temp && - JSCompiler_temp(shouldSetEventType, targetInst) + shouldSetEventType && + shouldSetEventType(JSCompiler_temp, targetInst) ) { - JSCompiler_temp = targetInst; + shouldSetEventType = targetInst; break b; } - JSCompiler_temp = null; + shouldSetEventType = null; } - shouldSetEventType._dispatchInstances = null; - shouldSetEventType._dispatchListeners = null; - shouldSetEventType.isPersistent() || - shouldSetEventType.constructor.release(shouldSetEventType); - if (JSCompiler_temp && JSCompiler_temp !== responderInst) + JSCompiler_temp._dispatchInstances = null; + JSCompiler_temp._dispatchListeners = null; + JSCompiler_temp.isPersistent() || + JSCompiler_temp.constructor.release(JSCompiler_temp); + if (shouldSetEventType && shouldSetEventType !== responderInst) if ( - ((shouldSetEventType = ResponderSyntheticEvent.getPooled( + ((JSCompiler_temp = ResponderSyntheticEvent.getPooled( eventTypes.responderGrant, - JSCompiler_temp, + shouldSetEventType, nativeEvent, nativeEventTarget )), - (shouldSetEventType.touchHistory = + (JSCompiler_temp.touchHistory = ResponderTouchHistoryStore.touchHistory), forEachAccumulated( - shouldSetEventType, + JSCompiler_temp, accumulateDirectDispatchesSingle ), - (targetInst = !0 === executeDirectDispatch(shouldSetEventType)), + (targetInst = !0 === executeDirectDispatch(JSCompiler_temp)), responderInst) ) if ( @@ -636,13 +658,13 @@ var ResponderEventPlugin = { forEachAccumulated(depthA, accumulateDirectDispatchesSingle); var JSCompiler_temp$jscomp$0 = accumulate( JSCompiler_temp$jscomp$0, - [shouldSetEventType, depthA] + [JSCompiler_temp, depthA] ); - changeResponder(JSCompiler_temp, targetInst); + changeResponder(shouldSetEventType, targetInst); } else (shouldSetEventType = ResponderSyntheticEvent.getPooled( eventTypes.responderReject, - JSCompiler_temp, + shouldSetEventType, nativeEvent, nativeEventTarget )), @@ -659,9 +681,9 @@ var ResponderEventPlugin = { else (JSCompiler_temp$jscomp$0 = accumulate( JSCompiler_temp$jscomp$0, - shouldSetEventType + JSCompiler_temp )), - changeResponder(JSCompiler_temp, targetInst); + changeResponder(shouldSetEventType, targetInst); else JSCompiler_temp$jscomp$0 = null; } else JSCompiler_temp$jscomp$0 = null; shouldSetEventType = responderInst && isStartish(topLevelType); @@ -789,6 +811,7 @@ function recomputePluginOrdering() { for (var eventName in pluginIndex) { var JSCompiler_inline_result = void 0; var dispatchConfig = pluginIndex[eventName], + pluginModule$jscomp$0 = pluginModule, eventName$jscomp$0 = eventName; if (eventNameDispatchConfigs.hasOwnProperty(eventName$jscomp$0)) throw Error( @@ -805,7 +828,7 @@ function recomputePluginOrdering() { ) && publishRegistrationName( phasedRegistrationNames[JSCompiler_inline_result], - pluginModule, + pluginModule$jscomp$0, eventName$jscomp$0 ); JSCompiler_inline_result = !0; @@ -813,7 +836,7 @@ function recomputePluginOrdering() { dispatchConfig.registrationName ? (publishRegistrationName( dispatchConfig.registrationName, - pluginModule, + pluginModule$jscomp$0, eventName$jscomp$0 ), (JSCompiler_inline_result = !0)) @@ -841,75 +864,13 @@ function publishRegistrationName(registrationName, pluginModule) { } var plugins = [], eventNameDispatchConfigs = {}, - registrationNameModules = {}; -function getListener$1(inst, registrationName) { - inst = inst.stateNode; - if (null === inst) return null; - inst = getFiberCurrentPropsFromNode(inst); - if (null === inst) return null; - if ((inst = inst[registrationName]) && "function" !== typeof inst) - throw Error( - "Expected `" + - registrationName + - "` listener to be a function, instead got a value of `" + - typeof inst + - "` type." - ); - return inst; -} -var customBubblingEventTypes = + registrationNameModules = {}, + customBubblingEventTypes = ReactNativePrivateInterface.ReactNativeViewConfigRegistry .customBubblingEventTypes, customDirectEventTypes = ReactNativePrivateInterface.ReactNativeViewConfigRegistry .customDirectEventTypes; -function accumulateDirectionalDispatches$1(inst, phase, event) { - if ( - (phase = getListener$1( - inst, - event.dispatchConfig.phasedRegistrationNames[phase] - )) - ) - (event._dispatchListeners = accumulateInto( - event._dispatchListeners, - phase - )), - (event._dispatchInstances = accumulateInto( - event._dispatchInstances, - inst - )); -} -function accumulateTwoPhaseDispatchesSingle$1(event) { - if (event && event.dispatchConfig.phasedRegistrationNames) { - for (var inst = event._targetInst, path = []; inst; ) { - path.push(inst); - do inst = inst.return; - while (inst && 5 !== inst.tag); - inst = inst ? inst : null; - } - for (inst = path.length; 0 < inst--; ) - accumulateDirectionalDispatches$1(path[inst], "captured", event); - for (inst = 0; inst < path.length; inst++) - accumulateDirectionalDispatches$1(path[inst], "bubbled", event); - } -} -function accumulateDirectDispatchesSingle$1(event) { - if (event && event.dispatchConfig.registrationName) { - var inst = event._targetInst; - if (inst && event && event.dispatchConfig.registrationName) { - var listener = getListener$1(inst, event.dispatchConfig.registrationName); - listener && - ((event._dispatchListeners = accumulateInto( - event._dispatchListeners, - listener - )), - (event._dispatchInstances = accumulateInto( - event._dispatchInstances, - inst - ))); - } - } -} if (eventPluginOrder) throw Error( "EventPluginRegistry: Cannot inject event plugin ordering more than once. You are likely trying to load more than one copy of React." @@ -919,7 +880,7 @@ eventPluginOrder = Array.prototype.slice.call([ "ReactNativeBridgeEventPlugin" ]); recomputePluginOrdering(); -var injectedNamesToPlugins$jscomp$inline_228 = { +var injectedNamesToPlugins$jscomp$inline_94 = { ResponderEventPlugin: ResponderEventPlugin, ReactNativeBridgeEventPlugin: { eventTypes: {}, @@ -943,45 +904,42 @@ var injectedNamesToPlugins$jscomp$inline_228 = { nativeEventTarget ); if (bubbleDispatchConfig) - forEachAccumulated( - topLevelType, - accumulateTwoPhaseDispatchesSingle$1 - ); + forEachAccumulated(topLevelType, accumulateTwoPhaseDispatchesSingle); else if (directDispatchConfig) - forEachAccumulated(topLevelType, accumulateDirectDispatchesSingle$1); + forEachAccumulated(topLevelType, accumulateDirectDispatchesSingle); else return null; return topLevelType; } } }, - isOrderingDirty$jscomp$inline_229 = !1, - pluginName$jscomp$inline_230; -for (pluginName$jscomp$inline_230 in injectedNamesToPlugins$jscomp$inline_228) + isOrderingDirty$jscomp$inline_95 = !1, + pluginName$jscomp$inline_96; +for (pluginName$jscomp$inline_96 in injectedNamesToPlugins$jscomp$inline_94) if ( - injectedNamesToPlugins$jscomp$inline_228.hasOwnProperty( - pluginName$jscomp$inline_230 + injectedNamesToPlugins$jscomp$inline_94.hasOwnProperty( + pluginName$jscomp$inline_96 ) ) { - var pluginModule$jscomp$inline_231 = - injectedNamesToPlugins$jscomp$inline_228[pluginName$jscomp$inline_230]; + var pluginModule$jscomp$inline_97 = + injectedNamesToPlugins$jscomp$inline_94[pluginName$jscomp$inline_96]; if ( - !namesToPlugins.hasOwnProperty(pluginName$jscomp$inline_230) || - namesToPlugins[pluginName$jscomp$inline_230] !== - pluginModule$jscomp$inline_231 + !namesToPlugins.hasOwnProperty(pluginName$jscomp$inline_96) || + namesToPlugins[pluginName$jscomp$inline_96] !== + pluginModule$jscomp$inline_97 ) { - if (namesToPlugins[pluginName$jscomp$inline_230]) + if (namesToPlugins[pluginName$jscomp$inline_96]) throw Error( "EventPluginRegistry: Cannot inject two different event plugins using the same name, `" + - pluginName$jscomp$inline_230 + + pluginName$jscomp$inline_96 + "`." ); namesToPlugins[ - pluginName$jscomp$inline_230 - ] = pluginModule$jscomp$inline_231; - isOrderingDirty$jscomp$inline_229 = !0; + pluginName$jscomp$inline_96 + ] = pluginModule$jscomp$inline_97; + isOrderingDirty$jscomp$inline_95 = !0; } } -isOrderingDirty$jscomp$inline_229 && recomputePluginOrdering(); +isOrderingDirty$jscomp$inline_95 && recomputePluginOrdering(); var instanceCache = new Map(), instanceProps = new Map(); function getInstanceFromTag(tag) { @@ -1027,41 +985,34 @@ function _receiveRootNodeIDEvent(rootNodeID, topLevelType, nativeEventParam) { target = null; null != inst && (target = inst.stateNode); batchedUpdates(function() { - var JSCompiler_inline_result = target; - for ( - var events = null, legacyPlugins = plugins, i = 0; - i < legacyPlugins.length; - i++ - ) { - var possiblePlugin = legacyPlugins[i]; + var events = target; + for (var events$jscomp$0 = null, i = 0; i < plugins.length; i++) { + var possiblePlugin = plugins[i]; possiblePlugin && (possiblePlugin = possiblePlugin.extractEvents( topLevelType, inst, nativeEvent, - JSCompiler_inline_result + events, + 1 )) && - (events = accumulateInto(events, possiblePlugin)); + (events$jscomp$0 = accumulateInto(events$jscomp$0, possiblePlugin)); } - JSCompiler_inline_result = events; - null !== JSCompiler_inline_result && - (eventQueue = accumulateInto(eventQueue, JSCompiler_inline_result)); - JSCompiler_inline_result = eventQueue; + events = events$jscomp$0; + null !== events && (eventQueue = accumulateInto(eventQueue, events)); + events = eventQueue; eventQueue = null; - if (JSCompiler_inline_result) { - forEachAccumulated( - JSCompiler_inline_result, - executeDispatchesAndReleaseTopLevel - ); + if (events) { + forEachAccumulated(events, executeDispatchesAndReleaseTopLevel); if (eventQueue) throw Error( "processEventQueue(): Additional events were enqueued while processing an event queue. Support for this has not yet been implemented." ); if (hasRethrowError) - throw ((JSCompiler_inline_result = rethrowError), + throw ((events = rethrowError), (hasRethrowError = !1), (rethrowError = null), - JSCompiler_inline_result); + events); } }); } @@ -1076,13 +1027,13 @@ ReactNativePrivateInterface.RCTEventEmitter.register({ ) { var JSCompiler_temp = []; for (var i = 0; i < changedIndices.length; i++) { - var index$0 = changedIndices[i]; - JSCompiler_temp.push(touches[index$0]); - touches[index$0] = null; + var index = changedIndices[i]; + JSCompiler_temp.push(touches[index]); + touches[index] = null; } for (i = changedIndices = 0; i < touches.length; i++) - (index$0 = touches[i]), - null !== index$0 && (touches[changedIndices++] = index$0); + (index = touches[i]), + null !== index && (touches[changedIndices++] = index); touches.length = changedIndices; } else for (JSCompiler_temp = [], i = 0; i < changedIndices.length; i++) @@ -1095,10 +1046,10 @@ ReactNativePrivateInterface.RCTEventEmitter.register({ i = JSCompiler_temp[changedIndices]; i.changedTouches = JSCompiler_temp; i.touches = touches; - index$0 = null; + index = null; var target = i.target; - null === target || void 0 === target || 1 > target || (index$0 = target); - _receiveRootNodeIDEvent(index$0, eventTopLevelType, i); + null === target || void 0 === target || 1 > target || (index = target); + _receiveRootNodeIDEvent(index, eventTopLevelType, i); } } }); @@ -1124,44 +1075,31 @@ ResponderEventPlugin.injection.injectGlobalResponderHandler({ } }); var ReactSharedInternals = - React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED, - REACT_ELEMENT_TYPE = 60103, - REACT_PORTAL_TYPE = 60106, - REACT_FRAGMENT_TYPE = 60107, - REACT_STRICT_MODE_TYPE = 60108, - REACT_PROFILER_TYPE = 60114, - REACT_PROVIDER_TYPE = 60109, - REACT_CONTEXT_TYPE = 60110, - REACT_FORWARD_REF_TYPE = 60112, - REACT_SUSPENSE_TYPE = 60113, - REACT_SUSPENSE_LIST_TYPE = 60120, - REACT_MEMO_TYPE = 60115, - REACT_LAZY_TYPE = 60116, - REACT_BLOCK_TYPE = 60121, - REACT_DEBUG_TRACING_MODE_TYPE = 60129, - REACT_OFFSCREEN_TYPE = 60130, - REACT_LEGACY_HIDDEN_TYPE = 60131; -if ("function" === typeof Symbol && Symbol.for) { - var symbolFor = Symbol.for; - REACT_ELEMENT_TYPE = symbolFor("react.element"); - REACT_PORTAL_TYPE = symbolFor("react.portal"); - REACT_FRAGMENT_TYPE = symbolFor("react.fragment"); - REACT_STRICT_MODE_TYPE = symbolFor("react.strict_mode"); - REACT_PROFILER_TYPE = symbolFor("react.profiler"); - REACT_PROVIDER_TYPE = symbolFor("react.provider"); - REACT_CONTEXT_TYPE = symbolFor("react.context"); - REACT_FORWARD_REF_TYPE = symbolFor("react.forward_ref"); - REACT_SUSPENSE_TYPE = symbolFor("react.suspense"); - REACT_SUSPENSE_LIST_TYPE = symbolFor("react.suspense_list"); - REACT_MEMO_TYPE = symbolFor("react.memo"); - REACT_LAZY_TYPE = symbolFor("react.lazy"); - REACT_BLOCK_TYPE = symbolFor("react.block"); - symbolFor("react.scope"); - REACT_DEBUG_TRACING_MODE_TYPE = symbolFor("react.debug_trace_mode"); - REACT_OFFSCREEN_TYPE = symbolFor("react.offscreen"); - REACT_LEGACY_HIDDEN_TYPE = symbolFor("react.legacy_hidden"); -} -var MAYBE_ITERATOR_SYMBOL = "function" === typeof Symbol && Symbol.iterator; + React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED; +ReactSharedInternals.hasOwnProperty("ReactCurrentDispatcher") || + (ReactSharedInternals.ReactCurrentDispatcher = { current: null }); +ReactSharedInternals.hasOwnProperty("ReactCurrentBatchConfig") || + (ReactSharedInternals.ReactCurrentBatchConfig = { suspense: null }); +var hasSymbol = "function" === typeof Symbol && Symbol.for, + REACT_ELEMENT_TYPE = hasSymbol ? Symbol.for("react.element") : 60103, + REACT_PORTAL_TYPE = hasSymbol ? Symbol.for("react.portal") : 60106, + REACT_FRAGMENT_TYPE = hasSymbol ? Symbol.for("react.fragment") : 60107, + REACT_STRICT_MODE_TYPE = hasSymbol ? Symbol.for("react.strict_mode") : 60108, + REACT_PROFILER_TYPE = hasSymbol ? Symbol.for("react.profiler") : 60114, + REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for("react.provider") : 60109, + REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for("react.context") : 60110, + REACT_CONCURRENT_MODE_TYPE = hasSymbol + ? Symbol.for("react.concurrent_mode") + : 60111, + REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for("react.forward_ref") : 60112, + REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for("react.suspense") : 60113, + REACT_SUSPENSE_LIST_TYPE = hasSymbol + ? Symbol.for("react.suspense_list") + : 60120, + REACT_MEMO_TYPE = hasSymbol ? Symbol.for("react.memo") : 60115, + REACT_LAZY_TYPE = hasSymbol ? Symbol.for("react.lazy") : 60116, + REACT_BLOCK_TYPE = hasSymbol ? Symbol.for("react.block") : 60121, + MAYBE_ITERATOR_SYMBOL = "function" === typeof Symbol && Symbol.iterator; function getIteratorFn(maybeIterable) { if (null === maybeIterable || "object" !== typeof maybeIterable) return null; maybeIterable = @@ -1169,6 +1107,27 @@ function getIteratorFn(maybeIterable) { maybeIterable["@@iterator"]; return "function" === typeof maybeIterable ? maybeIterable : null; } +function initializeLazyComponentType(lazyComponent) { + if (-1 === lazyComponent._status) { + var ctor = lazyComponent._result; + ctor || (ctor = lazyComponent._ctor); + ctor = ctor(); + lazyComponent._status = 0; + lazyComponent._result = ctor; + ctor.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)); + } + ); + } +} function getComponentName(type) { if (null == type) return null; if ("function" === typeof type) return type.displayName || type.name || null; @@ -1203,13 +1162,10 @@ function getComponentName(type) { case REACT_MEMO_TYPE: return getComponentName(type.type); case REACT_BLOCK_TYPE: - return getComponentName(type._render); + return getComponentName(type.render); case REACT_LAZY_TYPE: - innerType = type._payload; - type = type._init; - try { - return getComponentName(type(innerType)); - } catch (x) {} + if ((type = 1 === type._status ? type._result : null)) + return getComponentName(type); } return null; } @@ -1261,36 +1217,36 @@ function findCurrentFiberUsingSlowPath(fiber) { } if (a.return !== b.return) (a = parentA), (b = parentB); else { - for (var didFindChild = !1, child$1 = parentA.child; child$1; ) { - if (child$1 === a) { + for (var didFindChild = !1, _child = parentA.child; _child; ) { + if (_child === a) { didFindChild = !0; a = parentA; b = parentB; break; } - if (child$1 === b) { + if (_child === b) { didFindChild = !0; b = parentA; a = parentB; break; } - child$1 = child$1.sibling; + _child = _child.sibling; } if (!didFindChild) { - for (child$1 = parentB.child; child$1; ) { - if (child$1 === a) { + for (_child = parentB.child; _child; ) { + if (_child === a) { didFindChild = !0; a = parentB; b = parentA; break; } - if (child$1 === b) { + if (_child === b) { didFindChild = !0; b = parentB; a = parentA; break; } - child$1 = child$1.sibling; + _child = _child.sibling; } if (!didFindChild) throw Error( @@ -1325,18 +1281,6 @@ function findCurrentHostFiber(parent) { } return null; } -function doesFiberContain(parentFiber, childFiber) { - for ( - var parentFiberAlternate = parentFiber.alternate; - null !== childFiber; - - ) { - if (childFiber === parentFiber || childFiber === parentFiberAlternate) - return !0; - childFiber = childFiber.return; - } - return !1; -} var emptyObject = {}, removedKeys = null, removedKeyCount = 0, @@ -1541,19 +1485,19 @@ function diffProperties(updatePayload, prevProps, nextProps, validAttributes) { ), (removedKeys = null)); } - for (var propKey$3 in prevProps) - void 0 === nextProps[propKey$3] && - (!(attributeConfig = validAttributes[propKey$3]) || - (updatePayload && void 0 !== updatePayload[propKey$3]) || - ((prevProp = prevProps[propKey$3]), + for (var _propKey in prevProps) + void 0 === nextProps[_propKey] && + (!(attributeConfig = validAttributes[_propKey]) || + (updatePayload && void 0 !== updatePayload[_propKey]) || + ((prevProp = prevProps[_propKey]), void 0 !== prevProp && ("object" !== typeof attributeConfig || "function" === typeof attributeConfig.diff || "function" === typeof attributeConfig.process - ? (((updatePayload || (updatePayload = {}))[propKey$3] = null), + ? (((updatePayload || (updatePayload = {}))[_propKey] = null), removedKeys || (removedKeys = {}), - removedKeys[propKey$3] || - ((removedKeys[propKey$3] = !0), removedKeyCount++)) + removedKeys[_propKey] || + ((removedKeys[_propKey] = !0), removedKeyCount++)) : (updatePayload = clearNestedProperty( updatePayload, prevProp, @@ -1662,22 +1606,9 @@ function finalizeInitialChildren(parentInstance) { return !1; } var scheduleTimeout = setTimeout, - cancelTimeout = clearTimeout; -function describeComponentFrame(name, source, ownerName) { - source = ""; - ownerName && (source = " (created by " + ownerName + ")"); - return "\n in " + (name || "Unknown") + source; -} -function describeFunctionComponentFrame(fn, source) { - return fn - ? describeComponentFrame(fn.displayName || fn.name || null, source, null) - : ""; -} -var valueStack = [], + cancelTimeout = clearTimeout, + valueStack = [], index = -1; -function createCursor(defaultValue) { - return { current: defaultValue }; -} function pop(cursor) { 0 > index || ((cursor.current = valueStack[index]), (valueStack[index] = null), index--); @@ -1688,8 +1619,8 @@ function push(cursor, value) { cursor.current = value; } var emptyContextObject = {}, - contextStackCursor = createCursor(emptyContextObject), - didPerformWorkStackCursor = createCursor(!1), + contextStackCursor = { current: emptyContextObject }, + didPerformWorkStackCursor = { current: !1 }, previousContext = emptyContextObject; function getMaskedContext(workInProgress, unmaskedContext) { var contextTypes = workInProgress.type.contextTypes; @@ -1769,220 +1700,11 @@ function invalidateContextProvider(workInProgress, type, didChange) { : pop(didPerformWorkStackCursor); push(didPerformWorkStackCursor, didChange); } -var rendererID = null, - injectedHook = null, - Scheduler_now = Scheduler.unstable_now; -Scheduler_now(); -var return_highestLanePriority = 10; -function getHighestPriorityLanes(lanes) { - if (0 !== (1 & lanes)) return (return_highestLanePriority = 17), 1; - if (0 !== (2 & lanes)) return (return_highestLanePriority = 16), 2; - if (0 !== (4 & lanes)) return (return_highestLanePriority = 15), 4; - var inputDiscreteLanes = 24 & lanes; - if (0 !== inputDiscreteLanes) - return (return_highestLanePriority = 14), inputDiscreteLanes; - if (0 !== (lanes & 32)) return (return_highestLanePriority = 13), 32; - inputDiscreteLanes = 192 & lanes; - if (0 !== inputDiscreteLanes) - return (return_highestLanePriority = 12), inputDiscreteLanes; - if (0 !== (lanes & 256)) return (return_highestLanePriority = 11), 256; - inputDiscreteLanes = 3584 & lanes; - if (0 !== inputDiscreteLanes) - return (return_highestLanePriority = 10), inputDiscreteLanes; - if (0 !== (lanes & 4096)) return (return_highestLanePriority = 9), 4096; - inputDiscreteLanes = 122880 & lanes; - if (0 !== inputDiscreteLanes) - return (return_highestLanePriority = 8), inputDiscreteLanes; - if (0 !== (lanes & 131072)) return (return_highestLanePriority = 7), 131072; - inputDiscreteLanes = 3932160 & lanes; - if (0 !== inputDiscreteLanes) - return (return_highestLanePriority = 6), inputDiscreteLanes; - inputDiscreteLanes = 62914560 & lanes; - if (0 !== inputDiscreteLanes) - return (return_highestLanePriority = 5), inputDiscreteLanes; - if (lanes & 67108864) return (return_highestLanePriority = 4), 67108864; - if (0 !== (lanes & 134217728)) - return (return_highestLanePriority = 3), 134217728; - inputDiscreteLanes = 805306368 & lanes; - if (0 !== inputDiscreteLanes) - return (return_highestLanePriority = 2), inputDiscreteLanes; - if (0 !== (1073741824 & lanes)) - return (return_highestLanePriority = 1), 1073741824; - return_highestLanePriority = 10; - return lanes; -} -function schedulerPriorityToLanePriority(schedulerPriorityLevel) { - switch (schedulerPriorityLevel) { - case 99: - return 17; - case 98: - return 12; - case 97: - case 96: - return 10; - case 95: - return 2; - default: - return 0; - } -} -function lanePriorityToSchedulerPriority(lanePriority) { - switch (lanePriority) { - case 17: - case 16: - return 99; - case 15: - case 14: - case 13: - case 12: - return 98; - case 11: - case 10: - case 9: - case 8: - case 7: - case 6: - case 4: - case 5: - return 97; - case 3: - case 2: - case 1: - return 95; - case 0: - return 90; - default: - throw Error( - "Invalid update priority: " + lanePriority + ". This is a bug in React." - ); - } -} -function getNextLanes(root, wipLanes) { - var pendingLanes = root.pendingLanes; - if (0 === pendingLanes) return (return_highestLanePriority = 0); - var nextLanes = 0, - nextLanePriority = 0, - expiredLanes = root.expiredLanes, - suspendedLanes = root.suspendedLanes, - pingedLanes = root.pingedLanes; - if (0 !== expiredLanes) - (nextLanes = expiredLanes), - (nextLanePriority = return_highestLanePriority = 17); - else if (((expiredLanes = pendingLanes & 134217727), 0 !== expiredLanes)) { - var nonIdleUnblockedLanes = expiredLanes & ~suspendedLanes; - 0 !== nonIdleUnblockedLanes - ? ((nextLanes = getHighestPriorityLanes(nonIdleUnblockedLanes)), - (nextLanePriority = return_highestLanePriority)) - : ((pingedLanes &= expiredLanes), - 0 !== pingedLanes && - ((nextLanes = getHighestPriorityLanes(pingedLanes)), - (nextLanePriority = return_highestLanePriority))); - } else - (expiredLanes = pendingLanes & ~suspendedLanes), - 0 !== expiredLanes - ? ((nextLanes = getHighestPriorityLanes(expiredLanes)), - (nextLanePriority = return_highestLanePriority)) - : 0 !== pingedLanes && - ((nextLanes = getHighestPriorityLanes(pingedLanes)), - (nextLanePriority = return_highestLanePriority)); - if (0 === nextLanes) return 0; - nextLanes = 31 - clz32(nextLanes); - nextLanes = pendingLanes & (((0 > nextLanes ? 0 : 1 << nextLanes) << 1) - 1); - if ( - 0 !== wipLanes && - wipLanes !== nextLanes && - 0 === (wipLanes & suspendedLanes) - ) { - getHighestPriorityLanes(wipLanes); - if (nextLanePriority <= return_highestLanePriority) return wipLanes; - return_highestLanePriority = nextLanePriority; - } - wipLanes = root.entangledLanes; - if (0 !== wipLanes) - for (root = root.entanglements, wipLanes &= nextLanes; 0 < wipLanes; ) - (pendingLanes = 31 - clz32(wipLanes)), - (nextLanePriority = 1 << pendingLanes), - (nextLanes |= root[pendingLanes]), - (wipLanes &= ~nextLanePriority); - return nextLanes; -} -function getMostRecentEventTime(root, lanes) { - root = root.eventTimes; - for (var mostRecentEventTime = -1; 0 < lanes; ) { - var index$6 = 31 - clz32(lanes), - lane = 1 << index$6; - index$6 = root[index$6]; - index$6 > mostRecentEventTime && (mostRecentEventTime = index$6); - lanes &= ~lane; - } - return mostRecentEventTime; -} -function getLanesToRetrySynchronouslyOnError(root) { - root = root.pendingLanes & -1073741825; - return 0 !== root ? root : root & 1073741824 ? 1073741824 : 0; -} -function findUpdateLane(lanePriority, wipLanes) { - switch (lanePriority) { - case 17: - return 1; - case 16: - return 2; - case 14: - return ( - (lanePriority = getHighestPriorityLane(24 & ~wipLanes)), - 0 === lanePriority ? findUpdateLane(12, wipLanes) : lanePriority - ); - case 12: - return ( - (lanePriority = getHighestPriorityLane(192 & ~wipLanes)), - 0 === lanePriority ? findUpdateLane(10, wipLanes) : lanePriority - ); - case 10: - return ( - (lanePriority = getHighestPriorityLane(3584 & ~wipLanes)), - 0 === lanePriority && - ((lanePriority = getHighestPriorityLane(4055040 & ~wipLanes)), - 0 === lanePriority && (lanePriority = 512)), - lanePriority - ); - case 2: - return ( - (wipLanes = getHighestPriorityLane(805306368 & ~wipLanes)), - 0 === wipLanes && (wipLanes = 268435456), - wipLanes - ); - } - throw Error( - "Invalid update priority: " + lanePriority + ". This is a bug in React." - ); -} -function getHighestPriorityLane(lanes) { - return lanes & -lanes; -} -function pickArbitraryLane(lanes) { - return lanes & -lanes; -} -function markRootUpdated(root, updateLane, eventTime) { - root.pendingLanes |= updateLane; - var higherPriorityLanes = updateLane - 1; - root.suspendedLanes &= higherPriorityLanes; - root.pingedLanes &= higherPriorityLanes; - root = root.eventTimes; - updateLane = 31 - clz32(updateLane); - root[updateLane] = eventTime; -} -var clz32 = Math.clz32 ? Math.clz32 : clz32Fallback, - log = Math.log, - LN2 = Math.LN2; -function clz32Fallback(lanes) { - return 0 === lanes ? 32 : (31 - ((log(lanes) / LN2) | 0)) | 0; -} var Scheduler_runWithPriority = Scheduler.unstable_runWithPriority, Scheduler_scheduleCallback = Scheduler.unstable_scheduleCallback, Scheduler_cancelCallback = Scheduler.unstable_cancelCallback, - Scheduler_shouldYield = Scheduler.unstable_shouldYield, Scheduler_requestPaint = Scheduler.unstable_requestPaint, - Scheduler_now$1 = Scheduler.unstable_now, + Scheduler_now = Scheduler.unstable_now, Scheduler_getCurrentPriorityLevel = Scheduler.unstable_getCurrentPriorityLevel, Scheduler_ImmediatePriority = Scheduler.unstable_ImmediatePriority, @@ -1991,17 +1713,18 @@ var Scheduler_runWithPriority = Scheduler.unstable_runWithPriority, Scheduler_LowPriority = Scheduler.unstable_LowPriority, Scheduler_IdlePriority = Scheduler.unstable_IdlePriority, fakeCallbackNode = {}, + shouldYield = Scheduler.unstable_shouldYield, requestPaint = void 0 !== Scheduler_requestPaint ? Scheduler_requestPaint : function() {}, syncQueue = null, immediateQueueCallbackNode = null, isFlushingSyncQueue = !1, - initialTimeMs$1 = Scheduler_now$1(), + initialTimeMs = Scheduler_now(), now = - 1e4 > initialTimeMs$1 - ? Scheduler_now$1 + 1e4 > initialTimeMs + ? Scheduler_now : function() { - return Scheduler_now$1() - initialTimeMs$1; + return Scheduler_now() - initialTimeMs; }; function getCurrentPriorityLevel() { switch (Scheduler_getCurrentPriorityLevel()) { @@ -2043,6 +1766,16 @@ function scheduleCallback(reactPriorityLevel, callback, options) { reactPriorityLevel = reactPriorityToSchedulerPriority(reactPriorityLevel); return Scheduler_scheduleCallback(reactPriorityLevel, callback, options); } +function scheduleSyncCallback(callback) { + null === syncQueue + ? ((syncQueue = [callback]), + (immediateQueueCallbackNode = Scheduler_scheduleCallback( + Scheduler_ImmediatePriority, + flushSyncCallbackQueueImpl + ))) + : syncQueue.push(callback); + return fakeCallbackNode; +} function flushSyncCallbackQueue() { if (null !== immediateQueueCallbackNode) { var node = immediateQueueCallbackNode; @@ -2077,42 +1810,6 @@ function flushSyncCallbackQueueImpl() { } } } -function describeFiber(fiber) { - switch (fiber.tag) { - case 5: - return describeComponentFrame(fiber.type, null, null); - case 16: - return describeComponentFrame("Lazy", null, null); - case 13: - return describeComponentFrame("Suspense", null, null); - case 19: - return describeComponentFrame("SuspenseList", null, null); - case 0: - case 2: - case 15: - return describeFunctionComponentFrame(fiber.type, null); - case 11: - return describeFunctionComponentFrame(fiber.type.render, null); - case 22: - return describeFunctionComponentFrame(fiber.type._render, null); - case 1: - return (fiber = describeFunctionComponentFrame(fiber.type, null)), fiber; - default: - return ""; - } -} -function getStackByFiberInDevAndProd(workInProgress) { - try { - var info = ""; - do - (info += describeFiber(workInProgress)), - (workInProgress = workInProgress.return); - while (workInProgress); - return info; - } catch (x) { - return "\nError generating stack: " + x.message + "\n" + x.stack; - } -} function is(x, y) { return (x === y && (0 !== x || 1 / x === 1 / y)) || (x !== x && y !== y); } @@ -2138,6 +1835,43 @@ function shallowEqual(objA, objB) { return !1; return !0; } +var BEFORE_SLASH_RE = /^(.*)[\\\/]/; +function getStackByFiberInDevAndProd(workInProgress) { + var info = ""; + do { + a: switch (workInProgress.tag) { + case 3: + case 4: + case 6: + case 7: + case 10: + case 9: + var JSCompiler_inline_result = ""; + break a; + default: + var owner = workInProgress._debugOwner, + source = workInProgress._debugSource, + name = getComponentName(workInProgress.type); + JSCompiler_inline_result = null; + owner && (JSCompiler_inline_result = getComponentName(owner.type)); + owner = name; + name = ""; + source + ? (name = + " (at " + + source.fileName.replace(BEFORE_SLASH_RE, "") + + ":" + + source.lineNumber + + ")") + : JSCompiler_inline_result && + (name = " (created by " + JSCompiler_inline_result + ")"); + JSCompiler_inline_result = "\n in " + (owner || "Unknown") + name; + } + info += JSCompiler_inline_result; + workInProgress = workInProgress.return; + } while (workInProgress); + return info; +} function resolveDefaultProps(Component, baseProps) { if (Component && Component.defaultProps) { baseProps = Object.assign({}, baseProps); @@ -2145,11 +1879,10 @@ function resolveDefaultProps(Component, baseProps) { for (var propName in Component) void 0 === baseProps[propName] && (baseProps[propName] = Component[propName]); - return baseProps; } return baseProps; } -var valueCursor = createCursor(null), +var valueCursor = { current: null }, currentlyRenderingFiber = null, lastContextDependency = null, lastContextWithAllBitsObserved = null; @@ -2161,29 +1894,31 @@ function popProvider(providerFiber) { pop(valueCursor); providerFiber.type._context._currentValue = currentValue; } -function scheduleWorkOnParentPath(parent, renderLanes) { +function scheduleWorkOnParentPath(parent, renderExpirationTime) { for (; null !== parent; ) { var alternate = parent.alternate; - if ((parent.childLanes & renderLanes) === renderLanes) - if ( - null === alternate || - (alternate.childLanes & renderLanes) === renderLanes - ) - break; - else alternate.childLanes |= renderLanes; - else - (parent.childLanes |= renderLanes), - null !== alternate && (alternate.childLanes |= renderLanes); + if (parent.childExpirationTime < renderExpirationTime) + (parent.childExpirationTime = renderExpirationTime), + null !== alternate && + alternate.childExpirationTime < renderExpirationTime && + (alternate.childExpirationTime = renderExpirationTime); + else if ( + null !== alternate && + alternate.childExpirationTime < renderExpirationTime + ) + alternate.childExpirationTime = renderExpirationTime; + else break; parent = parent.return; } } -function prepareToReadContext(workInProgress, renderLanes) { +function prepareToReadContext(workInProgress, renderExpirationTime) { currentlyRenderingFiber = workInProgress; lastContextWithAllBitsObserved = lastContextDependency = null; workInProgress = workInProgress.dependencies; null !== workInProgress && null !== workInProgress.firstContext && - (0 !== (workInProgress.lanes & renderLanes) && (didReceiveUpdate = !0), + (workInProgress.expirationTime >= renderExpirationTime && + (didReceiveUpdate = !0), (workInProgress.firstContext = null)); } function readContext(context, observedBits) { @@ -2202,7 +1937,7 @@ function readContext(context, observedBits) { ); lastContextDependency = observedBits; currentlyRenderingFiber.dependencies = { - lanes: 0, + expirationTime: 0, firstContext: observedBits, responders: null }; @@ -2214,8 +1949,7 @@ var hasForceUpdate = !1; function initializeUpdateQueue(fiber) { fiber.updateQueue = { baseState: fiber.memoizedState, - firstBaseUpdate: null, - lastBaseUpdate: null, + baseQueue: null, shared: { pending: null }, effects: null }; @@ -2225,22 +1959,21 @@ function cloneUpdateQueue(current, workInProgress) { workInProgress.updateQueue === current && (workInProgress.updateQueue = { baseState: current.baseState, - firstBaseUpdate: current.firstBaseUpdate, - lastBaseUpdate: current.lastBaseUpdate, + baseQueue: current.baseQueue, shared: current.shared, effects: current.effects }); } -function createUpdate(eventTime, lane, suspenseConfig) { - return { - eventTime: eventTime, - lane: lane, +function createUpdate(expirationTime, suspenseConfig) { + expirationTime = { + expirationTime: expirationTime, suspenseConfig: suspenseConfig, tag: 0, payload: null, callback: null, next: null }; + return (expirationTime.next = expirationTime); } function enqueueUpdate(fiber, update) { fiber = fiber.updateQueue; @@ -2253,185 +1986,132 @@ function enqueueUpdate(fiber, update) { fiber.pending = update; } } -function enqueueCapturedUpdate(workInProgress, capturedUpdate) { - var queue = workInProgress.updateQueue, - current = workInProgress.alternate; - if ( - null !== current && - ((current = current.updateQueue), queue === current) - ) { - var newFirst = null, - newLast = null; - queue = queue.firstBaseUpdate; - if (null !== queue) { - do { - var clone = { - eventTime: queue.eventTime, - lane: queue.lane, - suspenseConfig: queue.suspenseConfig, - tag: queue.tag, - payload: queue.payload, - callback: queue.callback, - next: null - }; - null === newLast - ? (newFirst = newLast = clone) - : (newLast = newLast.next = clone); - queue = queue.next; - } while (null !== queue); - null === newLast - ? (newFirst = newLast = capturedUpdate) - : (newLast = newLast.next = capturedUpdate); - } else newFirst = newLast = capturedUpdate; - queue = { - baseState: current.baseState, - firstBaseUpdate: newFirst, - lastBaseUpdate: newLast, - shared: current.shared, - effects: current.effects - }; - workInProgress.updateQueue = queue; - return; - } - workInProgress = queue.lastBaseUpdate; - null === workInProgress - ? (queue.firstBaseUpdate = capturedUpdate) - : (workInProgress.next = capturedUpdate); - queue.lastBaseUpdate = capturedUpdate; +function enqueueCapturedUpdate(workInProgress, update) { + var current = workInProgress.alternate; + null !== current && cloneUpdateQueue(current, workInProgress); + workInProgress = workInProgress.updateQueue; + current = workInProgress.baseQueue; + null === current + ? ((workInProgress.baseQueue = update.next = update), + (update.next = update)) + : ((update.next = current.next), (current.next = update)); } function processUpdateQueue( workInProgress$jscomp$0, props, instance, - renderLanes + renderExpirationTime ) { var queue = workInProgress$jscomp$0.updateQueue; hasForceUpdate = !1; - var firstBaseUpdate = queue.firstBaseUpdate, - lastBaseUpdate = queue.lastBaseUpdate, + var baseQueue = queue.baseQueue, pendingQueue = queue.shared.pending; if (null !== pendingQueue) { - queue.shared.pending = null; - var lastPendingUpdate = pendingQueue, - firstPendingUpdate = lastPendingUpdate.next; - lastPendingUpdate.next = null; - null === lastBaseUpdate - ? (firstBaseUpdate = firstPendingUpdate) - : (lastBaseUpdate.next = firstPendingUpdate); - lastBaseUpdate = lastPendingUpdate; - var current = workInProgress$jscomp$0.alternate; - if (null !== current) { - current = current.updateQueue; - var currentLastBaseUpdate = current.lastBaseUpdate; - currentLastBaseUpdate !== lastBaseUpdate && - (null === currentLastBaseUpdate - ? (current.firstBaseUpdate = firstPendingUpdate) - : (currentLastBaseUpdate.next = firstPendingUpdate), - (current.lastBaseUpdate = lastPendingUpdate)); + if (null !== baseQueue) { + var baseFirst = baseQueue.next; + baseQueue.next = pendingQueue.next; + pendingQueue.next = baseFirst; } + baseQueue = pendingQueue; + queue.shared.pending = null; + baseFirst = workInProgress$jscomp$0.alternate; + null !== baseFirst && + ((baseFirst = baseFirst.updateQueue), + null !== baseFirst && (baseFirst.baseQueue = pendingQueue)); } - if (null !== firstBaseUpdate) { - currentLastBaseUpdate = queue.baseState; - lastBaseUpdate = 0; - current = firstPendingUpdate = lastPendingUpdate = null; - do { - pendingQueue = firstBaseUpdate.lane; - var updateEventTime = firstBaseUpdate.eventTime; - if ((renderLanes & pendingQueue) === pendingQueue) { - null !== current && - (current = current.next = { - eventTime: updateEventTime, - lane: 0, - suspenseConfig: firstBaseUpdate.suspenseConfig, - tag: firstBaseUpdate.tag, - payload: firstBaseUpdate.payload, - callback: firstBaseUpdate.callback, + if (null !== baseQueue) { + baseFirst = baseQueue.next; + var newState = queue.baseState, + newExpirationTime = 0, + newBaseState = null, + newBaseQueueFirst = null, + newBaseQueueLast = null; + if (null !== baseFirst) { + var update = baseFirst; + do { + pendingQueue = update.expirationTime; + if (pendingQueue < renderExpirationTime) { + var clone = { + expirationTime: update.expirationTime, + suspenseConfig: update.suspenseConfig, + tag: update.tag, + payload: update.payload, + callback: update.callback, next: null - }); - markRenderEventTimeAndConfig( - updateEventTime, - firstBaseUpdate.suspenseConfig - ); - a: { - var workInProgress = workInProgress$jscomp$0, - update = firstBaseUpdate; - pendingQueue = props; - updateEventTime = instance; - switch (update.tag) { - case 1: - workInProgress = update.payload; - if ("function" === typeof workInProgress) { - currentLastBaseUpdate = workInProgress.call( - updateEventTime, - currentLastBaseUpdate, - pendingQueue - ); + }; + null === newBaseQueueLast + ? ((newBaseQueueFirst = newBaseQueueLast = clone), + (newBaseState = newState)) + : (newBaseQueueLast = newBaseQueueLast.next = clone); + pendingQueue > newExpirationTime && + (newExpirationTime = pendingQueue); + } else { + null !== newBaseQueueLast && + (newBaseQueueLast = newBaseQueueLast.next = { + expirationTime: 1073741823, + suspenseConfig: update.suspenseConfig, + tag: update.tag, + payload: update.payload, + callback: update.callback, + next: null + }); + markRenderEventTimeAndConfig(pendingQueue, update.suspenseConfig); + a: { + var workInProgress = workInProgress$jscomp$0, + update$jscomp$0 = update; + pendingQueue = props; + clone = instance; + switch (update$jscomp$0.tag) { + case 1: + workInProgress = update$jscomp$0.payload; + if ("function" === typeof workInProgress) { + newState = workInProgress.call(clone, newState, pendingQueue); + break a; + } + newState = workInProgress; break a; - } - currentLastBaseUpdate = workInProgress; - break a; - case 3: - workInProgress.effectTag = - (workInProgress.effectTag & -4097) | 64; - case 0: - workInProgress = update.payload; - pendingQueue = - "function" === typeof workInProgress - ? workInProgress.call( - updateEventTime, - currentLastBaseUpdate, - pendingQueue - ) - : workInProgress; - if (null === pendingQueue || void 0 === pendingQueue) break a; - currentLastBaseUpdate = Object.assign( - {}, - currentLastBaseUpdate, - pendingQueue - ); - break a; - case 2: - hasForceUpdate = !0; + case 3: + workInProgress.effectTag = + (workInProgress.effectTag & -4097) | 64; + case 0: + workInProgress = update$jscomp$0.payload; + pendingQueue = + "function" === typeof workInProgress + ? workInProgress.call(clone, newState, pendingQueue) + : workInProgress; + if (null === pendingQueue || void 0 === pendingQueue) break a; + newState = Object.assign({}, newState, pendingQueue); + break a; + case 2: + hasForceUpdate = !0; + } } + null !== update.callback && + ((workInProgress$jscomp$0.effectTag |= 32), + (pendingQueue = queue.effects), + null === pendingQueue + ? (queue.effects = [update]) + : pendingQueue.push(update)); } - null !== firstBaseUpdate.callback && - ((workInProgress$jscomp$0.effectTag |= 32), - (pendingQueue = queue.effects), - null === pendingQueue - ? (queue.effects = [firstBaseUpdate]) - : pendingQueue.push(firstBaseUpdate)); - } else - (updateEventTime = { - eventTime: updateEventTime, - lane: pendingQueue, - suspenseConfig: firstBaseUpdate.suspenseConfig, - tag: firstBaseUpdate.tag, - payload: firstBaseUpdate.payload, - callback: firstBaseUpdate.callback, - next: null - }), - null === current - ? ((firstPendingUpdate = current = updateEventTime), - (lastPendingUpdate = currentLastBaseUpdate)) - : (current = current.next = updateEventTime), - (lastBaseUpdate |= pendingQueue); - firstBaseUpdate = firstBaseUpdate.next; - if (null === firstBaseUpdate) - if (((pendingQueue = queue.shared.pending), null === pendingQueue)) - break; - else - (firstBaseUpdate = pendingQueue.next), - (pendingQueue.next = null), - (queue.lastBaseUpdate = pendingQueue), - (queue.shared.pending = null); - } while (1); - null === current && (lastPendingUpdate = currentLastBaseUpdate); - queue.baseState = lastPendingUpdate; - queue.firstBaseUpdate = firstPendingUpdate; - queue.lastBaseUpdate = current; - workInProgressRootSkippedLanes |= lastBaseUpdate; - workInProgress$jscomp$0.lanes = lastBaseUpdate; - workInProgress$jscomp$0.memoizedState = currentLastBaseUpdate; + update = update.next; + if (null === update || update === baseFirst) + if (((pendingQueue = queue.shared.pending), null === pendingQueue)) + break; + else + (update = baseQueue.next = pendingQueue.next), + (pendingQueue.next = baseFirst), + (queue.baseQueue = baseQueue = pendingQueue), + (queue.shared.pending = null); + } while (1); + } + null === newBaseQueueLast + ? (newBaseState = newState) + : (newBaseQueueLast.next = newBaseQueueFirst); + queue.baseState = newBaseState; + queue.baseQueue = newBaseQueueLast; + markUnprocessedUpdateTime(newExpirationTime); + workInProgress$jscomp$0.expirationTime = newExpirationTime; + workInProgress$jscomp$0.memoizedState = newState; } } function commitUpdateQueue(finishedWork, finishedQueue, instance) { @@ -2471,54 +2151,54 @@ function applyDerivedStateFromProps( ? ctor : Object.assign({}, ctor, getDerivedStateFromProps); workInProgress.memoizedState = getDerivedStateFromProps; - 0 === workInProgress.lanes && + 0 === workInProgress.expirationTime && (workInProgress.updateQueue.baseState = getDerivedStateFromProps); } var classComponentUpdater = { isMounted: function(component) { - return (component = component._reactInternals) + return (component = component._reactInternalFiber) ? getNearestMountedFiber(component) === component : !1; }, enqueueSetState: function(inst, payload, callback) { - inst = inst._reactInternals; - var eventTime = requestEventTime(), - suspenseConfig = ReactCurrentBatchConfig.suspense, - lane = requestUpdateLane(inst, suspenseConfig); - suspenseConfig = createUpdate(eventTime, lane, suspenseConfig); + inst = inst._reactInternalFiber; + var currentTime = requestCurrentTimeForUpdate(), + suspenseConfig = ReactCurrentBatchConfig.suspense; + currentTime = computeExpirationForFiber(currentTime, inst, suspenseConfig); + suspenseConfig = createUpdate(currentTime, suspenseConfig); suspenseConfig.payload = payload; void 0 !== callback && null !== callback && (suspenseConfig.callback = callback); enqueueUpdate(inst, suspenseConfig); - scheduleUpdateOnFiber(inst, lane, eventTime); + scheduleWork(inst, currentTime); }, enqueueReplaceState: function(inst, payload, callback) { - inst = inst._reactInternals; - var eventTime = requestEventTime(), - suspenseConfig = ReactCurrentBatchConfig.suspense, - lane = requestUpdateLane(inst, suspenseConfig); - suspenseConfig = createUpdate(eventTime, lane, suspenseConfig); + inst = inst._reactInternalFiber; + var currentTime = requestCurrentTimeForUpdate(), + suspenseConfig = ReactCurrentBatchConfig.suspense; + currentTime = computeExpirationForFiber(currentTime, inst, suspenseConfig); + suspenseConfig = createUpdate(currentTime, suspenseConfig); suspenseConfig.tag = 1; suspenseConfig.payload = payload; void 0 !== callback && null !== callback && (suspenseConfig.callback = callback); enqueueUpdate(inst, suspenseConfig); - scheduleUpdateOnFiber(inst, lane, eventTime); + scheduleWork(inst, currentTime); }, enqueueForceUpdate: function(inst, callback) { - inst = inst._reactInternals; - var eventTime = requestEventTime(), - suspenseConfig = ReactCurrentBatchConfig.suspense, - lane = requestUpdateLane(inst, suspenseConfig); - suspenseConfig = createUpdate(eventTime, lane, suspenseConfig); + inst = inst._reactInternalFiber; + var currentTime = requestCurrentTimeForUpdate(), + suspenseConfig = ReactCurrentBatchConfig.suspense; + currentTime = computeExpirationForFiber(currentTime, inst, suspenseConfig); + suspenseConfig = createUpdate(currentTime, suspenseConfig); suspenseConfig.tag = 2; void 0 !== callback && null !== callback && (suspenseConfig.callback = callback); enqueueUpdate(inst, suspenseConfig); - scheduleUpdateOnFiber(inst, lane, eventTime); + scheduleWork(inst, currentTime); } }; function checkShouldComponentUpdate( @@ -2556,7 +2236,7 @@ function constructClassInstance(workInProgress, ctor, props) { null !== ctor.state && void 0 !== ctor.state ? ctor.state : null; ctor.updater = classComponentUpdater; workInProgress.stateNode = ctor; - ctor._reactInternals = workInProgress; + ctor._reactInternalFiber = workInProgress; isLegacyContextConsumer && ((workInProgress = workInProgress.stateNode), (workInProgress.__reactInternalMemoizedUnmaskedChildContext = unmaskedContext), @@ -2577,7 +2257,12 @@ function callComponentWillReceiveProps( instance.state !== workInProgress && classComponentUpdater.enqueueReplaceState(instance, instance.state, null); } -function mountClassInstance(workInProgress, ctor, newProps, renderLanes) { +function mountClassInstance( + workInProgress, + ctor, + newProps, + renderExpirationTime +) { var instance = workInProgress.stateNode; instance.props = newProps; instance.state = workInProgress.memoizedState; @@ -2590,7 +2275,7 @@ function mountClassInstance(workInProgress, ctor, newProps, renderLanes) { ? previousContext : contextStackCursor.current), (instance.context = getMaskedContext(workInProgress, contextType))); - processUpdateQueue(workInProgress, newProps, instance, renderLanes); + processUpdateQueue(workInProgress, newProps, instance, renderExpirationTime); instance.state = workInProgress.memoizedState; contextType = ctor.getDerivedStateFromProps; "function" === typeof contextType && @@ -2607,7 +2292,12 @@ function mountClassInstance(workInProgress, ctor, newProps, renderLanes) { instance.UNSAFE_componentWillMount(), ctor !== instance.state && classComponentUpdater.enqueueReplaceState(instance, instance.state, null), - processUpdateQueue(workInProgress, newProps, instance, renderLanes), + processUpdateQueue( + workInProgress, + newProps, + instance, + renderExpirationTime + ), (instance.state = workInProgress.memoizedState)); "function" === typeof instance.componentDidMount && (workInProgress.effectTag |= 4); @@ -2671,7 +2361,7 @@ function throwOnInvalidObjectType(returnFiber, newChild) { ("[object Object]" === Object.prototype.toString.call(newChild) ? "object with keys {" + Object.keys(newChild).join(", ") + "}" : newChild) + - "). If you meant to render a collection of children, use an array instead." + ")." ); } function ChildReconciler(shouldTrackSideEffects) { @@ -2727,10 +2417,14 @@ function ChildReconciler(shouldTrackSideEffects) { (newFiber.effectTag = 2); return newFiber; } - function updateTextNode(returnFiber, current, textContent, lanes) { + function updateTextNode(returnFiber, current, textContent, expirationTime) { if (null === current || 6 !== current.tag) return ( - (current = createFiberFromText(textContent, returnFiber.mode, lanes)), + (current = createFiberFromText( + textContent, + returnFiber.mode, + expirationTime + )), (current.return = returnFiber), current ); @@ -2738,27 +2432,27 @@ function ChildReconciler(shouldTrackSideEffects) { current.return = returnFiber; return current; } - function updateElement(returnFiber, current, element, lanes) { + function updateElement(returnFiber, current, element, expirationTime) { if (null !== current && current.elementType === element.type) return ( - (lanes = useFiber(current, element.props)), - (lanes.ref = coerceRef(returnFiber, current, element)), - (lanes.return = returnFiber), - lanes + (expirationTime = useFiber(current, element.props)), + (expirationTime.ref = coerceRef(returnFiber, current, element)), + (expirationTime.return = returnFiber), + expirationTime ); - lanes = createFiberFromTypeAndProps( + expirationTime = createFiberFromTypeAndProps( element.type, element.key, element.props, null, returnFiber.mode, - lanes + expirationTime ); - lanes.ref = coerceRef(returnFiber, current, element); - lanes.return = returnFiber; - return lanes; + expirationTime.ref = coerceRef(returnFiber, current, element); + expirationTime.return = returnFiber; + return expirationTime; } - function updatePortal(returnFiber, current, portal, lanes) { + function updatePortal(returnFiber, current, portal, expirationTime) { if ( null === current || 4 !== current.tag || @@ -2766,7 +2460,11 @@ function ChildReconciler(shouldTrackSideEffects) { current.stateNode.implementation !== portal.implementation ) return ( - (current = createFiberFromPortal(portal, returnFiber.mode, lanes)), + (current = createFiberFromPortal( + portal, + returnFiber.mode, + expirationTime + )), (current.return = returnFiber), current ); @@ -2774,13 +2472,13 @@ function ChildReconciler(shouldTrackSideEffects) { current.return = returnFiber; return current; } - function updateFragment(returnFiber, current, fragment, lanes, key) { + function updateFragment(returnFiber, current, fragment, expirationTime, key) { if (null === current || 7 !== current.tag) return ( (current = createFiberFromFragment( fragment, returnFiber.mode, - lanes, + expirationTime, key )), (current.return = returnFiber), @@ -2790,13 +2488,13 @@ function ChildReconciler(shouldTrackSideEffects) { current.return = returnFiber; return current; } - function createChild(returnFiber, newChild, lanes) { + function createChild(returnFiber, newChild, expirationTime) { if ("string" === typeof newChild || "number" === typeof newChild) return ( (newChild = createFiberFromText( "" + newChild, returnFiber.mode, - lanes + expirationTime )), (newChild.return = returnFiber), newChild @@ -2805,24 +2503,24 @@ function ChildReconciler(shouldTrackSideEffects) { switch (newChild.$$typeof) { case REACT_ELEMENT_TYPE: return ( - (lanes = createFiberFromTypeAndProps( + (expirationTime = createFiberFromTypeAndProps( newChild.type, newChild.key, newChild.props, null, returnFiber.mode, - lanes + expirationTime )), - (lanes.ref = coerceRef(returnFiber, null, newChild)), - (lanes.return = returnFiber), - lanes + (expirationTime.ref = coerceRef(returnFiber, null, newChild)), + (expirationTime.return = returnFiber), + expirationTime ); case REACT_PORTAL_TYPE: return ( (newChild = createFiberFromPortal( newChild, returnFiber.mode, - lanes + expirationTime )), (newChild.return = returnFiber), newChild @@ -2833,7 +2531,7 @@ function ChildReconciler(shouldTrackSideEffects) { (newChild = createFiberFromFragment( newChild, returnFiber.mode, - lanes, + expirationTime, null )), (newChild.return = returnFiber), @@ -2843,12 +2541,12 @@ function ChildReconciler(shouldTrackSideEffects) { } return null; } - function updateSlot(returnFiber, oldFiber, newChild, lanes) { + function updateSlot(returnFiber, oldFiber, newChild, expirationTime) { var key = null !== oldFiber ? oldFiber.key : null; if ("string" === typeof newChild || "number" === typeof newChild) return null !== key ? null - : updateTextNode(returnFiber, oldFiber, "" + newChild, lanes); + : updateTextNode(returnFiber, oldFiber, "" + newChild, expirationTime); if ("object" === typeof newChild && null !== newChild) { switch (newChild.$$typeof) { case REACT_ELEMENT_TYPE: @@ -2858,20 +2556,26 @@ function ChildReconciler(shouldTrackSideEffects) { returnFiber, oldFiber, newChild.props.children, - lanes, + expirationTime, key ) - : updateElement(returnFiber, oldFiber, newChild, lanes) + : updateElement(returnFiber, oldFiber, newChild, expirationTime) : null; case REACT_PORTAL_TYPE: return newChild.key === key - ? updatePortal(returnFiber, oldFiber, newChild, lanes) + ? updatePortal(returnFiber, oldFiber, newChild, expirationTime) : null; } if (isArray(newChild) || getIteratorFn(newChild)) return null !== key ? null - : updateFragment(returnFiber, oldFiber, newChild, lanes, null); + : updateFragment( + returnFiber, + oldFiber, + newChild, + expirationTime, + null + ); throwOnInvalidObjectType(returnFiber, newChild); } return null; @@ -2881,12 +2585,17 @@ function ChildReconciler(shouldTrackSideEffects) { returnFiber, newIdx, newChild, - lanes + expirationTime ) { if ("string" === typeof newChild || "number" === typeof newChild) return ( (existingChildren = existingChildren.get(newIdx) || null), - updateTextNode(returnFiber, existingChildren, "" + newChild, lanes) + updateTextNode( + returnFiber, + existingChildren, + "" + newChild, + expirationTime + ) ); if ("object" === typeof newChild && null !== newChild) { switch (newChild.$$typeof) { @@ -2901,10 +2610,15 @@ function ChildReconciler(shouldTrackSideEffects) { returnFiber, existingChildren, newChild.props.children, - lanes, + expirationTime, newChild.key ) - : updateElement(returnFiber, existingChildren, newChild, lanes) + : updateElement( + returnFiber, + existingChildren, + newChild, + expirationTime + ) ); case REACT_PORTAL_TYPE: return ( @@ -2912,13 +2626,24 @@ function ChildReconciler(shouldTrackSideEffects) { existingChildren.get( null === newChild.key ? newIdx : newChild.key ) || null), - updatePortal(returnFiber, existingChildren, newChild, lanes) + updatePortal( + returnFiber, + existingChildren, + newChild, + expirationTime + ) ); } if (isArray(newChild) || getIteratorFn(newChild)) return ( (existingChildren = existingChildren.get(newIdx) || null), - updateFragment(returnFiber, existingChildren, newChild, lanes, null) + updateFragment( + returnFiber, + existingChildren, + newChild, + expirationTime, + null + ) ); throwOnInvalidObjectType(returnFiber, newChild); } @@ -2928,7 +2653,7 @@ function ChildReconciler(shouldTrackSideEffects) { returnFiber, currentFirstChild, newChildren, - lanes + expirationTime ) { for ( var resultingFirstChild = null, @@ -2946,7 +2671,7 @@ function ChildReconciler(shouldTrackSideEffects) { returnFiber, oldFiber, newChildren[newIdx], - lanes + expirationTime ); if (null === newFiber) { null === oldFiber && (oldFiber = nextOldFiber); @@ -2969,7 +2694,11 @@ function ChildReconciler(shouldTrackSideEffects) { ); if (null === oldFiber) { for (; newIdx < newChildren.length; newIdx++) - (oldFiber = createChild(returnFiber, newChildren[newIdx], lanes)), + (oldFiber = createChild( + returnFiber, + newChildren[newIdx], + expirationTime + )), null !== oldFiber && ((currentFirstChild = placeChild( oldFiber, @@ -2992,7 +2721,7 @@ function ChildReconciler(shouldTrackSideEffects) { returnFiber, newIdx, newChildren[newIdx], - lanes + expirationTime )), null !== nextOldFiber && (shouldTrackSideEffects && @@ -3019,7 +2748,7 @@ function ChildReconciler(shouldTrackSideEffects) { returnFiber, currentFirstChild, newChildrenIterable, - lanes + expirationTime ) { var iteratorFn = getIteratorFn(newChildrenIterable); if ("function" !== typeof iteratorFn) @@ -3041,7 +2770,12 @@ function ChildReconciler(shouldTrackSideEffects) { oldFiber.index > newIdx ? ((nextOldFiber = oldFiber), (oldFiber = null)) : (nextOldFiber = oldFiber.sibling); - var newFiber = updateSlot(returnFiber, oldFiber, step.value, lanes); + var newFiber = updateSlot( + returnFiber, + oldFiber, + step.value, + expirationTime + ); if (null === newFiber) { null === oldFiber && (oldFiber = nextOldFiber); break; @@ -3061,7 +2795,7 @@ function ChildReconciler(shouldTrackSideEffects) { return deleteRemainingChildren(returnFiber, oldFiber), iteratorFn; if (null === oldFiber) { for (; !step.done; newIdx++, step = newChildrenIterable.next()) - (step = createChild(returnFiber, step.value, lanes)), + (step = createChild(returnFiber, step.value, expirationTime)), null !== step && ((currentFirstChild = placeChild(step, currentFirstChild, newIdx)), null === previousNewFiber @@ -3075,7 +2809,13 @@ function ChildReconciler(shouldTrackSideEffects) { !step.done; newIdx++, step = newChildrenIterable.next() ) - (step = updateFromMap(oldFiber, returnFiber, newIdx, step.value, lanes)), + (step = updateFromMap( + oldFiber, + returnFiber, + newIdx, + step.value, + expirationTime + )), null !== step && (shouldTrackSideEffects && null !== step.alternate && @@ -3091,7 +2831,7 @@ function ChildReconciler(shouldTrackSideEffects) { }); return iteratorFn; } - return function(returnFiber, currentFirstChild, newChild, lanes) { + return function(returnFiber, currentFirstChild, newChild, expirationTime) { var isUnkeyedTopLevelFragment = "object" === typeof newChild && null !== newChild && @@ -3157,26 +2897,26 @@ function ChildReconciler(shouldTrackSideEffects) { ? ((currentFirstChild = createFiberFromFragment( newChild.props.children, returnFiber.mode, - lanes, + expirationTime, newChild.key )), (currentFirstChild.return = returnFiber), (returnFiber = currentFirstChild)) - : ((lanes = createFiberFromTypeAndProps( + : ((expirationTime = createFiberFromTypeAndProps( newChild.type, newChild.key, newChild.props, null, returnFiber.mode, - lanes + expirationTime )), - (lanes.ref = coerceRef( + (expirationTime.ref = coerceRef( returnFiber, currentFirstChild, newChild )), - (lanes.return = returnFiber), - (returnFiber = lanes)); + (expirationTime.return = returnFiber), + (returnFiber = expirationTime)); } return placeSingleChild(returnFiber); case REACT_PORTAL_TYPE: @@ -3215,7 +2955,7 @@ function ChildReconciler(shouldTrackSideEffects) { currentFirstChild = createFiberFromPortal( newChild, returnFiber.mode, - lanes + expirationTime ); currentFirstChild.return = returnFiber; returnFiber = currentFirstChild; @@ -3234,7 +2974,7 @@ function ChildReconciler(shouldTrackSideEffects) { (currentFirstChild = createFiberFromText( newChild, returnFiber.mode, - lanes + expirationTime )), (currentFirstChild.return = returnFiber), (returnFiber = currentFirstChild)), @@ -3245,14 +2985,14 @@ function ChildReconciler(shouldTrackSideEffects) { returnFiber, currentFirstChild, newChild, - lanes + expirationTime ); if (getIteratorFn(newChild)) return reconcileChildrenIterator( returnFiber, currentFirstChild, newChild, - lanes + expirationTime ); isObject && throwOnInvalidObjectType(returnFiber, newChild); if ("undefined" === typeof newChild && !isUnkeyedTopLevelFragment) @@ -3271,9 +3011,9 @@ function ChildReconciler(shouldTrackSideEffects) { var reconcileChildFibers = ChildReconciler(!0), mountChildFibers = ChildReconciler(!1), NO_CONTEXT = {}, - contextStackCursor$1 = createCursor(NO_CONTEXT), - contextFiberStackCursor = createCursor(NO_CONTEXT), - rootInstanceStackCursor = createCursor(NO_CONTEXT); + contextStackCursor$1 = { current: NO_CONTEXT }, + contextFiberStackCursor = { current: NO_CONTEXT }, + rootInstanceStackCursor = { current: NO_CONTEXT }; function requiredContext(c) { if (c === NO_CONTEXT) throw Error( @@ -3296,26 +3036,26 @@ function popHostContainer() { function pushHostContext(fiber) { requiredContext(rootInstanceStackCursor.current); var context = requiredContext(contextStackCursor$1.current); - var JSCompiler_inline_result = fiber.type; - JSCompiler_inline_result = - "AndroidTextInput" === JSCompiler_inline_result || - "RCTMultilineTextInputView" === JSCompiler_inline_result || - "RCTSinglelineTextInputView" === JSCompiler_inline_result || - "RCTText" === JSCompiler_inline_result || - "RCTVirtualText" === JSCompiler_inline_result; - JSCompiler_inline_result = - context.isInAParentText !== JSCompiler_inline_result - ? { isInAParentText: JSCompiler_inline_result } + var nextContext = fiber.type; + nextContext = + "AndroidTextInput" === nextContext || + "RCTMultilineTextInputView" === nextContext || + "RCTSinglelineTextInputView" === nextContext || + "RCTText" === nextContext || + "RCTVirtualText" === nextContext; + nextContext = + context.isInAParentText !== nextContext + ? { isInAParentText: nextContext } : context; - context !== JSCompiler_inline_result && + context !== nextContext && (push(contextFiberStackCursor, fiber), - push(contextStackCursor$1, JSCompiler_inline_result)); + push(contextStackCursor$1, nextContext)); } function popHostContext(fiber) { contextFiberStackCursor.current === fiber && (pop(contextStackCursor$1), pop(contextFiberStackCursor)); } -var suspenseStackCursor = createCursor(0); +var suspenseStackCursor = { current: 0 }; function findFirstSuspended(row) { for (var node = row; null !== node; ) { if (13 === node.tag) { @@ -3342,20 +3082,13 @@ function findFirstSuspended(row) { function createDeprecatedResponderListener(responder, props) { return { responder: responder, props: props }; } -var workInProgressSources = []; -function resetWorkInProgressVersions() { - for (var i = 0; i < workInProgressSources.length; i++) - workInProgressSources[i]._workInProgressVersionPrimary = null; - workInProgressSources.length = 0; -} -var ReactCurrentDispatcher$1 = ReactSharedInternals.ReactCurrentDispatcher, +var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher, ReactCurrentBatchConfig$1 = ReactSharedInternals.ReactCurrentBatchConfig, - renderLanes = 0, + renderExpirationTime = 0, currentlyRenderingFiber$1 = null, currentHook = null, workInProgressHook = null, - didScheduleRenderPhaseUpdate = !1, - didScheduleRenderPhaseUpdateDuringThisPass = !1; + didScheduleRenderPhaseUpdate = !1; function throwInvalidHookError() { throw Error( "Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:\n1. You might have mismatching versions of React and the renderer (such as React DOM)\n2. You might be breaking the Rules of Hooks\n3. You might have more than one copy of React in the same app\nSee https://fb.me/react-invalid-hook-call for tips about how to debug and fix this problem." @@ -3373,36 +3106,36 @@ function renderWithHooks( Component, props, secondArg, - nextRenderLanes + nextRenderExpirationTime ) { - renderLanes = nextRenderLanes; + renderExpirationTime = nextRenderExpirationTime; currentlyRenderingFiber$1 = workInProgress; workInProgress.memoizedState = null; workInProgress.updateQueue = null; - workInProgress.lanes = 0; - ReactCurrentDispatcher$1.current = + workInProgress.expirationTime = 0; + ReactCurrentDispatcher.current = null === current || null === current.memoizedState ? HooksDispatcherOnMount : HooksDispatcherOnUpdate; current = Component(props, secondArg); - if (didScheduleRenderPhaseUpdateDuringThisPass) { - nextRenderLanes = 0; + if (workInProgress.expirationTime === renderExpirationTime) { + nextRenderExpirationTime = 0; do { - didScheduleRenderPhaseUpdateDuringThisPass = !1; - if (!(25 > nextRenderLanes)) + workInProgress.expirationTime = 0; + if (!(25 > nextRenderExpirationTime)) throw Error( "Too many re-renders. React limits the number of renders to prevent an infinite loop." ); - nextRenderLanes += 1; + nextRenderExpirationTime += 1; workInProgressHook = currentHook = null; workInProgress.updateQueue = null; - ReactCurrentDispatcher$1.current = HooksDispatcherOnRerender; + ReactCurrentDispatcher.current = HooksDispatcherOnRerender; current = Component(props, secondArg); - } while (didScheduleRenderPhaseUpdateDuringThisPass); + } while (workInProgress.expirationTime === renderExpirationTime); } - ReactCurrentDispatcher$1.current = ContextOnlyDispatcher; + ReactCurrentDispatcher.current = ContextOnlyDispatcher; workInProgress = null !== currentHook && null !== currentHook.next; - renderLanes = 0; + renderExpirationTime = 0; workInProgressHook = currentHook = currentlyRenderingFiber$1 = null; didScheduleRenderPhaseUpdate = !1; if (workInProgress) @@ -3483,40 +3216,40 @@ function updateReducer(reducer) { var newBaseQueueLast = (baseFirst = pendingQueue = null), update = baseQueue; do { - var suspenseConfig = update.suspenseConfig, - updateLane = update.lane, - updateEventTime = update.eventTime; - (renderLanes & updateLane) === updateLane - ? (null !== newBaseQueueLast && - (newBaseQueueLast = newBaseQueueLast.next = { - eventTime: updateEventTime, - lane: 0, - suspenseConfig: update.suspenseConfig, - action: update.action, - eagerReducer: update.eagerReducer, - eagerState: update.eagerState, - next: null - }), - markRenderEventTimeAndConfig(updateEventTime, suspenseConfig), - (current = - update.eagerReducer === reducer - ? update.eagerState - : reducer(current, update.action))) - : ((suspenseConfig = { - eventTime: updateEventTime, - lane: updateLane, - suspenseConfig: suspenseConfig, + var updateExpirationTime = update.expirationTime; + if (updateExpirationTime < renderExpirationTime) { + var clone = { + expirationTime: update.expirationTime, + suspenseConfig: update.suspenseConfig, + action: update.action, + eagerReducer: update.eagerReducer, + eagerState: update.eagerState, + next: null + }; + null === newBaseQueueLast + ? ((baseFirst = newBaseQueueLast = clone), (pendingQueue = current)) + : (newBaseQueueLast = newBaseQueueLast.next = clone); + updateExpirationTime > currentlyRenderingFiber$1.expirationTime && + ((currentlyRenderingFiber$1.expirationTime = updateExpirationTime), + markUnprocessedUpdateTime(updateExpirationTime)); + } else + null !== newBaseQueueLast && + (newBaseQueueLast = newBaseQueueLast.next = { + expirationTime: 1073741823, + suspenseConfig: update.suspenseConfig, action: update.action, eagerReducer: update.eagerReducer, eagerState: update.eagerState, next: null }), - null === newBaseQueueLast - ? ((baseFirst = newBaseQueueLast = suspenseConfig), - (pendingQueue = current)) - : (newBaseQueueLast = newBaseQueueLast.next = suspenseConfig), - (currentlyRenderingFiber$1.lanes |= updateLane), - (workInProgressRootSkippedLanes |= updateLane)); + markRenderEventTimeAndConfig( + updateExpirationTime, + update.suspenseConfig + ), + (current = + update.eagerReducer === reducer + ? update.eagerState + : reducer(current, update.action)); update = update.next; } while (null !== update && update !== baseQueue); null === newBaseQueueLast @@ -3553,117 +3286,6 @@ function rerenderReducer(reducer) { } return [newState, dispatch]; } -function readFromUnsubcribedMutableSource(root, source, getSnapshot) { - var getVersion = source._getVersion; - getVersion = getVersion(source._source); - var JSCompiler_inline_result = source._workInProgressVersionPrimary; - if (null !== JSCompiler_inline_result) - root = JSCompiler_inline_result === getVersion; - else if ( - ((root = root.mutableReadLanes), (root = (renderLanes & root) === root)) - ) - (source._workInProgressVersionPrimary = getVersion), - workInProgressSources.push(source); - if (root) return getSnapshot(source._source); - workInProgressSources.push(source); - throw Error( - "Cannot read from mutable source during the current render without tearing. This is a bug in React. Please file an issue." - ); -} -function useMutableSource(hook, source, getSnapshot, subscribe) { - var root = workInProgressRoot; - if (null === root) - throw Error( - "Expected a work-in-progress root. This is a bug in React. Please file an issue." - ); - var getVersion = source._getVersion, - version = getVersion(source._source), - dispatcher = ReactCurrentDispatcher$1.current, - _dispatcher$useState = dispatcher.useState(function() { - return readFromUnsubcribedMutableSource(root, source, getSnapshot); - }), - setSnapshot = _dispatcher$useState[1], - snapshot = _dispatcher$useState[0]; - _dispatcher$useState = workInProgressHook; - var memoizedState = hook.memoizedState, - refs = memoizedState.refs, - prevGetSnapshot = refs.getSnapshot, - prevSource = memoizedState.source; - memoizedState = memoizedState.subscribe; - var fiber = currentlyRenderingFiber$1; - hook.memoizedState = { refs: refs, source: source, subscribe: subscribe }; - dispatcher.useEffect( - function() { - refs.getSnapshot = getSnapshot; - refs.setSnapshot = setSnapshot; - var maybeNewVersion = getVersion(source._source); - if (!objectIs(version, maybeNewVersion)) { - maybeNewVersion = getSnapshot(source._source); - objectIs(snapshot, maybeNewVersion) || - (setSnapshot(maybeNewVersion), - (maybeNewVersion = requestUpdateLane( - fiber, - ReactCurrentBatchConfig.suspense - )), - (root.mutableReadLanes |= maybeNewVersion & root.pendingLanes)); - maybeNewVersion = root.mutableReadLanes; - root.entangledLanes |= maybeNewVersion; - for ( - var entanglements = root.entanglements, lanes = maybeNewVersion; - 0 < lanes; - - ) { - var index$14 = 31 - clz32(lanes), - lane = 1 << index$14; - entanglements[index$14] |= maybeNewVersion; - lanes &= ~lane; - } - } - }, - [getSnapshot, source, subscribe] - ); - dispatcher.useEffect( - function() { - return subscribe(source._source, function() { - var latestGetSnapshot = refs.getSnapshot, - latestSetSnapshot = refs.setSnapshot; - try { - latestSetSnapshot(latestGetSnapshot(source._source)); - var lane = requestUpdateLane(fiber, ReactCurrentBatchConfig.suspense); - root.mutableReadLanes |= lane & root.pendingLanes; - } catch (error) { - latestSetSnapshot(function() { - throw error; - }); - } - }); - }, - [source, subscribe] - ); - (objectIs(prevGetSnapshot, getSnapshot) && - objectIs(prevSource, source) && - objectIs(memoizedState, subscribe)) || - ((hook = { - pending: null, - dispatch: null, - lastRenderedReducer: basicStateReducer, - lastRenderedState: snapshot - }), - (hook.dispatch = setSnapshot = dispatchAction.bind( - null, - currentlyRenderingFiber$1, - hook - )), - (_dispatcher$useState.queue = hook), - (_dispatcher$useState.baseQueue = null), - (snapshot = readFromUnsubcribedMutableSource(root, source, getSnapshot)), - (_dispatcher$useState.memoizedState = _dispatcher$useState.baseState = snapshot)); - return snapshot; -} -function updateMutableSource(source, getSnapshot, subscribe) { - var hook = updateWorkInProgressHook(); - return useMutableSource(hook, source, getSnapshot, subscribe); -} function mountState(initialState) { var hook = mountWorkInProgressHook(); "function" === typeof initialState && (initialState = initialState()); @@ -3812,12 +3434,11 @@ function startTransition(setPending, config, callback) { }); } function dispatchAction(fiber, queue, action) { - var eventTime = requestEventTime(), - suspenseConfig = ReactCurrentBatchConfig.suspense, - lane = requestUpdateLane(fiber, suspenseConfig); + var currentTime = requestCurrentTimeForUpdate(), + suspenseConfig = ReactCurrentBatchConfig.suspense; + currentTime = computeExpirationForFiber(currentTime, fiber, suspenseConfig); suspenseConfig = { - eventTime: eventTime, - lane: lane, + expirationTime: currentTime, suspenseConfig: suspenseConfig, action: action, eagerReducer: null, @@ -3834,11 +3455,13 @@ function dispatchAction(fiber, queue, action) { fiber === currentlyRenderingFiber$1 || (null !== pending && pending === currentlyRenderingFiber$1) ) - didScheduleRenderPhaseUpdateDuringThisPass = didScheduleRenderPhaseUpdate = !0; + (didScheduleRenderPhaseUpdate = !0), + (suspenseConfig.expirationTime = renderExpirationTime), + (currentlyRenderingFiber$1.expirationTime = renderExpirationTime); else { if ( - 0 === fiber.lanes && - (null === pending || 0 === pending.lanes) && + 0 === fiber.expirationTime && + (null === pending || 0 === pending.expirationTime) && ((pending = queue.lastRenderedReducer), null !== pending) ) try { @@ -3850,9 +3473,10 @@ function dispatchAction(fiber, queue, action) { } catch (error) { } finally { } - scheduleUpdateOnFiber(fiber, lane, eventTime); + scheduleWork(fiber, currentTime); } } +function updateEventListener() {} var ContextOnlyDispatcher = { readContext: readContext, useCallback: throwInvalidHookError, @@ -3868,9 +3492,7 @@ var ContextOnlyDispatcher = { useResponder: throwInvalidHookError, useDeferredValue: throwInvalidHookError, useTransition: throwInvalidHookError, - useMutableSource: throwInvalidHookError, - useOpaqueIdentifier: throwInvalidHookError, - unstable_isNewReconciler: !1 + useEvent: throwInvalidHookError }, HooksDispatcherOnMount = { readContext: readContext, @@ -3952,19 +3574,7 @@ var ContextOnlyDispatcher = { isPending ]; }, - useMutableSource: function(source, getSnapshot, subscribe) { - var hook = mountWorkInProgressHook(); - hook.memoizedState = { - refs: { getSnapshot: getSnapshot, setSnapshot: null }, - source: source, - subscribe: subscribe - }; - return useMutableSource(hook, source, getSnapshot, subscribe); - }, - useOpaqueIdentifier: function() { - throw Error("Not yet implemented"); - }, - unstable_isNewReconciler: !1 + useEvent: function() {} }, HooksDispatcherOnUpdate = { readContext: readContext, @@ -4012,11 +3622,7 @@ var ContextOnlyDispatcher = { isPending ]; }, - useMutableSource: updateMutableSource, - useOpaqueIdentifier: function() { - return updateReducer(basicStateReducer)[0]; - }, - unstable_isNewReconciler: !1 + useEvent: updateEventListener }, HooksDispatcherOnRerender = { readContext: readContext, @@ -4064,23 +3670,29 @@ var ContextOnlyDispatcher = { isPending ]; }, - useMutableSource: updateMutableSource, - useOpaqueIdentifier: function() { - return rerenderReducer(basicStateReducer)[0]; - }, - unstable_isNewReconciler: !1 + useEvent: updateEventListener }, ReactCurrentOwner$1 = ReactSharedInternals.ReactCurrentOwner, didReceiveUpdate = !1; -function reconcileChildren(current, workInProgress, nextChildren, renderLanes) { +function reconcileChildren( + current, + workInProgress, + nextChildren, + renderExpirationTime +) { workInProgress.child = null === current - ? mountChildFibers(workInProgress, null, nextChildren, renderLanes) + ? mountChildFibers( + workInProgress, + null, + nextChildren, + renderExpirationTime + ) : reconcileChildFibers( workInProgress, current.child, nextChildren, - renderLanes + renderExpirationTime ); } function updateForwardRef( @@ -4088,28 +3700,33 @@ function updateForwardRef( workInProgress, Component, nextProps, - renderLanes + renderExpirationTime ) { Component = Component.render; var ref = workInProgress.ref; - prepareToReadContext(workInProgress, renderLanes); + prepareToReadContext(workInProgress, renderExpirationTime); nextProps = renderWithHooks( current, workInProgress, Component, nextProps, ref, - renderLanes + renderExpirationTime ); if (null !== current && !didReceiveUpdate) return ( (workInProgress.updateQueue = current.updateQueue), (workInProgress.effectTag &= -517), - (current.lanes &= ~renderLanes), - bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes) + current.expirationTime <= renderExpirationTime && + (current.expirationTime = 0), + bailoutOnAlreadyFinishedWork( + current, + workInProgress, + renderExpirationTime + ) ); workInProgress.effectTag |= 1; - reconcileChildren(current, workInProgress, nextProps, renderLanes); + reconcileChildren(current, workInProgress, nextProps, renderExpirationTime); return workInProgress.child; } function updateMemoComponent( @@ -4117,8 +3734,8 @@ function updateMemoComponent( workInProgress, Component, nextProps, - updateLanes, - renderLanes + updateExpirationTime, + renderExpirationTime ) { if (null === current) { var type = Component.type; @@ -4137,8 +3754,8 @@ function updateMemoComponent( workInProgress, type, nextProps, - updateLanes, - renderLanes + updateExpirationTime, + renderExpirationTime ) ); current = createFiberFromTypeAndProps( @@ -4147,7 +3764,7 @@ function updateMemoComponent( nextProps, null, workInProgress.mode, - renderLanes + renderExpirationTime ); current.ref = workInProgress.ref; current.return = workInProgress; @@ -4155,13 +3772,18 @@ function updateMemoComponent( } type = current.child; if ( - 0 === (updateLanes & renderLanes) && - ((updateLanes = type.memoizedProps), + updateExpirationTime < renderExpirationTime && + ((updateExpirationTime = type.memoizedProps), (Component = Component.compare), (Component = null !== Component ? Component : shallowEqual), - Component(updateLanes, nextProps) && current.ref === workInProgress.ref) + Component(updateExpirationTime, nextProps) && + current.ref === workInProgress.ref) ) - return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes); + return bailoutOnAlreadyFinishedWork( + current, + workInProgress, + renderExpirationTime + ); workInProgress.effectTag |= 1; current = createWorkInProgress(type, nextProps); current.ref = workInProgress.ref; @@ -4173,63 +3795,26 @@ function updateSimpleMemoComponent( workInProgress, Component, nextProps, - updateLanes, - renderLanes + updateExpirationTime, + renderExpirationTime ) { - if ( - null !== current && + return null !== current && shallowEqual(current.memoizedProps, nextProps) && - current.ref === workInProgress.ref - ) - if (((didReceiveUpdate = !1), 0 !== (renderLanes & updateLanes))) - 0 !== (current.effectTag & 16384) && (didReceiveUpdate = !0); - else - return ( - (workInProgress.lanes = current.lanes), - bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes) + current.ref === workInProgress.ref && + ((didReceiveUpdate = !1), updateExpirationTime < renderExpirationTime) + ? ((workInProgress.expirationTime = current.expirationTime), + bailoutOnAlreadyFinishedWork( + current, + workInProgress, + renderExpirationTime + )) + : updateFunctionComponent( + current, + workInProgress, + Component, + nextProps, + renderExpirationTime ); - return updateFunctionComponent( - current, - workInProgress, - Component, - nextProps, - renderLanes - ); -} -function updateOffscreenComponent(current, workInProgress, renderLanes) { - var nextProps = workInProgress.pendingProps, - nextChildren = nextProps.children, - prevState = null !== current ? current.memoizedState : null; - if ( - "hidden" === nextProps.mode || - "unstable-defer-without-hiding" === nextProps.mode - ) - if (0 === (workInProgress.mode & 4)) - (workInProgress.memoizedState = { baseLanes: 0 }), - pushRenderLanes(workInProgress, renderLanes); - else if (0 !== (renderLanes & 1073741824)) - (workInProgress.memoizedState = { baseLanes: 0 }), - pushRenderLanes( - workInProgress, - null !== prevState ? prevState.baseLanes : renderLanes - ); - else - return ( - (current = - null !== prevState ? prevState.baseLanes | renderLanes : renderLanes), - (workInProgress.lanes = workInProgress.childLanes = 1073741824), - (workInProgress.memoizedState = { baseLanes: current }), - pushRenderLanes(workInProgress, current), - null - ); - else - null !== prevState - ? ((nextProps = prevState.baseLanes | renderLanes), - (workInProgress.memoizedState = null)) - : (nextProps = renderLanes), - pushRenderLanes(workInProgress, nextProps); - reconcileChildren(current, workInProgress, nextChildren, renderLanes); - return workInProgress.child; } function markRef(current, workInProgress) { var ref = workInProgress.ref; @@ -4244,30 +3829,35 @@ function updateFunctionComponent( workInProgress, Component, nextProps, - renderLanes + renderExpirationTime ) { var context = isContextProvider(Component) ? previousContext : contextStackCursor.current; context = getMaskedContext(workInProgress, context); - prepareToReadContext(workInProgress, renderLanes); + prepareToReadContext(workInProgress, renderExpirationTime); Component = renderWithHooks( current, workInProgress, Component, nextProps, context, - renderLanes + renderExpirationTime ); if (null !== current && !didReceiveUpdate) return ( (workInProgress.updateQueue = current.updateQueue), (workInProgress.effectTag &= -517), - (current.lanes &= ~renderLanes), - bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes) + current.expirationTime <= renderExpirationTime && + (current.expirationTime = 0), + bailoutOnAlreadyFinishedWork( + current, + workInProgress, + renderExpirationTime + ) ); workInProgress.effectTag |= 1; - reconcileChildren(current, workInProgress, Component, renderLanes); + reconcileChildren(current, workInProgress, Component, renderExpirationTime); return workInProgress.child; } function updateClassComponent( @@ -4275,20 +3865,25 @@ function updateClassComponent( workInProgress, Component, nextProps, - renderLanes + renderExpirationTime ) { if (isContextProvider(Component)) { var hasContext = !0; pushContextProvider(workInProgress); } else hasContext = !1; - prepareToReadContext(workInProgress, renderLanes); + prepareToReadContext(workInProgress, renderExpirationTime); if (null === workInProgress.stateNode) null !== current && ((current.alternate = null), (workInProgress.alternate = null), (workInProgress.effectTag |= 2)), constructClassInstance(workInProgress, Component, nextProps), - mountClassInstance(workInProgress, Component, nextProps, renderLanes), + mountClassInstance( + workInProgress, + Component, + nextProps, + renderExpirationTime + ), (nextProps = !0); else if (null === current) { var instance = workInProgress.stateNode, @@ -4319,7 +3914,12 @@ function updateClassComponent( hasForceUpdate = !1; var oldState = workInProgress.memoizedState; instance.state = oldState; - processUpdateQueue(workInProgress, nextProps, instance, renderLanes); + processUpdateQueue( + workInProgress, + nextProps, + instance, + renderExpirationTime + ); oldContext = workInProgress.memoizedState; oldProps !== nextProps || oldState !== oldContext || @@ -4364,111 +3964,117 @@ function updateClassComponent( : ("function" === typeof instance.componentDidMount && (workInProgress.effectTag |= 4), (nextProps = !1)); - } else { - instance = workInProgress.stateNode; - cloneUpdateQueue(current, workInProgress); - oldProps = workInProgress.memoizedProps; - contextType = - workInProgress.type === workInProgress.elementType - ? oldProps - : resolveDefaultProps(workInProgress.type, oldProps); - instance.props = contextType; - hasNewLifecycles = workInProgress.pendingProps; - oldState = instance.context; - oldContext = Component.contextType; - "object" === typeof oldContext && null !== oldContext - ? (oldContext = readContext(oldContext)) - : ((oldContext = isContextProvider(Component) - ? previousContext - : contextStackCursor.current), - (oldContext = getMaskedContext(workInProgress, oldContext))); - var getDerivedStateFromProps$jscomp$0 = Component.getDerivedStateFromProps; - (getDerivedStateFromProps = - "function" === typeof getDerivedStateFromProps$jscomp$0 || - "function" === typeof instance.getSnapshotBeforeUpdate) || - ("function" !== typeof instance.UNSAFE_componentWillReceiveProps && - "function" !== typeof instance.componentWillReceiveProps) || - ((oldProps !== hasNewLifecycles || oldState !== oldContext) && - callComponentWillReceiveProps( - workInProgress, - instance, - nextProps, - oldContext - )); - hasForceUpdate = !1; - oldState = workInProgress.memoizedState; - instance.state = oldState; - processUpdateQueue(workInProgress, nextProps, instance, renderLanes); - var newState = workInProgress.memoizedState; - oldProps !== hasNewLifecycles || - oldState !== newState || - didPerformWorkStackCursor.current || - hasForceUpdate - ? ("function" === typeof getDerivedStateFromProps$jscomp$0 && - (applyDerivedStateFromProps( + } else + (instance = workInProgress.stateNode), + cloneUpdateQueue(current, workInProgress), + (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 = readContext(contextType)) + : ((contextType = isContextProvider(Component) + ? previousContext + : contextStackCursor.current), + (contextType = getMaskedContext(workInProgress, contextType))), + (getDerivedStateFromProps = Component.getDerivedStateFromProps), + (hasNewLifecycles = + "function" === typeof getDerivedStateFromProps || + "function" === typeof instance.getSnapshotBeforeUpdate) || + ("function" !== typeof instance.UNSAFE_componentWillReceiveProps && + "function" !== typeof instance.componentWillReceiveProps) || + ((oldProps !== nextProps || oldContext !== contextType) && + callComponentWillReceiveProps( workInProgress, - Component, - getDerivedStateFromProps$jscomp$0, - nextProps - ), - (newState = workInProgress.memoizedState)), - (contextType = - hasForceUpdate || - checkShouldComponentUpdate( - workInProgress, - Component, - contextType, + instance, nextProps, - oldState, - newState, - oldContext - )) - ? (getDerivedStateFromProps || - ("function" !== typeof instance.UNSAFE_componentWillUpdate && - "function" !== typeof instance.componentWillUpdate) || - ("function" === typeof instance.componentWillUpdate && - instance.componentWillUpdate(nextProps, newState, oldContext), - "function" === typeof instance.UNSAFE_componentWillUpdate && - instance.UNSAFE_componentWillUpdate( - nextProps, - newState, - oldContext - )), - "function" === typeof instance.componentDidUpdate && - (workInProgress.effectTag |= 4), - "function" === typeof instance.getSnapshotBeforeUpdate && - (workInProgress.effectTag |= 256)) - : ("function" !== typeof instance.componentDidUpdate || - (oldProps === current.memoizedProps && - oldState === current.memoizedState) || - (workInProgress.effectTag |= 4), - "function" !== typeof instance.getSnapshotBeforeUpdate || - (oldProps === current.memoizedProps && - oldState === current.memoizedState) || - (workInProgress.effectTag |= 256), - (workInProgress.memoizedProps = nextProps), - (workInProgress.memoizedState = newState)), - (instance.props = nextProps), - (instance.state = newState), - (instance.context = oldContext), - (nextProps = contextType)) - : ("function" !== typeof instance.componentDidUpdate || - (oldProps === current.memoizedProps && - oldState === current.memoizedState) || - (workInProgress.effectTag |= 4), - "function" !== typeof instance.getSnapshotBeforeUpdate || - (oldProps === current.memoizedProps && - oldState === current.memoizedState) || - (workInProgress.effectTag |= 256), - (nextProps = !1)); - } + contextType + )), + (hasForceUpdate = !1), + (oldContext = workInProgress.memoizedState), + (instance.state = oldContext), + processUpdateQueue( + workInProgress, + nextProps, + instance, + renderExpirationTime + ), + (oldState = workInProgress.memoizedState), + oldProps !== nextProps || + oldContext !== oldState || + didPerformWorkStackCursor.current || + hasForceUpdate + ? ("function" === typeof getDerivedStateFromProps && + (applyDerivedStateFromProps( + workInProgress, + Component, + getDerivedStateFromProps, + nextProps + ), + (oldState = workInProgress.memoizedState)), + (getDerivedStateFromProps = + hasForceUpdate || + checkShouldComponentUpdate( + workInProgress, + Component, + oldProps, + nextProps, + oldContext, + oldState, + contextType + )) + ? (hasNewLifecycles || + ("function" !== typeof instance.UNSAFE_componentWillUpdate && + "function" !== typeof instance.componentWillUpdate) || + ("function" === typeof instance.componentWillUpdate && + instance.componentWillUpdate( + nextProps, + oldState, + contextType + ), + "function" === typeof instance.UNSAFE_componentWillUpdate && + instance.UNSAFE_componentWillUpdate( + nextProps, + oldState, + contextType + )), + "function" === typeof instance.componentDidUpdate && + (workInProgress.effectTag |= 4), + "function" === typeof instance.getSnapshotBeforeUpdate && + (workInProgress.effectTag |= 256)) + : ("function" !== typeof instance.componentDidUpdate || + (oldProps === current.memoizedProps && + oldContext === current.memoizedState) || + (workInProgress.effectTag |= 4), + "function" !== typeof instance.getSnapshotBeforeUpdate || + (oldProps === current.memoizedProps && + oldContext === current.memoizedState) || + (workInProgress.effectTag |= 256), + (workInProgress.memoizedProps = nextProps), + (workInProgress.memoizedState = oldState)), + (instance.props = nextProps), + (instance.state = oldState), + (instance.context = contextType), + (nextProps = getDerivedStateFromProps)) + : ("function" !== typeof instance.componentDidUpdate || + (oldProps === current.memoizedProps && + oldContext === current.memoizedState) || + (workInProgress.effectTag |= 4), + "function" !== typeof instance.getSnapshotBeforeUpdate || + (oldProps === current.memoizedProps && + oldContext === current.memoizedState) || + (workInProgress.effectTag |= 256), + (nextProps = !1)); return finishClassComponent( current, workInProgress, Component, nextProps, hasContext, - renderLanes + renderExpirationTime ); } function finishClassComponent( @@ -4477,14 +4083,18 @@ function finishClassComponent( Component, shouldUpdate, hasContext, - renderLanes + renderExpirationTime ) { markRef(current, workInProgress); var didCaptureError = 0 !== (workInProgress.effectTag & 64); if (!shouldUpdate && !didCaptureError) return ( hasContext && invalidateContextProvider(workInProgress, Component, !1), - bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes) + bailoutOnAlreadyFinishedWork( + current, + workInProgress, + renderExpirationTime + ) ); shouldUpdate = workInProgress.stateNode; ReactCurrentOwner$1.current = workInProgress; @@ -4498,15 +4108,20 @@ function finishClassComponent( workInProgress, current.child, null, - renderLanes + renderExpirationTime )), (workInProgress.child = reconcileChildFibers( workInProgress, null, nextChildren, - renderLanes + renderExpirationTime ))) - : reconcileChildren(current, workInProgress, nextChildren, renderLanes); + : reconcileChildren( + current, + workInProgress, + nextChildren, + renderExpirationTime + ); workInProgress.memoizedState = shouldUpdate.state; hasContext && invalidateContextProvider(workInProgress, Component, !0); return workInProgress.child; @@ -4523,186 +4138,155 @@ function pushHostRootContext(workInProgress) { pushTopLevelContextObject(workInProgress, root.context, !1); pushHostContainer(workInProgress, root.containerInfo); } -var SUSPENDED_MARKER = { dehydrated: null, retryLane: 0 }; -function updateSuspenseComponent(current, workInProgress, renderLanes) { - var nextProps = workInProgress.pendingProps, +var SUSPENDED_MARKER = { dehydrated: null, retryTime: 0 }; +function updateSuspenseComponent( + current, + workInProgress, + renderExpirationTime +) { + var mode = workInProgress.mode, + nextProps = workInProgress.pendingProps, suspenseContext = suspenseStackCursor.current, - showFallback = !1, + nextDidTimeout = !1, JSCompiler_temp; (JSCompiler_temp = 0 !== (workInProgress.effectTag & 64)) || (JSCompiler_temp = - null !== current && null === current.memoizedState - ? !1 - : 0 !== (suspenseContext & 2)); + 0 !== (suspenseContext & 2) && + (null === current || null !== current.memoizedState)); JSCompiler_temp - ? ((showFallback = !0), (workInProgress.effectTag &= -65)) + ? ((nextDidTimeout = !0), (workInProgress.effectTag &= -65)) : (null !== current && null === current.memoizedState) || void 0 === nextProps.fallback || !0 === nextProps.unstable_avoidThisFallback || (suspenseContext |= 1); push(suspenseStackCursor, suspenseContext & 1); if (null === current) { - if (showFallback) - return ( - (current = nextProps.fallback), - (suspenseContext = workInProgress.mode), - (showFallback = workInProgress.child), - (nextProps = { mode: "hidden", children: nextProps.children }), - 0 === (suspenseContext & 2) && null !== showFallback - ? ((showFallback.childLanes = 0), - (showFallback.pendingProps = nextProps)) - : (showFallback = createFiberFromOffscreen( - nextProps, - suspenseContext, - 0, - null - )), - (current = createFiberFromFragment( - current, - suspenseContext, - renderLanes, - null - )), - (showFallback.return = workInProgress), - (current.return = workInProgress), - (showFallback.sibling = current), - (workInProgress.child = showFallback), - (workInProgress.child.memoizedState = { baseLanes: renderLanes }), - (workInProgress.memoizedState = SUSPENDED_MARKER), - current + if (nextDidTimeout) { + nextDidTimeout = nextProps.fallback; + nextProps = createFiberFromFragment(null, mode, 0, null); + nextProps.return = workInProgress; + if (0 === (workInProgress.mode & 2)) + for ( + current = + null !== workInProgress.memoizedState + ? workInProgress.child.child + : workInProgress.child, + nextProps.child = current; + null !== current; + + ) + (current.return = nextProps), (current = current.sibling); + renderExpirationTime = createFiberFromFragment( + nextDidTimeout, + mode, + renderExpirationTime, + null ); - renderLanes = createFiberFromOffscreen( - { mode: "visible", children: nextProps.children }, - workInProgress.mode, - renderLanes, - null - ); - renderLanes.return = workInProgress; - return (workInProgress.child = renderLanes); + renderExpirationTime.return = workInProgress; + nextProps.sibling = renderExpirationTime; + workInProgress.memoizedState = SUSPENDED_MARKER; + workInProgress.child = nextProps; + return renderExpirationTime; + } + mode = nextProps.children; + workInProgress.memoizedState = null; + return (workInProgress.child = mountChildFibers( + workInProgress, + null, + mode, + renderExpirationTime + )); } if (null !== current.memoizedState) { - if (showFallback) - return ( - (nextProps = updateSuspenseFallbackChildren( - current, - workInProgress, - nextProps.children, - nextProps.fallback, - renderLanes - )), - (suspenseContext = workInProgress.child), - (showFallback = current.child.memoizedState), - (suspenseContext.memoizedState = - null === showFallback - ? { baseLanes: renderLanes } - : { baseLanes: showFallback.baseLanes | renderLanes }), - (suspenseContext.childLanes = current.childLanes & ~renderLanes), - (workInProgress.memoizedState = SUSPENDED_MARKER), - nextProps + current = current.child; + mode = current.sibling; + if (nextDidTimeout) { + nextProps = nextProps.fallback; + renderExpirationTime = createWorkInProgress( + current, + current.pendingProps ); - renderLanes = updateSuspensePrimaryChildren( - current, + renderExpirationTime.return = workInProgress; + if ( + 0 === (workInProgress.mode & 2) && + ((nextDidTimeout = + null !== workInProgress.memoizedState + ? workInProgress.child.child + : workInProgress.child), + nextDidTimeout !== current.child) + ) + for ( + renderExpirationTime.child = nextDidTimeout; + null !== nextDidTimeout; + + ) + (nextDidTimeout.return = renderExpirationTime), + (nextDidTimeout = nextDidTimeout.sibling); + mode = createWorkInProgress(mode, nextProps); + mode.return = workInProgress; + renderExpirationTime.sibling = mode; + renderExpirationTime.childExpirationTime = 0; + workInProgress.memoizedState = SUSPENDED_MARKER; + workInProgress.child = renderExpirationTime; + return mode; + } + renderExpirationTime = reconcileChildFibers( workInProgress, + current.child, nextProps.children, - renderLanes + renderExpirationTime ); workInProgress.memoizedState = null; - return renderLanes; + return (workInProgress.child = renderExpirationTime); } - if (showFallback) - return ( - (nextProps = updateSuspenseFallbackChildren( - current, - workInProgress, - nextProps.children, - nextProps.fallback, - renderLanes - )), - (suspenseContext = workInProgress.child), - (showFallback = current.child.memoizedState), - (suspenseContext.memoizedState = - null === showFallback - ? { baseLanes: renderLanes } - : { baseLanes: showFallback.baseLanes | renderLanes }), - (suspenseContext.childLanes = current.childLanes & ~renderLanes), - (workInProgress.memoizedState = SUSPENDED_MARKER), - nextProps + current = current.child; + if (nextDidTimeout) { + nextDidTimeout = nextProps.fallback; + nextProps = createFiberFromFragment(null, mode, 0, null); + nextProps.return = workInProgress; + nextProps.child = current; + null !== current && (current.return = nextProps); + if (0 === (workInProgress.mode & 2)) + for ( + current = + null !== workInProgress.memoizedState + ? workInProgress.child.child + : workInProgress.child, + nextProps.child = current; + null !== current; + + ) + (current.return = nextProps), (current = current.sibling); + renderExpirationTime = createFiberFromFragment( + nextDidTimeout, + mode, + renderExpirationTime, + null ); - renderLanes = updateSuspensePrimaryChildren( - current, - workInProgress, - nextProps.children, - renderLanes - ); + renderExpirationTime.return = workInProgress; + nextProps.sibling = renderExpirationTime; + renderExpirationTime.effectTag |= 2; + nextProps.childExpirationTime = 0; + workInProgress.memoizedState = SUSPENDED_MARKER; + workInProgress.child = nextProps; + return renderExpirationTime; + } workInProgress.memoizedState = null; - return renderLanes; + return (workInProgress.child = reconcileChildFibers( + workInProgress, + current, + nextProps.children, + renderExpirationTime + )); } -function updateSuspensePrimaryChildren( - current, - workInProgress, - primaryChildren, - renderLanes -) { - var currentPrimaryChildFragment = current.child; - current = currentPrimaryChildFragment.sibling; - primaryChildren = createWorkInProgress(currentPrimaryChildFragment, { - mode: "visible", - children: primaryChildren - }); - 0 === (workInProgress.mode & 2) && (primaryChildren.lanes = renderLanes); - primaryChildren.return = workInProgress; - primaryChildren.sibling = null; - null !== current && - ((current.nextEffect = null), - (current.effectTag = 8), - (workInProgress.firstEffect = workInProgress.lastEffect = current)); - return (workInProgress.child = primaryChildren); -} -function updateSuspenseFallbackChildren( - current, - workInProgress, - primaryChildren, - fallbackChildren, - renderLanes -) { - var mode = workInProgress.mode, - currentPrimaryChildFragment = current.child; - current = currentPrimaryChildFragment.sibling; - var primaryChildProps = { mode: "hidden", children: primaryChildren }; - 0 === (mode & 2) && workInProgress.child !== currentPrimaryChildFragment - ? ((primaryChildren = workInProgress.child), - (primaryChildren.childLanes = 0), - (primaryChildren.pendingProps = primaryChildProps), - (currentPrimaryChildFragment = primaryChildren.lastEffect), - null !== currentPrimaryChildFragment - ? ((workInProgress.firstEffect = primaryChildren.firstEffect), - (workInProgress.lastEffect = currentPrimaryChildFragment), - (currentPrimaryChildFragment.nextEffect = null)) - : (workInProgress.firstEffect = workInProgress.lastEffect = null)) - : (primaryChildren = createWorkInProgress( - currentPrimaryChildFragment, - primaryChildProps - )); - null !== current - ? (fallbackChildren = createWorkInProgress(current, fallbackChildren)) - : ((fallbackChildren = createFiberFromFragment( - fallbackChildren, - mode, - renderLanes, - null - )), - (fallbackChildren.effectTag |= 2)); - fallbackChildren.return = workInProgress; - primaryChildren.return = workInProgress; - primaryChildren.sibling = fallbackChildren; - workInProgress.child = primaryChildren; - return fallbackChildren; -} -function scheduleWorkOnFiber(fiber, renderLanes) { - fiber.lanes |= renderLanes; +function scheduleWorkOnFiber(fiber, renderExpirationTime) { + fiber.expirationTime < renderExpirationTime && + (fiber.expirationTime = renderExpirationTime); var alternate = fiber.alternate; - null !== alternate && (alternate.lanes |= renderLanes); - scheduleWorkOnParentPath(fiber.return, renderLanes); + null !== alternate && + alternate.expirationTime < renderExpirationTime && + (alternate.expirationTime = renderExpirationTime); + scheduleWorkOnParentPath(fiber.return, renderExpirationTime); } function initSuspenseListRenderState( workInProgress, @@ -4733,11 +4317,20 @@ function initSuspenseListRenderState( (renderState.tailMode = tailMode), (renderState.lastEffect = lastEffectBeforeRendering)); } -function updateSuspenseListComponent(current, workInProgress, renderLanes) { +function updateSuspenseListComponent( + current, + workInProgress, + renderExpirationTime +) { var nextProps = workInProgress.pendingProps, revealOrder = nextProps.revealOrder, tailMode = nextProps.tail; - reconcileChildren(current, workInProgress, nextProps.children, renderLanes); + reconcileChildren( + current, + workInProgress, + nextProps.children, + renderExpirationTime + ); nextProps = suspenseStackCursor.current; if (0 !== (nextProps & 2)) (nextProps = (nextProps & 1) | 2), (workInProgress.effectTag |= 64); @@ -4746,8 +4339,9 @@ function updateSuspenseListComponent(current, workInProgress, renderLanes) { a: for (current = workInProgress.child; null !== current; ) { if (13 === current.tag) null !== current.memoizedState && - scheduleWorkOnFiber(current, renderLanes); - else if (19 === current.tag) scheduleWorkOnFiber(current, renderLanes); + scheduleWorkOnFiber(current, renderExpirationTime); + else if (19 === current.tag) + scheduleWorkOnFiber(current, renderExpirationTime); else if (null !== current.child) { current.child.return = current; current = current.child; @@ -4769,29 +4363,30 @@ function updateSuspenseListComponent(current, workInProgress, renderLanes) { else switch (revealOrder) { case "forwards": - renderLanes = workInProgress.child; - for (revealOrder = null; null !== renderLanes; ) - (current = renderLanes.alternate), + renderExpirationTime = workInProgress.child; + for (revealOrder = null; null !== renderExpirationTime; ) + (current = renderExpirationTime.alternate), null !== current && null === findFirstSuspended(current) && - (revealOrder = renderLanes), - (renderLanes = renderLanes.sibling); - renderLanes = revealOrder; - null === renderLanes + (revealOrder = renderExpirationTime), + (renderExpirationTime = renderExpirationTime.sibling); + renderExpirationTime = revealOrder; + null === renderExpirationTime ? ((revealOrder = workInProgress.child), (workInProgress.child = null)) - : ((revealOrder = renderLanes.sibling), (renderLanes.sibling = null)); + : ((revealOrder = renderExpirationTime.sibling), + (renderExpirationTime.sibling = null)); initSuspenseListRenderState( workInProgress, !1, revealOrder, - renderLanes, + renderExpirationTime, tailMode, workInProgress.lastEffect ); break; case "backwards": - renderLanes = null; + renderExpirationTime = null; revealOrder = workInProgress.child; for (workInProgress.child = null; null !== revealOrder; ) { current = revealOrder.alternate; @@ -4800,14 +4395,14 @@ function updateSuspenseListComponent(current, workInProgress, renderLanes) { break; } current = revealOrder.sibling; - revealOrder.sibling = renderLanes; - renderLanes = revealOrder; + revealOrder.sibling = renderExpirationTime; + renderExpirationTime = revealOrder; revealOrder = current; } initSuspenseListRenderState( workInProgress, !0, - renderLanes, + renderExpirationTime, null, tailMode, workInProgress.lastEffect @@ -4828,28 +4423,35 @@ function updateSuspenseListComponent(current, workInProgress, renderLanes) { } return workInProgress.child; } -function bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes) { +function bailoutOnAlreadyFinishedWork( + current, + workInProgress, + renderExpirationTime +) { null !== current && (workInProgress.dependencies = current.dependencies); - workInProgressRootSkippedLanes |= workInProgress.lanes; - if (0 !== (renderLanes & workInProgress.childLanes)) { - if (null !== current && workInProgress.child !== current.child) - throw Error("Resuming work not yet implemented."); - if (null !== workInProgress.child) { - current = workInProgress.child; - renderLanes = createWorkInProgress(current, current.pendingProps); - workInProgress.child = renderLanes; - for (renderLanes.return = workInProgress; null !== current.sibling; ) - (current = current.sibling), - (renderLanes = renderLanes.sibling = createWorkInProgress( - current, - current.pendingProps - )), - (renderLanes.return = workInProgress); - renderLanes.sibling = null; - } - return workInProgress.child; + var updateExpirationTime = workInProgress.expirationTime; + 0 !== updateExpirationTime && markUnprocessedUpdateTime(updateExpirationTime); + if (workInProgress.childExpirationTime < renderExpirationTime) return null; + if (null !== current && workInProgress.child !== current.child) + throw Error("Resuming work not yet implemented."); + if (null !== workInProgress.child) { + current = workInProgress.child; + renderExpirationTime = createWorkInProgress(current, current.pendingProps); + workInProgress.child = renderExpirationTime; + for ( + renderExpirationTime.return = workInProgress; + null !== current.sibling; + + ) + (current = current.sibling), + (renderExpirationTime = renderExpirationTime.sibling = createWorkInProgress( + current, + current.pendingProps + )), + (renderExpirationTime.return = workInProgress); + renderExpirationTime.sibling = null; } - return null; + return workInProgress.child; } var appendAllChildren, updateHostContainer, @@ -4896,17 +4498,17 @@ function cutOffTailIfNeeded(renderState, hasRenderedATailFallback) { break; case "collapsed": lastTailNode = renderState.tail; - for (var lastTailNode$64 = null; null !== lastTailNode; ) - null !== lastTailNode.alternate && (lastTailNode$64 = lastTailNode), + for (var _lastTailNode = null; null !== lastTailNode; ) + null !== lastTailNode.alternate && (_lastTailNode = lastTailNode), (lastTailNode = lastTailNode.sibling); - null === lastTailNode$64 + null === _lastTailNode ? hasRenderedATailFallback || null === renderState.tail ? (renderState.tail = null) : (renderState.tail.sibling = null) - : (lastTailNode$64.sibling = null); + : (_lastTailNode.sibling = null); } } -function completeWork(current, workInProgress, renderLanes) { +function completeWork(current, workInProgress, renderExpirationTime) { var newProps = workInProgress.pendingProps; switch (workInProgress.tag) { case 2: @@ -4927,14 +4529,10 @@ function completeWork(current, workInProgress, renderLanes) { popHostContainer(), pop(didPerformWorkStackCursor), pop(contextStackCursor), - resetWorkInProgressVersions(), - (newProps = workInProgress.stateNode), - newProps.pendingContext && - ((newProps.context = newProps.pendingContext), - (newProps.pendingContext = null)), - (null !== current && null !== current.child) || - newProps.hydrate || - (workInProgress.effectTag |= 256), + (current = workInProgress.stateNode), + current.pendingContext && + ((current.context = current.pendingContext), + (current.pendingContext = null)), updateHostContainer(workInProgress), null ); @@ -4943,12 +4541,12 @@ function completeWork(current, workInProgress, renderLanes) { var rootContainerInstance = requiredContext( rootInstanceStackCursor.current ); - renderLanes = workInProgress.type; + renderExpirationTime = workInProgress.type; if (null !== current && null != workInProgress.stateNode) updateHostComponent$1( current, workInProgress, - renderLanes, + renderExpirationTime, newProps, rootContainerInstance ), @@ -4964,22 +4562,22 @@ function completeWork(current, workInProgress, renderLanes) { } requiredContext(contextStackCursor$1.current); current = allocateTag(); - renderLanes = getViewConfigForType(renderLanes); + renderExpirationTime = getViewConfigForType(renderExpirationTime); var updatePayload = diffProperties( null, emptyObject, newProps, - renderLanes.validAttributes + renderExpirationTime.validAttributes ); ReactNativePrivateInterface.UIManager.createView( current, - renderLanes.uiViewClassName, + renderExpirationTime.uiViewClassName, rootContainerInstance, updatePayload ); rootContainerInstance = new ReactNativeFiberHostComponent( current, - renderLanes, + renderExpirationTime, workInProgress ); instanceCache.set(current, workInProgress); @@ -5024,32 +4622,49 @@ function completeWork(current, workInProgress, renderLanes) { pop(suspenseStackCursor); newProps = workInProgress.memoizedState; if (0 !== (workInProgress.effectTag & 64)) - return (workInProgress.lanes = renderLanes), workInProgress; + return ( + (workInProgress.expirationTime = renderExpirationTime), workInProgress + ); newProps = null !== newProps; rootContainerInstance = !1; null !== current && - (rootContainerInstance = null !== current.memoizedState); + ((renderExpirationTime = current.memoizedState), + (rootContainerInstance = null !== renderExpirationTime), + newProps || + null === renderExpirationTime || + ((renderExpirationTime = current.child.sibling), + null !== renderExpirationTime && + ((updatePayload = workInProgress.firstEffect), + null !== updatePayload + ? ((workInProgress.firstEffect = renderExpirationTime), + (renderExpirationTime.nextEffect = updatePayload)) + : ((workInProgress.firstEffect = workInProgress.lastEffect = renderExpirationTime), + (renderExpirationTime.nextEffect = null)), + (renderExpirationTime.effectTag = 8)))); if (newProps && !rootContainerInstance && 0 !== (workInProgress.mode & 2)) if ( (null === current && !0 !== workInProgress.memoizedProps.unstable_avoidThisFallback) || 0 !== (suspenseStackCursor.current & 1) ) - 0 === workInProgressRootExitStatus && - (workInProgressRootExitStatus = 3); + workInProgressRootExitStatus === RootIncomplete && + (workInProgressRootExitStatus = RootSuspended); else { if ( - 0 === workInProgressRootExitStatus || - 3 === workInProgressRootExitStatus + workInProgressRootExitStatus === RootIncomplete || + workInProgressRootExitStatus === RootSuspended ) - workInProgressRootExitStatus = 4; - null === workInProgressRoot || - (0 === (workInProgressRootSkippedLanes & 134217727) && - 0 === (workInProgressRootUpdatedLanes & 134217727)) || - markRootSuspended$1( + workInProgressRootExitStatus = RootSuspendedWithDelay; + 0 !== workInProgressRootNextUnprocessedUpdateTime && + null !== workInProgressRoot && + (markRootSuspendedAtTime( workInProgressRoot, - workInProgressRootRenderLanes - ); + renderExpirationTime$1 + ), + markRootUpdatedAtTime( + workInProgressRoot, + workInProgressRootNextUnprocessedUpdateTime + )); } if (newProps || rootContainerInstance) workInProgress.effectTag |= 4; return null; @@ -5069,7 +4684,7 @@ function completeWork(current, workInProgress, renderLanes) { if (rootContainerInstance) cutOffTailIfNeeded(newProps, !1); else { if ( - 0 !== workInProgressRootExitStatus || + workInProgressRootExitStatus !== RootIncomplete || (null !== current && 0 !== (current.effectTag & 64)) ) for (current = workInProgress.child; null !== current; ) { @@ -5084,27 +4699,27 @@ function completeWork(current, workInProgress, renderLanes) { null === newProps.lastEffect && (workInProgress.firstEffect = null); workInProgress.lastEffect = newProps.lastEffect; - current = renderLanes; + current = renderExpirationTime; for (newProps = workInProgress.child; null !== newProps; ) (rootContainerInstance = newProps), - (renderLanes = current), + (renderExpirationTime = current), (rootContainerInstance.effectTag &= 2), (rootContainerInstance.nextEffect = null), (rootContainerInstance.firstEffect = null), (rootContainerInstance.lastEffect = null), (updatePayload = rootContainerInstance.alternate), null === updatePayload - ? ((rootContainerInstance.childLanes = 0), - (rootContainerInstance.lanes = renderLanes), + ? ((rootContainerInstance.childExpirationTime = 0), + (rootContainerInstance.expirationTime = renderExpirationTime), (rootContainerInstance.child = null), (rootContainerInstance.memoizedProps = null), (rootContainerInstance.memoizedState = null), (rootContainerInstance.updateQueue = null), - (rootContainerInstance.dependencies = null), - (rootContainerInstance.stateNode = null)) - : ((rootContainerInstance.childLanes = - updatePayload.childLanes), - (rootContainerInstance.lanes = updatePayload.lanes), + (rootContainerInstance.dependencies = null)) + : ((rootContainerInstance.childExpirationTime = + updatePayload.childExpirationTime), + (rootContainerInstance.expirationTime = + updatePayload.expirationTime), (rootContainerInstance.child = updatePayload.child), (rootContainerInstance.memoizedProps = updatePayload.memoizedProps), @@ -5112,15 +4727,15 @@ function completeWork(current, workInProgress, renderLanes) { updatePayload.memoizedState), (rootContainerInstance.updateQueue = updatePayload.updateQueue), - (rootContainerInstance.type = updatePayload.type), - (renderLanes = updatePayload.dependencies), + (renderExpirationTime = updatePayload.dependencies), (rootContainerInstance.dependencies = - null === renderLanes + null === renderExpirationTime ? null : { - lanes: renderLanes.lanes, - firstContext: renderLanes.firstContext, - responders: renderLanes.responders + expirationTime: + renderExpirationTime.expirationTime, + firstContext: renderExpirationTime.firstContext, + responders: renderExpirationTime.responders })), (newProps = newProps.sibling); push( @@ -5157,11 +4772,12 @@ function completeWork(current, workInProgress, renderLanes) { ); } else 2 * now() - newProps.renderingStartTime > newProps.tailExpiration && - 1073741824 !== renderLanes && + 1 < renderExpirationTime && ((workInProgress.effectTag |= 64), (rootContainerInstance = !0), cutOffTailIfNeeded(newProps, !1), - (workInProgress.lanes = renderLanes)); + (workInProgress.expirationTime = workInProgress.childExpirationTime = + renderExpirationTime - 1)); newProps.isBackwards ? ((updatePayload.sibling = workInProgress.child), (workInProgress.child = updatePayload)) @@ -5189,17 +4805,6 @@ function completeWork(current, workInProgress, renderLanes) { ), current) : null; - case 23: - case 24: - return ( - popRenderLanes(), - null !== current && - (null !== current.memoizedState) !== - (null !== workInProgress.memoizedState) && - "unstable-defer-without-hiding" !== newProps.mode && - (workInProgress.effectTag |= 4), - null - ); } throw Error( "Unknown unit of work tag (" + @@ -5220,7 +4825,6 @@ function unwindWork(workInProgress) { popHostContainer(); pop(didPerformWorkStackCursor); pop(contextStackCursor); - resetWorkInProgressVersions(); effectTag = workInProgress.effectTag; if (0 !== (effectTag & 64)) throw Error( @@ -5245,9 +4849,6 @@ function unwindWork(workInProgress) { return popHostContainer(), null; case 10: return popProvider(workInProgress), null; - case 23: - case 24: - return popRenderLanes(), null; default: return null; } @@ -5266,61 +4867,51 @@ if ( throw Error( "Expected ReactFiberErrorDialog.showErrorDialog to be a function." ); -function logCapturedError(boundary, errorInfo) { +function logCapturedError(capturedError) { + !1 !== + ReactNativePrivateInterface.ReactFiberErrorDialog.showErrorDialog( + capturedError + ) && console.error(capturedError.error); +} +var PossiblyWeakSet = "function" === typeof WeakSet ? WeakSet : Set; +function logError(boundary, errorInfo) { + var source = errorInfo.source, + stack = errorInfo.stack; + null === stack && + null !== source && + (stack = getStackByFiberInDevAndProd(source)); + errorInfo = { + componentName: null !== source ? getComponentName(source.type) : null, + componentStack: null !== stack ? stack : "", + error: errorInfo.value, + errorBoundary: null, + errorBoundaryName: null, + errorBoundaryFound: !1, + willRetry: !1 + }; + null !== boundary && + 1 === boundary.tag && + ((errorInfo.errorBoundary = boundary.stateNode), + (errorInfo.errorBoundaryName = getComponentName(boundary.type)), + (errorInfo.errorBoundaryFound = !0), + (errorInfo.willRetry = !0)); try { - !1 !== - ReactNativePrivateInterface.ReactFiberErrorDialog.showErrorDialog({ - componentStack: null !== errorInfo.stack ? errorInfo.stack : "", - error: errorInfo.value, - errorBoundary: - null !== boundary && 1 === boundary.tag ? boundary.stateNode : null - }) && console.error(errorInfo.value); + logCapturedError(errorInfo); } catch (e) { setTimeout(function() { throw e; }); } } -var PossiblyWeakMap = "function" === typeof WeakMap ? WeakMap : Map; -function createRootErrorUpdate(fiber, errorInfo, lane) { - lane = createUpdate(-1, lane, null); - lane.tag = 3; - lane.payload = { element: null }; - var error = errorInfo.value; - lane.callback = function() { - hasUncaughtError || ((hasUncaughtError = !0), (firstUncaughtError = error)); - logCapturedError(fiber, errorInfo); - }; - return lane; -} -function createClassErrorUpdate(fiber, errorInfo, lane) { - lane = createUpdate(-1, lane, null); - lane.tag = 3; - var getDerivedStateFromError = fiber.type.getDerivedStateFromError; - if ("function" === typeof getDerivedStateFromError) { - var error = errorInfo.value; - lane.payload = function() { - logCapturedError(fiber, errorInfo); - return getDerivedStateFromError(error); - }; +function safelyCallComponentWillUnmount(current, instance) { + try { + (instance.props = current.memoizedProps), + (instance.state = current.memoizedState), + instance.componentWillUnmount(); + } catch (unmountError) { + captureCommitPhaseError(current, unmountError); } - var inst = fiber.stateNode; - null !== inst && - "function" === typeof inst.componentDidCatch && - (lane.callback = function() { - "function" !== typeof getDerivedStateFromError && - (null === legacyErrorBoundariesThatAlreadyFailed - ? (legacyErrorBoundariesThatAlreadyFailed = new Set([this])) - : legacyErrorBoundariesThatAlreadyFailed.add(this), - logCapturedError(fiber, errorInfo)); - var stack = errorInfo.stack; - this.componentDidCatch(errorInfo.value, { - componentStack: null !== stack ? stack : "" - }); - }); - return lane; } -var PossiblyWeakSet = "function" === typeof WeakSet ? WeakSet : Set; function safelyDetachRef(current) { var ref = current.ref; if (null !== ref) @@ -5354,7 +4945,6 @@ function commitBeforeMutationLifeCycles(current, finishedWork) { } return; case 3: - return; case 5: case 6: case 4: @@ -5365,57 +4955,58 @@ function commitBeforeMutationLifeCycles(current, finishedWork) { "This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue." ); } +function commitHookEffectListUnmount(tag, finishedWork) { + finishedWork = finishedWork.updateQueue; + finishedWork = null !== finishedWork ? finishedWork.lastEffect : null; + if (null !== finishedWork) { + var effect = (finishedWork = finishedWork.next); + do { + if ((effect.tag & tag) === tag) { + var destroy = effect.destroy; + effect.destroy = void 0; + void 0 !== destroy && destroy(); + } + effect = effect.next; + } while (effect !== finishedWork); + } +} +function commitHookEffectListMount(tag, finishedWork) { + finishedWork = finishedWork.updateQueue; + finishedWork = null !== finishedWork ? finishedWork.lastEffect : null; + if (null !== finishedWork) { + var effect = (finishedWork = finishedWork.next); + do { + if ((effect.tag & tag) === tag) { + var create = effect.create; + effect.destroy = create(); + } + effect = effect.next; + } while (effect !== finishedWork); + } +} function commitLifeCycles(finishedRoot, current, finishedWork) { switch (finishedWork.tag) { case 0: case 11: case 15: case 22: - current = finishedWork.updateQueue; - current = null !== current ? current.lastEffect : null; - if (null !== current) { - finishedRoot = current = current.next; - do { - if (3 === (finishedRoot.tag & 3)) { - var create$81 = finishedRoot.create; - finishedRoot.destroy = create$81(); - } - finishedRoot = finishedRoot.next; - } while (finishedRoot !== current); - } - current = finishedWork.updateQueue; - current = null !== current ? current.lastEffect : null; - if (null !== current) { - finishedRoot = current = current.next; - do { - var _effect = finishedRoot; - create$81 = _effect.next; - _effect = _effect.tag; - 0 !== (_effect & 4) && - 0 !== (_effect & 1) && - (enqueuePendingPassiveHookEffectUnmount(finishedWork, finishedRoot), - enqueuePendingPassiveHookEffectMount(finishedWork, finishedRoot)); - finishedRoot = create$81; - } while (finishedRoot !== current); - } + commitHookEffectListMount(3, finishedWork); return; case 1: finishedRoot = finishedWork.stateNode; - finishedWork.effectTag & 4 && - (null === current - ? finishedRoot.componentDidMount() - : ((create$81 = - finishedWork.elementType === finishedWork.type - ? current.memoizedProps - : resolveDefaultProps( - finishedWork.type, - current.memoizedProps - )), - finishedRoot.componentDidUpdate( - create$81, - current.memoizedState, - finishedRoot.__reactInternalSnapshotBeforeUpdate - ))); + if (finishedWork.effectTag & 4) + if (null === current) finishedRoot.componentDidMount(); + else { + var prevProps = + finishedWork.elementType === finishedWork.type + ? current.memoizedProps + : resolveDefaultProps(finishedWork.type, current.memoizedProps); + finishedRoot.componentDidUpdate( + prevProps, + current.memoizedState, + finishedRoot.__reactInternalSnapshotBeforeUpdate + ); + } current = finishedWork.updateQueue; null !== current && commitUpdateQueue(finishedWork, current, finishedRoot); @@ -5449,139 +5040,78 @@ function commitLifeCycles(finishedRoot, current, finishedWork) { case 17: case 20: case 21: - case 23: - case 24: return; } throw Error( "This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue." ); } -function hideOrUnhideAllChildren(finishedWork, isHidden) { - for (var node = finishedWork; ; ) { - if (5 === node.tag) { - var instance = node.stateNode; - if (isHidden) { - var viewConfig = instance.viewConfig; - var updatePayload = diffProperties( - null, - emptyObject, - { style: { display: "none" } }, - viewConfig.validAttributes - ); - ReactNativePrivateInterface.UIManager.updateView( - instance._nativeTag, - viewConfig.uiViewClassName, - updatePayload - ); - } else { - instance = node.stateNode; - updatePayload = node.memoizedProps; - viewConfig = instance.viewConfig; - var prevProps = Object.assign({}, updatePayload, { - style: [updatePayload.style, { display: "none" }] - }); - updatePayload = diffProperties( - null, - prevProps, - updatePayload, - viewConfig.validAttributes - ); - ReactNativePrivateInterface.UIManager.updateView( - instance._nativeTag, - viewConfig.uiViewClassName, - updatePayload - ); - } - } else { - if (6 === node.tag) throw Error("Not yet implemented."); - if ( - ((23 !== node.tag && 24 !== node.tag) || - null === node.memoizedState || - node === finishedWork) && - null !== node.child - ) { - node.child.return = node; - node = node.child; - continue; - } - } - if (node === finishedWork) break; - for (; null === node.sibling; ) { - if (null === node.return || node.return === finishedWork) return; - node = node.return; - } - node.sibling.return = node.return; - node = node.sibling; - } -} -function commitUnmount(finishedRoot, current) { - if (injectedHook && "function" === typeof injectedHook.onCommitFiberUnmount) - try { - injectedHook.onCommitFiberUnmount(rendererID, current); - } catch (err) {} - switch (current.tag) { +function commitUnmount(finishedRoot, current$jscomp$0, renderPriorityLevel) { + "function" === typeof onCommitFiberUnmount && + onCommitFiberUnmount(current$jscomp$0); + switch (current$jscomp$0.tag) { case 0: case 11: case 14: case 15: case 22: - finishedRoot = current.updateQueue; + finishedRoot = current$jscomp$0.updateQueue; if ( null !== finishedRoot && ((finishedRoot = finishedRoot.lastEffect), null !== finishedRoot) ) { - var effect = (finishedRoot = finishedRoot.next); - do { - var _effect2 = effect, - destroy = _effect2.destroy; - _effect2 = _effect2.tag; - if (void 0 !== destroy) - if (0 !== (_effect2 & 4)) - enqueuePendingPassiveHookEffectUnmount(current, effect); - else { - _effect2 = current; - try { - destroy(); - } catch (error) { - captureCommitPhaseError(_effect2, error); + var firstEffect = finishedRoot.next; + runWithPriority( + 97 < renderPriorityLevel ? 97 : renderPriorityLevel, + function() { + var effect = firstEffect; + do { + var _destroy = effect.destroy; + if (void 0 !== _destroy) { + var current = current$jscomp$0; + try { + _destroy(); + } catch (error) { + captureCommitPhaseError(current, error); + } } - } - effect = effect.next; - } while (effect !== finishedRoot); + effect = effect.next; + } while (effect !== firstEffect); + } + ); } break; case 1: - safelyDetachRef(current); - finishedRoot = current.stateNode; - if ("function" === typeof finishedRoot.componentWillUnmount) - try { - (finishedRoot.props = current.memoizedProps), - (finishedRoot.state = current.memoizedState), - finishedRoot.componentWillUnmount(); - } catch (unmountError) { - captureCommitPhaseError(current, unmountError); - } + safelyDetachRef(current$jscomp$0); + renderPriorityLevel = current$jscomp$0.stateNode; + "function" === typeof renderPriorityLevel.componentWillUnmount && + safelyCallComponentWillUnmount(current$jscomp$0, renderPriorityLevel); break; case 5: - safelyDetachRef(current); + safelyDetachRef(current$jscomp$0); break; case 4: - unmountHostComponents(finishedRoot, current); + unmountHostComponents( + finishedRoot, + current$jscomp$0, + renderPriorityLevel + ); } } -function detachFiberMutation(fiber) { - fiber.alternate = null; - fiber.child = null; - fiber.dependencies = null; - fiber.firstEffect = null; - fiber.lastEffect = null; - fiber.memoizedProps = null; - fiber.memoizedState = null; - fiber.pendingProps = null; - fiber.return = null; - fiber.stateNode = null; - fiber.updateQueue = null; +function detachFiber(current) { + var alternate = current.alternate; + current.return = null; + current.child = null; + current.memoizedState = null; + current.updateQueue = null; + current.dependencies = null; + current.alternate = null; + current.firstEffect = null; + current.lastEffect = null; + current.pendingProps = null; + current.memoizedProps = null; + current.stateNode = null; + null !== alternate && detachFiber(alternate); } function isHostParent(fiber) { return 5 === fiber.tag || 3 === fiber.tag || 4 === fiber.tag; @@ -5589,14 +5119,16 @@ function isHostParent(fiber) { function commitPlacement(finishedWork) { a: { for (var parent = finishedWork.return; null !== parent; ) { - if (isHostParent(parent)) break a; + if (isHostParent(parent)) { + var parentFiber = parent; + break a; + } parent = parent.return; } throw Error( "Expected to find a host parent. This error is likely caused by a bug in React. Please file an issue." ); } - var parentFiber = parent; parent = parentFiber.stateNode; switch (parentFiber.tag) { case 5: @@ -5731,7 +5263,11 @@ function insertOrAppendPlacementNode(node, before, parent) { ) insertOrAppendPlacementNode(node, before, parent), (node = node.sibling); } -function unmountHostComponents(finishedRoot$jscomp$0, current) { +function unmountHostComponents( + finishedRoot$jscomp$0, + current, + renderPriorityLevel$jscomp$0 +) { for ( var node = current, currentParentIsValid = !1, @@ -5769,12 +5305,13 @@ function unmountHostComponents(finishedRoot$jscomp$0, current) { a: for ( var finishedRoot = finishedRoot$jscomp$0, root = node, + renderPriorityLevel = renderPriorityLevel$jscomp$0, node$jscomp$0 = root; ; ) if ( - (commitUnmount(finishedRoot, node$jscomp$0), + (commitUnmount(finishedRoot, node$jscomp$0, renderPriorityLevel), null !== node$jscomp$0.child && 4 !== node$jscomp$0.tag) ) (node$jscomp$0.child.return = node$jscomp$0), @@ -5801,18 +5338,18 @@ function unmountHostComponents(finishedRoot$jscomp$0, current) { [0] )) : ((finishedRoot = currentParent), - (node$jscomp$0 = node.stateNode), - recursivelyUncacheFiberNode(node$jscomp$0), + (renderPriorityLevel = node.stateNode), + recursivelyUncacheFiberNode(renderPriorityLevel), (root = finishedRoot._children), - (node$jscomp$0 = root.indexOf(node$jscomp$0)), - root.splice(node$jscomp$0, 1), + (renderPriorityLevel = root.indexOf(renderPriorityLevel)), + root.splice(renderPriorityLevel, 1), ReactNativePrivateInterface.UIManager.manageChildren( finishedRoot._nativeTag, [], [], [], [], - [node$jscomp$0] + [renderPriorityLevel] )); } else if (4 === node.tag) { if (null !== node.child) { @@ -5823,7 +5360,8 @@ function unmountHostComponents(finishedRoot$jscomp$0, current) { continue; } } else if ( - (commitUnmount(finishedRoot$jscomp$0, node), null !== node.child) + (commitUnmount(finishedRoot$jscomp$0, node, renderPriorityLevel$jscomp$0), + null !== node.child) ) { node.child.return = node; node = node.child; @@ -5846,42 +5384,31 @@ function commitWork(current, finishedWork) { case 14: case 15: case 22: - var updateQueue = finishedWork.updateQueue; - updateQueue = null !== updateQueue ? updateQueue.lastEffect : null; - if (null !== updateQueue) { - var effect = (updateQueue = updateQueue.next); - do - 3 === (effect.tag & 3) && - ((finishedWork = effect.destroy), - (effect.destroy = void 0), - void 0 !== finishedWork && finishedWork()), - (effect = effect.next); - while (effect !== updateQueue); - } + commitHookEffectListUnmount(3, finishedWork); return; case 1: return; case 5: - updateQueue = finishedWork.stateNode; - if (null != updateQueue) { - effect = finishedWork.memoizedProps; - current = null !== current ? current.memoizedProps : effect; + var instance = finishedWork.stateNode; + if (null != instance) { + var newProps = finishedWork.memoizedProps; + current = null !== current ? current.memoizedProps : newProps; var updatePayload = finishedWork.updateQueue; finishedWork.updateQueue = null; null !== updatePayload && - ((finishedWork = updateQueue.viewConfig), - instanceProps.set(updateQueue._nativeTag, effect), - (effect = diffProperties( + ((finishedWork = instance.viewConfig), + instanceProps.set(instance._nativeTag, newProps), + (newProps = diffProperties( null, current, - effect, + newProps, finishedWork.validAttributes )), - null != effect && + null != newProps && ReactNativePrivateInterface.UIManager.updateView( - updateQueue._nativeTag, + instance._nativeTag, finishedWork.uiViewClassName, - effect + newProps )); } return; @@ -5901,9 +5428,72 @@ function commitWork(current, finishedWork) { case 12: return; case 13: - null !== finishedWork.memoizedState && - ((globalMostRecentFallbackTime = now()), - hideOrUnhideAllChildren(finishedWork.child, !0)); + instance = finishedWork; + null === finishedWork.memoizedState + ? (newProps = !1) + : ((newProps = !0), + (instance = finishedWork.child), + (globalMostRecentFallbackTime = now())); + if (null !== instance) + a: for (current = instance; ; ) { + if (5 === current.tag) + if (((updatePayload = current.stateNode), newProps)) { + var viewConfig = updatePayload.viewConfig; + var updatePayload$jscomp$0 = diffProperties( + null, + emptyObject, + { style: { display: "none" } }, + viewConfig.validAttributes + ); + ReactNativePrivateInterface.UIManager.updateView( + updatePayload._nativeTag, + viewConfig.uiViewClassName, + updatePayload$jscomp$0 + ); + } else { + updatePayload = current.stateNode; + updatePayload$jscomp$0 = current.memoizedProps; + viewConfig = updatePayload.viewConfig; + var prevProps = Object.assign({}, updatePayload$jscomp$0, { + style: [updatePayload$jscomp$0.style, { display: "none" }] + }); + updatePayload$jscomp$0 = diffProperties( + null, + prevProps, + updatePayload$jscomp$0, + viewConfig.validAttributes + ); + ReactNativePrivateInterface.UIManager.updateView( + updatePayload._nativeTag, + viewConfig.uiViewClassName, + updatePayload$jscomp$0 + ); + } + else { + if (6 === current.tag) throw Error("Not yet implemented."); + if ( + 13 === current.tag && + null !== current.memoizedState && + null === current.memoizedState.dehydrated + ) { + updatePayload = current.child.sibling; + updatePayload.return = current; + current = updatePayload; + continue; + } else if (null !== current.child) { + current.child.return = current; + current = current.child; + continue; + } + } + if (current === instance) break; + for (; null === current.sibling; ) { + if (null === current.return || current.return === instance) break a; + current = current.return; + } + current.sibling.return = current.return; + current = current.sibling; + } attachSuspenseRetryListeners(finishedWork); return; case 19: @@ -5911,59 +5501,90 @@ function commitWork(current, finishedWork) { return; case 17: return; - case 23: - case 24: - hideOrUnhideAllChildren( - finishedWork, - null !== finishedWork.memoizedState - ); - return; } throw Error( "This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue." ); } function attachSuspenseRetryListeners(finishedWork) { - var wakeables = finishedWork.updateQueue; - if (null !== wakeables) { + var thenables = finishedWork.updateQueue; + if (null !== thenables) { finishedWork.updateQueue = null; var retryCache = finishedWork.stateNode; null === retryCache && (retryCache = finishedWork.stateNode = new PossiblyWeakSet()); - wakeables.forEach(function(wakeable) { - var retry = resolveRetryWakeable.bind(null, finishedWork, wakeable); - retryCache.has(wakeable) || - (retryCache.add(wakeable), wakeable.then(retry, retry)); + thenables.forEach(function(thenable) { + var retry = resolveRetryThenable.bind(null, finishedWork, thenable); + retryCache.has(thenable) || + (retryCache.add(thenable), thenable.then(retry, retry)); }); } } -function isSuspenseBoundaryBeingHidden(current, finishedWork) { - return null !== current && - ((current = current.memoizedState), - null === current || null !== current.dehydrated) - ? ((finishedWork = finishedWork.memoizedState), - null !== finishedWork && null === finishedWork.dehydrated) - : !1; +var PossiblyWeakMap = "function" === typeof WeakMap ? WeakMap : Map; +function createRootErrorUpdate(fiber, errorInfo, expirationTime) { + expirationTime = createUpdate(expirationTime, null); + expirationTime.tag = 3; + expirationTime.payload = { element: null }; + var error = errorInfo.value; + expirationTime.callback = function() { + hasUncaughtError || ((hasUncaughtError = !0), (firstUncaughtError = error)); + logError(fiber, errorInfo); + }; + return expirationTime; +} +function createClassErrorUpdate(fiber, errorInfo, expirationTime) { + expirationTime = createUpdate(expirationTime, null); + expirationTime.tag = 3; + var getDerivedStateFromError = fiber.type.getDerivedStateFromError; + if ("function" === typeof getDerivedStateFromError) { + var error = errorInfo.value; + expirationTime.payload = function() { + logError(fiber, errorInfo); + return getDerivedStateFromError(error); + }; + } + var inst = fiber.stateNode; + null !== inst && + "function" === typeof inst.componentDidCatch && + (expirationTime.callback = function() { + "function" !== typeof getDerivedStateFromError && + (null === legacyErrorBoundariesThatAlreadyFailed + ? (legacyErrorBoundariesThatAlreadyFailed = new Set([this])) + : legacyErrorBoundariesThatAlreadyFailed.add(this), + logError(fiber, errorInfo)); + var stack = errorInfo.stack; + this.componentDidCatch(errorInfo.value, { + componentStack: null !== stack ? stack : "" + }); + }); + return expirationTime; } var ceil = Math.ceil, - ReactCurrentDispatcher$2 = ReactSharedInternals.ReactCurrentDispatcher, + ReactCurrentDispatcher$1 = ReactSharedInternals.ReactCurrentDispatcher, ReactCurrentOwner$2 = ReactSharedInternals.ReactCurrentOwner, - executionContext = 0, + NoContext = 0, + LegacyUnbatchedContext = 8, + RenderContext = 16, + CommitContext = 32, + RootIncomplete = 0, + RootFatalErrored = 1, + RootErrored = 2, + RootSuspended = 3, + RootSuspendedWithDelay = 4, + RootCompleted = 5, + executionContext = NoContext, workInProgressRoot = null, workInProgress = null, - workInProgressRootRenderLanes = 0, - subtreeRenderLanes = 0, - subtreeRenderLanesCursor = createCursor(0), - workInProgressRootExitStatus = 0, + renderExpirationTime$1 = 0, + workInProgressRootExitStatus = RootIncomplete, workInProgressRootFatalError = null, - workInProgressRootLatestSuspenseTimeout = -1, + workInProgressRootLatestProcessedExpirationTime = 1073741823, + workInProgressRootLatestSuspenseTimeout = 1073741823, workInProgressRootCanSuspendUsingConfig = null, - workInProgressRootIncludedLanes = 0, - workInProgressRootSkippedLanes = 0, - workInProgressRootUpdatedLanes = 0, - workInProgressRootPingedLanes = 0, - mostRecentlyUpdatedRoot = null, + workInProgressRootNextUnprocessedUpdateTime = 0, + workInProgressRootHasPendingPing = !1, globalMostRecentFallbackTime = 0, + FALLBACK_THROTTLE_MS = 500, nextEffect = null, hasUncaughtError = !1, firstUncaughtError = null, @@ -5971,200 +5592,205 @@ var ceil = Math.ceil, rootDoesHavePassiveEffects = !1, rootWithPendingPassiveEffects = null, pendingPassiveEffectsRenderPriority = 90, - pendingPassiveHookEffectsMount = [], - pendingPassiveHookEffectsUnmount = [], rootsWithPendingDiscreteUpdates = null, nestedUpdateCount = 0, rootWithNestedUpdates = null, - currentEventTime = -1, - currentEventWipLanes = 0, - currentEventPendingLanes = 0, - focusedInstanceHandle = null, - shouldFireAfterActiveInstanceBlur = !1; -function requestEventTime() { - return 0 !== (executionContext & 48) - ? now() - : -1 !== currentEventTime + currentEventTime = 0; +function requestCurrentTimeForUpdate() { + return (executionContext & (RenderContext | CommitContext)) !== NoContext + ? 1073741821 - ((now() / 10) | 0) + : 0 !== currentEventTime ? currentEventTime - : (currentEventTime = now()); + : (currentEventTime = 1073741821 - ((now() / 10) | 0)); } -function requestUpdateLane(fiber, suspenseConfig) { +function computeExpirationForFiber(currentTime, fiber, suspenseConfig) { fiber = fiber.mode; - if (0 === (fiber & 2)) return 1; - if (0 === (fiber & 4)) return 99 === getCurrentPriorityLevel() ? 1 : 2; - 0 === currentEventWipLanes && - (currentEventWipLanes = workInProgressRootIncludedLanes); - if (null !== suspenseConfig) { - suspenseConfig = suspenseConfig.timeoutMs; - fiber = void 0 === suspenseConfig || 1e4 > (suspenseConfig | 0) ? 8 : 6; - 0 !== currentEventPendingLanes && - (currentEventPendingLanes = - null !== mostRecentlyUpdatedRoot - ? mostRecentlyUpdatedRoot.pendingLanes - : 0); - suspenseConfig = currentEventWipLanes; - var pendingLanes = currentEventPendingLanes; - if (8 === fiber) - (fiber = pickArbitraryLane(122880 & ~pendingLanes)), - 0 === fiber && - ((fiber = pickArbitraryLane(122880 & ~suspenseConfig)), - 0 === fiber && (fiber = 8192)), - (suspenseConfig = fiber); - else if (6 === fiber) - (fiber = pickArbitraryLane(3932160 & ~pendingLanes)), - 0 === fiber && - ((fiber = pickArbitraryLane(3932160 & ~suspenseConfig)), - 0 === fiber && (fiber = 262144)), - (suspenseConfig = fiber); - else - throw Error( - "Invalid transition priority: " + fiber + ". This is a bug in React." - ); - return suspenseConfig; - } - suspenseConfig = getCurrentPriorityLevel(); - 0 !== (executionContext & 4) && 98 === suspenseConfig - ? (suspenseConfig = findUpdateLane(14, currentEventWipLanes)) - : ((suspenseConfig = schedulerPriorityToLanePriority(suspenseConfig)), - (suspenseConfig = findUpdateLane(suspenseConfig, currentEventWipLanes))); - return suspenseConfig; + if (0 === (fiber & 2)) return 1073741823; + var priorityLevel = getCurrentPriorityLevel(); + if (0 === (fiber & 4)) return 99 === priorityLevel ? 1073741823 : 1073741822; + if ((executionContext & RenderContext) !== NoContext) + return renderExpirationTime$1; + if (null !== suspenseConfig) + currentTime = + 1073741821 - + 25 * + ((((1073741821 - + currentTime + + (suspenseConfig.timeoutMs | 0 || 5e3) / 10) / + 25) | + 0) + + 1); + else + switch (priorityLevel) { + case 99: + currentTime = 1073741823; + break; + case 98: + currentTime = + 1073741821 - 10 * ((((1073741821 - currentTime + 15) / 10) | 0) + 1); + break; + case 97: + case 96: + currentTime = + 1073741821 - 25 * ((((1073741821 - currentTime + 500) / 25) | 0) + 1); + break; + case 95: + currentTime = 2; + break; + default: + throw Error("Expected a valid priority level"); + } + null !== workInProgressRoot && + currentTime === renderExpirationTime$1 && + --currentTime; + return currentTime; } -function scheduleUpdateOnFiber(fiber, lane, eventTime) { +function scheduleWork(fiber, expirationTime) { if (50 < nestedUpdateCount) throw ((nestedUpdateCount = 0), (rootWithNestedUpdates = null), Error( "Maximum update depth exceeded. This can happen when a component repeatedly calls setState inside componentWillUpdate or componentDidUpdate. React limits the number of nested updates to prevent infinite loops." )); - fiber = markUpdateLaneFromFiberToRoot(fiber, lane); - if (null === fiber) return null; - markRootUpdated(fiber, lane, eventTime); - fiber === workInProgressRoot && - ((workInProgressRootUpdatedLanes |= lane), - 4 === workInProgressRootExitStatus && - markRootSuspended$1(fiber, workInProgressRootRenderLanes)); - var priorityLevel = getCurrentPriorityLevel(); - 1 === lane - ? 0 !== (executionContext & 8) && 0 === (executionContext & 48) - ? performSyncWorkOnRoot(fiber) - : (ensureRootIsScheduled(fiber, eventTime), - 0 === executionContext && flushSyncCallbackQueue()) - : (0 === (executionContext & 4) || - (98 !== priorityLevel && 99 !== priorityLevel) || - (null === rootsWithPendingDiscreteUpdates - ? (rootsWithPendingDiscreteUpdates = new Set([fiber])) - : rootsWithPendingDiscreteUpdates.add(fiber)), - ensureRootIsScheduled(fiber, eventTime)); - mostRecentlyUpdatedRoot = fiber; -} -function markUpdateLaneFromFiberToRoot(sourceFiber, lane) { - sourceFiber.lanes |= lane; - var alternate = sourceFiber.alternate; - null !== alternate && (alternate.lanes |= lane); - alternate = sourceFiber; - for (sourceFiber = sourceFiber.return; null !== sourceFiber; ) - (sourceFiber.childLanes |= lane), - (alternate = sourceFiber.alternate), - null !== alternate && (alternate.childLanes |= lane), - (alternate = sourceFiber), - (sourceFiber = sourceFiber.return); - return 3 === alternate.tag ? alternate.stateNode : null; -} -function ensureRootIsScheduled(root, currentTime) { - for ( - var existingCallbackNode = root.callbackNode, - suspendedLanes = root.suspendedLanes, - pingedLanes = root.pingedLanes, - expirationTimes = root.expirationTimes, - lanes = root.pendingLanes; - 0 < lanes; - - ) { - var index$7 = 31 - clz32(lanes), - lane = 1 << index$7, - expirationTime = expirationTimes[index$7]; - if (-1 === expirationTime) { - if (0 === (lane & suspendedLanes) || 0 !== (lane & pingedLanes)) { - expirationTime = currentTime; - getHighestPriorityLanes(lane); - var priority = return_highestLanePriority; - expirationTimes[index$7] = - 12 <= priority - ? expirationTime + 1e3 - : 6 <= priority - ? expirationTime + 5e3 - : -1; - } - } else expirationTime <= currentTime && (root.expiredLanes |= lane); - lanes &= ~lane; + fiber = markUpdateTimeFromFiberToRoot(fiber, expirationTime); + if (null !== fiber) { + var priorityLevel = getCurrentPriorityLevel(); + 1073741823 === expirationTime + ? (executionContext & LegacyUnbatchedContext) !== NoContext && + (executionContext & (RenderContext | CommitContext)) === NoContext + ? performSyncWorkOnRoot(fiber) + : (ensureRootIsScheduled(fiber), + executionContext === NoContext && flushSyncCallbackQueue()) + : ensureRootIsScheduled(fiber); + (executionContext & 4) === NoContext || + (98 !== priorityLevel && 99 !== priorityLevel) || + (null === rootsWithPendingDiscreteUpdates + ? (rootsWithPendingDiscreteUpdates = new Map([[fiber, expirationTime]])) + : ((priorityLevel = rootsWithPendingDiscreteUpdates.get(fiber)), + (void 0 === priorityLevel || priorityLevel > expirationTime) && + rootsWithPendingDiscreteUpdates.set(fiber, expirationTime))); } - suspendedLanes = getNextLanes( - root, - root === workInProgressRoot ? workInProgressRootRenderLanes : 0 - ); - currentTime = return_highestLanePriority; - if (0 === suspendedLanes) - null !== existingCallbackNode && - (existingCallbackNode !== fakeCallbackNode && - Scheduler_cancelCallback(existingCallbackNode), - (root.callbackNode = null), - (root.callbackPriority = 0)); +} +function markUpdateTimeFromFiberToRoot(fiber, expirationTime) { + fiber.expirationTime < expirationTime && + (fiber.expirationTime = expirationTime); + var alternate = fiber.alternate; + null !== alternate && + alternate.expirationTime < expirationTime && + (alternate.expirationTime = expirationTime); + var node = fiber.return, + root = null; + if (null === node && 3 === fiber.tag) root = fiber.stateNode; + else + for (; null !== node; ) { + alternate = node.alternate; + node.childExpirationTime < expirationTime && + (node.childExpirationTime = expirationTime); + null !== alternate && + alternate.childExpirationTime < expirationTime && + (alternate.childExpirationTime = expirationTime); + if (null === node.return && 3 === node.tag) { + root = node.stateNode; + break; + } + node = node.return; + } + null !== root && + (workInProgressRoot === root && + (markUnprocessedUpdateTime(expirationTime), + workInProgressRootExitStatus === RootSuspendedWithDelay && + markRootSuspendedAtTime(root, renderExpirationTime$1)), + markRootUpdatedAtTime(root, expirationTime)); + return root; +} +function getNextRootExpirationTimeToWorkOn(root) { + var lastExpiredTime = root.lastExpiredTime; + if (0 !== lastExpiredTime) return lastExpiredTime; + lastExpiredTime = root.firstPendingTime; + if (!isRootSuspendedAtTime(root, lastExpiredTime)) return lastExpiredTime; + var lastPingedTime = root.lastPingedTime; + root = root.nextKnownPendingLevel; + root = lastPingedTime > root ? lastPingedTime : root; + return 2 >= root && lastExpiredTime !== root ? 0 : root; +} +function ensureRootIsScheduled(root) { + if (0 !== root.lastExpiredTime) + (root.callbackExpirationTime = 1073741823), + (root.callbackPriority = 99), + (root.callbackNode = scheduleSyncCallback( + performSyncWorkOnRoot.bind(null, root) + )); else { - if (null !== existingCallbackNode) { - if (root.callbackPriority === currentTime) return; - existingCallbackNode !== fakeCallbackNode && - Scheduler_cancelCallback(existingCallbackNode); + var expirationTime = getNextRootExpirationTimeToWorkOn(root), + existingCallbackNode = root.callbackNode; + if (0 === expirationTime) + null !== existingCallbackNode && + ((root.callbackNode = null), + (root.callbackExpirationTime = 0), + (root.callbackPriority = 90)); + else { + var priorityLevel = requestCurrentTimeForUpdate(); + 1073741823 === expirationTime + ? (priorityLevel = 99) + : 1 === expirationTime || 2 === expirationTime + ? (priorityLevel = 95) + : ((priorityLevel = + 10 * (1073741821 - expirationTime) - + 10 * (1073741821 - priorityLevel)), + (priorityLevel = + 0 >= priorityLevel + ? 99 + : 250 >= priorityLevel + ? 98 + : 5250 >= priorityLevel + ? 97 + : 95)); + if (null !== existingCallbackNode) { + var existingCallbackPriority = root.callbackPriority; + if ( + root.callbackExpirationTime === expirationTime && + existingCallbackPriority >= priorityLevel + ) + return; + existingCallbackNode !== fakeCallbackNode && + Scheduler_cancelCallback(existingCallbackNode); + } + root.callbackExpirationTime = expirationTime; + root.callbackPriority = priorityLevel; + expirationTime = + 1073741823 === expirationTime + ? scheduleSyncCallback(performSyncWorkOnRoot.bind(null, root)) + : scheduleCallback( + priorityLevel, + performConcurrentWorkOnRoot.bind(null, root), + { timeout: 10 * (1073741821 - expirationTime) - now() } + ); + root.callbackNode = expirationTime; } - 17 === currentTime - ? ((existingCallbackNode = performSyncWorkOnRoot.bind(null, root)), - null === syncQueue - ? ((syncQueue = [existingCallbackNode]), - (immediateQueueCallbackNode = Scheduler_scheduleCallback( - Scheduler_ImmediatePriority, - flushSyncCallbackQueueImpl - ))) - : syncQueue.push(existingCallbackNode), - (existingCallbackNode = fakeCallbackNode)) - : 16 === currentTime - ? (existingCallbackNode = scheduleCallback( - 99, - performSyncWorkOnRoot.bind(null, root) - )) - : ((existingCallbackNode = lanePriorityToSchedulerPriority(currentTime)), - (existingCallbackNode = scheduleCallback( - existingCallbackNode, - performConcurrentWorkOnRoot.bind(null, root) - ))); - root.callbackPriority = currentTime; - root.callbackNode = existingCallbackNode; } } function performConcurrentWorkOnRoot(root, didTimeout) { - currentEventTime = -1; - currentEventPendingLanes = currentEventWipLanes = 0; - if (0 !== (executionContext & 48)) - throw Error("Should not already be working."); - var originalCallbackNode = root.callbackNode; - if (flushPassiveEffects() && root.callbackNode !== originalCallbackNode) + currentEventTime = 0; + if (didTimeout) { + didTimeout = requestCurrentTimeForUpdate(); + var lastExpiredTime = root.lastExpiredTime; + if (0 === lastExpiredTime || lastExpiredTime > didTimeout) + root.lastExpiredTime = didTimeout; + ensureRootIsScheduled(root); return null; - var lanes = getNextLanes( - root, - root === workInProgressRoot ? workInProgressRootRenderLanes : 0 - ); - if (0 === lanes) return null; - if (didTimeout) - return ( - (root.expiredLanes |= lanes & root.pendingLanes), - ensureRootIsScheduled(root, now()), - null - ); - didTimeout = lanes; - var prevExecutionContext = executionContext; - executionContext |= 16; + } + lastExpiredTime = getNextRootExpirationTimeToWorkOn(root); + if (0 === lastExpiredTime) return null; + didTimeout = root.callbackNode; + if ((executionContext & (RenderContext | CommitContext)) !== NoContext) + throw Error("Should not already be working."); + flushPassiveEffects(); + var expirationTime = lastExpiredTime; + var exitStatus = executionContext; + executionContext |= RenderContext; var prevDispatcher = pushDispatcher(); - (workInProgressRoot === root && - workInProgressRootRenderLanes === didTimeout) || - prepareFreshStack(root, didTimeout); + (root === workInProgressRoot && expirationTime === renderExpirationTime$1) || + prepareFreshStack(root, expirationTime); do try { workLoopConcurrent(); @@ -6174,189 +5800,199 @@ function performConcurrentWorkOnRoot(root, didTimeout) { } while (1); resetContextDependencies(); - ReactCurrentDispatcher$2.current = prevDispatcher; - executionContext = prevExecutionContext; + ReactCurrentDispatcher$1.current = prevDispatcher; + executionContext = exitStatus; null !== workInProgress - ? (didTimeout = 0) + ? (exitStatus = RootIncomplete) : ((workInProgressRoot = null), - (workInProgressRootRenderLanes = 0), - (didTimeout = workInProgressRootExitStatus)); - if (0 !== (workInProgressRootIncludedLanes & workInProgressRootUpdatedLanes)) - prepareFreshStack(root, 0); - else if (0 !== didTimeout) { - 2 === didTimeout && - ((executionContext |= 64), - root.hydrate && (root.hydrate = !1), - (lanes = getLanesToRetrySynchronouslyOnError(root)), - 0 !== lanes && (didTimeout = renderRootSync(root, lanes))); - if (1 === didTimeout) - throw ((originalCallbackNode = workInProgressRootFatalError), - prepareFreshStack(root, 0), - markRootSuspended$1(root, lanes), - ensureRootIsScheduled(root, now()), - originalCallbackNode); - root.finishedWork = root.current.alternate; - root.finishedLanes = lanes; - switch (didTimeout) { - case 0: - case 1: + (exitStatus = workInProgressRootExitStatus)); + if (exitStatus !== RootIncomplete) { + exitStatus === RootErrored && + ((lastExpiredTime = 2 < lastExpiredTime ? 2 : lastExpiredTime), + (exitStatus = renderRootSync(root, lastExpiredTime))); + if (exitStatus === RootFatalErrored) + throw ((didTimeout = workInProgressRootFatalError), + prepareFreshStack(root, lastExpiredTime), + markRootSuspendedAtTime(root, lastExpiredTime), + ensureRootIsScheduled(root), + didTimeout); + expirationTime = root.finishedWork = root.current.alternate; + root.finishedExpirationTime = lastExpiredTime; + switch (exitStatus) { + case RootIncomplete: + case RootFatalErrored: throw Error("Root did not complete. This is a bug in React."); - case 2: + case RootErrored: commitRoot(root); break; - case 3: - markRootSuspended$1(root, lanes); + case RootSuspended: + markRootSuspendedAtTime(root, lastExpiredTime); + exitStatus = root.lastSuspendedTime; + lastExpiredTime === exitStatus && + (root.nextKnownPendingLevel = getRemainingExpirationTime( + expirationTime + )); if ( - (lanes & 62914560) === lanes && - ((didTimeout = globalMostRecentFallbackTime + 500 - now()), - 10 < didTimeout) + 1073741823 === workInProgressRootLatestProcessedExpirationTime && + ((expirationTime = + globalMostRecentFallbackTime + FALLBACK_THROTTLE_MS - now()), + 10 < expirationTime) ) { - if (0 !== getNextLanes(root, 0)) break; - prevExecutionContext = root.suspendedLanes; - if ((prevExecutionContext & lanes) !== lanes) { - requestEventTime(); - root.pingedLanes |= root.suspendedLanes & prevExecutionContext; + if ( + workInProgressRootHasPendingPing && + ((prevDispatcher = root.lastPingedTime), + 0 === prevDispatcher || prevDispatcher >= lastExpiredTime) + ) { + root.lastPingedTime = lastExpiredTime; + prepareFreshStack(root, lastExpiredTime); + break; + } + prevDispatcher = getNextRootExpirationTimeToWorkOn(root); + if (0 !== prevDispatcher && prevDispatcher !== lastExpiredTime) break; + if (0 !== exitStatus && exitStatus !== lastExpiredTime) { + root.lastPingedTime = exitStatus; break; } root.timeoutHandle = scheduleTimeout( commitRoot.bind(null, root), - didTimeout + expirationTime ); break; } commitRoot(root); break; - case 4: - markRootSuspended$1(root, lanes); - if (0 !== getNextLanes(root, 0)) break; - didTimeout = root.suspendedLanes; - if ((didTimeout & lanes) !== lanes) { - requestEventTime(); - root.pingedLanes |= root.suspendedLanes & didTimeout; - break; - } - lanes = getMostRecentEventTime(root, lanes); - -1 !== workInProgressRootLatestSuspenseTimeout - ? (lanes = workInProgressRootLatestSuspenseTimeout - now()) - : -1 === lanes - ? (lanes = 0) - : ((lanes = now() - lanes), - (lanes = - (120 > lanes - ? 120 - : 480 > lanes - ? 480 - : 1080 > lanes - ? 1080 - : 1920 > lanes - ? 1920 - : 3e3 > lanes - ? 3e3 - : 4320 > lanes - ? 4320 - : 1960 * ceil(lanes / 1960)) - lanes)); - if (10 < lanes) { - root.timeoutHandle = scheduleTimeout( - commitRoot.bind(null, root), - lanes - ); - break; - } - commitRoot(root); - break; - case 5: - prevDispatcher = getMostRecentEventTime(root, lanes); + case RootSuspendedWithDelay: + markRootSuspendedAtTime(root, lastExpiredTime); + exitStatus = root.lastSuspendedTime; + lastExpiredTime === exitStatus && + (root.nextKnownPendingLevel = getRemainingExpirationTime( + expirationTime + )); if ( - -1 !== prevDispatcher && - null !== workInProgressRootCanSuspendUsingConfig && - ((didTimeout = - workInProgressRootCanSuspendUsingConfig.busyMinDurationMs | 0), - 0 >= didTimeout - ? (didTimeout = 0) - : ((prevExecutionContext = - workInProgressRootCanSuspendUsingConfig.busyDelayMs | 0), - (prevDispatcher = now() - prevDispatcher), - (didTimeout = - prevDispatcher <= prevExecutionContext - ? 0 - : prevExecutionContext + didTimeout - prevDispatcher)), - 10 < didTimeout) + workInProgressRootHasPendingPing && + ((expirationTime = root.lastPingedTime), + 0 === expirationTime || expirationTime >= lastExpiredTime) ) { - markRootSuspended$1(root, lanes); + root.lastPingedTime = lastExpiredTime; + prepareFreshStack(root, lastExpiredTime); + break; + } + expirationTime = getNextRootExpirationTimeToWorkOn(root); + if (0 !== expirationTime && expirationTime !== lastExpiredTime) break; + if (0 !== exitStatus && exitStatus !== lastExpiredTime) { + root.lastPingedTime = exitStatus; + break; + } + 1073741823 !== workInProgressRootLatestSuspenseTimeout + ? (expirationTime = + 10 * (1073741821 - workInProgressRootLatestSuspenseTimeout) - + now()) + : 1073741823 === workInProgressRootLatestProcessedExpirationTime + ? (expirationTime = 0) + : ((expirationTime = + 10 * + (1073741821 - workInProgressRootLatestProcessedExpirationTime) - + 5e3), + (exitStatus = now()), + (lastExpiredTime = + 10 * (1073741821 - lastExpiredTime) - exitStatus), + (expirationTime = exitStatus - expirationTime), + 0 > expirationTime && (expirationTime = 0), + (expirationTime = + (120 > expirationTime + ? 120 + : 480 > expirationTime + ? 480 + : 1080 > expirationTime + ? 1080 + : 1920 > expirationTime + ? 1920 + : 3e3 > expirationTime + ? 3e3 + : 4320 > expirationTime + ? 4320 + : 1960 * ceil(expirationTime / 1960)) - expirationTime), + lastExpiredTime < expirationTime && + (expirationTime = lastExpiredTime)); + if (10 < expirationTime) { root.timeoutHandle = scheduleTimeout( commitRoot.bind(null, root), - didTimeout + expirationTime ); break; } commitRoot(root); break; + case RootCompleted: + if ( + 1073741823 !== workInProgressRootLatestProcessedExpirationTime && + null !== workInProgressRootCanSuspendUsingConfig + ) { + prevDispatcher = workInProgressRootLatestProcessedExpirationTime; + var suspenseConfig = workInProgressRootCanSuspendUsingConfig; + expirationTime = suspenseConfig.busyMinDurationMs | 0; + 0 >= expirationTime + ? (expirationTime = 0) + : ((exitStatus = suspenseConfig.busyDelayMs | 0), + (prevDispatcher = + now() - + (10 * (1073741821 - prevDispatcher) - + (suspenseConfig.timeoutMs | 0 || 5e3))), + (expirationTime = + prevDispatcher <= exitStatus + ? 0 + : exitStatus + expirationTime - prevDispatcher)); + if (10 < expirationTime) { + markRootSuspendedAtTime(root, lastExpiredTime); + root.timeoutHandle = scheduleTimeout( + commitRoot.bind(null, root), + expirationTime + ); + break; + } + } + commitRoot(root); + break; default: throw Error("Unknown root exit status."); } } - ensureRootIsScheduled(root, now()); - return root.callbackNode === originalCallbackNode + ensureRootIsScheduled(root); + return root.callbackNode === didTimeout ? performConcurrentWorkOnRoot.bind(null, root) : null; } -function markRootSuspended$1(root, suspendedLanes) { - suspendedLanes &= ~workInProgressRootPingedLanes; - suspendedLanes &= ~workInProgressRootUpdatedLanes; - root.suspendedLanes |= suspendedLanes; - root.pingedLanes &= ~suspendedLanes; - for (root = root.expirationTimes; 0 < suspendedLanes; ) { - var index$12 = 31 - clz32(suspendedLanes), - lane = 1 << index$12; - root[index$12] = -1; - suspendedLanes &= ~lane; - } -} function performSyncWorkOnRoot(root) { - if (0 !== (executionContext & 48)) + if ((executionContext & (RenderContext | CommitContext)) !== NoContext) throw Error("Should not already be working."); flushPassiveEffects(); - if ( - root === workInProgressRoot && - 0 !== (root.expiredLanes & workInProgressRootRenderLanes) - ) { - var lanes = workInProgressRootRenderLanes; - var exitStatus = renderRootSync(root, lanes); - 0 !== (workInProgressRootIncludedLanes & workInProgressRootUpdatedLanes) && - ((lanes = getNextLanes(root, lanes)), - (exitStatus = renderRootSync(root, lanes))); - } else - (lanes = getNextLanes(root, 0)), (exitStatus = renderRootSync(root, lanes)); + var lastExpiredTime = root.lastExpiredTime; + lastExpiredTime = + 0 !== lastExpiredTime + ? root === workInProgressRoot && renderExpirationTime$1 >= lastExpiredTime + ? renderExpirationTime$1 + : lastExpiredTime + : 1073741823; + var exitStatus = renderRootSync(root, lastExpiredTime); 0 !== root.tag && - 2 === exitStatus && - ((executionContext |= 64), - root.hydrate && (root.hydrate = !1), - (lanes = getLanesToRetrySynchronouslyOnError(root)), - 0 !== lanes && (exitStatus = renderRootSync(root, lanes))); - if (1 === exitStatus) + exitStatus === RootErrored && + ((lastExpiredTime = 2 < lastExpiredTime ? 2 : lastExpiredTime), + (exitStatus = renderRootSync(root, lastExpiredTime))); + if (exitStatus === RootFatalErrored) throw ((exitStatus = workInProgressRootFatalError), - prepareFreshStack(root, 0), - markRootSuspended$1(root, lanes), - ensureRootIsScheduled(root, now()), + prepareFreshStack(root, lastExpiredTime), + markRootSuspendedAtTime(root, lastExpiredTime), + ensureRootIsScheduled(root), exitStatus); root.finishedWork = root.current.alternate; - root.finishedLanes = lanes; + root.finishedExpirationTime = lastExpiredTime; commitRoot(root); - ensureRootIsScheduled(root, now()); + ensureRootIsScheduled(root); return null; } -function pushRenderLanes(fiber, lanes) { - push(subtreeRenderLanesCursor, subtreeRenderLanes); - subtreeRenderLanes |= lanes; - workInProgressRootIncludedLanes |= lanes; -} -function popRenderLanes() { - subtreeRenderLanes = subtreeRenderLanesCursor.current; - pop(subtreeRenderLanesCursor); -} -function prepareFreshStack(root, lanes) { +function prepareFreshStack(root, expirationTime) { root.finishedWork = null; - root.finishedLanes = 0; + root.finishedExpirationTime = 0; var timeoutHandle = root.timeoutHandle; -1 !== timeoutHandle && ((root.timeoutHandle = -1), cancelTimeout(timeoutHandle)); @@ -6374,7 +6010,6 @@ function prepareFreshStack(root, lanes) { popHostContainer(); pop(didPerformWorkStackCursor); pop(contextStackCursor); - resetWorkInProgressVersions(); break; case 5: popHostContext(interruptedWork); @@ -6390,29 +6025,25 @@ function prepareFreshStack(root, lanes) { break; case 10: popProvider(interruptedWork); - break; - case 23: - case 24: - popRenderLanes(); } timeoutHandle = timeoutHandle.return; } workInProgressRoot = root; workInProgress = createWorkInProgress(root.current, null); - workInProgressRootRenderLanes = subtreeRenderLanes = workInProgressRootIncludedLanes = lanes; - workInProgressRootExitStatus = 0; + renderExpirationTime$1 = expirationTime; + workInProgressRootExitStatus = RootIncomplete; workInProgressRootFatalError = null; - workInProgressRootLatestSuspenseTimeout = -1; + workInProgressRootLatestSuspenseTimeout = workInProgressRootLatestProcessedExpirationTime = 1073741823; workInProgressRootCanSuspendUsingConfig = null; - workInProgressRootPingedLanes = workInProgressRootUpdatedLanes = workInProgressRootSkippedLanes = 0; + workInProgressRootNextUnprocessedUpdateTime = 0; + workInProgressRootHasPendingPing = !1; } function handleError(root$jscomp$0, thrownValue) { do { - var erroredWork = workInProgress; try { resetContextDependencies(); - ReactCurrentDispatcher$1.current = ContextOnlyDispatcher; - if (didScheduleRenderPhaseUpdate) { + ReactCurrentDispatcher.current = ContextOnlyDispatcher; + if (didScheduleRenderPhaseUpdate) for ( var hook = currentlyRenderingFiber$1.memoizedState; null !== hook; @@ -6422,24 +6053,21 @@ function handleError(root$jscomp$0, thrownValue) { null !== queue && (queue.pending = null); hook = hook.next; } - didScheduleRenderPhaseUpdate = !1; - } - renderLanes = 0; + renderExpirationTime = 0; workInProgressHook = currentHook = currentlyRenderingFiber$1 = null; - didScheduleRenderPhaseUpdateDuringThisPass = !1; - ReactCurrentOwner$2.current = null; - if (null === erroredWork || null === erroredWork.return) { - workInProgressRootExitStatus = 1; - workInProgressRootFatalError = thrownValue; - workInProgress = null; - break; - } + didScheduleRenderPhaseUpdate = !1; + if (null === workInProgress || null === workInProgress.return) + return ( + (workInProgressRootExitStatus = RootFatalErrored), + (workInProgressRootFatalError = thrownValue), + (workInProgress = null) + ); a: { var root = root$jscomp$0, - returnFiber = erroredWork.return, - sourceFiber = erroredWork, + returnFiber = workInProgress.return, + sourceFiber = workInProgress, value = thrownValue; - thrownValue = workInProgressRootRenderLanes; + thrownValue = renderExpirationTime$1; sourceFiber.effectTag |= 2048; sourceFiber.firstEffect = sourceFiber.lastEffect = null; if ( @@ -6447,27 +6075,27 @@ function handleError(root$jscomp$0, thrownValue) { "object" === typeof value && "function" === typeof value.then ) { - var wakeable = value; + var thenable = value; if (0 === (sourceFiber.mode & 2)) { var currentSource = sourceFiber.alternate; currentSource ? ((sourceFiber.updateQueue = currentSource.updateQueue), (sourceFiber.memoizedState = currentSource.memoizedState), - (sourceFiber.lanes = currentSource.lanes)) + (sourceFiber.expirationTime = currentSource.expirationTime)) : ((sourceFiber.updateQueue = null), (sourceFiber.memoizedState = null)); } var hasInvisibleParentBoundary = 0 !== (suspenseStackCursor.current & 1), - workInProgress$76 = returnFiber; + _workInProgress = returnFiber; do { var JSCompiler_temp; - if ((JSCompiler_temp = 13 === workInProgress$76.tag)) { - var nextState = workInProgress$76.memoizedState; + if ((JSCompiler_temp = 13 === _workInProgress.tag)) { + var nextState = _workInProgress.memoizedState; if (null !== nextState) JSCompiler_temp = null !== nextState.dehydrated ? !0 : !1; else { - var props = workInProgress$76.memoizedProps; + var props = _workInProgress.memoizedProps; JSCompiler_temp = void 0 === props.fallback ? !1 @@ -6479,24 +6107,23 @@ function handleError(root$jscomp$0, thrownValue) { } } if (JSCompiler_temp) { - var wakeables = workInProgress$76.updateQueue; - if (null === wakeables) { + var thenables = _workInProgress.updateQueue; + if (null === thenables) { var updateQueue = new Set(); - updateQueue.add(wakeable); - workInProgress$76.updateQueue = updateQueue; - } else wakeables.add(wakeable); - if (0 === (workInProgress$76.mode & 2)) { - workInProgress$76.effectTag |= 64; - sourceFiber.effectTag |= 16384; + updateQueue.add(thenable); + _workInProgress.updateQueue = updateQueue; + } else thenables.add(thenable); + if (0 === (_workInProgress.mode & 2)) { + _workInProgress.effectTag |= 64; sourceFiber.effectTag &= -2981; if (1 === sourceFiber.tag) if (null === sourceFiber.alternate) sourceFiber.tag = 17; else { - var update = createUpdate(-1, 1, null); + var update = createUpdate(1073741823, null); update.tag = 2; enqueueUpdate(sourceFiber, update); } - sourceFiber.lanes |= 1; + sourceFiber.expirationTime = 1073741823; break a; } value = void 0; @@ -6505,105 +6132,108 @@ function handleError(root$jscomp$0, thrownValue) { null === pingCache ? ((pingCache = root.pingCache = new PossiblyWeakMap()), (value = new Set()), - pingCache.set(wakeable, value)) - : ((value = pingCache.get(wakeable)), + pingCache.set(thenable, value)) + : ((value = pingCache.get(thenable)), void 0 === value && - ((value = new Set()), pingCache.set(wakeable, value))); + ((value = new Set()), pingCache.set(thenable, value))); if (!value.has(sourceFiber)) { value.add(sourceFiber); var ping = pingSuspendedRoot.bind( null, root, - wakeable, + thenable, sourceFiber ); - wakeable.then(ping, ping); + thenable.then(ping, ping); } - workInProgress$76.effectTag |= 4096; - workInProgress$76.lanes = thrownValue; + _workInProgress.effectTag |= 4096; + _workInProgress.expirationTime = thrownValue; break a; } - workInProgress$76 = workInProgress$76.return; - } while (null !== workInProgress$76); + _workInProgress = _workInProgress.return; + } while (null !== _workInProgress); value = Error( (getComponentName(sourceFiber.type) || "A React component") + - " suspended while rendering, but no fallback UI was specified.\n\nAdd a component higher in the tree to provide a loading indicator or placeholder to display." + " 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) ); } - 5 !== workInProgressRootExitStatus && - (workInProgressRootExitStatus = 2); + workInProgressRootExitStatus !== RootCompleted && + (workInProgressRootExitStatus = RootErrored); value = createCapturedValue(value, sourceFiber); - workInProgress$76 = returnFiber; + _workInProgress = returnFiber; do { - switch (workInProgress$76.tag) { + switch (_workInProgress.tag) { case 3: - root = value; - workInProgress$76.effectTag |= 4096; - thrownValue &= -thrownValue; - workInProgress$76.lanes |= thrownValue; - var update$77 = createRootErrorUpdate( - workInProgress$76, - root, + thenable = value; + _workInProgress.effectTag |= 4096; + _workInProgress.expirationTime = thrownValue; + var _update = createRootErrorUpdate( + _workInProgress, + thenable, thrownValue ); - enqueueCapturedUpdate(workInProgress$76, update$77); + enqueueCapturedUpdate(_workInProgress, _update); break a; case 1: - root = value; - var ctor = workInProgress$76.type, - instance = workInProgress$76.stateNode; + thenable = value; + var ctor = _workInProgress.type, + instance = _workInProgress.stateNode; if ( - 0 === (workInProgress$76.effectTag & 64) && + 0 === (_workInProgress.effectTag & 64) && ("function" === typeof ctor.getDerivedStateFromError || (null !== instance && "function" === typeof instance.componentDidCatch && (null === legacyErrorBoundariesThatAlreadyFailed || !legacyErrorBoundariesThatAlreadyFailed.has(instance)))) ) { - workInProgress$76.effectTag |= 4096; - thrownValue &= -thrownValue; - workInProgress$76.lanes |= thrownValue; - var update$80 = createClassErrorUpdate( - workInProgress$76, - root, + _workInProgress.effectTag |= 4096; + _workInProgress.expirationTime = thrownValue; + var _update2 = createClassErrorUpdate( + _workInProgress, + thenable, thrownValue ); - enqueueCapturedUpdate(workInProgress$76, update$80); + enqueueCapturedUpdate(_workInProgress, _update2); break a; } } - workInProgress$76 = workInProgress$76.return; - } while (null !== workInProgress$76); + _workInProgress = _workInProgress.return; + } while (null !== _workInProgress); } - completeUnitOfWork(erroredWork); + workInProgress = completeUnitOfWork(workInProgress); } catch (yetAnotherThrownValue) { thrownValue = yetAnotherThrownValue; - workInProgress === erroredWork && - null !== erroredWork && - (workInProgress = erroredWork = erroredWork.return); continue; } break; } while (1); } function pushDispatcher() { - var prevDispatcher = ReactCurrentDispatcher$2.current; - ReactCurrentDispatcher$2.current = ContextOnlyDispatcher; + var prevDispatcher = ReactCurrentDispatcher$1.current; + ReactCurrentDispatcher$1.current = ContextOnlyDispatcher; return null === prevDispatcher ? ContextOnlyDispatcher : prevDispatcher; } -function markRenderEventTimeAndConfig(eventTime, suspenseConfig) { +function markRenderEventTimeAndConfig(expirationTime, suspenseConfig) { + expirationTime < workInProgressRootLatestProcessedExpirationTime && + 2 < expirationTime && + (workInProgressRootLatestProcessedExpirationTime = expirationTime); null !== suspenseConfig && - ((eventTime += suspenseConfig.timeoutMs | 0 || 5e3), - eventTime > workInProgressRootLatestSuspenseTimeout && - ((workInProgressRootLatestSuspenseTimeout = eventTime), - (workInProgressRootCanSuspendUsingConfig = suspenseConfig))); + expirationTime < workInProgressRootLatestSuspenseTimeout && + 2 < expirationTime && + ((workInProgressRootLatestSuspenseTimeout = expirationTime), + (workInProgressRootCanSuspendUsingConfig = suspenseConfig)); } -function renderRootSync(root, lanes) { +function markUnprocessedUpdateTime(expirationTime) { + expirationTime > workInProgressRootNextUnprocessedUpdateTime && + (workInProgressRootNextUnprocessedUpdateTime = expirationTime); +} +function renderRootSync(root, expirationTime) { var prevExecutionContext = executionContext; - executionContext |= 16; + executionContext |= RenderContext; var prevDispatcher = pushDispatcher(); - (workInProgressRoot === root && workInProgressRootRenderLanes === lanes) || - prepareFreshStack(root, lanes); + (root === workInProgressRoot && expirationTime === renderExpirationTime$1) || + prepareFreshStack(root, expirationTime); do try { workLoopSync(); @@ -6614,144 +6244,142 @@ function renderRootSync(root, lanes) { while (1); resetContextDependencies(); executionContext = prevExecutionContext; - ReactCurrentDispatcher$2.current = prevDispatcher; + ReactCurrentDispatcher$1.current = prevDispatcher; if (null !== workInProgress) throw Error( "Cannot commit an incomplete root. This error is likely caused by a bug in React. Please file an issue." ); workInProgressRoot = null; - workInProgressRootRenderLanes = 0; return workInProgressRootExitStatus; } function workLoopSync() { - for (; null !== workInProgress; ) performUnitOfWork(workInProgress); + for (; null !== workInProgress; ) + workInProgress = performUnitOfWork(workInProgress); } function workLoopConcurrent() { - for (; null !== workInProgress && !Scheduler_shouldYield(); ) - performUnitOfWork(workInProgress); + for (; null !== workInProgress && !shouldYield(); ) + workInProgress = performUnitOfWork(workInProgress); } function performUnitOfWork(unitOfWork) { - var next = beginWork$1(unitOfWork.alternate, unitOfWork, subtreeRenderLanes); + var next = beginWork$1( + unitOfWork.alternate, + unitOfWork, + renderExpirationTime$1 + ); unitOfWork.memoizedProps = unitOfWork.pendingProps; - null === next ? completeUnitOfWork(unitOfWork) : (workInProgress = next); + null === next && (next = completeUnitOfWork(unitOfWork)); ReactCurrentOwner$2.current = null; + return next; } function completeUnitOfWork(unitOfWork) { - var completedWork = unitOfWork; + workInProgress = unitOfWork; do { - var current = completedWork.alternate; - unitOfWork = completedWork.return; - if (0 === (completedWork.effectTag & 2048)) { - current = completeWork(current, completedWork, subtreeRenderLanes); - if (null !== current) { - workInProgress = current; - return; - } - current = completedWork; + var current = workInProgress.alternate; + unitOfWork = workInProgress.return; + if (0 === (workInProgress.effectTag & 2048)) { + current = completeWork(current, workInProgress, renderExpirationTime$1); if ( - (24 !== current.tag && 23 !== current.tag) || - null === current.memoizedState || - 0 !== (subtreeRenderLanes & 1073741824) || - 0 === (current.mode & 4) + 1 === renderExpirationTime$1 || + 1 !== workInProgress.childExpirationTime ) { - for (var newChildLanes = 0, child = current.child; null !== child; ) - (newChildLanes |= child.lanes | child.childLanes), - (child = child.sibling); - current.childLanes = newChildLanes; + for ( + var newChildExpirationTime = 0, _child = workInProgress.child; + null !== _child; + + ) { + var _childUpdateExpirationTime = _child.expirationTime, + _childChildExpirationTime = _child.childExpirationTime; + _childUpdateExpirationTime > newChildExpirationTime && + (newChildExpirationTime = _childUpdateExpirationTime); + _childChildExpirationTime > newChildExpirationTime && + (newChildExpirationTime = _childChildExpirationTime); + _child = _child.sibling; + } + workInProgress.childExpirationTime = newChildExpirationTime; } + if (null !== current) return current; null !== unitOfWork && 0 === (unitOfWork.effectTag & 2048) && (null === unitOfWork.firstEffect && - (unitOfWork.firstEffect = completedWork.firstEffect), - null !== completedWork.lastEffect && + (unitOfWork.firstEffect = workInProgress.firstEffect), + null !== workInProgress.lastEffect && (null !== unitOfWork.lastEffect && - (unitOfWork.lastEffect.nextEffect = completedWork.firstEffect), - (unitOfWork.lastEffect = completedWork.lastEffect)), - 1 < completedWork.effectTag && + (unitOfWork.lastEffect.nextEffect = workInProgress.firstEffect), + (unitOfWork.lastEffect = workInProgress.lastEffect)), + 1 < workInProgress.effectTag && (null !== unitOfWork.lastEffect - ? (unitOfWork.lastEffect.nextEffect = completedWork) - : (unitOfWork.firstEffect = completedWork), - (unitOfWork.lastEffect = completedWork))); + ? (unitOfWork.lastEffect.nextEffect = workInProgress) + : (unitOfWork.firstEffect = workInProgress), + (unitOfWork.lastEffect = workInProgress))); } else { - current = unwindWork(completedWork); - if (null !== current) { - current.effectTag &= 2047; - workInProgress = current; - return; - } + current = unwindWork(workInProgress); + if (null !== current) return (current.effectTag &= 2047), current; null !== unitOfWork && ((unitOfWork.firstEffect = unitOfWork.lastEffect = null), (unitOfWork.effectTag |= 2048)); } - completedWork = completedWork.sibling; - if (null !== completedWork) { - workInProgress = completedWork; - return; - } - workInProgress = completedWork = unitOfWork; - } while (null !== completedWork); - 0 === workInProgressRootExitStatus && (workInProgressRootExitStatus = 5); + current = workInProgress.sibling; + if (null !== current) return current; + workInProgress = unitOfWork; + } while (null !== workInProgress); + workInProgressRootExitStatus === RootIncomplete && + (workInProgressRootExitStatus = RootCompleted); + return null; +} +function getRemainingExpirationTime(fiber) { + var updateExpirationTime = fiber.expirationTime; + fiber = fiber.childExpirationTime; + return updateExpirationTime > fiber ? updateExpirationTime : fiber; } function commitRoot(root) { var renderPriorityLevel = getCurrentPriorityLevel(); runWithPriority(99, commitRootImpl.bind(null, root, renderPriorityLevel)); return null; } -function commitRootImpl(root, renderPriorityLevel) { +function commitRootImpl(root$jscomp$0, renderPriorityLevel$jscomp$0) { do flushPassiveEffects(); while (null !== rootWithPendingPassiveEffects); - if (0 !== (executionContext & 48)) + if ((executionContext & (RenderContext | CommitContext)) !== NoContext) throw Error("Should not already be working."); - var finishedWork = root.finishedWork; + var finishedWork = root$jscomp$0.finishedWork, + expirationTime = root$jscomp$0.finishedExpirationTime; if (null === finishedWork) return null; - root.finishedWork = null; - root.finishedLanes = 0; - if (finishedWork === root.current) + root$jscomp$0.finishedWork = null; + root$jscomp$0.finishedExpirationTime = 0; + if (finishedWork === root$jscomp$0.current) throw Error( "Cannot commit the same tree as before. This error is likely caused by a bug in React. Please file an issue." ); - root.callbackNode = null; - var remainingLanes = finishedWork.lanes | finishedWork.childLanes, - remainingLanes$jscomp$0 = remainingLanes, - noLongerPendingLanes = root.pendingLanes & ~remainingLanes$jscomp$0; - root.pendingLanes = remainingLanes$jscomp$0; - root.suspendedLanes = 0; - root.pingedLanes = 0; - root.expiredLanes &= remainingLanes$jscomp$0; - root.mutableReadLanes &= remainingLanes$jscomp$0; - root.entangledLanes &= remainingLanes$jscomp$0; - remainingLanes$jscomp$0 = root.entanglements; - for ( - var eventTimes = root.eventTimes, expirationTimes = root.expirationTimes; - 0 < noLongerPendingLanes; - - ) { - var index$13 = 31 - clz32(noLongerPendingLanes), - lane = 1 << index$13; - remainingLanes$jscomp$0[index$13] = 0; - eventTimes[index$13] = -1; - expirationTimes[index$13] = -1; - noLongerPendingLanes &= ~lane; - } - null !== rootsWithPendingDiscreteUpdates && - 0 === (remainingLanes & 24) && - rootsWithPendingDiscreteUpdates.has(root) && - rootsWithPendingDiscreteUpdates.delete(root); - root === workInProgressRoot && + root$jscomp$0.callbackNode = null; + root$jscomp$0.callbackExpirationTime = 0; + root$jscomp$0.callbackPriority = 90; + root$jscomp$0.nextKnownPendingLevel = 0; + var remainingExpirationTimeBeforeCommit = getRemainingExpirationTime( + finishedWork + ); + root$jscomp$0.firstPendingTime = remainingExpirationTimeBeforeCommit; + expirationTime <= root$jscomp$0.lastSuspendedTime + ? (root$jscomp$0.firstSuspendedTime = root$jscomp$0.lastSuspendedTime = root$jscomp$0.nextKnownPendingLevel = 0) + : expirationTime <= root$jscomp$0.firstSuspendedTime && + (root$jscomp$0.firstSuspendedTime = expirationTime - 1); + expirationTime <= root$jscomp$0.lastPingedTime && + (root$jscomp$0.lastPingedTime = 0); + expirationTime <= root$jscomp$0.lastExpiredTime && + (root$jscomp$0.lastExpiredTime = 0); + root$jscomp$0 === workInProgressRoot && ((workInProgress = workInProgressRoot = null), - (workInProgressRootRenderLanes = 0)); + (renderExpirationTime$1 = 0)); 1 < finishedWork.effectTag ? null !== finishedWork.lastEffect ? ((finishedWork.lastEffect.nextEffect = finishedWork), - (remainingLanes = finishedWork.firstEffect)) - : (remainingLanes = finishedWork) - : (remainingLanes = finishedWork.firstEffect); - if (null !== remainingLanes) { - remainingLanes$jscomp$0 = executionContext; - executionContext |= 32; - focusedInstanceHandle = ReactCurrentOwner$2.current = null; - shouldFireAfterActiveInstanceBlur = !1; - nextEffect = remainingLanes; + (remainingExpirationTimeBeforeCommit = finishedWork.firstEffect)) + : (remainingExpirationTimeBeforeCommit = finishedWork) + : (remainingExpirationTimeBeforeCommit = finishedWork.firstEffect); + if (null !== remainingExpirationTimeBeforeCommit) { + var prevExecutionContext = executionContext; + executionContext |= CommitContext; + ReactCurrentOwner$2.current = null; + nextEffect = remainingExpirationTimeBeforeCommit; do try { commitBeforeMutationEffects(); @@ -6761,11 +6389,15 @@ function commitRootImpl(root, renderPriorityLevel) { nextEffect = nextEffect.nextEffect; } while (null !== nextEffect); - focusedInstanceHandle = null; - nextEffect = remainingLanes; + nextEffect = remainingExpirationTimeBeforeCommit; do try { - for (eventTimes = root; null !== nextEffect; ) { + for ( + var root = root$jscomp$0, + renderPriorityLevel = renderPriorityLevel$jscomp$0; + null !== nextEffect; + + ) { var effectTag = nextEffect.effectTag; if (effectTag & 128) { var current = nextEffect.alternate; @@ -6798,25 +6430,27 @@ function commitRootImpl(root, renderPriorityLevel) { commitWork(nextEffect.alternate, nextEffect); break; case 8: - expirationTimes = nextEffect; - unmountHostComponents(eventTimes, expirationTimes); - var alternate = expirationTimes.alternate; - detachFiberMutation(expirationTimes); - null !== alternate && detachFiberMutation(alternate); + var current$jscomp$0 = nextEffect; + unmountHostComponents( + root, + current$jscomp$0, + renderPriorityLevel + ); + detachFiber(current$jscomp$0); } nextEffect = nextEffect.nextEffect; } - } catch (error$93) { + } catch (error) { if (null === nextEffect) throw Error("Should be working on an effect."); - captureCommitPhaseError(nextEffect, error$93); + captureCommitPhaseError(nextEffect, error); nextEffect = nextEffect.nextEffect; } while (null !== nextEffect); - root.current = finishedWork; - nextEffect = remainingLanes; + root$jscomp$0.current = finishedWork; + nextEffect = remainingExpirationTimeBeforeCommit; do try { - for (effectTag = root; null !== nextEffect; ) { + for (effectTag = root$jscomp$0; null !== nextEffect; ) { var effectTag$jscomp$0 = nextEffect.effectTag; effectTag$jscomp$0 & 36 && commitLifeCycles(effectTag, nextEffect.alternate, nextEffect); @@ -6839,68 +6473,54 @@ function commitRootImpl(root, renderPriorityLevel) { } nextEffect = nextEffect.nextEffect; } - } catch (error$94) { + } catch (error) { if (null === nextEffect) throw Error("Should be working on an effect."); - captureCommitPhaseError(nextEffect, error$94); + captureCommitPhaseError(nextEffect, error); nextEffect = nextEffect.nextEffect; } while (null !== nextEffect); nextEffect = null; requestPaint(); - executionContext = remainingLanes$jscomp$0; - } else root.current = finishedWork; + executionContext = prevExecutionContext; + } else root$jscomp$0.current = finishedWork; if (rootDoesHavePassiveEffects) (rootDoesHavePassiveEffects = !1), - (rootWithPendingPassiveEffects = root), - (pendingPassiveEffectsRenderPriority = renderPriorityLevel); + (rootWithPendingPassiveEffects = root$jscomp$0), + (pendingPassiveEffectsRenderPriority = renderPriorityLevel$jscomp$0); else - for (nextEffect = remainingLanes; null !== nextEffect; ) - (renderPriorityLevel = nextEffect.nextEffect), + for ( + nextEffect = remainingExpirationTimeBeforeCommit; + null !== nextEffect; + + ) + (renderPriorityLevel$jscomp$0 = nextEffect.nextEffect), (nextEffect.nextEffect = null), - nextEffect.effectTag & 8 && (nextEffect.sibling = null), - (nextEffect = renderPriorityLevel); - remainingLanes = root.pendingLanes; - 0 === remainingLanes && (legacyErrorBoundariesThatAlreadyFailed = null); - 1 === remainingLanes - ? root === rootWithNestedUpdates + (nextEffect = renderPriorityLevel$jscomp$0); + renderPriorityLevel$jscomp$0 = root$jscomp$0.firstPendingTime; + 0 === renderPriorityLevel$jscomp$0 && + (legacyErrorBoundariesThatAlreadyFailed = null); + 1073741823 === renderPriorityLevel$jscomp$0 + ? root$jscomp$0 === rootWithNestedUpdates ? nestedUpdateCount++ - : ((nestedUpdateCount = 0), (rootWithNestedUpdates = root)) + : ((nestedUpdateCount = 0), (rootWithNestedUpdates = root$jscomp$0)) : (nestedUpdateCount = 0); - finishedWork = finishedWork.stateNode; - if (injectedHook && "function" === typeof injectedHook.onCommitFiberRoot) - try { - injectedHook.onCommitFiberRoot( - rendererID, - finishedWork, - void 0, - 64 === (finishedWork.current.effectTag & 64) - ); - } catch (err) {} - ensureRootIsScheduled(root, now()); + "function" === typeof onCommitFiberRoot && + onCommitFiberRoot(finishedWork.stateNode, expirationTime); + ensureRootIsScheduled(root$jscomp$0); if (hasUncaughtError) throw ((hasUncaughtError = !1), - (root = firstUncaughtError), + (root$jscomp$0 = firstUncaughtError), (firstUncaughtError = null), - root); - if (0 !== (executionContext & 8)) return null; + root$jscomp$0); + if ((executionContext & LegacyUnbatchedContext) !== NoContext) return null; flushSyncCallbackQueue(); return null; } function commitBeforeMutationEffects() { for (; null !== nextEffect; ) { - var current = nextEffect.alternate; - shouldFireAfterActiveInstanceBlur || - null === focusedInstanceHandle || - (0 !== (nextEffect.effectTag & 8) - ? doesFiberContain(nextEffect, focusedInstanceHandle) && - (shouldFireAfterActiveInstanceBlur = !0) - : 13 === nextEffect.tag && - isSuspenseBoundaryBeingHidden(current, nextEffect) && - doesFiberContain(nextEffect, focusedInstanceHandle) && - (shouldFireAfterActiveInstanceBlur = !0)); var effectTag = nextEffect.effectTag; 0 !== (effectTag & 256) && - commitBeforeMutationLifeCycles(current, nextEffect); + commitBeforeMutationLifeCycles(nextEffect.alternate, nextEffect); 0 === (effectTag & 512) || rootDoesHavePassiveEffects || ((rootDoesHavePassiveEffects = !0), @@ -6918,83 +6538,47 @@ function flushPassiveEffects() { ? 97 : pendingPassiveEffectsRenderPriority; pendingPassiveEffectsRenderPriority = 90; - schedulerPriorityToLanePriority(priorityLevel); return runWithPriority(priorityLevel, flushPassiveEffectsImpl); } - return !1; -} -function enqueuePendingPassiveHookEffectMount(fiber, effect) { - pendingPassiveHookEffectsMount.push(effect, fiber); - rootDoesHavePassiveEffects || - ((rootDoesHavePassiveEffects = !0), - scheduleCallback(97, function() { - flushPassiveEffects(); - return null; - })); -} -function enqueuePendingPassiveHookEffectUnmount(fiber, effect) { - pendingPassiveHookEffectsUnmount.push(effect, fiber); - rootDoesHavePassiveEffects || - ((rootDoesHavePassiveEffects = !0), - scheduleCallback(97, function() { - flushPassiveEffects(); - return null; - })); } function flushPassiveEffectsImpl() { if (null === rootWithPendingPassiveEffects) return !1; var root = rootWithPendingPassiveEffects; rootWithPendingPassiveEffects = null; - if (0 !== (executionContext & 48)) + if ((executionContext & (RenderContext | CommitContext)) !== NoContext) throw Error("Cannot flush passive effects while already rendering."); var prevExecutionContext = executionContext; - executionContext |= 32; - var unmountEffects = pendingPassiveHookEffectsUnmount; - pendingPassiveHookEffectsUnmount = []; - for (var i = 0; i < unmountEffects.length; i += 2) { - var effect$99 = unmountEffects[i], - fiber = unmountEffects[i + 1], - destroy = effect$99.destroy; - effect$99.destroy = void 0; - if ("function" === typeof destroy) - try { - destroy(); - } catch (error) { - if (null === fiber) throw Error("Should be working on an effect."); - captureCommitPhaseError(fiber, error); - } - } - unmountEffects = pendingPassiveHookEffectsMount; - pendingPassiveHookEffectsMount = []; - for (i = 0; i < unmountEffects.length; i += 2) { - effect$99 = unmountEffects[i]; - fiber = unmountEffects[i + 1]; + executionContext |= CommitContext; + for (root = root.current.firstEffect; null !== root; ) { try { - var create$103 = effect$99.create; - effect$99.destroy = create$103(); - } catch (error$104) { - if (null === fiber) throw Error("Should be working on an effect."); - captureCommitPhaseError(fiber, error$104); + var finishedWork = root; + if (0 !== (finishedWork.effectTag & 512)) + switch (finishedWork.tag) { + case 0: + case 11: + case 15: + case 22: + commitHookEffectListUnmount(5, finishedWork), + commitHookEffectListMount(5, finishedWork); + } + } catch (error) { + if (null === root) throw Error("Should be working on an effect."); + captureCommitPhaseError(root, error); } + finishedWork = root.nextEffect; + root.nextEffect = null; + root = finishedWork; } - for (root = root.current.firstEffect; null !== root; ) - (create$103 = root.nextEffect), - (root.nextEffect = null), - root.effectTag & 8 && (root.sibling = null), - (root = create$103); executionContext = prevExecutionContext; flushSyncCallbackQueue(); return !0; } function captureCommitPhaseErrorOnRoot(rootFiber, sourceFiber, error) { sourceFiber = createCapturedValue(error, sourceFiber); - sourceFiber = createRootErrorUpdate(rootFiber, sourceFiber, 1); + sourceFiber = createRootErrorUpdate(rootFiber, sourceFiber, 1073741823); enqueueUpdate(rootFiber, sourceFiber); - sourceFiber = requestEventTime(); - rootFiber = markUpdateLaneFromFiberToRoot(rootFiber, 1); - null !== rootFiber && - (markRootUpdated(rootFiber, 1, sourceFiber), - ensureRootIsScheduled(rootFiber, sourceFiber)); + rootFiber = markUpdateTimeFromFiberToRoot(rootFiber, 1073741823); + null !== rootFiber && ensureRootIsScheduled(rootFiber); } function captureCommitPhaseError(sourceFiber, error) { if (3 === sourceFiber.tag) @@ -7013,156 +6597,143 @@ function captureCommitPhaseError(sourceFiber, error) { !legacyErrorBoundariesThatAlreadyFailed.has(instance))) ) { sourceFiber = createCapturedValue(error, sourceFiber); - sourceFiber = createClassErrorUpdate(fiber, sourceFiber, 1); + sourceFiber = createClassErrorUpdate(fiber, sourceFiber, 1073741823); enqueueUpdate(fiber, sourceFiber); - sourceFiber = requestEventTime(); - fiber = markUpdateLaneFromFiberToRoot(fiber, 1); - null !== fiber && - (markRootUpdated(fiber, 1, sourceFiber), - ensureRootIsScheduled(fiber, sourceFiber)); + fiber = markUpdateTimeFromFiberToRoot(fiber, 1073741823); + null !== fiber && ensureRootIsScheduled(fiber); break; } } fiber = fiber.return; } } -function pingSuspendedRoot(root, wakeable, pingedLanes) { +function pingSuspendedRoot(root, thenable, suspendedTime) { var pingCache = root.pingCache; - null !== pingCache && pingCache.delete(wakeable); - wakeable = requestEventTime(); - root.pingedLanes |= root.suspendedLanes & pingedLanes; - workInProgressRoot === root && - (workInProgressRootRenderLanes & pingedLanes) === pingedLanes && - (4 === workInProgressRootExitStatus || - (3 === workInProgressRootExitStatus && - (workInProgressRootRenderLanes & 62914560) === - workInProgressRootRenderLanes && - 500 > now() - globalMostRecentFallbackTime) - ? prepareFreshStack(root, 0) - : (workInProgressRootPingedLanes |= pingedLanes)); - ensureRootIsScheduled(root, wakeable); + null !== pingCache && pingCache.delete(thenable); + workInProgressRoot === root && renderExpirationTime$1 === suspendedTime + ? workInProgressRootExitStatus === RootSuspendedWithDelay || + (workInProgressRootExitStatus === RootSuspended && + 1073741823 === workInProgressRootLatestProcessedExpirationTime && + now() - globalMostRecentFallbackTime < FALLBACK_THROTTLE_MS) + ? prepareFreshStack(root, renderExpirationTime$1) + : (workInProgressRootHasPendingPing = !0) + : isRootSuspendedAtTime(root, suspendedTime) && + ((thenable = root.lastPingedTime), + (0 !== thenable && thenable < suspendedTime) || + ((root.lastPingedTime = suspendedTime), ensureRootIsScheduled(root))); } -function resolveRetryWakeable(boundaryFiber, wakeable) { +function resolveRetryThenable(boundaryFiber, thenable) { var retryCache = boundaryFiber.stateNode; - null !== retryCache && retryCache.delete(wakeable); - wakeable = 0; - 0 === wakeable && - ((wakeable = boundaryFiber.mode), - 0 === (wakeable & 2) - ? (wakeable = 1) - : 0 === (wakeable & 4) - ? (wakeable = 99 === getCurrentPriorityLevel() ? 1 : 2) - : (0 === currentEventWipLanes && - (currentEventWipLanes = workInProgressRootIncludedLanes), - (wakeable = getHighestPriorityLane(62914560 & ~currentEventWipLanes)), - 0 === wakeable && (wakeable = 4194304))); - retryCache = requestEventTime(); - boundaryFiber = markUpdateLaneFromFiberToRoot(boundaryFiber, wakeable); - null !== boundaryFiber && - (markRootUpdated(boundaryFiber, wakeable, retryCache), - ensureRootIsScheduled(boundaryFiber, retryCache)); + null !== retryCache && retryCache.delete(thenable); + thenable = 0; + 0 === thenable && + ((thenable = requestCurrentTimeForUpdate()), + (thenable = computeExpirationForFiber(thenable, boundaryFiber, null))); + boundaryFiber = markUpdateTimeFromFiberToRoot(boundaryFiber, thenable); + null !== boundaryFiber && ensureRootIsScheduled(boundaryFiber); } var beginWork$1; -beginWork$1 = function(current, workInProgress, renderLanes) { - var updateLanes = workInProgress.lanes; +beginWork$1 = function(current, workInProgress, renderExpirationTime) { + var updateExpirationTime = workInProgress.expirationTime; if (null !== current) if ( current.memoizedProps !== workInProgress.pendingProps || didPerformWorkStackCursor.current ) didReceiveUpdate = !0; - else if (0 !== (renderLanes & updateLanes)) - didReceiveUpdate = 0 !== (current.effectTag & 16384) ? !0 : !1; else { - didReceiveUpdate = !1; - switch (workInProgress.tag) { - case 3: - pushHostRootContext(workInProgress); - break; - case 5: - pushHostContext(workInProgress); - break; - case 1: - isContextProvider(workInProgress.type) && - pushContextProvider(workInProgress); - break; - case 4: - pushHostContainer( - workInProgress, - workInProgress.stateNode.containerInfo - ); - break; - case 10: - updateLanes = workInProgress.memoizedProps.value; - var context = workInProgress.type._context; - push(valueCursor, context._currentValue); - context._currentValue = updateLanes; - break; - case 13: - if (null !== workInProgress.memoizedState) { - if (0 !== (renderLanes & workInProgress.child.childLanes)) - return updateSuspenseComponent( - current, - workInProgress, - renderLanes - ); - push(suspenseStackCursor, suspenseStackCursor.current & 1); - workInProgress = bailoutOnAlreadyFinishedWork( - current, + if (updateExpirationTime < renderExpirationTime) { + didReceiveUpdate = !1; + switch (workInProgress.tag) { + case 3: + pushHostRootContext(workInProgress); + break; + case 5: + pushHostContext(workInProgress); + break; + case 1: + isContextProvider(workInProgress.type) && + pushContextProvider(workInProgress); + break; + case 4: + pushHostContainer( workInProgress, - renderLanes + workInProgress.stateNode.containerInfo ); - return null !== workInProgress ? workInProgress.sibling : null; - } - push(suspenseStackCursor, suspenseStackCursor.current & 1); - break; - case 19: - updateLanes = 0 !== (renderLanes & workInProgress.childLanes); - if (0 !== (current.effectTag & 64)) { - if (updateLanes) - return updateSuspenseListComponent( + break; + case 10: + updateExpirationTime = workInProgress.memoizedProps.value; + var context = workInProgress.type._context; + push(valueCursor, context._currentValue); + context._currentValue = updateExpirationTime; + break; + case 13: + if (null !== workInProgress.memoizedState) { + updateExpirationTime = workInProgress.child.childExpirationTime; + if ( + 0 !== updateExpirationTime && + updateExpirationTime >= renderExpirationTime + ) + return updateSuspenseComponent( + current, + workInProgress, + renderExpirationTime + ); + push(suspenseStackCursor, suspenseStackCursor.current & 1); + workInProgress = bailoutOnAlreadyFinishedWork( current, workInProgress, - renderLanes + renderExpirationTime ); - workInProgress.effectTag |= 64; - } - context = workInProgress.memoizedState; - null !== context && - ((context.rendering = null), - (context.tail = null), - (context.lastEffect = null)); - push(suspenseStackCursor, suspenseStackCursor.current); - if (updateLanes) break; - else return null; - case 23: - case 24: - return ( - (workInProgress.lanes = 0), - updateOffscreenComponent(current, workInProgress, renderLanes) - ); + return null !== workInProgress ? workInProgress.sibling : null; + } + push(suspenseStackCursor, suspenseStackCursor.current & 1); + break; + case 19: + updateExpirationTime = + workInProgress.childExpirationTime >= renderExpirationTime; + if (0 !== (current.effectTag & 64)) { + if (updateExpirationTime) + return updateSuspenseListComponent( + current, + workInProgress, + renderExpirationTime + ); + workInProgress.effectTag |= 64; + } + context = workInProgress.memoizedState; + null !== context && + ((context.rendering = null), (context.tail = null)); + push(suspenseStackCursor, suspenseStackCursor.current); + if (!updateExpirationTime) return null; + } + return bailoutOnAlreadyFinishedWork( + current, + workInProgress, + renderExpirationTime + ); } - return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes); + didReceiveUpdate = !1; } else didReceiveUpdate = !1; - workInProgress.lanes = 0; + workInProgress.expirationTime = 0; switch (workInProgress.tag) { case 2: - updateLanes = workInProgress.type; + updateExpirationTime = workInProgress.type; null !== current && ((current.alternate = null), (workInProgress.alternate = null), (workInProgress.effectTag |= 2)); current = workInProgress.pendingProps; context = getMaskedContext(workInProgress, contextStackCursor.current); - prepareToReadContext(workInProgress, renderLanes); + prepareToReadContext(workInProgress, renderExpirationTime); context = renderWithHooks( null, workInProgress, - updateLanes, + updateExpirationTime, current, context, - renderLanes + renderExpirationTime ); workInProgress.effectTag |= 1; if ( @@ -7174,7 +6745,7 @@ beginWork$1 = function(current, workInProgress, renderLanes) { workInProgress.tag = 1; workInProgress.memoizedState = null; workInProgress.updateQueue = null; - if (isContextProvider(updateLanes)) { + if (isContextProvider(updateExpirationTime)) { var hasContext = !0; pushContextProvider(workInProgress); } else hasContext = !1; @@ -7183,41 +6754,53 @@ beginWork$1 = function(current, workInProgress, renderLanes) { ? context.state : null; initializeUpdateQueue(workInProgress); - var getDerivedStateFromProps = updateLanes.getDerivedStateFromProps; + var getDerivedStateFromProps = + updateExpirationTime.getDerivedStateFromProps; "function" === typeof getDerivedStateFromProps && applyDerivedStateFromProps( workInProgress, - updateLanes, + updateExpirationTime, getDerivedStateFromProps, current ); context.updater = classComponentUpdater; workInProgress.stateNode = context; - context._reactInternals = workInProgress; - mountClassInstance(workInProgress, updateLanes, current, renderLanes); + context._reactInternalFiber = workInProgress; + mountClassInstance( + workInProgress, + updateExpirationTime, + current, + renderExpirationTime + ); workInProgress = finishClassComponent( null, workInProgress, - updateLanes, + updateExpirationTime, !0, hasContext, - renderLanes + renderExpirationTime ); } else (workInProgress.tag = 0), - reconcileChildren(null, workInProgress, context, renderLanes), + reconcileChildren( + null, + workInProgress, + context, + renderExpirationTime + ), (workInProgress = workInProgress.child); return workInProgress; case 16: - context = workInProgress.elementType; a: { + context = workInProgress.elementType; null !== current && ((current.alternate = null), (workInProgress.alternate = null), (workInProgress.effectTag |= 2)); current = workInProgress.pendingProps; - hasContext = context._init; - context = hasContext(context._payload); + initializeLazyComponentType(context); + if (1 !== context._status) throw context._result; + context = context._result; workInProgress.type = context; hasContext = workInProgress.tag = resolveLazyComponentTag(context); current = resolveDefaultProps(context, current); @@ -7228,7 +6811,7 @@ beginWork$1 = function(current, workInProgress, renderLanes) { workInProgress, context, current, - renderLanes + renderExpirationTime ); break a; case 1: @@ -7237,7 +6820,7 @@ beginWork$1 = function(current, workInProgress, renderLanes) { workInProgress, context, current, - renderLanes + renderExpirationTime ); break a; case 11: @@ -7246,7 +6829,7 @@ beginWork$1 = function(current, workInProgress, renderLanes) { workInProgress, context, current, - renderLanes + renderExpirationTime ); break a; case 14: @@ -7255,8 +6838,8 @@ beginWork$1 = function(current, workInProgress, renderLanes) { workInProgress, context, resolveDefaultProps(context.type, current), - updateLanes, - renderLanes + updateExpirationTime, + renderExpirationTime ); break a; } @@ -7269,106 +6852,126 @@ beginWork$1 = function(current, workInProgress, renderLanes) { return workInProgress; case 0: return ( - (updateLanes = workInProgress.type), + (updateExpirationTime = workInProgress.type), (context = workInProgress.pendingProps), (context = - workInProgress.elementType === updateLanes + workInProgress.elementType === updateExpirationTime ? context - : resolveDefaultProps(updateLanes, context)), + : resolveDefaultProps(updateExpirationTime, context)), updateFunctionComponent( current, workInProgress, - updateLanes, + updateExpirationTime, context, - renderLanes + renderExpirationTime ) ); case 1: return ( - (updateLanes = workInProgress.type), + (updateExpirationTime = workInProgress.type), (context = workInProgress.pendingProps), (context = - workInProgress.elementType === updateLanes + workInProgress.elementType === updateExpirationTime ? context - : resolveDefaultProps(updateLanes, context)), + : resolveDefaultProps(updateExpirationTime, context)), updateClassComponent( current, workInProgress, - updateLanes, + updateExpirationTime, context, - renderLanes + renderExpirationTime ) ); case 3: pushHostRootContext(workInProgress); - updateLanes = workInProgress.updateQueue; - if (null === current || null === updateLanes) + updateExpirationTime = workInProgress.updateQueue; + if (null === current || null === updateExpirationTime) throw Error( "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." ); - updateLanes = workInProgress.pendingProps; + updateExpirationTime = workInProgress.pendingProps; context = workInProgress.memoizedState; context = null !== context ? context.element : null; cloneUpdateQueue(current, workInProgress); - processUpdateQueue(workInProgress, updateLanes, null, renderLanes); - updateLanes = workInProgress.memoizedState.element; - updateLanes === context + processUpdateQueue( + workInProgress, + updateExpirationTime, + null, + renderExpirationTime + ); + updateExpirationTime = workInProgress.memoizedState.element; + updateExpirationTime === context ? (workInProgress = bailoutOnAlreadyFinishedWork( current, workInProgress, - renderLanes + renderExpirationTime )) - : (reconcileChildren(current, workInProgress, updateLanes, renderLanes), + : (reconcileChildren( + current, + workInProgress, + updateExpirationTime, + renderExpirationTime + ), (workInProgress = workInProgress.child)); return workInProgress; case 5: return ( pushHostContext(workInProgress), - (updateLanes = workInProgress.pendingProps.children), + (updateExpirationTime = workInProgress.pendingProps.children), markRef(current, workInProgress), - reconcileChildren(current, workInProgress, updateLanes, renderLanes), - workInProgress.child + reconcileChildren( + current, + workInProgress, + updateExpirationTime, + renderExpirationTime + ), + (workInProgress = workInProgress.child), + workInProgress ); case 6: return null; case 13: - return updateSuspenseComponent(current, workInProgress, renderLanes); + return updateSuspenseComponent( + current, + workInProgress, + renderExpirationTime + ); case 4: return ( pushHostContainer( workInProgress, workInProgress.stateNode.containerInfo ), - (updateLanes = workInProgress.pendingProps), + (updateExpirationTime = workInProgress.pendingProps), null === current ? (workInProgress.child = reconcileChildFibers( workInProgress, null, - updateLanes, - renderLanes + updateExpirationTime, + renderExpirationTime )) : reconcileChildren( current, workInProgress, - updateLanes, - renderLanes + updateExpirationTime, + renderExpirationTime ), workInProgress.child ); case 11: return ( - (updateLanes = workInProgress.type), + (updateExpirationTime = workInProgress.type), (context = workInProgress.pendingProps), (context = - workInProgress.elementType === updateLanes + workInProgress.elementType === updateExpirationTime ? context - : resolveDefaultProps(updateLanes, context)), + : resolveDefaultProps(updateExpirationTime, context)), updateForwardRef( current, workInProgress, - updateLanes, + updateExpirationTime, context, - renderLanes + renderExpirationTime ) ); case 7: @@ -7377,7 +6980,7 @@ beginWork$1 = function(current, workInProgress, renderLanes) { current, workInProgress, workInProgress.pendingProps, - renderLanes + renderExpirationTime ), workInProgress.child ); @@ -7387,7 +6990,7 @@ beginWork$1 = function(current, workInProgress, renderLanes) { current, workInProgress, workInProgress.pendingProps.children, - renderLanes + renderExpirationTime ), workInProgress.child ); @@ -7397,13 +7000,13 @@ beginWork$1 = function(current, workInProgress, renderLanes) { current, workInProgress, workInProgress.pendingProps.children, - renderLanes + renderExpirationTime ), workInProgress.child ); case 10: a: { - updateLanes = workInProgress.type._context; + updateExpirationTime = workInProgress.type._context; context = workInProgress.pendingProps; getDerivedStateFromProps = workInProgress.memoizedProps; hasContext = context.value; @@ -7415,8 +7018,9 @@ beginWork$1 = function(current, workInProgress, renderLanes) { ((context$jscomp$0 = getDerivedStateFromProps.value), (hasContext = objectIs(context$jscomp$0, hasContext) ? 0 - : ("function" === typeof updateLanes._calculateChangedBits - ? updateLanes._calculateChangedBits( + : ("function" === + typeof updateExpirationTime._calculateChangedBits + ? updateExpirationTime._calculateChangedBits( context$jscomp$0, hasContext ) @@ -7430,7 +7034,7 @@ beginWork$1 = function(current, workInProgress, renderLanes) { workInProgress = bailoutOnAlreadyFinishedWork( current, workInProgress, - renderLanes + renderExpirationTime ); break a; } @@ -7451,25 +7055,25 @@ beginWork$1 = function(current, workInProgress, renderLanes) { ) { if ( - dependency.context === updateLanes && + dependency.context === updateExpirationTime && 0 !== (dependency.observedBits & hasContext) ) { 1 === context$jscomp$0.tag && - ((dependency = createUpdate( - -1, - renderLanes & -renderLanes, - null - )), + ((dependency = createUpdate(renderExpirationTime, null)), (dependency.tag = 2), enqueueUpdate(context$jscomp$0, dependency)); - context$jscomp$0.lanes |= renderLanes; + context$jscomp$0.expirationTime < renderExpirationTime && + (context$jscomp$0.expirationTime = renderExpirationTime); dependency = context$jscomp$0.alternate; - null !== dependency && (dependency.lanes |= renderLanes); + null !== dependency && + dependency.expirationTime < renderExpirationTime && + (dependency.expirationTime = renderExpirationTime); scheduleWorkOnParentPath( context$jscomp$0.return, - renderLanes + renderExpirationTime ); - list.lanes |= renderLanes; + list.expirationTime < renderExpirationTime && + (list.expirationTime = renderExpirationTime); break; } dependency = dependency.next; @@ -7507,7 +7111,7 @@ beginWork$1 = function(current, workInProgress, renderLanes) { current, workInProgress, context.children, - renderLanes + renderExpirationTime ); workInProgress = workInProgress.child; } @@ -7516,12 +7120,17 @@ beginWork$1 = function(current, workInProgress, renderLanes) { return ( (context = workInProgress.type), (hasContext = workInProgress.pendingProps), - (updateLanes = hasContext.children), - prepareToReadContext(workInProgress, renderLanes), + (updateExpirationTime = hasContext.children), + prepareToReadContext(workInProgress, renderExpirationTime), (context = readContext(context, hasContext.unstable_observedBits)), - (updateLanes = updateLanes(context)), + (updateExpirationTime = updateExpirationTime(context)), (workInProgress.effectTag |= 1), - reconcileChildren(current, workInProgress, updateLanes, renderLanes), + reconcileChildren( + current, + workInProgress, + updateExpirationTime, + renderExpirationTime + ), workInProgress.child ); case 14: @@ -7537,8 +7146,8 @@ beginWork$1 = function(current, workInProgress, renderLanes) { workInProgress, context, hasContext, - updateLanes, - renderLanes + updateExpirationTime, + renderExpirationTime ) ); case 15: @@ -7547,43 +7156,48 @@ beginWork$1 = function(current, workInProgress, renderLanes) { workInProgress, workInProgress.type, workInProgress.pendingProps, - updateLanes, - renderLanes + updateExpirationTime, + renderExpirationTime ); case 17: return ( - (updateLanes = workInProgress.type), + (updateExpirationTime = workInProgress.type), (context = workInProgress.pendingProps), (context = - workInProgress.elementType === updateLanes + workInProgress.elementType === updateExpirationTime ? context - : resolveDefaultProps(updateLanes, context)), + : resolveDefaultProps(updateExpirationTime, context)), null !== current && ((current.alternate = null), (workInProgress.alternate = null), (workInProgress.effectTag |= 2)), (workInProgress.tag = 1), - isContextProvider(updateLanes) + isContextProvider(updateExpirationTime) ? ((current = !0), pushContextProvider(workInProgress)) : (current = !1), - prepareToReadContext(workInProgress, renderLanes), - constructClassInstance(workInProgress, updateLanes, context), - mountClassInstance(workInProgress, updateLanes, context, renderLanes), + prepareToReadContext(workInProgress, renderExpirationTime), + constructClassInstance(workInProgress, updateExpirationTime, context), + mountClassInstance( + workInProgress, + updateExpirationTime, + context, + renderExpirationTime + ), finishClassComponent( null, workInProgress, - updateLanes, + updateExpirationTime, !0, current, - renderLanes + renderExpirationTime ) ); case 19: - return updateSuspenseListComponent(current, workInProgress, renderLanes); - case 23: - return updateOffscreenComponent(current, workInProgress, renderLanes); - case 24: - return updateOffscreenComponent(current, workInProgress, renderLanes); + return updateSuspenseListComponent( + current, + workInProgress, + renderExpirationTime + ); } throw Error( "Unknown unit of work tag (" + @@ -7591,6 +7205,32 @@ beginWork$1 = function(current, workInProgress, renderLanes) { "). This error is likely caused by a bug in React. Please file an issue." ); }; +var onCommitFiberRoot = null, + onCommitFiberUnmount = null; +function injectInternals(internals) { + if ("undefined" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) return !1; + var hook = __REACT_DEVTOOLS_GLOBAL_HOOK__; + if (hook.isDisabled || !hook.supportsFiber) return !0; + try { + var rendererID = hook.inject(internals); + onCommitFiberRoot = function(root) { + try { + hook.onCommitFiberRoot( + rendererID, + root, + void 0, + 64 === (root.current.effectTag & 64) + ); + } catch (err) {} + }; + onCommitFiberUnmount = function(fiber) { + try { + hook.onCommitFiberUnmount(rendererID, fiber); + } catch (err) {} + }; + } catch (err) {} + return !0; +} function FiberNode(tag, pendingProps, key, mode) { this.tag = tag; this.key = key; @@ -7602,12 +7242,9 @@ function FiberNode(tag, pendingProps, key, mode) { this.mode = mode; this.effectTag = 0; this.lastEffect = this.firstEffect = this.nextEffect = null; - this.childLanes = this.lanes = 0; + 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); @@ -7625,7 +7262,7 @@ function resolveLazyComponentTag(Component) { function createWorkInProgress(current, pendingProps) { var workInProgress = current.alternate; null === workInProgress - ? ((workInProgress = createFiber( + ? ((workInProgress = new FiberNode( current.tag, pendingProps, current.key, @@ -7637,13 +7274,16 @@ function createWorkInProgress(current, pendingProps) { (workInProgress.alternate = current), (current.alternate = workInProgress)) : ((workInProgress.pendingProps = pendingProps), - (workInProgress.type = current.type), (workInProgress.effectTag = 0), (workInProgress.nextEffect = null), (workInProgress.firstEffect = null), (workInProgress.lastEffect = null)); - workInProgress.childLanes = current.childLanes; - workInProgress.lanes = current.lanes; + if (null == current) + throw Error("current is " + current + " but it can't be"); + if (null == workInProgress) + throw Error("workInProgress is " + workInProgress + " but it can't be"); + workInProgress.childExpirationTime = current.childExpirationTime; + workInProgress.expirationTime = current.expirationTime; workInProgress.child = current.child; workInProgress.memoizedProps = current.memoizedProps; workInProgress.memoizedState = current.memoizedState; @@ -7653,7 +7293,7 @@ function createWorkInProgress(current, pendingProps) { null === pendingProps ? null : { - lanes: pendingProps.lanes, + expirationTime: pendingProps.expirationTime, firstContext: pendingProps.firstContext, responders: pendingProps.responders }; @@ -7668,7 +7308,7 @@ function createFiberFromTypeAndProps( pendingProps, owner, mode, - lanes + expirationTime ) { var fiberTag = 2; owner = type; @@ -7677,10 +7317,15 @@ function createFiberFromTypeAndProps( else a: switch (type) { case REACT_FRAGMENT_TYPE: - return createFiberFromFragment(pendingProps.children, mode, lanes, key); - case REACT_DEBUG_TRACING_MODE_TYPE: + return createFiberFromFragment( + pendingProps.children, + mode, + expirationTime, + key + ); + case REACT_CONCURRENT_MODE_TYPE: fiberTag = 8; - mode |= 16; + mode |= 7; break; case REACT_STRICT_MODE_TYPE: fiberTag = 8; @@ -7688,34 +7333,25 @@ function createFiberFromTypeAndProps( break; case REACT_PROFILER_TYPE: return ( - (type = createFiber(12, pendingProps, key, mode | 8)), + (type = new FiberNode(12, pendingProps, key, mode | 8)), (type.elementType = REACT_PROFILER_TYPE), (type.type = REACT_PROFILER_TYPE), - (type.lanes = lanes), + (type.expirationTime = expirationTime), type ); case REACT_SUSPENSE_TYPE: return ( - (type = createFiber(13, pendingProps, key, mode)), + (type = new FiberNode(13, pendingProps, key, mode)), (type.type = REACT_SUSPENSE_TYPE), (type.elementType = REACT_SUSPENSE_TYPE), - (type.lanes = lanes), + (type.expirationTime = expirationTime), type ); case REACT_SUSPENSE_LIST_TYPE: return ( - (type = createFiber(19, pendingProps, key, mode)), + (type = new FiberNode(19, pendingProps, key, mode)), (type.elementType = REACT_SUSPENSE_LIST_TYPE), - (type.lanes = lanes), - type - ); - case REACT_OFFSCREEN_TYPE: - return createFiberFromOffscreen(pendingProps, mode, lanes, key); - case REACT_LEGACY_HIDDEN_TYPE: - return ( - (type = createFiber(24, pendingProps, key, mode)), - (type.elementType = REACT_LEGACY_HIDDEN_TYPE), - (type.lanes = lanes), + (type.expirationTime = expirationTime), type ); default: @@ -7747,36 +7383,30 @@ function createFiberFromTypeAndProps( "." ); } - key = createFiber(fiberTag, pendingProps, key, mode); + key = new FiberNode(fiberTag, pendingProps, key, mode); key.elementType = type; key.type = owner; - key.lanes = lanes; + key.expirationTime = expirationTime; return key; } -function createFiberFromFragment(elements, mode, lanes, key) { - elements = createFiber(7, elements, key, mode); - elements.lanes = lanes; +function createFiberFromFragment(elements, mode, expirationTime, key) { + elements = new FiberNode(7, elements, key, mode); + elements.expirationTime = expirationTime; return elements; } -function createFiberFromOffscreen(pendingProps, mode, lanes, key) { - pendingProps = createFiber(23, pendingProps, key, mode); - pendingProps.elementType = REACT_OFFSCREEN_TYPE; - pendingProps.lanes = lanes; - return pendingProps; -} -function createFiberFromText(content, mode, lanes) { - content = createFiber(6, content, null, mode); - content.lanes = lanes; +function createFiberFromText(content, mode, expirationTime) { + content = new FiberNode(6, content, null, mode); + content.expirationTime = expirationTime; return content; } -function createFiberFromPortal(portal, mode, lanes) { - mode = createFiber( +function createFiberFromPortal(portal, mode, expirationTime) { + mode = new FiberNode( 4, null !== portal.children ? portal.children : [], portal.key, mode ); - mode.lanes = lanes; + mode.expirationTime = expirationTime; mode.stateNode = { containerInfo: portal.containerInfo, pendingChildren: null, @@ -7786,31 +7416,51 @@ function createFiberFromPortal(portal, mode, lanes) { } function FiberRootNode(containerInfo, tag, hydrate) { this.tag = tag; + this.current = null; this.containerInfo = containerInfo; - this.finishedWork = this.pingCache = this.current = this.pendingChildren = null; + this.pingCache = this.pendingChildren = null; + this.finishedExpirationTime = 0; + this.finishedWork = null; this.timeoutHandle = -1; this.pendingContext = this.context = null; this.hydrate = hydrate; this.callbackNode = null; - this.callbackPriority = 0; - this.eventTimes = Array(31).fill(0); - this.expirationTimes = Array(31).fill(-1); - this.entangledLanes = this.finishedLanes = this.mutableReadLanes = this.expiredLanes = this.pingedLanes = this.suspendedLanes = this.pendingLanes = 0; - this.entanglements = Array(31).fill(0); + this.callbackPriority = 90; + this.lastExpiredTime = this.lastPingedTime = this.nextKnownPendingLevel = this.lastSuspendedTime = this.firstSuspendedTime = this.firstPendingTime = 0; } -function createPortal(children, containerInfo, implementation) { - var key = - 3 < arguments.length && void 0 !== arguments[3] ? arguments[3] : null; - return { - $$typeof: REACT_PORTAL_TYPE, - key: null == key ? null : "" + key, - children: children, - containerInfo: containerInfo, - implementation: implementation - }; +function isRootSuspendedAtTime(root, expirationTime) { + var firstSuspendedTime = root.firstSuspendedTime; + root = root.lastSuspendedTime; + return ( + 0 !== firstSuspendedTime && + firstSuspendedTime >= expirationTime && + root <= expirationTime + ); +} +function markRootSuspendedAtTime(root, expirationTime) { + var firstSuspendedTime = root.firstSuspendedTime, + lastSuspendedTime = root.lastSuspendedTime; + firstSuspendedTime < expirationTime && + (root.firstSuspendedTime = expirationTime); + if (lastSuspendedTime > expirationTime || 0 === firstSuspendedTime) + root.lastSuspendedTime = expirationTime; + expirationTime <= root.lastPingedTime && (root.lastPingedTime = 0); + expirationTime <= root.lastExpiredTime && (root.lastExpiredTime = 0); +} +function markRootUpdatedAtTime(root, expirationTime) { + expirationTime > root.firstPendingTime && + (root.firstPendingTime = expirationTime); + var firstSuspendedTime = root.firstSuspendedTime; + 0 !== firstSuspendedTime && + (expirationTime >= firstSuspendedTime + ? (root.firstSuspendedTime = root.lastSuspendedTime = root.nextKnownPendingLevel = 0) + : expirationTime >= root.lastSuspendedTime && + (root.lastSuspendedTime = expirationTime + 1), + expirationTime > root.nextKnownPendingLevel && + (root.nextKnownPendingLevel = expirationTime)); } function findHostInstance(component) { - var fiber = component._reactInternals; + var fiber = component._reactInternalFiber; if (void 0 === fiber) { if ("function" === typeof component.render) throw Error("Unable to find node on an unmounted component."); @@ -7824,11 +7474,11 @@ function findHostInstance(component) { } function updateContainer(element, container, parentComponent, callback) { var current = container.current, - eventTime = requestEventTime(), - suspenseConfig = ReactCurrentBatchConfig.suspense, - lane = requestUpdateLane(current, suspenseConfig); + currentTime = requestCurrentTimeForUpdate(), + suspenseConfig = ReactCurrentBatchConfig.suspense; + currentTime = computeExpirationForFiber(currentTime, current, suspenseConfig); a: if (parentComponent) { - parentComponent = parentComponent._reactInternals; + parentComponent = parentComponent._reactInternalFiber; b: { if ( getNearestMountedFiber(parentComponent) !== parentComponent || @@ -7837,23 +7487,22 @@ function updateContainer(element, container, parentComponent, callback) { throw Error( "Expected subtree parent to be a mounted class component. This error is likely caused by a bug in React. Please file an issue." ); - var JSCompiler_inline_result = parentComponent; + var parentContext = parentComponent; do { - switch (JSCompiler_inline_result.tag) { + switch (parentContext.tag) { case 3: - JSCompiler_inline_result = - JSCompiler_inline_result.stateNode.context; + parentContext = parentContext.stateNode.context; break b; case 1: - if (isContextProvider(JSCompiler_inline_result.type)) { - JSCompiler_inline_result = - JSCompiler_inline_result.stateNode + if (isContextProvider(parentContext.type)) { + parentContext = + parentContext.stateNode .__reactInternalMemoizedMergedChildContext; break b; } } - JSCompiler_inline_result = JSCompiler_inline_result.return; - } while (null !== JSCompiler_inline_result); + parentContext = parentContext.return; + } while (null !== parentContext); throw Error( "Found unexpected detached subtree parent. This error is likely caused by a bug in React. Please file an issue." ); @@ -7864,26 +7513,34 @@ function updateContainer(element, container, parentComponent, callback) { parentComponent = processChildContext( parentComponent, Component, - JSCompiler_inline_result + parentContext ); break a; } } - parentComponent = JSCompiler_inline_result; + parentComponent = parentContext; } else parentComponent = emptyContextObject; null === container.context ? (container.context = parentComponent) : (container.pendingContext = parentComponent); - container = createUpdate(eventTime, lane, suspenseConfig); + container = createUpdate(currentTime, suspenseConfig); container.payload = { element: element }; callback = void 0 === callback ? null : callback; null !== callback && (container.callback = callback); enqueueUpdate(current, container); - scheduleUpdateOnFiber(current, lane, eventTime); - return lane; + scheduleWork(current, currentTime); + return currentTime; } -function emptyFindFiberByHostInstance() { - return null; +function createPortal(children, containerInfo, implementation) { + var key = + 3 < arguments.length && void 0 !== arguments[3] ? arguments[3] : null; + return { + $$typeof: REACT_PORTAL_TYPE, + key: null == key ? null : "" + key, + children: children, + containerInfo: containerInfo, + implementation: implementation + }; } function findNodeHandle(componentOrHandle) { if (null == componentOrHandle) return null; @@ -7912,64 +7569,53 @@ batchedUpdatesImpl = function(fn, a) { return fn(a); } finally { (executionContext = prevExecutionContext), - 0 === executionContext && flushSyncCallbackQueue(); + executionContext === NoContext && flushSyncCallbackQueue(); } }; -var roots = new Map(), - devToolsConfig$jscomp$inline_934 = { - findFiberByHostInstance: getInstanceFromTag, - bundleType: 0, - version: "17.0.0-alpha.0", - rendererPackageName: "react-native-renderer", - rendererConfig: { - getInspectorDataForViewTag: function() { - throw Error( - "getInspectorDataForViewTag() is not available in production" - ); - }, - getInspectorDataForViewAtPoint: function() { - throw Error( - "getInspectorDataForViewAtPoint() is not available in production." - ); - }.bind(null, findNodeHandle) - } - }; -var internals$jscomp$inline_1135 = { - bundleType: devToolsConfig$jscomp$inline_934.bundleType, - version: devToolsConfig$jscomp$inline_934.version, - rendererPackageName: devToolsConfig$jscomp$inline_934.rendererPackageName, - rendererConfig: devToolsConfig$jscomp$inline_934.rendererConfig, - overrideHookState: null, - overrideProps: null, - setSuspenseHandler: null, - scheduleUpdate: null, - currentDispatcherRef: ReactSharedInternals.ReactCurrentDispatcher, - findHostInstanceByFiber: function(fiber) { - fiber = findCurrentHostFiber(fiber); - return null === fiber ? null : fiber.stateNode; - }, - findFiberByHostInstance: - devToolsConfig$jscomp$inline_934.findFiberByHostInstance || - emptyFindFiberByHostInstance, - findHostInstancesForRefresh: null, - scheduleRefresh: null, - scheduleRoot: null, - setRefreshHandler: null, - getCurrentFiber: null -}; -if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) { - var hook$jscomp$inline_1136 = __REACT_DEVTOOLS_GLOBAL_HOOK__; - if ( - !hook$jscomp$inline_1136.isDisabled && - hook$jscomp$inline_1136.supportsFiber - ) - try { - (rendererID = hook$jscomp$inline_1136.inject( - internals$jscomp$inline_1135 - )), - (injectedHook = hook$jscomp$inline_1136); - } catch (err) {} -} +var roots = new Map(); +(function(devToolsConfig) { + var findFiberByHostInstance = devToolsConfig.findFiberByHostInstance; + return injectInternals({ + bundleType: devToolsConfig.bundleType, + version: devToolsConfig.version, + rendererPackageName: devToolsConfig.rendererPackageName, + rendererConfig: devToolsConfig.rendererConfig, + overrideHookState: null, + overrideProps: null, + setSuspenseHandler: null, + scheduleUpdate: null, + currentDispatcherRef: ReactSharedInternals.ReactCurrentDispatcher, + findHostInstanceByFiber: function(fiber) { + fiber = findCurrentHostFiber(fiber); + return null === fiber ? null : fiber.stateNode; + }, + findFiberByHostInstance: function(instance) { + return findFiberByHostInstance ? findFiberByHostInstance(instance) : null; + }, + findHostInstancesForRefresh: null, + scheduleRefresh: null, + scheduleRoot: null, + setRefreshHandler: null, + getCurrentFiber: null + }); +})({ + findFiberByHostInstance: getInstanceFromTag, + bundleType: 0, + version: "16.13.0", + rendererPackageName: "react-native-renderer", + rendererConfig: { + getInspectorDataForViewTag: function() { + throw Error( + "getInspectorDataForViewTag() is not available in production" + ); + }, + getInspectorDataForViewAtPoint: function() { + throw Error( + "getInspectorDataForViewAtPoint() is not available in production." + ); + }.bind(null, findNodeHandle) + } +}); exports.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = { computeComponentStackForErrorReporting: function(reactTag) { return (reactTag = getInstanceFromTag(reactTag)) @@ -8016,7 +7662,7 @@ exports.render = function(element, containerTag, callback) { var root = roots.get(containerTag); if (!root) { root = new FiberRootNode(containerTag, 0, !1); - var uninitializedFiber = createFiber(3, null, null, 0); + var uninitializedFiber = new FiberNode(3, null, null, 0); root.current = uninitializedFiber; uninitializedFiber.stateNode = root; initializeUpdateQueue(uninitializedFiber); diff --git a/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.fb.js b/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.fb.js index fc338954b12..2bac9e25f6c 100644 --- a/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.fb.js +++ b/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.fb.js @@ -16,6 +16,16 @@ var ReactNativePrivateInterface = require("react-native/Libraries/ReactPrivate/R React = require("react"), Scheduler = require("scheduler"), tracing = require("scheduler/tracing"); +function getParent(inst) { + do inst = inst.return; + while (inst && 5 !== inst.tag); + return inst ? inst : null; +} +function traverseTwoPhase(inst, fn, arg) { + for (var path = []; inst; ) path.push(inst), (inst = getParent(inst)); + for (inst = path.length; 0 < inst--; ) fn(path[inst], "captured", arg); + for (inst = 0; inst < path.length; inst++) fn(path[inst], "bubbled", arg); +} function invokeGuardedCallbackImpl(name, func, context, a, b, c, d, e, f) { var funcArgs = Array.prototype.slice.call(arguments, 3); try { @@ -86,6 +96,109 @@ function executeDirectDispatch(event) { event._dispatchInstances = null; return dispatchListener; } +function getListener(inst, registrationName) { + var listener = inst.stateNode; + if (!listener) return null; + var props = getFiberCurrentPropsFromNode(listener); + if (!props) return null; + listener = props[registrationName]; + a: switch (registrationName) { + case "onClick": + case "onClickCapture": + case "onDoubleClick": + case "onDoubleClickCapture": + case "onMouseDown": + case "onMouseDownCapture": + case "onMouseMove": + case "onMouseMoveCapture": + case "onMouseUp": + case "onMouseUpCapture": + case "onMouseEnter": + (props = !props.disabled) || + ((inst = inst.type), + (props = !( + "button" === inst || + "input" === inst || + "select" === inst || + "textarea" === inst + ))); + inst = !props; + break a; + default: + inst = !1; + } + if (inst) return null; + if (listener && "function" !== typeof listener) + throw Error( + "Expected `" + + registrationName + + "` listener to be a function, instead got a value of `" + + typeof listener + + "` type." + ); + return listener; +} +function accumulateInto(current, next) { + if (null == next) + throw Error( + "accumulateInto(...): Accumulated items must not be null or undefined." + ); + if (null == current) return next; + if (Array.isArray(current)) { + if (Array.isArray(next)) return current.push.apply(current, next), current; + current.push(next); + return current; + } + return Array.isArray(next) ? [current].concat(next) : [current, next]; +} +function forEachAccumulated(arr, cb, scope) { + Array.isArray(arr) ? arr.forEach(cb, scope) : arr && cb.call(scope, arr); +} +function accumulateDirectionalDispatches(inst, phase, event) { + if ( + (phase = getListener( + inst, + event.dispatchConfig.phasedRegistrationNames[phase] + )) + ) + (event._dispatchListeners = accumulateInto( + event._dispatchListeners, + phase + )), + (event._dispatchInstances = accumulateInto( + event._dispatchInstances, + inst + )); +} +function accumulateTwoPhaseDispatchesSingle(event) { + event && + event.dispatchConfig.phasedRegistrationNames && + traverseTwoPhase(event._targetInst, accumulateDirectionalDispatches, event); +} +function accumulateTwoPhaseDispatchesSingleSkipTarget(event) { + if (event && event.dispatchConfig.phasedRegistrationNames) { + var targetInst = event._targetInst; + targetInst = targetInst ? getParent(targetInst) : null; + traverseTwoPhase(targetInst, accumulateDirectionalDispatches, event); + } +} +function accumulateDirectDispatchesSingle(event) { + if (event && event.dispatchConfig.registrationName) { + var inst = event._targetInst; + if (inst && event && event.dispatchConfig.registrationName) { + var listener = getListener(inst, event.dispatchConfig.registrationName); + listener && + ((event._dispatchListeners = accumulateInto( + event._dispatchListeners, + listener + )), + (event._dispatchInstances = accumulateInto( + event._dispatchInstances, + inst + ))); + } + } +} function functionThatReturnsTrue() { return !0; } @@ -101,7 +214,6 @@ function SyntheticEvent( this.dispatchConfig = dispatchConfig; this._targetInst = targetInst; this.nativeEvent = nativeEvent; - this._dispatchInstances = this._dispatchListeners = null; dispatchConfig = this.constructor.Interface; for (var propName in dispatchConfig) dispatchConfig.hasOwnProperty(propName) && @@ -181,12 +293,7 @@ SyntheticEvent.extend = function(Interface) { return Class; }; addEventPoolingTo(SyntheticEvent); -function createOrGetPooledEvent( - dispatchConfig, - targetInst, - nativeEvent, - nativeInst -) { +function getPooledEvent(dispatchConfig, targetInst, nativeEvent, nativeInst) { if (this.eventPool.length) { var instance = this.eventPool.pop(); this.call(instance, dispatchConfig, targetInst, nativeEvent, nativeInst); @@ -203,8 +310,8 @@ function releasePooledEvent(event) { 10 > this.eventPool.length && this.eventPool.push(event); } function addEventPoolingTo(EventConstructor) { - EventConstructor.getPooled = createOrGetPooledEvent; EventConstructor.eventPool = []; + EventConstructor.getPooled = getPooledEvent; EventConstructor.release = releasePooledEvent; } var ResponderSyntheticEvent = SyntheticEvent.extend({ @@ -332,22 +439,6 @@ function accumulate(current, next) { ? [current].concat(next) : [current, next]; } -function accumulateInto(current, next) { - if (null == next) - throw Error( - "accumulateInto(...): Accumulated items must not be null or undefined." - ); - if (null == current) return next; - if (Array.isArray(current)) { - if (Array.isArray(next)) return current.push.apply(current, next), current; - current.push(next); - return current; - } - return Array.isArray(next) ? [current].concat(next) : [current, next]; -} -function forEachAccumulated(arr, cb, scope) { - Array.isArray(arr) ? arr.forEach(cb, scope) : arr && cb.call(scope, arr); -} var responderInst = null, trackedTouchCount = 0; function changeResponder(nextResponderInst, blockHostResponder) { @@ -361,132 +452,65 @@ function changeResponder(nextResponderInst, blockHostResponder) { ); } var eventTypes = { - startShouldSetResponder: { - phasedRegistrationNames: { - bubbled: "onStartShouldSetResponder", - captured: "onStartShouldSetResponderCapture" + startShouldSetResponder: { + phasedRegistrationNames: { + bubbled: "onStartShouldSetResponder", + captured: "onStartShouldSetResponderCapture" + }, + dependencies: startDependencies }, - dependencies: startDependencies - }, - scrollShouldSetResponder: { - phasedRegistrationNames: { - bubbled: "onScrollShouldSetResponder", - captured: "onScrollShouldSetResponderCapture" + scrollShouldSetResponder: { + phasedRegistrationNames: { + bubbled: "onScrollShouldSetResponder", + captured: "onScrollShouldSetResponderCapture" + }, + dependencies: ["topScroll"] }, - dependencies: ["topScroll"] - }, - selectionChangeShouldSetResponder: { - phasedRegistrationNames: { - bubbled: "onSelectionChangeShouldSetResponder", - captured: "onSelectionChangeShouldSetResponderCapture" + selectionChangeShouldSetResponder: { + phasedRegistrationNames: { + bubbled: "onSelectionChangeShouldSetResponder", + captured: "onSelectionChangeShouldSetResponderCapture" + }, + dependencies: ["topSelectionChange"] }, - dependencies: ["topSelectionChange"] - }, - moveShouldSetResponder: { - phasedRegistrationNames: { - bubbled: "onMoveShouldSetResponder", - captured: "onMoveShouldSetResponderCapture" + moveShouldSetResponder: { + phasedRegistrationNames: { + bubbled: "onMoveShouldSetResponder", + captured: "onMoveShouldSetResponderCapture" + }, + dependencies: moveDependencies }, - dependencies: moveDependencies - }, - responderStart: { - registrationName: "onResponderStart", - dependencies: startDependencies - }, - responderMove: { - registrationName: "onResponderMove", - dependencies: moveDependencies - }, - responderEnd: { - registrationName: "onResponderEnd", - dependencies: endDependencies - }, - responderRelease: { - registrationName: "onResponderRelease", - dependencies: endDependencies - }, - responderTerminationRequest: { - registrationName: "onResponderTerminationRequest", - dependencies: [] - }, - responderGrant: { registrationName: "onResponderGrant", dependencies: [] }, - responderReject: { registrationName: "onResponderReject", dependencies: [] }, - responderTerminate: { - registrationName: "onResponderTerminate", - dependencies: [] - } -}; -function getParent(inst) { - do inst = inst.return; - while (inst && 5 !== inst.tag); - return inst ? inst : null; -} -function traverseTwoPhase(inst, fn, arg) { - for (var path = []; inst; ) path.push(inst), (inst = getParent(inst)); - for (inst = path.length; 0 < inst--; ) fn(path[inst], "captured", arg); - for (inst = 0; inst < path.length; inst++) fn(path[inst], "bubbled", arg); -} -function getListener(inst, registrationName) { - inst = inst.stateNode; - if (null === inst) return null; - inst = getFiberCurrentPropsFromNode(inst); - if (null === inst) return null; - if ((inst = inst[registrationName]) && "function" !== typeof inst) - throw Error( - "Expected `" + - registrationName + - "` listener to be a function, instead got a value of `" + - typeof inst + - "` type." - ); - return inst; -} -function accumulateDirectionalDispatches(inst, phase, event) { - if ( - (phase = getListener( - inst, - event.dispatchConfig.phasedRegistrationNames[phase] - )) - ) - (event._dispatchListeners = accumulateInto( - event._dispatchListeners, - phase - )), - (event._dispatchInstances = accumulateInto( - event._dispatchInstances, - inst - )); -} -function accumulateDirectDispatchesSingle(event) { - if (event && event.dispatchConfig.registrationName) { - var inst = event._targetInst; - if (inst && event && event.dispatchConfig.registrationName) { - var listener = getListener(inst, event.dispatchConfig.registrationName); - listener && - ((event._dispatchListeners = accumulateInto( - event._dispatchListeners, - listener - )), - (event._dispatchInstances = accumulateInto( - event._dispatchInstances, - inst - ))); + responderStart: { + registrationName: "onResponderStart", + dependencies: startDependencies + }, + responderMove: { + registrationName: "onResponderMove", + dependencies: moveDependencies + }, + responderEnd: { + registrationName: "onResponderEnd", + dependencies: endDependencies + }, + responderRelease: { + registrationName: "onResponderRelease", + dependencies: endDependencies + }, + responderTerminationRequest: { + registrationName: "onResponderTerminationRequest", + dependencies: [] + }, + responderGrant: { registrationName: "onResponderGrant", dependencies: [] }, + responderReject: { + registrationName: "onResponderReject", + dependencies: [] + }, + responderTerminate: { + registrationName: "onResponderTerminate", + dependencies: [] } - } -} -function accumulateTwoPhaseDispatchesSingleSkipTarget(event) { - if (event && event.dispatchConfig.phasedRegistrationNames) { - var targetInst = event._targetInst; - targetInst = targetInst ? getParent(targetInst) : null; - traverseTwoPhase(targetInst, accumulateDirectionalDispatches, event); - } -} -function accumulateTwoPhaseDispatchesSingle(event) { - event && - event.dispatchConfig.phasedRegistrationNames && - traverseTwoPhase(event._targetInst, accumulateDirectionalDispatches, event); -} -var ResponderEventPlugin = { + }, + ResponderEventPlugin = { _getResponder: function() { return responderInst; }, @@ -547,70 +571,68 @@ var ResponderEventPlugin = { JSCompiler_temp = null; } else JSCompiler_temp = targetInst; - targetInst = JSCompiler_temp; - JSCompiler_temp = targetInst === responderInst; - shouldSetEventType = ResponderSyntheticEvent.getPooled( + targetInst = JSCompiler_temp === responderInst; + JSCompiler_temp = ResponderSyntheticEvent.getPooled( shouldSetEventType, - targetInst, + JSCompiler_temp, nativeEvent, nativeEventTarget ); - shouldSetEventType.touchHistory = - ResponderTouchHistoryStore.touchHistory; - JSCompiler_temp + JSCompiler_temp.touchHistory = ResponderTouchHistoryStore.touchHistory; + targetInst ? forEachAccumulated( - shouldSetEventType, + JSCompiler_temp, accumulateTwoPhaseDispatchesSingleSkipTarget ) : forEachAccumulated( - shouldSetEventType, + JSCompiler_temp, accumulateTwoPhaseDispatchesSingle ); b: { - JSCompiler_temp = shouldSetEventType._dispatchListeners; - targetInst = shouldSetEventType._dispatchInstances; - if (Array.isArray(JSCompiler_temp)) + shouldSetEventType = JSCompiler_temp._dispatchListeners; + targetInst = JSCompiler_temp._dispatchInstances; + if (Array.isArray(shouldSetEventType)) for ( depthA = 0; - depthA < JSCompiler_temp.length && - !shouldSetEventType.isPropagationStopped(); + depthA < shouldSetEventType.length && + !JSCompiler_temp.isPropagationStopped(); depthA++ ) { if ( - JSCompiler_temp[depthA](shouldSetEventType, targetInst[depthA]) + shouldSetEventType[depthA](JSCompiler_temp, targetInst[depthA]) ) { - JSCompiler_temp = targetInst[depthA]; + shouldSetEventType = targetInst[depthA]; break b; } } else if ( - JSCompiler_temp && - JSCompiler_temp(shouldSetEventType, targetInst) + shouldSetEventType && + shouldSetEventType(JSCompiler_temp, targetInst) ) { - JSCompiler_temp = targetInst; + shouldSetEventType = targetInst; break b; } - JSCompiler_temp = null; + shouldSetEventType = null; } - shouldSetEventType._dispatchInstances = null; - shouldSetEventType._dispatchListeners = null; - shouldSetEventType.isPersistent() || - shouldSetEventType.constructor.release(shouldSetEventType); - if (JSCompiler_temp && JSCompiler_temp !== responderInst) + JSCompiler_temp._dispatchInstances = null; + JSCompiler_temp._dispatchListeners = null; + JSCompiler_temp.isPersistent() || + JSCompiler_temp.constructor.release(JSCompiler_temp); + if (shouldSetEventType && shouldSetEventType !== responderInst) if ( - ((shouldSetEventType = ResponderSyntheticEvent.getPooled( + ((JSCompiler_temp = ResponderSyntheticEvent.getPooled( eventTypes.responderGrant, - JSCompiler_temp, + shouldSetEventType, nativeEvent, nativeEventTarget )), - (shouldSetEventType.touchHistory = + (JSCompiler_temp.touchHistory = ResponderTouchHistoryStore.touchHistory), forEachAccumulated( - shouldSetEventType, + JSCompiler_temp, accumulateDirectDispatchesSingle ), - (targetInst = !0 === executeDirectDispatch(shouldSetEventType)), + (targetInst = !0 === executeDirectDispatch(JSCompiler_temp)), responderInst) ) if ( @@ -637,13 +659,13 @@ var ResponderEventPlugin = { forEachAccumulated(depthA, accumulateDirectDispatchesSingle); var JSCompiler_temp$jscomp$0 = accumulate( JSCompiler_temp$jscomp$0, - [shouldSetEventType, depthA] + [JSCompiler_temp, depthA] ); - changeResponder(JSCompiler_temp, targetInst); + changeResponder(shouldSetEventType, targetInst); } else (shouldSetEventType = ResponderSyntheticEvent.getPooled( eventTypes.responderReject, - JSCompiler_temp, + shouldSetEventType, nativeEvent, nativeEventTarget )), @@ -660,9 +682,9 @@ var ResponderEventPlugin = { else (JSCompiler_temp$jscomp$0 = accumulate( JSCompiler_temp$jscomp$0, - shouldSetEventType + JSCompiler_temp )), - changeResponder(JSCompiler_temp, targetInst); + changeResponder(shouldSetEventType, targetInst); else JSCompiler_temp$jscomp$0 = null; } else JSCompiler_temp$jscomp$0 = null; shouldSetEventType = responderInst && isStartish(topLevelType); @@ -790,6 +812,7 @@ function recomputePluginOrdering() { for (var eventName in pluginIndex) { var JSCompiler_inline_result = void 0; var dispatchConfig = pluginIndex[eventName], + pluginModule$jscomp$0 = pluginModule, eventName$jscomp$0 = eventName; if (eventNameDispatchConfigs.hasOwnProperty(eventName$jscomp$0)) throw Error( @@ -806,7 +829,7 @@ function recomputePluginOrdering() { ) && publishRegistrationName( phasedRegistrationNames[JSCompiler_inline_result], - pluginModule, + pluginModule$jscomp$0, eventName$jscomp$0 ); JSCompiler_inline_result = !0; @@ -814,7 +837,7 @@ function recomputePluginOrdering() { dispatchConfig.registrationName ? (publishRegistrationName( dispatchConfig.registrationName, - pluginModule, + pluginModule$jscomp$0, eventName$jscomp$0 ), (JSCompiler_inline_result = !0)) @@ -842,75 +865,13 @@ function publishRegistrationName(registrationName, pluginModule) { } var plugins = [], eventNameDispatchConfigs = {}, - registrationNameModules = {}; -function getListener$1(inst, registrationName) { - inst = inst.stateNode; - if (null === inst) return null; - inst = getFiberCurrentPropsFromNode(inst); - if (null === inst) return null; - if ((inst = inst[registrationName]) && "function" !== typeof inst) - throw Error( - "Expected `" + - registrationName + - "` listener to be a function, instead got a value of `" + - typeof inst + - "` type." - ); - return inst; -} -var customBubblingEventTypes = + registrationNameModules = {}, + customBubblingEventTypes = ReactNativePrivateInterface.ReactNativeViewConfigRegistry .customBubblingEventTypes, customDirectEventTypes = ReactNativePrivateInterface.ReactNativeViewConfigRegistry .customDirectEventTypes; -function accumulateDirectionalDispatches$1(inst, phase, event) { - if ( - (phase = getListener$1( - inst, - event.dispatchConfig.phasedRegistrationNames[phase] - )) - ) - (event._dispatchListeners = accumulateInto( - event._dispatchListeners, - phase - )), - (event._dispatchInstances = accumulateInto( - event._dispatchInstances, - inst - )); -} -function accumulateTwoPhaseDispatchesSingle$1(event) { - if (event && event.dispatchConfig.phasedRegistrationNames) { - for (var inst = event._targetInst, path = []; inst; ) { - path.push(inst); - do inst = inst.return; - while (inst && 5 !== inst.tag); - inst = inst ? inst : null; - } - for (inst = path.length; 0 < inst--; ) - accumulateDirectionalDispatches$1(path[inst], "captured", event); - for (inst = 0; inst < path.length; inst++) - accumulateDirectionalDispatches$1(path[inst], "bubbled", event); - } -} -function accumulateDirectDispatchesSingle$1(event) { - if (event && event.dispatchConfig.registrationName) { - var inst = event._targetInst; - if (inst && event && event.dispatchConfig.registrationName) { - var listener = getListener$1(inst, event.dispatchConfig.registrationName); - listener && - ((event._dispatchListeners = accumulateInto( - event._dispatchListeners, - listener - )), - (event._dispatchInstances = accumulateInto( - event._dispatchInstances, - inst - ))); - } - } -} if (eventPluginOrder) throw Error( "EventPluginRegistry: Cannot inject event plugin ordering more than once. You are likely trying to load more than one copy of React." @@ -920,7 +881,7 @@ eventPluginOrder = Array.prototype.slice.call([ "ReactNativeBridgeEventPlugin" ]); recomputePluginOrdering(); -var injectedNamesToPlugins$jscomp$inline_232 = { +var injectedNamesToPlugins$jscomp$inline_94 = { ResponderEventPlugin: ResponderEventPlugin, ReactNativeBridgeEventPlugin: { eventTypes: {}, @@ -944,45 +905,42 @@ var injectedNamesToPlugins$jscomp$inline_232 = { nativeEventTarget ); if (bubbleDispatchConfig) - forEachAccumulated( - topLevelType, - accumulateTwoPhaseDispatchesSingle$1 - ); + forEachAccumulated(topLevelType, accumulateTwoPhaseDispatchesSingle); else if (directDispatchConfig) - forEachAccumulated(topLevelType, accumulateDirectDispatchesSingle$1); + forEachAccumulated(topLevelType, accumulateDirectDispatchesSingle); else return null; return topLevelType; } } }, - isOrderingDirty$jscomp$inline_233 = !1, - pluginName$jscomp$inline_234; -for (pluginName$jscomp$inline_234 in injectedNamesToPlugins$jscomp$inline_232) + isOrderingDirty$jscomp$inline_95 = !1, + pluginName$jscomp$inline_96; +for (pluginName$jscomp$inline_96 in injectedNamesToPlugins$jscomp$inline_94) if ( - injectedNamesToPlugins$jscomp$inline_232.hasOwnProperty( - pluginName$jscomp$inline_234 + injectedNamesToPlugins$jscomp$inline_94.hasOwnProperty( + pluginName$jscomp$inline_96 ) ) { - var pluginModule$jscomp$inline_235 = - injectedNamesToPlugins$jscomp$inline_232[pluginName$jscomp$inline_234]; + var pluginModule$jscomp$inline_97 = + injectedNamesToPlugins$jscomp$inline_94[pluginName$jscomp$inline_96]; if ( - !namesToPlugins.hasOwnProperty(pluginName$jscomp$inline_234) || - namesToPlugins[pluginName$jscomp$inline_234] !== - pluginModule$jscomp$inline_235 + !namesToPlugins.hasOwnProperty(pluginName$jscomp$inline_96) || + namesToPlugins[pluginName$jscomp$inline_96] !== + pluginModule$jscomp$inline_97 ) { - if (namesToPlugins[pluginName$jscomp$inline_234]) + if (namesToPlugins[pluginName$jscomp$inline_96]) throw Error( "EventPluginRegistry: Cannot inject two different event plugins using the same name, `" + - pluginName$jscomp$inline_234 + + pluginName$jscomp$inline_96 + "`." ); namesToPlugins[ - pluginName$jscomp$inline_234 - ] = pluginModule$jscomp$inline_235; - isOrderingDirty$jscomp$inline_233 = !0; + pluginName$jscomp$inline_96 + ] = pluginModule$jscomp$inline_97; + isOrderingDirty$jscomp$inline_95 = !0; } } -isOrderingDirty$jscomp$inline_233 && recomputePluginOrdering(); +isOrderingDirty$jscomp$inline_95 && recomputePluginOrdering(); var instanceCache = new Map(), instanceProps = new Map(); function getInstanceFromTag(tag) { @@ -1028,41 +986,34 @@ function _receiveRootNodeIDEvent(rootNodeID, topLevelType, nativeEventParam) { target = null; null != inst && (target = inst.stateNode); batchedUpdates(function() { - var JSCompiler_inline_result = target; - for ( - var events = null, legacyPlugins = plugins, i = 0; - i < legacyPlugins.length; - i++ - ) { - var possiblePlugin = legacyPlugins[i]; + var events = target; + for (var events$jscomp$0 = null, i = 0; i < plugins.length; i++) { + var possiblePlugin = plugins[i]; possiblePlugin && (possiblePlugin = possiblePlugin.extractEvents( topLevelType, inst, nativeEvent, - JSCompiler_inline_result + events, + 1 )) && - (events = accumulateInto(events, possiblePlugin)); + (events$jscomp$0 = accumulateInto(events$jscomp$0, possiblePlugin)); } - JSCompiler_inline_result = events; - null !== JSCompiler_inline_result && - (eventQueue = accumulateInto(eventQueue, JSCompiler_inline_result)); - JSCompiler_inline_result = eventQueue; + events = events$jscomp$0; + null !== events && (eventQueue = accumulateInto(eventQueue, events)); + events = eventQueue; eventQueue = null; - if (JSCompiler_inline_result) { - forEachAccumulated( - JSCompiler_inline_result, - executeDispatchesAndReleaseTopLevel - ); + if (events) { + forEachAccumulated(events, executeDispatchesAndReleaseTopLevel); if (eventQueue) throw Error( "processEventQueue(): Additional events were enqueued while processing an event queue. Support for this has not yet been implemented." ); if (hasRethrowError) - throw ((JSCompiler_inline_result = rethrowError), + throw ((events = rethrowError), (hasRethrowError = !1), (rethrowError = null), - JSCompiler_inline_result); + events); } }); } @@ -1077,13 +1028,13 @@ ReactNativePrivateInterface.RCTEventEmitter.register({ ) { var JSCompiler_temp = []; for (var i = 0; i < changedIndices.length; i++) { - var index$0 = changedIndices[i]; - JSCompiler_temp.push(touches[index$0]); - touches[index$0] = null; + var index = changedIndices[i]; + JSCompiler_temp.push(touches[index]); + touches[index] = null; } for (i = changedIndices = 0; i < touches.length; i++) - (index$0 = touches[i]), - null !== index$0 && (touches[changedIndices++] = index$0); + (index = touches[i]), + null !== index && (touches[changedIndices++] = index); touches.length = changedIndices; } else for (JSCompiler_temp = [], i = 0; i < changedIndices.length; i++) @@ -1096,10 +1047,10 @@ ReactNativePrivateInterface.RCTEventEmitter.register({ i = JSCompiler_temp[changedIndices]; i.changedTouches = JSCompiler_temp; i.touches = touches; - index$0 = null; + index = null; var target = i.target; - null === target || void 0 === target || 1 > target || (index$0 = target); - _receiveRootNodeIDEvent(index$0, eventTopLevelType, i); + null === target || void 0 === target || 1 > target || (index = target); + _receiveRootNodeIDEvent(index, eventTopLevelType, i); } } }); @@ -1125,44 +1076,31 @@ ResponderEventPlugin.injection.injectGlobalResponderHandler({ } }); var ReactSharedInternals = - React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED, - REACT_ELEMENT_TYPE = 60103, - REACT_PORTAL_TYPE = 60106, - REACT_FRAGMENT_TYPE = 60107, - REACT_STRICT_MODE_TYPE = 60108, - REACT_PROFILER_TYPE = 60114, - REACT_PROVIDER_TYPE = 60109, - REACT_CONTEXT_TYPE = 60110, - REACT_FORWARD_REF_TYPE = 60112, - REACT_SUSPENSE_TYPE = 60113, - REACT_SUSPENSE_LIST_TYPE = 60120, - REACT_MEMO_TYPE = 60115, - REACT_LAZY_TYPE = 60116, - REACT_BLOCK_TYPE = 60121, - REACT_DEBUG_TRACING_MODE_TYPE = 60129, - REACT_OFFSCREEN_TYPE = 60130, - REACT_LEGACY_HIDDEN_TYPE = 60131; -if ("function" === typeof Symbol && Symbol.for) { - var symbolFor = Symbol.for; - REACT_ELEMENT_TYPE = symbolFor("react.element"); - REACT_PORTAL_TYPE = symbolFor("react.portal"); - REACT_FRAGMENT_TYPE = symbolFor("react.fragment"); - REACT_STRICT_MODE_TYPE = symbolFor("react.strict_mode"); - REACT_PROFILER_TYPE = symbolFor("react.profiler"); - REACT_PROVIDER_TYPE = symbolFor("react.provider"); - REACT_CONTEXT_TYPE = symbolFor("react.context"); - REACT_FORWARD_REF_TYPE = symbolFor("react.forward_ref"); - REACT_SUSPENSE_TYPE = symbolFor("react.suspense"); - REACT_SUSPENSE_LIST_TYPE = symbolFor("react.suspense_list"); - REACT_MEMO_TYPE = symbolFor("react.memo"); - REACT_LAZY_TYPE = symbolFor("react.lazy"); - REACT_BLOCK_TYPE = symbolFor("react.block"); - symbolFor("react.scope"); - REACT_DEBUG_TRACING_MODE_TYPE = symbolFor("react.debug_trace_mode"); - REACT_OFFSCREEN_TYPE = symbolFor("react.offscreen"); - REACT_LEGACY_HIDDEN_TYPE = symbolFor("react.legacy_hidden"); -} -var MAYBE_ITERATOR_SYMBOL = "function" === typeof Symbol && Symbol.iterator; + React.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED; +ReactSharedInternals.hasOwnProperty("ReactCurrentDispatcher") || + (ReactSharedInternals.ReactCurrentDispatcher = { current: null }); +ReactSharedInternals.hasOwnProperty("ReactCurrentBatchConfig") || + (ReactSharedInternals.ReactCurrentBatchConfig = { suspense: null }); +var hasSymbol = "function" === typeof Symbol && Symbol.for, + REACT_ELEMENT_TYPE = hasSymbol ? Symbol.for("react.element") : 60103, + REACT_PORTAL_TYPE = hasSymbol ? Symbol.for("react.portal") : 60106, + REACT_FRAGMENT_TYPE = hasSymbol ? Symbol.for("react.fragment") : 60107, + REACT_STRICT_MODE_TYPE = hasSymbol ? Symbol.for("react.strict_mode") : 60108, + REACT_PROFILER_TYPE = hasSymbol ? Symbol.for("react.profiler") : 60114, + REACT_PROVIDER_TYPE = hasSymbol ? Symbol.for("react.provider") : 60109, + REACT_CONTEXT_TYPE = hasSymbol ? Symbol.for("react.context") : 60110, + REACT_CONCURRENT_MODE_TYPE = hasSymbol + ? Symbol.for("react.concurrent_mode") + : 60111, + REACT_FORWARD_REF_TYPE = hasSymbol ? Symbol.for("react.forward_ref") : 60112, + REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for("react.suspense") : 60113, + REACT_SUSPENSE_LIST_TYPE = hasSymbol + ? Symbol.for("react.suspense_list") + : 60120, + REACT_MEMO_TYPE = hasSymbol ? Symbol.for("react.memo") : 60115, + REACT_LAZY_TYPE = hasSymbol ? Symbol.for("react.lazy") : 60116, + REACT_BLOCK_TYPE = hasSymbol ? Symbol.for("react.block") : 60121, + MAYBE_ITERATOR_SYMBOL = "function" === typeof Symbol && Symbol.iterator; function getIteratorFn(maybeIterable) { if (null === maybeIterable || "object" !== typeof maybeIterable) return null; maybeIterable = @@ -1170,6 +1108,27 @@ function getIteratorFn(maybeIterable) { maybeIterable["@@iterator"]; return "function" === typeof maybeIterable ? maybeIterable : null; } +function initializeLazyComponentType(lazyComponent) { + if (-1 === lazyComponent._status) { + var ctor = lazyComponent._result; + ctor || (ctor = lazyComponent._ctor); + ctor = ctor(); + lazyComponent._status = 0; + lazyComponent._result = ctor; + ctor.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)); + } + ); + } +} function getComponentName(type) { if (null == type) return null; if ("function" === typeof type) return type.displayName || type.name || null; @@ -1204,13 +1163,10 @@ function getComponentName(type) { case REACT_MEMO_TYPE: return getComponentName(type.type); case REACT_BLOCK_TYPE: - return getComponentName(type._render); + return getComponentName(type.render); case REACT_LAZY_TYPE: - innerType = type._payload; - type = type._init; - try { - return getComponentName(type(innerType)); - } catch (x) {} + if ((type = 1 === type._status ? type._result : null)) + return getComponentName(type); } return null; } @@ -1262,36 +1218,36 @@ function findCurrentFiberUsingSlowPath(fiber) { } if (a.return !== b.return) (a = parentA), (b = parentB); else { - for (var didFindChild = !1, child$1 = parentA.child; child$1; ) { - if (child$1 === a) { + for (var didFindChild = !1, _child = parentA.child; _child; ) { + if (_child === a) { didFindChild = !0; a = parentA; b = parentB; break; } - if (child$1 === b) { + if (_child === b) { didFindChild = !0; b = parentA; a = parentB; break; } - child$1 = child$1.sibling; + _child = _child.sibling; } if (!didFindChild) { - for (child$1 = parentB.child; child$1; ) { - if (child$1 === a) { + for (_child = parentB.child; _child; ) { + if (_child === a) { didFindChild = !0; a = parentB; b = parentA; break; } - if (child$1 === b) { + if (_child === b) { didFindChild = !0; b = parentB; a = parentA; break; } - child$1 = child$1.sibling; + _child = _child.sibling; } if (!didFindChild) throw Error( @@ -1326,18 +1282,6 @@ function findCurrentHostFiber(parent) { } return null; } -function doesFiberContain(parentFiber, childFiber) { - for ( - var parentFiberAlternate = parentFiber.alternate; - null !== childFiber; - - ) { - if (childFiber === parentFiber || childFiber === parentFiberAlternate) - return !0; - childFiber = childFiber.return; - } - return !1; -} var emptyObject = {}, removedKeys = null, removedKeyCount = 0, @@ -1542,19 +1486,19 @@ function diffProperties(updatePayload, prevProps, nextProps, validAttributes) { ), (removedKeys = null)); } - for (var propKey$3 in prevProps) - void 0 === nextProps[propKey$3] && - (!(attributeConfig = validAttributes[propKey$3]) || - (updatePayload && void 0 !== updatePayload[propKey$3]) || - ((prevProp = prevProps[propKey$3]), + for (var _propKey in prevProps) + void 0 === nextProps[_propKey] && + (!(attributeConfig = validAttributes[_propKey]) || + (updatePayload && void 0 !== updatePayload[_propKey]) || + ((prevProp = prevProps[_propKey]), void 0 !== prevProp && ("object" !== typeof attributeConfig || "function" === typeof attributeConfig.diff || "function" === typeof attributeConfig.process - ? (((updatePayload || (updatePayload = {}))[propKey$3] = null), + ? (((updatePayload || (updatePayload = {}))[_propKey] = null), removedKeys || (removedKeys = {}), - removedKeys[propKey$3] || - ((removedKeys[propKey$3] = !0), removedKeyCount++)) + removedKeys[_propKey] || + ((removedKeys[_propKey] = !0), removedKeyCount++)) : (updatePayload = clearNestedProperty( updatePayload, prevProp, @@ -1663,22 +1607,9 @@ function finalizeInitialChildren(parentInstance) { return !1; } var scheduleTimeout = setTimeout, - cancelTimeout = clearTimeout; -function describeComponentFrame(name, source, ownerName) { - source = ""; - ownerName && (source = " (created by " + ownerName + ")"); - return "\n in " + (name || "Unknown") + source; -} -function describeFunctionComponentFrame(fn, source) { - return fn - ? describeComponentFrame(fn.displayName || fn.name || null, source, null) - : ""; -} -var valueStack = [], + cancelTimeout = clearTimeout, + valueStack = [], index = -1; -function createCursor(defaultValue) { - return { current: defaultValue }; -} function pop(cursor) { 0 > index || ((cursor.current = valueStack[index]), (valueStack[index] = null), index--); @@ -1689,8 +1620,8 @@ function push(cursor, value) { cursor.current = value; } var emptyContextObject = {}, - contextStackCursor = createCursor(emptyContextObject), - didPerformWorkStackCursor = createCursor(!1), + contextStackCursor = { current: emptyContextObject }, + didPerformWorkStackCursor = { current: !1 }, previousContext = emptyContextObject; function getMaskedContext(workInProgress, unmaskedContext) { var contextTypes = workInProgress.type.contextTypes; @@ -1770,228 +1701,12 @@ function invalidateContextProvider(workInProgress, type, didChange) { : pop(didPerformWorkStackCursor); push(didPerformWorkStackCursor, didChange); } -var rendererID = null, - injectedHook = null, - isDevToolsPresent = "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__, - Scheduler_now = Scheduler.unstable_now; -if ( - null == tracing.__interactionsRef || - null == tracing.__interactionsRef.current -) - throw Error( - "It is not supported to run the profiling version of a renderer (for example, `react-dom/profiling`) without also replacing the `scheduler/tracing` module with `scheduler/tracing-profiling`. Your bundler might have a setting for aliasing both modules. Learn more at http://fb.me/react-profiling" - ); -Scheduler_now(); -var return_highestLanePriority = 10; -function getHighestPriorityLanes(lanes) { - if (0 !== (1 & lanes)) return (return_highestLanePriority = 17), 1; - if (0 !== (2 & lanes)) return (return_highestLanePriority = 16), 2; - if (0 !== (4 & lanes)) return (return_highestLanePriority = 15), 4; - var inputDiscreteLanes = 24 & lanes; - if (0 !== inputDiscreteLanes) - return (return_highestLanePriority = 14), inputDiscreteLanes; - if (0 !== (lanes & 32)) return (return_highestLanePriority = 13), 32; - inputDiscreteLanes = 192 & lanes; - if (0 !== inputDiscreteLanes) - return (return_highestLanePriority = 12), inputDiscreteLanes; - if (0 !== (lanes & 256)) return (return_highestLanePriority = 11), 256; - inputDiscreteLanes = 3584 & lanes; - if (0 !== inputDiscreteLanes) - return (return_highestLanePriority = 10), inputDiscreteLanes; - if (0 !== (lanes & 4096)) return (return_highestLanePriority = 9), 4096; - inputDiscreteLanes = 122880 & lanes; - if (0 !== inputDiscreteLanes) - return (return_highestLanePriority = 8), inputDiscreteLanes; - if (0 !== (lanes & 131072)) return (return_highestLanePriority = 7), 131072; - inputDiscreteLanes = 3932160 & lanes; - if (0 !== inputDiscreteLanes) - return (return_highestLanePriority = 6), inputDiscreteLanes; - inputDiscreteLanes = 62914560 & lanes; - if (0 !== inputDiscreteLanes) - return (return_highestLanePriority = 5), inputDiscreteLanes; - if (lanes & 67108864) return (return_highestLanePriority = 4), 67108864; - if (0 !== (lanes & 134217728)) - return (return_highestLanePriority = 3), 134217728; - inputDiscreteLanes = 805306368 & lanes; - if (0 !== inputDiscreteLanes) - return (return_highestLanePriority = 2), inputDiscreteLanes; - if (0 !== (1073741824 & lanes)) - return (return_highestLanePriority = 1), 1073741824; - return_highestLanePriority = 10; - return lanes; -} -function schedulerPriorityToLanePriority(schedulerPriorityLevel) { - switch (schedulerPriorityLevel) { - case 99: - return 17; - case 98: - return 12; - case 97: - case 96: - return 10; - case 95: - return 2; - default: - return 0; - } -} -function lanePriorityToSchedulerPriority(lanePriority) { - switch (lanePriority) { - case 17: - case 16: - return 99; - case 15: - case 14: - case 13: - case 12: - return 98; - case 11: - case 10: - case 9: - case 8: - case 7: - case 6: - case 4: - case 5: - return 97; - case 3: - case 2: - case 1: - return 95; - case 0: - return 90; - default: - throw Error( - "Invalid update priority: " + lanePriority + ". This is a bug in React." - ); - } -} -function getNextLanes(root, wipLanes) { - var pendingLanes = root.pendingLanes; - if (0 === pendingLanes) return (return_highestLanePriority = 0); - var nextLanes = 0, - nextLanePriority = 0, - expiredLanes = root.expiredLanes, - suspendedLanes = root.suspendedLanes, - pingedLanes = root.pingedLanes; - if (0 !== expiredLanes) - (nextLanes = expiredLanes), - (nextLanePriority = return_highestLanePriority = 17); - else if (((expiredLanes = pendingLanes & 134217727), 0 !== expiredLanes)) { - var nonIdleUnblockedLanes = expiredLanes & ~suspendedLanes; - 0 !== nonIdleUnblockedLanes - ? ((nextLanes = getHighestPriorityLanes(nonIdleUnblockedLanes)), - (nextLanePriority = return_highestLanePriority)) - : ((pingedLanes &= expiredLanes), - 0 !== pingedLanes && - ((nextLanes = getHighestPriorityLanes(pingedLanes)), - (nextLanePriority = return_highestLanePriority))); - } else - (expiredLanes = pendingLanes & ~suspendedLanes), - 0 !== expiredLanes - ? ((nextLanes = getHighestPriorityLanes(expiredLanes)), - (nextLanePriority = return_highestLanePriority)) - : 0 !== pingedLanes && - ((nextLanes = getHighestPriorityLanes(pingedLanes)), - (nextLanePriority = return_highestLanePriority)); - if (0 === nextLanes) return 0; - nextLanes = 31 - clz32(nextLanes); - nextLanes = pendingLanes & (((0 > nextLanes ? 0 : 1 << nextLanes) << 1) - 1); - if ( - 0 !== wipLanes && - wipLanes !== nextLanes && - 0 === (wipLanes & suspendedLanes) - ) { - getHighestPriorityLanes(wipLanes); - if (nextLanePriority <= return_highestLanePriority) return wipLanes; - return_highestLanePriority = nextLanePriority; - } - wipLanes = root.entangledLanes; - if (0 !== wipLanes) - for (root = root.entanglements, wipLanes &= nextLanes; 0 < wipLanes; ) - (pendingLanes = 31 - clz32(wipLanes)), - (nextLanePriority = 1 << pendingLanes), - (nextLanes |= root[pendingLanes]), - (wipLanes &= ~nextLanePriority); - return nextLanes; -} -function getMostRecentEventTime(root, lanes) { - root = root.eventTimes; - for (var mostRecentEventTime = -1; 0 < lanes; ) { - var index$6 = 31 - clz32(lanes), - lane = 1 << index$6; - index$6 = root[index$6]; - index$6 > mostRecentEventTime && (mostRecentEventTime = index$6); - lanes &= ~lane; - } - return mostRecentEventTime; -} -function getLanesToRetrySynchronouslyOnError(root) { - root = root.pendingLanes & -1073741825; - return 0 !== root ? root : root & 1073741824 ? 1073741824 : 0; -} -function findUpdateLane(lanePriority, wipLanes) { - switch (lanePriority) { - case 17: - return 1; - case 16: - return 2; - case 14: - return ( - (lanePriority = getHighestPriorityLane(24 & ~wipLanes)), - 0 === lanePriority ? findUpdateLane(12, wipLanes) : lanePriority - ); - case 12: - return ( - (lanePriority = getHighestPriorityLane(192 & ~wipLanes)), - 0 === lanePriority ? findUpdateLane(10, wipLanes) : lanePriority - ); - case 10: - return ( - (lanePriority = getHighestPriorityLane(3584 & ~wipLanes)), - 0 === lanePriority && - ((lanePriority = getHighestPriorityLane(4055040 & ~wipLanes)), - 0 === lanePriority && (lanePriority = 512)), - lanePriority - ); - case 2: - return ( - (wipLanes = getHighestPriorityLane(805306368 & ~wipLanes)), - 0 === wipLanes && (wipLanes = 268435456), - wipLanes - ); - } - throw Error( - "Invalid update priority: " + lanePriority + ". This is a bug in React." - ); -} -function getHighestPriorityLane(lanes) { - return lanes & -lanes; -} -function pickArbitraryLane(lanes) { - return lanes & -lanes; -} -function markRootUpdated(root, updateLane, eventTime) { - root.pendingLanes |= updateLane; - var higherPriorityLanes = updateLane - 1; - root.suspendedLanes &= higherPriorityLanes; - root.pingedLanes &= higherPriorityLanes; - root = root.eventTimes; - updateLane = 31 - clz32(updateLane); - root[updateLane] = eventTime; -} -var clz32 = Math.clz32 ? Math.clz32 : clz32Fallback, - log = Math.log, - LN2 = Math.LN2; -function clz32Fallback(lanes) { - return 0 === lanes ? 32 : (31 - ((log(lanes) / LN2) | 0)) | 0; -} var Scheduler_runWithPriority = Scheduler.unstable_runWithPriority, Scheduler_scheduleCallback = Scheduler.unstable_scheduleCallback, Scheduler_cancelCallback = Scheduler.unstable_cancelCallback, Scheduler_shouldYield = Scheduler.unstable_shouldYield, Scheduler_requestPaint = Scheduler.unstable_requestPaint, - Scheduler_now$1 = Scheduler.unstable_now, + Scheduler_now = Scheduler.unstable_now, Scheduler_getCurrentPriorityLevel = Scheduler.unstable_getCurrentPriorityLevel, Scheduler_ImmediatePriority = Scheduler.unstable_ImmediatePriority, @@ -2012,12 +1727,12 @@ var fakeCallbackNode = {}, syncQueue = null, immediateQueueCallbackNode = null, isFlushingSyncQueue = !1, - initialTimeMs$1 = Scheduler_now$1(), + initialTimeMs = Scheduler_now(), now = - 1e4 > initialTimeMs$1 - ? Scheduler_now$1 + 1e4 > initialTimeMs + ? Scheduler_now : function() { - return Scheduler_now$1() - initialTimeMs$1; + return Scheduler_now() - initialTimeMs; }; function getCurrentPriorityLevel() { switch (Scheduler_getCurrentPriorityLevel()) { @@ -2059,6 +1774,16 @@ function scheduleCallback(reactPriorityLevel, callback, options) { reactPriorityLevel = reactPriorityToSchedulerPriority(reactPriorityLevel); return Scheduler_scheduleCallback(reactPriorityLevel, callback, options); } +function scheduleSyncCallback(callback) { + null === syncQueue + ? ((syncQueue = [callback]), + (immediateQueueCallbackNode = Scheduler_scheduleCallback( + Scheduler_ImmediatePriority, + flushSyncCallbackQueueImpl + ))) + : syncQueue.push(callback); + return fakeCallbackNode; +} function flushSyncCallbackQueue() { if (null !== immediateQueueCallbackNode) { var node = immediateQueueCallbackNode; @@ -2093,41 +1818,18 @@ function flushSyncCallbackQueueImpl() { } } } -function describeFiber(fiber) { - switch (fiber.tag) { - case 5: - return describeComponentFrame(fiber.type, null, null); - case 16: - return describeComponentFrame("Lazy", null, null); - case 13: - return describeComponentFrame("Suspense", null, null); - case 19: - return describeComponentFrame("SuspenseList", null, null); - case 0: - case 2: - case 15: - return describeFunctionComponentFrame(fiber.type, null); - case 11: - return describeFunctionComponentFrame(fiber.type.render, null); - case 22: - return describeFunctionComponentFrame(fiber.type._render, null); - case 1: - return (fiber = describeFunctionComponentFrame(fiber.type, null)), fiber; - default: - return ""; - } -} -function getStackByFiberInDevAndProd(workInProgress) { - try { - var info = ""; - do - (info += describeFiber(workInProgress)), - (workInProgress = workInProgress.return); - while (workInProgress); - return info; - } catch (x) { - return "\nError generating stack: " + x.message + "\n" + x.stack; - } +function inferPriorityFromExpirationTime(currentTime, expirationTime) { + if (1073741823 === expirationTime) return 99; + if (1 === expirationTime || 2 === expirationTime) return 95; + currentTime = + 10 * (1073741821 - expirationTime) - 10 * (1073741821 - currentTime); + return 0 >= currentTime + ? 99 + : 250 >= currentTime + ? 98 + : 5250 >= currentTime + ? 97 + : 95; } function is(x, y) { return (x === y && (0 !== x || 1 / x === 1 / y)) || (x !== x && y !== y); @@ -2154,6 +1856,43 @@ function shallowEqual(objA, objB) { return !1; return !0; } +var BEFORE_SLASH_RE = /^(.*)[\\\/]/; +function getStackByFiberInDevAndProd(workInProgress) { + var info = ""; + do { + a: switch (workInProgress.tag) { + case 3: + case 4: + case 6: + case 7: + case 10: + case 9: + var JSCompiler_inline_result = ""; + break a; + default: + var owner = workInProgress._debugOwner, + source = workInProgress._debugSource, + name = getComponentName(workInProgress.type); + JSCompiler_inline_result = null; + owner && (JSCompiler_inline_result = getComponentName(owner.type)); + owner = name; + name = ""; + source + ? (name = + " (at " + + source.fileName.replace(BEFORE_SLASH_RE, "") + + ":" + + source.lineNumber + + ")") + : JSCompiler_inline_result && + (name = " (created by " + JSCompiler_inline_result + ")"); + JSCompiler_inline_result = "\n in " + (owner || "Unknown") + name; + } + info += JSCompiler_inline_result; + workInProgress = workInProgress.return; + } while (workInProgress); + return info; +} function resolveDefaultProps(Component, baseProps) { if (Component && Component.defaultProps) { baseProps = Object.assign({}, baseProps); @@ -2161,11 +1900,10 @@ function resolveDefaultProps(Component, baseProps) { for (var propName in Component) void 0 === baseProps[propName] && (baseProps[propName] = Component[propName]); - return baseProps; } return baseProps; } -var valueCursor = createCursor(null), +var valueCursor = { current: null }, currentlyRenderingFiber = null, lastContextDependency = null, lastContextWithAllBitsObserved = null; @@ -2177,29 +1915,31 @@ function popProvider(providerFiber) { pop(valueCursor); providerFiber.type._context._currentValue = currentValue; } -function scheduleWorkOnParentPath(parent, renderLanes) { +function scheduleWorkOnParentPath(parent, renderExpirationTime) { for (; null !== parent; ) { var alternate = parent.alternate; - if ((parent.childLanes & renderLanes) === renderLanes) - if ( - null === alternate || - (alternate.childLanes & renderLanes) === renderLanes - ) - break; - else alternate.childLanes |= renderLanes; - else - (parent.childLanes |= renderLanes), - null !== alternate && (alternate.childLanes |= renderLanes); + if (parent.childExpirationTime < renderExpirationTime) + (parent.childExpirationTime = renderExpirationTime), + null !== alternate && + alternate.childExpirationTime < renderExpirationTime && + (alternate.childExpirationTime = renderExpirationTime); + else if ( + null !== alternate && + alternate.childExpirationTime < renderExpirationTime + ) + alternate.childExpirationTime = renderExpirationTime; + else break; parent = parent.return; } } -function prepareToReadContext(workInProgress, renderLanes) { +function prepareToReadContext(workInProgress, renderExpirationTime) { currentlyRenderingFiber = workInProgress; lastContextWithAllBitsObserved = lastContextDependency = null; workInProgress = workInProgress.dependencies; null !== workInProgress && null !== workInProgress.firstContext && - (0 !== (workInProgress.lanes & renderLanes) && (didReceiveUpdate = !0), + (workInProgress.expirationTime >= renderExpirationTime && + (didReceiveUpdate = !0), (workInProgress.firstContext = null)); } function readContext(context, observedBits) { @@ -2218,7 +1958,7 @@ function readContext(context, observedBits) { ); lastContextDependency = observedBits; currentlyRenderingFiber.dependencies = { - lanes: 0, + expirationTime: 0, firstContext: observedBits, responders: null }; @@ -2230,8 +1970,7 @@ var hasForceUpdate = !1; function initializeUpdateQueue(fiber) { fiber.updateQueue = { baseState: fiber.memoizedState, - firstBaseUpdate: null, - lastBaseUpdate: null, + baseQueue: null, shared: { pending: null }, effects: null }; @@ -2241,22 +1980,21 @@ function cloneUpdateQueue(current, workInProgress) { workInProgress.updateQueue === current && (workInProgress.updateQueue = { baseState: current.baseState, - firstBaseUpdate: current.firstBaseUpdate, - lastBaseUpdate: current.lastBaseUpdate, + baseQueue: current.baseQueue, shared: current.shared, effects: current.effects }); } -function createUpdate(eventTime, lane, suspenseConfig) { - return { - eventTime: eventTime, - lane: lane, +function createUpdate(expirationTime, suspenseConfig) { + expirationTime = { + expirationTime: expirationTime, suspenseConfig: suspenseConfig, tag: 0, payload: null, callback: null, next: null }; + return (expirationTime.next = expirationTime); } function enqueueUpdate(fiber, update) { fiber = fiber.updateQueue; @@ -2269,185 +2007,132 @@ function enqueueUpdate(fiber, update) { fiber.pending = update; } } -function enqueueCapturedUpdate(workInProgress, capturedUpdate) { - var queue = workInProgress.updateQueue, - current = workInProgress.alternate; - if ( - null !== current && - ((current = current.updateQueue), queue === current) - ) { - var newFirst = null, - newLast = null; - queue = queue.firstBaseUpdate; - if (null !== queue) { - do { - var clone = { - eventTime: queue.eventTime, - lane: queue.lane, - suspenseConfig: queue.suspenseConfig, - tag: queue.tag, - payload: queue.payload, - callback: queue.callback, - next: null - }; - null === newLast - ? (newFirst = newLast = clone) - : (newLast = newLast.next = clone); - queue = queue.next; - } while (null !== queue); - null === newLast - ? (newFirst = newLast = capturedUpdate) - : (newLast = newLast.next = capturedUpdate); - } else newFirst = newLast = capturedUpdate; - queue = { - baseState: current.baseState, - firstBaseUpdate: newFirst, - lastBaseUpdate: newLast, - shared: current.shared, - effects: current.effects - }; - workInProgress.updateQueue = queue; - return; - } - workInProgress = queue.lastBaseUpdate; - null === workInProgress - ? (queue.firstBaseUpdate = capturedUpdate) - : (workInProgress.next = capturedUpdate); - queue.lastBaseUpdate = capturedUpdate; +function enqueueCapturedUpdate(workInProgress, update) { + var current = workInProgress.alternate; + null !== current && cloneUpdateQueue(current, workInProgress); + workInProgress = workInProgress.updateQueue; + current = workInProgress.baseQueue; + null === current + ? ((workInProgress.baseQueue = update.next = update), + (update.next = update)) + : ((update.next = current.next), (current.next = update)); } function processUpdateQueue( workInProgress$jscomp$0, props, instance, - renderLanes + renderExpirationTime ) { var queue = workInProgress$jscomp$0.updateQueue; hasForceUpdate = !1; - var firstBaseUpdate = queue.firstBaseUpdate, - lastBaseUpdate = queue.lastBaseUpdate, + var baseQueue = queue.baseQueue, pendingQueue = queue.shared.pending; if (null !== pendingQueue) { - queue.shared.pending = null; - var lastPendingUpdate = pendingQueue, - firstPendingUpdate = lastPendingUpdate.next; - lastPendingUpdate.next = null; - null === lastBaseUpdate - ? (firstBaseUpdate = firstPendingUpdate) - : (lastBaseUpdate.next = firstPendingUpdate); - lastBaseUpdate = lastPendingUpdate; - var current = workInProgress$jscomp$0.alternate; - if (null !== current) { - current = current.updateQueue; - var currentLastBaseUpdate = current.lastBaseUpdate; - currentLastBaseUpdate !== lastBaseUpdate && - (null === currentLastBaseUpdate - ? (current.firstBaseUpdate = firstPendingUpdate) - : (currentLastBaseUpdate.next = firstPendingUpdate), - (current.lastBaseUpdate = lastPendingUpdate)); + if (null !== baseQueue) { + var baseFirst = baseQueue.next; + baseQueue.next = pendingQueue.next; + pendingQueue.next = baseFirst; } + baseQueue = pendingQueue; + queue.shared.pending = null; + baseFirst = workInProgress$jscomp$0.alternate; + null !== baseFirst && + ((baseFirst = baseFirst.updateQueue), + null !== baseFirst && (baseFirst.baseQueue = pendingQueue)); } - if (null !== firstBaseUpdate) { - currentLastBaseUpdate = queue.baseState; - lastBaseUpdate = 0; - current = firstPendingUpdate = lastPendingUpdate = null; - do { - pendingQueue = firstBaseUpdate.lane; - var updateEventTime = firstBaseUpdate.eventTime; - if ((renderLanes & pendingQueue) === pendingQueue) { - null !== current && - (current = current.next = { - eventTime: updateEventTime, - lane: 0, - suspenseConfig: firstBaseUpdate.suspenseConfig, - tag: firstBaseUpdate.tag, - payload: firstBaseUpdate.payload, - callback: firstBaseUpdate.callback, + if (null !== baseQueue) { + baseFirst = baseQueue.next; + var newState = queue.baseState, + newExpirationTime = 0, + newBaseState = null, + newBaseQueueFirst = null, + newBaseQueueLast = null; + if (null !== baseFirst) { + var update = baseFirst; + do { + pendingQueue = update.expirationTime; + if (pendingQueue < renderExpirationTime) { + var clone = { + expirationTime: update.expirationTime, + suspenseConfig: update.suspenseConfig, + tag: update.tag, + payload: update.payload, + callback: update.callback, next: null - }); - markRenderEventTimeAndConfig( - updateEventTime, - firstBaseUpdate.suspenseConfig - ); - a: { - var workInProgress = workInProgress$jscomp$0, - update = firstBaseUpdate; - pendingQueue = props; - updateEventTime = instance; - switch (update.tag) { - case 1: - workInProgress = update.payload; - if ("function" === typeof workInProgress) { - currentLastBaseUpdate = workInProgress.call( - updateEventTime, - currentLastBaseUpdate, - pendingQueue - ); + }; + null === newBaseQueueLast + ? ((newBaseQueueFirst = newBaseQueueLast = clone), + (newBaseState = newState)) + : (newBaseQueueLast = newBaseQueueLast.next = clone); + pendingQueue > newExpirationTime && + (newExpirationTime = pendingQueue); + } else { + null !== newBaseQueueLast && + (newBaseQueueLast = newBaseQueueLast.next = { + expirationTime: 1073741823, + suspenseConfig: update.suspenseConfig, + tag: update.tag, + payload: update.payload, + callback: update.callback, + next: null + }); + markRenderEventTimeAndConfig(pendingQueue, update.suspenseConfig); + a: { + var workInProgress = workInProgress$jscomp$0, + update$jscomp$0 = update; + pendingQueue = props; + clone = instance; + switch (update$jscomp$0.tag) { + case 1: + workInProgress = update$jscomp$0.payload; + if ("function" === typeof workInProgress) { + newState = workInProgress.call(clone, newState, pendingQueue); + break a; + } + newState = workInProgress; break a; - } - currentLastBaseUpdate = workInProgress; - break a; - case 3: - workInProgress.effectTag = - (workInProgress.effectTag & -4097) | 64; - case 0: - workInProgress = update.payload; - pendingQueue = - "function" === typeof workInProgress - ? workInProgress.call( - updateEventTime, - currentLastBaseUpdate, - pendingQueue - ) - : workInProgress; - if (null === pendingQueue || void 0 === pendingQueue) break a; - currentLastBaseUpdate = Object.assign( - {}, - currentLastBaseUpdate, - pendingQueue - ); - break a; - case 2: - hasForceUpdate = !0; + case 3: + workInProgress.effectTag = + (workInProgress.effectTag & -4097) | 64; + case 0: + workInProgress = update$jscomp$0.payload; + pendingQueue = + "function" === typeof workInProgress + ? workInProgress.call(clone, newState, pendingQueue) + : workInProgress; + if (null === pendingQueue || void 0 === pendingQueue) break a; + newState = Object.assign({}, newState, pendingQueue); + break a; + case 2: + hasForceUpdate = !0; + } } + null !== update.callback && + ((workInProgress$jscomp$0.effectTag |= 32), + (pendingQueue = queue.effects), + null === pendingQueue + ? (queue.effects = [update]) + : pendingQueue.push(update)); } - null !== firstBaseUpdate.callback && - ((workInProgress$jscomp$0.effectTag |= 32), - (pendingQueue = queue.effects), - null === pendingQueue - ? (queue.effects = [firstBaseUpdate]) - : pendingQueue.push(firstBaseUpdate)); - } else - (updateEventTime = { - eventTime: updateEventTime, - lane: pendingQueue, - suspenseConfig: firstBaseUpdate.suspenseConfig, - tag: firstBaseUpdate.tag, - payload: firstBaseUpdate.payload, - callback: firstBaseUpdate.callback, - next: null - }), - null === current - ? ((firstPendingUpdate = current = updateEventTime), - (lastPendingUpdate = currentLastBaseUpdate)) - : (current = current.next = updateEventTime), - (lastBaseUpdate |= pendingQueue); - firstBaseUpdate = firstBaseUpdate.next; - if (null === firstBaseUpdate) - if (((pendingQueue = queue.shared.pending), null === pendingQueue)) - break; - else - (firstBaseUpdate = pendingQueue.next), - (pendingQueue.next = null), - (queue.lastBaseUpdate = pendingQueue), - (queue.shared.pending = null); - } while (1); - null === current && (lastPendingUpdate = currentLastBaseUpdate); - queue.baseState = lastPendingUpdate; - queue.firstBaseUpdate = firstPendingUpdate; - queue.lastBaseUpdate = current; - workInProgressRootSkippedLanes |= lastBaseUpdate; - workInProgress$jscomp$0.lanes = lastBaseUpdate; - workInProgress$jscomp$0.memoizedState = currentLastBaseUpdate; + update = update.next; + if (null === update || update === baseFirst) + if (((pendingQueue = queue.shared.pending), null === pendingQueue)) + break; + else + (update = baseQueue.next = pendingQueue.next), + (pendingQueue.next = baseFirst), + (queue.baseQueue = baseQueue = pendingQueue), + (queue.shared.pending = null); + } while (1); + } + null === newBaseQueueLast + ? (newBaseState = newState) + : (newBaseQueueLast.next = newBaseQueueFirst); + queue.baseState = newBaseState; + queue.baseQueue = newBaseQueueLast; + markUnprocessedUpdateTime(newExpirationTime); + workInProgress$jscomp$0.expirationTime = newExpirationTime; + workInProgress$jscomp$0.memoizedState = newState; } } function commitUpdateQueue(finishedWork, finishedQueue, instance) { @@ -2487,54 +2172,54 @@ function applyDerivedStateFromProps( ? ctor : Object.assign({}, ctor, getDerivedStateFromProps); workInProgress.memoizedState = getDerivedStateFromProps; - 0 === workInProgress.lanes && + 0 === workInProgress.expirationTime && (workInProgress.updateQueue.baseState = getDerivedStateFromProps); } var classComponentUpdater = { isMounted: function(component) { - return (component = component._reactInternals) + return (component = component._reactInternalFiber) ? getNearestMountedFiber(component) === component : !1; }, enqueueSetState: function(inst, payload, callback) { - inst = inst._reactInternals; - var eventTime = requestEventTime(), - suspenseConfig = ReactCurrentBatchConfig.suspense, - lane = requestUpdateLane(inst, suspenseConfig); - suspenseConfig = createUpdate(eventTime, lane, suspenseConfig); + inst = inst._reactInternalFiber; + var currentTime = requestCurrentTimeForUpdate(), + suspenseConfig = ReactCurrentBatchConfig.suspense; + currentTime = computeExpirationForFiber(currentTime, inst, suspenseConfig); + suspenseConfig = createUpdate(currentTime, suspenseConfig); suspenseConfig.payload = payload; void 0 !== callback && null !== callback && (suspenseConfig.callback = callback); enqueueUpdate(inst, suspenseConfig); - scheduleUpdateOnFiber(inst, lane, eventTime); + scheduleWork(inst, currentTime); }, enqueueReplaceState: function(inst, payload, callback) { - inst = inst._reactInternals; - var eventTime = requestEventTime(), - suspenseConfig = ReactCurrentBatchConfig.suspense, - lane = requestUpdateLane(inst, suspenseConfig); - suspenseConfig = createUpdate(eventTime, lane, suspenseConfig); + inst = inst._reactInternalFiber; + var currentTime = requestCurrentTimeForUpdate(), + suspenseConfig = ReactCurrentBatchConfig.suspense; + currentTime = computeExpirationForFiber(currentTime, inst, suspenseConfig); + suspenseConfig = createUpdate(currentTime, suspenseConfig); suspenseConfig.tag = 1; suspenseConfig.payload = payload; void 0 !== callback && null !== callback && (suspenseConfig.callback = callback); enqueueUpdate(inst, suspenseConfig); - scheduleUpdateOnFiber(inst, lane, eventTime); + scheduleWork(inst, currentTime); }, enqueueForceUpdate: function(inst, callback) { - inst = inst._reactInternals; - var eventTime = requestEventTime(), - suspenseConfig = ReactCurrentBatchConfig.suspense, - lane = requestUpdateLane(inst, suspenseConfig); - suspenseConfig = createUpdate(eventTime, lane, suspenseConfig); + inst = inst._reactInternalFiber; + var currentTime = requestCurrentTimeForUpdate(), + suspenseConfig = ReactCurrentBatchConfig.suspense; + currentTime = computeExpirationForFiber(currentTime, inst, suspenseConfig); + suspenseConfig = createUpdate(currentTime, suspenseConfig); suspenseConfig.tag = 2; void 0 !== callback && null !== callback && (suspenseConfig.callback = callback); enqueueUpdate(inst, suspenseConfig); - scheduleUpdateOnFiber(inst, lane, eventTime); + scheduleWork(inst, currentTime); } }; function checkShouldComponentUpdate( @@ -2572,7 +2257,7 @@ function constructClassInstance(workInProgress, ctor, props) { null !== ctor.state && void 0 !== ctor.state ? ctor.state : null; ctor.updater = classComponentUpdater; workInProgress.stateNode = ctor; - ctor._reactInternals = workInProgress; + ctor._reactInternalFiber = workInProgress; isLegacyContextConsumer && ((workInProgress = workInProgress.stateNode), (workInProgress.__reactInternalMemoizedUnmaskedChildContext = unmaskedContext), @@ -2593,7 +2278,12 @@ function callComponentWillReceiveProps( instance.state !== workInProgress && classComponentUpdater.enqueueReplaceState(instance, instance.state, null); } -function mountClassInstance(workInProgress, ctor, newProps, renderLanes) { +function mountClassInstance( + workInProgress, + ctor, + newProps, + renderExpirationTime +) { var instance = workInProgress.stateNode; instance.props = newProps; instance.state = workInProgress.memoizedState; @@ -2606,7 +2296,7 @@ function mountClassInstance(workInProgress, ctor, newProps, renderLanes) { ? previousContext : contextStackCursor.current), (instance.context = getMaskedContext(workInProgress, contextType))); - processUpdateQueue(workInProgress, newProps, instance, renderLanes); + processUpdateQueue(workInProgress, newProps, instance, renderExpirationTime); instance.state = workInProgress.memoizedState; contextType = ctor.getDerivedStateFromProps; "function" === typeof contextType && @@ -2623,7 +2313,12 @@ function mountClassInstance(workInProgress, ctor, newProps, renderLanes) { instance.UNSAFE_componentWillMount(), ctor !== instance.state && classComponentUpdater.enqueueReplaceState(instance, instance.state, null), - processUpdateQueue(workInProgress, newProps, instance, renderLanes), + processUpdateQueue( + workInProgress, + newProps, + instance, + renderExpirationTime + ), (instance.state = workInProgress.memoizedState)); "function" === typeof instance.componentDidMount && (workInProgress.effectTag |= 4); @@ -2687,7 +2382,7 @@ function throwOnInvalidObjectType(returnFiber, newChild) { ("[object Object]" === Object.prototype.toString.call(newChild) ? "object with keys {" + Object.keys(newChild).join(", ") + "}" : newChild) + - "). If you meant to render a collection of children, use an array instead." + ")." ); } function ChildReconciler(shouldTrackSideEffects) { @@ -2743,10 +2438,14 @@ function ChildReconciler(shouldTrackSideEffects) { (newFiber.effectTag = 2); return newFiber; } - function updateTextNode(returnFiber, current, textContent, lanes) { + function updateTextNode(returnFiber, current, textContent, expirationTime) { if (null === current || 6 !== current.tag) return ( - (current = createFiberFromText(textContent, returnFiber.mode, lanes)), + (current = createFiberFromText( + textContent, + returnFiber.mode, + expirationTime + )), (current.return = returnFiber), current ); @@ -2754,27 +2453,27 @@ function ChildReconciler(shouldTrackSideEffects) { current.return = returnFiber; return current; } - function updateElement(returnFiber, current, element, lanes) { + function updateElement(returnFiber, current, element, expirationTime) { if (null !== current && current.elementType === element.type) return ( - (lanes = useFiber(current, element.props)), - (lanes.ref = coerceRef(returnFiber, current, element)), - (lanes.return = returnFiber), - lanes + (expirationTime = useFiber(current, element.props)), + (expirationTime.ref = coerceRef(returnFiber, current, element)), + (expirationTime.return = returnFiber), + expirationTime ); - lanes = createFiberFromTypeAndProps( + expirationTime = createFiberFromTypeAndProps( element.type, element.key, element.props, null, returnFiber.mode, - lanes + expirationTime ); - lanes.ref = coerceRef(returnFiber, current, element); - lanes.return = returnFiber; - return lanes; + expirationTime.ref = coerceRef(returnFiber, current, element); + expirationTime.return = returnFiber; + return expirationTime; } - function updatePortal(returnFiber, current, portal, lanes) { + function updatePortal(returnFiber, current, portal, expirationTime) { if ( null === current || 4 !== current.tag || @@ -2782,7 +2481,11 @@ function ChildReconciler(shouldTrackSideEffects) { current.stateNode.implementation !== portal.implementation ) return ( - (current = createFiberFromPortal(portal, returnFiber.mode, lanes)), + (current = createFiberFromPortal( + portal, + returnFiber.mode, + expirationTime + )), (current.return = returnFiber), current ); @@ -2790,13 +2493,13 @@ function ChildReconciler(shouldTrackSideEffects) { current.return = returnFiber; return current; } - function updateFragment(returnFiber, current, fragment, lanes, key) { + function updateFragment(returnFiber, current, fragment, expirationTime, key) { if (null === current || 7 !== current.tag) return ( (current = createFiberFromFragment( fragment, returnFiber.mode, - lanes, + expirationTime, key )), (current.return = returnFiber), @@ -2806,13 +2509,13 @@ function ChildReconciler(shouldTrackSideEffects) { current.return = returnFiber; return current; } - function createChild(returnFiber, newChild, lanes) { + function createChild(returnFiber, newChild, expirationTime) { if ("string" === typeof newChild || "number" === typeof newChild) return ( (newChild = createFiberFromText( "" + newChild, returnFiber.mode, - lanes + expirationTime )), (newChild.return = returnFiber), newChild @@ -2821,24 +2524,24 @@ function ChildReconciler(shouldTrackSideEffects) { switch (newChild.$$typeof) { case REACT_ELEMENT_TYPE: return ( - (lanes = createFiberFromTypeAndProps( + (expirationTime = createFiberFromTypeAndProps( newChild.type, newChild.key, newChild.props, null, returnFiber.mode, - lanes + expirationTime )), - (lanes.ref = coerceRef(returnFiber, null, newChild)), - (lanes.return = returnFiber), - lanes + (expirationTime.ref = coerceRef(returnFiber, null, newChild)), + (expirationTime.return = returnFiber), + expirationTime ); case REACT_PORTAL_TYPE: return ( (newChild = createFiberFromPortal( newChild, returnFiber.mode, - lanes + expirationTime )), (newChild.return = returnFiber), newChild @@ -2849,7 +2552,7 @@ function ChildReconciler(shouldTrackSideEffects) { (newChild = createFiberFromFragment( newChild, returnFiber.mode, - lanes, + expirationTime, null )), (newChild.return = returnFiber), @@ -2859,12 +2562,12 @@ function ChildReconciler(shouldTrackSideEffects) { } return null; } - function updateSlot(returnFiber, oldFiber, newChild, lanes) { + function updateSlot(returnFiber, oldFiber, newChild, expirationTime) { var key = null !== oldFiber ? oldFiber.key : null; if ("string" === typeof newChild || "number" === typeof newChild) return null !== key ? null - : updateTextNode(returnFiber, oldFiber, "" + newChild, lanes); + : updateTextNode(returnFiber, oldFiber, "" + newChild, expirationTime); if ("object" === typeof newChild && null !== newChild) { switch (newChild.$$typeof) { case REACT_ELEMENT_TYPE: @@ -2874,20 +2577,26 @@ function ChildReconciler(shouldTrackSideEffects) { returnFiber, oldFiber, newChild.props.children, - lanes, + expirationTime, key ) - : updateElement(returnFiber, oldFiber, newChild, lanes) + : updateElement(returnFiber, oldFiber, newChild, expirationTime) : null; case REACT_PORTAL_TYPE: return newChild.key === key - ? updatePortal(returnFiber, oldFiber, newChild, lanes) + ? updatePortal(returnFiber, oldFiber, newChild, expirationTime) : null; } if (isArray(newChild) || getIteratorFn(newChild)) return null !== key ? null - : updateFragment(returnFiber, oldFiber, newChild, lanes, null); + : updateFragment( + returnFiber, + oldFiber, + newChild, + expirationTime, + null + ); throwOnInvalidObjectType(returnFiber, newChild); } return null; @@ -2897,12 +2606,17 @@ function ChildReconciler(shouldTrackSideEffects) { returnFiber, newIdx, newChild, - lanes + expirationTime ) { if ("string" === typeof newChild || "number" === typeof newChild) return ( (existingChildren = existingChildren.get(newIdx) || null), - updateTextNode(returnFiber, existingChildren, "" + newChild, lanes) + updateTextNode( + returnFiber, + existingChildren, + "" + newChild, + expirationTime + ) ); if ("object" === typeof newChild && null !== newChild) { switch (newChild.$$typeof) { @@ -2917,10 +2631,15 @@ function ChildReconciler(shouldTrackSideEffects) { returnFiber, existingChildren, newChild.props.children, - lanes, + expirationTime, newChild.key ) - : updateElement(returnFiber, existingChildren, newChild, lanes) + : updateElement( + returnFiber, + existingChildren, + newChild, + expirationTime + ) ); case REACT_PORTAL_TYPE: return ( @@ -2928,13 +2647,24 @@ function ChildReconciler(shouldTrackSideEffects) { existingChildren.get( null === newChild.key ? newIdx : newChild.key ) || null), - updatePortal(returnFiber, existingChildren, newChild, lanes) + updatePortal( + returnFiber, + existingChildren, + newChild, + expirationTime + ) ); } if (isArray(newChild) || getIteratorFn(newChild)) return ( (existingChildren = existingChildren.get(newIdx) || null), - updateFragment(returnFiber, existingChildren, newChild, lanes, null) + updateFragment( + returnFiber, + existingChildren, + newChild, + expirationTime, + null + ) ); throwOnInvalidObjectType(returnFiber, newChild); } @@ -2944,7 +2674,7 @@ function ChildReconciler(shouldTrackSideEffects) { returnFiber, currentFirstChild, newChildren, - lanes + expirationTime ) { for ( var resultingFirstChild = null, @@ -2962,7 +2692,7 @@ function ChildReconciler(shouldTrackSideEffects) { returnFiber, oldFiber, newChildren[newIdx], - lanes + expirationTime ); if (null === newFiber) { null === oldFiber && (oldFiber = nextOldFiber); @@ -2985,7 +2715,11 @@ function ChildReconciler(shouldTrackSideEffects) { ); if (null === oldFiber) { for (; newIdx < newChildren.length; newIdx++) - (oldFiber = createChild(returnFiber, newChildren[newIdx], lanes)), + (oldFiber = createChild( + returnFiber, + newChildren[newIdx], + expirationTime + )), null !== oldFiber && ((currentFirstChild = placeChild( oldFiber, @@ -3008,7 +2742,7 @@ function ChildReconciler(shouldTrackSideEffects) { returnFiber, newIdx, newChildren[newIdx], - lanes + expirationTime )), null !== nextOldFiber && (shouldTrackSideEffects && @@ -3035,7 +2769,7 @@ function ChildReconciler(shouldTrackSideEffects) { returnFiber, currentFirstChild, newChildrenIterable, - lanes + expirationTime ) { var iteratorFn = getIteratorFn(newChildrenIterable); if ("function" !== typeof iteratorFn) @@ -3057,7 +2791,12 @@ function ChildReconciler(shouldTrackSideEffects) { oldFiber.index > newIdx ? ((nextOldFiber = oldFiber), (oldFiber = null)) : (nextOldFiber = oldFiber.sibling); - var newFiber = updateSlot(returnFiber, oldFiber, step.value, lanes); + var newFiber = updateSlot( + returnFiber, + oldFiber, + step.value, + expirationTime + ); if (null === newFiber) { null === oldFiber && (oldFiber = nextOldFiber); break; @@ -3077,7 +2816,7 @@ function ChildReconciler(shouldTrackSideEffects) { return deleteRemainingChildren(returnFiber, oldFiber), iteratorFn; if (null === oldFiber) { for (; !step.done; newIdx++, step = newChildrenIterable.next()) - (step = createChild(returnFiber, step.value, lanes)), + (step = createChild(returnFiber, step.value, expirationTime)), null !== step && ((currentFirstChild = placeChild(step, currentFirstChild, newIdx)), null === previousNewFiber @@ -3091,7 +2830,13 @@ function ChildReconciler(shouldTrackSideEffects) { !step.done; newIdx++, step = newChildrenIterable.next() ) - (step = updateFromMap(oldFiber, returnFiber, newIdx, step.value, lanes)), + (step = updateFromMap( + oldFiber, + returnFiber, + newIdx, + step.value, + expirationTime + )), null !== step && (shouldTrackSideEffects && null !== step.alternate && @@ -3107,7 +2852,7 @@ function ChildReconciler(shouldTrackSideEffects) { }); return iteratorFn; } - return function(returnFiber, currentFirstChild, newChild, lanes) { + return function(returnFiber, currentFirstChild, newChild, expirationTime) { var isUnkeyedTopLevelFragment = "object" === typeof newChild && null !== newChild && @@ -3173,26 +2918,26 @@ function ChildReconciler(shouldTrackSideEffects) { ? ((currentFirstChild = createFiberFromFragment( newChild.props.children, returnFiber.mode, - lanes, + expirationTime, newChild.key )), (currentFirstChild.return = returnFiber), (returnFiber = currentFirstChild)) - : ((lanes = createFiberFromTypeAndProps( + : ((expirationTime = createFiberFromTypeAndProps( newChild.type, newChild.key, newChild.props, null, returnFiber.mode, - lanes + expirationTime )), - (lanes.ref = coerceRef( + (expirationTime.ref = coerceRef( returnFiber, currentFirstChild, newChild )), - (lanes.return = returnFiber), - (returnFiber = lanes)); + (expirationTime.return = returnFiber), + (returnFiber = expirationTime)); } return placeSingleChild(returnFiber); case REACT_PORTAL_TYPE: @@ -3231,7 +2976,7 @@ function ChildReconciler(shouldTrackSideEffects) { currentFirstChild = createFiberFromPortal( newChild, returnFiber.mode, - lanes + expirationTime ); currentFirstChild.return = returnFiber; returnFiber = currentFirstChild; @@ -3250,7 +2995,7 @@ function ChildReconciler(shouldTrackSideEffects) { (currentFirstChild = createFiberFromText( newChild, returnFiber.mode, - lanes + expirationTime )), (currentFirstChild.return = returnFiber), (returnFiber = currentFirstChild)), @@ -3261,14 +3006,14 @@ function ChildReconciler(shouldTrackSideEffects) { returnFiber, currentFirstChild, newChild, - lanes + expirationTime ); if (getIteratorFn(newChild)) return reconcileChildrenIterator( returnFiber, currentFirstChild, newChild, - lanes + expirationTime ); isObject && throwOnInvalidObjectType(returnFiber, newChild); if ("undefined" === typeof newChild && !isUnkeyedTopLevelFragment) @@ -3287,9 +3032,9 @@ function ChildReconciler(shouldTrackSideEffects) { var reconcileChildFibers = ChildReconciler(!0), mountChildFibers = ChildReconciler(!1), NO_CONTEXT = {}, - contextStackCursor$1 = createCursor(NO_CONTEXT), - contextFiberStackCursor = createCursor(NO_CONTEXT), - rootInstanceStackCursor = createCursor(NO_CONTEXT); + contextStackCursor$1 = { current: NO_CONTEXT }, + contextFiberStackCursor = { current: NO_CONTEXT }, + rootInstanceStackCursor = { current: NO_CONTEXT }; function requiredContext(c) { if (c === NO_CONTEXT) throw Error( @@ -3312,26 +3057,26 @@ function popHostContainer() { function pushHostContext(fiber) { requiredContext(rootInstanceStackCursor.current); var context = requiredContext(contextStackCursor$1.current); - var JSCompiler_inline_result = fiber.type; - JSCompiler_inline_result = - "AndroidTextInput" === JSCompiler_inline_result || - "RCTMultilineTextInputView" === JSCompiler_inline_result || - "RCTSinglelineTextInputView" === JSCompiler_inline_result || - "RCTText" === JSCompiler_inline_result || - "RCTVirtualText" === JSCompiler_inline_result; - JSCompiler_inline_result = - context.isInAParentText !== JSCompiler_inline_result - ? { isInAParentText: JSCompiler_inline_result } + var nextContext = fiber.type; + nextContext = + "AndroidTextInput" === nextContext || + "RCTMultilineTextInputView" === nextContext || + "RCTSinglelineTextInputView" === nextContext || + "RCTText" === nextContext || + "RCTVirtualText" === nextContext; + nextContext = + context.isInAParentText !== nextContext + ? { isInAParentText: nextContext } : context; - context !== JSCompiler_inline_result && + context !== nextContext && (push(contextFiberStackCursor, fiber), - push(contextStackCursor$1, JSCompiler_inline_result)); + push(contextStackCursor$1, nextContext)); } function popHostContext(fiber) { contextFiberStackCursor.current === fiber && (pop(contextStackCursor$1), pop(contextFiberStackCursor)); } -var suspenseStackCursor = createCursor(0); +var suspenseStackCursor = { current: 0 }; function findFirstSuspended(row) { for (var node = row; null !== node; ) { if (13 === node.tag) { @@ -3358,20 +3103,13 @@ function findFirstSuspended(row) { function createDeprecatedResponderListener(responder, props) { return { responder: responder, props: props }; } -var workInProgressSources = []; -function resetWorkInProgressVersions() { - for (var i = 0; i < workInProgressSources.length; i++) - workInProgressSources[i]._workInProgressVersionPrimary = null; - workInProgressSources.length = 0; -} -var ReactCurrentDispatcher$1 = ReactSharedInternals.ReactCurrentDispatcher, +var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher, ReactCurrentBatchConfig$1 = ReactSharedInternals.ReactCurrentBatchConfig, - renderLanes = 0, + renderExpirationTime = 0, currentlyRenderingFiber$1 = null, currentHook = null, workInProgressHook = null, - didScheduleRenderPhaseUpdate = !1, - didScheduleRenderPhaseUpdateDuringThisPass = !1; + didScheduleRenderPhaseUpdate = !1; function throwInvalidHookError() { throw Error( "Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:\n1. You might have mismatching versions of React and the renderer (such as React DOM)\n2. You might be breaking the Rules of Hooks\n3. You might have more than one copy of React in the same app\nSee https://fb.me/react-invalid-hook-call for tips about how to debug and fix this problem." @@ -3389,36 +3127,36 @@ function renderWithHooks( Component, props, secondArg, - nextRenderLanes + nextRenderExpirationTime ) { - renderLanes = nextRenderLanes; + renderExpirationTime = nextRenderExpirationTime; currentlyRenderingFiber$1 = workInProgress; workInProgress.memoizedState = null; workInProgress.updateQueue = null; - workInProgress.lanes = 0; - ReactCurrentDispatcher$1.current = + workInProgress.expirationTime = 0; + ReactCurrentDispatcher.current = null === current || null === current.memoizedState ? HooksDispatcherOnMount : HooksDispatcherOnUpdate; current = Component(props, secondArg); - if (didScheduleRenderPhaseUpdateDuringThisPass) { - nextRenderLanes = 0; + if (workInProgress.expirationTime === renderExpirationTime) { + nextRenderExpirationTime = 0; do { - didScheduleRenderPhaseUpdateDuringThisPass = !1; - if (!(25 > nextRenderLanes)) + workInProgress.expirationTime = 0; + if (!(25 > nextRenderExpirationTime)) throw Error( "Too many re-renders. React limits the number of renders to prevent an infinite loop." ); - nextRenderLanes += 1; + nextRenderExpirationTime += 1; workInProgressHook = currentHook = null; workInProgress.updateQueue = null; - ReactCurrentDispatcher$1.current = HooksDispatcherOnRerender; + ReactCurrentDispatcher.current = HooksDispatcherOnRerender; current = Component(props, secondArg); - } while (didScheduleRenderPhaseUpdateDuringThisPass); + } while (workInProgress.expirationTime === renderExpirationTime); } - ReactCurrentDispatcher$1.current = ContextOnlyDispatcher; + ReactCurrentDispatcher.current = ContextOnlyDispatcher; workInProgress = null !== currentHook && null !== currentHook.next; - renderLanes = 0; + renderExpirationTime = 0; workInProgressHook = currentHook = currentlyRenderingFiber$1 = null; didScheduleRenderPhaseUpdate = !1; if (workInProgress) @@ -3499,40 +3237,40 @@ function updateReducer(reducer) { var newBaseQueueLast = (baseFirst = pendingQueue = null), update = baseQueue; do { - var suspenseConfig = update.suspenseConfig, - updateLane = update.lane, - updateEventTime = update.eventTime; - (renderLanes & updateLane) === updateLane - ? (null !== newBaseQueueLast && - (newBaseQueueLast = newBaseQueueLast.next = { - eventTime: updateEventTime, - lane: 0, - suspenseConfig: update.suspenseConfig, - action: update.action, - eagerReducer: update.eagerReducer, - eagerState: update.eagerState, - next: null - }), - markRenderEventTimeAndConfig(updateEventTime, suspenseConfig), - (current = - update.eagerReducer === reducer - ? update.eagerState - : reducer(current, update.action))) - : ((suspenseConfig = { - eventTime: updateEventTime, - lane: updateLane, - suspenseConfig: suspenseConfig, + var updateExpirationTime = update.expirationTime; + if (updateExpirationTime < renderExpirationTime) { + var clone = { + expirationTime: update.expirationTime, + suspenseConfig: update.suspenseConfig, + action: update.action, + eagerReducer: update.eagerReducer, + eagerState: update.eagerState, + next: null + }; + null === newBaseQueueLast + ? ((baseFirst = newBaseQueueLast = clone), (pendingQueue = current)) + : (newBaseQueueLast = newBaseQueueLast.next = clone); + updateExpirationTime > currentlyRenderingFiber$1.expirationTime && + ((currentlyRenderingFiber$1.expirationTime = updateExpirationTime), + markUnprocessedUpdateTime(updateExpirationTime)); + } else + null !== newBaseQueueLast && + (newBaseQueueLast = newBaseQueueLast.next = { + expirationTime: 1073741823, + suspenseConfig: update.suspenseConfig, action: update.action, eagerReducer: update.eagerReducer, eagerState: update.eagerState, next: null }), - null === newBaseQueueLast - ? ((baseFirst = newBaseQueueLast = suspenseConfig), - (pendingQueue = current)) - : (newBaseQueueLast = newBaseQueueLast.next = suspenseConfig), - (currentlyRenderingFiber$1.lanes |= updateLane), - (workInProgressRootSkippedLanes |= updateLane)); + markRenderEventTimeAndConfig( + updateExpirationTime, + update.suspenseConfig + ), + (current = + update.eagerReducer === reducer + ? update.eagerState + : reducer(current, update.action)); update = update.next; } while (null !== update && update !== baseQueue); null === newBaseQueueLast @@ -3569,117 +3307,6 @@ function rerenderReducer(reducer) { } return [newState, dispatch]; } -function readFromUnsubcribedMutableSource(root, source, getSnapshot) { - var getVersion = source._getVersion; - getVersion = getVersion(source._source); - var JSCompiler_inline_result = source._workInProgressVersionPrimary; - if (null !== JSCompiler_inline_result) - root = JSCompiler_inline_result === getVersion; - else if ( - ((root = root.mutableReadLanes), (root = (renderLanes & root) === root)) - ) - (source._workInProgressVersionPrimary = getVersion), - workInProgressSources.push(source); - if (root) return getSnapshot(source._source); - workInProgressSources.push(source); - throw Error( - "Cannot read from mutable source during the current render without tearing. This is a bug in React. Please file an issue." - ); -} -function useMutableSource(hook, source, getSnapshot, subscribe) { - var root = workInProgressRoot; - if (null === root) - throw Error( - "Expected a work-in-progress root. This is a bug in React. Please file an issue." - ); - var getVersion = source._getVersion, - version = getVersion(source._source), - dispatcher = ReactCurrentDispatcher$1.current, - _dispatcher$useState = dispatcher.useState(function() { - return readFromUnsubcribedMutableSource(root, source, getSnapshot); - }), - setSnapshot = _dispatcher$useState[1], - snapshot = _dispatcher$useState[0]; - _dispatcher$useState = workInProgressHook; - var memoizedState = hook.memoizedState, - refs = memoizedState.refs, - prevGetSnapshot = refs.getSnapshot, - prevSource = memoizedState.source; - memoizedState = memoizedState.subscribe; - var fiber = currentlyRenderingFiber$1; - hook.memoizedState = { refs: refs, source: source, subscribe: subscribe }; - dispatcher.useEffect( - function() { - refs.getSnapshot = getSnapshot; - refs.setSnapshot = setSnapshot; - var maybeNewVersion = getVersion(source._source); - if (!objectIs(version, maybeNewVersion)) { - maybeNewVersion = getSnapshot(source._source); - objectIs(snapshot, maybeNewVersion) || - (setSnapshot(maybeNewVersion), - (maybeNewVersion = requestUpdateLane( - fiber, - ReactCurrentBatchConfig.suspense - )), - (root.mutableReadLanes |= maybeNewVersion & root.pendingLanes)); - maybeNewVersion = root.mutableReadLanes; - root.entangledLanes |= maybeNewVersion; - for ( - var entanglements = root.entanglements, lanes = maybeNewVersion; - 0 < lanes; - - ) { - var index$14 = 31 - clz32(lanes), - lane = 1 << index$14; - entanglements[index$14] |= maybeNewVersion; - lanes &= ~lane; - } - } - }, - [getSnapshot, source, subscribe] - ); - dispatcher.useEffect( - function() { - return subscribe(source._source, function() { - var latestGetSnapshot = refs.getSnapshot, - latestSetSnapshot = refs.setSnapshot; - try { - latestSetSnapshot(latestGetSnapshot(source._source)); - var lane = requestUpdateLane(fiber, ReactCurrentBatchConfig.suspense); - root.mutableReadLanes |= lane & root.pendingLanes; - } catch (error) { - latestSetSnapshot(function() { - throw error; - }); - } - }); - }, - [source, subscribe] - ); - (objectIs(prevGetSnapshot, getSnapshot) && - objectIs(prevSource, source) && - objectIs(memoizedState, subscribe)) || - ((hook = { - pending: null, - dispatch: null, - lastRenderedReducer: basicStateReducer, - lastRenderedState: snapshot - }), - (hook.dispatch = setSnapshot = dispatchAction.bind( - null, - currentlyRenderingFiber$1, - hook - )), - (_dispatcher$useState.queue = hook), - (_dispatcher$useState.baseQueue = null), - (snapshot = readFromUnsubcribedMutableSource(root, source, getSnapshot)), - (_dispatcher$useState.memoizedState = _dispatcher$useState.baseState = snapshot)); - return snapshot; -} -function updateMutableSource(source, getSnapshot, subscribe) { - var hook = updateWorkInProgressHook(); - return useMutableSource(hook, source, getSnapshot, subscribe); -} function mountState(initialState) { var hook = mountWorkInProgressHook(); "function" === typeof initialState && (initialState = initialState()); @@ -3828,12 +3455,11 @@ function startTransition(setPending, config, callback) { }); } function dispatchAction(fiber, queue, action) { - var eventTime = requestEventTime(), - suspenseConfig = ReactCurrentBatchConfig.suspense, - lane = requestUpdateLane(fiber, suspenseConfig); + var currentTime = requestCurrentTimeForUpdate(), + suspenseConfig = ReactCurrentBatchConfig.suspense; + currentTime = computeExpirationForFiber(currentTime, fiber, suspenseConfig); suspenseConfig = { - eventTime: eventTime, - lane: lane, + expirationTime: currentTime, suspenseConfig: suspenseConfig, action: action, eagerReducer: null, @@ -3850,11 +3476,13 @@ function dispatchAction(fiber, queue, action) { fiber === currentlyRenderingFiber$1 || (null !== pending && pending === currentlyRenderingFiber$1) ) - didScheduleRenderPhaseUpdateDuringThisPass = didScheduleRenderPhaseUpdate = !0; + (didScheduleRenderPhaseUpdate = !0), + (suspenseConfig.expirationTime = renderExpirationTime), + (currentlyRenderingFiber$1.expirationTime = renderExpirationTime); else { if ( - 0 === fiber.lanes && - (null === pending || 0 === pending.lanes) && + 0 === fiber.expirationTime && + (null === pending || 0 === pending.expirationTime) && ((pending = queue.lastRenderedReducer), null !== pending) ) try { @@ -3866,9 +3494,10 @@ function dispatchAction(fiber, queue, action) { } catch (error) { } finally { } - scheduleUpdateOnFiber(fiber, lane, eventTime); + scheduleWork(fiber, currentTime); } } +function updateEventListener() {} var ContextOnlyDispatcher = { readContext: readContext, useCallback: throwInvalidHookError, @@ -3884,9 +3513,7 @@ var ContextOnlyDispatcher = { useResponder: throwInvalidHookError, useDeferredValue: throwInvalidHookError, useTransition: throwInvalidHookError, - useMutableSource: throwInvalidHookError, - useOpaqueIdentifier: throwInvalidHookError, - unstable_isNewReconciler: !1 + useEvent: throwInvalidHookError }, HooksDispatcherOnMount = { readContext: readContext, @@ -3968,19 +3595,7 @@ var ContextOnlyDispatcher = { isPending ]; }, - useMutableSource: function(source, getSnapshot, subscribe) { - var hook = mountWorkInProgressHook(); - hook.memoizedState = { - refs: { getSnapshot: getSnapshot, setSnapshot: null }, - source: source, - subscribe: subscribe - }; - return useMutableSource(hook, source, getSnapshot, subscribe); - }, - useOpaqueIdentifier: function() { - throw Error("Not yet implemented"); - }, - unstable_isNewReconciler: !1 + useEvent: function() {} }, HooksDispatcherOnUpdate = { readContext: readContext, @@ -4028,11 +3643,7 @@ var ContextOnlyDispatcher = { isPending ]; }, - useMutableSource: updateMutableSource, - useOpaqueIdentifier: function() { - return updateReducer(basicStateReducer)[0]; - }, - unstable_isNewReconciler: !1 + useEvent: updateEventListener }, HooksDispatcherOnRerender = { readContext: readContext, @@ -4080,11 +3691,7 @@ var ContextOnlyDispatcher = { isPending ]; }, - useMutableSource: updateMutableSource, - useOpaqueIdentifier: function() { - return rerenderReducer(basicStateReducer)[0]; - }, - unstable_isNewReconciler: !1 + useEvent: updateEventListener }, now$1 = Scheduler.unstable_now, commitTime = 0, @@ -4097,21 +3704,27 @@ function stopProfilerTimerIfRunningAndRecordDelta(fiber, overrideBaseTime) { profilerStartTime = -1; } } -function transferActualDuration(fiber) { - for (var child = fiber.child; child; ) - (fiber.actualDuration += child.actualDuration), (child = child.sibling); -} var ReactCurrentOwner$1 = ReactSharedInternals.ReactCurrentOwner, didReceiveUpdate = !1; -function reconcileChildren(current, workInProgress, nextChildren, renderLanes) { +function reconcileChildren( + current, + workInProgress, + nextChildren, + renderExpirationTime +) { workInProgress.child = null === current - ? mountChildFibers(workInProgress, null, nextChildren, renderLanes) + ? mountChildFibers( + workInProgress, + null, + nextChildren, + renderExpirationTime + ) : reconcileChildFibers( workInProgress, current.child, nextChildren, - renderLanes + renderExpirationTime ); } function updateForwardRef( @@ -4119,28 +3732,33 @@ function updateForwardRef( workInProgress, Component, nextProps, - renderLanes + renderExpirationTime ) { Component = Component.render; var ref = workInProgress.ref; - prepareToReadContext(workInProgress, renderLanes); + prepareToReadContext(workInProgress, renderExpirationTime); nextProps = renderWithHooks( current, workInProgress, Component, nextProps, ref, - renderLanes + renderExpirationTime ); if (null !== current && !didReceiveUpdate) return ( (workInProgress.updateQueue = current.updateQueue), (workInProgress.effectTag &= -517), - (current.lanes &= ~renderLanes), - bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes) + current.expirationTime <= renderExpirationTime && + (current.expirationTime = 0), + bailoutOnAlreadyFinishedWork( + current, + workInProgress, + renderExpirationTime + ) ); workInProgress.effectTag |= 1; - reconcileChildren(current, workInProgress, nextProps, renderLanes); + reconcileChildren(current, workInProgress, nextProps, renderExpirationTime); return workInProgress.child; } function updateMemoComponent( @@ -4148,8 +3766,8 @@ function updateMemoComponent( workInProgress, Component, nextProps, - updateLanes, - renderLanes + updateExpirationTime, + renderExpirationTime ) { if (null === current) { var type = Component.type; @@ -4168,8 +3786,8 @@ function updateMemoComponent( workInProgress, type, nextProps, - updateLanes, - renderLanes + updateExpirationTime, + renderExpirationTime ) ); current = createFiberFromTypeAndProps( @@ -4178,7 +3796,7 @@ function updateMemoComponent( nextProps, null, workInProgress.mode, - renderLanes + renderExpirationTime ); current.ref = workInProgress.ref; current.return = workInProgress; @@ -4186,13 +3804,18 @@ function updateMemoComponent( } type = current.child; if ( - 0 === (updateLanes & renderLanes) && - ((updateLanes = type.memoizedProps), + updateExpirationTime < renderExpirationTime && + ((updateExpirationTime = type.memoizedProps), (Component = Component.compare), (Component = null !== Component ? Component : shallowEqual), - Component(updateLanes, nextProps) && current.ref === workInProgress.ref) + Component(updateExpirationTime, nextProps) && + current.ref === workInProgress.ref) ) - return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes); + return bailoutOnAlreadyFinishedWork( + current, + workInProgress, + renderExpirationTime + ); workInProgress.effectTag |= 1; current = createWorkInProgress(type, nextProps); current.ref = workInProgress.ref; @@ -4204,66 +3827,26 @@ function updateSimpleMemoComponent( workInProgress, Component, nextProps, - updateLanes, - renderLanes + updateExpirationTime, + renderExpirationTime ) { - if ( - null !== current && + return null !== current && shallowEqual(current.memoizedProps, nextProps) && - current.ref === workInProgress.ref - ) - if (((didReceiveUpdate = !1), 0 !== (renderLanes & updateLanes))) - 0 !== (current.effectTag & 16384) && (didReceiveUpdate = !0); - else - return ( - (workInProgress.lanes = current.lanes), - bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes) + current.ref === workInProgress.ref && + ((didReceiveUpdate = !1), updateExpirationTime < renderExpirationTime) + ? ((workInProgress.expirationTime = current.expirationTime), + bailoutOnAlreadyFinishedWork( + current, + workInProgress, + renderExpirationTime + )) + : updateFunctionComponent( + current, + workInProgress, + Component, + nextProps, + renderExpirationTime ); - return updateFunctionComponent( - current, - workInProgress, - Component, - nextProps, - renderLanes - ); -} -function updateOffscreenComponent(current, workInProgress, renderLanes) { - var nextProps = workInProgress.pendingProps, - nextChildren = nextProps.children, - prevState = null !== current ? current.memoizedState : null; - if ( - "hidden" === nextProps.mode || - "unstable-defer-without-hiding" === nextProps.mode - ) - if (0 === (workInProgress.mode & 4)) - (workInProgress.memoizedState = { baseLanes: 0 }), - pushRenderLanes(workInProgress, renderLanes); - else if (0 !== (renderLanes & 1073741824)) - (workInProgress.memoizedState = { baseLanes: 0 }), - pushRenderLanes( - workInProgress, - null !== prevState ? prevState.baseLanes : renderLanes - ); - else - return ( - (current = - null !== prevState ? prevState.baseLanes | renderLanes : renderLanes), - null === spawnedWorkDuringRender - ? (spawnedWorkDuringRender = [1073741824]) - : spawnedWorkDuringRender.push(1073741824), - (workInProgress.lanes = workInProgress.childLanes = 1073741824), - (workInProgress.memoizedState = { baseLanes: current }), - pushRenderLanes(workInProgress, current), - null - ); - else - null !== prevState - ? ((nextProps = prevState.baseLanes | renderLanes), - (workInProgress.memoizedState = null)) - : (nextProps = renderLanes), - pushRenderLanes(workInProgress, nextProps); - reconcileChildren(current, workInProgress, nextChildren, renderLanes); - return workInProgress.child; } function markRef(current, workInProgress) { var ref = workInProgress.ref; @@ -4278,30 +3861,35 @@ function updateFunctionComponent( workInProgress, Component, nextProps, - renderLanes + renderExpirationTime ) { var context = isContextProvider(Component) ? previousContext : contextStackCursor.current; context = getMaskedContext(workInProgress, context); - prepareToReadContext(workInProgress, renderLanes); + prepareToReadContext(workInProgress, renderExpirationTime); Component = renderWithHooks( current, workInProgress, Component, nextProps, context, - renderLanes + renderExpirationTime ); if (null !== current && !didReceiveUpdate) return ( (workInProgress.updateQueue = current.updateQueue), (workInProgress.effectTag &= -517), - (current.lanes &= ~renderLanes), - bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes) + current.expirationTime <= renderExpirationTime && + (current.expirationTime = 0), + bailoutOnAlreadyFinishedWork( + current, + workInProgress, + renderExpirationTime + ) ); workInProgress.effectTag |= 1; - reconcileChildren(current, workInProgress, Component, renderLanes); + reconcileChildren(current, workInProgress, Component, renderExpirationTime); return workInProgress.child; } function updateClassComponent( @@ -4309,20 +3897,25 @@ function updateClassComponent( workInProgress, Component, nextProps, - renderLanes + renderExpirationTime ) { if (isContextProvider(Component)) { var hasContext = !0; pushContextProvider(workInProgress); } else hasContext = !1; - prepareToReadContext(workInProgress, renderLanes); + prepareToReadContext(workInProgress, renderExpirationTime); if (null === workInProgress.stateNode) null !== current && ((current.alternate = null), (workInProgress.alternate = null), (workInProgress.effectTag |= 2)), constructClassInstance(workInProgress, Component, nextProps), - mountClassInstance(workInProgress, Component, nextProps, renderLanes), + mountClassInstance( + workInProgress, + Component, + nextProps, + renderExpirationTime + ), (nextProps = !0); else if (null === current) { var instance = workInProgress.stateNode, @@ -4353,7 +3946,12 @@ function updateClassComponent( hasForceUpdate = !1; var oldState = workInProgress.memoizedState; instance.state = oldState; - processUpdateQueue(workInProgress, nextProps, instance, renderLanes); + processUpdateQueue( + workInProgress, + nextProps, + instance, + renderExpirationTime + ); oldContext = workInProgress.memoizedState; oldProps !== nextProps || oldState !== oldContext || @@ -4398,111 +3996,117 @@ function updateClassComponent( : ("function" === typeof instance.componentDidMount && (workInProgress.effectTag |= 4), (nextProps = !1)); - } else { - instance = workInProgress.stateNode; - cloneUpdateQueue(current, workInProgress); - oldProps = workInProgress.memoizedProps; - contextType = - workInProgress.type === workInProgress.elementType - ? oldProps - : resolveDefaultProps(workInProgress.type, oldProps); - instance.props = contextType; - hasNewLifecycles = workInProgress.pendingProps; - oldState = instance.context; - oldContext = Component.contextType; - "object" === typeof oldContext && null !== oldContext - ? (oldContext = readContext(oldContext)) - : ((oldContext = isContextProvider(Component) - ? previousContext - : contextStackCursor.current), - (oldContext = getMaskedContext(workInProgress, oldContext))); - var getDerivedStateFromProps$jscomp$0 = Component.getDerivedStateFromProps; - (getDerivedStateFromProps = - "function" === typeof getDerivedStateFromProps$jscomp$0 || - "function" === typeof instance.getSnapshotBeforeUpdate) || - ("function" !== typeof instance.UNSAFE_componentWillReceiveProps && - "function" !== typeof instance.componentWillReceiveProps) || - ((oldProps !== hasNewLifecycles || oldState !== oldContext) && - callComponentWillReceiveProps( - workInProgress, - instance, - nextProps, - oldContext - )); - hasForceUpdate = !1; - oldState = workInProgress.memoizedState; - instance.state = oldState; - processUpdateQueue(workInProgress, nextProps, instance, renderLanes); - var newState = workInProgress.memoizedState; - oldProps !== hasNewLifecycles || - oldState !== newState || - didPerformWorkStackCursor.current || - hasForceUpdate - ? ("function" === typeof getDerivedStateFromProps$jscomp$0 && - (applyDerivedStateFromProps( + } else + (instance = workInProgress.stateNode), + cloneUpdateQueue(current, workInProgress), + (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 = readContext(contextType)) + : ((contextType = isContextProvider(Component) + ? previousContext + : contextStackCursor.current), + (contextType = getMaskedContext(workInProgress, contextType))), + (getDerivedStateFromProps = Component.getDerivedStateFromProps), + (hasNewLifecycles = + "function" === typeof getDerivedStateFromProps || + "function" === typeof instance.getSnapshotBeforeUpdate) || + ("function" !== typeof instance.UNSAFE_componentWillReceiveProps && + "function" !== typeof instance.componentWillReceiveProps) || + ((oldProps !== nextProps || oldContext !== contextType) && + callComponentWillReceiveProps( workInProgress, - Component, - getDerivedStateFromProps$jscomp$0, - nextProps - ), - (newState = workInProgress.memoizedState)), - (contextType = - hasForceUpdate || - checkShouldComponentUpdate( - workInProgress, - Component, - contextType, + instance, nextProps, - oldState, - newState, - oldContext - )) - ? (getDerivedStateFromProps || - ("function" !== typeof instance.UNSAFE_componentWillUpdate && - "function" !== typeof instance.componentWillUpdate) || - ("function" === typeof instance.componentWillUpdate && - instance.componentWillUpdate(nextProps, newState, oldContext), - "function" === typeof instance.UNSAFE_componentWillUpdate && - instance.UNSAFE_componentWillUpdate( - nextProps, - newState, - oldContext - )), - "function" === typeof instance.componentDidUpdate && - (workInProgress.effectTag |= 4), - "function" === typeof instance.getSnapshotBeforeUpdate && - (workInProgress.effectTag |= 256)) - : ("function" !== typeof instance.componentDidUpdate || - (oldProps === current.memoizedProps && - oldState === current.memoizedState) || - (workInProgress.effectTag |= 4), - "function" !== typeof instance.getSnapshotBeforeUpdate || - (oldProps === current.memoizedProps && - oldState === current.memoizedState) || - (workInProgress.effectTag |= 256), - (workInProgress.memoizedProps = nextProps), - (workInProgress.memoizedState = newState)), - (instance.props = nextProps), - (instance.state = newState), - (instance.context = oldContext), - (nextProps = contextType)) - : ("function" !== typeof instance.componentDidUpdate || - (oldProps === current.memoizedProps && - oldState === current.memoizedState) || - (workInProgress.effectTag |= 4), - "function" !== typeof instance.getSnapshotBeforeUpdate || - (oldProps === current.memoizedProps && - oldState === current.memoizedState) || - (workInProgress.effectTag |= 256), - (nextProps = !1)); - } + contextType + )), + (hasForceUpdate = !1), + (oldContext = workInProgress.memoizedState), + (instance.state = oldContext), + processUpdateQueue( + workInProgress, + nextProps, + instance, + renderExpirationTime + ), + (oldState = workInProgress.memoizedState), + oldProps !== nextProps || + oldContext !== oldState || + didPerformWorkStackCursor.current || + hasForceUpdate + ? ("function" === typeof getDerivedStateFromProps && + (applyDerivedStateFromProps( + workInProgress, + Component, + getDerivedStateFromProps, + nextProps + ), + (oldState = workInProgress.memoizedState)), + (getDerivedStateFromProps = + hasForceUpdate || + checkShouldComponentUpdate( + workInProgress, + Component, + oldProps, + nextProps, + oldContext, + oldState, + contextType + )) + ? (hasNewLifecycles || + ("function" !== typeof instance.UNSAFE_componentWillUpdate && + "function" !== typeof instance.componentWillUpdate) || + ("function" === typeof instance.componentWillUpdate && + instance.componentWillUpdate( + nextProps, + oldState, + contextType + ), + "function" === typeof instance.UNSAFE_componentWillUpdate && + instance.UNSAFE_componentWillUpdate( + nextProps, + oldState, + contextType + )), + "function" === typeof instance.componentDidUpdate && + (workInProgress.effectTag |= 4), + "function" === typeof instance.getSnapshotBeforeUpdate && + (workInProgress.effectTag |= 256)) + : ("function" !== typeof instance.componentDidUpdate || + (oldProps === current.memoizedProps && + oldContext === current.memoizedState) || + (workInProgress.effectTag |= 4), + "function" !== typeof instance.getSnapshotBeforeUpdate || + (oldProps === current.memoizedProps && + oldContext === current.memoizedState) || + (workInProgress.effectTag |= 256), + (workInProgress.memoizedProps = nextProps), + (workInProgress.memoizedState = oldState)), + (instance.props = nextProps), + (instance.state = oldState), + (instance.context = contextType), + (nextProps = getDerivedStateFromProps)) + : ("function" !== typeof instance.componentDidUpdate || + (oldProps === current.memoizedProps && + oldContext === current.memoizedState) || + (workInProgress.effectTag |= 4), + "function" !== typeof instance.getSnapshotBeforeUpdate || + (oldProps === current.memoizedProps && + oldContext === current.memoizedState) || + (workInProgress.effectTag |= 256), + (nextProps = !1)); return finishClassComponent( current, workInProgress, Component, nextProps, hasContext, - renderLanes + renderExpirationTime ); } function finishClassComponent( @@ -4511,14 +4115,18 @@ function finishClassComponent( Component, shouldUpdate, hasContext, - renderLanes + renderExpirationTime ) { markRef(current, workInProgress); var didCaptureError = 0 !== (workInProgress.effectTag & 64); if (!shouldUpdate && !didCaptureError) return ( hasContext && invalidateContextProvider(workInProgress, Component, !1), - bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes) + bailoutOnAlreadyFinishedWork( + current, + workInProgress, + renderExpirationTime + ) ); shouldUpdate = workInProgress.stateNode; ReactCurrentOwner$1.current = workInProgress; @@ -4536,15 +4144,20 @@ function finishClassComponent( workInProgress, current.child, null, - renderLanes + renderExpirationTime )), (workInProgress.child = reconcileChildFibers( workInProgress, null, didCaptureError, - renderLanes + renderExpirationTime ))) - : reconcileChildren(current, workInProgress, nextChildren, renderLanes); + : reconcileChildren( + current, + workInProgress, + nextChildren, + renderExpirationTime + ); workInProgress.memoizedState = shouldUpdate.state; hasContext && invalidateContextProvider(workInProgress, Component, !0); return workInProgress.child; @@ -4561,198 +4174,169 @@ function pushHostRootContext(workInProgress) { pushTopLevelContextObject(workInProgress, root.context, !1); pushHostContainer(workInProgress, root.containerInfo); } -var SUSPENDED_MARKER = { dehydrated: null, retryLane: 0 }; -function updateSuspenseComponent(current, workInProgress, renderLanes) { - var nextProps = workInProgress.pendingProps, +var SUSPENDED_MARKER = { dehydrated: null, retryTime: 0 }; +function updateSuspenseComponent( + current, + workInProgress, + renderExpirationTime +) { + var mode = workInProgress.mode, + nextProps = workInProgress.pendingProps, suspenseContext = suspenseStackCursor.current, - showFallback = !1, + nextDidTimeout = !1, JSCompiler_temp; (JSCompiler_temp = 0 !== (workInProgress.effectTag & 64)) || (JSCompiler_temp = - null !== current && null === current.memoizedState - ? !1 - : 0 !== (suspenseContext & 2)); + 0 !== (suspenseContext & 2) && + (null === current || null !== current.memoizedState)); JSCompiler_temp - ? ((showFallback = !0), (workInProgress.effectTag &= -65)) + ? ((nextDidTimeout = !0), (workInProgress.effectTag &= -65)) : (null !== current && null === current.memoizedState) || void 0 === nextProps.fallback || !0 === nextProps.unstable_avoidThisFallback || (suspenseContext |= 1); push(suspenseStackCursor, suspenseContext & 1); if (null === current) { - if (showFallback) - return ( - (current = nextProps.fallback), - (suspenseContext = workInProgress.mode), - (showFallback = workInProgress.child), - (nextProps = { mode: "hidden", children: nextProps.children }), - 0 === (suspenseContext & 2) && null !== showFallback - ? ((showFallback.childLanes = 0), - (showFallback.pendingProps = nextProps), - workInProgress.mode & 8 && - ((showFallback.actualDuration = 0), - (showFallback.actualStartTime = -1), - (showFallback.selfBaseDuration = 0), - (showFallback.treeBaseDuration = 0))) - : (showFallback = createFiberFromOffscreen( - nextProps, - suspenseContext, - 0, - null - )), - (current = createFiberFromFragment( - current, - suspenseContext, - renderLanes, - null - )), - (showFallback.return = workInProgress), - (current.return = workInProgress), - (showFallback.sibling = current), - (workInProgress.child = showFallback), - (workInProgress.child.memoizedState = { baseLanes: renderLanes }), - (workInProgress.memoizedState = SUSPENDED_MARKER), - current + if (nextDidTimeout) { + nextDidTimeout = nextProps.fallback; + nextProps = createFiberFromFragment(null, mode, 0, null); + nextProps.return = workInProgress; + if (0 === (workInProgress.mode & 2)) + for ( + current = + null !== workInProgress.memoizedState + ? workInProgress.child.child + : workInProgress.child, + nextProps.child = current; + null !== current; + + ) + (current.return = nextProps), (current = current.sibling); + renderExpirationTime = createFiberFromFragment( + nextDidTimeout, + mode, + renderExpirationTime, + null ); - renderLanes = createFiberFromOffscreen( - { mode: "visible", children: nextProps.children }, - workInProgress.mode, - renderLanes, - null - ); - renderLanes.return = workInProgress; - return (workInProgress.child = renderLanes); + renderExpirationTime.return = workInProgress; + nextProps.sibling = renderExpirationTime; + workInProgress.memoizedState = SUSPENDED_MARKER; + workInProgress.child = nextProps; + return renderExpirationTime; + } + mode = nextProps.children; + workInProgress.memoizedState = null; + return (workInProgress.child = mountChildFibers( + workInProgress, + null, + mode, + renderExpirationTime + )); } if (null !== current.memoizedState) { - if (showFallback) - return ( - (nextProps = updateSuspenseFallbackChildren( - current, - workInProgress, - nextProps.children, - nextProps.fallback, - renderLanes - )), - (suspenseContext = workInProgress.child), - (showFallback = current.child.memoizedState), - (suspenseContext.memoizedState = - null === showFallback - ? { baseLanes: renderLanes } - : { baseLanes: showFallback.baseLanes | renderLanes }), - (suspenseContext.childLanes = current.childLanes & ~renderLanes), - (workInProgress.memoizedState = SUSPENDED_MARKER), - nextProps + current = current.child; + mode = current.sibling; + if (nextDidTimeout) { + nextProps = nextProps.fallback; + renderExpirationTime = createWorkInProgress( + current, + current.pendingProps ); - renderLanes = updateSuspensePrimaryChildren( - current, + renderExpirationTime.return = workInProgress; + if ( + 0 === (workInProgress.mode & 2) && + ((nextDidTimeout = + null !== workInProgress.memoizedState + ? workInProgress.child.child + : workInProgress.child), + nextDidTimeout !== current.child) + ) + for ( + renderExpirationTime.child = nextDidTimeout; + null !== nextDidTimeout; + + ) + (nextDidTimeout.return = renderExpirationTime), + (nextDidTimeout = nextDidTimeout.sibling); + if (workInProgress.mode & 8) { + nextDidTimeout = 0; + for (current = renderExpirationTime.child; null !== current; ) + (nextDidTimeout += current.treeBaseDuration), + (current = current.sibling); + renderExpirationTime.treeBaseDuration = nextDidTimeout; + } + mode = createWorkInProgress(mode, nextProps); + mode.return = workInProgress; + renderExpirationTime.sibling = mode; + renderExpirationTime.childExpirationTime = 0; + workInProgress.memoizedState = SUSPENDED_MARKER; + workInProgress.child = renderExpirationTime; + return mode; + } + renderExpirationTime = reconcileChildFibers( workInProgress, + current.child, nextProps.children, - renderLanes + renderExpirationTime ); workInProgress.memoizedState = null; - return renderLanes; + return (workInProgress.child = renderExpirationTime); } - if (showFallback) - return ( - (nextProps = updateSuspenseFallbackChildren( - current, - workInProgress, - nextProps.children, - nextProps.fallback, - renderLanes - )), - (suspenseContext = workInProgress.child), - (showFallback = current.child.memoizedState), - (suspenseContext.memoizedState = - null === showFallback - ? { baseLanes: renderLanes } - : { baseLanes: showFallback.baseLanes | renderLanes }), - (suspenseContext.childLanes = current.childLanes & ~renderLanes), - (workInProgress.memoizedState = SUSPENDED_MARKER), - nextProps + current = current.child; + if (nextDidTimeout) { + nextDidTimeout = nextProps.fallback; + nextProps = createFiberFromFragment(null, mode, 0, null); + nextProps.return = workInProgress; + nextProps.child = current; + null !== current && (current.return = nextProps); + if (0 === (workInProgress.mode & 2)) + for ( + current = + null !== workInProgress.memoizedState + ? workInProgress.child.child + : workInProgress.child, + nextProps.child = current; + null !== current; + + ) + (current.return = nextProps), (current = current.sibling); + if (workInProgress.mode & 8) { + current = 0; + for (suspenseContext = nextProps.child; null !== suspenseContext; ) + (current += suspenseContext.treeBaseDuration), + (suspenseContext = suspenseContext.sibling); + nextProps.treeBaseDuration = current; + } + renderExpirationTime = createFiberFromFragment( + nextDidTimeout, + mode, + renderExpirationTime, + null ); - renderLanes = updateSuspensePrimaryChildren( - current, - workInProgress, - nextProps.children, - renderLanes - ); + renderExpirationTime.return = workInProgress; + nextProps.sibling = renderExpirationTime; + renderExpirationTime.effectTag |= 2; + nextProps.childExpirationTime = 0; + workInProgress.memoizedState = SUSPENDED_MARKER; + workInProgress.child = nextProps; + return renderExpirationTime; + } workInProgress.memoizedState = null; - return renderLanes; + return (workInProgress.child = reconcileChildFibers( + workInProgress, + current, + nextProps.children, + renderExpirationTime + )); } -function updateSuspensePrimaryChildren( - current, - workInProgress, - primaryChildren, - renderLanes -) { - var currentPrimaryChildFragment = current.child; - current = currentPrimaryChildFragment.sibling; - primaryChildren = createWorkInProgress(currentPrimaryChildFragment, { - mode: "visible", - children: primaryChildren - }); - 0 === (workInProgress.mode & 2) && (primaryChildren.lanes = renderLanes); - primaryChildren.return = workInProgress; - primaryChildren.sibling = null; - null !== current && - ((current.nextEffect = null), - (current.effectTag = 8), - (workInProgress.firstEffect = workInProgress.lastEffect = current)); - return (workInProgress.child = primaryChildren); -} -function updateSuspenseFallbackChildren( - current, - workInProgress, - primaryChildren, - fallbackChildren, - renderLanes -) { - var mode = workInProgress.mode, - currentPrimaryChildFragment = current.child; - current = currentPrimaryChildFragment.sibling; - var primaryChildProps = { mode: "hidden", children: primaryChildren }; - 0 === (mode & 2) && workInProgress.child !== currentPrimaryChildFragment - ? ((primaryChildren = workInProgress.child), - (primaryChildren.childLanes = 0), - (primaryChildren.pendingProps = primaryChildProps), - workInProgress.mode & 8 && - ((primaryChildren.actualDuration = 0), - (primaryChildren.actualStartTime = -1), - (primaryChildren.selfBaseDuration = - currentPrimaryChildFragment.selfBaseDuration), - (primaryChildren.treeBaseDuration = - currentPrimaryChildFragment.treeBaseDuration)), - (currentPrimaryChildFragment = primaryChildren.lastEffect), - null !== currentPrimaryChildFragment - ? ((workInProgress.firstEffect = primaryChildren.firstEffect), - (workInProgress.lastEffect = currentPrimaryChildFragment), - (currentPrimaryChildFragment.nextEffect = null)) - : (workInProgress.firstEffect = workInProgress.lastEffect = null)) - : (primaryChildren = createWorkInProgress( - currentPrimaryChildFragment, - primaryChildProps - )); - null !== current - ? (fallbackChildren = createWorkInProgress(current, fallbackChildren)) - : ((fallbackChildren = createFiberFromFragment( - fallbackChildren, - mode, - renderLanes, - null - )), - (fallbackChildren.effectTag |= 2)); - fallbackChildren.return = workInProgress; - primaryChildren.return = workInProgress; - primaryChildren.sibling = fallbackChildren; - workInProgress.child = primaryChildren; - return fallbackChildren; -} -function scheduleWorkOnFiber(fiber, renderLanes) { - fiber.lanes |= renderLanes; +function scheduleWorkOnFiber(fiber, renderExpirationTime) { + fiber.expirationTime < renderExpirationTime && + (fiber.expirationTime = renderExpirationTime); var alternate = fiber.alternate; - null !== alternate && (alternate.lanes |= renderLanes); - scheduleWorkOnParentPath(fiber.return, renderLanes); + null !== alternate && + alternate.expirationTime < renderExpirationTime && + (alternate.expirationTime = renderExpirationTime); + scheduleWorkOnParentPath(fiber.return, renderExpirationTime); } function initSuspenseListRenderState( workInProgress, @@ -4783,11 +4367,20 @@ function initSuspenseListRenderState( (renderState.tailMode = tailMode), (renderState.lastEffect = lastEffectBeforeRendering)); } -function updateSuspenseListComponent(current, workInProgress, renderLanes) { +function updateSuspenseListComponent( + current, + workInProgress, + renderExpirationTime +) { var nextProps = workInProgress.pendingProps, revealOrder = nextProps.revealOrder, tailMode = nextProps.tail; - reconcileChildren(current, workInProgress, nextProps.children, renderLanes); + reconcileChildren( + current, + workInProgress, + nextProps.children, + renderExpirationTime + ); nextProps = suspenseStackCursor.current; if (0 !== (nextProps & 2)) (nextProps = (nextProps & 1) | 2), (workInProgress.effectTag |= 64); @@ -4796,8 +4389,9 @@ function updateSuspenseListComponent(current, workInProgress, renderLanes) { a: for (current = workInProgress.child; null !== current; ) { if (13 === current.tag) null !== current.memoizedState && - scheduleWorkOnFiber(current, renderLanes); - else if (19 === current.tag) scheduleWorkOnFiber(current, renderLanes); + scheduleWorkOnFiber(current, renderExpirationTime); + else if (19 === current.tag) + scheduleWorkOnFiber(current, renderExpirationTime); else if (null !== current.child) { current.child.return = current; current = current.child; @@ -4819,29 +4413,30 @@ function updateSuspenseListComponent(current, workInProgress, renderLanes) { else switch (revealOrder) { case "forwards": - renderLanes = workInProgress.child; - for (revealOrder = null; null !== renderLanes; ) - (current = renderLanes.alternate), + renderExpirationTime = workInProgress.child; + for (revealOrder = null; null !== renderExpirationTime; ) + (current = renderExpirationTime.alternate), null !== current && null === findFirstSuspended(current) && - (revealOrder = renderLanes), - (renderLanes = renderLanes.sibling); - renderLanes = revealOrder; - null === renderLanes + (revealOrder = renderExpirationTime), + (renderExpirationTime = renderExpirationTime.sibling); + renderExpirationTime = revealOrder; + null === renderExpirationTime ? ((revealOrder = workInProgress.child), (workInProgress.child = null)) - : ((revealOrder = renderLanes.sibling), (renderLanes.sibling = null)); + : ((revealOrder = renderExpirationTime.sibling), + (renderExpirationTime.sibling = null)); initSuspenseListRenderState( workInProgress, !1, revealOrder, - renderLanes, + renderExpirationTime, tailMode, workInProgress.lastEffect ); break; case "backwards": - renderLanes = null; + renderExpirationTime = null; revealOrder = workInProgress.child; for (workInProgress.child = null; null !== revealOrder; ) { current = revealOrder.alternate; @@ -4850,14 +4445,14 @@ function updateSuspenseListComponent(current, workInProgress, renderLanes) { break; } current = revealOrder.sibling; - revealOrder.sibling = renderLanes; - renderLanes = revealOrder; + revealOrder.sibling = renderExpirationTime; + renderExpirationTime = revealOrder; revealOrder = current; } initSuspenseListRenderState( workInProgress, !0, - renderLanes, + renderExpirationTime, null, tailMode, workInProgress.lastEffect @@ -4878,29 +4473,36 @@ function updateSuspenseListComponent(current, workInProgress, renderLanes) { } return workInProgress.child; } -function bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes) { +function bailoutOnAlreadyFinishedWork( + current, + workInProgress, + renderExpirationTime +) { null !== current && (workInProgress.dependencies = current.dependencies); profilerStartTime = -1; - workInProgressRootSkippedLanes |= workInProgress.lanes; - if (0 !== (renderLanes & workInProgress.childLanes)) { - if (null !== current && workInProgress.child !== current.child) - throw Error("Resuming work not yet implemented."); - if (null !== workInProgress.child) { - current = workInProgress.child; - renderLanes = createWorkInProgress(current, current.pendingProps); - workInProgress.child = renderLanes; - for (renderLanes.return = workInProgress; null !== current.sibling; ) - (current = current.sibling), - (renderLanes = renderLanes.sibling = createWorkInProgress( - current, - current.pendingProps - )), - (renderLanes.return = workInProgress); - renderLanes.sibling = null; - } - return workInProgress.child; + var updateExpirationTime = workInProgress.expirationTime; + 0 !== updateExpirationTime && markUnprocessedUpdateTime(updateExpirationTime); + if (workInProgress.childExpirationTime < renderExpirationTime) return null; + if (null !== current && workInProgress.child !== current.child) + throw Error("Resuming work not yet implemented."); + if (null !== workInProgress.child) { + current = workInProgress.child; + renderExpirationTime = createWorkInProgress(current, current.pendingProps); + workInProgress.child = renderExpirationTime; + for ( + renderExpirationTime.return = workInProgress; + null !== current.sibling; + + ) + (current = current.sibling), + (renderExpirationTime = renderExpirationTime.sibling = createWorkInProgress( + current, + current.pendingProps + )), + (renderExpirationTime.return = workInProgress); + renderExpirationTime.sibling = null; } - return null; + return workInProgress.child; } var appendAllChildren, updateHostContainer, @@ -4947,17 +4549,17 @@ function cutOffTailIfNeeded(renderState, hasRenderedATailFallback) { break; case "collapsed": lastTailNode = renderState.tail; - for (var lastTailNode$65 = null; null !== lastTailNode; ) - null !== lastTailNode.alternate && (lastTailNode$65 = lastTailNode), + for (var _lastTailNode = null; null !== lastTailNode; ) + null !== lastTailNode.alternate && (_lastTailNode = lastTailNode), (lastTailNode = lastTailNode.sibling); - null === lastTailNode$65 + null === _lastTailNode ? hasRenderedATailFallback || null === renderState.tail ? (renderState.tail = null) : (renderState.tail.sibling = null) - : (lastTailNode$65.sibling = null); + : (_lastTailNode.sibling = null); } } -function completeWork(current, workInProgress, renderLanes) { +function completeWork(current, workInProgress, renderExpirationTime) { var newProps = workInProgress.pendingProps; switch (workInProgress.tag) { case 2: @@ -4978,14 +4580,10 @@ function completeWork(current, workInProgress, renderLanes) { popHostContainer(), pop(didPerformWorkStackCursor), pop(contextStackCursor), - resetWorkInProgressVersions(), - (newProps = workInProgress.stateNode), - newProps.pendingContext && - ((newProps.context = newProps.pendingContext), - (newProps.pendingContext = null)), - (null !== current && null !== current.child) || - newProps.hydrate || - (workInProgress.effectTag |= 256), + (current = workInProgress.stateNode), + current.pendingContext && + ((current.context = current.pendingContext), + (current.pendingContext = null)), updateHostContainer(workInProgress), null ); @@ -4994,12 +4592,12 @@ function completeWork(current, workInProgress, renderLanes) { var rootContainerInstance = requiredContext( rootInstanceStackCursor.current ); - renderLanes = workInProgress.type; + renderExpirationTime = workInProgress.type; if (null !== current && null != workInProgress.stateNode) updateHostComponent$1( current, workInProgress, - renderLanes, + renderExpirationTime, newProps, rootContainerInstance ), @@ -5015,22 +4613,22 @@ function completeWork(current, workInProgress, renderLanes) { } requiredContext(contextStackCursor$1.current); current = allocateTag(); - renderLanes = getViewConfigForType(renderLanes); + renderExpirationTime = getViewConfigForType(renderExpirationTime); var updatePayload = diffProperties( null, emptyObject, newProps, - renderLanes.validAttributes + renderExpirationTime.validAttributes ); ReactNativePrivateInterface.UIManager.createView( current, - renderLanes.uiViewClassName, + renderExpirationTime.uiViewClassName, rootContainerInstance, updatePayload ); rootContainerInstance = new ReactNativeFiberHostComponent( current, - renderLanes, + renderExpirationTime, workInProgress ); instanceCache.set(current, workInProgress); @@ -5076,36 +4674,48 @@ function completeWork(current, workInProgress, renderLanes) { newProps = workInProgress.memoizedState; if (0 !== (workInProgress.effectTag & 64)) return ( - (workInProgress.lanes = renderLanes), - 0 !== (workInProgress.mode & 8) && - transferActualDuration(workInProgress), - workInProgress + (workInProgress.expirationTime = renderExpirationTime), workInProgress ); newProps = null !== newProps; rootContainerInstance = !1; null !== current && - (rootContainerInstance = null !== current.memoizedState); + ((renderExpirationTime = current.memoizedState), + (rootContainerInstance = null !== renderExpirationTime), + newProps || + null === renderExpirationTime || + ((renderExpirationTime = current.child.sibling), + null !== renderExpirationTime && + ((updatePayload = workInProgress.firstEffect), + null !== updatePayload + ? ((workInProgress.firstEffect = renderExpirationTime), + (renderExpirationTime.nextEffect = updatePayload)) + : ((workInProgress.firstEffect = workInProgress.lastEffect = renderExpirationTime), + (renderExpirationTime.nextEffect = null)), + (renderExpirationTime.effectTag = 8)))); if (newProps && !rootContainerInstance && 0 !== (workInProgress.mode & 2)) if ( (null === current && !0 !== workInProgress.memoizedProps.unstable_avoidThisFallback) || 0 !== (suspenseStackCursor.current & 1) ) - 0 === workInProgressRootExitStatus && - (workInProgressRootExitStatus = 3); + workInProgressRootExitStatus === RootIncomplete && + (workInProgressRootExitStatus = RootSuspended); else { if ( - 0 === workInProgressRootExitStatus || - 3 === workInProgressRootExitStatus + workInProgressRootExitStatus === RootIncomplete || + workInProgressRootExitStatus === RootSuspended ) - workInProgressRootExitStatus = 4; - null === workInProgressRoot || - (0 === (workInProgressRootSkippedLanes & 134217727) && - 0 === (workInProgressRootUpdatedLanes & 134217727)) || - markRootSuspended$1( + workInProgressRootExitStatus = RootSuspendedWithDelay; + 0 !== workInProgressRootNextUnprocessedUpdateTime && + null !== workInProgressRoot && + (markRootSuspendedAtTime( workInProgressRoot, - workInProgressRootRenderLanes - ); + renderExpirationTime$1 + ), + markRootUpdatedAtTime( + workInProgressRoot, + workInProgressRootNextUnprocessedUpdateTime + )); } if (newProps || rootContainerInstance) workInProgress.effectTag |= 4; return null; @@ -5125,7 +4735,7 @@ function completeWork(current, workInProgress, renderLanes) { if (rootContainerInstance) cutOffTailIfNeeded(newProps, !1); else { if ( - 0 !== workInProgressRootExitStatus || + workInProgressRootExitStatus !== RootIncomplete || (null !== current && 0 !== (current.effectTag & 64)) ) for (current = workInProgress.child; null !== current; ) { @@ -5140,7 +4750,7 @@ function completeWork(current, workInProgress, renderLanes) { null === newProps.lastEffect && (workInProgress.firstEffect = null); workInProgress.lastEffect = newProps.lastEffect; - current = renderLanes; + current = renderExpirationTime; for (newProps = workInProgress.child; null !== newProps; ) (rootContainerInstance = newProps), (updatePayload = current), @@ -5148,42 +4758,42 @@ function completeWork(current, workInProgress, renderLanes) { (rootContainerInstance.nextEffect = null), (rootContainerInstance.firstEffect = null), (rootContainerInstance.lastEffect = null), - (renderLanes = rootContainerInstance.alternate), - null === renderLanes - ? ((rootContainerInstance.childLanes = 0), - (rootContainerInstance.lanes = updatePayload), + (renderExpirationTime = rootContainerInstance.alternate), + null === renderExpirationTime + ? ((rootContainerInstance.childExpirationTime = 0), + (rootContainerInstance.expirationTime = updatePayload), (rootContainerInstance.child = null), (rootContainerInstance.memoizedProps = null), (rootContainerInstance.memoizedState = null), (rootContainerInstance.updateQueue = null), (rootContainerInstance.dependencies = null), - (rootContainerInstance.stateNode = null), (rootContainerInstance.selfBaseDuration = 0), (rootContainerInstance.treeBaseDuration = 0)) - : ((rootContainerInstance.childLanes = - renderLanes.childLanes), - (rootContainerInstance.lanes = renderLanes.lanes), - (rootContainerInstance.child = renderLanes.child), + : ((rootContainerInstance.childExpirationTime = + renderExpirationTime.childExpirationTime), + (rootContainerInstance.expirationTime = + renderExpirationTime.expirationTime), + (rootContainerInstance.child = + renderExpirationTime.child), (rootContainerInstance.memoizedProps = - renderLanes.memoizedProps), + renderExpirationTime.memoizedProps), (rootContainerInstance.memoizedState = - renderLanes.memoizedState), + renderExpirationTime.memoizedState), (rootContainerInstance.updateQueue = - renderLanes.updateQueue), - (rootContainerInstance.type = renderLanes.type), - (updatePayload = renderLanes.dependencies), + renderExpirationTime.updateQueue), + (updatePayload = renderExpirationTime.dependencies), (rootContainerInstance.dependencies = null === updatePayload ? null : { - lanes: updatePayload.lanes, + expirationTime: updatePayload.expirationTime, firstContext: updatePayload.firstContext, responders: updatePayload.responders }), (rootContainerInstance.selfBaseDuration = - renderLanes.selfBaseDuration), + renderExpirationTime.selfBaseDuration), (rootContainerInstance.treeBaseDuration = - renderLanes.treeBaseDuration)), + renderExpirationTime.treeBaseDuration)), (newProps = newProps.sibling); push( suspenseStackCursor, @@ -5219,14 +4829,15 @@ function completeWork(current, workInProgress, renderLanes) { ); } else 2 * now() - newProps.renderingStartTime > newProps.tailExpiration && - 1073741824 !== renderLanes && + 1 < renderExpirationTime && ((workInProgress.effectTag |= 64), (rootContainerInstance = !0), cutOffTailIfNeeded(newProps, !1), - (workInProgress.lanes = renderLanes), + (current = renderExpirationTime - 1), + (workInProgress.expirationTime = workInProgress.childExpirationTime = current), null === spawnedWorkDuringRender - ? (spawnedWorkDuringRender = [renderLanes]) - : spawnedWorkDuringRender.push(renderLanes)); + ? (spawnedWorkDuringRender = [current]) + : spawnedWorkDuringRender.push(current)); newProps.isBackwards ? ((updatePayload.sibling = workInProgress.child), (workInProgress.child = updatePayload)) @@ -5254,17 +4865,6 @@ function completeWork(current, workInProgress, renderLanes) { ), current) : null; - case 23: - case 24: - return ( - popRenderLanes(), - null !== current && - (null !== current.memoizedState) !== - (null !== workInProgress.memoizedState) && - "unstable-defer-without-hiding" !== newProps.mode && - (workInProgress.effectTag |= 4), - null - ); } throw Error( "Unknown unit of work tag (" + @@ -5279,15 +4879,12 @@ function unwindWork(workInProgress) { var effectTag = workInProgress.effectTag; return effectTag & 4096 ? ((workInProgress.effectTag = (effectTag & -4097) | 64), - 0 !== (workInProgress.mode & 8) && - transferActualDuration(workInProgress), workInProgress) : null; case 3: popHostContainer(); pop(didPerformWorkStackCursor); pop(contextStackCursor); - resetWorkInProgressVersions(); effectTag = workInProgress.effectTag; if (0 !== (effectTag & 64)) throw Error( @@ -5303,8 +4900,6 @@ function unwindWork(workInProgress) { (effectTag = workInProgress.effectTag), effectTag & 4096 ? ((workInProgress.effectTag = (effectTag & -4097) | 64), - 0 !== (workInProgress.mode & 8) && - transferActualDuration(workInProgress), workInProgress) : null ); @@ -5314,9 +4909,6 @@ function unwindWork(workInProgress) { return popHostContainer(), null; case 10: return popProvider(workInProgress), null; - case 23: - case 24: - return popRenderLanes(), null; default: return null; } @@ -5335,61 +4927,51 @@ if ( throw Error( "Expected ReactFiberErrorDialog.showErrorDialog to be a function." ); -function logCapturedError(boundary, errorInfo) { +function logCapturedError(capturedError) { + !1 !== + ReactNativePrivateInterface.ReactFiberErrorDialog.showErrorDialog( + capturedError + ) && console.error(capturedError.error); +} +var PossiblyWeakSet = "function" === typeof WeakSet ? WeakSet : Set; +function logError(boundary, errorInfo) { + var source = errorInfo.source, + stack = errorInfo.stack; + null === stack && + null !== source && + (stack = getStackByFiberInDevAndProd(source)); + errorInfo = { + componentName: null !== source ? getComponentName(source.type) : null, + componentStack: null !== stack ? stack : "", + error: errorInfo.value, + errorBoundary: null, + errorBoundaryName: null, + errorBoundaryFound: !1, + willRetry: !1 + }; + null !== boundary && + 1 === boundary.tag && + ((errorInfo.errorBoundary = boundary.stateNode), + (errorInfo.errorBoundaryName = getComponentName(boundary.type)), + (errorInfo.errorBoundaryFound = !0), + (errorInfo.willRetry = !0)); try { - !1 !== - ReactNativePrivateInterface.ReactFiberErrorDialog.showErrorDialog({ - componentStack: null !== errorInfo.stack ? errorInfo.stack : "", - error: errorInfo.value, - errorBoundary: - null !== boundary && 1 === boundary.tag ? boundary.stateNode : null - }) && console.error(errorInfo.value); + logCapturedError(errorInfo); } catch (e) { setTimeout(function() { throw e; }); } } -var PossiblyWeakMap = "function" === typeof WeakMap ? WeakMap : Map; -function createRootErrorUpdate(fiber, errorInfo, lane) { - lane = createUpdate(-1, lane, null); - lane.tag = 3; - lane.payload = { element: null }; - var error = errorInfo.value; - lane.callback = function() { - hasUncaughtError || ((hasUncaughtError = !0), (firstUncaughtError = error)); - logCapturedError(fiber, errorInfo); - }; - return lane; -} -function createClassErrorUpdate(fiber, errorInfo, lane) { - lane = createUpdate(-1, lane, null); - lane.tag = 3; - var getDerivedStateFromError = fiber.type.getDerivedStateFromError; - if ("function" === typeof getDerivedStateFromError) { - var error = errorInfo.value; - lane.payload = function() { - logCapturedError(fiber, errorInfo); - return getDerivedStateFromError(error); - }; +function safelyCallComponentWillUnmount(current, instance) { + try { + (instance.props = current.memoizedProps), + (instance.state = current.memoizedState), + instance.componentWillUnmount(); + } catch (unmountError) { + captureCommitPhaseError(current, unmountError); } - var inst = fiber.stateNode; - null !== inst && - "function" === typeof inst.componentDidCatch && - (lane.callback = function() { - "function" !== typeof getDerivedStateFromError && - (null === legacyErrorBoundariesThatAlreadyFailed - ? (legacyErrorBoundariesThatAlreadyFailed = new Set([this])) - : legacyErrorBoundariesThatAlreadyFailed.add(this), - logCapturedError(fiber, errorInfo)); - var stack = errorInfo.stack; - this.componentDidCatch(errorInfo.value, { - componentStack: null !== stack ? stack : "" - }); - }); - return lane; } -var PossiblyWeakSet = "function" === typeof WeakSet ? WeakSet : Set; function safelyDetachRef(current) { var ref = current.ref; if (null !== ref) @@ -5423,7 +5005,6 @@ function commitBeforeMutationLifeCycles(current, finishedWork) { } return; case 3: - return; case 5: case 6: case 4: @@ -5434,57 +5015,58 @@ function commitBeforeMutationLifeCycles(current, finishedWork) { "This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue." ); } +function commitHookEffectListUnmount(tag, finishedWork) { + finishedWork = finishedWork.updateQueue; + finishedWork = null !== finishedWork ? finishedWork.lastEffect : null; + if (null !== finishedWork) { + var effect = (finishedWork = finishedWork.next); + do { + if ((effect.tag & tag) === tag) { + var destroy = effect.destroy; + effect.destroy = void 0; + void 0 !== destroy && destroy(); + } + effect = effect.next; + } while (effect !== finishedWork); + } +} +function commitHookEffectListMount(tag, finishedWork) { + finishedWork = finishedWork.updateQueue; + finishedWork = null !== finishedWork ? finishedWork.lastEffect : null; + if (null !== finishedWork) { + var effect = (finishedWork = finishedWork.next); + do { + if ((effect.tag & tag) === tag) { + var create = effect.create; + effect.destroy = create(); + } + effect = effect.next; + } while (effect !== finishedWork); + } +} function commitLifeCycles(finishedRoot, current, finishedWork) { switch (finishedWork.tag) { case 0: case 11: case 15: case 22: - current = finishedWork.updateQueue; - current = null !== current ? current.lastEffect : null; - if (null !== current) { - finishedRoot = current = current.next; - do { - if (3 === (finishedRoot.tag & 3)) { - var create$82 = finishedRoot.create; - finishedRoot.destroy = create$82(); - } - finishedRoot = finishedRoot.next; - } while (finishedRoot !== current); - } - current = finishedWork.updateQueue; - current = null !== current ? current.lastEffect : null; - if (null !== current) { - finishedRoot = current = current.next; - do { - var _effect = finishedRoot; - create$82 = _effect.next; - _effect = _effect.tag; - 0 !== (_effect & 4) && - 0 !== (_effect & 1) && - (enqueuePendingPassiveHookEffectUnmount(finishedWork, finishedRoot), - enqueuePendingPassiveHookEffectMount(finishedWork, finishedRoot)); - finishedRoot = create$82; - } while (finishedRoot !== current); - } + commitHookEffectListMount(3, finishedWork); return; case 1: finishedRoot = finishedWork.stateNode; - finishedWork.effectTag & 4 && - (null === current - ? finishedRoot.componentDidMount() - : ((create$82 = - finishedWork.elementType === finishedWork.type - ? current.memoizedProps - : resolveDefaultProps( - finishedWork.type, - current.memoizedProps - )), - finishedRoot.componentDidUpdate( - create$82, - current.memoizedState, - finishedRoot.__reactInternalSnapshotBeforeUpdate - ))); + if (finishedWork.effectTag & 4) + if (null === current) finishedRoot.componentDidMount(); + else { + var prevProps = + finishedWork.elementType === finishedWork.type + ? current.memoizedProps + : resolveDefaultProps(finishedWork.type, current.memoizedProps); + finishedRoot.componentDidUpdate( + prevProps, + current.memoizedState, + finishedRoot.__reactInternalSnapshotBeforeUpdate + ); + } current = finishedWork.updateQueue; null !== current && commitUpdateQueue(finishedWork, current, finishedRoot); @@ -5511,16 +5093,16 @@ function commitLifeCycles(finishedRoot, current, finishedWork) { case 4: return; case 12: - create$82 = finishedWork.memoizedProps.onRender; - _effect = commitTime; - "function" === typeof create$82 && - create$82( + prevProps = finishedWork.memoizedProps.onRender; + var commitTime$jscomp$0 = commitTime; + "function" === typeof prevProps && + prevProps( finishedWork.memoizedProps.id, null === current ? "mount" : "update", finishedWork.actualDuration, finishedWork.treeBaseDuration, finishedWork.actualStartTime, - _effect, + commitTime$jscomp$0, finishedRoot.memoizedInteractions ); return; @@ -5530,139 +5112,78 @@ function commitLifeCycles(finishedRoot, current, finishedWork) { case 17: case 20: case 21: - case 23: - case 24: return; } throw Error( "This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue." ); } -function hideOrUnhideAllChildren(finishedWork, isHidden) { - for (var node = finishedWork; ; ) { - if (5 === node.tag) { - var instance = node.stateNode; - if (isHidden) { - var viewConfig = instance.viewConfig; - var updatePayload = diffProperties( - null, - emptyObject, - { style: { display: "none" } }, - viewConfig.validAttributes - ); - ReactNativePrivateInterface.UIManager.updateView( - instance._nativeTag, - viewConfig.uiViewClassName, - updatePayload - ); - } else { - instance = node.stateNode; - updatePayload = node.memoizedProps; - viewConfig = instance.viewConfig; - var prevProps = Object.assign({}, updatePayload, { - style: [updatePayload.style, { display: "none" }] - }); - updatePayload = diffProperties( - null, - prevProps, - updatePayload, - viewConfig.validAttributes - ); - ReactNativePrivateInterface.UIManager.updateView( - instance._nativeTag, - viewConfig.uiViewClassName, - updatePayload - ); - } - } else { - if (6 === node.tag) throw Error("Not yet implemented."); - if ( - ((23 !== node.tag && 24 !== node.tag) || - null === node.memoizedState || - node === finishedWork) && - null !== node.child - ) { - node.child.return = node; - node = node.child; - continue; - } - } - if (node === finishedWork) break; - for (; null === node.sibling; ) { - if (null === node.return || node.return === finishedWork) return; - node = node.return; - } - node.sibling.return = node.return; - node = node.sibling; - } -} -function commitUnmount(finishedRoot, current) { - if (injectedHook && "function" === typeof injectedHook.onCommitFiberUnmount) - try { - injectedHook.onCommitFiberUnmount(rendererID, current); - } catch (err) {} - switch (current.tag) { +function commitUnmount(finishedRoot, current$jscomp$0, renderPriorityLevel) { + "function" === typeof onCommitFiberUnmount && + onCommitFiberUnmount(current$jscomp$0); + switch (current$jscomp$0.tag) { case 0: case 11: case 14: case 15: case 22: - finishedRoot = current.updateQueue; + finishedRoot = current$jscomp$0.updateQueue; if ( null !== finishedRoot && ((finishedRoot = finishedRoot.lastEffect), null !== finishedRoot) ) { - var effect = (finishedRoot = finishedRoot.next); - do { - var _effect2 = effect, - destroy = _effect2.destroy; - _effect2 = _effect2.tag; - if (void 0 !== destroy) - if (0 !== (_effect2 & 4)) - enqueuePendingPassiveHookEffectUnmount(current, effect); - else { - _effect2 = current; - try { - destroy(); - } catch (error) { - captureCommitPhaseError(_effect2, error); + var firstEffect = finishedRoot.next; + runWithPriority( + 97 < renderPriorityLevel ? 97 : renderPriorityLevel, + function() { + var effect = firstEffect; + do { + var _destroy = effect.destroy; + if (void 0 !== _destroy) { + var current = current$jscomp$0; + try { + _destroy(); + } catch (error) { + captureCommitPhaseError(current, error); + } } - } - effect = effect.next; - } while (effect !== finishedRoot); + effect = effect.next; + } while (effect !== firstEffect); + } + ); } break; case 1: - safelyDetachRef(current); - finishedRoot = current.stateNode; - if ("function" === typeof finishedRoot.componentWillUnmount) - try { - (finishedRoot.props = current.memoizedProps), - (finishedRoot.state = current.memoizedState), - finishedRoot.componentWillUnmount(); - } catch (unmountError) { - captureCommitPhaseError(current, unmountError); - } + safelyDetachRef(current$jscomp$0); + renderPriorityLevel = current$jscomp$0.stateNode; + "function" === typeof renderPriorityLevel.componentWillUnmount && + safelyCallComponentWillUnmount(current$jscomp$0, renderPriorityLevel); break; case 5: - safelyDetachRef(current); + safelyDetachRef(current$jscomp$0); break; case 4: - unmountHostComponents(finishedRoot, current); + unmountHostComponents( + finishedRoot, + current$jscomp$0, + renderPriorityLevel + ); } } -function detachFiberMutation(fiber) { - fiber.alternate = null; - fiber.child = null; - fiber.dependencies = null; - fiber.firstEffect = null; - fiber.lastEffect = null; - fiber.memoizedProps = null; - fiber.memoizedState = null; - fiber.pendingProps = null; - fiber.return = null; - fiber.stateNode = null; - fiber.updateQueue = null; +function detachFiber(current) { + var alternate = current.alternate; + current.return = null; + current.child = null; + current.memoizedState = null; + current.updateQueue = null; + current.dependencies = null; + current.alternate = null; + current.firstEffect = null; + current.lastEffect = null; + current.pendingProps = null; + current.memoizedProps = null; + current.stateNode = null; + null !== alternate && detachFiber(alternate); } function isHostParent(fiber) { return 5 === fiber.tag || 3 === fiber.tag || 4 === fiber.tag; @@ -5670,14 +5191,16 @@ function isHostParent(fiber) { function commitPlacement(finishedWork) { a: { for (var parent = finishedWork.return; null !== parent; ) { - if (isHostParent(parent)) break a; + if (isHostParent(parent)) { + var parentFiber = parent; + break a; + } parent = parent.return; } throw Error( "Expected to find a host parent. This error is likely caused by a bug in React. Please file an issue." ); } - var parentFiber = parent; parent = parentFiber.stateNode; switch (parentFiber.tag) { case 5: @@ -5812,7 +5335,11 @@ function insertOrAppendPlacementNode(node, before, parent) { ) insertOrAppendPlacementNode(node, before, parent), (node = node.sibling); } -function unmountHostComponents(finishedRoot$jscomp$0, current) { +function unmountHostComponents( + finishedRoot$jscomp$0, + current, + renderPriorityLevel$jscomp$0 +) { for ( var node = current, currentParentIsValid = !1, @@ -5850,12 +5377,13 @@ function unmountHostComponents(finishedRoot$jscomp$0, current) { a: for ( var finishedRoot = finishedRoot$jscomp$0, root = node, + renderPriorityLevel = renderPriorityLevel$jscomp$0, node$jscomp$0 = root; ; ) if ( - (commitUnmount(finishedRoot, node$jscomp$0), + (commitUnmount(finishedRoot, node$jscomp$0, renderPriorityLevel), null !== node$jscomp$0.child && 4 !== node$jscomp$0.tag) ) (node$jscomp$0.child.return = node$jscomp$0), @@ -5882,18 +5410,18 @@ function unmountHostComponents(finishedRoot$jscomp$0, current) { [0] )) : ((finishedRoot = currentParent), - (node$jscomp$0 = node.stateNode), - recursivelyUncacheFiberNode(node$jscomp$0), + (renderPriorityLevel = node.stateNode), + recursivelyUncacheFiberNode(renderPriorityLevel), (root = finishedRoot._children), - (node$jscomp$0 = root.indexOf(node$jscomp$0)), - root.splice(node$jscomp$0, 1), + (renderPriorityLevel = root.indexOf(renderPriorityLevel)), + root.splice(renderPriorityLevel, 1), ReactNativePrivateInterface.UIManager.manageChildren( finishedRoot._nativeTag, [], [], [], [], - [node$jscomp$0] + [renderPriorityLevel] )); } else if (4 === node.tag) { if (null !== node.child) { @@ -5904,7 +5432,8 @@ function unmountHostComponents(finishedRoot$jscomp$0, current) { continue; } } else if ( - (commitUnmount(finishedRoot$jscomp$0, node), null !== node.child) + (commitUnmount(finishedRoot$jscomp$0, node, renderPriorityLevel$jscomp$0), + null !== node.child) ) { node.child.return = node; node = node.child; @@ -5927,42 +5456,31 @@ function commitWork(current, finishedWork) { case 14: case 15: case 22: - var updateQueue = finishedWork.updateQueue; - updateQueue = null !== updateQueue ? updateQueue.lastEffect : null; - if (null !== updateQueue) { - var effect = (updateQueue = updateQueue.next); - do - 3 === (effect.tag & 3) && - ((finishedWork = effect.destroy), - (effect.destroy = void 0), - void 0 !== finishedWork && finishedWork()), - (effect = effect.next); - while (effect !== updateQueue); - } + commitHookEffectListUnmount(3, finishedWork); return; case 1: return; case 5: - updateQueue = finishedWork.stateNode; - if (null != updateQueue) { - effect = finishedWork.memoizedProps; - current = null !== current ? current.memoizedProps : effect; + var instance = finishedWork.stateNode; + if (null != instance) { + var newProps = finishedWork.memoizedProps; + current = null !== current ? current.memoizedProps : newProps; var updatePayload = finishedWork.updateQueue; finishedWork.updateQueue = null; null !== updatePayload && - ((finishedWork = updateQueue.viewConfig), - instanceProps.set(updateQueue._nativeTag, effect), - (effect = diffProperties( + ((finishedWork = instance.viewConfig), + instanceProps.set(instance._nativeTag, newProps), + (newProps = diffProperties( null, current, - effect, + newProps, finishedWork.validAttributes )), - null != effect && + null != newProps && ReactNativePrivateInterface.UIManager.updateView( - updateQueue._nativeTag, + instance._nativeTag, finishedWork.uiViewClassName, - effect + newProps )); } return; @@ -5982,9 +5500,72 @@ function commitWork(current, finishedWork) { case 12: return; case 13: - null !== finishedWork.memoizedState && - ((globalMostRecentFallbackTime = now()), - hideOrUnhideAllChildren(finishedWork.child, !0)); + instance = finishedWork; + null === finishedWork.memoizedState + ? (newProps = !1) + : ((newProps = !0), + (instance = finishedWork.child), + (globalMostRecentFallbackTime = now())); + if (null !== instance) + a: for (current = instance; ; ) { + if (5 === current.tag) + if (((updatePayload = current.stateNode), newProps)) { + var viewConfig = updatePayload.viewConfig; + var updatePayload$jscomp$0 = diffProperties( + null, + emptyObject, + { style: { display: "none" } }, + viewConfig.validAttributes + ); + ReactNativePrivateInterface.UIManager.updateView( + updatePayload._nativeTag, + viewConfig.uiViewClassName, + updatePayload$jscomp$0 + ); + } else { + updatePayload = current.stateNode; + updatePayload$jscomp$0 = current.memoizedProps; + viewConfig = updatePayload.viewConfig; + var prevProps = Object.assign({}, updatePayload$jscomp$0, { + style: [updatePayload$jscomp$0.style, { display: "none" }] + }); + updatePayload$jscomp$0 = diffProperties( + null, + prevProps, + updatePayload$jscomp$0, + viewConfig.validAttributes + ); + ReactNativePrivateInterface.UIManager.updateView( + updatePayload._nativeTag, + viewConfig.uiViewClassName, + updatePayload$jscomp$0 + ); + } + else { + if (6 === current.tag) throw Error("Not yet implemented."); + if ( + 13 === current.tag && + null !== current.memoizedState && + null === current.memoizedState.dehydrated + ) { + updatePayload = current.child.sibling; + updatePayload.return = current; + current = updatePayload; + continue; + } else if (null !== current.child) { + current.child.return = current; + current = current.child; + continue; + } + } + if (current === instance) break; + for (; null === current.sibling; ) { + if (null === current.return || current.return === instance) break a; + current = current.return; + } + current.sibling.return = current.return; + current = current.sibling; + } attachSuspenseRetryListeners(finishedWork); return; case 19: @@ -5992,62 +5573,93 @@ function commitWork(current, finishedWork) { return; case 17: return; - case 23: - case 24: - hideOrUnhideAllChildren( - finishedWork, - null !== finishedWork.memoizedState - ); - return; } throw Error( "This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue." ); } function attachSuspenseRetryListeners(finishedWork) { - var wakeables = finishedWork.updateQueue; - if (null !== wakeables) { + var thenables = finishedWork.updateQueue; + if (null !== thenables) { finishedWork.updateQueue = null; var retryCache = finishedWork.stateNode; null === retryCache && (retryCache = finishedWork.stateNode = new PossiblyWeakSet()); - wakeables.forEach(function(wakeable) { - var retry = resolveRetryWakeable.bind(null, finishedWork, wakeable); - retryCache.has(wakeable) || - (!0 !== wakeable.__reactDoNotTraceInteractions && + thenables.forEach(function(thenable) { + var retry = resolveRetryThenable.bind(null, finishedWork, thenable); + retryCache.has(thenable) || + (!0 !== thenable.__reactDoNotTraceInteractions && (retry = tracing.unstable_wrap(retry)), - retryCache.add(wakeable), - wakeable.then(retry, retry)); + retryCache.add(thenable), + thenable.then(retry, retry)); }); } } -function isSuspenseBoundaryBeingHidden(current, finishedWork) { - return null !== current && - ((current = current.memoizedState), - null === current || null !== current.dehydrated) - ? ((finishedWork = finishedWork.memoizedState), - null !== finishedWork && null === finishedWork.dehydrated) - : !1; +var PossiblyWeakMap = "function" === typeof WeakMap ? WeakMap : Map; +function createRootErrorUpdate(fiber, errorInfo, expirationTime) { + expirationTime = createUpdate(expirationTime, null); + expirationTime.tag = 3; + expirationTime.payload = { element: null }; + var error = errorInfo.value; + expirationTime.callback = function() { + hasUncaughtError || ((hasUncaughtError = !0), (firstUncaughtError = error)); + logError(fiber, errorInfo); + }; + return expirationTime; +} +function createClassErrorUpdate(fiber, errorInfo, expirationTime) { + expirationTime = createUpdate(expirationTime, null); + expirationTime.tag = 3; + var getDerivedStateFromError = fiber.type.getDerivedStateFromError; + if ("function" === typeof getDerivedStateFromError) { + var error = errorInfo.value; + expirationTime.payload = function() { + logError(fiber, errorInfo); + return getDerivedStateFromError(error); + }; + } + var inst = fiber.stateNode; + null !== inst && + "function" === typeof inst.componentDidCatch && + (expirationTime.callback = function() { + "function" !== typeof getDerivedStateFromError && + (null === legacyErrorBoundariesThatAlreadyFailed + ? (legacyErrorBoundariesThatAlreadyFailed = new Set([this])) + : legacyErrorBoundariesThatAlreadyFailed.add(this), + logError(fiber, errorInfo)); + var stack = errorInfo.stack; + this.componentDidCatch(errorInfo.value, { + componentStack: null !== stack ? stack : "" + }); + }); + return expirationTime; } var ceil = Math.ceil, - ReactCurrentDispatcher$2 = ReactSharedInternals.ReactCurrentDispatcher, + ReactCurrentDispatcher$1 = ReactSharedInternals.ReactCurrentDispatcher, ReactCurrentOwner$2 = ReactSharedInternals.ReactCurrentOwner, - executionContext = 0, + NoContext = 0, + LegacyUnbatchedContext = 8, + RenderContext = 16, + CommitContext = 32, + RootIncomplete = 0, + RootFatalErrored = 1, + RootErrored = 2, + RootSuspended = 3, + RootSuspendedWithDelay = 4, + RootCompleted = 5, + executionContext = NoContext, workInProgressRoot = null, workInProgress = null, - workInProgressRootRenderLanes = 0, - subtreeRenderLanes = 0, - subtreeRenderLanesCursor = createCursor(0), - workInProgressRootExitStatus = 0, + renderExpirationTime$1 = 0, + workInProgressRootExitStatus = RootIncomplete, workInProgressRootFatalError = null, - workInProgressRootLatestSuspenseTimeout = -1, + workInProgressRootLatestProcessedExpirationTime = 1073741823, + workInProgressRootLatestSuspenseTimeout = 1073741823, workInProgressRootCanSuspendUsingConfig = null, - workInProgressRootIncludedLanes = 0, - workInProgressRootSkippedLanes = 0, - workInProgressRootUpdatedLanes = 0, - workInProgressRootPingedLanes = 0, - mostRecentlyUpdatedRoot = null, + workInProgressRootNextUnprocessedUpdateTime = 0, + workInProgressRootHasPendingPing = !1, globalMostRecentFallbackTime = 0, + FALLBACK_THROTTLE_MS = 500, nextEffect = null, hasUncaughtError = !1, firstUncaughtError = null, @@ -6055,208 +5667,201 @@ var ceil = Math.ceil, rootDoesHavePassiveEffects = !1, rootWithPendingPassiveEffects = null, pendingPassiveEffectsRenderPriority = 90, - pendingPassiveEffectsLanes = 0, - pendingPassiveHookEffectsMount = [], - pendingPassiveHookEffectsUnmount = [], + pendingPassiveEffectsExpirationTime = 0, rootsWithPendingDiscreteUpdates = null, nestedUpdateCount = 0, rootWithNestedUpdates = null, spawnedWorkDuringRender = null, - currentEventTime = -1, - currentEventWipLanes = 0, - currentEventPendingLanes = 0, - focusedInstanceHandle = null, - shouldFireAfterActiveInstanceBlur = !1; -function requestEventTime() { - return 0 !== (executionContext & 48) - ? now() - : -1 !== currentEventTime + currentEventTime = 0; +function requestCurrentTimeForUpdate() { + return (executionContext & (RenderContext | CommitContext)) !== NoContext + ? 1073741821 - ((now() / 10) | 0) + : 0 !== currentEventTime ? currentEventTime - : (currentEventTime = now()); + : (currentEventTime = 1073741821 - ((now() / 10) | 0)); } -function requestUpdateLane(fiber, suspenseConfig) { +function computeExpirationForFiber(currentTime, fiber, suspenseConfig) { fiber = fiber.mode; - if (0 === (fiber & 2)) return 1; - if (0 === (fiber & 4)) return 99 === getCurrentPriorityLevel() ? 1 : 2; - 0 === currentEventWipLanes && - (currentEventWipLanes = workInProgressRootIncludedLanes); - if (null !== suspenseConfig) { - suspenseConfig = suspenseConfig.timeoutMs; - fiber = void 0 === suspenseConfig || 1e4 > (suspenseConfig | 0) ? 8 : 6; - 0 !== currentEventPendingLanes && - (currentEventPendingLanes = - null !== mostRecentlyUpdatedRoot - ? mostRecentlyUpdatedRoot.pendingLanes - : 0); - suspenseConfig = currentEventWipLanes; - var pendingLanes = currentEventPendingLanes; - if (8 === fiber) - (fiber = pickArbitraryLane(122880 & ~pendingLanes)), - 0 === fiber && - ((fiber = pickArbitraryLane(122880 & ~suspenseConfig)), - 0 === fiber && (fiber = 8192)), - (suspenseConfig = fiber); - else if (6 === fiber) - (fiber = pickArbitraryLane(3932160 & ~pendingLanes)), - 0 === fiber && - ((fiber = pickArbitraryLane(3932160 & ~suspenseConfig)), - 0 === fiber && (fiber = 262144)), - (suspenseConfig = fiber); - else - throw Error( - "Invalid transition priority: " + fiber + ". This is a bug in React." - ); - return suspenseConfig; - } - suspenseConfig = getCurrentPriorityLevel(); - 0 !== (executionContext & 4) && 98 === suspenseConfig - ? (suspenseConfig = findUpdateLane(14, currentEventWipLanes)) - : ((suspenseConfig = schedulerPriorityToLanePriority(suspenseConfig)), - (suspenseConfig = findUpdateLane(suspenseConfig, currentEventWipLanes))); - return suspenseConfig; + if (0 === (fiber & 2)) return 1073741823; + var priorityLevel = getCurrentPriorityLevel(); + if (0 === (fiber & 4)) return 99 === priorityLevel ? 1073741823 : 1073741822; + if ((executionContext & RenderContext) !== NoContext) + return renderExpirationTime$1; + if (null !== suspenseConfig) + currentTime = + 1073741821 - + 25 * + ((((1073741821 - + currentTime + + (suspenseConfig.timeoutMs | 0 || 5e3) / 10) / + 25) | + 0) + + 1); + else + switch (priorityLevel) { + case 99: + currentTime = 1073741823; + break; + case 98: + currentTime = + 1073741821 - 10 * ((((1073741821 - currentTime + 15) / 10) | 0) + 1); + break; + case 97: + case 96: + currentTime = + 1073741821 - 25 * ((((1073741821 - currentTime + 500) / 25) | 0) + 1); + break; + case 95: + currentTime = 2; + break; + default: + throw Error("Expected a valid priority level"); + } + null !== workInProgressRoot && + currentTime === renderExpirationTime$1 && + --currentTime; + return currentTime; } -function scheduleUpdateOnFiber(fiber, lane, eventTime) { +function scheduleWork(fiber, expirationTime) { if (50 < nestedUpdateCount) throw ((nestedUpdateCount = 0), (rootWithNestedUpdates = null), Error( "Maximum update depth exceeded. This can happen when a component repeatedly calls setState inside componentWillUpdate or componentDidUpdate. React limits the number of nested updates to prevent infinite loops." )); - fiber = markUpdateLaneFromFiberToRoot(fiber, lane); - if (null === fiber) return null; - markRootUpdated(fiber, lane, eventTime); - fiber === workInProgressRoot && - ((workInProgressRootUpdatedLanes |= lane), - 4 === workInProgressRootExitStatus && - markRootSuspended$1(fiber, workInProgressRootRenderLanes)); - var priorityLevel = getCurrentPriorityLevel(); - 1 === lane - ? 0 !== (executionContext & 8) && 0 === (executionContext & 48) - ? (schedulePendingInteractions(fiber, lane), performSyncWorkOnRoot(fiber)) - : (ensureRootIsScheduled(fiber, eventTime), - schedulePendingInteractions(fiber, lane), - 0 === executionContext && flushSyncCallbackQueue()) - : (0 === (executionContext & 4) || - (98 !== priorityLevel && 99 !== priorityLevel) || - (null === rootsWithPendingDiscreteUpdates - ? (rootsWithPendingDiscreteUpdates = new Set([fiber])) - : rootsWithPendingDiscreteUpdates.add(fiber)), - ensureRootIsScheduled(fiber, eventTime), - schedulePendingInteractions(fiber, lane)); - mostRecentlyUpdatedRoot = fiber; -} -function markUpdateLaneFromFiberToRoot(sourceFiber, lane) { - sourceFiber.lanes |= lane; - var alternate = sourceFiber.alternate; - null !== alternate && (alternate.lanes |= lane); - alternate = sourceFiber; - for (sourceFiber = sourceFiber.return; null !== sourceFiber; ) - (sourceFiber.childLanes |= lane), - (alternate = sourceFiber.alternate), - null !== alternate && (alternate.childLanes |= lane), - (alternate = sourceFiber), - (sourceFiber = sourceFiber.return); - return 3 === alternate.tag ? alternate.stateNode : null; -} -function ensureRootIsScheduled(root, currentTime) { - for ( - var existingCallbackNode = root.callbackNode, - suspendedLanes = root.suspendedLanes, - pingedLanes = root.pingedLanes, - expirationTimes = root.expirationTimes, - lanes = root.pendingLanes; - 0 < lanes; - - ) { - var index$7 = 31 - clz32(lanes), - lane = 1 << index$7, - expirationTime = expirationTimes[index$7]; - if (-1 === expirationTime) { - if (0 === (lane & suspendedLanes) || 0 !== (lane & pingedLanes)) { - expirationTime = currentTime; - getHighestPriorityLanes(lane); - var priority = return_highestLanePriority; - expirationTimes[index$7] = - 12 <= priority - ? expirationTime + 1e3 - : 6 <= priority - ? expirationTime + 5e3 - : -1; - } - } else expirationTime <= currentTime && (root.expiredLanes |= lane); - lanes &= ~lane; + fiber = markUpdateTimeFromFiberToRoot(fiber, expirationTime); + if (null !== fiber) { + var priorityLevel = getCurrentPriorityLevel(); + 1073741823 === expirationTime + ? (executionContext & LegacyUnbatchedContext) !== NoContext && + (executionContext & (RenderContext | CommitContext)) === NoContext + ? (schedulePendingInteractions(fiber, expirationTime), + performSyncWorkOnRoot(fiber)) + : (ensureRootIsScheduled(fiber), + schedulePendingInteractions(fiber, expirationTime), + executionContext === NoContext && flushSyncCallbackQueue()) + : (ensureRootIsScheduled(fiber), + schedulePendingInteractions(fiber, expirationTime)); + (executionContext & 4) === NoContext || + (98 !== priorityLevel && 99 !== priorityLevel) || + (null === rootsWithPendingDiscreteUpdates + ? (rootsWithPendingDiscreteUpdates = new Map([[fiber, expirationTime]])) + : ((priorityLevel = rootsWithPendingDiscreteUpdates.get(fiber)), + (void 0 === priorityLevel || priorityLevel > expirationTime) && + rootsWithPendingDiscreteUpdates.set(fiber, expirationTime))); } - suspendedLanes = getNextLanes( - root, - root === workInProgressRoot ? workInProgressRootRenderLanes : 0 - ); - currentTime = return_highestLanePriority; - if (0 === suspendedLanes) - null !== existingCallbackNode && - (existingCallbackNode !== fakeCallbackNode && - Scheduler_cancelCallback(existingCallbackNode), - (root.callbackNode = null), - (root.callbackPriority = 0)); +} +function markUpdateTimeFromFiberToRoot(fiber, expirationTime) { + fiber.expirationTime < expirationTime && + (fiber.expirationTime = expirationTime); + var alternate = fiber.alternate; + null !== alternate && + alternate.expirationTime < expirationTime && + (alternate.expirationTime = expirationTime); + var node = fiber.return, + root = null; + if (null === node && 3 === fiber.tag) root = fiber.stateNode; + else + for (; null !== node; ) { + alternate = node.alternate; + node.childExpirationTime < expirationTime && + (node.childExpirationTime = expirationTime); + null !== alternate && + alternate.childExpirationTime < expirationTime && + (alternate.childExpirationTime = expirationTime); + if (null === node.return && 3 === node.tag) { + root = node.stateNode; + break; + } + node = node.return; + } + null !== root && + (workInProgressRoot === root && + (markUnprocessedUpdateTime(expirationTime), + workInProgressRootExitStatus === RootSuspendedWithDelay && + markRootSuspendedAtTime(root, renderExpirationTime$1)), + markRootUpdatedAtTime(root, expirationTime)); + return root; +} +function getNextRootExpirationTimeToWorkOn(root) { + var lastExpiredTime = root.lastExpiredTime; + if (0 !== lastExpiredTime) return lastExpiredTime; + lastExpiredTime = root.firstPendingTime; + if (!isRootSuspendedAtTime(root, lastExpiredTime)) return lastExpiredTime; + var lastPingedTime = root.lastPingedTime; + root = root.nextKnownPendingLevel; + root = lastPingedTime > root ? lastPingedTime : root; + return 2 >= root && lastExpiredTime !== root ? 0 : root; +} +function ensureRootIsScheduled(root) { + if (0 !== root.lastExpiredTime) + (root.callbackExpirationTime = 1073741823), + (root.callbackPriority = 99), + (root.callbackNode = scheduleSyncCallback( + performSyncWorkOnRoot.bind(null, root) + )); else { - if (null !== existingCallbackNode) { - if (root.callbackPriority === currentTime) return; - existingCallbackNode !== fakeCallbackNode && - Scheduler_cancelCallback(existingCallbackNode); + var expirationTime = getNextRootExpirationTimeToWorkOn(root), + existingCallbackNode = root.callbackNode; + if (0 === expirationTime) + null !== existingCallbackNode && + ((root.callbackNode = null), + (root.callbackExpirationTime = 0), + (root.callbackPriority = 90)); + else { + var currentTime = requestCurrentTimeForUpdate(); + currentTime = inferPriorityFromExpirationTime( + currentTime, + expirationTime + ); + if (null !== existingCallbackNode) { + var existingCallbackPriority = root.callbackPriority; + if ( + root.callbackExpirationTime === expirationTime && + existingCallbackPriority >= currentTime + ) + return; + existingCallbackNode !== fakeCallbackNode && + Scheduler_cancelCallback(existingCallbackNode); + } + root.callbackExpirationTime = expirationTime; + root.callbackPriority = currentTime; + expirationTime = + 1073741823 === expirationTime + ? scheduleSyncCallback(performSyncWorkOnRoot.bind(null, root)) + : scheduleCallback( + currentTime, + performConcurrentWorkOnRoot.bind(null, root), + { timeout: 10 * (1073741821 - expirationTime) - now() } + ); + root.callbackNode = expirationTime; } - 17 === currentTime - ? ((existingCallbackNode = performSyncWorkOnRoot.bind(null, root)), - null === syncQueue - ? ((syncQueue = [existingCallbackNode]), - (immediateQueueCallbackNode = Scheduler_scheduleCallback( - Scheduler_ImmediatePriority, - flushSyncCallbackQueueImpl - ))) - : syncQueue.push(existingCallbackNode), - (existingCallbackNode = fakeCallbackNode)) - : 16 === currentTime - ? (existingCallbackNode = scheduleCallback( - 99, - performSyncWorkOnRoot.bind(null, root) - )) - : ((existingCallbackNode = lanePriorityToSchedulerPriority(currentTime)), - (existingCallbackNode = scheduleCallback( - existingCallbackNode, - performConcurrentWorkOnRoot.bind(null, root) - ))); - root.callbackPriority = currentTime; - root.callbackNode = existingCallbackNode; } } function performConcurrentWorkOnRoot(root, didTimeout) { - currentEventTime = -1; - currentEventPendingLanes = currentEventWipLanes = 0; - if (0 !== (executionContext & 48)) - throw Error("Should not already be working."); - var originalCallbackNode = root.callbackNode; - if (flushPassiveEffects() && root.callbackNode !== originalCallbackNode) + currentEventTime = 0; + if (didTimeout) { + didTimeout = requestCurrentTimeForUpdate(); + var lastExpiredTime = root.lastExpiredTime; + if (0 === lastExpiredTime || lastExpiredTime > didTimeout) + root.lastExpiredTime = didTimeout; + ensureRootIsScheduled(root); return null; - var lanes = getNextLanes( - root, - root === workInProgressRoot ? workInProgressRootRenderLanes : 0 - ); - if (0 === lanes) return null; - if (didTimeout) - return ( - (root.expiredLanes |= lanes & root.pendingLanes), - ensureRootIsScheduled(root, now()), - null - ); - var lanes$jscomp$0 = lanes; - didTimeout = executionContext; - executionContext |= 16; - var prevDispatcher = pushDispatcher(); - if ( - workInProgressRoot !== root || - workInProgressRootRenderLanes !== lanes$jscomp$0 - ) - prepareFreshStack(root, lanes$jscomp$0), - startWorkOnPendingInteractions(root, lanes$jscomp$0); - lanes$jscomp$0 = pushInteractions(root); + } + lastExpiredTime = getNextRootExpirationTimeToWorkOn(root); + if (0 === lastExpiredTime) return null; + didTimeout = root.callbackNode; + if ((executionContext & (RenderContext | CommitContext)) !== NoContext) + throw Error("Should not already be working."); + flushPassiveEffects(); + var expirationTime = lastExpiredTime, + prevExecutionContext = executionContext; + executionContext |= RenderContext; + var exitStatus = pushDispatcher(); + if (root !== workInProgressRoot || expirationTime !== renderExpirationTime$1) + prepareFreshStack(root, expirationTime), + startWorkOnPendingInteractions(root, expirationTime); + expirationTime = pushInteractions(root); do try { workLoopConcurrent(); @@ -6266,190 +5871,205 @@ function performConcurrentWorkOnRoot(root, didTimeout) { } while (1); resetContextDependencies(); - tracing.__interactionsRef.current = lanes$jscomp$0; - ReactCurrentDispatcher$2.current = prevDispatcher; - executionContext = didTimeout; + tracing.__interactionsRef.current = expirationTime; + ReactCurrentDispatcher$1.current = exitStatus; + executionContext = prevExecutionContext; null !== workInProgress - ? (didTimeout = 0) + ? (exitStatus = RootIncomplete) : ((workInProgressRoot = null), - (workInProgressRootRenderLanes = 0), - (didTimeout = workInProgressRootExitStatus)); - if (0 !== (workInProgressRootIncludedLanes & workInProgressRootUpdatedLanes)) - prepareFreshStack(root, 0); - else if (0 !== didTimeout) { - 2 === didTimeout && - ((executionContext |= 64), - root.hydrate && (root.hydrate = !1), - (lanes = getLanesToRetrySynchronouslyOnError(root)), - 0 !== lanes && (didTimeout = renderRootSync(root, lanes))); - if (1 === didTimeout) - throw ((originalCallbackNode = workInProgressRootFatalError), - prepareFreshStack(root, 0), - markRootSuspended$1(root, lanes), - ensureRootIsScheduled(root, now()), - originalCallbackNode); - root.finishedWork = root.current.alternate; - root.finishedLanes = lanes; - switch (didTimeout) { - case 0: - case 1: + (exitStatus = workInProgressRootExitStatus)); + if (exitStatus !== RootIncomplete) { + exitStatus === RootErrored && + ((lastExpiredTime = 2 < lastExpiredTime ? 2 : lastExpiredTime), + (exitStatus = renderRootSync(root, lastExpiredTime))); + if (exitStatus === RootFatalErrored) + throw ((didTimeout = workInProgressRootFatalError), + prepareFreshStack(root, lastExpiredTime), + markRootSuspendedAtTime(root, lastExpiredTime), + ensureRootIsScheduled(root), + didTimeout); + prevExecutionContext = root.finishedWork = root.current.alternate; + root.finishedExpirationTime = lastExpiredTime; + switch (exitStatus) { + case RootIncomplete: + case RootFatalErrored: throw Error("Root did not complete. This is a bug in React."); - case 2: + case RootErrored: commitRoot(root); break; - case 3: - markRootSuspended$1(root, lanes); + case RootSuspended: + markRootSuspendedAtTime(root, lastExpiredTime); + exitStatus = root.lastSuspendedTime; + lastExpiredTime === exitStatus && + (root.nextKnownPendingLevel = getRemainingExpirationTime( + prevExecutionContext + )); if ( - (lanes & 62914560) === lanes && - ((didTimeout = globalMostRecentFallbackTime + 500 - now()), - 10 < didTimeout) + 1073741823 === workInProgressRootLatestProcessedExpirationTime && + ((prevExecutionContext = + globalMostRecentFallbackTime + FALLBACK_THROTTLE_MS - now()), + 10 < prevExecutionContext) ) { - if (0 !== getNextLanes(root, 0)) break; - prevDispatcher = root.suspendedLanes; - if ((prevDispatcher & lanes) !== lanes) { - requestEventTime(); - root.pingedLanes |= root.suspendedLanes & prevDispatcher; + if ( + workInProgressRootHasPendingPing && + ((expirationTime = root.lastPingedTime), + 0 === expirationTime || expirationTime >= lastExpiredTime) + ) { + root.lastPingedTime = lastExpiredTime; + prepareFreshStack(root, lastExpiredTime); + break; + } + expirationTime = getNextRootExpirationTimeToWorkOn(root); + if (0 !== expirationTime && expirationTime !== lastExpiredTime) break; + if (0 !== exitStatus && exitStatus !== lastExpiredTime) { + root.lastPingedTime = exitStatus; break; } root.timeoutHandle = scheduleTimeout( commitRoot.bind(null, root), - didTimeout + prevExecutionContext ); break; } commitRoot(root); break; - case 4: - markRootSuspended$1(root, lanes); - if (0 !== getNextLanes(root, 0)) break; - didTimeout = root.suspendedLanes; - if ((didTimeout & lanes) !== lanes) { - requestEventTime(); - root.pingedLanes |= root.suspendedLanes & didTimeout; - break; - } - lanes = getMostRecentEventTime(root, lanes); - -1 !== workInProgressRootLatestSuspenseTimeout - ? (lanes = workInProgressRootLatestSuspenseTimeout - now()) - : -1 === lanes - ? (lanes = 0) - : ((lanes = now() - lanes), - (lanes = - (120 > lanes - ? 120 - : 480 > lanes - ? 480 - : 1080 > lanes - ? 1080 - : 1920 > lanes - ? 1920 - : 3e3 > lanes - ? 3e3 - : 4320 > lanes - ? 4320 - : 1960 * ceil(lanes / 1960)) - lanes)); - if (10 < lanes) { - root.timeoutHandle = scheduleTimeout( - commitRoot.bind(null, root), - lanes - ); - break; - } - commitRoot(root); - break; - case 5: - lanes$jscomp$0 = getMostRecentEventTime(root, lanes); + case RootSuspendedWithDelay: + markRootSuspendedAtTime(root, lastExpiredTime); + exitStatus = root.lastSuspendedTime; + lastExpiredTime === exitStatus && + (root.nextKnownPendingLevel = getRemainingExpirationTime( + prevExecutionContext + )); if ( - -1 !== lanes$jscomp$0 && - null !== workInProgressRootCanSuspendUsingConfig && - ((didTimeout = - workInProgressRootCanSuspendUsingConfig.busyMinDurationMs | 0), - 0 >= didTimeout - ? (didTimeout = 0) - : ((prevDispatcher = - workInProgressRootCanSuspendUsingConfig.busyDelayMs | 0), - (lanes$jscomp$0 = now() - lanes$jscomp$0), - (didTimeout = - lanes$jscomp$0 <= prevDispatcher - ? 0 - : prevDispatcher + didTimeout - lanes$jscomp$0)), - 10 < didTimeout) + workInProgressRootHasPendingPing && + ((prevExecutionContext = root.lastPingedTime), + 0 === prevExecutionContext || prevExecutionContext >= lastExpiredTime) ) { - markRootSuspended$1(root, lanes); + root.lastPingedTime = lastExpiredTime; + prepareFreshStack(root, lastExpiredTime); + break; + } + prevExecutionContext = getNextRootExpirationTimeToWorkOn(root); + if ( + 0 !== prevExecutionContext && + prevExecutionContext !== lastExpiredTime + ) + break; + if (0 !== exitStatus && exitStatus !== lastExpiredTime) { + root.lastPingedTime = exitStatus; + break; + } + 1073741823 !== workInProgressRootLatestSuspenseTimeout + ? (prevExecutionContext = + 10 * (1073741821 - workInProgressRootLatestSuspenseTimeout) - + now()) + : 1073741823 === workInProgressRootLatestProcessedExpirationTime + ? (prevExecutionContext = 0) + : ((prevExecutionContext = + 10 * + (1073741821 - workInProgressRootLatestProcessedExpirationTime) - + 5e3), + (exitStatus = now()), + (lastExpiredTime = + 10 * (1073741821 - lastExpiredTime) - exitStatus), + (prevExecutionContext = exitStatus - prevExecutionContext), + 0 > prevExecutionContext && (prevExecutionContext = 0), + (prevExecutionContext = + (120 > prevExecutionContext + ? 120 + : 480 > prevExecutionContext + ? 480 + : 1080 > prevExecutionContext + ? 1080 + : 1920 > prevExecutionContext + ? 1920 + : 3e3 > prevExecutionContext + ? 3e3 + : 4320 > prevExecutionContext + ? 4320 + : 1960 * ceil(prevExecutionContext / 1960)) - + prevExecutionContext), + lastExpiredTime < prevExecutionContext && + (prevExecutionContext = lastExpiredTime)); + if (10 < prevExecutionContext) { root.timeoutHandle = scheduleTimeout( commitRoot.bind(null, root), - didTimeout + prevExecutionContext ); break; } commitRoot(root); break; + case RootCompleted: + if ( + 1073741823 !== workInProgressRootLatestProcessedExpirationTime && + null !== workInProgressRootCanSuspendUsingConfig + ) { + expirationTime = workInProgressRootLatestProcessedExpirationTime; + var suspenseConfig = workInProgressRootCanSuspendUsingConfig; + prevExecutionContext = suspenseConfig.busyMinDurationMs | 0; + 0 >= prevExecutionContext + ? (prevExecutionContext = 0) + : ((exitStatus = suspenseConfig.busyDelayMs | 0), + (expirationTime = + now() - + (10 * (1073741821 - expirationTime) - + (suspenseConfig.timeoutMs | 0 || 5e3))), + (prevExecutionContext = + expirationTime <= exitStatus + ? 0 + : exitStatus + prevExecutionContext - expirationTime)); + if (10 < prevExecutionContext) { + markRootSuspendedAtTime(root, lastExpiredTime); + root.timeoutHandle = scheduleTimeout( + commitRoot.bind(null, root), + prevExecutionContext + ); + break; + } + } + commitRoot(root); + break; default: throw Error("Unknown root exit status."); } } - ensureRootIsScheduled(root, now()); - return root.callbackNode === originalCallbackNode + ensureRootIsScheduled(root); + return root.callbackNode === didTimeout ? performConcurrentWorkOnRoot.bind(null, root) : null; } -function markRootSuspended$1(root, suspendedLanes) { - suspendedLanes &= ~workInProgressRootPingedLanes; - suspendedLanes &= ~workInProgressRootUpdatedLanes; - root.suspendedLanes |= suspendedLanes; - root.pingedLanes &= ~suspendedLanes; - for (root = root.expirationTimes; 0 < suspendedLanes; ) { - var index$12 = 31 - clz32(suspendedLanes), - lane = 1 << index$12; - root[index$12] = -1; - suspendedLanes &= ~lane; - } -} function performSyncWorkOnRoot(root) { - if (0 !== (executionContext & 48)) + if ((executionContext & (RenderContext | CommitContext)) !== NoContext) throw Error("Should not already be working."); flushPassiveEffects(); - if ( - root === workInProgressRoot && - 0 !== (root.expiredLanes & workInProgressRootRenderLanes) - ) { - var lanes = workInProgressRootRenderLanes; - var exitStatus = renderRootSync(root, lanes); - 0 !== (workInProgressRootIncludedLanes & workInProgressRootUpdatedLanes) && - ((lanes = getNextLanes(root, lanes)), - (exitStatus = renderRootSync(root, lanes))); - } else - (lanes = getNextLanes(root, 0)), (exitStatus = renderRootSync(root, lanes)); + var lastExpiredTime = root.lastExpiredTime; + lastExpiredTime = + 0 !== lastExpiredTime + ? root === workInProgressRoot && renderExpirationTime$1 >= lastExpiredTime + ? renderExpirationTime$1 + : lastExpiredTime + : 1073741823; + var exitStatus = renderRootSync(root, lastExpiredTime); 0 !== root.tag && - 2 === exitStatus && - ((executionContext |= 64), - root.hydrate && (root.hydrate = !1), - (lanes = getLanesToRetrySynchronouslyOnError(root)), - 0 !== lanes && (exitStatus = renderRootSync(root, lanes))); - if (1 === exitStatus) + exitStatus === RootErrored && + ((lastExpiredTime = 2 < lastExpiredTime ? 2 : lastExpiredTime), + (exitStatus = renderRootSync(root, lastExpiredTime))); + if (exitStatus === RootFatalErrored) throw ((exitStatus = workInProgressRootFatalError), - prepareFreshStack(root, 0), - markRootSuspended$1(root, lanes), - ensureRootIsScheduled(root, now()), + prepareFreshStack(root, lastExpiredTime), + markRootSuspendedAtTime(root, lastExpiredTime), + ensureRootIsScheduled(root), exitStatus); root.finishedWork = root.current.alternate; - root.finishedLanes = lanes; + root.finishedExpirationTime = lastExpiredTime; commitRoot(root); - ensureRootIsScheduled(root, now()); + ensureRootIsScheduled(root); return null; } -function pushRenderLanes(fiber, lanes) { - push(subtreeRenderLanesCursor, subtreeRenderLanes); - subtreeRenderLanes |= lanes; - workInProgressRootIncludedLanes |= lanes; -} -function popRenderLanes() { - subtreeRenderLanes = subtreeRenderLanesCursor.current; - pop(subtreeRenderLanesCursor); -} -function prepareFreshStack(root, lanes) { +function prepareFreshStack(root, expirationTime) { root.finishedWork = null; - root.finishedLanes = 0; + root.finishedExpirationTime = 0; var timeoutHandle = root.timeoutHandle; -1 !== timeoutHandle && ((root.timeoutHandle = -1), cancelTimeout(timeoutHandle)); @@ -6467,7 +6087,6 @@ function prepareFreshStack(root, lanes) { popHostContainer(); pop(didPerformWorkStackCursor); pop(contextStackCursor); - resetWorkInProgressVersions(); break; case 5: popHostContext(interruptedWork); @@ -6483,30 +6102,26 @@ function prepareFreshStack(root, lanes) { break; case 10: popProvider(interruptedWork); - break; - case 23: - case 24: - popRenderLanes(); } timeoutHandle = timeoutHandle.return; } workInProgressRoot = root; workInProgress = createWorkInProgress(root.current, null); - workInProgressRootRenderLanes = subtreeRenderLanes = workInProgressRootIncludedLanes = lanes; - workInProgressRootExitStatus = 0; + renderExpirationTime$1 = expirationTime; + workInProgressRootExitStatus = RootIncomplete; workInProgressRootFatalError = null; - workInProgressRootLatestSuspenseTimeout = -1; + workInProgressRootLatestSuspenseTimeout = workInProgressRootLatestProcessedExpirationTime = 1073741823; workInProgressRootCanSuspendUsingConfig = null; - workInProgressRootPingedLanes = workInProgressRootUpdatedLanes = workInProgressRootSkippedLanes = 0; + workInProgressRootNextUnprocessedUpdateTime = 0; + workInProgressRootHasPendingPing = !1; spawnedWorkDuringRender = null; } function handleError(root$jscomp$0, thrownValue) { do { - var erroredWork = workInProgress; try { resetContextDependencies(); - ReactCurrentDispatcher$1.current = ContextOnlyDispatcher; - if (didScheduleRenderPhaseUpdate) { + ReactCurrentDispatcher.current = ContextOnlyDispatcher; + if (didScheduleRenderPhaseUpdate) for ( var hook = currentlyRenderingFiber$1.memoizedState; null !== hook; @@ -6516,26 +6131,23 @@ function handleError(root$jscomp$0, thrownValue) { null !== queue && (queue.pending = null); hook = hook.next; } - didScheduleRenderPhaseUpdate = !1; - } - renderLanes = 0; + renderExpirationTime = 0; workInProgressHook = currentHook = currentlyRenderingFiber$1 = null; - didScheduleRenderPhaseUpdateDuringThisPass = !1; - ReactCurrentOwner$2.current = null; - if (null === erroredWork || null === erroredWork.return) { - workInProgressRootExitStatus = 1; - workInProgressRootFatalError = thrownValue; - workInProgress = null; - break; - } - erroredWork.mode & 8 && - stopProfilerTimerIfRunningAndRecordDelta(erroredWork, !0); + didScheduleRenderPhaseUpdate = !1; + if (null === workInProgress || null === workInProgress.return) + return ( + (workInProgressRootExitStatus = RootFatalErrored), + (workInProgressRootFatalError = thrownValue), + (workInProgress = null) + ); + workInProgress.mode & 8 && + stopProfilerTimerIfRunningAndRecordDelta(workInProgress, !0); a: { var root = root$jscomp$0, - returnFiber = erroredWork.return, - sourceFiber = erroredWork, + returnFiber = workInProgress.return, + sourceFiber = workInProgress, value = thrownValue; - thrownValue = workInProgressRootRenderLanes; + thrownValue = renderExpirationTime$1; sourceFiber.effectTag |= 2048; sourceFiber.firstEffect = sourceFiber.lastEffect = null; if ( @@ -6543,27 +6155,27 @@ function handleError(root$jscomp$0, thrownValue) { "object" === typeof value && "function" === typeof value.then ) { - var wakeable = value; + var thenable = value; if (0 === (sourceFiber.mode & 2)) { var currentSource = sourceFiber.alternate; currentSource ? ((sourceFiber.updateQueue = currentSource.updateQueue), (sourceFiber.memoizedState = currentSource.memoizedState), - (sourceFiber.lanes = currentSource.lanes)) + (sourceFiber.expirationTime = currentSource.expirationTime)) : ((sourceFiber.updateQueue = null), (sourceFiber.memoizedState = null)); } var hasInvisibleParentBoundary = 0 !== (suspenseStackCursor.current & 1), - workInProgress$77 = returnFiber; + _workInProgress = returnFiber; do { var JSCompiler_temp; - if ((JSCompiler_temp = 13 === workInProgress$77.tag)) { - var nextState = workInProgress$77.memoizedState; + if ((JSCompiler_temp = 13 === _workInProgress.tag)) { + var nextState = _workInProgress.memoizedState; if (null !== nextState) JSCompiler_temp = null !== nextState.dehydrated ? !0 : !1; else { - var props = workInProgress$77.memoizedProps; + var props = _workInProgress.memoizedProps; JSCompiler_temp = void 0 === props.fallback ? !1 @@ -6575,24 +6187,23 @@ function handleError(root$jscomp$0, thrownValue) { } } if (JSCompiler_temp) { - var wakeables = workInProgress$77.updateQueue; - if (null === wakeables) { + var thenables = _workInProgress.updateQueue; + if (null === thenables) { var updateQueue = new Set(); - updateQueue.add(wakeable); - workInProgress$77.updateQueue = updateQueue; - } else wakeables.add(wakeable); - if (0 === (workInProgress$77.mode & 2)) { - workInProgress$77.effectTag |= 64; - sourceFiber.effectTag |= 16384; + updateQueue.add(thenable); + _workInProgress.updateQueue = updateQueue; + } else thenables.add(thenable); + if (0 === (_workInProgress.mode & 2)) { + _workInProgress.effectTag |= 64; sourceFiber.effectTag &= -2981; if (1 === sourceFiber.tag) if (null === sourceFiber.alternate) sourceFiber.tag = 17; else { - var update = createUpdate(-1, 1, null); + var update = createUpdate(1073741823, null); update.tag = 2; enqueueUpdate(sourceFiber, update); } - sourceFiber.lanes |= 1; + sourceFiber.expirationTime = 1073741823; break a; } value = void 0; @@ -6601,90 +6212,86 @@ function handleError(root$jscomp$0, thrownValue) { null === pingCache ? ((pingCache = root.pingCache = new PossiblyWeakMap()), (value = new Set()), - pingCache.set(wakeable, value)) - : ((value = pingCache.get(wakeable)), + pingCache.set(thenable, value)) + : ((value = pingCache.get(thenable)), void 0 === value && - ((value = new Set()), pingCache.set(wakeable, value))); + ((value = new Set()), pingCache.set(thenable, value))); if (!value.has(sourceFiber)) { value.add(sourceFiber); var ping = pingSuspendedRoot.bind( null, root, - wakeable, + thenable, sourceFiber ); - wakeable.then(ping, ping); + thenable.then(ping, ping); } - workInProgress$77.effectTag |= 4096; - workInProgress$77.lanes = thrownValue; + _workInProgress.effectTag |= 4096; + _workInProgress.expirationTime = thrownValue; break a; } - workInProgress$77 = workInProgress$77.return; - } while (null !== workInProgress$77); + _workInProgress = _workInProgress.return; + } while (null !== _workInProgress); value = Error( (getComponentName(sourceFiber.type) || "A React component") + - " suspended while rendering, but no fallback UI was specified.\n\nAdd a component higher in the tree to provide a loading indicator or placeholder to display." + " 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) ); } - 5 !== workInProgressRootExitStatus && - (workInProgressRootExitStatus = 2); + workInProgressRootExitStatus !== RootCompleted && + (workInProgressRootExitStatus = RootErrored); value = createCapturedValue(value, sourceFiber); - workInProgress$77 = returnFiber; + _workInProgress = returnFiber; do { - switch (workInProgress$77.tag) { + switch (_workInProgress.tag) { case 3: - root = value; - workInProgress$77.effectTag |= 4096; - thrownValue &= -thrownValue; - workInProgress$77.lanes |= thrownValue; - var update$78 = createRootErrorUpdate( - workInProgress$77, - root, + thenable = value; + _workInProgress.effectTag |= 4096; + _workInProgress.expirationTime = thrownValue; + var _update = createRootErrorUpdate( + _workInProgress, + thenable, thrownValue ); - enqueueCapturedUpdate(workInProgress$77, update$78); + enqueueCapturedUpdate(_workInProgress, _update); break a; case 1: - root = value; - var ctor = workInProgress$77.type, - instance = workInProgress$77.stateNode; + thenable = value; + var ctor = _workInProgress.type, + instance = _workInProgress.stateNode; if ( - 0 === (workInProgress$77.effectTag & 64) && + 0 === (_workInProgress.effectTag & 64) && ("function" === typeof ctor.getDerivedStateFromError || (null !== instance && "function" === typeof instance.componentDidCatch && (null === legacyErrorBoundariesThatAlreadyFailed || !legacyErrorBoundariesThatAlreadyFailed.has(instance)))) ) { - workInProgress$77.effectTag |= 4096; - thrownValue &= -thrownValue; - workInProgress$77.lanes |= thrownValue; - var update$81 = createClassErrorUpdate( - workInProgress$77, - root, + _workInProgress.effectTag |= 4096; + _workInProgress.expirationTime = thrownValue; + var _update2 = createClassErrorUpdate( + _workInProgress, + thenable, thrownValue ); - enqueueCapturedUpdate(workInProgress$77, update$81); + enqueueCapturedUpdate(_workInProgress, _update2); break a; } } - workInProgress$77 = workInProgress$77.return; - } while (null !== workInProgress$77); + _workInProgress = _workInProgress.return; + } while (null !== _workInProgress); } - completeUnitOfWork(erroredWork); + workInProgress = completeUnitOfWork(workInProgress); } catch (yetAnotherThrownValue) { thrownValue = yetAnotherThrownValue; - workInProgress === erroredWork && - null !== erroredWork && - (workInProgress = erroredWork = erroredWork.return); continue; } break; } while (1); } function pushDispatcher() { - var prevDispatcher = ReactCurrentDispatcher$2.current; - ReactCurrentDispatcher$2.current = ContextOnlyDispatcher; + var prevDispatcher = ReactCurrentDispatcher$1.current; + ReactCurrentDispatcher$1.current = ContextOnlyDispatcher; return null === prevDispatcher ? ContextOnlyDispatcher : prevDispatcher; } function pushInteractions(root) { @@ -6692,20 +6299,28 @@ function pushInteractions(root) { tracing.__interactionsRef.current = root.memoizedInteractions; return prevInteractions; } -function markRenderEventTimeAndConfig(eventTime, suspenseConfig) { +function markRenderEventTimeAndConfig(expirationTime, suspenseConfig) { + expirationTime < workInProgressRootLatestProcessedExpirationTime && + 2 < expirationTime && + (workInProgressRootLatestProcessedExpirationTime = expirationTime); null !== suspenseConfig && - ((eventTime += suspenseConfig.timeoutMs | 0 || 5e3), - eventTime > workInProgressRootLatestSuspenseTimeout && - ((workInProgressRootLatestSuspenseTimeout = eventTime), - (workInProgressRootCanSuspendUsingConfig = suspenseConfig))); + expirationTime < workInProgressRootLatestSuspenseTimeout && + 2 < expirationTime && + ((workInProgressRootLatestSuspenseTimeout = expirationTime), + (workInProgressRootCanSuspendUsingConfig = suspenseConfig)); } -function renderRootSync(root, lanes) { +function markUnprocessedUpdateTime(expirationTime) { + expirationTime > workInProgressRootNextUnprocessedUpdateTime && + (workInProgressRootNextUnprocessedUpdateTime = expirationTime); +} +function renderRootSync(root, expirationTime) { var prevExecutionContext = executionContext; - executionContext |= 16; + executionContext |= RenderContext; var prevDispatcher = pushDispatcher(); - if (workInProgressRoot !== root || workInProgressRootRenderLanes !== lanes) - prepareFreshStack(root, lanes), startWorkOnPendingInteractions(root, lanes); - lanes = pushInteractions(root); + if (root !== workInProgressRoot || expirationTime !== renderExpirationTime$1) + prepareFreshStack(root, expirationTime), + startWorkOnPendingInteractions(root, expirationTime); + expirationTime = pushInteractions(root); do try { workLoopSync(); @@ -6715,197 +6330,187 @@ function renderRootSync(root, lanes) { } while (1); resetContextDependencies(); - tracing.__interactionsRef.current = lanes; + tracing.__interactionsRef.current = expirationTime; executionContext = prevExecutionContext; - ReactCurrentDispatcher$2.current = prevDispatcher; + ReactCurrentDispatcher$1.current = prevDispatcher; if (null !== workInProgress) throw Error( "Cannot commit an incomplete root. This error is likely caused by a bug in React. Please file an issue." ); workInProgressRoot = null; - workInProgressRootRenderLanes = 0; return workInProgressRootExitStatus; } function workLoopSync() { - for (; null !== workInProgress; ) performUnitOfWork(workInProgress); + for (; null !== workInProgress; ) + workInProgress = performUnitOfWork(workInProgress); } function workLoopConcurrent() { for (; null !== workInProgress && !Scheduler_shouldYield(); ) - performUnitOfWork(workInProgress); + workInProgress = performUnitOfWork(workInProgress); } function performUnitOfWork(unitOfWork) { var current = unitOfWork.alternate; 0 !== (unitOfWork.mode & 8) ? ((profilerStartTime = now$1()), 0 > unitOfWork.actualStartTime && (unitOfWork.actualStartTime = now$1()), - (current = beginWork$1(current, unitOfWork, subtreeRenderLanes)), + (current = beginWork$1(current, unitOfWork, renderExpirationTime$1)), stopProfilerTimerIfRunningAndRecordDelta(unitOfWork, !0)) - : (current = beginWork$1(current, unitOfWork, subtreeRenderLanes)); + : (current = beginWork$1(current, unitOfWork, renderExpirationTime$1)); unitOfWork.memoizedProps = unitOfWork.pendingProps; - null === current - ? completeUnitOfWork(unitOfWork) - : (workInProgress = current); + null === current && (current = completeUnitOfWork(unitOfWork)); ReactCurrentOwner$2.current = null; + return current; } function completeUnitOfWork(unitOfWork) { - var completedWork = unitOfWork; + workInProgress = unitOfWork; do { - var current = completedWork.alternate; - unitOfWork = completedWork.return; - if (0 === (completedWork.effectTag & 2048)) { - if (0 === (completedWork.mode & 8)) - current = completeWork(current, completedWork, subtreeRenderLanes); + var current = workInProgress.alternate; + unitOfWork = workInProgress.return; + if (0 === (workInProgress.effectTag & 2048)) { + if (0 === (workInProgress.mode & 8)) + current = completeWork(current, workInProgress, renderExpirationTime$1); else { - var fiber = completedWork; + var fiber = workInProgress; profilerStartTime = now$1(); 0 > fiber.actualStartTime && (fiber.actualStartTime = now$1()); - current = completeWork(current, completedWork, subtreeRenderLanes); - stopProfilerTimerIfRunningAndRecordDelta(completedWork, !1); + current = completeWork(current, workInProgress, renderExpirationTime$1); + stopProfilerTimerIfRunningAndRecordDelta(workInProgress, !1); } - if (null !== current) { - workInProgress = current; - return; - } - current = completedWork; - if ( - (24 !== current.tag && 23 !== current.tag) || - null === current.memoizedState || - 0 !== (subtreeRenderLanes & 1073741824) || - 0 === (current.mode & 4) - ) { - fiber = 0; - if (0 !== (current.mode & 8)) { + fiber = workInProgress; + if (1 === renderExpirationTime$1 || 1 !== fiber.childExpirationTime) { + var newChildExpirationTime = 0; + if (0 !== (fiber.mode & 8)) { for ( - var actualDuration = current.actualDuration, - treeBaseDuration = current.selfBaseDuration, + var actualDuration = fiber.actualDuration, + treeBaseDuration = fiber.selfBaseDuration, shouldBubbleActualDurations = - null === current.alternate || - current.child !== current.alternate.child, - child = current.child; + null === fiber.alternate || + fiber.child !== fiber.alternate.child, + child = fiber.child; null !== child; - ) - (fiber |= child.lanes | child.childLanes), - shouldBubbleActualDurations && - (actualDuration += child.actualDuration), - (treeBaseDuration += child.treeBaseDuration), - (child = child.sibling); - 13 === current.tag && - null !== current.memoizedState && - ((shouldBubbleActualDurations = current.child), - null !== shouldBubbleActualDurations && - (treeBaseDuration -= - shouldBubbleActualDurations.treeBaseDuration)); - current.actualDuration = actualDuration; - current.treeBaseDuration = treeBaseDuration; + ) { + var childUpdateExpirationTime = child.expirationTime, + childChildExpirationTime = child.childExpirationTime; + childUpdateExpirationTime > newChildExpirationTime && + (newChildExpirationTime = childUpdateExpirationTime); + childChildExpirationTime > newChildExpirationTime && + (newChildExpirationTime = childChildExpirationTime); + shouldBubbleActualDurations && + (actualDuration += child.actualDuration); + treeBaseDuration += child.treeBaseDuration; + child = child.sibling; + } + fiber.actualDuration = actualDuration; + fiber.treeBaseDuration = treeBaseDuration; } else - for (actualDuration = current.child; null !== actualDuration; ) - (fiber |= actualDuration.lanes | actualDuration.childLanes), + for (actualDuration = fiber.child; null !== actualDuration; ) + (treeBaseDuration = actualDuration.expirationTime), + (shouldBubbleActualDurations = + actualDuration.childExpirationTime), + treeBaseDuration > newChildExpirationTime && + (newChildExpirationTime = treeBaseDuration), + shouldBubbleActualDurations > newChildExpirationTime && + (newChildExpirationTime = shouldBubbleActualDurations), (actualDuration = actualDuration.sibling); - current.childLanes = fiber; + fiber.childExpirationTime = newChildExpirationTime; } + if (null !== current) return current; null !== unitOfWork && 0 === (unitOfWork.effectTag & 2048) && (null === unitOfWork.firstEffect && - (unitOfWork.firstEffect = completedWork.firstEffect), - null !== completedWork.lastEffect && + (unitOfWork.firstEffect = workInProgress.firstEffect), + null !== workInProgress.lastEffect && (null !== unitOfWork.lastEffect && - (unitOfWork.lastEffect.nextEffect = completedWork.firstEffect), - (unitOfWork.lastEffect = completedWork.lastEffect)), - 1 < completedWork.effectTag && + (unitOfWork.lastEffect.nextEffect = workInProgress.firstEffect), + (unitOfWork.lastEffect = workInProgress.lastEffect)), + 1 < workInProgress.effectTag && (null !== unitOfWork.lastEffect - ? (unitOfWork.lastEffect.nextEffect = completedWork) - : (unitOfWork.firstEffect = completedWork), - (unitOfWork.lastEffect = completedWork))); + ? (unitOfWork.lastEffect.nextEffect = workInProgress) + : (unitOfWork.firstEffect = workInProgress), + (unitOfWork.lastEffect = workInProgress))); } else { - current = unwindWork(completedWork); - if (null !== current) { - current.effectTag &= 2047; - workInProgress = current; - return; - } - if (0 !== (completedWork.mode & 8)) { - stopProfilerTimerIfRunningAndRecordDelta(completedWork, !1); - current = completedWork.actualDuration; - for (fiber = completedWork.child; null !== fiber; ) - (current += fiber.actualDuration), (fiber = fiber.sibling); - completedWork.actualDuration = current; + current = unwindWork(workInProgress); + if (0 !== (workInProgress.mode & 8)) { + stopProfilerTimerIfRunningAndRecordDelta(workInProgress, !1); + fiber = workInProgress.actualDuration; + for ( + newChildExpirationTime = workInProgress.child; + null !== newChildExpirationTime; + + ) + (fiber += newChildExpirationTime.actualDuration), + (newChildExpirationTime = newChildExpirationTime.sibling); + workInProgress.actualDuration = fiber; } + if (null !== current) return (current.effectTag &= 2047), current; null !== unitOfWork && ((unitOfWork.firstEffect = unitOfWork.lastEffect = null), (unitOfWork.effectTag |= 2048)); } - completedWork = completedWork.sibling; - if (null !== completedWork) { - workInProgress = completedWork; - return; - } - workInProgress = completedWork = unitOfWork; - } while (null !== completedWork); - 0 === workInProgressRootExitStatus && (workInProgressRootExitStatus = 5); + current = workInProgress.sibling; + if (null !== current) return current; + workInProgress = unitOfWork; + } while (null !== workInProgress); + workInProgressRootExitStatus === RootIncomplete && + (workInProgressRootExitStatus = RootCompleted); + return null; +} +function getRemainingExpirationTime(fiber) { + var updateExpirationTime = fiber.expirationTime; + fiber = fiber.childExpirationTime; + return updateExpirationTime > fiber ? updateExpirationTime : fiber; } function commitRoot(root) { var renderPriorityLevel = getCurrentPriorityLevel(); runWithPriority(99, commitRootImpl.bind(null, root, renderPriorityLevel)); return null; } -function commitRootImpl(root, renderPriorityLevel) { +function commitRootImpl(root$jscomp$0, renderPriorityLevel$jscomp$0) { do flushPassiveEffects(); while (null !== rootWithPendingPassiveEffects); - if (0 !== (executionContext & 48)) + if ((executionContext & (RenderContext | CommitContext)) !== NoContext) throw Error("Should not already be working."); - var finishedWork = root.finishedWork, - lanes = root.finishedLanes; + var finishedWork = root$jscomp$0.finishedWork, + expirationTime = root$jscomp$0.finishedExpirationTime; if (null === finishedWork) return null; - root.finishedWork = null; - root.finishedLanes = 0; - if (finishedWork === root.current) + root$jscomp$0.finishedWork = null; + root$jscomp$0.finishedExpirationTime = 0; + if (finishedWork === root$jscomp$0.current) throw Error( "Cannot commit the same tree as before. This error is likely caused by a bug in React. Please file an issue." ); - root.callbackNode = null; - var remainingLanes = finishedWork.lanes | finishedWork.childLanes, - remainingLanes$jscomp$0 = remainingLanes, - noLongerPendingLanes = root.pendingLanes & ~remainingLanes$jscomp$0; - root.pendingLanes = remainingLanes$jscomp$0; - root.suspendedLanes = 0; - root.pingedLanes = 0; - root.expiredLanes &= remainingLanes$jscomp$0; - root.mutableReadLanes &= remainingLanes$jscomp$0; - root.entangledLanes &= remainingLanes$jscomp$0; - remainingLanes$jscomp$0 = root.entanglements; - for ( - var eventTimes = root.eventTimes, expirationTimes = root.expirationTimes; - 0 < noLongerPendingLanes; - - ) { - var index$13 = 31 - clz32(noLongerPendingLanes), - lane = 1 << index$13; - remainingLanes$jscomp$0[index$13] = 0; - eventTimes[index$13] = -1; - expirationTimes[index$13] = -1; - noLongerPendingLanes &= ~lane; - } - null !== rootsWithPendingDiscreteUpdates && - 0 === (remainingLanes & 24) && - rootsWithPendingDiscreteUpdates.has(root) && - rootsWithPendingDiscreteUpdates.delete(root); - root === workInProgressRoot && + root$jscomp$0.callbackNode = null; + root$jscomp$0.callbackExpirationTime = 0; + root$jscomp$0.callbackPriority = 90; + root$jscomp$0.nextKnownPendingLevel = 0; + var remainingExpirationTimeBeforeCommit = getRemainingExpirationTime( + finishedWork + ); + root$jscomp$0.firstPendingTime = remainingExpirationTimeBeforeCommit; + expirationTime <= root$jscomp$0.lastSuspendedTime + ? (root$jscomp$0.firstSuspendedTime = root$jscomp$0.lastSuspendedTime = root$jscomp$0.nextKnownPendingLevel = 0) + : expirationTime <= root$jscomp$0.firstSuspendedTime && + (root$jscomp$0.firstSuspendedTime = expirationTime - 1); + expirationTime <= root$jscomp$0.lastPingedTime && + (root$jscomp$0.lastPingedTime = 0); + expirationTime <= root$jscomp$0.lastExpiredTime && + (root$jscomp$0.lastExpiredTime = 0); + root$jscomp$0 === workInProgressRoot && ((workInProgress = workInProgressRoot = null), - (workInProgressRootRenderLanes = 0)); + (renderExpirationTime$1 = 0)); 1 < finishedWork.effectTag ? null !== finishedWork.lastEffect ? ((finishedWork.lastEffect.nextEffect = finishedWork), - (remainingLanes = finishedWork.firstEffect)) - : (remainingLanes = finishedWork) - : (remainingLanes = finishedWork.firstEffect); - if (null !== remainingLanes) { - remainingLanes$jscomp$0 = executionContext; - executionContext |= 32; - eventTimes = pushInteractions(root); - focusedInstanceHandle = ReactCurrentOwner$2.current = null; - shouldFireAfterActiveInstanceBlur = !1; - nextEffect = remainingLanes; + (remainingExpirationTimeBeforeCommit = finishedWork.firstEffect)) + : (remainingExpirationTimeBeforeCommit = finishedWork) + : (remainingExpirationTimeBeforeCommit = finishedWork.firstEffect); + if (null !== remainingExpirationTimeBeforeCommit) { + var prevExecutionContext = executionContext; + executionContext |= CommitContext; + var prevInteractions = pushInteractions(root$jscomp$0); + ReactCurrentOwner$2.current = null; + nextEffect = remainingExpirationTimeBeforeCommit; do try { commitBeforeMutationEffects(); @@ -6915,12 +6520,16 @@ function commitRootImpl(root, renderPriorityLevel) { nextEffect = nextEffect.nextEffect; } while (null !== nextEffect); - focusedInstanceHandle = null; commitTime = now$1(); - nextEffect = remainingLanes; + nextEffect = remainingExpirationTimeBeforeCommit; do try { - for (expirationTimes = root; null !== nextEffect; ) { + for ( + var root = root$jscomp$0, + renderPriorityLevel = renderPriorityLevel$jscomp$0; + null !== nextEffect; + + ) { var effectTag = nextEffect.effectTag; if (effectTag & 128) { var current = nextEffect.alternate; @@ -6953,25 +6562,27 @@ function commitRootImpl(root, renderPriorityLevel) { commitWork(nextEffect.alternate, nextEffect); break; case 8: - noLongerPendingLanes = nextEffect; - unmountHostComponents(expirationTimes, noLongerPendingLanes); - var alternate = noLongerPendingLanes.alternate; - detachFiberMutation(noLongerPendingLanes); - null !== alternate && detachFiberMutation(alternate); + var current$jscomp$0 = nextEffect; + unmountHostComponents( + root, + current$jscomp$0, + renderPriorityLevel + ); + detachFiber(current$jscomp$0); } nextEffect = nextEffect.nextEffect; } - } catch (error$96) { + } catch (error) { if (null === nextEffect) throw Error("Should be working on an effect."); - captureCommitPhaseError(nextEffect, error$96); + captureCommitPhaseError(nextEffect, error); nextEffect = nextEffect.nextEffect; } while (null !== nextEffect); - root.current = finishedWork; - nextEffect = remainingLanes; + root$jscomp$0.current = finishedWork; + nextEffect = remainingExpirationTimeBeforeCommit; do try { - for (effectTag = root; null !== nextEffect; ) { + for (effectTag = root$jscomp$0; null !== nextEffect; ) { var effectTag$jscomp$0 = nextEffect.effectTag; effectTag$jscomp$0 & 36 && commitLifeCycles(effectTag, nextEffect.alternate, nextEffect); @@ -6994,82 +6605,72 @@ function commitRootImpl(root, renderPriorityLevel) { } nextEffect = nextEffect.nextEffect; } - } catch (error$97) { + } catch (error) { if (null === nextEffect) throw Error("Should be working on an effect."); - captureCommitPhaseError(nextEffect, error$97); + captureCommitPhaseError(nextEffect, error); nextEffect = nextEffect.nextEffect; } while (null !== nextEffect); nextEffect = null; requestPaint(); - tracing.__interactionsRef.current = eventTimes; - executionContext = remainingLanes$jscomp$0; - } else (root.current = finishedWork), (commitTime = now$1()); + tracing.__interactionsRef.current = prevInteractions; + executionContext = prevExecutionContext; + } else (root$jscomp$0.current = finishedWork), (commitTime = now$1()); if ((effectTag$jscomp$0 = rootDoesHavePassiveEffects)) (rootDoesHavePassiveEffects = !1), - (rootWithPendingPassiveEffects = root), - (pendingPassiveEffectsLanes = lanes), - (pendingPassiveEffectsRenderPriority = renderPriorityLevel); + (rootWithPendingPassiveEffects = root$jscomp$0), + (pendingPassiveEffectsExpirationTime = expirationTime), + (pendingPassiveEffectsRenderPriority = renderPriorityLevel$jscomp$0); else - for (nextEffect = remainingLanes; null !== nextEffect; ) - (ref = nextEffect.nextEffect), + for ( + nextEffect = remainingExpirationTimeBeforeCommit; + null !== nextEffect; + + ) + (renderPriorityLevel$jscomp$0 = nextEffect.nextEffect), (nextEffect.nextEffect = null), - nextEffect.effectTag & 8 && (nextEffect.sibling = null), - (nextEffect = ref); - remainingLanes = root.pendingLanes; - if (0 !== remainingLanes) { + (nextEffect = renderPriorityLevel$jscomp$0); + renderPriorityLevel$jscomp$0 = root$jscomp$0.firstPendingTime; + if (0 !== renderPriorityLevel$jscomp$0) { if (null !== spawnedWorkDuringRender) for ( - ref = spawnedWorkDuringRender, + remainingExpirationTimeBeforeCommit = spawnedWorkDuringRender, spawnedWorkDuringRender = null, - instance = 0; - instance < ref.length; - instance++ + ref = 0; + ref < remainingExpirationTimeBeforeCommit.length; + ref++ ) - scheduleInteractions(root, ref[instance], root.memoizedInteractions); - schedulePendingInteractions(root, remainingLanes); + scheduleInteractions( + root$jscomp$0, + remainingExpirationTimeBeforeCommit[ref], + root$jscomp$0.memoizedInteractions + ); + schedulePendingInteractions(root$jscomp$0, renderPriorityLevel$jscomp$0); } else legacyErrorBoundariesThatAlreadyFailed = null; - effectTag$jscomp$0 || finishPendingInteractions(root, lanes); - 1 === remainingLanes - ? root === rootWithNestedUpdates + effectTag$jscomp$0 || + finishPendingInteractions(root$jscomp$0, expirationTime); + 1073741823 === renderPriorityLevel$jscomp$0 + ? root$jscomp$0 === rootWithNestedUpdates ? nestedUpdateCount++ - : ((nestedUpdateCount = 0), (rootWithNestedUpdates = root)) + : ((nestedUpdateCount = 0), (rootWithNestedUpdates = root$jscomp$0)) : (nestedUpdateCount = 0); - finishedWork = finishedWork.stateNode; - if (injectedHook && "function" === typeof injectedHook.onCommitFiberRoot) - try { - injectedHook.onCommitFiberRoot( - rendererID, - finishedWork, - renderPriorityLevel, - 64 === (finishedWork.current.effectTag & 64) - ); - } catch (err) {} - ensureRootIsScheduled(root, now()); + "function" === typeof onCommitFiberRoot && + onCommitFiberRoot(finishedWork.stateNode, expirationTime); + ensureRootIsScheduled(root$jscomp$0); if (hasUncaughtError) throw ((hasUncaughtError = !1), - (root = firstUncaughtError), + (root$jscomp$0 = firstUncaughtError), (firstUncaughtError = null), - root); - if (0 !== (executionContext & 8)) return null; + root$jscomp$0); + if ((executionContext & LegacyUnbatchedContext) !== NoContext) return null; flushSyncCallbackQueue(); return null; } function commitBeforeMutationEffects() { for (; null !== nextEffect; ) { - var current = nextEffect.alternate; - shouldFireAfterActiveInstanceBlur || - null === focusedInstanceHandle || - (0 !== (nextEffect.effectTag & 8) - ? doesFiberContain(nextEffect, focusedInstanceHandle) && - (shouldFireAfterActiveInstanceBlur = !0) - : 13 === nextEffect.tag && - isSuspenseBoundaryBeingHidden(current, nextEffect) && - doesFiberContain(nextEffect, focusedInstanceHandle) && - (shouldFireAfterActiveInstanceBlur = !0)); var effectTag = nextEffect.effectTag; 0 !== (effectTag & 256) && - commitBeforeMutationLifeCycles(current, nextEffect); + commitBeforeMutationLifeCycles(nextEffect.alternate, nextEffect); 0 === (effectTag & 512) || rootDoesHavePassiveEffects || ((rootDoesHavePassiveEffects = !0), @@ -7087,89 +6688,58 @@ function flushPassiveEffects() { ? 97 : pendingPassiveEffectsRenderPriority; pendingPassiveEffectsRenderPriority = 90; - schedulerPriorityToLanePriority(priorityLevel); return runWithPriority(priorityLevel, flushPassiveEffectsImpl); } - return !1; -} -function enqueuePendingPassiveHookEffectMount(fiber, effect) { - pendingPassiveHookEffectsMount.push(effect, fiber); - rootDoesHavePassiveEffects || - ((rootDoesHavePassiveEffects = !0), - scheduleCallback(97, function() { - flushPassiveEffects(); - return null; - })); -} -function enqueuePendingPassiveHookEffectUnmount(fiber, effect) { - pendingPassiveHookEffectsUnmount.push(effect, fiber); - rootDoesHavePassiveEffects || - ((rootDoesHavePassiveEffects = !0), - scheduleCallback(97, function() { - flushPassiveEffects(); - return null; - })); } function flushPassiveEffectsImpl() { if (null === rootWithPendingPassiveEffects) return !1; var root = rootWithPendingPassiveEffects, - lanes = pendingPassiveEffectsLanes; + expirationTime = pendingPassiveEffectsExpirationTime; rootWithPendingPassiveEffects = null; - pendingPassiveEffectsLanes = 0; - if (0 !== (executionContext & 48)) + pendingPassiveEffectsExpirationTime = 0; + if ((executionContext & (RenderContext | CommitContext)) !== NoContext) throw Error("Cannot flush passive effects while already rendering."); var prevExecutionContext = executionContext; - executionContext |= 32; - var prevInteractions = pushInteractions(root), - unmountEffects = pendingPassiveHookEffectsUnmount; - pendingPassiveHookEffectsUnmount = []; - for (var i = 0; i < unmountEffects.length; i += 2) { - var effect$102 = unmountEffects[i], - fiber = unmountEffects[i + 1], - destroy = effect$102.destroy; - effect$102.destroy = void 0; - if ("function" === typeof destroy) - try { - destroy(); - } catch (error) { - if (null === fiber) throw Error("Should be working on an effect."); - captureCommitPhaseError(fiber, error); - } - } - unmountEffects = pendingPassiveHookEffectsMount; - pendingPassiveHookEffectsMount = []; - for (i = 0; i < unmountEffects.length; i += 2) { - effect$102 = unmountEffects[i]; - fiber = unmountEffects[i + 1]; + executionContext |= CommitContext; + for ( + var prevInteractions = pushInteractions(root), + _effect2 = root.current.firstEffect; + null !== _effect2; + + ) { try { - var create$106 = effect$102.create; - effect$102.destroy = create$106(); - } catch (error$107) { - if (null === fiber) throw Error("Should be working on an effect."); - captureCommitPhaseError(fiber, error$107); + var finishedWork = _effect2; + if (0 !== (finishedWork.effectTag & 512)) + switch (finishedWork.tag) { + case 0: + case 11: + case 15: + case 22: + commitHookEffectListUnmount(5, finishedWork), + commitHookEffectListMount(5, finishedWork); + } + } catch (error) { + if (null === _effect2) throw Error("Should be working on an effect."); + captureCommitPhaseError(_effect2, error); } + finishedWork = _effect2.nextEffect; + _effect2.nextEffect = null; + _effect2 = finishedWork; } - for (create$106 = root.current.firstEffect; null !== create$106; ) - (unmountEffects = create$106.nextEffect), - (create$106.nextEffect = null), - create$106.effectTag & 8 && (create$106.sibling = null), - (create$106 = unmountEffects); tracing.__interactionsRef.current = prevInteractions; - finishPendingInteractions(root, lanes); + finishPendingInteractions(root, expirationTime); executionContext = prevExecutionContext; flushSyncCallbackQueue(); return !0; } function captureCommitPhaseErrorOnRoot(rootFiber, sourceFiber, error) { sourceFiber = createCapturedValue(error, sourceFiber); - sourceFiber = createRootErrorUpdate(rootFiber, sourceFiber, 1); + sourceFiber = createRootErrorUpdate(rootFiber, sourceFiber, 1073741823); enqueueUpdate(rootFiber, sourceFiber); - sourceFiber = requestEventTime(); - rootFiber = markUpdateLaneFromFiberToRoot(rootFiber, 1); + rootFiber = markUpdateTimeFromFiberToRoot(rootFiber, 1073741823); null !== rootFiber && - (markRootUpdated(rootFiber, 1, sourceFiber), - ensureRootIsScheduled(rootFiber, sourceFiber), - schedulePendingInteractions(rootFiber, 1)); + (ensureRootIsScheduled(rootFiber), + schedulePendingInteractions(rootFiber, 1073741823)); } function captureCommitPhaseError(sourceFiber, error) { if (3 === sourceFiber.tag) @@ -7188,166 +6758,156 @@ function captureCommitPhaseError(sourceFiber, error) { !legacyErrorBoundariesThatAlreadyFailed.has(instance))) ) { sourceFiber = createCapturedValue(error, sourceFiber); - sourceFiber = createClassErrorUpdate(fiber, sourceFiber, 1); + sourceFiber = createClassErrorUpdate(fiber, sourceFiber, 1073741823); enqueueUpdate(fiber, sourceFiber); - sourceFiber = requestEventTime(); - fiber = markUpdateLaneFromFiberToRoot(fiber, 1); + fiber = markUpdateTimeFromFiberToRoot(fiber, 1073741823); null !== fiber && - (markRootUpdated(fiber, 1, sourceFiber), - ensureRootIsScheduled(fiber, sourceFiber), - schedulePendingInteractions(fiber, 1)); + (ensureRootIsScheduled(fiber), + schedulePendingInteractions(fiber, 1073741823)); break; } } fiber = fiber.return; } } -function pingSuspendedRoot(root, wakeable, pingedLanes) { +function pingSuspendedRoot(root, thenable, suspendedTime) { var pingCache = root.pingCache; - null !== pingCache && pingCache.delete(wakeable); - wakeable = requestEventTime(); - root.pingedLanes |= root.suspendedLanes & pingedLanes; - workInProgressRoot === root && - (workInProgressRootRenderLanes & pingedLanes) === pingedLanes && - (4 === workInProgressRootExitStatus || - (3 === workInProgressRootExitStatus && - (workInProgressRootRenderLanes & 62914560) === - workInProgressRootRenderLanes && - 500 > now() - globalMostRecentFallbackTime) - ? prepareFreshStack(root, 0) - : (workInProgressRootPingedLanes |= pingedLanes)); - ensureRootIsScheduled(root, wakeable); - schedulePendingInteractions(root, pingedLanes); + null !== pingCache && pingCache.delete(thenable); + workInProgressRoot === root && renderExpirationTime$1 === suspendedTime + ? workInProgressRootExitStatus === RootSuspendedWithDelay || + (workInProgressRootExitStatus === RootSuspended && + 1073741823 === workInProgressRootLatestProcessedExpirationTime && + now() - globalMostRecentFallbackTime < FALLBACK_THROTTLE_MS) + ? prepareFreshStack(root, renderExpirationTime$1) + : (workInProgressRootHasPendingPing = !0) + : isRootSuspendedAtTime(root, suspendedTime) && + ((thenable = root.lastPingedTime), + (0 !== thenable && thenable < suspendedTime) || + ((root.lastPingedTime = suspendedTime), + ensureRootIsScheduled(root), + schedulePendingInteractions(root, suspendedTime))); } -function resolveRetryWakeable(boundaryFiber, wakeable) { +function resolveRetryThenable(boundaryFiber, thenable) { var retryCache = boundaryFiber.stateNode; - null !== retryCache && retryCache.delete(wakeable); - wakeable = 0; - 0 === wakeable && - ((wakeable = boundaryFiber.mode), - 0 === (wakeable & 2) - ? (wakeable = 1) - : 0 === (wakeable & 4) - ? (wakeable = 99 === getCurrentPriorityLevel() ? 1 : 2) - : (0 === currentEventWipLanes && - (currentEventWipLanes = workInProgressRootIncludedLanes), - (wakeable = getHighestPriorityLane(62914560 & ~currentEventWipLanes)), - 0 === wakeable && (wakeable = 4194304))); - retryCache = requestEventTime(); - boundaryFiber = markUpdateLaneFromFiberToRoot(boundaryFiber, wakeable); + null !== retryCache && retryCache.delete(thenable); + thenable = 0; + 0 === thenable && + ((thenable = requestCurrentTimeForUpdate()), + (thenable = computeExpirationForFiber(thenable, boundaryFiber, null))); + boundaryFiber = markUpdateTimeFromFiberToRoot(boundaryFiber, thenable); null !== boundaryFiber && - (markRootUpdated(boundaryFiber, wakeable, retryCache), - ensureRootIsScheduled(boundaryFiber, retryCache), - schedulePendingInteractions(boundaryFiber, wakeable)); + (ensureRootIsScheduled(boundaryFiber), + schedulePendingInteractions(boundaryFiber, thenable)); } var beginWork$1; -beginWork$1 = function(current, workInProgress, renderLanes) { - var updateLanes = workInProgress.lanes; +beginWork$1 = function(current, workInProgress, renderExpirationTime) { + var updateExpirationTime = workInProgress.expirationTime; if (null !== current) if ( current.memoizedProps !== workInProgress.pendingProps || didPerformWorkStackCursor.current ) didReceiveUpdate = !0; - else if (0 !== (renderLanes & updateLanes)) - didReceiveUpdate = 0 !== (current.effectTag & 16384) ? !0 : !1; else { - didReceiveUpdate = !1; - switch (workInProgress.tag) { - case 3: - pushHostRootContext(workInProgress); - break; - case 5: - pushHostContext(workInProgress); - break; - case 1: - isContextProvider(workInProgress.type) && - pushContextProvider(workInProgress); - break; - case 4: - pushHostContainer( - workInProgress, - workInProgress.stateNode.containerInfo - ); - break; - case 10: - updateLanes = workInProgress.memoizedProps.value; - var context = workInProgress.type._context; - push(valueCursor, context._currentValue); - context._currentValue = updateLanes; - break; - case 12: - 0 !== (renderLanes & workInProgress.childLanes) && - (workInProgress.effectTag |= 4); - updateLanes = workInProgress.stateNode; - updateLanes.effectDuration = 0; - updateLanes.passiveEffectDuration = 0; - break; - case 13: - if (null !== workInProgress.memoizedState) { - if (0 !== (renderLanes & workInProgress.child.childLanes)) - return updateSuspenseComponent( - current, - workInProgress, - renderLanes - ); - push(suspenseStackCursor, suspenseStackCursor.current & 1); - workInProgress = bailoutOnAlreadyFinishedWork( - current, + if (updateExpirationTime < renderExpirationTime) { + didReceiveUpdate = !1; + switch (workInProgress.tag) { + case 3: + pushHostRootContext(workInProgress); + break; + case 5: + pushHostContext(workInProgress); + break; + case 1: + isContextProvider(workInProgress.type) && + pushContextProvider(workInProgress); + break; + case 4: + pushHostContainer( workInProgress, - renderLanes + workInProgress.stateNode.containerInfo ); - return null !== workInProgress ? workInProgress.sibling : null; - } - push(suspenseStackCursor, suspenseStackCursor.current & 1); - break; - case 19: - updateLanes = 0 !== (renderLanes & workInProgress.childLanes); - if (0 !== (current.effectTag & 64)) { - if (updateLanes) - return updateSuspenseListComponent( + break; + case 10: + updateExpirationTime = workInProgress.memoizedProps.value; + var context = workInProgress.type._context; + push(valueCursor, context._currentValue); + context._currentValue = updateExpirationTime; + break; + case 12: + workInProgress.childExpirationTime >= renderExpirationTime && + (workInProgress.effectTag |= 4); + updateExpirationTime = workInProgress.stateNode; + updateExpirationTime.effectDuration = 0; + updateExpirationTime.passiveEffectDuration = 0; + break; + case 13: + if (null !== workInProgress.memoizedState) { + updateExpirationTime = workInProgress.child.childExpirationTime; + if ( + 0 !== updateExpirationTime && + updateExpirationTime >= renderExpirationTime + ) + return updateSuspenseComponent( + current, + workInProgress, + renderExpirationTime + ); + push(suspenseStackCursor, suspenseStackCursor.current & 1); + workInProgress = bailoutOnAlreadyFinishedWork( current, workInProgress, - renderLanes + renderExpirationTime ); - workInProgress.effectTag |= 64; - } - context = workInProgress.memoizedState; - null !== context && - ((context.rendering = null), - (context.tail = null), - (context.lastEffect = null)); - push(suspenseStackCursor, suspenseStackCursor.current); - if (updateLanes) break; - else return null; - case 23: - case 24: - return ( - (workInProgress.lanes = 0), - updateOffscreenComponent(current, workInProgress, renderLanes) - ); + return null !== workInProgress ? workInProgress.sibling : null; + } + push(suspenseStackCursor, suspenseStackCursor.current & 1); + break; + case 19: + updateExpirationTime = + workInProgress.childExpirationTime >= renderExpirationTime; + if (0 !== (current.effectTag & 64)) { + if (updateExpirationTime) + return updateSuspenseListComponent( + current, + workInProgress, + renderExpirationTime + ); + workInProgress.effectTag |= 64; + } + context = workInProgress.memoizedState; + null !== context && + ((context.rendering = null), (context.tail = null)); + push(suspenseStackCursor, suspenseStackCursor.current); + if (!updateExpirationTime) return null; + } + return bailoutOnAlreadyFinishedWork( + current, + workInProgress, + renderExpirationTime + ); } - return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes); + didReceiveUpdate = !1; } else didReceiveUpdate = !1; - workInProgress.lanes = 0; + workInProgress.expirationTime = 0; switch (workInProgress.tag) { case 2: - updateLanes = workInProgress.type; + updateExpirationTime = workInProgress.type; null !== current && ((current.alternate = null), (workInProgress.alternate = null), (workInProgress.effectTag |= 2)); current = workInProgress.pendingProps; context = getMaskedContext(workInProgress, contextStackCursor.current); - prepareToReadContext(workInProgress, renderLanes); + prepareToReadContext(workInProgress, renderExpirationTime); context = renderWithHooks( null, workInProgress, - updateLanes, + updateExpirationTime, current, context, - renderLanes + renderExpirationTime ); workInProgress.effectTag |= 1; if ( @@ -7359,7 +6919,7 @@ beginWork$1 = function(current, workInProgress, renderLanes) { workInProgress.tag = 1; workInProgress.memoizedState = null; workInProgress.updateQueue = null; - if (isContextProvider(updateLanes)) { + if (isContextProvider(updateExpirationTime)) { var hasContext = !0; pushContextProvider(workInProgress); } else hasContext = !1; @@ -7368,41 +6928,53 @@ beginWork$1 = function(current, workInProgress, renderLanes) { ? context.state : null; initializeUpdateQueue(workInProgress); - var getDerivedStateFromProps = updateLanes.getDerivedStateFromProps; + var getDerivedStateFromProps = + updateExpirationTime.getDerivedStateFromProps; "function" === typeof getDerivedStateFromProps && applyDerivedStateFromProps( workInProgress, - updateLanes, + updateExpirationTime, getDerivedStateFromProps, current ); context.updater = classComponentUpdater; workInProgress.stateNode = context; - context._reactInternals = workInProgress; - mountClassInstance(workInProgress, updateLanes, current, renderLanes); + context._reactInternalFiber = workInProgress; + mountClassInstance( + workInProgress, + updateExpirationTime, + current, + renderExpirationTime + ); workInProgress = finishClassComponent( null, workInProgress, - updateLanes, + updateExpirationTime, !0, hasContext, - renderLanes + renderExpirationTime ); } else (workInProgress.tag = 0), - reconcileChildren(null, workInProgress, context, renderLanes), + reconcileChildren( + null, + workInProgress, + context, + renderExpirationTime + ), (workInProgress = workInProgress.child); return workInProgress; case 16: - context = workInProgress.elementType; a: { + context = workInProgress.elementType; null !== current && ((current.alternate = null), (workInProgress.alternate = null), (workInProgress.effectTag |= 2)); current = workInProgress.pendingProps; - hasContext = context._init; - context = hasContext(context._payload); + initializeLazyComponentType(context); + if (1 !== context._status) throw context._result; + context = context._result; workInProgress.type = context; hasContext = workInProgress.tag = resolveLazyComponentTag(context); current = resolveDefaultProps(context, current); @@ -7413,7 +6985,7 @@ beginWork$1 = function(current, workInProgress, renderLanes) { workInProgress, context, current, - renderLanes + renderExpirationTime ); break a; case 1: @@ -7422,7 +6994,7 @@ beginWork$1 = function(current, workInProgress, renderLanes) { workInProgress, context, current, - renderLanes + renderExpirationTime ); break a; case 11: @@ -7431,7 +7003,7 @@ beginWork$1 = function(current, workInProgress, renderLanes) { workInProgress, context, current, - renderLanes + renderExpirationTime ); break a; case 14: @@ -7440,8 +7012,8 @@ beginWork$1 = function(current, workInProgress, renderLanes) { workInProgress, context, resolveDefaultProps(context.type, current), - updateLanes, - renderLanes + updateExpirationTime, + renderExpirationTime ); break a; } @@ -7454,106 +7026,126 @@ beginWork$1 = function(current, workInProgress, renderLanes) { return workInProgress; case 0: return ( - (updateLanes = workInProgress.type), + (updateExpirationTime = workInProgress.type), (context = workInProgress.pendingProps), (context = - workInProgress.elementType === updateLanes + workInProgress.elementType === updateExpirationTime ? context - : resolveDefaultProps(updateLanes, context)), + : resolveDefaultProps(updateExpirationTime, context)), updateFunctionComponent( current, workInProgress, - updateLanes, + updateExpirationTime, context, - renderLanes + renderExpirationTime ) ); case 1: return ( - (updateLanes = workInProgress.type), + (updateExpirationTime = workInProgress.type), (context = workInProgress.pendingProps), (context = - workInProgress.elementType === updateLanes + workInProgress.elementType === updateExpirationTime ? context - : resolveDefaultProps(updateLanes, context)), + : resolveDefaultProps(updateExpirationTime, context)), updateClassComponent( current, workInProgress, - updateLanes, + updateExpirationTime, context, - renderLanes + renderExpirationTime ) ); case 3: pushHostRootContext(workInProgress); - updateLanes = workInProgress.updateQueue; - if (null === current || null === updateLanes) + updateExpirationTime = workInProgress.updateQueue; + if (null === current || null === updateExpirationTime) throw Error( "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." ); - updateLanes = workInProgress.pendingProps; + updateExpirationTime = workInProgress.pendingProps; context = workInProgress.memoizedState; context = null !== context ? context.element : null; cloneUpdateQueue(current, workInProgress); - processUpdateQueue(workInProgress, updateLanes, null, renderLanes); - updateLanes = workInProgress.memoizedState.element; - updateLanes === context + processUpdateQueue( + workInProgress, + updateExpirationTime, + null, + renderExpirationTime + ); + updateExpirationTime = workInProgress.memoizedState.element; + updateExpirationTime === context ? (workInProgress = bailoutOnAlreadyFinishedWork( current, workInProgress, - renderLanes + renderExpirationTime )) - : (reconcileChildren(current, workInProgress, updateLanes, renderLanes), + : (reconcileChildren( + current, + workInProgress, + updateExpirationTime, + renderExpirationTime + ), (workInProgress = workInProgress.child)); return workInProgress; case 5: return ( pushHostContext(workInProgress), - (updateLanes = workInProgress.pendingProps.children), + (updateExpirationTime = workInProgress.pendingProps.children), markRef(current, workInProgress), - reconcileChildren(current, workInProgress, updateLanes, renderLanes), - workInProgress.child + reconcileChildren( + current, + workInProgress, + updateExpirationTime, + renderExpirationTime + ), + (workInProgress = workInProgress.child), + workInProgress ); case 6: return null; case 13: - return updateSuspenseComponent(current, workInProgress, renderLanes); + return updateSuspenseComponent( + current, + workInProgress, + renderExpirationTime + ); case 4: return ( pushHostContainer( workInProgress, workInProgress.stateNode.containerInfo ), - (updateLanes = workInProgress.pendingProps), + (updateExpirationTime = workInProgress.pendingProps), null === current ? (workInProgress.child = reconcileChildFibers( workInProgress, null, - updateLanes, - renderLanes + updateExpirationTime, + renderExpirationTime )) : reconcileChildren( current, workInProgress, - updateLanes, - renderLanes + updateExpirationTime, + renderExpirationTime ), workInProgress.child ); case 11: return ( - (updateLanes = workInProgress.type), + (updateExpirationTime = workInProgress.type), (context = workInProgress.pendingProps), (context = - workInProgress.elementType === updateLanes + workInProgress.elementType === updateExpirationTime ? context - : resolveDefaultProps(updateLanes, context)), + : resolveDefaultProps(updateExpirationTime, context)), updateForwardRef( current, workInProgress, - updateLanes, + updateExpirationTime, context, - renderLanes + renderExpirationTime ) ); case 7: @@ -7562,7 +7154,7 @@ beginWork$1 = function(current, workInProgress, renderLanes) { current, workInProgress, workInProgress.pendingProps, - renderLanes + renderExpirationTime ), workInProgress.child ); @@ -7572,27 +7164,27 @@ beginWork$1 = function(current, workInProgress, renderLanes) { current, workInProgress, workInProgress.pendingProps.children, - renderLanes + renderExpirationTime ), workInProgress.child ); case 12: return ( (workInProgress.effectTag |= 4), - (updateLanes = workInProgress.stateNode), - (updateLanes.effectDuration = 0), - (updateLanes.passiveEffectDuration = 0), + (updateExpirationTime = workInProgress.stateNode), + (updateExpirationTime.effectDuration = 0), + (updateExpirationTime.passiveEffectDuration = 0), reconcileChildren( current, workInProgress, workInProgress.pendingProps.children, - renderLanes + renderExpirationTime ), workInProgress.child ); case 10: a: { - updateLanes = workInProgress.type._context; + updateExpirationTime = workInProgress.type._context; context = workInProgress.pendingProps; getDerivedStateFromProps = workInProgress.memoizedProps; hasContext = context.value; @@ -7604,8 +7196,9 @@ beginWork$1 = function(current, workInProgress, renderLanes) { ((context$jscomp$0 = getDerivedStateFromProps.value), (hasContext = objectIs(context$jscomp$0, hasContext) ? 0 - : ("function" === typeof updateLanes._calculateChangedBits - ? updateLanes._calculateChangedBits( + : ("function" === + typeof updateExpirationTime._calculateChangedBits + ? updateExpirationTime._calculateChangedBits( context$jscomp$0, hasContext ) @@ -7619,7 +7212,7 @@ beginWork$1 = function(current, workInProgress, renderLanes) { workInProgress = bailoutOnAlreadyFinishedWork( current, workInProgress, - renderLanes + renderExpirationTime ); break a; } @@ -7640,25 +7233,25 @@ beginWork$1 = function(current, workInProgress, renderLanes) { ) { if ( - dependency.context === updateLanes && + dependency.context === updateExpirationTime && 0 !== (dependency.observedBits & hasContext) ) { 1 === context$jscomp$0.tag && - ((dependency = createUpdate( - -1, - renderLanes & -renderLanes, - null - )), + ((dependency = createUpdate(renderExpirationTime, null)), (dependency.tag = 2), enqueueUpdate(context$jscomp$0, dependency)); - context$jscomp$0.lanes |= renderLanes; + context$jscomp$0.expirationTime < renderExpirationTime && + (context$jscomp$0.expirationTime = renderExpirationTime); dependency = context$jscomp$0.alternate; - null !== dependency && (dependency.lanes |= renderLanes); + null !== dependency && + dependency.expirationTime < renderExpirationTime && + (dependency.expirationTime = renderExpirationTime); scheduleWorkOnParentPath( context$jscomp$0.return, - renderLanes + renderExpirationTime ); - list.lanes |= renderLanes; + list.expirationTime < renderExpirationTime && + (list.expirationTime = renderExpirationTime); break; } dependency = dependency.next; @@ -7696,7 +7289,7 @@ beginWork$1 = function(current, workInProgress, renderLanes) { current, workInProgress, context.children, - renderLanes + renderExpirationTime ); workInProgress = workInProgress.child; } @@ -7705,12 +7298,17 @@ beginWork$1 = function(current, workInProgress, renderLanes) { return ( (context = workInProgress.type), (hasContext = workInProgress.pendingProps), - (updateLanes = hasContext.children), - prepareToReadContext(workInProgress, renderLanes), + (updateExpirationTime = hasContext.children), + prepareToReadContext(workInProgress, renderExpirationTime), (context = readContext(context, hasContext.unstable_observedBits)), - (updateLanes = updateLanes(context)), + (updateExpirationTime = updateExpirationTime(context)), (workInProgress.effectTag |= 1), - reconcileChildren(current, workInProgress, updateLanes, renderLanes), + reconcileChildren( + current, + workInProgress, + updateExpirationTime, + renderExpirationTime + ), workInProgress.child ); case 14: @@ -7726,8 +7324,8 @@ beginWork$1 = function(current, workInProgress, renderLanes) { workInProgress, context, hasContext, - updateLanes, - renderLanes + updateExpirationTime, + renderExpirationTime ) ); case 15: @@ -7736,43 +7334,48 @@ beginWork$1 = function(current, workInProgress, renderLanes) { workInProgress, workInProgress.type, workInProgress.pendingProps, - updateLanes, - renderLanes + updateExpirationTime, + renderExpirationTime ); case 17: return ( - (updateLanes = workInProgress.type), + (updateExpirationTime = workInProgress.type), (context = workInProgress.pendingProps), (context = - workInProgress.elementType === updateLanes + workInProgress.elementType === updateExpirationTime ? context - : resolveDefaultProps(updateLanes, context)), + : resolveDefaultProps(updateExpirationTime, context)), null !== current && ((current.alternate = null), (workInProgress.alternate = null), (workInProgress.effectTag |= 2)), (workInProgress.tag = 1), - isContextProvider(updateLanes) + isContextProvider(updateExpirationTime) ? ((current = !0), pushContextProvider(workInProgress)) : (current = !1), - prepareToReadContext(workInProgress, renderLanes), - constructClassInstance(workInProgress, updateLanes, context), - mountClassInstance(workInProgress, updateLanes, context, renderLanes), + prepareToReadContext(workInProgress, renderExpirationTime), + constructClassInstance(workInProgress, updateExpirationTime, context), + mountClassInstance( + workInProgress, + updateExpirationTime, + context, + renderExpirationTime + ), finishClassComponent( null, workInProgress, - updateLanes, + updateExpirationTime, !0, current, - renderLanes + renderExpirationTime ) ); case 19: - return updateSuspenseListComponent(current, workInProgress, renderLanes); - case 23: - return updateOffscreenComponent(current, workInProgress, renderLanes); - case 24: - return updateOffscreenComponent(current, workInProgress, renderLanes); + return updateSuspenseListComponent( + current, + workInProgress, + renderExpirationTime + ); } throw Error( "Unknown unit of work tag (" + @@ -7780,16 +7383,16 @@ beginWork$1 = function(current, workInProgress, renderLanes) { "). This error is likely caused by a bug in React. Please file an issue." ); }; -function scheduleInteractions(root, lane, interactions) { +function scheduleInteractions(root, expirationTime, interactions) { if (0 < interactions.size) { var pendingInteractionMap = root.pendingInteractionMap, - pendingInteractions = pendingInteractionMap.get(lane); + pendingInteractions = pendingInteractionMap.get(expirationTime); null != pendingInteractions ? interactions.forEach(function(interaction) { pendingInteractions.has(interaction) || interaction.__count++; pendingInteractions.add(interaction); }) - : (pendingInteractionMap.set(lane, new Set(interactions)), + : (pendingInteractionMap.set(expirationTime, new Set(interactions)), interactions.forEach(function(interaction) { interaction.__count++; })); @@ -7797,20 +7400,20 @@ function scheduleInteractions(root, lane, interactions) { if (null !== pendingInteractionMap) pendingInteractionMap.onWorkScheduled( interactions, - 1e3 * lane + root.interactionThreadID + 1e3 * expirationTime + root.interactionThreadID ); } } -function schedulePendingInteractions(root, lane) { - scheduleInteractions(root, lane, tracing.__interactionsRef.current); +function schedulePendingInteractions(root, expirationTime) { + scheduleInteractions(root, expirationTime, tracing.__interactionsRef.current); } -function startWorkOnPendingInteractions(root, lanes) { +function startWorkOnPendingInteractions(root, expirationTime) { var interactions = new Set(); root.pendingInteractionMap.forEach(function( scheduledInteractions, - scheduledLane + scheduledExpirationTime ) { - 0 !== (lanes & scheduledLane) && + scheduledExpirationTime >= expirationTime && scheduledInteractions.forEach(function(interaction) { return interactions.add(interaction); }); @@ -7819,7 +7422,7 @@ function startWorkOnPendingInteractions(root, lanes) { if (0 < interactions.size) { var subscriber = tracing.__subscriberRef.current; if (null !== subscriber) { - root = 1e3 * lanes + root.interactionThreadID; + root = 1e3 * expirationTime + root.interactionThreadID; try { subscriber.onWorkStarted(interactions, root); } catch (error) { @@ -7830,14 +7433,14 @@ function startWorkOnPendingInteractions(root, lanes) { } } } -function finishPendingInteractions(root, committedLanes) { - var remainingLanesAfterCommit = root.pendingLanes; +function finishPendingInteractions(root, committedExpirationTime) { + var earliestRemainingTimeAfterCommit = root.firstPendingTime; try { var subscriber = tracing.__subscriberRef.current; if (null !== subscriber && 0 < root.memoizedInteractions.size) subscriber.onWorkStopped( root.memoizedInteractions, - 1e3 * committedLanes + root.interactionThreadID + 1e3 * committedExpirationTime + root.interactionThreadID ); } catch (error) { scheduleCallback(99, function() { @@ -7845,23 +7448,54 @@ function finishPendingInteractions(root, committedLanes) { }); } finally { var pendingInteractionMap = root.pendingInteractionMap; - pendingInteractionMap.forEach(function(scheduledInteractions, lane) { - 0 === (remainingLanesAfterCommit & lane) && - (pendingInteractionMap.delete(lane), + pendingInteractionMap.forEach(function( + scheduledInteractions, + scheduledExpirationTime + ) { + scheduledExpirationTime > earliestRemainingTimeAfterCommit && + (pendingInteractionMap.delete(scheduledExpirationTime), scheduledInteractions.forEach(function(interaction) { interaction.__count--; if (null !== subscriber && 0 === interaction.__count) try { subscriber.onInteractionScheduledWorkCompleted(interaction); - } catch (error$108) { + } catch (error) { scheduleCallback(99, function() { - throw error$108; + throw error; }); } })); }); } } +var onCommitFiberRoot = null, + onCommitFiberUnmount = null, + isDevToolsPresent = "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__; +function injectInternals(internals) { + if ("undefined" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) return !1; + var hook = __REACT_DEVTOOLS_GLOBAL_HOOK__; + if (hook.isDisabled || !hook.supportsFiber) return !0; + try { + var rendererID = hook.inject(internals); + onCommitFiberRoot = function(root, expirationTime) { + try { + var didError = 64 === (root.current.effectTag & 64), + currentTime = 1073741821 - ((now() / 10) | 0), + priorityLevel = inferPriorityFromExpirationTime( + currentTime, + expirationTime + ); + hook.onCommitFiberRoot(rendererID, root, priorityLevel, didError); + } catch (err) {} + }; + onCommitFiberUnmount = function(fiber) { + try { + hook.onCommitFiberUnmount(rendererID, fiber); + } catch (err) {} + }; + } catch (err) {} + return !0; +} function FiberNode(tag, pendingProps, key, mode) { this.tag = tag; this.key = key; @@ -7873,15 +7507,12 @@ function FiberNode(tag, pendingProps, key, mode) { this.mode = mode; this.effectTag = 0; this.lastEffect = this.firstEffect = this.nextEffect = null; - this.childLanes = this.lanes = 0; + this.childExpirationTime = this.expirationTime = 0; this.alternate = null; this.actualDuration = 0; 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); @@ -7899,7 +7530,7 @@ function resolveLazyComponentTag(Component) { function createWorkInProgress(current, pendingProps) { var workInProgress = current.alternate; null === workInProgress - ? ((workInProgress = createFiber( + ? ((workInProgress = new FiberNode( current.tag, pendingProps, current.key, @@ -7911,15 +7542,18 @@ function createWorkInProgress(current, pendingProps) { (workInProgress.alternate = current), (current.alternate = workInProgress)) : ((workInProgress.pendingProps = pendingProps), - (workInProgress.type = current.type), (workInProgress.effectTag = 0), (workInProgress.nextEffect = null), (workInProgress.firstEffect = null), (workInProgress.lastEffect = null), (workInProgress.actualDuration = 0), (workInProgress.actualStartTime = -1)); - workInProgress.childLanes = current.childLanes; - workInProgress.lanes = current.lanes; + if (null == current) + throw Error("current is " + current + " but it can't be"); + if (null == workInProgress) + throw Error("workInProgress is " + workInProgress + " but it can't be"); + workInProgress.childExpirationTime = current.childExpirationTime; + workInProgress.expirationTime = current.expirationTime; workInProgress.child = current.child; workInProgress.memoizedProps = current.memoizedProps; workInProgress.memoizedState = current.memoizedState; @@ -7929,7 +7563,7 @@ function createWorkInProgress(current, pendingProps) { null === pendingProps ? null : { - lanes: pendingProps.lanes, + expirationTime: pendingProps.expirationTime, firstContext: pendingProps.firstContext, responders: pendingProps.responders }; @@ -7946,7 +7580,7 @@ function createFiberFromTypeAndProps( pendingProps, owner, mode, - lanes + expirationTime ) { var fiberTag = 2; owner = type; @@ -7955,10 +7589,15 @@ function createFiberFromTypeAndProps( else a: switch (type) { case REACT_FRAGMENT_TYPE: - return createFiberFromFragment(pendingProps.children, mode, lanes, key); - case REACT_DEBUG_TRACING_MODE_TYPE: + return createFiberFromFragment( + pendingProps.children, + mode, + expirationTime, + key + ); + case REACT_CONCURRENT_MODE_TYPE: fiberTag = 8; - mode |= 16; + mode |= 7; break; case REACT_STRICT_MODE_TYPE: fiberTag = 8; @@ -7966,35 +7605,26 @@ function createFiberFromTypeAndProps( break; case REACT_PROFILER_TYPE: return ( - (type = createFiber(12, pendingProps, key, mode | 8)), + (type = new FiberNode(12, pendingProps, key, mode | 8)), (type.elementType = REACT_PROFILER_TYPE), (type.type = REACT_PROFILER_TYPE), - (type.lanes = lanes), + (type.expirationTime = expirationTime), (type.stateNode = { effectDuration: 0, passiveEffectDuration: 0 }), type ); case REACT_SUSPENSE_TYPE: return ( - (type = createFiber(13, pendingProps, key, mode)), + (type = new FiberNode(13, pendingProps, key, mode)), (type.type = REACT_SUSPENSE_TYPE), (type.elementType = REACT_SUSPENSE_TYPE), - (type.lanes = lanes), + (type.expirationTime = expirationTime), type ); case REACT_SUSPENSE_LIST_TYPE: return ( - (type = createFiber(19, pendingProps, key, mode)), + (type = new FiberNode(19, pendingProps, key, mode)), (type.elementType = REACT_SUSPENSE_LIST_TYPE), - (type.lanes = lanes), - type - ); - case REACT_OFFSCREEN_TYPE: - return createFiberFromOffscreen(pendingProps, mode, lanes, key); - case REACT_LEGACY_HIDDEN_TYPE: - return ( - (type = createFiber(24, pendingProps, key, mode)), - (type.elementType = REACT_LEGACY_HIDDEN_TYPE), - (type.lanes = lanes), + (type.expirationTime = expirationTime), type ); default: @@ -8026,36 +7656,30 @@ function createFiberFromTypeAndProps( "." ); } - key = createFiber(fiberTag, pendingProps, key, mode); + key = new FiberNode(fiberTag, pendingProps, key, mode); key.elementType = type; key.type = owner; - key.lanes = lanes; + key.expirationTime = expirationTime; return key; } -function createFiberFromFragment(elements, mode, lanes, key) { - elements = createFiber(7, elements, key, mode); - elements.lanes = lanes; +function createFiberFromFragment(elements, mode, expirationTime, key) { + elements = new FiberNode(7, elements, key, mode); + elements.expirationTime = expirationTime; return elements; } -function createFiberFromOffscreen(pendingProps, mode, lanes, key) { - pendingProps = createFiber(23, pendingProps, key, mode); - pendingProps.elementType = REACT_OFFSCREEN_TYPE; - pendingProps.lanes = lanes; - return pendingProps; -} -function createFiberFromText(content, mode, lanes) { - content = createFiber(6, content, null, mode); - content.lanes = lanes; +function createFiberFromText(content, mode, expirationTime) { + content = new FiberNode(6, content, null, mode); + content.expirationTime = expirationTime; return content; } -function createFiberFromPortal(portal, mode, lanes) { - mode = createFiber( +function createFiberFromPortal(portal, mode, expirationTime) { + mode = new FiberNode( 4, null !== portal.children ? portal.children : [], portal.key, mode ); - mode.lanes = lanes; + mode.expirationTime = expirationTime; mode.stateNode = { containerInfo: portal.containerInfo, pendingChildren: null, @@ -8065,34 +7689,54 @@ function createFiberFromPortal(portal, mode, lanes) { } function FiberRootNode(containerInfo, tag, hydrate) { this.tag = tag; + this.current = null; this.containerInfo = containerInfo; - this.finishedWork = this.pingCache = this.current = this.pendingChildren = null; + this.pingCache = this.pendingChildren = null; + this.finishedExpirationTime = 0; + this.finishedWork = null; this.timeoutHandle = -1; this.pendingContext = this.context = null; this.hydrate = hydrate; this.callbackNode = null; - this.callbackPriority = 0; - this.eventTimes = Array(31).fill(0); - this.expirationTimes = Array(31).fill(-1); - this.entangledLanes = this.finishedLanes = this.mutableReadLanes = this.expiredLanes = this.pingedLanes = this.suspendedLanes = this.pendingLanes = 0; - this.entanglements = Array(31).fill(0); + this.callbackPriority = 90; + this.lastExpiredTime = this.lastPingedTime = this.nextKnownPendingLevel = this.lastSuspendedTime = this.firstSuspendedTime = this.firstPendingTime = 0; this.interactionThreadID = tracing.unstable_getThreadID(); this.memoizedInteractions = new Set(); this.pendingInteractionMap = new Map(); } -function createPortal(children, containerInfo, implementation) { - var key = - 3 < arguments.length && void 0 !== arguments[3] ? arguments[3] : null; - return { - $$typeof: REACT_PORTAL_TYPE, - key: null == key ? null : "" + key, - children: children, - containerInfo: containerInfo, - implementation: implementation - }; +function isRootSuspendedAtTime(root, expirationTime) { + var firstSuspendedTime = root.firstSuspendedTime; + root = root.lastSuspendedTime; + return ( + 0 !== firstSuspendedTime && + firstSuspendedTime >= expirationTime && + root <= expirationTime + ); +} +function markRootSuspendedAtTime(root, expirationTime) { + var firstSuspendedTime = root.firstSuspendedTime, + lastSuspendedTime = root.lastSuspendedTime; + firstSuspendedTime < expirationTime && + (root.firstSuspendedTime = expirationTime); + if (lastSuspendedTime > expirationTime || 0 === firstSuspendedTime) + root.lastSuspendedTime = expirationTime; + expirationTime <= root.lastPingedTime && (root.lastPingedTime = 0); + expirationTime <= root.lastExpiredTime && (root.lastExpiredTime = 0); +} +function markRootUpdatedAtTime(root, expirationTime) { + expirationTime > root.firstPendingTime && + (root.firstPendingTime = expirationTime); + var firstSuspendedTime = root.firstSuspendedTime; + 0 !== firstSuspendedTime && + (expirationTime >= firstSuspendedTime + ? (root.firstSuspendedTime = root.lastSuspendedTime = root.nextKnownPendingLevel = 0) + : expirationTime >= root.lastSuspendedTime && + (root.lastSuspendedTime = expirationTime + 1), + expirationTime > root.nextKnownPendingLevel && + (root.nextKnownPendingLevel = expirationTime)); } function findHostInstance(component) { - var fiber = component._reactInternals; + var fiber = component._reactInternalFiber; if (void 0 === fiber) { if ("function" === typeof component.render) throw Error("Unable to find node on an unmounted component."); @@ -8106,11 +7750,11 @@ function findHostInstance(component) { } function updateContainer(element, container, parentComponent, callback) { var current = container.current, - eventTime = requestEventTime(), - suspenseConfig = ReactCurrentBatchConfig.suspense, - lane = requestUpdateLane(current, suspenseConfig); + currentTime = requestCurrentTimeForUpdate(), + suspenseConfig = ReactCurrentBatchConfig.suspense; + currentTime = computeExpirationForFiber(currentTime, current, suspenseConfig); a: if (parentComponent) { - parentComponent = parentComponent._reactInternals; + parentComponent = parentComponent._reactInternalFiber; b: { if ( getNearestMountedFiber(parentComponent) !== parentComponent || @@ -8119,23 +7763,22 @@ function updateContainer(element, container, parentComponent, callback) { throw Error( "Expected subtree parent to be a mounted class component. This error is likely caused by a bug in React. Please file an issue." ); - var JSCompiler_inline_result = parentComponent; + var parentContext = parentComponent; do { - switch (JSCompiler_inline_result.tag) { + switch (parentContext.tag) { case 3: - JSCompiler_inline_result = - JSCompiler_inline_result.stateNode.context; + parentContext = parentContext.stateNode.context; break b; case 1: - if (isContextProvider(JSCompiler_inline_result.type)) { - JSCompiler_inline_result = - JSCompiler_inline_result.stateNode + if (isContextProvider(parentContext.type)) { + parentContext = + parentContext.stateNode .__reactInternalMemoizedMergedChildContext; break b; } } - JSCompiler_inline_result = JSCompiler_inline_result.return; - } while (null !== JSCompiler_inline_result); + parentContext = parentContext.return; + } while (null !== parentContext); throw Error( "Found unexpected detached subtree parent. This error is likely caused by a bug in React. Please file an issue." ); @@ -8146,26 +7789,34 @@ function updateContainer(element, container, parentComponent, callback) { parentComponent = processChildContext( parentComponent, Component, - JSCompiler_inline_result + parentContext ); break a; } } - parentComponent = JSCompiler_inline_result; + parentComponent = parentContext; } else parentComponent = emptyContextObject; null === container.context ? (container.context = parentComponent) : (container.pendingContext = parentComponent); - container = createUpdate(eventTime, lane, suspenseConfig); + container = createUpdate(currentTime, suspenseConfig); container.payload = { element: element }; callback = void 0 === callback ? null : callback; null !== callback && (container.callback = callback); enqueueUpdate(current, container); - scheduleUpdateOnFiber(current, lane, eventTime); - return lane; + scheduleWork(current, currentTime); + return currentTime; } -function emptyFindFiberByHostInstance() { - return null; +function createPortal(children, containerInfo, implementation) { + var key = + 3 < arguments.length && void 0 !== arguments[3] ? arguments[3] : null; + return { + $$typeof: REACT_PORTAL_TYPE, + key: null == key ? null : "" + key, + children: children, + containerInfo: containerInfo, + implementation: implementation + }; } function findNodeHandle(componentOrHandle) { if (null == componentOrHandle) return null; @@ -8194,64 +7845,53 @@ batchedUpdatesImpl = function(fn, a) { return fn(a); } finally { (executionContext = prevExecutionContext), - 0 === executionContext && flushSyncCallbackQueue(); + executionContext === NoContext && flushSyncCallbackQueue(); } }; -var roots = new Map(), - devToolsConfig$jscomp$inline_956 = { - findFiberByHostInstance: getInstanceFromTag, - bundleType: 0, - version: "17.0.0-alpha.0", - rendererPackageName: "react-native-renderer", - rendererConfig: { - getInspectorDataForViewTag: function() { - throw Error( - "getInspectorDataForViewTag() is not available in production" - ); - }, - getInspectorDataForViewAtPoint: function() { - throw Error( - "getInspectorDataForViewAtPoint() is not available in production." - ); - }.bind(null, findNodeHandle) - } - }; -var internals$jscomp$inline_1172 = { - bundleType: devToolsConfig$jscomp$inline_956.bundleType, - version: devToolsConfig$jscomp$inline_956.version, - rendererPackageName: devToolsConfig$jscomp$inline_956.rendererPackageName, - rendererConfig: devToolsConfig$jscomp$inline_956.rendererConfig, - overrideHookState: null, - overrideProps: null, - setSuspenseHandler: null, - scheduleUpdate: null, - currentDispatcherRef: ReactSharedInternals.ReactCurrentDispatcher, - findHostInstanceByFiber: function(fiber) { - fiber = findCurrentHostFiber(fiber); - return null === fiber ? null : fiber.stateNode; - }, - findFiberByHostInstance: - devToolsConfig$jscomp$inline_956.findFiberByHostInstance || - emptyFindFiberByHostInstance, - findHostInstancesForRefresh: null, - scheduleRefresh: null, - scheduleRoot: null, - setRefreshHandler: null, - getCurrentFiber: null -}; -if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) { - var hook$jscomp$inline_1173 = __REACT_DEVTOOLS_GLOBAL_HOOK__; - if ( - !hook$jscomp$inline_1173.isDisabled && - hook$jscomp$inline_1173.supportsFiber - ) - try { - (rendererID = hook$jscomp$inline_1173.inject( - internals$jscomp$inline_1172 - )), - (injectedHook = hook$jscomp$inline_1173); - } catch (err) {} -} +var roots = new Map(); +(function(devToolsConfig) { + var findFiberByHostInstance = devToolsConfig.findFiberByHostInstance; + return injectInternals({ + bundleType: devToolsConfig.bundleType, + version: devToolsConfig.version, + rendererPackageName: devToolsConfig.rendererPackageName, + rendererConfig: devToolsConfig.rendererConfig, + overrideHookState: null, + overrideProps: null, + setSuspenseHandler: null, + scheduleUpdate: null, + currentDispatcherRef: ReactSharedInternals.ReactCurrentDispatcher, + findHostInstanceByFiber: function(fiber) { + fiber = findCurrentHostFiber(fiber); + return null === fiber ? null : fiber.stateNode; + }, + findFiberByHostInstance: function(instance) { + return findFiberByHostInstance ? findFiberByHostInstance(instance) : null; + }, + findHostInstancesForRefresh: null, + scheduleRefresh: null, + scheduleRoot: null, + setRefreshHandler: null, + getCurrentFiber: null + }); +})({ + findFiberByHostInstance: getInstanceFromTag, + bundleType: 0, + version: "16.13.0", + rendererPackageName: "react-native-renderer", + rendererConfig: { + getInspectorDataForViewTag: function() { + throw Error( + "getInspectorDataForViewTag() is not available in production" + ); + }, + getInspectorDataForViewAtPoint: function() { + throw Error( + "getInspectorDataForViewAtPoint() is not available in production." + ); + }.bind(null, findNodeHandle) + } +}); exports.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = { computeComponentStackForErrorReporting: function(reactTag) { return (reactTag = getInstanceFromTag(reactTag)) @@ -8298,17 +7938,12 @@ exports.render = function(element, containerTag, callback) { var root = roots.get(containerTag); if (!root) { root = new FiberRootNode(containerTag, 0, !1); - var JSCompiler_inline_result = 0; - isDevToolsPresent && (JSCompiler_inline_result |= 8); - JSCompiler_inline_result = createFiber( - 3, - null, - null, - JSCompiler_inline_result - ); - root.current = JSCompiler_inline_result; - JSCompiler_inline_result.stateNode = root; - initializeUpdateQueue(JSCompiler_inline_result); + var uninitializedFiber = 0; + isDevToolsPresent && (uninitializedFiber |= 8); + uninitializedFiber = new FiberNode(3, null, null, uninitializedFiber); + root.current = uninitializedFiber; + uninitializedFiber.stateNode = root; + initializeUpdateQueue(uninitializedFiber); roots.set(containerTag, root); } updateContainer(element, root, null, callback); diff --git a/Libraries/Renderer/shims/ReactNativeTypes.js b/Libraries/Renderer/shims/ReactNativeTypes.js index 2f9876384b8..41d220ab71a 100644 --- a/Libraries/Renderer/shims/ReactNativeTypes.js +++ b/Libraries/Renderer/shims/ReactNativeTypes.js @@ -212,6 +212,7 @@ export type ReactFaricEvent = { ... }; +// // Imperative LayoutAnimation API types // export type LayoutAnimationType = diff --git a/package.json b/package.json index e1067504c09..cd92bab7e33 100644 --- a/package.json +++ b/package.json @@ -82,7 +82,7 @@ "test-ios": "./scripts/objc-test.sh test" }, "peerDependencies": { - "react": "16.13.1" + "react": "0.0.0-experimental-aae83a4b9" }, "dependencies": { "@react-native-community/cli": "^4.10.0", @@ -111,7 +111,7 @@ "react-devtools-core": "^4.6.0", "react-refresh": "^0.4.0", "regenerator-runtime": "^0.13.2", - "scheduler": "0.19.1", + "scheduler": "0.0.0-experimental-aae83a4b9", "stacktrace-parser": "^0.1.3", "use-subscription": "^1.0.0", "whatwg-fetch": "^3.0.0" @@ -147,9 +147,9 @@ "jscodeshift": "^0.9.0", "mkdirp": "^0.5.1", "prettier": "1.19.1", - "react": "16.13.1", - "react-test-renderer": "16.13.1", + "react": "0.0.0-experimental-aae83a4b9", "react-shallow-renderer": "16.13.1", + "react-test-renderer": "0.0.0-experimental-aae83a4b9", "shelljs": "^0.7.8", "signedsource": "^1.0.0", "ws": "^6.1.4", diff --git a/template/package.json b/template/package.json index c0e21af4a72..b9f6e1b2943 100644 --- a/template/package.json +++ b/template/package.json @@ -10,7 +10,7 @@ "lint": "eslint ." }, "dependencies": { - "react": "16.13.1", + "react": "0.0.0-experimental-aae83a4b9", "react-native": "1000.0.0" }, "devDependencies": { @@ -21,7 +21,7 @@ "eslint": "^6.5.1", "jest": "^25.1.0", "metro-react-native-babel-preset": "^0.61.0", - "react-test-renderer": "16.13.1" + "react-test-renderer": "0.0.0-experimental-aae83a4b9 " }, "jest": { "preset": "react-native" diff --git a/yarn.lock b/yarn.lock index debeb305440..b168a1baf8d 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6217,6 +6217,11 @@ react-devtools-core@^4.6.0: shell-quote "^1.6.1" ws "^7" +react-is@0.0.0-experimental-aae83a4b9: + version "0.0.0-experimental-aae83a4b9" + resolved "https://registry.yarnpkg.com/react-is/-/react-is-0.0.0-experimental-aae83a4b9.tgz#9dde6f4ac1da013398bf990706af2d4f59774d2b" + integrity sha512-0AZ4lHKqoXzYZ5RhNtj7ODYhQ6fXLDRn9lRapoVxYd2rgfe6LLrrf7ob5lweuo/krb7heBGINZ479FdQIvNLfg== + react-is@^16.12.0: version "16.12.0" resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.12.0.tgz#2cc0fe0fba742d97fd527c42a13bec4eeb06241c" @@ -6227,17 +6232,12 @@ react-is@^16.8.1, react-is@^16.8.4: resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.8.4.tgz#90f336a68c3a29a096a3d648ab80e87ec61482a2" integrity sha512-PVadd+WaUDOAciICm/J1waJaSvgq+4rHE/K70j0PFqKhkTBsPv/82UGQJNXAngz1fOQLLxI6z1sEDmJDQhCTAA== -react-is@^16.8.6: - version "16.13.1" - resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.13.1.tgz#789729a4dc36de2999dc156dd6c1d9c18cea56a4" - integrity sha512-24e6ynE2H+OKt4kqsOvNd8kBpV65zoxbA4BVsEOB3ARVWQki/DHzaUoC5KuON/BiccDaCCTZBuOcfZs70kR8bQ== - react-refresh@^0.4.0: version "0.4.0" resolved "https://registry.yarnpkg.com/react-refresh/-/react-refresh-0.4.0.tgz#d421f9bd65e0e4b9822a399f14ac56bda9c92292" integrity sha512-bacjSio8GOtzNZKZZM6EWqbhlbb6pr28JWJWFTLwEBKvPIBRo6/Ob68D2EWZA2VyTdQxAh+TRnCYOPNKsQiXTA== -react-shallow-renderer@16.13.1: +react-shallow-renderer@16.13.1, react-shallow-renderer@^16.13.1: version "16.13.1" resolved "https://registry.yarnpkg.com/react-shallow-renderer/-/react-shallow-renderer-16.13.1.tgz#4cfd6dc0f05a8d4d261ff7a80e9b88f15491a00a" integrity sha512-hLmExm5/ZnjodLgm/4oxYw4i7fL6LLPhbO9mF/4tmaZUurtLrp2aSeDHZmRk0SVCHXPz0VaEbb3Dqi5J7odz7Q== @@ -6245,24 +6245,23 @@ react-shallow-renderer@16.13.1: object-assign "^4.1.1" react-is "^16.12.0" -react-test-renderer@16.13.1: - version "16.13.1" - resolved "https://registry.yarnpkg.com/react-test-renderer/-/react-test-renderer-16.13.1.tgz#de25ea358d9012606de51e012d9742e7f0deabc1" - integrity sha512-Sn2VRyOK2YJJldOqoh8Tn/lWQ+ZiKhyZTPtaO0Q6yNj+QDbmRkVFap6pZPy3YQk8DScRDfyqm/KxKYP9gCMRiQ== +react-test-renderer@0.0.0-experimental-aae83a4b9: + version "0.0.0-experimental-aae83a4b9" + resolved "https://registry.yarnpkg.com/react-test-renderer/-/react-test-renderer-0.0.0-experimental-aae83a4b9.tgz#494dc7b72fe7ab6d469cd43032e686aa15f767f8" + integrity sha512-Wbj7W/YQhJZpC5FbJmOgtEUNIFKfXmWvAHlJn9wc636pUHTMDYs/180qJlUwtrfW2WLb1xEpPKZQ9RnfT7gVxg== dependencies: object-assign "^4.1.1" - prop-types "^15.6.2" - react-is "^16.8.6" - scheduler "^0.19.1" + react-is "0.0.0-experimental-aae83a4b9" + react-shallow-renderer "^16.13.1" + scheduler "0.0.0-experimental-aae83a4b9" -react@16.13.1: - version "16.13.1" - resolved "https://registry.yarnpkg.com/react/-/react-16.13.1.tgz#2e818822f1a9743122c063d6410d85c1e3afe48e" - integrity sha512-YMZQQq32xHLX0bz5Mnibv1/LHb3Sqzngu7xstSM+vrkE5Kzr9xE0yMByK5kMoTK30YVJE61WfbxIFFvfeDKT1w== +react@0.0.0-experimental-aae83a4b9: + version "0.0.0-experimental-aae83a4b9" + resolved "https://registry.yarnpkg.com/react/-/react-0.0.0-experimental-aae83a4b9.tgz#9b2063ddb2dc9a3d347e7a0a4233462c78800ba0" + integrity sha512-PuabEUXkXk9E4FrB3FoHY6GwvkqBpN7Od2V91TQgwJcgfErMIXQQm1n9GxzQBJ/RfgkTBCoaV4zEC/B8cNJWjw== dependencies: loose-envify "^1.1.0" object-assign "^4.1.1" - prop-types "^15.6.2" read-pkg-up@^7.0.1: version "7.0.1" @@ -6679,10 +6678,10 @@ saxes@^5.0.0: dependencies: xmlchars "^2.2.0" -scheduler@0.19.1, scheduler@^0.19.1: - version "0.19.1" - resolved "https://registry.yarnpkg.com/scheduler/-/scheduler-0.19.1.tgz#4f3e2ed2c1a7d65681f4c854fa8c5a1ccb40f196" - integrity sha512-n/zwRWRYSUj0/3g/otKDRPMh6qv2SYMWNq85IEa8iZyAv8od9zDYpGSnpBEjNgcMNq6Scbu5KfIPxNF72R/2EA== +scheduler@0.0.0-experimental-aae83a4b9: + version "0.0.0-experimental-aae83a4b9" + resolved "https://registry.yarnpkg.com/scheduler/-/scheduler-0.0.0-experimental-aae83a4b9.tgz#da2d706425a55ff1538d26f634171bc333a38b3b" + integrity sha512-z0Z0TqehF/6dZbOtRcdvJBX5qUWhNs4sLddxe8VtCThTnBhK+vv5Hv6R/LP5UcE+ROk8988uTYlQExzofI7yZA== dependencies: loose-envify "^1.1.0" object-assign "^4.1.1"