From 03ca2fb303d25b963697e5165cc46701f6867ddd Mon Sep 17 00:00:00 2001 From: eps1lon Date: Thu, 16 May 2024 16:32:47 -0700 Subject: [PATCH 1/6] Switch to React RC --- scripts/sync-react.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/sync-react.js b/scripts/sync-react.js index d7663ebf1cf61..34f3dd398cde3 100644 --- a/scripts/sync-react.js +++ b/scripts/sync-react.js @@ -237,7 +237,7 @@ async function getChangelogFromGitHub(baseSha, newSha) { return changelog.length > 0 ? changelog.join('\n') : null } -sync('beta') +sync('rc') .then(() => sync('experimental')) .catch((error) => { console.error(error) From 71ddc78b7e169b2feb53d2ec68df3e676c0791df Mon Sep 17 00:00:00 2001 From: Janka Uryga Date: Tue, 21 May 2024 12:18:23 +0200 Subject: [PATCH 2/6] test: look for for "rc" instead of "beta" in react version --- test/e2e/app-dir/rsc-basic/rsc-basic.test.ts | 2 +- test/production/custom-server/custom-server.test.ts | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/test/e2e/app-dir/rsc-basic/rsc-basic.test.ts b/test/e2e/app-dir/rsc-basic/rsc-basic.test.ts index 2fd7c3fe78e15..32f9638af9bf0 100644 --- a/test/e2e/app-dir/rsc-basic/rsc-basic.test.ts +++ b/test/e2e/app-dir/rsc-basic/rsc-basic.test.ts @@ -470,7 +470,7 @@ describe('app dir - rsc basics', () => { // TODO: (PPR) remove once PPR is stable const bundledReactVersionPattern = - process.env.__NEXT_EXPERIMENTAL_PPR === 'true' ? '-experimental-' : '-beta-' + process.env.__NEXT_EXPERIMENTAL_PPR === 'true' ? '-experimental-' : '-rc-' // TODO: (React 19) During Beta, bundled and installed version match. it.skip('should not use bundled react for pages with app', async () => { diff --git a/test/production/custom-server/custom-server.test.ts b/test/production/custom-server/custom-server.test.ts index 9a7c6db3b1eaf..89e601a2bd241 100644 --- a/test/production/custom-server/custom-server.test.ts +++ b/test/production/custom-server/custom-server.test.ts @@ -20,16 +20,16 @@ describe('custom server', () => { }) describe('with app dir', () => { - it('should render app with react beta', async () => { + it('should render app with react rc', async () => { const $ = await next.render$(`/1`) - expect($('body').text()).toMatch(/app: .+-beta/) + expect($('body').text()).toMatch(/app: .+-rc/) }) it('should render pages with installed react', async () => { const $ = await next.render$(`/2`) expect($('body').text()).toMatch(/pages:/) - // TODO: should not match beta once React 19 stable is out - expect($('body').text()).toMatch(/beta/) + // TODO: should not match rc once React 19 stable is out + expect($('body').text()).toMatch(/rc/) }) }) }) From 16989f0ea4d1bd45aa58788fc1be9be7d04482c0 Mon Sep 17 00:00:00 2001 From: Janka Uryga Date: Tue, 21 May 2024 20:36:15 +0200 Subject: [PATCH 3/6] Update React from 04b058868c to 8f3c0525f9 --- package.json | 32 +- packages/create-next-app/templates/index.ts | 4 +- packages/next/package.json | 4 +- .../cjs/react-dom-client.development.js | 39541 +++++++-------- .../cjs/react-dom-client.production.js | 8795 ++-- .../cjs/react-dom-profiling.development.js | 39541 +++++++-------- .../cjs/react-dom-profiling.profiling.js | 6721 +-- ...t-dom-server-legacy.browser.development.js | 5 +- ...ct-dom-server-legacy.browser.production.js | 2 +- ...eact-dom-server-legacy.node.development.js | 5 +- ...react-dom-server-legacy.node.production.js | 2 +- .../react-dom-server.browser.development.js | 5 +- .../react-dom-server.browser.production.js | 2 +- .../cjs/react-dom-server.bun.production.js | 2 +- .../cjs/react-dom-server.edge.development.js | 5 +- .../cjs/react-dom-server.edge.production.js | 2 +- .../cjs/react-dom-server.node.development.js | 5 +- .../cjs/react-dom-server.node.production.js | 2 +- .../react-dom-unstable_testing.development.js | 40349 ++++++++-------- .../react-dom-unstable_testing.production.js | 9253 ++-- .../cjs/react-dom.development.js | 2 +- .../cjs/react-dom.production.js | 2 +- .../react-dom-experimental/package.json | 4 +- .../cjs/react-dom-client.development.js | 39323 +++++++-------- .../cjs/react-dom-client.production.js | 16725 +++---- .../cjs/react-dom-profiling.development.js | 39323 +++++++-------- .../cjs/react-dom-profiling.profiling.js | 6183 +-- ...t-dom-server-legacy.browser.development.js | 5 +- ...ct-dom-server-legacy.browser.production.js | 2 +- ...eact-dom-server-legacy.node.development.js | 5 +- ...react-dom-server-legacy.node.production.js | 2 +- .../react-dom-server.browser.development.js | 5 +- .../react-dom-server.browser.production.js | 2 +- .../cjs/react-dom-server.bun.production.js | 2 +- .../cjs/react-dom-server.edge.development.js | 5 +- .../cjs/react-dom-server.edge.production.js | 2 +- .../cjs/react-dom-server.node.development.js | 5 +- .../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 +- .../next/src/compiled/react-is/package.json | 2 +- ...om-turbopack-client.browser.development.js | 237 +- ...dom-turbopack-client.browser.production.js | 256 +- ...r-dom-turbopack-client.edge.development.js | 237 +- ...er-dom-turbopack-client.edge.production.js | 256 +- ...r-dom-turbopack-client.node.development.js | 235 +- ...er-dom-turbopack-client.node.production.js | 254 +- ...opack-client.node.unbundled.development.js | 235 +- ...bopack-client.node.unbundled.production.js | 254 +- ...om-turbopack-server.browser.development.js | 708 +- ...dom-turbopack-server.browser.production.js | 459 +- ...r-dom-turbopack-server.edge.development.js | 715 +- ...er-dom-turbopack-server.edge.production.js | 459 +- ...r-dom-turbopack-server.node.development.js | 718 +- ...er-dom-turbopack-server.node.production.js | 479 +- ...opack-server.node.unbundled.development.js | 718 +- ...bopack-server.node.unbundled.production.js | 479 +- .../package.json | 4 +- ...om-turbopack-client.browser.development.js | 1003 +- ...dom-turbopack-client.browser.production.js | 937 +- ...r-dom-turbopack-client.edge.development.js | 1003 +- ...er-dom-turbopack-client.edge.production.js | 937 +- ...r-dom-turbopack-client.node.development.js | 1001 +- ...er-dom-turbopack-client.node.production.js | 912 +- ...opack-client.node.unbundled.development.js | 1001 +- ...bopack-client.node.unbundled.production.js | 912 +- ...om-turbopack-server.browser.development.js | 1530 +- ...dom-turbopack-server.browser.production.js | 993 +- ...r-dom-turbopack-server.edge.development.js | 1532 +- ...er-dom-turbopack-server.edge.production.js | 993 +- ...r-dom-turbopack-server.node.development.js | 1496 +- ...er-dom-turbopack-server.node.production.js | 1021 +- ...opack-server.node.unbundled.development.js | 1496 +- ...bopack-server.node.unbundled.production.js | 1021 +- .../react-server-dom-turbopack/package.json | 4 +- ...-dom-webpack-client.browser.development.js | 237 +- ...r-dom-webpack-client.browser.production.js | 256 +- ...ver-dom-webpack-client.edge.development.js | 237 +- ...rver-dom-webpack-client.edge.production.js | 256 +- ...ver-dom-webpack-client.node.development.js | 235 +- ...rver-dom-webpack-client.node.production.js | 254 +- ...bpack-client.node.unbundled.development.js | 235 +- ...ebpack-client.node.unbundled.production.js | 254 +- ...-dom-webpack-server.browser.development.js | 658 +- ...r-dom-webpack-server.browser.production.js | 437 +- ...ver-dom-webpack-server.edge.development.js | 665 +- ...rver-dom-webpack-server.edge.production.js | 437 +- ...ver-dom-webpack-server.node.development.js | 663 +- ...rver-dom-webpack-server.node.production.js | 445 +- ...bpack-server.node.unbundled.development.js | 663 +- ...ebpack-server.node.unbundled.production.js | 445 +- .../package.json | 4 +- ...-dom-webpack-client.browser.development.js | 1003 +- ...r-dom-webpack-client.browser.production.js | 937 +- ...ver-dom-webpack-client.edge.development.js | 1003 +- ...rver-dom-webpack-client.edge.production.js | 937 +- ...ver-dom-webpack-client.node.development.js | 1001 +- ...rver-dom-webpack-client.node.production.js | 912 +- ...bpack-client.node.unbundled.development.js | 1001 +- ...ebpack-client.node.unbundled.production.js | 912 +- ...-dom-webpack-server.browser.development.js | 1480 +- ...r-dom-webpack-server.browser.production.js | 971 +- ...ver-dom-webpack-server.edge.development.js | 1482 +- ...rver-dom-webpack-server.edge.production.js | 971 +- ...ver-dom-webpack-server.node.development.js | 1441 +- ...rver-dom-webpack-server.node.production.js | 987 +- ...bpack-server.node.unbundled.development.js | 1441 +- ...ebpack-server.node.unbundled.production.js | 987 +- .../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 +- test/.stats-app/package.json | 6 +- .../acceptance-app/ReactRefresh.test.ts | 4 +- .../ReactRefreshLogBox-builtins.test.ts | 4 +- .../ReactRefreshLogBox-scss.test.ts | 4 +- .../acceptance-app/ReactRefreshLogBox.test.ts | 4 +- .../ReactRefreshLogBoxMisc.test.ts | 4 +- .../acceptance-app/ReactRefreshModule.test.ts | 4 +- .../ReactRefreshRegression.test.ts | 4 +- .../ReactRefreshRequire.test.ts | 4 +- .../acceptance-app/editor-links.test.ts | 4 +- .../acceptance-app/error-message-url.test.ts | 4 +- .../acceptance-app/error-recovery.test.ts | 4 +- .../acceptance-app/hydration-error.test.ts | 4 +- .../acceptance-app/invalid-imports.test.ts | 4 +- .../acceptance-app/rsc-build-errors.test.ts | 4 +- .../acceptance-app/server-components.test.ts | 4 +- .../acceptance/hydration-error.test.ts | 4 +- ...component-compiler-errors-in-pages.test.ts | 4 +- .../next-font/deprecated-package.test.ts | 4 +- .../app-action-allowed-origins.test.ts | 4 +- .../app-action-disallowed-origins.test.ts | 4 +- .../app-dir/actions/app-action-export.test.ts | 4 +- .../actions/app-action-form-state.test.ts | 4 +- ...app-action-progressive-enhancement.test.ts | 4 +- .../app-action-size-limit-invalid.test.ts | 4 +- test/e2e/app-dir/actions/app-action.test.ts | 4 +- .../app-css-pageextensions/index.test.ts | 4 +- test/e2e/app-dir/app-css/index.test.ts | 4 +- .../app-routes-client-component.test.ts | 4 +- .../create-root-layout.test.ts | 12 +- .../navigation.test.ts | 4 +- .../rewrites-redirects.test.ts | 4 +- .../child-a-tag-error.test.ts | 4 +- .../e2e/new-link-behavior/material-ui.test.ts | 4 +- test/e2e/new-link-behavior/stitches.test.ts | 4 +- test/e2e/next-font/with-proxy.test.ts | 4 +- test/e2e/next-script/index.test.ts | 32 +- .../first-time-setup-js/package.json | 4 +- .../first-time-setup-ts/package.json | 4 +- test/e2e/switchable-runtime/index.test.ts | 4 +- test/e2e/transpile-packages/index.test.ts | 4 +- test/e2e/yarn-pnp/test/utils.ts | 4 +- test/lib/next-modes/base.ts | 3 +- 170 files changed, 162518 insertions(+), 132525 deletions(-) diff --git a/package.json b/package.json index b2f5809186e40..a510cac8cced4 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-8f3c0525f9-20240521", "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-8f3c0525f9-20240521", + "react-dom": "19.0.0-rc-8f3c0525f9-20240521", "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-8f3c0525f9-20240521", + "react-dom-experimental-builtin": "npm:react-dom@0.0.0-experimental-8f3c0525f9-20240521", + "react-experimental-builtin": "npm:react@0.0.0-experimental-8f3c0525f9-20240521", + "react-server-dom-turbopack": "19.0.0-rc-8f3c0525f9-20240521", + "react-server-dom-turbopack-experimental": "npm:react-server-dom-turbopack@0.0.0-experimental-8f3c0525f9-20240521", + "react-server-dom-webpack": "19.0.0-rc-8f3c0525f9-20240521", + "react-server-dom-webpack-experimental": "npm:react-server-dom-webpack@0.0.0-experimental-8f3c0525f9-20240521", "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-8f3c0525f9-20240521", + "scheduler-experimental-builtin": "npm:scheduler@0.0.0-experimental-8f3c0525f9-20240521", "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-8f3c0525f9-20240521", + "react-dom": "19.0.0-rc-8f3c0525f9-20240521", + "react-is": "19.0.0-rc-8f3c0525f9-20240521", + "scheduler": "0.25.0-rc-8f3c0525f9-20240521" }, "engines": { "node": ">=18.17.0", diff --git a/packages/create-next-app/templates/index.ts b/packages/create-next-app/templates/index.ts index 53b6fe87fab10..fe6b4ce6737ed 100644 --- a/packages/create-next-app/templates/index.ts +++ b/packages/create-next-app/templates/index.ts @@ -184,8 +184,8 @@ export const installTemplate = async ({ * Default dependencies. */ dependencies: { - react: "19.0.0-beta-04b058868c-20240508", - "react-dom": "19.0.0-beta-04b058868c-20240508", + react: "19.0.0-rc-8f3c0525f9-20240521", + "react-dom": "19.0.0-rc-8f3c0525f9-20240521", next: version, }, devDependencies: {}, diff --git a/packages/next/package.json b/packages/next/package.json index 66b3f518dfe0f..6ba2d20837131 100644 --- a/packages/next/package.json +++ b/packages/next/package.json @@ -105,8 +105,8 @@ "@opentelemetry/api": "^1.1.0", "@playwright/test": "^1.41.2", "babel-plugin-react-compiler": "*", - "react": "19.0.0-beta-04b058868c-20240508", - "react-dom": "19.0.0-beta-04b058868c-20240508", + "react": "19.0.0-rc-8f3c0525f9-20240521", + "react-dom": "19.0.0-rc-8f3c0525f9-20240521", "sass": "^1.3.0" }, "peerDependenciesMeta": { 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..a48492e5b3512 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 @@ -5490,6 +5490,9 @@ var possibleStandardNames = { pointsatx: 'pointsAtX', pointsaty: 'pointsAtY', pointsatz: 'pointsAtZ', + popover: 'popover', + popovertarget: 'popoverTarget', + popovertargetaction: 'popoverTargetAction', prefix: 'prefix', preservealpha: 'preserveAlpha', preserveaspectratio: 'preserveAspectRatio', @@ -7030,6 +7033,13 @@ var WheelEventInterface = assign({}, MouseEventInterface, { var SyntheticWheelEvent = createSyntheticEvent(WheelEventInterface); +var ToggleEventInterface = assign({}, EventInterface, { + newState: 0, + oldState: 0 +}); + +var SyntheticToggleEvent = createSyntheticEvent(ToggleEventInterface); + var END_KEYCODES = [9, 13, 27, 32]; // Tab, Return, Esc, Space var START_KEYCODE = 229; @@ -8540,7 +8550,7 @@ var topLevelEventsToReactNames = new Map(); // NOTE: Capitalization is important // // prettier-ignore -var simpleEventPluginEvents = ['abort', 'auxClick', 'cancel', 'canPlay', 'canPlayThrough', 'click', 'close', 'contextMenu', 'copy', 'cut', 'drag', 'dragEnd', 'dragEnter', 'dragExit', 'dragLeave', 'dragOver', 'dragStart', 'drop', 'durationChange', 'emptied', 'encrypted', 'ended', 'error', 'gotPointerCapture', 'input', 'invalid', 'keyDown', 'keyPress', 'keyUp', 'load', 'loadedData', 'loadedMetadata', 'loadStart', 'lostPointerCapture', 'mouseDown', 'mouseMove', 'mouseOut', 'mouseOver', 'mouseUp', 'paste', 'pause', 'play', 'playing', 'pointerCancel', 'pointerDown', 'pointerMove', 'pointerOut', 'pointerOver', 'pointerUp', 'progress', 'rateChange', 'reset', 'resize', 'seeked', 'seeking', 'stalled', 'submit', 'suspend', 'timeUpdate', 'touchCancel', 'touchEnd', 'touchStart', 'volumeChange', 'scroll', 'scrollEnd', 'toggle', 'touchMove', 'waiting', 'wheel']; +var simpleEventPluginEvents = ['abort', 'auxClick', 'beforeToggle', 'cancel', 'canPlay', 'canPlayThrough', 'click', 'close', 'contextMenu', 'copy', 'cut', 'drag', 'dragEnd', 'dragEnter', 'dragExit', 'dragLeave', 'dragOver', 'dragStart', 'drop', 'durationChange', 'emptied', 'encrypted', 'ended', 'error', 'gotPointerCapture', 'input', 'invalid', 'keyDown', 'keyPress', 'keyUp', 'load', 'loadedData', 'loadedMetadata', 'loadStart', 'lostPointerCapture', 'mouseDown', 'mouseMove', 'mouseOut', 'mouseOver', 'mouseUp', 'paste', 'pause', 'play', 'playing', 'pointerCancel', 'pointerDown', 'pointerMove', 'pointerOut', 'pointerOver', 'pointerUp', 'progress', 'rateChange', 'reset', 'resize', 'seeked', 'seeking', 'stalled', 'submit', 'suspend', 'timeUpdate', 'touchCancel', 'touchEnd', 'touchStart', 'volumeChange', 'scroll', 'scrollEnd', 'toggle', 'touchMove', 'waiting', 'wheel']; function registerSimpleEvent(domEventName, reactName) { topLevelEventsToReactNames.set(domEventName, reactName); @@ -8689,6 +8699,12 @@ function extractEvents$2(dispatchQueue, domEventName, targetInst, nativeEvent, n case 'pointerup': SyntheticEventCtor = SyntheticPointerEvent; break; + + case 'toggle': + case 'beforetoggle': + // MDN claims
should not receive ToggleEvent contradicting the spec: https://html.spec.whatwg.org/multipage/indices.html#event-toggle + SyntheticEventCtor = SyntheticToggleEvent; + break; } var inCapturePhase = (eventSystemFlags & IS_CAPTURE_PHASE) !== 0; @@ -8718,24829 +8734,24895 @@ 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; +} - event.preventDefault(); - var formData; +function markUpdateLaneFromFiberToRoot(sourceFiber, update, lane) { + // Update the source fiber's lanes + sourceFiber.lanes = mergeLanes(sourceFiber.lanes, lane); + var alternate = sourceFiber.alternate; - 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 (alternate !== null) { + alternate.lanes = mergeLanes(alternate.lanes, lane); + } // Walk the parent path to the root and update the child lanes. - if (form.id) { - temp.setAttribute('form', form.id); - } - submitter.parentNode.insertBefore(temp, submitter); - formData = new FormData(form); - temp.parentNode.removeChild(temp); - } else { - formData = new FormData(form); + var isHidden = false; + var parent = sourceFiber.return; + var node = sourceFiber; + + 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); - - if (!shouldLog) { - return; - } - } 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. +function detectUpdateOnUnmountedFiber(sourceFiber, parent) { + { + var alternate = parent.alternate; - 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); + if (alternate === null && (parent.flags & (Placement | Hydrating)) !== NoFlags$1) { + warnAboutUpdateOnNotYetMountedFiberInDEV(sourceFiber); + } } -} // 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; - } - - 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 (needsRemount || needsRender) { + var root = enqueueConcurrentRenderForLane(fiber, SyncLane); - 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