diff --git a/compiled/facebook-www/REVISION b/compiled/facebook-www/REVISION index 40a68e4f05322..40fbc64921c16 100644 --- a/compiled/facebook-www/REVISION +++ b/compiled/facebook-www/REVISION @@ -1 +1 @@ -996e4c0d56dabab382ca932cd5b8517e63020999 +9c09c1cd62ef862df91bcb4df4271917629d6963 diff --git a/compiled/facebook-www/REVISION_TRANSFORMS b/compiled/facebook-www/REVISION_TRANSFORMS index 40a68e4f05322..40fbc64921c16 100644 --- a/compiled/facebook-www/REVISION_TRANSFORMS +++ b/compiled/facebook-www/REVISION_TRANSFORMS @@ -1 +1 @@ -996e4c0d56dabab382ca932cd5b8517e63020999 +9c09c1cd62ef862df91bcb4df4271917629d6963 diff --git a/compiled/facebook-www/React-dev.classic.js b/compiled/facebook-www/React-dev.classic.js index edd3cc7ee5a0f..80cbe2ed22365 100644 --- a/compiled/facebook-www/React-dev.classic.js +++ b/compiled/facebook-www/React-dev.classic.js @@ -27,7 +27,7 @@ if ( } "use strict"; -var ReactVersion = "18.3.0-www-classic-996e4c0d5-20221212"; +var ReactVersion = "18.3.0-www-classic-9c09c1cd6-20221212"; // ATTENTION // When adding new symbols to this file, diff --git a/compiled/facebook-www/React-dev.modern.js b/compiled/facebook-www/React-dev.modern.js index e8f4c8186123a..db3c2dc2a44e9 100644 --- a/compiled/facebook-www/React-dev.modern.js +++ b/compiled/facebook-www/React-dev.modern.js @@ -27,7 +27,7 @@ if ( } "use strict"; -var ReactVersion = "18.3.0-www-modern-996e4c0d5-20221212"; +var ReactVersion = "18.3.0-www-modern-9c09c1cd6-20221212"; // ATTENTION // When adding new symbols to this file, diff --git a/compiled/facebook-www/React-prod.classic.js b/compiled/facebook-www/React-prod.classic.js index a6b85c03d3787..7663e3e5d1cde 100644 --- a/compiled/facebook-www/React-prod.classic.js +++ b/compiled/facebook-www/React-prod.classic.js @@ -643,4 +643,4 @@ exports.useSyncExternalStore = function( ); }; exports.useTransition = useTransition; -exports.version = "18.3.0-www-classic-996e4c0d5-20221212"; +exports.version = "18.3.0-www-classic-9c09c1cd6-20221212"; diff --git a/compiled/facebook-www/React-prod.modern.js b/compiled/facebook-www/React-prod.modern.js index 15cd5e85220cd..acea5a1c7eb9e 100644 --- a/compiled/facebook-www/React-prod.modern.js +++ b/compiled/facebook-www/React-prod.modern.js @@ -635,4 +635,4 @@ exports.useSyncExternalStore = function( ); }; exports.useTransition = useTransition; -exports.version = "18.3.0-www-modern-996e4c0d5-20221212"; +exports.version = "18.3.0-www-modern-9c09c1cd6-20221212"; diff --git a/compiled/facebook-www/React-profiling.classic.js b/compiled/facebook-www/React-profiling.classic.js index ff9c18959462b..1ac554eefd62a 100644 --- a/compiled/facebook-www/React-profiling.classic.js +++ b/compiled/facebook-www/React-profiling.classic.js @@ -654,7 +654,7 @@ exports.useSyncExternalStore = function( ); }; exports.useTransition = useTransition; -exports.version = "18.3.0-www-classic-996e4c0d5-20221212"; +exports.version = "18.3.0-www-classic-9c09c1cd6-20221212"; /* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */ if ( diff --git a/compiled/facebook-www/React-profiling.modern.js b/compiled/facebook-www/React-profiling.modern.js index 136e16a1fee0c..ad5a6eb01f7a5 100644 --- a/compiled/facebook-www/React-profiling.modern.js +++ b/compiled/facebook-www/React-profiling.modern.js @@ -646,7 +646,7 @@ exports.useSyncExternalStore = function( ); }; exports.useTransition = useTransition; -exports.version = "18.3.0-www-modern-996e4c0d5-20221212"; +exports.version = "18.3.0-www-modern-9c09c1cd6-20221212"; /* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */ if ( diff --git a/compiled/facebook-www/ReactART-dev.classic.js b/compiled/facebook-www/ReactART-dev.classic.js index ea8aec39d5c2b..57768ee70413c 100644 --- a/compiled/facebook-www/ReactART-dev.classic.js +++ b/compiled/facebook-www/ReactART-dev.classic.js @@ -69,7 +69,7 @@ function _assertThisInitialized(self) { return self; } -var ReactVersion = "18.3.0-www-classic-996e4c0d5-20221212"; +var ReactVersion = "18.3.0-www-classic-9c09c1cd6-20221212"; var LegacyRoot = 0; var ConcurrentRoot = 1; diff --git a/compiled/facebook-www/ReactART-dev.modern.js b/compiled/facebook-www/ReactART-dev.modern.js index 8a78a32e3e079..4138b6c22e9b8 100644 --- a/compiled/facebook-www/ReactART-dev.modern.js +++ b/compiled/facebook-www/ReactART-dev.modern.js @@ -69,7 +69,7 @@ function _assertThisInitialized(self) { return self; } -var ReactVersion = "18.3.0-www-modern-996e4c0d5-20221212"; +var ReactVersion = "18.3.0-www-modern-9c09c1cd6-20221212"; var LegacyRoot = 0; var ConcurrentRoot = 1; diff --git a/compiled/facebook-www/ReactART-prod.classic.js b/compiled/facebook-www/ReactART-prod.classic.js index 536e3ac6b57dc..4ead11de3e0b2 100644 --- a/compiled/facebook-www/ReactART-prod.classic.js +++ b/compiled/facebook-www/ReactART-prod.classic.js @@ -9807,7 +9807,7 @@ var slice = Array.prototype.slice, return null; }, bundleType: 0, - version: "18.3.0-www-classic-996e4c0d5-20221212", + version: "18.3.0-www-classic-9c09c1cd6-20221212", rendererPackageName: "react-art" }; var internals$jscomp$inline_1338 = { @@ -9838,7 +9838,7 @@ var internals$jscomp$inline_1338 = { scheduleRoot: null, setRefreshHandler: null, getCurrentFiber: null, - reconcilerVersion: "18.3.0-next-996e4c0d5-20221212" + reconcilerVersion: "18.3.0-next-9c09c1cd6-20221212" }; if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) { var hook$jscomp$inline_1339 = __REACT_DEVTOOLS_GLOBAL_HOOK__; diff --git a/compiled/facebook-www/ReactART-prod.modern.js b/compiled/facebook-www/ReactART-prod.modern.js index 4f4924a85c820..676386c415ed1 100644 --- a/compiled/facebook-www/ReactART-prod.modern.js +++ b/compiled/facebook-www/ReactART-prod.modern.js @@ -9474,7 +9474,7 @@ var slice = Array.prototype.slice, return null; }, bundleType: 0, - version: "18.3.0-www-modern-996e4c0d5-20221212", + version: "18.3.0-www-modern-9c09c1cd6-20221212", rendererPackageName: "react-art" }; var internals$jscomp$inline_1329 = { @@ -9505,7 +9505,7 @@ var internals$jscomp$inline_1329 = { scheduleRoot: null, setRefreshHandler: null, getCurrentFiber: null, - reconcilerVersion: "18.3.0-next-996e4c0d5-20221212" + reconcilerVersion: "18.3.0-next-9c09c1cd6-20221212" }; if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) { var hook$jscomp$inline_1330 = __REACT_DEVTOOLS_GLOBAL_HOOK__; diff --git a/compiled/facebook-www/ReactDOM-dev.classic.js b/compiled/facebook-www/ReactDOM-dev.classic.js index 08fa3d1d6cfb7..902025fe99f8d 100644 --- a/compiled/facebook-www/ReactDOM-dev.classic.js +++ b/compiled/facebook-www/ReactDOM-dev.classic.js @@ -42565,7 +42565,7 @@ function createFiberRoot( return root; } -var ReactVersion = "18.3.0-www-classic-996e4c0d5-20221212"; +var ReactVersion = "18.3.0-www-classic-9c09c1cd6-20221212"; function createPortal( children, diff --git a/compiled/facebook-www/ReactDOM-dev.modern.js b/compiled/facebook-www/ReactDOM-dev.modern.js index b189199ac737b..44ec222e5c89d 100644 --- a/compiled/facebook-www/ReactDOM-dev.modern.js +++ b/compiled/facebook-www/ReactDOM-dev.modern.js @@ -42289,7 +42289,7 @@ function createFiberRoot( return root; } -var ReactVersion = "18.3.0-www-modern-996e4c0d5-20221212"; +var ReactVersion = "18.3.0-www-modern-9c09c1cd6-20221212"; function createPortal( children, diff --git a/compiled/facebook-www/ReactDOM-prod.classic.js b/compiled/facebook-www/ReactDOM-prod.classic.js index 1efaa879ddd2c..f1e184f3bb8e0 100644 --- a/compiled/facebook-www/ReactDOM-prod.classic.js +++ b/compiled/facebook-www/ReactDOM-prod.classic.js @@ -15557,7 +15557,7 @@ Internals.Events = [ var devToolsConfig$jscomp$inline_1770 = { findFiberByHostInstance: getClosestInstanceFromNode, bundleType: 0, - version: "18.3.0-www-classic-996e4c0d5-20221212", + version: "18.3.0-www-classic-9c09c1cd6-20221212", rendererPackageName: "react-dom" }; var internals$jscomp$inline_2157 = { @@ -15587,7 +15587,7 @@ var internals$jscomp$inline_2157 = { scheduleRoot: null, setRefreshHandler: null, getCurrentFiber: null, - reconcilerVersion: "18.3.0-next-996e4c0d5-20221212" + reconcilerVersion: "18.3.0-next-9c09c1cd6-20221212" }; if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) { var hook$jscomp$inline_2158 = __REACT_DEVTOOLS_GLOBAL_HOOK__; @@ -15829,4 +15829,4 @@ exports.unstable_renderSubtreeIntoContainer = function( ); }; exports.unstable_runWithPriority = runWithPriority; -exports.version = "18.3.0-next-996e4c0d5-20221212"; +exports.version = "18.3.0-next-9c09c1cd6-20221212"; diff --git a/compiled/facebook-www/ReactDOM-prod.modern.js b/compiled/facebook-www/ReactDOM-prod.modern.js index 95a2d95e64af6..883bad84b4540 100644 --- a/compiled/facebook-www/ReactDOM-prod.modern.js +++ b/compiled/facebook-www/ReactDOM-prod.modern.js @@ -15118,7 +15118,7 @@ Internals.Events = [ var devToolsConfig$jscomp$inline_1738 = { findFiberByHostInstance: getClosestInstanceFromNode, bundleType: 0, - version: "18.3.0-www-modern-996e4c0d5-20221212", + version: "18.3.0-www-modern-9c09c1cd6-20221212", rendererPackageName: "react-dom" }; var internals$jscomp$inline_2132 = { @@ -15149,7 +15149,7 @@ var internals$jscomp$inline_2132 = { scheduleRoot: null, setRefreshHandler: null, getCurrentFiber: null, - reconcilerVersion: "18.3.0-next-996e4c0d5-20221212" + reconcilerVersion: "18.3.0-next-9c09c1cd6-20221212" }; if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) { var hook$jscomp$inline_2133 = __REACT_DEVTOOLS_GLOBAL_HOOK__; @@ -15337,4 +15337,4 @@ exports.unstable_flushControlled = function(fn) { } }; exports.unstable_runWithPriority = runWithPriority; -exports.version = "18.3.0-next-996e4c0d5-20221212"; +exports.version = "18.3.0-next-9c09c1cd6-20221212"; diff --git a/compiled/facebook-www/ReactDOM-profiling.classic.js b/compiled/facebook-www/ReactDOM-profiling.classic.js index d6fec4b6ea9b2..840c9021d73c7 100644 --- a/compiled/facebook-www/ReactDOM-profiling.classic.js +++ b/compiled/facebook-www/ReactDOM-profiling.classic.js @@ -16327,7 +16327,7 @@ Internals.Events = [ var devToolsConfig$jscomp$inline_1844 = { findFiberByHostInstance: getClosestInstanceFromNode, bundleType: 0, - version: "18.3.0-www-classic-996e4c0d5-20221212", + version: "18.3.0-www-classic-9c09c1cd6-20221212", rendererPackageName: "react-dom" }; (function(internals) { @@ -16371,7 +16371,7 @@ var devToolsConfig$jscomp$inline_1844 = { scheduleRoot: null, setRefreshHandler: null, getCurrentFiber: null, - reconcilerVersion: "18.3.0-next-996e4c0d5-20221212" + reconcilerVersion: "18.3.0-next-9c09c1cd6-20221212" }); assign(Internals, { ReactBrowserEventEmitter: { @@ -16600,7 +16600,7 @@ exports.unstable_renderSubtreeIntoContainer = function( ); }; exports.unstable_runWithPriority = runWithPriority; -exports.version = "18.3.0-next-996e4c0d5-20221212"; +exports.version = "18.3.0-next-9c09c1cd6-20221212"; /* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */ if ( diff --git a/compiled/facebook-www/ReactDOM-profiling.modern.js b/compiled/facebook-www/ReactDOM-profiling.modern.js index ba08b083d0ebd..c2d68c3cbb9e6 100644 --- a/compiled/facebook-www/ReactDOM-profiling.modern.js +++ b/compiled/facebook-www/ReactDOM-profiling.modern.js @@ -15878,7 +15878,7 @@ Internals.Events = [ var devToolsConfig$jscomp$inline_1812 = { findFiberByHostInstance: getClosestInstanceFromNode, bundleType: 0, - version: "18.3.0-www-modern-996e4c0d5-20221212", + version: "18.3.0-www-modern-9c09c1cd6-20221212", rendererPackageName: "react-dom" }; (function(internals) { @@ -15923,7 +15923,7 @@ var devToolsConfig$jscomp$inline_1812 = { scheduleRoot: null, setRefreshHandler: null, getCurrentFiber: null, - reconcilerVersion: "18.3.0-next-996e4c0d5-20221212" + reconcilerVersion: "18.3.0-next-9c09c1cd6-20221212" }); exports.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = Internals; exports.createPortal = function(children, container) { @@ -16098,7 +16098,7 @@ exports.unstable_flushControlled = function(fn) { } }; exports.unstable_runWithPriority = runWithPriority; -exports.version = "18.3.0-next-996e4c0d5-20221212"; +exports.version = "18.3.0-next-9c09c1cd6-20221212"; /* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */ if ( diff --git a/compiled/facebook-www/ReactDOMForked-dev.classic.js b/compiled/facebook-www/ReactDOMForked-dev.classic.js index 08fa3d1d6cfb7..902025fe99f8d 100644 --- a/compiled/facebook-www/ReactDOMForked-dev.classic.js +++ b/compiled/facebook-www/ReactDOMForked-dev.classic.js @@ -42565,7 +42565,7 @@ function createFiberRoot( return root; } -var ReactVersion = "18.3.0-www-classic-996e4c0d5-20221212"; +var ReactVersion = "18.3.0-www-classic-9c09c1cd6-20221212"; function createPortal( children, diff --git a/compiled/facebook-www/ReactDOMForked-dev.modern.js b/compiled/facebook-www/ReactDOMForked-dev.modern.js index b189199ac737b..44ec222e5c89d 100644 --- a/compiled/facebook-www/ReactDOMForked-dev.modern.js +++ b/compiled/facebook-www/ReactDOMForked-dev.modern.js @@ -42289,7 +42289,7 @@ function createFiberRoot( return root; } -var ReactVersion = "18.3.0-www-modern-996e4c0d5-20221212"; +var ReactVersion = "18.3.0-www-modern-9c09c1cd6-20221212"; function createPortal( children, diff --git a/compiled/facebook-www/ReactDOMForked-prod.classic.js b/compiled/facebook-www/ReactDOMForked-prod.classic.js index 1efaa879ddd2c..f1e184f3bb8e0 100644 --- a/compiled/facebook-www/ReactDOMForked-prod.classic.js +++ b/compiled/facebook-www/ReactDOMForked-prod.classic.js @@ -15557,7 +15557,7 @@ Internals.Events = [ var devToolsConfig$jscomp$inline_1770 = { findFiberByHostInstance: getClosestInstanceFromNode, bundleType: 0, - version: "18.3.0-www-classic-996e4c0d5-20221212", + version: "18.3.0-www-classic-9c09c1cd6-20221212", rendererPackageName: "react-dom" }; var internals$jscomp$inline_2157 = { @@ -15587,7 +15587,7 @@ var internals$jscomp$inline_2157 = { scheduleRoot: null, setRefreshHandler: null, getCurrentFiber: null, - reconcilerVersion: "18.3.0-next-996e4c0d5-20221212" + reconcilerVersion: "18.3.0-next-9c09c1cd6-20221212" }; if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) { var hook$jscomp$inline_2158 = __REACT_DEVTOOLS_GLOBAL_HOOK__; @@ -15829,4 +15829,4 @@ exports.unstable_renderSubtreeIntoContainer = function( ); }; exports.unstable_runWithPriority = runWithPriority; -exports.version = "18.3.0-next-996e4c0d5-20221212"; +exports.version = "18.3.0-next-9c09c1cd6-20221212"; diff --git a/compiled/facebook-www/ReactDOMForked-prod.modern.js b/compiled/facebook-www/ReactDOMForked-prod.modern.js index 95a2d95e64af6..883bad84b4540 100644 --- a/compiled/facebook-www/ReactDOMForked-prod.modern.js +++ b/compiled/facebook-www/ReactDOMForked-prod.modern.js @@ -15118,7 +15118,7 @@ Internals.Events = [ var devToolsConfig$jscomp$inline_1738 = { findFiberByHostInstance: getClosestInstanceFromNode, bundleType: 0, - version: "18.3.0-www-modern-996e4c0d5-20221212", + version: "18.3.0-www-modern-9c09c1cd6-20221212", rendererPackageName: "react-dom" }; var internals$jscomp$inline_2132 = { @@ -15149,7 +15149,7 @@ var internals$jscomp$inline_2132 = { scheduleRoot: null, setRefreshHandler: null, getCurrentFiber: null, - reconcilerVersion: "18.3.0-next-996e4c0d5-20221212" + reconcilerVersion: "18.3.0-next-9c09c1cd6-20221212" }; if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) { var hook$jscomp$inline_2133 = __REACT_DEVTOOLS_GLOBAL_HOOK__; @@ -15337,4 +15337,4 @@ exports.unstable_flushControlled = function(fn) { } }; exports.unstable_runWithPriority = runWithPriority; -exports.version = "18.3.0-next-996e4c0d5-20221212"; +exports.version = "18.3.0-next-9c09c1cd6-20221212"; diff --git a/compiled/facebook-www/ReactDOMForked-profiling.classic.js b/compiled/facebook-www/ReactDOMForked-profiling.classic.js index d6fec4b6ea9b2..840c9021d73c7 100644 --- a/compiled/facebook-www/ReactDOMForked-profiling.classic.js +++ b/compiled/facebook-www/ReactDOMForked-profiling.classic.js @@ -16327,7 +16327,7 @@ Internals.Events = [ var devToolsConfig$jscomp$inline_1844 = { findFiberByHostInstance: getClosestInstanceFromNode, bundleType: 0, - version: "18.3.0-www-classic-996e4c0d5-20221212", + version: "18.3.0-www-classic-9c09c1cd6-20221212", rendererPackageName: "react-dom" }; (function(internals) { @@ -16371,7 +16371,7 @@ var devToolsConfig$jscomp$inline_1844 = { scheduleRoot: null, setRefreshHandler: null, getCurrentFiber: null, - reconcilerVersion: "18.3.0-next-996e4c0d5-20221212" + reconcilerVersion: "18.3.0-next-9c09c1cd6-20221212" }); assign(Internals, { ReactBrowserEventEmitter: { @@ -16600,7 +16600,7 @@ exports.unstable_renderSubtreeIntoContainer = function( ); }; exports.unstable_runWithPriority = runWithPriority; -exports.version = "18.3.0-next-996e4c0d5-20221212"; +exports.version = "18.3.0-next-9c09c1cd6-20221212"; /* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */ if ( diff --git a/compiled/facebook-www/ReactDOMForked-profiling.modern.js b/compiled/facebook-www/ReactDOMForked-profiling.modern.js index ba08b083d0ebd..c2d68c3cbb9e6 100644 --- a/compiled/facebook-www/ReactDOMForked-profiling.modern.js +++ b/compiled/facebook-www/ReactDOMForked-profiling.modern.js @@ -15878,7 +15878,7 @@ Internals.Events = [ var devToolsConfig$jscomp$inline_1812 = { findFiberByHostInstance: getClosestInstanceFromNode, bundleType: 0, - version: "18.3.0-www-modern-996e4c0d5-20221212", + version: "18.3.0-www-modern-9c09c1cd6-20221212", rendererPackageName: "react-dom" }; (function(internals) { @@ -15923,7 +15923,7 @@ var devToolsConfig$jscomp$inline_1812 = { scheduleRoot: null, setRefreshHandler: null, getCurrentFiber: null, - reconcilerVersion: "18.3.0-next-996e4c0d5-20221212" + reconcilerVersion: "18.3.0-next-9c09c1cd6-20221212" }); exports.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = Internals; exports.createPortal = function(children, container) { @@ -16098,7 +16098,7 @@ exports.unstable_flushControlled = function(fn) { } }; exports.unstable_runWithPriority = runWithPriority; -exports.version = "18.3.0-next-996e4c0d5-20221212"; +exports.version = "18.3.0-next-9c09c1cd6-20221212"; /* global __REACT_DEVTOOLS_GLOBAL_HOOK__ */ if ( diff --git a/compiled/facebook-www/ReactDOMServer-dev.classic.js b/compiled/facebook-www/ReactDOMServer-dev.classic.js index f2d796fd17dcd..7bf470e3ace39 100644 --- a/compiled/facebook-www/ReactDOMServer-dev.classic.js +++ b/compiled/facebook-www/ReactDOMServer-dev.classic.js @@ -17,8 +17,9 @@ if (__DEV__) { "use strict"; var React = require("react"); +var ReactDOM = require("react-dom"); -var ReactVersion = "18.3.0-www-classic-996e4c0d5-20221212"; +var ReactVersion = "18.3.0-www-classic-9c09c1cd6-20221212"; // This refers to a WWW module. var warningWWW = require("warning"); @@ -3609,9 +3610,6 @@ var completeBoundaryWithStyles = var completeSegment = "$RS=function(a,b){a=document.getElementById(a);b=document.getElementById(b);for(a.parentNode.removeChild(a);a.firstChild;)b.parentNode.insertBefore(a.firstChild,b);b.parentNode.removeChild(b)};"; -// $FlowIgnore[cannot-resolve-module] provided by www -var ReactDOM = require("ReactDOMComet"); - var ReactDOMSharedInternals = ReactDOM.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED; diff --git a/compiled/facebook-www/ReactDOMServer-dev.modern.js b/compiled/facebook-www/ReactDOMServer-dev.modern.js index 924b52eeb1eb2..b4e741541dce9 100644 --- a/compiled/facebook-www/ReactDOMServer-dev.modern.js +++ b/compiled/facebook-www/ReactDOMServer-dev.modern.js @@ -17,8 +17,9 @@ if (__DEV__) { "use strict"; var React = require("react"); +var ReactDOM = require("react-dom"); -var ReactVersion = "18.3.0-www-modern-996e4c0d5-20221212"; +var ReactVersion = "18.3.0-www-modern-9c09c1cd6-20221212"; // This refers to a WWW module. var warningWWW = require("warning"); @@ -3613,9 +3614,6 @@ var completeBoundaryWithStyles = var completeSegment = "$RS=function(a,b){a=document.getElementById(a);b=document.getElementById(b);for(a.parentNode.removeChild(a);a.firstChild;)b.parentNode.insertBefore(a.firstChild,b);b.parentNode.removeChild(b)};"; -// $FlowIgnore[cannot-resolve-module] provided by www -var ReactDOM = require("ReactDOMComet"); - var ReactDOMSharedInternals = ReactDOM.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED; diff --git a/compiled/facebook-www/ReactDOMServer-prod.classic.js b/compiled/facebook-www/ReactDOMServer-prod.classic.js index 5dba8238bdee4..3f4b51a2c5b16 100644 --- a/compiled/facebook-www/ReactDOMServer-prod.classic.js +++ b/compiled/facebook-www/ReactDOMServer-prod.classic.js @@ -11,7 +11,8 @@ */ "use strict"; -var React = require("react"); +var React = require("react"), + ReactDOM = require("react-dom"); function formatProdErrorMessage(code) { for ( var url = "https://reactjs.org/docs/error-decoder.html?invariant=" + code, @@ -640,8 +641,8 @@ function hoistResourcesToRoot(resources, boundaryResources) { }); boundaryResources.clear(); } -var ReactDOMCurrentDispatcher = require("ReactDOMComet") - .__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.Dispatcher; +var ReactDOMCurrentDispatcher = + ReactDOM.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.Dispatcher; function createFormatContext(insertionMode, selectedValue, noscriptTagInScope) { return { insertionMode: insertionMode, @@ -3632,4 +3633,4 @@ exports.renderToString = function(children, options) { 'The server used "renderToString" which does not support Suspense. If you intended for this Suspense boundary to render the fallback content on the server consider throwing an Error somewhere within the Suspense boundary. If you intended to have the server wait for the suspended component please switch to "renderToReadableStream" which supports Suspense on the server' ); }; -exports.version = "18.3.0-www-classic-996e4c0d5-20221212"; +exports.version = "18.3.0-www-classic-9c09c1cd6-20221212"; diff --git a/compiled/facebook-www/ReactDOMServer-prod.modern.js b/compiled/facebook-www/ReactDOMServer-prod.modern.js index 87de2dad055c1..35134b014de46 100644 --- a/compiled/facebook-www/ReactDOMServer-prod.modern.js +++ b/compiled/facebook-www/ReactDOMServer-prod.modern.js @@ -11,7 +11,8 @@ */ "use strict"; -var React = require("react"); +var React = require("react"), + ReactDOM = require("react-dom"); function formatProdErrorMessage(code) { for ( var url = "https://reactjs.org/docs/error-decoder.html?invariant=" + code, @@ -640,8 +641,8 @@ function hoistResourcesToRoot(resources, boundaryResources) { }); boundaryResources.clear(); } -var ReactDOMCurrentDispatcher = require("ReactDOMComet") - .__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.Dispatcher; +var ReactDOMCurrentDispatcher = + ReactDOM.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.Dispatcher; function createFormatContext(insertionMode, selectedValue, noscriptTagInScope) { return { insertionMode: insertionMode, @@ -3545,4 +3546,4 @@ exports.renderToString = function(children, options) { 'The server used "renderToString" which does not support Suspense. If you intended for this Suspense boundary to render the fallback content on the server consider throwing an Error somewhere within the Suspense boundary. If you intended to have the server wait for the suspended component please switch to "renderToReadableStream" which supports Suspense on the server' ); }; -exports.version = "18.3.0-www-modern-996e4c0d5-20221212"; +exports.version = "18.3.0-www-modern-9c09c1cd6-20221212"; diff --git a/compiled/facebook-www/ReactDOMServerStreaming-dev.modern.js b/compiled/facebook-www/ReactDOMServerStreaming-dev.modern.js index a2e7c6e115559..c48a4e5b47b5a 100644 --- a/compiled/facebook-www/ReactDOMServerStreaming-dev.modern.js +++ b/compiled/facebook-www/ReactDOMServerStreaming-dev.modern.js @@ -17,6 +17,7 @@ if (__DEV__) { "use strict"; var React = require("react"); +var ReactDOM = require("react-dom"); // This refers to a WWW module. var warningWWW = require("warning"); @@ -3610,9 +3611,6 @@ var completeBoundaryWithStyles = var completeSegment = "$RS=function(a,b){a=document.getElementById(a);b=document.getElementById(b);for(a.parentNode.removeChild(a);a.firstChild;)b.parentNode.insertBefore(a.firstChild,b);b.parentNode.removeChild(b)};"; -// $FlowIgnore[cannot-resolve-module] provided by www -var ReactDOM = require("ReactDOMComet"); - var ReactDOMSharedInternals = ReactDOM.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED; diff --git a/compiled/facebook-www/ReactDOMServerStreaming-prod.modern.js b/compiled/facebook-www/ReactDOMServerStreaming-prod.modern.js index e9a7e6b101633..ab8fc5864ea68 100644 --- a/compiled/facebook-www/ReactDOMServerStreaming-prod.modern.js +++ b/compiled/facebook-www/ReactDOMServerStreaming-prod.modern.js @@ -11,7 +11,8 @@ */ "use strict"; -var React = require("react"); +var React = require("react"), + ReactDOM = require("react-dom"); function writeChunk(destination, chunk) { destination.buffer += chunk; } @@ -640,8 +641,8 @@ function hoistResourcesToRoot(resources, boundaryResources) { }); boundaryResources.clear(); } -var ReactDOMCurrentDispatcher = require("ReactDOMComet") - .__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.Dispatcher, +var ReactDOMCurrentDispatcher = + ReactDOM.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.Dispatcher, scriptRegex = /(<\/|<)(s)(cript)/gi; function scriptReplacer(match, prefix, s, suffix) { return "" + prefix + ("s" === s ? "\\u0073" : "\\u0053") + suffix; diff --git a/compiled/facebook-www/ReactDOMTesting-dev.classic.js b/compiled/facebook-www/ReactDOMTesting-dev.classic.js index cdfe7f75e7aa9..51b3d43fa7a9e 100644 --- a/compiled/facebook-www/ReactDOMTesting-dev.classic.js +++ b/compiled/facebook-www/ReactDOMTesting-dev.classic.js @@ -8442,765 +8442,788 @@ function lanesToEventPriority(lanes) { return IdleEventPriority; } -// $FlowIgnore[cannot-resolve-module] provided by www -var ReactDOM = require("ReactDOMComet"); +var Internals = { + usingClientEntryPoint: false, + Events: null, + Dispatcher: { + current: null + } +}; -var ReactDOMSharedInternals = - ReactDOM.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED; +var loggedTypeFailures = {}; +var ReactDebugCurrentFrame$1 = ReactSharedInternals.ReactDebugCurrentFrame; -function warnOnMissingHrefAndRel(pendingProps, currentProps) { +function setCurrentlyValidatingElement(element) { { - if (currentProps != null) { - var originalResourceName = - typeof currentProps.href === "string" - ? 'Resource with href "' + currentProps.href + '"' - : "Resource"; - var originalRelStatement = getValueDescriptorExpectingEnumForWarning( - currentProps.rel - ); - var pendingRel = getValueDescriptorExpectingEnumForWarning( - pendingProps.rel - ); - var pendingHref = getValueDescriptorExpectingEnumForWarning( - pendingProps.href + if (element) { + var owner = element._owner; + var stack = describeUnknownElementTypeFrameInDEV( + element.type, + element._source, + owner ? owner.type : null ); - - if (typeof pendingProps.rel !== "string") { - error( - 'A previously rendered as a %s with rel "%s" but was updated with an invalid rel: %s. When a link' + - " does not have a valid rel prop it is not represented in the DOM. If this is intentional, instead" + - " do not render the anymore.", - originalResourceName, - originalRelStatement, - pendingRel - ); - } else if (typeof pendingProps.href !== "string") { - error( - "A previously rendered as a %s but was updated with an invalid href prop: %s. When a link" + - " does not have a valid href prop it is not represented in the DOM. If this is intentional, instead" + - " do not render the anymore.", - originalResourceName, - pendingHref - ); - } + ReactDebugCurrentFrame$1.setExtraStackFrame(stack); } else { - var _pendingRel = getValueDescriptorExpectingEnumForWarning( - pendingProps.rel - ); - - var _pendingHref = getValueDescriptorExpectingEnumForWarning( - pendingProps.href - ); - - if (typeof pendingProps.rel !== "string") { - error( - "A is rendering with an invalid rel: %s. When a link" + - " does not have a valid rel prop it is not represented in the DOM. If this is intentional, instead" + - " do not render the anymore.", - _pendingRel - ); - } else if (typeof pendingProps.href !== "string") { - error( - "A is rendering with an invalid href: %s. When a link" + - " does not have a valid href prop it is not represented in the DOM. If this is intentional, instead" + - " do not render the anymore.", - _pendingHref - ); - } + ReactDebugCurrentFrame$1.setExtraStackFrame(null); } } } -function validatePreloadResourceDifference( - originalProps, - originalImplicit, - latestProps, - latestImplicit -) { + +function checkPropTypes(typeSpecs, values, location, componentName, element) { { - var href = originalProps.href; - var originalWarningName = getResourceNameForWarning( - "preload", - originalProps, - originalImplicit - ); - var latestWarningName = getResourceNameForWarning( - "preload", - latestProps, - latestImplicit - ); + // $FlowFixMe This is okay but Flow doesn't know it. + var has = Function.call.bind(hasOwnProperty); - if (latestProps.as !== originalProps.as) { - error( - 'A %s is using the same href "%s" as a %s. This is always an error and React will only keep the first preload' + - " for any given href, discarding subsequent instances. To fix, find where you are using this href in link" + - " tags or in calls to ReactDOM.preload() or ReactDOM.preinit() and either make the Resource types agree or" + - " update the hrefs to be distinct for different Resource types.", - latestWarningName, - href, - originalWarningName - ); - } else { - var missingProps = null; - var extraProps = null; - var differentProps = null; + for (var typeSpecName in typeSpecs) { + if (has(typeSpecs, typeSpecName)) { + var error$1 = void 0; // Prop type validation may throw. In case they do, we don't want to + // fail the render phase where it didn't fail before. So we log it. + // After these have been cleaned up, we'll let them throw. - if (originalProps.media != null && latestProps.media == null) { - missingProps = missingProps || {}; - missingProps.media = originalProps.media; - } + try { + // This is intentionally an invariant that gets caught. It's the same + // behavior as without this statement except with a better message. + if (typeof typeSpecs[typeSpecName] !== "function") { + // eslint-disable-next-line react-internal/prod-error-codes + var err = Error( + (componentName || "React class") + + ": " + + location + + " type `" + + typeSpecName + + "` is invalid; " + + "it must be a function, usually from the `prop-types` package, but received `" + + typeof typeSpecs[typeSpecName] + + "`." + + "This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`." + ); + err.name = "Invariant Violation"; + throw err; + } - for (var propName in latestProps) { - var propValue = latestProps[propName]; - var originalValue = originalProps[propName]; + error$1 = typeSpecs[typeSpecName]( + values, + typeSpecName, + componentName, + location, + null, + "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED" + ); + } catch (ex) { + error$1 = ex; + } - if (propValue != null && propValue !== originalValue) { - if (originalValue == null) { - extraProps = extraProps || {}; - extraProps[propName] = propValue; - } else { - differentProps = differentProps || {}; - differentProps[propName] = { - original: originalValue, - latest: propValue - }; - } + if (error$1 && !(error$1 instanceof Error)) { + setCurrentlyValidatingElement(element); + + error( + "%s: type specification of %s" + + " `%s` is invalid; the type checker " + + "function must return `null` or an `Error` but returned a %s. " + + "You may have forgotten to pass an argument to the type checker " + + "creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and " + + "shape all require an argument).", + componentName || "React class", + location, + typeSpecName, + typeof error$1 + ); + + setCurrentlyValidatingElement(null); } - } - if (missingProps || extraProps || differentProps) { - warnDifferentProps( - href, - "href", - originalWarningName, - latestWarningName, - extraProps, - missingProps, - differentProps - ); + if ( + error$1 instanceof Error && + !(error$1.message in loggedTypeFailures) + ) { + // Only monitor this failure once because there tends to be a lot of the + // same error. + loggedTypeFailures[error$1.message] = true; + setCurrentlyValidatingElement(element); + + error("Failed %s type: %s", location, error$1.message); + + setCurrentlyValidatingElement(null); + } } } } } -function validateStyleResourceDifference(originalProps, latestProps) { - { - var href = originalProps.href; // eslint-disable-next-line no-labels - var originalWarningName = getResourceNameForWarning( - "style", - originalProps, - false - ); - var latestWarningName = getResourceNameForWarning( - "style", - latestProps, - false - ); - var missingProps = null; - var extraProps = null; - var differentProps = null; +var valueStack = []; +var fiberStack; - if (originalProps.media != null && latestProps.media == null) { - missingProps = missingProps || {}; - missingProps.media = originalProps.media; - } +{ + fiberStack = []; +} - for (var propName in latestProps) { - var propValue = latestProps[propName]; - var originalValue = originalProps[propName]; +var index = -1; - if (propValue != null && propValue !== originalValue) { - propName = propName === "data-precedence" ? "precedence" : propName; +function createCursor(defaultValue) { + return { + current: defaultValue + }; +} - if (originalValue == null) { - extraProps = extraProps || {}; - extraProps[propName] = propValue; - } else { - differentProps = differentProps || {}; - differentProps[propName] = { - original: originalValue, - latest: propValue - }; - } - } +function pop(cursor, fiber) { + if (index < 0) { + { + error("Unexpected pop."); } - if (missingProps || extraProps || differentProps) { - warnDifferentProps( - href, - "href", - originalWarningName, - latestWarningName, - extraProps, - missingProps, - differentProps - ); + return; + } + + { + if (fiber !== fiberStack[index]) { + error("Unexpected Fiber popped."); } } + + cursor.current = valueStack[index]; + valueStack[index] = null; + + { + fiberStack[index] = null; + } + + index--; } -function validateScriptResourceDifference(originalProps, latestProps) { + +function push(cursor, value, fiber) { + index++; + valueStack[index] = cursor.current; + { - var src = originalProps.src; // eslint-disable-next-line no-labels + fiberStack[index] = fiber; + } - var originalWarningName = getResourceNameForWarning( - "script", - originalProps, - false - ); - var latestWarningName = getResourceNameForWarning( - "script", - latestProps, - false - ); - var extraProps = null; - var differentProps = null; + cursor.current = value; +} - for (var propName in latestProps) { - var propValue = latestProps[propName]; - var originalValue = originalProps[propName]; +var warnedAboutMissingGetChildContext; - if (propValue != null && propValue !== originalValue) { - if (originalValue == null) { - extraProps = extraProps || {}; - extraProps[propName] = propValue; - } else { - differentProps = differentProps || {}; - differentProps[propName] = { - original: originalValue, - latest: propValue - }; - } - } - } +{ + warnedAboutMissingGetChildContext = {}; +} // $FlowFixMe[incompatible-exact] - if (extraProps || differentProps) { - warnDifferentProps( - src, - "src", - originalWarningName, - latestWarningName, - extraProps, - null, - differentProps - ); +var emptyContextObject = {}; + +{ + Object.freeze(emptyContextObject); +} // A cursor to the current merged context object on the stack. + +var contextStackCursor = createCursor(emptyContextObject); // A cursor to a boolean indicating whether the context has changed. + +var didPerformWorkStackCursor = createCursor(false); // Keep track of the previous context object that was on the stack. +// We use this to get access to the parent context after we have already +// pushed the next context provider, and now need to merge their contexts. + +var previousContext = emptyContextObject; + +function getUnmaskedContext( + workInProgress, + Component, + didPushOwnContextIfProvider +) { + { + if (didPushOwnContextIfProvider && isContextProvider(Component)) { + // If the fiber is a context provider itself, when we read its context + // we may have already pushed its own child context on the stack. A context + // provider should not "see" its own child context. Therefore we read the + // previous (parent) context instead for a context provider. + return previousContext; } + + return contextStackCursor.current; } } -function warnDifferentProps( - url, - urlPropKey, - originalName, - latestName, - extraProps, - missingProps, - differentProps -) { +function cacheContext(workInProgress, unmaskedContext, maskedContext) { { - var juxtaposedNameStatement = - latestName === originalName - ? "an earlier instance of this Resource" - : "a " + originalName + " with the same " + urlPropKey; - var comparisonStatement = ""; + var instance = workInProgress.stateNode; + instance.__reactInternalMemoizedUnmaskedChildContext = unmaskedContext; + instance.__reactInternalMemoizedMaskedChildContext = maskedContext; + } +} - if (missingProps !== null && typeof missingProps === "object") { - for (var propName in missingProps) { - comparisonStatement += - "\n " + - propName + - ': missing or null in latest props, "' + - missingProps[propName] + - '" in original props'; - } +function getMaskedContext(workInProgress, unmaskedContext) { + { + var type = workInProgress.type; + var contextTypes = type.contextTypes; + + if (!contextTypes) { + return emptyContextObject; + } // Avoid recreating masked context unless unmasked context has changed. + // Failing to do this will result in unnecessary calls to componentWillReceiveProps. + // This may trigger infinite loops if componentWillReceiveProps calls setState. + + var instance = workInProgress.stateNode; + + if ( + instance && + instance.__reactInternalMemoizedUnmaskedChildContext === unmaskedContext + ) { + return instance.__reactInternalMemoizedMaskedChildContext; } - if (extraProps !== null && typeof extraProps === "object") { - for (var _propName in extraProps) { - comparisonStatement += - "\n " + - _propName + - ': "' + - extraProps[_propName] + - '" in latest props, missing or null in original props'; - } + var context = {}; + + for (var key in contextTypes) { + context[key] = unmaskedContext[key]; } - if (differentProps !== null && typeof differentProps === "object") { - for (var _propName2 in differentProps) { - comparisonStatement += - "\n " + - _propName2 + - ': "' + - differentProps[_propName2].latest + - '" in latest props, "' + - differentProps[_propName2].original + - '" in original props'; - } + { + var name = getComponentNameFromFiber(workInProgress) || "Unknown"; + checkPropTypes(contextTypes, context, "context", name); + } // Cache unmasked context so we can avoid recreating masked context unless necessary. + // Context is created before the class component is instantiated so check for instance. + + if (instance) { + cacheContext(workInProgress, unmaskedContext, context); } - error( - 'A %s with %s "%s" has props that disagree with those found on %s. Resources always use the props' + - " that were provided the first time they are encountered so any differences will be ignored. Please" + - " update Resources that share an %s to have props that agree. The differences are described below.%s", - latestName, - urlPropKey, - url, - juxtaposedNameStatement, - urlPropKey, - comparisonStatement - ); + return context; } } -function getResourceNameForWarning(type, props, implicit) { +function hasContextChanged() { { - switch (type) { - case "style": { - return "style Resource"; - } - - case "script": { - return "script Resource"; - } + return didPerformWorkStackCursor.current; + } +} - case "preload": { - if (implicit) { - return "preload for a " + props.as + " Resource"; - } +function isContextProvider(type) { + { + var childContextTypes = type.childContextTypes; + return childContextTypes !== null && childContextTypes !== undefined; + } +} - return 'preload Resource (as "' + props.as + '")'; - } - } +function popContext(fiber) { + { + pop(didPerformWorkStackCursor, fiber); + pop(contextStackCursor, fiber); } +} - return "Resource"; +function popTopLevelContextObject(fiber) { + { + pop(didPerformWorkStackCursor, fiber); + pop(contextStackCursor, fiber); + } } -function validateURLKeyedUpdatedProps( - pendingProps, - currentProps, - resourceType, - urlPropKey -) { +function pushTopLevelContextObject(fiber, context, didChange) { { - // This function should never be called if we don't have /srcs so we don't bother considering - // Whether they are null or undefined - if (pendingProps[urlPropKey] === currentProps[urlPropKey]) { - // If we have the same href/src we need all other props to be the same - var missingProps; - var extraProps; - var differentProps; - var allProps = Array.from( - new Set(Object.keys(currentProps).concat(Object.keys(pendingProps))) + if (contextStackCursor.current !== emptyContextObject) { + throw new Error( + "Unexpected context found on stack. " + + "This error is likely caused by a bug in React. Please file an issue." ); + } - for (var i = 0; i < allProps.length; i++) { - var propName = allProps[i]; - var pendingValue = pendingProps[propName]; - var currentValue = currentProps[propName]; + push(contextStackCursor, context, fiber); + push(didPerformWorkStackCursor, didChange, fiber); + } +} - if ( - pendingValue !== currentValue && - !(pendingValue == null && currentValue == null) - ) { - if (pendingValue == null) { - missingProps = missingProps || {}; - missingProps[propName] = currentValue; - } else if (currentValue == null) { - extraProps = extraProps || {}; - extraProps[propName] = pendingValue; - } else { - differentProps = differentProps || {}; - differentProps[propName] = { - original: currentValue, - latest: pendingValue - }; - } - } - } +function processChildContext(fiber, type, parentContext) { + { + var instance = fiber.stateNode; + var childContextTypes = type.childContextTypes; // TODO (bvaughn) Replace this behavior with an invariant() in the future. + // It has only been added in Fiber to match the (unintentional) behavior in Stack. - if (missingProps || extraProps || differentProps) { - var latestWarningName = getResourceNameForWarning( - resourceType, - currentProps, - false - ); - var comparisonStatement = ""; + if (typeof instance.getChildContext !== "function") { + { + var componentName = getComponentNameFromFiber(fiber) || "Unknown"; - if (missingProps !== null && typeof missingProps === "object") { - for (var _propName3 in missingProps) { - comparisonStatement += - "\n " + - _propName3 + - ': missing or null in latest props, "' + - missingProps[_propName3] + - '" in original props'; - } - } + if (!warnedAboutMissingGetChildContext[componentName]) { + warnedAboutMissingGetChildContext[componentName] = true; - if (extraProps !== null && typeof extraProps === "object") { - for (var _propName4 in extraProps) { - comparisonStatement += - "\n " + - _propName4 + - ': "' + - extraProps[_propName4] + - '" in latest props, missing or null in original props'; - } + error( + "%s.childContextTypes is specified but there is no getChildContext() method " + + "on the instance. You can either define getChildContext() on %s or remove " + + "childContextTypes from it.", + componentName, + componentName + ); } + } - if (differentProps !== null && typeof differentProps === "object") { - for (var _propName5 in differentProps) { - comparisonStatement += - "\n " + - _propName5 + - ': "' + - differentProps[_propName5].latest + - '" in latest props, "' + - differentProps[_propName5].original + - '" in original props'; - } - } + return parentContext; + } - error( - 'A %s with %s "%s" received new props with different values from the props used' + - " when this Resource was first rendered. React will only use the props provided when" + - " this resource was first rendered until a new %s is provided. Unlike conventional" + - " DOM elements, Resources instances do not have a one to one correspondence with Elements" + - " in the DOM and as such, every instance of a Resource for a single Resource identifier" + - " (%s) must have props that agree with each other. The differences are described below.%s", - latestWarningName, - urlPropKey, - currentProps[urlPropKey], - urlPropKey, - urlPropKey, - comparisonStatement - ); + var childContext = instance.getChildContext(); - return true; + for (var contextKey in childContext) { + if (!(contextKey in childContextTypes)) { + throw new Error( + (getComponentNameFromFiber(fiber) || "Unknown") + + '.getChildContext(): key "' + + contextKey + + '" is not defined in childContextTypes.' + ); } } - } - - return false; -} -function validateLinkPropsForStyleResource(props) { - { - // This should only be called when we know we are opting into Resource semantics (i.e. precedence is not null) - var href = props.href, - onLoad = props.onLoad, - onError = props.onError, - disabled = props.disabled; - var allProps = ["onLoad", "onError", "disabled"]; - var includedProps = []; - if (onLoad) includedProps.push("onLoad"); - if (onError) includedProps.push("onError"); - if (disabled != null) includedProps.push("disabled"); - var allPropsUnionPhrase = propNamesListJoin(allProps, "or"); - var includedPropsPhrase = propNamesListJoin(includedProps, "and"); - includedPropsPhrase += includedProps.length === 1 ? " prop" : " props"; - - if (includedProps.length) { - error( - 'A link (rel="stylesheet") element with href "%s" has the precedence prop but also included the %s.' + - " When using %s React will opt out of Resource behavior. If you meant for this" + - " element to be treated as a Resource remove the %s. Otherwise remove the precedence prop.", - href, - includedPropsPhrase, - allPropsUnionPhrase, - includedPropsPhrase - ); - return true; + { + var name = getComponentNameFromFiber(fiber) || "Unknown"; + checkPropTypes(childContextTypes, childContext, "child context", name); } - } - return false; + return assign({}, parentContext, childContext); + } } -function propNamesListJoin(list, combinator) { - switch (list.length) { - case 0: - return ""; - - case 1: - return list[0]; +function pushContextProvider(workInProgress) { + { + var instance = workInProgress.stateNode; // We push the context as early as possible to ensure stack integrity. + // If the instance does not exist yet, we will push null at first, + // and replace it on the stack later when invalidating the context. - case 2: - return list[0] + " " + combinator + " " + list[1]; + var memoizedMergedChildContext = + (instance && instance.__reactInternalMemoizedMergedChildContext) || + emptyContextObject; // Remember the parent context so we can merge with it later. + // Inherit the parent's did-perform-work value to avoid inadvertently blocking updates. - default: - return ( - list.slice(0, -1).join(", ") + - ", " + - combinator + - " " + - list[list.length - 1] - ); + previousContext = contextStackCursor.current; + push(contextStackCursor, memoizedMergedChildContext, workInProgress); + push( + didPerformWorkStackCursor, + didPerformWorkStackCursor.current, + workInProgress + ); + return true; } } -function validateLinkPropsForPreloadResource(linkProps) { +function invalidateContextProvider(workInProgress, type, didChange) { { - var href = linkProps.href, - as = linkProps.as; + var instance = workInProgress.stateNode; - if (as === "font") { - var name = getResourceNameForWarning("preload", linkProps, false); + if (!instance) { + throw new Error( + "Expected to have an instance by this point. " + + "This error is likely caused by a bug in React. Please file an issue." + ); + } - if (!hasOwnProperty.call(linkProps, "crossOrigin")) { - error( - 'A %s with href "%s" did not specify the crossOrigin prop. Font preloads must always use' + - ' anonymouse CORS mode. To fix add an empty string, "anonymous", or any other string' + - ' value except "use-credentials" for the crossOrigin prop of all font preloads.', - name, - href - ); - } else if (linkProps.crossOrigin === "use-credentials") { - error( - 'A %s with href "%s" specified a crossOrigin value of "use-credentials". Font preloads must always use' + - ' anonymouse CORS mode. To fix use an empty string, "anonymous", or any other string' + - ' value except "use-credentials" for the crossOrigin prop of all font preloads.', - name, - href - ); - } + if (didChange) { + // Merge parent and own context. + // Skip this if we're not updating due to sCU. + // This avoids unnecessarily recomputing memoized values. + var mergedContext = processChildContext( + workInProgress, + type, + previousContext + ); + instance.__reactInternalMemoizedMergedChildContext = mergedContext; // Replace the old (or empty) context with the new one. + // It is important to unwind the context in the reverse order. + + pop(didPerformWorkStackCursor, workInProgress); + pop(contextStackCursor, workInProgress); // Now push the new context and mark that it has changed. + + push(contextStackCursor, mergedContext, workInProgress); + push(didPerformWorkStackCursor, didChange, workInProgress); + } else { + pop(didPerformWorkStackCursor, workInProgress); + push(didPerformWorkStackCursor, didChange, workInProgress); } } } -function validatePreloadArguments(href, options) { - { - if (!href || typeof href !== "string") { - var typeOfArg = getValueDescriptorExpectingObjectForWarning(href); - error( - "ReactDOM.preload() expected the first argument to be a string representing an href but found %s instead.", - typeOfArg +function findCurrentUnmaskedContext(fiber) { + { + // Currently this is only used with renderSubtreeIntoContainer; not sure if it + // makes sense elsewhere + if (!isFiberMounted(fiber) || fiber.tag !== ClassComponent) { + throw new Error( + "Expected subtree parent to be a mounted class component. " + + "This error is likely caused by a bug in React. Please file an issue." ); - } else if (typeof options !== "object" || options === null) { - var _typeOfArg = getValueDescriptorExpectingObjectForWarning(options); + } - error( - 'ReactDOM.preload() expected the second argument to be an options argument containing at least an "as" property' + - ' specifying the Resource type. It found %s instead. The href for the preload call where this warning originated is "%s".', - _typeOfArg, - href - ); - } else { - var as = options.as; + var node = fiber; - switch (as) { - // Font specific validation of options - case "font": { - if (options.crossOrigin === "use-credentials") { - error( - 'ReactDOM.preload() was called with an "as" type of "font" and with a "crossOrigin" option of "use-credentials".' + - ' Fonts preloading must use crossOrigin "anonymous" to be functional. Please update your font preload to omit' + - ' the crossOrigin option or change it to any other value than "use-credentials" (Browsers default all other values' + - ' to anonymous mode). The href for the preload call where this warning originated is "%s"', - href - ); - } - - break; - } - - case "script": - case "style": { - break; - } - // We have an invalid as type and need to warn - - default: { - var typeOfAs = getValueDescriptorExpectingEnumForWarning(as); - - error( - 'ReactDOM.preload() expected a valid "as" type in the options (second) argument but found %s instead.' + - " Please use one of the following valid values instead: %s. The href for the preload call where this" + - ' warning originated is "%s".', - typeOfAs, - '"style", "font", or "script"', - href - ); - } - } - } - } -} -function validatePreinitArguments(href, options) { - { - if (!href || typeof href !== "string") { - var typeOfArg = getValueDescriptorExpectingObjectForWarning(href); + do { + switch (node.tag) { + case HostRoot: + return node.stateNode.context; - error( - "ReactDOM.preinit() expected the first argument to be a string representing an href but found %s instead.", - typeOfArg - ); - } else if (typeof options !== "object" || options === null) { - var _typeOfArg2 = getValueDescriptorExpectingObjectForWarning(options); + case ClassComponent: { + var Component = node.type; - error( - 'ReactDOM.preinit() expected the second argument to be an options argument containing at least an "as" property' + - ' specifying the Resource type. It found %s instead. The href for the preload call where this warning originated is "%s".', - _typeOfArg2, - href - ); - } else { - var as = options.as; + if (isContextProvider(Component)) { + return node.stateNode.__reactInternalMemoizedMergedChildContext; + } - switch (as) { - case "style": - case "script": { break; } - // We have an invalid as type and need to warn + } // $FlowFixMe[incompatible-type] we bail out when we get a null - default: { - var typeOfAs = getValueDescriptorExpectingEnumForWarning(as); + node = node.return; + } while (node !== null); - error( - 'ReactDOM.preinit() expected the second argument to be an options argument containing at least an "as" property' + - ' specifying the Resource type. It found %s instead. Currently, valid resource types for for preinit are "style"' + - ' and "script". The href for the preinit call where this warning originated is "%s".', - typeOfAs, - href - ); - } - } - } + throw new Error( + "Found unexpected detached subtree parent. " + + "This error is likely caused by a bug in React. Please file an issue." + ); } } -function getValueDescriptorExpectingObjectForWarning(thing) { - return thing === null - ? "null" - : thing === undefined - ? "undefined" - : thing === "" - ? "an empty string" - : 'something with type "' + typeof thing + '"'; -} - -function getValueDescriptorExpectingEnumForWarning(thing) { - return thing === null - ? "null" - : thing === undefined - ? "undefined" - : thing === "" - ? "an empty string" - : typeof thing === "string" - ? JSON.stringify(thing) - : 'something with type "' + typeof thing + '"'; -} - -var valueStack = []; -var fiberStack; +var LegacyRoot = 0; +var ConcurrentRoot = 1; -{ - fiberStack = []; +// 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" + ); } -var index = -1; - -function createCursor(defaultValue) { - return { - current: defaultValue - }; +/** + * inlined Object.is polyfill to avoid requiring consumers ship their own + * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is + */ +function is(x, y) { + return ( + (x === y && (x !== 0 || 1 / x === 1 / y)) || (x !== x && y !== y) // eslint-disable-line no-self-compare + ); } -function pop(cursor, fiber) { - if (index < 0) { - { - error("Unexpected pop."); - } - - return; - } +var objectIs = typeof Object.is === "function" ? Object.is : is; // $FlowFixMe[method-unbinding] - { - if (fiber !== fiberStack[index]) { - error("Unexpected Fiber popped."); - } +var syncQueue = null; +var includesLegacySyncCallbacks = false; +var isFlushingSyncQueue = false; +function scheduleSyncCallback(callback) { + // Push this callback into an internal queue. We'll flush these either in + // the next tick, or earlier if something calls `flushSyncCallbackQueue`. + if (syncQueue === null) { + syncQueue = [callback]; + } else { + // Push onto existing queue. Don't need to schedule a callback because + // we already scheduled one when we created the queue. + syncQueue.push(callback); } - - cursor.current = valueStack[index]; - valueStack[index] = null; - - { - fiberStack[index] = null; +} +function scheduleLegacySyncCallback(callback) { + includesLegacySyncCallbacks = true; + scheduleSyncCallback(callback); +} +function flushSyncCallbacksOnlyInLegacyMode() { + // Only flushes the queue if there's a legacy sync callback scheduled. + // TODO: There's only a single type of callback: performSyncOnWorkOnRoot. So + // it might make more sense for the queue to be a list of roots instead of a + // list of generic callbacks. Then we can have two: one for legacy roots, one + // for concurrent roots. And this method would only flush the legacy ones. + if (includesLegacySyncCallbacks) { + flushSyncCallbacks(); } - - index--; } +function flushSyncCallbacks() { + if (!isFlushingSyncQueue && syncQueue !== null) { + // Prevent re-entrance. + isFlushingSyncQueue = true; + var i = 0; + var previousUpdatePriority = getCurrentUpdatePriority(); -function push(cursor, value, fiber) { - index++; - valueStack[index] = cursor.current; + try { + var isSync = true; + var queue = syncQueue; // TODO: Is this necessary anymore? The only user code that runs in this + // queue is in the render or commit phases. - { - fiberStack[index] = fiber; - } + setCurrentUpdatePriority(DiscreteEventPriority); // $FlowFixMe[incompatible-use] found when upgrading Flow - cursor.current = value; -} + for (; i < queue.length; i++) { + // $FlowFixMe[incompatible-use] found when upgrading Flow + var callback = queue[i]; -var contextStackCursor = createCursor(null); -var contextFiberStackCursor = createCursor(null); -var rootInstanceStackCursor = createCursor(null); + do { + // $FlowFixMe[incompatible-type] we bail out when we get a null + callback = callback(isSync); + } while (callback !== null); + } -function requiredContext(c) { - { - if (c === null) { - error( - "Expected host context to exist. This error is likely caused by a bug " + - "in React. Please file an issue." - ); + syncQueue = null; + includesLegacySyncCallbacks = false; + } catch (error) { + // If something throws, leave the remaining callbacks on the queue. + if (syncQueue !== null) { + syncQueue = syncQueue.slice(i + 1); + } // Resume flushing in the next tick + + scheduleCallback(ImmediatePriority, flushSyncCallbacks); + throw error; + } finally { + setCurrentUpdatePriority(previousUpdatePriority); + isFlushingSyncQueue = false; } } - return c; -} - -function getCurrentRootHostContainer() { - return rootInstanceStackCursor.current; + return null; } -function getRootHostContainer() { - var rootInstance = requiredContext(rootInstanceStackCursor.current); - return rootInstance; +// This is imported by the event replaying implementation in React DOM. It's +// in a separate file to break a circular dependency between the renderer and +// the reconciler. +function isRootDehydrated(root) { + var currentState = root.current.memoizedState; + return currentState.isDehydrated; } -function pushHostContainer(fiber, nextRootInstance) { - // Push current root instance onto the stack; - // This allows us to reset root when portals are popped. - push(rootInstanceStackCursor, nextRootInstance, fiber); // Track the context and the Fiber that provided it. - // This enables us to pop only Fibers that provide unique contexts. - - push(contextFiberStackCursor, fiber, fiber); // Finally, we need to push the host context to the stack. - // However, we can't just call getRootHostContext() and push it because - // we'd have a different number of entries on the stack depending on - // whether getRootHostContext() throws somewhere in renderer code or not. +// TODO: Use the unified fiber stack module instead of this local one? +// Intentionally not using it yet to derisk the initial implementation, because +// the way we push/pop these values is a bit unusual. If there's a mistake, I'd +// rather the ids be wrong than crash the whole reconciler. +var forkStack = []; +var forkStackIndex = 0; +var treeForkProvider = null; +var treeForkCount = 0; +var idStack = []; +var idStackIndex = 0; +var treeContextProvider = null; +var treeContextId = 1; +var treeContextOverflow = ""; +function isForkedChild(workInProgress) { + warnIfNotHydrating(); + return (workInProgress.flags & Forked) !== NoFlags; +} +function getForksAtLevel(workInProgress) { + warnIfNotHydrating(); + return treeForkCount; +} +function getTreeId() { + var overflow = treeContextOverflow; + var idWithLeadingBit = treeContextId; + var id = idWithLeadingBit & ~getLeadingBit(idWithLeadingBit); + return id.toString(32) + overflow; +} +function pushTreeFork(workInProgress, totalChildren) { + // This is called right after we reconcile an array (or iterator) of child + // fibers, because that's the only place where we know how many children in + // the whole set without doing extra work later, or storing addtional + // information on the fiber. + // + // That's why this function is separate from pushTreeId — it's called during + // the render phase of the fork parent, not the child, which is where we push + // the other context values. + // + // In the Fizz implementation this is much simpler because the child is + // rendered in the same callstack as the parent. + // + // It might be better to just add a `forks` field to the Fiber type. It would + // make this module simpler. + warnIfNotHydrating(); + forkStack[forkStackIndex++] = treeForkCount; + forkStack[forkStackIndex++] = treeForkProvider; + treeForkProvider = workInProgress; + treeForkCount = totalChildren; +} +function pushTreeId(workInProgress, totalChildren, index) { + warnIfNotHydrating(); + idStack[idStackIndex++] = treeContextId; + idStack[idStackIndex++] = treeContextOverflow; + idStack[idStackIndex++] = treeContextProvider; + treeContextProvider = workInProgress; + var baseIdWithLeadingBit = treeContextId; + var baseOverflow = treeContextOverflow; // The leftmost 1 marks the end of the sequence, non-inclusive. It's not part + // of the id; we use it to account for leading 0s. + + var baseLength = getBitLength(baseIdWithLeadingBit) - 1; + var baseId = baseIdWithLeadingBit & ~(1 << baseLength); + var slot = index + 1; + var length = getBitLength(totalChildren) + baseLength; // 30 is the max length we can store without overflowing, taking into + // consideration the leading 1 we use to mark the end of the sequence. + + if (length > 30) { + // We overflowed the bitwise-safe range. Fall back to slower algorithm. + // This branch assumes the length of the base id is greater than 5; it won't + // work for smaller ids, because you need 5 bits per character. + // + // We encode the id in multiple steps: first the base id, then the + // remaining digits. + // + // Each 5 bit sequence corresponds to a single base 32 character. So for + // example, if the current id is 23 bits long, we can convert 20 of those + // bits into a string of 4 characters, with 3 bits left over. + // + // First calculate how many bits in the base id represent a complete + // sequence of characters. + var numberOfOverflowBits = baseLength - (baseLength % 5); // Then create a bitmask that selects only those bits. + + var newOverflowBits = (1 << numberOfOverflowBits) - 1; // Select the bits, and convert them to a base 32 string. + + var newOverflow = (baseId & newOverflowBits).toString(32); // Now we can remove those bits from the base id. + + var restOfBaseId = baseId >> numberOfOverflowBits; + var restOfBaseLength = baseLength - numberOfOverflowBits; // Finally, encode the rest of the bits using the normal algorithm. Because + // we made more room, this time it won't overflow. + + var restOfLength = getBitLength(totalChildren) + restOfBaseLength; + var restOfNewBits = slot << restOfBaseLength; + var id = restOfNewBits | restOfBaseId; + var overflow = newOverflow + baseOverflow; + treeContextId = (1 << restOfLength) | id; + treeContextOverflow = overflow; + } else { + // Normal path + var newBits = slot << baseLength; + + var _id = newBits | baseId; + + var _overflow = baseOverflow; + treeContextId = (1 << length) | _id; + treeContextOverflow = _overflow; + } +} +function pushMaterializedTreeId(workInProgress) { + warnIfNotHydrating(); // This component materialized an id. This will affect any ids that appear + // in its children. + + var returnFiber = workInProgress.return; + + if (returnFiber !== null) { + var numberOfForks = 1; + var slotIndex = 0; + pushTreeFork(workInProgress, numberOfForks); + pushTreeId(workInProgress, numberOfForks, slotIndex); + } +} + +function getBitLength(number) { + return 32 - clz32(number); +} + +function getLeadingBit(id) { + return 1 << (getBitLength(id) - 1); +} + +function popTreeContext(workInProgress) { + // Restore the previous values. + // This is a bit more complicated than other context-like modules in Fiber + // because the same Fiber may appear on the stack multiple times and for + // different reasons. We have to keep popping until the work-in-progress is + // no longer at the top of the stack. + while (workInProgress === treeForkProvider) { + treeForkProvider = forkStack[--forkStackIndex]; + forkStack[forkStackIndex] = null; + treeForkCount = forkStack[--forkStackIndex]; + forkStack[forkStackIndex] = null; + } + + while (workInProgress === treeContextProvider) { + treeContextProvider = idStack[--idStackIndex]; + idStack[idStackIndex] = null; + treeContextOverflow = idStack[--idStackIndex]; + idStack[idStackIndex] = null; + treeContextId = idStack[--idStackIndex]; + idStack[idStackIndex] = null; + } +} +function getSuspendedTreeContext() { + warnIfNotHydrating(); + + if (treeContextProvider !== null) { + return { + id: treeContextId, + overflow: treeContextOverflow + }; + } else { + return null; + } +} +function restoreSuspendedTreeContext(workInProgress, suspendedContext) { + warnIfNotHydrating(); + idStack[idStackIndex++] = treeContextId; + idStack[idStackIndex++] = treeContextOverflow; + idStack[idStackIndex++] = treeContextProvider; + treeContextId = suspendedContext.id; + treeContextOverflow = suspendedContext.overflow; + treeContextProvider = workInProgress; +} + +function warnIfNotHydrating() { + { + if (!getIsHydrating()) { + error( + "Expected to be hydrating. This is a bug in React. Please file " + + "an issue." + ); + } + } +} + +var contextStackCursor$1 = createCursor(null); +var contextFiberStackCursor = createCursor(null); +var rootInstanceStackCursor = createCursor(null); + +function requiredContext(c) { + { + if (c === null) { + error( + "Expected host context to exist. This error is likely caused by a bug " + + "in React. Please file an issue." + ); + } + } + + return c; +} + +function getCurrentRootHostContainer() { + return rootInstanceStackCursor.current; +} + +function getRootHostContainer() { + var rootInstance = requiredContext(rootInstanceStackCursor.current); + return rootInstance; +} + +function pushHostContainer(fiber, nextRootInstance) { + // Push current root instance onto the stack; + // This allows us to reset root when portals are popped. + push(rootInstanceStackCursor, nextRootInstance, fiber); // Track the context and the Fiber that provided it. + // This enables us to pop only Fibers that provide unique contexts. + + push(contextFiberStackCursor, fiber, fiber); // Finally, we need to push the host context to the stack. + // However, we can't just call getRootHostContext() and push it because + // we'd have a different number of entries on the stack depending on + // whether getRootHostContext() throws somewhere in renderer code or not. // So we push an empty value first. This lets us safely unwind on errors. - push(contextStackCursor, null, fiber); + push(contextStackCursor$1, null, fiber); var nextRootContext = getRootHostContext(nextRootInstance); // Now that we know this function doesn't throw, replace it. - pop(contextStackCursor, fiber); - push(contextStackCursor, nextRootContext, fiber); + pop(contextStackCursor$1, fiber); + push(contextStackCursor$1, nextRootContext, fiber); } function popHostContainer(fiber) { - pop(contextStackCursor, fiber); + pop(contextStackCursor$1, fiber); pop(contextFiberStackCursor, fiber); pop(rootInstanceStackCursor, fiber); } function getHostContext() { - var context = requiredContext(contextStackCursor.current); + var context = requiredContext(contextStackCursor$1.current); return context; } function pushHostContext(fiber) { - var context = requiredContext(contextStackCursor.current); + var context = requiredContext(contextStackCursor$1.current); var nextContext = getChildHostContext(context, fiber.type); // Don't push this Fiber's context unless it's unique. if (context === nextContext) { @@ -9209,7 +9232,7 @@ function pushHostContext(fiber) { // This enables us to pop only Fibers that provide unique contexts. push(contextFiberStackCursor, fiber, fiber); - push(contextStackCursor, nextContext, fiber); + push(contextStackCursor$1, nextContext, fiber); } function popHostContext(fiber) { @@ -9219,31256 +9242,31229 @@ function popHostContext(fiber) { return; } - pop(contextStackCursor, fiber); + pop(contextStackCursor$1, fiber); pop(contextFiberStackCursor, fiber); } -var Dispatcher = ReactDOMSharedInternals.Dispatcher; -// In the future this may need to change, especially when modules / scripts are supported +// This may have been an insertion or a hydration. -// It is valid to preload even when we aren't actively rendering. For cases where Float functions are -// called when there is no rendering we track the last used document. It is not safe to insert -// arbitrary resources into the lastCurrentDocument b/c it may not actually be the document -// that the resource is meant to apply too (for example stylesheets or scripts). This is only -// appropriate for resources that don't really have a strict tie to the document itself for example -// preloads -var lastCurrentDocument = null; -var previousDispatcher = null; -function prepareToRenderResources(rootContainer) { - var rootNode = getRootNode(rootContainer); - lastCurrentDocument = getDocumentFromRoot(rootNode); - previousDispatcher = Dispatcher.current; - Dispatcher.current = ReactDOMClientDispatcher; -} -function cleanupAfterRenderResources() { - Dispatcher.current = previousDispatcher; - previousDispatcher = null; -} // We want this to be the default dispatcher on ReactDOMSharedInternals but we don't want to mutate -// internals in Module scope. Instead we export it and Internals will import it. There is already a cycle -// from Internals -> ReactDOM -> FloatClient -> Internals so this doesn't introduce a new one. +var hydrationParentFiber = null; +var nextHydratableInstance = null; +var isHydrating = false; // This flag allows for warning supression when we expect there to be mismatches +// due to earlier mismatches or a suspended fiber. -var ReactDOMClientDispatcher = { - preload: preload, - preinit: preinit -}; -// global maps of Resources -var preloadResources = new Map(); // getRootNode is missing from IE and old jsdom versions +var didSuspendOrErrorDEV = false; // Hydration errors that were thrown inside this boundary -function getRootNode(container) { - // $FlowFixMe[method-unbinding] - return typeof container.getRootNode === "function" - ? /* $FlowFixMe[incompatible-return] Flow types this as returning a `Node`, - * but it's either a `Document` or `ShadowRoot`. */ - container.getRootNode() - : container.ownerDocument; -} +var hydrationErrors = null; -function getCurrentResourceRoot() { - var currentContainer = getCurrentRootHostContainer(); // $FlowFixMe flow should know currentContainer is a Node and has getRootNode - - return currentContainer ? getRootNode(currentContainer) : null; -} // This resource type constraint can be loosened. It really is everything except PreloadResource -// because that is the only one that does not have an optional instance type. Expand as needed. - -function resetInstance(resource) { - resource.instance = undefined; +function warnIfHydrating() { + { + if (isHydrating) { + error( + "We should not be hydrating here. This is a bug in React. Please file a bug." + ); + } + } } -function clearRootResources(rootContainer) { - var rootNode = getRootNode(rootContainer); - var resources = getResourcesFromRoot(rootNode); // We can't actually delete the resource cache because this function is called - // during commit after we have rendered. Instead we detatch any instances from - // the Resource object if they are going to be cleared - // Styles stay put - // Scripts get reset - - resources.scripts.forEach(resetInstance); // Head Resources get reset - - resources.head.forEach(resetInstance); // lastStructuredMeta stays put -} // Preloads are somewhat special. Even if we don't have the Document -// used by the root that is rendering a component trying to insert a preload -// we can still seed the file cache by doing the preload on any document we have -// access to. We prefer the currentDocument if it exists, we also prefer the -// lastCurrentDocument if that exists. As a fallback we will use the window.document -// if available. - -function getDocumentForPreloads() { - var root = getCurrentResourceRoot(); - - if (root) { - return root.ownerDocument || root; - } else { - try { - return lastCurrentDocument || window.document; - } catch (error) { - return null; - } +function markDidThrowWhileHydratingDEV() { + { + didSuspendOrErrorDEV = true; } } -function getDocumentFromRoot(root) { - return root.ownerDocument || root; -} // -------------------------------------- -// ReactDOM.Preload -// -------------------------------------- +function enterHydrationState(fiber) { + var parentInstance = fiber.stateNode.containerInfo; + nextHydratableInstance = getFirstHydratableChildWithinContainer( + parentInstance + ); + hydrationParentFiber = fiber; + isHydrating = true; + hydrationErrors = null; + didSuspendOrErrorDEV = false; + return true; +} -function preload(href, options) { - { - validatePreloadArguments(href, options); +function reenterHydrationStateFromDehydratedSuspenseInstance( + fiber, + suspenseInstance, + treeContext +) { + nextHydratableInstance = getFirstHydratableChildWithinSuspenseInstance( + suspenseInstance + ); + hydrationParentFiber = fiber; + isHydrating = true; + hydrationErrors = null; + didSuspendOrErrorDEV = false; + + if (treeContext !== null) { + restoreSuspendedTreeContext(fiber, treeContext); } - var ownerDocument = getDocumentForPreloads(); + return true; +} - if ( - typeof href === "string" && - href && - typeof options === "object" && - options !== null && - ownerDocument - ) { - var as = options.as; - var resource = preloadResources.get(href); +function warnUnhydratedInstance(returnFiber, instance) { + { + switch (returnFiber.tag) { + case HostRoot: { + didNotHydrateInstanceWithinContainer( + returnFiber.stateNode.containerInfo, + instance + ); + break; + } - if (resource) { - { - var originallyImplicit = resource._dev_implicit_construction === true; - var latestProps = preloadPropsFromPreloadOptions(href, as, options); - validatePreloadResourceDifference( - resource.props, - originallyImplicit, - latestProps, - false + case HostSingleton: + case HostComponent: { + var isConcurrentMode = (returnFiber.mode & ConcurrentMode) !== NoMode; + didNotHydrateInstance( + returnFiber.type, + returnFiber.memoizedProps, + returnFiber.stateNode, + instance, // TODO: Delete this argument when we remove the legacy root API. + isConcurrentMode ); + break; + } + + case SuspenseComponent: { + var suspenseState = returnFiber.memoizedState; + if (suspenseState.dehydrated !== null) + didNotHydrateInstanceWithinSuspenseInstance( + suspenseState.dehydrated, + instance + ); + break; } - } else { - var resourceProps = preloadPropsFromPreloadOptions(href, as, options); - createPreloadResource(ownerDocument, href, resourceProps); } } } -function preloadPropsFromPreloadOptions(href, as, options) { - return { - href: href, - rel: "preload", - as: as, - crossOrigin: as === "font" ? "" : options.crossOrigin, - integrity: options.integrity - }; -} // -------------------------------------- -// ReactDOM.preinit -// -------------------------------------- +function deleteHydratableInstance(returnFiber, instance) { + warnUnhydratedInstance(returnFiber, instance); + var childToDelete = createFiberFromHostInstanceForDeletion(); + childToDelete.stateNode = instance; + childToDelete.return = returnFiber; + var deletions = returnFiber.deletions; -function preinit(href, options) { - { - validatePreinitArguments(href, options); + if (deletions === null) { + returnFiber.deletions = [childToDelete]; + returnFiber.flags |= ChildDeletion; + } else { + deletions.push(childToDelete); } +} - if ( - typeof href === "string" && - href && - typeof options === "object" && - options !== null - ) { - var resourceRoot = getCurrentResourceRoot(); - var as = options.as; - - if (!resourceRoot) { - // We are going to emit a preload as a best effort fallback since this preinit - // was called outside of a render. Given the passive nature of this fallback - // we do not warn in dev when props disagree if there happens to already be a - // matching preload with this href - var preloadDocument = getDocumentForPreloads(); - - if (preloadDocument) { - var preloadResource = preloadResources.get(href); - - if (!preloadResource) { - var preloadProps = preloadPropsFromPreinitOptions(href, as, options); - createPreloadResource(preloadDocument, href, preloadProps); - } - } - +function warnNonhydratedInstance(returnFiber, fiber) { + { + if (didSuspendOrErrorDEV) { + // Inside a boundary that already suspended. We're currently rendering the + // siblings of a suspended node. The mismatch may be due to the missing + // data, so it's probably a false positive. return; } - switch (as) { - case "style": { - var styleResources = getResourcesFromRoot(resourceRoot).styles; - var precedence = options.precedence || "default"; - var resource = styleResources.get(href); + switch (returnFiber.tag) { + case HostRoot: { + var parentContainer = returnFiber.stateNode.containerInfo; - if (resource) { - { - var latestProps = stylePropsFromPreinitOptions( - href, - precedence, - options + switch (fiber.tag) { + case HostSingleton: + case HostComponent: + var type = fiber.type; + var props = fiber.pendingProps; + didNotFindHydratableInstanceWithinContainer(parentContainer, type); + break; + + case HostText: + var text = fiber.pendingProps; + didNotFindHydratableTextInstanceWithinContainer( + parentContainer, + text ); - validateStyleResourceDifference(resource.props, latestProps); - } - } else { - var resourceProps = stylePropsFromPreinitOptions( - href, - precedence, - options - ); - resource = createStyleResource( - styleResources, - resourceRoot, - href, - precedence, - resourceProps - ); + break; } - acquireResource(resource); - return; + break; } - case "script": { - var src = href; - var scriptResources = getResourcesFromRoot(resourceRoot).scripts; - - var _resource = scriptResources.get(src); - - if (_resource) { - { - var _latestProps = scriptPropsFromPreinitOptions(src, options); - - validateScriptResourceDifference(_resource.props, _latestProps); - } - } else { - var _resourceProps = scriptPropsFromPreinitOptions(src, options); + case HostSingleton: + case HostComponent: { + var parentType = returnFiber.type; + var parentProps = returnFiber.memoizedProps; + var parentInstance = returnFiber.stateNode; - _resource = createScriptResource( - scriptResources, - resourceRoot, - src, - _resourceProps - ); + switch (fiber.tag) { + case HostSingleton: + case HostComponent: { + var _type = fiber.type; + var _props = fiber.pendingProps; + var isConcurrentMode = + (returnFiber.mode & ConcurrentMode) !== NoMode; + didNotFindHydratableInstance( + parentType, + parentProps, + parentInstance, + _type, + _props, // TODO: Delete this argument when we remove the legacy root API. + isConcurrentMode + ); + break; + } + + case HostText: { + var _text = fiber.pendingProps; + + var _isConcurrentMode = + (returnFiber.mode & ConcurrentMode) !== NoMode; + + didNotFindHydratableTextInstance( + parentType, + parentProps, + parentInstance, + _text, // TODO: Delete this argument when we remove the legacy root API. + _isConcurrentMode + ); + break; + } } - acquireResource(_resource); - return; + break; + } + + case SuspenseComponent: { + var suspenseState = returnFiber.memoizedState; + var _parentInstance = suspenseState.dehydrated; + if (_parentInstance !== null) + switch (fiber.tag) { + case HostSingleton: + case HostComponent: + var _type2 = fiber.type; + var _props2 = fiber.pendingProps; + didNotFindHydratableInstanceWithinSuspenseInstance( + _parentInstance, + _type2 + ); + break; + + case HostText: + var _text2 = fiber.pendingProps; + didNotFindHydratableTextInstanceWithinSuspenseInstance( + _parentInstance, + _text2 + ); + break; + } + break; } + + default: + return; } } } -function preloadPropsFromPreinitOptions(href, as, options) { - return { - href: href, - rel: "preload", - as: as, - crossOrigin: as === "font" ? "" : options.crossOrigin, - integrity: options.integrity - }; -} - -function stylePropsFromPreinitOptions(href, precedence, options) { - return { - rel: "stylesheet", - href: href, - "data-precedence": precedence, - crossOrigin: options.crossOrigin - }; +function insertNonHydratedInstance(returnFiber, fiber) { + fiber.flags = (fiber.flags & ~Hydrating) | Placement; + warnNonhydratedInstance(returnFiber, fiber); } -function scriptPropsFromPreinitOptions(src, options) { - return { - src: src, - async: true, - crossOrigin: options.crossOrigin, - integrity: options.integrity - }; -} // -------------------------------------- -// Resources from render -// -------------------------------------- +function tryHydrate(fiber, nextInstance) { + switch (fiber.tag) { + // HostSingleton is intentionally omitted. the hydration pathway for singletons is non-fallible + // you can find it inlined in claimHydratableSingleton + case HostComponent: { + var type = fiber.type; + var props = fiber.pendingProps; + var instance = canHydrateInstance(nextInstance, type); -function getTitleKey(child) { - return "title:" + child; -} // This function is called in begin work and we should always have a currentDocument set + if (instance !== null) { + fiber.stateNode = instance; + hydrationParentFiber = fiber; + nextHydratableInstance = getFirstHydratableChild(instance); + return true; + } -function getResource(type, pendingProps, currentProps) { - var resourceRoot = getCurrentResourceRoot(); + return false; + } - if (!resourceRoot) { - throw new Error( - '"resourceRoot" was expected to exist. This is a bug in React.' - ); - } + case HostText: { + var text = fiber.pendingProps; + var textInstance = canHydrateTextInstance(nextInstance, text); - switch (type) { - case "base": { - var headRoot = getDocumentFromRoot(resourceRoot); - var headResources = getResourcesFromRoot(headRoot).head; - var target = pendingProps.target, - href = pendingProps.href; - var matcher = "base"; - matcher += - typeof href === "string" - ? '[href="' + - escapeSelectorAttributeValueInsideDoubleQuotes(href) + - '"]' - : ":not([href])"; - matcher += - typeof target === "string" - ? '[target="' + - escapeSelectorAttributeValueInsideDoubleQuotes(target) + - '"]' - : ":not([target])"; - var resource = headResources.get(matcher); + if (textInstance !== null) { + fiber.stateNode = textInstance; + hydrationParentFiber = fiber; // Text Instances don't have children so there's nothing to hydrate. - if (!resource) { - resource = { - type: "base", - matcher: matcher, - props: assign({}, pendingProps), - count: 0, - instance: null, - root: headRoot - }; - headResources.set(matcher, resource); + nextHydratableInstance = null; + return true; } - return resource; + return false; } - case "meta": { - var _matcher, propertyString, parentResource; - - var charSet = pendingProps.charSet, - content = pendingProps.content, - httpEquiv = pendingProps.httpEquiv, - name = pendingProps.name, - itemProp = pendingProps.itemProp, - property = pendingProps.property; - - var _headRoot = getDocumentFromRoot(resourceRoot); + case SuspenseComponent: { + var suspenseInstance = canHydrateSuspenseInstance(nextInstance); - var _getResourcesFromRoot = getResourcesFromRoot(_headRoot), - _headResources = _getResourcesFromRoot.head, - lastStructuredMeta = _getResourcesFromRoot.lastStructuredMeta; + if (suspenseInstance !== null) { + var suspenseState = { + dehydrated: suspenseInstance, + treeContext: getSuspendedTreeContext(), + retryLane: OffscreenLane + }; + fiber.memoizedState = suspenseState; // Store the dehydrated fragment as a child fiber. + // This simplifies the code for getHostSibling and deleting nodes, + // since it doesn't have to consider all Suspense boundaries and + // check if they're dehydrated ones or not. - if (typeof charSet === "string") { - _matcher = "meta[charset]"; - } else if (typeof content === "string") { - if (typeof httpEquiv === "string") { - _matcher = - 'meta[http-equiv="' + - escapeSelectorAttributeValueInsideDoubleQuotes(httpEquiv) + - '"][content="' + - escapeSelectorAttributeValueInsideDoubleQuotes(content) + - '"]'; - } else if (typeof property === "string") { - propertyString = property; - _matcher = - 'meta[property="' + - escapeSelectorAttributeValueInsideDoubleQuotes(property) + - '"][content="' + - escapeSelectorAttributeValueInsideDoubleQuotes(content) + - '"]'; - var parentPropertyPath = property - .split(":") - .slice(0, -1) - .join(":"); - parentResource = lastStructuredMeta.get(parentPropertyPath); + var dehydratedFragment = createFiberFromDehydratedFragment( + suspenseInstance + ); + dehydratedFragment.return = fiber; + fiber.child = dehydratedFragment; + hydrationParentFiber = fiber; // While a Suspense Instance does have children, we won't step into + // it during the first pass. Instead, we'll reenter it later. - if (parentResource) { - // When using parentResource the matcher is not functional for locating - // the instance in the DOM but it still serves as a unique key. - _matcher = parentResource.matcher + _matcher; - } - } else if (typeof name === "string") { - _matcher = - 'meta[name="' + - escapeSelectorAttributeValueInsideDoubleQuotes(name) + - '"][content="' + - escapeSelectorAttributeValueInsideDoubleQuotes(content) + - '"]'; - } else if (typeof itemProp === "string") { - _matcher = - 'meta[itemprop="' + - escapeSelectorAttributeValueInsideDoubleQuotes(itemProp) + - '"][content="' + - escapeSelectorAttributeValueInsideDoubleQuotes(content) + - '"]'; - } + nextHydratableInstance = null; + return true; } - if (_matcher) { - var _resource2 = _headResources.get(_matcher); + return false; + } - if (!_resource2) { - _resource2 = { - type: "meta", - matcher: _matcher, - property: propertyString, - parentResource: parentResource, - props: assign({}, pendingProps), - count: 0, - instance: null, - root: _headRoot - }; - - _headResources.set(_matcher, _resource2); - } + default: + return false; + } +} - if (typeof _resource2.property === "string") { - // We cast because flow doesn't know that this resource must be a Meta resource - lastStructuredMeta.set(_resource2.property, _resource2); - } +function shouldClientRenderOnMismatch(fiber) { + return ( + (fiber.mode & ConcurrentMode) !== NoMode && + (fiber.flags & DidCapture) === NoFlags + ); +} - return _resource2; - } +function throwOnHydrationMismatch(fiber) { + throw new Error( + "Hydration failed because the initial UI does not match what was " + + "rendered on the server." + ); +} - return null; +function claimHydratableSingleton(fiber) { + { + if (!isHydrating) { + return; } - case "title": { - var children = pendingProps.children; - var child; - - if (Array.isArray(children)) { - child = children.length === 1 ? children[0] : null; - } else { - child = children; - } + var currentRootContainer = getRootHostContainer(); + var currentHostContext = getHostContext(); + var instance = (fiber.stateNode = resolveSingletonInstance( + fiber.type, + fiber.pendingProps, + currentRootContainer, + currentHostContext, + false + )); + hydrationParentFiber = fiber; + nextHydratableInstance = getFirstHydratableChild(instance); + } +} - if ( - typeof child !== "function" && - typeof child !== "symbol" && - child !== null && - child !== undefined - ) { - // eslint-disable-next-line react-internal/safe-string-coercion - var childString = "" + child; +function tryToClaimNextHydratableInstance(fiber) { + if (!isHydrating) { + return; + } - var _headRoot2 = getDocumentFromRoot(resourceRoot); + if (!isHydratable(fiber.type, fiber.pendingProps)) { + // This fiber never hydrates from the DOM and always does an insert + fiber.flags = (fiber.flags & ~Hydrating) | Placement; + isHydrating = false; + hydrationParentFiber = fiber; + return; + } - var _headResources2 = getResourcesFromRoot(_headRoot2).head; - var key = getTitleKey(childString); + var nextInstance = nextHydratableInstance; - var _resource3 = _headResources2.get(key); + if (!nextInstance) { + if (shouldClientRenderOnMismatch(fiber)) { + warnNonhydratedInstance(hydrationParentFiber, fiber); + throwOnHydrationMismatch(); + } // Nothing to hydrate. Make it an insertion. - if (!_resource3) { - var titleProps = titlePropsFromRawProps(childString, pendingProps); - _resource3 = { - type: "title", - props: titleProps, - count: 0, - instance: null, - root: _headRoot2 - }; + insertNonHydratedInstance(hydrationParentFiber, fiber); + isHydrating = false; + hydrationParentFiber = fiber; + return; + } - _headResources2.set(key, _resource3); - } + var firstAttemptedInstance = nextInstance; - return _resource3; - } + if (!tryHydrate(fiber, nextInstance)) { + if (shouldClientRenderOnMismatch(fiber)) { + warnNonhydratedInstance(hydrationParentFiber, fiber); + throwOnHydrationMismatch(); + } // If we can't hydrate this instance let's try the next one. + // We use this as a heuristic. It's based on intuition and not data so it + // might be flawed or unnecessary. - return null; - } + nextInstance = getNextHydratableSibling(firstAttemptedInstance); + var prevHydrationParentFiber = hydrationParentFiber; - case "link": { - var rel = pendingProps.rel; + if (!nextInstance || !tryHydrate(fiber, nextInstance)) { + // Nothing to hydrate. Make it an insertion. + insertNonHydratedInstance(hydrationParentFiber, fiber); + isHydrating = false; + hydrationParentFiber = fiber; + return; + } // We matched the next one, we'll now assume that the first one was + // superfluous and we'll delete it. Since we can't eagerly delete it + // we'll have to schedule a deletion. To do that, this node needs a dummy + // fiber associated with it. - switch (rel) { - case "stylesheet": { - var styleResources = getResourcesFromRoot(resourceRoot).styles; - var didWarn; + deleteHydratableInstance(prevHydrationParentFiber, firstAttemptedInstance); + } +} - { - if (currentProps) { - didWarn = validateURLKeyedUpdatedProps( - pendingProps, - currentProps, - "style", - "href" - ); - } +function prepareToHydrateHostInstance(fiber, hostContext) { + var instance = fiber.stateNode; + var shouldWarnIfMismatchDev = !didSuspendOrErrorDEV; + var updatePayload = hydrateInstance( + instance, + fiber.type, + fiber.memoizedProps, + hostContext, + fiber, + shouldWarnIfMismatchDev + ); // TODO: Type this specific to this type of component. - if (!didWarn) { - didWarn = validateLinkPropsForStyleResource(pendingProps); - } - } + fiber.updateQueue = updatePayload; // If the update payload indicates that there is a change or if there + // is a new ref we mark this as an update. - var precedence = pendingProps.precedence, - _href = pendingProps.href; + if (updatePayload !== null) { + return true; + } - if (typeof _href === "string" && typeof precedence === "string") { - // We've asserted all the specific types for StyleQualifyingProps - var styleRawProps = pendingProps; // We construct or get an existing resource for the style itself and return it + return false; +} - var _resource4 = styleResources.get(_href); +function prepareToHydrateHostTextInstance(fiber) { + var textInstance = fiber.stateNode; + var textContent = fiber.memoizedProps; + var shouldWarnIfMismatchDev = !didSuspendOrErrorDEV; + var shouldUpdate = hydrateTextInstance(textInstance, textContent, fiber); - if (_resource4) { - { - if (!didWarn) { - var latestProps = stylePropsFromRawProps(styleRawProps); + if (shouldUpdate) { + // We assume that prepareToHydrateHostTextInstance is called in a context where the + // hydration parent is the parent host component of this host text. + var returnFiber = hydrationParentFiber; - if (_resource4._dev_preload_props) { - adoptPreloadPropsForStyle( - latestProps, - _resource4._dev_preload_props - ); - } + if (returnFiber !== null) { + switch (returnFiber.tag) { + case HostRoot: { + var parentContainer = returnFiber.stateNode.containerInfo; + var isConcurrentMode = (returnFiber.mode & ConcurrentMode) !== NoMode; + didNotMatchHydratedContainerTextInstance( + parentContainer, + textInstance, + textContent, // TODO: Delete this argument when we remove the legacy root API. + isConcurrentMode, + shouldWarnIfMismatchDev + ); + break; + } - validateStyleResourceDifference( - _resource4.props, - latestProps - ); - } - } - } else { - var resourceProps = stylePropsFromRawProps(styleRawProps); - _resource4 = createStyleResource( - styleResources, - resourceRoot, - _href, - precedence, - resourceProps - ); - immediatelyPreloadStyleResource(_resource4); - } + case HostSingleton: + case HostComponent: { + var parentType = returnFiber.type; + var parentProps = returnFiber.memoizedProps; + var parentInstance = returnFiber.stateNode; - return _resource4; - } + var _isConcurrentMode2 = + (returnFiber.mode & ConcurrentMode) !== NoMode; - return null; + didNotMatchHydratedTextInstance( + parentType, + parentProps, + parentInstance, + textInstance, + textContent, // TODO: Delete this argument when we remove the legacy root API. + _isConcurrentMode2, + shouldWarnIfMismatchDev + ); + break; } + } + } + } - case "preload": { - { - validateLinkPropsForPreloadResource(pendingProps); - } + return shouldUpdate; +} - var _href2 = pendingProps.href; +function prepareToHydrateHostSuspenseInstance(fiber) { + var suspenseState = fiber.memoizedState; + var suspenseInstance = + suspenseState !== null ? suspenseState.dehydrated : null; - if (typeof _href2 === "string") { - // We've asserted all the specific types for PreloadQualifyingProps - var preloadRawProps = pendingProps; - - var _resource5 = preloadResources.get(_href2); - - if (_resource5) { - { - var originallyImplicit = - _resource5._dev_implicit_construction === true; - - var _latestProps2 = preloadPropsFromRawProps(preloadRawProps); - - validatePreloadResourceDifference( - _resource5.props, - originallyImplicit, - _latestProps2, - false - ); - } - } else { - var _resourceProps2 = preloadPropsFromRawProps(preloadRawProps); - - _resource5 = createPreloadResource( - getDocumentFromRoot(resourceRoot), - _href2, - _resourceProps2 - ); - } - - return _resource5; - } - - return null; - } + if (!suspenseInstance) { + throw new Error( + "Expected to have a hydrated suspense instance. " + + "This error is likely caused by a bug in React. Please file an issue." + ); + } - default: { - var _href3 = pendingProps.href, - sizes = pendingProps.sizes, - media = pendingProps.media; + hydrateSuspenseInstance(suspenseInstance, fiber); +} - if (typeof rel === "string" && typeof _href3 === "string") { - var sizeKey = "::sizes:" + (typeof sizes === "string" ? sizes : ""); - var mediaKey = - "::media:" + (typeof media === "string" ? media : ""); +function skipPastDehydratedSuspenseInstance(fiber) { + var suspenseState = fiber.memoizedState; + var suspenseInstance = + suspenseState !== null ? suspenseState.dehydrated : null; - var _key = "rel:" + rel + "::href:" + _href3 + sizeKey + mediaKey; + if (!suspenseInstance) { + throw new Error( + "Expected to have a hydrated suspense instance. " + + "This error is likely caused by a bug in React. Please file an issue." + ); + } - var _headRoot3 = getDocumentFromRoot(resourceRoot); + return getNextHydratableInstanceAfterSuspenseInstance(suspenseInstance); +} - var _headResources3 = getResourcesFromRoot(_headRoot3).head; +function popToNextHostParent(fiber) { + var parent = fiber.return; - var _resource6 = _headResources3.get(_key); + while ( + parent !== null && + parent.tag !== HostComponent && + parent.tag !== HostRoot && + parent.tag !== SuspenseComponent && + parent.tag !== HostSingleton + ) { + parent = parent.return; + } - if (!_resource6) { - _resource6 = { - type: "link", - props: assign({}, pendingProps), - count: 0, - instance: null, - root: _headRoot3 - }; + hydrationParentFiber = parent; +} - _headResources3.set(_key, _resource6); - } +function popHydrationState(fiber) { + if (fiber !== hydrationParentFiber) { + // We're deeper than the current hydration context, inside an inserted + // tree. + return false; + } - return _resource6; - } + if (!isHydrating) { + // If we're not currently hydrating but we're in a hydration context, then + // we were an insertion and now need to pop up reenter hydration of our + // siblings. + popToNextHostParent(fiber); + isHydrating = true; + return false; + } - { - warnOnMissingHrefAndRel(pendingProps, currentProps); - } + var shouldClear = false; - return null; - } - } + { + // With float we never clear the Root, or Singleton instances. We also do not clear Instances + // that have singleton text content + if ( + fiber.tag !== HostRoot && + fiber.tag !== HostSingleton && + !( + fiber.tag === HostComponent && + shouldSetTextContent(fiber.type, fiber.memoizedProps) + ) + ) { + shouldClear = true; } + } - case "script": { - var scriptResources = getResourcesFromRoot(resourceRoot).scripts; - - var _didWarn; + if (shouldClear) { + var nextInstance = nextHydratableInstance; - { - if (currentProps) { - _didWarn = validateURLKeyedUpdatedProps( - pendingProps, - currentProps, - "script", - "src" - ); + if (nextInstance) { + if (shouldClientRenderOnMismatch(fiber)) { + warnIfUnhydratedTailNodes(fiber); + throwOnHydrationMismatch(); + } else { + while (nextInstance) { + deleteHydratableInstance(fiber, nextInstance); + nextInstance = getNextHydratableSibling(nextInstance); } } + } + } - var src = pendingProps.src, - async = pendingProps.async; - - if (async && typeof src === "string") { - var scriptRawProps = pendingProps; - - var _resource7 = scriptResources.get(src); - - if (_resource7) { - { - if (!_didWarn) { - var _latestProps3 = scriptPropsFromRawProps(scriptRawProps); - - if (_resource7._dev_preload_props) { - adoptPreloadPropsForScript( - _latestProps3, - _resource7._dev_preload_props - ); - } + popToNextHostParent(fiber); - validateScriptResourceDifference(_resource7.props, _latestProps3); - } - } - } else { - var _resourceProps3 = scriptPropsFromRawProps(scriptRawProps); + if (fiber.tag === SuspenseComponent) { + nextHydratableInstance = skipPastDehydratedSuspenseInstance(fiber); + } else { + nextHydratableInstance = hydrationParentFiber + ? getNextHydratableSibling(fiber.stateNode) + : null; + } - _resource7 = createScriptResource( - scriptResources, - resourceRoot, - src, - _resourceProps3 - ); - } + return true; +} - return _resource7; - } +function hasUnhydratedTailNodes() { + return isHydrating && nextHydratableInstance !== null; +} - return null; - } +function warnIfUnhydratedTailNodes(fiber) { + var nextInstance = nextHydratableInstance; - default: { - throw new Error( - 'getResource encountered a resource type it did not expect: "' + - type + - '". this is a bug in React.' - ); - } + while (nextInstance) { + warnUnhydratedInstance(fiber, nextInstance); + nextInstance = getNextHydratableSibling(nextInstance); } } -function preloadPropsFromRawProps(rawBorrowedProps) { - return assign({}, rawBorrowedProps); +function resetHydrationState() { + hydrationParentFiber = null; + nextHydratableInstance = null; + isHydrating = false; + didSuspendOrErrorDEV = false; } -function titlePropsFromRawProps(child, rawProps) { - var props = assign({}, rawProps); - - props.children = child; - return props; +function upgradeHydrationErrorsToRecoverable() { + if (hydrationErrors !== null) { + // Successfully completed a forced client render. The errors that occurred + // during the hydration attempt are now recovered. We will log them in + // commit phase, once the entire tree has finished. + queueRecoverableErrors(hydrationErrors); + hydrationErrors = null; + } } -function stylePropsFromRawProps(rawProps) { - var props = assign({}, rawProps); +function getIsHydrating() { + return isHydrating; +} - props["data-precedence"] = rawProps.precedence; - props.precedence = null; - return props; +function queueHydrationError(error) { + if (hydrationErrors === null) { + hydrationErrors = [error]; + } else { + hydrationErrors.push(error); + } } -function scriptPropsFromRawProps(rawProps) { - var props = assign({}, rawProps); +// If a render is in progress, and we receive an update from a concurrent event, +// 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. +var concurrentQueues = []; +var concurrentQueuesIndex = 0; +var concurrentlyUpdatedLanes = NoLanes; +function finishQueueingConcurrentUpdates() { + var endIndex = concurrentQueuesIndex; + concurrentQueuesIndex = 0; + concurrentlyUpdatedLanes = NoLanes; + var i = 0; - return props; -} // -------------------------------------- -// Resource Reconciliation -// -------------------------------------- - -function acquireResource(resource) { - switch (resource.type) { - case "base": - case "title": - case "link": - case "meta": { - return acquireHeadResource(resource); - } + 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; - case "style": { - return acquireStyleResource(resource); - } + if (queue !== null && update !== null) { + var pending = queue.pending; - case "script": { - return acquireScriptResource(resource); - } + if (pending === null) { + // This is the first update. Create a circular list. + update.next = update; + } else { + update.next = pending.next; + pending.next = update; + } - case "preload": { - return resource.instance; + queue.pending = update; } - default: { - throw new Error( - 'acquireResource encountered a resource type it did not expect: "' + - resource.type + - '". this is a bug in React.' - ); + if (lane !== NoLane) { + markUpdateLaneFromFiberToRoot(fiber, update, lane); } } } -function releaseResource(resource) { - switch (resource.type) { - case "link": - case "title": - case "meta": { - return releaseHeadResource(resource); - } - - case "style": { - resource.count--; - return; - } - } +function getConcurrentlyUpdatedLanes() { + return concurrentlyUpdatedLanes; } -function releaseHeadResource(resource) { - if (--resource.count === 0) { - // the instance will have existed since we acquired it - var instance = resource.instance; - var parent = instance.parentNode; +function enqueueUpdate(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. - if (parent) { - parent.removeChild(instance); - } + fiber.lanes = mergeLanes(fiber.lanes, lane); + var alternate = fiber.alternate; - resource.instance = null; + if (alternate !== null) { + alternate.lanes = mergeLanes(alternate.lanes, lane); } } -function createResourceInstance(type, props, ownerDocument) { - var element = createElement(type, props, ownerDocument, HTML_NAMESPACE); - setInitialProperties(element, type, props); - markNodeAsResource(element); - return element; +function enqueueConcurrentHookUpdate(fiber, queue, update, lane) { + var concurrentQueue = queue; + var concurrentUpdate = update; + enqueueUpdate(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(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 createStyleResource(styleResources, root, href, precedence, props) { - { - if (styleResources.has(href)) { - error( - "createStyleResource was called when a style Resource matching the same href already exists. This is a bug in React." - ); - } + var isConcurrentlyRendering = getWorkInProgressRoot() !== null; + + if (!isConcurrentlyRendering) { + finishQueueingConcurrentUpdates(); } +} +function enqueueConcurrentClassUpdate(fiber, queue, update, lane) { + var concurrentQueue = queue; + var concurrentUpdate = update; + enqueueUpdate(fiber, concurrentQueue, concurrentUpdate, lane); + return getRootForUpdatedFiber(fiber); +} +function enqueueConcurrentRenderForLane(fiber, lane) { + enqueueUpdate(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. - var limitedEscapedHref = escapeSelectorAttributeValueInsideDoubleQuotes(href); - var existingEl = root.querySelector( - 'link[rel="stylesheet"][href="' + limitedEscapedHref + '"]' - ); - var resource = { - type: "style", - count: 0, - href: href, - precedence: precedence, - props: props, - hint: null, - preloaded: false, - loaded: false, - error: false, - root: root, - instance: null - }; - styleResources.set(href, resource); +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; +} - if (existingEl) { - // If we have an existing element in the DOM we don't need to preload this resource nor can we - // adopt props from any preload that might exist already for this resource. We do need to try - // to reify the Resource loading state the best we can. - var loadingState = existingEl._p; +function markUpdateLaneFromFiberToRoot(sourceFiber, update, lane) { + // Update the source fiber's lanes + sourceFiber.lanes = mergeLanes(sourceFiber.lanes, lane); + var alternate = sourceFiber.alternate; - if (loadingState) { - switch (loadingState.s) { - case "l": { - resource.loaded = true; - break; - } + if (alternate !== null) { + alternate.lanes = mergeLanes(alternate.lanes, lane); + } // Walk the parent path to the root and update the child lanes. - case "e": { - resource.error = true; - break; - } + var isHidden = false; + var parent = sourceFiber.return; + var node = sourceFiber; - default: { - attachLoadListeners(existingEl, resource); - } - } - } else { - // This is unfortunately just an assumption. The rationale here is that stylesheets without - // a loading state must have been flushed in the shell and would have blocked until loading - // or error. we can't know afterwards which happened for all types of stylesheets (cross origin) - // for instance) and the techniques for determining if a sheet has loaded that we do have still - // fail if the sheet loaded zero rules. At the moment we are going to just opt to assume the - // sheet is loaded if it was flushed in the shell - resource.loaded = true; - } - } else { - var hint = preloadResources.get(href); + while (parent !== null) { + parent.childLanes = mergeLanes(parent.childLanes, lane); + alternate = parent.alternate; - if (hint) { - // $FlowFixMe[incompatible-type]: found when upgrading Flow - resource.hint = hint; // If a preload for this style Resource already exists there are certain props we want to adopt - // on the style Resource, primarily focussed on making sure the style network pathways utilize - // the preload pathways. For instance if you have diffreent crossOrigin attributes for a preload - // and a stylesheet the stylesheet will make a new request even if the preload had already loaded + if (alternate !== null) { + alternate.childLanes = mergeLanes(alternate.childLanes, lane); + } - var preloadProps = hint.props; - adoptPreloadPropsForStyle(resource.props, hint.props); + 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; - { - resource._dev_preload_props = preloadProps; + if ( + offscreenInstance !== null && + !(offscreenInstance._visibility & OffscreenVisible) + ) { + isHidden = true; } } + + node = parent; + parent = parent.return; } - return resource; + if (isHidden && update !== null && node.tag === HostRoot) { + var root = node.stateNode; + markHiddenUpdate(root, update, lane); + } } -function adoptPreloadPropsForStyle(styleProps, preloadProps) { - if (styleProps.crossOrigin == null) - styleProps.crossOrigin = preloadProps.crossOrigin; - if (styleProps.referrerPolicy == null) - styleProps.referrerPolicy = preloadProps.referrerPolicy; - if (styleProps.title == null) styleProps.title = preloadProps.title; -} +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. -function immediatelyPreloadStyleResource(resource) { - // This function must be called synchronously after creating a styleResource otherwise it may - // violate assumptions around the existence of a preload. The reason it is extracted out is we - // don't always want to preload a style, in particular when we are going to synchronously insert - // that style. We confirm the style resource has no preload already and then construct it. If - // we wait and call this later it is possible a preload will already exist for this href - if (resource.loaded === false && resource.hint === null) { - var href = resource.href, - props = resource.props; - var preloadProps = preloadPropsFromStyleProps(props); - resource.hint = createPreloadResource( - getDocumentFromRoot(resource.root), - href, - preloadProps - ); + detectUpdateOnUnmountedFiber(sourceFiber, sourceFiber); + var node = sourceFiber; + var parent = node.return; + + while (parent !== null) { + detectUpdateOnUnmountedFiber(sourceFiber, node); + node = parent; + parent = node.return; } -} -function preloadPropsFromStyleProps(props) { - return { - rel: "preload", - as: "style", - href: props.href, - crossOrigin: props.crossOrigin, - integrity: props.integrity, - media: props.media, - hrefLang: props.hrefLang, - referrerPolicy: props.referrerPolicy - }; + return node.tag === HostRoot ? node.stateNode : null; } -function createScriptResource(scriptResources, root, src, props) { +function detectUpdateOnUnmountedFiber(sourceFiber, parent) { { - if (scriptResources.has(src)) { - error( - "createScriptResource was called when a script Resource matching the same src already exists. This is a bug in React." - ); + var alternate = parent.alternate; + + if ( + alternate === null && + (parent.flags & (Placement | Hydrating)) !== NoFlags + ) { + warnAboutUpdateOnNotYetMountedFiberInDEV(sourceFiber); } } +} - var limitedEscapedSrc = escapeSelectorAttributeValueInsideDoubleQuotes(src); - var existingEl = root.querySelector( - 'script[async][src="' + limitedEscapedSrc + '"]' - ); - var resource = { - type: "script", - src: src, - props: props, - root: root, - instance: existingEl || null - }; - scriptResources.set(src, resource); - - if (!existingEl) { - var hint = preloadResources.get(src); - - if (hint) { - // If a preload for this style Resource already exists there are certain props we want to adopt - // on the style Resource, primarily focussed on making sure the style network pathways utilize - // the preload pathways. For instance if you have diffreent crossOrigin attributes for a preload - // and a stylesheet the stylesheet will make a new request even if the preload had already loaded - var preloadProps = hint.props; - adoptPreloadPropsForScript(props, hint.props); +var UpdateState = 0; +var ReplaceState = 1; +var ForceUpdate = 2; +var CaptureUpdate = 3; // Global state that is reset at the beginning of calling `processUpdateQueue`. +// It should only be read right after calling `processUpdateQueue`, via +// `checkHasForceUpdateAfterProcessing`. - { - resource._dev_preload_props = preloadProps; - } - } - } else { - markNodeAsResource(existingEl); - } +var hasForceUpdate = false; +var didWarnUpdateInsideUpdate; +var currentlyProcessingQueue; - return resource; +{ + didWarnUpdateInsideUpdate = false; + currentlyProcessingQueue = null; } -function adoptPreloadPropsForScript(scriptProps, preloadProps) { - if (scriptProps.crossOrigin == null) - scriptProps.crossOrigin = preloadProps.crossOrigin; - if (scriptProps.referrerPolicy == null) - scriptProps.referrerPolicy = preloadProps.referrerPolicy; - if (scriptProps.integrity == null) - scriptProps.referrerPolicy = preloadProps.integrity; +function initializeUpdateQueue(fiber) { + var queue = { + baseState: fiber.memoizedState, + firstBaseUpdate: null, + lastBaseUpdate: null, + shared: { + pending: null, + lanes: NoLanes, + hiddenCallbacks: null + }, + callbacks: null + }; + fiber.updateQueue = queue; } +function cloneUpdateQueue(current, workInProgress) { + // Clone the update queue from current. Unless it's already a clone. + var queue = workInProgress.updateQueue; + var currentQueue = current.updateQueue; -function createPreloadResource(ownerDocument, href, props) { - var limitedEscapedHref = escapeSelectorAttributeValueInsideDoubleQuotes(href); - var element = ownerDocument.querySelector( - 'link[rel="preload"][href="' + limitedEscapedHref + '"]' - ); - - if (!element) { - element = createResourceInstance("link", props, ownerDocument); - insertResourceInstanceBefore(ownerDocument, element, null); - } else { - markNodeAsResource(element); + if (queue === currentQueue) { + var clone = { + baseState: currentQueue.baseState, + firstBaseUpdate: currentQueue.firstBaseUpdate, + lastBaseUpdate: currentQueue.lastBaseUpdate, + shared: currentQueue.shared, + callbacks: null + }; + workInProgress.updateQueue = clone; } - - return { - type: "preload", - href: href, - ownerDocument: ownerDocument, - props: props, - instance: element +} +function createUpdate(eventTime, lane) { + var update = { + eventTime: eventTime, + lane: lane, + tag: UpdateState, + payload: null, + callback: null, + next: null }; + return update; } +function enqueueUpdate$1(fiber, update, lane) { + var updateQueue = fiber.updateQueue; -function acquireHeadResource(resource) { - resource.count++; - var instance = resource.instance; - - if (!instance) { - var props = resource.props, - root = resource.root, - type = resource.type; + if (updateQueue === null) { + // Only occurs if the fiber has been unmounted. + return null; + } - switch (type) { - case "title": { - var titles = root.querySelectorAll("title"); + var sharedQueue = updateQueue.shared; - for (var i = 0; i < titles.length; i++) { - if (titles[i].textContent === props.children) { - instance = resource.instance = titles[i]; - markNodeAsResource(instance); - return instance; - } - } + { + if ( + currentlyProcessingQueue === sharedQueue && + !didWarnUpdateInsideUpdate + ) { + var componentName = getComponentNameFromFiber(fiber); - instance = resource.instance = createResourceInstance( - type, - props, - root - ); - var firstTitle = titles[0]; - insertResourceInstanceBefore( - root, - instance, - firstTitle && firstTitle.namespaceURI !== SVG_NAMESPACE - ? firstTitle - : null - ); - break; - } + error( + "An update (setState, replaceState, or forceUpdate) was scheduled " + + "from inside an update function. Update functions should be pure, " + + "with zero side-effects. Consider using componentDidUpdate or a " + + "callback.\n\nPlease update the following component: %s", + componentName + ); - case "meta": { - var insertBefore = null; - var metaResource = resource; - var matcher = metaResource.matcher, - property = metaResource.property, - parentResource = metaResource.parentResource; + didWarnUpdateInsideUpdate = true; + } + } - if (parentResource && typeof property === "string") { - // This resoruce is a structured meta type with a parent. - // Instead of using the matcher we just traverse forward - // siblings of the parent instance until we find a match - // or exhaust. - var parent = parentResource.instance; + if (isUnsafeClassRenderPhaseUpdate()) { + // This is an unsafe render phase update. Add directly to the update + // queue so we can process it immediately during the current render. + var pending = sharedQueue.pending; - if (parent) { - var node = null; - var nextNode = (insertBefore = parent.nextSibling); + if (pending === null) { + // This is the first update. Create a circular list. + update.next = update; + } else { + update.next = pending.next; + pending.next = update; + } - while ((node = nextNode)) { - nextNode = node.nextSibling; + sharedQueue.pending = update; // Update the childLanes even though we're most likely already rendering + // this fiber. This is for backwards compatibility in the case where you + // update a different component during render phase than the one that is + // currently renderings (a pattern that is accompanied by a warning). - if (node.nodeName === "META") { - var meta = node; - var propertyAttr = meta.getAttribute("property"); + return unsafe_markUpdateLaneFromFiberToRoot(fiber, lane); + } else { + return enqueueConcurrentClassUpdate(fiber, sharedQueue, update, lane); + } +} +function entangleTransitions(root, fiber, lane) { + var updateQueue = fiber.updateQueue; - if (typeof propertyAttr !== "string") { - continue; - } else if ( - propertyAttr === property && - meta.getAttribute("content") === props.content - ) { - resource.instance = meta; - markNodeAsResource(meta); - return meta; - } else if (property.startsWith(propertyAttr + ":")) { - // This meta starts a new instance of a parent structure for this meta type - // We need to halt our search here because even if we find a later match it - // is for a different parent element - break; - } - } - } - } - } else if ((instance = root.querySelector(matcher))) { - resource.instance = instance; - markNodeAsResource(instance); - return instance; - } + if (updateQueue === null) { + // Only occurs if the fiber has been unmounted. + return; + } - instance = resource.instance = createResourceInstance( - type, - props, - root - ); - insertResourceInstanceBefore(root, instance, insertBefore); - break; - } + var sharedQueue = updateQueue.shared; - case "link": { - var linkProps = props; - var limitedEscapedRel = escapeSelectorAttributeValueInsideDoubleQuotes( - linkProps.rel - ); - var limitedEscapedHref = escapeSelectorAttributeValueInsideDoubleQuotes( - linkProps.href - ); - var selector = - 'link[rel="' + - limitedEscapedRel + - '"][href="' + - limitedEscapedHref + - '"]'; + if (isTransitionLane(lane)) { + var queueLanes = sharedQueue.lanes; // If any entangled lanes are no longer pending on the root, then they must + // have finished. We can remove them from the shared queue, which represents + // a superset of the actually pending lanes. In some cases we may entangle + // more than we need to, but that's OK. In fact it's worse if we *don't* + // entangle when we should. - if (typeof linkProps.sizes === "string") { - var limitedEscapedSizes = escapeSelectorAttributeValueInsideDoubleQuotes( - linkProps.sizes - ); - selector += '[sizes="' + limitedEscapedSizes + '"]'; - } + queueLanes = intersectLanes(queueLanes, root.pendingLanes); // Entangle the new transition lane with the other transition lanes. - if (typeof linkProps.media === "string") { - var limitedEscapedMedia = escapeSelectorAttributeValueInsideDoubleQuotes( - linkProps.media - ); - selector += '[media="' + limitedEscapedMedia + '"]'; - } + var newQueueLanes = mergeLanes(queueLanes, lane); + sharedQueue.lanes = newQueueLanes; // Even if queue.lanes already include lane, we don't know for certain if + // the lane finished since the last time we entangled it. So we need to + // entangle it again, just to be sure. - var existingEl = root.querySelector(selector); + markRootEntangled(root, newQueueLanes); + } +} +function enqueueCapturedUpdate(workInProgress, capturedUpdate) { + // Captured updates are updates that are thrown by a child during the render + // phase. They should be discarded if the render is aborted. Therefore, + // we should only put them on the work-in-progress queue, not the current one. + var queue = workInProgress.updateQueue; // Check if the work-in-progress queue is a clone. - if (existingEl) { - instance = resource.instance = existingEl; - markNodeAsResource(instance); - return instance; - } + var current = workInProgress.alternate; - instance = resource.instance = createResourceInstance( - type, - props, - root - ); - insertResourceInstanceBefore(root, instance, null); - return instance; - } + if (current !== null) { + var currentQueue = current.updateQueue; - case "base": { - var baseResource = resource; - var _matcher2 = baseResource.matcher; - var base = root.querySelector(_matcher2); + if (queue === currentQueue) { + // The work-in-progress queue is the same as current. This happens when + // we bail out on a parent fiber that then captures an error thrown by + // a child. Since we want to append the update only to the work-in + // -progress queue, we need to clone the updates. We usually clone during + // processUpdateQueue, but that didn't happen in this case because we + // skipped over the parent when we bailed out. + var newFirst = null; + var newLast = null; + var firstBaseUpdate = queue.firstBaseUpdate; - if (base) { - instance = resource.instance = base; - markNodeAsResource(instance); + if (firstBaseUpdate !== null) { + // Loop through the updates and clone them. + var update = firstBaseUpdate; + + do { + var clone = { + eventTime: update.eventTime, + lane: update.lane, + tag: update.tag, + payload: update.payload, + // When this update is rebased, we should not fire its + // callback again. + callback: null, + next: null + }; + + if (newLast === null) { + newFirst = newLast = clone; + } else { + newLast.next = clone; + newLast = clone; + } // $FlowFixMe[incompatible-type] we bail out when we get a null + + update = update.next; + } while (update !== null); // Append the captured update the end of the cloned list. + + if (newLast === null) { + newFirst = newLast = capturedUpdate; } else { - instance = resource.instance = createResourceInstance( - type, - props, - root - ); - insertResourceInstanceBefore( - root, - instance, - root.querySelector("base") - ); + newLast.next = capturedUpdate; + newLast = capturedUpdate; } - - return instance; + } else { + // There are no base updates. + newFirst = newLast = capturedUpdate; } - default: { - throw new Error( - 'acquireHeadResource encountered a resource type it did not expect: "' + - type + - '". This is a bug in React.' - ); - } + queue = { + baseState: currentQueue.baseState, + firstBaseUpdate: newFirst, + lastBaseUpdate: newLast, + shared: currentQueue.shared, + callbacks: currentQueue.callbacks + }; + workInProgress.updateQueue = queue; + return; } + } // Append the update to the end of the list. + + var lastBaseUpdate = queue.lastBaseUpdate; + + if (lastBaseUpdate === null) { + queue.firstBaseUpdate = capturedUpdate; + } else { + lastBaseUpdate.next = capturedUpdate; } - return instance; + queue.lastBaseUpdate = capturedUpdate; } -function acquireStyleResource(resource) { - var instance = resource.instance; +function getStateFromUpdate( + workInProgress, + queue, + update, + prevState, + nextProps, + instance +) { + switch (update.tag) { + case ReplaceState: { + var payload = update.payload; - if (!instance) { - var props = resource.props, - root = resource.root, - precedence = resource.precedence; - var limitedEscapedHref = escapeSelectorAttributeValueInsideDoubleQuotes( - props.href - ); - var existingEl = root.querySelector( - 'link[rel="stylesheet"][data-precedence][href="' + - limitedEscapedHref + - '"]' - ); + if (typeof payload === "function") { + // Updater function + { + enterDisallowedContextReadInDEV(); + } - if (existingEl) { - instance = resource.instance = existingEl; - markNodeAsResource(instance); - resource.preloaded = true; - var loadingState = existingEl._p; + var nextState = payload.call(instance, prevState, nextProps); - if (loadingState) { - // if an existingEl is found there should always be a loadingState because if - // the resource was flushed in the head it should have already been found when - // the resource was first created. Still defensively we gate this - switch (loadingState.s) { - case "l": { - resource.loaded = true; - resource.error = false; - break; - } + { + exitDisallowedContextReadInDEV(); + } - case "e": { - resource.error = true; - break; - } + return nextState; + } // State object - default: { - attachLoadListeners(existingEl, resource); - } - } - } else { - resource.loaded = true; - } - } else { - instance = resource.instance = createResourceInstance( - "link", - resource.props, - getDocumentFromRoot(root) - ); - attachLoadListeners(instance, resource); - insertStyleInstance(instance, precedence, root); + return payload; } - } - - resource.count++; - return instance; -} -function acquireScriptResource(resource) { - var instance = resource.instance; + case CaptureUpdate: { + workInProgress.flags = + (workInProgress.flags & ~ShouldCapture) | DidCapture; + } + // Intentional fallthrough - if (!instance) { - var props = resource.props, - root = resource.root; - var limitedEscapedSrc = escapeSelectorAttributeValueInsideDoubleQuotes( - props.src - ); - var existingEl = root.querySelector( - 'script[async][src="' + limitedEscapedSrc + '"]' - ); + case UpdateState: { + var _payload = update.payload; + var partialState; - if (existingEl) { - instance = resource.instance = existingEl; - markNodeAsResource(instance); - } else { - instance = resource.instance = createResourceInstance( - "script", - resource.props, - getDocumentFromRoot(root) - ); - insertResourceInstanceBefore(getDocumentFromRoot(root), instance, null); - } - } + if (typeof _payload === "function") { + // Updater function + { + enterDisallowedContextReadInDEV(); + } - return instance; -} + partialState = _payload.call(instance, prevState, nextProps); -function attachLoadListeners(instance, resource) { - var listeners = {}; - listeners.load = onResourceLoad.bind( - null, - instance, - resource, - listeners, - loadAndErrorEventListenerOptions - ); - listeners.error = onResourceError.bind( - null, - instance, - resource, - listeners, - loadAndErrorEventListenerOptions - ); - instance.addEventListener( - "load", - listeners.load, - loadAndErrorEventListenerOptions - ); - instance.addEventListener( - "error", - listeners.error, - loadAndErrorEventListenerOptions - ); -} + { + exitDisallowedContextReadInDEV(); + } + } else { + // Partial state object + partialState = _payload; + } -var loadAndErrorEventListenerOptions = { - passive: true -}; + if (partialState === null || partialState === undefined) { + // Null and undefined are treated as no-ops. + return prevState; + } // Merge the partial state and the previous state. -function onResourceLoad(instance, resource, listeners, listenerOptions) { - resource.loaded = true; - resource.error = false; + return assign({}, prevState, partialState); + } - for (var event in listeners) { - instance.removeEventListener(event, listeners[event], listenerOptions); + case ForceUpdate: { + hasForceUpdate = true; + return prevState; + } } + + return prevState; } -function onResourceError(instance, resource, listeners, listenerOptions) { - resource.loaded = false; - resource.error = true; +function processUpdateQueue(workInProgress, props, instance, renderLanes) { + // This is always non-null on a ClassComponent or HostRoot + var queue = workInProgress.updateQueue; + hasForceUpdate = false; - for (var event in listeners) { - instance.removeEventListener(event, listeners[event], listenerOptions); + { + // $FlowFixMe[escaped-generic] discovered when updating Flow + currentlyProcessingQueue = queue.shared; } -} -function insertStyleInstance(instance, precedence, root) { - var nodes = root.querySelectorAll('link[rel="stylesheet"][data-precedence]'); - var last = nodes.length ? nodes[nodes.length - 1] : null; - var prior = last; + var firstBaseUpdate = queue.firstBaseUpdate; + var lastBaseUpdate = queue.lastBaseUpdate; // Check if there are pending updates. If so, transfer them to the base queue. - for (var i = 0; i < nodes.length; i++) { - var node = nodes[i]; - var nodePrecedence = node.dataset.precedence; + var pendingQueue = queue.shared.pending; - if (nodePrecedence === precedence) { - prior = node; - } else if (prior !== last) { - break; - } - } + if (pendingQueue !== null) { + queue.shared.pending = null; // The pending queue is circular. Disconnect the pointer between first + // and last so that it's non-circular. - if (prior) { - // We get the prior from the document so we know it is in the tree. - // We also know that links can't be the topmost Node so the parentNode - // must exist. - prior.parentNode.insertBefore(instance, prior.nextSibling); - } else { - var parent = root.nodeType === DOCUMENT_NODE ? root.head : root; + var lastPendingUpdate = pendingQueue; + var firstPendingUpdate = lastPendingUpdate.next; + lastPendingUpdate.next = null; // Append pending updates to base queue - if (parent) { - parent.insertBefore(instance, parent.firstChild); + if (lastBaseUpdate === null) { + firstBaseUpdate = firstPendingUpdate; } else { - throw new Error( - "While attempting to insert a Resource, React expected the Document to contain" + - " a head element but it was not found." - ); + lastBaseUpdate.next = firstPendingUpdate; } - } -} -function insertResourceInstanceBefore(ownerDocument, instance, before) { - { - if (instance.tagName === "LINK" && instance.rel === "stylesheet") { - error( - "insertResourceInstanceBefore was called with a stylesheet. Stylesheets must be" + - " inserted with insertStyleInstance instead. This is a bug in React." - ); - } - } + lastBaseUpdate = lastPendingUpdate; // If there's a current queue, and it's different from the base queue, then + // we need to transfer the updates to that queue, too. Because the base + // queue is a singly-linked list with no cycles, we can append to both + // lists and take advantage of structural sharing. + // TODO: Pass `current` as argument - var parent = (before && before.parentNode) || ownerDocument.head; + var current = workInProgress.alternate; - if (parent) { - parent.insertBefore(instance, before); - } else { - throw new Error( - "While attempting to insert a Resource, React expected the Document to contain" + - " a head element but it was not found." - ); - } -} // When passing user input into querySelector(All) the embedded string must not alter -// the semantics of the query. This escape function is safe to use when we know the -// provided value is going to be wrapped in double quotes as part of an attribute selector -// Do not use it anywhere else -// we escape double quotes and backslashes + if (current !== null) { + // This is always non-null on a ClassComponent or HostRoot + var currentQueue = current.updateQueue; + var currentLastBaseUpdate = currentQueue.lastBaseUpdate; -var escapeSelectorAttributeValueInsideDoubleQuotesRegex = /[\n\"\\]/g; + if (currentLastBaseUpdate !== lastBaseUpdate) { + if (currentLastBaseUpdate === null) { + currentQueue.firstBaseUpdate = firstPendingUpdate; + } else { + currentLastBaseUpdate.next = firstPendingUpdate; + } -function escapeSelectorAttributeValueInsideDoubleQuotes(value) { - return value.replace( - escapeSelectorAttributeValueInsideDoubleQuotesRegex, - function(ch) { - return "\\" + ch.charCodeAt(0).toString(16); + currentQueue.lastBaseUpdate = lastPendingUpdate; + } } - ); -} + } // These values may change as we process the queue. -var SUPPRESS_HYDRATION_WARNING$1 = "suppressHydrationWarning"; -var SUSPENSE_START_DATA = "$"; -var SUSPENSE_END_DATA = "/$"; -var SUSPENSE_PENDING_START_DATA = "$?"; -var SUSPENSE_FALLBACK_START_DATA = "$!"; -var STYLE$1 = "style"; -var eventsEnabled = null; -var selectionInformation = null; -function getRootHostContext(rootContainerInstance) { - var type; - var namespace; - var nodeType = rootContainerInstance.nodeType; + if (firstBaseUpdate !== null) { + // Iterate through the list of updates to compute the result. + var newState = queue.baseState; // TODO: Don't need to accumulate this. Instead, we can remove renderLanes + // from the original lanes. - switch (nodeType) { - case DOCUMENT_NODE: - case DOCUMENT_FRAGMENT_NODE: { - type = nodeType === DOCUMENT_NODE ? "#document" : "#fragment"; - var root = rootContainerInstance.documentElement; - namespace = root ? root.namespaceURI : getChildNamespace(null, ""); - break; - } + var newLanes = NoLanes; + var newBaseState = null; + var newFirstBaseUpdate = null; + var newLastBaseUpdate = null; + var update = firstBaseUpdate; - default: { - var container = - nodeType === COMMENT_NODE - ? rootContainerInstance.parentNode - : rootContainerInstance; - var ownNamespace = container.namespaceURI || null; - type = container.tagName; - namespace = getChildNamespace(ownNamespace, type); - break; - } - } + do { + // TODO: Don't need this field anymore + var updateEventTime = update.eventTime; // An extra OffscreenLane bit is added to updates that were made to + // a hidden tree, so that we can distinguish them from updates that were + // already there when the tree was hidden. + + var updateLane = removeLanes(update.lane, OffscreenLane); + var isHiddenUpdate = updateLane !== update.lane; // Check if this update was made while the tree was hidden. If so, then + // it's not a "base" update and we should disregard the extra base lanes + // that were added to renderLanes when we entered the Offscreen tree. + + var shouldSkipUpdate = isHiddenUpdate + ? !isSubsetOfLanes(getWorkInProgressRootRenderLanes(), updateLane) + : !isSubsetOfLanes(renderLanes, updateLane); + + if (shouldSkipUpdate) { + // Priority is insufficient. Skip this update. If this is the first + // skipped update, the previous update/state is the new base + // update/state. + var clone = { + eventTime: updateEventTime, + lane: updateLane, + tag: update.tag, + payload: update.payload, + callback: update.callback, + next: null + }; + + if (newLastBaseUpdate === null) { + newFirstBaseUpdate = newLastBaseUpdate = clone; + newBaseState = newState; + } else { + newLastBaseUpdate = newLastBaseUpdate.next = clone; + } // Update the remaining priority in the queue. + + newLanes = mergeLanes(newLanes, updateLane); + } else { + // This update does have sufficient priority. + if (newLastBaseUpdate !== null) { + var _clone = { + eventTime: updateEventTime, + // This update is going to be committed so we never want uncommit + // it. Using NoLane works because 0 is a subset of all bitmasks, so + // this will never be skipped by the check above. + lane: NoLane, + tag: update.tag, + payload: update.payload, + // When this update is rebased, we should not fire its + // callback again. + callback: null, + next: null + }; + newLastBaseUpdate = newLastBaseUpdate.next = _clone; + } // Process this update. + + newState = getStateFromUpdate( + workInProgress, + queue, + update, + newState, + props, + instance + ); + var callback = update.callback; + + if (callback !== null) { + workInProgress.flags |= Callback; + + if (isHiddenUpdate) { + workInProgress.flags |= Visibility; + } + + var callbacks = queue.callbacks; + + if (callbacks === null) { + queue.callbacks = [callback]; + } else { + callbacks.push(callback); + } + } + } // $FlowFixMe[incompatible-type] we bail out when we get a null + + update = update.next; + + if (update === null) { + pendingQueue = queue.shared.pending; + + if (pendingQueue === null) { + break; + } else { + // An update was scheduled from inside a reducer. Add the new + // pending updates to the end of the list and keep processing. + var _lastPendingUpdate = pendingQueue; // Intentionally unsound. Pending updates form a circular list, but we + // unravel them when transferring them to the base queue. + + var _firstPendingUpdate = _lastPendingUpdate.next; + _lastPendingUpdate.next = null; + update = _firstPendingUpdate; + queue.lastBaseUpdate = _lastPendingUpdate; + queue.shared.pending = null; + } + } + } while (true); + + if (newLastBaseUpdate === null) { + newBaseState = newState; + } + + queue.baseState = newBaseState; + queue.firstBaseUpdate = newFirstBaseUpdate; + queue.lastBaseUpdate = newLastBaseUpdate; + + if (firstBaseUpdate === null) { + // `queue.lanes` is used for entangling transitions. We can set it back to + // zero once the queue is empty. + queue.shared.lanes = NoLanes; + } // Set the remaining expiration time to be whatever is remaining in the queue. + // This should be fine because the only two other things that contribute to + // expiration time are props and context. We're already in the middle of the + // begin phase by the time we start processing the queue, so we've already + // dealt with the props. Context in components that specify + // shouldComponentUpdate is tricky; but we'll have to account for + // that regardless. + + markSkippedUpdateLanes(newLanes); + workInProgress.lanes = newLanes; + workInProgress.memoizedState = newState; + } { - var validatedTag = type.toLowerCase(); - var ancestorInfo = updatedAncestorInfoDev(null, validatedTag); - return { - namespace: namespace, - ancestorInfo: ancestorInfo - }; + currentlyProcessingQueue = null; } } -function getChildHostContext(parentHostContext, type) { - { - var parentHostContextDev = parentHostContext; - var namespace = getChildNamespace(parentHostContextDev.namespace, type); - var ancestorInfo = updatedAncestorInfoDev( - parentHostContextDev.ancestorInfo, - type + +function callCallback(callback, context) { + if (typeof callback !== "function") { + throw new Error( + "Invalid argument passed as callback. Expected a function. Instead " + + ("received: " + callback) ); - return { - namespace: namespace, - ancestorInfo: ancestorInfo - }; } + + callback.call(context); } -function getPublicInstance(instance) { - return instance; + +function resetHasForceUpdateBeforeProcessing() { + hasForceUpdate = false; } -function prepareForCommit(containerInfo) { - eventsEnabled = isEnabled(); - selectionInformation = getSelectionInformation(); - var activeInstance = null; +function checkHasForceUpdateAfterProcessing() { + return hasForceUpdate; +} +function deferHiddenCallbacks(updateQueue) { + // When an update finishes on a hidden component, its callback should not + // be fired until/unless the component is made visible again. Stash the + // callback on the shared queue object so it can be fired later. + var newHiddenCallbacks = updateQueue.callbacks; - { - var focusedElem = selectionInformation.focusedElem; + if (newHiddenCallbacks !== null) { + var existingHiddenCallbacks = updateQueue.shared.hiddenCallbacks; - if (focusedElem !== null) { - activeInstance = getClosestInstanceFromNode(focusedElem); + if (existingHiddenCallbacks === null) { + updateQueue.shared.hiddenCallbacks = newHiddenCallbacks; + } else { + updateQueue.shared.hiddenCallbacks = existingHiddenCallbacks.concat( + newHiddenCallbacks + ); } } - - setEnabled(false); - return activeInstance; -} -function beforeActiveInstanceBlur(internalInstanceHandle) { - { - setEnabled(true); - dispatchBeforeDetachedBlur( - selectionInformation.focusedElem, - internalInstanceHandle - ); - setEnabled(false); - } } -function afterActiveInstanceBlur() { - { - setEnabled(true); - dispatchAfterDetachedBlur(selectionInformation.focusedElem); - setEnabled(false); +function commitHiddenCallbacks(updateQueue, context) { + // This component is switching from hidden -> visible. Commit any callbacks + // that were previously deferred. + var hiddenCallbacks = updateQueue.shared.hiddenCallbacks; + + if (hiddenCallbacks !== null) { + updateQueue.shared.hiddenCallbacks = null; + + for (var i = 0; i < hiddenCallbacks.length; i++) { + var callback = hiddenCallbacks[i]; + callCallback(callback, context); + } } } -function resetAfterCommit(containerInfo) { - restoreSelection(selectionInformation); - setEnabled(eventsEnabled); - eventsEnabled = null; - selectionInformation = null; -} -function createInstance( - type, - props, - rootContainerInstance, - hostContext, - internalInstanceHandle -) { - var parentNamespace; +function commitCallbacks(updateQueue, context) { + var callbacks = updateQueue.callbacks; - { - // TODO: take namespace into account when validating. - var hostContextDev = hostContext; - validateDOMNesting(type, null, hostContextDev.ancestorInfo); + if (callbacks !== null) { + updateQueue.callbacks = null; - if ( - typeof props.children === "string" || - typeof props.children === "number" - ) { - var string = "" + props.children; - var ownAncestorInfo = updatedAncestorInfoDev( - hostContextDev.ancestorInfo, - type - ); - validateDOMNesting(null, string, ownAncestorInfo); + for (var i = 0; i < callbacks.length; i++) { + var callback = callbacks[i]; + callCallback(callback, context); } + } +} - parentNamespace = hostContextDev.namespace; +/** + * Performs equality by iterating through keys on an object and returning false + * when any key has values which are not strictly equal between the arguments. + * Returns true when the values of all keys are strictly equal. + */ + +function shallowEqual(objA, objB) { + if (objectIs(objA, objB)) { + return true; } - var domElement = createElement( - type, - props, - rootContainerInstance, - parentNamespace - ); - precacheFiberNode(internalInstanceHandle, domElement); - updateFiberProps(domElement, props); - return domElement; -} -function appendInitialChild(parentInstance, child) { - parentInstance.appendChild(child); -} -function finalizeInitialChildren(domElement, type, props, hostContext) { - setInitialProperties(domElement, type, props); + if ( + typeof objA !== "object" || + objA === null || + typeof objB !== "object" || + objB === null + ) { + return false; + } - switch (type) { - case "button": - case "input": - case "select": - case "textarea": - return !!props.autoFocus; + var keysA = Object.keys(objA); + var keysB = Object.keys(objB); - case "img": - return true; + if (keysA.length !== keysB.length) { + return false; + } // Test for A's keys different from B. - default: - return false; - } -} -function prepareUpdate(domElement, type, oldProps, newProps, hostContext) { - { - var hostContextDev = hostContext; + for (var i = 0; i < keysA.length; i++) { + var currentKey = keysA[i]; if ( - typeof newProps.children !== typeof oldProps.children && - (typeof newProps.children === "string" || - typeof newProps.children === "number") + !hasOwnProperty.call(objB, currentKey) || + !objectIs(objA[currentKey], objB[currentKey]) ) { - var string = "" + newProps.children; - var ownAncestorInfo = updatedAncestorInfoDev( - hostContextDev.ancestorInfo, - type - ); - validateDOMNesting(null, string, ownAncestorInfo); + return false; } } - return diffProperties(domElement, type, oldProps, newProps); -} -function shouldSetTextContent(type, props) { - return ( - type === "textarea" || - type === "noscript" || - typeof props.children === "string" || - typeof props.children === "number" || - (typeof props.dangerouslySetInnerHTML === "object" && - props.dangerouslySetInnerHTML !== null && - props.dangerouslySetInnerHTML.__html != null) - ); -} -function createTextInstance( - text, - rootContainerInstance, - hostContext, - internalInstanceHandle -) { - { - var hostContextDev = hostContext; - validateDOMNesting(null, text, hostContextDev.ancestorInfo); - } - - var textNode = createTextNode(text, rootContainerInstance); - precacheFiberNode(internalInstanceHandle, textNode); - return textNode; + return true; } -function getCurrentEventPriority() { - var currentEvent = window.event; - if (currentEvent === undefined) { - return DefaultEventPriority; - } +var ReactStrictModeWarnings = { + recordUnsafeLifecycleWarnings: function(fiber, instance) {}, + flushPendingUnsafeLifecycleWarnings: function() {}, + recordLegacyContextWarning: function(fiber, instance) {}, + flushLegacyContextWarning: function() {}, + discardPendingWarnings: function() {} +}; - return getEventPriority(currentEvent.type); -} -// if a component just imports ReactDOM (e.g. for findDOMNode). -// Some environments might not have setTimeout or clearTimeout. +{ + var findStrictRoot = function(fiber) { + var maybeStrictRoot = null; + var node = fiber; -var scheduleTimeout = typeof setTimeout === "function" ? setTimeout : undefined; -var cancelTimeout = - typeof clearTimeout === "function" ? clearTimeout : undefined; -var noTimeout = -1; -var localPromise = typeof Promise === "function" ? Promise : undefined; -function getInstanceFromNode(node) { - return getClosestInstanceFromNode(node) || null; -} -function preparePortalMount(portalInstance) { - listenToAllSupportedEvents(portalInstance); -} -function prepareScopeUpdate(scopeInstance, internalInstanceHandle) { - { - precacheFiberNode(internalInstanceHandle, scopeInstance); - } -} -function getInstanceFromScope(scopeInstance) { - { - return getFiberFromScopeInstance(scopeInstance); - } -} // ------------------- -var scheduleMicrotask = - typeof queueMicrotask === "function" - ? queueMicrotask - : typeof localPromise !== "undefined" - ? function(callback) { - return localPromise - .resolve(null) - .then(callback) - .catch(handleErrorInNextTick); + while (node !== null) { + if (node.mode & StrictLegacyMode) { + maybeStrictRoot = node; } - : scheduleTimeout; // TODO: Determine the best fallback here. -function handleErrorInNextTick(error) { - setTimeout(function() { - throw error; - }); -} // ------------------- -function commitMount(domElement, type, newProps, internalInstanceHandle) { - // Despite the naming that might imply otherwise, this method only - // fires if there is an `Update` effect scheduled during mounting. - // This happens if `finalizeInitialChildren` returns `true` (which it - // does to implement the `autoFocus` attribute on the client). But - // there are also other cases when this might happen (such as patching - // up text content during hydration mismatch). So we'll check this again. - switch (type) { - case "button": - case "input": - case "select": - case "textarea": - if (newProps.autoFocus) { - domElement.focus(); - } + node = node.return; + } - return; + return maybeStrictRoot; + }; - case "img": { - if (newProps.src) { - domElement.src = newProps.src; - } + var setToSortedString = function(set) { + var array = []; + set.forEach(function(value) { + array.push(value); + }); + 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. + + var didWarnAboutUnsafeLifecycles = new Set(); + ReactStrictModeWarnings.recordUnsafeLifecycleWarnings = function( + fiber, + instance + ) { + // Dedupe strategy: Warn once per component. + if (didWarnAboutUnsafeLifecycles.has(fiber.type)) { return; } - } -} -function commitUpdate( - domElement, - updatePayload, - type, - oldProps, - newProps, - internalInstanceHandle -) { - // Apply the diff to the DOM node. - updateProperties(domElement, updatePayload, type, oldProps, newProps); // Update the props handle so that we know which props are the ones with - // with current event handlers. - updateFiberProps(domElement, newProps); -} -function resetTextContent(domElement) { - setTextContent(domElement, ""); -} -function commitTextUpdate(textInstance, oldText, newText) { - textInstance.nodeValue = newText; -} -function appendChild(parentInstance, child) { - parentInstance.appendChild(child); -} -function appendChildToContainer(container, child) { - var parentNode; + if ( + typeof instance.componentWillMount === "function" && // Don't warn about react-lifecycles-compat polyfilled components. + instance.componentWillMount.__suppressDeprecationWarning !== true + ) { + pendingComponentWillMountWarnings.push(fiber); + } - if (container.nodeType === COMMENT_NODE) { - parentNode = container.parentNode; - parentNode.insertBefore(child, container); - } else { - parentNode = container; - parentNode.appendChild(child); - } // This container might be used for a portal. - // If something inside a portal is clicked, that click should bubble - // through the React tree. However, on Mobile Safari the click would - // never bubble through the *DOM* tree unless an ancestor with onclick - // event exists. So we wouldn't see it and dispatch it. - // This is why we ensure that non React root containers have inline onclick - // defined. - // https://github.com/facebook/react/issues/11918 + if ( + fiber.mode & StrictLegacyMode && + typeof instance.UNSAFE_componentWillMount === "function" + ) { + pendingUNSAFE_ComponentWillMountWarnings.push(fiber); + } - var reactRootContainer = container._reactRootContainer; + if ( + typeof instance.componentWillReceiveProps === "function" && + instance.componentWillReceiveProps.__suppressDeprecationWarning !== true + ) { + pendingComponentWillReceivePropsWarnings.push(fiber); + } - if ( - (reactRootContainer === null || reactRootContainer === undefined) && - parentNode.onclick === null - ) { - // TODO: This cast may not be sound for SVG, MathML or custom elements. - trapClickOnNonInteractiveElement(parentNode); - } -} -function insertBefore(parentInstance, child, beforeChild) { - parentInstance.insertBefore(child, beforeChild); -} -function insertInContainerBefore(container, child, beforeChild) { - if (container.nodeType === COMMENT_NODE) { - container.parentNode.insertBefore(child, beforeChild); - } else { - container.insertBefore(child, beforeChild); - } -} - -function createEvent(type, bubbles) { - var event = document.createEvent("Event"); - event.initEvent(type, bubbles, false); - return event; -} + if ( + fiber.mode & StrictLegacyMode && + typeof instance.UNSAFE_componentWillReceiveProps === "function" + ) { + pendingUNSAFE_ComponentWillReceivePropsWarnings.push(fiber); + } -function dispatchBeforeDetachedBlur(target, internalInstanceHandle) { - { - var event = createEvent("beforeblur", true); // Dispatch "beforeblur" directly on the target, - // so it gets picked up by the event system and - // can propagate through the React internal tree. - // $FlowFixMe: internal field + if ( + typeof instance.componentWillUpdate === "function" && + instance.componentWillUpdate.__suppressDeprecationWarning !== true + ) { + pendingComponentWillUpdateWarnings.push(fiber); + } - event._detachedInterceptFiber = internalInstanceHandle; - target.dispatchEvent(event); - } -} + if ( + fiber.mode & StrictLegacyMode && + typeof instance.UNSAFE_componentWillUpdate === "function" + ) { + pendingUNSAFE_ComponentWillUpdateWarnings.push(fiber); + } + }; -function dispatchAfterDetachedBlur(target) { - { - var event = createEvent("afterblur", false); // So we know what was detached, make the relatedTarget the - // detached target on the "afterblur" event. + ReactStrictModeWarnings.flushPendingUnsafeLifecycleWarnings = function() { + // We do an initial pass to gather component names + var componentWillMountUniqueNames = new Set(); - event.relatedTarget = target; // Dispatch the event on the document. + if (pendingComponentWillMountWarnings.length > 0) { + pendingComponentWillMountWarnings.forEach(function(fiber) { + componentWillMountUniqueNames.add( + getComponentNameFromFiber(fiber) || "Component" + ); + didWarnAboutUnsafeLifecycles.add(fiber.type); + }); + pendingComponentWillMountWarnings = []; + } - document.dispatchEvent(event); - } -} + var UNSAFE_componentWillMountUniqueNames = new Set(); -function removeChild(parentInstance, child) { - parentInstance.removeChild(child); -} -function removeChildFromContainer(container, child) { - if (container.nodeType === COMMENT_NODE) { - container.parentNode.removeChild(child); - } else { - container.removeChild(child); - } -} -function clearSuspenseBoundary(parentInstance, suspenseInstance) { - var node = suspenseInstance; // Delete all nodes within this suspense boundary. - // There might be nested nodes so we need to keep track of how - // deep we are and only break out when we're back on top. + if (pendingUNSAFE_ComponentWillMountWarnings.length > 0) { + pendingUNSAFE_ComponentWillMountWarnings.forEach(function(fiber) { + UNSAFE_componentWillMountUniqueNames.add( + getComponentNameFromFiber(fiber) || "Component" + ); + didWarnAboutUnsafeLifecycles.add(fiber.type); + }); + pendingUNSAFE_ComponentWillMountWarnings = []; + } - var depth = 0; + var componentWillReceivePropsUniqueNames = new Set(); - do { - var nextNode = node.nextSibling; - parentInstance.removeChild(node); + if (pendingComponentWillReceivePropsWarnings.length > 0) { + pendingComponentWillReceivePropsWarnings.forEach(function(fiber) { + componentWillReceivePropsUniqueNames.add( + getComponentNameFromFiber(fiber) || "Component" + ); + didWarnAboutUnsafeLifecycles.add(fiber.type); + }); + pendingComponentWillReceivePropsWarnings = []; + } - if (nextNode && nextNode.nodeType === COMMENT_NODE) { - var data = nextNode.data; + var UNSAFE_componentWillReceivePropsUniqueNames = new Set(); - if (data === SUSPENSE_END_DATA) { - if (depth === 0) { - parentInstance.removeChild(nextNode); // Retry if any event replaying was blocked on this. + if (pendingUNSAFE_ComponentWillReceivePropsWarnings.length > 0) { + pendingUNSAFE_ComponentWillReceivePropsWarnings.forEach(function(fiber) { + UNSAFE_componentWillReceivePropsUniqueNames.add( + getComponentNameFromFiber(fiber) || "Component" + ); + didWarnAboutUnsafeLifecycles.add(fiber.type); + }); + pendingUNSAFE_ComponentWillReceivePropsWarnings = []; + } - retryIfBlockedOn(suspenseInstance); - return; - } else { - depth--; - } - } else if ( - data === SUSPENSE_START_DATA || - data === SUSPENSE_PENDING_START_DATA || - data === SUSPENSE_FALLBACK_START_DATA - ) { - depth++; - } - } // $FlowFixMe[incompatible-type] we bail out when we get a null + var componentWillUpdateUniqueNames = new Set(); - node = nextNode; - } while (node); // TODO: Warn, we didn't find the end comment boundary. - // Retry if any event replaying was blocked on this. + if (pendingComponentWillUpdateWarnings.length > 0) { + pendingComponentWillUpdateWarnings.forEach(function(fiber) { + componentWillUpdateUniqueNames.add( + getComponentNameFromFiber(fiber) || "Component" + ); + didWarnAboutUnsafeLifecycles.add(fiber.type); + }); + pendingComponentWillUpdateWarnings = []; + } - retryIfBlockedOn(suspenseInstance); -} -function clearSuspenseBoundaryFromContainer(container, suspenseInstance) { - if (container.nodeType === COMMENT_NODE) { - clearSuspenseBoundary(container.parentNode, suspenseInstance); - } else if (container.nodeType === ELEMENT_NODE) { - clearSuspenseBoundary(container, suspenseInstance); - } // Retry if any event replaying was blocked on this. + var UNSAFE_componentWillUpdateUniqueNames = new Set(); - retryIfBlockedOn(container); -} -function hideInstance(instance) { - // TODO: Does this work for all element types? What about MathML? Should we - // pass host context to this method? - instance = instance; - var style = instance.style; // $FlowFixMe[method-unbinding] + if (pendingUNSAFE_ComponentWillUpdateWarnings.length > 0) { + pendingUNSAFE_ComponentWillUpdateWarnings.forEach(function(fiber) { + UNSAFE_componentWillUpdateUniqueNames.add( + getComponentNameFromFiber(fiber) || "Component" + ); + didWarnAboutUnsafeLifecycles.add(fiber.type); + }); + pendingUNSAFE_ComponentWillUpdateWarnings = []; + } // Finally, we flush all the warnings + // UNSAFE_ ones before the deprecated ones, since they'll be 'louder' - if (typeof style.setProperty === "function") { - style.setProperty("display", "none", "important"); - } else { - style.display = "none"; - } -} -function hideTextInstance(textInstance) { - textInstance.nodeValue = ""; -} -function unhideInstance(instance, props) { - instance = instance; - var styleProp = props[STYLE$1]; - var display = - styleProp !== undefined && - styleProp !== null && - styleProp.hasOwnProperty("display") - ? styleProp.display - : null; - instance.style.display = dangerousStyleValue("display", display); -} -function unhideTextInstance(textInstance, text) { - textInstance.nodeValue = text; -} -function clearContainer(container) { - { - var nodeType = container.nodeType; + if (UNSAFE_componentWillMountUniqueNames.size > 0) { + var sortedNames = setToSortedString(UNSAFE_componentWillMountUniqueNames); - if (nodeType === DOCUMENT_NODE) { - clearRootResources(container); - clearContainerSparingly(container); - } else if (nodeType === ELEMENT_NODE) { - switch (container.nodeName) { - case "HEAD": { - // If we are clearing document.head as a container we are essentially clearing everything - // that was hoisted to the head and should forget the instances that will no longer be in the DOM - clearRootResources(container); // fall through to clear child contents - } - // eslint-disable-next-line-no-fallthrough + error( + "Using UNSAFE_componentWillMount in strict mode is not recommended and may indicate bugs in your code. " + + "See https://reactjs.org/link/unsafe-component-lifecycles for details.\n\n" + + "* Move code with side effects to componentDidMount, and set initial state in the constructor.\n" + + "\nPlease update the following components: %s", + sortedNames + ); + } - case "HTML": - case "BODY": - clearContainerSparingly(container); - return; + if (UNSAFE_componentWillReceivePropsUniqueNames.size > 0) { + var _sortedNames = setToSortedString( + UNSAFE_componentWillReceivePropsUniqueNames + ); - default: { - container.textContent = ""; - } - } + error( + "Using UNSAFE_componentWillReceiveProps in strict mode is not recommended " + + "and may indicate bugs in your code. " + + "See https://reactjs.org/link/unsafe-component-lifecycles for details.\n\n" + + "* Move data fetching code or side effects to componentDidUpdate.\n" + + "* If you're updating state whenever props change, " + + "refactor your code to use memoization techniques or move it to " + + "static getDerivedStateFromProps. Learn more at: https://reactjs.org/link/derived-state\n" + + "\nPlease update the following components: %s", + _sortedNames + ); } - } -} - -function clearContainerSparingly(container) { - var node; - var nextNode = container.firstChild; - if (nextNode && nextNode.nodeType === DOCUMENT_TYPE_NODE) { - nextNode = nextNode.nextSibling; - } + if (UNSAFE_componentWillUpdateUniqueNames.size > 0) { + var _sortedNames2 = setToSortedString( + UNSAFE_componentWillUpdateUniqueNames + ); - while (nextNode) { - node = nextNode; - nextNode = nextNode.nextSibling; - - switch (node.nodeName) { - case "HTML": - case "HEAD": - case "BODY": { - var element = node; - clearContainerSparingly(element); // If these singleton instances had previously been rendered with React they - // may still hold on to references to the previous fiber tree. We detatch them - // prospectively to reset them to a baseline starting state since we cannot create - // new instances. - - detachDeletedInstance(element); - continue; - } + error( + "Using UNSAFE_componentWillUpdate in strict mode is not recommended " + + "and may indicate bugs in your code. " + + "See https://reactjs.org/link/unsafe-component-lifecycles for details.\n\n" + + "* Move data fetching code or side effects to componentDidUpdate.\n" + + "\nPlease update the following components: %s", + _sortedNames2 + ); + } - case "STYLE": { - continue; - } + if (componentWillMountUniqueNames.size > 0) { + var _sortedNames3 = setToSortedString(componentWillMountUniqueNames); - case "LINK": { - if (node.rel.toLowerCase() === "stylesheet") { - continue; - } - } + warn( + "componentWillMount has been renamed, and is not recommended for use. " + + "See https://reactjs.org/link/unsafe-component-lifecycles for details.\n\n" + + "* Move code with side effects to componentDidMount, and set initial state in the constructor.\n" + + "* Rename componentWillMount to UNSAFE_componentWillMount to suppress " + + "this warning in non-strict mode. In React 18.x, only the UNSAFE_ name will work. " + + "To rename all deprecated lifecycles to their new names, you can run " + + "`npx react-codemod rename-unsafe-lifecycles` in your project source folder.\n" + + "\nPlease update the following components: %s", + _sortedNames3 + ); } - container.removeChild(node); - } + if (componentWillReceivePropsUniqueNames.size > 0) { + var _sortedNames4 = setToSortedString( + componentWillReceivePropsUniqueNames + ); - return; -} // Making this so we can eventually move all of the instance caching to the commit phase. -// inserted without breaking hydration + warn( + "componentWillReceiveProps has been renamed, and is not recommended for use. " + + "See https://reactjs.org/link/unsafe-component-lifecycles for details.\n\n" + + "* Move data fetching code or side effects to componentDidUpdate.\n" + + "* If you're updating state whenever props change, refactor your " + + "code to use memoization techniques or move it to " + + "static getDerivedStateFromProps. Learn more at: https://reactjs.org/link/derived-state\n" + + "* Rename componentWillReceiveProps to UNSAFE_componentWillReceiveProps to suppress " + + "this warning in non-strict mode. In React 18.x, only the UNSAFE_ name will work. " + + "To rename all deprecated lifecycles to their new names, you can run " + + "`npx react-codemod rename-unsafe-lifecycles` in your project source folder.\n" + + "\nPlease update the following components: %s", + _sortedNames4 + ); + } -function isHydratable(type, props) { - { - if (type === "link") { - if (props.rel === "stylesheet" && typeof props.precedence !== "string") { - return true; - } + if (componentWillUpdateUniqueNames.size > 0) { + var _sortedNames5 = setToSortedString(componentWillUpdateUniqueNames); - return false; - } else if (type === "script") { - var _ref = props, - async = _ref.async, - onLoad = _ref.onLoad, - onError = _ref.onError; - return !(async && (onLoad || onError)); + warn( + "componentWillUpdate has been renamed, and is not recommended for use. " + + "See https://reactjs.org/link/unsafe-component-lifecycles for details.\n\n" + + "* Move data fetching code or side effects to componentDidUpdate.\n" + + "* Rename componentWillUpdate to UNSAFE_componentWillUpdate to suppress " + + "this warning in non-strict mode. In React 18.x, only the UNSAFE_ name will work. " + + "To rename all deprecated lifecycles to their new names, you can run " + + "`npx react-codemod rename-unsafe-lifecycles` in your project source folder.\n" + + "\nPlease update the following components: %s", + _sortedNames5 + ); } + }; - return true; - } -} -function canHydrateInstance(instance, type, props) { - if ( - instance.nodeType !== ELEMENT_NODE || - type.toLowerCase() !== instance.nodeName.toLowerCase() - ) { - return null; - } // This has now been refined to an element node. + var pendingLegacyContextWarning = new Map(); // Tracks components we have already warned about. - return instance; -} -function canHydrateTextInstance(instance, text) { - if (text === "" || instance.nodeType !== TEXT_NODE) { - // Empty strings are not parsed by HTML so there won't be a correct match here. - return null; - } // This has now been refined to a text node. + var didWarnAboutLegacyContext = new Set(); - return instance; -} -function canHydrateSuspenseInstance(instance) { - if (instance.nodeType !== COMMENT_NODE) { - // Empty strings are not parsed by HTML so there won't be a correct match here. - return null; - } // This has now been refined to a suspense node. + ReactStrictModeWarnings.recordLegacyContextWarning = function( + fiber, + instance + ) { + var strictRoot = findStrictRoot(fiber); - return instance; -} -function isSuspenseInstancePending(instance) { - return instance.data === SUSPENSE_PENDING_START_DATA; -} -function isSuspenseInstanceFallback(instance) { - return instance.data === SUSPENSE_FALLBACK_START_DATA; -} -function getSuspenseInstanceFallbackErrorDetails(instance) { - var dataset = instance.nextSibling && instance.nextSibling.dataset; - var digest, message, stack; + if (strictRoot === null) { + error( + "Expected to find a StrictMode component in a strict mode tree. " + + "This error is likely caused by a bug in React. Please file an issue." + ); - if (dataset) { - digest = dataset.dgst; + return; + } // Dedup strategy: Warn once per component. - { - message = dataset.msg; - stack = dataset.stck; + if (didWarnAboutLegacyContext.has(fiber.type)) { + return; } - } - { - return { - message: message, - digest: digest, - stack: stack - }; - } -} -function registerSuspenseInstanceRetry(instance, callback) { - instance._reactRetry = callback; -} + var warningsForRoot = pendingLegacyContextWarning.get(strictRoot); -function getNextHydratable(node) { - // Skip non-hydratable nodes. - for (; node != null; node = node.nextSibling) { - var nodeType = node.nodeType; + if ( + fiber.type.contextTypes != null || + fiber.type.childContextTypes != null || + (instance !== null && typeof instance.getChildContext === "function") + ) { + if (warningsForRoot === undefined) { + warningsForRoot = []; + pendingLegacyContextWarning.set(strictRoot, warningsForRoot); + } - { - if (nodeType === ELEMENT_NODE) { - var element = node; + warningsForRoot.push(fiber); + } + }; - switch (element.tagName) { - // This is subtle. in SVG scope the title tag is case sensitive. we don't want to skip - // titles in svg but we do want to skip them outside of svg. there is an edge case where - // you could do `React.createElement('TITLE', ...)` inside an svg scope but the SSR serializer - // will still emit lowercase. Practically speaking the only time the DOM will have a non-uppercased - // title tagName is if it is inside an svg. - // Other Resource types like META, BASE, LINK, and SCRIPT should be treated as resources even inside - // svg scope because they are invalid otherwise. We still don't need to handle the lowercase variant - // because if they are present in the DOM already they would have been hoisted outside the SVG scope - // as Resources. So while it would be correct to skip a inside and this algorithm won't - // skip that link because the tagName will not be uppercased it functionally is irrelevant. If one - // tries to render incompatible types such as a non-resource stylesheet inside an svg the server will - // emit that invalid html and hydration will fail. In Dev this will present warnings guiding the - // developer on how to fix. - case "TITLE": - case "META": - case "BASE": - case "HTML": - case "HEAD": - case "BODY": { - continue; - } + ReactStrictModeWarnings.flushLegacyContextWarning = function() { + pendingLegacyContextWarning.forEach(function(fiberArray, strictRoot) { + if (fiberArray.length === 0) { + return; + } - case "LINK": { - var linkEl = element; // All links that are server rendered are resources except - // stylesheets that do not have a precedence + var firstFiber = fiberArray[0]; + var uniqueNames = new Set(); + fiberArray.forEach(function(fiber) { + uniqueNames.add(getComponentNameFromFiber(fiber) || "Component"); + didWarnAboutLegacyContext.add(fiber.type); + }); + var sortedNames = setToSortedString(uniqueNames); - if ( - linkEl.rel === "stylesheet" && - !linkEl.hasAttribute("data-precedence") - ) { - break; - } + try { + setCurrentFiber(firstFiber); - continue; - } + error( + "Legacy context API has been detected within a strict-mode tree." + + "\n\nThe old API will be supported in all 16.x releases, but applications " + + "using it should migrate to the new version." + + "\n\nPlease update the following components: %s" + + "\n\nLearn more about this warning here: https://reactjs.org/link/legacy-context", + sortedNames + ); + } finally { + resetCurrentFiber(); + } + }); + }; - case "STYLE": { - var styleEl = element; + ReactStrictModeWarnings.discardPendingWarnings = function() { + pendingComponentWillMountWarnings = []; + pendingUNSAFE_ComponentWillMountWarnings = []; + pendingComponentWillReceivePropsWarnings = []; + pendingUNSAFE_ComponentWillReceivePropsWarnings = []; + pendingComponentWillUpdateWarnings = []; + pendingUNSAFE_ComponentWillUpdateWarnings = []; + pendingLegacyContextWarning = new Map(); + }; +} - if (styleEl.hasAttribute("data-precedence")) { - continue; - } +var didWarnAboutMaps; +var didWarnAboutGenerators; +var didWarnAboutStringRefs; +var ownerHasKeyUseWarning; +var ownerHasFunctionTypeWarning; - break; - } +var warnForMissingKey = function(child, returnFiber) {}; - case "SCRIPT": { - var scriptEl = element; +{ + didWarnAboutMaps = false; + didWarnAboutGenerators = false; + didWarnAboutStringRefs = {}; + /** + * Warn if there's no key explicitly set on dynamic arrays of children or + * object keys are not valid. This allows us to keep track of children between + * updates. + */ - if (scriptEl.hasAttribute("async")) { - continue; - } + ownerHasKeyUseWarning = {}; + ownerHasFunctionTypeWarning = {}; - break; - } - } + warnForMissingKey = function(child, returnFiber) { + if (child === null || typeof child !== "object") { + return; + } - break; - } else if (nodeType === TEXT_NODE) { - break; - } + if (!child._store || child._store.validated || child.key != null) { + return; } - if (nodeType === COMMENT_NODE) { - var nodeData = node.data; + if (typeof child._store !== "object") { + throw new Error( + "React Component in warnForMissingKey should have a _store. " + + "This error is likely caused by a bug in React. Please file an issue." + ); + } // $FlowFixMe unable to narrow type from mixed to writable object - if ( - nodeData === SUSPENSE_START_DATA || - nodeData === SUSPENSE_FALLBACK_START_DATA || - nodeData === SUSPENSE_PENDING_START_DATA - ) { - break; - } + child._store.validated = true; + var componentName = getComponentNameFromFiber(returnFiber) || "Component"; - if (nodeData === SUSPENSE_END_DATA) { - return null; - } + if (ownerHasKeyUseWarning[componentName]) { + return; } - } - return node; -} + ownerHasKeyUseWarning[componentName] = true; -function getNextHydratableSibling(instance) { - return getNextHydratable(instance.nextSibling); -} -function getFirstHydratableChild(parentInstance) { - return getNextHydratable(parentInstance.firstChild); -} -function getFirstHydratableChildWithinContainer(parentContainer) { - return getNextHydratable(parentContainer.firstChild); -} -function getFirstHydratableChildWithinSuspenseInstance(parentInstance) { - return getNextHydratable(parentInstance.nextSibling); + error( + "Each child in a list should have a unique " + + '"key" prop. See https://reactjs.org/link/warning-keys for ' + + "more information." + ); + }; } -function hydrateInstance( - instance, - type, - props, - hostContext, - internalInstanceHandle, - shouldWarnDev -) { - precacheFiberNode(internalInstanceHandle, instance); // TODO: Possibly defer this until the commit phase where all the events - // get attached. - - updateFiberProps(instance, props); - var parentNamespace; - - { - var hostContextDev = hostContext; - parentNamespace = hostContextDev.namespace; - } // TODO: Temporary hack to check if we're in a concurrent root. We can delete - // when the legacy root API is removed. - var isConcurrentMode = - (internalInstanceHandle.mode & ConcurrentMode) !== NoMode; - return diffHydratedProperties( - instance, - type, - props, - parentNamespace, - isConcurrentMode, - shouldWarnDev - ); +function isReactClass(type) { + return type.prototype && type.prototype.isReactComponent; } -function hydrateTextInstance( - textInstance, - text, - internalInstanceHandle, - shouldWarnDev -) { - precacheFiberNode(internalInstanceHandle, textInstance); // TODO: Temporary hack to check if we're in a concurrent root. We can delete - // when the legacy root API is removed. - var isConcurrentMode = - (internalInstanceHandle.mode & ConcurrentMode) !== NoMode; - return diffHydratedText(textInstance, text); -} -function hydrateSuspenseInstance(suspenseInstance, internalInstanceHandle) { - precacheFiberNode(internalInstanceHandle, suspenseInstance); -} -function getNextHydratableInstanceAfterSuspenseInstance(suspenseInstance) { - var node = suspenseInstance.nextSibling; // Skip past all nodes within this suspense boundary. - // There might be nested nodes so we need to keep track of how - // deep we are and only break out when we're back on top. +function coerceRef(returnFiber, current, element) { + var mixedRef = element.ref; - var depth = 0; + if ( + mixedRef !== null && + typeof mixedRef !== "function" && + typeof mixedRef !== "object" + ) { + { + // TODO: Clean this up once we turn on the string ref warning for + // everyone, because the strict mode case will no longer be relevant + if ( + (returnFiber.mode & StrictLegacyMode || warnAboutStringRefs) && // We warn in ReactElement.js if owner and self are equal for string refs + // because these cannot be automatically converted to an arrow function + // using a codemod. Therefore, we don't have to warn about string refs again. + !( + element._owner && + element._self && + element._owner.stateNode !== element._self + ) && // Will already throw with "Function components cannot have string refs" + !(element._owner && element._owner.tag !== ClassComponent) && // Will already warn with "Function components cannot be given refs" + !(typeof element.type === "function" && !isReactClass(element.type)) && // Will already throw with "Element ref was specified as a string (someStringRef) but no owner was set" + element._owner + ) { + var componentName = + getComponentNameFromFiber(returnFiber) || "Component"; - while (node) { - if (node.nodeType === COMMENT_NODE) { - var data = node.data; + if (!didWarnAboutStringRefs[componentName]) { + { + error( + 'Component "%s" contains the string ref "%s". Support for string refs ' + + "will be removed in a future major release. We recommend using " + + "useRef() or createRef() instead. " + + "Learn more about using refs safely here: " + + "https://reactjs.org/link/strict-mode-string-ref", + componentName, + mixedRef + ); + } - if (data === SUSPENSE_END_DATA) { - if (depth === 0) { - return getNextHydratableSibling(node); - } else { - depth--; + didWarnAboutStringRefs[componentName] = true; } - } else if ( - data === SUSPENSE_START_DATA || - data === SUSPENSE_FALLBACK_START_DATA || - data === SUSPENSE_PENDING_START_DATA - ) { - depth++; } } - node = node.nextSibling; - } // TODO: Warn, we didn't find the end comment boundary. + if (element._owner) { + var owner = element._owner; + var inst; - return null; -} // Returns the SuspenseInstance if this node is a direct child of a -// SuspenseInstance. I.e. if its previous sibling is a Comment with -// SUSPENSE_x_START_DATA. Otherwise, null. + if (owner) { + var ownerFiber = owner; -function getParentSuspenseInstance(targetInstance) { - var node = targetInstance.previousSibling; // Skip past all nodes within this suspense boundary. - // There might be nested nodes so we need to keep track of how - // deep we are and only break out when we're back on top. + if (ownerFiber.tag !== ClassComponent) { + throw new Error( + "Function components cannot have string refs. " + + "We recommend using useRef() instead. " + + "Learn more about using refs safely here: " + + "https://reactjs.org/link/strict-mode-string-ref" + ); + } - var depth = 0; + inst = ownerFiber.stateNode; + } - while (node) { - if (node.nodeType === COMMENT_NODE) { - var data = node.data; + if (!inst) { + throw new Error( + "Missing owner for string ref " + + mixedRef + + ". This error is likely caused by a " + + "bug in React. Please file an issue." + ); + } // Assigning this to a const so Flow knows it won't change in the closure + + var resolvedInst = inst; + + { + checkPropStringCoercion(mixedRef, "ref"); + } + + var stringRef = "" + mixedRef; // Check if previous string ref matches new string ref if ( - data === SUSPENSE_START_DATA || - data === SUSPENSE_FALLBACK_START_DATA || - data === SUSPENSE_PENDING_START_DATA + current !== null && + current.ref !== null && + typeof current.ref === "function" && + current.ref._stringRef === stringRef ) { - if (depth === 0) { - return node; - } else { - depth--; - } - } else if (data === SUSPENSE_END_DATA) { - depth++; + return current.ref; } - } - node = node.previousSibling; - } + var ref = function(value) { + var refs = resolvedInst.refs; - return null; -} -function commitHydratedContainer(container) { - // Retry if any event replaying was blocked on this. - retryIfBlockedOn(container); -} -function commitHydratedSuspenseInstance(suspenseInstance) { - // Retry if any event replaying was blocked on this. - retryIfBlockedOn(suspenseInstance); -} // @TODO remove this function once float lands and hydrated tail nodes -function didNotMatchHydratedContainerTextInstance( - parentContainer, - textInstance, - text, - isConcurrentMode, - shouldWarnDev -) { - checkForUnmatchedText( - textInstance.nodeValue, - text, - isConcurrentMode, - shouldWarnDev - ); -} -function didNotMatchHydratedTextInstance( - parentType, - parentProps, - parentInstance, - textInstance, - text, - isConcurrentMode, - shouldWarnDev -) { - if (parentProps[SUPPRESS_HYDRATION_WARNING$1] !== true) { - checkForUnmatchedText( - textInstance.nodeValue, - text, - isConcurrentMode, - shouldWarnDev - ); - } -} -function didNotHydrateInstanceWithinContainer(parentContainer, instance) { - { - if (instance.nodeType === ELEMENT_NODE) { - warnForDeletedHydratableElement(parentContainer, instance); - } else if (instance.nodeType === COMMENT_NODE); - else { - warnForDeletedHydratableText(parentContainer, instance); - } - } -} -function didNotHydrateInstanceWithinSuspenseInstance(parentInstance, instance) { - { - // $FlowFixMe: Only Element or Document can be parent nodes. - var parentNode = parentInstance.parentNode; + if (value === null) { + delete refs[stringRef]; + } else { + refs[stringRef] = value; + } + }; - if (parentNode !== null) { - if (instance.nodeType === ELEMENT_NODE) { - warnForDeletedHydratableElement(parentNode, instance); - } else if (instance.nodeType === COMMENT_NODE); - else { - warnForDeletedHydratableText(parentNode, instance); + ref._stringRef = stringRef; + return ref; + } else { + if (typeof mixedRef !== "string") { + throw new Error( + "Expected ref to be a function, a string, an object returned by React.createRef(), or null." + ); } - } - } -} -function didNotHydrateInstance( - parentType, - parentProps, - parentInstance, - instance, - isConcurrentMode -) { - { - if ( - isConcurrentMode || - parentProps[SUPPRESS_HYDRATION_WARNING$1] !== true - ) { - if (instance.nodeType === ELEMENT_NODE) { - warnForDeletedHydratableElement(parentInstance, instance); - } else if (instance.nodeType === COMMENT_NODE); - else { - warnForDeletedHydratableText(parentInstance, instance); + + if (!element._owner) { + throw new Error( + "Element ref was specified as a string (" + + mixedRef + + ") but no owner was set. This could happen for one of" + + " the following reasons:\n" + + "1. You may be adding a ref to a function component\n" + + "2. You may be adding a ref to a component that was not created inside a component's render method\n" + + "3. You have multiple copies of React loaded\n" + + "See https://reactjs.org/link/refs-must-have-owner for more information." + ); } } } + + return mixedRef; } -function didNotFindHydratableInstanceWithinContainer( - parentContainer, - type, - props -) { - { - warnForInsertedHydratedElement(parentContainer, type); - } -} -function didNotFindHydratableTextInstanceWithinContainer( - parentContainer, - text -) { - { - warnForInsertedHydratedText(parentContainer, text); - } + +function throwOnInvalidObjectType(returnFiber, newChild) { + // $FlowFixMe[method-unbinding] + var childString = Object.prototype.toString.call(newChild); + throw new Error( + "Objects are not valid as a React child (found: " + + (childString === "[object Object]" + ? "object with keys {" + Object.keys(newChild).join(", ") + "}" + : childString) + + "). " + + "If you meant to render a collection of children, use an array " + + "instead." + ); } -function didNotFindHydratableInstanceWithinSuspenseInstance( - parentInstance, - type, - props -) { + +function warnOnFunctionType(returnFiber) { { - // $FlowFixMe: Only Element or Document can be parent nodes. - var parentNode = parentInstance.parentNode; - if (parentNode !== null) warnForInsertedHydratedElement(parentNode, type); + var componentName = getComponentNameFromFiber(returnFiber) || "Component"; + + if (ownerHasFunctionTypeWarning[componentName]) { + return; + } + + ownerHasFunctionTypeWarning[componentName] = true; + + error( + "Functions are not valid as a React child. This may happen if " + + "you return a Component instead of from render. " + + "Or maybe you meant to call this function rather than return it." + ); } } -function didNotFindHydratableTextInstanceWithinSuspenseInstance( - parentInstance, - text -) { - { - // $FlowFixMe: Only Element or Document can be parent nodes. - var parentNode = parentInstance.parentNode; - if (parentNode !== null) warnForInsertedHydratedText(parentNode, text); - } + +function resolveLazy(lazyType) { + var payload = lazyType._payload; + var init = lazyType._init; + return init(payload); } -function didNotFindHydratableInstance( - parentType, - parentProps, - parentInstance, - type, - props, - isConcurrentMode -) { - { - if ( - isConcurrentMode || - parentProps[SUPPRESS_HYDRATION_WARNING$1] !== true - ) { - warnForInsertedHydratedElement(parentInstance, type); + +// This wrapper function exists because I expect to clone the code in each path +// to be able to optimize each path individually by branching early. This needs +// a compiler or we can do it manually. Helpers that don't need this branching +// live outside of this function. +function createChildReconciler(shouldTrackSideEffects) { + function deleteChild(returnFiber, childToDelete) { + if (!shouldTrackSideEffects) { + // Noop. + return; } - } -} -function didNotFindHydratableTextInstance( - parentType, - parentProps, - parentInstance, - text, - isConcurrentMode -) { - { - if ( - isConcurrentMode || - parentProps[SUPPRESS_HYDRATION_WARNING$1] !== true - ) { - warnForInsertedHydratedText(parentInstance, text); + + var deletions = returnFiber.deletions; + + if (deletions === null) { + returnFiber.deletions = [childToDelete]; + returnFiber.flags |= ChildDeletion; + } else { + deletions.push(childToDelete); } } -} -function errorHydratingContainer(parentContainer) { - { - // TODO: This gets logged by onRecoverableError, too, so we should be - // able to remove it. - error( - "An error occurred during hydration. The server HTML was replaced with client content in <%s>.", - parentContainer.nodeName.toLowerCase() - ); - } -} // ------------------- -function findFiberRoot(node) { - var stack = [node]; - var index = 0; - while (index < stack.length) { - var current = stack[index++]; + function deleteRemainingChildren(returnFiber, currentFirstChild) { + if (!shouldTrackSideEffects) { + // Noop. + return null; + } // TODO: For the shouldClone case, this could be micro-optimized a bit by + // assuming that after the first child we've already added everything. - if (isContainerMarkedAsRoot(current)) { - return getInstanceFromNode$1(current); + var childToDelete = currentFirstChild; + + while (childToDelete !== null) { + deleteChild(returnFiber, childToDelete); + childToDelete = childToDelete.sibling; } - stack.push.apply(stack, current.children); + return null; } - return null; -} -function getBoundingRect(node) { - var rect = node.getBoundingClientRect(); - return { - x: rect.left, - y: rect.top, - width: rect.width, - height: rect.height - }; -} -function matchAccessibilityRole(node, role) { - if (hasRole(node, role)) { - return true; - } - - return false; -} -function getTextContent(fiber) { - switch (fiber.tag) { - case HostResource: - case HostSingleton: - case HostComponent: - var textContent = ""; - var childNodes = fiber.stateNode.childNodes; - - for (var i = 0; i < childNodes.length; i++) { - var childNode = childNodes[i]; + function mapRemainingChildren(returnFiber, currentFirstChild) { + // Add the remaining children to a temporary map so that we can find them by + // keys quickly. Implicit (null) keys get added to this set with their index + // instead. + var existingChildren = new Map(); + var existingChild = currentFirstChild; - if (childNode.nodeType === Node.TEXT_NODE) { - textContent += childNode.textContent; - } + while (existingChild !== null) { + if (existingChild.key !== null) { + existingChildren.set(existingChild.key, existingChild); + } else { + existingChildren.set(existingChild.index, existingChild); } - return textContent; + existingChild = existingChild.sibling; + } - case HostText: - return fiber.stateNode.textContent; + return existingChildren; } - return null; -} -function isHiddenSubtree(fiber) { - return fiber.tag === HostComponent && fiber.memoizedProps.hidden === true; -} -function setFocusIfFocusable(node) { - // The logic for determining if an element is focusable is kind of complex, - // and since we want to actually change focus anyway- we can just skip it. - // Instead we'll just listen for a "focus" event to verify that focus was set. - // - // We could compare the node to document.activeElement after focus, - // but this would not handle the case where application code managed focus to automatically blur. - var didFocus = false; - - var handleFocus = function() { - didFocus = true; - }; - - var element = node; + function useFiber(fiber, pendingProps) { + // We currently set sibling to null and index to 0 here because it is easy + // to forget to do before returning it. E.g. for the single child case. + var clone = createWorkInProgress(fiber, pendingProps); + clone.index = 0; + clone.sibling = null; + return clone; + } - try { - element.addEventListener("focus", handleFocus); // $FlowFixMe[method-unbinding] + function placeChild(newFiber, lastPlacedIndex, newIndex) { + newFiber.index = newIndex; - (element.focus || HTMLElement.prototype.focus).call(element); - } finally { - element.removeEventListener("focus", handleFocus); - } + if (!shouldTrackSideEffects) { + // During hydration, the useId algorithm needs to know which fibers are + // part of a list of children (arrays, iterators). + newFiber.flags |= Forked; + return lastPlacedIndex; + } - return didFocus; -} -function setupIntersectionObserver(targets, callback, options) { - var rectRatioCache = new Map(); - targets.forEach(function(target) { - rectRatioCache.set(target, { - rect: getBoundingRect(target), - ratio: 0 - }); - }); + var current = newFiber.alternate; - var handleIntersection = function(entries) { - entries.forEach(function(entry) { - var boundingClientRect = entry.boundingClientRect, - intersectionRatio = entry.intersectionRatio, - target = entry.target; - rectRatioCache.set(target, { - rect: { - x: boundingClientRect.left, - y: boundingClientRect.top, - width: boundingClientRect.width, - height: boundingClientRect.height - }, - ratio: intersectionRatio - }); - }); - callback(Array.from(rectRatioCache.values())); - }; + if (current !== null) { + var oldIndex = current.index; - var observer = new IntersectionObserver(handleIntersection, options); - targets.forEach(function(target) { - observer.observe(target); - }); - return { - disconnect: function() { - return observer.disconnect(); - }, - observe: function(target) { - rectRatioCache.set(target, { - rect: getBoundingRect(target), - ratio: 0 - }); - observer.observe(target); - }, - unobserve: function(target) { - rectRatioCache.delete(target); - observer.unobserve(target); + if (oldIndex < lastPlacedIndex) { + // This is a move. + newFiber.flags |= Placement | PlacementDEV; + return lastPlacedIndex; + } else { + // This item can stay in place. + return oldIndex; + } + } else { + // This is an insertion. + newFiber.flags |= Placement | PlacementDEV; + return lastPlacedIndex; } - }; -} -function isHostResourceType(type, props, hostContext) { - var outsideHostContainerContext; - var namespace; + } - { - var hostContextDev = hostContext; // We can only render resources when we are not within the host container context + function placeSingleChild(newFiber) { + // This is simpler for the single child case. We only need to do a + // placement for inserting new children. + if (shouldTrackSideEffects && newFiber.alternate === null) { + newFiber.flags |= Placement | PlacementDEV; + } - outsideHostContainerContext = !hostContextDev.ancestorInfo - .containerTagInScope; - namespace = hostContextDev.namespace; + return newFiber; } - switch (type) { - case "base": - case "meta": { - return true; + function updateTextNode(returnFiber, current, textContent, lanes) { + if (current === null || current.tag !== HostText) { + // Insert + var created = createFiberFromText(textContent, returnFiber.mode, lanes); + created.return = returnFiber; + return created; + } else { + // Update + var existing = useFiber(current, textContent); + existing.return = returnFiber; + return existing; } + } - case "title": { - return namespace !== SVG_NAMESPACE; + function updateElement(returnFiber, current, element, lanes) { + var elementType = element.type; + + if (elementType === REACT_FRAGMENT_TYPE) { + return updateFragment( + returnFiber, + current, + element.props.children, + lanes, + element.key + ); } - case "link": { - var onLoad = props.onLoad, - onError = props.onError; + if (current !== null) { + if ( + current.elementType === elementType || // Keep this check inline so it only runs on the false path: + isCompatibleFamilyForHotReloading(current, element) || // Lazy types should reconcile their resolved type. + // We need to do this after the Hot Reloading check above, + // because hot reloading has different semantics than prod because + // it doesn't resuspend. So we can't let the call below suspend. + (typeof elementType === "object" && + elementType !== null && + elementType.$$typeof === REACT_LAZY_TYPE && + resolveLazy(elementType) === current.type) + ) { + // Move based on index + var existing = useFiber(current, element.props); + existing.ref = coerceRef(returnFiber, current, element); + existing.return = returnFiber; - if (onLoad || onError) { { - if (outsideHostContainerContext) { - error( - "Cannot render a with onLoad or onError listeners outside the main document." + - " Try removing onLoad={...} and onError={...} or moving it into the root tag or" + - " somewhere in the ." - ); - } else if (namespace === SVG_NAMESPACE) { - error( - "Cannot render a with onLoad or onError listeners as a descendent of ." + - " Try removing onLoad={...} and onError={...} or moving it above the ancestor." - ); - } + existing._debugSource = element._source; + existing._debugOwner = element._owner; } - return false; + return existing; } + } // Insert - switch (props.rel) { - case "stylesheet": { - var href = props.href, - precedence = props.precedence, - disabled = props.disabled; + var created = createFiberFromElement(element, returnFiber.mode, lanes); + created.ref = coerceRef(returnFiber, current, element); + created.return = returnFiber; + return created; + } - { - validateLinkPropsForStyleResource(props); + function updatePortal(returnFiber, current, portal, lanes) { + if ( + current === null || + current.tag !== HostPortal || + current.stateNode.containerInfo !== portal.containerInfo || + current.stateNode.implementation !== portal.implementation + ) { + // Insert + var created = createFiberFromPortal(portal, returnFiber.mode, lanes); + created.return = returnFiber; + return created; + } else { + // Update + var existing = useFiber(current, portal.children || []); + existing.return = returnFiber; + return existing; + } + } - if (typeof precedence !== "string") { - if (outsideHostContainerContext) { - error( - 'Cannot render a outside the main document without knowing its precedence.' + - ' Consider adding precedence="default" or moving it into the root tag.' - ); - } else if (namespace === SVG_NAMESPACE) { - error( - 'Cannot render a as a descendent of an element without knowing its precedence.' + - ' Consider adding precedence="default" or moving it above the ancestor.' - ); - } - } - } + function updateFragment(returnFiber, current, fragment, lanes, key) { + if (current === null || current.tag !== Fragment) { + // Insert + var created = createFiberFromFragment( + fragment, + returnFiber.mode, + lanes, + key + ); + created.return = returnFiber; + return created; + } else { + // Update + var existing = useFiber(current, fragment); + existing.return = returnFiber; + return existing; + } + } - return ( - typeof href === "string" && - typeof precedence === "string" && - disabled == null + function createChild(returnFiber, newChild, lanes) { + if ( + (typeof newChild === "string" && newChild !== "") || + typeof newChild === "number" + ) { + // Text nodes don't have keys. If the previous node is implicitly keyed + // we can continue to replace it without aborting even if it is not a text + // node. + var created = createFiberFromText("" + newChild, returnFiber.mode, lanes); + created.return = returnFiber; + return created; + } + + if (typeof newChild === "object" && newChild !== null) { + switch (newChild.$$typeof) { + case REACT_ELEMENT_TYPE: { + var _created = createFiberFromElement( + newChild, + returnFiber.mode, + lanes ); - } - default: { - var rel = props.rel, - _href = props.href; - return typeof _href === "string" && typeof rel === "string"; + _created.ref = coerceRef(returnFiber, null, newChild); + _created.return = returnFiber; + return _created; } - } - } - case "script": { - // We don't validate because it is valid to use async with onLoad/onError unlike combining - // precedence with these for style resources - var src = props.src, - async = props.async, - _onLoad = props.onLoad, - _onError = props.onError; + case REACT_PORTAL_TYPE: { + var _created2 = createFiberFromPortal( + newChild, + returnFiber.mode, + lanes + ); - { - if (async !== true) { - if (outsideHostContainerContext) { - error( - "Cannot render a sync or defer tag.' - ); - } else if (namespace === SVG_NAMESPACE) { - error( - "Cannot render a sync or defer