diff --git a/.circleci/config.yml b/.circleci/config.yml index b9135488f76453..eaa71d27e3f436 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -2,12 +2,12 @@ aliases: # Cache Management - &restore-yarn-cache keys: - - v1-yarn-cache-{{ arch }}-{{ checksum "package.json" }} - - v1-yarn-cache-{{ arch }} + - v2-yarn-cache-{{ arch }}-{{ checksum "package.json" }} + - v2-yarn-cache-{{ arch }} - &save-yarn-cache paths: - ~/.cache/yarn - key: v1-yarn-cache-{{ arch }}-{{ checksum "package.json" }} + key: v2-yarn-cache-{{ arch }}-{{ checksum "package.json" }} - &restore-node-modules keys: @@ -26,28 +26,44 @@ aliases: - node_modules key: v1-analysis-dependencies-{{ arch }}-{{ checksum "package.json" }}{{ checksum "bots/package.json" }} + - &restore-cache-android-packages + keys: + - v1-android-sdkmanager-packages-api-28-alpha-{{ checksum "scripts/.tests.env" }} + - &save-cache-android-packages + paths: + - /opt/android/sdk + key: v1-android-sdkmanager-packages-api-28-alpha-{{ checksum "scripts/.tests.env" }} + - &restore-cache-gradle keys: - - v1-gradle-{{ .Branch }}-{{ checksum "build.gradle" }}-{{ checksum "ReactAndroid/build.gradle" }} + - v2-gradle-{{ .Branch }}-{{ checksum "build.gradle" }}-{{ checksum "ReactAndroid/build.gradle" }} # Fallback in case checksum fails - - v1-gradle-{{ .Branch }}-{{ checksum "build.gradle" }}- - - v1-gradle-{{ .Branch }}- + - v2-gradle-{{ .Branch }}-{{ checksum "build.gradle" }}- + - v2-gradle-{{ .Branch }}- # Fallback in case this is a first-time run on a fork - - v1-gradle-master- + - v2-gradle-master- - &save-cache-gradle paths: - ~/.gradle - key: v1-gradle-{{ .Branch }}-{{ checksum "build.gradle" }}-{{ checksum "ReactAndroid/build.gradle" }} + key: v2-gradle-{{ .Branch }}-{{ checksum "build.gradle" }}-{{ checksum "ReactAndroid/build.gradle" }} + + - &restore-cache-ndk + keys: + - v3-android-ndk-r17c-{{ checksum "scripts/android-setup.sh" }} + - &save-cache-ndk + paths: + - /opt/ndk + key: v3-android-ndk-r17c-{{ checksum "scripts/android-setup.sh" }} - &restore-cache-downloads-buck keys: - - v3-buck-v2019.01.10.01-{{ checksum "scripts/circleci/buck_fetch.sh" }}} - - v3-buck-v2019.01.10.01- + - v4-buck-v2019.01.10.01-{{ checksum "scripts/circleci/buck_fetch.sh" }}} + - v4-buck-v2019.01.10.01- - &save-cache-downloads-buck paths: - ~/buck - ~/okbuck - key: v3-buck-v2019.01.10.01-{{ checksum "scripts/circleci/buck_fetch.sh" }} + key: v4-buck-v2019.01.10.01-{{ checksum "scripts/circleci/buck_fetch.sh" }} - &restore-cache-watchman keys: @@ -59,14 +75,14 @@ aliases: - &restore-cache-downloads-gradle keys: - - v1-gradle-{{ checksum "ReactAndroid/build.gradle" }}-{{ checksum "scripts/circleci/gradle_download_deps.sh" }} - - v1-gradle- + - v2-gradle-{{ checksum "ReactAndroid/build.gradle" }}-{{ checksum "scripts/circleci/gradle_download_deps.sh" }} + - v2-gradle- - &save-cache-downloads-gradle paths: - ~/.gradle - ReactAndroid/build/downloads - ReactAndroid/build/third-party-ndk - key: v1-gradle-{{ checksum "ReactAndroid/build.gradle" }}-{{ checksum "scripts/circleci/gradle_download_deps.sh" }} + key: v2-gradle-{{ checksum "ReactAndroid/build.gradle" }}-{{ checksum "scripts/circleci/gradle_download_deps.sh" }} - &restore-cache-homebrew keys: @@ -99,6 +115,11 @@ aliases: - /.*-stable/ - gh-pages + # Dependency Management + - &install-ndk + name: Install Android NDK + command: source scripts/android-setup.sh && getAndroidNDK + - &yarn name: Run Yarn command: | @@ -108,9 +129,20 @@ aliases: yarn install --non-interactive --cache-folder ~/.cache/yarn fi + - &install-yarn + name: Install Yarn + command: | + curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add - + echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list + sudo apt-get update && sudo apt-get install yarn + - &install-buck name: Install BUCK command: | + if [[ ! -e ~/buck ]]; then + git clone https://github.com/facebook/buck.git ~/buck --branch v2019.01.10.01 --depth=1 + fi + cd ~/buck && ant buck --version # Install related tooling if [[ ! -e ~/okbuck ]]; then @@ -118,6 +150,30 @@ aliases: fi mkdir -p ~/react-native/tooling/junit cp -R ~/okbuck/tooling/junit/* ~/react-native/tooling/junit/. + + - &create-ndk-directory + name: Create Android NDK Directory + command: | + if [[ ! -e /opt/ndk ]]; then + sudo mkdir /opt/ndk + fi + sudo chown ${USER:=$(/usr/bin/id -run)}:$USER /opt/ndk + + # CircleCI does not support interpolating env variables in the environment + # https://circleci.com/docs/2.0/env-vars/#interpolating-environment-variables-to-set-other-environment-variables + - &configure-android-path + name: Configure Environment Variables + command: | + echo 'export PATH=${ANDROID_NDK}:~/buck/bin:$PATH' >> $BASH_ENV + source $BASH_ENV + - &install-android-packages + name: Install Android SDK Packages + command: source scripts/android-setup.sh && getAndroidPackages + + - &install-android-build-dependencies + name: Install Android Build Dependencies + command: ./scripts/circleci/apt-get-android-deps.sh + - &validate-android-sdk name: Validate Android SDK Install command: ./scripts/validate-android-sdk.sh @@ -187,7 +243,7 @@ aliases: - &build-js-bundle name: Build JavaScript Bundle - command: node cli.js bundle --max-workers 2 --platform android --dev true --entry-file ReactAndroid/src/androidTest/js/TestBundle.js --bundle-output ReactAndroid/src/androidTest/assets/AndroidTestBundle.js + command: node cli.js bundle --max-workers 2 --platform android --dev true --entry-file ReactAndroid/src/androidTest/js/TestBundle.js --bundle-output ReactAndroid/src/androidTest/assets/AndroidTestBundle.js --reactNativePath . - &compile-native-libs name: Compile Native Libs for Unit and Integration Tests @@ -208,7 +264,7 @@ aliases: - &build-android-rntester-app name: Build Android RNTester App - command: ./gradlew RNTester:android:app:assembleRelease + command: ./gradlew RNTester:android:app:assembleRelease -Pjobs=$BUILD_THREADS - &collect-android-test-results name: Collect Test Results @@ -283,13 +339,14 @@ js_defaults: &js_defaults android_defaults: &android_defaults <<: *defaults docker: - - image: reactnativecommunity/react-native-android + - image: circleci/android:api-28-node8-alpha resource_class: "large" environment: - TERM: "dumb" - ADB_INSTALL_TIMEOUT: 10 - _JAVA_OPTIONS: "-XX:+UnlockExperimentalVMOptions -XX:+UseCGroupMemoryLimitForHeap" - GRADLE_OPTS: '-Dorg.gradle.daemon=false -Dorg.gradle.jvmargs="-XX:+HeapDumpOnOutOfMemoryError"' + - ANDROID_NDK: '/opt/ndk/android-ndk-r17c' - BUILD_THREADS: 2 macos_defaults: &macos_defaults @@ -415,6 +472,15 @@ jobs: - attach_workspace: at: ~/react-native + # Configure Android SDK and related dependencies + - run: *configure-android-path + # Android build deps install from the network faster than cache + - run: *install-android-build-dependencies + + - restore-cache: *restore-cache-android-packages + - run: *install-android-packages + - save-cache: *save-cache-android-packages + # Validate Android SDK installation and packages - run: *validate-android-sdk @@ -424,6 +490,12 @@ jobs: # Keep configuring Android dependencies while AVD boots up + # Install Android NDK + - run: *create-ndk-directory + - restore-cache: *restore-cache-ndk + - run: *install-ndk + - save-cache: *save-cache-ndk + # Install Buck - restore-cache: *restore-cache-downloads-buck - run: *install-buck @@ -547,21 +619,26 @@ jobs: <<: *android_defaults steps: - checkout - - - restore-cache: *restore-yarn-cache - run: *yarn + # Configure Android SDK and related dependencies + - run: *configure-android-path + - run: *install-android-build-dependencies + + - run: *install-android-packages + + # Install Android NDK + - run: *create-ndk-directory + - restore-cache: *restore-cache-ndk + - run: *install-ndk + # Fetch dependencies using Buck - - restore-cache: *restore-cache-downloads-buck + - run: *install-buck - run: *download-dependencies-buck # Fetch dependencies using Gradle - - restore-cache: *restore-cache-downloads-gradle - run: *download-dependencies-gradle - - restore-cache: *restore-yarn-cache - - run: *yarn - - run: name: Authenticate with npm command: echo "//registry.npmjs.org/:_authToken=${CIRCLE_NPM_TOKEN}" > ~/.npmrc diff --git a/ContainerShip/scripts/run-android-docker-instrumentation-tests.sh b/ContainerShip/scripts/run-android-docker-instrumentation-tests.sh index 2062b547e2bbc4..5f2e3154f063f1 100644 --- a/ContainerShip/scripts/run-android-docker-instrumentation-tests.sh +++ b/ContainerShip/scripts/run-android-docker-instrumentation-tests.sh @@ -31,7 +31,7 @@ watchman shutdown-server # integration tests # build JS bundle for instrumentation tests -node cli.js bundle --platform android --dev true --entry-file ReactAndroid/src/androidTest/js/TestBundle.js --bundle-output ReactAndroid/src/androidTest/assets/AndroidTestBundle.js +node cli.js bundle --platform android --dev true --entry-file ReactAndroid/src/androidTest/js/TestBundle.js --bundle-output ReactAndroid/src/androidTest/assets/AndroidTestBundle.js --reactNativePath . # build test APK # shellcheck disable=SC1091 diff --git a/Libraries/CameraRoll/RCTImagePickerManager.m b/Libraries/CameraRoll/RCTImagePickerManager.m index b8e570cfcd7b77..9ccc24845e78cc 100644 --- a/Libraries/CameraRoll/RCTImagePickerManager.m +++ b/Libraries/CameraRoll/RCTImagePickerManager.m @@ -52,9 +52,14 @@ - (id)init return self; } ++ (BOOL)requiresMainQueueSetup +{ + return NO; +} + - (void)dealloc { - [[NSNotificationCenter defaultCenter] removeObserver:self name:@"AVCaptureDeviceDidStartRunningNotification" object:nil]; + [[NSNotificationCenter defaultCenter] removeObserver:self name:@"AVCaptureDeviceDidStartRunningNotification" object:nil]; } - (dispatch_queue_t)methodQueue diff --git a/Libraries/Components/ScrollView/ScrollView.js b/Libraries/Components/ScrollView/ScrollView.js index c237e0a6a4a96d..6a9ce2c7fed555 100644 --- a/Libraries/Components/ScrollView/ScrollView.js +++ b/Libraries/Components/ScrollView/ScrollView.js @@ -210,6 +210,12 @@ type IOSProps = $ReadOnly<{| * @platform ios */ scrollIndicatorInsets?: ?EdgeInsetsProp, + /** + * When true, the scroll view can be programmatically scrolled beyond its + * content size. The default value is false. + * @platform ios + */ + scrollToOverflowEnabled?: ?boolean, /** * When true, the scroll view scrolls to top when the status bar is tapped. * The default value is true. diff --git a/Libraries/Components/Switch/Switch.js b/Libraries/Components/Switch/Switch.js index 9bd00aaf1b0e42..ad928639748fd9 100644 --- a/Libraries/Components/Switch/Switch.js +++ b/Libraries/Components/Switch/Switch.js @@ -137,6 +137,8 @@ class Switch extends React.Component { on: value === true, style, thumbTintColor: _thumbColor, + trackColorForFalse: _trackColorForFalse, + trackColorForTrue: _trackColorForTrue, trackTintColor: value === true ? _trackColorForTrue : _trackColorForFalse, }: NativeAndroidProps) diff --git a/Libraries/Components/TextInput/TextInput.js b/Libraries/Components/TextInput/TextInput.js index 296b6ec72dc029..bb40beb12c54fe 100644 --- a/Libraries/Components/TextInput/TextInput.js +++ b/Libraries/Components/TextInput/TextInput.js @@ -223,6 +223,21 @@ type IOSProps = $ReadOnly<{| |}>; type AndroidProps = $ReadOnly<{| + autoCompleteType?: ?( + | 'cc-csc' + | 'cc-exp' + | 'cc-exp-month' + | 'cc-exp-year' + | 'cc-number' + | 'email' + | 'name' + | 'password' + | 'postal-code' + | 'street-address' + | 'tel' + | 'username' + | 'off' + ), returnKeyLabel?: ?string, numberOfLines?: ?number, disableFullscreenUI?: ?boolean, @@ -230,6 +245,13 @@ type AndroidProps = $ReadOnly<{| underlineColorAndroid?: ?ColorValue, inlineImageLeft?: ?string, inlineImagePadding?: ?number, + importantForAutofill?: ?( + | 'auto' + | 'no' + | 'noExcludeDescendants' + | 'yes' + | 'yesExcludeDescendants' + ), |}>; type Props = $ReadOnly<{| @@ -413,6 +435,45 @@ const TextInput = createReactClass({ 'words', 'characters', ]), + /** + * Determines which content to suggest on auto complete, e.g.`username`. + * To disable auto complete, use `off`. + * + * *Android Only* + * + * The following values work on Android only: + * + * - `username` + * - `password` + * - `email` + * - `name` + * - `tel` + * - `street-address` + * - `postal-code` + * - `cc-number` + * - `cc-csc` + * - `cc-exp` + * - `cc-exp-month` + * - `cc-exp-year` + * - `off` + * + * @platform android + */ + autoCompleteType: PropTypes.oneOf([ + 'cc-csc', + 'cc-exp', + 'cc-exp-month', + 'cc-exp-year', + 'cc-number', + 'email', + 'name', + 'password', + 'postal-code', + 'street-address', + 'tel', + 'username', + 'off', + ]), /** * If `false`, disables auto-correct. The default value is `true`. */ diff --git a/Libraries/Components/Touchable/Touchable.js b/Libraries/Components/Touchable/Touchable.js index 65a82b1c4fb113..08237c6f0e0452 100644 --- a/Libraries/Components/Touchable/Touchable.js +++ b/Libraries/Components/Touchable/Touchable.js @@ -484,6 +484,7 @@ const TouchableMixin = { * Place as callback for a DOM element's `onResponderRelease` event. */ touchableHandleResponderRelease: function(e: PressEvent) { + this.pressInLocation = null; this._receiveSignal(Signals.RESPONDER_RELEASE, e); }, @@ -491,6 +492,7 @@ const TouchableMixin = { * Place as callback for a DOM element's `onResponderTerminate` event. */ touchableHandleResponderTerminate: function(e: PressEvent) { + this.pressInLocation = null; this._receiveSignal(Signals.RESPONDER_TERMINATED, e); }, @@ -558,9 +560,13 @@ const TouchableMixin = { dimensionsOnActivate.height + pressExpandBottom; if (isTouchWithinActive) { + const prevState = this.state.touchable.touchState; this._receiveSignal(Signals.ENTER_PRESS_RECT, e); const curState = this.state.touchable.touchState; - if (curState === States.RESPONDER_INACTIVE_PRESS_IN) { + if ( + curState === States.RESPONDER_INACTIVE_PRESS_IN && + prevState !== States.RESPONDER_INACTIVE_PRESS_IN + ) { // fix for t7967420 this._cancelLongPressDelayTimeout(); } diff --git a/Libraries/Core/ReactNativeVersion.js b/Libraries/Core/ReactNativeVersion.js index 1fcb2e9eb61be9..ce162de5a72e55 100644 --- a/Libraries/Core/ReactNativeVersion.js +++ b/Libraries/Core/ReactNativeVersion.js @@ -1,17 +1,17 @@ /** + * @generated by scripts/bump-oss-version.js + * * Copyright (c) Facebook, Inc. and its affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * - * @format - * @generated by scripts/bump-oss-version.js * @flow */ exports.version = { major: 0, - minor: 0, - patch: 0, + minor: 59, + patch: 6, prerelease: null, }; diff --git a/Libraries/LinkingIOS/RCTLinkingManager.h b/Libraries/LinkingIOS/RCTLinkingManager.h index de38c85de62216..b0d8d0053504f2 100644 --- a/Libraries/LinkingIOS/RCTLinkingManager.h +++ b/Libraries/LinkingIOS/RCTLinkingManager.h @@ -22,6 +22,11 @@ + (BOOL)application:(nonnull UIApplication *)application continueUserActivity:(nonnull NSUserActivity *)userActivity - restorationHandler:(nonnull void (^)(NSArray *__nullable))restorationHandler; + restorationHandler: + #if __has_include() && defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && (__IPHONE_OS_VERSION_MAX_ALLOWED >= 12000) /* __IPHONE_12_0 */ + (nonnull void (^)(NSArray> *_Nullable))restorationHandler; + #else + (nonnull void (^)(NSArray *_Nullable))restorationHandler; + #endif @end diff --git a/Libraries/LinkingIOS/RCTLinkingManager.m b/Libraries/LinkingIOS/RCTLinkingManager.m index 768f47edb063b4..353d0f78b96441 100644 --- a/Libraries/LinkingIOS/RCTLinkingManager.m +++ b/Libraries/LinkingIOS/RCTLinkingManager.m @@ -67,8 +67,12 @@ + (BOOL)application:(UIApplication *)application + (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity - restorationHandler:(void (^)(NSArray * __nullable))restorationHandler -{ + restorationHandler: + #if __has_include() && defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && (__IPHONE_OS_VERSION_MAX_ALLOWED >= 12000) /* __IPHONE_12_0 */ + (nonnull void (^)(NSArray> *_Nullable))restorationHandler { + #else + (nonnull void (^)(NSArray *_Nullable))restorationHandler { + #endif if ([userActivity.activityType isEqualToString:NSUserActivityTypeBrowsingWeb]) { NSDictionary *payload = @{@"url": userActivity.webpageURL.absoluteString}; [[NSNotificationCenter defaultCenter] postNotificationName:kOpenURLNotification diff --git a/Libraries/Lists/VirtualizedList.js b/Libraries/Lists/VirtualizedList.js index 8455c51d6167b8..72686db4e322c1 100644 --- a/Libraries/Lists/VirtualizedList.js +++ b/Libraries/Lists/VirtualizedList.js @@ -893,7 +893,10 @@ class VirtualizedList extends React.PureComponent { element.props.onLayout(event); } }, - style: [element.props.style, inversionStyle], + style: StyleSheet.compose( + inversionStyle, + element.props.style, + ), }), ); } @@ -937,7 +940,7 @@ class VirtualizedList extends React.PureComponent { : this.props.inverted, stickyHeaderIndices, }; - if (inversionStyle && itemCount !== 0) { + if (inversionStyle) { /* $FlowFixMe(>=0.70.0 site=react_native_fb) This comment suppresses an * error found when Flow v0.70 was deployed. To see the error delete * this comment and run Flow. */ @@ -1181,7 +1184,8 @@ class VirtualizedList extends React.PureComponent { _renderDebugOverlay() { const normalize = - this._scrollMetrics.visibleLength / this._scrollMetrics.contentLength; + this._scrollMetrics.visibleLength / + (this._scrollMetrics.contentLength || 1); const framesInLayout = []; const itemCount = this.props.getItemCount(this.props.data); for (let ii = 0; ii < itemCount; ii++) { diff --git a/Libraries/Lists/VirtualizedSectionList.js b/Libraries/Lists/VirtualizedSectionList.js index e314871c4ee13a..203813b96e086b 100644 --- a/Libraries/Lists/VirtualizedSectionList.js +++ b/Libraries/Lists/VirtualizedSectionList.js @@ -146,7 +146,7 @@ class VirtualizedSectionList extends React.PureComponent< sectionIndex: number, viewPosition?: number, }) { - let index = Platform.OS === 'ios' ? params.itemIndex : params.itemIndex - 1; + let index = Platform.OS === 'ios' ? params.itemIndex : params.itemIndex + 1; for (let ii = 0; ii < params.sectionIndex; ii++) { index += this.props.sections[ii].data.length + 2; } diff --git a/Libraries/Renderer/REVISION b/Libraries/Renderer/REVISION index afe4ebf1265bea..878748d2ea927f 100644 --- a/Libraries/Renderer/REVISION +++ b/Libraries/Renderer/REVISION @@ -1 +1 @@ -f24a0da6e0f59484e5aafd0825bb1a6ed27d7182 \ No newline at end of file +c64b330032cef887ac5f787ac4a50bb4eeca4e1d \ No newline at end of file diff --git a/Libraries/Renderer/oss/ReactFabric-dev.js b/Libraries/Renderer/oss/ReactFabric-dev.js index 147df8bf432166..2e3871931b554f 100644 --- a/Libraries/Renderer/oss/ReactFabric-dev.js +++ b/Libraries/Renderer/oss/ReactFabric-dev.js @@ -26,10 +26,20 @@ var deepFreezeAndThrowOnMutationInDev = require("deepFreezeAndThrowOnMutationInD var TextInputState = require("TextInputState"); var FabricUIManager = require("FabricUIManager"); var checkPropTypes = require("prop-types/checkPropTypes"); +var Scheduler = require("scheduler"); var tracing = require("scheduler/tracing"); -var scheduler = require("scheduler"); var ExceptionsManager = require("ExceptionsManager"); +// Do not require this module directly! Use a normal error constructor with +// template literal strings. The messages will be converted to ReactError during +// build, and in production they will be minified. + +function ReactError(message) { + var error = new Error(message); + error.name = "Invariant Violation"; + return error; +} + /** * Use invariant() to assert state which your program assumes to be true. * @@ -41,39 +51,237 @@ var ExceptionsManager = require("ExceptionsManager"); * will remain to ensure logic does not differ in production. */ -var validateFormat = function() {}; +/** + * Injectable ordering of event plugins. + */ +var eventPluginOrder = null; -{ - validateFormat = function(format) { - if (format === undefined) { - throw new Error("invariant requires an error message argument"); +/** + * Injectable mapping from names to event plugin modules. + */ +var namesToPlugins = {}; + +/** + * Recomputes the plugin list using the injected plugins and plugin ordering. + * + * @private + */ +function recomputePluginOrdering() { + if (!eventPluginOrder) { + // Wait until an `eventPluginOrder` is injected. + return; + } + for (var pluginName in namesToPlugins) { + var pluginModule = namesToPlugins[pluginName]; + var pluginIndex = eventPluginOrder.indexOf(pluginName); + (function() { + if (!(pluginIndex > -1)) { + throw ReactError( + "EventPluginRegistry: Cannot inject event plugins that do not exist in the plugin ordering, `" + + pluginName + + "`." + ); + } + })(); + if (plugins[pluginIndex]) { + continue; } - }; + (function() { + if (!pluginModule.extractEvents) { + throw ReactError( + "EventPluginRegistry: Event plugins must implement an `extractEvents` method, but `" + + pluginName + + "` does not." + ); + } + })(); + plugins[pluginIndex] = pluginModule; + var publishedEvents = pluginModule.eventTypes; + for (var eventName in publishedEvents) { + (function() { + if ( + !publishEventForPlugin( + publishedEvents[eventName], + pluginModule, + eventName + ) + ) { + throw ReactError( + "EventPluginRegistry: Failed to publish event `" + + eventName + + "` for plugin `" + + pluginName + + "`." + ); + } + })(); + } + } } -function invariant(condition, format, a, b, c, d, e, f) { - validateFormat(format); +/** + * Publishes an event so that it can be dispatched by the supplied plugin. + * + * @param {object} dispatchConfig Dispatch configuration for the event. + * @param {object} PluginModule Plugin publishing the event. + * @return {boolean} True if the event was successfully published. + * @private + */ +function publishEventForPlugin(dispatchConfig, pluginModule, eventName) { + (function() { + if (!!eventNameDispatchConfigs.hasOwnProperty(eventName)) { + throw ReactError( + "EventPluginHub: More than one plugin attempted to publish the same event name, `" + + eventName + + "`." + ); + } + })(); + eventNameDispatchConfigs[eventName] = dispatchConfig; - if (!condition) { - var error = void 0; - if (format === undefined) { - error = new Error( - "Minified exception occurred; use the non-minified dev environment " + - "for the full error message and additional helpful warnings." + var phasedRegistrationNames = dispatchConfig.phasedRegistrationNames; + if (phasedRegistrationNames) { + for (var phaseName in phasedRegistrationNames) { + if (phasedRegistrationNames.hasOwnProperty(phaseName)) { + var phasedRegistrationName = phasedRegistrationNames[phaseName]; + publishRegistrationName( + phasedRegistrationName, + pluginModule, + eventName + ); + } + } + return true; + } else if (dispatchConfig.registrationName) { + publishRegistrationName( + dispatchConfig.registrationName, + pluginModule, + eventName + ); + return true; + } + return false; +} + +/** + * Publishes a registration name that is used to identify dispatched events. + * + * @param {string} registrationName Registration name to add. + * @param {object} PluginModule Plugin publishing the event. + * @private + */ +function publishRegistrationName(registrationName, pluginModule, eventName) { + (function() { + if (!!registrationNameModules[registrationName]) { + throw ReactError( + "EventPluginHub: More than one plugin attempted to publish the same registration name, `" + + registrationName + + "`." ); - } else { - var args = [a, b, c, d, e, f]; - var argIndex = 0; - error = new Error( - format.replace(/%s/g, function() { - return args[argIndex++]; - }) + } + })(); + registrationNameModules[registrationName] = pluginModule; + registrationNameDependencies[registrationName] = + pluginModule.eventTypes[eventName].dependencies; + + { + var lowerCasedName = registrationName.toLowerCase(); + } +} + +/** + * Registers plugins so that they can extract and dispatch events. + * + * @see {EventPluginHub} + */ + +/** + * Ordered list of injected plugins. + */ +var plugins = []; + +/** + * Mapping from event name to dispatch config + */ +var eventNameDispatchConfigs = {}; + +/** + * Mapping from registration name to plugin module + */ +var registrationNameModules = {}; + +/** + * Mapping from registration name to event name + */ +var registrationNameDependencies = {}; + +/** + * Mapping from lowercase registration names to the properly cased version, + * used to warn in the case of missing event handlers. Available + * only in true. + * @type {Object} + */ + +// Trust the developer to only use possibleRegistrationNames in true + +/** + * Injects an ordering of plugins (by plugin name). This allows the ordering + * to be decoupled from injection of the actual plugins so that ordering is + * always deterministic regardless of packaging, on-the-fly injection, etc. + * + * @param {array} InjectedEventPluginOrder + * @internal + * @see {EventPluginHub.injection.injectEventPluginOrder} + */ +function injectEventPluginOrder(injectedEventPluginOrder) { + (function() { + if (!!eventPluginOrder) { + throw ReactError( + "EventPluginRegistry: Cannot inject event plugin ordering more than once. You are likely trying to load more than one copy of React." ); - error.name = "Invariant Violation"; } + })(); + // Clone the ordering so it cannot be dynamically mutated. + eventPluginOrder = Array.prototype.slice.call(injectedEventPluginOrder); + recomputePluginOrdering(); +} - error.framesToPop = 1; // we don't care about invariant's own frame - throw error; +/** + * Injects plugins to be used by `EventPluginHub`. The plugin names must be + * in the ordering injected by `injectEventPluginOrder`. + * + * Plugins can be injected as part of page initialization or on-the-fly. + * + * @param {object} injectedNamesToPlugins Map from names to plugin modules. + * @internal + * @see {EventPluginHub.injection.injectEventPluginsByName} + */ +function injectEventPluginsByName(injectedNamesToPlugins) { + var isOrderingDirty = false; + for (var pluginName in injectedNamesToPlugins) { + if (!injectedNamesToPlugins.hasOwnProperty(pluginName)) { + continue; + } + var pluginModule = injectedNamesToPlugins[pluginName]; + if ( + !namesToPlugins.hasOwnProperty(pluginName) || + namesToPlugins[pluginName] !== pluginModule + ) { + (function() { + if (!!namesToPlugins[pluginName]) { + throw ReactError( + "EventPluginRegistry: Cannot inject two different event plugins using the same name, `" + + pluginName + + "`." + ); + } + })(); + namesToPlugins[pluginName] = pluginModule; + isOrderingDirty = true; + } + } + if (isOrderingDirty) { + recomputePluginOrdering(); } } @@ -141,16 +349,13 @@ var invokeGuardedCallbackImpl = function( // when we call document.createEvent(). However this can cause confusing // errors: https://github.com/facebookincubator/create-react-app/issues/3482 // So we preemptively throw with a better message instead. - invariant( - typeof document !== "undefined", - "The `document` global was defined when React was initialized, but is not " + - "defined anymore. This can happen in a test environment if a component " + - "schedules an update from an asynchronous callback, but the test has already " + - "finished running. To solve this, you can either unmount the component at " + - "the end of your test (and ensure that any asynchronous operations get " + - "canceled in `componentWillUnmount`), or you can change the test itself " + - "to be asynchronous." - ); + (function() { + if (!(typeof document !== "undefined")) { + throw ReactError( + "The `document` global was defined when React was initialized, but is not defined anymore. This can happen in a test environment if a component schedules an update from an asynchronous callback, but the test has already finished running. To solve this, you can either unmount the component at the end of your test (and ensure that any asynchronous operations get canceled in `componentWillUnmount`), or you can change the test itself to be asynchronous." + ); + } + })(); var evt = document.createEvent("Event"); // Keeps track of whether the user-provided callback threw an error. We @@ -373,249 +578,41 @@ function clearCaughtError() { caughtError = null; return error; } else { - invariant( - false, - "clearCaughtError was called but no error was captured. This error " + - "is likely caused by a bug in React. Please file an issue." - ); + (function() { + { + throw ReactError( + "clearCaughtError was called but no error was captured. This error is likely caused by a bug in React. Please file an issue." + ); + } + })(); } } /** - * Injectable ordering of event plugins. + * Similar to invariant but only logs a warning if the condition is not met. + * This can be used to log issues in development environments in critical + * paths. Removing the logging code for production environments will keep the + * same logic and follow the same code paths. */ -var eventPluginOrder = null; -/** - * Injectable mapping from names to event plugin modules. - */ -var namesToPlugins = {}; +var warningWithoutStack = function() {}; -/** - * Recomputes the plugin list using the injected plugins and plugin ordering. - * - * @private - */ -function recomputePluginOrdering() { - if (!eventPluginOrder) { - // Wait until an `eventPluginOrder` is injected. - return; - } - for (var pluginName in namesToPlugins) { - var pluginModule = namesToPlugins[pluginName]; - var pluginIndex = eventPluginOrder.indexOf(pluginName); - invariant( - pluginIndex > -1, - "EventPluginRegistry: Cannot inject event plugins that do not exist in " + - "the plugin ordering, `%s`.", - pluginName - ); - if (plugins[pluginIndex]) { - continue; +{ + warningWithoutStack = function(condition, format) { + for ( + var _len = arguments.length, + args = Array(_len > 2 ? _len - 2 : 0), + _key = 2; + _key < _len; + _key++ + ) { + args[_key - 2] = arguments[_key]; } - invariant( - pluginModule.extractEvents, - "EventPluginRegistry: Event plugins must implement an `extractEvents` " + - "method, but `%s` does not.", - pluginName - ); - plugins[pluginIndex] = pluginModule; - var publishedEvents = pluginModule.eventTypes; - for (var eventName in publishedEvents) { - invariant( - publishEventForPlugin( - publishedEvents[eventName], - pluginModule, - eventName - ), - "EventPluginRegistry: Failed to publish event `%s` for plugin `%s`.", - eventName, - pluginName - ); - } - } -} - -/** - * Publishes an event so that it can be dispatched by the supplied plugin. - * - * @param {object} dispatchConfig Dispatch configuration for the event. - * @param {object} PluginModule Plugin publishing the event. - * @return {boolean} True if the event was successfully published. - * @private - */ -function publishEventForPlugin(dispatchConfig, pluginModule, eventName) { - invariant( - !eventNameDispatchConfigs.hasOwnProperty(eventName), - "EventPluginHub: More than one plugin attempted to publish the same " + - "event name, `%s`.", - eventName - ); - eventNameDispatchConfigs[eventName] = dispatchConfig; - - var phasedRegistrationNames = dispatchConfig.phasedRegistrationNames; - if (phasedRegistrationNames) { - for (var phaseName in phasedRegistrationNames) { - if (phasedRegistrationNames.hasOwnProperty(phaseName)) { - var phasedRegistrationName = phasedRegistrationNames[phaseName]; - publishRegistrationName( - phasedRegistrationName, - pluginModule, - eventName - ); - } - } - return true; - } else if (dispatchConfig.registrationName) { - publishRegistrationName( - dispatchConfig.registrationName, - pluginModule, - eventName - ); - return true; - } - return false; -} - -/** - * Publishes a registration name that is used to identify dispatched events. - * - * @param {string} registrationName Registration name to add. - * @param {object} PluginModule Plugin publishing the event. - * @private - */ -function publishRegistrationName(registrationName, pluginModule, eventName) { - invariant( - !registrationNameModules[registrationName], - "EventPluginHub: More than one plugin attempted to publish the same " + - "registration name, `%s`.", - registrationName - ); - registrationNameModules[registrationName] = pluginModule; - registrationNameDependencies[registrationName] = - pluginModule.eventTypes[eventName].dependencies; - - { - var lowerCasedName = registrationName.toLowerCase(); - } -} - -/** - * Registers plugins so that they can extract and dispatch events. - * - * @see {EventPluginHub} - */ - -/** - * Ordered list of injected plugins. - */ -var plugins = []; - -/** - * Mapping from event name to dispatch config - */ -var eventNameDispatchConfigs = {}; - -/** - * Mapping from registration name to plugin module - */ -var registrationNameModules = {}; - -/** - * Mapping from registration name to event name - */ -var registrationNameDependencies = {}; - -/** - * Mapping from lowercase registration names to the properly cased version, - * used to warn in the case of missing event handlers. Available - * only in true. - * @type {Object} - */ - -// Trust the developer to only use possibleRegistrationNames in true - -/** - * Injects an ordering of plugins (by plugin name). This allows the ordering - * to be decoupled from injection of the actual plugins so that ordering is - * always deterministic regardless of packaging, on-the-fly injection, etc. - * - * @param {array} InjectedEventPluginOrder - * @internal - * @see {EventPluginHub.injection.injectEventPluginOrder} - */ -function injectEventPluginOrder(injectedEventPluginOrder) { - invariant( - !eventPluginOrder, - "EventPluginRegistry: Cannot inject event plugin ordering more than " + - "once. You are likely trying to load more than one copy of React." - ); - // Clone the ordering so it cannot be dynamically mutated. - eventPluginOrder = Array.prototype.slice.call(injectedEventPluginOrder); - recomputePluginOrdering(); -} - -/** - * Injects plugins to be used by `EventPluginHub`. The plugin names must be - * in the ordering injected by `injectEventPluginOrder`. - * - * Plugins can be injected as part of page initialization or on-the-fly. - * - * @param {object} injectedNamesToPlugins Map from names to plugin modules. - * @internal - * @see {EventPluginHub.injection.injectEventPluginsByName} - */ -function injectEventPluginsByName(injectedNamesToPlugins) { - var isOrderingDirty = false; - for (var pluginName in injectedNamesToPlugins) { - if (!injectedNamesToPlugins.hasOwnProperty(pluginName)) { - continue; - } - var pluginModule = injectedNamesToPlugins[pluginName]; - if ( - !namesToPlugins.hasOwnProperty(pluginName) || - namesToPlugins[pluginName] !== pluginModule - ) { - invariant( - !namesToPlugins[pluginName], - "EventPluginRegistry: Cannot inject two different event plugins " + - "using the same name, `%s`.", - pluginName - ); - namesToPlugins[pluginName] = pluginModule; - isOrderingDirty = true; - } - } - if (isOrderingDirty) { - recomputePluginOrdering(); - } -} - -/** - * Similar to invariant but only logs a warning if the condition is not met. - * This can be used to log issues in development environments in critical - * paths. Removing the logging code for production environments will keep the - * same logic and follow the same code paths. - */ - -var warningWithoutStack = function() {}; - -{ - warningWithoutStack = function(condition, format) { - for ( - var _len = arguments.length, - args = Array(_len > 2 ? _len - 2 : 0), - _key = 2; - _key < _len; - _key++ - ) { - args[_key - 2] = arguments[_key]; - } - - if (format === undefined) { - throw new Error( - "`warningWithoutStack(condition, format, ...args)` requires a warning " + - "message argument" + + if (format === undefined) { + throw new Error( + "`warningWithoutStack(condition, format, ...args)` requires a warning " + + "message argument" ); } if (args.length > 8) { @@ -796,10 +793,11 @@ function executeDirectDispatch(event) { } var dispatchListener = event._dispatchListeners; var dispatchInstance = event._dispatchInstances; - invariant( - !Array.isArray(dispatchListener), - "executeDirectDispatch(...): Invalid `event`." - ); + (function() { + if (!!Array.isArray(dispatchListener)) { + throw ReactError("executeDirectDispatch(...): Invalid `event`."); + } + })(); event.currentTarget = dispatchListener ? getNodeFromInstance(dispatchInstance) : null; @@ -832,10 +830,13 @@ function hasDispatches(event) { */ function accumulateInto(current, next) { - invariant( - next != null, - "accumulateInto(...): Accumulated items must not be null or undefined." - ); + (function() { + if (!(next != null)) { + throw ReactError( + "accumulateInto(...): Accumulated items must not be null or undefined." + ); + } + })(); if (current == null) { return next; @@ -902,6 +903,32 @@ var executeDispatchesAndReleaseTopLevel = function(e) { return executeDispatchesAndRelease(e); }; +function runEventsInBatch(events) { + if (events !== null) { + eventQueue = accumulateInto(eventQueue, events); + } + + // Set `eventQueue` to null before processing it so that we can tell if more + // events get enqueued while processing. + var processingEventQueue = eventQueue; + eventQueue = null; + + if (!processingEventQueue) { + return; + } + + forEachAccumulated(processingEventQueue, executeDispatchesAndReleaseTopLevel); + (function() { + if (!!eventQueue) { + throw ReactError( + "processEventQueue(): Additional events were enqueued while processing an event queue. Support for this has not yet been implemented." + ); + } + })(); + // This would be a good time to rethrow if any of the event handlers threw. + rethrowCaughtError(); +} + function isInteractive(tag) { return ( tag === "button" || @@ -992,12 +1019,17 @@ function getListener(inst, registrationName) { if (shouldPreventMouseEvent(registrationName, inst.type, props)) { return null; } - invariant( - !listener || typeof listener === "function", - "Expected `%s` listener to be a function, instead got a value of `%s` type.", - registrationName, - typeof listener - ); + (function() { + if (!(!listener || typeof listener === "function")) { + throw ReactError( + "Expected `" + + registrationName + + "` listener to be a function, instead got a value of `" + + typeof listener + + "` type." + ); + } + })(); return listener; } @@ -1008,7 +1040,7 @@ function getListener(inst, registrationName) { * @return {*} An accumulation of synthetic events. * @internal */ -function extractEvents( +function extractPluginEvents( topLevelType, targetInst, nativeEvent, @@ -1033,37 +1065,13 @@ function extractEvents( return events; } -function runEventsInBatch(events) { - if (events !== null) { - eventQueue = accumulateInto(eventQueue, events); - } - - // Set `eventQueue` to null before processing it so that we can tell if more - // events get enqueued while processing. - var processingEventQueue = eventQueue; - eventQueue = null; - - if (!processingEventQueue) { - return; - } - - forEachAccumulated(processingEventQueue, executeDispatchesAndReleaseTopLevel); - invariant( - !eventQueue, - "processEventQueue(): Additional events were enqueued while processing " + - "an event queue. Support for this has not yet been implemented." - ); - // This would be a good time to rethrow if any of the event handlers threw. - rethrowCaughtError(); -} - -function runExtractedEventsInBatch( +function runExtractedPluginEventsInBatch( topLevelType, targetInst, nativeEvent, nativeEventTarget ) { - var events = extractEvents( + var events = extractPluginEvents( topLevelType, targetInst, nativeEvent, @@ -1090,6 +1098,9 @@ var MemoComponent = 14; var SimpleMemoComponent = 15; var LazyComponent = 16; var IncompleteClassComponent = 17; +var DehydratedSuspenseComponent = 18; +var EventComponent = 19; +var EventTarget = 20; function getParent(inst) { do { @@ -1608,10 +1619,13 @@ function getPooledEvent(dispatchConfig, targetInst, nativeEvent, nativeInst) { function releasePooledEvent(event) { var EventConstructor = this; - invariant( - event instanceof EventConstructor, - "Trying to release an event instance into a pool of a different type." - ); + (function() { + if (!(event instanceof EventConstructor)) { + throw ReactError( + "Trying to release an event instance into a pool of a different type." + ); + } + })(); event.destructor(); if (EventConstructor.eventPool.length < EVENT_POOL_SIZE) { EventConstructor.eventPool.push(event); @@ -1718,7 +1732,11 @@ function resetTouchRecord(touchRecord, touch) { function getTouchIdentifier(_ref) { var identifier = _ref.identifier; - invariant(identifier != null, "Touch object is missing identifier."); + (function() { + if (!(identifier != null)) { + throw ReactError("Touch object is missing identifier."); + } + })(); { !(identifier <= MAX_TOUCH_BANK) ? warningWithoutStack$1( @@ -1846,10 +1864,13 @@ var ResponderTouchHistoryStore = { * @return {*|array<*>} An accumulation of items. */ function accumulate(current, next) { - invariant( - next != null, - "accumulate(...): Accumulated items must be not be null or undefined." - ); + (function() { + if (!(next != null)) { + throw ReactError( + "accumulate(...): Accumulated items must be not be null or undefined." + ); + } + })(); if (current == null) { return next; @@ -2461,11 +2482,13 @@ var ReactNativeBridgeEventPlugin = { ReactNativeViewConfigRegistry.customBubblingEventTypes[topLevelType]; var directDispatchConfig = ReactNativeViewConfigRegistry.customDirectEventTypes[topLevelType]; - invariant( - bubbleDispatchConfig || directDispatchConfig, - 'Unsupported top level event type "%s" dispatched', - topLevelType - ); + (function() { + if (!(bubbleDispatchConfig || directDispatchConfig)) { + throw ReactError( + 'Unsupported top level event type "' + topLevelType + '" dispatched' + ); + } + })(); var event = SyntheticEvent.getPooled( bubbleDispatchConfig || directDispatchConfig, targetInst, @@ -2515,7 +2538,11 @@ function getInstanceFromInstance(instanceHandle) { function getTagFromInstance(inst) { var tag = inst.stateNode.canonical._nativeTag; - invariant(tag, "All native instances should have a tag."); + (function() { + if (!tag) { + throw ReactError("All native instances should have a tag."); + } + })(); return tag; } @@ -2604,6 +2631,17 @@ var REACT_FORWARD_REF_TYPE = hasSymbol var REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for("react.suspense") : 0xead1; var REACT_MEMO_TYPE = hasSymbol ? Symbol.for("react.memo") : 0xead3; var REACT_LAZY_TYPE = hasSymbol ? Symbol.for("react.lazy") : 0xead4; +var REACT_EVENT_COMPONENT_TYPE = hasSymbol + ? Symbol.for("react.event_component") + : 0xead5; +var REACT_EVENT_TARGET_TYPE = hasSymbol + ? Symbol.for("react.event_target") + : 0xead6; + +// React event targets +var REACT_EVENT_TARGET_TOUCH_HIT = hasSymbol + ? Symbol.for("react.event_target.touch_hit") + : 0xead7; var MAYBE_ITERATOR_SYMBOL = typeof Symbol === "function" && Symbol.iterator; var FAUX_ITERATOR_SYMBOL = "@@iterator"; @@ -2687,6 +2725,25 @@ function getComponentName(type) { if (resolvedThenable) { return getComponentName(resolvedThenable); } + break; + } + case REACT_EVENT_COMPONENT_TYPE: { + var eventComponent = type; + var displayName = eventComponent.displayName; + if (displayName !== undefined) { + return displayName; + } + break; + } + case REACT_EVENT_TARGET_TYPE: { + var eventTarget = type; + if (eventTarget.type === REACT_EVENT_TARGET_TOUCH_HIT) { + return "TouchHitTarget"; + } + var _displayName = eventTarget.displayName; + if (_displayName !== undefined) { + return _displayName; + } } } } @@ -2786,10 +2843,11 @@ function isMounted(component) { } function assertIsMounted(fiber) { - invariant( - isFiberMountedImpl(fiber) === MOUNTED, - "Unable to find node on an unmounted component." - ); + (function() { + if (!(isFiberMountedImpl(fiber) === MOUNTED)) { + throw ReactError("Unable to find node on an unmounted component."); + } + })(); } function findCurrentFiberUsingSlowPath(fiber) { @@ -2797,10 +2855,11 @@ function findCurrentFiberUsingSlowPath(fiber) { if (!alternate) { // If there is no alternate, then we only need to check if it is mounted. var state = isFiberMountedImpl(fiber); - invariant( - state !== UNMOUNTED, - "Unable to find node on an unmounted component." - ); + (function() { + if (!(state !== UNMOUNTED)) { + throw ReactError("Unable to find node on an unmounted component."); + } + })(); if (state === MOUNTING) { return null; } @@ -2813,11 +2872,24 @@ function findCurrentFiberUsingSlowPath(fiber) { var b = alternate; while (true) { var parentA = a.return; - var parentB = parentA ? parentA.alternate : null; - if (!parentA || !parentB) { + if (parentA === null) { // We're at the root. break; } + var parentB = parentA.alternate; + if (parentB === null) { + // There is no alternate. This is an unusual case. Currently, it only + // happens when a Suspense component is hidden. An extra fragment fiber + // is inserted in between the Suspense fiber and its children. Skip + // over this extra fragment fiber and proceed to the next parent. + var nextParent = parentA.return; + if (nextParent !== null) { + a = b = nextParent; + continue; + } + // If there's no parent, we're at the root. + break; + } // If both copies of the parent fiber point to the same child, we can // assume that the child is current. This happens when we bailout on low @@ -2839,7 +2911,11 @@ function findCurrentFiberUsingSlowPath(fiber) { } // We should never have an alternate for any mounting node. So the only // way this could possibly happen is if this was unmounted, if at all. - invariant(false, "Unable to find node on an unmounted component."); + (function() { + { + throw ReactError("Unable to find node on an unmounted component."); + } + })(); } if (a.return !== b.return) { @@ -2890,26 +2966,31 @@ function findCurrentFiberUsingSlowPath(fiber) { } _child = _child.sibling; } - invariant( - didFindChild, - "Child was not found in either parent set. This indicates a bug " + - "in React related to the return pointer. Please file an issue." - ); + (function() { + if (!didFindChild) { + throw ReactError( + "Child was not found in either parent set. This indicates a bug in React related to the return pointer. Please file an issue." + ); + } + })(); } } - invariant( - a.alternate === b, - "Return fibers should always be each others' alternates. " + - "This error is likely caused by a bug in React. Please file an issue." - ); - } + (function() { + if (!(a.alternate === b)) { + throw ReactError( + "Return fibers should always be each others' alternates. This error is likely caused by a bug in React. Please file an issue." + ); + } + })(); + } // If the root is not a host container, we're in a disconnected tree. I.e. // unmounted. - invariant( - a.tag === HostRoot, - "Unable to find node on an unmounted component." - ); + (function() { + if (!(a.tag === HostRoot)) { + throw ReactError("Unable to find node on an unmounted component."); + } + })(); if (a.stateNode.current === a) { // We've determined that A is the current branch. return fiber; @@ -3456,53 +3537,6 @@ function diff(prevProps, nextProps, validAttributes) { ); } -var hasNativePerformanceNow = - typeof performance === "object" && typeof performance.now === "function"; - -var now$1 = hasNativePerformanceNow - ? function() { - return performance.now(); - } - : function() { - return Date.now(); - }; - -var scheduledCallback = null; -var frameDeadline = 0; - -function setTimeoutCallback() { - // TODO (bvaughn) Hard-coded 5ms unblocks initial async testing. - // React API probably changing to boolean rather than time remaining. - // Longer-term plan is to rewrite this using shared memory, - // And just return the value of the bit as the boolean. - frameDeadline = now$1() + 5; - - var callback = scheduledCallback; - scheduledCallback = null; - if (callback !== null) { - callback(); - } -} - -// RN has a poor polyfill for requestIdleCallback so we aren't using it. -// This implementation is only intended for short-term use anyway. -// We also don't implement cancel functionality b'c Fiber doesn't currently need it. -function scheduleDeferredCallback$1(callback, options) { - // We assume only one callback is scheduled at a time b'c that's how Fiber works. - scheduledCallback = callback; - var timeoutId = setTimeout(setTimeoutCallback, 1); - return timeoutId; // Timeouts are always numbers on RN -} - -function cancelDeferredCallback$1(callbackID) { - scheduledCallback = null; - clearTimeout(callbackID); // Timeouts are always numbers on RN -} - -function shouldYield$1() { - return frameDeadline <= now$1(); -} - // Use to restore controlled state after a change event has fired. var restoreImpl = null; @@ -3517,11 +3551,13 @@ function restoreStateOfTarget(target) { // Unmounted return; } - invariant( - typeof restoreImpl === "function", - "setRestoreImplementation() needs to be called to handle a target for controlled " + - "events. This error is likely caused by a bug in React. Please file an issue." - ); + (function() { + if (!(typeof restoreImpl === "function")) { + throw ReactError( + "setRestoreImplementation() needs to be called to handle a target for controlled events. This error is likely caused by a bug in React. Please file an issue." + ); + } + })(); var props = getFiberCurrentPropsFromNode(internalInstance.stateNode); restoreImpl(internalInstance.stateNode, internalInstance.type, props); } @@ -3598,7 +3634,7 @@ function setBatchingImplementation( function dispatchEvent(target, topLevelType, nativeEvent) { var targetFiber = target; batchedUpdates(function() { - runExtractedEventsInBatch( + runExtractedPluginEventsInBatch( topLevelType, targetFiber, nativeEvent, @@ -3613,12 +3649,13 @@ function dispatchEvent(target, topLevelType, nativeEvent) { // can re-export everything from this module. function shim() { - invariant( - false, - "The current renderer does not support mutation. " + - "This error is likely caused by a bug in React. " + - "Please file an issue." - ); + (function() { + { + throw ReactError( + "The current renderer does not support mutation. This error is likely caused by a bug in React. Please file an issue." + ); + } + })(); } // Mutation (when unsupported) @@ -3642,30 +3679,41 @@ var unhideTextInstance = shim; // can re-export everything from this module. function shim$1() { - invariant( - false, - "The current renderer does not support hydration. " + - "This error is likely caused by a bug in React. " + - "Please file an issue." - ); + (function() { + { + throw ReactError( + "The current renderer does not support hydration. This error is likely caused by a bug in React. Please file an issue." + ); + } + })(); } // Hydration (when unsupported) + var supportsHydration = false; var canHydrateInstance = shim$1; var canHydrateTextInstance = shim$1; +var canHydrateSuspenseInstance = shim$1; +var isSuspenseInstancePending = shim$1; +var isSuspenseInstanceFallback = shim$1; +var registerSuspenseInstanceRetry = shim$1; var getNextHydratableSibling = shim$1; var getFirstHydratableChild = shim$1; var hydrateInstance = shim$1; var hydrateTextInstance = shim$1; +var getNextHydratableInstanceAfterSuspenseInstance = shim$1; +var clearSuspenseBoundary = shim$1; +var clearSuspenseBoundaryFromContainer = shim$1; var didNotMatchHydratedContainerTextInstance = shim$1; var didNotMatchHydratedTextInstance = shim$1; var didNotHydrateContainerInstance = shim$1; var didNotHydrateInstance = shim$1; var didNotFindHydratableContainerInstance = shim$1; var didNotFindHydratableContainerTextInstance = shim$1; +var didNotFindHydratableContainerSuspenseInstance = shim$1; var didNotFindHydratableInstance = shim$1; var didNotFindHydratableTextInstance = shim$1; +var didNotFindHydratableSuspenseInstance = shim$1; function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { @@ -3693,12 +3741,18 @@ if (FabricUIManager.registerEventHandler) { */ var ReactFabricHostComponent = (function() { - function ReactFabricHostComponent(tag, viewConfig, props) { + function ReactFabricHostComponent( + tag, + viewConfig, + props, + internalInstanceHandle + ) { _classCallCheck(this, ReactFabricHostComponent); this._nativeTag = tag; this.viewConfig = viewConfig; this.currentProps = props; + this._internalInstanceHandle = internalInstanceHandle; } ReactFabricHostComponent.prototype.blur = function blur() { @@ -3709,30 +3763,42 @@ var ReactFabricHostComponent = (function() { TextInputState.focusTextInput(this._nativeTag); }; - ReactFabricHostComponent.prototype.measure = function measure(callback) { - UIManager.measure( - this._nativeTag, + ReactFabricHostComponent.prototype.measure = function measure$$1(callback) { + FabricUIManager.measure( + this._internalInstanceHandle.stateNode.node, mountSafeCallback_NOT_REALLY_SAFE(this, callback) ); }; - ReactFabricHostComponent.prototype.measureInWindow = function measureInWindow( + ReactFabricHostComponent.prototype.measureInWindow = function measureInWindow$$1( callback ) { - UIManager.measureInWindow( - this._nativeTag, + FabricUIManager.measureInWindow( + this._internalInstanceHandle.stateNode.node, mountSafeCallback_NOT_REALLY_SAFE(this, callback) ); }; - ReactFabricHostComponent.prototype.measureLayout = function measureLayout( + ReactFabricHostComponent.prototype.measureLayout = function measureLayout$$1( relativeToNativeNode, onSuccess, onFail /* currently unused */ ) { - UIManager.measureLayout( - this._nativeTag, - relativeToNativeNode, + if ( + typeof relativeToNativeNode === "number" || + !(relativeToNativeNode instanceof ReactFabricHostComponent) + ) { + warningWithoutStack$1( + false, + "Warning: ref.measureLayout must be called with a ref to a native component." + ); + + return; + } + + FabricUIManager.measureLayout( + this._internalInstanceHandle.stateNode.node, + relativeToNativeNode._internalInstanceHandle.stateNode.node, mountSafeCallback_NOT_REALLY_SAFE(this, onFail), mountSafeCallback_NOT_REALLY_SAFE(this, onSuccess) ); @@ -3741,22 +3807,12 @@ var ReactFabricHostComponent = (function() { ReactFabricHostComponent.prototype.setNativeProps = function setNativeProps( nativeProps ) { - { - warnForStyleProps(nativeProps, this.viewConfig.validAttributes); - } - - var updatePayload = create(nativeProps, this.viewConfig.validAttributes); + warningWithoutStack$1( + false, + "Warning: setNativeProps is not currently supported in Fabric" + ); - // Avoid the overhead of bridge calls if there's no update. - // This is an expensive no-op for Android, and causes an unnecessary - // view invalidation for certain components (eg RCTTextInput) on iOS. - if (updatePayload != null) { - UIManager.updateView( - this._nativeTag, - this.viewConfig.uiViewClassName, - updatePayload - ); - } + return; }; return ReactFabricHostComponent; @@ -3786,10 +3842,13 @@ function createInstance( } } - invariant( - type !== "RCTView" || !hostContext.isInAParentText, - "Nesting of within is not currently supported." - ); + (function() { + if (!(type !== "RCTView" || !hostContext.isInAParentText)) { + throw ReactError( + "Nesting of within is not currently supported." + ); + } + })(); var updatePayload = create(props, viewConfig.validAttributes); @@ -3801,7 +3860,12 @@ function createInstance( internalInstanceHandle // internalInstanceHandle ); - var component = new ReactFabricHostComponent(tag, viewConfig, props); + var component = new ReactFabricHostComponent( + tag, + viewConfig, + props, + internalInstanceHandle + ); return { node: node, @@ -3815,10 +3879,13 @@ function createTextInstance( hostContext, internalInstanceHandle ) { - invariant( - hostContext.isInAParentText, - "Text strings must be rendered within a component." - ); + (function() { + if (!hostContext.isInAParentText) { + throw ReactError( + "Text strings must be rendered within a component." + ); + } + })(); var tag = nextReactTag; nextReactTag += 2; @@ -3866,6 +3933,16 @@ function getChildHostContext(parentHostContext, type, rootContainerInstance) { } } +function getChildHostContextForEventComponent(parentHostContext) { + // TODO: add getChildHostContextForEventComponent implementation + return parentHostContext; +} + +function getChildHostContextForEventTarget(parentHostContext, type) { + // TODO: add getChildHostContextForEventTarget implementation + return parentHostContext; +} + function getPublicInstance(instance) { return instance.canonical; } @@ -3911,16 +3988,10 @@ function shouldSetTextContent(type, props) { // The Fabric renderer is secondary to the existing React Native renderer. var isPrimaryRenderer = false; -var now$$1 = now$1; -var scheduleDeferredCallback$$1 = scheduleDeferredCallback$1; -var cancelDeferredCallback$$1 = cancelDeferredCallback$1; -var shouldYield$$1 = shouldYield$1; var scheduleTimeout = setTimeout; var cancelTimeout = clearTimeout; var noTimeout = -1; -var schedulePassiveEffects = scheduleDeferredCallback$$1; -var cancelPassiveEffects = cancelDeferredCallback$$1; // ------------------- // Persistence @@ -3975,26 +4046,7 @@ function cloneHiddenInstance(instance, type, props, internalInstanceHandle) { }; } -function cloneUnhiddenInstance(instance, type, props, internalInstanceHandle) { - var viewConfig = instance.canonical.viewConfig; - var node = instance.node; - var updatePayload = diff( - Object.assign({}, props, { style: [props.style, { display: "none" }] }), - props, - viewConfig.validAttributes - ); - return { - node: FabricUIManager.cloneNodeWithNewProps(node, updatePayload), - canonical: instance.canonical - }; -} - -function createHiddenTextInstance( - text, - rootContainerInstance, - hostContext, - internalInstanceHandle -) { +function cloneHiddenTextInstance(instance, text, internalInstanceHandle) { throw new Error("Not yet implemented."); } @@ -4010,6 +4062,35 @@ function finalizeContainerChildren(container, newChildren) { FabricUIManager.completeRoot(container, newChildren); } +function mountEventComponent(eventComponentInstance) { + throw new Error("Not yet implemented."); +} + +function updateEventComponent(eventComponentInstance) { + throw new Error("Not yet implemented."); +} + +function unmountEventComponent(eventComponentInstance) { + throw new Error("Not yet implemented."); +} + +function getEventTargetChildElement(type, props) { + throw new Error("Not yet implemented."); +} + +function handleEventTarget( + type, + props, + rootContainerInstance, + internalInstanceHandle +) { + throw new Error("Not yet implemented."); +} + +function commitEventTarget(type, props, instance, parentInstance) { + throw new Error("Not yet implemented."); +} + var BEFORE_SLASH_RE = /^(.*)[\\\/]/; var describeComponentFrame = function(name, source, ownerName) { @@ -4125,9 +4206,16 @@ var debugRenderPhaseSideEffects = false; var debugRenderPhaseSideEffectsForStrictMode = false; var enableUserTimingAPI = true; var replayFailedUnitOfWorkWithInvokeGuardedCallback = true; -var warnAboutDeprecatedLifecycles = false; +var warnAboutDeprecatedLifecycles = true; var enableProfilerTimer = true; var enableSchedulerTracing = true; +var enableSuspenseServerRenderer = false; + +var disableYielding = false; + +var warnAboutDeprecatedSetNativeProps = false; +var enableEventAPI = false; +var enableNewScheduler = false; // Only used in www builds. @@ -4402,7 +4490,8 @@ function stopFailedWorkTimer(fiber) { } fiber._debugIsCurrentlyTiming = false; var warning = - fiber.tag === SuspenseComponent + fiber.tag === SuspenseComponent || + fiber.tag === DehydratedSuspenseComponent ? "Rendering was suspended" : "An error was thrown inside this error boundary"; endFiberMark(fiber, null, warning); @@ -4765,11 +4854,13 @@ function popTopLevelContextObject(fiber) { } function pushTopLevelContextObject(fiber, context, didChange) { - invariant( - contextStackCursor.current === emptyContextObject, - "Unexpected context found on stack. " + - "This error is likely caused by a bug in React. Please file an issue." - ); + (function() { + if (!(contextStackCursor.current === emptyContextObject)) { + throw ReactError( + "Unexpected context found on stack. This error is likely caused by a bug in React. Please file an issue." + ); + } + })(); push(contextStackCursor, context, fiber); push(didPerformWorkStackCursor, didChange, fiber); @@ -4811,12 +4902,16 @@ function processChildContext(fiber, type, parentContext) { setCurrentPhase(null); } for (var contextKey in childContext) { - invariant( - contextKey in childContextTypes, - '%s.getChildContext(): key "%s" is not defined in childContextTypes.', - getComponentName(type) || "Unknown", - contextKey - ); + (function() { + if (!(contextKey in childContextTypes)) { + throw ReactError( + (getComponentName(type) || "Unknown") + + '.getChildContext(): key "' + + contextKey + + '" is not defined in childContextTypes.' + ); + } + })(); } { var name = getComponentName(type) || "Unknown"; @@ -4861,11 +4956,13 @@ function pushContextProvider(workInProgress) { function invalidateContextProvider(workInProgress, type, didChange) { var instance = workInProgress.stateNode; - invariant( - instance, - "Expected to have an instance by this point. " + - "This error is likely caused by a bug in React. Please file an issue." - ); + (function() { + if (!instance) { + throw ReactError( + "Expected to have an instance by this point. This error is likely caused by a bug in React. Please file an issue." + ); + } + })(); if (didChange) { // Merge parent and own context. @@ -4894,11 +4991,13 @@ function invalidateContextProvider(workInProgress, type, didChange) { function findCurrentUnmaskedContext(fiber) { // Currently this is only used with renderSubtreeIntoContainer; not sure if it // makes sense elsewhere - invariant( - isFiberMounted(fiber) && fiber.tag === ClassComponent, - "Expected subtree parent to be a mounted class component. " + - "This error is likely caused by a bug in React. Please file an issue." - ); + (function() { + if (!(isFiberMounted(fiber) && fiber.tag === ClassComponent)) { + throw ReactError( + "Expected subtree parent to be a mounted class component. This error is likely caused by a bug in React. Please file an issue." + ); + } + })(); var node = fiber; do { @@ -4915,11 +5014,13 @@ function findCurrentUnmaskedContext(fiber) { } node = node.return; } while (node !== null); - invariant( - false, - "Found unexpected detached subtree parent. " + - "This error is likely caused by a bug in React. Please file an issue." - ); + (function() { + { + throw ReactError( + "Found unexpected detached subtree parent. This error is likely caused by a bug in React. Please file an issue." + ); + } + })(); } var onCommitFiberRoot = null; @@ -5007,14 +5108,166 @@ function onCommitUnmount(fiber) { // Max 31 bit integer. The max integer size in V8 for 32-bit systems. // Math.pow(2, 30) - 1 // 0b111111111111111111111111111111 -var maxSigned31BitInt = 1073741823; +var MAX_SIGNED_31_BIT_INT = 1073741823; + +// Intentionally not named imports because Rollup would use dynamic dispatch for +// CommonJS interop named imports. +var Scheduler_runWithPriority = Scheduler.unstable_runWithPriority; +var Scheduler_scheduleCallback = Scheduler.unstable_scheduleCallback; +var Scheduler_cancelCallback = Scheduler.unstable_cancelCallback; +var Scheduler_shouldYield = Scheduler.unstable_shouldYield; +var Scheduler_now = Scheduler.unstable_now; +var Scheduler_getCurrentPriorityLevel = + Scheduler.unstable_getCurrentPriorityLevel; +var Scheduler_ImmediatePriority = Scheduler.unstable_ImmediatePriority; +var Scheduler_UserBlockingPriority = Scheduler.unstable_UserBlockingPriority; +var Scheduler_NormalPriority = Scheduler.unstable_NormalPriority; +var Scheduler_LowPriority = Scheduler.unstable_LowPriority; +var Scheduler_IdlePriority = Scheduler.unstable_IdlePriority; + +var fakeCallbackNode = {}; + +// Except for NoPriority, these correspond to Scheduler priorities. We use +// ascending numbers so we can compare them like numbers. They start at 90 to +// avoid clashing with Scheduler's priorities. +var ImmediatePriority = 99; +var UserBlockingPriority = 98; +var NormalPriority = 97; +var LowPriority = 96; +var IdlePriority = 95; +// NoPriority is the absence of priority. Also React-only. + +var now = Scheduler_now; +var shouldYield = disableYielding + ? function() { + return false; + } // Never yield when `disableYielding` is on + : Scheduler_shouldYield; + +var immediateQueue = null; +var immediateQueueCallbackNode = null; +var isFlushingImmediate = false; + +function getCurrentPriorityLevel() { + switch (Scheduler_getCurrentPriorityLevel()) { + case Scheduler_ImmediatePriority: + return ImmediatePriority; + case Scheduler_UserBlockingPriority: + return UserBlockingPriority; + case Scheduler_NormalPriority: + return NormalPriority; + case Scheduler_LowPriority: + return LowPriority; + case Scheduler_IdlePriority: + return IdlePriority; + default: + (function() { + { + throw ReactError("Unknown priority level."); + } + })(); + } +} + +function reactPriorityToSchedulerPriority(reactPriorityLevel) { + switch (reactPriorityLevel) { + case ImmediatePriority: + return Scheduler_ImmediatePriority; + case UserBlockingPriority: + return Scheduler_UserBlockingPriority; + case NormalPriority: + return Scheduler_NormalPriority; + case LowPriority: + return Scheduler_LowPriority; + case IdlePriority: + return Scheduler_IdlePriority; + default: + (function() { + { + throw ReactError("Unknown priority level."); + } + })(); + } +} + +function runWithPriority(reactPriorityLevel, fn) { + var priorityLevel = reactPriorityToSchedulerPriority(reactPriorityLevel); + return Scheduler_runWithPriority(priorityLevel, fn); +} + +function scheduleCallback(reactPriorityLevel, callback, options) { + if (reactPriorityLevel === ImmediatePriority) { + // Push this callback into an internal queue. We'll flush these either in + // the next tick, or earlier if something calls `flushImmediateQueue`. + if (immediateQueue === null) { + immediateQueue = [callback]; + // Flush the queue in the next tick, at the earliest. + immediateQueueCallbackNode = Scheduler_scheduleCallback( + Scheduler_ImmediatePriority, + flushImmediateQueueImpl + ); + } else { + // Push onto existing queue. Don't need to schedule a callback because + // we already scheduled one when we created the queue. + immediateQueue.push(callback); + } + return fakeCallbackNode; + } + // Otherwise pass through to Scheduler. + var priorityLevel = reactPriorityToSchedulerPriority(reactPriorityLevel); + return Scheduler_scheduleCallback(priorityLevel, callback, options); +} + +function cancelCallback(callbackNode) { + if (callbackNode !== fakeCallbackNode) { + Scheduler_cancelCallback(callbackNode); + } +} + +function flushImmediateQueue() { + if (immediateQueueCallbackNode !== null) { + Scheduler_cancelCallback(immediateQueueCallbackNode); + } + flushImmediateQueueImpl(); +} + +function flushImmediateQueueImpl() { + if (!isFlushingImmediate && immediateQueue !== null) { + // Prevent re-entrancy. + isFlushingImmediate = true; + var i = 0; + try { + var _isSync = true; + for (; i < immediateQueue.length; i++) { + var callback = immediateQueue[i]; + do { + callback = callback(_isSync); + } while (callback !== null); + } + immediateQueue = null; + } catch (error) { + // If something throws, leave the remaining callbacks on the queue. + if (immediateQueue !== null) { + immediateQueue = immediateQueue.slice(i + 1); + } + // Resume flushing in the next tick + Scheduler_scheduleCallback( + Scheduler_ImmediatePriority, + flushImmediateQueue + ); + throw error; + } finally { + isFlushingImmediate = false; + } + } +} var NoWork = 0; var Never = 1; -var Sync = maxSigned31BitInt; +var Sync = MAX_SIGNED_31_BIT_INT; var UNIT_SIZE = 10; -var MAGIC_NUMBER_OFFSET = maxSigned31BitInt - 1; +var MAGIC_NUMBER_OFFSET = MAX_SIGNED_31_BIT_INT - 1; // 1 unit of expiration time represents 10ms. function msToExpirationTime(ms) { @@ -5040,6 +5293,8 @@ function computeExpirationBucket(currentTime, expirationInMs, bucketSizeMs) { ); } +// TODO: This corresponds to Scheduler's NormalPriority, not LowPriority. Update +// the names to reflect. var LOW_PRIORITY_EXPIRATION = 5000; var LOW_PRIORITY_BATCH_SIZE = 250; @@ -5051,6 +5306,12 @@ function computeAsyncExpiration(currentTime) { ); } +// Same as computeAsyncExpiration but without the bucketing logic. This is +// used to compute timestamps instead of actual expiration times. +function computeAsyncExpirationNoBucket(currentTime) { + return currentTime - LOW_PRIORITY_EXPIRATION / UNIT_SIZE; +} + // We intentionally set a higher expiration time for interactive updates in // dev than in production. // @@ -5073,6 +5334,31 @@ function computeInteractiveExpiration(currentTime) { ); } +function inferPriorityFromExpirationTime(currentTime, expirationTime) { + if (expirationTime === Sync) { + return ImmediatePriority; + } + if (expirationTime === Never) { + return IdlePriority; + } + var msUntil = + msToExpirationTime(expirationTime) - msToExpirationTime(currentTime); + if (msUntil <= 0) { + return ImmediatePriority; + } + if (msUntil <= HIGH_PRIORITY_EXPIRATION) { + return UserBlockingPriority; + } + if (msUntil <= LOW_PRIORITY_EXPIRATION) { + return NormalPriority; + } + + // TODO: Handle LowPriority + + // Assume anything lower has idle priority + return IdlePriority; +} + var NoContext = 0; var ConcurrentMode = 1; var StrictMode = 2; @@ -5174,6 +5460,7 @@ function FiberNode(tag, pendingProps, key, mode) { this._debugSource = null; this._debugOwner = null; this._debugIsCurrentlyTiming = false; + this._debugHookTypes = null; if (!hasBadMapPolyfill && typeof Object.preventExtensions === "function") { Object.preventExtensions(this); } @@ -5250,6 +5537,7 @@ function createWorkInProgress(current, pendingProps, expirationTime) { workInProgress._debugID = current._debugID; workInProgress._debugSource = current._debugSource; workInProgress._debugOwner = current._debugOwner; + workInProgress._debugHookTypes = current._debugHookTypes; } workInProgress.alternate = current; @@ -5377,6 +5665,28 @@ function createFiberFromTypeAndProps( fiberTag = LazyComponent; resolvedType = null; break getTag; + case REACT_EVENT_COMPONENT_TYPE: + if (enableEventAPI) { + return createFiberFromEventComponent( + type, + pendingProps, + mode, + expirationTime, + key + ); + } + break; + case REACT_EVENT_TARGET_TYPE: + if (enableEventAPI) { + return createFiberFromEventTarget( + type, + pendingProps, + mode, + expirationTime, + key + ); + } + break; } } var info = ""; @@ -5397,14 +5707,16 @@ function createFiberFromTypeAndProps( info += "\n\nCheck the render method of `" + ownerName + "`."; } } - invariant( - false, - "Element type is invalid: expected a string (for built-in " + - "components) or a class/function (for composite components) " + - "but got: %s.%s", - type == null ? type : typeof type, - info - ); + (function() { + { + throw ReactError( + "Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: " + + (type == null ? type : typeof type) + + "." + + info + ); + } + })(); } } } @@ -5446,6 +5758,34 @@ function createFiberFromFragment(elements, mode, expirationTime, key) { return fiber; } +function createFiberFromEventComponent( + eventComponent, + pendingProps, + mode, + expirationTime, + key +) { + var fiber = createFiber(EventComponent, pendingProps, key, mode); + fiber.elementType = eventComponent; + fiber.type = eventComponent; + fiber.expirationTime = expirationTime; + return fiber; +} + +function createFiberFromEventTarget( + eventTarget, + pendingProps, + mode, + expirationTime, + key +) { + var fiber = createFiber(EventTarget, pendingProps, key, mode); + fiber.elementType = eventTarget; + fiber.type = eventTarget; + fiber.expirationTime = expirationTime; + return fiber; +} + function createFiberFromProfiler(pendingProps, mode, expirationTime, key) { { if ( @@ -5568,6 +5908,7 @@ function assignFiberPropertiesInDEV(target, source) { target._debugSource = source._debugSource; target._debugOwner = source._debugOwner; target._debugIsCurrentlyTiming = source._debugIsCurrentlyTiming; + target._debugHookTypes = source._debugHookTypes; return target; } @@ -5584,78 +5925,53 @@ function assignFiberPropertiesInDEV(target, source) { // The types are defined separately within this file to ensure they stay in sync. // (We don't have to use an inline :any cast when enableSchedulerTracing is disabled.) -function createFiberRoot(containerInfo, isConcurrent, hydrate) { - // Cyclic construction. This cheats the type system right now because - // stateNode is any. - var uninitializedFiber = createHostRootFiber(isConcurrent); +function FiberRootNode(containerInfo, hydrate) { + this.current = null; + this.containerInfo = containerInfo; + this.pendingChildren = null; + this.pingCache = null; + this.pendingCommitExpirationTime = NoWork; + this.finishedWork = null; + this.timeoutHandle = noTimeout; + this.context = null; + this.pendingContext = null; + this.hydrate = hydrate; + this.firstBatch = null; + + if (enableNewScheduler) { + this.callbackNode = null; + this.callbackExpirationTime = NoWork; + this.firstPendingTime = NoWork; + this.lastPendingTime = NoWork; + this.pingTime = NoWork; + } else { + this.earliestPendingTime = NoWork; + this.latestPendingTime = NoWork; + this.earliestSuspendedTime = NoWork; + this.latestSuspendedTime = NoWork; + this.latestPingedTime = NoWork; + this.didError = false; + this.nextExpirationTimeToWorkOn = NoWork; + this.expirationTime = NoWork; + this.nextScheduledRoot = null; + } - var root = void 0; if (enableSchedulerTracing) { - root = { - current: uninitializedFiber, - containerInfo: containerInfo, - pendingChildren: null, - - earliestPendingTime: NoWork, - latestPendingTime: NoWork, - earliestSuspendedTime: NoWork, - latestSuspendedTime: NoWork, - latestPingedTime: NoWork, - - pingCache: null, - - didError: false, - - pendingCommitExpirationTime: NoWork, - finishedWork: null, - timeoutHandle: noTimeout, - context: null, - pendingContext: null, - hydrate: hydrate, - nextExpirationTimeToWorkOn: NoWork, - expirationTime: NoWork, - firstBatch: null, - nextScheduledRoot: null, - - interactionThreadID: tracing.unstable_getThreadID(), - memoizedInteractions: new Set(), - pendingInteractionMap: new Map() - }; - } else { - root = { - current: uninitializedFiber, - containerInfo: containerInfo, - pendingChildren: null, - - pingCache: null, - - earliestPendingTime: NoWork, - latestPendingTime: NoWork, - earliestSuspendedTime: NoWork, - latestSuspendedTime: NoWork, - latestPingedTime: NoWork, - - didError: false, - - pendingCommitExpirationTime: NoWork, - finishedWork: null, - timeoutHandle: noTimeout, - context: null, - pendingContext: null, - hydrate: hydrate, - nextExpirationTimeToWorkOn: NoWork, - expirationTime: NoWork, - firstBatch: null, - nextScheduledRoot: null - }; + this.interactionThreadID = tracing.unstable_getThreadID(); + this.memoizedInteractions = new Set(); + this.pendingInteractionMap = new Map(); } +} + +function createFiberRoot(containerInfo, isConcurrent, hydrate) { + var root = new FiberRootNode(containerInfo, hydrate); + // Cyclic construction. This cheats the type system right now because + // stateNode is any. + var uninitializedFiber = createHostRootFiber(isConcurrent); + root.current = uninitializedFiber; uninitializedFiber.stateNode = root; - // The reason for the way the Flow types are structured in this file, - // Is to avoid needing :any casts everywhere interaction tracing fields are used. - // Unfortunately that requires an :any cast for non-interaction tracing capable builds. - // $FlowFixMe Remove this :any cast and replace it with something better. return root; } @@ -6058,19 +6374,56 @@ var ReactStrictModeWarnings = { }; } -// This lets us hook into Fiber to debug what it's doing. -// See https://github.com/facebook/react/pull/8033. -// This is not part of the public API, not even for React DevTools. -// You may only inject a debugTool if you work on React Fiber itself. -var ReactFiberInstrumentation = { - debugTool: null -}; +/** + * Similar to invariant but only logs a warning if the condition is not met. + * This can be used to log issues in development environments in critical + * paths. Removing the logging code for production environments will keep the + * same logic and follow the same code paths. + */ -var ReactFiberInstrumentation_1 = ReactFiberInstrumentation; +var warning = warningWithoutStack$1; -// TODO: Offscreen updates should never suspend. However, a promise that -// suspended inside an offscreen subtree should be able to ping at the priority -// of the outer render. +{ + warning = function(condition, format) { + if (condition) { + return; + } + var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame; + var stack = ReactDebugCurrentFrame.getStackAddendum(); + // eslint-disable-next-line react-internal/warning-and-invariant-args + + for ( + var _len = arguments.length, + args = Array(_len > 2 ? _len - 2 : 0), + _key = 2; + _key < _len; + _key++ + ) { + args[_key - 2] = arguments[_key]; + } + + warningWithoutStack$1.apply( + undefined, + [false, format + "%s"].concat(args, [stack]) + ); + }; +} + +var warning$1 = warning; + +// This lets us hook into Fiber to debug what it's doing. +// See https://github.com/facebook/react/pull/8033. +// This is not part of the public API, not even for React DevTools. +// You may only inject a debugTool if you work on React Fiber itself. +var ReactFiberInstrumentation = { + debugTool: null +}; + +var ReactFiberInstrumentation_1 = ReactFiberInstrumentation; + +// TODO: Offscreen updates should never suspend. However, a promise that +// suspended inside an offscreen subtree should be able to ping at the priority +// of the outer render. function markPendingPriorityLevel(root, expirationTime) { // If there's a gap between completing a failed root and retrying it, @@ -6257,20 +6610,6 @@ function clearPing(root, completedTime) { } } -function findEarliestOutstandingPriorityLevel(root, renderExpirationTime) { - var earliestExpirationTime = renderExpirationTime; - - var earliestPendingTime = root.earliestPendingTime; - var earliestSuspendedTime = root.earliestSuspendedTime; - if (earliestPendingTime > earliestExpirationTime) { - earliestExpirationTime = earliestPendingTime; - } - if (earliestSuspendedTime > earliestExpirationTime) { - earliestExpirationTime = earliestSuspendedTime; - } - return earliestExpirationTime; -} - function didExpireAtExpirationTime(root, currentTime) { var expirationTime = root.expirationTime; if (expirationTime !== NoWork && currentTime <= expirationTime) { @@ -6313,43 +6652,6 @@ function findNextExpirationTimeToWorkOn(completedExpirationTime, root) { root.expirationTime = expirationTime; } -/** - * Similar to invariant but only logs a warning if the condition is not met. - * This can be used to log issues in development environments in critical - * paths. Removing the logging code for production environments will keep the - * same logic and follow the same code paths. - */ - -var warning = warningWithoutStack$1; - -{ - warning = function(condition, format) { - if (condition) { - return; - } - var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame; - var stack = ReactDebugCurrentFrame.getStackAddendum(); - // eslint-disable-next-line react-internal/warning-and-invariant-args - - for ( - var _len = arguments.length, - args = Array(_len > 2 ? _len - 2 : 0), - _key = 2; - _key < _len; - _key++ - ) { - args[_key - 2] = arguments[_key]; - } - - warningWithoutStack$1.apply( - undefined, - [false, format + "%s"].concat(args, [stack]) - ); - }; -} - -var warning$1 = warning; - /** * 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 @@ -6545,15 +6847,13 @@ var didWarnAboutInvalidateContextType = void 0; Object.defineProperty(fakeInternalInstance, "_processChildContext", { enumerable: false, value: function() { - invariant( - false, - "_processChildContext is not available in React 16+. This likely " + - "means you have multiple copies of React and are attempting to nest " + - "a React 15 tree inside a React 16 tree using " + - "unstable_renderSubtreeIntoContainer, which isn't supported. Try " + - "to make sure you have only one copy of React (and ideally, switch " + - "to ReactDOM.createPortal)." - ); + (function() { + { + throw ReactError( + "_processChildContext is not available in React 16+. This likely means you have multiple copies of React and are attempting to nest a React 15 tree inside a React 16 tree using unstable_renderSubtreeIntoContainer, which isn't supported. Try to make sure you have only one copy of React (and ideally, switch to ReactDOM.createPortal)." + ); + } + })(); } }); Object.freeze(fakeInternalInstance); @@ -6602,8 +6902,8 @@ var classComponentUpdater = { isMounted: isMounted, enqueueSetState: function(inst, payload, callback) { var fiber = get$1(inst); - var currentTime = requestCurrentTime(); - var expirationTime = computeExpirationForFiber(currentTime, fiber); + var currentTime = requestCurrentTime$$1(); + var expirationTime = computeExpirationForFiber$$1(currentTime, fiber); var update = createUpdate(expirationTime); update.payload = payload; @@ -6614,14 +6914,14 @@ var classComponentUpdater = { update.callback = callback; } - flushPassiveEffects(); + flushPassiveEffects$$1(); enqueueUpdate(fiber, update); - scheduleWork(fiber, expirationTime); + scheduleWork$$1(fiber, expirationTime); }, enqueueReplaceState: function(inst, payload, callback) { var fiber = get$1(inst); - var currentTime = requestCurrentTime(); - var expirationTime = computeExpirationForFiber(currentTime, fiber); + var currentTime = requestCurrentTime$$1(); + var expirationTime = computeExpirationForFiber$$1(currentTime, fiber); var update = createUpdate(expirationTime); update.tag = ReplaceState; @@ -6634,14 +6934,14 @@ var classComponentUpdater = { update.callback = callback; } - flushPassiveEffects(); + flushPassiveEffects$$1(); enqueueUpdate(fiber, update); - scheduleWork(fiber, expirationTime); + scheduleWork$$1(fiber, expirationTime); }, enqueueForceUpdate: function(inst, callback) { var fiber = get$1(inst); - var currentTime = requestCurrentTime(); - var expirationTime = computeExpirationForFiber(currentTime, fiber); + var currentTime = requestCurrentTime$$1(); + var expirationTime = computeExpirationForFiber$$1(currentTime, fiber); var update = createUpdate(expirationTime); update.tag = ForceUpdate; @@ -6653,9 +6953,9 @@ var classComponentUpdater = { update.callback = callback; } - flushPassiveEffects(); + flushPassiveEffects$$1(); enqueueUpdate(fiber, update); - scheduleWork(fiber, expirationTime); + scheduleWork$$1(fiber, expirationTime); } }; @@ -6967,23 +7267,51 @@ function constructClassInstance( var unmaskedContext = emptyContextObject; var context = null; var contextType = ctor.contextType; - if (typeof contextType === "object" && contextType !== null) { - { - if ( - contextType.$$typeof !== REACT_CONTEXT_TYPE && - !didWarnAboutInvalidateContextType.has(ctor) - ) { + + { + if ("contextType" in ctor) { + var isValid = + // Allow null for conditional declaration + contextType === null || + (contextType !== undefined && + contextType.$$typeof === REACT_CONTEXT_TYPE && + contextType._context === undefined); // Not a + + if (!isValid && !didWarnAboutInvalidateContextType.has(ctor)) { didWarnAboutInvalidateContextType.add(ctor); + + var addendum = ""; + if (contextType === undefined) { + addendum = + " However, it is set to undefined. " + + "This can be caused by a typo or by mixing up named and default imports. " + + "This can also happen due to a circular dependency, so " + + "try moving the createContext() call to a separate file."; + } else if (typeof contextType !== "object") { + addendum = " However, it is set to a " + typeof contextType + "."; + } else if (contextType.$$typeof === REACT_PROVIDER_TYPE) { + addendum = " Did you accidentally pass the Context.Provider instead?"; + } else if (contextType._context !== undefined) { + // + addendum = " Did you accidentally pass the Context.Consumer instead?"; + } else { + addendum = + " However, it is set to an object with keys {" + + Object.keys(contextType).join(", ") + + "}."; + } warningWithoutStack$1( false, "%s defines an invalid contextType. " + - "contextType should point to the Context object returned by React.createContext(). " + - "Did you accidentally pass the Context.Provider instead?", - getComponentName(ctor) || "Component" + "contextType should point to the Context object returned by React.createContext().%s", + getComponentName(ctor) || "Component", + addendum ); } } + } + if (typeof contextType === "object" && contextType !== null) { context = readContext(contextType); } else { unmaskedContext = getUnmaskedContext(workInProgress, ctor, true); @@ -7625,11 +7953,13 @@ var warnForMissingKey = function(child) {}; if (!child._store || child._store.validated || child.key != null) { return; } - invariant( - typeof child._store === "object", - "React Component in warnForMissingKey should have a _store. " + - "This error is likely caused by a bug in React. Please file an issue." - ); + (function() { + if (!(typeof child._store === "object")) { + throw ReactError( + "React Component in warnForMissingKey should have a _store. This error is likely caused by a bug in React. Please file an issue." + ); + } + })(); child._store.validated = true; var currentComponentErrorInfo = @@ -7685,19 +8015,24 @@ function coerceRef(returnFiber, current$$1, element) { var inst = void 0; if (owner) { var ownerFiber = owner; - invariant( - ownerFiber.tag === ClassComponent, - "Function components cannot have refs. " + - "Did you mean to use React.forwardRef()?" - ); + (function() { + if (!(ownerFiber.tag === ClassComponent)) { + throw ReactError( + "Function components cannot have refs. Did you mean to use React.forwardRef()?" + ); + } + })(); inst = ownerFiber.stateNode; } - invariant( - inst, - "Missing owner for string ref %s. This error is likely caused by a " + - "bug in React. Please file an issue.", - mixedRef - ); + (function() { + if (!inst) { + throw ReactError( + "Missing owner for string ref " + + mixedRef + + ". This error is likely caused by a bug in React. Please file an issue." + ); + } + })(); var stringRef = "" + mixedRef; // Check if previous string ref matches new string ref if ( @@ -7723,20 +8058,22 @@ function coerceRef(returnFiber, current$$1, element) { ref._stringRef = stringRef; return ref; } else { - invariant( - typeof mixedRef === "string", - "Expected ref to be a function, a string, an object returned by React.createRef(), or null." - ); - invariant( - element._owner, - "Element ref was specified as a string (%s) 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://fb.me/react-refs-must-have-owner for more information.", - mixedRef - ); + (function() { + if (!(typeof mixedRef === "string")) { + throw ReactError( + "Expected ref to be a function, a string, an object returned by React.createRef(), or null." + ); + } + })(); + (function() { + if (!element._owner) { + throw ReactError( + "Element ref was specified as a string (" + + mixedRef + + ") but no owner was set. This could happen for one of the following reasons:\n1. You may be adding a ref to a function component\n2. You may be adding a ref to a component that was not created inside a component's render method\n3. You have multiple copies of React loaded\nSee https://fb.me/react-refs-must-have-owner for more information." + ); + } + })(); } } return mixedRef; @@ -7751,14 +8088,18 @@ function throwOnInvalidObjectType(returnFiber, newChild) { "instead." + getCurrentFiberStackInDev(); } - invariant( - false, - "Objects are not valid as a React child (found: %s).%s", - Object.prototype.toString.call(newChild) === "[object Object]" - ? "object with keys {" + Object.keys(newChild).join(", ") + "}" - : newChild, - addendum - ); + (function() { + { + throw ReactError( + "Objects are not valid as a React child (found: " + + (Object.prototype.toString.call(newChild) === "[object Object]" + ? "object with keys {" + Object.keys(newChild).join(", ") + "}" + : newChild) + + ")." + + addendum + ); + } + })(); } } @@ -8417,11 +8758,13 @@ function ChildReconciler(shouldTrackSideEffects) { // but using the iterator instead. var iteratorFn = getIteratorFn(newChildrenIterable); - invariant( - typeof iteratorFn === "function", - "An object is not an iterable. This error is likely caused by a bug in " + - "React. Please file an issue." - ); + (function() { + if (!(typeof iteratorFn === "function")) { + throw ReactError( + "An object is not an iterable. This error is likely caused by a bug in React. Please file an issue." + ); + } + })(); { // We don't support rendering Generators because it's a mutation. @@ -8471,7 +8814,11 @@ function ChildReconciler(shouldTrackSideEffects) { } var newChildren = iteratorFn.call(newChildrenIterable); - invariant(newChildren != null, "An iterable object provided no iterator."); + (function() { + if (!(newChildren != null)) { + throw ReactError("An iterable object provided no iterator."); + } + })(); var resultingFirstChild = null; var previousNewFiber = null; @@ -8842,13 +9189,14 @@ function ChildReconciler(shouldTrackSideEffects) { // eslint-disable-next-lined no-fallthrough case FunctionComponent: { var Component = returnFiber.type; - invariant( - false, - "%s(...): Nothing was returned from render. This usually means a " + - "return statement is missing. Or, to render nothing, " + - "return null.", - Component.displayName || Component.name || "Component" - ); + (function() { + { + throw ReactError( + (Component.displayName || Component.name || "Component") + + "(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null." + ); + } + })(); } } } @@ -8864,10 +9212,11 @@ var reconcileChildFibers = ChildReconciler(true); var mountChildFibers = ChildReconciler(false); function cloneChildFibers(current$$1, workInProgress) { - invariant( - current$$1 === null || workInProgress.child === current$$1.child, - "Resuming work not yet implemented." - ); + (function() { + if (!(current$$1 === null || workInProgress.child === current$$1.child)) { + throw ReactError("Resuming work not yet implemented."); + } + })(); if (workInProgress.child === null) { return; @@ -8901,11 +9250,13 @@ var contextFiberStackCursor = createCursor(NO_CONTEXT); var rootInstanceStackCursor = createCursor(NO_CONTEXT); function requiredContext(c) { - invariant( - c !== NO_CONTEXT, - "Expected host context to exist. This error is likely caused by a bug " + - "in React. Please file an issue." - ); + (function() { + if (!(c !== NO_CONTEXT)) { + throw ReactError( + "Expected host context to exist. This error is likely caused by a bug in React. Please file an issue." + ); + } + })(); return c; } @@ -8961,6 +9312,37 @@ function pushHostContext(fiber) { push(contextStackCursor$1, nextContext, fiber); } +function pushHostContextForEventComponent(fiber) { + var context = requiredContext(contextStackCursor$1.current); + var nextContext = getChildHostContextForEventComponent(context); + + // Don't push this Fiber's context unless it's unique. + if (context === nextContext) { + return; + } + + // Track the context and the Fiber that provided it. + // This enables us to pop only Fibers that provide unique contexts. + push(contextFiberStackCursor, fiber, fiber); + push(contextStackCursor$1, nextContext, fiber); +} + +function pushHostContextForEventTarget(fiber) { + var context = requiredContext(contextStackCursor$1.current); + var eventTargetType = fiber.type.type; + var nextContext = getChildHostContextForEventTarget(context, eventTargetType); + + // Don't push this Fiber's context unless it's unique. + if (context === nextContext) { + return; + } + + // Track the context and the Fiber that provided it. + // This enables us to pop only Fibers that provide unique contexts. + push(contextFiberStackCursor, fiber, fiber); + push(contextStackCursor$1, nextContext, fiber); +} + function popHostContext(fiber) { // Do not pop unless this Fiber provided the current context. // pushHostContext() only pushes Fibers that provide unique contexts. @@ -8998,7 +9380,6 @@ var currentlyRenderingFiber$1 = null; // current hook list is the list that belongs to the current fiber. The // work-in-progress hook list is a new list that will be added to the // work-in-progress fiber. -var firstCurrentHook = null; var currentHook = null; var nextCurrentHook = null; var firstWorkInProgressHook = null; @@ -9028,60 +9409,107 @@ var RE_RENDER_LIMIT = 25; // In DEV, this is the name of the currently executing primitive hook var currentHookNameInDev = null; -function warnOnHookMismatchInDev() { +// In DEV, this list ensures that hooks are called in the same order between renders. +// The list stores the order of hooks used during the initial render (mount). +// Subsequent renders (updates) reference this list. +var hookTypesDev = null; +var hookTypesUpdateIndexDev = -1; + +function mountHookTypesDev() { + { + var hookName = currentHookNameInDev; + + if (hookTypesDev === null) { + hookTypesDev = [hookName]; + } else { + hookTypesDev.push(hookName); + } + } +} + +function updateHookTypesDev() { + { + var hookName = currentHookNameInDev; + + if (hookTypesDev !== null) { + hookTypesUpdateIndexDev++; + if (hookTypesDev[hookTypesUpdateIndexDev] !== hookName) { + warnOnHookMismatchInDev(hookName); + } + } + } +} + +function checkDepsAreArrayDev(deps) { + { + if (deps !== undefined && deps !== null && !Array.isArray(deps)) { + // Verify deps, but only on mount to avoid extra checks. + // It's unlikely their type would change as usually you define them inline. + warning$1( + false, + "%s received a final argument that is not an array (instead, received `%s`). When " + + "specified, the final argument must be an array.", + currentHookNameInDev, + typeof deps + ); + } + } +} + +function warnOnHookMismatchInDev(currentHookName) { { var componentName = getComponentName(currentlyRenderingFiber$1.type); if (!didWarnAboutMismatchedHooksForComponent.has(componentName)) { didWarnAboutMismatchedHooksForComponent.add(componentName); - var secondColumnStart = 22; + if (hookTypesDev !== null) { + var table = ""; - var table = ""; - var prevHook = firstCurrentHook; - var nextHook = firstWorkInProgressHook; - var n = 1; - while (prevHook !== null && nextHook !== null) { - var oldHookName = prevHook._debugType; - var newHookName = nextHook._debugType; + var secondColumnStart = 30; - var row = n + ". " + oldHookName; + for (var i = 0; i <= hookTypesUpdateIndexDev; i++) { + var oldHookName = hookTypesDev[i]; + var newHookName = + i === hookTypesUpdateIndexDev ? currentHookName : oldHookName; - // Extra space so second column lines up - // lol @ IE not supporting String#repeat - while (row.length < secondColumnStart) { - row += " "; - } + var row = i + 1 + ". " + oldHookName; - row += newHookName + "\n"; + // Extra space so second column lines up + // lol @ IE not supporting String#repeat + while (row.length < secondColumnStart) { + row += " "; + } - table += row; - prevHook = prevHook.next; - nextHook = nextHook.next; - n++; - } + row += newHookName + "\n"; - warning$1( - false, - "React has detected a change in the order of Hooks called by %s. " + - "This will lead to bugs and errors if not fixed. " + - "For more information, read the Rules of Hooks: https://fb.me/rules-of-hooks\n\n" + - " Previous render Next render\n" + - " -------------------------------\n" + - "%s" + - " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", - componentName, - table - ); + table += row; + } + + warning$1( + false, + "React has detected a change in the order of Hooks called by %s. " + + "This will lead to bugs and errors if not fixed. " + + "For more information, read the Rules of Hooks: https://fb.me/rules-of-hooks\n\n" + + " Previous render Next render\n" + + " ------------------------------------------------------\n" + + "%s" + + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", + componentName, + table + ); + } } } } function throwInvalidHookError() { - invariant( - false, - "Hooks can only be called inside the body of a function component. " + - "(https://fb.me/react-invalid-hook-call)" - ); + (function() { + { + throw ReactError( + "Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:\n1. You might have mismatching versions of React and the renderer (such as React DOM)\n2. You might be breaking the Rules of Hooks\n3. You might have more than one copy of React in the same app\nSee https://fb.me/react-invalid-hook-call for tips about how to debug and fix this problem." + ); + } + })(); } function areHookInputsEqual(nextDeps, prevDeps) { @@ -9109,8 +9537,8 @@ function areHookInputsEqual(nextDeps, prevDeps) { "Previous: %s\n" + "Incoming: %s", currentHookNameInDev, - "[" + nextDeps.join(", ") + "]", - "[" + prevDeps.join(", ") + "]" + "[" + prevDeps.join(", ") + "]", + "[" + nextDeps.join(", ") + "]" ); } } @@ -9133,8 +9561,12 @@ function renderWithHooks( ) { renderExpirationTime = nextRenderExpirationTime; currentlyRenderingFiber$1 = workInProgress; - firstCurrentHook = nextCurrentHook = - current !== null ? current.memoizedState : null; + nextCurrentHook = current !== null ? current.memoizedState : null; + + { + hookTypesDev = current !== null ? current._debugHookTypes : null; + hookTypesUpdateIndexDev = -1; + } // The following should have already been reset // currentHook = null; @@ -9148,11 +9580,26 @@ function renderWithHooks( // numberOfReRenders = 0; // sideEffectTag = 0; + // TODO Warn if no hooks are used at all during mount, then some are used during update. + // Currently we will identify the update render as a mount because nextCurrentHook === null. + // This is tricky because it's valid for certain types of components (e.g. React.lazy) + + // Using nextCurrentHook to differentiate between mount/update only works if at least one stateful hook is used. + // Non-stateful hooks (e.g. context) don't get added to memoizedState, + // so nextCurrentHook would be null during updates and mounts. { - ReactCurrentDispatcher$1.current = - nextCurrentHook === null - ? HooksDispatcherOnMountInDEV - : HooksDispatcherOnUpdateInDEV; + if (nextCurrentHook !== null) { + ReactCurrentDispatcher$1.current = HooksDispatcherOnUpdateInDEV; + } else if (hookTypesDev !== null) { + // This dispatcher handles an edge case where a component is updating, + // but no stateful hooks have been used. + // We want to match the production code behavior (which will use HooksDispatcherOnMount), + // but with the extra DEV validation to ensure hooks ordering hasn't changed. + // This dispatcher does that. + ReactCurrentDispatcher$1.current = HooksDispatcherOnMountWithHookTypesInDEV; + } else { + ReactCurrentDispatcher$1.current = HooksDispatcherOnMountInDEV; + } } var children = Component(props, refOrContext); @@ -9163,14 +9610,18 @@ function renderWithHooks( numberOfReRenders += 1; // Start over from the beginning of the list - firstCurrentHook = nextCurrentHook = - current !== null ? current.memoizedState : null; + nextCurrentHook = current !== null ? current.memoizedState : null; nextWorkInProgressHook = firstWorkInProgressHook; currentHook = null; workInProgressHook = null; componentUpdateQueue = null; + { + // Also validate hook order for cascading updates. + hookTypesUpdateIndexDev = -1; + } + ReactCurrentDispatcher$1.current = HooksDispatcherOnUpdateInDEV; children = Component(props, refOrContext); @@ -9180,10 +9631,6 @@ function renderWithHooks( numberOfReRenders = 0; } - { - currentHookNameInDev = null; - } - // We can assume the previous dispatcher is always this one, since we set it // at the beginning of the render phase and there's no re-entrancy. ReactCurrentDispatcher$1.current = ContextOnlyDispatcher; @@ -9195,18 +9642,29 @@ function renderWithHooks( renderedWork.updateQueue = componentUpdateQueue; renderedWork.effectTag |= sideEffectTag; + { + renderedWork._debugHookTypes = hookTypesDev; + } + + // This check uses currentHook so that it works the same in DEV and prod bundles. + // hookTypesDev could catch more cases (e.g. context) but only in DEV bundles. var didRenderTooFewHooks = currentHook !== null && currentHook.next !== null; renderExpirationTime = NoWork; currentlyRenderingFiber$1 = null; - firstCurrentHook = null; currentHook = null; nextCurrentHook = null; firstWorkInProgressHook = null; workInProgressHook = null; nextWorkInProgressHook = null; + { + currentHookNameInDev = null; + hookTypesDev = null; + hookTypesUpdateIndexDev = -1; + } + remainingExpirationTime = NoWork; componentUpdateQueue = null; sideEffectTag = 0; @@ -9216,11 +9674,13 @@ function renderWithHooks( // renderPhaseUpdates = null; // numberOfReRenders = 0; - invariant( - !didRenderTooFewHooks, - "Rendered fewer hooks than expected. This may be caused by an accidental " + - "early return statement." - ); + (function() { + if (!!didRenderTooFewHooks) { + throw ReactError( + "Rendered fewer hooks than expected. This may be caused by an accidental early return statement." + ); + } + })(); return children; } @@ -9244,21 +9704,23 @@ function resetHooks() { renderExpirationTime = NoWork; currentlyRenderingFiber$1 = null; - firstCurrentHook = null; currentHook = null; nextCurrentHook = null; firstWorkInProgressHook = null; workInProgressHook = null; nextWorkInProgressHook = null; - remainingExpirationTime = NoWork; - componentUpdateQueue = null; - sideEffectTag = 0; - { + hookTypesDev = null; + hookTypesUpdateIndexDev = -1; + currentHookNameInDev = null; } + remainingExpirationTime = NoWork; + componentUpdateQueue = null; + sideEffectTag = 0; + didScheduleRenderPhaseUpdate = false; renderPhaseUpdates = null; numberOfReRenders = 0; @@ -9275,20 +9737,6 @@ function mountWorkInProgressHook() { next: null }; - { - hook._debugType = currentHookNameInDev; - if ( - currentlyRenderingFiber$1 !== null && - currentlyRenderingFiber$1.alternate !== null - ) { - warning$1( - false, - "%s: Rendered more hooks than during the previous render. This is " + - "not currently supported and may lead to unexpected behavior.", - getComponentName(currentlyRenderingFiber$1.type) - ); - } - } if (workInProgressHook === null) { // This is the first hook in the list firstWorkInProgressHook = workInProgressHook = hook; @@ -9314,10 +9762,13 @@ function updateWorkInProgressHook() { nextCurrentHook = currentHook !== null ? currentHook.next : null; } else { // Clone from the current hook. - invariant( - nextCurrentHook !== null, - "Rendered more hooks than during the previous render." - ); + (function() { + if (!(nextCurrentHook !== null)) { + throw ReactError( + "Rendered more hooks than during the previous render." + ); + } + })(); currentHook = nextCurrentHook; var newHook = { @@ -9338,13 +9789,6 @@ function updateWorkInProgressHook() { workInProgressHook = workInProgressHook.next = newHook; } nextCurrentHook = currentHook.next; - - { - newHook._debugType = currentHookNameInDev; - if (currentHookNameInDev !== currentHook._debugType) { - warnOnHookMismatchInDev(); - } - } } return workInProgressHook; } @@ -9359,20 +9803,6 @@ function basicStateReducer(state, action) { return typeof action === "function" ? action(state) : action; } -function mountContext(context, observedBits) { - { - mountWorkInProgressHook(); - } - return readContext(context, observedBits); -} - -function updateContext(context, observedBits) { - { - updateWorkInProgressHook(); - } - return readContext(context, observedBits); -} - function mountReducer(reducer, initialArg, init) { var hook = mountWorkInProgressHook(); var initialState = void 0; @@ -9385,8 +9815,8 @@ function mountReducer(reducer, initialArg, init) { var queue = (hook.queue = { last: null, dispatch: null, - eagerReducer: reducer, - eagerState: initialState + lastRenderedReducer: reducer, + lastRenderedState: initialState }); var dispatch = (queue.dispatch = dispatchAction.bind( null, @@ -9400,10 +9830,15 @@ function mountReducer(reducer, initialArg, init) { function updateReducer(reducer, initialArg, init) { var hook = updateWorkInProgressHook(); var queue = hook.queue; - invariant( - queue !== null, - "Should have a queue. This is likely a bug in React. Please file an issue." - ); + (function() { + if (!(queue !== null)) { + throw ReactError( + "Should have a queue. This is likely a bug in React. Please file an issue." + ); + } + })(); + + queue.lastRenderedReducer = reducer; if (numberOfReRenders > 0) { // This is a re-render. Apply the new render phase updates to the previous @@ -9431,7 +9866,6 @@ function updateReducer(reducer, initialArg, init) { } hook.memoizedState = newState; - // Don't persist the state accumlated from the render phase updates to // the base state unless the queue is empty. // TODO: Not sure if this is the desired semantics, but it's what we @@ -9440,6 +9874,8 @@ function updateReducer(reducer, initialArg, init) { hook.baseState = newState; } + queue.lastRenderedState = newState; + return [newState, _dispatch]; } } @@ -9488,6 +9924,16 @@ function updateReducer(reducer, initialArg, init) { remainingExpirationTime = updateExpirationTime; } } else { + // This update does have sufficient priority. + + // Mark the event time of this update as relevant to this render pass. + // TODO: This should ideally use the true event time of this update rather than + // its priority which is a derived and not reverseable value. + // TODO: We should skip this update if it was already committed but currently + // we have no way of detecting the difference between a committed and suspended + // update here. + markRenderEventTime$$1(updateExpirationTime); + // Process this update. if (_update.eagerReducer === reducer) { // If this update was processed eagerly, and its reducer matches the @@ -9517,8 +9963,7 @@ function updateReducer(reducer, initialArg, init) { hook.baseUpdate = newBaseUpdate; hook.baseState = newBaseState; - queue.eagerReducer = reducer; - queue.eagerState = _newState; + queue.lastRenderedState = _newState; } var dispatch = queue.dispatch; @@ -9534,8 +9979,8 @@ function mountState(initialState) { var queue = (hook.queue = { last: null, dispatch: null, - eagerReducer: basicStateReducer, - eagerState: initialState + lastRenderedReducer: basicStateReducer, + lastRenderedState: initialState }); var dispatch = (queue.dispatch = dispatchAction.bind( null, @@ -9778,25 +10223,14 @@ function updateMemo(nextCreate, deps) { return nextValue; } -// in a test-like environment, we want to warn if dispatchAction() -// is called outside of a batchedUpdates/TestUtils.act(...) call. -var shouldWarnForUnbatchedSetState = false; - -{ - // jest isn't a 'global', it's just exposed to tests via a wrapped function - // further, this isn't a test file, so flow doesn't recognize the symbol. So... - // $FlowExpectedError - because requirements don't give a damn about your type sigs. - if ("undefined" !== typeof jest) { - shouldWarnForUnbatchedSetState = true; - } -} - function dispatchAction(fiber, queue, action) { - invariant( - numberOfReRenders < RE_RENDER_LIMIT, - "Too many re-renders. React limits the number of renders to prevent " + - "an infinite loop." - ); + (function() { + if (!(numberOfReRenders < RE_RENDER_LIMIT)) { + throw ReactError( + "Too many re-renders. React limits the number of renders to prevent an infinite loop." + ); + } + })(); { !(arguments.length <= 3) @@ -9840,10 +10274,10 @@ function dispatchAction(fiber, queue, action) { lastRenderPhaseUpdate.next = update; } } else { - flushPassiveEffects(); + flushPassiveEffects$$1(); - var currentTime = requestCurrentTime(); - var _expirationTime = computeExpirationForFiber(currentTime, fiber); + var currentTime = requestCurrentTime$$1(); + var _expirationTime = computeExpirationForFiber$$1(currentTime, fiber); var _update2 = { expirationTime: _expirationTime, @@ -9875,21 +10309,21 @@ function dispatchAction(fiber, queue, action) { // The queue is currently empty, which means we can eagerly compute the // next state before entering the render phase. If the new state is the // same as the current state, we may be able to bail out entirely. - var _eagerReducer = queue.eagerReducer; - if (_eagerReducer !== null) { + var _lastRenderedReducer = queue.lastRenderedReducer; + if (_lastRenderedReducer !== null) { var prevDispatcher = void 0; { prevDispatcher = ReactCurrentDispatcher$1.current; ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV; } try { - var currentState = queue.eagerState; - var _eagerState = _eagerReducer(currentState, action); + var currentState = queue.lastRenderedState; + var _eagerState = _lastRenderedReducer(currentState, action); // Stash the eagerly computed state, and the reducer used to compute // it, on the update object. If the reducer hasn't changed by the // time we enter the render phase, then the eager state can be used // without calling the reducer again. - _update2.eagerReducer = _eagerReducer; + _update2.eagerReducer = _lastRenderedReducer; _update2.eagerState = _eagerState; if (is(_eagerState, currentState)) { // Fast path. We can bail out without scheduling React to re-render. @@ -9908,11 +10342,14 @@ function dispatchAction(fiber, queue, action) { } } { - if (shouldWarnForUnbatchedSetState === true) { - warnIfNotCurrentlyBatchingInDev(fiber); + // jest isn't a 'global', it's just exposed to tests via a wrapped function + // further, this isn't a test file, so flow doesn't recognize the symbol. So... + // $FlowExpectedError - because requirements don't give a damn about your type sigs. + if ("undefined" !== typeof jest) { + warnIfNotCurrentlyActingUpdatesInDev$$1(fiber); } } - scheduleWork(fiber, _expirationTime); + scheduleWork$$1(fiber, _expirationTime); } } @@ -9932,6 +10369,7 @@ var ContextOnlyDispatcher = { }; var HooksDispatcherOnMountInDEV = null; +var HooksDispatcherOnMountWithHookTypesInDEV = null; var HooksDispatcherOnUpdateInDEV = null; var InvalidNestedHooksDispatcherOnMountInDEV = null; var InvalidNestedHooksDispatcherOnUpdateInDEV = null; @@ -9963,26 +10401,111 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null; }, useCallback: function(callback, deps) { currentHookNameInDev = "useCallback"; + mountHookTypesDev(); + checkDepsAreArrayDev(deps); + return mountCallback(callback, deps); + }, + useContext: function(context, observedBits) { + currentHookNameInDev = "useContext"; + mountHookTypesDev(); + return readContext(context, observedBits); + }, + useEffect: function(create, deps) { + currentHookNameInDev = "useEffect"; + mountHookTypesDev(); + checkDepsAreArrayDev(deps); + return mountEffect(create, deps); + }, + useImperativeHandle: function(ref, create, deps) { + currentHookNameInDev = "useImperativeHandle"; + mountHookTypesDev(); + checkDepsAreArrayDev(deps); + return mountImperativeHandle(ref, create, deps); + }, + useLayoutEffect: function(create, deps) { + currentHookNameInDev = "useLayoutEffect"; + mountHookTypesDev(); + checkDepsAreArrayDev(deps); + return mountLayoutEffect(create, deps); + }, + useMemo: function(create, deps) { + currentHookNameInDev = "useMemo"; + mountHookTypesDev(); + checkDepsAreArrayDev(deps); + var prevDispatcher = ReactCurrentDispatcher$1.current; + ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV; + try { + return mountMemo(create, deps); + } finally { + ReactCurrentDispatcher$1.current = prevDispatcher; + } + }, + useReducer: function(reducer, initialArg, init) { + currentHookNameInDev = "useReducer"; + mountHookTypesDev(); + var prevDispatcher = ReactCurrentDispatcher$1.current; + ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV; + try { + return mountReducer(reducer, initialArg, init); + } finally { + ReactCurrentDispatcher$1.current = prevDispatcher; + } + }, + useRef: function(initialValue) { + currentHookNameInDev = "useRef"; + mountHookTypesDev(); + return mountRef(initialValue); + }, + useState: function(initialState) { + currentHookNameInDev = "useState"; + mountHookTypesDev(); + var prevDispatcher = ReactCurrentDispatcher$1.current; + ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV; + try { + return mountState(initialState); + } finally { + ReactCurrentDispatcher$1.current = prevDispatcher; + } + }, + useDebugValue: function(value, formatterFn) { + currentHookNameInDev = "useDebugValue"; + mountHookTypesDev(); + return mountDebugValue(value, formatterFn); + } + }; + + HooksDispatcherOnMountWithHookTypesInDEV = { + readContext: function(context, observedBits) { + return readContext(context, observedBits); + }, + useCallback: function(callback, deps) { + currentHookNameInDev = "useCallback"; + updateHookTypesDev(); return mountCallback(callback, deps); }, useContext: function(context, observedBits) { currentHookNameInDev = "useContext"; - return mountContext(context, observedBits); + updateHookTypesDev(); + return readContext(context, observedBits); }, useEffect: function(create, deps) { currentHookNameInDev = "useEffect"; + updateHookTypesDev(); return mountEffect(create, deps); }, useImperativeHandle: function(ref, create, deps) { currentHookNameInDev = "useImperativeHandle"; + updateHookTypesDev(); return mountImperativeHandle(ref, create, deps); }, useLayoutEffect: function(create, deps) { currentHookNameInDev = "useLayoutEffect"; + updateHookTypesDev(); return mountLayoutEffect(create, deps); }, useMemo: function(create, deps) { currentHookNameInDev = "useMemo"; + updateHookTypesDev(); var prevDispatcher = ReactCurrentDispatcher$1.current; ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV; try { @@ -9993,6 +10516,7 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null; }, useReducer: function(reducer, initialArg, init) { currentHookNameInDev = "useReducer"; + updateHookTypesDev(); var prevDispatcher = ReactCurrentDispatcher$1.current; ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV; try { @@ -10003,10 +10527,12 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null; }, useRef: function(initialValue) { currentHookNameInDev = "useRef"; + updateHookTypesDev(); return mountRef(initialValue); }, useState: function(initialState) { currentHookNameInDev = "useState"; + updateHookTypesDev(); var prevDispatcher = ReactCurrentDispatcher$1.current; ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV; try { @@ -10017,6 +10543,7 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null; }, useDebugValue: function(value, formatterFn) { currentHookNameInDev = "useDebugValue"; + updateHookTypesDev(); return mountDebugValue(value, formatterFn); } }; @@ -10027,26 +10554,32 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null; }, useCallback: function(callback, deps) { currentHookNameInDev = "useCallback"; + updateHookTypesDev(); return updateCallback(callback, deps); }, useContext: function(context, observedBits) { currentHookNameInDev = "useContext"; - return updateContext(context, observedBits); + updateHookTypesDev(); + return readContext(context, observedBits); }, useEffect: function(create, deps) { currentHookNameInDev = "useEffect"; + updateHookTypesDev(); return updateEffect(create, deps); }, useImperativeHandle: function(ref, create, deps) { currentHookNameInDev = "useImperativeHandle"; + updateHookTypesDev(); return updateImperativeHandle(ref, create, deps); }, useLayoutEffect: function(create, deps) { currentHookNameInDev = "useLayoutEffect"; + updateHookTypesDev(); return updateLayoutEffect(create, deps); }, useMemo: function(create, deps) { currentHookNameInDev = "useMemo"; + updateHookTypesDev(); var prevDispatcher = ReactCurrentDispatcher$1.current; ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV; try { @@ -10057,6 +10590,7 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null; }, useReducer: function(reducer, initialArg, init) { currentHookNameInDev = "useReducer"; + updateHookTypesDev(); var prevDispatcher = ReactCurrentDispatcher$1.current; ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV; try { @@ -10067,10 +10601,12 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null; }, useRef: function(initialValue) { currentHookNameInDev = "useRef"; + updateHookTypesDev(); return updateRef(initialValue); }, useState: function(initialState) { currentHookNameInDev = "useState"; + updateHookTypesDev(); var prevDispatcher = ReactCurrentDispatcher$1.current; ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV; try { @@ -10081,6 +10617,7 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null; }, useDebugValue: function(value, formatterFn) { currentHookNameInDev = "useDebugValue"; + updateHookTypesDev(); return updateDebugValue(value, formatterFn); } }; @@ -10093,31 +10630,37 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null; useCallback: function(callback, deps) { currentHookNameInDev = "useCallback"; warnInvalidHookAccess(); + mountHookTypesDev(); return mountCallback(callback, deps); }, useContext: function(context, observedBits) { currentHookNameInDev = "useContext"; warnInvalidHookAccess(); - return mountContext(context, observedBits); + mountHookTypesDev(); + return readContext(context, observedBits); }, useEffect: function(create, deps) { currentHookNameInDev = "useEffect"; warnInvalidHookAccess(); + mountHookTypesDev(); return mountEffect(create, deps); }, useImperativeHandle: function(ref, create, deps) { currentHookNameInDev = "useImperativeHandle"; warnInvalidHookAccess(); + mountHookTypesDev(); return mountImperativeHandle(ref, create, deps); }, useLayoutEffect: function(create, deps) { currentHookNameInDev = "useLayoutEffect"; warnInvalidHookAccess(); + mountHookTypesDev(); return mountLayoutEffect(create, deps); }, useMemo: function(create, deps) { currentHookNameInDev = "useMemo"; warnInvalidHookAccess(); + mountHookTypesDev(); var prevDispatcher = ReactCurrentDispatcher$1.current; ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV; try { @@ -10129,6 +10672,7 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null; useReducer: function(reducer, initialArg, init) { currentHookNameInDev = "useReducer"; warnInvalidHookAccess(); + mountHookTypesDev(); var prevDispatcher = ReactCurrentDispatcher$1.current; ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV; try { @@ -10140,11 +10684,13 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null; useRef: function(initialValue) { currentHookNameInDev = "useRef"; warnInvalidHookAccess(); + mountHookTypesDev(); return mountRef(initialValue); }, useState: function(initialState) { currentHookNameInDev = "useState"; warnInvalidHookAccess(); + mountHookTypesDev(); var prevDispatcher = ReactCurrentDispatcher$1.current; ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV; try { @@ -10156,6 +10702,7 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null; useDebugValue: function(value, formatterFn) { currentHookNameInDev = "useDebugValue"; warnInvalidHookAccess(); + mountHookTypesDev(); return mountDebugValue(value, formatterFn); } }; @@ -10168,31 +10715,37 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null; useCallback: function(callback, deps) { currentHookNameInDev = "useCallback"; warnInvalidHookAccess(); + updateHookTypesDev(); return updateCallback(callback, deps); }, useContext: function(context, observedBits) { currentHookNameInDev = "useContext"; warnInvalidHookAccess(); - return updateContext(context, observedBits); + updateHookTypesDev(); + return readContext(context, observedBits); }, useEffect: function(create, deps) { currentHookNameInDev = "useEffect"; warnInvalidHookAccess(); + updateHookTypesDev(); return updateEffect(create, deps); }, useImperativeHandle: function(ref, create, deps) { currentHookNameInDev = "useImperativeHandle"; warnInvalidHookAccess(); + updateHookTypesDev(); return updateImperativeHandle(ref, create, deps); }, useLayoutEffect: function(create, deps) { currentHookNameInDev = "useLayoutEffect"; warnInvalidHookAccess(); + updateHookTypesDev(); return updateLayoutEffect(create, deps); }, useMemo: function(create, deps) { currentHookNameInDev = "useMemo"; warnInvalidHookAccess(); + updateHookTypesDev(); var prevDispatcher = ReactCurrentDispatcher$1.current; ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV; try { @@ -10204,6 +10757,7 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null; useReducer: function(reducer, initialArg, init) { currentHookNameInDev = "useReducer"; warnInvalidHookAccess(); + updateHookTypesDev(); var prevDispatcher = ReactCurrentDispatcher$1.current; ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV; try { @@ -10215,11 +10769,13 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null; useRef: function(initialValue) { currentHookNameInDev = "useRef"; warnInvalidHookAccess(); + updateHookTypesDev(); return updateRef(initialValue); }, useState: function(initialState) { currentHookNameInDev = "useState"; warnInvalidHookAccess(); + updateHookTypesDev(); var prevDispatcher = ReactCurrentDispatcher$1.current; ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV; try { @@ -10231,11 +10787,16 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null; useDebugValue: function(value, formatterFn) { currentHookNameInDev = "useDebugValue"; warnInvalidHookAccess(); + updateHookTypesDev(); return updateDebugValue(value, formatterFn); } }; } +// Intentionally not named imports because Rollup would use dynamic dispatch for +// CommonJS interop named imports. +var now$2 = Scheduler.unstable_now; + var commitTime = 0; var profilerStartTime = -1; @@ -10247,7 +10808,7 @@ function recordCommitTime() { if (!enableProfilerTimer) { return; } - commitTime = now$$1(); + commitTime = now$2(); } function startProfilerTimer(fiber) { @@ -10255,10 +10816,10 @@ function startProfilerTimer(fiber) { return; } - profilerStartTime = now$$1(); + profilerStartTime = now$2(); if (fiber.actualStartTime < 0) { - fiber.actualStartTime = now$$1(); + fiber.actualStartTime = now$2(); } } @@ -10275,7 +10836,7 @@ function stopProfilerTimerIfRunningAndRecordDelta(fiber, overrideBaseTime) { } if (profilerStartTime >= 0) { - var elapsedTime = now$$1() - profilerStartTime; + var elapsedTime = now$2() - profilerStartTime; fiber.actualDuration += elapsedTime; if (overrideBaseTime) { fiber.selfBaseDuration = elapsedTime; @@ -10302,6 +10863,18 @@ function enterHydrationState(fiber) { return true; } +function reenterHydrationStateFromDehydratedSuspenseInstance(fiber) { + if (!supportsHydration) { + return false; + } + + var suspenseInstance = fiber.stateNode; + nextHydratableInstance = getNextHydratableSibling(suspenseInstance); + popToNextHostParent(fiber); + isHydrating = true; + return true; +} + function deleteHydratableInstance(returnFiber, instance) { { switch (returnFiber.tag) { @@ -10356,6 +10929,9 @@ function insertNonHydratedInstance(returnFiber, fiber) { var text = fiber.pendingProps; didNotFindHydratableContainerTextInstance(parentContainer, text); break; + case SuspenseComponent: + didNotFindHydratableContainerSuspenseInstance(parentContainer); + break; } break; } @@ -10384,6 +10960,13 @@ function insertNonHydratedInstance(returnFiber, fiber) { _text ); break; + case SuspenseComponent: + didNotFindHydratableSuspenseInstance( + parentType, + parentProps, + parentInstance + ); + break; } break; } @@ -10414,6 +10997,18 @@ function tryHydrate(fiber, nextInstance) { } return false; } + case SuspenseComponent: { + if (enableSuspenseServerRenderer) { + var suspenseInstance = canHydrateSuspenseInstance(nextInstance); + if (suspenseInstance !== null) { + // Downgrade the tag to a dehydrated component until we've hydrated it. + fiber.tag = DehydratedSuspenseComponent; + fiber.stateNode = suspenseInstance; + return true; + } + } + return false; + } default: return false; } @@ -10460,11 +11055,13 @@ function prepareToHydrateHostInstance( hostContext ) { if (!supportsHydration) { - invariant( - false, - "Expected prepareToHydrateHostInstance() to never be called. " + - "This error is likely caused by a bug in React. Please file an issue." - ); + (function() { + { + throw ReactError( + "Expected prepareToHydrateHostInstance() to never be called. This error is likely caused by a bug in React. Please file an issue." + ); + } + })(); } var instance = fiber.stateNode; @@ -10488,11 +11085,13 @@ function prepareToHydrateHostInstance( function prepareToHydrateHostTextInstance(fiber) { if (!supportsHydration) { - invariant( - false, - "Expected prepareToHydrateHostTextInstance() to never be called. " + - "This error is likely caused by a bug in React. Please file an issue." - ); + (function() { + { + throw ReactError( + "Expected prepareToHydrateHostTextInstance() to never be called. This error is likely caused by a bug in React. Please file an issue." + ); + } + })(); } var textInstance = fiber.stateNode; @@ -10534,12 +11133,36 @@ function prepareToHydrateHostTextInstance(fiber) { return shouldUpdate; } +function skipPastDehydratedSuspenseInstance(fiber) { + if (!supportsHydration) { + (function() { + { + throw ReactError( + "Expected skipPastDehydratedSuspenseInstance() to never be called. This error is likely caused by a bug in React. Please file an issue." + ); + } + })(); + } + var suspenseInstance = fiber.stateNode; + (function() { + if (!suspenseInstance) { + throw ReactError( + "Expected to have a hydrated suspense instance. This error is likely caused by a bug in React. Please file an issue." + ); + } + })(); + nextHydratableInstance = getNextHydratableInstanceAfterSuspenseInstance( + suspenseInstance + ); +} + function popToNextHostParent(fiber) { var parent = fiber.return; while ( parent !== null && parent.tag !== HostComponent && - parent.tag !== HostRoot + parent.tag !== HostRoot && + parent.tag !== DehydratedSuspenseComponent ) { parent = parent.return; } @@ -10606,17 +11229,21 @@ var ReactCurrentOwner$3 = ReactSharedInternals.ReactCurrentOwner; var didReceiveUpdate = false; var didWarnAboutBadClass = void 0; +var didWarnAboutModulePatternComponent = void 0; var didWarnAboutContextTypeOnFunctionComponent = void 0; var didWarnAboutGetDerivedStateOnFunctionComponent = void 0; var didWarnAboutFunctionRefs = void 0; var didWarnAboutReassigningProps = void 0; +var didWarnAboutMaxDuration = void 0; { didWarnAboutBadClass = {}; + didWarnAboutModulePatternComponent = {}; didWarnAboutContextTypeOnFunctionComponent = {}; didWarnAboutGetDerivedStateOnFunctionComponent = {}; didWarnAboutFunctionRefs = {}; didWarnAboutReassigningProps = false; + didWarnAboutMaxDuration = false; } function reconcileChildren( @@ -10691,6 +11318,10 @@ function updateForwardRef( nextProps, renderExpirationTime ) { + // TODO: current can be non-null here even if the component + // hasn't yet mounted. This happens after the first render suspends. + // We'll need to figure out if this is fine or can cause issues. + { if (workInProgress.type !== workInProgress.elementType) { // Lazy component props can't be validated in createElement @@ -10880,6 +11511,10 @@ function updateSimpleMemoComponent( updateExpirationTime, renderExpirationTime ) { + // TODO: current can be non-null here even if the component + // hasn't yet mounted. This happens when the inner render suspends. + // We'll need to figure out if this is fine or can cause issues. + { if (workInProgress.type !== workInProgress.elementType) { // Lazy component props can't be validated in createElement @@ -11274,12 +11909,13 @@ function pushHostRootContext(workInProgress) { function updateHostRoot(current$$1, workInProgress, renderExpirationTime) { pushHostRootContext(workInProgress); var updateQueue = workInProgress.updateQueue; - invariant( - updateQueue !== null, - "If the root does not have an updateQueue, we should have already " + - "bailed out. This error is likely caused by a bug in React. Please " + - "file an issue." - ); + (function() { + if (!(updateQueue !== null)) { + throw ReactError( + "If the root does not have an updateQueue, we should have already bailed out. This error is likely caused by a bug in React. Please file an issue." + ); + } + })(); var nextProps = workInProgress.pendingProps; var prevState = workInProgress.memoizedState; var prevChildren = prevState !== null ? prevState.element : null; @@ -11503,13 +12139,16 @@ function mountLazyComponent( // This message intentionally doesn't mention ForwardRef or MemoComponent // because the fact that it's a separate type of work is an // implementation detail. - invariant( - false, - "Element type is invalid. Received a promise that resolves to: %s. " + - "Lazy element type must resolve to a class or function.%s", - Component, - hint - ); + (function() { + { + throw ReactError( + "Element type is invalid. Received a promise that resolves to: " + + Component + + ". Lazy element type must resolve to a class or function." + + hint + ); + } + })(); } } return child; @@ -11640,6 +12279,24 @@ function mountIndeterminateComponent( typeof value.render === "function" && value.$$typeof === undefined ) { + { + var _componentName = getComponentName(Component) || "Unknown"; + if (!didWarnAboutModulePatternComponent[_componentName]) { + warningWithoutStack$1( + false, + "The <%s /> component appears to be a function component that returns a class instance. " + + "Change %s to a class that extends React.Component instead. " + + "If you can't use a class try assigning the prototype on the function as a workaround. " + + "`%s.prototype = React.Component.prototype`. Don't use an arrow function since it " + + "cannot be called with `new` by React.", + _componentName, + _componentName, + _componentName + ); + didWarnAboutModulePatternComponent[_componentName] = true; + } + } + // Proceed under the assumption that this is a class instance workInProgress.tag = ClassComponent; @@ -11761,15 +12418,15 @@ function validateFunctionComponentInDev(workInProgress, Component) { typeof Component.contextType === "object" && Component.contextType !== null ) { - var _componentName = getComponentName(Component) || "Unknown"; + var _componentName2 = getComponentName(Component) || "Unknown"; - if (!didWarnAboutContextTypeOnFunctionComponent[_componentName]) { + if (!didWarnAboutContextTypeOnFunctionComponent[_componentName2]) { warningWithoutStack$1( false, "%s: Function components do not support contextType.", - _componentName + _componentName2 ); - didWarnAboutContextTypeOnFunctionComponent[_componentName] = true; + didWarnAboutContextTypeOnFunctionComponent[_componentName2] = true; } } } @@ -11782,6 +12439,12 @@ function updateSuspenseComponent( var mode = workInProgress.mode; var nextProps = workInProgress.pendingProps; + { + if (shouldSuspend(workInProgress)) { + workInProgress.effectTag |= DidCapture; + } + } + // We should attempt to render the primary children unless this boundary // already suspended during this render (`alreadyCaptured` is true). var nextState = workInProgress.memoizedState; @@ -11795,12 +12458,26 @@ function updateSuspenseComponent( // Something in this boundary's subtree already suspended. Switch to // rendering the fallback children. nextState = { - timedOutAt: nextState !== null ? nextState.timedOutAt : NoWork + fallbackExpirationTime: + nextState !== null ? nextState.fallbackExpirationTime : NoWork }; nextDidTimeout = true; workInProgress.effectTag &= ~DidCapture; } + { + if ("maxDuration" in nextProps) { + if (!didWarnAboutMaxDuration) { + didWarnAboutMaxDuration = true; + warning$1( + false, + "maxDuration has been removed from React. " + + "Remove the maxDuration prop." + ); + } + } + } + // This next part is a bit confusing. If the children timeout, we switch to // showing the fallback children in place of the "primary" children. // However, we don't want to delete the primary children because then their @@ -11833,6 +12510,22 @@ function updateSuspenseComponent( // children -- we skip over the primary children entirely. var next = void 0; if (current$$1 === null) { + if (enableSuspenseServerRenderer) { + // If we're currently hydrating, try to hydrate this boundary. + // But only if this has a fallback. + if (nextProps.fallback !== undefined) { + tryToClaimNextHydratableInstance(workInProgress); + // This could've changed the tag if this was a dehydrated suspense component. + if (workInProgress.tag === DehydratedSuspenseComponent) { + return updateDehydratedSuspenseComponent( + null, + workInProgress, + renderExpirationTime + ); + } + } + } + // This is the initial mount. This branch is pretty simple because there's // no previous state that needs to be preserved. if (nextDidTimeout) { @@ -12035,6 +12728,141 @@ function updateSuspenseComponent( return next; } +function retrySuspenseComponentWithoutHydrating( + current$$1, + workInProgress, + renderExpirationTime +) { + // Detach from the current dehydrated boundary. + current$$1.alternate = null; + workInProgress.alternate = null; + + // Insert a deletion in the effect list. + var returnFiber = workInProgress.return; + (function() { + if (!(returnFiber !== null)) { + throw ReactError( + "Suspense boundaries are never on the root. This is probably a bug in React." + ); + } + })(); + var last = returnFiber.lastEffect; + if (last !== null) { + last.nextEffect = current$$1; + returnFiber.lastEffect = current$$1; + } else { + returnFiber.firstEffect = returnFiber.lastEffect = current$$1; + } + current$$1.nextEffect = null; + current$$1.effectTag = Deletion; + + // Upgrade this work in progress to a real Suspense component. + workInProgress.tag = SuspenseComponent; + workInProgress.stateNode = null; + workInProgress.memoizedState = null; + // This is now an insertion. + workInProgress.effectTag |= Placement; + // Retry as a real Suspense component. + return updateSuspenseComponent(null, workInProgress, renderExpirationTime); +} + +function updateDehydratedSuspenseComponent( + current$$1, + workInProgress, + renderExpirationTime +) { + var suspenseInstance = workInProgress.stateNode; + if (current$$1 === null) { + // During the first pass, we'll bail out and not drill into the children. + // Instead, we'll leave the content in place and try to hydrate it later. + if (isSuspenseInstanceFallback(suspenseInstance)) { + // This is a client-only boundary. Since we won't get any content from the server + // for this, we need to schedule that at a higher priority based on when it would + // have timed out. In theory we could render it in this pass but it would have the + // wrong priority associated with it and will prevent hydration of parent path. + // Instead, we'll leave work left on it to render it in a separate commit. + + // TODO This time should be the time at which the server rendered response that is + // a parent to this boundary was displayed. However, since we currently don't have + // a protocol to transfer that time, we'll just estimate it by using the current + // time. This will mean that Suspense timeouts are slightly shifted to later than + // they should be. + var serverDisplayTime = requestCurrentTime$$1(); + // Schedule a normal pri update to render this content. + workInProgress.expirationTime = computeAsyncExpiration(serverDisplayTime); + } else { + // We'll continue hydrating the rest at offscreen priority since we'll already + // be showing the right content coming from the server, it is no rush. + workInProgress.expirationTime = Never; + } + return null; + } + if ((workInProgress.effectTag & DidCapture) !== NoEffect) { + // Something suspended. Leave the existing children in place. + // TODO: In non-concurrent mode, should we commit the nodes we have hydrated so far? + workInProgress.child = null; + return null; + } + if (isSuspenseInstanceFallback(suspenseInstance)) { + // This boundary is in a permanent fallback state. In this case, we'll never + // get an update and we'll never be able to hydrate the final content. Let's just try the + // client side render instead. + return retrySuspenseComponentWithoutHydrating( + current$$1, + workInProgress, + renderExpirationTime + ); + } + // We use childExpirationTime to indicate that a child might depend on context, so if + // any context has changed, we need to treat is as if the input might have changed. + var hasContextChanged$$1 = + current$$1.childExpirationTime >= renderExpirationTime; + if (didReceiveUpdate || hasContextChanged$$1) { + // This boundary has changed since the first render. This means that we are now unable to + // hydrate it. We might still be able to hydrate it using an earlier expiration time but + // during this render we can't. Instead, we're going to delete the whole subtree and + // instead inject a new real Suspense boundary to take its place, which may render content + // or fallback. The real Suspense boundary will suspend for a while so we have some time + // to ensure it can produce real content, but all state and pending events will be lost. + return retrySuspenseComponentWithoutHydrating( + current$$1, + workInProgress, + renderExpirationTime + ); + } else if (isSuspenseInstancePending(suspenseInstance)) { + // This component is still pending more data from the server, so we can't hydrate its + // content. We treat it as if this component suspended itself. It might seem as if + // we could just try to render it client-side instead. However, this will perform a + // lot of unnecessary work and is unlikely to complete since it often will suspend + // on missing data anyway. Additionally, the server might be able to render more + // than we can on the client yet. In that case we'd end up with more fallback states + // on the client than if we just leave it alone. If the server times out or errors + // these should update this boundary to the permanent Fallback state instead. + // Mark it as having captured (i.e. suspended). + workInProgress.effectTag |= DidCapture; + // Leave the children in place. I.e. empty. + workInProgress.child = null; + // Register a callback to retry this boundary once the server has sent the result. + registerSuspenseInstanceRetry( + suspenseInstance, + retryTimedOutBoundary$$1.bind(null, current$$1) + ); + return null; + } else { + // This is the first attempt. + reenterHydrationStateFromDehydratedSuspenseInstance(workInProgress); + var nextProps = workInProgress.pendingProps; + var nextChildren = nextProps.children; + workInProgress.child = mountChildFibers( + workInProgress, + null, + nextChildren, + renderExpirationTime + ); + return workInProgress.child; + } +} + function updatePortalComponent( current$$1, workInProgress, @@ -12198,32 +13026,81 @@ function updateContextConsumer( return workInProgress.child; } -function markWorkInProgressReceivedUpdate() { - didReceiveUpdate = true; -} - -function bailoutOnAlreadyFinishedWork( +function updateEventComponent$1( current$$1, workInProgress, renderExpirationTime ) { - cancelWorkTimer(workInProgress); + var nextProps = workInProgress.pendingProps; + var nextChildren = nextProps.children; - if (current$$1 !== null) { - // Reuse previous context list - workInProgress.contextDependencies = current$$1.contextDependencies; - } + reconcileChildren( + current$$1, + workInProgress, + nextChildren, + renderExpirationTime + ); + pushHostContextForEventComponent(workInProgress); + return workInProgress.child; +} - if (enableProfilerTimer) { - // Don't update "base" render times for bailouts. - stopProfilerTimerIfRunning(workInProgress); - } +function updateEventTarget(current$$1, workInProgress, renderExpirationTime) { + var type = workInProgress.type.type; + var nextProps = workInProgress.pendingProps; + var eventTargetChild = getEventTargetChildElement(type, nextProps); - // Check if the children have any pending work. - var childExpirationTime = workInProgress.childExpirationTime; - if (childExpirationTime < renderExpirationTime) { - // The children don't have any work either. We can skip them. - // TODO: Once we add back resuming, we should check if the children are + { + !(nextProps.children == null) + ? warning$1(false, "Event targets should not have children.") + : void 0; + } + if (eventTargetChild !== null) { + var child = (workInProgress.child = createFiberFromTypeAndProps( + eventTargetChild.type, + null, + eventTargetChild.props, + null, + workInProgress.mode, + renderExpirationTime + )); + child.return = workInProgress; + + if (current$$1 === null || current$$1.child === null) { + child.effectTag = Placement; + } + } else { + reconcileChildren(current$$1, workInProgress, null, renderExpirationTime); + } + pushHostContextForEventTarget(workInProgress); + return workInProgress.child; +} + +function markWorkInProgressReceivedUpdate() { + didReceiveUpdate = true; +} + +function bailoutOnAlreadyFinishedWork( + current$$1, + workInProgress, + renderExpirationTime +) { + cancelWorkTimer(workInProgress); + + if (current$$1 !== null) { + // Reuse previous context list + workInProgress.contextDependencies = current$$1.contextDependencies; + } + + if (enableProfilerTimer) { + // Don't update "base" render times for bailouts. + stopProfilerTimerIfRunning(workInProgress); + } + + // Check if the children have any pending work. + var childExpirationTime = workInProgress.childExpirationTime; + if (childExpirationTime < renderExpirationTime) { + // The children don't have any work either. We can skip them. + // TODO: Once we add back resuming, we should check if the children are // a work-in-progress set. If so, we need to transfer their effects. return null; } else { @@ -12321,6 +13198,26 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { } break; } + case DehydratedSuspenseComponent: { + if (enableSuspenseServerRenderer) { + // We know that this component will suspend again because if it has + // been unsuspended it has committed as a regular Suspense component. + // If it needs to be retried, it should have work scheduled on it. + workInProgress.effectTag |= DidCapture; + } + break; + } + case EventComponent: + if (enableEventAPI) { + pushHostContextForEventComponent(workInProgress); + } + break; + case EventTarget: { + if (enableEventAPI) { + pushHostContextForEventTarget(workInProgress); + } + break; + } } return bailoutOnAlreadyFinishedWork( current$$1, @@ -12494,13 +13391,44 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { renderExpirationTime ); } - default: - invariant( - false, - "Unknown unit of work tag. This error is likely caused by a bug in " + - "React. Please file an issue." - ); + case DehydratedSuspenseComponent: { + if (enableSuspenseServerRenderer) { + return updateDehydratedSuspenseComponent( + current$$1, + workInProgress, + renderExpirationTime + ); + } + break; + } + case EventComponent: { + if (enableEventAPI) { + return updateEventComponent$1( + current$$1, + workInProgress, + renderExpirationTime + ); + } + break; + } + case EventTarget: { + if (enableEventAPI) { + return updateEventTarget( + current$$1, + workInProgress, + renderExpirationTime + ); + } + break; + } } + (function() { + { + throw ReactError( + "Unknown unit of work tag. This error is likely caused by a bug in React. Please file an issue." + ); + } + })(); } var valueCursor = createCursor(null); @@ -12603,10 +13531,10 @@ function calculateChangedBits(context, newValue, oldValue) { var changedBits = typeof context._calculateChangedBits === "function" ? context._calculateChangedBits(oldValue, newValue) - : maxSigned31BitInt; + : MAX_SIGNED_31_BIT_INT; { - !((changedBits & maxSigned31BitInt) === changedBits) + !((changedBits & MAX_SIGNED_31_BIT_INT) === changedBits) ? warning$1( false, "calculateChangedBits: Expected the return value to be a " + @@ -12619,6 +13547,34 @@ function calculateChangedBits(context, newValue, oldValue) { } } +function scheduleWorkOnParentPath(parent, renderExpirationTime) { + // Update the child expiration time of all the ancestors, including + // the alternates. + var node = parent; + while (node !== null) { + var alternate = node.alternate; + if (node.childExpirationTime < renderExpirationTime) { + node.childExpirationTime = renderExpirationTime; + if ( + alternate !== null && + alternate.childExpirationTime < renderExpirationTime + ) { + alternate.childExpirationTime = renderExpirationTime; + } + } else if ( + alternate !== null && + alternate.childExpirationTime < renderExpirationTime + ) { + alternate.childExpirationTime = renderExpirationTime; + } else { + // Neither alternate was updated, which means the rest of the + // ancestor path already has sufficient priority. + break; + } + node = node.return; + } +} + function propagateContextChange( workInProgress, context, @@ -12668,31 +13624,8 @@ function propagateContextChange( ) { alternate.expirationTime = renderExpirationTime; } - // Update the child expiration time of all the ancestors, including - // the alternates. - var node = fiber.return; - while (node !== null) { - alternate = node.alternate; - if (node.childExpirationTime < renderExpirationTime) { - node.childExpirationTime = renderExpirationTime; - if ( - alternate !== null && - alternate.childExpirationTime < renderExpirationTime - ) { - alternate.childExpirationTime = renderExpirationTime; - } - } else if ( - alternate !== null && - alternate.childExpirationTime < renderExpirationTime - ) { - alternate.childExpirationTime = renderExpirationTime; - } else { - // Neither alternate was updated, which means the rest of the - // ancestor path already has sufficient priority. - break; - } - node = node.return; - } + + scheduleWorkOnParentPath(fiber.return, renderExpirationTime); // Mark the expiration time on the list, too. if (list.expirationTime < renderExpirationTime) { @@ -12708,6 +13641,29 @@ function propagateContextChange( } else if (fiber.tag === ContextProvider) { // Don't scan deeper if this is a matching provider nextFiber = fiber.type === workInProgress.type ? null : fiber.child; + } else if ( + enableSuspenseServerRenderer && + fiber.tag === DehydratedSuspenseComponent + ) { + // If a dehydrated suspense component is in this subtree, we don't know + // if it will have any context consumers in it. The best we can do is + // mark it as having updates on its children. + if (fiber.expirationTime < renderExpirationTime) { + fiber.expirationTime = renderExpirationTime; + } + var _alternate = fiber.alternate; + if ( + _alternate !== null && + _alternate.expirationTime < renderExpirationTime + ) { + _alternate.expirationTime = renderExpirationTime; + } + // This is intentionally passing this fiber as the parent + // because we want to schedule this fiber as having work + // on its children. We'll use the childExpirationTime on + // this fiber to indicate that a context has changed. + scheduleWorkOnParentPath(fiber, renderExpirationTime); + nextFiber = fiber.sibling; } else { // Traverse down. nextFiber = fiber.child; @@ -12781,11 +13737,11 @@ function readContext(context, observedBits) { var resolvedObservedBits = void 0; // Avoid deopting on observable arguments or heterogeneous types. if ( typeof observedBits !== "number" || - observedBits === maxSigned31BitInt + observedBits === MAX_SIGNED_31_BIT_INT ) { // Observe all updates. lastContextWithAllBitsObserved = context; - resolvedObservedBits = maxSigned31BitInt; + resolvedObservedBits = MAX_SIGNED_31_BIT_INT; } else { resolvedObservedBits = observedBits; } @@ -12797,13 +13753,13 @@ function readContext(context, observedBits) { }; if (lastContextDependency === null) { - invariant( - currentlyRenderingFiber !== null, - "Context can only be read while React is rendering. " + - "In classes, you can read it in the render method or getDerivedStateFromProps. " + - "In function components, you can read it directly in the function body, but not " + - "inside Hooks like useReducer() or useMemo()." - ); + (function() { + if (!(currentlyRenderingFiber !== null)) { + throw ReactError( + "Context can only be read while React is rendering. In classes, you can read it in the render method or getDerivedStateFromProps. In function components, you can read it directly in the function body, but not inside Hooks like useReducer() or useMemo()." + ); + } + })(); // This is the first dependency for this component. Create a new list. lastContextDependency = contextItem; @@ -13207,8 +14163,17 @@ function processUpdateQueue( newExpirationTime = updateExpirationTime; } } else { - // This update does have sufficient priority. Process it and compute - // a new result. + // This update does have sufficient priority. + + // Mark the event time of this update as relevant to this render pass. + // TODO: This should ideally use the true event time of this update rather than + // its priority which is a derived and not reverseable value. + // TODO: We should skip this update if it was already committed but currently + // we have no way of detecting the difference between a committed and suspended + // update here. + markRenderEventTime$$1(updateExpirationTime); + + // Process it and compute a new result. resultState = getStateFromUpdate( workInProgress, queue, @@ -13317,12 +14282,14 @@ function processUpdateQueue( } function callCallback(callback, context) { - invariant( - typeof callback === "function", - "Invalid argument passed as callback. Expected a function. Instead " + - "received: %s", - callback - ); + (function() { + if (!(typeof callback === "function")) { + throw ReactError( + "Invalid argument passed as callback. Expected a function. Instead received: " + + callback + ); + } + })(); callback.call(context); } @@ -13501,43 +14468,19 @@ if (supportsMutation) { // eslint-disable-next-line no-labels branches: if (node.tag === HostComponent) { var instance = node.stateNode; - if (needsVisibilityToggle) { + if (needsVisibilityToggle && isHidden) { + // This child is inside a timed out tree. Hide it. var props = node.memoizedProps; var type = node.type; - if (isHidden) { - // This child is inside a timed out tree. Hide it. - instance = cloneHiddenInstance(instance, type, props, node); - } else { - // This child was previously inside a timed out tree. If it was not - // updated during this render, it may need to be unhidden. Clone - // again to be sure. - instance = cloneUnhiddenInstance(instance, type, props, node); - } - node.stateNode = instance; + instance = cloneHiddenInstance(instance, type, props, node); } appendInitialChild(parent, instance); } else if (node.tag === HostText) { var _instance = node.stateNode; - if (needsVisibilityToggle) { + if (needsVisibilityToggle && isHidden) { + // This child is inside a timed out tree. Hide it. var text = node.memoizedProps; - var rootContainerInstance = getRootHostContainer(); - var currentHostContext = getHostContext(); - if (isHidden) { - _instance = createHiddenTextInstance( - text, - rootContainerInstance, - currentHostContext, - workInProgress - ); - } else { - _instance = createTextInstance( - text, - rootContainerInstance, - currentHostContext, - workInProgress - ); - } - node.stateNode = _instance; + _instance = cloneHiddenTextInstance(_instance, text, node); } appendInitialChild(parent, _instance); } else if (node.tag === HostPortal) { @@ -13545,22 +14488,28 @@ if (supportsMutation) { // down its children. Instead, we'll get insertions from each child in // the portal directly. } else if (node.tag === SuspenseComponent) { - var current = node.alternate; - if (current !== null) { - var oldState = current.memoizedState; - var newState = node.memoizedState; - var oldIsHidden = oldState !== null; - var newIsHidden = newState !== null; - if (oldIsHidden !== newIsHidden) { - // The placeholder either just timed out or switched back to the normal - // children after having previously timed out. Toggle the visibility of - // the direct host children. - var primaryChildParent = newIsHidden ? node.child : node; + if ((node.effectTag & Update) !== NoEffect) { + // Need to toggle the visibility of the primary children. + var newIsHidden = node.memoizedState !== null; + if (newIsHidden) { + var primaryChildParent = node.child; if (primaryChildParent !== null) { - appendAllChildren(parent, primaryChildParent, true, newIsHidden); + if (primaryChildParent.child !== null) { + primaryChildParent.child.return = primaryChildParent; + appendAllChildren( + parent, + primaryChildParent, + true, + newIsHidden + ); + } + var fallbackChildParent = primaryChildParent.sibling; + if (fallbackChildParent !== null) { + fallbackChildParent.return = node; + node = fallbackChildParent; + continue; + } } - // eslint-disable-next-line no-labels - break branches; } } if (node.child !== null) { @@ -13604,43 +14553,19 @@ if (supportsMutation) { // eslint-disable-next-line no-labels branches: if (node.tag === HostComponent) { var instance = node.stateNode; - if (needsVisibilityToggle) { + if (needsVisibilityToggle && isHidden) { + // This child is inside a timed out tree. Hide it. var props = node.memoizedProps; var type = node.type; - if (isHidden) { - // This child is inside a timed out tree. Hide it. - instance = cloneHiddenInstance(instance, type, props, node); - } else { - // This child was previously inside a timed out tree. If it was not - // updated during this render, it may need to be unhidden. Clone - // again to be sure. - instance = cloneUnhiddenInstance(instance, type, props, node); - } - node.stateNode = instance; + instance = cloneHiddenInstance(instance, type, props, node); } appendChildToContainerChildSet(containerChildSet, instance); } else if (node.tag === HostText) { var _instance2 = node.stateNode; - if (needsVisibilityToggle) { + if (needsVisibilityToggle && isHidden) { + // This child is inside a timed out tree. Hide it. var text = node.memoizedProps; - var rootContainerInstance = getRootHostContainer(); - var currentHostContext = getHostContext(); - if (isHidden) { - _instance2 = createHiddenTextInstance( - text, - rootContainerInstance, - currentHostContext, - workInProgress - ); - } else { - _instance2 = createTextInstance( - text, - rootContainerInstance, - currentHostContext, - workInProgress - ); - } - node.stateNode = _instance2; + _instance2 = cloneHiddenTextInstance(_instance2, text, node); } appendChildToContainerChildSet(containerChildSet, _instance2); } else if (node.tag === HostPortal) { @@ -13648,27 +14573,28 @@ if (supportsMutation) { // down its children. Instead, we'll get insertions from each child in // the portal directly. } else if (node.tag === SuspenseComponent) { - var current = node.alternate; - if (current !== null) { - var oldState = current.memoizedState; - var newState = node.memoizedState; - var oldIsHidden = oldState !== null; - var newIsHidden = newState !== null; - if (oldIsHidden !== newIsHidden) { - // The placeholder either just timed out or switched back to the normal - // children after having previously timed out. Toggle the visibility of - // the direct host children. - var primaryChildParent = newIsHidden ? node.child : node; + if ((node.effectTag & Update) !== NoEffect) { + // Need to toggle the visibility of the primary children. + var newIsHidden = node.memoizedState !== null; + if (newIsHidden) { + var primaryChildParent = node.child; if (primaryChildParent !== null) { - appendAllChildrenToContainer( - containerChildSet, - primaryChildParent, - true, - newIsHidden - ); + if (primaryChildParent.child !== null) { + primaryChildParent.child.return = primaryChildParent; + appendAllChildrenToContainer( + containerChildSet, + primaryChildParent, + true, + newIsHidden + ); + } + var fallbackChildParent = primaryChildParent.sibling; + if (fallbackChildParent !== null) { + fallbackChildParent.return = node; + node = fallbackChildParent; + continue; + } } - // eslint-disable-next-line no-labels - break branches; } } if (node.child !== null) { @@ -13872,11 +14798,13 @@ function completeWork(current, workInProgress, renderExpirationTime) { } } else { if (!newProps) { - invariant( - workInProgress.stateNode !== null, - "We must have new props for new mounts. This error is likely " + - "caused by a bug in React. Please file an issue." - ); + (function() { + if (!(workInProgress.stateNode !== null)) { + throw ReactError( + "We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue." + ); + } + })(); // This can happen when we abort work. break; } @@ -13945,11 +14873,13 @@ function completeWork(current, workInProgress, renderExpirationTime) { updateHostText$1(current, workInProgress, oldText, newText); } else { if (typeof newText !== "string") { - invariant( - workInProgress.stateNode !== null, - "We must have new props for new mounts. This error is likely " + - "caused by a bug in React. Please file an issue." - ); + (function() { + if (!(workInProgress.stateNode !== null)) { + throw ReactError( + "We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue." + ); + } + })(); // This can happen when we abort work. } var _rootContainerInstance = getRootHostContainer(); @@ -13982,32 +14912,72 @@ function completeWork(current, workInProgress, renderExpirationTime) { } var nextDidTimeout = nextState !== null; - var prevDidTimeout = current !== null && current.memoizedState !== null; - - if (current !== null && !nextDidTimeout && prevDidTimeout) { - // We just switched from the fallback to the normal children. Delete - // the fallback. - // TODO: Would it be better to store the fallback fragment on - var currentFallbackChild = current.child.sibling; - if (currentFallbackChild !== null) { - // Deletions go at the beginning of the return fiber's effect list - var first = workInProgress.firstEffect; - if (first !== null) { - workInProgress.firstEffect = currentFallbackChild; - currentFallbackChild.nextEffect = first; - } else { - workInProgress.firstEffect = workInProgress.lastEffect = currentFallbackChild; - currentFallbackChild.nextEffect = null; + var prevDidTimeout = false; + if (current === null) { + // In cases where we didn't find a suitable hydration boundary we never + // downgraded this to a DehydratedSuspenseComponent, but we still need to + // pop the hydration state since we might be inside the insertion tree. + popHydrationState(workInProgress); + } else { + var prevState = current.memoizedState; + prevDidTimeout = prevState !== null; + if (!nextDidTimeout && prevState !== null) { + // We just switched from the fallback to the normal children. + + // Mark the event time of the switching from fallback to normal children, + // based on the start of when we first showed the fallback. This time + var fallbackExpirationTimeExpTime = prevState.fallbackExpirationTime; + markRenderEventTime$$1(fallbackExpirationTimeExpTime); + + // Delete the fallback. + // TODO: Would it be better to store the fallback fragment on + // the stateNode during the begin phase? + var currentFallbackChild = current.child.sibling; + if (currentFallbackChild !== null) { + // Deletions go at the beginning of the return fiber's effect list + var first = workInProgress.firstEffect; + if (first !== null) { + workInProgress.firstEffect = currentFallbackChild; + currentFallbackChild.nextEffect = first; + } else { + workInProgress.firstEffect = workInProgress.lastEffect = currentFallbackChild; + currentFallbackChild.nextEffect = null; + } + currentFallbackChild.effectTag = Deletion; } - currentFallbackChild.effectTag = Deletion; } } - if (nextDidTimeout || prevDidTimeout) { - // If the children are hidden, or if they were previous hidden, schedule - // an effect to toggle their visibility. This is also used to attach a - // retry listener to the promise. - workInProgress.effectTag |= Update; + if (nextDidTimeout && !prevDidTimeout) { + // If this subtreee is running in concurrent mode we can suspend, + // otherwise we won't suspend. + // TODO: This will still suspend a synchronous tree if anything + // in the concurrent tree already suspended during this render. + // This is a known bug. + if ((workInProgress.mode & ConcurrentMode) !== NoContext) { + renderDidSuspend$$1(); + } + } + + if (supportsPersistence) { + // TODO: Only schedule updates if not prevDidTimeout. + if (nextDidTimeout) { + // If this boundary just timed out, schedule an effect to attach a + // retry listener to the proimse. This flag is also used to hide the + // primary children. + workInProgress.effectTag |= Update; + } + } + if (supportsMutation) { + // TODO: Only schedule updates if these values are non equal, i.e. it changed. + if (nextDidTimeout || prevDidTimeout) { + // If this boundary just timed out, schedule an effect to attach a + // retry listener to the proimse. This flag is also used to hide the + // primary children. In mutation mode, we also need the flag to + // *unhide* children that were previously hidden, so check if the + // is currently timed out, too. + workInProgress.effectTag |= Update; + } } break; } @@ -14038,12 +15008,86 @@ function completeWork(current, workInProgress, renderExpirationTime) { } break; } + case DehydratedSuspenseComponent: { + if (enableSuspenseServerRenderer) { + if (current === null) { + var _wasHydrated2 = popHydrationState(workInProgress); + (function() { + if (!_wasHydrated2) { + throw ReactError( + "A dehydrated suspense component was completed without a hydrated node. This is probably a bug in React." + ); + } + })(); + skipPastDehydratedSuspenseInstance(workInProgress); + } else if ((workInProgress.effectTag & DidCapture) === NoEffect) { + // This boundary did not suspend so it's now hydrated. + // To handle any future suspense cases, we're going to now upgrade it + // to a Suspense component. We detach it from the existing current fiber. + current.alternate = null; + workInProgress.alternate = null; + workInProgress.tag = SuspenseComponent; + workInProgress.memoizedState = null; + workInProgress.stateNode = null; + } + } + break; + } + case EventComponent: { + if (enableEventAPI) { + popHostContext(workInProgress); + var _rootContainerInstance2 = getRootHostContainer(); + var responder = workInProgress.type.responder; + var eventComponentInstance = workInProgress.stateNode; + + if (eventComponentInstance === null) { + var responderState = null; + if (responder.createInitialState !== undefined) { + responderState = responder.createInitialState(newProps); + } + eventComponentInstance = workInProgress.stateNode = { + context: null, + props: newProps, + responder: responder, + rootInstance: _rootContainerInstance2, + state: responderState + }; + mountEventComponent(eventComponentInstance); + } else { + // Update the props on the event component state node + eventComponentInstance.props = newProps; + // Update the root container, so we can properly unmount events at some point + eventComponentInstance.rootInstance = _rootContainerInstance2; + updateEventComponent(eventComponentInstance); + } + } + break; + } + case EventTarget: { + if (enableEventAPI) { + popHostContext(workInProgress); + var _type = workInProgress.type.type; + var _rootContainerInstance3 = getRootHostContainer(); + var shouldUpdate = handleEventTarget( + _type, + newProps, + _rootContainerInstance3, + workInProgress + ); + if (shouldUpdate) { + markUpdate(workInProgress); + } + } + break; + } default: - invariant( - false, - "Unknown unit of work tag. This error is likely caused by a bug in " + - "React. Please file an issue." - ); + (function() { + { + throw ReactError( + "Unknown unit of work tag. This error is likely caused by a bug in React. Please file an issue." + ); + } + })(); } return null; @@ -14181,7 +15225,7 @@ var didWarnAboutUndefinedSnapshotBeforeUpdate = null; didWarnAboutUndefinedSnapshotBeforeUpdate = new Set(); } -var PossiblyWeakSet = typeof WeakSet === "function" ? WeakSet : Set; +var PossiblyWeakSet$1 = typeof WeakSet === "function" ? WeakSet : Set; function logError(boundary, errorInfo) { var source = errorInfo.source; @@ -14240,7 +15284,7 @@ function safelyCallComponentWillUnmount(current$$1, instance) { ); if (hasCaughtError()) { var unmountError = clearCaughtError(); - captureCommitPhaseError(current$$1, unmountError); + captureCommitPhaseError$$1(current$$1, unmountError); } } } @@ -14253,7 +15297,7 @@ function safelyDetachRef(current$$1) { invokeGuardedCallback(null, ref, null, null); if (hasCaughtError()) { var refError = clearCaughtError(); - captureCommitPhaseError(current$$1, refError); + captureCommitPhaseError$$1(current$$1, refError); } } } else { @@ -14267,7 +15311,7 @@ function safelyCallDestroy(current$$1, destroy) { invokeGuardedCallback(null, destroy, null); if (hasCaughtError()) { var error = clearCaughtError(); - captureCommitPhaseError(current$$1, error); + captureCommitPhaseError$$1(current$$1, error); } } } @@ -14348,14 +15392,17 @@ function commitBeforeMutationLifeCycles(current$$1, finishedWork) { case HostText: case HostPortal: case IncompleteClassComponent: + case EventTarget: // Nothing to do for these component types return; default: { - invariant( - false, - "This unit of work tag should not have side-effects. This error is " + - "likely caused by a bug in React. Please file an issue." - ); + (function() { + { + throw ReactError( + "This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue." + ); + } + })(); } } } @@ -14391,22 +15438,23 @@ function commitHookEffectList(unmountTag, mountTag, finishedWork) { } else if (typeof _destroy.then === "function") { addendum = "\n\nIt looks like you wrote useEffect(async () => ...) or returned a Promise. " + - "Instead, you may write an async function separately " + - "and then call it from inside the effect:\n\n" + - "async function fetchComment(commentId) {\n" + - " // You can await here\n" + - "}\n\n" + + "Instead, write the async function inside your effect " + + "and call it immediately:\n\n" + "useEffect(() => {\n" + - " fetchComment(commentId);\n" + - "}, [commentId]);\n\n" + - "In the future, React will provide a more idiomatic solution for data fetching " + - "that doesn't involve writing effects manually."; + " async function fetchData() {\n" + + " // You can await here\n" + + " const response = await MyAPI.getData(someId);\n" + + " // ...\n" + + " }\n" + + " fetchData();\n" + + "}, [someId]); // Or [] if effect doesn't need props or state\n\n" + + "Learn more about data fetching with Hooks: https://fb.me/react-hooks-data-fetching"; } else { addendum = " You returned: " + _destroy; } warningWithoutStack$1( false, - "An Effect function must not return anything besides a function, " + + "An effect function must not return anything besides a function, " + "which is used for clean-up.%s%s", addendum, getStackByFiberInDevAndProd(finishedWork) @@ -14643,15 +15691,17 @@ function commitLifeCycles( return; } case SuspenseComponent: - break; case IncompleteClassComponent: + case EventTarget: break; default: { - invariant( - false, - "This unit of work tag should not have side-effects. This error is " + - "likely caused by a bug in React. Please file an issue." - ); + (function() { + { + throw ReactError( + "This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue." + ); + } + })(); } } } @@ -14798,6 +15848,13 @@ function commitUnmount(current$$1) { } return; } + case EventComponent: { + if (enableEventAPI) { + var eventComponentInstance = current$$1.stateNode; + unmountEventComponent(eventComponentInstance); + current$$1.stateNode = null; + } + } } } @@ -14871,13 +15928,10 @@ function commitContainer(finishedWork) { } switch (finishedWork.tag) { - case ClassComponent: { - return; - } - case HostComponent: { - return; - } - case HostText: { + case ClassComponent: + case HostComponent: + case HostText: + case EventTarget: { return; } case HostRoot: @@ -14889,11 +15943,13 @@ function commitContainer(finishedWork) { return; } default: { - invariant( - false, - "This unit of work tag should not have side-effects. This error is " + - "likely caused by a bug in React. Please file an issue." - ); + (function() { + { + throw ReactError( + "This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue." + ); + } + })(); } } } @@ -14906,11 +15962,13 @@ function getHostParentFiber(fiber) { } parent = parent.return; } - invariant( - false, - "Expected to find a host parent. This error is likely caused by a bug " + - "in React. Please file an issue." - ); + (function() { + { + throw ReactError( + "Expected to find a host parent. This error is likely caused by a bug in React. Please file an issue." + ); + } + })(); } function isHostParent(fiber) { @@ -14938,7 +15996,11 @@ function getHostSibling(fiber) { } node.sibling.return = node.return; node = node.sibling; - while (node.tag !== HostComponent && node.tag !== HostText) { + while ( + node.tag !== HostComponent && + node.tag !== HostText && + node.tag !== DehydratedSuspenseComponent + ) { // If it is not host node and, we might have a host node inside it. // Try to search down until we find one. if (node.effectTag & Placement) { @@ -14988,11 +16050,13 @@ function commitPlacement(finishedWork) { isContainer = true; break; default: - invariant( - false, - "Invalid host parent fiber. This error is likely caused by a bug " + - "in React. Please file an issue." - ); + (function() { + { + throw ReactError( + "Invalid host parent fiber. This error is likely caused by a bug in React. Please file an issue." + ); + } + })(); } if (parentFiber.effectTag & ContentReset) { // Reset the text content of the parent before doing any insertions @@ -15007,17 +16071,18 @@ function commitPlacement(finishedWork) { var node = finishedWork; while (true) { if (node.tag === HostComponent || node.tag === HostText) { + var stateNode = node.stateNode; if (before) { if (isContainer) { - insertInContainerBefore(parent, node.stateNode, before); + insertInContainerBefore(parent, stateNode, before); } else { - insertBefore(parent, node.stateNode, before); + insertBefore(parent, stateNode, before); } } else { if (isContainer) { - appendChildToContainer(parent, node.stateNode); + appendChildToContainer(parent, stateNode); } else { - appendChild$1(parent, node.stateNode); + appendChild$1(parent, stateNode); } } } else if (node.tag === HostPortal) { @@ -15059,11 +16124,13 @@ function unmountHostComponents(current$$1) { if (!currentParentIsValid) { var parent = node.return; findParent: while (true) { - invariant( - parent !== null, - "Expected to find a host parent. This error is likely caused by " + - "a bug in React. Please file an issue." - ); + (function() { + if (!(parent !== null)) { + throw ReactError( + "Expected to find a host parent. This error is likely caused by a bug in React. Please file an issue." + ); + } + })(); switch (parent.tag) { case HostComponent: currentParent = parent.stateNode; @@ -15093,6 +16160,16 @@ function unmountHostComponents(current$$1) { removeChild(currentParent, node.stateNode); } // Don't visit children because we already visited them. + } else if ( + enableSuspenseServerRenderer && + node.tag === DehydratedSuspenseComponent + ) { + // Delete the dehydrated suspense boundary and all of its content. + if (currentParentIsContainer) { + clearSuspenseBoundaryFromContainer(currentParent, node.stateNode); + } else { + clearSuspenseBoundary(currentParent, node.stateNode); + } } else if (node.tag === HostPortal) { if (node.child !== null) { // When we go into a portal, it becomes the parent to remove from. @@ -15156,6 +16233,13 @@ function commitWork(current$$1, finishedWork) { commitHookEffectList(UnmountMutation, MountMutation, finishedWork); return; } + case Profiler: { + return; + } + case SuspenseComponent: { + commitSuspenseComponent(finishedWork); + return; + } } commitContainer(finishedWork); @@ -15203,11 +16287,13 @@ function commitWork(current$$1, finishedWork) { return; } case HostText: { - invariant( - finishedWork.stateNode !== null, - "This should have a text node initialized. This error is likely " + - "caused by a bug in React. Please file an issue." - ); + (function() { + if (!(finishedWork.stateNode !== null)) { + throw ReactError( + "This should have a text node initialized. This error is likely caused by a bug in React. Please file an issue." + ); + } + })(); var textInstance = finishedWork.stateNode; var newText = finishedWork.memoizedProps; // For hydration we reuse the update path but we treat the oldProps @@ -15217,6 +16303,36 @@ function commitWork(current$$1, finishedWork) { commitTextUpdate(textInstance, oldText, newText); return; } + case EventTarget: { + if (enableEventAPI) { + var _type = finishedWork.type.type; + var props = finishedWork.memoizedProps; + var _instance4 = finishedWork.stateNode; + var parentInstance = null; + + var node = finishedWork.return; + // Traverse up the fiber tree until we find the parent host node. + while (node !== null) { + if (node.tag === HostComponent) { + parentInstance = node.stateNode; + break; + } else if (node.tag === HostRoot) { + parentInstance = node.stateNode.containerInfo; + break; + } + node = node.return; + } + (function() { + if (!(parentInstance !== null)) { + throw ReactError( + "This should have a parent host component initialized. This error is likely caused by a bug in React. Please file an issue." + ); + } + })(); + commitEventTarget(_type, props, _instance4, parentInstance); + } + return; + } case HostRoot: { return; } @@ -15224,63 +16340,72 @@ function commitWork(current$$1, finishedWork) { return; } case SuspenseComponent: { - var newState = finishedWork.memoizedState; - - var newDidTimeout = void 0; - var primaryChildParent = finishedWork; - if (newState === null) { - newDidTimeout = false; - } else { - newDidTimeout = true; - primaryChildParent = finishedWork.child; - if (newState.timedOutAt === NoWork) { - // If the children had not already timed out, record the time. - // This is used to compute the elapsed time during subsequent - // attempts to render the children. - newState.timedOutAt = requestCurrentTime(); - } - } - - if (primaryChildParent !== null) { - hideOrUnhideAllChildren(primaryChildParent, newDidTimeout); - } - - // If this boundary just timed out, then it will have a set of thenables. - // For each thenable, attach a listener so that when it resolves, React - // attempts to re-render the boundary in the primary (pre-timeout) state. - var thenables = finishedWork.updateQueue; - if (thenables !== null) { - finishedWork.updateQueue = null; - var retryCache = finishedWork.stateNode; - if (retryCache === null) { - retryCache = finishedWork.stateNode = new PossiblyWeakSet(); - } - thenables.forEach(function(thenable) { - // Memoize using the boundary fiber to prevent redundant listeners. - var retry = retryTimedOutBoundary.bind(null, finishedWork, thenable); - if (enableSchedulerTracing) { - retry = tracing.unstable_wrap(retry); - } - if (!retryCache.has(thenable)) { - retryCache.add(thenable); - thenable.then(retry, retry); - } - }); - } - + commitSuspenseComponent(finishedWork); return; } case IncompleteClassComponent: { return; } default: { - invariant( - false, - "This unit of work tag should not have side-effects. This error is " + - "likely caused by a bug in React. Please file an issue." + (function() { + { + throw ReactError( + "This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue." + ); + } + })(); + } + } +} + +function commitSuspenseComponent(finishedWork) { + var newState = finishedWork.memoizedState; + + var newDidTimeout = void 0; + var primaryChildParent = finishedWork; + if (newState === null) { + newDidTimeout = false; + } else { + newDidTimeout = true; + primaryChildParent = finishedWork.child; + if (newState.fallbackExpirationTime === NoWork) { + // If the children had not already timed out, record the time. + // This is used to compute the elapsed time during subsequent + // attempts to render the children. + // We model this as a normal pri expiration time since that's + // how we infer start time for updates. + newState.fallbackExpirationTime = computeAsyncExpirationNoBucket( + requestCurrentTime$$1() ); } } + + if (supportsMutation && primaryChildParent !== null) { + hideOrUnhideAllChildren(primaryChildParent, newDidTimeout); + } + + // If this boundary just timed out, then it will have a set of thenables. + // For each thenable, attach a listener so that when it resolves, React + // attempts to re-render the boundary in the primary (pre-timeout) state. + var thenables = finishedWork.updateQueue; + if (thenables !== null) { + finishedWork.updateQueue = null; + var retryCache = finishedWork.stateNode; + if (retryCache === null) { + retryCache = finishedWork.stateNode = new PossiblyWeakSet$1(); + } + thenables.forEach(function(thenable) { + // Memoize using the boundary fiber to prevent redundant listeners. + var retry = resolveRetryThenable$$1.bind(null, finishedWork, thenable); + if (enableSchedulerTracing) { + retry = tracing.unstable_wrap(retry); + } + if (!retryCache.has(thenable)) { + retryCache.add(thenable); + thenable.then(retry, retry); + } + }); + } } function commitResetTextContent(current$$1) { @@ -15290,6 +16415,7 @@ function commitResetTextContent(current$$1) { resetTextContent(current$$1.stateNode); } +var PossiblyWeakSet = typeof WeakSet === "function" ? WeakSet : Set; var PossiblyWeakMap = typeof WeakMap === "function" ? WeakMap : Map; function createRootErrorUpdate(fiber, errorInfo, expirationTime) { @@ -15301,7 +16427,7 @@ function createRootErrorUpdate(fiber, errorInfo, expirationTime) { update.payload = { element: null }; var error = errorInfo.value; update.callback = function() { - onUncaughtError(error); + onUncaughtError$$1(error); logError(fiber, errorInfo); }; return update; @@ -15327,7 +16453,7 @@ function createClassErrorUpdate(fiber, errorInfo, expirationTime) { // This gets reset before we yield back to the browser. // TODO: Warn in strict mode if getDerivedStateFromError is // not defined. - markLegacyErrorBoundaryAsFailed(this); + markLegacyErrorBoundaryAsFailed$$1(this); } var error = errorInfo.value; var stack = errorInfo.stack; @@ -15355,6 +16481,39 @@ function createClassErrorUpdate(fiber, errorInfo, expirationTime) { return update; } +function attachPingListener(root, renderExpirationTime, thenable) { + // Attach a listener to the promise to "ping" the root and retry. But + // only if one does not already exist for the current render expiration + // time (which acts like a "thread ID" here). + var pingCache = root.pingCache; + var threadIDs = void 0; + if (pingCache === null) { + pingCache = root.pingCache = new PossiblyWeakMap(); + threadIDs = new Set(); + pingCache.set(thenable, threadIDs); + } else { + threadIDs = pingCache.get(thenable); + if (threadIDs === undefined) { + threadIDs = new Set(); + pingCache.set(thenable, threadIDs); + } + } + if (!threadIDs.has(renderExpirationTime)) { + // Memoize using the thread ID to prevent redundant listeners. + threadIDs.add(renderExpirationTime); + var ping = pingSuspendedRoot$$1.bind( + null, + root, + thenable, + renderExpirationTime + ); + if (enableSchedulerTracing) { + ping = tracing.unstable_wrap(ping); + } + thenable.then(ping, ping); + } +} + function throwException( root, returnFiber, @@ -15375,45 +16534,8 @@ function throwException( // This is a thenable. var thenable = value; - // Find the earliest timeout threshold of all the placeholders in the - // ancestor path. We could avoid this traversal by storing the thresholds on - // the stack, but we choose not to because we only hit this path if we're - // IO-bound (i.e. if something suspends). Whereas the stack is used even in - // the non-IO- bound case. - var _workInProgress = returnFiber; - var earliestTimeoutMs = -1; - var startTimeMs = -1; - do { - if (_workInProgress.tag === SuspenseComponent) { - var current$$1 = _workInProgress.alternate; - if (current$$1 !== null) { - var currentState = current$$1.memoizedState; - if (currentState !== null) { - // Reached a boundary that already timed out. Do not search - // any further. - var timedOutAt = currentState.timedOutAt; - startTimeMs = expirationTimeToMs(timedOutAt); - // Do not search any further. - break; - } - } - var timeoutPropMs = _workInProgress.pendingProps.maxDuration; - if (typeof timeoutPropMs === "number") { - if (timeoutPropMs <= 0) { - earliestTimeoutMs = 0; - } else if ( - earliestTimeoutMs === -1 || - timeoutPropMs < earliestTimeoutMs - ) { - earliestTimeoutMs = timeoutPropMs; - } - } - } - _workInProgress = _workInProgress.return; - } while (_workInProgress !== null); - // Schedule the nearest Suspense to re-render the timed out view. - _workInProgress = returnFiber; + var _workInProgress = returnFiber; do { if ( _workInProgress.tag === SuspenseComponent && @@ -15439,7 +16561,7 @@ function throwException( // Note: It doesn't matter whether the component that suspended was // inside a concurrent mode tree. If the Suspense is outside of it, we // should *not* suspend the commit. - if ((_workInProgress.mode & ConcurrentMode) === NoEffect) { + if ((_workInProgress.mode & ConcurrentMode) === NoContext) { _workInProgress.effectTag |= DidCapture; // We're going to commit this fiber even though it didn't complete. @@ -15475,72 +16597,44 @@ function throwException( // Confirmed that the boundary is in a concurrent mode tree. Continue // with the normal suspend path. - // Attach a listener to the promise to "ping" the root and retry. But - // only if one does not already exist for the current render expiration - // time (which acts like a "thread ID" here). - var pingCache = root.pingCache; - var threadIDs = void 0; - if (pingCache === null) { - pingCache = root.pingCache = new PossiblyWeakMap(); - threadIDs = new Set(); - pingCache.set(thenable, threadIDs); - } else { - threadIDs = pingCache.get(thenable); - if (threadIDs === undefined) { - threadIDs = new Set(); - pingCache.set(thenable, threadIDs); - } + attachPingListener(root, renderExpirationTime, thenable); + + _workInProgress.effectTag |= ShouldCapture; + _workInProgress.expirationTime = renderExpirationTime; + return; + } else if ( + enableSuspenseServerRenderer && + _workInProgress.tag === DehydratedSuspenseComponent + ) { + attachPingListener(root, renderExpirationTime, thenable); + + // Since we already have a current fiber, we can eagerly add a retry listener. + var retryCache = _workInProgress.memoizedState; + if (retryCache === null) { + retryCache = _workInProgress.memoizedState = new PossiblyWeakSet(); + var current$$1 = _workInProgress.alternate; + (function() { + if (!current$$1) { + throw ReactError( + "A dehydrated suspense boundary must commit before trying to render. This is probably a bug in React." + ); + } + })(); + current$$1.memoizedState = retryCache; } - if (!threadIDs.has(renderExpirationTime)) { - // Memoize using the thread ID to prevent redundant listeners. - threadIDs.add(renderExpirationTime); - var ping = pingSuspendedRoot.bind( + // Memoize using the boundary fiber to prevent redundant listeners. + if (!retryCache.has(thenable)) { + retryCache.add(thenable); + var retry = resolveRetryThenable$$1.bind( null, - root, - thenable, - renderExpirationTime + _workInProgress, + thenable ); if (enableSchedulerTracing) { - ping = tracing.unstable_wrap(ping); - } - thenable.then(ping, ping); - } - - var absoluteTimeoutMs = void 0; - if (earliestTimeoutMs === -1) { - // If no explicit threshold is given, default to an arbitrarily large - // value. The actual size doesn't matter because the threshold for the - // whole tree will be clamped to the expiration time. - absoluteTimeoutMs = maxSigned31BitInt; - } else { - if (startTimeMs === -1) { - // This suspend happened outside of any already timed-out - // placeholders. We don't know exactly when the update was - // scheduled, but we can infer an approximate start time from the - // expiration time. First, find the earliest uncommitted expiration - // time in the tree, including work that is suspended. Then subtract - // the offset used to compute an async update's expiration time. - // This will cause high priority (interactive) work to expire - // earlier than necessary, but we can account for this by adjusting - // for the Just Noticeable Difference. - var earliestExpirationTime = findEarliestOutstandingPriorityLevel( - root, - renderExpirationTime - ); - var earliestExpirationTimeMs = expirationTimeToMs( - earliestExpirationTime - ); - startTimeMs = earliestExpirationTimeMs - LOW_PRIORITY_EXPIRATION; + retry = tracing.unstable_wrap(retry); } - absoluteTimeoutMs = startTimeMs + earliestTimeoutMs; + thenable.then(retry, retry); } - - // Mark the earliest timeout in the suspended fiber's ancestor path. - // After completing the root, we'll take the largest of all the - // suspended fiber's timeouts and use it to compute a timeout for the - // whole tree. - renderDidSuspend(root, absoluteTimeoutMs, renderExpirationTime); - _workInProgress.effectTag |= ShouldCapture; _workInProgress.expirationTime = renderExpirationTime; return; @@ -15564,7 +16658,7 @@ function throwException( // We didn't find a boundary that could handle this type of exception. Start // over and traverse parent path again, this time treating the exception // as an error. - renderDidError(); + renderDidError$$1(); value = createCapturedValue(value, sourceFiber); var workInProgress = returnFiber; do { @@ -15591,7 +16685,7 @@ function throwException( (typeof ctor.getDerivedStateFromError === "function" || (instance !== null && typeof instance.componentDidCatch === "function" && - !isAlreadyFailedLegacyErrorBoundary(instance))) + !isAlreadyFailedLegacyErrorBoundary$$1(instance))) ) { workInProgress.effectTag |= ShouldCapture; workInProgress.expirationTime = renderExpirationTime; @@ -15630,15 +16724,18 @@ function unwindWork(workInProgress, renderExpirationTime) { popHostContainer(workInProgress); popTopLevelContextObject(workInProgress); var _effectTag = workInProgress.effectTag; - invariant( - (_effectTag & DidCapture) === NoEffect, - "The root failed to unmount after an error. This is likely a bug in " + - "React. Please file an issue." - ); + (function() { + if (!((_effectTag & DidCapture) === NoEffect)) { + throw ReactError( + "The root failed to unmount after an error. This is likely a bug in React. Please file an issue." + ); + } + })(); workInProgress.effectTag = (_effectTag & ~ShouldCapture) | DidCapture; return workInProgress; } case HostComponent: { + // TODO: popHydrationState popHostContext(workInProgress); return null; } @@ -15651,12 +16748,31 @@ function unwindWork(workInProgress, renderExpirationTime) { } return null; } + case DehydratedSuspenseComponent: { + if (enableSuspenseServerRenderer) { + // TODO: popHydrationState + var _effectTag3 = workInProgress.effectTag; + if (_effectTag3 & ShouldCapture) { + workInProgress.effectTag = + (_effectTag3 & ~ShouldCapture) | DidCapture; + // Captured a suspense effect. Re-render the boundary. + return workInProgress; + } + } + return null; + } case HostPortal: popHostContainer(workInProgress); return null; case ContextProvider: popProvider(workInProgress); return null; + case EventComponent: + case EventTarget: + if (enableEventAPI) { + popHostContext(workInProgress); + } + return null; default: return null; } @@ -15691,8 +16807,20 @@ function unwindInterruptedWork(interruptedWork) { } } +// Intentionally not named imports because Rollup would use dynamic dispatch for +// CommonJS interop named imports. +// Intentionally not named imports because Rollup would use dynamic dispatch for +// CommonJS interop named imports. +var scheduleCallback$1 = Scheduler.unstable_scheduleCallback; +var cancelCallback$1 = Scheduler.unstable_cancelCallback; +var shouldYield$1 = Scheduler.unstable_shouldYield; +var now$1 = Scheduler.unstable_now; +var getCurrentPriorityLevel$1 = Scheduler.unstable_getCurrentPriorityLevel; +var NormalPriority$1 = Scheduler.unstable_NormalPriority; var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher; var ReactCurrentOwner$2 = ReactSharedInternals.ReactCurrentOwner; +var ReactShouldWarnActingUpdates = + ReactSharedInternals.ReactShouldWarnActingUpdates; var didWarnAboutStateTransition = void 0; var didWarnSetStateChildContext = void 0; @@ -15702,14 +16830,18 @@ var warnAboutInvalidUpdates = void 0; if (enableSchedulerTracing) { // Provide explicit error message when production+profiling bundle of e.g. react-dom // is used with production (non-profiling) bundle of scheduler/tracing - invariant( - tracing.__interactionsRef != null && - tracing.__interactionsRef.current != null, - "It is not supported to run the profiling version of a renderer (for example, `react-dom/profiling`) " + - "without also replacing the `scheduler/tracing` module with `scheduler/tracing-profiling`. " + - "Your bundler might have a setting for aliasing both modules. " + - "Learn more at http://fb.me/react-profiling" - ); + (function() { + if ( + !( + tracing.__interactionsRef != null && + tracing.__interactionsRef.current != null + ) + ) { + throw ReactError( + "It is not supported to run the profiling version of a renderer (for example, `react-dom/profiling`) without also replacing the `scheduler/tracing` module with `scheduler/tracing-profiling`. Your bundler might have a setting for aliasing both modules. Learn more at http://fb.me/react-profiling" + ); + } + })(); } { @@ -15764,6 +16896,11 @@ if (enableSchedulerTracing) { }; } +// Represents the expiration time that incoming updates should use. (If this +// is NoWork, use the default strategy: async updates in async mode, sync +// updates in sync mode.) +var expirationContext = NoWork; + var isWorking = false; // The next work in progress fiber that we're currently working on. @@ -15771,7 +16908,8 @@ var nextUnitOfWork = null; var nextRoot = null; // The time at which we're currently rendering work. var nextRenderExpirationTime = NoWork; -var nextLatestAbsoluteTimeoutMs = -1; +var mostRecentEventTime = Sync; +var nextRenderDidSuspend = false; var nextRenderDidError = false; // The next fiber with an effect that we're currently committing. @@ -15894,7 +17032,8 @@ function resetStack() { nextRoot = null; nextRenderExpirationTime = NoWork; - nextLatestAbsoluteTimeoutMs = -1; + mostRecentEventTime = Sync; + nextRenderDidSuspend = false; nextRenderDidError = false; nextUnitOfWork = null; } @@ -16047,14 +17186,16 @@ function commitPassiveEffects(root, firstEffect) { var didError = false; var error = void 0; { + isInPassiveEffectDEV = true; invokeGuardedCallback(null, commitPassiveHookEffects, null, effect); + isInPassiveEffectDEV = false; if (hasCaughtError()) { didError = true; error = clearCaughtError(); } } if (didError) { - captureCommitPhaseError(effect, error); + captureCommitPhaseError$1(effect, error); } } effect = effect.nextEffect; @@ -16070,16 +17211,28 @@ function commitPassiveEffects(root, firstEffect) { if (rootExpirationTime !== NoWork) { requestWork(root, rootExpirationTime); } + // Flush any sync work that was scheduled by effects + if (!isBatchingUpdates && !isRendering) { + performSyncWork(); + } + + { + if (rootWithPendingPassiveEffects === root) { + nestedPassiveEffectCountDEV++; + } else { + nestedPassiveEffectCountDEV = 0; + } + } } -function isAlreadyFailedLegacyErrorBoundary(instance) { +function isAlreadyFailedLegacyErrorBoundary$1(instance) { return ( legacyErrorBoundariesThatAlreadyFailed !== null && legacyErrorBoundariesThatAlreadyFailed.has(instance) ); } -function markLegacyErrorBoundaryAsFailed(instance) { +function markLegacyErrorBoundaryAsFailed$1(instance) { if (legacyErrorBoundariesThatAlreadyFailed === null) { legacyErrorBoundariesThatAlreadyFailed = new Set([instance]); } else { @@ -16087,15 +17240,17 @@ function markLegacyErrorBoundaryAsFailed(instance) { } } -function flushPassiveEffects() { +function flushPassiveEffects$1() { + var didFlushEffects = passiveEffectCallback !== null; if (passiveEffectCallbackHandle !== null) { - cancelPassiveEffects(passiveEffectCallbackHandle); + cancelCallback$1(passiveEffectCallbackHandle); } if (passiveEffectCallback !== null) { // We call the scheduled callback instead of commitPassiveEffects directly // to ensure tracing works correctly. passiveEffectCallback(); } + return didFlushEffects; } function commitRoot(root, finishedWork) { @@ -16103,18 +17258,21 @@ function commitRoot(root, finishedWork) { isCommitting$1 = true; startCommitTimer(); - invariant( - root.current !== finishedWork, - "Cannot commit the same tree as before. This is probably a bug " + - "related to the return field. This error is likely caused by a bug " + - "in React. Please file an issue." - ); + (function() { + if (!(root.current !== finishedWork)) { + throw ReactError( + "Cannot commit the same tree as before. This is probably a bug related to the return field. This error is likely caused by a bug in React. Please file an issue." + ); + } + })(); var committedExpirationTime = root.pendingCommitExpirationTime; - invariant( - committedExpirationTime !== NoWork, - "Cannot commit an incomplete root. This error is likely caused by a " + - "bug in React. Please file an issue." - ); + (function() { + if (!(committedExpirationTime !== NoWork)) { + throw ReactError( + "Cannot commit an incomplete root. This error is likely caused by a bug in React. Please file an issue." + ); + } + })(); root.pendingCommitExpirationTime = NoWork; // Update the pending priority levels to account for the work that we are @@ -16172,12 +17330,14 @@ function commitRoot(root, finishedWork) { } } if (didError) { - invariant( - nextEffect !== null, - "Should have next effect. This error is likely caused by a bug " + - "in React. Please file an issue." - ); - captureCommitPhaseError(nextEffect, error); + (function() { + if (!(nextEffect !== null)) { + throw ReactError( + "Should have next effect. This error is likely caused by a bug in React. Please file an issue." + ); + } + })(); + captureCommitPhaseError$1(nextEffect, error); // Clean-up if (nextEffect !== null) { nextEffect = nextEffect.nextEffect; @@ -16208,12 +17368,14 @@ function commitRoot(root, finishedWork) { } } if (_didError) { - invariant( - nextEffect !== null, - "Should have next effect. This error is likely caused by a bug " + - "in React. Please file an issue." - ); - captureCommitPhaseError(nextEffect, _error); + (function() { + if (!(nextEffect !== null)) { + throw ReactError( + "Should have next effect. This error is likely caused by a bug in React. Please file an issue." + ); + } + })(); + captureCommitPhaseError$1(nextEffect, _error); // Clean-up if (nextEffect !== null) { nextEffect = nextEffect.nextEffect; @@ -16253,12 +17415,14 @@ function commitRoot(root, finishedWork) { } } if (_didError2) { - invariant( - nextEffect !== null, - "Should have next effect. This error is likely caused by a bug " + - "in React. Please file an issue." - ); - captureCommitPhaseError(nextEffect, _error2); + (function() { + if (!(nextEffect !== null)) { + throw ReactError( + "Should have next effect. This error is likely caused by a bug in React. Please file an issue." + ); + } + })(); + captureCommitPhaseError$1(nextEffect, _error2); if (nextEffect !== null) { nextEffect = nextEffect.nextEffect; } @@ -16277,11 +17441,9 @@ function commitRoot(root, finishedWork) { // here because that code is still in flux. callback = tracing.unstable_wrap(callback); } - passiveEffectCallbackHandle = scheduler.unstable_runWithPriority( - scheduler.unstable_NormalPriority, - function() { - return schedulePassiveEffects(callback); - } + passiveEffectCallbackHandle = scheduleCallback$1( + NormalPriority$1, + callback ); passiveEffectCallback = callback; } @@ -16685,20 +17847,22 @@ function workLoop(isYieldy) { } } else { // Flush asynchronous work until there's a higher priority event - while (nextUnitOfWork !== null && !shouldYieldToRenderer()) { + while (nextUnitOfWork !== null && !shouldYield$1()) { nextUnitOfWork = performUnitOfWork(nextUnitOfWork); } } } function renderRoot(root, isYieldy) { - invariant( - !isWorking, - "renderRoot was called recursively. This error is likely caused " + - "by a bug in React. Please file an issue." - ); + (function() { + if (!!isWorking) { + throw ReactError( + "renderRoot was called recursively. This error is likely caused by a bug in React. Please file an issue." + ); + } + })(); - flushPassiveEffects(); + flushPassiveEffects$1(); isWorking = true; var previousDispatcher = ReactCurrentDispatcher.current; @@ -16798,7 +17962,7 @@ function renderRoot(root, isYieldy) { if (nextUnitOfWork === null) { // This is a fatal error. didFatal = true; - onUncaughtError(thrownValue); + onUncaughtError$1(thrownValue); } else { if (enableProfilerTimer && nextUnitOfWork.mode & ProfileMode) { // Record the time spent rendering before an error was thrown. @@ -16822,12 +17986,13 @@ function renderRoot(root, isYieldy) { // TODO: we already know this isn't true in some cases. // At least this shows a nicer error message until we figure out the cause. // https://github.com/facebook/react/issues/12449#issuecomment-386727431 - invariant( - nextUnitOfWork !== null, - "Failed to replay rendering after an error. This " + - "is likely caused by a bug in React. Please file an issue " + - "with a reproducing case to help us find it." - ); + (function() { + if (!(nextUnitOfWork !== null)) { + throw ReactError( + "Failed to replay rendering after an error. This is likely caused by a bug in React. Please file an issue with a reproducing case to help us find it." + ); + } + })(); var sourceFiber = nextUnitOfWork; var returnFiber = sourceFiber.return; @@ -16839,7 +18004,7 @@ function renderRoot(root, isYieldy) { // which phase it fails in, but doesn't seem worth it. At least // for now. didFatal = true; - onUncaughtError(thrownValue); + onUncaughtError$1(thrownValue); } else { throwException( root, @@ -16900,11 +18065,13 @@ function renderRoot(root, isYieldy) { var didCompleteRoot = true; stopWorkLoopTimer(interruptedBy, didCompleteRoot); var rootWorkInProgress = root.current.alternate; - invariant( - rootWorkInProgress !== null, - "Finished root should have a work-in-progress. This error is likely " + - "caused by a bug in React. Please file an issue." - ); + (function() { + if (!(rootWorkInProgress !== null)) { + throw ReactError( + "Finished root should have a work-in-progress. This error is likely caused by a bug in React. Please file an issue." + ); + } + })(); // `nextRoot` points to the in-progress root. A non-null value indicates // that we're in the middle of an async render. Set it to null to indicate @@ -16953,32 +18120,23 @@ function renderRoot(root, isYieldy) { } } - if (isYieldy && nextLatestAbsoluteTimeoutMs !== -1) { + // Check if we should suspend this commit. + // If mostRecentEventTime is Sync, that means we didn't track any event + // times. That can happen if we retried but nothing switched from fallback + // to content. There's no reason to delay doing no work. + if (isYieldy && nextRenderDidSuspend && mostRecentEventTime !== Sync) { // The tree was suspended. var _suspendedExpirationTime2 = expirationTime; markSuspendedPriorityLevel(root, _suspendedExpirationTime2); - // Find the earliest uncommitted expiration time in the tree, including - // work that is suspended. The timeout threshold cannot be longer than - // the overall expiration. - var earliestExpirationTime = findEarliestOutstandingPriorityLevel( - root, - expirationTime - ); - var earliestExpirationTimeMs = expirationTimeToMs(earliestExpirationTime); - if (earliestExpirationTimeMs < nextLatestAbsoluteTimeoutMs) { - nextLatestAbsoluteTimeoutMs = earliestExpirationTimeMs; - } - - // Subtract the current time from the absolute timeout to get the number - // of milliseconds until the timeout. In other words, convert an absolute - // timestamp to a relative time. This is the value that is passed - // to `setTimeout`. - var currentTimeMs = expirationTimeToMs(requestCurrentTime()); - var msUntilTimeout = nextLatestAbsoluteTimeoutMs - currentTimeMs; - msUntilTimeout = msUntilTimeout < 0 ? 0 : msUntilTimeout; + var eventTimeMs = inferTimeFromExpirationTime(mostRecentEventTime); + var currentTimeMs = now$1(); + var timeElapsed = currentTimeMs - eventTimeMs; // TODO: Account for the Just Noticeable Difference + var timeoutMs = 150; + var msUntilTimeout = timeoutMs - timeElapsed; + msUntilTimeout = msUntilTimeout < 0 ? 0 : msUntilTimeout; var _rootExpirationTime2 = root.expirationTime; onSuspend( @@ -16995,7 +18153,7 @@ function renderRoot(root, isYieldy) { onComplete(root, rootWorkInProgress, expirationTime); } -function captureCommitPhaseError(sourceFiber, value) { +function captureCommitPhaseError$1(sourceFiber, value) { var expirationTime = Sync; var fiber = sourceFiber.return; while (fiber !== null) { @@ -17006,12 +18164,12 @@ function captureCommitPhaseError(sourceFiber, value) { if ( typeof ctor.getDerivedStateFromError === "function" || (typeof instance.componentDidCatch === "function" && - !isAlreadyFailedLegacyErrorBoundary(instance)) + !isAlreadyFailedLegacyErrorBoundary$1(instance)) ) { var errorInfo = createCapturedValue(value, sourceFiber); var update = createClassErrorUpdate(fiber, errorInfo, expirationTime); enqueueUpdate(fiber, update); - scheduleWork(fiber, expirationTime); + scheduleWork$1(fiber, expirationTime); return; } break; @@ -17019,7 +18177,7 @@ function captureCommitPhaseError(sourceFiber, value) { var _errorInfo = createCapturedValue(value, sourceFiber); var _update = createRootErrorUpdate(fiber, _errorInfo, expirationTime); enqueueUpdate(fiber, _update); - scheduleWork(fiber, expirationTime); + scheduleWork$1(fiber, expirationTime); return; } } @@ -17037,7 +18195,7 @@ function captureCommitPhaseError(sourceFiber, value) { expirationTime ); enqueueUpdate(rootFiber, _update2); - scheduleWork(rootFiber, expirationTime); + scheduleWork$1(rootFiber, expirationTime); } } @@ -17046,77 +18204,80 @@ function computeThreadID(expirationTime, interactionThreadID) { return expirationTime * 1000 + interactionThreadID; } -function computeExpirationForFiber(currentTime, fiber) { - var priorityLevel = scheduler.unstable_getCurrentPriorityLevel(); - +function computeExpirationForFiber$1(currentTime, fiber) { var expirationTime = void 0; - if ((fiber.mode & ConcurrentMode) === NoContext) { - // Outside of concurrent mode, updates are always synchronous. - expirationTime = Sync; - } else if (isWorking && !isCommitting$1) { - // During render phase, updates expire during as the current render. - expirationTime = nextRenderExpirationTime; + if (expirationContext !== NoWork) { + // An explicit expiration context was set; + expirationTime = expirationContext; + } else if (isWorking) { + if (isCommitting$1) { + // Updates that occur during the commit phase should have sync priority + // by default. + expirationTime = Sync; + } else { + // Updates during the render phase should expire at the same time as + // the work that is being rendered. + expirationTime = nextRenderExpirationTime; + } } else { - switch (priorityLevel) { - case scheduler.unstable_ImmediatePriority: - expirationTime = Sync; - break; - case scheduler.unstable_UserBlockingPriority: + // No explicit expiration context was set, and we're not currently + // performing work. Calculate a new expiration time. + if (fiber.mode & ConcurrentMode) { + if (isBatchingInteractiveUpdates) { + // This is an interactive update expirationTime = computeInteractiveExpiration(currentTime); - break; - case scheduler.unstable_NormalPriority: - // This is a normal, concurrent update + } else { + // This is an async update expirationTime = computeAsyncExpiration(currentTime); - break; - case scheduler.unstable_LowPriority: - case scheduler.unstable_IdlePriority: - expirationTime = Never; - break; - default: - invariant( - false, - "Unknown priority level. This error is likely caused by a bug in " + - "React. Please file an issue." - ); - } - - // If we're in the middle of rendering a tree, do not update at the same - // expiration time that is already rendering. - if (nextRoot !== null && expirationTime === nextRenderExpirationTime) { - expirationTime -= 1; + } + // If we're in the middle of rendering a tree, do not update at the same + // expiration time that is already rendering. + if (nextRoot !== null && expirationTime === nextRenderExpirationTime) { + expirationTime -= 1; + } + } else { + // This is a sync update + expirationTime = Sync; } } - - // Keep track of the lowest pending interactive expiration time. This - // allows us to synchronously flush all interactive updates - // when needed. - // TODO: Move this to renderer? - if ( - priorityLevel === scheduler.unstable_UserBlockingPriority && - (lowestPriorityPendingInteractiveExpirationTime === NoWork || - expirationTime < lowestPriorityPendingInteractiveExpirationTime) - ) { - lowestPriorityPendingInteractiveExpirationTime = expirationTime; + if (isBatchingInteractiveUpdates) { + // This is an interactive update. Keep track of the lowest pending + // interactive expiration time. This allows us to synchronously flush + // all interactive updates when needed. + if ( + lowestPriorityPendingInteractiveExpirationTime === NoWork || + expirationTime < lowestPriorityPendingInteractiveExpirationTime + ) { + lowestPriorityPendingInteractiveExpirationTime = expirationTime; + } } - return expirationTime; } -function renderDidSuspend(root, absoluteTimeoutMs, suspendedTime) { - // Schedule the timeout. - if ( - absoluteTimeoutMs >= 0 && - nextLatestAbsoluteTimeoutMs < absoluteTimeoutMs - ) { - nextLatestAbsoluteTimeoutMs = absoluteTimeoutMs; +function markRenderEventTime$1(expirationTime) { + if (expirationTime < mostRecentEventTime) { + mostRecentEventTime = expirationTime; } } -function renderDidError() { +function renderDidSuspend$1() { + nextRenderDidSuspend = true; +} + +function renderDidError$1() { nextRenderDidError = true; } -function pingSuspendedRoot(root, thenable, pingTime) { +function inferTimeFromExpirationTime(expirationTime) { + // We don't know exactly when the update was scheduled, but we can infer an + // approximate start time from the expiration time. + var earliestExpirationTimeMs = expirationTimeToMs(expirationTime); + return ( + earliestExpirationTimeMs - LOW_PRIORITY_EXPIRATION + originalStartTimeMs + ); +} + +function pingSuspendedRoot$1(root, thenable, pingTime) { // A promise that previously suspended React from committing has resolved. // If React is still suspended, try again at the previous level (pingTime). @@ -17144,27 +18305,51 @@ function pingSuspendedRoot(root, thenable, pingTime) { } } -function retryTimedOutBoundary(boundaryFiber, thenable) { +function retryTimedOutBoundary$1(boundaryFiber) { + var currentTime = requestCurrentTime$1(); + var retryTime = computeExpirationForFiber$1(currentTime, boundaryFiber); + var root = scheduleWorkToRoot(boundaryFiber, retryTime); + if (root !== null) { + markPendingPriorityLevel(root, retryTime); + var rootExpirationTime = root.expirationTime; + if (rootExpirationTime !== NoWork) { + requestWork(root, rootExpirationTime); + } + } +} + +function resolveRetryThenable$1(boundaryFiber, thenable) { // The boundary fiber (a Suspense component) previously timed out and was // rendered in its fallback state. One of the promises that suspended it has // resolved, which means at least part of the tree was likely unblocked. Try - var retryCache = boundaryFiber.stateNode; + var retryCache = void 0; + if (enableSuspenseServerRenderer) { + switch (boundaryFiber.tag) { + case SuspenseComponent: + retryCache = boundaryFiber.stateNode; + break; + case DehydratedSuspenseComponent: + retryCache = boundaryFiber.memoizedState; + break; + default: + (function() { + { + throw ReactError( + "Pinged unknown suspense boundary type. This is probably a bug in React." + ); + } + })(); + } + } else { + retryCache = boundaryFiber.stateNode; + } if (retryCache !== null) { // The thenable resolved, so we no longer need to memoize, because it will // never be thrown again. retryCache.delete(thenable); } - var currentTime = requestCurrentTime(); - var retryTime = computeExpirationForFiber(currentTime, boundaryFiber); - var root = scheduleWorkToRoot(boundaryFiber, retryTime); - if (root !== null) { - markPendingPriorityLevel(root, retryTime); - var rootExpirationTime = root.expirationTime; - if (rootExpirationTime !== NoWork) { - requestWork(root, rootExpirationTime); - } - } + retryTimedOutBoundary$1(boundaryFiber); } function scheduleWorkToRoot(fiber, expirationTime) { @@ -17253,9 +18438,20 @@ function scheduleWorkToRoot(fiber, expirationTime) { return root; } -function warnIfNotCurrentlyBatchingInDev(fiber) { +// in a test-like environment, we want to warn if dispatchAction() is +// called outside of a TestUtils.act(...)/batchedUpdates/render call. +// so we have a a step counter for when we descend/ascend from +// act() calls, and test on it for when to warn +// It's a tuple with a single value. Look for shared/createAct to +// see how we change the value inside act() calls + +function warnIfNotCurrentlyActingUpdatesInDev$1(fiber) { { - if (isRendering === false && isBatchingUpdates === false) { + if ( + isBatchingUpdates === false && + isRendering === false && + ReactShouldWarnActingUpdates.current === false + ) { warningWithoutStack$1( false, "An update to %s inside a test was not wrapped in act(...).\n\n" + @@ -17265,14 +18461,16 @@ function warnIfNotCurrentlyBatchingInDev(fiber) { "});\n" + "/* assert on the output */\n\n" + "This ensures that you're testing the behavior the user would see in the browser." + - " Learn more at https://fb.me/react-wrap-tests-with-act", - getComponentName(fiber.type) + " Learn more at https://fb.me/react-wrap-tests-with-act" + + "%s", + getComponentName(fiber.type), + getStackByFiberInDevAndProd(fiber) ); } } } -function scheduleWork(fiber, expirationTime) { +function scheduleWork$1(fiber, expirationTime) { var root = scheduleWorkToRoot(fiber, expirationTime); if (root === null) { { @@ -17315,13 +18513,28 @@ function scheduleWork(fiber, expirationTime) { if (nestedUpdateCount > NESTED_UPDATE_LIMIT) { // Reset this back to zero so subsequent updates don't throw. nestedUpdateCount = 0; - invariant( - false, - "Maximum update depth exceeded. This can happen when a " + - "component repeatedly calls setState inside " + - "componentWillUpdate or componentDidUpdate. React limits " + - "the number of nested updates to prevent infinite loops." - ); + (function() { + { + throw ReactError( + "Maximum update depth exceeded. This can happen when a component repeatedly calls setState inside componentWillUpdate or componentDidUpdate. React limits the number of nested updates to prevent infinite loops." + ); + } + })(); + } + { + if ( + isInPassiveEffectDEV && + nestedPassiveEffectCountDEV > NESTED_PASSIVE_UPDATE_LIMIT + ) { + nestedPassiveEffectCountDEV = 0; + warning$1( + false, + "Maximum update depth exceeded. This can happen when a " + + "component calls setState inside useEffect, but " + + "useEffect either doesn't have a dependency array, or " + + "one of the dependencies changes on every render." + ); + } } } @@ -17343,10 +18556,11 @@ var unhandledError = null; var isBatchingUpdates = false; var isUnbatchingUpdates = false; +var isBatchingInteractiveUpdates = false; var completedBatches = null; -var originalStartTimeMs = now$$1(); +var originalStartTimeMs = now$1(); var currentRendererTime = msToExpirationTime(originalStartTimeMs); var currentSchedulerTime = currentRendererTime; @@ -17355,8 +18569,17 @@ var NESTED_UPDATE_LIMIT = 50; var nestedUpdateCount = 0; var lastCommittedRootDuringThisBatch = null; +// Similar, but for useEffect infinite loops. These are DEV-only. +var NESTED_PASSIVE_UPDATE_LIMIT = 50; +var nestedPassiveEffectCountDEV = void 0; +var isInPassiveEffectDEV = void 0; +{ + nestedPassiveEffectCountDEV = 0; + isInPassiveEffectDEV = false; +} + function recomputeCurrentRendererTime() { - var currentTimeMs = now$$1() - originalStartTimeMs; + var currentTimeMs = now$1() - originalStartTimeMs; currentRendererTime = msToExpirationTime(currentTimeMs); } @@ -17370,7 +18593,7 @@ function scheduleCallbackWithExpirationTime(root, expirationTime) { if (callbackID !== null) { // Existing callback has insufficient timeout. Cancel and schedule a // new one. - cancelDeferredCallback$$1(callbackID); + cancelCallback$1(callbackID); } } // The request callback timer is already running. Don't start a new one. @@ -17379,10 +18602,11 @@ function scheduleCallbackWithExpirationTime(root, expirationTime) { } callbackExpirationTime = expirationTime; - var currentMs = now$$1() - originalStartTimeMs; + var currentMs = now$1() - originalStartTimeMs; var expirationTimeMs = expirationTimeToMs(expirationTime); var timeout = expirationTimeMs - currentMs; - callbackID = scheduleDeferredCallback$$1(performAsyncWork, { + var priorityLevel = getCurrentPriorityLevel$1(); + callbackID = scheduleCallback$1(priorityLevel, performAsyncWork, { timeout: timeout }); } @@ -17408,7 +18632,7 @@ function onSuspend( msUntilTimeout ) { root.expirationTime = rootExpirationTime; - if (msUntilTimeout === 0 && !shouldYieldToRenderer()) { + if (msUntilTimeout === 0 && (disableYielding || !shouldYield$1())) { // Don't wait an additional tick. Commit the tree immediately. root.pendingCommitExpirationTime = suspendedExpirationTime; root.finishedWork = finishedWork; @@ -17434,7 +18658,7 @@ function onTimeout(root, finishedWork, suspendedExpirationTime) { // because we're at the top of a timer event. recomputeCurrentRendererTime(); currentSchedulerTime = currentRendererTime; - flushRoot(root, suspendedExpirationTime); + flushRoot$1(root, suspendedExpirationTime); } function onCommit(root, expirationTime) { @@ -17442,7 +18666,7 @@ function onCommit(root, expirationTime) { root.finishedWork = null; } -function requestCurrentTime() { +function requestCurrentTime$1() { // requestCurrentTime is called by the scheduler to compute an expiration // time. // @@ -17554,11 +18778,13 @@ function findHighestPriorityRoot() { // TODO: This check is redudant, but Flow is confused by the branch // below where we set lastScheduledRoot to null, even though we break // from the loop right after. - invariant( - previousScheduledRoot !== null && lastScheduledRoot !== null, - "Should have a previous and last root. This error is likely " + - "caused by a bug in React. Please file an issue." - ); + (function() { + if (!(previousScheduledRoot !== null && lastScheduledRoot !== null)) { + throw ReactError( + "Should have a previous and last root. This error is likely caused by a bug in React. Please file an issue." + ); + } + })(); if (root === root.nextScheduledRoot) { // This is the only root in the list. root.nextScheduledRoot = null; @@ -17605,55 +18831,35 @@ function findHighestPriorityRoot() { nextFlushedExpirationTime = highestPriorityWork; } -// TODO: This wrapper exists because many of the older tests (the ones that use -// flushDeferredPri) rely on the number of times `shouldYield` is called. We -// should get rid of it. -var didYield = false; -function shouldYieldToRenderer() { - if (didYield) { - return true; - } - if (shouldYield$$1()) { - didYield = true; - return true; - } - return false; -} - -function performAsyncWork() { - try { - if (!shouldYieldToRenderer()) { - // The callback timed out. That means at least one update has expired. - // Iterate through the root schedule. If they contain expired work, set - // the next render expiration time to the current time. This has the effect - // of flushing all expired work in a single batch, instead of flushing each - // level one at a time. - if (firstScheduledRoot !== null) { - recomputeCurrentRendererTime(); - var root = firstScheduledRoot; - do { - didExpireAtExpirationTime(root, currentRendererTime); - // The root schedule is circular, so this is never null. - root = root.nextScheduledRoot; - } while (root !== firstScheduledRoot); - } +function performAsyncWork(didTimeout) { + if (didTimeout) { + // The callback timed out. That means at least one update has expired. + // Iterate through the root schedule. If they contain expired work, set + // the next render expiration time to the current time. This has the effect + // of flushing all expired work in a single batch, instead of flushing each + // level one at a time. + if (firstScheduledRoot !== null) { + recomputeCurrentRendererTime(); + var root = firstScheduledRoot; + do { + didExpireAtExpirationTime(root, currentRendererTime); + // The root schedule is circular, so this is never null. + root = root.nextScheduledRoot; + } while (root !== firstScheduledRoot); } - performWork(NoWork, true); - } finally { - didYield = false; } -} -function performSyncWork() { - performWork(Sync, false); -} - -function performWork(minExpirationTime, isYieldy) { // Keep working on roots until there's no more work, or until there's a higher // priority event. findHighestPriorityRoot(); - if (isYieldy) { + if (disableYielding) { + // Just do it all + while (nextFlushedRoot !== null && nextFlushedExpirationTime !== NoWork) { + performWorkOnRoot(nextFlushedRoot, nextFlushedExpirationTime, false); + findHighestPriorityRoot(); + } + } else { recomputeCurrentRendererTime(); currentSchedulerTime = currentRendererTime; @@ -17666,8 +18872,7 @@ function performWork(minExpirationTime, isYieldy) { while ( nextFlushedRoot !== null && nextFlushedExpirationTime !== NoWork && - minExpirationTime <= nextFlushedExpirationTime && - !(didYield && currentRendererTime > nextFlushedExpirationTime) + !(shouldYield$1() && currentRendererTime > nextFlushedExpirationTime) ) { performWorkOnRoot( nextFlushedRoot, @@ -17678,25 +18883,48 @@ function performWork(minExpirationTime, isYieldy) { recomputeCurrentRendererTime(); currentSchedulerTime = currentRendererTime; } - } else { - while ( - nextFlushedRoot !== null && - nextFlushedExpirationTime !== NoWork && - minExpirationTime <= nextFlushedExpirationTime - ) { - performWorkOnRoot(nextFlushedRoot, nextFlushedExpirationTime, false); - findHighestPriorityRoot(); - } } // We're done flushing work. Either we ran out of time in this callback, // or there's no more work left with sufficient priority. // If we're inside a callback, set this to false since we just completed it. - if (isYieldy) { - callbackExpirationTime = NoWork; - callbackID = null; + callbackExpirationTime = NoWork; + callbackID = null; + + // If there's work left over, schedule a new callback. + if (nextFlushedExpirationTime !== NoWork) { + scheduleCallbackWithExpirationTime( + nextFlushedRoot, + nextFlushedExpirationTime + ); + } + + // Clean-up. + finishRendering(); +} + +function performSyncWork() { + performWork(Sync); +} + +function performWork(minExpirationTime) { + // Keep working on roots until there's no more work, or until there's a higher + // priority event. + findHighestPriorityRoot(); + + while ( + nextFlushedRoot !== null && + nextFlushedExpirationTime !== NoWork && + minExpirationTime <= nextFlushedExpirationTime + ) { + performWorkOnRoot(nextFlushedRoot, nextFlushedExpirationTime, false); + findHighestPriorityRoot(); } + + // We're done flushing work. Either we ran out of time in this callback, + // or there's no more work left with sufficient priority. + // If there's work left over, schedule a new callback. if (nextFlushedExpirationTime !== NoWork) { scheduleCallbackWithExpirationTime( @@ -17709,12 +18937,14 @@ function performWork(minExpirationTime, isYieldy) { finishRendering(); } -function flushRoot(root, expirationTime) { - invariant( - !isRendering, - "work.commit(): Cannot commit while already rendering. This likely " + - "means you attempted to commit from inside a lifecycle method." - ); +function flushRoot$1(root, expirationTime) { + (function() { + if (!!isRendering) { + throw ReactError( + "work.commit(): Cannot commit while already rendering. This likely means you attempted to commit from inside a lifecycle method." + ); + } + })(); // Perform work on root as if the given expiration time is the current time. // This has the effect of synchronously flushing all work up to and // including the given time. @@ -17729,6 +18959,12 @@ function finishRendering() { nestedUpdateCount = 0; lastCommittedRootDuringThisBatch = null; + { + if (rootWithPendingPassiveEffects === null) { + nestedPassiveEffectCountDEV = 0; + } + } + if (completedBatches !== null) { var batches = completedBatches; completedBatches = null; @@ -17754,11 +18990,13 @@ function finishRendering() { } function performWorkOnRoot(root, expirationTime, isYieldy) { - invariant( - !isRendering, - "performWorkOnRoot was called recursively. This error is likely caused " + - "by a bug in React. Please file an issue." - ); + (function() { + if (!!isRendering) { + throw ReactError( + "performWorkOnRoot was called recursively. This error is likely caused by a bug in React. Please file an issue." + ); + } + })(); isRendering = true; @@ -17811,7 +19049,7 @@ function performWorkOnRoot(root, expirationTime, isYieldy) { if (_finishedWork !== null) { // We've completed the root. Check the if we should yield one more time // before committing. - if (!shouldYieldToRenderer()) { + if (!shouldYield$1()) { // Still time left. Commit the root. completeRoot$1(root, _finishedWork, expirationTime); } else { @@ -17858,20 +19096,17 @@ function completeRoot$1(root, finishedWork, expirationTime) { lastCommittedRootDuringThisBatch = root; nestedUpdateCount = 0; } - scheduler.unstable_runWithPriority( - scheduler.unstable_ImmediatePriority, - function() { - commitRoot(root, finishedWork); - } - ); + commitRoot(root, finishedWork); } -function onUncaughtError(error) { - invariant( - nextFlushedRoot !== null, - "Should be working on a root. This error is likely caused by a bug in " + - "React. Please file an issue." - ); +function onUncaughtError$1(error) { + (function() { + if (!(nextFlushedRoot !== null)) { + throw ReactError( + "Should be working on a root. This error is likely caused by a bug in React. Please file an issue." + ); + } + })(); // Unschedule this root so we don't work on it again until there's // another update. nextFlushedRoot.expirationTime = NoWork; @@ -17883,7 +19118,7 @@ function onUncaughtError(error) { // TODO: Batching should be implemented at the renderer level, not inside // the reconciler. -function batchedUpdates$1(fn, a) { +function batchedUpdates$2(fn, a) { var previousIsBatchingUpdates = isBatchingUpdates; isBatchingUpdates = true; try { @@ -17896,7 +19131,10 @@ function batchedUpdates$1(fn, a) { } } -function interactiveUpdates$1(fn, a, b) { +function interactiveUpdates$2(fn, a, b, c) { + if (isBatchingInteractiveUpdates) { + return fn(a, b, c); + } // If there are any pending interactive updates, synchronously flush them. // This needs to happen before we read any handlers, because the effect of // the previous event may influence which handlers are called during @@ -17907,37 +19145,2003 @@ function interactiveUpdates$1(fn, a, b) { lowestPriorityPendingInteractiveExpirationTime !== NoWork ) { // Synchronously flush pending interactive updates. - performWork(lowestPriorityPendingInteractiveExpirationTime, false); + performWork(lowestPriorityPendingInteractiveExpirationTime); lowestPriorityPendingInteractiveExpirationTime = NoWork; } + var previousIsBatchingInteractiveUpdates = isBatchingInteractiveUpdates; var previousIsBatchingUpdates = isBatchingUpdates; + isBatchingInteractiveUpdates = true; isBatchingUpdates = true; try { - return scheduler.unstable_runWithPriority( - scheduler.unstable_UserBlockingPriority, - function() { - return fn(a, b); + return fn(a, b, c); + } finally { + isBatchingInteractiveUpdates = previousIsBatchingInteractiveUpdates; + isBatchingUpdates = previousIsBatchingUpdates; + if (!isBatchingUpdates && !isRendering) { + performSyncWork(); + } + } +} + +function flushInteractiveUpdates$2() { + if ( + !isRendering && + lowestPriorityPendingInteractiveExpirationTime !== NoWork + ) { + // Synchronously flush pending interactive updates. + performWork(lowestPriorityPendingInteractiveExpirationTime); + lowestPriorityPendingInteractiveExpirationTime = NoWork; + } +} + +// TODO: Ahaha Andrew is bad at spellling +// DEV stuff +var ReactCurrentDispatcher$2 = ReactSharedInternals.ReactCurrentDispatcher; +var ReactCurrentOwner$4 = ReactSharedInternals.ReactCurrentOwner; +var ReactShouldWarnActingUpdates$1 = + ReactSharedInternals.ReactShouldWarnActingUpdates; + +var NotWorking = 0; +var BatchedPhase = 1; +var LegacyUnbatchedPhase = 2; +var RenderPhase = 4; +var CommitPhase = 5; + +var RootIncomplete = 0; +var RootErrored = 1; +var RootSuspended = 2; +var RootCompleted = 3; + +// The phase of work we're currently in +var workPhase = NotWorking; +// The root we're working on +var workInProgressRoot = null; +// The fiber we're working on +var workInProgress = null; +// The expiration time we're rendering +var renderExpirationTime$1 = NoWork; +// Whether to root completed, errored, suspended, etc. +var workInProgressRootExitStatus = RootIncomplete; +// Most recent event time among processed updates during this render. +// This is conceptually a time stamp but expressed in terms of an ExpirationTime +// because we deal mostly with expiration times in the hot path, so this avoids +// the conversion happening in the hot path. +var workInProgressRootMostRecentEventTime = Sync; + +var nextEffect$1 = null; +var hasUncaughtError = false; +var firstUncaughtError = null; +var legacyErrorBoundariesThatAlreadyFailed$1 = null; + +var rootDoesHavePassiveEffects = false; +var rootWithPendingPassiveEffects$1 = null; +var pendingPassiveEffectsExpirationTime = NoWork; + +var rootsWithPendingDiscreteUpdates = null; + +// Use these to prevent an infinite loop of nested updates +var NESTED_UPDATE_LIMIT$1 = 50; +var nestedUpdateCount$1 = 0; +var rootWithNestedUpdates = null; + +var NESTED_PASSIVE_UPDATE_LIMIT$1 = 50; +var nestedPassiveUpdateCount = 0; + +var interruptedBy$1 = null; + +// Expiration times are computed by adding to the current time (the start +// time). However, if two updates are scheduled within the same event, we +// should treat their start times as simultaneous, even if the actual clock +// time has advanced between the first and second call. + +// In other words, because expiration times determine how updates are batched, +// we want all updates of like priority that occur within the same event to +// receive the same expiration time. Otherwise we get tearing. +var initialTimeMs = now(); +var currentEventTime = NoWork; + +function requestCurrentTime$2() { + if (workPhase === RenderPhase || workPhase === CommitPhase) { + // We're inside React, so it's fine to read the actual time. + return msToExpirationTime(now() - initialTimeMs); + } + // We're not inside React, so we may be in the middle of a browser event. + if (currentEventTime !== NoWork) { + // Use the same start time for all updates until we enter React again. + return currentEventTime; + } + // This is the first update since React yielded. Compute a new start time. + currentEventTime = msToExpirationTime(now() - initialTimeMs); + return currentEventTime; +} + +function computeExpirationForFiber$2(currentTime, fiber) { + if ((fiber.mode & ConcurrentMode) === NoContext) { + return Sync; + } + + if (workPhase === RenderPhase) { + // Use whatever time we're already rendering + return renderExpirationTime$1; + } + + // Compute an expiration time based on the Scheduler priority. + var expirationTime = void 0; + var priorityLevel = getCurrentPriorityLevel(); + switch (priorityLevel) { + case ImmediatePriority: + expirationTime = Sync; + break; + case UserBlockingPriority: + // TODO: Rename this to computeUserBlockingExpiration + expirationTime = computeInteractiveExpiration(currentTime); + break; + case NormalPriority: + case LowPriority: + // TODO: Handle LowPriority + // TODO: Rename this to... something better. + expirationTime = computeAsyncExpiration(currentTime); + break; + case IdlePriority: + expirationTime = Never; + break; + default: + (function() { + { + throw ReactError("Expected a valid priority level"); + } + })(); + } + + // If we're in the middle of rendering a tree, do not update at the same + // expiration time that is already rendering. + if ( + workInProgressRoot !== null && + expirationTime === renderExpirationTime$1 + ) { + // This is a trick to move this update into a separate batch + expirationTime -= 1; + } + + return expirationTime; +} + +function scheduleUpdateOnFiber(fiber, expirationTime) { + checkForNestedUpdates(); + warnAboutInvalidUpdatesOnClassComponentsInDEV(fiber); + + var root = markUpdateTimeFromFiberToRoot(fiber, expirationTime); + if (root === null) { + warnAboutUpdateOnUnmountedFiberInDEV(fiber); + return; + } + + root.pingTime = NoWork; + + checkForInterruption(fiber, expirationTime); + recordScheduleUpdate(); + + if (expirationTime === Sync) { + if (workPhase === LegacyUnbatchedPhase) { + // This is a legacy edge case. The initial mount of a ReactDOM.render-ed + // root inside of batchedUpdates should be synchronous, but layout updates + // should be deferred until the end of the batch. + var callback = renderRoot$1(root, Sync, true); + while (callback !== null) { + callback = callback(true); + } + } else { + scheduleCallbackForRoot(root, ImmediatePriority, Sync); + if (workPhase === NotWorking) { + // Flush the synchronous work now, wnless we're already working or inside + // a batch. This is intentionally inside scheduleUpdateOnFiber instead of + // scheduleCallbackForFiber to preserve the ability to schedule a callback + // without immediately flushing it. We only do this for user-initated + // updates, to preserve historical behavior of sync mode. + flushImmediateQueue(); + } + } + } else { + // TODO: computeExpirationForFiber also reads the priority. Pass the + // priority as an argument to that function and this one. + var priorityLevel = getCurrentPriorityLevel(); + if (priorityLevel === UserBlockingPriority) { + // This is the result of a discrete event. Track the lowest priority + // discrete update per root so we can flush them early, if needed. + if (rootsWithPendingDiscreteUpdates === null) { + rootsWithPendingDiscreteUpdates = new Map([[root, expirationTime]]); + } else { + var lastDiscreteTime = rootsWithPendingDiscreteUpdates.get(root); + if ( + lastDiscreteTime === undefined || + lastDiscreteTime > expirationTime + ) { + rootsWithPendingDiscreteUpdates.set(root, expirationTime); + } + } + } + scheduleCallbackForRoot(root, priorityLevel, expirationTime); + } +} +var scheduleWork$2 = scheduleUpdateOnFiber; + +// This is split into a separate function so we can mark a fiber with pending +// work without treating it as a typical update that originates from an event; +// e.g. retrying a Suspense boundary isn't an update, but it does schedule work +// on a fiber. +function markUpdateTimeFromFiberToRoot(fiber, expirationTime) { + // Update the source fiber's expiration time + if (fiber.expirationTime < expirationTime) { + fiber.expirationTime = expirationTime; + } + var alternate = fiber.alternate; + if (alternate !== null && alternate.expirationTime < expirationTime) { + alternate.expirationTime = expirationTime; + } + // Walk the parent path to the root and update the child expiration time. + var node = fiber.return; + var root = null; + if (node === null && fiber.tag === HostRoot) { + root = fiber.stateNode; + } else { + while (node !== null) { + alternate = node.alternate; + if (node.childExpirationTime < expirationTime) { + node.childExpirationTime = expirationTime; + if ( + alternate !== null && + alternate.childExpirationTime < expirationTime + ) { + alternate.childExpirationTime = expirationTime; + } + } else if ( + alternate !== null && + alternate.childExpirationTime < expirationTime + ) { + alternate.childExpirationTime = expirationTime; + } + if (node.return === null && node.tag === HostRoot) { + root = node.stateNode; + break; + } + node = node.return; + } + } + + if (root !== null) { + // Update the first and last pending expiration times in this root + var firstPendingTime = root.firstPendingTime; + if (expirationTime > firstPendingTime) { + root.firstPendingTime = expirationTime; + } + var lastPendingTime = root.lastPendingTime; + if (lastPendingTime === NoWork || expirationTime < lastPendingTime) { + root.lastPendingTime = expirationTime; + } + } + + return root; +} + +// Use this function, along with runRootCallback, to ensure that only a single +// callback per root is scheduled. It's still possible to call renderRoot +// directly, but scheduling via this function helps avoid excessive callbacks. +// It works by storing the callback node and expiration time on the root. When a +// new callback comes in, it compares the expiration time to determine if it +// should cancel the previous one. It also relies on commitRoot scheduling a +// callback to render the next level, because that means we don't need a +// separate callback per expiration time. +function scheduleCallbackForRoot(root, priorityLevel, expirationTime) { + var existingCallbackExpirationTime = root.callbackExpirationTime; + if (existingCallbackExpirationTime < expirationTime) { + // New callback has higher priority than the existing one. + var existingCallbackNode = root.callbackNode; + if (existingCallbackNode !== null) { + cancelCallback(existingCallbackNode); + } + root.callbackExpirationTime = expirationTime; + var options = + expirationTime === Sync + ? null + : { timeout: expirationTimeToMs(expirationTime) }; + root.callbackNode = scheduleCallback( + priorityLevel, + runRootCallback.bind( + null, + root, + renderRoot$1.bind(null, root, expirationTime) + ), + options + ); + if ( + enableUserTimingAPI && + expirationTime !== Sync && + workPhase !== RenderPhase && + workPhase !== CommitPhase + ) { + // Scheduled an async callback, and we're not already working. Add an + // entry to the flamegraph that shows we're waiting for a callback + // to fire. + startRequestCallbackTimer(); + } + } + + var timeoutHandle = root.timeoutHandle; + if (timeoutHandle !== noTimeout) { + // The root previous suspended and scheduled a timeout to commit a fallback + // state. Now that we have additional work, cancel the timeout. + root.timeoutHandle = noTimeout; + // $FlowFixMe Complains noTimeout is not a TimeoutID, despite the check above + cancelTimeout(timeoutHandle); + } + + // Add the current set of interactions to the pending set associated with + // this root. + schedulePendingInteraction(root, expirationTime); +} + +function runRootCallback(root, callback, isSync) { + var prevCallbackNode = root.callbackNode; + var continuation = null; + try { + continuation = callback(isSync); + if (continuation !== null) { + return runRootCallback.bind(null, root, continuation); + } else { + return null; + } + } finally { + // If the callback exits without returning a continuation, remove the + // corresponding callback node from the root. Unless the callback node + // has changed, which implies that it was already cancelled by a high + // priority update. + if (continuation === null && prevCallbackNode === root.callbackNode) { + root.callbackNode = null; + root.callbackExpirationTime = NoWork; + } + } +} + +function flushInteractiveUpdates$3() { + if (workPhase === RenderPhase || workPhase === CommitPhase) { + // Can't synchronously flush interactive updates if React is already + // working. This is currently a no-op. + // TODO: Should we fire a warning? This happens if you synchronously invoke + // an input event inside an effect, like with `element.click()`. + return; + } + flushPendingDiscreteUpdates(); +} + +function resolveLocksOnRoot(root, expirationTime) { + var firstBatch = root.firstBatch; + if ( + firstBatch !== null && + firstBatch._defer && + firstBatch._expirationTime >= expirationTime + ) { + root.finishedWork = root.current.alternate; + root.pendingCommitExpirationTime = expirationTime; + scheduleCallback(NormalPriority, function() { + firstBatch._onComplete(); + return null; + }); + return true; + } else { + return false; + } +} + +function interactiveUpdates$3(fn, a, b, c) { + if (workPhase === NotWorking) { + // TODO: Remove this call. Instead of doing this automatically, the caller + // should explicitly call flushInteractiveUpdates. + flushPendingDiscreteUpdates(); + } + return runWithPriority(UserBlockingPriority, fn.bind(null, a, b, c)); +} + +function flushPendingDiscreteUpdates() { + if (rootsWithPendingDiscreteUpdates !== null) { + // For each root with pending discrete updates, schedule a callback to + // immediately flush them. + var roots = rootsWithPendingDiscreteUpdates; + rootsWithPendingDiscreteUpdates = null; + roots.forEach(function(expirationTime, root) { + scheduleCallback( + ImmediatePriority, + renderRoot$1.bind(null, root, expirationTime) + ); + }); + // Now flush the immediate queue. + flushImmediateQueue(); + } +} + +function batchedUpdates$3(fn, a) { + if (workPhase !== NotWorking) { + // We're already working, or inside a batch, so batchedUpdates is a no-op. + return fn(a); + } + workPhase = BatchedPhase; + try { + return fn(a); + } finally { + workPhase = NotWorking; + // Flush the immediate callbacks that were scheduled during this batch + flushImmediateQueue(); + } +} + +function prepareFreshStack(root, expirationTime) { + root.pendingCommitExpirationTime = NoWork; + + if (workInProgress !== null) { + var interruptedWork = workInProgress.return; + while (interruptedWork !== null) { + unwindInterruptedWork(interruptedWork); + interruptedWork = interruptedWork.return; + } + } + workInProgressRoot = root; + workInProgress = createWorkInProgress(root.current, null, expirationTime); + renderExpirationTime$1 = expirationTime; + workInProgressRootExitStatus = RootIncomplete; + workInProgressRootMostRecentEventTime = Sync; + + { + ReactStrictModeWarnings.discardPendingWarnings(); + } +} + +function renderRoot$1(root, expirationTime, isSync) { + (function() { + if (!(workPhase !== RenderPhase && workPhase !== CommitPhase)) { + throw ReactError("Should not already be working."); + } + })(); + + if (enableUserTimingAPI && expirationTime !== Sync) { + var didExpire = isSync; + var timeoutMs = expirationTimeToMs(expirationTime); + stopRequestCallbackTimer(didExpire, timeoutMs); + } + + if (root.firstPendingTime < expirationTime) { + // If there's no work left at this expiration time, exit immediately. This + // happens when multiple callbacks are scheduled for a single root, but an + // earlier callback flushes the work of a later one. + return null; + } + + if (root.pendingCommitExpirationTime === expirationTime) { + // There's already a pending commit at this expiration time. + root.pendingCommitExpirationTime = NoWork; + return commitRoot$1.bind(null, root, expirationTime); + } + + flushPassiveEffects$2(); + + // If the root or expiration time have changed, throw out the existing stack + // and prepare a fresh one. Otherwise we'll continue where we left off. + if ( + root !== workInProgressRoot || + expirationTime !== renderExpirationTime$1 + ) { + prepareFreshStack(root, expirationTime); + startWorkOnPendingInteraction(root, expirationTime); + } + + // If we have a work-in-progress fiber, it means there's still work to do + // in this root. + if (workInProgress !== null) { + var prevWorkPhase = workPhase; + workPhase = RenderPhase; + var prevDispatcher = ReactCurrentDispatcher$2.current; + if (prevDispatcher === null) { + // The React isomorphic package does not include a default dispatcher. + // Instead the first renderer will lazily attach one, in order to give + // nicer error messages. + prevDispatcher = ContextOnlyDispatcher; + } + ReactCurrentDispatcher$2.current = ContextOnlyDispatcher; + var prevInteractions = null; + if (enableSchedulerTracing) { + prevInteractions = tracing.__interactionsRef.current; + tracing.__interactionsRef.current = root.memoizedInteractions; + } + + startWorkLoopTimer(workInProgress); + + // TODO: Fork renderRoot into renderRootSync and renderRootAsync + if (isSync) { + if (expirationTime !== Sync) { + // An async update expired. There may be other expired updates on + // this root. We should render all the expired work in a + // single batch. + var currentTime = requestCurrentTime$2(); + if (currentTime < expirationTime) { + // Restart at the current time. + workPhase = prevWorkPhase; + resetContextDependences(); + ReactCurrentDispatcher$2.current = prevDispatcher; + if (enableSchedulerTracing) { + tracing.__interactionsRef.current = prevInteractions; + } + return renderRoot$1.bind(null, root, currentTime); + } + } + } else { + // Since we know we're in a React event, we can clear the current + // event time. The next update will compute a new event time. + currentEventTime = NoWork; + } + + do { + try { + if (isSync) { + workLoopSync(); + } else { + workLoop$1(); + } + break; + } catch (thrownValue) { + // Reset module-level state that was set during the render phase. + resetContextDependences(); + resetHooks(); + + var sourceFiber = workInProgress; + if (sourceFiber === null || sourceFiber.return === null) { + // Expected to be working on a non-root fiber. This is a fatal error + // because there's no ancestor that can handle it; the root is + // supposed to capture all errors that weren't caught by an error + // boundary. + prepareFreshStack(root, expirationTime); + workPhase = prevWorkPhase; + throw thrownValue; + } + + if (enableProfilerTimer && sourceFiber.mode & ProfileMode) { + // Record the time spent rendering before an error was thrown. This + // avoids inaccurate Profiler durations in the case of a + // suspended render. + stopProfilerTimerIfRunningAndRecordDelta(sourceFiber, true); + } + + var returnFiber = sourceFiber.return; + throwException( + root, + returnFiber, + sourceFiber, + thrownValue, + renderExpirationTime$1 + ); + workInProgress = completeUnitOfWork$1(sourceFiber); + } + } while (true); + + workPhase = prevWorkPhase; + resetContextDependences(); + ReactCurrentDispatcher$2.current = prevDispatcher; + if (enableSchedulerTracing) { + tracing.__interactionsRef.current = prevInteractions; + } + + if (workInProgress !== null) { + // There's still work left over. Return a continuation. + stopInterruptedWorkLoopTimer(); + if (expirationTime !== Sync) { + startRequestCallbackTimer(); + } + return renderRoot$1.bind(null, root, expirationTime); + } + } + + // We now have a consistent tree. The next step is either to commit it, or, if + // something suspended, wait to commit it after a timeout. + stopFinishedWorkLoopTimer(); + + var isLocked = resolveLocksOnRoot(root, expirationTime); + if (isLocked) { + // This root has a lock that prevents it from committing. Exit. If we begin + // work on the root again, without any intervening updates, it will finish + // without doing additional work. + return null; + } + + // Set this to null to indicate there's no in-progress render. + workInProgressRoot = null; + + switch (workInProgressRootExitStatus) { + case RootIncomplete: { + (function() { + { + throw ReactError("Should have a work-in-progress."); + } + })(); + } + // Flow knows about invariant, so it compains if I add a break statement, + // but eslint doesn't know about invariant, so it complains if I do. + // eslint-disable-next-line no-fallthrough + case RootErrored: { + // An error was thrown. First check if there is lower priority work + // scheduled on this root. + var lastPendingTime = root.lastPendingTime; + if (root.lastPendingTime < expirationTime) { + // There's lower priority work. Before raising the error, try rendering + // at the lower priority to see if it fixes it. Use a continuation to + // maintain the existing priority and position in the queue. + return renderRoot$1.bind(null, root, lastPendingTime); + } + if (!isSync) { + // If we're rendering asynchronously, it's possible the error was + // caused by tearing due to a mutation during an event. Try rendering + // one more time without yiedling to events. + prepareFreshStack(root, expirationTime); + scheduleCallback( + ImmediatePriority, + renderRoot$1.bind(null, root, expirationTime) + ); + return null; + } + // If we're already rendering synchronously, commit the root in its + // errored state. + return commitRoot$1.bind(null, root, expirationTime); + } + case RootSuspended: { + if (!isSync) { + var _lastPendingTime = root.lastPendingTime; + if (root.lastPendingTime < expirationTime) { + // There's lower priority work. It might be unsuspended. Try rendering + // at that level. + return renderRoot$1.bind(null, root, _lastPendingTime); + } + // If workInProgressRootMostRecentEventTime is Sync, that means we didn't + // track any event times. That can happen if we retried but nothing switched + // from fallback to content. There's no reason to delay doing no work. + if (workInProgressRootMostRecentEventTime !== Sync) { + var msUntilTimeout = computeMsUntilTimeout( + workInProgressRootMostRecentEventTime + ); + if (msUntilTimeout > 0) { + // The render is suspended, it hasn't timed out, and there's no lower + // priority work to do. Instead of committing the fallback + // immediately, wait for more data to arrive. + root.timeoutHandle = scheduleTimeout( + commitRoot$1.bind(null, root, expirationTime), + msUntilTimeout + ); + return null; + } + } + } + // The work expired. Commit immediately. + return commitRoot$1.bind(null, root, expirationTime); + } + case RootCompleted: { + // The work completed. Ready to commit. + return commitRoot$1.bind(null, root, expirationTime); + } + default: { + (function() { + { + throw ReactError("Unknown root exit status."); + } + })(); + } + } +} + +function markRenderEventTime$2(expirationTime) { + if (expirationTime < workInProgressRootMostRecentEventTime) { + workInProgressRootMostRecentEventTime = expirationTime; + } +} + +function renderDidSuspend$2() { + if (workInProgressRootExitStatus === RootIncomplete) { + workInProgressRootExitStatus = RootSuspended; + } +} + +function renderDidError$2() { + if ( + workInProgressRootExitStatus === RootIncomplete || + workInProgressRootExitStatus === RootSuspended + ) { + workInProgressRootExitStatus = RootErrored; + } +} + +function inferTimeFromExpirationTime$1(expirationTime) { + // We don't know exactly when the update was scheduled, but we can infer an + // approximate start time from the expiration time. + var earliestExpirationTimeMs = expirationTimeToMs(expirationTime); + return earliestExpirationTimeMs - LOW_PRIORITY_EXPIRATION + initialTimeMs; +} + +function workLoopSync() { + // Already timed out, so perform work without checking if we need to yield. + while (workInProgress !== null) { + workInProgress = performUnitOfWork$1(workInProgress); + } +} + +function workLoop$1() { + // Perform work until Scheduler asks us to yield + while (workInProgress !== null && !shouldYield()) { + workInProgress = performUnitOfWork$1(workInProgress); + } +} + +function performUnitOfWork$1(unitOfWork) { + // The current, flushed, state of this fiber is the alternate. Ideally + // nothing should rely on this, but relying on it here means that we don't + // need an additional field on the work in progress. + var current$$1 = unitOfWork.alternate; + + startWorkTimer(unitOfWork); + setCurrentFiber(unitOfWork); + + var next = void 0; + if (enableProfilerTimer && (unitOfWork.mode & ProfileMode) !== NoContext) { + startProfilerTimer(unitOfWork); + next = beginWork$1(current$$1, unitOfWork, renderExpirationTime$1); + stopProfilerTimerIfRunningAndRecordDelta(unitOfWork, true); + } else { + next = beginWork$1(current$$1, unitOfWork, renderExpirationTime$1); + } + + resetCurrentFiber(); + unitOfWork.memoizedProps = unitOfWork.pendingProps; + if (next === null) { + // If this doesn't spawn new work, complete the current work. + next = completeUnitOfWork$1(unitOfWork); + } + + ReactCurrentOwner$4.current = null; + return next; +} + +function completeUnitOfWork$1(unitOfWork) { + // Attempt to complete the current unit of work, then move to the next + // sibling. If there are no more siblings, return to the parent fiber. + workInProgress = unitOfWork; + do { + // The current, flushed, state of this fiber is the alternate. Ideally + // nothing should rely on this, but relying on it here means that we don't + // need an additional field on the work in progress. + var current$$1 = workInProgress.alternate; + var returnFiber = workInProgress.return; + + // Check if the work completed or if something threw. + if ((workInProgress.effectTag & Incomplete) === NoEffect) { + setCurrentFiber(workInProgress); + var next = void 0; + if ( + !enableProfilerTimer || + (workInProgress.mode & ProfileMode) === NoContext + ) { + next = completeWork(current$$1, workInProgress, renderExpirationTime$1); + } else { + startProfilerTimer(workInProgress); + next = completeWork(current$$1, workInProgress, renderExpirationTime$1); + // Update render duration assuming we didn't error. + stopProfilerTimerIfRunningAndRecordDelta(workInProgress, false); + } + stopWorkTimer(workInProgress); + resetCurrentFiber(); + resetChildExpirationTime$1(workInProgress); + + if (next !== null) { + // Completing this fiber spawned new work. Work on that next. + return next; + } + + if ( + returnFiber !== null && + // Do not append effects to parents if a sibling failed to complete + (returnFiber.effectTag & Incomplete) === NoEffect + ) { + // Append all the effects of the subtree and this fiber onto the effect + // list of the parent. The completion order of the children affects the + // side-effect order. + if (returnFiber.firstEffect === null) { + returnFiber.firstEffect = workInProgress.firstEffect; + } + if (workInProgress.lastEffect !== null) { + if (returnFiber.lastEffect !== null) { + returnFiber.lastEffect.nextEffect = workInProgress.firstEffect; + } + returnFiber.lastEffect = workInProgress.lastEffect; + } + + // If this fiber had side-effects, we append it AFTER the children's + // side-effects. We can perform certain side-effects earlier if needed, + // by doing multiple passes over the effect list. We don't want to + // schedule our own side-effect on our own list because if end up + // reusing children we'll schedule this effect onto itself since we're + // at the end. + var effectTag = workInProgress.effectTag; + + // Skip both NoWork and PerformedWork tags when creating the effect + // list. PerformedWork effect is read by React DevTools but shouldn't be + // committed. + if (effectTag > PerformedWork) { + if (returnFiber.lastEffect !== null) { + returnFiber.lastEffect.nextEffect = workInProgress; + } else { + returnFiber.firstEffect = workInProgress; + } + returnFiber.lastEffect = workInProgress; + } + } + } else { + // This fiber did not complete because something threw. Pop values off + // the stack without entering the complete phase. If this is a boundary, + // capture values if possible. + var _next = unwindWork(workInProgress, renderExpirationTime$1); + + // Because this fiber did not complete, don't reset its expiration time. + + if ( + enableProfilerTimer && + (workInProgress.mode & ProfileMode) !== NoContext + ) { + // Record the render duration for the fiber that errored. + stopProfilerTimerIfRunningAndRecordDelta(workInProgress, false); + + // Include the time spent working on failed children before continuing. + var actualDuration = workInProgress.actualDuration; + var child = workInProgress.child; + while (child !== null) { + actualDuration += child.actualDuration; + child = child.sibling; + } + workInProgress.actualDuration = actualDuration; + } + + if (_next !== null) { + // If completing this work spawned new work, do that next. We'll come + // back here again. + // Since we're restarting, remove anything that is not a host effect + // from the effect tag. + // TODO: The name stopFailedWorkTimer is misleading because Suspense + // also captures and restarts. + stopFailedWorkTimer(workInProgress); + _next.effectTag &= HostEffectMask; + return _next; + } + stopWorkTimer(workInProgress); + + if (returnFiber !== null) { + // Mark the parent fiber as incomplete and clear its effect list. + returnFiber.firstEffect = returnFiber.lastEffect = null; + returnFiber.effectTag |= Incomplete; + } + } + + var siblingFiber = workInProgress.sibling; + if (siblingFiber !== null) { + // If there is more work to do in this returnFiber, do that next. + return siblingFiber; + } + // Otherwise, return to the parent + workInProgress = returnFiber; + } while (workInProgress !== null); + + // We've reached the root. + if (workInProgressRootExitStatus === RootIncomplete) { + workInProgressRootExitStatus = RootCompleted; + } + return null; +} + +function resetChildExpirationTime$1(completedWork) { + if ( + renderExpirationTime$1 !== Never && + completedWork.childExpirationTime === Never + ) { + // The children of this component are hidden. Don't bubble their + // expiration times. + return; + } + + var newChildExpirationTime = NoWork; + + // Bubble up the earliest expiration time. + if (enableProfilerTimer && (completedWork.mode & ProfileMode) !== NoContext) { + // In profiling mode, resetChildExpirationTime is also used to reset + // profiler durations. + var actualDuration = completedWork.actualDuration; + var treeBaseDuration = completedWork.selfBaseDuration; + + // When a fiber is cloned, its actualDuration is reset to 0. This value will + // only be updated if work is done on the fiber (i.e. it doesn't bailout). + // When work is done, it should bubble to the parent's actualDuration. If + // the fiber has not been cloned though, (meaning no work was done), then + // this value will reflect the amount of time spent working on a previous + // render. In that case it should not bubble. We determine whether it was + // cloned by comparing the child pointer. + var shouldBubbleActualDurations = + completedWork.alternate === null || + completedWork.child !== completedWork.alternate.child; + + var child = completedWork.child; + while (child !== null) { + var childUpdateExpirationTime = child.expirationTime; + var childChildExpirationTime = child.childExpirationTime; + if (childUpdateExpirationTime > newChildExpirationTime) { + newChildExpirationTime = childUpdateExpirationTime; + } + if (childChildExpirationTime > newChildExpirationTime) { + newChildExpirationTime = childChildExpirationTime; + } + if (shouldBubbleActualDurations) { + actualDuration += child.actualDuration; + } + treeBaseDuration += child.treeBaseDuration; + child = child.sibling; + } + completedWork.actualDuration = actualDuration; + completedWork.treeBaseDuration = treeBaseDuration; + } else { + var _child = completedWork.child; + while (_child !== null) { + var _childUpdateExpirationTime = _child.expirationTime; + var _childChildExpirationTime = _child.childExpirationTime; + if (_childUpdateExpirationTime > newChildExpirationTime) { + newChildExpirationTime = _childUpdateExpirationTime; + } + if (_childChildExpirationTime > newChildExpirationTime) { + newChildExpirationTime = _childChildExpirationTime; + } + _child = _child.sibling; + } + } + + completedWork.childExpirationTime = newChildExpirationTime; +} + +function commitRoot$1(root, expirationTime) { + runWithPriority( + ImmediatePriority, + commitRootImpl.bind(null, root, expirationTime) + ); + // If there are passive effects, schedule a callback to flush them. This goes + // outside commitRootImpl so that it inherits the priority of the render. + if (rootWithPendingPassiveEffects$1 !== null) { + var priorityLevel = getCurrentPriorityLevel(); + scheduleCallback(priorityLevel, function() { + flushPassiveEffects$2(); + return null; + }); + } + return null; +} + +function commitRootImpl(root, expirationTime) { + flushPassiveEffects$2(); + flushRenderPhaseStrictModeWarningsInDEV(); + + (function() { + if (!(workPhase !== RenderPhase && workPhase !== CommitPhase)) { + throw ReactError("Should not already be working."); + } + })(); + var finishedWork = root.current.alternate; + (function() { + if (!(finishedWork !== null)) { + throw ReactError("Should have a work-in-progress root."); + } + })(); + + // commitRoot never returns a continuation; it always finishes synchronously. + // So we can clear these now to allow a new callback to be scheduled. + root.callbackNode = null; + root.callbackExpirationTime = NoWork; + + startCommitTimer(); + + // Update the first and last pending times on this root. The new first + // pending time is whatever is left on the root fiber. + var updateExpirationTimeBeforeCommit = finishedWork.expirationTime; + var childExpirationTimeBeforeCommit = finishedWork.childExpirationTime; + var firstPendingTimeBeforeCommit = + childExpirationTimeBeforeCommit > updateExpirationTimeBeforeCommit + ? childExpirationTimeBeforeCommit + : updateExpirationTimeBeforeCommit; + root.firstPendingTime = firstPendingTimeBeforeCommit; + if (firstPendingTimeBeforeCommit < root.lastPendingTime) { + // This usually means we've finished all the work, but it can also happen + // when something gets downprioritized during render, like a hidden tree. + root.lastPendingTime = firstPendingTimeBeforeCommit; + } + + if (root === workInProgressRoot) { + // We can reset these now that they are finished. + workInProgressRoot = null; + workInProgress = null; + renderExpirationTime$1 = NoWork; + } else { + } + // This indicates that the last root we worked on is not the same one that + // we're committing now. This most commonly happens when a suspended root + // times out. + + // Get the list of effects. + var firstEffect = void 0; + if (finishedWork.effectTag > PerformedWork) { + // A fiber's effect list consists only of its children, not itself. So if + // the root has an effect, we need to add it to the end of the list. The + // resulting list is the set that would belong to the root's parent, if it + // had one; that is, all the effects in the tree including the root. + if (finishedWork.lastEffect !== null) { + finishedWork.lastEffect.nextEffect = finishedWork; + firstEffect = finishedWork.firstEffect; + } else { + firstEffect = finishedWork; + } + } else { + // There is no effect on the root. + firstEffect = finishedWork.firstEffect; + } + + if (firstEffect !== null) { + var prevWorkPhase = workPhase; + workPhase = CommitPhase; + var prevInteractions = null; + if (enableSchedulerTracing) { + prevInteractions = tracing.__interactionsRef.current; + tracing.__interactionsRef.current = root.memoizedInteractions; + } + + // Reset this to null before calling lifecycles + ReactCurrentOwner$4.current = null; + + // The commit phase is broken into several sub-phases. We do a separate pass + // of the effect list for each phase: all mutation effects come before all + // layout effects, and so on. + + // The first phase a "before mutation" phase. We use this phase to read the + // state of the host tree right before we mutate it. This is where + // getSnapshotBeforeUpdate is called. + startCommitSnapshotEffectsTimer(); + prepareForCommit(root.containerInfo); + nextEffect$1 = firstEffect; + do { + { + invokeGuardedCallback(null, commitBeforeMutationEffects, null); + if (hasCaughtError()) { + (function() { + if (!(nextEffect$1 !== null)) { + throw ReactError("Should be working on an effect."); + } + })(); + var error = clearCaughtError(); + captureCommitPhaseError$2(nextEffect$1, error); + nextEffect$1 = nextEffect$1.nextEffect; + } + } + } while (nextEffect$1 !== null); + stopCommitSnapshotEffectsTimer(); + + if (enableProfilerTimer) { + // Mark the current commit time to be shared by all Profilers in this + // batch. This enables them to be grouped later. + recordCommitTime(); + } + + // The next phase is the mutation phase, where we mutate the host tree. + startCommitHostEffectsTimer(); + nextEffect$1 = firstEffect; + do { + { + invokeGuardedCallback(null, commitMutationEffects, null); + if (hasCaughtError()) { + (function() { + if (!(nextEffect$1 !== null)) { + throw ReactError("Should be working on an effect."); + } + })(); + var _error = clearCaughtError(); + captureCommitPhaseError$2(nextEffect$1, _error); + nextEffect$1 = nextEffect$1.nextEffect; + } + } + } while (nextEffect$1 !== null); + stopCommitHostEffectsTimer(); + resetAfterCommit(root.containerInfo); + + // The work-in-progress tree is now the current tree. This must come after + // the mutation phase, so that the previous tree is still current during + // componentWillUnmount, but before the layout phase, so that the finished + // work is current during componentDidMount/Update. + root.current = finishedWork; + + // The next phase is the layout phase, where we call effects that read + // the host tree after it's been mutated. The idiomatic use case for this is + // layout, but class component lifecycles also fire here for legacy reasons. + startCommitLifeCyclesTimer(); + nextEffect$1 = firstEffect; + do { + { + invokeGuardedCallback( + null, + commitLayoutEffects, + null, + root, + expirationTime + ); + if (hasCaughtError()) { + (function() { + if (!(nextEffect$1 !== null)) { + throw ReactError("Should be working on an effect."); + } + })(); + var _error2 = clearCaughtError(); + captureCommitPhaseError$2(nextEffect$1, _error2); + nextEffect$1 = nextEffect$1.nextEffect; + } + } + } while (nextEffect$1 !== null); + stopCommitLifeCyclesTimer(); + + nextEffect$1 = null; + + if (enableSchedulerTracing) { + tracing.__interactionsRef.current = prevInteractions; + } + workPhase = prevWorkPhase; + } else { + // No effects. + root.current = finishedWork; + // Measure these anyway so the flamegraph explicitly shows that there were + // no effects. + // TODO: Maybe there's a better way to report this. + startCommitSnapshotEffectsTimer(); + stopCommitSnapshotEffectsTimer(); + if (enableProfilerTimer) { + recordCommitTime(); + } + startCommitHostEffectsTimer(); + stopCommitHostEffectsTimer(); + startCommitLifeCyclesTimer(); + stopCommitLifeCyclesTimer(); + } + + stopCommitTimer(); + + if (rootDoesHavePassiveEffects) { + // This commit has passive effects. Stash a reference to them. But don't + // schedule a callback until after flushing layout work. + rootDoesHavePassiveEffects = false; + rootWithPendingPassiveEffects$1 = root; + pendingPassiveEffectsExpirationTime = expirationTime; + } else { + if (enableSchedulerTracing) { + // If there are no passive effects, then we can complete the pending + // interactions. Otherwise, we'll wait until after the passive effects + // are flushed. + finishPendingInteractions(root, expirationTime); + } + } + + // Check if there's remaining work on this root + var remainingExpirationTime = root.firstPendingTime; + if (remainingExpirationTime !== NoWork) { + var currentTime = requestCurrentTime$2(); + var priorityLevel = inferPriorityFromExpirationTime( + currentTime, + remainingExpirationTime + ); + scheduleCallbackForRoot(root, priorityLevel, remainingExpirationTime); + } else { + // If there's no remaining work, we can clear the set of already failed + // error boundaries. + legacyErrorBoundariesThatAlreadyFailed$1 = null; + } + + onCommitRoot(finishedWork.stateNode); + + if (remainingExpirationTime === Sync) { + // Count the number of times the root synchronously re-renders without + // finishing. If there are too many, it indicates an infinite update loop. + if (root === rootWithNestedUpdates) { + nestedUpdateCount$1++; + } else { + nestedUpdateCount$1 = 0; + rootWithNestedUpdates = root; + } + } else { + nestedUpdateCount$1 = 0; + } + + if (hasUncaughtError) { + hasUncaughtError = false; + var _error3 = firstUncaughtError; + firstUncaughtError = null; + throw _error3; + } + + if (workPhase === LegacyUnbatchedPhase) { + // This is a legacy edge case. We just committed the initial mount of + // a ReactDOM.render-ed root inside of batchedUpdates. The commit fired + // synchronously, but layout updates should be deferred until the end + // of the batch. + return null; + } + + // If layout work was scheduled, flush it now. + flushImmediateQueue(); + return null; +} + +function commitBeforeMutationEffects() { + while (nextEffect$1 !== null) { + if ((nextEffect$1.effectTag & Snapshot) !== NoEffect) { + setCurrentFiber(nextEffect$1); + recordEffect(); + + var current$$1 = nextEffect$1.alternate; + commitBeforeMutationLifeCycles(current$$1, nextEffect$1); + + resetCurrentFiber(); + } + nextEffect$1 = nextEffect$1.nextEffect; + } +} + +function commitMutationEffects() { + // TODO: Should probably move the bulk of this function to commitWork. + while (nextEffect$1 !== null) { + setCurrentFiber(nextEffect$1); + + var effectTag = nextEffect$1.effectTag; + + if (effectTag & ContentReset) { + commitResetTextContent(nextEffect$1); + } + + if (effectTag & Ref) { + var current$$1 = nextEffect$1.alternate; + if (current$$1 !== null) { + commitDetachRef(current$$1); + } + } + + // The following switch statement is only concerned about placement, + // updates, and deletions. To avoid needing to add a case for every possible + // bitmap value, we remove the secondary effects from the effect tag and + // switch on that value. + var primaryEffectTag = effectTag & (Placement | Update | Deletion); + switch (primaryEffectTag) { + case Placement: { + commitPlacement(nextEffect$1); + // Clear the "placement" from effect tag so that we know that this is + // inserted, before any life-cycles like componentDidMount gets called. + // TODO: findDOMNode doesn't rely on this any more but isMounted does + // and isMounted is deprecated anyway so we should be able to kill this. + nextEffect$1.effectTag &= ~Placement; + break; + } + case PlacementAndUpdate: { + // Placement + commitPlacement(nextEffect$1); + // Clear the "placement" from effect tag so that we know that this is + // inserted, before any life-cycles like componentDidMount gets called. + nextEffect$1.effectTag &= ~Placement; + + // Update + var _current = nextEffect$1.alternate; + commitWork(_current, nextEffect$1); + break; + } + case Update: { + var _current2 = nextEffect$1.alternate; + commitWork(_current2, nextEffect$1); + break; + } + case Deletion: { + commitDeletion(nextEffect$1); + break; + } + } + + // TODO: Only record a mutation effect if primaryEffectTag is non-zero. + recordEffect(); + + resetCurrentFiber(); + nextEffect$1 = nextEffect$1.nextEffect; + } +} + +function commitLayoutEffects(root, committedExpirationTime) { + // TODO: Should probably move the bulk of this function to commitWork. + while (nextEffect$1 !== null) { + setCurrentFiber(nextEffect$1); + + var effectTag = nextEffect$1.effectTag; + + if (effectTag & (Update | Callback)) { + recordEffect(); + var current$$1 = nextEffect$1.alternate; + commitLifeCycles(root, current$$1, nextEffect$1, committedExpirationTime); + } + + if (effectTag & Ref) { + recordEffect(); + commitAttachRef(nextEffect$1); + } + + if (effectTag & Passive) { + rootDoesHavePassiveEffects = true; + } + + resetCurrentFiber(); + nextEffect$1 = nextEffect$1.nextEffect; + } +} + +function flushPassiveEffects$2() { + if (rootWithPendingPassiveEffects$1 === null) { + return false; + } + var root = rootWithPendingPassiveEffects$1; + var expirationTime = pendingPassiveEffectsExpirationTime; + rootWithPendingPassiveEffects$1 = null; + pendingPassiveEffectsExpirationTime = NoWork; + + var prevInteractions = null; + if (enableSchedulerTracing) { + prevInteractions = tracing.__interactionsRef.current; + tracing.__interactionsRef.current = root.memoizedInteractions; + } + + (function() { + if (!(workPhase !== RenderPhase && workPhase !== CommitPhase)) { + throw ReactError("Cannot flush passive effects while already rendering."); + } + })(); + var prevWorkPhase = workPhase; + workPhase = CommitPhase; + + // Note: This currently assumes there are no passive effects on the root + // fiber, because the root is not part of its own effect list. This could + // change in the future. + var effect = root.current.firstEffect; + while (effect !== null) { + { + setCurrentFiber(effect); + invokeGuardedCallback(null, commitPassiveHookEffects, null, effect); + if (hasCaughtError()) { + (function() { + if (!(effect !== null)) { + throw ReactError("Should be working on an effect."); + } + })(); + var error = clearCaughtError(); + captureCommitPhaseError$2(effect, error); + } + resetCurrentFiber(); + } + effect = effect.nextEffect; + } + + if (enableSchedulerTracing) { + tracing.__interactionsRef.current = prevInteractions; + finishPendingInteractions(root, expirationTime); + } + + workPhase = prevWorkPhase; + flushImmediateQueue(); + + // If additional passive effects were scheduled, increment a counter. If this + // exceeds the limit, we'll fire a warning. + nestedPassiveUpdateCount = + rootWithPendingPassiveEffects$1 === null ? 0 : nestedPassiveUpdateCount + 1; + + return true; +} + +function isAlreadyFailedLegacyErrorBoundary$2(instance) { + return ( + legacyErrorBoundariesThatAlreadyFailed$1 !== null && + legacyErrorBoundariesThatAlreadyFailed$1.has(instance) + ); +} + +function markLegacyErrorBoundaryAsFailed$2(instance) { + if (legacyErrorBoundariesThatAlreadyFailed$1 === null) { + legacyErrorBoundariesThatAlreadyFailed$1 = new Set([instance]); + } else { + legacyErrorBoundariesThatAlreadyFailed$1.add(instance); + } +} + +function prepareToThrowUncaughtError(error) { + if (!hasUncaughtError) { + hasUncaughtError = true; + firstUncaughtError = error; + } +} +var onUncaughtError$2 = prepareToThrowUncaughtError; + +function captureCommitPhaseErrorOnRoot(rootFiber, sourceFiber, error) { + var errorInfo = createCapturedValue(error, sourceFiber); + var update = createRootErrorUpdate(rootFiber, errorInfo, Sync); + enqueueUpdate(rootFiber, update); + var root = markUpdateTimeFromFiberToRoot(rootFiber, Sync); + if (root !== null) { + scheduleCallbackForRoot(root, ImmediatePriority, Sync); + } +} + +function captureCommitPhaseError$2(sourceFiber, error) { + if (sourceFiber.tag === HostRoot) { + // Error was thrown at the root. There is no parent, so the root + // itself should capture it. + captureCommitPhaseErrorOnRoot(sourceFiber, sourceFiber, error); + return; + } + + var fiber = sourceFiber.return; + while (fiber !== null) { + if (fiber.tag === HostRoot) { + captureCommitPhaseErrorOnRoot(fiber, sourceFiber, error); + return; + } else if (fiber.tag === ClassComponent) { + var ctor = fiber.type; + var instance = fiber.stateNode; + if ( + typeof ctor.getDerivedStateFromError === "function" || + (typeof instance.componentDidCatch === "function" && + !isAlreadyFailedLegacyErrorBoundary$2(instance)) + ) { + var errorInfo = createCapturedValue(error, sourceFiber); + var update = createClassErrorUpdate( + fiber, + errorInfo, + // TODO: This is always sync + Sync + ); + enqueueUpdate(fiber, update); + var root = markUpdateTimeFromFiberToRoot(fiber, Sync); + if (root !== null) { + scheduleCallbackForRoot(root, ImmediatePriority, Sync); + } + return; + } + } + fiber = fiber.return; + } +} + +function pingSuspendedRoot$2(root, thenable, suspendedTime) { + var pingCache = root.pingCache; + if (pingCache !== null) { + // The thenable resolved, so we no longer need to memoize, because it will + // never be thrown again. + pingCache.delete(thenable); + } + + if (workInProgressRoot === root && renderExpirationTime$1 === suspendedTime) { + // Received a ping at the same priority level at which we're currently + // rendering. Restart from the root. Don't need to schedule a ping because + // we're already working on this tree. + prepareFreshStack(root, renderExpirationTime$1); + return; + } + + var lastPendingTime = root.lastPendingTime; + if (lastPendingTime < suspendedTime) { + // The root is no longer suspended at this time. + return; + } + + var pingTime = root.pingTime; + if (pingTime !== NoWork && pingTime < suspendedTime) { + // There's already a lower priority ping scheduled. + return; + } + + // Mark the time at which this ping was scheduled. + root.pingTime = suspendedTime; + + var currentTime = requestCurrentTime$2(); + var priorityLevel = inferPriorityFromExpirationTime( + currentTime, + suspendedTime + ); + scheduleCallbackForRoot(root, priorityLevel, suspendedTime); +} + +function retryTimedOutBoundary$2(boundaryFiber) { + // The boundary fiber (a Suspense component) previously timed out and was + // rendered in its fallback state. One of the promises that suspended it has + // resolved, which means at least part of the tree was likely unblocked. Try + // rendering again, at a new expiration time. + var currentTime = requestCurrentTime$2(); + var retryTime = computeExpirationForFiber$2(currentTime, boundaryFiber); + // TODO: Special case idle priority? + var priorityLevel = inferPriorityFromExpirationTime(currentTime, retryTime); + var root = markUpdateTimeFromFiberToRoot(boundaryFiber, retryTime); + if (root !== null) { + scheduleCallbackForRoot(root, priorityLevel, retryTime); + } +} + +function resolveRetryThenable$2(boundaryFiber, thenable) { + var retryCache = void 0; + if (enableSuspenseServerRenderer) { + switch (boundaryFiber.tag) { + case SuspenseComponent: + retryCache = boundaryFiber.stateNode; + break; + case DehydratedSuspenseComponent: + retryCache = boundaryFiber.memoizedState; + break; + default: + (function() { + { + throw ReactError( + "Pinged unknown suspense boundary type. This is probably a bug in React." + ); + } + })(); + } + } else { + retryCache = boundaryFiber.stateNode; + } + + if (retryCache !== null) { + // The thenable resolved, so we no longer need to memoize, because it will + // never be thrown again. + retryCache.delete(thenable); + } + + retryTimedOutBoundary$2(boundaryFiber); +} + +function computeMsUntilTimeout(mostRecentEventTime) { + if (disableYielding) { + // Timeout immediately when yielding is disabled. + return 0; + } + + var eventTimeMs = inferTimeFromExpirationTime$1(mostRecentEventTime); + var currentTimeMs = now(); + var timeElapsed = currentTimeMs - eventTimeMs; + + // TODO: Account for the Just Noticeable Difference + var timeoutMs = 150; + var msUntilTimeout = timeoutMs - timeElapsed; + // This is the value that is passed to `setTimeout`. + return msUntilTimeout < 0 ? 0 : msUntilTimeout; +} + +function checkForNestedUpdates() { + if (nestedUpdateCount$1 > NESTED_UPDATE_LIMIT$1) { + nestedUpdateCount$1 = 0; + rootWithNestedUpdates = null; + (function() { + { + throw ReactError( + "Maximum update depth exceeded. This can happen when a component repeatedly calls setState inside componentWillUpdate or componentDidUpdate. React limits the number of nested updates to prevent infinite loops." + ); + } + })(); + } + + { + if (nestedPassiveUpdateCount > NESTED_PASSIVE_UPDATE_LIMIT$1) { + nestedPassiveUpdateCount = 0; + warning$1( + false, + "Maximum update depth exceeded. This can happen when a component " + + "calls setState inside useEffect, but useEffect either doesn't " + + "have a dependency array, or one of the dependencies changes on " + + "every render." + ); + } + } +} + +function flushRenderPhaseStrictModeWarningsInDEV() { + { + ReactStrictModeWarnings.flushPendingUnsafeLifecycleWarnings(); + ReactStrictModeWarnings.flushLegacyContextWarning(); + + if (warnAboutDeprecatedLifecycles) { + ReactStrictModeWarnings.flushPendingDeprecationWarnings(); + } + } +} + +function stopFinishedWorkLoopTimer() { + var didCompleteRoot = true; + stopWorkLoopTimer(interruptedBy$1, didCompleteRoot); + interruptedBy$1 = null; +} + +function stopInterruptedWorkLoopTimer() { + // TODO: Track which fiber caused the interruption. + var didCompleteRoot = false; + stopWorkLoopTimer(interruptedBy$1, didCompleteRoot); + interruptedBy$1 = null; +} + +function checkForInterruption(fiberThatReceivedUpdate, updateExpirationTime) { + if ( + enableUserTimingAPI && + workInProgressRoot !== null && + updateExpirationTime > renderExpirationTime$1 + ) { + interruptedBy$1 = fiberThatReceivedUpdate; + } +} + +var didWarnStateUpdateForUnmountedComponent$1 = null; +function warnAboutUpdateOnUnmountedFiberInDEV(fiber) { + { + var tag = fiber.tag; + if ( + tag !== HostRoot && + tag !== ClassComponent && + tag !== FunctionComponent && + tag !== ForwardRef && + tag !== MemoComponent && + tag !== SimpleMemoComponent + ) { + // Only warn for user-defined components, not internal ones like Suspense. + return; + } + // We show the whole stack but dedupe on the top component's name because + // the problematic code almost always lies inside that component. + var componentName = getComponentName(fiber.type) || "ReactComponent"; + if (didWarnStateUpdateForUnmountedComponent$1 !== null) { + if (didWarnStateUpdateForUnmountedComponent$1.has(componentName)) { + return; + } + didWarnStateUpdateForUnmountedComponent$1.add(componentName); + } else { + didWarnStateUpdateForUnmountedComponent$1 = new Set([componentName]); + } + warningWithoutStack$1( + false, + "Can't perform a React state update on an unmounted component. This " + + "is a no-op, but it indicates a memory leak in your application. To " + + "fix, cancel all subscriptions and asynchronous tasks in %s.%s", + tag === ClassComponent + ? "the componentWillUnmount method" + : "a useEffect cleanup function", + getStackByFiberInDevAndProd(fiber) + ); + } +} + +var beginWork$1 = void 0; +if (true && replayFailedUnitOfWorkWithInvokeGuardedCallback) { + var dummyFiber = null; + beginWork$1 = function(current$$1, unitOfWork, expirationTime) { + // If a component throws an error, we replay it again in a synchronously + // dispatched event, so that the debugger will treat it as an uncaught + // error See ReactErrorUtils for more information. + + // Before entering the begin phase, copy the work-in-progress onto a dummy + // fiber. If beginWork throws, we'll use this to reset the state. + var originalWorkInProgressCopy = assignFiberPropertiesInDEV( + dummyFiber, + unitOfWork + ); + try { + return beginWork(current$$1, unitOfWork, expirationTime); + } catch (originalError) { + if ( + originalError !== null && + typeof originalError === "object" && + typeof originalError.then === "function" + ) { + // Don't replay promises. Treat everything else like an error. + throw originalError; + } + + // Keep this code in sync with renderRoot; any changes here must have + // corresponding changes there. + resetContextDependences(); + resetHooks(); + + // Unwind the failed stack frame + unwindInterruptedWork(unitOfWork); + + // Restore the original properties of the fiber. + assignFiberPropertiesInDEV(unitOfWork, originalWorkInProgressCopy); + + if (enableProfilerTimer && unitOfWork.mode & ProfileMode) { + // Reset the profiler timer. + startProfilerTimer(unitOfWork); + } + + // Run beginWork again. + invokeGuardedCallback( + null, + beginWork, + null, + current$$1, + unitOfWork, + expirationTime + ); + + if (hasCaughtError()) { + var replayError = clearCaughtError(); + // `invokeGuardedCallback` sometimes sets an expando `_suppressLogging`. + // Rethrow this error instead of the original one. + throw replayError; + } else { + // This branch is reachable if the render phase is impure. + throw originalError; + } + } + }; +} else { + beginWork$1 = beginWork; +} + +var didWarnAboutUpdateInRender = false; +var didWarnAboutUpdateInGetChildContext = false; +function warnAboutInvalidUpdatesOnClassComponentsInDEV(fiber) { + { + if (fiber.tag === ClassComponent) { + switch (phase) { + case "getChildContext": + if (didWarnAboutUpdateInGetChildContext) { + return; + } + warningWithoutStack$1( + false, + "setState(...): Cannot call setState() inside getChildContext()" + ); + didWarnAboutUpdateInGetChildContext = true; + break; + case "render": + if (didWarnAboutUpdateInRender) { + return; + } + warningWithoutStack$1( + false, + "Cannot update during an existing state transition (such as " + + "within `render`). Render methods should be a pure function of " + + "props and state." + ); + didWarnAboutUpdateInRender = true; + break; + } + } + } +} + +function warnIfNotCurrentlyActingUpdatesInDEV(fiber) { + { + if ( + workPhase === NotWorking && + ReactShouldWarnActingUpdates$1.current === false + ) { + warningWithoutStack$1( + false, + "An update to %s inside a test was not wrapped in act(...).\n\n" + + "When testing, code that causes React state updates should be " + + "wrapped into act(...):\n\n" + + "act(() => {\n" + + " /* fire events that update state */\n" + + "});\n" + + "/* assert on the output */\n\n" + + "This ensures that you're testing the behavior the user would see " + + "in the browser." + + " Learn more at https://fb.me/react-wrap-tests-with-act" + + "%s", + getComponentName(fiber.type), + getStackByFiberInDevAndProd(fiber) + ); + } + } +} + +var warnIfNotCurrentlyActingUpdatesInDev$2 = warnIfNotCurrentlyActingUpdatesInDEV; + +function computeThreadID$1(root, expirationTime) { + // Interaction threads are unique per root and expiration time. + return expirationTime * 1000 + root.interactionThreadID; +} + +function schedulePendingInteraction(root, expirationTime) { + // This is called when work is scheduled on a root. It sets up a pending + // interaction, which is completed once the work commits. + if (!enableSchedulerTracing) { + return; + } + + var interactions = tracing.__interactionsRef.current; + if (interactions.size > 0) { + var pendingInteractionMap = root.pendingInteractionMap; + var pendingInteractions = pendingInteractionMap.get(expirationTime); + if (pendingInteractions != null) { + interactions.forEach(function(interaction) { + if (!pendingInteractions.has(interaction)) { + // Update the pending async work count for previously unscheduled interaction. + interaction.__count++; + } + + pendingInteractions.add(interaction); + }); + } else { + pendingInteractionMap.set(expirationTime, new Set(interactions)); + + // Update the pending async work count for the current interactions. + interactions.forEach(function(interaction) { + interaction.__count++; + }); + } + + var subscriber = tracing.__subscriberRef.current; + if (subscriber !== null) { + var threadID = computeThreadID$1(root, expirationTime); + subscriber.onWorkScheduled(interactions, threadID); + } + } +} + +function startWorkOnPendingInteraction(root, expirationTime) { + // This is called when new work is started on a root. + if (!enableSchedulerTracing) { + return; + } + + // Determine which interactions this batch of work currently includes, So that + // we can accurately attribute time spent working on it, And so that cascading + // work triggered during the render phase will be associated with it. + var interactions = new Set(); + root.pendingInteractionMap.forEach(function( + scheduledInteractions, + scheduledExpirationTime + ) { + if (scheduledExpirationTime >= expirationTime) { + scheduledInteractions.forEach(function(interaction) { + return interactions.add(interaction); + }); + } + }); + + // Store the current set of interactions on the FiberRoot for a few reasons: + // We can re-use it in hot functions like renderRoot() without having to + // recalculate it. We will also use it in commitWork() to pass to any Profiler + // onRender() hooks. This also provides DevTools with a way to access it when + // the onCommitRoot() hook is called. + root.memoizedInteractions = interactions; + + if (interactions.size > 0) { + var subscriber = tracing.__subscriberRef.current; + if (subscriber !== null) { + var threadID = computeThreadID$1(root, expirationTime); + try { + subscriber.onWorkStarted(interactions, threadID); + } catch (error) { + // If the subscriber throws, rethrow it in a separate task + scheduleCallback(ImmediatePriority, function() { + throw error; + }); } - ); - } finally { - isBatchingUpdates = previousIsBatchingUpdates; - if (!isBatchingUpdates && !isRendering) { - performSyncWork(); } } } -function flushInteractiveUpdates$1() { - if ( - !isRendering && - lowestPriorityPendingInteractiveExpirationTime !== NoWork - ) { - // Synchronously flush pending interactive updates. - performWork(lowestPriorityPendingInteractiveExpirationTime, false); - lowestPriorityPendingInteractiveExpirationTime = NoWork; +function finishPendingInteractions(root, committedExpirationTime) { + if (!enableSchedulerTracing) { + return; + } + + var earliestRemainingTimeAfterCommit = root.firstPendingTime; + + var subscriber = void 0; + + try { + subscriber = tracing.__subscriberRef.current; + if (subscriber !== null && root.memoizedInteractions.size > 0) { + var threadID = computeThreadID$1(root, committedExpirationTime); + subscriber.onWorkStopped(root.memoizedInteractions, threadID); + } + } catch (error) { + // If the subscriber throws, rethrow it in a separate task + scheduleCallback(ImmediatePriority, function() { + throw error; + }); + } finally { + // Clear completed interactions from the pending Map. + // Unless the render was suspended or cascading work was scheduled, + // In which case– leave pending interactions until the subsequent render. + var pendingInteractionMap = root.pendingInteractionMap; + pendingInteractionMap.forEach(function( + scheduledInteractions, + scheduledExpirationTime + ) { + // Only decrement the pending interaction count if we're done. + // If there's still work at the current priority, + // That indicates that we are waiting for suspense data. + if (scheduledExpirationTime > earliestRemainingTimeAfterCommit) { + pendingInteractionMap.delete(scheduledExpirationTime); + + scheduledInteractions.forEach(function(interaction) { + interaction.__count--; + + if (subscriber !== null && interaction.__count === 0) { + try { + subscriber.onInteractionScheduledWorkCompleted(interaction); + } catch (error) { + // If the subscriber throws, rethrow it in a separate task + scheduleCallback(ImmediatePriority, function() { + throw error; + }); + } + } + }); + } + }); } } +var requestCurrentTime$$1 = enableNewScheduler + ? requestCurrentTime$2 + : requestCurrentTime$1; +var computeExpirationForFiber$$1 = enableNewScheduler + ? computeExpirationForFiber$2 + : computeExpirationForFiber$1; +var captureCommitPhaseError$$1 = enableNewScheduler + ? captureCommitPhaseError$2 + : captureCommitPhaseError$1; +var onUncaughtError$$1 = enableNewScheduler + ? onUncaughtError$2 + : onUncaughtError$1; +var markRenderEventTime$$1 = enableNewScheduler + ? markRenderEventTime$2 + : markRenderEventTime$1; +var renderDidSuspend$$1 = enableNewScheduler + ? renderDidSuspend$2 + : renderDidSuspend$1; +var renderDidError$$1 = enableNewScheduler + ? renderDidError$2 + : renderDidError$1; +var pingSuspendedRoot$$1 = enableNewScheduler + ? pingSuspendedRoot$2 + : pingSuspendedRoot$1; +var retryTimedOutBoundary$$1 = enableNewScheduler + ? retryTimedOutBoundary$2 + : retryTimedOutBoundary$1; +var resolveRetryThenable$$1 = enableNewScheduler + ? resolveRetryThenable$2 + : resolveRetryThenable$1; +var markLegacyErrorBoundaryAsFailed$$1 = enableNewScheduler + ? markLegacyErrorBoundaryAsFailed$2 + : markLegacyErrorBoundaryAsFailed$1; +var isAlreadyFailedLegacyErrorBoundary$$1 = enableNewScheduler + ? isAlreadyFailedLegacyErrorBoundary$2 + : isAlreadyFailedLegacyErrorBoundary$1; +var scheduleWork$$1 = enableNewScheduler ? scheduleWork$2 : scheduleWork$1; + +var batchedUpdates$1 = enableNewScheduler ? batchedUpdates$3 : batchedUpdates$2; + +var interactiveUpdates$1 = enableNewScheduler + ? interactiveUpdates$3 + : interactiveUpdates$2; +var flushInteractiveUpdates$1 = enableNewScheduler + ? flushInteractiveUpdates$3 + : flushInteractiveUpdates$2; + +var flushPassiveEffects$$1 = enableNewScheduler + ? flushPassiveEffects$2 + : flushPassiveEffects$1; +var warnIfNotCurrentlyActingUpdatesInDev$$1 = enableNewScheduler + ? warnIfNotCurrentlyActingUpdatesInDev$2 + : warnIfNotCurrentlyActingUpdatesInDev$1; + // 0 is PROD, 1 is DEV. // Might add PROFILE later. @@ -18000,9 +21204,9 @@ function scheduleRootUpdate(current$$1, element, expirationTime, callback) { update.callback = callback; } - flushPassiveEffects(); + flushPassiveEffects$$1(); enqueueUpdate(current$$1, update); - scheduleWork(current$$1, expirationTime); + scheduleWork$$1(current$$1, expirationTime); return expirationTime; } @@ -18043,13 +21247,20 @@ function findHostInstance(component) { var fiber = get$1(component); if (fiber === undefined) { if (typeof component.render === "function") { - invariant(false, "Unable to find node on an unmounted component."); + (function() { + { + throw ReactError("Unable to find node on an unmounted component."); + } + })(); } else { - invariant( - false, - "Argument appears to not be a ReactComponent. Keys: %s", - Object.keys(component) - ); + (function() { + { + throw ReactError( + "Argument appears to not be a ReactComponent. Keys: " + + Object.keys(component) + ); + } + })(); } } var hostFiber = findCurrentHostFiber(fiber); @@ -18064,13 +21275,20 @@ function findHostInstanceWithWarning(component, methodName) { var fiber = get$1(component); if (fiber === undefined) { if (typeof component.render === "function") { - invariant(false, "Unable to find node on an unmounted component."); + (function() { + { + throw ReactError("Unable to find node on an unmounted component."); + } + })(); } else { - invariant( - false, - "Argument appears to not be a ReactComponent. Keys: %s", - Object.keys(component) - ); + (function() { + { + throw ReactError( + "Argument appears to not be a ReactComponent. Keys: " + + Object.keys(component) + ); + } + })(); } } var hostFiber = findCurrentHostFiber(fiber); @@ -18123,8 +21341,8 @@ function createContainer(containerInfo, isConcurrent, hydrate) { function updateContainer(element, container, parentComponent, callback) { var current$$1 = container.current; - var currentTime = requestCurrentTime(); - var expirationTime = computeExpirationForFiber(currentTime, current$$1); + var currentTime = requestCurrentTime$$1(); + var expirationTime = computeExpirationForFiber$$1(currentTime, current$$1); return updateContainerAtExpirationTime( element, container, @@ -18147,7 +21365,18 @@ function getPublicRootInstance(container) { } } +var shouldSuspendImpl = function(fiber) { + return false; +}; + +function shouldSuspend(fiber) { + return shouldSuspendImpl(fiber); +} + +var overrideHookState = null; var overrideProps = null; +var scheduleUpdate = null; +var setSuspenseHandler = null; { var copyWithSetImpl = function(obj, path, idx, value) { @@ -18165,14 +21394,50 @@ var overrideProps = null; return copyWithSetImpl(obj, path, 0, value); }; + // Support DevTools editable values for useState and useReducer. + overrideHookState = function(fiber, id, path, value) { + // For now, the "id" of stateful hooks is just the stateful hook index. + // This may change in the future with e.g. nested hooks. + var currentHook = fiber.memoizedState; + while (currentHook !== null && id > 0) { + currentHook = currentHook.next; + id--; + } + if (currentHook !== null) { + flushPassiveEffects$$1(); + + var newState = copyWithSet(currentHook.memoizedState, path, value); + currentHook.memoizedState = newState; + currentHook.baseState = newState; + + // We aren't actually adding an update to the queue, + // because there is no update we can add for useReducer hooks that won't trigger an error. + // (There's no appropriate action type for DevTools overrides.) + // As a result though, React will see the scheduled update as a noop and bailout. + // Shallow cloning props works as a workaround for now to bypass the bailout check. + fiber.memoizedProps = Object.assign({}, fiber.memoizedProps); + + scheduleWork$$1(fiber, Sync); + } + }; + // Support DevTools props for function components, forwardRef, memo, host components, etc. overrideProps = function(fiber, path, value) { - flushPassiveEffects(); + flushPassiveEffects$$1(); fiber.pendingProps = copyWithSet(fiber.memoizedProps, path, value); if (fiber.alternate) { fiber.alternate.pendingProps = fiber.pendingProps; } - scheduleWork(fiber, Sync); + scheduleWork$$1(fiber, Sync); + }; + + scheduleUpdate = function(fiber) { + flushPassiveEffects$$1(); + scheduleWork$$1(fiber, Sync); + }; + + setSuspenseHandler = function(newShouldSuspendImpl) { + shouldSuspendImpl = newShouldSuspendImpl; }; } @@ -18182,7 +21447,10 @@ function injectIntoDevTools(devToolsConfig) { return injectInternals( Object.assign({}, devToolsConfig, { + overrideHookState: overrideHookState, overrideProps: overrideProps, + setSuspenseHandler: setSuspenseHandler, + scheduleUpdate: scheduleUpdate, currentDispatcherRef: ReactCurrentDispatcher, findHostInstanceByFiber: function(fiber) { var hostFiber = findCurrentHostFiber(fiber); @@ -18226,7 +21494,7 @@ function createPortal( // TODO: this is special because it gets imported during build. -var ReactVersion = "16.8.1"; +var ReactVersion = "16.8.6"; // Modules provided by RN: var NativeMethodsMixin = function(findNodeHandle, findHostInstance) { @@ -18264,10 +21532,33 @@ var NativeMethodsMixin = function(findNodeHandle, findHostInstance) { * prop](docs/view.html#onlayout) instead. */ measure: function(callback) { - UIManager.measure( - findNodeHandle(this), - mountSafeCallback_NOT_REALLY_SAFE(this, callback) - ); + var maybeInstance = void 0; + + // Fiber errors if findNodeHandle is called for an umounted component. + // Tests using ReactTestRenderer will trigger this case indirectly. + // Mimicking stack behavior, we should silently ignore this case. + // TODO Fix ReactTestRenderer so we can remove this try/catch. + try { + maybeInstance = findHostInstance(this); + } catch (error) {} + + // If there is no host component beneath this we should fail silently. + // This is not an error; it could mean a class component rendered null. + if (maybeInstance == null) { + return; + } + + if (maybeInstance.canonical) { + FabricUIManager.measure( + maybeInstance.node, + mountSafeCallback_NOT_REALLY_SAFE(this, callback) + ); + } else { + UIManager.measure( + findNodeHandle(this), + mountSafeCallback_NOT_REALLY_SAFE(this, callback) + ); + } }, /** @@ -18286,10 +21577,33 @@ var NativeMethodsMixin = function(findNodeHandle, findHostInstance) { * has been completed in native. */ measureInWindow: function(callback) { - UIManager.measureInWindow( - findNodeHandle(this), - mountSafeCallback_NOT_REALLY_SAFE(this, callback) - ); + var maybeInstance = void 0; + + // Fiber errors if findNodeHandle is called for an umounted component. + // Tests using ReactTestRenderer will trigger this case indirectly. + // Mimicking stack behavior, we should silently ignore this case. + // TODO Fix ReactTestRenderer so we can remove this try/catch. + try { + maybeInstance = findHostInstance(this); + } catch (error) {} + + // If there is no host component beneath this we should fail silently. + // This is not an error; it could mean a class component rendered null. + if (maybeInstance == null) { + return; + } + + if (maybeInstance.canonical) { + FabricUIManager.measureInWindow( + maybeInstance.node, + mountSafeCallback_NOT_REALLY_SAFE(this, callback) + ); + } else { + UIManager.measureInWindow( + findNodeHandle(this), + mountSafeCallback_NOT_REALLY_SAFE(this, callback) + ); + } }, /** @@ -18305,12 +21619,56 @@ var NativeMethodsMixin = function(findNodeHandle, findHostInstance) { onSuccess, onFail /* currently unused */ ) { - UIManager.measureLayout( - findNodeHandle(this), - relativeToNativeNode, - mountSafeCallback_NOT_REALLY_SAFE(this, onFail), - mountSafeCallback_NOT_REALLY_SAFE(this, onSuccess) - ); + var maybeInstance = void 0; + + // Fiber errors if findNodeHandle is called for an umounted component. + // Tests using ReactTestRenderer will trigger this case indirectly. + // Mimicking stack behavior, we should silently ignore this case. + // TODO Fix ReactTestRenderer so we can remove this try/catch. + try { + maybeInstance = findHostInstance(this); + } catch (error) {} + + // If there is no host component beneath this we should fail silently. + // This is not an error; it could mean a class component rendered null. + if (maybeInstance == null) { + return; + } + + if (maybeInstance.canonical) { + warningWithoutStack$1( + false, + "Warning: measureLayout on components using NativeMethodsMixin " + + "or ReactNative.NativeComponent is not currently supported in Fabric. " + + "measureLayout must be called on a native ref. Consider using forwardRef." + ); + return; + } else { + var relativeNode = void 0; + + if (typeof relativeToNativeNode === "number") { + // Already a node handle + relativeNode = relativeToNativeNode; + } else if (relativeToNativeNode._nativeTag) { + relativeNode = relativeToNativeNode._nativeTag; + } + + if (relativeNode == null) { + warningWithoutStack$1( + false, + "Warning: ref.measureLayout must be called with a node handle or a ref to a native component." + ); + + return; + } + + UIManager.measureLayout( + findNodeHandle(this), + relativeNode, + mountSafeCallback_NOT_REALLY_SAFE(this, onFail), + mountSafeCallback_NOT_REALLY_SAFE(this, onSuccess) + ); + } }, /** @@ -18341,7 +21699,30 @@ var NativeMethodsMixin = function(findNodeHandle, findHostInstance) { return; } - var viewConfig = maybeInstance.viewConfig; + if (maybeInstance.canonical) { + warningWithoutStack$1( + false, + "Warning: setNativeProps is not currently supported in Fabric" + ); + return; + } + + { + if (warnAboutDeprecatedSetNativeProps) { + warningWithoutStack$1( + false, + "Warning: Calling ref.setNativeProps(nativeProps) " + + "is deprecated and will be removed in a future release. " + + "Use the setNativeProps export from the react-native package instead." + + "\n\timport {setNativeProps} from 'react-native';\n\tsetNativeProps(ref, nativeProps);\n" + ); + } + } + + var nativeTag = + maybeInstance._nativeTag || maybeInstance.canonical._nativeTag; + var viewConfig = + maybeInstance.viewConfig || maybeInstance.canonical.viewConfig; { warnForStyleProps(nativeProps, viewConfig.validAttributes); @@ -18354,7 +21735,7 @@ var NativeMethodsMixin = function(findNodeHandle, findHostInstance) { // view invalidation for certain components (eg RCTTextInput) on iOS. if (updatePayload != null) { UIManager.updateView( - maybeInstance._nativeTag, + nativeTag, viewConfig.uiViewClassName, updatePayload ); @@ -18382,13 +21763,18 @@ var NativeMethodsMixin = function(findNodeHandle, findHostInstance) { // true without actually implementing them (setting them to undefined // isn't allowed by ReactClass) var NativeMethodsMixin_DEV = NativeMethodsMixin; - invariant( - !NativeMethodsMixin_DEV.componentWillMount && - !NativeMethodsMixin_DEV.componentWillReceiveProps && - !NativeMethodsMixin_DEV.UNSAFE_componentWillMount && - !NativeMethodsMixin_DEV.UNSAFE_componentWillReceiveProps, - "Do not override existing functions." - ); + (function() { + if ( + !( + !NativeMethodsMixin_DEV.componentWillMount && + !NativeMethodsMixin_DEV.componentWillReceiveProps && + !NativeMethodsMixin_DEV.UNSAFE_componentWillMount && + !NativeMethodsMixin_DEV.UNSAFE_componentWillReceiveProps + ) + ) { + throw ReactError("Do not override existing functions."); + } + })(); // TODO (bvaughn) Remove cWM and cWRP in a future version of React Native, // Once these lifecycles have been remove from the reconciler. NativeMethodsMixin_DEV.componentWillMount = function() { @@ -18515,11 +21901,34 @@ var ReactNativeComponent = function(findNodeHandle, findHostInstance) { * [`onLayout` prop](docs/view.html#onlayout) instead. */ - ReactNativeComponent.prototype.measure = function measure(callback) { - UIManager.measure( - findNodeHandle(this), - mountSafeCallback_NOT_REALLY_SAFE(this, callback) - ); + ReactNativeComponent.prototype.measure = function measure$$1(callback) { + var maybeInstance = void 0; + + // Fiber errors if findNodeHandle is called for an umounted component. + // Tests using ReactTestRenderer will trigger this case indirectly. + // Mimicking stack behavior, we should silently ignore this case. + // TODO Fix ReactTestRenderer so we can remove this try/catch. + try { + maybeInstance = findHostInstance(this); + } catch (error) {} + + // If there is no host component beneath this we should fail silently. + // This is not an error; it could mean a class component rendered null. + if (maybeInstance == null) { + return; + } + + if (maybeInstance.canonical) { + FabricUIManager.measure( + maybeInstance.node, + mountSafeCallback_NOT_REALLY_SAFE(this, callback) + ); + } else { + UIManager.measure( + findNodeHandle(this), + mountSafeCallback_NOT_REALLY_SAFE(this, callback) + ); + } }; /** @@ -18536,13 +21945,36 @@ var ReactNativeComponent = function(findNodeHandle, findHostInstance) { * These values are not available until after natives rendering completes. */ - ReactNativeComponent.prototype.measureInWindow = function measureInWindow( + ReactNativeComponent.prototype.measureInWindow = function measureInWindow$$1( callback ) { - UIManager.measureInWindow( - findNodeHandle(this), - mountSafeCallback_NOT_REALLY_SAFE(this, callback) - ); + var maybeInstance = void 0; + + // Fiber errors if findNodeHandle is called for an umounted component. + // Tests using ReactTestRenderer will trigger this case indirectly. + // Mimicking stack behavior, we should silently ignore this case. + // TODO Fix ReactTestRenderer so we can remove this try/catch. + try { + maybeInstance = findHostInstance(this); + } catch (error) {} + + // If there is no host component beneath this we should fail silently. + // This is not an error; it could mean a class component rendered null. + if (maybeInstance == null) { + return; + } + + if (maybeInstance.canonical) { + FabricUIManager.measureInWindow( + maybeInstance.node, + mountSafeCallback_NOT_REALLY_SAFE(this, callback) + ); + } else { + UIManager.measureInWindow( + findNodeHandle(this), + mountSafeCallback_NOT_REALLY_SAFE(this, callback) + ); + } }; /** @@ -18552,17 +21984,61 @@ var ReactNativeComponent = function(findNodeHandle, findHostInstance) { * Obtain a native node handle with `ReactNative.findNodeHandle(component)`. */ - ReactNativeComponent.prototype.measureLayout = function measureLayout( + ReactNativeComponent.prototype.measureLayout = function measureLayout$$1( relativeToNativeNode, onSuccess, onFail /* currently unused */ ) { - UIManager.measureLayout( - findNodeHandle(this), - relativeToNativeNode, - mountSafeCallback_NOT_REALLY_SAFE(this, onFail), - mountSafeCallback_NOT_REALLY_SAFE(this, onSuccess) - ); + var maybeInstance = void 0; + + // Fiber errors if findNodeHandle is called for an umounted component. + // Tests using ReactTestRenderer will trigger this case indirectly. + // Mimicking stack behavior, we should silently ignore this case. + // TODO Fix ReactTestRenderer so we can remove this try/catch. + try { + maybeInstance = findHostInstance(this); + } catch (error) {} + + // If there is no host component beneath this we should fail silently. + // This is not an error; it could mean a class component rendered null. + if (maybeInstance == null) { + return; + } + + if (maybeInstance.canonical) { + warningWithoutStack$1( + false, + "Warning: measureLayout on components using NativeMethodsMixin " + + "or ReactNative.NativeComponent is not currently supported in Fabric. " + + "measureLayout must be called on a native ref. Consider using forwardRef." + ); + return; + } else { + var relativeNode = void 0; + + if (typeof relativeToNativeNode === "number") { + // Already a node handle + relativeNode = relativeToNativeNode; + } else if (relativeToNativeNode._nativeTag) { + relativeNode = relativeToNativeNode._nativeTag; + } + + if (relativeNode == null) { + warningWithoutStack$1( + false, + "Warning: ref.measureLayout must be called with a node handle or a ref to a native component." + ); + + return; + } + + UIManager.measureLayout( + findNodeHandle(this), + relativeNode, + mountSafeCallback_NOT_REALLY_SAFE(this, onFail), + mountSafeCallback_NOT_REALLY_SAFE(this, onSuccess) + ); + } }; /** @@ -18596,6 +22072,28 @@ var ReactNativeComponent = function(findNodeHandle, findHostInstance) { return; } + if (maybeInstance.canonical) { + warningWithoutStack$1( + false, + "Warning: setNativeProps is not currently supported in Fabric" + ); + return; + } + + { + if (warnAboutDeprecatedSetNativeProps) { + warningWithoutStack$1( + false, + "Warning: Calling ref.setNativeProps(nativeProps) " + + "is deprecated and will be removed in a future release. " + + "Use the setNativeProps export from the react-native package instead." + + "\n\timport {setNativeProps} from 'react-native';\n\tsetNativeProps(ref, nativeProps);\n" + ); + } + } + + var nativeTag = + maybeInstance._nativeTag || maybeInstance.canonical._nativeTag; var viewConfig = maybeInstance.viewConfig || maybeInstance.canonical.viewConfig; @@ -18606,7 +22104,7 @@ var ReactNativeComponent = function(findNodeHandle, findHostInstance) { // view invalidation for certain components (eg RCTTextInput) on iOS. if (updatePayload != null) { UIManager.updateView( - maybeInstance._nativeTag, + nativeTag, viewConfig.uiViewClassName, updatePayload ); @@ -18801,6 +22299,14 @@ var ReactFabric = { findNodeHandle: findNodeHandle, + setNativeProps: function(handle, nativeProps) { + warningWithoutStack$1( + false, + "Warning: setNativeProps is not currently supported in Fabric" + ); + + return; + }, render: function(element, containerTag, callback) { var root = roots.get(containerTag); diff --git a/Libraries/Renderer/oss/ReactFabric-prod.js b/Libraries/Renderer/oss/ReactFabric-prod.js index 6a2913b0b564c7..5e48e88a8a0889 100644 --- a/Libraries/Renderer/oss/ReactFabric-prod.js +++ b/Libraries/Renderer/oss/ReactFabric-prod.js @@ -18,78 +18,13 @@ var ReactNativeViewConfigRegistry = require("ReactNativeViewConfigRegistry"), deepDiffer = require("deepDiffer"), flattenStyle = require("flattenStyle"), TextInputState = require("TextInputState"), - FabricUIManager = require("FabricUIManager"); -var scheduler = require("scheduler"), - ExceptionsManager = require("ExceptionsManager"); -function invariant(condition, format, a, b, c, d, e, f) { - if (!condition) { - condition = void 0; - if (void 0 === format) - condition = Error( - "Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings." - ); - else { - var args = [a, b, c, d, e, f], - argIndex = 0; - condition = Error( - format.replace(/%s/g, function() { - return args[argIndex++]; - }) - ); - condition.name = "Invariant Violation"; - } - condition.framesToPop = 1; - throw condition; - } -} -function invokeGuardedCallbackImpl(name, func, context, a, b, c, d, e, f) { - var funcArgs = Array.prototype.slice.call(arguments, 3); - try { - func.apply(context, funcArgs); - } catch (error) { - this.onError(error); - } -} -var hasError = !1, - caughtError = null, - hasRethrowError = !1, - rethrowError = null, - reporter = { - onError: function(error) { - hasError = !0; - caughtError = error; - } - }; -function invokeGuardedCallback(name, func, context, a, b, c, d, e, f) { - hasError = !1; - caughtError = null; - invokeGuardedCallbackImpl.apply(reporter, arguments); -} -function invokeGuardedCallbackAndCatchFirstError( - name, - func, - context, - a, - b, - c, - d, - e, - f -) { - invokeGuardedCallback.apply(this, arguments); - if (hasError) { - if (hasError) { - var error = caughtError; - hasError = !1; - caughtError = null; - } else - invariant( - !1, - "clearCaughtError was called but no error was captured. This error is likely caused by a bug in React. Please file an issue." - ), - (error = void 0); - hasRethrowError || ((hasRethrowError = !0), (rethrowError = error)); - } + FabricUIManager = require("FabricUIManager"), + Scheduler = require("scheduler"); +var ExceptionsManager = require("ExceptionsManager"); +function ReactError(message) { + message = Error(message); + message.name = "Invariant Violation"; + return message; } var eventPluginOrder = null, namesToPlugins = {}; @@ -98,17 +33,19 @@ function recomputePluginOrdering() { for (var pluginName in namesToPlugins) { var pluginModule = namesToPlugins[pluginName], pluginIndex = eventPluginOrder.indexOf(pluginName); - invariant( - -1 < pluginIndex, - "EventPluginRegistry: Cannot inject event plugins that do not exist in the plugin ordering, `%s`.", - pluginName - ); - if (!plugins[pluginIndex]) { - invariant( - pluginModule.extractEvents, - "EventPluginRegistry: Event plugins must implement an `extractEvents` method, but `%s` does not.", - pluginName + if (!(-1 < pluginIndex)) + throw ReactError( + "EventPluginRegistry: Cannot inject event plugins that do not exist in the plugin ordering, `" + + pluginName + + "`." ); + if (!plugins[pluginIndex]) { + if (!pluginModule.extractEvents) + throw ReactError( + "EventPluginRegistry: Event plugins must implement an `extractEvents` method, but `" + + pluginName + + "` does not." + ); plugins[pluginIndex] = pluginModule; pluginIndex = pluginModule.eventTypes; for (var eventName in pluginIndex) { @@ -116,11 +53,12 @@ function recomputePluginOrdering() { var dispatchConfig = pluginIndex[eventName], pluginModule$jscomp$0 = pluginModule, eventName$jscomp$0 = eventName; - invariant( - !eventNameDispatchConfigs.hasOwnProperty(eventName$jscomp$0), - "EventPluginHub: More than one plugin attempted to publish the same event name, `%s`.", - eventName$jscomp$0 - ); + if (eventNameDispatchConfigs.hasOwnProperty(eventName$jscomp$0)) + throw ReactError( + "EventPluginHub: More than one plugin attempted to publish the same event name, `" + + eventName$jscomp$0 + + "`." + ); eventNameDispatchConfigs[eventName$jscomp$0] = dispatchConfig; var phasedRegistrationNames = dispatchConfig.phasedRegistrationNames; if (phasedRegistrationNames) { @@ -143,28 +81,78 @@ function recomputePluginOrdering() { ), (JSCompiler_inline_result = !0)) : (JSCompiler_inline_result = !1); - invariant( - JSCompiler_inline_result, - "EventPluginRegistry: Failed to publish event `%s` for plugin `%s`.", - eventName, - pluginName - ); + if (!JSCompiler_inline_result) + throw ReactError( + "EventPluginRegistry: Failed to publish event `" + + eventName + + "` for plugin `" + + pluginName + + "`." + ); } } } } function publishRegistrationName(registrationName, pluginModule) { - invariant( - !registrationNameModules[registrationName], - "EventPluginHub: More than one plugin attempted to publish the same registration name, `%s`.", - registrationName - ); + if (registrationNameModules[registrationName]) + throw ReactError( + "EventPluginHub: More than one plugin attempted to publish the same registration name, `" + + registrationName + + "`." + ); registrationNameModules[registrationName] = pluginModule; } var plugins = [], eventNameDispatchConfigs = {}, - registrationNameModules = {}, - getFiberCurrentPropsFromNode = null, + registrationNameModules = {}; +function invokeGuardedCallbackImpl(name, func, context, a, b, c, d, e, f) { + var funcArgs = Array.prototype.slice.call(arguments, 3); + try { + func.apply(context, funcArgs); + } catch (error) { + this.onError(error); + } +} +var hasError = !1, + caughtError = null, + hasRethrowError = !1, + rethrowError = null, + reporter = { + onError: function(error) { + hasError = !0; + caughtError = error; + } + }; +function invokeGuardedCallback(name, func, context, a, b, c, d, e, f) { + hasError = !1; + caughtError = null; + invokeGuardedCallbackImpl.apply(reporter, arguments); +} +function invokeGuardedCallbackAndCatchFirstError( + name, + func, + context, + a, + b, + c, + d, + e, + f +) { + invokeGuardedCallback.apply(this, arguments); + if (hasError) { + if (hasError) { + var error = caughtError; + hasError = !1; + caughtError = null; + } else + throw ReactError( + "clearCaughtError was called but no error was captured. This error is likely caused by a bug in React. Please file an issue." + ); + hasRethrowError || ((hasRethrowError = !0), (rethrowError = error)); + } +} +var getFiberCurrentPropsFromNode = null, getInstanceFromNode = null, getNodeFromInstance = null; function executeDispatch(event, listener, inst) { @@ -176,10 +164,8 @@ function executeDispatch(event, listener, inst) { function executeDirectDispatch(event) { var dispatchListener = event._dispatchListeners, dispatchInstance = event._dispatchInstances; - invariant( - !Array.isArray(dispatchListener), - "executeDirectDispatch(...): Invalid `event`." - ); + if (Array.isArray(dispatchListener)) + throw ReactError("executeDirectDispatch(...): Invalid `event`."); event.currentTarget = dispatchListener ? getNodeFromInstance(dispatchInstance) : null; @@ -190,10 +176,10 @@ function executeDirectDispatch(event) { return dispatchListener; } function accumulateInto(current, next) { - invariant( - null != next, - "accumulateInto(...): Accumulated items must not be null or undefined." - ); + if (null == next) + throw ReactError( + "accumulateInto(...): Accumulated items must not be null or undefined." + ); if (null == current) return next; if (Array.isArray(current)) { if (Array.isArray(next)) return current.push.apply(current, next), current; @@ -227,10 +213,10 @@ function executeDispatchesAndReleaseTopLevel(e) { } var injection = { injectEventPluginOrder: function(injectedEventPluginOrder) { - invariant( - !eventPluginOrder, - "EventPluginRegistry: Cannot inject event plugin ordering more than once. You are likely trying to load more than one copy of React." - ); + if (eventPluginOrder) + throw ReactError( + "EventPluginRegistry: Cannot inject event plugin ordering more than once. You are likely trying to load more than one copy of React." + ); eventPluginOrder = Array.prototype.slice.call(injectedEventPluginOrder); recomputePluginOrdering(); }, @@ -240,15 +226,19 @@ var injection = { for (pluginName in injectedNamesToPlugins) if (injectedNamesToPlugins.hasOwnProperty(pluginName)) { var pluginModule = injectedNamesToPlugins[pluginName]; - (namesToPlugins.hasOwnProperty(pluginName) && - namesToPlugins[pluginName] === pluginModule) || - (invariant( - !namesToPlugins[pluginName], - "EventPluginRegistry: Cannot inject two different event plugins using the same name, `%s`.", - pluginName - ), - (namesToPlugins[pluginName] = pluginModule), - (isOrderingDirty = !0)); + if ( + !namesToPlugins.hasOwnProperty(pluginName) || + namesToPlugins[pluginName] !== pluginModule + ) { + if (namesToPlugins[pluginName]) + throw ReactError( + "EventPluginRegistry: Cannot inject two different event plugins using the same name, `" + + pluginName + + "`." + ); + namesToPlugins[pluginName] = pluginModule; + isOrderingDirty = !0; + } } isOrderingDirty && recomputePluginOrdering(); } @@ -284,12 +274,14 @@ function getListener(inst, registrationName) { inst = !1; } if (inst) return null; - invariant( - !listener || "function" === typeof listener, - "Expected `%s` listener to be a function, instead got a value of `%s` type.", - registrationName, - typeof listener - ); + if (listener && "function" !== typeof listener) + throw ReactError( + "Expected `" + + registrationName + + "` listener to be a function, instead got a value of `" + + typeof listener + + "` type." + ); return listener; } function getParent(inst) { @@ -450,10 +442,10 @@ function getPooledEvent(dispatchConfig, targetInst, nativeEvent, nativeInst) { return new this(dispatchConfig, targetInst, nativeEvent, nativeInst); } function releasePooledEvent(event) { - invariant( - event instanceof this, - "Trying to release an event instance into a pool of a different type." - ); + if (!(event instanceof this)) + throw ReactError( + "Trying to release an event instance into a pool of a different type." + ); event.destructor(); 10 > this.eventPool.length && this.eventPool.push(event); } @@ -488,7 +480,7 @@ function timestampForTouch(touch) { } function getTouchIdentifier(_ref) { _ref = _ref.identifier; - invariant(null != _ref, "Touch object is missing identifier."); + if (null == _ref) throw ReactError("Touch object is missing identifier."); return _ref; } function recordTouchStart(touch) { @@ -601,10 +593,10 @@ var ResponderTouchHistoryStore = { touchHistory: touchHistory }; function accumulate(current, next) { - invariant( - null != next, - "accumulate(...): Accumulated items must be not be null or undefined." - ); + if (null == next) + throw ReactError( + "accumulate(...): Accumulated items must be not be null or undefined." + ); return null == current ? next : Array.isArray(current) @@ -969,11 +961,10 @@ var eventTypes$1 = { ReactNativeViewConfigRegistry.customBubblingEventTypes[topLevelType], directDispatchConfig = ReactNativeViewConfigRegistry.customDirectEventTypes[topLevelType]; - invariant( - bubbleDispatchConfig || directDispatchConfig, - 'Unsupported top level event type "%s" dispatched', - topLevelType - ); + if (!bubbleDispatchConfig && !directDispatchConfig) + throw ReactError( + 'Unsupported top level event type "' + topLevelType + '" dispatched' + ); topLevelType = SyntheticEvent.getPooled( bubbleDispatchConfig || directDispatchConfig, targetInst, @@ -1005,7 +996,7 @@ getFiberCurrentPropsFromNode = function(inst) { getInstanceFromNode = getInstanceFromInstance; getNodeFromInstance = function(inst) { inst = inst.stateNode.canonical._nativeTag; - invariant(inst, "All native instances should have a tag."); + if (!inst) throw ReactError("All native instances should have a tag."); return inst; }; ResponderEventPlugin.injection.injectGlobalResponderHandler({ @@ -1037,6 +1028,15 @@ var hasSymbol = "function" === typeof Symbol && Symbol.for, REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for("react.suspense") : 60113, REACT_MEMO_TYPE = hasSymbol ? Symbol.for("react.memo") : 60115, REACT_LAZY_TYPE = hasSymbol ? Symbol.for("react.lazy") : 60116, + REACT_EVENT_COMPONENT_TYPE = hasSymbol + ? Symbol.for("react.event_component") + : 60117, + REACT_EVENT_TARGET_TYPE = hasSymbol + ? Symbol.for("react.event_target") + : 60118, + REACT_EVENT_TARGET_TOUCH_HIT = hasSymbol + ? Symbol.for("react.event_target.touch_hit") + : 60119, MAYBE_ITERATOR_SYMBOL = "function" === typeof Symbol && Symbol.iterator; function getIteratorFn(maybeIterable) { if (null === maybeIterable || "object" !== typeof maybeIterable) return null; @@ -1081,6 +1081,15 @@ function getComponentName(type) { case REACT_LAZY_TYPE: if ((type = 1 === type._status ? type._result : null)) return getComponentName(type); + break; + case REACT_EVENT_COMPONENT_TYPE: + type = type.displayName; + if (void 0 !== type) return type; + break; + case REACT_EVENT_TARGET_TYPE: + if (type.type === REACT_EVENT_TARGET_TOUCH_HIT) return "TouchHitTarget"; + type = type.displayName; + if (void 0 !== type) return type; } return null; } @@ -1095,80 +1104,83 @@ function isFiberMountedImpl(fiber) { return 3 === node.tag ? 2 : 3; } function assertIsMounted(fiber) { - invariant( - 2 === isFiberMountedImpl(fiber), - "Unable to find node on an unmounted component." - ); + if (2 !== isFiberMountedImpl(fiber)) + throw ReactError("Unable to find node on an unmounted component."); } function findCurrentFiberUsingSlowPath(fiber) { var alternate = fiber.alternate; - if (!alternate) - return ( - (alternate = isFiberMountedImpl(fiber)), - invariant( - 3 !== alternate, - "Unable to find node on an unmounted component." - ), - 1 === alternate ? null : fiber - ); + if (!alternate) { + alternate = isFiberMountedImpl(fiber); + if (3 === alternate) + throw ReactError("Unable to find node on an unmounted component."); + return 1 === alternate ? null : fiber; + } for (var a = fiber, b = alternate; ; ) { - var parentA = a.return, - parentB = parentA ? parentA.alternate : null; - if (!parentA || !parentB) break; + var parentA = a.return; + if (null === parentA) break; + var parentB = parentA.alternate; + if (null === parentB) { + b = parentA.return; + if (null !== b) { + a = b; + continue; + } + break; + } if (parentA.child === parentB.child) { - for (var child = parentA.child; child; ) { - if (child === a) return assertIsMounted(parentA), fiber; - if (child === b) return assertIsMounted(parentA), alternate; - child = child.sibling; + for (parentB = parentA.child; parentB; ) { + if (parentB === a) return assertIsMounted(parentA), fiber; + if (parentB === b) return assertIsMounted(parentA), alternate; + parentB = parentB.sibling; } - invariant(!1, "Unable to find node on an unmounted component."); + throw ReactError("Unable to find node on an unmounted component."); } if (a.return !== b.return) (a = parentA), (b = parentB); else { - child = !1; - for (var _child = parentA.child; _child; ) { + for (var didFindChild = !1, _child = parentA.child; _child; ) { if (_child === a) { - child = !0; + didFindChild = !0; a = parentA; b = parentB; break; } if (_child === b) { - child = !0; + didFindChild = !0; b = parentA; a = parentB; break; } _child = _child.sibling; } - if (!child) { + if (!didFindChild) { for (_child = parentB.child; _child; ) { if (_child === a) { - child = !0; + didFindChild = !0; a = parentB; b = parentA; break; } if (_child === b) { - child = !0; + didFindChild = !0; b = parentB; a = parentA; break; } _child = _child.sibling; } - invariant( - child, - "Child was not found in either parent set. This indicates a bug in React related to the return pointer. Please file an issue." - ); + if (!didFindChild) + throw ReactError( + "Child was not found in either parent set. This indicates a bug in React related to the return pointer. Please file an issue." + ); } } - invariant( - a.alternate === b, - "Return fibers should always be each others' alternates. This error is likely caused by a bug in React. Please file an issue." - ); + if (a.alternate !== b) + throw ReactError( + "Return fibers should always be each others' alternates. This error is likely caused by a bug in React. Please file an issue." + ); } - invariant(3 === a.tag, "Unable to find node on an unmounted component."); + if (3 !== a.tag) + throw ReactError("Unable to find node on an unmounted component."); return a.stateNode.current === a ? fiber : alternate; } function findCurrentHostFiber(parent) { @@ -1416,37 +1428,13 @@ function diffProperties(updatePayload, prevProps, nextProps, validAttributes) { ))))); return updatePayload; } -var now$1 = - "object" === typeof performance && "function" === typeof performance.now - ? function() { - return performance.now(); - } - : function() { - return Date.now(); - }, - scheduledCallback = null, - frameDeadline = 0; -function setTimeoutCallback() { - frameDeadline = now$1() + 5; - var callback = scheduledCallback; - scheduledCallback = null; - null !== callback && callback(); -} -function scheduleDeferredCallback$1(callback) { - scheduledCallback = callback; - return setTimeout(setTimeoutCallback, 1); -} var restoreTarget = null, restoreQueue = null; function restoreStateOfTarget(target) { - if ((target = getInstanceFromNode(target))) { - invariant( - !1, + if (getInstanceFromNode(target)) + throw ReactError( "setRestoreImplementation() needs to be called to handle a target for controlled events. This error is likely caused by a bug in React. Please file an issue." ); - var props = getFiberCurrentPropsFromNode(target.stateNode); - null(target.stateNode, target.type, props); - } } function _batchedUpdatesImpl(fn, bookkeeping) { return fn(bookkeeping); @@ -1491,24 +1479,22 @@ function dispatchEvent(target, topLevelType, nativeEvent) { null !== events && (eventQueue = accumulateInto(eventQueue, events)); events = eventQueue; eventQueue = null; - if ( - events && - (forEachAccumulated(events, executeDispatchesAndReleaseTopLevel), - invariant( - !eventQueue, - "processEventQueue(): Additional events were enqueued while processing an event queue. Support for this has not yet been implemented." - ), - hasRethrowError) - ) - throw ((events = rethrowError), - (hasRethrowError = !1), - (rethrowError = null), - events); + if (events) { + forEachAccumulated(events, executeDispatchesAndReleaseTopLevel); + if (eventQueue) + throw ReactError( + "processEventQueue(): Additional events were enqueued while processing an event queue. Support for this has not yet been implemented." + ); + if (hasRethrowError) + throw ((events = rethrowError), + (hasRethrowError = !1), + (rethrowError = null), + events); + } }); } function shim$1() { - invariant( - !1, + throw ReactError( "The current renderer does not support hydration. This error is likely caused by a bug in React. Please file an issue." ); } @@ -1516,12 +1502,18 @@ var nextReactTag = 2; FabricUIManager.registerEventHandler && FabricUIManager.registerEventHandler(dispatchEvent); var ReactFabricHostComponent = (function() { - function ReactFabricHostComponent(tag, viewConfig, props) { + function ReactFabricHostComponent( + tag, + viewConfig, + props, + internalInstanceHandle + ) { if (!(this instanceof ReactFabricHostComponent)) throw new TypeError("Cannot call a class as a function"); this._nativeTag = tag; this.viewConfig = viewConfig; this.currentProps = props; + this._internalInstanceHandle = internalInstanceHandle; } ReactFabricHostComponent.prototype.blur = function() { TextInputState.blurTextInput(this._nativeTag); @@ -1530,14 +1522,14 @@ var ReactFabricHostComponent = (function() { TextInputState.focusTextInput(this._nativeTag); }; ReactFabricHostComponent.prototype.measure = function(callback) { - UIManager.measure( - this._nativeTag, + FabricUIManager.measure( + this._internalInstanceHandle.stateNode.node, mountSafeCallback_NOT_REALLY_SAFE(this, callback) ); }; ReactFabricHostComponent.prototype.measureInWindow = function(callback) { - UIManager.measureInWindow( - this._nativeTag, + FabricUIManager.measureInWindow( + this._internalInstanceHandle.stateNode.node, mountSafeCallback_NOT_REALLY_SAFE(this, callback) ); }; @@ -1546,27 +1538,16 @@ var ReactFabricHostComponent = (function() { onSuccess, onFail ) { - UIManager.measureLayout( - this._nativeTag, - relativeToNativeNode, - mountSafeCallback_NOT_REALLY_SAFE(this, onFail), - mountSafeCallback_NOT_REALLY_SAFE(this, onSuccess) - ); - }; - ReactFabricHostComponent.prototype.setNativeProps = function(nativeProps) { - nativeProps = diffProperties( - null, - emptyObject, - nativeProps, - this.viewConfig.validAttributes - ); - null != nativeProps && - UIManager.updateView( - this._nativeTag, - this.viewConfig.uiViewClassName, - nativeProps + "number" !== typeof relativeToNativeNode && + relativeToNativeNode instanceof ReactFabricHostComponent && + FabricUIManager.measureLayout( + this._internalInstanceHandle.stateNode.node, + relativeToNativeNode._internalInstanceHandle.stateNode.node, + mountSafeCallback_NOT_REALLY_SAFE(this, onFail), + mountSafeCallback_NOT_REALLY_SAFE(this, onSuccess) ); }; + ReactFabricHostComponent.prototype.setNativeProps = function() {}; return ReactFabricHostComponent; })(); function createTextInstance( @@ -1575,10 +1556,10 @@ function createTextInstance( hostContext, internalInstanceHandle ) { - invariant( - hostContext.isInAParentText, - "Text strings must be rendered within a component." - ); + if (!hostContext.isInAParentText) + throw ReactError( + "Text strings must be rendered within a component." + ); hostContext = nextReactTag; nextReactTag += 2; return { @@ -1606,18 +1587,6 @@ function cloneHiddenInstance(instance) { canonical: instance.canonical }; } -function cloneUnhiddenInstance(instance, type, props) { - var viewConfig = instance.canonical.viewConfig; - type = instance.node; - var prevProps = Object.assign({}, props, { - style: [props.style, { display: "none" }] - }); - props = diffProperties(null, prevProps, props, viewConfig.validAttributes); - return { - node: FabricUIManager.cloneNodeWithNewProps(type, props), - canonical: instance.canonical - }; -} var BEFORE_SLASH_RE = /^(.*)[\\\/]/; function getStackByFiberInDevAndProd(workInProgress) { var info = ""; @@ -1702,10 +1671,10 @@ function popTopLevelContextObject(fiber) { pop(contextStackCursor, fiber); } function pushTopLevelContextObject(fiber, context, didChange) { - invariant( - contextStackCursor.current === emptyContextObject, - "Unexpected context found on stack. This error is likely caused by a bug in React. Please file an issue." - ); + if (contextStackCursor.current !== emptyContextObject) + throw ReactError( + "Unexpected context found on stack. This error is likely caused by a bug in React. Please file an issue." + ); push(contextStackCursor, context, fiber); push(didPerformWorkStackCursor, didChange, fiber); } @@ -1715,12 +1684,13 @@ function processChildContext(fiber, type, parentContext) { if ("function" !== typeof instance.getChildContext) return parentContext; instance = instance.getChildContext(); for (var contextKey in instance) - invariant( - contextKey in fiber, - '%s.getChildContext(): key "%s" is not defined in childContextTypes.', - getComponentName(type) || "Unknown", - contextKey - ); + if (!(contextKey in fiber)) + throw ReactError( + (getComponentName(type) || "Unknown") + + '.getChildContext(): key "' + + contextKey + + '" is not defined in childContextTypes.' + ); return Object.assign({}, parentContext, instance); } function pushContextProvider(workInProgress) { @@ -1739,10 +1709,10 @@ function pushContextProvider(workInProgress) { } function invalidateContextProvider(workInProgress, type, didChange) { var instance = workInProgress.stateNode; - invariant( - instance, - "Expected to have an instance by this point. This error is likely caused by a bug in React. Please file an issue." - ); + if (!instance) + throw ReactError( + "Expected to have an instance by this point. This error is likely caused by a bug in React. Please file an issue." + ); didChange ? ((type = processChildContext(workInProgress, type, previousContext)), (instance.__reactInternalMemoizedMergedChildContext = type), @@ -1776,6 +1746,7 @@ function injectInternals(internals) { } catch (err) {} return !0; } +var Scheduler_now = Scheduler.unstable_now; function FiberNode(tag, pendingProps, key, mode) { this.tag = tag; this.key = key; @@ -1899,11 +1870,10 @@ function createFiberFromTypeAndProps( owner = null; break a; } - invariant( - !1, - "Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s", - null == type ? type : typeof type, - "" + throw ReactError( + "Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: " + + (null == type ? type : typeof type) + + "." ); } key = createFiber(fiberTag, pendingProps, key, mode); @@ -1945,6 +1915,21 @@ function createFiberFromPortal(portal, mode, expirationTime) { }; return mode; } +function FiberRootNode(containerInfo, hydrate) { + this.current = null; + this.containerInfo = containerInfo; + this.pingCache = this.pendingChildren = null; + this.pendingCommitExpirationTime = 0; + this.finishedWork = null; + this.timeoutHandle = -1; + this.pendingContext = this.context = null; + this.hydrate = hydrate; + this.firstBatch = null; + this.latestPingedTime = this.latestSuspendedTime = this.earliestSuspendedTime = this.latestPendingTime = this.earliestPendingTime = 0; + this.didError = !1; + this.expirationTime = this.nextExpirationTimeToWorkOn = 0; + this.nextScheduledRoot = null; +} function markPendingPriorityLevel(root, expirationTime) { root.didError = !1; var earliestPendingTime = root.earliestPendingTime; @@ -1956,36 +1941,6 @@ function markPendingPriorityLevel(root, expirationTime) { (root.latestPendingTime = expirationTime); findNextExpirationTimeToWorkOn(expirationTime, root); } -function markCommittedPriorityLevels(root, earliestRemainingTime) { - root.didError = !1; - if (0 === earliestRemainingTime) - (root.earliestPendingTime = 0), - (root.latestPendingTime = 0), - (root.earliestSuspendedTime = 0), - (root.latestSuspendedTime = 0), - (root.latestPingedTime = 0); - else { - earliestRemainingTime < root.latestPingedTime && - (root.latestPingedTime = 0); - var latestPendingTime = root.latestPendingTime; - 0 !== latestPendingTime && - (latestPendingTime > earliestRemainingTime - ? (root.earliestPendingTime = root.latestPendingTime = 0) - : root.earliestPendingTime > earliestRemainingTime && - (root.earliestPendingTime = root.latestPendingTime)); - latestPendingTime = root.earliestSuspendedTime; - 0 === latestPendingTime - ? markPendingPriorityLevel(root, earliestRemainingTime) - : earliestRemainingTime < root.latestSuspendedTime - ? ((root.earliestSuspendedTime = 0), - (root.latestSuspendedTime = 0), - (root.latestPingedTime = 0), - markPendingPriorityLevel(root, earliestRemainingTime)) - : earliestRemainingTime > latestPendingTime && - markPendingPriorityLevel(root, earliestRemainingTime); - } - findNextExpirationTimeToWorkOn(0, root); -} function markSuspendedPriorityLevel(root, suspendedTime) { root.didError = !1; root.latestPingedTime >= suspendedTime && (root.latestPingedTime = 0); @@ -2008,14 +1963,6 @@ function markSuspendedPriorityLevel(root, suspendedTime) { (root.latestSuspendedTime = suspendedTime); findNextExpirationTimeToWorkOn(suspendedTime, root); } -function findEarliestOutstandingPriorityLevel(root, renderExpirationTime) { - var earliestPendingTime = root.earliestPendingTime; - root = root.earliestSuspendedTime; - earliestPendingTime > renderExpirationTime && - (renderExpirationTime = earliestPendingTime); - root > renderExpirationTime && (renderExpirationTime = root); - return renderExpirationTime; -} function findNextExpirationTimeToWorkOn(completedExpirationTime, root) { var earliestSuspendedTime = root.earliestSuspendedTime, latestSuspendedTime = root.latestSuspendedTime, @@ -2130,37 +2077,37 @@ var classComponentUpdater = { }, enqueueSetState: function(inst, payload, callback) { inst = inst._reactInternalFiber; - var currentTime = requestCurrentTime(); - currentTime = computeExpirationForFiber(currentTime, inst); + var currentTime = requestCurrentTime$$1(); + currentTime = computeExpirationForFiber$$1(currentTime, inst); var update = createUpdate(currentTime); update.payload = payload; void 0 !== callback && null !== callback && (update.callback = callback); - flushPassiveEffects(); + flushPassiveEffects$$1(); enqueueUpdate(inst, update); - scheduleWork(inst, currentTime); + scheduleWork$$1(inst, currentTime); }, enqueueReplaceState: function(inst, payload, callback) { inst = inst._reactInternalFiber; - var currentTime = requestCurrentTime(); - currentTime = computeExpirationForFiber(currentTime, inst); + var currentTime = requestCurrentTime$$1(); + currentTime = computeExpirationForFiber$$1(currentTime, inst); var update = createUpdate(currentTime); update.tag = ReplaceState; update.payload = payload; void 0 !== callback && null !== callback && (update.callback = callback); - flushPassiveEffects(); + flushPassiveEffects$$1(); enqueueUpdate(inst, update); - scheduleWork(inst, currentTime); + scheduleWork$$1(inst, currentTime); }, enqueueForceUpdate: function(inst, callback) { inst = inst._reactInternalFiber; - var currentTime = requestCurrentTime(); - currentTime = computeExpirationForFiber(currentTime, inst); + var currentTime = requestCurrentTime$$1(); + currentTime = computeExpirationForFiber$$1(currentTime, inst); var update = createUpdate(currentTime); update.tag = ForceUpdate; void 0 !== callback && null !== callback && (update.callback = callback); - flushPassiveEffects(); + flushPassiveEffects$$1(); enqueueUpdate(inst, update); - scheduleWork(inst, currentTime); + scheduleWork$$1(inst, currentTime); } }; function checkShouldComponentUpdate( @@ -2285,17 +2232,19 @@ function coerceRef(returnFiber, current$$1, element) { if (element._owner) { element = element._owner; var inst = void 0; - element && - (invariant( - 1 === element.tag, - "Function components cannot have refs. Did you mean to use React.forwardRef()?" - ), - (inst = element.stateNode)); - invariant( - inst, - "Missing owner for string ref %s. This error is likely caused by a bug in React. Please file an issue.", - returnFiber - ); + if (element) { + if (1 !== element.tag) + throw ReactError( + "Function components cannot have refs. Did you mean to use React.forwardRef()?" + ); + inst = element.stateNode; + } + if (!inst) + throw ReactError( + "Missing owner for string ref " + + returnFiber + + ". This error is likely caused by a bug in React. Please file an issue." + ); var stringRef = "" + returnFiber; if ( null !== current$$1 && @@ -2312,27 +2261,27 @@ function coerceRef(returnFiber, current$$1, element) { current$$1._stringRef = stringRef; return current$$1; } - invariant( - "string" === typeof returnFiber, - "Expected ref to be a function, a string, an object returned by React.createRef(), or null." - ); - invariant( - element._owner, - "Element ref was specified as a string (%s) but no owner was set. This could happen for one of the following reasons:\n1. You may be adding a ref to a function component\n2. You may be adding a ref to a component that was not created inside a component's render method\n3. You have multiple copies of React loaded\nSee https://fb.me/react-refs-must-have-owner for more information.", - returnFiber - ); + if ("string" !== typeof returnFiber) + throw ReactError( + "Expected ref to be a function, a string, an object returned by React.createRef(), or null." + ); + if (!element._owner) + throw ReactError( + "Element ref was specified as a string (" + + returnFiber + + ") but no owner was set. This could happen for one of the following reasons:\n1. You may be adding a ref to a function component\n2. You may be adding a ref to a component that was not created inside a component's render method\n3. You have multiple copies of React loaded\nSee https://fb.me/react-refs-must-have-owner for more information." + ); } return returnFiber; } function throwOnInvalidObjectType(returnFiber, newChild) { - "textarea" !== returnFiber.type && - invariant( - !1, - "Objects are not valid as a React child (found: %s).%s", - "[object Object]" === Object.prototype.toString.call(newChild) - ? "object with keys {" + Object.keys(newChild).join(", ") + "}" - : newChild, - "" + if ("textarea" !== returnFiber.type) + throw ReactError( + "Objects are not valid as a React child (found: " + + ("[object Object]" === Object.prototype.toString.call(newChild) + ? "object with keys {" + Object.keys(newChild).join(", ") + "}" + : newChild) + + ")." ); } function ChildReconciler(shouldTrackSideEffects) { @@ -2731,15 +2680,13 @@ function ChildReconciler(shouldTrackSideEffects) { expirationTime ) { var iteratorFn = getIteratorFn(newChildrenIterable); - invariant( - "function" === typeof iteratorFn, - "An object is not an iterable. This error is likely caused by a bug in React. Please file an issue." - ); + if ("function" !== typeof iteratorFn) + throw ReactError( + "An object is not an iterable. This error is likely caused by a bug in React. Please file an issue." + ); newChildrenIterable = iteratorFn.call(newChildrenIterable); - invariant( - null != newChildrenIterable, - "An iterable object provided no iterator." - ); + if (null == newChildrenIterable) + throw ReactError("An iterable object provided no iterator."); for ( var previousNewFiber = (iteratorFn = null), oldFiber = currentFirstChild, @@ -2831,7 +2778,7 @@ function ChildReconciler(shouldTrackSideEffects) { null !== isUnkeyedTopLevelFragment; ) { - if (isUnkeyedTopLevelFragment.key === isObject) + if (isUnkeyedTopLevelFragment.key === isObject) { if ( 7 === isUnkeyedTopLevelFragment.tag ? newChild.type === REACT_FRAGMENT_TYPE @@ -2856,14 +2803,10 @@ function ChildReconciler(shouldTrackSideEffects) { currentFirstChild.return = returnFiber; returnFiber = currentFirstChild; break a; - } else { - deleteRemainingChildren( - returnFiber, - isUnkeyedTopLevelFragment - ); - break; } - else deleteChild(returnFiber, isUnkeyedTopLevelFragment); + deleteRemainingChildren(returnFiber, isUnkeyedTopLevelFragment); + break; + } else deleteChild(returnFiber, isUnkeyedTopLevelFragment); isUnkeyedTopLevelFragment = isUnkeyedTopLevelFragment.sibling; } newChild.type === REACT_FRAGMENT_TYPE @@ -2899,7 +2842,7 @@ function ChildReconciler(shouldTrackSideEffects) { null !== currentFirstChild; ) { - if (currentFirstChild.key === isUnkeyedTopLevelFragment) + if (currentFirstChild.key === isUnkeyedTopLevelFragment) { if ( 4 === currentFirstChild.tag && currentFirstChild.stateNode.containerInfo === @@ -2919,11 +2862,10 @@ function ChildReconciler(shouldTrackSideEffects) { currentFirstChild.return = returnFiber; returnFiber = currentFirstChild; break a; - } else { - deleteRemainingChildren(returnFiber, currentFirstChild); - break; } - else deleteChild(returnFiber, currentFirstChild); + deleteRemainingChildren(returnFiber, currentFirstChild); + break; + } else deleteChild(returnFiber, currentFirstChild); currentFirstChild = currentFirstChild.sibling; } currentFirstChild = createFiberFromPortal( @@ -2977,12 +2919,11 @@ function ChildReconciler(shouldTrackSideEffects) { switch (returnFiber.tag) { case 1: case 0: - (expirationTime = returnFiber.type), - invariant( - !1, - "%s(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null.", - expirationTime.displayName || expirationTime.name || "Component" - ); + throw ((returnFiber = returnFiber.type), + ReactError( + (returnFiber.displayName || returnFiber.name || "Component") + + "(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null." + )); } return deleteRemainingChildren(returnFiber, currentFirstChild); }; @@ -2994,10 +2935,10 @@ var reconcileChildFibers = ChildReconciler(!0), contextFiberStackCursor = { current: NO_CONTEXT }, rootInstanceStackCursor = { current: NO_CONTEXT }; function requiredContext(c) { - invariant( - c !== NO_CONTEXT, - "Expected host context to exist. This error is likely caused by a bug in React. Please file an issue." - ); + if (c === NO_CONTEXT) + throw ReactError( + "Expected host context to exist. This error is likely caused by a bug in React. Please file an issue." + ); return c; } function pushHostContainer(fiber, nextRootInstance) { @@ -3034,15 +2975,7 @@ function popHostContext(fiber) { contextFiberStackCursor.current === fiber && (pop(contextStackCursor$1, fiber), pop(contextFiberStackCursor, fiber)); } -var NoEffect$1 = 0, - UnmountSnapshot = 2, - UnmountMutation = 4, - MountMutation = 8, - UnmountLayout = 16, - MountLayout = 32, - MountPassive = 64, - UnmountPassive = 128, - ReactCurrentDispatcher$1 = ReactSharedInternals.ReactCurrentDispatcher, +var ReactCurrentDispatcher$1 = ReactSharedInternals.ReactCurrentDispatcher, renderExpirationTime = 0, currentlyRenderingFiber$1 = null, currentHook = null, @@ -3057,9 +2990,8 @@ var NoEffect$1 = 0, renderPhaseUpdates = null, numberOfReRenders = 0; function throwInvalidHookError() { - invariant( - !1, - "Hooks can only be called inside the body of a function component. (https://fb.me/react-invalid-hook-call)" + throw ReactError( + "Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:\n1. You might have mismatching versions of React and the renderer (such as React DOM)\n2. You might be breaking the Rules of Hooks\n3. You might have more than one copy of React in the same app\nSee https://fb.me/react-invalid-hook-call for tips about how to debug and fix this problem." ); } function areHookInputsEqual(nextDeps, prevDeps) { @@ -3107,10 +3039,10 @@ function renderWithHooks( remainingExpirationTime = 0; componentUpdateQueue = null; sideEffectTag = 0; - invariant( - !current, - "Rendered fewer hooks than expected. This may be caused by an accidental early return statement." - ); + if (current) + throw ReactError( + "Rendered fewer hooks than expected. This may be caused by an accidental early return statement." + ); return workInProgress; } function resetHooks() { @@ -3144,10 +3076,8 @@ function updateWorkInProgressHook() { (currentHook = nextCurrentHook), (nextCurrentHook = null !== currentHook ? currentHook.next : null); else { - invariant( - null !== nextCurrentHook, - "Rendered more hooks than during the previous render." - ); + if (null === nextCurrentHook) + throw ReactError("Rendered more hooks than during the previous render."); currentHook = nextCurrentHook; var newHook = { memoizedState: currentHook.memoizedState, @@ -3170,10 +3100,11 @@ function basicStateReducer(state, action) { function updateReducer(reducer) { var hook = updateWorkInProgressHook(), queue = hook.queue; - invariant( - null !== queue, - "Should have a queue. This is likely a bug in React. Please file an issue." - ); + if (null === queue) + throw ReactError( + "Should have a queue. This is likely a bug in React. Please file an issue." + ); + queue.lastRenderedReducer = reducer; if (0 < numberOfReRenders) { var _dispatch = queue.dispatch; if (null !== renderPhaseUpdates) { @@ -3188,6 +3119,7 @@ function updateReducer(reducer) { is(newState, hook.memoizedState) || (didReceiveUpdate = !0); hook.memoizedState = newState; hook.baseUpdate === queue.last && (hook.baseState = newState); + queue.lastRenderedState = newState; return [newState, _dispatch]; } } @@ -3213,10 +3145,12 @@ function updateReducer(reducer) { (firstRenderPhaseUpdate = newState)), updateExpirationTime > remainingExpirationTime && (remainingExpirationTime = updateExpirationTime)) - : (newState = + : (updateExpirationTime < mostRecentEventTime && + (mostRecentEventTime = updateExpirationTime), + (newState = _update.eagerReducer === reducer ? _update.eagerState - : reducer(newState, _update.action)); + : reducer(newState, _update.action))); baseUpdate = _update; _update = _update.next; } while (null !== _update && _update !== _dispatch); @@ -3226,8 +3160,7 @@ function updateReducer(reducer) { hook.memoizedState = newState; hook.baseUpdate = newBaseUpdate; hook.baseState = firstRenderPhaseUpdate; - queue.eagerReducer = reducer; - queue.eagerState = newState; + queue.lastRenderedState = newState; } return [hook.memoizedState, queue.dispatch]; } @@ -3263,7 +3196,7 @@ function updateEffectImpl(fiberEffectTag, hookEffectTag, create, deps) { var prevEffect = currentHook.memoizedState; destroy = prevEffect.destroy; if (null !== deps && areHookInputsEqual(deps, prevEffect.deps)) { - pushEffect(NoEffect$1, create, destroy, deps); + pushEffect(0, create, destroy, deps); return; } } @@ -3290,10 +3223,10 @@ function imperativeHandleEffect(create, ref) { } function mountDebugValue() {} function dispatchAction(fiber, queue, action) { - invariant( - 25 > numberOfReRenders, - "Too many re-renders. React limits the number of renders to prevent an infinite loop." - ); + if (!(25 > numberOfReRenders)) + throw ReactError( + "Too many re-renders. React limits the number of renders to prevent an infinite loop." + ); var alternate = fiber.alternate; if ( fiber === currentlyRenderingFiber$1 || @@ -3318,9 +3251,9 @@ function dispatchAction(fiber, queue, action) { queue.next = fiber; } else { - flushPassiveEffects(); - var currentTime = requestCurrentTime(); - currentTime = computeExpirationForFiber(currentTime, fiber); + flushPassiveEffects$$1(); + var currentTime = requestCurrentTime$$1(); + currentTime = computeExpirationForFiber$$1(currentTime, fiber); var _update2 = { expirationTime: currentTime, action: action, @@ -3339,10 +3272,10 @@ function dispatchAction(fiber, queue, action) { if ( 0 === fiber.expirationTime && (null === alternate || 0 === alternate.expirationTime) && - ((alternate = queue.eagerReducer), null !== alternate) + ((alternate = queue.lastRenderedReducer), null !== alternate) ) try { - var currentState = queue.eagerState, + var currentState = queue.lastRenderedState, _eagerState = alternate(currentState, action); _update2.eagerReducer = alternate; _update2.eagerState = _eagerState; @@ -3350,7 +3283,7 @@ function dispatchAction(fiber, queue, action) { } catch (error) { } finally { } - scheduleWork(fiber, currentTime); + scheduleWork$$1(fiber, currentTime); } } var ContextOnlyDispatcher = { @@ -3377,19 +3310,19 @@ var ContextOnlyDispatcher = { }, useContext: readContext, useEffect: function(create, deps) { - return mountEffectImpl(516, UnmountPassive | MountPassive, create, deps); + return mountEffectImpl(516, 192, create, deps); }, useImperativeHandle: function(ref, create, deps) { deps = null !== deps && void 0 !== deps ? deps.concat([ref]) : null; return mountEffectImpl( 4, - UnmountMutation | MountLayout, + 36, imperativeHandleEffect.bind(null, create, ref), deps ); }, useLayoutEffect: function(create, deps) { - return mountEffectImpl(4, UnmountMutation | MountLayout, create, deps); + return mountEffectImpl(4, 36, create, deps); }, useMemo: function(nextCreate, deps) { var hook = mountWorkInProgressHook(); @@ -3405,8 +3338,8 @@ var ContextOnlyDispatcher = { reducer = hook.queue = { last: null, dispatch: null, - eagerReducer: reducer, - eagerState: initialArg + lastRenderedReducer: reducer, + lastRenderedState: initialArg }; reducer = reducer.dispatch = dispatchAction.bind( null, @@ -3427,8 +3360,8 @@ var ContextOnlyDispatcher = { initialState = hook.queue = { last: null, dispatch: null, - eagerReducer: basicStateReducer, - eagerState: initialState + lastRenderedReducer: basicStateReducer, + lastRenderedState: initialState }; initialState = initialState.dispatch = dispatchAction.bind( null, @@ -3456,19 +3389,19 @@ var ContextOnlyDispatcher = { }, useContext: readContext, useEffect: function(create, deps) { - return updateEffectImpl(516, UnmountPassive | MountPassive, create, deps); + return updateEffectImpl(516, 192, create, deps); }, useImperativeHandle: function(ref, create, deps) { deps = null !== deps && void 0 !== deps ? deps.concat([ref]) : null; return updateEffectImpl( 4, - UnmountMutation | MountLayout, + 36, imperativeHandleEffect.bind(null, create, ref), deps ); }, useLayoutEffect: function(create, deps) { - return updateEffectImpl(4, UnmountMutation | MountLayout, create, deps); + return updateEffectImpl(4, 36, create, deps); }, useMemo: function(nextCreate, deps) { var hook = updateWorkInProgressHook(); @@ -3508,6 +3441,8 @@ function tryHydrate(fiber, nextInstance) { (nextInstance = shim$1(nextInstance, fiber.pendingProps)), null !== nextInstance ? ((fiber.stateNode = nextInstance), !0) : !1 ); + case 13: + return !1; default: return !1; } @@ -4042,7 +3977,10 @@ function updateSuspenseComponent( nextState = null; var nextDidTimeout = !1; } else - (nextState = { timedOutAt: null !== nextState ? nextState.timedOutAt : 0 }), + (nextState = { + fallbackExpirationTime: + null !== nextState ? nextState.fallbackExpirationTime : 0 + }), (nextDidTimeout = !0), (workInProgress.effectTag &= -65); if (null === current$$1) @@ -4137,10 +4075,8 @@ function bailoutOnAlreadyFinishedWork( null !== current$$1 && (workInProgress.contextDependencies = current$$1.contextDependencies); if (workInProgress.childExpirationTime < renderExpirationTime) return null; - invariant( - null === current$$1 || workInProgress.child === current$$1.child, - "Resuming work not yet implemented." - ); + if (null !== current$$1 && workInProgress.child !== current$$1.child) + throw ReactError("Resuming work not yet implemented."); if (null !== workInProgress.child) { current$$1 = workInProgress.child; renderExpirationTime = createWorkInProgress( @@ -4305,59 +4241,57 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { ((current$$1.alternate = null), (workInProgress.alternate = null), (workInProgress.effectTag |= 2)); - hasContext = workInProgress.pendingProps; - current$$1 = readLazyComponentType(context); - workInProgress.type = current$$1; - context = workInProgress.tag = resolveLazyComponentTag(current$$1); - hasContext = resolveDefaultProps(current$$1, hasContext); - getDerivedStateFromProps = void 0; - switch (context) { + current$$1 = workInProgress.pendingProps; + context = readLazyComponentType(context); + workInProgress.type = context; + hasContext = workInProgress.tag = resolveLazyComponentTag(context); + current$$1 = resolveDefaultProps(context, current$$1); + switch (hasContext) { case 0: - getDerivedStateFromProps = updateFunctionComponent( + workInProgress = updateFunctionComponent( null, workInProgress, + context, current$$1, - hasContext, renderExpirationTime ); break; case 1: - getDerivedStateFromProps = updateClassComponent( + workInProgress = updateClassComponent( null, workInProgress, + context, current$$1, - hasContext, renderExpirationTime ); break; case 11: - getDerivedStateFromProps = updateForwardRef( + workInProgress = updateForwardRef( null, workInProgress, + context, current$$1, - hasContext, renderExpirationTime ); break; case 14: - getDerivedStateFromProps = updateMemoComponent( + workInProgress = updateMemoComponent( null, workInProgress, - current$$1, - resolveDefaultProps(current$$1.type, hasContext), + context, + resolveDefaultProps(context.type, current$$1), updateExpirationTime, renderExpirationTime ); break; default: - invariant( - !1, - "Element type is invalid. Received a promise that resolves to: %s. Lazy element type must resolve to a class or function.%s", - current$$1, - "" + throw ReactError( + "Element type is invalid. Received a promise that resolves to: " + + context + + ". Lazy element type must resolve to a class or function." ); } - return getDerivedStateFromProps; + return workInProgress; case 0: return ( (updateExpirationTime = workInProgress.type), @@ -4391,38 +4325,36 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { ) ); case 3: - return ( - pushHostRootContext(workInProgress), - (updateExpirationTime = workInProgress.updateQueue), - invariant( - null !== updateExpirationTime, + pushHostRootContext(workInProgress); + updateExpirationTime = workInProgress.updateQueue; + if (null === updateExpirationTime) + throw ReactError( "If the root does not have an updateQueue, we should have already bailed out. This error is likely caused by a bug in React. Please file an issue." - ), - (context = workInProgress.memoizedState), - (context = null !== context ? context.element : null), - processUpdateQueue( - workInProgress, - updateExpirationTime, - workInProgress.pendingProps, - null, - renderExpirationTime - ), - (updateExpirationTime = workInProgress.memoizedState.element), - updateExpirationTime === context - ? (workInProgress = bailoutOnAlreadyFinishedWork( - current$$1, - workInProgress, - renderExpirationTime - )) - : (reconcileChildren( - current$$1, - workInProgress, - updateExpirationTime, - renderExpirationTime - ), - (workInProgress = workInProgress.child)), - workInProgress + ); + context = workInProgress.memoizedState; + context = null !== context ? context.element : null; + processUpdateQueue( + workInProgress, + updateExpirationTime, + workInProgress.pendingProps, + null, + renderExpirationTime ); + updateExpirationTime = workInProgress.memoizedState.element; + updateExpirationTime === context + ? (workInProgress = bailoutOnAlreadyFinishedWork( + current$$1, + workInProgress, + renderExpirationTime + )) + : (reconcileChildren( + current$$1, + workInProgress, + updateExpirationTime, + renderExpirationTime + ), + (workInProgress = workInProgress.child)); + return workInProgress; case 5: return ( pushHostContext(workInProgress), @@ -4435,8 +4367,7 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { updateExpirationTime, renderExpirationTime ), - (workInProgress = workInProgress.child), - workInProgress + workInProgress.child ); case 6: return ( @@ -4571,19 +4502,19 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { null !== dependency && dependency.expirationTime < renderExpirationTime && (dependency.expirationTime = renderExpirationTime); + dependency = renderExpirationTime; for (var node = oldValue.return; null !== node; ) { - dependency = node.alternate; - if (node.childExpirationTime < renderExpirationTime) - (node.childExpirationTime = renderExpirationTime), - null !== dependency && - dependency.childExpirationTime < - renderExpirationTime && - (dependency.childExpirationTime = renderExpirationTime); + var alternate = node.alternate; + if (node.childExpirationTime < dependency) + (node.childExpirationTime = dependency), + null !== alternate && + alternate.childExpirationTime < dependency && + (alternate.childExpirationTime = dependency); else if ( - null !== dependency && - dependency.childExpirationTime < renderExpirationTime + null !== alternate && + alternate.childExpirationTime < dependency ) - dependency.childExpirationTime = renderExpirationTime; + alternate.childExpirationTime = dependency; else break; node = node.return; } @@ -4713,12 +4644,10 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { renderExpirationTime ) ); - default: - invariant( - !1, - "Unknown unit of work tag. This error is likely caused by a bug in React. Please file an issue." - ); } + throw ReactError( + "Unknown unit of work tag. This error is likely caused by a bug in React. Please file an issue." + ); } var valueCursor = { current: null }, currentlyRenderingFiber = null, @@ -4752,17 +4681,17 @@ function readContext(context, observedBits) { if ("number" !== typeof observedBits || 1073741823 === observedBits) (lastContextWithAllBitsObserved = context), (observedBits = 1073741823); observedBits = { context: context, observedBits: observedBits, next: null }; - null === lastContextDependency - ? (invariant( - null !== currentlyRenderingFiber, + if (null === lastContextDependency) { + if (null === currentlyRenderingFiber) + throw ReactError( "Context can only be read while React is rendering. In classes, you can read it in the render method or getDerivedStateFromProps. In function components, you can read it directly in the function body, but not inside Hooks like useReducer() or useMemo()." - ), - (lastContextDependency = observedBits), - (currentlyRenderingFiber.contextDependencies = { - first: observedBits, - expirationTime: 0 - })) - : (lastContextDependency = lastContextDependency.next = observedBits); + ); + lastContextDependency = observedBits; + currentlyRenderingFiber.contextDependencies = { + first: observedBits, + expirationTime: 0 + }; + } else lastContextDependency = lastContextDependency.next = observedBits; } return context._currentValue2; } @@ -4915,7 +4844,9 @@ function processUpdateQueue( ((newFirstUpdate = update), (newBaseState = resultState)), newExpirationTime < updateExpirationTime && (newExpirationTime = updateExpirationTime)) - : ((resultState = getStateFromUpdate( + : (updateExpirationTime < mostRecentEventTime && + (mostRecentEventTime = updateExpirationTime), + (resultState = getStateFromUpdate( workInProgress, queue, update, @@ -4988,11 +4919,11 @@ function commitUpdateEffects(effect, instance) { if (null !== _callback3) { effect.callback = null; var context = instance; - invariant( - "function" === typeof _callback3, - "Invalid argument passed as callback. Expected a function. Instead received: %s", - _callback3 - ); + if ("function" !== typeof _callback3) + throw ReactError( + "Invalid argument passed as callback. Expected a function. Instead received: " + + _callback3 + ); _callback3.call(context); } effect = effect.nextEffect; @@ -5016,39 +4947,41 @@ appendAllChildren = function( isHidden ) { for (var node = workInProgress.child; null !== node; ) { - a: if (5 === node.tag) { + if (5 === node.tag) { var instance = node.stateNode; - if (needsVisibilityToggle) { - var props = node.memoizedProps, - type = node.type; - instance = isHidden - ? cloneHiddenInstance(instance, type, props, node) - : cloneUnhiddenInstance(instance, type, props, node); - node.stateNode = instance; - } + needsVisibilityToggle && + isHidden && + (instance = cloneHiddenInstance( + instance, + node.type, + node.memoizedProps, + node + )); FabricUIManager.appendChild(parent.node, instance.node); } else if (6 === node.tag) { instance = node.stateNode; - if (needsVisibilityToggle) { - instance = node.memoizedProps; - props = requiredContext(rootInstanceStackCursor.current); - type = requiredContext(contextStackCursor$1.current); - if (isHidden) throw Error("Not yet implemented."); - instance = createTextInstance(instance, props, type, workInProgress); - node.stateNode = instance; - } + if (needsVisibilityToggle && isHidden) + throw Error("Not yet implemented."); FabricUIManager.appendChild(parent.node, instance.node); } else if (4 !== node.tag) { if ( 13 === node.tag && - ((props = node.alternate), - null !== props && - ((instance = null !== node.memoizedState), - (null !== props.memoizedState) !== instance)) + 0 !== (node.effectTag & 4) && + (instance = null !== node.memoizedState) ) { - props = instance ? node.child : node; - null !== props && appendAllChildren(parent, props, !0, instance); - break a; + var primaryChildParent = node.child; + if ( + null !== primaryChildParent && + (null !== primaryChildParent.child && + ((primaryChildParent.child.return = primaryChildParent), + appendAllChildren(parent, primaryChildParent, !0, instance)), + (instance = primaryChildParent.sibling), + null !== instance) + ) { + instance.return = node; + node = instance; + continue; + } } if (null !== node.child) { node.child.return = node; @@ -5072,40 +5005,46 @@ function appendAllChildrenToContainer( isHidden ) { for (var node = workInProgress.child; null !== node; ) { - a: if (5 === node.tag) { + if (5 === node.tag) { var instance = node.stateNode; - if (needsVisibilityToggle) { - var props = node.memoizedProps, - type = node.type; - instance = isHidden - ? cloneHiddenInstance(instance, type, props, node) - : cloneUnhiddenInstance(instance, type, props, node); - node.stateNode = instance; - } + needsVisibilityToggle && + isHidden && + (instance = cloneHiddenInstance( + instance, + node.type, + node.memoizedProps, + node + )); FabricUIManager.appendChildToSet(containerChildSet, instance.node); } else if (6 === node.tag) { instance = node.stateNode; - if (needsVisibilityToggle) { - instance = node.memoizedProps; - props = requiredContext(rootInstanceStackCursor.current); - type = requiredContext(contextStackCursor$1.current); - if (isHidden) throw Error("Not yet implemented."); - instance = createTextInstance(instance, props, type, workInProgress); - node.stateNode = instance; - } + if (needsVisibilityToggle && isHidden) + throw Error("Not yet implemented."); FabricUIManager.appendChildToSet(containerChildSet, instance.node); } else if (4 !== node.tag) { if ( 13 === node.tag && - ((props = node.alternate), - null !== props && - ((instance = null !== node.memoizedState), - (null !== props.memoizedState) !== instance)) + 0 !== (node.effectTag & 4) && + (instance = null !== node.memoizedState) ) { - props = instance ? node.child : node; - null !== props && - appendAllChildrenToContainer(containerChildSet, props, !0, instance); - break a; + var primaryChildParent = node.child; + if ( + null !== primaryChildParent && + (null !== primaryChildParent.child && + ((primaryChildParent.child.return = primaryChildParent), + appendAllChildrenToContainer( + containerChildSet, + primaryChildParent, + !0, + instance + )), + (instance = primaryChildParent.sibling), + null !== instance) + ) { + instance.return = node; + node = instance; + continue; + } } if (null !== node.child) { node.child.return = node; @@ -5208,6 +5147,7 @@ function logCapturedError(capturedError) { : Error("Unspecified error at:" + componentStack); ExceptionsManager.handleException(error, !1); } +var PossiblyWeakSet$1 = "function" === typeof WeakSet ? WeakSet : Set; function logError(boundary, errorInfo) { var source = errorInfo.source, stack = errorInfo.stack; @@ -5244,7 +5184,7 @@ function safelyDetachRef(current$$1) { try { ref(null); } catch (refError) { - captureCommitPhaseError(current$$1, refError); + captureCommitPhaseError$$1(current$$1, refError); } else ref.current = null; } @@ -5254,12 +5194,12 @@ function commitHookEffectList(unmountTag, mountTag, finishedWork) { if (null !== finishedWork) { var effect = (finishedWork = finishedWork.next); do { - if ((effect.tag & unmountTag) !== NoEffect$1) { + if (0 !== (effect.tag & unmountTag)) { var destroy = effect.destroy; effect.destroy = void 0; void 0 !== destroy && destroy(); } - (effect.tag & mountTag) !== NoEffect$1 && + 0 !== (effect.tag & mountTag) && ((destroy = effect.create), (effect.destroy = destroy())); effect = effect.next; } while (effect !== finishedWork); @@ -5271,26 +5211,47 @@ function commitWork(current$$1, finishedWork) { case 11: case 14: case 15: - commitHookEffectList(UnmountMutation, MountMutation, finishedWork); + commitHookEffectList(4, 8, finishedWork); + return; + case 12: + return; + case 13: + commitSuspenseComponent(finishedWork); return; } switch (finishedWork.tag) { case 1: - break; case 5: - break; case 6: + case 20: break; case 3: case 4: break; default: - invariant( - !1, + throw ReactError( "This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue." ); } } +function commitSuspenseComponent(finishedWork) { + var newState = finishedWork.memoizedState; + null !== newState && + 0 === newState.fallbackExpirationTime && + (newState.fallbackExpirationTime = requestCurrentTime$$1() - 500); + newState = finishedWork.updateQueue; + if (null !== newState) { + finishedWork.updateQueue = null; + var retryCache = finishedWork.stateNode; + null === retryCache && + (retryCache = finishedWork.stateNode = new PossiblyWeakSet$1()); + newState.forEach(function(thenable) { + var retry = resolveRetryThenable$$1.bind(null, finishedWork, thenable); + retryCache.has(thenable) || + (retryCache.add(thenable), thenable.then(retry, retry)); + }); + } +} var PossiblyWeakMap = "function" === typeof WeakMap ? WeakMap : Map; function createRootErrorUpdate(fiber, errorInfo, expirationTime) { expirationTime = createUpdate(expirationTime); @@ -5298,7 +5259,7 @@ function createRootErrorUpdate(fiber, errorInfo, expirationTime) { expirationTime.payload = { element: null }; var error = errorInfo.value; expirationTime.callback = function() { - onUncaughtError(error); + onUncaughtError$$1(error); logError(fiber, errorInfo); }; return expirationTime; @@ -5340,17 +5301,15 @@ function unwindWork(workInProgress) { workInProgress) : null; case 3: - return ( - popHostContainer(workInProgress), - popTopLevelContextObject(workInProgress), - (effectTag = workInProgress.effectTag), - invariant( - 0 === (effectTag & 64), + popHostContainer(workInProgress); + popTopLevelContextObject(workInProgress); + effectTag = workInProgress.effectTag; + if (0 !== (effectTag & 64)) + throw ReactError( "The root failed to unmount after an error. This is likely a bug in React. Please file an issue." - ), - (workInProgress.effectTag = (effectTag & -2049) | 64), - workInProgress - ); + ); + workInProgress.effectTag = (effectTag & -2049) | 64; + return workInProgress; case 5: return popHostContext(workInProgress), null; case 13: @@ -5361,21 +5320,33 @@ function unwindWork(workInProgress) { workInProgress) : null ); + case 18: + return null; case 4: return popHostContainer(workInProgress), null; case 10: return popProvider(workInProgress), null; + case 19: + case 20: + return null; default: return null; } } -var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher, +var scheduleCallback$1 = Scheduler.unstable_scheduleCallback, + cancelCallback$1 = Scheduler.unstable_cancelCallback, + shouldYield$1 = Scheduler.unstable_shouldYield, + now$1 = Scheduler.unstable_now, + getCurrentPriorityLevel$1 = Scheduler.unstable_getCurrentPriorityLevel, + NormalPriority$1 = Scheduler.unstable_NormalPriority, + ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher, ReactCurrentOwner$2 = ReactSharedInternals.ReactCurrentOwner, isWorking = !1, nextUnitOfWork = null, nextRoot = null, nextRenderExpirationTime = 0, - nextLatestAbsoluteTimeoutMs = -1, + mostRecentEventTime = 1073741823, + nextRenderDidSuspend = !1, nextRenderDidError = !1, nextEffect = null, isCommitting$1 = !1, @@ -5416,254 +5387,10 @@ function resetStack() { } nextRoot = null; nextRenderExpirationTime = 0; - nextLatestAbsoluteTimeoutMs = -1; - nextRenderDidError = !1; + mostRecentEventTime = 1073741823; + nextRenderDidError = nextRenderDidSuspend = !1; nextUnitOfWork = null; } -function commitAllHostEffects() { - for (; null !== nextEffect; ) { - var effectTag = nextEffect.effectTag; - if (effectTag & 128) { - var current$$1 = nextEffect.alternate; - null !== current$$1 && - ((current$$1 = current$$1.ref), - null !== current$$1 && - ("function" === typeof current$$1 - ? current$$1(null) - : (current$$1.current = null))); - } - switch (effectTag & 14) { - case 2: - nextEffect.effectTag &= -3; - break; - case 6: - nextEffect.effectTag &= -3; - commitWork(nextEffect.alternate, nextEffect); - break; - case 4: - commitWork(nextEffect.alternate, nextEffect); - break; - case 8: - effectTag = nextEffect; - a: for (var node = (current$$1 = effectTag); ; ) { - var current$$1$jscomp$0 = node; - "function" === typeof onCommitFiberUnmount && - onCommitFiberUnmount(current$$1$jscomp$0); - switch (current$$1$jscomp$0.tag) { - case 0: - case 11: - case 14: - case 15: - var updateQueue = current$$1$jscomp$0.updateQueue; - if ( - null !== updateQueue && - ((updateQueue = updateQueue.lastEffect), null !== updateQueue) - ) { - var effect = (updateQueue = updateQueue.next); - do { - var destroy = effect.destroy; - if (void 0 !== destroy) { - var current$$1$jscomp$1 = current$$1$jscomp$0; - try { - destroy(); - } catch (error) { - captureCommitPhaseError(current$$1$jscomp$1, error); - } - } - effect = effect.next; - } while (effect !== updateQueue); - } - break; - case 1: - safelyDetachRef(current$$1$jscomp$0); - updateQueue = current$$1$jscomp$0.stateNode; - if ("function" === typeof updateQueue.componentWillUnmount) - try { - (updateQueue.props = current$$1$jscomp$0.memoizedProps), - (updateQueue.state = current$$1$jscomp$0.memoizedState), - updateQueue.componentWillUnmount(); - } catch (unmountError) { - captureCommitPhaseError(current$$1$jscomp$0, unmountError); - } - break; - case 5: - safelyDetachRef(current$$1$jscomp$0); - break; - case 4: - FabricUIManager.createChildSet( - current$$1$jscomp$0.stateNode.containerInfo - ); - } - if (null !== node.child) - (node.child.return = node), (node = node.child); - else { - if (node === current$$1) break; - for (; null === node.sibling; ) { - if (null === node.return || node.return === current$$1) break a; - node = node.return; - } - node.sibling.return = node.return; - node = node.sibling; - } - } - effectTag.return = null; - effectTag.child = null; - effectTag.memoizedState = null; - effectTag.updateQueue = null; - effectTag = effectTag.alternate; - null !== effectTag && - ((effectTag.return = null), - (effectTag.child = null), - (effectTag.memoizedState = null), - (effectTag.updateQueue = null)); - } - nextEffect = nextEffect.nextEffect; - } -} -function commitBeforeMutationLifecycles() { - for (; null !== nextEffect; ) { - if (nextEffect.effectTag & 256) - a: { - var current$$1 = nextEffect.alternate, - finishedWork = nextEffect; - switch (finishedWork.tag) { - case 0: - case 11: - case 15: - commitHookEffectList(UnmountSnapshot, NoEffect$1, finishedWork); - break a; - case 1: - if (finishedWork.effectTag & 256 && null !== current$$1) { - var prevProps = current$$1.memoizedProps, - prevState = current$$1.memoizedState; - current$$1 = finishedWork.stateNode; - finishedWork = current$$1.getSnapshotBeforeUpdate( - finishedWork.elementType === finishedWork.type - ? prevProps - : resolveDefaultProps(finishedWork.type, prevProps), - prevState - ); - current$$1.__reactInternalSnapshotBeforeUpdate = finishedWork; - } - break a; - case 3: - case 5: - case 6: - case 4: - case 17: - break a; - default: - invariant( - !1, - "This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue." - ); - } - } - nextEffect = nextEffect.nextEffect; - } -} -function commitAllLifeCycles(finishedRoot, committedExpirationTime$jscomp$0) { - for (; null !== nextEffect; ) { - var effectTag = nextEffect.effectTag; - if (effectTag & 36) { - var current$$1 = nextEffect.alternate, - finishedWork = nextEffect, - committedExpirationTime = committedExpirationTime$jscomp$0; - switch (finishedWork.tag) { - case 0: - case 11: - case 15: - commitHookEffectList(UnmountLayout, MountLayout, finishedWork); - break; - case 1: - var instance = finishedWork.stateNode; - if (finishedWork.effectTag & 4) - if (null === current$$1) instance.componentDidMount(); - else { - var prevProps = - finishedWork.elementType === finishedWork.type - ? current$$1.memoizedProps - : resolveDefaultProps( - finishedWork.type, - current$$1.memoizedProps - ); - instance.componentDidUpdate( - prevProps, - current$$1.memoizedState, - instance.__reactInternalSnapshotBeforeUpdate - ); - } - current$$1 = finishedWork.updateQueue; - null !== current$$1 && - commitUpdateQueue( - finishedWork, - current$$1, - instance, - committedExpirationTime - ); - break; - case 3: - instance = finishedWork.updateQueue; - if (null !== instance) { - current$$1 = null; - if (null !== finishedWork.child) - switch (finishedWork.child.tag) { - case 5: - current$$1 = finishedWork.child.stateNode.canonical; - break; - case 1: - current$$1 = finishedWork.child.stateNode; - } - commitUpdateQueue( - finishedWork, - instance, - current$$1, - committedExpirationTime - ); - } - break; - case 5: - null === current$$1 && - finishedWork.effectTag & 4 && - invariant( - !1, - "The current renderer does not support mutation. This error is likely caused by a bug in React. Please file an issue." - ); - break; - case 6: - break; - case 4: - break; - case 12: - break; - case 13: - break; - case 17: - break; - default: - invariant( - !1, - "This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue." - ); - } - } - if ( - effectTag & 128 && - ((finishedWork = nextEffect.ref), null !== finishedWork) - ) { - committedExpirationTime = nextEffect.stateNode; - switch (nextEffect.tag) { - case 5: - committedExpirationTime = committedExpirationTime.canonical; - } - "function" === typeof finishedWork - ? finishedWork(committedExpirationTime) - : (finishedWork.current = committedExpirationTime); - } - effectTag & 512 && (rootWithPendingPassiveEffects = finishedRoot); - nextEffect = nextEffect.nextEffect; - } -} function commitPassiveEffects(root, firstEffect) { passiveEffectCallback = passiveEffectCallbackHandle = rootWithPendingPassiveEffects = null; var previousIsRendering = isRendering; @@ -5674,132 +5401,32 @@ function commitPassiveEffects(root, firstEffect) { error = void 0; try { var finishedWork = firstEffect; - commitHookEffectList(UnmountPassive, NoEffect$1, finishedWork); - commitHookEffectList(NoEffect$1, MountPassive, finishedWork); + commitHookEffectList(128, 0, finishedWork); + commitHookEffectList(0, 64, finishedWork); } catch (e) { (didError = !0), (error = e); } - didError && captureCommitPhaseError(firstEffect, error); + didError && captureCommitPhaseError$1(firstEffect, error); } firstEffect = firstEffect.nextEffect; } while (null !== firstEffect); isRendering = previousIsRendering; previousIsRendering = root.expirationTime; 0 !== previousIsRendering && requestWork(root, previousIsRendering); + isBatchingUpdates || isRendering || performWork(1073741823); } -function flushPassiveEffects() { - if (null !== passiveEffectCallbackHandle) { - var callbackID = passiveEffectCallbackHandle; - scheduledCallback = null; - clearTimeout(callbackID); - } - null !== passiveEffectCallback && passiveEffectCallback(); -} -function commitRoot(root, finishedWork) { - isCommitting$1 = isWorking = !0; - invariant( - root.current !== finishedWork, - "Cannot commit the same tree as before. This is probably a bug related to the return field. This error is likely caused by a bug in React. Please file an issue." - ); - var committedExpirationTime = root.pendingCommitExpirationTime; - invariant( - 0 !== committedExpirationTime, - "Cannot commit an incomplete root. This error is likely caused by a bug in React. Please file an issue." +function isAlreadyFailedLegacyErrorBoundary$1(instance) { + return ( + null !== legacyErrorBoundariesThatAlreadyFailed && + legacyErrorBoundariesThatAlreadyFailed.has(instance) ); - root.pendingCommitExpirationTime = 0; - var updateExpirationTimeBeforeCommit = finishedWork.expirationTime, - childExpirationTimeBeforeCommit = finishedWork.childExpirationTime; - markCommittedPriorityLevels( - root, - childExpirationTimeBeforeCommit > updateExpirationTimeBeforeCommit - ? childExpirationTimeBeforeCommit - : updateExpirationTimeBeforeCommit - ); - ReactCurrentOwner$2.current = null; - updateExpirationTimeBeforeCommit = void 0; - 1 < finishedWork.effectTag - ? null !== finishedWork.lastEffect - ? ((finishedWork.lastEffect.nextEffect = finishedWork), - (updateExpirationTimeBeforeCommit = finishedWork.firstEffect)) - : (updateExpirationTimeBeforeCommit = finishedWork) - : (updateExpirationTimeBeforeCommit = finishedWork.firstEffect); - for (nextEffect = updateExpirationTimeBeforeCommit; null !== nextEffect; ) { - childExpirationTimeBeforeCommit = !1; - var error = void 0; - try { - commitBeforeMutationLifecycles(); - } catch (e) { - (childExpirationTimeBeforeCommit = !0), (error = e); - } - childExpirationTimeBeforeCommit && - (invariant( - null !== nextEffect, - "Should have next effect. This error is likely caused by a bug in React. Please file an issue." - ), - captureCommitPhaseError(nextEffect, error), - null !== nextEffect && (nextEffect = nextEffect.nextEffect)); - } - for (nextEffect = updateExpirationTimeBeforeCommit; null !== nextEffect; ) { - childExpirationTimeBeforeCommit = !1; - error = void 0; - try { - commitAllHostEffects(); - } catch (e) { - (childExpirationTimeBeforeCommit = !0), (error = e); - } - childExpirationTimeBeforeCommit && - (invariant( - null !== nextEffect, - "Should have next effect. This error is likely caused by a bug in React. Please file an issue." - ), - captureCommitPhaseError(nextEffect, error), - null !== nextEffect && (nextEffect = nextEffect.nextEffect)); - } - root.current = finishedWork; - for (nextEffect = updateExpirationTimeBeforeCommit; null !== nextEffect; ) { - childExpirationTimeBeforeCommit = !1; - error = void 0; - try { - commitAllLifeCycles(root, committedExpirationTime); - } catch (e) { - (childExpirationTimeBeforeCommit = !0), (error = e); - } - childExpirationTimeBeforeCommit && - (invariant( - null !== nextEffect, - "Should have next effect. This error is likely caused by a bug in React. Please file an issue." - ), - captureCommitPhaseError(nextEffect, error), - null !== nextEffect && (nextEffect = nextEffect.nextEffect)); - } - if ( - null !== updateExpirationTimeBeforeCommit && - null !== rootWithPendingPassiveEffects - ) { - var callback = commitPassiveEffects.bind( - null, - root, - updateExpirationTimeBeforeCommit - ); - passiveEffectCallbackHandle = scheduler.unstable_runWithPriority( - scheduler.unstable_NormalPriority, - function() { - return scheduleDeferredCallback$1(callback); - } - ); - passiveEffectCallback = callback; - } - isWorking = isCommitting$1 = !1; - "function" === typeof onCommitFiberRoot && - onCommitFiberRoot(finishedWork.stateNode); - committedExpirationTime = finishedWork.expirationTime; - finishedWork = finishedWork.childExpirationTime; - finishedWork = - finishedWork > committedExpirationTime - ? finishedWork - : committedExpirationTime; - 0 === finishedWork && (legacyErrorBoundariesThatAlreadyFailed = null); - onCommit(root, finishedWork); +} +function flushPassiveEffects$1() { + var didFlushEffects = null !== passiveEffectCallback; + null !== passiveEffectCallbackHandle && + cancelCallback$1(passiveEffectCallbackHandle); + null !== passiveEffectCallback && passiveEffectCallback(); + return didFlushEffects; } function completeUnitOfWork(workInProgress) { for (;;) { @@ -5852,16 +5479,15 @@ function completeUnitOfWork(workInProgress) { current.ref !== current$$1.ref && (current$$1.effectTag |= 128); else if (instance) { var currentHostContext = requiredContext( - contextStackCursor$1.current - ), - internalInstanceHandle = current$$1; + contextStackCursor$1.current + ); current = nextReactTag; nextReactTag += 2; var viewConfig = ReactNativeViewConfigRegistry.get(type); - invariant( - "RCTView" !== type || !currentHostContext.isInAParentText, - "Nesting of within is not currently supported." - ); + if ("RCTView" === type && currentHostContext.isInAParentText) + throw ReactError( + "Nesting of within is not currently supported." + ); type = diffProperties( null, emptyObject, @@ -5873,46 +5499,47 @@ function completeUnitOfWork(workInProgress) { viewConfig.uiViewClassName, renderExpirationTime, type, - internalInstanceHandle + current$$1 ); instance = new ReactFabricHostComponent( current, viewConfig, - instance + instance, + current$$1 ); instance = { node: renderExpirationTime, canonical: instance }; appendAllChildren(instance, current$$1, !1, !1); current$$1.stateNode = instance; null !== current$$1.ref && (current$$1.effectTag |= 128); - } else - invariant( - null !== current$$1.stateNode, + } else if (null === current$$1.stateNode) + throw ReactError( "We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue." ); break; case 6: - current && null != current$$1.stateNode - ? updateHostText$1( - current, - current$$1, - current.memoizedProps, - instance - ) - : ("string" !== typeof instance && - invariant( - null !== current$$1.stateNode, - "We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue." - ), - (current = requiredContext(rootInstanceStackCursor.current)), - (renderExpirationTime = requiredContext( - contextStackCursor$1.current - )), - (current$$1.stateNode = createTextInstance( - instance, - current, - renderExpirationTime, - current$$1 - ))); + if (current && null != current$$1.stateNode) + updateHostText$1( + current, + current$$1, + current.memoizedProps, + instance + ); + else { + if ("string" !== typeof instance && null === current$$1.stateNode) + throw ReactError( + "We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue." + ); + current = requiredContext(rootInstanceStackCursor.current); + renderExpirationTime = requiredContext( + contextStackCursor$1.current + ); + current$$1.stateNode = createTextInstance( + instance, + current, + renderExpirationTime, + current$$1 + ); + } break; case 11: break; @@ -5924,21 +5551,29 @@ function completeUnitOfWork(workInProgress) { break a; } instance = null !== instance; - renderExpirationTime = - null !== current && null !== current.memoizedState; + renderExpirationTime = !1; null !== current && - !instance && - renderExpirationTime && - ((current = current.child.sibling), - null !== current && - ((viewConfig = current$$1.firstEffect), - null !== viewConfig - ? ((current$$1.firstEffect = current), - (current.nextEffect = viewConfig)) - : ((current$$1.firstEffect = current$$1.lastEffect = current), - (current.nextEffect = null)), - (current.effectTag = 8))); - if (instance || renderExpirationTime) current$$1.effectTag |= 4; + ((viewConfig = current.memoizedState), + (renderExpirationTime = null !== viewConfig), + instance || + null === viewConfig || + ((viewConfig = viewConfig.fallbackExpirationTime), + viewConfig < mostRecentEventTime && + (mostRecentEventTime = viewConfig), + (current = current.child.sibling), + null !== current && + ((viewConfig = current$$1.firstEffect), + null !== viewConfig + ? ((current$$1.firstEffect = current), + (current.nextEffect = viewConfig)) + : ((current$$1.firstEffect = current$$1.lastEffect = current), + (current.nextEffect = null)), + (current.effectTag = 8)))); + instance && + !renderExpirationTime && + 0 !== (current$$1.mode & 1) && + (nextRenderDidSuspend = !0); + instance && (current$$1.effectTag |= 4); break; case 7: break; @@ -5960,9 +5595,14 @@ function completeUnitOfWork(workInProgress) { case 17: isContextProvider(current$$1.type) && popContext(current$$1); break; + case 18: + break; + case 19: + break; + case 20: + break; default: - invariant( - !1, + throw ReactError( "Unknown unit of work tag. This error is likely caused by a bug in React. Please file an issue." ); } @@ -6023,11 +5663,11 @@ function performUnitOfWork(workInProgress) { return next; } function renderRoot(root$jscomp$0, isYieldy) { - invariant( - !isWorking, - "renderRoot was called recursively. This error is likely caused by a bug in React. Please file an issue." - ); - flushPassiveEffects(); + if (isWorking) + throw ReactError( + "renderRoot was called recursively. This error is likely caused by a bug in React. Please file an issue." + ); + flushPassiveEffects$1(); isWorking = !0; var previousDispatcher = ReactCurrentDispatcher.current; ReactCurrentDispatcher.current = ContextOnlyDispatcher; @@ -6050,7 +5690,7 @@ function renderRoot(root$jscomp$0, isYieldy) { do { try { if (isYieldy) - for (; null !== nextUnitOfWork && !shouldYieldToRenderer(); ) + for (; null !== nextUnitOfWork && !shouldYield$1(); ) nextUnitOfWork = performUnitOfWork(nextUnitOfWork); else for (; null !== nextUnitOfWork; ) @@ -6061,15 +5701,16 @@ function renderRoot(root$jscomp$0, isYieldy) { resetHooks(), null === nextUnitOfWork) ) - (didFatal = !0), onUncaughtError(thrownValue); + (didFatal = !0), onUncaughtError$1(thrownValue); else { - invariant( - null !== nextUnitOfWork, - "Failed to replay rendering after an error. This is likely caused by a bug in React. Please file an issue with a reproducing case to help us find it." - ); + if (null === nextUnitOfWork) + throw ReactError( + "Failed to replay rendering after an error. This is likely caused by a bug in React. Please file an issue with a reproducing case to help us find it." + ); var sourceFiber = nextUnitOfWork, returnFiber = sourceFiber.return; - if (null === returnFiber) (didFatal = !0), onUncaughtError(thrownValue); + if (null === returnFiber) + (didFatal = !0), onUncaughtError$1(thrownValue); else { a: { var root = root$jscomp$0, @@ -6086,38 +5727,13 @@ function renderRoot(root$jscomp$0, isYieldy) { ) { var thenable = value; value = returnFiber$jscomp$0; - var earliestTimeoutMs = -1, - startTimeMs = -1; do { - if (13 === value.tag) { - var current$$1 = value.alternate; - if ( - null !== current$$1 && - ((current$$1 = current$$1.memoizedState), - null !== current$$1) - ) { - startTimeMs = 10 * (1073741822 - current$$1.timedOutAt); - break; - } - current$$1 = value.pendingProps.maxDuration; - if ("number" === typeof current$$1) - if (0 >= current$$1) earliestTimeoutMs = 0; - else if ( - -1 === earliestTimeoutMs || - current$$1 < earliestTimeoutMs - ) - earliestTimeoutMs = current$$1; - } - value = value.return; - } while (null !== value); - value = returnFiber$jscomp$0; - do { - if ((current$$1 = 13 === value.tag)) - current$$1 = - void 0 === value.memoizedProps.fallback - ? !1 - : null === value.memoizedState; - if (current$$1) { + if ( + 13 === value.tag && + (void 0 === value.memoizedProps.fallback + ? 0 + : null === value.memoizedState) + ) { returnFiber$jscomp$0 = value.updateQueue; null === returnFiber$jscomp$0 ? ((returnFiber$jscomp$0 = new Set()), @@ -6136,44 +5752,25 @@ function renderRoot(root$jscomp$0, isYieldy) { sourceFiber$jscomp$0.expirationTime = 1073741823; break a; } - sourceFiber$jscomp$0 = root.pingCache; - null === sourceFiber$jscomp$0 - ? ((sourceFiber$jscomp$0 = root.pingCache = new PossiblyWeakMap()), + sourceFiber$jscomp$0 = returnFiber; + var pingCache = root.pingCache; + null === pingCache + ? ((pingCache = root.pingCache = new PossiblyWeakMap()), (returnFiber$jscomp$0 = new Set()), - sourceFiber$jscomp$0.set(thenable, returnFiber$jscomp$0)) - : ((returnFiber$jscomp$0 = sourceFiber$jscomp$0.get( - thenable - )), + pingCache.set(thenable, returnFiber$jscomp$0)) + : ((returnFiber$jscomp$0 = pingCache.get(thenable)), void 0 === returnFiber$jscomp$0 && ((returnFiber$jscomp$0 = new Set()), - sourceFiber$jscomp$0.set( - thenable, - returnFiber$jscomp$0 - ))); - returnFiber$jscomp$0.has(returnFiber) || - (returnFiber$jscomp$0.add(returnFiber), - (sourceFiber$jscomp$0 = pingSuspendedRoot.bind( + pingCache.set(thenable, returnFiber$jscomp$0))); + returnFiber$jscomp$0.has(sourceFiber$jscomp$0) || + (returnFiber$jscomp$0.add(sourceFiber$jscomp$0), + (root = pingSuspendedRoot$$1.bind( null, root, thenable, - returnFiber + sourceFiber$jscomp$0 )), - thenable.then(sourceFiber$jscomp$0, sourceFiber$jscomp$0)); - -1 === earliestTimeoutMs - ? (root = 1073741823) - : (-1 === startTimeMs && - (startTimeMs = - 10 * - (1073741822 - - findEarliestOutstandingPriorityLevel( - root, - returnFiber - )) - - 5e3), - (root = startTimeMs + earliestTimeoutMs)); - 0 <= root && - nextLatestAbsoluteTimeoutMs < root && - (nextLatestAbsoluteTimeoutMs = root); + thenable.then(root, root)); value.effectTag |= 2048; value.expirationTime = returnFiber; break a; @@ -6200,24 +5797,24 @@ function renderRoot(root$jscomp$0, isYieldy) { break a; case 1: if ( - ((thenable = value), - (earliestTimeoutMs = root.type), - (startTimeMs = root.stateNode), + ((sourceFiber$jscomp$0 = value), + (thenable = root.type), + (returnFiber$jscomp$0 = root.stateNode), 0 === (root.effectTag & 64) && ("function" === - typeof earliestTimeoutMs.getDerivedStateFromError || - (null !== startTimeMs && - "function" === typeof startTimeMs.componentDidCatch && - (null === legacyErrorBoundariesThatAlreadyFailed || - !legacyErrorBoundariesThatAlreadyFailed.has( - startTimeMs - ))))) + typeof thenable.getDerivedStateFromError || + (null !== returnFiber$jscomp$0 && + "function" === + typeof returnFiber$jscomp$0.componentDidCatch && + !isAlreadyFailedLegacyErrorBoundary$$1( + returnFiber$jscomp$0 + )))) ) { root.effectTag |= 2048; root.expirationTime = returnFiber; returnFiber = createClassErrorUpdate( root, - thenable, + sourceFiber$jscomp$0, returnFiber ); enqueueCapturedUpdate(root, returnFiber); @@ -6242,10 +5839,10 @@ function renderRoot(root$jscomp$0, isYieldy) { else if (null !== nextUnitOfWork) root$jscomp$0.finishedWork = null; else { previousDispatcher = root$jscomp$0.current.alternate; - invariant( - null !== previousDispatcher, - "Finished root should have a work-in-progress. This error is likely caused by a bug in React. Please file an issue." - ); + if (null === previousDispatcher) + throw ReactError( + "Finished root should have a work-in-progress. This error is likely caused by a bug in React. Please file an issue." + ); nextRoot = null; if (nextRenderDidError) { didFatal = root$jscomp$0.latestPendingTime; @@ -6280,19 +5877,11 @@ function renderRoot(root$jscomp$0, isYieldy) { return; } } - isYieldy && -1 !== nextLatestAbsoluteTimeoutMs + isYieldy && nextRenderDidSuspend && 1073741823 !== mostRecentEventTime ? (markSuspendedPriorityLevel(root$jscomp$0, expirationTime), (isYieldy = - 10 * - (1073741822 - - findEarliestOutstandingPriorityLevel( - root$jscomp$0, - expirationTime - ))), - isYieldy < nextLatestAbsoluteTimeoutMs && - (nextLatestAbsoluteTimeoutMs = isYieldy), - (isYieldy = 10 * (1073741822 - requestCurrentTime())), - (isYieldy = nextLatestAbsoluteTimeoutMs - isYieldy), + 10 * (1073741822 - mostRecentEventTime) - 5e3 + originalStartTimeMs), + (isYieldy = 150 - (now$1() - isYieldy)), onSuspend( root$jscomp$0, previousDispatcher, @@ -6304,7 +5893,7 @@ function renderRoot(root$jscomp$0, isYieldy) { (root$jscomp$0.finishedWork = previousDispatcher)); } } -function captureCommitPhaseError(sourceFiber, value) { +function captureCommitPhaseError$1(sourceFiber, value) { for (var fiber = sourceFiber.return; null !== fiber; ) { switch (fiber.tag) { case 1: @@ -6312,13 +5901,12 @@ function captureCommitPhaseError(sourceFiber, value) { if ( "function" === typeof fiber.type.getDerivedStateFromError || ("function" === typeof instance.componentDidCatch && - (null === legacyErrorBoundariesThatAlreadyFailed || - !legacyErrorBoundariesThatAlreadyFailed.has(instance))) + !isAlreadyFailedLegacyErrorBoundary$1(instance)) ) { sourceFiber = createCapturedValue(value, sourceFiber); sourceFiber = createClassErrorUpdate(fiber, sourceFiber, 1073741823); enqueueUpdate(fiber, sourceFiber); - scheduleWork(fiber, 1073741823); + scheduleWork$1(fiber, 1073741823); return; } break; @@ -6326,7 +5914,7 @@ function captureCommitPhaseError(sourceFiber, value) { sourceFiber = createCapturedValue(value, sourceFiber); sourceFiber = createRootErrorUpdate(fiber, sourceFiber, 1073741823); enqueueUpdate(fiber, sourceFiber); - scheduleWork(fiber, 1073741823); + scheduleWork$1(fiber, 1073741823); return; } fiber = fiber.return; @@ -6335,66 +5923,27 @@ function captureCommitPhaseError(sourceFiber, value) { ((fiber = createCapturedValue(value, sourceFiber)), (fiber = createRootErrorUpdate(sourceFiber, fiber, 1073741823)), enqueueUpdate(sourceFiber, fiber), - scheduleWork(sourceFiber, 1073741823)); -} -function computeExpirationForFiber(currentTime, fiber) { - var priorityLevel = scheduler.unstable_getCurrentPriorityLevel(), - expirationTime = void 0; - if (0 === (fiber.mode & 1)) expirationTime = 1073741823; - else if (isWorking && !isCommitting$1) - expirationTime = nextRenderExpirationTime; - else { - switch (priorityLevel) { - case scheduler.unstable_ImmediatePriority: - expirationTime = 1073741823; - break; - case scheduler.unstable_UserBlockingPriority: - expirationTime = - 1073741822 - 10 * ((((1073741822 - currentTime + 15) / 10) | 0) + 1); - break; - case scheduler.unstable_NormalPriority: - expirationTime = - 1073741822 - 25 * ((((1073741822 - currentTime + 500) / 25) | 0) + 1); - break; - case scheduler.unstable_LowPriority: - case scheduler.unstable_IdlePriority: - expirationTime = 1; - break; - default: - invariant( - !1, - "Unknown priority level. This error is likely caused by a bug in React. Please file an issue." - ); - } - null !== nextRoot && - expirationTime === nextRenderExpirationTime && - --expirationTime; - } - priorityLevel === scheduler.unstable_UserBlockingPriority && + scheduleWork$1(sourceFiber, 1073741823)); +} +function computeExpirationForFiber$1(currentTime, fiber) { + isWorking + ? (currentTime = isCommitting$1 ? 1073741823 : nextRenderExpirationTime) + : fiber.mode & 1 + ? ((currentTime = isBatchingInteractiveUpdates + ? 1073741822 - 10 * ((((1073741822 - currentTime + 15) / 10) | 0) + 1) + : 1073741822 - + 25 * ((((1073741822 - currentTime + 500) / 25) | 0) + 1)), + null !== nextRoot && + currentTime === nextRenderExpirationTime && + --currentTime) + : (currentTime = 1073741823); + isBatchingInteractiveUpdates && (0 === lowestPriorityPendingInteractiveExpirationTime || - expirationTime < lowestPriorityPendingInteractiveExpirationTime) && - (lowestPriorityPendingInteractiveExpirationTime = expirationTime); - return expirationTime; -} -function pingSuspendedRoot(root, thenable, pingTime) { - var pingCache = root.pingCache; - null !== pingCache && pingCache.delete(thenable); - if (null !== nextRoot && nextRenderExpirationTime === pingTime) - nextRoot = null; - else if ( - ((thenable = root.earliestSuspendedTime), - (pingCache = root.latestSuspendedTime), - 0 !== thenable && pingTime <= thenable && pingTime >= pingCache) - ) { - root.didError = !1; - thenable = root.latestPingedTime; - if (0 === thenable || thenable > pingTime) root.latestPingedTime = pingTime; - findNextExpirationTimeToWorkOn(pingTime, root); - pingTime = root.expirationTime; - 0 !== pingTime && requestWork(root, pingTime); - } + currentTime < lowestPriorityPendingInteractiveExpirationTime) && + (lowestPriorityPendingInteractiveExpirationTime = currentTime); + return currentTime; } -function scheduleWork(fiber, expirationTime) { +function scheduleWorkToRoot(fiber, expirationTime) { fiber.expirationTime < expirationTime && (fiber.expirationTime = expirationTime); var alternate = fiber.alternate; @@ -6418,8 +5967,12 @@ function scheduleWork(fiber, expirationTime) { } node = node.return; } - fiber = root; - null !== fiber && + return root; +} +function scheduleWork$1(fiber, expirationTime) { + fiber = scheduleWorkToRoot(fiber, expirationTime); + if ( + null !== fiber && (!isWorking && 0 !== nextRenderExpirationTime && expirationTime > nextRenderExpirationTime && @@ -6427,12 +5980,12 @@ function scheduleWork(fiber, expirationTime) { markPendingPriorityLevel(fiber, expirationTime), (isWorking && !isCommitting$1 && nextRoot === fiber) || requestWork(fiber, fiber.expirationTime), - nestedUpdateCount > NESTED_UPDATE_LIMIT && - ((nestedUpdateCount = 0), - invariant( - !1, - "Maximum update depth exceeded. This can happen when a component repeatedly calls setState inside componentWillUpdate or componentDidUpdate. React limits the number of nested updates to prevent infinite loops." - ))); + nestedUpdateCount > NESTED_UPDATE_LIMIT) + ) + throw ((nestedUpdateCount = 0), + ReactError( + "Maximum update depth exceeded. This can happen when a component repeatedly calls setState inside componentWillUpdate or componentDidUpdate. React limits the number of nested updates to prevent infinite loops." + )); } var firstScheduledRoot = null, lastScheduledRoot = null, @@ -6446,6 +5999,7 @@ var firstScheduledRoot = null, unhandledError = null, isBatchingUpdates = !1, isUnbatchingUpdates = !1, + isBatchingInteractiveUpdates = !1, completedBatches = null, originalStartTimeMs = now$1(), currentRendererTime = 1073741822 - ((originalStartTimeMs / 10) | 0), @@ -6460,13 +6014,14 @@ function recomputeCurrentRendererTime() { function scheduleCallbackWithExpirationTime(root, expirationTime) { if (0 !== callbackExpirationTime) { if (expirationTime < callbackExpirationTime) return; - null !== callbackID && - ((root = callbackID), (scheduledCallback = null), clearTimeout(root)); + null !== callbackID && cancelCallback$1(callbackID); } callbackExpirationTime = expirationTime; root = now$1() - originalStartTimeMs; - callbackID = scheduleDeferredCallback$1(performAsyncWork, { - timeout: 10 * (1073741822 - expirationTime) - root + expirationTime = 10 * (1073741822 - expirationTime) - root; + root = getCurrentPriorityLevel$1(); + callbackID = scheduleCallback$1(root, performAsyncWork, { + timeout: expirationTime }); } function onSuspend( @@ -6477,7 +6032,7 @@ function onSuspend( msUntilTimeout ) { root.expirationTime = rootExpirationTime; - 0 !== msUntilTimeout || shouldYieldToRenderer() + 0 !== msUntilTimeout || shouldYield$1() ? 0 < msUntilTimeout && (root.timeoutHandle = scheduleTimeout( onTimeout.bind(null, root, finishedWork, suspendedExpirationTime), @@ -6491,20 +6046,16 @@ function onTimeout(root, finishedWork, suspendedExpirationTime) { root.finishedWork = finishedWork; recomputeCurrentRendererTime(); currentSchedulerTime = currentRendererTime; - invariant( - !isRendering, - "work.commit(): Cannot commit while already rendering. This likely means you attempted to commit from inside a lifecycle method." - ); + if (isRendering) + throw ReactError( + "work.commit(): Cannot commit while already rendering. This likely means you attempted to commit from inside a lifecycle method." + ); nextFlushedRoot = root; nextFlushedExpirationTime = suspendedExpirationTime; performWorkOnRoot(root, suspendedExpirationTime, !1); - performWork(1073741823, !1); -} -function onCommit(root, expirationTime) { - root.expirationTime = expirationTime; - root.finishedWork = null; + performWork(1073741823); } -function requestCurrentTime() { +function requestCurrentTime$1() { if (isRendering) return currentSchedulerTime; findHighestPriorityRoot(); if (0 === nextFlushedExpirationTime || 1 === nextFlushedExpirationTime) @@ -6529,7 +6080,7 @@ function requestWork(root, expirationTime) { (nextFlushedExpirationTime = 1073741823), performWorkOnRoot(root, 1073741823, !1)) : 1073741823 === expirationTime - ? performWork(1073741823, !1) + ? performWork(1073741823) : scheduleCallbackWithExpirationTime(root, expirationTime)); } function findHighestPriorityRoot() { @@ -6543,10 +6094,10 @@ function findHighestPriorityRoot() { ) { var remainingExpirationTime = root.expirationTime; if (0 === remainingExpirationTime) { - invariant( - null !== previousScheduledRoot && null !== lastScheduledRoot, - "Should have a previous and last root. This error is likely caused by a bug in React. Please file an issue." - ); + if (null === previousScheduledRoot || null === lastScheduledRoot) + throw ReactError( + "Should have a previous and last root. This error is likely caused by a bug in React. Please file an issue." + ); if (root === root.nextScheduledRoot) { firstScheduledRoot = lastScheduledRoot = root.nextScheduledRoot = null; break; @@ -6577,75 +6128,69 @@ function findHighestPriorityRoot() { nextFlushedRoot = highestPriorityRoot; nextFlushedExpirationTime = highestPriorityWork; } -var didYield = !1; -function shouldYieldToRenderer() { - return didYield ? !0 : frameDeadline <= now$1() ? (didYield = !0) : !1; -} -function performAsyncWork() { - try { - if (!shouldYieldToRenderer() && null !== firstScheduledRoot) { - recomputeCurrentRendererTime(); - var root = firstScheduledRoot; - do { - var expirationTime = root.expirationTime; - 0 !== expirationTime && - currentRendererTime <= expirationTime && - (root.nextExpirationTimeToWorkOn = currentRendererTime); - root = root.nextScheduledRoot; - } while (root !== firstScheduledRoot); - } - performWork(0, !0); - } finally { - didYield = !1; +function performAsyncWork(didTimeout) { + if (didTimeout && null !== firstScheduledRoot) { + recomputeCurrentRendererTime(); + didTimeout = firstScheduledRoot; + do { + var expirationTime = didTimeout.expirationTime; + 0 !== expirationTime && + currentRendererTime <= expirationTime && + (didTimeout.nextExpirationTimeToWorkOn = currentRendererTime); + didTimeout = didTimeout.nextScheduledRoot; + } while (didTimeout !== firstScheduledRoot); } -} -function performWork(minExpirationTime, isYieldy) { findHighestPriorityRoot(); - if (isYieldy) - for ( - recomputeCurrentRendererTime(), - currentSchedulerTime = currentRendererTime; - null !== nextFlushedRoot && - 0 !== nextFlushedExpirationTime && - minExpirationTime <= nextFlushedExpirationTime && - !(didYield && currentRendererTime > nextFlushedExpirationTime); + recomputeCurrentRendererTime(); + for ( + currentSchedulerTime = currentRendererTime; + null !== nextFlushedRoot && + 0 !== nextFlushedExpirationTime && + !(shouldYield$1() && currentRendererTime > nextFlushedExpirationTime); - ) - performWorkOnRoot( - nextFlushedRoot, - nextFlushedExpirationTime, - currentRendererTime > nextFlushedExpirationTime - ), - findHighestPriorityRoot(), - recomputeCurrentRendererTime(), - (currentSchedulerTime = currentRendererTime); - else - for ( - ; - null !== nextFlushedRoot && - 0 !== nextFlushedExpirationTime && - minExpirationTime <= nextFlushedExpirationTime; + ) + performWorkOnRoot( + nextFlushedRoot, + nextFlushedExpirationTime, + currentRendererTime > nextFlushedExpirationTime + ), + findHighestPriorityRoot(), + recomputeCurrentRendererTime(), + (currentSchedulerTime = currentRendererTime); + callbackExpirationTime = 0; + callbackID = null; + 0 !== nextFlushedExpirationTime && + scheduleCallbackWithExpirationTime( + nextFlushedRoot, + nextFlushedExpirationTime + ); + finishRendering(); +} +function performWork(minExpirationTime) { + for ( + findHighestPriorityRoot(); + null !== nextFlushedRoot && + 0 !== nextFlushedExpirationTime && + minExpirationTime <= nextFlushedExpirationTime; - ) - performWorkOnRoot(nextFlushedRoot, nextFlushedExpirationTime, !1), - findHighestPriorityRoot(); - isYieldy && ((callbackExpirationTime = 0), (callbackID = null)); + ) + performWorkOnRoot(nextFlushedRoot, nextFlushedExpirationTime, !1), + findHighestPriorityRoot(); 0 !== nextFlushedExpirationTime && scheduleCallbackWithExpirationTime( nextFlushedRoot, nextFlushedExpirationTime ); + finishRendering(); +} +function finishRendering() { nestedUpdateCount = 0; lastCommittedRootDuringThisBatch = null; - if (null !== completedBatches) - for ( - minExpirationTime = completedBatches, - completedBatches = null, - isYieldy = 0; - isYieldy < minExpirationTime.length; - isYieldy++ - ) { - var batch = minExpirationTime[isYieldy]; + if (null !== completedBatches) { + var batches = completedBatches; + completedBatches = null; + for (var i = 0; i < batches.length; i++) { + var batch = batches[i]; try { batch._onComplete(); } catch (error) { @@ -6653,17 +6198,18 @@ function performWork(minExpirationTime, isYieldy) { ((hasUnhandledError = !0), (unhandledError = error)); } } + } if (hasUnhandledError) - throw ((minExpirationTime = unhandledError), + throw ((batches = unhandledError), (unhandledError = null), (hasUnhandledError = !1), - minExpirationTime); + batches); } function performWorkOnRoot(root, expirationTime, isYieldy) { - invariant( - !isRendering, - "performWorkOnRoot was called recursively. This error is likely caused by a bug in React. Please file an issue." - ); + if (isRendering) + throw ReactError( + "performWorkOnRoot was called recursively. This error is likely caused by a bug in React. Please file an issue." + ); isRendering = !0; if (isYieldy) { var _finishedWork = root.finishedWork; @@ -6676,7 +6222,7 @@ function performWorkOnRoot(root, expirationTime, isYieldy) { renderRoot(root, isYieldy), (_finishedWork = root.finishedWork), null !== _finishedWork && - (shouldYieldToRenderer() + (shouldYield$1() ? (root.finishedWork = _finishedWork) : completeRoot$1(root, _finishedWork, expirationTime))); } else @@ -6693,7 +6239,7 @@ function performWorkOnRoot(root, expirationTime, isYieldy) { completeRoot$1(root, _finishedWork, expirationTime)); isRendering = !1; } -function completeRoot$1(root, finishedWork, expirationTime) { +function completeRoot$1(root, finishedWork$jscomp$0, expirationTime) { var firstBatch = root.firstBatch; if ( null !== firstBatch && @@ -6703,7 +6249,7 @@ function completeRoot$1(root, finishedWork, expirationTime) { : completedBatches.push(firstBatch), firstBatch._defer) ) { - root.finishedWork = finishedWork; + root.finishedWork = finishedWork$jscomp$0; root.expirationTime = 0; return; } @@ -6711,46 +6257,455 @@ function completeRoot$1(root, finishedWork, expirationTime) { root === lastCommittedRootDuringThisBatch ? nestedUpdateCount++ : ((lastCommittedRootDuringThisBatch = root), (nestedUpdateCount = 0)); - scheduler.unstable_runWithPriority( - scheduler.unstable_ImmediatePriority, - function() { - commitRoot(root, finishedWork); + isCommitting$1 = isWorking = !0; + if (root.current === finishedWork$jscomp$0) + throw ReactError( + "Cannot commit the same tree as before. This is probably a bug related to the return field. This error is likely caused by a bug in React. Please file an issue." + ); + expirationTime = root.pendingCommitExpirationTime; + if (0 === expirationTime) + throw ReactError( + "Cannot commit an incomplete root. This error is likely caused by a bug in React. Please file an issue." + ); + root.pendingCommitExpirationTime = 0; + firstBatch = finishedWork$jscomp$0.expirationTime; + var childExpirationTimeBeforeCommit = + finishedWork$jscomp$0.childExpirationTime; + firstBatch = + childExpirationTimeBeforeCommit > firstBatch + ? childExpirationTimeBeforeCommit + : firstBatch; + root.didError = !1; + 0 === firstBatch + ? ((root.earliestPendingTime = 0), + (root.latestPendingTime = 0), + (root.earliestSuspendedTime = 0), + (root.latestSuspendedTime = 0), + (root.latestPingedTime = 0)) + : (firstBatch < root.latestPingedTime && (root.latestPingedTime = 0), + (childExpirationTimeBeforeCommit = root.latestPendingTime), + 0 !== childExpirationTimeBeforeCommit && + (childExpirationTimeBeforeCommit > firstBatch + ? (root.earliestPendingTime = root.latestPendingTime = 0) + : root.earliestPendingTime > firstBatch && + (root.earliestPendingTime = root.latestPendingTime)), + (childExpirationTimeBeforeCommit = root.earliestSuspendedTime), + 0 === childExpirationTimeBeforeCommit + ? markPendingPriorityLevel(root, firstBatch) + : firstBatch < root.latestSuspendedTime + ? ((root.earliestSuspendedTime = 0), + (root.latestSuspendedTime = 0), + (root.latestPingedTime = 0), + markPendingPriorityLevel(root, firstBatch)) + : firstBatch > childExpirationTimeBeforeCommit && + markPendingPriorityLevel(root, firstBatch)); + findNextExpirationTimeToWorkOn(0, root); + ReactCurrentOwner$2.current = null; + 1 < finishedWork$jscomp$0.effectTag + ? null !== finishedWork$jscomp$0.lastEffect + ? ((finishedWork$jscomp$0.lastEffect.nextEffect = finishedWork$jscomp$0), + (firstBatch = finishedWork$jscomp$0.firstEffect)) + : (firstBatch = finishedWork$jscomp$0) + : (firstBatch = finishedWork$jscomp$0.firstEffect); + for (nextEffect = firstBatch; null !== nextEffect; ) { + childExpirationTimeBeforeCommit = !1; + var error$jscomp$0 = void 0; + try { + for (; null !== nextEffect; ) { + if (nextEffect.effectTag & 256) { + var current$$1 = nextEffect.alternate, + finishedWork = nextEffect; + switch (finishedWork.tag) { + case 0: + case 11: + case 15: + commitHookEffectList(2, 0, finishedWork); + break; + case 1: + if (finishedWork.effectTag & 256 && null !== current$$1) { + var prevProps = current$$1.memoizedProps, + prevState = current$$1.memoizedState, + instance = finishedWork.stateNode, + snapshot = instance.getSnapshotBeforeUpdate( + finishedWork.elementType === finishedWork.type + ? prevProps + : resolveDefaultProps(finishedWork.type, prevProps), + prevState + ); + instance.__reactInternalSnapshotBeforeUpdate = snapshot; + } + break; + case 3: + case 5: + case 6: + case 4: + case 17: + case 20: + break; + default: + throw ReactError( + "This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue." + ); + } + } + nextEffect = nextEffect.nextEffect; + } + } catch (e) { + (childExpirationTimeBeforeCommit = !0), (error$jscomp$0 = e); } - ); + if (childExpirationTimeBeforeCommit) { + if (null === nextEffect) + throw ReactError( + "Should have next effect. This error is likely caused by a bug in React. Please file an issue." + ); + captureCommitPhaseError$1(nextEffect, error$jscomp$0); + null !== nextEffect && (nextEffect = nextEffect.nextEffect); + } + } + for (nextEffect = firstBatch; null !== nextEffect; ) { + current$$1 = !1; + prevProps = void 0; + try { + for (; null !== nextEffect; ) { + var effectTag = nextEffect.effectTag; + if (effectTag & 128) { + var current$$1$jscomp$0 = nextEffect.alternate; + if (null !== current$$1$jscomp$0) { + var currentRef = current$$1$jscomp$0.ref; + null !== currentRef && + ("function" === typeof currentRef + ? currentRef(null) + : (currentRef.current = null)); + } + } + switch (effectTag & 14) { + case 2: + nextEffect.effectTag &= -3; + break; + case 6: + nextEffect.effectTag &= -3; + commitWork(nextEffect.alternate, nextEffect); + break; + case 4: + commitWork(nextEffect.alternate, nextEffect); + break; + case 8: + prevState = nextEffect; + a: for (snapshot = instance = prevState; ; ) { + childExpirationTimeBeforeCommit = snapshot; + "function" === typeof onCommitFiberUnmount && + onCommitFiberUnmount(childExpirationTimeBeforeCommit); + switch (childExpirationTimeBeforeCommit.tag) { + case 0: + case 11: + case 14: + case 15: + var updateQueue = childExpirationTimeBeforeCommit.updateQueue; + if (null !== updateQueue) { + var lastEffect = updateQueue.lastEffect; + if (null !== lastEffect) { + var firstEffect = lastEffect.next; + error$jscomp$0 = firstEffect; + do { + var destroy = error$jscomp$0.destroy; + if (void 0 !== destroy) { + finishedWork = childExpirationTimeBeforeCommit; + try { + destroy(); + } catch (error) { + captureCommitPhaseError$$1(finishedWork, error); + } + } + error$jscomp$0 = error$jscomp$0.next; + } while (error$jscomp$0 !== firstEffect); + } + } + break; + case 1: + safelyDetachRef(childExpirationTimeBeforeCommit); + var instance$jscomp$0 = + childExpirationTimeBeforeCommit.stateNode; + if ( + "function" === typeof instance$jscomp$0.componentWillUnmount + ) + try { + (instance$jscomp$0.props = + childExpirationTimeBeforeCommit.memoizedProps), + (instance$jscomp$0.state = + childExpirationTimeBeforeCommit.memoizedState), + instance$jscomp$0.componentWillUnmount(); + } catch (unmountError) { + captureCommitPhaseError$$1( + childExpirationTimeBeforeCommit, + unmountError + ); + } + break; + case 5: + safelyDetachRef(childExpirationTimeBeforeCommit); + break; + case 4: + FabricUIManager.createChildSet( + childExpirationTimeBeforeCommit.stateNode.containerInfo + ); + } + if (null !== snapshot.child) + (snapshot.child.return = snapshot), (snapshot = snapshot.child); + else { + if (snapshot === instance) break; + for (; null === snapshot.sibling; ) { + if (null === snapshot.return || snapshot.return === instance) + break a; + snapshot = snapshot.return; + } + snapshot.sibling.return = snapshot.return; + snapshot = snapshot.sibling; + } + } + prevState.return = null; + prevState.child = null; + prevState.memoizedState = null; + prevState.updateQueue = null; + var alternate = prevState.alternate; + null !== alternate && + ((alternate.return = null), + (alternate.child = null), + (alternate.memoizedState = null), + (alternate.updateQueue = null)); + } + nextEffect = nextEffect.nextEffect; + } + } catch (e) { + (current$$1 = !0), (prevProps = e); + } + if (current$$1) { + if (null === nextEffect) + throw ReactError( + "Should have next effect. This error is likely caused by a bug in React. Please file an issue." + ); + captureCommitPhaseError$1(nextEffect, prevProps); + null !== nextEffect && (nextEffect = nextEffect.nextEffect); + } + } + root.current = finishedWork$jscomp$0; + for (nextEffect = firstBatch; null !== nextEffect; ) { + effectTag = !1; + current$$1$jscomp$0 = void 0; + try { + for ( + currentRef = root, updateQueue = expirationTime; + null !== nextEffect; + + ) { + var effectTag$jscomp$0 = nextEffect.effectTag; + if (effectTag$jscomp$0 & 36) { + var current$$1$jscomp$1 = nextEffect.alternate; + lastEffect = nextEffect; + firstEffect = updateQueue; + switch (lastEffect.tag) { + case 0: + case 11: + case 15: + commitHookEffectList(16, 32, lastEffect); + break; + case 1: + var instance$jscomp$1 = lastEffect.stateNode; + if (lastEffect.effectTag & 4) + if (null === current$$1$jscomp$1) + instance$jscomp$1.componentDidMount(); + else { + var prevProps$jscomp$0 = + lastEffect.elementType === lastEffect.type + ? current$$1$jscomp$1.memoizedProps + : resolveDefaultProps( + lastEffect.type, + current$$1$jscomp$1.memoizedProps + ); + instance$jscomp$1.componentDidUpdate( + prevProps$jscomp$0, + current$$1$jscomp$1.memoizedState, + instance$jscomp$1.__reactInternalSnapshotBeforeUpdate + ); + } + var updateQueue$jscomp$0 = lastEffect.updateQueue; + null !== updateQueue$jscomp$0 && + commitUpdateQueue( + lastEffect, + updateQueue$jscomp$0, + instance$jscomp$1, + firstEffect + ); + break; + case 3: + var _updateQueue = lastEffect.updateQueue; + if (null !== _updateQueue) { + destroy = null; + if (null !== lastEffect.child) + switch (lastEffect.child.tag) { + case 5: + destroy = lastEffect.child.stateNode.canonical; + break; + case 1: + destroy = lastEffect.child.stateNode; + } + commitUpdateQueue( + lastEffect, + _updateQueue, + destroy, + firstEffect + ); + } + break; + case 5: + if (null === current$$1$jscomp$1 && lastEffect.effectTag & 4) + throw ReactError( + "The current renderer does not support mutation. This error is likely caused by a bug in React. Please file an issue." + ); + break; + case 6: + break; + case 4: + break; + case 12: + break; + case 13: + case 17: + case 20: + break; + default: + throw ReactError( + "This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue." + ); + } + } + if (effectTag$jscomp$0 & 128) { + lastEffect = void 0; + var ref = nextEffect.ref; + if (null !== ref) { + var instance$jscomp$2 = nextEffect.stateNode; + switch (nextEffect.tag) { + case 5: + lastEffect = instance$jscomp$2.canonical; + break; + default: + lastEffect = instance$jscomp$2; + } + "function" === typeof ref + ? ref(lastEffect) + : (ref.current = lastEffect); + } + } + effectTag$jscomp$0 & 512 && + (rootWithPendingPassiveEffects = currentRef); + nextEffect = nextEffect.nextEffect; + } + } catch (e) { + (effectTag = !0), (current$$1$jscomp$0 = e); + } + if (effectTag) { + if (null === nextEffect) + throw ReactError( + "Should have next effect. This error is likely caused by a bug in React. Please file an issue." + ); + captureCommitPhaseError$1(nextEffect, current$$1$jscomp$0); + null !== nextEffect && (nextEffect = nextEffect.nextEffect); + } + } + null !== firstBatch && + null !== rootWithPendingPassiveEffects && + ((effectTag$jscomp$0 = commitPassiveEffects.bind(null, root, firstBatch)), + (passiveEffectCallbackHandle = scheduleCallback$1( + NormalPriority$1, + effectTag$jscomp$0 + )), + (passiveEffectCallback = effectTag$jscomp$0)); + isWorking = isCommitting$1 = !1; + "function" === typeof onCommitFiberRoot && + onCommitFiberRoot(finishedWork$jscomp$0.stateNode); + effectTag$jscomp$0 = finishedWork$jscomp$0.expirationTime; + finishedWork$jscomp$0 = finishedWork$jscomp$0.childExpirationTime; + finishedWork$jscomp$0 = + finishedWork$jscomp$0 > effectTag$jscomp$0 + ? finishedWork$jscomp$0 + : effectTag$jscomp$0; + 0 === finishedWork$jscomp$0 && + (legacyErrorBoundariesThatAlreadyFailed = null); + root.expirationTime = finishedWork$jscomp$0; + root.finishedWork = null; } -function onUncaughtError(error) { - invariant( - null !== nextFlushedRoot, - "Should be working on a root. This error is likely caused by a bug in React. Please file an issue." - ); +function onUncaughtError$1(error) { + if (null === nextFlushedRoot) + throw ReactError( + "Should be working on a root. This error is likely caused by a bug in React. Please file an issue." + ); nextFlushedRoot.expirationTime = 0; hasUnhandledError || ((hasUnhandledError = !0), (unhandledError = error)); } +Scheduler_now(); +var requestCurrentTime$$1 = requestCurrentTime$1, + computeExpirationForFiber$$1 = computeExpirationForFiber$1, + captureCommitPhaseError$$1 = captureCommitPhaseError$1, + onUncaughtError$$1 = onUncaughtError$1; +function pingSuspendedRoot$$1(root, thenable, pingTime) { + var pingCache = root.pingCache; + null !== pingCache && pingCache.delete(thenable); + if (null !== nextRoot && nextRenderExpirationTime === pingTime) + nextRoot = null; + else if ( + ((thenable = root.earliestSuspendedTime), + (pingCache = root.latestSuspendedTime), + 0 !== thenable && pingTime <= thenable && pingTime >= pingCache) + ) { + root.didError = !1; + thenable = root.latestPingedTime; + if (0 === thenable || thenable > pingTime) root.latestPingedTime = pingTime; + findNextExpirationTimeToWorkOn(pingTime, root); + pingTime = root.expirationTime; + 0 !== pingTime && requestWork(root, pingTime); + } +} +function resolveRetryThenable$$1(boundaryFiber, thenable) { + var retryCache = boundaryFiber.stateNode; + null !== retryCache && retryCache.delete(thenable); + thenable = requestCurrentTime$1(); + thenable = computeExpirationForFiber$1(thenable, boundaryFiber); + boundaryFiber = scheduleWorkToRoot(boundaryFiber, thenable); + null !== boundaryFiber && + (markPendingPriorityLevel(boundaryFiber, thenable), + (thenable = boundaryFiber.expirationTime), + 0 !== thenable && requestWork(boundaryFiber, thenable)); +} +var isAlreadyFailedLegacyErrorBoundary$$1 = isAlreadyFailedLegacyErrorBoundary$1, + scheduleWork$$1 = scheduleWork$1, + flushPassiveEffects$$1 = flushPassiveEffects$1; function findHostInstance(component) { var fiber = component._reactInternalFiber; - void 0 === fiber && - ("function" === typeof component.render - ? invariant(!1, "Unable to find node on an unmounted component.") - : invariant( - !1, - "Argument appears to not be a ReactComponent. Keys: %s", - Object.keys(component) - )); + if (void 0 === fiber) { + if ("function" === typeof component.render) + throw ReactError("Unable to find node on an unmounted component."); + throw ReactError( + "Argument appears to not be a ReactComponent. Keys: " + + Object.keys(component) + ); + } component = findCurrentHostFiber(fiber); return null === component ? null : component.stateNode; } function updateContainer(element, container, parentComponent, callback) { var current$$1 = container.current, - currentTime = requestCurrentTime(); - current$$1 = computeExpirationForFiber(currentTime, current$$1); + currentTime = requestCurrentTime$$1(); + current$$1 = computeExpirationForFiber$$1(currentTime, current$$1); currentTime = container.current; a: if (parentComponent) { parentComponent = parentComponent._reactInternalFiber; b: { - invariant( - 2 === isFiberMountedImpl(parentComponent) && 1 === parentComponent.tag, - "Expected subtree parent to be a mounted class component. This error is likely caused by a bug in React. Please file an issue." - ); + if ( + 2 !== isFiberMountedImpl(parentComponent) || + 1 !== parentComponent.tag + ) + throw ReactError( + "Expected subtree parent to be a mounted class component. This error is likely caused by a bug in React. Please file an issue." + ); var parentContext = parentComponent; do { switch (parentContext.tag) { @@ -6767,11 +6722,9 @@ function updateContainer(element, container, parentComponent, callback) { } parentContext = parentContext.return; } while (null !== parentContext); - invariant( - !1, + throw ReactError( "Found unexpected detached subtree parent. This error is likely caused by a bug in React. Please file an issue." ); - parentContext = void 0; } if (1 === parentComponent.tag) { var Component = parentComponent.type; @@ -6794,9 +6747,9 @@ function updateContainer(element, container, parentComponent, callback) { callback.payload = { element: element }; container = void 0 === container ? null : container; null !== container && (callback.callback = container); - flushPassiveEffects(); + flushPassiveEffects$$1(); enqueueUpdate(currentTime, callback); - scheduleWork(currentTime, current$$1); + scheduleWork$$1(currentTime, current$$1); return current$$1; } function createPortal(children, containerInfo, implementation) { @@ -6831,7 +6784,9 @@ function _inherits(subClass, superClass) { } var getInspectorDataForViewTag = void 0; getInspectorDataForViewTag = function() { - invariant(!1, "getInspectorDataForViewTag() is not available in production"); + throw ReactError( + "getInspectorDataForViewTag() is not available in production" + ); }; function findNodeHandle(componentOrHandle) { if (null == componentOrHandle) return null; @@ -6854,13 +6809,13 @@ _batchedUpdatesImpl = function(fn, a) { } finally { (isBatchingUpdates = previousIsBatchingUpdates) || isRendering || - performWork(1073741823, !1); + performWork(1073741823); } }; _flushInteractiveUpdatesImpl = function() { isRendering || 0 === lowestPriorityPendingInteractiveExpirationTime || - (performWork(lowestPriorityPendingInteractiveExpirationTime, !1), + (performWork(lowestPriorityPendingInteractiveExpirationTime), (lowestPriorityPendingInteractiveExpirationTime = 0)); }; var roots = new Map(), @@ -6888,47 +6843,81 @@ var roots = new Map(), TextInputState.focusTextInput(findNodeHandle(this)); }; ReactNativeComponent.prototype.measure = function(callback) { - UIManager.measure( - findNodeHandle(this), - mountSafeCallback_NOT_REALLY_SAFE(this, callback) - ); + var maybeInstance = void 0; + try { + maybeInstance = findHostInstance(this); + } catch (error) {} + null != maybeInstance && + (maybeInstance.canonical + ? FabricUIManager.measure( + maybeInstance.node, + mountSafeCallback_NOT_REALLY_SAFE(this, callback) + ) + : UIManager.measure( + findNodeHandle(this), + mountSafeCallback_NOT_REALLY_SAFE(this, callback) + )); }; ReactNativeComponent.prototype.measureInWindow = function(callback) { - UIManager.measureInWindow( - findNodeHandle(this), - mountSafeCallback_NOT_REALLY_SAFE(this, callback) - ); + var maybeInstance = void 0; + try { + maybeInstance = findHostInstance(this); + } catch (error) {} + null != maybeInstance && + (maybeInstance.canonical + ? FabricUIManager.measureInWindow( + maybeInstance.node, + mountSafeCallback_NOT_REALLY_SAFE(this, callback) + ) + : UIManager.measureInWindow( + findNodeHandle(this), + mountSafeCallback_NOT_REALLY_SAFE(this, callback) + )); }; ReactNativeComponent.prototype.measureLayout = function( relativeToNativeNode, onSuccess, onFail ) { - UIManager.measureLayout( - findNodeHandle(this), - relativeToNativeNode, - mountSafeCallback_NOT_REALLY_SAFE(this, onFail), - mountSafeCallback_NOT_REALLY_SAFE(this, onSuccess) - ); + var maybeInstance = void 0; + try { + maybeInstance = findHostInstance(this); + } catch (error) {} + null == maybeInstance || + maybeInstance.canonical || + ((maybeInstance = void 0), + "number" === typeof relativeToNativeNode + ? (maybeInstance = relativeToNativeNode) + : relativeToNativeNode._nativeTag && + (maybeInstance = relativeToNativeNode._nativeTag), + null != maybeInstance && + UIManager.measureLayout( + findNodeHandle(this), + maybeInstance, + mountSafeCallback_NOT_REALLY_SAFE(this, onFail), + mountSafeCallback_NOT_REALLY_SAFE(this, onSuccess) + )); }; ReactNativeComponent.prototype.setNativeProps = function(nativeProps) { var maybeInstance = void 0; try { maybeInstance = findHostInstance(this); } catch (error) {} - if (null != maybeInstance) { - var viewConfig = + if (null != maybeInstance && !maybeInstance.canonical) { + var nativeTag = + maybeInstance._nativeTag || maybeInstance.canonical._nativeTag; + maybeInstance = maybeInstance.viewConfig || maybeInstance.canonical.viewConfig; nativeProps = diffProperties( null, emptyObject, nativeProps, - viewConfig.validAttributes + maybeInstance.validAttributes ); null != nativeProps && UIManager.updateView( - maybeInstance._nativeTag, - viewConfig.uiViewClassName, + nativeTag, + maybeInstance.uiViewClassName, nativeProps ); } @@ -6937,33 +6926,14 @@ var roots = new Map(), })(React.Component); })(findNodeHandle, findHostInstance), findNodeHandle: findNodeHandle, + setNativeProps: function() {}, render: function(element, containerTag, callback) { var root = roots.get(containerTag); if (!root) { - root = createFiber(3, null, null, 0); - var root$jscomp$0 = { - current: root, - containerInfo: containerTag, - pendingChildren: null, - pingCache: null, - earliestPendingTime: 0, - latestPendingTime: 0, - earliestSuspendedTime: 0, - latestSuspendedTime: 0, - latestPingedTime: 0, - didError: !1, - pendingCommitExpirationTime: 0, - finishedWork: null, - timeoutHandle: -1, - context: null, - pendingContext: null, - hydrate: !1, - nextExpirationTimeToWorkOn: 0, - expirationTime: 0, - firstBatch: null, - nextScheduledRoot: null - }; - root = root.stateNode = root$jscomp$0; + root = new FiberRootNode(containerTag, !1); + var uninitializedFiber = createFiber(3, null, null, 0); + root.current = uninitializedFiber; + uninitializedFiber.stateNode = root; roots.set(containerTag, root); } updateContainer(element, root, null, callback); @@ -6997,42 +6967,77 @@ var roots = new Map(), NativeMethodsMixin: (function(findNodeHandle, findHostInstance) { return { measure: function(callback) { - UIManager.measure( - findNodeHandle(this), - mountSafeCallback_NOT_REALLY_SAFE(this, callback) - ); + var maybeInstance = void 0; + try { + maybeInstance = findHostInstance(this); + } catch (error) {} + null != maybeInstance && + (maybeInstance.canonical + ? FabricUIManager.measure( + maybeInstance.node, + mountSafeCallback_NOT_REALLY_SAFE(this, callback) + ) + : UIManager.measure( + findNodeHandle(this), + mountSafeCallback_NOT_REALLY_SAFE(this, callback) + )); }, measureInWindow: function(callback) { - UIManager.measureInWindow( - findNodeHandle(this), - mountSafeCallback_NOT_REALLY_SAFE(this, callback) - ); + var maybeInstance = void 0; + try { + maybeInstance = findHostInstance(this); + } catch (error) {} + null != maybeInstance && + (maybeInstance.canonical + ? FabricUIManager.measureInWindow( + maybeInstance.node, + mountSafeCallback_NOT_REALLY_SAFE(this, callback) + ) + : UIManager.measureInWindow( + findNodeHandle(this), + mountSafeCallback_NOT_REALLY_SAFE(this, callback) + )); }, measureLayout: function(relativeToNativeNode, onSuccess, onFail) { - UIManager.measureLayout( - findNodeHandle(this), - relativeToNativeNode, - mountSafeCallback_NOT_REALLY_SAFE(this, onFail), - mountSafeCallback_NOT_REALLY_SAFE(this, onSuccess) - ); + var maybeInstance = void 0; + try { + maybeInstance = findHostInstance(this); + } catch (error) {} + null == maybeInstance || + maybeInstance.canonical || + ((maybeInstance = void 0), + "number" === typeof relativeToNativeNode + ? (maybeInstance = relativeToNativeNode) + : relativeToNativeNode._nativeTag && + (maybeInstance = relativeToNativeNode._nativeTag), + null != maybeInstance && + UIManager.measureLayout( + findNodeHandle(this), + maybeInstance, + mountSafeCallback_NOT_REALLY_SAFE(this, onFail), + mountSafeCallback_NOT_REALLY_SAFE(this, onSuccess) + )); }, setNativeProps: function(nativeProps) { var maybeInstance = void 0; try { maybeInstance = findHostInstance(this); } catch (error) {} - if (null != maybeInstance) { - var viewConfig = maybeInstance.viewConfig; + if (null != maybeInstance && !maybeInstance.canonical) { + var nativeTag = + maybeInstance._nativeTag || maybeInstance.canonical._nativeTag; + maybeInstance = + maybeInstance.viewConfig || maybeInstance.canonical.viewConfig; nativeProps = diffProperties( null, emptyObject, nativeProps, - viewConfig.validAttributes + maybeInstance.validAttributes ); null != nativeProps && UIManager.updateView( - maybeInstance._nativeTag, - viewConfig.uiViewClassName, + nativeTag, + maybeInstance.uiViewClassName, nativeProps ); } @@ -7051,7 +7056,10 @@ var roots = new Map(), var findFiberByHostInstance = devToolsConfig.findFiberByHostInstance; return injectInternals( Object.assign({}, devToolsConfig, { + overrideHookState: null, overrideProps: null, + setSuspenseHandler: null, + scheduleUpdate: null, currentDispatcherRef: ReactSharedInternals.ReactCurrentDispatcher, findHostInstanceByFiber: function(fiber) { fiber = findCurrentHostFiber(fiber); @@ -7068,7 +7076,7 @@ var roots = new Map(), findFiberByHostInstance: getInstanceFromInstance, getInspectorDataForViewTag: getInspectorDataForViewTag, bundleType: 0, - version: "16.8.1", + version: "16.8.6", rendererPackageName: "react-native-renderer" }); var ReactFabric$2 = { default: ReactFabric }, diff --git a/Libraries/Renderer/oss/ReactFabric-profiling.js b/Libraries/Renderer/oss/ReactFabric-profiling.js index 4e42e56b1bb6fc..91e31d61e554eb 100644 --- a/Libraries/Renderer/oss/ReactFabric-profiling.js +++ b/Libraries/Renderer/oss/ReactFabric-profiling.js @@ -19,78 +19,13 @@ var ReactNativeViewConfigRegistry = require("ReactNativeViewConfigRegistry"), flattenStyle = require("flattenStyle"), TextInputState = require("TextInputState"), FabricUIManager = require("FabricUIManager"), + Scheduler = require("scheduler"), tracing = require("scheduler/tracing"), - scheduler = require("scheduler"), ExceptionsManager = require("ExceptionsManager"); -function invariant(condition, format, a, b, c, d, e, f) { - if (!condition) { - condition = void 0; - if (void 0 === format) - condition = Error( - "Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings." - ); - else { - var args = [a, b, c, d, e, f], - argIndex = 0; - condition = Error( - format.replace(/%s/g, function() { - return args[argIndex++]; - }) - ); - condition.name = "Invariant Violation"; - } - condition.framesToPop = 1; - throw condition; - } -} -function invokeGuardedCallbackImpl(name, func, context, a, b, c, d, e, f) { - var funcArgs = Array.prototype.slice.call(arguments, 3); - try { - func.apply(context, funcArgs); - } catch (error) { - this.onError(error); - } -} -var hasError = !1, - caughtError = null, - hasRethrowError = !1, - rethrowError = null, - reporter = { - onError: function(error) { - hasError = !0; - caughtError = error; - } - }; -function invokeGuardedCallback(name, func, context, a, b, c, d, e, f) { - hasError = !1; - caughtError = null; - invokeGuardedCallbackImpl.apply(reporter, arguments); -} -function invokeGuardedCallbackAndCatchFirstError( - name, - func, - context, - a, - b, - c, - d, - e, - f -) { - invokeGuardedCallback.apply(this, arguments); - if (hasError) { - if (hasError) { - var error = caughtError; - hasError = !1; - caughtError = null; - } else - invariant( - !1, - "clearCaughtError was called but no error was captured. This error is likely caused by a bug in React. Please file an issue." - ), - (error = void 0); - hasRethrowError || ((hasRethrowError = !0), (rethrowError = error)); - } +function ReactError(message) { + message = Error(message); + message.name = "Invariant Violation"; + return message; } var eventPluginOrder = null, namesToPlugins = {}; @@ -99,17 +34,19 @@ function recomputePluginOrdering() { for (var pluginName in namesToPlugins) { var pluginModule = namesToPlugins[pluginName], pluginIndex = eventPluginOrder.indexOf(pluginName); - invariant( - -1 < pluginIndex, - "EventPluginRegistry: Cannot inject event plugins that do not exist in the plugin ordering, `%s`.", - pluginName - ); - if (!plugins[pluginIndex]) { - invariant( - pluginModule.extractEvents, - "EventPluginRegistry: Event plugins must implement an `extractEvents` method, but `%s` does not.", - pluginName + if (!(-1 < pluginIndex)) + throw ReactError( + "EventPluginRegistry: Cannot inject event plugins that do not exist in the plugin ordering, `" + + pluginName + + "`." ); + if (!plugins[pluginIndex]) { + if (!pluginModule.extractEvents) + throw ReactError( + "EventPluginRegistry: Event plugins must implement an `extractEvents` method, but `" + + pluginName + + "` does not." + ); plugins[pluginIndex] = pluginModule; pluginIndex = pluginModule.eventTypes; for (var eventName in pluginIndex) { @@ -117,11 +54,12 @@ function recomputePluginOrdering() { var dispatchConfig = pluginIndex[eventName], pluginModule$jscomp$0 = pluginModule, eventName$jscomp$0 = eventName; - invariant( - !eventNameDispatchConfigs.hasOwnProperty(eventName$jscomp$0), - "EventPluginHub: More than one plugin attempted to publish the same event name, `%s`.", - eventName$jscomp$0 - ); + if (eventNameDispatchConfigs.hasOwnProperty(eventName$jscomp$0)) + throw ReactError( + "EventPluginHub: More than one plugin attempted to publish the same event name, `" + + eventName$jscomp$0 + + "`." + ); eventNameDispatchConfigs[eventName$jscomp$0] = dispatchConfig; var phasedRegistrationNames = dispatchConfig.phasedRegistrationNames; if (phasedRegistrationNames) { @@ -144,28 +82,78 @@ function recomputePluginOrdering() { ), (JSCompiler_inline_result = !0)) : (JSCompiler_inline_result = !1); - invariant( - JSCompiler_inline_result, - "EventPluginRegistry: Failed to publish event `%s` for plugin `%s`.", - eventName, - pluginName - ); + if (!JSCompiler_inline_result) + throw ReactError( + "EventPluginRegistry: Failed to publish event `" + + eventName + + "` for plugin `" + + pluginName + + "`." + ); } } } } function publishRegistrationName(registrationName, pluginModule) { - invariant( - !registrationNameModules[registrationName], - "EventPluginHub: More than one plugin attempted to publish the same registration name, `%s`.", - registrationName - ); + if (registrationNameModules[registrationName]) + throw ReactError( + "EventPluginHub: More than one plugin attempted to publish the same registration name, `" + + registrationName + + "`." + ); registrationNameModules[registrationName] = pluginModule; } var plugins = [], eventNameDispatchConfigs = {}, - registrationNameModules = {}, - getFiberCurrentPropsFromNode = null, + registrationNameModules = {}; +function invokeGuardedCallbackImpl(name, func, context, a, b, c, d, e, f) { + var funcArgs = Array.prototype.slice.call(arguments, 3); + try { + func.apply(context, funcArgs); + } catch (error) { + this.onError(error); + } +} +var hasError = !1, + caughtError = null, + hasRethrowError = !1, + rethrowError = null, + reporter = { + onError: function(error) { + hasError = !0; + caughtError = error; + } + }; +function invokeGuardedCallback(name, func, context, a, b, c, d, e, f) { + hasError = !1; + caughtError = null; + invokeGuardedCallbackImpl.apply(reporter, arguments); +} +function invokeGuardedCallbackAndCatchFirstError( + name, + func, + context, + a, + b, + c, + d, + e, + f +) { + invokeGuardedCallback.apply(this, arguments); + if (hasError) { + if (hasError) { + var error = caughtError; + hasError = !1; + caughtError = null; + } else + throw ReactError( + "clearCaughtError was called but no error was captured. This error is likely caused by a bug in React. Please file an issue." + ); + hasRethrowError || ((hasRethrowError = !0), (rethrowError = error)); + } +} +var getFiberCurrentPropsFromNode = null, getInstanceFromNode = null, getNodeFromInstance = null; function executeDispatch(event, listener, inst) { @@ -177,10 +165,8 @@ function executeDispatch(event, listener, inst) { function executeDirectDispatch(event) { var dispatchListener = event._dispatchListeners, dispatchInstance = event._dispatchInstances; - invariant( - !Array.isArray(dispatchListener), - "executeDirectDispatch(...): Invalid `event`." - ); + if (Array.isArray(dispatchListener)) + throw ReactError("executeDirectDispatch(...): Invalid `event`."); event.currentTarget = dispatchListener ? getNodeFromInstance(dispatchInstance) : null; @@ -191,10 +177,10 @@ function executeDirectDispatch(event) { return dispatchListener; } function accumulateInto(current, next) { - invariant( - null != next, - "accumulateInto(...): Accumulated items must not be null or undefined." - ); + if (null == next) + throw ReactError( + "accumulateInto(...): Accumulated items must not be null or undefined." + ); if (null == current) return next; if (Array.isArray(current)) { if (Array.isArray(next)) return current.push.apply(current, next), current; @@ -228,10 +214,10 @@ function executeDispatchesAndReleaseTopLevel(e) { } var injection = { injectEventPluginOrder: function(injectedEventPluginOrder) { - invariant( - !eventPluginOrder, - "EventPluginRegistry: Cannot inject event plugin ordering more than once. You are likely trying to load more than one copy of React." - ); + if (eventPluginOrder) + throw ReactError( + "EventPluginRegistry: Cannot inject event plugin ordering more than once. You are likely trying to load more than one copy of React." + ); eventPluginOrder = Array.prototype.slice.call(injectedEventPluginOrder); recomputePluginOrdering(); }, @@ -241,15 +227,19 @@ var injection = { for (pluginName in injectedNamesToPlugins) if (injectedNamesToPlugins.hasOwnProperty(pluginName)) { var pluginModule = injectedNamesToPlugins[pluginName]; - (namesToPlugins.hasOwnProperty(pluginName) && - namesToPlugins[pluginName] === pluginModule) || - (invariant( - !namesToPlugins[pluginName], - "EventPluginRegistry: Cannot inject two different event plugins using the same name, `%s`.", - pluginName - ), - (namesToPlugins[pluginName] = pluginModule), - (isOrderingDirty = !0)); + if ( + !namesToPlugins.hasOwnProperty(pluginName) || + namesToPlugins[pluginName] !== pluginModule + ) { + if (namesToPlugins[pluginName]) + throw ReactError( + "EventPluginRegistry: Cannot inject two different event plugins using the same name, `" + + pluginName + + "`." + ); + namesToPlugins[pluginName] = pluginModule; + isOrderingDirty = !0; + } } isOrderingDirty && recomputePluginOrdering(); } @@ -285,12 +275,14 @@ function getListener(inst, registrationName) { inst = !1; } if (inst) return null; - invariant( - !listener || "function" === typeof listener, - "Expected `%s` listener to be a function, instead got a value of `%s` type.", - registrationName, - typeof listener - ); + if (listener && "function" !== typeof listener) + throw ReactError( + "Expected `" + + registrationName + + "` listener to be a function, instead got a value of `" + + typeof listener + + "` type." + ); return listener; } function getParent(inst) { @@ -451,10 +443,10 @@ function getPooledEvent(dispatchConfig, targetInst, nativeEvent, nativeInst) { return new this(dispatchConfig, targetInst, nativeEvent, nativeInst); } function releasePooledEvent(event) { - invariant( - event instanceof this, - "Trying to release an event instance into a pool of a different type." - ); + if (!(event instanceof this)) + throw ReactError( + "Trying to release an event instance into a pool of a different type." + ); event.destructor(); 10 > this.eventPool.length && this.eventPool.push(event); } @@ -489,7 +481,7 @@ function timestampForTouch(touch) { } function getTouchIdentifier(_ref) { _ref = _ref.identifier; - invariant(null != _ref, "Touch object is missing identifier."); + if (null == _ref) throw ReactError("Touch object is missing identifier."); return _ref; } function recordTouchStart(touch) { @@ -602,10 +594,10 @@ var ResponderTouchHistoryStore = { touchHistory: touchHistory }; function accumulate(current, next) { - invariant( - null != next, - "accumulate(...): Accumulated items must be not be null or undefined." - ); + if (null == next) + throw ReactError( + "accumulate(...): Accumulated items must be not be null or undefined." + ); return null == current ? next : Array.isArray(current) @@ -970,11 +962,10 @@ var eventTypes$1 = { ReactNativeViewConfigRegistry.customBubblingEventTypes[topLevelType], directDispatchConfig = ReactNativeViewConfigRegistry.customDirectEventTypes[topLevelType]; - invariant( - bubbleDispatchConfig || directDispatchConfig, - 'Unsupported top level event type "%s" dispatched', - topLevelType - ); + if (!bubbleDispatchConfig && !directDispatchConfig) + throw ReactError( + 'Unsupported top level event type "' + topLevelType + '" dispatched' + ); topLevelType = SyntheticEvent.getPooled( bubbleDispatchConfig || directDispatchConfig, targetInst, @@ -1006,7 +997,7 @@ getFiberCurrentPropsFromNode = function(inst) { getInstanceFromNode = getInstanceFromInstance; getNodeFromInstance = function(inst) { inst = inst.stateNode.canonical._nativeTag; - invariant(inst, "All native instances should have a tag."); + if (!inst) throw ReactError("All native instances should have a tag."); return inst; }; ResponderEventPlugin.injection.injectGlobalResponderHandler({ @@ -1038,6 +1029,15 @@ var hasSymbol = "function" === typeof Symbol && Symbol.for, REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for("react.suspense") : 60113, REACT_MEMO_TYPE = hasSymbol ? Symbol.for("react.memo") : 60115, REACT_LAZY_TYPE = hasSymbol ? Symbol.for("react.lazy") : 60116, + REACT_EVENT_COMPONENT_TYPE = hasSymbol + ? Symbol.for("react.event_component") + : 60117, + REACT_EVENT_TARGET_TYPE = hasSymbol + ? Symbol.for("react.event_target") + : 60118, + REACT_EVENT_TARGET_TOUCH_HIT = hasSymbol + ? Symbol.for("react.event_target.touch_hit") + : 60119, MAYBE_ITERATOR_SYMBOL = "function" === typeof Symbol && Symbol.iterator; function getIteratorFn(maybeIterable) { if (null === maybeIterable || "object" !== typeof maybeIterable) return null; @@ -1082,6 +1082,15 @@ function getComponentName(type) { case REACT_LAZY_TYPE: if ((type = 1 === type._status ? type._result : null)) return getComponentName(type); + break; + case REACT_EVENT_COMPONENT_TYPE: + type = type.displayName; + if (void 0 !== type) return type; + break; + case REACT_EVENT_TARGET_TYPE: + if (type.type === REACT_EVENT_TARGET_TOUCH_HIT) return "TouchHitTarget"; + type = type.displayName; + if (void 0 !== type) return type; } return null; } @@ -1096,80 +1105,83 @@ function isFiberMountedImpl(fiber) { return 3 === node.tag ? 2 : 3; } function assertIsMounted(fiber) { - invariant( - 2 === isFiberMountedImpl(fiber), - "Unable to find node on an unmounted component." - ); + if (2 !== isFiberMountedImpl(fiber)) + throw ReactError("Unable to find node on an unmounted component."); } function findCurrentFiberUsingSlowPath(fiber) { var alternate = fiber.alternate; - if (!alternate) - return ( - (alternate = isFiberMountedImpl(fiber)), - invariant( - 3 !== alternate, - "Unable to find node on an unmounted component." - ), - 1 === alternate ? null : fiber - ); + if (!alternate) { + alternate = isFiberMountedImpl(fiber); + if (3 === alternate) + throw ReactError("Unable to find node on an unmounted component."); + return 1 === alternate ? null : fiber; + } for (var a = fiber, b = alternate; ; ) { - var parentA = a.return, - parentB = parentA ? parentA.alternate : null; - if (!parentA || !parentB) break; + var parentA = a.return; + if (null === parentA) break; + var parentB = parentA.alternate; + if (null === parentB) { + b = parentA.return; + if (null !== b) { + a = b; + continue; + } + break; + } if (parentA.child === parentB.child) { - for (var child = parentA.child; child; ) { - if (child === a) return assertIsMounted(parentA), fiber; - if (child === b) return assertIsMounted(parentA), alternate; - child = child.sibling; + for (parentB = parentA.child; parentB; ) { + if (parentB === a) return assertIsMounted(parentA), fiber; + if (parentB === b) return assertIsMounted(parentA), alternate; + parentB = parentB.sibling; } - invariant(!1, "Unable to find node on an unmounted component."); + throw ReactError("Unable to find node on an unmounted component."); } if (a.return !== b.return) (a = parentA), (b = parentB); else { - child = !1; - for (var _child = parentA.child; _child; ) { + for (var didFindChild = !1, _child = parentA.child; _child; ) { if (_child === a) { - child = !0; + didFindChild = !0; a = parentA; b = parentB; break; } if (_child === b) { - child = !0; + didFindChild = !0; b = parentA; a = parentB; break; } _child = _child.sibling; } - if (!child) { + if (!didFindChild) { for (_child = parentB.child; _child; ) { if (_child === a) { - child = !0; + didFindChild = !0; a = parentB; b = parentA; break; } if (_child === b) { - child = !0; + didFindChild = !0; b = parentB; a = parentA; break; } _child = _child.sibling; } - invariant( - child, - "Child was not found in either parent set. This indicates a bug in React related to the return pointer. Please file an issue." - ); + if (!didFindChild) + throw ReactError( + "Child was not found in either parent set. This indicates a bug in React related to the return pointer. Please file an issue." + ); } } - invariant( - a.alternate === b, - "Return fibers should always be each others' alternates. This error is likely caused by a bug in React. Please file an issue." - ); + if (a.alternate !== b) + throw ReactError( + "Return fibers should always be each others' alternates. This error is likely caused by a bug in React. Please file an issue." + ); } - invariant(3 === a.tag, "Unable to find node on an unmounted component."); + if (3 !== a.tag) + throw ReactError("Unable to find node on an unmounted component."); return a.stateNode.current === a ? fiber : alternate; } function findCurrentHostFiber(parent) { @@ -1417,37 +1429,13 @@ function diffProperties(updatePayload, prevProps, nextProps, validAttributes) { ))))); return updatePayload; } -var now$1 = - "object" === typeof performance && "function" === typeof performance.now - ? function() { - return performance.now(); - } - : function() { - return Date.now(); - }, - scheduledCallback = null, - frameDeadline = 0; -function setTimeoutCallback() { - frameDeadline = now$1() + 5; - var callback = scheduledCallback; - scheduledCallback = null; - null !== callback && callback(); -} -function scheduleDeferredCallback$1(callback) { - scheduledCallback = callback; - return setTimeout(setTimeoutCallback, 1); -} var restoreTarget = null, restoreQueue = null; function restoreStateOfTarget(target) { - if ((target = getInstanceFromNode(target))) { - invariant( - !1, + if (getInstanceFromNode(target)) + throw ReactError( "setRestoreImplementation() needs to be called to handle a target for controlled events. This error is likely caused by a bug in React. Please file an issue." ); - var props = getFiberCurrentPropsFromNode(target.stateNode); - null(target.stateNode, target.type, props); - } } function _batchedUpdatesImpl(fn, bookkeeping) { return fn(bookkeeping); @@ -1492,24 +1480,22 @@ function dispatchEvent(target, topLevelType, nativeEvent) { null !== events && (eventQueue = accumulateInto(eventQueue, events)); events = eventQueue; eventQueue = null; - if ( - events && - (forEachAccumulated(events, executeDispatchesAndReleaseTopLevel), - invariant( - !eventQueue, - "processEventQueue(): Additional events were enqueued while processing an event queue. Support for this has not yet been implemented." - ), - hasRethrowError) - ) - throw ((events = rethrowError), - (hasRethrowError = !1), - (rethrowError = null), - events); + if (events) { + forEachAccumulated(events, executeDispatchesAndReleaseTopLevel); + if (eventQueue) + throw ReactError( + "processEventQueue(): Additional events were enqueued while processing an event queue. Support for this has not yet been implemented." + ); + if (hasRethrowError) + throw ((events = rethrowError), + (hasRethrowError = !1), + (rethrowError = null), + events); + } }); } function shim$1() { - invariant( - !1, + throw ReactError( "The current renderer does not support hydration. This error is likely caused by a bug in React. Please file an issue." ); } @@ -1517,12 +1503,18 @@ var nextReactTag = 2; FabricUIManager.registerEventHandler && FabricUIManager.registerEventHandler(dispatchEvent); var ReactFabricHostComponent = (function() { - function ReactFabricHostComponent(tag, viewConfig, props) { + function ReactFabricHostComponent( + tag, + viewConfig, + props, + internalInstanceHandle + ) { if (!(this instanceof ReactFabricHostComponent)) throw new TypeError("Cannot call a class as a function"); this._nativeTag = tag; this.viewConfig = viewConfig; this.currentProps = props; + this._internalInstanceHandle = internalInstanceHandle; } ReactFabricHostComponent.prototype.blur = function() { TextInputState.blurTextInput(this._nativeTag); @@ -1531,14 +1523,14 @@ var ReactFabricHostComponent = (function() { TextInputState.focusTextInput(this._nativeTag); }; ReactFabricHostComponent.prototype.measure = function(callback) { - UIManager.measure( - this._nativeTag, + FabricUIManager.measure( + this._internalInstanceHandle.stateNode.node, mountSafeCallback_NOT_REALLY_SAFE(this, callback) ); }; ReactFabricHostComponent.prototype.measureInWindow = function(callback) { - UIManager.measureInWindow( - this._nativeTag, + FabricUIManager.measureInWindow( + this._internalInstanceHandle.stateNode.node, mountSafeCallback_NOT_REALLY_SAFE(this, callback) ); }; @@ -1547,27 +1539,16 @@ var ReactFabricHostComponent = (function() { onSuccess, onFail ) { - UIManager.measureLayout( - this._nativeTag, - relativeToNativeNode, - mountSafeCallback_NOT_REALLY_SAFE(this, onFail), - mountSafeCallback_NOT_REALLY_SAFE(this, onSuccess) - ); - }; - ReactFabricHostComponent.prototype.setNativeProps = function(nativeProps) { - nativeProps = diffProperties( - null, - emptyObject, - nativeProps, - this.viewConfig.validAttributes - ); - null != nativeProps && - UIManager.updateView( - this._nativeTag, - this.viewConfig.uiViewClassName, - nativeProps + "number" !== typeof relativeToNativeNode && + relativeToNativeNode instanceof ReactFabricHostComponent && + FabricUIManager.measureLayout( + this._internalInstanceHandle.stateNode.node, + relativeToNativeNode._internalInstanceHandle.stateNode.node, + mountSafeCallback_NOT_REALLY_SAFE(this, onFail), + mountSafeCallback_NOT_REALLY_SAFE(this, onSuccess) ); }; + ReactFabricHostComponent.prototype.setNativeProps = function() {}; return ReactFabricHostComponent; })(); function createTextInstance( @@ -1576,10 +1557,10 @@ function createTextInstance( hostContext, internalInstanceHandle ) { - invariant( - hostContext.isInAParentText, - "Text strings must be rendered within a component." - ); + if (!hostContext.isInAParentText) + throw ReactError( + "Text strings must be rendered within a component." + ); hostContext = nextReactTag; nextReactTag += 2; return { @@ -1607,18 +1588,6 @@ function cloneHiddenInstance(instance) { canonical: instance.canonical }; } -function cloneUnhiddenInstance(instance, type, props) { - var viewConfig = instance.canonical.viewConfig; - type = instance.node; - var prevProps = Object.assign({}, props, { - style: [props.style, { display: "none" }] - }); - props = diffProperties(null, prevProps, props, viewConfig.validAttributes); - return { - node: FabricUIManager.cloneNodeWithNewProps(type, props), - canonical: instance.canonical - }; -} var BEFORE_SLASH_RE = /^(.*)[\\\/]/; function getStackByFiberInDevAndProd(workInProgress) { var info = ""; @@ -1703,10 +1672,10 @@ function popTopLevelContextObject(fiber) { pop(contextStackCursor, fiber); } function pushTopLevelContextObject(fiber, context, didChange) { - invariant( - contextStackCursor.current === emptyContextObject, - "Unexpected context found on stack. This error is likely caused by a bug in React. Please file an issue." - ); + if (contextStackCursor.current !== emptyContextObject) + throw ReactError( + "Unexpected context found on stack. This error is likely caused by a bug in React. Please file an issue." + ); push(contextStackCursor, context, fiber); push(didPerformWorkStackCursor, didChange, fiber); } @@ -1716,12 +1685,13 @@ function processChildContext(fiber, type, parentContext) { if ("function" !== typeof instance.getChildContext) return parentContext; instance = instance.getChildContext(); for (var contextKey in instance) - invariant( - contextKey in fiber, - '%s.getChildContext(): key "%s" is not defined in childContextTypes.', - getComponentName(type) || "Unknown", - contextKey - ); + if (!(contextKey in fiber)) + throw ReactError( + (getComponentName(type) || "Unknown") + + '.getChildContext(): key "' + + contextKey + + '" is not defined in childContextTypes.' + ); return Object.assign({}, parentContext, instance); } function pushContextProvider(workInProgress) { @@ -1740,10 +1710,10 @@ function pushContextProvider(workInProgress) { } function invalidateContextProvider(workInProgress, type, didChange) { var instance = workInProgress.stateNode; - invariant( - instance, - "Expected to have an instance by this point. This error is likely caused by a bug in React. Please file an issue." - ); + if (!instance) + throw ReactError( + "Expected to have an instance by this point. This error is likely caused by a bug in React. Please file an issue." + ); didChange ? ((type = processChildContext(workInProgress, type, previousContext)), (instance.__reactInternalMemoizedMergedChildContext = type), @@ -1778,6 +1748,7 @@ function injectInternals(internals) { } catch (err) {} return !0; } +var Scheduler_now = Scheduler.unstable_now; function FiberNode(tag, pendingProps, key, mode) { this.tag = tag; this.key = key; @@ -1908,11 +1879,10 @@ function createFiberFromTypeAndProps( owner = null; break a; } - invariant( - !1, - "Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s", - null == type ? type : typeof type, - "" + throw ReactError( + "Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: " + + (null == type ? type : typeof type) + + "." ); } key = createFiber(fiberTag, pendingProps, key, mode); @@ -1954,6 +1924,24 @@ function createFiberFromPortal(portal, mode, expirationTime) { }; return mode; } +function FiberRootNode(containerInfo, hydrate) { + this.current = null; + this.containerInfo = containerInfo; + this.pingCache = this.pendingChildren = null; + this.pendingCommitExpirationTime = 0; + this.finishedWork = null; + this.timeoutHandle = -1; + this.pendingContext = this.context = null; + this.hydrate = hydrate; + this.firstBatch = null; + this.latestPingedTime = this.latestSuspendedTime = this.earliestSuspendedTime = this.latestPendingTime = this.earliestPendingTime = 0; + this.didError = !1; + this.expirationTime = this.nextExpirationTimeToWorkOn = 0; + this.nextScheduledRoot = null; + this.interactionThreadID = tracing.unstable_getThreadID(); + this.memoizedInteractions = new Set(); + this.pendingInteractionMap = new Map(); +} function markPendingPriorityLevel(root, expirationTime) { root.didError = !1; var earliestPendingTime = root.earliestPendingTime; @@ -2028,14 +2016,6 @@ function markSuspendedPriorityLevel(root, suspendedTime) { (root.latestSuspendedTime = suspendedTime); findNextExpirationTimeToWorkOn(suspendedTime, root); } -function findEarliestOutstandingPriorityLevel(root, renderExpirationTime) { - var earliestPendingTime = root.earliestPendingTime; - root = root.earliestSuspendedTime; - earliestPendingTime > renderExpirationTime && - (renderExpirationTime = earliestPendingTime); - root > renderExpirationTime && (renderExpirationTime = root); - return renderExpirationTime; -} function findNextExpirationTimeToWorkOn(completedExpirationTime, root) { var earliestSuspendedTime = root.earliestSuspendedTime, latestSuspendedTime = root.latestSuspendedTime, @@ -2150,37 +2130,37 @@ var classComponentUpdater = { }, enqueueSetState: function(inst, payload, callback) { inst = inst._reactInternalFiber; - var currentTime = requestCurrentTime(); - currentTime = computeExpirationForFiber(currentTime, inst); + var currentTime = requestCurrentTime$$1(); + currentTime = computeExpirationForFiber$$1(currentTime, inst); var update = createUpdate(currentTime); update.payload = payload; void 0 !== callback && null !== callback && (update.callback = callback); - flushPassiveEffects(); + flushPassiveEffects$$1(); enqueueUpdate(inst, update); - scheduleWork(inst, currentTime); + scheduleWork$$1(inst, currentTime); }, enqueueReplaceState: function(inst, payload, callback) { inst = inst._reactInternalFiber; - var currentTime = requestCurrentTime(); - currentTime = computeExpirationForFiber(currentTime, inst); + var currentTime = requestCurrentTime$$1(); + currentTime = computeExpirationForFiber$$1(currentTime, inst); var update = createUpdate(currentTime); update.tag = ReplaceState; update.payload = payload; void 0 !== callback && null !== callback && (update.callback = callback); - flushPassiveEffects(); + flushPassiveEffects$$1(); enqueueUpdate(inst, update); - scheduleWork(inst, currentTime); + scheduleWork$$1(inst, currentTime); }, enqueueForceUpdate: function(inst, callback) { inst = inst._reactInternalFiber; - var currentTime = requestCurrentTime(); - currentTime = computeExpirationForFiber(currentTime, inst); + var currentTime = requestCurrentTime$$1(); + currentTime = computeExpirationForFiber$$1(currentTime, inst); var update = createUpdate(currentTime); update.tag = ForceUpdate; void 0 !== callback && null !== callback && (update.callback = callback); - flushPassiveEffects(); + flushPassiveEffects$$1(); enqueueUpdate(inst, update); - scheduleWork(inst, currentTime); + scheduleWork$$1(inst, currentTime); } }; function checkShouldComponentUpdate( @@ -2305,17 +2285,19 @@ function coerceRef(returnFiber, current$$1, element) { if (element._owner) { element = element._owner; var inst = void 0; - element && - (invariant( - 1 === element.tag, - "Function components cannot have refs. Did you mean to use React.forwardRef()?" - ), - (inst = element.stateNode)); - invariant( - inst, - "Missing owner for string ref %s. This error is likely caused by a bug in React. Please file an issue.", - returnFiber - ); + if (element) { + if (1 !== element.tag) + throw ReactError( + "Function components cannot have refs. Did you mean to use React.forwardRef()?" + ); + inst = element.stateNode; + } + if (!inst) + throw ReactError( + "Missing owner for string ref " + + returnFiber + + ". This error is likely caused by a bug in React. Please file an issue." + ); var stringRef = "" + returnFiber; if ( null !== current$$1 && @@ -2332,27 +2314,27 @@ function coerceRef(returnFiber, current$$1, element) { current$$1._stringRef = stringRef; return current$$1; } - invariant( - "string" === typeof returnFiber, - "Expected ref to be a function, a string, an object returned by React.createRef(), or null." - ); - invariant( - element._owner, - "Element ref was specified as a string (%s) but no owner was set. This could happen for one of the following reasons:\n1. You may be adding a ref to a function component\n2. You may be adding a ref to a component that was not created inside a component's render method\n3. You have multiple copies of React loaded\nSee https://fb.me/react-refs-must-have-owner for more information.", - returnFiber - ); + if ("string" !== typeof returnFiber) + throw ReactError( + "Expected ref to be a function, a string, an object returned by React.createRef(), or null." + ); + if (!element._owner) + throw ReactError( + "Element ref was specified as a string (" + + returnFiber + + ") but no owner was set. This could happen for one of the following reasons:\n1. You may be adding a ref to a function component\n2. You may be adding a ref to a component that was not created inside a component's render method\n3. You have multiple copies of React loaded\nSee https://fb.me/react-refs-must-have-owner for more information." + ); } return returnFiber; } function throwOnInvalidObjectType(returnFiber, newChild) { - "textarea" !== returnFiber.type && - invariant( - !1, - "Objects are not valid as a React child (found: %s).%s", - "[object Object]" === Object.prototype.toString.call(newChild) - ? "object with keys {" + Object.keys(newChild).join(", ") + "}" - : newChild, - "" + if ("textarea" !== returnFiber.type) + throw ReactError( + "Objects are not valid as a React child (found: " + + ("[object Object]" === Object.prototype.toString.call(newChild) + ? "object with keys {" + Object.keys(newChild).join(", ") + "}" + : newChild) + + ")." ); } function ChildReconciler(shouldTrackSideEffects) { @@ -2751,15 +2733,13 @@ function ChildReconciler(shouldTrackSideEffects) { expirationTime ) { var iteratorFn = getIteratorFn(newChildrenIterable); - invariant( - "function" === typeof iteratorFn, - "An object is not an iterable. This error is likely caused by a bug in React. Please file an issue." - ); + if ("function" !== typeof iteratorFn) + throw ReactError( + "An object is not an iterable. This error is likely caused by a bug in React. Please file an issue." + ); newChildrenIterable = iteratorFn.call(newChildrenIterable); - invariant( - null != newChildrenIterable, - "An iterable object provided no iterator." - ); + if (null == newChildrenIterable) + throw ReactError("An iterable object provided no iterator."); for ( var previousNewFiber = (iteratorFn = null), oldFiber = currentFirstChild, @@ -2851,7 +2831,7 @@ function ChildReconciler(shouldTrackSideEffects) { null !== isUnkeyedTopLevelFragment; ) { - if (isUnkeyedTopLevelFragment.key === isObject) + if (isUnkeyedTopLevelFragment.key === isObject) { if ( 7 === isUnkeyedTopLevelFragment.tag ? newChild.type === REACT_FRAGMENT_TYPE @@ -2876,14 +2856,10 @@ function ChildReconciler(shouldTrackSideEffects) { currentFirstChild.return = returnFiber; returnFiber = currentFirstChild; break a; - } else { - deleteRemainingChildren( - returnFiber, - isUnkeyedTopLevelFragment - ); - break; } - else deleteChild(returnFiber, isUnkeyedTopLevelFragment); + deleteRemainingChildren(returnFiber, isUnkeyedTopLevelFragment); + break; + } else deleteChild(returnFiber, isUnkeyedTopLevelFragment); isUnkeyedTopLevelFragment = isUnkeyedTopLevelFragment.sibling; } newChild.type === REACT_FRAGMENT_TYPE @@ -2919,7 +2895,7 @@ function ChildReconciler(shouldTrackSideEffects) { null !== currentFirstChild; ) { - if (currentFirstChild.key === isUnkeyedTopLevelFragment) + if (currentFirstChild.key === isUnkeyedTopLevelFragment) { if ( 4 === currentFirstChild.tag && currentFirstChild.stateNode.containerInfo === @@ -2939,11 +2915,10 @@ function ChildReconciler(shouldTrackSideEffects) { currentFirstChild.return = returnFiber; returnFiber = currentFirstChild; break a; - } else { - deleteRemainingChildren(returnFiber, currentFirstChild); - break; } - else deleteChild(returnFiber, currentFirstChild); + deleteRemainingChildren(returnFiber, currentFirstChild); + break; + } else deleteChild(returnFiber, currentFirstChild); currentFirstChild = currentFirstChild.sibling; } currentFirstChild = createFiberFromPortal( @@ -2997,12 +2972,11 @@ function ChildReconciler(shouldTrackSideEffects) { switch (returnFiber.tag) { case 1: case 0: - (expirationTime = returnFiber.type), - invariant( - !1, - "%s(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null.", - expirationTime.displayName || expirationTime.name || "Component" - ); + throw ((returnFiber = returnFiber.type), + ReactError( + (returnFiber.displayName || returnFiber.name || "Component") + + "(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null." + )); } return deleteRemainingChildren(returnFiber, currentFirstChild); }; @@ -3014,10 +2988,10 @@ var reconcileChildFibers = ChildReconciler(!0), contextFiberStackCursor = { current: NO_CONTEXT }, rootInstanceStackCursor = { current: NO_CONTEXT }; function requiredContext(c) { - invariant( - c !== NO_CONTEXT, - "Expected host context to exist. This error is likely caused by a bug in React. Please file an issue." - ); + if (c === NO_CONTEXT) + throw ReactError( + "Expected host context to exist. This error is likely caused by a bug in React. Please file an issue." + ); return c; } function pushHostContainer(fiber, nextRootInstance) { @@ -3054,15 +3028,7 @@ function popHostContext(fiber) { contextFiberStackCursor.current === fiber && (pop(contextStackCursor$1, fiber), pop(contextFiberStackCursor, fiber)); } -var NoEffect$1 = 0, - UnmountSnapshot = 2, - UnmountMutation = 4, - MountMutation = 8, - UnmountLayout = 16, - MountLayout = 32, - MountPassive = 64, - UnmountPassive = 128, - ReactCurrentDispatcher$1 = ReactSharedInternals.ReactCurrentDispatcher, +var ReactCurrentDispatcher$1 = ReactSharedInternals.ReactCurrentDispatcher, renderExpirationTime = 0, currentlyRenderingFiber$1 = null, currentHook = null, @@ -3077,9 +3043,8 @@ var NoEffect$1 = 0, renderPhaseUpdates = null, numberOfReRenders = 0; function throwInvalidHookError() { - invariant( - !1, - "Hooks can only be called inside the body of a function component. (https://fb.me/react-invalid-hook-call)" + throw ReactError( + "Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:\n1. You might have mismatching versions of React and the renderer (such as React DOM)\n2. You might be breaking the Rules of Hooks\n3. You might have more than one copy of React in the same app\nSee https://fb.me/react-invalid-hook-call for tips about how to debug and fix this problem." ); } function areHookInputsEqual(nextDeps, prevDeps) { @@ -3127,10 +3092,10 @@ function renderWithHooks( remainingExpirationTime = 0; componentUpdateQueue = null; sideEffectTag = 0; - invariant( - !current, - "Rendered fewer hooks than expected. This may be caused by an accidental early return statement." - ); + if (current) + throw ReactError( + "Rendered fewer hooks than expected. This may be caused by an accidental early return statement." + ); return workInProgress; } function resetHooks() { @@ -3164,10 +3129,8 @@ function updateWorkInProgressHook() { (currentHook = nextCurrentHook), (nextCurrentHook = null !== currentHook ? currentHook.next : null); else { - invariant( - null !== nextCurrentHook, - "Rendered more hooks than during the previous render." - ); + if (null === nextCurrentHook) + throw ReactError("Rendered more hooks than during the previous render."); currentHook = nextCurrentHook; var newHook = { memoizedState: currentHook.memoizedState, @@ -3190,10 +3153,11 @@ function basicStateReducer(state, action) { function updateReducer(reducer) { var hook = updateWorkInProgressHook(), queue = hook.queue; - invariant( - null !== queue, - "Should have a queue. This is likely a bug in React. Please file an issue." - ); + if (null === queue) + throw ReactError( + "Should have a queue. This is likely a bug in React. Please file an issue." + ); + queue.lastRenderedReducer = reducer; if (0 < numberOfReRenders) { var _dispatch = queue.dispatch; if (null !== renderPhaseUpdates) { @@ -3208,6 +3172,7 @@ function updateReducer(reducer) { is(newState, hook.memoizedState) || (didReceiveUpdate = !0); hook.memoizedState = newState; hook.baseUpdate === queue.last && (hook.baseState = newState); + queue.lastRenderedState = newState; return [newState, _dispatch]; } } @@ -3233,10 +3198,12 @@ function updateReducer(reducer) { (firstRenderPhaseUpdate = newState)), updateExpirationTime > remainingExpirationTime && (remainingExpirationTime = updateExpirationTime)) - : (newState = + : (updateExpirationTime < mostRecentEventTime && + (mostRecentEventTime = updateExpirationTime), + (newState = _update.eagerReducer === reducer ? _update.eagerState - : reducer(newState, _update.action)); + : reducer(newState, _update.action))); baseUpdate = _update; _update = _update.next; } while (null !== _update && _update !== _dispatch); @@ -3246,8 +3213,7 @@ function updateReducer(reducer) { hook.memoizedState = newState; hook.baseUpdate = newBaseUpdate; hook.baseState = firstRenderPhaseUpdate; - queue.eagerReducer = reducer; - queue.eagerState = newState; + queue.lastRenderedState = newState; } return [hook.memoizedState, queue.dispatch]; } @@ -3283,7 +3249,7 @@ function updateEffectImpl(fiberEffectTag, hookEffectTag, create, deps) { var prevEffect = currentHook.memoizedState; destroy = prevEffect.destroy; if (null !== deps && areHookInputsEqual(deps, prevEffect.deps)) { - pushEffect(NoEffect$1, create, destroy, deps); + pushEffect(0, create, destroy, deps); return; } } @@ -3310,10 +3276,10 @@ function imperativeHandleEffect(create, ref) { } function mountDebugValue() {} function dispatchAction(fiber, queue, action) { - invariant( - 25 > numberOfReRenders, - "Too many re-renders. React limits the number of renders to prevent an infinite loop." - ); + if (!(25 > numberOfReRenders)) + throw ReactError( + "Too many re-renders. React limits the number of renders to prevent an infinite loop." + ); var alternate = fiber.alternate; if ( fiber === currentlyRenderingFiber$1 || @@ -3338,9 +3304,9 @@ function dispatchAction(fiber, queue, action) { queue.next = fiber; } else { - flushPassiveEffects(); - var currentTime = requestCurrentTime(); - currentTime = computeExpirationForFiber(currentTime, fiber); + flushPassiveEffects$$1(); + var currentTime = requestCurrentTime$$1(); + currentTime = computeExpirationForFiber$$1(currentTime, fiber); var _update2 = { expirationTime: currentTime, action: action, @@ -3359,10 +3325,10 @@ function dispatchAction(fiber, queue, action) { if ( 0 === fiber.expirationTime && (null === alternate || 0 === alternate.expirationTime) && - ((alternate = queue.eagerReducer), null !== alternate) + ((alternate = queue.lastRenderedReducer), null !== alternate) ) try { - var currentState = queue.eagerState, + var currentState = queue.lastRenderedState, _eagerState = alternate(currentState, action); _update2.eagerReducer = alternate; _update2.eagerState = _eagerState; @@ -3370,7 +3336,7 @@ function dispatchAction(fiber, queue, action) { } catch (error) { } finally { } - scheduleWork(fiber, currentTime); + scheduleWork$$1(fiber, currentTime); } } var ContextOnlyDispatcher = { @@ -3397,19 +3363,19 @@ var ContextOnlyDispatcher = { }, useContext: readContext, useEffect: function(create, deps) { - return mountEffectImpl(516, UnmountPassive | MountPassive, create, deps); + return mountEffectImpl(516, 192, create, deps); }, useImperativeHandle: function(ref, create, deps) { deps = null !== deps && void 0 !== deps ? deps.concat([ref]) : null; return mountEffectImpl( 4, - UnmountMutation | MountLayout, + 36, imperativeHandleEffect.bind(null, create, ref), deps ); }, useLayoutEffect: function(create, deps) { - return mountEffectImpl(4, UnmountMutation | MountLayout, create, deps); + return mountEffectImpl(4, 36, create, deps); }, useMemo: function(nextCreate, deps) { var hook = mountWorkInProgressHook(); @@ -3425,8 +3391,8 @@ var ContextOnlyDispatcher = { reducer = hook.queue = { last: null, dispatch: null, - eagerReducer: reducer, - eagerState: initialArg + lastRenderedReducer: reducer, + lastRenderedState: initialArg }; reducer = reducer.dispatch = dispatchAction.bind( null, @@ -3447,8 +3413,8 @@ var ContextOnlyDispatcher = { initialState = hook.queue = { last: null, dispatch: null, - eagerReducer: basicStateReducer, - eagerState: initialState + lastRenderedReducer: basicStateReducer, + lastRenderedState: initialState }; initialState = initialState.dispatch = dispatchAction.bind( null, @@ -3476,19 +3442,19 @@ var ContextOnlyDispatcher = { }, useContext: readContext, useEffect: function(create, deps) { - return updateEffectImpl(516, UnmountPassive | MountPassive, create, deps); + return updateEffectImpl(516, 192, create, deps); }, useImperativeHandle: function(ref, create, deps) { deps = null !== deps && void 0 !== deps ? deps.concat([ref]) : null; return updateEffectImpl( 4, - UnmountMutation | MountLayout, + 36, imperativeHandleEffect.bind(null, create, ref), deps ); }, useLayoutEffect: function(create, deps) { - return updateEffectImpl(4, UnmountMutation | MountLayout, create, deps); + return updateEffectImpl(4, 36, create, deps); }, useMemo: function(nextCreate, deps) { var hook = updateWorkInProgressHook(); @@ -3513,11 +3479,12 @@ var ContextOnlyDispatcher = { }, useDebugValue: mountDebugValue }, + now$2 = Scheduler.unstable_now, commitTime = 0, profilerStartTime = -1; function stopProfilerTimerIfRunningAndRecordDelta(fiber, overrideBaseTime) { if (0 <= profilerStartTime) { - var elapsedTime = now$1() - profilerStartTime; + var elapsedTime = now$2() - profilerStartTime; fiber.actualDuration += elapsedTime; overrideBaseTime && (fiber.selfBaseDuration = elapsedTime); profilerStartTime = -1; @@ -3538,6 +3505,8 @@ function tryHydrate(fiber, nextInstance) { (nextInstance = shim$1(nextInstance, fiber.pendingProps)), null !== nextInstance ? ((fiber.stateNode = nextInstance), !0) : !1 ); + case 13: + return !1; default: return !1; } @@ -4076,7 +4045,10 @@ function updateSuspenseComponent( nextState = null; var nextDidTimeout = !1; } else - (nextState = { timedOutAt: null !== nextState ? nextState.timedOutAt : 0 }), + (nextState = { + fallbackExpirationTime: + null !== nextState ? nextState.fallbackExpirationTime : 0 + }), (nextDidTimeout = !0), (workInProgress.effectTag &= -65); if (null === current$$1) @@ -4206,10 +4178,8 @@ function bailoutOnAlreadyFinishedWork( (workInProgress.contextDependencies = current$$1.contextDependencies); profilerStartTime = -1; if (workInProgress.childExpirationTime < renderExpirationTime) return null; - invariant( - null === current$$1 || workInProgress.child === current$$1.child, - "Resuming work not yet implemented." - ); + if (null !== current$$1 && workInProgress.child !== current$$1.child) + throw ReactError("Resuming work not yet implemented."); if (null !== workInProgress.child) { current$$1 = workInProgress.child; renderExpirationTime = createWorkInProgress( @@ -4377,59 +4347,57 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { ((current$$1.alternate = null), (workInProgress.alternate = null), (workInProgress.effectTag |= 2)); - hasContext = workInProgress.pendingProps; - current$$1 = readLazyComponentType(context); - workInProgress.type = current$$1; - context = workInProgress.tag = resolveLazyComponentTag(current$$1); - hasContext = resolveDefaultProps(current$$1, hasContext); - getDerivedStateFromProps = void 0; - switch (context) { + current$$1 = workInProgress.pendingProps; + context = readLazyComponentType(context); + workInProgress.type = context; + hasContext = workInProgress.tag = resolveLazyComponentTag(context); + current$$1 = resolveDefaultProps(context, current$$1); + switch (hasContext) { case 0: - getDerivedStateFromProps = updateFunctionComponent( + workInProgress = updateFunctionComponent( null, workInProgress, + context, current$$1, - hasContext, renderExpirationTime ); break; case 1: - getDerivedStateFromProps = updateClassComponent( + workInProgress = updateClassComponent( null, workInProgress, + context, current$$1, - hasContext, renderExpirationTime ); break; case 11: - getDerivedStateFromProps = updateForwardRef( + workInProgress = updateForwardRef( null, workInProgress, + context, current$$1, - hasContext, renderExpirationTime ); break; case 14: - getDerivedStateFromProps = updateMemoComponent( + workInProgress = updateMemoComponent( null, workInProgress, - current$$1, - resolveDefaultProps(current$$1.type, hasContext), + context, + resolveDefaultProps(context.type, current$$1), updateExpirationTime, renderExpirationTime ); break; default: - invariant( - !1, - "Element type is invalid. Received a promise that resolves to: %s. Lazy element type must resolve to a class or function.%s", - current$$1, - "" + throw ReactError( + "Element type is invalid. Received a promise that resolves to: " + + context + + ". Lazy element type must resolve to a class or function." ); } - return getDerivedStateFromProps; + return workInProgress; case 0: return ( (updateExpirationTime = workInProgress.type), @@ -4463,38 +4431,36 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { ) ); case 3: - return ( - pushHostRootContext(workInProgress), - (updateExpirationTime = workInProgress.updateQueue), - invariant( - null !== updateExpirationTime, + pushHostRootContext(workInProgress); + updateExpirationTime = workInProgress.updateQueue; + if (null === updateExpirationTime) + throw ReactError( "If the root does not have an updateQueue, we should have already bailed out. This error is likely caused by a bug in React. Please file an issue." - ), - (context = workInProgress.memoizedState), - (context = null !== context ? context.element : null), - processUpdateQueue( - workInProgress, - updateExpirationTime, - workInProgress.pendingProps, - null, - renderExpirationTime - ), - (updateExpirationTime = workInProgress.memoizedState.element), - updateExpirationTime === context - ? (workInProgress = bailoutOnAlreadyFinishedWork( - current$$1, - workInProgress, - renderExpirationTime - )) - : (reconcileChildren( - current$$1, - workInProgress, - updateExpirationTime, - renderExpirationTime - ), - (workInProgress = workInProgress.child)), - workInProgress + ); + context = workInProgress.memoizedState; + context = null !== context ? context.element : null; + processUpdateQueue( + workInProgress, + updateExpirationTime, + workInProgress.pendingProps, + null, + renderExpirationTime ); + updateExpirationTime = workInProgress.memoizedState.element; + updateExpirationTime === context + ? (workInProgress = bailoutOnAlreadyFinishedWork( + current$$1, + workInProgress, + renderExpirationTime + )) + : (reconcileChildren( + current$$1, + workInProgress, + updateExpirationTime, + renderExpirationTime + ), + (workInProgress = workInProgress.child)); + return workInProgress; case 5: return ( pushHostContext(workInProgress), @@ -4507,8 +4473,7 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { updateExpirationTime, renderExpirationTime ), - (workInProgress = workInProgress.child), - workInProgress + workInProgress.child ); case 6: return ( @@ -4644,19 +4609,19 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { null !== dependency && dependency.expirationTime < renderExpirationTime && (dependency.expirationTime = renderExpirationTime); + dependency = renderExpirationTime; for (var node = oldValue.return; null !== node; ) { - dependency = node.alternate; - if (node.childExpirationTime < renderExpirationTime) - (node.childExpirationTime = renderExpirationTime), - null !== dependency && - dependency.childExpirationTime < - renderExpirationTime && - (dependency.childExpirationTime = renderExpirationTime); + var alternate = node.alternate; + if (node.childExpirationTime < dependency) + (node.childExpirationTime = dependency), + null !== alternate && + alternate.childExpirationTime < dependency && + (alternate.childExpirationTime = dependency); else if ( - null !== dependency && - dependency.childExpirationTime < renderExpirationTime + null !== alternate && + alternate.childExpirationTime < dependency ) - dependency.childExpirationTime = renderExpirationTime; + alternate.childExpirationTime = dependency; else break; node = node.return; } @@ -4786,12 +4751,10 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { renderExpirationTime ) ); - default: - invariant( - !1, - "Unknown unit of work tag. This error is likely caused by a bug in React. Please file an issue." - ); } + throw ReactError( + "Unknown unit of work tag. This error is likely caused by a bug in React. Please file an issue." + ); } var valueCursor = { current: null }, currentlyRenderingFiber = null, @@ -4825,17 +4788,17 @@ function readContext(context, observedBits) { if ("number" !== typeof observedBits || 1073741823 === observedBits) (lastContextWithAllBitsObserved = context), (observedBits = 1073741823); observedBits = { context: context, observedBits: observedBits, next: null }; - null === lastContextDependency - ? (invariant( - null !== currentlyRenderingFiber, + if (null === lastContextDependency) { + if (null === currentlyRenderingFiber) + throw ReactError( "Context can only be read while React is rendering. In classes, you can read it in the render method or getDerivedStateFromProps. In function components, you can read it directly in the function body, but not inside Hooks like useReducer() or useMemo()." - ), - (lastContextDependency = observedBits), - (currentlyRenderingFiber.contextDependencies = { - first: observedBits, - expirationTime: 0 - })) - : (lastContextDependency = lastContextDependency.next = observedBits); + ); + lastContextDependency = observedBits; + currentlyRenderingFiber.contextDependencies = { + first: observedBits, + expirationTime: 0 + }; + } else lastContextDependency = lastContextDependency.next = observedBits; } return context._currentValue2; } @@ -4988,7 +4951,9 @@ function processUpdateQueue( ((newFirstUpdate = update), (newBaseState = resultState)), newExpirationTime < updateExpirationTime && (newExpirationTime = updateExpirationTime)) - : ((resultState = getStateFromUpdate( + : (updateExpirationTime < mostRecentEventTime && + (mostRecentEventTime = updateExpirationTime), + (resultState = getStateFromUpdate( workInProgress, queue, update, @@ -5061,11 +5026,11 @@ function commitUpdateEffects(effect, instance) { if (null !== _callback3) { effect.callback = null; var context = instance; - invariant( - "function" === typeof _callback3, - "Invalid argument passed as callback. Expected a function. Instead received: %s", - _callback3 - ); + if ("function" !== typeof _callback3) + throw ReactError( + "Invalid argument passed as callback. Expected a function. Instead received: " + + _callback3 + ); _callback3.call(context); } effect = effect.nextEffect; @@ -5089,39 +5054,41 @@ appendAllChildren = function( isHidden ) { for (var node = workInProgress.child; null !== node; ) { - a: if (5 === node.tag) { + if (5 === node.tag) { var instance = node.stateNode; - if (needsVisibilityToggle) { - var props = node.memoizedProps, - type = node.type; - instance = isHidden - ? cloneHiddenInstance(instance, type, props, node) - : cloneUnhiddenInstance(instance, type, props, node); - node.stateNode = instance; - } + needsVisibilityToggle && + isHidden && + (instance = cloneHiddenInstance( + instance, + node.type, + node.memoizedProps, + node + )); FabricUIManager.appendChild(parent.node, instance.node); } else if (6 === node.tag) { instance = node.stateNode; - if (needsVisibilityToggle) { - instance = node.memoizedProps; - props = requiredContext(rootInstanceStackCursor.current); - type = requiredContext(contextStackCursor$1.current); - if (isHidden) throw Error("Not yet implemented."); - instance = createTextInstance(instance, props, type, workInProgress); - node.stateNode = instance; - } + if (needsVisibilityToggle && isHidden) + throw Error("Not yet implemented."); FabricUIManager.appendChild(parent.node, instance.node); } else if (4 !== node.tag) { if ( 13 === node.tag && - ((props = node.alternate), - null !== props && - ((instance = null !== node.memoizedState), - (null !== props.memoizedState) !== instance)) + 0 !== (node.effectTag & 4) && + (instance = null !== node.memoizedState) ) { - props = instance ? node.child : node; - null !== props && appendAllChildren(parent, props, !0, instance); - break a; + var primaryChildParent = node.child; + if ( + null !== primaryChildParent && + (null !== primaryChildParent.child && + ((primaryChildParent.child.return = primaryChildParent), + appendAllChildren(parent, primaryChildParent, !0, instance)), + (instance = primaryChildParent.sibling), + null !== instance) + ) { + instance.return = node; + node = instance; + continue; + } } if (null !== node.child) { node.child.return = node; @@ -5145,40 +5112,46 @@ function appendAllChildrenToContainer( isHidden ) { for (var node = workInProgress.child; null !== node; ) { - a: if (5 === node.tag) { + if (5 === node.tag) { var instance = node.stateNode; - if (needsVisibilityToggle) { - var props = node.memoizedProps, - type = node.type; - instance = isHidden - ? cloneHiddenInstance(instance, type, props, node) - : cloneUnhiddenInstance(instance, type, props, node); - node.stateNode = instance; - } + needsVisibilityToggle && + isHidden && + (instance = cloneHiddenInstance( + instance, + node.type, + node.memoizedProps, + node + )); FabricUIManager.appendChildToSet(containerChildSet, instance.node); } else if (6 === node.tag) { instance = node.stateNode; - if (needsVisibilityToggle) { - instance = node.memoizedProps; - props = requiredContext(rootInstanceStackCursor.current); - type = requiredContext(contextStackCursor$1.current); - if (isHidden) throw Error("Not yet implemented."); - instance = createTextInstance(instance, props, type, workInProgress); - node.stateNode = instance; - } + if (needsVisibilityToggle && isHidden) + throw Error("Not yet implemented."); FabricUIManager.appendChildToSet(containerChildSet, instance.node); } else if (4 !== node.tag) { if ( 13 === node.tag && - ((props = node.alternate), - null !== props && - ((instance = null !== node.memoizedState), - (null !== props.memoizedState) !== instance)) + 0 !== (node.effectTag & 4) && + (instance = null !== node.memoizedState) ) { - props = instance ? node.child : node; - null !== props && - appendAllChildrenToContainer(containerChildSet, props, !0, instance); - break a; + var primaryChildParent = node.child; + if ( + null !== primaryChildParent && + (null !== primaryChildParent.child && + ((primaryChildParent.child.return = primaryChildParent), + appendAllChildrenToContainer( + containerChildSet, + primaryChildParent, + !0, + instance + )), + (instance = primaryChildParent.sibling), + null !== instance) + ) { + instance.return = node; + node = instance; + continue; + } } if (null !== node.child) { node.child.return = node; @@ -5281,6 +5254,7 @@ function logCapturedError(capturedError) { : Error("Unspecified error at:" + componentStack); ExceptionsManager.handleException(error, !1); } +var PossiblyWeakSet$1 = "function" === typeof WeakSet ? WeakSet : Set; function logError(boundary, errorInfo) { var source = errorInfo.source, stack = errorInfo.stack; @@ -5317,22 +5291,56 @@ function safelyDetachRef(current$$1) { try { ref(null); } catch (refError) { - captureCommitPhaseError(current$$1, refError); + captureCommitPhaseError$$1(current$$1, refError); } else ref.current = null; } +function commitBeforeMutationLifeCycles(current$$1, finishedWork) { + switch (finishedWork.tag) { + case 0: + case 11: + case 15: + commitHookEffectList(2, 0, finishedWork); + break; + case 1: + if (finishedWork.effectTag & 256 && null !== current$$1) { + var prevProps = current$$1.memoizedProps, + prevState = current$$1.memoizedState; + current$$1 = finishedWork.stateNode; + finishedWork = current$$1.getSnapshotBeforeUpdate( + finishedWork.elementType === finishedWork.type + ? prevProps + : resolveDefaultProps(finishedWork.type, prevProps), + prevState + ); + current$$1.__reactInternalSnapshotBeforeUpdate = finishedWork; + } + break; + case 3: + case 5: + case 6: + case 4: + case 17: + case 20: + break; + default: + throw ReactError( + "This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue." + ); + } +} function commitHookEffectList(unmountTag, mountTag, finishedWork) { finishedWork = finishedWork.updateQueue; finishedWork = null !== finishedWork ? finishedWork.lastEffect : null; if (null !== finishedWork) { var effect = (finishedWork = finishedWork.next); do { - if ((effect.tag & unmountTag) !== NoEffect$1) { + if (0 !== (effect.tag & unmountTag)) { var destroy = effect.destroy; effect.destroy = void 0; void 0 !== destroy && destroy(); } - (effect.tag & mountTag) !== NoEffect$1 && + 0 !== (effect.tag & mountTag) && ((destroy = effect.create), (effect.destroy = destroy())); effect = effect.next; } while (effect !== finishedWork); @@ -5344,26 +5352,48 @@ function commitWork(current$$1, finishedWork) { case 11: case 14: case 15: - commitHookEffectList(UnmountMutation, MountMutation, finishedWork); + commitHookEffectList(4, 8, finishedWork); + return; + case 12: + return; + case 13: + commitSuspenseComponent(finishedWork); return; } switch (finishedWork.tag) { case 1: - break; case 5: - break; case 6: + case 20: break; case 3: case 4: break; default: - invariant( - !1, + throw ReactError( "This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue." ); } } +function commitSuspenseComponent(finishedWork) { + var newState = finishedWork.memoizedState; + null !== newState && + 0 === newState.fallbackExpirationTime && + (newState.fallbackExpirationTime = requestCurrentTime$$1() - 500); + newState = finishedWork.updateQueue; + if (null !== newState) { + finishedWork.updateQueue = null; + var retryCache = finishedWork.stateNode; + null === retryCache && + (retryCache = finishedWork.stateNode = new PossiblyWeakSet$1()); + newState.forEach(function(thenable) { + var retry = resolveRetryThenable$$1.bind(null, finishedWork, thenable); + retry = tracing.unstable_wrap(retry); + retryCache.has(thenable) || + (retryCache.add(thenable), thenable.then(retry, retry)); + }); + } +} var PossiblyWeakMap = "function" === typeof WeakMap ? WeakMap : Map; function createRootErrorUpdate(fiber, errorInfo, expirationTime) { expirationTime = createUpdate(expirationTime); @@ -5371,7 +5401,7 @@ function createRootErrorUpdate(fiber, errorInfo, expirationTime) { expirationTime.payload = { element: null }; var error = errorInfo.value; expirationTime.callback = function() { - onUncaughtError(error); + onUncaughtError$$1(error); logError(fiber, errorInfo); }; return expirationTime; @@ -5419,34 +5449,13 @@ function throwException( ) { var thenable = value; value = returnFiber; - var earliestTimeoutMs = -1, - startTimeMs = -1; do { - if (13 === value.tag) { - var current$$1 = value.alternate; - if ( - null !== current$$1 && - ((current$$1 = current$$1.memoizedState), null !== current$$1) - ) { - startTimeMs = 10 * (1073741822 - current$$1.timedOutAt); - break; - } - current$$1 = value.pendingProps.maxDuration; - if ("number" === typeof current$$1) - if (0 >= current$$1) earliestTimeoutMs = 0; - else if (-1 === earliestTimeoutMs || current$$1 < earliestTimeoutMs) - earliestTimeoutMs = current$$1; - } - value = value.return; - } while (null !== value); - value = returnFiber; - do { - if ((current$$1 = 13 === value.tag)) - current$$1 = - void 0 === value.memoizedProps.fallback - ? !1 - : null === value.memoizedState; - if (current$$1) { + if ( + 13 === value.tag && + (void 0 === value.memoizedProps.fallback + ? 0 + : null === value.memoizedState) + ) { returnFiber = value.updateQueue; null === returnFiber ? ((returnFiber = new Set()), @@ -5465,40 +5474,27 @@ function throwException( sourceFiber.expirationTime = 1073741823; return; } - sourceFiber = root.pingCache; - null === sourceFiber - ? ((sourceFiber = root.pingCache = new PossiblyWeakMap()), + sourceFiber = root; + root = renderExpirationTime; + var pingCache = sourceFiber.pingCache; + null === pingCache + ? ((pingCache = sourceFiber.pingCache = new PossiblyWeakMap()), (returnFiber = new Set()), - sourceFiber.set(thenable, returnFiber)) - : ((returnFiber = sourceFiber.get(thenable)), + pingCache.set(thenable, returnFiber)) + : ((returnFiber = pingCache.get(thenable)), void 0 === returnFiber && ((returnFiber = new Set()), - sourceFiber.set(thenable, returnFiber))); - returnFiber.has(renderExpirationTime) || - (returnFiber.add(renderExpirationTime), - (sourceFiber = pingSuspendedRoot.bind( + pingCache.set(thenable, returnFiber))); + returnFiber.has(root) || + (returnFiber.add(root), + (sourceFiber = pingSuspendedRoot$$1.bind( null, - root, + sourceFiber, thenable, - renderExpirationTime + root )), (sourceFiber = tracing.unstable_wrap(sourceFiber)), thenable.then(sourceFiber, sourceFiber)); - -1 === earliestTimeoutMs - ? (root = 1073741823) - : (-1 === startTimeMs && - (startTimeMs = - 10 * - (1073741822 - - findEarliestOutstandingPriorityLevel( - root, - renderExpirationTime - )) - - 5e3), - (root = startTimeMs + earliestTimeoutMs)); - 0 <= root && - nextLatestAbsoluteTimeoutMs < root && - (nextLatestAbsoluteTimeoutMs = root); value.effectTag |= 2048; value.expirationTime = renderExpirationTime; return; @@ -5513,44 +5509,43 @@ function throwException( } nextRenderDidError = !0; value = createCapturedValue(value, sourceFiber); - root = returnFiber; + sourceFiber = returnFiber; do { - switch (root.tag) { + switch (sourceFiber.tag) { case 3: - root.effectTag |= 2048; - root.expirationTime = renderExpirationTime; + sourceFiber.effectTag |= 2048; + sourceFiber.expirationTime = renderExpirationTime; renderExpirationTime = createRootErrorUpdate( - root, + sourceFiber, value, renderExpirationTime ); - enqueueCapturedUpdate(root, renderExpirationTime); + enqueueCapturedUpdate(sourceFiber, renderExpirationTime); return; case 1: if ( ((thenable = value), - (earliestTimeoutMs = root.type), - (startTimeMs = root.stateNode), - 0 === (root.effectTag & 64) && - ("function" === typeof earliestTimeoutMs.getDerivedStateFromError || - (null !== startTimeMs && - "function" === typeof startTimeMs.componentDidCatch && - (null === legacyErrorBoundariesThatAlreadyFailed || - !legacyErrorBoundariesThatAlreadyFailed.has(startTimeMs))))) + (root = sourceFiber.type), + (returnFiber = sourceFiber.stateNode), + 0 === (sourceFiber.effectTag & 64) && + ("function" === typeof root.getDerivedStateFromError || + (null !== returnFiber && + "function" === typeof returnFiber.componentDidCatch && + !isAlreadyFailedLegacyErrorBoundary$$1(returnFiber)))) ) { - root.effectTag |= 2048; - root.expirationTime = renderExpirationTime; + sourceFiber.effectTag |= 2048; + sourceFiber.expirationTime = renderExpirationTime; renderExpirationTime = createClassErrorUpdate( - root, + sourceFiber, thenable, renderExpirationTime ); - enqueueCapturedUpdate(root, renderExpirationTime); + enqueueCapturedUpdate(sourceFiber, renderExpirationTime); return; } } - root = root.return; - } while (null !== root); + sourceFiber = sourceFiber.return; + } while (null !== sourceFiber); } function unwindWork(workInProgress) { switch (workInProgress.tag) { @@ -5562,17 +5557,15 @@ function unwindWork(workInProgress) { workInProgress) : null; case 3: - return ( - popHostContainer(workInProgress), - popTopLevelContextObject(workInProgress), - (effectTag = workInProgress.effectTag), - invariant( - 0 === (effectTag & 64), + popHostContainer(workInProgress); + popTopLevelContextObject(workInProgress); + effectTag = workInProgress.effectTag; + if (0 !== (effectTag & 64)) + throw ReactError( "The root failed to unmount after an error. This is likely a bug in React. Please file an issue." - ), - (workInProgress.effectTag = (effectTag & -2049) | 64), - workInProgress - ); + ); + workInProgress.effectTag = (effectTag & -2049) | 64; + return workInProgress; case 5: return popHostContext(workInProgress), null; case 13: @@ -5583,26 +5576,40 @@ function unwindWork(workInProgress) { workInProgress) : null ); + case 18: + return null; case 4: return popHostContainer(workInProgress), null; case 10: return popProvider(workInProgress), null; + case 19: + case 20: + return null; default: return null; } } -var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher, +var scheduleCallback$1 = Scheduler.unstable_scheduleCallback, + cancelCallback$1 = Scheduler.unstable_cancelCallback, + shouldYield$1 = Scheduler.unstable_shouldYield, + now$1 = Scheduler.unstable_now, + getCurrentPriorityLevel$1 = Scheduler.unstable_getCurrentPriorityLevel, + NormalPriority$1 = Scheduler.unstable_NormalPriority, + ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher, ReactCurrentOwner$2 = ReactSharedInternals.ReactCurrentOwner; -invariant( - null != tracing.__interactionsRef && - null != tracing.__interactionsRef.current, - "It is not supported to run the profiling version of a renderer (for example, `react-dom/profiling`) without also replacing the `scheduler/tracing` module with `scheduler/tracing-profiling`. Your bundler might have a setting for aliasing both modules. Learn more at http://fb.me/react-profiling" -); +if ( + null == tracing.__interactionsRef || + null == tracing.__interactionsRef.current +) + throw ReactError( + "It is not supported to run the profiling version of a renderer (for example, `react-dom/profiling`) without also replacing the `scheduler/tracing` module with `scheduler/tracing-profiling`. Your bundler might have a setting for aliasing both modules. Learn more at http://fb.me/react-profiling" + ); var isWorking = !1, nextUnitOfWork = null, nextRoot = null, nextRenderExpirationTime = 0, - nextLatestAbsoluteTimeoutMs = -1, + mostRecentEventTime = 1073741823, + nextRenderDidSuspend = !1, nextRenderDidError = !1, nextEffect = null, isCommitting$1 = !1, @@ -5643,8 +5650,8 @@ function resetStack() { } nextRoot = null; nextRenderExpirationTime = 0; - nextLatestAbsoluteTimeoutMs = -1; - nextRenderDidError = !1; + mostRecentEventTime = 1073741823; + nextRenderDidError = nextRenderDidSuspend = !1; nextUnitOfWork = null; } function commitAllHostEffects() { @@ -5694,7 +5701,7 @@ function commitAllHostEffects() { try { destroy(); } catch (error) { - captureCommitPhaseError(current$$1$jscomp$1, error); + captureCommitPhaseError$$1(current$$1$jscomp$1, error); } } effect = effect.next; @@ -5710,7 +5717,7 @@ function commitAllHostEffects() { (updateQueue.state = current$$1$jscomp$0.memoizedState), updateQueue.componentWillUnmount(); } catch (unmountError) { - captureCommitPhaseError(current$$1$jscomp$0, unmountError); + captureCommitPhaseError$$1(current$$1$jscomp$0, unmountError); } break; case 5: @@ -5747,48 +5754,6 @@ function commitAllHostEffects() { nextEffect = nextEffect.nextEffect; } } -function commitBeforeMutationLifecycles() { - for (; null !== nextEffect; ) { - if (nextEffect.effectTag & 256) - a: { - var current$$1 = nextEffect.alternate, - finishedWork = nextEffect; - switch (finishedWork.tag) { - case 0: - case 11: - case 15: - commitHookEffectList(UnmountSnapshot, NoEffect$1, finishedWork); - break a; - case 1: - if (finishedWork.effectTag & 256 && null !== current$$1) { - var prevProps = current$$1.memoizedProps, - prevState = current$$1.memoizedState; - current$$1 = finishedWork.stateNode; - finishedWork = current$$1.getSnapshotBeforeUpdate( - finishedWork.elementType === finishedWork.type - ? prevProps - : resolveDefaultProps(finishedWork.type, prevProps), - prevState - ); - current$$1.__reactInternalSnapshotBeforeUpdate = finishedWork; - } - break a; - case 3: - case 5: - case 6: - case 4: - case 17: - break a; - default: - invariant( - !1, - "This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue." - ); - } - } - nextEffect = nextEffect.nextEffect; - } -} function commitAllLifeCycles( finishedRoot$jscomp$0, committedExpirationTime$jscomp$0 @@ -5804,7 +5769,7 @@ function commitAllLifeCycles( case 0: case 11: case 15: - commitHookEffectList(UnmountLayout, MountLayout, finishedWork); + commitHookEffectList(16, 32, finishedWork); break; case 1: finishedRoot = finishedWork.stateNode; @@ -5854,10 +5819,8 @@ function commitAllLifeCycles( } break; case 5: - null === current$$1 && - finishedWork.effectTag & 4 && - invariant( - !1, + if (null === current$$1 && finishedWork.effectTag & 4) + throw ReactError( "The current renderer does not support mutation. This error is likely caused by a bug in React. Please file an issue." ); break; @@ -5878,12 +5841,11 @@ function commitAllLifeCycles( ); break; case 13: - break; case 17: + case 20: break; default: - invariant( - !1, + throw ReactError( "This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue." ); } @@ -5915,38 +5877,44 @@ function commitPassiveEffects(root, firstEffect) { error = void 0; try { var finishedWork = firstEffect; - commitHookEffectList(UnmountPassive, NoEffect$1, finishedWork); - commitHookEffectList(NoEffect$1, MountPassive, finishedWork); + commitHookEffectList(128, 0, finishedWork); + commitHookEffectList(0, 64, finishedWork); } catch (e) { (didError = !0), (error = e); } - didError && captureCommitPhaseError(firstEffect, error); + didError && captureCommitPhaseError$1(firstEffect, error); } firstEffect = firstEffect.nextEffect; } while (null !== firstEffect); isRendering = previousIsRendering; previousIsRendering = root.expirationTime; 0 !== previousIsRendering && requestWork(root, previousIsRendering); + isBatchingUpdates || isRendering || performWork(1073741823); } -function flushPassiveEffects() { - if (null !== passiveEffectCallbackHandle) { - var callbackID = passiveEffectCallbackHandle; - scheduledCallback = null; - clearTimeout(callbackID); - } +function isAlreadyFailedLegacyErrorBoundary$1(instance) { + return ( + null !== legacyErrorBoundariesThatAlreadyFailed && + legacyErrorBoundariesThatAlreadyFailed.has(instance) + ); +} +function flushPassiveEffects$1() { + var didFlushEffects = null !== passiveEffectCallback; + null !== passiveEffectCallbackHandle && + cancelCallback$1(passiveEffectCallbackHandle); null !== passiveEffectCallback && passiveEffectCallback(); + return didFlushEffects; } function commitRoot(root, finishedWork) { isCommitting$1 = isWorking = !0; - invariant( - root.current !== finishedWork, - "Cannot commit the same tree as before. This is probably a bug related to the return field. This error is likely caused by a bug in React. Please file an issue." - ); + if (root.current === finishedWork) + throw ReactError( + "Cannot commit the same tree as before. This is probably a bug related to the return field. This error is likely caused by a bug in React. Please file an issue." + ); var committedExpirationTime = root.pendingCommitExpirationTime; - invariant( - 0 !== committedExpirationTime, - "Cannot commit an incomplete root. This error is likely caused by a bug in React. Please file an issue." - ); + if (0 === committedExpirationTime) + throw ReactError( + "Cannot commit an incomplete root. This error is likely caused by a bug in React. Please file an issue." + ); root.pendingCommitExpirationTime = 0; var updateExpirationTimeBeforeCommit = finishedWork.expirationTime, childExpirationTimeBeforeCommit = finishedWork.childExpirationTime; @@ -5971,19 +5939,23 @@ function commitRoot(root, finishedWork) { var didError = !1, error$jscomp$0 = void 0; try { - commitBeforeMutationLifecycles(); + for (; null !== nextEffect; ) + nextEffect.effectTag & 256 && + commitBeforeMutationLifeCycles(nextEffect.alternate, nextEffect), + (nextEffect = nextEffect.nextEffect); } catch (e) { (didError = !0), (error$jscomp$0 = e); } - didError && - (invariant( - null !== nextEffect, - "Should have next effect. This error is likely caused by a bug in React. Please file an issue." - ), - captureCommitPhaseError(nextEffect, error$jscomp$0), - null !== nextEffect && (nextEffect = nextEffect.nextEffect)); + if (didError) { + if (null === nextEffect) + throw ReactError( + "Should have next effect. This error is likely caused by a bug in React. Please file an issue." + ); + captureCommitPhaseError$1(nextEffect, error$jscomp$0); + null !== nextEffect && (nextEffect = nextEffect.nextEffect); + } } - commitTime = now$1(); + commitTime = now$2(); for (nextEffect = childExpirationTimeBeforeCommit; null !== nextEffect; ) { didError = !1; error$jscomp$0 = void 0; @@ -5992,13 +5964,14 @@ function commitRoot(root, finishedWork) { } catch (e) { (didError = !0), (error$jscomp$0 = e); } - didError && - (invariant( - null !== nextEffect, - "Should have next effect. This error is likely caused by a bug in React. Please file an issue." - ), - captureCommitPhaseError(nextEffect, error$jscomp$0), - null !== nextEffect && (nextEffect = nextEffect.nextEffect)); + if (didError) { + if (null === nextEffect) + throw ReactError( + "Should have next effect. This error is likely caused by a bug in React. Please file an issue." + ); + captureCommitPhaseError$1(nextEffect, error$jscomp$0); + null !== nextEffect && (nextEffect = nextEffect.nextEffect); + } } root.current = finishedWork; for (nextEffect = childExpirationTimeBeforeCommit; null !== nextEffect; ) { @@ -6009,32 +5982,30 @@ function commitRoot(root, finishedWork) { } catch (e) { (didError = !0), (error$jscomp$0 = e); } - didError && - (invariant( - null !== nextEffect, - "Should have next effect. This error is likely caused by a bug in React. Please file an issue." - ), - captureCommitPhaseError(nextEffect, error$jscomp$0), - null !== nextEffect && (nextEffect = nextEffect.nextEffect)); + if (didError) { + if (null === nextEffect) + throw ReactError( + "Should have next effect. This error is likely caused by a bug in React. Please file an issue." + ); + captureCommitPhaseError$1(nextEffect, error$jscomp$0); + null !== nextEffect && (nextEffect = nextEffect.nextEffect); + } } - if ( - null !== childExpirationTimeBeforeCommit && - null !== rootWithPendingPassiveEffects - ) { - var callback = commitPassiveEffects.bind( + null !== childExpirationTimeBeforeCommit && + null !== rootWithPendingPassiveEffects && + ((childExpirationTimeBeforeCommit = commitPassiveEffects.bind( null, root, childExpirationTimeBeforeCommit - ); - callback = tracing.unstable_wrap(callback); - passiveEffectCallbackHandle = scheduler.unstable_runWithPriority( - scheduler.unstable_NormalPriority, - function() { - return scheduleDeferredCallback$1(callback); - } - ); - passiveEffectCallback = callback; - } + )), + (childExpirationTimeBeforeCommit = tracing.unstable_wrap( + childExpirationTimeBeforeCommit + )), + (passiveEffectCallbackHandle = scheduleCallback$1( + NormalPriority$1, + childExpirationTimeBeforeCommit + )), + (passiveEffectCallback = childExpirationTimeBeforeCommit)); isWorking = isCommitting$1 = !1; "function" === typeof onCommitFiberRoot && onCommitFiberRoot(finishedWork.stateNode); @@ -6090,8 +6061,8 @@ function completeUnitOfWork(workInProgress) { nextUnitOfWork = workInProgress; if (workInProgress.mode & 4) { var fiber = workInProgress; - profilerStartTime = now$1(); - 0 > fiber.actualStartTime && (fiber.actualStartTime = now$1()); + profilerStartTime = now$2(); + 0 > fiber.actualStartTime && (fiber.actualStartTime = now$2()); } a: { var current = current$$1; @@ -6137,16 +6108,15 @@ function completeUnitOfWork(workInProgress) { current.ref !== current$$1.ref && (current$$1.effectTag |= 128); else if (fiber) { var currentHostContext = requiredContext( - contextStackCursor$1.current - ), - internalInstanceHandle = current$$1; + contextStackCursor$1.current + ); current = nextReactTag; nextReactTag += 2; var viewConfig = ReactNativeViewConfigRegistry.get(type); - invariant( - "RCTView" !== type || !currentHostContext.isInAParentText, - "Nesting of within is not currently supported." - ); + if ("RCTView" === type && currentHostContext.isInAParentText) + throw ReactError( + "Nesting of within is not currently supported." + ); type = diffProperties( null, emptyObject, @@ -6158,42 +6128,47 @@ function completeUnitOfWork(workInProgress) { viewConfig.uiViewClassName, renderExpirationTime, type, - internalInstanceHandle + current$$1 + ); + fiber = new ReactFabricHostComponent( + current, + viewConfig, + fiber, + current$$1 ); - fiber = new ReactFabricHostComponent(current, viewConfig, fiber); fiber = { node: renderExpirationTime, canonical: fiber }; appendAllChildren(fiber, current$$1, !1, !1); current$$1.stateNode = fiber; null !== current$$1.ref && (current$$1.effectTag |= 128); - } else - invariant( - null !== current$$1.stateNode, + } else if (null === current$$1.stateNode) + throw ReactError( "We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue." ); break; case 6: - current && null != current$$1.stateNode - ? updateHostText$1( - current, - current$$1, - current.memoizedProps, - fiber - ) - : ("string" !== typeof fiber && - invariant( - null !== current$$1.stateNode, - "We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue." - ), - (current = requiredContext(rootInstanceStackCursor.current)), - (renderExpirationTime = requiredContext( - contextStackCursor$1.current - )), - (current$$1.stateNode = createTextInstance( - fiber, - current, - renderExpirationTime, - current$$1 - ))); + if (current && null != current$$1.stateNode) + updateHostText$1( + current, + current$$1, + current.memoizedProps, + fiber + ); + else { + if ("string" !== typeof fiber && null === current$$1.stateNode) + throw ReactError( + "We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue." + ); + current = requiredContext(rootInstanceStackCursor.current); + renderExpirationTime = requiredContext( + contextStackCursor$1.current + ); + current$$1.stateNode = createTextInstance( + fiber, + current, + renderExpirationTime, + current$$1 + ); + } break; case 11: break; @@ -6205,21 +6180,29 @@ function completeUnitOfWork(workInProgress) { break a; } fiber = null !== fiber; - renderExpirationTime = - null !== current && null !== current.memoizedState; + renderExpirationTime = !1; null !== current && - !fiber && - renderExpirationTime && - ((current = current.child.sibling), - null !== current && - ((viewConfig = current$$1.firstEffect), - null !== viewConfig - ? ((current$$1.firstEffect = current), - (current.nextEffect = viewConfig)) - : ((current$$1.firstEffect = current$$1.lastEffect = current), - (current.nextEffect = null)), - (current.effectTag = 8))); - if (fiber || renderExpirationTime) current$$1.effectTag |= 4; + ((viewConfig = current.memoizedState), + (renderExpirationTime = null !== viewConfig), + fiber || + null === viewConfig || + ((viewConfig = viewConfig.fallbackExpirationTime), + viewConfig < mostRecentEventTime && + (mostRecentEventTime = viewConfig), + (current = current.child.sibling), + null !== current && + ((viewConfig = current$$1.firstEffect), + null !== viewConfig + ? ((current$$1.firstEffect = current), + (current.nextEffect = viewConfig)) + : ((current$$1.firstEffect = current$$1.lastEffect = current), + (current.nextEffect = null)), + (current.effectTag = 8)))); + fiber && + !renderExpirationTime && + 0 !== (current$$1.mode & 1) && + (nextRenderDidSuspend = !0); + fiber && (current$$1.effectTag |= 4); break; case 7: break; @@ -6241,9 +6224,14 @@ function completeUnitOfWork(workInProgress) { case 17: isContextProvider(current$$1.type) && popContext(current$$1); break; + case 18: + break; + case 19: + break; + case 20: + break; default: - invariant( - !1, + throw ReactError( "Unknown unit of work tag. This error is likely caused by a bug in React. Please file an issue." ); } @@ -6263,15 +6251,16 @@ function completeUnitOfWork(workInProgress) { viewConfig = null === current$$1.alternate || current$$1.child !== current$$1.alternate.child; - for (type = current$$1.child; null !== type; ) - (internalInstanceHandle = type.expirationTime), - (currentHostContext = type.childExpirationTime), - internalInstanceHandle > fiber && - (fiber = internalInstanceHandle), - currentHostContext > fiber && (fiber = currentHostContext), - viewConfig && (current += type.actualDuration), - (renderExpirationTime += type.treeBaseDuration), - (type = type.sibling); + for (type = current$$1.child; null !== type; ) { + currentHostContext = type.expirationTime; + var childChildExpirationTime = type.childExpirationTime; + currentHostContext > fiber && (fiber = currentHostContext); + childChildExpirationTime > fiber && + (fiber = childChildExpirationTime); + viewConfig && (current += type.actualDuration); + renderExpirationTime += type.treeBaseDuration; + type = type.sibling; + } current$$1.actualDuration = current; current$$1.treeBaseDuration = renderExpirationTime; } else @@ -6321,9 +6310,9 @@ function completeUnitOfWork(workInProgress) { function performUnitOfWork(workInProgress) { var current$$1 = workInProgress.alternate; workInProgress.mode & 4 && - ((profilerStartTime = now$1()), + ((profilerStartTime = now$2()), 0 > workInProgress.actualStartTime && - (workInProgress.actualStartTime = now$1())); + (workInProgress.actualStartTime = now$2())); current$$1 = beginWork(current$$1, workInProgress, nextRenderExpirationTime); workInProgress.memoizedProps = workInProgress.pendingProps; workInProgress.mode & 4 && @@ -6333,11 +6322,11 @@ function performUnitOfWork(workInProgress) { return current$$1; } function renderRoot(root, isYieldy) { - invariant( - !isWorking, - "renderRoot was called recursively. This error is likely caused by a bug in React. Please file an issue." - ); - flushPassiveEffects(); + if (isWorking) + throw ReactError( + "renderRoot was called recursively. This error is likely caused by a bug in React. Please file an issue." + ); + flushPassiveEffects$1(); isWorking = !0; var previousDispatcher = ReactCurrentDispatcher.current; ReactCurrentDispatcher.current = ContextOnlyDispatcher; @@ -6387,7 +6376,7 @@ function renderRoot(root, isYieldy) { do { try { if (isYieldy) - for (; null !== nextUnitOfWork && !shouldYieldToRenderer(); ) + for (; null !== nextUnitOfWork && !shouldYield$1(); ) nextUnitOfWork = performUnitOfWork(nextUnitOfWork); else for (; null !== nextUnitOfWork; ) @@ -6398,17 +6387,18 @@ function renderRoot(root, isYieldy) { resetHooks(), null === nextUnitOfWork) ) - (threadID = !0), onUncaughtError(thrownValue); + (threadID = !0), onUncaughtError$1(thrownValue); else { nextUnitOfWork.mode & 4 && stopProfilerTimerIfRunningAndRecordDelta(nextUnitOfWork, !0); - invariant( - null !== nextUnitOfWork, - "Failed to replay rendering after an error. This is likely caused by a bug in React. Please file an issue with a reproducing case to help us find it." - ); + if (null === nextUnitOfWork) + throw ReactError( + "Failed to replay rendering after an error. This is likely caused by a bug in React. Please file an issue with a reproducing case to help us find it." + ); var sourceFiber = nextUnitOfWork, returnFiber = sourceFiber.return; - if (null === returnFiber) (threadID = !0), onUncaughtError(thrownValue); + if (null === returnFiber) + (threadID = !0), onUncaughtError$1(thrownValue); else { throwException( root, @@ -6433,10 +6423,10 @@ function renderRoot(root, isYieldy) { else if (null !== nextUnitOfWork) root.finishedWork = null; else { previousDispatcher = root.current.alternate; - invariant( - null !== previousDispatcher, - "Finished root should have a work-in-progress. This error is likely caused by a bug in React. Please file an issue." - ); + if (null === previousDispatcher) + throw ReactError( + "Finished root should have a work-in-progress. This error is likely caused by a bug in React. Please file an issue." + ); nextRoot = null; if (nextRenderDidError) { if (hasLowerPriorityWork(root, expirationTime)) { @@ -6458,16 +6448,11 @@ function renderRoot(root, isYieldy) { return; } } - isYieldy && -1 !== nextLatestAbsoluteTimeoutMs + isYieldy && nextRenderDidSuspend && 1073741823 !== mostRecentEventTime ? (markSuspendedPriorityLevel(root, expirationTime), (isYieldy = - 10 * - (1073741822 - - findEarliestOutstandingPriorityLevel(root, expirationTime))), - isYieldy < nextLatestAbsoluteTimeoutMs && - (nextLatestAbsoluteTimeoutMs = isYieldy), - (isYieldy = 10 * (1073741822 - requestCurrentTime())), - (isYieldy = nextLatestAbsoluteTimeoutMs - isYieldy), + 10 * (1073741822 - mostRecentEventTime) - 5e3 + originalStartTimeMs), + (isYieldy = 150 - (now$1() - isYieldy)), onSuspend( root, previousDispatcher, @@ -6478,7 +6463,7 @@ function renderRoot(root, isYieldy) { : onComplete(root, previousDispatcher, expirationTime); } } -function captureCommitPhaseError(sourceFiber, value) { +function captureCommitPhaseError$1(sourceFiber, value) { for (var fiber = sourceFiber.return; null !== fiber; ) { switch (fiber.tag) { case 1: @@ -6486,13 +6471,12 @@ function captureCommitPhaseError(sourceFiber, value) { if ( "function" === typeof fiber.type.getDerivedStateFromError || ("function" === typeof instance.componentDidCatch && - (null === legacyErrorBoundariesThatAlreadyFailed || - !legacyErrorBoundariesThatAlreadyFailed.has(instance))) + !isAlreadyFailedLegacyErrorBoundary$1(instance)) ) { sourceFiber = createCapturedValue(value, sourceFiber); sourceFiber = createClassErrorUpdate(fiber, sourceFiber, 1073741823); enqueueUpdate(fiber, sourceFiber); - scheduleWork(fiber, 1073741823); + scheduleWork$1(fiber, 1073741823); return; } break; @@ -6500,7 +6484,7 @@ function captureCommitPhaseError(sourceFiber, value) { sourceFiber = createCapturedValue(value, sourceFiber); sourceFiber = createRootErrorUpdate(fiber, sourceFiber, 1073741823); enqueueUpdate(fiber, sourceFiber); - scheduleWork(fiber, 1073741823); + scheduleWork$1(fiber, 1073741823); return; } fiber = fiber.return; @@ -6509,64 +6493,25 @@ function captureCommitPhaseError(sourceFiber, value) { ((fiber = createCapturedValue(value, sourceFiber)), (fiber = createRootErrorUpdate(sourceFiber, fiber, 1073741823)), enqueueUpdate(sourceFiber, fiber), - scheduleWork(sourceFiber, 1073741823)); -} -function computeExpirationForFiber(currentTime, fiber) { - var priorityLevel = scheduler.unstable_getCurrentPriorityLevel(), - expirationTime = void 0; - if (0 === (fiber.mode & 1)) expirationTime = 1073741823; - else if (isWorking && !isCommitting$1) - expirationTime = nextRenderExpirationTime; - else { - switch (priorityLevel) { - case scheduler.unstable_ImmediatePriority: - expirationTime = 1073741823; - break; - case scheduler.unstable_UserBlockingPriority: - expirationTime = - 1073741822 - 10 * ((((1073741822 - currentTime + 15) / 10) | 0) + 1); - break; - case scheduler.unstable_NormalPriority: - expirationTime = - 1073741822 - 25 * ((((1073741822 - currentTime + 500) / 25) | 0) + 1); - break; - case scheduler.unstable_LowPriority: - case scheduler.unstable_IdlePriority: - expirationTime = 1; - break; - default: - invariant( - !1, - "Unknown priority level. This error is likely caused by a bug in React. Please file an issue." - ); - } - null !== nextRoot && - expirationTime === nextRenderExpirationTime && - --expirationTime; - } - priorityLevel === scheduler.unstable_UserBlockingPriority && + scheduleWork$1(sourceFiber, 1073741823)); +} +function computeExpirationForFiber$1(currentTime, fiber) { + isWorking + ? (currentTime = isCommitting$1 ? 1073741823 : nextRenderExpirationTime) + : fiber.mode & 1 + ? ((currentTime = isBatchingInteractiveUpdates + ? 1073741822 - 10 * ((((1073741822 - currentTime + 15) / 10) | 0) + 1) + : 1073741822 - + 25 * ((((1073741822 - currentTime + 500) / 25) | 0) + 1)), + null !== nextRoot && + currentTime === nextRenderExpirationTime && + --currentTime) + : (currentTime = 1073741823); + isBatchingInteractiveUpdates && (0 === lowestPriorityPendingInteractiveExpirationTime || - expirationTime < lowestPriorityPendingInteractiveExpirationTime) && - (lowestPriorityPendingInteractiveExpirationTime = expirationTime); - return expirationTime; -} -function pingSuspendedRoot(root, thenable, pingTime) { - var pingCache = root.pingCache; - null !== pingCache && pingCache.delete(thenable); - if (null !== nextRoot && nextRenderExpirationTime === pingTime) - nextRoot = null; - else if ( - ((thenable = root.earliestSuspendedTime), - (pingCache = root.latestSuspendedTime), - 0 !== thenable && pingTime <= thenable && pingTime >= pingCache) - ) { - root.didError = !1; - thenable = root.latestPingedTime; - if (0 === thenable || thenable > pingTime) root.latestPingedTime = pingTime; - findNextExpirationTimeToWorkOn(pingTime, root); - pingTime = root.expirationTime; - 0 !== pingTime && requestWork(root, pingTime); - } + currentTime < lowestPriorityPendingInteractiveExpirationTime) && + (lowestPriorityPendingInteractiveExpirationTime = currentTime); + return currentTime; } function scheduleWorkToRoot(fiber, expirationTime) { fiber.expirationTime < expirationTime && @@ -6616,9 +6561,10 @@ function scheduleWorkToRoot(fiber, expirationTime) { } return root; } -function scheduleWork(fiber, expirationTime) { +function scheduleWork$1(fiber, expirationTime) { fiber = scheduleWorkToRoot(fiber, expirationTime); - null !== fiber && + if ( + null !== fiber && (!isWorking && 0 !== nextRenderExpirationTime && expirationTime > nextRenderExpirationTime && @@ -6626,12 +6572,12 @@ function scheduleWork(fiber, expirationTime) { markPendingPriorityLevel(fiber, expirationTime), (isWorking && !isCommitting$1 && nextRoot === fiber) || requestWork(fiber, fiber.expirationTime), - nestedUpdateCount > NESTED_UPDATE_LIMIT && - ((nestedUpdateCount = 0), - invariant( - !1, - "Maximum update depth exceeded. This can happen when a component repeatedly calls setState inside componentWillUpdate or componentDidUpdate. React limits the number of nested updates to prevent infinite loops." - ))); + nestedUpdateCount > NESTED_UPDATE_LIMIT) + ) + throw ((nestedUpdateCount = 0), + ReactError( + "Maximum update depth exceeded. This can happen when a component repeatedly calls setState inside componentWillUpdate or componentDidUpdate. React limits the number of nested updates to prevent infinite loops." + )); } var firstScheduledRoot = null, lastScheduledRoot = null, @@ -6645,6 +6591,7 @@ var firstScheduledRoot = null, unhandledError = null, isBatchingUpdates = !1, isUnbatchingUpdates = !1, + isBatchingInteractiveUpdates = !1, completedBatches = null, originalStartTimeMs = now$1(), currentRendererTime = 1073741822 - ((originalStartTimeMs / 10) | 0), @@ -6659,13 +6606,14 @@ function recomputeCurrentRendererTime() { function scheduleCallbackWithExpirationTime(root, expirationTime) { if (0 !== callbackExpirationTime) { if (expirationTime < callbackExpirationTime) return; - null !== callbackID && - ((root = callbackID), (scheduledCallback = null), clearTimeout(root)); + null !== callbackID && cancelCallback$1(callbackID); } callbackExpirationTime = expirationTime; root = now$1() - originalStartTimeMs; - callbackID = scheduleDeferredCallback$1(performAsyncWork, { - timeout: 10 * (1073741822 - expirationTime) - root + expirationTime = 10 * (1073741822 - expirationTime) - root; + root = getCurrentPriorityLevel$1(); + callbackID = scheduleCallback$1(root, performAsyncWork, { + timeout: expirationTime }); } function onComplete(root, finishedWork, expirationTime) { @@ -6680,7 +6628,7 @@ function onSuspend( msUntilTimeout ) { root.expirationTime = rootExpirationTime; - 0 !== msUntilTimeout || shouldYieldToRenderer() + 0 !== msUntilTimeout || shouldYield$1() ? 0 < msUntilTimeout && (root.timeoutHandle = scheduleTimeout( onTimeout.bind(null, root, finishedWork, suspendedExpirationTime), @@ -6694,20 +6642,20 @@ function onTimeout(root, finishedWork, suspendedExpirationTime) { root.finishedWork = finishedWork; recomputeCurrentRendererTime(); currentSchedulerTime = currentRendererTime; - invariant( - !isRendering, - "work.commit(): Cannot commit while already rendering. This likely means you attempted to commit from inside a lifecycle method." - ); + if (isRendering) + throw ReactError( + "work.commit(): Cannot commit while already rendering. This likely means you attempted to commit from inside a lifecycle method." + ); nextFlushedRoot = root; nextFlushedExpirationTime = suspendedExpirationTime; performWorkOnRoot(root, suspendedExpirationTime, !1); - performWork(1073741823, !1); + performWork(1073741823); } function onCommit(root, expirationTime) { root.expirationTime = expirationTime; root.finishedWork = null; } -function requestCurrentTime() { +function requestCurrentTime$1() { if (isRendering) return currentSchedulerTime; findHighestPriorityRoot(); if (0 === nextFlushedExpirationTime || 1 === nextFlushedExpirationTime) @@ -6732,7 +6680,7 @@ function requestWork(root, expirationTime) { (nextFlushedExpirationTime = 1073741823), performWorkOnRoot(root, 1073741823, !1)) : 1073741823 === expirationTime - ? performWork(1073741823, !1) + ? performWork(1073741823) : scheduleCallbackWithExpirationTime(root, expirationTime)); } function findHighestPriorityRoot() { @@ -6746,10 +6694,10 @@ function findHighestPriorityRoot() { ) { var remainingExpirationTime = root.expirationTime; if (0 === remainingExpirationTime) { - invariant( - null !== previousScheduledRoot && null !== lastScheduledRoot, - "Should have a previous and last root. This error is likely caused by a bug in React. Please file an issue." - ); + if (null === previousScheduledRoot || null === lastScheduledRoot) + throw ReactError( + "Should have a previous and last root. This error is likely caused by a bug in React. Please file an issue." + ); if (root === root.nextScheduledRoot) { firstScheduledRoot = lastScheduledRoot = root.nextScheduledRoot = null; break; @@ -6780,75 +6728,69 @@ function findHighestPriorityRoot() { nextFlushedRoot = highestPriorityRoot; nextFlushedExpirationTime = highestPriorityWork; } -var didYield = !1; -function shouldYieldToRenderer() { - return didYield ? !0 : frameDeadline <= now$1() ? (didYield = !0) : !1; -} -function performAsyncWork() { - try { - if (!shouldYieldToRenderer() && null !== firstScheduledRoot) { - recomputeCurrentRendererTime(); - var root = firstScheduledRoot; - do { - var expirationTime = root.expirationTime; - 0 !== expirationTime && - currentRendererTime <= expirationTime && - (root.nextExpirationTimeToWorkOn = currentRendererTime); - root = root.nextScheduledRoot; - } while (root !== firstScheduledRoot); - } - performWork(0, !0); - } finally { - didYield = !1; +function performAsyncWork(didTimeout) { + if (didTimeout && null !== firstScheduledRoot) { + recomputeCurrentRendererTime(); + didTimeout = firstScheduledRoot; + do { + var expirationTime = didTimeout.expirationTime; + 0 !== expirationTime && + currentRendererTime <= expirationTime && + (didTimeout.nextExpirationTimeToWorkOn = currentRendererTime); + didTimeout = didTimeout.nextScheduledRoot; + } while (didTimeout !== firstScheduledRoot); } -} -function performWork(minExpirationTime, isYieldy) { findHighestPriorityRoot(); - if (isYieldy) - for ( - recomputeCurrentRendererTime(), - currentSchedulerTime = currentRendererTime; - null !== nextFlushedRoot && - 0 !== nextFlushedExpirationTime && - minExpirationTime <= nextFlushedExpirationTime && - !(didYield && currentRendererTime > nextFlushedExpirationTime); + recomputeCurrentRendererTime(); + for ( + currentSchedulerTime = currentRendererTime; + null !== nextFlushedRoot && + 0 !== nextFlushedExpirationTime && + !(shouldYield$1() && currentRendererTime > nextFlushedExpirationTime); - ) - performWorkOnRoot( - nextFlushedRoot, - nextFlushedExpirationTime, - currentRendererTime > nextFlushedExpirationTime - ), - findHighestPriorityRoot(), - recomputeCurrentRendererTime(), - (currentSchedulerTime = currentRendererTime); - else - for ( - ; - null !== nextFlushedRoot && - 0 !== nextFlushedExpirationTime && - minExpirationTime <= nextFlushedExpirationTime; + ) + performWorkOnRoot( + nextFlushedRoot, + nextFlushedExpirationTime, + currentRendererTime > nextFlushedExpirationTime + ), + findHighestPriorityRoot(), + recomputeCurrentRendererTime(), + (currentSchedulerTime = currentRendererTime); + callbackExpirationTime = 0; + callbackID = null; + 0 !== nextFlushedExpirationTime && + scheduleCallbackWithExpirationTime( + nextFlushedRoot, + nextFlushedExpirationTime + ); + finishRendering(); +} +function performWork(minExpirationTime) { + for ( + findHighestPriorityRoot(); + null !== nextFlushedRoot && + 0 !== nextFlushedExpirationTime && + minExpirationTime <= nextFlushedExpirationTime; - ) - performWorkOnRoot(nextFlushedRoot, nextFlushedExpirationTime, !1), - findHighestPriorityRoot(); - isYieldy && ((callbackExpirationTime = 0), (callbackID = null)); + ) + performWorkOnRoot(nextFlushedRoot, nextFlushedExpirationTime, !1), + findHighestPriorityRoot(); 0 !== nextFlushedExpirationTime && scheduleCallbackWithExpirationTime( nextFlushedRoot, nextFlushedExpirationTime ); + finishRendering(); +} +function finishRendering() { nestedUpdateCount = 0; lastCommittedRootDuringThisBatch = null; - if (null !== completedBatches) - for ( - minExpirationTime = completedBatches, - completedBatches = null, - isYieldy = 0; - isYieldy < minExpirationTime.length; - isYieldy++ - ) { - var batch = minExpirationTime[isYieldy]; + if (null !== completedBatches) { + var batches = completedBatches; + completedBatches = null; + for (var i = 0; i < batches.length; i++) { + var batch = batches[i]; try { batch._onComplete(); } catch (error) { @@ -6856,17 +6798,18 @@ function performWork(minExpirationTime, isYieldy) { ((hasUnhandledError = !0), (unhandledError = error)); } } + } if (hasUnhandledError) - throw ((minExpirationTime = unhandledError), + throw ((batches = unhandledError), (unhandledError = null), (hasUnhandledError = !1), - minExpirationTime); + batches); } function performWorkOnRoot(root, expirationTime, isYieldy) { - invariant( - !isRendering, - "performWorkOnRoot was called recursively. This error is likely caused by a bug in React. Please file an issue." - ); + if (isRendering) + throw ReactError( + "performWorkOnRoot was called recursively. This error is likely caused by a bug in React. Please file an issue." + ); isRendering = !0; if (isYieldy) { var _finishedWork = root.finishedWork; @@ -6879,7 +6822,7 @@ function performWorkOnRoot(root, expirationTime, isYieldy) { renderRoot(root, isYieldy), (_finishedWork = root.finishedWork), null !== _finishedWork && - (shouldYieldToRenderer() + (shouldYield$1() ? (root.finishedWork = _finishedWork) : completeRoot$1(root, _finishedWork, expirationTime))); } else @@ -6914,46 +6857,81 @@ function completeRoot$1(root, finishedWork, expirationTime) { root === lastCommittedRootDuringThisBatch ? nestedUpdateCount++ : ((lastCommittedRootDuringThisBatch = root), (nestedUpdateCount = 0)); - scheduler.unstable_runWithPriority( - scheduler.unstable_ImmediatePriority, - function() { - commitRoot(root, finishedWork); - } - ); + commitRoot(root, finishedWork); } -function onUncaughtError(error) { - invariant( - null !== nextFlushedRoot, - "Should be working on a root. This error is likely caused by a bug in React. Please file an issue." - ); +function onUncaughtError$1(error) { + if (null === nextFlushedRoot) + throw ReactError( + "Should be working on a root. This error is likely caused by a bug in React. Please file an issue." + ); nextFlushedRoot.expirationTime = 0; hasUnhandledError || ((hasUnhandledError = !0), (unhandledError = error)); } +Scheduler_now(); +var requestCurrentTime$$1 = requestCurrentTime$1, + computeExpirationForFiber$$1 = computeExpirationForFiber$1, + captureCommitPhaseError$$1 = captureCommitPhaseError$1, + onUncaughtError$$1 = onUncaughtError$1; +function pingSuspendedRoot$$1(root, thenable, pingTime) { + var pingCache = root.pingCache; + null !== pingCache && pingCache.delete(thenable); + if (null !== nextRoot && nextRenderExpirationTime === pingTime) + nextRoot = null; + else if ( + ((thenable = root.earliestSuspendedTime), + (pingCache = root.latestSuspendedTime), + 0 !== thenable && pingTime <= thenable && pingTime >= pingCache) + ) { + root.didError = !1; + thenable = root.latestPingedTime; + if (0 === thenable || thenable > pingTime) root.latestPingedTime = pingTime; + findNextExpirationTimeToWorkOn(pingTime, root); + pingTime = root.expirationTime; + 0 !== pingTime && requestWork(root, pingTime); + } +} +function resolveRetryThenable$$1(boundaryFiber, thenable) { + var retryCache = boundaryFiber.stateNode; + null !== retryCache && retryCache.delete(thenable); + thenable = requestCurrentTime$1(); + thenable = computeExpirationForFiber$1(thenable, boundaryFiber); + boundaryFiber = scheduleWorkToRoot(boundaryFiber, thenable); + null !== boundaryFiber && + (markPendingPriorityLevel(boundaryFiber, thenable), + (thenable = boundaryFiber.expirationTime), + 0 !== thenable && requestWork(boundaryFiber, thenable)); +} +var isAlreadyFailedLegacyErrorBoundary$$1 = isAlreadyFailedLegacyErrorBoundary$1, + scheduleWork$$1 = scheduleWork$1, + flushPassiveEffects$$1 = flushPassiveEffects$1; function findHostInstance(component) { var fiber = component._reactInternalFiber; - void 0 === fiber && - ("function" === typeof component.render - ? invariant(!1, "Unable to find node on an unmounted component.") - : invariant( - !1, - "Argument appears to not be a ReactComponent. Keys: %s", - Object.keys(component) - )); + if (void 0 === fiber) { + if ("function" === typeof component.render) + throw ReactError("Unable to find node on an unmounted component."); + throw ReactError( + "Argument appears to not be a ReactComponent. Keys: " + + Object.keys(component) + ); + } component = findCurrentHostFiber(fiber); return null === component ? null : component.stateNode; } function updateContainer(element, container, parentComponent, callback) { var current$$1 = container.current, - currentTime = requestCurrentTime(); - current$$1 = computeExpirationForFiber(currentTime, current$$1); + currentTime = requestCurrentTime$$1(); + current$$1 = computeExpirationForFiber$$1(currentTime, current$$1); currentTime = container.current; a: if (parentComponent) { parentComponent = parentComponent._reactInternalFiber; b: { - invariant( - 2 === isFiberMountedImpl(parentComponent) && 1 === parentComponent.tag, - "Expected subtree parent to be a mounted class component. This error is likely caused by a bug in React. Please file an issue." - ); + if ( + 2 !== isFiberMountedImpl(parentComponent) || + 1 !== parentComponent.tag + ) + throw ReactError( + "Expected subtree parent to be a mounted class component. This error is likely caused by a bug in React. Please file an issue." + ); var parentContext = parentComponent; do { switch (parentContext.tag) { @@ -6970,11 +6948,9 @@ function updateContainer(element, container, parentComponent, callback) { } parentContext = parentContext.return; } while (null !== parentContext); - invariant( - !1, + throw ReactError( "Found unexpected detached subtree parent. This error is likely caused by a bug in React. Please file an issue." ); - parentContext = void 0; } if (1 === parentComponent.tag) { var Component = parentComponent.type; @@ -6997,9 +6973,9 @@ function updateContainer(element, container, parentComponent, callback) { callback.payload = { element: element }; container = void 0 === container ? null : container; null !== container && (callback.callback = container); - flushPassiveEffects(); + flushPassiveEffects$$1(); enqueueUpdate(currentTime, callback); - scheduleWork(currentTime, current$$1); + scheduleWork$$1(currentTime, current$$1); return current$$1; } function createPortal(children, containerInfo, implementation) { @@ -7034,7 +7010,9 @@ function _inherits(subClass, superClass) { } var getInspectorDataForViewTag = void 0; getInspectorDataForViewTag = function() { - invariant(!1, "getInspectorDataForViewTag() is not available in production"); + throw ReactError( + "getInspectorDataForViewTag() is not available in production" + ); }; function findNodeHandle(componentOrHandle) { if (null == componentOrHandle) return null; @@ -7057,13 +7035,13 @@ _batchedUpdatesImpl = function(fn, a) { } finally { (isBatchingUpdates = previousIsBatchingUpdates) || isRendering || - performWork(1073741823, !1); + performWork(1073741823); } }; _flushInteractiveUpdatesImpl = function() { isRendering || 0 === lowestPriorityPendingInteractiveExpirationTime || - (performWork(lowestPriorityPendingInteractiveExpirationTime, !1), + (performWork(lowestPriorityPendingInteractiveExpirationTime), (lowestPriorityPendingInteractiveExpirationTime = 0)); }; var roots = new Map(), @@ -7091,47 +7069,81 @@ var roots = new Map(), TextInputState.focusTextInput(findNodeHandle(this)); }; ReactNativeComponent.prototype.measure = function(callback) { - UIManager.measure( - findNodeHandle(this), - mountSafeCallback_NOT_REALLY_SAFE(this, callback) - ); + var maybeInstance = void 0; + try { + maybeInstance = findHostInstance(this); + } catch (error) {} + null != maybeInstance && + (maybeInstance.canonical + ? FabricUIManager.measure( + maybeInstance.node, + mountSafeCallback_NOT_REALLY_SAFE(this, callback) + ) + : UIManager.measure( + findNodeHandle(this), + mountSafeCallback_NOT_REALLY_SAFE(this, callback) + )); }; ReactNativeComponent.prototype.measureInWindow = function(callback) { - UIManager.measureInWindow( - findNodeHandle(this), - mountSafeCallback_NOT_REALLY_SAFE(this, callback) - ); + var maybeInstance = void 0; + try { + maybeInstance = findHostInstance(this); + } catch (error) {} + null != maybeInstance && + (maybeInstance.canonical + ? FabricUIManager.measureInWindow( + maybeInstance.node, + mountSafeCallback_NOT_REALLY_SAFE(this, callback) + ) + : UIManager.measureInWindow( + findNodeHandle(this), + mountSafeCallback_NOT_REALLY_SAFE(this, callback) + )); }; ReactNativeComponent.prototype.measureLayout = function( relativeToNativeNode, onSuccess, onFail ) { - UIManager.measureLayout( - findNodeHandle(this), - relativeToNativeNode, - mountSafeCallback_NOT_REALLY_SAFE(this, onFail), - mountSafeCallback_NOT_REALLY_SAFE(this, onSuccess) - ); + var maybeInstance = void 0; + try { + maybeInstance = findHostInstance(this); + } catch (error) {} + null == maybeInstance || + maybeInstance.canonical || + ((maybeInstance = void 0), + "number" === typeof relativeToNativeNode + ? (maybeInstance = relativeToNativeNode) + : relativeToNativeNode._nativeTag && + (maybeInstance = relativeToNativeNode._nativeTag), + null != maybeInstance && + UIManager.measureLayout( + findNodeHandle(this), + maybeInstance, + mountSafeCallback_NOT_REALLY_SAFE(this, onFail), + mountSafeCallback_NOT_REALLY_SAFE(this, onSuccess) + )); }; ReactNativeComponent.prototype.setNativeProps = function(nativeProps) { var maybeInstance = void 0; try { maybeInstance = findHostInstance(this); } catch (error) {} - if (null != maybeInstance) { - var viewConfig = + if (null != maybeInstance && !maybeInstance.canonical) { + var nativeTag = + maybeInstance._nativeTag || maybeInstance.canonical._nativeTag; + maybeInstance = maybeInstance.viewConfig || maybeInstance.canonical.viewConfig; nativeProps = diffProperties( null, emptyObject, nativeProps, - viewConfig.validAttributes + maybeInstance.validAttributes ); null != nativeProps && UIManager.updateView( - maybeInstance._nativeTag, - viewConfig.uiViewClassName, + nativeTag, + maybeInstance.uiViewClassName, nativeProps ); } @@ -7140,38 +7152,16 @@ var roots = new Map(), })(React.Component); })(findNodeHandle, findHostInstance), findNodeHandle: findNodeHandle, + setNativeProps: function() {}, render: function(element, containerTag, callback) { var root = roots.get(containerTag); if (!root) { - root = 0; - isDevToolsPresent && (root |= 4); - root = createFiber(3, null, null, root); - var root$jscomp$0 = { - current: root, - containerInfo: containerTag, - pendingChildren: null, - earliestPendingTime: 0, - latestPendingTime: 0, - earliestSuspendedTime: 0, - latestSuspendedTime: 0, - latestPingedTime: 0, - pingCache: null, - didError: !1, - pendingCommitExpirationTime: 0, - finishedWork: null, - timeoutHandle: -1, - context: null, - pendingContext: null, - hydrate: !1, - nextExpirationTimeToWorkOn: 0, - expirationTime: 0, - firstBatch: null, - nextScheduledRoot: null, - interactionThreadID: tracing.unstable_getThreadID(), - memoizedInteractions: new Set(), - pendingInteractionMap: new Map() - }; - root = root.stateNode = root$jscomp$0; + root = new FiberRootNode(containerTag, !1); + var uninitializedFiber = 0; + isDevToolsPresent && (uninitializedFiber |= 4); + uninitializedFiber = createFiber(3, null, null, uninitializedFiber); + root.current = uninitializedFiber; + uninitializedFiber.stateNode = root; roots.set(containerTag, root); } updateContainer(element, root, null, callback); @@ -7205,42 +7195,77 @@ var roots = new Map(), NativeMethodsMixin: (function(findNodeHandle, findHostInstance) { return { measure: function(callback) { - UIManager.measure( - findNodeHandle(this), - mountSafeCallback_NOT_REALLY_SAFE(this, callback) - ); + var maybeInstance = void 0; + try { + maybeInstance = findHostInstance(this); + } catch (error) {} + null != maybeInstance && + (maybeInstance.canonical + ? FabricUIManager.measure( + maybeInstance.node, + mountSafeCallback_NOT_REALLY_SAFE(this, callback) + ) + : UIManager.measure( + findNodeHandle(this), + mountSafeCallback_NOT_REALLY_SAFE(this, callback) + )); }, measureInWindow: function(callback) { - UIManager.measureInWindow( - findNodeHandle(this), - mountSafeCallback_NOT_REALLY_SAFE(this, callback) - ); + var maybeInstance = void 0; + try { + maybeInstance = findHostInstance(this); + } catch (error) {} + null != maybeInstance && + (maybeInstance.canonical + ? FabricUIManager.measureInWindow( + maybeInstance.node, + mountSafeCallback_NOT_REALLY_SAFE(this, callback) + ) + : UIManager.measureInWindow( + findNodeHandle(this), + mountSafeCallback_NOT_REALLY_SAFE(this, callback) + )); }, measureLayout: function(relativeToNativeNode, onSuccess, onFail) { - UIManager.measureLayout( - findNodeHandle(this), - relativeToNativeNode, - mountSafeCallback_NOT_REALLY_SAFE(this, onFail), - mountSafeCallback_NOT_REALLY_SAFE(this, onSuccess) - ); + var maybeInstance = void 0; + try { + maybeInstance = findHostInstance(this); + } catch (error) {} + null == maybeInstance || + maybeInstance.canonical || + ((maybeInstance = void 0), + "number" === typeof relativeToNativeNode + ? (maybeInstance = relativeToNativeNode) + : relativeToNativeNode._nativeTag && + (maybeInstance = relativeToNativeNode._nativeTag), + null != maybeInstance && + UIManager.measureLayout( + findNodeHandle(this), + maybeInstance, + mountSafeCallback_NOT_REALLY_SAFE(this, onFail), + mountSafeCallback_NOT_REALLY_SAFE(this, onSuccess) + )); }, setNativeProps: function(nativeProps) { var maybeInstance = void 0; try { maybeInstance = findHostInstance(this); } catch (error) {} - if (null != maybeInstance) { - var viewConfig = maybeInstance.viewConfig; + if (null != maybeInstance && !maybeInstance.canonical) { + var nativeTag = + maybeInstance._nativeTag || maybeInstance.canonical._nativeTag; + maybeInstance = + maybeInstance.viewConfig || maybeInstance.canonical.viewConfig; nativeProps = diffProperties( null, emptyObject, nativeProps, - viewConfig.validAttributes + maybeInstance.validAttributes ); null != nativeProps && UIManager.updateView( - maybeInstance._nativeTag, - viewConfig.uiViewClassName, + nativeTag, + maybeInstance.uiViewClassName, nativeProps ); } @@ -7259,7 +7284,10 @@ var roots = new Map(), var findFiberByHostInstance = devToolsConfig.findFiberByHostInstance; return injectInternals( Object.assign({}, devToolsConfig, { + overrideHookState: null, overrideProps: null, + setSuspenseHandler: null, + scheduleUpdate: null, currentDispatcherRef: ReactSharedInternals.ReactCurrentDispatcher, findHostInstanceByFiber: function(fiber) { fiber = findCurrentHostFiber(fiber); @@ -7276,7 +7304,7 @@ var roots = new Map(), findFiberByHostInstance: getInstanceFromInstance, getInspectorDataForViewTag: getInspectorDataForViewTag, bundleType: 0, - version: "16.8.1", + version: "16.8.6", rendererPackageName: "react-native-renderer" }); var ReactFabric$2 = { default: ReactFabric }, diff --git a/Libraries/Renderer/oss/ReactNativeRenderer-dev.js b/Libraries/Renderer/oss/ReactNativeRenderer-dev.js index 5dad5a29b88266..dad23916a514c2 100644 --- a/Libraries/Renderer/oss/ReactNativeRenderer-dev.js +++ b/Libraries/Renderer/oss/ReactNativeRenderer-dev.js @@ -26,9 +26,20 @@ var deepDiffer = require("deepDiffer"); var flattenStyle = require("flattenStyle"); var TextInputState = require("TextInputState"); var checkPropTypes = require("prop-types/checkPropTypes"); +var Scheduler = require("scheduler"); var tracing = require("scheduler/tracing"); -var scheduler = require("scheduler"); var ExceptionsManager = require("ExceptionsManager"); +var FabricUIManager = require("FabricUIManager"); + +// Do not require this module directly! Use a normal error constructor with +// template literal strings. The messages will be converted to ReactError during +// build, and in production they will be minified. + +function ReactError(message) { + var error = new Error(message); + error.name = "Invariant Violation"; + return error; +} /** * Use invariant() to assert state which your program assumes to be true. @@ -41,39 +52,237 @@ var ExceptionsManager = require("ExceptionsManager"); * will remain to ensure logic does not differ in production. */ -var validateFormat = function() {}; +/** + * Injectable ordering of event plugins. + */ +var eventPluginOrder = null; -{ - validateFormat = function(format) { - if (format === undefined) { - throw new Error("invariant requires an error message argument"); +/** + * Injectable mapping from names to event plugin modules. + */ +var namesToPlugins = {}; + +/** + * Recomputes the plugin list using the injected plugins and plugin ordering. + * + * @private + */ +function recomputePluginOrdering() { + if (!eventPluginOrder) { + // Wait until an `eventPluginOrder` is injected. + return; + } + for (var pluginName in namesToPlugins) { + var pluginModule = namesToPlugins[pluginName]; + var pluginIndex = eventPluginOrder.indexOf(pluginName); + (function() { + if (!(pluginIndex > -1)) { + throw ReactError( + "EventPluginRegistry: Cannot inject event plugins that do not exist in the plugin ordering, `" + + pluginName + + "`." + ); + } + })(); + if (plugins[pluginIndex]) { + continue; } - }; + (function() { + if (!pluginModule.extractEvents) { + throw ReactError( + "EventPluginRegistry: Event plugins must implement an `extractEvents` method, but `" + + pluginName + + "` does not." + ); + } + })(); + plugins[pluginIndex] = pluginModule; + var publishedEvents = pluginModule.eventTypes; + for (var eventName in publishedEvents) { + (function() { + if ( + !publishEventForPlugin( + publishedEvents[eventName], + pluginModule, + eventName + ) + ) { + throw ReactError( + "EventPluginRegistry: Failed to publish event `" + + eventName + + "` for plugin `" + + pluginName + + "`." + ); + } + })(); + } + } } -function invariant(condition, format, a, b, c, d, e, f) { - validateFormat(format); +/** + * Publishes an event so that it can be dispatched by the supplied plugin. + * + * @param {object} dispatchConfig Dispatch configuration for the event. + * @param {object} PluginModule Plugin publishing the event. + * @return {boolean} True if the event was successfully published. + * @private + */ +function publishEventForPlugin(dispatchConfig, pluginModule, eventName) { + (function() { + if (!!eventNameDispatchConfigs.hasOwnProperty(eventName)) { + throw ReactError( + "EventPluginHub: More than one plugin attempted to publish the same event name, `" + + eventName + + "`." + ); + } + })(); + eventNameDispatchConfigs[eventName] = dispatchConfig; - if (!condition) { - var error = void 0; - if (format === undefined) { - error = new Error( - "Minified exception occurred; use the non-minified dev environment " + - "for the full error message and additional helpful warnings." + var phasedRegistrationNames = dispatchConfig.phasedRegistrationNames; + if (phasedRegistrationNames) { + for (var phaseName in phasedRegistrationNames) { + if (phasedRegistrationNames.hasOwnProperty(phaseName)) { + var phasedRegistrationName = phasedRegistrationNames[phaseName]; + publishRegistrationName( + phasedRegistrationName, + pluginModule, + eventName + ); + } + } + return true; + } else if (dispatchConfig.registrationName) { + publishRegistrationName( + dispatchConfig.registrationName, + pluginModule, + eventName + ); + return true; + } + return false; +} + +/** + * Publishes a registration name that is used to identify dispatched events. + * + * @param {string} registrationName Registration name to add. + * @param {object} PluginModule Plugin publishing the event. + * @private + */ +function publishRegistrationName(registrationName, pluginModule, eventName) { + (function() { + if (!!registrationNameModules[registrationName]) { + throw ReactError( + "EventPluginHub: More than one plugin attempted to publish the same registration name, `" + + registrationName + + "`." ); - } else { - var args = [a, b, c, d, e, f]; - var argIndex = 0; - error = new Error( - format.replace(/%s/g, function() { - return args[argIndex++]; - }) + } + })(); + registrationNameModules[registrationName] = pluginModule; + registrationNameDependencies[registrationName] = + pluginModule.eventTypes[eventName].dependencies; + + { + var lowerCasedName = registrationName.toLowerCase(); + } +} + +/** + * Registers plugins so that they can extract and dispatch events. + * + * @see {EventPluginHub} + */ + +/** + * Ordered list of injected plugins. + */ +var plugins = []; + +/** + * Mapping from event name to dispatch config + */ +var eventNameDispatchConfigs = {}; + +/** + * Mapping from registration name to plugin module + */ +var registrationNameModules = {}; + +/** + * Mapping from registration name to event name + */ +var registrationNameDependencies = {}; + +/** + * Mapping from lowercase registration names to the properly cased version, + * used to warn in the case of missing event handlers. Available + * only in true. + * @type {Object} + */ + +// Trust the developer to only use possibleRegistrationNames in true + +/** + * Injects an ordering of plugins (by plugin name). This allows the ordering + * to be decoupled from injection of the actual plugins so that ordering is + * always deterministic regardless of packaging, on-the-fly injection, etc. + * + * @param {array} InjectedEventPluginOrder + * @internal + * @see {EventPluginHub.injection.injectEventPluginOrder} + */ +function injectEventPluginOrder(injectedEventPluginOrder) { + (function() { + if (!!eventPluginOrder) { + throw ReactError( + "EventPluginRegistry: Cannot inject event plugin ordering more than once. You are likely trying to load more than one copy of React." ); - error.name = "Invariant Violation"; } + })(); + // Clone the ordering so it cannot be dynamically mutated. + eventPluginOrder = Array.prototype.slice.call(injectedEventPluginOrder); + recomputePluginOrdering(); +} - error.framesToPop = 1; // we don't care about invariant's own frame - throw error; +/** + * Injects plugins to be used by `EventPluginHub`. The plugin names must be + * in the ordering injected by `injectEventPluginOrder`. + * + * Plugins can be injected as part of page initialization or on-the-fly. + * + * @param {object} injectedNamesToPlugins Map from names to plugin modules. + * @internal + * @see {EventPluginHub.injection.injectEventPluginsByName} + */ +function injectEventPluginsByName(injectedNamesToPlugins) { + var isOrderingDirty = false; + for (var pluginName in injectedNamesToPlugins) { + if (!injectedNamesToPlugins.hasOwnProperty(pluginName)) { + continue; + } + var pluginModule = injectedNamesToPlugins[pluginName]; + if ( + !namesToPlugins.hasOwnProperty(pluginName) || + namesToPlugins[pluginName] !== pluginModule + ) { + (function() { + if (!!namesToPlugins[pluginName]) { + throw ReactError( + "EventPluginRegistry: Cannot inject two different event plugins using the same name, `" + + pluginName + + "`." + ); + } + })(); + namesToPlugins[pluginName] = pluginModule; + isOrderingDirty = true; + } + } + if (isOrderingDirty) { + recomputePluginOrdering(); } } @@ -141,16 +350,13 @@ var invokeGuardedCallbackImpl = function( // when we call document.createEvent(). However this can cause confusing // errors: https://github.com/facebookincubator/create-react-app/issues/3482 // So we preemptively throw with a better message instead. - invariant( - typeof document !== "undefined", - "The `document` global was defined when React was initialized, but is not " + - "defined anymore. This can happen in a test environment if a component " + - "schedules an update from an asynchronous callback, but the test has already " + - "finished running. To solve this, you can either unmount the component at " + - "the end of your test (and ensure that any asynchronous operations get " + - "canceled in `componentWillUnmount`), or you can change the test itself " + - "to be asynchronous." - ); + (function() { + if (!(typeof document !== "undefined")) { + throw ReactError( + "The `document` global was defined when React was initialized, but is not defined anymore. This can happen in a test environment if a component schedules an update from an asynchronous callback, but the test has already finished running. To solve this, you can either unmount the component at the end of your test (and ensure that any asynchronous operations get canceled in `componentWillUnmount`), or you can change the test itself to be asynchronous." + ); + } + })(); var evt = document.createEvent("Event"); // Keeps track of whether the user-provided callback threw an error. We @@ -373,249 +579,41 @@ function clearCaughtError() { caughtError = null; return error; } else { - invariant( - false, - "clearCaughtError was called but no error was captured. This error " + - "is likely caused by a bug in React. Please file an issue." - ); + (function() { + { + throw ReactError( + "clearCaughtError was called but no error was captured. This error is likely caused by a bug in React. Please file an issue." + ); + } + })(); } } /** - * Injectable ordering of event plugins. + * Similar to invariant but only logs a warning if the condition is not met. + * This can be used to log issues in development environments in critical + * paths. Removing the logging code for production environments will keep the + * same logic and follow the same code paths. */ -var eventPluginOrder = null; -/** - * Injectable mapping from names to event plugin modules. - */ -var namesToPlugins = {}; +var warningWithoutStack = function() {}; -/** - * Recomputes the plugin list using the injected plugins and plugin ordering. - * - * @private - */ -function recomputePluginOrdering() { - if (!eventPluginOrder) { - // Wait until an `eventPluginOrder` is injected. - return; - } - for (var pluginName in namesToPlugins) { - var pluginModule = namesToPlugins[pluginName]; - var pluginIndex = eventPluginOrder.indexOf(pluginName); - invariant( - pluginIndex > -1, - "EventPluginRegistry: Cannot inject event plugins that do not exist in " + - "the plugin ordering, `%s`.", - pluginName - ); - if (plugins[pluginIndex]) { - continue; +{ + warningWithoutStack = function(condition, format) { + for ( + var _len = arguments.length, + args = Array(_len > 2 ? _len - 2 : 0), + _key = 2; + _key < _len; + _key++ + ) { + args[_key - 2] = arguments[_key]; } - invariant( - pluginModule.extractEvents, - "EventPluginRegistry: Event plugins must implement an `extractEvents` " + - "method, but `%s` does not.", - pluginName - ); - plugins[pluginIndex] = pluginModule; - var publishedEvents = pluginModule.eventTypes; - for (var eventName in publishedEvents) { - invariant( - publishEventForPlugin( - publishedEvents[eventName], - pluginModule, - eventName - ), - "EventPluginRegistry: Failed to publish event `%s` for plugin `%s`.", - eventName, - pluginName - ); - } - } -} - -/** - * Publishes an event so that it can be dispatched by the supplied plugin. - * - * @param {object} dispatchConfig Dispatch configuration for the event. - * @param {object} PluginModule Plugin publishing the event. - * @return {boolean} True if the event was successfully published. - * @private - */ -function publishEventForPlugin(dispatchConfig, pluginModule, eventName) { - invariant( - !eventNameDispatchConfigs.hasOwnProperty(eventName), - "EventPluginHub: More than one plugin attempted to publish the same " + - "event name, `%s`.", - eventName - ); - eventNameDispatchConfigs[eventName] = dispatchConfig; - - var phasedRegistrationNames = dispatchConfig.phasedRegistrationNames; - if (phasedRegistrationNames) { - for (var phaseName in phasedRegistrationNames) { - if (phasedRegistrationNames.hasOwnProperty(phaseName)) { - var phasedRegistrationName = phasedRegistrationNames[phaseName]; - publishRegistrationName( - phasedRegistrationName, - pluginModule, - eventName - ); - } - } - return true; - } else if (dispatchConfig.registrationName) { - publishRegistrationName( - dispatchConfig.registrationName, - pluginModule, - eventName - ); - return true; - } - return false; -} - -/** - * Publishes a registration name that is used to identify dispatched events. - * - * @param {string} registrationName Registration name to add. - * @param {object} PluginModule Plugin publishing the event. - * @private - */ -function publishRegistrationName(registrationName, pluginModule, eventName) { - invariant( - !registrationNameModules[registrationName], - "EventPluginHub: More than one plugin attempted to publish the same " + - "registration name, `%s`.", - registrationName - ); - registrationNameModules[registrationName] = pluginModule; - registrationNameDependencies[registrationName] = - pluginModule.eventTypes[eventName].dependencies; - - { - var lowerCasedName = registrationName.toLowerCase(); - } -} - -/** - * Registers plugins so that they can extract and dispatch events. - * - * @see {EventPluginHub} - */ - -/** - * Ordered list of injected plugins. - */ -var plugins = []; - -/** - * Mapping from event name to dispatch config - */ -var eventNameDispatchConfigs = {}; - -/** - * Mapping from registration name to plugin module - */ -var registrationNameModules = {}; - -/** - * Mapping from registration name to event name - */ -var registrationNameDependencies = {}; - -/** - * Mapping from lowercase registration names to the properly cased version, - * used to warn in the case of missing event handlers. Available - * only in true. - * @type {Object} - */ - -// Trust the developer to only use possibleRegistrationNames in true - -/** - * Injects an ordering of plugins (by plugin name). This allows the ordering - * to be decoupled from injection of the actual plugins so that ordering is - * always deterministic regardless of packaging, on-the-fly injection, etc. - * - * @param {array} InjectedEventPluginOrder - * @internal - * @see {EventPluginHub.injection.injectEventPluginOrder} - */ -function injectEventPluginOrder(injectedEventPluginOrder) { - invariant( - !eventPluginOrder, - "EventPluginRegistry: Cannot inject event plugin ordering more than " + - "once. You are likely trying to load more than one copy of React." - ); - // Clone the ordering so it cannot be dynamically mutated. - eventPluginOrder = Array.prototype.slice.call(injectedEventPluginOrder); - recomputePluginOrdering(); -} - -/** - * Injects plugins to be used by `EventPluginHub`. The plugin names must be - * in the ordering injected by `injectEventPluginOrder`. - * - * Plugins can be injected as part of page initialization or on-the-fly. - * - * @param {object} injectedNamesToPlugins Map from names to plugin modules. - * @internal - * @see {EventPluginHub.injection.injectEventPluginsByName} - */ -function injectEventPluginsByName(injectedNamesToPlugins) { - var isOrderingDirty = false; - for (var pluginName in injectedNamesToPlugins) { - if (!injectedNamesToPlugins.hasOwnProperty(pluginName)) { - continue; - } - var pluginModule = injectedNamesToPlugins[pluginName]; - if ( - !namesToPlugins.hasOwnProperty(pluginName) || - namesToPlugins[pluginName] !== pluginModule - ) { - invariant( - !namesToPlugins[pluginName], - "EventPluginRegistry: Cannot inject two different event plugins " + - "using the same name, `%s`.", - pluginName - ); - namesToPlugins[pluginName] = pluginModule; - isOrderingDirty = true; - } - } - if (isOrderingDirty) { - recomputePluginOrdering(); - } -} - -/** - * Similar to invariant but only logs a warning if the condition is not met. - * This can be used to log issues in development environments in critical - * paths. Removing the logging code for production environments will keep the - * same logic and follow the same code paths. - */ - -var warningWithoutStack = function() {}; - -{ - warningWithoutStack = function(condition, format) { - for ( - var _len = arguments.length, - args = Array(_len > 2 ? _len - 2 : 0), - _key = 2; - _key < _len; - _key++ - ) { - args[_key - 2] = arguments[_key]; - } - - if (format === undefined) { - throw new Error( - "`warningWithoutStack(condition, format, ...args)` requires a warning " + - "message argument" + + if (format === undefined) { + throw new Error( + "`warningWithoutStack(condition, format, ...args)` requires a warning " + + "message argument" ); } if (args.length > 8) { @@ -796,10 +794,11 @@ function executeDirectDispatch(event) { } var dispatchListener = event._dispatchListeners; var dispatchInstance = event._dispatchInstances; - invariant( - !Array.isArray(dispatchListener), - "executeDirectDispatch(...): Invalid `event`." - ); + (function() { + if (!!Array.isArray(dispatchListener)) { + throw ReactError("executeDirectDispatch(...): Invalid `event`."); + } + })(); event.currentTarget = dispatchListener ? getNodeFromInstance(dispatchInstance) : null; @@ -832,10 +831,13 @@ function hasDispatches(event) { */ function accumulateInto(current, next) { - invariant( - next != null, - "accumulateInto(...): Accumulated items must not be null or undefined." - ); + (function() { + if (!(next != null)) { + throw ReactError( + "accumulateInto(...): Accumulated items must not be null or undefined." + ); + } + })(); if (current == null) { return next; @@ -902,6 +904,32 @@ var executeDispatchesAndReleaseTopLevel = function(e) { return executeDispatchesAndRelease(e); }; +function runEventsInBatch(events) { + if (events !== null) { + eventQueue = accumulateInto(eventQueue, events); + } + + // Set `eventQueue` to null before processing it so that we can tell if more + // events get enqueued while processing. + var processingEventQueue = eventQueue; + eventQueue = null; + + if (!processingEventQueue) { + return; + } + + forEachAccumulated(processingEventQueue, executeDispatchesAndReleaseTopLevel); + (function() { + if (!!eventQueue) { + throw ReactError( + "processEventQueue(): Additional events were enqueued while processing an event queue. Support for this has not yet been implemented." + ); + } + })(); + // This would be a good time to rethrow if any of the event handlers threw. + rethrowCaughtError(); +} + function isInteractive(tag) { return ( tag === "button" || @@ -992,12 +1020,17 @@ function getListener(inst, registrationName) { if (shouldPreventMouseEvent(registrationName, inst.type, props)) { return null; } - invariant( - !listener || typeof listener === "function", - "Expected `%s` listener to be a function, instead got a value of `%s` type.", - registrationName, - typeof listener - ); + (function() { + if (!(!listener || typeof listener === "function")) { + throw ReactError( + "Expected `" + + registrationName + + "` listener to be a function, instead got a value of `" + + typeof listener + + "` type." + ); + } + })(); return listener; } @@ -1008,7 +1041,7 @@ function getListener(inst, registrationName) { * @return {*} An accumulation of synthetic events. * @internal */ -function extractEvents( +function extractPluginEvents( topLevelType, targetInst, nativeEvent, @@ -1033,37 +1066,13 @@ function extractEvents( return events; } -function runEventsInBatch(events) { - if (events !== null) { - eventQueue = accumulateInto(eventQueue, events); - } - - // Set `eventQueue` to null before processing it so that we can tell if more - // events get enqueued while processing. - var processingEventQueue = eventQueue; - eventQueue = null; - - if (!processingEventQueue) { - return; - } - - forEachAccumulated(processingEventQueue, executeDispatchesAndReleaseTopLevel); - invariant( - !eventQueue, - "processEventQueue(): Additional events were enqueued while processing " + - "an event queue. Support for this has not yet been implemented." - ); - // This would be a good time to rethrow if any of the event handlers threw. - rethrowCaughtError(); -} - -function runExtractedEventsInBatch( +function runExtractedPluginEventsInBatch( topLevelType, targetInst, nativeEvent, nativeEventTarget ) { - var events = extractEvents( + var events = extractPluginEvents( topLevelType, targetInst, nativeEvent, @@ -1090,6 +1099,9 @@ var MemoComponent = 14; var SimpleMemoComponent = 15; var LazyComponent = 16; var IncompleteClassComponent = 17; +var DehydratedSuspenseComponent = 18; +var EventComponent = 19; +var EventTarget = 20; function getParent(inst) { do { @@ -1608,10 +1620,13 @@ function getPooledEvent(dispatchConfig, targetInst, nativeEvent, nativeInst) { function releasePooledEvent(event) { var EventConstructor = this; - invariant( - event instanceof EventConstructor, - "Trying to release an event instance into a pool of a different type." - ); + (function() { + if (!(event instanceof EventConstructor)) { + throw ReactError( + "Trying to release an event instance into a pool of a different type." + ); + } + })(); event.destructor(); if (EventConstructor.eventPool.length < EVENT_POOL_SIZE) { EventConstructor.eventPool.push(event); @@ -1718,7 +1733,11 @@ function resetTouchRecord(touchRecord, touch) { function getTouchIdentifier(_ref) { var identifier = _ref.identifier; - invariant(identifier != null, "Touch object is missing identifier."); + (function() { + if (!(identifier != null)) { + throw ReactError("Touch object is missing identifier."); + } + })(); { !(identifier <= MAX_TOUCH_BANK) ? warningWithoutStack$1( @@ -1846,10 +1865,13 @@ var ResponderTouchHistoryStore = { * @return {*|array<*>} An accumulation of items. */ function accumulate(current, next) { - invariant( - next != null, - "accumulate(...): Accumulated items must be not be null or undefined." - ); + (function() { + if (!(next != null)) { + throw ReactError( + "accumulate(...): Accumulated items must be not be null or undefined." + ); + } + })(); if (current == null) { return next; @@ -2461,11 +2483,13 @@ var ReactNativeBridgeEventPlugin = { ReactNativeViewConfigRegistry.customBubblingEventTypes[topLevelType]; var directDispatchConfig = ReactNativeViewConfigRegistry.customDirectEventTypes[topLevelType]; - invariant( - bubbleDispatchConfig || directDispatchConfig, - 'Unsupported top level event type "%s" dispatched', - topLevelType - ); + (function() { + if (!(bubbleDispatchConfig || directDispatchConfig)) { + throw ReactError( + 'Unsupported top level event type "' + topLevelType + '" dispatched' + ); + } + })(); var event = SyntheticEvent.getPooled( bubbleDispatchConfig || directDispatchConfig, targetInst, @@ -2530,7 +2554,11 @@ function getTagFromInstance(inst) { if (tag === undefined) { tag = inst.stateNode.canonical._nativeTag; } - invariant(tag, "All native instances should have a tag."); + (function() { + if (!tag) { + throw ReactError("All native instances should have a tag."); + } + })(); return tag; } @@ -2556,11 +2584,13 @@ function restoreStateOfTarget(target) { // Unmounted return; } - invariant( - typeof restoreImpl === "function", - "setRestoreImplementation() needs to be called to handle a target for controlled " + - "events. This error is likely caused by a bug in React. Please file an issue." - ); + (function() { + if (!(typeof restoreImpl === "function")) { + throw ReactError( + "setRestoreImplementation() needs to be called to handle a target for controlled events. This error is likely caused by a bug in React. Please file an issue." + ); + } + })(); var props = getFiberCurrentPropsFromNode(internalInstance.stateNode); restoreImpl(internalInstance.stateNode, internalInstance.type, props); } @@ -2703,7 +2733,7 @@ function _receiveRootNodeIDEvent(rootNodeID, topLevelType, nativeEventParam) { var nativeEvent = nativeEventParam || EMPTY_NATIVE_EVENT; var inst = getInstanceFromTag(rootNodeID); batchedUpdates(function() { - runExtractedEventsInBatch( + runExtractedPluginEventsInBatch( topLevelType, inst, nativeEvent, @@ -2872,6 +2902,17 @@ var REACT_FORWARD_REF_TYPE = hasSymbol var REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for("react.suspense") : 0xead1; var REACT_MEMO_TYPE = hasSymbol ? Symbol.for("react.memo") : 0xead3; var REACT_LAZY_TYPE = hasSymbol ? Symbol.for("react.lazy") : 0xead4; +var REACT_EVENT_COMPONENT_TYPE = hasSymbol + ? Symbol.for("react.event_component") + : 0xead5; +var REACT_EVENT_TARGET_TYPE = hasSymbol + ? Symbol.for("react.event_target") + : 0xead6; + +// React event targets +var REACT_EVENT_TARGET_TOUCH_HIT = hasSymbol + ? Symbol.for("react.event_target.touch_hit") + : 0xead7; var MAYBE_ITERATOR_SYMBOL = typeof Symbol === "function" && Symbol.iterator; var FAUX_ITERATOR_SYMBOL = "@@iterator"; @@ -2955,6 +2996,25 @@ function getComponentName(type) { if (resolvedThenable) { return getComponentName(resolvedThenable); } + break; + } + case REACT_EVENT_COMPONENT_TYPE: { + var eventComponent = type; + var displayName = eventComponent.displayName; + if (displayName !== undefined) { + return displayName; + } + break; + } + case REACT_EVENT_TARGET_TYPE: { + var eventTarget = type; + if (eventTarget.type === REACT_EVENT_TARGET_TOUCH_HIT) { + return "TouchHitTarget"; + } + var _displayName = eventTarget.displayName; + if (_displayName !== undefined) { + return _displayName; + } } } } @@ -3054,10 +3114,11 @@ function isMounted(component) { } function assertIsMounted(fiber) { - invariant( - isFiberMountedImpl(fiber) === MOUNTED, - "Unable to find node on an unmounted component." - ); + (function() { + if (!(isFiberMountedImpl(fiber) === MOUNTED)) { + throw ReactError("Unable to find node on an unmounted component."); + } + })(); } function findCurrentFiberUsingSlowPath(fiber) { @@ -3065,10 +3126,11 @@ function findCurrentFiberUsingSlowPath(fiber) { if (!alternate) { // If there is no alternate, then we only need to check if it is mounted. var state = isFiberMountedImpl(fiber); - invariant( - state !== UNMOUNTED, - "Unable to find node on an unmounted component." - ); + (function() { + if (!(state !== UNMOUNTED)) { + throw ReactError("Unable to find node on an unmounted component."); + } + })(); if (state === MOUNTING) { return null; } @@ -3081,11 +3143,24 @@ function findCurrentFiberUsingSlowPath(fiber) { var b = alternate; while (true) { var parentA = a.return; - var parentB = parentA ? parentA.alternate : null; - if (!parentA || !parentB) { + if (parentA === null) { // We're at the root. break; } + var parentB = parentA.alternate; + if (parentB === null) { + // There is no alternate. This is an unusual case. Currently, it only + // happens when a Suspense component is hidden. An extra fragment fiber + // is inserted in between the Suspense fiber and its children. Skip + // over this extra fragment fiber and proceed to the next parent. + var nextParent = parentA.return; + if (nextParent !== null) { + a = b = nextParent; + continue; + } + // If there's no parent, we're at the root. + break; + } // If both copies of the parent fiber point to the same child, we can // assume that the child is current. This happens when we bailout on low @@ -3107,7 +3182,11 @@ function findCurrentFiberUsingSlowPath(fiber) { } // We should never have an alternate for any mounting node. So the only // way this could possibly happen is if this was unmounted, if at all. - invariant(false, "Unable to find node on an unmounted component."); + (function() { + { + throw ReactError("Unable to find node on an unmounted component."); + } + })(); } if (a.return !== b.return) { @@ -3158,26 +3237,31 @@ function findCurrentFiberUsingSlowPath(fiber) { } _child = _child.sibling; } - invariant( - didFindChild, - "Child was not found in either parent set. This indicates a bug " + - "in React related to the return pointer. Please file an issue." - ); + (function() { + if (!didFindChild) { + throw ReactError( + "Child was not found in either parent set. This indicates a bug in React related to the return pointer. Please file an issue." + ); + } + })(); } } - invariant( - a.alternate === b, - "Return fibers should always be each others' alternates. " + - "This error is likely caused by a bug in React. Please file an issue." - ); + (function() { + if (!(a.alternate === b)) { + throw ReactError( + "Return fibers should always be each others' alternates. This error is likely caused by a bug in React. Please file an issue." + ); + } + })(); } // If the root is not a host container, we're in a disconnected tree. I.e. // unmounted. - invariant( - a.tag === HostRoot, - "Unable to find node on an unmounted component." - ); + (function() { + if (!(a.tag === HostRoot)) { + throw ReactError("Unable to find node on an unmounted component."); + } + })(); if (a.stateNode.current === a) { // We've determined that A is the current branch. return fiber; @@ -3724,6 +3808,23 @@ function warnForStyleProps(props, validAttributes) { } } +var debugRenderPhaseSideEffects = false; +var debugRenderPhaseSideEffectsForStrictMode = false; +var enableUserTimingAPI = true; +var replayFailedUnitOfWorkWithInvokeGuardedCallback = true; +var warnAboutDeprecatedLifecycles = true; +var enableProfilerTimer = true; +var enableSchedulerTracing = true; +var enableSuspenseServerRenderer = false; + +var disableYielding = false; + +var warnAboutDeprecatedSetNativeProps = false; +var enableEventAPI = false; +var enableNewScheduler = false; + +// Only used in www builds. + function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); @@ -3756,14 +3857,16 @@ var ReactNativeFiberHostComponent = (function() { TextInputState.focusTextInput(this._nativeTag); }; - ReactNativeFiberHostComponent.prototype.measure = function measure(callback) { + ReactNativeFiberHostComponent.prototype.measure = function measure$$1( + callback + ) { UIManager.measure( this._nativeTag, mountSafeCallback_NOT_REALLY_SAFE(this, callback) ); }; - ReactNativeFiberHostComponent.prototype.measureInWindow = function measureInWindow( + ReactNativeFiberHostComponent.prototype.measureInWindow = function measureInWindow$$1( callback ) { UIManager.measureInWindow( @@ -3777,9 +3880,32 @@ var ReactNativeFiberHostComponent = (function() { onSuccess, onFail /* currently unused */ ) { + var relativeNode = void 0; + + if (typeof relativeToNativeNode === "number") { + // Already a node handle + relativeNode = relativeToNativeNode; + } else if (relativeToNativeNode._nativeTag) { + relativeNode = relativeToNativeNode._nativeTag; + } else if ( + relativeToNativeNode.canonical && + relativeToNativeNode.canonical._nativeTag + ) { + relativeNode = relativeToNativeNode.canonical._nativeTag; + } + + if (relativeNode == null) { + warningWithoutStack$1( + false, + "Warning: ref.measureLayout must be called with a node handle or a ref to a native component." + ); + + return; + } + UIManager.measureLayout( this._nativeTag, - relativeToNativeNode, + relativeNode, mountSafeCallback_NOT_REALLY_SAFE(this, onFail), mountSafeCallback_NOT_REALLY_SAFE(this, onSuccess) ); @@ -3789,6 +3915,15 @@ var ReactNativeFiberHostComponent = (function() { nativeProps ) { { + if (warnAboutDeprecatedSetNativeProps) { + warningWithoutStack$1( + false, + "Warning: Calling ref.setNativeProps(nativeProps) " + + "is deprecated and will be removed in a future release. " + + "Use the setNativeProps export from the react-native package instead." + + "\n\timport {setNativeProps} from 'react-native';\n\tsetNativeProps(ref, nativeProps);\n" + ); + } warnForStyleProps(nativeProps, this.viewConfig.validAttributes); } @@ -3809,63 +3944,17 @@ var ReactNativeFiberHostComponent = (function() { return ReactNativeFiberHostComponent; })(); -var hasNativePerformanceNow = - typeof performance === "object" && typeof performance.now === "function"; - -var now$1 = hasNativePerformanceNow - ? function() { - return performance.now(); - } - : function() { - return Date.now(); - }; - -var scheduledCallback = null; -var frameDeadline = 0; - -function setTimeoutCallback() { - // TODO (bvaughn) Hard-coded 5ms unblocks initial async testing. - // React API probably changing to boolean rather than time remaining. - // Longer-term plan is to rewrite this using shared memory, - // And just return the value of the bit as the boolean. - frameDeadline = now$1() + 5; - - var callback = scheduledCallback; - scheduledCallback = null; - if (callback !== null) { - callback(); - } -} - -// RN has a poor polyfill for requestIdleCallback so we aren't using it. -// This implementation is only intended for short-term use anyway. -// We also don't implement cancel functionality b'c Fiber doesn't currently need it. -function scheduleDeferredCallback$1(callback, options) { - // We assume only one callback is scheduled at a time b'c that's how Fiber works. - scheduledCallback = callback; - var timeoutId = setTimeout(setTimeoutCallback, 1); - return timeoutId; // Timeouts are always numbers on RN -} - -function cancelDeferredCallback$1(callbackID) { - scheduledCallback = null; - clearTimeout(callbackID); // Timeouts are always numbers on RN -} - -function shouldYield$1() { - return frameDeadline <= now$1(); -} - // Renderers that don't support persistence // can re-export everything from this module. function shim() { - invariant( - false, - "The current renderer does not support persistence. " + - "This error is likely caused by a bug in React. " + - "Please file an issue." - ); + (function() { + { + throw ReactError( + "The current renderer does not support persistence. This error is likely caused by a bug in React. Please file an issue." + ); + } + })(); } // Persistence (when unsupported) @@ -3876,37 +3965,47 @@ var appendChildToContainerChildSet = shim; var finalizeContainerChildren = shim; var replaceContainerChildren = shim; var cloneHiddenInstance = shim; -var cloneUnhiddenInstance = shim; -var createHiddenTextInstance = shim; +var cloneHiddenTextInstance = shim; // Renderers that don't support hydration // can re-export everything from this module. function shim$1() { - invariant( - false, - "The current renderer does not support hydration. " + - "This error is likely caused by a bug in React. " + - "Please file an issue." - ); + (function() { + { + throw ReactError( + "The current renderer does not support hydration. This error is likely caused by a bug in React. Please file an issue." + ); + } + })(); } // Hydration (when unsupported) + var supportsHydration = false; var canHydrateInstance = shim$1; var canHydrateTextInstance = shim$1; +var canHydrateSuspenseInstance = shim$1; +var isSuspenseInstancePending = shim$1; +var isSuspenseInstanceFallback = shim$1; +var registerSuspenseInstanceRetry = shim$1; var getNextHydratableSibling = shim$1; var getFirstHydratableChild = shim$1; var hydrateInstance = shim$1; var hydrateTextInstance = shim$1; +var getNextHydratableInstanceAfterSuspenseInstance = shim$1; +var clearSuspenseBoundary = shim$1; +var clearSuspenseBoundaryFromContainer = shim$1; var didNotMatchHydratedContainerTextInstance = shim$1; var didNotMatchHydratedTextInstance = shim$1; var didNotHydrateContainerInstance = shim$1; var didNotHydrateInstance = shim$1; var didNotFindHydratableContainerInstance = shim$1; var didNotFindHydratableContainerTextInstance = shim$1; +var didNotFindHydratableContainerSuspenseInstance = shim$1; var didNotFindHydratableInstance = shim$1; var didNotFindHydratableTextInstance = shim$1; +var didNotFindHydratableSuspenseInstance = shim$1; // Modules provided by RN: // Unused @@ -3962,10 +4061,13 @@ function createInstance( } } - invariant( - type !== "RCTView" || !hostContext.isInAParentText, - "Nesting of within is not currently supported." - ); + (function() { + if (!(type !== "RCTView" || !hostContext.isInAParentText)) { + throw ReactError( + "Nesting of within is not currently supported." + ); + } + })(); var updatePayload = create(props, viewConfig.validAttributes); @@ -3992,10 +4094,13 @@ function createTextInstance( hostContext, internalInstanceHandle ) { - invariant( - hostContext.isInAParentText, - "Text strings must be rendered within a component." - ); + (function() { + if (!hostContext.isInAParentText) { + throw ReactError( + "Text strings must be rendered within a component." + ); + } + })(); var tag = allocateTag(); @@ -4059,6 +4164,16 @@ function getChildHostContext(parentHostContext, type, rootContainerInstance) { } } +function getChildHostContextForEventComponent(parentHostContext) { + // TODO: add getChildHostContextForEventComponent implementation + return parentHostContext; +} + +function getChildHostContextForEventTarget(parentHostContext, type) { + // TODO: add getChildHostContextForEventTarget implementation + return parentHostContext; +} + function getPublicInstance(instance) { return instance; } @@ -4082,17 +4197,11 @@ function resetAfterCommit(containerInfo) { // Noop } -var now$$1 = now$1; var isPrimaryRenderer = true; -var scheduleDeferredCallback$$1 = scheduleDeferredCallback$1; -var cancelDeferredCallback$$1 = cancelDeferredCallback$1; -var shouldYield$$1 = shouldYield$1; var scheduleTimeout = setTimeout; var cancelTimeout = clearTimeout; var noTimeout = -1; -var schedulePassiveEffects = scheduleDeferredCallback$$1; -var cancelPassiveEffects = cancelDeferredCallback$$1; function shouldDeprioritizeSubtree(type, props) { return false; @@ -4227,10 +4336,11 @@ function insertInContainerBefore(parentInstance, child, beforeChild) { // We create a wrapper object for the container in ReactNative render() // Or we refactor to remove wrapper objects entirely. // For more info on pros/cons see PR #8560 description. - invariant( - typeof parentInstance !== "number", - "Container does not support insertBefore operation" - ); + (function() { + if (!(typeof parentInstance !== "number")) { + throw ReactError("Container does not support insertBefore operation"); + } + })(); } function removeChild(parentInstance, child) { @@ -4301,6 +4411,35 @@ function unhideTextInstance(textInstance, text) { throw new Error("Not yet implemented."); } +function mountEventComponent(eventComponentInstance) { + throw new Error("Not yet implemented."); +} + +function updateEventComponent(eventComponentInstance) { + throw new Error("Not yet implemented."); +} + +function unmountEventComponent(eventComponentInstance) { + throw new Error("Not yet implemented."); +} + +function getEventTargetChildElement(type, props) { + throw new Error("Not yet implemented."); +} + +function handleEventTarget( + type, + props, + rootContainerInstance, + internalInstanceHandle +) { + throw new Error("Not yet implemented."); +} + +function commitEventTarget(type, props, instance, parentInstance) { + throw new Error("Not yet implemented."); +} + var BEFORE_SLASH_RE = /^(.*)[\\\/]/; var describeComponentFrame = function(name, source, ownerName) { @@ -4412,16 +4551,6 @@ function setCurrentPhase(lifeCyclePhase) { } } -var debugRenderPhaseSideEffects = false; -var debugRenderPhaseSideEffectsForStrictMode = false; -var enableUserTimingAPI = true; -var replayFailedUnitOfWorkWithInvokeGuardedCallback = true; -var warnAboutDeprecatedLifecycles = false; -var enableProfilerTimer = true; -var enableSchedulerTracing = true; - -// Only used in www builds. - // Prefix measurements so that it's possible to filter them. // Longer prefixes are hard to read in DevTools. var reactEmoji = "\u269B"; @@ -4693,7 +4822,8 @@ function stopFailedWorkTimer(fiber) { } fiber._debugIsCurrentlyTiming = false; var warning = - fiber.tag === SuspenseComponent + fiber.tag === SuspenseComponent || + fiber.tag === DehydratedSuspenseComponent ? "Rendering was suspended" : "An error was thrown inside this error boundary"; endFiberMark(fiber, null, warning); @@ -5056,11 +5186,13 @@ function popTopLevelContextObject(fiber) { } function pushTopLevelContextObject(fiber, context, didChange) { - invariant( - contextStackCursor.current === emptyContextObject, - "Unexpected context found on stack. " + - "This error is likely caused by a bug in React. Please file an issue." - ); + (function() { + if (!(contextStackCursor.current === emptyContextObject)) { + throw ReactError( + "Unexpected context found on stack. This error is likely caused by a bug in React. Please file an issue." + ); + } + })(); push(contextStackCursor, context, fiber); push(didPerformWorkStackCursor, didChange, fiber); @@ -5102,12 +5234,16 @@ function processChildContext(fiber, type, parentContext) { setCurrentPhase(null); } for (var contextKey in childContext) { - invariant( - contextKey in childContextTypes, - '%s.getChildContext(): key "%s" is not defined in childContextTypes.', - getComponentName(type) || "Unknown", - contextKey - ); + (function() { + if (!(contextKey in childContextTypes)) { + throw ReactError( + (getComponentName(type) || "Unknown") + + '.getChildContext(): key "' + + contextKey + + '" is not defined in childContextTypes.' + ); + } + })(); } { var name = getComponentName(type) || "Unknown"; @@ -5152,11 +5288,13 @@ function pushContextProvider(workInProgress) { function invalidateContextProvider(workInProgress, type, didChange) { var instance = workInProgress.stateNode; - invariant( - instance, - "Expected to have an instance by this point. " + - "This error is likely caused by a bug in React. Please file an issue." - ); + (function() { + if (!instance) { + throw ReactError( + "Expected to have an instance by this point. This error is likely caused by a bug in React. Please file an issue." + ); + } + })(); if (didChange) { // Merge parent and own context. @@ -5185,11 +5323,13 @@ function invalidateContextProvider(workInProgress, type, didChange) { function findCurrentUnmaskedContext(fiber) { // Currently this is only used with renderSubtreeIntoContainer; not sure if it // makes sense elsewhere - invariant( - isFiberMounted(fiber) && fiber.tag === ClassComponent, - "Expected subtree parent to be a mounted class component. " + - "This error is likely caused by a bug in React. Please file an issue." - ); + (function() { + if (!(isFiberMounted(fiber) && fiber.tag === ClassComponent)) { + throw ReactError( + "Expected subtree parent to be a mounted class component. This error is likely caused by a bug in React. Please file an issue." + ); + } + })(); var node = fiber; do { @@ -5206,11 +5346,13 @@ function findCurrentUnmaskedContext(fiber) { } node = node.return; } while (node !== null); - invariant( - false, - "Found unexpected detached subtree parent. " + - "This error is likely caused by a bug in React. Please file an issue." - ); + (function() { + { + throw ReactError( + "Found unexpected detached subtree parent. This error is likely caused by a bug in React. Please file an issue." + ); + } + })(); } var onCommitFiberRoot = null; @@ -5298,14 +5440,166 @@ function onCommitUnmount(fiber) { // Max 31 bit integer. The max integer size in V8 for 32-bit systems. // Math.pow(2, 30) - 1 // 0b111111111111111111111111111111 -var maxSigned31BitInt = 1073741823; +var MAX_SIGNED_31_BIT_INT = 1073741823; + +// Intentionally not named imports because Rollup would use dynamic dispatch for +// CommonJS interop named imports. +var Scheduler_runWithPriority = Scheduler.unstable_runWithPriority; +var Scheduler_scheduleCallback = Scheduler.unstable_scheduleCallback; +var Scheduler_cancelCallback = Scheduler.unstable_cancelCallback; +var Scheduler_shouldYield = Scheduler.unstable_shouldYield; +var Scheduler_now = Scheduler.unstable_now; +var Scheduler_getCurrentPriorityLevel = + Scheduler.unstable_getCurrentPriorityLevel; +var Scheduler_ImmediatePriority = Scheduler.unstable_ImmediatePriority; +var Scheduler_UserBlockingPriority = Scheduler.unstable_UserBlockingPriority; +var Scheduler_NormalPriority = Scheduler.unstable_NormalPriority; +var Scheduler_LowPriority = Scheduler.unstable_LowPriority; +var Scheduler_IdlePriority = Scheduler.unstable_IdlePriority; + +var fakeCallbackNode = {}; + +// Except for NoPriority, these correspond to Scheduler priorities. We use +// ascending numbers so we can compare them like numbers. They start at 90 to +// avoid clashing with Scheduler's priorities. +var ImmediatePriority = 99; +var UserBlockingPriority = 98; +var NormalPriority = 97; +var LowPriority = 96; +var IdlePriority = 95; +// NoPriority is the absence of priority. Also React-only. + +var now = Scheduler_now; +var shouldYield = disableYielding + ? function() { + return false; + } // Never yield when `disableYielding` is on + : Scheduler_shouldYield; + +var immediateQueue = null; +var immediateQueueCallbackNode = null; +var isFlushingImmediate = false; + +function getCurrentPriorityLevel() { + switch (Scheduler_getCurrentPriorityLevel()) { + case Scheduler_ImmediatePriority: + return ImmediatePriority; + case Scheduler_UserBlockingPriority: + return UserBlockingPriority; + case Scheduler_NormalPriority: + return NormalPriority; + case Scheduler_LowPriority: + return LowPriority; + case Scheduler_IdlePriority: + return IdlePriority; + default: + (function() { + { + throw ReactError("Unknown priority level."); + } + })(); + } +} + +function reactPriorityToSchedulerPriority(reactPriorityLevel) { + switch (reactPriorityLevel) { + case ImmediatePriority: + return Scheduler_ImmediatePriority; + case UserBlockingPriority: + return Scheduler_UserBlockingPriority; + case NormalPriority: + return Scheduler_NormalPriority; + case LowPriority: + return Scheduler_LowPriority; + case IdlePriority: + return Scheduler_IdlePriority; + default: + (function() { + { + throw ReactError("Unknown priority level."); + } + })(); + } +} + +function runWithPriority(reactPriorityLevel, fn) { + var priorityLevel = reactPriorityToSchedulerPriority(reactPriorityLevel); + return Scheduler_runWithPriority(priorityLevel, fn); +} + +function scheduleCallback(reactPriorityLevel, callback, options) { + if (reactPriorityLevel === ImmediatePriority) { + // Push this callback into an internal queue. We'll flush these either in + // the next tick, or earlier if something calls `flushImmediateQueue`. + if (immediateQueue === null) { + immediateQueue = [callback]; + // Flush the queue in the next tick, at the earliest. + immediateQueueCallbackNode = Scheduler_scheduleCallback( + Scheduler_ImmediatePriority, + flushImmediateQueueImpl + ); + } else { + // Push onto existing queue. Don't need to schedule a callback because + // we already scheduled one when we created the queue. + immediateQueue.push(callback); + } + return fakeCallbackNode; + } + // Otherwise pass through to Scheduler. + var priorityLevel = reactPriorityToSchedulerPriority(reactPriorityLevel); + return Scheduler_scheduleCallback(priorityLevel, callback, options); +} + +function cancelCallback(callbackNode) { + if (callbackNode !== fakeCallbackNode) { + Scheduler_cancelCallback(callbackNode); + } +} + +function flushImmediateQueue() { + if (immediateQueueCallbackNode !== null) { + Scheduler_cancelCallback(immediateQueueCallbackNode); + } + flushImmediateQueueImpl(); +} + +function flushImmediateQueueImpl() { + if (!isFlushingImmediate && immediateQueue !== null) { + // Prevent re-entrancy. + isFlushingImmediate = true; + var i = 0; + try { + var _isSync = true; + for (; i < immediateQueue.length; i++) { + var callback = immediateQueue[i]; + do { + callback = callback(_isSync); + } while (callback !== null); + } + immediateQueue = null; + } catch (error) { + // If something throws, leave the remaining callbacks on the queue. + if (immediateQueue !== null) { + immediateQueue = immediateQueue.slice(i + 1); + } + // Resume flushing in the next tick + Scheduler_scheduleCallback( + Scheduler_ImmediatePriority, + flushImmediateQueue + ); + throw error; + } finally { + isFlushingImmediate = false; + } + } +} var NoWork = 0; var Never = 1; -var Sync = maxSigned31BitInt; +var Sync = MAX_SIGNED_31_BIT_INT; var UNIT_SIZE = 10; -var MAGIC_NUMBER_OFFSET = maxSigned31BitInt - 1; +var MAGIC_NUMBER_OFFSET = MAX_SIGNED_31_BIT_INT - 1; // 1 unit of expiration time represents 10ms. function msToExpirationTime(ms) { @@ -5331,6 +5625,8 @@ function computeExpirationBucket(currentTime, expirationInMs, bucketSizeMs) { ); } +// TODO: This corresponds to Scheduler's NormalPriority, not LowPriority. Update +// the names to reflect. var LOW_PRIORITY_EXPIRATION = 5000; var LOW_PRIORITY_BATCH_SIZE = 250; @@ -5342,6 +5638,12 @@ function computeAsyncExpiration(currentTime) { ); } +// Same as computeAsyncExpiration but without the bucketing logic. This is +// used to compute timestamps instead of actual expiration times. +function computeAsyncExpirationNoBucket(currentTime) { + return currentTime - LOW_PRIORITY_EXPIRATION / UNIT_SIZE; +} + // We intentionally set a higher expiration time for interactive updates in // dev than in production. // @@ -5364,6 +5666,31 @@ function computeInteractiveExpiration(currentTime) { ); } +function inferPriorityFromExpirationTime(currentTime, expirationTime) { + if (expirationTime === Sync) { + return ImmediatePriority; + } + if (expirationTime === Never) { + return IdlePriority; + } + var msUntil = + msToExpirationTime(expirationTime) - msToExpirationTime(currentTime); + if (msUntil <= 0) { + return ImmediatePriority; + } + if (msUntil <= HIGH_PRIORITY_EXPIRATION) { + return UserBlockingPriority; + } + if (msUntil <= LOW_PRIORITY_EXPIRATION) { + return NormalPriority; + } + + // TODO: Handle LowPriority + + // Assume anything lower has idle priority + return IdlePriority; +} + var NoContext = 0; var ConcurrentMode = 1; var StrictMode = 2; @@ -5465,6 +5792,7 @@ function FiberNode(tag, pendingProps, key, mode) { this._debugSource = null; this._debugOwner = null; this._debugIsCurrentlyTiming = false; + this._debugHookTypes = null; if (!hasBadMapPolyfill && typeof Object.preventExtensions === "function") { Object.preventExtensions(this); } @@ -5541,6 +5869,7 @@ function createWorkInProgress(current, pendingProps, expirationTime) { workInProgress._debugID = current._debugID; workInProgress._debugSource = current._debugSource; workInProgress._debugOwner = current._debugOwner; + workInProgress._debugHookTypes = current._debugHookTypes; } workInProgress.alternate = current; @@ -5668,6 +5997,28 @@ function createFiberFromTypeAndProps( fiberTag = LazyComponent; resolvedType = null; break getTag; + case REACT_EVENT_COMPONENT_TYPE: + if (enableEventAPI) { + return createFiberFromEventComponent( + type, + pendingProps, + mode, + expirationTime, + key + ); + } + break; + case REACT_EVENT_TARGET_TYPE: + if (enableEventAPI) { + return createFiberFromEventTarget( + type, + pendingProps, + mode, + expirationTime, + key + ); + } + break; } } var info = ""; @@ -5688,14 +6039,16 @@ function createFiberFromTypeAndProps( info += "\n\nCheck the render method of `" + ownerName + "`."; } } - invariant( - false, - "Element type is invalid: expected a string (for built-in " + - "components) or a class/function (for composite components) " + - "but got: %s.%s", - type == null ? type : typeof type, - info - ); + (function() { + { + throw ReactError( + "Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: " + + (type == null ? type : typeof type) + + "." + + info + ); + } + })(); } } } @@ -5737,6 +6090,34 @@ function createFiberFromFragment(elements, mode, expirationTime, key) { return fiber; } +function createFiberFromEventComponent( + eventComponent, + pendingProps, + mode, + expirationTime, + key +) { + var fiber = createFiber(EventComponent, pendingProps, key, mode); + fiber.elementType = eventComponent; + fiber.type = eventComponent; + fiber.expirationTime = expirationTime; + return fiber; +} + +function createFiberFromEventTarget( + eventTarget, + pendingProps, + mode, + expirationTime, + key +) { + var fiber = createFiber(EventTarget, pendingProps, key, mode); + fiber.elementType = eventTarget; + fiber.type = eventTarget; + fiber.expirationTime = expirationTime; + return fiber; +} + function createFiberFromProfiler(pendingProps, mode, expirationTime, key) { { if ( @@ -5859,6 +6240,7 @@ function assignFiberPropertiesInDEV(target, source) { target._debugSource = source._debugSource; target._debugOwner = source._debugOwner; target._debugIsCurrentlyTiming = source._debugIsCurrentlyTiming; + target._debugHookTypes = source._debugHookTypes; return target; } @@ -5875,78 +6257,53 @@ function assignFiberPropertiesInDEV(target, source) { // The types are defined separately within this file to ensure they stay in sync. // (We don't have to use an inline :any cast when enableSchedulerTracing is disabled.) -function createFiberRoot(containerInfo, isConcurrent, hydrate) { - // Cyclic construction. This cheats the type system right now because - // stateNode is any. - var uninitializedFiber = createHostRootFiber(isConcurrent); +function FiberRootNode(containerInfo, hydrate) { + this.current = null; + this.containerInfo = containerInfo; + this.pendingChildren = null; + this.pingCache = null; + this.pendingCommitExpirationTime = NoWork; + this.finishedWork = null; + this.timeoutHandle = noTimeout; + this.context = null; + this.pendingContext = null; + this.hydrate = hydrate; + this.firstBatch = null; + + if (enableNewScheduler) { + this.callbackNode = null; + this.callbackExpirationTime = NoWork; + this.firstPendingTime = NoWork; + this.lastPendingTime = NoWork; + this.pingTime = NoWork; + } else { + this.earliestPendingTime = NoWork; + this.latestPendingTime = NoWork; + this.earliestSuspendedTime = NoWork; + this.latestSuspendedTime = NoWork; + this.latestPingedTime = NoWork; + this.didError = false; + this.nextExpirationTimeToWorkOn = NoWork; + this.expirationTime = NoWork; + this.nextScheduledRoot = null; + } - var root = void 0; if (enableSchedulerTracing) { - root = { - current: uninitializedFiber, - containerInfo: containerInfo, - pendingChildren: null, - - earliestPendingTime: NoWork, - latestPendingTime: NoWork, - earliestSuspendedTime: NoWork, - latestSuspendedTime: NoWork, - latestPingedTime: NoWork, - - pingCache: null, - - didError: false, - - pendingCommitExpirationTime: NoWork, - finishedWork: null, - timeoutHandle: noTimeout, - context: null, - pendingContext: null, - hydrate: hydrate, - nextExpirationTimeToWorkOn: NoWork, - expirationTime: NoWork, - firstBatch: null, - nextScheduledRoot: null, - - interactionThreadID: tracing.unstable_getThreadID(), - memoizedInteractions: new Set(), - pendingInteractionMap: new Map() - }; - } else { - root = { - current: uninitializedFiber, - containerInfo: containerInfo, - pendingChildren: null, - - pingCache: null, - - earliestPendingTime: NoWork, - latestPendingTime: NoWork, - earliestSuspendedTime: NoWork, - latestSuspendedTime: NoWork, - latestPingedTime: NoWork, - - didError: false, - - pendingCommitExpirationTime: NoWork, - finishedWork: null, - timeoutHandle: noTimeout, - context: null, - pendingContext: null, - hydrate: hydrate, - nextExpirationTimeToWorkOn: NoWork, - expirationTime: NoWork, - firstBatch: null, - nextScheduledRoot: null - }; + this.interactionThreadID = tracing.unstable_getThreadID(); + this.memoizedInteractions = new Set(); + this.pendingInteractionMap = new Map(); } +} +function createFiberRoot(containerInfo, isConcurrent, hydrate) { + var root = new FiberRootNode(containerInfo, hydrate); + + // Cyclic construction. This cheats the type system right now because + // stateNode is any. + var uninitializedFiber = createHostRootFiber(isConcurrent); + root.current = uninitializedFiber; uninitializedFiber.stateNode = root; - // The reason for the way the Flow types are structured in this file, - // Is to avoid needing :any casts everywhere interaction tracing fields are used. - // Unfortunately that requires an :any cast for non-interaction tracing capable builds. - // $FlowFixMe Remove this :any cast and replace it with something better. return root; } @@ -6349,19 +6706,56 @@ var ReactStrictModeWarnings = { }; } -// This lets us hook into Fiber to debug what it's doing. -// See https://github.com/facebook/react/pull/8033. -// This is not part of the public API, not even for React DevTools. -// You may only inject a debugTool if you work on React Fiber itself. -var ReactFiberInstrumentation = { - debugTool: null -}; - -var ReactFiberInstrumentation_1 = ReactFiberInstrumentation; +/** + * Similar to invariant but only logs a warning if the condition is not met. + * This can be used to log issues in development environments in critical + * paths. Removing the logging code for production environments will keep the + * same logic and follow the same code paths. + */ -// TODO: Offscreen updates should never suspend. However, a promise that -// suspended inside an offscreen subtree should be able to ping at the priority -// of the outer render. +var warning = warningWithoutStack$1; + +{ + warning = function(condition, format) { + if (condition) { + return; + } + var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame; + var stack = ReactDebugCurrentFrame.getStackAddendum(); + // eslint-disable-next-line react-internal/warning-and-invariant-args + + for ( + var _len = arguments.length, + args = Array(_len > 2 ? _len - 2 : 0), + _key = 2; + _key < _len; + _key++ + ) { + args[_key - 2] = arguments[_key]; + } + + warningWithoutStack$1.apply( + undefined, + [false, format + "%s"].concat(args, [stack]) + ); + }; +} + +var warning$1 = warning; + +// This lets us hook into Fiber to debug what it's doing. +// See https://github.com/facebook/react/pull/8033. +// This is not part of the public API, not even for React DevTools. +// You may only inject a debugTool if you work on React Fiber itself. +var ReactFiberInstrumentation = { + debugTool: null +}; + +var ReactFiberInstrumentation_1 = ReactFiberInstrumentation; + +// TODO: Offscreen updates should never suspend. However, a promise that +// suspended inside an offscreen subtree should be able to ping at the priority +// of the outer render. function markPendingPriorityLevel(root, expirationTime) { // If there's a gap between completing a failed root and retrying it, @@ -6548,20 +6942,6 @@ function clearPing(root, completedTime) { } } -function findEarliestOutstandingPriorityLevel(root, renderExpirationTime) { - var earliestExpirationTime = renderExpirationTime; - - var earliestPendingTime = root.earliestPendingTime; - var earliestSuspendedTime = root.earliestSuspendedTime; - if (earliestPendingTime > earliestExpirationTime) { - earliestExpirationTime = earliestPendingTime; - } - if (earliestSuspendedTime > earliestExpirationTime) { - earliestExpirationTime = earliestSuspendedTime; - } - return earliestExpirationTime; -} - function didExpireAtExpirationTime(root, currentTime) { var expirationTime = root.expirationTime; if (expirationTime !== NoWork && currentTime <= expirationTime) { @@ -6604,43 +6984,6 @@ function findNextExpirationTimeToWorkOn(completedExpirationTime, root) { root.expirationTime = expirationTime; } -/** - * Similar to invariant but only logs a warning if the condition is not met. - * This can be used to log issues in development environments in critical - * paths. Removing the logging code for production environments will keep the - * same logic and follow the same code paths. - */ - -var warning = warningWithoutStack$1; - -{ - warning = function(condition, format) { - if (condition) { - return; - } - var ReactDebugCurrentFrame = ReactSharedInternals.ReactDebugCurrentFrame; - var stack = ReactDebugCurrentFrame.getStackAddendum(); - // eslint-disable-next-line react-internal/warning-and-invariant-args - - for ( - var _len = arguments.length, - args = Array(_len > 2 ? _len - 2 : 0), - _key = 2; - _key < _len; - _key++ - ) { - args[_key - 2] = arguments[_key]; - } - - warningWithoutStack$1.apply( - undefined, - [false, format + "%s"].concat(args, [stack]) - ); - }; -} - -var warning$1 = warning; - /** * 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 @@ -6836,15 +7179,13 @@ var didWarnAboutInvalidateContextType = void 0; Object.defineProperty(fakeInternalInstance, "_processChildContext", { enumerable: false, value: function() { - invariant( - false, - "_processChildContext is not available in React 16+. This likely " + - "means you have multiple copies of React and are attempting to nest " + - "a React 15 tree inside a React 16 tree using " + - "unstable_renderSubtreeIntoContainer, which isn't supported. Try " + - "to make sure you have only one copy of React (and ideally, switch " + - "to ReactDOM.createPortal)." - ); + (function() { + { + throw ReactError( + "_processChildContext is not available in React 16+. This likely means you have multiple copies of React and are attempting to nest a React 15 tree inside a React 16 tree using unstable_renderSubtreeIntoContainer, which isn't supported. Try to make sure you have only one copy of React (and ideally, switch to ReactDOM.createPortal)." + ); + } + })(); } }); Object.freeze(fakeInternalInstance); @@ -6893,8 +7234,8 @@ var classComponentUpdater = { isMounted: isMounted, enqueueSetState: function(inst, payload, callback) { var fiber = get$1(inst); - var currentTime = requestCurrentTime(); - var expirationTime = computeExpirationForFiber(currentTime, fiber); + var currentTime = requestCurrentTime$$1(); + var expirationTime = computeExpirationForFiber$$1(currentTime, fiber); var update = createUpdate(expirationTime); update.payload = payload; @@ -6905,14 +7246,14 @@ var classComponentUpdater = { update.callback = callback; } - flushPassiveEffects(); + flushPassiveEffects$$1(); enqueueUpdate(fiber, update); - scheduleWork(fiber, expirationTime); + scheduleWork$$1(fiber, expirationTime); }, enqueueReplaceState: function(inst, payload, callback) { var fiber = get$1(inst); - var currentTime = requestCurrentTime(); - var expirationTime = computeExpirationForFiber(currentTime, fiber); + var currentTime = requestCurrentTime$$1(); + var expirationTime = computeExpirationForFiber$$1(currentTime, fiber); var update = createUpdate(expirationTime); update.tag = ReplaceState; @@ -6925,14 +7266,14 @@ var classComponentUpdater = { update.callback = callback; } - flushPassiveEffects(); + flushPassiveEffects$$1(); enqueueUpdate(fiber, update); - scheduleWork(fiber, expirationTime); + scheduleWork$$1(fiber, expirationTime); }, enqueueForceUpdate: function(inst, callback) { var fiber = get$1(inst); - var currentTime = requestCurrentTime(); - var expirationTime = computeExpirationForFiber(currentTime, fiber); + var currentTime = requestCurrentTime$$1(); + var expirationTime = computeExpirationForFiber$$1(currentTime, fiber); var update = createUpdate(expirationTime); update.tag = ForceUpdate; @@ -6944,9 +7285,9 @@ var classComponentUpdater = { update.callback = callback; } - flushPassiveEffects(); + flushPassiveEffects$$1(); enqueueUpdate(fiber, update); - scheduleWork(fiber, expirationTime); + scheduleWork$$1(fiber, expirationTime); } }; @@ -7258,23 +7599,51 @@ function constructClassInstance( var unmaskedContext = emptyContextObject; var context = null; var contextType = ctor.contextType; - if (typeof contextType === "object" && contextType !== null) { - { - if ( - contextType.$$typeof !== REACT_CONTEXT_TYPE && - !didWarnAboutInvalidateContextType.has(ctor) - ) { + + { + if ("contextType" in ctor) { + var isValid = + // Allow null for conditional declaration + contextType === null || + (contextType !== undefined && + contextType.$$typeof === REACT_CONTEXT_TYPE && + contextType._context === undefined); // Not a + + if (!isValid && !didWarnAboutInvalidateContextType.has(ctor)) { didWarnAboutInvalidateContextType.add(ctor); + + var addendum = ""; + if (contextType === undefined) { + addendum = + " However, it is set to undefined. " + + "This can be caused by a typo or by mixing up named and default imports. " + + "This can also happen due to a circular dependency, so " + + "try moving the createContext() call to a separate file."; + } else if (typeof contextType !== "object") { + addendum = " However, it is set to a " + typeof contextType + "."; + } else if (contextType.$$typeof === REACT_PROVIDER_TYPE) { + addendum = " Did you accidentally pass the Context.Provider instead?"; + } else if (contextType._context !== undefined) { + // + addendum = " Did you accidentally pass the Context.Consumer instead?"; + } else { + addendum = + " However, it is set to an object with keys {" + + Object.keys(contextType).join(", ") + + "}."; + } warningWithoutStack$1( false, "%s defines an invalid contextType. " + - "contextType should point to the Context object returned by React.createContext(). " + - "Did you accidentally pass the Context.Provider instead?", - getComponentName(ctor) || "Component" + "contextType should point to the Context object returned by React.createContext().%s", + getComponentName(ctor) || "Component", + addendum ); } } + } + if (typeof contextType === "object" && contextType !== null) { context = readContext(contextType); } else { unmaskedContext = getUnmaskedContext(workInProgress, ctor, true); @@ -7916,11 +8285,13 @@ var warnForMissingKey = function(child) {}; if (!child._store || child._store.validated || child.key != null) { return; } - invariant( - typeof child._store === "object", - "React Component in warnForMissingKey should have a _store. " + - "This error is likely caused by a bug in React. Please file an issue." - ); + (function() { + if (!(typeof child._store === "object")) { + throw ReactError( + "React Component in warnForMissingKey should have a _store. This error is likely caused by a bug in React. Please file an issue." + ); + } + })(); child._store.validated = true; var currentComponentErrorInfo = @@ -7976,19 +8347,24 @@ function coerceRef(returnFiber, current$$1, element) { var inst = void 0; if (owner) { var ownerFiber = owner; - invariant( - ownerFiber.tag === ClassComponent, - "Function components cannot have refs. " + - "Did you mean to use React.forwardRef()?" - ); + (function() { + if (!(ownerFiber.tag === ClassComponent)) { + throw ReactError( + "Function components cannot have refs. Did you mean to use React.forwardRef()?" + ); + } + })(); inst = ownerFiber.stateNode; } - invariant( - inst, - "Missing owner for string ref %s. This error is likely caused by a " + - "bug in React. Please file an issue.", - mixedRef - ); + (function() { + if (!inst) { + throw ReactError( + "Missing owner for string ref " + + mixedRef + + ". This error is likely caused by a bug in React. Please file an issue." + ); + } + })(); var stringRef = "" + mixedRef; // Check if previous string ref matches new string ref if ( @@ -8014,20 +8390,22 @@ function coerceRef(returnFiber, current$$1, element) { ref._stringRef = stringRef; return ref; } else { - invariant( - typeof mixedRef === "string", - "Expected ref to be a function, a string, an object returned by React.createRef(), or null." - ); - invariant( - element._owner, - "Element ref was specified as a string (%s) 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://fb.me/react-refs-must-have-owner for more information.", - mixedRef - ); + (function() { + if (!(typeof mixedRef === "string")) { + throw ReactError( + "Expected ref to be a function, a string, an object returned by React.createRef(), or null." + ); + } + })(); + (function() { + if (!element._owner) { + throw ReactError( + "Element ref was specified as a string (" + + mixedRef + + ") but no owner was set. This could happen for one of the following reasons:\n1. You may be adding a ref to a function component\n2. You may be adding a ref to a component that was not created inside a component's render method\n3. You have multiple copies of React loaded\nSee https://fb.me/react-refs-must-have-owner for more information." + ); + } + })(); } } return mixedRef; @@ -8042,14 +8420,18 @@ function throwOnInvalidObjectType(returnFiber, newChild) { "instead." + getCurrentFiberStackInDev(); } - invariant( - false, - "Objects are not valid as a React child (found: %s).%s", - Object.prototype.toString.call(newChild) === "[object Object]" - ? "object with keys {" + Object.keys(newChild).join(", ") + "}" - : newChild, - addendum - ); + (function() { + { + throw ReactError( + "Objects are not valid as a React child (found: " + + (Object.prototype.toString.call(newChild) === "[object Object]" + ? "object with keys {" + Object.keys(newChild).join(", ") + "}" + : newChild) + + ")." + + addendum + ); + } + })(); } } @@ -8708,11 +9090,13 @@ function ChildReconciler(shouldTrackSideEffects) { // but using the iterator instead. var iteratorFn = getIteratorFn(newChildrenIterable); - invariant( - typeof iteratorFn === "function", - "An object is not an iterable. This error is likely caused by a bug in " + - "React. Please file an issue." - ); + (function() { + if (!(typeof iteratorFn === "function")) { + throw ReactError( + "An object is not an iterable. This error is likely caused by a bug in React. Please file an issue." + ); + } + })(); { // We don't support rendering Generators because it's a mutation. @@ -8762,7 +9146,11 @@ function ChildReconciler(shouldTrackSideEffects) { } var newChildren = iteratorFn.call(newChildrenIterable); - invariant(newChildren != null, "An iterable object provided no iterator."); + (function() { + if (!(newChildren != null)) { + throw ReactError("An iterable object provided no iterator."); + } + })(); var resultingFirstChild = null; var previousNewFiber = null; @@ -9133,13 +9521,14 @@ function ChildReconciler(shouldTrackSideEffects) { // eslint-disable-next-lined no-fallthrough case FunctionComponent: { var Component = returnFiber.type; - invariant( - false, - "%s(...): Nothing was returned from render. This usually means a " + - "return statement is missing. Or, to render nothing, " + - "return null.", - Component.displayName || Component.name || "Component" - ); + (function() { + { + throw ReactError( + (Component.displayName || Component.name || "Component") + + "(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null." + ); + } + })(); } } } @@ -9155,10 +9544,11 @@ var reconcileChildFibers = ChildReconciler(true); var mountChildFibers = ChildReconciler(false); function cloneChildFibers(current$$1, workInProgress) { - invariant( - current$$1 === null || workInProgress.child === current$$1.child, - "Resuming work not yet implemented." - ); + (function() { + if (!(current$$1 === null || workInProgress.child === current$$1.child)) { + throw ReactError("Resuming work not yet implemented."); + } + })(); if (workInProgress.child === null) { return; @@ -9192,11 +9582,13 @@ var contextFiberStackCursor = createCursor(NO_CONTEXT); var rootInstanceStackCursor = createCursor(NO_CONTEXT); function requiredContext(c) { - invariant( - c !== NO_CONTEXT, - "Expected host context to exist. This error is likely caused by a bug " + - "in React. Please file an issue." - ); + (function() { + if (!(c !== NO_CONTEXT)) { + throw ReactError( + "Expected host context to exist. This error is likely caused by a bug in React. Please file an issue." + ); + } + })(); return c; } @@ -9252,6 +9644,37 @@ function pushHostContext(fiber) { push(contextStackCursor$1, nextContext, fiber); } +function pushHostContextForEventComponent(fiber) { + var context = requiredContext(contextStackCursor$1.current); + var nextContext = getChildHostContextForEventComponent(context); + + // Don't push this Fiber's context unless it's unique. + if (context === nextContext) { + return; + } + + // Track the context and the Fiber that provided it. + // This enables us to pop only Fibers that provide unique contexts. + push(contextFiberStackCursor, fiber, fiber); + push(contextStackCursor$1, nextContext, fiber); +} + +function pushHostContextForEventTarget(fiber) { + var context = requiredContext(contextStackCursor$1.current); + var eventTargetType = fiber.type.type; + var nextContext = getChildHostContextForEventTarget(context, eventTargetType); + + // Don't push this Fiber's context unless it's unique. + if (context === nextContext) { + return; + } + + // Track the context and the Fiber that provided it. + // This enables us to pop only Fibers that provide unique contexts. + push(contextFiberStackCursor, fiber, fiber); + push(contextStackCursor$1, nextContext, fiber); +} + function popHostContext(fiber) { // Do not pop unless this Fiber provided the current context. // pushHostContext() only pushes Fibers that provide unique contexts. @@ -9289,7 +9712,6 @@ var currentlyRenderingFiber$1 = null; // current hook list is the list that belongs to the current fiber. The // work-in-progress hook list is a new list that will be added to the // work-in-progress fiber. -var firstCurrentHook = null; var currentHook = null; var nextCurrentHook = null; var firstWorkInProgressHook = null; @@ -9319,60 +9741,107 @@ var RE_RENDER_LIMIT = 25; // In DEV, this is the name of the currently executing primitive hook var currentHookNameInDev = null; -function warnOnHookMismatchInDev() { +// In DEV, this list ensures that hooks are called in the same order between renders. +// The list stores the order of hooks used during the initial render (mount). +// Subsequent renders (updates) reference this list. +var hookTypesDev = null; +var hookTypesUpdateIndexDev = -1; + +function mountHookTypesDev() { + { + var hookName = currentHookNameInDev; + + if (hookTypesDev === null) { + hookTypesDev = [hookName]; + } else { + hookTypesDev.push(hookName); + } + } +} + +function updateHookTypesDev() { + { + var hookName = currentHookNameInDev; + + if (hookTypesDev !== null) { + hookTypesUpdateIndexDev++; + if (hookTypesDev[hookTypesUpdateIndexDev] !== hookName) { + warnOnHookMismatchInDev(hookName); + } + } + } +} + +function checkDepsAreArrayDev(deps) { + { + if (deps !== undefined && deps !== null && !Array.isArray(deps)) { + // Verify deps, but only on mount to avoid extra checks. + // It's unlikely their type would change as usually you define them inline. + warning$1( + false, + "%s received a final argument that is not an array (instead, received `%s`). When " + + "specified, the final argument must be an array.", + currentHookNameInDev, + typeof deps + ); + } + } +} + +function warnOnHookMismatchInDev(currentHookName) { { var componentName = getComponentName(currentlyRenderingFiber$1.type); if (!didWarnAboutMismatchedHooksForComponent.has(componentName)) { didWarnAboutMismatchedHooksForComponent.add(componentName); - var secondColumnStart = 22; + if (hookTypesDev !== null) { + var table = ""; - var table = ""; - var prevHook = firstCurrentHook; - var nextHook = firstWorkInProgressHook; - var n = 1; - while (prevHook !== null && nextHook !== null) { - var oldHookName = prevHook._debugType; - var newHookName = nextHook._debugType; + var secondColumnStart = 30; - var row = n + ". " + oldHookName; + for (var i = 0; i <= hookTypesUpdateIndexDev; i++) { + var oldHookName = hookTypesDev[i]; + var newHookName = + i === hookTypesUpdateIndexDev ? currentHookName : oldHookName; - // Extra space so second column lines up - // lol @ IE not supporting String#repeat - while (row.length < secondColumnStart) { - row += " "; - } + var row = i + 1 + ". " + oldHookName; + + // Extra space so second column lines up + // lol @ IE not supporting String#repeat + while (row.length < secondColumnStart) { + row += " "; + } - row += newHookName + "\n"; + row += newHookName + "\n"; - table += row; - prevHook = prevHook.next; - nextHook = nextHook.next; - n++; - } + table += row; + } - warning$1( - false, - "React has detected a change in the order of Hooks called by %s. " + - "This will lead to bugs and errors if not fixed. " + - "For more information, read the Rules of Hooks: https://fb.me/rules-of-hooks\n\n" + - " Previous render Next render\n" + - " -------------------------------\n" + - "%s" + - " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", - componentName, - table - ); + warning$1( + false, + "React has detected a change in the order of Hooks called by %s. " + + "This will lead to bugs and errors if not fixed. " + + "For more information, read the Rules of Hooks: https://fb.me/rules-of-hooks\n\n" + + " Previous render Next render\n" + + " ------------------------------------------------------\n" + + "%s" + + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", + componentName, + table + ); + } } } } function throwInvalidHookError() { - invariant( - false, - "Hooks can only be called inside the body of a function component. " + - "(https://fb.me/react-invalid-hook-call)" - ); + (function() { + { + throw ReactError( + "Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:\n1. You might have mismatching versions of React and the renderer (such as React DOM)\n2. You might be breaking the Rules of Hooks\n3. You might have more than one copy of React in the same app\nSee https://fb.me/react-invalid-hook-call for tips about how to debug and fix this problem." + ); + } + })(); } function areHookInputsEqual(nextDeps, prevDeps) { @@ -9400,8 +9869,8 @@ function areHookInputsEqual(nextDeps, prevDeps) { "Previous: %s\n" + "Incoming: %s", currentHookNameInDev, - "[" + nextDeps.join(", ") + "]", - "[" + prevDeps.join(", ") + "]" + "[" + prevDeps.join(", ") + "]", + "[" + nextDeps.join(", ") + "]" ); } } @@ -9424,8 +9893,12 @@ function renderWithHooks( ) { renderExpirationTime = nextRenderExpirationTime; currentlyRenderingFiber$1 = workInProgress; - firstCurrentHook = nextCurrentHook = - current !== null ? current.memoizedState : null; + nextCurrentHook = current !== null ? current.memoizedState : null; + + { + hookTypesDev = current !== null ? current._debugHookTypes : null; + hookTypesUpdateIndexDev = -1; + } // The following should have already been reset // currentHook = null; @@ -9439,11 +9912,26 @@ function renderWithHooks( // numberOfReRenders = 0; // sideEffectTag = 0; + // TODO Warn if no hooks are used at all during mount, then some are used during update. + // Currently we will identify the update render as a mount because nextCurrentHook === null. + // This is tricky because it's valid for certain types of components (e.g. React.lazy) + + // Using nextCurrentHook to differentiate between mount/update only works if at least one stateful hook is used. + // Non-stateful hooks (e.g. context) don't get added to memoizedState, + // so nextCurrentHook would be null during updates and mounts. { - ReactCurrentDispatcher$1.current = - nextCurrentHook === null - ? HooksDispatcherOnMountInDEV - : HooksDispatcherOnUpdateInDEV; + if (nextCurrentHook !== null) { + ReactCurrentDispatcher$1.current = HooksDispatcherOnUpdateInDEV; + } else if (hookTypesDev !== null) { + // This dispatcher handles an edge case where a component is updating, + // but no stateful hooks have been used. + // We want to match the production code behavior (which will use HooksDispatcherOnMount), + // but with the extra DEV validation to ensure hooks ordering hasn't changed. + // This dispatcher does that. + ReactCurrentDispatcher$1.current = HooksDispatcherOnMountWithHookTypesInDEV; + } else { + ReactCurrentDispatcher$1.current = HooksDispatcherOnMountInDEV; + } } var children = Component(props, refOrContext); @@ -9454,14 +9942,18 @@ function renderWithHooks( numberOfReRenders += 1; // Start over from the beginning of the list - firstCurrentHook = nextCurrentHook = - current !== null ? current.memoizedState : null; + nextCurrentHook = current !== null ? current.memoizedState : null; nextWorkInProgressHook = firstWorkInProgressHook; currentHook = null; workInProgressHook = null; componentUpdateQueue = null; + { + // Also validate hook order for cascading updates. + hookTypesUpdateIndexDev = -1; + } + ReactCurrentDispatcher$1.current = HooksDispatcherOnUpdateInDEV; children = Component(props, refOrContext); @@ -9471,10 +9963,6 @@ function renderWithHooks( numberOfReRenders = 0; } - { - currentHookNameInDev = null; - } - // We can assume the previous dispatcher is always this one, since we set it // at the beginning of the render phase and there's no re-entrancy. ReactCurrentDispatcher$1.current = ContextOnlyDispatcher; @@ -9486,18 +9974,29 @@ function renderWithHooks( renderedWork.updateQueue = componentUpdateQueue; renderedWork.effectTag |= sideEffectTag; + { + renderedWork._debugHookTypes = hookTypesDev; + } + + // This check uses currentHook so that it works the same in DEV and prod bundles. + // hookTypesDev could catch more cases (e.g. context) but only in DEV bundles. var didRenderTooFewHooks = currentHook !== null && currentHook.next !== null; renderExpirationTime = NoWork; currentlyRenderingFiber$1 = null; - firstCurrentHook = null; currentHook = null; nextCurrentHook = null; firstWorkInProgressHook = null; workInProgressHook = null; nextWorkInProgressHook = null; + { + currentHookNameInDev = null; + hookTypesDev = null; + hookTypesUpdateIndexDev = -1; + } + remainingExpirationTime = NoWork; componentUpdateQueue = null; sideEffectTag = 0; @@ -9507,11 +10006,13 @@ function renderWithHooks( // renderPhaseUpdates = null; // numberOfReRenders = 0; - invariant( - !didRenderTooFewHooks, - "Rendered fewer hooks than expected. This may be caused by an accidental " + - "early return statement." - ); + (function() { + if (!!didRenderTooFewHooks) { + throw ReactError( + "Rendered fewer hooks than expected. This may be caused by an accidental early return statement." + ); + } + })(); return children; } @@ -9535,21 +10036,23 @@ function resetHooks() { renderExpirationTime = NoWork; currentlyRenderingFiber$1 = null; - firstCurrentHook = null; currentHook = null; nextCurrentHook = null; firstWorkInProgressHook = null; workInProgressHook = null; nextWorkInProgressHook = null; - remainingExpirationTime = NoWork; - componentUpdateQueue = null; - sideEffectTag = 0; - { + hookTypesDev = null; + hookTypesUpdateIndexDev = -1; + currentHookNameInDev = null; } + remainingExpirationTime = NoWork; + componentUpdateQueue = null; + sideEffectTag = 0; + didScheduleRenderPhaseUpdate = false; renderPhaseUpdates = null; numberOfReRenders = 0; @@ -9566,20 +10069,6 @@ function mountWorkInProgressHook() { next: null }; - { - hook._debugType = currentHookNameInDev; - if ( - currentlyRenderingFiber$1 !== null && - currentlyRenderingFiber$1.alternate !== null - ) { - warning$1( - false, - "%s: Rendered more hooks than during the previous render. This is " + - "not currently supported and may lead to unexpected behavior.", - getComponentName(currentlyRenderingFiber$1.type) - ); - } - } if (workInProgressHook === null) { // This is the first hook in the list firstWorkInProgressHook = workInProgressHook = hook; @@ -9605,10 +10094,13 @@ function updateWorkInProgressHook() { nextCurrentHook = currentHook !== null ? currentHook.next : null; } else { // Clone from the current hook. - invariant( - nextCurrentHook !== null, - "Rendered more hooks than during the previous render." - ); + (function() { + if (!(nextCurrentHook !== null)) { + throw ReactError( + "Rendered more hooks than during the previous render." + ); + } + })(); currentHook = nextCurrentHook; var newHook = { @@ -9629,13 +10121,6 @@ function updateWorkInProgressHook() { workInProgressHook = workInProgressHook.next = newHook; } nextCurrentHook = currentHook.next; - - { - newHook._debugType = currentHookNameInDev; - if (currentHookNameInDev !== currentHook._debugType) { - warnOnHookMismatchInDev(); - } - } } return workInProgressHook; } @@ -9650,20 +10135,6 @@ function basicStateReducer(state, action) { return typeof action === "function" ? action(state) : action; } -function mountContext(context, observedBits) { - { - mountWorkInProgressHook(); - } - return readContext(context, observedBits); -} - -function updateContext(context, observedBits) { - { - updateWorkInProgressHook(); - } - return readContext(context, observedBits); -} - function mountReducer(reducer, initialArg, init) { var hook = mountWorkInProgressHook(); var initialState = void 0; @@ -9676,8 +10147,8 @@ function mountReducer(reducer, initialArg, init) { var queue = (hook.queue = { last: null, dispatch: null, - eagerReducer: reducer, - eagerState: initialState + lastRenderedReducer: reducer, + lastRenderedState: initialState }); var dispatch = (queue.dispatch = dispatchAction.bind( null, @@ -9691,10 +10162,15 @@ function mountReducer(reducer, initialArg, init) { function updateReducer(reducer, initialArg, init) { var hook = updateWorkInProgressHook(); var queue = hook.queue; - invariant( - queue !== null, - "Should have a queue. This is likely a bug in React. Please file an issue." - ); + (function() { + if (!(queue !== null)) { + throw ReactError( + "Should have a queue. This is likely a bug in React. Please file an issue." + ); + } + })(); + + queue.lastRenderedReducer = reducer; if (numberOfReRenders > 0) { // This is a re-render. Apply the new render phase updates to the previous @@ -9722,7 +10198,6 @@ function updateReducer(reducer, initialArg, init) { } hook.memoizedState = newState; - // Don't persist the state accumlated from the render phase updates to // the base state unless the queue is empty. // TODO: Not sure if this is the desired semantics, but it's what we @@ -9731,6 +10206,8 @@ function updateReducer(reducer, initialArg, init) { hook.baseState = newState; } + queue.lastRenderedState = newState; + return [newState, _dispatch]; } } @@ -9779,6 +10256,16 @@ function updateReducer(reducer, initialArg, init) { remainingExpirationTime = updateExpirationTime; } } else { + // This update does have sufficient priority. + + // Mark the event time of this update as relevant to this render pass. + // TODO: This should ideally use the true event time of this update rather than + // its priority which is a derived and not reverseable value. + // TODO: We should skip this update if it was already committed but currently + // we have no way of detecting the difference between a committed and suspended + // update here. + markRenderEventTime$$1(updateExpirationTime); + // Process this update. if (_update.eagerReducer === reducer) { // If this update was processed eagerly, and its reducer matches the @@ -9808,8 +10295,7 @@ function updateReducer(reducer, initialArg, init) { hook.baseUpdate = newBaseUpdate; hook.baseState = newBaseState; - queue.eagerReducer = reducer; - queue.eagerState = _newState; + queue.lastRenderedState = _newState; } var dispatch = queue.dispatch; @@ -9825,8 +10311,8 @@ function mountState(initialState) { var queue = (hook.queue = { last: null, dispatch: null, - eagerReducer: basicStateReducer, - eagerState: initialState + lastRenderedReducer: basicStateReducer, + lastRenderedState: initialState }); var dispatch = (queue.dispatch = dispatchAction.bind( null, @@ -10069,25 +10555,14 @@ function updateMemo(nextCreate, deps) { return nextValue; } -// in a test-like environment, we want to warn if dispatchAction() -// is called outside of a batchedUpdates/TestUtils.act(...) call. -var shouldWarnForUnbatchedSetState = false; - -{ - // jest isn't a 'global', it's just exposed to tests via a wrapped function - // further, this isn't a test file, so flow doesn't recognize the symbol. So... - // $FlowExpectedError - because requirements don't give a damn about your type sigs. - if ("undefined" !== typeof jest) { - shouldWarnForUnbatchedSetState = true; - } -} - function dispatchAction(fiber, queue, action) { - invariant( - numberOfReRenders < RE_RENDER_LIMIT, - "Too many re-renders. React limits the number of renders to prevent " + - "an infinite loop." - ); + (function() { + if (!(numberOfReRenders < RE_RENDER_LIMIT)) { + throw ReactError( + "Too many re-renders. React limits the number of renders to prevent an infinite loop." + ); + } + })(); { !(arguments.length <= 3) @@ -10131,10 +10606,10 @@ function dispatchAction(fiber, queue, action) { lastRenderPhaseUpdate.next = update; } } else { - flushPassiveEffects(); + flushPassiveEffects$$1(); - var currentTime = requestCurrentTime(); - var _expirationTime = computeExpirationForFiber(currentTime, fiber); + var currentTime = requestCurrentTime$$1(); + var _expirationTime = computeExpirationForFiber$$1(currentTime, fiber); var _update2 = { expirationTime: _expirationTime, @@ -10166,21 +10641,21 @@ function dispatchAction(fiber, queue, action) { // The queue is currently empty, which means we can eagerly compute the // next state before entering the render phase. If the new state is the // same as the current state, we may be able to bail out entirely. - var _eagerReducer = queue.eagerReducer; - if (_eagerReducer !== null) { + var _lastRenderedReducer = queue.lastRenderedReducer; + if (_lastRenderedReducer !== null) { var prevDispatcher = void 0; { prevDispatcher = ReactCurrentDispatcher$1.current; ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV; } try { - var currentState = queue.eagerState; - var _eagerState = _eagerReducer(currentState, action); + var currentState = queue.lastRenderedState; + var _eagerState = _lastRenderedReducer(currentState, action); // Stash the eagerly computed state, and the reducer used to compute // it, on the update object. If the reducer hasn't changed by the // time we enter the render phase, then the eager state can be used // without calling the reducer again. - _update2.eagerReducer = _eagerReducer; + _update2.eagerReducer = _lastRenderedReducer; _update2.eagerState = _eagerState; if (is(_eagerState, currentState)) { // Fast path. We can bail out without scheduling React to re-render. @@ -10199,11 +10674,14 @@ function dispatchAction(fiber, queue, action) { } } { - if (shouldWarnForUnbatchedSetState === true) { - warnIfNotCurrentlyBatchingInDev(fiber); + // jest isn't a 'global', it's just exposed to tests via a wrapped function + // further, this isn't a test file, so flow doesn't recognize the symbol. So... + // $FlowExpectedError - because requirements don't give a damn about your type sigs. + if ("undefined" !== typeof jest) { + warnIfNotCurrentlyActingUpdatesInDev$$1(fiber); } } - scheduleWork(fiber, _expirationTime); + scheduleWork$$1(fiber, _expirationTime); } } @@ -10223,6 +10701,7 @@ var ContextOnlyDispatcher = { }; var HooksDispatcherOnMountInDEV = null; +var HooksDispatcherOnMountWithHookTypesInDEV = null; var HooksDispatcherOnUpdateInDEV = null; var InvalidNestedHooksDispatcherOnMountInDEV = null; var InvalidNestedHooksDispatcherOnUpdateInDEV = null; @@ -10254,26 +10733,111 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null; }, useCallback: function(callback, deps) { currentHookNameInDev = "useCallback"; + mountHookTypesDev(); + checkDepsAreArrayDev(deps); + return mountCallback(callback, deps); + }, + useContext: function(context, observedBits) { + currentHookNameInDev = "useContext"; + mountHookTypesDev(); + return readContext(context, observedBits); + }, + useEffect: function(create, deps) { + currentHookNameInDev = "useEffect"; + mountHookTypesDev(); + checkDepsAreArrayDev(deps); + return mountEffect(create, deps); + }, + useImperativeHandle: function(ref, create, deps) { + currentHookNameInDev = "useImperativeHandle"; + mountHookTypesDev(); + checkDepsAreArrayDev(deps); + return mountImperativeHandle(ref, create, deps); + }, + useLayoutEffect: function(create, deps) { + currentHookNameInDev = "useLayoutEffect"; + mountHookTypesDev(); + checkDepsAreArrayDev(deps); + return mountLayoutEffect(create, deps); + }, + useMemo: function(create, deps) { + currentHookNameInDev = "useMemo"; + mountHookTypesDev(); + checkDepsAreArrayDev(deps); + var prevDispatcher = ReactCurrentDispatcher$1.current; + ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV; + try { + return mountMemo(create, deps); + } finally { + ReactCurrentDispatcher$1.current = prevDispatcher; + } + }, + useReducer: function(reducer, initialArg, init) { + currentHookNameInDev = "useReducer"; + mountHookTypesDev(); + var prevDispatcher = ReactCurrentDispatcher$1.current; + ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV; + try { + return mountReducer(reducer, initialArg, init); + } finally { + ReactCurrentDispatcher$1.current = prevDispatcher; + } + }, + useRef: function(initialValue) { + currentHookNameInDev = "useRef"; + mountHookTypesDev(); + return mountRef(initialValue); + }, + useState: function(initialState) { + currentHookNameInDev = "useState"; + mountHookTypesDev(); + var prevDispatcher = ReactCurrentDispatcher$1.current; + ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV; + try { + return mountState(initialState); + } finally { + ReactCurrentDispatcher$1.current = prevDispatcher; + } + }, + useDebugValue: function(value, formatterFn) { + currentHookNameInDev = "useDebugValue"; + mountHookTypesDev(); + return mountDebugValue(value, formatterFn); + } + }; + + HooksDispatcherOnMountWithHookTypesInDEV = { + readContext: function(context, observedBits) { + return readContext(context, observedBits); + }, + useCallback: function(callback, deps) { + currentHookNameInDev = "useCallback"; + updateHookTypesDev(); return mountCallback(callback, deps); }, useContext: function(context, observedBits) { currentHookNameInDev = "useContext"; - return mountContext(context, observedBits); + updateHookTypesDev(); + return readContext(context, observedBits); }, useEffect: function(create, deps) { currentHookNameInDev = "useEffect"; + updateHookTypesDev(); return mountEffect(create, deps); }, useImperativeHandle: function(ref, create, deps) { currentHookNameInDev = "useImperativeHandle"; + updateHookTypesDev(); return mountImperativeHandle(ref, create, deps); }, useLayoutEffect: function(create, deps) { currentHookNameInDev = "useLayoutEffect"; + updateHookTypesDev(); return mountLayoutEffect(create, deps); }, useMemo: function(create, deps) { currentHookNameInDev = "useMemo"; + updateHookTypesDev(); var prevDispatcher = ReactCurrentDispatcher$1.current; ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV; try { @@ -10284,6 +10848,7 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null; }, useReducer: function(reducer, initialArg, init) { currentHookNameInDev = "useReducer"; + updateHookTypesDev(); var prevDispatcher = ReactCurrentDispatcher$1.current; ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV; try { @@ -10294,10 +10859,12 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null; }, useRef: function(initialValue) { currentHookNameInDev = "useRef"; + updateHookTypesDev(); return mountRef(initialValue); }, useState: function(initialState) { currentHookNameInDev = "useState"; + updateHookTypesDev(); var prevDispatcher = ReactCurrentDispatcher$1.current; ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV; try { @@ -10308,6 +10875,7 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null; }, useDebugValue: function(value, formatterFn) { currentHookNameInDev = "useDebugValue"; + updateHookTypesDev(); return mountDebugValue(value, formatterFn); } }; @@ -10318,26 +10886,32 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null; }, useCallback: function(callback, deps) { currentHookNameInDev = "useCallback"; + updateHookTypesDev(); return updateCallback(callback, deps); }, useContext: function(context, observedBits) { currentHookNameInDev = "useContext"; - return updateContext(context, observedBits); + updateHookTypesDev(); + return readContext(context, observedBits); }, useEffect: function(create, deps) { currentHookNameInDev = "useEffect"; + updateHookTypesDev(); return updateEffect(create, deps); }, useImperativeHandle: function(ref, create, deps) { currentHookNameInDev = "useImperativeHandle"; + updateHookTypesDev(); return updateImperativeHandle(ref, create, deps); }, useLayoutEffect: function(create, deps) { currentHookNameInDev = "useLayoutEffect"; + updateHookTypesDev(); return updateLayoutEffect(create, deps); }, useMemo: function(create, deps) { currentHookNameInDev = "useMemo"; + updateHookTypesDev(); var prevDispatcher = ReactCurrentDispatcher$1.current; ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV; try { @@ -10348,6 +10922,7 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null; }, useReducer: function(reducer, initialArg, init) { currentHookNameInDev = "useReducer"; + updateHookTypesDev(); var prevDispatcher = ReactCurrentDispatcher$1.current; ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV; try { @@ -10358,10 +10933,12 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null; }, useRef: function(initialValue) { currentHookNameInDev = "useRef"; + updateHookTypesDev(); return updateRef(initialValue); }, useState: function(initialState) { currentHookNameInDev = "useState"; + updateHookTypesDev(); var prevDispatcher = ReactCurrentDispatcher$1.current; ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV; try { @@ -10372,6 +10949,7 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null; }, useDebugValue: function(value, formatterFn) { currentHookNameInDev = "useDebugValue"; + updateHookTypesDev(); return updateDebugValue(value, formatterFn); } }; @@ -10384,31 +10962,37 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null; useCallback: function(callback, deps) { currentHookNameInDev = "useCallback"; warnInvalidHookAccess(); + mountHookTypesDev(); return mountCallback(callback, deps); }, useContext: function(context, observedBits) { currentHookNameInDev = "useContext"; warnInvalidHookAccess(); - return mountContext(context, observedBits); + mountHookTypesDev(); + return readContext(context, observedBits); }, useEffect: function(create, deps) { currentHookNameInDev = "useEffect"; warnInvalidHookAccess(); + mountHookTypesDev(); return mountEffect(create, deps); }, useImperativeHandle: function(ref, create, deps) { currentHookNameInDev = "useImperativeHandle"; warnInvalidHookAccess(); + mountHookTypesDev(); return mountImperativeHandle(ref, create, deps); }, useLayoutEffect: function(create, deps) { currentHookNameInDev = "useLayoutEffect"; warnInvalidHookAccess(); + mountHookTypesDev(); return mountLayoutEffect(create, deps); }, useMemo: function(create, deps) { currentHookNameInDev = "useMemo"; warnInvalidHookAccess(); + mountHookTypesDev(); var prevDispatcher = ReactCurrentDispatcher$1.current; ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV; try { @@ -10420,6 +11004,7 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null; useReducer: function(reducer, initialArg, init) { currentHookNameInDev = "useReducer"; warnInvalidHookAccess(); + mountHookTypesDev(); var prevDispatcher = ReactCurrentDispatcher$1.current; ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV; try { @@ -10431,11 +11016,13 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null; useRef: function(initialValue) { currentHookNameInDev = "useRef"; warnInvalidHookAccess(); + mountHookTypesDev(); return mountRef(initialValue); }, useState: function(initialState) { currentHookNameInDev = "useState"; warnInvalidHookAccess(); + mountHookTypesDev(); var prevDispatcher = ReactCurrentDispatcher$1.current; ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnMountInDEV; try { @@ -10447,6 +11034,7 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null; useDebugValue: function(value, formatterFn) { currentHookNameInDev = "useDebugValue"; warnInvalidHookAccess(); + mountHookTypesDev(); return mountDebugValue(value, formatterFn); } }; @@ -10459,31 +11047,37 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null; useCallback: function(callback, deps) { currentHookNameInDev = "useCallback"; warnInvalidHookAccess(); + updateHookTypesDev(); return updateCallback(callback, deps); }, useContext: function(context, observedBits) { currentHookNameInDev = "useContext"; warnInvalidHookAccess(); - return updateContext(context, observedBits); + updateHookTypesDev(); + return readContext(context, observedBits); }, useEffect: function(create, deps) { currentHookNameInDev = "useEffect"; warnInvalidHookAccess(); + updateHookTypesDev(); return updateEffect(create, deps); }, useImperativeHandle: function(ref, create, deps) { currentHookNameInDev = "useImperativeHandle"; warnInvalidHookAccess(); + updateHookTypesDev(); return updateImperativeHandle(ref, create, deps); }, useLayoutEffect: function(create, deps) { currentHookNameInDev = "useLayoutEffect"; warnInvalidHookAccess(); + updateHookTypesDev(); return updateLayoutEffect(create, deps); }, useMemo: function(create, deps) { currentHookNameInDev = "useMemo"; warnInvalidHookAccess(); + updateHookTypesDev(); var prevDispatcher = ReactCurrentDispatcher$1.current; ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV; try { @@ -10495,6 +11089,7 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null; useReducer: function(reducer, initialArg, init) { currentHookNameInDev = "useReducer"; warnInvalidHookAccess(); + updateHookTypesDev(); var prevDispatcher = ReactCurrentDispatcher$1.current; ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV; try { @@ -10506,11 +11101,13 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null; useRef: function(initialValue) { currentHookNameInDev = "useRef"; warnInvalidHookAccess(); + updateHookTypesDev(); return updateRef(initialValue); }, useState: function(initialState) { currentHookNameInDev = "useState"; warnInvalidHookAccess(); + updateHookTypesDev(); var prevDispatcher = ReactCurrentDispatcher$1.current; ReactCurrentDispatcher$1.current = InvalidNestedHooksDispatcherOnUpdateInDEV; try { @@ -10522,11 +11119,16 @@ var InvalidNestedHooksDispatcherOnUpdateInDEV = null; useDebugValue: function(value, formatterFn) { currentHookNameInDev = "useDebugValue"; warnInvalidHookAccess(); + updateHookTypesDev(); return updateDebugValue(value, formatterFn); } }; } +// Intentionally not named imports because Rollup would use dynamic dispatch for +// CommonJS interop named imports. +var now$2 = Scheduler.unstable_now; + var commitTime = 0; var profilerStartTime = -1; @@ -10538,7 +11140,7 @@ function recordCommitTime() { if (!enableProfilerTimer) { return; } - commitTime = now$$1(); + commitTime = now$2(); } function startProfilerTimer(fiber) { @@ -10546,10 +11148,10 @@ function startProfilerTimer(fiber) { return; } - profilerStartTime = now$$1(); + profilerStartTime = now$2(); if (fiber.actualStartTime < 0) { - fiber.actualStartTime = now$$1(); + fiber.actualStartTime = now$2(); } } @@ -10566,7 +11168,7 @@ function stopProfilerTimerIfRunningAndRecordDelta(fiber, overrideBaseTime) { } if (profilerStartTime >= 0) { - var elapsedTime = now$$1() - profilerStartTime; + var elapsedTime = now$2() - profilerStartTime; fiber.actualDuration += elapsedTime; if (overrideBaseTime) { fiber.selfBaseDuration = elapsedTime; @@ -10593,6 +11195,18 @@ function enterHydrationState(fiber) { return true; } +function reenterHydrationStateFromDehydratedSuspenseInstance(fiber) { + if (!supportsHydration) { + return false; + } + + var suspenseInstance = fiber.stateNode; + nextHydratableInstance = getNextHydratableSibling(suspenseInstance); + popToNextHostParent(fiber); + isHydrating = true; + return true; +} + function deleteHydratableInstance(returnFiber, instance) { { switch (returnFiber.tag) { @@ -10647,6 +11261,9 @@ function insertNonHydratedInstance(returnFiber, fiber) { var text = fiber.pendingProps; didNotFindHydratableContainerTextInstance(parentContainer, text); break; + case SuspenseComponent: + didNotFindHydratableContainerSuspenseInstance(parentContainer); + break; } break; } @@ -10675,6 +11292,13 @@ function insertNonHydratedInstance(returnFiber, fiber) { _text ); break; + case SuspenseComponent: + didNotFindHydratableSuspenseInstance( + parentType, + parentProps, + parentInstance + ); + break; } break; } @@ -10705,6 +11329,18 @@ function tryHydrate(fiber, nextInstance) { } return false; } + case SuspenseComponent: { + if (enableSuspenseServerRenderer) { + var suspenseInstance = canHydrateSuspenseInstance(nextInstance); + if (suspenseInstance !== null) { + // Downgrade the tag to a dehydrated component until we've hydrated it. + fiber.tag = DehydratedSuspenseComponent; + fiber.stateNode = suspenseInstance; + return true; + } + } + return false; + } default: return false; } @@ -10751,11 +11387,13 @@ function prepareToHydrateHostInstance( hostContext ) { if (!supportsHydration) { - invariant( - false, - "Expected prepareToHydrateHostInstance() to never be called. " + - "This error is likely caused by a bug in React. Please file an issue." - ); + (function() { + { + throw ReactError( + "Expected prepareToHydrateHostInstance() to never be called. This error is likely caused by a bug in React. Please file an issue." + ); + } + })(); } var instance = fiber.stateNode; @@ -10779,11 +11417,13 @@ function prepareToHydrateHostInstance( function prepareToHydrateHostTextInstance(fiber) { if (!supportsHydration) { - invariant( - false, - "Expected prepareToHydrateHostTextInstance() to never be called. " + - "This error is likely caused by a bug in React. Please file an issue." - ); + (function() { + { + throw ReactError( + "Expected prepareToHydrateHostTextInstance() to never be called. This error is likely caused by a bug in React. Please file an issue." + ); + } + })(); } var textInstance = fiber.stateNode; @@ -10825,12 +11465,36 @@ function prepareToHydrateHostTextInstance(fiber) { return shouldUpdate; } +function skipPastDehydratedSuspenseInstance(fiber) { + if (!supportsHydration) { + (function() { + { + throw ReactError( + "Expected skipPastDehydratedSuspenseInstance() to never be called. This error is likely caused by a bug in React. Please file an issue." + ); + } + })(); + } + var suspenseInstance = fiber.stateNode; + (function() { + if (!suspenseInstance) { + throw ReactError( + "Expected to have a hydrated suspense instance. This error is likely caused by a bug in React. Please file an issue." + ); + } + })(); + nextHydratableInstance = getNextHydratableInstanceAfterSuspenseInstance( + suspenseInstance + ); +} + function popToNextHostParent(fiber) { var parent = fiber.return; while ( parent !== null && parent.tag !== HostComponent && - parent.tag !== HostRoot + parent.tag !== HostRoot && + parent.tag !== DehydratedSuspenseComponent ) { parent = parent.return; } @@ -10897,17 +11561,21 @@ var ReactCurrentOwner$3 = ReactSharedInternals.ReactCurrentOwner; var didReceiveUpdate = false; var didWarnAboutBadClass = void 0; +var didWarnAboutModulePatternComponent = void 0; var didWarnAboutContextTypeOnFunctionComponent = void 0; var didWarnAboutGetDerivedStateOnFunctionComponent = void 0; var didWarnAboutFunctionRefs = void 0; var didWarnAboutReassigningProps = void 0; +var didWarnAboutMaxDuration = void 0; { didWarnAboutBadClass = {}; + didWarnAboutModulePatternComponent = {}; didWarnAboutContextTypeOnFunctionComponent = {}; didWarnAboutGetDerivedStateOnFunctionComponent = {}; didWarnAboutFunctionRefs = {}; didWarnAboutReassigningProps = false; + didWarnAboutMaxDuration = false; } function reconcileChildren( @@ -10982,6 +11650,10 @@ function updateForwardRef( nextProps, renderExpirationTime ) { + // TODO: current can be non-null here even if the component + // hasn't yet mounted. This happens after the first render suspends. + // We'll need to figure out if this is fine or can cause issues. + { if (workInProgress.type !== workInProgress.elementType) { // Lazy component props can't be validated in createElement @@ -11171,6 +11843,10 @@ function updateSimpleMemoComponent( updateExpirationTime, renderExpirationTime ) { + // TODO: current can be non-null here even if the component + // hasn't yet mounted. This happens when the inner render suspends. + // We'll need to figure out if this is fine or can cause issues. + { if (workInProgress.type !== workInProgress.elementType) { // Lazy component props can't be validated in createElement @@ -11565,12 +12241,13 @@ function pushHostRootContext(workInProgress) { function updateHostRoot(current$$1, workInProgress, renderExpirationTime) { pushHostRootContext(workInProgress); var updateQueue = workInProgress.updateQueue; - invariant( - updateQueue !== null, - "If the root does not have an updateQueue, we should have already " + - "bailed out. This error is likely caused by a bug in React. Please " + - "file an issue." - ); + (function() { + if (!(updateQueue !== null)) { + throw ReactError( + "If the root does not have an updateQueue, we should have already bailed out. This error is likely caused by a bug in React. Please file an issue." + ); + } + })(); var nextProps = workInProgress.pendingProps; var prevState = workInProgress.memoizedState; var prevChildren = prevState !== null ? prevState.element : null; @@ -11794,13 +12471,16 @@ function mountLazyComponent( // This message intentionally doesn't mention ForwardRef or MemoComponent // because the fact that it's a separate type of work is an // implementation detail. - invariant( - false, - "Element type is invalid. Received a promise that resolves to: %s. " + - "Lazy element type must resolve to a class or function.%s", - Component, - hint - ); + (function() { + { + throw ReactError( + "Element type is invalid. Received a promise that resolves to: " + + Component + + ". Lazy element type must resolve to a class or function." + + hint + ); + } + })(); } } return child; @@ -11931,6 +12611,24 @@ function mountIndeterminateComponent( typeof value.render === "function" && value.$$typeof === undefined ) { + { + var _componentName = getComponentName(Component) || "Unknown"; + if (!didWarnAboutModulePatternComponent[_componentName]) { + warningWithoutStack$1( + false, + "The <%s /> component appears to be a function component that returns a class instance. " + + "Change %s to a class that extends React.Component instead. " + + "If you can't use a class try assigning the prototype on the function as a workaround. " + + "`%s.prototype = React.Component.prototype`. Don't use an arrow function since it " + + "cannot be called with `new` by React.", + _componentName, + _componentName, + _componentName + ); + didWarnAboutModulePatternComponent[_componentName] = true; + } + } + // Proceed under the assumption that this is a class instance workInProgress.tag = ClassComponent; @@ -12052,15 +12750,15 @@ function validateFunctionComponentInDev(workInProgress, Component) { typeof Component.contextType === "object" && Component.contextType !== null ) { - var _componentName = getComponentName(Component) || "Unknown"; + var _componentName2 = getComponentName(Component) || "Unknown"; - if (!didWarnAboutContextTypeOnFunctionComponent[_componentName]) { + if (!didWarnAboutContextTypeOnFunctionComponent[_componentName2]) { warningWithoutStack$1( false, "%s: Function components do not support contextType.", - _componentName + _componentName2 ); - didWarnAboutContextTypeOnFunctionComponent[_componentName] = true; + didWarnAboutContextTypeOnFunctionComponent[_componentName2] = true; } } } @@ -12073,6 +12771,12 @@ function updateSuspenseComponent( var mode = workInProgress.mode; var nextProps = workInProgress.pendingProps; + { + if (shouldSuspend(workInProgress)) { + workInProgress.effectTag |= DidCapture; + } + } + // We should attempt to render the primary children unless this boundary // already suspended during this render (`alreadyCaptured` is true). var nextState = workInProgress.memoizedState; @@ -12086,12 +12790,26 @@ function updateSuspenseComponent( // Something in this boundary's subtree already suspended. Switch to // rendering the fallback children. nextState = { - timedOutAt: nextState !== null ? nextState.timedOutAt : NoWork + fallbackExpirationTime: + nextState !== null ? nextState.fallbackExpirationTime : NoWork }; nextDidTimeout = true; workInProgress.effectTag &= ~DidCapture; } + { + if ("maxDuration" in nextProps) { + if (!didWarnAboutMaxDuration) { + didWarnAboutMaxDuration = true; + warning$1( + false, + "maxDuration has been removed from React. " + + "Remove the maxDuration prop." + ); + } + } + } + // This next part is a bit confusing. If the children timeout, we switch to // showing the fallback children in place of the "primary" children. // However, we don't want to delete the primary children because then their @@ -12124,6 +12842,22 @@ function updateSuspenseComponent( // children -- we skip over the primary children entirely. var next = void 0; if (current$$1 === null) { + if (enableSuspenseServerRenderer) { + // If we're currently hydrating, try to hydrate this boundary. + // But only if this has a fallback. + if (nextProps.fallback !== undefined) { + tryToClaimNextHydratableInstance(workInProgress); + // This could've changed the tag if this was a dehydrated suspense component. + if (workInProgress.tag === DehydratedSuspenseComponent) { + return updateDehydratedSuspenseComponent( + null, + workInProgress, + renderExpirationTime + ); + } + } + } + // This is the initial mount. This branch is pretty simple because there's // no previous state that needs to be preserved. if (nextDidTimeout) { @@ -12326,6 +13060,141 @@ function updateSuspenseComponent( return next; } +function retrySuspenseComponentWithoutHydrating( + current$$1, + workInProgress, + renderExpirationTime +) { + // Detach from the current dehydrated boundary. + current$$1.alternate = null; + workInProgress.alternate = null; + + // Insert a deletion in the effect list. + var returnFiber = workInProgress.return; + (function() { + if (!(returnFiber !== null)) { + throw ReactError( + "Suspense boundaries are never on the root. This is probably a bug in React." + ); + } + })(); + var last = returnFiber.lastEffect; + if (last !== null) { + last.nextEffect = current$$1; + returnFiber.lastEffect = current$$1; + } else { + returnFiber.firstEffect = returnFiber.lastEffect = current$$1; + } + current$$1.nextEffect = null; + current$$1.effectTag = Deletion; + + // Upgrade this work in progress to a real Suspense component. + workInProgress.tag = SuspenseComponent; + workInProgress.stateNode = null; + workInProgress.memoizedState = null; + // This is now an insertion. + workInProgress.effectTag |= Placement; + // Retry as a real Suspense component. + return updateSuspenseComponent(null, workInProgress, renderExpirationTime); +} + +function updateDehydratedSuspenseComponent( + current$$1, + workInProgress, + renderExpirationTime +) { + var suspenseInstance = workInProgress.stateNode; + if (current$$1 === null) { + // During the first pass, we'll bail out and not drill into the children. + // Instead, we'll leave the content in place and try to hydrate it later. + if (isSuspenseInstanceFallback(suspenseInstance)) { + // This is a client-only boundary. Since we won't get any content from the server + // for this, we need to schedule that at a higher priority based on when it would + // have timed out. In theory we could render it in this pass but it would have the + // wrong priority associated with it and will prevent hydration of parent path. + // Instead, we'll leave work left on it to render it in a separate commit. + + // TODO This time should be the time at which the server rendered response that is + // a parent to this boundary was displayed. However, since we currently don't have + // a protocol to transfer that time, we'll just estimate it by using the current + // time. This will mean that Suspense timeouts are slightly shifted to later than + // they should be. + var serverDisplayTime = requestCurrentTime$$1(); + // Schedule a normal pri update to render this content. + workInProgress.expirationTime = computeAsyncExpiration(serverDisplayTime); + } else { + // We'll continue hydrating the rest at offscreen priority since we'll already + // be showing the right content coming from the server, it is no rush. + workInProgress.expirationTime = Never; + } + return null; + } + if ((workInProgress.effectTag & DidCapture) !== NoEffect) { + // Something suspended. Leave the existing children in place. + // TODO: In non-concurrent mode, should we commit the nodes we have hydrated so far? + workInProgress.child = null; + return null; + } + if (isSuspenseInstanceFallback(suspenseInstance)) { + // This boundary is in a permanent fallback state. In this case, we'll never + // get an update and we'll never be able to hydrate the final content. Let's just try the + // client side render instead. + return retrySuspenseComponentWithoutHydrating( + current$$1, + workInProgress, + renderExpirationTime + ); + } + // We use childExpirationTime to indicate that a child might depend on context, so if + // any context has changed, we need to treat is as if the input might have changed. + var hasContextChanged$$1 = + current$$1.childExpirationTime >= renderExpirationTime; + if (didReceiveUpdate || hasContextChanged$$1) { + // This boundary has changed since the first render. This means that we are now unable to + // hydrate it. We might still be able to hydrate it using an earlier expiration time but + // during this render we can't. Instead, we're going to delete the whole subtree and + // instead inject a new real Suspense boundary to take its place, which may render content + // or fallback. The real Suspense boundary will suspend for a while so we have some time + // to ensure it can produce real content, but all state and pending events will be lost. + return retrySuspenseComponentWithoutHydrating( + current$$1, + workInProgress, + renderExpirationTime + ); + } else if (isSuspenseInstancePending(suspenseInstance)) { + // This component is still pending more data from the server, so we can't hydrate its + // content. We treat it as if this component suspended itself. It might seem as if + // we could just try to render it client-side instead. However, this will perform a + // lot of unnecessary work and is unlikely to complete since it often will suspend + // on missing data anyway. Additionally, the server might be able to render more + // than we can on the client yet. In that case we'd end up with more fallback states + // on the client than if we just leave it alone. If the server times out or errors + // these should update this boundary to the permanent Fallback state instead. + // Mark it as having captured (i.e. suspended). + workInProgress.effectTag |= DidCapture; + // Leave the children in place. I.e. empty. + workInProgress.child = null; + // Register a callback to retry this boundary once the server has sent the result. + registerSuspenseInstanceRetry( + suspenseInstance, + retryTimedOutBoundary$$1.bind(null, current$$1) + ); + return null; + } else { + // This is the first attempt. + reenterHydrationStateFromDehydratedSuspenseInstance(workInProgress); + var nextProps = workInProgress.pendingProps; + var nextChildren = nextProps.children; + workInProgress.child = mountChildFibers( + workInProgress, + null, + nextChildren, + renderExpirationTime + ); + return workInProgress.child; + } +} + function updatePortalComponent( current$$1, workInProgress, @@ -12489,31 +13358,80 @@ function updateContextConsumer( return workInProgress.child; } -function markWorkInProgressReceivedUpdate() { - didReceiveUpdate = true; -} - -function bailoutOnAlreadyFinishedWork( +function updateEventComponent$1( current$$1, workInProgress, renderExpirationTime ) { - cancelWorkTimer(workInProgress); + var nextProps = workInProgress.pendingProps; + var nextChildren = nextProps.children; - if (current$$1 !== null) { - // Reuse previous context list - workInProgress.contextDependencies = current$$1.contextDependencies; - } + reconcileChildren( + current$$1, + workInProgress, + nextChildren, + renderExpirationTime + ); + pushHostContextForEventComponent(workInProgress); + return workInProgress.child; +} - if (enableProfilerTimer) { - // Don't update "base" render times for bailouts. - stopProfilerTimerIfRunning(workInProgress); - } +function updateEventTarget(current$$1, workInProgress, renderExpirationTime) { + var type = workInProgress.type.type; + var nextProps = workInProgress.pendingProps; + var eventTargetChild = getEventTargetChildElement(type, nextProps); - // Check if the children have any pending work. - var childExpirationTime = workInProgress.childExpirationTime; - if (childExpirationTime < renderExpirationTime) { - // The children don't have any work either. We can skip them. + { + !(nextProps.children == null) + ? warning$1(false, "Event targets should not have children.") + : void 0; + } + if (eventTargetChild !== null) { + var child = (workInProgress.child = createFiberFromTypeAndProps( + eventTargetChild.type, + null, + eventTargetChild.props, + null, + workInProgress.mode, + renderExpirationTime + )); + child.return = workInProgress; + + if (current$$1 === null || current$$1.child === null) { + child.effectTag = Placement; + } + } else { + reconcileChildren(current$$1, workInProgress, null, renderExpirationTime); + } + pushHostContextForEventTarget(workInProgress); + return workInProgress.child; +} + +function markWorkInProgressReceivedUpdate() { + didReceiveUpdate = true; +} + +function bailoutOnAlreadyFinishedWork( + current$$1, + workInProgress, + renderExpirationTime +) { + cancelWorkTimer(workInProgress); + + if (current$$1 !== null) { + // Reuse previous context list + workInProgress.contextDependencies = current$$1.contextDependencies; + } + + if (enableProfilerTimer) { + // Don't update "base" render times for bailouts. + stopProfilerTimerIfRunning(workInProgress); + } + + // Check if the children have any pending work. + var childExpirationTime = workInProgress.childExpirationTime; + if (childExpirationTime < renderExpirationTime) { + // The children don't have any work either. We can skip them. // TODO: Once we add back resuming, we should check if the children are // a work-in-progress set. If so, we need to transfer their effects. return null; @@ -12612,6 +13530,26 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { } break; } + case DehydratedSuspenseComponent: { + if (enableSuspenseServerRenderer) { + // We know that this component will suspend again because if it has + // been unsuspended it has committed as a regular Suspense component. + // If it needs to be retried, it should have work scheduled on it. + workInProgress.effectTag |= DidCapture; + } + break; + } + case EventComponent: + if (enableEventAPI) { + pushHostContextForEventComponent(workInProgress); + } + break; + case EventTarget: { + if (enableEventAPI) { + pushHostContextForEventTarget(workInProgress); + } + break; + } } return bailoutOnAlreadyFinishedWork( current$$1, @@ -12785,13 +13723,44 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { renderExpirationTime ); } - default: - invariant( - false, - "Unknown unit of work tag. This error is likely caused by a bug in " + - "React. Please file an issue." - ); + case DehydratedSuspenseComponent: { + if (enableSuspenseServerRenderer) { + return updateDehydratedSuspenseComponent( + current$$1, + workInProgress, + renderExpirationTime + ); + } + break; + } + case EventComponent: { + if (enableEventAPI) { + return updateEventComponent$1( + current$$1, + workInProgress, + renderExpirationTime + ); + } + break; + } + case EventTarget: { + if (enableEventAPI) { + return updateEventTarget( + current$$1, + workInProgress, + renderExpirationTime + ); + } + break; + } } + (function() { + { + throw ReactError( + "Unknown unit of work tag. This error is likely caused by a bug in React. Please file an issue." + ); + } + })(); } var valueCursor = createCursor(null); @@ -12894,10 +13863,10 @@ function calculateChangedBits(context, newValue, oldValue) { var changedBits = typeof context._calculateChangedBits === "function" ? context._calculateChangedBits(oldValue, newValue) - : maxSigned31BitInt; + : MAX_SIGNED_31_BIT_INT; { - !((changedBits & maxSigned31BitInt) === changedBits) + !((changedBits & MAX_SIGNED_31_BIT_INT) === changedBits) ? warning$1( false, "calculateChangedBits: Expected the return value to be a " + @@ -12910,6 +13879,34 @@ function calculateChangedBits(context, newValue, oldValue) { } } +function scheduleWorkOnParentPath(parent, renderExpirationTime) { + // Update the child expiration time of all the ancestors, including + // the alternates. + var node = parent; + while (node !== null) { + var alternate = node.alternate; + if (node.childExpirationTime < renderExpirationTime) { + node.childExpirationTime = renderExpirationTime; + if ( + alternate !== null && + alternate.childExpirationTime < renderExpirationTime + ) { + alternate.childExpirationTime = renderExpirationTime; + } + } else if ( + alternate !== null && + alternate.childExpirationTime < renderExpirationTime + ) { + alternate.childExpirationTime = renderExpirationTime; + } else { + // Neither alternate was updated, which means the rest of the + // ancestor path already has sufficient priority. + break; + } + node = node.return; + } +} + function propagateContextChange( workInProgress, context, @@ -12959,31 +13956,8 @@ function propagateContextChange( ) { alternate.expirationTime = renderExpirationTime; } - // Update the child expiration time of all the ancestors, including - // the alternates. - var node = fiber.return; - while (node !== null) { - alternate = node.alternate; - if (node.childExpirationTime < renderExpirationTime) { - node.childExpirationTime = renderExpirationTime; - if ( - alternate !== null && - alternate.childExpirationTime < renderExpirationTime - ) { - alternate.childExpirationTime = renderExpirationTime; - } - } else if ( - alternate !== null && - alternate.childExpirationTime < renderExpirationTime - ) { - alternate.childExpirationTime = renderExpirationTime; - } else { - // Neither alternate was updated, which means the rest of the - // ancestor path already has sufficient priority. - break; - } - node = node.return; - } + + scheduleWorkOnParentPath(fiber.return, renderExpirationTime); // Mark the expiration time on the list, too. if (list.expirationTime < renderExpirationTime) { @@ -12999,6 +13973,29 @@ function propagateContextChange( } else if (fiber.tag === ContextProvider) { // Don't scan deeper if this is a matching provider nextFiber = fiber.type === workInProgress.type ? null : fiber.child; + } else if ( + enableSuspenseServerRenderer && + fiber.tag === DehydratedSuspenseComponent + ) { + // If a dehydrated suspense component is in this subtree, we don't know + // if it will have any context consumers in it. The best we can do is + // mark it as having updates on its children. + if (fiber.expirationTime < renderExpirationTime) { + fiber.expirationTime = renderExpirationTime; + } + var _alternate = fiber.alternate; + if ( + _alternate !== null && + _alternate.expirationTime < renderExpirationTime + ) { + _alternate.expirationTime = renderExpirationTime; + } + // This is intentionally passing this fiber as the parent + // because we want to schedule this fiber as having work + // on its children. We'll use the childExpirationTime on + // this fiber to indicate that a context has changed. + scheduleWorkOnParentPath(fiber, renderExpirationTime); + nextFiber = fiber.sibling; } else { // Traverse down. nextFiber = fiber.child; @@ -13072,11 +14069,11 @@ function readContext(context, observedBits) { var resolvedObservedBits = void 0; // Avoid deopting on observable arguments or heterogeneous types. if ( typeof observedBits !== "number" || - observedBits === maxSigned31BitInt + observedBits === MAX_SIGNED_31_BIT_INT ) { // Observe all updates. lastContextWithAllBitsObserved = context; - resolvedObservedBits = maxSigned31BitInt; + resolvedObservedBits = MAX_SIGNED_31_BIT_INT; } else { resolvedObservedBits = observedBits; } @@ -13088,13 +14085,13 @@ function readContext(context, observedBits) { }; if (lastContextDependency === null) { - invariant( - currentlyRenderingFiber !== null, - "Context can only be read while React is rendering. " + - "In classes, you can read it in the render method or getDerivedStateFromProps. " + - "In function components, you can read it directly in the function body, but not " + - "inside Hooks like useReducer() or useMemo()." - ); + (function() { + if (!(currentlyRenderingFiber !== null)) { + throw ReactError( + "Context can only be read while React is rendering. In classes, you can read it in the render method or getDerivedStateFromProps. In function components, you can read it directly in the function body, but not inside Hooks like useReducer() or useMemo()." + ); + } + })(); // This is the first dependency for this component. Create a new list. lastContextDependency = contextItem; @@ -13498,8 +14495,17 @@ function processUpdateQueue( newExpirationTime = updateExpirationTime; } } else { - // This update does have sufficient priority. Process it and compute - // a new result. + // This update does have sufficient priority. + + // Mark the event time of this update as relevant to this render pass. + // TODO: This should ideally use the true event time of this update rather than + // its priority which is a derived and not reverseable value. + // TODO: We should skip this update if it was already committed but currently + // we have no way of detecting the difference between a committed and suspended + // update here. + markRenderEventTime$$1(updateExpirationTime); + + // Process it and compute a new result. resultState = getStateFromUpdate( workInProgress, queue, @@ -13608,12 +14614,14 @@ function processUpdateQueue( } function callCallback(callback, context) { - invariant( - typeof callback === "function", - "Invalid argument passed as callback. Expected a function. Instead " + - "received: %s", - callback - ); + (function() { + if (!(typeof callback === "function")) { + throw ReactError( + "Invalid argument passed as callback. Expected a function. Instead received: " + + callback + ); + } + })(); callback.call(context); } @@ -13792,43 +14800,19 @@ if (supportsMutation) { // eslint-disable-next-line no-labels branches: if (node.tag === HostComponent) { var instance = node.stateNode; - if (needsVisibilityToggle) { + if (needsVisibilityToggle && isHidden) { + // This child is inside a timed out tree. Hide it. var props = node.memoizedProps; var type = node.type; - if (isHidden) { - // This child is inside a timed out tree. Hide it. - instance = cloneHiddenInstance(instance, type, props, node); - } else { - // This child was previously inside a timed out tree. If it was not - // updated during this render, it may need to be unhidden. Clone - // again to be sure. - instance = cloneUnhiddenInstance(instance, type, props, node); - } - node.stateNode = instance; + instance = cloneHiddenInstance(instance, type, props, node); } appendInitialChild(parent, instance); } else if (node.tag === HostText) { var _instance = node.stateNode; - if (needsVisibilityToggle) { + if (needsVisibilityToggle && isHidden) { + // This child is inside a timed out tree. Hide it. var text = node.memoizedProps; - var rootContainerInstance = getRootHostContainer(); - var currentHostContext = getHostContext(); - if (isHidden) { - _instance = createHiddenTextInstance( - text, - rootContainerInstance, - currentHostContext, - workInProgress - ); - } else { - _instance = createTextInstance( - text, - rootContainerInstance, - currentHostContext, - workInProgress - ); - } - node.stateNode = _instance; + _instance = cloneHiddenTextInstance(_instance, text, node); } appendInitialChild(parent, _instance); } else if (node.tag === HostPortal) { @@ -13836,22 +14820,28 @@ if (supportsMutation) { // down its children. Instead, we'll get insertions from each child in // the portal directly. } else if (node.tag === SuspenseComponent) { - var current = node.alternate; - if (current !== null) { - var oldState = current.memoizedState; - var newState = node.memoizedState; - var oldIsHidden = oldState !== null; - var newIsHidden = newState !== null; - if (oldIsHidden !== newIsHidden) { - // The placeholder either just timed out or switched back to the normal - // children after having previously timed out. Toggle the visibility of - // the direct host children. - var primaryChildParent = newIsHidden ? node.child : node; + if ((node.effectTag & Update) !== NoEffect) { + // Need to toggle the visibility of the primary children. + var newIsHidden = node.memoizedState !== null; + if (newIsHidden) { + var primaryChildParent = node.child; if (primaryChildParent !== null) { - appendAllChildren(parent, primaryChildParent, true, newIsHidden); + if (primaryChildParent.child !== null) { + primaryChildParent.child.return = primaryChildParent; + appendAllChildren( + parent, + primaryChildParent, + true, + newIsHidden + ); + } + var fallbackChildParent = primaryChildParent.sibling; + if (fallbackChildParent !== null) { + fallbackChildParent.return = node; + node = fallbackChildParent; + continue; + } } - // eslint-disable-next-line no-labels - break branches; } } if (node.child !== null) { @@ -13895,43 +14885,19 @@ if (supportsMutation) { // eslint-disable-next-line no-labels branches: if (node.tag === HostComponent) { var instance = node.stateNode; - if (needsVisibilityToggle) { + if (needsVisibilityToggle && isHidden) { + // This child is inside a timed out tree. Hide it. var props = node.memoizedProps; var type = node.type; - if (isHidden) { - // This child is inside a timed out tree. Hide it. - instance = cloneHiddenInstance(instance, type, props, node); - } else { - // This child was previously inside a timed out tree. If it was not - // updated during this render, it may need to be unhidden. Clone - // again to be sure. - instance = cloneUnhiddenInstance(instance, type, props, node); - } - node.stateNode = instance; + instance = cloneHiddenInstance(instance, type, props, node); } appendChildToContainerChildSet(containerChildSet, instance); } else if (node.tag === HostText) { var _instance2 = node.stateNode; - if (needsVisibilityToggle) { + if (needsVisibilityToggle && isHidden) { + // This child is inside a timed out tree. Hide it. var text = node.memoizedProps; - var rootContainerInstance = getRootHostContainer(); - var currentHostContext = getHostContext(); - if (isHidden) { - _instance2 = createHiddenTextInstance( - text, - rootContainerInstance, - currentHostContext, - workInProgress - ); - } else { - _instance2 = createTextInstance( - text, - rootContainerInstance, - currentHostContext, - workInProgress - ); - } - node.stateNode = _instance2; + _instance2 = cloneHiddenTextInstance(_instance2, text, node); } appendChildToContainerChildSet(containerChildSet, _instance2); } else if (node.tag === HostPortal) { @@ -13939,27 +14905,28 @@ if (supportsMutation) { // down its children. Instead, we'll get insertions from each child in // the portal directly. } else if (node.tag === SuspenseComponent) { - var current = node.alternate; - if (current !== null) { - var oldState = current.memoizedState; - var newState = node.memoizedState; - var oldIsHidden = oldState !== null; - var newIsHidden = newState !== null; - if (oldIsHidden !== newIsHidden) { - // The placeholder either just timed out or switched back to the normal - // children after having previously timed out. Toggle the visibility of - // the direct host children. - var primaryChildParent = newIsHidden ? node.child : node; + if ((node.effectTag & Update) !== NoEffect) { + // Need to toggle the visibility of the primary children. + var newIsHidden = node.memoizedState !== null; + if (newIsHidden) { + var primaryChildParent = node.child; if (primaryChildParent !== null) { - appendAllChildrenToContainer( - containerChildSet, - primaryChildParent, - true, - newIsHidden - ); + if (primaryChildParent.child !== null) { + primaryChildParent.child.return = primaryChildParent; + appendAllChildrenToContainer( + containerChildSet, + primaryChildParent, + true, + newIsHidden + ); + } + var fallbackChildParent = primaryChildParent.sibling; + if (fallbackChildParent !== null) { + fallbackChildParent.return = node; + node = fallbackChildParent; + continue; + } } - // eslint-disable-next-line no-labels - break branches; } } if (node.child !== null) { @@ -14163,11 +15130,13 @@ function completeWork(current, workInProgress, renderExpirationTime) { } } else { if (!newProps) { - invariant( - workInProgress.stateNode !== null, - "We must have new props for new mounts. This error is likely " + - "caused by a bug in React. Please file an issue." - ); + (function() { + if (!(workInProgress.stateNode !== null)) { + throw ReactError( + "We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue." + ); + } + })(); // This can happen when we abort work. break; } @@ -14236,11 +15205,13 @@ function completeWork(current, workInProgress, renderExpirationTime) { updateHostText$1(current, workInProgress, oldText, newText); } else { if (typeof newText !== "string") { - invariant( - workInProgress.stateNode !== null, - "We must have new props for new mounts. This error is likely " + - "caused by a bug in React. Please file an issue." - ); + (function() { + if (!(workInProgress.stateNode !== null)) { + throw ReactError( + "We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue." + ); + } + })(); // This can happen when we abort work. } var _rootContainerInstance = getRootHostContainer(); @@ -14273,32 +15244,72 @@ function completeWork(current, workInProgress, renderExpirationTime) { } var nextDidTimeout = nextState !== null; - var prevDidTimeout = current !== null && current.memoizedState !== null; - - if (current !== null && !nextDidTimeout && prevDidTimeout) { - // We just switched from the fallback to the normal children. Delete - // the fallback. - // TODO: Would it be better to store the fallback fragment on - var currentFallbackChild = current.child.sibling; - if (currentFallbackChild !== null) { - // Deletions go at the beginning of the return fiber's effect list - var first = workInProgress.firstEffect; - if (first !== null) { - workInProgress.firstEffect = currentFallbackChild; - currentFallbackChild.nextEffect = first; - } else { - workInProgress.firstEffect = workInProgress.lastEffect = currentFallbackChild; - currentFallbackChild.nextEffect = null; + var prevDidTimeout = false; + if (current === null) { + // In cases where we didn't find a suitable hydration boundary we never + // downgraded this to a DehydratedSuspenseComponent, but we still need to + // pop the hydration state since we might be inside the insertion tree. + popHydrationState(workInProgress); + } else { + var prevState = current.memoizedState; + prevDidTimeout = prevState !== null; + if (!nextDidTimeout && prevState !== null) { + // We just switched from the fallback to the normal children. + + // Mark the event time of the switching from fallback to normal children, + // based on the start of when we first showed the fallback. This time + var fallbackExpirationTimeExpTime = prevState.fallbackExpirationTime; + markRenderEventTime$$1(fallbackExpirationTimeExpTime); + + // Delete the fallback. + // TODO: Would it be better to store the fallback fragment on + // the stateNode during the begin phase? + var currentFallbackChild = current.child.sibling; + if (currentFallbackChild !== null) { + // Deletions go at the beginning of the return fiber's effect list + var first = workInProgress.firstEffect; + if (first !== null) { + workInProgress.firstEffect = currentFallbackChild; + currentFallbackChild.nextEffect = first; + } else { + workInProgress.firstEffect = workInProgress.lastEffect = currentFallbackChild; + currentFallbackChild.nextEffect = null; + } + currentFallbackChild.effectTag = Deletion; } - currentFallbackChild.effectTag = Deletion; } } - if (nextDidTimeout || prevDidTimeout) { - // If the children are hidden, or if they were previous hidden, schedule - // an effect to toggle their visibility. This is also used to attach a - // retry listener to the promise. - workInProgress.effectTag |= Update; + if (nextDidTimeout && !prevDidTimeout) { + // If this subtreee is running in concurrent mode we can suspend, + // otherwise we won't suspend. + // TODO: This will still suspend a synchronous tree if anything + // in the concurrent tree already suspended during this render. + // This is a known bug. + if ((workInProgress.mode & ConcurrentMode) !== NoContext) { + renderDidSuspend$$1(); + } + } + + if (supportsPersistence) { + // TODO: Only schedule updates if not prevDidTimeout. + if (nextDidTimeout) { + // If this boundary just timed out, schedule an effect to attach a + // retry listener to the proimse. This flag is also used to hide the + // primary children. + workInProgress.effectTag |= Update; + } + } + if (supportsMutation) { + // TODO: Only schedule updates if these values are non equal, i.e. it changed. + if (nextDidTimeout || prevDidTimeout) { + // If this boundary just timed out, schedule an effect to attach a + // retry listener to the proimse. This flag is also used to hide the + // primary children. In mutation mode, we also need the flag to + // *unhide* children that were previously hidden, so check if the + // is currently timed out, too. + workInProgress.effectTag |= Update; + } } break; } @@ -14329,12 +15340,86 @@ function completeWork(current, workInProgress, renderExpirationTime) { } break; } + case DehydratedSuspenseComponent: { + if (enableSuspenseServerRenderer) { + if (current === null) { + var _wasHydrated2 = popHydrationState(workInProgress); + (function() { + if (!_wasHydrated2) { + throw ReactError( + "A dehydrated suspense component was completed without a hydrated node. This is probably a bug in React." + ); + } + })(); + skipPastDehydratedSuspenseInstance(workInProgress); + } else if ((workInProgress.effectTag & DidCapture) === NoEffect) { + // This boundary did not suspend so it's now hydrated. + // To handle any future suspense cases, we're going to now upgrade it + // to a Suspense component. We detach it from the existing current fiber. + current.alternate = null; + workInProgress.alternate = null; + workInProgress.tag = SuspenseComponent; + workInProgress.memoizedState = null; + workInProgress.stateNode = null; + } + } + break; + } + case EventComponent: { + if (enableEventAPI) { + popHostContext(workInProgress); + var _rootContainerInstance2 = getRootHostContainer(); + var responder = workInProgress.type.responder; + var eventComponentInstance = workInProgress.stateNode; + + if (eventComponentInstance === null) { + var responderState = null; + if (responder.createInitialState !== undefined) { + responderState = responder.createInitialState(newProps); + } + eventComponentInstance = workInProgress.stateNode = { + context: null, + props: newProps, + responder: responder, + rootInstance: _rootContainerInstance2, + state: responderState + }; + mountEventComponent(eventComponentInstance); + } else { + // Update the props on the event component state node + eventComponentInstance.props = newProps; + // Update the root container, so we can properly unmount events at some point + eventComponentInstance.rootInstance = _rootContainerInstance2; + updateEventComponent(eventComponentInstance); + } + } + break; + } + case EventTarget: { + if (enableEventAPI) { + popHostContext(workInProgress); + var _type = workInProgress.type.type; + var _rootContainerInstance3 = getRootHostContainer(); + var shouldUpdate = handleEventTarget( + _type, + newProps, + _rootContainerInstance3, + workInProgress + ); + if (shouldUpdate) { + markUpdate(workInProgress); + } + } + break; + } default: - invariant( - false, - "Unknown unit of work tag. This error is likely caused by a bug in " + - "React. Please file an issue." - ); + (function() { + { + throw ReactError( + "Unknown unit of work tag. This error is likely caused by a bug in React. Please file an issue." + ); + } + })(); } return null; @@ -14472,7 +15557,7 @@ var didWarnAboutUndefinedSnapshotBeforeUpdate = null; didWarnAboutUndefinedSnapshotBeforeUpdate = new Set(); } -var PossiblyWeakSet = typeof WeakSet === "function" ? WeakSet : Set; +var PossiblyWeakSet$1 = typeof WeakSet === "function" ? WeakSet : Set; function logError(boundary, errorInfo) { var source = errorInfo.source; @@ -14531,7 +15616,7 @@ function safelyCallComponentWillUnmount(current$$1, instance) { ); if (hasCaughtError()) { var unmountError = clearCaughtError(); - captureCommitPhaseError(current$$1, unmountError); + captureCommitPhaseError$$1(current$$1, unmountError); } } } @@ -14544,7 +15629,7 @@ function safelyDetachRef(current$$1) { invokeGuardedCallback(null, ref, null, null); if (hasCaughtError()) { var refError = clearCaughtError(); - captureCommitPhaseError(current$$1, refError); + captureCommitPhaseError$$1(current$$1, refError); } } } else { @@ -14558,7 +15643,7 @@ function safelyCallDestroy(current$$1, destroy) { invokeGuardedCallback(null, destroy, null); if (hasCaughtError()) { var error = clearCaughtError(); - captureCommitPhaseError(current$$1, error); + captureCommitPhaseError$$1(current$$1, error); } } } @@ -14639,14 +15724,17 @@ function commitBeforeMutationLifeCycles(current$$1, finishedWork) { case HostText: case HostPortal: case IncompleteClassComponent: + case EventTarget: // Nothing to do for these component types return; default: { - invariant( - false, - "This unit of work tag should not have side-effects. This error is " + - "likely caused by a bug in React. Please file an issue." - ); + (function() { + { + throw ReactError( + "This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue." + ); + } + })(); } } } @@ -14682,22 +15770,23 @@ function commitHookEffectList(unmountTag, mountTag, finishedWork) { } else if (typeof _destroy.then === "function") { addendum = "\n\nIt looks like you wrote useEffect(async () => ...) or returned a Promise. " + - "Instead, you may write an async function separately " + - "and then call it from inside the effect:\n\n" + - "async function fetchComment(commentId) {\n" + - " // You can await here\n" + - "}\n\n" + + "Instead, write the async function inside your effect " + + "and call it immediately:\n\n" + "useEffect(() => {\n" + - " fetchComment(commentId);\n" + - "}, [commentId]);\n\n" + - "In the future, React will provide a more idiomatic solution for data fetching " + - "that doesn't involve writing effects manually."; + " async function fetchData() {\n" + + " // You can await here\n" + + " const response = await MyAPI.getData(someId);\n" + + " // ...\n" + + " }\n" + + " fetchData();\n" + + "}, [someId]); // Or [] if effect doesn't need props or state\n\n" + + "Learn more about data fetching with Hooks: https://fb.me/react-hooks-data-fetching"; } else { addendum = " You returned: " + _destroy; } warningWithoutStack$1( false, - "An Effect function must not return anything besides a function, " + + "An effect function must not return anything besides a function, " + "which is used for clean-up.%s%s", addendum, getStackByFiberInDevAndProd(finishedWork) @@ -14933,15 +16022,17 @@ function commitLifeCycles( return; } case SuspenseComponent: - break; case IncompleteClassComponent: + case EventTarget: break; default: { - invariant( - false, - "This unit of work tag should not have side-effects. This error is " + - "likely caused by a bug in React. Please file an issue." - ); + (function() { + { + throw ReactError( + "This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue." + ); + } + })(); } } } @@ -15088,6 +16179,13 @@ function commitUnmount(current$$1) { } return; } + case EventComponent: { + if (enableEventAPI) { + var eventComponentInstance = current$$1.stateNode; + unmountEventComponent(eventComponentInstance); + current$$1.stateNode = null; + } + } } } @@ -15162,13 +16260,10 @@ function commitContainer(finishedWork) { } switch (finishedWork.tag) { - case ClassComponent: { - return; - } - case HostComponent: { - return; - } - case HostText: { + case ClassComponent: + case HostComponent: + case HostText: + case EventTarget: { return; } case HostRoot: @@ -15181,11 +16276,13 @@ function commitContainer(finishedWork) { return; } default: { - invariant( - false, - "This unit of work tag should not have side-effects. This error is " + - "likely caused by a bug in React. Please file an issue." - ); + (function() { + { + throw ReactError( + "This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue." + ); + } + })(); } } } @@ -15198,11 +16295,13 @@ function getHostParentFiber(fiber) { } parent = parent.return; } - invariant( - false, - "Expected to find a host parent. This error is likely caused by a bug " + - "in React. Please file an issue." - ); + (function() { + { + throw ReactError( + "Expected to find a host parent. This error is likely caused by a bug in React. Please file an issue." + ); + } + })(); } function isHostParent(fiber) { @@ -15230,7 +16329,11 @@ function getHostSibling(fiber) { } node.sibling.return = node.return; node = node.sibling; - while (node.tag !== HostComponent && node.tag !== HostText) { + while ( + node.tag !== HostComponent && + node.tag !== HostText && + node.tag !== DehydratedSuspenseComponent + ) { // If it is not host node and, we might have a host node inside it. // Try to search down until we find one. if (node.effectTag & Placement) { @@ -15280,11 +16383,13 @@ function commitPlacement(finishedWork) { isContainer = true; break; default: - invariant( - false, - "Invalid host parent fiber. This error is likely caused by a bug " + - "in React. Please file an issue." - ); + (function() { + { + throw ReactError( + "Invalid host parent fiber. This error is likely caused by a bug in React. Please file an issue." + ); + } + })(); } if (parentFiber.effectTag & ContentReset) { // Reset the text content of the parent before doing any insertions @@ -15297,17 +16402,18 @@ function commitPlacement(finishedWork) { var node = finishedWork; while (true) { if (node.tag === HostComponent || node.tag === HostText) { + var stateNode = node.stateNode; if (before) { if (isContainer) { - insertInContainerBefore(parent, node.stateNode, before); + insertInContainerBefore(parent, stateNode, before); } else { - insertBefore(parent, node.stateNode, before); + insertBefore(parent, stateNode, before); } } else { if (isContainer) { - appendChildToContainer(parent, node.stateNode); + appendChildToContainer(parent, stateNode); } else { - appendChild(parent, node.stateNode); + appendChild(parent, stateNode); } } } else if (node.tag === HostPortal) { @@ -15349,11 +16455,13 @@ function unmountHostComponents(current$$1) { if (!currentParentIsValid) { var parent = node.return; findParent: while (true) { - invariant( - parent !== null, - "Expected to find a host parent. This error is likely caused by " + - "a bug in React. Please file an issue." - ); + (function() { + if (!(parent !== null)) { + throw ReactError( + "Expected to find a host parent. This error is likely caused by a bug in React. Please file an issue." + ); + } + })(); switch (parent.tag) { case HostComponent: currentParent = parent.stateNode; @@ -15383,6 +16491,16 @@ function unmountHostComponents(current$$1) { removeChild(currentParent, node.stateNode); } // Don't visit children because we already visited them. + } else if ( + enableSuspenseServerRenderer && + node.tag === DehydratedSuspenseComponent + ) { + // Delete the dehydrated suspense boundary and all of its content. + if (currentParentIsContainer) { + clearSuspenseBoundaryFromContainer(currentParent, node.stateNode); + } else { + clearSuspenseBoundary(currentParent, node.stateNode); + } } else if (node.tag === HostPortal) { if (node.child !== null) { // When we go into a portal, it becomes the parent to remove from. @@ -15446,6 +16564,13 @@ function commitWork(current$$1, finishedWork) { commitHookEffectList(UnmountMutation, MountMutation, finishedWork); return; } + case Profiler: { + return; + } + case SuspenseComponent: { + commitSuspenseComponent(finishedWork); + return; + } } commitContainer(finishedWork); @@ -15493,11 +16618,13 @@ function commitWork(current$$1, finishedWork) { return; } case HostText: { - invariant( - finishedWork.stateNode !== null, - "This should have a text node initialized. This error is likely " + - "caused by a bug in React. Please file an issue." - ); + (function() { + if (!(finishedWork.stateNode !== null)) { + throw ReactError( + "This should have a text node initialized. This error is likely caused by a bug in React. Please file an issue." + ); + } + })(); var textInstance = finishedWork.stateNode; var newText = finishedWork.memoizedProps; // For hydration we reuse the update path but we treat the oldProps @@ -15507,6 +16634,36 @@ function commitWork(current$$1, finishedWork) { commitTextUpdate(textInstance, oldText, newText); return; } + case EventTarget: { + if (enableEventAPI) { + var _type = finishedWork.type.type; + var props = finishedWork.memoizedProps; + var _instance4 = finishedWork.stateNode; + var parentInstance = null; + + var node = finishedWork.return; + // Traverse up the fiber tree until we find the parent host node. + while (node !== null) { + if (node.tag === HostComponent) { + parentInstance = node.stateNode; + break; + } else if (node.tag === HostRoot) { + parentInstance = node.stateNode.containerInfo; + break; + } + node = node.return; + } + (function() { + if (!(parentInstance !== null)) { + throw ReactError( + "This should have a parent host component initialized. This error is likely caused by a bug in React. Please file an issue." + ); + } + })(); + commitEventTarget(_type, props, _instance4, parentInstance); + } + return; + } case HostRoot: { return; } @@ -15514,63 +16671,72 @@ function commitWork(current$$1, finishedWork) { return; } case SuspenseComponent: { - var newState = finishedWork.memoizedState; - - var newDidTimeout = void 0; - var primaryChildParent = finishedWork; - if (newState === null) { - newDidTimeout = false; - } else { - newDidTimeout = true; - primaryChildParent = finishedWork.child; - if (newState.timedOutAt === NoWork) { - // If the children had not already timed out, record the time. - // This is used to compute the elapsed time during subsequent - // attempts to render the children. - newState.timedOutAt = requestCurrentTime(); - } - } - - if (primaryChildParent !== null) { - hideOrUnhideAllChildren(primaryChildParent, newDidTimeout); - } - - // If this boundary just timed out, then it will have a set of thenables. - // For each thenable, attach a listener so that when it resolves, React - // attempts to re-render the boundary in the primary (pre-timeout) state. - var thenables = finishedWork.updateQueue; - if (thenables !== null) { - finishedWork.updateQueue = null; - var retryCache = finishedWork.stateNode; - if (retryCache === null) { - retryCache = finishedWork.stateNode = new PossiblyWeakSet(); - } - thenables.forEach(function(thenable) { - // Memoize using the boundary fiber to prevent redundant listeners. - var retry = retryTimedOutBoundary.bind(null, finishedWork, thenable); - if (enableSchedulerTracing) { - retry = tracing.unstable_wrap(retry); - } - if (!retryCache.has(thenable)) { - retryCache.add(thenable); - thenable.then(retry, retry); - } - }); - } - + commitSuspenseComponent(finishedWork); return; } case IncompleteClassComponent: { return; } default: { - invariant( - false, - "This unit of work tag should not have side-effects. This error is " + - "likely caused by a bug in React. Please file an issue." + (function() { + { + throw ReactError( + "This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue." + ); + } + })(); + } + } +} + +function commitSuspenseComponent(finishedWork) { + var newState = finishedWork.memoizedState; + + var newDidTimeout = void 0; + var primaryChildParent = finishedWork; + if (newState === null) { + newDidTimeout = false; + } else { + newDidTimeout = true; + primaryChildParent = finishedWork.child; + if (newState.fallbackExpirationTime === NoWork) { + // If the children had not already timed out, record the time. + // This is used to compute the elapsed time during subsequent + // attempts to render the children. + // We model this as a normal pri expiration time since that's + // how we infer start time for updates. + newState.fallbackExpirationTime = computeAsyncExpirationNoBucket( + requestCurrentTime$$1() ); } } + + if (supportsMutation && primaryChildParent !== null) { + hideOrUnhideAllChildren(primaryChildParent, newDidTimeout); + } + + // If this boundary just timed out, then it will have a set of thenables. + // For each thenable, attach a listener so that when it resolves, React + // attempts to re-render the boundary in the primary (pre-timeout) state. + var thenables = finishedWork.updateQueue; + if (thenables !== null) { + finishedWork.updateQueue = null; + var retryCache = finishedWork.stateNode; + if (retryCache === null) { + retryCache = finishedWork.stateNode = new PossiblyWeakSet$1(); + } + thenables.forEach(function(thenable) { + // Memoize using the boundary fiber to prevent redundant listeners. + var retry = resolveRetryThenable$$1.bind(null, finishedWork, thenable); + if (enableSchedulerTracing) { + retry = tracing.unstable_wrap(retry); + } + if (!retryCache.has(thenable)) { + retryCache.add(thenable); + thenable.then(retry, retry); + } + }); + } } function commitResetTextContent(current$$1) { @@ -15580,6 +16746,7 @@ function commitResetTextContent(current$$1) { resetTextContent(current$$1.stateNode); } +var PossiblyWeakSet = typeof WeakSet === "function" ? WeakSet : Set; var PossiblyWeakMap = typeof WeakMap === "function" ? WeakMap : Map; function createRootErrorUpdate(fiber, errorInfo, expirationTime) { @@ -15591,7 +16758,7 @@ function createRootErrorUpdate(fiber, errorInfo, expirationTime) { update.payload = { element: null }; var error = errorInfo.value; update.callback = function() { - onUncaughtError(error); + onUncaughtError$$1(error); logError(fiber, errorInfo); }; return update; @@ -15617,7 +16784,7 @@ function createClassErrorUpdate(fiber, errorInfo, expirationTime) { // This gets reset before we yield back to the browser. // TODO: Warn in strict mode if getDerivedStateFromError is // not defined. - markLegacyErrorBoundaryAsFailed(this); + markLegacyErrorBoundaryAsFailed$$1(this); } var error = errorInfo.value; var stack = errorInfo.stack; @@ -15645,6 +16812,39 @@ function createClassErrorUpdate(fiber, errorInfo, expirationTime) { return update; } +function attachPingListener(root, renderExpirationTime, thenable) { + // Attach a listener to the promise to "ping" the root and retry. But + // only if one does not already exist for the current render expiration + // time (which acts like a "thread ID" here). + var pingCache = root.pingCache; + var threadIDs = void 0; + if (pingCache === null) { + pingCache = root.pingCache = new PossiblyWeakMap(); + threadIDs = new Set(); + pingCache.set(thenable, threadIDs); + } else { + threadIDs = pingCache.get(thenable); + if (threadIDs === undefined) { + threadIDs = new Set(); + pingCache.set(thenable, threadIDs); + } + } + if (!threadIDs.has(renderExpirationTime)) { + // Memoize using the thread ID to prevent redundant listeners. + threadIDs.add(renderExpirationTime); + var ping = pingSuspendedRoot$$1.bind( + null, + root, + thenable, + renderExpirationTime + ); + if (enableSchedulerTracing) { + ping = tracing.unstable_wrap(ping); + } + thenable.then(ping, ping); + } +} + function throwException( root, returnFiber, @@ -15665,45 +16865,8 @@ function throwException( // This is a thenable. var thenable = value; - // Find the earliest timeout threshold of all the placeholders in the - // ancestor path. We could avoid this traversal by storing the thresholds on - // the stack, but we choose not to because we only hit this path if we're - // IO-bound (i.e. if something suspends). Whereas the stack is used even in - // the non-IO- bound case. - var _workInProgress = returnFiber; - var earliestTimeoutMs = -1; - var startTimeMs = -1; - do { - if (_workInProgress.tag === SuspenseComponent) { - var current$$1 = _workInProgress.alternate; - if (current$$1 !== null) { - var currentState = current$$1.memoizedState; - if (currentState !== null) { - // Reached a boundary that already timed out. Do not search - // any further. - var timedOutAt = currentState.timedOutAt; - startTimeMs = expirationTimeToMs(timedOutAt); - // Do not search any further. - break; - } - } - var timeoutPropMs = _workInProgress.pendingProps.maxDuration; - if (typeof timeoutPropMs === "number") { - if (timeoutPropMs <= 0) { - earliestTimeoutMs = 0; - } else if ( - earliestTimeoutMs === -1 || - timeoutPropMs < earliestTimeoutMs - ) { - earliestTimeoutMs = timeoutPropMs; - } - } - } - _workInProgress = _workInProgress.return; - } while (_workInProgress !== null); - // Schedule the nearest Suspense to re-render the timed out view. - _workInProgress = returnFiber; + var _workInProgress = returnFiber; do { if ( _workInProgress.tag === SuspenseComponent && @@ -15729,7 +16892,7 @@ function throwException( // Note: It doesn't matter whether the component that suspended was // inside a concurrent mode tree. If the Suspense is outside of it, we // should *not* suspend the commit. - if ((_workInProgress.mode & ConcurrentMode) === NoEffect) { + if ((_workInProgress.mode & ConcurrentMode) === NoContext) { _workInProgress.effectTag |= DidCapture; // We're going to commit this fiber even though it didn't complete. @@ -15765,72 +16928,44 @@ function throwException( // Confirmed that the boundary is in a concurrent mode tree. Continue // with the normal suspend path. - // Attach a listener to the promise to "ping" the root and retry. But - // only if one does not already exist for the current render expiration - // time (which acts like a "thread ID" here). - var pingCache = root.pingCache; - var threadIDs = void 0; - if (pingCache === null) { - pingCache = root.pingCache = new PossiblyWeakMap(); - threadIDs = new Set(); - pingCache.set(thenable, threadIDs); - } else { - threadIDs = pingCache.get(thenable); - if (threadIDs === undefined) { - threadIDs = new Set(); - pingCache.set(thenable, threadIDs); - } + attachPingListener(root, renderExpirationTime, thenable); + + _workInProgress.effectTag |= ShouldCapture; + _workInProgress.expirationTime = renderExpirationTime; + return; + } else if ( + enableSuspenseServerRenderer && + _workInProgress.tag === DehydratedSuspenseComponent + ) { + attachPingListener(root, renderExpirationTime, thenable); + + // Since we already have a current fiber, we can eagerly add a retry listener. + var retryCache = _workInProgress.memoizedState; + if (retryCache === null) { + retryCache = _workInProgress.memoizedState = new PossiblyWeakSet(); + var current$$1 = _workInProgress.alternate; + (function() { + if (!current$$1) { + throw ReactError( + "A dehydrated suspense boundary must commit before trying to render. This is probably a bug in React." + ); + } + })(); + current$$1.memoizedState = retryCache; } - if (!threadIDs.has(renderExpirationTime)) { - // Memoize using the thread ID to prevent redundant listeners. - threadIDs.add(renderExpirationTime); - var ping = pingSuspendedRoot.bind( + // Memoize using the boundary fiber to prevent redundant listeners. + if (!retryCache.has(thenable)) { + retryCache.add(thenable); + var retry = resolveRetryThenable$$1.bind( null, - root, - thenable, - renderExpirationTime + _workInProgress, + thenable ); if (enableSchedulerTracing) { - ping = tracing.unstable_wrap(ping); - } - thenable.then(ping, ping); - } - - var absoluteTimeoutMs = void 0; - if (earliestTimeoutMs === -1) { - // If no explicit threshold is given, default to an arbitrarily large - // value. The actual size doesn't matter because the threshold for the - // whole tree will be clamped to the expiration time. - absoluteTimeoutMs = maxSigned31BitInt; - } else { - if (startTimeMs === -1) { - // This suspend happened outside of any already timed-out - // placeholders. We don't know exactly when the update was - // scheduled, but we can infer an approximate start time from the - // expiration time. First, find the earliest uncommitted expiration - // time in the tree, including work that is suspended. Then subtract - // the offset used to compute an async update's expiration time. - // This will cause high priority (interactive) work to expire - // earlier than necessary, but we can account for this by adjusting - // for the Just Noticeable Difference. - var earliestExpirationTime = findEarliestOutstandingPriorityLevel( - root, - renderExpirationTime - ); - var earliestExpirationTimeMs = expirationTimeToMs( - earliestExpirationTime - ); - startTimeMs = earliestExpirationTimeMs - LOW_PRIORITY_EXPIRATION; + retry = tracing.unstable_wrap(retry); } - absoluteTimeoutMs = startTimeMs + earliestTimeoutMs; + thenable.then(retry, retry); } - - // Mark the earliest timeout in the suspended fiber's ancestor path. - // After completing the root, we'll take the largest of all the - // suspended fiber's timeouts and use it to compute a timeout for the - // whole tree. - renderDidSuspend(root, absoluteTimeoutMs, renderExpirationTime); - _workInProgress.effectTag |= ShouldCapture; _workInProgress.expirationTime = renderExpirationTime; return; @@ -15854,7 +16989,7 @@ function throwException( // We didn't find a boundary that could handle this type of exception. Start // over and traverse parent path again, this time treating the exception // as an error. - renderDidError(); + renderDidError$$1(); value = createCapturedValue(value, sourceFiber); var workInProgress = returnFiber; do { @@ -15881,7 +17016,7 @@ function throwException( (typeof ctor.getDerivedStateFromError === "function" || (instance !== null && typeof instance.componentDidCatch === "function" && - !isAlreadyFailedLegacyErrorBoundary(instance))) + !isAlreadyFailedLegacyErrorBoundary$$1(instance))) ) { workInProgress.effectTag |= ShouldCapture; workInProgress.expirationTime = renderExpirationTime; @@ -15920,15 +17055,18 @@ function unwindWork(workInProgress, renderExpirationTime) { popHostContainer(workInProgress); popTopLevelContextObject(workInProgress); var _effectTag = workInProgress.effectTag; - invariant( - (_effectTag & DidCapture) === NoEffect, - "The root failed to unmount after an error. This is likely a bug in " + - "React. Please file an issue." - ); + (function() { + if (!((_effectTag & DidCapture) === NoEffect)) { + throw ReactError( + "The root failed to unmount after an error. This is likely a bug in React. Please file an issue." + ); + } + })(); workInProgress.effectTag = (_effectTag & ~ShouldCapture) | DidCapture; return workInProgress; } case HostComponent: { + // TODO: popHydrationState popHostContext(workInProgress); return null; } @@ -15941,12 +17079,31 @@ function unwindWork(workInProgress, renderExpirationTime) { } return null; } + case DehydratedSuspenseComponent: { + if (enableSuspenseServerRenderer) { + // TODO: popHydrationState + var _effectTag3 = workInProgress.effectTag; + if (_effectTag3 & ShouldCapture) { + workInProgress.effectTag = + (_effectTag3 & ~ShouldCapture) | DidCapture; + // Captured a suspense effect. Re-render the boundary. + return workInProgress; + } + } + return null; + } case HostPortal: popHostContainer(workInProgress); return null; case ContextProvider: popProvider(workInProgress); return null; + case EventComponent: + case EventTarget: + if (enableEventAPI) { + popHostContext(workInProgress); + } + return null; default: return null; } @@ -15981,8 +17138,20 @@ function unwindInterruptedWork(interruptedWork) { } } +// Intentionally not named imports because Rollup would use dynamic dispatch for +// CommonJS interop named imports. +// Intentionally not named imports because Rollup would use dynamic dispatch for +// CommonJS interop named imports. +var scheduleCallback$1 = Scheduler.unstable_scheduleCallback; +var cancelCallback$1 = Scheduler.unstable_cancelCallback; +var shouldYield$1 = Scheduler.unstable_shouldYield; +var now$1 = Scheduler.unstable_now; +var getCurrentPriorityLevel$1 = Scheduler.unstable_getCurrentPriorityLevel; +var NormalPriority$1 = Scheduler.unstable_NormalPriority; var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher; var ReactCurrentOwner$2 = ReactSharedInternals.ReactCurrentOwner; +var ReactShouldWarnActingUpdates = + ReactSharedInternals.ReactShouldWarnActingUpdates; var didWarnAboutStateTransition = void 0; var didWarnSetStateChildContext = void 0; @@ -15992,14 +17161,18 @@ var warnAboutInvalidUpdates = void 0; if (enableSchedulerTracing) { // Provide explicit error message when production+profiling bundle of e.g. react-dom // is used with production (non-profiling) bundle of scheduler/tracing - invariant( - tracing.__interactionsRef != null && - tracing.__interactionsRef.current != null, - "It is not supported to run the profiling version of a renderer (for example, `react-dom/profiling`) " + - "without also replacing the `scheduler/tracing` module with `scheduler/tracing-profiling`. " + - "Your bundler might have a setting for aliasing both modules. " + - "Learn more at http://fb.me/react-profiling" - ); + (function() { + if ( + !( + tracing.__interactionsRef != null && + tracing.__interactionsRef.current != null + ) + ) { + throw ReactError( + "It is not supported to run the profiling version of a renderer (for example, `react-dom/profiling`) without also replacing the `scheduler/tracing` module with `scheduler/tracing-profiling`. Your bundler might have a setting for aliasing both modules. Learn more at http://fb.me/react-profiling" + ); + } + })(); } { @@ -16054,6 +17227,11 @@ if (enableSchedulerTracing) { }; } +// Represents the expiration time that incoming updates should use. (If this +// is NoWork, use the default strategy: async updates in async mode, sync +// updates in sync mode.) +var expirationContext = NoWork; + var isWorking = false; // The next work in progress fiber that we're currently working on. @@ -16061,7 +17239,8 @@ var nextUnitOfWork = null; var nextRoot = null; // The time at which we're currently rendering work. var nextRenderExpirationTime = NoWork; -var nextLatestAbsoluteTimeoutMs = -1; +var mostRecentEventTime = Sync; +var nextRenderDidSuspend = false; var nextRenderDidError = false; // The next fiber with an effect that we're currently committing. @@ -16184,7 +17363,8 @@ function resetStack() { nextRoot = null; nextRenderExpirationTime = NoWork; - nextLatestAbsoluteTimeoutMs = -1; + mostRecentEventTime = Sync; + nextRenderDidSuspend = false; nextRenderDidError = false; nextUnitOfWork = null; } @@ -16337,14 +17517,16 @@ function commitPassiveEffects(root, firstEffect) { var didError = false; var error = void 0; { + isInPassiveEffectDEV = true; invokeGuardedCallback(null, commitPassiveHookEffects, null, effect); + isInPassiveEffectDEV = false; if (hasCaughtError()) { didError = true; error = clearCaughtError(); } } if (didError) { - captureCommitPhaseError(effect, error); + captureCommitPhaseError$1(effect, error); } } effect = effect.nextEffect; @@ -16360,16 +17542,28 @@ function commitPassiveEffects(root, firstEffect) { if (rootExpirationTime !== NoWork) { requestWork(root, rootExpirationTime); } + // Flush any sync work that was scheduled by effects + if (!isBatchingUpdates && !isRendering) { + performSyncWork(); + } + + { + if (rootWithPendingPassiveEffects === root) { + nestedPassiveEffectCountDEV++; + } else { + nestedPassiveEffectCountDEV = 0; + } + } } -function isAlreadyFailedLegacyErrorBoundary(instance) { +function isAlreadyFailedLegacyErrorBoundary$1(instance) { return ( legacyErrorBoundariesThatAlreadyFailed !== null && legacyErrorBoundariesThatAlreadyFailed.has(instance) ); } -function markLegacyErrorBoundaryAsFailed(instance) { +function markLegacyErrorBoundaryAsFailed$1(instance) { if (legacyErrorBoundariesThatAlreadyFailed === null) { legacyErrorBoundariesThatAlreadyFailed = new Set([instance]); } else { @@ -16377,15 +17571,17 @@ function markLegacyErrorBoundaryAsFailed(instance) { } } -function flushPassiveEffects() { +function flushPassiveEffects$1() { + var didFlushEffects = passiveEffectCallback !== null; if (passiveEffectCallbackHandle !== null) { - cancelPassiveEffects(passiveEffectCallbackHandle); + cancelCallback$1(passiveEffectCallbackHandle); } if (passiveEffectCallback !== null) { // We call the scheduled callback instead of commitPassiveEffects directly // to ensure tracing works correctly. passiveEffectCallback(); } + return didFlushEffects; } function commitRoot(root, finishedWork) { @@ -16393,18 +17589,21 @@ function commitRoot(root, finishedWork) { isCommitting$1 = true; startCommitTimer(); - invariant( - root.current !== finishedWork, - "Cannot commit the same tree as before. This is probably a bug " + - "related to the return field. This error is likely caused by a bug " + - "in React. Please file an issue." - ); + (function() { + if (!(root.current !== finishedWork)) { + throw ReactError( + "Cannot commit the same tree as before. This is probably a bug related to the return field. This error is likely caused by a bug in React. Please file an issue." + ); + } + })(); var committedExpirationTime = root.pendingCommitExpirationTime; - invariant( - committedExpirationTime !== NoWork, - "Cannot commit an incomplete root. This error is likely caused by a " + - "bug in React. Please file an issue." - ); + (function() { + if (!(committedExpirationTime !== NoWork)) { + throw ReactError( + "Cannot commit an incomplete root. This error is likely caused by a bug in React. Please file an issue." + ); + } + })(); root.pendingCommitExpirationTime = NoWork; // Update the pending priority levels to account for the work that we are @@ -16462,12 +17661,14 @@ function commitRoot(root, finishedWork) { } } if (didError) { - invariant( - nextEffect !== null, - "Should have next effect. This error is likely caused by a bug " + - "in React. Please file an issue." - ); - captureCommitPhaseError(nextEffect, error); + (function() { + if (!(nextEffect !== null)) { + throw ReactError( + "Should have next effect. This error is likely caused by a bug in React. Please file an issue." + ); + } + })(); + captureCommitPhaseError$1(nextEffect, error); // Clean-up if (nextEffect !== null) { nextEffect = nextEffect.nextEffect; @@ -16498,12 +17699,14 @@ function commitRoot(root, finishedWork) { } } if (_didError) { - invariant( - nextEffect !== null, - "Should have next effect. This error is likely caused by a bug " + - "in React. Please file an issue." - ); - captureCommitPhaseError(nextEffect, _error); + (function() { + if (!(nextEffect !== null)) { + throw ReactError( + "Should have next effect. This error is likely caused by a bug in React. Please file an issue." + ); + } + })(); + captureCommitPhaseError$1(nextEffect, _error); // Clean-up if (nextEffect !== null) { nextEffect = nextEffect.nextEffect; @@ -16543,12 +17746,14 @@ function commitRoot(root, finishedWork) { } } if (_didError2) { - invariant( - nextEffect !== null, - "Should have next effect. This error is likely caused by a bug " + - "in React. Please file an issue." - ); - captureCommitPhaseError(nextEffect, _error2); + (function() { + if (!(nextEffect !== null)) { + throw ReactError( + "Should have next effect. This error is likely caused by a bug in React. Please file an issue." + ); + } + })(); + captureCommitPhaseError$1(nextEffect, _error2); if (nextEffect !== null) { nextEffect = nextEffect.nextEffect; } @@ -16567,11 +17772,9 @@ function commitRoot(root, finishedWork) { // here because that code is still in flux. callback = tracing.unstable_wrap(callback); } - passiveEffectCallbackHandle = scheduler.unstable_runWithPriority( - scheduler.unstable_NormalPriority, - function() { - return schedulePassiveEffects(callback); - } + passiveEffectCallbackHandle = scheduleCallback$1( + NormalPriority$1, + callback ); passiveEffectCallback = callback; } @@ -16975,20 +18178,22 @@ function workLoop(isYieldy) { } } else { // Flush asynchronous work until there's a higher priority event - while (nextUnitOfWork !== null && !shouldYieldToRenderer()) { + while (nextUnitOfWork !== null && !shouldYield$1()) { nextUnitOfWork = performUnitOfWork(nextUnitOfWork); } } } function renderRoot(root, isYieldy) { - invariant( - !isWorking, - "renderRoot was called recursively. This error is likely caused " + - "by a bug in React. Please file an issue." - ); + (function() { + if (!!isWorking) { + throw ReactError( + "renderRoot was called recursively. This error is likely caused by a bug in React. Please file an issue." + ); + } + })(); - flushPassiveEffects(); + flushPassiveEffects$1(); isWorking = true; var previousDispatcher = ReactCurrentDispatcher.current; @@ -17088,7 +18293,7 @@ function renderRoot(root, isYieldy) { if (nextUnitOfWork === null) { // This is a fatal error. didFatal = true; - onUncaughtError(thrownValue); + onUncaughtError$1(thrownValue); } else { if (enableProfilerTimer && nextUnitOfWork.mode & ProfileMode) { // Record the time spent rendering before an error was thrown. @@ -17112,12 +18317,13 @@ function renderRoot(root, isYieldy) { // TODO: we already know this isn't true in some cases. // At least this shows a nicer error message until we figure out the cause. // https://github.com/facebook/react/issues/12449#issuecomment-386727431 - invariant( - nextUnitOfWork !== null, - "Failed to replay rendering after an error. This " + - "is likely caused by a bug in React. Please file an issue " + - "with a reproducing case to help us find it." - ); + (function() { + if (!(nextUnitOfWork !== null)) { + throw ReactError( + "Failed to replay rendering after an error. This is likely caused by a bug in React. Please file an issue with a reproducing case to help us find it." + ); + } + })(); var sourceFiber = nextUnitOfWork; var returnFiber = sourceFiber.return; @@ -17129,7 +18335,7 @@ function renderRoot(root, isYieldy) { // which phase it fails in, but doesn't seem worth it. At least // for now. didFatal = true; - onUncaughtError(thrownValue); + onUncaughtError$1(thrownValue); } else { throwException( root, @@ -17190,11 +18396,13 @@ function renderRoot(root, isYieldy) { var didCompleteRoot = true; stopWorkLoopTimer(interruptedBy, didCompleteRoot); var rootWorkInProgress = root.current.alternate; - invariant( - rootWorkInProgress !== null, - "Finished root should have a work-in-progress. This error is likely " + - "caused by a bug in React. Please file an issue." - ); + (function() { + if (!(rootWorkInProgress !== null)) { + throw ReactError( + "Finished root should have a work-in-progress. This error is likely caused by a bug in React. Please file an issue." + ); + } + })(); // `nextRoot` points to the in-progress root. A non-null value indicates // that we're in the middle of an async render. Set it to null to indicate @@ -17243,32 +18451,23 @@ function renderRoot(root, isYieldy) { } } - if (isYieldy && nextLatestAbsoluteTimeoutMs !== -1) { + // Check if we should suspend this commit. + // If mostRecentEventTime is Sync, that means we didn't track any event + // times. That can happen if we retried but nothing switched from fallback + // to content. There's no reason to delay doing no work. + if (isYieldy && nextRenderDidSuspend && mostRecentEventTime !== Sync) { // The tree was suspended. var _suspendedExpirationTime2 = expirationTime; markSuspendedPriorityLevel(root, _suspendedExpirationTime2); - // Find the earliest uncommitted expiration time in the tree, including - // work that is suspended. The timeout threshold cannot be longer than - // the overall expiration. - var earliestExpirationTime = findEarliestOutstandingPriorityLevel( - root, - expirationTime - ); - var earliestExpirationTimeMs = expirationTimeToMs(earliestExpirationTime); - if (earliestExpirationTimeMs < nextLatestAbsoluteTimeoutMs) { - nextLatestAbsoluteTimeoutMs = earliestExpirationTimeMs; - } - - // Subtract the current time from the absolute timeout to get the number - // of milliseconds until the timeout. In other words, convert an absolute - // timestamp to a relative time. This is the value that is passed - // to `setTimeout`. - var currentTimeMs = expirationTimeToMs(requestCurrentTime()); - var msUntilTimeout = nextLatestAbsoluteTimeoutMs - currentTimeMs; - msUntilTimeout = msUntilTimeout < 0 ? 0 : msUntilTimeout; + var eventTimeMs = inferTimeFromExpirationTime(mostRecentEventTime); + var currentTimeMs = now$1(); + var timeElapsed = currentTimeMs - eventTimeMs; // TODO: Account for the Just Noticeable Difference + var timeoutMs = 150; + var msUntilTimeout = timeoutMs - timeElapsed; + msUntilTimeout = msUntilTimeout < 0 ? 0 : msUntilTimeout; var _rootExpirationTime2 = root.expirationTime; onSuspend( @@ -17285,7 +18484,7 @@ function renderRoot(root, isYieldy) { onComplete(root, rootWorkInProgress, expirationTime); } -function captureCommitPhaseError(sourceFiber, value) { +function captureCommitPhaseError$1(sourceFiber, value) { var expirationTime = Sync; var fiber = sourceFiber.return; while (fiber !== null) { @@ -17296,12 +18495,12 @@ function captureCommitPhaseError(sourceFiber, value) { if ( typeof ctor.getDerivedStateFromError === "function" || (typeof instance.componentDidCatch === "function" && - !isAlreadyFailedLegacyErrorBoundary(instance)) + !isAlreadyFailedLegacyErrorBoundary$1(instance)) ) { var errorInfo = createCapturedValue(value, sourceFiber); var update = createClassErrorUpdate(fiber, errorInfo, expirationTime); enqueueUpdate(fiber, update); - scheduleWork(fiber, expirationTime); + scheduleWork$1(fiber, expirationTime); return; } break; @@ -17309,7 +18508,7 @@ function captureCommitPhaseError(sourceFiber, value) { var _errorInfo = createCapturedValue(value, sourceFiber); var _update = createRootErrorUpdate(fiber, _errorInfo, expirationTime); enqueueUpdate(fiber, _update); - scheduleWork(fiber, expirationTime); + scheduleWork$1(fiber, expirationTime); return; } } @@ -17327,7 +18526,7 @@ function captureCommitPhaseError(sourceFiber, value) { expirationTime ); enqueueUpdate(rootFiber, _update2); - scheduleWork(rootFiber, expirationTime); + scheduleWork$1(rootFiber, expirationTime); } } @@ -17336,77 +18535,80 @@ function computeThreadID(expirationTime, interactionThreadID) { return expirationTime * 1000 + interactionThreadID; } -function computeExpirationForFiber(currentTime, fiber) { - var priorityLevel = scheduler.unstable_getCurrentPriorityLevel(); - +function computeExpirationForFiber$1(currentTime, fiber) { var expirationTime = void 0; - if ((fiber.mode & ConcurrentMode) === NoContext) { - // Outside of concurrent mode, updates are always synchronous. - expirationTime = Sync; - } else if (isWorking && !isCommitting$1) { - // During render phase, updates expire during as the current render. - expirationTime = nextRenderExpirationTime; + if (expirationContext !== NoWork) { + // An explicit expiration context was set; + expirationTime = expirationContext; + } else if (isWorking) { + if (isCommitting$1) { + // Updates that occur during the commit phase should have sync priority + // by default. + expirationTime = Sync; + } else { + // Updates during the render phase should expire at the same time as + // the work that is being rendered. + expirationTime = nextRenderExpirationTime; + } } else { - switch (priorityLevel) { - case scheduler.unstable_ImmediatePriority: - expirationTime = Sync; - break; - case scheduler.unstable_UserBlockingPriority: + // No explicit expiration context was set, and we're not currently + // performing work. Calculate a new expiration time. + if (fiber.mode & ConcurrentMode) { + if (isBatchingInteractiveUpdates) { + // This is an interactive update expirationTime = computeInteractiveExpiration(currentTime); - break; - case scheduler.unstable_NormalPriority: - // This is a normal, concurrent update + } else { + // This is an async update expirationTime = computeAsyncExpiration(currentTime); - break; - case scheduler.unstable_LowPriority: - case scheduler.unstable_IdlePriority: - expirationTime = Never; - break; - default: - invariant( - false, - "Unknown priority level. This error is likely caused by a bug in " + - "React. Please file an issue." - ); - } - - // If we're in the middle of rendering a tree, do not update at the same - // expiration time that is already rendering. - if (nextRoot !== null && expirationTime === nextRenderExpirationTime) { - expirationTime -= 1; + } + // If we're in the middle of rendering a tree, do not update at the same + // expiration time that is already rendering. + if (nextRoot !== null && expirationTime === nextRenderExpirationTime) { + expirationTime -= 1; + } + } else { + // This is a sync update + expirationTime = Sync; } } - - // Keep track of the lowest pending interactive expiration time. This - // allows us to synchronously flush all interactive updates - // when needed. - // TODO: Move this to renderer? - if ( - priorityLevel === scheduler.unstable_UserBlockingPriority && - (lowestPriorityPendingInteractiveExpirationTime === NoWork || - expirationTime < lowestPriorityPendingInteractiveExpirationTime) - ) { - lowestPriorityPendingInteractiveExpirationTime = expirationTime; + if (isBatchingInteractiveUpdates) { + // This is an interactive update. Keep track of the lowest pending + // interactive expiration time. This allows us to synchronously flush + // all interactive updates when needed. + if ( + lowestPriorityPendingInteractiveExpirationTime === NoWork || + expirationTime < lowestPriorityPendingInteractiveExpirationTime + ) { + lowestPriorityPendingInteractiveExpirationTime = expirationTime; + } } - return expirationTime; } -function renderDidSuspend(root, absoluteTimeoutMs, suspendedTime) { - // Schedule the timeout. - if ( - absoluteTimeoutMs >= 0 && - nextLatestAbsoluteTimeoutMs < absoluteTimeoutMs - ) { - nextLatestAbsoluteTimeoutMs = absoluteTimeoutMs; +function markRenderEventTime$1(expirationTime) { + if (expirationTime < mostRecentEventTime) { + mostRecentEventTime = expirationTime; } } -function renderDidError() { +function renderDidSuspend$1() { + nextRenderDidSuspend = true; +} + +function renderDidError$1() { nextRenderDidError = true; } -function pingSuspendedRoot(root, thenable, pingTime) { +function inferTimeFromExpirationTime(expirationTime) { + // We don't know exactly when the update was scheduled, but we can infer an + // approximate start time from the expiration time. + var earliestExpirationTimeMs = expirationTimeToMs(expirationTime); + return ( + earliestExpirationTimeMs - LOW_PRIORITY_EXPIRATION + originalStartTimeMs + ); +} + +function pingSuspendedRoot$1(root, thenable, pingTime) { // A promise that previously suspended React from committing has resolved. // If React is still suspended, try again at the previous level (pingTime). @@ -17434,27 +18636,51 @@ function pingSuspendedRoot(root, thenable, pingTime) { } } -function retryTimedOutBoundary(boundaryFiber, thenable) { +function retryTimedOutBoundary$1(boundaryFiber) { + var currentTime = requestCurrentTime$1(); + var retryTime = computeExpirationForFiber$1(currentTime, boundaryFiber); + var root = scheduleWorkToRoot(boundaryFiber, retryTime); + if (root !== null) { + markPendingPriorityLevel(root, retryTime); + var rootExpirationTime = root.expirationTime; + if (rootExpirationTime !== NoWork) { + requestWork(root, rootExpirationTime); + } + } +} + +function resolveRetryThenable$1(boundaryFiber, thenable) { // The boundary fiber (a Suspense component) previously timed out and was // rendered in its fallback state. One of the promises that suspended it has // resolved, which means at least part of the tree was likely unblocked. Try - var retryCache = boundaryFiber.stateNode; + var retryCache = void 0; + if (enableSuspenseServerRenderer) { + switch (boundaryFiber.tag) { + case SuspenseComponent: + retryCache = boundaryFiber.stateNode; + break; + case DehydratedSuspenseComponent: + retryCache = boundaryFiber.memoizedState; + break; + default: + (function() { + { + throw ReactError( + "Pinged unknown suspense boundary type. This is probably a bug in React." + ); + } + })(); + } + } else { + retryCache = boundaryFiber.stateNode; + } if (retryCache !== null) { // The thenable resolved, so we no longer need to memoize, because it will // never be thrown again. retryCache.delete(thenable); } - var currentTime = requestCurrentTime(); - var retryTime = computeExpirationForFiber(currentTime, boundaryFiber); - var root = scheduleWorkToRoot(boundaryFiber, retryTime); - if (root !== null) { - markPendingPriorityLevel(root, retryTime); - var rootExpirationTime = root.expirationTime; - if (rootExpirationTime !== NoWork) { - requestWork(root, rootExpirationTime); - } - } + retryTimedOutBoundary$1(boundaryFiber); } function scheduleWorkToRoot(fiber, expirationTime) { @@ -17543,9 +18769,20 @@ function scheduleWorkToRoot(fiber, expirationTime) { return root; } -function warnIfNotCurrentlyBatchingInDev(fiber) { +// in a test-like environment, we want to warn if dispatchAction() is +// called outside of a TestUtils.act(...)/batchedUpdates/render call. +// so we have a a step counter for when we descend/ascend from +// act() calls, and test on it for when to warn +// It's a tuple with a single value. Look for shared/createAct to +// see how we change the value inside act() calls + +function warnIfNotCurrentlyActingUpdatesInDev$1(fiber) { { - if (isRendering === false && isBatchingUpdates === false) { + if ( + isBatchingUpdates === false && + isRendering === false && + ReactShouldWarnActingUpdates.current === false + ) { warningWithoutStack$1( false, "An update to %s inside a test was not wrapped in act(...).\n\n" + @@ -17555,14 +18792,16 @@ function warnIfNotCurrentlyBatchingInDev(fiber) { "});\n" + "/* assert on the output */\n\n" + "This ensures that you're testing the behavior the user would see in the browser." + - " Learn more at https://fb.me/react-wrap-tests-with-act", - getComponentName(fiber.type) + " Learn more at https://fb.me/react-wrap-tests-with-act" + + "%s", + getComponentName(fiber.type), + getStackByFiberInDevAndProd(fiber) ); } } } -function scheduleWork(fiber, expirationTime) { +function scheduleWork$1(fiber, expirationTime) { var root = scheduleWorkToRoot(fiber, expirationTime); if (root === null) { { @@ -17605,13 +18844,28 @@ function scheduleWork(fiber, expirationTime) { if (nestedUpdateCount > NESTED_UPDATE_LIMIT) { // Reset this back to zero so subsequent updates don't throw. nestedUpdateCount = 0; - invariant( - false, - "Maximum update depth exceeded. This can happen when a " + - "component repeatedly calls setState inside " + - "componentWillUpdate or componentDidUpdate. React limits " + - "the number of nested updates to prevent infinite loops." - ); + (function() { + { + throw ReactError( + "Maximum update depth exceeded. This can happen when a component repeatedly calls setState inside componentWillUpdate or componentDidUpdate. React limits the number of nested updates to prevent infinite loops." + ); + } + })(); + } + { + if ( + isInPassiveEffectDEV && + nestedPassiveEffectCountDEV > NESTED_PASSIVE_UPDATE_LIMIT + ) { + nestedPassiveEffectCountDEV = 0; + warning$1( + false, + "Maximum update depth exceeded. This can happen when a " + + "component calls setState inside useEffect, but " + + "useEffect either doesn't have a dependency array, or " + + "one of the dependencies changes on every render." + ); + } } } @@ -17633,10 +18887,11 @@ var unhandledError = null; var isBatchingUpdates = false; var isUnbatchingUpdates = false; +var isBatchingInteractiveUpdates = false; var completedBatches = null; -var originalStartTimeMs = now$$1(); +var originalStartTimeMs = now$1(); var currentRendererTime = msToExpirationTime(originalStartTimeMs); var currentSchedulerTime = currentRendererTime; @@ -17645,8 +18900,17 @@ var NESTED_UPDATE_LIMIT = 50; var nestedUpdateCount = 0; var lastCommittedRootDuringThisBatch = null; +// Similar, but for useEffect infinite loops. These are DEV-only. +var NESTED_PASSIVE_UPDATE_LIMIT = 50; +var nestedPassiveEffectCountDEV = void 0; +var isInPassiveEffectDEV = void 0; +{ + nestedPassiveEffectCountDEV = 0; + isInPassiveEffectDEV = false; +} + function recomputeCurrentRendererTime() { - var currentTimeMs = now$$1() - originalStartTimeMs; + var currentTimeMs = now$1() - originalStartTimeMs; currentRendererTime = msToExpirationTime(currentTimeMs); } @@ -17660,7 +18924,7 @@ function scheduleCallbackWithExpirationTime(root, expirationTime) { if (callbackID !== null) { // Existing callback has insufficient timeout. Cancel and schedule a // new one. - cancelDeferredCallback$$1(callbackID); + cancelCallback$1(callbackID); } } // The request callback timer is already running. Don't start a new one. @@ -17669,10 +18933,11 @@ function scheduleCallbackWithExpirationTime(root, expirationTime) { } callbackExpirationTime = expirationTime; - var currentMs = now$$1() - originalStartTimeMs; + var currentMs = now$1() - originalStartTimeMs; var expirationTimeMs = expirationTimeToMs(expirationTime); var timeout = expirationTimeMs - currentMs; - callbackID = scheduleDeferredCallback$$1(performAsyncWork, { + var priorityLevel = getCurrentPriorityLevel$1(); + callbackID = scheduleCallback$1(priorityLevel, performAsyncWork, { timeout: timeout }); } @@ -17698,7 +18963,7 @@ function onSuspend( msUntilTimeout ) { root.expirationTime = rootExpirationTime; - if (msUntilTimeout === 0 && !shouldYieldToRenderer()) { + if (msUntilTimeout === 0 && (disableYielding || !shouldYield$1())) { // Don't wait an additional tick. Commit the tree immediately. root.pendingCommitExpirationTime = suspendedExpirationTime; root.finishedWork = finishedWork; @@ -17724,7 +18989,7 @@ function onTimeout(root, finishedWork, suspendedExpirationTime) { // because we're at the top of a timer event. recomputeCurrentRendererTime(); currentSchedulerTime = currentRendererTime; - flushRoot(root, suspendedExpirationTime); + flushRoot$1(root, suspendedExpirationTime); } function onCommit(root, expirationTime) { @@ -17732,7 +18997,7 @@ function onCommit(root, expirationTime) { root.finishedWork = null; } -function requestCurrentTime() { +function requestCurrentTime$1() { // requestCurrentTime is called by the scheduler to compute an expiration // time. // @@ -17844,11 +19109,13 @@ function findHighestPriorityRoot() { // TODO: This check is redudant, but Flow is confused by the branch // below where we set lastScheduledRoot to null, even though we break // from the loop right after. - invariant( - previousScheduledRoot !== null && lastScheduledRoot !== null, - "Should have a previous and last root. This error is likely " + - "caused by a bug in React. Please file an issue." - ); + (function() { + if (!(previousScheduledRoot !== null && lastScheduledRoot !== null)) { + throw ReactError( + "Should have a previous and last root. This error is likely caused by a bug in React. Please file an issue." + ); + } + })(); if (root === root.nextScheduledRoot) { // This is the only root in the list. root.nextScheduledRoot = null; @@ -17895,55 +19162,35 @@ function findHighestPriorityRoot() { nextFlushedExpirationTime = highestPriorityWork; } -// TODO: This wrapper exists because many of the older tests (the ones that use -// flushDeferredPri) rely on the number of times `shouldYield` is called. We -// should get rid of it. -var didYield = false; -function shouldYieldToRenderer() { - if (didYield) { - return true; - } - if (shouldYield$$1()) { - didYield = true; - return true; - } - return false; -} - -function performAsyncWork() { - try { - if (!shouldYieldToRenderer()) { - // The callback timed out. That means at least one update has expired. - // Iterate through the root schedule. If they contain expired work, set - // the next render expiration time to the current time. This has the effect - // of flushing all expired work in a single batch, instead of flushing each - // level one at a time. - if (firstScheduledRoot !== null) { - recomputeCurrentRendererTime(); - var root = firstScheduledRoot; - do { - didExpireAtExpirationTime(root, currentRendererTime); - // The root schedule is circular, so this is never null. - root = root.nextScheduledRoot; - } while (root !== firstScheduledRoot); - } +function performAsyncWork(didTimeout) { + if (didTimeout) { + // The callback timed out. That means at least one update has expired. + // Iterate through the root schedule. If they contain expired work, set + // the next render expiration time to the current time. This has the effect + // of flushing all expired work in a single batch, instead of flushing each + // level one at a time. + if (firstScheduledRoot !== null) { + recomputeCurrentRendererTime(); + var root = firstScheduledRoot; + do { + didExpireAtExpirationTime(root, currentRendererTime); + // The root schedule is circular, so this is never null. + root = root.nextScheduledRoot; + } while (root !== firstScheduledRoot); } - performWork(NoWork, true); - } finally { - didYield = false; } -} - -function performSyncWork() { - performWork(Sync, false); -} -function performWork(minExpirationTime, isYieldy) { // Keep working on roots until there's no more work, or until there's a higher // priority event. findHighestPriorityRoot(); - if (isYieldy) { + if (disableYielding) { + // Just do it all + while (nextFlushedRoot !== null && nextFlushedExpirationTime !== NoWork) { + performWorkOnRoot(nextFlushedRoot, nextFlushedExpirationTime, false); + findHighestPriorityRoot(); + } + } else { recomputeCurrentRendererTime(); currentSchedulerTime = currentRendererTime; @@ -17956,8 +19203,7 @@ function performWork(minExpirationTime, isYieldy) { while ( nextFlushedRoot !== null && nextFlushedExpirationTime !== NoWork && - minExpirationTime <= nextFlushedExpirationTime && - !(didYield && currentRendererTime > nextFlushedExpirationTime) + !(shouldYield$1() && currentRendererTime > nextFlushedExpirationTime) ) { performWorkOnRoot( nextFlushedRoot, @@ -17968,25 +19214,48 @@ function performWork(minExpirationTime, isYieldy) { recomputeCurrentRendererTime(); currentSchedulerTime = currentRendererTime; } - } else { - while ( - nextFlushedRoot !== null && - nextFlushedExpirationTime !== NoWork && - minExpirationTime <= nextFlushedExpirationTime - ) { - performWorkOnRoot(nextFlushedRoot, nextFlushedExpirationTime, false); - findHighestPriorityRoot(); - } } // We're done flushing work. Either we ran out of time in this callback, // or there's no more work left with sufficient priority. // If we're inside a callback, set this to false since we just completed it. - if (isYieldy) { - callbackExpirationTime = NoWork; - callbackID = null; + callbackExpirationTime = NoWork; + callbackID = null; + + // If there's work left over, schedule a new callback. + if (nextFlushedExpirationTime !== NoWork) { + scheduleCallbackWithExpirationTime( + nextFlushedRoot, + nextFlushedExpirationTime + ); + } + + // Clean-up. + finishRendering(); +} + +function performSyncWork() { + performWork(Sync); +} + +function performWork(minExpirationTime) { + // Keep working on roots until there's no more work, or until there's a higher + // priority event. + findHighestPriorityRoot(); + + while ( + nextFlushedRoot !== null && + nextFlushedExpirationTime !== NoWork && + minExpirationTime <= nextFlushedExpirationTime + ) { + performWorkOnRoot(nextFlushedRoot, nextFlushedExpirationTime, false); + findHighestPriorityRoot(); } + + // We're done flushing work. Either we ran out of time in this callback, + // or there's no more work left with sufficient priority. + // If there's work left over, schedule a new callback. if (nextFlushedExpirationTime !== NoWork) { scheduleCallbackWithExpirationTime( @@ -17999,12 +19268,14 @@ function performWork(minExpirationTime, isYieldy) { finishRendering(); } -function flushRoot(root, expirationTime) { - invariant( - !isRendering, - "work.commit(): Cannot commit while already rendering. This likely " + - "means you attempted to commit from inside a lifecycle method." - ); +function flushRoot$1(root, expirationTime) { + (function() { + if (!!isRendering) { + throw ReactError( + "work.commit(): Cannot commit while already rendering. This likely means you attempted to commit from inside a lifecycle method." + ); + } + })(); // Perform work on root as if the given expiration time is the current time. // This has the effect of synchronously flushing all work up to and // including the given time. @@ -18019,6 +19290,12 @@ function finishRendering() { nestedUpdateCount = 0; lastCommittedRootDuringThisBatch = null; + { + if (rootWithPendingPassiveEffects === null) { + nestedPassiveEffectCountDEV = 0; + } + } + if (completedBatches !== null) { var batches = completedBatches; completedBatches = null; @@ -18044,11 +19321,13 @@ function finishRendering() { } function performWorkOnRoot(root, expirationTime, isYieldy) { - invariant( - !isRendering, - "performWorkOnRoot was called recursively. This error is likely caused " + - "by a bug in React. Please file an issue." - ); + (function() { + if (!!isRendering) { + throw ReactError( + "performWorkOnRoot was called recursively. This error is likely caused by a bug in React. Please file an issue." + ); + } + })(); isRendering = true; @@ -18101,7 +19380,7 @@ function performWorkOnRoot(root, expirationTime, isYieldy) { if (_finishedWork !== null) { // We've completed the root. Check the if we should yield one more time // before committing. - if (!shouldYieldToRenderer()) { + if (!shouldYield$1()) { // Still time left. Commit the root. completeRoot(root, _finishedWork, expirationTime); } else { @@ -18148,20 +19427,17 @@ function completeRoot(root, finishedWork, expirationTime) { lastCommittedRootDuringThisBatch = root; nestedUpdateCount = 0; } - scheduler.unstable_runWithPriority( - scheduler.unstable_ImmediatePriority, - function() { - commitRoot(root, finishedWork); - } - ); + commitRoot(root, finishedWork); } -function onUncaughtError(error) { - invariant( - nextFlushedRoot !== null, - "Should be working on a root. This error is likely caused by a bug in " + - "React. Please file an issue." - ); +function onUncaughtError$1(error) { + (function() { + if (!(nextFlushedRoot !== null)) { + throw ReactError( + "Should be working on a root. This error is likely caused by a bug in React. Please file an issue." + ); + } + })(); // Unschedule this root so we don't work on it again until there's // another update. nextFlushedRoot.expirationTime = NoWork; @@ -18173,7 +19449,7 @@ function onUncaughtError(error) { // TODO: Batching should be implemented at the renderer level, not inside // the reconciler. -function batchedUpdates$1(fn, a) { +function batchedUpdates$2(fn, a) { var previousIsBatchingUpdates = isBatchingUpdates; isBatchingUpdates = true; try { @@ -18186,7 +19462,10 @@ function batchedUpdates$1(fn, a) { } } -function interactiveUpdates$1(fn, a, b) { +function interactiveUpdates$2(fn, a, b, c) { + if (isBatchingInteractiveUpdates) { + return fn(a, b, c); + } // If there are any pending interactive updates, synchronously flush them. // This needs to happen before we read any handlers, because the effect of // the previous event may influence which handlers are called during @@ -18197,36 +19476,2002 @@ function interactiveUpdates$1(fn, a, b) { lowestPriorityPendingInteractiveExpirationTime !== NoWork ) { // Synchronously flush pending interactive updates. - performWork(lowestPriorityPendingInteractiveExpirationTime, false); + performWork(lowestPriorityPendingInteractiveExpirationTime); lowestPriorityPendingInteractiveExpirationTime = NoWork; } + var previousIsBatchingInteractiveUpdates = isBatchingInteractiveUpdates; var previousIsBatchingUpdates = isBatchingUpdates; + isBatchingInteractiveUpdates = true; isBatchingUpdates = true; try { - return scheduler.unstable_runWithPriority( - scheduler.unstable_UserBlockingPriority, - function() { - return fn(a, b); + return fn(a, b, c); + } finally { + isBatchingInteractiveUpdates = previousIsBatchingInteractiveUpdates; + isBatchingUpdates = previousIsBatchingUpdates; + if (!isBatchingUpdates && !isRendering) { + performSyncWork(); + } + } +} + +function flushInteractiveUpdates$2() { + if ( + !isRendering && + lowestPriorityPendingInteractiveExpirationTime !== NoWork + ) { + // Synchronously flush pending interactive updates. + performWork(lowestPriorityPendingInteractiveExpirationTime); + lowestPriorityPendingInteractiveExpirationTime = NoWork; + } +} + +// TODO: Ahaha Andrew is bad at spellling +// DEV stuff +var ReactCurrentDispatcher$2 = ReactSharedInternals.ReactCurrentDispatcher; +var ReactCurrentOwner$4 = ReactSharedInternals.ReactCurrentOwner; +var ReactShouldWarnActingUpdates$1 = + ReactSharedInternals.ReactShouldWarnActingUpdates; + +var NotWorking = 0; +var BatchedPhase = 1; +var LegacyUnbatchedPhase = 2; +var RenderPhase = 4; +var CommitPhase = 5; + +var RootIncomplete = 0; +var RootErrored = 1; +var RootSuspended = 2; +var RootCompleted = 3; + +// The phase of work we're currently in +var workPhase = NotWorking; +// The root we're working on +var workInProgressRoot = null; +// The fiber we're working on +var workInProgress = null; +// The expiration time we're rendering +var renderExpirationTime$1 = NoWork; +// Whether to root completed, errored, suspended, etc. +var workInProgressRootExitStatus = RootIncomplete; +// Most recent event time among processed updates during this render. +// This is conceptually a time stamp but expressed in terms of an ExpirationTime +// because we deal mostly with expiration times in the hot path, so this avoids +// the conversion happening in the hot path. +var workInProgressRootMostRecentEventTime = Sync; + +var nextEffect$1 = null; +var hasUncaughtError = false; +var firstUncaughtError = null; +var legacyErrorBoundariesThatAlreadyFailed$1 = null; + +var rootDoesHavePassiveEffects = false; +var rootWithPendingPassiveEffects$1 = null; +var pendingPassiveEffectsExpirationTime = NoWork; + +var rootsWithPendingDiscreteUpdates = null; + +// Use these to prevent an infinite loop of nested updates +var NESTED_UPDATE_LIMIT$1 = 50; +var nestedUpdateCount$1 = 0; +var rootWithNestedUpdates = null; + +var NESTED_PASSIVE_UPDATE_LIMIT$1 = 50; +var nestedPassiveUpdateCount = 0; + +var interruptedBy$1 = null; + +// Expiration times are computed by adding to the current time (the start +// time). However, if two updates are scheduled within the same event, we +// should treat their start times as simultaneous, even if the actual clock +// time has advanced between the first and second call. + +// In other words, because expiration times determine how updates are batched, +// we want all updates of like priority that occur within the same event to +// receive the same expiration time. Otherwise we get tearing. +var initialTimeMs = now(); +var currentEventTime = NoWork; + +function requestCurrentTime$2() { + if (workPhase === RenderPhase || workPhase === CommitPhase) { + // We're inside React, so it's fine to read the actual time. + return msToExpirationTime(now() - initialTimeMs); + } + // We're not inside React, so we may be in the middle of a browser event. + if (currentEventTime !== NoWork) { + // Use the same start time for all updates until we enter React again. + return currentEventTime; + } + // This is the first update since React yielded. Compute a new start time. + currentEventTime = msToExpirationTime(now() - initialTimeMs); + return currentEventTime; +} + +function computeExpirationForFiber$2(currentTime, fiber) { + if ((fiber.mode & ConcurrentMode) === NoContext) { + return Sync; + } + + if (workPhase === RenderPhase) { + // Use whatever time we're already rendering + return renderExpirationTime$1; + } + + // Compute an expiration time based on the Scheduler priority. + var expirationTime = void 0; + var priorityLevel = getCurrentPriorityLevel(); + switch (priorityLevel) { + case ImmediatePriority: + expirationTime = Sync; + break; + case UserBlockingPriority: + // TODO: Rename this to computeUserBlockingExpiration + expirationTime = computeInteractiveExpiration(currentTime); + break; + case NormalPriority: + case LowPriority: + // TODO: Handle LowPriority + // TODO: Rename this to... something better. + expirationTime = computeAsyncExpiration(currentTime); + break; + case IdlePriority: + expirationTime = Never; + break; + default: + (function() { + { + throw ReactError("Expected a valid priority level"); + } + })(); + } + + // If we're in the middle of rendering a tree, do not update at the same + // expiration time that is already rendering. + if ( + workInProgressRoot !== null && + expirationTime === renderExpirationTime$1 + ) { + // This is a trick to move this update into a separate batch + expirationTime -= 1; + } + + return expirationTime; +} + +function scheduleUpdateOnFiber(fiber, expirationTime) { + checkForNestedUpdates(); + warnAboutInvalidUpdatesOnClassComponentsInDEV(fiber); + + var root = markUpdateTimeFromFiberToRoot(fiber, expirationTime); + if (root === null) { + warnAboutUpdateOnUnmountedFiberInDEV(fiber); + return; + } + + root.pingTime = NoWork; + + checkForInterruption(fiber, expirationTime); + recordScheduleUpdate(); + + if (expirationTime === Sync) { + if (workPhase === LegacyUnbatchedPhase) { + // This is a legacy edge case. The initial mount of a ReactDOM.render-ed + // root inside of batchedUpdates should be synchronous, but layout updates + // should be deferred until the end of the batch. + var callback = renderRoot$1(root, Sync, true); + while (callback !== null) { + callback = callback(true); + } + } else { + scheduleCallbackForRoot(root, ImmediatePriority, Sync); + if (workPhase === NotWorking) { + // Flush the synchronous work now, wnless we're already working or inside + // a batch. This is intentionally inside scheduleUpdateOnFiber instead of + // scheduleCallbackForFiber to preserve the ability to schedule a callback + // without immediately flushing it. We only do this for user-initated + // updates, to preserve historical behavior of sync mode. + flushImmediateQueue(); + } + } + } else { + // TODO: computeExpirationForFiber also reads the priority. Pass the + // priority as an argument to that function and this one. + var priorityLevel = getCurrentPriorityLevel(); + if (priorityLevel === UserBlockingPriority) { + // This is the result of a discrete event. Track the lowest priority + // discrete update per root so we can flush them early, if needed. + if (rootsWithPendingDiscreteUpdates === null) { + rootsWithPendingDiscreteUpdates = new Map([[root, expirationTime]]); + } else { + var lastDiscreteTime = rootsWithPendingDiscreteUpdates.get(root); + if ( + lastDiscreteTime === undefined || + lastDiscreteTime > expirationTime + ) { + rootsWithPendingDiscreteUpdates.set(root, expirationTime); + } + } + } + scheduleCallbackForRoot(root, priorityLevel, expirationTime); + } +} +var scheduleWork$2 = scheduleUpdateOnFiber; + +// This is split into a separate function so we can mark a fiber with pending +// work without treating it as a typical update that originates from an event; +// e.g. retrying a Suspense boundary isn't an update, but it does schedule work +// on a fiber. +function markUpdateTimeFromFiberToRoot(fiber, expirationTime) { + // Update the source fiber's expiration time + if (fiber.expirationTime < expirationTime) { + fiber.expirationTime = expirationTime; + } + var alternate = fiber.alternate; + if (alternate !== null && alternate.expirationTime < expirationTime) { + alternate.expirationTime = expirationTime; + } + // Walk the parent path to the root and update the child expiration time. + var node = fiber.return; + var root = null; + if (node === null && fiber.tag === HostRoot) { + root = fiber.stateNode; + } else { + while (node !== null) { + alternate = node.alternate; + if (node.childExpirationTime < expirationTime) { + node.childExpirationTime = expirationTime; + if ( + alternate !== null && + alternate.childExpirationTime < expirationTime + ) { + alternate.childExpirationTime = expirationTime; + } + } else if ( + alternate !== null && + alternate.childExpirationTime < expirationTime + ) { + alternate.childExpirationTime = expirationTime; + } + if (node.return === null && node.tag === HostRoot) { + root = node.stateNode; + break; + } + node = node.return; + } + } + + if (root !== null) { + // Update the first and last pending expiration times in this root + var firstPendingTime = root.firstPendingTime; + if (expirationTime > firstPendingTime) { + root.firstPendingTime = expirationTime; + } + var lastPendingTime = root.lastPendingTime; + if (lastPendingTime === NoWork || expirationTime < lastPendingTime) { + root.lastPendingTime = expirationTime; + } + } + + return root; +} + +// Use this function, along with runRootCallback, to ensure that only a single +// callback per root is scheduled. It's still possible to call renderRoot +// directly, but scheduling via this function helps avoid excessive callbacks. +// It works by storing the callback node and expiration time on the root. When a +// new callback comes in, it compares the expiration time to determine if it +// should cancel the previous one. It also relies on commitRoot scheduling a +// callback to render the next level, because that means we don't need a +// separate callback per expiration time. +function scheduleCallbackForRoot(root, priorityLevel, expirationTime) { + var existingCallbackExpirationTime = root.callbackExpirationTime; + if (existingCallbackExpirationTime < expirationTime) { + // New callback has higher priority than the existing one. + var existingCallbackNode = root.callbackNode; + if (existingCallbackNode !== null) { + cancelCallback(existingCallbackNode); + } + root.callbackExpirationTime = expirationTime; + var options = + expirationTime === Sync + ? null + : { timeout: expirationTimeToMs(expirationTime) }; + root.callbackNode = scheduleCallback( + priorityLevel, + runRootCallback.bind( + null, + root, + renderRoot$1.bind(null, root, expirationTime) + ), + options + ); + if ( + enableUserTimingAPI && + expirationTime !== Sync && + workPhase !== RenderPhase && + workPhase !== CommitPhase + ) { + // Scheduled an async callback, and we're not already working. Add an + // entry to the flamegraph that shows we're waiting for a callback + // to fire. + startRequestCallbackTimer(); + } + } + + var timeoutHandle = root.timeoutHandle; + if (timeoutHandle !== noTimeout) { + // The root previous suspended and scheduled a timeout to commit a fallback + // state. Now that we have additional work, cancel the timeout. + root.timeoutHandle = noTimeout; + // $FlowFixMe Complains noTimeout is not a TimeoutID, despite the check above + cancelTimeout(timeoutHandle); + } + + // Add the current set of interactions to the pending set associated with + // this root. + schedulePendingInteraction(root, expirationTime); +} + +function runRootCallback(root, callback, isSync) { + var prevCallbackNode = root.callbackNode; + var continuation = null; + try { + continuation = callback(isSync); + if (continuation !== null) { + return runRootCallback.bind(null, root, continuation); + } else { + return null; + } + } finally { + // If the callback exits without returning a continuation, remove the + // corresponding callback node from the root. Unless the callback node + // has changed, which implies that it was already cancelled by a high + // priority update. + if (continuation === null && prevCallbackNode === root.callbackNode) { + root.callbackNode = null; + root.callbackExpirationTime = NoWork; + } + } +} + +function flushInteractiveUpdates$3() { + if (workPhase === RenderPhase || workPhase === CommitPhase) { + // Can't synchronously flush interactive updates if React is already + // working. This is currently a no-op. + // TODO: Should we fire a warning? This happens if you synchronously invoke + // an input event inside an effect, like with `element.click()`. + return; + } + flushPendingDiscreteUpdates(); +} + +function resolveLocksOnRoot(root, expirationTime) { + var firstBatch = root.firstBatch; + if ( + firstBatch !== null && + firstBatch._defer && + firstBatch._expirationTime >= expirationTime + ) { + root.finishedWork = root.current.alternate; + root.pendingCommitExpirationTime = expirationTime; + scheduleCallback(NormalPriority, function() { + firstBatch._onComplete(); + return null; + }); + return true; + } else { + return false; + } +} + +function interactiveUpdates$3(fn, a, b, c) { + if (workPhase === NotWorking) { + // TODO: Remove this call. Instead of doing this automatically, the caller + // should explicitly call flushInteractiveUpdates. + flushPendingDiscreteUpdates(); + } + return runWithPriority(UserBlockingPriority, fn.bind(null, a, b, c)); +} + +function flushPendingDiscreteUpdates() { + if (rootsWithPendingDiscreteUpdates !== null) { + // For each root with pending discrete updates, schedule a callback to + // immediately flush them. + var roots = rootsWithPendingDiscreteUpdates; + rootsWithPendingDiscreteUpdates = null; + roots.forEach(function(expirationTime, root) { + scheduleCallback( + ImmediatePriority, + renderRoot$1.bind(null, root, expirationTime) + ); + }); + // Now flush the immediate queue. + flushImmediateQueue(); + } +} + +function batchedUpdates$3(fn, a) { + if (workPhase !== NotWorking) { + // We're already working, or inside a batch, so batchedUpdates is a no-op. + return fn(a); + } + workPhase = BatchedPhase; + try { + return fn(a); + } finally { + workPhase = NotWorking; + // Flush the immediate callbacks that were scheduled during this batch + flushImmediateQueue(); + } +} + +function prepareFreshStack(root, expirationTime) { + root.pendingCommitExpirationTime = NoWork; + + if (workInProgress !== null) { + var interruptedWork = workInProgress.return; + while (interruptedWork !== null) { + unwindInterruptedWork(interruptedWork); + interruptedWork = interruptedWork.return; + } + } + workInProgressRoot = root; + workInProgress = createWorkInProgress(root.current, null, expirationTime); + renderExpirationTime$1 = expirationTime; + workInProgressRootExitStatus = RootIncomplete; + workInProgressRootMostRecentEventTime = Sync; + + { + ReactStrictModeWarnings.discardPendingWarnings(); + } +} + +function renderRoot$1(root, expirationTime, isSync) { + (function() { + if (!(workPhase !== RenderPhase && workPhase !== CommitPhase)) { + throw ReactError("Should not already be working."); + } + })(); + + if (enableUserTimingAPI && expirationTime !== Sync) { + var didExpire = isSync; + var timeoutMs = expirationTimeToMs(expirationTime); + stopRequestCallbackTimer(didExpire, timeoutMs); + } + + if (root.firstPendingTime < expirationTime) { + // If there's no work left at this expiration time, exit immediately. This + // happens when multiple callbacks are scheduled for a single root, but an + // earlier callback flushes the work of a later one. + return null; + } + + if (root.pendingCommitExpirationTime === expirationTime) { + // There's already a pending commit at this expiration time. + root.pendingCommitExpirationTime = NoWork; + return commitRoot$1.bind(null, root, expirationTime); + } + + flushPassiveEffects$2(); + + // If the root or expiration time have changed, throw out the existing stack + // and prepare a fresh one. Otherwise we'll continue where we left off. + if ( + root !== workInProgressRoot || + expirationTime !== renderExpirationTime$1 + ) { + prepareFreshStack(root, expirationTime); + startWorkOnPendingInteraction(root, expirationTime); + } + + // If we have a work-in-progress fiber, it means there's still work to do + // in this root. + if (workInProgress !== null) { + var prevWorkPhase = workPhase; + workPhase = RenderPhase; + var prevDispatcher = ReactCurrentDispatcher$2.current; + if (prevDispatcher === null) { + // The React isomorphic package does not include a default dispatcher. + // Instead the first renderer will lazily attach one, in order to give + // nicer error messages. + prevDispatcher = ContextOnlyDispatcher; + } + ReactCurrentDispatcher$2.current = ContextOnlyDispatcher; + var prevInteractions = null; + if (enableSchedulerTracing) { + prevInteractions = tracing.__interactionsRef.current; + tracing.__interactionsRef.current = root.memoizedInteractions; + } + + startWorkLoopTimer(workInProgress); + + // TODO: Fork renderRoot into renderRootSync and renderRootAsync + if (isSync) { + if (expirationTime !== Sync) { + // An async update expired. There may be other expired updates on + // this root. We should render all the expired work in a + // single batch. + var currentTime = requestCurrentTime$2(); + if (currentTime < expirationTime) { + // Restart at the current time. + workPhase = prevWorkPhase; + resetContextDependences(); + ReactCurrentDispatcher$2.current = prevDispatcher; + if (enableSchedulerTracing) { + tracing.__interactionsRef.current = prevInteractions; + } + return renderRoot$1.bind(null, root, currentTime); + } + } + } else { + // Since we know we're in a React event, we can clear the current + // event time. The next update will compute a new event time. + currentEventTime = NoWork; + } + + do { + try { + if (isSync) { + workLoopSync(); + } else { + workLoop$1(); + } + break; + } catch (thrownValue) { + // Reset module-level state that was set during the render phase. + resetContextDependences(); + resetHooks(); + + var sourceFiber = workInProgress; + if (sourceFiber === null || sourceFiber.return === null) { + // Expected to be working on a non-root fiber. This is a fatal error + // because there's no ancestor that can handle it; the root is + // supposed to capture all errors that weren't caught by an error + // boundary. + prepareFreshStack(root, expirationTime); + workPhase = prevWorkPhase; + throw thrownValue; + } + + if (enableProfilerTimer && sourceFiber.mode & ProfileMode) { + // Record the time spent rendering before an error was thrown. This + // avoids inaccurate Profiler durations in the case of a + // suspended render. + stopProfilerTimerIfRunningAndRecordDelta(sourceFiber, true); + } + + var returnFiber = sourceFiber.return; + throwException( + root, + returnFiber, + sourceFiber, + thrownValue, + renderExpirationTime$1 + ); + workInProgress = completeUnitOfWork$1(sourceFiber); + } + } while (true); + + workPhase = prevWorkPhase; + resetContextDependences(); + ReactCurrentDispatcher$2.current = prevDispatcher; + if (enableSchedulerTracing) { + tracing.__interactionsRef.current = prevInteractions; + } + + if (workInProgress !== null) { + // There's still work left over. Return a continuation. + stopInterruptedWorkLoopTimer(); + if (expirationTime !== Sync) { + startRequestCallbackTimer(); + } + return renderRoot$1.bind(null, root, expirationTime); + } + } + + // We now have a consistent tree. The next step is either to commit it, or, if + // something suspended, wait to commit it after a timeout. + stopFinishedWorkLoopTimer(); + + var isLocked = resolveLocksOnRoot(root, expirationTime); + if (isLocked) { + // This root has a lock that prevents it from committing. Exit. If we begin + // work on the root again, without any intervening updates, it will finish + // without doing additional work. + return null; + } + + // Set this to null to indicate there's no in-progress render. + workInProgressRoot = null; + + switch (workInProgressRootExitStatus) { + case RootIncomplete: { + (function() { + { + throw ReactError("Should have a work-in-progress."); + } + })(); + } + // Flow knows about invariant, so it compains if I add a break statement, + // but eslint doesn't know about invariant, so it complains if I do. + // eslint-disable-next-line no-fallthrough + case RootErrored: { + // An error was thrown. First check if there is lower priority work + // scheduled on this root. + var lastPendingTime = root.lastPendingTime; + if (root.lastPendingTime < expirationTime) { + // There's lower priority work. Before raising the error, try rendering + // at the lower priority to see if it fixes it. Use a continuation to + // maintain the existing priority and position in the queue. + return renderRoot$1.bind(null, root, lastPendingTime); + } + if (!isSync) { + // If we're rendering asynchronously, it's possible the error was + // caused by tearing due to a mutation during an event. Try rendering + // one more time without yiedling to events. + prepareFreshStack(root, expirationTime); + scheduleCallback( + ImmediatePriority, + renderRoot$1.bind(null, root, expirationTime) + ); + return null; + } + // If we're already rendering synchronously, commit the root in its + // errored state. + return commitRoot$1.bind(null, root, expirationTime); + } + case RootSuspended: { + if (!isSync) { + var _lastPendingTime = root.lastPendingTime; + if (root.lastPendingTime < expirationTime) { + // There's lower priority work. It might be unsuspended. Try rendering + // at that level. + return renderRoot$1.bind(null, root, _lastPendingTime); + } + // If workInProgressRootMostRecentEventTime is Sync, that means we didn't + // track any event times. That can happen if we retried but nothing switched + // from fallback to content. There's no reason to delay doing no work. + if (workInProgressRootMostRecentEventTime !== Sync) { + var msUntilTimeout = computeMsUntilTimeout( + workInProgressRootMostRecentEventTime + ); + if (msUntilTimeout > 0) { + // The render is suspended, it hasn't timed out, and there's no lower + // priority work to do. Instead of committing the fallback + // immediately, wait for more data to arrive. + root.timeoutHandle = scheduleTimeout( + commitRoot$1.bind(null, root, expirationTime), + msUntilTimeout + ); + return null; + } + } + } + // The work expired. Commit immediately. + return commitRoot$1.bind(null, root, expirationTime); + } + case RootCompleted: { + // The work completed. Ready to commit. + return commitRoot$1.bind(null, root, expirationTime); + } + default: { + (function() { + { + throw ReactError("Unknown root exit status."); + } + })(); + } + } +} + +function markRenderEventTime$2(expirationTime) { + if (expirationTime < workInProgressRootMostRecentEventTime) { + workInProgressRootMostRecentEventTime = expirationTime; + } +} + +function renderDidSuspend$2() { + if (workInProgressRootExitStatus === RootIncomplete) { + workInProgressRootExitStatus = RootSuspended; + } +} + +function renderDidError$2() { + if ( + workInProgressRootExitStatus === RootIncomplete || + workInProgressRootExitStatus === RootSuspended + ) { + workInProgressRootExitStatus = RootErrored; + } +} + +function inferTimeFromExpirationTime$1(expirationTime) { + // We don't know exactly when the update was scheduled, but we can infer an + // approximate start time from the expiration time. + var earliestExpirationTimeMs = expirationTimeToMs(expirationTime); + return earliestExpirationTimeMs - LOW_PRIORITY_EXPIRATION + initialTimeMs; +} + +function workLoopSync() { + // Already timed out, so perform work without checking if we need to yield. + while (workInProgress !== null) { + workInProgress = performUnitOfWork$1(workInProgress); + } +} + +function workLoop$1() { + // Perform work until Scheduler asks us to yield + while (workInProgress !== null && !shouldYield()) { + workInProgress = performUnitOfWork$1(workInProgress); + } +} + +function performUnitOfWork$1(unitOfWork) { + // The current, flushed, state of this fiber is the alternate. Ideally + // nothing should rely on this, but relying on it here means that we don't + // need an additional field on the work in progress. + var current$$1 = unitOfWork.alternate; + + startWorkTimer(unitOfWork); + setCurrentFiber(unitOfWork); + + var next = void 0; + if (enableProfilerTimer && (unitOfWork.mode & ProfileMode) !== NoContext) { + startProfilerTimer(unitOfWork); + next = beginWork$1(current$$1, unitOfWork, renderExpirationTime$1); + stopProfilerTimerIfRunningAndRecordDelta(unitOfWork, true); + } else { + next = beginWork$1(current$$1, unitOfWork, renderExpirationTime$1); + } + + resetCurrentFiber(); + unitOfWork.memoizedProps = unitOfWork.pendingProps; + if (next === null) { + // If this doesn't spawn new work, complete the current work. + next = completeUnitOfWork$1(unitOfWork); + } + + ReactCurrentOwner$4.current = null; + return next; +} + +function completeUnitOfWork$1(unitOfWork) { + // Attempt to complete the current unit of work, then move to the next + // sibling. If there are no more siblings, return to the parent fiber. + workInProgress = unitOfWork; + do { + // The current, flushed, state of this fiber is the alternate. Ideally + // nothing should rely on this, but relying on it here means that we don't + // need an additional field on the work in progress. + var current$$1 = workInProgress.alternate; + var returnFiber = workInProgress.return; + + // Check if the work completed or if something threw. + if ((workInProgress.effectTag & Incomplete) === NoEffect) { + setCurrentFiber(workInProgress); + var next = void 0; + if ( + !enableProfilerTimer || + (workInProgress.mode & ProfileMode) === NoContext + ) { + next = completeWork(current$$1, workInProgress, renderExpirationTime$1); + } else { + startProfilerTimer(workInProgress); + next = completeWork(current$$1, workInProgress, renderExpirationTime$1); + // Update render duration assuming we didn't error. + stopProfilerTimerIfRunningAndRecordDelta(workInProgress, false); + } + stopWorkTimer(workInProgress); + resetCurrentFiber(); + resetChildExpirationTime$1(workInProgress); + + if (next !== null) { + // Completing this fiber spawned new work. Work on that next. + return next; + } + + if ( + returnFiber !== null && + // Do not append effects to parents if a sibling failed to complete + (returnFiber.effectTag & Incomplete) === NoEffect + ) { + // Append all the effects of the subtree and this fiber onto the effect + // list of the parent. The completion order of the children affects the + // side-effect order. + if (returnFiber.firstEffect === null) { + returnFiber.firstEffect = workInProgress.firstEffect; + } + if (workInProgress.lastEffect !== null) { + if (returnFiber.lastEffect !== null) { + returnFiber.lastEffect.nextEffect = workInProgress.firstEffect; + } + returnFiber.lastEffect = workInProgress.lastEffect; + } + + // If this fiber had side-effects, we append it AFTER the children's + // side-effects. We can perform certain side-effects earlier if needed, + // by doing multiple passes over the effect list. We don't want to + // schedule our own side-effect on our own list because if end up + // reusing children we'll schedule this effect onto itself since we're + // at the end. + var effectTag = workInProgress.effectTag; + + // Skip both NoWork and PerformedWork tags when creating the effect + // list. PerformedWork effect is read by React DevTools but shouldn't be + // committed. + if (effectTag > PerformedWork) { + if (returnFiber.lastEffect !== null) { + returnFiber.lastEffect.nextEffect = workInProgress; + } else { + returnFiber.firstEffect = workInProgress; + } + returnFiber.lastEffect = workInProgress; + } + } + } else { + // This fiber did not complete because something threw. Pop values off + // the stack without entering the complete phase. If this is a boundary, + // capture values if possible. + var _next = unwindWork(workInProgress, renderExpirationTime$1); + + // Because this fiber did not complete, don't reset its expiration time. + + if ( + enableProfilerTimer && + (workInProgress.mode & ProfileMode) !== NoContext + ) { + // Record the render duration for the fiber that errored. + stopProfilerTimerIfRunningAndRecordDelta(workInProgress, false); + + // Include the time spent working on failed children before continuing. + var actualDuration = workInProgress.actualDuration; + var child = workInProgress.child; + while (child !== null) { + actualDuration += child.actualDuration; + child = child.sibling; + } + workInProgress.actualDuration = actualDuration; + } + + if (_next !== null) { + // If completing this work spawned new work, do that next. We'll come + // back here again. + // Since we're restarting, remove anything that is not a host effect + // from the effect tag. + // TODO: The name stopFailedWorkTimer is misleading because Suspense + // also captures and restarts. + stopFailedWorkTimer(workInProgress); + _next.effectTag &= HostEffectMask; + return _next; + } + stopWorkTimer(workInProgress); + + if (returnFiber !== null) { + // Mark the parent fiber as incomplete and clear its effect list. + returnFiber.firstEffect = returnFiber.lastEffect = null; + returnFiber.effectTag |= Incomplete; + } + } + + var siblingFiber = workInProgress.sibling; + if (siblingFiber !== null) { + // If there is more work to do in this returnFiber, do that next. + return siblingFiber; + } + // Otherwise, return to the parent + workInProgress = returnFiber; + } while (workInProgress !== null); + + // We've reached the root. + if (workInProgressRootExitStatus === RootIncomplete) { + workInProgressRootExitStatus = RootCompleted; + } + return null; +} + +function resetChildExpirationTime$1(completedWork) { + if ( + renderExpirationTime$1 !== Never && + completedWork.childExpirationTime === Never + ) { + // The children of this component are hidden. Don't bubble their + // expiration times. + return; + } + + var newChildExpirationTime = NoWork; + + // Bubble up the earliest expiration time. + if (enableProfilerTimer && (completedWork.mode & ProfileMode) !== NoContext) { + // In profiling mode, resetChildExpirationTime is also used to reset + // profiler durations. + var actualDuration = completedWork.actualDuration; + var treeBaseDuration = completedWork.selfBaseDuration; + + // When a fiber is cloned, its actualDuration is reset to 0. This value will + // only be updated if work is done on the fiber (i.e. it doesn't bailout). + // When work is done, it should bubble to the parent's actualDuration. If + // the fiber has not been cloned though, (meaning no work was done), then + // this value will reflect the amount of time spent working on a previous + // render. In that case it should not bubble. We determine whether it was + // cloned by comparing the child pointer. + var shouldBubbleActualDurations = + completedWork.alternate === null || + completedWork.child !== completedWork.alternate.child; + + var child = completedWork.child; + while (child !== null) { + var childUpdateExpirationTime = child.expirationTime; + var childChildExpirationTime = child.childExpirationTime; + if (childUpdateExpirationTime > newChildExpirationTime) { + newChildExpirationTime = childUpdateExpirationTime; + } + if (childChildExpirationTime > newChildExpirationTime) { + newChildExpirationTime = childChildExpirationTime; + } + if (shouldBubbleActualDurations) { + actualDuration += child.actualDuration; + } + treeBaseDuration += child.treeBaseDuration; + child = child.sibling; + } + completedWork.actualDuration = actualDuration; + completedWork.treeBaseDuration = treeBaseDuration; + } else { + var _child = completedWork.child; + while (_child !== null) { + var _childUpdateExpirationTime = _child.expirationTime; + var _childChildExpirationTime = _child.childExpirationTime; + if (_childUpdateExpirationTime > newChildExpirationTime) { + newChildExpirationTime = _childUpdateExpirationTime; + } + if (_childChildExpirationTime > newChildExpirationTime) { + newChildExpirationTime = _childChildExpirationTime; + } + _child = _child.sibling; + } + } + + completedWork.childExpirationTime = newChildExpirationTime; +} + +function commitRoot$1(root, expirationTime) { + runWithPriority( + ImmediatePriority, + commitRootImpl.bind(null, root, expirationTime) + ); + // If there are passive effects, schedule a callback to flush them. This goes + // outside commitRootImpl so that it inherits the priority of the render. + if (rootWithPendingPassiveEffects$1 !== null) { + var priorityLevel = getCurrentPriorityLevel(); + scheduleCallback(priorityLevel, function() { + flushPassiveEffects$2(); + return null; + }); + } + return null; +} + +function commitRootImpl(root, expirationTime) { + flushPassiveEffects$2(); + flushRenderPhaseStrictModeWarningsInDEV(); + + (function() { + if (!(workPhase !== RenderPhase && workPhase !== CommitPhase)) { + throw ReactError("Should not already be working."); + } + })(); + var finishedWork = root.current.alternate; + (function() { + if (!(finishedWork !== null)) { + throw ReactError("Should have a work-in-progress root."); + } + })(); + + // commitRoot never returns a continuation; it always finishes synchronously. + // So we can clear these now to allow a new callback to be scheduled. + root.callbackNode = null; + root.callbackExpirationTime = NoWork; + + startCommitTimer(); + + // Update the first and last pending times on this root. The new first + // pending time is whatever is left on the root fiber. + var updateExpirationTimeBeforeCommit = finishedWork.expirationTime; + var childExpirationTimeBeforeCommit = finishedWork.childExpirationTime; + var firstPendingTimeBeforeCommit = + childExpirationTimeBeforeCommit > updateExpirationTimeBeforeCommit + ? childExpirationTimeBeforeCommit + : updateExpirationTimeBeforeCommit; + root.firstPendingTime = firstPendingTimeBeforeCommit; + if (firstPendingTimeBeforeCommit < root.lastPendingTime) { + // This usually means we've finished all the work, but it can also happen + // when something gets downprioritized during render, like a hidden tree. + root.lastPendingTime = firstPendingTimeBeforeCommit; + } + + if (root === workInProgressRoot) { + // We can reset these now that they are finished. + workInProgressRoot = null; + workInProgress = null; + renderExpirationTime$1 = NoWork; + } else { + } + // This indicates that the last root we worked on is not the same one that + // we're committing now. This most commonly happens when a suspended root + // times out. + + // Get the list of effects. + var firstEffect = void 0; + if (finishedWork.effectTag > PerformedWork) { + // A fiber's effect list consists only of its children, not itself. So if + // the root has an effect, we need to add it to the end of the list. The + // resulting list is the set that would belong to the root's parent, if it + // had one; that is, all the effects in the tree including the root. + if (finishedWork.lastEffect !== null) { + finishedWork.lastEffect.nextEffect = finishedWork; + firstEffect = finishedWork.firstEffect; + } else { + firstEffect = finishedWork; + } + } else { + // There is no effect on the root. + firstEffect = finishedWork.firstEffect; + } + + if (firstEffect !== null) { + var prevWorkPhase = workPhase; + workPhase = CommitPhase; + var prevInteractions = null; + if (enableSchedulerTracing) { + prevInteractions = tracing.__interactionsRef.current; + tracing.__interactionsRef.current = root.memoizedInteractions; + } + + // Reset this to null before calling lifecycles + ReactCurrentOwner$4.current = null; + + // The commit phase is broken into several sub-phases. We do a separate pass + // of the effect list for each phase: all mutation effects come before all + // layout effects, and so on. + + // The first phase a "before mutation" phase. We use this phase to read the + // state of the host tree right before we mutate it. This is where + // getSnapshotBeforeUpdate is called. + startCommitSnapshotEffectsTimer(); + prepareForCommit(root.containerInfo); + nextEffect$1 = firstEffect; + do { + { + invokeGuardedCallback(null, commitBeforeMutationEffects, null); + if (hasCaughtError()) { + (function() { + if (!(nextEffect$1 !== null)) { + throw ReactError("Should be working on an effect."); + } + })(); + var error = clearCaughtError(); + captureCommitPhaseError$2(nextEffect$1, error); + nextEffect$1 = nextEffect$1.nextEffect; + } + } + } while (nextEffect$1 !== null); + stopCommitSnapshotEffectsTimer(); + + if (enableProfilerTimer) { + // Mark the current commit time to be shared by all Profilers in this + // batch. This enables them to be grouped later. + recordCommitTime(); + } + + // The next phase is the mutation phase, where we mutate the host tree. + startCommitHostEffectsTimer(); + nextEffect$1 = firstEffect; + do { + { + invokeGuardedCallback(null, commitMutationEffects, null); + if (hasCaughtError()) { + (function() { + if (!(nextEffect$1 !== null)) { + throw ReactError("Should be working on an effect."); + } + })(); + var _error = clearCaughtError(); + captureCommitPhaseError$2(nextEffect$1, _error); + nextEffect$1 = nextEffect$1.nextEffect; + } + } + } while (nextEffect$1 !== null); + stopCommitHostEffectsTimer(); + resetAfterCommit(root.containerInfo); + + // The work-in-progress tree is now the current tree. This must come after + // the mutation phase, so that the previous tree is still current during + // componentWillUnmount, but before the layout phase, so that the finished + // work is current during componentDidMount/Update. + root.current = finishedWork; + + // The next phase is the layout phase, where we call effects that read + // the host tree after it's been mutated. The idiomatic use case for this is + // layout, but class component lifecycles also fire here for legacy reasons. + startCommitLifeCyclesTimer(); + nextEffect$1 = firstEffect; + do { + { + invokeGuardedCallback( + null, + commitLayoutEffects, + null, + root, + expirationTime + ); + if (hasCaughtError()) { + (function() { + if (!(nextEffect$1 !== null)) { + throw ReactError("Should be working on an effect."); + } + })(); + var _error2 = clearCaughtError(); + captureCommitPhaseError$2(nextEffect$1, _error2); + nextEffect$1 = nextEffect$1.nextEffect; + } + } + } while (nextEffect$1 !== null); + stopCommitLifeCyclesTimer(); + + nextEffect$1 = null; + + if (enableSchedulerTracing) { + tracing.__interactionsRef.current = prevInteractions; + } + workPhase = prevWorkPhase; + } else { + // No effects. + root.current = finishedWork; + // Measure these anyway so the flamegraph explicitly shows that there were + // no effects. + // TODO: Maybe there's a better way to report this. + startCommitSnapshotEffectsTimer(); + stopCommitSnapshotEffectsTimer(); + if (enableProfilerTimer) { + recordCommitTime(); + } + startCommitHostEffectsTimer(); + stopCommitHostEffectsTimer(); + startCommitLifeCyclesTimer(); + stopCommitLifeCyclesTimer(); + } + + stopCommitTimer(); + + if (rootDoesHavePassiveEffects) { + // This commit has passive effects. Stash a reference to them. But don't + // schedule a callback until after flushing layout work. + rootDoesHavePassiveEffects = false; + rootWithPendingPassiveEffects$1 = root; + pendingPassiveEffectsExpirationTime = expirationTime; + } else { + if (enableSchedulerTracing) { + // If there are no passive effects, then we can complete the pending + // interactions. Otherwise, we'll wait until after the passive effects + // are flushed. + finishPendingInteractions(root, expirationTime); + } + } + + // Check if there's remaining work on this root + var remainingExpirationTime = root.firstPendingTime; + if (remainingExpirationTime !== NoWork) { + var currentTime = requestCurrentTime$2(); + var priorityLevel = inferPriorityFromExpirationTime( + currentTime, + remainingExpirationTime + ); + scheduleCallbackForRoot(root, priorityLevel, remainingExpirationTime); + } else { + // If there's no remaining work, we can clear the set of already failed + // error boundaries. + legacyErrorBoundariesThatAlreadyFailed$1 = null; + } + + onCommitRoot(finishedWork.stateNode); + + if (remainingExpirationTime === Sync) { + // Count the number of times the root synchronously re-renders without + // finishing. If there are too many, it indicates an infinite update loop. + if (root === rootWithNestedUpdates) { + nestedUpdateCount$1++; + } else { + nestedUpdateCount$1 = 0; + rootWithNestedUpdates = root; + } + } else { + nestedUpdateCount$1 = 0; + } + + if (hasUncaughtError) { + hasUncaughtError = false; + var _error3 = firstUncaughtError; + firstUncaughtError = null; + throw _error3; + } + + if (workPhase === LegacyUnbatchedPhase) { + // This is a legacy edge case. We just committed the initial mount of + // a ReactDOM.render-ed root inside of batchedUpdates. The commit fired + // synchronously, but layout updates should be deferred until the end + // of the batch. + return null; + } + + // If layout work was scheduled, flush it now. + flushImmediateQueue(); + return null; +} + +function commitBeforeMutationEffects() { + while (nextEffect$1 !== null) { + if ((nextEffect$1.effectTag & Snapshot) !== NoEffect) { + setCurrentFiber(nextEffect$1); + recordEffect(); + + var current$$1 = nextEffect$1.alternate; + commitBeforeMutationLifeCycles(current$$1, nextEffect$1); + + resetCurrentFiber(); + } + nextEffect$1 = nextEffect$1.nextEffect; + } +} + +function commitMutationEffects() { + // TODO: Should probably move the bulk of this function to commitWork. + while (nextEffect$1 !== null) { + setCurrentFiber(nextEffect$1); + + var effectTag = nextEffect$1.effectTag; + + if (effectTag & ContentReset) { + commitResetTextContent(nextEffect$1); + } + + if (effectTag & Ref) { + var current$$1 = nextEffect$1.alternate; + if (current$$1 !== null) { + commitDetachRef(current$$1); + } + } + + // The following switch statement is only concerned about placement, + // updates, and deletions. To avoid needing to add a case for every possible + // bitmap value, we remove the secondary effects from the effect tag and + // switch on that value. + var primaryEffectTag = effectTag & (Placement | Update | Deletion); + switch (primaryEffectTag) { + case Placement: { + commitPlacement(nextEffect$1); + // Clear the "placement" from effect tag so that we know that this is + // inserted, before any life-cycles like componentDidMount gets called. + // TODO: findDOMNode doesn't rely on this any more but isMounted does + // and isMounted is deprecated anyway so we should be able to kill this. + nextEffect$1.effectTag &= ~Placement; + break; + } + case PlacementAndUpdate: { + // Placement + commitPlacement(nextEffect$1); + // Clear the "placement" from effect tag so that we know that this is + // inserted, before any life-cycles like componentDidMount gets called. + nextEffect$1.effectTag &= ~Placement; + + // Update + var _current = nextEffect$1.alternate; + commitWork(_current, nextEffect$1); + break; + } + case Update: { + var _current2 = nextEffect$1.alternate; + commitWork(_current2, nextEffect$1); + break; + } + case Deletion: { + commitDeletion(nextEffect$1); + break; + } + } + + // TODO: Only record a mutation effect if primaryEffectTag is non-zero. + recordEffect(); + + resetCurrentFiber(); + nextEffect$1 = nextEffect$1.nextEffect; + } +} + +function commitLayoutEffects(root, committedExpirationTime) { + // TODO: Should probably move the bulk of this function to commitWork. + while (nextEffect$1 !== null) { + setCurrentFiber(nextEffect$1); + + var effectTag = nextEffect$1.effectTag; + + if (effectTag & (Update | Callback)) { + recordEffect(); + var current$$1 = nextEffect$1.alternate; + commitLifeCycles(root, current$$1, nextEffect$1, committedExpirationTime); + } + + if (effectTag & Ref) { + recordEffect(); + commitAttachRef(nextEffect$1); + } + + if (effectTag & Passive) { + rootDoesHavePassiveEffects = true; + } + + resetCurrentFiber(); + nextEffect$1 = nextEffect$1.nextEffect; + } +} + +function flushPassiveEffects$2() { + if (rootWithPendingPassiveEffects$1 === null) { + return false; + } + var root = rootWithPendingPassiveEffects$1; + var expirationTime = pendingPassiveEffectsExpirationTime; + rootWithPendingPassiveEffects$1 = null; + pendingPassiveEffectsExpirationTime = NoWork; + + var prevInteractions = null; + if (enableSchedulerTracing) { + prevInteractions = tracing.__interactionsRef.current; + tracing.__interactionsRef.current = root.memoizedInteractions; + } + + (function() { + if (!(workPhase !== RenderPhase && workPhase !== CommitPhase)) { + throw ReactError("Cannot flush passive effects while already rendering."); + } + })(); + var prevWorkPhase = workPhase; + workPhase = CommitPhase; + + // Note: This currently assumes there are no passive effects on the root + // fiber, because the root is not part of its own effect list. This could + // change in the future. + var effect = root.current.firstEffect; + while (effect !== null) { + { + setCurrentFiber(effect); + invokeGuardedCallback(null, commitPassiveHookEffects, null, effect); + if (hasCaughtError()) { + (function() { + if (!(effect !== null)) { + throw ReactError("Should be working on an effect."); + } + })(); + var error = clearCaughtError(); + captureCommitPhaseError$2(effect, error); + } + resetCurrentFiber(); + } + effect = effect.nextEffect; + } + + if (enableSchedulerTracing) { + tracing.__interactionsRef.current = prevInteractions; + finishPendingInteractions(root, expirationTime); + } + + workPhase = prevWorkPhase; + flushImmediateQueue(); + + // If additional passive effects were scheduled, increment a counter. If this + // exceeds the limit, we'll fire a warning. + nestedPassiveUpdateCount = + rootWithPendingPassiveEffects$1 === null ? 0 : nestedPassiveUpdateCount + 1; + + return true; +} + +function isAlreadyFailedLegacyErrorBoundary$2(instance) { + return ( + legacyErrorBoundariesThatAlreadyFailed$1 !== null && + legacyErrorBoundariesThatAlreadyFailed$1.has(instance) + ); +} + +function markLegacyErrorBoundaryAsFailed$2(instance) { + if (legacyErrorBoundariesThatAlreadyFailed$1 === null) { + legacyErrorBoundariesThatAlreadyFailed$1 = new Set([instance]); + } else { + legacyErrorBoundariesThatAlreadyFailed$1.add(instance); + } +} + +function prepareToThrowUncaughtError(error) { + if (!hasUncaughtError) { + hasUncaughtError = true; + firstUncaughtError = error; + } +} +var onUncaughtError$2 = prepareToThrowUncaughtError; + +function captureCommitPhaseErrorOnRoot(rootFiber, sourceFiber, error) { + var errorInfo = createCapturedValue(error, sourceFiber); + var update = createRootErrorUpdate(rootFiber, errorInfo, Sync); + enqueueUpdate(rootFiber, update); + var root = markUpdateTimeFromFiberToRoot(rootFiber, Sync); + if (root !== null) { + scheduleCallbackForRoot(root, ImmediatePriority, Sync); + } +} + +function captureCommitPhaseError$2(sourceFiber, error) { + if (sourceFiber.tag === HostRoot) { + // Error was thrown at the root. There is no parent, so the root + // itself should capture it. + captureCommitPhaseErrorOnRoot(sourceFiber, sourceFiber, error); + return; + } + + var fiber = sourceFiber.return; + while (fiber !== null) { + if (fiber.tag === HostRoot) { + captureCommitPhaseErrorOnRoot(fiber, sourceFiber, error); + return; + } else if (fiber.tag === ClassComponent) { + var ctor = fiber.type; + var instance = fiber.stateNode; + if ( + typeof ctor.getDerivedStateFromError === "function" || + (typeof instance.componentDidCatch === "function" && + !isAlreadyFailedLegacyErrorBoundary$2(instance)) + ) { + var errorInfo = createCapturedValue(error, sourceFiber); + var update = createClassErrorUpdate( + fiber, + errorInfo, + // TODO: This is always sync + Sync + ); + enqueueUpdate(fiber, update); + var root = markUpdateTimeFromFiberToRoot(fiber, Sync); + if (root !== null) { + scheduleCallbackForRoot(root, ImmediatePriority, Sync); + } + return; + } + } + fiber = fiber.return; + } +} + +function pingSuspendedRoot$2(root, thenable, suspendedTime) { + var pingCache = root.pingCache; + if (pingCache !== null) { + // The thenable resolved, so we no longer need to memoize, because it will + // never be thrown again. + pingCache.delete(thenable); + } + + if (workInProgressRoot === root && renderExpirationTime$1 === suspendedTime) { + // Received a ping at the same priority level at which we're currently + // rendering. Restart from the root. Don't need to schedule a ping because + // we're already working on this tree. + prepareFreshStack(root, renderExpirationTime$1); + return; + } + + var lastPendingTime = root.lastPendingTime; + if (lastPendingTime < suspendedTime) { + // The root is no longer suspended at this time. + return; + } + + var pingTime = root.pingTime; + if (pingTime !== NoWork && pingTime < suspendedTime) { + // There's already a lower priority ping scheduled. + return; + } + + // Mark the time at which this ping was scheduled. + root.pingTime = suspendedTime; + + var currentTime = requestCurrentTime$2(); + var priorityLevel = inferPriorityFromExpirationTime( + currentTime, + suspendedTime + ); + scheduleCallbackForRoot(root, priorityLevel, suspendedTime); +} + +function retryTimedOutBoundary$2(boundaryFiber) { + // The boundary fiber (a Suspense component) previously timed out and was + // rendered in its fallback state. One of the promises that suspended it has + // resolved, which means at least part of the tree was likely unblocked. Try + // rendering again, at a new expiration time. + var currentTime = requestCurrentTime$2(); + var retryTime = computeExpirationForFiber$2(currentTime, boundaryFiber); + // TODO: Special case idle priority? + var priorityLevel = inferPriorityFromExpirationTime(currentTime, retryTime); + var root = markUpdateTimeFromFiberToRoot(boundaryFiber, retryTime); + if (root !== null) { + scheduleCallbackForRoot(root, priorityLevel, retryTime); + } +} + +function resolveRetryThenable$2(boundaryFiber, thenable) { + var retryCache = void 0; + if (enableSuspenseServerRenderer) { + switch (boundaryFiber.tag) { + case SuspenseComponent: + retryCache = boundaryFiber.stateNode; + break; + case DehydratedSuspenseComponent: + retryCache = boundaryFiber.memoizedState; + break; + default: + (function() { + { + throw ReactError( + "Pinged unknown suspense boundary type. This is probably a bug in React." + ); + } + })(); + } + } else { + retryCache = boundaryFiber.stateNode; + } + + if (retryCache !== null) { + // The thenable resolved, so we no longer need to memoize, because it will + // never be thrown again. + retryCache.delete(thenable); + } + + retryTimedOutBoundary$2(boundaryFiber); +} + +function computeMsUntilTimeout(mostRecentEventTime) { + if (disableYielding) { + // Timeout immediately when yielding is disabled. + return 0; + } + + var eventTimeMs = inferTimeFromExpirationTime$1(mostRecentEventTime); + var currentTimeMs = now(); + var timeElapsed = currentTimeMs - eventTimeMs; + + // TODO: Account for the Just Noticeable Difference + var timeoutMs = 150; + var msUntilTimeout = timeoutMs - timeElapsed; + // This is the value that is passed to `setTimeout`. + return msUntilTimeout < 0 ? 0 : msUntilTimeout; +} + +function checkForNestedUpdates() { + if (nestedUpdateCount$1 > NESTED_UPDATE_LIMIT$1) { + nestedUpdateCount$1 = 0; + rootWithNestedUpdates = null; + (function() { + { + throw ReactError( + "Maximum update depth exceeded. This can happen when a component repeatedly calls setState inside componentWillUpdate or componentDidUpdate. React limits the number of nested updates to prevent infinite loops." + ); + } + })(); + } + + { + if (nestedPassiveUpdateCount > NESTED_PASSIVE_UPDATE_LIMIT$1) { + nestedPassiveUpdateCount = 0; + warning$1( + false, + "Maximum update depth exceeded. This can happen when a component " + + "calls setState inside useEffect, but useEffect either doesn't " + + "have a dependency array, or one of the dependencies changes on " + + "every render." + ); + } + } +} + +function flushRenderPhaseStrictModeWarningsInDEV() { + { + ReactStrictModeWarnings.flushPendingUnsafeLifecycleWarnings(); + ReactStrictModeWarnings.flushLegacyContextWarning(); + + if (warnAboutDeprecatedLifecycles) { + ReactStrictModeWarnings.flushPendingDeprecationWarnings(); + } + } +} + +function stopFinishedWorkLoopTimer() { + var didCompleteRoot = true; + stopWorkLoopTimer(interruptedBy$1, didCompleteRoot); + interruptedBy$1 = null; +} + +function stopInterruptedWorkLoopTimer() { + // TODO: Track which fiber caused the interruption. + var didCompleteRoot = false; + stopWorkLoopTimer(interruptedBy$1, didCompleteRoot); + interruptedBy$1 = null; +} + +function checkForInterruption(fiberThatReceivedUpdate, updateExpirationTime) { + if ( + enableUserTimingAPI && + workInProgressRoot !== null && + updateExpirationTime > renderExpirationTime$1 + ) { + interruptedBy$1 = fiberThatReceivedUpdate; + } +} + +var didWarnStateUpdateForUnmountedComponent$1 = null; +function warnAboutUpdateOnUnmountedFiberInDEV(fiber) { + { + var tag = fiber.tag; + if ( + tag !== HostRoot && + tag !== ClassComponent && + tag !== FunctionComponent && + tag !== ForwardRef && + tag !== MemoComponent && + tag !== SimpleMemoComponent + ) { + // Only warn for user-defined components, not internal ones like Suspense. + return; + } + // We show the whole stack but dedupe on the top component's name because + // the problematic code almost always lies inside that component. + var componentName = getComponentName(fiber.type) || "ReactComponent"; + if (didWarnStateUpdateForUnmountedComponent$1 !== null) { + if (didWarnStateUpdateForUnmountedComponent$1.has(componentName)) { + return; + } + didWarnStateUpdateForUnmountedComponent$1.add(componentName); + } else { + didWarnStateUpdateForUnmountedComponent$1 = new Set([componentName]); + } + warningWithoutStack$1( + false, + "Can't perform a React state update on an unmounted component. This " + + "is a no-op, but it indicates a memory leak in your application. To " + + "fix, cancel all subscriptions and asynchronous tasks in %s.%s", + tag === ClassComponent + ? "the componentWillUnmount method" + : "a useEffect cleanup function", + getStackByFiberInDevAndProd(fiber) + ); + } +} + +var beginWork$1 = void 0; +if (true && replayFailedUnitOfWorkWithInvokeGuardedCallback) { + var dummyFiber = null; + beginWork$1 = function(current$$1, unitOfWork, expirationTime) { + // If a component throws an error, we replay it again in a synchronously + // dispatched event, so that the debugger will treat it as an uncaught + // error See ReactErrorUtils for more information. + + // Before entering the begin phase, copy the work-in-progress onto a dummy + // fiber. If beginWork throws, we'll use this to reset the state. + var originalWorkInProgressCopy = assignFiberPropertiesInDEV( + dummyFiber, + unitOfWork + ); + try { + return beginWork(current$$1, unitOfWork, expirationTime); + } catch (originalError) { + if ( + originalError !== null && + typeof originalError === "object" && + typeof originalError.then === "function" + ) { + // Don't replay promises. Treat everything else like an error. + throw originalError; + } + + // Keep this code in sync with renderRoot; any changes here must have + // corresponding changes there. + resetContextDependences(); + resetHooks(); + + // Unwind the failed stack frame + unwindInterruptedWork(unitOfWork); + + // Restore the original properties of the fiber. + assignFiberPropertiesInDEV(unitOfWork, originalWorkInProgressCopy); + + if (enableProfilerTimer && unitOfWork.mode & ProfileMode) { + // Reset the profiler timer. + startProfilerTimer(unitOfWork); + } + + // Run beginWork again. + invokeGuardedCallback( + null, + beginWork, + null, + current$$1, + unitOfWork, + expirationTime + ); + + if (hasCaughtError()) { + var replayError = clearCaughtError(); + // `invokeGuardedCallback` sometimes sets an expando `_suppressLogging`. + // Rethrow this error instead of the original one. + throw replayError; + } else { + // This branch is reachable if the render phase is impure. + throw originalError; + } + } + }; +} else { + beginWork$1 = beginWork; +} + +var didWarnAboutUpdateInRender = false; +var didWarnAboutUpdateInGetChildContext = false; +function warnAboutInvalidUpdatesOnClassComponentsInDEV(fiber) { + { + if (fiber.tag === ClassComponent) { + switch (phase) { + case "getChildContext": + if (didWarnAboutUpdateInGetChildContext) { + return; + } + warningWithoutStack$1( + false, + "setState(...): Cannot call setState() inside getChildContext()" + ); + didWarnAboutUpdateInGetChildContext = true; + break; + case "render": + if (didWarnAboutUpdateInRender) { + return; + } + warningWithoutStack$1( + false, + "Cannot update during an existing state transition (such as " + + "within `render`). Render methods should be a pure function of " + + "props and state." + ); + didWarnAboutUpdateInRender = true; + break; + } + } + } +} + +function warnIfNotCurrentlyActingUpdatesInDEV(fiber) { + { + if ( + workPhase === NotWorking && + ReactShouldWarnActingUpdates$1.current === false + ) { + warningWithoutStack$1( + false, + "An update to %s inside a test was not wrapped in act(...).\n\n" + + "When testing, code that causes React state updates should be " + + "wrapped into act(...):\n\n" + + "act(() => {\n" + + " /* fire events that update state */\n" + + "});\n" + + "/* assert on the output */\n\n" + + "This ensures that you're testing the behavior the user would see " + + "in the browser." + + " Learn more at https://fb.me/react-wrap-tests-with-act" + + "%s", + getComponentName(fiber.type), + getStackByFiberInDevAndProd(fiber) + ); + } + } +} + +var warnIfNotCurrentlyActingUpdatesInDev$2 = warnIfNotCurrentlyActingUpdatesInDEV; + +function computeThreadID$1(root, expirationTime) { + // Interaction threads are unique per root and expiration time. + return expirationTime * 1000 + root.interactionThreadID; +} + +function schedulePendingInteraction(root, expirationTime) { + // This is called when work is scheduled on a root. It sets up a pending + // interaction, which is completed once the work commits. + if (!enableSchedulerTracing) { + return; + } + + var interactions = tracing.__interactionsRef.current; + if (interactions.size > 0) { + var pendingInteractionMap = root.pendingInteractionMap; + var pendingInteractions = pendingInteractionMap.get(expirationTime); + if (pendingInteractions != null) { + interactions.forEach(function(interaction) { + if (!pendingInteractions.has(interaction)) { + // Update the pending async work count for previously unscheduled interaction. + interaction.__count++; + } + + pendingInteractions.add(interaction); + }); + } else { + pendingInteractionMap.set(expirationTime, new Set(interactions)); + + // Update the pending async work count for the current interactions. + interactions.forEach(function(interaction) { + interaction.__count++; + }); + } + + var subscriber = tracing.__subscriberRef.current; + if (subscriber !== null) { + var threadID = computeThreadID$1(root, expirationTime); + subscriber.onWorkScheduled(interactions, threadID); + } + } +} + +function startWorkOnPendingInteraction(root, expirationTime) { + // This is called when new work is started on a root. + if (!enableSchedulerTracing) { + return; + } + + // Determine which interactions this batch of work currently includes, So that + // we can accurately attribute time spent working on it, And so that cascading + // work triggered during the render phase will be associated with it. + var interactions = new Set(); + root.pendingInteractionMap.forEach(function( + scheduledInteractions, + scheduledExpirationTime + ) { + if (scheduledExpirationTime >= expirationTime) { + scheduledInteractions.forEach(function(interaction) { + return interactions.add(interaction); + }); + } + }); + + // Store the current set of interactions on the FiberRoot for a few reasons: + // We can re-use it in hot functions like renderRoot() without having to + // recalculate it. We will also use it in commitWork() to pass to any Profiler + // onRender() hooks. This also provides DevTools with a way to access it when + // the onCommitRoot() hook is called. + root.memoizedInteractions = interactions; + + if (interactions.size > 0) { + var subscriber = tracing.__subscriberRef.current; + if (subscriber !== null) { + var threadID = computeThreadID$1(root, expirationTime); + try { + subscriber.onWorkStarted(interactions, threadID); + } catch (error) { + // If the subscriber throws, rethrow it in a separate task + scheduleCallback(ImmediatePriority, function() { + throw error; + }); + } + } + } +} + +function finishPendingInteractions(root, committedExpirationTime) { + if (!enableSchedulerTracing) { + return; + } + + var earliestRemainingTimeAfterCommit = root.firstPendingTime; + + var subscriber = void 0; + + try { + subscriber = tracing.__subscriberRef.current; + if (subscriber !== null && root.memoizedInteractions.size > 0) { + var threadID = computeThreadID$1(root, committedExpirationTime); + subscriber.onWorkStopped(root.memoizedInteractions, threadID); + } + } catch (error) { + // If the subscriber throws, rethrow it in a separate task + scheduleCallback(ImmediatePriority, function() { + throw error; + }); + } finally { + // Clear completed interactions from the pending Map. + // Unless the render was suspended or cascading work was scheduled, + // In which case– leave pending interactions until the subsequent render. + var pendingInteractionMap = root.pendingInteractionMap; + pendingInteractionMap.forEach(function( + scheduledInteractions, + scheduledExpirationTime + ) { + // Only decrement the pending interaction count if we're done. + // If there's still work at the current priority, + // That indicates that we are waiting for suspense data. + if (scheduledExpirationTime > earliestRemainingTimeAfterCommit) { + pendingInteractionMap.delete(scheduledExpirationTime); + + scheduledInteractions.forEach(function(interaction) { + interaction.__count--; + + if (subscriber !== null && interaction.__count === 0) { + try { + subscriber.onInteractionScheduledWorkCompleted(interaction); + } catch (error) { + // If the subscriber throws, rethrow it in a separate task + scheduleCallback(ImmediatePriority, function() { + throw error; + }); + } + } + }); } - ); - } finally { - isBatchingUpdates = previousIsBatchingUpdates; - if (!isBatchingUpdates && !isRendering) { - performSyncWork(); - } + }); } } -function flushInteractiveUpdates$1() { - if ( - !isRendering && - lowestPriorityPendingInteractiveExpirationTime !== NoWork - ) { - // Synchronously flush pending interactive updates. - performWork(lowestPriorityPendingInteractiveExpirationTime, false); - lowestPriorityPendingInteractiveExpirationTime = NoWork; - } -} +var requestCurrentTime$$1 = enableNewScheduler + ? requestCurrentTime$2 + : requestCurrentTime$1; +var computeExpirationForFiber$$1 = enableNewScheduler + ? computeExpirationForFiber$2 + : computeExpirationForFiber$1; +var captureCommitPhaseError$$1 = enableNewScheduler + ? captureCommitPhaseError$2 + : captureCommitPhaseError$1; +var onUncaughtError$$1 = enableNewScheduler + ? onUncaughtError$2 + : onUncaughtError$1; +var markRenderEventTime$$1 = enableNewScheduler + ? markRenderEventTime$2 + : markRenderEventTime$1; +var renderDidSuspend$$1 = enableNewScheduler + ? renderDidSuspend$2 + : renderDidSuspend$1; +var renderDidError$$1 = enableNewScheduler + ? renderDidError$2 + : renderDidError$1; +var pingSuspendedRoot$$1 = enableNewScheduler + ? pingSuspendedRoot$2 + : pingSuspendedRoot$1; +var retryTimedOutBoundary$$1 = enableNewScheduler + ? retryTimedOutBoundary$2 + : retryTimedOutBoundary$1; +var resolveRetryThenable$$1 = enableNewScheduler + ? resolveRetryThenable$2 + : resolveRetryThenable$1; +var markLegacyErrorBoundaryAsFailed$$1 = enableNewScheduler + ? markLegacyErrorBoundaryAsFailed$2 + : markLegacyErrorBoundaryAsFailed$1; +var isAlreadyFailedLegacyErrorBoundary$$1 = enableNewScheduler + ? isAlreadyFailedLegacyErrorBoundary$2 + : isAlreadyFailedLegacyErrorBoundary$1; +var scheduleWork$$1 = enableNewScheduler ? scheduleWork$2 : scheduleWork$1; + +var batchedUpdates$1 = enableNewScheduler ? batchedUpdates$3 : batchedUpdates$2; + +var interactiveUpdates$1 = enableNewScheduler + ? interactiveUpdates$3 + : interactiveUpdates$2; +var flushInteractiveUpdates$1 = enableNewScheduler + ? flushInteractiveUpdates$3 + : flushInteractiveUpdates$2; + +var flushPassiveEffects$$1 = enableNewScheduler + ? flushPassiveEffects$2 + : flushPassiveEffects$1; +var warnIfNotCurrentlyActingUpdatesInDev$$1 = enableNewScheduler + ? warnIfNotCurrentlyActingUpdatesInDev$2 + : warnIfNotCurrentlyActingUpdatesInDev$1; // 0 is PROD, 1 is DEV. // Might add PROFILE later. @@ -18290,9 +21535,9 @@ function scheduleRootUpdate(current$$1, element, expirationTime, callback) { update.callback = callback; } - flushPassiveEffects(); + flushPassiveEffects$$1(); enqueueUpdate(current$$1, update); - scheduleWork(current$$1, expirationTime); + scheduleWork$$1(current$$1, expirationTime); return expirationTime; } @@ -18333,13 +21578,20 @@ function findHostInstance(component) { var fiber = get$1(component); if (fiber === undefined) { if (typeof component.render === "function") { - invariant(false, "Unable to find node on an unmounted component."); + (function() { + { + throw ReactError("Unable to find node on an unmounted component."); + } + })(); } else { - invariant( - false, - "Argument appears to not be a ReactComponent. Keys: %s", - Object.keys(component) - ); + (function() { + { + throw ReactError( + "Argument appears to not be a ReactComponent. Keys: " + + Object.keys(component) + ); + } + })(); } } var hostFiber = findCurrentHostFiber(fiber); @@ -18354,13 +21606,20 @@ function findHostInstanceWithWarning(component, methodName) { var fiber = get$1(component); if (fiber === undefined) { if (typeof component.render === "function") { - invariant(false, "Unable to find node on an unmounted component."); + (function() { + { + throw ReactError("Unable to find node on an unmounted component."); + } + })(); } else { - invariant( - false, - "Argument appears to not be a ReactComponent. Keys: %s", - Object.keys(component) - ); + (function() { + { + throw ReactError( + "Argument appears to not be a ReactComponent. Keys: " + + Object.keys(component) + ); + } + })(); } } var hostFiber = findCurrentHostFiber(fiber); @@ -18413,8 +21672,8 @@ function createContainer(containerInfo, isConcurrent, hydrate) { function updateContainer(element, container, parentComponent, callback) { var current$$1 = container.current; - var currentTime = requestCurrentTime(); - var expirationTime = computeExpirationForFiber(currentTime, current$$1); + var currentTime = requestCurrentTime$$1(); + var expirationTime = computeExpirationForFiber$$1(currentTime, current$$1); return updateContainerAtExpirationTime( element, container, @@ -18437,7 +21696,18 @@ function getPublicRootInstance(container) { } } +var shouldSuspendImpl = function(fiber) { + return false; +}; + +function shouldSuspend(fiber) { + return shouldSuspendImpl(fiber); +} + +var overrideHookState = null; var overrideProps = null; +var scheduleUpdate = null; +var setSuspenseHandler = null; { var copyWithSetImpl = function(obj, path, idx, value) { @@ -18455,14 +21725,50 @@ var overrideProps = null; return copyWithSetImpl(obj, path, 0, value); }; + // Support DevTools editable values for useState and useReducer. + overrideHookState = function(fiber, id, path, value) { + // For now, the "id" of stateful hooks is just the stateful hook index. + // This may change in the future with e.g. nested hooks. + var currentHook = fiber.memoizedState; + while (currentHook !== null && id > 0) { + currentHook = currentHook.next; + id--; + } + if (currentHook !== null) { + flushPassiveEffects$$1(); + + var newState = copyWithSet(currentHook.memoizedState, path, value); + currentHook.memoizedState = newState; + currentHook.baseState = newState; + + // We aren't actually adding an update to the queue, + // because there is no update we can add for useReducer hooks that won't trigger an error. + // (There's no appropriate action type for DevTools overrides.) + // As a result though, React will see the scheduled update as a noop and bailout. + // Shallow cloning props works as a workaround for now to bypass the bailout check. + fiber.memoizedProps = Object.assign({}, fiber.memoizedProps); + + scheduleWork$$1(fiber, Sync); + } + }; + // Support DevTools props for function components, forwardRef, memo, host components, etc. overrideProps = function(fiber, path, value) { - flushPassiveEffects(); + flushPassiveEffects$$1(); fiber.pendingProps = copyWithSet(fiber.memoizedProps, path, value); if (fiber.alternate) { fiber.alternate.pendingProps = fiber.pendingProps; } - scheduleWork(fiber, Sync); + scheduleWork$$1(fiber, Sync); + }; + + scheduleUpdate = function(fiber) { + flushPassiveEffects$$1(); + scheduleWork$$1(fiber, Sync); + }; + + setSuspenseHandler = function(newShouldSuspendImpl) { + shouldSuspendImpl = newShouldSuspendImpl; }; } @@ -18472,7 +21778,10 @@ function injectIntoDevTools(devToolsConfig) { return injectInternals( Object.assign({}, devToolsConfig, { + overrideHookState: overrideHookState, overrideProps: overrideProps, + setSuspenseHandler: setSuspenseHandler, + scheduleUpdate: scheduleUpdate, currentDispatcherRef: ReactCurrentDispatcher, findHostInstanceByFiber: function(fiber) { var hostFiber = findCurrentHostFiber(fiber); @@ -18516,7 +21825,7 @@ function createPortal( // TODO: this is special because it gets imported during build. -var ReactVersion = "16.8.1"; +var ReactVersion = "16.8.6"; // Modules provided by RN: var NativeMethodsMixin = function(findNodeHandle, findHostInstance) { @@ -18554,10 +21863,33 @@ var NativeMethodsMixin = function(findNodeHandle, findHostInstance) { * prop](docs/view.html#onlayout) instead. */ measure: function(callback) { - UIManager.measure( - findNodeHandle(this), - mountSafeCallback_NOT_REALLY_SAFE(this, callback) - ); + var maybeInstance = void 0; + + // Fiber errors if findNodeHandle is called for an umounted component. + // Tests using ReactTestRenderer will trigger this case indirectly. + // Mimicking stack behavior, we should silently ignore this case. + // TODO Fix ReactTestRenderer so we can remove this try/catch. + try { + maybeInstance = findHostInstance(this); + } catch (error) {} + + // If there is no host component beneath this we should fail silently. + // This is not an error; it could mean a class component rendered null. + if (maybeInstance == null) { + return; + } + + if (maybeInstance.canonical) { + FabricUIManager.measure( + maybeInstance.node, + mountSafeCallback_NOT_REALLY_SAFE(this, callback) + ); + } else { + UIManager.measure( + findNodeHandle(this), + mountSafeCallback_NOT_REALLY_SAFE(this, callback) + ); + } }, /** @@ -18576,10 +21908,33 @@ var NativeMethodsMixin = function(findNodeHandle, findHostInstance) { * has been completed in native. */ measureInWindow: function(callback) { - UIManager.measureInWindow( - findNodeHandle(this), - mountSafeCallback_NOT_REALLY_SAFE(this, callback) - ); + var maybeInstance = void 0; + + // Fiber errors if findNodeHandle is called for an umounted component. + // Tests using ReactTestRenderer will trigger this case indirectly. + // Mimicking stack behavior, we should silently ignore this case. + // TODO Fix ReactTestRenderer so we can remove this try/catch. + try { + maybeInstance = findHostInstance(this); + } catch (error) {} + + // If there is no host component beneath this we should fail silently. + // This is not an error; it could mean a class component rendered null. + if (maybeInstance == null) { + return; + } + + if (maybeInstance.canonical) { + FabricUIManager.measureInWindow( + maybeInstance.node, + mountSafeCallback_NOT_REALLY_SAFE(this, callback) + ); + } else { + UIManager.measureInWindow( + findNodeHandle(this), + mountSafeCallback_NOT_REALLY_SAFE(this, callback) + ); + } }, /** @@ -18595,12 +21950,56 @@ var NativeMethodsMixin = function(findNodeHandle, findHostInstance) { onSuccess, onFail /* currently unused */ ) { - UIManager.measureLayout( - findNodeHandle(this), - relativeToNativeNode, - mountSafeCallback_NOT_REALLY_SAFE(this, onFail), - mountSafeCallback_NOT_REALLY_SAFE(this, onSuccess) - ); + var maybeInstance = void 0; + + // Fiber errors if findNodeHandle is called for an umounted component. + // Tests using ReactTestRenderer will trigger this case indirectly. + // Mimicking stack behavior, we should silently ignore this case. + // TODO Fix ReactTestRenderer so we can remove this try/catch. + try { + maybeInstance = findHostInstance(this); + } catch (error) {} + + // If there is no host component beneath this we should fail silently. + // This is not an error; it could mean a class component rendered null. + if (maybeInstance == null) { + return; + } + + if (maybeInstance.canonical) { + warningWithoutStack$1( + false, + "Warning: measureLayout on components using NativeMethodsMixin " + + "or ReactNative.NativeComponent is not currently supported in Fabric. " + + "measureLayout must be called on a native ref. Consider using forwardRef." + ); + return; + } else { + var relativeNode = void 0; + + if (typeof relativeToNativeNode === "number") { + // Already a node handle + relativeNode = relativeToNativeNode; + } else if (relativeToNativeNode._nativeTag) { + relativeNode = relativeToNativeNode._nativeTag; + } + + if (relativeNode == null) { + warningWithoutStack$1( + false, + "Warning: ref.measureLayout must be called with a node handle or a ref to a native component." + ); + + return; + } + + UIManager.measureLayout( + findNodeHandle(this), + relativeNode, + mountSafeCallback_NOT_REALLY_SAFE(this, onFail), + mountSafeCallback_NOT_REALLY_SAFE(this, onSuccess) + ); + } }, /** @@ -18631,7 +22030,30 @@ var NativeMethodsMixin = function(findNodeHandle, findHostInstance) { return; } - var viewConfig = maybeInstance.viewConfig; + if (maybeInstance.canonical) { + warningWithoutStack$1( + false, + "Warning: setNativeProps is not currently supported in Fabric" + ); + return; + } + + { + if (warnAboutDeprecatedSetNativeProps) { + warningWithoutStack$1( + false, + "Warning: Calling ref.setNativeProps(nativeProps) " + + "is deprecated and will be removed in a future release. " + + "Use the setNativeProps export from the react-native package instead." + + "\n\timport {setNativeProps} from 'react-native';\n\tsetNativeProps(ref, nativeProps);\n" + ); + } + } + + var nativeTag = + maybeInstance._nativeTag || maybeInstance.canonical._nativeTag; + var viewConfig = + maybeInstance.viewConfig || maybeInstance.canonical.viewConfig; { warnForStyleProps(nativeProps, viewConfig.validAttributes); @@ -18644,7 +22066,7 @@ var NativeMethodsMixin = function(findNodeHandle, findHostInstance) { // view invalidation for certain components (eg RCTTextInput) on iOS. if (updatePayload != null) { UIManager.updateView( - maybeInstance._nativeTag, + nativeTag, viewConfig.uiViewClassName, updatePayload ); @@ -18672,13 +22094,18 @@ var NativeMethodsMixin = function(findNodeHandle, findHostInstance) { // true without actually implementing them (setting them to undefined // isn't allowed by ReactClass) var NativeMethodsMixin_DEV = NativeMethodsMixin; - invariant( - !NativeMethodsMixin_DEV.componentWillMount && - !NativeMethodsMixin_DEV.componentWillReceiveProps && - !NativeMethodsMixin_DEV.UNSAFE_componentWillMount && - !NativeMethodsMixin_DEV.UNSAFE_componentWillReceiveProps, - "Do not override existing functions." - ); + (function() { + if ( + !( + !NativeMethodsMixin_DEV.componentWillMount && + !NativeMethodsMixin_DEV.componentWillReceiveProps && + !NativeMethodsMixin_DEV.UNSAFE_componentWillMount && + !NativeMethodsMixin_DEV.UNSAFE_componentWillReceiveProps + ) + ) { + throw ReactError("Do not override existing functions."); + } + })(); // TODO (bvaughn) Remove cWM and cWRP in a future version of React Native, // Once these lifecycles have been remove from the reconciler. NativeMethodsMixin_DEV.componentWillMount = function() { @@ -18805,11 +22232,34 @@ var ReactNativeComponent = function(findNodeHandle, findHostInstance) { * [`onLayout` prop](docs/view.html#onlayout) instead. */ - ReactNativeComponent.prototype.measure = function measure(callback) { - UIManager.measure( - findNodeHandle(this), - mountSafeCallback_NOT_REALLY_SAFE(this, callback) - ); + ReactNativeComponent.prototype.measure = function measure$$1(callback) { + var maybeInstance = void 0; + + // Fiber errors if findNodeHandle is called for an umounted component. + // Tests using ReactTestRenderer will trigger this case indirectly. + // Mimicking stack behavior, we should silently ignore this case. + // TODO Fix ReactTestRenderer so we can remove this try/catch. + try { + maybeInstance = findHostInstance(this); + } catch (error) {} + + // If there is no host component beneath this we should fail silently. + // This is not an error; it could mean a class component rendered null. + if (maybeInstance == null) { + return; + } + + if (maybeInstance.canonical) { + FabricUIManager.measure( + maybeInstance.node, + mountSafeCallback_NOT_REALLY_SAFE(this, callback) + ); + } else { + UIManager.measure( + findNodeHandle(this), + mountSafeCallback_NOT_REALLY_SAFE(this, callback) + ); + } }; /** @@ -18826,13 +22276,36 @@ var ReactNativeComponent = function(findNodeHandle, findHostInstance) { * These values are not available until after natives rendering completes. */ - ReactNativeComponent.prototype.measureInWindow = function measureInWindow( + ReactNativeComponent.prototype.measureInWindow = function measureInWindow$$1( callback ) { - UIManager.measureInWindow( - findNodeHandle(this), - mountSafeCallback_NOT_REALLY_SAFE(this, callback) - ); + var maybeInstance = void 0; + + // Fiber errors if findNodeHandle is called for an umounted component. + // Tests using ReactTestRenderer will trigger this case indirectly. + // Mimicking stack behavior, we should silently ignore this case. + // TODO Fix ReactTestRenderer so we can remove this try/catch. + try { + maybeInstance = findHostInstance(this); + } catch (error) {} + + // If there is no host component beneath this we should fail silently. + // This is not an error; it could mean a class component rendered null. + if (maybeInstance == null) { + return; + } + + if (maybeInstance.canonical) { + FabricUIManager.measureInWindow( + maybeInstance.node, + mountSafeCallback_NOT_REALLY_SAFE(this, callback) + ); + } else { + UIManager.measureInWindow( + findNodeHandle(this), + mountSafeCallback_NOT_REALLY_SAFE(this, callback) + ); + } }; /** @@ -18847,12 +22320,56 @@ var ReactNativeComponent = function(findNodeHandle, findHostInstance) { onSuccess, onFail /* currently unused */ ) { - UIManager.measureLayout( - findNodeHandle(this), - relativeToNativeNode, - mountSafeCallback_NOT_REALLY_SAFE(this, onFail), - mountSafeCallback_NOT_REALLY_SAFE(this, onSuccess) - ); + var maybeInstance = void 0; + + // Fiber errors if findNodeHandle is called for an umounted component. + // Tests using ReactTestRenderer will trigger this case indirectly. + // Mimicking stack behavior, we should silently ignore this case. + // TODO Fix ReactTestRenderer so we can remove this try/catch. + try { + maybeInstance = findHostInstance(this); + } catch (error) {} + + // If there is no host component beneath this we should fail silently. + // This is not an error; it could mean a class component rendered null. + if (maybeInstance == null) { + return; + } + + if (maybeInstance.canonical) { + warningWithoutStack$1( + false, + "Warning: measureLayout on components using NativeMethodsMixin " + + "or ReactNative.NativeComponent is not currently supported in Fabric. " + + "measureLayout must be called on a native ref. Consider using forwardRef." + ); + return; + } else { + var relativeNode = void 0; + + if (typeof relativeToNativeNode === "number") { + // Already a node handle + relativeNode = relativeToNativeNode; + } else if (relativeToNativeNode._nativeTag) { + relativeNode = relativeToNativeNode._nativeTag; + } + + if (relativeNode == null) { + warningWithoutStack$1( + false, + "Warning: ref.measureLayout must be called with a node handle or a ref to a native component." + ); + + return; + } + + UIManager.measureLayout( + findNodeHandle(this), + relativeNode, + mountSafeCallback_NOT_REALLY_SAFE(this, onFail), + mountSafeCallback_NOT_REALLY_SAFE(this, onSuccess) + ); + } }; /** @@ -18886,6 +22403,28 @@ var ReactNativeComponent = function(findNodeHandle, findHostInstance) { return; } + if (maybeInstance.canonical) { + warningWithoutStack$1( + false, + "Warning: setNativeProps is not currently supported in Fabric" + ); + return; + } + + { + if (warnAboutDeprecatedSetNativeProps) { + warningWithoutStack$1( + false, + "Warning: Calling ref.setNativeProps(nativeProps) " + + "is deprecated and will be removed in a future release. " + + "Use the setNativeProps export from the react-native package instead." + + "\n\timport {setNativeProps} from 'react-native';\n\tsetNativeProps(ref, nativeProps);\n" + ); + } + } + + var nativeTag = + maybeInstance._nativeTag || maybeInstance.canonical._nativeTag; var viewConfig = maybeInstance.viewConfig || maybeInstance.canonical.viewConfig; @@ -18896,7 +22435,7 @@ var ReactNativeComponent = function(findNodeHandle, findHostInstance) { // view invalidation for certain components (eg RCTTextInput) on iOS. if (updatePayload != null) { UIManager.updateView( - maybeInstance._nativeTag, + nativeTag, viewConfig.uiViewClassName, updatePayload ); @@ -19018,6 +22557,36 @@ var getInspectorDataForViewTag = void 0; }; } +// Module provided by RN: +function setNativeProps(handle, nativeProps) { + if (handle._nativeTag == null) { + !(handle._nativeTag != null) + ? warningWithoutStack$1( + false, + "setNativeProps was called with a ref that isn't a " + + "native component. Use React.forwardRef to get access to the underlying native component" + ) + : void 0; + return; + } + + { + warnForStyleProps(nativeProps, handle.viewConfig.validAttributes); + } + + var updatePayload = create(nativeProps, handle.viewConfig.validAttributes); + // Avoid the overhead of bridge calls if there's no update. + // This is an expensive no-op for Android, and causes an unnecessary + // view invalidation for certain components (eg RCTTextInput) on iOS. + if (updatePayload != null) { + UIManager.updateView( + handle._nativeTag, + handle.viewConfig.uiViewClassName, + updatePayload + ); + } +} + // TODO: direct imports like some-package/src/* are bad. Fix me. // Module provided by RN: var ReactCurrentOwner = ReactSharedInternals.ReactCurrentOwner; @@ -19093,6 +22662,8 @@ var ReactNativeRenderer = { findNodeHandle: findNodeHandle, + setNativeProps: setNativeProps, + render: function(element, containerTag, callback) { var root = roots.get(containerTag); diff --git a/Libraries/Renderer/oss/ReactNativeRenderer-prod.js b/Libraries/Renderer/oss/ReactNativeRenderer-prod.js index a9a20a350ad2f6..a8645a716e16fa 100644 --- a/Libraries/Renderer/oss/ReactNativeRenderer-prod.js +++ b/Libraries/Renderer/oss/ReactNativeRenderer-prod.js @@ -18,78 +18,14 @@ var ReactNativeViewConfigRegistry = require("ReactNativeViewConfigRegistry"), React = require("react"), deepDiffer = require("deepDiffer"), flattenStyle = require("flattenStyle"), - TextInputState = require("TextInputState"); -var scheduler = require("scheduler"), - ExceptionsManager = require("ExceptionsManager"); -function invariant(condition, format, a, b, c, d, e, f) { - if (!condition) { - condition = void 0; - if (void 0 === format) - condition = Error( - "Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings." - ); - else { - var args = [a, b, c, d, e, f], - argIndex = 0; - condition = Error( - format.replace(/%s/g, function() { - return args[argIndex++]; - }) - ); - condition.name = "Invariant Violation"; - } - condition.framesToPop = 1; - throw condition; - } -} -function invokeGuardedCallbackImpl(name, func, context, a, b, c, d, e, f) { - var funcArgs = Array.prototype.slice.call(arguments, 3); - try { - func.apply(context, funcArgs); - } catch (error) { - this.onError(error); - } -} -var hasError = !1, - caughtError = null, - hasRethrowError = !1, - rethrowError = null, - reporter = { - onError: function(error) { - hasError = !0; - caughtError = error; - } - }; -function invokeGuardedCallback(name, func, context, a, b, c, d, e, f) { - hasError = !1; - caughtError = null; - invokeGuardedCallbackImpl.apply(reporter, arguments); -} -function invokeGuardedCallbackAndCatchFirstError( - name, - func, - context, - a, - b, - c, - d, - e, - f -) { - invokeGuardedCallback.apply(this, arguments); - if (hasError) { - if (hasError) { - var error = caughtError; - hasError = !1; - caughtError = null; - } else - invariant( - !1, - "clearCaughtError was called but no error was captured. This error is likely caused by a bug in React. Please file an issue." - ), - (error = void 0); - hasRethrowError || ((hasRethrowError = !0), (rethrowError = error)); - } + TextInputState = require("TextInputState"), + Scheduler = require("scheduler"); +var ExceptionsManager = require("ExceptionsManager"), + FabricUIManager = require("FabricUIManager"); +function ReactError(message) { + message = Error(message); + message.name = "Invariant Violation"; + return message; } var eventPluginOrder = null, namesToPlugins = {}; @@ -98,17 +34,19 @@ function recomputePluginOrdering() { for (var pluginName in namesToPlugins) { var pluginModule = namesToPlugins[pluginName], pluginIndex = eventPluginOrder.indexOf(pluginName); - invariant( - -1 < pluginIndex, - "EventPluginRegistry: Cannot inject event plugins that do not exist in the plugin ordering, `%s`.", - pluginName - ); - if (!plugins[pluginIndex]) { - invariant( - pluginModule.extractEvents, - "EventPluginRegistry: Event plugins must implement an `extractEvents` method, but `%s` does not.", - pluginName + if (!(-1 < pluginIndex)) + throw ReactError( + "EventPluginRegistry: Cannot inject event plugins that do not exist in the plugin ordering, `" + + pluginName + + "`." ); + if (!plugins[pluginIndex]) { + if (!pluginModule.extractEvents) + throw ReactError( + "EventPluginRegistry: Event plugins must implement an `extractEvents` method, but `" + + pluginName + + "` does not." + ); plugins[pluginIndex] = pluginModule; pluginIndex = pluginModule.eventTypes; for (var eventName in pluginIndex) { @@ -116,11 +54,12 @@ function recomputePluginOrdering() { var dispatchConfig = pluginIndex[eventName], pluginModule$jscomp$0 = pluginModule, eventName$jscomp$0 = eventName; - invariant( - !eventNameDispatchConfigs.hasOwnProperty(eventName$jscomp$0), - "EventPluginHub: More than one plugin attempted to publish the same event name, `%s`.", - eventName$jscomp$0 - ); + if (eventNameDispatchConfigs.hasOwnProperty(eventName$jscomp$0)) + throw ReactError( + "EventPluginHub: More than one plugin attempted to publish the same event name, `" + + eventName$jscomp$0 + + "`." + ); eventNameDispatchConfigs[eventName$jscomp$0] = dispatchConfig; var phasedRegistrationNames = dispatchConfig.phasedRegistrationNames; if (phasedRegistrationNames) { @@ -143,28 +82,78 @@ function recomputePluginOrdering() { ), (JSCompiler_inline_result = !0)) : (JSCompiler_inline_result = !1); - invariant( - JSCompiler_inline_result, - "EventPluginRegistry: Failed to publish event `%s` for plugin `%s`.", - eventName, - pluginName - ); + if (!JSCompiler_inline_result) + throw ReactError( + "EventPluginRegistry: Failed to publish event `" + + eventName + + "` for plugin `" + + pluginName + + "`." + ); } } } } function publishRegistrationName(registrationName, pluginModule) { - invariant( - !registrationNameModules[registrationName], - "EventPluginHub: More than one plugin attempted to publish the same registration name, `%s`.", - registrationName - ); + if (registrationNameModules[registrationName]) + throw ReactError( + "EventPluginHub: More than one plugin attempted to publish the same registration name, `" + + registrationName + + "`." + ); registrationNameModules[registrationName] = pluginModule; } var plugins = [], eventNameDispatchConfigs = {}, - registrationNameModules = {}, - getFiberCurrentPropsFromNode = null, + registrationNameModules = {}; +function invokeGuardedCallbackImpl(name, func, context, a, b, c, d, e, f) { + var funcArgs = Array.prototype.slice.call(arguments, 3); + try { + func.apply(context, funcArgs); + } catch (error) { + this.onError(error); + } +} +var hasError = !1, + caughtError = null, + hasRethrowError = !1, + rethrowError = null, + reporter = { + onError: function(error) { + hasError = !0; + caughtError = error; + } + }; +function invokeGuardedCallback(name, func, context, a, b, c, d, e, f) { + hasError = !1; + caughtError = null; + invokeGuardedCallbackImpl.apply(reporter, arguments); +} +function invokeGuardedCallbackAndCatchFirstError( + name, + func, + context, + a, + b, + c, + d, + e, + f +) { + invokeGuardedCallback.apply(this, arguments); + if (hasError) { + if (hasError) { + var error = caughtError; + hasError = !1; + caughtError = null; + } else + throw ReactError( + "clearCaughtError was called but no error was captured. This error is likely caused by a bug in React. Please file an issue." + ); + hasRethrowError || ((hasRethrowError = !0), (rethrowError = error)); + } +} +var getFiberCurrentPropsFromNode = null, getInstanceFromNode = null, getNodeFromInstance = null; function executeDispatch(event, listener, inst) { @@ -176,10 +165,8 @@ function executeDispatch(event, listener, inst) { function executeDirectDispatch(event) { var dispatchListener = event._dispatchListeners, dispatchInstance = event._dispatchInstances; - invariant( - !Array.isArray(dispatchListener), - "executeDirectDispatch(...): Invalid `event`." - ); + if (Array.isArray(dispatchListener)) + throw ReactError("executeDirectDispatch(...): Invalid `event`."); event.currentTarget = dispatchListener ? getNodeFromInstance(dispatchInstance) : null; @@ -190,10 +177,10 @@ function executeDirectDispatch(event) { return dispatchListener; } function accumulateInto(current, next) { - invariant( - null != next, - "accumulateInto(...): Accumulated items must not be null or undefined." - ); + if (null == next) + throw ReactError( + "accumulateInto(...): Accumulated items must not be null or undefined." + ); if (null == current) return next; if (Array.isArray(current)) { if (Array.isArray(next)) return current.push.apply(current, next), current; @@ -227,10 +214,10 @@ function executeDispatchesAndReleaseTopLevel(e) { } var injection = { injectEventPluginOrder: function(injectedEventPluginOrder) { - invariant( - !eventPluginOrder, - "EventPluginRegistry: Cannot inject event plugin ordering more than once. You are likely trying to load more than one copy of React." - ); + if (eventPluginOrder) + throw ReactError( + "EventPluginRegistry: Cannot inject event plugin ordering more than once. You are likely trying to load more than one copy of React." + ); eventPluginOrder = Array.prototype.slice.call(injectedEventPluginOrder); recomputePluginOrdering(); }, @@ -240,15 +227,19 @@ var injection = { for (pluginName in injectedNamesToPlugins) if (injectedNamesToPlugins.hasOwnProperty(pluginName)) { var pluginModule = injectedNamesToPlugins[pluginName]; - (namesToPlugins.hasOwnProperty(pluginName) && - namesToPlugins[pluginName] === pluginModule) || - (invariant( - !namesToPlugins[pluginName], - "EventPluginRegistry: Cannot inject two different event plugins using the same name, `%s`.", - pluginName - ), - (namesToPlugins[pluginName] = pluginModule), - (isOrderingDirty = !0)); + if ( + !namesToPlugins.hasOwnProperty(pluginName) || + namesToPlugins[pluginName] !== pluginModule + ) { + if (namesToPlugins[pluginName]) + throw ReactError( + "EventPluginRegistry: Cannot inject two different event plugins using the same name, `" + + pluginName + + "`." + ); + namesToPlugins[pluginName] = pluginModule; + isOrderingDirty = !0; + } } isOrderingDirty && recomputePluginOrdering(); } @@ -284,12 +275,14 @@ function getListener(inst, registrationName) { inst = !1; } if (inst) return null; - invariant( - !listener || "function" === typeof listener, - "Expected `%s` listener to be a function, instead got a value of `%s` type.", - registrationName, - typeof listener - ); + if (listener && "function" !== typeof listener) + throw ReactError( + "Expected `" + + registrationName + + "` listener to be a function, instead got a value of `" + + typeof listener + + "` type." + ); return listener; } function getParent(inst) { @@ -450,10 +443,10 @@ function getPooledEvent(dispatchConfig, targetInst, nativeEvent, nativeInst) { return new this(dispatchConfig, targetInst, nativeEvent, nativeInst); } function releasePooledEvent(event) { - invariant( - event instanceof this, - "Trying to release an event instance into a pool of a different type." - ); + if (!(event instanceof this)) + throw ReactError( + "Trying to release an event instance into a pool of a different type." + ); event.destructor(); 10 > this.eventPool.length && this.eventPool.push(event); } @@ -488,7 +481,7 @@ function timestampForTouch(touch) { } function getTouchIdentifier(_ref) { _ref = _ref.identifier; - invariant(null != _ref, "Touch object is missing identifier."); + if (null == _ref) throw ReactError("Touch object is missing identifier."); return _ref; } function recordTouchStart(touch) { @@ -601,10 +594,10 @@ var ResponderTouchHistoryStore = { touchHistory: touchHistory }; function accumulate(current, next) { - invariant( - null != next, - "accumulate(...): Accumulated items must be not be null or undefined." - ); + if (null == next) + throw ReactError( + "accumulate(...): Accumulated items must be not be null or undefined." + ); return null == current ? next : Array.isArray(current) @@ -969,11 +962,10 @@ var eventTypes$1 = { ReactNativeViewConfigRegistry.customBubblingEventTypes[topLevelType], directDispatchConfig = ReactNativeViewConfigRegistry.customDirectEventTypes[topLevelType]; - invariant( - bubbleDispatchConfig || directDispatchConfig, - 'Unsupported top level event type "%s" dispatched', - topLevelType - ); + if (!bubbleDispatchConfig && !directDispatchConfig) + throw ReactError( + 'Unsupported top level event type "' + topLevelType + '" dispatched' + ); topLevelType = SyntheticEvent.getPooled( bubbleDispatchConfig || directDispatchConfig, targetInst, @@ -1004,14 +996,10 @@ function getInstanceFromTag(tag) { var restoreTarget = null, restoreQueue = null; function restoreStateOfTarget(target) { - if ((target = getInstanceFromNode(target))) { - invariant( - !1, + if (getInstanceFromNode(target)) + throw ReactError( "setRestoreImplementation() needs to be called to handle a target for controlled events. This error is likely caused by a bug in React. Please file an issue." ); - var props = getFiberCurrentPropsFromNode(target.stateNode); - null(target.stateNode, target.type, props); - } } function _batchedUpdatesImpl(fn, bookkeeping) { return fn(bookkeeping); @@ -1059,19 +1047,18 @@ function _receiveRootNodeIDEvent(rootNodeID, topLevelType, nativeEventParam) { null !== events && (eventQueue = accumulateInto(eventQueue, events)); events = eventQueue; eventQueue = null; - if ( - events && - (forEachAccumulated(events, executeDispatchesAndReleaseTopLevel), - invariant( - !eventQueue, - "processEventQueue(): Additional events were enqueued while processing an event queue. Support for this has not yet been implemented." - ), - hasRethrowError) - ) - throw ((events = rethrowError), - (hasRethrowError = !1), - (rethrowError = null), - events); + if (events) { + forEachAccumulated(events, executeDispatchesAndReleaseTopLevel); + if (eventQueue) + throw ReactError( + "processEventQueue(): Additional events were enqueued while processing an event queue. Support for this has not yet been implemented." + ); + if (hasRethrowError) + throw ((events = rethrowError), + (hasRethrowError = !1), + (rethrowError = null), + events); + } }); } RCTEventEmitter.register({ @@ -1118,7 +1105,7 @@ getInstanceFromNode = getInstanceFromTag; getNodeFromInstance = function(inst) { var tag = inst.stateNode._nativeTag; void 0 === tag && (tag = inst.stateNode.canonical._nativeTag); - invariant(tag, "All native instances should have a tag."); + if (!tag) throw ReactError("All native instances should have a tag."); return tag; }; ResponderEventPlugin.injection.injectGlobalResponderHandler({ @@ -1147,6 +1134,15 @@ var hasSymbol = "function" === typeof Symbol && Symbol.for, REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for("react.suspense") : 60113, REACT_MEMO_TYPE = hasSymbol ? Symbol.for("react.memo") : 60115, REACT_LAZY_TYPE = hasSymbol ? Symbol.for("react.lazy") : 60116, + REACT_EVENT_COMPONENT_TYPE = hasSymbol + ? Symbol.for("react.event_component") + : 60117, + REACT_EVENT_TARGET_TYPE = hasSymbol + ? Symbol.for("react.event_target") + : 60118, + REACT_EVENT_TARGET_TOUCH_HIT = hasSymbol + ? Symbol.for("react.event_target.touch_hit") + : 60119, MAYBE_ITERATOR_SYMBOL = "function" === typeof Symbol && Symbol.iterator; function getIteratorFn(maybeIterable) { if (null === maybeIterable || "object" !== typeof maybeIterable) return null; @@ -1191,6 +1187,15 @@ function getComponentName(type) { case REACT_LAZY_TYPE: if ((type = 1 === type._status ? type._result : null)) return getComponentName(type); + break; + case REACT_EVENT_COMPONENT_TYPE: + type = type.displayName; + if (void 0 !== type) return type; + break; + case REACT_EVENT_TARGET_TYPE: + if (type.type === REACT_EVENT_TARGET_TOUCH_HIT) return "TouchHitTarget"; + type = type.displayName; + if (void 0 !== type) return type; } return null; } @@ -1205,80 +1210,83 @@ function isFiberMountedImpl(fiber) { return 3 === node.tag ? 2 : 3; } function assertIsMounted(fiber) { - invariant( - 2 === isFiberMountedImpl(fiber), - "Unable to find node on an unmounted component." - ); + if (2 !== isFiberMountedImpl(fiber)) + throw ReactError("Unable to find node on an unmounted component."); } function findCurrentFiberUsingSlowPath(fiber) { var alternate = fiber.alternate; - if (!alternate) - return ( - (alternate = isFiberMountedImpl(fiber)), - invariant( - 3 !== alternate, - "Unable to find node on an unmounted component." - ), - 1 === alternate ? null : fiber - ); + if (!alternate) { + alternate = isFiberMountedImpl(fiber); + if (3 === alternate) + throw ReactError("Unable to find node on an unmounted component."); + return 1 === alternate ? null : fiber; + } for (var a = fiber, b = alternate; ; ) { - var parentA = a.return, - parentB = parentA ? parentA.alternate : null; - if (!parentA || !parentB) break; + var parentA = a.return; + if (null === parentA) break; + var parentB = parentA.alternate; + if (null === parentB) { + b = parentA.return; + if (null !== b) { + a = b; + continue; + } + break; + } if (parentA.child === parentB.child) { - for (var child = parentA.child; child; ) { - if (child === a) return assertIsMounted(parentA), fiber; - if (child === b) return assertIsMounted(parentA), alternate; - child = child.sibling; + for (parentB = parentA.child; parentB; ) { + if (parentB === a) return assertIsMounted(parentA), fiber; + if (parentB === b) return assertIsMounted(parentA), alternate; + parentB = parentB.sibling; } - invariant(!1, "Unable to find node on an unmounted component."); + throw ReactError("Unable to find node on an unmounted component."); } if (a.return !== b.return) (a = parentA), (b = parentB); else { - child = !1; - for (var _child = parentA.child; _child; ) { + for (var didFindChild = !1, _child = parentA.child; _child; ) { if (_child === a) { - child = !0; + didFindChild = !0; a = parentA; b = parentB; break; } if (_child === b) { - child = !0; + didFindChild = !0; b = parentA; a = parentB; break; } _child = _child.sibling; } - if (!child) { + if (!didFindChild) { for (_child = parentB.child; _child; ) { if (_child === a) { - child = !0; + didFindChild = !0; a = parentB; b = parentA; break; } if (_child === b) { - child = !0; + didFindChild = !0; b = parentB; a = parentA; break; } _child = _child.sibling; } - invariant( - child, - "Child was not found in either parent set. This indicates a bug in React related to the return pointer. Please file an issue." - ); + if (!didFindChild) + throw ReactError( + "Child was not found in either parent set. This indicates a bug in React related to the return pointer. Please file an issue." + ); } } - invariant( - a.alternate === b, - "Return fibers should always be each others' alternates. This error is likely caused by a bug in React. Please file an issue." - ); + if (a.alternate !== b) + throw ReactError( + "Return fibers should always be each others' alternates. This error is likely caused by a bug in React. Please file an issue." + ); } - invariant(3 === a.tag, "Unable to find node on an unmounted component."); + if (3 !== a.tag) + throw ReactError("Unable to find node on an unmounted component."); return a.stateNode.current === a ? fiber : alternate; } function findCurrentHostFiber(parent) { @@ -1527,86 +1535,72 @@ function mountSafeCallback_NOT_REALLY_SAFE(context, callback) { }; } var ReactNativeFiberHostComponent = (function() { - function ReactNativeFiberHostComponent(tag, viewConfig) { - if (!(this instanceof ReactNativeFiberHostComponent)) - throw new TypeError("Cannot call a class as a function"); - this._nativeTag = tag; - this._children = []; - this.viewConfig = viewConfig; - } - ReactNativeFiberHostComponent.prototype.blur = function() { - TextInputState.blurTextInput(this._nativeTag); - }; - ReactNativeFiberHostComponent.prototype.focus = function() { - TextInputState.focusTextInput(this._nativeTag); - }; - ReactNativeFiberHostComponent.prototype.measure = function(callback) { - UIManager.measure( - this._nativeTag, - mountSafeCallback_NOT_REALLY_SAFE(this, callback) - ); - }; - ReactNativeFiberHostComponent.prototype.measureInWindow = function( - callback - ) { - UIManager.measureInWindow( - this._nativeTag, - mountSafeCallback_NOT_REALLY_SAFE(this, callback) - ); - }; - ReactNativeFiberHostComponent.prototype.measureLayout = function( - relativeToNativeNode, - onSuccess, - onFail - ) { + function ReactNativeFiberHostComponent(tag, viewConfig) { + if (!(this instanceof ReactNativeFiberHostComponent)) + throw new TypeError("Cannot call a class as a function"); + this._nativeTag = tag; + this._children = []; + this.viewConfig = viewConfig; + } + ReactNativeFiberHostComponent.prototype.blur = function() { + TextInputState.blurTextInput(this._nativeTag); + }; + ReactNativeFiberHostComponent.prototype.focus = function() { + TextInputState.focusTextInput(this._nativeTag); + }; + ReactNativeFiberHostComponent.prototype.measure = function(callback) { + UIManager.measure( + this._nativeTag, + mountSafeCallback_NOT_REALLY_SAFE(this, callback) + ); + }; + ReactNativeFiberHostComponent.prototype.measureInWindow = function(callback) { + UIManager.measureInWindow( + this._nativeTag, + mountSafeCallback_NOT_REALLY_SAFE(this, callback) + ); + }; + ReactNativeFiberHostComponent.prototype.measureLayout = function( + relativeToNativeNode, + onSuccess, + onFail + ) { + var relativeNode = void 0; + "number" === typeof relativeToNativeNode + ? (relativeNode = relativeToNativeNode) + : relativeToNativeNode._nativeTag + ? (relativeNode = relativeToNativeNode._nativeTag) + : relativeToNativeNode.canonical && + relativeToNativeNode.canonical._nativeTag && + (relativeNode = relativeToNativeNode.canonical._nativeTag); + null != relativeNode && UIManager.measureLayout( this._nativeTag, - relativeToNativeNode, + relativeNode, mountSafeCallback_NOT_REALLY_SAFE(this, onFail), mountSafeCallback_NOT_REALLY_SAFE(this, onSuccess) ); - }; - ReactNativeFiberHostComponent.prototype.setNativeProps = function( - nativeProps - ) { - nativeProps = diffProperties( - null, - emptyObject, - nativeProps, - this.viewConfig.validAttributes + }; + ReactNativeFiberHostComponent.prototype.setNativeProps = function( + nativeProps + ) { + nativeProps = diffProperties( + null, + emptyObject, + nativeProps, + this.viewConfig.validAttributes + ); + null != nativeProps && + UIManager.updateView( + this._nativeTag, + this.viewConfig.uiViewClassName, + nativeProps ); - null != nativeProps && - UIManager.updateView( - this._nativeTag, - this.viewConfig.uiViewClassName, - nativeProps - ); - }; - return ReactNativeFiberHostComponent; - })(), - now$1 = - "object" === typeof performance && "function" === typeof performance.now - ? function() { - return performance.now(); - } - : function() { - return Date.now(); - }, - scheduledCallback = null, - frameDeadline = 0; -function setTimeoutCallback() { - frameDeadline = now$1() + 5; - var callback = scheduledCallback; - scheduledCallback = null; - null !== callback && callback(); -} -function scheduleDeferredCallback$1(callback) { - scheduledCallback = callback; - return setTimeout(setTimeoutCallback, 1); -} + }; + return ReactNativeFiberHostComponent; +})(); function shim$1() { - invariant( - !1, + throw ReactError( "The current renderer does not support hydration. This error is likely caused by a bug in React. Please file an issue." ); } @@ -1637,24 +1631,8 @@ function finalizeInitialChildren(parentInstance) { return !1; } var scheduleTimeout = setTimeout, - cancelTimeout = clearTimeout; -function commitUpdate(instance, updatePayloadTODO, type, oldProps, newProps) { - updatePayloadTODO = instance.viewConfig; - instanceProps[instance._nativeTag] = newProps; - oldProps = diffProperties( - null, - oldProps, - newProps, - updatePayloadTODO.validAttributes - ); - null != oldProps && - UIManager.updateView( - instance._nativeTag, - updatePayloadTODO.uiViewClassName, - oldProps - ); -} -var BEFORE_SLASH_RE = /^(.*)[\\\/]/; + cancelTimeout = clearTimeout, + BEFORE_SLASH_RE = /^(.*)[\\\/]/; function getStackByFiberInDevAndProd(workInProgress) { var info = ""; do { @@ -1738,10 +1716,10 @@ function popTopLevelContextObject(fiber) { pop(contextStackCursor, fiber); } function pushTopLevelContextObject(fiber, context, didChange) { - invariant( - contextStackCursor.current === emptyContextObject, - "Unexpected context found on stack. This error is likely caused by a bug in React. Please file an issue." - ); + if (contextStackCursor.current !== emptyContextObject) + throw ReactError( + "Unexpected context found on stack. This error is likely caused by a bug in React. Please file an issue." + ); push(contextStackCursor, context, fiber); push(didPerformWorkStackCursor, didChange, fiber); } @@ -1751,12 +1729,13 @@ function processChildContext(fiber, type, parentContext) { if ("function" !== typeof instance.getChildContext) return parentContext; instance = instance.getChildContext(); for (var contextKey in instance) - invariant( - contextKey in fiber, - '%s.getChildContext(): key "%s" is not defined in childContextTypes.', - getComponentName(type) || "Unknown", - contextKey - ); + if (!(contextKey in fiber)) + throw ReactError( + (getComponentName(type) || "Unknown") + + '.getChildContext(): key "' + + contextKey + + '" is not defined in childContextTypes.' + ); return Object.assign({}, parentContext, instance); } function pushContextProvider(workInProgress) { @@ -1775,10 +1754,10 @@ function pushContextProvider(workInProgress) { } function invalidateContextProvider(workInProgress, type, didChange) { var instance = workInProgress.stateNode; - invariant( - instance, - "Expected to have an instance by this point. This error is likely caused by a bug in React. Please file an issue." - ); + if (!instance) + throw ReactError( + "Expected to have an instance by this point. This error is likely caused by a bug in React. Please file an issue." + ); didChange ? ((type = processChildContext(workInProgress, type, previousContext)), (instance.__reactInternalMemoizedMergedChildContext = type), @@ -1812,6 +1791,7 @@ function injectInternals(internals) { } catch (err) {} return !0; } +var Scheduler_now = Scheduler.unstable_now; function FiberNode(tag, pendingProps, key, mode) { this.tag = tag; this.key = key; @@ -1935,11 +1915,10 @@ function createFiberFromTypeAndProps( owner = null; break a; } - invariant( - !1, - "Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s", - null == type ? type : typeof type, - "" + throw ReactError( + "Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: " + + (null == type ? type : typeof type) + + "." ); } key = createFiber(fiberTag, pendingProps, key, mode); @@ -1981,6 +1960,21 @@ function createFiberFromPortal(portal, mode, expirationTime) { }; return mode; } +function FiberRootNode(containerInfo, hydrate) { + this.current = null; + this.containerInfo = containerInfo; + this.pingCache = this.pendingChildren = null; + this.pendingCommitExpirationTime = 0; + this.finishedWork = null; + this.timeoutHandle = -1; + this.pendingContext = this.context = null; + this.hydrate = hydrate; + this.firstBatch = null; + this.latestPingedTime = this.latestSuspendedTime = this.earliestSuspendedTime = this.latestPendingTime = this.earliestPendingTime = 0; + this.didError = !1; + this.expirationTime = this.nextExpirationTimeToWorkOn = 0; + this.nextScheduledRoot = null; +} function markPendingPriorityLevel(root, expirationTime) { root.didError = !1; var earliestPendingTime = root.earliestPendingTime; @@ -1992,36 +1986,6 @@ function markPendingPriorityLevel(root, expirationTime) { (root.latestPendingTime = expirationTime); findNextExpirationTimeToWorkOn(expirationTime, root); } -function markCommittedPriorityLevels(root, earliestRemainingTime) { - root.didError = !1; - if (0 === earliestRemainingTime) - (root.earliestPendingTime = 0), - (root.latestPendingTime = 0), - (root.earliestSuspendedTime = 0), - (root.latestSuspendedTime = 0), - (root.latestPingedTime = 0); - else { - earliestRemainingTime < root.latestPingedTime && - (root.latestPingedTime = 0); - var latestPendingTime = root.latestPendingTime; - 0 !== latestPendingTime && - (latestPendingTime > earliestRemainingTime - ? (root.earliestPendingTime = root.latestPendingTime = 0) - : root.earliestPendingTime > earliestRemainingTime && - (root.earliestPendingTime = root.latestPendingTime)); - latestPendingTime = root.earliestSuspendedTime; - 0 === latestPendingTime - ? markPendingPriorityLevel(root, earliestRemainingTime) - : earliestRemainingTime < root.latestSuspendedTime - ? ((root.earliestSuspendedTime = 0), - (root.latestSuspendedTime = 0), - (root.latestPingedTime = 0), - markPendingPriorityLevel(root, earliestRemainingTime)) - : earliestRemainingTime > latestPendingTime && - markPendingPriorityLevel(root, earliestRemainingTime); - } - findNextExpirationTimeToWorkOn(0, root); -} function markSuspendedPriorityLevel(root, suspendedTime) { root.didError = !1; root.latestPingedTime >= suspendedTime && (root.latestPingedTime = 0); @@ -2044,14 +2008,6 @@ function markSuspendedPriorityLevel(root, suspendedTime) { (root.latestSuspendedTime = suspendedTime); findNextExpirationTimeToWorkOn(suspendedTime, root); } -function findEarliestOutstandingPriorityLevel(root, renderExpirationTime) { - var earliestPendingTime = root.earliestPendingTime; - root = root.earliestSuspendedTime; - earliestPendingTime > renderExpirationTime && - (renderExpirationTime = earliestPendingTime); - root > renderExpirationTime && (renderExpirationTime = root); - return renderExpirationTime; -} function findNextExpirationTimeToWorkOn(completedExpirationTime, root) { var earliestSuspendedTime = root.earliestSuspendedTime, latestSuspendedTime = root.latestSuspendedTime, @@ -2166,37 +2122,37 @@ var classComponentUpdater = { }, enqueueSetState: function(inst, payload, callback) { inst = inst._reactInternalFiber; - var currentTime = requestCurrentTime(); - currentTime = computeExpirationForFiber(currentTime, inst); + var currentTime = requestCurrentTime$$1(); + currentTime = computeExpirationForFiber$$1(currentTime, inst); var update = createUpdate(currentTime); update.payload = payload; void 0 !== callback && null !== callback && (update.callback = callback); - flushPassiveEffects(); + flushPassiveEffects$$1(); enqueueUpdate(inst, update); - scheduleWork(inst, currentTime); + scheduleWork$$1(inst, currentTime); }, enqueueReplaceState: function(inst, payload, callback) { inst = inst._reactInternalFiber; - var currentTime = requestCurrentTime(); - currentTime = computeExpirationForFiber(currentTime, inst); + var currentTime = requestCurrentTime$$1(); + currentTime = computeExpirationForFiber$$1(currentTime, inst); var update = createUpdate(currentTime); update.tag = ReplaceState; update.payload = payload; void 0 !== callback && null !== callback && (update.callback = callback); - flushPassiveEffects(); + flushPassiveEffects$$1(); enqueueUpdate(inst, update); - scheduleWork(inst, currentTime); + scheduleWork$$1(inst, currentTime); }, enqueueForceUpdate: function(inst, callback) { inst = inst._reactInternalFiber; - var currentTime = requestCurrentTime(); - currentTime = computeExpirationForFiber(currentTime, inst); + var currentTime = requestCurrentTime$$1(); + currentTime = computeExpirationForFiber$$1(currentTime, inst); var update = createUpdate(currentTime); update.tag = ForceUpdate; void 0 !== callback && null !== callback && (update.callback = callback); - flushPassiveEffects(); + flushPassiveEffects$$1(); enqueueUpdate(inst, update); - scheduleWork(inst, currentTime); + scheduleWork$$1(inst, currentTime); } }; function checkShouldComponentUpdate( @@ -2321,17 +2277,19 @@ function coerceRef(returnFiber, current$$1, element) { if (element._owner) { element = element._owner; var inst = void 0; - element && - (invariant( - 1 === element.tag, - "Function components cannot have refs. Did you mean to use React.forwardRef()?" - ), - (inst = element.stateNode)); - invariant( - inst, - "Missing owner for string ref %s. This error is likely caused by a bug in React. Please file an issue.", - returnFiber - ); + if (element) { + if (1 !== element.tag) + throw ReactError( + "Function components cannot have refs. Did you mean to use React.forwardRef()?" + ); + inst = element.stateNode; + } + if (!inst) + throw ReactError( + "Missing owner for string ref " + + returnFiber + + ". This error is likely caused by a bug in React. Please file an issue." + ); var stringRef = "" + returnFiber; if ( null !== current$$1 && @@ -2348,27 +2306,27 @@ function coerceRef(returnFiber, current$$1, element) { current$$1._stringRef = stringRef; return current$$1; } - invariant( - "string" === typeof returnFiber, - "Expected ref to be a function, a string, an object returned by React.createRef(), or null." - ); - invariant( - element._owner, - "Element ref was specified as a string (%s) but no owner was set. This could happen for one of the following reasons:\n1. You may be adding a ref to a function component\n2. You may be adding a ref to a component that was not created inside a component's render method\n3. You have multiple copies of React loaded\nSee https://fb.me/react-refs-must-have-owner for more information.", - returnFiber - ); + if ("string" !== typeof returnFiber) + throw ReactError( + "Expected ref to be a function, a string, an object returned by React.createRef(), or null." + ); + if (!element._owner) + throw ReactError( + "Element ref was specified as a string (" + + returnFiber + + ") but no owner was set. This could happen for one of the following reasons:\n1. You may be adding a ref to a function component\n2. You may be adding a ref to a component that was not created inside a component's render method\n3. You have multiple copies of React loaded\nSee https://fb.me/react-refs-must-have-owner for more information." + ); } return returnFiber; } function throwOnInvalidObjectType(returnFiber, newChild) { - "textarea" !== returnFiber.type && - invariant( - !1, - "Objects are not valid as a React child (found: %s).%s", - "[object Object]" === Object.prototype.toString.call(newChild) - ? "object with keys {" + Object.keys(newChild).join(", ") + "}" - : newChild, - "" + if ("textarea" !== returnFiber.type) + throw ReactError( + "Objects are not valid as a React child (found: " + + ("[object Object]" === Object.prototype.toString.call(newChild) + ? "object with keys {" + Object.keys(newChild).join(", ") + "}" + : newChild) + + ")." ); } function ChildReconciler(shouldTrackSideEffects) { @@ -2767,15 +2725,13 @@ function ChildReconciler(shouldTrackSideEffects) { expirationTime ) { var iteratorFn = getIteratorFn(newChildrenIterable); - invariant( - "function" === typeof iteratorFn, - "An object is not an iterable. This error is likely caused by a bug in React. Please file an issue." - ); + if ("function" !== typeof iteratorFn) + throw ReactError( + "An object is not an iterable. This error is likely caused by a bug in React. Please file an issue." + ); newChildrenIterable = iteratorFn.call(newChildrenIterable); - invariant( - null != newChildrenIterable, - "An iterable object provided no iterator." - ); + if (null == newChildrenIterable) + throw ReactError("An iterable object provided no iterator."); for ( var previousNewFiber = (iteratorFn = null), oldFiber = currentFirstChild, @@ -2867,7 +2823,7 @@ function ChildReconciler(shouldTrackSideEffects) { null !== isUnkeyedTopLevelFragment; ) { - if (isUnkeyedTopLevelFragment.key === isObject) + if (isUnkeyedTopLevelFragment.key === isObject) { if ( 7 === isUnkeyedTopLevelFragment.tag ? newChild.type === REACT_FRAGMENT_TYPE @@ -2892,14 +2848,10 @@ function ChildReconciler(shouldTrackSideEffects) { currentFirstChild.return = returnFiber; returnFiber = currentFirstChild; break a; - } else { - deleteRemainingChildren( - returnFiber, - isUnkeyedTopLevelFragment - ); - break; } - else deleteChild(returnFiber, isUnkeyedTopLevelFragment); + deleteRemainingChildren(returnFiber, isUnkeyedTopLevelFragment); + break; + } else deleteChild(returnFiber, isUnkeyedTopLevelFragment); isUnkeyedTopLevelFragment = isUnkeyedTopLevelFragment.sibling; } newChild.type === REACT_FRAGMENT_TYPE @@ -2935,7 +2887,7 @@ function ChildReconciler(shouldTrackSideEffects) { null !== currentFirstChild; ) { - if (currentFirstChild.key === isUnkeyedTopLevelFragment) + if (currentFirstChild.key === isUnkeyedTopLevelFragment) { if ( 4 === currentFirstChild.tag && currentFirstChild.stateNode.containerInfo === @@ -2955,11 +2907,10 @@ function ChildReconciler(shouldTrackSideEffects) { currentFirstChild.return = returnFiber; returnFiber = currentFirstChild; break a; - } else { - deleteRemainingChildren(returnFiber, currentFirstChild); - break; } - else deleteChild(returnFiber, currentFirstChild); + deleteRemainingChildren(returnFiber, currentFirstChild); + break; + } else deleteChild(returnFiber, currentFirstChild); currentFirstChild = currentFirstChild.sibling; } currentFirstChild = createFiberFromPortal( @@ -3013,12 +2964,11 @@ function ChildReconciler(shouldTrackSideEffects) { switch (returnFiber.tag) { case 1: case 0: - (expirationTime = returnFiber.type), - invariant( - !1, - "%s(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null.", - expirationTime.displayName || expirationTime.name || "Component" - ); + throw ((returnFiber = returnFiber.type), + ReactError( + (returnFiber.displayName || returnFiber.name || "Component") + + "(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null." + )); } return deleteRemainingChildren(returnFiber, currentFirstChild); }; @@ -3030,10 +2980,10 @@ var reconcileChildFibers = ChildReconciler(!0), contextFiberStackCursor = { current: NO_CONTEXT }, rootInstanceStackCursor = { current: NO_CONTEXT }; function requiredContext(c) { - invariant( - c !== NO_CONTEXT, - "Expected host context to exist. This error is likely caused by a bug in React. Please file an issue." - ); + if (c === NO_CONTEXT) + throw ReactError( + "Expected host context to exist. This error is likely caused by a bug in React. Please file an issue." + ); return c; } function pushHostContainer(fiber, nextRootInstance) { @@ -3070,15 +3020,7 @@ function popHostContext(fiber) { contextFiberStackCursor.current === fiber && (pop(contextStackCursor$1, fiber), pop(contextFiberStackCursor, fiber)); } -var NoEffect$1 = 0, - UnmountSnapshot = 2, - UnmountMutation = 4, - MountMutation = 8, - UnmountLayout = 16, - MountLayout = 32, - MountPassive = 64, - UnmountPassive = 128, - ReactCurrentDispatcher$1 = ReactSharedInternals.ReactCurrentDispatcher, +var ReactCurrentDispatcher$1 = ReactSharedInternals.ReactCurrentDispatcher, renderExpirationTime = 0, currentlyRenderingFiber$1 = null, currentHook = null, @@ -3093,9 +3035,8 @@ var NoEffect$1 = 0, renderPhaseUpdates = null, numberOfReRenders = 0; function throwInvalidHookError() { - invariant( - !1, - "Hooks can only be called inside the body of a function component. (https://fb.me/react-invalid-hook-call)" + throw ReactError( + "Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:\n1. You might have mismatching versions of React and the renderer (such as React DOM)\n2. You might be breaking the Rules of Hooks\n3. You might have more than one copy of React in the same app\nSee https://fb.me/react-invalid-hook-call for tips about how to debug and fix this problem." ); } function areHookInputsEqual(nextDeps, prevDeps) { @@ -3143,10 +3084,10 @@ function renderWithHooks( remainingExpirationTime = 0; componentUpdateQueue = null; sideEffectTag = 0; - invariant( - !current, - "Rendered fewer hooks than expected. This may be caused by an accidental early return statement." - ); + if (current) + throw ReactError( + "Rendered fewer hooks than expected. This may be caused by an accidental early return statement." + ); return workInProgress; } function resetHooks() { @@ -3180,10 +3121,8 @@ function updateWorkInProgressHook() { (currentHook = nextCurrentHook), (nextCurrentHook = null !== currentHook ? currentHook.next : null); else { - invariant( - null !== nextCurrentHook, - "Rendered more hooks than during the previous render." - ); + if (null === nextCurrentHook) + throw ReactError("Rendered more hooks than during the previous render."); currentHook = nextCurrentHook; var newHook = { memoizedState: currentHook.memoizedState, @@ -3206,10 +3145,11 @@ function basicStateReducer(state, action) { function updateReducer(reducer) { var hook = updateWorkInProgressHook(), queue = hook.queue; - invariant( - null !== queue, - "Should have a queue. This is likely a bug in React. Please file an issue." - ); + if (null === queue) + throw ReactError( + "Should have a queue. This is likely a bug in React. Please file an issue." + ); + queue.lastRenderedReducer = reducer; if (0 < numberOfReRenders) { var _dispatch = queue.dispatch; if (null !== renderPhaseUpdates) { @@ -3224,6 +3164,7 @@ function updateReducer(reducer) { is(newState, hook.memoizedState) || (didReceiveUpdate = !0); hook.memoizedState = newState; hook.baseUpdate === queue.last && (hook.baseState = newState); + queue.lastRenderedState = newState; return [newState, _dispatch]; } } @@ -3249,10 +3190,12 @@ function updateReducer(reducer) { (firstRenderPhaseUpdate = newState)), updateExpirationTime > remainingExpirationTime && (remainingExpirationTime = updateExpirationTime)) - : (newState = + : (updateExpirationTime < mostRecentEventTime && + (mostRecentEventTime = updateExpirationTime), + (newState = _update.eagerReducer === reducer ? _update.eagerState - : reducer(newState, _update.action)); + : reducer(newState, _update.action))); baseUpdate = _update; _update = _update.next; } while (null !== _update && _update !== _dispatch); @@ -3262,8 +3205,7 @@ function updateReducer(reducer) { hook.memoizedState = newState; hook.baseUpdate = newBaseUpdate; hook.baseState = firstRenderPhaseUpdate; - queue.eagerReducer = reducer; - queue.eagerState = newState; + queue.lastRenderedState = newState; } return [hook.memoizedState, queue.dispatch]; } @@ -3299,7 +3241,7 @@ function updateEffectImpl(fiberEffectTag, hookEffectTag, create, deps) { var prevEffect = currentHook.memoizedState; destroy = prevEffect.destroy; if (null !== deps && areHookInputsEqual(deps, prevEffect.deps)) { - pushEffect(NoEffect$1, create, destroy, deps); + pushEffect(0, create, destroy, deps); return; } } @@ -3326,10 +3268,10 @@ function imperativeHandleEffect(create, ref) { } function mountDebugValue() {} function dispatchAction(fiber, queue, action) { - invariant( - 25 > numberOfReRenders, - "Too many re-renders. React limits the number of renders to prevent an infinite loop." - ); + if (!(25 > numberOfReRenders)) + throw ReactError( + "Too many re-renders. React limits the number of renders to prevent an infinite loop." + ); var alternate = fiber.alternate; if ( fiber === currentlyRenderingFiber$1 || @@ -3354,9 +3296,9 @@ function dispatchAction(fiber, queue, action) { queue.next = fiber; } else { - flushPassiveEffects(); - var currentTime = requestCurrentTime(); - currentTime = computeExpirationForFiber(currentTime, fiber); + flushPassiveEffects$$1(); + var currentTime = requestCurrentTime$$1(); + currentTime = computeExpirationForFiber$$1(currentTime, fiber); var _update2 = { expirationTime: currentTime, action: action, @@ -3375,10 +3317,10 @@ function dispatchAction(fiber, queue, action) { if ( 0 === fiber.expirationTime && (null === alternate || 0 === alternate.expirationTime) && - ((alternate = queue.eagerReducer), null !== alternate) + ((alternate = queue.lastRenderedReducer), null !== alternate) ) try { - var currentState = queue.eagerState, + var currentState = queue.lastRenderedState, _eagerState = alternate(currentState, action); _update2.eagerReducer = alternate; _update2.eagerState = _eagerState; @@ -3386,7 +3328,7 @@ function dispatchAction(fiber, queue, action) { } catch (error) { } finally { } - scheduleWork(fiber, currentTime); + scheduleWork$$1(fiber, currentTime); } } var ContextOnlyDispatcher = { @@ -3413,19 +3355,19 @@ var ContextOnlyDispatcher = { }, useContext: readContext, useEffect: function(create, deps) { - return mountEffectImpl(516, UnmountPassive | MountPassive, create, deps); + return mountEffectImpl(516, 192, create, deps); }, useImperativeHandle: function(ref, create, deps) { deps = null !== deps && void 0 !== deps ? deps.concat([ref]) : null; return mountEffectImpl( 4, - UnmountMutation | MountLayout, + 36, imperativeHandleEffect.bind(null, create, ref), deps ); }, useLayoutEffect: function(create, deps) { - return mountEffectImpl(4, UnmountMutation | MountLayout, create, deps); + return mountEffectImpl(4, 36, create, deps); }, useMemo: function(nextCreate, deps) { var hook = mountWorkInProgressHook(); @@ -3441,8 +3383,8 @@ var ContextOnlyDispatcher = { reducer = hook.queue = { last: null, dispatch: null, - eagerReducer: reducer, - eagerState: initialArg + lastRenderedReducer: reducer, + lastRenderedState: initialArg }; reducer = reducer.dispatch = dispatchAction.bind( null, @@ -3463,8 +3405,8 @@ var ContextOnlyDispatcher = { initialState = hook.queue = { last: null, dispatch: null, - eagerReducer: basicStateReducer, - eagerState: initialState + lastRenderedReducer: basicStateReducer, + lastRenderedState: initialState }; initialState = initialState.dispatch = dispatchAction.bind( null, @@ -3492,19 +3434,19 @@ var ContextOnlyDispatcher = { }, useContext: readContext, useEffect: function(create, deps) { - return updateEffectImpl(516, UnmountPassive | MountPassive, create, deps); + return updateEffectImpl(516, 192, create, deps); }, useImperativeHandle: function(ref, create, deps) { deps = null !== deps && void 0 !== deps ? deps.concat([ref]) : null; return updateEffectImpl( 4, - UnmountMutation | MountLayout, + 36, imperativeHandleEffect.bind(null, create, ref), deps ); }, useLayoutEffect: function(create, deps) { - return updateEffectImpl(4, UnmountMutation | MountLayout, create, deps); + return updateEffectImpl(4, 36, create, deps); }, useMemo: function(nextCreate, deps) { var hook = updateWorkInProgressHook(); @@ -3544,6 +3486,8 @@ function tryHydrate(fiber, nextInstance) { (nextInstance = shim$1(nextInstance, fiber.pendingProps)), null !== nextInstance ? ((fiber.stateNode = nextInstance), !0) : !1 ); + case 13: + return !1; default: return !1; } @@ -4078,7 +4022,10 @@ function updateSuspenseComponent( nextState = null; var nextDidTimeout = !1; } else - (nextState = { timedOutAt: null !== nextState ? nextState.timedOutAt : 0 }), + (nextState = { + fallbackExpirationTime: + null !== nextState ? nextState.fallbackExpirationTime : 0 + }), (nextDidTimeout = !0), (workInProgress.effectTag &= -65); if (null === current$$1) @@ -4173,10 +4120,8 @@ function bailoutOnAlreadyFinishedWork( null !== current$$1 && (workInProgress.contextDependencies = current$$1.contextDependencies); if (workInProgress.childExpirationTime < renderExpirationTime) return null; - invariant( - null === current$$1 || workInProgress.child === current$$1.child, - "Resuming work not yet implemented." - ); + if (null !== current$$1 && workInProgress.child !== current$$1.child) + throw ReactError("Resuming work not yet implemented."); if (null !== workInProgress.child) { current$$1 = workInProgress.child; renderExpirationTime = createWorkInProgress( @@ -4341,59 +4286,57 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { ((current$$1.alternate = null), (workInProgress.alternate = null), (workInProgress.effectTag |= 2)); - hasContext = workInProgress.pendingProps; - current$$1 = readLazyComponentType(context); - workInProgress.type = current$$1; - context = workInProgress.tag = resolveLazyComponentTag(current$$1); - hasContext = resolveDefaultProps(current$$1, hasContext); - getDerivedStateFromProps = void 0; - switch (context) { + current$$1 = workInProgress.pendingProps; + context = readLazyComponentType(context); + workInProgress.type = context; + hasContext = workInProgress.tag = resolveLazyComponentTag(context); + current$$1 = resolveDefaultProps(context, current$$1); + switch (hasContext) { case 0: - getDerivedStateFromProps = updateFunctionComponent( + workInProgress = updateFunctionComponent( null, workInProgress, + context, current$$1, - hasContext, renderExpirationTime ); break; case 1: - getDerivedStateFromProps = updateClassComponent( + workInProgress = updateClassComponent( null, workInProgress, + context, current$$1, - hasContext, renderExpirationTime ); break; case 11: - getDerivedStateFromProps = updateForwardRef( + workInProgress = updateForwardRef( null, workInProgress, + context, current$$1, - hasContext, renderExpirationTime ); break; case 14: - getDerivedStateFromProps = updateMemoComponent( + workInProgress = updateMemoComponent( null, workInProgress, - current$$1, - resolveDefaultProps(current$$1.type, hasContext), + context, + resolveDefaultProps(context.type, current$$1), updateExpirationTime, renderExpirationTime ); break; default: - invariant( - !1, - "Element type is invalid. Received a promise that resolves to: %s. Lazy element type must resolve to a class or function.%s", - current$$1, - "" + throw ReactError( + "Element type is invalid. Received a promise that resolves to: " + + context + + ". Lazy element type must resolve to a class or function." ); } - return getDerivedStateFromProps; + return workInProgress; case 0: return ( (updateExpirationTime = workInProgress.type), @@ -4427,38 +4370,36 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { ) ); case 3: - return ( - pushHostRootContext(workInProgress), - (updateExpirationTime = workInProgress.updateQueue), - invariant( - null !== updateExpirationTime, + pushHostRootContext(workInProgress); + updateExpirationTime = workInProgress.updateQueue; + if (null === updateExpirationTime) + throw ReactError( "If the root does not have an updateQueue, we should have already bailed out. This error is likely caused by a bug in React. Please file an issue." - ), - (context = workInProgress.memoizedState), - (context = null !== context ? context.element : null), - processUpdateQueue( - workInProgress, - updateExpirationTime, - workInProgress.pendingProps, - null, - renderExpirationTime - ), - (updateExpirationTime = workInProgress.memoizedState.element), - updateExpirationTime === context - ? (workInProgress = bailoutOnAlreadyFinishedWork( - current$$1, - workInProgress, - renderExpirationTime - )) - : (reconcileChildren( - current$$1, - workInProgress, - updateExpirationTime, - renderExpirationTime - ), - (workInProgress = workInProgress.child)), - workInProgress + ); + context = workInProgress.memoizedState; + context = null !== context ? context.element : null; + processUpdateQueue( + workInProgress, + updateExpirationTime, + workInProgress.pendingProps, + null, + renderExpirationTime ); + updateExpirationTime = workInProgress.memoizedState.element; + updateExpirationTime === context + ? (workInProgress = bailoutOnAlreadyFinishedWork( + current$$1, + workInProgress, + renderExpirationTime + )) + : (reconcileChildren( + current$$1, + workInProgress, + updateExpirationTime, + renderExpirationTime + ), + (workInProgress = workInProgress.child)); + return workInProgress; case 5: return ( pushHostContext(workInProgress), @@ -4471,8 +4412,7 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { updateExpirationTime, renderExpirationTime ), - (workInProgress = workInProgress.child), - workInProgress + workInProgress.child ); case 6: return ( @@ -4607,19 +4547,19 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { null !== dependency && dependency.expirationTime < renderExpirationTime && (dependency.expirationTime = renderExpirationTime); + dependency = renderExpirationTime; for (var node = oldValue.return; null !== node; ) { - dependency = node.alternate; - if (node.childExpirationTime < renderExpirationTime) - (node.childExpirationTime = renderExpirationTime), - null !== dependency && - dependency.childExpirationTime < - renderExpirationTime && - (dependency.childExpirationTime = renderExpirationTime); + var alternate = node.alternate; + if (node.childExpirationTime < dependency) + (node.childExpirationTime = dependency), + null !== alternate && + alternate.childExpirationTime < dependency && + (alternate.childExpirationTime = dependency); else if ( - null !== dependency && - dependency.childExpirationTime < renderExpirationTime + null !== alternate && + alternate.childExpirationTime < dependency ) - dependency.childExpirationTime = renderExpirationTime; + alternate.childExpirationTime = dependency; else break; node = node.return; } @@ -4749,12 +4689,10 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { renderExpirationTime ) ); - default: - invariant( - !1, - "Unknown unit of work tag. This error is likely caused by a bug in React. Please file an issue." - ); } + throw ReactError( + "Unknown unit of work tag. This error is likely caused by a bug in React. Please file an issue." + ); } var valueCursor = { current: null }, currentlyRenderingFiber = null, @@ -4788,17 +4726,17 @@ function readContext(context, observedBits) { if ("number" !== typeof observedBits || 1073741823 === observedBits) (lastContextWithAllBitsObserved = context), (observedBits = 1073741823); observedBits = { context: context, observedBits: observedBits, next: null }; - null === lastContextDependency - ? (invariant( - null !== currentlyRenderingFiber, + if (null === lastContextDependency) { + if (null === currentlyRenderingFiber) + throw ReactError( "Context can only be read while React is rendering. In classes, you can read it in the render method or getDerivedStateFromProps. In function components, you can read it directly in the function body, but not inside Hooks like useReducer() or useMemo()." - ), - (lastContextDependency = observedBits), - (currentlyRenderingFiber.contextDependencies = { - first: observedBits, - expirationTime: 0 - })) - : (lastContextDependency = lastContextDependency.next = observedBits); + ); + lastContextDependency = observedBits; + currentlyRenderingFiber.contextDependencies = { + first: observedBits, + expirationTime: 0 + }; + } else lastContextDependency = lastContextDependency.next = observedBits; } return context._currentValue; } @@ -4951,7 +4889,9 @@ function processUpdateQueue( ((newFirstUpdate = update), (newBaseState = resultState)), newExpirationTime < updateExpirationTime && (newExpirationTime = updateExpirationTime)) - : ((resultState = getStateFromUpdate( + : (updateExpirationTime < mostRecentEventTime && + (mostRecentEventTime = updateExpirationTime), + (resultState = getStateFromUpdate( workInProgress, queue, update, @@ -5024,11 +4964,11 @@ function commitUpdateEffects(effect, instance) { if (null !== _callback3) { effect.callback = null; var context = instance; - invariant( - "function" === typeof _callback3, - "Invalid argument passed as callback. Expected a function. Instead received: %s", - _callback3 - ); + if ("function" !== typeof _callback3) + throw ReactError( + "Invalid argument passed as callback. Expected a function. Instead received: " + + _callback3 + ); _callback3.call(context); } effect = effect.nextEffect; @@ -5091,7 +5031,7 @@ function logCapturedError(capturedError) { : Error("Unspecified error at:" + componentStack); ExceptionsManager.handleException(error, !1); } -var PossiblyWeakSet = "function" === typeof WeakSet ? WeakSet : Set; +var PossiblyWeakSet$1 = "function" === typeof WeakSet ? WeakSet : Set; function logError(boundary, errorInfo) { var source = errorInfo.source, stack = errorInfo.stack; @@ -5128,7 +5068,7 @@ function safelyDetachRef(current$$1) { try { ref(null); } catch (refError) { - captureCommitPhaseError(current$$1, refError); + captureCommitPhaseError$$1(current$$1, refError); } else ref.current = null; } @@ -5138,12 +5078,12 @@ function commitHookEffectList(unmountTag, mountTag, finishedWork) { if (null !== finishedWork) { var effect = (finishedWork = finishedWork.next); do { - if ((effect.tag & unmountTag) !== NoEffect$1) { + if (0 !== (effect.tag & unmountTag)) { var destroy = effect.destroy; effect.destroy = void 0; void 0 !== destroy && destroy(); } - (effect.tag & mountTag) !== NoEffect$1 && + 0 !== (effect.tag & mountTag) && ((destroy = effect.create), (effect.destroy = destroy())); effect = effect.next; } while (effect !== finishedWork); @@ -5228,7 +5168,7 @@ function commitUnmount(current$$1$jscomp$0) { try { destroy(); } catch (error) { - captureCommitPhaseError(current$$1, error); + captureCommitPhaseError$$1(current$$1, error); } } effect = effect.next; @@ -5244,7 +5184,7 @@ function commitUnmount(current$$1$jscomp$0) { (updateQueue.state = current$$1$jscomp$0.memoizedState), updateQueue.componentWillUnmount(); } catch (unmountError) { - captureCommitPhaseError(current$$1$jscomp$0, unmountError); + captureCommitPhaseError$$1(current$$1$jscomp$0, unmountError); } break; case 5: @@ -5266,17 +5206,14 @@ function commitPlacement(finishedWork) { } parent = parent.return; } - invariant( - !1, + throw ReactError( "Expected to find a host parent. This error is likely caused by a bug in React. Please file an issue." ); - parentFiber = void 0; } - var isContainer = (parent = void 0); switch (parentFiber.tag) { case 5: parent = parentFiber.stateNode; - isContainer = !1; + var isContainer = !1; break; case 3: parent = parentFiber.stateNode.containerInfo; @@ -5287,8 +5224,7 @@ function commitPlacement(finishedWork) { isContainer = !0; break; default: - invariant( - !1, + throw ReactError( "Invalid host parent fiber. This error is likely caused by a bug in React. Please file an issue." ); } @@ -5304,7 +5240,7 @@ function commitPlacement(finishedWork) { parentFiber.sibling.return = parentFiber.return; for ( parentFiber = parentFiber.sibling; - 5 !== parentFiber.tag && 6 !== parentFiber.tag; + 5 !== parentFiber.tag && 6 !== parentFiber.tag && 18 !== parentFiber.tag; ) { if (parentFiber.effectTag & 2) continue b; @@ -5319,23 +5255,23 @@ function commitPlacement(finishedWork) { } } for (var node = finishedWork; ; ) { - if (5 === node.tag || 6 === node.tag) + if (5 === node.tag || 6 === node.tag) { + var stateNode = node.stateNode; if (parentFiber) - if (isContainer) - invariant( - "number" !== typeof parent, - "Container does not support insertBefore operation" - ); - else { + if (isContainer) { + if ("number" === typeof parent) + throw ReactError( + "Container does not support insertBefore operation" + ); + } else { var parentInstance = parent, - child = node.stateNode, beforeChild = parentFiber, children = parentInstance._children, - index = children.indexOf(child); + index = children.indexOf(stateNode); 0 <= index ? (children.splice(index, 1), (beforeChild = children.indexOf(beforeChild)), - children.splice(beforeChild, 0, child), + children.splice(beforeChild, 0, stateNode), UIManager.manageChildren( parentInstance._nativeTag, [index], @@ -5345,32 +5281,33 @@ function commitPlacement(finishedWork) { [] )) : ((index = children.indexOf(beforeChild)), - children.splice(index, 0, child), + children.splice(index, 0, stateNode), UIManager.manageChildren( parentInstance._nativeTag, [], [], - ["number" === typeof child ? child : child._nativeTag], + [ + "number" === typeof stateNode + ? stateNode + : stateNode._nativeTag + ], [index], [] )); } else isContainer - ? ((parentInstance = node.stateNode), - UIManager.setChildren(parent, [ - "number" === typeof parentInstance - ? parentInstance - : parentInstance._nativeTag - ])) + ? UIManager.setChildren(parent, [ + "number" === typeof stateNode ? stateNode : stateNode._nativeTag + ]) : ((parentInstance = parent), - (child = node.stateNode), - (children = "number" === typeof child ? child : child._nativeTag), + (children = + "number" === typeof stateNode ? stateNode : stateNode._nativeTag), (index = parentInstance._children), - (beforeChild = index.indexOf(child)), + (beforeChild = index.indexOf(stateNode)), 0 <= beforeChild ? (index.splice(beforeChild, 1), - index.push(child), + index.push(stateNode), UIManager.manageChildren( parentInstance._nativeTag, [beforeChild], @@ -5379,7 +5316,7 @@ function commitPlacement(finishedWork) { [], [] )) - : (index.push(child), + : (index.push(stateNode), UIManager.manageChildren( parentInstance._nativeTag, [], @@ -5388,7 +5325,7 @@ function commitPlacement(finishedWork) { [index.length - 1], [] ))); - else if (4 !== node.tag && null !== node.child) { + } else if (4 !== node.tag && null !== node.child) { node.child.return = node; node = node.child; continue; @@ -5414,10 +5351,10 @@ function unmountHostComponents(current$$1) { if (!currentParentIsValid) { currentParentIsValid = node.return; a: for (;;) { - invariant( - null !== currentParentIsValid, - "Expected to find a host parent. This error is likely caused by a bug in React. Please file an issue." - ); + if (null === currentParentIsValid) + throw ReactError( + "Expected to find a host parent. This error is likely caused by a bug in React. Please file an issue." + ); switch (currentParentIsValid.tag) { case 5: currentParent = currentParentIsValid.stateNode; @@ -5496,7 +5433,7 @@ function commitWork(current$$1, finishedWork) { case 11: case 14: case 15: - commitHookEffectList(UnmountMutation, MountMutation, finishedWork); + commitHookEffectList(4, 8, finishedWork); break; case 1: break; @@ -5505,66 +5442,76 @@ function commitWork(current$$1, finishedWork) { if (null != instance) { var newProps = finishedWork.memoizedProps; current$$1 = null !== current$$1 ? current$$1.memoizedProps : newProps; - var type = finishedWork.type, - updatePayload = finishedWork.updateQueue; + var updatePayload = finishedWork.updateQueue; finishedWork.updateQueue = null; null !== updatePayload && - commitUpdate( - instance, - updatePayload, - type, + ((finishedWork = instance.viewConfig), + (instanceProps[instance._nativeTag] = newProps), + (newProps = diffProperties( + null, current$$1, newProps, - finishedWork - ); + finishedWork.validAttributes + )), + null != newProps && + UIManager.updateView( + instance._nativeTag, + finishedWork.uiViewClassName, + newProps + )); } break; case 6: - invariant( - null !== finishedWork.stateNode, - "This should have a text node initialized. This error is likely caused by a bug in React. Please file an issue." - ); + if (null === finishedWork.stateNode) + throw ReactError( + "This should have a text node initialized. This error is likely caused by a bug in React. Please file an issue." + ); UIManager.updateView(finishedWork.stateNode, "RCTRawText", { text: finishedWork.memoizedProps }); break; + case 20: + break; case 3: break; case 12: break; case 13: - instance = finishedWork.memoizedState; - newProps = void 0; - current$$1 = finishedWork; - null === instance - ? (newProps = !1) - : ((newProps = !0), - (current$$1 = finishedWork.child), - 0 === instance.timedOutAt && - (instance.timedOutAt = requestCurrentTime())); - null !== current$$1 && hideOrUnhideAllChildren(current$$1, newProps); - instance = finishedWork.updateQueue; - if (null !== instance) { - finishedWork.updateQueue = null; - var retryCache = finishedWork.stateNode; - null === retryCache && - (retryCache = finishedWork.stateNode = new PossiblyWeakSet()); - instance.forEach(function(thenable) { - var retry = retryTimedOutBoundary.bind(null, finishedWork, thenable); - retryCache.has(thenable) || - (retryCache.add(thenable), thenable.then(retry, retry)); - }); - } + commitSuspenseComponent(finishedWork); break; case 17: break; default: - invariant( - !1, + throw ReactError( "This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue." ); } } +function commitSuspenseComponent(finishedWork) { + var newState = finishedWork.memoizedState, + newDidTimeout = void 0, + primaryChildParent = finishedWork; + null === newState + ? (newDidTimeout = !1) + : ((newDidTimeout = !0), + (primaryChildParent = finishedWork.child), + 0 === newState.fallbackExpirationTime && + (newState.fallbackExpirationTime = requestCurrentTime$$1() - 500)); + null !== primaryChildParent && + hideOrUnhideAllChildren(primaryChildParent, newDidTimeout); + newState = finishedWork.updateQueue; + if (null !== newState) { + finishedWork.updateQueue = null; + var retryCache = finishedWork.stateNode; + null === retryCache && + (retryCache = finishedWork.stateNode = new PossiblyWeakSet$1()); + newState.forEach(function(thenable) { + var retry = resolveRetryThenable$$1.bind(null, finishedWork, thenable); + retryCache.has(thenable) || + (retryCache.add(thenable), thenable.then(retry, retry)); + }); + } +} var PossiblyWeakMap = "function" === typeof WeakMap ? WeakMap : Map; function createRootErrorUpdate(fiber, errorInfo, expirationTime) { expirationTime = createUpdate(expirationTime); @@ -5572,7 +5519,7 @@ function createRootErrorUpdate(fiber, errorInfo, expirationTime) { expirationTime.payload = { element: null }; var error = errorInfo.value; expirationTime.callback = function() { - onUncaughtError(error); + onUncaughtError$$1(error); logError(fiber, errorInfo); }; return expirationTime; @@ -5614,17 +5561,15 @@ function unwindWork(workInProgress) { workInProgress) : null; case 3: - return ( - popHostContainer(workInProgress), - popTopLevelContextObject(workInProgress), - (effectTag = workInProgress.effectTag), - invariant( - 0 === (effectTag & 64), + popHostContainer(workInProgress); + popTopLevelContextObject(workInProgress); + effectTag = workInProgress.effectTag; + if (0 !== (effectTag & 64)) + throw ReactError( "The root failed to unmount after an error. This is likely a bug in React. Please file an issue." - ), - (workInProgress.effectTag = (effectTag & -2049) | 64), - workInProgress - ); + ); + workInProgress.effectTag = (effectTag & -2049) | 64; + return workInProgress; case 5: return popHostContext(workInProgress), null; case 13: @@ -5635,21 +5580,33 @@ function unwindWork(workInProgress) { workInProgress) : null ); + case 18: + return null; case 4: return popHostContainer(workInProgress), null; case 10: return popProvider(workInProgress), null; + case 19: + case 20: + return null; default: return null; } } -var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher, +var scheduleCallback$1 = Scheduler.unstable_scheduleCallback, + cancelCallback$1 = Scheduler.unstable_cancelCallback, + shouldYield$1 = Scheduler.unstable_shouldYield, + now$1 = Scheduler.unstable_now, + getCurrentPriorityLevel$1 = Scheduler.unstable_getCurrentPriorityLevel, + NormalPriority$1 = Scheduler.unstable_NormalPriority, + ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher, ReactCurrentOwner$2 = ReactSharedInternals.ReactCurrentOwner, isWorking = !1, nextUnitOfWork = null, nextRoot = null, nextRenderExpirationTime = 0, - nextLatestAbsoluteTimeoutMs = -1, + mostRecentEventTime = 1073741823, + nextRenderDidSuspend = !1, nextRenderDidError = !1, nextEffect = null, isCommitting$1 = !1, @@ -5690,184 +5647,10 @@ function resetStack() { } nextRoot = null; nextRenderExpirationTime = 0; - nextLatestAbsoluteTimeoutMs = -1; - nextRenderDidError = !1; + mostRecentEventTime = 1073741823; + nextRenderDidError = nextRenderDidSuspend = !1; nextUnitOfWork = null; } -function commitAllHostEffects() { - for (; null !== nextEffect; ) { - var effectTag = nextEffect.effectTag; - if (effectTag & 128) { - var current$$1 = nextEffect.alternate; - null !== current$$1 && - ((current$$1 = current$$1.ref), - null !== current$$1 && - ("function" === typeof current$$1 - ? current$$1(null) - : (current$$1.current = null))); - } - switch (effectTag & 14) { - case 2: - commitPlacement(nextEffect); - nextEffect.effectTag &= -3; - break; - case 6: - commitPlacement(nextEffect); - nextEffect.effectTag &= -3; - commitWork(nextEffect.alternate, nextEffect); - break; - case 4: - commitWork(nextEffect.alternate, nextEffect); - break; - case 8: - (effectTag = nextEffect), - unmountHostComponents(effectTag), - (effectTag.return = null), - (effectTag.child = null), - (effectTag.memoizedState = null), - (effectTag.updateQueue = null), - (effectTag = effectTag.alternate), - null !== effectTag && - ((effectTag.return = null), - (effectTag.child = null), - (effectTag.memoizedState = null), - (effectTag.updateQueue = null)); - } - nextEffect = nextEffect.nextEffect; - } -} -function commitBeforeMutationLifecycles() { - for (; null !== nextEffect; ) { - if (nextEffect.effectTag & 256) - a: { - var current$$1 = nextEffect.alternate, - finishedWork = nextEffect; - switch (finishedWork.tag) { - case 0: - case 11: - case 15: - commitHookEffectList(UnmountSnapshot, NoEffect$1, finishedWork); - break a; - case 1: - if (finishedWork.effectTag & 256 && null !== current$$1) { - var prevProps = current$$1.memoizedProps, - prevState = current$$1.memoizedState; - current$$1 = finishedWork.stateNode; - finishedWork = current$$1.getSnapshotBeforeUpdate( - finishedWork.elementType === finishedWork.type - ? prevProps - : resolveDefaultProps(finishedWork.type, prevProps), - prevState - ); - current$$1.__reactInternalSnapshotBeforeUpdate = finishedWork; - } - break a; - case 3: - case 5: - case 6: - case 4: - case 17: - break a; - default: - invariant( - !1, - "This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue." - ); - } - } - nextEffect = nextEffect.nextEffect; - } -} -function commitAllLifeCycles(finishedRoot, committedExpirationTime$jscomp$0) { - for (; null !== nextEffect; ) { - var effectTag = nextEffect.effectTag; - if (effectTag & 36) { - var current$$1 = nextEffect.alternate, - finishedWork = nextEffect, - committedExpirationTime = committedExpirationTime$jscomp$0; - switch (finishedWork.tag) { - case 0: - case 11: - case 15: - commitHookEffectList(UnmountLayout, MountLayout, finishedWork); - break; - case 1: - var instance = finishedWork.stateNode; - if (finishedWork.effectTag & 4) - if (null === current$$1) instance.componentDidMount(); - else { - var prevProps = - finishedWork.elementType === finishedWork.type - ? current$$1.memoizedProps - : resolveDefaultProps( - finishedWork.type, - current$$1.memoizedProps - ); - instance.componentDidUpdate( - prevProps, - current$$1.memoizedState, - instance.__reactInternalSnapshotBeforeUpdate - ); - } - current$$1 = finishedWork.updateQueue; - null !== current$$1 && - commitUpdateQueue( - finishedWork, - current$$1, - instance, - committedExpirationTime - ); - break; - case 3: - instance = finishedWork.updateQueue; - if (null !== instance) { - current$$1 = null; - if (null !== finishedWork.child) - switch (finishedWork.child.tag) { - case 5: - current$$1 = finishedWork.child.stateNode; - break; - case 1: - current$$1 = finishedWork.child.stateNode; - } - commitUpdateQueue( - finishedWork, - instance, - current$$1, - committedExpirationTime - ); - } - break; - case 5: - break; - case 6: - break; - case 4: - break; - case 12: - break; - case 13: - break; - case 17: - break; - default: - invariant( - !1, - "This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue." - ); - } - } - effectTag & 128 && - ((finishedWork = nextEffect.ref), - null !== finishedWork && - ((committedExpirationTime = nextEffect.stateNode), - "function" === typeof finishedWork - ? finishedWork(committedExpirationTime) - : (finishedWork.current = committedExpirationTime))); - effectTag & 512 && (rootWithPendingPassiveEffects = finishedRoot); - nextEffect = nextEffect.nextEffect; - } -} function commitPassiveEffects(root, firstEffect) { passiveEffectCallback = passiveEffectCallbackHandle = rootWithPendingPassiveEffects = null; var previousIsRendering = isRendering; @@ -5878,132 +5661,32 @@ function commitPassiveEffects(root, firstEffect) { error = void 0; try { var finishedWork = firstEffect; - commitHookEffectList(UnmountPassive, NoEffect$1, finishedWork); - commitHookEffectList(NoEffect$1, MountPassive, finishedWork); + commitHookEffectList(128, 0, finishedWork); + commitHookEffectList(0, 64, finishedWork); } catch (e) { (didError = !0), (error = e); } - didError && captureCommitPhaseError(firstEffect, error); + didError && captureCommitPhaseError$1(firstEffect, error); } firstEffect = firstEffect.nextEffect; } while (null !== firstEffect); isRendering = previousIsRendering; previousIsRendering = root.expirationTime; 0 !== previousIsRendering && requestWork(root, previousIsRendering); + isBatchingUpdates || isRendering || performWork(1073741823); } -function flushPassiveEffects() { - if (null !== passiveEffectCallbackHandle) { - var callbackID = passiveEffectCallbackHandle; - scheduledCallback = null; - clearTimeout(callbackID); - } - null !== passiveEffectCallback && passiveEffectCallback(); -} -function commitRoot(root, finishedWork) { - isCommitting$1 = isWorking = !0; - invariant( - root.current !== finishedWork, - "Cannot commit the same tree as before. This is probably a bug related to the return field. This error is likely caused by a bug in React. Please file an issue." - ); - var committedExpirationTime = root.pendingCommitExpirationTime; - invariant( - 0 !== committedExpirationTime, - "Cannot commit an incomplete root. This error is likely caused by a bug in React. Please file an issue." +function isAlreadyFailedLegacyErrorBoundary$1(instance) { + return ( + null !== legacyErrorBoundariesThatAlreadyFailed && + legacyErrorBoundariesThatAlreadyFailed.has(instance) ); - root.pendingCommitExpirationTime = 0; - var updateExpirationTimeBeforeCommit = finishedWork.expirationTime, - childExpirationTimeBeforeCommit = finishedWork.childExpirationTime; - markCommittedPriorityLevels( - root, - childExpirationTimeBeforeCommit > updateExpirationTimeBeforeCommit - ? childExpirationTimeBeforeCommit - : updateExpirationTimeBeforeCommit - ); - ReactCurrentOwner$2.current = null; - updateExpirationTimeBeforeCommit = void 0; - 1 < finishedWork.effectTag - ? null !== finishedWork.lastEffect - ? ((finishedWork.lastEffect.nextEffect = finishedWork), - (updateExpirationTimeBeforeCommit = finishedWork.firstEffect)) - : (updateExpirationTimeBeforeCommit = finishedWork) - : (updateExpirationTimeBeforeCommit = finishedWork.firstEffect); - for (nextEffect = updateExpirationTimeBeforeCommit; null !== nextEffect; ) { - childExpirationTimeBeforeCommit = !1; - var error = void 0; - try { - commitBeforeMutationLifecycles(); - } catch (e) { - (childExpirationTimeBeforeCommit = !0), (error = e); - } - childExpirationTimeBeforeCommit && - (invariant( - null !== nextEffect, - "Should have next effect. This error is likely caused by a bug in React. Please file an issue." - ), - captureCommitPhaseError(nextEffect, error), - null !== nextEffect && (nextEffect = nextEffect.nextEffect)); - } - for (nextEffect = updateExpirationTimeBeforeCommit; null !== nextEffect; ) { - childExpirationTimeBeforeCommit = !1; - error = void 0; - try { - commitAllHostEffects(); - } catch (e) { - (childExpirationTimeBeforeCommit = !0), (error = e); - } - childExpirationTimeBeforeCommit && - (invariant( - null !== nextEffect, - "Should have next effect. This error is likely caused by a bug in React. Please file an issue." - ), - captureCommitPhaseError(nextEffect, error), - null !== nextEffect && (nextEffect = nextEffect.nextEffect)); - } - root.current = finishedWork; - for (nextEffect = updateExpirationTimeBeforeCommit; null !== nextEffect; ) { - childExpirationTimeBeforeCommit = !1; - error = void 0; - try { - commitAllLifeCycles(root, committedExpirationTime); - } catch (e) { - (childExpirationTimeBeforeCommit = !0), (error = e); - } - childExpirationTimeBeforeCommit && - (invariant( - null !== nextEffect, - "Should have next effect. This error is likely caused by a bug in React. Please file an issue." - ), - captureCommitPhaseError(nextEffect, error), - null !== nextEffect && (nextEffect = nextEffect.nextEffect)); - } - if ( - null !== updateExpirationTimeBeforeCommit && - null !== rootWithPendingPassiveEffects - ) { - var callback = commitPassiveEffects.bind( - null, - root, - updateExpirationTimeBeforeCommit - ); - passiveEffectCallbackHandle = scheduler.unstable_runWithPriority( - scheduler.unstable_NormalPriority, - function() { - return scheduleDeferredCallback$1(callback); - } - ); - passiveEffectCallback = callback; - } - isWorking = isCommitting$1 = !1; - "function" === typeof onCommitFiberRoot && - onCommitFiberRoot(finishedWork.stateNode); - committedExpirationTime = finishedWork.expirationTime; - finishedWork = finishedWork.childExpirationTime; - finishedWork = - finishedWork > committedExpirationTime - ? finishedWork - : committedExpirationTime; - 0 === finishedWork && (legacyErrorBoundariesThatAlreadyFailed = null); - onCommit(root, finishedWork); +} +function flushPassiveEffects$1() { + var didFlushEffects = null !== passiveEffectCallback; + null !== passiveEffectCallbackHandle && + cancelCallback$1(passiveEffectCallbackHandle); + null !== passiveEffectCallback && passiveEffectCallback(); + return didFlushEffects; } function completeUnitOfWork(workInProgress) { for (;;) { @@ -6056,13 +5739,12 @@ function completeUnitOfWork(workInProgress) { current.ref !== current$$1.ref && (current$$1.effectTag |= 128); else if (newProps) { current = requiredContext(contextStackCursor$1.current); - var internalInstanceHandle = current$$1, - tag = allocateTag(), + var tag = allocateTag(), viewConfig = ReactNativeViewConfigRegistry.get(type); - invariant( - "RCTView" !== type || !current.isInAParentText, - "Nesting of within is not currently supported." - ); + if ("RCTView" === type && current.isInAParentText) + throw ReactError( + "Nesting of within is not currently supported." + ); var updatePayload = diffProperties( null, emptyObject, @@ -6076,7 +5758,7 @@ function completeUnitOfWork(workInProgress) { updatePayload ); viewConfig = new ReactNativeFiberHostComponent(tag, viewConfig); - instanceCache[tag] = internalInstanceHandle; + instanceCache[tag] = current$$1; instanceProps[tag] = newProps; appendAllChildren(viewConfig, current$$1, !1, !1); finalizeInitialChildren( @@ -6088,38 +5770,41 @@ function completeUnitOfWork(workInProgress) { ) && (current$$1.effectTag |= 4); current$$1.stateNode = viewConfig; null !== current$$1.ref && (current$$1.effectTag |= 128); - } else - invariant( - null !== current$$1.stateNode, + } else if (null === current$$1.stateNode) + throw ReactError( "We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue." ); break; case 6: - current && null != current$$1.stateNode - ? updateHostText$1( - current, - current$$1, - current.memoizedProps, - newProps - ) - : ("string" !== typeof newProps && - invariant( - null !== current$$1.stateNode, - "We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue." - ), - (current = requiredContext(rootInstanceStackCursor.current)), - (type = requiredContext(contextStackCursor$1.current)), - (renderExpirationTime = current$$1), - invariant( - type.isInAParentText, + if (current && null != current$$1.stateNode) + updateHostText$1( + current, + current$$1, + current.memoizedProps, + newProps + ); + else { + if ("string" !== typeof newProps && null === current$$1.stateNode) + throw ReactError( + "We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue." + ); + current = requiredContext(rootInstanceStackCursor.current); + if ( + !requiredContext(contextStackCursor$1.current).isInAParentText + ) + throw ReactError( "Text strings must be rendered within a component." - ), - (type = allocateTag()), - UIManager.createView(type, "RCTRawText", current, { - text: newProps - }), - (instanceCache[type] = current$$1), - (renderExpirationTime.stateNode = type)); + ); + renderExpirationTime = allocateTag(); + UIManager.createView( + renderExpirationTime, + "RCTRawText", + current, + { text: newProps } + ); + instanceCache[renderExpirationTime] = current$$1; + current$$1.stateNode = renderExpirationTime; + } break; case 11: break; @@ -6131,20 +5816,27 @@ function completeUnitOfWork(workInProgress) { break a; } newProps = null !== newProps; - renderExpirationTime = - null !== current && null !== current.memoizedState; + renderExpirationTime = !1; null !== current && - !newProps && - renderExpirationTime && - ((type = current.child.sibling), - null !== type && - ((current = current$$1.firstEffect), - null !== current - ? ((current$$1.firstEffect = type), - (type.nextEffect = current)) - : ((current$$1.firstEffect = current$$1.lastEffect = type), - (type.nextEffect = null)), - (type.effectTag = 8))); + ((type = current.memoizedState), + (renderExpirationTime = null !== type), + newProps || + null === type || + ((type = type.fallbackExpirationTime), + type < mostRecentEventTime && (mostRecentEventTime = type), + (current = current.child.sibling), + null !== current && + ((type = current$$1.firstEffect), + null !== type + ? ((current$$1.firstEffect = current), + (current.nextEffect = type)) + : ((current$$1.firstEffect = current$$1.lastEffect = current), + (current.nextEffect = null)), + (current.effectTag = 8)))); + newProps && + !renderExpirationTime && + 0 !== (current$$1.mode & 1) && + (nextRenderDidSuspend = !0); if (newProps || renderExpirationTime) current$$1.effectTag |= 4; break; case 7: @@ -6167,9 +5859,14 @@ function completeUnitOfWork(workInProgress) { case 17: isContextProvider(current$$1.type) && popContext(current$$1); break; + case 18: + break; + case 19: + break; + case 20: + break; default: - invariant( - !1, + throw ReactError( "Unknown unit of work tag. This error is likely caused by a bug in React. Please file an issue." ); } @@ -6181,16 +5878,13 @@ function completeUnitOfWork(workInProgress) { 1 !== current$$1.childExpirationTime ) { newProps = 0; - for ( - renderExpirationTime = current$$1.child; - null !== renderExpirationTime; - - ) - (type = renderExpirationTime.expirationTime), - (current = renderExpirationTime.childExpirationTime), + for (current = current$$1.child; null !== current; ) + (renderExpirationTime = current.expirationTime), + (type = current.childExpirationTime), + renderExpirationTime > newProps && + (newProps = renderExpirationTime), type > newProps && (newProps = type), - current > newProps && (newProps = current), - (renderExpirationTime = renderExpirationTime.sibling); + (current = current.sibling); current$$1.childExpirationTime = newProps; } if (null !== nextUnitOfWork) return nextUnitOfWork; @@ -6233,11 +5927,11 @@ function performUnitOfWork(workInProgress) { return next; } function renderRoot(root$jscomp$0, isYieldy) { - invariant( - !isWorking, - "renderRoot was called recursively. This error is likely caused by a bug in React. Please file an issue." - ); - flushPassiveEffects(); + if (isWorking) + throw ReactError( + "renderRoot was called recursively. This error is likely caused by a bug in React. Please file an issue." + ); + flushPassiveEffects$1(); isWorking = !0; var previousDispatcher = ReactCurrentDispatcher.current; ReactCurrentDispatcher.current = ContextOnlyDispatcher; @@ -6260,7 +5954,7 @@ function renderRoot(root$jscomp$0, isYieldy) { do { try { if (isYieldy) - for (; null !== nextUnitOfWork && !shouldYieldToRenderer(); ) + for (; null !== nextUnitOfWork && !shouldYield$1(); ) nextUnitOfWork = performUnitOfWork(nextUnitOfWork); else for (; null !== nextUnitOfWork; ) @@ -6271,15 +5965,16 @@ function renderRoot(root$jscomp$0, isYieldy) { resetHooks(), null === nextUnitOfWork) ) - (didFatal = !0), onUncaughtError(thrownValue); + (didFatal = !0), onUncaughtError$1(thrownValue); else { - invariant( - null !== nextUnitOfWork, - "Failed to replay rendering after an error. This is likely caused by a bug in React. Please file an issue with a reproducing case to help us find it." - ); + if (null === nextUnitOfWork) + throw ReactError( + "Failed to replay rendering after an error. This is likely caused by a bug in React. Please file an issue with a reproducing case to help us find it." + ); var sourceFiber = nextUnitOfWork, returnFiber = sourceFiber.return; - if (null === returnFiber) (didFatal = !0), onUncaughtError(thrownValue); + if (null === returnFiber) + (didFatal = !0), onUncaughtError$1(thrownValue); else { a: { var root = root$jscomp$0, @@ -6296,38 +5991,13 @@ function renderRoot(root$jscomp$0, isYieldy) { ) { var thenable = value; value = returnFiber$jscomp$0; - var earliestTimeoutMs = -1, - startTimeMs = -1; - do { - if (13 === value.tag) { - var current$$1 = value.alternate; - if ( - null !== current$$1 && - ((current$$1 = current$$1.memoizedState), - null !== current$$1) - ) { - startTimeMs = 10 * (1073741822 - current$$1.timedOutAt); - break; - } - current$$1 = value.pendingProps.maxDuration; - if ("number" === typeof current$$1) - if (0 >= current$$1) earliestTimeoutMs = 0; - else if ( - -1 === earliestTimeoutMs || - current$$1 < earliestTimeoutMs - ) - earliestTimeoutMs = current$$1; - } - value = value.return; - } while (null !== value); - value = returnFiber$jscomp$0; do { - if ((current$$1 = 13 === value.tag)) - current$$1 = - void 0 === value.memoizedProps.fallback - ? !1 - : null === value.memoizedState; - if (current$$1) { + if ( + 13 === value.tag && + (void 0 === value.memoizedProps.fallback + ? 0 + : null === value.memoizedState) + ) { returnFiber$jscomp$0 = value.updateQueue; null === returnFiber$jscomp$0 ? ((returnFiber$jscomp$0 = new Set()), @@ -6346,44 +6016,25 @@ function renderRoot(root$jscomp$0, isYieldy) { sourceFiber$jscomp$0.expirationTime = 1073741823; break a; } - sourceFiber$jscomp$0 = root.pingCache; - null === sourceFiber$jscomp$0 - ? ((sourceFiber$jscomp$0 = root.pingCache = new PossiblyWeakMap()), + sourceFiber$jscomp$0 = returnFiber; + var pingCache = root.pingCache; + null === pingCache + ? ((pingCache = root.pingCache = new PossiblyWeakMap()), (returnFiber$jscomp$0 = new Set()), - sourceFiber$jscomp$0.set(thenable, returnFiber$jscomp$0)) - : ((returnFiber$jscomp$0 = sourceFiber$jscomp$0.get( - thenable - )), + pingCache.set(thenable, returnFiber$jscomp$0)) + : ((returnFiber$jscomp$0 = pingCache.get(thenable)), void 0 === returnFiber$jscomp$0 && ((returnFiber$jscomp$0 = new Set()), - sourceFiber$jscomp$0.set( - thenable, - returnFiber$jscomp$0 - ))); - returnFiber$jscomp$0.has(returnFiber) || - (returnFiber$jscomp$0.add(returnFiber), - (sourceFiber$jscomp$0 = pingSuspendedRoot.bind( + pingCache.set(thenable, returnFiber$jscomp$0))); + returnFiber$jscomp$0.has(sourceFiber$jscomp$0) || + (returnFiber$jscomp$0.add(sourceFiber$jscomp$0), + (root = pingSuspendedRoot$$1.bind( null, root, thenable, - returnFiber + sourceFiber$jscomp$0 )), - thenable.then(sourceFiber$jscomp$0, sourceFiber$jscomp$0)); - -1 === earliestTimeoutMs - ? (root = 1073741823) - : (-1 === startTimeMs && - (startTimeMs = - 10 * - (1073741822 - - findEarliestOutstandingPriorityLevel( - root, - returnFiber - )) - - 5e3), - (root = startTimeMs + earliestTimeoutMs)); - 0 <= root && - nextLatestAbsoluteTimeoutMs < root && - (nextLatestAbsoluteTimeoutMs = root); + thenable.then(root, root)); value.effectTag |= 2048; value.expirationTime = returnFiber; break a; @@ -6410,24 +6061,24 @@ function renderRoot(root$jscomp$0, isYieldy) { break a; case 1: if ( - ((thenable = value), - (earliestTimeoutMs = root.type), - (startTimeMs = root.stateNode), + ((sourceFiber$jscomp$0 = value), + (thenable = root.type), + (returnFiber$jscomp$0 = root.stateNode), 0 === (root.effectTag & 64) && ("function" === - typeof earliestTimeoutMs.getDerivedStateFromError || - (null !== startTimeMs && - "function" === typeof startTimeMs.componentDidCatch && - (null === legacyErrorBoundariesThatAlreadyFailed || - !legacyErrorBoundariesThatAlreadyFailed.has( - startTimeMs - ))))) + typeof thenable.getDerivedStateFromError || + (null !== returnFiber$jscomp$0 && + "function" === + typeof returnFiber$jscomp$0.componentDidCatch && + !isAlreadyFailedLegacyErrorBoundary$$1( + returnFiber$jscomp$0 + )))) ) { root.effectTag |= 2048; root.expirationTime = returnFiber; returnFiber = createClassErrorUpdate( root, - thenable, + sourceFiber$jscomp$0, returnFiber ); enqueueCapturedUpdate(root, returnFiber); @@ -6452,10 +6103,10 @@ function renderRoot(root$jscomp$0, isYieldy) { else if (null !== nextUnitOfWork) root$jscomp$0.finishedWork = null; else { previousDispatcher = root$jscomp$0.current.alternate; - invariant( - null !== previousDispatcher, - "Finished root should have a work-in-progress. This error is likely caused by a bug in React. Please file an issue." - ); + if (null === previousDispatcher) + throw ReactError( + "Finished root should have a work-in-progress. This error is likely caused by a bug in React. Please file an issue." + ); nextRoot = null; if (nextRenderDidError) { didFatal = root$jscomp$0.latestPendingTime; @@ -6490,19 +6141,11 @@ function renderRoot(root$jscomp$0, isYieldy) { return; } } - isYieldy && -1 !== nextLatestAbsoluteTimeoutMs + isYieldy && nextRenderDidSuspend && 1073741823 !== mostRecentEventTime ? (markSuspendedPriorityLevel(root$jscomp$0, expirationTime), (isYieldy = - 10 * - (1073741822 - - findEarliestOutstandingPriorityLevel( - root$jscomp$0, - expirationTime - ))), - isYieldy < nextLatestAbsoluteTimeoutMs && - (nextLatestAbsoluteTimeoutMs = isYieldy), - (isYieldy = 10 * (1073741822 - requestCurrentTime())), - (isYieldy = nextLatestAbsoluteTimeoutMs - isYieldy), + 10 * (1073741822 - mostRecentEventTime) - 5e3 + originalStartTimeMs), + (isYieldy = 150 - (now$1() - isYieldy)), onSuspend( root$jscomp$0, previousDispatcher, @@ -6514,7 +6157,7 @@ function renderRoot(root$jscomp$0, isYieldy) { (root$jscomp$0.finishedWork = previousDispatcher)); } } -function captureCommitPhaseError(sourceFiber, value) { +function captureCommitPhaseError$1(sourceFiber, value) { for (var fiber = sourceFiber.return; null !== fiber; ) { switch (fiber.tag) { case 1: @@ -6522,13 +6165,12 @@ function captureCommitPhaseError(sourceFiber, value) { if ( "function" === typeof fiber.type.getDerivedStateFromError || ("function" === typeof instance.componentDidCatch && - (null === legacyErrorBoundariesThatAlreadyFailed || - !legacyErrorBoundariesThatAlreadyFailed.has(instance))) + !isAlreadyFailedLegacyErrorBoundary$1(instance)) ) { sourceFiber = createCapturedValue(value, sourceFiber); sourceFiber = createClassErrorUpdate(fiber, sourceFiber, 1073741823); enqueueUpdate(fiber, sourceFiber); - scheduleWork(fiber, 1073741823); + scheduleWork$1(fiber, 1073741823); return; } break; @@ -6536,7 +6178,7 @@ function captureCommitPhaseError(sourceFiber, value) { sourceFiber = createCapturedValue(value, sourceFiber); sourceFiber = createRootErrorUpdate(fiber, sourceFiber, 1073741823); enqueueUpdate(fiber, sourceFiber); - scheduleWork(fiber, 1073741823); + scheduleWork$1(fiber, 1073741823); return; } fiber = fiber.return; @@ -6545,75 +6187,25 @@ function captureCommitPhaseError(sourceFiber, value) { ((fiber = createCapturedValue(value, sourceFiber)), (fiber = createRootErrorUpdate(sourceFiber, fiber, 1073741823)), enqueueUpdate(sourceFiber, fiber), - scheduleWork(sourceFiber, 1073741823)); -} -function computeExpirationForFiber(currentTime, fiber) { - var priorityLevel = scheduler.unstable_getCurrentPriorityLevel(), - expirationTime = void 0; - if (0 === (fiber.mode & 1)) expirationTime = 1073741823; - else if (isWorking && !isCommitting$1) - expirationTime = nextRenderExpirationTime; - else { - switch (priorityLevel) { - case scheduler.unstable_ImmediatePriority: - expirationTime = 1073741823; - break; - case scheduler.unstable_UserBlockingPriority: - expirationTime = - 1073741822 - 10 * ((((1073741822 - currentTime + 15) / 10) | 0) + 1); - break; - case scheduler.unstable_NormalPriority: - expirationTime = - 1073741822 - 25 * ((((1073741822 - currentTime + 500) / 25) | 0) + 1); - break; - case scheduler.unstable_LowPriority: - case scheduler.unstable_IdlePriority: - expirationTime = 1; - break; - default: - invariant( - !1, - "Unknown priority level. This error is likely caused by a bug in React. Please file an issue." - ); - } - null !== nextRoot && - expirationTime === nextRenderExpirationTime && - --expirationTime; - } - priorityLevel === scheduler.unstable_UserBlockingPriority && + scheduleWork$1(sourceFiber, 1073741823)); +} +function computeExpirationForFiber$1(currentTime, fiber) { + isWorking + ? (currentTime = isCommitting$1 ? 1073741823 : nextRenderExpirationTime) + : fiber.mode & 1 + ? ((currentTime = isBatchingInteractiveUpdates + ? 1073741822 - 10 * ((((1073741822 - currentTime + 15) / 10) | 0) + 1) + : 1073741822 - + 25 * ((((1073741822 - currentTime + 500) / 25) | 0) + 1)), + null !== nextRoot && + currentTime === nextRenderExpirationTime && + --currentTime) + : (currentTime = 1073741823); + isBatchingInteractiveUpdates && (0 === lowestPriorityPendingInteractiveExpirationTime || - expirationTime < lowestPriorityPendingInteractiveExpirationTime) && - (lowestPriorityPendingInteractiveExpirationTime = expirationTime); - return expirationTime; -} -function pingSuspendedRoot(root, thenable, pingTime) { - var pingCache = root.pingCache; - null !== pingCache && pingCache.delete(thenable); - if (null !== nextRoot && nextRenderExpirationTime === pingTime) - nextRoot = null; - else if ( - ((thenable = root.earliestSuspendedTime), - (pingCache = root.latestSuspendedTime), - 0 !== thenable && pingTime <= thenable && pingTime >= pingCache) - ) { - root.didError = !1; - thenable = root.latestPingedTime; - if (0 === thenable || thenable > pingTime) root.latestPingedTime = pingTime; - findNextExpirationTimeToWorkOn(pingTime, root); - pingTime = root.expirationTime; - 0 !== pingTime && requestWork(root, pingTime); - } -} -function retryTimedOutBoundary(boundaryFiber, thenable) { - var retryCache = boundaryFiber.stateNode; - null !== retryCache && retryCache.delete(thenable); - thenable = requestCurrentTime(); - thenable = computeExpirationForFiber(thenable, boundaryFiber); - boundaryFiber = scheduleWorkToRoot(boundaryFiber, thenable); - null !== boundaryFiber && - (markPendingPriorityLevel(boundaryFiber, thenable), - (thenable = boundaryFiber.expirationTime), - 0 !== thenable && requestWork(boundaryFiber, thenable)); + currentTime < lowestPriorityPendingInteractiveExpirationTime) && + (lowestPriorityPendingInteractiveExpirationTime = currentTime); + return currentTime; } function scheduleWorkToRoot(fiber, expirationTime) { fiber.expirationTime < expirationTime && @@ -6641,9 +6233,10 @@ function scheduleWorkToRoot(fiber, expirationTime) { } return root; } -function scheduleWork(fiber, expirationTime) { +function scheduleWork$1(fiber, expirationTime) { fiber = scheduleWorkToRoot(fiber, expirationTime); - null !== fiber && + if ( + null !== fiber && (!isWorking && 0 !== nextRenderExpirationTime && expirationTime > nextRenderExpirationTime && @@ -6651,12 +6244,12 @@ function scheduleWork(fiber, expirationTime) { markPendingPriorityLevel(fiber, expirationTime), (isWorking && !isCommitting$1 && nextRoot === fiber) || requestWork(fiber, fiber.expirationTime), - nestedUpdateCount > NESTED_UPDATE_LIMIT && - ((nestedUpdateCount = 0), - invariant( - !1, - "Maximum update depth exceeded. This can happen when a component repeatedly calls setState inside componentWillUpdate or componentDidUpdate. React limits the number of nested updates to prevent infinite loops." - ))); + nestedUpdateCount > NESTED_UPDATE_LIMIT) + ) + throw ((nestedUpdateCount = 0), + ReactError( + "Maximum update depth exceeded. This can happen when a component repeatedly calls setState inside componentWillUpdate or componentDidUpdate. React limits the number of nested updates to prevent infinite loops." + )); } var firstScheduledRoot = null, lastScheduledRoot = null, @@ -6670,6 +6263,7 @@ var firstScheduledRoot = null, unhandledError = null, isBatchingUpdates = !1, isUnbatchingUpdates = !1, + isBatchingInteractiveUpdates = !1, completedBatches = null, originalStartTimeMs = now$1(), currentRendererTime = 1073741822 - ((originalStartTimeMs / 10) | 0), @@ -6684,13 +6278,14 @@ function recomputeCurrentRendererTime() { function scheduleCallbackWithExpirationTime(root, expirationTime) { if (0 !== callbackExpirationTime) { if (expirationTime < callbackExpirationTime) return; - null !== callbackID && - ((root = callbackID), (scheduledCallback = null), clearTimeout(root)); + null !== callbackID && cancelCallback$1(callbackID); } callbackExpirationTime = expirationTime; root = now$1() - originalStartTimeMs; - callbackID = scheduleDeferredCallback$1(performAsyncWork, { - timeout: 10 * (1073741822 - expirationTime) - root + expirationTime = 10 * (1073741822 - expirationTime) - root; + root = getCurrentPriorityLevel$1(); + callbackID = scheduleCallback$1(root, performAsyncWork, { + timeout: expirationTime }); } function onSuspend( @@ -6701,7 +6296,7 @@ function onSuspend( msUntilTimeout ) { root.expirationTime = rootExpirationTime; - 0 !== msUntilTimeout || shouldYieldToRenderer() + 0 !== msUntilTimeout || shouldYield$1() ? 0 < msUntilTimeout && (root.timeoutHandle = scheduleTimeout( onTimeout.bind(null, root, finishedWork, suspendedExpirationTime), @@ -6715,20 +6310,16 @@ function onTimeout(root, finishedWork, suspendedExpirationTime) { root.finishedWork = finishedWork; recomputeCurrentRendererTime(); currentSchedulerTime = currentRendererTime; - invariant( - !isRendering, - "work.commit(): Cannot commit while already rendering. This likely means you attempted to commit from inside a lifecycle method." - ); + if (isRendering) + throw ReactError( + "work.commit(): Cannot commit while already rendering. This likely means you attempted to commit from inside a lifecycle method." + ); nextFlushedRoot = root; nextFlushedExpirationTime = suspendedExpirationTime; performWorkOnRoot(root, suspendedExpirationTime, !1); - performWork(1073741823, !1); + performWork(1073741823); } -function onCommit(root, expirationTime) { - root.expirationTime = expirationTime; - root.finishedWork = null; -} -function requestCurrentTime() { +function requestCurrentTime$1() { if (isRendering) return currentSchedulerTime; findHighestPriorityRoot(); if (0 === nextFlushedExpirationTime || 1 === nextFlushedExpirationTime) @@ -6753,7 +6344,7 @@ function requestWork(root, expirationTime) { (nextFlushedExpirationTime = 1073741823), performWorkOnRoot(root, 1073741823, !1)) : 1073741823 === expirationTime - ? performWork(1073741823, !1) + ? performWork(1073741823) : scheduleCallbackWithExpirationTime(root, expirationTime)); } function findHighestPriorityRoot() { @@ -6767,10 +6358,10 @@ function findHighestPriorityRoot() { ) { var remainingExpirationTime = root.expirationTime; if (0 === remainingExpirationTime) { - invariant( - null !== previousScheduledRoot && null !== lastScheduledRoot, - "Should have a previous and last root. This error is likely caused by a bug in React. Please file an issue." - ); + if (null === previousScheduledRoot || null === lastScheduledRoot) + throw ReactError( + "Should have a previous and last root. This error is likely caused by a bug in React. Please file an issue." + ); if (root === root.nextScheduledRoot) { firstScheduledRoot = lastScheduledRoot = root.nextScheduledRoot = null; break; @@ -6801,75 +6392,69 @@ function findHighestPriorityRoot() { nextFlushedRoot = highestPriorityRoot; nextFlushedExpirationTime = highestPriorityWork; } -var didYield = !1; -function shouldYieldToRenderer() { - return didYield ? !0 : frameDeadline <= now$1() ? (didYield = !0) : !1; -} -function performAsyncWork() { - try { - if (!shouldYieldToRenderer() && null !== firstScheduledRoot) { - recomputeCurrentRendererTime(); - var root = firstScheduledRoot; - do { - var expirationTime = root.expirationTime; - 0 !== expirationTime && - currentRendererTime <= expirationTime && - (root.nextExpirationTimeToWorkOn = currentRendererTime); - root = root.nextScheduledRoot; - } while (root !== firstScheduledRoot); - } - performWork(0, !0); - } finally { - didYield = !1; +function performAsyncWork(didTimeout) { + if (didTimeout && null !== firstScheduledRoot) { + recomputeCurrentRendererTime(); + didTimeout = firstScheduledRoot; + do { + var expirationTime = didTimeout.expirationTime; + 0 !== expirationTime && + currentRendererTime <= expirationTime && + (didTimeout.nextExpirationTimeToWorkOn = currentRendererTime); + didTimeout = didTimeout.nextScheduledRoot; + } while (didTimeout !== firstScheduledRoot); } -} -function performWork(minExpirationTime, isYieldy) { findHighestPriorityRoot(); - if (isYieldy) - for ( - recomputeCurrentRendererTime(), - currentSchedulerTime = currentRendererTime; - null !== nextFlushedRoot && - 0 !== nextFlushedExpirationTime && - minExpirationTime <= nextFlushedExpirationTime && - !(didYield && currentRendererTime > nextFlushedExpirationTime); + recomputeCurrentRendererTime(); + for ( + currentSchedulerTime = currentRendererTime; + null !== nextFlushedRoot && + 0 !== nextFlushedExpirationTime && + !(shouldYield$1() && currentRendererTime > nextFlushedExpirationTime); - ) - performWorkOnRoot( - nextFlushedRoot, - nextFlushedExpirationTime, - currentRendererTime > nextFlushedExpirationTime - ), - findHighestPriorityRoot(), - recomputeCurrentRendererTime(), - (currentSchedulerTime = currentRendererTime); - else - for ( - ; - null !== nextFlushedRoot && - 0 !== nextFlushedExpirationTime && - minExpirationTime <= nextFlushedExpirationTime; + ) + performWorkOnRoot( + nextFlushedRoot, + nextFlushedExpirationTime, + currentRendererTime > nextFlushedExpirationTime + ), + findHighestPriorityRoot(), + recomputeCurrentRendererTime(), + (currentSchedulerTime = currentRendererTime); + callbackExpirationTime = 0; + callbackID = null; + 0 !== nextFlushedExpirationTime && + scheduleCallbackWithExpirationTime( + nextFlushedRoot, + nextFlushedExpirationTime + ); + finishRendering(); +} +function performWork(minExpirationTime) { + for ( + findHighestPriorityRoot(); + null !== nextFlushedRoot && + 0 !== nextFlushedExpirationTime && + minExpirationTime <= nextFlushedExpirationTime; - ) - performWorkOnRoot(nextFlushedRoot, nextFlushedExpirationTime, !1), - findHighestPriorityRoot(); - isYieldy && ((callbackExpirationTime = 0), (callbackID = null)); + ) + performWorkOnRoot(nextFlushedRoot, nextFlushedExpirationTime, !1), + findHighestPriorityRoot(); 0 !== nextFlushedExpirationTime && scheduleCallbackWithExpirationTime( nextFlushedRoot, nextFlushedExpirationTime ); + finishRendering(); +} +function finishRendering() { nestedUpdateCount = 0; lastCommittedRootDuringThisBatch = null; - if (null !== completedBatches) - for ( - minExpirationTime = completedBatches, - completedBatches = null, - isYieldy = 0; - isYieldy < minExpirationTime.length; - isYieldy++ - ) { - var batch = minExpirationTime[isYieldy]; + if (null !== completedBatches) { + var batches = completedBatches; + completedBatches = null; + for (var i = 0; i < batches.length; i++) { + var batch = batches[i]; try { batch._onComplete(); } catch (error) { @@ -6877,17 +6462,18 @@ function performWork(minExpirationTime, isYieldy) { ((hasUnhandledError = !0), (unhandledError = error)); } } + } if (hasUnhandledError) - throw ((minExpirationTime = unhandledError), + throw ((batches = unhandledError), (unhandledError = null), (hasUnhandledError = !1), - minExpirationTime); + batches); } function performWorkOnRoot(root, expirationTime, isYieldy) { - invariant( - !isRendering, - "performWorkOnRoot was called recursively. This error is likely caused by a bug in React. Please file an issue." - ); + if (isRendering) + throw ReactError( + "performWorkOnRoot was called recursively. This error is likely caused by a bug in React. Please file an issue." + ); isRendering = !0; if (isYieldy) { var _finishedWork = root.finishedWork; @@ -6900,7 +6486,7 @@ function performWorkOnRoot(root, expirationTime, isYieldy) { renderRoot(root, isYieldy), (_finishedWork = root.finishedWork), null !== _finishedWork && - (shouldYieldToRenderer() + (shouldYield$1() ? (root.finishedWork = _finishedWork) : completeRoot(root, _finishedWork, expirationTime))); } else @@ -6917,7 +6503,7 @@ function performWorkOnRoot(root, expirationTime, isYieldy) { completeRoot(root, _finishedWork, expirationTime)); isRendering = !1; } -function completeRoot(root, finishedWork, expirationTime) { +function completeRoot(root, finishedWork$jscomp$0, expirationTime) { var firstBatch = root.firstBatch; if ( null !== firstBatch && @@ -6927,7 +6513,7 @@ function completeRoot(root, finishedWork, expirationTime) { : completedBatches.push(firstBatch), firstBatch._defer) ) { - root.finishedWork = finishedWork; + root.finishedWork = finishedWork$jscomp$0; root.expirationTime = 0; return; } @@ -6935,46 +6521,383 @@ function completeRoot(root, finishedWork, expirationTime) { root === lastCommittedRootDuringThisBatch ? nestedUpdateCount++ : ((lastCommittedRootDuringThisBatch = root), (nestedUpdateCount = 0)); - scheduler.unstable_runWithPriority( - scheduler.unstable_ImmediatePriority, - function() { - commitRoot(root, finishedWork); + isCommitting$1 = isWorking = !0; + if (root.current === finishedWork$jscomp$0) + throw ReactError( + "Cannot commit the same tree as before. This is probably a bug related to the return field. This error is likely caused by a bug in React. Please file an issue." + ); + expirationTime = root.pendingCommitExpirationTime; + if (0 === expirationTime) + throw ReactError( + "Cannot commit an incomplete root. This error is likely caused by a bug in React. Please file an issue." + ); + root.pendingCommitExpirationTime = 0; + firstBatch = finishedWork$jscomp$0.expirationTime; + var childExpirationTimeBeforeCommit = + finishedWork$jscomp$0.childExpirationTime; + firstBatch = + childExpirationTimeBeforeCommit > firstBatch + ? childExpirationTimeBeforeCommit + : firstBatch; + root.didError = !1; + 0 === firstBatch + ? ((root.earliestPendingTime = 0), + (root.latestPendingTime = 0), + (root.earliestSuspendedTime = 0), + (root.latestSuspendedTime = 0), + (root.latestPingedTime = 0)) + : (firstBatch < root.latestPingedTime && (root.latestPingedTime = 0), + (childExpirationTimeBeforeCommit = root.latestPendingTime), + 0 !== childExpirationTimeBeforeCommit && + (childExpirationTimeBeforeCommit > firstBatch + ? (root.earliestPendingTime = root.latestPendingTime = 0) + : root.earliestPendingTime > firstBatch && + (root.earliestPendingTime = root.latestPendingTime)), + (childExpirationTimeBeforeCommit = root.earliestSuspendedTime), + 0 === childExpirationTimeBeforeCommit + ? markPendingPriorityLevel(root, firstBatch) + : firstBatch < root.latestSuspendedTime + ? ((root.earliestSuspendedTime = 0), + (root.latestSuspendedTime = 0), + (root.latestPingedTime = 0), + markPendingPriorityLevel(root, firstBatch)) + : firstBatch > childExpirationTimeBeforeCommit && + markPendingPriorityLevel(root, firstBatch)); + findNextExpirationTimeToWorkOn(0, root); + ReactCurrentOwner$2.current = null; + 1 < finishedWork$jscomp$0.effectTag + ? null !== finishedWork$jscomp$0.lastEffect + ? ((finishedWork$jscomp$0.lastEffect.nextEffect = finishedWork$jscomp$0), + (firstBatch = finishedWork$jscomp$0.firstEffect)) + : (firstBatch = finishedWork$jscomp$0) + : (firstBatch = finishedWork$jscomp$0.firstEffect); + for (nextEffect = firstBatch; null !== nextEffect; ) { + childExpirationTimeBeforeCommit = !1; + var error = void 0; + try { + for (; null !== nextEffect; ) { + if (nextEffect.effectTag & 256) { + var current$$1 = nextEffect.alternate, + finishedWork = nextEffect; + switch (finishedWork.tag) { + case 0: + case 11: + case 15: + commitHookEffectList(2, 0, finishedWork); + break; + case 1: + if (finishedWork.effectTag & 256 && null !== current$$1) { + var prevProps = current$$1.memoizedProps, + prevState = current$$1.memoizedState, + instance = finishedWork.stateNode, + snapshot = instance.getSnapshotBeforeUpdate( + finishedWork.elementType === finishedWork.type + ? prevProps + : resolveDefaultProps(finishedWork.type, prevProps), + prevState + ); + instance.__reactInternalSnapshotBeforeUpdate = snapshot; + } + break; + case 3: + case 5: + case 6: + case 4: + case 17: + case 20: + break; + default: + throw ReactError( + "This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue." + ); + } + } + nextEffect = nextEffect.nextEffect; + } + } catch (e) { + (childExpirationTimeBeforeCommit = !0), (error = e); } - ); + if (childExpirationTimeBeforeCommit) { + if (null === nextEffect) + throw ReactError( + "Should have next effect. This error is likely caused by a bug in React. Please file an issue." + ); + captureCommitPhaseError$1(nextEffect, error); + null !== nextEffect && (nextEffect = nextEffect.nextEffect); + } + } + for (nextEffect = firstBatch; null !== nextEffect; ) { + current$$1 = !1; + prevProps = void 0; + try { + for (; null !== nextEffect; ) { + var effectTag = nextEffect.effectTag; + if (effectTag & 128) { + var current$$1$jscomp$0 = nextEffect.alternate; + if (null !== current$$1$jscomp$0) { + var currentRef = current$$1$jscomp$0.ref; + null !== currentRef && + ("function" === typeof currentRef + ? currentRef(null) + : (currentRef.current = null)); + } + } + switch (effectTag & 14) { + case 2: + commitPlacement(nextEffect); + nextEffect.effectTag &= -3; + break; + case 6: + commitPlacement(nextEffect); + nextEffect.effectTag &= -3; + commitWork(nextEffect.alternate, nextEffect); + break; + case 4: + commitWork(nextEffect.alternate, nextEffect); + break; + case 8: + prevState = nextEffect; + unmountHostComponents(prevState); + prevState.return = null; + prevState.child = null; + prevState.memoizedState = null; + prevState.updateQueue = null; + var alternate = prevState.alternate; + null !== alternate && + ((alternate.return = null), + (alternate.child = null), + (alternate.memoizedState = null), + (alternate.updateQueue = null)); + } + nextEffect = nextEffect.nextEffect; + } + } catch (e) { + (current$$1 = !0), (prevProps = e); + } + if (current$$1) { + if (null === nextEffect) + throw ReactError( + "Should have next effect. This error is likely caused by a bug in React. Please file an issue." + ); + captureCommitPhaseError$1(nextEffect, prevProps); + null !== nextEffect && (nextEffect = nextEffect.nextEffect); + } + } + root.current = finishedWork$jscomp$0; + for (nextEffect = firstBatch; null !== nextEffect; ) { + effectTag = !1; + current$$1$jscomp$0 = void 0; + try { + for ( + currentRef = root, alternate = expirationTime; + null !== nextEffect; + + ) { + var effectTag$jscomp$0 = nextEffect.effectTag; + if (effectTag$jscomp$0 & 36) { + var current$$1$jscomp$1 = nextEffect.alternate; + current$$1 = nextEffect; + prevProps = alternate; + switch (current$$1.tag) { + case 0: + case 11: + case 15: + commitHookEffectList(16, 32, current$$1); + break; + case 1: + var instance$jscomp$0 = current$$1.stateNode; + if (current$$1.effectTag & 4) + if (null === current$$1$jscomp$1) + instance$jscomp$0.componentDidMount(); + else { + var prevProps$jscomp$0 = + current$$1.elementType === current$$1.type + ? current$$1$jscomp$1.memoizedProps + : resolveDefaultProps( + current$$1.type, + current$$1$jscomp$1.memoizedProps + ); + instance$jscomp$0.componentDidUpdate( + prevProps$jscomp$0, + current$$1$jscomp$1.memoizedState, + instance$jscomp$0.__reactInternalSnapshotBeforeUpdate + ); + } + var updateQueue = current$$1.updateQueue; + null !== updateQueue && + commitUpdateQueue( + current$$1, + updateQueue, + instance$jscomp$0, + prevProps + ); + break; + case 3: + var _updateQueue = current$$1.updateQueue; + if (null !== _updateQueue) { + prevState = null; + if (null !== current$$1.child) + switch (current$$1.child.tag) { + case 5: + prevState = current$$1.child.stateNode; + break; + case 1: + prevState = current$$1.child.stateNode; + } + commitUpdateQueue( + current$$1, + _updateQueue, + prevState, + prevProps + ); + } + break; + case 5: + break; + case 6: + break; + case 4: + break; + case 12: + break; + case 13: + case 17: + case 20: + break; + default: + throw ReactError( + "This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue." + ); + } + } + if (effectTag$jscomp$0 & 128) { + current$$1 = void 0; + var ref = nextEffect.ref; + if (null !== ref) { + var instance$jscomp$1 = nextEffect.stateNode; + switch (nextEffect.tag) { + case 5: + current$$1 = instance$jscomp$1; + break; + default: + current$$1 = instance$jscomp$1; + } + "function" === typeof ref + ? ref(current$$1) + : (ref.current = current$$1); + } + } + effectTag$jscomp$0 & 512 && + (rootWithPendingPassiveEffects = currentRef); + nextEffect = nextEffect.nextEffect; + } + } catch (e) { + (effectTag = !0), (current$$1$jscomp$0 = e); + } + if (effectTag) { + if (null === nextEffect) + throw ReactError( + "Should have next effect. This error is likely caused by a bug in React. Please file an issue." + ); + captureCommitPhaseError$1(nextEffect, current$$1$jscomp$0); + null !== nextEffect && (nextEffect = nextEffect.nextEffect); + } + } + null !== firstBatch && + null !== rootWithPendingPassiveEffects && + ((effectTag$jscomp$0 = commitPassiveEffects.bind(null, root, firstBatch)), + (passiveEffectCallbackHandle = scheduleCallback$1( + NormalPriority$1, + effectTag$jscomp$0 + )), + (passiveEffectCallback = effectTag$jscomp$0)); + isWorking = isCommitting$1 = !1; + "function" === typeof onCommitFiberRoot && + onCommitFiberRoot(finishedWork$jscomp$0.stateNode); + effectTag$jscomp$0 = finishedWork$jscomp$0.expirationTime; + finishedWork$jscomp$0 = finishedWork$jscomp$0.childExpirationTime; + finishedWork$jscomp$0 = + finishedWork$jscomp$0 > effectTag$jscomp$0 + ? finishedWork$jscomp$0 + : effectTag$jscomp$0; + 0 === finishedWork$jscomp$0 && + (legacyErrorBoundariesThatAlreadyFailed = null); + root.expirationTime = finishedWork$jscomp$0; + root.finishedWork = null; } -function onUncaughtError(error) { - invariant( - null !== nextFlushedRoot, - "Should be working on a root. This error is likely caused by a bug in React. Please file an issue." - ); +function onUncaughtError$1(error) { + if (null === nextFlushedRoot) + throw ReactError( + "Should be working on a root. This error is likely caused by a bug in React. Please file an issue." + ); nextFlushedRoot.expirationTime = 0; hasUnhandledError || ((hasUnhandledError = !0), (unhandledError = error)); } +Scheduler_now(); +var requestCurrentTime$$1 = requestCurrentTime$1, + computeExpirationForFiber$$1 = computeExpirationForFiber$1, + captureCommitPhaseError$$1 = captureCommitPhaseError$1, + onUncaughtError$$1 = onUncaughtError$1; +function pingSuspendedRoot$$1(root, thenable, pingTime) { + var pingCache = root.pingCache; + null !== pingCache && pingCache.delete(thenable); + if (null !== nextRoot && nextRenderExpirationTime === pingTime) + nextRoot = null; + else if ( + ((thenable = root.earliestSuspendedTime), + (pingCache = root.latestSuspendedTime), + 0 !== thenable && pingTime <= thenable && pingTime >= pingCache) + ) { + root.didError = !1; + thenable = root.latestPingedTime; + if (0 === thenable || thenable > pingTime) root.latestPingedTime = pingTime; + findNextExpirationTimeToWorkOn(pingTime, root); + pingTime = root.expirationTime; + 0 !== pingTime && requestWork(root, pingTime); + } +} +function resolveRetryThenable$$1(boundaryFiber, thenable) { + var retryCache = boundaryFiber.stateNode; + null !== retryCache && retryCache.delete(thenable); + thenable = requestCurrentTime$1(); + thenable = computeExpirationForFiber$1(thenable, boundaryFiber); + boundaryFiber = scheduleWorkToRoot(boundaryFiber, thenable); + null !== boundaryFiber && + (markPendingPriorityLevel(boundaryFiber, thenable), + (thenable = boundaryFiber.expirationTime), + 0 !== thenable && requestWork(boundaryFiber, thenable)); +} +var isAlreadyFailedLegacyErrorBoundary$$1 = isAlreadyFailedLegacyErrorBoundary$1, + scheduleWork$$1 = scheduleWork$1, + flushPassiveEffects$$1 = flushPassiveEffects$1; function findHostInstance(component) { var fiber = component._reactInternalFiber; - void 0 === fiber && - ("function" === typeof component.render - ? invariant(!1, "Unable to find node on an unmounted component.") - : invariant( - !1, - "Argument appears to not be a ReactComponent. Keys: %s", - Object.keys(component) - )); + if (void 0 === fiber) { + if ("function" === typeof component.render) + throw ReactError("Unable to find node on an unmounted component."); + throw ReactError( + "Argument appears to not be a ReactComponent. Keys: " + + Object.keys(component) + ); + } component = findCurrentHostFiber(fiber); return null === component ? null : component.stateNode; } function updateContainer(element, container, parentComponent, callback) { var current$$1 = container.current, - currentTime = requestCurrentTime(); - current$$1 = computeExpirationForFiber(currentTime, current$$1); + currentTime = requestCurrentTime$$1(); + current$$1 = computeExpirationForFiber$$1(currentTime, current$$1); currentTime = container.current; a: if (parentComponent) { parentComponent = parentComponent._reactInternalFiber; b: { - invariant( - 2 === isFiberMountedImpl(parentComponent) && 1 === parentComponent.tag, - "Expected subtree parent to be a mounted class component. This error is likely caused by a bug in React. Please file an issue." - ); + if ( + 2 !== isFiberMountedImpl(parentComponent) || + 1 !== parentComponent.tag + ) + throw ReactError( + "Expected subtree parent to be a mounted class component. This error is likely caused by a bug in React. Please file an issue." + ); var parentContext = parentComponent; do { switch (parentContext.tag) { @@ -6991,11 +6914,9 @@ function updateContainer(element, container, parentComponent, callback) { } parentContext = parentContext.return; } while (null !== parentContext); - invariant( - !1, + throw ReactError( "Found unexpected detached subtree parent. This error is likely caused by a bug in React. Please file an issue." ); - parentContext = void 0; } if (1 === parentComponent.tag) { var Component = parentComponent.type; @@ -7018,9 +6939,9 @@ function updateContainer(element, container, parentComponent, callback) { callback.payload = { element: element }; container = void 0 === container ? null : container; null !== container && (callback.callback = container); - flushPassiveEffects(); + flushPassiveEffects$$1(); enqueueUpdate(currentTime, callback); - scheduleWork(currentTime, current$$1); + scheduleWork$$1(currentTime, current$$1); return current$$1; } function createPortal(children, containerInfo, implementation) { @@ -7055,7 +6976,9 @@ function _inherits(subClass, superClass) { } var getInspectorDataForViewTag = void 0; getInspectorDataForViewTag = function() { - invariant(!1, "getInspectorDataForViewTag() is not available in production"); + throw ReactError( + "getInspectorDataForViewTag() is not available in production" + ); }; function findNodeHandle(componentOrHandle) { if (null == componentOrHandle) return null; @@ -7078,13 +7001,13 @@ _batchedUpdatesImpl = function(fn, a) { } finally { (isBatchingUpdates = previousIsBatchingUpdates) || isRendering || - performWork(1073741823, !1); + performWork(1073741823); } }; _flushInteractiveUpdatesImpl = function() { isRendering || 0 === lowestPriorityPendingInteractiveExpirationTime || - (performWork(lowestPriorityPendingInteractiveExpirationTime, !1), + (performWork(lowestPriorityPendingInteractiveExpirationTime), (lowestPriorityPendingInteractiveExpirationTime = 0)); }; var roots = new Map(), @@ -7112,47 +7035,81 @@ var roots = new Map(), TextInputState.focusTextInput(findNodeHandle(this)); }; ReactNativeComponent.prototype.measure = function(callback) { - UIManager.measure( - findNodeHandle(this), - mountSafeCallback_NOT_REALLY_SAFE(this, callback) - ); + var maybeInstance = void 0; + try { + maybeInstance = findHostInstance(this); + } catch (error) {} + null != maybeInstance && + (maybeInstance.canonical + ? FabricUIManager.measure( + maybeInstance.node, + mountSafeCallback_NOT_REALLY_SAFE(this, callback) + ) + : UIManager.measure( + findNodeHandle(this), + mountSafeCallback_NOT_REALLY_SAFE(this, callback) + )); }; ReactNativeComponent.prototype.measureInWindow = function(callback) { - UIManager.measureInWindow( - findNodeHandle(this), - mountSafeCallback_NOT_REALLY_SAFE(this, callback) - ); + var maybeInstance = void 0; + try { + maybeInstance = findHostInstance(this); + } catch (error) {} + null != maybeInstance && + (maybeInstance.canonical + ? FabricUIManager.measureInWindow( + maybeInstance.node, + mountSafeCallback_NOT_REALLY_SAFE(this, callback) + ) + : UIManager.measureInWindow( + findNodeHandle(this), + mountSafeCallback_NOT_REALLY_SAFE(this, callback) + )); }; ReactNativeComponent.prototype.measureLayout = function( relativeToNativeNode, onSuccess, onFail ) { - UIManager.measureLayout( - findNodeHandle(this), - relativeToNativeNode, - mountSafeCallback_NOT_REALLY_SAFE(this, onFail), - mountSafeCallback_NOT_REALLY_SAFE(this, onSuccess) - ); + var maybeInstance = void 0; + try { + maybeInstance = findHostInstance(this); + } catch (error) {} + null == maybeInstance || + maybeInstance.canonical || + ((maybeInstance = void 0), + "number" === typeof relativeToNativeNode + ? (maybeInstance = relativeToNativeNode) + : relativeToNativeNode._nativeTag && + (maybeInstance = relativeToNativeNode._nativeTag), + null != maybeInstance && + UIManager.measureLayout( + findNodeHandle(this), + maybeInstance, + mountSafeCallback_NOT_REALLY_SAFE(this, onFail), + mountSafeCallback_NOT_REALLY_SAFE(this, onSuccess) + )); }; ReactNativeComponent.prototype.setNativeProps = function(nativeProps) { var maybeInstance = void 0; try { maybeInstance = findHostInstance(this); } catch (error) {} - if (null != maybeInstance) { - var viewConfig = + if (null != maybeInstance && !maybeInstance.canonical) { + var nativeTag = + maybeInstance._nativeTag || maybeInstance.canonical._nativeTag; + maybeInstance = maybeInstance.viewConfig || maybeInstance.canonical.viewConfig; nativeProps = diffProperties( null, emptyObject, nativeProps, - viewConfig.validAttributes + maybeInstance.validAttributes ); null != nativeProps && UIManager.updateView( - maybeInstance._nativeTag, - viewConfig.uiViewClassName, + nativeTag, + maybeInstance.uiViewClassName, nativeProps ); } @@ -7161,33 +7118,28 @@ var roots = new Map(), })(React.Component); })(findNodeHandle, findHostInstance), findNodeHandle: findNodeHandle, + setNativeProps: function(handle, nativeProps) { + null != handle._nativeTag && + ((nativeProps = diffProperties( + null, + emptyObject, + nativeProps, + handle.viewConfig.validAttributes + )), + null != nativeProps && + UIManager.updateView( + handle._nativeTag, + handle.viewConfig.uiViewClassName, + nativeProps + )); + }, render: function(element, containerTag, callback) { var root = roots.get(containerTag); if (!root) { - root = createFiber(3, null, null, 0); - var root$jscomp$0 = { - current: root, - containerInfo: containerTag, - pendingChildren: null, - pingCache: null, - earliestPendingTime: 0, - latestPendingTime: 0, - earliestSuspendedTime: 0, - latestSuspendedTime: 0, - latestPingedTime: 0, - didError: !1, - pendingCommitExpirationTime: 0, - finishedWork: null, - timeoutHandle: -1, - context: null, - pendingContext: null, - hydrate: !1, - nextExpirationTimeToWorkOn: 0, - expirationTime: 0, - firstBatch: null, - nextScheduledRoot: null - }; - root = root.stateNode = root$jscomp$0; + root = new FiberRootNode(containerTag, !1); + var uninitializedFiber = createFiber(3, null, null, 0); + root.current = uninitializedFiber; + uninitializedFiber.stateNode = root; roots.set(containerTag, root); } updateContainer(element, root, null, callback); @@ -7226,42 +7178,77 @@ var roots = new Map(), NativeMethodsMixin: (function(findNodeHandle, findHostInstance) { return { measure: function(callback) { - UIManager.measure( - findNodeHandle(this), - mountSafeCallback_NOT_REALLY_SAFE(this, callback) - ); + var maybeInstance = void 0; + try { + maybeInstance = findHostInstance(this); + } catch (error) {} + null != maybeInstance && + (maybeInstance.canonical + ? FabricUIManager.measure( + maybeInstance.node, + mountSafeCallback_NOT_REALLY_SAFE(this, callback) + ) + : UIManager.measure( + findNodeHandle(this), + mountSafeCallback_NOT_REALLY_SAFE(this, callback) + )); }, measureInWindow: function(callback) { - UIManager.measureInWindow( - findNodeHandle(this), - mountSafeCallback_NOT_REALLY_SAFE(this, callback) - ); + var maybeInstance = void 0; + try { + maybeInstance = findHostInstance(this); + } catch (error) {} + null != maybeInstance && + (maybeInstance.canonical + ? FabricUIManager.measureInWindow( + maybeInstance.node, + mountSafeCallback_NOT_REALLY_SAFE(this, callback) + ) + : UIManager.measureInWindow( + findNodeHandle(this), + mountSafeCallback_NOT_REALLY_SAFE(this, callback) + )); }, measureLayout: function(relativeToNativeNode, onSuccess, onFail) { - UIManager.measureLayout( - findNodeHandle(this), - relativeToNativeNode, - mountSafeCallback_NOT_REALLY_SAFE(this, onFail), - mountSafeCallback_NOT_REALLY_SAFE(this, onSuccess) - ); + var maybeInstance = void 0; + try { + maybeInstance = findHostInstance(this); + } catch (error) {} + null == maybeInstance || + maybeInstance.canonical || + ((maybeInstance = void 0), + "number" === typeof relativeToNativeNode + ? (maybeInstance = relativeToNativeNode) + : relativeToNativeNode._nativeTag && + (maybeInstance = relativeToNativeNode._nativeTag), + null != maybeInstance && + UIManager.measureLayout( + findNodeHandle(this), + maybeInstance, + mountSafeCallback_NOT_REALLY_SAFE(this, onFail), + mountSafeCallback_NOT_REALLY_SAFE(this, onSuccess) + )); }, setNativeProps: function(nativeProps) { var maybeInstance = void 0; try { maybeInstance = findHostInstance(this); } catch (error) {} - if (null != maybeInstance) { - var viewConfig = maybeInstance.viewConfig; + if (null != maybeInstance && !maybeInstance.canonical) { + var nativeTag = + maybeInstance._nativeTag || maybeInstance.canonical._nativeTag; + maybeInstance = + maybeInstance.viewConfig || maybeInstance.canonical.viewConfig; nativeProps = diffProperties( null, emptyObject, nativeProps, - viewConfig.validAttributes + maybeInstance.validAttributes ); null != nativeProps && UIManager.updateView( - maybeInstance._nativeTag, - viewConfig.uiViewClassName, + nativeTag, + maybeInstance.uiViewClassName, nativeProps ); } @@ -7285,7 +7272,10 @@ var roots = new Map(), var findFiberByHostInstance = devToolsConfig.findFiberByHostInstance; return injectInternals( Object.assign({}, devToolsConfig, { + overrideHookState: null, overrideProps: null, + setSuspenseHandler: null, + scheduleUpdate: null, currentDispatcherRef: ReactSharedInternals.ReactCurrentDispatcher, findHostInstanceByFiber: function(fiber) { fiber = findCurrentHostFiber(fiber); @@ -7302,7 +7292,7 @@ var roots = new Map(), findFiberByHostInstance: getInstanceFromTag, getInspectorDataForViewTag: getInspectorDataForViewTag, bundleType: 0, - version: "16.8.1", + version: "16.8.6", rendererPackageName: "react-native-renderer" }); var ReactNativeRenderer$2 = { default: ReactNativeRenderer }, diff --git a/Libraries/Renderer/oss/ReactNativeRenderer-profiling.js b/Libraries/Renderer/oss/ReactNativeRenderer-profiling.js index b0636f842253b4..65b70bd7146800 100644 --- a/Libraries/Renderer/oss/ReactNativeRenderer-profiling.js +++ b/Libraries/Renderer/oss/ReactNativeRenderer-profiling.js @@ -19,78 +19,14 @@ var ReactNativeViewConfigRegistry = require("ReactNativeViewConfigRegistry"), deepDiffer = require("deepDiffer"), flattenStyle = require("flattenStyle"), TextInputState = require("TextInputState"), + Scheduler = require("scheduler"), tracing = require("scheduler/tracing"), - scheduler = require("scheduler"), - ExceptionsManager = require("ExceptionsManager"); -function invariant(condition, format, a, b, c, d, e, f) { - if (!condition) { - condition = void 0; - if (void 0 === format) - condition = Error( - "Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings." - ); - else { - var args = [a, b, c, d, e, f], - argIndex = 0; - condition = Error( - format.replace(/%s/g, function() { - return args[argIndex++]; - }) - ); - condition.name = "Invariant Violation"; - } - condition.framesToPop = 1; - throw condition; - } -} -function invokeGuardedCallbackImpl(name, func, context, a, b, c, d, e, f) { - var funcArgs = Array.prototype.slice.call(arguments, 3); - try { - func.apply(context, funcArgs); - } catch (error) { - this.onError(error); - } -} -var hasError = !1, - caughtError = null, - hasRethrowError = !1, - rethrowError = null, - reporter = { - onError: function(error) { - hasError = !0; - caughtError = error; - } - }; -function invokeGuardedCallback(name, func, context, a, b, c, d, e, f) { - hasError = !1; - caughtError = null; - invokeGuardedCallbackImpl.apply(reporter, arguments); -} -function invokeGuardedCallbackAndCatchFirstError( - name, - func, - context, - a, - b, - c, - d, - e, - f -) { - invokeGuardedCallback.apply(this, arguments); - if (hasError) { - if (hasError) { - var error = caughtError; - hasError = !1; - caughtError = null; - } else - invariant( - !1, - "clearCaughtError was called but no error was captured. This error is likely caused by a bug in React. Please file an issue." - ), - (error = void 0); - hasRethrowError || ((hasRethrowError = !0), (rethrowError = error)); - } + ExceptionsManager = require("ExceptionsManager"), + FabricUIManager = require("FabricUIManager"); +function ReactError(message) { + message = Error(message); + message.name = "Invariant Violation"; + return message; } var eventPluginOrder = null, namesToPlugins = {}; @@ -99,17 +35,19 @@ function recomputePluginOrdering() { for (var pluginName in namesToPlugins) { var pluginModule = namesToPlugins[pluginName], pluginIndex = eventPluginOrder.indexOf(pluginName); - invariant( - -1 < pluginIndex, - "EventPluginRegistry: Cannot inject event plugins that do not exist in the plugin ordering, `%s`.", - pluginName - ); - if (!plugins[pluginIndex]) { - invariant( - pluginModule.extractEvents, - "EventPluginRegistry: Event plugins must implement an `extractEvents` method, but `%s` does not.", - pluginName + if (!(-1 < pluginIndex)) + throw ReactError( + "EventPluginRegistry: Cannot inject event plugins that do not exist in the plugin ordering, `" + + pluginName + + "`." ); + if (!plugins[pluginIndex]) { + if (!pluginModule.extractEvents) + throw ReactError( + "EventPluginRegistry: Event plugins must implement an `extractEvents` method, but `" + + pluginName + + "` does not." + ); plugins[pluginIndex] = pluginModule; pluginIndex = pluginModule.eventTypes; for (var eventName in pluginIndex) { @@ -117,11 +55,12 @@ function recomputePluginOrdering() { var dispatchConfig = pluginIndex[eventName], pluginModule$jscomp$0 = pluginModule, eventName$jscomp$0 = eventName; - invariant( - !eventNameDispatchConfigs.hasOwnProperty(eventName$jscomp$0), - "EventPluginHub: More than one plugin attempted to publish the same event name, `%s`.", - eventName$jscomp$0 - ); + if (eventNameDispatchConfigs.hasOwnProperty(eventName$jscomp$0)) + throw ReactError( + "EventPluginHub: More than one plugin attempted to publish the same event name, `" + + eventName$jscomp$0 + + "`." + ); eventNameDispatchConfigs[eventName$jscomp$0] = dispatchConfig; var phasedRegistrationNames = dispatchConfig.phasedRegistrationNames; if (phasedRegistrationNames) { @@ -144,28 +83,78 @@ function recomputePluginOrdering() { ), (JSCompiler_inline_result = !0)) : (JSCompiler_inline_result = !1); - invariant( - JSCompiler_inline_result, - "EventPluginRegistry: Failed to publish event `%s` for plugin `%s`.", - eventName, - pluginName - ); + if (!JSCompiler_inline_result) + throw ReactError( + "EventPluginRegistry: Failed to publish event `" + + eventName + + "` for plugin `" + + pluginName + + "`." + ); } } } } function publishRegistrationName(registrationName, pluginModule) { - invariant( - !registrationNameModules[registrationName], - "EventPluginHub: More than one plugin attempted to publish the same registration name, `%s`.", - registrationName - ); + if (registrationNameModules[registrationName]) + throw ReactError( + "EventPluginHub: More than one plugin attempted to publish the same registration name, `" + + registrationName + + "`." + ); registrationNameModules[registrationName] = pluginModule; } var plugins = [], eventNameDispatchConfigs = {}, - registrationNameModules = {}, - getFiberCurrentPropsFromNode = null, + registrationNameModules = {}; +function invokeGuardedCallbackImpl(name, func, context, a, b, c, d, e, f) { + var funcArgs = Array.prototype.slice.call(arguments, 3); + try { + func.apply(context, funcArgs); + } catch (error) { + this.onError(error); + } +} +var hasError = !1, + caughtError = null, + hasRethrowError = !1, + rethrowError = null, + reporter = { + onError: function(error) { + hasError = !0; + caughtError = error; + } + }; +function invokeGuardedCallback(name, func, context, a, b, c, d, e, f) { + hasError = !1; + caughtError = null; + invokeGuardedCallbackImpl.apply(reporter, arguments); +} +function invokeGuardedCallbackAndCatchFirstError( + name, + func, + context, + a, + b, + c, + d, + e, + f +) { + invokeGuardedCallback.apply(this, arguments); + if (hasError) { + if (hasError) { + var error = caughtError; + hasError = !1; + caughtError = null; + } else + throw ReactError( + "clearCaughtError was called but no error was captured. This error is likely caused by a bug in React. Please file an issue." + ); + hasRethrowError || ((hasRethrowError = !0), (rethrowError = error)); + } +} +var getFiberCurrentPropsFromNode = null, getInstanceFromNode = null, getNodeFromInstance = null; function executeDispatch(event, listener, inst) { @@ -177,10 +166,8 @@ function executeDispatch(event, listener, inst) { function executeDirectDispatch(event) { var dispatchListener = event._dispatchListeners, dispatchInstance = event._dispatchInstances; - invariant( - !Array.isArray(dispatchListener), - "executeDirectDispatch(...): Invalid `event`." - ); + if (Array.isArray(dispatchListener)) + throw ReactError("executeDirectDispatch(...): Invalid `event`."); event.currentTarget = dispatchListener ? getNodeFromInstance(dispatchInstance) : null; @@ -191,10 +178,10 @@ function executeDirectDispatch(event) { return dispatchListener; } function accumulateInto(current, next) { - invariant( - null != next, - "accumulateInto(...): Accumulated items must not be null or undefined." - ); + if (null == next) + throw ReactError( + "accumulateInto(...): Accumulated items must not be null or undefined." + ); if (null == current) return next; if (Array.isArray(current)) { if (Array.isArray(next)) return current.push.apply(current, next), current; @@ -228,10 +215,10 @@ function executeDispatchesAndReleaseTopLevel(e) { } var injection = { injectEventPluginOrder: function(injectedEventPluginOrder) { - invariant( - !eventPluginOrder, - "EventPluginRegistry: Cannot inject event plugin ordering more than once. You are likely trying to load more than one copy of React." - ); + if (eventPluginOrder) + throw ReactError( + "EventPluginRegistry: Cannot inject event plugin ordering more than once. You are likely trying to load more than one copy of React." + ); eventPluginOrder = Array.prototype.slice.call(injectedEventPluginOrder); recomputePluginOrdering(); }, @@ -241,15 +228,19 @@ var injection = { for (pluginName in injectedNamesToPlugins) if (injectedNamesToPlugins.hasOwnProperty(pluginName)) { var pluginModule = injectedNamesToPlugins[pluginName]; - (namesToPlugins.hasOwnProperty(pluginName) && - namesToPlugins[pluginName] === pluginModule) || - (invariant( - !namesToPlugins[pluginName], - "EventPluginRegistry: Cannot inject two different event plugins using the same name, `%s`.", - pluginName - ), - (namesToPlugins[pluginName] = pluginModule), - (isOrderingDirty = !0)); + if ( + !namesToPlugins.hasOwnProperty(pluginName) || + namesToPlugins[pluginName] !== pluginModule + ) { + if (namesToPlugins[pluginName]) + throw ReactError( + "EventPluginRegistry: Cannot inject two different event plugins using the same name, `" + + pluginName + + "`." + ); + namesToPlugins[pluginName] = pluginModule; + isOrderingDirty = !0; + } } isOrderingDirty && recomputePluginOrdering(); } @@ -285,12 +276,14 @@ function getListener(inst, registrationName) { inst = !1; } if (inst) return null; - invariant( - !listener || "function" === typeof listener, - "Expected `%s` listener to be a function, instead got a value of `%s` type.", - registrationName, - typeof listener - ); + if (listener && "function" !== typeof listener) + throw ReactError( + "Expected `" + + registrationName + + "` listener to be a function, instead got a value of `" + + typeof listener + + "` type." + ); return listener; } function getParent(inst) { @@ -451,10 +444,10 @@ function getPooledEvent(dispatchConfig, targetInst, nativeEvent, nativeInst) { return new this(dispatchConfig, targetInst, nativeEvent, nativeInst); } function releasePooledEvent(event) { - invariant( - event instanceof this, - "Trying to release an event instance into a pool of a different type." - ); + if (!(event instanceof this)) + throw ReactError( + "Trying to release an event instance into a pool of a different type." + ); event.destructor(); 10 > this.eventPool.length && this.eventPool.push(event); } @@ -489,7 +482,7 @@ function timestampForTouch(touch) { } function getTouchIdentifier(_ref) { _ref = _ref.identifier; - invariant(null != _ref, "Touch object is missing identifier."); + if (null == _ref) throw ReactError("Touch object is missing identifier."); return _ref; } function recordTouchStart(touch) { @@ -602,10 +595,10 @@ var ResponderTouchHistoryStore = { touchHistory: touchHistory }; function accumulate(current, next) { - invariant( - null != next, - "accumulate(...): Accumulated items must be not be null or undefined." - ); + if (null == next) + throw ReactError( + "accumulate(...): Accumulated items must be not be null or undefined." + ); return null == current ? next : Array.isArray(current) @@ -970,11 +963,10 @@ var eventTypes$1 = { ReactNativeViewConfigRegistry.customBubblingEventTypes[topLevelType], directDispatchConfig = ReactNativeViewConfigRegistry.customDirectEventTypes[topLevelType]; - invariant( - bubbleDispatchConfig || directDispatchConfig, - 'Unsupported top level event type "%s" dispatched', - topLevelType - ); + if (!bubbleDispatchConfig && !directDispatchConfig) + throw ReactError( + 'Unsupported top level event type "' + topLevelType + '" dispatched' + ); topLevelType = SyntheticEvent.getPooled( bubbleDispatchConfig || directDispatchConfig, targetInst, @@ -1005,14 +997,10 @@ function getInstanceFromTag(tag) { var restoreTarget = null, restoreQueue = null; function restoreStateOfTarget(target) { - if ((target = getInstanceFromNode(target))) { - invariant( - !1, + if (getInstanceFromNode(target)) + throw ReactError( "setRestoreImplementation() needs to be called to handle a target for controlled events. This error is likely caused by a bug in React. Please file an issue." ); - var props = getFiberCurrentPropsFromNode(target.stateNode); - null(target.stateNode, target.type, props); - } } function _batchedUpdatesImpl(fn, bookkeeping) { return fn(bookkeeping); @@ -1060,19 +1048,18 @@ function _receiveRootNodeIDEvent(rootNodeID, topLevelType, nativeEventParam) { null !== events && (eventQueue = accumulateInto(eventQueue, events)); events = eventQueue; eventQueue = null; - if ( - events && - (forEachAccumulated(events, executeDispatchesAndReleaseTopLevel), - invariant( - !eventQueue, - "processEventQueue(): Additional events were enqueued while processing an event queue. Support for this has not yet been implemented." - ), - hasRethrowError) - ) - throw ((events = rethrowError), - (hasRethrowError = !1), - (rethrowError = null), - events); + if (events) { + forEachAccumulated(events, executeDispatchesAndReleaseTopLevel); + if (eventQueue) + throw ReactError( + "processEventQueue(): Additional events were enqueued while processing an event queue. Support for this has not yet been implemented." + ); + if (hasRethrowError) + throw ((events = rethrowError), + (hasRethrowError = !1), + (rethrowError = null), + events); + } }); } RCTEventEmitter.register({ @@ -1119,7 +1106,7 @@ getInstanceFromNode = getInstanceFromTag; getNodeFromInstance = function(inst) { var tag = inst.stateNode._nativeTag; void 0 === tag && (tag = inst.stateNode.canonical._nativeTag); - invariant(tag, "All native instances should have a tag."); + if (!tag) throw ReactError("All native instances should have a tag."); return tag; }; ResponderEventPlugin.injection.injectGlobalResponderHandler({ @@ -1148,6 +1135,15 @@ var hasSymbol = "function" === typeof Symbol && Symbol.for, REACT_SUSPENSE_TYPE = hasSymbol ? Symbol.for("react.suspense") : 60113, REACT_MEMO_TYPE = hasSymbol ? Symbol.for("react.memo") : 60115, REACT_LAZY_TYPE = hasSymbol ? Symbol.for("react.lazy") : 60116, + REACT_EVENT_COMPONENT_TYPE = hasSymbol + ? Symbol.for("react.event_component") + : 60117, + REACT_EVENT_TARGET_TYPE = hasSymbol + ? Symbol.for("react.event_target") + : 60118, + REACT_EVENT_TARGET_TOUCH_HIT = hasSymbol + ? Symbol.for("react.event_target.touch_hit") + : 60119, MAYBE_ITERATOR_SYMBOL = "function" === typeof Symbol && Symbol.iterator; function getIteratorFn(maybeIterable) { if (null === maybeIterable || "object" !== typeof maybeIterable) return null; @@ -1192,6 +1188,15 @@ function getComponentName(type) { case REACT_LAZY_TYPE: if ((type = 1 === type._status ? type._result : null)) return getComponentName(type); + break; + case REACT_EVENT_COMPONENT_TYPE: + type = type.displayName; + if (void 0 !== type) return type; + break; + case REACT_EVENT_TARGET_TYPE: + if (type.type === REACT_EVENT_TARGET_TOUCH_HIT) return "TouchHitTarget"; + type = type.displayName; + if (void 0 !== type) return type; } return null; } @@ -1206,80 +1211,83 @@ function isFiberMountedImpl(fiber) { return 3 === node.tag ? 2 : 3; } function assertIsMounted(fiber) { - invariant( - 2 === isFiberMountedImpl(fiber), - "Unable to find node on an unmounted component." - ); + if (2 !== isFiberMountedImpl(fiber)) + throw ReactError("Unable to find node on an unmounted component."); } function findCurrentFiberUsingSlowPath(fiber) { var alternate = fiber.alternate; - if (!alternate) - return ( - (alternate = isFiberMountedImpl(fiber)), - invariant( - 3 !== alternate, - "Unable to find node on an unmounted component." - ), - 1 === alternate ? null : fiber - ); + if (!alternate) { + alternate = isFiberMountedImpl(fiber); + if (3 === alternate) + throw ReactError("Unable to find node on an unmounted component."); + return 1 === alternate ? null : fiber; + } for (var a = fiber, b = alternate; ; ) { - var parentA = a.return, - parentB = parentA ? parentA.alternate : null; - if (!parentA || !parentB) break; + var parentA = a.return; + if (null === parentA) break; + var parentB = parentA.alternate; + if (null === parentB) { + b = parentA.return; + if (null !== b) { + a = b; + continue; + } + break; + } if (parentA.child === parentB.child) { - for (var child = parentA.child; child; ) { - if (child === a) return assertIsMounted(parentA), fiber; - if (child === b) return assertIsMounted(parentA), alternate; - child = child.sibling; + for (parentB = parentA.child; parentB; ) { + if (parentB === a) return assertIsMounted(parentA), fiber; + if (parentB === b) return assertIsMounted(parentA), alternate; + parentB = parentB.sibling; } - invariant(!1, "Unable to find node on an unmounted component."); + throw ReactError("Unable to find node on an unmounted component."); } if (a.return !== b.return) (a = parentA), (b = parentB); else { - child = !1; - for (var _child = parentA.child; _child; ) { + for (var didFindChild = !1, _child = parentA.child; _child; ) { if (_child === a) { - child = !0; + didFindChild = !0; a = parentA; b = parentB; break; } if (_child === b) { - child = !0; + didFindChild = !0; b = parentA; a = parentB; break; } _child = _child.sibling; } - if (!child) { + if (!didFindChild) { for (_child = parentB.child; _child; ) { if (_child === a) { - child = !0; + didFindChild = !0; a = parentB; b = parentA; break; } if (_child === b) { - child = !0; + didFindChild = !0; b = parentB; a = parentA; break; } _child = _child.sibling; } - invariant( - child, - "Child was not found in either parent set. This indicates a bug in React related to the return pointer. Please file an issue." - ); + if (!didFindChild) + throw ReactError( + "Child was not found in either parent set. This indicates a bug in React related to the return pointer. Please file an issue." + ); } } - invariant( - a.alternate === b, - "Return fibers should always be each others' alternates. This error is likely caused by a bug in React. Please file an issue." - ); + if (a.alternate !== b) + throw ReactError( + "Return fibers should always be each others' alternates. This error is likely caused by a bug in React. Please file an issue." + ); } - invariant(3 === a.tag, "Unable to find node on an unmounted component."); + if (3 !== a.tag) + throw ReactError("Unable to find node on an unmounted component."); return a.stateNode.current === a ? fiber : alternate; } function findCurrentHostFiber(parent) { @@ -1528,86 +1536,72 @@ function mountSafeCallback_NOT_REALLY_SAFE(context, callback) { }; } var ReactNativeFiberHostComponent = (function() { - function ReactNativeFiberHostComponent(tag, viewConfig) { - if (!(this instanceof ReactNativeFiberHostComponent)) - throw new TypeError("Cannot call a class as a function"); - this._nativeTag = tag; - this._children = []; - this.viewConfig = viewConfig; - } - ReactNativeFiberHostComponent.prototype.blur = function() { - TextInputState.blurTextInput(this._nativeTag); - }; - ReactNativeFiberHostComponent.prototype.focus = function() { - TextInputState.focusTextInput(this._nativeTag); - }; - ReactNativeFiberHostComponent.prototype.measure = function(callback) { - UIManager.measure( - this._nativeTag, - mountSafeCallback_NOT_REALLY_SAFE(this, callback) - ); - }; - ReactNativeFiberHostComponent.prototype.measureInWindow = function( - callback - ) { - UIManager.measureInWindow( - this._nativeTag, - mountSafeCallback_NOT_REALLY_SAFE(this, callback) - ); - }; - ReactNativeFiberHostComponent.prototype.measureLayout = function( - relativeToNativeNode, - onSuccess, - onFail - ) { + function ReactNativeFiberHostComponent(tag, viewConfig) { + if (!(this instanceof ReactNativeFiberHostComponent)) + throw new TypeError("Cannot call a class as a function"); + this._nativeTag = tag; + this._children = []; + this.viewConfig = viewConfig; + } + ReactNativeFiberHostComponent.prototype.blur = function() { + TextInputState.blurTextInput(this._nativeTag); + }; + ReactNativeFiberHostComponent.prototype.focus = function() { + TextInputState.focusTextInput(this._nativeTag); + }; + ReactNativeFiberHostComponent.prototype.measure = function(callback) { + UIManager.measure( + this._nativeTag, + mountSafeCallback_NOT_REALLY_SAFE(this, callback) + ); + }; + ReactNativeFiberHostComponent.prototype.measureInWindow = function(callback) { + UIManager.measureInWindow( + this._nativeTag, + mountSafeCallback_NOT_REALLY_SAFE(this, callback) + ); + }; + ReactNativeFiberHostComponent.prototype.measureLayout = function( + relativeToNativeNode, + onSuccess, + onFail + ) { + var relativeNode = void 0; + "number" === typeof relativeToNativeNode + ? (relativeNode = relativeToNativeNode) + : relativeToNativeNode._nativeTag + ? (relativeNode = relativeToNativeNode._nativeTag) + : relativeToNativeNode.canonical && + relativeToNativeNode.canonical._nativeTag && + (relativeNode = relativeToNativeNode.canonical._nativeTag); + null != relativeNode && UIManager.measureLayout( this._nativeTag, - relativeToNativeNode, + relativeNode, mountSafeCallback_NOT_REALLY_SAFE(this, onFail), mountSafeCallback_NOT_REALLY_SAFE(this, onSuccess) ); - }; - ReactNativeFiberHostComponent.prototype.setNativeProps = function( - nativeProps - ) { - nativeProps = diffProperties( - null, - emptyObject, - nativeProps, - this.viewConfig.validAttributes + }; + ReactNativeFiberHostComponent.prototype.setNativeProps = function( + nativeProps + ) { + nativeProps = diffProperties( + null, + emptyObject, + nativeProps, + this.viewConfig.validAttributes + ); + null != nativeProps && + UIManager.updateView( + this._nativeTag, + this.viewConfig.uiViewClassName, + nativeProps ); - null != nativeProps && - UIManager.updateView( - this._nativeTag, - this.viewConfig.uiViewClassName, - nativeProps - ); - }; - return ReactNativeFiberHostComponent; - })(), - now$1 = - "object" === typeof performance && "function" === typeof performance.now - ? function() { - return performance.now(); - } - : function() { - return Date.now(); - }, - scheduledCallback = null, - frameDeadline = 0; -function setTimeoutCallback() { - frameDeadline = now$1() + 5; - var callback = scheduledCallback; - scheduledCallback = null; - null !== callback && callback(); -} -function scheduleDeferredCallback$1(callback) { - scheduledCallback = callback; - return setTimeout(setTimeoutCallback, 1); -} + }; + return ReactNativeFiberHostComponent; +})(); function shim$1() { - invariant( - !1, + throw ReactError( "The current renderer does not support hydration. This error is likely caused by a bug in React. Please file an issue." ); } @@ -1638,24 +1632,8 @@ function finalizeInitialChildren(parentInstance) { return !1; } var scheduleTimeout = setTimeout, - cancelTimeout = clearTimeout; -function commitUpdate(instance, updatePayloadTODO, type, oldProps, newProps) { - updatePayloadTODO = instance.viewConfig; - instanceProps[instance._nativeTag] = newProps; - oldProps = diffProperties( - null, - oldProps, - newProps, - updatePayloadTODO.validAttributes - ); - null != oldProps && - UIManager.updateView( - instance._nativeTag, - updatePayloadTODO.uiViewClassName, - oldProps - ); -} -var BEFORE_SLASH_RE = /^(.*)[\\\/]/; + cancelTimeout = clearTimeout, + BEFORE_SLASH_RE = /^(.*)[\\\/]/; function getStackByFiberInDevAndProd(workInProgress) { var info = ""; do { @@ -1739,10 +1717,10 @@ function popTopLevelContextObject(fiber) { pop(contextStackCursor, fiber); } function pushTopLevelContextObject(fiber, context, didChange) { - invariant( - contextStackCursor.current === emptyContextObject, - "Unexpected context found on stack. This error is likely caused by a bug in React. Please file an issue." - ); + if (contextStackCursor.current !== emptyContextObject) + throw ReactError( + "Unexpected context found on stack. This error is likely caused by a bug in React. Please file an issue." + ); push(contextStackCursor, context, fiber); push(didPerformWorkStackCursor, didChange, fiber); } @@ -1752,12 +1730,13 @@ function processChildContext(fiber, type, parentContext) { if ("function" !== typeof instance.getChildContext) return parentContext; instance = instance.getChildContext(); for (var contextKey in instance) - invariant( - contextKey in fiber, - '%s.getChildContext(): key "%s" is not defined in childContextTypes.', - getComponentName(type) || "Unknown", - contextKey - ); + if (!(contextKey in fiber)) + throw ReactError( + (getComponentName(type) || "Unknown") + + '.getChildContext(): key "' + + contextKey + + '" is not defined in childContextTypes.' + ); return Object.assign({}, parentContext, instance); } function pushContextProvider(workInProgress) { @@ -1776,10 +1755,10 @@ function pushContextProvider(workInProgress) { } function invalidateContextProvider(workInProgress, type, didChange) { var instance = workInProgress.stateNode; - invariant( - instance, - "Expected to have an instance by this point. This error is likely caused by a bug in React. Please file an issue." - ); + if (!instance) + throw ReactError( + "Expected to have an instance by this point. This error is likely caused by a bug in React. Please file an issue." + ); didChange ? ((type = processChildContext(workInProgress, type, previousContext)), (instance.__reactInternalMemoizedMergedChildContext = type), @@ -1814,6 +1793,7 @@ function injectInternals(internals) { } catch (err) {} return !0; } +var Scheduler_now = Scheduler.unstable_now; function FiberNode(tag, pendingProps, key, mode) { this.tag = tag; this.key = key; @@ -1944,11 +1924,10 @@ function createFiberFromTypeAndProps( owner = null; break a; } - invariant( - !1, - "Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s", - null == type ? type : typeof type, - "" + throw ReactError( + "Element type is invalid: expected a string (for built-in components) or a class/function (for composite components) but got: " + + (null == type ? type : typeof type) + + "." ); } key = createFiber(fiberTag, pendingProps, key, mode); @@ -1990,6 +1969,24 @@ function createFiberFromPortal(portal, mode, expirationTime) { }; return mode; } +function FiberRootNode(containerInfo, hydrate) { + this.current = null; + this.containerInfo = containerInfo; + this.pingCache = this.pendingChildren = null; + this.pendingCommitExpirationTime = 0; + this.finishedWork = null; + this.timeoutHandle = -1; + this.pendingContext = this.context = null; + this.hydrate = hydrate; + this.firstBatch = null; + this.latestPingedTime = this.latestSuspendedTime = this.earliestSuspendedTime = this.latestPendingTime = this.earliestPendingTime = 0; + this.didError = !1; + this.expirationTime = this.nextExpirationTimeToWorkOn = 0; + this.nextScheduledRoot = null; + this.interactionThreadID = tracing.unstable_getThreadID(); + this.memoizedInteractions = new Set(); + this.pendingInteractionMap = new Map(); +} function markPendingPriorityLevel(root, expirationTime) { root.didError = !1; var earliestPendingTime = root.earliestPendingTime; @@ -2064,14 +2061,6 @@ function markSuspendedPriorityLevel(root, suspendedTime) { (root.latestSuspendedTime = suspendedTime); findNextExpirationTimeToWorkOn(suspendedTime, root); } -function findEarliestOutstandingPriorityLevel(root, renderExpirationTime) { - var earliestPendingTime = root.earliestPendingTime; - root = root.earliestSuspendedTime; - earliestPendingTime > renderExpirationTime && - (renderExpirationTime = earliestPendingTime); - root > renderExpirationTime && (renderExpirationTime = root); - return renderExpirationTime; -} function findNextExpirationTimeToWorkOn(completedExpirationTime, root) { var earliestSuspendedTime = root.earliestSuspendedTime, latestSuspendedTime = root.latestSuspendedTime, @@ -2186,37 +2175,37 @@ var classComponentUpdater = { }, enqueueSetState: function(inst, payload, callback) { inst = inst._reactInternalFiber; - var currentTime = requestCurrentTime(); - currentTime = computeExpirationForFiber(currentTime, inst); + var currentTime = requestCurrentTime$$1(); + currentTime = computeExpirationForFiber$$1(currentTime, inst); var update = createUpdate(currentTime); update.payload = payload; void 0 !== callback && null !== callback && (update.callback = callback); - flushPassiveEffects(); + flushPassiveEffects$$1(); enqueueUpdate(inst, update); - scheduleWork(inst, currentTime); + scheduleWork$$1(inst, currentTime); }, enqueueReplaceState: function(inst, payload, callback) { inst = inst._reactInternalFiber; - var currentTime = requestCurrentTime(); - currentTime = computeExpirationForFiber(currentTime, inst); + var currentTime = requestCurrentTime$$1(); + currentTime = computeExpirationForFiber$$1(currentTime, inst); var update = createUpdate(currentTime); update.tag = ReplaceState; update.payload = payload; void 0 !== callback && null !== callback && (update.callback = callback); - flushPassiveEffects(); + flushPassiveEffects$$1(); enqueueUpdate(inst, update); - scheduleWork(inst, currentTime); + scheduleWork$$1(inst, currentTime); }, enqueueForceUpdate: function(inst, callback) { inst = inst._reactInternalFiber; - var currentTime = requestCurrentTime(); - currentTime = computeExpirationForFiber(currentTime, inst); + var currentTime = requestCurrentTime$$1(); + currentTime = computeExpirationForFiber$$1(currentTime, inst); var update = createUpdate(currentTime); update.tag = ForceUpdate; void 0 !== callback && null !== callback && (update.callback = callback); - flushPassiveEffects(); + flushPassiveEffects$$1(); enqueueUpdate(inst, update); - scheduleWork(inst, currentTime); + scheduleWork$$1(inst, currentTime); } }; function checkShouldComponentUpdate( @@ -2341,17 +2330,19 @@ function coerceRef(returnFiber, current$$1, element) { if (element._owner) { element = element._owner; var inst = void 0; - element && - (invariant( - 1 === element.tag, - "Function components cannot have refs. Did you mean to use React.forwardRef()?" - ), - (inst = element.stateNode)); - invariant( - inst, - "Missing owner for string ref %s. This error is likely caused by a bug in React. Please file an issue.", - returnFiber - ); + if (element) { + if (1 !== element.tag) + throw ReactError( + "Function components cannot have refs. Did you mean to use React.forwardRef()?" + ); + inst = element.stateNode; + } + if (!inst) + throw ReactError( + "Missing owner for string ref " + + returnFiber + + ". This error is likely caused by a bug in React. Please file an issue." + ); var stringRef = "" + returnFiber; if ( null !== current$$1 && @@ -2368,27 +2359,27 @@ function coerceRef(returnFiber, current$$1, element) { current$$1._stringRef = stringRef; return current$$1; } - invariant( - "string" === typeof returnFiber, - "Expected ref to be a function, a string, an object returned by React.createRef(), or null." - ); - invariant( - element._owner, - "Element ref was specified as a string (%s) but no owner was set. This could happen for one of the following reasons:\n1. You may be adding a ref to a function component\n2. You may be adding a ref to a component that was not created inside a component's render method\n3. You have multiple copies of React loaded\nSee https://fb.me/react-refs-must-have-owner for more information.", - returnFiber - ); + if ("string" !== typeof returnFiber) + throw ReactError( + "Expected ref to be a function, a string, an object returned by React.createRef(), or null." + ); + if (!element._owner) + throw ReactError( + "Element ref was specified as a string (" + + returnFiber + + ") but no owner was set. This could happen for one of the following reasons:\n1. You may be adding a ref to a function component\n2. You may be adding a ref to a component that was not created inside a component's render method\n3. You have multiple copies of React loaded\nSee https://fb.me/react-refs-must-have-owner for more information." + ); } return returnFiber; } function throwOnInvalidObjectType(returnFiber, newChild) { - "textarea" !== returnFiber.type && - invariant( - !1, - "Objects are not valid as a React child (found: %s).%s", - "[object Object]" === Object.prototype.toString.call(newChild) - ? "object with keys {" + Object.keys(newChild).join(", ") + "}" - : newChild, - "" + if ("textarea" !== returnFiber.type) + throw ReactError( + "Objects are not valid as a React child (found: " + + ("[object Object]" === Object.prototype.toString.call(newChild) + ? "object with keys {" + Object.keys(newChild).join(", ") + "}" + : newChild) + + ")." ); } function ChildReconciler(shouldTrackSideEffects) { @@ -2787,15 +2778,13 @@ function ChildReconciler(shouldTrackSideEffects) { expirationTime ) { var iteratorFn = getIteratorFn(newChildrenIterable); - invariant( - "function" === typeof iteratorFn, - "An object is not an iterable. This error is likely caused by a bug in React. Please file an issue." - ); + if ("function" !== typeof iteratorFn) + throw ReactError( + "An object is not an iterable. This error is likely caused by a bug in React. Please file an issue." + ); newChildrenIterable = iteratorFn.call(newChildrenIterable); - invariant( - null != newChildrenIterable, - "An iterable object provided no iterator." - ); + if (null == newChildrenIterable) + throw ReactError("An iterable object provided no iterator."); for ( var previousNewFiber = (iteratorFn = null), oldFiber = currentFirstChild, @@ -2887,7 +2876,7 @@ function ChildReconciler(shouldTrackSideEffects) { null !== isUnkeyedTopLevelFragment; ) { - if (isUnkeyedTopLevelFragment.key === isObject) + if (isUnkeyedTopLevelFragment.key === isObject) { if ( 7 === isUnkeyedTopLevelFragment.tag ? newChild.type === REACT_FRAGMENT_TYPE @@ -2912,14 +2901,10 @@ function ChildReconciler(shouldTrackSideEffects) { currentFirstChild.return = returnFiber; returnFiber = currentFirstChild; break a; - } else { - deleteRemainingChildren( - returnFiber, - isUnkeyedTopLevelFragment - ); - break; } - else deleteChild(returnFiber, isUnkeyedTopLevelFragment); + deleteRemainingChildren(returnFiber, isUnkeyedTopLevelFragment); + break; + } else deleteChild(returnFiber, isUnkeyedTopLevelFragment); isUnkeyedTopLevelFragment = isUnkeyedTopLevelFragment.sibling; } newChild.type === REACT_FRAGMENT_TYPE @@ -2955,7 +2940,7 @@ function ChildReconciler(shouldTrackSideEffects) { null !== currentFirstChild; ) { - if (currentFirstChild.key === isUnkeyedTopLevelFragment) + if (currentFirstChild.key === isUnkeyedTopLevelFragment) { if ( 4 === currentFirstChild.tag && currentFirstChild.stateNode.containerInfo === @@ -2975,11 +2960,10 @@ function ChildReconciler(shouldTrackSideEffects) { currentFirstChild.return = returnFiber; returnFiber = currentFirstChild; break a; - } else { - deleteRemainingChildren(returnFiber, currentFirstChild); - break; } - else deleteChild(returnFiber, currentFirstChild); + deleteRemainingChildren(returnFiber, currentFirstChild); + break; + } else deleteChild(returnFiber, currentFirstChild); currentFirstChild = currentFirstChild.sibling; } currentFirstChild = createFiberFromPortal( @@ -3033,12 +3017,11 @@ function ChildReconciler(shouldTrackSideEffects) { switch (returnFiber.tag) { case 1: case 0: - (expirationTime = returnFiber.type), - invariant( - !1, - "%s(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null.", - expirationTime.displayName || expirationTime.name || "Component" - ); + throw ((returnFiber = returnFiber.type), + ReactError( + (returnFiber.displayName || returnFiber.name || "Component") + + "(...): Nothing was returned from render. This usually means a return statement is missing. Or, to render nothing, return null." + )); } return deleteRemainingChildren(returnFiber, currentFirstChild); }; @@ -3050,10 +3033,10 @@ var reconcileChildFibers = ChildReconciler(!0), contextFiberStackCursor = { current: NO_CONTEXT }, rootInstanceStackCursor = { current: NO_CONTEXT }; function requiredContext(c) { - invariant( - c !== NO_CONTEXT, - "Expected host context to exist. This error is likely caused by a bug in React. Please file an issue." - ); + if (c === NO_CONTEXT) + throw ReactError( + "Expected host context to exist. This error is likely caused by a bug in React. Please file an issue." + ); return c; } function pushHostContainer(fiber, nextRootInstance) { @@ -3090,15 +3073,7 @@ function popHostContext(fiber) { contextFiberStackCursor.current === fiber && (pop(contextStackCursor$1, fiber), pop(contextFiberStackCursor, fiber)); } -var NoEffect$1 = 0, - UnmountSnapshot = 2, - UnmountMutation = 4, - MountMutation = 8, - UnmountLayout = 16, - MountLayout = 32, - MountPassive = 64, - UnmountPassive = 128, - ReactCurrentDispatcher$1 = ReactSharedInternals.ReactCurrentDispatcher, +var ReactCurrentDispatcher$1 = ReactSharedInternals.ReactCurrentDispatcher, renderExpirationTime = 0, currentlyRenderingFiber$1 = null, currentHook = null, @@ -3113,9 +3088,8 @@ var NoEffect$1 = 0, renderPhaseUpdates = null, numberOfReRenders = 0; function throwInvalidHookError() { - invariant( - !1, - "Hooks can only be called inside the body of a function component. (https://fb.me/react-invalid-hook-call)" + throw ReactError( + "Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:\n1. You might have mismatching versions of React and the renderer (such as React DOM)\n2. You might be breaking the Rules of Hooks\n3. You might have more than one copy of React in the same app\nSee https://fb.me/react-invalid-hook-call for tips about how to debug and fix this problem." ); } function areHookInputsEqual(nextDeps, prevDeps) { @@ -3163,10 +3137,10 @@ function renderWithHooks( remainingExpirationTime = 0; componentUpdateQueue = null; sideEffectTag = 0; - invariant( - !current, - "Rendered fewer hooks than expected. This may be caused by an accidental early return statement." - ); + if (current) + throw ReactError( + "Rendered fewer hooks than expected. This may be caused by an accidental early return statement." + ); return workInProgress; } function resetHooks() { @@ -3200,10 +3174,8 @@ function updateWorkInProgressHook() { (currentHook = nextCurrentHook), (nextCurrentHook = null !== currentHook ? currentHook.next : null); else { - invariant( - null !== nextCurrentHook, - "Rendered more hooks than during the previous render." - ); + if (null === nextCurrentHook) + throw ReactError("Rendered more hooks than during the previous render."); currentHook = nextCurrentHook; var newHook = { memoizedState: currentHook.memoizedState, @@ -3226,10 +3198,11 @@ function basicStateReducer(state, action) { function updateReducer(reducer) { var hook = updateWorkInProgressHook(), queue = hook.queue; - invariant( - null !== queue, - "Should have a queue. This is likely a bug in React. Please file an issue." - ); + if (null === queue) + throw ReactError( + "Should have a queue. This is likely a bug in React. Please file an issue." + ); + queue.lastRenderedReducer = reducer; if (0 < numberOfReRenders) { var _dispatch = queue.dispatch; if (null !== renderPhaseUpdates) { @@ -3244,6 +3217,7 @@ function updateReducer(reducer) { is(newState, hook.memoizedState) || (didReceiveUpdate = !0); hook.memoizedState = newState; hook.baseUpdate === queue.last && (hook.baseState = newState); + queue.lastRenderedState = newState; return [newState, _dispatch]; } } @@ -3269,10 +3243,12 @@ function updateReducer(reducer) { (firstRenderPhaseUpdate = newState)), updateExpirationTime > remainingExpirationTime && (remainingExpirationTime = updateExpirationTime)) - : (newState = + : (updateExpirationTime < mostRecentEventTime && + (mostRecentEventTime = updateExpirationTime), + (newState = _update.eagerReducer === reducer ? _update.eagerState - : reducer(newState, _update.action)); + : reducer(newState, _update.action))); baseUpdate = _update; _update = _update.next; } while (null !== _update && _update !== _dispatch); @@ -3282,8 +3258,7 @@ function updateReducer(reducer) { hook.memoizedState = newState; hook.baseUpdate = newBaseUpdate; hook.baseState = firstRenderPhaseUpdate; - queue.eagerReducer = reducer; - queue.eagerState = newState; + queue.lastRenderedState = newState; } return [hook.memoizedState, queue.dispatch]; } @@ -3319,7 +3294,7 @@ function updateEffectImpl(fiberEffectTag, hookEffectTag, create, deps) { var prevEffect = currentHook.memoizedState; destroy = prevEffect.destroy; if (null !== deps && areHookInputsEqual(deps, prevEffect.deps)) { - pushEffect(NoEffect$1, create, destroy, deps); + pushEffect(0, create, destroy, deps); return; } } @@ -3346,10 +3321,10 @@ function imperativeHandleEffect(create, ref) { } function mountDebugValue() {} function dispatchAction(fiber, queue, action) { - invariant( - 25 > numberOfReRenders, - "Too many re-renders. React limits the number of renders to prevent an infinite loop." - ); + if (!(25 > numberOfReRenders)) + throw ReactError( + "Too many re-renders. React limits the number of renders to prevent an infinite loop." + ); var alternate = fiber.alternate; if ( fiber === currentlyRenderingFiber$1 || @@ -3374,9 +3349,9 @@ function dispatchAction(fiber, queue, action) { queue.next = fiber; } else { - flushPassiveEffects(); - var currentTime = requestCurrentTime(); - currentTime = computeExpirationForFiber(currentTime, fiber); + flushPassiveEffects$$1(); + var currentTime = requestCurrentTime$$1(); + currentTime = computeExpirationForFiber$$1(currentTime, fiber); var _update2 = { expirationTime: currentTime, action: action, @@ -3395,10 +3370,10 @@ function dispatchAction(fiber, queue, action) { if ( 0 === fiber.expirationTime && (null === alternate || 0 === alternate.expirationTime) && - ((alternate = queue.eagerReducer), null !== alternate) + ((alternate = queue.lastRenderedReducer), null !== alternate) ) try { - var currentState = queue.eagerState, + var currentState = queue.lastRenderedState, _eagerState = alternate(currentState, action); _update2.eagerReducer = alternate; _update2.eagerState = _eagerState; @@ -3406,7 +3381,7 @@ function dispatchAction(fiber, queue, action) { } catch (error) { } finally { } - scheduleWork(fiber, currentTime); + scheduleWork$$1(fiber, currentTime); } } var ContextOnlyDispatcher = { @@ -3433,19 +3408,19 @@ var ContextOnlyDispatcher = { }, useContext: readContext, useEffect: function(create, deps) { - return mountEffectImpl(516, UnmountPassive | MountPassive, create, deps); + return mountEffectImpl(516, 192, create, deps); }, useImperativeHandle: function(ref, create, deps) { deps = null !== deps && void 0 !== deps ? deps.concat([ref]) : null; return mountEffectImpl( 4, - UnmountMutation | MountLayout, + 36, imperativeHandleEffect.bind(null, create, ref), deps ); }, useLayoutEffect: function(create, deps) { - return mountEffectImpl(4, UnmountMutation | MountLayout, create, deps); + return mountEffectImpl(4, 36, create, deps); }, useMemo: function(nextCreate, deps) { var hook = mountWorkInProgressHook(); @@ -3461,8 +3436,8 @@ var ContextOnlyDispatcher = { reducer = hook.queue = { last: null, dispatch: null, - eagerReducer: reducer, - eagerState: initialArg + lastRenderedReducer: reducer, + lastRenderedState: initialArg }; reducer = reducer.dispatch = dispatchAction.bind( null, @@ -3483,8 +3458,8 @@ var ContextOnlyDispatcher = { initialState = hook.queue = { last: null, dispatch: null, - eagerReducer: basicStateReducer, - eagerState: initialState + lastRenderedReducer: basicStateReducer, + lastRenderedState: initialState }; initialState = initialState.dispatch = dispatchAction.bind( null, @@ -3512,19 +3487,19 @@ var ContextOnlyDispatcher = { }, useContext: readContext, useEffect: function(create, deps) { - return updateEffectImpl(516, UnmountPassive | MountPassive, create, deps); + return updateEffectImpl(516, 192, create, deps); }, useImperativeHandle: function(ref, create, deps) { deps = null !== deps && void 0 !== deps ? deps.concat([ref]) : null; return updateEffectImpl( 4, - UnmountMutation | MountLayout, + 36, imperativeHandleEffect.bind(null, create, ref), deps ); }, useLayoutEffect: function(create, deps) { - return updateEffectImpl(4, UnmountMutation | MountLayout, create, deps); + return updateEffectImpl(4, 36, create, deps); }, useMemo: function(nextCreate, deps) { var hook = updateWorkInProgressHook(); @@ -3549,11 +3524,12 @@ var ContextOnlyDispatcher = { }, useDebugValue: mountDebugValue }, + now$2 = Scheduler.unstable_now, commitTime = 0, profilerStartTime = -1; function stopProfilerTimerIfRunningAndRecordDelta(fiber, overrideBaseTime) { if (0 <= profilerStartTime) { - var elapsedTime = now$1() - profilerStartTime; + var elapsedTime = now$2() - profilerStartTime; fiber.actualDuration += elapsedTime; overrideBaseTime && (fiber.selfBaseDuration = elapsedTime); profilerStartTime = -1; @@ -3574,6 +3550,8 @@ function tryHydrate(fiber, nextInstance) { (nextInstance = shim$1(nextInstance, fiber.pendingProps)), null !== nextInstance ? ((fiber.stateNode = nextInstance), !0) : !1 ); + case 13: + return !1; default: return !1; } @@ -4112,7 +4090,10 @@ function updateSuspenseComponent( nextState = null; var nextDidTimeout = !1; } else - (nextState = { timedOutAt: null !== nextState ? nextState.timedOutAt : 0 }), + (nextState = { + fallbackExpirationTime: + null !== nextState ? nextState.fallbackExpirationTime : 0 + }), (nextDidTimeout = !0), (workInProgress.effectTag &= -65); if (null === current$$1) @@ -4242,10 +4223,8 @@ function bailoutOnAlreadyFinishedWork( (workInProgress.contextDependencies = current$$1.contextDependencies); profilerStartTime = -1; if (workInProgress.childExpirationTime < renderExpirationTime) return null; - invariant( - null === current$$1 || workInProgress.child === current$$1.child, - "Resuming work not yet implemented." - ); + if (null !== current$$1 && workInProgress.child !== current$$1.child) + throw ReactError("Resuming work not yet implemented."); if (null !== workInProgress.child) { current$$1 = workInProgress.child; renderExpirationTime = createWorkInProgress( @@ -4413,59 +4392,57 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { ((current$$1.alternate = null), (workInProgress.alternate = null), (workInProgress.effectTag |= 2)); - hasContext = workInProgress.pendingProps; - current$$1 = readLazyComponentType(context); - workInProgress.type = current$$1; - context = workInProgress.tag = resolveLazyComponentTag(current$$1); - hasContext = resolveDefaultProps(current$$1, hasContext); - getDerivedStateFromProps = void 0; - switch (context) { + current$$1 = workInProgress.pendingProps; + context = readLazyComponentType(context); + workInProgress.type = context; + hasContext = workInProgress.tag = resolveLazyComponentTag(context); + current$$1 = resolveDefaultProps(context, current$$1); + switch (hasContext) { case 0: - getDerivedStateFromProps = updateFunctionComponent( + workInProgress = updateFunctionComponent( null, workInProgress, + context, current$$1, - hasContext, renderExpirationTime ); break; case 1: - getDerivedStateFromProps = updateClassComponent( + workInProgress = updateClassComponent( null, workInProgress, + context, current$$1, - hasContext, renderExpirationTime ); break; case 11: - getDerivedStateFromProps = updateForwardRef( + workInProgress = updateForwardRef( null, workInProgress, + context, current$$1, - hasContext, renderExpirationTime ); break; case 14: - getDerivedStateFromProps = updateMemoComponent( + workInProgress = updateMemoComponent( null, workInProgress, - current$$1, - resolveDefaultProps(current$$1.type, hasContext), + context, + resolveDefaultProps(context.type, current$$1), updateExpirationTime, renderExpirationTime ); break; default: - invariant( - !1, - "Element type is invalid. Received a promise that resolves to: %s. Lazy element type must resolve to a class or function.%s", - current$$1, - "" + throw ReactError( + "Element type is invalid. Received a promise that resolves to: " + + context + + ". Lazy element type must resolve to a class or function." ); } - return getDerivedStateFromProps; + return workInProgress; case 0: return ( (updateExpirationTime = workInProgress.type), @@ -4499,41 +4476,39 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { ) ); case 3: - return ( - pushHostRootContext(workInProgress), - (updateExpirationTime = workInProgress.updateQueue), - invariant( - null !== updateExpirationTime, + pushHostRootContext(workInProgress); + updateExpirationTime = workInProgress.updateQueue; + if (null === updateExpirationTime) + throw ReactError( "If the root does not have an updateQueue, we should have already bailed out. This error is likely caused by a bug in React. Please file an issue." - ), - (context = workInProgress.memoizedState), - (context = null !== context ? context.element : null), - processUpdateQueue( - workInProgress, - updateExpirationTime, - workInProgress.pendingProps, - null, - renderExpirationTime - ), - (updateExpirationTime = workInProgress.memoizedState.element), - updateExpirationTime === context - ? (workInProgress = bailoutOnAlreadyFinishedWork( - current$$1, - workInProgress, - renderExpirationTime - )) - : (reconcileChildren( - current$$1, - workInProgress, - updateExpirationTime, - renderExpirationTime - ), - (workInProgress = workInProgress.child)), - workInProgress - ); - case 5: - return ( - pushHostContext(workInProgress), + ); + context = workInProgress.memoizedState; + context = null !== context ? context.element : null; + processUpdateQueue( + workInProgress, + updateExpirationTime, + workInProgress.pendingProps, + null, + renderExpirationTime + ); + updateExpirationTime = workInProgress.memoizedState.element; + updateExpirationTime === context + ? (workInProgress = bailoutOnAlreadyFinishedWork( + current$$1, + workInProgress, + renderExpirationTime + )) + : (reconcileChildren( + current$$1, + workInProgress, + updateExpirationTime, + renderExpirationTime + ), + (workInProgress = workInProgress.child)); + return workInProgress; + case 5: + return ( + pushHostContext(workInProgress), null === current$$1 && tryToClaimNextHydratableInstance(workInProgress), (updateExpirationTime = workInProgress.pendingProps.children), markRef(current$$1, workInProgress), @@ -4543,8 +4518,7 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { updateExpirationTime, renderExpirationTime ), - (workInProgress = workInProgress.child), - workInProgress + workInProgress.child ); case 6: return ( @@ -4680,19 +4654,19 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { null !== dependency && dependency.expirationTime < renderExpirationTime && (dependency.expirationTime = renderExpirationTime); + dependency = renderExpirationTime; for (var node = oldValue.return; null !== node; ) { - dependency = node.alternate; - if (node.childExpirationTime < renderExpirationTime) - (node.childExpirationTime = renderExpirationTime), - null !== dependency && - dependency.childExpirationTime < - renderExpirationTime && - (dependency.childExpirationTime = renderExpirationTime); + var alternate = node.alternate; + if (node.childExpirationTime < dependency) + (node.childExpirationTime = dependency), + null !== alternate && + alternate.childExpirationTime < dependency && + (alternate.childExpirationTime = dependency); else if ( - null !== dependency && - dependency.childExpirationTime < renderExpirationTime + null !== alternate && + alternate.childExpirationTime < dependency ) - dependency.childExpirationTime = renderExpirationTime; + alternate.childExpirationTime = dependency; else break; node = node.return; } @@ -4822,12 +4796,10 @@ function beginWork(current$$1, workInProgress, renderExpirationTime) { renderExpirationTime ) ); - default: - invariant( - !1, - "Unknown unit of work tag. This error is likely caused by a bug in React. Please file an issue." - ); } + throw ReactError( + "Unknown unit of work tag. This error is likely caused by a bug in React. Please file an issue." + ); } var valueCursor = { current: null }, currentlyRenderingFiber = null, @@ -4861,17 +4833,17 @@ function readContext(context, observedBits) { if ("number" !== typeof observedBits || 1073741823 === observedBits) (lastContextWithAllBitsObserved = context), (observedBits = 1073741823); observedBits = { context: context, observedBits: observedBits, next: null }; - null === lastContextDependency - ? (invariant( - null !== currentlyRenderingFiber, + if (null === lastContextDependency) { + if (null === currentlyRenderingFiber) + throw ReactError( "Context can only be read while React is rendering. In classes, you can read it in the render method or getDerivedStateFromProps. In function components, you can read it directly in the function body, but not inside Hooks like useReducer() or useMemo()." - ), - (lastContextDependency = observedBits), - (currentlyRenderingFiber.contextDependencies = { - first: observedBits, - expirationTime: 0 - })) - : (lastContextDependency = lastContextDependency.next = observedBits); + ); + lastContextDependency = observedBits; + currentlyRenderingFiber.contextDependencies = { + first: observedBits, + expirationTime: 0 + }; + } else lastContextDependency = lastContextDependency.next = observedBits; } return context._currentValue; } @@ -5024,7 +4996,9 @@ function processUpdateQueue( ((newFirstUpdate = update), (newBaseState = resultState)), newExpirationTime < updateExpirationTime && (newExpirationTime = updateExpirationTime)) - : ((resultState = getStateFromUpdate( + : (updateExpirationTime < mostRecentEventTime && + (mostRecentEventTime = updateExpirationTime), + (resultState = getStateFromUpdate( workInProgress, queue, update, @@ -5097,11 +5071,11 @@ function commitUpdateEffects(effect, instance) { if (null !== _callback3) { effect.callback = null; var context = instance; - invariant( - "function" === typeof _callback3, - "Invalid argument passed as callback. Expected a function. Instead received: %s", - _callback3 - ); + if ("function" !== typeof _callback3) + throw ReactError( + "Invalid argument passed as callback. Expected a function. Instead received: " + + _callback3 + ); _callback3.call(context); } effect = effect.nextEffect; @@ -5164,7 +5138,7 @@ function logCapturedError(capturedError) { : Error("Unspecified error at:" + componentStack); ExceptionsManager.handleException(error, !1); } -var PossiblyWeakSet = "function" === typeof WeakSet ? WeakSet : Set; +var PossiblyWeakSet$1 = "function" === typeof WeakSet ? WeakSet : Set; function logError(boundary, errorInfo) { var source = errorInfo.source, stack = errorInfo.stack; @@ -5201,22 +5175,56 @@ function safelyDetachRef(current$$1) { try { ref(null); } catch (refError) { - captureCommitPhaseError(current$$1, refError); + captureCommitPhaseError$$1(current$$1, refError); } else ref.current = null; } +function commitBeforeMutationLifeCycles(current$$1, finishedWork) { + switch (finishedWork.tag) { + case 0: + case 11: + case 15: + commitHookEffectList(2, 0, finishedWork); + break; + case 1: + if (finishedWork.effectTag & 256 && null !== current$$1) { + var prevProps = current$$1.memoizedProps, + prevState = current$$1.memoizedState; + current$$1 = finishedWork.stateNode; + finishedWork = current$$1.getSnapshotBeforeUpdate( + finishedWork.elementType === finishedWork.type + ? prevProps + : resolveDefaultProps(finishedWork.type, prevProps), + prevState + ); + current$$1.__reactInternalSnapshotBeforeUpdate = finishedWork; + } + break; + case 3: + case 5: + case 6: + case 4: + case 17: + case 20: + break; + default: + throw ReactError( + "This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue." + ); + } +} function commitHookEffectList(unmountTag, mountTag, finishedWork) { finishedWork = finishedWork.updateQueue; finishedWork = null !== finishedWork ? finishedWork.lastEffect : null; if (null !== finishedWork) { var effect = (finishedWork = finishedWork.next); do { - if ((effect.tag & unmountTag) !== NoEffect$1) { + if (0 !== (effect.tag & unmountTag)) { var destroy = effect.destroy; effect.destroy = void 0; void 0 !== destroy && destroy(); } - (effect.tag & mountTag) !== NoEffect$1 && + 0 !== (effect.tag & mountTag) && ((destroy = effect.create), (effect.destroy = destroy())); effect = effect.next; } while (effect !== finishedWork); @@ -5301,7 +5309,7 @@ function commitUnmount(current$$1$jscomp$0) { try { destroy(); } catch (error) { - captureCommitPhaseError(current$$1, error); + captureCommitPhaseError$$1(current$$1, error); } } effect = effect.next; @@ -5317,7 +5325,7 @@ function commitUnmount(current$$1$jscomp$0) { (updateQueue.state = current$$1$jscomp$0.memoizedState), updateQueue.componentWillUnmount(); } catch (unmountError) { - captureCommitPhaseError(current$$1$jscomp$0, unmountError); + captureCommitPhaseError$$1(current$$1$jscomp$0, unmountError); } break; case 5: @@ -5339,17 +5347,14 @@ function commitPlacement(finishedWork) { } parent = parent.return; } - invariant( - !1, + throw ReactError( "Expected to find a host parent. This error is likely caused by a bug in React. Please file an issue." ); - parentFiber = void 0; } - var isContainer = (parent = void 0); switch (parentFiber.tag) { case 5: parent = parentFiber.stateNode; - isContainer = !1; + var isContainer = !1; break; case 3: parent = parentFiber.stateNode.containerInfo; @@ -5360,8 +5365,7 @@ function commitPlacement(finishedWork) { isContainer = !0; break; default: - invariant( - !1, + throw ReactError( "Invalid host parent fiber. This error is likely caused by a bug in React. Please file an issue." ); } @@ -5377,7 +5381,7 @@ function commitPlacement(finishedWork) { parentFiber.sibling.return = parentFiber.return; for ( parentFiber = parentFiber.sibling; - 5 !== parentFiber.tag && 6 !== parentFiber.tag; + 5 !== parentFiber.tag && 6 !== parentFiber.tag && 18 !== parentFiber.tag; ) { if (parentFiber.effectTag & 2) continue b; @@ -5392,23 +5396,23 @@ function commitPlacement(finishedWork) { } } for (var node = finishedWork; ; ) { - if (5 === node.tag || 6 === node.tag) + if (5 === node.tag || 6 === node.tag) { + var stateNode = node.stateNode; if (parentFiber) - if (isContainer) - invariant( - "number" !== typeof parent, - "Container does not support insertBefore operation" - ); - else { + if (isContainer) { + if ("number" === typeof parent) + throw ReactError( + "Container does not support insertBefore operation" + ); + } else { var parentInstance = parent, - child = node.stateNode, beforeChild = parentFiber, children = parentInstance._children, - index = children.indexOf(child); + index = children.indexOf(stateNode); 0 <= index ? (children.splice(index, 1), (beforeChild = children.indexOf(beforeChild)), - children.splice(beforeChild, 0, child), + children.splice(beforeChild, 0, stateNode), UIManager.manageChildren( parentInstance._nativeTag, [index], @@ -5418,32 +5422,33 @@ function commitPlacement(finishedWork) { [] )) : ((index = children.indexOf(beforeChild)), - children.splice(index, 0, child), + children.splice(index, 0, stateNode), UIManager.manageChildren( parentInstance._nativeTag, [], [], - ["number" === typeof child ? child : child._nativeTag], + [ + "number" === typeof stateNode + ? stateNode + : stateNode._nativeTag + ], [index], [] )); } else isContainer - ? ((parentInstance = node.stateNode), - UIManager.setChildren(parent, [ - "number" === typeof parentInstance - ? parentInstance - : parentInstance._nativeTag - ])) + ? UIManager.setChildren(parent, [ + "number" === typeof stateNode ? stateNode : stateNode._nativeTag + ]) : ((parentInstance = parent), - (child = node.stateNode), - (children = "number" === typeof child ? child : child._nativeTag), + (children = + "number" === typeof stateNode ? stateNode : stateNode._nativeTag), (index = parentInstance._children), - (beforeChild = index.indexOf(child)), + (beforeChild = index.indexOf(stateNode)), 0 <= beforeChild ? (index.splice(beforeChild, 1), - index.push(child), + index.push(stateNode), UIManager.manageChildren( parentInstance._nativeTag, [beforeChild], @@ -5452,7 +5457,7 @@ function commitPlacement(finishedWork) { [], [] )) - : (index.push(child), + : (index.push(stateNode), UIManager.manageChildren( parentInstance._nativeTag, [], @@ -5461,7 +5466,7 @@ function commitPlacement(finishedWork) { [index.length - 1], [] ))); - else if (4 !== node.tag && null !== node.child) { + } else if (4 !== node.tag && null !== node.child) { node.child.return = node; node = node.child; continue; @@ -5487,10 +5492,10 @@ function unmountHostComponents(current$$1) { if (!currentParentIsValid) { currentParentIsValid = node.return; a: for (;;) { - invariant( - null !== currentParentIsValid, - "Expected to find a host parent. This error is likely caused by a bug in React. Please file an issue." - ); + if (null === currentParentIsValid) + throw ReactError( + "Expected to find a host parent. This error is likely caused by a bug in React. Please file an issue." + ); switch (currentParentIsValid.tag) { case 5: currentParent = currentParentIsValid.stateNode; @@ -5569,7 +5574,7 @@ function commitWork(current$$1, finishedWork) { case 11: case 14: case 15: - commitHookEffectList(UnmountMutation, MountMutation, finishedWork); + commitHookEffectList(4, 8, finishedWork); break; case 1: break; @@ -5578,67 +5583,77 @@ function commitWork(current$$1, finishedWork) { if (null != instance) { var newProps = finishedWork.memoizedProps; current$$1 = null !== current$$1 ? current$$1.memoizedProps : newProps; - var type = finishedWork.type, - updatePayload = finishedWork.updateQueue; + var updatePayload = finishedWork.updateQueue; finishedWork.updateQueue = null; null !== updatePayload && - commitUpdate( - instance, - updatePayload, - type, + ((finishedWork = instance.viewConfig), + (instanceProps[instance._nativeTag] = newProps), + (newProps = diffProperties( + null, current$$1, newProps, - finishedWork - ); + finishedWork.validAttributes + )), + null != newProps && + UIManager.updateView( + instance._nativeTag, + finishedWork.uiViewClassName, + newProps + )); } break; case 6: - invariant( - null !== finishedWork.stateNode, - "This should have a text node initialized. This error is likely caused by a bug in React. Please file an issue." - ); + if (null === finishedWork.stateNode) + throw ReactError( + "This should have a text node initialized. This error is likely caused by a bug in React. Please file an issue." + ); UIManager.updateView(finishedWork.stateNode, "RCTRawText", { text: finishedWork.memoizedProps }); break; + case 20: + break; case 3: break; case 12: break; case 13: - instance = finishedWork.memoizedState; - newProps = void 0; - current$$1 = finishedWork; - null === instance - ? (newProps = !1) - : ((newProps = !0), - (current$$1 = finishedWork.child), - 0 === instance.timedOutAt && - (instance.timedOutAt = requestCurrentTime())); - null !== current$$1 && hideOrUnhideAllChildren(current$$1, newProps); - instance = finishedWork.updateQueue; - if (null !== instance) { - finishedWork.updateQueue = null; - var retryCache = finishedWork.stateNode; - null === retryCache && - (retryCache = finishedWork.stateNode = new PossiblyWeakSet()); - instance.forEach(function(thenable) { - var retry = retryTimedOutBoundary.bind(null, finishedWork, thenable); - retry = tracing.unstable_wrap(retry); - retryCache.has(thenable) || - (retryCache.add(thenable), thenable.then(retry, retry)); - }); - } + commitSuspenseComponent(finishedWork); break; case 17: break; default: - invariant( - !1, + throw ReactError( "This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue." ); } } +function commitSuspenseComponent(finishedWork) { + var newState = finishedWork.memoizedState, + newDidTimeout = void 0, + primaryChildParent = finishedWork; + null === newState + ? (newDidTimeout = !1) + : ((newDidTimeout = !0), + (primaryChildParent = finishedWork.child), + 0 === newState.fallbackExpirationTime && + (newState.fallbackExpirationTime = requestCurrentTime$$1() - 500)); + null !== primaryChildParent && + hideOrUnhideAllChildren(primaryChildParent, newDidTimeout); + newState = finishedWork.updateQueue; + if (null !== newState) { + finishedWork.updateQueue = null; + var retryCache = finishedWork.stateNode; + null === retryCache && + (retryCache = finishedWork.stateNode = new PossiblyWeakSet$1()); + newState.forEach(function(thenable) { + var retry = resolveRetryThenable$$1.bind(null, finishedWork, thenable); + retry = tracing.unstable_wrap(retry); + retryCache.has(thenable) || + (retryCache.add(thenable), thenable.then(retry, retry)); + }); + } +} var PossiblyWeakMap = "function" === typeof WeakMap ? WeakMap : Map; function createRootErrorUpdate(fiber, errorInfo, expirationTime) { expirationTime = createUpdate(expirationTime); @@ -5646,7 +5661,7 @@ function createRootErrorUpdate(fiber, errorInfo, expirationTime) { expirationTime.payload = { element: null }; var error = errorInfo.value; expirationTime.callback = function() { - onUncaughtError(error); + onUncaughtError$$1(error); logError(fiber, errorInfo); }; return expirationTime; @@ -5694,34 +5709,13 @@ function throwException( ) { var thenable = value; value = returnFiber; - var earliestTimeoutMs = -1, - startTimeMs = -1; do { - if (13 === value.tag) { - var current$$1 = value.alternate; - if ( - null !== current$$1 && - ((current$$1 = current$$1.memoizedState), null !== current$$1) - ) { - startTimeMs = 10 * (1073741822 - current$$1.timedOutAt); - break; - } - current$$1 = value.pendingProps.maxDuration; - if ("number" === typeof current$$1) - if (0 >= current$$1) earliestTimeoutMs = 0; - else if (-1 === earliestTimeoutMs || current$$1 < earliestTimeoutMs) - earliestTimeoutMs = current$$1; - } - value = value.return; - } while (null !== value); - value = returnFiber; - do { - if ((current$$1 = 13 === value.tag)) - current$$1 = - void 0 === value.memoizedProps.fallback - ? !1 - : null === value.memoizedState; - if (current$$1) { + if ( + 13 === value.tag && + (void 0 === value.memoizedProps.fallback + ? 0 + : null === value.memoizedState) + ) { returnFiber = value.updateQueue; null === returnFiber ? ((returnFiber = new Set()), @@ -5740,40 +5734,27 @@ function throwException( sourceFiber.expirationTime = 1073741823; return; } - sourceFiber = root.pingCache; - null === sourceFiber - ? ((sourceFiber = root.pingCache = new PossiblyWeakMap()), + sourceFiber = root; + root = renderExpirationTime; + var pingCache = sourceFiber.pingCache; + null === pingCache + ? ((pingCache = sourceFiber.pingCache = new PossiblyWeakMap()), (returnFiber = new Set()), - sourceFiber.set(thenable, returnFiber)) - : ((returnFiber = sourceFiber.get(thenable)), + pingCache.set(thenable, returnFiber)) + : ((returnFiber = pingCache.get(thenable)), void 0 === returnFiber && ((returnFiber = new Set()), - sourceFiber.set(thenable, returnFiber))); - returnFiber.has(renderExpirationTime) || - (returnFiber.add(renderExpirationTime), - (sourceFiber = pingSuspendedRoot.bind( + pingCache.set(thenable, returnFiber))); + returnFiber.has(root) || + (returnFiber.add(root), + (sourceFiber = pingSuspendedRoot$$1.bind( null, - root, + sourceFiber, thenable, - renderExpirationTime + root )), (sourceFiber = tracing.unstable_wrap(sourceFiber)), thenable.then(sourceFiber, sourceFiber)); - -1 === earliestTimeoutMs - ? (root = 1073741823) - : (-1 === startTimeMs && - (startTimeMs = - 10 * - (1073741822 - - findEarliestOutstandingPriorityLevel( - root, - renderExpirationTime - )) - - 5e3), - (root = startTimeMs + earliestTimeoutMs)); - 0 <= root && - nextLatestAbsoluteTimeoutMs < root && - (nextLatestAbsoluteTimeoutMs = root); value.effectTag |= 2048; value.expirationTime = renderExpirationTime; return; @@ -5788,44 +5769,43 @@ function throwException( } nextRenderDidError = !0; value = createCapturedValue(value, sourceFiber); - root = returnFiber; + sourceFiber = returnFiber; do { - switch (root.tag) { + switch (sourceFiber.tag) { case 3: - root.effectTag |= 2048; - root.expirationTime = renderExpirationTime; + sourceFiber.effectTag |= 2048; + sourceFiber.expirationTime = renderExpirationTime; renderExpirationTime = createRootErrorUpdate( - root, + sourceFiber, value, renderExpirationTime ); - enqueueCapturedUpdate(root, renderExpirationTime); + enqueueCapturedUpdate(sourceFiber, renderExpirationTime); return; case 1: if ( ((thenable = value), - (earliestTimeoutMs = root.type), - (startTimeMs = root.stateNode), - 0 === (root.effectTag & 64) && - ("function" === typeof earliestTimeoutMs.getDerivedStateFromError || - (null !== startTimeMs && - "function" === typeof startTimeMs.componentDidCatch && - (null === legacyErrorBoundariesThatAlreadyFailed || - !legacyErrorBoundariesThatAlreadyFailed.has(startTimeMs))))) + (root = sourceFiber.type), + (returnFiber = sourceFiber.stateNode), + 0 === (sourceFiber.effectTag & 64) && + ("function" === typeof root.getDerivedStateFromError || + (null !== returnFiber && + "function" === typeof returnFiber.componentDidCatch && + !isAlreadyFailedLegacyErrorBoundary$$1(returnFiber)))) ) { - root.effectTag |= 2048; - root.expirationTime = renderExpirationTime; + sourceFiber.effectTag |= 2048; + sourceFiber.expirationTime = renderExpirationTime; renderExpirationTime = createClassErrorUpdate( - root, + sourceFiber, thenable, renderExpirationTime ); - enqueueCapturedUpdate(root, renderExpirationTime); + enqueueCapturedUpdate(sourceFiber, renderExpirationTime); return; } } - root = root.return; - } while (null !== root); + sourceFiber = sourceFiber.return; + } while (null !== sourceFiber); } function unwindWork(workInProgress) { switch (workInProgress.tag) { @@ -5837,17 +5817,15 @@ function unwindWork(workInProgress) { workInProgress) : null; case 3: - return ( - popHostContainer(workInProgress), - popTopLevelContextObject(workInProgress), - (effectTag = workInProgress.effectTag), - invariant( - 0 === (effectTag & 64), + popHostContainer(workInProgress); + popTopLevelContextObject(workInProgress); + effectTag = workInProgress.effectTag; + if (0 !== (effectTag & 64)) + throw ReactError( "The root failed to unmount after an error. This is likely a bug in React. Please file an issue." - ), - (workInProgress.effectTag = (effectTag & -2049) | 64), - workInProgress - ); + ); + workInProgress.effectTag = (effectTag & -2049) | 64; + return workInProgress; case 5: return popHostContext(workInProgress), null; case 13: @@ -5858,26 +5836,40 @@ function unwindWork(workInProgress) { workInProgress) : null ); + case 18: + return null; case 4: return popHostContainer(workInProgress), null; case 10: return popProvider(workInProgress), null; + case 19: + case 20: + return null; default: return null; } } -var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher, +var scheduleCallback$1 = Scheduler.unstable_scheduleCallback, + cancelCallback$1 = Scheduler.unstable_cancelCallback, + shouldYield$1 = Scheduler.unstable_shouldYield, + now$1 = Scheduler.unstable_now, + getCurrentPriorityLevel$1 = Scheduler.unstable_getCurrentPriorityLevel, + NormalPriority$1 = Scheduler.unstable_NormalPriority, + ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher, ReactCurrentOwner$2 = ReactSharedInternals.ReactCurrentOwner; -invariant( - null != tracing.__interactionsRef && - null != tracing.__interactionsRef.current, - "It is not supported to run the profiling version of a renderer (for example, `react-dom/profiling`) without also replacing the `scheduler/tracing` module with `scheduler/tracing-profiling`. Your bundler might have a setting for aliasing both modules. Learn more at http://fb.me/react-profiling" -); +if ( + null == tracing.__interactionsRef || + null == tracing.__interactionsRef.current +) + throw ReactError( + "It is not supported to run the profiling version of a renderer (for example, `react-dom/profiling`) without also replacing the `scheduler/tracing` module with `scheduler/tracing-profiling`. Your bundler might have a setting for aliasing both modules. Learn more at http://fb.me/react-profiling" + ); var isWorking = !1, nextUnitOfWork = null, nextRoot = null, nextRenderExpirationTime = 0, - nextLatestAbsoluteTimeoutMs = -1, + mostRecentEventTime = 1073741823, + nextRenderDidSuspend = !1, nextRenderDidError = !1, nextEffect = null, isCommitting$1 = !1, @@ -5918,8 +5910,8 @@ function resetStack() { } nextRoot = null; nextRenderExpirationTime = 0; - nextLatestAbsoluteTimeoutMs = -1; - nextRenderDidError = !1; + mostRecentEventTime = 1073741823; + nextRenderDidError = nextRenderDidSuspend = !1; nextUnitOfWork = null; } function commitAllHostEffects() { @@ -5964,48 +5956,6 @@ function commitAllHostEffects() { nextEffect = nextEffect.nextEffect; } } -function commitBeforeMutationLifecycles() { - for (; null !== nextEffect; ) { - if (nextEffect.effectTag & 256) - a: { - var current$$1 = nextEffect.alternate, - finishedWork = nextEffect; - switch (finishedWork.tag) { - case 0: - case 11: - case 15: - commitHookEffectList(UnmountSnapshot, NoEffect$1, finishedWork); - break a; - case 1: - if (finishedWork.effectTag & 256 && null !== current$$1) { - var prevProps = current$$1.memoizedProps, - prevState = current$$1.memoizedState; - current$$1 = finishedWork.stateNode; - finishedWork = current$$1.getSnapshotBeforeUpdate( - finishedWork.elementType === finishedWork.type - ? prevProps - : resolveDefaultProps(finishedWork.type, prevProps), - prevState - ); - current$$1.__reactInternalSnapshotBeforeUpdate = finishedWork; - } - break a; - case 3: - case 5: - case 6: - case 4: - case 17: - break a; - default: - invariant( - !1, - "This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue." - ); - } - } - nextEffect = nextEffect.nextEffect; - } -} function commitAllLifeCycles( finishedRoot$jscomp$0, committedExpirationTime$jscomp$0 @@ -6021,7 +5971,7 @@ function commitAllLifeCycles( case 0: case 11: case 15: - commitHookEffectList(UnmountLayout, MountLayout, finishedWork); + commitHookEffectList(16, 32, finishedWork); break; case 1: finishedRoot = finishedWork.stateNode; @@ -6089,12 +6039,11 @@ function commitAllLifeCycles( ); break; case 13: - break; case 17: + case 20: break; default: - invariant( - !1, + throw ReactError( "This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue." ); } @@ -6120,38 +6069,44 @@ function commitPassiveEffects(root, firstEffect) { error = void 0; try { var finishedWork = firstEffect; - commitHookEffectList(UnmountPassive, NoEffect$1, finishedWork); - commitHookEffectList(NoEffect$1, MountPassive, finishedWork); + commitHookEffectList(128, 0, finishedWork); + commitHookEffectList(0, 64, finishedWork); } catch (e) { (didError = !0), (error = e); } - didError && captureCommitPhaseError(firstEffect, error); + didError && captureCommitPhaseError$1(firstEffect, error); } firstEffect = firstEffect.nextEffect; } while (null !== firstEffect); isRendering = previousIsRendering; previousIsRendering = root.expirationTime; 0 !== previousIsRendering && requestWork(root, previousIsRendering); + isBatchingUpdates || isRendering || performWork(1073741823); } -function flushPassiveEffects() { - if (null !== passiveEffectCallbackHandle) { - var callbackID = passiveEffectCallbackHandle; - scheduledCallback = null; - clearTimeout(callbackID); - } +function isAlreadyFailedLegacyErrorBoundary$1(instance) { + return ( + null !== legacyErrorBoundariesThatAlreadyFailed && + legacyErrorBoundariesThatAlreadyFailed.has(instance) + ); +} +function flushPassiveEffects$1() { + var didFlushEffects = null !== passiveEffectCallback; + null !== passiveEffectCallbackHandle && + cancelCallback$1(passiveEffectCallbackHandle); null !== passiveEffectCallback && passiveEffectCallback(); + return didFlushEffects; } function commitRoot(root, finishedWork) { isCommitting$1 = isWorking = !0; - invariant( - root.current !== finishedWork, - "Cannot commit the same tree as before. This is probably a bug related to the return field. This error is likely caused by a bug in React. Please file an issue." - ); + if (root.current === finishedWork) + throw ReactError( + "Cannot commit the same tree as before. This is probably a bug related to the return field. This error is likely caused by a bug in React. Please file an issue." + ); var committedExpirationTime = root.pendingCommitExpirationTime; - invariant( - 0 !== committedExpirationTime, - "Cannot commit an incomplete root. This error is likely caused by a bug in React. Please file an issue." - ); + if (0 === committedExpirationTime) + throw ReactError( + "Cannot commit an incomplete root. This error is likely caused by a bug in React. Please file an issue." + ); root.pendingCommitExpirationTime = 0; var updateExpirationTimeBeforeCommit = finishedWork.expirationTime, childExpirationTimeBeforeCommit = finishedWork.childExpirationTime; @@ -6176,19 +6131,23 @@ function commitRoot(root, finishedWork) { var didError = !1, error$jscomp$0 = void 0; try { - commitBeforeMutationLifecycles(); + for (; null !== nextEffect; ) + nextEffect.effectTag & 256 && + commitBeforeMutationLifeCycles(nextEffect.alternate, nextEffect), + (nextEffect = nextEffect.nextEffect); } catch (e) { (didError = !0), (error$jscomp$0 = e); } - didError && - (invariant( - null !== nextEffect, - "Should have next effect. This error is likely caused by a bug in React. Please file an issue." - ), - captureCommitPhaseError(nextEffect, error$jscomp$0), - null !== nextEffect && (nextEffect = nextEffect.nextEffect)); + if (didError) { + if (null === nextEffect) + throw ReactError( + "Should have next effect. This error is likely caused by a bug in React. Please file an issue." + ); + captureCommitPhaseError$1(nextEffect, error$jscomp$0); + null !== nextEffect && (nextEffect = nextEffect.nextEffect); + } } - commitTime = now$1(); + commitTime = now$2(); for (nextEffect = childExpirationTimeBeforeCommit; null !== nextEffect; ) { didError = !1; error$jscomp$0 = void 0; @@ -6197,13 +6156,14 @@ function commitRoot(root, finishedWork) { } catch (e) { (didError = !0), (error$jscomp$0 = e); } - didError && - (invariant( - null !== nextEffect, - "Should have next effect. This error is likely caused by a bug in React. Please file an issue." - ), - captureCommitPhaseError(nextEffect, error$jscomp$0), - null !== nextEffect && (nextEffect = nextEffect.nextEffect)); + if (didError) { + if (null === nextEffect) + throw ReactError( + "Should have next effect. This error is likely caused by a bug in React. Please file an issue." + ); + captureCommitPhaseError$1(nextEffect, error$jscomp$0); + null !== nextEffect && (nextEffect = nextEffect.nextEffect); + } } root.current = finishedWork; for (nextEffect = childExpirationTimeBeforeCommit; null !== nextEffect; ) { @@ -6214,32 +6174,30 @@ function commitRoot(root, finishedWork) { } catch (e) { (didError = !0), (error$jscomp$0 = e); } - didError && - (invariant( - null !== nextEffect, - "Should have next effect. This error is likely caused by a bug in React. Please file an issue." - ), - captureCommitPhaseError(nextEffect, error$jscomp$0), - null !== nextEffect && (nextEffect = nextEffect.nextEffect)); + if (didError) { + if (null === nextEffect) + throw ReactError( + "Should have next effect. This error is likely caused by a bug in React. Please file an issue." + ); + captureCommitPhaseError$1(nextEffect, error$jscomp$0); + null !== nextEffect && (nextEffect = nextEffect.nextEffect); + } } - if ( - null !== childExpirationTimeBeforeCommit && - null !== rootWithPendingPassiveEffects - ) { - var callback = commitPassiveEffects.bind( + null !== childExpirationTimeBeforeCommit && + null !== rootWithPendingPassiveEffects && + ((childExpirationTimeBeforeCommit = commitPassiveEffects.bind( null, root, childExpirationTimeBeforeCommit - ); - callback = tracing.unstable_wrap(callback); - passiveEffectCallbackHandle = scheduler.unstable_runWithPriority( - scheduler.unstable_NormalPriority, - function() { - return scheduleDeferredCallback$1(callback); - } - ); - passiveEffectCallback = callback; - } + )), + (childExpirationTimeBeforeCommit = tracing.unstable_wrap( + childExpirationTimeBeforeCommit + )), + (passiveEffectCallbackHandle = scheduleCallback$1( + NormalPriority$1, + childExpirationTimeBeforeCommit + )), + (passiveEffectCallback = childExpirationTimeBeforeCommit)); isWorking = isCommitting$1 = !1; "function" === typeof onCommitFiberRoot && onCommitFiberRoot(finishedWork.stateNode); @@ -6295,8 +6253,8 @@ function completeUnitOfWork(workInProgress) { nextUnitOfWork = workInProgress; if (workInProgress.mode & 4) { var fiber = workInProgress; - profilerStartTime = now$1(); - 0 > fiber.actualStartTime && (fiber.actualStartTime = now$1()); + profilerStartTime = now$2(); + 0 > fiber.actualStartTime && (fiber.actualStartTime = now$2()); } a: { var current = current$$1; @@ -6342,13 +6300,12 @@ function completeUnitOfWork(workInProgress) { current.ref !== current$$1.ref && (current$$1.effectTag |= 128); else if (fiber) { current = requiredContext(contextStackCursor$1.current); - var internalInstanceHandle = current$$1, - tag = allocateTag(), + var tag = allocateTag(), viewConfig = ReactNativeViewConfigRegistry.get(type); - invariant( - "RCTView" !== type || !current.isInAParentText, - "Nesting of within is not currently supported." - ); + if ("RCTView" === type && current.isInAParentText) + throw ReactError( + "Nesting of within is not currently supported." + ); var updatePayload = diffProperties( null, emptyObject, @@ -6362,7 +6319,7 @@ function completeUnitOfWork(workInProgress) { updatePayload ); viewConfig = new ReactNativeFiberHostComponent(tag, viewConfig); - instanceCache[tag] = internalInstanceHandle; + instanceCache[tag] = current$$1; instanceProps[tag] = fiber; appendAllChildren(viewConfig, current$$1, !1, !1); finalizeInitialChildren( @@ -6374,38 +6331,41 @@ function completeUnitOfWork(workInProgress) { ) && (current$$1.effectTag |= 4); current$$1.stateNode = viewConfig; null !== current$$1.ref && (current$$1.effectTag |= 128); - } else - invariant( - null !== current$$1.stateNode, + } else if (null === current$$1.stateNode) + throw ReactError( "We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue." ); break; case 6: - current && null != current$$1.stateNode - ? updateHostText$1( - current, - current$$1, - current.memoizedProps, - fiber - ) - : ("string" !== typeof fiber && - invariant( - null !== current$$1.stateNode, - "We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue." - ), - (current = requiredContext(rootInstanceStackCursor.current)), - (type = requiredContext(contextStackCursor$1.current)), - (renderExpirationTime = current$$1), - invariant( - type.isInAParentText, + if (current && null != current$$1.stateNode) + updateHostText$1( + current, + current$$1, + current.memoizedProps, + fiber + ); + else { + if ("string" !== typeof fiber && null === current$$1.stateNode) + throw ReactError( + "We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue." + ); + current = requiredContext(rootInstanceStackCursor.current); + if ( + !requiredContext(contextStackCursor$1.current).isInAParentText + ) + throw ReactError( "Text strings must be rendered within a component." - ), - (type = allocateTag()), - UIManager.createView(type, "RCTRawText", current, { - text: fiber - }), - (instanceCache[type] = current$$1), - (renderExpirationTime.stateNode = type)); + ); + renderExpirationTime = allocateTag(); + UIManager.createView( + renderExpirationTime, + "RCTRawText", + current, + { text: fiber } + ); + instanceCache[renderExpirationTime] = current$$1; + current$$1.stateNode = renderExpirationTime; + } break; case 11: break; @@ -6417,20 +6377,27 @@ function completeUnitOfWork(workInProgress) { break a; } fiber = null !== fiber; - renderExpirationTime = - null !== current && null !== current.memoizedState; + renderExpirationTime = !1; null !== current && - !fiber && - renderExpirationTime && - ((type = current.child.sibling), - null !== type && - ((current = current$$1.firstEffect), - null !== current - ? ((current$$1.firstEffect = type), - (type.nextEffect = current)) - : ((current$$1.firstEffect = current$$1.lastEffect = type), - (type.nextEffect = null)), - (type.effectTag = 8))); + ((type = current.memoizedState), + (renderExpirationTime = null !== type), + fiber || + null === type || + ((type = type.fallbackExpirationTime), + type < mostRecentEventTime && (mostRecentEventTime = type), + (current = current.child.sibling), + null !== current && + ((type = current$$1.firstEffect), + null !== type + ? ((current$$1.firstEffect = current), + (current.nextEffect = type)) + : ((current$$1.firstEffect = current$$1.lastEffect = current), + (current.nextEffect = null)), + (current.effectTag = 8)))); + fiber && + !renderExpirationTime && + 0 !== (current$$1.mode & 1) && + (nextRenderDidSuspend = !0); if (fiber || renderExpirationTime) current$$1.effectTag |= 4; break; case 7: @@ -6453,9 +6420,14 @@ function completeUnitOfWork(workInProgress) { case 17: isContextProvider(current$$1.type) && popContext(current$$1); break; + case 18: + break; + case 19: + break; + case 20: + break; default: - invariant( - !1, + throw ReactError( "Unknown unit of work tag. This error is likely caused by a bug in React. Please file an issue." ); } @@ -6470,37 +6442,28 @@ function completeUnitOfWork(workInProgress) { ) { fiber = 0; if (current$$1.mode & 4) { - renderExpirationTime = current$$1.actualDuration; - type = current$$1.selfBaseDuration; - current = + current = current$$1.actualDuration; + renderExpirationTime = current$$1.selfBaseDuration; + type = null === current$$1.alternate || current$$1.child !== current$$1.alternate.child; - for ( - internalInstanceHandle = current$$1.child; - null !== internalInstanceHandle; - - ) - (tag = internalInstanceHandle.expirationTime), - (viewConfig = internalInstanceHandle.childExpirationTime), - tag > fiber && (fiber = tag), + for (tag = current$$1.child; null !== tag; ) + (viewConfig = tag.expirationTime), + (updatePayload = tag.childExpirationTime), viewConfig > fiber && (fiber = viewConfig), - current && - (renderExpirationTime += internalInstanceHandle.actualDuration), - (type += internalInstanceHandle.treeBaseDuration), - (internalInstanceHandle = internalInstanceHandle.sibling); - current$$1.actualDuration = renderExpirationTime; - current$$1.treeBaseDuration = type; + updatePayload > fiber && (fiber = updatePayload), + type && (current += tag.actualDuration), + (renderExpirationTime += tag.treeBaseDuration), + (tag = tag.sibling); + current$$1.actualDuration = current; + current$$1.treeBaseDuration = renderExpirationTime; } else - for ( - renderExpirationTime = current$$1.child; - null !== renderExpirationTime; - - ) - (type = renderExpirationTime.expirationTime), - (current = renderExpirationTime.childExpirationTime), + for (current = current$$1.child; null !== current; ) + (renderExpirationTime = current.expirationTime), + (type = current.childExpirationTime), + renderExpirationTime > fiber && (fiber = renderExpirationTime), type > fiber && (fiber = type), - current > fiber && (fiber = current), - (renderExpirationTime = renderExpirationTime.sibling); + (current = current.sibling); current$$1.childExpirationTime = fiber; } if (null !== nextUnitOfWork) return nextUnitOfWork; @@ -6541,9 +6504,9 @@ function completeUnitOfWork(workInProgress) { function performUnitOfWork(workInProgress) { var current$$1 = workInProgress.alternate; workInProgress.mode & 4 && - ((profilerStartTime = now$1()), + ((profilerStartTime = now$2()), 0 > workInProgress.actualStartTime && - (workInProgress.actualStartTime = now$1())); + (workInProgress.actualStartTime = now$2())); current$$1 = beginWork(current$$1, workInProgress, nextRenderExpirationTime); workInProgress.memoizedProps = workInProgress.pendingProps; workInProgress.mode & 4 && @@ -6553,11 +6516,11 @@ function performUnitOfWork(workInProgress) { return current$$1; } function renderRoot(root, isYieldy) { - invariant( - !isWorking, - "renderRoot was called recursively. This error is likely caused by a bug in React. Please file an issue." - ); - flushPassiveEffects(); + if (isWorking) + throw ReactError( + "renderRoot was called recursively. This error is likely caused by a bug in React. Please file an issue." + ); + flushPassiveEffects$1(); isWorking = !0; var previousDispatcher = ReactCurrentDispatcher.current; ReactCurrentDispatcher.current = ContextOnlyDispatcher; @@ -6607,7 +6570,7 @@ function renderRoot(root, isYieldy) { do { try { if (isYieldy) - for (; null !== nextUnitOfWork && !shouldYieldToRenderer(); ) + for (; null !== nextUnitOfWork && !shouldYield$1(); ) nextUnitOfWork = performUnitOfWork(nextUnitOfWork); else for (; null !== nextUnitOfWork; ) @@ -6618,17 +6581,18 @@ function renderRoot(root, isYieldy) { resetHooks(), null === nextUnitOfWork) ) - (threadID = !0), onUncaughtError(thrownValue); + (threadID = !0), onUncaughtError$1(thrownValue); else { nextUnitOfWork.mode & 4 && stopProfilerTimerIfRunningAndRecordDelta(nextUnitOfWork, !0); - invariant( - null !== nextUnitOfWork, - "Failed to replay rendering after an error. This is likely caused by a bug in React. Please file an issue with a reproducing case to help us find it." - ); + if (null === nextUnitOfWork) + throw ReactError( + "Failed to replay rendering after an error. This is likely caused by a bug in React. Please file an issue with a reproducing case to help us find it." + ); var sourceFiber = nextUnitOfWork, returnFiber = sourceFiber.return; - if (null === returnFiber) (threadID = !0), onUncaughtError(thrownValue); + if (null === returnFiber) + (threadID = !0), onUncaughtError$1(thrownValue); else { throwException( root, @@ -6653,10 +6617,10 @@ function renderRoot(root, isYieldy) { else if (null !== nextUnitOfWork) root.finishedWork = null; else { previousDispatcher = root.current.alternate; - invariant( - null !== previousDispatcher, - "Finished root should have a work-in-progress. This error is likely caused by a bug in React. Please file an issue." - ); + if (null === previousDispatcher) + throw ReactError( + "Finished root should have a work-in-progress. This error is likely caused by a bug in React. Please file an issue." + ); nextRoot = null; if (nextRenderDidError) { if (hasLowerPriorityWork(root, expirationTime)) { @@ -6678,16 +6642,11 @@ function renderRoot(root, isYieldy) { return; } } - isYieldy && -1 !== nextLatestAbsoluteTimeoutMs + isYieldy && nextRenderDidSuspend && 1073741823 !== mostRecentEventTime ? (markSuspendedPriorityLevel(root, expirationTime), (isYieldy = - 10 * - (1073741822 - - findEarliestOutstandingPriorityLevel(root, expirationTime))), - isYieldy < nextLatestAbsoluteTimeoutMs && - (nextLatestAbsoluteTimeoutMs = isYieldy), - (isYieldy = 10 * (1073741822 - requestCurrentTime())), - (isYieldy = nextLatestAbsoluteTimeoutMs - isYieldy), + 10 * (1073741822 - mostRecentEventTime) - 5e3 + originalStartTimeMs), + (isYieldy = 150 - (now$1() - isYieldy)), onSuspend( root, previousDispatcher, @@ -6698,7 +6657,7 @@ function renderRoot(root, isYieldy) { : onComplete(root, previousDispatcher, expirationTime); } } -function captureCommitPhaseError(sourceFiber, value) { +function captureCommitPhaseError$1(sourceFiber, value) { for (var fiber = sourceFiber.return; null !== fiber; ) { switch (fiber.tag) { case 1: @@ -6706,13 +6665,12 @@ function captureCommitPhaseError(sourceFiber, value) { if ( "function" === typeof fiber.type.getDerivedStateFromError || ("function" === typeof instance.componentDidCatch && - (null === legacyErrorBoundariesThatAlreadyFailed || - !legacyErrorBoundariesThatAlreadyFailed.has(instance))) + !isAlreadyFailedLegacyErrorBoundary$1(instance)) ) { sourceFiber = createCapturedValue(value, sourceFiber); sourceFiber = createClassErrorUpdate(fiber, sourceFiber, 1073741823); enqueueUpdate(fiber, sourceFiber); - scheduleWork(fiber, 1073741823); + scheduleWork$1(fiber, 1073741823); return; } break; @@ -6720,7 +6678,7 @@ function captureCommitPhaseError(sourceFiber, value) { sourceFiber = createCapturedValue(value, sourceFiber); sourceFiber = createRootErrorUpdate(fiber, sourceFiber, 1073741823); enqueueUpdate(fiber, sourceFiber); - scheduleWork(fiber, 1073741823); + scheduleWork$1(fiber, 1073741823); return; } fiber = fiber.return; @@ -6729,75 +6687,25 @@ function captureCommitPhaseError(sourceFiber, value) { ((fiber = createCapturedValue(value, sourceFiber)), (fiber = createRootErrorUpdate(sourceFiber, fiber, 1073741823)), enqueueUpdate(sourceFiber, fiber), - scheduleWork(sourceFiber, 1073741823)); -} -function computeExpirationForFiber(currentTime, fiber) { - var priorityLevel = scheduler.unstable_getCurrentPriorityLevel(), - expirationTime = void 0; - if (0 === (fiber.mode & 1)) expirationTime = 1073741823; - else if (isWorking && !isCommitting$1) - expirationTime = nextRenderExpirationTime; - else { - switch (priorityLevel) { - case scheduler.unstable_ImmediatePriority: - expirationTime = 1073741823; - break; - case scheduler.unstable_UserBlockingPriority: - expirationTime = - 1073741822 - 10 * ((((1073741822 - currentTime + 15) / 10) | 0) + 1); - break; - case scheduler.unstable_NormalPriority: - expirationTime = - 1073741822 - 25 * ((((1073741822 - currentTime + 500) / 25) | 0) + 1); - break; - case scheduler.unstable_LowPriority: - case scheduler.unstable_IdlePriority: - expirationTime = 1; - break; - default: - invariant( - !1, - "Unknown priority level. This error is likely caused by a bug in React. Please file an issue." - ); - } - null !== nextRoot && - expirationTime === nextRenderExpirationTime && - --expirationTime; - } - priorityLevel === scheduler.unstable_UserBlockingPriority && + scheduleWork$1(sourceFiber, 1073741823)); +} +function computeExpirationForFiber$1(currentTime, fiber) { + isWorking + ? (currentTime = isCommitting$1 ? 1073741823 : nextRenderExpirationTime) + : fiber.mode & 1 + ? ((currentTime = isBatchingInteractiveUpdates + ? 1073741822 - 10 * ((((1073741822 - currentTime + 15) / 10) | 0) + 1) + : 1073741822 - + 25 * ((((1073741822 - currentTime + 500) / 25) | 0) + 1)), + null !== nextRoot && + currentTime === nextRenderExpirationTime && + --currentTime) + : (currentTime = 1073741823); + isBatchingInteractiveUpdates && (0 === lowestPriorityPendingInteractiveExpirationTime || - expirationTime < lowestPriorityPendingInteractiveExpirationTime) && - (lowestPriorityPendingInteractiveExpirationTime = expirationTime); - return expirationTime; -} -function pingSuspendedRoot(root, thenable, pingTime) { - var pingCache = root.pingCache; - null !== pingCache && pingCache.delete(thenable); - if (null !== nextRoot && nextRenderExpirationTime === pingTime) - nextRoot = null; - else if ( - ((thenable = root.earliestSuspendedTime), - (pingCache = root.latestSuspendedTime), - 0 !== thenable && pingTime <= thenable && pingTime >= pingCache) - ) { - root.didError = !1; - thenable = root.latestPingedTime; - if (0 === thenable || thenable > pingTime) root.latestPingedTime = pingTime; - findNextExpirationTimeToWorkOn(pingTime, root); - pingTime = root.expirationTime; - 0 !== pingTime && requestWork(root, pingTime); - } -} -function retryTimedOutBoundary(boundaryFiber, thenable) { - var retryCache = boundaryFiber.stateNode; - null !== retryCache && retryCache.delete(thenable); - thenable = requestCurrentTime(); - thenable = computeExpirationForFiber(thenable, boundaryFiber); - boundaryFiber = scheduleWorkToRoot(boundaryFiber, thenable); - null !== boundaryFiber && - (markPendingPriorityLevel(boundaryFiber, thenable), - (thenable = boundaryFiber.expirationTime), - 0 !== thenable && requestWork(boundaryFiber, thenable)); + currentTime < lowestPriorityPendingInteractiveExpirationTime) && + (lowestPriorityPendingInteractiveExpirationTime = currentTime); + return currentTime; } function scheduleWorkToRoot(fiber, expirationTime) { fiber.expirationTime < expirationTime && @@ -6847,9 +6755,10 @@ function scheduleWorkToRoot(fiber, expirationTime) { } return root; } -function scheduleWork(fiber, expirationTime) { +function scheduleWork$1(fiber, expirationTime) { fiber = scheduleWorkToRoot(fiber, expirationTime); - null !== fiber && + if ( + null !== fiber && (!isWorking && 0 !== nextRenderExpirationTime && expirationTime > nextRenderExpirationTime && @@ -6857,12 +6766,12 @@ function scheduleWork(fiber, expirationTime) { markPendingPriorityLevel(fiber, expirationTime), (isWorking && !isCommitting$1 && nextRoot === fiber) || requestWork(fiber, fiber.expirationTime), - nestedUpdateCount > NESTED_UPDATE_LIMIT && - ((nestedUpdateCount = 0), - invariant( - !1, - "Maximum update depth exceeded. This can happen when a component repeatedly calls setState inside componentWillUpdate or componentDidUpdate. React limits the number of nested updates to prevent infinite loops." - ))); + nestedUpdateCount > NESTED_UPDATE_LIMIT) + ) + throw ((nestedUpdateCount = 0), + ReactError( + "Maximum update depth exceeded. This can happen when a component repeatedly calls setState inside componentWillUpdate or componentDidUpdate. React limits the number of nested updates to prevent infinite loops." + )); } var firstScheduledRoot = null, lastScheduledRoot = null, @@ -6876,6 +6785,7 @@ var firstScheduledRoot = null, unhandledError = null, isBatchingUpdates = !1, isUnbatchingUpdates = !1, + isBatchingInteractiveUpdates = !1, completedBatches = null, originalStartTimeMs = now$1(), currentRendererTime = 1073741822 - ((originalStartTimeMs / 10) | 0), @@ -6890,13 +6800,14 @@ function recomputeCurrentRendererTime() { function scheduleCallbackWithExpirationTime(root, expirationTime) { if (0 !== callbackExpirationTime) { if (expirationTime < callbackExpirationTime) return; - null !== callbackID && - ((root = callbackID), (scheduledCallback = null), clearTimeout(root)); + null !== callbackID && cancelCallback$1(callbackID); } callbackExpirationTime = expirationTime; root = now$1() - originalStartTimeMs; - callbackID = scheduleDeferredCallback$1(performAsyncWork, { - timeout: 10 * (1073741822 - expirationTime) - root + expirationTime = 10 * (1073741822 - expirationTime) - root; + root = getCurrentPriorityLevel$1(); + callbackID = scheduleCallback$1(root, performAsyncWork, { + timeout: expirationTime }); } function onComplete(root, finishedWork, expirationTime) { @@ -6911,7 +6822,7 @@ function onSuspend( msUntilTimeout ) { root.expirationTime = rootExpirationTime; - 0 !== msUntilTimeout || shouldYieldToRenderer() + 0 !== msUntilTimeout || shouldYield$1() ? 0 < msUntilTimeout && (root.timeoutHandle = scheduleTimeout( onTimeout.bind(null, root, finishedWork, suspendedExpirationTime), @@ -6925,20 +6836,20 @@ function onTimeout(root, finishedWork, suspendedExpirationTime) { root.finishedWork = finishedWork; recomputeCurrentRendererTime(); currentSchedulerTime = currentRendererTime; - invariant( - !isRendering, - "work.commit(): Cannot commit while already rendering. This likely means you attempted to commit from inside a lifecycle method." - ); + if (isRendering) + throw ReactError( + "work.commit(): Cannot commit while already rendering. This likely means you attempted to commit from inside a lifecycle method." + ); nextFlushedRoot = root; nextFlushedExpirationTime = suspendedExpirationTime; performWorkOnRoot(root, suspendedExpirationTime, !1); - performWork(1073741823, !1); + performWork(1073741823); } function onCommit(root, expirationTime) { root.expirationTime = expirationTime; root.finishedWork = null; } -function requestCurrentTime() { +function requestCurrentTime$1() { if (isRendering) return currentSchedulerTime; findHighestPriorityRoot(); if (0 === nextFlushedExpirationTime || 1 === nextFlushedExpirationTime) @@ -6963,7 +6874,7 @@ function requestWork(root, expirationTime) { (nextFlushedExpirationTime = 1073741823), performWorkOnRoot(root, 1073741823, !1)) : 1073741823 === expirationTime - ? performWork(1073741823, !1) + ? performWork(1073741823) : scheduleCallbackWithExpirationTime(root, expirationTime)); } function findHighestPriorityRoot() { @@ -6977,10 +6888,10 @@ function findHighestPriorityRoot() { ) { var remainingExpirationTime = root.expirationTime; if (0 === remainingExpirationTime) { - invariant( - null !== previousScheduledRoot && null !== lastScheduledRoot, - "Should have a previous and last root. This error is likely caused by a bug in React. Please file an issue." - ); + if (null === previousScheduledRoot || null === lastScheduledRoot) + throw ReactError( + "Should have a previous and last root. This error is likely caused by a bug in React. Please file an issue." + ); if (root === root.nextScheduledRoot) { firstScheduledRoot = lastScheduledRoot = root.nextScheduledRoot = null; break; @@ -7011,75 +6922,69 @@ function findHighestPriorityRoot() { nextFlushedRoot = highestPriorityRoot; nextFlushedExpirationTime = highestPriorityWork; } -var didYield = !1; -function shouldYieldToRenderer() { - return didYield ? !0 : frameDeadline <= now$1() ? (didYield = !0) : !1; -} -function performAsyncWork() { - try { - if (!shouldYieldToRenderer() && null !== firstScheduledRoot) { - recomputeCurrentRendererTime(); - var root = firstScheduledRoot; - do { - var expirationTime = root.expirationTime; - 0 !== expirationTime && - currentRendererTime <= expirationTime && - (root.nextExpirationTimeToWorkOn = currentRendererTime); - root = root.nextScheduledRoot; - } while (root !== firstScheduledRoot); - } - performWork(0, !0); - } finally { - didYield = !1; +function performAsyncWork(didTimeout) { + if (didTimeout && null !== firstScheduledRoot) { + recomputeCurrentRendererTime(); + didTimeout = firstScheduledRoot; + do { + var expirationTime = didTimeout.expirationTime; + 0 !== expirationTime && + currentRendererTime <= expirationTime && + (didTimeout.nextExpirationTimeToWorkOn = currentRendererTime); + didTimeout = didTimeout.nextScheduledRoot; + } while (didTimeout !== firstScheduledRoot); } -} -function performWork(minExpirationTime, isYieldy) { findHighestPriorityRoot(); - if (isYieldy) - for ( - recomputeCurrentRendererTime(), - currentSchedulerTime = currentRendererTime; - null !== nextFlushedRoot && - 0 !== nextFlushedExpirationTime && - minExpirationTime <= nextFlushedExpirationTime && - !(didYield && currentRendererTime > nextFlushedExpirationTime); + recomputeCurrentRendererTime(); + for ( + currentSchedulerTime = currentRendererTime; + null !== nextFlushedRoot && + 0 !== nextFlushedExpirationTime && + !(shouldYield$1() && currentRendererTime > nextFlushedExpirationTime); - ) - performWorkOnRoot( - nextFlushedRoot, - nextFlushedExpirationTime, - currentRendererTime > nextFlushedExpirationTime - ), - findHighestPriorityRoot(), - recomputeCurrentRendererTime(), - (currentSchedulerTime = currentRendererTime); - else - for ( - ; - null !== nextFlushedRoot && - 0 !== nextFlushedExpirationTime && - minExpirationTime <= nextFlushedExpirationTime; + ) + performWorkOnRoot( + nextFlushedRoot, + nextFlushedExpirationTime, + currentRendererTime > nextFlushedExpirationTime + ), + findHighestPriorityRoot(), + recomputeCurrentRendererTime(), + (currentSchedulerTime = currentRendererTime); + callbackExpirationTime = 0; + callbackID = null; + 0 !== nextFlushedExpirationTime && + scheduleCallbackWithExpirationTime( + nextFlushedRoot, + nextFlushedExpirationTime + ); + finishRendering(); +} +function performWork(minExpirationTime) { + for ( + findHighestPriorityRoot(); + null !== nextFlushedRoot && + 0 !== nextFlushedExpirationTime && + minExpirationTime <= nextFlushedExpirationTime; - ) - performWorkOnRoot(nextFlushedRoot, nextFlushedExpirationTime, !1), - findHighestPriorityRoot(); - isYieldy && ((callbackExpirationTime = 0), (callbackID = null)); + ) + performWorkOnRoot(nextFlushedRoot, nextFlushedExpirationTime, !1), + findHighestPriorityRoot(); 0 !== nextFlushedExpirationTime && scheduleCallbackWithExpirationTime( nextFlushedRoot, nextFlushedExpirationTime ); + finishRendering(); +} +function finishRendering() { nestedUpdateCount = 0; lastCommittedRootDuringThisBatch = null; - if (null !== completedBatches) - for ( - minExpirationTime = completedBatches, - completedBatches = null, - isYieldy = 0; - isYieldy < minExpirationTime.length; - isYieldy++ - ) { - var batch = minExpirationTime[isYieldy]; + if (null !== completedBatches) { + var batches = completedBatches; + completedBatches = null; + for (var i = 0; i < batches.length; i++) { + var batch = batches[i]; try { batch._onComplete(); } catch (error) { @@ -7087,17 +6992,18 @@ function performWork(minExpirationTime, isYieldy) { ((hasUnhandledError = !0), (unhandledError = error)); } } + } if (hasUnhandledError) - throw ((minExpirationTime = unhandledError), + throw ((batches = unhandledError), (unhandledError = null), (hasUnhandledError = !1), - minExpirationTime); + batches); } function performWorkOnRoot(root, expirationTime, isYieldy) { - invariant( - !isRendering, - "performWorkOnRoot was called recursively. This error is likely caused by a bug in React. Please file an issue." - ); + if (isRendering) + throw ReactError( + "performWorkOnRoot was called recursively. This error is likely caused by a bug in React. Please file an issue." + ); isRendering = !0; if (isYieldy) { var _finishedWork = root.finishedWork; @@ -7110,7 +7016,7 @@ function performWorkOnRoot(root, expirationTime, isYieldy) { renderRoot(root, isYieldy), (_finishedWork = root.finishedWork), null !== _finishedWork && - (shouldYieldToRenderer() + (shouldYield$1() ? (root.finishedWork = _finishedWork) : completeRoot(root, _finishedWork, expirationTime))); } else @@ -7145,46 +7051,81 @@ function completeRoot(root, finishedWork, expirationTime) { root === lastCommittedRootDuringThisBatch ? nestedUpdateCount++ : ((lastCommittedRootDuringThisBatch = root), (nestedUpdateCount = 0)); - scheduler.unstable_runWithPriority( - scheduler.unstable_ImmediatePriority, - function() { - commitRoot(root, finishedWork); - } - ); + commitRoot(root, finishedWork); } -function onUncaughtError(error) { - invariant( - null !== nextFlushedRoot, - "Should be working on a root. This error is likely caused by a bug in React. Please file an issue." - ); +function onUncaughtError$1(error) { + if (null === nextFlushedRoot) + throw ReactError( + "Should be working on a root. This error is likely caused by a bug in React. Please file an issue." + ); nextFlushedRoot.expirationTime = 0; hasUnhandledError || ((hasUnhandledError = !0), (unhandledError = error)); } +Scheduler_now(); +var requestCurrentTime$$1 = requestCurrentTime$1, + computeExpirationForFiber$$1 = computeExpirationForFiber$1, + captureCommitPhaseError$$1 = captureCommitPhaseError$1, + onUncaughtError$$1 = onUncaughtError$1; +function pingSuspendedRoot$$1(root, thenable, pingTime) { + var pingCache = root.pingCache; + null !== pingCache && pingCache.delete(thenable); + if (null !== nextRoot && nextRenderExpirationTime === pingTime) + nextRoot = null; + else if ( + ((thenable = root.earliestSuspendedTime), + (pingCache = root.latestSuspendedTime), + 0 !== thenable && pingTime <= thenable && pingTime >= pingCache) + ) { + root.didError = !1; + thenable = root.latestPingedTime; + if (0 === thenable || thenable > pingTime) root.latestPingedTime = pingTime; + findNextExpirationTimeToWorkOn(pingTime, root); + pingTime = root.expirationTime; + 0 !== pingTime && requestWork(root, pingTime); + } +} +function resolveRetryThenable$$1(boundaryFiber, thenable) { + var retryCache = boundaryFiber.stateNode; + null !== retryCache && retryCache.delete(thenable); + thenable = requestCurrentTime$1(); + thenable = computeExpirationForFiber$1(thenable, boundaryFiber); + boundaryFiber = scheduleWorkToRoot(boundaryFiber, thenable); + null !== boundaryFiber && + (markPendingPriorityLevel(boundaryFiber, thenable), + (thenable = boundaryFiber.expirationTime), + 0 !== thenable && requestWork(boundaryFiber, thenable)); +} +var isAlreadyFailedLegacyErrorBoundary$$1 = isAlreadyFailedLegacyErrorBoundary$1, + scheduleWork$$1 = scheduleWork$1, + flushPassiveEffects$$1 = flushPassiveEffects$1; function findHostInstance(component) { var fiber = component._reactInternalFiber; - void 0 === fiber && - ("function" === typeof component.render - ? invariant(!1, "Unable to find node on an unmounted component.") - : invariant( - !1, - "Argument appears to not be a ReactComponent. Keys: %s", - Object.keys(component) - )); + if (void 0 === fiber) { + if ("function" === typeof component.render) + throw ReactError("Unable to find node on an unmounted component."); + throw ReactError( + "Argument appears to not be a ReactComponent. Keys: " + + Object.keys(component) + ); + } component = findCurrentHostFiber(fiber); return null === component ? null : component.stateNode; } function updateContainer(element, container, parentComponent, callback) { var current$$1 = container.current, - currentTime = requestCurrentTime(); - current$$1 = computeExpirationForFiber(currentTime, current$$1); + currentTime = requestCurrentTime$$1(); + current$$1 = computeExpirationForFiber$$1(currentTime, current$$1); currentTime = container.current; a: if (parentComponent) { parentComponent = parentComponent._reactInternalFiber; b: { - invariant( - 2 === isFiberMountedImpl(parentComponent) && 1 === parentComponent.tag, - "Expected subtree parent to be a mounted class component. This error is likely caused by a bug in React. Please file an issue." - ); + if ( + 2 !== isFiberMountedImpl(parentComponent) || + 1 !== parentComponent.tag + ) + throw ReactError( + "Expected subtree parent to be a mounted class component. This error is likely caused by a bug in React. Please file an issue." + ); var parentContext = parentComponent; do { switch (parentContext.tag) { @@ -7201,11 +7142,9 @@ function updateContainer(element, container, parentComponent, callback) { } parentContext = parentContext.return; } while (null !== parentContext); - invariant( - !1, + throw ReactError( "Found unexpected detached subtree parent. This error is likely caused by a bug in React. Please file an issue." ); - parentContext = void 0; } if (1 === parentComponent.tag) { var Component = parentComponent.type; @@ -7228,9 +7167,9 @@ function updateContainer(element, container, parentComponent, callback) { callback.payload = { element: element }; container = void 0 === container ? null : container; null !== container && (callback.callback = container); - flushPassiveEffects(); + flushPassiveEffects$$1(); enqueueUpdate(currentTime, callback); - scheduleWork(currentTime, current$$1); + scheduleWork$$1(currentTime, current$$1); return current$$1; } function createPortal(children, containerInfo, implementation) { @@ -7265,7 +7204,9 @@ function _inherits(subClass, superClass) { } var getInspectorDataForViewTag = void 0; getInspectorDataForViewTag = function() { - invariant(!1, "getInspectorDataForViewTag() is not available in production"); + throw ReactError( + "getInspectorDataForViewTag() is not available in production" + ); }; function findNodeHandle(componentOrHandle) { if (null == componentOrHandle) return null; @@ -7288,13 +7229,13 @@ _batchedUpdatesImpl = function(fn, a) { } finally { (isBatchingUpdates = previousIsBatchingUpdates) || isRendering || - performWork(1073741823, !1); + performWork(1073741823); } }; _flushInteractiveUpdatesImpl = function() { isRendering || 0 === lowestPriorityPendingInteractiveExpirationTime || - (performWork(lowestPriorityPendingInteractiveExpirationTime, !1), + (performWork(lowestPriorityPendingInteractiveExpirationTime), (lowestPriorityPendingInteractiveExpirationTime = 0)); }; var roots = new Map(), @@ -7322,47 +7263,81 @@ var roots = new Map(), TextInputState.focusTextInput(findNodeHandle(this)); }; ReactNativeComponent.prototype.measure = function(callback) { - UIManager.measure( - findNodeHandle(this), - mountSafeCallback_NOT_REALLY_SAFE(this, callback) - ); + var maybeInstance = void 0; + try { + maybeInstance = findHostInstance(this); + } catch (error) {} + null != maybeInstance && + (maybeInstance.canonical + ? FabricUIManager.measure( + maybeInstance.node, + mountSafeCallback_NOT_REALLY_SAFE(this, callback) + ) + : UIManager.measure( + findNodeHandle(this), + mountSafeCallback_NOT_REALLY_SAFE(this, callback) + )); }; ReactNativeComponent.prototype.measureInWindow = function(callback) { - UIManager.measureInWindow( - findNodeHandle(this), - mountSafeCallback_NOT_REALLY_SAFE(this, callback) - ); + var maybeInstance = void 0; + try { + maybeInstance = findHostInstance(this); + } catch (error) {} + null != maybeInstance && + (maybeInstance.canonical + ? FabricUIManager.measureInWindow( + maybeInstance.node, + mountSafeCallback_NOT_REALLY_SAFE(this, callback) + ) + : UIManager.measureInWindow( + findNodeHandle(this), + mountSafeCallback_NOT_REALLY_SAFE(this, callback) + )); }; ReactNativeComponent.prototype.measureLayout = function( relativeToNativeNode, onSuccess, onFail ) { - UIManager.measureLayout( - findNodeHandle(this), - relativeToNativeNode, - mountSafeCallback_NOT_REALLY_SAFE(this, onFail), - mountSafeCallback_NOT_REALLY_SAFE(this, onSuccess) - ); + var maybeInstance = void 0; + try { + maybeInstance = findHostInstance(this); + } catch (error) {} + null == maybeInstance || + maybeInstance.canonical || + ((maybeInstance = void 0), + "number" === typeof relativeToNativeNode + ? (maybeInstance = relativeToNativeNode) + : relativeToNativeNode._nativeTag && + (maybeInstance = relativeToNativeNode._nativeTag), + null != maybeInstance && + UIManager.measureLayout( + findNodeHandle(this), + maybeInstance, + mountSafeCallback_NOT_REALLY_SAFE(this, onFail), + mountSafeCallback_NOT_REALLY_SAFE(this, onSuccess) + )); }; ReactNativeComponent.prototype.setNativeProps = function(nativeProps) { var maybeInstance = void 0; try { maybeInstance = findHostInstance(this); } catch (error) {} - if (null != maybeInstance) { - var viewConfig = + if (null != maybeInstance && !maybeInstance.canonical) { + var nativeTag = + maybeInstance._nativeTag || maybeInstance.canonical._nativeTag; + maybeInstance = maybeInstance.viewConfig || maybeInstance.canonical.viewConfig; nativeProps = diffProperties( null, emptyObject, nativeProps, - viewConfig.validAttributes + maybeInstance.validAttributes ); null != nativeProps && UIManager.updateView( - maybeInstance._nativeTag, - viewConfig.uiViewClassName, + nativeTag, + maybeInstance.uiViewClassName, nativeProps ); } @@ -7371,38 +7346,30 @@ var roots = new Map(), })(React.Component); })(findNodeHandle, findHostInstance), findNodeHandle: findNodeHandle, + setNativeProps: function(handle, nativeProps) { + null != handle._nativeTag && + ((nativeProps = diffProperties( + null, + emptyObject, + nativeProps, + handle.viewConfig.validAttributes + )), + null != nativeProps && + UIManager.updateView( + handle._nativeTag, + handle.viewConfig.uiViewClassName, + nativeProps + )); + }, render: function(element, containerTag, callback) { var root = roots.get(containerTag); if (!root) { - root = 0; - isDevToolsPresent && (root |= 4); - root = createFiber(3, null, null, root); - var root$jscomp$0 = { - current: root, - containerInfo: containerTag, - pendingChildren: null, - earliestPendingTime: 0, - latestPendingTime: 0, - earliestSuspendedTime: 0, - latestSuspendedTime: 0, - latestPingedTime: 0, - pingCache: null, - didError: !1, - pendingCommitExpirationTime: 0, - finishedWork: null, - timeoutHandle: -1, - context: null, - pendingContext: null, - hydrate: !1, - nextExpirationTimeToWorkOn: 0, - expirationTime: 0, - firstBatch: null, - nextScheduledRoot: null, - interactionThreadID: tracing.unstable_getThreadID(), - memoizedInteractions: new Set(), - pendingInteractionMap: new Map() - }; - root = root.stateNode = root$jscomp$0; + root = new FiberRootNode(containerTag, !1); + var uninitializedFiber = 0; + isDevToolsPresent && (uninitializedFiber |= 4); + uninitializedFiber = createFiber(3, null, null, uninitializedFiber); + root.current = uninitializedFiber; + uninitializedFiber.stateNode = root; roots.set(containerTag, root); } updateContainer(element, root, null, callback); @@ -7441,42 +7408,77 @@ var roots = new Map(), NativeMethodsMixin: (function(findNodeHandle, findHostInstance) { return { measure: function(callback) { - UIManager.measure( - findNodeHandle(this), - mountSafeCallback_NOT_REALLY_SAFE(this, callback) - ); + var maybeInstance = void 0; + try { + maybeInstance = findHostInstance(this); + } catch (error) {} + null != maybeInstance && + (maybeInstance.canonical + ? FabricUIManager.measure( + maybeInstance.node, + mountSafeCallback_NOT_REALLY_SAFE(this, callback) + ) + : UIManager.measure( + findNodeHandle(this), + mountSafeCallback_NOT_REALLY_SAFE(this, callback) + )); }, measureInWindow: function(callback) { - UIManager.measureInWindow( - findNodeHandle(this), - mountSafeCallback_NOT_REALLY_SAFE(this, callback) - ); + var maybeInstance = void 0; + try { + maybeInstance = findHostInstance(this); + } catch (error) {} + null != maybeInstance && + (maybeInstance.canonical + ? FabricUIManager.measureInWindow( + maybeInstance.node, + mountSafeCallback_NOT_REALLY_SAFE(this, callback) + ) + : UIManager.measureInWindow( + findNodeHandle(this), + mountSafeCallback_NOT_REALLY_SAFE(this, callback) + )); }, measureLayout: function(relativeToNativeNode, onSuccess, onFail) { - UIManager.measureLayout( - findNodeHandle(this), - relativeToNativeNode, - mountSafeCallback_NOT_REALLY_SAFE(this, onFail), - mountSafeCallback_NOT_REALLY_SAFE(this, onSuccess) - ); + var maybeInstance = void 0; + try { + maybeInstance = findHostInstance(this); + } catch (error) {} + null == maybeInstance || + maybeInstance.canonical || + ((maybeInstance = void 0), + "number" === typeof relativeToNativeNode + ? (maybeInstance = relativeToNativeNode) + : relativeToNativeNode._nativeTag && + (maybeInstance = relativeToNativeNode._nativeTag), + null != maybeInstance && + UIManager.measureLayout( + findNodeHandle(this), + maybeInstance, + mountSafeCallback_NOT_REALLY_SAFE(this, onFail), + mountSafeCallback_NOT_REALLY_SAFE(this, onSuccess) + )); }, setNativeProps: function(nativeProps) { var maybeInstance = void 0; try { maybeInstance = findHostInstance(this); } catch (error) {} - if (null != maybeInstance) { - var viewConfig = maybeInstance.viewConfig; + if (null != maybeInstance && !maybeInstance.canonical) { + var nativeTag = + maybeInstance._nativeTag || maybeInstance.canonical._nativeTag; + maybeInstance = + maybeInstance.viewConfig || maybeInstance.canonical.viewConfig; nativeProps = diffProperties( null, emptyObject, nativeProps, - viewConfig.validAttributes + maybeInstance.validAttributes ); null != nativeProps && UIManager.updateView( - maybeInstance._nativeTag, - viewConfig.uiViewClassName, + nativeTag, + maybeInstance.uiViewClassName, nativeProps ); } @@ -7500,7 +7502,10 @@ var roots = new Map(), var findFiberByHostInstance = devToolsConfig.findFiberByHostInstance; return injectInternals( Object.assign({}, devToolsConfig, { + overrideHookState: null, overrideProps: null, + setSuspenseHandler: null, + scheduleUpdate: null, currentDispatcherRef: ReactSharedInternals.ReactCurrentDispatcher, findHostInstanceByFiber: function(fiber) { fiber = findCurrentHostFiber(fiber); @@ -7517,7 +7522,7 @@ var roots = new Map(), findFiberByHostInstance: getInstanceFromTag, getInspectorDataForViewTag: getInspectorDataForViewTag, bundleType: 0, - version: "16.8.1", + version: "16.8.6", rendererPackageName: "react-native-renderer" }); var ReactNativeRenderer$2 = { default: ReactNativeRenderer }, diff --git a/Libraries/Renderer/shims/ReactNativeTypes.js b/Libraries/Renderer/shims/ReactNativeTypes.js index f9058abc1e939a..3e777114db2ae5 100644 --- a/Libraries/Renderer/shims/ReactNativeTypes.js +++ b/Libraries/Renderer/shims/ReactNativeTypes.js @@ -89,7 +89,7 @@ class ReactNativeComponent extends React.Component { measure(callback: MeasureOnSuccessCallback): void {} measureInWindow(callback: MeasureInWindowOnSuccessCallback): void {} measureLayout( - relativeToNativeNode: number, + relativeToNativeNode: number | Object, onSuccess: MeasureLayoutOnSuccessCallback, onFail?: () => void, ): void {} @@ -106,7 +106,7 @@ export type NativeMethodsMixinType = { measure(callback: MeasureOnSuccessCallback): void, measureInWindow(callback: MeasureInWindowOnSuccessCallback): void, measureLayout( - relativeToNativeNode: number, + relativeToNativeNode: number | Object, onSuccess: MeasureLayoutOnSuccessCallback, onFail: () => void, ): void, @@ -131,6 +131,7 @@ type SecretInternalsFabricType = { export type ReactNativeType = { NativeComponent: typeof ReactNativeComponent, findNodeHandle(componentOrHandle: any): ?number, + setNativeProps(handle: any, nativeProps: Object): void, render( element: React$Element, containerTag: any, @@ -146,6 +147,7 @@ export type ReactNativeType = { export type ReactFabricType = { NativeComponent: typeof ReactNativeComponent, findNodeHandle(componentOrHandle: any): ?number, + setNativeProps(handle: any, nativeProps: Object): void, render( element: React$Element, containerTag: any, diff --git a/Libraries/Renderer/shims/ReactTypes.js b/Libraries/Renderer/shims/ReactTypes.js index f09207928ceaff..7b5f2d1c66c528 100644 --- a/Libraries/Renderer/shims/ReactTypes.js +++ b/Libraries/Renderer/shims/ReactTypes.js @@ -13,7 +13,9 @@ export type ReactNode = | ReactText | ReactFragment | ReactProvider - | ReactConsumer; + | ReactConsumer + | ReactEventComponent + | ReactEventTarget; export type ReactEmpty = null | void | boolean; @@ -78,3 +80,93 @@ export type ReactPortal = { export type RefObject = {| current: any, |}; + +export type ReactEventResponderEventType = + | string + | {name: string, passive?: boolean, capture?: boolean}; + +export type ReactEventResponder = { + targetEventTypes: Array, + createInitialState?: (props: null | Object) => Object, + onEvent: ( + event: ReactResponderEvent, + context: ReactResponderContext, + props: null | Object, + state: null | Object, + ) => void, + onUnmount: ( + context: ReactResponderContext, + props: null | Object, + state: null | Object, + ) => void, + onOwnershipChange: ( + context: ReactResponderContext, + props: null | Object, + state: null | Object, + ) => void, +}; + +export type ReactEventComponentInstance = {| + context: null | Object, + props: null | Object, + responder: ReactEventResponder, + rootInstance: mixed, + state: null | Object, +|}; + +export type ReactEventComponent = {| + $$typeof: Symbol | number, + displayName?: string, + props: null | Object, + responder: ReactEventResponder, +|}; + +export type ReactEventTarget = {| + $$typeof: Symbol | number, + displayName?: string, + type: Symbol | number, +|}; + +type AnyNativeEvent = Event | KeyboardEvent | MouseEvent | Touch; + +export type ReactResponderEvent = { + nativeEvent: AnyNativeEvent, + target: Element | Document, + type: string, + passive: boolean, + passiveSupported: boolean, +}; + +export type ReactResponderDispatchEventOptions = { + capture?: boolean, + discrete?: boolean, + stopPropagation?: boolean, +}; + +export type ReactResponderContext = { + dispatchEvent: ( + eventObject: Object, + otpions: ReactResponderDispatchEventOptions, + ) => void, + isTargetWithinElement: ( + childTarget: Element | Document, + parentTarget: Element | Document, + ) => boolean, + isTargetWithinEventComponent: (Element | Document) => boolean, + isPositionWithinTouchHitTarget: ( + doc: Document, + x: number, + y: number, + ) => boolean, + addRootEventTypes: ( + document: Document, + rootEventTypes: Array, + ) => void, + removeRootEventTypes: ( + rootEventTypes: Array, + ) => void, + hasOwnership: () => boolean, + requestOwnership: () => boolean, + releaseOwnership: () => boolean, + setTimeout: (func: () => void, timeout: number) => TimeoutID, +}; diff --git a/Libraries/Text/TextInput/RCTBaseTextInputView.h b/Libraries/Text/TextInput/RCTBaseTextInputView.h index 67c1e54a9db3a6..5b62f90251492e 100644 --- a/Libraries/Text/TextInput/RCTBaseTextInputView.h +++ b/Libraries/Text/TextInput/RCTBaseTextInputView.h @@ -43,6 +43,7 @@ NS_ASSUME_NONNULL_BEGIN @property (nonatomic, assign) BOOL blurOnSubmit; @property (nonatomic, assign) BOOL selectTextOnFocus; @property (nonatomic, assign) BOOL clearTextOnFocus; +@property (nonatomic, assign) BOOL secureTextEntry; @property (nonatomic, copy) RCTTextSelection *selection; @property (nonatomic, strong, nullable) NSNumber *maxLength; @property (nonatomic, copy) NSAttributedString *attributedText; diff --git a/Libraries/Text/TextInput/RCTBaseTextInputView.m b/Libraries/Text/TextInput/RCTBaseTextInputView.m index 231680750dcd9a..fac75588340e52 100644 --- a/Libraries/Text/TextInput/RCTBaseTextInputView.m +++ b/Libraries/Text/TextInput/RCTBaseTextInputView.m @@ -141,9 +141,9 @@ - (void)setAttributedText:(NSAttributedString *)attributedText [attributedTextCopy removeAttribute:RCTTextAttributesTagAttributeName range:NSMakeRange(0, attributedTextCopy.length)]; - + textNeedsUpdate = ([self textOf:attributedTextCopy equals:backedTextInputViewTextCopy] == NO); - + if (eventLag == 0 && textNeedsUpdate) { UITextRange *selection = self.backedTextInputView.selectedTextRange; NSInteger oldTextLength = self.backedTextInputView.attributedText.string.length; @@ -203,9 +203,65 @@ - (void)setTextContentType:(NSString *)type { #if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_10_0 if (@available(iOS 10.0, *)) { + + static dispatch_once_t onceToken; + static NSDictionary *contentTypeMap; + + dispatch_once(&onceToken, ^{ + contentTypeMap = @{@"none": @"", + @"URL": UITextContentTypeURL, + @"addressCity": UITextContentTypeAddressCity, + @"addressCityAndState":UITextContentTypeAddressCityAndState, + @"addressState": UITextContentTypeAddressState, + @"countryName": UITextContentTypeCountryName, + @"creditCardNumber": UITextContentTypeCreditCardNumber, + @"emailAddress": UITextContentTypeEmailAddress, + @"familyName": UITextContentTypeFamilyName, + @"fullStreetAddress": UITextContentTypeFullStreetAddress, + @"givenName": UITextContentTypeGivenName, + @"jobTitle": UITextContentTypeJobTitle, + @"location": UITextContentTypeLocation, + @"middleName": UITextContentTypeMiddleName, + @"name": UITextContentTypeName, + @"namePrefix": UITextContentTypeNamePrefix, + @"nameSuffix": UITextContentTypeNameSuffix, + @"nickname": UITextContentTypeNickname, + @"organizationName": UITextContentTypeOrganizationName, + @"postalCode": UITextContentTypePostalCode, + @"streetAddressLine1": UITextContentTypeStreetAddressLine1, + @"streetAddressLine2": UITextContentTypeStreetAddressLine2, + @"sublocality": UITextContentTypeSublocality, + @"telephoneNumber": UITextContentTypeTelephoneNumber, + }; + + #if __IPHONE_OS_VERSION_MAX_ALLOWED >= 110000 /* __IPHONE_11_0 */ + if (@available(iOS 11.0, tvOS 11.0, *)) { + NSDictionary * iOS11extras = @{@"username": UITextContentTypeUsername, + @"password": UITextContentTypePassword}; + + NSMutableDictionary * iOS11baseMap = [contentTypeMap mutableCopy]; + [iOS11baseMap addEntriesFromDictionary:iOS11extras]; + + contentTypeMap = [iOS11baseMap copy]; + } + #endif + + #if __IPHONE_OS_VERSION_MAX_ALLOWED >= 120000 /* __IPHONE_12_0 */ + if (@available(iOS 12.0, tvOS 12.0, *)) { + NSDictionary * iOS12extras = @{@"newPassword": UITextContentTypeNewPassword, + @"oneTimeCode": UITextContentTypeOneTimeCode}; + + NSMutableDictionary * iOS12baseMap = [contentTypeMap mutableCopy]; + [iOS12baseMap addEntriesFromDictionary:iOS12extras]; + + contentTypeMap = [iOS12baseMap copy]; + } + #endif + }); + // Setting textContentType to an empty string will disable any // default behaviour, like the autofill bar for password inputs - self.backedTextInputView.textContentType = [type isEqualToString:@"none"] ? @"" : type; + self.backedTextInputView.textContentType = contentTypeMap[type] ?: type; } #endif } @@ -227,6 +283,24 @@ - (void)setKeyboardType:(UIKeyboardType)keyboardType } } +- (BOOL)secureTextEntry { + return self.backedTextInputView.secureTextEntry; +} + +- (void)setSecureTextEntry:(BOOL)secureTextEntry { + UIView *textInputView = self.backedTextInputView; + + if (textInputView.secureTextEntry != secureTextEntry) { + textInputView.secureTextEntry = secureTextEntry; + + // Fix #5859, see https://stackoverflow.com/questions/14220187/uitextfield-has-trailing-whitespace-after-securetextentry-toggle/22537788#22537788 + NSAttributedString *originalText = [textInputView.attributedText copy]; + self.backedTextInputView.attributedText = [NSAttributedString new]; + self.backedTextInputView.attributedText = originalText; + } + +} + #pragma mark - RCTBackedTextInputDelegate - (BOOL)textInputShouldBeginEditing @@ -330,18 +404,12 @@ - (BOOL)textInputShouldChangeTextInRange:(NSRange)range replacementText:(NSStrin } } - if (range.location + range.length > _predictedText.length) { - // _predictedText got out of sync in a bad way, so let's just force sync it. Haven't been able to repro this, but - // it's causing a real crash here: #6523822 + NSString *previousText = backedTextInputView.attributedText.string ?: @""; + + if (range.location + range.length > backedTextInputView.attributedText.string.length) { _predictedText = backedTextInputView.attributedText.string; - } - - NSString *previousText = [_predictedText substringWithRange:range] ?: @""; - - if (!_predictedText || backedTextInputView.attributedText.string.length == 0) { - _predictedText = text; } else { - _predictedText = [_predictedText stringByReplacingCharactersInRange:range withString:text]; + _predictedText = [backedTextInputView.attributedText.string stringByReplacingCharactersInRange:range withString:text]; } if (_onTextInput) { @@ -376,7 +444,6 @@ - (void)textInputDidChange [self textInputShouldChangeTextInRange:predictionRange replacementText:replacement]; // JS will assume the selection changed based on the location of our shouldChangeTextInRange, so reset it. [self textInputDidChangeSelection]; - _predictedText = backedTextInputView.attributedText.string; } _nativeEventCount++; diff --git a/Libraries/Text/TextInput/RCTBaseTextInputViewManager.m b/Libraries/Text/TextInput/RCTBaseTextInputViewManager.m index 6d5f7ec5aa001e..d226782be62faa 100644 --- a/Libraries/Text/TextInput/RCTBaseTextInputViewManager.m +++ b/Libraries/Text/TextInput/RCTBaseTextInputViewManager.m @@ -43,12 +43,12 @@ @implementation RCTBaseTextInputViewManager RCT_REMAP_VIEW_PROPERTY(placeholder, backedTextInputView.placeholder, NSString) RCT_REMAP_VIEW_PROPERTY(placeholderTextColor, backedTextInputView.placeholderColor, UIColor) RCT_REMAP_VIEW_PROPERTY(returnKeyType, backedTextInputView.returnKeyType, UIReturnKeyType) -RCT_REMAP_VIEW_PROPERTY(secureTextEntry, backedTextInputView.secureTextEntry, BOOL) RCT_REMAP_VIEW_PROPERTY(selectionColor, backedTextInputView.tintColor, UIColor) RCT_REMAP_VIEW_PROPERTY(spellCheck, backedTextInputView.spellCheckingType, UITextSpellCheckingType) RCT_REMAP_VIEW_PROPERTY(caretHidden, backedTextInputView.caretHidden, BOOL) RCT_REMAP_VIEW_PROPERTY(clearButtonMode, backedTextInputView.clearButtonMode, UITextFieldViewMode) RCT_REMAP_VIEW_PROPERTY(scrollEnabled, backedTextInputView.scrollEnabled, BOOL) +RCT_EXPORT_VIEW_PROPERTY(secureTextEntry, BOOL) RCT_EXPORT_VIEW_PROPERTY(blurOnSubmit, BOOL) RCT_EXPORT_VIEW_PROPERTY(clearTextOnFocus, BOOL) RCT_EXPORT_VIEW_PROPERTY(keyboardType, UIKeyboardType) diff --git a/Libraries/Text/TextInput/Singleline/RCTUITextField.m b/Libraries/Text/TextInput/Singleline/RCTUITextField.m index 6549f203cbca03..03a9198e18446b 100644 --- a/Libraries/Text/TextInput/Singleline/RCTUITextField.m +++ b/Libraries/Text/TextInput/Singleline/RCTUITextField.m @@ -14,7 +14,6 @@ @implementation RCTUITextField { RCTBackedTextFieldDelegateAdapter *_textInputDelegateAdapter; - NSMutableAttributedString *_attributesHolder; } - (instancetype)initWithFrame:(CGRect)frame @@ -26,7 +25,6 @@ - (instancetype)initWithFrame:(CGRect)frame object:self]; _textInputDelegateAdapter = [[RCTBackedTextFieldDelegateAdapter alloc] initWithTextField:self]; - _attributesHolder = [[NSMutableAttributedString alloc] init]; } return self; @@ -119,48 +117,6 @@ - (CGRect)caretRectForPosition:(UITextPosition *)position return [super caretRectForPosition:position]; } -#pragma mark - Fix for CJK Languages - -/* - * The workaround to fix inputting complex locales (like CJK languages). - * When we use `setAttrbutedText:` while user is inputting text in a complex - * locale (like Chinese, Japanese or Korean), some internal state breaks and - * input stops working. - * - * To workaround that, we don't skip underlying attributedString in the text - * field if only attributes were changed. We keep track of these attributes in - * a local variable. - * - * There are two methods that are altered by this workaround: - * - * (1) `-setAttributedText:` - * Applies the attributed string change to a local variable `_attributesHolder` instead of calling `-[super setAttributedText:]`. - * If new attributed text differs from the existing one only in attributes, - * skips `-[super setAttributedText:`] completely. - * - * (2) `-attributedText` - * Return `_attributesHolder` context. - * Updates `_atributesHolder` before returning if the underlying `super.attributedText.string` was changed. - * - */ -- (void)setAttributedText:(NSAttributedString *)attributedText -{ - BOOL textWasChanged = ![_attributesHolder.string isEqualToString:attributedText.string]; - [_attributesHolder setAttributedString:attributedText]; - - if (textWasChanged) { - [super setAttributedText:attributedText]; - } -} - -- (NSAttributedString *)attributedText -{ - if (![super.attributedText.string isEqualToString:_attributesHolder.string]) { - [_attributesHolder setAttributedString:super.attributedText]; - } - - return _attributesHolder; -} #pragma mark - Positioning Overrides diff --git a/RNTester/RNTester.xcodeproj/project.pbxproj b/RNTester/RNTester.xcodeproj/project.pbxproj index 370d12836e1146..e1f0b0648aeece 100644 --- a/RNTester/RNTester.xcodeproj/project.pbxproj +++ b/RNTester/RNTester.xcodeproj/project.pbxproj @@ -1688,7 +1688,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "export NODE_BINARY=node\n$SRCROOT/../scripts/react-native-xcode.sh RNTester/js/RNTesterApp.ios.js\n"; + shellScript = "export EXTRA_PACKAGER_ARGS=\"--reactNativePath $SRCROOT/../\"\nexport NODE_BINARY=node\n$SRCROOT/../scripts/react-native-xcode.sh RNTester/js/RNTesterApp.ios.js\n"; }; /* End PBXShellScriptBuildPhase section */ diff --git a/RNTester/RNTesterIntegrationTests/ReferenceImages/RNTester-js-RNTesterApp.ios/testSwitchExample_1-iOS12@2x.png b/RNTester/RNTesterIntegrationTests/ReferenceImages/RNTester-js-RNTesterApp.ios/testSwitchExample_1-iOS12@2x.png index 01047454a189f7..ac1eabff547707 100644 Binary files a/RNTester/RNTesterIntegrationTests/ReferenceImages/RNTester-js-RNTesterApp.ios/testSwitchExample_1-iOS12@2x.png and b/RNTester/RNTesterIntegrationTests/ReferenceImages/RNTester-js-RNTesterApp.ios/testSwitchExample_1-iOS12@2x.png differ diff --git a/RNTester/RNTesterIntegrationTests/ReferenceImages/RNTester-js-RNTesterApp.ios/testTextExample_1-iOS12@2x.png b/RNTester/RNTesterIntegrationTests/ReferenceImages/RNTester-js-RNTesterApp.ios/testTextExample_1-iOS12@2x.png index d016b823e5a4bb..642a56961e002c 100644 Binary files a/RNTester/RNTesterIntegrationTests/ReferenceImages/RNTester-js-RNTesterApp.ios/testTextExample_1-iOS12@2x.png and b/RNTester/RNTesterIntegrationTests/ReferenceImages/RNTester-js-RNTesterApp.ios/testTextExample_1-iOS12@2x.png differ diff --git a/RNTester/android/app/build.gradle b/RNTester/android/app/build.gradle index 3207cf6ced2f09..275ecae7297148 100644 --- a/RNTester/android/app/build.gradle +++ b/RNTester/android/app/build.gradle @@ -69,7 +69,8 @@ project.ext.react = [ bundleAssetName: "RNTesterApp.android.bundle", entryFile: file("../../js/RNTesterApp.android.js"), root: "$rootDir", - inputExcludes: ["android/**", "./**", ".gradle/**"] + inputExcludes: ["android/**", "./**", ".gradle/**"], + extraPackagerArgs: ["--reactNativePath", "$rootDir"] ] apply from: "../../../react.gradle" @@ -101,7 +102,7 @@ android { defaultConfig { applicationId "com.facebook.react.uiapp" minSdkVersion 16 - targetSdkVersion 27 + targetSdkVersion 28 versionCode 1 versionName "1.0" } diff --git a/RNTester/e2e/__tests__/DatePickerIOS-test.js b/RNTester/e2e/__tests__/DatePickerIOS-test.js index 6f8a3b6ee0ab61..024f237d74613b 100644 --- a/RNTester/e2e/__tests__/DatePickerIOS-test.js +++ b/RNTester/e2e/__tests__/DatePickerIOS-test.js @@ -27,33 +27,34 @@ describe('DatePickerIOS', () => { it('Should change indicator with datetime picker', async () => { await openExampleWithTitle('Date and time picker'); const testID = 'date-and-time'; - const indicatorID = 'date-and-time-indicator'; const testElement = await element( by.type('UIPickerView').withAncestor(by.id(testID)), ); - const indicator = await element(by.id(indicatorID)); + const dateIndicator = await element(by.id('date-indicator')); + const timeIndicator = await element(by.id('time-indicator')); await expect(testElement).toBeVisible(); - await expect(indicator).toBeVisible(); + await expect(dateIndicator).toBeVisible(); + await expect(timeIndicator).toBeVisible(); await testElement.setColumnToValue(0, 'Dec 4'); await testElement.setColumnToValue(1, '4'); await testElement.setColumnToValue(2, '10'); await testElement.setColumnToValue(3, 'AM'); - await expect(indicator).toHaveText('12/4/2005 4:10 AM'); + await expect(dateIndicator).toHaveText('12/4/2005'); + await expect(timeIndicator).toHaveText('4:10 AM'); }); it('Should change indicator with date-only picker', async () => { - await openExampleWithTitle('Date only'); + await openExampleWithTitle('Date only picker'); const testID = 'date-only'; - const indicatorID = 'date-and-time-indicator'; const testElement = await element( by.type('UIPickerView').withAncestor(by.id(testID)), ); - const indicator = await element(by.id(indicatorID)); + const indicator = await element(by.id('date-indicator')); await expect(testElement).toBeVisible(); await expect(indicator).toBeVisible(); @@ -62,6 +63,6 @@ describe('DatePickerIOS', () => { await testElement.setColumnToValue(1, '3'); await testElement.setColumnToValue(2, '2006'); - await expect(indicator).toHaveText('11/3/2006 4:10 AM'); + await expect(indicator).toHaveText('11/3/2006'); }); }); diff --git a/RNTester/js/AccessibilityAndroidExample.android.js b/RNTester/js/AccessibilityAndroidExample.android.js index ac4b6c00108667..aa41b63a122f2d 100644 --- a/RNTester/js/AccessibilityAndroidExample.android.js +++ b/RNTester/js/AccessibilityAndroidExample.android.js @@ -111,6 +111,31 @@ class AccessibilityAndroidExample extends React.Component { + + + This is + + nontouchable accessible view with label. + + + + + + + ToastAndroid.show('Toasts work by default', ToastAndroid.SHORT) + } + accessibilityRole="link"> + + Click me + Or not + + + + diff --git a/RNTester/js/DatePickerIOSExample.js b/RNTester/js/DatePickerIOSExample.js index fa4dcb12b0a1ce..1c94e347bb99bc 100644 --- a/RNTester/js/DatePickerIOSExample.js +++ b/RNTester/js/DatePickerIOSExample.js @@ -12,11 +12,10 @@ const React = require('react'); const ReactNative = require('react-native'); -const {DatePickerIOS, StyleSheet, Text, TextInput, View} = ReactNative; +const {DatePickerIOS, StyleSheet, Text, View} = ReactNative; type State = {| date: Date, - timeZoneOffsetInHours: number, |}; type Props = {| @@ -26,43 +25,25 @@ type Props = {| class WithDatePickerData extends React.Component { state = { date: new Date(), - timeZoneOffsetInHours: (-1 * new Date().getTimezoneOffset()) / 60, }; onDateChange = date => { this.setState({date: date}); }; - onTimezoneChange = event => { - const offset = parseInt(event.nativeEvent.text, 10); - if (isNaN(offset)) { - return; - } - this.setState({timeZoneOffsetInHours: offset}); - }; - render() { - // Ideally, the timezone input would be a picker rather than a - // text input, but we don't have any pickers yet :( return ( - - {this.state.date.toLocaleDateString() + - ' ' + - this.state.date.toLocaleTimeString([], { - hour: '2-digit', - minute: '2-digit', - })} + + {this.state.date.toLocaleDateString()} + + + {this.state.date.toLocaleTimeString([], { + hour: '2-digit', + minute: '2-digit', + })} - - - - hours from UTC {this.props.children(this.state, this.onDateChange)} @@ -124,7 +105,6 @@ exports.examples = [ testID="date-and-time" date={state.date} mode="datetime" - timeZoneOffsetInMinutes={state.timeZoneOffsetInHours * 60} onDateChange={onDateChange} /> )} @@ -142,7 +122,6 @@ exports.examples = [ testID="date-only" date={state.date} mode="date" - timeZoneOffsetInMinutes={state.timeZoneOffsetInHours * 60} onDateChange={onDateChange} /> )} @@ -151,16 +130,16 @@ exports.examples = [ }, }, { - title: 'Time only picker, 10-minute interval', + title: 'Picker with 20-minute interval', render: function(): React.Element { return ( {(state, onDateChange) => ( )} diff --git a/RNTester/js/SwitchExample.js b/RNTester/js/SwitchExample.js index ca36372e3788be..d1d81811b2b7c0 100644 --- a/RNTester/js/SwitchExample.js +++ b/RNTester/js/SwitchExample.js @@ -54,6 +54,10 @@ class BasicSwitchExample extends React.Component< this.setState({falseSwitchIsOn: value})} + trackColor={{ + true: 'yellow', + false: 'purple', + }} value={this.state.falseSwitchIsOn} /> { right right right right right right right right right right right right right + + justify (works when api level >= 26 otherwise fallbacks to "left"): + this text component{"'"}s contents are laid out with "textAlign: + justify" and as you can see all of the lines except the last one + span the available width of the parent container. + @@ -615,11 +621,13 @@ class TextExample extends React.Component<{}> { Works with other text styles + + {'test🙃'.substring(0, 5)} + ); } } - const styles = StyleSheet.create({ backgroundColorText: { left: 5, diff --git a/RNTester/js/TextExample.ios.js b/RNTester/js/TextExample.ios.js index d52f9a8c6025c8..320854f88ae017 100644 --- a/RNTester/js/TextExample.ios.js +++ b/RNTester/js/TextExample.ios.js @@ -428,6 +428,12 @@ exports.examples = [ ); }, }, + { + title: "Substring Emoji (should only see 'test')", + render: function() { + return {'test🙃'.substring(0, 5)}; + }, + }, { title: 'Text metrics', render: function() { diff --git a/RNTester/js/TextInputExample.ios.js b/RNTester/js/TextInputExample.ios.js index b7a61032e98c6a..c2a73781a7b442 100644 --- a/RNTester/js/TextInputExample.ios.js +++ b/RNTester/js/TextInputExample.ios.js @@ -212,7 +212,11 @@ class SecureEntryExample extends React.Component<$FlowFixMeProps, any> { * comment and run Flow. */ constructor(props) { super(props); - this.state = {text: ''}; + this.state = { + text: '', + password: '', + isSecureTextEntry: true, + }; } render() { return ( @@ -225,6 +229,26 @@ class SecureEntryExample extends React.Component<$FlowFixMeProps, any> { value={this.state.text} /> Current text is: {this.state.text} + + this.setState({password: text})} + secureTextEntry={this.state.isSecureTextEntry} + value={this.state.password} + /> + { + this.setState({isSecureTextEntry: value}); + }} + style={{marginLeft: 4}} + value={this.state.isSecureTextEntry} + /> + ); } @@ -1085,4 +1109,19 @@ exports.examples = [ ); }, }, + { + title: 'Text Content Type', + render: function() { + return ( + + + + + + + + + ); + }, + }, ]; diff --git a/React.podspec b/React.podspec index a5d06285fff740..ce9dc99b583a99 100644 --- a/React.podspec +++ b/React.podspec @@ -66,6 +66,7 @@ Pod::Spec.new do |s| "React/Views/RCTSlider*", "React/Views/RCTSwitch*", "React/Views/RCTWebView*" + ss.compiler_flags = folly_compiler_flags ss.header_dir = "React" ss.framework = "JavaScriptCore" ss.libraries = "stdc++" @@ -116,6 +117,8 @@ Pod::Spec.new do |s| ss.dependency "React/cxxreact" ss.dependency "React/jsi" ss.dependency "Folly", folly_version + ss.dependency "DoubleConversion" + ss.dependency "glog" ss.compiler_flags = folly_compiler_flags ss.source_files = "ReactCommon/jsiexecutor/jsireact/*.{cpp,h}" ss.private_header_files = "ReactCommon/jsiexecutor/jsireact/*.h" @@ -125,6 +128,8 @@ Pod::Spec.new do |s| s.subspec "jsi" do |ss| ss.dependency "Folly", folly_version + ss.dependency "DoubleConversion" + ss.dependency "glog" ss.compiler_flags = folly_compiler_flags ss.source_files = "ReactCommon/jsi/*.{cpp,h}" ss.private_header_files = "ReactCommon/jsi/*.h" @@ -142,6 +147,8 @@ Pod::Spec.new do |s| ss.dependency "React/jsinspector" ss.dependency "boost-for-react-native", "1.63.0" ss.dependency "Folly", folly_version + ss.dependency "DoubleConversion" + ss.dependency "glog" ss.compiler_flags = folly_compiler_flags ss.source_files = "ReactCommon/cxxreact/*.{cpp,h}" ss.exclude_files = "ReactCommon/cxxreact/SampleCxxModule.*" diff --git a/React/Base/RCTBridge.m b/React/Base/RCTBridge.m index 5ae96783e499fa..0ff789cf44c850 100644 --- a/React/Base/RCTBridge.m +++ b/React/Base/RCTBridge.m @@ -292,6 +292,8 @@ - (void)reload * Any thread */ dispatch_async(dispatch_get_main_queue(), ^{ + // WARNING: Invalidation is async, so it may not finish before re-setting up the bridge, + // causing some issues. TODO: revisit this post-Fabric/TurboModule. [self invalidate]; // Reload is a special case, do not preserve launchOptions and treat reload as a fresh start self->_launchOptions = nil; diff --git a/React/Base/RCTBridgeModule.h b/React/Base/RCTBridgeModule.h index f6b12bf00c0881..54a27802cbd0dc 100644 --- a/React/Base/RCTBridgeModule.h +++ b/React/Base/RCTBridgeModule.h @@ -73,6 +73,17 @@ RCT_EXTERN void RCTRegisterModule(Class); \ + (NSString *)moduleName { return @#js_name; } \ + (void)load { RCTRegisterModule(self); } +/** + * Same as RCT_EXPORT_MODULE, but uses __attribute__((constructor)) for module + * registration. Useful for registering swift classes that forbids use of load + * Used in RCT_EXTERN_REMAP_MODULE + */ +#define RCT_EXPORT_MODULE_NO_LOAD(js_name, objc_name) \ +RCT_EXTERN void RCTRegisterModule(Class); \ ++ (NSString *)moduleName { return @#js_name; } \ +__attribute__((constructor)) static void \ +RCT_CONCAT(initialize_, objc_name)() { RCTRegisterModule([objc_name class]); } + /** * To improve startup performance users may want to generate their module lists * at build time and hook the delegate to merge with the runtime list. This @@ -250,7 +261,7 @@ RCT_EXTERN void RCTRegisterModule(Class); \ @interface objc_name (RCTExternModule) \ @end \ @implementation objc_name (RCTExternModule) \ - RCT_EXPORT_MODULE(js_name) + RCT_EXPORT_MODULE_NO_LOAD(js_name, objc_name) /** * Use this macro in accordance with RCT_EXTERN_MODULE to export methods diff --git a/React/Base/RCTUtils.m b/React/Base/RCTUtils.m index 44e1e7fe5c1730..37fff6a2a530e0 100644 --- a/React/Base/RCTUtils.m +++ b/React/Base/RCTUtils.m @@ -708,13 +708,11 @@ BOOL RCTIsLocalAssetURL(NSURL *__nullable imageURL) if (!image) { // Attempt to load from the file system - NSData *fileData; - if (imageURL.pathExtension.length == 0) { - fileData = [NSData dataWithContentsOfURL:[imageURL URLByAppendingPathExtension:@"png"]]; - } else { - fileData = [NSData dataWithContentsOfURL:imageURL]; + NSString *filePath = [NSString stringWithUTF8String:[imageURL fileSystemRepresentation]]; + if (filePath.pathExtension.length == 0) { + filePath = [filePath stringByAppendingPathExtension:@"png"]; } - image = [UIImage imageWithData:fileData]; + image = [UIImage imageWithContentsOfFile:filePath]; } if (!image && !bundle) { diff --git a/React/Base/RCTVersion.m b/React/Base/RCTVersion.m index 8073c42e1670d9..f53daf948e5559 100644 --- a/React/Base/RCTVersion.m +++ b/React/Base/RCTVersion.m @@ -21,8 +21,8 @@ static void __makeVersion() { __rnVersion = @{ RCTVersionMajor: @(0), - RCTVersionMinor: @(0), - RCTVersionPatch: @(0), + RCTVersionMinor: @(59), + RCTVersionPatch: @(6), RCTVersionPrerelease: [NSNull null], }; } diff --git a/React/CxxBridge/RCTCxxBridge.mm b/React/CxxBridge/RCTCxxBridge.mm index 31cdd75b1f5f04..194b06c96c901a 100644 --- a/React/CxxBridge/RCTCxxBridge.mm +++ b/React/CxxBridge/RCTCxxBridge.mm @@ -357,7 +357,9 @@ - (void)start dispatch_group_leave(prepareBridge); } onProgress:^(RCTLoadingProgress *progressData) { #if RCT_DEV && __has_include("RCTDevLoadingView.h") - RCTDevLoadingView *loadingView = [weakSelf moduleForClass:[RCTDevLoadingView class]]; + // Note: RCTDevLoadingView should have been loaded at this point, so no need to allow lazy loading. + RCTDevLoadingView *loadingView = [weakSelf moduleForName:RCTBridgeModuleNameForClass([RCTDevLoadingView class]) + lazilyLoadIfNecessary:NO]; [loadingView updateProgress:progressData]; #endif }]; diff --git a/React/Inspector/RCTInspectorPackagerConnection.m b/React/Inspector/RCTInspectorPackagerConnection.m index 5d0ed99ab468d0..d3d97d0eaf6097 100644 --- a/React/Inspector/RCTInspectorPackagerConnection.m +++ b/React/Inspector/RCTInspectorPackagerConnection.m @@ -201,7 +201,7 @@ - (void)webSocket:(RCTSRWebSocket *)webSocket didFailWithError:(NSError *)error [self abort:@"Websocket exception" withCause:error]; } - if (!_closed) { + if (!_closed && [error code] != ECONNREFUSED) { [self reconnect]; } } diff --git a/React/Modules/RCTDeviceInfo.m b/React/Modules/RCTDeviceInfo.m index 8feb87f26dec76..940a1076ac02b3 100644 --- a/React/Modules/RCTDeviceInfo.m +++ b/React/Modules/RCTDeviceInfo.m @@ -16,6 +16,7 @@ @implementation RCTDeviceInfo { #if !TARGET_OS_TV UIInterfaceOrientation _currentInterfaceOrientation; + NSDictionary *_currentInterfaceDimensions; #endif } @@ -48,6 +49,13 @@ - (void)setBridge:(RCTBridge *)bridge selector:@selector(interfaceOrientationDidChange) name:UIApplicationDidChangeStatusBarOrientationNotification object:nil]; + + _currentInterfaceDimensions = RCTExportedDimensions(_bridge); + + [[NSNotificationCenter defaultCenter] addObserver:self + selector:@selector(interfaceFrameDidChange) + name:UIApplicationDidBecomeActiveNotification + object:nil]; #endif } @@ -77,16 +85,23 @@ static BOOL RCTIsIPhoneX() { RCTAssertMainQueue(); RCTDimensions dimensions = RCTGetDimensions(bridge.accessibilityManager.multiplier); - typeof (dimensions.window) window = dimensions.window; // Window and Screen are considered equal for iOS. - NSDictionary *dims = @{ + typeof (dimensions.window) window = dimensions.window; + NSDictionary *dimsWindow = @{ @"width": @(window.width), @"height": @(window.height), @"scale": @(window.scale), @"fontScale": @(window.fontScale) }; + typeof (dimensions.screen) screen = dimensions.screen; + NSDictionary *dimsScreen = @{ + @"width": @(screen.width), + @"height": @(screen.height), + @"scale": @(screen.scale), + @"fontScale": @(screen.fontScale) + }; return @{ - @"window": dims, - @"screen": dims + @"window": dimsWindow, + @"screen": dimsScreen }; } @@ -163,6 +178,31 @@ - (void)_interfaceOrientationDidChange _currentInterfaceOrientation = nextOrientation; } + +- (void)interfaceFrameDidChange +{ + __weak typeof(self) weakSelf = self; + RCTExecuteOnMainQueue(^{ + [weakSelf _interfaceFrameDidChange]; + }); +} + + +- (void)_interfaceFrameDidChange +{ + NSDictionary *nextInterfaceDimensions = RCTExportedDimensions(_bridge); + + if (!([nextInterfaceDimensions isEqual:_currentInterfaceDimensions])) { +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" + [_bridge.eventDispatcher sendDeviceEventWithName:@"didUpdateDimensions" + body:nextInterfaceDimensions]; +#pragma clang diagnostic pop + } + + _currentInterfaceDimensions = nextInterfaceDimensions; +} + #endif // TARGET_OS_TV diff --git a/React/Profiler/RCTPerfMonitor.m b/React/Profiler/RCTPerfMonitor.m index 57bd0f9adf42f7..1db32322a33b78 100644 --- a/React/Profiler/RCTPerfMonitor.m +++ b/React/Profiler/RCTPerfMonitor.m @@ -156,6 +156,9 @@ - (RCTDevMenuItem *)devMenuItem if (!_devMenuItem) { __weak __typeof__(self) weakSelf = self; __weak RCTDevSettings *devSettings = self.bridge.devSettings; + if (devSettings.isPerfMonitorShown) { + [weakSelf show]; + } _devMenuItem = [RCTDevMenuItem buttonItemWithTitleBlock:^NSString *{ return (devSettings.isPerfMonitorShown) ? diff --git a/React/React.xcodeproj/project.pbxproj b/React/React.xcodeproj/project.pbxproj index 2fc11518236d24..28fcfe85b1712f 100644 --- a/React/React.xcodeproj/project.pbxproj +++ b/React/React.xcodeproj/project.pbxproj @@ -985,7 +985,6 @@ 59EDBCC61FDF4E55003573DE /* (null) in Copy Headers */ = {isa = PBXBuildFile; }; 59EDBCC71FDF4E55003573DE /* RCTScrollView.h in Copy Headers */ = {isa = PBXBuildFile; fileRef = 59EDBCA31FDF4E0C003573DE /* RCTScrollView.h */; }; 59EDBCC81FDF4E55003573DE /* RCTScrollViewManager.h in Copy Headers */ = {isa = PBXBuildFile; fileRef = 59EDBCA51FDF4E0C003573DE /* RCTScrollViewManager.h */; }; - 5CE2080220772F7D009A43B3 /* YGConfig.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5CE2080020772F7C009A43B3 /* YGConfig.cpp */; }; 5CE2080320772F7D009A43B3 /* YGConfig.h in Headers */ = {isa = PBXBuildFile; fileRef = 5CE2080120772F7C009A43B3 /* YGConfig.h */; }; 657734841EE834C900A0E9EA /* RCTInspectorDevServerHelper.h in Headers */ = {isa = PBXBuildFile; fileRef = 657734821EE834C900A0E9EA /* RCTInspectorDevServerHelper.h */; }; 657734851EE834C900A0E9EA /* RCTInspectorDevServerHelper.mm in Sources */ = {isa = PBXBuildFile; fileRef = 657734831EE834C900A0E9EA /* RCTInspectorDevServerHelper.mm */; }; @@ -1047,13 +1046,11 @@ A2440AA21DF8D854006E7BFC /* RCTReloadCommand.h in Headers */ = {isa = PBXBuildFile; fileRef = A2440AA01DF8D854006E7BFC /* RCTReloadCommand.h */; }; A2440AA31DF8D854006E7BFC /* RCTReloadCommand.m in Sources */ = {isa = PBXBuildFile; fileRef = A2440AA11DF8D854006E7BFC /* RCTReloadCommand.m */; }; A2440AA41DF8D865006E7BFC /* RCTReloadCommand.h in Headers */ = {isa = PBXBuildFile; fileRef = A2440AA01DF8D854006E7BFC /* RCTReloadCommand.h */; }; - AC4A6AF921FB4EA900FBEC39 /* YGMarker.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AC4A6AF821FB4EA900FBEC39 /* YGMarker.cpp */; }; AC4A6AFA21FB4EBF00FBEC39 /* YGMarker.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AC4A6AF821FB4EA900FBEC39 /* YGMarker.cpp */; }; AC4A6AFB21FB4ECA00FBEC39 /* YGMarker.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AC4A6AF821FB4EA900FBEC39 /* YGMarker.cpp */; }; AC52CEDE21FB3FF9003C6BEC /* instrumentation.h in Headers */ = {isa = PBXBuildFile; fileRef = AC52CEDD21FB3FF9003C6BEC /* instrumentation.h */; }; AC52CEDF21FB401D003C6BEC /* instrumentation.h in Headers */ = {isa = PBXBuildFile; fileRef = AC52CEDD21FB3FF9003C6BEC /* instrumentation.h */; }; AC52CEE021FB403B003C6BEC /* instrumentation.h in Headers */ = {isa = PBXBuildFile; fileRef = AC52CEDD21FB3FF9003C6BEC /* instrumentation.h */; }; - AC6B69E321B1467C00B2B68A /* YGValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AC6B69E121B1467C00B2B68A /* YGValue.cpp */; }; AC6B69E421B1467C00B2B68A /* YGValue.h in Headers */ = {isa = PBXBuildFile; fileRef = AC6B69E221B1467C00B2B68A /* YGValue.h */; }; AC6B69E521B1469A00B2B68A /* YGValue.h in Headers */ = {isa = PBXBuildFile; fileRef = AC6B69E221B1467C00B2B68A /* YGValue.h */; }; AC6B69E621B146A500B2B68A /* YGValue.h in Copy Headers */ = {isa = PBXBuildFile; fileRef = AC6B69E221B1467C00B2B68A /* YGValue.h */; }; @@ -4427,7 +4424,6 @@ 352DCFF01D19F4C20056D623 /* RCTI18nUtil.m in Sources */, 66CD94B71F1045E700CB3C7C /* RCTMaskedViewManager.m in Sources */, 008341F61D1DB34400876D9A /* RCTJSStackFrame.m in Sources */, - AC4A6AF921FB4EA900FBEC39 /* YGMarker.cpp in Sources */, 13134C961E296B2A00B9F3CB /* RCTObjcExecutor.mm in Sources */, 59D031FB1F8353D3008361F0 /* RCTSafeAreaViewManager.m in Sources */, 83CBBACC1A6023D300E9B192 /* RCTConvert.m in Sources */, @@ -4459,7 +4455,6 @@ 13134C8E1E296B2A00B9F3CB /* RCTMessageThread.mm in Sources */, 599FAA381FB274980058CCF6 /* RCTSurface.mm in Sources */, 59D031EF1F8353D3008361F0 /* RCTSafeAreaShadowView.m in Sources */, - AC6B69E321B1467C00B2B68A /* YGValue.cpp in Sources */, 3D1E68DB1CABD13900DD7465 /* RCTDisplayLink.m in Sources */, 14F3620E1AABD06A001CE568 /* RCTSwitchManager.m in Sources */, 13B080201A69489C00A75B9A /* RCTActivityIndicatorViewManager.m in Sources */, @@ -4516,7 +4511,6 @@ 13A1F71E1A75392D00D3D453 /* RCTKeyCommands.m in Sources */, 83CBBA531A601E3B00E9B192 /* RCTUtils.m in Sources */, 130443C61E401A8C00D93A67 /* RCTConvert+Transform.m in Sources */, - 5CE2080220772F7D009A43B3 /* YGConfig.cpp in Sources */, 191E3EC11C29DC3800C180A6 /* RCTRefreshControl.m in Sources */, 3DCE532B1FEAB23100613583 /* RCTDatePickerManager.m in Sources */, 13C156051AB1A2840079392D /* RCTWebView.m in Sources */, diff --git a/React/UIUtils/RCTUIUtils.m b/React/UIUtils/RCTUIUtils.m index dcc3353ccf6f60..961c9426e3564c 100644 --- a/React/UIUtils/RCTUIUtils.m +++ b/React/UIUtils/RCTUIUtils.m @@ -7,19 +7,32 @@ #import "RCTUIUtils.h" +#import "RCTUtils.h" + RCTDimensions RCTGetDimensions(CGFloat fontScale) { UIScreen *mainScreen = UIScreen.mainScreen; CGSize screenSize = mainScreen.bounds.size; + + UIView *mainWindow; + mainWindow = RCTKeyWindow(); + CGSize windowSize = mainWindow.bounds.size; + RCTDimensions result; - typeof (result.window) dims = { + typeof (result.screen) dimsScreen = { .width = screenSize.width, .height = screenSize.height, .scale = mainScreen.scale, .fontScale = fontScale }; - result.window = dims; - result.screen = dims; + typeof (result.window) dimsWindow = { + .width = windowSize.width, + .height = windowSize.height, + .scale = mainScreen.scale, + .fontScale = fontScale + }; + result.screen = dimsScreen; + result.window = dimsWindow; return result; } diff --git a/React/Views/RCTBorderDrawing.m b/React/Views/RCTBorderDrawing.m index 2a8d105471aa2a..a92db47791018d 100644 --- a/React/Views/RCTBorderDrawing.m +++ b/React/Views/RCTBorderDrawing.m @@ -224,13 +224,15 @@ static CGContextRef RCTUIGraphicsBeginImageContext(CGSize size, CGColorRef backg borderInsets.right + MAX(cornerInsets.bottomRight.width, cornerInsets.topRight.width) }; - // Asymmetrical edgeInsets cause strange artifacting on iOS 10 and earlier. - edgeInsets = (UIEdgeInsets){ - MAX(edgeInsets.top, edgeInsets.bottom), - MAX(edgeInsets.left, edgeInsets.right), - MAX(edgeInsets.top, edgeInsets.bottom), - MAX(edgeInsets.left, edgeInsets.right), - }; + if (hasCornerRadii) { + // Asymmetrical edgeInsets cause strange artifacting on iOS 10 and earlier. + edgeInsets = (UIEdgeInsets){ + MAX(edgeInsets.top, edgeInsets.bottom), + MAX(edgeInsets.left, edgeInsets.right), + MAX(edgeInsets.top, edgeInsets.bottom), + MAX(edgeInsets.left, edgeInsets.right), + }; + } const CGSize size = makeStretchable ? (CGSize){ // 1pt for the middle stretchable area along each axis diff --git a/React/Views/RCTRefreshControl.m b/React/Views/RCTRefreshControl.m index b26bb03371ed56..24090c83e41011 100644 --- a/React/Views/RCTRefreshControl.m +++ b/React/Views/RCTRefreshControl.m @@ -12,6 +12,8 @@ @implementation RCTRefreshControl { BOOL _isInitialRender; BOOL _currentRefreshingState; + UInt64 _currentRefreshingStateClock; + UInt64 _currentRefreshingStateTimestamp; BOOL _refreshingProgrammatically; NSString *_title; UIColor *_titleColor; @@ -21,6 +23,8 @@ - (instancetype)init { if ((self = [super init])) { [self addTarget:self action:@selector(refreshControlValueChanged) forControlEvents:UIControlEventValueChanged]; + _currentRefreshingStateClock = 1; + _currentRefreshingStateTimestamp = 0; _isInitialRender = true; _currentRefreshingState = false; } @@ -49,6 +53,7 @@ - (void)layoutSubviews - (void)beginRefreshingProgrammatically { + UInt64 beginRefreshingTimestamp = _currentRefreshingStateTimestamp; _refreshingProgrammatically = YES; // When using begin refreshing we need to adjust the ScrollView content offset manually. UIScrollView *scrollView = (UIScrollView *)self.superview; @@ -62,7 +67,10 @@ - (void)beginRefreshingProgrammatically animations:^(void) { [scrollView setContentOffset:offset]; } completion:^(__unused BOOL finished) { - [super beginRefreshing]; + if(beginRefreshingTimestamp == self->_currentRefreshingStateTimestamp) { + [super beginRefreshing]; + [self setCurrentRefreshingState:super.refreshing]; + } }]; } @@ -72,6 +80,7 @@ - (void)endRefreshingProgrammatically // endRefreshing otherwise the next pull to refresh will not work properly. UIScrollView *scrollView = (UIScrollView *)self.superview; if (_refreshingProgrammatically && scrollView.contentOffset.y < 0) { + UInt64 endRefreshingTimestamp = _currentRefreshingStateTimestamp; CGPoint offset = {scrollView.contentOffset.x, 0}; [UIView animateWithDuration:0.25 delay:0 @@ -79,7 +88,10 @@ - (void)endRefreshingProgrammatically animations:^(void) { [scrollView setContentOffset:offset]; } completion:^(__unused BOOL finished) { - [super endRefreshing]; + if(endRefreshingTimestamp == self->_currentRefreshingStateTimestamp) { + [super endRefreshing]; + [self setCurrentRefreshingState:super.refreshing]; + } }]; } else { [super endRefreshing]; @@ -120,7 +132,7 @@ - (void)_updateTitle - (void)setRefreshing:(BOOL)refreshing { if (_currentRefreshingState != refreshing) { - _currentRefreshingState = refreshing; + [self setCurrentRefreshingState:refreshing]; if (refreshing) { if (!_isInitialRender) { @@ -132,9 +144,15 @@ - (void)setRefreshing:(BOOL)refreshing } } +- (void)setCurrentRefreshingState:(BOOL)refreshing +{ + _currentRefreshingState = refreshing; + _currentRefreshingStateTimestamp = _currentRefreshingStateClock++; +} + - (void)refreshControlValueChanged { - _currentRefreshingState = super.refreshing; + [self setCurrentRefreshingState:super.refreshing]; _refreshingProgrammatically = NO; if (_onRefresh) { diff --git a/React/Views/ScrollView/RCTScrollView.h b/React/Views/ScrollView/RCTScrollView.h index 3404422c7b00da..6ef40fa840857d 100644 --- a/React/Views/ScrollView/RCTScrollView.h +++ b/React/Views/ScrollView/RCTScrollView.h @@ -44,6 +44,7 @@ @property (nonatomic, assign) NSTimeInterval scrollEventThrottle; @property (nonatomic, assign) BOOL centerContent; @property (nonatomic, copy) NSDictionary *maintainVisibleContentPosition; +@property (nonatomic, assign) BOOL scrollToOverflowEnabled; @property (nonatomic, assign) int snapToInterval; @property (nonatomic, copy) NSArray *snapToOffsets; @property (nonatomic, assign) BOOL snapToStart; diff --git a/React/Views/ScrollView/RCTScrollView.m b/React/Views/ScrollView/RCTScrollView.m index 58bff0f0fd2c25..46b2a69b48907a 100644 --- a/React/Views/ScrollView/RCTScrollView.m +++ b/React/Views/ScrollView/RCTScrollView.m @@ -588,8 +588,19 @@ - (void)scrollToOffset:(CGPoint)offset - (void)scrollToOffset:(CGPoint)offset animated:(BOOL)animated { if (!CGPointEqualToPoint(_scrollView.contentOffset, offset)) { + CGRect maxRect = CGRectMake(fmin(-_scrollView.contentInset.left, 0), + fmin(-_scrollView.contentInset.top, 0), + fmax(_scrollView.contentSize.width - _scrollView.bounds.size.width + _scrollView.contentInset.right + fmax(_scrollView.contentInset.left, 0), 0.01), + fmax(_scrollView.contentSize.height - _scrollView.bounds.size.height + _scrollView.contentInset.bottom + fmax(_scrollView.contentInset.top, 0), 0.01)); // Make width and height greater than 0 // Ensure at least one scroll event will fire _allowNextScrollNoMatterWhat = YES; + if (!CGRectContainsPoint(maxRect, offset) && !self.scrollToOverflowEnabled) { + CGFloat x = fmax(offset.x, CGRectGetMinX(maxRect)); + x = fmin(x, CGRectGetMaxX(maxRect)); + CGFloat y = fmax(offset.y, CGRectGetMinY(maxRect)); + y = fmin(y, CGRectGetMaxY(maxRect)); + offset = CGPointMake(x, y); + } [_scrollView setContentOffset:offset animated:animated]; } } diff --git a/React/Views/ScrollView/RCTScrollViewManager.m b/React/Views/ScrollView/RCTScrollViewManager.m index 6494d52f48fb29..a9714f8dfe9536 100644 --- a/React/Views/ScrollView/RCTScrollViewManager.m +++ b/React/Views/ScrollView/RCTScrollViewManager.m @@ -80,6 +80,7 @@ - (UIView *)view RCT_EXPORT_VIEW_PROPERTY(zoomScale, CGFloat) RCT_EXPORT_VIEW_PROPERTY(contentInset, UIEdgeInsets) RCT_EXPORT_VIEW_PROPERTY(scrollIndicatorInsets, UIEdgeInsets) +RCT_EXPORT_VIEW_PROPERTY(scrollToOverflowEnabled, BOOL) RCT_EXPORT_VIEW_PROPERTY(snapToInterval, int) RCT_EXPORT_VIEW_PROPERTY(snapToOffsets, NSArray) RCT_EXPORT_VIEW_PROPERTY(snapToStart, BOOL) diff --git a/ReactAndroid/build.gradle b/ReactAndroid/build.gradle index effbf2efdf15f0..4300a8423069c6 100644 --- a/ReactAndroid/build.gradle +++ b/ReactAndroid/build.gradle @@ -274,7 +274,7 @@ android { defaultConfig { minSdkVersion(16) - targetSdkVersion(27) + targetSdkVersion(28) versionCode(1) versionName("1.0") diff --git a/ReactAndroid/gradle.properties b/ReactAndroid/gradle.properties index 5decf540444471..5f2d7a9f4d3418 100644 --- a/ReactAndroid/gradle.properties +++ b/ReactAndroid/gradle.properties @@ -1,4 +1,4 @@ -VERSION_NAME=1000.0.0-master +VERSION_NAME=0.59.6 GROUP=com.facebook.react POM_NAME=ReactNative diff --git a/ReactAndroid/src/main/AndroidManifest.xml b/ReactAndroid/src/main/AndroidManifest.xml index 900169cc7c5012..ec2751f1bac2fd 100644 --- a/ReactAndroid/src/main/AndroidManifest.xml +++ b/ReactAndroid/src/main/AndroidManifest.xml @@ -1,7 +1,5 @@ - - diff --git a/ReactAndroid/src/main/java/com/facebook/react/ReactPackage.java b/ReactAndroid/src/main/java/com/facebook/react/ReactPackage.java index 527db0ace2e544..7bf8569d7bc00c 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/ReactPackage.java +++ b/ReactAndroid/src/main/java/com/facebook/react/ReactPackage.java @@ -34,10 +34,12 @@ public interface ReactPackage { * @param reactContext react application context that can be used to create modules * @return list of native modules to register with the newly created catalyst instance */ + @Nonnull List createNativeModules(@Nonnull ReactApplicationContext reactContext); /** * @return a list of view managers that should be registered with {@link UIManagerModule} */ + @Nonnull List createViewManagers(@Nonnull ReactApplicationContext reactContext); } diff --git a/ReactAndroid/src/main/java/com/facebook/react/modules/core/DeviceEventManagerModule.java b/ReactAndroid/src/main/java/com/facebook/react/modules/core/DeviceEventManagerModule.java index 56109af8af0ec1..c78527208ccbc0 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/modules/core/DeviceEventManagerModule.java +++ b/ReactAndroid/src/main/java/com/facebook/react/modules/core/DeviceEventManagerModule.java @@ -7,6 +7,7 @@ package com.facebook.react.modules.core; +import javax.annotation.Nonnull; import javax.annotation.Nullable; import android.net.Uri; @@ -27,7 +28,7 @@ public class DeviceEventManagerModule extends ReactContextBaseJavaModule { public static final String NAME = "DeviceEventManager"; public interface RCTDeviceEventEmitter extends JavaScriptModule { - void emit(String eventName, @Nullable Object data); + void emit(@Nonnull String eventName, @Nullable Object data); } private final Runnable mInvokeDefaultBackPressRunnable; diff --git a/ReactAndroid/src/main/java/com/facebook/react/modules/location/BUCK b/ReactAndroid/src/main/java/com/facebook/react/modules/location/BUCK index 37df1e9b950d93..8ba313dee7add3 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/modules/location/BUCK +++ b/ReactAndroid/src/main/java/com/facebook/react/modules/location/BUCK @@ -8,6 +8,7 @@ rn_android_library( ], deps = [ react_native_dep("libraries/fbcore/src/main/java/com/facebook/common/logging:logging"), + react_native_dep("third-party/android/support/v4:lib-support-v4"), react_native_dep("third-party/java/infer-annotations:infer-annotations"), react_native_dep("third-party/java/jsr-305:jsr-305"), react_native_target("java/com/facebook/react/bridge:bridge"), diff --git a/ReactAndroid/src/main/java/com/facebook/react/modules/location/LocationModule.java b/ReactAndroid/src/main/java/com/facebook/react/modules/location/LocationModule.java index 22d6b9f405ee36..520eb2947a1b1c 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/modules/location/LocationModule.java +++ b/ReactAndroid/src/main/java/com/facebook/react/modules/location/LocationModule.java @@ -9,6 +9,7 @@ import android.annotation.SuppressLint; import android.content.Context; +import android.content.pm.PackageManager; import android.location.Location; import android.location.LocationListener; import android.location.LocationManager; @@ -16,6 +17,7 @@ import android.os.Build; import android.os.Bundle; import android.os.Handler; +import android.support.v4.content.ContextCompat; import com.facebook.common.logging.FLog; import com.facebook.react.bridge.Arguments; import com.facebook.react.bridge.Callback; @@ -193,7 +195,7 @@ public void stopObserving() { } @Nullable - private static String getValidProvider(LocationManager locationManager, boolean highAccuracy) { + private String getValidProvider(LocationManager locationManager, boolean highAccuracy) { String provider = highAccuracy ? LocationManager.GPS_PROVIDER : LocationManager.NETWORK_PROVIDER; if (!locationManager.isProviderEnabled(provider)) { @@ -204,6 +206,11 @@ private static String getValidProvider(LocationManager locationManager, boolean return null; } } + // If it's an enabled provider, but we don't have permissions, ignore it + int finePermission = ContextCompat.checkSelfPermission(getReactApplicationContext(), android.Manifest.permission.ACCESS_FINE_LOCATION); + if (provider.equals(LocationManager.GPS_PROVIDER) && finePermission != PackageManager.PERMISSION_GRANTED) { + return null; + } return provider; } diff --git a/ReactAndroid/src/main/java/com/facebook/react/modules/network/ForwardingCookieHandler.java b/ReactAndroid/src/main/java/com/facebook/react/modules/network/ForwardingCookieHandler.java index 222a7ce463652c..2ad5e8fc59989e 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/modules/network/ForwardingCookieHandler.java +++ b/ReactAndroid/src/main/java/com/facebook/react/modules/network/ForwardingCookieHandler.java @@ -56,7 +56,10 @@ public ForwardingCookieHandler(ReactContext context) { @Override public Map> get(URI uri, Map> headers) throws IOException { - String cookies = getCookieManager().getCookie(uri.toString()); + CookieManager cookieManager = getCookieManager(); + if (cookieManager == null) return Collections.emptyMap(); + + String cookies = cookieManager.getCookie(uri.toString()); if (TextUtils.isEmpty(cookies)) { return Collections.emptyMap(); } @@ -80,7 +83,10 @@ public void clearCookies(final Callback callback) { new GuardedResultAsyncTask(mContext) { @Override protected Boolean doInBackgroundGuarded() { - getCookieManager().removeAllCookie(); + CookieManager cookieManager = getCookieManager(); + if (cookieManager != null) { + cookieManager.removeAllCookie(); + } mCookieSaver.onCookiesModified(); return true; } @@ -96,31 +102,40 @@ protected void onPostExecuteGuarded(Boolean result) { } private void clearCookiesAsync(final Callback callback) { - getCookieManager().removeAllCookies( - new ValueCallback() { - @Override - public void onReceiveValue(Boolean value) { - mCookieSaver.onCookiesModified(); - callback.invoke(value); - } - }); + CookieManager cookieManager = getCookieManager(); + if (cookieManager != null) { + cookieManager.removeAllCookies( + new ValueCallback() { + @Override + public void onReceiveValue(Boolean value) { + mCookieSaver.onCookiesModified(); + callback.invoke(value); + } + }); + } } public void destroy() { if (USES_LEGACY_STORE) { - getCookieManager().removeExpiredCookie(); + CookieManager cookieManager = getCookieManager(); + if (cookieManager != null) { + cookieManager.removeExpiredCookie(); + } mCookieSaver.persistCookies(); } } private void addCookies(final String url, final List cookies) { + final CookieManager cookieManager = getCookieManager(); + if (cookieManager == null) return; + if (USES_LEGACY_STORE) { runInBackground( new Runnable() { @Override public void run() { for (String cookie : cookies) { - getCookieManager().setCookie(url, cookie); + cookieManager.setCookie(url, cookie); } mCookieSaver.onCookiesModified(); } @@ -129,14 +144,17 @@ public void run() { for (String cookie : cookies) { addCookieAsync(url, cookie); } - getCookieManager().flush(); + cookieManager.flush(); mCookieSaver.onCookiesModified(); } } @TargetApi(21) private void addCookieAsync(String url, String cookie) { - getCookieManager().setCookie(url, cookie, null); + CookieManager cookieManager = getCookieManager(); + if (cookieManager != null) { + cookieManager.setCookie(url, cookie, null); + } } private static boolean isCookieHeader(String name) { @@ -156,10 +174,15 @@ protected void doInBackgroundGuarded(Void... params) { * Instantiating CookieManager in KitKat+ will load the Chromium task taking a 100ish ms so we * do it lazily to make sure it's done on a background thread as needed. */ - private CookieManager getCookieManager() { + private @Nullable CookieManager getCookieManager() { if (mCookieManager == null) { possiblyWorkaroundSyncManager(mContext); - mCookieManager = CookieManager.getInstance(); + try { + mCookieManager = CookieManager.getInstance(); + } catch (IllegalArgumentException ex) { + // https://bugs.chromium.org/p/chromium/issues/detail?id=559720 + return null; + } if (USES_LEGACY_STORE) { mCookieManager.removeExpiredCookie(); @@ -228,7 +251,10 @@ public void run() { @TargetApi(21) private void flush() { - getCookieManager().flush(); + CookieManager cookieManager = getCookieManager(); + if (cookieManager != null) { + cookieManager.flush(); + } } } } diff --git a/ReactAndroid/src/main/java/com/facebook/react/modules/network/HeaderUtil.java b/ReactAndroid/src/main/java/com/facebook/react/modules/network/HeaderUtil.java new file mode 100644 index 00000000000000..2f2d72bb90c3e3 --- /dev/null +++ b/ReactAndroid/src/main/java/com/facebook/react/modules/network/HeaderUtil.java @@ -0,0 +1,47 @@ +/** + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +package com.facebook.react.modules.network; + +/** + * + * The class purpose is to weaken too strict OkHttp restriction on http headers. + * See: https://github.com/square/okhttp/issues/2016 + * Auth headers might have an Authentication information. It is better to get 401 from the + * server in this case, rather than non descriptive error as 401 could be handled to invalidate + * the wrong token in the client code. + */ +public class HeaderUtil { + + public static String stripHeaderName(String name) { + StringBuilder builder = new StringBuilder(name.length()); + boolean modified = false; + for (int i = 0, length = name.length(); i < length; i++) { + char c = name.charAt(i); + if (c > '\u0020' && c < '\u007f') { + builder.append(c); + } else { + modified = true; + } + } + return modified ? builder.toString() : name; + } + + public static String stripHeaderValue(String value) { + StringBuilder builder = new StringBuilder(value.length()); + boolean modified = false; + for (int i = 0, length = value.length(); i < length; i++) { + char c = value.charAt(i); + if ((c > '\u001f' && c < '\u007f') || c == '\t' ) { + builder.append(c); + } else { + modified = true; + } + } + return modified ? builder.toString() : value; + } +} diff --git a/ReactAndroid/src/main/java/com/facebook/react/modules/network/NetworkingModule.java b/ReactAndroid/src/main/java/com/facebook/react/modules/network/NetworkingModule.java index eb84d6e33d9c24..cbae1f0fbb0062 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/modules/network/NetworkingModule.java +++ b/ReactAndroid/src/main/java/com/facebook/react/modules/network/NetworkingModule.java @@ -9,6 +9,7 @@ import android.net.Uri; import android.util.Base64; +import com.facebook.common.logging.FLog; import com.facebook.react.bridge.Arguments; import com.facebook.react.bridge.GuardedAsyncTask; import com.facebook.react.bridge.ReactApplicationContext; @@ -104,6 +105,7 @@ public interface ResponseHandler { protected static final String NAME = "Networking"; + private static final String TAG = "NetworkingModule"; private static final String CONTENT_ENCODING_HEADER_NAME = "content-encoding"; private static final String CONTENT_TYPE_HEADER_NAME = "content-type"; private static final String REQUEST_BODY_KEY_STRING = "string"; @@ -234,10 +236,29 @@ public void removeResponseHandler(ResponseHandler handler) { } @ReactMethod + public void sendRequest( + String method, + String url, + final int requestId, + ReadableArray headers, + ReadableMap data, + final String responseType, + final boolean useIncrementalUpdates, + int timeout, + boolean withCredentials) { + try { + sendRequestInternal(method, url, requestId, headers, data, responseType, + useIncrementalUpdates, timeout, withCredentials); + } catch (Throwable th) { + FLog.e(TAG, "Failed to send url request: " + url, th); + ResponseUtil.onRequestError(getEventEmitter(), requestId, th.getMessage(), th); + } + } + /** * @param timeout value of 0 results in no timeout */ - public void sendRequest( + public void sendRequestInternal( String method, String url, final int requestId, @@ -372,7 +393,13 @@ public void onProgress(long bytesWritten, long contentLength, boolean done) { return; } } else { - requestBody = RequestBody.create(contentMediaType, body); + // Use getBytes() to convert the body into a byte[], preventing okhttp from + // appending the character set to the Content-Type header when otherwise unspecified + // https://github.com/facebook/react-native/issues/8237 + Charset charset = contentMediaType == null + ? StandardCharsets.UTF_8 + : contentMediaType.charset(StandardCharsets.UTF_8); + requestBody = RequestBody.create(contentMediaType, body.getBytes(charset)); } } else if (data.hasKey(REQUEST_BODY_KEY_BASE64)) { if (contentType == null) { @@ -714,8 +741,8 @@ public void clearCookies(com.facebook.react.bridge.Callback callback) { if (header == null || header.size() != 2) { return null; } - String headerName = header.getString(0); - String headerValue = header.getString(1); + String headerName = HeaderUtil.stripHeaderName(header.getString(0)); + String headerValue = HeaderUtil.stripHeaderValue(header.getString(1)); if (headerName == null || headerValue == null) { return null; } diff --git a/ReactAndroid/src/main/java/com/facebook/react/modules/network/OkHttpClientProvider.java b/ReactAndroid/src/main/java/com/facebook/react/modules/network/OkHttpClientProvider.java index ceeaf874a2a8e7..34aefeabbb1276 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/modules/network/OkHttpClientProvider.java +++ b/ReactAndroid/src/main/java/com/facebook/react/modules/network/OkHttpClientProvider.java @@ -13,6 +13,8 @@ import com.facebook.common.logging.FLog; import java.io.File; +import java.security.Provider; +import java.security.Security; import java.util.ArrayList; import java.util.List; import java.util.concurrent.TimeUnit; @@ -69,7 +71,14 @@ public static OkHttpClient.Builder createClientBuilder() { .writeTimeout(0, TimeUnit.MILLISECONDS) .cookieJar(new ReactCookieJarContainer()); - return enableTls12OnPreLollipop(client); + try { + Class ConscryptProvider = Class.forName("org.conscrypt.OpenSSLProvider"); + Security.insertProviderAt( + (Provider) ConscryptProvider.newInstance(), 1); + return client; + } catch (Exception e) { + return enableTls12OnPreLollipop(client); + } } public static OkHttpClient.Builder createClientBuilder(Context context) { diff --git a/ReactAndroid/src/main/java/com/facebook/react/modules/network/ResponseUtil.java b/ReactAndroid/src/main/java/com/facebook/react/modules/network/ResponseUtil.java index f163ae7746792c..9ad7bffdac0303 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/modules/network/ResponseUtil.java +++ b/ReactAndroid/src/main/java/com/facebook/react/modules/network/ResponseUtil.java @@ -85,7 +85,7 @@ public static void onRequestError( RCTDeviceEventEmitter eventEmitter, int requestId, String error, - IOException e) { + Throwable e) { WritableArray args = Arguments.createArray(); args.pushInt(requestId); args.pushString(error); diff --git a/ReactAndroid/src/main/java/com/facebook/react/modules/systeminfo/ReactNativeVersion.java b/ReactAndroid/src/main/java/com/facebook/react/modules/systeminfo/ReactNativeVersion.java index 6278912404c943..c897e51c2d9f19 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/modules/systeminfo/ReactNativeVersion.java +++ b/ReactAndroid/src/main/java/com/facebook/react/modules/systeminfo/ReactNativeVersion.java @@ -16,7 +16,7 @@ public class ReactNativeVersion { public static final Map VERSION = MapBuilder.of( "major", 0, - "minor", 0, - "patch", 0, + "minor", 59, + "patch", 6, "prerelease", null); } diff --git a/ReactAndroid/src/main/java/com/facebook/react/uimanager/AccessibilityDelegateUtil.java b/ReactAndroid/src/main/java/com/facebook/react/uimanager/AccessibilityDelegateUtil.java index 617773b24eb0fc..aeffe238a91ba8 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/uimanager/AccessibilityDelegateUtil.java +++ b/ReactAndroid/src/main/java/com/facebook/react/uimanager/AccessibilityDelegateUtil.java @@ -9,6 +9,9 @@ import android.support.v4.view.AccessibilityDelegateCompat; import android.support.v4.view.ViewCompat; import android.support.v4.view.accessibility.AccessibilityNodeInfoCompat; +import android.support.v4.view.accessibility.AccessibilityNodeInfoCompat.CollectionItemInfoCompat; +import android.text.SpannableString; +import android.text.style.URLSpan; import android.view.View; import com.facebook.react.R; import java.util.Locale; @@ -98,7 +101,6 @@ public static void setDelegate(final View view) { public void onInitializeAccessibilityNodeInfo( View host, AccessibilityNodeInfoCompat info) { super.onInitializeAccessibilityNodeInfo(host, info); - setRole(info, accessibilityRole, view.getContext()); if (!(accessibilityHint == null)) { String contentDescription=(String)info.getContentDescription(); if (contentDescription != null) { @@ -108,6 +110,8 @@ public void onInitializeAccessibilityNodeInfo( info.setContentDescription(accessibilityHint); } } + + setRole(info, accessibilityRole, view.getContext()); } }); } @@ -127,6 +131,18 @@ public static void setRole(AccessibilityNodeInfoCompat nodeInfo, AccessibilityRo if (Locale.getDefault().getLanguage().equals(new Locale("en").getLanguage())) { if (role.equals(AccessibilityRole.LINK)) { nodeInfo.setRoleDescription(context.getString(R.string.link_description)); + + if (nodeInfo.getContentDescription() != null) { + SpannableString spannable = new SpannableString(nodeInfo.getContentDescription()); + spannable.setSpan(new URLSpan(""), 0, spannable.length(), 0); + nodeInfo.setContentDescription(spannable); + } + + if (nodeInfo.getText() != null) { + SpannableString spannable = new SpannableString(nodeInfo.getText()); + spannable.setSpan(new URLSpan(""), 0, spannable.length(), 0); + nodeInfo.setText(spannable); + } } if (role.equals(AccessibilityRole.SEARCH)) { nodeInfo.setRoleDescription(context.getString(R.string.search_description)); @@ -140,6 +156,12 @@ public static void setRole(AccessibilityNodeInfoCompat nodeInfo, AccessibilityRo if (role.equals(AccessibilityRole.ADJUSTABLE)) { nodeInfo.setRoleDescription(context.getString(R.string.adjustable_description)); } + if (role.equals(AccessibilityRole.HEADER)) { + nodeInfo.setRoleDescription(context.getString(R.string.header_description)); + final AccessibilityNodeInfoCompat.CollectionItemInfoCompat itemInfo = + AccessibilityNodeInfoCompat.CollectionItemInfoCompat.obtain(0, 1, 0, 1, true); + nodeInfo.setCollectionItemInfo(itemInfo); + } } if (role.equals(AccessibilityRole.IMAGEBUTTON)) { nodeInfo.setClickable(true); diff --git a/ReactAndroid/src/main/java/com/facebook/react/uimanager/BaseViewManager.java b/ReactAndroid/src/main/java/com/facebook/react/uimanager/BaseViewManager.java index e7d003854bec89..88fcf056601cbe 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/uimanager/BaseViewManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/uimanager/BaseViewManager.java @@ -15,7 +15,9 @@ import com.facebook.react.uimanager.AccessibilityDelegateUtil.AccessibilityRole; import com.facebook.react.uimanager.annotations.ReactProp; import com.facebook.react.uimanager.util.ReactFindViewUtil; -import java.util.Locale; + +import javax.annotation.Nonnull; +import javax.annotation.Nullable; /** * Base class that should be suitable for the majority of subclasses of {@link ViewManager}. @@ -58,12 +60,12 @@ public abstract class BaseViewManager= Build.VERSION_CODES.LOLLIPOP) { - view.setElevation(PixelUtil.toPixelFromDIP(elevation)); - } - // Do nothing on API < 21 + public void setElevation(@Nonnull T view, float elevation) { + ViewCompat.setElevation(view, PixelUtil.toPixelFromDIP(elevation)); } @ReactProp(name = PROP_Z_INDEX) - public void setZIndex(T view, float zIndex) { + public void setZIndex(@Nonnull T view, float zIndex) { int integerZIndex = Math.round(zIndex); ViewGroupManager.setViewZIndex(view, integerZIndex); ViewParent parent = view.getParent(); @@ -95,12 +94,12 @@ public void setZIndex(T view, float zIndex) { } @ReactProp(name = PROP_RENDER_TO_HARDWARE_TEXTURE) - public void setRenderToHardwareTexture(T view, boolean useHWTexture) { + public void setRenderToHardwareTexture(@Nonnull T view, boolean useHWTexture) { view.setLayerType(useHWTexture ? View.LAYER_TYPE_HARDWARE : View.LAYER_TYPE_NONE, null); } @ReactProp(name = PROP_TEST_ID) - public void setTestId(T view, String testId) { + public void setTestId(@Nonnull T view, String testId) { view.setTag(R.id.react_test_id, testId); // temporarily set the tag and keyed tags to avoid end to end test regressions @@ -108,28 +107,28 @@ public void setTestId(T view, String testId) { } @ReactProp(name = PROP_NATIVE_ID) - public void setNativeId(T view, String nativeId) { + public void setNativeId(@Nonnull T view, String nativeId) { view.setTag(R.id.view_tag_native_id, nativeId); ReactFindViewUtil.notifyViewRendered(view); } @ReactProp(name = PROP_ACCESSIBILITY_LABEL) - public void setAccessibilityLabel(T view, String accessibilityLabel) { + public void setAccessibilityLabel(@Nonnull T view, String accessibilityLabel) { view.setContentDescription(accessibilityLabel); } @ReactProp(name = PROP_ACCESSIBILITY_COMPONENT_TYPE) - public void setAccessibilityComponentType(T view, String accessibilityComponentType) { + public void setAccessibilityComponentType(@Nonnull T view, String accessibilityComponentType) { AccessibilityHelper.updateAccessibilityComponentType(view, accessibilityComponentType); } @ReactProp(name = PROP_ACCESSIBILITY_HINT) - public void setAccessibilityHint(T view, String accessibilityHint) { + public void setAccessibilityHint(@Nonnull T view, String accessibilityHint) { view.setTag(R.id.accessibility_hint, accessibilityHint); } @ReactProp(name = PROP_ACCESSIBILITY_ROLE) - public void setAccessibilityRole(T view, String accessibilityRole) { + public void setAccessibilityRole(@Nonnull T view, @Nullable String accessibilityRole) { if (accessibilityRole == null) { return; } @@ -138,7 +137,7 @@ public void setAccessibilityRole(T view, String accessibilityRole) { } @ReactProp(name = PROP_ACCESSIBILITY_STATES) - public void setViewStates(T view, ReadableArray accessibilityStates) { + public void setViewStates(@Nonnull T view, @Nullable ReadableArray accessibilityStates) { view.setSelected(false); view.setEnabled(true); if (accessibilityStates == null) { @@ -155,7 +154,7 @@ public void setViewStates(T view, ReadableArray accessibilityStates) { } @ReactProp(name = PROP_IMPORTANT_FOR_ACCESSIBILITY) - public void setImportantForAccessibility(T view, String importantForAccessibility) { + public void setImportantForAccessibility(@Nonnull T view, @Nullable String importantForAccessibility) { if (importantForAccessibility == null || importantForAccessibility.equals("auto")) { ViewCompat.setImportantForAccessibility(view, ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_AUTO); } else if (importantForAccessibility.equals("yes")) { @@ -169,48 +168,46 @@ public void setImportantForAccessibility(T view, String importantForAccessibilit @Deprecated @ReactProp(name = PROP_ROTATION) - public void setRotation(T view, float rotation) { + public void setRotation(@Nonnull T view, float rotation) { view.setRotation(rotation); } @Deprecated @ReactProp(name = PROP_SCALE_X, defaultFloat = 1f) - public void setScaleX(T view, float scaleX) { + public void setScaleX(@Nonnull T view, float scaleX) { view.setScaleX(scaleX); } @Deprecated @ReactProp(name = PROP_SCALE_Y, defaultFloat = 1f) - public void setScaleY(T view, float scaleY) { + public void setScaleY(@Nonnull T view, float scaleY) { view.setScaleY(scaleY); } @Deprecated @ReactProp(name = PROP_TRANSLATE_X, defaultFloat = 0f) - public void setTranslateX(T view, float translateX) { + public void setTranslateX(@Nonnull T view, float translateX) { view.setTranslationX(PixelUtil.toPixelFromDIP(translateX)); } @Deprecated @ReactProp(name = PROP_TRANSLATE_Y, defaultFloat = 0f) - public void setTranslateY(T view, float translateY) { + public void setTranslateY(@Nonnull T view, float translateY) { view.setTranslationY(PixelUtil.toPixelFromDIP(translateY)); } @ReactProp(name = PROP_ACCESSIBILITY_LIVE_REGION) - public void setAccessibilityLiveRegion(T view, String liveRegion) { - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { + public void setAccessibilityLiveRegion(@Nonnull T view, @Nullable String liveRegion) { if (liveRegion == null || liveRegion.equals("none")) { - view.setAccessibilityLiveRegion(View.ACCESSIBILITY_LIVE_REGION_NONE); + ViewCompat.setAccessibilityLiveRegion(view, ViewCompat.ACCESSIBILITY_LIVE_REGION_NONE); } else if (liveRegion.equals("polite")) { - view.setAccessibilityLiveRegion(View.ACCESSIBILITY_LIVE_REGION_POLITE); + ViewCompat.setAccessibilityLiveRegion(view, ViewCompat.ACCESSIBILITY_LIVE_REGION_POLITE); } else if (liveRegion.equals("assertive")) { - view.setAccessibilityLiveRegion(View.ACCESSIBILITY_LIVE_REGION_ASSERTIVE); + ViewCompat.setAccessibilityLiveRegion(view, ViewCompat.ACCESSIBILITY_LIVE_REGION_ASSERTIVE); } - } } - private static void setTransformProperty(View view, ReadableArray transforms) { + private static void setTransformProperty(@Nonnull View view, ReadableArray transforms) { TransformHelper.processTransform(transforms, sTransformDecompositionArray); MatrixMathHelper.decomposeMatrix(sTransformDecompositionArray, sMatrixDecompositionContext); view.setTranslationX( @@ -246,7 +243,7 @@ private static void setTransformProperty(View view, ReadableArray transforms) { } } - private static void resetTransformProperty(View view) { + private static void resetTransformProperty(@Nonnull View view) { view.setTranslationX(PixelUtil.toPixelFromDIP(0)); view.setTranslationY(PixelUtil.toPixelFromDIP(0)); view.setRotation(0); @@ -257,12 +254,12 @@ private static void resetTransformProperty(View view) { view.setCameraDistance(0); } - private void updateViewAccessibility(T view) { + private void updateViewAccessibility(@Nonnull T view) { AccessibilityDelegateUtil.setDelegate(view); } @Override - protected void onAfterUpdateTransaction(T view) { + protected void onAfterUpdateTransaction(@Nonnull T view) { super.onAfterUpdateTransaction(view); updateViewAccessibility(view); } diff --git a/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIImplementation.java b/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIImplementation.java index aceed54ef7b61a..fa630887080ddb 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIImplementation.java +++ b/ReactAndroid/src/main/java/com/facebook/react/uimanager/UIImplementation.java @@ -43,6 +43,7 @@ * shadow node hierarchy that is then mapped to a native view hierarchy. */ public class UIImplementation { + protected Object uiImplementationThreadLock = new Object(); protected final EventDispatcher mEventDispatcher; protected final ReactApplicationContext mReactContext; @@ -197,23 +198,25 @@ public void updateRootView( */ public void registerRootView( T rootView, int tag, ThemedReactContext context) { - final ReactShadowNode rootCSSNode = createRootShadowNode(); - rootCSSNode.setReactTag(tag); - rootCSSNode.setThemedContext(context); - - int widthMeasureSpec = rootView.getWidthMeasureSpec(); - int heightMeasureSpec = rootView.getHeightMeasureSpec(); - updateRootView(rootCSSNode, widthMeasureSpec, heightMeasureSpec); - - context.runOnNativeModulesQueueThread(new Runnable() { - @Override - public void run() { - mShadowNodeRegistry.addRootNode(rootCSSNode); - } - }); + synchronized (uiImplementationThreadLock) { + final ReactShadowNode rootCSSNode = createRootShadowNode(); + rootCSSNode.setReactTag(tag); + rootCSSNode.setThemedContext(context); + + int widthMeasureSpec = rootView.getWidthMeasureSpec(); + int heightMeasureSpec = rootView.getHeightMeasureSpec(); + updateRootView(rootCSSNode, widthMeasureSpec, heightMeasureSpec); + + context.runOnNativeModulesQueueThread(new Runnable() { + @Override + public void run() { + mShadowNodeRegistry.addRootNode(rootCSSNode); + } + }); - // register it within NativeViewHierarchyManager - mOperationsQueue.addRootView(tag, rootView, context); + // register it within NativeViewHierarchyManager + mOperationsQueue.addRootView(tag, rootView, context); + } } /** @@ -228,7 +231,9 @@ public void removeRootView(int rootViewTag) { * Unregisters a root node with a given tag from the shadow node registry */ public void removeRootShadowNode(int rootViewTag) { - mShadowNodeRegistry.removeRootNode(rootViewTag); + synchronized (uiImplementationThreadLock) { + mShadowNodeRegistry.removeRootNode(rootViewTag); + } } /** @@ -279,23 +284,25 @@ public Map getProfiledBatchPerfCounters() { * Invoked by React to create a new node with a given tag, class name and properties. */ public void createView(int tag, String className, int rootViewTag, ReadableMap props) { - ReactShadowNode cssNode = createShadowNode(className); - ReactShadowNode rootNode = mShadowNodeRegistry.getNode(rootViewTag); - Assertions.assertNotNull(rootNode, "Root node with tag " + rootViewTag + " doesn't exist"); - cssNode.setReactTag(tag); - cssNode.setViewClassName(className); - cssNode.setRootTag(rootNode.getReactTag()); - cssNode.setThemedContext(rootNode.getThemedContext()); - - mShadowNodeRegistry.addNode(cssNode); + synchronized (uiImplementationThreadLock) { + ReactShadowNode cssNode = createShadowNode(className); + ReactShadowNode rootNode = mShadowNodeRegistry.getNode(rootViewTag); + Assertions.assertNotNull(rootNode, "Root node with tag " + rootViewTag + " doesn't exist"); + cssNode.setReactTag(tag); + cssNode.setViewClassName(className); + cssNode.setRootTag(rootNode.getReactTag()); + cssNode.setThemedContext(rootNode.getThemedContext()); + + mShadowNodeRegistry.addNode(cssNode); + + ReactStylesDiffMap styles = null; + if (props != null) { + styles = new ReactStylesDiffMap(props); + cssNode.updateProperties(styles); + } - ReactStylesDiffMap styles = null; - if (props != null) { - styles = new ReactStylesDiffMap(props); - cssNode.updateProperties(styles); + handleCreateView(cssNode, rootViewTag, styles); } - - handleCreateView(cssNode, rootViewTag, styles); } protected void handleCreateView( @@ -363,106 +370,108 @@ public void manageChildren( @Nullable ReadableArray addChildTags, @Nullable ReadableArray addAtIndices, @Nullable ReadableArray removeFrom) { - ReactShadowNode cssNodeToManage = mShadowNodeRegistry.getNode(viewTag); + synchronized (uiImplementationThreadLock) { + ReactShadowNode cssNodeToManage = mShadowNodeRegistry.getNode(viewTag); - int numToMove = moveFrom == null ? 0 : moveFrom.size(); - int numToAdd = addChildTags == null ? 0 : addChildTags.size(); - int numToRemove = removeFrom == null ? 0 : removeFrom.size(); + int numToMove = moveFrom == null ? 0 : moveFrom.size(); + int numToAdd = addChildTags == null ? 0 : addChildTags.size(); + int numToRemove = removeFrom == null ? 0 : removeFrom.size(); - if (numToMove != 0 && (moveTo == null || numToMove != moveTo.size())) { - throw new IllegalViewOperationException("Size of moveFrom != size of moveTo!"); - } + if (numToMove != 0 && (moveTo == null || numToMove != moveTo.size())) { + throw new IllegalViewOperationException("Size of moveFrom != size of moveTo!"); + } - if (numToAdd != 0 && (addAtIndices == null || numToAdd != addAtIndices.size())) { - throw new IllegalViewOperationException("Size of addChildTags != size of addAtIndices!"); - } + if (numToAdd != 0 && (addAtIndices == null || numToAdd != addAtIndices.size())) { + throw new IllegalViewOperationException("Size of addChildTags != size of addAtIndices!"); + } - // We treat moves as an add and a delete - ViewAtIndex[] viewsToAdd = new ViewAtIndex[numToMove + numToAdd]; - int[] indicesToRemove = new int[numToMove + numToRemove]; - int[] tagsToRemove = new int[indicesToRemove.length]; - int[] tagsToDelete = new int[numToRemove]; - - if (numToMove > 0) { - Assertions.assertNotNull(moveFrom); - Assertions.assertNotNull(moveTo); - for (int i = 0; i < numToMove; i++) { - int moveFromIndex = moveFrom.getInt(i); - int tagToMove = cssNodeToManage.getChildAt(moveFromIndex).getReactTag(); - viewsToAdd[i] = new ViewAtIndex( - tagToMove, - moveTo.getInt(i)); - indicesToRemove[i] = moveFromIndex; - tagsToRemove[i] = tagToMove; + // We treat moves as an add and a delete + ViewAtIndex[] viewsToAdd = new ViewAtIndex[numToMove + numToAdd]; + int[] indicesToRemove = new int[numToMove + numToRemove]; + int[] tagsToRemove = new int[indicesToRemove.length]; + int[] tagsToDelete = new int[numToRemove]; + + if (numToMove > 0) { + Assertions.assertNotNull(moveFrom); + Assertions.assertNotNull(moveTo); + for (int i = 0; i < numToMove; i++) { + int moveFromIndex = moveFrom.getInt(i); + int tagToMove = cssNodeToManage.getChildAt(moveFromIndex).getReactTag(); + viewsToAdd[i] = new ViewAtIndex( + tagToMove, + moveTo.getInt(i)); + indicesToRemove[i] = moveFromIndex; + tagsToRemove[i] = tagToMove; + } } - } - if (numToAdd > 0) { - Assertions.assertNotNull(addChildTags); - Assertions.assertNotNull(addAtIndices); - for (int i = 0; i < numToAdd; i++) { - int viewTagToAdd = addChildTags.getInt(i); - int indexToAddAt = addAtIndices.getInt(i); - viewsToAdd[numToMove + i] = new ViewAtIndex(viewTagToAdd, indexToAddAt); + if (numToAdd > 0) { + Assertions.assertNotNull(addChildTags); + Assertions.assertNotNull(addAtIndices); + for (int i = 0; i < numToAdd; i++) { + int viewTagToAdd = addChildTags.getInt(i); + int indexToAddAt = addAtIndices.getInt(i); + viewsToAdd[numToMove + i] = new ViewAtIndex(viewTagToAdd, indexToAddAt); + } } - } - if (numToRemove > 0) { - Assertions.assertNotNull(removeFrom); - for (int i = 0; i < numToRemove; i++) { - int indexToRemove = removeFrom.getInt(i); - int tagToRemove = cssNodeToManage.getChildAt(indexToRemove).getReactTag(); - indicesToRemove[numToMove + i] = indexToRemove; - tagsToRemove[numToMove + i] = tagToRemove; - tagsToDelete[i] = tagToRemove; + if (numToRemove > 0) { + Assertions.assertNotNull(removeFrom); + for (int i = 0; i < numToRemove; i++) { + int indexToRemove = removeFrom.getInt(i); + int tagToRemove = cssNodeToManage.getChildAt(indexToRemove).getReactTag(); + indicesToRemove[numToMove + i] = indexToRemove; + tagsToRemove[numToMove + i] = tagToRemove; + tagsToDelete[i] = tagToRemove; + } } - } - // NB: moveFrom and removeFrom are both relative to the starting state of the View's children. - // moveTo and addAt are both relative to the final state of the View's children. - // - // 1) Sort the views to add and indices to remove by index - // 2) Iterate the indices being removed from high to low and remove them. Going high to low - // makes sure we remove the correct index when there are multiple to remove. - // 3) Iterate the views being added by index low to high and add them. Like the view removal, - // iteration direction is important to preserve the correct index. - - Arrays.sort(viewsToAdd, ViewAtIndex.COMPARATOR); - Arrays.sort(indicesToRemove); - - // Apply changes to CSSNodeDEPRECATED hierarchy - int lastIndexRemoved = -1; - for (int i = indicesToRemove.length - 1; i >= 0; i--) { - int indexToRemove = indicesToRemove[i]; - if (indexToRemove == lastIndexRemoved) { - throw new IllegalViewOperationException("Repeated indices in Removal list for view tag: " - + viewTag); + // NB: moveFrom and removeFrom are both relative to the starting state of the View's children. + // moveTo and addAt are both relative to the final state of the View's children. + // + // 1) Sort the views to add and indices to remove by index + // 2) Iterate the indices being removed from high to low and remove them. Going high to low + // makes sure we remove the correct index when there are multiple to remove. + // 3) Iterate the views being added by index low to high and add them. Like the view removal, + // iteration direction is important to preserve the correct index. + + Arrays.sort(viewsToAdd, ViewAtIndex.COMPARATOR); + Arrays.sort(indicesToRemove); + + // Apply changes to CSSNodeDEPRECATED hierarchy + int lastIndexRemoved = -1; + for (int i = indicesToRemove.length - 1; i >= 0; i--) { + int indexToRemove = indicesToRemove[i]; + if (indexToRemove == lastIndexRemoved) { + throw new IllegalViewOperationException("Repeated indices in Removal list for view tag: " + + viewTag); + } + cssNodeToManage.removeChildAt(indicesToRemove[i]); + lastIndexRemoved = indicesToRemove[i]; } - cssNodeToManage.removeChildAt(indicesToRemove[i]); - lastIndexRemoved = indicesToRemove[i]; - } - for (int i = 0; i < viewsToAdd.length; i++) { - ViewAtIndex viewAtIndex = viewsToAdd[i]; - ReactShadowNode cssNodeToAdd = mShadowNodeRegistry.getNode(viewAtIndex.mTag); - if (cssNodeToAdd == null) { - throw new IllegalViewOperationException("Trying to add unknown view tag: " - + viewAtIndex.mTag); + for (int i = 0; i < viewsToAdd.length; i++) { + ViewAtIndex viewAtIndex = viewsToAdd[i]; + ReactShadowNode cssNodeToAdd = mShadowNodeRegistry.getNode(viewAtIndex.mTag); + if (cssNodeToAdd == null) { + throw new IllegalViewOperationException("Trying to add unknown view tag: " + + viewAtIndex.mTag); + } + cssNodeToManage.addChildAt(cssNodeToAdd, viewAtIndex.mIndex); } - cssNodeToManage.addChildAt(cssNodeToAdd, viewAtIndex.mIndex); - } - if (!cssNodeToManage.isVirtual() && !cssNodeToManage.isVirtualAnchor()) { - mNativeViewHierarchyOptimizer.handleManageChildren( - cssNodeToManage, - indicesToRemove, - tagsToRemove, - viewsToAdd, - tagsToDelete); - } + if (!cssNodeToManage.isVirtual() && !cssNodeToManage.isVirtualAnchor()) { + mNativeViewHierarchyOptimizer.handleManageChildren( + cssNodeToManage, + indicesToRemove, + tagsToRemove, + viewsToAdd, + tagsToDelete); + } - for (int i = 0; i < tagsToDelete.length; i++) { - removeShadowNode(mShadowNodeRegistry.getNode(tagsToDelete[i])); + for (int i = 0; i < tagsToDelete.length; i++) { + removeShadowNode(mShadowNodeRegistry.getNode(tagsToDelete[i])); + } } } @@ -476,22 +485,23 @@ public void manageChildren( public void setChildren( int viewTag, ReadableArray childrenTags) { - - ReactShadowNode cssNodeToManage = mShadowNodeRegistry.getNode(viewTag); - - for (int i = 0; i < childrenTags.size(); i++) { - ReactShadowNode cssNodeToAdd = mShadowNodeRegistry.getNode(childrenTags.getInt(i)); - if (cssNodeToAdd == null) { - throw new IllegalViewOperationException("Trying to add unknown view tag: " - + childrenTags.getInt(i)); + synchronized (uiImplementationThreadLock) { + ReactShadowNode cssNodeToManage = mShadowNodeRegistry.getNode(viewTag); + + for (int i = 0; i < childrenTags.size(); i++) { + ReactShadowNode cssNodeToAdd = mShadowNodeRegistry.getNode(childrenTags.getInt(i)); + if (cssNodeToAdd == null) { + throw new IllegalViewOperationException("Trying to add unknown view tag: " + + childrenTags.getInt(i)); + } + cssNodeToManage.addChildAt(cssNodeToAdd, i); } - cssNodeToManage.addChildAt(cssNodeToAdd, i); - } - if (!cssNodeToManage.isVirtual() && !cssNodeToManage.isVirtualAnchor()) { - mNativeViewHierarchyOptimizer.handleSetChildren( - cssNodeToManage, - childrenTags); + if (!cssNodeToManage.isVirtual() && !cssNodeToManage.isVirtualAnchor()) { + mNativeViewHierarchyOptimizer.handleSetChildren( + cssNodeToManage, + childrenTags); + } } } diff --git a/ReactAndroid/src/main/java/com/facebook/react/uimanager/ViewManager.java b/ReactAndroid/src/main/java/com/facebook/react/uimanager/ViewManager.java index 75087c755aab0e..1b0cab7f0f90c3 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/uimanager/ViewManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/uimanager/ViewManager.java @@ -20,6 +20,8 @@ import com.facebook.react.uimanager.annotations.ReactPropertyHolder; import com.facebook.yoga.YogaMeasureMode; import java.util.Map; + +import javax.annotation.Nonnull; import javax.annotation.Nullable; /** @@ -31,7 +33,7 @@ public abstract class ViewManager extends BaseJavaModule { - public final void updateProperties(T viewToUpdate, ReactStylesDiffMap props) { + public final void updateProperties(@Nonnull T viewToUpdate, ReactStylesDiffMap props) { ViewManagerPropertyUpdater.updateProps(this, viewToUpdate, props); onAfterUpdateTransaction(viewToUpdate); } @@ -39,8 +41,8 @@ public final void updateProperties(T viewToUpdate, ReactStylesDiffMap props) { /** * Creates a view and installs event emitters on it. */ - public final T createView( - ThemedReactContext reactContext, + public final @Nonnull T createView( + @Nonnull ThemedReactContext reactContext, JSResponderHandler jsResponderHandler) { T view = createViewInstance(reactContext); addEventEmitters(reactContext, view); @@ -54,7 +56,7 @@ public final T createView( * @return the name of this view manager. This will be the name used to reference this view * manager from JavaScript in createReactNativeComponentClass. */ - public abstract String getName(); + public abstract @Nonnull String getName(); /** * This method should return a subclass of {@link ReactShadowNode} which will be then used for @@ -65,7 +67,7 @@ public C createShadowNodeInstance() { throw new RuntimeException("ViewManager subclasses must implement createShadowNodeInstance()"); } - public C createShadowNodeInstance(ReactApplicationContext context) { + public @Nonnull C createShadowNodeInstance(@Nonnull ReactApplicationContext context) { return createShadowNodeInstance(); } @@ -85,13 +87,13 @@ public C createShadowNodeInstance(ReactApplicationContext context) { * Subclasses should return a new View instance of the proper type. * @param reactContext */ - protected abstract T createViewInstance(ThemedReactContext reactContext); + protected abstract @Nonnull T createViewInstance(@Nonnull ThemedReactContext reactContext); /** * Called when view is detached from view hierarchy and allows for some additional cleanup by * the {@link ViewManager} subclass. */ - public void onDropViewInstance(T view) { + public void onDropViewInstance(@Nonnull T view) { } /** @@ -99,7 +101,7 @@ public void onDropViewInstance(T view) { * might want to override this method if your view needs to emit events besides basic touch events * to JS (e.g. scroll events). */ - protected void addEventEmitters(ThemedReactContext reactContext, T view) { + protected void addEventEmitters(@Nonnull ThemedReactContext reactContext, @Nonnull T view) { } /** @@ -108,7 +110,7 @@ protected void addEventEmitters(ThemedReactContext reactContext, T view) { * you want to override this method you should call super.onAfterUpdateTransaction from it as * the parent class of the ViewManager may rely on callback being executed. */ - protected void onAfterUpdateTransaction(T view) { + protected void onAfterUpdateTransaction(@Nonnull T view) { } /** @@ -122,7 +124,7 @@ protected void onAfterUpdateTransaction(T view) { * * TODO(7247021): Replace updateExtraData with generic update props mechanism after D2086999 */ - public abstract void updateExtraData(T root, Object extraData); + public abstract void updateExtraData(@Nonnull T root, Object extraData); /** * Subclasses may use this method to receive events/commands directly from JS through the @@ -133,7 +135,7 @@ protected void onAfterUpdateTransaction(T view) { * @param commandId code of the command * @param args optional arguments for the command */ - public void receiveCommand(T root, int commandId, @Nullable ReadableArray args) { + public void receiveCommand(@Nonnull T root, int commandId, @Nullable ReadableArray args) { } /** @@ -209,7 +211,7 @@ public Map getNativeProps() { /** * */ - public @Nullable Object updateLocalData(T view, ReactStylesDiffMap props, ReactStylesDiffMap localData) { + public @Nullable Object updateLocalData(@Nonnull T view, ReactStylesDiffMap props, ReactStylesDiffMap localData) { return null; } diff --git a/ReactAndroid/src/main/java/com/facebook/react/util/JSStackTrace.java b/ReactAndroid/src/main/java/com/facebook/react/util/JSStackTrace.java index a80101533e87b3..1a58a8f168433c 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/util/JSStackTrace.java +++ b/ReactAndroid/src/main/java/com/facebook/react/util/JSStackTrace.java @@ -24,8 +24,18 @@ public static String format(String message, ReadableArray stack) { stringBuilder .append(frame.getString("methodName")) .append("@") - .append(parseFileId(frame)) - .append(frame.getInt("lineNumber")); + .append(parseFileId(frame)); + + if (frame.hasKey("lineNumber") && + !frame.isNull("lineNumber") && + frame.getType("lineNumber") == ReadableType.Number) { + stringBuilder + .append(frame.getInt("lineNumber")); + } else { + stringBuilder + .append(-1); + } + if (frame.hasKey("column") && !frame.isNull("column") && frame.getType("column") == ReadableType.Number) { @@ -33,6 +43,7 @@ public static String format(String message, ReadableArray stack) { .append(":") .append(frame.getInt("column")); } + stringBuilder.append("\n"); } return stringBuilder.toString(); diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/switchview/ReactSwitch.java b/ReactAndroid/src/main/java/com/facebook/react/views/switchview/ReactSwitch.java index 64d0d444816253..acaaf1b96feca9 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/switchview/ReactSwitch.java +++ b/ReactAndroid/src/main/java/com/facebook/react/views/switchview/ReactSwitch.java @@ -36,6 +36,7 @@ public void setChecked(boolean checked) { if (mAllowChange && isChecked() != checked) { mAllowChange = false; super.setChecked(checked); + setTrackColor(checked); } } @@ -59,8 +60,7 @@ public void setThumbColor(@Nullable Integer color) { // If the switch has a different value than the value sent by JS, we must change it. if (isChecked() != on) { super.setChecked(on); - Integer currentTrackColor = on ? mTrackColorForTrue : mTrackColorForFalse; - setTrackColor(currentTrackColor); + setTrackColor(on); } mAllowChange = true; } @@ -86,4 +86,13 @@ public void setTrackColorForFalse(@Nullable Integer color) { setTrackColor(mTrackColorForFalse); } } + + private void setTrackColor(boolean checked) { + if (mTrackColorForTrue != null || mTrackColorForFalse != null) { + // Update the track color to reflect the new value. We only want to do this if these + // props were actually set from JS; otherwise we'll just reset the color to the default. + Integer currentTrackColor = checked ? mTrackColorForTrue : mTrackColorForFalse; + setTrackColor(currentTrackColor); + } + } } diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/text/BUCK b/ReactAndroid/src/main/java/com/facebook/react/views/text/BUCK index 449f27adafead5..2008eda3ce16a3 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/text/BUCK +++ b/ReactAndroid/src/main/java/com/facebook/react/views/text/BUCK @@ -9,6 +9,8 @@ rn_android_library( ], deps = [ YOGA_TARGET, + react_native_dep("third-party/android/support/v4:lib-support-v4"), + react_native_dep("third-party/android/support/v7/appcompat-orig:appcompat"), react_native_dep("libraries/fbcore/src/main/java/com/facebook/common/logging:logging"), react_native_dep("third-party/java/infer-annotations:infer-annotations"), react_native_dep("third-party/java/jsr-305:jsr-305"), diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactBaseTextShadowNode.java b/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactBaseTextShadowNode.java index ec00cd5b30662e..e5c94e0084f971 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactBaseTextShadowNode.java +++ b/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactBaseTextShadowNode.java @@ -265,6 +265,9 @@ private static int parseNumericFontWeight(String fontWeightString) { protected int mTextAlign = Gravity.NO_GRAVITY; protected int mTextBreakStrategy = (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) ? 0 : Layout.BREAK_STRATEGY_HIGH_QUALITY; + protected int mJustificationMode = + (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) ? 0 : Layout.JUSTIFICATION_MODE_NONE; + protected TextTransform mTextTransform = TextTransform.UNSET; protected float mTextShadowOffsetDx = 0; protected float mTextShadowOffsetDy = 0; @@ -312,10 +315,10 @@ public ReactBaseTextShadowNode() { private int getTextAlign() { int textAlign = mTextAlign; if (getLayoutDirection() == YogaDirection.RTL) { - if (textAlign == Gravity.RIGHT) { - textAlign = Gravity.LEFT; - } else if (textAlign == Gravity.LEFT) { - textAlign = Gravity.RIGHT; + if (textAlign == Gravity.END) { + textAlign = Gravity.START; + } else if (textAlign == Gravity.START) { + textAlign = Gravity.END; } } return textAlign; @@ -357,19 +360,28 @@ public void setMaxFontSizeMultiplier(float maxFontSizeMultiplier) { @ReactProp(name = ViewProps.TEXT_ALIGN) public void setTextAlign(@Nullable String textAlign) { - if (textAlign == null || "auto".equals(textAlign)) { - mTextAlign = Gravity.NO_GRAVITY; - } else if ("left".equals(textAlign)) { - mTextAlign = Gravity.LEFT; - } else if ("right".equals(textAlign)) { - mTextAlign = Gravity.RIGHT; - } else if ("center".equals(textAlign)) { - mTextAlign = Gravity.CENTER_HORIZONTAL; - } else if ("justify".equals(textAlign)) { - // Fallback gracefully for cross-platform compat instead of error - mTextAlign = Gravity.LEFT; + if ("justify".equals(textAlign)) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + mJustificationMode = Layout.JUSTIFICATION_MODE_INTER_WORD; + } + mTextAlign = Gravity.START; } else { - throw new JSApplicationIllegalArgumentException("Invalid textAlign: " + textAlign); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + mJustificationMode = Layout.JUSTIFICATION_MODE_NONE; + } + + if (textAlign == null || "auto".equals(textAlign)) { + mTextAlign = Gravity.NO_GRAVITY; + } else if ("left".equals(textAlign)) { + mTextAlign = Gravity.START; + } else if ("right".equals(textAlign)) { + mTextAlign = Gravity.END; + } else if ("center".equals(textAlign)) { + mTextAlign = Gravity.CENTER_HORIZONTAL; + } else { + throw new JSApplicationIllegalArgumentException("Invalid textAlign: " + textAlign); + } + } markUpdated(); } diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactTextShadowNode.java b/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactTextShadowNode.java index eaef5690304b33..e5eaf49ff01df9 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactTextShadowNode.java +++ b/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactTextShadowNode.java @@ -76,10 +76,10 @@ public long measure( Layout.Alignment alignment = Layout.Alignment.ALIGN_NORMAL; switch (getTextAlign()) { - case Gravity.LEFT: + case Gravity.START: alignment = Layout.Alignment.ALIGN_NORMAL; break; - case Gravity.RIGHT: + case Gravity.END: alignment = Layout.Alignment.ALIGN_OPPOSITE; break; case Gravity.CENTER_HORIZONTAL: @@ -99,14 +99,18 @@ public long measure( new StaticLayout( text, textPaint, hintWidth, alignment, 1.f, 0.f, mIncludeFontPadding); } else { - layout = + StaticLayout.Builder builder = StaticLayout.Builder.obtain(text, 0, text.length(), textPaint, hintWidth) - .setAlignment(alignment) - .setLineSpacing(0.f, 1.f) - .setIncludePad(mIncludeFontPadding) - .setBreakStrategy(mTextBreakStrategy) - .setHyphenationFrequency(Layout.HYPHENATION_FREQUENCY_NORMAL) - .build(); + .setAlignment(alignment) + .setLineSpacing(0.f, 1.f) + .setIncludePad(mIncludeFontPadding) + .setBreakStrategy(mTextBreakStrategy) + .setHyphenationFrequency(Layout.HYPHENATION_FREQUENCY_NORMAL); + + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + builder.setJustificationMode(mJustificationMode); + } + layout = builder.build(); } } else if (boring != null && (unconstrainedWidth || boring.width <= width)) { @@ -175,10 +179,10 @@ private void initMeasureFunction() { private int getTextAlign() { int textAlign = mTextAlign; if (getLayoutDirection() == YogaDirection.RTL) { - if (textAlign == Gravity.RIGHT) { - textAlign = Gravity.LEFT; - } else if (textAlign == Gravity.LEFT) { - textAlign = Gravity.RIGHT; + if (textAlign == Gravity.END) { + textAlign = Gravity.START; + } else if (textAlign == Gravity.START) { + textAlign = Gravity.END; } } return textAlign; @@ -217,7 +221,8 @@ public void onCollectExtraUpdates(UIViewOperationQueue uiViewOperationQueue) { getPadding(Spacing.END), getPadding(Spacing.BOTTOM), getTextAlign(), - mTextBreakStrategy); + mTextBreakStrategy, + mJustificationMode); uiViewOperationQueue.enqueueUpdateExtraData(getReactTag(), reactTextUpdate); } } diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactTextUpdate.java b/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactTextUpdate.java index c31bb3c55ea52d..fd1344f0fb714d 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactTextUpdate.java +++ b/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactTextUpdate.java @@ -26,6 +26,7 @@ public class ReactTextUpdate { private final float mPaddingBottom; private final int mTextAlign; private final int mTextBreakStrategy; + private final int mJustificationMode; /** * @deprecated Use a non-deprecated constructor for ReactTextUpdate instead. This one remains @@ -49,7 +50,8 @@ public ReactTextUpdate( paddingEnd, paddingBottom, textAlign, - Layout.BREAK_STRATEGY_HIGH_QUALITY); + Layout.BREAK_STRATEGY_HIGH_QUALITY, + Layout.JUSTIFICATION_MODE_NONE); } public ReactTextUpdate( @@ -61,7 +63,8 @@ public ReactTextUpdate( float paddingEnd, float paddingBottom, int textAlign, - int textBreakStrategy) { + int textBreakStrategy, + int justificationMode) { mText = text; mJsEventCounter = jsEventCounter; mContainsImages = containsImages; @@ -71,6 +74,7 @@ public ReactTextUpdate( mPaddingBottom = paddingBottom; mTextAlign = textAlign; mTextBreakStrategy = textBreakStrategy; + mJustificationMode = justificationMode; } public Spannable getText() { @@ -108,4 +112,8 @@ public int getTextAlign() { public int getTextBreakStrategy() { return mTextBreakStrategy; } + + public int getJustificationMode() { + return mJustificationMode; + } } diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactTextView.java b/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactTextView.java index f2f739b239c8a5..a804a46a94a6d5 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactTextView.java +++ b/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactTextView.java @@ -10,13 +10,13 @@ import android.content.Context; import android.graphics.drawable.Drawable; import android.os.Build; +import android.support.v7.widget.AppCompatTextView; import android.text.Layout; import android.text.Spannable; import android.text.Spanned; import android.text.TextUtils; import android.view.Gravity; import android.view.ViewGroup; -import android.widget.TextView; import com.facebook.common.logging.FLog; import com.facebook.react.common.ReactConstants; import com.facebook.react.uimanager.ReactCompoundView; @@ -24,7 +24,7 @@ import com.facebook.react.views.view.ReactViewBackgroundManager; import javax.annotation.Nullable; -public class ReactTextView extends TextView implements ReactCompoundView { +public class ReactTextView extends AppCompatTextView implements ReactCompoundView { private static final ViewGroup.LayoutParams EMPTY_LAYOUT_PARAMS = new ViewGroup.LayoutParams(0, 0); @@ -72,6 +72,11 @@ public void setText(ReactTextUpdate update) { setBreakStrategy(update.getTextBreakStrategy()); } } + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + if (getJustificationMode() != update.getJustificationMode()) { + setJustificationMode(update.getJustificationMode()); + } + } } @Override diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactTextViewManager.java b/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactTextViewManager.java index 226776b7dd6d0d..81323b335272d0 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactTextViewManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/views/text/ReactTextViewManager.java @@ -82,8 +82,10 @@ public Object updateLocalData(ReactTextView view, ReactStylesDiffMap props, Reac // TODO add textBreakStrategy prop into local Data int textBreakStrategy = Layout.BREAK_STRATEGY_HIGH_QUALITY; - return - new ReactTextUpdate( + // TODO add justificationMode prop into local Data + int justificationMode = Layout.JUSTIFICATION_MODE_NONE; + + return new ReactTextUpdate( spanned, -1, // TODO add this into local Data? false, // TODO add this into local Data @@ -92,7 +94,8 @@ public Object updateLocalData(ReactTextView view, ReactStylesDiffMap props, Reac textViewProps.getEndPadding(), textViewProps.getBottomPadding(), textViewProps.getTextAlign(), - textBreakStrategy + textBreakStrategy, + justificationMode ); } diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/text/TextAttributeProps.java b/ReactAndroid/src/main/java/com/facebook/react/views/text/TextAttributeProps.java index cbf49e34dc0e84..34ca9213b35ac0 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/text/TextAttributeProps.java +++ b/ReactAndroid/src/main/java/com/facebook/react/views/text/TextAttributeProps.java @@ -50,6 +50,8 @@ public class TextAttributeProps { protected int mTextAlign = Gravity.NO_GRAVITY; protected int mTextBreakStrategy = (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) ? 0 : Layout.BREAK_STRATEGY_HIGH_QUALITY; + protected int mJustificationMode = + (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) ? 0 : Layout.JUSTIFICATION_MODE_NONE; protected TextTransform mTextTransform = TextTransform.UNSET; protected float mTextShadowOffsetDx = 0; @@ -162,10 +164,10 @@ public float getEffectiveLineHeight() { public int getTextAlign() { int textAlign = mTextAlign; if (getLayoutDirection() == YogaDirection.RTL) { - if (textAlign == Gravity.RIGHT) { - textAlign = Gravity.LEFT; - } else if (textAlign == Gravity.LEFT) { - textAlign = Gravity.RIGHT; + if (textAlign == Gravity.END) { + textAlign = Gravity.START; + } else if (textAlign == Gravity.START) { + textAlign = Gravity.END; } } return textAlign; @@ -204,19 +206,28 @@ public void setAllowFontScaling(boolean allowFontScaling) { } public void setTextAlign(@Nullable String textAlign) { - if (textAlign == null || "auto".equals(textAlign)) { - mTextAlign = Gravity.NO_GRAVITY; - } else if ("left".equals(textAlign)) { - mTextAlign = Gravity.LEFT; - } else if ("right".equals(textAlign)) { - mTextAlign = Gravity.RIGHT; - } else if ("center".equals(textAlign)) { - mTextAlign = Gravity.CENTER_HORIZONTAL; - } else if ("justify".equals(textAlign)) { - // Fallback gracefully for cross-platform compat instead of error - mTextAlign = Gravity.LEFT; + if ("justify".equals(textAlign)) { + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + mJustificationMode = Layout.JUSTIFICATION_MODE_INTER_WORD; + } + mTextAlign = Gravity.START; } else { - throw new JSApplicationIllegalArgumentException("Invalid textAlign: " + textAlign); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + mJustificationMode = Layout.JUSTIFICATION_MODE_NONE; + } + + if (textAlign == null || "auto".equals(textAlign)) { + mTextAlign = Gravity.NO_GRAVITY; + } else if ("left".equals(textAlign)) { + mTextAlign = Gravity.START; + } else if ("right".equals(textAlign)) { + mTextAlign = Gravity.END; + } else if ("center".equals(textAlign)) { + mTextAlign = Gravity.CENTER_HORIZONTAL; + } else { + throw new JSApplicationIllegalArgumentException("Invalid textAlign: " + textAlign); + } + } } diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/textinput/BUCK b/ReactAndroid/src/main/java/com/facebook/react/views/textinput/BUCK index 3c29c2262fcb4f..69b9d0f593b6a8 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/textinput/BUCK +++ b/ReactAndroid/src/main/java/com/facebook/react/views/textinput/BUCK @@ -12,6 +12,7 @@ rn_android_library( ], deps = [ YOGA_TARGET, + react_native_dep("libraries/fbcore/src/main/java/com/facebook/common/logging:logging"), react_native_dep("third-party/java/infer-annotations:infer-annotations"), react_native_dep("third-party/java/jsr-305:jsr-305"), react_native_target("java/com/facebook/react/bridge:bridge"), diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactEditText.java b/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactEditText.java index e8d24d7ea73aa4..f603bfb847193e 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactEditText.java +++ b/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactEditText.java @@ -236,6 +236,10 @@ public void setContentSizeWatcher(ContentSizeWatcher contentSizeWatcher) { mContentSizeWatcher = contentSizeWatcher; } + public void setMostRecentEventCount(int mostRecentEventCount) { + mMostRecentEventCount = mostRecentEventCount; + } + public void setScrollWatcher(ScrollWatcher scrollWatcher) { mScrollWatcher = scrollWatcher; } diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputManager.java b/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputManager.java index 363511025c190d..62da81900d6749 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputManager.java @@ -7,13 +7,18 @@ package com.facebook.react.views.textinput; +import static android.view.View.FOCUS_FORWARD; + +import android.annotation.TargetApi; import android.graphics.PorterDuff; import android.graphics.Typeface; import android.graphics.drawable.Drawable; +import android.os.Build; import android.support.v4.content.ContextCompat; import android.text.Editable; import android.text.InputFilter; import android.text.InputType; +import android.text.Layout; import android.text.Spannable; import android.text.TextWatcher; import android.util.TypedValue; @@ -22,6 +27,7 @@ import android.view.View; import android.view.inputmethod.EditorInfo; import android.widget.TextView; +import com.facebook.common.logging.FLog; import com.facebook.infer.annotation.Assertions; import com.facebook.react.bridge.JSApplicationIllegalArgumentException; import com.facebook.react.bridge.ReactContext; @@ -59,7 +65,7 @@ */ @ReactModule(name = ReactTextInputManager.REACT_CLASS) public class ReactTextInputManager extends BaseViewManager { - + public static final String TAG = ReactTextInputManager.class.getSimpleName(); protected static final String REACT_CLASS = "AndroidTextInput"; private static final int[] SPACING_TYPES = { @@ -69,7 +75,7 @@ public class ReactTextInputManager extends BaseViewManager= Build.VERSION_CODES.O) { + view.setJustificationMode(Layout.JUSTIFICATION_MODE_INTER_WORD); + } + view.setGravityHorizontal(Gravity.START); } else { - throw new JSApplicationIllegalArgumentException("Invalid textAlign: " + textAlign); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + view.setJustificationMode(Layout.JUSTIFICATION_MODE_NONE); + } + + if (textAlign == null || "auto".equals(textAlign)) { + view.setGravityHorizontal(Gravity.NO_GRAVITY); + } else if ("left".equals(textAlign)) { + view.setGravityHorizontal(Gravity.START); + } else if ("right".equals(textAlign)) { + view.setGravityHorizontal(Gravity.END); + } else if ("center".equals(textAlign)) { + view.setGravityHorizontal(Gravity.CENTER_HORIZONTAL); + } else { + throw new JSApplicationIllegalArgumentException("Invalid textAlign: " + textAlign); + } + } } @@ -528,6 +571,46 @@ public void setMaxLength(ReactEditText view, @Nullable Integer maxLength) { view.setFilters(newFilters); } + @ReactProp(name = "autoComplete") + public void setTextContentType(ReactEditText view, @Nullable String autocomplete) { + // Autofill hints were added in Android API 26. + if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) { + return; + } + + if (autocomplete == null) { + view.setImportantForAutofill(View.IMPORTANT_FOR_AUTOFILL_NO); + } else if ("username".equals(autocomplete)) { + view.setAutofillHints(View.AUTOFILL_HINT_USERNAME); + } else if ("password".equals(autocomplete)) { + view.setAutofillHints(View.AUTOFILL_HINT_PASSWORD); + } else if ("email".equals(autocomplete)) { + view.setAutofillHints(View.AUTOFILL_HINT_EMAIL_ADDRESS); + } else if ("name".equals(autocomplete)) { + view.setAutofillHints(View.AUTOFILL_HINT_NAME); + } else if ("tel".equals(autocomplete)) { + view.setAutofillHints(View.AUTOFILL_HINT_PHONE); + } else if ("street-address".equals(autocomplete)) { + view.setAutofillHints(View.AUTOFILL_HINT_POSTAL_ADDRESS); + } else if ("postal-code".equals(autocomplete)) { + view.setAutofillHints(View.AUTOFILL_HINT_POSTAL_CODE); + } else if ("cc-number".equals(autocomplete)) { + view.setAutofillHints(View.AUTOFILL_HINT_CREDIT_CARD_NUMBER); + } else if ("cc-csc".equals(autocomplete)) { + view.setAutofillHints(View.AUTOFILL_HINT_CREDIT_CARD_SECURITY_CODE); + } else if ("cc-exp".equals(autocomplete)) { + view.setAutofillHints(View.AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_DATE); + } else if ("cc-exp-month".equals(autocomplete)) { + view.setAutofillHints(View.AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_MONTH); + } else if ("cc-exp-year".equals(autocomplete)) { + view.setAutofillHints(View.AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_YEAR); + } else if ("off".equals(autocomplete)) { + view.setImportantForAutofill(View.IMPORTANT_FOR_AUTOFILL_NO); + } else { + throw new JSApplicationIllegalArgumentException("Invalid autocomplete option: " + autocomplete); + } + } + @ReactProp(name = "autoCorrect") public void setAutoCorrect(ReactEditText view, @Nullable Boolean autoCorrect) { // clear auto correct flags, set SUGGESTIONS or NO_SUGGESTIONS depending on value @@ -812,6 +895,12 @@ public boolean onEditorAction(TextView v, int actionId, KeyEvent keyEvent) { // Prevent default behavior except when we want it to insert a newline. return blurOnSubmit || !isMultiline; + } else if (actionId == EditorInfo.IME_ACTION_NEXT) { + View v1 = v.focusSearch(FOCUS_FORWARD); + if (v1 != null && !v.requestFocus(FOCUS_FORWARD)) { + return true; + } + return false; } return true; diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputShadowNode.java b/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputShadowNode.java index 53efe02e06e46d..f40a05dde07cd9 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputShadowNode.java +++ b/ReactAndroid/src/main/java/com/facebook/react/views/textinput/ReactTextInputShadowNode.java @@ -204,7 +204,8 @@ public void onCollectExtraUpdates(UIViewOperationQueue uiViewOperationQueue) { getPadding(Spacing.RIGHT), getPadding(Spacing.BOTTOM), mTextAlign, - mTextBreakStrategy); + mTextBreakStrategy, + mJustificationMode); uiViewOperationQueue.enqueueUpdateExtraData(getReactTag(), reactTextUpdate); } } diff --git a/ReactAndroid/src/main/res/devsupport/xml/rn_dev_preferences.xml b/ReactAndroid/src/main/res/devsupport/xml/rn_dev_preferences.xml index bb98248b93f0da..c9b1e616ee6e36 100644 --- a/ReactAndroid/src/main/res/devsupport/xml/rn_dev_preferences.xml +++ b/ReactAndroid/src/main/res/devsupport/xml/rn_dev_preferences.xml @@ -23,7 +23,7 @@ android:key="js_bundle_deltas" android:title="Use JS Deltas" android:summary="Request delta bundles from metro to get faster reloads (Experimental)" - android:defaultValue="true" + android:defaultValue="false" /> Adjustable + Heading diff --git a/ReactAndroid/src/test/java/com/facebook/react/modules/network/HeaderUtilTest.java b/ReactAndroid/src/test/java/com/facebook/react/modules/network/HeaderUtilTest.java new file mode 100644 index 00000000000000..10e52ddc5474e3 --- /dev/null +++ b/ReactAndroid/src/test/java/com/facebook/react/modules/network/HeaderUtilTest.java @@ -0,0 +1,76 @@ +/** + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +package com.facebook.react.modules.network; + +import org.junit.Test; + +import static org.junit.Assert.assertEquals; + +public class HeaderUtilTest { + public static final String TABULATION_TEST = "\teyJhbGciOiJS\t"; + public static final String TABULATION_STRIP_EXPECTED = "eyJhbGciOiJS"; + public static final String NUMBERS_TEST = "0123456789"; + public static final String SPECIALS_TEST = "!@#$%^&*()-=_+{}[]\\|;:'\",.<>/?"; + public static final String ALPHABET_TEST = "abcdefghijklmnopqrstuvwxyzABCDEFGHIGKLMNOPQRSTUVWHYZ"; + public static final String VALUE_BANNED_SYMBOLS_TEST = "���name�����������\u007f\u001f"; + public static final String NAME_BANNED_SYMBOLS_TEST = "���name�����������\u007f\u0020\u001f"; + public static final String BANNED_TEST_EXPECTED = "name"; + + @Test + public void nameStripKeepsLetters() { + assertEquals(ALPHABET_TEST, HeaderUtil.stripHeaderName(ALPHABET_TEST)); + + } + + @Test + public void valueStripKeepsLetters() { + assertEquals(ALPHABET_TEST, HeaderUtil.stripHeaderValue(ALPHABET_TEST)); + } + + @Test + public void nameStripKeepsNumbers() { + assertEquals(NUMBERS_TEST, HeaderUtil.stripHeaderName(NUMBERS_TEST)); + + } + + @Test + public void valueStripKeepsNumbers() { + assertEquals(NUMBERS_TEST, HeaderUtil.stripHeaderValue(NUMBERS_TEST)); + } + + @Test + public void valueStripKeepsSpecials() { + assertEquals(SPECIALS_TEST, HeaderUtil.stripHeaderValue(SPECIALS_TEST)); + } + + @Test + public void nameStripKeepsSpecials() { + assertEquals(SPECIALS_TEST, HeaderUtil.stripHeaderName(SPECIALS_TEST)); + } + + @Test + public void valueStripKeepsTabs() { + assertEquals(TABULATION_TEST, HeaderUtil.stripHeaderValue(TABULATION_TEST)); + } + + @Test + public void nameStripDeletesTabs() { + assertEquals(TABULATION_STRIP_EXPECTED, HeaderUtil.stripHeaderName(TABULATION_TEST)); + } + + @Test + public void valueStripRemovesExtraSymbols() { + assertEquals(BANNED_TEST_EXPECTED, HeaderUtil.stripHeaderValue(VALUE_BANNED_SYMBOLS_TEST)); + } + + @Test + public void nameStripRemovesExtraSymbols() { + assertEquals(BANNED_TEST_EXPECTED, HeaderUtil.stripHeaderName(NAME_BANNED_SYMBOLS_TEST)); + } + +} diff --git a/ReactAndroid/src/test/java/com/facebook/react/modules/network/NetworkingModuleTest.java b/ReactAndroid/src/test/java/com/facebook/react/modules/network/NetworkingModuleTest.java index 39a5cf76533be7..cdbcb8908c057f 100644 --- a/ReactAndroid/src/test/java/com/facebook/react/modules/network/NetworkingModuleTest.java +++ b/ReactAndroid/src/test/java/com/facebook/react/modules/network/NetworkingModuleTest.java @@ -18,6 +18,7 @@ import com.facebook.react.bridge.ReactContext; import com.facebook.react.bridge.WritableArray; import com.facebook.react.bridge.WritableMap; +import com.facebook.react.common.StandardCharsets; import com.facebook.react.common.network.OkHttpCallUtil; import com.facebook.react.modules.core.DeviceEventManagerModule.RCTDeviceEventEmitter; @@ -247,7 +248,7 @@ public Object answer(InvocationOnMock invocation) throws Throwable { body.putString("string", "This is request body"); mockEvents(); - + networkingModule.sendRequest( "POST", "http://somedomain/bar", @@ -309,6 +310,131 @@ public Object answer(InvocationOnMock invocation) throws Throwable { assertThat(requestHeaders.get("User-Agent")).isEqualTo("React test agent/1.0"); } + @Test + public void testPostJsonContentTypeHeader() throws Exception { + OkHttpClient httpClient = mock(OkHttpClient.class); + when(httpClient.newCall(any(Request.class))).thenAnswer(new Answer() { + @Override + public Object answer(InvocationOnMock invocation) throws Throwable { + Call callMock = mock(Call.class); + return callMock; + } + }); + OkHttpClient.Builder clientBuilder = mock(OkHttpClient.Builder.class); + when(clientBuilder.build()).thenReturn(httpClient); + when(httpClient.newBuilder()).thenReturn(clientBuilder); + NetworkingModule networkingModule = + new NetworkingModule(mock(ReactApplicationContext.class), "", httpClient); + + JavaOnlyMap body = new JavaOnlyMap(); + body.putString("string", "{ \"key\": \"value\" }"); + + networkingModule.sendRequest( + "POST", + "http://somedomain/bar", + 0, + JavaOnlyArray.of(JavaOnlyArray.of("Content-Type", "application/json")), + body, + /* responseType */ "text", + /* useIncrementalUpdates*/ true, + /* timeout */ 0, + /* withCredentials */ false); + + ArgumentCaptor argumentCaptor = ArgumentCaptor.forClass(Request.class); + verify(httpClient).newCall(argumentCaptor.capture()); + + // Verify okhttp does not append "charset=utf-8" + assertThat(argumentCaptor.getValue().body().contentType().toString()).isEqualTo("application/json"); + } + + @Test + public void testRespectsExistingCharacterSet() throws Exception { + RCTDeviceEventEmitter emitter = mock(RCTDeviceEventEmitter.class); + ReactApplicationContext context = mock(ReactApplicationContext.class); + when(context.getJSModule(any(Class.class))).thenReturn(emitter); + + OkHttpClient httpClient = mock(OkHttpClient.class); + when(httpClient.newCall(any(Request.class))).thenAnswer(new Answer() { + @Override + public Object answer(InvocationOnMock invocation) throws Throwable { + Call callMock = mock(Call.class); + return callMock; + } + }); + OkHttpClient.Builder clientBuilder = mock(OkHttpClient.Builder.class); + when(clientBuilder.build()).thenReturn(httpClient); + when(httpClient.newBuilder()).thenReturn(clientBuilder); + NetworkingModule networkingModule = new NetworkingModule(context, "", httpClient); + + JavaOnlyMap body = new JavaOnlyMap(); + body.putString("string", "Friðjónsson"); + + mockEvents(); + + networkingModule.sendRequest( + "POST", + "http://somedomain/bar", + 0, + JavaOnlyArray.of(JavaOnlyArray.of("Content-Type", "text/plain; charset=utf-16")), + body, + /* responseType */ "text", + /* useIncrementalUpdates*/ true, + /* timeout */ 0, + /* withCredentials */ false); + + ArgumentCaptor argumentCaptor = ArgumentCaptor.forClass(Request.class); + verify(httpClient).newCall(argumentCaptor.capture()); + + Buffer contentBuffer = new Buffer(); + argumentCaptor.getValue().body().writeTo(contentBuffer); + assertThat(contentBuffer.readString(StandardCharsets.UTF_16)).isEqualTo("Friðjónsson"); + } + + @Test + public void testGracefullyRecoversFromInvalidContentType() throws Exception { + RCTDeviceEventEmitter emitter = mock(RCTDeviceEventEmitter.class); + ReactApplicationContext context = mock(ReactApplicationContext.class); + when(context.getJSModule(any(Class.class))).thenReturn(emitter); + + OkHttpClient httpClient = mock(OkHttpClient.class); + when(httpClient.newCall(any(Request.class))).thenAnswer(new Answer() { + @Override + public Object answer(InvocationOnMock invocation) throws Throwable { + Call callMock = mock(Call.class); + return callMock; + } + }); + OkHttpClient.Builder clientBuilder = mock(OkHttpClient.Builder.class); + when(clientBuilder.build()).thenReturn(httpClient); + when(httpClient.newBuilder()).thenReturn(clientBuilder); + NetworkingModule networkingModule = new NetworkingModule(context, "", httpClient); + + JavaOnlyMap body = new JavaOnlyMap(); + body.putString("string", "test"); + + mockEvents(); + + networkingModule.sendRequest( + "POST", + "http://somedomain/bar", + 0, + JavaOnlyArray.of(JavaOnlyArray.of("Content-Type", "invalid")), + body, + /* responseType */ "text", + /* useIncrementalUpdates*/ true, + /* timeout */ 0, + /* withCredentials */ false); + + ArgumentCaptor argumentCaptor = ArgumentCaptor.forClass(Request.class); + verify(httpClient).newCall(argumentCaptor.capture()); + + Buffer contentBuffer = new Buffer(); + argumentCaptor.getValue().body().writeTo(contentBuffer); + + assertThat(contentBuffer.readString(StandardCharsets.UTF_8)).isEqualTo("test"); + assertThat(argumentCaptor.getValue().header("Content-Type")).isEqualTo("invalid"); + } + @Test public void testMultipartPostRequestSimple() throws Exception { PowerMockito.mockStatic(RequestBodyUtil.class); diff --git a/ReactAndroid/src/test/java/com/facebook/react/views/text/ReactTextTest.java b/ReactAndroid/src/test/java/com/facebook/react/views/text/ReactTextTest.java index 7938bbffd2625f..05af680b549ab0 100644 --- a/ReactAndroid/src/test/java/com/facebook/react/views/text/ReactTextTest.java +++ b/ReactAndroid/src/test/java/com/facebook/react/views/text/ReactTextTest.java @@ -15,6 +15,7 @@ import android.graphics.Color; import android.graphics.Typeface; import android.graphics.drawable.Drawable; +import android.text.Layout; import android.text.Spanned; import android.text.TextUtils; import android.text.style.AbsoluteSizeSpan; @@ -419,6 +420,21 @@ public void testMaxLinesApplied() { assertThat(textView.getEllipsize()).isEqualTo(TextUtils.TruncateAt.END); } + @TargetApi(Build.VERSION_CODES.O) + @Test + public void testTextAlignJustifyApplied() { + UIManagerModule uiManager = getUIManagerModule(); + + ReactRootView rootView = createText( + uiManager, + JavaOnlyMap.of("textAlign", "justify"), + JavaOnlyMap.of(ReactRawTextShadowNode.PROP_TEXT, "test text")); + + TextView textView = (TextView) rootView.getChildAt(0); + assertThat(textView.getText().toString()).isEqualTo("test text"); + assertThat(textView.getJustificationMode()).isEqualTo(Layout.JUSTIFICATION_MODE_INTER_WORD); + } + /** * Make sure TextView has exactly one span and that span has given type. */ diff --git a/ReactAndroid/src/test/java/com/facebook/react/views/textinput/ReactTextInputPropertyTest.java b/ReactAndroid/src/test/java/com/facebook/react/views/textinput/ReactTextInputPropertyTest.java index 50fc92e218d3ed..3bf3865b6e298d 100644 --- a/ReactAndroid/src/test/java/com/facebook/react/views/textinput/ReactTextInputPropertyTest.java +++ b/ReactAndroid/src/test/java/com/facebook/react/views/textinput/ReactTextInputPropertyTest.java @@ -9,8 +9,10 @@ import android.content.res.ColorStateList; import android.graphics.Color; +import android.os.Build; import android.text.InputType; import android.text.InputFilter; +import android.text.Layout; import android.util.DisplayMetrics; import android.view.Gravity; import android.view.inputmethod.EditorInfo; @@ -344,6 +346,10 @@ public void testTextAlign() { assertThat(view.getGravity() & Gravity.HORIZONTAL_GRAVITY_MASK).isEqualTo(Gravity.CENTER_HORIZONTAL); mManager.updateProperties(view, buildStyles("textAlign", null)); assertThat(view.getGravity() & Gravity.HORIZONTAL_GRAVITY_MASK).isEqualTo(defaultHorizontalGravity); + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { + mManager.updateProperties(view, buildStyles("textAlign", "justify")); + assertThat(view.getJustificationMode()).isEqualTo(Layout.JUSTIFICATION_MODE_INTER_WORD); + } // TextAlignVertical mManager.updateProperties(view, buildStyles("textAlignVertical", "top")); diff --git a/ReactCommon/jsi/JSCRuntime.cpp b/ReactCommon/jsi/JSCRuntime.cpp index b1cbc68cd33aef..6656eee750a9e0 100644 --- a/ReactCommon/jsi/JSCRuntime.cpp +++ b/ReactCommon/jsi/JSCRuntime.cpp @@ -238,14 +238,10 @@ class JSCRuntime : public jsi::Runtime { // JSStringRef utilities namespace { std::string JSStringToSTLString(JSStringRef str) { - std::string result; size_t maxBytes = JSStringGetMaximumUTF8CStringSize(str); - result.resize(maxBytes); - size_t bytesWritten = JSStringGetUTF8CString(str, &result[0], maxBytes); - // JSStringGetUTF8CString writes the null terminator, so we want to resize - // to `bytesWritten - 1` so that `result` has the correct length. - result.resize(bytesWritten - 1); - return result; + std::vector buffer(maxBytes); + JSStringGetUTF8CString(str, buffer.data(), maxBytes); + return std::string(buffer.data()); } JSStringRef getLengthString() { diff --git a/build.gradle b/build.gradle index 080a3bb288f9b5..779aadaeb56920 100644 --- a/build.gradle +++ b/build.gradle @@ -10,7 +10,7 @@ buildscript { jcenter() } dependencies { - classpath("com.android.tools.build:gradle:3.3.0") + classpath("com.android.tools.build:gradle:3.3.1") classpath("de.undercouch:gradle-download-task:3.4.3") // NOTE: Do not place your application dependencies here; they belong diff --git a/jest-preset.js b/jest-preset.js index 249ec2d7b6dbe6..bd343328a06267 100644 --- a/jest-preset.js +++ b/jest-preset.js @@ -18,7 +18,6 @@ module.exports = { hasteImplModulePath: require.resolve('./jest/hasteImpl.js'), providesModuleNodeModules: ['react-native'], }, - moduleFileExtensions: ['js', 'json', 'jsx', 'node', 'ts', 'tsx'], moduleNameMapper: { '^React$': require.resolve('react'), }, @@ -30,11 +29,7 @@ module.exports = { ), }, transformIgnorePatterns: [ - 'node_modules/(?!(jest-)?react-native|react-clone-referenced-element)', - ], - testMatch: [ - '**/__tests__/**/*.(js|ts|tsx)', - '**/?(*.)+(spec|test).(js|ts|tsx)', + 'node_modules/(?!(jest-)?react-native|react-clone-referenced-element|@react-native-community)', ], setupFiles: [require.resolve('./jest/setup.js')], testEnvironment: 'node', diff --git a/jest/hasteImpl.js b/jest/hasteImpl.js index cee692a77051c3..2632a105aa5767 100644 --- a/jest/hasteImpl.js +++ b/jest/hasteImpl.js @@ -25,7 +25,8 @@ if (REACT_NATIVE_CI) { function getPlugins() { try { // @todo do not rely on private files - const findPlugins = require('@react-native-community/cli/build/core/findPlugins'); + const findPlugins = require('@react-native-community/cli/build/core/findPlugins') + .default; return findPlugins(path.resolve(__dirname, pluginsPath)); } catch (e) { diff --git a/package.json b/package.json index 20fc02a94a1cc8..1eda078894b095 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-native", - "version": "1000.0.0", + "version": "0.59.6", "description": "A framework for building native apps using React", "license": "MIT", "repository": { @@ -109,6 +109,7 @@ "cli.js", "flow", "init.sh", + "local-cli", "scripts/ios-configure-glog.sh", "scripts/ios-install-third-party.sh", "scripts/launchPackager.bat", @@ -132,7 +133,7 @@ "template" ], "scripts": { - "start": "node cli.js start", + "start": "node cli.js start --reactNativePath .", "test": "jest", "test-ci": "jest --maxWorkers=2 --ci --reporters=\"default\" --reporters=\"jest-junit\"", "flow": "flow", @@ -154,11 +155,11 @@ "test-ios-e2e": "detox test -c ios.sim.release" }, "peerDependencies": { - "react": "16.8.1" + "react": "16.8.6" }, "dependencies": { "@babel/runtime": "^7.0.0", - "@react-native-community/cli": "^1.1.0", + "@react-native-community/cli": "^1.2.1", "absolute-path": "^0.0.0", "art": "^0.10.0", "base64-js": "^1.1.2", @@ -227,13 +228,13 @@ "eslint-plugin-react-hooks": "^1.0.1", "eslint-plugin-react-native": "3.5.0", "flow-bin": "^0.92.0", - "jest": "24.0.0-alpha.6", + "jest": "24.1.0", "jest-junit": "5.2.0", "jscodeshift": "^0.6.2", "prettier": "1.13.6", - "react": "16.8.1", + "react": "16.8.6", "react-native-dummy": "0.2.0", - "react-test-renderer": "16.8.1", + "react-test-renderer": "16.8.6", "shelljs": "^0.7.8" }, "detox": { @@ -255,4 +256,4 @@ } } } -} +} \ No newline at end of file diff --git a/scripts/android-setup.sh b/scripts/android-setup.sh index c76f520b931854..f4adf6047d49f9 100644 --- a/scripts/android-setup.sh +++ b/scripts/android-setup.sh @@ -17,18 +17,18 @@ function getAndroidPackages { # Package names can be obtained using `sdkmanager --list` if [ ! -e "$DEPS" ] || [ ! "$CI" ]; then echo "Installing Android API level $ANDROID_SDK_TARGET_API_LEVEL, Google APIs, $AVD_ABI system image..." - sdkmanager "system-images;android-$ANDROID_SDK_TARGET_API_LEVEL;google_apis;$AVD_ABI" + echo y | sdkmanager "system-images;android-$ANDROID_SDK_TARGET_API_LEVEL;google_apis;$AVD_ABI" echo "Installing build SDK for Android API level $ANDROID_SDK_BUILD_API_LEVEL..." - sdkmanager "platforms;android-$ANDROID_SDK_BUILD_API_LEVEL" + echo y | sdkmanager "platforms;android-$ANDROID_SDK_BUILD_API_LEVEL" echo "Installing target SDK for Android API level $ANDROID_SDK_TARGET_API_LEVEL..." - sdkmanager "platforms;android-$ANDROID_SDK_TARGET_API_LEVEL" + echo y | sdkmanager "platforms;android-$ANDROID_SDK_TARGET_API_LEVEL" echo "Installing SDK build tools, revision $ANDROID_SDK_BUILD_TOOLS_REVISION..." - sdkmanager "build-tools;$ANDROID_SDK_BUILD_TOOLS_REVISION" + echo y | sdkmanager "build-tools;$ANDROID_SDK_BUILD_TOOLS_REVISION" # These moved to "system-images;android-$ANDROID_SDK_BUILD_API_LEVEL;google_apis;x86" starting with API level 25, but there is no ARM version. echo "Installing Google APIs $ANDROID_GOOGLE_API_LEVEL..." - sdkmanager "add-ons;addon-google_apis-google-$ANDROID_GOOGLE_API_LEVEL" + echo y | sdkmanager "add-ons;addon-google_apis-google-$ANDROID_GOOGLE_API_LEVEL" echo "Installing Android Support Repository" - sdkmanager "extras;android;m2repository" + echo y | sdkmanager "extras;android;m2repository" $CI && touch "$DEPS" fi } diff --git a/scripts/launchPackager.bat b/scripts/launchPackager.bat index d33f31ee60032d..377d1f7d3ae284 100644 --- a/scripts/launchPackager.bat +++ b/scripts/launchPackager.bat @@ -6,6 +6,6 @@ @echo off title Metro Bundler call .packager.bat -node "%~dp0..\cli.js" start +node "%~dp0..\cli.js" --reactNativePath ../ --projectRoot ../../../ start pause exit diff --git a/scripts/packager.sh b/scripts/packager.sh index 6cab21b669eeb9..e5bb1e903f0282 100755 --- a/scripts/packager.sh +++ b/scripts/packager.sh @@ -4,9 +4,20 @@ # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. +# scripts directory THIS_DIR=$(cd -P "$(dirname "$(readlink "${BASH_SOURCE[0]}" || echo "${BASH_SOURCE[0]}")")" && pwd) +REACT_NATIVE_ROOT="$THIS_DIR/.." +# Application root directory - General use case: react-native is a dependency +PROJECT_ROOT="$THIS_DIR/../../.." # shellcheck source=/dev/null source "${THIS_DIR}/.packager.env" -cd "$THIS_DIR/.." || exit -node "./cli.js" start "$@" + +# When running react-native tests, react-native doesn't live in node_modules but in the PROJECT_ROOT +if [ ! -d "$PROJECT_ROOT/node_modules/react-native" ]; +then + PROJECT_ROOT="$THIS_DIR/.." +fi +# Start packager from PROJECT_ROOT +cd "$PROJECT_ROOT" || exit +node "$REACT_NATIVE_ROOT/cli.js" start "$@" diff --git a/scripts/run-android-local-integration-tests.sh b/scripts/run-android-local-integration-tests.sh index 9fd5fb63a04667..24c4d9f20691d5 100755 --- a/scripts/run-android-local-integration-tests.sh +++ b/scripts/run-android-local-integration-tests.sh @@ -17,7 +17,7 @@ echo "Compiling native code..." ./gradlew :ReactAndroid:packageReactNdkLibsForBuck echo "Building JS bundle..." -node cli.js bundle --platform android --dev true --entry-file ReactAndroid/src/androidTest/js/TestBundle.js --bundle-output ReactAndroid/src/androidTest/assets/AndroidTestBundle.js +node cli.js bundle --platform android --dev true --entry-file ReactAndroid/src/androidTest/js/TestBundle.js --bundle-output ReactAndroid/src/androidTest/assets/AndroidTestBundle.js --reactNativePath . echo "Installing test app on the device..." buck fetch ReactAndroid/src/androidTest/buck-runner:instrumentation-tests diff --git a/template/android/app/build.gradle b/template/android/app/build.gradle index e22ba91cc5d469..a7a5a1e23fc535 100644 --- a/template/android/app/build.gradle +++ b/template/android/app/build.gradle @@ -113,25 +113,11 @@ android { reset() enable enableSeparateBuildPerCPUArchitecture universalApk false // If true, also generate a universal APK - include "armeabi-v7a", "x86", "arm64-v8a", "x86-64" - } - } - signingConfigs { - debug { - storeFile file('debug.keystore') - storePassword 'android' - keyAlias 'androiddebugkey' - keyPassword 'android' + include "armeabi-v7a", "x86", "arm64-v8a", "x86_64" } } buildTypes { - debug { - signingConfig signingConfigs.debug - } release { - // Caution! In production, you need to generate your own keystore file. - // see https://facebook.github.io/react-native/docs/signed-apk-android. - signingConfig signingConfigs.debug minifyEnabled enableProguardInReleaseBuilds proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro" } @@ -141,7 +127,7 @@ android { variant.outputs.each { output -> // For each separate APK per architecture, set a unique version code as described here: // http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits - def versionCodes = ["armeabi-v7a":1, "x86":2, "arm64-v8a": 3, "x86-64": 4] + def versionCodes = ["armeabi-v7a":1, "x86":2, "arm64-v8a": 3, "x86_64": 4] def abi = output.getFilter(OutputFile.ABI) if (abi != null) { // null for the universal-debug, universal-release variants output.versionCodeOverride = diff --git a/template/android/app/debug.keystore b/template/android/app/debug.keystore deleted file mode 100644 index 364e105ed39fbf..00000000000000 Binary files a/template/android/app/debug.keystore and /dev/null differ diff --git a/template/android/app/src/debug/AndroidManifest.xml b/template/android/app/src/debug/AndroidManifest.xml new file mode 100644 index 00000000000000..fa26aa56e1c144 --- /dev/null +++ b/template/android/app/src/debug/AndroidManifest.xml @@ -0,0 +1,8 @@ + + + + + + + diff --git a/template/android/app/src/debug/res/xml/network_security_config.xml b/template/android/app/src/debug/res/xml/network_security_config.xml deleted file mode 100644 index ba4b23070be6cc..00000000000000 --- a/template/android/app/src/debug/res/xml/network_security_config.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - localhost - 10.0.2.2 - 10.0.3.2 - - diff --git a/template/android/app/src/main/AndroidManifest.xml b/template/android/app/src/main/AndroidManifest.xml index 1b0c20ef328804..7bfb4481abbcf1 100644 --- a/template/android/app/src/main/AndroidManifest.xml +++ b/template/android/app/src/main/AndroidManifest.xml @@ -1,9 +1,7 @@ - + android:theme="@style/AppTheme"> - - - localhost - 10.0.2.2 - 10.0.3.2 - - diff --git a/template/android/build.gradle b/template/android/build.gradle index 20748f9adfead9..c6e7c7c0ab72bc 100644 --- a/template/android/build.gradle +++ b/template/android/build.gradle @@ -5,7 +5,7 @@ buildscript { buildToolsVersion = "28.0.3" minSdkVersion = 16 compileSdkVersion = 28 - targetSdkVersion = 27 + targetSdkVersion = 28 supportLibVersion = "28.0.0" } repositories { @@ -13,7 +13,7 @@ buildscript { jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:3.3.0' + classpath 'com.android.tools.build:gradle:3.3.1' // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files diff --git a/template/android/keystores/_BUCK b/template/android/keystores/_BUCK new file mode 100644 index 00000000000000..88e4c31b28d497 --- /dev/null +++ b/template/android/keystores/_BUCK @@ -0,0 +1,8 @@ +keystore( + name = "debug", + properties = "debug.keystore.properties", + store = "debug.keystore", + visibility = [ + "PUBLIC", + ], +) diff --git a/template/android/keystores/debug.keystore.properties b/template/android/keystores/debug.keystore.properties new file mode 100644 index 00000000000000..121bfb49f0dfda --- /dev/null +++ b/template/android/keystores/debug.keystore.properties @@ -0,0 +1,4 @@ +key.store=debug.keystore +key.alias=androiddebugkey +key.store.password=android +key.alias.password=android diff --git a/yarn.lock b/yarn.lock index be9e3493f0e084..42ca1e7ff60813 100644 --- a/yarn.lock +++ b/yarn.lock @@ -29,6 +29,26 @@ semver "^5.4.1" source-map "^0.5.0" +"@babel/core@^7.1.0": + version "7.3.4" + resolved "https://registry.yarnpkg.com/@babel/core/-/core-7.3.4.tgz#921a5a13746c21e32445bf0798680e9d11a6530b" + integrity sha512-jRsuseXBo9pN197KnDwhhaaBzyZr2oIcLHHTt2oDdQrej5Qp57dCCJafWx5ivU8/alEYDpssYqv1MUqcxwQlrA== + dependencies: + "@babel/code-frame" "^7.0.0" + "@babel/generator" "^7.3.4" + "@babel/helpers" "^7.2.0" + "@babel/parser" "^7.3.4" + "@babel/template" "^7.2.2" + "@babel/traverse" "^7.3.4" + "@babel/types" "^7.3.4" + convert-source-map "^1.1.0" + debug "^4.1.0" + json5 "^2.1.0" + lodash "^4.17.11" + resolve "^1.3.2" + semver "^5.4.1" + source-map "^0.5.0" + "@babel/core@^7.1.6": version "7.2.2" resolved "https://registry.yarnpkg.com/@babel/core/-/core-7.2.2.tgz#07adba6dde27bb5ad8d8672f15fde3e08184a687" @@ -71,6 +91,17 @@ source-map "^0.5.0" trim-right "^1.0.1" +"@babel/generator@^7.3.4": + version "7.3.4" + resolved "https://registry.yarnpkg.com/@babel/generator/-/generator-7.3.4.tgz#9aa48c1989257877a9d971296e5b73bfe72e446e" + integrity sha512-8EXhHRFqlVVWXPezBW5keTiQi/rJMQTg/Y9uVCEZ0CAF3PKtCCaVRnp64Ii1ujhkoDhhF1fVsImoN4yJ2uz4Wg== + dependencies: + "@babel/types" "^7.3.4" + jsesc "^2.5.1" + lodash "^4.17.11" + source-map "^0.5.0" + trim-right "^1.0.1" + "@babel/helper-annotate-as-pure@^7.0.0": version "7.0.0" resolved "https://registry.yarnpkg.com/@babel/helper-annotate-as-pure/-/helper-annotate-as-pure-7.0.0.tgz#323d39dd0b50e10c7c06ca7d7638e6864d8c5c32" @@ -287,6 +318,11 @@ resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.1.3.tgz#2c92469bac2b7fbff810b67fca07bd138b48af77" integrity sha512-gqmspPZOMW3MIRb9HlrnbZHXI1/KHTOroBwN1NcLL6pWxzqzEKGvRTq0W/PxS45OtQGbaFikSQpkS5zbnsQm2w== +"@babel/parser@^7.1.0", "@babel/parser@^7.3.4": + version "7.3.4" + resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.3.4.tgz#a43357e4bbf4b92a437fb9e465c192848287f27c" + integrity sha512-tXZCqWtlOOP4wgCp6RjRvLmfuhnqTLy9VHwRochJBCP2nDm27JnnuFEnXFASVyQNHk36jD1tAammsCEEqgscIQ== + "@babel/parser@^7.1.6", "@babel/parser@^7.2.2", "@babel/parser@^7.2.3": version "7.2.3" resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.2.3.tgz#32f5df65744b70888d17872ec106b02434ba1489" @@ -1090,6 +1126,21 @@ globals "^11.1.0" lodash "^4.17.10" +"@babel/traverse@^7.3.4": + version "7.3.4" + resolved "https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.3.4.tgz#1330aab72234f8dea091b08c4f8b9d05c7119e06" + integrity sha512-TvTHKp6471OYEcE/91uWmhR6PrrYywQntCHSaZ8CM8Vmp+pjAusal4nGB2WCCQd0rvI7nOMKn9GnbcvTUz3/ZQ== + dependencies: + "@babel/code-frame" "^7.0.0" + "@babel/generator" "^7.3.4" + "@babel/helper-function-name" "^7.1.0" + "@babel/helper-split-export-declaration" "^7.0.0" + "@babel/parser" "^7.3.4" + "@babel/types" "^7.3.4" + debug "^4.1.0" + globals "^11.1.0" + lodash "^4.17.11" + "@babel/types@^7.0.0", "@babel/types@^7.1.2", "@babel/types@^7.1.3": version "7.1.3" resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.1.3.tgz#3a767004567060c2f40fca49a304712c525ee37d" @@ -1108,10 +1159,164 @@ lodash "^4.17.10" to-fast-properties "^2.0.0" -"@react-native-community/cli@^1.1.0": - version "1.1.0" - resolved "https://registry.yarnpkg.com/@react-native-community/cli/-/cli-1.1.0.tgz#aa915a86d3242923a77f3035b02103488fc6f91a" - integrity sha512-cIMD7IsE+NCSnHRcqU5MvVhhqjopRU9VvBVIndfD4pe9pee+qodOY+II25fa93+3lytxxEx4LEtG5sn0RoAWAQ== +"@babel/types@^7.3.0", "@babel/types@^7.3.4": + version "7.3.4" + resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.3.4.tgz#bf482eaeaffb367a28abbf9357a94963235d90ed" + integrity sha512-WEkp8MsLftM7O/ty580wAmZzN1nDmCACc5+jFzUt+GUFNNIi3LdRlueYz0YIlmJhlZx1QYDMZL5vdWCL0fNjFQ== + dependencies: + esutils "^2.0.2" + lodash "^4.17.11" + to-fast-properties "^2.0.0" + +"@cnakazawa/watch@^1.0.3": + version "1.0.3" + resolved "https://registry.yarnpkg.com/@cnakazawa/watch/-/watch-1.0.3.tgz#099139eaec7ebf07a27c1786a3ff64f39464d2ef" + integrity sha512-r5160ogAvGyHsal38Kux7YYtodEKOj89RGb28ht1jh3SJb08VwRwAKKJL0bGb04Zd/3r9FL3BFIc3bBidYffCA== + dependencies: + exec-sh "^0.3.2" + minimist "^1.2.0" + +"@jest/console@^24.3.0": + version "24.3.0" + resolved "https://registry.yarnpkg.com/@jest/console/-/console-24.3.0.tgz#7bd920d250988ba0bf1352c4493a48e1cb97671e" + integrity sha512-NaCty/OOei6rSDcbPdMiCbYCI0KGFGPgGO6B09lwWt5QTxnkuhKYET9El5u5z1GAcSxkQmSMtM63e24YabCWqA== + dependencies: + "@jest/source-map" "^24.3.0" + "@types/node" "*" + chalk "^2.0.1" + slash "^2.0.0" + +"@jest/core@^24.4.0": + version "24.4.0" + resolved "https://registry.yarnpkg.com/@jest/core/-/core-24.4.0.tgz#ec53510f19dde5aaf4e9e28a3c3426fc0f2a41d6" + integrity sha512-S48krBwigVm3DwLSEtMiiWnWz+G3uGii192LIZYbWULYSOCwQeG7hWb6a3yWBLYuZnATh3W6QMxs7whS0/hQMQ== + dependencies: + "@jest/console" "^24.3.0" + "@jest/reporters" "^24.4.0" + "@jest/test-result" "^24.3.0" + "@jest/transform" "^24.4.0" + "@jest/types" "^24.3.0" + ansi-escapes "^3.0.0" + chalk "^2.0.1" + exit "^0.1.2" + graceful-fs "^4.1.15" + jest-changed-files "^24.3.0" + jest-config "^24.4.0" + jest-haste-map "^24.4.0" + jest-message-util "^24.3.0" + jest-regex-util "^24.3.0" + jest-resolve-dependencies "^24.4.0" + jest-runner "^24.4.0" + jest-runtime "^24.4.0" + jest-snapshot "^24.4.0" + jest-util "^24.3.0" + jest-validate "^24.4.0" + jest-watcher "^24.3.0" + micromatch "^3.1.10" + p-each-series "^1.0.0" + pirates "^4.0.1" + realpath-native "^1.1.0" + rimraf "^2.5.4" + strip-ansi "^5.0.0" + +"@jest/environment@^24.4.0": + version "24.4.0" + resolved "https://registry.yarnpkg.com/@jest/environment/-/environment-24.4.0.tgz#552f0629a9cc2bd015f370b3af77222f069f158f" + integrity sha512-YuPsWWwTS4wkMsvCNXvBZPZQGOVtsVyle9OzHIAdWvV+B9qjs0vA85Il1+FSG0b765VqznPvpfIe1wKoIFOleQ== + dependencies: + "@jest/fake-timers" "^24.3.0" + "@jest/transform" "^24.4.0" + "@jest/types" "^24.3.0" + "@types/node" "*" + jest-mock "^24.3.0" + +"@jest/fake-timers@^24.3.0": + version "24.3.0" + resolved "https://registry.yarnpkg.com/@jest/fake-timers/-/fake-timers-24.3.0.tgz#0a7f8b877b78780c3fa5c3f8683cc0aaf9488331" + integrity sha512-rHwVI17dGMHxHzfAhnZ04+wFznjFfZ246QugeBnbiYr7/bDosPD2P1qeNjWnJUUcfl0HpS6kkr+OB/mqSJxQFg== + dependencies: + "@jest/types" "^24.3.0" + "@types/node" "*" + jest-message-util "^24.3.0" + jest-mock "^24.3.0" + +"@jest/reporters@^24.4.0": + version "24.4.0" + resolved "https://registry.yarnpkg.com/@jest/reporters/-/reporters-24.4.0.tgz#e1e6ca29593f36088db76a380f04e93e71f09607" + integrity sha512-teO0to16UaYJTLWXCWCa1kBPx/PY4dw2/8I2LPIzk5mNN5km8jyx5jz8D1Yy0nqascVtbpG4+VnSt7E16cnrcw== + dependencies: + "@jest/environment" "^24.4.0" + "@jest/test-result" "^24.3.0" + "@jest/transform" "^24.4.0" + "@jest/types" "^24.3.0" + chalk "^2.0.1" + exit "^0.1.2" + glob "^7.1.2" + istanbul-api "^2.1.1" + istanbul-lib-coverage "^2.0.2" + istanbul-lib-instrument "^3.0.1" + istanbul-lib-source-maps "^3.0.1" + jest-haste-map "^24.4.0" + jest-resolve "^24.4.0" + jest-runtime "^24.4.0" + jest-util "^24.3.0" + jest-worker "^24.4.0" + node-notifier "^5.2.1" + slash "^2.0.0" + source-map "^0.6.0" + string-length "^2.0.0" + +"@jest/source-map@^24.3.0": + version "24.3.0" + resolved "https://registry.yarnpkg.com/@jest/source-map/-/source-map-24.3.0.tgz#563be3aa4d224caf65ff77edc95cd1ca4da67f28" + integrity sha512-zALZt1t2ou8le/crCeeiRYzvdnTzaIlpOWaet45lNSqNJUnXbppUUFR4ZUAlzgDmKee4Q5P/tKXypI1RiHwgag== + dependencies: + callsites "^3.0.0" + graceful-fs "^4.1.15" + source-map "^0.6.0" + +"@jest/test-result@^24.3.0": + version "24.3.0" + resolved "https://registry.yarnpkg.com/@jest/test-result/-/test-result-24.3.0.tgz#4c0b1c9716212111920f7cf8c4329c69bc81924a" + integrity sha512-j7UZ49T8C4CVipEY99nLttnczVTtLyVzFfN20OiBVn7awOs0U3endXSTq7ouPrLR5y4YjI5GDcbcvDUjgeamzg== + dependencies: + "@jest/console" "^24.3.0" + "@jest/types" "^24.3.0" + "@types/istanbul-lib-coverage" "^1.1.0" + +"@jest/transform@^24.4.0": + version "24.4.0" + resolved "https://registry.yarnpkg.com/@jest/transform/-/transform-24.4.0.tgz#2f6b4b5dc7f7673d8fec8bf1040d4236c58c7a60" + integrity sha512-Y928pU6bqWqMlGugRiaWOresox/CIrRuBVdPnYiSoIcRtwNKZujCOkzIzRalcTTxm77wuLjNihcq8OWfdm+Dxg== + dependencies: + "@babel/core" "^7.1.0" + "@jest/types" "^24.3.0" + babel-plugin-istanbul "^5.1.0" + chalk "^2.0.1" + convert-source-map "^1.4.0" + fast-json-stable-stringify "^2.0.0" + graceful-fs "^4.1.15" + jest-haste-map "^24.4.0" + jest-regex-util "^24.3.0" + jest-util "^24.3.0" + micromatch "^3.1.10" + realpath-native "^1.1.0" + slash "^2.0.0" + source-map "^0.6.1" + write-file-atomic "2.4.1" + +"@jest/types@^24.3.0": + version "24.3.0" + resolved "https://registry.yarnpkg.com/@jest/types/-/types-24.3.0.tgz#3f6e117e47248a9a6b5f1357ec645bd364f7ad23" + integrity sha512-VoO1F5tU2n/93QN/zaZ7Q8SeV/Rj+9JJOgbvKbBwy4lenvmdj1iDaQEPXGTKrO6OSvDeb2drTFipZJYxgo6kIQ== + dependencies: + "@types/istanbul-lib-coverage" "^1.1.0" + "@types/yargs" "^12.0.9" + +"@react-native-community/cli@^1.2.1": + version "1.2.1" + resolved "https://registry.yarnpkg.com/@react-native-community/cli/-/cli-1.2.1.tgz#990b0b0e199e4a75357dfb445eaae13100f60a1b" + integrity sha512-PwOLWckcQbgyekCcKKGfBqNnK5SFJtdUQdNemF4odn5bWKigr4JsNd4wT2BRqvRHuzYa7kY6MjriwgYTHSSChA== dependencies: chalk "^1.1.1" commander "^2.9.0" @@ -1137,20 +1342,73 @@ morgan "^1.9.0" node-fetch "^2.2.0" node-notifier "^5.2.1" - npmlog "^2.0.4" opn "^3.0.2" plist "^3.0.0" semver "^5.0.3" serve-static "^1.13.1" shell-quote "1.6.1" + slash "^2.0.0" ws "^1.1.0" - xcode "^1.0.0" + xcode "^2.0.0" xmldoc "^0.4.0" "@reactions/component@^2.0.2": version "2.0.2" resolved "https://registry.yarnpkg.com/@reactions/component/-/component-2.0.2.tgz#40f8c1c2c37baabe57a0c944edb9310dc1ec6642" +"@types/babel__core@^7.1.0": + version "7.1.0" + resolved "https://registry.yarnpkg.com/@types/babel__core/-/babel__core-7.1.0.tgz#710f2487dda4dcfd010ca6abb2b4dc7394365c51" + integrity sha512-wJTeJRt7BToFx3USrCDs2BhEi4ijBInTQjOIukj6a/5tEkwpFMVZ+1ppgmE+Q/FQyc5P/VWUbx7I9NELrKruHA== + dependencies: + "@babel/parser" "^7.1.0" + "@babel/types" "^7.0.0" + "@types/babel__generator" "*" + "@types/babel__template" "*" + "@types/babel__traverse" "*" + +"@types/babel__generator@*": + version "7.0.2" + resolved "https://registry.yarnpkg.com/@types/babel__generator/-/babel__generator-7.0.2.tgz#d2112a6b21fad600d7674274293c85dce0cb47fc" + integrity sha512-NHcOfab3Zw4q5sEE2COkpfXjoE7o+PmqD9DQW4koUT3roNxwziUdXGnRndMat/LJNUtePwn1TlP4do3uoe3KZQ== + dependencies: + "@babel/types" "^7.0.0" + +"@types/babel__template@*": + version "7.0.2" + resolved "https://registry.yarnpkg.com/@types/babel__template/-/babel__template-7.0.2.tgz#4ff63d6b52eddac1de7b975a5223ed32ecea9307" + integrity sha512-/K6zCpeW7Imzgab2bLkLEbz0+1JlFSrUMdw7KoIIu+IUdu51GWaBZpd3y1VXGVXzynvGa4DaIaxNZHiON3GXUg== + dependencies: + "@babel/parser" "^7.1.0" + "@babel/types" "^7.0.0" + +"@types/babel__traverse@*", "@types/babel__traverse@^7.0.6": + version "7.0.6" + resolved "https://registry.yarnpkg.com/@types/babel__traverse/-/babel__traverse-7.0.6.tgz#328dd1a8fc4cfe3c8458be9477b219ea158fd7b2" + integrity sha512-XYVgHF2sQ0YblLRMLNPB3CkFMewzFmlDsH/TneZFHUXDlABQgh88uOxuez7ZcXxayLFrqLwtDH1t+FmlFwNZxw== + dependencies: + "@babel/types" "^7.3.0" + +"@types/istanbul-lib-coverage@^1.1.0": + version "1.1.0" + resolved "https://registry.yarnpkg.com/@types/istanbul-lib-coverage/-/istanbul-lib-coverage-1.1.0.tgz#2cc2ca41051498382b43157c8227fea60363f94a" + integrity sha512-ohkhb9LehJy+PA40rDtGAji61NCgdtKLAlFoYp4cnuuQEswwdK3vz9SOIkkyc3wrk8dzjphQApNs56yyXLStaQ== + +"@types/node@*": + version "11.11.0" + resolved "https://registry.yarnpkg.com/@types/node/-/node-11.11.0.tgz#070e9ce7c90e727aca0e0c14e470f9a93ffe9390" + integrity sha512-D5Rt+HXgEywr3RQJcGlZUCTCx1qVbCZpVk3/tOOA6spLNZdGm8BU+zRgdRYDoF1pO3RuXLxADzMrF903JlQXqg== + +"@types/stack-utils@^1.0.1": + version "1.0.1" + resolved "https://registry.yarnpkg.com/@types/stack-utils/-/stack-utils-1.0.1.tgz#0a851d3bd96498fa25c33ab7278ed3bd65f06c3e" + integrity sha512-l42BggppR6zLmpfU6fq9HEa2oGPEI8yrSPL3GITjfRInppYFahObbIQOQK3UGxEnyQpltZLaPe75046NOZQikw== + +"@types/yargs@^12.0.2", "@types/yargs@^12.0.9": + version "12.0.9" + resolved "https://registry.yarnpkg.com/@types/yargs/-/yargs-12.0.9.tgz#693e76a52f61a2f1e7fb48c0eef167b95ea4ffd0" + integrity sha512-sCZy4SxP9rN2w30Hlmg5dtdRwgYQfYRiLo9usw8X9cxlf+H4FqM1xX7+sNH7NNKVdbXMJWqva7iyy+fxh/V7fA== + abab@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/abab/-/abab-2.0.0.tgz#aba0ab4c5eee2d4c79d3487d85450fb2376ebb0f" @@ -1307,12 +1565,12 @@ anymatch@^2.0.0: micromatch "^3.1.4" normalize-path "^2.1.1" -append-transform@^0.4.0: - version "0.4.0" - resolved "https://registry.yarnpkg.com/append-transform/-/append-transform-0.4.0.tgz#d76ebf8ca94d276e247a36bad44a4b74ab611991" - integrity sha1-126/jKlNJ24keja61EpLdKthGZE= +append-transform@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/append-transform/-/append-transform-1.0.0.tgz#046a52ae582a228bd72f58acfbe2967c678759ab" + integrity sha512-P009oYkeHyU742iSZJzZZywj4QRJdnTWffaKuJQLablCZ1uz6/cW4yaRgcDaoQ+uwOxxnt0gRUcwfsNP2ri0gw== dependencies: - default-require-extensions "^1.0.0" + default-require-extensions "^2.0.0" aproba@^1.0.3: version "1.2.0" @@ -1471,13 +1729,20 @@ async-limiter@~1.0.0: resolved "https://registry.yarnpkg.com/async-limiter/-/async-limiter-1.0.0.tgz#78faed8c3d074ab81f22b4e985d79e8738f720f8" integrity sha512-jp/uFnooOiO+L211eZOoSyzpOITMXx1rBITauYykG3BRYPu8h0UcxsPNB04RR5vo4Tyz3+ay17tR6JVf9qzYWg== -async@^2.1.4, async@^2.4.0, async@^2.5.0: +async@^2.4.0, async@^2.5.0: version "2.6.1" resolved "https://registry.yarnpkg.com/async/-/async-2.6.1.tgz#b245a23ca71930044ec53fa46aa00a3e87c6a610" integrity sha512-fNEiL2+AZt6AlAw/29Cr0UDe4sRAHCpEHh54WMz+Bb7QfNcFw4h3loofyJpLeQs4Yx7yuqu/2dLgM5hKOs6HlQ== dependencies: lodash "^4.17.10" +async@^2.6.1: + version "2.6.2" + resolved "https://registry.yarnpkg.com/async/-/async-2.6.2.tgz#18330ea7e6e313887f5d2f2a904bac6fe4dd5381" + integrity sha512-H1qVYh1MYhEEFLsP97cVKqCGo7KfCyTt6uEWqsTBr9SO84oK9Uwbyd/yCW+6rKJLHksBNUVWZDAjfS+Ccx0Bbg== + dependencies: + lodash "^4.17.11" + asynckit@^0.4.0: version "0.4.0" resolved "https://registry.yarnpkg.com/asynckit/-/asynckit-0.4.0.tgz#c79ed97f7f34cb8f2ba1bc9790bcc366474b4b79" @@ -1579,13 +1844,18 @@ babel-jest@^23.6.0: babel-plugin-istanbul "^4.1.6" babel-preset-jest "^23.2.0" -babel-jest@^24.0.0-alpha.6: - version "24.0.0-alpha.6" - resolved "https://registry.yarnpkg.com/babel-jest/-/babel-jest-24.0.0-alpha.6.tgz#e3bd746b82456fc67fb7b4c9152a9aacbc747a8d" - integrity sha512-2scrmuFWZcQ4Bc0ULhzhKH8eQCC1XAa6TPs9QD7ofYeJsrC5XeJj4EfACYyW5NnvhStXm9R/OU1uoxWDAas1wQ== - dependencies: - babel-plugin-istanbul "^4.1.6" - babel-preset-jest "^24.0.0-alpha.6" +babel-jest@^24.4.0: + version "24.4.0" + resolved "https://registry.yarnpkg.com/babel-jest/-/babel-jest-24.4.0.tgz#6c4029f52175d4f8f138cdad42d2a02fe34ddb03" + integrity sha512-wh23nKbWZf9SeO0GNOQc2QDqaMXOmbaI2Hvbcl6FGqg9zqHwr9Jy0e0ZqsXiJ2Cv8YKqD+eOE2wAGVhq4nzWDQ== + dependencies: + "@jest/transform" "^24.4.0" + "@jest/types" "^24.3.0" + "@types/babel__core" "^7.1.0" + babel-plugin-istanbul "^5.1.0" + babel-preset-jest "^24.3.0" + chalk "^2.4.2" + slash "^2.0.0" babel-messages@^6.23.0: version "6.23.0" @@ -1604,15 +1874,26 @@ babel-plugin-istanbul@^4.1.6: istanbul-lib-instrument "^1.10.1" test-exclude "^4.2.1" +babel-plugin-istanbul@^5.1.0: + version "5.1.1" + resolved "https://registry.yarnpkg.com/babel-plugin-istanbul/-/babel-plugin-istanbul-5.1.1.tgz#7981590f1956d75d67630ba46f0c22493588c893" + integrity sha512-RNNVv2lsHAXJQsEJ5jonQwrJVWK8AcZpG1oxhnjCUaAjL7xahYLANhPUZbzEQHjKy1NMYUwn+0NPKQc8iSY4xQ== + dependencies: + find-up "^3.0.0" + istanbul-lib-instrument "^3.0.0" + test-exclude "^5.0.0" + babel-plugin-jest-hoist@^23.2.0: version "23.2.0" resolved "https://registry.yarnpkg.com/babel-plugin-jest-hoist/-/babel-plugin-jest-hoist-23.2.0.tgz#e61fae05a1ca8801aadee57a6d66b8cefaf44167" integrity sha1-5h+uBaHKiAGq3uV6bWa4zvr0QWc= -babel-plugin-jest-hoist@^24.0.0-alpha.6: - version "24.0.0-alpha.6" - resolved "https://registry.yarnpkg.com/babel-plugin-jest-hoist/-/babel-plugin-jest-hoist-24.0.0-alpha.6.tgz#b1e3e1b8d3d64f1f94dde438b7fbb5f91506b6f7" - integrity sha512-Z06kZ8x8EtaBgUUI9Rkg3oZBq3jWhlF2yHFOzxBvjkQGQU/r014RjcIVT5qKeYDGn9Z8eYHy8w//a0qOphSI3Q== +babel-plugin-jest-hoist@^24.3.0: + version "24.3.0" + resolved "https://registry.yarnpkg.com/babel-plugin-jest-hoist/-/babel-plugin-jest-hoist-24.3.0.tgz#f2e82952946f6e40bb0a75d266a3790d854c8b5b" + integrity sha512-nWh4N1mVH55Tzhx2isvUN5ebM5CDUvIpXPZYMRazQughie/EqGnbR+czzoQlhUmJG9pPJmYDRhvocotb2THl1w== + dependencies: + "@types/babel__traverse" "^7.0.6" babel-plugin-syntax-object-rest-spread@^6.13.0: version "6.13.0" @@ -1666,13 +1947,13 @@ babel-preset-jest@^23.2.0: babel-plugin-jest-hoist "^23.2.0" babel-plugin-syntax-object-rest-spread "^6.13.0" -babel-preset-jest@^24.0.0-alpha.6: - version "24.0.0-alpha.6" - resolved "https://registry.yarnpkg.com/babel-preset-jest/-/babel-preset-jest-24.0.0-alpha.6.tgz#effeb7f6927ac2734dd55e2f3936bbaab7312a6a" - integrity sha512-XuKtUS/hIRfRgJHTVpwGe2yZfE6SFqTElzMdG79tUuOs8z+BxURTCNuVXecVcXDuermn7HA7NAi9VS0zgSmc4g== +babel-preset-jest@^24.3.0: + version "24.3.0" + resolved "https://registry.yarnpkg.com/babel-preset-jest/-/babel-preset-jest-24.3.0.tgz#db88497e18869f15b24d9c0e547d8e0ab950796d" + integrity sha512-VGTV2QYBa/Kn3WCOKdfS31j9qomaXSgJqi65B6o05/1GsJyj9LVhSljM9ro4S+IBGj/ENhNBuH9bpqzztKAQSw== dependencies: - babel-plugin-jest-hoist "^24.0.0-alpha.6" - babel-plugin-syntax-object-rest-spread "^6.13.0" + "@babel/plugin-syntax-object-rest-spread" "^7.0.0" + babel-plugin-jest-hoist "^24.3.0" babel-register@^6.26.0: version "6.26.0" @@ -1741,11 +2022,6 @@ balanced-match@^1.0.0: resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.0.tgz#89b4d199ab2bee49de164ea02b89ce462d71b767" integrity sha1-ibTRmasr7kneFk6gK4nORi1xt2c= -base64-js@1.1.2: - version "1.1.2" - resolved "https://registry.yarnpkg.com/base64-js/-/base64-js-1.1.2.tgz#d6400cac1c4c660976d90d07a04351d89395f5e8" - integrity sha1-1kAMrBxMZgl22Q0HoENR2JOV9eg= - base64-js@^1.1.2, base64-js@^1.2.3: version "1.3.0" resolved "https://registry.yarnpkg.com/base64-js/-/base64-js-1.3.0.tgz#cab1e6118f051095e58b5281aea8c1cd22bfc0e3" @@ -1933,11 +2209,21 @@ callsites@^2.0.0: resolved "https://registry.yarnpkg.com/callsites/-/callsites-2.0.0.tgz#06eb84f00eea413da86affefacbffb36093b3c50" integrity sha1-BuuE8A7qQT2oav/vrL/7Ngk7PFA= +callsites@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/callsites/-/callsites-3.0.0.tgz#fb7eb569b72ad7a45812f93fd9430a3e410b3dd3" + integrity sha512-tWnkwu9YEq2uzlBDI4RcLn8jrFvF9AOi8PxDNU3hZZjJcjkcRAq3vCI+vZcg1SuxISDYe86k9VZFwAxDiJGoAw== + camelcase@^4.1.0: version "4.1.0" resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-4.1.0.tgz#d545635be1e33c542649c69173e5de6acfae34dd" integrity sha1-1UVjW+HjPFQmScaRc+Xeas+uNN0= +camelcase@^5.0.0: + version "5.2.0" + resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-5.2.0.tgz#e7522abda5ed94cc0489e1b8466610e88404cf45" + integrity sha512-IXFsBS2pC+X0j0N/GE7Dm7j3bsEBp+oTpb7F50dwEVX7rf3IgwO9XatnegTsDtniKCUtEJH4fSU6Asw7uoVLfQ== + caniuse-lite@^1.0.30000921: version "1.0.30000923" resolved "https://registry.yarnpkg.com/caniuse-lite/-/caniuse-lite-1.0.30000923.tgz#148f9bda508024b5ce957b463ae2e8302b451bb2" @@ -1975,6 +2261,15 @@ chalk@^2.0.0, chalk@^2.0.1, chalk@^2.1.0, chalk@^2.4.1: escape-string-regexp "^1.0.5" supports-color "^5.3.0" +chalk@^2.4.2: + version "2.4.2" + resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.4.2.tgz#cd42541677a54333cf541a49108c1432b44c9424" + integrity sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ== + dependencies: + ansi-styles "^3.2.1" + escape-string-regexp "^1.0.5" + supports-color "^5.3.0" + chardet@^0.4.0: version "0.4.2" resolved "https://registry.yarnpkg.com/chardet/-/chardet-0.4.2.tgz#b5473b33dc97c424e5d98dc87d55d4d8a29c8bf2" @@ -1999,6 +2294,11 @@ ci-info@^1.5.0: resolved "https://registry.yarnpkg.com/ci-info/-/ci-info-1.6.0.tgz#2ca20dbb9ceb32d4524a683303313f0304b1e497" integrity sha512-vsGdkwSCDpWmP80ncATX7iea5DWQemg1UgCW5J8tqjU3lYw4FBYuj89J0CTVomA7BEfvSZd84GmHko+MxFQU2A== +ci-info@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/ci-info/-/ci-info-2.0.0.tgz#67a9e964be31a51e15e5010d58e6f12834002f46" + integrity sha512-5tK7EtrZ0N+OLFMthtqOj4fI2Jeb88C4CAZPu25LDVUgXJ0A3Js4PMGqrn0JU1W0Mh1/Z8wZzYPxqUrXeBboCQ== + circular-json@^0.3.1: version "0.3.3" resolved "https://registry.yarnpkg.com/circular-json/-/circular-json-0.3.3.tgz#815c99ea84f6809529d2f45791bdf82711352d66" @@ -2123,6 +2423,11 @@ commondir@^1.0.1: resolved "https://registry.yarnpkg.com/commondir/-/commondir-1.0.1.tgz#ddd800da0c66127393cca5950ea968a3aaf1253b" integrity sha1-3dgA2gxmEnOTzKWVDqloo6rxJTs= +compare-versions@^3.2.1: + version "3.4.0" + resolved "https://registry.yarnpkg.com/compare-versions/-/compare-versions-3.4.0.tgz#e0747df5c9cb7f054d6d3dc3e1dbc444f9e92b26" + integrity sha512-tK69D7oNXXqUW3ZNo/z7NXTEz22TCF0pTE+YF9cxvaAM9XnkLo1fV621xCLrRR6aevJlKxExkss0vWqUCUpqdg== + component-emitter@^1.2.1: version "1.2.1" resolved "https://registry.yarnpkg.com/component-emitter/-/component-emitter-1.2.1.tgz#137918d6d78283f7df7a6b7c5a63e140e69425e6" @@ -2312,6 +2617,13 @@ debug@^4.1.0: dependencies: ms "^2.1.1" +debug@^4.1.1: + version "4.1.1" + resolved "https://registry.yarnpkg.com/debug/-/debug-4.1.1.tgz#3b72260255109c6b589cee050f1d516139664791" + integrity sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw== + dependencies: + ms "^2.1.1" + decamelize@^1.1.1: version "1.2.0" resolved "https://registry.yarnpkg.com/decamelize/-/decamelize-1.2.0.tgz#f6534d15148269b20352e7bee26f501f9a191290" @@ -2339,12 +2651,12 @@ deep-is@~0.1.3: resolved "https://registry.yarnpkg.com/deep-is/-/deep-is-0.1.3.tgz#b369d6fb5dbc13eecf524f91b070feedc357cf34" integrity sha1-s2nW+128E+7PUk+RsHD+7cNXzzQ= -default-require-extensions@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/default-require-extensions/-/default-require-extensions-1.0.0.tgz#f37ea15d3e13ffd9b437d33e1a75b5fb97874cb8" - integrity sha1-836hXT4T/9m0N9M+GnW1+5eHTLg= +default-require-extensions@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/default-require-extensions/-/default-require-extensions-2.0.0.tgz#f5f8fbb18a7d6d50b21f641f649ebb522cfe24f7" + integrity sha1-9fj7sYp9bVCyH2QfZJ67Uiz+JPc= dependencies: - strip-bom "^2.0.0" + strip-bom "^3.0.0" define-properties@^1.1.2: version "1.1.3" @@ -2452,6 +2764,11 @@ detox@9.0.4: tempfile "^2.0.0" ws "^1.1.1" +diff-sequences@^24.3.0: + version "24.3.0" + resolved "https://registry.yarnpkg.com/diff-sequences/-/diff-sequences-24.3.0.tgz#0f20e8a1df1abddaf4d9c226680952e64118b975" + integrity sha512-xLqpez+Zj9GKSnPWS0WZw1igGocZ+uua8+y+5dDNTT934N3QuY1sp2LkHzwiaYQGz60hMq0pjAshdeXm5VUOEw== + diff@^3.2.0: version "3.5.0" resolved "https://registry.yarnpkg.com/diff/-/diff-3.5.0.tgz#800c0dd1e0a8bfbc95835c202ad220fe317e5a12" @@ -2796,6 +3113,11 @@ exec-sh@^0.2.0: dependencies: merge "^1.2.0" +exec-sh@^0.3.2: + version "0.3.2" + resolved "https://registry.yarnpkg.com/exec-sh/-/exec-sh-0.3.2.tgz#6738de2eb7c8e671d0366aea0b0db8c6f7d7391b" + integrity sha512-9sLAvzhI5nc8TpuQUh4ahMdCrWT00wPWz7j47/emR5+2qEfoZP5zzUXvx+vdx+H6ohhnsYC31iX04QLYJK8zTg== + execa@^0.10.0: version "0.10.0" resolved "https://registry.yarnpkg.com/execa/-/execa-0.10.0.tgz#ff456a8f53f90f8eccc71a96d11bdfc7f082cb50" @@ -2879,17 +3201,17 @@ expect@^23.6.0: jest-message-util "^23.4.0" jest-regex-util "^23.3.0" -expect@^24.0.0-alpha.6: - version "24.0.0-alpha.6" - resolved "https://registry.yarnpkg.com/expect/-/expect-24.0.0-alpha.6.tgz#55f1edb1d73e1b0b58474b4775331480d50839cd" - integrity sha512-FcafdwfuHoDPgzVlBrhRVp7s2y5Qd+Jv4nlHtCAlO5b1BWArhZFwc9n1Jp4M8/q5nINICkbSFoA1bmR6czLg3w== +expect@^24.4.0: + version "24.4.0" + resolved "https://registry.yarnpkg.com/expect/-/expect-24.4.0.tgz#df52da212bc06831c38fb51a53106ae7a0e7aaf2" + integrity sha512-p3QGkNhxN4WXih12lOx4vuhJpl/ZFD1AWu9lWh8IXNZD10ySSOzDN4Io8zuEOWvzylFkDpU9oQ/KRTZ/Bs9/ag== dependencies: + "@jest/types" "^24.3.0" ansi-styles "^3.2.0" - jest-diff "^24.0.0-alpha.6" - jest-get-type "^24.0.0-alpha.6" - jest-matcher-utils "^24.0.0-alpha.6" - jest-message-util "^24.0.0-alpha.6" - jest-regex-util "^24.0.0-alpha.6" + jest-get-type "^24.3.0" + jest-matcher-utils "^24.4.0" + jest-message-util "^24.3.0" + jest-regex-util "^24.3.0" extend-shallow@^1.1.2: version "1.1.4" @@ -3067,7 +3389,7 @@ filename-regex@^2.0.0: resolved "https://registry.yarnpkg.com/filename-regex/-/filename-regex-2.0.1.tgz#c1c4b9bee3e09725ddb106b75c1e301fe2f18b26" integrity sha1-wcS5vuPglyXdsQa3XB4wH+LxiyY= -fileset@^2.0.2: +fileset@^2.0.3: version "2.0.3" resolved "https://registry.yarnpkg.com/fileset/-/fileset-2.0.3.tgz#8e7548a96d3cc2327ee5e674168723a333bba2a0" integrity sha1-jnVIqW08wjJ+5eZ0FocjozO7oqA= @@ -3380,6 +3702,11 @@ graceful-fs@^4.1.11, graceful-fs@^4.1.2, graceful-fs@^4.1.3, graceful-fs@^4.1.6, resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.1.11.tgz#0e8bdfe4d1ddb8854d64e04ea7c00e2a026e5658" integrity sha1-Dovf5NHduIVNZOBOp8AOKgJuVlg= +graceful-fs@^4.1.15: + version "4.1.15" + resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.1.15.tgz#ffb703e1066e8a0eeaa4c8b80ba9253eeefbfb00" + integrity sha512-6uHUhOPEBgQ24HM+r6b/QwWfZq+yiFcipKFrOFiBEnWdy5sdzYoi+pJeQaPI5qOLRFqWmAXUPQNsielzdLoecA== + "growl@~> 1.10.0": version "1.10.5" resolved "https://registry.yarnpkg.com/growl/-/growl-1.10.5.tgz#f2735dc2283674fa67478b10181059355c369e5e" @@ -3390,10 +3717,10 @@ growly@^1.3.0: resolved "https://registry.yarnpkg.com/growly/-/growly-1.3.0.tgz#f10748cbe76af964b7c96c93c6bcc28af120c081" integrity sha1-8QdIy+dq+WS3yWyTxrzCivEgwIE= -handlebars@^4.0.3: - version "4.0.12" - resolved "https://registry.yarnpkg.com/handlebars/-/handlebars-4.0.12.tgz#2c15c8a96d46da5e266700518ba8cb8d919d5bc5" - integrity sha512-RhmTekP+FZL+XNhwS1Wf+bTTZpdLougwt5pcgA1tuz6Jcx0fpH/7z0qd71RKnZHBCxIRBHfBOnio4gViPemNzA== +handlebars@^4.1.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/handlebars/-/handlebars-4.1.0.tgz#0d6a6f34ff1f63cecec8423aa4169827bf787c3a" + integrity sha512-l2jRuU1NAWK6AW5qqcTATWQJvNPEwkM7NEKSiv/gqOsoSQbVoWyqVEY5GS+XPQ88zLNmqASRpzfdm8d79hJS+w== dependencies: async "^2.5.0" optimist "^0.6.1" @@ -3421,11 +3748,6 @@ has-ansi@^2.0.0: dependencies: ansi-regex "^2.0.0" -has-flag@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-1.0.0.tgz#9d9e793165ce017a00f00418c43f942a7b1d11fa" - integrity sha1-nZ55MWXOAXoA8AQYxD+UKnsdEfo= - has-flag@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-3.0.0.tgz#b5d454dc2199ae225699f3467e5a07f3b955bafd" @@ -3682,6 +4004,13 @@ is-ci@^1.0.10: dependencies: ci-info "^1.5.0" +is-ci@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/is-ci/-/is-ci-2.0.0.tgz#6bc6334181810e04b5c22b3d589fdca55026404c" + integrity sha512-YfJT7rkpQB0updsdHLGWrvhBJfcfzNNawYDNIyQXJz0IViGf75O8EBPKSdvw2rF+LGCsX4FZ8tcr3b19LcZq4w== + dependencies: + ci-info "^2.0.0" + is-data-descriptor@^0.1.4: version "0.1.4" resolved "https://registry.yarnpkg.com/is-data-descriptor/-/is-data-descriptor-0.1.4.tgz#0b5ee648388e2c860282e793f1856fec3f301b56" @@ -3777,6 +4106,11 @@ is-generator-fn@^1.0.0: resolved "https://registry.yarnpkg.com/is-generator-fn/-/is-generator-fn-1.0.0.tgz#969d49e1bb3329f6bb7f09089be26578b2ddd46a" integrity sha1-lp1J4bszKfa7fwkIm+JleLLd1Go= +is-generator-fn@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/is-generator-fn/-/is-generator-fn-2.0.0.tgz#038c31b774709641bda678b1f06a4e3227c10b3e" + integrity sha512-elzyIdM7iKoFHzcrndIqjYomImhxrFRnGP3galODoII4TB9gI7mZ+FnlLQmmjf27SxHS2gKEeyhX5/+YRS6H9g== + is-glob@^2.0.0, is-glob@^2.0.1: version "2.0.1" resolved "https://registry.yarnpkg.com/is-glob/-/is-glob-2.0.1.tgz#d096f926a3ded5600f3fdfd91198cb0888c2d863" @@ -3918,36 +4252,43 @@ isstream@~0.1.2: resolved "https://registry.yarnpkg.com/isstream/-/isstream-0.1.2.tgz#47e63f7af55afa6f92e1500e690eb8b8529c099a" integrity sha1-R+Y/evVa+m+S4VAOaQ64uFKcCZo= -istanbul-api@^1.3.1: - version "1.3.7" - resolved "https://registry.yarnpkg.com/istanbul-api/-/istanbul-api-1.3.7.tgz#a86c770d2b03e11e3f778cd7aedd82d2722092aa" - integrity sha512-4/ApBnMVeEPG3EkSzcw25wDe4N66wxwn+KKn6b47vyek8Xb3NBAcg4xfuQbS7BqcZuTX4wxfD5lVagdggR3gyA== - dependencies: - async "^2.1.4" - fileset "^2.0.2" - istanbul-lib-coverage "^1.2.1" - istanbul-lib-hook "^1.2.2" - istanbul-lib-instrument "^1.10.2" - istanbul-lib-report "^1.1.5" - istanbul-lib-source-maps "^1.2.6" - istanbul-reports "^1.5.1" - js-yaml "^3.7.0" - mkdirp "^0.5.1" +istanbul-api@^2.1.1: + version "2.1.1" + resolved "https://registry.yarnpkg.com/istanbul-api/-/istanbul-api-2.1.1.tgz#194b773f6d9cbc99a9258446848b0f988951c4d0" + integrity sha512-kVmYrehiwyeBAk/wE71tW6emzLiHGjYIiDrc8sfyty4F8M02/lrgXSm+R1kXysmF20zArvmZXjlE/mg24TVPJw== + dependencies: + async "^2.6.1" + compare-versions "^3.2.1" + fileset "^2.0.3" + istanbul-lib-coverage "^2.0.3" + istanbul-lib-hook "^2.0.3" + istanbul-lib-instrument "^3.1.0" + istanbul-lib-report "^2.0.4" + istanbul-lib-source-maps "^3.0.2" + istanbul-reports "^2.1.1" + js-yaml "^3.12.0" + make-dir "^1.3.0" + minimatch "^3.0.4" once "^1.4.0" -istanbul-lib-coverage@^1.2.0, istanbul-lib-coverage@^1.2.1: +istanbul-lib-coverage@^1.2.1: version "1.2.1" resolved "https://registry.yarnpkg.com/istanbul-lib-coverage/-/istanbul-lib-coverage-1.2.1.tgz#ccf7edcd0a0bb9b8f729feeb0930470f9af664f0" integrity sha512-PzITeunAgyGbtY1ibVIUiV679EFChHjoMNRibEIobvmrCRaIgwLxNucOSimtNWUhEib/oO7QY2imD75JVgCJWQ== -istanbul-lib-hook@^1.2.2: - version "1.2.2" - resolved "https://registry.yarnpkg.com/istanbul-lib-hook/-/istanbul-lib-hook-1.2.2.tgz#bc6bf07f12a641fbf1c85391d0daa8f0aea6bf86" - integrity sha512-/Jmq7Y1VeHnZEQ3TL10VHyb564mn6VrQXHchON9Jf/AEcmQ3ZIiyD1BVzNOKTZf/G3gE+kiGK6SmpF9y3qGPLw== +istanbul-lib-coverage@^2.0.2, istanbul-lib-coverage@^2.0.3: + version "2.0.3" + resolved "https://registry.yarnpkg.com/istanbul-lib-coverage/-/istanbul-lib-coverage-2.0.3.tgz#0b891e5ad42312c2b9488554f603795f9a2211ba" + integrity sha512-dKWuzRGCs4G+67VfW9pBFFz2Jpi4vSp/k7zBcJ888ofV5Mi1g5CUML5GvMvV6u9Cjybftu+E8Cgp+k0dI1E5lw== + +istanbul-lib-hook@^2.0.3: + version "2.0.3" + resolved "https://registry.yarnpkg.com/istanbul-lib-hook/-/istanbul-lib-hook-2.0.3.tgz#e0e581e461c611be5d0e5ef31c5f0109759916fb" + integrity sha512-CLmEqwEhuCYtGcpNVJjLV1DQyVnIqavMLFHV/DP+np/g3qvdxu3gsPqYoJMXm15sN84xOlckFB3VNvRbf5yEgA== dependencies: - append-transform "^0.4.0" + append-transform "^1.0.0" -istanbul-lib-instrument@^1.10.1, istanbul-lib-instrument@^1.10.2: +istanbul-lib-instrument@^1.10.1: version "1.10.2" resolved "https://registry.yarnpkg.com/istanbul-lib-instrument/-/istanbul-lib-instrument-1.10.2.tgz#1f55ed10ac3c47f2bdddd5307935126754d0a9ca" integrity sha512-aWHxfxDqvh/ZlxR8BBaEPVSWDPUkGD63VjGQn3jcw8jCp7sHEMKcrj4xfJn/ABzdMEHiQNyvDQhqm5o8+SQg7A== @@ -3960,82 +4301,72 @@ istanbul-lib-instrument@^1.10.1, istanbul-lib-instrument@^1.10.2: istanbul-lib-coverage "^1.2.1" semver "^5.3.0" -istanbul-lib-report@^1.1.5: - version "1.1.5" - resolved "https://registry.yarnpkg.com/istanbul-lib-report/-/istanbul-lib-report-1.1.5.tgz#f2a657fc6282f96170aaf281eb30a458f7f4170c" - integrity sha512-UsYfRMoi6QO/doUshYNqcKJqVmFe9w51GZz8BS3WB0lYxAllQYklka2wP9+dGZeHYaWIdcXUx8JGdbqaoXRXzw== +istanbul-lib-instrument@^3.0.0, istanbul-lib-instrument@^3.0.1, istanbul-lib-instrument@^3.1.0: + version "3.1.0" + resolved "https://registry.yarnpkg.com/istanbul-lib-instrument/-/istanbul-lib-instrument-3.1.0.tgz#a2b5484a7d445f1f311e93190813fa56dfb62971" + integrity sha512-ooVllVGT38HIk8MxDj/OIHXSYvH+1tq/Vb38s8ixt9GoJadXska4WkGY+0wkmtYCZNYtaARniH/DixUGGLZ0uA== dependencies: - istanbul-lib-coverage "^1.2.1" - mkdirp "^0.5.1" - path-parse "^1.0.5" - supports-color "^3.1.2" + "@babel/generator" "^7.0.0" + "@babel/parser" "^7.0.0" + "@babel/template" "^7.0.0" + "@babel/traverse" "^7.0.0" + "@babel/types" "^7.0.0" + istanbul-lib-coverage "^2.0.3" + semver "^5.5.0" -istanbul-lib-source-maps@^1.2.4, istanbul-lib-source-maps@^1.2.6: - version "1.2.6" - resolved "https://registry.yarnpkg.com/istanbul-lib-source-maps/-/istanbul-lib-source-maps-1.2.6.tgz#37b9ff661580f8fca11232752ee42e08c6675d8f" - integrity sha512-TtbsY5GIHgbMsMiRw35YBHGpZ1DVFEO19vxxeiDMYaeOFOCzfnYVxvl6pOUIZR4dtPhAGpSMup8OyF8ubsaqEg== +istanbul-lib-report@^2.0.4: + version "2.0.4" + resolved "https://registry.yarnpkg.com/istanbul-lib-report/-/istanbul-lib-report-2.0.4.tgz#bfd324ee0c04f59119cb4f07dab157d09f24d7e4" + integrity sha512-sOiLZLAWpA0+3b5w5/dq0cjm2rrNdAfHWaGhmn7XEFW6X++IV9Ohn+pnELAl9K3rfpaeBfbmH9JU5sejacdLeA== dependencies: - debug "^3.1.0" - istanbul-lib-coverage "^1.2.1" - mkdirp "^0.5.1" - rimraf "^2.6.1" - source-map "^0.5.3" + istanbul-lib-coverage "^2.0.3" + make-dir "^1.3.0" + supports-color "^6.0.0" -istanbul-reports@^1.5.1: - version "1.5.1" - resolved "https://registry.yarnpkg.com/istanbul-reports/-/istanbul-reports-1.5.1.tgz#97e4dbf3b515e8c484caea15d6524eebd3ff4e1a" - integrity sha512-+cfoZ0UXzWjhAdzosCPP3AN8vvef8XDkWtTfgaN+7L3YTpNYITnCaEkceo5SEYy644VkHka/P1FvkWvrG/rrJw== +istanbul-lib-source-maps@^3.0.1, istanbul-lib-source-maps@^3.0.2: + version "3.0.2" + resolved "https://registry.yarnpkg.com/istanbul-lib-source-maps/-/istanbul-lib-source-maps-3.0.2.tgz#f1e817229a9146e8424a28e5d69ba220fda34156" + integrity sha512-JX4v0CiKTGp9fZPmoxpu9YEkPbEqCqBbO3403VabKjH+NRXo72HafD5UgnjTEqHL2SAjaZK1XDuDOkn6I5QVfQ== dependencies: - handlebars "^4.0.3" + debug "^4.1.1" + istanbul-lib-coverage "^2.0.3" + make-dir "^1.3.0" + rimraf "^2.6.2" + source-map "^0.6.1" -jest-changed-files@^24.0.0-alpha.6: - version "24.0.0-alpha.6" - resolved "https://registry.yarnpkg.com/jest-changed-files/-/jest-changed-files-24.0.0-alpha.6.tgz#f3fd2e96f67f3e1e7e2bc74fc7c81c5e53801404" - integrity sha512-0Z2UpqTqMNhMNEtIK/1nCD7jR4+w1YM7zAaMFQMJG28UiV0Oqarn9u5OeH66BbUvB9FnKvVJTrSPpgPpR9f2YA== +istanbul-reports@^2.1.1: + version "2.1.1" + resolved "https://registry.yarnpkg.com/istanbul-reports/-/istanbul-reports-2.1.1.tgz#72ef16b4ecb9a4a7bd0e2001e00f95d1eec8afa9" + integrity sha512-FzNahnidyEPBCI0HcufJoSEoKykesRlFcSzQqjH9x0+LC8tnnE/p/90PBLu8iZTxr8yYZNyTtiAujUqyN+CIxw== + dependencies: + handlebars "^4.1.0" + +jest-changed-files@^24.3.0: + version "24.3.0" + resolved "https://registry.yarnpkg.com/jest-changed-files/-/jest-changed-files-24.3.0.tgz#7050ae29aaf1d59437c80f21d5b3cd354e88a499" + integrity sha512-fTq0YAUR6644fgsqLC7Zi2gXA/bAplMRvfXQdutmkwgrCKK6upkj+sgXqsUfUZRm15CVr3YSojr/GRNn71IMvg== dependencies: + "@jest/types" "^24.3.0" execa "^1.0.0" throat "^4.0.0" -jest-cli@^24.0.0-alpha.6: - version "24.0.0-alpha.6" - resolved "https://registry.yarnpkg.com/jest-cli/-/jest-cli-24.0.0-alpha.6.tgz#d5e4ee6c39d2912a70ac78352521d8c606ea27b9" - integrity sha512-xPp1CqmyE1i66hnci4Mk/eRrPHAKAmWZjKXDTa084NSpmEVnvbapDFEcSlWFvEhzGx5Hux8nIXjk8qr1ODAA4Q== +jest-cli@^24.1.0: + version "24.4.0" + resolved "https://registry.yarnpkg.com/jest-cli/-/jest-cli-24.4.0.tgz#3297c2f817611b86ce1250fb5703a28bca201034" + integrity sha512-QQOgpRpXoDqpxhEux/AGyI9XJzVOJ5ppz4Kb9MlA5PvzsyYD3DRk/uiyJgmvBhCCXvcA1CKEl/g/LH0kbKg10Q== dependencies: - ansi-escapes "^3.0.0" + "@jest/core" "^24.4.0" + "@jest/test-result" "^24.3.0" + "@jest/types" "^24.3.0" chalk "^2.0.1" exit "^0.1.2" - glob "^7.1.2" - graceful-fs "^4.1.11" import-local "^2.0.0" - is-ci "^1.0.10" - istanbul-api "^1.3.1" - istanbul-lib-coverage "^1.2.0" - istanbul-lib-instrument "^1.10.1" - istanbul-lib-source-maps "^1.2.4" - jest-changed-files "^24.0.0-alpha.6" - jest-config "^24.0.0-alpha.6" - jest-environment-jsdom "^24.0.0-alpha.6" - jest-get-type "^24.0.0-alpha.6" - jest-haste-map "^24.0.0-alpha.6" - jest-message-util "^24.0.0-alpha.6" - jest-regex-util "^24.0.0-alpha.6" - jest-resolve-dependencies "^24.0.0-alpha.6" - jest-runner "^24.0.0-alpha.6" - jest-runtime "^24.0.0-alpha.6" - jest-snapshot "^24.0.0-alpha.6" - jest-util "^24.0.0-alpha.6" - jest-validate "^24.0.0-alpha.6" - jest-watcher "^24.0.0-alpha.6" - jest-worker "^24.0.0-alpha.6" - micromatch "^2.3.11" - node-notifier "^5.2.1" - prompts "^1.1.0" - realpath-native "^1.0.0" - rimraf "^2.5.4" - slash "^2.0.0" - string-length "^2.0.0" - strip-ansi "^5.0.0" - which "^1.2.12" + is-ci "^2.0.0" + jest-config "^24.4.0" + jest-util "^24.3.0" + jest-validate "^24.4.0" + prompts "^2.0.1" + realpath-native "^1.1.0" yargs "^12.0.2" jest-config@^23.6.0: @@ -4058,25 +4389,27 @@ jest-config@^23.6.0: micromatch "^2.3.11" pretty-format "^23.6.0" -jest-config@^24.0.0-alpha.6: - version "24.0.0-alpha.6" - resolved "https://registry.yarnpkg.com/jest-config/-/jest-config-24.0.0-alpha.6.tgz#63f86a568a4e2135bee93396dedca04c7a2da14b" - integrity sha512-f9fGnkqxuYZnrioQ05eWZLSp750h+VkWJ1EU5xrf9zRR7Zu9BUTPubomvT0/FUbxK9QszxmU5SMKvdNKuwrwpw== +jest-config@^24.4.0: + version "24.4.0" + resolved "https://registry.yarnpkg.com/jest-config/-/jest-config-24.4.0.tgz#07bf14d43c02aec3bd384121a165a6ee9d8c5ed1" + integrity sha512-H2R6qkfUPck+OlIWsjeShecbqYiEDUvzZfsfgQkx6LVakAORy7wZFptONVF+Qz7iO9Bl6x35cBA2A1o1W+ctDg== dependencies: - babel-core "^6.0.0" - babel-jest "^24.0.0-alpha.6" + "@babel/core" "^7.1.0" + "@jest/types" "^24.3.0" + babel-jest "^24.4.0" chalk "^2.0.1" glob "^7.1.1" - jest-environment-jsdom "^24.0.0-alpha.6" - jest-environment-node "^24.0.0-alpha.6" - jest-get-type "^24.0.0-alpha.6" - jest-jasmine2 "^24.0.0-alpha.6" - jest-regex-util "^24.0.0-alpha.6" - jest-resolve "^24.0.0-alpha.6" - jest-util "^24.0.0-alpha.6" - jest-validate "^24.0.0-alpha.6" - micromatch "^2.3.11" - pretty-format "^24.0.0-alpha.6" + jest-environment-jsdom "^24.4.0" + jest-environment-node "^24.4.0" + jest-get-type "^24.3.0" + jest-jasmine2 "^24.4.0" + jest-regex-util "^24.3.0" + jest-resolve "^24.4.0" + jest-util "^24.3.0" + jest-validate "^24.4.0" + micromatch "^3.1.10" + pretty-format "^24.4.0" + realpath-native "^1.1.0" jest-diff@^23.6.0: version "23.6.0" @@ -4088,25 +4421,25 @@ jest-diff@^23.6.0: jest-get-type "^22.1.0" pretty-format "^23.6.0" -jest-diff@^24.0.0-alpha.6: - version "24.0.0-alpha.6" - resolved "https://registry.yarnpkg.com/jest-diff/-/jest-diff-24.0.0-alpha.6.tgz#9770b9d2067d40f3f8ff4001fcaf0eb0e5390f36" - integrity sha512-WXk920DseU/E93jfRv47RLUmYfZeVmEDDE2VF3P2tMoJSCsZ3A00KbjCtlgJ/8hXA7vPLPJN6SBcb5kqqRJ/RQ== +jest-diff@^24.4.0: + version "24.4.0" + resolved "https://registry.yarnpkg.com/jest-diff/-/jest-diff-24.4.0.tgz#106cd0491cb32da31debbea3e21f094d358dc7d9" + integrity sha512-2GdKN8GOledWkMGXcRCSr3KVTrjZU6vxbfZzwzRlM7gSG8HNIx+eoFXauQNQ5j7q73fZCoPnyS5/uOcXQ3wkWg== dependencies: chalk "^2.0.1" - diff "^3.2.0" - jest-get-type "^24.0.0-alpha.6" - pretty-format "^24.0.0-alpha.6" + diff-sequences "^24.3.0" + jest-get-type "^24.3.0" + pretty-format "^24.4.0" jest-docblock@^21.0.0: version "21.2.0" resolved "https://registry.yarnpkg.com/jest-docblock/-/jest-docblock-21.2.0.tgz#51529c3b30d5fd159da60c27ceedc195faf8d414" integrity sha512-5IZ7sY9dBAYSV+YjQ0Ovb540Ku7AO9Z5o2Cg789xj167iQuZ2cG+z0f3Uct6WeYLbU6aQiM2pCs7sZ+4dotydw== -jest-docblock@^24.0.0-alpha.6: - version "24.0.0-alpha.6" - resolved "https://registry.yarnpkg.com/jest-docblock/-/jest-docblock-24.0.0-alpha.6.tgz#abb38d04afd624cbfb34e13fa9e0c1053388a333" - integrity sha512-veghPy2eBQ5r8XXd+VLK7AfCxJMTwqA8B2fknR24aibIkGW7dj4fq538HtwIvXkRpUO5f1b5x6IEsCb9g+e6qw== +jest-docblock@^24.3.0: + version "24.3.0" + resolved "https://registry.yarnpkg.com/jest-docblock/-/jest-docblock-24.3.0.tgz#b9c32dac70f72e4464520d2ba4aec02ab14db5dd" + integrity sha512-nlANmF9Yq1dufhFlKG9rasfQlrY7wINJbo3q01tu56Jv5eBU5jirylhF2O5ZBnLxzOVBGRDz/9NAwNyBtG4Nyg== dependencies: detect-newline "^2.1.0" @@ -4118,14 +4451,16 @@ jest-each@^23.6.0: chalk "^2.0.1" pretty-format "^23.6.0" -jest-each@^24.0.0-alpha.6: - version "24.0.0-alpha.6" - resolved "https://registry.yarnpkg.com/jest-each/-/jest-each-24.0.0-alpha.6.tgz#9f73236c940ec82fca62992435c671cfa9a871eb" - integrity sha512-l9Dm0R6dKUT+4wRsQTAm52tAlcI0QQPOuLYouN997Ac/0t+dwPH9j/gMxpcSw6GHf3g208jZIPaA/fbR1ZMh9Q== +jest-each@^24.4.0: + version "24.4.0" + resolved "https://registry.yarnpkg.com/jest-each/-/jest-each-24.4.0.tgz#2a0e06d957b31ec9ca4679ed9d4a15ac48299d6b" + integrity sha512-W98N4Ep6BBdCanynA9jdJDUaPvZ9OAnIHNA8mK6kbH7JYdnNQKGvp5ivl/PjCTqiI2wnHKYRI06EjsfOqT8ZFQ== dependencies: + "@jest/types" "^24.3.0" chalk "^2.0.1" - jest-util "^24.0.0-alpha.6" - pretty-format "^24.0.0-alpha.6" + jest-get-type "^24.3.0" + jest-util "^24.3.0" + pretty-format "^24.4.0" jest-environment-jsdom@^23.4.0: version "23.4.0" @@ -4136,13 +4471,16 @@ jest-environment-jsdom@^23.4.0: jest-util "^23.4.0" jsdom "^11.5.1" -jest-environment-jsdom@^24.0.0-alpha.6: - version "24.0.0-alpha.6" - resolved "https://registry.yarnpkg.com/jest-environment-jsdom/-/jest-environment-jsdom-24.0.0-alpha.6.tgz#a829e26120a056a6c0a4dbdf20b7d2bbb6a306bd" - integrity sha512-wM3z01cTdUzS1/l0k/74AxU01Uzz7KT5s45wEqrJk2YTztbRo8epEUg0rhd7kPwxYoqbEW/fpgszzMKETcS/4A== +jest-environment-jsdom@^24.4.0: + version "24.4.0" + resolved "https://registry.yarnpkg.com/jest-environment-jsdom/-/jest-environment-jsdom-24.4.0.tgz#86e1c494abb1ab58b7aa5791bdb4fa96d709b57b" + integrity sha512-7irZXPZLQF79r97uH9dG9mm76H+27CMSH8TEcF70x6pY4xFJipjjluiXRw1C2lh0o6FrbSQKpkSXncdOw+hY0A== dependencies: - jest-mock "^24.0.0-alpha.6" - jest-util "^24.0.0-alpha.6" + "@jest/environment" "^24.4.0" + "@jest/fake-timers" "^24.3.0" + "@jest/types" "^24.3.0" + jest-mock "^24.3.0" + jest-util "^24.3.0" jsdom "^11.5.1" jest-environment-node@^23.4.0: @@ -4153,25 +4491,28 @@ jest-environment-node@^23.4.0: jest-mock "^23.2.0" jest-util "^23.4.0" -jest-environment-node@^24.0.0-alpha.6: - version "24.0.0-alpha.6" - resolved "https://registry.yarnpkg.com/jest-environment-node/-/jest-environment-node-24.0.0-alpha.6.tgz#81104a599f1db3afc7c2c2c17d1cc2772e3a8870" - integrity sha512-23QNlMuij/DqbJknKste29nOBiK/ly7fN2RkIOkeEBmimTObM8ou0C7k21jkxVnBQOtAjWuHpv0ycz1YK6G5RA== +jest-environment-node@^24.4.0: + version "24.4.0" + resolved "https://registry.yarnpkg.com/jest-environment-node/-/jest-environment-node-24.4.0.tgz#c10cd617ccc73c1936d46a925e9dcade8709d044" + integrity sha512-ed1TjncsHO+Ird4BDrWwqsMQQM+bg9AFHj0AcCumgzfc+Us6ywWUQUg+5UbKLKnu1EWp5mK7mmbLxLqdz2kc9w== dependencies: - jest-mock "^24.0.0-alpha.6" - jest-util "^24.0.0-alpha.6" + "@jest/environment" "^24.4.0" + "@jest/fake-timers" "^24.3.0" + "@jest/types" "^24.3.0" + jest-mock "^24.3.0" + jest-util "^24.3.0" jest-get-type@^22.1.0: version "22.4.3" resolved "https://registry.yarnpkg.com/jest-get-type/-/jest-get-type-22.4.3.tgz#e3a8504d8479342dd4420236b322869f18900ce4" integrity sha512-/jsz0Y+V29w1chdXVygEKSz2nBoHoYqNShPe+QgxSNjAuP1i8+k4LbQNrfoliKej0P45sivkSCh7yiD6ubHS3w== -jest-get-type@^24.0.0-alpha.6: - version "24.0.0-alpha.6" - resolved "https://registry.yarnpkg.com/jest-get-type/-/jest-get-type-24.0.0-alpha.6.tgz#23cc13e4e04c61f001356529675a6aec5a2ef53d" - integrity sha512-U9hmkEfO5dtccZ96iQgbPARorzyVRYWiRnrm5GO4l5iJOpK86fuUsZLjETu+cOpd72RVh00aEm/tVOhZrLizbA== +jest-get-type@^24.3.0: + version "24.3.0" + resolved "https://registry.yarnpkg.com/jest-get-type/-/jest-get-type-24.3.0.tgz#582cfd1a4f91b5cdad1d43d2932f816d543c65da" + integrity sha512-HYF6pry72YUlVcvUx3sEpMRwXEWGEPlJ0bSPVnB3b3n++j4phUEoSPcS6GC0pPJ9rpyPSe4cb5muFo6D39cXow== -jest-haste-map@24.0.0-alpha.6, jest-haste-map@^24.0.0-alpha.6: +jest-haste-map@24.0.0-alpha.6: version "24.0.0-alpha.6" resolved "https://registry.yarnpkg.com/jest-haste-map/-/jest-haste-map-24.0.0-alpha.6.tgz#fb2c785080f391b923db51846b86840d0d773076" integrity sha512-+NO2HMbjvrG8BC39ieLukdpFrcPhhjCJGhpbHodHNZygH1Tt06WrlNYGpZtWKx/zpf533tCtMQXO/q59JenjNw== @@ -4184,6 +4525,21 @@ jest-haste-map@24.0.0-alpha.6, jest-haste-map@^24.0.0-alpha.6: micromatch "^2.3.11" sane "^3.0.0" +jest-haste-map@^24.4.0: + version "24.4.0" + resolved "https://registry.yarnpkg.com/jest-haste-map/-/jest-haste-map-24.4.0.tgz#a969ecab8a9521115c5fecec82366d66433c851b" + integrity sha512-X20xhhPBjbz4UVTN9BMBjlFUM/gmi1TmYWWxZUgLg4fZXMIve4RUdA/nS/QgC76ouGgvwb9z52KwZ85bmNx55A== + dependencies: + "@jest/types" "^24.3.0" + fb-watchman "^2.0.0" + graceful-fs "^4.1.15" + invariant "^2.2.4" + jest-serializer "^24.4.0" + jest-util "^24.3.0" + jest-worker "^24.4.0" + micromatch "^3.1.10" + sane "^4.0.3" + jest-jasmine2@^23.6.0: version "23.6.0" resolved "https://registry.yarnpkg.com/jest-jasmine2/-/jest-jasmine2-23.6.0.tgz#840e937f848a6c8638df24360ab869cc718592e0" @@ -4202,23 +4558,27 @@ jest-jasmine2@^23.6.0: jest-util "^23.4.0" pretty-format "^23.6.0" -jest-jasmine2@^24.0.0-alpha.6: - version "24.0.0-alpha.6" - resolved "https://registry.yarnpkg.com/jest-jasmine2/-/jest-jasmine2-24.0.0-alpha.6.tgz#a3ea4ac5e71c366360bfebc96fd2b5a6274b3292" - integrity sha512-u00yGK7La1O2PVCuAhQ7bepRsOJmrdtEZVAzvganBfxqNzEIEeBtsBgv4MrQDb/CqM43XqTtJIo5Cb8AiUsxrw== +jest-jasmine2@^24.4.0: + version "24.4.0" + resolved "https://registry.yarnpkg.com/jest-jasmine2/-/jest-jasmine2-24.4.0.tgz#f1d3749b1fc4a90cbdca1480f0ce932d135b69e5" + integrity sha512-J9A0SKWuUNDmXKU+a3Yj69NmUXK7R3btHHu1ZMpjHKlMoHggVjdzsolpNHELCENBOTXvcLXqEH0Xm+pYRoNfMw== dependencies: - babel-traverse "^6.0.0" + "@babel/traverse" "^7.1.0" + "@jest/environment" "^24.4.0" + "@jest/test-result" "^24.3.0" + "@jest/types" "^24.3.0" chalk "^2.0.1" co "^4.6.0" - expect "^24.0.0-alpha.6" - is-generator-fn "^1.0.0" - jest-diff "^24.0.0-alpha.6" - jest-each "^24.0.0-alpha.6" - jest-matcher-utils "^24.0.0-alpha.6" - jest-message-util "^24.0.0-alpha.6" - jest-snapshot "^24.0.0-alpha.6" - jest-util "^24.0.0-alpha.6" - pretty-format "^24.0.0-alpha.6" + expect "^24.4.0" + is-generator-fn "^2.0.0" + jest-each "^24.4.0" + jest-matcher-utils "^24.4.0" + jest-message-util "^24.3.0" + jest-runtime "^24.4.0" + jest-snapshot "^24.4.0" + jest-util "^24.3.0" + pretty-format "^24.4.0" + throat "^4.0.0" jest-junit@5.2.0: version "5.2.0" @@ -4231,12 +4591,12 @@ jest-junit@5.2.0: strip-ansi "^4.0.0" xml "^1.0.1" -jest-leak-detector@^24.0.0-alpha.6: - version "24.0.0-alpha.6" - resolved "https://registry.yarnpkg.com/jest-leak-detector/-/jest-leak-detector-24.0.0-alpha.6.tgz#01f95a351f6689f7162224bbdcde3ccdca6b0a8e" - integrity sha512-jFjDN9F5H47lE8TgM1+K4cR6ep3/cKwx+PP/qnuJpwKeKEp69DyvxXYriExbq54eo3Ed5yq7yH+PsAf6dwllew== +jest-leak-detector@^24.4.0: + version "24.4.0" + resolved "https://registry.yarnpkg.com/jest-leak-detector/-/jest-leak-detector-24.4.0.tgz#f255d2f582b8dda7b960e04a42f7239b7ec6520b" + integrity sha512-PAo0y19ZkWZWYmdoPAQKpYTDt7IGwrTFhIwGmHO1xkRjzAWW8zcCoiMLrFwNSi9rir2ZH7el8gXZ0d2mmU7O9Q== dependencies: - pretty-format "^24.0.0-alpha.6" + pretty-format "^24.4.0" jest-matcher-utils@^23.6.0: version "23.6.0" @@ -4247,14 +4607,15 @@ jest-matcher-utils@^23.6.0: jest-get-type "^22.1.0" pretty-format "^23.6.0" -jest-matcher-utils@^24.0.0-alpha.6: - version "24.0.0-alpha.6" - resolved "https://registry.yarnpkg.com/jest-matcher-utils/-/jest-matcher-utils-24.0.0-alpha.6.tgz#124f3363fdf69d3cc940e53ce868156cc8642552" - integrity sha512-kGJff51/cbi9KcRvYW4q+k8iGM/3k07cA+nAdu8FEjsCT+xqs7mhA5TcSWpOc1qwaGftYiz9HxfHJ2gWTwPyCQ== +jest-matcher-utils@^24.4.0: + version "24.4.0" + resolved "https://registry.yarnpkg.com/jest-matcher-utils/-/jest-matcher-utils-24.4.0.tgz#285a2a5c8414d2f4a62d89ddc4b381730e2b717d" + integrity sha512-JDWrJ1G+GfxtEQlX7DlCV/0sk0uYbnra0jVl3DiDbS0FUX0HeGA1CxRW/U87LB3XNHQydhBKbXgf+pDCiUCn4w== dependencies: chalk "^2.0.1" - jest-get-type "^24.0.0-alpha.6" - pretty-format "^24.0.0-alpha.6" + jest-diff "^24.4.0" + jest-get-type "^24.3.0" + pretty-format "^24.4.0" jest-message-util@^23.4.0: version "23.4.0" @@ -4267,14 +4628,17 @@ jest-message-util@^23.4.0: slash "^1.0.0" stack-utils "^1.0.1" -jest-message-util@^24.0.0-alpha.6: - version "24.0.0-alpha.6" - resolved "https://registry.yarnpkg.com/jest-message-util/-/jest-message-util-24.0.0-alpha.6.tgz#050c9194ca710f8759907e9e12f4c53061ba46fa" - integrity sha512-6wgFC5laPLBR84EioBn1OnYPi9UijhtV6tL+eukIXOqdLfy9eY8GeGTxbphJJJUmSP9g1+wM5Mzk6ycXou4Wlg== +jest-message-util@^24.3.0: + version "24.3.0" + resolved "https://registry.yarnpkg.com/jest-message-util/-/jest-message-util-24.3.0.tgz#e8f64b63ebc75b1a9c67ee35553752596e70d4a9" + integrity sha512-lXM0YgKYGqN5/eH1NGw4Ix+Pk2I9Y77beyRas7xM24n+XTTK3TbT0VkT3L/qiyS7WkW0YwyxoXnnAaGw4hsEDA== dependencies: "@babel/code-frame" "^7.0.0" + "@jest/test-result" "^24.3.0" + "@jest/types" "^24.3.0" + "@types/stack-utils" "^1.0.1" chalk "^2.0.1" - micromatch "^2.3.11" + micromatch "^3.1.10" slash "^2.0.0" stack-utils "^1.0.1" @@ -4283,28 +4647,36 @@ jest-mock@^23.2.0: resolved "https://registry.yarnpkg.com/jest-mock/-/jest-mock-23.2.0.tgz#ad1c60f29e8719d47c26e1138098b6d18b261134" integrity sha1-rRxg8p6HGdR8JuETgJi20YsmETQ= -jest-mock@^24.0.0-alpha.6: - version "24.0.0-alpha.6" - resolved "https://registry.yarnpkg.com/jest-mock/-/jest-mock-24.0.0-alpha.6.tgz#26ee1fe581c4ee71f604ffd4fae6743d8d3a899d" - integrity sha512-1wrKUhTwSi4BNk3ztjbS6IgBrPyWno6ClHekSHefB82PbKtZAJ2PbU2sTAqkBP/OZetFPIe3BgaHuoumsuZazg== +jest-mock@^24.3.0: + version "24.3.0" + resolved "https://registry.yarnpkg.com/jest-mock/-/jest-mock-24.3.0.tgz#95a86b6ad474e3e33227e6dd7c4ff6b07e18d3cb" + integrity sha512-AhAo0qjbVWWGvcbW5nChFjR0ObQImvGtU6DodprNziDOt+pP0CBdht/sYcNIOXeim8083QUi9bC8QdKB8PTK4Q== + dependencies: + "@jest/types" "^24.3.0" + +jest-pnp-resolver@^1.2.1: + version "1.2.1" + resolved "https://registry.yarnpkg.com/jest-pnp-resolver/-/jest-pnp-resolver-1.2.1.tgz#ecdae604c077a7fbc70defb6d517c3c1c898923a" + integrity sha512-pgFw2tm54fzgYvc/OHrnysABEObZCUNFnhjoRjaVOCN8NYc032/gVjPaHD4Aq6ApkSieWtfKAFQtmDKAmhupnQ== jest-regex-util@^23.3.0: version "23.3.0" resolved "https://registry.yarnpkg.com/jest-regex-util/-/jest-regex-util-23.3.0.tgz#5f86729547c2785c4002ceaa8f849fe8ca471bc5" integrity sha1-X4ZylUfCeFxAAs6qj4Sf6MpHG8U= -jest-regex-util@^24.0.0-alpha.6: - version "24.0.0-alpha.6" - resolved "https://registry.yarnpkg.com/jest-regex-util/-/jest-regex-util-24.0.0-alpha.6.tgz#290684073641e2be4c0a5ddaaf4450d7956f7b57" - integrity sha512-kfV9Z/Sfj/PRcuJLrnk4IoOC0GDfzEn+GmPZ2PI8ql+xa3EYq/+bM75SnbvM6axLaaiLavxPZfoAY5UK07N1Wg== +jest-regex-util@^24.3.0: + version "24.3.0" + resolved "https://registry.yarnpkg.com/jest-regex-util/-/jest-regex-util-24.3.0.tgz#d5a65f60be1ae3e310d5214a0307581995227b36" + integrity sha512-tXQR1NEOyGlfylyEjg1ImtScwMq8Oh3iJbGTjN7p0J23EuVX1MA8rwU69K4sLbCmwzgCUbVkm0FkSF9TdzOhtg== -jest-resolve-dependencies@^24.0.0-alpha.6: - version "24.0.0-alpha.6" - resolved "https://registry.yarnpkg.com/jest-resolve-dependencies/-/jest-resolve-dependencies-24.0.0-alpha.6.tgz#a345714786dfed646ca0e1d69c03e99f54c7f415" - integrity sha512-llBtvVgESLt7xPK3NGVYNb7FSr15GzDXJPkYyhvXV7ox1/8hSurWieKis19tWoqkC81zTeQNM/65CAcv7EPVug== +jest-resolve-dependencies@^24.4.0: + version "24.4.0" + resolved "https://registry.yarnpkg.com/jest-resolve-dependencies/-/jest-resolve-dependencies-24.4.0.tgz#296420c04211d2697dfe3141744e7071028ea9b0" + integrity sha512-3ssDSve3iSsIKm5daivq1mrCaBVFAa+TMG4qardNPoi7IJfupDUETIBCXYF9GRtIfNuD/dJOSag4u6oMHRxTGg== dependencies: - jest-regex-util "^24.0.0-alpha.6" - jest-snapshot "^24.0.0-alpha.6" + "@jest/types" "^24.3.0" + jest-regex-util "^24.3.0" + jest-snapshot "^24.4.0" jest-resolve@^23.6.0: version "23.6.0" @@ -4315,60 +4687,69 @@ jest-resolve@^23.6.0: chalk "^2.0.1" realpath-native "^1.0.0" -jest-resolve@^24.0.0-alpha.6: - version "24.0.0-alpha.6" - resolved "https://registry.yarnpkg.com/jest-resolve/-/jest-resolve-24.0.0-alpha.6.tgz#652abbae048b531311315aa546c5c8ad663ea6a2" - integrity sha512-+RFkYvG5DJ6A2R2r8zrJX3Hv9byIM0Ytrib2mpc8FNrLAe5fEEmaC+GdcVx5b0ybh1F7ZPoFNSoEWKZpK9+76A== +jest-resolve@^24.4.0: + version "24.4.0" + resolved "https://registry.yarnpkg.com/jest-resolve/-/jest-resolve-24.4.0.tgz#5314af3cc9abc8d2de55c6e78edac4253c2f46f3" + integrity sha512-XvMIuDH6wQi76YJfNG40iolXP2l+fA+LLORGgNSZ5VgowCeyV/XVygTN4L3No3GP1cthUdl/ULzWBd2CfYmTkw== dependencies: + "@jest/types" "^24.3.0" browser-resolve "^1.11.3" chalk "^2.0.1" - realpath-native "^1.0.0" - -jest-runner@^24.0.0-alpha.6: - version "24.0.0-alpha.6" - resolved "https://registry.yarnpkg.com/jest-runner/-/jest-runner-24.0.0-alpha.6.tgz#520692dfc07de1cfe4261c806a9b8f0225bd16df" - integrity sha512-EeQ4pkfwPakGREYcKi8oJc/OWmfkld7AaNDkClbKuaKUyS0gkGNXUc9YijvlyA8VBXYTDqMRs8E8HoWKsW5LTw== - dependencies: + jest-pnp-resolver "^1.2.1" + realpath-native "^1.1.0" + +jest-runner@^24.4.0: + version "24.4.0" + resolved "https://registry.yarnpkg.com/jest-runner/-/jest-runner-24.4.0.tgz#71ad09858be897cc37da1bf88bf67baaa0219fdb" + integrity sha512-eCuEMDbJknyKEUBWBDebW3GQ6Ty8wwB3YqDjFb4p3UQozA2HarPq0n9N83viq18vvZ/BDrQvW6RLdZaiLipM4Q== + dependencies: + "@jest/console" "^24.3.0" + "@jest/environment" "^24.4.0" + "@jest/test-result" "^24.3.0" + "@jest/types" "^24.3.0" + chalk "^2.4.2" exit "^0.1.2" - graceful-fs "^4.1.11" - jest-config "^24.0.0-alpha.6" - jest-docblock "^24.0.0-alpha.6" - jest-haste-map "^24.0.0-alpha.6" - jest-jasmine2 "^24.0.0-alpha.6" - jest-leak-detector "^24.0.0-alpha.6" - jest-message-util "^24.0.0-alpha.6" - jest-runtime "^24.0.0-alpha.6" - jest-util "^24.0.0-alpha.6" - jest-worker "^24.0.0-alpha.6" + graceful-fs "^4.1.15" + jest-config "^24.4.0" + jest-docblock "^24.3.0" + jest-haste-map "^24.4.0" + jest-jasmine2 "^24.4.0" + jest-leak-detector "^24.4.0" + jest-message-util "^24.3.0" + jest-resolve "^24.4.0" + jest-runtime "^24.4.0" + jest-util "^24.3.0" + jest-worker "^24.4.0" source-map-support "^0.5.6" throat "^4.0.0" -jest-runtime@^24.0.0-alpha.6: - version "24.0.0-alpha.6" - resolved "https://registry.yarnpkg.com/jest-runtime/-/jest-runtime-24.0.0-alpha.6.tgz#3c9e5d032324b95360736115a8182639d4120e82" - integrity sha512-91VTDRHcrvKFQRI9NeVe2+PfMekV0Bo3fNFArfmISpx3fOLqt96AbFWltAFMVkaLTLuVizyYBkKFXCfYYytQ2Q== - dependencies: - babel-core "^6.0.0" - babel-plugin-istanbul "^4.1.6" +jest-runtime@^24.4.0: + version "24.4.0" + resolved "https://registry.yarnpkg.com/jest-runtime/-/jest-runtime-24.4.0.tgz#77df2137d1cb78a30f8b7c52cc06427272e06334" + integrity sha512-wmopIA6EqgfSvYmqFvfZViJy5LCyIATUSRRt16HQDNN4ypWUQAaFwZ9fpbPo7e2UnKHTe2CK0dCRB1o/a6JUfQ== + dependencies: + "@jest/console" "^24.3.0" + "@jest/environment" "^24.4.0" + "@jest/source-map" "^24.3.0" + "@jest/transform" "^24.4.0" + "@jest/types" "^24.3.0" + "@types/yargs" "^12.0.2" chalk "^2.0.1" - convert-source-map "^1.4.0" exit "^0.1.2" - fast-json-stable-stringify "^2.0.0" glob "^7.1.3" - graceful-fs "^4.1.11" - jest-config "^24.0.0-alpha.6" - jest-haste-map "^24.0.0-alpha.6" - jest-message-util "^24.0.0-alpha.6" - jest-regex-util "^24.0.0-alpha.6" - jest-resolve "^24.0.0-alpha.6" - jest-snapshot "^24.0.0-alpha.6" - jest-util "^24.0.0-alpha.6" - jest-validate "^24.0.0-alpha.6" - micromatch "^2.3.11" - realpath-native "^1.0.0" + graceful-fs "^4.1.15" + jest-config "^24.4.0" + jest-haste-map "^24.4.0" + jest-message-util "^24.3.0" + jest-mock "^24.3.0" + jest-regex-util "^24.3.0" + jest-resolve "^24.4.0" + jest-snapshot "^24.4.0" + jest-util "^24.3.0" + jest-validate "^24.4.0" + realpath-native "^1.1.0" slash "^2.0.0" - strip-bom "3.0.0" - write-file-atomic "^2.1.0" + strip-bom "^3.0.0" yargs "^12.0.2" jest-serializer@24.0.0-alpha.6, jest-serializer@^24.0.0-alpha.6: @@ -4376,6 +4757,11 @@ jest-serializer@24.0.0-alpha.6, jest-serializer@^24.0.0-alpha.6: resolved "https://registry.yarnpkg.com/jest-serializer/-/jest-serializer-24.0.0-alpha.6.tgz#27d2fee4b1a85698717a30c3ec2ab80767312597" integrity sha512-IPA5T6/GhlE6dedSk7Cd7YfuORnYjN0VD5iJVFn1Q81RJjpj++Hen5kJbKcg547vXsQ1TddV15qOA/zeIfOCLw== +jest-serializer@^24.4.0: + version "24.4.0" + resolved "https://registry.yarnpkg.com/jest-serializer/-/jest-serializer-24.4.0.tgz#f70c5918c8ea9235ccb1276d232e459080588db3" + integrity sha512-k//0DtglVstc1fv+GY/VHDIjrtNjdYvYjMlbLUed4kxrE92sIUewOi5Hj3vrpB8CXfkJntRPDRjCrCvUhBdL8Q== + jest-snapshot@^23.6.0: version "23.6.0" resolved "https://registry.yarnpkg.com/jest-snapshot/-/jest-snapshot-23.6.0.tgz#f9c2625d1b18acda01ec2d2b826c0ce58a5aa17a" @@ -4392,20 +4778,22 @@ jest-snapshot@^23.6.0: pretty-format "^23.6.0" semver "^5.5.0" -jest-snapshot@^24.0.0-alpha.6: - version "24.0.0-alpha.6" - resolved "https://registry.yarnpkg.com/jest-snapshot/-/jest-snapshot-24.0.0-alpha.6.tgz#89659179ccd8f47e4476850f04e9810e6ea9a425" - integrity sha512-TzNqLIwje0rh637ibAoD+BO0rTngznhUnlmM1AcCIxb663oLfxzSjMIhxwcQ4bhATlsrluerNfGeqp07DEWkPQ== +jest-snapshot@^24.4.0: + version "24.4.0" + resolved "https://registry.yarnpkg.com/jest-snapshot/-/jest-snapshot-24.4.0.tgz#7e76ff377cf84af65e37b46c48bbda555e7545da" + integrity sha512-h+xO+ZQC+XEcf5wsy6+yducTKw6ku+oS5E2eJZI4YI65AT/lvbMjKgulgQWUOxga4HP0qHnz9uwa67/Zo7jVrw== dependencies: - babel-types "^6.0.0" + "@babel/types" "^7.0.0" + "@jest/types" "^24.3.0" chalk "^2.0.1" - jest-diff "^24.0.0-alpha.6" - jest-matcher-utils "^24.0.0-alpha.6" - jest-message-util "^24.0.0-alpha.6" - jest-resolve "^24.0.0-alpha.6" + expect "^24.4.0" + jest-diff "^24.4.0" + jest-matcher-utils "^24.4.0" + jest-message-util "^24.3.0" + jest-resolve "^24.4.0" mkdirp "^0.5.1" natural-compare "^1.4.0" - pretty-format "^24.0.0-alpha.6" + pretty-format "^24.4.0" semver "^5.5.0" jest-util@^23.4.0: @@ -4422,16 +4810,21 @@ jest-util@^23.4.0: slash "^1.0.0" source-map "^0.6.0" -jest-util@^24.0.0-alpha.6: - version "24.0.0-alpha.6" - resolved "https://registry.yarnpkg.com/jest-util/-/jest-util-24.0.0-alpha.6.tgz#974ce25422e1b545d225b90ac0bdcd5453dfd634" - integrity sha512-u8iGWbLABtJIJeZ0oB01n0BBUuDQT0iQvNXYN0+9WTKO+pHgv37ItYAbMQNM0NjIZig0l410VoFeWqg1KJyxpw== - dependencies: - callsites "^2.0.0" +jest-util@^24.3.0: + version "24.3.0" + resolved "https://registry.yarnpkg.com/jest-util/-/jest-util-24.3.0.tgz#a549ae9910fedbd4c5912b204bb1bcc122ea0057" + integrity sha512-eKIAC+MTKWZthUUVOwZ3Tc5a0cKMnxalQHr6qZ4kPzKn6k09sKvsmjCygqZ1SxVVfUKoa8Sfn6XDv9uTJ1iXTg== + dependencies: + "@jest/console" "^24.3.0" + "@jest/fake-timers" "^24.3.0" + "@jest/source-map" "^24.3.0" + "@jest/test-result" "^24.3.0" + "@jest/types" "^24.3.0" + "@types/node" "*" + callsites "^3.0.0" chalk "^2.0.1" - graceful-fs "^4.1.11" - is-ci "^1.0.10" - jest-message-util "^24.0.0-alpha.6" + graceful-fs "^4.1.15" + is-ci "^2.0.0" mkdirp "^0.5.1" slash "^2.0.0" source-map "^0.6.0" @@ -4446,23 +4839,30 @@ jest-validate@^23.0.1, jest-validate@^23.6.0: leven "^2.1.0" pretty-format "^23.6.0" -jest-validate@^24.0.0-alpha.6: - version "24.0.0-alpha.6" - resolved "https://registry.yarnpkg.com/jest-validate/-/jest-validate-24.0.0-alpha.6.tgz#19f8a9ac395199c9b4965297a159caf7024f4713" - integrity sha512-E6N3xiZ0EQais9WW3alpWO3NNGxvrbbwkXGPLimpSKEwpz29ezL93C4XFPnzZ2Xet+7I5SJxrvgOYkFJLreAdQ== +jest-validate@^24.4.0: + version "24.4.0" + resolved "https://registry.yarnpkg.com/jest-validate/-/jest-validate-24.4.0.tgz#4f19c7d738a6bb700620c766428c7738d6985555" + integrity sha512-XESrpRYneLmiN9ayFm9RhBV5dwmhRZ+LbebScuuQ5GsY6ILpX9UeUMUdQ5Iz++YxFsmn5Lyi/Wkw6EV4v7nNTg== dependencies: + "@jest/types" "^24.3.0" + camelcase "^5.0.0" chalk "^2.0.1" - jest-get-type "^24.0.0-alpha.6" + jest-get-type "^24.3.0" leven "^2.1.0" - pretty-format "^24.0.0-alpha.6" + pretty-format "^24.4.0" -jest-watcher@^24.0.0-alpha.6: - version "24.0.0-alpha.6" - resolved "https://registry.yarnpkg.com/jest-watcher/-/jest-watcher-24.0.0-alpha.6.tgz#e54918ae31bfed17581fa3978afbe5cf20e9c512" - integrity sha512-CxL49DV+dNa7ET1OAFGoZd0F1Bt8dgdwyycV9znLkB+RJrVm+kh8KPF24LM5p66f5oQyhAfuxO71u6eRPYkSGg== +jest-watcher@^24.3.0: + version "24.3.0" + resolved "https://registry.yarnpkg.com/jest-watcher/-/jest-watcher-24.3.0.tgz#ee51c6afbe4b35a12fcf1107556db6756d7b9290" + integrity sha512-EpJS/aUG8D3DMuy9XNA4fnkKWy3DQdoWhY92ZUdlETIeEn1xya4Np/96MBSh4II5YvxwKe6JKwbu3Bnzfwa7vA== dependencies: + "@jest/test-result" "^24.3.0" + "@jest/types" "^24.3.0" + "@types/node" "*" + "@types/yargs" "^12.0.9" ansi-escapes "^3.0.0" chalk "^2.0.1" + jest-util "^24.3.0" string-length "^2.0.0" jest-worker@24.0.0-alpha.6, jest-worker@^24.0.0-alpha.6: @@ -4472,13 +4872,22 @@ jest-worker@24.0.0-alpha.6, jest-worker@^24.0.0-alpha.6: dependencies: merge-stream "^1.0.1" -jest@24.0.0-alpha.6: - version "24.0.0-alpha.6" - resolved "https://registry.yarnpkg.com/jest/-/jest-24.0.0-alpha.6.tgz#2635f90c5f5deaeb47e9c0f3e4ab3ed290f59bf4" - integrity sha512-2mVzUbDspFFZFB0bmT4cEbWmnMqz4CGEY1EiNCngO//NL+OSEqXPLwV/wdFWwLb3QeYm7TSgTE7Mf18ZAHSrhw== +jest-worker@^24.4.0: + version "24.4.0" + resolved "https://registry.yarnpkg.com/jest-worker/-/jest-worker-24.4.0.tgz#fbc452b0120bb5c2a70cdc88fa132b48eeb11dd0" + integrity sha512-BH9X/klG9vxwoO99ZBUbZFfV8qO0XNZ5SIiCyYK2zOuJBl6YJVAeNIQjcoOVNu4HGEHeYEKsUWws8kSlSbZ9YQ== + dependencies: + "@types/node" "*" + merge-stream "^1.0.1" + supports-color "^6.1.0" + +jest@24.1.0: + version "24.1.0" + resolved "https://registry.yarnpkg.com/jest/-/jest-24.1.0.tgz#b1e1135caefcf2397950ecf7f90e395fde866fd2" + integrity sha512-+q91L65kypqklvlRFfXfdzUKyngQLOcwGhXQaLmVHv+d09LkNXuBuGxlofTFW42XMzu3giIcChchTsCNUjQ78A== dependencies: import-local "^2.0.0" - jest-cli "^24.0.0-alpha.6" + jest-cli "^24.1.0" js-levenshtein@^1.1.3: version "1.1.4" @@ -4495,7 +4904,7 @@ js-tokens@^3.0.2: resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-3.0.2.tgz#9866df395102130e38f7f996bceb65443209c25b" integrity sha1-mGbfOVECEw449/mWvOtlRDIJwls= -js-yaml@^3.11.0, js-yaml@^3.7.0, js-yaml@^3.9.0: +js-yaml@^3.11.0, js-yaml@^3.9.0: version "3.12.0" resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.12.0.tgz#eaed656ec8344f10f527c6bfa1b6e2244de167d1" integrity sha512-PIt2cnwmPfL4hKNwqeiuz4bKfnzHTBv6HyVgjahA6mPLwPDzjDWrplJBMjHUFxku/N3FlmrbyPclad+I+4mJ3A== @@ -4503,6 +4912,14 @@ js-yaml@^3.11.0, js-yaml@^3.7.0, js-yaml@^3.9.0: argparse "^1.0.7" esprima "^4.0.0" +js-yaml@^3.12.0: + version "3.12.2" + resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.12.2.tgz#ef1d067c5a9d9cb65bd72f285b5d8105c77f14fc" + integrity sha512-QHn/Lh/7HhZ/Twc7vJYQTkjuCa0kaCcDcjK5Zlk2rvnUpy7DxMJ23+Jc2dcyvltwQVg1nygAVlB2oRDFHoRS5Q== + dependencies: + argparse "^1.0.7" + esprima "^4.0.0" + jsbn@~0.1.0: version "0.1.1" resolved "https://registry.yarnpkg.com/jsbn/-/jsbn-0.1.1.tgz#a5e654c2e5a2deb5f201d96cefbca80c0ef2f513" @@ -4700,10 +5117,10 @@ klaw@^1.0.0: optionalDependencies: graceful-fs "^4.1.9" -kleur@^2.0.1: - version "2.0.2" - resolved "https://registry.yarnpkg.com/kleur/-/kleur-2.0.2.tgz#b704f4944d95e255d038f0cb05fb8a602c55a300" - integrity sha512-77XF9iTllATmG9lSlIv0qdQ2BQ/h9t0bJllHlbvsQ0zUWfU7Yi0S8L5JXzPZgkefIiajLmBJJ4BsMJmqcf7oxQ== +kleur@^3.0.2: + version "3.0.2" + resolved "https://registry.yarnpkg.com/kleur/-/kleur-3.0.2.tgz#83c7ec858a41098b613d5998a7b653962b504f68" + integrity sha512-3h7B2WRT5LNXOtQiAaWonilegHcPSf9nLVXlSTci8lu1dZUuui61+EsPEZqSVxY7rXYmB2DVKMQILxaO5WL61Q== lcid@^1.0.0: version "1.0.0" @@ -4763,6 +5180,16 @@ load-json-file@^2.0.0: pify "^2.0.0" strip-bom "^3.0.0" +load-json-file@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/load-json-file/-/load-json-file-4.0.0.tgz#2f5f45ab91e33216234fd53adab668eb4ec0993b" + integrity sha1-L19Fq5HjMhYjT9U62rZo607AmTs= + dependencies: + graceful-fs "^4.1.2" + parse-json "^4.0.0" + pify "^3.0.0" + strip-bom "^3.0.0" + locate-path@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-2.0.0.tgz#2b568b265eec944c6d9c0de9c3dbbbca0354cd8e" @@ -4804,7 +5231,7 @@ lodash.throttle@^4.1.1: resolved "https://registry.yarnpkg.com/lodash.throttle/-/lodash.throttle-4.1.1.tgz#c23e91b710242ac70c37f1e1cda9274cc39bf2f4" integrity sha1-wj6RtxAkKscMN/HhzaknTMOb8vQ= -lodash@4.x.x, lodash@^4.13.1, lodash@^4.15.0, lodash@^4.17.10, lodash@^4.17.4, lodash@^4.17.5, lodash@^4.3.0, lodash@^4.6.1: +lodash@4.x.x, lodash@^4.13.1, lodash@^4.15.0, lodash@^4.17.10, lodash@^4.17.11, lodash@^4.17.4, lodash@^4.17.5, lodash@^4.3.0, lodash@^4.6.1: version "4.17.11" resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.11.tgz#b39ea6229ef607ecd89e2c8df12536891cac9b8d" integrity sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg== @@ -4829,7 +5256,7 @@ lru-cache@^4.0.1: pseudomap "^1.0.2" yallist "^2.1.2" -make-dir@^1.0.0: +make-dir@^1.0.0, make-dir@^1.3.0: version "1.3.0" resolved "https://registry.yarnpkg.com/make-dir/-/make-dir-1.3.0.tgz#79c1033b80515bd6d24ec9933e860ca75ee27f0c" integrity sha512-2w31R7SJtieJJnQtGc7RVL2StM2vGYVfqUOvUDxH6bC6aJTxPxTF0GnIgCyu7tjockiUWAYQRbxa7vKn34s5sQ== @@ -5689,6 +6116,13 @@ p-defer@^1.0.0: resolved "https://registry.yarnpkg.com/p-defer/-/p-defer-1.0.0.tgz#9f6eb182f6c9aa8cd743004a7d4f96b196b0fb0c" integrity sha1-n26xgvbJqozXQwBKfU+WsZaw+ww= +p-each-series@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/p-each-series/-/p-each-series-1.0.0.tgz#930f3d12dd1f50e7434457a22cd6f04ac6ad7f71" + integrity sha1-kw89Et0fUOdDRFeiLNbwSsatf3E= + dependencies: + p-reduce "^1.0.0" + p-finally@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/p-finally/-/p-finally-1.0.0.tgz#3fbcfb15b899a44123b34b6dcc18b724336a2cae" @@ -5727,6 +6161,11 @@ p-locate@^3.0.0: dependencies: p-limit "^2.0.0" +p-reduce@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/p-reduce/-/p-reduce-1.0.0.tgz#18c2b0dd936a4690a529f8231f58a0fdb6a47dfa" + integrity sha1-GMKw3ZNqRpClKfgjH1ig/bakffo= + p-try@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/p-try/-/p-try-1.0.0.tgz#cbc79cdbaf8fd4228e13f621f2b1a237c1b207b3" @@ -5825,10 +6264,12 @@ path-type@^2.0.0: dependencies: pify "^2.0.0" -pegjs@^0.10.0: - version "0.10.0" - resolved "https://registry.yarnpkg.com/pegjs/-/pegjs-0.10.0.tgz#cf8bafae6eddff4b5a7efb185269eaaf4610ddbd" - integrity sha1-z4uvrm7d/0tafvsYUmnqr0YQ3b0= +path-type@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/path-type/-/path-type-3.0.0.tgz#cef31dc8e0a1a3bb0d105c0cd97cf3bf47f4e36f" + integrity sha512-T2ZUsdZFHgA3u4e5PfPbjd7HDDpxPnQb5jN0SrDsjNSuVXHJqtwTnWqG0B1jZrgmJ/7lj1EmVIByWt1gxGkWvg== + dependencies: + pify "^3.0.0" performance-now@^2.1.0: version "2.1.0" @@ -5864,6 +6305,13 @@ pirates@^4.0.0: dependencies: node-modules-regexp "^1.0.0" +pirates@^4.0.1: + version "4.0.1" + resolved "https://registry.yarnpkg.com/pirates/-/pirates-4.0.1.tgz#643a92caf894566f91b2b986d2c66950a8e2fb87" + integrity sha512-WuNqLTbMI3tmfef2TKxlQmAiLHKtFhlsCZnPIpuv2Ow0RDVO8lfy1Opf4NUzlMXLjPl+Men7AuVdX6TA+s+uGA== + dependencies: + node-modules-regexp "^1.0.0" + pkg-dir@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/pkg-dir/-/pkg-dir-2.0.0.tgz#f6d5d1109e19d63edf428e0bd57e12777615334b" @@ -5878,16 +6326,7 @@ pkg-dir@^3.0.0: dependencies: find-up "^3.0.0" -plist@2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/plist/-/plist-2.0.1.tgz#0a32ca9481b1c364e92e18dc55c876de9d01da8b" - integrity sha1-CjLKlIGxw2TpLhjcVch23p0B2os= - dependencies: - base64-js "1.1.2" - xmlbuilder "8.2.2" - xmldom "0.1.x" - -plist@^3.0.0: +plist@^3.0.0, plist@^3.0.1: version "3.0.1" resolved "https://registry.yarnpkg.com/plist/-/plist-3.0.1.tgz#a9b931d17c304e8912ef0ba3bdd6182baf2e1f8c" integrity sha512-GpgvHHocGRyQm74b6FWEZZVRroHKE1I0/BTjAmySaohK+cUn+hZpbqXkc3KWgW3gQYkqcQej35FohcT0FRlkRQ== @@ -5937,7 +6376,7 @@ prettier@1.13.6: resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.13.6.tgz#00ae0b777ad92f81a9e7a1df2f0470b6dab0cb44" integrity sha512-p5eqCNiohWZN++7aJXUVj0JgLqHCPLf9GLIcLBHGNWs4Y9FJOPs6+KNO2WT0udJIQJTbeZFrJkjzjcb8fkAYYQ== -pretty-format@24.0.0-alpha.6, pretty-format@^24.0.0-alpha.6: +pretty-format@24.0.0-alpha.6: version "24.0.0-alpha.6" resolved "https://registry.yarnpkg.com/pretty-format/-/pretty-format-24.0.0-alpha.6.tgz#25ad2fa46b342d6278bf241c5d2114d4376fbac1" integrity sha512-zG2m6YJeuzwBFqb5EIdmwYVf30sap+iMRuYNPytOccEXZMAJbPIFGKVJ/U0WjQegmnQbRo9CI7j6j3HtDaifiA== @@ -5953,6 +6392,16 @@ pretty-format@^23.6.0: ansi-regex "^3.0.0" ansi-styles "^3.2.0" +pretty-format@^24.4.0: + version "24.4.0" + resolved "https://registry.yarnpkg.com/pretty-format/-/pretty-format-24.4.0.tgz#48db91969eb89f272c1bf3514bc5d5b228b3e722" + integrity sha512-SEXFzT01NwO4vaymwhz1/CM+wKCLOT92uqrzxIjmdRQMt7JAEuZ2eInCMvDS+4ZidEB+Rdq+fMs/Vwse8VAh1A== + dependencies: + "@jest/types" "^24.3.0" + ansi-regex "^4.0.0" + ansi-styles "^3.2.0" + react-is "^16.8.4" + private@^0.1.6, private@^0.1.8, private@~0.1.5: version "0.1.8" resolved "https://registry.yarnpkg.com/private/-/private-0.1.8.tgz#2381edb3689f7a53d653190060fcf822d2f368ff" @@ -5985,12 +6434,12 @@ promise@^7.1.1: dependencies: asap "~2.0.3" -prompts@^1.1.0: - version "1.1.1" - resolved "https://registry.yarnpkg.com/prompts/-/prompts-1.1.1.tgz#c687590e472c08cd84cfa4b8694b1cab5de45144" - integrity sha512-lC0+ifgWNKhTNF28Wj41TOXE+gEzrHcDqkCRHMbv39afuGT1ClekTgcVF+r2VuSgNr3Fy2hq6Pu3Mlt43u+QlQ== +prompts@^2.0.1: + version "2.0.3" + resolved "https://registry.yarnpkg.com/prompts/-/prompts-2.0.3.tgz#c5ccb324010b2e8f74752aadceeb57134c1d2522" + integrity sha512-H8oWEoRZpybm6NV4to9/1limhttEo13xK62pNvn2JzY0MA03p7s0OjtmhXyon3uJmxiJJVSuUwEJFFssI3eBiQ== dependencies: - kleur "^2.0.1" + kleur "^3.0.2" sisteransi "^1.0.0" prop-types@^15.5.8, prop-types@^15.6.0, prop-types@^15.6.2: @@ -6084,10 +6533,15 @@ react-devtools-core@^3.6.0: shell-quote "^1.6.1" ws "^3.3.1" -react-is@^16.8.1: - version "16.8.1" - resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.8.1.tgz#a80141e246eb894824fb4f2901c0c50ef31d4cdb" - integrity sha512-ioMCzVDWvCvKD8eeT+iukyWrBGrA3DiFYkXfBsVYIRdaREZuBjENG+KjrikavCLasozqRWTwFUagU/O4vPpRMA== +react-is@^16.8.4: + version "16.8.4" + resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.8.4.tgz#90f336a68c3a29a096a3d648ab80e87ec61482a2" + integrity sha512-PVadd+WaUDOAciICm/J1waJaSvgq+4rHE/K70j0PFqKhkTBsPv/82UGQJNXAngz1fOQLLxI6z1sEDmJDQhCTAA== + +react-is@^16.8.6: + version "16.8.6" + resolved "https://registry.yarnpkg.com/react-is/-/react-is-16.8.6.tgz#5bbc1e2d29141c9fbdfed456343fe2bc430a6a16" + integrity sha512-aUk3bHfZ2bRSVFFbbeVS4i+lNPZr3/WM5jT2J5omUVV1zzcs1nAaf3l51ctA5FFvCRbhrH0bdAsRRQddFJZPtA== react-native-dummy@0.2.0: version "0.2.0" @@ -6102,15 +6556,15 @@ react-proxy@^1.1.7: lodash "^4.6.1" react-deep-force-update "^1.0.0" -react-test-renderer@16.8.1: - version "16.8.1" - resolved "https://registry.yarnpkg.com/react-test-renderer/-/react-test-renderer-16.8.1.tgz#72845ad9269be526126e97853311982f781767be" - integrity sha512-Bd21TN3+YVl6GZwav6O0T6m5UwGfOj+2+xZH5VH93ToD6M5uclN/c+R1DGX49ueG413KZPUx7Kw3sOYz2aJgfg== +react-test-renderer@16.8.6: + version "16.8.6" + resolved "https://registry.yarnpkg.com/react-test-renderer/-/react-test-renderer-16.8.6.tgz#188d8029b8c39c786f998aa3efd3ffe7642d5ba1" + integrity sha512-H2srzU5IWYT6cZXof6AhUcx/wEyJddQ8l7cLM/F7gDXYyPr4oq+vCIxJYXVGhId1J706sqziAjuOEjyNkfgoEw== dependencies: object-assign "^4.1.1" prop-types "^15.6.2" - react-is "^16.8.1" - scheduler "^0.13.1" + react-is "^16.8.6" + scheduler "^0.13.6" react-transform-hmr@^1.0.4: version "1.0.4" @@ -6120,15 +6574,15 @@ react-transform-hmr@^1.0.4: global "^4.3.0" react-proxy "^1.1.7" -react@16.8.1: - version "16.8.1" - resolved "https://registry.yarnpkg.com/react/-/react-16.8.1.tgz#ae11831f6cb2a05d58603a976afc8a558e852c4a" - integrity sha512-wLw5CFGPdo7p/AgteFz7GblI2JPOos0+biSoxf1FPsGxWQZdN/pj6oToJs1crn61DL3Ln7mN86uZ4j74p31ELQ== +react@16.8.6: + version "16.8.6" + resolved "https://registry.yarnpkg.com/react/-/react-16.8.6.tgz#ad6c3a9614fd3a4e9ef51117f54d888da01f2bbe" + integrity sha512-pC0uMkhLaHm11ZSJULfOBqV4tIZkx87ZLvbbQYunNixAAvjnC+snJCg0XQXn9VIsttVsbZP/H/ewzgsd5fxKXw== dependencies: loose-envify "^1.1.0" object-assign "^4.1.1" prop-types "^15.6.2" - scheduler "^0.13.1" + scheduler "^0.13.6" read-pkg-up@^1.0.1: version "1.0.1" @@ -6146,6 +6600,14 @@ read-pkg-up@^2.0.0: find-up "^2.0.0" read-pkg "^2.0.0" +read-pkg-up@^4.0.0: + version "4.0.0" + resolved "https://registry.yarnpkg.com/read-pkg-up/-/read-pkg-up-4.0.0.tgz#1b221c6088ba7799601c808f91161c66e58f8978" + integrity sha512-6etQSH7nJGsK0RbG/2TeDzZFa8shjQ1um+SwQQ5cwKy0dhSXdOncEhb1CPpvQG4h7FyOV6EB6YlV0yJvZQNAkA== + dependencies: + find-up "^3.0.0" + read-pkg "^3.0.0" + read-pkg@^1.0.0: version "1.1.0" resolved "https://registry.yarnpkg.com/read-pkg/-/read-pkg-1.1.0.tgz#f5ffaa5ecd29cb31c0474bca7d756b6bb29e3f28" @@ -6164,6 +6626,15 @@ read-pkg@^2.0.0: normalize-package-data "^2.3.2" path-type "^2.0.0" +read-pkg@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/read-pkg/-/read-pkg-3.0.0.tgz#9cbc686978fee65d16c00e2b19c237fcf6e38389" + integrity sha1-nLxoaXj+5l0WwA4rGcI3/Pbjg4k= + dependencies: + load-json-file "^4.0.0" + normalize-package-data "^2.3.2" + path-type "^3.0.0" + readable-stream@^2.0.1, readable-stream@^2.0.6, readable-stream@^2.1.5, readable-stream@^2.2.2: version "2.3.6" resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.3.6.tgz#b11c27d88b8ff1fbe070643cf94b0c79ae1b0aaf" @@ -6184,6 +6655,13 @@ realpath-native@^1.0.0: dependencies: util.promisify "^1.0.0" +realpath-native@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/realpath-native/-/realpath-native-1.1.0.tgz#2003294fea23fb0672f2476ebe22fcf498a2d65c" + integrity sha512-wlgPA6cCIIg9gKz0fgAPjnzh4yR/LnXovwuo9hvyGvx3h8nX4+/iLZplfUWasXpqD8BdnGnP5njOFjkUwPzvjA== + dependencies: + util.promisify "^1.0.0" + recast@^0.16.1: version "0.16.1" resolved "https://registry.yarnpkg.com/recast/-/recast-0.16.1.tgz#865f1800ef76e42e5d0375763b80f4d6a05f2069" @@ -6422,6 +6900,13 @@ rimraf@^2.2.8, rimraf@^2.5.4, rimraf@^2.6.1: dependencies: glob "^7.0.5" +rimraf@^2.6.2: + version "2.6.3" + resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.6.3.tgz#b2d104fe0d8fb27cf9e0a1cda8262dd3833c6cab" + integrity sha512-mwqeW5XsA2qAejG46gYdENaxXjx9onRNCfn7L0duuP4hCuTIi/QO7PDK07KJfp1d+izWPrzEJDcSqBa0OZQriA== + dependencies: + glob "^7.1.3" + rimraf@~2.2.6: version "2.2.8" resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.2.8.tgz#e439be2aaee327321952730f99a8929e4fc50582" @@ -6504,6 +6989,21 @@ sane@^3.0.0: optionalDependencies: fsevents "^1.2.3" +sane@^4.0.3: + version "4.0.3" + resolved "https://registry.yarnpkg.com/sane/-/sane-4.0.3.tgz#e878c3f19e25cc57fbb734602f48f8a97818b181" + integrity sha512-hSLkC+cPHiBQs7LSyXkotC3UUtyn8C4FMn50TNaacRyvBlI+3ebcxMpqckmTdtXVtel87YS7GXN3UIOj7NiGVQ== + dependencies: + "@cnakazawa/watch" "^1.0.3" + anymatch "^2.0.0" + capture-exit "^1.2.0" + exec-sh "^0.3.2" + execa "^1.0.0" + fb-watchman "^2.0.0" + micromatch "^3.1.4" + minimist "^1.1.1" + walker "~1.0.5" + sanitize-filename@^1.6.1: version "1.6.1" resolved "https://registry.yarnpkg.com/sanitize-filename/-/sanitize-filename-1.6.1.tgz#612da1c96473fa02dccda92dcd5b4ab164a6772a" @@ -6521,10 +7021,10 @@ sax@~1.1.1: resolved "https://registry.yarnpkg.com/sax/-/sax-1.1.6.tgz#5d616be8a5e607d54e114afae55b7eaf2fcc3240" integrity sha1-XWFr6KXmB9VOEUr65Vt+ry/MMkA= -scheduler@^0.13.1: - version "0.13.1" - resolved "https://registry.yarnpkg.com/scheduler/-/scheduler-0.13.1.tgz#1a217df1bfaabaf4f1b92a9127d5d732d85a9591" - integrity sha512-VJKOkiKIN2/6NOoexuypwSrybx13MY7NSy9RNt8wPvZDMRT1CW6qlpF5jXRToXNHz3uWzbm2elNpZfXfGPqP9A== +scheduler@^0.13.6: + version "0.13.6" + resolved "https://registry.yarnpkg.com/scheduler/-/scheduler-0.13.6.tgz#466a4ec332467b31a91b9bf74e5347072e4cd889" + integrity sha512-IWnObHt413ucAYKsD9J1QShUKkbKLQQHdxRyw73sw4FN26iWr3DY/H34xGPe4nmL1DwXyWmSWmMrA9TfQbE/XQ== dependencies: loose-envify "^1.1.0" object-assign "^4.1.1" @@ -6651,14 +7151,14 @@ signal-exit@^3.0.0, signal-exit@^3.0.2: resolved "https://registry.yarnpkg.com/signal-exit/-/signal-exit-3.0.2.tgz#b5fdc08f1287ea1178628e415e25132b73646c6d" integrity sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0= -simple-plist@^0.2.1: - version "0.2.1" - resolved "https://registry.yarnpkg.com/simple-plist/-/simple-plist-0.2.1.tgz#71766db352326928cf3a807242ba762322636723" - integrity sha1-cXZts1IyaSjPOoByQrp2IyJjZyM= +simple-plist@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/simple-plist/-/simple-plist-1.0.0.tgz#bed3085633b22f371e111f45d159a1ccf94b81eb" + integrity sha512-043L2rO80LVF7zfZ+fqhsEkoJFvW8o59rt/l4ctx1TJWoTx7/jkiS1R5TatD15Z1oYnuLJytzE7gcnnBuIPL2g== dependencies: bplist-creator "0.0.7" bplist-parser "0.1.1" - plist "2.0.1" + plist "^3.0.1" sisteransi@^1.0.0: version "1.0.0" @@ -6748,7 +7248,7 @@ source-map-url@^0.4.0: resolved "https://registry.yarnpkg.com/source-map-url/-/source-map-url-0.4.0.tgz#3e935d7ddd73631b97659956d55128e87b5084a3" integrity sha1-PpNdfd1zYxuXZZlW1VEo6HtQhKM= -source-map@^0.5.0, source-map@^0.5.3, source-map@^0.5.6, source-map@^0.5.7: +source-map@^0.5.0, source-map@^0.5.6, source-map@^0.5.7: version "0.5.7" resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.5.7.tgz#8a039d2d1021d22d1ea14c80d8ea468ba2ef3fcc" integrity sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w= @@ -6918,11 +7418,6 @@ strip-ansi@^5.0.0: dependencies: ansi-regex "^4.0.0" -strip-bom@3.0.0, strip-bom@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/strip-bom/-/strip-bom-3.0.0.tgz#2334c18e9c759f7bdd56fdef7e9ae3d588e68ed3" - integrity sha1-IzTBjpx1n3vdVv3vfprj1YjmjtM= - strip-bom@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/strip-bom/-/strip-bom-2.0.0.tgz#6219a85616520491f35788bdbf1447a99c7e6b0e" @@ -6930,6 +7425,11 @@ strip-bom@^2.0.0: dependencies: is-utf8 "^0.2.0" +strip-bom@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/strip-bom/-/strip-bom-3.0.0.tgz#2334c18e9c759f7bdd56fdef7e9ae3d588e68ed3" + integrity sha1-IzTBjpx1n3vdVv3vfprj1YjmjtM= + strip-eof@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/strip-eof/-/strip-eof-1.0.0.tgz#bb43ff5598a6eb05d89b59fcd129c983313606bf" @@ -6945,13 +7445,6 @@ supports-color@^2.0.0: resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-2.0.0.tgz#535d045ce6b6363fa40117084629995e9df324c7" integrity sha1-U10EXOa2Nj+kARcIRimZXp3zJMc= -supports-color@^3.1.2: - version "3.2.3" - resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-3.2.3.tgz#65ac0504b3954171d8a64946b2ae3cbb8a5f54f6" - integrity sha1-ZawFBLOVQXHYpklGsq48u4pfVPY= - dependencies: - has-flag "^1.0.0" - supports-color@^5.3.0: version "5.5.0" resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-5.5.0.tgz#e2e69a44ac8772f78a1ec0b35b689df6530efc8f" @@ -6959,6 +7452,13 @@ supports-color@^5.3.0: dependencies: has-flag "^3.0.0" +supports-color@^6.0.0, supports-color@^6.1.0: + version "6.1.0" + resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-6.1.0.tgz#0764abc69c63d5ac842dd4867e8d025e880df8f3" + integrity sha512-qe1jfm1Mg7Nq/NSh6XE24gPXROEVsWHxC1LIx//XNlD9iw7YZQGjZNjYN7xGaEG6iKdA8EtNFW6R0gjnVXp+wQ== + dependencies: + has-flag "^3.0.0" + symbol-observable@1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/symbol-observable/-/symbol-observable-1.0.1.tgz#8340fc4702c3122df5d22288f88283f513d3fdd4" @@ -7038,6 +7538,16 @@ test-exclude@^4.2.1: read-pkg-up "^1.0.1" require-main-filename "^1.0.1" +test-exclude@^5.0.0: + version "5.1.0" + resolved "https://registry.yarnpkg.com/test-exclude/-/test-exclude-5.1.0.tgz#6ba6b25179d2d38724824661323b73e03c0c1de1" + integrity sha512-gwf0S2fFsANC55fSeSqpb8BYk6w3FDvwZxfNjeF6FRgvFa43r+7wRiA/Q0IxoRU37wB/LE8IQ4221BsNucTaCA== + dependencies: + arrify "^1.0.1" + minimatch "^3.0.4" + read-pkg-up "^4.0.0" + require-main-filename "^1.0.1" + text-table@^0.2.0: version "0.2.0" resolved "https://registry.yarnpkg.com/text-table/-/text-table-0.2.0.tgz#7f5ee823ae805207c00af2df4a84ec3fcfa570b4" @@ -7286,11 +7796,6 @@ utils-merge@1.0.1: resolved "https://registry.yarnpkg.com/utils-merge/-/utils-merge-1.0.1.tgz#9f95710f50a267947b2ccc124741c1028427e713" integrity sha1-n5VxD1CiZ5R7LMwSR0HBAoQn5xM= -uuid@3.0.1: - version "3.0.1" - resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.0.1.tgz#6544bba2dfda8c1cf17e629a3a305e2bb1fee6c1" - integrity sha1-ZUS7ot/ajBzxfmKaOjBeK7H+5sE= - uuid@^3.0.1, uuid@^3.3.2: version "3.3.2" resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.3.2.tgz#1b4af4955eb3077c501c23872fc6513811587131" @@ -7385,7 +7890,7 @@ which-module@^2.0.0: resolved "https://registry.yarnpkg.com/which-module/-/which-module-2.0.0.tgz#d9ef07dce77b9902b8a3a8fa4b31c3e3f7e6e87a" integrity sha1-2e8H3Od7mQK4o6j6SzHD4/fm6Ho= -which@^1.2.12, which@^1.2.9, which@^1.3.0: +which@^1.2.9, which@^1.3.0: version "1.3.1" resolved "https://registry.yarnpkg.com/which/-/which-1.3.1.tgz#a45043d54f5805316da8d62f9f50918d3da70b0a" integrity sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ== @@ -7422,6 +7927,15 @@ wrappy@1: resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f" integrity sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8= +write-file-atomic@2.4.1: + version "2.4.1" + resolved "https://registry.yarnpkg.com/write-file-atomic/-/write-file-atomic-2.4.1.tgz#d0b05463c188ae804396fd5ab2a370062af87529" + integrity sha512-TGHFeZEZMnv+gBFRfjAcxL5bPHrsGKtnb4qsFAws7/vlh+QfwAaySIw4AXP9ZskTTh5GWu3FLuJhsWVdiJPGvg== + dependencies: + graceful-fs "^4.1.11" + imurmurhash "^0.1.4" + signal-exit "^3.0.2" + write-file-atomic@^1.2.0: version "1.3.4" resolved "https://registry.yarnpkg.com/write-file-atomic/-/write-file-atomic-1.3.4.tgz#f807a4f0b1d9e913ae7a48112e6cc3af1991b45f" @@ -7431,7 +7945,7 @@ write-file-atomic@^1.2.0: imurmurhash "^0.1.4" slide "^1.1.5" -write-file-atomic@^2.1.0, write-file-atomic@^2.3.0: +write-file-atomic@^2.3.0: version "2.3.0" resolved "https://registry.yarnpkg.com/write-file-atomic/-/write-file-atomic-2.3.0.tgz#1ff61575c2e2a4e8e510d6fa4e243cce183999ab" integrity sha512-xuPeK4OdjWqtfi59ylvVL0Yn35SF3zgcAcv7rBPFHVaEapaDr4GdGgm3j7ckTwH9wHL7fGmgfAnb0+THrHb8tA== @@ -7471,14 +7985,13 @@ ws@^5.2.0: dependencies: async-limiter "~1.0.0" -xcode@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/xcode/-/xcode-1.0.0.tgz#e1f5b1443245ded38c180796df1a10fdeda084ec" - integrity sha1-4fWxRDJF3tOMGAeW3xoQ/e2ghOw= +xcode@^2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/xcode/-/xcode-2.0.0.tgz#134f1f94c26fbfe8a9aaa9724bfb2772419da1a2" + integrity sha512-5xF6RCjAdDEiEsbbZaS/gBRt3jZ/177otZcpoLCjGN/u1LrfgH7/Sgeeavpr/jELpyDqN2im3AKosl2G2W8hfw== dependencies: - pegjs "^0.10.0" - simple-plist "^0.2.1" - uuid "3.0.1" + simple-plist "^1.0.0" + uuid "^3.3.2" xml-name-validator@^3.0.0: version "3.0.0" @@ -7490,11 +8003,6 @@ xml@^1.0.1: resolved "https://registry.yarnpkg.com/xml/-/xml-1.0.1.tgz#78ba72020029c5bc87b8a81a3cfcd74b4a2fc1e5" integrity sha1-eLpyAgApxbyHuKgaPPzXS0ovweU= -xmlbuilder@8.2.2: - version "8.2.2" - resolved "https://registry.yarnpkg.com/xmlbuilder/-/xmlbuilder-8.2.2.tgz#69248673410b4ba42e1a6136551d2922335aa773" - integrity sha1-aSSGc0ELS6QuGmE2VR0pIjNap3M= - xmlbuilder@^9.0.7: version "9.0.7" resolved "https://registry.yarnpkg.com/xmlbuilder/-/xmlbuilder-9.0.7.tgz#132ee63d2ec5565c557e20f4c22df9aca686b10d"