From 6761b98fbd71dbd67cba62b545febd1ceb4c4a0e Mon Sep 17 00:00:00 2001 From: Janka Uryga Date: Tue, 21 May 2024 11:27:03 +0200 Subject: [PATCH] Update React from 04b058868c to d3ce0d3ea9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ### React upstream changes - 75871d7de [ssa] Add support for other kinds of Instructions (Sathya Gunasekaran) - bb91cbbf6 [hir][be] Use a Map to store ObjectExpression.properties (Sathya Gunasekaran) - f54d121d7 [hir][be] Use a Map to store JsxExpression.props (Sathya Gunasekaran) - c347e8b6d [ssa][be] Delete dead code (Sathya Gunasekaran) - 152c3e81d [hir][be] Use .kind() to update and find ValueKind (Sathya Gunasekaran) - f4df34542 Improve playground validation, workaround lack of JSX support (Joseph Savona) - a7450572f import runtime from "React.unstable_ForgetRuntime" (Joseph Savona) - 2f34f8501 Enable no-use-before-define validation in playground (Joseph Savona) - 00a58cdab Option to validate output with ESLint (Joseph Savona) - 94f1e6f27 Add runtime dependencies to the dependencies (Jan Kassens) - eeb01b17e [ssa] Remove lambdas for update functions (Sathya Gunasekaran) - b9ce8bdcf [SSA] Fix identifierID hack (Sathya Gunasekaran) - 379251c65 Add SSA-ify pass (Sathya Gunasekaran) - 9524c5848 Replace `import from '.'` with path name (Jan Kassens) - 95fe4ed0e Include `Utils.Component()` in BailOnCapitalizedFunctionCalls (Tianyu Yao) - 704d93600 [easy] rename InferReference{Capability=>Effects} (Joseph Savona) - 471201774 Include `Utils.Component()` in BailOnCapitalizedFunctionCalls (Tianyu Yao) - 46d7f4f8a Synchronize symbol names with React (Lauren Tan) - b03752cbe Use for loop instead of Array.prototype.fill (Lauren Tan) - 90e189ae8 Add react-forget-runtime (Jan Kassens) - 8f42eda43 Provide full path to tsc (Lauren Tan) - 9e8224cc5 Pass `init` to E0007 diagnostic (Lauren Tan) - 33735b90f Add a ts:analyze-trace command (Lauren Tan) - e939cacf9 Don't console.error in dev (Lauren Tan) - 101ee3a44 Allow capitalized function identifiers to be allowlisted (Lauren Tan) - 58100e3d6 Use CompilerError invariant (Lauren Tan) - https://github.com/facebook/react/pull/662 - 0000ab6ca [new-arch] HIR cleanup per discussion (Joseph Savona) - 73059d9a4 [Playground][Nit] Add delete + overtype for autoclosing brackets (mofeiZ) - 144e85626 Cleanup reverse postordering (Joseph Savona) - b01fbfa7f Change function parameters to type Place (Sathya Gunasekaran) - 5149ce0fb [new-arch] Store HIR blocks in reverse postorder (Joseph Savona) - 3d4130140 [new-arch] Scaffolding and fixtures for mutability lifetime inference (Joseph Savona) - https://github.com/facebook/react/pull/651 - beb6e1431 [new-arch] Improve reference-kind analysis (Joseph Savona) - 7f17dd84d Import useMemoCache from unstable name (Jan Kassens) - e575e2292 Add hash of Babel plugin to Jest transform (Jan Kassens) - b605fc1ab [BE] Even more permissive ref annotation comment (Xuan Huang (黄玄)) - a574d1598 [Fix] Control Dep Should Only Add To Defs (Xuan Huang (黄玄)) - 19b08e67a [Bailout] When Inputs Detected In DepGraph Cycle (Xuan Huang (黄玄)) - cbbfba27b [new-arch][easy] Handle declarations (let/const) through codegen (Joseph Savona) - 90ab34650 [new-arch][easy] Codegen for switch statements (Joseph Savona) - f5f914338 [new-architecture] Reassignment-safe frozenness inference (Joseph Savona) - e877f89dd Allow comment annotation to be spaced (Xuan Huang (黄玄)) - 83f3999a2 Support var declaration hoisting (Xuan Huang (黄玄)) - 896ef251b patch makeReadOnly into playground (Mofei Zhang) - 4e0639c2d Add makeReadOnly codegen into the compiler (Mofei Zhang) - 72775fba1 makeReadOnly implementation (Mofei Zhang) - https://github.com/facebook/react/pull/589 - a33c0b897 Initial commit (Xuan Huang (黄玄)) - https://github.com/facebook/react/pull/29026 --- package.json | 32 +- .../cjs/react-dom-client.development.js | 39526 +++++++-------- .../cjs/react-dom-client.production.js | 15603 +++--- .../cjs/react-dom-profiling.development.js | 39526 +++++++-------- .../cjs/react-dom-profiling.profiling.js | 6695 +-- ...t-dom-server-legacy.browser.development.js | 2 +- ...ct-dom-server-legacy.browser.production.js | 2 +- ...eact-dom-server-legacy.node.development.js | 2 +- ...react-dom-server-legacy.node.production.js | 2 +- .../react-dom-server.browser.development.js | 2 +- .../react-dom-server.browser.production.js | 2 +- .../cjs/react-dom-server.bun.production.js | 2 +- .../cjs/react-dom-server.edge.development.js | 2 +- .../cjs/react-dom-server.edge.production.js | 2 +- .../cjs/react-dom-server.node.development.js | 2 +- .../cjs/react-dom-server.node.production.js | 2 +- .../react-dom-unstable_testing.development.js | 40222 ++++++++-------- .../react-dom-unstable_testing.production.js | 9201 ++-- .../cjs/react-dom.development.js | 2 +- .../cjs/react-dom.production.js | 2 +- .../react-dom-experimental/package.json | 4 +- .../cjs/react-dom-client.development.js | 39132 +++++++-------- .../cjs/react-dom-client.production.js | 16853 +++---- .../cjs/react-dom-profiling.development.js | 39132 +++++++-------- .../cjs/react-dom-profiling.profiling.js | 6161 +-- ...t-dom-server-legacy.browser.development.js | 2 +- ...ct-dom-server-legacy.browser.production.js | 2 +- ...eact-dom-server-legacy.node.development.js | 2 +- ...react-dom-server-legacy.node.production.js | 2 +- .../react-dom-server.browser.development.js | 2 +- .../react-dom-server.browser.production.js | 2 +- .../cjs/react-dom-server.bun.production.js | 2 +- .../cjs/react-dom-server.edge.development.js | 2 +- .../cjs/react-dom-server.edge.production.js | 2 +- .../cjs/react-dom-server.node.development.js | 2 +- .../cjs/react-dom-server.node.production.js | 2 +- .../react-dom/cjs/react-dom.development.js | 2 +- .../react-dom/cjs/react-dom.production.js | 2 +- .../next/src/compiled/react-dom/package.json | 4 +- .../cjs/react-jsx-dev-runtime.development.js | 43 +- ...sx-dev-runtime.react-server.development.js | 43 +- .../cjs/react-jsx-runtime.development.js | 43 +- ...ct-jsx-runtime.react-server.development.js | 43 +- .../cjs/react.development.js | 49 +- .../cjs/react.production.js | 2 +- .../cjs/react.react-server.development.js | 49 +- .../cjs/react.react-server.production.js | 2 +- ...om-turbopack-client.browser.development.js | 235 +- ...dom-turbopack-client.browser.production.js | 251 +- ...r-dom-turbopack-client.edge.development.js | 235 +- ...er-dom-turbopack-client.edge.production.js | 251 +- ...r-dom-turbopack-client.node.development.js | 233 +- ...er-dom-turbopack-client.node.production.js | 249 +- ...opack-client.node.unbundled.development.js | 233 +- ...bopack-client.node.unbundled.production.js | 249 +- ...om-turbopack-server.browser.development.js | 706 +- ...dom-turbopack-server.browser.production.js | 458 +- ...r-dom-turbopack-server.edge.development.js | 713 +- ...er-dom-turbopack-server.edge.production.js | 458 +- ...r-dom-turbopack-server.node.development.js | 716 +- ...er-dom-turbopack-server.node.production.js | 478 +- ...opack-server.node.unbundled.development.js | 716 +- ...bopack-server.node.unbundled.production.js | 478 +- .../package.json | 4 +- ...om-turbopack-client.browser.development.js | 1001 +- ...dom-turbopack-client.browser.production.js | 932 +- ...r-dom-turbopack-client.edge.development.js | 1001 +- ...er-dom-turbopack-client.edge.production.js | 932 +- ...r-dom-turbopack-client.node.development.js | 999 +- ...er-dom-turbopack-client.node.production.js | 907 +- ...opack-client.node.unbundled.development.js | 999 +- ...bopack-client.node.unbundled.production.js | 907 +- ...om-turbopack-server.browser.development.js | 1528 +- ...dom-turbopack-server.browser.production.js | 992 +- ...r-dom-turbopack-server.edge.development.js | 1530 +- ...er-dom-turbopack-server.edge.production.js | 992 +- ...r-dom-turbopack-server.node.development.js | 1494 +- ...er-dom-turbopack-server.node.production.js | 1020 +- ...opack-server.node.unbundled.development.js | 1494 +- ...bopack-server.node.unbundled.production.js | 1020 +- .../react-server-dom-turbopack/package.json | 4 +- ...-dom-webpack-client.browser.development.js | 235 +- ...r-dom-webpack-client.browser.production.js | 251 +- ...ver-dom-webpack-client.edge.development.js | 235 +- ...rver-dom-webpack-client.edge.production.js | 251 +- ...ver-dom-webpack-client.node.development.js | 233 +- ...rver-dom-webpack-client.node.production.js | 249 +- ...bpack-client.node.unbundled.development.js | 233 +- ...ebpack-client.node.unbundled.production.js | 249 +- ...-dom-webpack-server.browser.development.js | 656 +- ...r-dom-webpack-server.browser.production.js | 436 +- ...ver-dom-webpack-server.edge.development.js | 663 +- ...rver-dom-webpack-server.edge.production.js | 436 +- ...ver-dom-webpack-server.node.development.js | 661 +- ...rver-dom-webpack-server.node.production.js | 444 +- ...bpack-server.node.unbundled.development.js | 661 +- ...ebpack-server.node.unbundled.production.js | 444 +- .../package.json | 4 +- ...-dom-webpack-client.browser.development.js | 1001 +- ...r-dom-webpack-client.browser.production.js | 932 +- ...ver-dom-webpack-client.edge.development.js | 1001 +- ...rver-dom-webpack-client.edge.production.js | 932 +- ...ver-dom-webpack-client.node.development.js | 999 +- ...rver-dom-webpack-client.node.production.js | 907 +- ...bpack-client.node.unbundled.development.js | 999 +- ...ebpack-client.node.unbundled.production.js | 907 +- ...-dom-webpack-server.browser.development.js | 1478 +- ...r-dom-webpack-server.browser.production.js | 970 +- ...ver-dom-webpack-server.edge.development.js | 1480 +- ...rver-dom-webpack-server.edge.production.js | 970 +- ...ver-dom-webpack-server.node.development.js | 1439 +- ...rver-dom-webpack-server.node.production.js | 986 +- ...bpack-server.node.unbundled.development.js | 1439 +- ...ebpack-server.node.unbundled.production.js | 986 +- .../react-server-dom-webpack/package.json | 4 +- .../cjs/react-jsx-dev-runtime.development.js | 2 +- ...sx-dev-runtime.react-server.development.js | 2 +- .../cjs/react-jsx-runtime.development.js | 2 +- ...ct-jsx-runtime.react-server.development.js | 2 +- .../compiled/react/cjs/react.development.js | 4 +- .../compiled/react/cjs/react.production.js | 2 +- .../cjs/react.react-server.development.js | 4 +- .../cjs/react.react-server.production.js | 2 +- pnpm-lock.yaml | 308 +- 124 files changed, 165380 insertions(+), 135551 deletions(-) diff --git a/package.json b/package.json index b2f5809186e40..c3dbbe5defb1e 100644 --- a/package.json +++ b/package.json @@ -197,18 +197,18 @@ "pretty-bytes": "5.3.0", "pretty-ms": "7.0.0", "random-seed": "0.3.0", - "react": "19.0.0-beta-04b058868c-20240508", + "react": "19.0.0-rc-d3ce0d3ea9-20240520", "react-17": "npm:react@17.0.2", - "react-builtin": "npm:react@19.0.0-beta-04b058868c-20240508", - "react-dom": "19.0.0-beta-04b058868c-20240508", + "react-builtin": "npm:react@19.0.0-rc-d3ce0d3ea9-20240520", + "react-dom": "19.0.0-rc-d3ce0d3ea9-20240520", "react-dom-17": "npm:react-dom@17.0.2", - "react-dom-builtin": "npm:react-dom@19.0.0-beta-04b058868c-20240508", - "react-dom-experimental-builtin": "npm:react-dom@0.0.0-experimental-04b058868c-20240508", - "react-experimental-builtin": "npm:react@0.0.0-experimental-04b058868c-20240508", - "react-server-dom-turbopack": "19.0.0-beta-04b058868c-20240508", - "react-server-dom-turbopack-experimental": "npm:react-server-dom-turbopack@0.0.0-experimental-04b058868c-20240508", - "react-server-dom-webpack": "19.0.0-beta-04b058868c-20240508", - "react-server-dom-webpack-experimental": "npm:react-server-dom-webpack@0.0.0-experimental-04b058868c-20240508", + "react-dom-builtin": "npm:react-dom@19.0.0-rc-d3ce0d3ea9-20240520", + "react-dom-experimental-builtin": "npm:react-dom@0.0.0-experimental-d3ce0d3ea9-20240520", + "react-experimental-builtin": "npm:react@0.0.0-experimental-d3ce0d3ea9-20240520", + "react-server-dom-turbopack": "19.0.0-rc-d3ce0d3ea9-20240520", + "react-server-dom-turbopack-experimental": "npm:react-server-dom-turbopack@0.0.0-experimental-d3ce0d3ea9-20240520", + "react-server-dom-webpack": "19.0.0-rc-d3ce0d3ea9-20240520", + "react-server-dom-webpack-experimental": "npm:react-server-dom-webpack@0.0.0-experimental-d3ce0d3ea9-20240520", "react-ssr-prepass": "1.0.8", "react-virtualized": "9.22.3", "relay-compiler": "13.0.2", @@ -218,8 +218,8 @@ "resolve-from": "5.0.0", "sass": "1.54.0", "satori": "0.10.9", - "scheduler-builtin": "npm:scheduler@0.25.0-beta-04b058868c-20240508", - "scheduler-experimental-builtin": "npm:scheduler@0.0.0-experimental-04b058868c-20240508", + "scheduler-builtin": "npm:scheduler@0.25.0-rc-d3ce0d3ea9-20240520", + "scheduler-experimental-builtin": "npm:scheduler@0.0.0-experimental-d3ce0d3ea9-20240520", "seedrandom": "3.0.5", "semver": "7.3.7", "shell-quote": "1.7.3", @@ -253,10 +253,10 @@ "@babel/traverse": "7.22.5", "@types/react": "18.2.74", "@types/react-dom": "18.2.23", - "react": "19.0.0-beta-04b058868c-20240508", - "react-dom": "19.0.0-beta-04b058868c-20240508", - "react-is": "19.0.0-beta-04b058868c-20240508", - "scheduler": "0.25.0-beta-04b058868c-20240508" + "react": "19.0.0-rc-d3ce0d3ea9-20240520", + "react-dom": "19.0.0-rc-d3ce0d3ea9-20240520", + "react-is": "19.0.0-rc-d3ce0d3ea9-20240520", + "scheduler": "0.25.0-rc-d3ce0d3ea9-20240520" }, "engines": { "node": ">=18.17.0", diff --git a/packages/next/src/compiled/react-dom-experimental/cjs/react-dom-client.development.js b/packages/next/src/compiled/react-dom-experimental/cjs/react-dom-client.development.js index 355746f3d2aed..760b9a9134638 100644 --- a/packages/next/src/compiled/react-dom-experimental/cjs/react-dom-client.development.js +++ b/packages/next/src/compiled/react-dom-experimental/cjs/react-dom-client.development.js @@ -8718,24829 +8718,24871 @@ function extractEvents$2(dispatchQueue, domEventName, targetInst, nativeEvent, n } } -/** - * This plugin invokes action functions on forms, inputs and buttons if - * the form doesn't prevent default. - */ +// We use the existence of the state object as an indicator that the component +// is hidden. +var OffscreenVisible = +/* */ +1; +var OffscreenDetached = +/* */ +2; +var OffscreenPassiveEffectsConnected = +/* */ +4; +function isOffscreenManual(offscreenFiber) { + return offscreenFiber.memoizedProps !== null && offscreenFiber.memoizedProps.mode === 'manual'; +} -function extractEvents$1(dispatchQueue, domEventName, maybeTargetInst, nativeEvent, nativeEventTarget, eventSystemFlags, targetContainer) { - if (domEventName !== 'submit') { - return; - } +// we wait until the current render is over (either finished or interrupted) +// before adding it to the fiber/hook queue. Push to this array so we can +// access the queue, fiber, update, et al later. - if (!maybeTargetInst || maybeTargetInst.stateNode !== nativeEventTarget) { - // If we're inside a parent root that itself is a parent of this root, then - // its deepest target won't be the actual form that's being submitted. - return; - } +var concurrentQueues = []; +var concurrentQueuesIndex = 0; +var concurrentlyUpdatedLanes = NoLanes; +function finishQueueingConcurrentUpdates() { + var endIndex = concurrentQueuesIndex; + concurrentQueuesIndex = 0; + concurrentlyUpdatedLanes = NoLanes; + var i = 0; - var formInst = maybeTargetInst; - var form = nativeEventTarget; - var action = getFiberCurrentPropsFromNode(form).action; - var submitter = nativeEvent.submitter; - var submitterAction; + while (i < endIndex) { + var fiber = concurrentQueues[i]; + concurrentQueues[i++] = null; + var queue = concurrentQueues[i]; + concurrentQueues[i++] = null; + var update = concurrentQueues[i]; + concurrentQueues[i++] = null; + var lane = concurrentQueues[i]; + concurrentQueues[i++] = null; - if (submitter) { - var submitterProps = getFiberCurrentPropsFromNode(submitter); - submitterAction = submitterProps ? submitterProps.formAction : submitter.getAttribute('formAction'); + if (queue !== null && update !== null) { + var pending = queue.pending; - if (submitterAction != null) { - // The submitter overrides the form action. - action = submitterAction; // If the action is a function, we don't want to pass its name - // value to the FormData since it's controlled by the server. + if (pending === null) { + // This is the first update. Create a circular list. + update.next = update; + } else { + update.next = pending.next; + pending.next = update; + } - submitter = null; + queue.pending = update; + } + + if (lane !== NoLane) { + markUpdateLaneFromFiberToRoot(fiber, update, lane); } } +} +function getConcurrentlyUpdatedLanes() { + return concurrentlyUpdatedLanes; +} - if (typeof action !== 'function') { - return; +function enqueueUpdate$1(fiber, queue, update, lane) { + // Don't update the `childLanes` on the return path yet. If we already in + // the middle of rendering, wait until after it has completed. + concurrentQueues[concurrentQueuesIndex++] = fiber; + concurrentQueues[concurrentQueuesIndex++] = queue; + concurrentQueues[concurrentQueuesIndex++] = update; + concurrentQueues[concurrentQueuesIndex++] = lane; + concurrentlyUpdatedLanes = mergeLanes(concurrentlyUpdatedLanes, lane); // The fiber's `lane` field is used in some places to check if any work is + // scheduled, to perform an eager bailout, so we need to update it immediately. + // TODO: We should probably move this to the "shared" queue instead. + + fiber.lanes = mergeLanes(fiber.lanes, lane); + var alternate = fiber.alternate; + + if (alternate !== null) { + alternate.lanes = mergeLanes(alternate.lanes, lane); } +} - var event = new SyntheticEvent('action', 'action', null, nativeEvent, nativeEventTarget); +function enqueueConcurrentHookUpdate(fiber, queue, update, lane) { + var concurrentQueue = queue; + var concurrentUpdate = update; + enqueueUpdate$1(fiber, concurrentQueue, concurrentUpdate, lane); + return getRootForUpdatedFiber(fiber); +} +function enqueueConcurrentHookUpdateAndEagerlyBailout(fiber, queue, update) { + // This function is used to queue an update that doesn't need a rerender. The + // only reason we queue it is in case there's a subsequent higher priority + // update that causes it to be rebased. + var lane = NoLane; + var concurrentQueue = queue; + var concurrentUpdate = update; + enqueueUpdate$1(fiber, concurrentQueue, concurrentUpdate, lane); // Usually we can rely on the upcoming render phase to process the concurrent + // queue. However, since this is a bail out, we're not scheduling any work + // here. So the update we just queued will leak until something else happens + // to schedule work (if ever). + // + // Check if we're currently in the middle of rendering a tree, and if not, + // process the queue immediately to prevent a leak. - function submitForm() { - if (nativeEvent.defaultPrevented) { - // We let earlier events to prevent the action from submitting. - return; - } // Prevent native navigation. + var isConcurrentlyRendering = getWorkInProgressRoot() !== null; + + if (!isConcurrentlyRendering) { + finishQueueingConcurrentUpdates(); + } +} +function enqueueConcurrentClassUpdate(fiber, queue, update, lane) { + var concurrentQueue = queue; + var concurrentUpdate = update; + enqueueUpdate$1(fiber, concurrentQueue, concurrentUpdate, lane); + return getRootForUpdatedFiber(fiber); +} +function enqueueConcurrentRenderForLane(fiber, lane) { + enqueueUpdate$1(fiber, null, null, lane); + return getRootForUpdatedFiber(fiber); +} // Calling this function outside this module should only be done for backwards +// compatibility and should always be accompanied by a warning. + +function unsafe_markUpdateLaneFromFiberToRoot(sourceFiber, lane) { + // NOTE: For Hyrum's Law reasons, if an infinite update loop is detected, it + // should throw before `markUpdateLaneFromFiberToRoot` is called. But this is + // undefined behavior and we can change it if we need to; it just so happens + // that, at the time of this writing, there's an internal product test that + // happens to rely on this. + var root = getRootForUpdatedFiber(sourceFiber); + markUpdateLaneFromFiberToRoot(sourceFiber, null, lane); + return root; +} +function markUpdateLaneFromFiberToRoot(sourceFiber, update, lane) { + // Update the source fiber's lanes + sourceFiber.lanes = mergeLanes(sourceFiber.lanes, lane); + var alternate = sourceFiber.alternate; - event.preventDefault(); - var formData; + if (alternate !== null) { + alternate.lanes = mergeLanes(alternate.lanes, lane); + } // Walk the parent path to the root and update the child lanes. - if (submitter) { - // The submitter's value should be included in the FormData. - // It should be in the document order in the form. - // Since the FormData constructor invokes the formdata event it also - // needs to be available before that happens so after construction it's too - // late. We use a temporary fake node for the duration of this event. - // TODO: FormData takes a second argument that it's the submitter but this - // is fairly new so not all browsers support it yet. Switch to that technique - // when available. - var temp = submitter.ownerDocument.createElement('input'); - temp.name = submitter.name; - temp.value = submitter.value; - if (form.id) { - temp.setAttribute('form', form.id); - } + var isHidden = false; + var parent = sourceFiber.return; + var node = sourceFiber; - submitter.parentNode.insertBefore(temp, submitter); - formData = new FormData(form); - temp.parentNode.removeChild(temp); - } else { - formData = new FormData(form); + while (parent !== null) { + parent.childLanes = mergeLanes(parent.childLanes, lane); + alternate = parent.alternate; + + if (alternate !== null) { + alternate.childLanes = mergeLanes(alternate.childLanes, lane); } - var pendingState = { - pending: true, - data: formData, - method: form.method, - action: action - }; + if (parent.tag === OffscreenComponent) { + // Check if this offscreen boundary is currently hidden. + // + // The instance may be null if the Offscreen parent was unmounted. Usually + // the parent wouldn't be reachable in that case because we disconnect + // fibers from the tree when they are deleted. However, there's a weird + // edge case where setState is called on a fiber that was interrupted + // before it ever mounted. Because it never mounts, it also never gets + // deleted. Because it never gets deleted, its return pointer never gets + // disconnected. Which means it may be attached to a deleted Offscreen + // parent node. (This discovery suggests it may be better for memory usage + // if we don't attach the `return` pointer until the commit phase, though + // in order to do that we'd need some other way to track the return + // pointer during the initial render, like on the stack.) + // + // This case is always accompanied by a warning, but we still need to + // account for it. (There may be other cases that we haven't discovered, + // too.) + var offscreenInstance = parent.stateNode; - { - Object.freeze(pendingState); + if (offscreenInstance !== null && !(offscreenInstance._visibility & OffscreenVisible)) { + isHidden = true; + } } - startHostTransition(formInst, pendingState, action, formData); + node = parent; + parent = parent.return; } - dispatchQueue.push({ - event: event, - listeners: [{ - instance: null, - listener: submitForm, - currentTarget: form - }] - }); + if (isHidden && update !== null && node.tag === HostRoot) { + var root = node.stateNode; + markHiddenUpdate(root, update, lane); + } } -function dispatchReplayedFormAction(formInst, form, action, formData) { - var pendingState = { - pending: true, - data: formData, - method: form.method, - action: action - }; - { - Object.freeze(pendingState); +function getRootForUpdatedFiber(sourceFiber) { + // TODO: We will detect and infinite update loop and throw even if this fiber + // has already unmounted. This isn't really necessary but it happens to be the + // current behavior we've used for several release cycles. Consider not + // performing this check if the updated fiber already unmounted, since it's + // not possible for that to cause an infinite update loop. + throwIfInfiniteUpdateLoopDetected(); // When a setState happens, we must ensure the root is scheduled. Because + // update queues do not have a backpointer to the root, the only way to do + // this currently is to walk up the return path. This used to not be a big + // deal because we would have to walk up the return path to set + // the `childLanes`, anyway, but now those two traversals happen at + // different times. + // TODO: Consider adding a `root` backpointer on the update queue. + + detectUpdateOnUnmountedFiber(sourceFiber, sourceFiber); + var node = sourceFiber; + var parent = node.return; + + while (parent !== null) { + detectUpdateOnUnmountedFiber(sourceFiber, node); + node = parent; + parent = node.return; } - startHostTransition(formInst, pendingState, action, formData); + return node.tag === HostRoot ? node.stateNode : null; } -var reportGlobalError = typeof reportError === 'function' ? // In modern browsers, reportError will dispatch an error event, -// emulating an uncaught JavaScript error. -reportError : function (error) { - if (typeof window === 'object' && typeof window.ErrorEvent === 'function') { - // Browser Polyfill - var message = typeof error === 'object' && error !== null && typeof error.message === 'string' ? // eslint-disable-next-line react-internal/safe-string-coercion - String(error.message) : // eslint-disable-next-line react-internal/safe-string-coercion - String(error); - var event = new window.ErrorEvent('error', { - bubbles: true, - cancelable: true, - message: message, - error: error - }); - var shouldLog = window.dispatchEvent(event); +function detectUpdateOnUnmountedFiber(sourceFiber, parent) { + { + var alternate = parent.alternate; - if (!shouldLog) { - return; + if (alternate === null && (parent.flags & (Placement | Hydrating)) !== NoFlags$1) { + warnAboutUpdateOnNotYetMountedFiberInDEV(sourceFiber); } - } else if (typeof process === 'object' && // $FlowFixMe[method-unbinding] - typeof process.emit === 'function') { - // Node Polyfill - process.emit('uncaughtException', error); - return; - } // eslint-disable-next-line react-internal/no-production-logging - - - console['error'](error); -}; - -registerSimpleEvents(); -registerEvents$1(); -registerEvents$2(); -registerEvents(); -registerEvents$3(); - -function extractEvents(dispatchQueue, domEventName, targetInst, nativeEvent, nativeEventTarget, eventSystemFlags, targetContainer) { - // TODO: we should remove the concept of a "SimpleEventPlugin". - // This is the basic functionality of the event system. All - // the other plugins are essentially polyfills. So the plugin - // should probably be inlined somewhere and have its logic - // be core the to event system. This would potentially allow - // us to ship builds of React without the polyfilled plugins below. - extractEvents$2(dispatchQueue, domEventName, targetInst, nativeEvent, nativeEventTarget, eventSystemFlags); - var shouldProcessPolyfillPlugins = (eventSystemFlags & SHOULD_NOT_PROCESS_POLYFILL_EVENT_PLUGINS) === 0; // We don't process these events unless we are in the - // event's native "bubble" phase, which means that we're - // not in the capture phase. That's because we emulate - // the capture phase here still. This is a trade-off, - // because in an ideal world we would not emulate and use - // the phases properly, like we do with the SimpleEvent - // plugin. However, the plugins below either expect - // emulation (EnterLeave) or use state localized to that - // plugin (BeforeInput, Change, Select). The state in - // these modules complicates things, as you'll essentially - // get the case where the capture phase event might change - // state, only for the following bubble event to come in - // later and not trigger anything as the state now - // invalidates the heuristics of the event plugin. We - // could alter all these plugins to work in such ways, but - // that might cause other unknown side-effects that we - // can't foresee right now. - - if (shouldProcessPolyfillPlugins) { - extractEvents$4(dispatchQueue, domEventName, targetInst, nativeEvent, nativeEventTarget); - extractEvents$5(dispatchQueue, domEventName, targetInst, nativeEvent, nativeEventTarget); - extractEvents$3(dispatchQueue, domEventName, targetInst, nativeEvent, nativeEventTarget); - extractEvents$6(dispatchQueue, domEventName, targetInst, nativeEvent, nativeEventTarget); - extractEvents$1(dispatchQueue, domEventName, targetInst, nativeEvent, nativeEventTarget); } -} // List of events that need to be individually attached to media elements. - - -var mediaEventTypes = ['abort', 'canplay', 'canplaythrough', 'durationchange', 'emptied', 'encrypted', 'ended', 'error', 'loadeddata', 'loadedmetadata', 'loadstart', 'pause', 'play', 'playing', 'progress', 'ratechange', 'resize', 'seeked', 'seeking', 'stalled', 'suspend', 'timeupdate', 'volumechange', 'waiting']; // We should not delegate these events to the container, but rather -// set them on the actual target element itself. This is primarily -// because these events do not consistently bubble in the DOM. +} -var nonDelegatedEvents = new Set(['cancel', 'close', 'invalid', 'load', 'scroll', 'scrollend', 'toggle'].concat(mediaEventTypes)); +var emptyContextObject = {}; -function executeDispatch(event, listener, currentTarget) { - event.currentTarget = currentTarget; +{ + Object.freeze(emptyContextObject); +} // A cursor to the current merged context object on the stack. - try { - listener(event); - } catch (error) { - reportGlobalError(error); +function hasContextChanged() { + { + return false; } - - event.currentTarget = null; } -function processDispatchQueueItemsInOrder(event, dispatchListeners, inCapturePhase) { - var previousInstance; - - if (inCapturePhase) { - for (var i = dispatchListeners.length - 1; i >= 0; i--) { - var _dispatchListeners$i = dispatchListeners[i], - instance = _dispatchListeners$i.instance, - currentTarget = _dispatchListeners$i.currentTarget, - listener = _dispatchListeners$i.listener; - - if (instance !== previousInstance && event.isPropagationStopped()) { - return; - } - - executeDispatch(event, listener, currentTarget); - previousInstance = instance; - } - } else { - for (var _i = 0; _i < dispatchListeners.length; _i++) { - var _dispatchListeners$_i = dispatchListeners[_i], - _instance = _dispatchListeners$_i.instance, - _currentTarget = _dispatchListeners$_i.currentTarget, - _listener = _dispatchListeners$_i.listener; - - if (_instance !== previousInstance && event.isPropagationStopped()) { - return; - } - - executeDispatch(event, _listener, _currentTarget); - previousInstance = _instance; - } +function isContextProvider(type) { + { + return false; } } -function processDispatchQueue(dispatchQueue, eventSystemFlags) { - var inCapturePhase = (eventSystemFlags & IS_CAPTURE_PHASE) !== 0; - - for (var i = 0; i < dispatchQueue.length; i++) { - var _dispatchQueue$i = dispatchQueue[i], - event = _dispatchQueue$i.event, - listeners = _dispatchQueue$i.listeners; - processDispatchQueueItemsInOrder(event, listeners, inCapturePhase); // event system doesn't use pooling. +function processChildContext(fiber, type, parentContext) { + { + return parentContext; } } -function dispatchEventsForPlugins(domEventName, eventSystemFlags, nativeEvent, targetInst, targetContainer) { - var nativeEventTarget = getEventTarget(nativeEvent); - var dispatchQueue = []; - extractEvents(dispatchQueue, domEventName, targetInst, nativeEvent, nativeEventTarget, eventSystemFlags); - processDispatchQueue(dispatchQueue, eventSystemFlags); +function findCurrentUnmaskedContext(fiber) { + { + return emptyContextObject; + } } -function listenToNonDelegatedEvent(domEventName, targetElement) { +/* eslint-disable react-internal/prod-error-codes */ +// Used by React Refresh runtime through DevTools Global Hook. + +var resolveFamily = null; +var failedBoundaries = null; +var setRefreshHandler = function (handler) { { - if (!nonDelegatedEvents.has(domEventName)) { - error('Did not expect a listenToNonDelegatedEvent() call for "%s". ' + 'This is a bug in React. Please file an issue.', domEventName); - } + resolveFamily = handler; } +}; +function resolveFunctionForHotReloading(type) { + { + if (resolveFamily === null) { + // Hot reloading is disabled. + return type; + } - var isCapturePhaseListener = false; - var listenerSet = getEventListenerSet(targetElement); - var listenerSetKey = getListenerSetKey(domEventName, isCapturePhaseListener); + var family = resolveFamily(type); - if (!listenerSet.has(listenerSetKey)) { - addTrappedEventListener(targetElement, domEventName, IS_NON_DELEGATED, isCapturePhaseListener); - listenerSet.add(listenerSetKey); + if (family === undefined) { + return type; + } // Use the latest known implementation. + + + return family.current; } } -function listenToNativeEvent(domEventName, isCapturePhaseListener, target) { +function resolveClassForHotReloading(type) { + // No implementation differences. + return resolveFunctionForHotReloading(type); +} +function resolveForwardRefForHotReloading(type) { { - if (nonDelegatedEvents.has(domEventName) && !isCapturePhaseListener) { - error('Did not expect a listenToNativeEvent() call for "%s" in the bubble phase. ' + 'This is a bug in React. Please file an issue.', domEventName); + if (resolveFamily === null) { + // Hot reloading is disabled. + return type; } - } - var eventSystemFlags = 0; + var family = resolveFamily(type); - if (isCapturePhaseListener) { - eventSystemFlags |= IS_CAPTURE_PHASE; - } + if (family === undefined) { + // Check if we're dealing with a real forwardRef. Don't want to crash early. + if (type !== null && type !== undefined && typeof type.render === 'function') { + // ForwardRef is special because its resolved .type is an object, + // but it's possible that we only have its inner render function in the map. + // If that inner render function is different, we'll build a new forwardRef type. + var currentRender = resolveFunctionForHotReloading(type.render); - addTrappedEventListener(target, domEventName, eventSystemFlags, isCapturePhaseListener); -} // This is only used by createEventHandle when the -var listeningMarker = '_reactListening' + Math.random().toString(36).slice(2); -function listenToAllSupportedEvents(rootContainerElement) { - if (!rootContainerElement[listeningMarker]) { - rootContainerElement[listeningMarker] = true; - allNativeEvents.forEach(function (domEventName) { - // We handle selectionchange separately because it - // doesn't bubble and needs to be on the document. - if (domEventName !== 'selectionchange') { - if (!nonDelegatedEvents.has(domEventName)) { - listenToNativeEvent(domEventName, false, rootContainerElement); - } + if (type.render !== currentRender) { + var syntheticType = { + $$typeof: REACT_FORWARD_REF_TYPE, + render: currentRender + }; - listenToNativeEvent(domEventName, true, rootContainerElement); - } - }); - var ownerDocument = rootContainerElement.nodeType === DOCUMENT_NODE ? rootContainerElement : rootContainerElement.ownerDocument; + if (type.displayName !== undefined) { + syntheticType.displayName = type.displayName; + } - if (ownerDocument !== null) { - // The selectionchange event also needs deduplication - // but it is attached to the document. - if (!ownerDocument[listeningMarker]) { - ownerDocument[listeningMarker] = true; - listenToNativeEvent('selectionchange', false, ownerDocument); + return syntheticType; + } } - } - } -} -function addTrappedEventListener(targetContainer, domEventName, eventSystemFlags, isCapturePhaseListener, isDeferredListenerForLegacyFBSupport) { - var listener = createEventListenerWrapperWithPriority(targetContainer, domEventName, eventSystemFlags); // If passive option is not supported, then the event will be - // active and not passive. + return type; + } // Use the latest known implementation. - var isPassiveListener = undefined; - if (passiveBrowserEventsSupported) { - // Browsers introduced an intervention, making these events - // passive by default on document. React doesn't bind them - // to document anymore, but changing this now would undo - // the performance wins from the change. So we emulate - // the existing behavior manually on the roots now. - // https://github.com/facebook/react/issues/19651 - if (domEventName === 'touchstart' || domEventName === 'touchmove' || domEventName === 'wheel') { - isPassiveListener = true; - } + return family.current; } +} +function isCompatibleFamilyForHotReloading(fiber, element) { + { + if (resolveFamily === null) { + // Hot reloading is disabled. + return false; + } - targetContainer = targetContainer; + var prevType = fiber.elementType; + var nextType = element.type; // If we got here, we know types aren't === equal. + var needsCompareFamilies = false; + var $$typeofNextType = typeof nextType === 'object' && nextType !== null ? nextType.$$typeof : null; - if (isCapturePhaseListener) { - if (isPassiveListener !== undefined) { - addEventCaptureListenerWithPassiveFlag(targetContainer, domEventName, listener, isPassiveListener); - } else { - addEventCaptureListener(targetContainer, domEventName, listener); - } - } else { - if (isPassiveListener !== undefined) { - addEventBubbleListenerWithPassiveFlag(targetContainer, domEventName, listener, isPassiveListener); - } else { - addEventBubbleListener(targetContainer, domEventName, listener); - } - } -} - -function isMatchingRootContainer(grandContainer, targetContainer) { - return grandContainer === targetContainer || grandContainer.nodeType === COMMENT_NODE && grandContainer.parentNode === targetContainer; -} - -function dispatchEventForPluginEventSystem(domEventName, eventSystemFlags, nativeEvent, targetInst, targetContainer) { - var ancestorInst = targetInst; - - if ((eventSystemFlags & IS_EVENT_HANDLE_NON_MANAGED_NODE) === 0 && (eventSystemFlags & IS_NON_DELEGATED) === 0) { - var targetContainerNode = targetContainer; // If we are using the legacy FB support flag, we - - if (targetInst !== null) { - // The below logic attempts to work out if we need to change - // the target fiber to a different ancestor. We had similar logic - // in the legacy event system, except the big difference between - // systems is that the modern event system now has an event listener - // attached to each React Root and React Portal Root. Together, - // the DOM nodes representing these roots are the "rootContainer". - // To figure out which ancestor instance we should use, we traverse - // up the fiber tree from the target instance and attempt to find - // root boundaries that match that of our current "rootContainer". - // If we find that "rootContainer", we find the parent fiber - // sub-tree for that root and make that our ancestor instance. - var node = targetInst; + switch (fiber.tag) { + case ClassComponent: + { + if (typeof nextType === 'function') { + needsCompareFamilies = true; + } - mainLoop: while (true) { - if (node === null) { - return; + break; } - var nodeTag = node.tag; + case FunctionComponent: + { + if (typeof nextType === 'function') { + needsCompareFamilies = true; + } else if ($$typeofNextType === REACT_LAZY_TYPE) { + // We don't know the inner type yet. + // We're going to assume that the lazy inner type is stable, + // and so it is sufficient to avoid reconciling it away. + // We're not going to unwrap or actually use the new lazy type. + needsCompareFamilies = true; + } - if (nodeTag === HostRoot || nodeTag === HostPortal) { - var container = node.stateNode.containerInfo; + break; + } - if (isMatchingRootContainer(container, targetContainerNode)) { - break; + case ForwardRef: + { + if ($$typeofNextType === REACT_FORWARD_REF_TYPE) { + needsCompareFamilies = true; + } else if ($$typeofNextType === REACT_LAZY_TYPE) { + needsCompareFamilies = true; } - if (nodeTag === HostPortal) { - // The target is a portal, but it's not the rootContainer we're looking for. - // Normally portals handle their own events all the way down to the root. - // So we should be able to stop now. However, we don't know if this portal - // was part of *our* root. - var grandNode = node.return; - - while (grandNode !== null) { - var grandTag = grandNode.tag; + break; + } - if (grandTag === HostRoot || grandTag === HostPortal) { - var grandContainer = grandNode.stateNode.containerInfo; + case MemoComponent: + case SimpleMemoComponent: + { + if ($$typeofNextType === REACT_MEMO_TYPE) { + // TODO: if it was but can no longer be simple, + // we shouldn't set this. + needsCompareFamilies = true; + } else if ($$typeofNextType === REACT_LAZY_TYPE) { + needsCompareFamilies = true; + } - if (isMatchingRootContainer(grandContainer, targetContainerNode)) { - // This is the rootContainer we're looking for and we found it as - // a parent of the Portal. That means we can ignore it because the - // Portal will bubble through to us. - return; - } - } + break; + } - grandNode = grandNode.return; - } - } // Now we need to find it's corresponding host fiber in the other - // tree. To do this we can use getClosestInstanceFromNode, but we - // need to validate that the fiber is a host instance, otherwise - // we need to traverse up through the DOM till we find the correct - // node that is from the other tree. + default: + return false; + } // Check if both types have a family and it's the same one. - while (container !== null) { - var parentNode = getClosestInstanceFromNode(container); + if (needsCompareFamilies) { + // Note: memo() and forwardRef() we'll compare outer rather than inner type. + // This means both of them need to be registered to preserve state. + // If we unwrapped and compared the inner types for wrappers instead, + // then we would risk falsely saying two separate memo(Foo) + // calls are equivalent because they wrap the same Foo function. + var prevFamily = resolveFamily(prevType); // $FlowFixMe[not-a-function] found when upgrading Flow - if (parentNode === null) { - return; - } + if (prevFamily !== undefined && prevFamily === resolveFamily(nextType)) { + return true; + } + } - var parentTag = parentNode.tag; + return false; + } +} +function markFailedErrorBoundaryForHotReloading(fiber) { + { + if (resolveFamily === null) { + // Hot reloading is disabled. + return; + } - if (parentTag === HostComponent || parentTag === HostText || parentTag === HostHoistable || parentTag === HostSingleton) { - node = ancestorInst = parentNode; - continue mainLoop; - } + if (typeof WeakSet !== 'function') { + return; + } - container = container.parentNode; - } - } + if (failedBoundaries === null) { + failedBoundaries = new WeakSet(); + } - node = node.return; - } + failedBoundaries.add(fiber); + } +} +var scheduleRefresh = function (root, update) { + { + if (resolveFamily === null) { + // Hot reloading is disabled. + return; } + + var staleFamilies = update.staleFamilies, + updatedFamilies = update.updatedFamilies; + flushPassiveEffects(); + scheduleFibersWithFamiliesRecursively(root.current, updatedFamilies, staleFamilies); + flushSyncWork$1(); } +}; +var scheduleRoot = function (root, element) { + { + if (root.context !== emptyContextObject) { + // Super edge case: root has a legacy _renderSubtree context + // but we don't know the parentComponent so we can't pass it. + // Just ignore. We'll delete this with _renderSubtree code path later. + return; + } - batchedUpdates$1(function () { - return dispatchEventsForPlugins(domEventName, eventSystemFlags, nativeEvent, ancestorInst); - }); -} + updateContainerSync(element, root, null, null); + flushSyncWork$1(); + } +}; -function createDispatchListener(instance, listener, currentTarget) { - return { - instance: instance, - listener: listener, - currentTarget: currentTarget - }; -} +function scheduleFibersWithFamiliesRecursively(fiber, updatedFamilies, staleFamilies) { + { + var alternate = fiber.alternate, + child = fiber.child, + sibling = fiber.sibling, + tag = fiber.tag, + type = fiber.type; + var candidateType = null; -function accumulateSinglePhaseListeners(targetFiber, reactName, nativeEventType, inCapturePhase, accumulateTargetOnly, nativeEvent) { - var captureName = reactName !== null ? reactName + 'Capture' : null; - var reactEventName = inCapturePhase ? captureName : reactName; - var listeners = []; - var instance = targetFiber; - var lastHostComponent = null; // Accumulate all instances and listeners via the target -> root path. + switch (tag) { + case FunctionComponent: + case SimpleMemoComponent: + case ClassComponent: + candidateType = type; + break; - while (instance !== null) { - var _instance2 = instance, - stateNode = _instance2.stateNode, - tag = _instance2.tag; // Handle listeners that are on HostComponents (i.e.
) + case ForwardRef: + candidateType = type.render; + break; + } - if ((tag === HostComponent || tag === HostHoistable || tag === HostSingleton) && stateNode !== null) { - lastHostComponent = stateNode; // createEventHandle listeners + if (resolveFamily === null) { + throw new Error('Expected resolveFamily to be set during hot reload.'); + } + var needsRender = false; + var needsRemount = false; - if (reactEventName !== null) { - var listener = getListener(instance, reactEventName); + if (candidateType !== null) { + var family = resolveFamily(candidateType); - if (listener != null) { - listeners.push(createDispatchListener(instance, listener, lastHostComponent)); + if (family !== undefined) { + if (staleFamilies.has(family)) { + needsRemount = true; + } else if (updatedFamilies.has(family)) { + if (tag === ClassComponent) { + needsRemount = true; + } else { + needsRender = true; + } } } - } // If we are only accumulating events for the target, then we don't - // continue to propagate through the React fiber tree to find other - // listeners. + } + if (failedBoundaries !== null) { + if (failedBoundaries.has(fiber) || // $FlowFixMe[incompatible-use] found when upgrading Flow + alternate !== null && failedBoundaries.has(alternate)) { + needsRemount = true; + } + } - if (accumulateTargetOnly) { - break; - } // If we are processing the onBeforeBlur event, then we need to take + if (needsRemount) { + fiber._debugNeedsRemount = true; + } - instance = instance.return; - } + if (needsRemount || needsRender) { + var root = enqueueConcurrentRenderForLane(fiber, SyncLane); - return listeners; -} // We should only use this function for: -// - BeforeInputEventPlugin -// - ChangeEventPlugin -// - SelectEventPlugin -// This is because we only process these plugins -// in the bubble phase, so we need to accumulate two -// phase event listeners (via emulation). - -function accumulateTwoPhaseListeners(targetFiber, reactName) { - var captureName = reactName + 'Capture'; - var listeners = []; - var instance = targetFiber; // Accumulate all instances and listeners via the target -> root path. - - while (instance !== null) { - var _instance3 = instance, - stateNode = _instance3.stateNode, - tag = _instance3.tag; // Handle listeners that are on HostComponents (i.e.
) - - if ((tag === HostComponent || tag === HostHoistable || tag === HostSingleton) && stateNode !== null) { - var currentTarget = stateNode; - var captureListener = getListener(instance, captureName); - - if (captureListener != null) { - listeners.unshift(createDispatchListener(instance, captureListener, currentTarget)); + if (root !== null) { + scheduleUpdateOnFiber(root, fiber, SyncLane); } + } - var bubbleListener = getListener(instance, reactName); - - if (bubbleListener != null) { - listeners.push(createDispatchListener(instance, bubbleListener, currentTarget)); - } + if (child !== null && !needsRemount) { + scheduleFibersWithFamiliesRecursively(child, updatedFamilies, staleFamilies); } - instance = instance.return; + if (sibling !== null) { + scheduleFibersWithFamiliesRecursively(sibling, updatedFamilies, staleFamilies); + } } - - return listeners; } -function getParent(inst) { - if (inst === null) { - return null; +var findHostInstancesForRefresh = function (root, families) { + { + var hostInstances = new Set(); + var types = new Set(families.map(function (family) { + return family.current; + })); + findHostInstancesForMatchingFibersRecursively(root.current, types, hostInstances); + return hostInstances; } +}; - do { - // $FlowFixMe[incompatible-use] found when upgrading Flow - inst = inst.return; // TODO: If this is a HostRoot we might want to bail out. - // That is depending on if we want nested subtrees (layers) to bubble - // events to their parent. We could also go through parentNode on the - // host node but that wouldn't work for React Native and doesn't let us - // do the portal feature. - } while (inst && inst.tag !== HostComponent && inst.tag !== HostSingleton); +function findHostInstancesForMatchingFibersRecursively(fiber, types, hostInstances) { + { + var child = fiber.child, + sibling = fiber.sibling, + tag = fiber.tag, + type = fiber.type; + var candidateType = null; - if (inst) { - return inst; - } + switch (tag) { + case FunctionComponent: + case SimpleMemoComponent: + case ClassComponent: + candidateType = type; + break; - return null; -} -/** - * Return the lowest common ancestor of A and B, or null if they are in - * different trees. - */ + case ForwardRef: + candidateType = type.render; + break; + } + var didMatch = false; -function getLowestCommonAncestor(instA, instB) { - var nodeA = instA; - var nodeB = instB; - var depthA = 0; + if (candidateType !== null) { + if (types.has(candidateType)) { + didMatch = true; + } + } - for (var tempA = nodeA; tempA; tempA = getParent(tempA)) { - depthA++; + if (didMatch) { + // We have a match. This only drills down to the closest host components. + // There's no need to search deeper because for the purpose of giving + // visual feedback, "flashing" outermost parent rectangles is sufficient. + findHostInstancesForFiberShallowly(fiber, hostInstances); + } else { + // If there's no match, maybe there will be one further down in the child tree. + if (child !== null) { + findHostInstancesForMatchingFibersRecursively(child, types, hostInstances); + } + } + + if (sibling !== null) { + findHostInstancesForMatchingFibersRecursively(sibling, types, hostInstances); + } } +} - var depthB = 0; +function findHostInstancesForFiberShallowly(fiber, hostInstances) { + { + var foundHostInstances = findChildHostInstancesForFiberShallowly(fiber, hostInstances); - for (var tempB = nodeB; tempB; tempB = getParent(tempB)) { - depthB++; - } // If A is deeper, crawl up. + if (foundHostInstances) { + return; + } // If we didn't find any host children, fallback to closest host parent. - while (depthA - depthB > 0) { - nodeA = getParent(nodeA); - depthA--; - } // If B is deeper, crawl up. + var node = fiber; + while (true) { + switch (node.tag) { + case HostSingleton: + case HostComponent: + hostInstances.add(node.stateNode); + return; - while (depthB - depthA > 0) { - nodeB = getParent(nodeB); - depthB--; - } // Walk in lockstep until we find a match. + case HostPortal: + hostInstances.add(node.stateNode.containerInfo); + return; + case HostRoot: + hostInstances.add(node.stateNode.containerInfo); + return; + } - var depth = depthA; + if (node.return === null) { + throw new Error('Expected to reach root first.'); + } - while (depth--) { - if (nodeA === nodeB || nodeB !== null && nodeA === nodeB.alternate) { - return nodeA; + node = node.return; } - - nodeA = getParent(nodeA); - nodeB = getParent(nodeB); } - - return null; } -function accumulateEnterLeaveListenersForEvent(dispatchQueue, event, target, common, inCapturePhase) { - var registrationName = event._reactName; - var listeners = []; - var instance = target; +function findChildHostInstancesForFiberShallowly(fiber, hostInstances) { + { + var node = fiber; + var foundHostInstances = false; - while (instance !== null) { - if (instance === common) { - break; - } + while (true) { + if (node.tag === HostComponent || node.tag === HostHoistable || (node.tag === HostSingleton )) { + // We got a match. + foundHostInstances = true; + hostInstances.add(node.stateNode); // There may still be more, so keep searching. + } else if (node.child !== null) { + node.child.return = node; + node = node.child; + continue; + } - var _instance4 = instance, - alternate = _instance4.alternate, - stateNode = _instance4.stateNode, - tag = _instance4.tag; + if (node === fiber) { + return foundHostInstances; + } - if (alternate !== null && alternate === common) { - break; + while (node.sibling === null) { + if (node.return === null || node.return === fiber) { + return foundHostInstances; + } + + node = node.return; + } + + node.sibling.return = node.return; + node = node.sibling; } + } - if ((tag === HostComponent || tag === HostHoistable || tag === HostSingleton) && stateNode !== null) { - var currentTarget = stateNode; + return false; +} - if (inCapturePhase) { - var captureListener = getListener(instance, registrationName); +var ReactStrictModeWarnings = { + recordUnsafeLifecycleWarnings: function (fiber, instance) {}, + flushPendingUnsafeLifecycleWarnings: function () {}, + recordLegacyContextWarning: function (fiber, instance) {}, + flushLegacyContextWarning: function () {}, + discardPendingWarnings: function () {} +}; - if (captureListener != null) { - listeners.unshift(createDispatchListener(instance, captureListener, currentTarget)); - } - } else if (!inCapturePhase) { - var bubbleListener = getListener(instance, registrationName); +{ + var findStrictRoot = function (fiber) { + var maybeStrictRoot = null; + var node = fiber; - if (bubbleListener != null) { - listeners.push(createDispatchListener(instance, bubbleListener, currentTarget)); - } + while (node !== null) { + if (node.mode & StrictLegacyMode) { + maybeStrictRoot = node; } + + node = node.return; } - instance = instance.return; - } + return maybeStrictRoot; + }; - if (listeners.length !== 0) { - dispatchQueue.push({ - event: event, - listeners: listeners + var setToSortedString = function (set) { + var array = []; + set.forEach(function (value) { + array.push(value); }); - } -} // We should only use this function for: -// - EnterLeaveEventPlugin -// This is because we only process this plugin -// in the bubble phase, so we need to accumulate two -// phase event listeners. + return array.sort().join(', '); + }; + var pendingComponentWillMountWarnings = []; + var pendingUNSAFE_ComponentWillMountWarnings = []; + var pendingComponentWillReceivePropsWarnings = []; + var pendingUNSAFE_ComponentWillReceivePropsWarnings = []; + var pendingComponentWillUpdateWarnings = []; + var pendingUNSAFE_ComponentWillUpdateWarnings = []; // Tracks components we have already warned about. -function accumulateEnterLeaveTwoPhaseListeners(dispatchQueue, leaveEvent, enterEvent, from, to) { - var common = from && to ? getLowestCommonAncestor(from, to) : null; + var didWarnAboutUnsafeLifecycles = new Set(); - if (from !== null) { - accumulateEnterLeaveListenersForEvent(dispatchQueue, leaveEvent, from, common, false); - } + ReactStrictModeWarnings.recordUnsafeLifecycleWarnings = function (fiber, instance) { + // Dedupe strategy: Warn once per component. + if (didWarnAboutUnsafeLifecycles.has(fiber.type)) { + return; + } - if (to !== null && enterEvent !== null) { - accumulateEnterLeaveListenersForEvent(dispatchQueue, enterEvent, to, common, true); - } -} -function getListenerSetKey(domEventName, capture) { - return domEventName + "__" + (capture ? 'capture' : 'bubble'); -} + if (typeof instance.componentWillMount === 'function' && // Don't warn about react-lifecycles-compat polyfilled components. + instance.componentWillMount.__suppressDeprecationWarning !== true) { + pendingComponentWillMountWarnings.push(fiber); + } -var didWarnControlledToUncontrolled = false; -var didWarnUncontrolledToControlled = false; -var didWarnFormActionType = false; -var didWarnFormActionName = false; -var didWarnFormActionTarget = false; -var didWarnFormActionMethod = false; -var didWarnForNewBooleanPropsWithEmptyValue; -var canDiffStyleForHydrationWarning; + if (fiber.mode & StrictLegacyMode && typeof instance.UNSAFE_componentWillMount === 'function') { + pendingUNSAFE_ComponentWillMountWarnings.push(fiber); + } -{ - didWarnForNewBooleanPropsWithEmptyValue = {}; // IE 11 parses & normalizes the style attribute as opposed to other - // browsers. It adds spaces and sorts the properties in some - // non-alphabetical order. Handling that would require sorting CSS - // properties in the client & server versions or applying - // `expectedStyle` to a temporary DOM node to read its `style` attribute - // normalized. Since it only affects IE, we're skipping style warnings - // in that browser completely in favor of doing all that work. - // See https://github.com/facebook/react/issues/11807 + if (typeof instance.componentWillReceiveProps === 'function' && instance.componentWillReceiveProps.__suppressDeprecationWarning !== true) { + pendingComponentWillReceivePropsWarnings.push(fiber); + } - canDiffStyleForHydrationWarning = disableIEWorkarounds ; -} + if (fiber.mode & StrictLegacyMode && typeof instance.UNSAFE_componentWillReceiveProps === 'function') { + pendingUNSAFE_ComponentWillReceivePropsWarnings.push(fiber); + } -function validatePropertiesInDevelopment(type, props) { - { - validateProperties$2(type, props); - validateProperties$1(type, props); - validateProperties(type, props, { - registrationNameDependencies: registrationNameDependencies, - possibleRegistrationNames: possibleRegistrationNames - }); + if (typeof instance.componentWillUpdate === 'function' && instance.componentWillUpdate.__suppressDeprecationWarning !== true) { + pendingComponentWillUpdateWarnings.push(fiber); + } - if (props.contentEditable && !props.suppressContentEditableWarning && props.children != null) { - error('A component is `contentEditable` and contains `children` managed by ' + 'React. It is now your responsibility to guarantee that none of ' + 'those nodes are unexpectedly modified or duplicated. This is ' + 'probably not intentional.'); + if (fiber.mode & StrictLegacyMode && typeof instance.UNSAFE_componentWillUpdate === 'function') { + pendingUNSAFE_ComponentWillUpdateWarnings.push(fiber); } - } -} + }; -function validateFormActionInDevelopment(tag, key, value, props) { - { - if (value == null) { - return; + ReactStrictModeWarnings.flushPendingUnsafeLifecycleWarnings = function () { + // We do an initial pass to gather component names + var componentWillMountUniqueNames = new Set(); + + if (pendingComponentWillMountWarnings.length > 0) { + pendingComponentWillMountWarnings.forEach(function (fiber) { + componentWillMountUniqueNames.add(getComponentNameFromFiber(fiber) || 'Component'); + didWarnAboutUnsafeLifecycles.add(fiber.type); + }); + pendingComponentWillMountWarnings = []; } - if (tag === 'form') { - if (key === 'formAction') { - error('You can only pass the formAction prop to or