diff --git a/Libraries/Renderer/REVISION b/Libraries/Renderer/REVISION index 4783a1805fc..97d8977a5a3 100644 --- a/Libraries/Renderer/REVISION +++ b/Libraries/Renderer/REVISION @@ -1 +1 @@ -3fcd81dd1c3cd1413b72ae2919bc8312787f8f58 \ No newline at end of file +afcb9cdc9343ddc134b03dcf4d7fbc0810b6002b \ 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 af5fb754ee5..6bc84b6f495 100644 --- a/Libraries/Renderer/implementations/ReactFabric-dev.fb.js +++ b/Libraries/Renderer/implementations/ReactFabric-dev.fb.js @@ -7,33 +7,14 @@ * @noflow * @nolint * @preventMunge - * @generated SignedSource<<5ea41cf7a37f479802f5b09b15260681>> + * @generated SignedSource<> */ 'use strict'; if (__DEV__) { (function() { - - /** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -/* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */ - -// Don't require this file directly; it's embedded by Rollup during build. - -if ( - typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' && - typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart === - 'function' -) { - __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error()); -} - "use strict"; +"use strict"; var React = require("react"); require("react-native/Libraries/ReactPrivate/ReactNativePrivateInitializeCore"); @@ -2618,6 +2599,7 @@ var REACT_SUSPENSE_LIST_TYPE = 0xead8; var REACT_MEMO_TYPE = 0xead3; var REACT_LAZY_TYPE = 0xead4; 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; @@ -2638,6 +2620,7 @@ if (typeof Symbol === "function" && Symbol.for) { REACT_MEMO_TYPE = symbolFor("react.memo"); REACT_LAZY_TYPE = symbolFor("react.lazy"); 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"); @@ -2870,7 +2853,7 @@ function getComponentNameFromFiber(fiber) { var enablePersistentOffscreenHostContainer = dynamicFlags.enablePersistentOffscreenHostContainer; // The rest of the flags are static for better dead code elimination. -var enableSchedulingProfiler = true; +var enableSchedulingProfiler = false; var enableProfilerTimer = true; var enableProfilerCommitHooks = true; var enableLazyElements = false; @@ -2945,9 +2928,6 @@ var ShouldCapture = var ForceUpdateForLegacySuspense = /* */ 131072; -var Forked = - /* */ - 1048576; // Static tags describe aspects of a fiber that are not specific to a render, // e.g. a fiber uses a passive effect (even if there are no updates on this particular render). // This enables us to defer more work in the unmount case, // since we can defer traversing the tree during layout to look for Passive effects, @@ -2955,22 +2935,22 @@ var Forked = var RefStatic = /* */ - 2097152; + 1048576; var LayoutStatic = /* */ - 4194304; + 2097152; var PassiveStatic = /* */ - 8388608; // These flags allow us to traverse to fibers that have effects on mount + 4194304; // These flags allow us to traverse to fibers that have effects on mount // without traversing the entire tree after every commit for // double invoking var MountLayoutDev = /* */ - 16777216; + 8388608; var MountPassiveDev = /* */ - 33554432; // Groups of flags that are used in the commit phase to skip over trees that + 16777216; // Groups of flags that are used in the commit phase to skip over trees that // don't contain effects, by checking subtreeFlags. var BeforeMutationMask = // TODO: Remove Update flag from before mutation phase by re-landing Visibility @@ -4195,24 +4175,6 @@ var ConcurrentUpdatesByDefaultMode = /* */ 32; -// TODO: This is pretty well supported by browsers. Maybe we can drop it. -var clz32 = Math.clz32 ? Math.clz32 : clz32Fallback; // Count leading zeros. -// 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(x) { - var asUint = x >>> 0; - - if (asUint === 0) { - return 32; - } - - return (31 - ((log(asUint) / LN2) | 0)) | 0; -} - // If those values are changed that package should be rebuilt and redeployed. var TotalLanes = 31; @@ -4325,59 +4287,6 @@ var IdleLane = var OffscreenLane = /* */ 1073741824; // This function is used for the experimental scheduling profiler (react-devtools-scheduling-profiler) -// It should be kept in sync with the Lanes values above. - -function getLabelForLane(lane) { - { - if (lane & SyncLane) { - return "Sync"; - } - - if (lane & InputContinuousHydrationLane) { - return "InputContinuousHydration"; - } - - if (lane & InputContinuousLane) { - return "InputContinuous"; - } - - if (lane & DefaultHydrationLane) { - return "DefaultHydration"; - } - - if (lane & DefaultLane) { - return "Default"; - } - - if (lane & TransitionHydrationLane) { - return "TransitionHydration"; - } - - if (lane & TransitionLanes) { - return "Transition"; - } - - if (lane & RetryLanes) { - return "Retry"; - } - - if (lane & SelectiveHydrationLane) { - return "SelectiveHydration"; - } - - if (lane & IdleHydrationLane) { - return "IdleHydration"; - } - - if (lane & IdleLane) { - return "Idle"; - } - - if (lane & OffscreenLane) { - return "Offscreen"; - } - } -} var NoTimestamp = -1; var nextTransitionLane = TransitionLane1; var nextRetryLane = RetryLane1; @@ -4843,6 +4752,9 @@ function markRootSuspended(root, suspendedLanes) { function markRootPinged(root, pingedLanes, eventTime) { root.pingedLanes |= root.suspendedLanes & pingedLanes; } +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 @@ -4852,6 +4764,7 @@ function markRootFinished(root, remainingLanes) { 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 @@ -4940,6 +4853,20 @@ function movePendingFibersToMemoized(root, lanes) { 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; +} var DiscreteEventPriority = SyncLane; var ContinuousEventPriority = InputContinuousLane; @@ -5278,8 +5205,6 @@ function getCurrentEventPriority() { return DefaultEventPriority; } // The Fabric renderer is secondary to the existing React Native renderer. - -var warnsIfNotActing = false; var scheduleTimeout = setTimeout; var cancelTimeout = clearTimeout; var noTimeout = -1; // ------------------- @@ -5375,6 +5300,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 } @@ -6010,350 +5938,12 @@ function flushSyncCallbacks() { return null; } -var ReactVersion = "18.0.0-3fcd81dd1-20211102"; +var ReactVersion = "18.0.0-afcb9cdc9-20211008"; -var SCHEDULING_PROFILER_VERSION = 1; +function markComponentRenderStopped() {} +function markComponentErrored(fiber, thrownValue, lanes) {} -var getLabelForLane$1 = getLabelForLane; -var TotalLanes$1 = TotalLanes; -/** - * If performance exists and supports the subset of the User Timing API that we - * require. - */ - -var supportsUserTiming = - typeof performance !== "undefined" && - typeof performance.mark === "function" && - typeof performance.clearMarks === "function"; -var supportsUserTimingV3 = false; - -{ - if (supportsUserTiming) { - var CHECK_V3_MARK = "__v3"; - var markOptions = {}; // $FlowFixMe: Ignore Flow complaining about needing a value - - Object.defineProperty(markOptions, "startTime", { - get: function() { - supportsUserTimingV3 = true; - return 0; - }, - set: function() {} - }); - - try { - // $FlowFixMe: Flow expects the User Timing level 2 API. - performance.mark(CHECK_V3_MARK, markOptions); - } catch (error) { - // Ignore - } finally { - performance.clearMarks(CHECK_V3_MARK); - } - } -} - -var laneLabels = []; -function getLaneLabels() { - if (laneLabels.length === 0) { - var lane = 1; - - for (var index = 0; index < TotalLanes$1; index++) { - laneLabels.push(getLabelForLane$1(lane)); - lane *= 2; - } - } - - return laneLabels; -} - -function markLaneToLabelMetadata() { - getLaneLabels(); - markAndClear("--react-lane-labels-" + laneLabels.join(",")); -} - -function markAndClear(name) { - performance.mark(name); - performance.clearMarks(name); -} - -function markVersionMetadata() { - markAndClear("--react-version-" + ReactVersion); - markAndClear("--profiler-version-" + SCHEDULING_PROFILER_VERSION); -} - -function markInternalModuleRanges() { - /* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */ - if ( - typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== "undefined" && - typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.getInternalModuleRanges === "function" - ) { - var ranges = __REACT_DEVTOOLS_GLOBAL_HOOK__.getInternalModuleRanges(); - - for (var i = 0; i < ranges.length; i++) { - var _ranges$i = ranges[i], - startStackFrame = _ranges$i[0], - stopStackFrame = _ranges$i[1]; - markAndClear("--react-internal-module-start-" + startStackFrame); - markAndClear("--react-internal-module-stop-" + stopStackFrame); - } - } -} - -function markCommitStarted(lanes) { - { - if (supportsUserTimingV3) { - markAndClear("--commit-start-" + lanes); // Certain types of metadata should be logged infrequently. - // Normally we would log this during module init, - // but there's no guarantee a user is profiling at that time. - // Commits happen infrequently (less than renders or state updates) - // so we log this extra information along with a commit. - // It will likely be logged more than once but that's okay. - // - // TODO Once DevTools supports starting/stopping the profiler, - // we can log this data only once (when started) and remove the per-commit logging. - - markVersionMetadata(); - markLaneToLabelMetadata(); - markInternalModuleRanges(); - } - } -} -function markCommitStopped() { - { - if (supportsUserTimingV3) { - markAndClear("--commit-stop"); - } - } -} -function markComponentRenderStarted(fiber) { - { - if (supportsUserTimingV3) { - var componentName = getComponentNameFromFiber(fiber) || "Unknown"; // TODO (scheduling profiler) Add component stack id - - markAndClear("--component-render-start-" + componentName); - } - } -} -function markComponentRenderStopped() { - { - if (supportsUserTimingV3) { - markAndClear("--component-render-stop"); - } - } -} -function markComponentPassiveEffectMountStarted(fiber) { - { - if (supportsUserTimingV3) { - var componentName = getComponentNameFromFiber(fiber) || "Unknown"; // TODO (scheduling profiler) Add component stack id - - markAndClear("--component-passive-effect-mount-start-" + componentName); - } - } -} -function markComponentPassiveEffectMountStopped() { - { - if (supportsUserTimingV3) { - markAndClear("--component-passive-effect-mount-stop"); - } - } -} -function markComponentPassiveEffectUnmountStarted(fiber) { - { - if (supportsUserTimingV3) { - var componentName = getComponentNameFromFiber(fiber) || "Unknown"; // TODO (scheduling profiler) Add component stack id - - markAndClear("--component-passive-effect-unmount-start-" + componentName); - } - } -} -function markComponentPassiveEffectUnmountStopped() { - { - if (supportsUserTimingV3) { - markAndClear("--component-passive-effect-unmount-stop"); - } - } -} -function markComponentLayoutEffectMountStarted(fiber) { - { - if (supportsUserTimingV3) { - var componentName = getComponentNameFromFiber(fiber) || "Unknown"; // TODO (scheduling profiler) Add component stack id - - markAndClear("--component-layout-effect-mount-start-" + componentName); - } - } -} -function markComponentLayoutEffectMountStopped() { - { - if (supportsUserTimingV3) { - markAndClear("--component-layout-effect-mount-stop"); - } - } -} -function markComponentLayoutEffectUnmountStarted(fiber) { - { - if (supportsUserTimingV3) { - var componentName = getComponentNameFromFiber(fiber) || "Unknown"; // TODO (scheduling profiler) Add component stack id - - markAndClear("--component-layout-effect-unmount-start-" + componentName); - } - } -} -function markComponentLayoutEffectUnmountStopped() { - { - if (supportsUserTimingV3) { - markAndClear("--component-layout-effect-unmount-stop"); - } - } -} -function markComponentErrored(fiber, thrownValue, lanes) { - { - if (supportsUserTimingV3) { - var componentName = getComponentNameFromFiber(fiber) || "Unknown"; - var phase = fiber.alternate === null ? "mount" : "update"; - var message = ""; - - if ( - thrownValue !== null && - typeof thrownValue === "object" && - typeof thrownValue.message === "string" - ) { - message = thrownValue.message; - } else if (typeof thrownValue === "string") { - message = thrownValue; - } // TODO (scheduling profiler) Add component stack id - - markAndClear("--error-" + componentName + "-" + phase + "-" + message); - } - } -} -var PossiblyWeakMap$1 = typeof WeakMap === "function" ? WeakMap : Map; // $FlowFixMe: Flow cannot handle polymorphic WeakMaps - -var wakeableIDs = new PossiblyWeakMap$1(); -var wakeableID = 0; - -function getWakeableID(wakeable) { - if (!wakeableIDs.has(wakeable)) { - wakeableIDs.set(wakeable, wakeableID++); - } - - return wakeableIDs.get(wakeable); -} - -function markComponentSuspended(fiber, wakeable, lanes) { - { - if (supportsUserTimingV3) { - var eventType = wakeableIDs.has(wakeable) ? "resuspend" : "suspend"; - var id = getWakeableID(wakeable); - var componentName = getComponentNameFromFiber(fiber) || "Unknown"; - var phase = fiber.alternate === null ? "mount" : "update"; // Following the non-standard fn.displayName convention, - // frameworks like Relay may also annotate Promises with a displayName, - // describing what operation/data the thrown Promise is related to. - // When this is available we should pass it along to the Scheduling Profiler. - - var displayName = wakeable.displayName || ""; // TODO (scheduling profiler) Add component stack id - - markAndClear( - "--suspense-" + - eventType + - "-" + - id + - "-" + - componentName + - "-" + - phase + - "-" + - lanes + - "-" + - displayName - ); - wakeable.then( - function() { - return markAndClear( - "--suspense-resolved-" + id + "-" + componentName - ); - }, - function() { - return markAndClear( - "--suspense-rejected-" + id + "-" + componentName - ); - } - ); - } - } -} -function markLayoutEffectsStarted(lanes) { - { - if (supportsUserTimingV3) { - markAndClear("--layout-effects-start-" + lanes); - } - } -} -function markLayoutEffectsStopped() { - { - if (supportsUserTimingV3) { - markAndClear("--layout-effects-stop"); - } - } -} -function markPassiveEffectsStarted(lanes) { - { - if (supportsUserTimingV3) { - markAndClear("--passive-effects-start-" + lanes); - } - } -} -function markPassiveEffectsStopped() { - { - if (supportsUserTimingV3) { - markAndClear("--passive-effects-stop"); - } - } -} -function markRenderStarted(lanes) { - { - if (supportsUserTimingV3) { - markAndClear("--render-start-" + lanes); - } - } -} -function markRenderYielded() { - { - if (supportsUserTimingV3) { - markAndClear("--render-yield"); - } - } -} -function markRenderStopped() { - { - if (supportsUserTimingV3) { - markAndClear("--render-stop"); - } - } -} -function markRenderScheduled(lane) { - { - if (supportsUserTimingV3) { - markAndClear("--schedule-render-" + lane); - } - } -} -function markForceUpdateScheduled(fiber, lane) { - { - if (supportsUserTimingV3) { - var componentName = getComponentNameFromFiber(fiber) || "Unknown"; // TODO (scheduling profiler) Add component stack id - - markAndClear("--schedule-forced-update-" + lane + "-" + componentName); - } - } -} -function markStateUpdateScheduled(fiber, lane) { - { - if (supportsUserTimingV3) { - var componentName = getComponentNameFromFiber(fiber) || "Unknown"; // TODO (scheduling profiler) Add component stack id - - markAndClear("--schedule-state-update-" + lane + "-" + componentName); - } - } -} +function markComponentSuspended(fiber, wakeable, lanes) {} var ReactCurrentBatchConfig = ReactSharedInternals.ReactCurrentBatchConfig; var NoTransition = 0; @@ -6389,11 +5979,9 @@ function shallowEqual(objA, objB) { } // Test for A's keys different from B. for (var i = 0; i < keysA.length; i++) { - var currentKey = keysA[i]; - if ( - !hasOwnProperty.call(objB, currentKey) || - !objectIs(objA[currentKey], objB[currentKey]) + !hasOwnProperty.call(objB, keysA[i]) || + !objectIs(objA[keysA[i]], objB[keysA[i]]) ) { return false; } @@ -6500,6 +6088,11 @@ function setIsRendering(rendering) { isRendering = rendering; } } +function getIsRendering() { + { + return isRendering; + } +} var ReactStrictModeWarnings = { recordUnsafeLifecycleWarnings: function(fiber, instance) {}, @@ -6859,6 +6452,7 @@ var ReactStrictModeWarnings = { * of the `value` object). */ // $FlowFixMe only called in DEV, so void return is not possible. + function typeName(value) { { // toStringTag is needed for namespaced types like Temporal.Instant @@ -6873,6 +6467,17 @@ function typeName(value) { function willCoercionThrow(value) { { + if ( + value !== null && + typeof value === "object" && + value.$$typeof === REACT_OPAQUE_ID_TYPE + ) { + // OpaqueID type is expected to throw, so React will handle it. Not sure if + // it's expected that string coercion will throw, but we'll assume it's OK. + // See https://github.com/facebook/react/issues/20127. + return; + } + try { testStringCoercion(value); return false; @@ -7949,10 +7554,6 @@ var classComponentUpdater = { if (root !== null) { entangleTransitions(root, fiber, lane); } - - { - markStateUpdateScheduled(fiber, lane); - } }, enqueueReplaceState: function(inst, payload, callback) { var fiber = get(inst); @@ -7976,10 +7577,6 @@ var classComponentUpdater = { if (root !== null) { entangleTransitions(root, fiber, lane); } - - { - markStateUpdateScheduled(fiber, lane); - } }, enqueueForceUpdate: function(inst, callback) { var fiber = get(inst); @@ -8002,10 +7599,6 @@ var classComponentUpdater = { if (root !== null) { entangleTransitions(root, fiber, lane); } - - { - markForceUpdateScheduled(fiber, lane); - } } }; @@ -8944,84 +8537,6 @@ function updateClassInstance( return shouldUpdate; } -// TODO: Use the unified fiber stack module instead of this local one? -// Intentionally not using it yet to derisk the initial implementation, because -// the way we push/pop these values is a bit unusual. If there's a mistake, I'd -// rather the ids be wrong than crash the whole reconciler. -var forkStack = []; -var forkStackIndex = 0; -var treeForkProvider = null; -var treeForkCount = 0; -var idStack = []; -var idStackIndex = 0; -var treeContextProvider = null; -var treeContextId = 1; -var treeContextOverflow = ""; - -function popTreeContext(workInProgress) { - // Restore the previous values. - // This is a bit more complicated than other context-like modules in Fiber - // because the same Fiber may appear on the stack multiple times and for - // different reasons. We have to keep popping until the work-in-progress is - // no longer at the top of the stack. - while (workInProgress === treeForkProvider) { - treeForkProvider = forkStack[--forkStackIndex]; - forkStack[forkStackIndex] = null; - treeForkCount = forkStack[--forkStackIndex]; - forkStack[forkStackIndex] = null; - } - - while (workInProgress === treeContextProvider) { - treeContextProvider = idStack[--idStackIndex]; - idStack[idStackIndex] = null; - treeContextOverflow = idStack[--idStackIndex]; - idStack[idStackIndex] = null; - treeContextId = idStack[--idStackIndex]; - idStack[idStackIndex] = null; - } -} - -var isHydrating = false; - -function enterHydrationState(fiber) { - { - return false; - } -} - -function prepareToHydrateHostInstance( - fiber, - rootContainerInstance, - hostContext -) { - { - throw new 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 new 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; -} - var didWarnAboutMaps; var didWarnAboutGenerators; var didWarnAboutStringRefs; @@ -9305,9 +8820,7 @@ function ChildReconciler(shouldTrackSideEffects) { newFiber.index = newIndex; if (!shouldTrackSideEffects) { - // During hydration, the useId algorithm needs to know which fibers are - // part of a list of children (arrays, iterators). - newFiber.flags |= Forked; + // Noop. return lastPlacedIndex; } @@ -9747,7 +9260,6 @@ function ChildReconciler(shouldTrackSideEffects) { if (newIdx === newChildren.length) { // We've reached the end of the new children. We can delete the rest. deleteRemainingChildren(returnFiber, oldFiber); - return resultingFirstChild; } @@ -9954,7 +9466,6 @@ function ChildReconciler(shouldTrackSideEffects) { if (step.done) { // We've reached the end of the new children. We can delete the rest. deleteRemainingChildren(returnFiber, oldFiber); - return resultingFirstChild; } @@ -10513,10 +10024,61 @@ var Passive$1 = /* */ 8; +var isHydrating = false; + +function enterHydrationState(fiber) { + { + return false; + } +} + +function prepareToHydrateHostInstance( + fiber, + rootContainerInstance, + hostContext +) { + { + throw new 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 new 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]; @@ -10528,6 +10090,32 @@ function resetWorkInProgressVersions() { 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. function getSuspendedCachePool() { { @@ -10538,9 +10126,11 @@ function getSuspendedCachePool() { var ReactCurrentDispatcher$1 = ReactSharedInternals.ReactCurrentDispatcher, ReactCurrentBatchConfig$1 = ReactSharedInternals.ReactCurrentBatchConfig; var didWarnAboutMismatchedHooksForComponent; +var didWarnAboutUseOpaqueIdentifier; var didWarnUncachedGetSnapshot; { + didWarnAboutUseOpaqueIdentifier = {}; didWarnAboutMismatchedHooksForComponent = new Set(); } @@ -10564,11 +10154,7 @@ var didScheduleRenderPhaseUpdate = false; // Where an update was scheduled only // TODO: Maybe there's some way to consolidate this with // `didScheduleRenderPhaseUpdate`. Or with `numberOfReRenders`. -var didScheduleRenderPhaseUpdateDuringThisPass = false; // Counts the number of useId hooks in this component. -// hydration). This counter is global, so client ids are not stable across -// render attempts. - -var globalClientIdCounter = 0; +var didScheduleRenderPhaseUpdateDuringThisPass = 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. @@ -10749,7 +10335,6 @@ function renderWithHooks( // currentHook = null; // workInProgressHook = null; // didScheduleRenderPhaseUpdate = false; - // localIdCounter = 0; // TODO Warn if no hooks are used at all during mount, then some are used during update. // Currently we will identify the update render as a mount because memoizedState === null. // This is tricky because it's valid for certain types of components (e.g. React.lazy) @@ -11246,16 +10831,254 @@ function rerenderReducer(reducer, initialArg, init) { return [newState, dispatch]; } -function mountMutableSource(source, getSnapshot, subscribe) { +function readFromUnsubscribedMutableSource(root, source, getSnapshot) { { - return undefined; + 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); // Intentioally throw an error to force React to retry synchronously. During + // the synchronous retry, it will block interleaved mutations, so we should + // get a consistent read. Therefore, the following error should never be + // visible to the user. + // We expect this error not to be thrown during the synchronous retry, + // because we blocked interleaved mutations. + + throw new Error( + "Cannot read from mutable source during the current render without tearing. This may be a bug in React. Please file an issue." + ); } } -function updateMutableSource(source, getSnapshot, subscribe) { - { - return undefined; +function useMutableSource(hook, source, getSnapshot, subscribe) { + var root = getWorkInProgressRoot(); + + if (root === null) { + throw new 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 readFromUnsubscribedMutableSource(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 lane = requestUpdateLane(fiber); + 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 lane = requestUpdateLane(fiber); + 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, + interleaved: null, + lanes: NoLanes, + dispatch: null, + lastRenderedReducer: basicStateReducer, + lastRenderedState: snapshot + }; + newQueue.dispatch = setSnapshot = dispatchSetState.bind( + null, + currentlyRenderingFiber$1, + newQueue + ); + stateHook.queue = newQueue; + stateHook.baseQueue = null; + snapshot = readFromUnsubscribedMutableSource(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 mountSyncExternalStore(subscribe, getSnapshot, getServerSnapshot) { @@ -11900,23 +11723,44 @@ function getIsUpdatingOpaqueValueInRenderPhaseInDEV() { } } -function mountId() { - var hook = mountWorkInProgressHook(); - var id; +function warnOnOpaqueIdentifierAccessInDEV(fiber) { + { + // TODO: Should warn in effects and callbacks, too + var name = getComponentNameFromFiber(fiber) || "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) + ); { - // Use a lowercase r prefix for client-generated ids. - var globalClientId = globalClientIdCounter++; - id = "r:" + globalClientId.toString(32); - } + var _id = makeId(); - hook.memoizedState = id; + mountState(_id); + return _id; + } +} + +function updateOpaqueIdentifier() { + var id = updateState()[0]; return id; } -function updateId() { - var hook = updateWorkInProgressHook(); - var id = hook.memoizedState; +function rerenderOpaqueIdentifier() { + var id = rerenderState()[0]; return id; } @@ -11944,6 +11788,7 @@ function dispatchReducerAction(fiber, queue, action) { enqueueRenderPhaseUpdate(queue, update); } else { enqueueUpdate$1(fiber, queue, update); + var eventTime = requestEventTime(); var root = scheduleUpdateOnFiber(fiber, lane, eventTime); @@ -11951,8 +11796,6 @@ function dispatchReducerAction(fiber, queue, action) { entangleTransitionUpdate(root, queue, lane); } } - - markUpdateInDevTools(fiber, lane); } function dispatchSetState(fiber, queue, action) { @@ -12032,8 +11875,6 @@ function dispatchSetState(fiber, queue, action) { entangleTransitionUpdate(root, queue, lane); } } - - markUpdateInDevTools(fiber, lane); } function isRenderPhaseUpdate(fiber) { @@ -12112,12 +11953,6 @@ function entangleTransitionUpdate(root, queue, lane) { } } -function markUpdateInDevTools(fiber, lane, action) { - { - markStateUpdateScheduled(fiber, lane); - } -} - var ContextOnlyDispatcher = { readContext: readContext, useCallback: throwInvalidHookError, @@ -12135,7 +11970,7 @@ var ContextOnlyDispatcher = { useTransition: throwInvalidHookError, useMutableSource: throwInvalidHookError, useSyncExternalStore: throwInvalidHookError, - useId: throwInvalidHookError, + useOpaqueIdentifier: throwInvalidHookError, unstable_isNewReconciler: enableNewReconciler }; @@ -12265,17 +12100,17 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; useMutableSource: function(source, getSnapshot, subscribe) { currentHookNameInDev = "useMutableSource"; mountHookTypesDev(); - return mountMutableSource(); + return mountMutableSource(source, getSnapshot, subscribe); }, useSyncExternalStore: function(subscribe, getSnapshot, getServerSnapshot) { currentHookNameInDev = "useSyncExternalStore"; mountHookTypesDev(); return mountSyncExternalStore(subscribe, getSnapshot); }, - useId: function() { - currentHookNameInDev = "useId"; + useOpaqueIdentifier: function() { + currentHookNameInDev = "useOpaqueIdentifier"; mountHookTypesDev(); - return mountId(); + return mountOpaqueIdentifier(); }, unstable_isNewReconciler: enableNewReconciler }; @@ -12373,17 +12208,17 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; useMutableSource: function(source, getSnapshot, subscribe) { currentHookNameInDev = "useMutableSource"; updateHookTypesDev(); - return mountMutableSource(); + return mountMutableSource(source, getSnapshot, subscribe); }, useSyncExternalStore: function(subscribe, getSnapshot, getServerSnapshot) { currentHookNameInDev = "useSyncExternalStore"; updateHookTypesDev(); return mountSyncExternalStore(subscribe, getSnapshot); }, - useId: function() { - currentHookNameInDev = "useId"; + useOpaqueIdentifier: function() { + currentHookNameInDev = "useOpaqueIdentifier"; updateHookTypesDev(); - return mountId(); + return mountOpaqueIdentifier(); }, unstable_isNewReconciler: enableNewReconciler }; @@ -12481,17 +12316,17 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; useMutableSource: function(source, getSnapshot, subscribe) { currentHookNameInDev = "useMutableSource"; updateHookTypesDev(); - return updateMutableSource(); + return updateMutableSource(source, getSnapshot, subscribe); }, useSyncExternalStore: function(subscribe, getSnapshot, getServerSnapshot) { currentHookNameInDev = "useSyncExternalStore"; updateHookTypesDev(); return updateSyncExternalStore(subscribe, getSnapshot); }, - useId: function() { - currentHookNameInDev = "useId"; + useOpaqueIdentifier: function() { + currentHookNameInDev = "useOpaqueIdentifier"; updateHookTypesDev(); - return updateId(); + return updateOpaqueIdentifier(); }, unstable_isNewReconciler: enableNewReconciler }; @@ -12589,17 +12424,17 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; useMutableSource: function(source, getSnapshot, subscribe) { currentHookNameInDev = "useMutableSource"; updateHookTypesDev(); - return updateMutableSource(); + return updateMutableSource(source, getSnapshot, subscribe); }, useSyncExternalStore: function(subscribe, getSnapshot, getServerSnapshot) { currentHookNameInDev = "useSyncExternalStore"; updateHookTypesDev(); return updateSyncExternalStore(subscribe, getSnapshot); }, - useId: function() { - currentHookNameInDev = "useId"; + useOpaqueIdentifier: function() { + currentHookNameInDev = "useOpaqueIdentifier"; updateHookTypesDev(); - return updateId(); + return rerenderOpaqueIdentifier(); }, unstable_isNewReconciler: enableNewReconciler }; @@ -12712,7 +12547,7 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; currentHookNameInDev = "useMutableSource"; warnInvalidHookAccess(); mountHookTypesDev(); - return mountMutableSource(); + return mountMutableSource(source, getSnapshot, subscribe); }, useSyncExternalStore: function(subscribe, getSnapshot, getServerSnapshot) { currentHookNameInDev = "useSyncExternalStore"; @@ -12720,11 +12555,11 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; mountHookTypesDev(); return mountSyncExternalStore(subscribe, getSnapshot); }, - useId: function() { - currentHookNameInDev = "useId"; + useOpaqueIdentifier: function() { + currentHookNameInDev = "useOpaqueIdentifier"; warnInvalidHookAccess(); mountHookTypesDev(); - return mountId(); + return mountOpaqueIdentifier(); }, unstable_isNewReconciler: enableNewReconciler }; @@ -12837,7 +12672,7 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; currentHookNameInDev = "useMutableSource"; warnInvalidHookAccess(); updateHookTypesDev(); - return updateMutableSource(); + return updateMutableSource(source, getSnapshot, subscribe); }, useSyncExternalStore: function(subscribe, getSnapshot, getServerSnapshot) { currentHookNameInDev = "useSyncExternalStore"; @@ -12845,11 +12680,11 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; updateHookTypesDev(); return updateSyncExternalStore(subscribe, getSnapshot); }, - useId: function() { - currentHookNameInDev = "useId"; + useOpaqueIdentifier: function() { + currentHookNameInDev = "useOpaqueIdentifier"; warnInvalidHookAccess(); updateHookTypesDev(); - return updateId(); + return updateOpaqueIdentifier(); }, unstable_isNewReconciler: enableNewReconciler }; @@ -12962,7 +12797,7 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; currentHookNameInDev = "useMutableSource"; warnInvalidHookAccess(); updateHookTypesDev(); - return updateMutableSource(); + return updateMutableSource(source, getSnapshot, subscribe); }, useSyncExternalStore: function(subscribe, getSnapshot, getServerSnapshot) { currentHookNameInDev = "useSyncExternalStore"; @@ -12970,11 +12805,11 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; updateHookTypesDev(); return updateSyncExternalStore(subscribe, getSnapshot); }, - useId: function() { - currentHookNameInDev = "useId"; + useOpaqueIdentifier: function() { + currentHookNameInDev = "useOpaqueIdentifier"; warnInvalidHookAccess(); updateHookTypesDev(); - return updateId(); + return rerenderOpaqueIdentifier(); }, unstable_isNewReconciler: enableNewReconciler }; @@ -13258,7 +13093,7 @@ function logCapturedError(boundary, errorInfo) { } } -var PossiblyWeakMap$2 = typeof WeakMap === "function" ? WeakMap : Map; +var PossiblyWeakMap$1 = typeof WeakMap === "function" ? WeakMap : Map; function createRootErrorUpdate(fiber, errorInfo, lane) { var update = createUpdate(NoTimestamp, lane); // Unmount the root by rendering null. @@ -13363,7 +13198,7 @@ function attachWakeableListeners(suspenseBoundary, root, wakeable, lanes) { var threadIDs; if (pingCache === null) { - pingCache = root.pingCache = new PossiblyWeakMap$2(); + pingCache = root.pingCache = new PossiblyWeakMap$1(); threadIDs = new Set(); pingCache.set(wakeable, threadIDs); } else { @@ -14210,12 +14045,7 @@ function completeSuspendedOffscreenHostContainer(current, workInProgress) { } function completeWork(current, workInProgress, renderLanes) { - var newProps = workInProgress.pendingProps; // Note: This intentionally doesn't check if we're hydrating because comparing - // to the current tree provider fiber is just as fast and less error-prone. - // Ideally we would have a special version of the work loop only - // for hydration. - - popTreeContext(workInProgress); + var newProps = workInProgress.pendingProps; switch (workInProgress.tag) { case IndeterminateComponent: @@ -14408,7 +14238,7 @@ function completeWork(current, workInProgress, renderLanes) { else { var prevState = current.memoizedState; prevDidTimeout = prevState !== null; - } + } // If the suspended state of the boundary changes, we need to schedule // an effect to toggle the subtree's visibility. When we switch from // fallback -> primary, the inner Offscreen fiber schedules this effect // as part of its normal complete phase. But when we switch from @@ -14421,8 +14251,8 @@ function completeWork(current, workInProgress, renderLanes) { // is active that we have to do anything special. if (nextDidTimeout && !prevDidTimeout) { - var _offscreenFiber = workInProgress.child; - _offscreenFiber.flags |= Visibility; // TODO: This will still suspend a synchronous tree if anything + var offscreenFiber = workInProgress.child; + offscreenFiber.flags |= Visibility; // TODO: This will still suspend a synchronous tree if anything // in the concurrent tree already suspended during this render. // This is a known bug. @@ -14883,10 +14713,6 @@ function updateForwardRef( var nextChildren; prepareToReadContext(workInProgress, renderLanes); - { - markComponentRenderStarted(workInProgress); - } - { ReactCurrentOwner$1.current = workInProgress; setIsRendering(true); @@ -14919,10 +14745,6 @@ function updateForwardRef( setIsRendering(false); } - { - markComponentRenderStopped(); - } - if (current !== null && !didReceiveUpdate) { bailoutHooks(current, workInProgress, renderLanes); return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes); @@ -15361,10 +15183,6 @@ function updateFunctionComponent( var nextChildren; prepareToReadContext(workInProgress, renderLanes); - { - markComponentRenderStarted(workInProgress); - } - { ReactCurrentOwner$1.current = workInProgress; setIsRendering(true); @@ -15397,10 +15215,6 @@ function updateFunctionComponent( setIsRendering(false); } - { - markComponentRenderStopped(); - } - if (current !== null && !didReceiveUpdate) { bailoutHooks(current, workInProgress, renderLanes); return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes); @@ -15588,10 +15402,6 @@ function finishClassComponent( stopProfilerTimerIfRunning(); } } else { - { - markComponentRenderStarted(workInProgress); - } - { setIsRendering(true); nextChildren = instance.render(); @@ -15608,10 +15418,6 @@ function finishClassComponent( setIsRendering(false); } - - { - markComponentRenderStopped(); - } } // React DevTools reads this flag. workInProgress.flags |= PerformedWork; @@ -15942,10 +15748,6 @@ function mountIndeterminateComponent( prepareToReadContext(workInProgress, renderLanes); var value; - { - markComponentRenderStarted(workInProgress); - } - { if ( Component.prototype && @@ -15982,10 +15784,6 @@ function mountIndeterminateComponent( setIsRendering(false); } - { - markComponentRenderStopped(); - } // React DevTools reads this flag. - workInProgress.flags |= PerformedWork; { @@ -16176,7 +15974,6 @@ function validateFunctionComponentInDev(workInProgress, Component) { var SUSPENDED_MARKER = { dehydrated: null, - treeContext: null, retryLane: NoLane }; @@ -17209,10 +17006,6 @@ function updateContextConsumer(current, workInProgress, renderLanes) { prepareToReadContext(workInProgress, renderLanes); var newValue = readContext(context); - { - markComponentRenderStarted(workInProgress); - } - var newChildren; { @@ -17222,10 +17015,6 @@ function updateContextConsumer(current, workInProgress, renderLanes) { setIsRendering(false); } - { - markComponentRenderStopped(); - } // React DevTools reads this flag. - workInProgress.flags |= PerformedWork; reconcileChildren(current, workInProgress, newChildren, renderLanes); return workInProgress.child; @@ -17773,12 +17562,6 @@ function beginWork(current, workInProgress, renderLanes) { } function unwindWork(workInProgress, renderLanes) { - // Note: This intentionally doesn't check if we're hydrating because comparing - // to the current tree provider fiber is just as fast and less error-prone. - // Ideally we would have a special version of the work loop only - // for hydration. - popTreeContext(workInProgress); - switch (workInProgress.tag) { case ClassComponent: { var Component = workInProgress.type; @@ -17874,12 +17657,6 @@ function unwindWork(workInProgress, renderLanes) { } function unwindInterruptedWork(interruptedWork, renderLanes) { - // Note: This intentionally doesn't check if we're hydrating because comparing - // to the current tree provider fiber is just as fast and less error-prone. - // Ideally we would have a special version of the work loop only - // for hydration. - popTreeContext(interruptedWork); - switch (interruptedWork.tag) { case ClassComponent: { var childContextTypes = interruptedWork.type.childContextTypes; @@ -18199,23 +17976,7 @@ function commitHookEffectListUnmount( effect.destroy = undefined; if (destroy !== undefined) { - { - if ((flags & Passive$1) !== NoFlags$1) { - markComponentPassiveEffectUnmountStarted(finishedWork); - } else if ((flags & Layout) !== NoFlags$1) { - markComponentLayoutEffectUnmountStarted(finishedWork); - } - } - safelyCallDestroy(finishedWork, nearestMountedAncestor, destroy); - - { - if ((flags & Passive$1) !== NoFlags$1) { - markComponentPassiveEffectUnmountStopped(); - } else if ((flags & Layout) !== NoFlags$1) { - markComponentLayoutEffectUnmountStopped(); - } - } } } @@ -18224,7 +17985,7 @@ function commitHookEffectListUnmount( } } -function commitHookEffectListMount(flags, finishedWork) { +function commitHookEffectListMount(tag, finishedWork) { var updateQueue = finishedWork.updateQueue; var lastEffect = updateQueue !== null ? updateQueue.lastEffect : null; @@ -18233,26 +17994,11 @@ function commitHookEffectListMount(flags, finishedWork) { var effect = firstEffect; do { - if ((effect.tag & flags) === flags) { - { - if ((flags & Passive$1) !== NoFlags$1) { - markComponentPassiveEffectMountStarted(finishedWork); - } else if ((flags & Layout) !== NoFlags$1) { - markComponentLayoutEffectMountStarted(finishedWork); - } - } // Mount - + if ((effect.tag & tag) === tag) { + // Mount var create = effect.create; effect.destroy = create(); - { - if ((flags & Passive$1) !== NoFlags$1) { - markComponentPassiveEffectMountStopped(); - } else if ((flags & Layout) !== NoFlags$1) { - markComponentLayoutEffectMountStopped(); - } - } - { var destroy = effect.destroy; @@ -18778,13 +18524,10 @@ function commitUnmount(finishedRoot, current, nearestMountedAncestor) { tag = _effect.tag; if (destroy !== undefined) { - if ((tag & Insertion) !== NoFlags$1) { - safelyCallDestroy(current, nearestMountedAncestor, destroy); - } else if ((tag & Layout) !== NoFlags$1) { - { - markComponentLayoutEffectUnmountStarted(current); - } - + if ( + (tag & Insertion) !== NoFlags$1 || + (tag & Layout) !== NoFlags$1 + ) { if (current.mode & ProfileMode) { startLayoutEffectTimer(); safelyCallDestroy(current, nearestMountedAncestor, destroy); @@ -18792,10 +18535,6 @@ function commitUnmount(finishedRoot, current, nearestMountedAncestor) { } else { safelyCallDestroy(current, nearestMountedAncestor, destroy); } - - { - markComponentLayoutEffectUnmountStopped(); - } } } @@ -19748,44 +19487,11 @@ if (typeof Symbol === "function" && Symbol.for) { TEXT_TYPE = symbolFor$1("selector.text"); } -var ReactCurrentActQueue = ReactSharedInternals.ReactCurrentActQueue; -function isLegacyActEnvironment(fiber) { - { - // Legacy mode. We preserve the behavior of React 17's act. It assumes an - // act environment whenever `jest` is defined, but you can still turn off - // spurious warnings by setting IS_REACT_ACT_ENVIRONMENT explicitly - // to false. - var isReactActEnvironmentGlobal = // $FlowExpectedError – Flow doesn't know about IS_REACT_ACT_ENVIRONMENT global - typeof IS_REACT_ACT_ENVIRONMENT !== "undefined" - ? IS_REACT_ACT_ENVIRONMENT - : undefined; // $FlowExpectedError - Flow doesn't know about jest - return warnsIfNotActing; - } -} -function isConcurrentActEnvironment() { - { - var isReactActEnvironmentGlobal = // $FlowExpectedError – Flow doesn't know about IS_REACT_ACT_ENVIRONMENT global - typeof IS_REACT_ACT_ENVIRONMENT !== "undefined" - ? IS_REACT_ACT_ENVIRONMENT - : undefined; - - if (!isReactActEnvironmentGlobal && ReactCurrentActQueue.current !== null) { - // TODO: Include link to relevant documentation page. - error( - "The current testing environment is not configured to support " + - "act(...)" - ); - } - - return isReactActEnvironmentGlobal; - } -} - var ceil = Math.ceil; var ReactCurrentDispatcher$2 = ReactSharedInternals.ReactCurrentDispatcher, ReactCurrentOwner$2 = ReactSharedInternals.ReactCurrentOwner, ReactCurrentBatchConfig$2 = ReactSharedInternals.ReactCurrentBatchConfig, - ReactCurrentActQueue$1 = ReactSharedInternals.ReactCurrentActQueue; + ReactCurrentActQueue = ReactSharedInternals.ReactCurrentActQueue; var NoContext = /* */ 0; @@ -19838,9 +19544,7 @@ var workInProgressRootIncludedLanes = NoLanes; // The work left over by componen var workInProgressRootSkippedLanes = NoLanes; // Lanes that were updated (in an interleaved event) during this render. -var workInProgressRootInterleavedUpdatedLanes = NoLanes; // Lanes that were updated during the render phase (*not* an interleaved event). - -var workInProgressRootRenderPhaseUpdatedLanes = NoLanes; // Lanes that were pinged (in an interleaved event) during this render. +var workInProgressRootUpdatedLanes = NoLanes; // Lanes that were pinged (in an interleaved event) during this render. var workInProgressRootPingedLanes = NoLanes; // 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. @@ -19867,7 +19571,7 @@ var legacyErrorBoundariesThatAlreadyFailed = null; // Only used when enableProfi var rootDoesHavePassiveEffects = false; var rootWithPendingPassiveEffects = null; var pendingPassiveEffectsLanes = NoLanes; -var pendingPassiveProfilerEffects = []; +var pendingPassiveProfilerEffects = []; // Use these to prevent an infinite loop of nested updates var NESTED_UPDATE_LIMIT = 50; var nestedUpdateCount = 0; @@ -19972,80 +19676,60 @@ function requestRetryLane(fiber) { function scheduleUpdateOnFiber(fiber, lane, eventTime) { checkForNestedUpdates(); + warnAboutRenderPhaseUpdatesInDEV(fiber); var root = markUpdateLaneFromFiberToRoot(fiber, lane); if (root === null) { return null; + } + + { + if (isDevToolsPresent) { + addFiberToLanesMap(root, fiber, lane); + } } // Mark that the root has a pending update. 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. + if ((executionContext & RenderContext) === NoContext) { + 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); + } + } + + ensureRootIsScheduled(root, eventTime); + if ( - (executionContext & RenderContext) !== NoLanes && - root === workInProgressRoot + lane === SyncLane && + executionContext === NoContext && + (fiber.mode & ConcurrentMode) === NoMode && // Treat `act` as if it's inside `batchedUpdates`, even in legacy mode. + !ReactCurrentActQueue.isBatchingLegacy ) { - // This update was dispatched during the render phase. This is a mistake - // if the update originates from user space (with the exception of local - // hook updates, which are handled differently and don't reach this - // function), but there are some internal React features that use this as - // an implementation detail, like selective hydration. - warnAboutRenderPhaseUpdatesInDEV(fiber); // Track lanes that were updated during the render phase - - workInProgressRootRenderPhaseUpdatedLanes = mergeLanes( - workInProgressRootRenderPhaseUpdatedLanes, - lane - ); - } else { - // This is a normal update, scheduled from outside the render phase. For - // example, during an input event. - { - if (isDevToolsPresent) { - addFiberToLanesMap(root, fiber, lane); - } - } - - warnIfUpdatesNotWrappedWithActDEV(fiber); - - 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. - if ((executionContext & RenderContext) === NoContext) { - workInProgressRootInterleavedUpdatedLanes = mergeLanes( - workInProgressRootInterleavedUpdatedLanes, - 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); - } - } - - ensureRootIsScheduled(root, eventTime); - - if ( - lane === SyncLane && - executionContext === NoContext && - (fiber.mode & ConcurrentMode) === NoMode && // Treat `act` as if it's inside `batchedUpdates`, even in legacy mode. - !ReactCurrentActQueue$1.isBatchingLegacy - ) { - // Flush the synchronous work now, unless we're already working or inside - // a batch. This is intentionally inside scheduleUpdateOnFiber instead of - // scheduleCallbackForFiber to preserve the ability to schedule a callback - // without immediately flushing it. We only do this for user-initiated - // updates, to preserve historical behavior of legacy mode. - resetRenderTimer(); - flushSyncCallbacksOnlyInLegacyMode(); - } + // Flush the synchronous work now, unless we're already working or inside + // a batch. This is intentionally inside scheduleUpdateOnFiber instead of + // scheduleCallbackForFiber to preserve the ability to schedule a callback + // without immediately flushing it. We only do this for user-initiated + // updates, to preserve historical behavior of legacy mode. + resetRenderTimer(); + flushSyncCallbacksOnlyInLegacyMode(); } return root; @@ -20150,7 +19834,7 @@ function ensureRootIsScheduled(root, currentTime) { // Scheduler task, rather than an `act` task, cancel it and re-scheduled // on the `act` queue. !( - ReactCurrentActQueue$1.current !== null && + ReactCurrentActQueue.current !== null && existingCallbackNode !== fakeActCallbackNode ) ) { @@ -20182,8 +19866,8 @@ function ensureRootIsScheduled(root, currentTime) { // Special case: Sync React callbacks are scheduled on a special // internal queue if (root.tag === LegacyRoot) { - if (ReactCurrentActQueue$1.isBatchingLegacy !== null) { - ReactCurrentActQueue$1.didScheduleLegacyUpdate = true; + if (ReactCurrentActQueue.isBatchingLegacy !== null) { + ReactCurrentActQueue.didScheduleLegacyUpdate = true; } scheduleLegacySyncCallback(performSyncWorkOnRoot.bind(null, root)); @@ -20373,26 +20057,7 @@ function recoverFromConcurrentError(root, errorRetryLanes) { clearContainer(root.containerInfo); } - var exitStatus; - var MAX_ERROR_RETRY_ATTEMPTS = 50; - - for (var i = 0; i < MAX_ERROR_RETRY_ATTEMPTS; i++) { - exitStatus = renderRootSync(root, errorRetryLanes); - - if ( - exitStatus === RootErrored && - workInProgressRootRenderPhaseUpdatedLanes !== NoLanes - ) { - // There was a render phase update during this render. Some internal React - // implementation details may use this as a trick to schedule another - // render pass. To protect against an inifinite loop, eventually - // we'll give up. - continue; - } - - break; - } - + var exitStatus = renderRootSync(root, errorRetryLanes); executionContext = prevExecutionContext; return exitStatus; } @@ -20579,10 +20244,7 @@ function markRootSuspended$1(root, suspendedLanes) { // TODO: Lol maybe there's a better way to factor this besides this // obnoxiously named function :) suspendedLanes = removeLanes(suspendedLanes, workInProgressRootPingedLanes); - suspendedLanes = removeLanes( - suspendedLanes, - workInProgressRootInterleavedUpdatedLanes - ); + suspendedLanes = removeLanes(suspendedLanes, workInProgressRootUpdatedLanes); markRootSuspended(root, suspendedLanes); } // This is the entry point for synchronous tasks that don't go // through Scheduler @@ -20608,16 +20270,31 @@ function performSyncWorkOnRoot(root) { var exitStatus = renderRootSync(root, lanes); if (root.tag !== LegacyRoot && exitStatus === RootErrored) { - // If something threw an error, try rendering one more time. We'll render + var prevExecutionContext = executionContext; + executionContext |= RetryAfterError; // If an error occurred during hydration, + // discard server response and fall back to client side render. + + if (root.isDehydrated) { + root.isDehydrated = false; + + { + errorHydratingContainer(root.containerInfo); + } + + 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. + var errorRetryLanes = getLanesToRetrySynchronouslyOnError(root); if (errorRetryLanes !== NoLanes) { lanes = errorRetryLanes; - exitStatus = recoverFromConcurrentError(root, errorRetryLanes); + exitStatus = renderRootSync(root, lanes); } + + executionContext = prevExecutionContext; } if (exitStatus === RootFatalErrored) { @@ -20650,7 +20327,7 @@ function batchedUpdates$1(fn, a) { if ( executionContext === NoContext && // Treat `act` as if it's inside `batchedUpdates`, even in legacy mode. - !ReactCurrentActQueue$1.isBatchingLegacy + !ReactCurrentActQueue.isBatchingLegacy ) { resetRenderTimer(); flushSyncCallbacksOnlyInLegacyMode(); @@ -20738,8 +20415,7 @@ function prepareFreshStack(root, lanes) { workInProgressRootExitStatus = RootIncomplete; workInProgressRootFatalError = null; workInProgressRootSkippedLanes = NoLanes; - workInProgressRootInterleavedUpdatedLanes = NoLanes; - workInProgressRootRenderPhaseUpdatedLanes = NoLanes; + workInProgressRootUpdatedLanes = NoLanes; workInProgressRootPingedLanes = NoLanes; enqueueInterleavedUpdates(); @@ -20881,7 +20557,7 @@ function renderDidSuspendDelayIfPossible() { if ( workInProgressRoot !== null && (includesNonIdleWork(workInProgressRootSkippedLanes) || - includesNonIdleWork(workInProgressRootInterleavedUpdatedLanes)) + includesNonIdleWork(workInProgressRootUpdatedLanes)) ) { // 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 @@ -20932,10 +20608,6 @@ function renderRootSync(root, lanes) { prepareFreshStack(root, lanes); } - { - markRenderStarted(lanes); - } - do { try { workLoopSync(); @@ -20957,10 +20629,6 @@ function renderRootSync(root, lanes) { ); } - { - markRenderStopped(); - } // Set this to null to indicate there's no in-progress render. - workInProgressRoot = null; workInProgressRootRenderLanes = NoLanes; return workInProgressRootExitStatus; @@ -21002,10 +20670,6 @@ function renderRootConcurrent(root, lanes) { prepareFreshStack(root, lanes); } - { - markRenderStarted(lanes); - } - do { try { workLoopConcurrent(); @@ -21020,18 +20684,8 @@ function renderRootConcurrent(root, lanes) { executionContext = prevExecutionContext; if (workInProgress !== null) { - // Still work remaining. - { - markRenderYielded(); - } - return RootIncomplete; } else { - // Completed the tree. - { - markRenderStopped(); - } // Set this to null to indicate there's no in-progress render. - workInProgressRoot = null; workInProgressRootRenderLanes = NoLanes; // Return the final exit status. @@ -21203,15 +20857,7 @@ function commitRootImpl(root, renderPriorityLevel) { var finishedWork = root.finishedWork; var lanes = root.finishedLanes; - { - markCommitStarted(lanes); - } - if (finishedWork === null) { - { - markCommitStopped(); - } - return null; } else { { @@ -21260,10 +20906,7 @@ function commitRootImpl(root, renderPriorityLevel) { if (!rootDoesHavePassiveEffects) { rootDoesHavePassiveEffects = true; scheduleCallback$1(NormalPriority, function() { - flushPassiveEffects(); // This render triggered passive effects: release the root cache pool - // *after* passive effects fire to avoid freeing a cache pool that may - // be referenced by a node in the tree (HostRoot, Cache boundary etc) - + flushPassiveEffects(); return null; }); } @@ -21317,15 +20960,7 @@ function commitRootImpl(root, renderPriorityLevel) { root.current = finishedWork; // The next phase is the layout phase, where we call effects that read - { - markLayoutEffectsStarted(lanes); - } - commitLayoutEffects(finishedWork, root, lanes); - - { - markLayoutEffectsStopped(); - } // opportunity to paint. requestPaint(); @@ -21429,10 +21064,6 @@ function commitRootImpl(root, renderPriorityLevel) { flushSyncCallbacks(); - { - markCommitStopped(); - } - return null; } @@ -21455,7 +21086,7 @@ function flushPassiveEffects() { return flushPassiveEffectsImpl(); } finally { setCurrentUpdatePriority(previousPriority); - ReactCurrentBatchConfig$2.transition = prevTransition; // Once passive effects have run for the tree - giving components a + ReactCurrentBatchConfig$2.transition = prevTransition; } } @@ -21481,7 +21112,6 @@ function flushPassiveEffectsImpl() { } var root = rootWithPendingPassiveEffects; - var lanes = pendingPassiveEffectsLanes; rootWithPendingPassiveEffects = null; // TODO: This is sometimes out of sync with rootWithPendingPassiveEffects. // Figure out why and fix it. It's not causing any known issues (probably // because it's only used for profiling), but it's a refactor hazard. @@ -21492,10 +21122,6 @@ function flushPassiveEffectsImpl() { throw new Error("Cannot flush passive effects while already rendering."); } - { - markPassiveEffectsStarted(lanes); - } - var prevExecutionContext = executionContext; executionContext |= CommitContext; commitPassiveUnmountEffects(root.current); @@ -21511,10 +21137,6 @@ function flushPassiveEffectsImpl() { } } - { - markPassiveEffectsStopped(); - } - { commitDoubleInvokeEffectsInDEV(root.current, true); } @@ -21645,7 +21267,6 @@ function pingSuspendedRoot(root, wakeable, pingedLanes) { var eventTime = requestEventTime(); markRootPinged(root, pingedLanes); - warnIfSuspenseResolutionNotWrappedWithActDEV(root); if ( workInProgressRoot === root && @@ -21971,7 +21592,11 @@ var didWarnAboutUpdateInRenderForAnotherComponent; function warnAboutRenderPhaseUpdatesInDEV(fiber) { { - if (isRendering && !getIsUpdatingOpaqueValueInRenderPhaseInDEV()) { + if ( + isRendering && + (executionContext & RenderContext) !== NoContext && + !getIsUpdatingOpaqueValueInRenderPhaseInDEV() + ) { switch (fiber.tag) { case FunctionComponent: case ForwardRef: @@ -22036,7 +21661,7 @@ function scheduleCallback$1(priorityLevel, callback) { { // If we're currently inside an `act` scope, bypass Scheduler and push to // the `act` queue instead. - var actQueue = ReactCurrentActQueue$1.current; + var actQueue = ReactCurrentActQueue.current; if (actQueue !== null) { actQueue.push(callback); @@ -22057,92 +21682,7 @@ function cancelCallback$1(callbackNode) { function shouldForceFlushFallbacksInDEV() { // Never force flush in production. This function should get stripped out. - return ReactCurrentActQueue$1.current !== null; -} - -function warnIfUpdatesNotWrappedWithActDEV(fiber) { - { - if (fiber.mode & ConcurrentMode) { - if (!isConcurrentActEnvironment()) { - // Not in an act environment. No need to warn. - return; - } - } else { - // Legacy mode has additional cases where we suppress a warning. - if (!isLegacyActEnvironment()) { - // Not in an act environment. No need to warn. - return; - } - - if (executionContext !== NoContext) { - // Legacy mode doesn't warn if the update is batched, i.e. - // batchedUpdates or flushSync. - return; - } - - if ( - fiber.tag !== FunctionComponent && - fiber.tag !== ForwardRef && - fiber.tag !== SimpleMemoComponent - ) { - // For backwards compatibility with pre-hooks code, legacy mode only - // warns for updates that originate from a hook. - return; - } - } - - if (ReactCurrentActQueue$1.current === null) { - 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://reactjs.org/link/wrap-tests-with-act", - getComponentNameFromFiber(fiber) - ); - } finally { - if (previousFiber) { - setCurrentFiber(fiber); - } else { - resetCurrentFiber(); - } - } - } - } -} - -function warnIfSuspenseResolutionNotWrappedWithActDEV(root) { - { - if ( - root.tag !== LegacyRoot && - isConcurrentActEnvironment() && - ReactCurrentActQueue$1.current === null - ) { - error( - "A suspended resource finished loading inside a test, but the event " + - "was not wrapped in act(...).\n\n" + - "When testing, code that resolves suspended data should be wrapped " + - "into act(...):\n\n" + - "act(() => {\n" + - " /* finish loading suspended data */\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://reactjs.org/link/wrap-tests-with-act" - ); - } - } + return ReactCurrentActQueue.current !== null; } /* eslint-disable react-internal/prod-error-codes */ @@ -23441,10 +22981,6 @@ function updateContainer(element, container, parentComponent, callback) { var eventTime = requestEventTime(); var lane = requestUpdateLane(current$1); - { - markRenderScheduled(lane); - } - var context = getContextForSubtree(parentComponent); if (container.context === null) { @@ -24279,24 +23815,5 @@ exports.sendAccessibilityEvent = sendAccessibilityEvent; exports.stopSurface = stopSurface; exports.unmountComponentAtNode = unmountComponentAtNode; - /** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -/* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */ - -// Don't require this file directly; it's embedded by Rollup during build. - -if ( - typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' && - typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop === - 'function' -) { - __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error()); -} - })(); } diff --git a/Libraries/Renderer/implementations/ReactFabric-prod.fb.js b/Libraries/Renderer/implementations/ReactFabric-prod.fb.js index 085993091a3..73b6f5eb765 100644 --- a/Libraries/Renderer/implementations/ReactFabric-prod.fb.js +++ b/Libraries/Renderer/implementations/ReactFabric-prod.fb.js @@ -7,7 +7,7 @@ * @noflow * @nolint * @preventMunge - * @generated SignedSource<<5f9a6b5a20e93d43bb11fbe8e20384f1>> + * @generated SignedSource<<0641813b146d4710c4029f156d65891e>> */ "use strict"; @@ -927,7 +927,7 @@ eventPluginOrder = Array.prototype.slice.call([ "ReactNativeBridgeEventPlugin" ]); recomputePluginOrdering(); -var injectedNamesToPlugins$jscomp$inline_218 = { +var injectedNamesToPlugins$jscomp$inline_219 = { ResponderEventPlugin: ResponderEventPlugin, ReactNativeBridgeEventPlugin: { eventTypes: {}, @@ -962,33 +962,33 @@ var injectedNamesToPlugins$jscomp$inline_218 = { } } }, - isOrderingDirty$jscomp$inline_219 = !1, - pluginName$jscomp$inline_220; -for (pluginName$jscomp$inline_220 in injectedNamesToPlugins$jscomp$inline_218) + isOrderingDirty$jscomp$inline_220 = !1, + pluginName$jscomp$inline_221; +for (pluginName$jscomp$inline_221 in injectedNamesToPlugins$jscomp$inline_219) if ( - injectedNamesToPlugins$jscomp$inline_218.hasOwnProperty( - pluginName$jscomp$inline_220 + injectedNamesToPlugins$jscomp$inline_219.hasOwnProperty( + pluginName$jscomp$inline_221 ) ) { - var pluginModule$jscomp$inline_221 = - injectedNamesToPlugins$jscomp$inline_218[pluginName$jscomp$inline_220]; + var pluginModule$jscomp$inline_222 = + injectedNamesToPlugins$jscomp$inline_219[pluginName$jscomp$inline_221]; if ( - !namesToPlugins.hasOwnProperty(pluginName$jscomp$inline_220) || - namesToPlugins[pluginName$jscomp$inline_220] !== - pluginModule$jscomp$inline_221 + !namesToPlugins.hasOwnProperty(pluginName$jscomp$inline_221) || + namesToPlugins[pluginName$jscomp$inline_221] !== + pluginModule$jscomp$inline_222 ) { - if (namesToPlugins[pluginName$jscomp$inline_220]) + if (namesToPlugins[pluginName$jscomp$inline_221]) throw Error( "EventPluginRegistry: Cannot inject two different event plugins using the same name, `" + - (pluginName$jscomp$inline_220 + "`.") + (pluginName$jscomp$inline_221 + "`.") ); namesToPlugins[ - pluginName$jscomp$inline_220 - ] = pluginModule$jscomp$inline_221; - isOrderingDirty$jscomp$inline_219 = !0; + pluginName$jscomp$inline_221 + ] = pluginModule$jscomp$inline_222; + isOrderingDirty$jscomp$inline_220 = !0; } } -isOrderingDirty$jscomp$inline_219 && recomputePluginOrdering(); +isOrderingDirty$jscomp$inline_220 && recomputePluginOrdering(); function getInstanceFromInstance(instanceHandle) { return instanceHandle; } @@ -1619,13 +1619,6 @@ function onCommitRoot(root) { ); } catch (err) {} } -var clz32 = Math.clz32 ? Math.clz32 : clz32Fallback, - log = Math.log, - LN2 = Math.LN2; -function clz32Fallback(x) { - x >>>= 0; - return 0 === x ? 32 : (31 - ((log(x) / LN2) | 0)) | 0; -} var nextTransitionLane = 64, nextRetryLane = 4194304; function getHighestPriorityLanes(lanes) { @@ -1809,6 +1802,12 @@ function markRootEntangled(root, entangledLanes) { rootEntangledLanes &= ~lane; } } +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 currentUpdatePriority = 0; function lanesToEventPriority(lanes) { lanes &= -lanes; @@ -2129,14 +2128,12 @@ function shallowEqual(objA, objB) { var keysA = Object.keys(objA), keysB = Object.keys(objB); if (keysA.length !== keysB.length) return !1; - for (keysB = 0; keysB < keysA.length; keysB++) { - var currentKey = keysA[keysB]; + for (keysB = 0; keysB < keysA.length; keysB++) if ( - !hasOwnProperty.call(objB, currentKey) || - !objectIs(objA[currentKey], objB[currentKey]) + !hasOwnProperty.call(objB, keysA[keysB]) || + !objectIs(objA[keysA[keysB]], objB[keysA[keysB]]) ) return !1; - } return !0; } function describeFiber(fiber) { @@ -2634,26 +2631,6 @@ function mountClassInstance(workInProgress, ctor, newProps, renderLanes) { "function" === typeof instance.componentDidMount && (workInProgress.flags |= 4); } -var forkStack = [], - forkStackIndex = 0, - treeForkProvider = null, - idStack = [], - idStackIndex = 0, - treeContextProvider = null; -function popTreeContext(workInProgress) { - for (; workInProgress === treeForkProvider; ) - (treeForkProvider = forkStack[--forkStackIndex]), - (forkStack[forkStackIndex] = null), - --forkStackIndex, - (forkStack[forkStackIndex] = null); - for (; workInProgress === treeContextProvider; ) - (treeContextProvider = idStack[--idStackIndex]), - (idStack[idStackIndex] = null), - --idStackIndex, - (idStack[idStackIndex] = null), - --idStackIndex, - (idStack[idStackIndex] = null); -} function coerceRef(returnFiber, current, element) { returnFiber = element.ref; if ( @@ -2748,8 +2725,7 @@ function ChildReconciler(shouldTrackSideEffects) { } function placeChild(newFiber, lastPlacedIndex, newIndex) { newFiber.index = newIndex; - if (!shouldTrackSideEffects) - return (newFiber.flags |= 1048576), lastPlacedIndex; + if (!shouldTrackSideEffects) return lastPlacedIndex; newIndex = newFiber.alternate; if (null !== newIndex) return ( @@ -3353,8 +3329,7 @@ var ReactCurrentDispatcher$1 = ReactSharedInternals.ReactCurrentDispatcher, currentHook = null, workInProgressHook = null, didScheduleRenderPhaseUpdate = !1, - didScheduleRenderPhaseUpdateDuringThisPass = !1, - globalClientIdCounter = 0; + didScheduleRenderPhaseUpdateDuringThisPass = !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://reactjs.org/link/invalid-hook-call for tips about how to debug and fix this problem." @@ -3557,7 +3532,104 @@ function rerenderReducer(reducer) { } return [newState, dispatch]; } -function updateMutableSource() {} +function readFromUnsubscribedMutableSource(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 may be 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 readFromUnsubscribedMutableSource(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); + objectIs(version, maybeNewVersion) || + ((maybeNewVersion = getSnapshot(source._source)), + objectIs(snapshot, maybeNewVersion) || + (setSnapshot(maybeNewVersion), + (maybeNewVersion = requestUpdateLane(fiber)), + (root.mutableReadLanes |= maybeNewVersion & root.pendingLanes)), + markRootEntangled(root, root.mutableReadLanes)); + }, + [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); + 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, + interleaved: null, + lanes: 0, + dispatch: null, + lastRenderedReducer: basicStateReducer, + lastRenderedState: snapshot + }), + (hook.dispatch = setSnapshot = dispatchSetState.bind( + null, + currentlyRenderingFiber$1, + hook + )), + (_dispatcher$useState.queue = hook), + (_dispatcher$useState.baseQueue = null), + (snapshot = readFromUnsubscribedMutableSource(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 mountSyncExternalStore(subscribe, getSnapshot) { var fiber = currentlyRenderingFiber$1, hook = mountWorkInProgressHook(); @@ -3680,7 +3752,7 @@ function updateEffectImpl(fiberFlags, hookFlags, create, deps) { hook.memoizedState = pushEffect(1 | hookFlags, create, destroy, deps); } function mountEffect(create, deps) { - return mountEffectImpl(8390656, 8, create, deps); + return mountEffectImpl(4196352, 8, create, deps); } function updateEffect(create, deps) { return updateEffectImpl(2048, 8, create, deps); @@ -3760,9 +3832,6 @@ function startTransition(setPending, callback) { (ReactCurrentBatchConfig$1.transition = prevTransition); } } -function updateId() { - return updateWorkInProgressHook().memoizedState; -} function dispatchReducerAction(fiber, queue, action) { var lane = requestUpdateLane(fiber); action = { @@ -3870,7 +3939,7 @@ var ContextOnlyDispatcher = { useTransition: throwInvalidHookError, useMutableSource: throwInvalidHookError, useSyncExternalStore: throwInvalidHookError, - useId: throwInvalidHookError, + useOpaqueIdentifier: throwInvalidHookError, unstable_isNewReconciler: !1 }, HooksDispatcherOnMount = { @@ -3958,12 +4027,18 @@ var ContextOnlyDispatcher = { mountWorkInProgressHook().memoizedState = _mountState2; return [isPending, _mountState2]; }, - useMutableSource: function() {}, - useSyncExternalStore: mountSyncExternalStore, - useId: function() { + useMutableSource: function(source, getSnapshot, subscribe) { var hook = mountWorkInProgressHook(); - var id = "r:" + (globalClientIdCounter++).toString(32); - return (hook.memoizedState = id); + hook.memoizedState = { + refs: { getSnapshot: getSnapshot, setSnapshot: null }, + source: source, + subscribe: subscribe + }; + return useMutableSource(hook, source, getSnapshot, subscribe); + }, + useSyncExternalStore: mountSyncExternalStore, + useOpaqueIdentifier: function() { + throw Error("Not yet implemented"); }, unstable_isNewReconciler: !1 }, @@ -4046,7 +4121,9 @@ var ContextOnlyDispatcher = { } return nextSnapshot; }, - useId: updateId, + useOpaqueIdentifier: function() { + return updateReducer(basicStateReducer)[0]; + }, unstable_isNewReconciler: !1 }, HooksDispatcherOnRerender = { @@ -4089,7 +4166,9 @@ var ContextOnlyDispatcher = { }, useMutableSource: updateMutableSource, useSyncExternalStore: mountSyncExternalStore, - useId: updateId, + useOpaqueIdentifier: function() { + return rerenderReducer(basicStateReducer)[0]; + }, unstable_isNewReconciler: !1 }; function createCapturedValue(value, source) { @@ -4355,8 +4434,8 @@ function bubbleProperties(completedWork) { if (didBailout) for (var child$36 = completedWork.child; null !== child$36; ) (newChildLanes |= child$36.lanes | child$36.childLanes), - (subtreeFlags |= child$36.subtreeFlags & 14680064), - (subtreeFlags |= child$36.flags & 14680064), + (subtreeFlags |= child$36.subtreeFlags & 7340032), + (subtreeFlags |= child$36.flags & 7340032), (child$36.return = completedWork), (child$36 = child$36.sibling); else @@ -4397,7 +4476,6 @@ function completeSuspendedOffscreenHostContainer(current, workInProgress) { } function completeWork(current, workInProgress, renderLanes) { var newProps = workInProgress.pendingProps; - popTreeContext(workInProgress); switch (workInProgress.tag) { case 2: case 16: @@ -4521,7 +4599,7 @@ function completeWork(current, workInProgress, renderLanes) { workInProgressRootExitStatus = 4; null === workInProgressRoot || (0 === (workInProgressRootSkippedLanes & 268435455) && - 0 === (workInProgressRootInterleavedUpdatedLanes & 268435455)) || + 0 === (workInProgressRootUpdatedLanes & 268435455)) || markRootSuspended$1( workInProgressRoot, workInProgressRootRenderLanes @@ -4576,7 +4654,7 @@ function completeWork(current, workInProgress, renderLanes) { for (newProps = workInProgress.child; null !== newProps; ) (renderLanes = newProps), (type = current), - (renderLanes.flags &= 14680066), + (renderLanes.flags &= 7340034), (renderedTail = renderLanes.alternate), null === renderedTail ? ((renderLanes.childLanes = 0), @@ -5192,7 +5270,7 @@ function pushHostRootContext(workInProgress) { pushTopLevelContextObject(workInProgress, root.context, !1); pushHostContainer(workInProgress, root.containerInfo); } -var SUSPENDED_MARKER = { dehydrated: null, treeContext: null, retryLane: 0 }; +var SUSPENDED_MARKER = { dehydrated: null, retryLane: 0 }; function mountSuspenseOffscreenState(renderLanes) { return { baseLanes: renderLanes, cachePool: null }; } @@ -5417,7 +5495,7 @@ function updateSuspenseFallbackChildren( primaryChildren ))), (current.subtreeFlags = - currentPrimaryChildFragment.subtreeFlags & 14680064)); + currentPrimaryChildFragment.subtreeFlags & 7340032)); null !== currentFallbackChildFragment ? (fallbackChildren = createWorkInProgress( currentFallbackChildFragment, @@ -5641,7 +5719,6 @@ function attemptEarlyBailoutIfNoScheduledUpdate( return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes); } function unwindWork(workInProgress) { - popTreeContext(workInProgress); switch (workInProgress.tag) { case 1: isContextProvider(workInProgress.type) && popContext(); @@ -5699,13 +5776,6 @@ function safelyDetachRef(current, nearestMountedAncestor) { } else ref.current = null; } -function safelyCallDestroy(current, nearestMountedAncestor, destroy) { - try { - destroy(); - } catch (error) { - captureCommitPhaseError(current, nearestMountedAncestor, error); - } -} var shouldFireAfterActiveInstanceBlur = !1; function commitBeforeMutationEffects(root, firstChild) { for (nextEffect = firstChild; null !== nextEffect; ) @@ -5770,7 +5840,7 @@ function commitBeforeMutationEffects(root, firstChild) { function commitHookEffectListUnmount( flags, finishedWork, - nearestMountedAncestor + nearestMountedAncestor$jscomp$0 ) { var updateQueue = finishedWork.updateQueue; updateQueue = null !== updateQueue ? updateQueue.lastEffect : null; @@ -5780,20 +5850,27 @@ function commitHookEffectListUnmount( if ((effect.tag & flags) === flags) { var destroy = effect.destroy; effect.destroy = void 0; - void 0 !== destroy && - safelyCallDestroy(finishedWork, nearestMountedAncestor, destroy); + if (void 0 !== destroy) { + var current = finishedWork, + nearestMountedAncestor = nearestMountedAncestor$jscomp$0; + try { + destroy(); + } catch (error) { + captureCommitPhaseError(current, nearestMountedAncestor, error); + } + } } effect = effect.next; } while (effect !== updateQueue); } } -function commitHookEffectListMount(flags, 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 & flags) === flags) { + if ((effect.tag & tag) === tag) { var create$80 = effect.create; effect.destroy = create$80(); } @@ -5900,11 +5977,22 @@ function commitMutationEffects(root, firstChild) { var _effect = effect, destroy = _effect.destroy, tag = _effect.tag; - void 0 !== destroy && - (0 !== (tag & 2) - ? safelyCallDestroy(current, root, destroy) - : 0 !== (tag & 4) && - safelyCallDestroy(current, root, destroy)); + if ( + void 0 !== destroy && + (0 !== (tag & 2) || 0 !== (tag & 4)) + ) { + _effect = current; + var nearestMountedAncestor = root; + try { + destroy(); + } catch (error) { + captureCommitPhaseError( + _effect, + nearestMountedAncestor, + error + ); + } + } effect = effect.next; } while (effect !== firstEffect); } @@ -6134,8 +6222,7 @@ var ceil = Math.ceil, workInProgressRootExitStatus = 0, workInProgressRootFatalError = null, workInProgressRootSkippedLanes = 0, - workInProgressRootInterleavedUpdatedLanes = 0, - workInProgressRootRenderPhaseUpdatedLanes = 0, + workInProgressRootUpdatedLanes = 0, workInProgressRootPingedLanes = 0, globalMostRecentFallbackTime = 0, workInProgressRootRenderTargetTime = Infinity, @@ -6195,19 +6282,16 @@ function scheduleUpdateOnFiber(fiber, lane, eventTime) { var root = markUpdateLaneFromFiberToRoot(fiber, lane); if (null === root) return null; markRootUpdated(root, lane, eventTime); - 0 !== (executionContext & 2) && root === workInProgressRoot - ? (workInProgressRootRenderPhaseUpdatedLanes |= lane) - : (root === workInProgressRoot && - (0 === (executionContext & 2) && - (workInProgressRootInterleavedUpdatedLanes |= lane), - 4 === workInProgressRootExitStatus && - markRootSuspended$1(root, workInProgressRootRenderLanes)), - ensureRootIsScheduled(root, eventTime), - 1 === lane && - 0 === executionContext && - 0 === (fiber.mode & 1) && - ((workInProgressRootRenderTargetTime = now() + 500), - includesLegacySyncCallbacks && flushSyncCallbacks())); + root === workInProgressRoot && + (0 === (executionContext & 2) && (workInProgressRootUpdatedLanes |= lane), + 4 === workInProgressRootExitStatus && + markRootSuspended$1(root, workInProgressRootRenderLanes)); + ensureRootIsScheduled(root, eventTime); + 1 === lane && + 0 === executionContext && + 0 === (fiber.mode & 1) && + ((workInProgressRootRenderTargetTime = now() + 500), + includesLegacySyncCallbacks && flushSyncCallbacks()); return root; } function markUpdateLaneFromFiberToRoot(sourceFiber, lane) { @@ -6454,15 +6538,9 @@ function recoverFromConcurrentError(root, errorRetryLanes) { var prevExecutionContext = executionContext; executionContext |= 8; root.isDehydrated && ((root.isDehydrated = !1), shim(root.containerInfo)); - for ( - var exitStatus, i = 0; - 50 > i && - ((exitStatus = renderRootSync(root, errorRetryLanes)), - 2 === exitStatus && 0 !== workInProgressRootRenderPhaseUpdatedLanes); - i++ - ); + root = renderRootSync(root, errorRetryLanes); executionContext = prevExecutionContext; - return exitStatus; + return root; } function isRenderConsistentWithExternalStores(finishedWork) { for (var node = finishedWork; ; ) { @@ -6500,7 +6578,7 @@ function isRenderConsistentWithExternalStores(finishedWork) { } function markRootSuspended$1(root, suspendedLanes) { suspendedLanes &= ~workInProgressRootPingedLanes; - suspendedLanes &= ~workInProgressRootInterleavedUpdatedLanes; + suspendedLanes &= ~workInProgressRootUpdatedLanes; root.suspendedLanes |= suspendedLanes; root.pingedLanes &= ~suspendedLanes; for (root = root.expirationTimes; 0 < suspendedLanes; ) { @@ -6518,10 +6596,13 @@ function performSyncWorkOnRoot(root) { if (0 === (lanes & 1)) return ensureRootIsScheduled(root, now()), null; var exitStatus = renderRootSync(root, lanes); if (0 !== root.tag && 2 === exitStatus) { + var prevExecutionContext = executionContext; + executionContext |= 8; + root.isDehydrated && ((root.isDehydrated = !1), shim(root.containerInfo)); var errorRetryLanes = getLanesToRetrySynchronouslyOnError(root); 0 !== errorRetryLanes && - ((lanes = errorRetryLanes), - (exitStatus = recoverFromConcurrentError(root, errorRetryLanes))); + ((lanes = errorRetryLanes), (exitStatus = renderRootSync(root, lanes))); + executionContext = prevExecutionContext; } if (1 === exitStatus) throw ((exitStatus = workInProgressRootFatalError), @@ -6548,7 +6629,6 @@ function prepareFreshStack(root, lanes) { if (null !== workInProgress) for (timeoutHandle = workInProgress.return; null !== timeoutHandle; ) { var interruptedWork = timeoutHandle; - popTreeContext(interruptedWork); switch (interruptedWork.tag) { case 1: interruptedWork = interruptedWork.type.childContextTypes; @@ -6588,7 +6668,7 @@ function prepareFreshStack(root, lanes) { workInProgressRootRenderLanes = subtreeRenderLanes = lanes; workInProgressRootExitStatus = 0; workInProgressRootFatalError = null; - workInProgressRootPingedLanes = workInProgressRootRenderPhaseUpdatedLanes = workInProgressRootInterleavedUpdatedLanes = workInProgressRootSkippedLanes = 0; + workInProgressRootPingedLanes = workInProgressRootUpdatedLanes = workInProgressRootSkippedLanes = 0; if (null !== interleavedQueues) { for (root = 0; root < interleavedQueues.length; root++) if ( @@ -7704,7 +7784,7 @@ function createWorkInProgress(current, pendingProps) { (workInProgress.flags = 0), (workInProgress.subtreeFlags = 0), (workInProgress.deletions = null)); - workInProgress.flags = current.flags & 14680064; + workInProgress.flags = current.flags & 7340032; workInProgress.childLanes = current.childLanes; workInProgress.lanes = current.lanes; workInProgress.child = current.child; @@ -8060,10 +8140,10 @@ batchedUpdatesImpl = function(fn, a) { } }; var roots = new Map(), - devToolsConfig$jscomp$inline_911 = { + devToolsConfig$jscomp$inline_935 = { findFiberByHostInstance: getInstanceFromInstance, bundleType: 0, - version: "18.0.0-3fcd81dd1-20211102", + version: "18.0.0-afcb9cdc9-20211008", rendererPackageName: "react-native-renderer", rendererConfig: { getInspectorDataForViewTag: function() { @@ -8078,11 +8158,11 @@ var roots = new Map(), }.bind(null, findNodeHandle) } }; -var internals$jscomp$inline_1160 = { - bundleType: devToolsConfig$jscomp$inline_911.bundleType, - version: devToolsConfig$jscomp$inline_911.version, - rendererPackageName: devToolsConfig$jscomp$inline_911.rendererPackageName, - rendererConfig: devToolsConfig$jscomp$inline_911.rendererConfig, +var internals$jscomp$inline_1189 = { + bundleType: devToolsConfig$jscomp$inline_935.bundleType, + version: devToolsConfig$jscomp$inline_935.version, + rendererPackageName: devToolsConfig$jscomp$inline_935.rendererPackageName, + rendererConfig: devToolsConfig$jscomp$inline_935.rendererConfig, overrideHookState: null, overrideHookStateDeletePath: null, overrideHookStateRenamePath: null, @@ -8098,26 +8178,26 @@ var internals$jscomp$inline_1160 = { return null === fiber ? null : fiber.stateNode; }, findFiberByHostInstance: - devToolsConfig$jscomp$inline_911.findFiberByHostInstance || + devToolsConfig$jscomp$inline_935.findFiberByHostInstance || emptyFindFiberByHostInstance, findHostInstancesForRefresh: null, scheduleRefresh: null, scheduleRoot: null, setRefreshHandler: null, getCurrentFiber: null, - reconcilerVersion: "18.0.0-3fcd81dd1-20211102" + reconcilerVersion: "18.0.0-afcb9cdc9-20211008" }; if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) { - var hook$jscomp$inline_1161 = __REACT_DEVTOOLS_GLOBAL_HOOK__; + var hook$jscomp$inline_1190 = __REACT_DEVTOOLS_GLOBAL_HOOK__; if ( - !hook$jscomp$inline_1161.isDisabled && - hook$jscomp$inline_1161.supportsFiber + !hook$jscomp$inline_1190.isDisabled && + hook$jscomp$inline_1190.supportsFiber ) try { - (rendererID = hook$jscomp$inline_1161.inject( - internals$jscomp$inline_1160 + (rendererID = hook$jscomp$inline_1190.inject( + internals$jscomp$inline_1189 )), - (injectedHook = hook$jscomp$inline_1161); + (injectedHook = hook$jscomp$inline_1190); } catch (err) {} } exports.createPortal = function(children, containerTag) { diff --git a/Libraries/Renderer/implementations/ReactFabric-profiling.fb.js b/Libraries/Renderer/implementations/ReactFabric-profiling.fb.js index 52f77d4ea44..1950c8517f1 100644 --- a/Libraries/Renderer/implementations/ReactFabric-profiling.fb.js +++ b/Libraries/Renderer/implementations/ReactFabric-profiling.fb.js @@ -7,29 +7,10 @@ * @noflow * @nolint * @preventMunge - * @generated SignedSource<<19f971b57faf7a665639f8c6cebcb2fc>> + * @generated SignedSource<<62430ecbf70b848b8677c9a80f79d347>> */ - - /** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -/* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */ - -// Don't require this file directly; it's embedded by Rollup during build. - -if ( - typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' && - typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart === - 'function' -) { - __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error()); -} - "use strict"; +"use strict"; require("react-native/Libraries/ReactPrivate/ReactNativePrivateInitializeCore"); var ReactNativePrivateInterface = require("react-native/Libraries/ReactPrivate/ReactNativePrivateInterface"), React = require("react"), @@ -946,7 +927,7 @@ eventPluginOrder = Array.prototype.slice.call([ "ReactNativeBridgeEventPlugin" ]); recomputePluginOrdering(); -var injectedNamesToPlugins$jscomp$inline_241 = { +var injectedNamesToPlugins$jscomp$inline_227 = { ResponderEventPlugin: ResponderEventPlugin, ReactNativeBridgeEventPlugin: { eventTypes: {}, @@ -981,33 +962,33 @@ var injectedNamesToPlugins$jscomp$inline_241 = { } } }, - isOrderingDirty$jscomp$inline_242 = !1, - pluginName$jscomp$inline_243; -for (pluginName$jscomp$inline_243 in injectedNamesToPlugins$jscomp$inline_241) + isOrderingDirty$jscomp$inline_228 = !1, + pluginName$jscomp$inline_229; +for (pluginName$jscomp$inline_229 in injectedNamesToPlugins$jscomp$inline_227) if ( - injectedNamesToPlugins$jscomp$inline_241.hasOwnProperty( - pluginName$jscomp$inline_243 + injectedNamesToPlugins$jscomp$inline_227.hasOwnProperty( + pluginName$jscomp$inline_229 ) ) { - var pluginModule$jscomp$inline_244 = - injectedNamesToPlugins$jscomp$inline_241[pluginName$jscomp$inline_243]; + var pluginModule$jscomp$inline_230 = + injectedNamesToPlugins$jscomp$inline_227[pluginName$jscomp$inline_229]; if ( - !namesToPlugins.hasOwnProperty(pluginName$jscomp$inline_243) || - namesToPlugins[pluginName$jscomp$inline_243] !== - pluginModule$jscomp$inline_244 + !namesToPlugins.hasOwnProperty(pluginName$jscomp$inline_229) || + namesToPlugins[pluginName$jscomp$inline_229] !== + pluginModule$jscomp$inline_230 ) { - if (namesToPlugins[pluginName$jscomp$inline_243]) + if (namesToPlugins[pluginName$jscomp$inline_229]) throw Error( "EventPluginRegistry: Cannot inject two different event plugins using the same name, `" + - (pluginName$jscomp$inline_243 + "`.") + (pluginName$jscomp$inline_229 + "`.") ); namesToPlugins[ - pluginName$jscomp$inline_243 - ] = pluginModule$jscomp$inline_244; - isOrderingDirty$jscomp$inline_242 = !0; + pluginName$jscomp$inline_229 + ] = pluginModule$jscomp$inline_230; + isOrderingDirty$jscomp$inline_228 = !0; } } -isOrderingDirty$jscomp$inline_242 && recomputePluginOrdering(); +isOrderingDirty$jscomp$inline_228 && recomputePluginOrdering(); function getInstanceFromInstance(instanceHandle) { return instanceHandle; } @@ -1656,27 +1637,6 @@ function onCommitRoot(root, eventPriority) { ); } catch (err) {} } -var clz32 = Math.clz32 ? Math.clz32 : clz32Fallback, - log = Math.log, - LN2 = Math.LN2; -function clz32Fallback(x) { - x >>>= 0; - return 0 === x ? 32 : (31 - ((log(x) / LN2) | 0)) | 0; -} -function getLabelForLane(lane) { - if (lane & 1) return "Sync"; - if (lane & 2) return "InputContinuousHydration"; - if (lane & 4) return "InputContinuous"; - if (lane & 8) return "DefaultHydration"; - if (lane & 16) return "Default"; - if (lane & 32) return "TransitionHydration"; - if (lane & 4194240) return "Transition"; - if (lane & 130023424) return "Retry"; - if (lane & 134217728) return "SelectiveHydration"; - if (lane & 268435456) return "IdleHydration"; - if (lane & 536870912) return "Idle"; - if (lane & 1073741824) return "Offscreen"; -} var nextTransitionLane = 64, nextRetryLane = 4194304; function getHighestPriorityLanes(lanes) { @@ -1890,6 +1850,12 @@ function movePendingFibersToMemoized(root, lanes) { lanes &= ~root; } } +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 currentUpdatePriority = 0; function lanesToEventPriority(lanes) { lanes &= -lanes; @@ -2197,112 +2163,6 @@ function flushSyncCallbacks() { } return null; } -var supportsUserTimingV3 = !1; -if ( - "undefined" !== typeof performance && - "function" === typeof performance.mark && - "function" === typeof performance.clearMarks -) { - var markOptions = {}; - Object.defineProperty(markOptions, "startTime", { - get: function() { - supportsUserTimingV3 = !0; - return 0; - }, - set: function() {} - }); - try { - performance.mark("__v3", markOptions); - } catch (error) { - } finally { - performance.clearMarks("__v3"); - } -} -var laneLabels = []; -function getLaneLabels() { - if (0 === laneLabels.length) - for (var lane = 1, index$11 = 0; 31 > index$11; index$11++) - laneLabels.push(getLabelForLane(lane)), (lane *= 2); - return laneLabels; -} -function markAndClear(name) { - performance.mark(name); - performance.clearMarks(name); -} -function markInternalModuleRanges() { - if ( - "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && - "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.getInternalModuleRanges - ) - for ( - var ranges = __REACT_DEVTOOLS_GLOBAL_HOOK__.getInternalModuleRanges(), - i = 0; - i < ranges.length; - i++ - ) { - var _ranges$i = ranges[i], - stopStackFrame = _ranges$i[1]; - markAndClear("--react-internal-module-start-" + _ranges$i[0]); - markAndClear("--react-internal-module-stop-" + stopStackFrame); - } -} -function markComponentRenderStarted(fiber) { - supportsUserTimingV3 && - ((fiber = getComponentNameFromFiber(fiber) || "Unknown"), - markAndClear("--component-render-start-" + fiber)); -} -function markComponentRenderStopped() { - supportsUserTimingV3 && markAndClear("--component-render-stop"); -} -function markComponentLayoutEffectUnmountStarted(fiber) { - supportsUserTimingV3 && - ((fiber = getComponentNameFromFiber(fiber) || "Unknown"), - markAndClear("--component-layout-effect-unmount-start-" + fiber)); -} -function markComponentLayoutEffectUnmountStopped() { - supportsUserTimingV3 && - markAndClear("--component-layout-effect-unmount-stop"); -} -var wakeableIDs = new ("function" === typeof WeakMap ? WeakMap : Map)(), - wakeableID = 0; -function getWakeableID(wakeable) { - wakeableIDs.has(wakeable) || wakeableIDs.set(wakeable, wakeableID++); - return wakeableIDs.get(wakeable); -} -function markComponentSuspended(fiber, wakeable, lanes) { - if (supportsUserTimingV3) { - var eventType = wakeableIDs.has(wakeable) ? "resuspend" : "suspend", - id = getWakeableID(wakeable), - componentName = getComponentNameFromFiber(fiber) || "Unknown"; - markAndClear( - "--suspense-" + - eventType + - "-" + - id + - "-" + - componentName + - "-" + - (null === fiber.alternate ? "mount" : "update") + - "-" + - lanes + - "-" + - (wakeable.displayName || "") - ); - wakeable.then( - function() { - return markAndClear("--suspense-resolved-" + id + "-" + componentName); - }, - function() { - return markAndClear("--suspense-rejected-" + id + "-" + componentName); - } - ); - } -} -function markStateUpdateScheduled(fiber, lane) { - supportsUserTimingV3 && - ((fiber = getComponentNameFromFiber(fiber) || "Unknown"), - markAndClear("--schedule-state-update-" + lane + "-" + fiber)); -} var ReactCurrentBatchConfig = ReactSharedInternals.ReactCurrentBatchConfig; function shallowEqual(objA, objB) { if (objectIs(objA, objB)) return !0; @@ -2316,14 +2176,12 @@ function shallowEqual(objA, objB) { var keysA = Object.keys(objA), keysB = Object.keys(objB); if (keysA.length !== keysB.length) return !1; - for (keysB = 0; keysB < keysA.length; keysB++) { - var currentKey = keysA[keysB]; + for (keysB = 0; keysB < keysA.length; keysB++) if ( - !hasOwnProperty.call(objB, currentKey) || - !objectIs(objA[currentKey], objB[currentKey]) + !hasOwnProperty.call(objB, keysA[keysB]) || + !objectIs(objA[keysA[keysB]], objB[keysA[keysB]]) ) return !1; - } return !0; } function describeFiber(fiber) { @@ -2706,7 +2564,6 @@ var classComponentUpdater = { enqueueUpdate(inst, update); payload = scheduleUpdateOnFiber(inst, lane, eventTime); null !== payload && entangleTransitions(payload, inst, lane); - markStateUpdateScheduled(inst, lane); }, enqueueReplaceState: function(inst, payload, callback) { inst = inst._reactInternals; @@ -2719,21 +2576,17 @@ var classComponentUpdater = { enqueueUpdate(inst, update); payload = scheduleUpdateOnFiber(inst, lane, eventTime); null !== payload && entangleTransitions(payload, inst, lane); - markStateUpdateScheduled(inst, lane); }, enqueueForceUpdate: function(inst, callback) { - var fiber = inst._reactInternals, - eventTime = requestEventTime(); - inst = requestUpdateLane(fiber); - var update = createUpdate(eventTime, inst); + inst = inst._reactInternals; + var eventTime = requestEventTime(), + lane = requestUpdateLane(inst), + update = createUpdate(eventTime, lane); update.tag = 2; void 0 !== callback && null !== callback && (update.callback = callback); - enqueueUpdate(fiber, update); - callback = scheduleUpdateOnFiber(fiber, inst, eventTime); - null !== callback && entangleTransitions(callback, fiber, inst); - supportsUserTimingV3 && - ((callback = getComponentNameFromFiber(fiber) || "Unknown"), - markAndClear("--schedule-forced-update-" + inst + "-" + callback)); + enqueueUpdate(inst, update); + callback = scheduleUpdateOnFiber(inst, lane, eventTime); + null !== callback && entangleTransitions(callback, inst, lane); } }; function checkShouldComponentUpdate( @@ -2826,26 +2679,6 @@ function mountClassInstance(workInProgress, ctor, newProps, renderLanes) { "function" === typeof instance.componentDidMount && (workInProgress.flags |= 4); } -var forkStack = [], - forkStackIndex = 0, - treeForkProvider = null, - idStack = [], - idStackIndex = 0, - treeContextProvider = null; -function popTreeContext(workInProgress) { - for (; workInProgress === treeForkProvider; ) - (treeForkProvider = forkStack[--forkStackIndex]), - (forkStack[forkStackIndex] = null), - --forkStackIndex, - (forkStack[forkStackIndex] = null); - for (; workInProgress === treeContextProvider; ) - (treeContextProvider = idStack[--idStackIndex]), - (idStack[idStackIndex] = null), - --idStackIndex, - (idStack[idStackIndex] = null), - --idStackIndex, - (idStack[idStackIndex] = null); -} function coerceRef(returnFiber, current, element) { returnFiber = element.ref; if ( @@ -2940,8 +2773,7 @@ function ChildReconciler(shouldTrackSideEffects) { } function placeChild(newFiber, lastPlacedIndex, newIndex) { newFiber.index = newIndex; - if (!shouldTrackSideEffects) - return (newFiber.flags |= 1048576), lastPlacedIndex; + if (!shouldTrackSideEffects) return lastPlacedIndex; newIndex = newFiber.alternate; if (null !== newIndex) return ( @@ -3545,8 +3377,7 @@ var ReactCurrentDispatcher$1 = ReactSharedInternals.ReactCurrentDispatcher, currentHook = null, workInProgressHook = null, didScheduleRenderPhaseUpdate = !1, - didScheduleRenderPhaseUpdateDuringThisPass = !1, - globalClientIdCounter = 0; + didScheduleRenderPhaseUpdateDuringThisPass = !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://reactjs.org/link/invalid-hook-call for tips about how to debug and fix this problem." @@ -3749,7 +3580,104 @@ function rerenderReducer(reducer) { } return [newState, dispatch]; } -function updateMutableSource() {} +function readFromUnsubscribedMutableSource(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 may be 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 readFromUnsubscribedMutableSource(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); + objectIs(version, maybeNewVersion) || + ((maybeNewVersion = getSnapshot(source._source)), + objectIs(snapshot, maybeNewVersion) || + (setSnapshot(maybeNewVersion), + (maybeNewVersion = requestUpdateLane(fiber)), + (root.mutableReadLanes |= maybeNewVersion & root.pendingLanes)), + markRootEntangled(root, root.mutableReadLanes)); + }, + [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); + 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, + interleaved: null, + lanes: 0, + dispatch: null, + lastRenderedReducer: basicStateReducer, + lastRenderedState: snapshot + }), + (hook.dispatch = setSnapshot = dispatchSetState.bind( + null, + currentlyRenderingFiber$1, + hook + )), + (_dispatcher$useState.queue = hook), + (_dispatcher$useState.baseQueue = null), + (snapshot = readFromUnsubscribedMutableSource(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 mountSyncExternalStore(subscribe, getSnapshot) { var fiber = currentlyRenderingFiber$1, hook = mountWorkInProgressHook(); @@ -3803,7 +3731,7 @@ function checkIfSnapshotChanged(inst) { try { var nextValue = latestGetSnapshot(); return !objectIs(inst, nextValue); - } catch (error$31) { + } catch (error) { return !0; } } @@ -3872,7 +3800,7 @@ function updateEffectImpl(fiberFlags, hookFlags, create, deps) { hook.memoizedState = pushEffect(1 | hookFlags, create, destroy, deps); } function mountEffect(create, deps) { - return mountEffectImpl(8390656, 8, create, deps); + return mountEffectImpl(4196352, 8, create, deps); } function updateEffect(create, deps) { return updateEffectImpl(2048, 8, create, deps); @@ -3952,9 +3880,6 @@ function startTransition(setPending, callback) { (ReactCurrentBatchConfig$1.transition = prevTransition); } } -function updateId() { - return updateWorkInProgressHook().memoizedState; -} function dispatchReducerAction(fiber, queue, action) { var lane = requestUpdateLane(fiber); action = { @@ -3968,9 +3893,8 @@ function dispatchReducerAction(fiber, queue, action) { ? enqueueRenderPhaseUpdate(queue, action) : (enqueueUpdate$1(fiber, queue, action), (action = requestEventTime()), - (action = scheduleUpdateOnFiber(fiber, lane, action)), - null !== action && entangleTransitionUpdate(action, queue, lane)); - markStateUpdateScheduled(fiber, lane); + (fiber = scheduleUpdateOnFiber(fiber, lane, action)), + null !== fiber && entangleTransitionUpdate(fiber, queue, lane)); } function dispatchSetState(fiber, queue, action) { var lane = requestUpdateLane(fiber), @@ -3996,14 +3920,13 @@ function dispatchSetState(fiber, queue, action) { update.hasEagerState = !0; update.eagerState = eagerState; if (objectIs(eagerState, currentState)) return; - } catch (error$33) { + } catch (error) { } finally { } action = requestEventTime(); - action = scheduleUpdateOnFiber(fiber, lane, action); - null !== action && entangleTransitionUpdate(action, queue, lane); + fiber = scheduleUpdateOnFiber(fiber, lane, action); + null !== fiber && entangleTransitionUpdate(fiber, queue, lane); } - markStateUpdateScheduled(fiber, lane); } function isRenderPhaseUpdate(fiber) { var alternate = fiber.alternate; @@ -4064,7 +3987,7 @@ var ContextOnlyDispatcher = { useTransition: throwInvalidHookError, useMutableSource: throwInvalidHookError, useSyncExternalStore: throwInvalidHookError, - useId: throwInvalidHookError, + useOpaqueIdentifier: throwInvalidHookError, unstable_isNewReconciler: !1 }, HooksDispatcherOnMount = { @@ -4152,12 +4075,18 @@ var ContextOnlyDispatcher = { mountWorkInProgressHook().memoizedState = _mountState2; return [isPending, _mountState2]; }, - useMutableSource: function() {}, - useSyncExternalStore: mountSyncExternalStore, - useId: function() { + useMutableSource: function(source, getSnapshot, subscribe) { var hook = mountWorkInProgressHook(); - var id = "r:" + (globalClientIdCounter++).toString(32); - return (hook.memoizedState = id); + hook.memoizedState = { + refs: { getSnapshot: getSnapshot, setSnapshot: null }, + source: source, + subscribe: subscribe + }; + return useMutableSource(hook, source, getSnapshot, subscribe); + }, + useSyncExternalStore: mountSyncExternalStore, + useOpaqueIdentifier: function() { + throw Error("Not yet implemented"); }, unstable_isNewReconciler: !1 }, @@ -4240,7 +4169,9 @@ var ContextOnlyDispatcher = { } return nextSnapshot; }, - useId: updateId, + useOpaqueIdentifier: function() { + return updateReducer(basicStateReducer)[0]; + }, unstable_isNewReconciler: !1 }, HooksDispatcherOnRerender = { @@ -4283,7 +4214,9 @@ var ContextOnlyDispatcher = { }, useMutableSource: updateMutableSource, useSyncExternalStore: mountSyncExternalStore, - useId: updateId, + useOpaqueIdentifier: function() { + return rerenderReducer(basicStateReducer)[0]; + }, unstable_isNewReconciler: !1 }, now$1 = Scheduler.unstable_now, @@ -4379,7 +4312,7 @@ function logCapturedError(boundary, errorInfo) { }); } } -var PossiblyWeakMap$1 = "function" === typeof WeakMap ? WeakMap : Map; +var PossiblyWeakMap = "function" === typeof WeakMap ? WeakMap : Map; function createRootErrorUpdate(fiber, errorInfo, lane) { lane = createUpdate(-1, lane); lane.tag = 3; @@ -4396,9 +4329,9 @@ function createClassErrorUpdate(fiber, errorInfo, lane) { lane.tag = 3; var getDerivedStateFromError = fiber.type.getDerivedStateFromError; if ("function" === typeof getDerivedStateFromError) { - var error$35 = errorInfo.value; + var error = errorInfo.value; lane.payload = function() { - return getDerivedStateFromError(error$35); + return getDerivedStateFromError(error); }; lane.callback = function() { logCapturedError(fiber, errorInfo); @@ -4588,14 +4521,14 @@ function cutOffTailIfNeeded(renderState, hasRenderedATailFallback) { break; case "collapsed": lastTailNode = renderState.tail; - for (var lastTailNode$42 = null; null !== lastTailNode; ) - null !== lastTailNode.alternate && (lastTailNode$42 = lastTailNode), + for (var lastTailNode$37 = null; null !== lastTailNode; ) + null !== lastTailNode.alternate && (lastTailNode$37 = lastTailNode), (lastTailNode = lastTailNode.sibling); - null === lastTailNode$42 + null === lastTailNode$37 ? hasRenderedATailFallback || null === renderState.tail ? (renderState.tail = null) : (renderState.tail.sibling = null) - : (lastTailNode$42.sibling = null); + : (lastTailNode$37.sibling = null); } } function bubbleProperties(completedWork) { @@ -4607,53 +4540,53 @@ function bubbleProperties(completedWork) { if (didBailout) if (0 !== (completedWork.mode & 2)) { for ( - var treeBaseDuration$44 = completedWork.selfBaseDuration, - child$45 = completedWork.child; - null !== child$45; + var treeBaseDuration$39 = completedWork.selfBaseDuration, + child$40 = completedWork.child; + null !== child$40; ) - (newChildLanes |= child$45.lanes | child$45.childLanes), - (subtreeFlags |= child$45.subtreeFlags & 14680064), - (subtreeFlags |= child$45.flags & 14680064), - (treeBaseDuration$44 += child$45.treeBaseDuration), - (child$45 = child$45.sibling); - completedWork.treeBaseDuration = treeBaseDuration$44; + (newChildLanes |= child$40.lanes | child$40.childLanes), + (subtreeFlags |= child$40.subtreeFlags & 7340032), + (subtreeFlags |= child$40.flags & 7340032), + (treeBaseDuration$39 += child$40.treeBaseDuration), + (child$40 = child$40.sibling); + completedWork.treeBaseDuration = treeBaseDuration$39; } else for ( - treeBaseDuration$44 = completedWork.child; - null !== treeBaseDuration$44; + treeBaseDuration$39 = completedWork.child; + null !== treeBaseDuration$39; ) (newChildLanes |= - treeBaseDuration$44.lanes | treeBaseDuration$44.childLanes), - (subtreeFlags |= treeBaseDuration$44.subtreeFlags & 14680064), - (subtreeFlags |= treeBaseDuration$44.flags & 14680064), - (treeBaseDuration$44.return = completedWork), - (treeBaseDuration$44 = treeBaseDuration$44.sibling); + treeBaseDuration$39.lanes | treeBaseDuration$39.childLanes), + (subtreeFlags |= treeBaseDuration$39.subtreeFlags & 7340032), + (subtreeFlags |= treeBaseDuration$39.flags & 7340032), + (treeBaseDuration$39.return = completedWork), + (treeBaseDuration$39 = treeBaseDuration$39.sibling); else if (0 !== (completedWork.mode & 2)) { - treeBaseDuration$44 = completedWork.actualDuration; - child$45 = completedWork.selfBaseDuration; + treeBaseDuration$39 = completedWork.actualDuration; + child$40 = completedWork.selfBaseDuration; for (var child = completedWork.child; null !== child; ) (newChildLanes |= child.lanes | child.childLanes), (subtreeFlags |= child.subtreeFlags), (subtreeFlags |= child.flags), - (treeBaseDuration$44 += child.actualDuration), - (child$45 += child.treeBaseDuration), + (treeBaseDuration$39 += child.actualDuration), + (child$40 += child.treeBaseDuration), (child = child.sibling); - completedWork.actualDuration = treeBaseDuration$44; - completedWork.treeBaseDuration = child$45; + completedWork.actualDuration = treeBaseDuration$39; + completedWork.treeBaseDuration = child$40; } else for ( - treeBaseDuration$44 = completedWork.child; - null !== treeBaseDuration$44; + treeBaseDuration$39 = completedWork.child; + null !== treeBaseDuration$39; ) (newChildLanes |= - treeBaseDuration$44.lanes | treeBaseDuration$44.childLanes), - (subtreeFlags |= treeBaseDuration$44.subtreeFlags), - (subtreeFlags |= treeBaseDuration$44.flags), - (treeBaseDuration$44.return = completedWork), - (treeBaseDuration$44 = treeBaseDuration$44.sibling); + treeBaseDuration$39.lanes | treeBaseDuration$39.childLanes), + (subtreeFlags |= treeBaseDuration$39.subtreeFlags), + (subtreeFlags |= treeBaseDuration$39.flags), + (treeBaseDuration$39.return = completedWork), + (treeBaseDuration$39 = treeBaseDuration$39.sibling); completedWork.subtreeFlags |= subtreeFlags; completedWork.childLanes = newChildLanes; return didBailout; @@ -4685,7 +4618,6 @@ function completeSuspendedOffscreenHostContainer(current, workInProgress) { } function completeWork(current, workInProgress, renderLanes) { var newProps = workInProgress.pendingProps; - popTreeContext(workInProgress); switch (workInProgress.tag) { case 2: case 16: @@ -4815,7 +4747,7 @@ function completeWork(current, workInProgress, renderLanes) { workInProgressRootExitStatus = 4; null === workInProgressRoot || (0 === (workInProgressRootSkippedLanes & 268435455) && - 0 === (workInProgressRootInterleavedUpdatedLanes & 268435455)) || + 0 === (workInProgressRootUpdatedLanes & 268435455)) || markRootSuspended$1( workInProgressRoot, workInProgressRootRenderLanes @@ -4875,7 +4807,7 @@ function completeWork(current, workInProgress, renderLanes) { for (newProps = workInProgress.child; null !== newProps; ) (renderLanes = newProps), (renderedTail = current), - (renderLanes.flags &= 14680066), + (renderLanes.flags &= 7340034), (type = renderLanes.alternate), null === type ? ((renderLanes.childLanes = 0), @@ -5018,7 +4950,6 @@ function updateForwardRef( Component = Component.render; var ref = workInProgress.ref; prepareToReadContext(workInProgress, renderLanes); - markComponentRenderStarted(workInProgress); nextProps = renderWithHooks( current, workInProgress, @@ -5027,7 +4958,6 @@ function updateForwardRef( ref, renderLanes ); - markComponentRenderStopped(); if (null !== current && !didReceiveUpdate) return ( (workInProgress.updateQueue = current.updateQueue), @@ -5222,7 +5152,6 @@ function updateFunctionComponent( : contextStackCursor.current; context = getMaskedContext(workInProgress, context); prepareToReadContext(workInProgress, renderLanes); - markComponentRenderStarted(workInProgress); Component = renderWithHooks( current, workInProgress, @@ -5231,7 +5160,6 @@ function updateFunctionComponent( context, renderLanes ); - markComponentRenderStopped(); if (null !== current && !didReceiveUpdate) return ( (workInProgress.updateQueue = current.updateQueue), @@ -5468,10 +5396,7 @@ function finishClassComponent( ) { var nextChildren = null; profilerStartTime = -1; - } else - markComponentRenderStarted(workInProgress), - (nextChildren = shouldUpdate.render()), - markComponentRenderStopped(); + } else nextChildren = shouldUpdate.render(); workInProgress.flags |= 1; null !== current && didCaptureError ? ((didCaptureError = nextChildren), @@ -5504,7 +5429,7 @@ function pushHostRootContext(workInProgress) { pushTopLevelContextObject(workInProgress, root.context, !1); pushHostContainer(workInProgress, root.containerInfo); } -var SUSPENDED_MARKER = { dehydrated: null, treeContext: null, retryLane: 0 }; +var SUSPENDED_MARKER = { dehydrated: null, retryLane: 0 }; function mountSuspenseOffscreenState(renderLanes) { return { baseLanes: renderLanes, cachePool: null }; } @@ -5741,7 +5666,7 @@ function updateSuspenseFallbackChildren( primaryChildren ))), (current.subtreeFlags = - currentPrimaryChildFragment.subtreeFlags & 14680064)); + currentPrimaryChildFragment.subtreeFlags & 7340032)); null !== currentFallbackChildFragment ? (fallbackChildren = createWorkInProgress( currentFallbackChildFragment, @@ -5973,7 +5898,6 @@ function attemptEarlyBailoutIfNoScheduledUpdate( return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes); } function unwindWork(workInProgress) { - popTreeContext(workInProgress); switch (workInProgress.tag) { case 1: isContextProvider(workInProgress.type) && popContext(); @@ -6040,16 +5964,16 @@ function safelyDetachRef(current, nearestMountedAncestor) { recordLayoutEffectDuration(current); } else ref(null); - } catch (error$92) { - captureCommitPhaseError(current, nearestMountedAncestor, error$92); + } catch (error) { + captureCommitPhaseError(current, nearestMountedAncestor, error); } else ref.current = null; } function safelyCallDestroy(current, nearestMountedAncestor, destroy) { try { destroy(); - } catch (error$93) { - captureCommitPhaseError(current, nearestMountedAncestor, error$93); + } catch (error) { + captureCommitPhaseError(current, nearestMountedAncestor, error); } } var shouldFireAfterActiveInstanceBlur = !1; @@ -6098,8 +6022,8 @@ function commitBeforeMutationEffects(root, firstChild) { "This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue." ); } - } catch (error$94) { - captureCommitPhaseError(root, root.return, error$94); + } catch (error) { + captureCommitPhaseError(root, root.return, error); } firstChild = root.sibling; if (null !== firstChild) { @@ -6126,63 +6050,25 @@ function commitHookEffectListUnmount( if ((effect.tag & flags) === flags) { var destroy = effect.destroy; effect.destroy = void 0; - if (void 0 !== destroy) { - if (0 !== (flags & 8)) { - if (supportsUserTimingV3) { - var componentName = - getComponentNameFromFiber(finishedWork) || "Unknown"; - markAndClear( - "--component-passive-effect-unmount-start-" + componentName - ); - } - } else - 0 !== (flags & 4) && - markComponentLayoutEffectUnmountStarted(finishedWork); + void 0 !== destroy && safelyCallDestroy(finishedWork, nearestMountedAncestor, destroy); - 0 !== (flags & 8) - ? supportsUserTimingV3 && - markAndClear("--component-passive-effect-unmount-stop") - : 0 !== (flags & 4) && markComponentLayoutEffectUnmountStopped(); - } } effect = effect.next; } while (effect !== updateQueue); } } -function commitHookEffectListMount(flags, finishedWork) { - var updateQueue = finishedWork.updateQueue; - updateQueue = null !== updateQueue ? updateQueue.lastEffect : null; - if (null !== updateQueue) { - var effect = (updateQueue = updateQueue.next); +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 & flags) === flags) { - if (0 !== (flags & 8)) { - if (supportsUserTimingV3) { - var componentName = - getComponentNameFromFiber(finishedWork) || "Unknown"; - markAndClear( - "--component-passive-effect-mount-start-" + componentName - ); - } - } else - 0 !== (flags & 4) && - supportsUserTimingV3 && - ((componentName = - getComponentNameFromFiber(finishedWork) || "Unknown"), - markAndClear( - "--component-layout-effect-mount-start-" + componentName - )); - componentName = effect.create; - effect.destroy = componentName(); - 0 !== (flags & 8) - ? supportsUserTimingV3 && - markAndClear("--component-passive-effect-mount-stop") - : 0 !== (flags & 4) && - supportsUserTimingV3 && - markAndClear("--component-layout-effect-mount-stop"); + if ((effect.tag & tag) === tag) { + var create$86 = effect.create; + effect.destroy = create$86(); } effect = effect.next; - } while (effect !== updateQueue); + } while (effect !== finishedWork); } } function detachFiberAfterEffects(fiber) { @@ -6306,17 +6192,13 @@ function commitMutationEffects(root, firstChild, committedLanes) { var _effect = effect, destroy = _effect.destroy, tag = _effect.tag; - void 0 !== destroy && - (0 !== (tag & 2) - ? safelyCallDestroy(current, root, destroy) - : 0 !== (tag & 4) && - (markComponentLayoutEffectUnmountStarted(current), - current.mode & 2 - ? (startLayoutEffectTimer(), - safelyCallDestroy(current, root, destroy), - recordLayoutEffectDuration(current)) - : safelyCallDestroy(current, root, destroy), - markComponentLayoutEffectUnmountStopped())); + void 0 === destroy || + (0 === (tag & 2) && 0 === (tag & 4)) || + (current.mode & 2 + ? (startLayoutEffectTimer(), + safelyCallDestroy(current, root, destroy), + recordLayoutEffectDuration(current)) + : safelyCallDestroy(current, root, destroy)); effect = effect.next; } while (effect !== firstEffect); } @@ -6341,8 +6223,8 @@ function commitMutationEffects(root, firstChild, committedLanes) { recordLayoutEffectDuration(effect); } else _effect.componentWillUnmount(); - } catch (error$91) { - captureCommitPhaseError(current, root, error$91); + } catch (error) { + captureCommitPhaseError(current, root, error); } break; case 5: @@ -6367,8 +6249,8 @@ function commitMutationEffects(root, firstChild, committedLanes) { var alternate = childToDelete.alternate; null !== alternate && (alternate.return = null); childToDelete.return = null; - } catch (error$101) { - captureCommitPhaseError(childToDelete, root, error$101); + } catch (error) { + captureCommitPhaseError(childToDelete, root, error); } } firstChild = root.child; @@ -6400,11 +6282,8 @@ function commitMutationEffects(root, firstChild, committedLanes) { switch (root.tag) { case 13: if (null !== root.memoizedState) { - var current$103 = root.alternate; - if ( - null === current$103 || - null === current$103.memoizedState - ) + var current$92 = root.alternate; + if (null === current$92 || null === current$92.memoizedState) globalMostRecentFallbackTime = now(); } } @@ -6426,8 +6305,8 @@ function commitMutationEffects(root, firstChild, committedLanes) { case 4: commitWork(root.alternate, root); } - } catch (error$102) { - captureCommitPhaseError(root, root.return, error$102); + } catch (error) { + captureCommitPhaseError(root, root.return, error); } firstChild = root.sibling; if (null !== firstChild) { @@ -6514,22 +6393,22 @@ function commitLayoutEffects(finishedWork, root, committedLanes) { commitUpdateQueue(committedLanes, updateQueue, instance); break; case 3: - var updateQueue$97 = committedLanes.updateQueue; - if (null !== updateQueue$97) { - var instance$98 = null; + var updateQueue$88 = committedLanes.updateQueue; + if (null !== updateQueue$88) { + var instance$89 = null; if (null !== committedLanes.child) switch (committedLanes.child.tag) { case 5: - instance$98 = + instance$89 = committedLanes.child.stateNode.canonical; break; case 1: - instance$98 = committedLanes.child.stateNode; + instance$89 = committedLanes.child.stateNode; } commitUpdateQueue( committedLanes, - updateQueue$97, - instance$98 + updateQueue$88, + instance$89 ); } break; @@ -6545,7 +6424,7 @@ function commitLayoutEffects(finishedWork, root, committedLanes) { onCommit = _finishedWork$memoize2.onCommit, onRender = _finishedWork$memoize2.onRender, effectDuration = committedLanes.stateNode.effectDuration; - instance$98 = commitTime; + instance$89 = commitTime; current = null === current ? "mount" : "update"; currentUpdateIsNested && (current = "nested-update"); "function" === typeof onRender && @@ -6555,14 +6434,14 @@ function commitLayoutEffects(finishedWork, root, committedLanes) { committedLanes.actualDuration, committedLanes.treeBaseDuration, committedLanes.actualStartTime, - instance$98 + instance$89 ); "function" === typeof onCommit && onCommit( committedLanes.memoizedProps.id, current, effectDuration, - instance$98 + instance$89 ); enqueuePendingPassiveProfilerEffect(committedLanes); var parentFiber = committedLanes.return; @@ -6592,34 +6471,34 @@ function commitLayoutEffects(finishedWork, root, committedLanes) { ); } if (committedLanes.flags & 512) { - instance$98 = void 0; + instance$89 = void 0; current = committedLanes; var ref = current.ref; if (null !== ref) { var instance$jscomp$0 = current.stateNode; switch (current.tag) { case 5: - instance$98 = instance$jscomp$0.canonical; + instance$89 = instance$jscomp$0.canonical; break; default: - instance$98 = instance$jscomp$0; + instance$89 = instance$jscomp$0; } if ("function" === typeof ref) if (current.mode & 2) try { - startLayoutEffectTimer(), ref(instance$98); + startLayoutEffectTimer(), ref(instance$89); } finally { recordLayoutEffectDuration(current); } - else ref(instance$98); - else ref.current = instance$98; + else ref(instance$89); + else ref.current = instance$89; } } - } catch (error$110) { + } catch (error) { captureCommitPhaseError( committedLanes, committedLanes.return, - error$110 + error ); } } @@ -6627,10 +6506,10 @@ function commitLayoutEffects(finishedWork, root, committedLanes) { nextEffect = null; break; } - instance$98 = committedLanes.sibling; - if (null !== instance$98) { - instance$98.return = committedLanes.return; - nextEffect = instance$98; + instance$89 = committedLanes.sibling; + if (null !== instance$89) { + instance$89.return = committedLanes.return; + nextEffect = instance$89; break; } nextEffect = committedLanes.return; @@ -6650,8 +6529,7 @@ var ceil = Math.ceil, workInProgressRootExitStatus = 0, workInProgressRootFatalError = null, workInProgressRootSkippedLanes = 0, - workInProgressRootInterleavedUpdatedLanes = 0, - workInProgressRootRenderPhaseUpdatedLanes = 0, + workInProgressRootUpdatedLanes = 0, workInProgressRootPingedLanes = 0, globalMostRecentFallbackTime = 0, workInProgressRootRenderTargetTime = Infinity, @@ -6711,21 +6589,18 @@ function scheduleUpdateOnFiber(fiber, lane, eventTime) { )); var root = markUpdateLaneFromFiberToRoot(fiber, lane); if (null === root) return null; + isDevToolsPresent && addFiberToLanesMap(root, fiber, lane); markRootUpdated(root, lane, eventTime); - 0 !== (executionContext & 2) && root === workInProgressRoot - ? (workInProgressRootRenderPhaseUpdatedLanes |= lane) - : (isDevToolsPresent && addFiberToLanesMap(root, fiber, lane), - root === workInProgressRoot && - (0 === (executionContext & 2) && - (workInProgressRootInterleavedUpdatedLanes |= lane), - 4 === workInProgressRootExitStatus && - markRootSuspended$1(root, workInProgressRootRenderLanes)), - ensureRootIsScheduled(root, eventTime), - 1 === lane && - 0 === executionContext && - 0 === (fiber.mode & 1) && - ((workInProgressRootRenderTargetTime = now() + 500), - includesLegacySyncCallbacks && flushSyncCallbacks())); + root === workInProgressRoot && + (0 === (executionContext & 2) && (workInProgressRootUpdatedLanes |= lane), + 4 === workInProgressRootExitStatus && + markRootSuspended$1(root, workInProgressRootRenderLanes)); + ensureRootIsScheduled(root, eventTime); + 1 === lane && + 0 === executionContext && + 0 === (fiber.mode & 1) && + ((workInProgressRootRenderTargetTime = now() + 500), + includesLegacySyncCallbacks && flushSyncCallbacks()); return root; } function markUpdateLaneFromFiberToRoot(sourceFiber, lane) { @@ -6851,7 +6726,6 @@ function performConcurrentWorkOnRoot(root, didTimeout) { workInProgressRootRenderTargetTime = now() + 500; prepareFreshStack(root, didTimeout); } - supportsUserTimingV3 && markAndClear("--render-start-" + didTimeout); do try { workLoopConcurrent(); @@ -6864,10 +6738,8 @@ function performConcurrentWorkOnRoot(root, didTimeout) { ReactCurrentDispatcher$2.current = prevDispatcher; executionContext = prevExecutionContext; null !== workInProgress - ? (supportsUserTimingV3 && markAndClear("--render-yield"), - (didTimeout = 0)) - : (supportsUserTimingV3 && markAndClear("--render-stop"), - (workInProgressRoot = null), + ? (didTimeout = 0) + : ((workInProgressRoot = null), (workInProgressRootRenderLanes = 0), (didTimeout = workInProgressRootExitStatus)); } @@ -6984,15 +6856,9 @@ function recoverFromConcurrentError(root, errorRetryLanes) { var prevExecutionContext = executionContext; executionContext |= 8; root.isDehydrated && ((root.isDehydrated = !1), shim(root.containerInfo)); - for ( - var exitStatus, i = 0; - 50 > i && - ((exitStatus = renderRootSync(root, errorRetryLanes)), - 2 === exitStatus && 0 !== workInProgressRootRenderPhaseUpdatedLanes); - i++ - ); + root = renderRootSync(root, errorRetryLanes); executionContext = prevExecutionContext; - return exitStatus; + return root; } function isRenderConsistentWithExternalStores(finishedWork) { for (var node = finishedWork; ; ) { @@ -7008,7 +6874,7 @@ function isRenderConsistentWithExternalStores(finishedWork) { check = check.value; try { if (!objectIs(getSnapshot(), check)) return !1; - } catch (error$115) { + } catch (error) { return !1; } } @@ -7030,7 +6896,7 @@ function isRenderConsistentWithExternalStores(finishedWork) { } function markRootSuspended$1(root, suspendedLanes) { suspendedLanes &= ~workInProgressRootPingedLanes; - suspendedLanes &= ~workInProgressRootInterleavedUpdatedLanes; + suspendedLanes &= ~workInProgressRootUpdatedLanes; root.suspendedLanes |= suspendedLanes; root.pingedLanes &= ~suspendedLanes; for (root = root.expirationTimes; 0 < suspendedLanes; ) { @@ -7050,10 +6916,13 @@ function performSyncWorkOnRoot(root) { if (0 === (lanes & 1)) return ensureRootIsScheduled(root, now()), null; var exitStatus = renderRootSync(root, lanes); if (0 !== root.tag && 2 === exitStatus) { + var prevExecutionContext = executionContext; + executionContext |= 8; + root.isDehydrated && ((root.isDehydrated = !1), shim(root.containerInfo)); var errorRetryLanes = getLanesToRetrySynchronouslyOnError(root); 0 !== errorRetryLanes && - ((lanes = errorRetryLanes), - (exitStatus = recoverFromConcurrentError(root, errorRetryLanes))); + ((lanes = errorRetryLanes), (exitStatus = renderRootSync(root, lanes))); + executionContext = prevExecutionContext; } if (1 === exitStatus) throw ((exitStatus = workInProgressRootFatalError), @@ -7080,7 +6949,6 @@ function prepareFreshStack(root, lanes) { if (null !== workInProgress) for (timeoutHandle = workInProgress.return; null !== timeoutHandle; ) { var interruptedWork = timeoutHandle; - popTreeContext(interruptedWork); switch (interruptedWork.tag) { case 1: interruptedWork = interruptedWork.type.childContextTypes; @@ -7120,7 +6988,7 @@ function prepareFreshStack(root, lanes) { workInProgressRootRenderLanes = subtreeRenderLanes = lanes; workInProgressRootExitStatus = 0; workInProgressRootFatalError = null; - workInProgressRootPingedLanes = workInProgressRootRenderPhaseUpdatedLanes = workInProgressRootInterleavedUpdatedLanes = workInProgressRootSkippedLanes = 0; + workInProgressRootPingedLanes = workInProgressRootUpdatedLanes = workInProgressRootSkippedLanes = 0; if (null !== interleavedQueues) { for (root = 0; root < interleavedQueues.length; root++) if ( @@ -7141,7 +7009,7 @@ function prepareFreshStack(root, lanes) { interleavedQueues = null; } } -function handleError(root, thrownValue$jscomp$0) { +function handleError(root$jscomp$0, thrownValue) { do { var erroredWork = workInProgress; try { @@ -7165,54 +7033,27 @@ function handleError(root, thrownValue$jscomp$0) { ReactCurrentOwner$2.current = null; if (null === erroredWork || null === erroredWork.return) { workInProgressRootExitStatus = 1; - workInProgressRootFatalError = thrownValue$jscomp$0; + workInProgressRootFatalError = thrownValue; workInProgress = null; break; } erroredWork.mode & 2 && stopProfilerTimerIfRunningAndRecordDelta(erroredWork, !0); - markComponentRenderStopped(); - if ( - null !== thrownValue$jscomp$0 && - "object" === typeof thrownValue$jscomp$0 && - "function" === typeof thrownValue$jscomp$0.then - ) - markComponentSuspended( - erroredWork, - thrownValue$jscomp$0, - workInProgressRootRenderLanes - ); - else { - var fiber = erroredWork, - thrownValue = thrownValue$jscomp$0; - if (supportsUserTimingV3) { - var componentName = getComponentNameFromFiber(fiber) || "Unknown", - phase = null === fiber.alternate ? "mount" : "update"; - fiber = ""; - null !== thrownValue && - "object" === typeof thrownValue && - "string" === typeof thrownValue.message - ? (fiber = thrownValue.message) - : "string" === typeof thrownValue && (fiber = thrownValue); - markAndClear("--error-" + componentName + "-" + phase + "-" + fiber); - } - } a: { - thrownValue = root; - var returnFiber = erroredWork.return, + var root = root$jscomp$0, + returnFiber = erroredWork.return, sourceFiber = erroredWork, - value = thrownValue$jscomp$0; - thrownValue$jscomp$0 = workInProgressRootRenderLanes; + value = thrownValue; + thrownValue = workInProgressRootRenderLanes; sourceFiber.flags |= 32768; - isDevToolsPresent && - restorePendingUpdaters(thrownValue, thrownValue$jscomp$0); + isDevToolsPresent && restorePendingUpdaters(root, thrownValue); if ( null !== value && "object" === typeof value && "function" === typeof value.then ) { - fiber = value; - var sourceFiber$jscomp$0 = sourceFiber, + var wakeable = value, + sourceFiber$jscomp$0 = sourceFiber, tag = sourceFiber$jscomp$0.tag; if ( 0 === (sourceFiber$jscomp$0.mode & 1) && @@ -7230,7 +7071,7 @@ function handleError(root, thrownValue$jscomp$0) { b: { sourceFiber$jscomp$0 = returnFiber; var sourceFiber$jscomp$1 = sourceFiber, - rootRenderLanes = thrownValue$jscomp$0, + rootRenderLanes = thrownValue, hasInvisibleParentBoundary = 0 !== (suspenseStackCursor.current & 1), node = sourceFiber$jscomp$0; @@ -7296,33 +7137,32 @@ function handleError(root, thrownValue$jscomp$0) { value = void 0; sourceFiber = suspenseBoundary; if (sourceFiber.mode & 1) { - var pingCache = thrownValue.pingCache; + var pingCache = root.pingCache; null === pingCache - ? ((pingCache = thrownValue.pingCache = new PossiblyWeakMap$1()), + ? ((pingCache = root.pingCache = new PossiblyWeakMap()), (value = new Set()), - pingCache.set(fiber, value)) - : ((value = pingCache.get(fiber)), + pingCache.set(wakeable, value)) + : ((value = pingCache.get(wakeable)), void 0 === value && - ((value = new Set()), pingCache.set(fiber, value))); - if (!value.has(thrownValue$jscomp$0)) { - value.add(thrownValue$jscomp$0); + ((value = new Set()), pingCache.set(wakeable, value))); + if (!value.has(thrownValue)) { + value.add(thrownValue); var ping = pingSuspendedRoot.bind( null, - thrownValue, - fiber, - thrownValue$jscomp$0 + root, + wakeable, + thrownValue ); - isDevToolsPresent && - restorePendingUpdaters(thrownValue, thrownValue$jscomp$0); - fiber.then(ping, ping); + isDevToolsPresent && restorePendingUpdaters(root, thrownValue); + wakeable.then(ping, ping); } } var wakeables = sourceFiber.updateQueue; if (null === wakeables) { var updateQueue = new Set(); - updateQueue.add(fiber); + updateQueue.add(wakeable); sourceFiber.updateQueue = updateQueue; - } else wakeables.add(fiber); + } else wakeables.add(wakeable); break a; } else value = Error( @@ -7333,51 +7173,51 @@ function handleError(root, thrownValue$jscomp$0) { 4 !== workInProgressRootExitStatus && (workInProgressRootExitStatus = 2); value = createCapturedValue(value, sourceFiber); - thrownValue = returnFiber; + root = returnFiber; do { - switch (thrownValue.tag) { + switch (root.tag) { case 3: - fiber = value; - thrownValue.flags |= 65536; - thrownValue$jscomp$0 &= -thrownValue$jscomp$0; - thrownValue.lanes |= thrownValue$jscomp$0; + wakeable = value; + root.flags |= 65536; + thrownValue &= -thrownValue; + root.lanes |= thrownValue; var update$jscomp$0 = createRootErrorUpdate( - thrownValue, - fiber, - thrownValue$jscomp$0 + root, + wakeable, + thrownValue ); - enqueueCapturedUpdate(thrownValue, update$jscomp$0); + enqueueCapturedUpdate(root, update$jscomp$0); break a; case 1: - fiber = value; - var ctor = thrownValue.type, - instance = thrownValue.stateNode; + wakeable = value; + var ctor = root.type, + instance = root.stateNode; if ( - 0 === (thrownValue.flags & 128) && + 0 === (root.flags & 128) && ("function" === typeof ctor.getDerivedStateFromError || (null !== instance && "function" === typeof instance.componentDidCatch && (null === legacyErrorBoundariesThatAlreadyFailed || !legacyErrorBoundariesThatAlreadyFailed.has(instance)))) ) { - thrownValue.flags |= 65536; - thrownValue$jscomp$0 &= -thrownValue$jscomp$0; - thrownValue.lanes |= thrownValue$jscomp$0; - var update$38 = createClassErrorUpdate( - thrownValue, - fiber, - thrownValue$jscomp$0 + root.flags |= 65536; + thrownValue &= -thrownValue; + root.lanes |= thrownValue; + var update$33 = createClassErrorUpdate( + root, + wakeable, + thrownValue ); - enqueueCapturedUpdate(thrownValue, update$38); + enqueueCapturedUpdate(root, update$33); break a; } } - thrownValue = thrownValue.return; - } while (null !== thrownValue); + root = root.return; + } while (null !== root); } completeUnitOfWork(erroredWork); } catch (yetAnotherThrownValue) { - thrownValue$jscomp$0 = yetAnotherThrownValue; + thrownValue = yetAnotherThrownValue; workInProgress === erroredWork && null !== erroredWork && (workInProgress = erroredWork = erroredWork.return); @@ -7405,7 +7245,6 @@ function renderRootSync(root, lanes) { } prepareFreshStack(root, lanes); } - supportsUserTimingV3 && markAndClear("--render-start-" + lanes); do try { workLoopSync(); @@ -7421,7 +7260,6 @@ function renderRootSync(root, lanes) { throw Error( "Cannot commit an incomplete root. This error is likely caused by a bug in React. Please file an issue." ); - supportsUserTimingV3 && markAndClear("--render-stop"); workInProgressRoot = null; workInProgressRootRenderLanes = 0; return workInProgressRootExitStatus; @@ -7514,15 +7352,7 @@ function commitRootImpl(root, renderPriorityLevel) { throw Error("Should not already be working."); var finishedWork = root.finishedWork, lanes = root.finishedLanes; - supportsUserTimingV3 && - (markAndClear("--commit-start-" + lanes), - markAndClear("--react-version-18.0.0-3fcd81dd1-20211102"), - markAndClear("--profiler-version-1"), - getLaneLabels(), - markAndClear("--react-lane-labels-" + laneLabels.join(",")), - markInternalModuleRanges()); - if (null === finishedWork) - return supportsUserTimingV3 && markAndClear("--commit-stop"), null; + if (null === finishedWork) return null; root.finishedWork = null; root.finishedLanes = 0; if (finishedWork === root.current) @@ -7557,9 +7387,7 @@ function commitRootImpl(root, renderPriorityLevel) { commitTime = now$1(); commitMutationEffects(root, finishedWork, lanes); root.current = finishedWork; - supportsUserTimingV3 && markAndClear("--layout-effects-start-" + lanes); commitLayoutEffects(finishedWork, root, lanes); - supportsUserTimingV3 && markAndClear("--layout-effects-stop"); requestPaint(); executionContext = prevExecutionContext; currentUpdatePriority = previousPriority; @@ -7590,7 +7418,6 @@ function commitRootImpl(root, renderPriorityLevel) { : ((nestedUpdateCount = 0), (rootWithNestedUpdates = root))) : (nestedUpdateCount = 0); flushSyncCallbacks(); - supportsUserTimingV3 && markAndClear("--commit-stop"); return null; } function flushPassiveEffects() { @@ -7605,14 +7432,11 @@ function flushPassiveEffects() { var JSCompiler_inline_result = !1; else { renderPriority = rootWithPendingPassiveEffects; - var lanes = pendingPassiveEffectsLanes; rootWithPendingPassiveEffects = null; pendingPassiveEffectsLanes = 0; if (0 !== (executionContext & 6)) throw Error("Cannot flush passive effects while already rendering."); - supportsUserTimingV3 && - markAndClear("--passive-effects-start-" + lanes); - lanes = executionContext; + var prevExecutionContext = executionContext; executionContext |= 4; for (nextEffect = renderPriority.current; null !== nextEffect; ) { var fiber = nextEffect, @@ -7722,12 +7546,8 @@ function flushPassiveEffects() { } } else commitHookEffectListMount(9, fiberToDelete); } - } catch (error$111) { - captureCommitPhaseError( - deletions, - deletions.return, - error$111 - ); + } catch (error) { + captureCommitPhaseError(deletions, deletions.return, error); } if (deletions === child) { nextEffect = null; @@ -7779,8 +7599,7 @@ function flushPassiveEffects() { } } } - supportsUserTimingV3 && markAndClear("--passive-effects-stop"); - executionContext = lanes; + executionContext = prevExecutionContext; flushSyncCallbacks(); if ( injectedHook && @@ -7937,7 +7756,6 @@ beginWork$1 = function(current, workInProgress, renderLanes) { contextStackCursor.current ); prepareToReadContext(workInProgress, renderLanes); - markComponentRenderStarted(workInProgress); context = renderWithHooks( null, workInProgress, @@ -7946,7 +7764,6 @@ beginWork$1 = function(current, workInProgress, renderLanes) { context, renderLanes ); - markComponentRenderStopped(); workInProgress.flags |= 1; if ( "object" === typeof context && @@ -8272,9 +8089,7 @@ beginWork$1 = function(current, workInProgress, renderLanes) { (Component = workInProgress.pendingProps.children), prepareToReadContext(workInProgress, renderLanes), (context = readContext(context)), - markComponentRenderStarted(workInProgress), (Component = Component(context)), - markComponentRenderStopped(), (workInProgress.flags |= 1), reconcileChildren(current, workInProgress, Component, renderLanes), workInProgress.child @@ -8405,7 +8220,7 @@ function createWorkInProgress(current, pendingProps) { (workInProgress.deletions = null), (workInProgress.actualDuration = 0), (workInProgress.actualStartTime = -1)); - workInProgress.flags = current.flags & 14680064; + workInProgress.flags = current.flags & 7340032; workInProgress.childLanes = current.childLanes; workInProgress.lanes = current.lanes; workInProgress.child = current.child; @@ -8594,7 +8409,6 @@ function updateContainer(element, container, parentComponent, callback) { var current = container.current, eventTime = requestEventTime(), lane = requestUpdateLane(current); - supportsUserTimingV3 && markAndClear("--schedule-render-" + lane); a: if (parentComponent) { parentComponent = parentComponent._reactInternals; b: { @@ -8769,10 +8583,10 @@ batchedUpdatesImpl = function(fn, a) { } }; var roots = new Map(), - devToolsConfig$jscomp$inline_1005 = { + devToolsConfig$jscomp$inline_965 = { findFiberByHostInstance: getInstanceFromInstance, bundleType: 0, - version: "18.0.0-3fcd81dd1-20211102", + version: "18.0.0-afcb9cdc9-20211008", rendererPackageName: "react-native-renderer", rendererConfig: { getInspectorDataForViewTag: function() { @@ -8787,11 +8601,11 @@ var roots = new Map(), }.bind(null, findNodeHandle) } }; -var internals$jscomp$inline_1288 = { - bundleType: devToolsConfig$jscomp$inline_1005.bundleType, - version: devToolsConfig$jscomp$inline_1005.version, - rendererPackageName: devToolsConfig$jscomp$inline_1005.rendererPackageName, - rendererConfig: devToolsConfig$jscomp$inline_1005.rendererConfig, +var internals$jscomp$inline_1239 = { + bundleType: devToolsConfig$jscomp$inline_965.bundleType, + version: devToolsConfig$jscomp$inline_965.version, + rendererPackageName: devToolsConfig$jscomp$inline_965.rendererPackageName, + rendererConfig: devToolsConfig$jscomp$inline_965.rendererConfig, overrideHookState: null, overrideHookStateDeletePath: null, overrideHookStateRenamePath: null, @@ -8807,26 +8621,26 @@ var internals$jscomp$inline_1288 = { return null === fiber ? null : fiber.stateNode; }, findFiberByHostInstance: - devToolsConfig$jscomp$inline_1005.findFiberByHostInstance || + devToolsConfig$jscomp$inline_965.findFiberByHostInstance || emptyFindFiberByHostInstance, findHostInstancesForRefresh: null, scheduleRefresh: null, scheduleRoot: null, setRefreshHandler: null, getCurrentFiber: null, - reconcilerVersion: "18.0.0-3fcd81dd1-20211102" + reconcilerVersion: "18.0.0-afcb9cdc9-20211008" }; if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) { - var hook$jscomp$inline_1289 = __REACT_DEVTOOLS_GLOBAL_HOOK__; + var hook$jscomp$inline_1240 = __REACT_DEVTOOLS_GLOBAL_HOOK__; if ( - !hook$jscomp$inline_1289.isDisabled && - hook$jscomp$inline_1289.supportsFiber + !hook$jscomp$inline_1240.isDisabled && + hook$jscomp$inline_1240.supportsFiber ) try { - (rendererID = hook$jscomp$inline_1289.inject( - internals$jscomp$inline_1288 + (rendererID = hook$jscomp$inline_1240.inject( + internals$jscomp$inline_1239 )), - (injectedHook = hook$jscomp$inline_1289); + (injectedHook = hook$jscomp$inline_1240); } catch (err) {} } exports.createPortal = function(children, containerTag) { @@ -8909,23 +8723,3 @@ exports.stopSurface = function(containerTag) { exports.unmountComponentAtNode = function(containerTag) { this.stopSurface(containerTag); }; - - /** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -/* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */ - -// Don't require this file directly; it's embedded by Rollup during build. - -if ( - typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' && - typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop === - 'function' -) { - __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error()); -} - diff --git a/Libraries/Renderer/implementations/ReactNativeRenderer-dev.fb.js b/Libraries/Renderer/implementations/ReactNativeRenderer-dev.fb.js index 42defadcf70..1c526c7f8cb 100644 --- a/Libraries/Renderer/implementations/ReactNativeRenderer-dev.fb.js +++ b/Libraries/Renderer/implementations/ReactNativeRenderer-dev.fb.js @@ -7,33 +7,14 @@ * @noflow * @nolint * @preventMunge - * @generated SignedSource<> + * @generated SignedSource<> */ 'use strict'; if (__DEV__) { (function() { - - /** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -/* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */ - -// Don't require this file directly; it's embedded by Rollup during build. - -if ( - typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' && - typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart === - 'function' -) { - __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error()); -} - "use strict"; +"use strict"; var React = require("react"); require("react-native/Libraries/ReactPrivate/ReactNativePrivateInitializeCore"); @@ -2906,6 +2887,7 @@ var REACT_SUSPENSE_LIST_TYPE = 0xead8; var REACT_MEMO_TYPE = 0xead3; var REACT_LAZY_TYPE = 0xead4; 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; @@ -2926,6 +2908,7 @@ if (typeof Symbol === "function" && Symbol.for) { REACT_MEMO_TYPE = symbolFor("react.memo"); REACT_LAZY_TYPE = symbolFor("react.lazy"); 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"); @@ -3158,7 +3141,7 @@ function getComponentNameFromFiber(fiber) { var enablePersistentOffscreenHostContainer = dynamicFlags.enablePersistentOffscreenHostContainer; // The rest of the flags are static for better dead code elimination. -var enableSchedulingProfiler = true; +var enableSchedulingProfiler = false; var enableProfilerTimer = true; var enableProfilerCommitHooks = true; var enableLazyElements = false; @@ -3233,9 +3216,6 @@ var ShouldCapture = var ForceUpdateForLegacySuspense = /* */ 131072; -var Forked = - /* */ - 1048576; // Static tags describe aspects of a fiber that are not specific to a render, // e.g. a fiber uses a passive effect (even if there are no updates on this particular render). // This enables us to defer more work in the unmount case, // since we can defer traversing the tree during layout to look for Passive effects, @@ -3243,22 +3223,22 @@ var Forked = var RefStatic = /* */ - 2097152; + 1048576; var LayoutStatic = /* */ - 4194304; + 2097152; var PassiveStatic = /* */ - 8388608; // These flags allow us to traverse to fibers that have effects on mount + 4194304; // These flags allow us to traverse to fibers that have effects on mount // without traversing the entire tree after every commit for // double invoking var MountLayoutDev = /* */ - 16777216; + 8388608; var MountPassiveDev = /* */ - 33554432; // Groups of flags that are used in the commit phase to skip over trees that + 16777216; // Groups of flags that are used in the commit phase to skip over trees that // don't contain effects, by checking subtreeFlags. var BeforeMutationMask = // TODO: Remove Update flag from before mutation phase by re-landing Visibility @@ -4438,24 +4418,6 @@ var ConcurrentUpdatesByDefaultMode = /* */ 32; -// TODO: This is pretty well supported by browsers. Maybe we can drop it. -var clz32 = Math.clz32 ? Math.clz32 : clz32Fallback; // Count leading zeros. -// 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(x) { - var asUint = x >>> 0; - - if (asUint === 0) { - return 32; - } - - return (31 - ((log(asUint) / LN2) | 0)) | 0; -} - // If those values are changed that package should be rebuilt and redeployed. var TotalLanes = 31; @@ -4568,59 +4530,6 @@ var IdleLane = var OffscreenLane = /* */ 1073741824; // This function is used for the experimental scheduling profiler (react-devtools-scheduling-profiler) -// It should be kept in sync with the Lanes values above. - -function getLabelForLane(lane) { - { - if (lane & SyncLane) { - return "Sync"; - } - - if (lane & InputContinuousHydrationLane) { - return "InputContinuousHydration"; - } - - if (lane & InputContinuousLane) { - return "InputContinuous"; - } - - if (lane & DefaultHydrationLane) { - return "DefaultHydration"; - } - - if (lane & DefaultLane) { - return "Default"; - } - - if (lane & TransitionHydrationLane) { - return "TransitionHydration"; - } - - if (lane & TransitionLanes) { - return "Transition"; - } - - if (lane & RetryLanes) { - return "Retry"; - } - - if (lane & SelectiveHydrationLane) { - return "SelectiveHydration"; - } - - if (lane & IdleHydrationLane) { - return "IdleHydration"; - } - - if (lane & IdleLane) { - return "Idle"; - } - - if (lane & OffscreenLane) { - return "Offscreen"; - } - } -} var NoTimestamp = -1; var nextTransitionLane = TransitionLane1; var nextRetryLane = RetryLane1; @@ -5086,6 +4995,9 @@ function markRootSuspended(root, suspendedLanes) { function markRootPinged(root, pingedLanes, eventTime) { root.pingedLanes |= root.suspendedLanes & pingedLanes; } +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 @@ -5095,6 +5007,7 @@ function markRootFinished(root, remainingLanes) { 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 @@ -5183,6 +5096,20 @@ function movePendingFibersToMemoized(root, lanes) { 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; +} var DiscreteEventPriority = SyncLane; var ContinuousEventPriority = InputContinuousLane; @@ -5608,6 +5535,9 @@ function clearContainer(container) { function unhideTextInstance(textInstance, text) { throw new Error("Not yet implemented."); } +function makeClientIdInDEV(warnOnAccessInDEV) { + throw new Error("Not yet implemented"); +} function preparePortalMount(portalInstance) { // noop } @@ -6243,350 +6173,12 @@ function flushSyncCallbacks() { return null; } -var ReactVersion = "18.0.0-3fcd81dd1-20211102"; +var ReactVersion = "18.0.0-afcb9cdc9-20211008"; -var SCHEDULING_PROFILER_VERSION = 1; +function markComponentRenderStopped() {} +function markComponentErrored(fiber, thrownValue, lanes) {} -var getLabelForLane$1 = getLabelForLane; -var TotalLanes$1 = TotalLanes; -/** - * If performance exists and supports the subset of the User Timing API that we - * require. - */ - -var supportsUserTiming = - typeof performance !== "undefined" && - typeof performance.mark === "function" && - typeof performance.clearMarks === "function"; -var supportsUserTimingV3 = false; - -{ - if (supportsUserTiming) { - var CHECK_V3_MARK = "__v3"; - var markOptions = {}; // $FlowFixMe: Ignore Flow complaining about needing a value - - Object.defineProperty(markOptions, "startTime", { - get: function() { - supportsUserTimingV3 = true; - return 0; - }, - set: function() {} - }); - - try { - // $FlowFixMe: Flow expects the User Timing level 2 API. - performance.mark(CHECK_V3_MARK, markOptions); - } catch (error) { - // Ignore - } finally { - performance.clearMarks(CHECK_V3_MARK); - } - } -} - -var laneLabels = []; -function getLaneLabels() { - if (laneLabels.length === 0) { - var lane = 1; - - for (var index = 0; index < TotalLanes$1; index++) { - laneLabels.push(getLabelForLane$1(lane)); - lane *= 2; - } - } - - return laneLabels; -} - -function markLaneToLabelMetadata() { - getLaneLabels(); - markAndClear("--react-lane-labels-" + laneLabels.join(",")); -} - -function markAndClear(name) { - performance.mark(name); - performance.clearMarks(name); -} - -function markVersionMetadata() { - markAndClear("--react-version-" + ReactVersion); - markAndClear("--profiler-version-" + SCHEDULING_PROFILER_VERSION); -} - -function markInternalModuleRanges() { - /* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */ - if ( - typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== "undefined" && - typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.getInternalModuleRanges === "function" - ) { - var ranges = __REACT_DEVTOOLS_GLOBAL_HOOK__.getInternalModuleRanges(); - - for (var i = 0; i < ranges.length; i++) { - var _ranges$i = ranges[i], - startStackFrame = _ranges$i[0], - stopStackFrame = _ranges$i[1]; - markAndClear("--react-internal-module-start-" + startStackFrame); - markAndClear("--react-internal-module-stop-" + stopStackFrame); - } - } -} - -function markCommitStarted(lanes) { - { - if (supportsUserTimingV3) { - markAndClear("--commit-start-" + lanes); // Certain types of metadata should be logged infrequently. - // Normally we would log this during module init, - // but there's no guarantee a user is profiling at that time. - // Commits happen infrequently (less than renders or state updates) - // so we log this extra information along with a commit. - // It will likely be logged more than once but that's okay. - // - // TODO Once DevTools supports starting/stopping the profiler, - // we can log this data only once (when started) and remove the per-commit logging. - - markVersionMetadata(); - markLaneToLabelMetadata(); - markInternalModuleRanges(); - } - } -} -function markCommitStopped() { - { - if (supportsUserTimingV3) { - markAndClear("--commit-stop"); - } - } -} -function markComponentRenderStarted(fiber) { - { - if (supportsUserTimingV3) { - var componentName = getComponentNameFromFiber(fiber) || "Unknown"; // TODO (scheduling profiler) Add component stack id - - markAndClear("--component-render-start-" + componentName); - } - } -} -function markComponentRenderStopped() { - { - if (supportsUserTimingV3) { - markAndClear("--component-render-stop"); - } - } -} -function markComponentPassiveEffectMountStarted(fiber) { - { - if (supportsUserTimingV3) { - var componentName = getComponentNameFromFiber(fiber) || "Unknown"; // TODO (scheduling profiler) Add component stack id - - markAndClear("--component-passive-effect-mount-start-" + componentName); - } - } -} -function markComponentPassiveEffectMountStopped() { - { - if (supportsUserTimingV3) { - markAndClear("--component-passive-effect-mount-stop"); - } - } -} -function markComponentPassiveEffectUnmountStarted(fiber) { - { - if (supportsUserTimingV3) { - var componentName = getComponentNameFromFiber(fiber) || "Unknown"; // TODO (scheduling profiler) Add component stack id - - markAndClear("--component-passive-effect-unmount-start-" + componentName); - } - } -} -function markComponentPassiveEffectUnmountStopped() { - { - if (supportsUserTimingV3) { - markAndClear("--component-passive-effect-unmount-stop"); - } - } -} -function markComponentLayoutEffectMountStarted(fiber) { - { - if (supportsUserTimingV3) { - var componentName = getComponentNameFromFiber(fiber) || "Unknown"; // TODO (scheduling profiler) Add component stack id - - markAndClear("--component-layout-effect-mount-start-" + componentName); - } - } -} -function markComponentLayoutEffectMountStopped() { - { - if (supportsUserTimingV3) { - markAndClear("--component-layout-effect-mount-stop"); - } - } -} -function markComponentLayoutEffectUnmountStarted(fiber) { - { - if (supportsUserTimingV3) { - var componentName = getComponentNameFromFiber(fiber) || "Unknown"; // TODO (scheduling profiler) Add component stack id - - markAndClear("--component-layout-effect-unmount-start-" + componentName); - } - } -} -function markComponentLayoutEffectUnmountStopped() { - { - if (supportsUserTimingV3) { - markAndClear("--component-layout-effect-unmount-stop"); - } - } -} -function markComponentErrored(fiber, thrownValue, lanes) { - { - if (supportsUserTimingV3) { - var componentName = getComponentNameFromFiber(fiber) || "Unknown"; - var phase = fiber.alternate === null ? "mount" : "update"; - var message = ""; - - if ( - thrownValue !== null && - typeof thrownValue === "object" && - typeof thrownValue.message === "string" - ) { - message = thrownValue.message; - } else if (typeof thrownValue === "string") { - message = thrownValue; - } // TODO (scheduling profiler) Add component stack id - - markAndClear("--error-" + componentName + "-" + phase + "-" + message); - } - } -} -var PossiblyWeakMap$1 = typeof WeakMap === "function" ? WeakMap : Map; // $FlowFixMe: Flow cannot handle polymorphic WeakMaps - -var wakeableIDs = new PossiblyWeakMap$1(); -var wakeableID = 0; - -function getWakeableID(wakeable) { - if (!wakeableIDs.has(wakeable)) { - wakeableIDs.set(wakeable, wakeableID++); - } - - return wakeableIDs.get(wakeable); -} - -function markComponentSuspended(fiber, wakeable, lanes) { - { - if (supportsUserTimingV3) { - var eventType = wakeableIDs.has(wakeable) ? "resuspend" : "suspend"; - var id = getWakeableID(wakeable); - var componentName = getComponentNameFromFiber(fiber) || "Unknown"; - var phase = fiber.alternate === null ? "mount" : "update"; // Following the non-standard fn.displayName convention, - // frameworks like Relay may also annotate Promises with a displayName, - // describing what operation/data the thrown Promise is related to. - // When this is available we should pass it along to the Scheduling Profiler. - - var displayName = wakeable.displayName || ""; // TODO (scheduling profiler) Add component stack id - - markAndClear( - "--suspense-" + - eventType + - "-" + - id + - "-" + - componentName + - "-" + - phase + - "-" + - lanes + - "-" + - displayName - ); - wakeable.then( - function() { - return markAndClear( - "--suspense-resolved-" + id + "-" + componentName - ); - }, - function() { - return markAndClear( - "--suspense-rejected-" + id + "-" + componentName - ); - } - ); - } - } -} -function markLayoutEffectsStarted(lanes) { - { - if (supportsUserTimingV3) { - markAndClear("--layout-effects-start-" + lanes); - } - } -} -function markLayoutEffectsStopped() { - { - if (supportsUserTimingV3) { - markAndClear("--layout-effects-stop"); - } - } -} -function markPassiveEffectsStarted(lanes) { - { - if (supportsUserTimingV3) { - markAndClear("--passive-effects-start-" + lanes); - } - } -} -function markPassiveEffectsStopped() { - { - if (supportsUserTimingV3) { - markAndClear("--passive-effects-stop"); - } - } -} -function markRenderStarted(lanes) { - { - if (supportsUserTimingV3) { - markAndClear("--render-start-" + lanes); - } - } -} -function markRenderYielded() { - { - if (supportsUserTimingV3) { - markAndClear("--render-yield"); - } - } -} -function markRenderStopped() { - { - if (supportsUserTimingV3) { - markAndClear("--render-stop"); - } - } -} -function markRenderScheduled(lane) { - { - if (supportsUserTimingV3) { - markAndClear("--schedule-render-" + lane); - } - } -} -function markForceUpdateScheduled(fiber, lane) { - { - if (supportsUserTimingV3) { - var componentName = getComponentNameFromFiber(fiber) || "Unknown"; // TODO (scheduling profiler) Add component stack id - - markAndClear("--schedule-forced-update-" + lane + "-" + componentName); - } - } -} -function markStateUpdateScheduled(fiber, lane) { - { - if (supportsUserTimingV3) { - var componentName = getComponentNameFromFiber(fiber) || "Unknown"; // TODO (scheduling profiler) Add component stack id - - markAndClear("--schedule-state-update-" + lane + "-" + componentName); - } - } -} +function markComponentSuspended(fiber, wakeable, lanes) {} var ReactCurrentBatchConfig = ReactSharedInternals.ReactCurrentBatchConfig; var NoTransition = 0; @@ -6622,11 +6214,9 @@ function shallowEqual(objA, objB) { } // Test for A's keys different from B. for (var i = 0; i < keysA.length; i++) { - var currentKey = keysA[i]; - if ( - !hasOwnProperty.call(objB, currentKey) || - !objectIs(objA[currentKey], objB[currentKey]) + !hasOwnProperty.call(objB, keysA[i]) || + !objectIs(objA[keysA[i]], objB[keysA[i]]) ) { return false; } @@ -6733,6 +6323,11 @@ function setIsRendering(rendering) { isRendering = rendering; } } +function getIsRendering() { + { + return isRendering; + } +} var ReactStrictModeWarnings = { recordUnsafeLifecycleWarnings: function(fiber, instance) {}, @@ -7092,6 +6687,7 @@ var ReactStrictModeWarnings = { * of the `value` object). */ // $FlowFixMe only called in DEV, so void return is not possible. + function typeName(value) { { // toStringTag is needed for namespaced types like Temporal.Instant @@ -7106,6 +6702,17 @@ function typeName(value) { function willCoercionThrow(value) { { + if ( + value !== null && + typeof value === "object" && + value.$$typeof === REACT_OPAQUE_ID_TYPE + ) { + // OpaqueID type is expected to throw, so React will handle it. Not sure if + // it's expected that string coercion will throw, but we'll assume it's OK. + // See https://github.com/facebook/react/issues/20127. + return; + } + try { testStringCoercion(value); return false; @@ -8182,10 +7789,6 @@ var classComponentUpdater = { if (root !== null) { entangleTransitions(root, fiber, lane); } - - { - markStateUpdateScheduled(fiber, lane); - } }, enqueueReplaceState: function(inst, payload, callback) { var fiber = get(inst); @@ -8209,10 +7812,6 @@ var classComponentUpdater = { if (root !== null) { entangleTransitions(root, fiber, lane); } - - { - markStateUpdateScheduled(fiber, lane); - } }, enqueueForceUpdate: function(inst, callback) { var fiber = get(inst); @@ -8235,10 +7834,6 @@ var classComponentUpdater = { if (root !== null) { entangleTransitions(root, fiber, lane); } - - { - markForceUpdateScheduled(fiber, lane); - } } }; @@ -9177,84 +8772,6 @@ function updateClassInstance( return shouldUpdate; } -// TODO: Use the unified fiber stack module instead of this local one? -// Intentionally not using it yet to derisk the initial implementation, because -// the way we push/pop these values is a bit unusual. If there's a mistake, I'd -// rather the ids be wrong than crash the whole reconciler. -var forkStack = []; -var forkStackIndex = 0; -var treeForkProvider = null; -var treeForkCount = 0; -var idStack = []; -var idStackIndex = 0; -var treeContextProvider = null; -var treeContextId = 1; -var treeContextOverflow = ""; - -function popTreeContext(workInProgress) { - // Restore the previous values. - // This is a bit more complicated than other context-like modules in Fiber - // because the same Fiber may appear on the stack multiple times and for - // different reasons. We have to keep popping until the work-in-progress is - // no longer at the top of the stack. - while (workInProgress === treeForkProvider) { - treeForkProvider = forkStack[--forkStackIndex]; - forkStack[forkStackIndex] = null; - treeForkCount = forkStack[--forkStackIndex]; - forkStack[forkStackIndex] = null; - } - - while (workInProgress === treeContextProvider) { - treeContextProvider = idStack[--idStackIndex]; - idStack[idStackIndex] = null; - treeContextOverflow = idStack[--idStackIndex]; - idStack[idStackIndex] = null; - treeContextId = idStack[--idStackIndex]; - idStack[idStackIndex] = null; - } -} - -var isHydrating = false; - -function enterHydrationState(fiber) { - { - return false; - } -} - -function prepareToHydrateHostInstance( - fiber, - rootContainerInstance, - hostContext -) { - { - throw new 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 new 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; -} - var didWarnAboutMaps; var didWarnAboutGenerators; var didWarnAboutStringRefs; @@ -9538,9 +9055,7 @@ function ChildReconciler(shouldTrackSideEffects) { newFiber.index = newIndex; if (!shouldTrackSideEffects) { - // During hydration, the useId algorithm needs to know which fibers are - // part of a list of children (arrays, iterators). - newFiber.flags |= Forked; + // Noop. return lastPlacedIndex; } @@ -9980,7 +9495,6 @@ function ChildReconciler(shouldTrackSideEffects) { if (newIdx === newChildren.length) { // We've reached the end of the new children. We can delete the rest. deleteRemainingChildren(returnFiber, oldFiber); - return resultingFirstChild; } @@ -10187,7 +9701,6 @@ function ChildReconciler(shouldTrackSideEffects) { if (step.done) { // We've reached the end of the new children. We can delete the rest. deleteRemainingChildren(returnFiber, oldFiber); - return resultingFirstChild; } @@ -10746,10 +10259,61 @@ var Passive$1 = /* */ 8; +var isHydrating = false; + +function enterHydrationState(fiber) { + { + return false; + } +} + +function prepareToHydrateHostInstance( + fiber, + rootContainerInstance, + hostContext +) { + { + throw new 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 new 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]; @@ -10761,6 +10325,32 @@ function resetWorkInProgressVersions() { 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. function getSuspendedCachePool() { { @@ -10771,9 +10361,11 @@ function getSuspendedCachePool() { var ReactCurrentDispatcher$1 = ReactSharedInternals.ReactCurrentDispatcher, ReactCurrentBatchConfig$1 = ReactSharedInternals.ReactCurrentBatchConfig; var didWarnAboutMismatchedHooksForComponent; +var didWarnAboutUseOpaqueIdentifier; var didWarnUncachedGetSnapshot; { + didWarnAboutUseOpaqueIdentifier = {}; didWarnAboutMismatchedHooksForComponent = new Set(); } @@ -10797,11 +10389,7 @@ var didScheduleRenderPhaseUpdate = false; // Where an update was scheduled only // TODO: Maybe there's some way to consolidate this with // `didScheduleRenderPhaseUpdate`. Or with `numberOfReRenders`. -var didScheduleRenderPhaseUpdateDuringThisPass = false; // Counts the number of useId hooks in this component. -// hydration). This counter is global, so client ids are not stable across -// render attempts. - -var globalClientIdCounter = 0; +var didScheduleRenderPhaseUpdateDuringThisPass = 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. @@ -10982,7 +10570,6 @@ function renderWithHooks( // currentHook = null; // workInProgressHook = null; // didScheduleRenderPhaseUpdate = false; - // localIdCounter = 0; // TODO Warn if no hooks are used at all during mount, then some are used during update. // Currently we will identify the update render as a mount because memoizedState === null. // This is tricky because it's valid for certain types of components (e.g. React.lazy) @@ -11479,16 +11066,254 @@ function rerenderReducer(reducer, initialArg, init) { return [newState, dispatch]; } -function mountMutableSource(source, getSnapshot, subscribe) { +function readFromUnsubscribedMutableSource(root, source, getSnapshot) { { - return undefined; + 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); // Intentioally throw an error to force React to retry synchronously. During + // the synchronous retry, it will block interleaved mutations, so we should + // get a consistent read. Therefore, the following error should never be + // visible to the user. + // We expect this error not to be thrown during the synchronous retry, + // because we blocked interleaved mutations. + + throw new Error( + "Cannot read from mutable source during the current render without tearing. This may be a bug in React. Please file an issue." + ); } } -function updateMutableSource(source, getSnapshot, subscribe) { - { - return undefined; +function useMutableSource(hook, source, getSnapshot, subscribe) { + var root = getWorkInProgressRoot(); + + if (root === null) { + throw new 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 readFromUnsubscribedMutableSource(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 lane = requestUpdateLane(fiber); + 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 lane = requestUpdateLane(fiber); + 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, + interleaved: null, + lanes: NoLanes, + dispatch: null, + lastRenderedReducer: basicStateReducer, + lastRenderedState: snapshot + }; + newQueue.dispatch = setSnapshot = dispatchSetState.bind( + null, + currentlyRenderingFiber$1, + newQueue + ); + stateHook.queue = newQueue; + stateHook.baseQueue = null; + snapshot = readFromUnsubscribedMutableSource(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 mountSyncExternalStore(subscribe, getSnapshot, getServerSnapshot) { @@ -11815,6 +11640,13 @@ function updateEffectImpl(fiberFlags, hookFlags, create, deps) { } function mountEffect(create, deps) { + { + // $FlowExpectedError - jest isn't a global, and isn't recognized outside of tests + if ("undefined" !== typeof jest) { + warnIfNotCurrentlyActingEffectsInDEV(currentlyRenderingFiber$1); + } + } + if ((currentlyRenderingFiber$1.mode & StrictEffectsMode) !== NoMode) { return mountEffectImpl( MountPassiveDev | Passive | PassiveStatic, @@ -11828,6 +11660,13 @@ function mountEffect(create, deps) { } function updateEffect(create, deps) { + { + // $FlowExpectedError - jest isn't a global, and isn't recognized outside of tests + if ("undefined" !== typeof jest) { + warnIfNotCurrentlyActingEffectsInDEV(currentlyRenderingFiber$1); + } + } + return updateEffectImpl(Passive, Passive$1, create, deps); } @@ -12133,23 +11972,44 @@ function getIsUpdatingOpaqueValueInRenderPhaseInDEV() { } } -function mountId() { - var hook = mountWorkInProgressHook(); - var id; +function warnOnOpaqueIdentifierAccessInDEV(fiber) { + { + // TODO: Should warn in effects and callbacks, too + var name = getComponentNameFromFiber(fiber) || "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) + ); { - // Use a lowercase r prefix for client-generated ids. - var globalClientId = globalClientIdCounter++; - id = "r:" + globalClientId.toString(32); - } + var _id = makeId(); - hook.memoizedState = id; + mountState(_id); + return _id; + } +} + +function updateOpaqueIdentifier() { + var id = updateState()[0]; return id; } -function updateId() { - var hook = updateWorkInProgressHook(); - var id = hook.memoizedState; +function rerenderOpaqueIdentifier() { + var id = rerenderState()[0]; return id; } @@ -12177,6 +12037,14 @@ function dispatchReducerAction(fiber, queue, action) { enqueueRenderPhaseUpdate(queue, update); } else { enqueueUpdate$1(fiber, queue, update); + + { + // $FlowExpectedError - jest isn't a global, and isn't recognized outside of tests + if ("undefined" !== typeof jest) { + warnIfNotCurrentlyActingUpdatesInDev(fiber); + } + } + var eventTime = requestEventTime(); var root = scheduleUpdateOnFiber(fiber, lane, eventTime); @@ -12184,8 +12052,6 @@ function dispatchReducerAction(fiber, queue, action) { entangleTransitionUpdate(root, queue, lane); } } - - markUpdateInDevTools(fiber, lane); } function dispatchSetState(fiber, queue, action) { @@ -12258,6 +12124,13 @@ function dispatchSetState(fiber, queue, action) { } } + { + // $FlowExpectedError - jest isn't a global, and isn't recognized outside of tests + if ("undefined" !== typeof jest) { + warnIfNotCurrentlyActingUpdatesInDev(fiber); + } + } + var eventTime = requestEventTime(); var root = scheduleUpdateOnFiber(fiber, lane, eventTime); @@ -12265,8 +12138,6 @@ function dispatchSetState(fiber, queue, action) { entangleTransitionUpdate(root, queue, lane); } } - - markUpdateInDevTools(fiber, lane); } function isRenderPhaseUpdate(fiber) { @@ -12345,12 +12216,6 @@ function entangleTransitionUpdate(root, queue, lane) { } } -function markUpdateInDevTools(fiber, lane, action) { - { - markStateUpdateScheduled(fiber, lane); - } -} - var ContextOnlyDispatcher = { readContext: readContext, useCallback: throwInvalidHookError, @@ -12368,7 +12233,7 @@ var ContextOnlyDispatcher = { useTransition: throwInvalidHookError, useMutableSource: throwInvalidHookError, useSyncExternalStore: throwInvalidHookError, - useId: throwInvalidHookError, + useOpaqueIdentifier: throwInvalidHookError, unstable_isNewReconciler: enableNewReconciler }; @@ -12498,17 +12363,17 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; useMutableSource: function(source, getSnapshot, subscribe) { currentHookNameInDev = "useMutableSource"; mountHookTypesDev(); - return mountMutableSource(); + return mountMutableSource(source, getSnapshot, subscribe); }, useSyncExternalStore: function(subscribe, getSnapshot, getServerSnapshot) { currentHookNameInDev = "useSyncExternalStore"; mountHookTypesDev(); return mountSyncExternalStore(subscribe, getSnapshot); }, - useId: function() { - currentHookNameInDev = "useId"; + useOpaqueIdentifier: function() { + currentHookNameInDev = "useOpaqueIdentifier"; mountHookTypesDev(); - return mountId(); + return mountOpaqueIdentifier(); }, unstable_isNewReconciler: enableNewReconciler }; @@ -12606,17 +12471,17 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; useMutableSource: function(source, getSnapshot, subscribe) { currentHookNameInDev = "useMutableSource"; updateHookTypesDev(); - return mountMutableSource(); + return mountMutableSource(source, getSnapshot, subscribe); }, useSyncExternalStore: function(subscribe, getSnapshot, getServerSnapshot) { currentHookNameInDev = "useSyncExternalStore"; updateHookTypesDev(); return mountSyncExternalStore(subscribe, getSnapshot); }, - useId: function() { - currentHookNameInDev = "useId"; + useOpaqueIdentifier: function() { + currentHookNameInDev = "useOpaqueIdentifier"; updateHookTypesDev(); - return mountId(); + return mountOpaqueIdentifier(); }, unstable_isNewReconciler: enableNewReconciler }; @@ -12714,17 +12579,17 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; useMutableSource: function(source, getSnapshot, subscribe) { currentHookNameInDev = "useMutableSource"; updateHookTypesDev(); - return updateMutableSource(); + return updateMutableSource(source, getSnapshot, subscribe); }, useSyncExternalStore: function(subscribe, getSnapshot, getServerSnapshot) { currentHookNameInDev = "useSyncExternalStore"; updateHookTypesDev(); return updateSyncExternalStore(subscribe, getSnapshot); }, - useId: function() { - currentHookNameInDev = "useId"; + useOpaqueIdentifier: function() { + currentHookNameInDev = "useOpaqueIdentifier"; updateHookTypesDev(); - return updateId(); + return updateOpaqueIdentifier(); }, unstable_isNewReconciler: enableNewReconciler }; @@ -12822,17 +12687,17 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; useMutableSource: function(source, getSnapshot, subscribe) { currentHookNameInDev = "useMutableSource"; updateHookTypesDev(); - return updateMutableSource(); + return updateMutableSource(source, getSnapshot, subscribe); }, useSyncExternalStore: function(subscribe, getSnapshot, getServerSnapshot) { currentHookNameInDev = "useSyncExternalStore"; updateHookTypesDev(); return updateSyncExternalStore(subscribe, getSnapshot); }, - useId: function() { - currentHookNameInDev = "useId"; + useOpaqueIdentifier: function() { + currentHookNameInDev = "useOpaqueIdentifier"; updateHookTypesDev(); - return updateId(); + return rerenderOpaqueIdentifier(); }, unstable_isNewReconciler: enableNewReconciler }; @@ -12945,7 +12810,7 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; currentHookNameInDev = "useMutableSource"; warnInvalidHookAccess(); mountHookTypesDev(); - return mountMutableSource(); + return mountMutableSource(source, getSnapshot, subscribe); }, useSyncExternalStore: function(subscribe, getSnapshot, getServerSnapshot) { currentHookNameInDev = "useSyncExternalStore"; @@ -12953,11 +12818,11 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; mountHookTypesDev(); return mountSyncExternalStore(subscribe, getSnapshot); }, - useId: function() { - currentHookNameInDev = "useId"; + useOpaqueIdentifier: function() { + currentHookNameInDev = "useOpaqueIdentifier"; warnInvalidHookAccess(); mountHookTypesDev(); - return mountId(); + return mountOpaqueIdentifier(); }, unstable_isNewReconciler: enableNewReconciler }; @@ -13070,7 +12935,7 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; currentHookNameInDev = "useMutableSource"; warnInvalidHookAccess(); updateHookTypesDev(); - return updateMutableSource(); + return updateMutableSource(source, getSnapshot, subscribe); }, useSyncExternalStore: function(subscribe, getSnapshot, getServerSnapshot) { currentHookNameInDev = "useSyncExternalStore"; @@ -13078,11 +12943,11 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; updateHookTypesDev(); return updateSyncExternalStore(subscribe, getSnapshot); }, - useId: function() { - currentHookNameInDev = "useId"; + useOpaqueIdentifier: function() { + currentHookNameInDev = "useOpaqueIdentifier"; warnInvalidHookAccess(); updateHookTypesDev(); - return updateId(); + return updateOpaqueIdentifier(); }, unstable_isNewReconciler: enableNewReconciler }; @@ -13195,7 +13060,7 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; currentHookNameInDev = "useMutableSource"; warnInvalidHookAccess(); updateHookTypesDev(); - return updateMutableSource(); + return updateMutableSource(source, getSnapshot, subscribe); }, useSyncExternalStore: function(subscribe, getSnapshot, getServerSnapshot) { currentHookNameInDev = "useSyncExternalStore"; @@ -13203,11 +13068,11 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; updateHookTypesDev(); return updateSyncExternalStore(subscribe, getSnapshot); }, - useId: function() { - currentHookNameInDev = "useId"; + useOpaqueIdentifier: function() { + currentHookNameInDev = "useOpaqueIdentifier"; warnInvalidHookAccess(); updateHookTypesDev(); - return updateId(); + return rerenderOpaqueIdentifier(); }, unstable_isNewReconciler: enableNewReconciler }; @@ -13491,7 +13356,7 @@ function logCapturedError(boundary, errorInfo) { } } -var PossiblyWeakMap$2 = typeof WeakMap === "function" ? WeakMap : Map; +var PossiblyWeakMap$1 = typeof WeakMap === "function" ? WeakMap : Map; function createRootErrorUpdate(fiber, errorInfo, lane) { var update = createUpdate(NoTimestamp, lane); // Unmount the root by rendering null. @@ -13596,7 +13461,7 @@ function attachWakeableListeners(suspenseBoundary, root, wakeable, lanes) { var threadIDs; if (pingCache === null) { - pingCache = root.pingCache = new PossiblyWeakMap$2(); + pingCache = root.pingCache = new PossiblyWeakMap$1(); threadIDs = new Set(); pingCache.set(wakeable, threadIDs); } else { @@ -14237,12 +14102,7 @@ function completeSuspendedOffscreenHostContainer(current, workInProgress) { } function completeWork(current, workInProgress, renderLanes) { - var newProps = workInProgress.pendingProps; // Note: This intentionally doesn't check if we're hydrating because comparing - // to the current tree provider fiber is just as fast and less error-prone. - // Ideally we would have a special version of the work loop only - // for hydration. - - popTreeContext(workInProgress); + var newProps = workInProgress.pendingProps; switch (workInProgress.tag) { case IndeterminateComponent: @@ -14441,7 +14301,7 @@ function completeWork(current, workInProgress, renderLanes) { else { var prevState = current.memoizedState; prevDidTimeout = prevState !== null; - } + } // If the suspended state of the boundary changes, we need to schedule // an effect to toggle the subtree's visibility. When we switch from // fallback -> primary, the inner Offscreen fiber schedules this effect // as part of its normal complete phase. But when we switch from @@ -14454,8 +14314,8 @@ function completeWork(current, workInProgress, renderLanes) { // is active that we have to do anything special. if (nextDidTimeout && !prevDidTimeout) { - var _offscreenFiber = workInProgress.child; - _offscreenFiber.flags |= Visibility; // TODO: This will still suspend a synchronous tree if anything + var offscreenFiber = workInProgress.child; + offscreenFiber.flags |= Visibility; // TODO: This will still suspend a synchronous tree if anything // in the concurrent tree already suspended during this render. // This is a known bug. @@ -14929,10 +14789,6 @@ function updateForwardRef( var nextChildren; prepareToReadContext(workInProgress, renderLanes); - { - markComponentRenderStarted(workInProgress); - } - { ReactCurrentOwner$1.current = workInProgress; setIsRendering(true); @@ -14965,10 +14821,6 @@ function updateForwardRef( setIsRendering(false); } - { - markComponentRenderStopped(); - } - if (current !== null && !didReceiveUpdate) { bailoutHooks(current, workInProgress, renderLanes); return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes); @@ -15397,10 +15249,6 @@ function updateFunctionComponent( var nextChildren; prepareToReadContext(workInProgress, renderLanes); - { - markComponentRenderStarted(workInProgress); - } - { ReactCurrentOwner$1.current = workInProgress; setIsRendering(true); @@ -15433,10 +15281,6 @@ function updateFunctionComponent( setIsRendering(false); } - { - markComponentRenderStopped(); - } - if (current !== null && !didReceiveUpdate) { bailoutHooks(current, workInProgress, renderLanes); return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes); @@ -15624,10 +15468,6 @@ function finishClassComponent( stopProfilerTimerIfRunning(); } } else { - { - markComponentRenderStarted(workInProgress); - } - { setIsRendering(true); nextChildren = instance.render(); @@ -15644,10 +15484,6 @@ function finishClassComponent( setIsRendering(false); } - - { - markComponentRenderStopped(); - } } // React DevTools reads this flag. workInProgress.flags |= PerformedWork; @@ -15978,10 +15814,6 @@ function mountIndeterminateComponent( prepareToReadContext(workInProgress, renderLanes); var value; - { - markComponentRenderStarted(workInProgress); - } - { if ( Component.prototype && @@ -16018,10 +15850,6 @@ function mountIndeterminateComponent( setIsRendering(false); } - { - markComponentRenderStopped(); - } // React DevTools reads this flag. - workInProgress.flags |= PerformedWork; { @@ -16212,7 +16040,6 @@ function validateFunctionComponentInDev(workInProgress, Component) { var SUSPENDED_MARKER = { dehydrated: null, - treeContext: null, retryLane: NoLane }; @@ -17237,10 +17064,6 @@ function updateContextConsumer(current, workInProgress, renderLanes) { prepareToReadContext(workInProgress, renderLanes); var newValue = readContext(context); - { - markComponentRenderStarted(workInProgress); - } - var newChildren; { @@ -17250,10 +17073,6 @@ function updateContextConsumer(current, workInProgress, renderLanes) { setIsRendering(false); } - { - markComponentRenderStopped(); - } // React DevTools reads this flag. - workInProgress.flags |= PerformedWork; reconcileChildren(current, workInProgress, newChildren, renderLanes); return workInProgress.child; @@ -17801,12 +17620,6 @@ function beginWork(current, workInProgress, renderLanes) { } function unwindWork(workInProgress, renderLanes) { - // Note: This intentionally doesn't check if we're hydrating because comparing - // to the current tree provider fiber is just as fast and less error-prone. - // Ideally we would have a special version of the work loop only - // for hydration. - popTreeContext(workInProgress); - switch (workInProgress.tag) { case ClassComponent: { var Component = workInProgress.type; @@ -17902,12 +17715,6 @@ function unwindWork(workInProgress, renderLanes) { } function unwindInterruptedWork(interruptedWork, renderLanes) { - // Note: This intentionally doesn't check if we're hydrating because comparing - // to the current tree provider fiber is just as fast and less error-prone. - // Ideally we would have a special version of the work loop only - // for hydration. - popTreeContext(interruptedWork); - switch (interruptedWork.tag) { case ClassComponent: { var childContextTypes = interruptedWork.type.childContextTypes; @@ -18232,23 +18039,7 @@ function commitHookEffectListUnmount( effect.destroy = undefined; if (destroy !== undefined) { - { - if ((flags & Passive$1) !== NoFlags$1) { - markComponentPassiveEffectUnmountStarted(finishedWork); - } else if ((flags & Layout) !== NoFlags$1) { - markComponentLayoutEffectUnmountStarted(finishedWork); - } - } - safelyCallDestroy(finishedWork, nearestMountedAncestor, destroy); - - { - if ((flags & Passive$1) !== NoFlags$1) { - markComponentPassiveEffectUnmountStopped(); - } else if ((flags & Layout) !== NoFlags$1) { - markComponentLayoutEffectUnmountStopped(); - } - } } } @@ -18257,7 +18048,7 @@ function commitHookEffectListUnmount( } } -function commitHookEffectListMount(flags, finishedWork) { +function commitHookEffectListMount(tag, finishedWork) { var updateQueue = finishedWork.updateQueue; var lastEffect = updateQueue !== null ? updateQueue.lastEffect : null; @@ -18266,26 +18057,11 @@ function commitHookEffectListMount(flags, finishedWork) { var effect = firstEffect; do { - if ((effect.tag & flags) === flags) { - { - if ((flags & Passive$1) !== NoFlags$1) { - markComponentPassiveEffectMountStarted(finishedWork); - } else if ((flags & Layout) !== NoFlags$1) { - markComponentLayoutEffectMountStarted(finishedWork); - } - } // Mount - + if ((effect.tag & tag) === tag) { + // Mount var create = effect.create; effect.destroy = create(); - { - if ((flags & Passive$1) !== NoFlags$1) { - markComponentPassiveEffectMountStopped(); - } else if ((flags & Layout) !== NoFlags$1) { - markComponentLayoutEffectMountStopped(); - } - } - { var destroy = effect.destroy; @@ -18879,13 +18655,10 @@ function commitUnmount(finishedRoot, current, nearestMountedAncestor) { tag = _effect.tag; if (destroy !== undefined) { - if ((tag & Insertion) !== NoFlags$1) { - safelyCallDestroy(current, nearestMountedAncestor, destroy); - } else if ((tag & Layout) !== NoFlags$1) { - { - markComponentLayoutEffectUnmountStarted(current); - } - + if ( + (tag & Insertion) !== NoFlags$1 || + (tag & Layout) !== NoFlags$1 + ) { if (current.mode & ProfileMode) { startLayoutEffectTimer(); safelyCallDestroy(current, nearestMountedAncestor, destroy); @@ -18893,10 +18666,6 @@ function commitUnmount(finishedRoot, current, nearestMountedAncestor) { } else { safelyCallDestroy(current, nearestMountedAncestor, destroy); } - - { - markComponentLayoutEffectUnmountStopped(); - } } } @@ -20158,46 +19927,11 @@ if (typeof Symbol === "function" && Symbol.for) { TEXT_TYPE = symbolFor$1("selector.text"); } -var ReactCurrentActQueue = ReactSharedInternals.ReactCurrentActQueue; -function isLegacyActEnvironment(fiber) { - { - // Legacy mode. We preserve the behavior of React 17's act. It assumes an - // act environment whenever `jest` is defined, but you can still turn off - // spurious warnings by setting IS_REACT_ACT_ENVIRONMENT explicitly - // to false. - var isReactActEnvironmentGlobal = // $FlowExpectedError – Flow doesn't know about IS_REACT_ACT_ENVIRONMENT global - typeof IS_REACT_ACT_ENVIRONMENT !== "undefined" - ? IS_REACT_ACT_ENVIRONMENT - : undefined; // $FlowExpectedError - Flow doesn't know about jest - - var jestIsDefined = typeof jest !== "undefined"; - return jestIsDefined && isReactActEnvironmentGlobal !== false; - } -} -function isConcurrentActEnvironment() { - { - var isReactActEnvironmentGlobal = // $FlowExpectedError – Flow doesn't know about IS_REACT_ACT_ENVIRONMENT global - typeof IS_REACT_ACT_ENVIRONMENT !== "undefined" - ? IS_REACT_ACT_ENVIRONMENT - : undefined; - - if (!isReactActEnvironmentGlobal && ReactCurrentActQueue.current !== null) { - // TODO: Include link to relevant documentation page. - error( - "The current testing environment is not configured to support " + - "act(...)" - ); - } - - return isReactActEnvironmentGlobal; - } -} - var ceil = Math.ceil; var ReactCurrentDispatcher$2 = ReactSharedInternals.ReactCurrentDispatcher, ReactCurrentOwner$2 = ReactSharedInternals.ReactCurrentOwner, ReactCurrentBatchConfig$2 = ReactSharedInternals.ReactCurrentBatchConfig, - ReactCurrentActQueue$1 = ReactSharedInternals.ReactCurrentActQueue; + ReactCurrentActQueue = ReactSharedInternals.ReactCurrentActQueue; var NoContext = /* */ 0; @@ -20250,9 +19984,7 @@ var workInProgressRootIncludedLanes = NoLanes; // The work left over by componen var workInProgressRootSkippedLanes = NoLanes; // Lanes that were updated (in an interleaved event) during this render. -var workInProgressRootInterleavedUpdatedLanes = NoLanes; // Lanes that were updated during the render phase (*not* an interleaved event). - -var workInProgressRootRenderPhaseUpdatedLanes = NoLanes; // Lanes that were pinged (in an interleaved event) during this render. +var workInProgressRootUpdatedLanes = NoLanes; // Lanes that were pinged (in an interleaved event) during this render. var workInProgressRootPingedLanes = NoLanes; // 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. @@ -20279,7 +20011,7 @@ var legacyErrorBoundariesThatAlreadyFailed = null; // Only used when enableProfi var rootDoesHavePassiveEffects = false; var rootWithPendingPassiveEffects = null; var pendingPassiveEffectsLanes = NoLanes; -var pendingPassiveProfilerEffects = []; +var pendingPassiveProfilerEffects = []; // Use these to prevent an infinite loop of nested updates var NESTED_UPDATE_LIMIT = 50; var nestedUpdateCount = 0; @@ -20384,80 +20116,60 @@ function requestRetryLane(fiber) { function scheduleUpdateOnFiber(fiber, lane, eventTime) { checkForNestedUpdates(); + warnAboutRenderPhaseUpdatesInDEV(fiber); var root = markUpdateLaneFromFiberToRoot(fiber, lane); if (root === null) { return null; + } + + { + if (isDevToolsPresent) { + addFiberToLanesMap(root, fiber, lane); + } } // Mark that the root has a pending update. 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. + if ((executionContext & RenderContext) === NoContext) { + 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); + } + } + + ensureRootIsScheduled(root, eventTime); + if ( - (executionContext & RenderContext) !== NoLanes && - root === workInProgressRoot + lane === SyncLane && + executionContext === NoContext && + (fiber.mode & ConcurrentMode) === NoMode && // Treat `act` as if it's inside `batchedUpdates`, even in legacy mode. + !ReactCurrentActQueue.isBatchingLegacy ) { - // This update was dispatched during the render phase. This is a mistake - // if the update originates from user space (with the exception of local - // hook updates, which are handled differently and don't reach this - // function), but there are some internal React features that use this as - // an implementation detail, like selective hydration. - warnAboutRenderPhaseUpdatesInDEV(fiber); // Track lanes that were updated during the render phase - - workInProgressRootRenderPhaseUpdatedLanes = mergeLanes( - workInProgressRootRenderPhaseUpdatedLanes, - lane - ); - } else { - // This is a normal update, scheduled from outside the render phase. For - // example, during an input event. - { - if (isDevToolsPresent) { - addFiberToLanesMap(root, fiber, lane); - } - } - - warnIfUpdatesNotWrappedWithActDEV(fiber); - - 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. - if ((executionContext & RenderContext) === NoContext) { - workInProgressRootInterleavedUpdatedLanes = mergeLanes( - workInProgressRootInterleavedUpdatedLanes, - 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); - } - } - - ensureRootIsScheduled(root, eventTime); - - if ( - lane === SyncLane && - executionContext === NoContext && - (fiber.mode & ConcurrentMode) === NoMode && // Treat `act` as if it's inside `batchedUpdates`, even in legacy mode. - !ReactCurrentActQueue$1.isBatchingLegacy - ) { - // Flush the synchronous work now, unless we're already working or inside - // a batch. This is intentionally inside scheduleUpdateOnFiber instead of - // scheduleCallbackForFiber to preserve the ability to schedule a callback - // without immediately flushing it. We only do this for user-initiated - // updates, to preserve historical behavior of legacy mode. - resetRenderTimer(); - flushSyncCallbacksOnlyInLegacyMode(); - } + // Flush the synchronous work now, unless we're already working or inside + // a batch. This is intentionally inside scheduleUpdateOnFiber instead of + // scheduleCallbackForFiber to preserve the ability to schedule a callback + // without immediately flushing it. We only do this for user-initiated + // updates, to preserve historical behavior of legacy mode. + resetRenderTimer(); + flushSyncCallbacksOnlyInLegacyMode(); } return root; @@ -20562,7 +20274,7 @@ function ensureRootIsScheduled(root, currentTime) { // Scheduler task, rather than an `act` task, cancel it and re-scheduled // on the `act` queue. !( - ReactCurrentActQueue$1.current !== null && + ReactCurrentActQueue.current !== null && existingCallbackNode !== fakeActCallbackNode ) ) { @@ -20594,8 +20306,8 @@ function ensureRootIsScheduled(root, currentTime) { // Special case: Sync React callbacks are scheduled on a special // internal queue if (root.tag === LegacyRoot) { - if (ReactCurrentActQueue$1.isBatchingLegacy !== null) { - ReactCurrentActQueue$1.didScheduleLegacyUpdate = true; + if (ReactCurrentActQueue.isBatchingLegacy !== null) { + ReactCurrentActQueue.didScheduleLegacyUpdate = true; } scheduleLegacySyncCallback(performSyncWorkOnRoot.bind(null, root)); @@ -20785,26 +20497,7 @@ function recoverFromConcurrentError(root, errorRetryLanes) { clearContainer(root.containerInfo); } - var exitStatus; - var MAX_ERROR_RETRY_ATTEMPTS = 50; - - for (var i = 0; i < MAX_ERROR_RETRY_ATTEMPTS; i++) { - exitStatus = renderRootSync(root, errorRetryLanes); - - if ( - exitStatus === RootErrored && - workInProgressRootRenderPhaseUpdatedLanes !== NoLanes - ) { - // There was a render phase update during this render. Some internal React - // implementation details may use this as a trick to schedule another - // render pass. To protect against an inifinite loop, eventually - // we'll give up. - continue; - } - - break; - } - + var exitStatus = renderRootSync(root, errorRetryLanes); executionContext = prevExecutionContext; return exitStatus; } @@ -20991,10 +20684,7 @@ function markRootSuspended$1(root, suspendedLanes) { // TODO: Lol maybe there's a better way to factor this besides this // obnoxiously named function :) suspendedLanes = removeLanes(suspendedLanes, workInProgressRootPingedLanes); - suspendedLanes = removeLanes( - suspendedLanes, - workInProgressRootInterleavedUpdatedLanes - ); + suspendedLanes = removeLanes(suspendedLanes, workInProgressRootUpdatedLanes); markRootSuspended(root, suspendedLanes); } // This is the entry point for synchronous tasks that don't go // through Scheduler @@ -21020,16 +20710,31 @@ function performSyncWorkOnRoot(root) { var exitStatus = renderRootSync(root, lanes); if (root.tag !== LegacyRoot && exitStatus === RootErrored) { - // If something threw an error, try rendering one more time. We'll render + var prevExecutionContext = executionContext; + executionContext |= RetryAfterError; // If an error occurred during hydration, + // discard server response and fall back to client side render. + + if (root.isDehydrated) { + root.isDehydrated = false; + + { + errorHydratingContainer(root.containerInfo); + } + + 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. + var errorRetryLanes = getLanesToRetrySynchronouslyOnError(root); if (errorRetryLanes !== NoLanes) { lanes = errorRetryLanes; - exitStatus = recoverFromConcurrentError(root, errorRetryLanes); + exitStatus = renderRootSync(root, lanes); } + + executionContext = prevExecutionContext; } if (exitStatus === RootFatalErrored) { @@ -21062,7 +20767,7 @@ function batchedUpdates$1(fn, a) { if ( executionContext === NoContext && // Treat `act` as if it's inside `batchedUpdates`, even in legacy mode. - !ReactCurrentActQueue$1.isBatchingLegacy + !ReactCurrentActQueue.isBatchingLegacy ) { resetRenderTimer(); flushSyncCallbacksOnlyInLegacyMode(); @@ -21150,8 +20855,7 @@ function prepareFreshStack(root, lanes) { workInProgressRootExitStatus = RootIncomplete; workInProgressRootFatalError = null; workInProgressRootSkippedLanes = NoLanes; - workInProgressRootInterleavedUpdatedLanes = NoLanes; - workInProgressRootRenderPhaseUpdatedLanes = NoLanes; + workInProgressRootUpdatedLanes = NoLanes; workInProgressRootPingedLanes = NoLanes; enqueueInterleavedUpdates(); @@ -21293,7 +20997,7 @@ function renderDidSuspendDelayIfPossible() { if ( workInProgressRoot !== null && (includesNonIdleWork(workInProgressRootSkippedLanes) || - includesNonIdleWork(workInProgressRootInterleavedUpdatedLanes)) + includesNonIdleWork(workInProgressRootUpdatedLanes)) ) { // 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 @@ -21344,10 +21048,6 @@ function renderRootSync(root, lanes) { prepareFreshStack(root, lanes); } - { - markRenderStarted(lanes); - } - do { try { workLoopSync(); @@ -21369,10 +21069,6 @@ function renderRootSync(root, lanes) { ); } - { - markRenderStopped(); - } // Set this to null to indicate there's no in-progress render. - workInProgressRoot = null; workInProgressRootRenderLanes = NoLanes; return workInProgressRootExitStatus; @@ -21414,10 +21110,6 @@ function renderRootConcurrent(root, lanes) { prepareFreshStack(root, lanes); } - { - markRenderStarted(lanes); - } - do { try { workLoopConcurrent(); @@ -21432,18 +21124,8 @@ function renderRootConcurrent(root, lanes) { executionContext = prevExecutionContext; if (workInProgress !== null) { - // Still work remaining. - { - markRenderYielded(); - } - return RootIncomplete; } else { - // Completed the tree. - { - markRenderStopped(); - } // Set this to null to indicate there's no in-progress render. - workInProgressRoot = null; workInProgressRootRenderLanes = NoLanes; // Return the final exit status. @@ -21615,15 +21297,7 @@ function commitRootImpl(root, renderPriorityLevel) { var finishedWork = root.finishedWork; var lanes = root.finishedLanes; - { - markCommitStarted(lanes); - } - if (finishedWork === null) { - { - markCommitStopped(); - } - return null; } else { { @@ -21672,10 +21346,7 @@ function commitRootImpl(root, renderPriorityLevel) { if (!rootDoesHavePassiveEffects) { rootDoesHavePassiveEffects = true; scheduleCallback$1(NormalPriority, function() { - flushPassiveEffects(); // This render triggered passive effects: release the root cache pool - // *after* passive effects fire to avoid freeing a cache pool that may - // be referenced by a node in the tree (HostRoot, Cache boundary etc) - + flushPassiveEffects(); return null; }); } @@ -21729,15 +21400,7 @@ function commitRootImpl(root, renderPriorityLevel) { root.current = finishedWork; // The next phase is the layout phase, where we call effects that read - { - markLayoutEffectsStarted(lanes); - } - commitLayoutEffects(finishedWork, root, lanes); - - { - markLayoutEffectsStopped(); - } // opportunity to paint. requestPaint(); @@ -21841,10 +21504,6 @@ function commitRootImpl(root, renderPriorityLevel) { flushSyncCallbacks(); - { - markCommitStopped(); - } - return null; } @@ -21867,7 +21526,7 @@ function flushPassiveEffects() { return flushPassiveEffectsImpl(); } finally { setCurrentUpdatePriority(previousPriority); - ReactCurrentBatchConfig$2.transition = prevTransition; // Once passive effects have run for the tree - giving components a + ReactCurrentBatchConfig$2.transition = prevTransition; } } @@ -21893,7 +21552,6 @@ function flushPassiveEffectsImpl() { } var root = rootWithPendingPassiveEffects; - var lanes = pendingPassiveEffectsLanes; rootWithPendingPassiveEffects = null; // TODO: This is sometimes out of sync with rootWithPendingPassiveEffects. // Figure out why and fix it. It's not causing any known issues (probably // because it's only used for profiling), but it's a refactor hazard. @@ -21904,10 +21562,6 @@ function flushPassiveEffectsImpl() { throw new Error("Cannot flush passive effects while already rendering."); } - { - markPassiveEffectsStarted(lanes); - } - var prevExecutionContext = executionContext; executionContext |= CommitContext; commitPassiveUnmountEffects(root.current); @@ -21923,10 +21577,6 @@ function flushPassiveEffectsImpl() { } } - { - markPassiveEffectsStopped(); - } - { commitDoubleInvokeEffectsInDEV(root.current, true); } @@ -22057,7 +21707,6 @@ function pingSuspendedRoot(root, wakeable, pingedLanes) { var eventTime = requestEventTime(); markRootPinged(root, pingedLanes); - warnIfSuspenseResolutionNotWrappedWithActDEV(root); if ( workInProgressRoot === root && @@ -22383,7 +22032,11 @@ var didWarnAboutUpdateInRenderForAnotherComponent; function warnAboutRenderPhaseUpdatesInDEV(fiber) { { - if (isRendering && !getIsUpdatingOpaqueValueInRenderPhaseInDEV()) { + if ( + isRendering && + (executionContext & RenderContext) !== NoContext && + !getIsUpdatingOpaqueValueInRenderPhaseInDEV() + ) { switch (fiber.tag) { case FunctionComponent: case ForwardRef: @@ -22448,7 +22101,7 @@ function scheduleCallback$1(priorityLevel, callback) { { // If we're currently inside an `act` scope, bypass Scheduler and push to // the `act` queue instead. - var actQueue = ReactCurrentActQueue$1.current; + var actQueue = ReactCurrentActQueue.current; if (actQueue !== null) { actQueue.push(callback); @@ -22469,41 +22122,48 @@ function cancelCallback$1(callbackNode) { function shouldForceFlushFallbacksInDEV() { // Never force flush in production. This function should get stripped out. - return ReactCurrentActQueue$1.current !== null; + return ReactCurrentActQueue.current !== null; } -function warnIfUpdatesNotWrappedWithActDEV(fiber) { +function warnIfNotCurrentlyActingEffectsInDEV(fiber) { { - if (fiber.mode & ConcurrentMode) { - if (!isConcurrentActEnvironment()) { - // Not in an act environment. No need to warn. - return; - } - } else { - // Legacy mode has additional cases where we suppress a warning. - if (!isLegacyActEnvironment()) { - // Not in an act environment. No need to warn. - return; - } - - if (executionContext !== NoContext) { - // Legacy mode doesn't warn if the update is batched, i.e. - // batchedUpdates or flushSync. - return; - } - - if ( - fiber.tag !== FunctionComponent && - fiber.tag !== ForwardRef && - fiber.tag !== SimpleMemoComponent - ) { - // For backwards compatibility with pre-hooks code, legacy mode only - // warns for updates that originate from a hook. - return; - } + if ( + (fiber.mode & StrictLegacyMode) !== NoMode && + ReactCurrentActQueue.current === null && // Our internal tests use a custom implementation of `act` that works by + // mocking the Scheduler package. Disable the `act` warning. + // TODO: Maybe the warning should be disabled by default, and then turned + // on at the testing frameworks layer? Instead of what we do now, which + // is check if a `jest` global is defined. + ReactCurrentActQueue.disableActWarning === false + ) { + error( + "An update to %s ran an effect, but 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://reactjs.org/link/wrap-tests-with-act", + getComponentNameFromFiber(fiber) + ); } + } +} - if (ReactCurrentActQueue$1.current === null) { +function warnIfNotCurrentlyActingUpdatesInDEV(fiber) { + { + if ( + executionContext === NoContext && + ReactCurrentActQueue.current === null && // Our internal tests use a custom implementation of `act` that works by + // mocking the Scheduler package. Disable the `act` warning. + // TODO: Maybe the warning should be disabled by default, and then turned + // on at the testing frameworks layer? Instead of what we do now, which + // is check if a `jest` global is defined. + ReactCurrentActQueue.disableActWarning === false + ) { var previousFiber = current; try { @@ -22533,29 +22193,7 @@ function warnIfUpdatesNotWrappedWithActDEV(fiber) { } } -function warnIfSuspenseResolutionNotWrappedWithActDEV(root) { - { - if ( - root.tag !== LegacyRoot && - isConcurrentActEnvironment() && - ReactCurrentActQueue$1.current === null - ) { - error( - "A suspended resource finished loading inside a test, but the event " + - "was not wrapped in act(...).\n\n" + - "When testing, code that resolves suspended data should be wrapped " + - "into act(...):\n\n" + - "act(() => {\n" + - " /* finish loading suspended data */\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://reactjs.org/link/wrap-tests-with-act" - ); - } - } -} +var warnIfNotCurrentlyActingUpdatesInDev = warnIfNotCurrentlyActingUpdatesInDEV; /* eslint-disable react-internal/prod-error-codes */ var resolveFamily = null; // $FlowFixMe Flow gets confused by a WeakSet feature check below. @@ -23849,10 +23487,6 @@ function updateContainer(element, container, parentComponent, callback) { var eventTime = requestEventTime(); var lane = requestUpdateLane(current$1); - { - markRenderScheduled(lane); - } - var context = getContextForSubtree(parentComponent); if (container.context === null) { @@ -24689,24 +24323,5 @@ exports.unmountComponentAtNode = unmountComponentAtNode; exports.unmountComponentAtNodeAndRemoveContainer = unmountComponentAtNodeAndRemoveContainer; exports.unstable_batchedUpdates = batchedUpdates; - /** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -/* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */ - -// Don't require this file directly; it's embedded by Rollup during build. - -if ( - typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' && - typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop === - 'function' -) { - __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error()); -} - })(); } diff --git a/Libraries/Renderer/implementations/ReactNativeRenderer-prod.fb.js b/Libraries/Renderer/implementations/ReactNativeRenderer-prod.fb.js index 249c56d2259..fc9aa87d9e9 100644 --- a/Libraries/Renderer/implementations/ReactNativeRenderer-prod.fb.js +++ b/Libraries/Renderer/implementations/ReactNativeRenderer-prod.fb.js @@ -7,7 +7,7 @@ * @noflow * @nolint * @preventMunge - * @generated SignedSource<> + * @generated SignedSource<> */ "use strict"; @@ -926,7 +926,7 @@ eventPluginOrder = Array.prototype.slice.call([ "ReactNativeBridgeEventPlugin" ]); recomputePluginOrdering(); -var injectedNamesToPlugins$jscomp$inline_221 = { +var injectedNamesToPlugins$jscomp$inline_222 = { ResponderEventPlugin: ResponderEventPlugin, ReactNativeBridgeEventPlugin: { eventTypes: {}, @@ -961,33 +961,33 @@ var injectedNamesToPlugins$jscomp$inline_221 = { } } }, - isOrderingDirty$jscomp$inline_222 = !1, - pluginName$jscomp$inline_223; -for (pluginName$jscomp$inline_223 in injectedNamesToPlugins$jscomp$inline_221) + isOrderingDirty$jscomp$inline_223 = !1, + pluginName$jscomp$inline_224; +for (pluginName$jscomp$inline_224 in injectedNamesToPlugins$jscomp$inline_222) if ( - injectedNamesToPlugins$jscomp$inline_221.hasOwnProperty( - pluginName$jscomp$inline_223 + injectedNamesToPlugins$jscomp$inline_222.hasOwnProperty( + pluginName$jscomp$inline_224 ) ) { - var pluginModule$jscomp$inline_224 = - injectedNamesToPlugins$jscomp$inline_221[pluginName$jscomp$inline_223]; + var pluginModule$jscomp$inline_225 = + injectedNamesToPlugins$jscomp$inline_222[pluginName$jscomp$inline_224]; if ( - !namesToPlugins.hasOwnProperty(pluginName$jscomp$inline_223) || - namesToPlugins[pluginName$jscomp$inline_223] !== - pluginModule$jscomp$inline_224 + !namesToPlugins.hasOwnProperty(pluginName$jscomp$inline_224) || + namesToPlugins[pluginName$jscomp$inline_224] !== + pluginModule$jscomp$inline_225 ) { - if (namesToPlugins[pluginName$jscomp$inline_223]) + if (namesToPlugins[pluginName$jscomp$inline_224]) throw Error( "EventPluginRegistry: Cannot inject two different event plugins using the same name, `" + - (pluginName$jscomp$inline_223 + "`.") + (pluginName$jscomp$inline_224 + "`.") ); namesToPlugins[ - pluginName$jscomp$inline_223 - ] = pluginModule$jscomp$inline_224; - isOrderingDirty$jscomp$inline_222 = !0; + pluginName$jscomp$inline_224 + ] = pluginModule$jscomp$inline_225; + isOrderingDirty$jscomp$inline_223 = !0; } } -isOrderingDirty$jscomp$inline_222 && recomputePluginOrdering(); +isOrderingDirty$jscomp$inline_223 && recomputePluginOrdering(); var instanceCache = new Map(), instanceProps = new Map(); function getInstanceFromTag(tag) { @@ -1697,13 +1697,6 @@ function onCommitRoot(root) { ); } catch (err) {} } -var clz32 = Math.clz32 ? Math.clz32 : clz32Fallback, - log = Math.log, - LN2 = Math.LN2; -function clz32Fallback(x) { - x >>>= 0; - return 0 === x ? 32 : (31 - ((log(x) / LN2) | 0)) | 0; -} var nextTransitionLane = 64, nextRetryLane = 4194304; function getHighestPriorityLanes(lanes) { @@ -1887,6 +1880,12 @@ function markRootEntangled(root, entangledLanes) { rootEntangledLanes &= ~lane; } } +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 currentUpdatePriority = 0; function lanesToEventPriority(lanes) { lanes &= -lanes; @@ -2088,14 +2087,12 @@ function shallowEqual(objA, objB) { var keysA = Object.keys(objA), keysB = Object.keys(objB); if (keysA.length !== keysB.length) return !1; - for (keysB = 0; keysB < keysA.length; keysB++) { - var currentKey = keysA[keysB]; + for (keysB = 0; keysB < keysA.length; keysB++) if ( - !hasOwnProperty.call(objB, currentKey) || - !objectIs(objA[currentKey], objB[currentKey]) + !hasOwnProperty.call(objB, keysA[keysB]) || + !objectIs(objA[keysA[keysB]], objB[keysA[keysB]]) ) return !1; - } return !0; } function describeFiber(fiber) { @@ -2605,26 +2602,6 @@ function mountClassInstance(workInProgress, ctor, newProps, renderLanes) { "function" === typeof instance.componentDidMount && (workInProgress.flags |= 4); } -var forkStack = [], - forkStackIndex = 0, - treeForkProvider = null, - idStack = [], - idStackIndex = 0, - treeContextProvider = null; -function popTreeContext(workInProgress) { - for (; workInProgress === treeForkProvider; ) - (treeForkProvider = forkStack[--forkStackIndex]), - (forkStack[forkStackIndex] = null), - --forkStackIndex, - (forkStack[forkStackIndex] = null); - for (; workInProgress === treeContextProvider; ) - (treeContextProvider = idStack[--idStackIndex]), - (idStack[idStackIndex] = null), - --idStackIndex, - (idStack[idStackIndex] = null), - --idStackIndex, - (idStack[idStackIndex] = null); -} function coerceRef(returnFiber, current, element) { returnFiber = element.ref; if ( @@ -2719,8 +2696,7 @@ function ChildReconciler(shouldTrackSideEffects) { } function placeChild(newFiber, lastPlacedIndex, newIndex) { newFiber.index = newIndex; - if (!shouldTrackSideEffects) - return (newFiber.flags |= 1048576), lastPlacedIndex; + if (!shouldTrackSideEffects) return lastPlacedIndex; newIndex = newFiber.alternate; if (null !== newIndex) return ( @@ -3324,8 +3300,7 @@ var ReactCurrentDispatcher$1 = ReactSharedInternals.ReactCurrentDispatcher, currentHook = null, workInProgressHook = null, didScheduleRenderPhaseUpdate = !1, - didScheduleRenderPhaseUpdateDuringThisPass = !1, - globalClientIdCounter = 0; + didScheduleRenderPhaseUpdateDuringThisPass = !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://reactjs.org/link/invalid-hook-call for tips about how to debug and fix this problem." @@ -3528,7 +3503,104 @@ function rerenderReducer(reducer) { } return [newState, dispatch]; } -function updateMutableSource() {} +function readFromUnsubscribedMutableSource(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 may be 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 readFromUnsubscribedMutableSource(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); + objectIs(version, maybeNewVersion) || + ((maybeNewVersion = getSnapshot(source._source)), + objectIs(snapshot, maybeNewVersion) || + (setSnapshot(maybeNewVersion), + (maybeNewVersion = requestUpdateLane(fiber)), + (root.mutableReadLanes |= maybeNewVersion & root.pendingLanes)), + markRootEntangled(root, root.mutableReadLanes)); + }, + [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); + 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, + interleaved: null, + lanes: 0, + dispatch: null, + lastRenderedReducer: basicStateReducer, + lastRenderedState: snapshot + }), + (hook.dispatch = setSnapshot = dispatchSetState.bind( + null, + currentlyRenderingFiber$1, + hook + )), + (_dispatcher$useState.queue = hook), + (_dispatcher$useState.baseQueue = null), + (snapshot = readFromUnsubscribedMutableSource(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 mountSyncExternalStore(subscribe, getSnapshot) { var fiber = currentlyRenderingFiber$1, hook = mountWorkInProgressHook(); @@ -3651,7 +3723,7 @@ function updateEffectImpl(fiberFlags, hookFlags, create, deps) { hook.memoizedState = pushEffect(1 | hookFlags, create, destroy, deps); } function mountEffect(create, deps) { - return mountEffectImpl(8390656, 8, create, deps); + return mountEffectImpl(4196352, 8, create, deps); } function updateEffect(create, deps) { return updateEffectImpl(2048, 8, create, deps); @@ -3731,9 +3803,6 @@ function startTransition(setPending, callback) { (ReactCurrentBatchConfig$1.transition = prevTransition); } } -function updateId() { - return updateWorkInProgressHook().memoizedState; -} function dispatchReducerAction(fiber, queue, action) { var lane = requestUpdateLane(fiber); action = { @@ -3841,7 +3910,7 @@ var ContextOnlyDispatcher = { useTransition: throwInvalidHookError, useMutableSource: throwInvalidHookError, useSyncExternalStore: throwInvalidHookError, - useId: throwInvalidHookError, + useOpaqueIdentifier: throwInvalidHookError, unstable_isNewReconciler: !1 }, HooksDispatcherOnMount = { @@ -3929,12 +3998,18 @@ var ContextOnlyDispatcher = { mountWorkInProgressHook().memoizedState = _mountState2; return [isPending, _mountState2]; }, - useMutableSource: function() {}, - useSyncExternalStore: mountSyncExternalStore, - useId: function() { + useMutableSource: function(source, getSnapshot, subscribe) { var hook = mountWorkInProgressHook(); - var id = "r:" + (globalClientIdCounter++).toString(32); - return (hook.memoizedState = id); + hook.memoizedState = { + refs: { getSnapshot: getSnapshot, setSnapshot: null }, + source: source, + subscribe: subscribe + }; + return useMutableSource(hook, source, getSnapshot, subscribe); + }, + useSyncExternalStore: mountSyncExternalStore, + useOpaqueIdentifier: function() { + throw Error("Not yet implemented"); }, unstable_isNewReconciler: !1 }, @@ -4017,7 +4092,9 @@ var ContextOnlyDispatcher = { } return nextSnapshot; }, - useId: updateId, + useOpaqueIdentifier: function() { + return updateReducer(basicStateReducer)[0]; + }, unstable_isNewReconciler: !1 }, HooksDispatcherOnRerender = { @@ -4060,7 +4137,9 @@ var ContextOnlyDispatcher = { }, useMutableSource: updateMutableSource, useSyncExternalStore: mountSyncExternalStore, - useId: updateId, + useOpaqueIdentifier: function() { + return rerenderReducer(basicStateReducer)[0]; + }, unstable_isNewReconciler: !1 }; function createCapturedValue(value, source) { @@ -4194,8 +4273,8 @@ function bubbleProperties(completedWork) { if (didBailout) for (var child$36 = completedWork.child; null !== child$36; ) (newChildLanes |= child$36.lanes | child$36.childLanes), - (subtreeFlags |= child$36.subtreeFlags & 14680064), - (subtreeFlags |= child$36.flags & 14680064), + (subtreeFlags |= child$36.subtreeFlags & 7340032), + (subtreeFlags |= child$36.flags & 7340032), (child$36.return = completedWork), (child$36 = child$36.sibling); else @@ -4211,7 +4290,6 @@ function bubbleProperties(completedWork) { } function completeWork(current, workInProgress, renderLanes) { var newProps = workInProgress.pendingProps; - popTreeContext(workInProgress); switch (workInProgress.tag) { case 2: case 16: @@ -4356,7 +4434,7 @@ function completeWork(current, workInProgress, renderLanes) { workInProgressRootExitStatus = 4; null === workInProgressRoot || (0 === (workInProgressRootSkippedLanes & 268435455) && - 0 === (workInProgressRootInterleavedUpdatedLanes & 268435455)) || + 0 === (workInProgressRootUpdatedLanes & 268435455)) || markRootSuspended$1( workInProgressRoot, workInProgressRootRenderLanes @@ -4411,7 +4489,7 @@ function completeWork(current, workInProgress, renderLanes) { for (newProps = workInProgress.child; null !== newProps; ) (renderLanes = newProps), (type = current), - (renderLanes.flags &= 14680066), + (renderLanes.flags &= 7340034), (updatePayload = renderLanes.alternate), null === updatePayload ? ((renderLanes.childLanes = 0), @@ -4992,7 +5070,7 @@ function pushHostRootContext(workInProgress) { pushTopLevelContextObject(workInProgress, root.context, !1); pushHostContainer(workInProgress, root.containerInfo); } -var SUSPENDED_MARKER = { dehydrated: null, treeContext: null, retryLane: 0 }; +var SUSPENDED_MARKER = { dehydrated: null, retryLane: 0 }; function mountSuspenseOffscreenState(renderLanes) { return { baseLanes: renderLanes, cachePool: null }; } @@ -5185,7 +5263,7 @@ function updateSuspenseFallbackChildren( (primaryChildren.pendingProps = primaryChildProps), (workInProgress.deletions = null)) : ((primaryChildren = createWorkInProgress(current, primaryChildProps)), - (primaryChildren.subtreeFlags = current.subtreeFlags & 14680064)); + (primaryChildren.subtreeFlags = current.subtreeFlags & 7340032)); null !== currentFallbackChildFragment ? (fallbackChildren = createWorkInProgress( currentFallbackChildFragment, @@ -5409,7 +5487,6 @@ function attemptEarlyBailoutIfNoScheduledUpdate( return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes); } function unwindWork(workInProgress) { - popTreeContext(workInProgress); switch (workInProgress.tag) { case 1: isContextProvider(workInProgress.type) && popContext(); @@ -5467,13 +5544,6 @@ function safelyDetachRef(current, nearestMountedAncestor) { } else ref.current = null; } -function safelyCallDestroy(current, nearestMountedAncestor, destroy) { - try { - destroy(); - } catch (error) { - captureCommitPhaseError(current, nearestMountedAncestor, error); - } -} var shouldFireAfterActiveInstanceBlur = !1; function commitBeforeMutationEffects(root, firstChild) { for (nextEffect = firstChild; null !== nextEffect; ) @@ -5538,7 +5608,7 @@ function commitBeforeMutationEffects(root, firstChild) { function commitHookEffectListUnmount( flags, finishedWork, - nearestMountedAncestor + nearestMountedAncestor$jscomp$0 ) { var updateQueue = finishedWork.updateQueue; updateQueue = null !== updateQueue ? updateQueue.lastEffect : null; @@ -5548,20 +5618,27 @@ function commitHookEffectListUnmount( if ((effect.tag & flags) === flags) { var destroy = effect.destroy; effect.destroy = void 0; - void 0 !== destroy && - safelyCallDestroy(finishedWork, nearestMountedAncestor, destroy); + if (void 0 !== destroy) { + var current = finishedWork, + nearestMountedAncestor = nearestMountedAncestor$jscomp$0; + try { + destroy(); + } catch (error) { + captureCommitPhaseError(current, nearestMountedAncestor, error); + } + } } effect = effect.next; } while (effect !== updateQueue); } } -function commitHookEffectListMount(flags, 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 & flags) === flags) { + if ((effect.tag & tag) === tag) { var create$80 = effect.create; effect.destroy = create$80(); } @@ -5569,7 +5646,7 @@ function commitHookEffectListMount(flags, finishedWork) { } while (effect !== finishedWork); } } -function commitUnmount(finishedRoot, current, nearestMountedAncestor) { +function commitUnmount(finishedRoot, current, nearestMountedAncestor$jscomp$0) { if (injectedHook && "function" === typeof injectedHook.onCommitFiberUnmount) try { injectedHook.onCommitFiberUnmount(rendererID, current); @@ -5589,17 +5666,24 @@ function commitUnmount(finishedRoot, current, nearestMountedAncestor) { var _effect = effect, destroy = _effect.destroy; _effect = _effect.tag; - void 0 !== destroy && - (0 !== (_effect & 2) - ? safelyCallDestroy(current, nearestMountedAncestor, destroy) - : 0 !== (_effect & 4) && - safelyCallDestroy(current, nearestMountedAncestor, destroy)); + if ( + void 0 !== destroy && + (0 !== (_effect & 2) || 0 !== (_effect & 4)) + ) { + _effect = current; + var nearestMountedAncestor = nearestMountedAncestor$jscomp$0; + try { + destroy(); + } catch (error) { + captureCommitPhaseError(_effect, nearestMountedAncestor, error); + } + } effect = effect.next; } while (effect !== finishedRoot); } break; case 1: - safelyDetachRef(current, nearestMountedAncestor); + safelyDetachRef(current, nearestMountedAncestor$jscomp$0); finishedRoot = current.stateNode; if ("function" === typeof finishedRoot.componentWillUnmount) try { @@ -5607,14 +5691,22 @@ function commitUnmount(finishedRoot, current, nearestMountedAncestor) { (finishedRoot.state = current.memoizedState), finishedRoot.componentWillUnmount(); } catch (error) { - captureCommitPhaseError(current, nearestMountedAncestor, error); + captureCommitPhaseError( + current, + nearestMountedAncestor$jscomp$0, + error + ); } break; case 5: - safelyDetachRef(current, nearestMountedAncestor); + safelyDetachRef(current, nearestMountedAncestor$jscomp$0); break; case 4: - unmountHostComponents(finishedRoot, current, nearestMountedAncestor); + unmountHostComponents( + finishedRoot, + current, + nearestMountedAncestor$jscomp$0 + ); } } function detachFiberAfterEffects(fiber) { @@ -6248,8 +6340,7 @@ var ceil = Math.ceil, workInProgressRootExitStatus = 0, workInProgressRootFatalError = null, workInProgressRootSkippedLanes = 0, - workInProgressRootInterleavedUpdatedLanes = 0, - workInProgressRootRenderPhaseUpdatedLanes = 0, + workInProgressRootUpdatedLanes = 0, workInProgressRootPingedLanes = 0, globalMostRecentFallbackTime = 0, workInProgressRootRenderTargetTime = Infinity, @@ -6296,19 +6387,16 @@ function scheduleUpdateOnFiber(fiber, lane, eventTime) { var root = markUpdateLaneFromFiberToRoot(fiber, lane); if (null === root) return null; markRootUpdated(root, lane, eventTime); - 0 !== (executionContext & 2) && root === workInProgressRoot - ? (workInProgressRootRenderPhaseUpdatedLanes |= lane) - : (root === workInProgressRoot && - (0 === (executionContext & 2) && - (workInProgressRootInterleavedUpdatedLanes |= lane), - 4 === workInProgressRootExitStatus && - markRootSuspended$1(root, workInProgressRootRenderLanes)), - ensureRootIsScheduled(root, eventTime), - 1 === lane && - 0 === executionContext && - 0 === (fiber.mode & 1) && - ((workInProgressRootRenderTargetTime = now() + 500), - includesLegacySyncCallbacks && flushSyncCallbacks())); + root === workInProgressRoot && + (0 === (executionContext & 2) && (workInProgressRootUpdatedLanes |= lane), + 4 === workInProgressRootExitStatus && + markRootSuspended$1(root, workInProgressRootRenderLanes)); + ensureRootIsScheduled(root, eventTime); + 1 === lane && + 0 === executionContext && + 0 === (fiber.mode & 1) && + ((workInProgressRootRenderTargetTime = now() + 500), + includesLegacySyncCallbacks && flushSyncCallbacks()); return root; } function markUpdateLaneFromFiberToRoot(sourceFiber, lane) { @@ -6555,15 +6643,9 @@ function recoverFromConcurrentError(root, errorRetryLanes) { var prevExecutionContext = executionContext; executionContext |= 8; root.isDehydrated && (root.isDehydrated = !1); - for ( - var exitStatus, i = 0; - 50 > i && - ((exitStatus = renderRootSync(root, errorRetryLanes)), - 2 === exitStatus && 0 !== workInProgressRootRenderPhaseUpdatedLanes); - i++ - ); + root = renderRootSync(root, errorRetryLanes); executionContext = prevExecutionContext; - return exitStatus; + return root; } function isRenderConsistentWithExternalStores(finishedWork) { for (var node = finishedWork; ; ) { @@ -6601,7 +6683,7 @@ function isRenderConsistentWithExternalStores(finishedWork) { } function markRootSuspended$1(root, suspendedLanes) { suspendedLanes &= ~workInProgressRootPingedLanes; - suspendedLanes &= ~workInProgressRootInterleavedUpdatedLanes; + suspendedLanes &= ~workInProgressRootUpdatedLanes; root.suspendedLanes |= suspendedLanes; root.pingedLanes &= ~suspendedLanes; for (root = root.expirationTimes; 0 < suspendedLanes; ) { @@ -6619,10 +6701,13 @@ function performSyncWorkOnRoot(root) { if (0 === (lanes & 1)) return ensureRootIsScheduled(root, now()), null; var exitStatus = renderRootSync(root, lanes); if (0 !== root.tag && 2 === exitStatus) { + var prevExecutionContext = executionContext; + executionContext |= 8; + root.isDehydrated && (root.isDehydrated = !1); var errorRetryLanes = getLanesToRetrySynchronouslyOnError(root); 0 !== errorRetryLanes && - ((lanes = errorRetryLanes), - (exitStatus = recoverFromConcurrentError(root, errorRetryLanes))); + ((lanes = errorRetryLanes), (exitStatus = renderRootSync(root, lanes))); + executionContext = prevExecutionContext; } if (1 === exitStatus) throw ((exitStatus = workInProgressRootFatalError), @@ -6649,7 +6734,6 @@ function prepareFreshStack(root, lanes) { if (null !== workInProgress) for (timeoutHandle = workInProgress.return; null !== timeoutHandle; ) { var interruptedWork = timeoutHandle; - popTreeContext(interruptedWork); switch (interruptedWork.tag) { case 1: interruptedWork = interruptedWork.type.childContextTypes; @@ -6689,7 +6773,7 @@ function prepareFreshStack(root, lanes) { workInProgressRootRenderLanes = subtreeRenderLanes = lanes; workInProgressRootExitStatus = 0; workInProgressRootFatalError = null; - workInProgressRootPingedLanes = workInProgressRootRenderPhaseUpdatedLanes = workInProgressRootInterleavedUpdatedLanes = workInProgressRootSkippedLanes = 0; + workInProgressRootPingedLanes = workInProgressRootUpdatedLanes = workInProgressRootSkippedLanes = 0; if (null !== interleavedQueues) { for (root = 0; root < interleavedQueues.length; root++) if ( @@ -7791,7 +7875,7 @@ function createWorkInProgress(current, pendingProps) { (workInProgress.flags = 0), (workInProgress.subtreeFlags = 0), (workInProgress.deletions = null)); - workInProgress.flags = current.flags & 14680064; + workInProgress.flags = current.flags & 7340032; workInProgress.childLanes = current.childLanes; workInProgress.lanes = current.lanes; workInProgress.child = current.child; @@ -8147,10 +8231,10 @@ batchedUpdatesImpl = function(fn, a) { } }; var roots = new Map(), - devToolsConfig$jscomp$inline_952 = { + devToolsConfig$jscomp$inline_976 = { findFiberByHostInstance: getInstanceFromTag, bundleType: 0, - version: "18.0.0-3fcd81dd1-20211102", + version: "18.0.0-afcb9cdc9-20211008", rendererPackageName: "react-native-renderer", rendererConfig: { getInspectorDataForViewTag: function() { @@ -8165,11 +8249,11 @@ var roots = new Map(), }.bind(null, findNodeHandle) } }; -var internals$jscomp$inline_1211 = { - bundleType: devToolsConfig$jscomp$inline_952.bundleType, - version: devToolsConfig$jscomp$inline_952.version, - rendererPackageName: devToolsConfig$jscomp$inline_952.rendererPackageName, - rendererConfig: devToolsConfig$jscomp$inline_952.rendererConfig, +var internals$jscomp$inline_1240 = { + bundleType: devToolsConfig$jscomp$inline_976.bundleType, + version: devToolsConfig$jscomp$inline_976.version, + rendererPackageName: devToolsConfig$jscomp$inline_976.rendererPackageName, + rendererConfig: devToolsConfig$jscomp$inline_976.rendererConfig, overrideHookState: null, overrideHookStateDeletePath: null, overrideHookStateRenamePath: null, @@ -8185,26 +8269,26 @@ var internals$jscomp$inline_1211 = { return null === fiber ? null : fiber.stateNode; }, findFiberByHostInstance: - devToolsConfig$jscomp$inline_952.findFiberByHostInstance || + devToolsConfig$jscomp$inline_976.findFiberByHostInstance || emptyFindFiberByHostInstance, findHostInstancesForRefresh: null, scheduleRefresh: null, scheduleRoot: null, setRefreshHandler: null, getCurrentFiber: null, - reconcilerVersion: "18.0.0-3fcd81dd1-20211102" + reconcilerVersion: "18.0.0-afcb9cdc9-20211008" }; if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) { - var hook$jscomp$inline_1212 = __REACT_DEVTOOLS_GLOBAL_HOOK__; + var hook$jscomp$inline_1241 = __REACT_DEVTOOLS_GLOBAL_HOOK__; if ( - !hook$jscomp$inline_1212.isDisabled && - hook$jscomp$inline_1212.supportsFiber + !hook$jscomp$inline_1241.isDisabled && + hook$jscomp$inline_1241.supportsFiber ) try { - (rendererID = hook$jscomp$inline_1212.inject( - internals$jscomp$inline_1211 + (rendererID = hook$jscomp$inline_1241.inject( + internals$jscomp$inline_1240 )), - (injectedHook = hook$jscomp$inline_1212); + (injectedHook = hook$jscomp$inline_1241); } catch (err) {} } exports.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = { diff --git a/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.fb.js b/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.fb.js index 589d02c3b16..8916f57175f 100644 --- a/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.fb.js +++ b/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.fb.js @@ -7,29 +7,10 @@ * @noflow * @nolint * @preventMunge - * @generated SignedSource<<3965891898f053c31929e4bcdfda0c74>> + * @generated SignedSource<> */ - - /** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -/* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */ - -// Don't require this file directly; it's embedded by Rollup during build. - -if ( - typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' && - typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart === - 'function' -) { - __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStart(new Error()); -} - "use strict"; +"use strict"; require("react-native/Libraries/ReactPrivate/ReactNativePrivateInitializeCore"); var ReactNativePrivateInterface = require("react-native/Libraries/ReactPrivate/ReactNativePrivateInterface"), React = require("react"); @@ -945,7 +926,7 @@ eventPluginOrder = Array.prototype.slice.call([ "ReactNativeBridgeEventPlugin" ]); recomputePluginOrdering(); -var injectedNamesToPlugins$jscomp$inline_244 = { +var injectedNamesToPlugins$jscomp$inline_230 = { ResponderEventPlugin: ResponderEventPlugin, ReactNativeBridgeEventPlugin: { eventTypes: {}, @@ -980,33 +961,33 @@ var injectedNamesToPlugins$jscomp$inline_244 = { } } }, - isOrderingDirty$jscomp$inline_245 = !1, - pluginName$jscomp$inline_246; -for (pluginName$jscomp$inline_246 in injectedNamesToPlugins$jscomp$inline_244) + isOrderingDirty$jscomp$inline_231 = !1, + pluginName$jscomp$inline_232; +for (pluginName$jscomp$inline_232 in injectedNamesToPlugins$jscomp$inline_230) if ( - injectedNamesToPlugins$jscomp$inline_244.hasOwnProperty( - pluginName$jscomp$inline_246 + injectedNamesToPlugins$jscomp$inline_230.hasOwnProperty( + pluginName$jscomp$inline_232 ) ) { - var pluginModule$jscomp$inline_247 = - injectedNamesToPlugins$jscomp$inline_244[pluginName$jscomp$inline_246]; + var pluginModule$jscomp$inline_233 = + injectedNamesToPlugins$jscomp$inline_230[pluginName$jscomp$inline_232]; if ( - !namesToPlugins.hasOwnProperty(pluginName$jscomp$inline_246) || - namesToPlugins[pluginName$jscomp$inline_246] !== - pluginModule$jscomp$inline_247 + !namesToPlugins.hasOwnProperty(pluginName$jscomp$inline_232) || + namesToPlugins[pluginName$jscomp$inline_232] !== + pluginModule$jscomp$inline_233 ) { - if (namesToPlugins[pluginName$jscomp$inline_246]) + if (namesToPlugins[pluginName$jscomp$inline_232]) throw Error( "EventPluginRegistry: Cannot inject two different event plugins using the same name, `" + - (pluginName$jscomp$inline_246 + "`.") + (pluginName$jscomp$inline_232 + "`.") ); namesToPlugins[ - pluginName$jscomp$inline_246 - ] = pluginModule$jscomp$inline_247; - isOrderingDirty$jscomp$inline_245 = !0; + pluginName$jscomp$inline_232 + ] = pluginModule$jscomp$inline_233; + isOrderingDirty$jscomp$inline_231 = !0; } } -isOrderingDirty$jscomp$inline_245 && recomputePluginOrdering(); +isOrderingDirty$jscomp$inline_231 && recomputePluginOrdering(); var instanceCache = new Map(), instanceProps = new Map(); function getInstanceFromTag(tag) { @@ -1734,27 +1715,6 @@ function onCommitRoot(root, eventPriority) { ); } catch (err) {} } -var clz32 = Math.clz32 ? Math.clz32 : clz32Fallback, - log = Math.log, - LN2 = Math.LN2; -function clz32Fallback(x) { - x >>>= 0; - return 0 === x ? 32 : (31 - ((log(x) / LN2) | 0)) | 0; -} -function getLabelForLane(lane) { - if (lane & 1) return "Sync"; - if (lane & 2) return "InputContinuousHydration"; - if (lane & 4) return "InputContinuous"; - if (lane & 8) return "DefaultHydration"; - if (lane & 16) return "Default"; - if (lane & 32) return "TransitionHydration"; - if (lane & 4194240) return "Transition"; - if (lane & 130023424) return "Retry"; - if (lane & 134217728) return "SelectiveHydration"; - if (lane & 268435456) return "IdleHydration"; - if (lane & 536870912) return "Idle"; - if (lane & 1073741824) return "Offscreen"; -} var nextTransitionLane = 64, nextRetryLane = 4194304; function getHighestPriorityLanes(lanes) { @@ -1968,6 +1928,12 @@ function movePendingFibersToMemoized(root, lanes) { lanes &= ~root; } } +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 currentUpdatePriority = 0; function lanesToEventPriority(lanes) { lanes &= -lanes; @@ -2156,112 +2122,6 @@ function flushSyncCallbacks() { } return null; } -var supportsUserTimingV3 = !1; -if ( - "undefined" !== typeof performance && - "function" === typeof performance.mark && - "function" === typeof performance.clearMarks -) { - var markOptions = {}; - Object.defineProperty(markOptions, "startTime", { - get: function() { - supportsUserTimingV3 = !0; - return 0; - }, - set: function() {} - }); - try { - performance.mark("__v3", markOptions); - } catch (error) { - } finally { - performance.clearMarks("__v3"); - } -} -var laneLabels = []; -function getLaneLabels() { - if (0 === laneLabels.length) - for (var lane = 1, index$13 = 0; 31 > index$13; index$13++) - laneLabels.push(getLabelForLane(lane)), (lane *= 2); - return laneLabels; -} -function markAndClear(name) { - performance.mark(name); - performance.clearMarks(name); -} -function markInternalModuleRanges() { - if ( - "undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ && - "function" === typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.getInternalModuleRanges - ) - for ( - var ranges = __REACT_DEVTOOLS_GLOBAL_HOOK__.getInternalModuleRanges(), - i = 0; - i < ranges.length; - i++ - ) { - var _ranges$i = ranges[i], - stopStackFrame = _ranges$i[1]; - markAndClear("--react-internal-module-start-" + _ranges$i[0]); - markAndClear("--react-internal-module-stop-" + stopStackFrame); - } -} -function markComponentRenderStarted(fiber) { - supportsUserTimingV3 && - ((fiber = getComponentNameFromFiber(fiber) || "Unknown"), - markAndClear("--component-render-start-" + fiber)); -} -function markComponentRenderStopped() { - supportsUserTimingV3 && markAndClear("--component-render-stop"); -} -function markComponentLayoutEffectUnmountStarted(fiber) { - supportsUserTimingV3 && - ((fiber = getComponentNameFromFiber(fiber) || "Unknown"), - markAndClear("--component-layout-effect-unmount-start-" + fiber)); -} -function markComponentLayoutEffectUnmountStopped() { - supportsUserTimingV3 && - markAndClear("--component-layout-effect-unmount-stop"); -} -var wakeableIDs = new ("function" === typeof WeakMap ? WeakMap : Map)(), - wakeableID = 0; -function getWakeableID(wakeable) { - wakeableIDs.has(wakeable) || wakeableIDs.set(wakeable, wakeableID++); - return wakeableIDs.get(wakeable); -} -function markComponentSuspended(fiber, wakeable, lanes) { - if (supportsUserTimingV3) { - var eventType = wakeableIDs.has(wakeable) ? "resuspend" : "suspend", - id = getWakeableID(wakeable), - componentName = getComponentNameFromFiber(fiber) || "Unknown"; - markAndClear( - "--suspense-" + - eventType + - "-" + - id + - "-" + - componentName + - "-" + - (null === fiber.alternate ? "mount" : "update") + - "-" + - lanes + - "-" + - (wakeable.displayName || "") - ); - wakeable.then( - function() { - return markAndClear("--suspense-resolved-" + id + "-" + componentName); - }, - function() { - return markAndClear("--suspense-rejected-" + id + "-" + componentName); - } - ); - } -} -function markStateUpdateScheduled(fiber, lane) { - supportsUserTimingV3 && - ((fiber = getComponentNameFromFiber(fiber) || "Unknown"), - markAndClear("--schedule-state-update-" + lane + "-" + fiber)); -} var ReactCurrentBatchConfig = ReactSharedInternals.ReactCurrentBatchConfig; function shallowEqual(objA, objB) { if (objectIs(objA, objB)) return !0; @@ -2275,14 +2135,12 @@ function shallowEqual(objA, objB) { var keysA = Object.keys(objA), keysB = Object.keys(objB); if (keysA.length !== keysB.length) return !1; - for (keysB = 0; keysB < keysA.length; keysB++) { - var currentKey = keysA[keysB]; + for (keysB = 0; keysB < keysA.length; keysB++) if ( - !hasOwnProperty.call(objB, currentKey) || - !objectIs(objA[currentKey], objB[currentKey]) + !hasOwnProperty.call(objB, keysA[keysB]) || + !objectIs(objA[keysA[keysB]], objB[keysA[keysB]]) ) return !1; - } return !0; } function describeFiber(fiber) { @@ -2677,7 +2535,6 @@ var classComponentUpdater = { enqueueUpdate(inst, update); payload = scheduleUpdateOnFiber(inst, lane, eventTime); null !== payload && entangleTransitions(payload, inst, lane); - markStateUpdateScheduled(inst, lane); }, enqueueReplaceState: function(inst, payload, callback) { inst = inst._reactInternals; @@ -2690,21 +2547,17 @@ var classComponentUpdater = { enqueueUpdate(inst, update); payload = scheduleUpdateOnFiber(inst, lane, eventTime); null !== payload && entangleTransitions(payload, inst, lane); - markStateUpdateScheduled(inst, lane); }, enqueueForceUpdate: function(inst, callback) { - var fiber = inst._reactInternals, - eventTime = requestEventTime(); - inst = requestUpdateLane(fiber); - var update = createUpdate(eventTime, inst); + inst = inst._reactInternals; + var eventTime = requestEventTime(), + lane = requestUpdateLane(inst), + update = createUpdate(eventTime, lane); update.tag = 2; void 0 !== callback && null !== callback && (update.callback = callback); - enqueueUpdate(fiber, update); - callback = scheduleUpdateOnFiber(fiber, inst, eventTime); - null !== callback && entangleTransitions(callback, fiber, inst); - supportsUserTimingV3 && - ((callback = getComponentNameFromFiber(fiber) || "Unknown"), - markAndClear("--schedule-forced-update-" + inst + "-" + callback)); + enqueueUpdate(inst, update); + callback = scheduleUpdateOnFiber(inst, lane, eventTime); + null !== callback && entangleTransitions(callback, inst, lane); } }; function checkShouldComponentUpdate( @@ -2797,26 +2650,6 @@ function mountClassInstance(workInProgress, ctor, newProps, renderLanes) { "function" === typeof instance.componentDidMount && (workInProgress.flags |= 4); } -var forkStack = [], - forkStackIndex = 0, - treeForkProvider = null, - idStack = [], - idStackIndex = 0, - treeContextProvider = null; -function popTreeContext(workInProgress) { - for (; workInProgress === treeForkProvider; ) - (treeForkProvider = forkStack[--forkStackIndex]), - (forkStack[forkStackIndex] = null), - --forkStackIndex, - (forkStack[forkStackIndex] = null); - for (; workInProgress === treeContextProvider; ) - (treeContextProvider = idStack[--idStackIndex]), - (idStack[idStackIndex] = null), - --idStackIndex, - (idStack[idStackIndex] = null), - --idStackIndex, - (idStack[idStackIndex] = null); -} function coerceRef(returnFiber, current, element) { returnFiber = element.ref; if ( @@ -2911,8 +2744,7 @@ function ChildReconciler(shouldTrackSideEffects) { } function placeChild(newFiber, lastPlacedIndex, newIndex) { newFiber.index = newIndex; - if (!shouldTrackSideEffects) - return (newFiber.flags |= 1048576), lastPlacedIndex; + if (!shouldTrackSideEffects) return lastPlacedIndex; newIndex = newFiber.alternate; if (null !== newIndex) return ( @@ -3516,8 +3348,7 @@ var ReactCurrentDispatcher$1 = ReactSharedInternals.ReactCurrentDispatcher, currentHook = null, workInProgressHook = null, didScheduleRenderPhaseUpdate = !1, - didScheduleRenderPhaseUpdateDuringThisPass = !1, - globalClientIdCounter = 0; + didScheduleRenderPhaseUpdateDuringThisPass = !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://reactjs.org/link/invalid-hook-call for tips about how to debug and fix this problem." @@ -3720,7 +3551,104 @@ function rerenderReducer(reducer) { } return [newState, dispatch]; } -function updateMutableSource() {} +function readFromUnsubscribedMutableSource(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 may be 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 readFromUnsubscribedMutableSource(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); + objectIs(version, maybeNewVersion) || + ((maybeNewVersion = getSnapshot(source._source)), + objectIs(snapshot, maybeNewVersion) || + (setSnapshot(maybeNewVersion), + (maybeNewVersion = requestUpdateLane(fiber)), + (root.mutableReadLanes |= maybeNewVersion & root.pendingLanes)), + markRootEntangled(root, root.mutableReadLanes)); + }, + [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); + 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, + interleaved: null, + lanes: 0, + dispatch: null, + lastRenderedReducer: basicStateReducer, + lastRenderedState: snapshot + }), + (hook.dispatch = setSnapshot = dispatchSetState.bind( + null, + currentlyRenderingFiber$1, + hook + )), + (_dispatcher$useState.queue = hook), + (_dispatcher$useState.baseQueue = null), + (snapshot = readFromUnsubscribedMutableSource(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 mountSyncExternalStore(subscribe, getSnapshot) { var fiber = currentlyRenderingFiber$1, hook = mountWorkInProgressHook(); @@ -3774,7 +3702,7 @@ function checkIfSnapshotChanged(inst) { try { var nextValue = latestGetSnapshot(); return !objectIs(inst, nextValue); - } catch (error$33) { + } catch (error) { return !0; } } @@ -3843,7 +3771,7 @@ function updateEffectImpl(fiberFlags, hookFlags, create, deps) { hook.memoizedState = pushEffect(1 | hookFlags, create, destroy, deps); } function mountEffect(create, deps) { - return mountEffectImpl(8390656, 8, create, deps); + return mountEffectImpl(4196352, 8, create, deps); } function updateEffect(create, deps) { return updateEffectImpl(2048, 8, create, deps); @@ -3923,9 +3851,6 @@ function startTransition(setPending, callback) { (ReactCurrentBatchConfig$1.transition = prevTransition); } } -function updateId() { - return updateWorkInProgressHook().memoizedState; -} function dispatchReducerAction(fiber, queue, action) { var lane = requestUpdateLane(fiber); action = { @@ -3939,9 +3864,8 @@ function dispatchReducerAction(fiber, queue, action) { ? enqueueRenderPhaseUpdate(queue, action) : (enqueueUpdate$1(fiber, queue, action), (action = requestEventTime()), - (action = scheduleUpdateOnFiber(fiber, lane, action)), - null !== action && entangleTransitionUpdate(action, queue, lane)); - markStateUpdateScheduled(fiber, lane); + (fiber = scheduleUpdateOnFiber(fiber, lane, action)), + null !== fiber && entangleTransitionUpdate(fiber, queue, lane)); } function dispatchSetState(fiber, queue, action) { var lane = requestUpdateLane(fiber), @@ -3967,14 +3891,13 @@ function dispatchSetState(fiber, queue, action) { update.hasEagerState = !0; update.eagerState = eagerState; if (objectIs(eagerState, currentState)) return; - } catch (error$35) { + } catch (error) { } finally { } action = requestEventTime(); - action = scheduleUpdateOnFiber(fiber, lane, action); - null !== action && entangleTransitionUpdate(action, queue, lane); + fiber = scheduleUpdateOnFiber(fiber, lane, action); + null !== fiber && entangleTransitionUpdate(fiber, queue, lane); } - markStateUpdateScheduled(fiber, lane); } function isRenderPhaseUpdate(fiber) { var alternate = fiber.alternate; @@ -4035,7 +3958,7 @@ var ContextOnlyDispatcher = { useTransition: throwInvalidHookError, useMutableSource: throwInvalidHookError, useSyncExternalStore: throwInvalidHookError, - useId: throwInvalidHookError, + useOpaqueIdentifier: throwInvalidHookError, unstable_isNewReconciler: !1 }, HooksDispatcherOnMount = { @@ -4123,12 +4046,18 @@ var ContextOnlyDispatcher = { mountWorkInProgressHook().memoizedState = _mountState2; return [isPending, _mountState2]; }, - useMutableSource: function() {}, - useSyncExternalStore: mountSyncExternalStore, - useId: function() { + useMutableSource: function(source, getSnapshot, subscribe) { var hook = mountWorkInProgressHook(); - var id = "r:" + (globalClientIdCounter++).toString(32); - return (hook.memoizedState = id); + hook.memoizedState = { + refs: { getSnapshot: getSnapshot, setSnapshot: null }, + source: source, + subscribe: subscribe + }; + return useMutableSource(hook, source, getSnapshot, subscribe); + }, + useSyncExternalStore: mountSyncExternalStore, + useOpaqueIdentifier: function() { + throw Error("Not yet implemented"); }, unstable_isNewReconciler: !1 }, @@ -4211,7 +4140,9 @@ var ContextOnlyDispatcher = { } return nextSnapshot; }, - useId: updateId, + useOpaqueIdentifier: function() { + return updateReducer(basicStateReducer)[0]; + }, unstable_isNewReconciler: !1 }, HooksDispatcherOnRerender = { @@ -4254,7 +4185,9 @@ var ContextOnlyDispatcher = { }, useMutableSource: updateMutableSource, useSyncExternalStore: mountSyncExternalStore, - useId: updateId, + useOpaqueIdentifier: function() { + return rerenderReducer(basicStateReducer)[0]; + }, unstable_isNewReconciler: !1 }, now$1 = Scheduler.unstable_now, @@ -4344,7 +4277,7 @@ function logCapturedError(boundary, errorInfo) { }); } } -var PossiblyWeakMap$1 = "function" === typeof WeakMap ? WeakMap : Map; +var PossiblyWeakMap = "function" === typeof WeakMap ? WeakMap : Map; function createRootErrorUpdate(fiber, errorInfo, lane) { lane = createUpdate(-1, lane); lane.tag = 3; @@ -4361,9 +4294,9 @@ function createClassErrorUpdate(fiber, errorInfo, lane) { lane.tag = 3; var getDerivedStateFromError = fiber.type.getDerivedStateFromError; if ("function" === typeof getDerivedStateFromError) { - var error$37 = errorInfo.value; + var error = errorInfo.value; lane.payload = function() { - return getDerivedStateFromError(error$37); + return getDerivedStateFromError(error); }; lane.callback = function() { logCapturedError(fiber, errorInfo); @@ -4427,14 +4360,14 @@ function cutOffTailIfNeeded(renderState, hasRenderedATailFallback) { break; case "collapsed": lastTailNode = renderState.tail; - for (var lastTailNode$42 = null; null !== lastTailNode; ) - null !== lastTailNode.alternate && (lastTailNode$42 = lastTailNode), + for (var lastTailNode$37 = null; null !== lastTailNode; ) + null !== lastTailNode.alternate && (lastTailNode$37 = lastTailNode), (lastTailNode = lastTailNode.sibling); - null === lastTailNode$42 + null === lastTailNode$37 ? hasRenderedATailFallback || null === renderState.tail ? (renderState.tail = null) : (renderState.tail.sibling = null) - : (lastTailNode$42.sibling = null); + : (lastTailNode$37.sibling = null); } } function bubbleProperties(completedWork) { @@ -4446,60 +4379,59 @@ function bubbleProperties(completedWork) { if (didBailout) if (0 !== (completedWork.mode & 2)) { for ( - var treeBaseDuration$44 = completedWork.selfBaseDuration, - child$45 = completedWork.child; - null !== child$45; + var treeBaseDuration$39 = completedWork.selfBaseDuration, + child$40 = completedWork.child; + null !== child$40; ) - (newChildLanes |= child$45.lanes | child$45.childLanes), - (subtreeFlags |= child$45.subtreeFlags & 14680064), - (subtreeFlags |= child$45.flags & 14680064), - (treeBaseDuration$44 += child$45.treeBaseDuration), - (child$45 = child$45.sibling); - completedWork.treeBaseDuration = treeBaseDuration$44; + (newChildLanes |= child$40.lanes | child$40.childLanes), + (subtreeFlags |= child$40.subtreeFlags & 7340032), + (subtreeFlags |= child$40.flags & 7340032), + (treeBaseDuration$39 += child$40.treeBaseDuration), + (child$40 = child$40.sibling); + completedWork.treeBaseDuration = treeBaseDuration$39; } else for ( - treeBaseDuration$44 = completedWork.child; - null !== treeBaseDuration$44; + treeBaseDuration$39 = completedWork.child; + null !== treeBaseDuration$39; ) (newChildLanes |= - treeBaseDuration$44.lanes | treeBaseDuration$44.childLanes), - (subtreeFlags |= treeBaseDuration$44.subtreeFlags & 14680064), - (subtreeFlags |= treeBaseDuration$44.flags & 14680064), - (treeBaseDuration$44.return = completedWork), - (treeBaseDuration$44 = treeBaseDuration$44.sibling); + treeBaseDuration$39.lanes | treeBaseDuration$39.childLanes), + (subtreeFlags |= treeBaseDuration$39.subtreeFlags & 7340032), + (subtreeFlags |= treeBaseDuration$39.flags & 7340032), + (treeBaseDuration$39.return = completedWork), + (treeBaseDuration$39 = treeBaseDuration$39.sibling); else if (0 !== (completedWork.mode & 2)) { - treeBaseDuration$44 = completedWork.actualDuration; - child$45 = completedWork.selfBaseDuration; + treeBaseDuration$39 = completedWork.actualDuration; + child$40 = completedWork.selfBaseDuration; for (var child = completedWork.child; null !== child; ) (newChildLanes |= child.lanes | child.childLanes), (subtreeFlags |= child.subtreeFlags), (subtreeFlags |= child.flags), - (treeBaseDuration$44 += child.actualDuration), - (child$45 += child.treeBaseDuration), + (treeBaseDuration$39 += child.actualDuration), + (child$40 += child.treeBaseDuration), (child = child.sibling); - completedWork.actualDuration = treeBaseDuration$44; - completedWork.treeBaseDuration = child$45; + completedWork.actualDuration = treeBaseDuration$39; + completedWork.treeBaseDuration = child$40; } else for ( - treeBaseDuration$44 = completedWork.child; - null !== treeBaseDuration$44; + treeBaseDuration$39 = completedWork.child; + null !== treeBaseDuration$39; ) (newChildLanes |= - treeBaseDuration$44.lanes | treeBaseDuration$44.childLanes), - (subtreeFlags |= treeBaseDuration$44.subtreeFlags), - (subtreeFlags |= treeBaseDuration$44.flags), - (treeBaseDuration$44.return = completedWork), - (treeBaseDuration$44 = treeBaseDuration$44.sibling); + treeBaseDuration$39.lanes | treeBaseDuration$39.childLanes), + (subtreeFlags |= treeBaseDuration$39.subtreeFlags), + (subtreeFlags |= treeBaseDuration$39.flags), + (treeBaseDuration$39.return = completedWork), + (treeBaseDuration$39 = treeBaseDuration$39.sibling); completedWork.subtreeFlags |= subtreeFlags; completedWork.childLanes = newChildLanes; return didBailout; } function completeWork(current, workInProgress, renderLanes) { var newProps = workInProgress.pendingProps; - popTreeContext(workInProgress); switch (workInProgress.tag) { case 2: case 16: @@ -4650,7 +4582,7 @@ function completeWork(current, workInProgress, renderLanes) { workInProgressRootExitStatus = 4; null === workInProgressRoot || (0 === (workInProgressRootSkippedLanes & 268435455) && - 0 === (workInProgressRootInterleavedUpdatedLanes & 268435455)) || + 0 === (workInProgressRootUpdatedLanes & 268435455)) || markRootSuspended$1( workInProgressRoot, workInProgressRootRenderLanes @@ -4710,7 +4642,7 @@ function completeWork(current, workInProgress, renderLanes) { for (newProps = workInProgress.child; null !== newProps; ) (renderLanes = newProps), (updatePayload = current), - (renderLanes.flags &= 14680066), + (renderLanes.flags &= 7340034), (type = renderLanes.alternate), null === type ? ((renderLanes.childLanes = 0), @@ -4857,7 +4789,6 @@ function updateForwardRef( Component = Component.render; var ref = workInProgress.ref; prepareToReadContext(workInProgress, renderLanes); - markComponentRenderStarted(workInProgress); nextProps = renderWithHooks( current, workInProgress, @@ -4866,7 +4797,6 @@ function updateForwardRef( ref, renderLanes ); - markComponentRenderStopped(); if (null !== current && !didReceiveUpdate) return ( (workInProgress.updateQueue = current.updateQueue), @@ -5022,7 +4952,6 @@ function updateFunctionComponent( : contextStackCursor.current; context = getMaskedContext(workInProgress, context); prepareToReadContext(workInProgress, renderLanes); - markComponentRenderStarted(workInProgress); Component = renderWithHooks( current, workInProgress, @@ -5031,7 +4960,6 @@ function updateFunctionComponent( context, renderLanes ); - markComponentRenderStopped(); if (null !== current && !didReceiveUpdate) return ( (workInProgress.updateQueue = current.updateQueue), @@ -5268,10 +5196,7 @@ function finishClassComponent( ) { var nextChildren = null; profilerStartTime = -1; - } else - markComponentRenderStarted(workInProgress), - (nextChildren = shouldUpdate.render()), - markComponentRenderStopped(); + } else nextChildren = shouldUpdate.render(); workInProgress.flags |= 1; null !== current && didCaptureError ? ((didCaptureError = nextChildren), @@ -5304,7 +5229,7 @@ function pushHostRootContext(workInProgress) { pushTopLevelContextObject(workInProgress, root.context, !1); pushHostContainer(workInProgress, root.containerInfo); } -var SUSPENDED_MARKER = { dehydrated: null, treeContext: null, retryLane: 0 }; +var SUSPENDED_MARKER = { dehydrated: null, retryLane: 0 }; function mountSuspenseOffscreenState(renderLanes) { return { baseLanes: renderLanes, cachePool: null }; } @@ -5507,7 +5432,7 @@ function updateSuspenseFallbackChildren( (primaryChildren.treeBaseDuration = current.treeBaseDuration)), (workInProgress.deletions = null)) : ((primaryChildren = createWorkInProgress(current, primaryChildProps)), - (primaryChildren.subtreeFlags = current.subtreeFlags & 14680064)); + (primaryChildren.subtreeFlags = current.subtreeFlags & 7340032)); null !== currentFallbackChildFragment ? (fallbackChildren = createWorkInProgress( currentFallbackChildFragment, @@ -5739,7 +5664,6 @@ function attemptEarlyBailoutIfNoScheduledUpdate( return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes); } function unwindWork(workInProgress) { - popTreeContext(workInProgress); switch (workInProgress.tag) { case 1: isContextProvider(workInProgress.type) && popContext(); @@ -5806,16 +5730,16 @@ function safelyDetachRef(current, nearestMountedAncestor) { recordLayoutEffectDuration(current); } else ref(null); - } catch (error$92) { - captureCommitPhaseError(current, nearestMountedAncestor, error$92); + } catch (error) { + captureCommitPhaseError(current, nearestMountedAncestor, error); } else ref.current = null; } function safelyCallDestroy(current, nearestMountedAncestor, destroy) { try { destroy(); - } catch (error$93) { - captureCommitPhaseError(current, nearestMountedAncestor, error$93); + } catch (error) { + captureCommitPhaseError(current, nearestMountedAncestor, error); } } var shouldFireAfterActiveInstanceBlur = !1; @@ -5864,8 +5788,8 @@ function commitBeforeMutationEffects(root, firstChild) { "This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue." ); } - } catch (error$94) { - captureCommitPhaseError(root, root.return, error$94); + } catch (error) { + captureCommitPhaseError(root, root.return, error); } firstChild = root.sibling; if (null !== firstChild) { @@ -5892,63 +5816,25 @@ function commitHookEffectListUnmount( if ((effect.tag & flags) === flags) { var destroy = effect.destroy; effect.destroy = void 0; - if (void 0 !== destroy) { - if (0 !== (flags & 8)) { - if (supportsUserTimingV3) { - var componentName = - getComponentNameFromFiber(finishedWork) || "Unknown"; - markAndClear( - "--component-passive-effect-unmount-start-" + componentName - ); - } - } else - 0 !== (flags & 4) && - markComponentLayoutEffectUnmountStarted(finishedWork); + void 0 !== destroy && safelyCallDestroy(finishedWork, nearestMountedAncestor, destroy); - 0 !== (flags & 8) - ? supportsUserTimingV3 && - markAndClear("--component-passive-effect-unmount-stop") - : 0 !== (flags & 4) && markComponentLayoutEffectUnmountStopped(); - } } effect = effect.next; } while (effect !== updateQueue); } } -function commitHookEffectListMount(flags, finishedWork) { - var updateQueue = finishedWork.updateQueue; - updateQueue = null !== updateQueue ? updateQueue.lastEffect : null; - if (null !== updateQueue) { - var effect = (updateQueue = updateQueue.next); +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 & flags) === flags) { - if (0 !== (flags & 8)) { - if (supportsUserTimingV3) { - var componentName = - getComponentNameFromFiber(finishedWork) || "Unknown"; - markAndClear( - "--component-passive-effect-mount-start-" + componentName - ); - } - } else - 0 !== (flags & 4) && - supportsUserTimingV3 && - ((componentName = - getComponentNameFromFiber(finishedWork) || "Unknown"), - markAndClear( - "--component-layout-effect-mount-start-" + componentName - )); - componentName = effect.create; - effect.destroy = componentName(); - 0 !== (flags & 8) - ? supportsUserTimingV3 && - markAndClear("--component-passive-effect-mount-stop") - : 0 !== (flags & 4) && - supportsUserTimingV3 && - markAndClear("--component-layout-effect-mount-stop"); + if ((effect.tag & tag) === tag) { + var create$86 = effect.create; + effect.destroy = create$86(); } effect = effect.next; - } while (effect !== updateQueue); + } while (effect !== finishedWork); } } function commitUnmount(finishedRoot, current, nearestMountedAncestor) { @@ -5971,17 +5857,13 @@ function commitUnmount(finishedRoot, current, nearestMountedAncestor) { var _effect = effect, destroy = _effect.destroy; _effect = _effect.tag; - void 0 !== destroy && - (0 !== (_effect & 2) - ? safelyCallDestroy(current, nearestMountedAncestor, destroy) - : 0 !== (_effect & 4) && - (markComponentLayoutEffectUnmountStarted(current), - current.mode & 2 - ? (startLayoutEffectTimer(), - safelyCallDestroy(current, nearestMountedAncestor, destroy), - recordLayoutEffectDuration(current)) - : safelyCallDestroy(current, nearestMountedAncestor, destroy), - markComponentLayoutEffectUnmountStopped())); + void 0 === destroy || + (0 === (_effect & 2) && 0 === (_effect & 4)) || + (current.mode & 2 + ? (startLayoutEffectTimer(), + safelyCallDestroy(current, nearestMountedAncestor, destroy), + recordLayoutEffectDuration(current)) + : safelyCallDestroy(current, nearestMountedAncestor, destroy)); effect = effect.next; } while (effect !== finishedRoot); } @@ -6002,8 +5884,8 @@ function commitUnmount(finishedRoot, current, nearestMountedAncestor) { recordLayoutEffectDuration(current); } else finishedRoot.componentWillUnmount(); - } catch (error$91) { - captureCommitPhaseError(current, nearestMountedAncestor, error$91); + } catch (error) { + captureCommitPhaseError(current, nearestMountedAncestor, error); } break; case 5: @@ -6401,8 +6283,8 @@ function commitMutationEffects(root, firstChild, committedLanes) { var alternate = childToDelete.alternate; null !== alternate && (alternate.return = null); childToDelete.return = null; - } catch (error$102) { - captureCommitPhaseError(childToDelete, firstChild, error$102); + } catch (error) { + captureCommitPhaseError(childToDelete, firstChild, error); } } committedLanes = firstChild.child; @@ -6434,11 +6316,8 @@ function commitMutationEffects(root, firstChild, committedLanes) { switch (firstChild.tag) { case 13: if (null !== firstChild.memoizedState) { - var current$104 = firstChild.alternate; - if ( - null === current$104 || - null === current$104.memoizedState - ) + var current$93 = firstChild.alternate; + if (null === current$93 || null === current$93.memoizedState) globalMostRecentFallbackTime = now(); } break; @@ -6534,8 +6413,8 @@ function commitMutationEffects(root, firstChild, committedLanes) { case 4: commitWork(firstChild.alternate, firstChild); } - } catch (error$103) { - captureCommitPhaseError(firstChild, firstChild.return, error$103); + } catch (error) { + captureCommitPhaseError(firstChild, firstChild.return, error); } committedLanes = firstChild.sibling; if (null !== committedLanes) { @@ -6622,21 +6501,21 @@ function commitLayoutEffects(finishedWork, root, committedLanes) { commitUpdateQueue(committedLanes, updateQueue, instance); break; case 3: - var updateQueue$97 = committedLanes.updateQueue; - if (null !== updateQueue$97) { - var instance$98 = null; + var updateQueue$88 = committedLanes.updateQueue; + if (null !== updateQueue$88) { + var instance$89 = null; if (null !== committedLanes.child) switch (committedLanes.child.tag) { case 5: - instance$98 = committedLanes.child.stateNode; + instance$89 = committedLanes.child.stateNode; break; case 1: - instance$98 = committedLanes.child.stateNode; + instance$89 = committedLanes.child.stateNode; } commitUpdateQueue( committedLanes, - updateQueue$97, - instance$98 + updateQueue$88, + instance$89 ); } break; @@ -6651,7 +6530,7 @@ function commitLayoutEffects(finishedWork, root, committedLanes) { onCommit = _finishedWork$memoize2.onCommit, onRender = _finishedWork$memoize2.onRender, effectDuration = committedLanes.stateNode.effectDuration; - instance$98 = commitTime; + instance$89 = commitTime; current = null === current ? "mount" : "update"; currentUpdateIsNested && (current = "nested-update"); "function" === typeof onRender && @@ -6661,14 +6540,14 @@ function commitLayoutEffects(finishedWork, root, committedLanes) { committedLanes.actualDuration, committedLanes.treeBaseDuration, committedLanes.actualStartTime, - instance$98 + instance$89 ); "function" === typeof onCommit && onCommit( committedLanes.memoizedProps.id, current, effectDuration, - instance$98 + instance$89 ); enqueuePendingPassiveProfilerEffect(committedLanes); var parentFiber = committedLanes.return; @@ -6698,34 +6577,34 @@ function commitLayoutEffects(finishedWork, root, committedLanes) { ); } if (committedLanes.flags & 512) { - instance$98 = void 0; + instance$89 = void 0; current = committedLanes; var ref = current.ref; if (null !== ref) { var instance$jscomp$0 = current.stateNode; switch (current.tag) { case 5: - instance$98 = instance$jscomp$0; + instance$89 = instance$jscomp$0; break; default: - instance$98 = instance$jscomp$0; + instance$89 = instance$jscomp$0; } if ("function" === typeof ref) if (current.mode & 2) try { - startLayoutEffectTimer(), ref(instance$98); + startLayoutEffectTimer(), ref(instance$89); } finally { recordLayoutEffectDuration(current); } - else ref(instance$98); - else ref.current = instance$98; + else ref(instance$89); + else ref.current = instance$89; } } - } catch (error$112) { + } catch (error) { captureCommitPhaseError( committedLanes, committedLanes.return, - error$112 + error ); } } @@ -6733,10 +6612,10 @@ function commitLayoutEffects(finishedWork, root, committedLanes) { nextEffect = null; break; } - instance$98 = committedLanes.sibling; - if (null !== instance$98) { - instance$98.return = committedLanes.return; - nextEffect = instance$98; + instance$89 = committedLanes.sibling; + if (null !== instance$89) { + instance$89.return = committedLanes.return; + nextEffect = instance$89; break; } nextEffect = committedLanes.return; @@ -6756,8 +6635,7 @@ var ceil = Math.ceil, workInProgressRootExitStatus = 0, workInProgressRootFatalError = null, workInProgressRootSkippedLanes = 0, - workInProgressRootInterleavedUpdatedLanes = 0, - workInProgressRootRenderPhaseUpdatedLanes = 0, + workInProgressRootUpdatedLanes = 0, workInProgressRootPingedLanes = 0, globalMostRecentFallbackTime = 0, workInProgressRootRenderTargetTime = Infinity, @@ -6804,21 +6682,18 @@ function scheduleUpdateOnFiber(fiber, lane, eventTime) { )); var root = markUpdateLaneFromFiberToRoot(fiber, lane); if (null === root) return null; + isDevToolsPresent && addFiberToLanesMap(root, fiber, lane); markRootUpdated(root, lane, eventTime); - 0 !== (executionContext & 2) && root === workInProgressRoot - ? (workInProgressRootRenderPhaseUpdatedLanes |= lane) - : (isDevToolsPresent && addFiberToLanesMap(root, fiber, lane), - root === workInProgressRoot && - (0 === (executionContext & 2) && - (workInProgressRootInterleavedUpdatedLanes |= lane), - 4 === workInProgressRootExitStatus && - markRootSuspended$1(root, workInProgressRootRenderLanes)), - ensureRootIsScheduled(root, eventTime), - 1 === lane && - 0 === executionContext && - 0 === (fiber.mode & 1) && - ((workInProgressRootRenderTargetTime = now() + 500), - includesLegacySyncCallbacks && flushSyncCallbacks())); + root === workInProgressRoot && + (0 === (executionContext & 2) && (workInProgressRootUpdatedLanes |= lane), + 4 === workInProgressRootExitStatus && + markRootSuspended$1(root, workInProgressRootRenderLanes)); + ensureRootIsScheduled(root, eventTime); + 1 === lane && + 0 === executionContext && + 0 === (fiber.mode & 1) && + ((workInProgressRootRenderTargetTime = now() + 500), + includesLegacySyncCallbacks && flushSyncCallbacks()); return root; } function markUpdateLaneFromFiberToRoot(sourceFiber, lane) { @@ -6944,7 +6819,6 @@ function performConcurrentWorkOnRoot(root, didTimeout) { workInProgressRootRenderTargetTime = now() + 500; prepareFreshStack(root, didTimeout); } - supportsUserTimingV3 && markAndClear("--render-start-" + didTimeout); do try { workLoopConcurrent(); @@ -6957,10 +6831,8 @@ function performConcurrentWorkOnRoot(root, didTimeout) { ReactCurrentDispatcher$2.current = prevDispatcher; executionContext = prevExecutionContext; null !== workInProgress - ? (supportsUserTimingV3 && markAndClear("--render-yield"), - (didTimeout = 0)) - : (supportsUserTimingV3 && markAndClear("--render-stop"), - (workInProgressRoot = null), + ? (didTimeout = 0) + : ((workInProgressRoot = null), (workInProgressRootRenderLanes = 0), (didTimeout = workInProgressRootExitStatus)); } @@ -7077,15 +6949,9 @@ function recoverFromConcurrentError(root, errorRetryLanes) { var prevExecutionContext = executionContext; executionContext |= 8; root.isDehydrated && (root.isDehydrated = !1); - for ( - var exitStatus, i = 0; - 50 > i && - ((exitStatus = renderRootSync(root, errorRetryLanes)), - 2 === exitStatus && 0 !== workInProgressRootRenderPhaseUpdatedLanes); - i++ - ); + root = renderRootSync(root, errorRetryLanes); executionContext = prevExecutionContext; - return exitStatus; + return root; } function isRenderConsistentWithExternalStores(finishedWork) { for (var node = finishedWork; ; ) { @@ -7101,7 +6967,7 @@ function isRenderConsistentWithExternalStores(finishedWork) { check = check.value; try { if (!objectIs(getSnapshot(), check)) return !1; - } catch (error$117) { + } catch (error) { return !1; } } @@ -7123,7 +6989,7 @@ function isRenderConsistentWithExternalStores(finishedWork) { } function markRootSuspended$1(root, suspendedLanes) { suspendedLanes &= ~workInProgressRootPingedLanes; - suspendedLanes &= ~workInProgressRootInterleavedUpdatedLanes; + suspendedLanes &= ~workInProgressRootUpdatedLanes; root.suspendedLanes |= suspendedLanes; root.pingedLanes &= ~suspendedLanes; for (root = root.expirationTimes; 0 < suspendedLanes; ) { @@ -7143,10 +7009,13 @@ function performSyncWorkOnRoot(root) { if (0 === (lanes & 1)) return ensureRootIsScheduled(root, now()), null; var exitStatus = renderRootSync(root, lanes); if (0 !== root.tag && 2 === exitStatus) { + var prevExecutionContext = executionContext; + executionContext |= 8; + root.isDehydrated && (root.isDehydrated = !1); var errorRetryLanes = getLanesToRetrySynchronouslyOnError(root); 0 !== errorRetryLanes && - ((lanes = errorRetryLanes), - (exitStatus = recoverFromConcurrentError(root, errorRetryLanes))); + ((lanes = errorRetryLanes), (exitStatus = renderRootSync(root, lanes))); + executionContext = prevExecutionContext; } if (1 === exitStatus) throw ((exitStatus = workInProgressRootFatalError), @@ -7173,7 +7042,6 @@ function prepareFreshStack(root, lanes) { if (null !== workInProgress) for (timeoutHandle = workInProgress.return; null !== timeoutHandle; ) { var interruptedWork = timeoutHandle; - popTreeContext(interruptedWork); switch (interruptedWork.tag) { case 1: interruptedWork = interruptedWork.type.childContextTypes; @@ -7213,7 +7081,7 @@ function prepareFreshStack(root, lanes) { workInProgressRootRenderLanes = subtreeRenderLanes = lanes; workInProgressRootExitStatus = 0; workInProgressRootFatalError = null; - workInProgressRootPingedLanes = workInProgressRootRenderPhaseUpdatedLanes = workInProgressRootInterleavedUpdatedLanes = workInProgressRootSkippedLanes = 0; + workInProgressRootPingedLanes = workInProgressRootUpdatedLanes = workInProgressRootSkippedLanes = 0; if (null !== interleavedQueues) { for (root = 0; root < interleavedQueues.length; root++) if ( @@ -7234,7 +7102,7 @@ function prepareFreshStack(root, lanes) { interleavedQueues = null; } } -function handleError(root, thrownValue$jscomp$0) { +function handleError(root$jscomp$0, thrownValue) { do { var erroredWork = workInProgress; try { @@ -7258,54 +7126,27 @@ function handleError(root, thrownValue$jscomp$0) { ReactCurrentOwner$2.current = null; if (null === erroredWork || null === erroredWork.return) { workInProgressRootExitStatus = 1; - workInProgressRootFatalError = thrownValue$jscomp$0; + workInProgressRootFatalError = thrownValue; workInProgress = null; break; } erroredWork.mode & 2 && stopProfilerTimerIfRunningAndRecordDelta(erroredWork, !0); - markComponentRenderStopped(); - if ( - null !== thrownValue$jscomp$0 && - "object" === typeof thrownValue$jscomp$0 && - "function" === typeof thrownValue$jscomp$0.then - ) - markComponentSuspended( - erroredWork, - thrownValue$jscomp$0, - workInProgressRootRenderLanes - ); - else { - var fiber = erroredWork, - thrownValue = thrownValue$jscomp$0; - if (supportsUserTimingV3) { - var componentName = getComponentNameFromFiber(fiber) || "Unknown", - phase = null === fiber.alternate ? "mount" : "update"; - fiber = ""; - null !== thrownValue && - "object" === typeof thrownValue && - "string" === typeof thrownValue.message - ? (fiber = thrownValue.message) - : "string" === typeof thrownValue && (fiber = thrownValue); - markAndClear("--error-" + componentName + "-" + phase + "-" + fiber); - } - } a: { - thrownValue = root; - var returnFiber = erroredWork.return, + var root = root$jscomp$0, + returnFiber = erroredWork.return, sourceFiber = erroredWork, - value = thrownValue$jscomp$0; - thrownValue$jscomp$0 = workInProgressRootRenderLanes; + value = thrownValue; + thrownValue = workInProgressRootRenderLanes; sourceFiber.flags |= 32768; - isDevToolsPresent && - restorePendingUpdaters(thrownValue, thrownValue$jscomp$0); + isDevToolsPresent && restorePendingUpdaters(root, thrownValue); if ( null !== value && "object" === typeof value && "function" === typeof value.then ) { - fiber = value; - var sourceFiber$jscomp$0 = sourceFiber, + var wakeable = value, + sourceFiber$jscomp$0 = sourceFiber, tag = sourceFiber$jscomp$0.tag; if ( 0 === (sourceFiber$jscomp$0.mode & 1) && @@ -7323,7 +7164,7 @@ function handleError(root, thrownValue$jscomp$0) { b: { sourceFiber$jscomp$0 = returnFiber; var sourceFiber$jscomp$1 = sourceFiber, - rootRenderLanes = thrownValue$jscomp$0, + rootRenderLanes = thrownValue, hasInvisibleParentBoundary = 0 !== (suspenseStackCursor.current & 1), node = sourceFiber$jscomp$0; @@ -7375,33 +7216,32 @@ function handleError(root, thrownValue$jscomp$0) { value = void 0; sourceFiber = suspenseBoundary; if (sourceFiber.mode & 1) { - var pingCache = thrownValue.pingCache; + var pingCache = root.pingCache; null === pingCache - ? ((pingCache = thrownValue.pingCache = new PossiblyWeakMap$1()), + ? ((pingCache = root.pingCache = new PossiblyWeakMap()), (value = new Set()), - pingCache.set(fiber, value)) - : ((value = pingCache.get(fiber)), + pingCache.set(wakeable, value)) + : ((value = pingCache.get(wakeable)), void 0 === value && - ((value = new Set()), pingCache.set(fiber, value))); - if (!value.has(thrownValue$jscomp$0)) { - value.add(thrownValue$jscomp$0); + ((value = new Set()), pingCache.set(wakeable, value))); + if (!value.has(thrownValue)) { + value.add(thrownValue); var ping = pingSuspendedRoot.bind( null, - thrownValue, - fiber, - thrownValue$jscomp$0 + root, + wakeable, + thrownValue ); - isDevToolsPresent && - restorePendingUpdaters(thrownValue, thrownValue$jscomp$0); - fiber.then(ping, ping); + isDevToolsPresent && restorePendingUpdaters(root, thrownValue); + wakeable.then(ping, ping); } } var wakeables = sourceFiber.updateQueue; if (null === wakeables) { var updateQueue = new Set(); - updateQueue.add(fiber); + updateQueue.add(wakeable); sourceFiber.updateQueue = updateQueue; - } else wakeables.add(fiber); + } else wakeables.add(wakeable); break a; } else value = Error( @@ -7412,51 +7252,51 @@ function handleError(root, thrownValue$jscomp$0) { 4 !== workInProgressRootExitStatus && (workInProgressRootExitStatus = 2); value = createCapturedValue(value, sourceFiber); - thrownValue = returnFiber; + root = returnFiber; do { - switch (thrownValue.tag) { + switch (root.tag) { case 3: - fiber = value; - thrownValue.flags |= 65536; - thrownValue$jscomp$0 &= -thrownValue$jscomp$0; - thrownValue.lanes |= thrownValue$jscomp$0; + wakeable = value; + root.flags |= 65536; + thrownValue &= -thrownValue; + root.lanes |= thrownValue; var update$jscomp$0 = createRootErrorUpdate( - thrownValue, - fiber, - thrownValue$jscomp$0 + root, + wakeable, + thrownValue ); - enqueueCapturedUpdate(thrownValue, update$jscomp$0); + enqueueCapturedUpdate(root, update$jscomp$0); break a; case 1: - fiber = value; - var ctor = thrownValue.type, - instance = thrownValue.stateNode; + wakeable = value; + var ctor = root.type, + instance = root.stateNode; if ( - 0 === (thrownValue.flags & 128) && + 0 === (root.flags & 128) && ("function" === typeof ctor.getDerivedStateFromError || (null !== instance && "function" === typeof instance.componentDidCatch && (null === legacyErrorBoundariesThatAlreadyFailed || !legacyErrorBoundariesThatAlreadyFailed.has(instance)))) ) { - thrownValue.flags |= 65536; - thrownValue$jscomp$0 &= -thrownValue$jscomp$0; - thrownValue.lanes |= thrownValue$jscomp$0; - var update$40 = createClassErrorUpdate( - thrownValue, - fiber, - thrownValue$jscomp$0 + root.flags |= 65536; + thrownValue &= -thrownValue; + root.lanes |= thrownValue; + var update$35 = createClassErrorUpdate( + root, + wakeable, + thrownValue ); - enqueueCapturedUpdate(thrownValue, update$40); + enqueueCapturedUpdate(root, update$35); break a; } } - thrownValue = thrownValue.return; - } while (null !== thrownValue); + root = root.return; + } while (null !== root); } completeUnitOfWork(erroredWork); } catch (yetAnotherThrownValue) { - thrownValue$jscomp$0 = yetAnotherThrownValue; + thrownValue = yetAnotherThrownValue; workInProgress === erroredWork && null !== erroredWork && (workInProgress = erroredWork = erroredWork.return); @@ -7484,7 +7324,6 @@ function renderRootSync(root, lanes) { } prepareFreshStack(root, lanes); } - supportsUserTimingV3 && markAndClear("--render-start-" + lanes); do try { workLoopSync(); @@ -7500,7 +7339,6 @@ function renderRootSync(root, lanes) { throw Error( "Cannot commit an incomplete root. This error is likely caused by a bug in React. Please file an issue." ); - supportsUserTimingV3 && markAndClear("--render-stop"); workInProgressRoot = null; workInProgressRootRenderLanes = 0; return workInProgressRootExitStatus; @@ -7593,15 +7431,7 @@ function commitRootImpl(root, renderPriorityLevel) { throw Error("Should not already be working."); var finishedWork = root.finishedWork, lanes = root.finishedLanes; - supportsUserTimingV3 && - (markAndClear("--commit-start-" + lanes), - markAndClear("--react-version-18.0.0-3fcd81dd1-20211102"), - markAndClear("--profiler-version-1"), - getLaneLabels(), - markAndClear("--react-lane-labels-" + laneLabels.join(",")), - markInternalModuleRanges()); - if (null === finishedWork) - return supportsUserTimingV3 && markAndClear("--commit-stop"), null; + if (null === finishedWork) return null; root.finishedWork = null; root.finishedLanes = 0; if (finishedWork === root.current) @@ -7636,9 +7466,7 @@ function commitRootImpl(root, renderPriorityLevel) { commitTime = now$1(); commitMutationEffects(root, finishedWork, lanes); root.current = finishedWork; - supportsUserTimingV3 && markAndClear("--layout-effects-start-" + lanes); commitLayoutEffects(finishedWork, root, lanes); - supportsUserTimingV3 && markAndClear("--layout-effects-stop"); requestPaint(); executionContext = prevExecutionContext; currentUpdatePriority = previousPriority; @@ -7669,7 +7497,6 @@ function commitRootImpl(root, renderPriorityLevel) { : ((nestedUpdateCount = 0), (rootWithNestedUpdates = root))) : (nestedUpdateCount = 0); flushSyncCallbacks(); - supportsUserTimingV3 && markAndClear("--commit-stop"); return null; } function flushPassiveEffects() { @@ -7684,14 +7511,11 @@ function flushPassiveEffects() { var JSCompiler_inline_result = !1; else { renderPriority = rootWithPendingPassiveEffects; - var lanes = pendingPassiveEffectsLanes; rootWithPendingPassiveEffects = null; pendingPassiveEffectsLanes = 0; if (0 !== (executionContext & 6)) throw Error("Cannot flush passive effects while already rendering."); - supportsUserTimingV3 && - markAndClear("--passive-effects-start-" + lanes); - lanes = executionContext; + var prevExecutionContext = executionContext; executionContext |= 4; for (nextEffect = renderPriority.current; null !== nextEffect; ) { var fiber = nextEffect, @@ -7801,12 +7625,8 @@ function flushPassiveEffects() { } } else commitHookEffectListMount(9, fiberToDelete); } - } catch (error$113) { - captureCommitPhaseError( - deletions, - deletions.return, - error$113 - ); + } catch (error) { + captureCommitPhaseError(deletions, deletions.return, error); } if (deletions === child) { nextEffect = null; @@ -7858,8 +7678,7 @@ function flushPassiveEffects() { } } } - supportsUserTimingV3 && markAndClear("--passive-effects-stop"); - executionContext = lanes; + executionContext = prevExecutionContext; flushSyncCallbacks(); if ( injectedHook && @@ -8016,7 +7835,6 @@ beginWork$1 = function(current, workInProgress, renderLanes) { contextStackCursor.current ); prepareToReadContext(workInProgress, renderLanes); - markComponentRenderStarted(workInProgress); context = renderWithHooks( null, workInProgress, @@ -8025,7 +7843,6 @@ beginWork$1 = function(current, workInProgress, renderLanes) { context, renderLanes ); - markComponentRenderStopped(); workInProgress.flags |= 1; if ( "object" === typeof context && @@ -8351,9 +8168,7 @@ beginWork$1 = function(current, workInProgress, renderLanes) { (Component = workInProgress.pendingProps.children), prepareToReadContext(workInProgress, renderLanes), (context = readContext(context)), - markComponentRenderStarted(workInProgress), (Component = Component(context)), - markComponentRenderStopped(), (workInProgress.flags |= 1), reconcileChildren(current, workInProgress, Component, renderLanes), workInProgress.child @@ -8484,7 +8299,7 @@ function createWorkInProgress(current, pendingProps) { (workInProgress.deletions = null), (workInProgress.actualDuration = 0), (workInProgress.actualStartTime = -1)); - workInProgress.flags = current.flags & 14680064; + workInProgress.flags = current.flags & 7340032; workInProgress.childLanes = current.childLanes; workInProgress.lanes = current.lanes; workInProgress.child = current.child; @@ -8666,7 +8481,6 @@ function updateContainer(element, container, parentComponent, callback) { var current = container.current, eventTime = requestEventTime(), lane = requestUpdateLane(current); - supportsUserTimingV3 && markAndClear("--schedule-render-" + lane); a: if (parentComponent) { parentComponent = parentComponent._reactInternals; b: { @@ -8848,10 +8662,10 @@ batchedUpdatesImpl = function(fn, a) { } }; var roots = new Map(), - devToolsConfig$jscomp$inline_1046 = { + devToolsConfig$jscomp$inline_1006 = { findFiberByHostInstance: getInstanceFromTag, bundleType: 0, - version: "18.0.0-3fcd81dd1-20211102", + version: "18.0.0-afcb9cdc9-20211008", rendererPackageName: "react-native-renderer", rendererConfig: { getInspectorDataForViewTag: function() { @@ -8866,11 +8680,11 @@ var roots = new Map(), }.bind(null, findNodeHandle) } }; -var internals$jscomp$inline_1339 = { - bundleType: devToolsConfig$jscomp$inline_1046.bundleType, - version: devToolsConfig$jscomp$inline_1046.version, - rendererPackageName: devToolsConfig$jscomp$inline_1046.rendererPackageName, - rendererConfig: devToolsConfig$jscomp$inline_1046.rendererConfig, +var internals$jscomp$inline_1290 = { + bundleType: devToolsConfig$jscomp$inline_1006.bundleType, + version: devToolsConfig$jscomp$inline_1006.version, + rendererPackageName: devToolsConfig$jscomp$inline_1006.rendererPackageName, + rendererConfig: devToolsConfig$jscomp$inline_1006.rendererConfig, overrideHookState: null, overrideHookStateDeletePath: null, overrideHookStateRenamePath: null, @@ -8886,26 +8700,26 @@ var internals$jscomp$inline_1339 = { return null === fiber ? null : fiber.stateNode; }, findFiberByHostInstance: - devToolsConfig$jscomp$inline_1046.findFiberByHostInstance || + devToolsConfig$jscomp$inline_1006.findFiberByHostInstance || emptyFindFiberByHostInstance, findHostInstancesForRefresh: null, scheduleRefresh: null, scheduleRoot: null, setRefreshHandler: null, getCurrentFiber: null, - reconcilerVersion: "18.0.0-3fcd81dd1-20211102" + reconcilerVersion: "18.0.0-afcb9cdc9-20211008" }; if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) { - var hook$jscomp$inline_1340 = __REACT_DEVTOOLS_GLOBAL_HOOK__; + var hook$jscomp$inline_1291 = __REACT_DEVTOOLS_GLOBAL_HOOK__; if ( - !hook$jscomp$inline_1340.isDisabled && - hook$jscomp$inline_1340.supportsFiber + !hook$jscomp$inline_1291.isDisabled && + hook$jscomp$inline_1291.supportsFiber ) try { - (rendererID = hook$jscomp$inline_1340.inject( - internals$jscomp$inline_1339 + (rendererID = hook$jscomp$inline_1291.inject( + internals$jscomp$inline_1290 )), - (injectedHook = hook$jscomp$inline_1340); + (injectedHook = hook$jscomp$inline_1291); } catch (err) {} } exports.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = { @@ -8995,23 +8809,3 @@ exports.unmountComponentAtNodeAndRemoveContainer = function(containerTag) { ReactNativePrivateInterface.UIManager.removeRootView(containerTag); }; exports.unstable_batchedUpdates = batchedUpdates; - - /** - * Copyright (c) Facebook, Inc. and its affiliates. - * - * This source code is licensed under the MIT license found in the - * LICENSE file in the root directory of this source tree. - */ - -/* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */ - -// Don't require this file directly; it's embedded by Rollup during build. - -if ( - typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' && - typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop === - 'function' -) { - __REACT_DEVTOOLS_GLOBAL_HOOK__.registerInternalModuleStop(new Error()); -} -