From 34b7d22f3d33792ffd86092d6c39564969c027d8 Mon Sep 17 00:00:00 2001 From: Kevin Gozali Date: Fri, 1 Oct 2021 10:25:26 -0700 Subject: [PATCH 01/62] OSS: install node via nvm on iOS image (#32309) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/32309 With the iOS image using Xcode 13, the Circle CI guide mentioned to use `nvm` to manage node: https://circleci.com/docs/2.0/testing-ios/#images-using-xcode-13-and-later. Note: doing this here also helps with Xcode build scripts that needs to invoke this line: https://github.com/facebook/react-native/blob/main/scripts/find-node.sh#L27. For some reason, with Xcode 13 Circle CI image, without explicitly sourcing find-node.sh beforehand, react-native-codegen script phase within Xcode would fail (permission denied), like: https://app.circleci.com/pipelines/github/facebook/react-native/10525/workflows/b68b10a3-325a-4892-8252-baed9017c613/jobs/219615 Changelog: [Internal] Reviewed By: cortinico Differential Revision: D31331905 fbshipit-source-id: 387c7a8931b07ee76fa6cd081d04c8704c1f7da4 --- .circleci/config.yml | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 70cb95c97e..5bcebf7b82 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -370,14 +370,18 @@ jobs: steps: - brew_install: package: watchman - - brew_install: - package: node@12 - run: name: "Brew: Tap wix/brew" command: HOMEBREW_NO_AUTO_UPDATE=1 brew tap wix/brew >/dev/null - brew_install: package: applesimutils + - run: + name: Configure Node + # Sourcing find-node.sh will ensure nvm is set up. + # It also helps future invocation of find-node.sh prevent permission issue with nvm.sh. + command: source scripts/find-node.sh && nvm install 12 && nvm alias default 12 + - run: name: Configure Watchman command: echo "{}" > .watchmanconfig From 8b5906d2091ad5cde05008f750e47df1be362f48 Mon Sep 17 00:00:00 2001 From: Kevin Gozali Date: Fri, 1 Oct 2021 15:31:24 -0700 Subject: [PATCH 02/62] OSS CircleCI: pinned Linux machines to ubuntu-2004:202010-01 (#32315) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/32315 Some tests were running old Ubuntu with old Node.js etc, causing failures like this: https://app.circleci.com/pipelines/github/facebook/react-native/10557/workflows/ddd94f8a-7200-40ab-9439-19683d691c67/jobs/220000 In this case, `node` in the machine was really old: ``` node -v v6.1.0 ``` So let's use the latest recommended one per: https://circleci.com/docs/2.0/executor-intro/#machine Changelog: [Internal] Reviewed By: hramos Differential Revision: D31351763 fbshipit-source-id: e97aae638cc5b999e98129de64dad9092113cb5f --- .circleci/config.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index 5bcebf7b82..f17cc1a4e2 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -585,7 +585,8 @@ jobs: # JOBS: Test Docker # ------------------------- test_docker_android: - machine: true + machine: + image: ubuntu-2004:202010-01 steps: - checkout - run: @@ -762,7 +763,8 @@ jobs: # JOBS: Nightly # ------------------------- nightly_job: - machine: true + machine: + image: ubuntu-2004:202010-01 steps: - run: name: Nightly From fabd253ef1d2aab7f1c1130756a465d92c513a5c Mon Sep 17 00:00:00 2001 From: Kevin Gozali Date: Fri, 1 Oct 2021 15:31:24 -0700 Subject: [PATCH 03/62] OSS Circle CI: upgrade iOS image Node installation to v14 (#32316) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/32316 Other tests/images are already using Node 14, let's upgrade. Changelog: [Internal] Reviewed By: hramos Differential Revision: D31351912 fbshipit-source-id: a42addbf7aa7c2dcbf497519b7af18d0cdb31e65 --- .circleci/config.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.circleci/config.yml b/.circleci/config.yml index f17cc1a4e2..3f9543d974 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -363,7 +363,7 @@ jobs: - run: name: Configure Environment Variables command: | - echo 'export PATH=/usr/local/opt/node@12/bin:$PATH' >> $BASH_ENV + echo 'export PATH=/usr/local/opt/node@14/bin:$PATH' >> $BASH_ENV source $BASH_ENV - with_brew_cache_span: @@ -380,7 +380,7 @@ jobs: name: Configure Node # Sourcing find-node.sh will ensure nvm is set up. # It also helps future invocation of find-node.sh prevent permission issue with nvm.sh. - command: source scripts/find-node.sh && nvm install 12 && nvm alias default 12 + command: source scripts/find-node.sh && nvm install 14 && nvm alias default 14 - run: name: Configure Watchman From 254493e1fb0c3a1e279e2c957e83edac6252d041 Mon Sep 17 00:00:00 2001 From: fabriziobertoglio1987 Date: Fri, 1 Oct 2021 16:42:50 -0700 Subject: [PATCH 04/62] Fix - TextInput Drawable to avoid Null Pointer Exception RuntimeError #17530 (#29452) Summary: This issue fixes https://github.com/facebook/react-native/issues/17530 fixes https://github.com/expo/expo/issues/9905 with the help of sunnylqm https://github.com/sunnylqm Re-rendering a large number of TextInputs with key prop on the screen will trigger the below Null Pointer Exception Runtime Error NullPointerException:tempt to invoke virtual method 'android.graphics.drawable.Drawable android.graphics.drawable.Drawable$ConstantState.newDrawable(android.content.res.Resources)' The error is caused by null.newDrawable(mSourceRes) at https://github.com/aosp-mirror/platform_frameworks_base/blob/20b012282e0c3d94b5c0aa799cdda065f2df06db/graphics/java/android/graphics/drawable/DrawableContainer.java#L919 More info https://github.com/facebook/react-native/pull/29452#issuecomment-662616018 https://github.com/facebook/react-native/issues/17530#issuecomment-662000718 The Theme Theme.AppCompat.Light.NoActionBar defines the Drawables for AppCompatEditText in drawable/abc_edit_text_material.xml https://chromium.googlesource.com/android_tools/+/7200281446186c7192cb02f54dc2b38e02d705e5/sdk/extras/android/support/v7/appcompat/res/drawable/abc_edit_text_material.xml Removing the following line from the above xml file drawable/abc_edit_text_material.xml fixes the error https://github.com/facebook/react-native/issues/17530#issuecomment-662000718 `` The Theme default EditText background is replaced with a custom background, which is a copy of the original background without the above item which triggers the Runtime Error. The changes are implemented in RNTester with commit (more info in the commit) https://github.com/facebook/react-native/commit/0858d4120df242196570f5394f8ae4e623533493. The new custom drawable used as default background for the TextInput is named edit_text. `drawable/edit_text` The same changes have been added to react-native default template for creating new applications with commit (more info) https://github.com/facebook/react-native/commit/f3493083df5e1b157bbdaf18f97c59b7b0ad828c, lean core moved the cli tools to https://github.com/react-native-community/cli, but the default template for creating a new application is stored in facebook/react-native/template. New applications will be generated with this configurations and will not experience the error, existing react-native applications will fix the error by upgrading with the [upgrade-helper](https://github.com/react-native-community/upgrade-helper). A Minimum Reproducible Example to reproduce this error is included in commit (more info in the commit) https://github.com/fabriziobertoglio1987/react-native/commit/4a414e2cc7e17068da26ef7727a04d0aa5883a17 and https://github.com/facebook/react-native/issues/17530#issuecomment-660017858 ## Changelog [Android] [Fixed] - TextInput Drawable to avoid Null Pointer Exception RuntimeError https://github.com/facebook/react-native/issues/17530 Pull Request resolved: https://github.com/facebook/react-native/pull/29452 Test Plan: Works in all scenarios on Android. **
CLICK TO OPEN TESTS RESULTS - React Native**

Test Results from the Testing in RNTester. Minimum Reproducible Example added with commit (more info in the commit) https://github.com/fabriziobertoglio1987/react-native/commit/4a414e2cc7e17068da26ef7727a04d0aa5883a17 The example included in commit https://github.com/fabriziobertoglio1987/react-native/commit/4a414e2cc7e17068da26ef7727a04d0aa5883a17 will cause a [NPE Runtime Error on Master Branch](https://fabriziobertoglio.s3.eu-central-1.amazonaws.com/opensource/react-native/17530/runtime.mp4), while no error is experienced in the [feature branch](https://fabriziobertoglio.s3.eu-central-1.amazonaws.com/opensource/react-native/17530/no_runtime.mp4). The links are video hosted on s3 of this tests (playable by google chrome). | **[BEFORE](https://fabriziobertoglio.s3.eu-central-1.amazonaws.com/opensource/react-native/17530/runtime.mp4)** | **[AFTER](https://fabriziobertoglio.s3.eu-central-1.amazonaws.com/opensource/react-native/17530/no_runtime.mp4)** | |:-------------------------:|:-------------------------:| | | | The below screenshots were taken to detect any issues with the EditText Background. There is no difference between master and feature branch. | **BEFORE** | **AFTER** | |:-------------------------:|:-------------------------:| | | | | **BEFORE** | **AFTER** | |:-------------------------:|:-------------------------:| | | | | **BEFORE** | **AFTER** | |:-------------------------:|:-------------------------:| | | | | **BEFORE** | **AFTER** | |:-------------------------:|:-------------------------:| | | | | **BEFORE** | **AFTER** | |:-------------------------:|:-------------------------:| | | | | **BEFORE** | **AFTER** | |:-------------------------:|:-------------------------:| | | | | **BEFORE** | **AFTER** | |:-------------------------:|:-------------------------:| | | | | **BEFORE** | **AFTER** | |:-------------------------:|:-------------------------:| | | | | **BEFORE** | **AFTER** | |:-------------------------:|:-------------------------:| | | | | **AFTER** | |:-------------------------:| | |

**
CLICK TO OPEN TESTS RESULTS - React Native Cli**

As lean core move cli tools to https://github.com/react-native-community/cli, I tested the changes to the template in a separate repository https://github.com/fabriziobertoglio1987/react-native-template and generated the template with the following command ``` npx react-native init ProjectName --template file:///home/fabrizio/Documents/sourcecode/opensource/react-native-template/template ``` The generated app did not experience any issues and includes all the changes in [rn_edit_text_material.xml](https://github.com/fabriziobertoglio1987/react-native-template/blob/master/ProjectName/android/app/src/main/res/drawable/rn_edit_text_material.xml) and [styles.xml](https://github.com/fabriziobertoglio1987/react-native-template/blob/master/ProjectName/android/app/src/main/res/values/styles.xml)

Reviewed By: cortinico Differential Revision: D30684030 Pulled By: lunaleaps fbshipit-source-id: 7404da0a7259a4bc0405e57e5ed908649d180524 --- .../android/app/src/main/AndroidManifest.xml | 2 +- .../res/drawable/rn_edit_text_material.xml | 36 +++++++++++++ .../app/src/main/res/values/styles.xml | 1 + .../js/examples/TextInput/TextInputKeyProp.js | 52 +++++++++++++++++++ .../js/utils/RNTesterList.android.js | 4 ++ .../res/drawable/rn_edit_text_material.xml | 36 +++++++++++++ .../app/src/main/res/values/styles.xml | 1 + 7 files changed, 131 insertions(+), 1 deletion(-) create mode 100644 packages/rn-tester/android/app/src/main/res/drawable/rn_edit_text_material.xml create mode 100644 packages/rn-tester/js/examples/TextInput/TextInputKeyProp.js create mode 100644 template/android/app/src/main/res/drawable/rn_edit_text_material.xml diff --git a/packages/rn-tester/android/app/src/main/AndroidManifest.xml b/packages/rn-tester/android/app/src/main/AndroidManifest.xml index e2e8857659..8ee8ae3a35 100644 --- a/packages/rn-tester/android/app/src/main/AndroidManifest.xml +++ b/packages/rn-tester/android/app/src/main/AndroidManifest.xml @@ -30,7 +30,7 @@ android:banner="@drawable/tv_banner" android:icon="@drawable/launcher_icon" android:label="@string/app_name" - android:theme="@style/Theme.ReactNative.AppCompat.Light" > + android:theme="@style/AppTheme"> + + + + + + + + + + diff --git a/packages/rn-tester/android/app/src/main/res/values/styles.xml b/packages/rn-tester/android/app/src/main/res/values/styles.xml index 62fe59fa48..42c90f3e99 100644 --- a/packages/rn-tester/android/app/src/main/res/values/styles.xml +++ b/packages/rn-tester/android/app/src/main/res/values/styles.xml @@ -4,6 +4,7 @@ diff --git a/packages/rn-tester/js/examples/TextInput/TextInputKeyProp.js b/packages/rn-tester/js/examples/TextInput/TextInputKeyProp.js new file mode 100644 index 0000000000..a16bcb87d0 --- /dev/null +++ b/packages/rn-tester/js/examples/TextInput/TextInputKeyProp.js @@ -0,0 +1,52 @@ +/** + * 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 + * @flow + */ + +'use strict'; + +const React = require('react'); +const {View, TextInput} = require('react-native'); +const {useEffect, useState} = React; + +function TextInputKeyProp() { + const [startKey, setStartKey] = useState(0); + + useEffect(() => { + const interval = setInterval(() => setStartKey(startKey + 100), 3000); + return () => clearInterval(interval); + }, [startKey]); + + const textInputs = []; + for (let i = 0; i < 101; i++) { + const key = (startKey + i).toString(); + console.log('Adding a TextInput with key ' + key); + textInputs.push( + , + ); + } + + return {textInputs}; +} + +exports.title = 'TextInputs with key prop'; +exports.description = + 'Periodically render large number of TextInputs with key prop without a Runtime Error'; +exports.examples = [ + { + title: 'Long List of TextInputs with key props', + description: + '100 TextInputs are added every 3 seconds to the View. #29452 avoids a NPE Runtime Error. If you want to trigger the Runtime, change 101 to 1001 in RNTester/TextInputKeyProp.js and use an Emulator with 8GB of RAM. This example is only meant to verify no RuntimeError is triggered. To test TextInput functionalities use the example.', + render: function(): React.Node { + return ; + }, + }, +]; diff --git a/packages/rn-tester/js/utils/RNTesterList.android.js b/packages/rn-tester/js/utils/RNTesterList.android.js index 18b9106ad9..92cd28d26e 100644 --- a/packages/rn-tester/js/utils/RNTesterList.android.js +++ b/packages/rn-tester/js/utils/RNTesterList.android.js @@ -105,6 +105,10 @@ const Components: Array = [ category: 'Basic', module: require('../examples/TextInput/TextInputExample'), }, + { + key: 'TextInputs with key prop', + module: require('../examples/TextInput/TextInputKeyProp'), + }, { key: 'TouchableExample', category: 'UI', diff --git a/template/android/app/src/main/res/drawable/rn_edit_text_material.xml b/template/android/app/src/main/res/drawable/rn_edit_text_material.xml new file mode 100644 index 0000000000..f35d996202 --- /dev/null +++ b/template/android/app/src/main/res/drawable/rn_edit_text_material.xml @@ -0,0 +1,36 @@ + + + + + + + + + + + diff --git a/template/android/app/src/main/res/values/styles.xml b/template/android/app/src/main/res/values/styles.xml index 24bc061368..7ba83a2ad5 100644 --- a/template/android/app/src/main/res/values/styles.xml +++ b/template/android/app/src/main/res/values/styles.xml @@ -3,6 +3,7 @@ From 42dc8ddff4de1061751a4fa7e696c0d29de5fcbf Mon Sep 17 00:00:00 2001 From: Kevin Gozali Date: Fri, 1 Oct 2021 17:00:23 -0700 Subject: [PATCH 05/62] OSS CircleCI: Unbreak analyze_pr cert issue (#32317) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/32317 Context: https://github.com/nodesource/distributions/issues/1266#issuecomment-932583579 For now apply some workaround in analyze_pr docker image to unblock. Changelog: [Internal] Reviewed By: hramos Differential Revision: D31356337 fbshipit-source-id: 4c5ea57e6f94eeb53c8a12b736d7d178b2b9c6e6 --- .circleci/config.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index 3f9543d974..849c11663f 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -223,9 +223,14 @@ jobs: # Note: The yarn gpg key needs to be refreshed to work around https://github.com/yarnpkg/yarn/issues/7866 - run: name: Install additional GitHub bot dependencies + # TEMP: Added workaround from https://github.com/nodesource/distributions/issues/1266#issuecomment-932583579 command: | curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - apt update && apt install -y shellcheck jq + apt-get install openssl ca-certificates + update-ca-certificates + curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - + apt update && apt install -y shellcheck jq - run: name: Run linters against modified files (analysis-bot) From ea53d3a9c282f4c4ad1547b934025acd1db322fc Mon Sep 17 00:00:00 2001 From: Samuel Susla Date: Fri, 1 Oct 2021 17:45:51 -0700 Subject: [PATCH 06/62] Pass reference instead of shared_ptr to getInspectorDataForInstance Summary: changelog: [internal] This is a pre-condition to get rid of `shared_ptr` from `EventEmitterWrapper`. Also saves us a few copies of shared_ptr, this is negligible though. Reviewed By: mdvacca Differential Revision: D31307048 fbshipit-source-id: b84654bed2359b66faf3995795e135e88fe51cb6 --- .../src/main/java/com/facebook/react/fabric/jni/Binding.cpp | 2 +- ReactCommon/react/renderer/scheduler/Scheduler.cpp | 2 +- ReactCommon/react/renderer/scheduler/Scheduler.h | 2 +- ReactCommon/react/renderer/uimanager/UIManagerBinding.cpp | 4 ++-- ReactCommon/react/renderer/uimanager/UIManagerBinding.h | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/Binding.cpp b/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/Binding.cpp index e07977cb8b..edbe5613e6 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/Binding.cpp +++ b/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/Binding.cpp @@ -244,7 +244,7 @@ Binding::getInspectorDataForInstance( EventEmitterWrapper *cEventEmitter = cthis(eventEmitterWrapper); InspectorData data = - scheduler->getInspectorDataForInstance(cEventEmitter->eventEmitter); + scheduler->getInspectorDataForInstance(*cEventEmitter->eventEmitter); folly::dynamic result = folly::dynamic::object; result["fileName"] = data.fileName; diff --git a/ReactCommon/react/renderer/scheduler/Scheduler.cpp b/ReactCommon/react/renderer/scheduler/Scheduler.cpp index 00d13bcb53..15cff205ff 100644 --- a/ReactCommon/react/renderer/scheduler/Scheduler.cpp +++ b/ReactCommon/react/renderer/scheduler/Scheduler.cpp @@ -187,7 +187,7 @@ void Scheduler::registerSurface( } InspectorData Scheduler::getInspectorDataForInstance( - SharedEventEmitter eventEmitter) const noexcept { + EventEmitter const &eventEmitter) const noexcept { return executeSynchronouslyOnSameThread_CAN_DEADLOCK( runtimeExecutor_, [=](jsi::Runtime &runtime) -> InspectorData { auto uiManagerBinding = UIManagerBinding::getBinding(runtime); diff --git a/ReactCommon/react/renderer/scheduler/Scheduler.h b/ReactCommon/react/renderer/scheduler/Scheduler.h index e604c4adac..32beafc7e9 100644 --- a/ReactCommon/react/renderer/scheduler/Scheduler.h +++ b/ReactCommon/react/renderer/scheduler/Scheduler.h @@ -52,7 +52,7 @@ class Scheduler final : public UIManagerDelegate { void unregisterSurface(SurfaceHandler const &surfaceHandler) const noexcept; InspectorData getInspectorDataForInstance( - SharedEventEmitter eventEmitter) const noexcept; + EventEmitter const &eventEmitter) const noexcept; void renderTemplateToSurface( SurfaceId surfaceId, diff --git a/ReactCommon/react/renderer/uimanager/UIManagerBinding.cpp b/ReactCommon/react/renderer/uimanager/UIManagerBinding.cpp index c926765ec8..cbc68035ad 100644 --- a/ReactCommon/react/renderer/uimanager/UIManagerBinding.cpp +++ b/ReactCommon/react/renderer/uimanager/UIManagerBinding.cpp @@ -131,8 +131,8 @@ static jsi::Value callMethodOfModule( jsi::Value UIManagerBinding::getInspectorDataForInstance( jsi::Runtime &runtime, - SharedEventEmitter eventEmitter) const { - auto eventTarget = eventEmitter->eventTarget_; + EventEmitter const &eventEmitter) const { + auto eventTarget = eventEmitter.eventTarget_; EventEmitter::DispatchMutex().lock(); if (!runtime.global().hasProperty(runtime, "__fbBatchedBridge") || diff --git a/ReactCommon/react/renderer/uimanager/UIManagerBinding.h b/ReactCommon/react/renderer/uimanager/UIManagerBinding.h index 7b16099046..947e3ecf43 100644 --- a/ReactCommon/react/renderer/uimanager/UIManagerBinding.h +++ b/ReactCommon/react/renderer/uimanager/UIManagerBinding.h @@ -74,7 +74,7 @@ class UIManagerBinding : public jsi::HostObject { jsi::Value getInspectorDataForInstance( jsi::Runtime &runtime, - SharedEventEmitter eventEmitter) const; + EventEmitter const &eventEmitter) const; /* * Stops React Native Surface with given id. From d8931e2f940de0ce7bce9d8b8cf559ccec49f46f Mon Sep 17 00:00:00 2001 From: Phillip Pan Date: Fri, 1 Oct 2021 21:15:37 -0700 Subject: [PATCH 07/62] provide public hook to programatically turn on voiceover Summary: Changelog: [Internal] https://fb.workplace.com/groups/rn.support/posts/6677051292343429 ax team is building a tool to extract information about the views for design reviewers, and RN has some AX information that is not working atm because of dependency on whether voiceover is on or not. so, this will give them the ability to programmatically set that field and hopefully be able to get accurate ax info Reviewed By: ikenwoo Differential Revision: D31010566 fbshipit-source-id: 4c8a33fce40266b270dd5994442c8472ca88f5dd --- .../RCTAccessibilityManager+Internal.h | 21 +++++++++++++++++++ React/CoreModules/RCTAccessibilityManager.mm | 21 ++++++++++++++++--- 2 files changed, 39 insertions(+), 3 deletions(-) create mode 100644 React/CoreModules/RCTAccessibilityManager+Internal.h diff --git a/React/CoreModules/RCTAccessibilityManager+Internal.h b/React/CoreModules/RCTAccessibilityManager+Internal.h new file mode 100644 index 0000000000..b3a17b5f3c --- /dev/null +++ b/React/CoreModules/RCTAccessibilityManager+Internal.h @@ -0,0 +1,21 @@ +/* + * 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. + */ + +#import "RCTAccessibilityManager.h" + +#import + +NS_ASSUME_NONNULL_BEGIN + +RCT_EXTERN_C_BEGIN + +// Only to be used for testing and internal tooling. Do not use this in production. +void RCTAccessibilityManagerSetIsVoiceOverEnabled(RCTAccessibilityManager *accessibiltyManager, BOOL isVoiceOverEnabled); + +RCT_EXTERN_C_END + +NS_ASSUME_NONNULL_END diff --git a/React/CoreModules/RCTAccessibilityManager.mm b/React/CoreModules/RCTAccessibilityManager.mm index 1ea4436cf3..3d0c7765d0 100644 --- a/React/CoreModules/RCTAccessibilityManager.mm +++ b/React/CoreModules/RCTAccessibilityManager.mm @@ -6,6 +6,7 @@ */ #import "RCTAccessibilityManager.h" +#import "RCTAccessibilityManager+Internal.h" #import #import @@ -183,9 +184,14 @@ RCT_EXPORT_MODULE() - (void)voiceVoiceOverStatusDidChange:(__unused NSNotification *)notification { - BOOL newIsVoiceOverEnabled = UIAccessibilityIsVoiceOverRunning(); - if (_isVoiceOverEnabled != newIsVoiceOverEnabled) { - _isVoiceOverEnabled = newIsVoiceOverEnabled; + BOOL isVoiceOverEnabled = UIAccessibilityIsVoiceOverRunning(); + [self _setIsVoiceOverEnabled:isVoiceOverEnabled]; +} + +- (void)_setIsVoiceOverEnabled:(BOOL)isVoiceOverEnabled +{ + if (_isVoiceOverEnabled != isVoiceOverEnabled) { + _isVoiceOverEnabled = isVoiceOverEnabled; #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wdeprecated-declarations" [[_moduleRegistry moduleForName:"EventDispatcher"] sendDeviceEventWithName:@"screenReaderChanged" @@ -350,6 +356,15 @@ RCT_EXPORT_METHOD(getCurrentVoiceOverState return std::make_shared(params); } +#pragma mark - Internal + +void RCTAccessibilityManagerSetIsVoiceOverEnabled( + RCTAccessibilityManager *accessibilityManager, + BOOL isVoiceOverEnabled) +{ + [accessibilityManager _setIsVoiceOverEnabled:isVoiceOverEnabled]; +} + @end @implementation RCTBridge (RCTAccessibilityManager) From 57aa70c06cba3597725f7447943613e8905ae11d Mon Sep 17 00:00:00 2001 From: Gustavo Sverzut Barbieri Date: Fri, 1 Oct 2021 21:21:03 -0700 Subject: [PATCH 08/62] Introduce Gemfile, ruby-version (#32303) Summary: Implement par of the discussion https://github.com/react-native-community/discussions-and-proposals/discussions/411, except the `.nvmrc` part, this includes: - Setting `.ruby-version` in the main project and also `template/` - Fixing the CocoaPods version with a project-level `Gemfile` and also `template/Gemfile` - Using all `pod` executions from `bundle exec pod`, using the determined version - Script to manage and update the ruby version ## Changelog [iOS] [Added] - Gemfile with CocoaPods 1.11 and ruby-version (2.7.4) Pull Request resolved: https://github.com/facebook/react-native/pull/32303 Test Plan: Build for iOS and run all CircleCI tests to see if nothing changed Reviewed By: RSNara Differential Revision: D31344686 Pulled By: fkgozali fbshipit-source-id: 25c63131ca9b16d3cf6341019548e0d63bdcaefe --- .bundle/config | 2 + .circleci/config.yml | 13 ++- .gitignore | 4 + .ruby-version | 1 + Gemfile | 6 ++ Gemfile.lock | 100 +++++++++++++++++++++ Libraries/Animated/NativeAnimatedHelper.js | 2 +- scripts/bump-oss-version.js | 6 ++ scripts/process-podspecs.sh | 33 +++---- scripts/react-native-xcode.sh | 2 +- scripts/run-ci-e2e-tests.js | 3 +- scripts/test-manual-e2e.sh | 4 +- scripts/update-ruby.sh | 66 ++++++++++++++ scripts/update_podfile_lock.sh | 27 ++---- template/Gemfile | 6 ++ template/Gemfile.lock | 100 +++++++++++++++++++++ template/_bundle/config | 2 + template/_ruby-version | 1 + 18 files changed, 335 insertions(+), 43 deletions(-) create mode 100644 .bundle/config create mode 100644 .ruby-version create mode 100644 Gemfile create mode 100644 Gemfile.lock create mode 100755 scripts/update-ruby.sh create mode 100644 template/Gemfile create mode 100644 template/Gemfile.lock create mode 100644 template/_bundle/config create mode 100644 template/_ruby-version diff --git a/.bundle/config b/.bundle/config new file mode 100644 index 0000000000..848943bb52 --- /dev/null +++ b/.bundle/config @@ -0,0 +1,2 @@ +BUNDLE_PATH: "vendor/bundle" +BUNDLE_FORCE_RUBY_PLATFORM: 1 diff --git a/.circleci/config.yml b/.circleci/config.yml index 849c11663f..2d8e41eaea 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -65,6 +65,16 @@ commands: name: Initial Setup command: mkdir -p ./reports/{buck,build,junit,outputs} + setup_ruby: + steps: + - restore_cache: + key: 1-gems-{{ checksum "Gemfile.lock" }} + - run: bundle check || bundle install --path vendor/bundle --clean + - save_cache: + key: 1-gems-{{ checksum "Gemfile.lock" }} + paths: + - vendor/bundle + run_yarn: steps: - restore_cache: @@ -356,6 +366,7 @@ jobs: steps: - checkout - setup_artifacts + - setup_ruby - run_yarn - run: | @@ -407,7 +418,7 @@ jobs: - run: name: Setup the CocoaPods environment - command: pod setup + command: bundle exec pod setup - with_rntester_pods_cache_span: steps: diff --git a/.gitignore b/.gitignore index a34c407b2a..c60f27e2a0 100644 --- a/.gitignore +++ b/.gitignore @@ -91,6 +91,10 @@ package-lock.json /React/FBReactNativeSpec/**/*.xcodeproj /packages/react-native-codegen/**/*.xcodeproj +# Ruby Gems (Bundler) +/vendor +/template/vendor + # CocoaPods /template/ios/Pods/ /template/ios/Podfile.lock diff --git a/.ruby-version b/.ruby-version new file mode 100644 index 0000000000..a4dd9dba4f --- /dev/null +++ b/.ruby-version @@ -0,0 +1 @@ +2.7.4 diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000000..2c3edcf4b7 --- /dev/null +++ b/Gemfile @@ -0,0 +1,6 @@ +source 'https://rubygems.org' + +# You may use http://rbenv.org/ or https://rvm.io/ to install and use this version +ruby '2.7.4' + +gem 'cocoapods', '~> 1.11', '>= 1.11.2' diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 0000000000..de5f3d29a1 --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,100 @@ +GEM + remote: https://rubygems.org/ + specs: + CFPropertyList (3.0.4) + rexml + activesupport (6.1.4.1) + concurrent-ruby (~> 1.0, >= 1.0.2) + i18n (>= 1.6, < 2) + minitest (>= 5.1) + tzinfo (~> 2.0) + zeitwerk (~> 2.3) + addressable (2.8.0) + public_suffix (>= 2.0.2, < 5.0) + algoliasearch (1.27.5) + httpclient (~> 2.8, >= 2.8.3) + json (>= 1.5.1) + atomos (0.1.3) + claide (1.0.3) + cocoapods (1.11.2) + addressable (~> 2.8) + claide (>= 1.0.2, < 2.0) + cocoapods-core (= 1.11.2) + cocoapods-deintegrate (>= 1.0.3, < 2.0) + cocoapods-downloader (>= 1.4.0, < 2.0) + cocoapods-plugins (>= 1.0.0, < 2.0) + cocoapods-search (>= 1.0.0, < 2.0) + cocoapods-trunk (>= 1.4.0, < 2.0) + cocoapods-try (>= 1.1.0, < 2.0) + colored2 (~> 3.1) + escape (~> 0.0.4) + fourflusher (>= 2.3.0, < 3.0) + gh_inspector (~> 1.0) + molinillo (~> 0.8.0) + nap (~> 1.0) + ruby-macho (>= 1.0, < 3.0) + xcodeproj (>= 1.21.0, < 2.0) + cocoapods-core (1.11.2) + activesupport (>= 5.0, < 7) + addressable (~> 2.8) + algoliasearch (~> 1.0) + concurrent-ruby (~> 1.1) + fuzzy_match (~> 2.0.4) + nap (~> 1.0) + netrc (~> 0.11) + public_suffix (~> 4.0) + typhoeus (~> 1.0) + cocoapods-deintegrate (1.0.5) + cocoapods-downloader (1.5.1) + cocoapods-plugins (1.0.0) + nap + cocoapods-search (1.0.1) + cocoapods-trunk (1.6.0) + nap (>= 0.8, < 2.0) + netrc (~> 0.11) + cocoapods-try (1.2.0) + colored2 (3.1.2) + concurrent-ruby (1.1.9) + escape (0.0.4) + ethon (0.14.0) + ffi (>= 1.15.0) + ffi (1.15.4) + fourflusher (2.3.1) + fuzzy_match (2.0.4) + gh_inspector (1.1.3) + httpclient (2.8.3) + i18n (1.8.10) + concurrent-ruby (~> 1.0) + json (2.5.1) + minitest (5.14.4) + molinillo (0.8.0) + nanaimo (0.3.0) + nap (1.1.0) + netrc (0.11.0) + public_suffix (4.0.6) + rexml (3.2.5) + ruby-macho (2.5.1) + typhoeus (1.4.0) + ethon (>= 0.9.0) + tzinfo (2.0.4) + concurrent-ruby (~> 1.0) + xcodeproj (1.21.0) + CFPropertyList (>= 2.3.3, < 4.0) + atomos (~> 0.1.3) + claide (>= 1.0.2, < 2.0) + colored2 (~> 3.1) + nanaimo (~> 0.3.0) + rexml (~> 3.2.4) + zeitwerk (2.4.2) + +PLATFORMS + ruby + +DEPENDENCIES + cocoapods (~> 1.11, >= 1.11.2) + +RUBY VERSION + ruby 2.7.4p191 + +BUNDLED WITH + 2.2.28 diff --git a/Libraries/Animated/NativeAnimatedHelper.js b/Libraries/Animated/NativeAnimatedHelper.js index 6bac8cb1fb..89fe7b5a8d 100644 --- a/Libraries/Animated/NativeAnimatedHelper.js +++ b/Libraries/Animated/NativeAnimatedHelper.js @@ -355,7 +355,7 @@ function shouldUseNativeDriver( 'animated module is missing. Falling back to JS-based animation. To ' + 'resolve this, add `RCTAnimation` module to this app, or remove ' + '`useNativeDriver`. ' + - 'Make sure to run `pod install` first. Read more about autolinking: https://github.com/react-native-community/cli/blob/master/docs/autolinking.md', + 'Make sure to run `bundle exec pod install` first. Read more about autolinking: https://github.com/react-native-community/cli/blob/master/docs/autolinking.md', ); _warnedMissingNativeAnimated = true; } diff --git a/scripts/bump-oss-version.js b/scripts/bump-oss-version.js index 2eaa43095d..6550726ed8 100755 --- a/scripts/bump-oss-version.js +++ b/scripts/bump-oss-version.js @@ -172,6 +172,12 @@ let numberOfChangedLinesWithNewVersion = exec( {silent: true}, ).stdout.trim(); +// Make sure to update ruby version +if (exec('scripts/update-ruby.sh').code) { + echo('Failed to update Ruby version'); + exit(1); +} + // Release builds should commit the version bumps, and create tags. // Nightly builds do not need to do that. if (!nightlyBuild) { diff --git a/scripts/process-podspecs.sh b/scripts/process-podspecs.sh index 539a4fea34..97ec80c8e0 100755 --- a/scripts/process-podspecs.sh +++ b/scripts/process-podspecs.sh @@ -6,12 +6,12 @@ set -ex -SCRIPTS=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd) -ROOT=$(dirname $SCRIPTS) +SCRIPTS="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +ROOT="$(dirname "$SCRIPTS")" # Specify `SPEC_REPO` as an env variable if you want to push to a specific spec repo. # Defaults to `react-test`, which is meant to be a dummy repo used to test that the specs fully lint. -: ${SPEC_REPO:="react-test"} +: "${SPEC_REPO:=react-test}" SPEC_REPO_DIR="$HOME/.cocoapods/repos/$SPEC_REPO" # If the `SPEC_REPO` does not exist yet, assume this is purely for testing and create a dummy repo. @@ -28,7 +28,7 @@ fi cd "$SPEC_REPO_DIR" SPEC_REPOS="$(git remote get-url origin),https://github.com/CocoaPods/Specs.git" -POD_LINT_OPT="--verbose --allow-warnings --fail-fast --private --swift-version=3.0 --sources=$SPEC_REPOS" +POD_LINT_OPT=(--verbose --allow-warnings --fail-fast --private "--swift-version=3.0" "--sources=$SPEC_REPOS") # Get the version from a podspec. version() { @@ -37,33 +37,34 @@ version() { # Lint both framework and static library builds. lint() { - local SUBSPEC=$1 + local SUBSPEC="$1" if [ "${SUBSPEC:-}" ]; then local SUBSPEC_OPT="--subspec=$SUBSPEC" fi - pod lib lint $SUBSPEC_OPT $POD_LINT_OPT - pod lib lint $SUBSPEC_OPT $POD_LINT_OPT --use-libraries + bundle exec pod lib lint "$SUBSPEC_OPT" "${POD_LINT_OPT[@]}" + bundle exec pod lib lint "$SUBSPEC_OPT" "${POD_LINT_OPT[@]}" --use-libraries } # Push the spec in arg `$1`, which is expected to be in the cwd, to the `SPEC_REPO` in JSON format. push() { - local SPEC_NAME=$1 - local POD_NAME=$(basename $SPEC_NAME .podspec) - local SPEC_DIR="$SPEC_REPO_DIR/$POD_NAME/$(version $SPEC_NAME)" - local SPEC_PATH="$SPEC_DIR/$SPEC_NAME.json" - mkdir -p $SPEC_DIR - env INSTALL_YOGA_WITHOUT_PATH_OPTION=1 INSTALL_YOGA_FROM_LOCATION="$ROOT" pod ipc spec $SPEC_NAME > $SPEC_PATH + local SPEC_NAME POD_NAME SPEC_DIR SPEC_PATH + SPEC_NAME="$1" + POD_NAME=$(basename "$SPEC_NAME" .podspec) + SPEC_DIR="$SPEC_REPO_DIR/$POD_NAME/$(version "$SPEC_NAME")" + SPEC_PATH="$SPEC_DIR/$SPEC_NAME.json" + mkdir -p "$SPEC_DIR" + env INSTALL_YOGA_WITHOUT_PATH_OPTION=1 INSTALL_YOGA_FROM_LOCATION="$ROOT" bundle exec pod ipc spec "$SPEC_NAME" > "$SPEC_PATH" } # Perform linting and publishing of podspec in cwd. # Skip linting with `SKIP_LINT` if e.g. publishing to a private spec repo. process() { - cd $1 + cd "$1" if [ -z "$SKIP_LINT" ]; then - lint $2 + lint "$2" fi local SPEC_NAME=(*.podspec) - push $SPEC_NAME + push "${SPEC_NAME[0]}" } # Make third-party deps accessible diff --git a/scripts/react-native-xcode.sh b/scripts/react-native-xcode.sh index 83c55d43f4..e9ddec0c30 100755 --- a/scripts/react-native-xcode.sh +++ b/scripts/react-native-xcode.sh @@ -96,7 +96,7 @@ fi if [[ $USE_HERMES == true && ! -f "$HERMES_CLI_PATH" ]]; then echo "error: USE_HERMES is set to true but the hermesc binary could not be " \ - "found at ${HERMES_CLI_PATH}. Perhaps you need to run pod install or otherwise " \ + "found at ${HERMES_CLI_PATH}. Perhaps you need to run 'bundle exec pod install' or otherwise " \ "point the HERMES_CLI_PATH variable to your custom location." >&2 exit 2 fi diff --git a/scripts/run-ci-e2e-tests.js b/scripts/run-ci-e2e-tests.js index ecbaea2409..a2bcb45c42 100644 --- a/scripts/run-ci-e2e-tests.js +++ b/scripts/run-ci-e2e-tests.js @@ -99,6 +99,7 @@ try { ); mv('_flowconfig', '.flowconfig'); mv('_watchmanconfig', '.watchmanconfig'); + mv('_bundle', '.bundle'); describe('Install React Native package'); exec(`npm install ${REACT_NATIVE_PACKAGE}`); @@ -210,7 +211,7 @@ try { echo(`Metro is running, ${SERVER_PID}`); describe('Install CocoaPod dependencies'); - exec('pod install'); + exec('bundle exec pod install'); describe('Test: iOS end-to-end test'); if ( diff --git a/scripts/test-manual-e2e.sh b/scripts/test-manual-e2e.sh index 6ea038b1ca..137d4c66f9 100755 --- a/scripts/test-manual-e2e.sh +++ b/scripts/test-manual-e2e.sh @@ -71,7 +71,7 @@ read -r -n 1 success "About to test iOS JSC... " success "Installing CocoaPods dependencies..." rm -rf packages/rn-tester/Pods -(cd packages/rn-tester && pod install) +(cd packages/rn-tester && bundle exec pod install) info "Press any key to open the workspace in Xcode, then build and test manually." info "" @@ -85,7 +85,7 @@ read -r -n 1 success "About to test iOS Hermes... " success "Installing CocoaPods dependencies..." rm -rf packages/rn-tester/Pods -(cd packages/rn-tester && USE_HERMES=1 pod install) +(cd packages/rn-tester && USE_HERMES=1 bundle exec pod install) info "Press any key to open the workspace in Xcode, then build and test manually." info "" diff --git a/scripts/update-ruby.sh b/scripts/update-ruby.sh new file mode 100755 index 0000000000..a220ad8473 --- /dev/null +++ b/scripts/update-ruby.sh @@ -0,0 +1,66 @@ +#!/bin/bash +# 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. + +set -e + +if [ "$VERBOSE" = 1 ]; then + set -x +fi + +case $(sed --help 2>&1) in + *GNU*) sed_i () { sed -i "$@"; };; + *) sed_i () { sed -i '' "$@"; };; +esac + +SCRIPTS="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +ROOT="$(dirname "$SCRIPTS")" + +die() { + echo "ERROR: $*" >&2 + exit 1 +} + +if [ $# -eq 1 ]; then + VERSION=$1 +else + VERSION=$(ruby --version | cut -d' ' -f2 | cut -dp -f1) +fi + +if [ -z "$VERSION" ]; then + die "Please provide an installed/usable Ruby version" +fi +echo "Setting Ruby version to: $VERSION" + +cd "$ROOT" || die "Failed to change to $ROOT" + +# do this first, so rbenv/rvm will automatically pick the desired version +echo "$VERSION" > .ruby-version + +# make sure we're using it +CURRENT_VERSION=$(ruby --version | cut -d' ' -f2 | cut -dp -f1) +if [ -z "$CURRENT_VERSION" ]; then + # rbenv/rvm uses shims, the commands do exist, but do not return a version if misconfigured + die "Missing usable ruby, check your installation" +elif [ "$VERSION" != "$CURRENT_VERSION" ]; then + die "Plese use the ruby version you are trying to set: $VERSION ('$CURRENT_VERSION' in use)" +fi + +echo "$VERSION" > template/_ruby-version + +sed_i -e "s/^\(ruby '\)[^']*\('.*\)$/\1$VERSION\2/" Gemfile +sed_i -e "s/^\(ruby '\)[^']*\('.*\)$/\1$VERSION\2/" template/Gemfile + +rm -f Gemfile.lock template/Gemfile.lock + +bundle lock +(cd template && bundle lock) + +git add \ + .ruby-version \ + Gemfile \ + template/_ruby-version \ + template/Gemfile \ + template/Gemfile.lock diff --git a/scripts/update_podfile_lock.sh b/scripts/update_podfile_lock.sh index 31163e29e4..d31016723e 100755 --- a/scripts/update_podfile_lock.sh +++ b/scripts/update_podfile_lock.sh @@ -11,31 +11,16 @@ THIS_DIR=$(cd -P "$(dirname "$(readlink "${BASH_SOURCE[0]}" || echo "${BASH_SOURCE[0]}")")" && pwd) RNTESTER_DIR="$THIS_DIR/../packages/rn-tester" -# Note: Keep in sync with FB internal. -REQUIRED_COCOAPODS_VERSION="1.11.2" - +# Keep this separate for FB internal access. validate_env () { - # Check that CocoaPods is working. - if [ -z "$(command -v pod)" ]; then - echo "You need to install CocoaPods." - echo "See https://guides.cocoapods.org/using/getting-started.html#getting-started for instructions." - exit 1 - fi - - COCOAPODS_VERSION=$(pod --version) - if [[ "$COCOAPODS_VERSION" != "$REQUIRED_COCOAPODS_VERSION" ]]; - then - echo "You must have CocoaPods $REQUIRED_COCOAPODS_VERSION installed; you have $COCOAPODS_VERSION." - echo "Installing via gem is recommended:" - echo " sudo gem install cocoapods -v $REQUIRED_COCOAPODS_VERSION" - exit 1 - fi + cd "$RNTESTER_DIR" || exit + bundle check || exit + cd "$THIS_DIR" || exit } update_pods () { - validate_env - cd "$RNTESTER_DIR" || exit - pod install + bundle check || exit + bundle exec pod install cd "$THIS_DIR" || exit } diff --git a/template/Gemfile b/template/Gemfile new file mode 100644 index 0000000000..2c3edcf4b7 --- /dev/null +++ b/template/Gemfile @@ -0,0 +1,6 @@ +source 'https://rubygems.org' + +# You may use http://rbenv.org/ or https://rvm.io/ to install and use this version +ruby '2.7.4' + +gem 'cocoapods', '~> 1.11', '>= 1.11.2' diff --git a/template/Gemfile.lock b/template/Gemfile.lock new file mode 100644 index 0000000000..f0b073f27b --- /dev/null +++ b/template/Gemfile.lock @@ -0,0 +1,100 @@ +GEM + remote: https://rubygems.org/ + specs: + CFPropertyList (3.0.4) + rexml + activesupport (6.1.4.1) + concurrent-ruby (~> 1.0, >= 1.0.2) + i18n (>= 1.6, < 2) + minitest (>= 5.1) + tzinfo (~> 2.0) + zeitwerk (~> 2.3) + addressable (2.8.0) + public_suffix (>= 2.0.2, < 5.0) + algoliasearch (1.27.5) + httpclient (~> 2.8, >= 2.8.3) + json (>= 1.5.1) + atomos (0.1.3) + claide (1.0.3) + cocoapods (1.11.2) + addressable (~> 2.8) + claide (>= 1.0.2, < 2.0) + cocoapods-core (= 1.11.2) + cocoapods-deintegrate (>= 1.0.3, < 2.0) + cocoapods-downloader (>= 1.4.0, < 2.0) + cocoapods-plugins (>= 1.0.0, < 2.0) + cocoapods-search (>= 1.0.0, < 2.0) + cocoapods-trunk (>= 1.4.0, < 2.0) + cocoapods-try (>= 1.1.0, < 2.0) + colored2 (~> 3.1) + escape (~> 0.0.4) + fourflusher (>= 2.3.0, < 3.0) + gh_inspector (~> 1.0) + molinillo (~> 0.8.0) + nap (~> 1.0) + ruby-macho (>= 1.0, < 3.0) + xcodeproj (>= 1.21.0, < 2.0) + cocoapods-core (1.11.2) + activesupport (>= 5.0, < 7) + addressable (~> 2.8) + algoliasearch (~> 1.0) + concurrent-ruby (~> 1.1) + fuzzy_match (~> 2.0.4) + nap (~> 1.0) + netrc (~> 0.11) + public_suffix (~> 4.0) + typhoeus (~> 1.0) + cocoapods-deintegrate (1.0.5) + cocoapods-downloader (1.5.1) + cocoapods-plugins (1.0.0) + nap + cocoapods-search (1.0.1) + cocoapods-trunk (1.6.0) + nap (>= 0.8, < 2.0) + netrc (~> 0.11) + cocoapods-try (1.2.0) + colored2 (3.1.2) + concurrent-ruby (1.1.9) + escape (0.0.4) + ethon (0.14.0) + ffi (>= 1.15.0) + ffi (1.15.4) + fourflusher (2.3.1) + fuzzy_match (2.0.4) + gh_inspector (1.1.3) + httpclient (2.8.3) + i18n (1.8.10) + concurrent-ruby (~> 1.0) + json (2.5.1) + minitest (5.14.4) + molinillo (0.8.0) + nanaimo (0.3.0) + nap (1.1.0) + netrc (0.11.0) + public_suffix (4.0.6) + rexml (3.2.5) + ruby-macho (2.5.1) + typhoeus (1.4.0) + ethon (>= 0.9.0) + tzinfo (2.0.4) + concurrent-ruby (~> 1.0) + xcodeproj (1.21.0) + CFPropertyList (>= 2.3.3, < 4.0) + atomos (~> 0.1.3) + claide (>= 1.0.2, < 2.0) + colored2 (~> 3.1) + nanaimo (~> 0.3.0) + rexml (~> 3.2.4) + zeitwerk (2.4.2) + +PLATFORMS + arm64-darwin-20 + +DEPENDENCIES + cocoapods (~> 1.11, >= 1.11.2) + +RUBY VERSION + ruby 2.7.4p191 + +BUNDLED WITH + 2.2.28 diff --git a/template/_bundle/config b/template/_bundle/config new file mode 100644 index 0000000000..848943bb52 --- /dev/null +++ b/template/_bundle/config @@ -0,0 +1,2 @@ +BUNDLE_PATH: "vendor/bundle" +BUNDLE_FORCE_RUBY_PLATFORM: 1 diff --git a/template/_ruby-version b/template/_ruby-version new file mode 100644 index 0000000000..a4dd9dba4f --- /dev/null +++ b/template/_ruby-version @@ -0,0 +1 @@ +2.7.4 From 2372e7a008539f65f26a5f5163a4cbb20e5a944e Mon Sep 17 00:00:00 2001 From: CodemodService FBSourceClangFormatLinterBot <> Date: Sat, 2 Oct 2021 08:31:38 -0700 Subject: [PATCH 09/62] Daily `arc lint --take CLANGFORMAT` Reviewed By: zertosh Differential Revision: D31362458 fbshipit-source-id: e26b6b5e1c99dd6adbd661240d6979160633c10b --- React/CoreModules/RCTAccessibilityManager+Internal.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/React/CoreModules/RCTAccessibilityManager+Internal.h b/React/CoreModules/RCTAccessibilityManager+Internal.h index b3a17b5f3c..e01e800748 100644 --- a/React/CoreModules/RCTAccessibilityManager+Internal.h +++ b/React/CoreModules/RCTAccessibilityManager+Internal.h @@ -13,8 +13,11 @@ NS_ASSUME_NONNULL_BEGIN RCT_EXTERN_C_BEGIN -// Only to be used for testing and internal tooling. Do not use this in production. -void RCTAccessibilityManagerSetIsVoiceOverEnabled(RCTAccessibilityManager *accessibiltyManager, BOOL isVoiceOverEnabled); +// Only to be used for testing and internal tooling. Do not use this in +// production. +void RCTAccessibilityManagerSetIsVoiceOverEnabled( + RCTAccessibilityManager *accessibiltyManager, + BOOL isVoiceOverEnabled); RCT_EXTERN_C_END From 36f3bf2f583596a08a59e1f65016aaf4652fc341 Mon Sep 17 00:00:00 2001 From: Samuel Susla Date: Sat, 2 Oct 2021 09:02:20 -0700 Subject: [PATCH 10/62] Add option to use raw pointer instead of shared_ptr in EventEmitterWrapper Summary: changelog: [internal] Retaining `EventEmitter` beyond runtime triggers a crash. Let's try to use raw pointer in `EventEmitterWrapper` to see if it fixes some crashes. Reviewed By: philIip Differential Revision: D31307332 fbshipit-source-id: cd059b6c56f8dffe985b3ecb62cdafe823ba1462 --- .../com/facebook/react/fabric/jni/Binding.cpp | 27 ++++++++++++++----- .../com/facebook/react/fabric/jni/Binding.h | 1 + .../react/fabric/jni/EventEmitterWrapper.cpp | 14 ++++++++++ .../react/fabric/jni/EventEmitterWrapper.h | 1 + 4 files changed, 37 insertions(+), 6 deletions(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/Binding.cpp b/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/Binding.cpp index edbe5613e6..bdabaaf882 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/Binding.cpp +++ b/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/Binding.cpp @@ -243,8 +243,9 @@ Binding::getInspectorDataForInstance( } EventEmitterWrapper *cEventEmitter = cthis(eventEmitterWrapper); - InspectorData data = - scheduler->getInspectorDataForInstance(*cEventEmitter->eventEmitter); + InspectorData data = scheduler->getInspectorDataForInstance( + enableEventEmitterRawPointer_ ? *cEventEmitter->eventEmitterPointer + : *cEventEmitter->eventEmitter); folly::dynamic result = folly::dynamic::object; result["fileName"] = data.fileName; @@ -511,6 +512,9 @@ void Binding::installFabricUIManager( disableRevisionCheckForPreallocation_ = config->getBool("react_fabric:disable_revision_check_for_preallocation"); + enableEventEmitterRawPointer_ = + config->getBool("react_fabric:enable_event_emitter_wrapper_raw_pointer"); + if (enableFabricLogs_) { LOG(WARNING) << "Binding::installFabricUIManager() was called (address: " << this << ")."; @@ -920,8 +924,11 @@ void Binding::schedulerDidFinishTransaction( mountItem.newChildShadowView.eventEmitter; auto javaEventEmitter = EventEmitterWrapper::newObjectJavaArgs(); EventEmitterWrapper *cEventEmitter = cthis(javaEventEmitter); - cEventEmitter->eventEmitter = eventEmitter; - + if (enableEventEmitterRawPointer_) { + cEventEmitter->eventEmitterPointer = eventEmitter.get(); + } else { + cEventEmitter->eventEmitter = eventEmitter; + } temp[0] = mountItem.newChildShadowView.tag; temp[1] = isLayoutable; env->SetIntArrayRegion(intBufferArray, intBufferPosition, 2, temp); @@ -1071,7 +1078,11 @@ void Binding::schedulerDidFinishTransaction( // Do not hold a reference to javaEventEmitter from the C++ side. auto javaEventEmitter = EventEmitterWrapper::newObjectJavaArgs(); EventEmitterWrapper *cEventEmitter = cthis(javaEventEmitter); - cEventEmitter->eventEmitter = eventEmitter; + if (enableEventEmitterRawPointer_) { + cEventEmitter->eventEmitterPointer = eventEmitter.get(); + } else { + cEventEmitter->eventEmitter = eventEmitter; + } (*objBufferArray)[objBufferPosition++] = javaEventEmitter.get(); } @@ -1198,7 +1209,11 @@ void Binding::preallocateShadowView( if (eventEmitter != nullptr) { javaEventEmitter = EventEmitterWrapper::newObjectJavaArgs(); EventEmitterWrapper *cEventEmitter = cthis(javaEventEmitter); - cEventEmitter->eventEmitter = eventEmitter; + if (enableEventEmitterRawPointer_) { + cEventEmitter->eventEmitterPointer = eventEmitter.get(); + } else { + cEventEmitter->eventEmitter = eventEmitter; + } } } diff --git a/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/Binding.h b/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/Binding.h index 9750a51bf2..717d1be076 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/Binding.h +++ b/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/Binding.h @@ -202,6 +202,7 @@ class Binding : public jni::HybridClass, bool enableFabricLogs_{false}; bool enableEarlyEventEmitterUpdate_{false}; bool disableRevisionCheckForPreallocation_{false}; + bool enableEventEmitterRawPointer_{false}; }; } // namespace react diff --git a/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/EventEmitterWrapper.cpp b/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/EventEmitterWrapper.cpp index af207a64b7..b535c2ca75 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/EventEmitterWrapper.cpp +++ b/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/EventEmitterWrapper.cpp @@ -22,6 +22,15 @@ void EventEmitterWrapper::invokeEvent( std::string eventName, NativeMap *payload, int category) { + if (eventEmitterPointer) { + eventEmitterPointer->dispatchEvent( + std::move(eventName), + payload->consume(), + EventPriority::AsynchronousBatched, + static_cast(category)); + return; + } + // It is marginal, but possible for this to be constructed without a valid // EventEmitter. In those cases, make sure we noop/blackhole events instead of // crashing. @@ -38,6 +47,11 @@ void EventEmitterWrapper::invokeUniqueEvent( std::string eventName, NativeMap *payload, int customCoalesceKey) { + if (eventEmitterPointer) { + eventEmitterPointer->dispatchUniqueEvent( + std::move(eventName), payload->consume()); + return; + } // TODO: customCoalesceKey currently unused // It is marginal, but possible for this to be constructed without a valid // EventEmitter. In those cases, make sure we noop/blackhole events instead of diff --git a/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/EventEmitterWrapper.h b/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/EventEmitterWrapper.h index bc2d3cac90..b36911da92 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/EventEmitterWrapper.h +++ b/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/EventEmitterWrapper.h @@ -24,6 +24,7 @@ class EventEmitterWrapper : public jni::HybridClass { static void registerNatives(); SharedEventEmitter eventEmitter; + EventEmitter const *eventEmitterPointer; void invokeEvent(std::string eventName, NativeMap *params, int category); void invokeUniqueEvent( From 93beb83abef42b92db43ee3bb8b156f486a6c00f Mon Sep 17 00:00:00 2001 From: Xin Chen Date: Mon, 4 Oct 2021 17:50:52 -0700 Subject: [PATCH 11/62] Allow overflow scroll to clip the view instead of let it be visible Summary: When the overflow style set to 'scroll', React ViewGroup does nothing to the container. Instead it should be clipped just like hidden. Changelog: [Android][Changed] - Setting `overflow: scroll` in View component style will clip the children in the View container Reviewed By: javache Differential Revision: D31350605 fbshipit-source-id: e0d618f5e872fec9cf9ecb2d4cfe7af9a2f3c063 --- .../main/java/com/facebook/react/views/view/ReactViewGroup.java | 1 + 1 file changed, 1 insertion(+) diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactViewGroup.java b/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactViewGroup.java index c0bf085c8f..8bf0f0b4fa 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactViewGroup.java +++ b/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactViewGroup.java @@ -786,6 +786,7 @@ public class ReactViewGroup extends ViewGroup } break; case ViewProps.HIDDEN: + case ViewProps.SCROLL: float left = 0f; float top = 0f; float right = getWidth(); From 7923804c28aac731396f0db112cb6c3a9d30c08f Mon Sep 17 00:00:00 2001 From: Rob Hogan Date: Tue, 5 Oct 2021 02:25:07 -0700 Subject: [PATCH 12/62] Use newer metro language: `blacklistRE` -> `blockList` (#30342) Summary: An [update to `metro`](https://github.com/facebook/metro/commit/94c0b541b4bfa17aee4efa0f1969565522ce830d#diff-1a3c1a959bb8c4e2e9743c03cb7a6d0c56648ffcfe129a11b9090bfc139622dd) which landed in metro 0.60 (RN 0.64+) deprecates the config `blacklistRE`, renaming it to `blockList`. Although the former is still supported it now generates a deprecation warning. ## Changelog [General] [Fixed] - Update metro config language to `blockList` Pull Request resolved: https://github.com/facebook/react-native/pull/30342 Test Plan: Confirm that the config is still respected (`/buck-out/` should be excluded), and that no deprecation warning is issued. Reviewed By: lunaleaps Differential Revision: D31380163 Pulled By: motiz88 fbshipit-source-id: f64cff30690f0252fafd4eac254a8c2278c4ac2f --- metro.config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/metro.config.js b/metro.config.js index a868d504fc..69a20e6346 100644 --- a/metro.config.js +++ b/metro.config.js @@ -19,7 +19,7 @@ const getPolyfills = require('./rn-get-polyfills'); module.exports = { resolver: { // $FlowFixMe[signature-verification-failure] Can't infer RegExp type. - blacklistRE: /buck-out/, + blockList: /buck-out/, extraNodeModules: { 'react-native': __dirname, }, From 046b02628d32eadd6d44160ab79932f6c26b188d Mon Sep 17 00:00:00 2001 From: Frieder Bluemle Date: Tue, 5 Oct 2021 12:54:22 -0700 Subject: [PATCH 13/62] Move mavenCentral repo below local paths (#32326) Summary: In https://github.com/facebook/react-native/issues/31609, the deprecated `jcenter()` was replaced with `mavenCentral()`. In the template build.gradle, it _also changed the order of repos_. I am not sure if this was done intentionally or not (dulmandakh please confirm). Instead of appearing right _after_ `google()`, `mavenCentral()` was put **first** in the list, even before the local repos (that, for example, contain the `react-native` artifacts fetched by npm). Now, under normal circumstance, this _might_ not cause issues because of latency, but there is chance that Gradle could resolve incorrect versions (or at least look in the wrong repo first). The last version of `react-native` published to the public repo was [`0.20.1`](https://mvnrepository.com/artifact/com.facebook.react/react-native/0.20.1), uploaded in February 2016! This PR changes the order of `mavenCentral()` so that is consistent with both the repo's current [root level build.gradle](https://github.com/facebook/react-native/blob/main/build.gradle.kts#L34), as well as other default Android templates. Putting the local repos first will ensure they have the highest priority when looking for artifacts. `react-native` should _always_ come from the locally downloaded `node_modules/` folder, not from a remote repo. ## Changelog [Android] [Changed] - Move mavenCentral repo below local paths Pull Request resolved: https://github.com/facebook/react-native/pull/32326 Test Plan: Create new app from template, ensure local repos appear before remote repos; `react-native` resolves to correct version. Reviewed By: yungsters Differential Revision: D31375678 Pulled By: cortinico fbshipit-source-id: e47737262b4eebb06e22a955cacd6114059bb2f4 --- template/android/build.gradle | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/template/android/build.gradle b/template/android/build.gradle index 758d1d448a..db796539ce 100644 --- a/template/android/build.gradle +++ b/template/android/build.gradle @@ -21,7 +21,6 @@ buildscript { allprojects { repositories { - mavenCentral() maven { // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm url("$rootDir/../node_modules/react-native/android") @@ -30,7 +29,7 @@ allprojects { // Android JSC is installed from npm url("$rootDir/../node_modules/jsc-android/dist") } - + mavenCentral() google() maven { url 'https://www.jitpack.io' } } From 52809688d2a23a8ac89463f836c4c46eef46f4b9 Mon Sep 17 00:00:00 2001 From: Luna Wei Date: Tue, 5 Oct 2021 17:22:05 -0700 Subject: [PATCH 14/62] Remove ProgressBar from examples and fix XHRDownloadExample Summary: Changelog: [Internal] - Remove usage of ProgressViewIOS and ProgressBarAndroid from RNTester Note: Android example doesn't properly update progress. Filing an issue here: TODO Reviewed By: yungsters Differential Revision: D31328094 fbshipit-source-id: 5afa3bb1079b91bb98fa51587e96402fb1565f82 --- .../js/examples/XHR/XHRExampleDownload.js | 27 ++++--------------- 1 file changed, 5 insertions(+), 22 deletions(-) diff --git a/packages/rn-tester/js/examples/XHR/XHRExampleDownload.js b/packages/rn-tester/js/examples/XHR/XHRExampleDownload.js index f203a7d9a1..107dc45349 100644 --- a/packages/rn-tester/js/examples/XHR/XHRExampleDownload.js +++ b/packages/rn-tester/js/examples/XHR/XHRExampleDownload.js @@ -14,9 +14,6 @@ const React = require('react'); const { Alert, - Platform, - ProgressBarAndroid, - ProgressViewIOS, StyleSheet, Switch, Text, @@ -31,21 +28,6 @@ function roundKilo(value: number): number { return Math.round(value / 1000); } -class ProgressBar extends React.Component<$FlowFixMeProps> { - render() { - if (Platform.OS === 'android') { - return ( - - ); - } - return ; - } -} - class XHRExampleDownload extends React.Component<{...}, Object> { state: Object = { downloading: false, @@ -126,7 +108,10 @@ class XHRExampleDownload extends React.Component<{...}, Object> { Alert.alert('Error', xhr.responseText); } }; - xhr.open('GET', 'http://aleph.gutenberg.org/cache/epub/100/pg100.txt.utf8'); + xhr.open( + 'GET', + 'http://aleph.gutenberg.org/cache/epub/100/pg100-images.html.utf8', + ); // Avoid gzip so we can actually show progress xhr.setRequestHeader('Accept-Encoding', ''); xhr.send(); @@ -149,7 +134,7 @@ class XHRExampleDownload extends React.Component<{...}, Object> { ) : ( - Download 5MB Text File + Download 7MB Text File ); @@ -164,7 +149,6 @@ class XHRExampleDownload extends React.Component<{...}, Object> { responseText: {roundKilo(responseLength)}/{roundKilo(contentLength)} k chars - ); } @@ -176,7 +160,6 @@ class XHRExampleDownload extends React.Component<{...}, Object> { onprogress: {roundKilo(progressLoaded)}/{roundKilo(progressTotal)}{' '} KB - ); } From 25a2c608f790f42cbc4bb0a90fc06cc7bbbc9b95 Mon Sep 17 00:00:00 2001 From: Brent Kelly Date: Tue, 5 Oct 2021 20:21:48 -0700 Subject: [PATCH 15/62] Addressing various issues with the Appearance API (#28823) (#29106) Summary: This PR fixes a few issues with the Appearance API (as noted here https://github.com/facebook/react-native/issues/28823). 1. For the Appearance API to work correctly on Android you need to call `AppearanceModule.onConfigurationChanged` when the current Activity goes through a configuration change. This was being called in the RNTester app but not in `ReactActivity` so it meant the Appearance API wouldn't work for Android in newly generated RN projects (or ones upgraded to the latest version of RN). 2. The Appearance API wasn't working correctly for brownfield scenarios on Android. It's possible to force an app light or dark natively on Android by calling `AppCompatDelegate.setDefaultNightMode()`. The Appearance API wasn't picking up changes from this function because it was using the Application context instead of the current Activity context. 3. The Appearance API wasn't working correctly for brownfield scenarios on iOS. Just like on Android its possible to force an app light or dark natively by setting `window.overrideUserInterfaceStyle`. The Appearance API didn't work with this override because we were overwriting `_currentColorScheme` back to default as soon as we set it. ## Changelog ### Fixed https://github.com/facebook/react-native/issues/28823 * [Android] [Fixed] - Appearance API now works on Android * [Android] [Fixed] - Appearance API now works correctly when calling `AppCompatDelegate.setDefaultNightMode()` * [iOS] [Fixed] - Appearance API now works correctly when setting `window.overrideUserInterfaceStyle` Pull Request resolved: https://github.com/facebook/react-native/pull/29106 Test Plan: Ran RNTester on iOS and Android and verified the Appearance examples still worked [correctly.](url) Reviewed By: hramos Differential Revision: D31284331 Pulled By: sota000 fbshipit-source-id: 45bbe33983e506eb177d596d33ddf15f846708fd --- React/CoreModules/RCTAppearance.mm | 4 +++- .../main/java/com/facebook/react/ReactActivity.java | 7 +++++++ .../com/facebook/react/ReactActivityDelegate.java | 7 +++++++ .../react/modules/appearance/AppearanceModule.java | 11 ++++++++++- .../com/facebook/react/uiapp/RNTesterActivity.java | 12 ------------ 5 files changed, 27 insertions(+), 14 deletions(-) diff --git a/React/CoreModules/RCTAppearance.mm b/React/CoreModules/RCTAppearance.mm index 820063db4e..1d762b67cc 100644 --- a/React/CoreModules/RCTAppearance.mm +++ b/React/CoreModules/RCTAppearance.mm @@ -89,7 +89,9 @@ RCT_EXPORT_MODULE(Appearance) RCT_EXPORT_SYNCHRONOUS_TYPED_METHOD(NSString *, getColorScheme) { - _currentColorScheme = RCTColorSchemePreference(nil); + if (_currentColorScheme == nil) { + _currentColorScheme = RCTColorSchemePreference(nil); + } return _currentColorScheme; } diff --git a/ReactAndroid/src/main/java/com/facebook/react/ReactActivity.java b/ReactAndroid/src/main/java/com/facebook/react/ReactActivity.java index 3eb5aa7408..d5290d968c 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/ReactActivity.java +++ b/ReactAndroid/src/main/java/com/facebook/react/ReactActivity.java @@ -8,6 +8,7 @@ package com.facebook.react; import android.content.Intent; +import android.content.res.Configuration; import android.os.Bundle; import android.view.KeyEvent; import androidx.annotation.Nullable; @@ -121,6 +122,12 @@ public abstract class ReactActivity extends AppCompatActivity mDelegate.onWindowFocusChanged(hasFocus); } + @Override + public void onConfigurationChanged(Configuration newConfig) { + super.onConfigurationChanged(newConfig); + mDelegate.onConfigurationChanged(newConfig); + } + protected final ReactNativeHost getReactNativeHost() { return mDelegate.getReactNativeHost(); } diff --git a/ReactAndroid/src/main/java/com/facebook/react/ReactActivityDelegate.java b/ReactAndroid/src/main/java/com/facebook/react/ReactActivityDelegate.java index c6766d138f..fc9090001c 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/ReactActivityDelegate.java +++ b/ReactAndroid/src/main/java/com/facebook/react/ReactActivityDelegate.java @@ -11,6 +11,7 @@ import android.annotation.TargetApi; import android.app.Activity; import android.content.Context; import android.content.Intent; +import android.content.res.Configuration; import android.os.Build; import android.os.Bundle; import android.view.KeyEvent; @@ -154,6 +155,12 @@ public class ReactActivityDelegate { } } + public void onConfigurationChanged(Configuration newConfig) { + if (getReactNativeHost().hasInstance()) { + getReactInstanceManager().onConfigurationChanged(getContext(), newConfig); + } + } + @TargetApi(Build.VERSION_CODES.M) public void requestPermissions( String[] permissions, int requestCode, PermissionListener listener) { diff --git a/ReactAndroid/src/main/java/com/facebook/react/modules/appearance/AppearanceModule.java b/ReactAndroid/src/main/java/com/facebook/react/modules/appearance/AppearanceModule.java index 99b7c5311b..ab47e66c52 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/modules/appearance/AppearanceModule.java +++ b/ReactAndroid/src/main/java/com/facebook/react/modules/appearance/AppearanceModule.java @@ -7,6 +7,7 @@ package com.facebook.react.modules.appearance; +import android.app.Activity; import android.content.Context; import android.content.res.Configuration; import androidx.annotation.Nullable; @@ -74,7 +75,15 @@ public class AppearanceModule extends NativeAppearanceSpec { @Override public String getColorScheme() { - mColorScheme = colorSchemeForCurrentConfiguration(getReactApplicationContext()); + // Attempt to use the Activity context first in order to get the most up to date + // scheme. This covers the scenario when AppCompatDelegate.setDefaultNightMode() + // is called directly (which can occur in Brownfield apps for example). + Activity activity = getCurrentActivity(); + + mColorScheme = + colorSchemeForCurrentConfiguration( + activity != null ? activity : getReactApplicationContext()); + return mColorScheme; } diff --git a/packages/rn-tester/android/app/src/main/java/com/facebook/react/uiapp/RNTesterActivity.java b/packages/rn-tester/android/app/src/main/java/com/facebook/react/uiapp/RNTesterActivity.java index 4cbb384cde..9d7964a5f2 100644 --- a/packages/rn-tester/android/app/src/main/java/com/facebook/react/uiapp/RNTesterActivity.java +++ b/packages/rn-tester/android/app/src/main/java/com/facebook/react/uiapp/RNTesterActivity.java @@ -7,12 +7,10 @@ package com.facebook.react.uiapp; -import android.content.res.Configuration; import android.os.Bundle; import androidx.annotation.Nullable; import com.facebook.react.ReactActivity; import com.facebook.react.ReactActivityDelegate; -import com.facebook.react.ReactInstanceManager; import com.facebook.react.ReactRootView; public class RNTesterActivity extends ReactActivity { @@ -64,14 +62,4 @@ public class RNTesterActivity extends ReactActivity { protected String getMainComponentName() { return "RNTesterApp"; } - - @Override - public void onConfigurationChanged(Configuration newConfig) { - super.onConfigurationChanged(newConfig); - ReactInstanceManager instanceManager = getReactInstanceManager(); - - if (instanceManager != null) { - instanceManager.onConfigurationChanged(this, newConfig); - } - } } From cd4bef97d06e5534faa67246c7c486f93a4a6703 Mon Sep 17 00:00:00 2001 From: Pieter De Baets Date: Wed, 6 Oct 2021 04:03:13 -0700 Subject: [PATCH 16/62] Add toString to all MountItem subclasses Summary: Useful when Fabric debug logging is enabled Changelog: [Internal] Reviewed By: mdvacca Differential Revision: D31399518 fbshipit-source-id: b5907084604adf1f7093798315147ac63b5876f2 --- .../react/fabric/FabricUIManager.java | 19 +++++++++++++++++++ .../mountitems/IntBufferBatchMountItem.java | 8 ++++++-- .../processing/ReactPropertyProcessor.java | 2 +- 3 files changed, 26 insertions(+), 3 deletions(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricUIManager.java b/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricUIManager.java index c8f24f4e0c..44a81cd031 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricUIManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricUIManager.java @@ -628,6 +628,15 @@ public class FabricUIManager implements UIManager, LifecycleEventListener { public int getSurfaceId() { return View.NO_ID; } + + @Override + public String toString() { + String propsString = + IS_DEVELOPMENT_ENVIRONMENT + ? (props != null ? props.toHashMap().toString() : "") + : ""; + return String.format("SYNC UPDATE PROPS [%d]: %s", reactTag, propsString); + } }; // If the reactTag exists, we assume that it might at the end of the next @@ -1016,6 +1025,11 @@ public class FabricUIManager implements UIManager, LifecycleEventListener { public int getSurfaceId() { return surfaceId; } + + @Override + public String toString() { + return String.format("SET_JS_RESPONDER [%d] [surface:%d]", reactTag, surfaceId); + } }); } @@ -1035,6 +1049,11 @@ public class FabricUIManager implements UIManager, LifecycleEventListener { public int getSurfaceId() { return View.NO_ID; } + + @Override + public String toString() { + return "CLEAR_JS_RESPONDER"; + } }); } diff --git a/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/mountitems/IntBufferBatchMountItem.java b/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/mountitems/IntBufferBatchMountItem.java index cd4bb8c5f6..038596c6ac 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/mountitems/IntBufferBatchMountItem.java +++ b/ReactAndroid/src/main/java/com/facebook/react/fabric/mounting/mountitems/IntBufferBatchMountItem.java @@ -226,8 +226,12 @@ public class IntBufferBatchMountItem implements MountItem { : ""; s.append(String.format("UPDATE PROPS [%d]: %s\n", mIntBuffer[i++], propsString)); } else if (type == INSTRUCTION_UPDATE_STATE) { - j += 1; - s.append(String.format("UPDATE STATE [%d]\n", mIntBuffer[i++])); + StateWrapper state = castToState(mObjBuffer[j++]); + String stateString = + IS_DEVELOPMENT_ENVIRONMENT + ? (state != null ? state.getStateData().toString() : "") + : ""; + s.append(String.format("UPDATE STATE [%d]: %s\n", mIntBuffer[i++], stateString)); } else if (type == INSTRUCTION_UPDATE_LAYOUT) { s.append( String.format( diff --git a/ReactAndroid/src/main/java/com/facebook/react/processing/ReactPropertyProcessor.java b/ReactAndroid/src/main/java/com/facebook/react/processing/ReactPropertyProcessor.java index 5cee5dba14..9ac4470224 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/processing/ReactPropertyProcessor.java +++ b/ReactAndroid/src/main/java/com/facebook/react/processing/ReactPropertyProcessor.java @@ -59,7 +59,7 @@ import javax.lang.model.util.Types; /** * This annotation processor crawls subclasses of ReactShadowNode and ViewManager and finds their * exported properties with the @ReactProp or @ReactGroupProp annotation. It generates a class per - * shadow node/view manager that is named {@code $$PropSetter}. This class contains + * shadow node/view manager that is named {@code $$PropsSetter}. This class contains * methods to retrieve the name and type of all methods and a way to set these properties without * reflection. */ From 72ef5e280f7111d236c8090c37f13f7e111738f0 Mon Sep 17 00:00:00 2001 From: Manoj Kumar Date: Wed, 6 Oct 2021 04:05:53 -0700 Subject: [PATCH 17/62] Update gradle.properties example (#32314) Summary: Fixed incorrect default mentioned in the comment Changelog: [Internal] Update gradle.properties example Pull Request resolved: https://github.com/facebook/react-native/pull/32314 Reviewed By: yungsters Differential Revision: D31365465 Pulled By: cortinico fbshipit-source-id: 82383c9c50495575698e27350cbf181f6effa0ee --- template/android/gradle.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/template/android/gradle.properties b/template/android/gradle.properties index cdb4c21108..11d6e02418 100644 --- a/template/android/gradle.properties +++ b/template/android/gradle.properties @@ -9,7 +9,7 @@ # Specifies the JVM arguments used for the daemon process. # The setting is particularly useful for tweaking memory settings. -# Default value: -Xmx10248m -XX:MaxPermSize=256m +# Default value: -Xmx1024m -XX:MaxPermSize=256m # org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8 # When configured, Gradle will run in incubating parallel mode. From 356236471abc6b5b8c139223e15388fd1eecd2d1 Mon Sep 17 00:00:00 2001 From: Juan Tejada Date: Wed, 6 Oct 2021 08:33:08 -0700 Subject: [PATCH 18/62] Update React DevTools from 4.13.0 -> 4.19.1 Summary: Update `react-devtools-core` and `react-devtools` dependencies for RN, VSCode, Sonar, etc. `js1 upgrade react-devtools -v 4.19.1` # Changelog: [General][Changed] - Upgraded react-devtools-core dependency to 4.19.1 Reviewed By: bvaughn Differential Revision: D31345135 fbshipit-source-id: dae06a18699df19a6e8422460effd48f715e395b --- package.json | 2 +- yarn.lock | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index 00d2fce131..29ea521de0 100644 --- a/package.json +++ b/package.json @@ -109,7 +109,7 @@ "pretty-format": "^26.5.2", "promise": "^8.0.3", "prop-types": "^15.7.2", - "react-devtools-core": "^4.13.0", + "react-devtools-core": "4.19.1", "react-refresh": "^0.4.0", "regenerator-runtime": "^0.13.2", "scheduler": "^0.20.2", diff --git a/yarn.lock b/yarn.lock index 53726729ab..c9dde3be89 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5554,10 +5554,10 @@ range-parser@~1.2.0: resolved "https://registry.yarnpkg.com/range-parser/-/range-parser-1.2.0.tgz#f49be6b487894ddc40dcc94a322f611092e00d5e" integrity sha1-9JvmtIeJTdxA3MlKMi9hEJLgDV4= -react-devtools-core@^4.13.0: - version "4.13.0" - resolved "https://registry.yarnpkg.com/react-devtools-core/-/react-devtools-core-4.13.0.tgz#fa80ee03b1a975c1d9898e24de841e45a4b22d30" - integrity sha512-KR+0pLw8wTjOVr+9AECe5ctmycaAjbmxN3bbdB0vmlwm0JkxNnKMxDzanf+4V8IuPBQWgm8qdWpbSOqhu1l14g== +react-devtools-core@4.19.1: + version "4.19.1" + resolved "https://registry.yarnpkg.com/react-devtools-core/-/react-devtools-core-4.19.1.tgz#bc37c2ef2f48f28c6af4c7292be9dca1b63deace" + integrity sha512-2wJiGffPWK0KggBjVwnTaAk+Z3MSxKInHmdzPTrBh1mAarexsa93Kw+WMX88+XjN+TtYgAiLe9xeTqcO5FfJTw== dependencies: shell-quote "^1.6.1" ws "^7" From 22801870f0613c2544ade1ebc5363e6e2f015c79 Mon Sep 17 00:00:00 2001 From: Xiankun Cheng Date: Wed, 6 Oct 2021 12:42:00 -0700 Subject: [PATCH 19/62] Fix: multiline textinput start "jerking" when trying to move cursor. (#32179) Summary: Fixes https://github.com/facebook/react-native/issues/30748: on iOS 14, when trying to hold down the space bar and move the cursor on a multi-line TextInput with lots of lines, the cursor could not be scrolled to the desired point. It works as expected on iOS 13 and before. Figured out that iOS14 acting as expected without `[setContentOffset:animated:]`, so exclude it when iOS version is and above 14. Credit to efstathiosntonas for the finding and solution provides. ## Related issue - https://github.com/facebook/react-native/issues/30748 ## Changelog [iOS] [Fixed] - Fixed the issue when moving cursor in multi-line TextInput. Pull Request resolved: https://github.com/facebook/react-native/pull/32179 Test Plan: 1. Launch RNTester app on iOS 2. Open `TextInput` in tab `Components` 3. Scroll to `Multiline` section and focus on the first child 4. Input lots of dummy texts 5. Hold the space bar (on device) or press down the mouse inside `TextInput` (simulator without showing keyboard) ### **Video Before:** https://user-images.githubusercontent.com/6382178/132800651-fb7cd2ac-fbd1-4ec4-9e3b-c06ab5b6a114.MP4 ### **Video After:** https://user-images.githubusercontent.com/6382178/132800677-f349fe7f-5902-40ff-8b93-ecc96ce29166.MP4 Reviewed By: philIip Differential Revision: D31404248 Pulled By: lunaleaps fbshipit-source-id: 74a39106e628602c5177fc243783288fcb7782fa --- Libraries/Text/TextInput/Multiline/RCTUITextView.m | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Libraries/Text/TextInput/Multiline/RCTUITextView.m b/Libraries/Text/TextInput/Multiline/RCTUITextView.m index 2f72cb83fa..4a94455025 100644 --- a/Libraries/Text/TextInput/Multiline/RCTUITextView.m +++ b/Libraries/Text/TextInput/Multiline/RCTUITextView.m @@ -182,12 +182,14 @@ static UIColor *defaultPlaceholderColor() _textWasPasted = YES; } +// Turn off scroll animation to fix flaky scrolling. +// This is only necessary for iOS <= 13. +#if defined(__IPHONE_OS_VERSION_MAX_ALLOWED) && __IPHONE_OS_VERSION_MAX_ALLOWED < 140000 - (void)setContentOffset:(CGPoint)contentOffset animated:(__unused BOOL)animated { - // Turning off scroll animation. - // This fixes the problem also known as "flaky scrolling". [super setContentOffset:contentOffset animated:NO]; } +#endif - (void)selectAll:(id)sender { From 7bbf549ae5954009146b611e364bb22cc15b8c2a Mon Sep 17 00:00:00 2001 From: Gijs Weterings Date: Thu, 7 Oct 2021 11:20:24 -0700 Subject: [PATCH 20/62] fix viewconfig for AndroidHorizontalScrollViewNativeComponent Summary: Changelog: [Android][Fix] Fix viewconfig for AndroidHorizontalScrollViewNativeComponent by adding snapToAlignment Reviewed By: mdvacca Differential Revision: D31476885 fbshipit-source-id: 89a4e16bd3d2cac0cc3c70c8a948deadababd488 --- .../ScrollView/AndroidHorizontalScrollViewNativeComponent.js | 1 + 1 file changed, 1 insertion(+) diff --git a/Libraries/Components/ScrollView/AndroidHorizontalScrollViewNativeComponent.js b/Libraries/Components/ScrollView/AndroidHorizontalScrollViewNativeComponent.js index 05f629e01a..9ba0b235f2 100644 --- a/Libraries/Components/ScrollView/AndroidHorizontalScrollViewNativeComponent.js +++ b/Libraries/Components/ScrollView/AndroidHorizontalScrollViewNativeComponent.js @@ -31,6 +31,7 @@ const AndroidHorizontalScrollViewNativeComponent: HostComponent = NativeC scrollPerfTag: true, sendMomentumEvents: true, showsHorizontalScrollIndicator: true, + snapToAlignment: true, snapToEnd: true, snapToInterval: true, snapToStart: true, From e612d3a116f39ab354169643bab0d4bb9cfc1a85 Mon Sep 17 00:00:00 2001 From: Wes Johnson Date: Thu, 7 Oct 2021 12:04:29 -0700 Subject: [PATCH 21/62] fix(logging): avoid logging sensitive param values (#31522) Summary: We noticed that by default when the RootView / ReactView calls runApplication, we're logging at an info level any props ("params") passed to that component. In our case, one of these props was sensitive in nature, causing the value to leak out in logs for our release builds. This is especially problematic on Android where device logs can be accessed by any app which requests that permission. This is probably more of a concern for brownfield react-native apps, but it seems worthwhile locking this down in non-dev builds. ## Changelog [General] [Security] - Avoiding logging root view params outside of dev / debug mode builds Pull Request resolved: https://github.com/facebook/react-native/pull/31522 Test Plan: * build app in release mode on Android and verified I could not see: `Running "my app" with { sensitive: 'thing' }` in logcat in Android Studio with a tethered device Reviewed By: yungsters Differential Revision: D31064902 Pulled By: charlesbdudley fbshipit-source-id: 8b10a46d92a9ec44243dd74384299087260c7d83 --- Libraries/ReactNative/AppRegistry.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Libraries/ReactNative/AppRegistry.js b/Libraries/ReactNative/AppRegistry.js index 93c4447c41..f1ff791dd3 100644 --- a/Libraries/ReactNative/AppRegistry.js +++ b/Libraries/ReactNative/AppRegistry.js @@ -189,8 +189,10 @@ const AppRegistry = { displayMode?: number, ): void { if (appKey !== 'LogBox') { - const msg = - 'Running "' + appKey + '" with ' + JSON.stringify(appParameters); + const logParams = __DEV__ + ? '" with ' + JSON.stringify(appParameters) + : ''; + const msg = 'Running "' + appKey + logParams; infoLog(msg); BugReporting.addSource( 'AppRegistry.runApplication' + runCount++, From 27304fcd0bd9ff8b860f05ec8753bc0dc15c4d54 Mon Sep 17 00:00:00 2001 From: Samuel Susla Date: Thu, 7 Oct 2021 15:21:34 -0700 Subject: [PATCH 22/62] Add error handling to RuntimeScheduler Summary: changelog: [internal] Catch JavaScript errors and forward them to `ErrorUtils` in *RuntimeScheduler*. This makes sure that JS errors are handled by ErrorUtils and do not bubble up to bridge. Reviewed By: philIip Differential Revision: D31429001 fbshipit-source-id: 50f865872e4cd3ba180056099ff40f5962ee7a77 --- .../renderer/runtimescheduler/ErrorUtils.h | 36 ++++++++++ .../runtimescheduler/RuntimeScheduler.cpp | 38 +++++----- .../tests/RuntimeSchedulerTest.cpp | 27 ++++++- .../runtimescheduler/tests/StubErrorUtils.h | 72 +++++++++++++++++++ 4 files changed, 156 insertions(+), 17 deletions(-) create mode 100644 ReactCommon/react/renderer/runtimescheduler/ErrorUtils.h create mode 100644 ReactCommon/react/renderer/runtimescheduler/tests/StubErrorUtils.h diff --git a/ReactCommon/react/renderer/runtimescheduler/ErrorUtils.h b/ReactCommon/react/renderer/runtimescheduler/ErrorUtils.h new file mode 100644 index 0000000000..a6da8b49b8 --- /dev/null +++ b/ReactCommon/react/renderer/runtimescheduler/ErrorUtils.h @@ -0,0 +1,36 @@ +/* + * 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. + */ + +#include + +namespace facebook { +namespace react { + +inline static void handleFatalError( + jsi::Runtime &runtime, + const jsi::JSError &error) { + auto reportFatalError = "reportFatalError"; + auto errorUtils = runtime.global().getProperty(runtime, "ErrorUtils"); + if (errorUtils.isUndefined() || !errorUtils.isObject() || + !errorUtils.getObject(runtime).hasProperty(runtime, reportFatalError)) { + // ErrorUtils was not set up. This probably means the bundle didn't + // load properly. + throw jsi::JSError( + runtime, + "ErrorUtils is not set up properly. Something probably went wrong trying to load the JS bundle. Trying to report error " + + error.getMessage(), + error.getStack()); + } + + auto func = errorUtils.asObject(runtime).getPropertyAsFunction( + runtime, reportFatalError); + + func.call(runtime, error.value()); +} + +} // namespace react +} // namespace facebook diff --git a/ReactCommon/react/renderer/runtimescheduler/RuntimeScheduler.cpp b/ReactCommon/react/renderer/runtimescheduler/RuntimeScheduler.cpp index fd47ab4303..ecf2589ddd 100644 --- a/ReactCommon/react/renderer/runtimescheduler/RuntimeScheduler.cpp +++ b/ReactCommon/react/renderer/runtimescheduler/RuntimeScheduler.cpp @@ -6,6 +6,7 @@ */ #include "RuntimeScheduler.h" +#include "ErrorUtils.h" namespace facebook { namespace react { @@ -89,27 +90,32 @@ void RuntimeScheduler::executeNowOnTheSameThread( void RuntimeScheduler::startWorkLoop(jsi::Runtime &runtime) const { auto previousPriority = currentPriority_; isPerformingWork_ = true; - while (!taskQueue_.empty()) { - auto topPriorityTask = taskQueue_.top(); - auto now = now_(); - auto didUserCallbackTimeout = topPriorityTask->expirationTime <= now; + try { + while (!taskQueue_.empty()) { + auto topPriorityTask = taskQueue_.top(); + auto now = now_(); + auto didUserCallbackTimeout = topPriorityTask->expirationTime <= now; - if (!didUserCallbackTimeout && shouldYield_) { - // This task hasn't expired and we need to yield. - break; - } - currentPriority_ = topPriorityTask->priority; - auto result = topPriorityTask->execute(runtime); + if (!didUserCallbackTimeout && shouldYield_) { + // This task hasn't expired and we need to yield. + break; + } + currentPriority_ = topPriorityTask->priority; + auto result = topPriorityTask->execute(runtime); - if (result.isObject() && result.getObject(runtime).isFunction(runtime)) { - topPriorityTask->callback = - result.getObject(runtime).getFunction(runtime); - } else { - if (taskQueue_.top() == topPriorityTask) { - taskQueue_.pop(); + if (result.isObject() && result.getObject(runtime).isFunction(runtime)) { + topPriorityTask->callback = + result.getObject(runtime).getFunction(runtime); + } else { + if (taskQueue_.top() == topPriorityTask) { + taskQueue_.pop(); + } } } + } catch (jsi::JSError &error) { + handleFatalError(runtime, error); } + currentPriority_ = previousPriority; isPerformingWork_ = false; } diff --git a/ReactCommon/react/renderer/runtimescheduler/tests/RuntimeSchedulerTest.cpp b/ReactCommon/react/renderer/runtimescheduler/tests/RuntimeSchedulerTest.cpp index abb6a96b48..3fade3594e 100644 --- a/ReactCommon/react/renderer/runtimescheduler/tests/RuntimeSchedulerTest.cpp +++ b/ReactCommon/react/renderer/runtimescheduler/tests/RuntimeSchedulerTest.cpp @@ -10,7 +10,9 @@ #include #include #include + #include "StubClock.h" +#include "StubErrorUtils.h" #include "StubQueue.h" namespace facebook::react { @@ -22,6 +24,7 @@ class RuntimeSchedulerTest : public testing::Test { void SetUp() override { hostFunctionCallCount_ = 0; runtime_ = facebook::hermes::makeHermesRuntime(); + stubErrorUtils_ = StubErrorUtils::createAndInstallIfNeeded(*runtime_); stubQueue_ = std::make_unique(); RuntimeExecutor runtimeExecutor = @@ -52,7 +55,7 @@ class RuntimeSchedulerTest : public testing::Test { jsi::Runtime &, jsi::Value const &, jsi::Value const *arguments, - size_t) noexcept -> jsi::Value { + size_t) -> jsi::Value { ++hostFunctionCallCount_; auto didUserCallbackTimeout = arguments[0].getBool(); return callback(didUserCallbackTimeout); @@ -65,6 +68,7 @@ class RuntimeSchedulerTest : public testing::Test { std::unique_ptr stubClock_; std::unique_ptr stubQueue_; std::unique_ptr runtimeScheduler_; + std::shared_ptr stubErrorUtils_; }; TEST_F(RuntimeSchedulerTest, now) { @@ -469,4 +473,25 @@ TEST_F(RuntimeSchedulerTest, scheduleTaskFromTask) { EXPECT_EQ(stubQueue_->size(), 0); } +TEST_F(RuntimeSchedulerTest, handlingError) { + bool didRunTask = false; + auto firstCallback = createHostFunctionFromLambda([this, &didRunTask](bool) { + didRunTask = true; + jsi::detail::throwJSError(*runtime_, "Test error"); + return jsi::Value::undefined(); + }); + + runtimeScheduler_->scheduleTask( + SchedulerPriority::NormalPriority, std::move(firstCallback)); + + EXPECT_FALSE(didRunTask); + EXPECT_EQ(stubQueue_->size(), 1); + + stubQueue_->tick(); + + EXPECT_TRUE(didRunTask); + EXPECT_EQ(stubQueue_->size(), 0); + EXPECT_EQ(stubErrorUtils_->getReportFatalCallCount(), 1); +} + } // namespace facebook::react diff --git a/ReactCommon/react/renderer/runtimescheduler/tests/StubErrorUtils.h b/ReactCommon/react/renderer/runtimescheduler/tests/StubErrorUtils.h new file mode 100644 index 0000000000..ca2de84a0f --- /dev/null +++ b/ReactCommon/react/renderer/runtimescheduler/tests/StubErrorUtils.h @@ -0,0 +1,72 @@ +/* + * 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. + */ + +#pragma once + +#include +#include + +namespace facebook { +namespace react { + +/* + * Exposes StubErrorUtils to JavaScript realm. + */ +class StubErrorUtils : public jsi::HostObject { + public: + static std::shared_ptr createAndInstallIfNeeded( + jsi::Runtime &runtime) { + auto errorUtilsModuleName = "ErrorUtils"; + auto errorUtilsValue = + runtime.global().getProperty(runtime, errorUtilsModuleName); + + if (errorUtilsValue.isUndefined()) { + auto stubErrorUtils = std::make_shared(); + auto object = jsi::Object::createFromHostObject(runtime, stubErrorUtils); + runtime.global().setProperty( + runtime, errorUtilsModuleName, std::move(object)); + return stubErrorUtils; + } + + auto stubErrorUtilsObject = errorUtilsValue.asObject(runtime); + return stubErrorUtilsObject.getHostObject(runtime); + } + + /* + * `jsi::HostObject` specific overloads. + */ + jsi::Value get(jsi::Runtime &runtime, jsi::PropNameID const &name) override { + auto propertyName = name.utf8(runtime); + + if (propertyName == "reportFatalError") { + return jsi::Function::createFromHostFunction( + runtime, + name, + 1, + [this]( + jsi::Runtime &runtime, + jsi::Value const &, + jsi::Value const *arguments, + size_t) noexcept -> jsi::Value { + reportFatalCallCount_++; + return jsi::Value::undefined(); + }); + } + + return jsi::Value::undefined(); + } + + int getReportFatalCallCount() const { + return reportFatalCallCount_; + } + + private: + int reportFatalCallCount_; +}; + +} // namespace react +} // namespace facebook From ec614c16b331bf3f793fda5780fa273d181a8492 Mon Sep 17 00:00:00 2001 From: AntoineDoubovetzky Date: Thu, 7 Oct 2021 22:42:56 -0700 Subject: [PATCH 23/62] Update Modal's mock to not render its children when it is not visible (#32346) Summary: The Modal's mock always render its children (whether it is visible or not), whereas in reality the Modal renders `null` when the Modal is not visible. This causes troubles when trying to test whether the Modal is visible or not. Instead of testing if the children are rendered (using getByText from React Native Testing Library for instance), we are forced to test the value of the visible prop directly (see https://github.com/callstack/react-native-testing-library/issues/508 and https://github.com/callstack/react-native-testing-library/issues/659). This is not ideal because we are forced to test implementation detail and can't test from the user perspective. I also believe the mock should be closest as possible from reality. I had 2 options: 1. Rendering the Modal without its children 2. Not rendering the Modal at all The latter has the advantage of being closer to the reality, but I chose the former to still be able to test the Modal through the visible prop, so there is no breaking change (only snapshots update will be required). ## Changelog [General] [Changed] - Update Modal's mock to not render its children when it is not visible Pull Request resolved: https://github.com/facebook/react-native/pull/32346 Test Plan: I added a test case when visible is false, then updated the mock so the children are not rendered. The before / after is here: ![image](https://user-images.githubusercontent.com/17070498/136256142-a351d002-8b77-490a-ba65-1e8ad0d6eb55.png) Reviewed By: yungsters Differential Revision: D31445964 Pulled By: lunaleaps fbshipit-source-id: 08501921455728cde6befd0103016c95074cc1df --- Libraries/Modal/__tests__/Modal-test.js | 9 ++++++ .../__snapshots__/Modal-test.js.snap | 2 +- jest/mockModal.js | 31 +++++++++++++++++++ jest/setup.js | 8 +++-- 4 files changed, 46 insertions(+), 4 deletions(-) create mode 100644 jest/mockModal.js diff --git a/Libraries/Modal/__tests__/Modal-test.js b/Libraries/Modal/__tests__/Modal-test.js index 33cbb19dd5..7c27e70b20 100644 --- a/Libraries/Modal/__tests__/Modal-test.js +++ b/Libraries/Modal/__tests__/Modal-test.js @@ -27,6 +27,15 @@ describe('', () => { expect(instance).toMatchSnapshot(); }); + it('should not render its children when mocked with visible=false', () => { + const instance = render.create( + + + , + ); + expect(instance.root.findAllByProps({testID: 'child'})).toHaveLength(0); + }); + it('should shallow render as when mocked', () => { const output = render.shallow( diff --git a/Libraries/Modal/__tests__/__snapshots__/Modal-test.js.snap b/Libraries/Modal/__tests__/__snapshots__/Modal-test.js.snap index b8afa44393..2bd414e07c 100644 --- a/Libraries/Modal/__tests__/__snapshots__/Modal-test.js.snap +++ b/Libraries/Modal/__tests__/__snapshots__/Modal-test.js.snap @@ -13,7 +13,7 @@ exports[` should render as when not mocked 1`] = ` { + return ( + + {this.props.visible !== true ? null : this.props.children} + + ); + } + } + return ModalMock; +} + +module.exports = (mockModal: $FlowFixMe); diff --git a/jest/setup.js b/jest/setup.js index 912b5f78dc..778778859d 100644 --- a/jest/setup.js +++ b/jest/setup.js @@ -110,9 +110,11 @@ jest getNativeRef: jest.fn(), }), ) - .mock('../Libraries/Modal/Modal', () => - mockComponent('../Libraries/Modal/Modal'), - ) + .mock('../Libraries/Modal/Modal', () => { + const baseComponent = mockComponent('../Libraries/Modal/Modal'); + const mockModal = jest.requireActual('./mockModal'); + return mockModal(baseComponent); + }) .mock('../Libraries/Components/View/View', () => mockComponent('../Libraries/Components/View/View', MockNativeMethods), ) From a101fc768cedc7ac9754006e5b7292bb7084ab54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rub=C3=A9n=20Norte?= Date: Fri, 8 Oct 2021 07:37:41 -0700 Subject: [PATCH 24/62] Remove unnecessary global variable named GLOBAL Summary: We are defining an alias for the global variable in React Native called `GLOBAL`, which is not used at all at Facebook and it doesn't seem it's used externally either. This alias is not standard nor common in the JS ecosystem, so we can just remove it to reduce the pollution of the global scope. Changelog: [General][Removed] - Removed unnecessary global variable `GLOBAL`. Reviewed By: yungsters Differential Revision: D31472154 fbshipit-source-id: 127c3264848b638f85fb2e39e17ed2006372d2dd --- Libraries/Core/setUpGlobals.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/Libraries/Core/setUpGlobals.js b/Libraries/Core/setUpGlobals.js index a8ce63d132..a571ba52b1 100644 --- a/Libraries/Core/setUpGlobals.js +++ b/Libraries/Core/setUpGlobals.js @@ -14,10 +14,6 @@ * Sets up global variables for React Native. * You can use this module directly, or just require InitializeCore. */ -if (global.GLOBAL === undefined) { - global.GLOBAL = global; -} - if (global.window === undefined) { // $FlowFixMe[cannot-write] global.window = global; From b14b34b232b4873137ea3f3c7a90f86b9013885a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rub=C3=A9n=20Norte?= Date: Fri, 8 Oct 2021 07:37:41 -0700 Subject: [PATCH 25/62] Make runtime initialization from React renderers a no-op Summary: This module is imported by all flavors of the React Native renderers (dev/prod, Fabric/Paper, etc.), which itself imports `InitializeCore`. This is effectively a no-op in most React Native apps because Metro adds it as a module to execute before the entrypoint of the bundle. This import would be harmless if all React Native apps included all polyfills and globals, but some of them don't want to include everything and instead of importing `InitializeCore` they import individual setup functions (like `setupXhr`). Having this automatic import in the renderer defeats that purpose (most importantly for app size), so we should remove it. The main motivation for this change is to increase the number (and spec-compliance) of Web APIs that are supported out of the box without adding that cost to apps that choose not to use some of them (see https://github.com/facebook/react-native/pull/30188#issuecomment-929352747). Changelog: [General][Removed] Breaking: Removed initialization of React Native polyfills and global variables from React renderers. Note: this will only be a breaking change for apps not using the React Native CLI, Expo nor have a Metro configuration that executes `InitializeCore` automatically before the bundle EntryPoint. Reviewed By: yungsters Differential Revision: D31472153 fbshipit-source-id: 92eb113c83f77dbe414869fbce152a22f3617dcb --- .../ReactPrivate/ReactNativePrivateInitializeCore.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Libraries/ReactPrivate/ReactNativePrivateInitializeCore.js b/Libraries/ReactPrivate/ReactNativePrivateInitializeCore.js index e34e6271f2..975e173537 100644 --- a/Libraries/ReactPrivate/ReactNativePrivateInitializeCore.js +++ b/Libraries/ReactPrivate/ReactNativePrivateInitializeCore.js @@ -8,4 +8,13 @@ * @flow strict-local */ -import '../Core/InitializeCore'; +// TODO: Remove this module when the import is removed from the React renderers. + +// This module is used by React to initialize the React Native runtime, +// but it is now a no-op. + +// This is redundant because all React Native apps are already executing +// `InitializeCore` before the entrypoint of the JS bundle +// (see https://github.com/react-native-community/cli/blob/e1da64317a1178c2b262d82c2f14210cdfa3ebe1/packages/cli-plugin-metro/src/tools/loadMetroConfig.ts#L93) +// and importing it unconditionally from React only prevents users from +// customizing what they want to include in their apps (re: app size). From c901c43d11a243e7e4a9389f7e8f1440581ef7d9 Mon Sep 17 00:00:00 2001 From: Lulu Wu Date: Fri, 8 Oct 2021 11:06:46 -0700 Subject: [PATCH 26/62] Remove shared responsibility between LogBox and ExceptionsManager native module Summary: ## Context Right now we are using both LogBox and ExceptionsManager native module to report JS errors in ExceptionsManager.js, from below code we can tell they have some overlapping - when ```__DEV__ === true``` both could report the error. https://www.internalfb.com/code/fbsource/[5fb44bc926de87e62e6e538082496f22017698eb]/xplat/js/react-native-github/Libraries/Core/ExceptionsManager.js?lines=109-141 ## Changes In this diff overlapping is removed: in ```ExceptionsManager.js``` LogBox will be responsible for showing the error with dialog when ```__DEV__ === true```, when it's prod we'll use ExceptionsManager native module to report the error. As a result LogBox and ExceptionsManager native module don't share responsibilities any more. Changelog: [General][Changed] - Remove shared responsibility between LogBox and ExceptionsManager native module Reviewed By: philIip Differential Revision: D30942433 fbshipit-source-id: 8fceaaa431e5a460c0ccd151fe9831dcccbcf237 --- Libraries/Core/ExceptionsManager.js | 125 +++----- Libraries/Core/ExtendedError.js | 1 - .../Core/__tests__/ExceptionsManager-test.js | 286 ++++++++++++++---- Libraries/LogBox/Data/LogBoxData.js | 1 - .../LogBox/Data/__tests__/LogBoxData-test.js | 2 - React/CoreModules/RCTExceptionsManager.mm | 35 +-- .../modules/core/ExceptionsManagerModule.java | 26 +- 7 files changed, 290 insertions(+), 186 deletions(-) diff --git a/Libraries/Core/ExceptionsManager.js b/Libraries/Core/ExceptionsManager.js index d4826d4b54..00caaf92ab 100644 --- a/Libraries/Core/ExceptionsManager.js +++ b/Libraries/Core/ExceptionsManager.js @@ -56,94 +56,57 @@ function reportException( isFatal: boolean, reportToConsole: boolean, // only true when coming from handleException; the error has not yet been logged ) { - const NativeExceptionsManager = require('./NativeExceptionsManager').default; - if (NativeExceptionsManager) { - const parseErrorStack = require('./Devtools/parseErrorStack'); - const stack = parseErrorStack(e?.stack); - const currentExceptionID = ++exceptionID; - const originalMessage = e.message || ''; - let message = originalMessage; - if (e.componentStack != null) { - message += `\n\nThis error is located at:${e.componentStack}`; - } - const namePrefix = e.name == null || e.name === '' ? '' : `${e.name}: `; + const parseErrorStack = require('./Devtools/parseErrorStack'); + const stack = parseErrorStack(e?.stack); + const currentExceptionID = ++exceptionID; + const originalMessage = e.message || ''; + let message = originalMessage; + if (e.componentStack != null) { + message += `\n\nThis error is located at:${e.componentStack}`; + } + const namePrefix = e.name == null || e.name === '' ? '' : `${e.name}: `; - if (!message.startsWith(namePrefix)) { - message = namePrefix + message; - } + if (!message.startsWith(namePrefix)) { + message = namePrefix + message; + } - message = - e.jsEngine == null ? message : `${message}, js engine: ${e.jsEngine}`; + message = + e.jsEngine == null ? message : `${message}, js engine: ${e.jsEngine}`; - const isHandledByLogBox = - e.forceRedbox !== true && - global.RN$Bridgeless !== true && - !global.RN$Express; + const data = preprocessException({ + message, + originalMessage: message === originalMessage ? null : originalMessage, + name: e.name == null || e.name === '' ? null : e.name, + componentStack: + typeof e.componentStack === 'string' ? e.componentStack : null, + stack, + id: currentExceptionID, + isFatal, + extraData: { + jsEngine: e.jsEngine, + rawStack: e.stack, + }, + }); - const data = preprocessException({ - message, - originalMessage: message === originalMessage ? null : originalMessage, - name: e.name == null || e.name === '' ? null : e.name, - componentStack: - typeof e.componentStack === 'string' ? e.componentStack : null, - stack, - id: currentExceptionID, - isFatal, - extraData: { - jsEngine: e.jsEngine, - rawStack: e.stack, - - // Hack to hide native redboxes when in the LogBox experiment. - // This is intentionally untyped and stuffed here, because it is temporary. - suppressRedBox: isHandledByLogBox, - }, - }); - - if (reportToConsole) { - // we feed back into console.error, to make sure any methods that are - // monkey patched on top of console.error are called when coming from - // handleException - console.error(data.message); - } - - if (__DEV__ && isHandledByLogBox) { - const LogBox = require('../LogBox/LogBox'); - LogBox.addException({ - ...data, - isComponentError: !!e.isComponentError, - }); - } - - if (isFatal || e.type !== 'warn') { - NativeExceptionsManager.reportException(data); - - if (__DEV__ && !global.RN$Express) { - if (e.preventSymbolication === true) { - return; - } - const symbolicateStackTrace = require('./Devtools/symbolicateStackTrace'); - symbolicateStackTrace(stack) - .then(({stack: prettyStack}) => { - if (prettyStack) { - NativeExceptionsManager.updateExceptionMessage( - data.message, - prettyStack, - currentExceptionID, - ); - } else { - throw new Error('The stack is null'); - } - }) - .catch(error => { - console.log('Unable to symbolicate stack trace: ' + error.message); - }); - } - } - } else if (reportToConsole) { + if (reportToConsole) { // we feed back into console.error, to make sure any methods that are // monkey patched on top of console.error are called when coming from // handleException - console.error(e); + console.error(data.message); + } + + if (__DEV__) { + const LogBox = require('../LogBox/LogBox'); + LogBox.addException({ + ...data, + isComponentError: !!e.isComponentError, + }); + } else if (isFatal || e.type !== 'warn') { + const NativeExceptionsManager = require('./NativeExceptionsManager') + .default; + if (NativeExceptionsManager) { + NativeExceptionsManager.reportException(data); + } } } diff --git a/Libraries/Core/ExtendedError.js b/Libraries/Core/ExtendedError.js index 88e6331ced..e6b9a65103 100644 --- a/Libraries/Core/ExtendedError.js +++ b/Libraries/Core/ExtendedError.js @@ -12,7 +12,6 @@ export type ExtendedError = Error & { jsEngine?: string, preventSymbolication?: boolean, componentStack?: string, - forceRedbox?: boolean, isComponentError?: boolean, type?: string, ... diff --git a/Libraries/Core/__tests__/ExceptionsManager-test.js b/Libraries/Core/__tests__/ExceptionsManager-test.js index ffd3be593e..d85927d123 100644 --- a/Libraries/Core/__tests__/ExceptionsManager-test.js +++ b/Libraries/Core/__tests__/ExceptionsManager-test.js @@ -12,6 +12,7 @@ const ExceptionsManager = require('../ExceptionsManager'); const NativeExceptionsManager = require('../NativeExceptionsManager').default; +const LogBox = require('../../LogBox/LogBox'); const ReactFiberErrorDialog = require('../ReactFiberErrorDialog').default; const fs = require('fs'); const path = require('path'); @@ -27,9 +28,13 @@ const capturedErrorDefaults = { describe('ExceptionsManager', () => { let nativeReportException; + let logBoxAddException; beforeEach(() => { jest.resetModules(); + jest.mock('../../LogBox/LogBox', () => ({ + addException: jest.fn(), + })); jest.mock('../NativeExceptionsManager', () => { return { default: { @@ -49,6 +54,7 @@ describe('ExceptionsManager', () => { ); jest.spyOn(console, 'error').mockReturnValue(undefined); nativeReportException = NativeExceptionsManager.reportException; + logBoxAddException = LogBox.addException; }); afterEach(() => { @@ -66,6 +72,11 @@ describe('ExceptionsManager', () => { error, }); + if (__DEV__) { + expect(nativeReportException.mock.calls.length).toBe(0); + expect(logBoxAddException.mock.calls.length).toBe(1); + return; + } expect(nativeReportException.mock.calls.length).toBe(1); const exceptionData = nativeReportException.mock.calls[0][0]; const formattedMessage = @@ -101,8 +112,15 @@ describe('ExceptionsManager', () => { error, }); - expect(nativeReportException.mock.calls.length).toBe(1); - const exceptionData = nativeReportException.mock.calls[0][0]; + let exceptionData; + + if (__DEV__) { + expect(logBoxAddException.mock.calls.length).toBe(1); + exceptionData = logBoxAddException.mock.calls[0][0]; + } else { + expect(nativeReportException.mock.calls.length).toBe(1); + exceptionData = nativeReportException.mock.calls[0][0]; + } expect(getLineFromFrame(exceptionData.stack[0])).toBe( "const error = new Error('Some error happened');", ); @@ -119,8 +137,15 @@ describe('ExceptionsManager', () => { error, }); - expect(nativeReportException.mock.calls.length).toBe(1); - const exceptionData = nativeReportException.mock.calls[0][0]; + let exceptionData; + + if (__DEV__) { + expect(logBoxAddException.mock.calls.length).toBe(1); + exceptionData = logBoxAddException.mock.calls[0][0]; + } else { + expect(nativeReportException.mock.calls.length).toBe(1); + exceptionData = nativeReportException.mock.calls[0][0]; + } expect(exceptionData.message).toBe( 'Error: ' + message + @@ -149,8 +174,15 @@ describe('ExceptionsManager', () => { error: message, }); - expect(nativeReportException.mock.calls.length).toBe(1); - const exceptionData = nativeReportException.mock.calls[0][0]; + let exceptionData; + + if (__DEV__) { + expect(logBoxAddException.mock.calls.length).toBe(1); + exceptionData = logBoxAddException.mock.calls[0][0]; + } else { + expect(nativeReportException.mock.calls.length).toBe(1); + exceptionData = nativeReportException.mock.calls[0][0]; + } const formattedMessage = message + '\n\n' + @@ -173,8 +205,15 @@ describe('ExceptionsManager', () => { error: null, }); - expect(nativeReportException.mock.calls.length).toBe(1); - const exceptionData = nativeReportException.mock.calls[0][0]; + let exceptionData; + + if (__DEV__) { + expect(logBoxAddException.mock.calls.length).toBe(1); + exceptionData = logBoxAddException.mock.calls[0][0]; + } else { + expect(nativeReportException.mock.calls.length).toBe(1); + exceptionData = nativeReportException.mock.calls[0][0]; + } const formattedMessage = 'Unspecified error' + '\n\n' + @@ -200,8 +239,15 @@ describe('ExceptionsManager', () => { error, }); - expect(nativeReportException.mock.calls.length).toBe(1); - const exceptionData = nativeReportException.mock.calls[0][0]; + let exceptionData; + + if (__DEV__) { + expect(logBoxAddException.mock.calls.length).toBe(1); + exceptionData = logBoxAddException.mock.calls[0][0]; + } else { + expect(nativeReportException.mock.calls.length).toBe(1); + exceptionData = nativeReportException.mock.calls[0][0]; + } expect(getLineFromFrame(exceptionData.stack[0])).toBe( "const error = Object.freeze(new Error('Some error happened'));", ); @@ -216,8 +262,12 @@ describe('ExceptionsManager', () => { error, }); - expect(nativeReportException).toHaveBeenCalled(); - expect(error.message).toBe(message); + if (__DEV__) { + expect(logBoxAddException).toHaveBeenCalled(); + } else { + expect(nativeReportException).toHaveBeenCalled(); + expect(error.message).toBe(message); + } }); test('can safely process the same error multiple times', () => { @@ -230,6 +280,7 @@ describe('ExceptionsManager', () => { ]; for (const componentStack of componentStacks) { nativeReportException.mockClear(); + logBoxAddException.mockClear(); const formattedMessage = 'ReferenceError: ' + message + @@ -242,8 +293,15 @@ describe('ExceptionsManager', () => { error, }); - expect(nativeReportException.mock.calls.length).toBe(1); - const exceptionData = nativeReportException.mock.calls[0][0]; + let exceptionData; + + if (__DEV__) { + expect(logBoxAddException.mock.calls.length).toBe(1); + exceptionData = logBoxAddException.mock.calls[0][0]; + } else { + expect(nativeReportException.mock.calls.length).toBe(1); + exceptionData = nativeReportException.mock.calls[0][0]; + } expect(exceptionData.message).toBe(formattedMessage); expect(exceptionData.originalMessage).toBe(message); expect(exceptionData.componentStack).toBe(componentStack); @@ -281,8 +339,15 @@ describe('ExceptionsManager', () => { console.error(error); - expect(nativeReportException.mock.calls.length).toBe(1); - const exceptionData = nativeReportException.mock.calls[0][0]; + let exceptionData; + + if (__DEV__) { + expect(logBoxAddException.mock.calls.length).toBe(1); + exceptionData = logBoxAddException.mock.calls[0][0]; + } else { + expect(nativeReportException.mock.calls.length).toBe(1); + exceptionData = nativeReportException.mock.calls[0][0]; + } const formattedMessage = 'Error: ' + message; expect(exceptionData.message).toBe(formattedMessage); expect(exceptionData.originalMessage).toBe(message); @@ -301,8 +366,15 @@ describe('ExceptionsManager', () => { console.error(message); - expect(nativeReportException.mock.calls.length).toBe(1); - const exceptionData = nativeReportException.mock.calls[0][0]; + let exceptionData; + + if (__DEV__) { + expect(logBoxAddException.mock.calls.length).toBe(1); + exceptionData = logBoxAddException.mock.calls[0][0]; + } else { + expect(nativeReportException.mock.calls.length).toBe(1); + exceptionData = nativeReportException.mock.calls[0][0]; + } expect(exceptionData.message).toBe('console.error: Some error happened'); expect(exceptionData.originalMessage).toBe('Some error happened'); expect(exceptionData.name).toBe('console.error'); @@ -318,8 +390,15 @@ describe('ExceptionsManager', () => { console.error(...args); - expect(nativeReportException.mock.calls.length).toBe(1); - const exceptionData = nativeReportException.mock.calls[0][0]; + let exceptionData; + + if (__DEV__) { + expect(logBoxAddException.mock.calls.length).toBe(1); + exceptionData = logBoxAddException.mock.calls[0][0]; + } else { + expect(nativeReportException.mock.calls.length).toBe(1); + exceptionData = nativeReportException.mock.calls[0][0]; + } expect(exceptionData.message).toBe( 'console.error: 42 true ["symbol" failed to stringify] {"y":null}', ); @@ -367,7 +446,11 @@ describe('ExceptionsManager', () => { console.error(...args); - expect(nativeReportException).toHaveBeenCalled(); + if (__DEV__) { + expect(logBoxAddException).toHaveBeenCalled(); + } else { + expect(nativeReportException).toHaveBeenCalled(); + } }); test('does not log "warn"-type errors', () => { @@ -399,8 +482,15 @@ describe('ExceptionsManager', () => { console.error(error); - expect(nativeReportException.mock.calls.length).toBe(1); - const exceptionData = nativeReportException.mock.calls[0][0]; + let exceptionData; + + if (__DEV__) { + expect(logBoxAddException.mock.calls.length).toBe(1); + exceptionData = logBoxAddException.mock.calls[0][0]; + } else { + expect(nativeReportException.mock.calls.length).toBe(1); + exceptionData = nativeReportException.mock.calls[0][0]; + } expect(getLineFromFrame(exceptionData.stack[0])).toBe( "const error = new Error('Some error happened');", ); @@ -414,8 +504,15 @@ describe('ExceptionsManager', () => { ExceptionsManager.handleException(error, true); - expect(nativeReportException.mock.calls.length).toBe(1); - const exceptionData = nativeReportException.mock.calls[0][0]; + let exceptionData; + + if (__DEV__) { + expect(logBoxAddException.mock.calls.length).toBe(1); + exceptionData = logBoxAddException.mock.calls[0][0]; + } else { + expect(nativeReportException.mock.calls.length).toBe(1); + exceptionData = nativeReportException.mock.calls[0][0]; + } const formattedMessage = 'Error: ' + message; expect(exceptionData.message).toBe(formattedMessage); expect(exceptionData.originalMessage).toBe(message); @@ -434,8 +531,15 @@ describe('ExceptionsManager', () => { ExceptionsManager.handleException(error, false); - expect(nativeReportException.mock.calls.length).toBe(1); - const exceptionData = nativeReportException.mock.calls[0][0]; + let exceptionData; + + if (__DEV__) { + expect(logBoxAddException.mock.calls.length).toBe(1); + exceptionData = logBoxAddException.mock.calls[0][0]; + } else { + expect(nativeReportException.mock.calls.length).toBe(1); + exceptionData = nativeReportException.mock.calls[0][0]; + } const formattedMessage = 'Error: ' + message; expect(exceptionData.message).toBe(formattedMessage); expect(exceptionData.originalMessage).toBe(message); @@ -453,8 +557,15 @@ describe('ExceptionsManager', () => { ExceptionsManager.handleException(message, true); - expect(nativeReportException.mock.calls.length).toBe(1); - const exceptionData = nativeReportException.mock.calls[0][0]; + let exceptionData; + + if (__DEV__) { + expect(logBoxAddException.mock.calls.length).toBe(1); + exceptionData = logBoxAddException.mock.calls[0][0]; + } else { + expect(nativeReportException.mock.calls.length).toBe(1); + exceptionData = nativeReportException.mock.calls[0][0]; + } expect(exceptionData.message).toBe(message); expect(exceptionData.originalMessage).toBe(null); expect(exceptionData.name).toBe(null); @@ -473,8 +584,15 @@ describe('ExceptionsManager', () => { ExceptionsManager.handleException(error, true); - expect(nativeReportException.mock.calls.length).toBe(1); - const exceptionData = nativeReportException.mock.calls[0][0]; + let exceptionData; + + if (__DEV__) { + expect(logBoxAddException.mock.calls.length).toBe(1); + exceptionData = logBoxAddException.mock.calls[0][0]; + } else { + expect(nativeReportException.mock.calls.length).toBe(1); + exceptionData = nativeReportException.mock.calls[0][0]; + } expect(getLineFromFrame(exceptionData.stack[0])).toBe( "const error = new Error('Some error happened');", ); @@ -486,7 +604,11 @@ describe('ExceptionsManager', () => { ExceptionsManager.handleException(error, true); - expect(nativeReportException).toHaveBeenCalled(); + if (__DEV__) { + expect(logBoxAddException).toHaveBeenCalled(); + } else { + expect(nativeReportException).toHaveBeenCalled(); + } }); }); @@ -520,19 +642,30 @@ describe('ExceptionsManager', () => { ExceptionsManager.unstable_setExceptionDecorator(decorator); ExceptionsManager.handleException(error, true); - expect(nativeReportException.mock.calls.length).toBe(2); expect(decorator.mock.calls.length).toBe(1); - - const withoutDecoratorInstalled = nativeReportException.mock.calls[0][0]; - const afterDecorator = nativeReportException.mock.calls[1][0]; const beforeDecorator = decorator.mock.calls[0][0]; + let withoutDecoratorInstalled; + let afterDecorator; + + if (__DEV__) { + expect(logBoxAddException.mock.calls.length).toBe(2); + withoutDecoratorInstalled = logBoxAddException.mock.calls[0][0]; + afterDecorator = logBoxAddException.mock.calls[1][0]; + } else { + expect(nativeReportException.mock.calls.length).toBe(2); + withoutDecoratorInstalled = nativeReportException.mock.calls[0][0]; + afterDecorator = nativeReportException.mock.calls[1][0]; + } + expect(afterDecorator.id).toEqual(beforeDecorator.id); // id will change between successive exceptions delete withoutDecoratorInstalled.id; delete beforeDecorator.id; delete afterDecorator.id; + delete withoutDecoratorInstalled.isComponentError; + delete afterDecorator.isComponentError; expect(withoutDecoratorInstalled).toEqual(beforeDecorator); expect(afterDecorator).toEqual({ @@ -553,7 +686,11 @@ describe('ExceptionsManager', () => { ExceptionsManager.handleException(error, true); expect(decorator).not.toHaveBeenCalled(); - expect(nativeReportException).toHaveBeenCalled(); + if (__DEV__) { + expect(logBoxAddException).toHaveBeenCalled(); + } else { + expect(nativeReportException).toHaveBeenCalled(); + } }); test('prevents decorator recursion from error handler', () => { @@ -569,10 +706,17 @@ describe('ExceptionsManager', () => { ExceptionsManager.unstable_setExceptionDecorator(decorator); ExceptionsManager.handleException(error, true); - expect(nativeReportException).toHaveBeenCalledTimes(1); - expect(nativeReportException.mock.calls[0][0].message).toMatch( - /decorated: .*Some error happened/, - ); + if (__DEV__) { + expect(logBoxAddException).toHaveBeenCalledTimes(1); + expect(logBoxAddException.mock.calls[0][0].message).toMatch( + /decorated: .*Some error happened/, + ); + } else { + expect(nativeReportException).toHaveBeenCalledTimes(1); + expect(nativeReportException.mock.calls[0][0].message).toMatch( + /decorated: .*Some error happened/, + ); + } expect(mockError).toHaveBeenCalledTimes(2); expect(mockError.mock.calls[0][0]).toMatch( /Logging an error within the decorator/, @@ -595,13 +739,23 @@ describe('ExceptionsManager', () => { ExceptionsManager.unstable_setExceptionDecorator(decorator); console.error(error); - expect(nativeReportException).toHaveBeenCalledTimes(2); - expect(nativeReportException.mock.calls[0][0].message).toMatch( - /Logging an error within the decorator/, - ); - expect(nativeReportException.mock.calls[1][0].message).toMatch( - /decorated: .*Some error happened/, - ); + if (__DEV__) { + expect(logBoxAddException).toHaveBeenCalledTimes(2); + expect(logBoxAddException.mock.calls[0][0].message).toMatch( + /Logging an error within the decorator/, + ); + expect(logBoxAddException.mock.calls[1][0].message).toMatch( + /decorated: .*Some error happened/, + ); + } else { + expect(nativeReportException).toHaveBeenCalledTimes(2); + expect(nativeReportException.mock.calls[0][0].message).toMatch( + /Logging an error within the decorator/, + ); + expect(nativeReportException.mock.calls[1][0].message).toMatch( + /decorated: .*Some error happened/, + ); + } expect(mockError).toHaveBeenCalledTimes(2); // console.error calls are chained without exception pre-processing, so decorator doesn't apply expect(mockError.mock.calls[0][0].toString()).toMatch( @@ -621,11 +775,19 @@ describe('ExceptionsManager', () => { ExceptionsManager.unstable_setExceptionDecorator(decorator); ExceptionsManager.handleException(error, true); - expect(nativeReportException).toHaveBeenCalledTimes(1); - // Exceptions in decorators are ignored and the decorator is not applied - expect(nativeReportException.mock.calls[0][0].message).toMatch( - /Error: Some error happened/, - ); + if (__DEV__) { + expect(logBoxAddException).toHaveBeenCalledTimes(1); + // Exceptions in decorators are ignored and the decorator is not applied + expect(logBoxAddException.mock.calls[0][0].message).toMatch( + /Error: Some error happened/, + ); + } else { + expect(nativeReportException).toHaveBeenCalledTimes(1); + // Exceptions in decorators are ignored and the decorator is not applied + expect(nativeReportException.mock.calls[0][0].message).toMatch( + /Error: Some error happened/, + ); + } expect(mockError).toHaveBeenCalledTimes(1); expect(mockError.mock.calls[0][0]).toMatch(/Error: Some error happened/); }); @@ -639,11 +801,19 @@ describe('ExceptionsManager', () => { ExceptionsManager.unstable_setExceptionDecorator(decorator); console.error(error); - expect(nativeReportException).toHaveBeenCalledTimes(1); - // Exceptions in decorators are ignored and the decorator is not applied - expect(nativeReportException.mock.calls[0][0].message).toMatch( - /Error: Some error happened/, - ); + if (__DEV__) { + expect(logBoxAddException).toHaveBeenCalledTimes(1); + // Exceptions in decorators are ignored and the decorator is not applied + expect(logBoxAddException.mock.calls[0][0].message).toMatch( + /Error: Some error happened/, + ); + } else { + expect(nativeReportException).toHaveBeenCalledTimes(1); + // Exceptions in decorators are ignored and the decorator is not applied + expect(nativeReportException.mock.calls[0][0].message).toMatch( + /Error: Some error happened/, + ); + } expect(mockError).toHaveBeenCalledTimes(1); expect(mockError.mock.calls[0][0].toString()).toMatch( /Error: Some error happened/, diff --git a/Libraries/LogBox/Data/LogBoxData.js b/Libraries/LogBox/Data/LogBoxData.js index 55d8dd4165..1c2f842602 100644 --- a/Libraries/LogBox/Data/LogBoxData.js +++ b/Libraries/LogBox/Data/LogBoxData.js @@ -100,7 +100,6 @@ export function reportLogBoxError( ): void { const ExceptionsManager = require('../../Core/ExceptionsManager'); - error.forceRedbox = true; error.message = `${LOGBOX_ERROR_MESSAGE}\n\n${error.message}`; if (componentStack != null) { error.componentStack = componentStack; diff --git a/Libraries/LogBox/Data/__tests__/LogBoxData-test.js b/Libraries/LogBox/Data/__tests__/LogBoxData-test.js index 5e4225e946..556aef41c7 100644 --- a/Libraries/LogBox/Data/__tests__/LogBoxData-test.js +++ b/Libraries/LogBox/Data/__tests__/LogBoxData-test.js @@ -676,7 +676,6 @@ describe('LogBoxData', () => { const receivedError = ExceptionsManager.handleException.mock.calls[0][0]; expect(receivedError.componentStack).toBe(' in Component (file.js:1)'); - expect(receivedError.forceRedbox).toBe(true); expect(receivedError.message).toBe( 'An error was thrown when attempting to render log messages via LogBox.\n\nSimulated Error', ); @@ -689,7 +688,6 @@ describe('LogBoxData', () => { const receivedError = ExceptionsManager.handleException.mock.calls[0][0]; expect(receivedError.componentStack).toBeUndefined(); - expect(receivedError.forceRedbox).toBe(true); expect(receivedError.message).toBe( 'An error was thrown when attempting to render log messages via LogBox.\n\nSimulated Error', ); diff --git a/React/CoreModules/RCTExceptionsManager.mm b/React/CoreModules/RCTExceptionsManager.mm index 175c5612cf..749e3914eb 100644 --- a/React/CoreModules/RCTExceptionsManager.mm +++ b/React/CoreModules/RCTExceptionsManager.mm @@ -35,15 +35,10 @@ RCT_EXPORT_MODULE() return self; } -- (void)reportSoft:(NSString *)message - stack:(NSArray *)stack - exceptionId:(double)exceptionId - suppressRedBox:(BOOL)suppressRedBox +- (void)reportSoft:(NSString *)message stack:(NSArray *)stack exceptionId:(double)exceptionId { - if (!suppressRedBox) { - RCTRedBox *redbox = [_moduleRegistry moduleForName:"RedBox"]; - [redbox showErrorMessage:message withStack:stack errorCookie:(int)exceptionId]; - } + RCTRedBox *redbox = [_moduleRegistry moduleForName:"RedBox"]; + [redbox showErrorMessage:message withStack:stack errorCookie:(int)exceptionId]; if (_delegate) { [_delegate handleSoftJSExceptionWithMessage:message @@ -52,15 +47,10 @@ RCT_EXPORT_MODULE() } } -- (void)reportFatal:(NSString *)message - stack:(NSArray *)stack - exceptionId:(double)exceptionId - suppressRedBox:(BOOL)suppressRedBox +- (void)reportFatal:(NSString *)message stack:(NSArray *)stack exceptionId:(double)exceptionId { - if (!suppressRedBox) { - RCTRedBox *redbox = [_moduleRegistry moduleForName:"RedBox"]; - [redbox showErrorMessage:message withStack:stack errorCookie:(int)exceptionId]; - } + RCTRedBox *redbox = [_moduleRegistry moduleForName:"RedBox"]; + [redbox showErrorMessage:message withStack:stack errorCookie:(int)exceptionId]; if (_delegate) { [_delegate handleFatalJSExceptionWithMessage:message @@ -72,7 +62,7 @@ RCT_EXPORT_MODULE() if (!RCT_DEBUG && reloadRetries < _maxReloadAttempts) { reloadRetries++; RCTTriggerReloadCommandListeners(@"JS Crash Reload"); - } else if (!RCT_DEV || !suppressRedBox) { + } else if (!RCT_DEV) { NSString *description = [@"Unhandled JS Exception: " stringByAppendingString:message]; NSDictionary *errorInfo = @{NSLocalizedDescriptionKey : description, RCTJSStackTraceKey : stack}; RCTFatal([NSError errorWithDomain:RCTErrorDomain code:0 userInfo:errorInfo]); @@ -84,7 +74,7 @@ RCT_EXPORT_METHOD(reportSoftException : (NSArray *)stack exceptionId : (double)exceptionId) { - [self reportSoft:message stack:stack exceptionId:exceptionId suppressRedBox:NO]; + [self reportSoft:message stack:stack exceptionId:exceptionId]; } RCT_EXPORT_METHOD(reportFatalException @@ -92,7 +82,7 @@ RCT_EXPORT_METHOD(reportFatalException : (NSArray *)stack exceptionId : (double)exceptionId) { - [self reportFatal:message stack:stack exceptionId:exceptionId suppressRedBox:NO]; + [self reportFatal:message stack:stack exceptionId:exceptionId]; } RCT_EXPORT_METHOD(updateExceptionMessage @@ -120,7 +110,6 @@ RCT_EXPORT_METHOD(reportException : (JS::NativeExceptionsManager::ExceptionData { NSString *message = data.message(); double exceptionId = data.id_(); - id extraData = data.extraData(); // Reserialize data.stack() into an array of untyped dictionaries. // TODO: (moti) T53588496 Replace `(NSArray *)stack` in @@ -141,13 +130,11 @@ RCT_EXPORT_METHOD(reportException : (JS::NativeExceptionsManager::ExceptionData } [stackArray addObject:frameDict]; } - NSDictionary *dict = (NSDictionary *)extraData; - BOOL suppressRedBox = [[dict objectForKey:@"suppressRedBox"] boolValue]; if (data.isFatal()) { - [self reportFatal:message stack:stackArray exceptionId:exceptionId suppressRedBox:suppressRedBox]; + [self reportFatal:message stack:stackArray exceptionId:exceptionId]; } else { - [self reportSoft:message stack:stackArray exceptionId:exceptionId suppressRedBox:suppressRedBox]; + [self reportSoft:message stack:stackArray exceptionId:exceptionId]; } } diff --git a/ReactAndroid/src/main/java/com/facebook/react/modules/core/ExceptionsManagerModule.java b/ReactAndroid/src/main/java/com/facebook/react/modules/core/ExceptionsManagerModule.java index 265ecf88be..bb5e4be1b1 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/modules/core/ExceptionsManagerModule.java +++ b/ReactAndroid/src/main/java/com/facebook/react/modules/core/ExceptionsManagerModule.java @@ -65,28 +65,16 @@ public class ExceptionsManagerModule extends NativeExceptionsManagerSpec { public void reportException(ReadableMap data) { String message = data.hasKey("message") ? data.getString("message") : ""; ReadableArray stack = data.hasKey("stack") ? data.getArray("stack") : Arguments.createArray(); - int id = data.hasKey("id") ? data.getInt("id") : -1; boolean isFatal = data.hasKey("isFatal") ? data.getBoolean("isFatal") : false; - if (mDevSupportManager.getDevSupportEnabled()) { - boolean suppressRedBox = false; - if (data.getMap("extraData") != null && data.getMap("extraData").hasKey("suppressRedBox")) { - suppressRedBox = data.getMap("extraData").getBoolean("suppressRedBox"); - } - - if (!suppressRedBox) { - mDevSupportManager.showNewJSError(message, stack, id); - } + String extraDataAsJson = ExceptionDataHelper.getExtraDataAsJson(data); + if (isFatal) { + throw new JavascriptException(JSStackTrace.format(message, stack)) + .setExtraDataAsJson(extraDataAsJson); } else { - String extraDataAsJson = ExceptionDataHelper.getExtraDataAsJson(data); - if (isFatal) { - throw new JavascriptException(JSStackTrace.format(message, stack)) - .setExtraDataAsJson(extraDataAsJson); - } else { - FLog.e(ReactConstants.TAG, JSStackTrace.format(message, stack)); - if (extraDataAsJson != null) { - FLog.d(ReactConstants.TAG, "extraData: %s", extraDataAsJson); - } + FLog.e(ReactConstants.TAG, JSStackTrace.format(message, stack)); + if (extraDataAsJson != null) { + FLog.d(ReactConstants.TAG, "extraData: %s", extraDataAsJson); } } } From c99a0212a0abaeb47721b08f3ae50fffb4601e12 Mon Sep 17 00:00:00 2001 From: Samuel Susla Date: Fri, 8 Oct 2021 13:43:16 -0700 Subject: [PATCH 27/62] Fix failing assert in EventTarget Summary: changelog: [internal] calling `setEnabled(true)` needs to have a matching `setEnabled(false)` in order for `eventTarget_` to be deallocated correctly. Also, retaining `eventTarget_` longer, does not mean instanceHandle will be available later on. Reviewed By: p-sun Differential Revision: D31503119 fbshipit-source-id: 324e16fe0f6ad937ab2c38be9a536bdf14851172 --- .../ComponentViews/Modal/RCTModalHostViewComponentView.mm | 3 --- 1 file changed, 3 deletions(-) diff --git a/React/Fabric/Mounting/ComponentViews/Modal/RCTModalHostViewComponentView.mm b/React/Fabric/Mounting/ComponentViews/Modal/RCTModalHostViewComponentView.mm index 16ae9beeec..5d2b1d347c 100644 --- a/React/Fabric/Mounting/ComponentViews/Modal/RCTModalHostViewComponentView.mm +++ b/React/Fabric/Mounting/ComponentViews/Modal/RCTModalHostViewComponentView.mm @@ -156,9 +156,6 @@ static ModalHostViewEventEmitter::OnOrientationChange onOrientationChangeStruct( auto eventEmitter = [self modalEventEmitter]; if (eventEmitter) { eventEmitter->onShow(ModalHostViewEventEmitter::OnShow{}); - - // A hack so that EventEmitter.cpp's eventTarget_ does not become null when modal is dismissed - eventEmitter->setEnabled(true); } }]; } From aae93553d0bbfee3baf340ba0b68e88328b97319 Mon Sep 17 00:00:00 2001 From: Neil Dhar Date: Fri, 8 Oct 2021 14:14:49 -0700 Subject: [PATCH 28/62] Remove libstdc++ dependency (#32247) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/32247 I don't think we need both libc++ and libstdc++. allow-large-files Changelog: [Internal] Reviewed By: fkgozali Differential Revision: D30950943 fbshipit-source-id: d0669815ff59c3e9ac45954a4a11930d1bc3959f --- React-Core.podspec | 1 - React/React-RCTFabric.podspec | 1 - ReactCommon/React-Fabric.podspec | 1 - .../react/renderer/graphics/React-graphics.podspec | 1 - packages/rn-tester/Podfile.lock | 12 ++++++------ .../rn-tester/RNTesterPods.xcodeproj/project.pbxproj | 2 -- third-party-podspecs/RCT-Folly.podspec | 2 +- third-party-podspecs/glog.podspec | 1 - 8 files changed, 7 insertions(+), 14 deletions(-) diff --git a/React-Core.podspec b/React-Core.podspec index a44fbe2632..cd9af69910 100644 --- a/React-Core.podspec +++ b/React-Core.podspec @@ -47,7 +47,6 @@ Pod::Spec.new do |s| s.compiler_flags = folly_compiler_flags + ' ' + boost_compiler_flags s.header_dir = "React" s.framework = "JavaScriptCore" - s.library = "stdc++" s.pod_target_xcconfig = { "HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)/ReactCommon\" \"$(PODS_ROOT)/boost\" \"$(PODS_ROOT)/DoubleConversion\" \"$(PODS_ROOT)/RCT-Folly\" \"${PODS_ROOT}/Headers/Public/React-hermes\" \"${PODS_ROOT}/Headers/Public/hermes-engine\"", "DEFINES_MODULE" => "YES" } s.user_target_xcconfig = { "HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/Headers/Private/React-Core\""} s.default_subspec = "Default" diff --git a/React/React-RCTFabric.podspec b/React/React-RCTFabric.podspec index 6f64a5b7d5..21352e308a 100644 --- a/React/React-RCTFabric.podspec +++ b/React/React-RCTFabric.podspec @@ -36,7 +36,6 @@ Pod::Spec.new do |s| s.compiler_flags = folly_compiler_flags + ' ' + boost_compiler_flags s.header_dir = "React" s.framework = "JavaScriptCore" - s.library = "stdc++" s.pod_target_xcconfig = { "HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)/ReactCommon\" \"$(PODS_ROOT)/boost\" \"$(PODS_ROOT)/DoubleConversion\" \"$(PODS_ROOT)/RCT-Folly\" \"$(PODS_ROOT)/Headers/Private/React-Core\"" } s.xcconfig = { "HEADER_SEARCH_PATHS" => "\"$(PODS_ROOT)/boost\" \"$(PODS_ROOT)/glog\" \"$(PODS_ROOT)/RCT-Folly\"", "OTHER_CFLAGS" => "$(inherited) -DRN_FABRIC_ENABLED" + " " + folly_flags } diff --git a/ReactCommon/React-Fabric.podspec b/ReactCommon/React-Fabric.podspec index 085480d50c..742040c57d 100644 --- a/ReactCommon/React-Fabric.podspec +++ b/ReactCommon/React-Fabric.podspec @@ -32,7 +32,6 @@ Pod::Spec.new do |s| s.platforms = { :ios => "11.0" } s.source = source s.source_files = "dummyFile.cpp" - s.library = "stdc++" s.pod_target_xcconfig = { "USE_HEADERMAP" => "YES", "CLANG_CXX_LANGUAGE_STANDARD" => "c++17" } diff --git a/ReactCommon/react/renderer/graphics/React-graphics.podspec b/ReactCommon/react/renderer/graphics/React-graphics.podspec index 00ea874350..bb49136238 100644 --- a/ReactCommon/react/renderer/graphics/React-graphics.podspec +++ b/ReactCommon/react/renderer/graphics/React-graphics.podspec @@ -29,7 +29,6 @@ Pod::Spec.new do |s| s.author = "Facebook, Inc. and its affiliates" s.platforms = { :ios => "11.0", :tvos => "11.0" } s.source = source - s.library = "stdc++" s.compiler_flags = folly_compiler_flags + ' ' + boost_compiler_flags s.source_files = "**/*.{m,mm,cpp,h}" s.exclude_files = "tests", diff --git a/packages/rn-tester/Podfile.lock b/packages/rn-tester/Podfile.lock index 89f7b072ff..afdcd457dd 100644 --- a/packages/rn-tester/Podfile.lock +++ b/packages/rn-tester/Podfile.lock @@ -883,19 +883,19 @@ SPEC CHECKSUMS: Flipper-RSocket: d9d9ade67cbecf6ac10730304bf5607266dd2541 FlipperKit: d8d346844eca5d9120c17d441a2f38596e8ed2b9 fmt: ff9d55029c625d3757ed641535fd4a75fedc7ce9 - glog: 837f9f3924abd268645a4d5b95736ab91c619fb1 + glog: 85ecdd10ee8d8ec362ef519a6a45ff9aa27b2e85 libevent: 4049cae6c81cdb3654a443be001fb9bdceff7913 OpenSSL-Universal: 1aa4f6a6ee7256b83db99ec1ccdaa80d10f9af9b - RCT-Folly: a21c126816d8025b547704b777a2ba552f3d9fa9 + RCT-Folly: 803a9cfd78114b2ec0f140cfa6fa2a6bafb2d685 RCTRequired: af2d6080a4b9ba0885b28ca78879a92066c71cab RCTTypeSafety: c7a7f67ae5b1b986b78d817baa408fc984ab7c0c React: f64c9f6db5428717922a3292ba6a448615a2e143 React-callinvoker: c5d61e29df57793f0dc10ec2bc01c846f863e51f - React-Core: f4cd5c72f7f1bf021ed386d3d6c1a89b5c59cfb1 + React-Core: 22bc86b79dd931dbfb7fd2af91a35a98d41ceb64 React-CoreModules: 1a96917a9a5fd73a989b462ed4dee742fb92332f React-cxxreact: cfc1663dae1ea52b465bbf021ef7b1527c5dc80c - React-Fabric: d49c26d5d651292c48dfcf0f0d78bb2e16f326a3 - React-graphics: b52a1478e052dca3a9f1e8f894f4399988d67508 + React-Fabric: 1489d7b89f472f291b950a483c905ca5443eb288 + React-graphics: 9a84942b49ea1375ce83844041fa2ba766cfe0b9 React-jsi: c1c0108d86e1378aabf7c9146ed7d12d87c7df85 React-jsiexecutor: d08ec14edc8f2e19af51550cd1505332eae35c7b React-jsinspector: 7d223826b0e7a61b3540c21b9eca2603b1d4e823 @@ -904,7 +904,7 @@ SPEC CHECKSUMS: React-RCTActionSheet: 3131a0b9280aa0e51bdf54b3d79aecd8503db62c React-RCTAnimation: 5b2a86f9b5dc9683bfcf6315c58d04e93da57fd7 React-RCTBlob: d417f5814b38d91c8e7a1f667aef7d36c6c789de - React-RCTFabric: b39da03f4147bfa1f0223ffd3c8c2de97185de04 + React-RCTFabric: 921f6d8ae5211e1c0bd31d426487118a61502c8b React-RCTImage: 1717771340c6319ed49a529faf1581c779c52d77 React-RCTLinking: 559c9223212ab2824950883220582c5e29a6fcb2 React-RCTNetwork: fe64ecd503461a8c01a0ab21d07cf9419f1cba54 diff --git a/packages/rn-tester/RNTesterPods.xcodeproj/project.pbxproj b/packages/rn-tester/RNTesterPods.xcodeproj/project.pbxproj index 84c21d73d7..9b3b1f8097 100644 --- a/packages/rn-tester/RNTesterPods.xcodeproj/project.pbxproj +++ b/packages/rn-tester/RNTesterPods.xcodeproj/project.pbxproj @@ -791,7 +791,6 @@ OTHER_LDFLAGS = ( "$(inherited)", "-ObjC", - "-l\"stdc++\"", "-framework", "\"JavaScriptCore\"", ); @@ -824,7 +823,6 @@ OTHER_LDFLAGS = ( "$(inherited)", "-ObjC", - "-l\"stdc++\"", "-framework", "\"JavaScriptCore\"", ); diff --git a/third-party-podspecs/RCT-Folly.podspec b/third-party-podspecs/RCT-Folly.podspec index f5dc212148..21cc71a915 100644 --- a/third-party-podspecs/RCT-Folly.podspec +++ b/third-party-podspecs/RCT-Folly.podspec @@ -72,7 +72,7 @@ Pod::Spec.new do |spec| 'folly/net/*.h', 'folly/net/detail/*.h', 'folly/portability/*.h' - spec.libraries = "stdc++", "c++abi" # NOTE Apple-only: Keep c++abi here due to https://github.com/react-native-community/releases/issues/251 + spec.libraries = "c++abi" # NOTE Apple-only: Keep c++abi here due to https://github.com/react-native-community/releases/issues/251 spec.pod_target_xcconfig = { "USE_HEADERMAP" => "NO", "CLANG_CXX_LANGUAGE_STANDARD" => "c++17", "HEADER_SEARCH_PATHS" => "\"$(PODS_TARGET_SRCROOT)\" \"$(PODS_ROOT)/boost\" \"$(PODS_ROOT)/DoubleConversion\" \"$(PODS_ROOT)/libevent/include/\"" } diff --git a/third-party-podspecs/glog.podspec b/third-party-podspecs/glog.podspec index 810c7b2838..6894aeda4b 100644 --- a/third-party-podspecs/glog.podspec +++ b/third-party-podspecs/glog.podspec @@ -28,7 +28,6 @@ Pod::Spec.new do |spec| spec.preserve_paths = 'src/*.h', 'src/base/*.h' spec.exclude_files = "src/windows/**/*" - spec.libraries = "stdc++" spec.compiler_flags = '-Wno-shorten-64-to-32' spec.pod_target_xcconfig = { "USE_HEADERMAP" => "NO", "HEADER_SEARCH_PATHS" => "$(PODS_TARGET_SRCROOT)/src" } From 2a605c30e45f8f437cf9a935583825daf1fbe371 Mon Sep 17 00:00:00 2001 From: Luna Wei Date: Fri, 8 Oct 2021 17:53:18 -0700 Subject: [PATCH 29/62] Comment on PR with link to PR artifact Summary: Changelog: [Internal] Configure circleCI to comment on PR after building tarball Reviewed By: hramos Differential Revision: D31387660 fbshipit-source-id: 28902148cf5e2ea15320333b90a6a7fa9d553c3b --- .circleci/config.yml | 7 ++++ bots/post-artifacts-link.js | 48 +++++++++++++++++++++++++ scripts/circleci/post-artifacts-link.sh | 11 ++++++ 3 files changed, 66 insertions(+) create mode 100644 bots/post-artifacts-link.js create mode 100755 scripts/circleci/post-artifacts-link.sh diff --git a/.circleci/config.yml b/.circleci/config.yml index 2d8e41eaea..4846fb669d 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -774,6 +774,13 @@ jobs: - store_artifacts: path: ~/react-native/build/ destination: build + - when: + condition: + matches: { pattern: '^pull\/.*$', value: << pipeline.git.branch >> } + steps: + - run: + name: Post link to PR build artifacts (pull-bot) + command: GITHUB_TOKEN="$PUBLIC_PULLBOT_GITHUB_TOKEN_A""$PUBLIC_PULLBOT_GITHUB_TOKEN_B" scripts/circleci/post-artifacts-link.sh # ------------------------- # JOBS: Nightly diff --git a/bots/post-artifacts-link.js b/bots/post-artifacts-link.js new file mode 100644 index 0000000000..cc93fc5ad2 --- /dev/null +++ b/bots/post-artifacts-link.js @@ -0,0 +1,48 @@ +/** + * 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 + */ + +'use strict'; + +const {GITHUB_TOKEN, CIRCLE_BUILD_URL, GITHUB_SHA} = process.env; +if (!GITHUB_TOKEN || !CIRCLE_BUILD_URL) { + if (!GITHUB_TOKEN) { + console.error("Missing GITHUB_TOKEN. This should've been set by the CI."); + } + if (!CIRCLE_BUILD_URL) { + console.error( + "Missing CIRCLE_BUILD_URL. This should've been set by the CI.", + ); + } + process.exit(1); +} + +const {createOrUpdateComment} = require('./make-comment'); + +/** + * Creates or updates a comment with specified pattern. + * @param {string} buildURL link to circleCI build + * @param {string} commitSha github sha of PR + */ +function postArtifactLink(buildUrl, commitSha) { + const artifactLink = buildUrl + '/artifacts'; + const comment = [ + `PR build artifact${ + commitSha != null ? ` for ${commitSha}` : '' + } is ready.`, + `To use, download tarball from [this CircleCI job](${artifactLink}) then run \`yarn add \` in your React Native project.`, + ].join('\n'); + createOrUpdateComment(comment); +} + +try { + postArtifactLink(CIRCLE_BUILD_URL, GITHUB_SHA); +} catch (error) { + console.error(error); + process.exitCode = 1; +} diff --git a/scripts/circleci/post-artifacts-link.sh b/scripts/circleci/post-artifacts-link.sh new file mode 100755 index 0000000000..eb9fe28a5c --- /dev/null +++ b/scripts/circleci/post-artifacts-link.sh @@ -0,0 +1,11 @@ +#!/bin/bash +# 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. + +GITHUB_OWNER=${CIRCLE_PROJECT_USERNAME:-facebook} \ +GITHUB_REPO=${CIRCLE_PROJECT_REPONAME:-react-native} \ +GITHUB_PR_NUMBER="${CIRCLE_PR_NUMBER:-${CIRCLE_PULL_REQUEST##*/}}" \ +GITHUB_SHA=${CIRCLE_SHA1} \ +exec node bots/post-artifacts-link.js From 1a9e2d5d5589ce5cee92868ea5bccceb6e161eff Mon Sep 17 00:00:00 2001 From: Xin Chen Date: Fri, 8 Oct 2021 18:56:09 -0700 Subject: [PATCH 30/62] Fix issue with scrollTo method in ScrollViews to set actual scroll position Summary: The `scrollTo` method in ScrollViews are using the `(x, y)` position they got from upperstream to scroll, and to set the state for Fabric. This diff fixes an edge case where the scroll result is not ended up to `(x, y)`. For example, if we are going to scroll to the last item in the list, the item may not scroll to the `(x, y)` position, but stay at the end position of the view. - Change `scrollTo` method to use the actual `scrollX` and `scrollY` position after scrolling to set current state. Changelog: [Android][Fixed] - scrollTo API in ScrollView will check the actual scroll position before setting the scroll state Reviewed By: JoshuaGross Differential Revision: D31492685 fbshipit-source-id: e5513fb735ea68c5014b5c47fadffe461cad5c94 --- .../react/views/scroll/ReactHorizontalScrollView.java | 8 ++++++-- .../com/facebook/react/views/scroll/ReactScrollView.java | 8 ++++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactHorizontalScrollView.java b/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactHorizontalScrollView.java index 82099cb25b..470c7d0f9b 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactHorizontalScrollView.java +++ b/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactHorizontalScrollView.java @@ -1231,8 +1231,12 @@ public class ReactHorizontalScrollView extends HorizontalScrollView } super.scrollTo(x, y); - updateStateOnScroll(x, y); - setPendingContentOffsets(x, y); + // The final scroll position might be different from (x, y). For example, we may need to scroll + // to the last item in the list, but that item cannot be move to the start position of the view. + final int actualX = getScrollX(); + final int actualY = getScrollY(); + updateStateOnScroll(actualX, actualY); + setPendingContentOffsets(actualX, actualY); } /** diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactScrollView.java b/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactScrollView.java index 3b920a6f50..54643e6e2d 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactScrollView.java +++ b/ReactAndroid/src/main/java/com/facebook/react/views/scroll/ReactScrollView.java @@ -1006,8 +1006,12 @@ public class ReactScrollView extends ScrollView @Override public void scrollTo(int x, int y) { super.scrollTo(x, y); - updateStateOnScroll(x, y); - setPendingContentOffsets(x, y); + // The final scroll position might be different from (x, y). For example, we may need to scroll + // to the last item in the list, but that item cannot be move to the start position of the view. + final int actualX = getScrollX(); + final int actualY = getScrollY(); + updateStateOnScroll(actualX, actualY); + setPendingContentOffsets(actualX, actualY); } /** From 232d02c5f620fcf49fd5b0ed6c74386aea5ab58b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Ramos?= Date: Sat, 9 Oct 2021 11:36:17 -0700 Subject: [PATCH 31/62] Move Docker test to GitHub Actions Summary: The test_docker_android job on Circle CI has a simple function: verify the base community RN Android image can be downloaded, and verify that we can use it to build a container with a compiled Android test app. Since the job is not strictly running a suite of tests, it can be moved to GitHub Actions. It will run on GitHub Actions as a Check on commits to main and pull requests. As building the test image requires the use of the base React Native Android image, we can skip downloading the base container and go straight to building the test image. Changelog: [Internal] Reviewed By: fkgozali Differential Revision: D31521978 fbshipit-source-id: ca8372a1464054e37f2da28a3ecfbc8f84db0408 --- .circleci/config.yml | 25 ----------------------- .github/workflows/test-docker-android.yml | 19 +++++++++++++++++ 2 files changed, 19 insertions(+), 25 deletions(-) create mode 100644 .github/workflows/test-docker-android.yml diff --git a/.circleci/config.yml b/.circleci/config.yml index 4846fb669d..b9f77a6ede 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -597,27 +597,6 @@ jobs: name: Build the template application command: cd template/android/ && ./gradlew assembleDebug - # ------------------------- - # JOBS: Test Docker - # ------------------------- - test_docker_android: - machine: - image: ubuntu-2004:202010-01 - steps: - - checkout - - run: - name: Configure Node - command: | - source ~/.bashrc - nvm i node - echo y | npx envinfo@latest - - run: - name: Pulls down the React Native Community Android Docker image - command: npm run docker-setup-android - - run: - name: Builds the Docker image with a compiled instance of the test app - command: npm run docker-build-android - # ------------------------- # JOBS: Windows # ------------------------- @@ -855,10 +834,6 @@ workflows: filters: branches: ignore: gh-pages - - test_docker_android: - filters: - branches: - ignore: gh-pages - test_windows: filters: branches: diff --git a/.github/workflows/test-docker-android.yml b/.github/workflows/test-docker-android.yml new file mode 100644 index 0000000000..8aec07427d --- /dev/null +++ b/.github/workflows/test-docker-android.yml @@ -0,0 +1,19 @@ +name: Test Docker Android Image +# This workflow is triggered on commits to main and pull requests. +on: + push: + branches: + - main + pull_request: + types: [ synchronize ] + branches: + - main + +jobs: + test-docker-android: + name: Test Docker + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Build Docker image with Android test app + run: npm run docker-build-android From e9440508e1c3f721452026662ac32663438ca87c Mon Sep 17 00:00:00 2001 From: Andrei Shikov Date: Mon, 11 Oct 2021 11:53:45 -0700 Subject: [PATCH 32/62] Correctly apply elevation barriers to Android views Summary: The elevation barriers that limited view reordering were applied incorrectly, disabling elevation completely for some combinations of views. This change ensures the order of barriers is correct and only disables elevation reorder between the children and not on them. Changelog: [Internal] Reviewed By: p-sun Differential Revision: D31541961 fbshipit-source-id: 2fa4dc6906790053bd4445c841aeda0e2b3830e5 --- .../java/com/facebook/react/views/view/ReactViewGroup.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactViewGroup.java b/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactViewGroup.java index 8bf0f0b4fa..8aedfecf77 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactViewGroup.java +++ b/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactViewGroup.java @@ -766,13 +766,13 @@ public class ReactViewGroup extends ViewGroup child.getElevation() > 0 && ReactFeatureFlags.insertZReorderBarriersOnViewGroupChildren; if (drawWithZ) { - CanvasUtil.enableZ(canvas, false); + CanvasUtil.enableZ(canvas, true); } boolean result = super.drawChild(canvas, child, drawingTime); if (drawWithZ) { - CanvasUtil.enableZ(canvas, true); + CanvasUtil.enableZ(canvas, false); } return result; } From 1ad45f516048b86eb03d6c2352b4b85c21ee3860 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kr=C3=A6n=20Hansen?= Date: Mon, 11 Oct 2021 14:15:33 -0700 Subject: [PATCH 33/62] Update build.gradle (#32382) Summary: This is a proposal to adjust the in-code documentation to clarify the semantics of the `enableHermes` variable. This fixes https://github.com/facebook/react-native-website/issues/2813. ## Changelog [Android] [Fixed] - Clarified in-code documentation in the template's `android/app/build.gradle`. Pull Request resolved: https://github.com/facebook/react-native/pull/32382 Test Plan: This is just an update to documentation, no need for tests. Reviewed By: yungsters Differential Revision: D31550133 Pulled By: Huxpro fbshipit-source-id: d60e5d256e1ffaf8556710b75582f1ae1c0f1fd3 --- template/android/app/build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/template/android/app/build.gradle b/template/android/app/build.gradle index 4e64e6a0d0..a461d9a900 100644 --- a/template/android/app/build.gradle +++ b/template/android/app/build.gradle @@ -114,7 +114,7 @@ def jscFlavor = 'org.webkit:android-jsc:+' /** * Whether to enable the Hermes VM. * - * This should be set on project.ext.react and mirrored here. If it is not set + * This should be set on project.ext.react and that value will be read here. If it is not set * on project.ext.react, JavaScript will not be compiled to Hermes Bytecode * and the benefits of using Hermes will therefore be sharply reduced. */ From f788aab45b7359e196a2420d5094e5ac5fe28033 Mon Sep 17 00:00:00 2001 From: Oleksandr Melnykov Date: Mon, 11 Oct 2021 15:49:48 -0700 Subject: [PATCH 34/62] Back out "Make runtime initialization from React renderers a no-op" Summary: Changelog: [Internal] Reviewed By: yungsters Differential Revision: D31552508 fbshipit-source-id: 1821f97393e3b9c40bd484a0831eb8fbdfc4bb82 --- .../ReactPrivate/ReactNativePrivateInitializeCore.js | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/Libraries/ReactPrivate/ReactNativePrivateInitializeCore.js b/Libraries/ReactPrivate/ReactNativePrivateInitializeCore.js index 975e173537..e34e6271f2 100644 --- a/Libraries/ReactPrivate/ReactNativePrivateInitializeCore.js +++ b/Libraries/ReactPrivate/ReactNativePrivateInitializeCore.js @@ -8,13 +8,4 @@ * @flow strict-local */ -// TODO: Remove this module when the import is removed from the React renderers. - -// This module is used by React to initialize the React Native runtime, -// but it is now a no-op. - -// This is redundant because all React Native apps are already executing -// `InitializeCore` before the entrypoint of the JS bundle -// (see https://github.com/react-native-community/cli/blob/e1da64317a1178c2b262d82c2f14210cdfa3ebe1/packages/cli-plugin-metro/src/tools/loadMetroConfig.ts#L93) -// and importing it unconditionally from React only prevents users from -// customizing what they want to include in their apps (re: app size). +import '../Core/InitializeCore'; From d47c487f7eff81dda498353bd7a351b6c5adac11 Mon Sep 17 00:00:00 2001 From: Luna Wei Date: Mon, 11 Oct 2021 21:23:38 -0700 Subject: [PATCH 35/62] install_github_bot_deps for posting link Summary: Changelog: [Internal] - Install dependencies for posting as bot Reviewed By: hramos Differential Revision: D31552246 fbshipit-source-id: 83e4953730cbd8dc5f3475ced20fb6556f97a4c6 --- .circleci/config.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.circleci/config.yml b/.circleci/config.yml index b9f77a6ede..1118ce028b 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -757,6 +757,7 @@ jobs: condition: matches: { pattern: '^pull\/.*$', value: << pipeline.git.branch >> } steps: + - install_github_bot_deps - run: name: Post link to PR build artifacts (pull-bot) command: GITHUB_TOKEN="$PUBLIC_PULLBOT_GITHUB_TOKEN_A""$PUBLIC_PULLBOT_GITHUB_TOKEN_B" scripts/circleci/post-artifacts-link.sh From 79db4835681f5d0149620ec8e0990411cb882241 Mon Sep 17 00:00:00 2001 From: Aditya Wasan Date: Tue, 12 Oct 2021 03:59:03 -0700 Subject: [PATCH 36/62] Add `ACCESS_MEDIA_LOCATION` permission (#32282) Summary: This PR adds `ACCESS_MEDIA_LOCATION` permission to the PermissionsAndroid library. It fixes https://github.com/facebook/react-native/issues/31953. It's a `dangerous` permission added in API level 29. https://developer.android.com/reference/android/Manifest.permission#ACCESS_MEDIA_LOCATION ## Changelog [Android] [Added] - Add ACCESS_MEDIA_LOCATION permission to PermisionsAndroid library. Pull Request resolved: https://github.com/facebook/react-native/pull/32282 Test Plan: ``` PermissionsAndroid.ACCESS_MEDIA_LOCATION === 'android.permission.ACCESS_MEDIA_LOCATION' ``` Reviewed By: yungsters Differential Revision: D31235523 Pulled By: cortinico fbshipit-source-id: 45fa86b1cdf8bc76453e9df6198c1f7ed923db7c --- Libraries/PermissionsAndroid/NativePermissionsAndroid.js | 3 ++- Libraries/PermissionsAndroid/PermissionsAndroid.js | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Libraries/PermissionsAndroid/NativePermissionsAndroid.js b/Libraries/PermissionsAndroid/NativePermissionsAndroid.js index 358882c8ec..7c3a6c58ac 100644 --- a/Libraries/PermissionsAndroid/NativePermissionsAndroid.js +++ b/Libraries/PermissionsAndroid/NativePermissionsAndroid.js @@ -44,7 +44,8 @@ export type PermissionType = | 'android.permission.WRITE_EXTERNAL_STORAGE' | 'android.permission.BLUETOOTH_CONNECT' | 'android.permission.BLUETOOTH_SCAN' - | 'android.permission.BLUETOOTH_ADVERTISE'; + | 'android.permission.BLUETOOTH_ADVERTISE' + | 'android.permission.ACCESS_MEDIA_LOCATION'; */ export interface Spec extends TurboModule { diff --git a/Libraries/PermissionsAndroid/PermissionsAndroid.js b/Libraries/PermissionsAndroid/PermissionsAndroid.js index 1006cd3192..0a24840c56 100644 --- a/Libraries/PermissionsAndroid/PermissionsAndroid.js +++ b/Libraries/PermissionsAndroid/PermissionsAndroid.js @@ -62,6 +62,7 @@ const PERMISSIONS = Object.freeze({ BLUETOOTH_CONNECT: 'android.permission.BLUETOOTH_CONNECT', BLUETOOTH_SCAN: 'android.permission.BLUETOOTH_SCAN', BLUETOOTH_ADVERTISE: 'android.permission.BLUETOOTH_ADVERTISE', + ACCESS_MEDIA_LOCATION: 'android.permission.ACCESS_MEDIA_LOCATION', }); /** @@ -75,6 +76,7 @@ class PermissionsAndroid { ACCESS_BACKGROUND_LOCATION: string, ACCESS_COARSE_LOCATION: string, ACCESS_FINE_LOCATION: string, + ACCESS_MEDIA_LOCATION: string, ADD_VOICEMAIL: string, BLUETOOTH_ADVERTISE: string, BLUETOOTH_CONNECT: string, From c75ad2cdb1b553af47dafb5840137d845b38be0b Mon Sep 17 00:00:00 2001 From: Andrei Shikov Date: Tue, 12 Oct 2021 08:29:07 -0700 Subject: [PATCH 37/62] React Native sync for revisions e8feb11...afcb9cd MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Summary: This sync includes the following changes: - **[579c008a7](https://github.com/facebook/react/commit/579c008a7 )**: [Fizz/Flight] pipeToNodeWritable(..., writable).startWriting() -> renderToPipeableStream(...).pipe(writable) ([#22450](https://github.com/facebook/react/pull/22450)) //// - **[f2c381131](https://github.com/facebook/react/commit/f2c381131 )**: fix: useSyncExternalStoreExtra ([#22500](https://github.com/facebook/react/pull/22500)) //// - **[0ecbbe142](https://github.com/facebook/react/commit/0ecbbe142 )**: Sync hydrate discrete events in capture phase and dont replay discrete events ([#22448](https://github.com/facebook/react/pull/22448)) //// - **[a724a3b57](https://github.com/facebook/react/commit/a724a3b57 )**: [RFC] Codemod invariant -> throw new Error ([#22435](https://github.com/facebook/react/pull/22435)) //// - **[201af81b0](https://github.com/facebook/react/commit/201af81b0 )**: Release pooled cache reference in complete/unwind ([#22464](https://github.com/facebook/react/pull/22464)) //// - **[033efe731](https://github.com/facebook/react/commit/033efe731 )**: Call get snapshot in useSyncExternalStore server shim ([#22453](https://github.com/facebook/react/pull/22453)) //// - **[7843b142a](https://github.com/facebook/react/commit/7843b142a )**: [Fizz/Flight] Pass in Destination lazily to startFlowing instead of in createRequest ([#22449](https://github.com/facebook/react/pull/22449)) //// - **[d9fb383d6](https://github.com/facebook/react/commit/d9fb383d6 )**: Extract queueing logic into shared functions ([#22452](https://github.com/facebook/react/pull/22452)) //// - **[9175f4d15](https://github.com/facebook/react/commit/9175f4d15 )**: Scheduling Profiler: Show Suspense resource .displayName ([#22451](https://github.com/facebook/react/pull/22451)) //// - **[eba248c39](https://github.com/facebook/react/commit/eba248c39 )**: [Fizz/Flight] Remove reentrancy hack ([#22446](https://github.com/facebook/react/pull/22446)) //// - **[66388150e](https://github.com/facebook/react/commit/66388150e )**: Remove usereducer eager bailout ([#22445](https://github.com/facebook/react/pull/22445)) //// - **[d3e086932](https://github.com/facebook/react/commit/d3e086932 )**: Make root.unmount() synchronous ([#22444](https://github.com/facebook/react/pull/22444)) //// - **[2cc6d79c9](https://github.com/facebook/react/commit/2cc6d79c9 )**: Rename onReadyToStream to onCompleteShell ([#22443](https://github.com/facebook/react/pull/22443)) //// - **[c88fb49d3](https://github.com/facebook/react/commit/c88fb49d3 )**: Improve DEV errors if string coercion throws (Temporal.*, Symbol, etc.) ([#22064](https://github.com/facebook/react/pull/22064)) //// - **[05726d72c](https://github.com/facebook/react/commit/05726d72c )**: [Fix] Errors should not "unsuspend" a transition ([#22423](https://github.com/facebook/react/pull/22423)) //// - **[3746eaf98](https://github.com/facebook/react/commit/3746eaf98 )**: Packages/React/src/ReactLazy ---> changing -1 to unintialized ([#22421](https://github.com/facebook/react/pull/22421)) //// - **[04ccc01d9](https://github.com/facebook/react/commit/04ccc01d9 )**: Hydration errors should force a client render ([#22416](https://github.com/facebook/react/pull/22416)) //// - **[029fdcebb](https://github.com/facebook/react/commit/029fdcebb )**: root.hydrate -> root.isDehydrated ([#22420](https://github.com/facebook/react/pull/22420)) //// - **[af87f5a83](https://github.com/facebook/react/commit/af87f5a83 )**: Scheduling Profiler marks should include thrown Errors ([#22417](https://github.com/facebook/react/pull/22417)) //// - **[d47339ea3](https://github.com/facebook/react/commit/d47339ea3 )**: [Fizz] Remove assignID mechanism ([#22410](https://github.com/facebook/react/pull/22410)) //// - **[3a50d9557](https://github.com/facebook/react/commit/3a50d9557 )**: Never attach ping listeners in legacy Suspense ([#22407](https://github.com/facebook/react/pull/22407)) //// - **[82c8fa90b](https://github.com/facebook/react/commit/82c8fa90b )**: Add back useMutableSource temporarily ([#22396](https://github.com/facebook/react/pull/22396)) //// - **[5b57bc6e3](https://github.com/facebook/react/commit/5b57bc6e3 )**: [Draft] don't patch console during first render ([#22308](https://github.com/facebook/react/pull/22308)) //// - **[cf07c3df1](https://github.com/facebook/react/commit/cf07c3df1 )**: Delete all but one `build2` reference ([#22391](https://github.com/facebook/react/pull/22391)) //// - **[bb0d06935](https://github.com/facebook/react/commit/bb0d06935 )**: [build2 -> build] Local scripts //// - **[0c81d347b](https://github.com/facebook/react/commit/0c81d347b )**: Write artifacts to `build` instead of `build2` //// - **[4da03c9fb](https://github.com/facebook/react/commit/4da03c9fb )**: useSyncExternalStore React Native version ([#22367](https://github.com/facebook/react/pull/22367)) //// - **[48d475c9e](https://github.com/facebook/react/commit/48d475c9e )**: correct typos ([#22294](https://github.com/facebook/react/pull/22294)) //// - **[cb6c619c0](https://github.com/facebook/react/commit/cb6c619c0 )**: Remove Fiber fields that were used for hydrating useMutableSource ([#22368](https://github.com/facebook/react/pull/22368)) //// - **[64e70f82e](https://github.com/facebook/react/commit/64e70f82e )**: [Fizz] add avoidThisFallback support ([#22318](https://github.com/facebook/react/pull/22318)) //// - **[3ee7a004e](https://github.com/facebook/react/commit/3ee7a004e )**: devtools: Display actual ReactDOM API name in root type ([#22363](https://github.com/facebook/react/pull/22363)) //// - **[79b8fc667](https://github.com/facebook/react/commit/79b8fc667 )**: Implement getServerSnapshot in userspace shim ([#22359](https://github.com/facebook/react/pull/22359)) //// - **[86b3e2461](https://github.com/facebook/react/commit/86b3e2461 )**: Implement useSyncExternalStore on server ([#22347](https://github.com/facebook/react/pull/22347)) //// - **[8209de269](https://github.com/facebook/react/commit/8209de269 )**: Delete useMutableSource implementation ([#22292](https://github.com/facebook/react/pull/22292)) //// Changelog: [General][Changed] - React Native sync for revisions e8feb11...afcb9cd jest_e2e[run_all_tests] Reviewed By: yungsters Differential Revision: D31541359 fbshipit-source-id: c35941bc303fdf55cb061e9996200dc868a6f2af --- Libraries/Renderer/REVISION | 2 +- .../implementations/ReactFabric-dev.fb.js | 1792 +++++++++------- .../implementations/ReactFabric-prod.fb.js | 640 +++--- .../ReactFabric-profiling.fb.js | 710 +++---- .../ReactNativeRenderer-dev.fb.js | 1797 ++++++++++------- .../ReactNativeRenderer-prod.fb.js | 610 +++--- .../ReactNativeRenderer-profiling.fb.js | 680 ++++--- 7 files changed, 3407 insertions(+), 2824 deletions(-) diff --git a/Libraries/Renderer/REVISION b/Libraries/Renderer/REVISION index 188feb01ce..97d8977a5a 100644 --- a/Libraries/Renderer/REVISION +++ b/Libraries/Renderer/REVISION @@ -1 +1 @@ -e8feb11b62e869804970258fa629922edbfc836b \ No newline at end of file +afcb9cdc9343ddc134b03dcf4d7fbc0810b6002b \ No newline at end of file diff --git a/Libraries/Renderer/implementations/ReactFabric-dev.fb.js b/Libraries/Renderer/implementations/ReactFabric-dev.fb.js index 7de2d2c90a..6bc84b6f49 100644 --- a/Libraries/Renderer/implementations/ReactFabric-dev.fb.js +++ b/Libraries/Renderer/implementations/ReactFabric-dev.fb.js @@ -7,7 +7,7 @@ * @noflow * @nolint * @preventMunge - * @generated SignedSource<<65d072c3d2937f89a7fadc55450af2f7>> + * @generated SignedSource<> */ 'use strict'; @@ -75,10 +75,10 @@ function printWarning(level, format, args) { if (stack !== "") { format += "%s"; args = args.concat([stack]); - } + } // eslint-disable-next-line react-internal/safe-string-coercion var argsWithFormat = args.map(function(item) { - return "" + item; + return String(item); }); // Careful: RN currently depends on this prefix argsWithFormat.unshift("Warning: " + format); // We intentionally don't use spread (or .apply) directly because it @@ -145,9 +145,15 @@ var invokeGuardedCallbackImpl = invokeGuardedCallbackProd; // when we call document.createEvent(). However this can cause confusing // errors: https://github.com/facebook/create-react-app/issues/3482 // So we preemptively throw with a better message instead. - if (!(typeof document !== "undefined")) { - throw Error( - "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." + if (typeof document === "undefined") { + throw new Error( + "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." ); } @@ -253,6 +259,7 @@ var invokeGuardedCallbackImpl = invokeGuardedCallbackProd; if (didCall && didError) { if (!didSetError) { // The callback errored, but the error event never fired. + // eslint-disable-next-line react-internal/prod-error-codes error = new Error( "An error was thrown inside one of your components, but React " + "doesn't know what it was. This is likely due to browser " + @@ -264,6 +271,7 @@ var invokeGuardedCallbackImpl = invokeGuardedCallbackProd; "actually an issue with React, please file an issue." ); } else if (isCrossOriginError) { + // eslint-disable-next-line react-internal/prod-error-codes error = new Error( "A cross-origin error was thrown. React doesn't have access to " + "the actual error object in development. " + @@ -376,11 +384,10 @@ function clearCaughtError() { caughtError = null; return error; } else { - { - throw Error( - "clearCaughtError was called but no error was captured. This error is likely caused by a bug in React. Please file an issue." - ); - } + throw new Error( + "clearCaughtError was called but no error was captured. This error " + + "is likely caused by a bug in React. Please file an issue." + ); } } @@ -537,8 +544,8 @@ function executeDirectDispatch(event) { var dispatchListener = event._dispatchListeners; var dispatchInstance = event._dispatchInstances; - if (!!isArray(dispatchListener)) { - throw Error("executeDirectDispatch(...): Invalid `event`."); + if (isArray(dispatchListener)) { + throw new Error("executeDirectDispatch(...): Invalid `event`."); } event.currentTarget = dispatchListener @@ -559,6 +566,7 @@ function hasDispatches(event) { return !!event._dispatchListeners; } +/* eslint valid-typeof: 0 */ var EVENT_POOL_SIZE = 10; /** * @interface Event @@ -885,7 +893,7 @@ function releasePooledEvent(event) { var EventConstructor = this; if (!(event instanceof EventConstructor)) { - throw Error( + throw new Error( "Trying to release an event instance into a pool of a different type." ); } @@ -994,8 +1002,8 @@ function resetTouchRecord(touchRecord, touch) { function getTouchIdentifier(_ref) { var identifier = _ref.identifier; - if (!(identifier != null)) { - throw Error("Touch object is missing identifier."); + if (identifier == null) { + throw new Error("Touch object is missing identifier."); } { @@ -1153,8 +1161,8 @@ var ResponderTouchHistoryStore = { */ function accumulate(current, next) { - if (!(next != null)) { - throw Error( + if (next == null) { + throw new Error( "accumulate(...): Accumulated items must not be null or undefined." ); } @@ -1189,8 +1197,8 @@ function accumulate(current, next) { */ function accumulateInto(current, next) { - if (!(next != null)) { - throw Error( + if (next == null) { + throw new Error( "accumulateInto(...): Accumulated items must not be null or undefined." ); } @@ -1496,8 +1504,8 @@ function getListener(inst, registrationName) { var listener = props[registrationName]; - if (!(!listener || typeof listener === "function")) { - throw Error( + if (listener && typeof listener !== "function") { + throw new Error( "Expected `" + registrationName + "` listener to be a function, instead got a value of `" + @@ -2079,11 +2087,10 @@ function recomputePluginOrdering() { var pluginModule = namesToPlugins[pluginName]; var pluginIndex = eventPluginOrder.indexOf(pluginName); - if (!(pluginIndex > -1)) { - throw Error( - "EventPluginRegistry: Cannot inject event plugins that do not exist in the plugin ordering, `" + - pluginName + - "`." + if (pluginIndex <= -1) { + throw new Error( + "EventPluginRegistry: Cannot inject event plugins that do not exist in " + + ("the plugin ordering, `" + pluginName + "`.") ); } @@ -2092,10 +2099,9 @@ function recomputePluginOrdering() { } if (!pluginModule.extractEvents) { - throw Error( - "EventPluginRegistry: Event plugins must implement an `extractEvents` method, but `" + - pluginName + - "` does not." + throw new Error( + "EventPluginRegistry: Event plugins must implement an `extractEvents` " + + ("method, but `" + pluginName + "` does not.") ); } @@ -2110,7 +2116,7 @@ function recomputePluginOrdering() { eventName ) ) { - throw Error( + throw new Error( "EventPluginRegistry: Failed to publish event `" + eventName + "` for plugin `" + @@ -2131,11 +2137,10 @@ function recomputePluginOrdering() { */ function publishEventForPlugin(dispatchConfig, pluginModule, eventName) { - if (!!eventNameDispatchConfigs.hasOwnProperty(eventName)) { - throw Error( - "EventPluginRegistry: More than one plugin attempted to publish the same event name, `" + - eventName + - "`." + if (eventNameDispatchConfigs.hasOwnProperty(eventName)) { + throw new Error( + "EventPluginRegistry: More than one plugin attempted to publish the same " + + ("event name, `" + eventName + "`.") ); } @@ -2175,11 +2180,10 @@ function publishEventForPlugin(dispatchConfig, pluginModule, eventName) { */ function publishRegistrationName(registrationName, pluginModule, eventName) { - if (!!registrationNameModules[registrationName]) { - throw Error( - "EventPluginRegistry: More than one plugin attempted to publish the same registration name, `" + - registrationName + - "`." + if (registrationNameModules[registrationName]) { + throw new Error( + "EventPluginRegistry: More than one plugin attempted to publish the same " + + ("registration name, `" + registrationName + "`.") ); } @@ -2226,9 +2230,10 @@ var registrationNameDependencies = {}; */ function injectEventPluginOrder(injectedEventPluginOrder) { - if (!!eventPluginOrder) { - throw Error( - "EventPluginRegistry: Cannot inject event plugin ordering more than once. You are likely trying to load more than one copy of React." + if (eventPluginOrder) { + throw new Error( + "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. @@ -2259,11 +2264,10 @@ function injectEventPluginsByName(injectedNamesToPlugins) { !namesToPlugins.hasOwnProperty(pluginName) || namesToPlugins[pluginName] !== pluginModule ) { - if (!!namesToPlugins[pluginName]) { - throw Error( - "EventPluginRegistry: Cannot inject two different event plugins using the same name, `" + - pluginName + - "`." + if (namesToPlugins[pluginName]) { + throw new Error( + "EventPluginRegistry: Cannot inject two different event plugins " + + ("using the same name, `" + pluginName + "`.") ); } @@ -2294,8 +2298,8 @@ function getListener$1(inst, registrationName) { var listener = props[registrationName]; - if (!(!listener || typeof listener === "function")) { - throw Error( + if (listener && typeof listener !== "function") { + throw new Error( "Expected `" + registrationName + "` listener to be a function, instead got a value of `" + @@ -2443,8 +2447,8 @@ var ReactNativeBridgeEventPlugin = { var bubbleDispatchConfig = customBubblingEventTypes[topLevelType]; var directDispatchConfig = customDirectEventTypes[topLevelType]; - if (!(bubbleDispatchConfig || directDispatchConfig)) { - throw Error( + if (!bubbleDispatchConfig && !directDispatchConfig) { + throw new Error( // $FlowFixMe - Flow doesn't like this string coercion because DOMTopLevelEventType is opaque 'Unsupported top level event type "' + topLevelType + '" dispatched' ); } @@ -2502,7 +2506,7 @@ function getTagFromInstance(inst) { var nativeInstance = inst.stateNode.canonical; if (!nativeInstance._nativeTag) { - throw Error("All native instances should have a tag."); + throw new Error("All native instances should have a tag."); } return nativeInstance; @@ -2849,6 +2853,7 @@ function getComponentNameFromFiber(fiber) { var enablePersistentOffscreenHostContainer = dynamicFlags.enablePersistentOffscreenHostContainer; // The rest of the flags are static for better dead code elimination. +var enableSchedulingProfiler = false; var enableProfilerTimer = true; var enableProfilerCommitHooks = true; var enableLazyElements = false; @@ -2888,41 +2893,41 @@ var DidCapture = 128; var Ref = /* */ - 256; + 512; var Snapshot = /* */ - 512; + 1024; var Passive = /* */ - 1024; + 2048; var Hydrating = /* */ - 2048; + 4096; var HydratingAndUpdate = /* */ Hydrating | Update; var Visibility = /* */ - 4096; + 8192; var StoreConsistency = /* */ - 8192; + 16384; var LifecycleEffectMask = Passive | Update | Callback | Ref | Snapshot | StoreConsistency; // Union of all commit flags (flags with the lifetime of a particular commit) var HostEffectMask = /* */ - 16383; // These are not really side effects, but we still reuse this field. + 32767; // These are not really side effects, but we still reuse this field. var Incomplete = /* */ - 16384; + 32768; var ShouldCapture = /* */ - 32768; + 65536; var ForceUpdateForLegacySuspense = /* */ - 65536; + 131072; // e.g. a fiber uses a passive effect (even if there are no updates on this particular render). // This enables us to defer more work in the unmount case, // since we can defer traversing the tree during layout to look for Passive effects, @@ -2930,22 +2935,22 @@ var ForceUpdateForLegacySuspense = var RefStatic = /* */ - 524288; + 1048576; var LayoutStatic = /* */ - 1048576; + 2097152; var PassiveStatic = /* */ - 2097152; // These flags allow us to traverse to fibers that have effects on mount + 4194304; // These flags allow us to traverse to fibers that have effects on mount // without traversing the entire tree after every commit for // double invoking var MountLayoutDev = /* */ - 4194304; + 8388608; var MountPassiveDev = /* */ - 8388608; // Groups of flags that are used in the commit phase to skip over trees that + 16777216; // Groups of flags that are used in the commit phase to skip over trees that // don't contain effects, by checking subtreeFlags. var BeforeMutationMask = // TODO: Remove Update flag from before mutation phase by re-landing Visibility @@ -3040,8 +3045,8 @@ function isMounted(component) { } function assertIsMounted(fiber) { - if (!(getNearestMountedFiber(fiber) === fiber)) { - throw Error("Unable to find node on an unmounted component."); + if (getNearestMountedFiber(fiber) !== fiber) { + throw new Error("Unable to find node on an unmounted component."); } } @@ -3052,8 +3057,8 @@ function findCurrentFiberUsingSlowPath(fiber) { // If there is no alternate, then we only need to check if it is mounted. var nearestMounted = getNearestMountedFiber(fiber); - if (!(nearestMounted !== null)) { - throw Error("Unable to find node on an unmounted component."); + if (nearestMounted === null) { + throw new Error("Unable to find node on an unmounted component."); } if (nearestMounted !== fiber) { @@ -3115,9 +3120,7 @@ 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. - { - throw Error("Unable to find node on an unmounted component."); - } + throw new Error("Unable to find node on an unmounted component."); } if (a.return !== b.return) { @@ -3177,23 +3180,25 @@ function findCurrentFiberUsingSlowPath(fiber) { } if (!didFindChild) { - throw Error( - "Child was not found in either parent set. This indicates a bug in React related to the return pointer. Please file an issue." + throw new Error( + "Child was not found in either parent set. This indicates a bug " + + "in React related to the return pointer. Please file an issue." ); } } } - if (!(a.alternate === b)) { - throw Error( - "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 new Error( + "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. - if (!(a.tag === HostRoot)) { - throw Error("Unable to find node on an unmounted component."); + if (a.tag !== HostRoot) { + throw new Error("Unable to find node on an unmounted component."); } if (a.stateNode.current === a) { @@ -3791,9 +3796,10 @@ function runEventsInBatch(events) { forEachAccumulated(processingEventQueue, executeDispatchesAndReleaseTopLevel); - if (!!eventQueue) { - throw Error( - "processEventQueue(): Additional events were enqueued while processing an event queue. Support for this has not yet been implemented." + if (eventQueue) { + throw new Error( + "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. @@ -3888,6 +3894,103 @@ var UserBlockingPriority = Scheduler.unstable_UserBlockingPriority; var NormalPriority = Scheduler.unstable_NormalPriority; var IdlePriority = Scheduler.unstable_IdlePriority; +// Helpers to patch console.logs to avoid logging during side-effect free +// replaying on render function. This currently only patches the object +// lazily which won't cover if the log function was extracted eagerly. +// We could also eagerly patch the method. +var disabledDepth = 0; +var prevLog; +var prevInfo; +var prevWarn; +var prevError; +var prevGroup; +var prevGroupCollapsed; +var prevGroupEnd; + +function disabledLog() {} + +disabledLog.__reactDisabledLog = true; +function disableLogs() { + { + if (disabledDepth === 0) { + /* eslint-disable react-internal/no-production-logging */ + prevLog = console.log; + prevInfo = console.info; + prevWarn = console.warn; + prevError = console.error; + prevGroup = console.group; + prevGroupCollapsed = console.groupCollapsed; + prevGroupEnd = console.groupEnd; // https://github.com/facebook/react/issues/19099 + + var props = { + configurable: true, + enumerable: true, + value: disabledLog, + writable: true + }; // $FlowFixMe Flow thinks console is immutable. + + Object.defineProperties(console, { + info: props, + log: props, + warn: props, + error: props, + group: props, + groupCollapsed: props, + groupEnd: props + }); + /* eslint-enable react-internal/no-production-logging */ + } + + disabledDepth++; + } +} +function reenableLogs() { + { + disabledDepth--; + + if (disabledDepth === 0) { + /* eslint-disable react-internal/no-production-logging */ + var props = { + configurable: true, + enumerable: true, + writable: true + }; // $FlowFixMe Flow thinks console is immutable. + + Object.defineProperties(console, { + log: Object.assign({}, props, { + value: prevLog + }), + info: Object.assign({}, props, { + value: prevInfo + }), + warn: Object.assign({}, props, { + value: prevWarn + }), + error: Object.assign({}, props, { + value: prevError + }), + group: Object.assign({}, props, { + value: prevGroup + }), + groupCollapsed: Object.assign({}, props, { + value: prevGroupCollapsed + }), + groupEnd: Object.assign({}, props, { + value: prevGroupEnd + }) + }); + /* eslint-enable react-internal/no-production-logging */ + } + + if (disabledDepth < 0) { + error( + "disabledDepth fell below zero. " + + "This is a bug in React. Please file an issue." + ); + } + } +} + var rendererID = null; var injectedHook = null; var hasLoggedError = false; @@ -4039,6 +4142,15 @@ function onCommitUnmount(fiber) { } } } +function setIsStrictModeForDevtools(newIsStrictMode) { + { + if (newIsStrictMode) { + disableLogs(); + } else { + reenableLogs(); + } + } +} var NoMode = /* */ @@ -4794,28 +4906,28 @@ function lanesToEventPriority(lanes) { return IdleEventPriority; } +// Renderers that don't support mutation // can re-export everything from this module. - function shim() { - { - throw Error( - "The current renderer does not support mutation. This error is likely caused by a bug in React. Please file an issue." - ); - } + throw new Error( + "The current renderer does not support mutation. " + + "This error is likely caused by a bug in React. " + + "Please file an issue." + ); } // Mutation (when unsupported) var supportsMutation = false; var commitMount = shim; var clearContainer = shim; +// Renderers that don't support hydration // can re-export everything from this module. - function shim$1() { - { - throw Error( - "The current renderer does not support hydration. This error is likely caused by a bug in React. Please file an issue." - ); - } + throw new Error( + "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 isSuspenseInstancePending = shim$1; var isSuspenseInstanceFallback = shim$1; @@ -5195,103 +5307,6 @@ function preparePortalMount(portalInstance) { // noop } -// Helpers to patch console.logs to avoid logging during side-effect free -// replaying on render function. This currently only patches the object -// lazily which won't cover if the log function was extracted eagerly. -// We could also eagerly patch the method. -var disabledDepth = 0; -var prevLog; -var prevInfo; -var prevWarn; -var prevError; -var prevGroup; -var prevGroupCollapsed; -var prevGroupEnd; - -function disabledLog() {} - -disabledLog.__reactDisabledLog = true; -function disableLogs() { - { - if (disabledDepth === 0) { - /* eslint-disable react-internal/no-production-logging */ - prevLog = console.log; - prevInfo = console.info; - prevWarn = console.warn; - prevError = console.error; - prevGroup = console.group; - prevGroupCollapsed = console.groupCollapsed; - prevGroupEnd = console.groupEnd; // https://github.com/facebook/react/issues/19099 - - var props = { - configurable: true, - enumerable: true, - value: disabledLog, - writable: true - }; // $FlowFixMe Flow thinks console is immutable. - - Object.defineProperties(console, { - info: props, - log: props, - warn: props, - error: props, - group: props, - groupCollapsed: props, - groupEnd: props - }); - /* eslint-enable react-internal/no-production-logging */ - } - - disabledDepth++; - } -} -function reenableLogs() { - { - disabledDepth--; - - if (disabledDepth === 0) { - /* eslint-disable react-internal/no-production-logging */ - var props = { - configurable: true, - enumerable: true, - writable: true - }; // $FlowFixMe Flow thinks console is immutable. - - Object.defineProperties(console, { - log: Object.assign({}, props, { - value: prevLog - }), - info: Object.assign({}, props, { - value: prevInfo - }), - warn: Object.assign({}, props, { - value: prevWarn - }), - error: Object.assign({}, props, { - value: prevError - }), - group: Object.assign({}, props, { - value: prevGroup - }), - groupCollapsed: Object.assign({}, props, { - value: prevGroupCollapsed - }), - groupEnd: Object.assign({}, props, { - value: prevGroupEnd - }) - }); - /* eslint-enable react-internal/no-production-logging */ - } - - if (disabledDepth < 0) { - error( - "disabledDepth fell below zero. " + - "This is a bug in React. Please file an issue." - ); - } - } -} - var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher; function describeBuiltInComponentFrame(name, source, ownerFn) { { @@ -5451,6 +5466,7 @@ function checkPropTypes(typeSpecs, values, location, componentName, element) { // This is intentionally an invariant that gets caught. It's the same // behavior as without this statement except with a better message. if (typeof typeSpecs[typeSpecName] !== "function") { + // eslint-disable-next-line react-internal/prod-error-codes var err = Error( (componentName || "React class") + ": " + @@ -5682,9 +5698,10 @@ function popTopLevelContextObject(fiber) { function pushTopLevelContextObject(fiber, context, didChange) { { - if (!(contextStackCursor.current === emptyContextObject)) { - throw Error( - "Unexpected context found on stack. This error is likely caused by a bug in React. Please file an issue." + if (contextStackCursor.current !== emptyContextObject) { + throw new Error( + "Unexpected context found on stack. " + + "This error is likely caused by a bug in React. Please file an issue." ); } @@ -5723,7 +5740,7 @@ function processChildContext(fiber, type, parentContext) { for (var contextKey in childContext) { if (!(contextKey in childContextTypes)) { - throw Error( + throw new Error( (getComponentNameFromFiber(fiber) || "Unknown") + '.getChildContext(): key "' + contextKey + @@ -5768,8 +5785,9 @@ function invalidateContextProvider(workInProgress, type, didChange) { var instance = workInProgress.stateNode; if (!instance) { - throw Error( - "Expected to have an instance by this point. This error is likely caused by a bug in React. Please file an issue." + throw new Error( + "Expected to have an instance by this point. " + + "This error is likely caused by a bug in React. Please file an issue." ); } @@ -5801,9 +5819,10 @@ function findCurrentUnmaskedContext(fiber) { { // Currently this is only used with renderSubtreeIntoContainer; not sure if it // makes sense elsewhere - if (!(isFiberMounted(fiber) && fiber.tag === ClassComponent)) { - throw Error( - "Expected subtree parent to be a mounted class component. This error is likely caused by a bug in React. Please file an issue." + if (!isFiberMounted(fiber) || fiber.tag !== ClassComponent) { + throw new Error( + "Expected subtree parent to be a mounted class component. " + + "This error is likely caused by a bug in React. Please file an issue." ); } @@ -5828,11 +5847,10 @@ function findCurrentUnmaskedContext(fiber) { node = node.return; } while (node !== null); - { - throw Error( - "Found unexpected detached subtree parent. This error is likely caused by a bug in React. Please file an issue." - ); - } + throw new Error( + "Found unexpected detached subtree parent. " + + "This error is likely caused by a bug in React. Please file an issue." + ); } } @@ -5920,7 +5938,12 @@ function flushSyncCallbacks() { return null; } -var ReactVersion = "18.0.0-e8feb11b6-20210915"; +var ReactVersion = "18.0.0-afcb9cdc9-20211008"; + +function markComponentRenderStopped() {} +function markComponentErrored(fiber, thrownValue, lanes) {} + +function markComponentSuspended(fiber, wakeable, lanes) {} var ReactCurrentBatchConfig = ReactSharedInternals.ReactCurrentBatchConfig; var NoTransition = 0; @@ -6419,6 +6442,105 @@ var ReactStrictModeWarnings = { }; } +/* + * The `'' + value` pattern (used in in perf-sensitive code) throws for Symbol + * and Temporal.* types. See https://github.com/facebook/react/pull/22064. + * + * The functions in this module will throw an easier-to-understand, + * easier-to-debug exception with a clear errors message message explaining the + * problem. (Instead of a confusing exception thrown inside the implementation + * of the `value` object). + */ +// $FlowFixMe only called in DEV, so void return is not possible. + +function typeName(value) { + { + // toStringTag is needed for namespaced types like Temporal.Instant + var hasToStringTag = typeof Symbol === "function" && Symbol.toStringTag; + var type = + (hasToStringTag && value[Symbol.toStringTag]) || + value.constructor.name || + "Object"; + return type; + } +} // $FlowFixMe only called in DEV, so void return is not possible. + +function willCoercionThrow(value) { + { + if ( + value !== null && + typeof value === "object" && + value.$$typeof === REACT_OPAQUE_ID_TYPE + ) { + // OpaqueID type is expected to throw, so React will handle it. Not sure if + // it's expected that string coercion will throw, but we'll assume it's OK. + // See https://github.com/facebook/react/issues/20127. + return; + } + + try { + testStringCoercion(value); + return false; + } catch (e) { + return true; + } + } +} + +function testStringCoercion(value) { + // If you ended up here by following an exception call stack, here's what's + // happened: you supplied an object or symbol value to React (as a prop, key, + // DOM attribute, CSS property, string ref, etc.) and when React tried to + // coerce it to a string using `'' + value`, an exception was thrown. + // + // The most common types that will cause this exception are `Symbol` instances + // and Temporal objects like `Temporal.Instant`. But any object that has a + // `valueOf` or `[Symbol.toPrimitive]` method that throws will also cause this + // exception. (Library authors do this to prevent users from using built-in + // numeric operators like `+` or comparison operators like `>=` because custom + // methods are needed to perform accurate arithmetic or comparison.) + // + // To fix the problem, coerce this object or symbol value to a string before + // passing it to React. The most reliable way is usually `String(value)`. + // + // To find which value is throwing, check the browser or debugger console. + // Before this exception was thrown, there should be `console.error` output + // that shows the type (Symbol, Temporal.PlainDate, etc.) that caused the + // problem and how that type was used: key, atrribute, input value prop, etc. + // In most cases, this console output also shows the component and its + // ancestor components where the exception happened. + // + // eslint-disable-next-line react-internal/safe-string-coercion + return "" + value; +} +function checkKeyStringCoercion(value) { + { + if (willCoercionThrow(value)) { + error( + "The provided key is an unsupported type %s." + + " This value must be coerced to a string before before using it here.", + typeName(value) + ); + + return testStringCoercion(value); // throw (to help callers find troubleshooting comments) + } + } +} +function checkPropStringCoercion(value, propName) { + { + if (willCoercionThrow(value)) { + error( + "The provided `%s` prop is an unsupported type %s." + + " This value must be coerced to a string before before using it here.", + propName, + typeName(value) + ); + + return testStringCoercion(value); // throw (to help callers find troubleshooting comments) + } + } +} + function resolveDefaultProps(Component, baseProps) { if (Component && Component.defaultProps) { // Resolve default props. Taken from ReactElement @@ -6683,9 +6805,12 @@ function readContext(context) { }; if (lastContextDependency === null) { - if (!(currentlyRenderingFiber !== null)) { - throw Error( - "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()." + if (currentlyRenderingFiber === null) { + throw new Error( + "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. @@ -7253,10 +7378,10 @@ function processUpdateQueue(workInProgress, props, instance, renderLanes) { } function callCallback(callback, context) { - if (!(typeof callback === "function")) { - throw Error( - "Invalid argument passed as callback. Expected a function. Instead received: " + - callback + if (typeof callback !== "function") { + throw new Error( + "Invalid argument passed as callback. Expected a function. Instead " + + ("received: " + callback) ); } @@ -7355,11 +7480,14 @@ var didWarnAboutInvalidateContextType; Object.defineProperty(fakeInternalInstance, "_processChildContext", { enumerable: false, value: function() { - { - throw Error( - "_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)." - ); - } + throw new Error( + "_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); @@ -8439,9 +8567,10 @@ var warnForMissingKey = function(child, returnFiber) {}; return; } - if (!(typeof child._store === "object")) { - throw Error( - "React Component in warnForMissingKey should have a _store. This error is likely caused by a bug in React. Please file an issue." + if (typeof child._store !== "object") { + throw new Error( + "React Component in warnForMissingKey should have a _store. " + + "This error is likely caused by a bug in React. Please file an issue." ); } @@ -8510,9 +8639,12 @@ function coerceRef(returnFiber, current, element) { if (owner) { var ownerFiber = owner; - if (!(ownerFiber.tag === ClassComponent)) { - throw Error( - "Function components cannot have string refs. We recommend using useRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref" + if (ownerFiber.tag !== ClassComponent) { + throw new Error( + "Function components cannot have string refs. " + + "We recommend using useRef() instead. " + + "Learn more about using refs safely here: " + + "https://reactjs.org/link/strict-mode-string-ref" ); } @@ -8520,11 +8652,18 @@ function coerceRef(returnFiber, current, element) { } if (!inst) { - throw Error( + throw new Error( "Missing owner for string ref " + mixedRef + - ". This error is likely caused by a bug in React. Please file an issue." + ". This error is likely caused by a " + + "bug in React. Please file an issue." ); + } // Assigning this to a const so Flow knows it won't change in the closure + + var resolvedInst = inst; + + { + checkPropStringCoercion(mixedRef, "ref"); } var stringRef = "" + mixedRef; // Check if previous string ref matches new string ref @@ -8539,11 +8678,11 @@ function coerceRef(returnFiber, current, element) { } var ref = function(value) { - var refs = inst.refs; + var refs = resolvedInst.refs; if (refs === emptyRefsObject) { // This is a lazy pooled frozen object, so we need to initialize. - refs = inst.refs = {}; + refs = resolvedInst.refs = {}; } if (value === null) { @@ -8556,17 +8695,22 @@ function coerceRef(returnFiber, current, element) { ref._stringRef = stringRef; return ref; } else { - if (!(typeof mixedRef === "string")) { - throw Error( + if (typeof mixedRef !== "string") { + throw new Error( "Expected ref to be a function, a string, an object returned by React.createRef(), or null." ); } if (!element._owner) { - throw Error( + throw new Error( "Element ref was specified as a string (" + mixedRef + - ") but no owner was set. This could happen for one of the following reasons:\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://reactjs.org/link/refs-must-have-owner for more information." + ") but no owner was set. This could happen for one of" + + " the following reasons:\n" + + "1. You may be adding a ref to a function component\n" + + "2. You may be adding a ref to a component that was not created inside a component's render method\n" + + "3. You have multiple copies of React loaded\n" + + "See https://reactjs.org/link/refs-must-have-owner for more information." ); } } @@ -8577,16 +8721,15 @@ function coerceRef(returnFiber, current, element) { function throwOnInvalidObjectType(returnFiber, newChild) { var childString = Object.prototype.toString.call(newChild); - - { - throw Error( - "Objects are not valid as a React child (found: " + - (childString === "[object Object]" - ? "object with keys {" + Object.keys(newChild).join(", ") + "}" - : childString) + - "). If you meant to render a collection of children, use an array instead." - ); - } + throw new Error( + "Objects are not valid as a React child (found: " + + (childString === "[object Object]" + ? "object with keys {" + Object.keys(newChild).join(", ") + "}" + : childString) + + "). " + + "If you meant to render a collection of children, use an array " + + "instead." + ); } function warnOnFunctionType(returnFiber) { @@ -9202,9 +9345,10 @@ function ChildReconciler(shouldTrackSideEffects) { // but using the iterator instead. var iteratorFn = getIteratorFn(newChildrenIterable); - if (!(typeof iteratorFn === "function")) { - throw Error( - "An object is not an iterable. This error is likely caused by a bug in React. Please file an issue." + if (typeof iteratorFn !== "function") { + throw new Error( + "An object is not an iterable. This error is likely caused by a bug in " + + "React. Please file an issue." ); } @@ -9256,8 +9400,8 @@ function ChildReconciler(shouldTrackSideEffects) { var newChildren = iteratorFn.call(newChildrenIterable); - if (!(newChildren != null)) { - throw Error("An iterable object provided no iterator."); + if (newChildren == null) { + throw new Error("An iterable object provided no iterator."); } var resultingFirstChild = null; @@ -9634,8 +9778,8 @@ function ChildReconciler(shouldTrackSideEffects) { var reconcileChildFibers = ChildReconciler(true); var mountChildFibers = ChildReconciler(false); function cloneChildFibers(current, workInProgress) { - if (!(current === null || workInProgress.child === current.child)) { - throw Error("Resuming work not yet implemented."); + if (current !== null && workInProgress.child !== current.child) { + throw new Error("Resuming work not yet implemented."); } if (workInProgress.child === null) { @@ -9674,9 +9818,10 @@ var contextFiberStackCursor = createCursor(NO_CONTEXT); var rootInstanceStackCursor = createCursor(NO_CONTEXT); function requiredContext(c) { - if (!(c !== NO_CONTEXT)) { - throw Error( - "Expected host context to exist. This error is likely caused by a bug in React. Please file an issue." + if (c === NO_CONTEXT) { + throw new Error( + "Expected host context to exist. This error is likely caused by a bug " + + "in React. Please file an issue." ); } @@ -9893,21 +10038,19 @@ function prepareToHydrateHostInstance( hostContext ) { { - { - throw Error( - "Expected prepareToHydrateHostInstance() to never be called. This error is likely caused by a bug in React. Please file an issue." - ); - } + throw new Error( + "Expected prepareToHydrateHostInstance() to never be called. " + + "This error is likely caused by a bug in React. Please file an issue." + ); } } function prepareToHydrateHostTextInstance(fiber) { { - { - throw Error( - "Expected prepareToHydrateHostTextInstance() to never be called. This error is likely caused by a bug in React. Please file an issue." - ); - } + throw new Error( + "Expected prepareToHydrateHostTextInstance() to never be called. " + + "This error is likely caused by a bug in React. Please file an issue." + ); } var shouldUpdate = hydrateTextInstance(); } @@ -10109,11 +10252,14 @@ function warnOnHookMismatchInDev(currentHookName) { } function throwInvalidHookError() { - { - throw Error( - "Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:\n1. You might have mismatching versions of React and the renderer (such as React DOM)\n2. You might be breaking the Rules of Hooks\n3. You might have more than one copy of React in the same app\nSee https://reactjs.org/link/invalid-hook-call for tips about how to debug and fix this problem." - ); - } + throw new Error( + "Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for" + + " one of the following reasons:\n" + + "1. You might have mismatching versions of React and the renderer (such as React DOM)\n" + + "2. You might be breaking the Rules of Hooks\n" + + "3. You might have more than one copy of React in the same app\n" + + "See https://reactjs.org/link/invalid-hook-call for tips about how to debug and fix this problem." + ); } function areHookInputsEqual(nextDeps, prevDeps) { @@ -10221,9 +10367,10 @@ function renderWithHooks( do { didScheduleRenderPhaseUpdateDuringThisPass = false; - if (!(numberOfReRenders < RE_RENDER_LIMIT)) { - throw Error( - "Too many re-renders. React limits the number of renders to prevent an infinite loop." + if (numberOfReRenders >= RE_RENDER_LIMIT) { + throw new Error( + "Too many re-renders. React limits the number of renders to prevent " + + "an infinite loop." ); } @@ -10289,9 +10436,10 @@ function renderWithHooks( didScheduleRenderPhaseUpdate = false; - if (!!didRenderTooFewHooks) { - throw Error( - "Rendered fewer hooks than expected. This may be caused by an accidental early return statement." + if (didRenderTooFewHooks) { + throw new Error( + "Rendered fewer hooks than expected. This may be caused by an accidental " + + "early return statement." ); } @@ -10413,8 +10561,8 @@ function updateWorkInProgressHook() { currentHook = nextCurrentHook; } else { // Clone from the current hook. - if (!(nextCurrentHook !== null)) { - throw Error("Rendered more hooks than during the previous render."); + if (nextCurrentHook === null) { + throw new Error("Rendered more hooks than during the previous render."); } currentHook = nextCurrentHook; @@ -10470,7 +10618,7 @@ function mountReducer(reducer, initialArg, init) { lastRenderedState: initialState }; hook.queue = queue; - var dispatch = (queue.dispatch = dispatchAction.bind( + var dispatch = (queue.dispatch = dispatchReducerAction.bind( null, currentlyRenderingFiber$1, queue @@ -10482,8 +10630,8 @@ function updateReducer(reducer, initialArg, init) { var hook = updateWorkInProgressHook(); var queue = hook.queue; - if (!(queue !== null)) { - throw Error( + if (queue === null) { + throw new Error( "Should have a queue. This is likely a bug in React. Please file an issue." ); } @@ -10540,7 +10688,7 @@ function updateReducer(reducer, initialArg, init) { var clone = { lane: updateLane, action: update.action, - eagerReducer: update.eagerReducer, + hasEagerState: update.hasEagerState, eagerState: update.eagerState, next: null }; @@ -10568,16 +10716,16 @@ function updateReducer(reducer, initialArg, init) { // this will never be skipped by the check above. lane: NoLane, action: update.action, - eagerReducer: update.eagerReducer, + hasEagerState: update.hasEagerState, eagerState: update.eagerState, next: null }; newBaseQueueLast = newBaseQueueLast.next = _clone; } // Process this update. - if (update.eagerReducer === reducer) { - // If this update was processed eagerly, and its reducer matches the - // current reducer, we can use the eagerly computed state. + if (update.hasEagerState) { + // If this update is a state update (not a reducer) and was processed eagerly, + // we can use the eagerly computed state newState = update.eagerState; } else { var action = update.action; @@ -10635,8 +10783,8 @@ function rerenderReducer(reducer, initialArg, init) { var hook = updateWorkInProgressHook(); var queue = hook.queue; - if (!(queue !== null)) { - throw Error( + if (queue === null) { + throw new Error( "Should have a queue. This is likely a bug in React. Please file an issue." ); } @@ -10756,56 +10904,20 @@ function readFromUnsubscribedMutableSource(root, source, getSnapshot) { // the synchronous retry, it will block interleaved mutations, so we should // get a consistent read. Therefore, the following error should never be // visible to the user. - // - // If it were to become visible to the user, it suggests one of two things: - // a bug in React, or (more likely), a mutation during the render phase that - // caused the second re-render attempt to be different from the first. - // - // We know it's the second case if the logs are currently disabled. So in - // dev, we can present a more accurate error message. - - { - // eslint-disable-next-line react-internal/no-production-logging - if (getIsStrictModeForDevtools()) { - // If getIsStrictModeForDevtools is true, this is the dev-only double render - // This is only reachable if there was a mutation during render. Show a helpful - // error message. - // - // Something interesting to note: because we only double render in - // development, this error will never happen during production. This is - // actually true of all errors that occur during a double render, - // because if the first render had thrown, we would have exited the - // begin phase without double rendering. We should consider suppressing - // any error from a double render (with a warning) to more closely match - // the production behavior. - var componentName = getComponentNameFromFiber( - currentlyRenderingFiber$1 - ); - - { - throw Error( - "A mutable source was mutated while the " + - componentName + - " component was rendering. This is not supported. Move any mutations into event handlers or effects." - ); - } - } - } // We expect this error not to be thrown during the synchronous retry, + // We expect this error not to be thrown during the synchronous retry, // because we blocked interleaved mutations. - { - throw Error( - "Cannot read from mutable source during the current render without tearing. This may be a bug in React. Please file an issue." - ); - } + throw new Error( + "Cannot read from mutable source during the current render without tearing. This may be a bug in React. Please file an issue." + ); } } function useMutableSource(hook, source, getSnapshot, subscribe) { var root = getWorkInProgressRoot(); - if (!(root !== null)) { - throw Error( + if (root === null) { + throw new Error( "Expected a work-in-progress root. This is a bug in React. Please file an issue." ); } @@ -10937,7 +11049,7 @@ function useMutableSource(hook, source, getSnapshot, subscribe) { lastRenderedReducer: basicStateReducer, lastRenderedState: snapshot }; - newQueue.dispatch = setSnapshot = dispatchAction.bind( + newQueue.dispatch = setSnapshot = dispatchSetState.bind( null, currentlyRenderingFiber$1, newQueue @@ -10969,25 +11081,46 @@ function updateMutableSource(source, getSnapshot, subscribe) { return useMutableSource(hook, source, getSnapshot, subscribe); } -function mountSyncExternalStore(subscribe, getSnapshot) { +function mountSyncExternalStore(subscribe, getSnapshot, getServerSnapshot) { var fiber = currentlyRenderingFiber$1; - var hook = mountWorkInProgressHook(); // Read the current snapshot from the store on every render. This breaks the - // normal rules of React, and only works because store updates are - // always synchronous. - - var nextSnapshot = getSnapshot(); + var hook = mountWorkInProgressHook(); + var nextSnapshot; { - if (!didWarnUncachedGetSnapshot) { - if (nextSnapshot !== getSnapshot()) { - error( - "The result of getSnapshot should be cached to avoid an infinite loop" - ); + nextSnapshot = getSnapshot(); - didWarnUncachedGetSnapshot = true; + { + if (!didWarnUncachedGetSnapshot) { + if (nextSnapshot !== getSnapshot()) { + error( + "The result of getSnapshot should be cached to avoid an infinite loop" + ); + + didWarnUncachedGetSnapshot = true; + } } + } // Unless we're rendering a blocking lane, schedule a consistency check. + // Right before committing, we will walk the tree and check if any of the + // stores were mutated. + // + // We won't do this if we're hydrating server-rendered content, because if + // the content is stale, it's already visible anyway. Instead we'll patch + // it up in a passive effect. + + var root = getWorkInProgressRoot(); + + if (root === null) { + throw new Error( + "Expected a work-in-progress root. This is a bug in React. Please file an issue." + ); } - } + + if (!includesBlockingLane(root, renderLanes)) { + pushStoreConsistencyCheck(fiber, getSnapshot, nextSnapshot); + } + } // Read the current snapshot from the store on every render. This breaks the + // normal rules of React, and only works because store updates are + // always synchronous. hook.memoizedState = nextSnapshot; var inst = { @@ -11010,26 +11143,11 @@ function mountSyncExternalStore(subscribe, getSnapshot) { updateStoreInstance.bind(null, fiber, inst, nextSnapshot, getSnapshot), undefined, null - ); // Unless we're rendering a blocking lane, schedule a consistency check. Right - // before committing, we will walk the tree and check if any of the stores - // were mutated. - - var root = getWorkInProgressRoot(); - - if (!(root !== null)) { - throw Error( - "Expected a work-in-progress root. This is a bug in React. Please file an issue." - ); - } - - if (!includesBlockingLane(root, renderLanes)) { - pushStoreConsistencyCheck(fiber, getSnapshot, nextSnapshot); - } - + ); return nextSnapshot; } -function updateSyncExternalStore(subscribe, getSnapshot) { +function updateSyncExternalStore(subscribe, getSnapshot, getServerSnapshot) { var fiber = currentlyRenderingFiber$1; var hook = updateWorkInProgressHook(); // Read the current snapshot from the store on every render. This breaks the // normal rules of React, and only works because store updates are @@ -11084,8 +11202,8 @@ function updateSyncExternalStore(subscribe, getSnapshot) { var root = getWorkInProgressRoot(); - if (!(root !== null)) { - throw Error( + if (root === null) { + throw new Error( "Expected a work-in-progress root. This is a bug in React. Please file an issue." ); } @@ -11182,7 +11300,7 @@ function mountState(initialState) { lastRenderedState: initialState }; hook.queue = queue; - var dispatch = (queue.dispatch = dispatchAction.bind( + var dispatch = (queue.dispatch = dispatchSetState.bind( null, currentlyRenderingFiber$1, queue @@ -11646,7 +11764,7 @@ function rerenderOpaqueIdentifier() { return id; } -function dispatchAction(fiber, queue, action) { +function dispatchReducerAction(fiber, queue, action) { { if (typeof arguments[3] === "function") { error( @@ -11657,65 +11775,54 @@ function dispatchAction(fiber, queue, action) { } } - var eventTime = requestEventTime(); var lane = requestUpdateLane(fiber); var update = { lane: lane, action: action, - eagerReducer: null, + hasEagerState: false, eagerState: null, next: null }; - var alternate = fiber.alternate; - if ( - fiber === currentlyRenderingFiber$1 || - (alternate !== null && alternate === currentlyRenderingFiber$1) - ) { - // This is a render phase update. Stash it in a lazily-created map of - // queue -> linked list of updates. After this render pass, we'll restart - // and apply the stashed updates on top of the work-in-progress hook. - didScheduleRenderPhaseUpdateDuringThisPass = didScheduleRenderPhaseUpdate = true; - var pending = queue.pending; - - if (pending === null) { - // This is the first update. Create a circular list. - update.next = update; - } else { - update.next = pending.next; - pending.next = update; - } - - queue.pending = update; + if (isRenderPhaseUpdate(fiber)) { + enqueueRenderPhaseUpdate(queue, update); } else { - if (isInterleavedUpdate(fiber)) { - var interleaved = queue.interleaved; + enqueueUpdate$1(fiber, queue, update); - if (interleaved === null) { - // This is the first update. Create a circular list. - update.next = update; // At the end of the current render, this queue's interleaved updates will - // be transferred to the pending queue. + var eventTime = requestEventTime(); + var root = scheduleUpdateOnFiber(fiber, lane, eventTime); - pushInterleavedQueue(queue); - } else { - update.next = interleaved.next; - interleaved.next = update; - } - - queue.interleaved = update; - } else { - var _pending = queue.pending; - - if (_pending === null) { - // This is the first update. Create a circular list. - update.next = update; - } else { - update.next = _pending.next; - _pending.next = update; - } - - queue.pending = update; + if (root !== null) { + entangleTransitionUpdate(root, queue, lane); } + } +} + +function dispatchSetState(fiber, queue, action) { + { + if (typeof arguments[3] === "function") { + error( + "State updates from the useState() and useReducer() Hooks don't support the " + + "second callback argument. To execute a side effect after " + + "rendering, declare it in the component body with useEffect()." + ); + } + } + + var lane = requestUpdateLane(fiber); + var update = { + lane: lane, + action: action, + hasEagerState: false, + eagerState: null, + next: null + }; + + if (isRenderPhaseUpdate(fiber)) { + enqueueRenderPhaseUpdate(queue, update); + } else { + enqueueUpdate$1(fiber, queue, update); + var alternate = fiber.alternate; if ( fiber.lanes === NoLanes && @@ -11741,7 +11848,7 @@ function dispatchAction(fiber, queue, action) { // time we enter the render phase, then the eager state can be used // without calling the reducer again. - update.eagerReducer = lastRenderedReducer; + update.hasEagerState = true; update.eagerState = eagerState; if (objectIs(eagerState, currentState)) { @@ -11761,27 +11868,91 @@ function dispatchAction(fiber, queue, action) { } } + var eventTime = requestEventTime(); var root = scheduleUpdateOnFiber(fiber, lane, eventTime); - if (isTransitionLane(lane) && root !== null) { - var queueLanes = queue.lanes; // If any entangled lanes are no longer pending on the root, then they - // must have finished. We can remove them from the shared queue, which - // represents a superset of the actually pending lanes. In some cases we - // may entangle more than we need to, but that's OK. In fact it's worse if - // we *don't* entangle when we should. - - queueLanes = intersectLanes(queueLanes, root.pendingLanes); // Entangle the new transition lane with the other transition lanes. - - var newQueueLanes = mergeLanes(queueLanes, lane); - queue.lanes = newQueueLanes; // Even if queue.lanes already include lane, we don't know for certain if - // the lane finished since the last time we entangled it. So we need to - // entangle it again, just to be sure. - - markRootEntangled(root, newQueueLanes); + if (root !== null) { + entangleTransitionUpdate(root, queue, lane); } } } +function isRenderPhaseUpdate(fiber) { + var alternate = fiber.alternate; + return ( + fiber === currentlyRenderingFiber$1 || + (alternate !== null && alternate === currentlyRenderingFiber$1) + ); +} + +function enqueueRenderPhaseUpdate(queue, update) { + // This is a render phase update. Stash it in a lazily-created map of + // queue -> linked list of updates. After this render pass, we'll restart + // and apply the stashed updates on top of the work-in-progress hook. + didScheduleRenderPhaseUpdateDuringThisPass = didScheduleRenderPhaseUpdate = true; + var pending = queue.pending; + + if (pending === null) { + // This is the first update. Create a circular list. + update.next = update; + } else { + update.next = pending.next; + pending.next = update; + } + + queue.pending = update; +} + +function enqueueUpdate$1(fiber, queue, update, lane) { + if (isInterleavedUpdate(fiber)) { + var interleaved = queue.interleaved; + + if (interleaved === null) { + // This is the first update. Create a circular list. + update.next = update; // At the end of the current render, this queue's interleaved updates will + // be transferred to the pending queue. + + pushInterleavedQueue(queue); + } else { + update.next = interleaved.next; + interleaved.next = update; + } + + queue.interleaved = update; + } else { + var pending = queue.pending; + + if (pending === null) { + // This is the first update. Create a circular list. + update.next = update; + } else { + update.next = pending.next; + pending.next = update; + } + + queue.pending = update; + } +} + +function entangleTransitionUpdate(root, queue, lane) { + if (isTransitionLane(lane)) { + var queueLanes = queue.lanes; // If any entangled lanes are no longer pending on the root, then they + // must have finished. We can remove them from the shared queue, which + // represents a superset of the actually pending lanes. In some cases we + // may entangle more than we need to, but that's OK. In fact it's worse if + // we *don't* entangle when we should. + + queueLanes = intersectLanes(queueLanes, root.pendingLanes); // Entangle the new transition lane with the other transition lanes. + + var newQueueLanes = mergeLanes(queueLanes, lane); + queue.lanes = newQueueLanes; // Even if queue.lanes already include lane, we don't know for certain if + // the lane finished since the last time we entangled it. So we need to + // entangle it again, just to be sure. + + markRootEntangled(root, newQueueLanes); + } +} + var ContextOnlyDispatcher = { readContext: readContext, useCallback: throwInvalidHookError, @@ -11931,7 +12102,7 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; mountHookTypesDev(); return mountMutableSource(source, getSnapshot, subscribe); }, - useSyncExternalStore: function(subscribe, getSnapshot) { + useSyncExternalStore: function(subscribe, getSnapshot, getServerSnapshot) { currentHookNameInDev = "useSyncExternalStore"; mountHookTypesDev(); return mountSyncExternalStore(subscribe, getSnapshot); @@ -12039,7 +12210,7 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; updateHookTypesDev(); return mountMutableSource(source, getSnapshot, subscribe); }, - useSyncExternalStore: function(subscribe, getSnapshot) { + useSyncExternalStore: function(subscribe, getSnapshot, getServerSnapshot) { currentHookNameInDev = "useSyncExternalStore"; updateHookTypesDev(); return mountSyncExternalStore(subscribe, getSnapshot); @@ -12147,7 +12318,7 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; updateHookTypesDev(); return updateMutableSource(source, getSnapshot, subscribe); }, - useSyncExternalStore: function(subscribe, getSnapshot) { + useSyncExternalStore: function(subscribe, getSnapshot, getServerSnapshot) { currentHookNameInDev = "useSyncExternalStore"; updateHookTypesDev(); return updateSyncExternalStore(subscribe, getSnapshot); @@ -12255,7 +12426,7 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; updateHookTypesDev(); return updateMutableSource(source, getSnapshot, subscribe); }, - useSyncExternalStore: function(subscribe, getSnapshot) { + useSyncExternalStore: function(subscribe, getSnapshot, getServerSnapshot) { currentHookNameInDev = "useSyncExternalStore"; updateHookTypesDev(); return updateSyncExternalStore(subscribe, getSnapshot); @@ -12378,7 +12549,7 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; mountHookTypesDev(); return mountMutableSource(source, getSnapshot, subscribe); }, - useSyncExternalStore: function(subscribe, getSnapshot) { + useSyncExternalStore: function(subscribe, getSnapshot, getServerSnapshot) { currentHookNameInDev = "useSyncExternalStore"; warnInvalidHookAccess(); mountHookTypesDev(); @@ -12503,7 +12674,7 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; updateHookTypesDev(); return updateMutableSource(source, getSnapshot, subscribe); }, - useSyncExternalStore: function(subscribe, getSnapshot) { + useSyncExternalStore: function(subscribe, getSnapshot, getServerSnapshot) { currentHookNameInDev = "useSyncExternalStore"; warnInvalidHookAccess(); updateHookTypesDev(); @@ -12628,7 +12799,7 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; updateHookTypesDev(); return updateMutableSource(source, getSnapshot, subscribe); }, - useSyncExternalStore: function(subscribe, getSnapshot) { + useSyncExternalStore: function(subscribe, getSnapshot, getServerSnapshot) { currentHookNameInDev = "useSyncExternalStore"; warnInvalidHookAccess(); updateHookTypesDev(); @@ -12820,12 +12991,10 @@ function createCapturedValue(value, source) { } if ( - !( - typeof ReactNativePrivateInterface.ReactFiberErrorDialog.showErrorDialog === - "function" - ) + typeof ReactNativePrivateInterface.ReactFiberErrorDialog.showErrorDialog !== + "function" ) { - throw Error( + throw new Error( "Expected ReactFiberErrorDialog.showErrorDialog to be a function." ); } @@ -13011,42 +13180,250 @@ function createClassErrorUpdate(fiber, errorInfo, lane) { return update; } -function attachPingListener(root, wakeable, lanes) { - // Attach a listener to the promise to "ping" the root and retry. But only if - // one does not already exist for the lanes we're currently rendering (which - // acts like a "thread ID" here). - var pingCache = root.pingCache; - var threadIDs; +function attachWakeableListeners(suspenseBoundary, root, wakeable, lanes) { + // Attach a ping listener + // + // The data might resolve before we have a chance to commit the fallback. Or, + // in the case of a refresh, we'll never commit a fallback. So we need to + // attach a listener now. When it resolves ("pings"), we can decide whether to + // try rendering the tree again. + // + // Only attach a listener if one does not already exist for the lanes + // we're currently rendering (which acts like a "thread ID" here). + // + // We only need to do this in concurrent mode. Legacy Suspense always + // commits fallbacks synchronously, so there are no pings. + if (suspenseBoundary.mode & ConcurrentMode) { + var pingCache = root.pingCache; + var threadIDs; - if (pingCache === null) { - pingCache = root.pingCache = new PossiblyWeakMap$1(); - threadIDs = new Set(); - pingCache.set(wakeable, threadIDs); - } else { - threadIDs = pingCache.get(wakeable); - - if (threadIDs === undefined) { + if (pingCache === null) { + pingCache = root.pingCache = new PossiblyWeakMap$1(); threadIDs = new Set(); pingCache.set(wakeable, threadIDs); - } - } + } else { + threadIDs = pingCache.get(wakeable); - if (!threadIDs.has(lanes)) { - // Memoize using the thread ID to prevent redundant listeners. - threadIDs.add(lanes); - var ping = pingSuspendedRoot.bind(null, root, wakeable, lanes); - - { - if (isDevToolsPresent) { - // If we have pending work still, restore the original updaters - restorePendingUpdaters(root, lanes); + if (threadIDs === undefined) { + threadIDs = new Set(); + pingCache.set(wakeable, threadIDs); } } - wakeable.then(ping, ping); + if (!threadIDs.has(lanes)) { + // Memoize using the thread ID to prevent redundant listeners. + threadIDs.add(lanes); + var ping = pingSuspendedRoot.bind(null, root, wakeable, lanes); + + { + if (isDevToolsPresent) { + // If we have pending work still, restore the original updaters + restorePendingUpdaters(root, lanes); + } + } + + wakeable.then(ping, ping); + } + } // Retry listener + // + // If the fallback does commit, we need to attach a different type of + // listener. This one schedules an update on the Suspense boundary to turn + // the fallback state off. + // + // Stash the wakeable on the boundary fiber so we can access it in the + // commit phase. + // + // When the wakeable resolves, we'll attempt to render the boundary + // again ("retry"). + + var wakeables = suspenseBoundary.updateQueue; + + if (wakeables === null) { + var updateQueue = new Set(); + updateQueue.add(wakeable); + suspenseBoundary.updateQueue = updateQueue; + } else { + wakeables.add(wakeable); } } +function resetSuspendedComponent(sourceFiber, rootRenderLanes) { + // A legacy mode Suspense quirk, only relevant to hook components. + + var tag = sourceFiber.tag; + + if ( + (sourceFiber.mode & ConcurrentMode) === NoMode && + (tag === FunctionComponent || + tag === ForwardRef || + tag === SimpleMemoComponent) + ) { + var currentSource = sourceFiber.alternate; + + if (currentSource) { + sourceFiber.updateQueue = currentSource.updateQueue; + sourceFiber.memoizedState = currentSource.memoizedState; + sourceFiber.lanes = currentSource.lanes; + } else { + sourceFiber.updateQueue = null; + sourceFiber.memoizedState = null; + } + } +} + +function markNearestSuspenseBoundaryShouldCapture( + returnFiber, + sourceFiber, + root, + rootRenderLanes +) { + var hasInvisibleParentBoundary = hasSuspenseContext( + suspenseStackCursor.current, + InvisibleParentSuspenseContext + ); + var node = returnFiber; + + do { + if ( + node.tag === SuspenseComponent && + shouldCaptureSuspense(node, hasInvisibleParentBoundary) + ) { + // Found the nearest boundary. + var suspenseBoundary = node; // This marks a Suspense boundary so that when we're unwinding the stack, + // it captures the suspended "exception" and does a second (fallback) pass. + + if ((suspenseBoundary.mode & ConcurrentMode) === NoMode) { + // Legacy Mode Suspense + // + // If the boundary is in legacy mode, we should *not* + // suspend the commit. Pretend as if the suspended component rendered + // null and keep rendering. When the Suspense boundary completes, + // we'll do a second pass to render the fallback. + if (suspenseBoundary === returnFiber) { + // Special case where we suspended while reconciling the children of + // a Suspense boundary's inner Offscreen wrapper fiber. This happens + // when a React.lazy component is a direct child of a + // Suspense boundary. + // + // Suspense boundaries are implemented as multiple fibers, but they + // are a single conceptual unit. The legacy mode behavior where we + // pretend the suspended fiber committed as `null` won't work, + // because in this case the "suspended" fiber is the inner + // Offscreen wrapper. + // + // Because the contents of the boundary haven't started rendering + // yet (i.e. nothing in the tree has partially rendered) we can + // switch to the regular, concurrent mode behavior: mark the + // boundary with ShouldCapture and enter the unwind phase. + suspenseBoundary.flags |= ShouldCapture; + } else { + suspenseBoundary.flags |= DidCapture; + sourceFiber.flags |= ForceUpdateForLegacySuspense; // We're going to commit this fiber even though it didn't complete. + // But we shouldn't call any lifecycle methods or callbacks. Remove + // all lifecycle effect tags. + + sourceFiber.flags &= ~(LifecycleEffectMask | Incomplete); + + if (enablePersistentOffscreenHostContainer) { + // Another legacy Suspense quirk. In persistent mode, if this is the + // initial mount, override the props of the host container to hide + // its contents. + var currentSuspenseBoundary = suspenseBoundary.alternate; + + if (currentSuspenseBoundary === null) { + var offscreenFiber = suspenseBoundary.child; + var offscreenContainer = offscreenFiber.child; + + if (offscreenContainer !== null) { + var children = offscreenContainer.memoizedProps.children; + var containerProps = getOffscreenContainerProps( + "hidden", + children + ); + offscreenContainer.pendingProps = containerProps; + offscreenContainer.memoizedProps = containerProps; + } + } + } + + if (sourceFiber.tag === ClassComponent) { + var currentSourceFiber = sourceFiber.alternate; + + if (currentSourceFiber === null) { + // This is a new mount. Change the tag so it's not mistaken for a + // completed class component. For example, we should not call + // componentWillUnmount if it is deleted. + sourceFiber.tag = IncompleteClassComponent; + } else { + // When we try rendering again, we should not reuse the current fiber, + // since it's known to be in an inconsistent state. Use a force update to + // prevent a bail out. + var update = createUpdate(NoTimestamp, SyncLane); + update.tag = ForceUpdate; + enqueueUpdate(sourceFiber, update); + } + } // The source fiber did not complete. Mark it with Sync priority to + // indicate that it still has pending work. + + sourceFiber.lanes = mergeLanes(sourceFiber.lanes, SyncLane); + } + + return suspenseBoundary; + } // Confirmed that the boundary is in a concurrent mode tree. Continue + // with the normal suspend path. + // + // After this we'll use a set of heuristics to determine whether this + // render pass will run to completion or restart or "suspend" the commit. + // The actual logic for this is spread out in different places. + // + // This first principle is that if we're going to suspend when we complete + // a root, then we should also restart if we get an update or ping that + // might unsuspend it, and vice versa. The only reason to suspend is + // because you think you might want to restart before committing. However, + // it doesn't make sense to restart only while in the period we're suspended. + // + // Restarting too aggressively is also not good because it starves out any + // intermediate loading state. So we use heuristics to determine when. + // Suspense Heuristics + // + // If nothing threw a Promise or all the same fallbacks are already showing, + // then don't suspend/restart. + // + // If this is an initial render of a new tree of Suspense boundaries and + // those trigger a fallback, then don't suspend/restart. We want to ensure + // that we can show the initial loading state as quickly as possible. + // + // If we hit a "Delayed" case, such as when we'd switch from content back into + // a fallback, then we should always suspend/restart. Transitions apply + // to this case. If none is defined, JND is used instead. + // + // If we're already showing a fallback and it gets "retried", allowing us to show + // another level, but there's still an inner boundary that would show a fallback, + // then we suspend/restart for 500ms since the last time we showed a fallback + // anywhere in the tree. This effectively throttles progressive loading into a + // consistent train of commits. This also gives us an opportunity to restart to + // get to the completed state slightly earlier. + // + // If there's ambiguity due to batching it's resolved in preference of: + // 1) "delayed", 2) "initial render", 3) "retry". + // + // We want to ensure that a "busy" state doesn't get force committed. We want to + // ensure that new initial loading states can commit as soon as possible. + + suspenseBoundary.flags |= ShouldCapture; // TODO: I think we can remove this, since we now use `DidCapture` in + // the begin phase to prevent an early bailout. + + suspenseBoundary.lanes = rootRenderLanes; + return suspenseBoundary; + } // This boundary already captured during this render. Continue to the next + // boundary. + + node = node.return; + } while (node !== null); // Could not find a Suspense boundary capable of capturing. + + return null; +} + function throwException( root, returnFiber, @@ -13069,182 +13446,37 @@ function throwException( typeof value === "object" && typeof value.then === "function" ) { + // This is a wakeable. The component suspended. var wakeable = value; - // A legacy mode Suspense quirk, only relevant to hook components. + resetSuspendedComponent(sourceFiber); - var tag = sourceFiber.tag; - - if ( - (sourceFiber.mode & ConcurrentMode) === NoMode && - (tag === FunctionComponent || - tag === ForwardRef || - tag === SimpleMemoComponent) - ) { - var currentSource = sourceFiber.alternate; - - if (currentSource) { - sourceFiber.updateQueue = currentSource.updateQueue; - sourceFiber.memoizedState = currentSource.memoizedState; - sourceFiber.lanes = currentSource.lanes; - } else { - sourceFiber.updateQueue = null; - sourceFiber.memoizedState = null; - } - } - - var hasInvisibleParentBoundary = hasSuspenseContext( - suspenseStackCursor.current, - InvisibleParentSuspenseContext - ); // Schedule the nearest Suspense to re-render the timed out view. - - var _workInProgress = returnFiber; - - do { - if ( - _workInProgress.tag === SuspenseComponent && - shouldCaptureSuspense(_workInProgress, hasInvisibleParentBoundary) - ) { - // Found the nearest boundary. - // Stash the promise on the boundary fiber. If the boundary times out, we'll - // attach another listener to flip the boundary back to its normal state. - var wakeables = _workInProgress.updateQueue; - - if (wakeables === null) { - var updateQueue = new Set(); - updateQueue.add(wakeable); - _workInProgress.updateQueue = updateQueue; - } else { - wakeables.add(wakeable); - } // If the boundary is in legacy mode, we should *not* - // suspend the commit. Pretend as if the suspended component rendered - // null and keep rendering. In the commit phase, we'll schedule a - // subsequent synchronous update to re-render the Suspense. - // - // 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 the suspense boundary suspended itself suspended, we don't have to - // do this trick because nothing was partially started. We can just - // directly do a second pass over the fallback in this render and - // pretend we meant to render that directly. - - if ( - (_workInProgress.mode & ConcurrentMode) === NoMode && - _workInProgress !== returnFiber - ) { - _workInProgress.flags |= DidCapture; - sourceFiber.flags |= ForceUpdateForLegacySuspense; // We're going to commit this fiber even though it didn't complete. - // But we shouldn't call any lifecycle methods or callbacks. Remove - // all lifecycle effect tags. - - sourceFiber.flags &= ~(LifecycleEffectMask | Incomplete); - - if (enablePersistentOffscreenHostContainer) { - // Another legacy Suspense quirk. In persistent mode, if this is the - // initial mount, override the props of the host container to hide - // its contents. - var currentSuspenseBoundary = _workInProgress.alternate; - - if (currentSuspenseBoundary === null) { - var offscreenFiber = _workInProgress.child; - var offscreenContainer = offscreenFiber.child; - - if (offscreenContainer !== null) { - var children = offscreenContainer.memoizedProps.children; - var containerProps = getOffscreenContainerProps( - "hidden", - children - ); - offscreenContainer.pendingProps = containerProps; - offscreenContainer.memoizedProps = containerProps; - } - } - } - - if (sourceFiber.tag === ClassComponent) { - var _currentSourceFiber = sourceFiber.alternate; - - if (_currentSourceFiber === null) { - // This is a new mount. Change the tag so it's not mistaken for a - // completed class component. For example, we should not call - // componentWillUnmount if it is deleted. - sourceFiber.tag = IncompleteClassComponent; - } else { - // When we try rendering again, we should not reuse the current fiber, - // since it's known to be in an inconsistent state. Use a force update to - // prevent a bail out. - var update = createUpdate(NoTimestamp, SyncLane); - update.tag = ForceUpdate; - enqueueUpdate(sourceFiber, update); - } - } // The source fiber did not complete. Mark it with Sync priority to - // indicate that it still has pending work. - - sourceFiber.lanes = mergeLanes(sourceFiber.lanes, SyncLane); // Exit without suspending. - - return; - } // Confirmed that the boundary is in a concurrent mode tree. Continue - // with the normal suspend path. - // - // After this we'll use a set of heuristics to determine whether this - // render pass will run to completion or restart or "suspend" the commit. - // The actual logic for this is spread out in different places. - // - // This first principle is that if we're going to suspend when we complete - // a root, then we should also restart if we get an update or ping that - // might unsuspend it, and vice versa. The only reason to suspend is - // because you think you might want to restart before committing. However, - // it doesn't make sense to restart only while in the period we're suspended. - // - // Restarting too aggressively is also not good because it starves out any - // intermediate loading state. So we use heuristics to determine when. - // Suspense Heuristics - // - // If nothing threw a Promise or all the same fallbacks are already showing, - // then don't suspend/restart. - // - // If this is an initial render of a new tree of Suspense boundaries and - // those trigger a fallback, then don't suspend/restart. We want to ensure - // that we can show the initial loading state as quickly as possible. - // - // If we hit a "Delayed" case, such as when we'd switch from content back into - // a fallback, then we should always suspend/restart. Transitions apply - // to this case. If none is defined, JND is used instead. - // - // If we're already showing a fallback and it gets "retried", allowing us to show - // another level, but there's still an inner boundary that would show a fallback, - // then we suspend/restart for 500ms since the last time we showed a fallback - // anywhere in the tree. This effectively throttles progressive loading into a - // consistent train of commits. This also gives us an opportunity to restart to - // get to the completed state slightly earlier. - // - // If there's ambiguity due to batching it's resolved in preference of: - // 1) "delayed", 2) "initial render", 3) "retry". - // - // We want to ensure that a "busy" state doesn't get force committed. We want to - // ensure that new initial loading states can commit as soon as possible. - - attachPingListener(root, wakeable, rootRenderLanes); - _workInProgress.flags |= ShouldCapture; // TODO: I think we can remove this, since we now use `DidCapture` in - // the begin phase to prevent an early bailout. - - _workInProgress.lanes = rootRenderLanes; - return; - } // This boundary already captured during this render. Continue to the next - // boundary. - - _workInProgress = _workInProgress.return; - } while (_workInProgress !== null); // No boundary was found. Fallthrough to error mode. - // TODO: Use invariant so the message is stripped in prod? - - value = new Error( - (getComponentNameFromFiber(sourceFiber) || "A React component") + - " suspended while rendering, but no fallback UI was specified.\n" + - "\n" + - "Add a component higher in the tree to " + - "provide a loading indicator or placeholder to display." + var suspenseBoundary = markNearestSuspenseBoundaryShouldCapture( + returnFiber, + sourceFiber, + root, + rootRenderLanes ); + + if (suspenseBoundary !== null) { + attachWakeableListeners( + suspenseBoundary, + root, + wakeable, + rootRenderLanes + ); + return; + } else { + // No boundary was found. Fallthrough to error mode. + // TODO: We should never call getComponentNameFromFiber in production. + // Log a warning or something to prevent us from accidentally bundling it. + value = new Error( + (getComponentNameFromFiber(sourceFiber) || "A React component") + + " suspended while rendering, but no fallback UI was specified.\n" + + "\n" + + "Add a component higher in the tree to " + + "provide a loading indicator or placeholder to display." + ); + } } // 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. @@ -13260,10 +13492,8 @@ function throwException( workInProgress.flags |= ShouldCapture; var lane = pickArbitraryLane(rootRenderLanes); workInProgress.lanes = mergeLanes(workInProgress.lanes, lane); - - var _update = createRootErrorUpdate(workInProgress, _errorInfo, lane); - - enqueueCapturedUpdate(workInProgress, _update); + var update = createRootErrorUpdate(workInProgress, _errorInfo, lane); + enqueueCapturedUpdate(workInProgress, update); return; } @@ -13286,13 +13516,13 @@ function throwException( workInProgress.lanes = mergeLanes(workInProgress.lanes, _lane); // Schedule the error boundary to re-render using updated state - var _update2 = createClassErrorUpdate( + var _update = createClassErrorUpdate( workInProgress, errorInfo, _lane ); - enqueueCapturedUpdate(workInProgress, _update2); + enqueueCapturedUpdate(workInProgress, _update); return; } @@ -13863,7 +14093,7 @@ function completeWork(current, workInProgress, renderLanes) { // If we hydrated, then we'll need to schedule an update for // the commit side-effects on the root. markUpdate(workInProgress); - } else if (!fiberRoot.hydrate) { + } else if (!fiberRoot.isDehydrated) { // Schedule an effect to clear this container at the start of the next commit. // This handles the case of React rendering into a container with previous children. // It's also safe to do for updates too, because current.child would only be null @@ -13896,9 +14126,10 @@ function completeWork(current, workInProgress, renderLanes) { } } else { if (!newProps) { - if (!(workInProgress.stateNode !== null)) { - throw Error( - "We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue." + if (workInProgress.stateNode === null) { + throw new Error( + "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. @@ -13953,9 +14184,10 @@ function completeWork(current, workInProgress, renderLanes) { updateHostText(current, workInProgress, oldText, newText); } else { if (typeof newText !== "string") { - if (!(workInProgress.stateNode !== null)) { - throw Error( - "We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue." + if (workInProgress.stateNode === null) { + throw new Error( + "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. } @@ -14359,13 +14591,12 @@ function completeWork(current, workInProgress, renderLanes) { } } - { - throw Error( - "Unknown unit of work tag (" + - workInProgress.tag + - "). This error is likely caused by a bug in React. Please file an issue." - ); - } + throw new Error( + "Unknown unit of work tag (" + + workInProgress.tag + + "). This error is likely caused by a bug in " + + "React. Please file an issue." + ); } var ReactCurrentOwner$1 = ReactSharedInternals.ReactCurrentOwner; @@ -15022,7 +15253,8 @@ function updateClassComponent( case true: { workInProgress.flags |= DidCapture; - workInProgress.flags |= ShouldCapture; + workInProgress.flags |= ShouldCapture; // eslint-disable-next-line react-internal/prod-error-codes + var error$1 = new Error("Simulated error coming from DevTools"); var lane = pickArbitraryLane(renderLanes); workInProgress.lanes = mergeLanes(workInProgress.lanes, lane); // Schedule the error boundary to re-render using updated state @@ -15236,9 +15468,11 @@ function updateHostRoot(current, workInProgress, renderLanes) { pushHostRootContext(workInProgress); var updateQueue = workInProgress.updateQueue; - if (!(current !== null && updateQueue !== null)) { - throw Error( - "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." + if (current === null || updateQueue === null) { + throw new Error( + "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." ); } @@ -15257,7 +15491,7 @@ function updateHostRoot(current, workInProgress, renderLanes) { return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes); } - if (root.hydrate && enterHydrationState()) { + if (root.isDehydrated && enterHydrationState()) { var child = mountChildFibers( workInProgress, null, @@ -15433,14 +15667,12 @@ function mountLazyComponent( // because the fact that it's a separate type of work is an // implementation detail. - { - throw Error( - "Element type is invalid. Received a promise that resolves to: " + - Component + - ". Lazy element type must resolve to a class or function." + - hint - ); - } + throw new Error( + "Element type is invalid. Received a promise that resolves to: " + + Component + + ". " + + ("Lazy element type must resolve to a class or function." + hint) + ); } function mountIncompleteClassComponent( @@ -16824,6 +17056,7 @@ function remountFiber(current, oldWorkInProgress, newWorkInProgress) { var returnFiber = oldWorkInProgress.return; if (returnFiber === null) { + // eslint-disable-next-line react-internal/prod-error-codes throw new Error("Cannot swap the root fiber."); } // Disconnect from the old current. // It will get deleted. @@ -16842,6 +17075,7 @@ function remountFiber(current, oldWorkInProgress, newWorkInProgress) { var prevSibling = returnFiber.child; if (prevSibling === null) { + // eslint-disable-next-line react-internal/prod-error-codes throw new Error("Expected parent to have a child."); } @@ -16849,6 +17083,7 @@ function remountFiber(current, oldWorkInProgress, newWorkInProgress) { prevSibling = prevSibling.sibling; if (prevSibling === null) { + // eslint-disable-next-line react-internal/prod-error-codes throw new Error("Expected to find the previous sibling."); } } @@ -17318,13 +17553,12 @@ function beginWork(current, workInProgress, renderLanes) { } } - { - throw Error( - "Unknown unit of work tag (" + - workInProgress.tag + - "). This error is likely caused by a bug in React. Please file an issue." - ); - } + throw new Error( + "Unknown unit of work tag (" + + workInProgress.tag + + "). This error is likely caused by a bug in " + + "React. Please file an issue." + ); } function unwindWork(workInProgress, renderLanes) { @@ -17357,9 +17591,10 @@ function unwindWork(workInProgress, renderLanes) { resetWorkInProgressVersions(); var _flags = workInProgress.flags; - if (!((_flags & DidCapture) === NoFlags)) { - throw Error( - "The root failed to unmount after an error. This is likely a bug in React. Please file an issue." + if ((_flags & DidCapture) !== NoFlags) { + throw new Error( + "The root failed to unmount after an error. This is likely a bug in " + + "React. Please file an issue." ); } @@ -17711,11 +17946,10 @@ function commitBeforeMutationEffectsOnFiber(finishedWork) { break; default: { - { - throw Error( - "This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue." - ); - } + throw new Error( + "This unit of work tag should not have side-effects. This error is " + + "likely caused by a bug in React. Please file an issue." + ); } } @@ -18182,11 +18416,11 @@ function commitLayoutEffectOnFiber( case LegacyHiddenComponent: break; - default: { - throw Error( - "This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue." + default: + throw new Error( + "This unit of work tag should not have side-effects. This error is " + + "likely caused by a bug in React. Please file an issue." ); - } } } @@ -18498,11 +18732,10 @@ function commitContainer(finishedWork) { } } - { - throw Error( - "This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue." - ); - } + throw new Error( + "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 commitDeletion(finishedRoot, current, nearestMountedAncestor) { @@ -19693,8 +19926,8 @@ function performConcurrentWorkOnRoot(root, didTimeout) { currentEventTime = NoTimestamp; currentEventTransitionLane = NoLanes; - if (!((executionContext & (RenderContext | CommitContext)) === NoContext)) { - throw Error("Should not already be working."); + if ((executionContext & (RenderContext | CommitContext)) !== NoContext) { + throw new Error("Should not already be working."); } // Flush any pending passive effects before deciding which lanes to work on, // in case they schedule additional work. @@ -19814,8 +20047,8 @@ function recoverFromConcurrentError(root, errorRetryLanes) { executionContext |= RetryAfterError; // If an error occurred during hydration, discard server response and fall // back to client side render. - if (root.hydrate) { - root.hydrate = false; + if (root.isDehydrated) { + root.isDehydrated = false; { errorHydratingContainer(root.containerInfo); @@ -19833,9 +20066,7 @@ function finishConcurrentRender(root, exitStatus, lanes) { switch (exitStatus) { case RootIncomplete: case RootFatalErrored: { - { - throw Error("Root did not complete. This is a bug in React."); - } + throw new Error("Root did not complete. This is a bug in React."); } // Flow knows about invariant, so it complains if I add a break // statement, but eslint doesn't know about invariant, so it complains @@ -19940,9 +20171,7 @@ function finishConcurrentRender(root, exitStatus, lanes) { } default: { - { - throw Error("Unknown root exit status."); - } + throw new Error("Unknown root exit status."); } } } @@ -20025,8 +20254,8 @@ function performSyncWorkOnRoot(root) { syncNestedUpdateFlag(); } - if (!((executionContext & (RenderContext | CommitContext)) === NoContext)) { - throw Error("Should not already be working."); + if ((executionContext & (RenderContext | CommitContext)) !== NoContext) { + throw new Error("Should not already be working."); } flushPassiveEffects(); @@ -20045,8 +20274,8 @@ function performSyncWorkOnRoot(root) { executionContext |= RetryAfterError; // If an error occurred during hydration, // discard server response and fall back to client side render. - if (root.hydrate) { - root.hydrate = false; + if (root.isDehydrated) { + root.isDehydrated = false; { errorHydratingContainer(root.containerInfo); @@ -20108,7 +20337,7 @@ function batchedUpdates$1(fn, a) { // Warning, this opts-out of checking the function body. // eslint-disable-next-line no-redeclare -function flushSyncWithoutWarningIfAlreadyRendering(fn) { +function flushSync(fn) { // In legacy mode, we flush pending passive effects at the beginning of the // next event, not at the end of the previous one. if ( @@ -20144,22 +20373,6 @@ function flushSyncWithoutWarningIfAlreadyRendering(fn) { flushSyncCallbacks(); } } -} // Overload the definition to the two valid signatures. -// Warning, this opts-out of checking the function body. - -// eslint-disable-next-line no-redeclare -function flushSync(fn) { - { - if ((executionContext & (RenderContext | CommitContext)) !== NoContext) { - error( - "flushSync was called from inside a lifecycle method. React cannot " + - "flush when React is already rendering. Consider moving this call to " + - "a scheduler task or micro task." - ); - } - } - - return flushSyncWithoutWarningIfAlreadyRendering(fn); } function pushRenderLanes(fiber, lanes) { push(subtreeRenderLanesCursor, subtreeRenderLanes, fiber); @@ -20248,6 +20461,29 @@ function handleError(root, thrownValue) { stopProfilerTimerIfRunningAndRecordDelta(erroredWork, true); } + if (enableSchedulingProfiler) { + markComponentRenderStopped(); + + if ( + thrownValue !== null && + typeof thrownValue === "object" && + typeof thrownValue.then === "function" + ) { + var wakeable = thrownValue; + markComponentSuspended( + erroredWork, + wakeable, + workInProgressRootRenderLanes + ); + } else { + markComponentErrored( + erroredWork, + thrownValue, + workInProgressRootRenderLanes + ); + } + } + throwException( root, erroredWork.return, @@ -20311,7 +20547,8 @@ function renderDidSuspend() { function renderDidSuspendDelayIfPossible() { if ( workInProgressRootExitStatus === RootIncomplete || - workInProgressRootExitStatus === RootSuspended + workInProgressRootExitStatus === RootSuspended || + workInProgressRootExitStatus === RootErrored ) { workInProgressRootExitStatus = RootSuspendedWithDelay; } // Check if there are updates that we skipped tree that might have unblocked @@ -20333,7 +20570,7 @@ function renderDidSuspendDelayIfPossible() { } } function renderDidError() { - if (workInProgressRootExitStatus !== RootCompleted) { + if (workInProgressRootExitStatus !== RootSuspendedWithDelay) { workInProgressRootExitStatus = RootErrored; } } // Called during render to determine if anything has suspended. @@ -20386,11 +20623,10 @@ function renderRootSync(root, lanes) { if (workInProgress !== null) { // This is a sync render, so we should have finished the whole tree. - { - throw Error( - "Cannot commit an incomplete root. This error is likely caused by a bug in React. Please file an issue." - ); - } + throw new Error( + "Cannot commit an incomplete root. This error is likely caused by a " + + "bug in React. Please file an issue." + ); } workInProgressRoot = null; @@ -20614,8 +20850,8 @@ function commitRootImpl(root, renderPriorityLevel) { flushRenderPhaseStrictModeWarningsInDEV(); - if (!((executionContext & (RenderContext | CommitContext)) === NoContext)) { - throw Error("Should not already be working."); + if ((executionContext & (RenderContext | CommitContext)) !== NoContext) { + throw new Error("Should not already be working."); } var finishedWork = root.finishedWork; @@ -20637,9 +20873,10 @@ function commitRootImpl(root, renderPriorityLevel) { root.finishedWork = null; root.finishedLanes = NoLanes; - if (!(finishedWork !== root.current)) { - throw Error( - "Cannot commit the same tree as before. This error is likely caused by a bug in React. Please file an issue." + if (finishedWork === root.current) { + throw new Error( + "Cannot commit the same tree as before. This error is likely caused by " + + "a bug in React. Please file an issue." ); } // commitRoot never returns a continuation; it always finishes synchronously. // So we can clear these now to allow a new callback to be scheduled. @@ -20881,8 +21118,8 @@ function flushPassiveEffectsImpl() { pendingPassiveEffectsLanes = NoLanes; - if (!((executionContext & (RenderContext | CommitContext)) === NoContext)) { - throw Error("Cannot flush passive effects while already rendering."); + if ((executionContext & (RenderContext | CommitContext)) !== NoContext) { + throw new Error("Cannot flush passive effects while already rendering."); } var prevExecutionContext = executionContext; @@ -21128,12 +21365,12 @@ function checkForNestedUpdates() { if (nestedUpdateCount > NESTED_UPDATE_LIMIT) { nestedUpdateCount = 0; rootWithNestedUpdates = null; - - { - throw Error( - "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." - ); - } + throw new Error( + "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." + ); } { @@ -21339,7 +21576,7 @@ var beginWork$1; originalError._suppressLogging = true; } } // We always throw the original error in case the second render pass is not idempotent. - // This can happen if a memoized function or CommonJS module doesn't throw after first invokation. + // This can happen if a memoized function or CommonJS module doesn't throw after first invocation. throw originalError; } @@ -21448,6 +21685,7 @@ function shouldForceFlushFallbacksInDEV() { return ReactCurrentActQueue.current !== null; } +/* eslint-disable react-internal/prod-error-codes */ var resolveFamily = null; // $FlowFixMe Flow gets confused by a WeakSet feature check below. var failedBoundaries = null; @@ -22341,14 +22579,11 @@ function createFiberFromTypeAndProps( } } - { - throw Error( - "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 - ); - } + throw new Error( + "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) + ); } } } @@ -22530,7 +22765,7 @@ function FiberRootNode(containerInfo, tag, hydrate) { this.timeoutHandle = noTimeout; this.context = null; this.pendingContext = null; - this.hydrate = hydrate; + this.isDehydrated = hydrate; this.callbackNode = null; this.callbackPriority = NoLane; this.eventTimes = createLaneMap(NoLanes); @@ -22561,11 +22796,11 @@ function FiberRootNode(containerInfo, tag, hydrate) { { switch (tag) { case ConcurrentRoot: - this._debugRootType = "createRoot()"; + this._debugRootType = hydrate ? "hydrateRoot()" : "createRoot()"; break; case LegacyRoot: - this._debugRootType = "createLegacyRoot()"; + this._debugRootType = hydrate ? "hydrate()" : "render()"; break; } } @@ -22608,6 +22843,11 @@ function createPortal( ) { var key = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null; + + { + checkKeyStringCoercion(key); + } + return { // This tag allow us to uniquely identify this as a React Portal $$typeof: REACT_PORTAL_TYPE, @@ -22651,16 +22891,12 @@ function findHostInstanceWithWarning(component, methodName) { if (fiber === undefined) { if (typeof component.render === "function") { - { - throw Error("Unable to find node on an unmounted component."); - } + throw new Error("Unable to find node on an unmounted component."); } else { - { - throw Error( - "Argument appears to not be a ReactComponent. Keys: " + - Object.keys(component) - ); - } + var keys = Object.keys(component).join(","); + throw new Error( + "Argument appears to not be a ReactComponent. Keys: " + keys + ); } } @@ -22829,7 +23065,6 @@ var shouldSuspendImpl = function(fiber) { function shouldSuspend(fiber) { return shouldSuspendImpl(fiber); } -var isStrictMode = false; var overrideHookState = null; var overrideHookStateDeletePath = null; var overrideHookStateRenamePath = null; @@ -23052,20 +23287,6 @@ function getCurrentFiberForDevTools() { return current; } -function getIsStrictModeForDevtools() { - return isStrictMode; -} -function setIsStrictModeForDevtools(newIsStrictMode) { - isStrictMode = newIsStrictMode; - - { - if (newIsStrictMode) { - disableLogs(); - } else { - reenableLogs(); - } - } -} function injectIntoDevTools(devToolsConfig) { var findFiberByHostInstance = devToolsConfig.findFiberByHostInstance; var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher; @@ -23094,7 +23315,6 @@ function injectIntoDevTools(devToolsConfig) { setRefreshHandler: setRefreshHandler, // Enables DevTools to append owner stacks to error messages in DEV mode. getCurrentFiber: getCurrentFiberForDevTools, - getIsStrictMode: getIsStrictModeForDevtools, // Enables DevTools to detect reconciler version rather than renderer version // which may not match for third party renderers. reconcilerVersion: ReactVersion diff --git a/Libraries/Renderer/implementations/ReactFabric-prod.fb.js b/Libraries/Renderer/implementations/ReactFabric-prod.fb.js index 6a8a0754f0..73b6f5eb76 100644 --- a/Libraries/Renderer/implementations/ReactFabric-prod.fb.js +++ b/Libraries/Renderer/implementations/ReactFabric-prod.fb.js @@ -7,7 +7,7 @@ * @noflow * @nolint * @preventMunge - * @generated SignedSource<<4538b6a9895755454ebc3d0f7b8f568e>> + * @generated SignedSource<<0641813b146d4710c4029f156d65891e>> */ "use strict"; @@ -783,18 +783,16 @@ function recomputePluginOrdering() { for (var pluginName in namesToPlugins) { var pluginModule = namesToPlugins[pluginName], pluginIndex = eventPluginOrder.indexOf(pluginName); - if (!(-1 < pluginIndex)) + if (-1 >= pluginIndex) throw Error( "EventPluginRegistry: Cannot inject event plugins that do not exist in the plugin ordering, `" + - pluginName + - "`." + (pluginName + "`.") ); if (!plugins[pluginIndex]) { if (!pluginModule.extractEvents) throw Error( "EventPluginRegistry: Event plugins must implement an `extractEvents` method, but `" + - pluginName + - "` does not." + (pluginName + "` does not.") ); plugins[pluginIndex] = pluginModule; pluginIndex = pluginModule.eventTypes; @@ -805,8 +803,7 @@ function recomputePluginOrdering() { if (eventNameDispatchConfigs.hasOwnProperty(eventName$jscomp$0)) throw Error( "EventPluginRegistry: More than one plugin attempted to publish the same event name, `" + - eventName$jscomp$0 + - "`." + (eventName$jscomp$0 + "`.") ); eventNameDispatchConfigs[eventName$jscomp$0] = dispatchConfig; var phasedRegistrationNames = dispatchConfig.phasedRegistrationNames; @@ -846,8 +843,7 @@ function publishRegistrationName(registrationName, pluginModule) { if (registrationNameModules[registrationName]) throw Error( "EventPluginRegistry: More than one plugin attempted to publish the same registration name, `" + - registrationName + - "`." + (registrationName + "`.") ); registrationNameModules[registrationName] = pluginModule; } @@ -931,7 +927,7 @@ eventPluginOrder = Array.prototype.slice.call([ "ReactNativeBridgeEventPlugin" ]); recomputePluginOrdering(); -var injectedNamesToPlugins$jscomp$inline_222 = { +var injectedNamesToPlugins$jscomp$inline_219 = { ResponderEventPlugin: ResponderEventPlugin, ReactNativeBridgeEventPlugin: { eventTypes: {}, @@ -966,34 +962,33 @@ var injectedNamesToPlugins$jscomp$inline_222 = { } } }, - isOrderingDirty$jscomp$inline_223 = !1, - pluginName$jscomp$inline_224; -for (pluginName$jscomp$inline_224 in injectedNamesToPlugins$jscomp$inline_222) + isOrderingDirty$jscomp$inline_220 = !1, + pluginName$jscomp$inline_221; +for (pluginName$jscomp$inline_221 in injectedNamesToPlugins$jscomp$inline_219) if ( - injectedNamesToPlugins$jscomp$inline_222.hasOwnProperty( - pluginName$jscomp$inline_224 + injectedNamesToPlugins$jscomp$inline_219.hasOwnProperty( + pluginName$jscomp$inline_221 ) ) { - var pluginModule$jscomp$inline_225 = - injectedNamesToPlugins$jscomp$inline_222[pluginName$jscomp$inline_224]; + var pluginModule$jscomp$inline_222 = + injectedNamesToPlugins$jscomp$inline_219[pluginName$jscomp$inline_221]; if ( - !namesToPlugins.hasOwnProperty(pluginName$jscomp$inline_224) || - namesToPlugins[pluginName$jscomp$inline_224] !== - pluginModule$jscomp$inline_225 + !namesToPlugins.hasOwnProperty(pluginName$jscomp$inline_221) || + namesToPlugins[pluginName$jscomp$inline_221] !== + pluginModule$jscomp$inline_222 ) { - if (namesToPlugins[pluginName$jscomp$inline_224]) + if (namesToPlugins[pluginName$jscomp$inline_221]) throw Error( "EventPluginRegistry: Cannot inject two different event plugins using the same name, `" + - pluginName$jscomp$inline_224 + - "`." + (pluginName$jscomp$inline_221 + "`.") ); namesToPlugins[ - pluginName$jscomp$inline_224 - ] = pluginModule$jscomp$inline_225; - isOrderingDirty$jscomp$inline_223 = !0; + pluginName$jscomp$inline_221 + ] = pluginModule$jscomp$inline_222; + isOrderingDirty$jscomp$inline_220 = !0; } } -isOrderingDirty$jscomp$inline_223 && recomputePluginOrdering(); +isOrderingDirty$jscomp$inline_220 && recomputePluginOrdering(); function getInstanceFromInstance(instanceHandle) { return instanceHandle; } @@ -1192,7 +1187,7 @@ function getNearestMountedFiber(fiber) { fiber = node; do (node = fiber), - 0 !== (node.flags & 2050) && (nearestMounted = node.return), + 0 !== (node.flags & 4098) && (nearestMounted = node.return), (fiber = node.return); while (fiber); } @@ -2405,7 +2400,7 @@ function processUpdateQueue( newState = workInProgress; break a; case 3: - workInProgress.flags = (workInProgress.flags & -32769) | 128; + workInProgress.flags = (workInProgress.flags & -65537) | 128; case 0: workInProgress = update.payload; updateLane = @@ -2658,7 +2653,8 @@ function coerceRef(returnFiber, current, element) { returnFiber + ". This error is likely caused by a bug in React. Please file an issue." ); - var stringRef = "" + returnFiber; + var resolvedInst = inst, + stringRef = "" + returnFiber; if ( null !== current && null !== current.ref && @@ -2667,8 +2663,8 @@ function coerceRef(returnFiber, current, element) { ) return current.ref; current = function(value) { - var refs = inst.refs; - refs === emptyRefsObject && (refs = inst.refs = {}); + var refs = resolvedInst.refs; + refs === emptyRefsObject && (refs = resolvedInst.refs = {}); null === value ? delete refs[stringRef] : (refs[stringRef] = value); }; current._stringRef = stringRef; @@ -3367,7 +3363,7 @@ function renderWithHooks( nextRenderLanes = 0; do { didScheduleRenderPhaseUpdateDuringThisPass = !1; - if (!(25 > nextRenderLanes)) + if (25 <= nextRenderLanes) throw Error( "Too many re-renders. React limits the number of renders to prevent an infinite loop." ); @@ -3468,19 +3464,18 @@ function updateReducer(reducer) { (newBaseQueueLast = newBaseQueueLast.next = { lane: 0, action: update.action, - eagerReducer: update.eagerReducer, + hasEagerState: update.hasEagerState, eagerState: update.eagerState, next: null }), - (current = - update.eagerReducer === reducer - ? update.eagerState - : reducer(current, update.action)); + (current = update.hasEagerState + ? update.eagerState + : reducer(current, update.action)); else { var clone = { lane: updateLane, action: update.action, - eagerReducer: update.eagerReducer, + hasEagerState: update.hasEagerState, eagerState: update.eagerState, next: null }; @@ -3620,7 +3615,7 @@ function useMutableSource(hook, source, getSnapshot, subscribe) { lastRenderedReducer: basicStateReducer, lastRenderedState: snapshot }), - (hook.dispatch = setSnapshot = dispatchAction.bind( + (hook.dispatch = setSnapshot = dispatchSetState.bind( null, currentlyRenderingFiber$1, hook @@ -3637,30 +3632,30 @@ function updateMutableSource(source, getSnapshot, subscribe) { } function mountSyncExternalStore(subscribe, getSnapshot) { var fiber = currentlyRenderingFiber$1, - hook = mountWorkInProgressHook(), - nextSnapshot = getSnapshot(); - hook.memoizedState = nextSnapshot; - var inst = { value: nextSnapshot, getSnapshot: getSnapshot }; - hook.queue = inst; - mountEffect(subscribeToStore.bind(null, fiber, inst, subscribe), [subscribe]); - fiber.flags |= 1024; - pushEffect( - 9, - updateStoreInstance.bind(null, fiber, inst, nextSnapshot, getSnapshot), - void 0, - null - ); - subscribe = workInProgressRoot; - if (null === subscribe) + hook = mountWorkInProgressHook(); + var nextSnapshot = getSnapshot(); + var root = workInProgressRoot; + if (null === root) throw Error( "Expected a work-in-progress root. This is a bug in React. Please file an issue." ); - includesBlockingLane(subscribe, renderLanes) || + includesBlockingLane(root, renderLanes) || pushStoreConsistencyCheck(fiber, getSnapshot, nextSnapshot); + hook.memoizedState = nextSnapshot; + root = { value: nextSnapshot, getSnapshot: getSnapshot }; + hook.queue = root; + mountEffect(subscribeToStore.bind(null, fiber, root, subscribe), [subscribe]); + fiber.flags |= 2048; + pushEffect( + 9, + updateStoreInstance.bind(null, fiber, root, nextSnapshot, getSnapshot), + void 0, + null + ); return nextSnapshot; } function pushStoreConsistencyCheck(fiber, getSnapshot, renderedSnapshot) { - fiber.flags |= 8192; + fiber.flags |= 16384; fiber = { getSnapshot: getSnapshot, value: renderedSnapshot }; getSnapshot = currentlyRenderingFiber$1.updateQueue; null === getSnapshot @@ -3705,7 +3700,7 @@ function mountState(initialState) { lastRenderedState: initialState }; hook.queue = initialState; - initialState = initialState.dispatch = dispatchAction.bind( + initialState = initialState.dispatch = dispatchSetState.bind( null, currentlyRenderingFiber$1, initialState @@ -3757,10 +3752,10 @@ function updateEffectImpl(fiberFlags, hookFlags, create, deps) { hook.memoizedState = pushEffect(1 | hookFlags, create, destroy, deps); } function mountEffect(create, deps) { - return mountEffectImpl(2098176, 8, create, deps); + return mountEffectImpl(4196352, 8, create, deps); } function updateEffect(create, deps) { - return updateEffectImpl(1024, 8, create, deps); + return updateEffectImpl(2048, 8, create, deps); } function updateInsertionEffect(create, deps) { return updateEffectImpl(4, 2, create, deps); @@ -3837,47 +3832,35 @@ function startTransition(setPending, callback) { (ReactCurrentBatchConfig$1.transition = prevTransition); } } -function dispatchAction(fiber, queue, action) { - var eventTime = requestEventTime(), - lane = requestUpdateLane(fiber), +function dispatchReducerAction(fiber, queue, action) { + var lane = requestUpdateLane(fiber); + action = { + lane: lane, + action: action, + hasEagerState: !1, + eagerState: null, + next: null + }; + isRenderPhaseUpdate(fiber) + ? enqueueRenderPhaseUpdate(queue, action) + : (enqueueUpdate$1(fiber, queue, action), + (action = requestEventTime()), + (fiber = scheduleUpdateOnFiber(fiber, lane, action)), + null !== fiber && entangleTransitionUpdate(fiber, queue, lane)); +} +function dispatchSetState(fiber, queue, action) { + var lane = requestUpdateLane(fiber), update = { lane: lane, action: action, - eagerReducer: null, + hasEagerState: !1, eagerState: null, next: null - }, - alternate = fiber.alternate; - if ( - fiber === currentlyRenderingFiber$1 || - (null !== alternate && alternate === currentlyRenderingFiber$1) - ) - (didScheduleRenderPhaseUpdateDuringThisPass = didScheduleRenderPhaseUpdate = !0), - (lane = queue.pending), - null === lane - ? (update.next = update) - : ((update.next = lane.next), (lane.next = update)), - (queue.pending = update); + }; + if (isRenderPhaseUpdate(fiber)) enqueueRenderPhaseUpdate(queue, update); else { - if ( - null !== workInProgressRoot && - 0 !== (fiber.mode & 1) && - 0 === (executionContext & 2) - ) { - var interleaved = queue.interleaved; - null === interleaved - ? ((update.next = update), - null === interleavedQueues - ? (interleavedQueues = [queue]) - : interleavedQueues.push(queue)) - : ((update.next = interleaved.next), (interleaved.next = update)); - queue.interleaved = update; - } else - (interleaved = queue.pending), - null === interleaved - ? (update.next = update) - : ((update.next = interleaved.next), (interleaved.next = update)), - (queue.pending = update); + enqueueUpdate$1(fiber, queue, update); + var alternate = fiber.alternate; if ( 0 === fiber.lanes && (null === alternate || 0 === alternate.lanes) && @@ -3886,20 +3869,57 @@ function dispatchAction(fiber, queue, action) { try { var currentState = queue.lastRenderedState, eagerState = alternate(currentState, action); - update.eagerReducer = alternate; + update.hasEagerState = !0; update.eagerState = eagerState; if (objectIs(eagerState, currentState)) return; } catch (error) { } finally { } - update = scheduleUpdateOnFiber(fiber, lane, eventTime); - 0 !== (lane & 4194240) && - null !== update && - ((fiber = queue.lanes), - (fiber &= update.pendingLanes), - (lane |= fiber), - (queue.lanes = lane), - markRootEntangled(update, lane)); + action = requestEventTime(); + fiber = scheduleUpdateOnFiber(fiber, lane, action); + null !== fiber && entangleTransitionUpdate(fiber, queue, lane); + } +} +function isRenderPhaseUpdate(fiber) { + var alternate = fiber.alternate; + return ( + fiber === currentlyRenderingFiber$1 || + (null !== alternate && alternate === currentlyRenderingFiber$1) + ); +} +function enqueueRenderPhaseUpdate(queue, update) { + didScheduleRenderPhaseUpdateDuringThisPass = didScheduleRenderPhaseUpdate = !0; + var pending = queue.pending; + null === pending + ? (update.next = update) + : ((update.next = pending.next), (pending.next = update)); + queue.pending = update; +} +function enqueueUpdate$1(fiber, queue, update) { + null !== workInProgressRoot && + 0 !== (fiber.mode & 1) && + 0 === (executionContext & 2) + ? ((fiber = queue.interleaved), + null === fiber + ? ((update.next = update), + null === interleavedQueues + ? (interleavedQueues = [queue]) + : interleavedQueues.push(queue)) + : ((update.next = fiber.next), (fiber.next = update)), + (queue.interleaved = update)) + : ((fiber = queue.pending), + null === fiber + ? (update.next = update) + : ((update.next = fiber.next), (fiber.next = update)), + (queue.pending = update)); +} +function entangleTransitionUpdate(root, queue, lane) { + if (0 !== (lane & 4194240)) { + var queueLanes = queue.lanes; + queueLanes &= root.pendingLanes; + lane |= queueLanes; + queue.lanes = lane; + markRootEntangled(root, lane); } } var ContextOnlyDispatcher = { @@ -3968,7 +3988,7 @@ var ContextOnlyDispatcher = { lastRenderedState: initialArg }; hook.queue = reducer; - reducer = reducer.dispatch = dispatchAction.bind( + reducer = reducer.dispatch = dispatchReducerAction.bind( null, currentlyRenderingFiber$1, reducer @@ -4078,7 +4098,7 @@ var ContextOnlyDispatcher = { (null !== workInProgressHook && workInProgressHook.memoizedState.tag & 1) ) { - fiber.flags |= 1024; + fiber.flags |= 2048; pushEffect( 9, updateStoreInstance.bind( @@ -4231,7 +4251,7 @@ function hadNoMutationsEffects(current, completedWork) { if (null !== current && current.child === completedWork.child) return !0; if (0 !== (completedWork.flags & 16)) return !1; for (current = completedWork.child; null !== current; ) { - if (0 !== (current.flags & 6454) || 0 !== (current.subtreeFlags & 6454)) + if (0 !== (current.flags & 12854) || 0 !== (current.subtreeFlags & 12854)) return !1; current = current.sibling; } @@ -4395,14 +4415,14 @@ function cutOffTailIfNeeded(renderState, hasRenderedATailFallback) { break; case "collapsed": lastTailNode = renderState.tail; - for (var lastTailNode$38 = null; null !== lastTailNode; ) - null !== lastTailNode.alternate && (lastTailNode$38 = lastTailNode), + for (var lastTailNode$35 = null; null !== lastTailNode; ) + null !== lastTailNode.alternate && (lastTailNode$35 = lastTailNode), (lastTailNode = lastTailNode.sibling); - null === lastTailNode$38 + null === lastTailNode$35 ? hasRenderedATailFallback || null === renderState.tail ? (renderState.tail = null) : (renderState.tail.sibling = null) - : (lastTailNode$38.sibling = null); + : (lastTailNode$35.sibling = null); } } function bubbleProperties(completedWork) { @@ -4412,19 +4432,19 @@ function bubbleProperties(completedWork) { newChildLanes = 0, subtreeFlags = 0; if (didBailout) - for (var child$39 = completedWork.child; null !== child$39; ) - (newChildLanes |= child$39.lanes | child$39.childLanes), - (subtreeFlags |= child$39.subtreeFlags & 3670016), - (subtreeFlags |= child$39.flags & 3670016), - (child$39.return = completedWork), - (child$39 = child$39.sibling); + for (var child$36 = completedWork.child; null !== child$36; ) + (newChildLanes |= child$36.lanes | child$36.childLanes), + (subtreeFlags |= child$36.subtreeFlags & 7340032), + (subtreeFlags |= child$36.flags & 7340032), + (child$36.return = completedWork), + (child$36 = child$36.sibling); else - for (child$39 = completedWork.child; null !== child$39; ) - (newChildLanes |= child$39.lanes | child$39.childLanes), - (subtreeFlags |= child$39.subtreeFlags), - (subtreeFlags |= child$39.flags), - (child$39.return = completedWork), - (child$39 = child$39.sibling); + for (child$36 = completedWork.child; null !== child$36; ) + (newChildLanes |= child$36.lanes | child$36.childLanes), + (subtreeFlags |= child$36.subtreeFlags), + (subtreeFlags |= child$36.flags), + (child$36.return = completedWork), + (child$36 = child$36.sibling); completedWork.subtreeFlags |= subtreeFlags; completedWork.childLanes = newChildLanes; return didBailout; @@ -4451,7 +4471,7 @@ function completeSuspendedOffscreenHostContainer(current, workInProgress) { )), appendAllChildren(rootContainerInstance, workInProgress, !1, !1), (workInProgress.stateNode = rootContainerInstance), - null !== workInProgress.ref && (workInProgress.flags |= 256)); + null !== workInProgress.ref && (workInProgress.flags |= 512)); bubbleProperties(workInProgress); } function completeWork(current, workInProgress, renderLanes) { @@ -4485,8 +4505,8 @@ function completeWork(current, workInProgress, renderLanes) { ((newProps.context = newProps.pendingContext), (newProps.pendingContext = null)), (null !== current && null !== current.child) || - newProps.hydrate || - (workInProgress.flags |= 512), + newProps.isDehydrated || + (workInProgress.flags |= 1024), updateHostContainer(current, workInProgress), bubbleProperties(workInProgress), null @@ -4503,7 +4523,7 @@ function completeWork(current, workInProgress, renderLanes) { newProps, renderLanes ), - current.ref !== workInProgress.ref && (workInProgress.flags |= 256); + current.ref !== workInProgress.ref && (workInProgress.flags |= 512); else { if (!newProps) { if (null === workInProgress.stateNode) @@ -4523,7 +4543,7 @@ function completeWork(current, workInProgress, renderLanes) { ); appendAllChildren(current, workInProgress, !1, !1); workInProgress.stateNode = current; - null !== workInProgress.ref && (workInProgress.flags |= 256); + null !== workInProgress.ref && (workInProgress.flags |= 512); } bubbleProperties(workInProgress); return null; @@ -4561,7 +4581,7 @@ function completeWork(current, workInProgress, renderLanes) { if ( null !== newProps && !renderLanes && - ((workInProgress.child.flags |= 4096), 0 !== (workInProgress.mode & 1)) + ((workInProgress.child.flags |= 8192), 0 !== (workInProgress.mode & 1)) ) if ( (null === current && @@ -4573,7 +4593,8 @@ function completeWork(current, workInProgress, renderLanes) { else { if ( 0 === workInProgressRootExitStatus || - 3 === workInProgressRootExitStatus + 3 === workInProgressRootExitStatus || + 2 === workInProgressRootExitStatus ) workInProgressRootExitStatus = 4; null === workInProgressRoot || @@ -4633,7 +4654,7 @@ function completeWork(current, workInProgress, renderLanes) { for (newProps = workInProgress.child; null !== newProps; ) (renderLanes = newProps), (type = current), - (renderLanes.flags &= 3670018), + (renderLanes.flags &= 7340034), (renderedTail = renderLanes.alternate), null === renderedTail ? ((renderLanes.childLanes = 0), @@ -4737,7 +4758,7 @@ function completeWork(current, workInProgress, renderLanes) { (null !== current.memoizedState) !== renderLanes && "unstable-defer-without-hiding" !== newProps.mode && 23 !== workInProgress.tag && - (workInProgress.flags |= 4096), + (workInProgress.flags |= 8192), renderLanes && 0 !== (workInProgress.mode & 1) ? 0 !== (subtreeRenderLanes & 1073741824) && bubbleProperties(workInProgress) @@ -4785,7 +4806,7 @@ function updateForwardRef( if (null !== current && !didReceiveUpdate) return ( (workInProgress.updateQueue = current.updateQueue), - (workInProgress.flags &= -1029), + (workInProgress.flags &= -2053), (current.lanes &= ~renderLanes), bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes) ); @@ -4859,7 +4880,7 @@ function updateSimpleMemoComponent( current.ref === workInProgress.ref ) if (((didReceiveUpdate = !1), 0 !== (current.lanes & renderLanes))) - 0 !== (current.flags & 65536) && (didReceiveUpdate = !0); + 0 !== (current.flags & 131072) && (didReceiveUpdate = !0); else return ( (workInProgress.lanes = current.lanes), @@ -4962,7 +4983,7 @@ function markRef$1(current, workInProgress) { (null === current && null !== ref) || (null !== current && current.ref !== ref) ) - workInProgress.flags |= 256; + workInProgress.flags |= 512; } function updateFunctionComponent( current, @@ -4987,7 +5008,7 @@ function updateFunctionComponent( if (null !== current && !didReceiveUpdate) return ( (workInProgress.updateQueue = current.updateQueue), - (workInProgress.flags &= -1029), + (workInProgress.flags &= -2053), (current.lanes &= ~renderLanes), bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes) ); @@ -5163,7 +5184,7 @@ function updateClassComponent( "function" === typeof instance.componentDidUpdate && (workInProgress.flags |= 4), "function" === typeof instance.getSnapshotBeforeUpdate && - (workInProgress.flags |= 512)) + (workInProgress.flags |= 1024)) : ("function" !== typeof instance.componentDidUpdate || (oldProps === current.memoizedProps && oldState === current.memoizedState) || @@ -5171,7 +5192,7 @@ function updateClassComponent( "function" !== typeof instance.getSnapshotBeforeUpdate || (oldProps === current.memoizedProps && oldState === current.memoizedState) || - (workInProgress.flags |= 512), + (workInProgress.flags |= 1024), (workInProgress.memoizedProps = nextProps), (workInProgress.memoizedState = newState)), (instance.props = nextProps), @@ -5185,7 +5206,7 @@ function updateClassComponent( "function" !== typeof instance.getSnapshotBeforeUpdate || (oldProps === current.memoizedProps && oldState === current.memoizedState) || - (workInProgress.flags |= 512), + (workInProgress.flags |= 1024), (nextProps = !1)); } return finishClassComponent( @@ -5474,7 +5495,7 @@ function updateSuspenseFallbackChildren( primaryChildren ))), (current.subtreeFlags = - currentPrimaryChildFragment.subtreeFlags & 3670016)); + currentPrimaryChildFragment.subtreeFlags & 7340032)); null !== currentFallbackChildFragment ? (fallbackChildren = createWorkInProgress( currentFallbackChildFragment, @@ -5702,8 +5723,8 @@ function unwindWork(workInProgress) { case 1: isContextProvider(workInProgress.type) && popContext(); var flags = workInProgress.flags; - return flags & 32768 - ? ((workInProgress.flags = (flags & -32769) | 128), workInProgress) + return flags & 65536 + ? ((workInProgress.flags = (flags & -65537) | 128), workInProgress) : null; case 3: popHostContainer(); @@ -5715,7 +5736,7 @@ function unwindWork(workInProgress) { throw Error( "The root failed to unmount after an error. This is likely a bug in React. Please file an issue." ); - workInProgress.flags = (flags & -32769) | 128; + workInProgress.flags = (flags & -65537) | 128; return workInProgress; case 5: return popHostContext(workInProgress), null; @@ -5723,8 +5744,8 @@ function unwindWork(workInProgress) { return ( pop(suspenseStackCursor), (flags = workInProgress.flags), - flags & 32768 - ? ((workInProgress.flags = (flags & -32769) | 128), workInProgress) + flags & 65536 + ? ((workInProgress.flags = (flags & -65537) | 128), workInProgress) : null ); case 19: @@ -5761,7 +5782,7 @@ function commitBeforeMutationEffects(root, firstChild) { if ( ((root = nextEffect), (firstChild = root.child), - 0 !== (root.subtreeFlags & 516) && null !== firstChild) + 0 !== (root.subtreeFlags & 1028) && null !== firstChild) ) (firstChild.return = root), (nextEffect = firstChild); else @@ -5769,7 +5790,7 @@ function commitBeforeMutationEffects(root, firstChild) { root = nextEffect; try { var current = root.alternate; - if (0 !== (root.flags & 512)) + if (0 !== (root.flags & 1024)) switch (root.tag) { case 0: case 11: @@ -5850,8 +5871,8 @@ function commitHookEffectListMount(tag, finishedWork) { var effect = (finishedWork = finishedWork.next); do { if ((effect.tag & tag) === tag) { - var create$83 = effect.create; - effect.destroy = create$83(); + var create$80 = effect.create; + effect.destroy = create$80(); } effect = effect.next; } while (effect !== finishedWork); @@ -6018,14 +6039,14 @@ function commitMutationEffects(root, firstChild) { } } firstChild = root.child; - if (0 !== (root.subtreeFlags & 6454) && null !== firstChild) + if (0 !== (root.subtreeFlags & 12854) && null !== firstChild) (firstChild.return = root), (nextEffect = firstChild); else for (; null !== nextEffect; ) { root = nextEffect; try { var flags = root.flags; - if (flags & 256) { + if (flags & 512) { var current$jscomp$0 = root.alternate; if (null !== current$jscomp$0) { var currentRef = current$jscomp$0.ref; @@ -6035,16 +6056,16 @@ function commitMutationEffects(root, firstChild) { : (currentRef.current = null)); } } - if (flags & 4096) + if (flags & 8192) switch (root.tag) { case 13: if (null !== root.memoizedState) { - var current$87 = root.alternate; - if (null === current$87 || null === current$87.memoizedState) + var current$84 = root.alternate; + if (null === current$84 || null === current$84.memoizedState) globalMostRecentFallbackTime = now(); } } - switch (flags & 2054) { + switch (flags & 4102) { case 2: root.flags &= -3; break; @@ -6052,11 +6073,11 @@ function commitMutationEffects(root, firstChild) { root.flags &= -3; commitWork(root.alternate, root); break; - case 2048: - root.flags &= -2049; + case 4096: + root.flags &= -4097; break; - case 2052: - root.flags &= -2049; + case 4100: + root.flags &= -4097; commitWork(root.alternate, root); break; case 4: @@ -6079,15 +6100,15 @@ function commitLayoutEffects(finishedWork) { for (nextEffect = finishedWork; null !== nextEffect; ) { var fiber = nextEffect, firstChild = fiber.child; - if (0 !== (fiber.subtreeFlags & 4420) && null !== firstChild) + if (0 !== (fiber.subtreeFlags & 8772) && null !== firstChild) (firstChild.return = fiber), (nextEffect = firstChild); else for (fiber = finishedWork; null !== nextEffect; ) { firstChild = nextEffect; - if (0 !== (firstChild.flags & 4420)) { + if (0 !== (firstChild.flags & 8772)) { var current = firstChild.alternate; try { - if (0 !== (firstChild.flags & 4420)) + if (0 !== (firstChild.flags & 8772)) switch (firstChild.tag) { case 0: case 11: @@ -6117,8 +6138,8 @@ function commitLayoutEffects(finishedWork) { commitUpdateQueue(firstChild, updateQueue, instance); break; case 3: - var updateQueue$84 = firstChild.updateQueue; - if (null !== updateQueue$84) { + var updateQueue$81 = firstChild.updateQueue; + if (null !== updateQueue$81) { current = null; if (null !== firstChild.child) switch (firstChild.child.tag) { @@ -6128,7 +6149,7 @@ function commitLayoutEffects(finishedWork) { case 1: current = firstChild.child.stateNode; } - commitUpdateQueue(firstChild, updateQueue$84, current); + commitUpdateQueue(firstChild, updateQueue$81, current); } break; case 5: @@ -6153,7 +6174,7 @@ function commitLayoutEffects(finishedWork) { "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 (firstChild.flags & 256) { + if (firstChild.flags & 512) { current = void 0; var ref = firstChild.ref; if (null !== ref) { @@ -6516,14 +6537,14 @@ function performConcurrentWorkOnRoot(root, didTimeout) { function recoverFromConcurrentError(root, errorRetryLanes) { var prevExecutionContext = executionContext; executionContext |= 8; - root.hydrate && ((root.hydrate = !1), shim(root.containerInfo)); + root.isDehydrated && ((root.isDehydrated = !1), shim(root.containerInfo)); root = renderRootSync(root, errorRetryLanes); executionContext = prevExecutionContext; return root; } function isRenderConsistentWithExternalStores(finishedWork) { for (var node = finishedWork; ; ) { - if (node.flags & 8192) { + if (node.flags & 16384) { var updateQueue = node.updateQueue; if ( null !== updateQueue && @@ -6541,7 +6562,7 @@ function isRenderConsistentWithExternalStores(finishedWork) { } } updateQueue = node.child; - if (node.subtreeFlags & 8192 && null !== updateQueue) + if (node.subtreeFlags & 16384 && null !== updateQueue) (updateQueue.return = node), (node = updateQueue); else { if (node === finishedWork) break; @@ -6577,7 +6598,7 @@ function performSyncWorkOnRoot(root) { if (0 !== root.tag && 2 === exitStatus) { var prevExecutionContext = executionContext; executionContext |= 8; - root.hydrate && ((root.hydrate = !1), shim(root.containerInfo)); + root.isDehydrated && ((root.isDehydrated = !1), shim(root.containerInfo)); var errorRetryLanes = getLanesToRetrySynchronouslyOnError(root); 0 !== errorRetryLanes && ((lanes = errorRetryLanes), (exitStatus = renderRootSync(root, lanes))); @@ -6702,85 +6723,97 @@ function handleError(root$jscomp$0, thrownValue) { sourceFiber = erroredWork, value = thrownValue; thrownValue = workInProgressRootRenderLanes; - sourceFiber.flags |= 16384; + sourceFiber.flags |= 32768; if ( null !== value && "object" === typeof value && "function" === typeof value.then ) { var wakeable = value, - tag = sourceFiber.tag; + sourceFiber$jscomp$0 = sourceFiber, + tag = sourceFiber$jscomp$0.tag; if ( - 0 === (sourceFiber.mode & 1) && + 0 === (sourceFiber$jscomp$0.mode & 1) && (0 === tag || 11 === tag || 15 === tag) ) { - var currentSource = sourceFiber.alternate; + var currentSource = sourceFiber$jscomp$0.alternate; currentSource - ? ((sourceFiber.updateQueue = currentSource.updateQueue), - (sourceFiber.memoizedState = currentSource.memoizedState), - (sourceFiber.lanes = currentSource.lanes)) - : ((sourceFiber.updateQueue = null), - (sourceFiber.memoizedState = null)); + ? ((sourceFiber$jscomp$0.updateQueue = currentSource.updateQueue), + (sourceFiber$jscomp$0.memoizedState = + currentSource.memoizedState), + (sourceFiber$jscomp$0.lanes = currentSource.lanes)) + : ((sourceFiber$jscomp$0.updateQueue = null), + (sourceFiber$jscomp$0.memoizedState = null)); } - var hasInvisibleParentBoundary = - 0 !== (suspenseStackCursor.current & 1), - workInProgress$30 = returnFiber; - do { - var JSCompiler_temp; - if ((JSCompiler_temp = 13 === workInProgress$30.tag)) { - var nextState = workInProgress$30.memoizedState; - JSCompiler_temp = - null !== nextState - ? null !== nextState.dehydrated + b: { + sourceFiber$jscomp$0 = returnFiber; + var sourceFiber$jscomp$1 = sourceFiber, + rootRenderLanes = thrownValue, + hasInvisibleParentBoundary = + 0 !== (suspenseStackCursor.current & 1), + node = sourceFiber$jscomp$0; + do { + var JSCompiler_temp; + if ((JSCompiler_temp = 13 === node.tag)) { + var nextState = node.memoizedState; + JSCompiler_temp = + null !== nextState + ? null !== nextState.dehydrated + ? !0 + : !1 + : !0 !== node.memoizedProps.unstable_avoidThisFallback ? !0 - : !1 - : !0 !== - workInProgress$30.memoizedProps.unstable_avoidThisFallback - ? !0 - : hasInvisibleParentBoundary - ? !1 - : !0; - } - if (JSCompiler_temp) { - var wakeables = workInProgress$30.updateQueue; - if (null === wakeables) { - var updateQueue = new Set(); - updateQueue.add(wakeable); - workInProgress$30.updateQueue = updateQueue; - } else wakeables.add(wakeable); - if ( - 0 === (workInProgress$30.mode & 1) && - workInProgress$30 !== returnFiber - ) { - workInProgress$30.flags |= 128; - sourceFiber.flags |= 65536; - sourceFiber.flags &= -26437; - if ( - enablePersistentOffscreenHostContainer && - null === workInProgress$30.alternate - ) { - var offscreenContainer = workInProgress$30.child.child; - if (null !== offscreenContainer) { - var containerProps = getOffscreenContainerProps( - "hidden", - offscreenContainer.memoizedProps.children - ); - offscreenContainer.pendingProps = containerProps; - offscreenContainer.memoizedProps = containerProps; - } - } - if (1 === sourceFiber.tag) - if (null === sourceFiber.alternate) sourceFiber.tag = 17; - else { - var update = createUpdate(-1, 1); - update.tag = 2; - enqueueUpdate(sourceFiber, update); - } - sourceFiber.lanes |= 1; - break a; + : hasInvisibleParentBoundary + ? !1 + : !0; } - value = void 0; - sourceFiber = thrownValue; + if (JSCompiler_temp) { + if (0 === (node.mode & 1)) { + if (node === sourceFiber$jscomp$0) node.flags |= 65536; + else { + node.flags |= 128; + sourceFiber$jscomp$1.flags |= 131072; + sourceFiber$jscomp$1.flags &= -52805; + if ( + enablePersistentOffscreenHostContainer && + null === node.alternate + ) { + var offscreenContainer = node.child.child; + if (null !== offscreenContainer) { + var containerProps = getOffscreenContainerProps( + "hidden", + offscreenContainer.memoizedProps.children + ); + offscreenContainer.pendingProps = containerProps; + offscreenContainer.memoizedProps = containerProps; + } + } + if (1 === sourceFiber$jscomp$1.tag) + if (null === sourceFiber$jscomp$1.alternate) + sourceFiber$jscomp$1.tag = 17; + else { + var update = createUpdate(-1, 1); + update.tag = 2; + enqueueUpdate(sourceFiber$jscomp$1, update); + } + sourceFiber$jscomp$1.lanes |= 1; + } + var suspenseBoundary = node; + break b; + } + node.flags |= 65536; + node.lanes = rootRenderLanes; + suspenseBoundary = node; + break b; + } + node = node.return; + } while (null !== node); + suspenseBoundary = null; + } + if (null !== suspenseBoundary) { + value = void 0; + sourceFiber = suspenseBoundary; + if (sourceFiber.mode & 1) { var pingCache = root.pingCache; null === pingCache ? ((pingCache = root.pingCache = new PossiblyWeakMap()), @@ -6789,71 +6822,74 @@ function handleError(root$jscomp$0, thrownValue) { : ((value = pingCache.get(wakeable)), void 0 === value && ((value = new Set()), pingCache.set(wakeable, value))); - if (!value.has(sourceFiber)) { - value.add(sourceFiber); + if (!value.has(thrownValue)) { + value.add(thrownValue); var ping = pingSuspendedRoot.bind( null, root, wakeable, - sourceFiber + thrownValue ); wakeable.then(ping, ping); } - workInProgress$30.flags |= 32768; - workInProgress$30.lanes = thrownValue; - break a; } - workInProgress$30 = workInProgress$30.return; - } while (null !== workInProgress$30); - value = Error( - (getComponentNameFromFiber(sourceFiber) || "A React component") + - " suspended while rendering, but no fallback UI was specified.\n\nAdd a component higher in the tree to provide a loading indicator or placeholder to display." - ); + var wakeables = sourceFiber.updateQueue; + if (null === wakeables) { + var updateQueue = new Set(); + updateQueue.add(wakeable); + sourceFiber.updateQueue = updateQueue; + } else wakeables.add(wakeable); + break a; + } else + value = Error( + (getComponentNameFromFiber(sourceFiber) || "A React component") + + " suspended while rendering, but no fallback UI was specified.\n\nAdd a component higher in the tree to provide a loading indicator or placeholder to display." + ); } - 5 !== workInProgressRootExitStatus && + 4 !== workInProgressRootExitStatus && (workInProgressRootExitStatus = 2); value = createCapturedValue(value, sourceFiber); - workInProgress$30 = returnFiber; + root = returnFiber; do { - switch (workInProgress$30.tag) { + switch (root.tag) { case 3: - root = value; - workInProgress$30.flags |= 32768; + wakeable = value; + root.flags |= 65536; thrownValue &= -thrownValue; - workInProgress$30.lanes |= thrownValue; - var update$31 = createRootErrorUpdate( - workInProgress$30, + root.lanes |= thrownValue; + var update$jscomp$0 = createRootErrorUpdate( root, + wakeable, thrownValue ); - enqueueCapturedUpdate(workInProgress$30, update$31); + enqueueCapturedUpdate(root, update$jscomp$0); break a; case 1: - root = value; - var ctor = workInProgress$30.type, - instance = workInProgress$30.stateNode; + wakeable = value; + var ctor = root.type, + instance = root.stateNode; if ( - 0 === (workInProgress$30.flags & 128) && + 0 === (root.flags & 128) && ("function" === typeof ctor.getDerivedStateFromError || (null !== instance && "function" === typeof instance.componentDidCatch && (null === legacyErrorBoundariesThatAlreadyFailed || !legacyErrorBoundariesThatAlreadyFailed.has(instance)))) ) { - workInProgress$30.flags |= 32768; + root.flags |= 65536; thrownValue &= -thrownValue; - workInProgress$30.lanes |= thrownValue; - var update$34 = createClassErrorUpdate( - workInProgress$30, + root.lanes |= thrownValue; + var update$31 = createClassErrorUpdate( root, + wakeable, thrownValue ); - enqueueCapturedUpdate(workInProgress$30, update$34); + enqueueCapturedUpdate(root, update$31); break a; } } - workInProgress$30 = workInProgress$30.return; - } while (null !== workInProgress$30); + root = root.return; + } while (null !== root); } completeUnitOfWork(erroredWork); } catch (yetAnotherThrownValue) { @@ -6914,7 +6950,7 @@ function completeUnitOfWork(unitOfWork) { do { var current = completedWork.alternate; unitOfWork = completedWork.return; - if (0 === (completedWork.flags & 16384)) { + if (0 === (completedWork.flags & 32768)) { if ( ((current = completeWork(current, completedWork, subtreeRenderLanes)), null !== current) @@ -6925,12 +6961,12 @@ function completeUnitOfWork(unitOfWork) { } else { current = unwindWork(completedWork); if (null !== current) { - current.flags &= 16383; + current.flags &= 32767; workInProgress = current; return; } null !== unitOfWork && - ((unitOfWork.flags |= 16384), + ((unitOfWork.flags |= 32768), (unitOfWork.subtreeFlags = 0), (unitOfWork.deletions = null)); } @@ -6977,16 +7013,16 @@ function commitRootImpl(root, renderPriorityLevel) { root === workInProgressRoot && ((workInProgress = workInProgressRoot = null), (workInProgressRootRenderLanes = 0)); - (0 === (finishedWork.subtreeFlags & 1040) && - 0 === (finishedWork.flags & 1040)) || + (0 === (finishedWork.subtreeFlags & 2064) && + 0 === (finishedWork.flags & 2064)) || rootDoesHavePassiveEffects || ((rootDoesHavePassiveEffects = !0), scheduleCallback$1(NormalPriority, function() { flushPassiveEffects(); return null; })); - remainingLanes = 0 !== (finishedWork.flags & 8054); - if (0 !== (finishedWork.subtreeFlags & 8054) || remainingLanes) { + remainingLanes = 0 !== (finishedWork.flags & 15990); + if (0 !== (finishedWork.subtreeFlags & 15990) || remainingLanes) { remainingLanes = ReactCurrentBatchConfig$2.transition; ReactCurrentBatchConfig$2.transition = 0; var previousPriority = currentUpdatePriority; @@ -7100,12 +7136,12 @@ function flushPassiveEffects() { nextEffect = fiber; } } - if (0 !== (fiber.subtreeFlags & 1040) && null !== child) + if (0 !== (fiber.subtreeFlags & 2064) && null !== child) (child.return = fiber), (nextEffect = child); else b: for (; null !== nextEffect; ) { fiber = nextEffect; - if (0 !== (fiber.flags & 1024)) + if (0 !== (fiber.flags & 2048)) switch (fiber.tag) { case 0: case 11: @@ -7125,12 +7161,12 @@ function flushPassiveEffects() { for (nextEffect = finishedWork; null !== nextEffect; ) { child = nextEffect; var firstChild = child.child; - if (0 !== (child.subtreeFlags & 1040) && null !== firstChild) + if (0 !== (child.subtreeFlags & 2064) && null !== firstChild) (firstChild.return = child), (nextEffect = firstChild); else b: for (child = finishedWork; null !== nextEffect; ) { deletions = nextEffect; - if (0 !== (deletions.flags & 1024)) + if (0 !== (deletions.flags & 2048)) try { switch (deletions.tag) { case 0: @@ -7282,7 +7318,7 @@ beginWork$1 = function(current, workInProgress, renderLanes) { renderLanes ) ); - didReceiveUpdate = 0 !== (current.flags & 65536) ? !0 : !1; + didReceiveUpdate = 0 !== (current.flags & 131072) ? !0 : !1; } else didReceiveUpdate = !1; workInProgress.lanes = 0; @@ -7748,7 +7784,7 @@ function createWorkInProgress(current, pendingProps) { (workInProgress.flags = 0), (workInProgress.subtreeFlags = 0), (workInProgress.deletions = null)); - workInProgress.flags = current.flags & 3670016; + workInProgress.flags = current.flags & 7340032; workInProgress.childLanes = current.childLanes; workInProgress.lanes = current.lanes; workInProgress.child = current.child; @@ -7841,8 +7877,7 @@ function createFiberFromTypeAndProps( } throw Error( "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) + - "." + ((null == type ? type : typeof type) + ".") ); } key = createFiber(fiberTag, pendingProps, key, mode); @@ -7895,7 +7930,7 @@ function FiberRootNode(containerInfo, tag, hydrate) { this.finishedWork = this.pingCache = this.current = this.pendingChildren = null; this.timeoutHandle = -1; this.pendingContext = this.context = null; - this.hydrate = hydrate; + this.isDehydrated = hydrate; this.callbackNode = null; this.callbackPriority = 0; this.eventTimes = createLaneMap(0); @@ -7919,9 +7954,9 @@ function findHostInstance(component) { if (void 0 === fiber) { if ("function" === typeof component.render) throw Error("Unable to find node on an unmounted component."); + component = Object.keys(component).join(","); throw Error( - "Argument appears to not be a ReactComponent. Keys: " + - Object.keys(component) + "Argument appears to not be a ReactComponent. Keys: " + component ); } component = findCurrentHostFiber(fiber); @@ -8105,10 +8140,10 @@ batchedUpdatesImpl = function(fn, a) { } }; var roots = new Map(), - devToolsConfig$jscomp$inline_950 = { + devToolsConfig$jscomp$inline_935 = { findFiberByHostInstance: getInstanceFromInstance, bundleType: 0, - version: "18.0.0-e8feb11b6-20210915", + version: "18.0.0-afcb9cdc9-20211008", rendererPackageName: "react-native-renderer", rendererConfig: { getInspectorDataForViewTag: function() { @@ -8123,11 +8158,11 @@ var roots = new Map(), }.bind(null, findNodeHandle) } }; -var internals$jscomp$inline_1191 = { - bundleType: devToolsConfig$jscomp$inline_950.bundleType, - version: devToolsConfig$jscomp$inline_950.version, - rendererPackageName: devToolsConfig$jscomp$inline_950.rendererPackageName, - rendererConfig: devToolsConfig$jscomp$inline_950.rendererConfig, +var internals$jscomp$inline_1189 = { + bundleType: devToolsConfig$jscomp$inline_935.bundleType, + version: devToolsConfig$jscomp$inline_935.version, + rendererPackageName: devToolsConfig$jscomp$inline_935.rendererPackageName, + rendererConfig: devToolsConfig$jscomp$inline_935.rendererConfig, overrideHookState: null, overrideHookStateDeletePath: null, overrideHookStateRenamePath: null, @@ -8143,27 +8178,26 @@ var internals$jscomp$inline_1191 = { return null === fiber ? null : fiber.stateNode; }, findFiberByHostInstance: - devToolsConfig$jscomp$inline_950.findFiberByHostInstance || + devToolsConfig$jscomp$inline_935.findFiberByHostInstance || emptyFindFiberByHostInstance, findHostInstancesForRefresh: null, scheduleRefresh: null, scheduleRoot: null, setRefreshHandler: null, getCurrentFiber: null, - getIsStrictMode: null, - reconcilerVersion: "18.0.0-e8feb11b6-20210915" + reconcilerVersion: "18.0.0-afcb9cdc9-20211008" }; if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) { - var hook$jscomp$inline_1192 = __REACT_DEVTOOLS_GLOBAL_HOOK__; + var hook$jscomp$inline_1190 = __REACT_DEVTOOLS_GLOBAL_HOOK__; if ( - !hook$jscomp$inline_1192.isDisabled && - hook$jscomp$inline_1192.supportsFiber + !hook$jscomp$inline_1190.isDisabled && + hook$jscomp$inline_1190.supportsFiber ) try { - (rendererID = hook$jscomp$inline_1192.inject( - internals$jscomp$inline_1191 + (rendererID = hook$jscomp$inline_1190.inject( + internals$jscomp$inline_1189 )), - (injectedHook = hook$jscomp$inline_1192); + (injectedHook = hook$jscomp$inline_1190); } catch (err) {} } exports.createPortal = function(children, containerTag) { diff --git a/Libraries/Renderer/implementations/ReactFabric-profiling.fb.js b/Libraries/Renderer/implementations/ReactFabric-profiling.fb.js index 1277c286d3..1950c8517f 100644 --- a/Libraries/Renderer/implementations/ReactFabric-profiling.fb.js +++ b/Libraries/Renderer/implementations/ReactFabric-profiling.fb.js @@ -7,7 +7,7 @@ * @noflow * @nolint * @preventMunge - * @generated SignedSource<<9613963109b67072417dfb9843578a9d>> + * @generated SignedSource<<62430ecbf70b848b8677c9a80f79d347>> */ "use strict"; @@ -783,18 +783,16 @@ function recomputePluginOrdering() { for (var pluginName in namesToPlugins) { var pluginModule = namesToPlugins[pluginName], pluginIndex = eventPluginOrder.indexOf(pluginName); - if (!(-1 < pluginIndex)) + if (-1 >= pluginIndex) throw Error( "EventPluginRegistry: Cannot inject event plugins that do not exist in the plugin ordering, `" + - pluginName + - "`." + (pluginName + "`.") ); if (!plugins[pluginIndex]) { if (!pluginModule.extractEvents) throw Error( "EventPluginRegistry: Event plugins must implement an `extractEvents` method, but `" + - pluginName + - "` does not." + (pluginName + "` does not.") ); plugins[pluginIndex] = pluginModule; pluginIndex = pluginModule.eventTypes; @@ -805,8 +803,7 @@ function recomputePluginOrdering() { if (eventNameDispatchConfigs.hasOwnProperty(eventName$jscomp$0)) throw Error( "EventPluginRegistry: More than one plugin attempted to publish the same event name, `" + - eventName$jscomp$0 + - "`." + (eventName$jscomp$0 + "`.") ); eventNameDispatchConfigs[eventName$jscomp$0] = dispatchConfig; var phasedRegistrationNames = dispatchConfig.phasedRegistrationNames; @@ -846,8 +843,7 @@ function publishRegistrationName(registrationName, pluginModule) { if (registrationNameModules[registrationName]) throw Error( "EventPluginRegistry: More than one plugin attempted to publish the same registration name, `" + - registrationName + - "`." + (registrationName + "`.") ); registrationNameModules[registrationName] = pluginModule; } @@ -931,7 +927,7 @@ eventPluginOrder = Array.prototype.slice.call([ "ReactNativeBridgeEventPlugin" ]); recomputePluginOrdering(); -var injectedNamesToPlugins$jscomp$inline_230 = { +var injectedNamesToPlugins$jscomp$inline_227 = { ResponderEventPlugin: ResponderEventPlugin, ReactNativeBridgeEventPlugin: { eventTypes: {}, @@ -966,34 +962,33 @@ var injectedNamesToPlugins$jscomp$inline_230 = { } } }, - isOrderingDirty$jscomp$inline_231 = !1, - pluginName$jscomp$inline_232; -for (pluginName$jscomp$inline_232 in injectedNamesToPlugins$jscomp$inline_230) + isOrderingDirty$jscomp$inline_228 = !1, + pluginName$jscomp$inline_229; +for (pluginName$jscomp$inline_229 in injectedNamesToPlugins$jscomp$inline_227) if ( - injectedNamesToPlugins$jscomp$inline_230.hasOwnProperty( - pluginName$jscomp$inline_232 + injectedNamesToPlugins$jscomp$inline_227.hasOwnProperty( + pluginName$jscomp$inline_229 ) ) { - var pluginModule$jscomp$inline_233 = - injectedNamesToPlugins$jscomp$inline_230[pluginName$jscomp$inline_232]; + var pluginModule$jscomp$inline_230 = + injectedNamesToPlugins$jscomp$inline_227[pluginName$jscomp$inline_229]; if ( - !namesToPlugins.hasOwnProperty(pluginName$jscomp$inline_232) || - namesToPlugins[pluginName$jscomp$inline_232] !== - pluginModule$jscomp$inline_233 + !namesToPlugins.hasOwnProperty(pluginName$jscomp$inline_229) || + namesToPlugins[pluginName$jscomp$inline_229] !== + pluginModule$jscomp$inline_230 ) { - if (namesToPlugins[pluginName$jscomp$inline_232]) + if (namesToPlugins[pluginName$jscomp$inline_229]) throw Error( "EventPluginRegistry: Cannot inject two different event plugins using the same name, `" + - pluginName$jscomp$inline_232 + - "`." + (pluginName$jscomp$inline_229 + "`.") ); namesToPlugins[ - pluginName$jscomp$inline_232 - ] = pluginModule$jscomp$inline_233; - isOrderingDirty$jscomp$inline_231 = !0; + pluginName$jscomp$inline_229 + ] = pluginModule$jscomp$inline_230; + isOrderingDirty$jscomp$inline_228 = !0; } } -isOrderingDirty$jscomp$inline_231 && recomputePluginOrdering(); +isOrderingDirty$jscomp$inline_228 && recomputePluginOrdering(); function getInstanceFromInstance(instanceHandle) { return instanceHandle; } @@ -1192,7 +1187,7 @@ function getNearestMountedFiber(fiber) { fiber = node; do (node = fiber), - 0 !== (node.flags & 2050) && (nearestMounted = node.return), + 0 !== (node.flags & 4098) && (nearestMounted = node.return), (fiber = node.return); while (fiber); } @@ -2453,7 +2448,7 @@ function processUpdateQueue( newState = workInProgress; break a; case 3: - workInProgress.flags = (workInProgress.flags & -32769) | 128; + workInProgress.flags = (workInProgress.flags & -65537) | 128; case 0: workInProgress = update.payload; updateLane = @@ -2706,7 +2701,8 @@ function coerceRef(returnFiber, current, element) { returnFiber + ". This error is likely caused by a bug in React. Please file an issue." ); - var stringRef = "" + returnFiber; + var resolvedInst = inst, + stringRef = "" + returnFiber; if ( null !== current && null !== current.ref && @@ -2715,8 +2711,8 @@ function coerceRef(returnFiber, current, element) { ) return current.ref; current = function(value) { - var refs = inst.refs; - refs === emptyRefsObject && (refs = inst.refs = {}); + var refs = resolvedInst.refs; + refs === emptyRefsObject && (refs = resolvedInst.refs = {}); null === value ? delete refs[stringRef] : (refs[stringRef] = value); }; current._stringRef = stringRef; @@ -3415,7 +3411,7 @@ function renderWithHooks( nextRenderLanes = 0; do { didScheduleRenderPhaseUpdateDuringThisPass = !1; - if (!(25 > nextRenderLanes)) + if (25 <= nextRenderLanes) throw Error( "Too many re-renders. React limits the number of renders to prevent an infinite loop." ); @@ -3516,19 +3512,18 @@ function updateReducer(reducer) { (newBaseQueueLast = newBaseQueueLast.next = { lane: 0, action: update.action, - eagerReducer: update.eagerReducer, + hasEagerState: update.hasEagerState, eagerState: update.eagerState, next: null }), - (current = - update.eagerReducer === reducer - ? update.eagerState - : reducer(current, update.action)); + (current = update.hasEagerState + ? update.eagerState + : reducer(current, update.action)); else { var clone = { lane: updateLane, action: update.action, - eagerReducer: update.eagerReducer, + hasEagerState: update.hasEagerState, eagerState: update.eagerState, next: null }; @@ -3668,7 +3663,7 @@ function useMutableSource(hook, source, getSnapshot, subscribe) { lastRenderedReducer: basicStateReducer, lastRenderedState: snapshot }), - (hook.dispatch = setSnapshot = dispatchAction.bind( + (hook.dispatch = setSnapshot = dispatchSetState.bind( null, currentlyRenderingFiber$1, hook @@ -3685,30 +3680,30 @@ function updateMutableSource(source, getSnapshot, subscribe) { } function mountSyncExternalStore(subscribe, getSnapshot) { var fiber = currentlyRenderingFiber$1, - hook = mountWorkInProgressHook(), - nextSnapshot = getSnapshot(); - hook.memoizedState = nextSnapshot; - var inst = { value: nextSnapshot, getSnapshot: getSnapshot }; - hook.queue = inst; - mountEffect(subscribeToStore.bind(null, fiber, inst, subscribe), [subscribe]); - fiber.flags |= 1024; - pushEffect( - 9, - updateStoreInstance.bind(null, fiber, inst, nextSnapshot, getSnapshot), - void 0, - null - ); - subscribe = workInProgressRoot; - if (null === subscribe) + hook = mountWorkInProgressHook(); + var nextSnapshot = getSnapshot(); + var root = workInProgressRoot; + if (null === root) throw Error( "Expected a work-in-progress root. This is a bug in React. Please file an issue." ); - includesBlockingLane(subscribe, renderLanes) || + includesBlockingLane(root, renderLanes) || pushStoreConsistencyCheck(fiber, getSnapshot, nextSnapshot); + hook.memoizedState = nextSnapshot; + root = { value: nextSnapshot, getSnapshot: getSnapshot }; + hook.queue = root; + mountEffect(subscribeToStore.bind(null, fiber, root, subscribe), [subscribe]); + fiber.flags |= 2048; + pushEffect( + 9, + updateStoreInstance.bind(null, fiber, root, nextSnapshot, getSnapshot), + void 0, + null + ); return nextSnapshot; } function pushStoreConsistencyCheck(fiber, getSnapshot, renderedSnapshot) { - fiber.flags |= 8192; + fiber.flags |= 16384; fiber = { getSnapshot: getSnapshot, value: renderedSnapshot }; getSnapshot = currentlyRenderingFiber$1.updateQueue; null === getSnapshot @@ -3753,7 +3748,7 @@ function mountState(initialState) { lastRenderedState: initialState }; hook.queue = initialState; - initialState = initialState.dispatch = dispatchAction.bind( + initialState = initialState.dispatch = dispatchSetState.bind( null, currentlyRenderingFiber$1, initialState @@ -3805,10 +3800,10 @@ function updateEffectImpl(fiberFlags, hookFlags, create, deps) { hook.memoizedState = pushEffect(1 | hookFlags, create, destroy, deps); } function mountEffect(create, deps) { - return mountEffectImpl(2098176, 8, create, deps); + return mountEffectImpl(4196352, 8, create, deps); } function updateEffect(create, deps) { - return updateEffectImpl(1024, 8, create, deps); + return updateEffectImpl(2048, 8, create, deps); } function updateInsertionEffect(create, deps) { return updateEffectImpl(4, 2, create, deps); @@ -3885,47 +3880,35 @@ function startTransition(setPending, callback) { (ReactCurrentBatchConfig$1.transition = prevTransition); } } -function dispatchAction(fiber, queue, action) { - var eventTime = requestEventTime(), - lane = requestUpdateLane(fiber), +function dispatchReducerAction(fiber, queue, action) { + var lane = requestUpdateLane(fiber); + action = { + lane: lane, + action: action, + hasEagerState: !1, + eagerState: null, + next: null + }; + isRenderPhaseUpdate(fiber) + ? enqueueRenderPhaseUpdate(queue, action) + : (enqueueUpdate$1(fiber, queue, action), + (action = requestEventTime()), + (fiber = scheduleUpdateOnFiber(fiber, lane, action)), + null !== fiber && entangleTransitionUpdate(fiber, queue, lane)); +} +function dispatchSetState(fiber, queue, action) { + var lane = requestUpdateLane(fiber), update = { lane: lane, action: action, - eagerReducer: null, + hasEagerState: !1, eagerState: null, next: null - }, - alternate = fiber.alternate; - if ( - fiber === currentlyRenderingFiber$1 || - (null !== alternate && alternate === currentlyRenderingFiber$1) - ) - (didScheduleRenderPhaseUpdateDuringThisPass = didScheduleRenderPhaseUpdate = !0), - (lane = queue.pending), - null === lane - ? (update.next = update) - : ((update.next = lane.next), (lane.next = update)), - (queue.pending = update); + }; + if (isRenderPhaseUpdate(fiber)) enqueueRenderPhaseUpdate(queue, update); else { - if ( - null !== workInProgressRoot && - 0 !== (fiber.mode & 1) && - 0 === (executionContext & 2) - ) { - var interleaved = queue.interleaved; - null === interleaved - ? ((update.next = update), - null === interleavedQueues - ? (interleavedQueues = [queue]) - : interleavedQueues.push(queue)) - : ((update.next = interleaved.next), (interleaved.next = update)); - queue.interleaved = update; - } else - (interleaved = queue.pending), - null === interleaved - ? (update.next = update) - : ((update.next = interleaved.next), (interleaved.next = update)), - (queue.pending = update); + enqueueUpdate$1(fiber, queue, update); + var alternate = fiber.alternate; if ( 0 === fiber.lanes && (null === alternate || 0 === alternate.lanes) && @@ -3934,20 +3917,57 @@ function dispatchAction(fiber, queue, action) { try { var currentState = queue.lastRenderedState, eagerState = alternate(currentState, action); - update.eagerReducer = alternate; + update.hasEagerState = !0; update.eagerState = eagerState; if (objectIs(eagerState, currentState)) return; } catch (error) { } finally { } - update = scheduleUpdateOnFiber(fiber, lane, eventTime); - 0 !== (lane & 4194240) && - null !== update && - ((fiber = queue.lanes), - (fiber &= update.pendingLanes), - (lane |= fiber), - (queue.lanes = lane), - markRootEntangled(update, lane)); + action = requestEventTime(); + fiber = scheduleUpdateOnFiber(fiber, lane, action); + null !== fiber && entangleTransitionUpdate(fiber, queue, lane); + } +} +function isRenderPhaseUpdate(fiber) { + var alternate = fiber.alternate; + return ( + fiber === currentlyRenderingFiber$1 || + (null !== alternate && alternate === currentlyRenderingFiber$1) + ); +} +function enqueueRenderPhaseUpdate(queue, update) { + didScheduleRenderPhaseUpdateDuringThisPass = didScheduleRenderPhaseUpdate = !0; + var pending = queue.pending; + null === pending + ? (update.next = update) + : ((update.next = pending.next), (pending.next = update)); + queue.pending = update; +} +function enqueueUpdate$1(fiber, queue, update) { + null !== workInProgressRoot && + 0 !== (fiber.mode & 1) && + 0 === (executionContext & 2) + ? ((fiber = queue.interleaved), + null === fiber + ? ((update.next = update), + null === interleavedQueues + ? (interleavedQueues = [queue]) + : interleavedQueues.push(queue)) + : ((update.next = fiber.next), (fiber.next = update)), + (queue.interleaved = update)) + : ((fiber = queue.pending), + null === fiber + ? (update.next = update) + : ((update.next = fiber.next), (fiber.next = update)), + (queue.pending = update)); +} +function entangleTransitionUpdate(root, queue, lane) { + if (0 !== (lane & 4194240)) { + var queueLanes = queue.lanes; + queueLanes &= root.pendingLanes; + lane |= queueLanes; + queue.lanes = lane; + markRootEntangled(root, lane); } } var ContextOnlyDispatcher = { @@ -4016,7 +4036,7 @@ var ContextOnlyDispatcher = { lastRenderedState: initialArg }; hook.queue = reducer; - reducer = reducer.dispatch = dispatchAction.bind( + reducer = reducer.dispatch = dispatchReducerAction.bind( null, currentlyRenderingFiber$1, reducer @@ -4126,7 +4146,7 @@ var ContextOnlyDispatcher = { (null !== workInProgressHook && workInProgressHook.memoizedState.tag & 1) ) { - fiber.flags |= 1024; + fiber.flags |= 2048; pushEffect( 9, updateStoreInstance.bind( @@ -4337,7 +4357,7 @@ function hadNoMutationsEffects(current, completedWork) { if (null !== current && current.child === completedWork.child) return !0; if (0 !== (completedWork.flags & 16)) return !1; for (current = completedWork.child; null !== current; ) { - if (0 !== (current.flags & 6454) || 0 !== (current.subtreeFlags & 6454)) + if (0 !== (current.flags & 12854) || 0 !== (current.subtreeFlags & 12854)) return !1; current = current.sibling; } @@ -4501,14 +4521,14 @@ function cutOffTailIfNeeded(renderState, hasRenderedATailFallback) { break; case "collapsed": lastTailNode = renderState.tail; - for (var lastTailNode$40 = null; null !== lastTailNode; ) - null !== lastTailNode.alternate && (lastTailNode$40 = lastTailNode), + for (var lastTailNode$37 = null; null !== lastTailNode; ) + null !== lastTailNode.alternate && (lastTailNode$37 = lastTailNode), (lastTailNode = lastTailNode.sibling); - null === lastTailNode$40 + null === lastTailNode$37 ? hasRenderedATailFallback || null === renderState.tail ? (renderState.tail = null) : (renderState.tail.sibling = null) - : (lastTailNode$40.sibling = null); + : (lastTailNode$37.sibling = null); } } function bubbleProperties(completedWork) { @@ -4520,53 +4540,53 @@ function bubbleProperties(completedWork) { if (didBailout) if (0 !== (completedWork.mode & 2)) { for ( - var treeBaseDuration$42 = completedWork.selfBaseDuration, - child$43 = completedWork.child; - null !== child$43; + var treeBaseDuration$39 = completedWork.selfBaseDuration, + child$40 = completedWork.child; + null !== child$40; ) - (newChildLanes |= child$43.lanes | child$43.childLanes), - (subtreeFlags |= child$43.subtreeFlags & 3670016), - (subtreeFlags |= child$43.flags & 3670016), - (treeBaseDuration$42 += child$43.treeBaseDuration), - (child$43 = child$43.sibling); - completedWork.treeBaseDuration = treeBaseDuration$42; + (newChildLanes |= child$40.lanes | child$40.childLanes), + (subtreeFlags |= child$40.subtreeFlags & 7340032), + (subtreeFlags |= child$40.flags & 7340032), + (treeBaseDuration$39 += child$40.treeBaseDuration), + (child$40 = child$40.sibling); + completedWork.treeBaseDuration = treeBaseDuration$39; } else for ( - treeBaseDuration$42 = completedWork.child; - null !== treeBaseDuration$42; + treeBaseDuration$39 = completedWork.child; + null !== treeBaseDuration$39; ) (newChildLanes |= - treeBaseDuration$42.lanes | treeBaseDuration$42.childLanes), - (subtreeFlags |= treeBaseDuration$42.subtreeFlags & 3670016), - (subtreeFlags |= treeBaseDuration$42.flags & 3670016), - (treeBaseDuration$42.return = completedWork), - (treeBaseDuration$42 = treeBaseDuration$42.sibling); + treeBaseDuration$39.lanes | treeBaseDuration$39.childLanes), + (subtreeFlags |= treeBaseDuration$39.subtreeFlags & 7340032), + (subtreeFlags |= treeBaseDuration$39.flags & 7340032), + (treeBaseDuration$39.return = completedWork), + (treeBaseDuration$39 = treeBaseDuration$39.sibling); else if (0 !== (completedWork.mode & 2)) { - treeBaseDuration$42 = completedWork.actualDuration; - child$43 = completedWork.selfBaseDuration; + treeBaseDuration$39 = completedWork.actualDuration; + child$40 = completedWork.selfBaseDuration; for (var child = completedWork.child; null !== child; ) (newChildLanes |= child.lanes | child.childLanes), (subtreeFlags |= child.subtreeFlags), (subtreeFlags |= child.flags), - (treeBaseDuration$42 += child.actualDuration), - (child$43 += child.treeBaseDuration), + (treeBaseDuration$39 += child.actualDuration), + (child$40 += child.treeBaseDuration), (child = child.sibling); - completedWork.actualDuration = treeBaseDuration$42; - completedWork.treeBaseDuration = child$43; + completedWork.actualDuration = treeBaseDuration$39; + completedWork.treeBaseDuration = child$40; } else for ( - treeBaseDuration$42 = completedWork.child; - null !== treeBaseDuration$42; + treeBaseDuration$39 = completedWork.child; + null !== treeBaseDuration$39; ) (newChildLanes |= - treeBaseDuration$42.lanes | treeBaseDuration$42.childLanes), - (subtreeFlags |= treeBaseDuration$42.subtreeFlags), - (subtreeFlags |= treeBaseDuration$42.flags), - (treeBaseDuration$42.return = completedWork), - (treeBaseDuration$42 = treeBaseDuration$42.sibling); + treeBaseDuration$39.lanes | treeBaseDuration$39.childLanes), + (subtreeFlags |= treeBaseDuration$39.subtreeFlags), + (subtreeFlags |= treeBaseDuration$39.flags), + (treeBaseDuration$39.return = completedWork), + (treeBaseDuration$39 = treeBaseDuration$39.sibling); completedWork.subtreeFlags |= subtreeFlags; completedWork.childLanes = newChildLanes; return didBailout; @@ -4593,7 +4613,7 @@ function completeSuspendedOffscreenHostContainer(current, workInProgress) { )), appendAllChildren(rootContainerInstance, workInProgress, !1, !1), (workInProgress.stateNode = rootContainerInstance), - null !== workInProgress.ref && (workInProgress.flags |= 256)); + null !== workInProgress.ref && (workInProgress.flags |= 512)); bubbleProperties(workInProgress); } function completeWork(current, workInProgress, renderLanes) { @@ -4627,8 +4647,8 @@ function completeWork(current, workInProgress, renderLanes) { ((newProps.context = newProps.pendingContext), (newProps.pendingContext = null)), (null !== current && null !== current.child) || - newProps.hydrate || - (workInProgress.flags |= 512), + newProps.isDehydrated || + (workInProgress.flags |= 1024), updateHostContainer(current, workInProgress), bubbleProperties(workInProgress), null @@ -4645,7 +4665,7 @@ function completeWork(current, workInProgress, renderLanes) { newProps, renderLanes ), - current.ref !== workInProgress.ref && (workInProgress.flags |= 256); + current.ref !== workInProgress.ref && (workInProgress.flags |= 512); else { if (!newProps) { if (null === workInProgress.stateNode) @@ -4665,7 +4685,7 @@ function completeWork(current, workInProgress, renderLanes) { ); appendAllChildren(current, workInProgress, !1, !1); workInProgress.stateNode = current; - null !== workInProgress.ref && (workInProgress.flags |= 256); + null !== workInProgress.ref && (workInProgress.flags |= 512); } bubbleProperties(workInProgress); return null; @@ -4709,7 +4729,7 @@ function completeWork(current, workInProgress, renderLanes) { if ( newProps && !renderLanes && - ((workInProgress.child.flags |= 4096), 0 !== (workInProgress.mode & 1)) + ((workInProgress.child.flags |= 8192), 0 !== (workInProgress.mode & 1)) ) if ( (null === current && @@ -4721,7 +4741,8 @@ function completeWork(current, workInProgress, renderLanes) { else { if ( 0 === workInProgressRootExitStatus || - 3 === workInProgressRootExitStatus + 3 === workInProgressRootExitStatus || + 2 === workInProgressRootExitStatus ) workInProgressRootExitStatus = 4; null === workInProgressRoot || @@ -4786,7 +4807,7 @@ function completeWork(current, workInProgress, renderLanes) { for (newProps = workInProgress.child; null !== newProps; ) (renderLanes = newProps), (renderedTail = current), - (renderLanes.flags &= 3670018), + (renderLanes.flags &= 7340034), (type = renderLanes.alternate), null === type ? ((renderLanes.childLanes = 0), @@ -4892,7 +4913,7 @@ function completeWork(current, workInProgress, renderLanes) { (null !== current.memoizedState) !== renderLanes && "unstable-defer-without-hiding" !== newProps.mode && 23 !== workInProgress.tag && - (workInProgress.flags |= 4096), + (workInProgress.flags |= 8192), renderLanes && 0 !== (workInProgress.mode & 1) ? 0 !== (subtreeRenderLanes & 1073741824) && bubbleProperties(workInProgress) @@ -4940,7 +4961,7 @@ function updateForwardRef( if (null !== current && !didReceiveUpdate) return ( (workInProgress.updateQueue = current.updateQueue), - (workInProgress.flags &= -1029), + (workInProgress.flags &= -2053), (current.lanes &= ~renderLanes), bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes) ); @@ -5014,7 +5035,7 @@ function updateSimpleMemoComponent( current.ref === workInProgress.ref ) if (((didReceiveUpdate = !1), 0 !== (current.lanes & renderLanes))) - 0 !== (current.flags & 65536) && (didReceiveUpdate = !0); + 0 !== (current.flags & 131072) && (didReceiveUpdate = !0); else return ( (workInProgress.lanes = current.lanes), @@ -5117,7 +5138,7 @@ function markRef$1(current, workInProgress) { (null === current && null !== ref) || (null !== current && current.ref !== ref) ) - workInProgress.flags |= 256; + workInProgress.flags |= 512; } function updateFunctionComponent( current, @@ -5142,7 +5163,7 @@ function updateFunctionComponent( if (null !== current && !didReceiveUpdate) return ( (workInProgress.updateQueue = current.updateQueue), - (workInProgress.flags &= -1029), + (workInProgress.flags &= -2053), (current.lanes &= ~renderLanes), bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes) ); @@ -5318,7 +5339,7 @@ function updateClassComponent( "function" === typeof instance.componentDidUpdate && (workInProgress.flags |= 4), "function" === typeof instance.getSnapshotBeforeUpdate && - (workInProgress.flags |= 512)) + (workInProgress.flags |= 1024)) : ("function" !== typeof instance.componentDidUpdate || (oldProps === current.memoizedProps && oldState === current.memoizedState) || @@ -5326,7 +5347,7 @@ function updateClassComponent( "function" !== typeof instance.getSnapshotBeforeUpdate || (oldProps === current.memoizedProps && oldState === current.memoizedState) || - (workInProgress.flags |= 512), + (workInProgress.flags |= 1024), (workInProgress.memoizedProps = nextProps), (workInProgress.memoizedState = newState)), (instance.props = nextProps), @@ -5340,7 +5361,7 @@ function updateClassComponent( "function" !== typeof instance.getSnapshotBeforeUpdate || (oldProps === current.memoizedProps && oldState === current.memoizedState) || - (workInProgress.flags |= 512), + (workInProgress.flags |= 1024), (nextProps = !1)); } return finishClassComponent( @@ -5645,7 +5666,7 @@ function updateSuspenseFallbackChildren( primaryChildren ))), (current.subtreeFlags = - currentPrimaryChildFragment.subtreeFlags & 3670016)); + currentPrimaryChildFragment.subtreeFlags & 7340032)); null !== currentFallbackChildFragment ? (fallbackChildren = createWorkInProgress( currentFallbackChildFragment, @@ -5881,8 +5902,8 @@ function unwindWork(workInProgress) { case 1: isContextProvider(workInProgress.type) && popContext(); var flags = workInProgress.flags; - return flags & 32768 - ? ((workInProgress.flags = (flags & -32769) | 128), + return flags & 65536 + ? ((workInProgress.flags = (flags & -65537) | 128), 0 !== (workInProgress.mode & 2) && transferActualDuration(workInProgress), workInProgress) @@ -5897,7 +5918,7 @@ function unwindWork(workInProgress) { throw Error( "The root failed to unmount after an error. This is likely a bug in React. Please file an issue." ); - workInProgress.flags = (flags & -32769) | 128; + workInProgress.flags = (flags & -65537) | 128; return workInProgress; case 5: return popHostContext(workInProgress), null; @@ -5905,8 +5926,8 @@ function unwindWork(workInProgress) { return ( pop(suspenseStackCursor), (flags = workInProgress.flags), - flags & 32768 - ? ((workInProgress.flags = (flags & -32769) | 128), + flags & 65536 + ? ((workInProgress.flags = (flags & -65537) | 128), 0 !== (workInProgress.mode & 2) && transferActualDuration(workInProgress), workInProgress) @@ -5961,7 +5982,7 @@ function commitBeforeMutationEffects(root, firstChild) { if ( ((root = nextEffect), (firstChild = root.child), - 0 !== (root.subtreeFlags & 516) && null !== firstChild) + 0 !== (root.subtreeFlags & 1028) && null !== firstChild) ) (firstChild.return = root), (nextEffect = firstChild); else @@ -5969,7 +5990,7 @@ function commitBeforeMutationEffects(root, firstChild) { root = nextEffect; try { var current = root.alternate; - if (0 !== (root.flags & 512)) + if (0 !== (root.flags & 1024)) switch (root.tag) { case 0: case 11: @@ -6043,8 +6064,8 @@ function commitHookEffectListMount(tag, finishedWork) { var effect = (finishedWork = finishedWork.next); do { if ((effect.tag & tag) === tag) { - var create$89 = effect.create; - effect.destroy = create$89(); + var create$86 = effect.create; + effect.destroy = create$86(); } effect = effect.next; } while (effect !== finishedWork); @@ -6233,14 +6254,14 @@ function commitMutationEffects(root, firstChild, committedLanes) { } } firstChild = root.child; - if (0 !== (root.subtreeFlags & 6454) && null !== firstChild) + if (0 !== (root.subtreeFlags & 12854) && null !== firstChild) (firstChild.return = root), (nextEffect = firstChild); else for (; null !== nextEffect; ) { root = nextEffect; try { var flags = root.flags; - if (flags & 256) { + if (flags & 512) { var current$jscomp$0 = root.alternate; if (null !== current$jscomp$0) { firstChild = current$jscomp$0; @@ -6257,16 +6278,16 @@ function commitMutationEffects(root, firstChild, committedLanes) { else currentRef.current = null; } } - if (flags & 4096) + if (flags & 8192) switch (root.tag) { case 13: if (null !== root.memoizedState) { - var current$95 = root.alternate; - if (null === current$95 || null === current$95.memoizedState) + var current$92 = root.alternate; + if (null === current$92 || null === current$92.memoizedState) globalMostRecentFallbackTime = now(); } } - switch (flags & 2054) { + switch (flags & 4102) { case 2: root.flags &= -3; break; @@ -6274,11 +6295,11 @@ function commitMutationEffects(root, firstChild, committedLanes) { root.flags &= -3; commitWork(root.alternate, root); break; - case 2048: - root.flags &= -2049; + case 4096: + root.flags &= -4097; break; - case 2052: - root.flags &= -2049; + case 4100: + root.flags &= -4097; commitWork(root.alternate, root); break; case 4: @@ -6305,16 +6326,16 @@ function commitLayoutEffects(finishedWork, root, committedLanes) { if ( ((root = nextEffect), (committedLanes = root.child), - 0 !== (root.subtreeFlags & 4420) && null !== committedLanes) + 0 !== (root.subtreeFlags & 8772) && null !== committedLanes) ) (committedLanes.return = root), (nextEffect = committedLanes); else for (root = finishedWork; null !== nextEffect; ) { committedLanes = nextEffect; - if (0 !== (committedLanes.flags & 4420)) { + if (0 !== (committedLanes.flags & 8772)) { var current = committedLanes.alternate; try { - if (0 !== (committedLanes.flags & 4420)) + if (0 !== (committedLanes.flags & 8772)) switch (committedLanes.tag) { case 0: case 11: @@ -6372,22 +6393,22 @@ function commitLayoutEffects(finishedWork, root, committedLanes) { commitUpdateQueue(committedLanes, updateQueue, instance); break; case 3: - var updateQueue$91 = committedLanes.updateQueue; - if (null !== updateQueue$91) { - var instance$92 = null; + var updateQueue$88 = committedLanes.updateQueue; + if (null !== updateQueue$88) { + var instance$89 = null; if (null !== committedLanes.child) switch (committedLanes.child.tag) { case 5: - instance$92 = + instance$89 = committedLanes.child.stateNode.canonical; break; case 1: - instance$92 = committedLanes.child.stateNode; + instance$89 = committedLanes.child.stateNode; } commitUpdateQueue( committedLanes, - updateQueue$91, - instance$92 + updateQueue$88, + instance$89 ); } break; @@ -6403,7 +6424,7 @@ function commitLayoutEffects(finishedWork, root, committedLanes) { onCommit = _finishedWork$memoize2.onCommit, onRender = _finishedWork$memoize2.onRender, effectDuration = committedLanes.stateNode.effectDuration; - instance$92 = commitTime; + instance$89 = commitTime; current = null === current ? "mount" : "update"; currentUpdateIsNested && (current = "nested-update"); "function" === typeof onRender && @@ -6413,14 +6434,14 @@ function commitLayoutEffects(finishedWork, root, committedLanes) { committedLanes.actualDuration, committedLanes.treeBaseDuration, committedLanes.actualStartTime, - instance$92 + instance$89 ); "function" === typeof onCommit && onCommit( committedLanes.memoizedProps.id, current, effectDuration, - instance$92 + instance$89 ); enqueuePendingPassiveProfilerEffect(committedLanes); var parentFiber = committedLanes.return; @@ -6449,28 +6470,28 @@ function commitLayoutEffects(finishedWork, root, committedLanes) { "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 (committedLanes.flags & 256) { - instance$92 = void 0; + if (committedLanes.flags & 512) { + instance$89 = void 0; current = committedLanes; var ref = current.ref; if (null !== ref) { var instance$jscomp$0 = current.stateNode; switch (current.tag) { case 5: - instance$92 = instance$jscomp$0.canonical; + instance$89 = instance$jscomp$0.canonical; break; default: - instance$92 = instance$jscomp$0; + instance$89 = instance$jscomp$0; } if ("function" === typeof ref) if (current.mode & 2) try { - startLayoutEffectTimer(), ref(instance$92); + startLayoutEffectTimer(), ref(instance$89); } finally { recordLayoutEffectDuration(current); } - else ref(instance$92); - else ref.current = instance$92; + else ref(instance$89); + else ref.current = instance$89; } } } catch (error) { @@ -6485,10 +6506,10 @@ function commitLayoutEffects(finishedWork, root, committedLanes) { nextEffect = null; break; } - instance$92 = committedLanes.sibling; - if (null !== instance$92) { - instance$92.return = committedLanes.return; - nextEffect = instance$92; + instance$89 = committedLanes.sibling; + if (null !== instance$89) { + instance$89.return = committedLanes.return; + nextEffect = instance$89; break; } nextEffect = committedLanes.return; @@ -6834,14 +6855,14 @@ function performConcurrentWorkOnRoot(root, didTimeout) { function recoverFromConcurrentError(root, errorRetryLanes) { var prevExecutionContext = executionContext; executionContext |= 8; - root.hydrate && ((root.hydrate = !1), shim(root.containerInfo)); + root.isDehydrated && ((root.isDehydrated = !1), shim(root.containerInfo)); root = renderRootSync(root, errorRetryLanes); executionContext = prevExecutionContext; return root; } function isRenderConsistentWithExternalStores(finishedWork) { for (var node = finishedWork; ; ) { - if (node.flags & 8192) { + if (node.flags & 16384) { var updateQueue = node.updateQueue; if ( null !== updateQueue && @@ -6859,7 +6880,7 @@ function isRenderConsistentWithExternalStores(finishedWork) { } } updateQueue = node.child; - if (node.subtreeFlags & 8192 && null !== updateQueue) + if (node.subtreeFlags & 16384 && null !== updateQueue) (updateQueue.return = node), (node = updateQueue); else { if (node === finishedWork) break; @@ -6897,7 +6918,7 @@ function performSyncWorkOnRoot(root) { if (0 !== root.tag && 2 === exitStatus) { var prevExecutionContext = executionContext; executionContext |= 8; - root.hydrate && ((root.hydrate = !1), shim(root.containerInfo)); + root.isDehydrated && ((root.isDehydrated = !1), shim(root.containerInfo)); var errorRetryLanes = getLanesToRetrySynchronouslyOnError(root); 0 !== errorRetryLanes && ((lanes = errorRetryLanes), (exitStatus = renderRootSync(root, lanes))); @@ -7024,7 +7045,7 @@ function handleError(root$jscomp$0, thrownValue) { sourceFiber = erroredWork, value = thrownValue; thrownValue = workInProgressRootRenderLanes; - sourceFiber.flags |= 16384; + sourceFiber.flags |= 32768; isDevToolsPresent && restorePendingUpdaters(root, thrownValue); if ( null !== value && @@ -7032,78 +7053,90 @@ function handleError(root$jscomp$0, thrownValue) { "function" === typeof value.then ) { var wakeable = value, - tag = sourceFiber.tag; + sourceFiber$jscomp$0 = sourceFiber, + tag = sourceFiber$jscomp$0.tag; if ( - 0 === (sourceFiber.mode & 1) && + 0 === (sourceFiber$jscomp$0.mode & 1) && (0 === tag || 11 === tag || 15 === tag) ) { - var currentSource = sourceFiber.alternate; + var currentSource = sourceFiber$jscomp$0.alternate; currentSource - ? ((sourceFiber.updateQueue = currentSource.updateQueue), - (sourceFiber.memoizedState = currentSource.memoizedState), - (sourceFiber.lanes = currentSource.lanes)) - : ((sourceFiber.updateQueue = null), - (sourceFiber.memoizedState = null)); + ? ((sourceFiber$jscomp$0.updateQueue = currentSource.updateQueue), + (sourceFiber$jscomp$0.memoizedState = + currentSource.memoizedState), + (sourceFiber$jscomp$0.lanes = currentSource.lanes)) + : ((sourceFiber$jscomp$0.updateQueue = null), + (sourceFiber$jscomp$0.memoizedState = null)); } - var hasInvisibleParentBoundary = - 0 !== (suspenseStackCursor.current & 1), - workInProgress$32 = returnFiber; - do { - var JSCompiler_temp; - if ((JSCompiler_temp = 13 === workInProgress$32.tag)) { - var nextState = workInProgress$32.memoizedState; - JSCompiler_temp = - null !== nextState - ? null !== nextState.dehydrated + b: { + sourceFiber$jscomp$0 = returnFiber; + var sourceFiber$jscomp$1 = sourceFiber, + rootRenderLanes = thrownValue, + hasInvisibleParentBoundary = + 0 !== (suspenseStackCursor.current & 1), + node = sourceFiber$jscomp$0; + do { + var JSCompiler_temp; + if ((JSCompiler_temp = 13 === node.tag)) { + var nextState = node.memoizedState; + JSCompiler_temp = + null !== nextState + ? null !== nextState.dehydrated + ? !0 + : !1 + : !0 !== node.memoizedProps.unstable_avoidThisFallback ? !0 - : !1 - : !0 !== - workInProgress$32.memoizedProps.unstable_avoidThisFallback - ? !0 - : hasInvisibleParentBoundary - ? !1 - : !0; - } - if (JSCompiler_temp) { - var wakeables = workInProgress$32.updateQueue; - if (null === wakeables) { - var updateQueue = new Set(); - updateQueue.add(wakeable); - workInProgress$32.updateQueue = updateQueue; - } else wakeables.add(wakeable); - if ( - 0 === (workInProgress$32.mode & 1) && - workInProgress$32 !== returnFiber - ) { - workInProgress$32.flags |= 128; - sourceFiber.flags |= 65536; - sourceFiber.flags &= -26437; - if ( - enablePersistentOffscreenHostContainer && - null === workInProgress$32.alternate - ) { - var offscreenContainer = workInProgress$32.child.child; - if (null !== offscreenContainer) { - var containerProps = getOffscreenContainerProps( - "hidden", - offscreenContainer.memoizedProps.children - ); - offscreenContainer.pendingProps = containerProps; - offscreenContainer.memoizedProps = containerProps; - } - } - if (1 === sourceFiber.tag) - if (null === sourceFiber.alternate) sourceFiber.tag = 17; - else { - var update = createUpdate(-1, 1); - update.tag = 2; - enqueueUpdate(sourceFiber, update); - } - sourceFiber.lanes |= 1; - break a; + : hasInvisibleParentBoundary + ? !1 + : !0; } - value = void 0; - sourceFiber = thrownValue; + if (JSCompiler_temp) { + if (0 === (node.mode & 1)) { + if (node === sourceFiber$jscomp$0) node.flags |= 65536; + else { + node.flags |= 128; + sourceFiber$jscomp$1.flags |= 131072; + sourceFiber$jscomp$1.flags &= -52805; + if ( + enablePersistentOffscreenHostContainer && + null === node.alternate + ) { + var offscreenContainer = node.child.child; + if (null !== offscreenContainer) { + var containerProps = getOffscreenContainerProps( + "hidden", + offscreenContainer.memoizedProps.children + ); + offscreenContainer.pendingProps = containerProps; + offscreenContainer.memoizedProps = containerProps; + } + } + if (1 === sourceFiber$jscomp$1.tag) + if (null === sourceFiber$jscomp$1.alternate) + sourceFiber$jscomp$1.tag = 17; + else { + var update = createUpdate(-1, 1); + update.tag = 2; + enqueueUpdate(sourceFiber$jscomp$1, update); + } + sourceFiber$jscomp$1.lanes |= 1; + } + var suspenseBoundary = node; + break b; + } + node.flags |= 65536; + node.lanes = rootRenderLanes; + suspenseBoundary = node; + break b; + } + node = node.return; + } while (null !== node); + suspenseBoundary = null; + } + if (null !== suspenseBoundary) { + value = void 0; + sourceFiber = suspenseBoundary; + if (sourceFiber.mode & 1) { var pingCache = root.pingCache; null === pingCache ? ((pingCache = root.pingCache = new PossiblyWeakMap()), @@ -7112,72 +7145,75 @@ function handleError(root$jscomp$0, thrownValue) { : ((value = pingCache.get(wakeable)), void 0 === value && ((value = new Set()), pingCache.set(wakeable, value))); - if (!value.has(sourceFiber)) { - value.add(sourceFiber); + if (!value.has(thrownValue)) { + value.add(thrownValue); var ping = pingSuspendedRoot.bind( null, root, wakeable, - sourceFiber + thrownValue ); - isDevToolsPresent && restorePendingUpdaters(root, sourceFiber); + isDevToolsPresent && restorePendingUpdaters(root, thrownValue); wakeable.then(ping, ping); } - workInProgress$32.flags |= 32768; - workInProgress$32.lanes = thrownValue; - break a; } - workInProgress$32 = workInProgress$32.return; - } while (null !== workInProgress$32); - value = Error( - (getComponentNameFromFiber(sourceFiber) || "A React component") + - " suspended while rendering, but no fallback UI was specified.\n\nAdd a component higher in the tree to provide a loading indicator or placeholder to display." - ); + var wakeables = sourceFiber.updateQueue; + if (null === wakeables) { + var updateQueue = new Set(); + updateQueue.add(wakeable); + sourceFiber.updateQueue = updateQueue; + } else wakeables.add(wakeable); + break a; + } else + value = Error( + (getComponentNameFromFiber(sourceFiber) || "A React component") + + " suspended while rendering, but no fallback UI was specified.\n\nAdd a component higher in the tree to provide a loading indicator or placeholder to display." + ); } - 5 !== workInProgressRootExitStatus && + 4 !== workInProgressRootExitStatus && (workInProgressRootExitStatus = 2); value = createCapturedValue(value, sourceFiber); - workInProgress$32 = returnFiber; + root = returnFiber; do { - switch (workInProgress$32.tag) { + switch (root.tag) { case 3: - root = value; - workInProgress$32.flags |= 32768; + wakeable = value; + root.flags |= 65536; thrownValue &= -thrownValue; - workInProgress$32.lanes |= thrownValue; - var update$33 = createRootErrorUpdate( - workInProgress$32, + root.lanes |= thrownValue; + var update$jscomp$0 = createRootErrorUpdate( root, + wakeable, thrownValue ); - enqueueCapturedUpdate(workInProgress$32, update$33); + enqueueCapturedUpdate(root, update$jscomp$0); break a; case 1: - root = value; - var ctor = workInProgress$32.type, - instance = workInProgress$32.stateNode; + wakeable = value; + var ctor = root.type, + instance = root.stateNode; if ( - 0 === (workInProgress$32.flags & 128) && + 0 === (root.flags & 128) && ("function" === typeof ctor.getDerivedStateFromError || (null !== instance && "function" === typeof instance.componentDidCatch && (null === legacyErrorBoundariesThatAlreadyFailed || !legacyErrorBoundariesThatAlreadyFailed.has(instance)))) ) { - workInProgress$32.flags |= 32768; + root.flags |= 65536; thrownValue &= -thrownValue; - workInProgress$32.lanes |= thrownValue; - var update$36 = createClassErrorUpdate( - workInProgress$32, + root.lanes |= thrownValue; + var update$33 = createClassErrorUpdate( root, + wakeable, thrownValue ); - enqueueCapturedUpdate(workInProgress$32, update$36); + enqueueCapturedUpdate(root, update$33); break a; } } - workInProgress$32 = workInProgress$32.return; - } while (null !== workInProgress$32); + root = root.return; + } while (null !== root); } completeUnitOfWork(erroredWork); } catch (yetAnotherThrownValue) { @@ -7254,7 +7290,7 @@ function completeUnitOfWork(unitOfWork) { do { var current = completedWork.alternate; unitOfWork = completedWork.return; - if (0 === (completedWork.flags & 16384)) { + if (0 === (completedWork.flags & 32768)) { if (0 === (completedWork.mode & 2)) current = completeWork(current, completedWork, subtreeRenderLanes); else { @@ -7271,7 +7307,7 @@ function completeUnitOfWork(unitOfWork) { } else { current = unwindWork(completedWork); if (null !== current) { - current.flags &= 16383; + current.flags &= 32767; workInProgress = current; return; } @@ -7283,7 +7319,7 @@ function completeUnitOfWork(unitOfWork) { completedWork.actualDuration = current; } null !== unitOfWork && - ((unitOfWork.flags |= 16384), + ((unitOfWork.flags |= 32768), (unitOfWork.subtreeFlags = 0), (unitOfWork.deletions = null)); } @@ -7330,16 +7366,16 @@ function commitRootImpl(root, renderPriorityLevel) { root === workInProgressRoot && ((workInProgress = workInProgressRoot = null), (workInProgressRootRenderLanes = 0)); - (0 === (finishedWork.subtreeFlags & 1040) && - 0 === (finishedWork.flags & 1040)) || + (0 === (finishedWork.subtreeFlags & 2064) && + 0 === (finishedWork.flags & 2064)) || rootDoesHavePassiveEffects || ((rootDoesHavePassiveEffects = !0), scheduleCallback$1(NormalPriority, function() { flushPassiveEffects(); return null; })); - remainingLanes = 0 !== (finishedWork.flags & 8054); - if (0 !== (finishedWork.subtreeFlags & 8054) || remainingLanes) { + remainingLanes = 0 !== (finishedWork.flags & 15990); + if (0 !== (finishedWork.subtreeFlags & 15990) || remainingLanes) { remainingLanes = ReactCurrentBatchConfig$2.transition; ReactCurrentBatchConfig$2.transition = 0; var previousPriority = currentUpdatePriority; @@ -7461,12 +7497,12 @@ function flushPassiveEffects() { nextEffect = fiber; } } - if (0 !== (fiber.subtreeFlags & 1040) && null !== child) + if (0 !== (fiber.subtreeFlags & 2064) && null !== child) (child.return = fiber), (nextEffect = child); else b: for (; null !== nextEffect; ) { fiber = nextEffect; - if (0 !== (fiber.flags & 1024)) + if (0 !== (fiber.flags & 2048)) switch (((i = fiber), i.tag)) { case 0: case 11: @@ -7490,12 +7526,12 @@ function flushPassiveEffects() { for (nextEffect = finishedWork; null !== nextEffect; ) { child = nextEffect; var firstChild = child.child; - if (0 !== (child.subtreeFlags & 1040) && null !== firstChild) + if (0 !== (child.subtreeFlags & 2064) && null !== firstChild) (firstChild.return = child), (nextEffect = firstChild); else b: for (child = finishedWork; null !== nextEffect; ) { deletions = nextEffect; - if (0 !== (deletions.flags & 1024)) + if (0 !== (deletions.flags & 2048)) try { switch (((fiberToDelete = deletions), fiberToDelete.tag)) { case 0: @@ -7703,7 +7739,7 @@ beginWork$1 = function(current, workInProgress, renderLanes) { renderLanes ) ); - didReceiveUpdate = 0 !== (current.flags & 65536) ? !0 : !1; + didReceiveUpdate = 0 !== (current.flags & 131072) ? !0 : !1; } else didReceiveUpdate = !1; workInProgress.lanes = 0; @@ -8184,7 +8220,7 @@ function createWorkInProgress(current, pendingProps) { (workInProgress.deletions = null), (workInProgress.actualDuration = 0), (workInProgress.actualStartTime = -1)); - workInProgress.flags = current.flags & 3670016; + workInProgress.flags = current.flags & 7340032; workInProgress.childLanes = current.childLanes; workInProgress.lanes = current.lanes; workInProgress.child = current.child; @@ -8280,8 +8316,7 @@ function createFiberFromTypeAndProps( } throw Error( "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) + - "." + ((null == type ? type : typeof type) + ".") ); } key = createFiber(fiberTag, pendingProps, key, mode); @@ -8334,7 +8369,7 @@ function FiberRootNode(containerInfo, tag, hydrate) { this.finishedWork = this.pingCache = this.current = this.pendingChildren = null; this.timeoutHandle = -1; this.pendingContext = this.context = null; - this.hydrate = hydrate; + this.isDehydrated = hydrate; this.callbackNode = null; this.callbackPriority = 0; this.eventTimes = createLaneMap(0); @@ -8362,9 +8397,9 @@ function findHostInstance(component) { if (void 0 === fiber) { if ("function" === typeof component.render) throw Error("Unable to find node on an unmounted component."); + component = Object.keys(component).join(","); throw Error( - "Argument appears to not be a ReactComponent. Keys: " + - Object.keys(component) + "Argument appears to not be a ReactComponent. Keys: " + component ); } component = findCurrentHostFiber(fiber); @@ -8548,10 +8583,10 @@ batchedUpdatesImpl = function(fn, a) { } }; var roots = new Map(), - devToolsConfig$jscomp$inline_980 = { + devToolsConfig$jscomp$inline_965 = { findFiberByHostInstance: getInstanceFromInstance, bundleType: 0, - version: "18.0.0-e8feb11b6-20210915", + version: "18.0.0-afcb9cdc9-20211008", rendererPackageName: "react-native-renderer", rendererConfig: { getInspectorDataForViewTag: function() { @@ -8566,11 +8601,11 @@ var roots = new Map(), }.bind(null, findNodeHandle) } }; -var internals$jscomp$inline_1241 = { - bundleType: devToolsConfig$jscomp$inline_980.bundleType, - version: devToolsConfig$jscomp$inline_980.version, - rendererPackageName: devToolsConfig$jscomp$inline_980.rendererPackageName, - rendererConfig: devToolsConfig$jscomp$inline_980.rendererConfig, +var internals$jscomp$inline_1239 = { + bundleType: devToolsConfig$jscomp$inline_965.bundleType, + version: devToolsConfig$jscomp$inline_965.version, + rendererPackageName: devToolsConfig$jscomp$inline_965.rendererPackageName, + rendererConfig: devToolsConfig$jscomp$inline_965.rendererConfig, overrideHookState: null, overrideHookStateDeletePath: null, overrideHookStateRenamePath: null, @@ -8586,27 +8621,26 @@ var internals$jscomp$inline_1241 = { return null === fiber ? null : fiber.stateNode; }, findFiberByHostInstance: - devToolsConfig$jscomp$inline_980.findFiberByHostInstance || + devToolsConfig$jscomp$inline_965.findFiberByHostInstance || emptyFindFiberByHostInstance, findHostInstancesForRefresh: null, scheduleRefresh: null, scheduleRoot: null, setRefreshHandler: null, getCurrentFiber: null, - getIsStrictMode: null, - reconcilerVersion: "18.0.0-e8feb11b6-20210915" + reconcilerVersion: "18.0.0-afcb9cdc9-20211008" }; if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) { - var hook$jscomp$inline_1242 = __REACT_DEVTOOLS_GLOBAL_HOOK__; + var hook$jscomp$inline_1240 = __REACT_DEVTOOLS_GLOBAL_HOOK__; if ( - !hook$jscomp$inline_1242.isDisabled && - hook$jscomp$inline_1242.supportsFiber + !hook$jscomp$inline_1240.isDisabled && + hook$jscomp$inline_1240.supportsFiber ) try { - (rendererID = hook$jscomp$inline_1242.inject( - internals$jscomp$inline_1241 + (rendererID = hook$jscomp$inline_1240.inject( + internals$jscomp$inline_1239 )), - (injectedHook = hook$jscomp$inline_1242); + (injectedHook = hook$jscomp$inline_1240); } catch (err) {} } exports.createPortal = function(children, containerTag) { diff --git a/Libraries/Renderer/implementations/ReactNativeRenderer-dev.fb.js b/Libraries/Renderer/implementations/ReactNativeRenderer-dev.fb.js index 0f1cae0b61..1c526c7f8c 100644 --- a/Libraries/Renderer/implementations/ReactNativeRenderer-dev.fb.js +++ b/Libraries/Renderer/implementations/ReactNativeRenderer-dev.fb.js @@ -7,7 +7,7 @@ * @noflow * @nolint * @preventMunge - * @generated SignedSource<> + * @generated SignedSource<> */ 'use strict'; @@ -75,10 +75,10 @@ function printWarning(level, format, args) { if (stack !== "") { format += "%s"; args = args.concat([stack]); - } + } // eslint-disable-next-line react-internal/safe-string-coercion var argsWithFormat = args.map(function(item) { - return "" + item; + return String(item); }); // Careful: RN currently depends on this prefix argsWithFormat.unshift("Warning: " + format); // We intentionally don't use spread (or .apply) directly because it @@ -145,9 +145,15 @@ var invokeGuardedCallbackImpl = invokeGuardedCallbackProd; // when we call document.createEvent(). However this can cause confusing // errors: https://github.com/facebook/create-react-app/issues/3482 // So we preemptively throw with a better message instead. - if (!(typeof document !== "undefined")) { - throw Error( - "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." + if (typeof document === "undefined") { + throw new Error( + "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." ); } @@ -253,6 +259,7 @@ var invokeGuardedCallbackImpl = invokeGuardedCallbackProd; if (didCall && didError) { if (!didSetError) { // The callback errored, but the error event never fired. + // eslint-disable-next-line react-internal/prod-error-codes error = new Error( "An error was thrown inside one of your components, but React " + "doesn't know what it was. This is likely due to browser " + @@ -264,6 +271,7 @@ var invokeGuardedCallbackImpl = invokeGuardedCallbackProd; "actually an issue with React, please file an issue." ); } else if (isCrossOriginError) { + // eslint-disable-next-line react-internal/prod-error-codes error = new Error( "A cross-origin error was thrown. React doesn't have access to " + "the actual error object in development. " + @@ -376,11 +384,10 @@ function clearCaughtError() { caughtError = null; return error; } else { - { - throw Error( - "clearCaughtError was called but no error was captured. This error is likely caused by a bug in React. Please file an issue." - ); - } + throw new Error( + "clearCaughtError was called but no error was captured. This error " + + "is likely caused by a bug in React. Please file an issue." + ); } } @@ -537,8 +544,8 @@ function executeDirectDispatch(event) { var dispatchListener = event._dispatchListeners; var dispatchInstance = event._dispatchInstances; - if (!!isArray(dispatchListener)) { - throw Error("executeDirectDispatch(...): Invalid `event`."); + if (isArray(dispatchListener)) { + throw new Error("executeDirectDispatch(...): Invalid `event`."); } event.currentTarget = dispatchListener @@ -559,6 +566,7 @@ function hasDispatches(event) { return !!event._dispatchListeners; } +/* eslint valid-typeof: 0 */ var EVENT_POOL_SIZE = 10; /** * @interface Event @@ -885,7 +893,7 @@ function releasePooledEvent(event) { var EventConstructor = this; if (!(event instanceof EventConstructor)) { - throw Error( + throw new Error( "Trying to release an event instance into a pool of a different type." ); } @@ -994,8 +1002,8 @@ function resetTouchRecord(touchRecord, touch) { function getTouchIdentifier(_ref) { var identifier = _ref.identifier; - if (!(identifier != null)) { - throw Error("Touch object is missing identifier."); + if (identifier == null) { + throw new Error("Touch object is missing identifier."); } { @@ -1153,8 +1161,8 @@ var ResponderTouchHistoryStore = { */ function accumulate(current, next) { - if (!(next != null)) { - throw Error( + if (next == null) { + throw new Error( "accumulate(...): Accumulated items must not be null or undefined." ); } @@ -1189,8 +1197,8 @@ function accumulate(current, next) { */ function accumulateInto(current, next) { - if (!(next != null)) { - throw Error( + if (next == null) { + throw new Error( "accumulateInto(...): Accumulated items must not be null or undefined." ); } @@ -1496,8 +1504,8 @@ function getListener(inst, registrationName) { var listener = props[registrationName]; - if (!(!listener || typeof listener === "function")) { - throw Error( + if (listener && typeof listener !== "function") { + throw new Error( "Expected `" + registrationName + "` listener to be a function, instead got a value of `" + @@ -2079,11 +2087,10 @@ function recomputePluginOrdering() { var pluginModule = namesToPlugins[pluginName]; var pluginIndex = eventPluginOrder.indexOf(pluginName); - if (!(pluginIndex > -1)) { - throw Error( - "EventPluginRegistry: Cannot inject event plugins that do not exist in the plugin ordering, `" + - pluginName + - "`." + if (pluginIndex <= -1) { + throw new Error( + "EventPluginRegistry: Cannot inject event plugins that do not exist in " + + ("the plugin ordering, `" + pluginName + "`.") ); } @@ -2092,10 +2099,9 @@ function recomputePluginOrdering() { } if (!pluginModule.extractEvents) { - throw Error( - "EventPluginRegistry: Event plugins must implement an `extractEvents` method, but `" + - pluginName + - "` does not." + throw new Error( + "EventPluginRegistry: Event plugins must implement an `extractEvents` " + + ("method, but `" + pluginName + "` does not.") ); } @@ -2110,7 +2116,7 @@ function recomputePluginOrdering() { eventName ) ) { - throw Error( + throw new Error( "EventPluginRegistry: Failed to publish event `" + eventName + "` for plugin `" + @@ -2131,11 +2137,10 @@ function recomputePluginOrdering() { */ function publishEventForPlugin(dispatchConfig, pluginModule, eventName) { - if (!!eventNameDispatchConfigs.hasOwnProperty(eventName)) { - throw Error( - "EventPluginRegistry: More than one plugin attempted to publish the same event name, `" + - eventName + - "`." + if (eventNameDispatchConfigs.hasOwnProperty(eventName)) { + throw new Error( + "EventPluginRegistry: More than one plugin attempted to publish the same " + + ("event name, `" + eventName + "`.") ); } @@ -2175,11 +2180,10 @@ function publishEventForPlugin(dispatchConfig, pluginModule, eventName) { */ function publishRegistrationName(registrationName, pluginModule, eventName) { - if (!!registrationNameModules[registrationName]) { - throw Error( - "EventPluginRegistry: More than one plugin attempted to publish the same registration name, `" + - registrationName + - "`." + if (registrationNameModules[registrationName]) { + throw new Error( + "EventPluginRegistry: More than one plugin attempted to publish the same " + + ("registration name, `" + registrationName + "`.") ); } @@ -2226,9 +2230,10 @@ var registrationNameDependencies = {}; */ function injectEventPluginOrder(injectedEventPluginOrder) { - if (!!eventPluginOrder) { - throw Error( - "EventPluginRegistry: Cannot inject event plugin ordering more than once. You are likely trying to load more than one copy of React." + if (eventPluginOrder) { + throw new Error( + "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. @@ -2259,11 +2264,10 @@ function injectEventPluginsByName(injectedNamesToPlugins) { !namesToPlugins.hasOwnProperty(pluginName) || namesToPlugins[pluginName] !== pluginModule ) { - if (!!namesToPlugins[pluginName]) { - throw Error( - "EventPluginRegistry: Cannot inject two different event plugins using the same name, `" + - pluginName + - "`." + if (namesToPlugins[pluginName]) { + throw new Error( + "EventPluginRegistry: Cannot inject two different event plugins " + + ("using the same name, `" + pluginName + "`.") ); } @@ -2294,8 +2298,8 @@ function getListener$1(inst, registrationName) { var listener = props[registrationName]; - if (!(!listener || typeof listener === "function")) { - throw Error( + if (listener && typeof listener !== "function") { + throw new Error( "Expected `" + registrationName + "` listener to be a function, instead got a value of `" + @@ -2443,8 +2447,8 @@ var ReactNativeBridgeEventPlugin = { var bubbleDispatchConfig = customBubblingEventTypes[topLevelType]; var directDispatchConfig = customDirectEventTypes[topLevelType]; - if (!(bubbleDispatchConfig || directDispatchConfig)) { - throw Error( + if (!bubbleDispatchConfig && !directDispatchConfig) { + throw new Error( // $FlowFixMe - Flow doesn't like this string coercion because DOMTopLevelEventType is opaque 'Unsupported top level event type "' + topLevelType + '" dispatched' ); } @@ -2518,7 +2522,7 @@ function getTagFromInstance(inst) { } if (!tag) { - throw Error("All native instances should have a tag."); + throw new Error("All native instances should have a tag."); } return nativeInstance; @@ -2602,9 +2606,10 @@ function runEventsInBatch(events) { forEachAccumulated(processingEventQueue, executeDispatchesAndReleaseTopLevel); - if (!!eventQueue) { - throw Error( - "processEventQueue(): Additional events were enqueued while processing an event queue. Support for this has not yet been implemented." + if (eventQueue) { + throw new Error( + "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. @@ -3136,6 +3141,7 @@ function getComponentNameFromFiber(fiber) { var enablePersistentOffscreenHostContainer = dynamicFlags.enablePersistentOffscreenHostContainer; // The rest of the flags are static for better dead code elimination. +var enableSchedulingProfiler = false; var enableProfilerTimer = true; var enableProfilerCommitHooks = true; var enableLazyElements = false; @@ -3175,41 +3181,41 @@ var DidCapture = 128; var Ref = /* */ - 256; + 512; var Snapshot = /* */ - 512; + 1024; var Passive = /* */ - 1024; + 2048; var Hydrating = /* */ - 2048; + 4096; var HydratingAndUpdate = /* */ Hydrating | Update; var Visibility = /* */ - 4096; + 8192; var StoreConsistency = /* */ - 8192; + 16384; var LifecycleEffectMask = Passive | Update | Callback | Ref | Snapshot | StoreConsistency; // Union of all commit flags (flags with the lifetime of a particular commit) var HostEffectMask = /* */ - 16383; // These are not really side effects, but we still reuse this field. + 32767; // These are not really side effects, but we still reuse this field. var Incomplete = /* */ - 16384; + 32768; var ShouldCapture = /* */ - 32768; + 65536; var ForceUpdateForLegacySuspense = /* */ - 65536; + 131072; // e.g. a fiber uses a passive effect (even if there are no updates on this particular render). // This enables us to defer more work in the unmount case, // since we can defer traversing the tree during layout to look for Passive effects, @@ -3217,22 +3223,22 @@ var ForceUpdateForLegacySuspense = var RefStatic = /* */ - 524288; + 1048576; var LayoutStatic = /* */ - 1048576; + 2097152; var PassiveStatic = /* */ - 2097152; // These flags allow us to traverse to fibers that have effects on mount + 4194304; // These flags allow us to traverse to fibers that have effects on mount // without traversing the entire tree after every commit for // double invoking var MountLayoutDev = /* */ - 4194304; + 8388608; var MountPassiveDev = /* */ - 8388608; // Groups of flags that are used in the commit phase to skip over trees that + 16777216; // Groups of flags that are used in the commit phase to skip over trees that // don't contain effects, by checking subtreeFlags. var BeforeMutationMask = // TODO: Remove Update flag from before mutation phase by re-landing Visibility @@ -3327,8 +3333,8 @@ function isMounted(component) { } function assertIsMounted(fiber) { - if (!(getNearestMountedFiber(fiber) === fiber)) { - throw Error("Unable to find node on an unmounted component."); + if (getNearestMountedFiber(fiber) !== fiber) { + throw new Error("Unable to find node on an unmounted component."); } } @@ -3339,8 +3345,8 @@ function findCurrentFiberUsingSlowPath(fiber) { // If there is no alternate, then we only need to check if it is mounted. var nearestMounted = getNearestMountedFiber(fiber); - if (!(nearestMounted !== null)) { - throw Error("Unable to find node on an unmounted component."); + if (nearestMounted === null) { + throw new Error("Unable to find node on an unmounted component."); } if (nearestMounted !== fiber) { @@ -3402,9 +3408,7 @@ 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. - { - throw Error("Unable to find node on an unmounted component."); - } + throw new Error("Unable to find node on an unmounted component."); } if (a.return !== b.return) { @@ -3464,23 +3468,25 @@ function findCurrentFiberUsingSlowPath(fiber) { } if (!didFindChild) { - throw Error( - "Child was not found in either parent set. This indicates a bug in React related to the return pointer. Please file an issue." + throw new Error( + "Child was not found in either parent set. This indicates a bug " + + "in React related to the return pointer. Please file an issue." ); } } } - if (!(a.alternate === b)) { - throw Error( - "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 new Error( + "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. - if (!(a.tag === HostRoot)) { - throw Error("Unable to find node on an unmounted component."); + if (a.tag !== HostRoot) { + throw new Error("Unable to find node on an unmounted component."); } if (a.stateNode.current === a) { @@ -4131,6 +4137,103 @@ var UserBlockingPriority = Scheduler.unstable_UserBlockingPriority; var NormalPriority = Scheduler.unstable_NormalPriority; var IdlePriority = Scheduler.unstable_IdlePriority; +// Helpers to patch console.logs to avoid logging during side-effect free +// replaying on render function. This currently only patches the object +// lazily which won't cover if the log function was extracted eagerly. +// We could also eagerly patch the method. +var disabledDepth = 0; +var prevLog; +var prevInfo; +var prevWarn; +var prevError; +var prevGroup; +var prevGroupCollapsed; +var prevGroupEnd; + +function disabledLog() {} + +disabledLog.__reactDisabledLog = true; +function disableLogs() { + { + if (disabledDepth === 0) { + /* eslint-disable react-internal/no-production-logging */ + prevLog = console.log; + prevInfo = console.info; + prevWarn = console.warn; + prevError = console.error; + prevGroup = console.group; + prevGroupCollapsed = console.groupCollapsed; + prevGroupEnd = console.groupEnd; // https://github.com/facebook/react/issues/19099 + + var props = { + configurable: true, + enumerable: true, + value: disabledLog, + writable: true + }; // $FlowFixMe Flow thinks console is immutable. + + Object.defineProperties(console, { + info: props, + log: props, + warn: props, + error: props, + group: props, + groupCollapsed: props, + groupEnd: props + }); + /* eslint-enable react-internal/no-production-logging */ + } + + disabledDepth++; + } +} +function reenableLogs() { + { + disabledDepth--; + + if (disabledDepth === 0) { + /* eslint-disable react-internal/no-production-logging */ + var props = { + configurable: true, + enumerable: true, + writable: true + }; // $FlowFixMe Flow thinks console is immutable. + + Object.defineProperties(console, { + log: Object.assign({}, props, { + value: prevLog + }), + info: Object.assign({}, props, { + value: prevInfo + }), + warn: Object.assign({}, props, { + value: prevWarn + }), + error: Object.assign({}, props, { + value: prevError + }), + group: Object.assign({}, props, { + value: prevGroup + }), + groupCollapsed: Object.assign({}, props, { + value: prevGroupCollapsed + }), + groupEnd: Object.assign({}, props, { + value: prevGroupEnd + }) + }); + /* eslint-enable react-internal/no-production-logging */ + } + + if (disabledDepth < 0) { + error( + "disabledDepth fell below zero. " + + "This is a bug in React. Please file an issue." + ); + } + } +} + var rendererID = null; var injectedHook = null; var hasLoggedError = false; @@ -4282,6 +4385,15 @@ function onCommitUnmount(fiber) { } } } +function setIsStrictModeForDevtools(newIsStrictMode) { + { + if (newIsStrictMode) { + disableLogs(); + } else { + reenableLogs(); + } + } +} var NoMode = /* */ @@ -5037,33 +5149,34 @@ function lanesToEventPriority(lanes) { return IdleEventPriority; } +// Renderers that don't support persistence // can re-export everything from this module. - function shim() { - { - throw Error( - "The current renderer does not support persistence. This error is likely caused by a bug in React. Please file an issue." - ); - } + throw new Error( + "The current renderer does not support persistence. " + + "This error is likely caused by a bug in React. " + + "Please file an issue." + ); } // Persistence (when unsupported) var supportsPersistence = false; var getOffscreenContainerProps = shim; +// Renderers that don't support hydration // can re-export everything from this module. - function shim$1() { - { - throw Error( - "The current renderer does not support hydration. This error is likely caused by a bug in React. Please file an issue." - ); - } + throw new Error( + "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 isSuspenseInstancePending = shim$1; var isSuspenseInstanceFallback = shim$1; var hydrateTextInstance = shim$1; var errorHydratingContainer = shim$1; +// Modules provided by RN: var getViewConfigForType = ReactNativePrivateInterface.ReactNativeViewConfigRegistry.get; var UPDATE_SIGNAL = {}; @@ -5145,7 +5258,7 @@ function createTextInstance( internalInstanceHandle ) { if (!hostContext.isInAParentText) { - throw Error("Text strings must be rendered within a component."); + throw new Error("Text strings must be rendered within a component."); } var tag = allocateTag(); @@ -5344,8 +5457,8 @@ 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. - if (!(typeof parentInstance !== "number")) { - throw Error("Container does not support insertBefore operation"); + if (typeof parentInstance === "number") { + throw new Error("Container does not support insertBefore operation"); } } function removeChild(parentInstance, child) { @@ -5429,103 +5542,6 @@ function preparePortalMount(portalInstance) { // noop } -// Helpers to patch console.logs to avoid logging during side-effect free -// replaying on render function. This currently only patches the object -// lazily which won't cover if the log function was extracted eagerly. -// We could also eagerly patch the method. -var disabledDepth = 0; -var prevLog; -var prevInfo; -var prevWarn; -var prevError; -var prevGroup; -var prevGroupCollapsed; -var prevGroupEnd; - -function disabledLog() {} - -disabledLog.__reactDisabledLog = true; -function disableLogs() { - { - if (disabledDepth === 0) { - /* eslint-disable react-internal/no-production-logging */ - prevLog = console.log; - prevInfo = console.info; - prevWarn = console.warn; - prevError = console.error; - prevGroup = console.group; - prevGroupCollapsed = console.groupCollapsed; - prevGroupEnd = console.groupEnd; // https://github.com/facebook/react/issues/19099 - - var props = { - configurable: true, - enumerable: true, - value: disabledLog, - writable: true - }; // $FlowFixMe Flow thinks console is immutable. - - Object.defineProperties(console, { - info: props, - log: props, - warn: props, - error: props, - group: props, - groupCollapsed: props, - groupEnd: props - }); - /* eslint-enable react-internal/no-production-logging */ - } - - disabledDepth++; - } -} -function reenableLogs() { - { - disabledDepth--; - - if (disabledDepth === 0) { - /* eslint-disable react-internal/no-production-logging */ - var props = { - configurable: true, - enumerable: true, - writable: true - }; // $FlowFixMe Flow thinks console is immutable. - - Object.defineProperties(console, { - log: Object.assign({}, props, { - value: prevLog - }), - info: Object.assign({}, props, { - value: prevInfo - }), - warn: Object.assign({}, props, { - value: prevWarn - }), - error: Object.assign({}, props, { - value: prevError - }), - group: Object.assign({}, props, { - value: prevGroup - }), - groupCollapsed: Object.assign({}, props, { - value: prevGroupCollapsed - }), - groupEnd: Object.assign({}, props, { - value: prevGroupEnd - }) - }); - /* eslint-enable react-internal/no-production-logging */ - } - - if (disabledDepth < 0) { - error( - "disabledDepth fell below zero. " + - "This is a bug in React. Please file an issue." - ); - } - } -} - var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher; function describeBuiltInComponentFrame(name, source, ownerFn) { { @@ -5685,6 +5701,7 @@ function checkPropTypes(typeSpecs, values, location, componentName, element) { // This is intentionally an invariant that gets caught. It's the same // behavior as without this statement except with a better message. if (typeof typeSpecs[typeSpecName] !== "function") { + // eslint-disable-next-line react-internal/prod-error-codes var err = Error( (componentName || "React class") + ": " + @@ -5916,9 +5933,10 @@ function popTopLevelContextObject(fiber) { function pushTopLevelContextObject(fiber, context, didChange) { { - if (!(contextStackCursor.current === emptyContextObject)) { - throw Error( - "Unexpected context found on stack. This error is likely caused by a bug in React. Please file an issue." + if (contextStackCursor.current !== emptyContextObject) { + throw new Error( + "Unexpected context found on stack. " + + "This error is likely caused by a bug in React. Please file an issue." ); } @@ -5957,7 +5975,7 @@ function processChildContext(fiber, type, parentContext) { for (var contextKey in childContext) { if (!(contextKey in childContextTypes)) { - throw Error( + throw new Error( (getComponentNameFromFiber(fiber) || "Unknown") + '.getChildContext(): key "' + contextKey + @@ -6002,8 +6020,9 @@ function invalidateContextProvider(workInProgress, type, didChange) { var instance = workInProgress.stateNode; if (!instance) { - throw Error( - "Expected to have an instance by this point. This error is likely caused by a bug in React. Please file an issue." + throw new Error( + "Expected to have an instance by this point. " + + "This error is likely caused by a bug in React. Please file an issue." ); } @@ -6035,9 +6054,10 @@ function findCurrentUnmaskedContext(fiber) { { // Currently this is only used with renderSubtreeIntoContainer; not sure if it // makes sense elsewhere - if (!(isFiberMounted(fiber) && fiber.tag === ClassComponent)) { - throw Error( - "Expected subtree parent to be a mounted class component. This error is likely caused by a bug in React. Please file an issue." + if (!isFiberMounted(fiber) || fiber.tag !== ClassComponent) { + throw new Error( + "Expected subtree parent to be a mounted class component. " + + "This error is likely caused by a bug in React. Please file an issue." ); } @@ -6062,11 +6082,10 @@ function findCurrentUnmaskedContext(fiber) { node = node.return; } while (node !== null); - { - throw Error( - "Found unexpected detached subtree parent. This error is likely caused by a bug in React. Please file an issue." - ); - } + throw new Error( + "Found unexpected detached subtree parent. " + + "This error is likely caused by a bug in React. Please file an issue." + ); } } @@ -6154,7 +6173,12 @@ function flushSyncCallbacks() { return null; } -var ReactVersion = "18.0.0-e8feb11b6-20210915"; +var ReactVersion = "18.0.0-afcb9cdc9-20211008"; + +function markComponentRenderStopped() {} +function markComponentErrored(fiber, thrownValue, lanes) {} + +function markComponentSuspended(fiber, wakeable, lanes) {} var ReactCurrentBatchConfig = ReactSharedInternals.ReactCurrentBatchConfig; var NoTransition = 0; @@ -6653,6 +6677,105 @@ var ReactStrictModeWarnings = { }; } +/* + * The `'' + value` pattern (used in in perf-sensitive code) throws for Symbol + * and Temporal.* types. See https://github.com/facebook/react/pull/22064. + * + * The functions in this module will throw an easier-to-understand, + * easier-to-debug exception with a clear errors message message explaining the + * problem. (Instead of a confusing exception thrown inside the implementation + * of the `value` object). + */ +// $FlowFixMe only called in DEV, so void return is not possible. + +function typeName(value) { + { + // toStringTag is needed for namespaced types like Temporal.Instant + var hasToStringTag = typeof Symbol === "function" && Symbol.toStringTag; + var type = + (hasToStringTag && value[Symbol.toStringTag]) || + value.constructor.name || + "Object"; + return type; + } +} // $FlowFixMe only called in DEV, so void return is not possible. + +function willCoercionThrow(value) { + { + if ( + value !== null && + typeof value === "object" && + value.$$typeof === REACT_OPAQUE_ID_TYPE + ) { + // OpaqueID type is expected to throw, so React will handle it. Not sure if + // it's expected that string coercion will throw, but we'll assume it's OK. + // See https://github.com/facebook/react/issues/20127. + return; + } + + try { + testStringCoercion(value); + return false; + } catch (e) { + return true; + } + } +} + +function testStringCoercion(value) { + // If you ended up here by following an exception call stack, here's what's + // happened: you supplied an object or symbol value to React (as a prop, key, + // DOM attribute, CSS property, string ref, etc.) and when React tried to + // coerce it to a string using `'' + value`, an exception was thrown. + // + // The most common types that will cause this exception are `Symbol` instances + // and Temporal objects like `Temporal.Instant`. But any object that has a + // `valueOf` or `[Symbol.toPrimitive]` method that throws will also cause this + // exception. (Library authors do this to prevent users from using built-in + // numeric operators like `+` or comparison operators like `>=` because custom + // methods are needed to perform accurate arithmetic or comparison.) + // + // To fix the problem, coerce this object or symbol value to a string before + // passing it to React. The most reliable way is usually `String(value)`. + // + // To find which value is throwing, check the browser or debugger console. + // Before this exception was thrown, there should be `console.error` output + // that shows the type (Symbol, Temporal.PlainDate, etc.) that caused the + // problem and how that type was used: key, atrribute, input value prop, etc. + // In most cases, this console output also shows the component and its + // ancestor components where the exception happened. + // + // eslint-disable-next-line react-internal/safe-string-coercion + return "" + value; +} +function checkKeyStringCoercion(value) { + { + if (willCoercionThrow(value)) { + error( + "The provided key is an unsupported type %s." + + " This value must be coerced to a string before before using it here.", + typeName(value) + ); + + return testStringCoercion(value); // throw (to help callers find troubleshooting comments) + } + } +} +function checkPropStringCoercion(value, propName) { + { + if (willCoercionThrow(value)) { + error( + "The provided `%s` prop is an unsupported type %s." + + " This value must be coerced to a string before before using it here.", + propName, + typeName(value) + ); + + return testStringCoercion(value); // throw (to help callers find troubleshooting comments) + } + } +} + function resolveDefaultProps(Component, baseProps) { if (Component && Component.defaultProps) { // Resolve default props. Taken from ReactElement @@ -6917,9 +7040,12 @@ function readContext(context) { }; if (lastContextDependency === null) { - if (!(currentlyRenderingFiber !== null)) { - throw Error( - "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()." + if (currentlyRenderingFiber === null) { + throw new Error( + "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. @@ -7487,10 +7613,10 @@ function processUpdateQueue(workInProgress, props, instance, renderLanes) { } function callCallback(callback, context) { - if (!(typeof callback === "function")) { - throw Error( - "Invalid argument passed as callback. Expected a function. Instead received: " + - callback + if (typeof callback !== "function") { + throw new Error( + "Invalid argument passed as callback. Expected a function. Instead " + + ("received: " + callback) ); } @@ -7589,11 +7715,14 @@ var didWarnAboutInvalidateContextType; Object.defineProperty(fakeInternalInstance, "_processChildContext", { enumerable: false, value: function() { - { - throw Error( - "_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)." - ); - } + throw new Error( + "_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); @@ -8673,9 +8802,10 @@ var warnForMissingKey = function(child, returnFiber) {}; return; } - if (!(typeof child._store === "object")) { - throw Error( - "React Component in warnForMissingKey should have a _store. This error is likely caused by a bug in React. Please file an issue." + if (typeof child._store !== "object") { + throw new Error( + "React Component in warnForMissingKey should have a _store. " + + "This error is likely caused by a bug in React. Please file an issue." ); } @@ -8744,9 +8874,12 @@ function coerceRef(returnFiber, current, element) { if (owner) { var ownerFiber = owner; - if (!(ownerFiber.tag === ClassComponent)) { - throw Error( - "Function components cannot have string refs. We recommend using useRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref" + if (ownerFiber.tag !== ClassComponent) { + throw new Error( + "Function components cannot have string refs. " + + "We recommend using useRef() instead. " + + "Learn more about using refs safely here: " + + "https://reactjs.org/link/strict-mode-string-ref" ); } @@ -8754,11 +8887,18 @@ function coerceRef(returnFiber, current, element) { } if (!inst) { - throw Error( + throw new Error( "Missing owner for string ref " + mixedRef + - ". This error is likely caused by a bug in React. Please file an issue." + ". This error is likely caused by a " + + "bug in React. Please file an issue." ); + } // Assigning this to a const so Flow knows it won't change in the closure + + var resolvedInst = inst; + + { + checkPropStringCoercion(mixedRef, "ref"); } var stringRef = "" + mixedRef; // Check if previous string ref matches new string ref @@ -8773,11 +8913,11 @@ function coerceRef(returnFiber, current, element) { } var ref = function(value) { - var refs = inst.refs; + var refs = resolvedInst.refs; if (refs === emptyRefsObject) { // This is a lazy pooled frozen object, so we need to initialize. - refs = inst.refs = {}; + refs = resolvedInst.refs = {}; } if (value === null) { @@ -8790,17 +8930,22 @@ function coerceRef(returnFiber, current, element) { ref._stringRef = stringRef; return ref; } else { - if (!(typeof mixedRef === "string")) { - throw Error( + if (typeof mixedRef !== "string") { + throw new Error( "Expected ref to be a function, a string, an object returned by React.createRef(), or null." ); } if (!element._owner) { - throw Error( + throw new Error( "Element ref was specified as a string (" + mixedRef + - ") but no owner was set. This could happen for one of the following reasons:\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://reactjs.org/link/refs-must-have-owner for more information." + ") but no owner was set. This could happen for one of" + + " the following reasons:\n" + + "1. You may be adding a ref to a function component\n" + + "2. You may be adding a ref to a component that was not created inside a component's render method\n" + + "3. You have multiple copies of React loaded\n" + + "See https://reactjs.org/link/refs-must-have-owner for more information." ); } } @@ -8811,16 +8956,15 @@ function coerceRef(returnFiber, current, element) { function throwOnInvalidObjectType(returnFiber, newChild) { var childString = Object.prototype.toString.call(newChild); - - { - throw Error( - "Objects are not valid as a React child (found: " + - (childString === "[object Object]" - ? "object with keys {" + Object.keys(newChild).join(", ") + "}" - : childString) + - "). If you meant to render a collection of children, use an array instead." - ); - } + throw new Error( + "Objects are not valid as a React child (found: " + + (childString === "[object Object]" + ? "object with keys {" + Object.keys(newChild).join(", ") + "}" + : childString) + + "). " + + "If you meant to render a collection of children, use an array " + + "instead." + ); } function warnOnFunctionType(returnFiber) { @@ -9436,9 +9580,10 @@ function ChildReconciler(shouldTrackSideEffects) { // but using the iterator instead. var iteratorFn = getIteratorFn(newChildrenIterable); - if (!(typeof iteratorFn === "function")) { - throw Error( - "An object is not an iterable. This error is likely caused by a bug in React. Please file an issue." + if (typeof iteratorFn !== "function") { + throw new Error( + "An object is not an iterable. This error is likely caused by a bug in " + + "React. Please file an issue." ); } @@ -9490,8 +9635,8 @@ function ChildReconciler(shouldTrackSideEffects) { var newChildren = iteratorFn.call(newChildrenIterable); - if (!(newChildren != null)) { - throw Error("An iterable object provided no iterator."); + if (newChildren == null) { + throw new Error("An iterable object provided no iterator."); } var resultingFirstChild = null; @@ -9868,8 +10013,8 @@ function ChildReconciler(shouldTrackSideEffects) { var reconcileChildFibers = ChildReconciler(true); var mountChildFibers = ChildReconciler(false); function cloneChildFibers(current, workInProgress) { - if (!(current === null || workInProgress.child === current.child)) { - throw Error("Resuming work not yet implemented."); + if (current !== null && workInProgress.child !== current.child) { + throw new Error("Resuming work not yet implemented."); } if (workInProgress.child === null) { @@ -9908,9 +10053,10 @@ var contextFiberStackCursor = createCursor(NO_CONTEXT); var rootInstanceStackCursor = createCursor(NO_CONTEXT); function requiredContext(c) { - if (!(c !== NO_CONTEXT)) { - throw Error( - "Expected host context to exist. This error is likely caused by a bug in React. Please file an issue." + if (c === NO_CONTEXT) { + throw new Error( + "Expected host context to exist. This error is likely caused by a bug " + + "in React. Please file an issue." ); } @@ -10127,21 +10273,19 @@ function prepareToHydrateHostInstance( hostContext ) { { - { - throw Error( - "Expected prepareToHydrateHostInstance() to never be called. This error is likely caused by a bug in React. Please file an issue." - ); - } + throw new Error( + "Expected prepareToHydrateHostInstance() to never be called. " + + "This error is likely caused by a bug in React. Please file an issue." + ); } } function prepareToHydrateHostTextInstance(fiber) { { - { - throw Error( - "Expected prepareToHydrateHostTextInstance() to never be called. This error is likely caused by a bug in React. Please file an issue." - ); - } + throw new Error( + "Expected prepareToHydrateHostTextInstance() to never be called. " + + "This error is likely caused by a bug in React. Please file an issue." + ); } var shouldUpdate = hydrateTextInstance(); } @@ -10343,11 +10487,14 @@ function warnOnHookMismatchInDev(currentHookName) { } function throwInvalidHookError() { - { - throw Error( - "Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for one of the following reasons:\n1. You might have mismatching versions of React and the renderer (such as React DOM)\n2. You might be breaking the Rules of Hooks\n3. You might have more than one copy of React in the same app\nSee https://reactjs.org/link/invalid-hook-call for tips about how to debug and fix this problem." - ); - } + throw new Error( + "Invalid hook call. Hooks can only be called inside of the body of a function component. This could happen for" + + " one of the following reasons:\n" + + "1. You might have mismatching versions of React and the renderer (such as React DOM)\n" + + "2. You might be breaking the Rules of Hooks\n" + + "3. You might have more than one copy of React in the same app\n" + + "See https://reactjs.org/link/invalid-hook-call for tips about how to debug and fix this problem." + ); } function areHookInputsEqual(nextDeps, prevDeps) { @@ -10455,9 +10602,10 @@ function renderWithHooks( do { didScheduleRenderPhaseUpdateDuringThisPass = false; - if (!(numberOfReRenders < RE_RENDER_LIMIT)) { - throw Error( - "Too many re-renders. React limits the number of renders to prevent an infinite loop." + if (numberOfReRenders >= RE_RENDER_LIMIT) { + throw new Error( + "Too many re-renders. React limits the number of renders to prevent " + + "an infinite loop." ); } @@ -10523,9 +10671,10 @@ function renderWithHooks( didScheduleRenderPhaseUpdate = false; - if (!!didRenderTooFewHooks) { - throw Error( - "Rendered fewer hooks than expected. This may be caused by an accidental early return statement." + if (didRenderTooFewHooks) { + throw new Error( + "Rendered fewer hooks than expected. This may be caused by an accidental " + + "early return statement." ); } @@ -10647,8 +10796,8 @@ function updateWorkInProgressHook() { currentHook = nextCurrentHook; } else { // Clone from the current hook. - if (!(nextCurrentHook !== null)) { - throw Error("Rendered more hooks than during the previous render."); + if (nextCurrentHook === null) { + throw new Error("Rendered more hooks than during the previous render."); } currentHook = nextCurrentHook; @@ -10704,7 +10853,7 @@ function mountReducer(reducer, initialArg, init) { lastRenderedState: initialState }; hook.queue = queue; - var dispatch = (queue.dispatch = dispatchAction.bind( + var dispatch = (queue.dispatch = dispatchReducerAction.bind( null, currentlyRenderingFiber$1, queue @@ -10716,8 +10865,8 @@ function updateReducer(reducer, initialArg, init) { var hook = updateWorkInProgressHook(); var queue = hook.queue; - if (!(queue !== null)) { - throw Error( + if (queue === null) { + throw new Error( "Should have a queue. This is likely a bug in React. Please file an issue." ); } @@ -10774,7 +10923,7 @@ function updateReducer(reducer, initialArg, init) { var clone = { lane: updateLane, action: update.action, - eagerReducer: update.eagerReducer, + hasEagerState: update.hasEagerState, eagerState: update.eagerState, next: null }; @@ -10802,16 +10951,16 @@ function updateReducer(reducer, initialArg, init) { // this will never be skipped by the check above. lane: NoLane, action: update.action, - eagerReducer: update.eagerReducer, + hasEagerState: update.hasEagerState, eagerState: update.eagerState, next: null }; newBaseQueueLast = newBaseQueueLast.next = _clone; } // Process this update. - if (update.eagerReducer === reducer) { - // If this update was processed eagerly, and its reducer matches the - // current reducer, we can use the eagerly computed state. + if (update.hasEagerState) { + // If this update is a state update (not a reducer) and was processed eagerly, + // we can use the eagerly computed state newState = update.eagerState; } else { var action = update.action; @@ -10869,8 +11018,8 @@ function rerenderReducer(reducer, initialArg, init) { var hook = updateWorkInProgressHook(); var queue = hook.queue; - if (!(queue !== null)) { - throw Error( + if (queue === null) { + throw new Error( "Should have a queue. This is likely a bug in React. Please file an issue." ); } @@ -10990,56 +11139,20 @@ function readFromUnsubscribedMutableSource(root, source, getSnapshot) { // the synchronous retry, it will block interleaved mutations, so we should // get a consistent read. Therefore, the following error should never be // visible to the user. - // - // If it were to become visible to the user, it suggests one of two things: - // a bug in React, or (more likely), a mutation during the render phase that - // caused the second re-render attempt to be different from the first. - // - // We know it's the second case if the logs are currently disabled. So in - // dev, we can present a more accurate error message. - - { - // eslint-disable-next-line react-internal/no-production-logging - if (getIsStrictModeForDevtools()) { - // If getIsStrictModeForDevtools is true, this is the dev-only double render - // This is only reachable if there was a mutation during render. Show a helpful - // error message. - // - // Something interesting to note: because we only double render in - // development, this error will never happen during production. This is - // actually true of all errors that occur during a double render, - // because if the first render had thrown, we would have exited the - // begin phase without double rendering. We should consider suppressing - // any error from a double render (with a warning) to more closely match - // the production behavior. - var componentName = getComponentNameFromFiber( - currentlyRenderingFiber$1 - ); - - { - throw Error( - "A mutable source was mutated while the " + - componentName + - " component was rendering. This is not supported. Move any mutations into event handlers or effects." - ); - } - } - } // We expect this error not to be thrown during the synchronous retry, + // We expect this error not to be thrown during the synchronous retry, // because we blocked interleaved mutations. - { - throw Error( - "Cannot read from mutable source during the current render without tearing. This may be a bug in React. Please file an issue." - ); - } + throw new Error( + "Cannot read from mutable source during the current render without tearing. This may be a bug in React. Please file an issue." + ); } } function useMutableSource(hook, source, getSnapshot, subscribe) { var root = getWorkInProgressRoot(); - if (!(root !== null)) { - throw Error( + if (root === null) { + throw new Error( "Expected a work-in-progress root. This is a bug in React. Please file an issue." ); } @@ -11171,7 +11284,7 @@ function useMutableSource(hook, source, getSnapshot, subscribe) { lastRenderedReducer: basicStateReducer, lastRenderedState: snapshot }; - newQueue.dispatch = setSnapshot = dispatchAction.bind( + newQueue.dispatch = setSnapshot = dispatchSetState.bind( null, currentlyRenderingFiber$1, newQueue @@ -11203,25 +11316,46 @@ function updateMutableSource(source, getSnapshot, subscribe) { return useMutableSource(hook, source, getSnapshot, subscribe); } -function mountSyncExternalStore(subscribe, getSnapshot) { +function mountSyncExternalStore(subscribe, getSnapshot, getServerSnapshot) { var fiber = currentlyRenderingFiber$1; - var hook = mountWorkInProgressHook(); // Read the current snapshot from the store on every render. This breaks the - // normal rules of React, and only works because store updates are - // always synchronous. - - var nextSnapshot = getSnapshot(); + var hook = mountWorkInProgressHook(); + var nextSnapshot; { - if (!didWarnUncachedGetSnapshot) { - if (nextSnapshot !== getSnapshot()) { - error( - "The result of getSnapshot should be cached to avoid an infinite loop" - ); + nextSnapshot = getSnapshot(); - didWarnUncachedGetSnapshot = true; + { + if (!didWarnUncachedGetSnapshot) { + if (nextSnapshot !== getSnapshot()) { + error( + "The result of getSnapshot should be cached to avoid an infinite loop" + ); + + didWarnUncachedGetSnapshot = true; + } } + } // Unless we're rendering a blocking lane, schedule a consistency check. + // Right before committing, we will walk the tree and check if any of the + // stores were mutated. + // + // We won't do this if we're hydrating server-rendered content, because if + // the content is stale, it's already visible anyway. Instead we'll patch + // it up in a passive effect. + + var root = getWorkInProgressRoot(); + + if (root === null) { + throw new Error( + "Expected a work-in-progress root. This is a bug in React. Please file an issue." + ); } - } + + if (!includesBlockingLane(root, renderLanes)) { + pushStoreConsistencyCheck(fiber, getSnapshot, nextSnapshot); + } + } // Read the current snapshot from the store on every render. This breaks the + // normal rules of React, and only works because store updates are + // always synchronous. hook.memoizedState = nextSnapshot; var inst = { @@ -11244,26 +11378,11 @@ function mountSyncExternalStore(subscribe, getSnapshot) { updateStoreInstance.bind(null, fiber, inst, nextSnapshot, getSnapshot), undefined, null - ); // Unless we're rendering a blocking lane, schedule a consistency check. Right - // before committing, we will walk the tree and check if any of the stores - // were mutated. - - var root = getWorkInProgressRoot(); - - if (!(root !== null)) { - throw Error( - "Expected a work-in-progress root. This is a bug in React. Please file an issue." - ); - } - - if (!includesBlockingLane(root, renderLanes)) { - pushStoreConsistencyCheck(fiber, getSnapshot, nextSnapshot); - } - + ); return nextSnapshot; } -function updateSyncExternalStore(subscribe, getSnapshot) { +function updateSyncExternalStore(subscribe, getSnapshot, getServerSnapshot) { var fiber = currentlyRenderingFiber$1; var hook = updateWorkInProgressHook(); // Read the current snapshot from the store on every render. This breaks the // normal rules of React, and only works because store updates are @@ -11318,8 +11437,8 @@ function updateSyncExternalStore(subscribe, getSnapshot) { var root = getWorkInProgressRoot(); - if (!(root !== null)) { - throw Error( + if (root === null) { + throw new Error( "Expected a work-in-progress root. This is a bug in React. Please file an issue." ); } @@ -11416,7 +11535,7 @@ function mountState(initialState) { lastRenderedState: initialState }; hook.queue = queue; - var dispatch = (queue.dispatch = dispatchAction.bind( + var dispatch = (queue.dispatch = dispatchSetState.bind( null, currentlyRenderingFiber$1, queue @@ -11894,7 +12013,7 @@ function rerenderOpaqueIdentifier() { return id; } -function dispatchAction(fiber, queue, action) { +function dispatchReducerAction(fiber, queue, action) { { if (typeof arguments[3] === "function") { error( @@ -11905,66 +12024,62 @@ function dispatchAction(fiber, queue, action) { } } - var eventTime = requestEventTime(); var lane = requestUpdateLane(fiber); var update = { lane: lane, action: action, - eagerReducer: null, + hasEagerState: false, eagerState: null, next: null }; - var alternate = fiber.alternate; - if ( - fiber === currentlyRenderingFiber$1 || - (alternate !== null && alternate === currentlyRenderingFiber$1) - ) { - // This is a render phase update. Stash it in a lazily-created map of - // queue -> linked list of updates. After this render pass, we'll restart - // and apply the stashed updates on top of the work-in-progress hook. - didScheduleRenderPhaseUpdateDuringThisPass = didScheduleRenderPhaseUpdate = true; - var pending = queue.pending; - - if (pending === null) { - // This is the first update. Create a circular list. - update.next = update; - } else { - update.next = pending.next; - pending.next = update; - } - - queue.pending = update; + if (isRenderPhaseUpdate(fiber)) { + enqueueRenderPhaseUpdate(queue, update); } else { - if (isInterleavedUpdate(fiber)) { - var interleaved = queue.interleaved; + enqueueUpdate$1(fiber, queue, update); - if (interleaved === null) { - // This is the first update. Create a circular list. - update.next = update; // At the end of the current render, this queue's interleaved updates will - // be transferred to the pending queue. - - pushInterleavedQueue(queue); - } else { - update.next = interleaved.next; - interleaved.next = update; + { + // $FlowExpectedError - jest isn't a global, and isn't recognized outside of tests + if ("undefined" !== typeof jest) { + warnIfNotCurrentlyActingUpdatesInDev(fiber); } - - queue.interleaved = update; - } else { - var _pending = queue.pending; - - if (_pending === null) { - // This is the first update. Create a circular list. - update.next = update; - } else { - update.next = _pending.next; - _pending.next = update; - } - - queue.pending = update; } + var eventTime = requestEventTime(); + var root = scheduleUpdateOnFiber(fiber, lane, eventTime); + + if (root !== null) { + entangleTransitionUpdate(root, queue, lane); + } + } +} + +function dispatchSetState(fiber, queue, action) { + { + if (typeof arguments[3] === "function") { + error( + "State updates from the useState() and useReducer() Hooks don't support the " + + "second callback argument. To execute a side effect after " + + "rendering, declare it in the component body with useEffect()." + ); + } + } + + var lane = requestUpdateLane(fiber); + var update = { + lane: lane, + action: action, + hasEagerState: false, + eagerState: null, + next: null + }; + + if (isRenderPhaseUpdate(fiber)) { + enqueueRenderPhaseUpdate(queue, update); + } else { + enqueueUpdate$1(fiber, queue, update); + var alternate = fiber.alternate; + if ( fiber.lanes === NoLanes && (alternate === null || alternate.lanes === NoLanes) @@ -11989,7 +12104,7 @@ function dispatchAction(fiber, queue, action) { // time we enter the render phase, then the eager state can be used // without calling the reducer again. - update.eagerReducer = lastRenderedReducer; + update.hasEagerState = true; update.eagerState = eagerState; if (objectIs(eagerState, currentState)) { @@ -12016,27 +12131,91 @@ function dispatchAction(fiber, queue, action) { } } + var eventTime = requestEventTime(); var root = scheduleUpdateOnFiber(fiber, lane, eventTime); - if (isTransitionLane(lane) && root !== null) { - var queueLanes = queue.lanes; // If any entangled lanes are no longer pending on the root, then they - // must have finished. We can remove them from the shared queue, which - // represents a superset of the actually pending lanes. In some cases we - // may entangle more than we need to, but that's OK. In fact it's worse if - // we *don't* entangle when we should. - - queueLanes = intersectLanes(queueLanes, root.pendingLanes); // Entangle the new transition lane with the other transition lanes. - - var newQueueLanes = mergeLanes(queueLanes, lane); - queue.lanes = newQueueLanes; // Even if queue.lanes already include lane, we don't know for certain if - // the lane finished since the last time we entangled it. So we need to - // entangle it again, just to be sure. - - markRootEntangled(root, newQueueLanes); + if (root !== null) { + entangleTransitionUpdate(root, queue, lane); } } } +function isRenderPhaseUpdate(fiber) { + var alternate = fiber.alternate; + return ( + fiber === currentlyRenderingFiber$1 || + (alternate !== null && alternate === currentlyRenderingFiber$1) + ); +} + +function enqueueRenderPhaseUpdate(queue, update) { + // This is a render phase update. Stash it in a lazily-created map of + // queue -> linked list of updates. After this render pass, we'll restart + // and apply the stashed updates on top of the work-in-progress hook. + didScheduleRenderPhaseUpdateDuringThisPass = didScheduleRenderPhaseUpdate = true; + var pending = queue.pending; + + if (pending === null) { + // This is the first update. Create a circular list. + update.next = update; + } else { + update.next = pending.next; + pending.next = update; + } + + queue.pending = update; +} + +function enqueueUpdate$1(fiber, queue, update, lane) { + if (isInterleavedUpdate(fiber)) { + var interleaved = queue.interleaved; + + if (interleaved === null) { + // This is the first update. Create a circular list. + update.next = update; // At the end of the current render, this queue's interleaved updates will + // be transferred to the pending queue. + + pushInterleavedQueue(queue); + } else { + update.next = interleaved.next; + interleaved.next = update; + } + + queue.interleaved = update; + } else { + var pending = queue.pending; + + if (pending === null) { + // This is the first update. Create a circular list. + update.next = update; + } else { + update.next = pending.next; + pending.next = update; + } + + queue.pending = update; + } +} + +function entangleTransitionUpdate(root, queue, lane) { + if (isTransitionLane(lane)) { + var queueLanes = queue.lanes; // If any entangled lanes are no longer pending on the root, then they + // must have finished. We can remove them from the shared queue, which + // represents a superset of the actually pending lanes. In some cases we + // may entangle more than we need to, but that's OK. In fact it's worse if + // we *don't* entangle when we should. + + queueLanes = intersectLanes(queueLanes, root.pendingLanes); // Entangle the new transition lane with the other transition lanes. + + var newQueueLanes = mergeLanes(queueLanes, lane); + queue.lanes = newQueueLanes; // Even if queue.lanes already include lane, we don't know for certain if + // the lane finished since the last time we entangled it. So we need to + // entangle it again, just to be sure. + + markRootEntangled(root, newQueueLanes); + } +} + var ContextOnlyDispatcher = { readContext: readContext, useCallback: throwInvalidHookError, @@ -12186,7 +12365,7 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; mountHookTypesDev(); return mountMutableSource(source, getSnapshot, subscribe); }, - useSyncExternalStore: function(subscribe, getSnapshot) { + useSyncExternalStore: function(subscribe, getSnapshot, getServerSnapshot) { currentHookNameInDev = "useSyncExternalStore"; mountHookTypesDev(); return mountSyncExternalStore(subscribe, getSnapshot); @@ -12294,7 +12473,7 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; updateHookTypesDev(); return mountMutableSource(source, getSnapshot, subscribe); }, - useSyncExternalStore: function(subscribe, getSnapshot) { + useSyncExternalStore: function(subscribe, getSnapshot, getServerSnapshot) { currentHookNameInDev = "useSyncExternalStore"; updateHookTypesDev(); return mountSyncExternalStore(subscribe, getSnapshot); @@ -12402,7 +12581,7 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; updateHookTypesDev(); return updateMutableSource(source, getSnapshot, subscribe); }, - useSyncExternalStore: function(subscribe, getSnapshot) { + useSyncExternalStore: function(subscribe, getSnapshot, getServerSnapshot) { currentHookNameInDev = "useSyncExternalStore"; updateHookTypesDev(); return updateSyncExternalStore(subscribe, getSnapshot); @@ -12510,7 +12689,7 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; updateHookTypesDev(); return updateMutableSource(source, getSnapshot, subscribe); }, - useSyncExternalStore: function(subscribe, getSnapshot) { + useSyncExternalStore: function(subscribe, getSnapshot, getServerSnapshot) { currentHookNameInDev = "useSyncExternalStore"; updateHookTypesDev(); return updateSyncExternalStore(subscribe, getSnapshot); @@ -12633,7 +12812,7 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; mountHookTypesDev(); return mountMutableSource(source, getSnapshot, subscribe); }, - useSyncExternalStore: function(subscribe, getSnapshot) { + useSyncExternalStore: function(subscribe, getSnapshot, getServerSnapshot) { currentHookNameInDev = "useSyncExternalStore"; warnInvalidHookAccess(); mountHookTypesDev(); @@ -12758,7 +12937,7 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; updateHookTypesDev(); return updateMutableSource(source, getSnapshot, subscribe); }, - useSyncExternalStore: function(subscribe, getSnapshot) { + useSyncExternalStore: function(subscribe, getSnapshot, getServerSnapshot) { currentHookNameInDev = "useSyncExternalStore"; warnInvalidHookAccess(); updateHookTypesDev(); @@ -12883,7 +13062,7 @@ var InvalidNestedHooksDispatcherOnRerenderInDEV = null; updateHookTypesDev(); return updateMutableSource(source, getSnapshot, subscribe); }, - useSyncExternalStore: function(subscribe, getSnapshot) { + useSyncExternalStore: function(subscribe, getSnapshot, getServerSnapshot) { currentHookNameInDev = "useSyncExternalStore"; warnInvalidHookAccess(); updateHookTypesDev(); @@ -13075,12 +13254,10 @@ function createCapturedValue(value, source) { } if ( - !( - typeof ReactNativePrivateInterface.ReactFiberErrorDialog.showErrorDialog === - "function" - ) + typeof ReactNativePrivateInterface.ReactFiberErrorDialog.showErrorDialog !== + "function" ) { - throw Error( + throw new Error( "Expected ReactFiberErrorDialog.showErrorDialog to be a function." ); } @@ -13266,42 +13443,228 @@ function createClassErrorUpdate(fiber, errorInfo, lane) { return update; } -function attachPingListener(root, wakeable, lanes) { - // Attach a listener to the promise to "ping" the root and retry. But only if - // one does not already exist for the lanes we're currently rendering (which - // acts like a "thread ID" here). - var pingCache = root.pingCache; - var threadIDs; +function attachWakeableListeners(suspenseBoundary, root, wakeable, lanes) { + // Attach a ping listener + // + // The data might resolve before we have a chance to commit the fallback. Or, + // in the case of a refresh, we'll never commit a fallback. So we need to + // attach a listener now. When it resolves ("pings"), we can decide whether to + // try rendering the tree again. + // + // Only attach a listener if one does not already exist for the lanes + // we're currently rendering (which acts like a "thread ID" here). + // + // We only need to do this in concurrent mode. Legacy Suspense always + // commits fallbacks synchronously, so there are no pings. + if (suspenseBoundary.mode & ConcurrentMode) { + var pingCache = root.pingCache; + var threadIDs; - if (pingCache === null) { - pingCache = root.pingCache = new PossiblyWeakMap$1(); - threadIDs = new Set(); - pingCache.set(wakeable, threadIDs); - } else { - threadIDs = pingCache.get(wakeable); - - if (threadIDs === undefined) { + if (pingCache === null) { + pingCache = root.pingCache = new PossiblyWeakMap$1(); threadIDs = new Set(); pingCache.set(wakeable, threadIDs); - } - } + } else { + threadIDs = pingCache.get(wakeable); - if (!threadIDs.has(lanes)) { - // Memoize using the thread ID to prevent redundant listeners. - threadIDs.add(lanes); - var ping = pingSuspendedRoot.bind(null, root, wakeable, lanes); - - { - if (isDevToolsPresent) { - // If we have pending work still, restore the original updaters - restorePendingUpdaters(root, lanes); + if (threadIDs === undefined) { + threadIDs = new Set(); + pingCache.set(wakeable, threadIDs); } } - wakeable.then(ping, ping); + if (!threadIDs.has(lanes)) { + // Memoize using the thread ID to prevent redundant listeners. + threadIDs.add(lanes); + var ping = pingSuspendedRoot.bind(null, root, wakeable, lanes); + + { + if (isDevToolsPresent) { + // If we have pending work still, restore the original updaters + restorePendingUpdaters(root, lanes); + } + } + + wakeable.then(ping, ping); + } + } // Retry listener + // + // If the fallback does commit, we need to attach a different type of + // listener. This one schedules an update on the Suspense boundary to turn + // the fallback state off. + // + // Stash the wakeable on the boundary fiber so we can access it in the + // commit phase. + // + // When the wakeable resolves, we'll attempt to render the boundary + // again ("retry"). + + var wakeables = suspenseBoundary.updateQueue; + + if (wakeables === null) { + var updateQueue = new Set(); + updateQueue.add(wakeable); + suspenseBoundary.updateQueue = updateQueue; + } else { + wakeables.add(wakeable); } } +function resetSuspendedComponent(sourceFiber, rootRenderLanes) { + // A legacy mode Suspense quirk, only relevant to hook components. + + var tag = sourceFiber.tag; + + if ( + (sourceFiber.mode & ConcurrentMode) === NoMode && + (tag === FunctionComponent || + tag === ForwardRef || + tag === SimpleMemoComponent) + ) { + var currentSource = sourceFiber.alternate; + + if (currentSource) { + sourceFiber.updateQueue = currentSource.updateQueue; + sourceFiber.memoizedState = currentSource.memoizedState; + sourceFiber.lanes = currentSource.lanes; + } else { + sourceFiber.updateQueue = null; + sourceFiber.memoizedState = null; + } + } +} + +function markNearestSuspenseBoundaryShouldCapture( + returnFiber, + sourceFiber, + root, + rootRenderLanes +) { + var hasInvisibleParentBoundary = hasSuspenseContext( + suspenseStackCursor.current, + InvisibleParentSuspenseContext + ); + var node = returnFiber; + + do { + if ( + node.tag === SuspenseComponent && + shouldCaptureSuspense(node, hasInvisibleParentBoundary) + ) { + // Found the nearest boundary. + var suspenseBoundary = node; // This marks a Suspense boundary so that when we're unwinding the stack, + // it captures the suspended "exception" and does a second (fallback) pass. + + if ((suspenseBoundary.mode & ConcurrentMode) === NoMode) { + // Legacy Mode Suspense + // + // If the boundary is in legacy mode, we should *not* + // suspend the commit. Pretend as if the suspended component rendered + // null and keep rendering. When the Suspense boundary completes, + // we'll do a second pass to render the fallback. + if (suspenseBoundary === returnFiber) { + // Special case where we suspended while reconciling the children of + // a Suspense boundary's inner Offscreen wrapper fiber. This happens + // when a React.lazy component is a direct child of a + // Suspense boundary. + // + // Suspense boundaries are implemented as multiple fibers, but they + // are a single conceptual unit. The legacy mode behavior where we + // pretend the suspended fiber committed as `null` won't work, + // because in this case the "suspended" fiber is the inner + // Offscreen wrapper. + // + // Because the contents of the boundary haven't started rendering + // yet (i.e. nothing in the tree has partially rendered) we can + // switch to the regular, concurrent mode behavior: mark the + // boundary with ShouldCapture and enter the unwind phase. + suspenseBoundary.flags |= ShouldCapture; + } else { + suspenseBoundary.flags |= DidCapture; + sourceFiber.flags |= ForceUpdateForLegacySuspense; // We're going to commit this fiber even though it didn't complete. + // But we shouldn't call any lifecycle methods or callbacks. Remove + // all lifecycle effect tags. + + sourceFiber.flags &= ~(LifecycleEffectMask | Incomplete); + + if (sourceFiber.tag === ClassComponent) { + var currentSourceFiber = sourceFiber.alternate; + + if (currentSourceFiber === null) { + // This is a new mount. Change the tag so it's not mistaken for a + // completed class component. For example, we should not call + // componentWillUnmount if it is deleted. + sourceFiber.tag = IncompleteClassComponent; + } else { + // When we try rendering again, we should not reuse the current fiber, + // since it's known to be in an inconsistent state. Use a force update to + // prevent a bail out. + var update = createUpdate(NoTimestamp, SyncLane); + update.tag = ForceUpdate; + enqueueUpdate(sourceFiber, update); + } + } // The source fiber did not complete. Mark it with Sync priority to + // indicate that it still has pending work. + + sourceFiber.lanes = mergeLanes(sourceFiber.lanes, SyncLane); + } + + return suspenseBoundary; + } // Confirmed that the boundary is in a concurrent mode tree. Continue + // with the normal suspend path. + // + // After this we'll use a set of heuristics to determine whether this + // render pass will run to completion or restart or "suspend" the commit. + // The actual logic for this is spread out in different places. + // + // This first principle is that if we're going to suspend when we complete + // a root, then we should also restart if we get an update or ping that + // might unsuspend it, and vice versa. The only reason to suspend is + // because you think you might want to restart before committing. However, + // it doesn't make sense to restart only while in the period we're suspended. + // + // Restarting too aggressively is also not good because it starves out any + // intermediate loading state. So we use heuristics to determine when. + // Suspense Heuristics + // + // If nothing threw a Promise or all the same fallbacks are already showing, + // then don't suspend/restart. + // + // If this is an initial render of a new tree of Suspense boundaries and + // those trigger a fallback, then don't suspend/restart. We want to ensure + // that we can show the initial loading state as quickly as possible. + // + // If we hit a "Delayed" case, such as when we'd switch from content back into + // a fallback, then we should always suspend/restart. Transitions apply + // to this case. If none is defined, JND is used instead. + // + // If we're already showing a fallback and it gets "retried", allowing us to show + // another level, but there's still an inner boundary that would show a fallback, + // then we suspend/restart for 500ms since the last time we showed a fallback + // anywhere in the tree. This effectively throttles progressive loading into a + // consistent train of commits. This also gives us an opportunity to restart to + // get to the completed state slightly earlier. + // + // If there's ambiguity due to batching it's resolved in preference of: + // 1) "delayed", 2) "initial render", 3) "retry". + // + // We want to ensure that a "busy" state doesn't get force committed. We want to + // ensure that new initial loading states can commit as soon as possible. + + suspenseBoundary.flags |= ShouldCapture; // TODO: I think we can remove this, since we now use `DidCapture` in + // the begin phase to prevent an early bailout. + + suspenseBoundary.lanes = rootRenderLanes; + return suspenseBoundary; + } // This boundary already captured during this render. Continue to the next + // boundary. + + node = node.return; + } while (node !== null); // Could not find a Suspense boundary capable of capturing. + + return null; +} + function throwException( root, returnFiber, @@ -13324,160 +13687,37 @@ function throwException( typeof value === "object" && typeof value.then === "function" ) { + // This is a wakeable. The component suspended. var wakeable = value; - // A legacy mode Suspense quirk, only relevant to hook components. + resetSuspendedComponent(sourceFiber); - var tag = sourceFiber.tag; - - if ( - (sourceFiber.mode & ConcurrentMode) === NoMode && - (tag === FunctionComponent || - tag === ForwardRef || - tag === SimpleMemoComponent) - ) { - var currentSource = sourceFiber.alternate; - - if (currentSource) { - sourceFiber.updateQueue = currentSource.updateQueue; - sourceFiber.memoizedState = currentSource.memoizedState; - sourceFiber.lanes = currentSource.lanes; - } else { - sourceFiber.updateQueue = null; - sourceFiber.memoizedState = null; - } - } - - var hasInvisibleParentBoundary = hasSuspenseContext( - suspenseStackCursor.current, - InvisibleParentSuspenseContext - ); // Schedule the nearest Suspense to re-render the timed out view. - - var _workInProgress = returnFiber; - - do { - if ( - _workInProgress.tag === SuspenseComponent && - shouldCaptureSuspense(_workInProgress, hasInvisibleParentBoundary) - ) { - // Found the nearest boundary. - // Stash the promise on the boundary fiber. If the boundary times out, we'll - // attach another listener to flip the boundary back to its normal state. - var wakeables = _workInProgress.updateQueue; - - if (wakeables === null) { - var updateQueue = new Set(); - updateQueue.add(wakeable); - _workInProgress.updateQueue = updateQueue; - } else { - wakeables.add(wakeable); - } // If the boundary is in legacy mode, we should *not* - // suspend the commit. Pretend as if the suspended component rendered - // null and keep rendering. In the commit phase, we'll schedule a - // subsequent synchronous update to re-render the Suspense. - // - // 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 the suspense boundary suspended itself suspended, we don't have to - // do this trick because nothing was partially started. We can just - // directly do a second pass over the fallback in this render and - // pretend we meant to render that directly. - - if ( - (_workInProgress.mode & ConcurrentMode) === NoMode && - _workInProgress !== returnFiber - ) { - _workInProgress.flags |= DidCapture; - sourceFiber.flags |= ForceUpdateForLegacySuspense; // We're going to commit this fiber even though it didn't complete. - // But we shouldn't call any lifecycle methods or callbacks. Remove - // all lifecycle effect tags. - - sourceFiber.flags &= ~(LifecycleEffectMask | Incomplete); - - if (sourceFiber.tag === ClassComponent) { - var _currentSourceFiber = sourceFiber.alternate; - - if (_currentSourceFiber === null) { - // This is a new mount. Change the tag so it's not mistaken for a - // completed class component. For example, we should not call - // componentWillUnmount if it is deleted. - sourceFiber.tag = IncompleteClassComponent; - } else { - // When we try rendering again, we should not reuse the current fiber, - // since it's known to be in an inconsistent state. Use a force update to - // prevent a bail out. - var update = createUpdate(NoTimestamp, SyncLane); - update.tag = ForceUpdate; - enqueueUpdate(sourceFiber, update); - } - } // The source fiber did not complete. Mark it with Sync priority to - // indicate that it still has pending work. - - sourceFiber.lanes = mergeLanes(sourceFiber.lanes, SyncLane); // Exit without suspending. - - return; - } // Confirmed that the boundary is in a concurrent mode tree. Continue - // with the normal suspend path. - // - // After this we'll use a set of heuristics to determine whether this - // render pass will run to completion or restart or "suspend" the commit. - // The actual logic for this is spread out in different places. - // - // This first principle is that if we're going to suspend when we complete - // a root, then we should also restart if we get an update or ping that - // might unsuspend it, and vice versa. The only reason to suspend is - // because you think you might want to restart before committing. However, - // it doesn't make sense to restart only while in the period we're suspended. - // - // Restarting too aggressively is also not good because it starves out any - // intermediate loading state. So we use heuristics to determine when. - // Suspense Heuristics - // - // If nothing threw a Promise or all the same fallbacks are already showing, - // then don't suspend/restart. - // - // If this is an initial render of a new tree of Suspense boundaries and - // those trigger a fallback, then don't suspend/restart. We want to ensure - // that we can show the initial loading state as quickly as possible. - // - // If we hit a "Delayed" case, such as when we'd switch from content back into - // a fallback, then we should always suspend/restart. Transitions apply - // to this case. If none is defined, JND is used instead. - // - // If we're already showing a fallback and it gets "retried", allowing us to show - // another level, but there's still an inner boundary that would show a fallback, - // then we suspend/restart for 500ms since the last time we showed a fallback - // anywhere in the tree. This effectively throttles progressive loading into a - // consistent train of commits. This also gives us an opportunity to restart to - // get to the completed state slightly earlier. - // - // If there's ambiguity due to batching it's resolved in preference of: - // 1) "delayed", 2) "initial render", 3) "retry". - // - // We want to ensure that a "busy" state doesn't get force committed. We want to - // ensure that new initial loading states can commit as soon as possible. - - attachPingListener(root, wakeable, rootRenderLanes); - _workInProgress.flags |= ShouldCapture; // TODO: I think we can remove this, since we now use `DidCapture` in - // the begin phase to prevent an early bailout. - - _workInProgress.lanes = rootRenderLanes; - return; - } // This boundary already captured during this render. Continue to the next - // boundary. - - _workInProgress = _workInProgress.return; - } while (_workInProgress !== null); // No boundary was found. Fallthrough to error mode. - // TODO: Use invariant so the message is stripped in prod? - - value = new Error( - (getComponentNameFromFiber(sourceFiber) || "A React component") + - " suspended while rendering, but no fallback UI was specified.\n" + - "\n" + - "Add a component higher in the tree to " + - "provide a loading indicator or placeholder to display." + var suspenseBoundary = markNearestSuspenseBoundaryShouldCapture( + returnFiber, + sourceFiber, + root, + rootRenderLanes ); + + if (suspenseBoundary !== null) { + attachWakeableListeners( + suspenseBoundary, + root, + wakeable, + rootRenderLanes + ); + return; + } else { + // No boundary was found. Fallthrough to error mode. + // TODO: We should never call getComponentNameFromFiber in production. + // Log a warning or something to prevent us from accidentally bundling it. + value = new Error( + (getComponentNameFromFiber(sourceFiber) || "A React component") + + " suspended while rendering, but no fallback UI was specified.\n" + + "\n" + + "Add a component higher in the tree to " + + "provide a loading indicator or placeholder to display." + ); + } } // 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. @@ -13493,10 +13733,8 @@ function throwException( workInProgress.flags |= ShouldCapture; var lane = pickArbitraryLane(rootRenderLanes); workInProgress.lanes = mergeLanes(workInProgress.lanes, lane); - - var _update = createRootErrorUpdate(workInProgress, _errorInfo, lane); - - enqueueCapturedUpdate(workInProgress, _update); + var update = createRootErrorUpdate(workInProgress, _errorInfo, lane); + enqueueCapturedUpdate(workInProgress, update); return; } @@ -13519,13 +13757,13 @@ function throwException( workInProgress.lanes = mergeLanes(workInProgress.lanes, _lane); // Schedule the error boundary to re-render using updated state - var _update2 = createClassErrorUpdate( + var _update = createClassErrorUpdate( workInProgress, errorInfo, _lane ); - enqueueCapturedUpdate(workInProgress, _update2); + enqueueCapturedUpdate(workInProgress, _update); return; } @@ -13912,7 +14150,7 @@ function completeWork(current, workInProgress, renderLanes) { // If we hydrated, then we'll need to schedule an update for // the commit side-effects on the root. markUpdate(workInProgress); - } else if (!fiberRoot.hydrate) { + } else if (!fiberRoot.isDehydrated) { // Schedule an effect to clear this container at the start of the next commit. // This handles the case of React rendering into a container with previous children. // It's also safe to do for updates too, because current.child would only be null @@ -13945,9 +14183,10 @@ function completeWork(current, workInProgress, renderLanes) { } } else { if (!newProps) { - if (!(workInProgress.stateNode !== null)) { - throw Error( - "We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue." + if (workInProgress.stateNode === null) { + throw new Error( + "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. @@ -14008,9 +14247,10 @@ function completeWork(current, workInProgress, renderLanes) { updateHostText(current, workInProgress, oldText, newText); } else { if (typeof newText !== "string") { - if (!(workInProgress.stateNode !== null)) { - throw Error( - "We must have new props for new mounts. This error is likely caused by a bug in React. Please file an issue." + if (workInProgress.stateNode === null) { + throw new Error( + "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. } @@ -14427,13 +14667,12 @@ function completeWork(current, workInProgress, renderLanes) { } } - { - throw Error( - "Unknown unit of work tag (" + - workInProgress.tag + - "). This error is likely caused by a bug in React. Please file an issue." - ); - } + throw new Error( + "Unknown unit of work tag (" + + workInProgress.tag + + "). This error is likely caused by a bug in " + + "React. Please file an issue." + ); } var ReactCurrentOwner$1 = ReactSharedInternals.ReactCurrentOwner; @@ -15080,7 +15319,8 @@ function updateClassComponent( case true: { workInProgress.flags |= DidCapture; - workInProgress.flags |= ShouldCapture; + workInProgress.flags |= ShouldCapture; // eslint-disable-next-line react-internal/prod-error-codes + var error$1 = new Error("Simulated error coming from DevTools"); var lane = pickArbitraryLane(renderLanes); workInProgress.lanes = mergeLanes(workInProgress.lanes, lane); // Schedule the error boundary to re-render using updated state @@ -15294,9 +15534,11 @@ function updateHostRoot(current, workInProgress, renderLanes) { pushHostRootContext(workInProgress); var updateQueue = workInProgress.updateQueue; - if (!(current !== null && updateQueue !== null)) { - throw Error( - "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." + if (current === null || updateQueue === null) { + throw new Error( + "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." ); } @@ -15315,7 +15557,7 @@ function updateHostRoot(current, workInProgress, renderLanes) { return bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes); } - if (root.hydrate && enterHydrationState()) { + if (root.isDehydrated && enterHydrationState()) { var child = mountChildFibers( workInProgress, null, @@ -15491,14 +15733,12 @@ function mountLazyComponent( // because the fact that it's a separate type of work is an // implementation detail. - { - throw Error( - "Element type is invalid. Received a promise that resolves to: " + - Component + - ". Lazy element type must resolve to a class or function." + - hint - ); - } + throw new Error( + "Element type is invalid. Received a promise that resolves to: " + + Component + + ". " + + ("Lazy element type must resolve to a class or function." + hint) + ); } function mountIncompleteClassComponent( @@ -16874,6 +17114,7 @@ function remountFiber(current, oldWorkInProgress, newWorkInProgress) { var returnFiber = oldWorkInProgress.return; if (returnFiber === null) { + // eslint-disable-next-line react-internal/prod-error-codes throw new Error("Cannot swap the root fiber."); } // Disconnect from the old current. // It will get deleted. @@ -16892,6 +17133,7 @@ function remountFiber(current, oldWorkInProgress, newWorkInProgress) { var prevSibling = returnFiber.child; if (prevSibling === null) { + // eslint-disable-next-line react-internal/prod-error-codes throw new Error("Expected parent to have a child."); } @@ -16899,6 +17141,7 @@ function remountFiber(current, oldWorkInProgress, newWorkInProgress) { prevSibling = prevSibling.sibling; if (prevSibling === null) { + // eslint-disable-next-line react-internal/prod-error-codes throw new Error("Expected to find the previous sibling."); } } @@ -17368,13 +17611,12 @@ function beginWork(current, workInProgress, renderLanes) { } } - { - throw Error( - "Unknown unit of work tag (" + - workInProgress.tag + - "). This error is likely caused by a bug in React. Please file an issue." - ); - } + throw new Error( + "Unknown unit of work tag (" + + workInProgress.tag + + "). This error is likely caused by a bug in " + + "React. Please file an issue." + ); } function unwindWork(workInProgress, renderLanes) { @@ -17407,9 +17649,10 @@ function unwindWork(workInProgress, renderLanes) { resetWorkInProgressVersions(); var _flags = workInProgress.flags; - if (!((_flags & DidCapture) === NoFlags)) { - throw Error( - "The root failed to unmount after an error. This is likely a bug in React. Please file an issue." + if ((_flags & DidCapture) !== NoFlags) { + throw new Error( + "The root failed to unmount after an error. This is likely a bug in " + + "React. Please file an issue." ); } @@ -17766,11 +18009,10 @@ function commitBeforeMutationEffectsOnFiber(finishedWork) { break; default: { - { - throw Error( - "This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue." - ); - } + throw new Error( + "This unit of work tag should not have side-effects. This error is " + + "likely caused by a bug in React. Please file an issue." + ); } } @@ -18236,11 +18478,11 @@ function commitLayoutEffectOnFiber( case LegacyHiddenComponent: break; - default: { - throw Error( - "This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue." + default: + throw new Error( + "This unit of work tag should not have side-effects. This error is " + + "likely caused by a bug in React. Please file an issue." ); - } } } @@ -18609,11 +18851,10 @@ function getHostParentFiber(fiber) { parent = parent.return; } - { - throw Error( - "Expected to find a host parent. This error is likely caused by a bug in React. Please file an issue." - ); - } + throw new Error( + "Expected to find a host parent. This error is likely caused by a bug " + + "in React. Please file an issue." + ); } function isHostParent(fiber) { @@ -18698,11 +18939,11 @@ function commitPlacement(finishedWork) { break; // eslint-disable-next-line-no-fallthrough - default: { - throw Error( - "Invalid host parent fiber. This error is likely caused by a bug in React. Please file an issue." + default: + throw new Error( + "Invalid host parent fiber. This error is likely caused by a bug " + + "in React. Please file an issue." ); - } } if (parentFiber.flags & ContentReset) { @@ -18791,9 +19032,10 @@ function unmountHostComponents(finishedRoot, current, nearestMountedAncestor) { var parent = node.return; findParent: while (true) { - if (!(parent !== null)) { - throw Error( - "Expected to find a host parent. This error is likely caused by a bug in React. Please file an issue." + if (parent === null) { + throw new Error( + "Expected to find a host parent. This error is likely caused by " + + "a bug in React. Please file an issue." ); } @@ -18952,9 +19194,10 @@ function commitWork(current, finishedWork) { } case HostText: { - if (!(finishedWork.stateNode !== null)) { - throw Error( - "This should have a text node initialized. This error is likely caused by a bug in React. Please file an issue." + if (finishedWork.stateNode === null) { + throw new Error( + "This should have a text node initialized. This error is likely " + + "caused by a bug in React. Please file an issue." ); } @@ -18992,11 +19235,10 @@ function commitWork(current, finishedWork) { } } - { - throw Error( - "This unit of work tag should not have side-effects. This error is likely caused by a bug in React. Please file an issue." - ); - } + throw new Error( + "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 commitSuspenseCallback(finishedWork) { @@ -20124,8 +20366,8 @@ function performConcurrentWorkOnRoot(root, didTimeout) { currentEventTime = NoTimestamp; currentEventTransitionLane = NoLanes; - if (!((executionContext & (RenderContext | CommitContext)) === NoContext)) { - throw Error("Should not already be working."); + if ((executionContext & (RenderContext | CommitContext)) !== NoContext) { + throw new Error("Should not already be working."); } // Flush any pending passive effects before deciding which lanes to work on, // in case they schedule additional work. @@ -20245,8 +20487,8 @@ function recoverFromConcurrentError(root, errorRetryLanes) { executionContext |= RetryAfterError; // If an error occurred during hydration, discard server response and fall // back to client side render. - if (root.hydrate) { - root.hydrate = false; + if (root.isDehydrated) { + root.isDehydrated = false; { errorHydratingContainer(root.containerInfo); @@ -20264,9 +20506,7 @@ function finishConcurrentRender(root, exitStatus, lanes) { switch (exitStatus) { case RootIncomplete: case RootFatalErrored: { - { - throw Error("Root did not complete. This is a bug in React."); - } + throw new Error("Root did not complete. This is a bug in React."); } // Flow knows about invariant, so it complains if I add a break // statement, but eslint doesn't know about invariant, so it complains @@ -20371,9 +20611,7 @@ function finishConcurrentRender(root, exitStatus, lanes) { } default: { - { - throw Error("Unknown root exit status."); - } + throw new Error("Unknown root exit status."); } } } @@ -20456,8 +20694,8 @@ function performSyncWorkOnRoot(root) { syncNestedUpdateFlag(); } - if (!((executionContext & (RenderContext | CommitContext)) === NoContext)) { - throw Error("Should not already be working."); + if ((executionContext & (RenderContext | CommitContext)) !== NoContext) { + throw new Error("Should not already be working."); } flushPassiveEffects(); @@ -20476,8 +20714,8 @@ function performSyncWorkOnRoot(root) { executionContext |= RetryAfterError; // If an error occurred during hydration, // discard server response and fall back to client side render. - if (root.hydrate) { - root.hydrate = false; + if (root.isDehydrated) { + root.isDehydrated = false; { errorHydratingContainer(root.containerInfo); @@ -20539,7 +20777,7 @@ function batchedUpdates$1(fn, a) { // Warning, this opts-out of checking the function body. // eslint-disable-next-line no-redeclare -function flushSyncWithoutWarningIfAlreadyRendering(fn) { +function flushSync(fn) { // In legacy mode, we flush pending passive effects at the beginning of the // next event, not at the end of the previous one. if ( @@ -20575,22 +20813,6 @@ function flushSyncWithoutWarningIfAlreadyRendering(fn) { flushSyncCallbacks(); } } -} // Overload the definition to the two valid signatures. -// Warning, this opts-out of checking the function body. - -// eslint-disable-next-line no-redeclare -function flushSync(fn) { - { - if ((executionContext & (RenderContext | CommitContext)) !== NoContext) { - error( - "flushSync was called from inside a lifecycle method. React cannot " + - "flush when React is already rendering. Consider moving this call to " + - "a scheduler task or micro task." - ); - } - } - - return flushSyncWithoutWarningIfAlreadyRendering(fn); } function pushRenderLanes(fiber, lanes) { push(subtreeRenderLanesCursor, subtreeRenderLanes, fiber); @@ -20679,6 +20901,29 @@ function handleError(root, thrownValue) { stopProfilerTimerIfRunningAndRecordDelta(erroredWork, true); } + if (enableSchedulingProfiler) { + markComponentRenderStopped(); + + if ( + thrownValue !== null && + typeof thrownValue === "object" && + typeof thrownValue.then === "function" + ) { + var wakeable = thrownValue; + markComponentSuspended( + erroredWork, + wakeable, + workInProgressRootRenderLanes + ); + } else { + markComponentErrored( + erroredWork, + thrownValue, + workInProgressRootRenderLanes + ); + } + } + throwException( root, erroredWork.return, @@ -20742,7 +20987,8 @@ function renderDidSuspend() { function renderDidSuspendDelayIfPossible() { if ( workInProgressRootExitStatus === RootIncomplete || - workInProgressRootExitStatus === RootSuspended + workInProgressRootExitStatus === RootSuspended || + workInProgressRootExitStatus === RootErrored ) { workInProgressRootExitStatus = RootSuspendedWithDelay; } // Check if there are updates that we skipped tree that might have unblocked @@ -20764,7 +21010,7 @@ function renderDidSuspendDelayIfPossible() { } } function renderDidError() { - if (workInProgressRootExitStatus !== RootCompleted) { + if (workInProgressRootExitStatus !== RootSuspendedWithDelay) { workInProgressRootExitStatus = RootErrored; } } // Called during render to determine if anything has suspended. @@ -20817,11 +21063,10 @@ function renderRootSync(root, lanes) { if (workInProgress !== null) { // This is a sync render, so we should have finished the whole tree. - { - throw Error( - "Cannot commit an incomplete root. This error is likely caused by a bug in React. Please file an issue." - ); - } + throw new Error( + "Cannot commit an incomplete root. This error is likely caused by a " + + "bug in React. Please file an issue." + ); } workInProgressRoot = null; @@ -21045,8 +21290,8 @@ function commitRootImpl(root, renderPriorityLevel) { flushRenderPhaseStrictModeWarningsInDEV(); - if (!((executionContext & (RenderContext | CommitContext)) === NoContext)) { - throw Error("Should not already be working."); + if ((executionContext & (RenderContext | CommitContext)) !== NoContext) { + throw new Error("Should not already be working."); } var finishedWork = root.finishedWork; @@ -21068,9 +21313,10 @@ function commitRootImpl(root, renderPriorityLevel) { root.finishedWork = null; root.finishedLanes = NoLanes; - if (!(finishedWork !== root.current)) { - throw Error( - "Cannot commit the same tree as before. This error is likely caused by a bug in React. Please file an issue." + if (finishedWork === root.current) { + throw new Error( + "Cannot commit the same tree as before. This error is likely caused by " + + "a bug in React. Please file an issue." ); } // commitRoot never returns a continuation; it always finishes synchronously. // So we can clear these now to allow a new callback to be scheduled. @@ -21312,8 +21558,8 @@ function flushPassiveEffectsImpl() { pendingPassiveEffectsLanes = NoLanes; - if (!((executionContext & (RenderContext | CommitContext)) === NoContext)) { - throw Error("Cannot flush passive effects while already rendering."); + if ((executionContext & (RenderContext | CommitContext)) !== NoContext) { + throw new Error("Cannot flush passive effects while already rendering."); } var prevExecutionContext = executionContext; @@ -21559,12 +21805,12 @@ function checkForNestedUpdates() { if (nestedUpdateCount > NESTED_UPDATE_LIMIT) { nestedUpdateCount = 0; rootWithNestedUpdates = null; - - { - throw Error( - "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." - ); - } + throw new Error( + "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." + ); } { @@ -21770,7 +22016,7 @@ var beginWork$1; originalError._suppressLogging = true; } } // We always throw the original error in case the second render pass is not idempotent. - // This can happen if a memoized function or CommonJS module doesn't throw after first invokation. + // This can happen if a memoized function or CommonJS module doesn't throw after first invocation. throw originalError; } @@ -21949,6 +22195,7 @@ function warnIfNotCurrentlyActingUpdatesInDEV(fiber) { var warnIfNotCurrentlyActingUpdatesInDev = warnIfNotCurrentlyActingUpdatesInDEV; +/* eslint-disable react-internal/prod-error-codes */ var resolveFamily = null; // $FlowFixMe Flow gets confused by a WeakSet feature check below. var failedBoundaries = null; @@ -22842,14 +23089,11 @@ function createFiberFromTypeAndProps( } } - { - throw Error( - "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 - ); - } + throw new Error( + "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) + ); } } } @@ -22868,9 +23112,7 @@ function createFiberFromTypeAndProps( function createOffscreenHostContainerFiber(props, fiberMode, lanes, key) { { // Only implemented in persistent mode - { - throw Error("Not implemented."); - } + throw new Error("Not implemented."); } } function createFiberFromElement(element, mode, lanes) { @@ -23029,7 +23271,7 @@ function FiberRootNode(containerInfo, tag, hydrate) { this.timeoutHandle = noTimeout; this.context = null; this.pendingContext = null; - this.hydrate = hydrate; + this.isDehydrated = hydrate; this.callbackNode = null; this.callbackPriority = NoLane; this.eventTimes = createLaneMap(NoLanes); @@ -23060,11 +23302,11 @@ function FiberRootNode(containerInfo, tag, hydrate) { { switch (tag) { case ConcurrentRoot: - this._debugRootType = "createRoot()"; + this._debugRootType = hydrate ? "hydrateRoot()" : "createRoot()"; break; case LegacyRoot: - this._debugRootType = "createLegacyRoot()"; + this._debugRootType = hydrate ? "hydrate()" : "render()"; break; } } @@ -23107,6 +23349,11 @@ function createPortal( ) { var key = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : null; + + { + checkKeyStringCoercion(key); + } + return { // This tag allow us to uniquely identify this as a React Portal $$typeof: REACT_PORTAL_TYPE, @@ -23150,16 +23397,12 @@ function findHostInstanceWithWarning(component, methodName) { if (fiber === undefined) { if (typeof component.render === "function") { - { - throw Error("Unable to find node on an unmounted component."); - } + throw new Error("Unable to find node on an unmounted component."); } else { - { - throw Error( - "Argument appears to not be a ReactComponent. Keys: " + - Object.keys(component) - ); - } + var keys = Object.keys(component).join(","); + throw new Error( + "Argument appears to not be a ReactComponent. Keys: " + keys + ); } } @@ -23328,7 +23571,6 @@ var shouldSuspendImpl = function(fiber) { function shouldSuspend(fiber) { return shouldSuspendImpl(fiber); } -var isStrictMode = false; var overrideHookState = null; var overrideHookStateDeletePath = null; var overrideHookStateRenamePath = null; @@ -23551,20 +23793,6 @@ function getCurrentFiberForDevTools() { return current; } -function getIsStrictModeForDevtools() { - return isStrictMode; -} -function setIsStrictModeForDevtools(newIsStrictMode) { - isStrictMode = newIsStrictMode; - - { - if (newIsStrictMode) { - disableLogs(); - } else { - reenableLogs(); - } - } -} function injectIntoDevTools(devToolsConfig) { var findFiberByHostInstance = devToolsConfig.findFiberByHostInstance; var ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher; @@ -23593,7 +23821,6 @@ function injectIntoDevTools(devToolsConfig) { setRefreshHandler: setRefreshHandler, // Enables DevTools to append owner stacks to error messages in DEV mode. getCurrentFiber: getCurrentFiberForDevTools, - getIsStrictMode: getIsStrictModeForDevtools, // Enables DevTools to detect reconciler version rather than renderer version // which may not match for third party renderers. reconcilerVersion: ReactVersion diff --git a/Libraries/Renderer/implementations/ReactNativeRenderer-prod.fb.js b/Libraries/Renderer/implementations/ReactNativeRenderer-prod.fb.js index e748bf48d9..fc9aa87d9e 100644 --- a/Libraries/Renderer/implementations/ReactNativeRenderer-prod.fb.js +++ b/Libraries/Renderer/implementations/ReactNativeRenderer-prod.fb.js @@ -7,7 +7,7 @@ * @noflow * @nolint * @preventMunge - * @generated SignedSource<<5c359ba9bcb80e09d414cf763d94b5d5>> + * @generated SignedSource<> */ "use strict"; @@ -782,18 +782,16 @@ function recomputePluginOrdering() { for (var pluginName in namesToPlugins) { var pluginModule = namesToPlugins[pluginName], pluginIndex = eventPluginOrder.indexOf(pluginName); - if (!(-1 < pluginIndex)) + if (-1 >= pluginIndex) throw Error( "EventPluginRegistry: Cannot inject event plugins that do not exist in the plugin ordering, `" + - pluginName + - "`." + (pluginName + "`.") ); if (!plugins[pluginIndex]) { if (!pluginModule.extractEvents) throw Error( "EventPluginRegistry: Event plugins must implement an `extractEvents` method, but `" + - pluginName + - "` does not." + (pluginName + "` does not.") ); plugins[pluginIndex] = pluginModule; pluginIndex = pluginModule.eventTypes; @@ -804,8 +802,7 @@ function recomputePluginOrdering() { if (eventNameDispatchConfigs.hasOwnProperty(eventName$jscomp$0)) throw Error( "EventPluginRegistry: More than one plugin attempted to publish the same event name, `" + - eventName$jscomp$0 + - "`." + (eventName$jscomp$0 + "`.") ); eventNameDispatchConfigs[eventName$jscomp$0] = dispatchConfig; var phasedRegistrationNames = dispatchConfig.phasedRegistrationNames; @@ -845,8 +842,7 @@ function publishRegistrationName(registrationName, pluginModule) { if (registrationNameModules[registrationName]) throw Error( "EventPluginRegistry: More than one plugin attempted to publish the same registration name, `" + - registrationName + - "`." + (registrationName + "`.") ); registrationNameModules[registrationName] = pluginModule; } @@ -930,7 +926,7 @@ eventPluginOrder = Array.prototype.slice.call([ "ReactNativeBridgeEventPlugin" ]); recomputePluginOrdering(); -var injectedNamesToPlugins$jscomp$inline_225 = { +var injectedNamesToPlugins$jscomp$inline_222 = { ResponderEventPlugin: ResponderEventPlugin, ReactNativeBridgeEventPlugin: { eventTypes: {}, @@ -965,34 +961,33 @@ var injectedNamesToPlugins$jscomp$inline_225 = { } } }, - isOrderingDirty$jscomp$inline_226 = !1, - pluginName$jscomp$inline_227; -for (pluginName$jscomp$inline_227 in injectedNamesToPlugins$jscomp$inline_225) + isOrderingDirty$jscomp$inline_223 = !1, + pluginName$jscomp$inline_224; +for (pluginName$jscomp$inline_224 in injectedNamesToPlugins$jscomp$inline_222) if ( - injectedNamesToPlugins$jscomp$inline_225.hasOwnProperty( - pluginName$jscomp$inline_227 + injectedNamesToPlugins$jscomp$inline_222.hasOwnProperty( + pluginName$jscomp$inline_224 ) ) { - var pluginModule$jscomp$inline_228 = - injectedNamesToPlugins$jscomp$inline_225[pluginName$jscomp$inline_227]; + var pluginModule$jscomp$inline_225 = + injectedNamesToPlugins$jscomp$inline_222[pluginName$jscomp$inline_224]; if ( - !namesToPlugins.hasOwnProperty(pluginName$jscomp$inline_227) || - namesToPlugins[pluginName$jscomp$inline_227] !== - pluginModule$jscomp$inline_228 + !namesToPlugins.hasOwnProperty(pluginName$jscomp$inline_224) || + namesToPlugins[pluginName$jscomp$inline_224] !== + pluginModule$jscomp$inline_225 ) { - if (namesToPlugins[pluginName$jscomp$inline_227]) + if (namesToPlugins[pluginName$jscomp$inline_224]) throw Error( "EventPluginRegistry: Cannot inject two different event plugins using the same name, `" + - pluginName$jscomp$inline_227 + - "`." + (pluginName$jscomp$inline_224 + "`.") ); namesToPlugins[ - pluginName$jscomp$inline_227 - ] = pluginModule$jscomp$inline_228; - isOrderingDirty$jscomp$inline_226 = !0; + pluginName$jscomp$inline_224 + ] = pluginModule$jscomp$inline_225; + isOrderingDirty$jscomp$inline_223 = !0; } } -isOrderingDirty$jscomp$inline_226 && recomputePluginOrdering(); +isOrderingDirty$jscomp$inline_223 && recomputePluginOrdering(); var instanceCache = new Map(), instanceProps = new Map(); function getInstanceFromTag(tag) { @@ -1293,7 +1288,7 @@ function getNearestMountedFiber(fiber) { fiber = node; do (node = fiber), - 0 !== (node.flags & 2050) && (nearestMounted = node.return), + 0 !== (node.flags & 4098) && (nearestMounted = node.return), (fiber = node.return); while (fiber); } @@ -2376,7 +2371,7 @@ function processUpdateQueue( newState = workInProgress; break a; case 3: - workInProgress.flags = (workInProgress.flags & -32769) | 128; + workInProgress.flags = (workInProgress.flags & -65537) | 128; case 0: workInProgress = update.payload; updateLane = @@ -2629,7 +2624,8 @@ function coerceRef(returnFiber, current, element) { returnFiber + ". This error is likely caused by a bug in React. Please file an issue." ); - var stringRef = "" + returnFiber; + var resolvedInst = inst, + stringRef = "" + returnFiber; if ( null !== current && null !== current.ref && @@ -2638,8 +2634,8 @@ function coerceRef(returnFiber, current, element) { ) return current.ref; current = function(value) { - var refs = inst.refs; - refs === emptyRefsObject && (refs = inst.refs = {}); + var refs = resolvedInst.refs; + refs === emptyRefsObject && (refs = resolvedInst.refs = {}); null === value ? delete refs[stringRef] : (refs[stringRef] = value); }; current._stringRef = stringRef; @@ -3338,7 +3334,7 @@ function renderWithHooks( nextRenderLanes = 0; do { didScheduleRenderPhaseUpdateDuringThisPass = !1; - if (!(25 > nextRenderLanes)) + if (25 <= nextRenderLanes) throw Error( "Too many re-renders. React limits the number of renders to prevent an infinite loop." ); @@ -3439,19 +3435,18 @@ function updateReducer(reducer) { (newBaseQueueLast = newBaseQueueLast.next = { lane: 0, action: update.action, - eagerReducer: update.eagerReducer, + hasEagerState: update.hasEagerState, eagerState: update.eagerState, next: null }), - (current = - update.eagerReducer === reducer - ? update.eagerState - : reducer(current, update.action)); + (current = update.hasEagerState + ? update.eagerState + : reducer(current, update.action)); else { var clone = { lane: updateLane, action: update.action, - eagerReducer: update.eagerReducer, + hasEagerState: update.hasEagerState, eagerState: update.eagerState, next: null }; @@ -3591,7 +3586,7 @@ function useMutableSource(hook, source, getSnapshot, subscribe) { lastRenderedReducer: basicStateReducer, lastRenderedState: snapshot }), - (hook.dispatch = setSnapshot = dispatchAction.bind( + (hook.dispatch = setSnapshot = dispatchSetState.bind( null, currentlyRenderingFiber$1, hook @@ -3608,30 +3603,30 @@ function updateMutableSource(source, getSnapshot, subscribe) { } function mountSyncExternalStore(subscribe, getSnapshot) { var fiber = currentlyRenderingFiber$1, - hook = mountWorkInProgressHook(), - nextSnapshot = getSnapshot(); - hook.memoizedState = nextSnapshot; - var inst = { value: nextSnapshot, getSnapshot: getSnapshot }; - hook.queue = inst; - mountEffect(subscribeToStore.bind(null, fiber, inst, subscribe), [subscribe]); - fiber.flags |= 1024; - pushEffect( - 9, - updateStoreInstance.bind(null, fiber, inst, nextSnapshot, getSnapshot), - void 0, - null - ); - subscribe = workInProgressRoot; - if (null === subscribe) + hook = mountWorkInProgressHook(); + var nextSnapshot = getSnapshot(); + var root = workInProgressRoot; + if (null === root) throw Error( "Expected a work-in-progress root. This is a bug in React. Please file an issue." ); - includesBlockingLane(subscribe, renderLanes) || + includesBlockingLane(root, renderLanes) || pushStoreConsistencyCheck(fiber, getSnapshot, nextSnapshot); + hook.memoizedState = nextSnapshot; + root = { value: nextSnapshot, getSnapshot: getSnapshot }; + hook.queue = root; + mountEffect(subscribeToStore.bind(null, fiber, root, subscribe), [subscribe]); + fiber.flags |= 2048; + pushEffect( + 9, + updateStoreInstance.bind(null, fiber, root, nextSnapshot, getSnapshot), + void 0, + null + ); return nextSnapshot; } function pushStoreConsistencyCheck(fiber, getSnapshot, renderedSnapshot) { - fiber.flags |= 8192; + fiber.flags |= 16384; fiber = { getSnapshot: getSnapshot, value: renderedSnapshot }; getSnapshot = currentlyRenderingFiber$1.updateQueue; null === getSnapshot @@ -3676,7 +3671,7 @@ function mountState(initialState) { lastRenderedState: initialState }; hook.queue = initialState; - initialState = initialState.dispatch = dispatchAction.bind( + initialState = initialState.dispatch = dispatchSetState.bind( null, currentlyRenderingFiber$1, initialState @@ -3728,10 +3723,10 @@ function updateEffectImpl(fiberFlags, hookFlags, create, deps) { hook.memoizedState = pushEffect(1 | hookFlags, create, destroy, deps); } function mountEffect(create, deps) { - return mountEffectImpl(2098176, 8, create, deps); + return mountEffectImpl(4196352, 8, create, deps); } function updateEffect(create, deps) { - return updateEffectImpl(1024, 8, create, deps); + return updateEffectImpl(2048, 8, create, deps); } function updateInsertionEffect(create, deps) { return updateEffectImpl(4, 2, create, deps); @@ -3808,47 +3803,35 @@ function startTransition(setPending, callback) { (ReactCurrentBatchConfig$1.transition = prevTransition); } } -function dispatchAction(fiber, queue, action) { - var eventTime = requestEventTime(), - lane = requestUpdateLane(fiber), +function dispatchReducerAction(fiber, queue, action) { + var lane = requestUpdateLane(fiber); + action = { + lane: lane, + action: action, + hasEagerState: !1, + eagerState: null, + next: null + }; + isRenderPhaseUpdate(fiber) + ? enqueueRenderPhaseUpdate(queue, action) + : (enqueueUpdate$1(fiber, queue, action), + (action = requestEventTime()), + (fiber = scheduleUpdateOnFiber(fiber, lane, action)), + null !== fiber && entangleTransitionUpdate(fiber, queue, lane)); +} +function dispatchSetState(fiber, queue, action) { + var lane = requestUpdateLane(fiber), update = { lane: lane, action: action, - eagerReducer: null, + hasEagerState: !1, eagerState: null, next: null - }, - alternate = fiber.alternate; - if ( - fiber === currentlyRenderingFiber$1 || - (null !== alternate && alternate === currentlyRenderingFiber$1) - ) - (didScheduleRenderPhaseUpdateDuringThisPass = didScheduleRenderPhaseUpdate = !0), - (lane = queue.pending), - null === lane - ? (update.next = update) - : ((update.next = lane.next), (lane.next = update)), - (queue.pending = update); + }; + if (isRenderPhaseUpdate(fiber)) enqueueRenderPhaseUpdate(queue, update); else { - if ( - null !== workInProgressRoot && - 0 !== (fiber.mode & 1) && - 0 === (executionContext & 2) - ) { - var interleaved = queue.interleaved; - null === interleaved - ? ((update.next = update), - null === interleavedQueues - ? (interleavedQueues = [queue]) - : interleavedQueues.push(queue)) - : ((update.next = interleaved.next), (interleaved.next = update)); - queue.interleaved = update; - } else - (interleaved = queue.pending), - null === interleaved - ? (update.next = update) - : ((update.next = interleaved.next), (interleaved.next = update)), - (queue.pending = update); + enqueueUpdate$1(fiber, queue, update); + var alternate = fiber.alternate; if ( 0 === fiber.lanes && (null === alternate || 0 === alternate.lanes) && @@ -3857,20 +3840,57 @@ function dispatchAction(fiber, queue, action) { try { var currentState = queue.lastRenderedState, eagerState = alternate(currentState, action); - update.eagerReducer = alternate; + update.hasEagerState = !0; update.eagerState = eagerState; if (objectIs(eagerState, currentState)) return; } catch (error) { } finally { } - update = scheduleUpdateOnFiber(fiber, lane, eventTime); - 0 !== (lane & 4194240) && - null !== update && - ((fiber = queue.lanes), - (fiber &= update.pendingLanes), - (lane |= fiber), - (queue.lanes = lane), - markRootEntangled(update, lane)); + action = requestEventTime(); + fiber = scheduleUpdateOnFiber(fiber, lane, action); + null !== fiber && entangleTransitionUpdate(fiber, queue, lane); + } +} +function isRenderPhaseUpdate(fiber) { + var alternate = fiber.alternate; + return ( + fiber === currentlyRenderingFiber$1 || + (null !== alternate && alternate === currentlyRenderingFiber$1) + ); +} +function enqueueRenderPhaseUpdate(queue, update) { + didScheduleRenderPhaseUpdateDuringThisPass = didScheduleRenderPhaseUpdate = !0; + var pending = queue.pending; + null === pending + ? (update.next = update) + : ((update.next = pending.next), (pending.next = update)); + queue.pending = update; +} +function enqueueUpdate$1(fiber, queue, update) { + null !== workInProgressRoot && + 0 !== (fiber.mode & 1) && + 0 === (executionContext & 2) + ? ((fiber = queue.interleaved), + null === fiber + ? ((update.next = update), + null === interleavedQueues + ? (interleavedQueues = [queue]) + : interleavedQueues.push(queue)) + : ((update.next = fiber.next), (fiber.next = update)), + (queue.interleaved = update)) + : ((fiber = queue.pending), + null === fiber + ? (update.next = update) + : ((update.next = fiber.next), (fiber.next = update)), + (queue.pending = update)); +} +function entangleTransitionUpdate(root, queue, lane) { + if (0 !== (lane & 4194240)) { + var queueLanes = queue.lanes; + queueLanes &= root.pendingLanes; + lane |= queueLanes; + queue.lanes = lane; + markRootEntangled(root, lane); } } var ContextOnlyDispatcher = { @@ -3939,7 +3959,7 @@ var ContextOnlyDispatcher = { lastRenderedState: initialArg }; hook.queue = reducer; - reducer = reducer.dispatch = dispatchAction.bind( + reducer = reducer.dispatch = dispatchReducerAction.bind( null, currentlyRenderingFiber$1, reducer @@ -4049,7 +4069,7 @@ var ContextOnlyDispatcher = { (null !== workInProgressHook && workInProgressHook.memoizedState.tag & 1) ) { - fiber.flags |= 1024; + fiber.flags |= 2048; pushEffect( 9, updateStoreInstance.bind( @@ -4234,14 +4254,14 @@ function cutOffTailIfNeeded(renderState, hasRenderedATailFallback) { break; case "collapsed": lastTailNode = renderState.tail; - for (var lastTailNode$38 = null; null !== lastTailNode; ) - null !== lastTailNode.alternate && (lastTailNode$38 = lastTailNode), + for (var lastTailNode$35 = null; null !== lastTailNode; ) + null !== lastTailNode.alternate && (lastTailNode$35 = lastTailNode), (lastTailNode = lastTailNode.sibling); - null === lastTailNode$38 + null === lastTailNode$35 ? hasRenderedATailFallback || null === renderState.tail ? (renderState.tail = null) : (renderState.tail.sibling = null) - : (lastTailNode$38.sibling = null); + : (lastTailNode$35.sibling = null); } } function bubbleProperties(completedWork) { @@ -4251,19 +4271,19 @@ function bubbleProperties(completedWork) { newChildLanes = 0, subtreeFlags = 0; if (didBailout) - for (var child$39 = completedWork.child; null !== child$39; ) - (newChildLanes |= child$39.lanes | child$39.childLanes), - (subtreeFlags |= child$39.subtreeFlags & 3670016), - (subtreeFlags |= child$39.flags & 3670016), - (child$39.return = completedWork), - (child$39 = child$39.sibling); + for (var child$36 = completedWork.child; null !== child$36; ) + (newChildLanes |= child$36.lanes | child$36.childLanes), + (subtreeFlags |= child$36.subtreeFlags & 7340032), + (subtreeFlags |= child$36.flags & 7340032), + (child$36.return = completedWork), + (child$36 = child$36.sibling); else - for (child$39 = completedWork.child; null !== child$39; ) - (newChildLanes |= child$39.lanes | child$39.childLanes), - (subtreeFlags |= child$39.subtreeFlags), - (subtreeFlags |= child$39.flags), - (child$39.return = completedWork), - (child$39 = child$39.sibling); + for (child$36 = completedWork.child; null !== child$36; ) + (newChildLanes |= child$36.lanes | child$36.childLanes), + (subtreeFlags |= child$36.subtreeFlags), + (subtreeFlags |= child$36.flags), + (child$36.return = completedWork), + (child$36 = child$36.sibling); completedWork.subtreeFlags |= subtreeFlags; completedWork.childLanes = newChildLanes; return didBailout; @@ -4299,8 +4319,8 @@ function completeWork(current, workInProgress, renderLanes) { ((newProps.context = newProps.pendingContext), (newProps.pendingContext = null)), (null !== current && null !== current.child) || - newProps.hydrate || - (workInProgress.flags |= 512), + newProps.isDehydrated || + (workInProgress.flags |= 1024), updateHostContainer(current, workInProgress), bubbleProperties(workInProgress), null @@ -4317,7 +4337,7 @@ function completeWork(current, workInProgress, renderLanes) { newProps, renderLanes ), - current.ref !== workInProgress.ref && (workInProgress.flags |= 256); + current.ref !== workInProgress.ref && (workInProgress.flags |= 512); else { if (!newProps) { if (null === workInProgress.stateNode) @@ -4352,7 +4372,7 @@ function completeWork(current, workInProgress, renderLanes) { appendAllChildren(renderLanes, workInProgress, !1, !1); workInProgress.stateNode = renderLanes; finalizeInitialChildren(renderLanes) && (workInProgress.flags |= 4); - null !== workInProgress.ref && (workInProgress.flags |= 256); + null !== workInProgress.ref && (workInProgress.flags |= 512); } bubbleProperties(workInProgress); return null; @@ -4396,7 +4416,7 @@ function completeWork(current, workInProgress, renderLanes) { if ( null !== newProps && !renderLanes && - ((workInProgress.child.flags |= 4096), 0 !== (workInProgress.mode & 1)) + ((workInProgress.child.flags |= 8192), 0 !== (workInProgress.mode & 1)) ) if ( (null === current && @@ -4408,7 +4428,8 @@ function completeWork(current, workInProgress, renderLanes) { else { if ( 0 === workInProgressRootExitStatus || - 3 === workInProgressRootExitStatus + 3 === workInProgressRootExitStatus || + 2 === workInProgressRootExitStatus ) workInProgressRootExitStatus = 4; null === workInProgressRoot || @@ -4468,7 +4489,7 @@ function completeWork(current, workInProgress, renderLanes) { for (newProps = workInProgress.child; null !== newProps; ) (renderLanes = newProps), (type = current), - (renderLanes.flags &= 3670018), + (renderLanes.flags &= 7340034), (updatePayload = renderLanes.alternate), null === updatePayload ? ((renderLanes.childLanes = 0), @@ -4572,14 +4593,14 @@ function completeWork(current, workInProgress, renderLanes) { (null !== current.memoizedState) !== renderLanes && "unstable-defer-without-hiding" !== newProps.mode && 23 !== workInProgress.tag && - (workInProgress.flags |= 4096), + (workInProgress.flags |= 8192), renderLanes && 0 !== (workInProgress.mode & 1) ? 0 !== (subtreeRenderLanes & 1073741824) && (bubbleProperties(workInProgress), 23 !== workInProgress.tag && workInProgress.subtreeFlags & 6 && "unstable-defer-without-hiding" !== newProps.mode && - (workInProgress.flags |= 4096)) + (workInProgress.flags |= 8192)) : bubbleProperties(workInProgress), null ); @@ -4624,7 +4645,7 @@ function updateForwardRef( if (null !== current && !didReceiveUpdate) return ( (workInProgress.updateQueue = current.updateQueue), - (workInProgress.flags &= -1029), + (workInProgress.flags &= -2053), (current.lanes &= ~renderLanes), bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes) ); @@ -4698,7 +4719,7 @@ function updateSimpleMemoComponent( current.ref === workInProgress.ref ) if (((didReceiveUpdate = !1), 0 !== (current.lanes & renderLanes))) - 0 !== (current.flags & 65536) && (didReceiveUpdate = !0); + 0 !== (current.flags & 131072) && (didReceiveUpdate = !0); else return ( (workInProgress.lanes = current.lanes), @@ -4762,7 +4783,7 @@ function markRef$1(current, workInProgress) { (null === current && null !== ref) || (null !== current && current.ref !== ref) ) - workInProgress.flags |= 256; + workInProgress.flags |= 512; } function updateFunctionComponent( current, @@ -4787,7 +4808,7 @@ function updateFunctionComponent( if (null !== current && !didReceiveUpdate) return ( (workInProgress.updateQueue = current.updateQueue), - (workInProgress.flags &= -1029), + (workInProgress.flags &= -2053), (current.lanes &= ~renderLanes), bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes) ); @@ -4963,7 +4984,7 @@ function updateClassComponent( "function" === typeof instance.componentDidUpdate && (workInProgress.flags |= 4), "function" === typeof instance.getSnapshotBeforeUpdate && - (workInProgress.flags |= 512)) + (workInProgress.flags |= 1024)) : ("function" !== typeof instance.componentDidUpdate || (oldProps === current.memoizedProps && oldState === current.memoizedState) || @@ -4971,7 +4992,7 @@ function updateClassComponent( "function" !== typeof instance.getSnapshotBeforeUpdate || (oldProps === current.memoizedProps && oldState === current.memoizedState) || - (workInProgress.flags |= 512), + (workInProgress.flags |= 1024), (workInProgress.memoizedProps = nextProps), (workInProgress.memoizedState = newState)), (instance.props = nextProps), @@ -4985,7 +5006,7 @@ function updateClassComponent( "function" !== typeof instance.getSnapshotBeforeUpdate || (oldProps === current.memoizedProps && oldState === current.memoizedState) || - (workInProgress.flags |= 512), + (workInProgress.flags |= 1024), (nextProps = !1)); } return finishClassComponent( @@ -5242,7 +5263,7 @@ function updateSuspenseFallbackChildren( (primaryChildren.pendingProps = primaryChildProps), (workInProgress.deletions = null)) : ((primaryChildren = createWorkInProgress(current, primaryChildProps)), - (primaryChildren.subtreeFlags = current.subtreeFlags & 3670016)); + (primaryChildren.subtreeFlags = current.subtreeFlags & 7340032)); null !== currentFallbackChildFragment ? (fallbackChildren = createWorkInProgress( currentFallbackChildFragment, @@ -5470,8 +5491,8 @@ function unwindWork(workInProgress) { case 1: isContextProvider(workInProgress.type) && popContext(); var flags = workInProgress.flags; - return flags & 32768 - ? ((workInProgress.flags = (flags & -32769) | 128), workInProgress) + return flags & 65536 + ? ((workInProgress.flags = (flags & -65537) | 128), workInProgress) : null; case 3: popHostContainer(); @@ -5483,7 +5504,7 @@ function unwindWork(workInProgress) { throw Error( "The root failed to unmount after an error. This is likely a bug in React. Please file an issue." ); - workInProgress.flags = (flags & -32769) | 128; + workInProgress.flags = (flags & -65537) | 128; return workInProgress; case 5: return popHostContext(workInProgress), null; @@ -5491,8 +5512,8 @@ function unwindWork(workInProgress) { return ( pop(suspenseStackCursor), (flags = workInProgress.flags), - flags & 32768 - ? ((workInProgress.flags = (flags & -32769) | 128), workInProgress) + flags & 65536 + ? ((workInProgress.flags = (flags & -65537) | 128), workInProgress) : null ); case 19: @@ -5529,7 +5550,7 @@ function commitBeforeMutationEffects(root, firstChild) { if ( ((root = nextEffect), (firstChild = root.child), - 0 !== (root.subtreeFlags & 516) && null !== firstChild) + 0 !== (root.subtreeFlags & 1028) && null !== firstChild) ) (firstChild.return = root), (nextEffect = firstChild); else @@ -5537,7 +5558,7 @@ function commitBeforeMutationEffects(root, firstChild) { root = nextEffect; try { var current = root.alternate; - if (0 !== (root.flags & 512)) + if (0 !== (root.flags & 1024)) switch (root.tag) { case 0: case 11: @@ -5618,8 +5639,8 @@ function commitHookEffectListMount(tag, finishedWork) { var effect = (finishedWork = finishedWork.next); do { if ((effect.tag & tag) === tag) { - var create$83 = effect.create; - effect.destroy = create$83(); + var create$80 = effect.create; + effect.destroy = create$80(); } effect = effect.next; } while (effect !== finishedWork); @@ -6063,14 +6084,14 @@ function commitMutationEffects(root, firstChild) { } } deletions = firstChild.child; - if (0 !== (firstChild.subtreeFlags & 6454) && null !== deletions) + if (0 !== (firstChild.subtreeFlags & 12854) && null !== deletions) (deletions.return = firstChild), (nextEffect = deletions); else for (; null !== nextEffect; ) { firstChild = nextEffect; try { var flags = firstChild.flags; - if (flags & 256) { + if (flags & 512) { var current = firstChild.alternate; if (null !== current) { var currentRef = current.ref; @@ -6080,12 +6101,12 @@ function commitMutationEffects(root, firstChild) { : (currentRef.current = null)); } } - if (flags & 4096) + if (flags & 8192) switch (firstChild.tag) { case 13: if (null !== firstChild.memoizedState) { - var current$88 = firstChild.alternate; - if (null === current$88 || null === current$88.memoizedState) + var current$85 = firstChild.alternate; + if (null === current$85 || null === current$85.memoizedState) globalMostRecentFallbackTime = now(); } break; @@ -6161,7 +6182,7 @@ function commitMutationEffects(root, firstChild) { } } } - switch (flags & 2054) { + switch (flags & 4102) { case 2: commitPlacement(firstChild); firstChild.flags &= -3; @@ -6171,11 +6192,11 @@ function commitMutationEffects(root, firstChild) { firstChild.flags &= -3; commitWork(firstChild.alternate, firstChild); break; - case 2048: - firstChild.flags &= -2049; + case 4096: + firstChild.flags &= -4097; break; - case 2052: - firstChild.flags &= -2049; + case 4100: + firstChild.flags &= -4097; commitWork(firstChild.alternate, firstChild); break; case 4: @@ -6198,15 +6219,15 @@ function commitLayoutEffects(finishedWork) { for (nextEffect = finishedWork; null !== nextEffect; ) { var fiber = nextEffect, firstChild = fiber.child; - if (0 !== (fiber.subtreeFlags & 4420) && null !== firstChild) + if (0 !== (fiber.subtreeFlags & 8772) && null !== firstChild) (firstChild.return = fiber), (nextEffect = firstChild); else for (fiber = finishedWork; null !== nextEffect; ) { firstChild = nextEffect; - if (0 !== (firstChild.flags & 4420)) { + if (0 !== (firstChild.flags & 8772)) { var current = firstChild.alternate; try { - if (0 !== (firstChild.flags & 4420)) + if (0 !== (firstChild.flags & 8772)) switch (firstChild.tag) { case 0: case 11: @@ -6236,8 +6257,8 @@ function commitLayoutEffects(finishedWork) { commitUpdateQueue(firstChild, updateQueue, instance); break; case 3: - var updateQueue$84 = firstChild.updateQueue; - if (null !== updateQueue$84) { + var updateQueue$81 = firstChild.updateQueue; + if (null !== updateQueue$81) { current = null; if (null !== firstChild.child) switch (firstChild.child.tag) { @@ -6247,7 +6268,7 @@ function commitLayoutEffects(finishedWork) { case 1: current = firstChild.child.stateNode; } - commitUpdateQueue(firstChild, updateQueue$84, current); + commitUpdateQueue(firstChild, updateQueue$81, current); } break; case 5: @@ -6271,7 +6292,7 @@ function commitLayoutEffects(finishedWork) { "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 (firstChild.flags & 256) { + if (firstChild.flags & 512) { current = void 0; var ref = firstChild.ref; if (null !== ref) { @@ -6621,14 +6642,14 @@ function performConcurrentWorkOnRoot(root, didTimeout) { function recoverFromConcurrentError(root, errorRetryLanes) { var prevExecutionContext = executionContext; executionContext |= 8; - root.hydrate && (root.hydrate = !1); + root.isDehydrated && (root.isDehydrated = !1); root = renderRootSync(root, errorRetryLanes); executionContext = prevExecutionContext; return root; } function isRenderConsistentWithExternalStores(finishedWork) { for (var node = finishedWork; ; ) { - if (node.flags & 8192) { + if (node.flags & 16384) { var updateQueue = node.updateQueue; if ( null !== updateQueue && @@ -6646,7 +6667,7 @@ function isRenderConsistentWithExternalStores(finishedWork) { } } updateQueue = node.child; - if (node.subtreeFlags & 8192 && null !== updateQueue) + if (node.subtreeFlags & 16384 && null !== updateQueue) (updateQueue.return = node), (node = updateQueue); else { if (node === finishedWork) break; @@ -6682,7 +6703,7 @@ function performSyncWorkOnRoot(root) { if (0 !== root.tag && 2 === exitStatus) { var prevExecutionContext = executionContext; executionContext |= 8; - root.hydrate && (root.hydrate = !1); + root.isDehydrated && (root.isDehydrated = !1); var errorRetryLanes = getLanesToRetrySynchronouslyOnError(root); 0 !== errorRetryLanes && ((lanes = errorRetryLanes), (exitStatus = renderRootSync(root, lanes))); @@ -6807,71 +6828,83 @@ function handleError(root$jscomp$0, thrownValue) { sourceFiber = erroredWork, value = thrownValue; thrownValue = workInProgressRootRenderLanes; - sourceFiber.flags |= 16384; + sourceFiber.flags |= 32768; if ( null !== value && "object" === typeof value && "function" === typeof value.then ) { var wakeable = value, - tag = sourceFiber.tag; + sourceFiber$jscomp$0 = sourceFiber, + tag = sourceFiber$jscomp$0.tag; if ( - 0 === (sourceFiber.mode & 1) && + 0 === (sourceFiber$jscomp$0.mode & 1) && (0 === tag || 11 === tag || 15 === tag) ) { - var currentSource = sourceFiber.alternate; + var currentSource = sourceFiber$jscomp$0.alternate; currentSource - ? ((sourceFiber.updateQueue = currentSource.updateQueue), - (sourceFiber.memoizedState = currentSource.memoizedState), - (sourceFiber.lanes = currentSource.lanes)) - : ((sourceFiber.updateQueue = null), - (sourceFiber.memoizedState = null)); + ? ((sourceFiber$jscomp$0.updateQueue = currentSource.updateQueue), + (sourceFiber$jscomp$0.memoizedState = + currentSource.memoizedState), + (sourceFiber$jscomp$0.lanes = currentSource.lanes)) + : ((sourceFiber$jscomp$0.updateQueue = null), + (sourceFiber$jscomp$0.memoizedState = null)); } - var hasInvisibleParentBoundary = - 0 !== (suspenseStackCursor.current & 1), - workInProgress$32 = returnFiber; - do { - var JSCompiler_temp; - if ((JSCompiler_temp = 13 === workInProgress$32.tag)) { - var nextState = workInProgress$32.memoizedState; - JSCompiler_temp = - null !== nextState - ? null !== nextState.dehydrated + b: { + sourceFiber$jscomp$0 = returnFiber; + var sourceFiber$jscomp$1 = sourceFiber, + rootRenderLanes = thrownValue, + hasInvisibleParentBoundary = + 0 !== (suspenseStackCursor.current & 1), + node = sourceFiber$jscomp$0; + do { + var JSCompiler_temp; + if ((JSCompiler_temp = 13 === node.tag)) { + var nextState = node.memoizedState; + JSCompiler_temp = + null !== nextState + ? null !== nextState.dehydrated + ? !0 + : !1 + : !0 !== node.memoizedProps.unstable_avoidThisFallback ? !0 - : !1 - : !0 !== - workInProgress$32.memoizedProps.unstable_avoidThisFallback - ? !0 - : hasInvisibleParentBoundary - ? !1 - : !0; - } - if (JSCompiler_temp) { - var wakeables = workInProgress$32.updateQueue; - if (null === wakeables) { - var updateQueue = new Set(); - updateQueue.add(wakeable); - workInProgress$32.updateQueue = updateQueue; - } else wakeables.add(wakeable); - if ( - 0 === (workInProgress$32.mode & 1) && - workInProgress$32 !== returnFiber - ) { - workInProgress$32.flags |= 128; - sourceFiber.flags |= 65536; - sourceFiber.flags &= -26437; - if (1 === sourceFiber.tag) - if (null === sourceFiber.alternate) sourceFiber.tag = 17; - else { - var update = createUpdate(-1, 1); - update.tag = 2; - enqueueUpdate(sourceFiber, update); - } - sourceFiber.lanes |= 1; - break a; + : hasInvisibleParentBoundary + ? !1 + : !0; } - value = void 0; - sourceFiber = thrownValue; + if (JSCompiler_temp) { + if (0 === (node.mode & 1)) { + if (node === sourceFiber$jscomp$0) node.flags |= 65536; + else { + node.flags |= 128; + sourceFiber$jscomp$1.flags |= 131072; + sourceFiber$jscomp$1.flags &= -52805; + if (1 === sourceFiber$jscomp$1.tag) + if (null === sourceFiber$jscomp$1.alternate) + sourceFiber$jscomp$1.tag = 17; + else { + var update = createUpdate(-1, 1); + update.tag = 2; + enqueueUpdate(sourceFiber$jscomp$1, update); + } + sourceFiber$jscomp$1.lanes |= 1; + } + var suspenseBoundary = node; + break b; + } + node.flags |= 65536; + node.lanes = rootRenderLanes; + suspenseBoundary = node; + break b; + } + node = node.return; + } while (null !== node); + suspenseBoundary = null; + } + if (null !== suspenseBoundary) { + value = void 0; + sourceFiber = suspenseBoundary; + if (sourceFiber.mode & 1) { var pingCache = root.pingCache; null === pingCache ? ((pingCache = root.pingCache = new PossiblyWeakMap()), @@ -6880,71 +6913,74 @@ function handleError(root$jscomp$0, thrownValue) { : ((value = pingCache.get(wakeable)), void 0 === value && ((value = new Set()), pingCache.set(wakeable, value))); - if (!value.has(sourceFiber)) { - value.add(sourceFiber); + if (!value.has(thrownValue)) { + value.add(thrownValue); var ping = pingSuspendedRoot.bind( null, root, wakeable, - sourceFiber + thrownValue ); wakeable.then(ping, ping); } - workInProgress$32.flags |= 32768; - workInProgress$32.lanes = thrownValue; - break a; } - workInProgress$32 = workInProgress$32.return; - } while (null !== workInProgress$32); - value = Error( - (getComponentNameFromFiber(sourceFiber) || "A React component") + - " suspended while rendering, but no fallback UI was specified.\n\nAdd a component higher in the tree to provide a loading indicator or placeholder to display." - ); + var wakeables = sourceFiber.updateQueue; + if (null === wakeables) { + var updateQueue = new Set(); + updateQueue.add(wakeable); + sourceFiber.updateQueue = updateQueue; + } else wakeables.add(wakeable); + break a; + } else + value = Error( + (getComponentNameFromFiber(sourceFiber) || "A React component") + + " suspended while rendering, but no fallback UI was specified.\n\nAdd a component higher in the tree to provide a loading indicator or placeholder to display." + ); } - 5 !== workInProgressRootExitStatus && + 4 !== workInProgressRootExitStatus && (workInProgressRootExitStatus = 2); value = createCapturedValue(value, sourceFiber); - workInProgress$32 = returnFiber; + root = returnFiber; do { - switch (workInProgress$32.tag) { + switch (root.tag) { case 3: - root = value; - workInProgress$32.flags |= 32768; + wakeable = value; + root.flags |= 65536; thrownValue &= -thrownValue; - workInProgress$32.lanes |= thrownValue; - var update$33 = createRootErrorUpdate( - workInProgress$32, + root.lanes |= thrownValue; + var update$jscomp$0 = createRootErrorUpdate( root, + wakeable, thrownValue ); - enqueueCapturedUpdate(workInProgress$32, update$33); + enqueueCapturedUpdate(root, update$jscomp$0); break a; case 1: - root = value; - var ctor = workInProgress$32.type, - instance = workInProgress$32.stateNode; + wakeable = value; + var ctor = root.type, + instance = root.stateNode; if ( - 0 === (workInProgress$32.flags & 128) && + 0 === (root.flags & 128) && ("function" === typeof ctor.getDerivedStateFromError || (null !== instance && "function" === typeof instance.componentDidCatch && (null === legacyErrorBoundariesThatAlreadyFailed || !legacyErrorBoundariesThatAlreadyFailed.has(instance)))) ) { - workInProgress$32.flags |= 32768; + root.flags |= 65536; thrownValue &= -thrownValue; - workInProgress$32.lanes |= thrownValue; - var update$36 = createClassErrorUpdate( - workInProgress$32, + root.lanes |= thrownValue; + var update$33 = createClassErrorUpdate( root, + wakeable, thrownValue ); - enqueueCapturedUpdate(workInProgress$32, update$36); + enqueueCapturedUpdate(root, update$33); break a; } } - workInProgress$32 = workInProgress$32.return; - } while (null !== workInProgress$32); + root = root.return; + } while (null !== root); } completeUnitOfWork(erroredWork); } catch (yetAnotherThrownValue) { @@ -7005,7 +7041,7 @@ function completeUnitOfWork(unitOfWork) { do { var current = completedWork.alternate; unitOfWork = completedWork.return; - if (0 === (completedWork.flags & 16384)) { + if (0 === (completedWork.flags & 32768)) { if ( ((current = completeWork(current, completedWork, subtreeRenderLanes)), null !== current) @@ -7016,12 +7052,12 @@ function completeUnitOfWork(unitOfWork) { } else { current = unwindWork(completedWork); if (null !== current) { - current.flags &= 16383; + current.flags &= 32767; workInProgress = current; return; } null !== unitOfWork && - ((unitOfWork.flags |= 16384), + ((unitOfWork.flags |= 32768), (unitOfWork.subtreeFlags = 0), (unitOfWork.deletions = null)); } @@ -7068,16 +7104,16 @@ function commitRootImpl(root, renderPriorityLevel) { root === workInProgressRoot && ((workInProgress = workInProgressRoot = null), (workInProgressRootRenderLanes = 0)); - (0 === (finishedWork.subtreeFlags & 1040) && - 0 === (finishedWork.flags & 1040)) || + (0 === (finishedWork.subtreeFlags & 2064) && + 0 === (finishedWork.flags & 2064)) || rootDoesHavePassiveEffects || ((rootDoesHavePassiveEffects = !0), scheduleCallback$1(NormalPriority, function() { flushPassiveEffects(); return null; })); - remainingLanes = 0 !== (finishedWork.flags & 8054); - if (0 !== (finishedWork.subtreeFlags & 8054) || remainingLanes) { + remainingLanes = 0 !== (finishedWork.flags & 15990); + if (0 !== (finishedWork.subtreeFlags & 15990) || remainingLanes) { remainingLanes = ReactCurrentBatchConfig$2.transition; ReactCurrentBatchConfig$2.transition = 0; var previousPriority = currentUpdatePriority; @@ -7191,12 +7227,12 @@ function flushPassiveEffects() { nextEffect = fiber; } } - if (0 !== (fiber.subtreeFlags & 1040) && null !== child) + if (0 !== (fiber.subtreeFlags & 2064) && null !== child) (child.return = fiber), (nextEffect = child); else b: for (; null !== nextEffect; ) { fiber = nextEffect; - if (0 !== (fiber.flags & 1024)) + if (0 !== (fiber.flags & 2048)) switch (fiber.tag) { case 0: case 11: @@ -7216,12 +7252,12 @@ function flushPassiveEffects() { for (nextEffect = finishedWork; null !== nextEffect; ) { child = nextEffect; var firstChild = child.child; - if (0 !== (child.subtreeFlags & 1040) && null !== firstChild) + if (0 !== (child.subtreeFlags & 2064) && null !== firstChild) (firstChild.return = child), (nextEffect = firstChild); else b: for (child = finishedWork; null !== nextEffect; ) { deletions = nextEffect; - if (0 !== (deletions.flags & 1024)) + if (0 !== (deletions.flags & 2048)) try { switch (deletions.tag) { case 0: @@ -7373,7 +7409,7 @@ beginWork$1 = function(current, workInProgress, renderLanes) { renderLanes ) ); - didReceiveUpdate = 0 !== (current.flags & 65536) ? !0 : !1; + didReceiveUpdate = 0 !== (current.flags & 131072) ? !0 : !1; } else didReceiveUpdate = !1; workInProgress.lanes = 0; @@ -7839,7 +7875,7 @@ function createWorkInProgress(current, pendingProps) { (workInProgress.flags = 0), (workInProgress.subtreeFlags = 0), (workInProgress.deletions = null)); - workInProgress.flags = current.flags & 3670016; + workInProgress.flags = current.flags & 7340032; workInProgress.childLanes = current.childLanes; workInProgress.lanes = current.lanes; workInProgress.child = current.child; @@ -7932,8 +7968,7 @@ function createFiberFromTypeAndProps( } throw Error( "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) + - "." + ((null == type ? type : typeof type) + ".") ); } key = createFiber(fiberTag, pendingProps, key, mode); @@ -7979,7 +8014,7 @@ function FiberRootNode(containerInfo, tag, hydrate) { this.finishedWork = this.pingCache = this.current = this.pendingChildren = null; this.timeoutHandle = -1; this.pendingContext = this.context = null; - this.hydrate = hydrate; + this.isDehydrated = hydrate; this.callbackNode = null; this.callbackPriority = 0; this.eventTimes = createLaneMap(0); @@ -8003,9 +8038,9 @@ function findHostInstance(component) { if (void 0 === fiber) { if ("function" === typeof component.render) throw Error("Unable to find node on an unmounted component."); + component = Object.keys(component).join(","); throw Error( - "Argument appears to not be a ReactComponent. Keys: " + - Object.keys(component) + "Argument appears to not be a ReactComponent. Keys: " + component ); } component = findCurrentHostFiber(fiber); @@ -8196,10 +8231,10 @@ batchedUpdatesImpl = function(fn, a) { } }; var roots = new Map(), - devToolsConfig$jscomp$inline_986 = { + devToolsConfig$jscomp$inline_976 = { findFiberByHostInstance: getInstanceFromTag, bundleType: 0, - version: "18.0.0-e8feb11b6-20210915", + version: "18.0.0-afcb9cdc9-20211008", rendererPackageName: "react-native-renderer", rendererConfig: { getInspectorDataForViewTag: function() { @@ -8214,11 +8249,11 @@ var roots = new Map(), }.bind(null, findNodeHandle) } }; -var internals$jscomp$inline_1239 = { - bundleType: devToolsConfig$jscomp$inline_986.bundleType, - version: devToolsConfig$jscomp$inline_986.version, - rendererPackageName: devToolsConfig$jscomp$inline_986.rendererPackageName, - rendererConfig: devToolsConfig$jscomp$inline_986.rendererConfig, +var internals$jscomp$inline_1240 = { + bundleType: devToolsConfig$jscomp$inline_976.bundleType, + version: devToolsConfig$jscomp$inline_976.version, + rendererPackageName: devToolsConfig$jscomp$inline_976.rendererPackageName, + rendererConfig: devToolsConfig$jscomp$inline_976.rendererConfig, overrideHookState: null, overrideHookStateDeletePath: null, overrideHookStateRenamePath: null, @@ -8234,27 +8269,26 @@ var internals$jscomp$inline_1239 = { return null === fiber ? null : fiber.stateNode; }, findFiberByHostInstance: - devToolsConfig$jscomp$inline_986.findFiberByHostInstance || + devToolsConfig$jscomp$inline_976.findFiberByHostInstance || emptyFindFiberByHostInstance, findHostInstancesForRefresh: null, scheduleRefresh: null, scheduleRoot: null, setRefreshHandler: null, getCurrentFiber: null, - getIsStrictMode: null, - reconcilerVersion: "18.0.0-e8feb11b6-20210915" + reconcilerVersion: "18.0.0-afcb9cdc9-20211008" }; if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) { - var hook$jscomp$inline_1240 = __REACT_DEVTOOLS_GLOBAL_HOOK__; + var hook$jscomp$inline_1241 = __REACT_DEVTOOLS_GLOBAL_HOOK__; if ( - !hook$jscomp$inline_1240.isDisabled && - hook$jscomp$inline_1240.supportsFiber + !hook$jscomp$inline_1241.isDisabled && + hook$jscomp$inline_1241.supportsFiber ) try { - (rendererID = hook$jscomp$inline_1240.inject( - internals$jscomp$inline_1239 + (rendererID = hook$jscomp$inline_1241.inject( + internals$jscomp$inline_1240 )), - (injectedHook = hook$jscomp$inline_1240); + (injectedHook = hook$jscomp$inline_1241); } catch (err) {} } exports.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = { diff --git a/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.fb.js b/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.fb.js index 6dc64c74dc..8916f57175 100644 --- a/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.fb.js +++ b/Libraries/Renderer/implementations/ReactNativeRenderer-profiling.fb.js @@ -7,7 +7,7 @@ * @noflow * @nolint * @preventMunge - * @generated SignedSource<> + * @generated SignedSource<> */ "use strict"; @@ -782,18 +782,16 @@ function recomputePluginOrdering() { for (var pluginName in namesToPlugins) { var pluginModule = namesToPlugins[pluginName], pluginIndex = eventPluginOrder.indexOf(pluginName); - if (!(-1 < pluginIndex)) + if (-1 >= pluginIndex) throw Error( "EventPluginRegistry: Cannot inject event plugins that do not exist in the plugin ordering, `" + - pluginName + - "`." + (pluginName + "`.") ); if (!plugins[pluginIndex]) { if (!pluginModule.extractEvents) throw Error( "EventPluginRegistry: Event plugins must implement an `extractEvents` method, but `" + - pluginName + - "` does not." + (pluginName + "` does not.") ); plugins[pluginIndex] = pluginModule; pluginIndex = pluginModule.eventTypes; @@ -804,8 +802,7 @@ function recomputePluginOrdering() { if (eventNameDispatchConfigs.hasOwnProperty(eventName$jscomp$0)) throw Error( "EventPluginRegistry: More than one plugin attempted to publish the same event name, `" + - eventName$jscomp$0 + - "`." + (eventName$jscomp$0 + "`.") ); eventNameDispatchConfigs[eventName$jscomp$0] = dispatchConfig; var phasedRegistrationNames = dispatchConfig.phasedRegistrationNames; @@ -845,8 +842,7 @@ function publishRegistrationName(registrationName, pluginModule) { if (registrationNameModules[registrationName]) throw Error( "EventPluginRegistry: More than one plugin attempted to publish the same registration name, `" + - registrationName + - "`." + (registrationName + "`.") ); registrationNameModules[registrationName] = pluginModule; } @@ -930,7 +926,7 @@ eventPluginOrder = Array.prototype.slice.call([ "ReactNativeBridgeEventPlugin" ]); recomputePluginOrdering(); -var injectedNamesToPlugins$jscomp$inline_233 = { +var injectedNamesToPlugins$jscomp$inline_230 = { ResponderEventPlugin: ResponderEventPlugin, ReactNativeBridgeEventPlugin: { eventTypes: {}, @@ -965,34 +961,33 @@ var injectedNamesToPlugins$jscomp$inline_233 = { } } }, - isOrderingDirty$jscomp$inline_234 = !1, - pluginName$jscomp$inline_235; -for (pluginName$jscomp$inline_235 in injectedNamesToPlugins$jscomp$inline_233) + isOrderingDirty$jscomp$inline_231 = !1, + pluginName$jscomp$inline_232; +for (pluginName$jscomp$inline_232 in injectedNamesToPlugins$jscomp$inline_230) if ( - injectedNamesToPlugins$jscomp$inline_233.hasOwnProperty( - pluginName$jscomp$inline_235 + injectedNamesToPlugins$jscomp$inline_230.hasOwnProperty( + pluginName$jscomp$inline_232 ) ) { - var pluginModule$jscomp$inline_236 = - injectedNamesToPlugins$jscomp$inline_233[pluginName$jscomp$inline_235]; + var pluginModule$jscomp$inline_233 = + injectedNamesToPlugins$jscomp$inline_230[pluginName$jscomp$inline_232]; if ( - !namesToPlugins.hasOwnProperty(pluginName$jscomp$inline_235) || - namesToPlugins[pluginName$jscomp$inline_235] !== - pluginModule$jscomp$inline_236 + !namesToPlugins.hasOwnProperty(pluginName$jscomp$inline_232) || + namesToPlugins[pluginName$jscomp$inline_232] !== + pluginModule$jscomp$inline_233 ) { - if (namesToPlugins[pluginName$jscomp$inline_235]) + if (namesToPlugins[pluginName$jscomp$inline_232]) throw Error( "EventPluginRegistry: Cannot inject two different event plugins using the same name, `" + - pluginName$jscomp$inline_235 + - "`." + (pluginName$jscomp$inline_232 + "`.") ); namesToPlugins[ - pluginName$jscomp$inline_235 - ] = pluginModule$jscomp$inline_236; - isOrderingDirty$jscomp$inline_234 = !0; + pluginName$jscomp$inline_232 + ] = pluginModule$jscomp$inline_233; + isOrderingDirty$jscomp$inline_231 = !0; } } -isOrderingDirty$jscomp$inline_234 && recomputePluginOrdering(); +isOrderingDirty$jscomp$inline_231 && recomputePluginOrdering(); var instanceCache = new Map(), instanceProps = new Map(); function getInstanceFromTag(tag) { @@ -1293,7 +1288,7 @@ function getNearestMountedFiber(fiber) { fiber = node; do (node = fiber), - 0 !== (node.flags & 2050) && (nearestMounted = node.return), + 0 !== (node.flags & 4098) && (nearestMounted = node.return), (fiber = node.return); while (fiber); } @@ -2424,7 +2419,7 @@ function processUpdateQueue( newState = workInProgress; break a; case 3: - workInProgress.flags = (workInProgress.flags & -32769) | 128; + workInProgress.flags = (workInProgress.flags & -65537) | 128; case 0: workInProgress = update.payload; updateLane = @@ -2677,7 +2672,8 @@ function coerceRef(returnFiber, current, element) { returnFiber + ". This error is likely caused by a bug in React. Please file an issue." ); - var stringRef = "" + returnFiber; + var resolvedInst = inst, + stringRef = "" + returnFiber; if ( null !== current && null !== current.ref && @@ -2686,8 +2682,8 @@ function coerceRef(returnFiber, current, element) { ) return current.ref; current = function(value) { - var refs = inst.refs; - refs === emptyRefsObject && (refs = inst.refs = {}); + var refs = resolvedInst.refs; + refs === emptyRefsObject && (refs = resolvedInst.refs = {}); null === value ? delete refs[stringRef] : (refs[stringRef] = value); }; current._stringRef = stringRef; @@ -3386,7 +3382,7 @@ function renderWithHooks( nextRenderLanes = 0; do { didScheduleRenderPhaseUpdateDuringThisPass = !1; - if (!(25 > nextRenderLanes)) + if (25 <= nextRenderLanes) throw Error( "Too many re-renders. React limits the number of renders to prevent an infinite loop." ); @@ -3487,19 +3483,18 @@ function updateReducer(reducer) { (newBaseQueueLast = newBaseQueueLast.next = { lane: 0, action: update.action, - eagerReducer: update.eagerReducer, + hasEagerState: update.hasEagerState, eagerState: update.eagerState, next: null }), - (current = - update.eagerReducer === reducer - ? update.eagerState - : reducer(current, update.action)); + (current = update.hasEagerState + ? update.eagerState + : reducer(current, update.action)); else { var clone = { lane: updateLane, action: update.action, - eagerReducer: update.eagerReducer, + hasEagerState: update.hasEagerState, eagerState: update.eagerState, next: null }; @@ -3639,7 +3634,7 @@ function useMutableSource(hook, source, getSnapshot, subscribe) { lastRenderedReducer: basicStateReducer, lastRenderedState: snapshot }), - (hook.dispatch = setSnapshot = dispatchAction.bind( + (hook.dispatch = setSnapshot = dispatchSetState.bind( null, currentlyRenderingFiber$1, hook @@ -3656,30 +3651,30 @@ function updateMutableSource(source, getSnapshot, subscribe) { } function mountSyncExternalStore(subscribe, getSnapshot) { var fiber = currentlyRenderingFiber$1, - hook = mountWorkInProgressHook(), - nextSnapshot = getSnapshot(); - hook.memoizedState = nextSnapshot; - var inst = { value: nextSnapshot, getSnapshot: getSnapshot }; - hook.queue = inst; - mountEffect(subscribeToStore.bind(null, fiber, inst, subscribe), [subscribe]); - fiber.flags |= 1024; - pushEffect( - 9, - updateStoreInstance.bind(null, fiber, inst, nextSnapshot, getSnapshot), - void 0, - null - ); - subscribe = workInProgressRoot; - if (null === subscribe) + hook = mountWorkInProgressHook(); + var nextSnapshot = getSnapshot(); + var root = workInProgressRoot; + if (null === root) throw Error( "Expected a work-in-progress root. This is a bug in React. Please file an issue." ); - includesBlockingLane(subscribe, renderLanes) || + includesBlockingLane(root, renderLanes) || pushStoreConsistencyCheck(fiber, getSnapshot, nextSnapshot); + hook.memoizedState = nextSnapshot; + root = { value: nextSnapshot, getSnapshot: getSnapshot }; + hook.queue = root; + mountEffect(subscribeToStore.bind(null, fiber, root, subscribe), [subscribe]); + fiber.flags |= 2048; + pushEffect( + 9, + updateStoreInstance.bind(null, fiber, root, nextSnapshot, getSnapshot), + void 0, + null + ); return nextSnapshot; } function pushStoreConsistencyCheck(fiber, getSnapshot, renderedSnapshot) { - fiber.flags |= 8192; + fiber.flags |= 16384; fiber = { getSnapshot: getSnapshot, value: renderedSnapshot }; getSnapshot = currentlyRenderingFiber$1.updateQueue; null === getSnapshot @@ -3724,7 +3719,7 @@ function mountState(initialState) { lastRenderedState: initialState }; hook.queue = initialState; - initialState = initialState.dispatch = dispatchAction.bind( + initialState = initialState.dispatch = dispatchSetState.bind( null, currentlyRenderingFiber$1, initialState @@ -3776,10 +3771,10 @@ function updateEffectImpl(fiberFlags, hookFlags, create, deps) { hook.memoizedState = pushEffect(1 | hookFlags, create, destroy, deps); } function mountEffect(create, deps) { - return mountEffectImpl(2098176, 8, create, deps); + return mountEffectImpl(4196352, 8, create, deps); } function updateEffect(create, deps) { - return updateEffectImpl(1024, 8, create, deps); + return updateEffectImpl(2048, 8, create, deps); } function updateInsertionEffect(create, deps) { return updateEffectImpl(4, 2, create, deps); @@ -3856,47 +3851,35 @@ function startTransition(setPending, callback) { (ReactCurrentBatchConfig$1.transition = prevTransition); } } -function dispatchAction(fiber, queue, action) { - var eventTime = requestEventTime(), - lane = requestUpdateLane(fiber), +function dispatchReducerAction(fiber, queue, action) { + var lane = requestUpdateLane(fiber); + action = { + lane: lane, + action: action, + hasEagerState: !1, + eagerState: null, + next: null + }; + isRenderPhaseUpdate(fiber) + ? enqueueRenderPhaseUpdate(queue, action) + : (enqueueUpdate$1(fiber, queue, action), + (action = requestEventTime()), + (fiber = scheduleUpdateOnFiber(fiber, lane, action)), + null !== fiber && entangleTransitionUpdate(fiber, queue, lane)); +} +function dispatchSetState(fiber, queue, action) { + var lane = requestUpdateLane(fiber), update = { lane: lane, action: action, - eagerReducer: null, + hasEagerState: !1, eagerState: null, next: null - }, - alternate = fiber.alternate; - if ( - fiber === currentlyRenderingFiber$1 || - (null !== alternate && alternate === currentlyRenderingFiber$1) - ) - (didScheduleRenderPhaseUpdateDuringThisPass = didScheduleRenderPhaseUpdate = !0), - (lane = queue.pending), - null === lane - ? (update.next = update) - : ((update.next = lane.next), (lane.next = update)), - (queue.pending = update); + }; + if (isRenderPhaseUpdate(fiber)) enqueueRenderPhaseUpdate(queue, update); else { - if ( - null !== workInProgressRoot && - 0 !== (fiber.mode & 1) && - 0 === (executionContext & 2) - ) { - var interleaved = queue.interleaved; - null === interleaved - ? ((update.next = update), - null === interleavedQueues - ? (interleavedQueues = [queue]) - : interleavedQueues.push(queue)) - : ((update.next = interleaved.next), (interleaved.next = update)); - queue.interleaved = update; - } else - (interleaved = queue.pending), - null === interleaved - ? (update.next = update) - : ((update.next = interleaved.next), (interleaved.next = update)), - (queue.pending = update); + enqueueUpdate$1(fiber, queue, update); + var alternate = fiber.alternate; if ( 0 === fiber.lanes && (null === alternate || 0 === alternate.lanes) && @@ -3905,20 +3888,57 @@ function dispatchAction(fiber, queue, action) { try { var currentState = queue.lastRenderedState, eagerState = alternate(currentState, action); - update.eagerReducer = alternate; + update.hasEagerState = !0; update.eagerState = eagerState; if (objectIs(eagerState, currentState)) return; } catch (error) { } finally { } - update = scheduleUpdateOnFiber(fiber, lane, eventTime); - 0 !== (lane & 4194240) && - null !== update && - ((fiber = queue.lanes), - (fiber &= update.pendingLanes), - (lane |= fiber), - (queue.lanes = lane), - markRootEntangled(update, lane)); + action = requestEventTime(); + fiber = scheduleUpdateOnFiber(fiber, lane, action); + null !== fiber && entangleTransitionUpdate(fiber, queue, lane); + } +} +function isRenderPhaseUpdate(fiber) { + var alternate = fiber.alternate; + return ( + fiber === currentlyRenderingFiber$1 || + (null !== alternate && alternate === currentlyRenderingFiber$1) + ); +} +function enqueueRenderPhaseUpdate(queue, update) { + didScheduleRenderPhaseUpdateDuringThisPass = didScheduleRenderPhaseUpdate = !0; + var pending = queue.pending; + null === pending + ? (update.next = update) + : ((update.next = pending.next), (pending.next = update)); + queue.pending = update; +} +function enqueueUpdate$1(fiber, queue, update) { + null !== workInProgressRoot && + 0 !== (fiber.mode & 1) && + 0 === (executionContext & 2) + ? ((fiber = queue.interleaved), + null === fiber + ? ((update.next = update), + null === interleavedQueues + ? (interleavedQueues = [queue]) + : interleavedQueues.push(queue)) + : ((update.next = fiber.next), (fiber.next = update)), + (queue.interleaved = update)) + : ((fiber = queue.pending), + null === fiber + ? (update.next = update) + : ((update.next = fiber.next), (fiber.next = update)), + (queue.pending = update)); +} +function entangleTransitionUpdate(root, queue, lane) { + if (0 !== (lane & 4194240)) { + var queueLanes = queue.lanes; + queueLanes &= root.pendingLanes; + lane |= queueLanes; + queue.lanes = lane; + markRootEntangled(root, lane); } } var ContextOnlyDispatcher = { @@ -3987,7 +4007,7 @@ var ContextOnlyDispatcher = { lastRenderedState: initialArg }; hook.queue = reducer; - reducer = reducer.dispatch = dispatchAction.bind( + reducer = reducer.dispatch = dispatchReducerAction.bind( null, currentlyRenderingFiber$1, reducer @@ -4097,7 +4117,7 @@ var ContextOnlyDispatcher = { (null !== workInProgressHook && workInProgressHook.memoizedState.tag & 1) ) { - fiber.flags |= 1024; + fiber.flags |= 2048; pushEffect( 9, updateStoreInstance.bind( @@ -4340,14 +4360,14 @@ function cutOffTailIfNeeded(renderState, hasRenderedATailFallback) { break; case "collapsed": lastTailNode = renderState.tail; - for (var lastTailNode$40 = null; null !== lastTailNode; ) - null !== lastTailNode.alternate && (lastTailNode$40 = lastTailNode), + for (var lastTailNode$37 = null; null !== lastTailNode; ) + null !== lastTailNode.alternate && (lastTailNode$37 = lastTailNode), (lastTailNode = lastTailNode.sibling); - null === lastTailNode$40 + null === lastTailNode$37 ? hasRenderedATailFallback || null === renderState.tail ? (renderState.tail = null) : (renderState.tail.sibling = null) - : (lastTailNode$40.sibling = null); + : (lastTailNode$37.sibling = null); } } function bubbleProperties(completedWork) { @@ -4359,53 +4379,53 @@ function bubbleProperties(completedWork) { if (didBailout) if (0 !== (completedWork.mode & 2)) { for ( - var treeBaseDuration$42 = completedWork.selfBaseDuration, - child$43 = completedWork.child; - null !== child$43; + var treeBaseDuration$39 = completedWork.selfBaseDuration, + child$40 = completedWork.child; + null !== child$40; ) - (newChildLanes |= child$43.lanes | child$43.childLanes), - (subtreeFlags |= child$43.subtreeFlags & 3670016), - (subtreeFlags |= child$43.flags & 3670016), - (treeBaseDuration$42 += child$43.treeBaseDuration), - (child$43 = child$43.sibling); - completedWork.treeBaseDuration = treeBaseDuration$42; + (newChildLanes |= child$40.lanes | child$40.childLanes), + (subtreeFlags |= child$40.subtreeFlags & 7340032), + (subtreeFlags |= child$40.flags & 7340032), + (treeBaseDuration$39 += child$40.treeBaseDuration), + (child$40 = child$40.sibling); + completedWork.treeBaseDuration = treeBaseDuration$39; } else for ( - treeBaseDuration$42 = completedWork.child; - null !== treeBaseDuration$42; + treeBaseDuration$39 = completedWork.child; + null !== treeBaseDuration$39; ) (newChildLanes |= - treeBaseDuration$42.lanes | treeBaseDuration$42.childLanes), - (subtreeFlags |= treeBaseDuration$42.subtreeFlags & 3670016), - (subtreeFlags |= treeBaseDuration$42.flags & 3670016), - (treeBaseDuration$42.return = completedWork), - (treeBaseDuration$42 = treeBaseDuration$42.sibling); + treeBaseDuration$39.lanes | treeBaseDuration$39.childLanes), + (subtreeFlags |= treeBaseDuration$39.subtreeFlags & 7340032), + (subtreeFlags |= treeBaseDuration$39.flags & 7340032), + (treeBaseDuration$39.return = completedWork), + (treeBaseDuration$39 = treeBaseDuration$39.sibling); else if (0 !== (completedWork.mode & 2)) { - treeBaseDuration$42 = completedWork.actualDuration; - child$43 = completedWork.selfBaseDuration; + treeBaseDuration$39 = completedWork.actualDuration; + child$40 = completedWork.selfBaseDuration; for (var child = completedWork.child; null !== child; ) (newChildLanes |= child.lanes | child.childLanes), (subtreeFlags |= child.subtreeFlags), (subtreeFlags |= child.flags), - (treeBaseDuration$42 += child.actualDuration), - (child$43 += child.treeBaseDuration), + (treeBaseDuration$39 += child.actualDuration), + (child$40 += child.treeBaseDuration), (child = child.sibling); - completedWork.actualDuration = treeBaseDuration$42; - completedWork.treeBaseDuration = child$43; + completedWork.actualDuration = treeBaseDuration$39; + completedWork.treeBaseDuration = child$40; } else for ( - treeBaseDuration$42 = completedWork.child; - null !== treeBaseDuration$42; + treeBaseDuration$39 = completedWork.child; + null !== treeBaseDuration$39; ) (newChildLanes |= - treeBaseDuration$42.lanes | treeBaseDuration$42.childLanes), - (subtreeFlags |= treeBaseDuration$42.subtreeFlags), - (subtreeFlags |= treeBaseDuration$42.flags), - (treeBaseDuration$42.return = completedWork), - (treeBaseDuration$42 = treeBaseDuration$42.sibling); + treeBaseDuration$39.lanes | treeBaseDuration$39.childLanes), + (subtreeFlags |= treeBaseDuration$39.subtreeFlags), + (subtreeFlags |= treeBaseDuration$39.flags), + (treeBaseDuration$39.return = completedWork), + (treeBaseDuration$39 = treeBaseDuration$39.sibling); completedWork.subtreeFlags |= subtreeFlags; completedWork.childLanes = newChildLanes; return didBailout; @@ -4441,8 +4461,8 @@ function completeWork(current, workInProgress, renderLanes) { ((newProps.context = newProps.pendingContext), (newProps.pendingContext = null)), (null !== current && null !== current.child) || - newProps.hydrate || - (workInProgress.flags |= 512), + newProps.isDehydrated || + (workInProgress.flags |= 1024), updateHostContainer(current, workInProgress), bubbleProperties(workInProgress), null @@ -4459,7 +4479,7 @@ function completeWork(current, workInProgress, renderLanes) { newProps, renderLanes ), - current.ref !== workInProgress.ref && (workInProgress.flags |= 256); + current.ref !== workInProgress.ref && (workInProgress.flags |= 512); else { if (!newProps) { if (null === workInProgress.stateNode) @@ -4494,7 +4514,7 @@ function completeWork(current, workInProgress, renderLanes) { appendAllChildren(renderLanes, workInProgress, !1, !1); workInProgress.stateNode = renderLanes; finalizeInitialChildren(renderLanes) && (workInProgress.flags |= 4); - null !== workInProgress.ref && (workInProgress.flags |= 256); + null !== workInProgress.ref && (workInProgress.flags |= 512); } bubbleProperties(workInProgress); return null; @@ -4544,7 +4564,7 @@ function completeWork(current, workInProgress, renderLanes) { if ( newProps && !renderLanes && - ((workInProgress.child.flags |= 4096), 0 !== (workInProgress.mode & 1)) + ((workInProgress.child.flags |= 8192), 0 !== (workInProgress.mode & 1)) ) if ( (null === current && @@ -4556,7 +4576,8 @@ function completeWork(current, workInProgress, renderLanes) { else { if ( 0 === workInProgressRootExitStatus || - 3 === workInProgressRootExitStatus + 3 === workInProgressRootExitStatus || + 2 === workInProgressRootExitStatus ) workInProgressRootExitStatus = 4; null === workInProgressRoot || @@ -4621,7 +4642,7 @@ function completeWork(current, workInProgress, renderLanes) { for (newProps = workInProgress.child; null !== newProps; ) (renderLanes = newProps), (updatePayload = current), - (renderLanes.flags &= 3670018), + (renderLanes.flags &= 7340034), (type = renderLanes.alternate), null === type ? ((renderLanes.childLanes = 0), @@ -4727,14 +4748,14 @@ function completeWork(current, workInProgress, renderLanes) { (null !== current.memoizedState) !== renderLanes && "unstable-defer-without-hiding" !== newProps.mode && 23 !== workInProgress.tag && - (workInProgress.flags |= 4096), + (workInProgress.flags |= 8192), renderLanes && 0 !== (workInProgress.mode & 1) ? 0 !== (subtreeRenderLanes & 1073741824) && (bubbleProperties(workInProgress), 23 !== workInProgress.tag && workInProgress.subtreeFlags & 6 && "unstable-defer-without-hiding" !== newProps.mode && - (workInProgress.flags |= 4096)) + (workInProgress.flags |= 8192)) : bubbleProperties(workInProgress), null ); @@ -4779,7 +4800,7 @@ function updateForwardRef( if (null !== current && !didReceiveUpdate) return ( (workInProgress.updateQueue = current.updateQueue), - (workInProgress.flags &= -1029), + (workInProgress.flags &= -2053), (current.lanes &= ~renderLanes), bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes) ); @@ -4853,7 +4874,7 @@ function updateSimpleMemoComponent( current.ref === workInProgress.ref ) if (((didReceiveUpdate = !1), 0 !== (current.lanes & renderLanes))) - 0 !== (current.flags & 65536) && (didReceiveUpdate = !0); + 0 !== (current.flags & 131072) && (didReceiveUpdate = !0); else return ( (workInProgress.lanes = current.lanes), @@ -4917,7 +4938,7 @@ function markRef$1(current, workInProgress) { (null === current && null !== ref) || (null !== current && current.ref !== ref) ) - workInProgress.flags |= 256; + workInProgress.flags |= 512; } function updateFunctionComponent( current, @@ -4942,7 +4963,7 @@ function updateFunctionComponent( if (null !== current && !didReceiveUpdate) return ( (workInProgress.updateQueue = current.updateQueue), - (workInProgress.flags &= -1029), + (workInProgress.flags &= -2053), (current.lanes &= ~renderLanes), bailoutOnAlreadyFinishedWork(current, workInProgress, renderLanes) ); @@ -5118,7 +5139,7 @@ function updateClassComponent( "function" === typeof instance.componentDidUpdate && (workInProgress.flags |= 4), "function" === typeof instance.getSnapshotBeforeUpdate && - (workInProgress.flags |= 512)) + (workInProgress.flags |= 1024)) : ("function" !== typeof instance.componentDidUpdate || (oldProps === current.memoizedProps && oldState === current.memoizedState) || @@ -5126,7 +5147,7 @@ function updateClassComponent( "function" !== typeof instance.getSnapshotBeforeUpdate || (oldProps === current.memoizedProps && oldState === current.memoizedState) || - (workInProgress.flags |= 512), + (workInProgress.flags |= 1024), (workInProgress.memoizedProps = nextProps), (workInProgress.memoizedState = newState)), (instance.props = nextProps), @@ -5140,7 +5161,7 @@ function updateClassComponent( "function" !== typeof instance.getSnapshotBeforeUpdate || (oldProps === current.memoizedProps && oldState === current.memoizedState) || - (workInProgress.flags |= 512), + (workInProgress.flags |= 1024), (nextProps = !1)); } return finishClassComponent( @@ -5411,7 +5432,7 @@ function updateSuspenseFallbackChildren( (primaryChildren.treeBaseDuration = current.treeBaseDuration)), (workInProgress.deletions = null)) : ((primaryChildren = createWorkInProgress(current, primaryChildProps)), - (primaryChildren.subtreeFlags = current.subtreeFlags & 3670016)); + (primaryChildren.subtreeFlags = current.subtreeFlags & 7340032)); null !== currentFallbackChildFragment ? (fallbackChildren = createWorkInProgress( currentFallbackChildFragment, @@ -5647,8 +5668,8 @@ function unwindWork(workInProgress) { case 1: isContextProvider(workInProgress.type) && popContext(); var flags = workInProgress.flags; - return flags & 32768 - ? ((workInProgress.flags = (flags & -32769) | 128), + return flags & 65536 + ? ((workInProgress.flags = (flags & -65537) | 128), 0 !== (workInProgress.mode & 2) && transferActualDuration(workInProgress), workInProgress) @@ -5663,7 +5684,7 @@ function unwindWork(workInProgress) { throw Error( "The root failed to unmount after an error. This is likely a bug in React. Please file an issue." ); - workInProgress.flags = (flags & -32769) | 128; + workInProgress.flags = (flags & -65537) | 128; return workInProgress; case 5: return popHostContext(workInProgress), null; @@ -5671,8 +5692,8 @@ function unwindWork(workInProgress) { return ( pop(suspenseStackCursor), (flags = workInProgress.flags), - flags & 32768 - ? ((workInProgress.flags = (flags & -32769) | 128), + flags & 65536 + ? ((workInProgress.flags = (flags & -65537) | 128), 0 !== (workInProgress.mode & 2) && transferActualDuration(workInProgress), workInProgress) @@ -5727,7 +5748,7 @@ function commitBeforeMutationEffects(root, firstChild) { if ( ((root = nextEffect), (firstChild = root.child), - 0 !== (root.subtreeFlags & 516) && null !== firstChild) + 0 !== (root.subtreeFlags & 1028) && null !== firstChild) ) (firstChild.return = root), (nextEffect = firstChild); else @@ -5735,7 +5756,7 @@ function commitBeforeMutationEffects(root, firstChild) { root = nextEffect; try { var current = root.alternate; - if (0 !== (root.flags & 512)) + if (0 !== (root.flags & 1024)) switch (root.tag) { case 0: case 11: @@ -5809,8 +5830,8 @@ function commitHookEffectListMount(tag, finishedWork) { var effect = (finishedWork = finishedWork.next); do { if ((effect.tag & tag) === tag) { - var create$89 = effect.create; - effect.destroy = create$89(); + var create$86 = effect.create; + effect.destroy = create$86(); } effect = effect.next; } while (effect !== finishedWork); @@ -6267,14 +6288,14 @@ function commitMutationEffects(root, firstChild, committedLanes) { } } committedLanes = firstChild.child; - if (0 !== (firstChild.subtreeFlags & 6454) && null !== committedLanes) + if (0 !== (firstChild.subtreeFlags & 12854) && null !== committedLanes) (committedLanes.return = firstChild), (nextEffect = committedLanes); else for (; null !== nextEffect; ) { firstChild = nextEffect; try { var flags = firstChild.flags; - if (flags & 256) { + if (flags & 512) { var current = firstChild.alternate; if (null !== current) { committedLanes = current; @@ -6291,12 +6312,12 @@ function commitMutationEffects(root, firstChild, committedLanes) { else currentRef.current = null; } } - if (flags & 4096) + if (flags & 8192) switch (firstChild.tag) { case 13: if (null !== firstChild.memoizedState) { - var current$96 = firstChild.alternate; - if (null === current$96 || null === current$96.memoizedState) + var current$93 = firstChild.alternate; + if (null === current$93 || null === current$93.memoizedState) globalMostRecentFallbackTime = now(); } break; @@ -6372,7 +6393,7 @@ function commitMutationEffects(root, firstChild, committedLanes) { } } } - switch (flags & 2054) { + switch (flags & 4102) { case 2: commitPlacement(firstChild); firstChild.flags &= -3; @@ -6382,11 +6403,11 @@ function commitMutationEffects(root, firstChild, committedLanes) { firstChild.flags &= -3; commitWork(firstChild.alternate, firstChild); break; - case 2048: - firstChild.flags &= -2049; + case 4096: + firstChild.flags &= -4097; break; - case 2052: - firstChild.flags &= -2049; + case 4100: + firstChild.flags &= -4097; commitWork(firstChild.alternate, firstChild); break; case 4: @@ -6413,16 +6434,16 @@ function commitLayoutEffects(finishedWork, root, committedLanes) { if ( ((root = nextEffect), (committedLanes = root.child), - 0 !== (root.subtreeFlags & 4420) && null !== committedLanes) + 0 !== (root.subtreeFlags & 8772) && null !== committedLanes) ) (committedLanes.return = root), (nextEffect = committedLanes); else for (root = finishedWork; null !== nextEffect; ) { committedLanes = nextEffect; - if (0 !== (committedLanes.flags & 4420)) { + if (0 !== (committedLanes.flags & 8772)) { var current = committedLanes.alternate; try { - if (0 !== (committedLanes.flags & 4420)) + if (0 !== (committedLanes.flags & 8772)) switch (committedLanes.tag) { case 0: case 11: @@ -6480,21 +6501,21 @@ function commitLayoutEffects(finishedWork, root, committedLanes) { commitUpdateQueue(committedLanes, updateQueue, instance); break; case 3: - var updateQueue$91 = committedLanes.updateQueue; - if (null !== updateQueue$91) { - var instance$92 = null; + var updateQueue$88 = committedLanes.updateQueue; + if (null !== updateQueue$88) { + var instance$89 = null; if (null !== committedLanes.child) switch (committedLanes.child.tag) { case 5: - instance$92 = committedLanes.child.stateNode; + instance$89 = committedLanes.child.stateNode; break; case 1: - instance$92 = committedLanes.child.stateNode; + instance$89 = committedLanes.child.stateNode; } commitUpdateQueue( committedLanes, - updateQueue$91, - instance$92 + updateQueue$88, + instance$89 ); } break; @@ -6509,7 +6530,7 @@ function commitLayoutEffects(finishedWork, root, committedLanes) { onCommit = _finishedWork$memoize2.onCommit, onRender = _finishedWork$memoize2.onRender, effectDuration = committedLanes.stateNode.effectDuration; - instance$92 = commitTime; + instance$89 = commitTime; current = null === current ? "mount" : "update"; currentUpdateIsNested && (current = "nested-update"); "function" === typeof onRender && @@ -6519,14 +6540,14 @@ function commitLayoutEffects(finishedWork, root, committedLanes) { committedLanes.actualDuration, committedLanes.treeBaseDuration, committedLanes.actualStartTime, - instance$92 + instance$89 ); "function" === typeof onCommit && onCommit( committedLanes.memoizedProps.id, current, effectDuration, - instance$92 + instance$89 ); enqueuePendingPassiveProfilerEffect(committedLanes); var parentFiber = committedLanes.return; @@ -6555,28 +6576,28 @@ function commitLayoutEffects(finishedWork, root, committedLanes) { "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 (committedLanes.flags & 256) { - instance$92 = void 0; + if (committedLanes.flags & 512) { + instance$89 = void 0; current = committedLanes; var ref = current.ref; if (null !== ref) { var instance$jscomp$0 = current.stateNode; switch (current.tag) { case 5: - instance$92 = instance$jscomp$0; + instance$89 = instance$jscomp$0; break; default: - instance$92 = instance$jscomp$0; + instance$89 = instance$jscomp$0; } if ("function" === typeof ref) if (current.mode & 2) try { - startLayoutEffectTimer(), ref(instance$92); + startLayoutEffectTimer(), ref(instance$89); } finally { recordLayoutEffectDuration(current); } - else ref(instance$92); - else ref.current = instance$92; + else ref(instance$89); + else ref.current = instance$89; } } } catch (error) { @@ -6591,10 +6612,10 @@ function commitLayoutEffects(finishedWork, root, committedLanes) { nextEffect = null; break; } - instance$92 = committedLanes.sibling; - if (null !== instance$92) { - instance$92.return = committedLanes.return; - nextEffect = instance$92; + instance$89 = committedLanes.sibling; + if (null !== instance$89) { + instance$89.return = committedLanes.return; + nextEffect = instance$89; break; } nextEffect = committedLanes.return; @@ -6927,14 +6948,14 @@ function performConcurrentWorkOnRoot(root, didTimeout) { function recoverFromConcurrentError(root, errorRetryLanes) { var prevExecutionContext = executionContext; executionContext |= 8; - root.hydrate && (root.hydrate = !1); + root.isDehydrated && (root.isDehydrated = !1); root = renderRootSync(root, errorRetryLanes); executionContext = prevExecutionContext; return root; } function isRenderConsistentWithExternalStores(finishedWork) { for (var node = finishedWork; ; ) { - if (node.flags & 8192) { + if (node.flags & 16384) { var updateQueue = node.updateQueue; if ( null !== updateQueue && @@ -6952,7 +6973,7 @@ function isRenderConsistentWithExternalStores(finishedWork) { } } updateQueue = node.child; - if (node.subtreeFlags & 8192 && null !== updateQueue) + if (node.subtreeFlags & 16384 && null !== updateQueue) (updateQueue.return = node), (node = updateQueue); else { if (node === finishedWork) break; @@ -6990,7 +7011,7 @@ function performSyncWorkOnRoot(root) { if (0 !== root.tag && 2 === exitStatus) { var prevExecutionContext = executionContext; executionContext |= 8; - root.hydrate && (root.hydrate = !1); + root.isDehydrated && (root.isDehydrated = !1); var errorRetryLanes = getLanesToRetrySynchronouslyOnError(root); 0 !== errorRetryLanes && ((lanes = errorRetryLanes), (exitStatus = renderRootSync(root, lanes))); @@ -7117,7 +7138,7 @@ function handleError(root$jscomp$0, thrownValue) { sourceFiber = erroredWork, value = thrownValue; thrownValue = workInProgressRootRenderLanes; - sourceFiber.flags |= 16384; + sourceFiber.flags |= 32768; isDevToolsPresent && restorePendingUpdaters(root, thrownValue); if ( null !== value && @@ -7125,64 +7146,76 @@ function handleError(root$jscomp$0, thrownValue) { "function" === typeof value.then ) { var wakeable = value, - tag = sourceFiber.tag; + sourceFiber$jscomp$0 = sourceFiber, + tag = sourceFiber$jscomp$0.tag; if ( - 0 === (sourceFiber.mode & 1) && + 0 === (sourceFiber$jscomp$0.mode & 1) && (0 === tag || 11 === tag || 15 === tag) ) { - var currentSource = sourceFiber.alternate; + var currentSource = sourceFiber$jscomp$0.alternate; currentSource - ? ((sourceFiber.updateQueue = currentSource.updateQueue), - (sourceFiber.memoizedState = currentSource.memoizedState), - (sourceFiber.lanes = currentSource.lanes)) - : ((sourceFiber.updateQueue = null), - (sourceFiber.memoizedState = null)); + ? ((sourceFiber$jscomp$0.updateQueue = currentSource.updateQueue), + (sourceFiber$jscomp$0.memoizedState = + currentSource.memoizedState), + (sourceFiber$jscomp$0.lanes = currentSource.lanes)) + : ((sourceFiber$jscomp$0.updateQueue = null), + (sourceFiber$jscomp$0.memoizedState = null)); } - var hasInvisibleParentBoundary = - 0 !== (suspenseStackCursor.current & 1), - workInProgress$34 = returnFiber; - do { - var JSCompiler_temp; - if ((JSCompiler_temp = 13 === workInProgress$34.tag)) { - var nextState = workInProgress$34.memoizedState; - JSCompiler_temp = - null !== nextState - ? null !== nextState.dehydrated + b: { + sourceFiber$jscomp$0 = returnFiber; + var sourceFiber$jscomp$1 = sourceFiber, + rootRenderLanes = thrownValue, + hasInvisibleParentBoundary = + 0 !== (suspenseStackCursor.current & 1), + node = sourceFiber$jscomp$0; + do { + var JSCompiler_temp; + if ((JSCompiler_temp = 13 === node.tag)) { + var nextState = node.memoizedState; + JSCompiler_temp = + null !== nextState + ? null !== nextState.dehydrated + ? !0 + : !1 + : !0 !== node.memoizedProps.unstable_avoidThisFallback ? !0 - : !1 - : !0 !== - workInProgress$34.memoizedProps.unstable_avoidThisFallback - ? !0 - : hasInvisibleParentBoundary - ? !1 - : !0; - } - if (JSCompiler_temp) { - var wakeables = workInProgress$34.updateQueue; - if (null === wakeables) { - var updateQueue = new Set(); - updateQueue.add(wakeable); - workInProgress$34.updateQueue = updateQueue; - } else wakeables.add(wakeable); - if ( - 0 === (workInProgress$34.mode & 1) && - workInProgress$34 !== returnFiber - ) { - workInProgress$34.flags |= 128; - sourceFiber.flags |= 65536; - sourceFiber.flags &= -26437; - if (1 === sourceFiber.tag) - if (null === sourceFiber.alternate) sourceFiber.tag = 17; - else { - var update = createUpdate(-1, 1); - update.tag = 2; - enqueueUpdate(sourceFiber, update); - } - sourceFiber.lanes |= 1; - break a; + : hasInvisibleParentBoundary + ? !1 + : !0; } - value = void 0; - sourceFiber = thrownValue; + if (JSCompiler_temp) { + if (0 === (node.mode & 1)) { + if (node === sourceFiber$jscomp$0) node.flags |= 65536; + else { + node.flags |= 128; + sourceFiber$jscomp$1.flags |= 131072; + sourceFiber$jscomp$1.flags &= -52805; + if (1 === sourceFiber$jscomp$1.tag) + if (null === sourceFiber$jscomp$1.alternate) + sourceFiber$jscomp$1.tag = 17; + else { + var update = createUpdate(-1, 1); + update.tag = 2; + enqueueUpdate(sourceFiber$jscomp$1, update); + } + sourceFiber$jscomp$1.lanes |= 1; + } + var suspenseBoundary = node; + break b; + } + node.flags |= 65536; + node.lanes = rootRenderLanes; + suspenseBoundary = node; + break b; + } + node = node.return; + } while (null !== node); + suspenseBoundary = null; + } + if (null !== suspenseBoundary) { + value = void 0; + sourceFiber = suspenseBoundary; + if (sourceFiber.mode & 1) { var pingCache = root.pingCache; null === pingCache ? ((pingCache = root.pingCache = new PossiblyWeakMap()), @@ -7191,72 +7224,75 @@ function handleError(root$jscomp$0, thrownValue) { : ((value = pingCache.get(wakeable)), void 0 === value && ((value = new Set()), pingCache.set(wakeable, value))); - if (!value.has(sourceFiber)) { - value.add(sourceFiber); + if (!value.has(thrownValue)) { + value.add(thrownValue); var ping = pingSuspendedRoot.bind( null, root, wakeable, - sourceFiber + thrownValue ); - isDevToolsPresent && restorePendingUpdaters(root, sourceFiber); + isDevToolsPresent && restorePendingUpdaters(root, thrownValue); wakeable.then(ping, ping); } - workInProgress$34.flags |= 32768; - workInProgress$34.lanes = thrownValue; - break a; } - workInProgress$34 = workInProgress$34.return; - } while (null !== workInProgress$34); - value = Error( - (getComponentNameFromFiber(sourceFiber) || "A React component") + - " suspended while rendering, but no fallback UI was specified.\n\nAdd a component higher in the tree to provide a loading indicator or placeholder to display." - ); + var wakeables = sourceFiber.updateQueue; + if (null === wakeables) { + var updateQueue = new Set(); + updateQueue.add(wakeable); + sourceFiber.updateQueue = updateQueue; + } else wakeables.add(wakeable); + break a; + } else + value = Error( + (getComponentNameFromFiber(sourceFiber) || "A React component") + + " suspended while rendering, but no fallback UI was specified.\n\nAdd a component higher in the tree to provide a loading indicator or placeholder to display." + ); } - 5 !== workInProgressRootExitStatus && + 4 !== workInProgressRootExitStatus && (workInProgressRootExitStatus = 2); value = createCapturedValue(value, sourceFiber); - workInProgress$34 = returnFiber; + root = returnFiber; do { - switch (workInProgress$34.tag) { + switch (root.tag) { case 3: - root = value; - workInProgress$34.flags |= 32768; + wakeable = value; + root.flags |= 65536; thrownValue &= -thrownValue; - workInProgress$34.lanes |= thrownValue; - var update$35 = createRootErrorUpdate( - workInProgress$34, + root.lanes |= thrownValue; + var update$jscomp$0 = createRootErrorUpdate( root, + wakeable, thrownValue ); - enqueueCapturedUpdate(workInProgress$34, update$35); + enqueueCapturedUpdate(root, update$jscomp$0); break a; case 1: - root = value; - var ctor = workInProgress$34.type, - instance = workInProgress$34.stateNode; + wakeable = value; + var ctor = root.type, + instance = root.stateNode; if ( - 0 === (workInProgress$34.flags & 128) && + 0 === (root.flags & 128) && ("function" === typeof ctor.getDerivedStateFromError || (null !== instance && "function" === typeof instance.componentDidCatch && (null === legacyErrorBoundariesThatAlreadyFailed || !legacyErrorBoundariesThatAlreadyFailed.has(instance)))) ) { - workInProgress$34.flags |= 32768; + root.flags |= 65536; thrownValue &= -thrownValue; - workInProgress$34.lanes |= thrownValue; - var update$38 = createClassErrorUpdate( - workInProgress$34, + root.lanes |= thrownValue; + var update$35 = createClassErrorUpdate( root, + wakeable, thrownValue ); - enqueueCapturedUpdate(workInProgress$34, update$38); + enqueueCapturedUpdate(root, update$35); break a; } } - workInProgress$34 = workInProgress$34.return; - } while (null !== workInProgress$34); + root = root.return; + } while (null !== root); } completeUnitOfWork(erroredWork); } catch (yetAnotherThrownValue) { @@ -7333,7 +7369,7 @@ function completeUnitOfWork(unitOfWork) { do { var current = completedWork.alternate; unitOfWork = completedWork.return; - if (0 === (completedWork.flags & 16384)) { + if (0 === (completedWork.flags & 32768)) { if (0 === (completedWork.mode & 2)) current = completeWork(current, completedWork, subtreeRenderLanes); else { @@ -7350,7 +7386,7 @@ function completeUnitOfWork(unitOfWork) { } else { current = unwindWork(completedWork); if (null !== current) { - current.flags &= 16383; + current.flags &= 32767; workInProgress = current; return; } @@ -7362,7 +7398,7 @@ function completeUnitOfWork(unitOfWork) { completedWork.actualDuration = current; } null !== unitOfWork && - ((unitOfWork.flags |= 16384), + ((unitOfWork.flags |= 32768), (unitOfWork.subtreeFlags = 0), (unitOfWork.deletions = null)); } @@ -7409,16 +7445,16 @@ function commitRootImpl(root, renderPriorityLevel) { root === workInProgressRoot && ((workInProgress = workInProgressRoot = null), (workInProgressRootRenderLanes = 0)); - (0 === (finishedWork.subtreeFlags & 1040) && - 0 === (finishedWork.flags & 1040)) || + (0 === (finishedWork.subtreeFlags & 2064) && + 0 === (finishedWork.flags & 2064)) || rootDoesHavePassiveEffects || ((rootDoesHavePassiveEffects = !0), scheduleCallback$1(NormalPriority, function() { flushPassiveEffects(); return null; })); - remainingLanes = 0 !== (finishedWork.flags & 8054); - if (0 !== (finishedWork.subtreeFlags & 8054) || remainingLanes) { + remainingLanes = 0 !== (finishedWork.flags & 15990); + if (0 !== (finishedWork.subtreeFlags & 15990) || remainingLanes) { remainingLanes = ReactCurrentBatchConfig$2.transition; ReactCurrentBatchConfig$2.transition = 0; var previousPriority = currentUpdatePriority; @@ -7540,12 +7576,12 @@ function flushPassiveEffects() { nextEffect = fiber; } } - if (0 !== (fiber.subtreeFlags & 1040) && null !== child) + if (0 !== (fiber.subtreeFlags & 2064) && null !== child) (child.return = fiber), (nextEffect = child); else b: for (; null !== nextEffect; ) { fiber = nextEffect; - if (0 !== (fiber.flags & 1024)) + if (0 !== (fiber.flags & 2048)) switch (((i = fiber), i.tag)) { case 0: case 11: @@ -7569,12 +7605,12 @@ function flushPassiveEffects() { for (nextEffect = finishedWork; null !== nextEffect; ) { child = nextEffect; var firstChild = child.child; - if (0 !== (child.subtreeFlags & 1040) && null !== firstChild) + if (0 !== (child.subtreeFlags & 2064) && null !== firstChild) (firstChild.return = child), (nextEffect = firstChild); else b: for (child = finishedWork; null !== nextEffect; ) { deletions = nextEffect; - if (0 !== (deletions.flags & 1024)) + if (0 !== (deletions.flags & 2048)) try { switch (((fiberToDelete = deletions), fiberToDelete.tag)) { case 0: @@ -7782,7 +7818,7 @@ beginWork$1 = function(current, workInProgress, renderLanes) { renderLanes ) ); - didReceiveUpdate = 0 !== (current.flags & 65536) ? !0 : !1; + didReceiveUpdate = 0 !== (current.flags & 131072) ? !0 : !1; } else didReceiveUpdate = !1; workInProgress.lanes = 0; @@ -8263,7 +8299,7 @@ function createWorkInProgress(current, pendingProps) { (workInProgress.deletions = null), (workInProgress.actualDuration = 0), (workInProgress.actualStartTime = -1)); - workInProgress.flags = current.flags & 3670016; + workInProgress.flags = current.flags & 7340032; workInProgress.childLanes = current.childLanes; workInProgress.lanes = current.lanes; workInProgress.child = current.child; @@ -8359,8 +8395,7 @@ function createFiberFromTypeAndProps( } throw Error( "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) + - "." + ((null == type ? type : typeof type) + ".") ); } key = createFiber(fiberTag, pendingProps, key, mode); @@ -8406,7 +8441,7 @@ function FiberRootNode(containerInfo, tag, hydrate) { this.finishedWork = this.pingCache = this.current = this.pendingChildren = null; this.timeoutHandle = -1; this.pendingContext = this.context = null; - this.hydrate = hydrate; + this.isDehydrated = hydrate; this.callbackNode = null; this.callbackPriority = 0; this.eventTimes = createLaneMap(0); @@ -8434,9 +8469,9 @@ function findHostInstance(component) { if (void 0 === fiber) { if ("function" === typeof component.render) throw Error("Unable to find node on an unmounted component."); + component = Object.keys(component).join(","); throw Error( - "Argument appears to not be a ReactComponent. Keys: " + - Object.keys(component) + "Argument appears to not be a ReactComponent. Keys: " + component ); } component = findCurrentHostFiber(fiber); @@ -8627,10 +8662,10 @@ batchedUpdatesImpl = function(fn, a) { } }; var roots = new Map(), - devToolsConfig$jscomp$inline_1016 = { + devToolsConfig$jscomp$inline_1006 = { findFiberByHostInstance: getInstanceFromTag, bundleType: 0, - version: "18.0.0-e8feb11b6-20210915", + version: "18.0.0-afcb9cdc9-20211008", rendererPackageName: "react-native-renderer", rendererConfig: { getInspectorDataForViewTag: function() { @@ -8645,11 +8680,11 @@ var roots = new Map(), }.bind(null, findNodeHandle) } }; -var internals$jscomp$inline_1289 = { - bundleType: devToolsConfig$jscomp$inline_1016.bundleType, - version: devToolsConfig$jscomp$inline_1016.version, - rendererPackageName: devToolsConfig$jscomp$inline_1016.rendererPackageName, - rendererConfig: devToolsConfig$jscomp$inline_1016.rendererConfig, +var internals$jscomp$inline_1290 = { + bundleType: devToolsConfig$jscomp$inline_1006.bundleType, + version: devToolsConfig$jscomp$inline_1006.version, + rendererPackageName: devToolsConfig$jscomp$inline_1006.rendererPackageName, + rendererConfig: devToolsConfig$jscomp$inline_1006.rendererConfig, overrideHookState: null, overrideHookStateDeletePath: null, overrideHookStateRenamePath: null, @@ -8665,27 +8700,26 @@ var internals$jscomp$inline_1289 = { return null === fiber ? null : fiber.stateNode; }, findFiberByHostInstance: - devToolsConfig$jscomp$inline_1016.findFiberByHostInstance || + devToolsConfig$jscomp$inline_1006.findFiberByHostInstance || emptyFindFiberByHostInstance, findHostInstancesForRefresh: null, scheduleRefresh: null, scheduleRoot: null, setRefreshHandler: null, getCurrentFiber: null, - getIsStrictMode: null, - reconcilerVersion: "18.0.0-e8feb11b6-20210915" + reconcilerVersion: "18.0.0-afcb9cdc9-20211008" }; if ("undefined" !== typeof __REACT_DEVTOOLS_GLOBAL_HOOK__) { - var hook$jscomp$inline_1290 = __REACT_DEVTOOLS_GLOBAL_HOOK__; + var hook$jscomp$inline_1291 = __REACT_DEVTOOLS_GLOBAL_HOOK__; if ( - !hook$jscomp$inline_1290.isDisabled && - hook$jscomp$inline_1290.supportsFiber + !hook$jscomp$inline_1291.isDisabled && + hook$jscomp$inline_1291.supportsFiber ) try { - (rendererID = hook$jscomp$inline_1290.inject( - internals$jscomp$inline_1289 + (rendererID = hook$jscomp$inline_1291.inject( + internals$jscomp$inline_1290 )), - (injectedHook = hook$jscomp$inline_1290); + (injectedHook = hook$jscomp$inline_1291); } catch (err) {} } exports.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED = { From 24ac66984c2d0c55ae09fb2df0f1e88a42339f21 Mon Sep 17 00:00:00 2001 From: Lulu Wu Date: Tue, 12 Oct 2021 14:14:23 -0700 Subject: [PATCH 38/62] Add more logs Summary: Added more logs to understand what's the root cause for https://fburl.com/logview/kgknonri ```java.lang.IllegalStateException: Message queue threads already initialized at X.5y2.A0I(:64) at com.facebook.venice.ReactInstance.(:112) at X.PrB.EgB(:33) at X.2pN.run(:4) at X.2pA.execute(:32) at X.2p6.A00(:30) at X.2p6.A08(:2) at X.PrC.EgB(:26) at X.Pr7.run(:4) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) at java.lang.Thread.run(Thread.java:919) ``` Changelog: [Android][Changed] - Add some logs Reviewed By: RSNara Differential Revision: D31584264 fbshipit-source-id: 11b8bb2c6c9af2266688e3dae95e09f0160de79a --- .../src/main/java/com/facebook/react/bridge/ReactContext.java | 1 + 1 file changed, 1 insertion(+) diff --git a/ReactAndroid/src/main/java/com/facebook/react/bridge/ReactContext.java b/ReactAndroid/src/main/java/com/facebook/react/bridge/ReactContext.java index 0f89c17dc4..dbc51207af 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/bridge/ReactContext.java +++ b/ReactAndroid/src/main/java/com/facebook/react/bridge/ReactContext.java @@ -91,6 +91,7 @@ public class ReactContext extends ContextWrapper { /** Initialize message queue threads using a ReactQueueConfiguration. */ public synchronized void initializeMessageQueueThreads(ReactQueueConfiguration queueConfig) { + FLog.w(TAG, "initializeMessageQueueThreads() is called."); if (mUiMessageQueueThread != null || mNativeModulesMessageQueueThread != null || mJSMessageQueueThread != null) { From 8581661e84232eda174c4a0ad809f6ce3107ae55 Mon Sep 17 00:00:00 2001 From: Luna Wei Date: Tue, 12 Oct 2021 17:38:07 -0700 Subject: [PATCH 39/62] Support fbt for accessibilityValue Summary: Changelog: [Internal] - Change accessibilityValue.text type to allow for Stringish type Reviewed By: yungsters Differential Revision: D31577860 fbshipit-source-id: af12505794037a68850a16ce139359e2f8a879e4 --- Libraries/Components/View/ViewAccessibility.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Libraries/Components/View/ViewAccessibility.js b/Libraries/Components/View/ViewAccessibility.js index 4debbe4da3..66ba513789 100644 --- a/Libraries/Components/View/ViewAccessibility.js +++ b/Libraries/Components/View/ViewAccessibility.js @@ -85,5 +85,5 @@ export type AccessibilityValue = $ReadOnly<{| /** * A textual description of this component's value. (will override minimum, current, and maximum if set) */ - text?: string, + text?: Stringish, |}>; From 55392f65a6addbdd8214b61d4ae286f26d63a94f Mon Sep 17 00:00:00 2001 From: Xin Chen Date: Tue, 12 Oct 2021 17:39:43 -0700 Subject: [PATCH 40/62] Fix issue with setting shadow node state data after scrolling programmatically Summary: This issue is found when investigating T101563978 with IOS platform. When animation is off, the x position measurement is off after `scrollToItem` is called. The android fix is checked in at D31492685 (https://github.com/facebook/react-native/commit/1a9e2d5d5589ce5cee92868ea5bccceb6e161eff). For IOS, the correct state data is updated only for animated cases, but not for instant scroll cases. This diff unified them. Changelog [IOS][Fixed] Fixed an edge case when scroll to item/index is called without animation, the offset position is not updated. This caused the measurement of the position to be wrong. Reviewed By: sammy-SC Differential Revision: D31564169 fbshipit-source-id: 89f47d8054afb03c2ace1d595163b160e5bb2036 --- .../ScrollView/RCTScrollViewComponentView.mm | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.mm b/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.mm index 603b76a7f6..082933ad6a 100644 --- a/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.mm +++ b/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.mm @@ -498,6 +498,11 @@ static void RCTSendPaperScrollEvent_DEPRECATED(UIScrollView *scrollView, NSInteg } - (void)scrollViewDidEndScrollingAnimation:(UIScrollView *)scrollView +{ + [self _handleFinishedScrolling:scrollView]; +} + +- (void)_handleFinishedScrolling:(UIScrollView *)scrollView { [self _forceDispatchNextScrollEvent]; [self scrollViewDidScroll:scrollView]; @@ -710,6 +715,12 @@ static void RCTSendPaperScrollEvent_DEPRECATED(UIScrollView *scrollView, NSInteg } [_scrollView setContentOffset:offset animated:animated]; + + if (!animated) { + // When not animated, the expected workflow in ``scrollViewDidEndScrollingAnimation`` after scrolling is not going + // to get triggered. We will need to manually execute here. + [self _handleFinishedScrolling:_scrollView]; + } } - (void)zoomToRect:(CGRect)rect animated:(BOOL)animated From 47901463746391ab28085d2c9d9734b9710dee58 Mon Sep 17 00:00:00 2001 From: David Vacca Date: Tue, 12 Oct 2021 18:26:21 -0700 Subject: [PATCH 41/62] Fix link in View.js Summary: https://reactnative.dev/docs/view.html doesn't work, this diff replaces the url for the new link [Changelog] [General][Fixed] - Updated documentation link in `View`. Reviewed By: yungsters Differential Revision: D31519836 fbshipit-source-id: c93feee4652caf4ef8390a047599149fc547db48 --- Libraries/Components/View/View.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Libraries/Components/View/View.js b/Libraries/Components/View/View.js index 19bcf46922..5bf6f7407d 100644 --- a/Libraries/Components/View/View.js +++ b/Libraries/Components/View/View.js @@ -21,7 +21,7 @@ export type Props = ViewProps; * supports layout with flexbox, style, some touch handling, and accessibility * controls. * - * @see https://reactnative.dev/docs/view.html + * @see https://reactnative.dev/docs/view */ const View: React.AbstractComponent< ViewProps, From 2f8e52b52a40fb7f72c45a24e60895156946c8ba Mon Sep 17 00:00:00 2001 From: Nicola Corti Date: Wed, 13 Oct 2021 05:33:08 -0700 Subject: [PATCH 42/62] Restrict mavenCentral to exclude react-native older packages Summary: This Diff is restricting the scope of `mavenCentral` to do not include react-native packages. This will make us sure we don't pickup older versions of react-native. This specifically is a problem if you're building on a nightly as the version of RN nightly is `0.0.0.xxx` which is lower than then version on maven central. More on this here https://github.com/facebook/react-native/pull/32326#issuecomment-933368880 Changelog: [Internal] [Changed] - Restrict mavenCentral to exclude react-native older packages Reviewed By: ShikaSD Differential Revision: D31571803 fbshipit-source-id: d7ce7e82825cbebda2e4e534565d7ab15dba2624 --- build.gradle.kts | 8 +++++++- template/android/build.gradle | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index 4318c6d00e..dbe8e69b2d 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -31,7 +31,13 @@ allprojects { url = uri("$rootDir/node_modules/detox/Detox-android") } google() - mavenCentral() + mavenCentral { + // We don't want to fetch react-native from Maven Central as there are + // older versions over there. + content { + excludeGroup("com.facebook.react") + } + } } // used to override ndk path/version from env variables on CI diff --git a/template/android/build.gradle b/template/android/build.gradle index db796539ce..3be1031fb2 100644 --- a/template/android/build.gradle +++ b/template/android/build.gradle @@ -29,7 +29,13 @@ allprojects { // Android JSC is installed from npm url("$rootDir/../node_modules/jsc-android/dist") } - mavenCentral() + mavenCentral { + // We don't want to fetch react-native from Maven Central as there are + // older versions over there. + content { + excludeGroup "com.facebook.react" + } + } google() maven { url 'https://www.jitpack.io' } } From 9ae3367431428748f5486c782199beb4f9c6b477 Mon Sep 17 00:00:00 2001 From: svbutko Date: Wed, 13 Oct 2021 06:00:42 -0700 Subject: [PATCH 43/62] Bump Kotlin and Gradle versions (#32319) Summary: Bump Kotlin version to 1.5.31 to include following changes: https://kotlinlang.org/docs/whatsnew15.html https://kotlinlang.org/docs/whatsnew1520.html https://kotlinlang.org/docs/whatsnew1530.html Primarily: - Native support for Apple silicon - Kotlin/JS IR backend reaches Beta - Improved Gradle plugin experience - Performance improvements ## Changelog [Android] [Changed] - Bump Kotlin version to 1.5.31 [Android] [Changed] - Bump Gradle version to 7.2 Pull Request resolved: https://github.com/facebook/react-native/pull/32319 Reviewed By: yungsters Differential Revision: D31365479 Pulled By: cortinico fbshipit-source-id: 1ffaef1222a6ada8ebc746267b2a22561c3c770f --- gradle.properties | 2 +- gradle/wrapper/gradle-wrapper.properties | 2 +- packages/react-native-gradle-plugin/build.gradle.kts | 4 ++-- .../gradle/wrapper/gradle-wrapper.properties | 2 +- template/android/gradle/wrapper/gradle-wrapper.properties | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/gradle.properties b/gradle.properties index 223dcfb79c..4d0bece201 100644 --- a/gradle.properties +++ b/gradle.properties @@ -6,4 +6,4 @@ org.gradle.parallel=true ANDROID_NDK_VERSION=21.4.7075529 android.useAndroidX=true -kotlin_version=1.4.32 +kotlin_version=1.5.31 diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index af7be50b10..a0f7639f7d 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.1.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-all.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/packages/react-native-gradle-plugin/build.gradle.kts b/packages/react-native-gradle-plugin/build.gradle.kts index 88d9dc7774..6320a994ad 100644 --- a/packages/react-native-gradle-plugin/build.gradle.kts +++ b/packages/react-native-gradle-plugin/build.gradle.kts @@ -9,7 +9,7 @@ import org.gradle.api.internal.classpath.ModuleRegistry import org.gradle.configurationcache.extensions.serviceOf plugins { - kotlin("jvm") version "1.4.21" + kotlin("jvm") version "1.5.31" id("java-gradle-plugin") } @@ -30,7 +30,7 @@ gradlePlugin { dependencies { implementation(gradleApi()) implementation("com.android.tools.build:gradle:4.2.2") - + testImplementation("junit:junit:4.13.2") testRuntimeOnly( diff --git a/packages/react-native-gradle-plugin/gradle/wrapper/gradle-wrapper.properties b/packages/react-native-gradle-plugin/gradle/wrapper/gradle-wrapper.properties index af7be50b10..a0f7639f7d 100644 --- a/packages/react-native-gradle-plugin/gradle/wrapper/gradle-wrapper.properties +++ b/packages/react-native-gradle-plugin/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.1.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-all.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/template/android/gradle/wrapper/gradle-wrapper.properties b/template/android/gradle/wrapper/gradle-wrapper.properties index af7be50b10..a0f7639f7d 100644 --- a/template/android/gradle/wrapper/gradle-wrapper.properties +++ b/template/android/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.1.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.2-all.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists From 8ba4a2f127ee5fd862f2bb573ded50abce70c048 Mon Sep 17 00:00:00 2001 From: Andrei Shikov Date: Wed, 13 Oct 2021 08:21:38 -0700 Subject: [PATCH 44/62] Define event category in Event class Summary: Propagate event category definition to every event that is using `dispatchModernV2` (gated in production), providing opportunity to override categories of some events if needed. No events are meaningfully affected by this change, as coalesced events (e.g. scroll) are always dispatched as continuous and touch events are handled separately. Changelog: [Internal] Expose event category in Event class Reviewed By: cortinico Differential Revision: D31276249 fbshipit-source-id: f9a756b3a5cf5897e17209f3d0aed6a1c16cbd2e --- .../react/fabric/FabricUIManager.java | 2 +- .../fabric/events/EventEmitterWrapper.java | 1 + .../fabric/events/FabricEventEmitter.java | 33 ++++++++++++------- .../react/uimanager/events/Event.java | 8 ++++- .../events/EventCategoryDef.java | 12 +++---- .../events/RCTModernEventEmitter.java | 3 +- .../uimanager/events/ReactEventEmitter.java | 13 ++++++-- 7 files changed, 48 insertions(+), 24 deletions(-) rename ReactAndroid/src/main/java/com/facebook/react/{fabric => uimanager}/events/EventCategoryDef.java (71%) diff --git a/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricUIManager.java b/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricUIManager.java index 44a81cd031..270b9466b0 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricUIManager.java +++ b/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricUIManager.java @@ -54,7 +54,6 @@ import com.facebook.react.common.build.ReactBuildConfig; import com.facebook.react.common.mapbuffer.ReadableMapBuffer; import com.facebook.react.config.ReactFeatureFlags; import com.facebook.react.fabric.events.EventBeatManager; -import com.facebook.react.fabric.events.EventCategoryDef; import com.facebook.react.fabric.events.EventEmitterWrapper; import com.facebook.react.fabric.events.FabricEventEmitter; import com.facebook.react.fabric.mounting.MountItemDispatcher; @@ -78,6 +77,7 @@ import com.facebook.react.uimanager.ThemedReactContext; import com.facebook.react.uimanager.UIManagerHelper; import com.facebook.react.uimanager.ViewManagerPropertyUpdater; import com.facebook.react.uimanager.ViewManagerRegistry; +import com.facebook.react.uimanager.events.EventCategoryDef; import com.facebook.react.uimanager.events.EventDispatcher; import com.facebook.react.uimanager.events.EventDispatcherImpl; import com.facebook.react.uimanager.events.LockFreeEventDispatcherImpl; diff --git a/ReactAndroid/src/main/java/com/facebook/react/fabric/events/EventEmitterWrapper.java b/ReactAndroid/src/main/java/com/facebook/react/fabric/events/EventEmitterWrapper.java index dc875cea1d..24d33be42f 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/fabric/events/EventEmitterWrapper.java +++ b/ReactAndroid/src/main/java/com/facebook/react/fabric/events/EventEmitterWrapper.java @@ -16,6 +16,7 @@ import com.facebook.react.bridge.NativeMap; import com.facebook.react.bridge.WritableMap; import com.facebook.react.bridge.WritableNativeMap; import com.facebook.react.fabric.FabricSoLoader; +import com.facebook.react.uimanager.events.EventCategoryDef; /** * This class holds reference to the C++ EventEmitter object. Instances of this class are created on diff --git a/ReactAndroid/src/main/java/com/facebook/react/fabric/events/FabricEventEmitter.java b/ReactAndroid/src/main/java/com/facebook/react/fabric/events/FabricEventEmitter.java index 71cafaabd3..983466ab38 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/fabric/events/FabricEventEmitter.java +++ b/ReactAndroid/src/main/java/com/facebook/react/fabric/events/FabricEventEmitter.java @@ -22,6 +22,7 @@ import com.facebook.react.bridge.WritableMap; import com.facebook.react.bridge.WritableNativeArray; import com.facebook.react.bridge.WritableNativeMap; import com.facebook.react.fabric.FabricUIManager; +import com.facebook.react.uimanager.events.EventCategoryDef; import com.facebook.react.uimanager.events.RCTModernEventEmitter; import com.facebook.react.uimanager.events.TouchEventType; import com.facebook.systrace.Systrace; @@ -46,7 +47,7 @@ public class FabricEventEmitter implements RCTModernEventEmitter { @Override public void receiveEvent( int surfaceId, int reactTag, String eventName, @Nullable WritableMap params) { - receiveEvent(surfaceId, reactTag, eventName, false, 0, params); + receiveEvent(surfaceId, reactTag, eventName, false, 0, params, EventCategoryDef.UNSPECIFIED); } @Override @@ -56,37 +57,46 @@ public class FabricEventEmitter implements RCTModernEventEmitter { String eventName, boolean canCoalesceEvent, int customCoalesceKey, - @Nullable WritableMap params) { + @Nullable WritableMap params, + @EventCategoryDef int category) { Systrace.beginSection( Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, "FabricEventEmitter.receiveEvent('" + eventName + "')"); mUIManager.receiveEvent( - surfaceId, reactTag, eventName, canCoalesceEvent, customCoalesceKey, params); + surfaceId, reactTag, eventName, canCoalesceEvent, customCoalesceKey, params, category); Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE); } + /** + * Processes touches in a JS compatible way and send it to Fabric core + * + * @param eventName the event name (see {@link TouchEventType}) + * @param touches all the touch data extracted from MotionEvent + * @param changedIndices the indices of the pointers that changed (MOVE/CANCEL includes all + * touches, START/END only the one that was added/removed) + */ @Override public void receiveTouches( - @NonNull String eventTopLevelType, + @NonNull String eventName, @NonNull WritableArray touches, @NonNull WritableArray changedIndices) { Systrace.beginSection( Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, - "FabricEventEmitter.receiveTouches('" + eventTopLevelType + "')"); + "FabricEventEmitter.receiveTouches('" + eventName + "')"); - boolean isPointerEndEvent = - TouchEventType.END.getJsName().equalsIgnoreCase(eventTopLevelType) - || TouchEventType.CANCEL.getJsName().equalsIgnoreCase(eventTopLevelType); + boolean isFinalEvent = + TouchEventType.END.getJsName().equalsIgnoreCase(eventName) + || TouchEventType.CANCEL.getJsName().equalsIgnoreCase(eventName); Pair result = - isPointerEndEvent + isFinalEvent ? removeTouchesAtIndices(touches, changedIndices) : touchSubsequence(touches, changedIndices); WritableArray changedTouches = result.first; touches = result.second; - int eventCategory = getTouchCategory(eventTopLevelType); + int eventCategory = getTouchCategory(eventName); for (int jj = 0; jj < changedTouches.size(); jj++) { WritableMap touch = getWritableMap(changedTouches.getMap(jj)); // Touch objects can fulfill the role of `DOM` `Event` objects if we set @@ -104,8 +114,7 @@ public class FabricEventEmitter implements RCTModernEventEmitter { rootNodeID = targetReactTag; } - mUIManager.receiveEvent( - targetSurfaceId, rootNodeID, eventTopLevelType, false, 0, touch, eventCategory); + receiveEvent(targetSurfaceId, rootNodeID, eventName, false, 0, touch, eventCategory); } Systrace.endSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE); diff --git a/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/Event.java b/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/Event.java index 22ba914995..2ffb063c96 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/Event.java +++ b/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/Event.java @@ -182,6 +182,11 @@ public abstract class Event { return null; } + @EventCategoryDef + protected int getEventCategory() { + return EventCategoryDef.UNSPECIFIED; + } + /** * Dispatch this event to JS using a V2 EventEmitter. If surfaceId is not -1 and `getEventData` is * non-null, this will use the RCTModernEventEmitter API. Otherwise, it falls back to the @@ -215,7 +220,8 @@ public abstract class Event { getEventName(), canCoalesce(), getCoalescingKey(), - eventData); + eventData, + getEventCategory()); return; } } diff --git a/ReactAndroid/src/main/java/com/facebook/react/fabric/events/EventCategoryDef.java b/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/EventCategoryDef.java similarity index 71% rename from ReactAndroid/src/main/java/com/facebook/react/fabric/events/EventCategoryDef.java rename to ReactAndroid/src/main/java/com/facebook/react/uimanager/events/EventCategoryDef.java index f55fa701c0..60c5a50df7 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/fabric/events/EventCategoryDef.java +++ b/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/EventCategoryDef.java @@ -5,13 +5,13 @@ * LICENSE file in the root directory of this source tree. */ -package com.facebook.react.fabric.events; +package com.facebook.react.uimanager.events; -import static com.facebook.react.fabric.events.EventCategoryDef.CONTINUOUS; -import static com.facebook.react.fabric.events.EventCategoryDef.CONTINUOUS_END; -import static com.facebook.react.fabric.events.EventCategoryDef.CONTINUOUS_START; -import static com.facebook.react.fabric.events.EventCategoryDef.DISCRETE; -import static com.facebook.react.fabric.events.EventCategoryDef.UNSPECIFIED; +import static com.facebook.react.uimanager.events.EventCategoryDef.CONTINUOUS; +import static com.facebook.react.uimanager.events.EventCategoryDef.CONTINUOUS_END; +import static com.facebook.react.uimanager.events.EventCategoryDef.CONTINUOUS_START; +import static com.facebook.react.uimanager.events.EventCategoryDef.DISCRETE; +import static com.facebook.react.uimanager.events.EventCategoryDef.UNSPECIFIED; import androidx.annotation.IntDef; diff --git a/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/RCTModernEventEmitter.java b/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/RCTModernEventEmitter.java index 47fbd76416..4466e07b11 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/RCTModernEventEmitter.java +++ b/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/RCTModernEventEmitter.java @@ -28,5 +28,6 @@ public interface RCTModernEventEmitter extends RCTEventEmitter { String eventName, boolean canCoalesceEvent, int customCoalesceKey, - @Nullable WritableMap event); + @Nullable WritableMap event, + @EventCategoryDef int category); } diff --git a/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/ReactEventEmitter.java b/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/ReactEventEmitter.java index c99cb277ba..1ab5400106 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/ReactEventEmitter.java +++ b/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/ReactEventEmitter.java @@ -64,7 +64,7 @@ public class ReactEventEmitter implements RCTModernEventEmitter { int surfaceId, int targetTag, String eventName, @Nullable WritableMap event) { // The two additional params here, `canCoalesceEvent` and `customCoalesceKey`, have no // meaning outside of Fabric. - receiveEvent(surfaceId, targetTag, eventName, false, 0, event); + receiveEvent(surfaceId, targetTag, eventName, false, 0, event, EventCategoryDef.UNSPECIFIED); } @Override @@ -120,11 +120,18 @@ public class ReactEventEmitter implements RCTModernEventEmitter { String eventName, boolean canCoalesceEvent, int customCoalesceKey, - @Nullable WritableMap event) { + @Nullable WritableMap event, + @EventCategoryDef int category) { @UIManagerType int uiManagerType = ViewUtil.getUIManagerType(targetReactTag); if (uiManagerType == UIManagerType.FABRIC && mFabricEventEmitter != null) { mFabricEventEmitter.receiveEvent( - surfaceId, targetReactTag, eventName, canCoalesceEvent, customCoalesceKey, event); + surfaceId, + targetReactTag, + eventName, + canCoalesceEvent, + customCoalesceKey, + event, + category); } else if (uiManagerType == UIManagerType.DEFAULT && getEventEmitter(targetReactTag) != null) { mRCTEventEmitter.receiveEvent(targetReactTag, eventName, event); } else { From 91adb761cf1583598d4d63ce879fd7e0f4ae793c Mon Sep 17 00:00:00 2001 From: Geraint White Date: Wed, 13 Oct 2021 12:49:02 -0700 Subject: [PATCH 45/62] Add hermesFlagsForVariant and deleteDebugFilesForVariant (#32281) Summary: Ref https://github.com/facebook/react-native/issues/25601#issuecomment-510856047. From https://github.com/facebook/react-native/pull/31040. The `hermesFlagsRelease` option only works with the release build type, but not with other build types. This PR allows hermes flags on a per variant basis to be specified using the `hermesFlagsForVariant` lambda. It also allows the hermes debugger cleanup to be run on a per variant basis using the `deleteDebugFilesForVariant` lambda. ## Changelog [Android] [Fixed] - Fix hermesFlags not working with multiple variants Pull Request resolved: https://github.com/facebook/react-native/pull/32281 Test Plan: Set the following options in `android/app/build.gradle` and ensure warnings are hidden when running `./gradlew assembleRelease` and `./gradlew assembleLive`. ``` hermesFlagsForVariant: { def v -> v.name.toLowerCase().contains('release') || v.name.toLowerCase().contains('live') ? ['-w'] : [] }, deleteDebugFilesForVariant: { def v -> v.name.toLowerCase().contains('release') || v.name.toLowerCase().contains('live') }, ``` Reviewed By: cortinico Differential Revision: D31234241 Pulled By: ShikaSD fbshipit-source-id: 2cb3dd63adbcd023061076b5a3b262a87b470518 --- .../com/facebook/react/ReactExtension.kt | 16 ++++++++ .../com/facebook/react/TaskConfiguration.kt | 18 ++++----- react.gradle | 39 ++++++++++++------- 3 files changed, 51 insertions(+), 22 deletions(-) diff --git a/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/ReactExtension.kt b/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/ReactExtension.kt index ad432829ac..9344c51faf 100644 --- a/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/ReactExtension.kt +++ b/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/ReactExtension.kt @@ -137,6 +137,22 @@ abstract class ReactExtension @Inject constructor(project: Project) { */ var enableHermesForVariant: (BaseVariant) -> Boolean = { enableHermes.get() } + /** + * Functional interface specify flags for Hermes on specific [BaseVariant] Default: will + * return [hermesFlagsRelease] for Release variants and [hermesFlagsDebug] for Debug variants. + */ + var hermesFlagsForVariant: (BaseVariant) -> List = { + variant -> if (variant.isRelease) hermesFlagsRelease.get() else hermesFlagsDebug.get() + } + + /** + * Functional interface to delete debug files only on specific [BaseVariant] Default: will + * return True for Release variants and False for Debug variants. + */ + var deleteDebugFilesForVariant: (BaseVariant) -> Boolean = { + variant -> variant.isRelease + } + /** Flags to pass to Hermes for Debug variants. Default: [] */ val hermesFlagsDebug: ListProperty = objects.listProperty(String::class.java).convention(emptyList()) diff --git a/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/TaskConfiguration.kt b/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/TaskConfiguration.kt index ad0f73c5ce..eefaef68a8 100644 --- a/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/TaskConfiguration.kt +++ b/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/TaskConfiguration.kt @@ -49,6 +49,7 @@ internal fun Project.configureReactTasks(variant: BaseVariant, config: ReactExte val execCommand = nodeExecutableAndArgs + cliPath val enableHermes = config.enableHermesForVariant(variant) + val cleanup = config.deleteDebugFilesForVariant(variant) val bundleEnabled = variant.checkBundleEnabled(config) val bundleTask = @@ -100,8 +101,7 @@ internal fun Project.configureReactTasks(variant: BaseVariant, config: ReactExte it.reactRoot = config.reactRoot.get().asFile it.hermesCommand = detectedHermesCommand(config) - it.hermesFlags = - if (isRelease) config.hermesFlagsRelease.get() else config.hermesFlagsDebug.get() + it.hermesFlags = config.hermesFlagsForVariant(variant) it.jsBundleFile = jsBundleFile it.composeSourceMapsCommand = nodeExecutableAndArgs + config.composeSourceMapsPath.get() it.jsPackagerSourceMapFile = jsPackagerSourceMapFile @@ -166,7 +166,7 @@ internal fun Project.configureReactTasks(variant: BaseVariant, config: ReactExte if (config.enableVmCleanup.get()) { val libDir = "$buildDir/intermediates/transforms/" val targetVariant = ".*/transforms/[^/]*/$targetPath/.*".toRegex() - it.doFirst { cleanupVMFiles(libDir, targetVariant, enableHermes, isRelease) } + it.doFirst { cleanupVMFiles(libDir, targetVariant, enableHermes, cleanup) } } } @@ -174,7 +174,7 @@ internal fun Project.configureReactTasks(variant: BaseVariant, config: ReactExte if (config.enableVmCleanup.get()) { val libDir = "$buildDir/intermediates/stripped_native_libs/${targetPath}/out/lib/" val targetVariant = ".*/stripped_native_libs/$targetPath/out/lib/.*".toRegex() - it.doLast { cleanupVMFiles(libDir, targetVariant, enableHermes, isRelease) } + it.doLast { cleanupVMFiles(libDir, targetVariant, enableHermes, cleanup) } } } @@ -182,7 +182,7 @@ internal fun Project.configureReactTasks(variant: BaseVariant, config: ReactExte if (config.enableVmCleanup.get()) { val libDir = "$buildDir/intermediates/merged_native_libs/${targetPath}/out/lib/" val targetVariant = ".*/merged_native_libs/$targetPath/out/lib/.*".toRegex() - it.doLast { cleanupVMFiles(libDir, targetVariant, enableHermes, isRelease) } + it.doLast { cleanupVMFiles(libDir, targetVariant, enableHermes, cleanup) } } } @@ -217,7 +217,7 @@ private fun Project.cleanupVMFiles( libDir: String, targetVariant: Regex, enableHermes: Boolean, - isRelease: Boolean + cleanup: Boolean ) { // Delete the VM related libraries that this build doesn't need. // The application can manage this manually by setting 'enableVmCleanup: false' @@ -230,7 +230,7 @@ private fun Project.cleanupVMFiles( // For Hermes, delete all the libjsc* files it.include("**/libjsc*.so") - if (isRelease) { + if (cleanup) { // Reduce size by deleting the debugger/inspector it.include("**/libhermes-inspector.so") it.include("**/libhermes-executor-debug.so") @@ -245,7 +245,7 @@ private fun Project.cleanupVMFiles( // For JSC, delete all the libhermes* files it.include("**/libhermes*.so") // Delete the libjscexecutor from release build - if (isRelease) { + if (cleanup) { it.include("**/libjscexecutor.so") } } @@ -270,5 +270,5 @@ private fun BaseVariant.checkBundleEnabled(config: ReactExtension): Boolean { return isRelease } -private val BaseVariant.isRelease: Boolean +internal val BaseVariant.isRelease: Boolean get() = name.toLowerCase(Locale.ROOT).contains("release") diff --git a/react.gradle b/react.gradle index 812d11e43e..d9e27140ae 100644 --- a/react.gradle +++ b/react.gradle @@ -83,6 +83,28 @@ def enableHermesForVariant = config.enableHermesForVariant ?: { def variant -> config.enableHermes ?: false } +// Set hermesFlagsForVariant to a function to configure per variant, +// or set `hermesFlagsRelease` and `hermesFlagsDebug` to an array +def hermesFlagsForVariant = config.hermesFlagsForVariant ?: { + def variant -> + def hermesFlags; + if (variant.name.toLowerCase().contains("release")) { + // Can't use ?: since that will also substitute valid empty lists + hermesFlags = config.hermesFlagsRelease + if (hermesFlags == null) hermesFlags = ["-O", "-output-source-map"] + } else { + hermesFlags = config.hermesFlagsDebug + if (hermesFlags == null) hermesFlags = [] + } + return hermesFlags +} + +// Set deleteDebugFilesForVariant to a function to configure per variant, +// defaults to True for Release variants and False for debug variants +def deleteDebugFilesForVariant = config.deleteDebugFilesForVariant ?: { + def variant -> variant.name.toLowerCase().contains("release") +} + android { buildTypes.all { resValue "integer", "react_native_dev_server_port", reactNativeDevServerPort() @@ -177,18 +199,9 @@ afterEvaluate { if (enableHermes) { doLast { - def hermesFlags; + def hermesFlags = hermesFlagsForVariant(variant) def hbcTempFile = file("${jsBundleFile}.hbc") exec { - if (targetName.toLowerCase().contains("release")) { - // Can't use ?: since that will also substitute valid empty lists - hermesFlags = config.hermesFlagsRelease - if (hermesFlags == null) hermesFlags = ["-O", "-output-source-map"] - } else { - hermesFlags = config.hermesFlagsDebug - if (hermesFlags == null) hermesFlags = [] - } - if (Os.isFamily(Os.FAMILY_WINDOWS)) { commandLine("cmd", "/c", getHermesCommand(), "-emit-binary", "-out", hbcTempFile, jsBundleFile, *hermesFlags) } else { @@ -328,7 +341,7 @@ afterEvaluate { // This should really be done by packaging all Hermes related libs into // two separate HermesDebug and HermesRelease AARs, but until then we'll // kludge it by deleting the .so files out of the /transforms/ directory. - def isRelease = targetName.toLowerCase().contains("release") + def cleanup = deleteDebugFilesForVariant(variant) def vmSelectionAction = { libDir -> fileTree(libDir).matching { @@ -336,7 +349,7 @@ afterEvaluate { // For Hermes, delete all the libjsc* files include "**/libjsc*.so" - if (isRelease) { + if (cleanup) { // Reduce size by deleting the debugger/inspector include '**/libhermes-inspector.so' include '**/libhermes-executor-debug.so' @@ -351,7 +364,7 @@ afterEvaluate { // For JSC, delete all the libhermes* files include "**/libhermes*.so" // Delete the libjscexecutor from release build - if (isRelease) { + if (cleanup) { include "**/libjscexecutor.so" } } From 046a7d2286089d9bfaef656ea6c97e65cf0a40b1 Mon Sep 17 00:00:00 2001 From: Luna Wei Date: Wed, 13 Oct 2021 15:04:03 -0700 Subject: [PATCH 46/62] Fix artifacts link Summary: Changelog: [Internal] - Fix artifacts link in PR commitly comment Reviewed By: hramos Differential Revision: D31624488 fbshipit-source-id: cef7c79f1f8d290aa9541c3c955c9a68dc5fd643 --- bots/post-artifacts-link.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/bots/post-artifacts-link.js b/bots/post-artifacts-link.js index cc93fc5ad2..f658d2b3ce 100644 --- a/bots/post-artifacts-link.js +++ b/bots/post-artifacts-link.js @@ -30,12 +30,13 @@ const {createOrUpdateComment} = require('./make-comment'); * @param {string} commitSha github sha of PR */ function postArtifactLink(buildUrl, commitSha) { - const artifactLink = buildUrl + '/artifacts'; + // build url link is redirected by CircleCI so appending `/artifacts` doesn't work + const artifactLink = buildUrl; const comment = [ `PR build artifact${ commitSha != null ? ` for ${commitSha}` : '' } is ready.`, - `To use, download tarball from [this CircleCI job](${artifactLink}) then run \`yarn add \` in your React Native project.`, + `To use, download tarball from "Artifacts" tab in [this CircleCI job](${artifactLink}) then run \`yarn add \` in your React Native project.`, ].join('\n'); createOrUpdateComment(comment); } From d1a33cd139fab4565b1fc691f5751c4af99d5849 Mon Sep 17 00:00:00 2001 From: Joel Arvidsson Date: Wed, 13 Oct 2021 16:59:17 -0700 Subject: [PATCH 47/62] Fix Android border positioning regression (#32398) Summary: https://github.com/facebook/react-native/issues/29099 introduced a regression where non-rounded borders on Android would render partly outside of the bounds of the view as I reported in https://github.com/facebook/react-native/issues/32393. This PR addresses that by rendering the borders completely inside the view like it works on iOS, previous version of RN and for rounded corners. ## Changelog [Android] [Fixed] - Fix Android border positioning regression Pull Request resolved: https://github.com/facebook/react-native/pull/32398 Test Plan: Rendering the following code (as reported in the issue) in the RN Tester app: ```jsx ``` |Before|After| |--|--| |![before](https://user-images.githubusercontent.com/378279/137178113-dd2fea7e-48c8-450b-be3a-92706ef93194.png)|![after](https://user-images.githubusercontent.com/378279/137178140-b5ce7b3d-d455-48a9-a57f-0f3194a65c9a.png)| Reviewed By: yungsters Differential Revision: D31623647 Pulled By: lunaleaps fbshipit-source-id: c38d172ae4a9dc48f800c63258223a59e2f621ed --- .../views/view/ReactViewBackgroundDrawable.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactViewBackgroundDrawable.java b/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactViewBackgroundDrawable.java index bed2251c84..5d19b87139 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactViewBackgroundDrawable.java +++ b/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactViewBackgroundDrawable.java @@ -1106,8 +1106,8 @@ public class ReactViewBackgroundDrawable extends Drawable { int width = Math.round(borderWidth.left); updatePathEffect(width); mPaint.setStrokeWidth(width); - mPathForSingleBorder.moveTo(left, top - borderWidth.top / 2); - mPathForSingleBorder.lineTo(left, bottom + borderWidth.bottom / 2); + mPathForSingleBorder.moveTo(left + width / 2, top); + mPathForSingleBorder.lineTo(left + width / 2, bottom); canvas.drawPath(mPathForSingleBorder, mPaint); } if (borderTop > 0) { @@ -1115,8 +1115,8 @@ public class ReactViewBackgroundDrawable extends Drawable { int width = Math.round(borderWidth.top); updatePathEffect(width); mPaint.setStrokeWidth(width); - mPathForSingleBorder.moveTo(left, top); - mPathForSingleBorder.lineTo(right, top); + mPathForSingleBorder.moveTo(left, top + width / 2); + mPathForSingleBorder.lineTo(right, top + width / 2); canvas.drawPath(mPathForSingleBorder, mPaint); } if (borderRight > 0) { @@ -1124,8 +1124,8 @@ public class ReactViewBackgroundDrawable extends Drawable { int width = Math.round(borderWidth.right); updatePathEffect(width); mPaint.setStrokeWidth(width); - mPathForSingleBorder.moveTo(right, top - borderWidth.top / 2); - mPathForSingleBorder.lineTo(right, bottom + borderWidth.bottom / 2); + mPathForSingleBorder.moveTo(right - width / 2, top); + mPathForSingleBorder.lineTo(right - width / 2, bottom); canvas.drawPath(mPathForSingleBorder, mPaint); } if (borderBottom > 0) { @@ -1133,8 +1133,8 @@ public class ReactViewBackgroundDrawable extends Drawable { int width = Math.round(borderWidth.bottom); updatePathEffect(width); mPaint.setStrokeWidth(width); - mPathForSingleBorder.moveTo(left, bottom); - mPathForSingleBorder.lineTo(right, bottom); + mPathForSingleBorder.moveTo(left, bottom - width / 2); + mPathForSingleBorder.lineTo(right, bottom - width / 2); canvas.drawPath(mPathForSingleBorder, mPaint); } } From 2bced60851ec668d3bc9c75c99803891aab772e3 Mon Sep 17 00:00:00 2001 From: CodemodService FBSourceKtfmtLinterBot <> Date: Wed, 13 Oct 2021 19:52:03 -0700 Subject: [PATCH 48/62] Daily `arc lint --take KTFMT` Reviewed By: zertosh Differential Revision: D31636434 fbshipit-source-id: 4632cdc1bfd3eb398079fa3c7c3791783f30515f --- .../kotlin/com/facebook/react/ReactExtension.kt | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/ReactExtension.kt b/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/ReactExtension.kt index 9344c51faf..f898c9d37f 100644 --- a/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/ReactExtension.kt +++ b/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/ReactExtension.kt @@ -138,20 +138,18 @@ abstract class ReactExtension @Inject constructor(project: Project) { var enableHermesForVariant: (BaseVariant) -> Boolean = { enableHermes.get() } /** - * Functional interface specify flags for Hermes on specific [BaseVariant] Default: will - * return [hermesFlagsRelease] for Release variants and [hermesFlagsDebug] for Debug variants. + * Functional interface specify flags for Hermes on specific [BaseVariant] Default: will return + * [hermesFlagsRelease] for Release variants and [hermesFlagsDebug] for Debug variants. */ - var hermesFlagsForVariant: (BaseVariant) -> List = { - variant -> if (variant.isRelease) hermesFlagsRelease.get() else hermesFlagsDebug.get() + var hermesFlagsForVariant: (BaseVariant) -> List = { variant -> + if (variant.isRelease) hermesFlagsRelease.get() else hermesFlagsDebug.get() } /** - * Functional interface to delete debug files only on specific [BaseVariant] Default: will - * return True for Release variants and False for Debug variants. + * Functional interface to delete debug files only on specific [BaseVariant] Default: will return + * True for Release variants and False for Debug variants. */ - var deleteDebugFilesForVariant: (BaseVariant) -> Boolean = { - variant -> variant.isRelease - } + var deleteDebugFilesForVariant: (BaseVariant) -> Boolean = { variant -> variant.isRelease } /** Flags to pass to Hermes for Debug variants. Default: [] */ val hermesFlagsDebug: ListProperty = From 943f86272d5b312382e08eb9fbbba515d8a2812f Mon Sep 17 00:00:00 2001 From: Desmond Ng Date: Wed, 13 Oct 2021 20:35:19 -0700 Subject: [PATCH 49/62] Revert D31636434: Daily `arc lint --take KTFMT` Differential Revision: D31636434 (https://github.com/facebook/react-native/commit/2bced60851ec668d3bc9c75c99803891aab772e3) Original commit changeset: 4632cdc1bfd3 fbshipit-source-id: 7810fcba547d091e5014d6a3f70af7779e9a2aa1 --- .../kotlin/com/facebook/react/ReactExtension.kt | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/ReactExtension.kt b/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/ReactExtension.kt index f898c9d37f..9344c51faf 100644 --- a/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/ReactExtension.kt +++ b/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/ReactExtension.kt @@ -138,18 +138,20 @@ abstract class ReactExtension @Inject constructor(project: Project) { var enableHermesForVariant: (BaseVariant) -> Boolean = { enableHermes.get() } /** - * Functional interface specify flags for Hermes on specific [BaseVariant] Default: will return - * [hermesFlagsRelease] for Release variants and [hermesFlagsDebug] for Debug variants. + * Functional interface specify flags for Hermes on specific [BaseVariant] Default: will + * return [hermesFlagsRelease] for Release variants and [hermesFlagsDebug] for Debug variants. */ - var hermesFlagsForVariant: (BaseVariant) -> List = { variant -> - if (variant.isRelease) hermesFlagsRelease.get() else hermesFlagsDebug.get() + var hermesFlagsForVariant: (BaseVariant) -> List = { + variant -> if (variant.isRelease) hermesFlagsRelease.get() else hermesFlagsDebug.get() } /** - * Functional interface to delete debug files only on specific [BaseVariant] Default: will return - * True for Release variants and False for Debug variants. + * Functional interface to delete debug files only on specific [BaseVariant] Default: will + * return True for Release variants and False for Debug variants. */ - var deleteDebugFilesForVariant: (BaseVariant) -> Boolean = { variant -> variant.isRelease } + var deleteDebugFilesForVariant: (BaseVariant) -> Boolean = { + variant -> variant.isRelease + } /** Flags to pass to Hermes for Debug variants. Default: [] */ val hermesFlagsDebug: ListProperty = From 689bfed9f12edbb7c964af36578dd7086c78c227 Mon Sep 17 00:00:00 2001 From: CodemodService FBSourceKtfmtLinterBot <> Date: Thu, 14 Oct 2021 04:46:13 -0700 Subject: [PATCH 50/62] Daily `arc lint --take KTFMT` Reviewed By: zertosh Differential Revision: D31647300 fbshipit-source-id: b0374baa40ff01d3ef6174d348e1c7793cb7bcaf --- .../kotlin/com/facebook/react/ReactExtension.kt | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/ReactExtension.kt b/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/ReactExtension.kt index 9344c51faf..f898c9d37f 100644 --- a/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/ReactExtension.kt +++ b/packages/react-native-gradle-plugin/src/main/kotlin/com/facebook/react/ReactExtension.kt @@ -138,20 +138,18 @@ abstract class ReactExtension @Inject constructor(project: Project) { var enableHermesForVariant: (BaseVariant) -> Boolean = { enableHermes.get() } /** - * Functional interface specify flags for Hermes on specific [BaseVariant] Default: will - * return [hermesFlagsRelease] for Release variants and [hermesFlagsDebug] for Debug variants. + * Functional interface specify flags for Hermes on specific [BaseVariant] Default: will return + * [hermesFlagsRelease] for Release variants and [hermesFlagsDebug] for Debug variants. */ - var hermesFlagsForVariant: (BaseVariant) -> List = { - variant -> if (variant.isRelease) hermesFlagsRelease.get() else hermesFlagsDebug.get() + var hermesFlagsForVariant: (BaseVariant) -> List = { variant -> + if (variant.isRelease) hermesFlagsRelease.get() else hermesFlagsDebug.get() } /** - * Functional interface to delete debug files only on specific [BaseVariant] Default: will - * return True for Release variants and False for Debug variants. + * Functional interface to delete debug files only on specific [BaseVariant] Default: will return + * True for Release variants and False for Debug variants. */ - var deleteDebugFilesForVariant: (BaseVariant) -> Boolean = { - variant -> variant.isRelease - } + var deleteDebugFilesForVariant: (BaseVariant) -> Boolean = { variant -> variant.isRelease } /** Flags to pass to Hermes for Debug variants. Default: [] */ val hermesFlagsDebug: ListProperty = From 53fd0f4026ca9717c00d8bcbece5736568768793 Mon Sep 17 00:00:00 2001 From: Andrei Shikov Date: Thu, 14 Oct 2021 05:17:31 -0700 Subject: [PATCH 51/62] Retrieve touch dispatch information from event directly Summary: Simplifies logic of touch dispatch by retrieving surface id and other require info from the event directly. Changelog: [Android][Internal] - Simplify logic of dispatching touches Reviewed By: cortinico Differential Revision: D31583314 fbshipit-source-id: c6b6e131a759c2ebe0cf4441c3aeb1a8b9f5781e --- .../react/uimanager/events/Event.java | 2 +- .../react/uimanager/events/TouchEvent.java | 12 ++++++------ .../react/uimanager/events/TouchesHelper.java | 19 ++++++------------- 3 files changed, 13 insertions(+), 20 deletions(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/Event.java b/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/Event.java index 2ffb063c96..b205bdeb3c 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/Event.java +++ b/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/Event.java @@ -197,7 +197,7 @@ public abstract class Event { if (getSurfaceId() != -1) { WritableMap eventData = getEventData(); if (eventData != null) { - rctEventEmitter.receiveEvent(getSurfaceId(), getViewTag(), getEventName(), getEventData()); + rctEventEmitter.receiveEvent(getSurfaceId(), getViewTag(), getEventName(), eventData); return; } } diff --git a/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/TouchEvent.java b/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/TouchEvent.java index de64e8c8f9..f21e140b1f 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/TouchEvent.java +++ b/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/TouchEvent.java @@ -188,12 +188,8 @@ public class TouchEvent extends Event { "Cannot dispatch a TouchEvent that has no MotionEvent; the TouchEvent has been recycled")); return; } - TouchesHelper.sendTouchEvent( - rctEventEmitter, - Assertions.assertNotNull(mTouchEventType), - getSurfaceId(), - getViewTag(), - this); + + TouchesHelper.sendTouchEvent(rctEventEmitter, this); } @Override @@ -210,6 +206,10 @@ public class TouchEvent extends Event { return mMotionEvent != null; } + public TouchEventType getTouchEventType() { + return Assertions.assertNotNull(mTouchEventType); + } + public float getViewX() { return mViewX; } diff --git a/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/TouchesHelper.java b/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/TouchesHelper.java index 676f672954..2b2c6ae975 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/TouchesHelper.java +++ b/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/TouchesHelper.java @@ -33,8 +33,7 @@ public class TouchesHelper { * given {@param event} instance. This method use {@param reactTarget} parameter to set as a * target view id associated with current gesture. */ - private static WritableArray createsPointersArray( - int surfaceId, int reactTarget, TouchEvent event) { + private static WritableArray createsPointersArray(TouchEvent event) { WritableArray touches = Arguments.createArray(); MotionEvent motionEvent = event.getMotionEvent(); @@ -60,8 +59,8 @@ public class TouchesHelper { float locationY = motionEvent.getY(index) - targetViewCoordinateY; touch.putDouble(LOCATION_X_KEY, PixelUtil.toDIPFromPixel(locationX)); touch.putDouble(LOCATION_Y_KEY, PixelUtil.toDIPFromPixel(locationY)); - touch.putInt(TARGET_SURFACE_KEY, surfaceId); - touch.putInt(TARGET_KEY, reactTarget); + touch.putInt(TARGET_SURFACE_KEY, event.getSurfaceId()); + touch.putInt(TARGET_KEY, event.getViewTag()); touch.putDouble(TIMESTAMP_KEY, event.getTimestampMs()); touch.putDouble(POINTER_IDENTIFIER_KEY, motionEvent.getPointerId(index)); touches.pushMap(touch); @@ -75,17 +74,11 @@ public class TouchesHelper { * context}. Touch event can encode multiple concurrent touches (pointers). * * @param rctEventEmitter Event emitter used to execute JS module call - * @param type type of the touch event (see {@link TouchEventType}) - * @param reactTarget target view react id associated with this gesture * @param touchEvent native touch event to read pointers count and coordinates from */ - public static void sendTouchEvent( - RCTEventEmitter rctEventEmitter, - TouchEventType type, - int surfaceId, - int reactTarget, - TouchEvent touchEvent) { - WritableArray pointers = createsPointersArray(surfaceId, reactTarget, touchEvent); + public static void sendTouchEvent(RCTEventEmitter rctEventEmitter, TouchEvent touchEvent) { + TouchEventType type = touchEvent.getTouchEventType(); + WritableArray pointers = createsPointersArray(touchEvent); MotionEvent motionEvent = touchEvent.getMotionEvent(); // For START and END events send only index of the pointer that is associated with that event From a2feaeb5f1121a860a9416b5d4e0e96debd45b09 Mon Sep 17 00:00:00 2001 From: Andrei Shikov Date: Thu, 14 Oct 2021 05:17:31 -0700 Subject: [PATCH 52/62] Refactor touch event dispatch Summary: Updates touch events in Fabric to be dispatched through the same pipeline as the rest of events, instead of relying on custom dispatch behavior. Previous method of handling touches was reusing Paper behavior which required: 1. Transform event into a Paper-compatible form of WritableArray and dispatch it to `RCTEventEmitter.receiveTouches`. 2. Intercept `receiveTouches` for Fabric and redirect it to `FabricEventEmitter` 3. Perform transformations copied from Paper JS renderer in Java, transform it to the final form and dispatch this event as usual after. The new behavior uses emitter's `receiveEvent` method directly to dispatch events. Additionally, it should decrease allocations done when transforming events during step 3 above, as `WritableNativeMap`-based operations performed many re-allocations when reading/re-creating arrays. Changelog: [Android][Changed] - Added an experimental touch dispatch path Reviewed By: JoshuaGross Differential Revision: D31280052 fbshipit-source-id: 829c2646ac6b0ebff0f0106159e76d84324ac732 --- .../react/config/ReactFeatureFlags.java | 2 + .../react/uimanager/events/TouchEvent.java | 38 +++++- .../react/uimanager/events/TouchesHelper.java | 109 +++++++++++++++++- 3 files changed, 143 insertions(+), 6 deletions(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/config/ReactFeatureFlags.java b/ReactAndroid/src/main/java/com/facebook/react/config/ReactFeatureFlags.java index 7cf3f4237e..446ea326ac 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/config/ReactFeatureFlags.java +++ b/ReactAndroid/src/main/java/com/facebook/react/config/ReactFeatureFlags.java @@ -103,4 +103,6 @@ public class ReactFeatureFlags { public static boolean enableScrollViewSnapToAlignmentProp = true; public static boolean useDispatchUniqueForCoalescableEvents = false; + + public static boolean useUpdatedTouchPreprocessing = false; } diff --git a/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/TouchEvent.java b/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/TouchEvent.java index f21e140b1f..4ee7137456 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/TouchEvent.java +++ b/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/TouchEvent.java @@ -13,6 +13,8 @@ import androidx.core.util.Pools; import com.facebook.infer.annotation.Assertions; import com.facebook.react.bridge.ReactSoftExceptionLogger; import com.facebook.react.bridge.SoftAssertions; +import com.facebook.react.bridge.WritableMap; +import com.facebook.react.config.ReactFeatureFlags; /** * An event representing the start, end or movement of a touch. Corresponds to a single {@link @@ -194,7 +196,41 @@ public class TouchEvent extends Event { @Override public void dispatchModern(RCTModernEventEmitter rctEventEmitter) { - dispatch(rctEventEmitter); + if (ReactFeatureFlags.useUpdatedTouchPreprocessing) { + TouchesHelper.sendTouchEventModern(rctEventEmitter, this, /* useDispatchV2 */ false); + } else { + dispatch(rctEventEmitter); + } + } + + @Override + public void dispatchModernV2(RCTModernEventEmitter rctEventEmitter) { + if (ReactFeatureFlags.useUpdatedTouchPreprocessing) { + TouchesHelper.sendTouchEventModern(rctEventEmitter, this, /* useDispatchV2 */ true); + } else { + dispatch(rctEventEmitter); + } + } + + @Override + protected int getEventCategory() { + TouchEventType type = mTouchEventType; + if (type == null) { + return EventCategoryDef.UNSPECIFIED; + } + + switch (type) { + case START: + return EventCategoryDef.CONTINUOUS_START; + case END: + case CANCEL: + return EventCategoryDef.CONTINUOUS_END; + case MOVE: + return EventCategoryDef.CONTINUOUS; + } + + // Something something smart compiler... + return super.getEventCategory(); } public MotionEvent getMotionEvent() { diff --git a/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/TouchesHelper.java b/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/TouchesHelper.java index 2b2c6ae975..25b4236828 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/TouchesHelper.java +++ b/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/TouchesHelper.java @@ -9,13 +9,14 @@ package com.facebook.react.uimanager.events; import android.view.MotionEvent; import com.facebook.react.bridge.Arguments; +import com.facebook.react.bridge.ReactSoftExceptionLogger; import com.facebook.react.bridge.WritableArray; import com.facebook.react.bridge.WritableMap; +import com.facebook.react.bridge.WritableNativeArray; import com.facebook.react.uimanager.PixelUtil; /** Class responsible for generating catalyst touch events based on android {@link MotionEvent}. */ public class TouchesHelper { - public static final String TARGET_SURFACE_KEY = "targetSurface"; public static final String TARGET_KEY = "target"; public static final String CHANGED_TOUCHES_KEY = "changedTouches"; @@ -28,14 +29,16 @@ public class TouchesHelper { private static final String LOCATION_X_KEY = "locationX"; private static final String LOCATION_Y_KEY = "locationY"; + private static final String TAG = "TouchesHelper"; + /** * Creates catalyst pointers array in format that is expected by RCTEventEmitter JS module from * given {@param event} instance. This method use {@param reactTarget} parameter to set as a * target view id associated with current gesture. */ - private static WritableArray createsPointersArray(TouchEvent event) { - WritableArray touches = Arguments.createArray(); + private static WritableMap[] createPointersArray(TouchEvent event) { MotionEvent motionEvent = event.getMotionEvent(); + WritableMap[] touches = new WritableMap[motionEvent.getPointerCount()]; // Calculate the coordinates for the target view. // The MotionEvent contains the X,Y of the touch in the coordinate space of the root view @@ -63,7 +66,8 @@ public class TouchesHelper { touch.putInt(TARGET_KEY, event.getViewTag()); touch.putDouble(TIMESTAMP_KEY, event.getTimestampMs()); touch.putDouble(POINTER_IDENTIFIER_KEY, motionEvent.getPointerId(index)); - touches.pushMap(touch); + + touches[index] = touch; } return touches; @@ -78,7 +82,8 @@ public class TouchesHelper { */ public static void sendTouchEvent(RCTEventEmitter rctEventEmitter, TouchEvent touchEvent) { TouchEventType type = touchEvent.getTouchEventType(); - WritableArray pointers = createsPointersArray(touchEvent); + + WritableArray pointers = getWritableArray(createPointersArray(touchEvent)); MotionEvent motionEvent = touchEvent.getMotionEvent(); // For START and END events send only index of the pointer that is associated with that event @@ -96,4 +101,98 @@ public class TouchesHelper { rctEventEmitter.receiveTouches(TouchEventType.getJSEventName(type), pointers, changedIndices); } + + /** + * Generate touch event data to match JS expectations. Combines logic in {@link #sendTouchEvent} + * and FabricEventEmitter to create the same data structure in a more efficient manner. + * + *

Touches have to be dispatched as separate events for each changed pointer to make JS process + * them correctly. To avoid allocations, we preprocess touch events in Java world and then convert + * them to native before dispatch. + * + * @param eventEmitter emitter to dispatch event to + * @param event the touch event to extract data from + * @param useDispatchV2 whether to dispatch additional data used by {@link Event#dispatchModernV2} + */ + public static void sendTouchEventModern( + RCTModernEventEmitter eventEmitter, TouchEvent event, boolean useDispatchV2) { + TouchEventType type = event.getTouchEventType(); + MotionEvent motionEvent = event.getMotionEvent(); + + if (motionEvent == null) { + ReactSoftExceptionLogger.logSoftException( + TAG, + new IllegalStateException( + "Cannot dispatch a TouchEvent that has no MotionEvent; the TouchEvent has been recycled")); + return; + } + + WritableMap[] touches = createPointersArray(event); + WritableMap[] changedTouches = null; + + switch (type) { + case START: + int newPointerIndex = motionEvent.getActionIndex(); + + changedTouches = new WritableMap[] {touches[newPointerIndex].copy()}; + break; + case END: + int finishedPointerIndex = motionEvent.getActionIndex(); + /* + * Clear finished pointer index for compatibility with W3C touch "end" events, where the + * active touches don't include the set that has just been "ended". + */ + WritableMap finishedPointer = touches[finishedPointerIndex]; + touches[finishedPointerIndex] = null; + + changedTouches = new WritableMap[] {finishedPointer}; + break; + case MOVE: + changedTouches = new WritableMap[touches.length]; + for (int i = 0; i < touches.length; i++) { + changedTouches[i] = touches[i].copy(); + } + break; + case CANCEL: + changedTouches = touches; + touches = new WritableMap[0]; + break; + } + + WritableArray touchesArray = getWritableArray(touches); + WritableArray changedTouchesArray = getWritableArray(/* copyObjects */ true, changedTouches); + + for (WritableMap eventData : changedTouches) { + eventData.putArray(CHANGED_TOUCHES_KEY, changedTouchesArray); + eventData.putArray(TOUCHES_KEY, touchesArray); + + if (useDispatchV2) { + eventEmitter.receiveEvent( + event.getSurfaceId(), + event.getViewTag(), + event.getEventName(), + event.canCoalesce(), + 0, + eventData, + event.getEventCategory()); + } else { + eventEmitter.receiveEvent( + event.getSurfaceId(), event.getViewTag(), event.getEventName(), eventData); + } + } + } + + private static WritableArray getWritableArray(WritableMap... objects) { + return getWritableArray(false, objects); + } + + private static WritableArray getWritableArray(boolean copyObjects, WritableMap... objects) { + WritableArray result = new WritableNativeArray(); + for (WritableMap object : objects) { + if (object != null) { + result.pushMap(copyObjects ? object.copy() : object); + } + } + return result; + } } From ad0d4534a751ed05f84ff971714c8f7a4d1deb3a Mon Sep 17 00:00:00 2001 From: Pieter De Baets Date: Thu, 14 Oct 2021 05:27:30 -0700 Subject: [PATCH 53/62] Remove jsMessageQueueThread from Fabric binding Summary: This seems like a remnant of an old refactor. This is passed in, we wrap it with a JMessageQueueThread and then never use it again. Changelog: [Internal] Reviewed By: mdvacca Differential Revision: D31506280 fbshipit-source-id: aca01439dcddbe2b44ce80342fa8664f827919c9 --- .../src/main/java/com/facebook/react/fabric/Binding.java | 4 ---- .../facebook/react/fabric/FabricJSIModuleProvider.java | 9 ++------- .../main/java/com/facebook/react/fabric/jni/Binding.cpp | 3 --- .../main/java/com/facebook/react/fabric/jni/Binding.h | 2 -- 4 files changed, 2 insertions(+), 16 deletions(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/fabric/Binding.java b/ReactAndroid/src/main/java/com/facebook/react/fabric/Binding.java index e02f4188f5..6ad92742b8 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/fabric/Binding.java +++ b/ReactAndroid/src/main/java/com/facebook/react/fabric/Binding.java @@ -16,7 +16,6 @@ import com.facebook.react.bridge.NativeMap; import com.facebook.react.bridge.ReadableNativeMap; import com.facebook.react.bridge.RuntimeExecutor; import com.facebook.react.bridge.RuntimeScheduler; -import com.facebook.react.bridge.queue.MessageQueueThread; import com.facebook.react.fabric.events.EventBeatManager; import com.facebook.react.fabric.events.EventEmitterWrapper; import com.facebook.react.uimanager.PixelUtil; @@ -42,7 +41,6 @@ public class Binding { RuntimeScheduler runtimeScheduler, Object uiManager, EventBeatManager eventBeatManager, - MessageQueueThread jsMessageQueueThread, ComponentFactory componentsRegistry, Object reactNativeConfig); @@ -89,7 +87,6 @@ public class Binding { @Nullable RuntimeScheduler runtimeScheduler, @NonNull FabricUIManager fabricUIManager, @NonNull EventBeatManager eventBeatManager, - @NonNull MessageQueueThread jsMessageQueueThread, @NonNull ComponentFactory componentFactory, @NonNull ReactNativeConfig reactNativeConfig) { fabricUIManager.setBinding(this); @@ -98,7 +95,6 @@ public class Binding { runtimeScheduler, fabricUIManager, eventBeatManager, - jsMessageQueueThread, componentFactory, reactNativeConfig); diff --git a/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricJSIModuleProvider.java b/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricJSIModuleProvider.java index c4a6fbfb5c..811514772d 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricJSIModuleProvider.java +++ b/ReactAndroid/src/main/java/com/facebook/react/fabric/FabricJSIModuleProvider.java @@ -11,7 +11,6 @@ import androidx.annotation.NonNull; import com.facebook.react.bridge.JSIModuleProvider; import com.facebook.react.bridge.ReactApplicationContext; import com.facebook.react.bridge.UIManager; -import com.facebook.react.bridge.queue.MessageQueueThread; import com.facebook.react.common.mapbuffer.ReadableMapBufferSoLoader; import com.facebook.react.config.ReactFeatureFlags; import com.facebook.react.fabric.events.EventBeatManager; @@ -41,24 +40,20 @@ public class FabricJSIModuleProvider implements JSIModuleProvider { Systrace.beginSection(Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, "FabricJSIModuleProvider.get"); final EventBeatManager eventBeatManager = new EventBeatManager(mReactApplicationContext); final FabricUIManager uiManager = createUIManager(eventBeatManager); + Systrace.beginSection( Systrace.TRACE_TAG_REACT_JAVA_BRIDGE, "FabricJSIModuleProvider.registerBinding"); final Binding binding = new Binding(); + if (ReactFeatureFlags.enableEagerInitializeMapBufferSoFile) { ReadableMapBufferSoLoader.staticInit(); } - MessageQueueThread jsMessageQueueThread = - mReactApplicationContext - .getCatalystInstance() - .getReactQueueConfiguration() - .getJSQueueThread(); binding.register( mReactApplicationContext.getCatalystInstance().getRuntimeExecutor(), mReactApplicationContext.getCatalystInstance().getRuntimeScheduler(), uiManager, eventBeatManager, - jsMessageQueueThread, mComponentFactory, mConfig); diff --git a/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/Binding.cpp b/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/Binding.cpp index bdabaaf882..b4d0abd992 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/Binding.cpp +++ b/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/Binding.cpp @@ -498,7 +498,6 @@ void Binding::installFabricUIManager( jni::alias_ref runtimeSchedulerHolder, jni::alias_ref javaUIManager, EventBeatManager *eventBeatManager, - jni::alias_ref jsMessageQueueThread, ComponentFactory *componentsRegistry, jni::alias_ref reactNativeConfig) { SystraceSection s("FabricUIManagerBinding::installFabricUIManager"); @@ -532,8 +531,6 @@ void Binding::installFabricUIManager( ContextContainer::Shared contextContainer = std::make_shared(); - auto sharedJSMessageQueueThread = - std::make_shared(jsMessageQueueThread); auto runtimeExecutor = runtimeExecutorHolder->cthis()->get(); if (runtimeSchedulerHolder) { diff --git a/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/Binding.h b/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/Binding.h index 717d1be076..5f261f3453 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/Binding.h +++ b/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/Binding.h @@ -8,7 +8,6 @@ #pragma once #include -#include #include #include #include @@ -109,7 +108,6 @@ class Binding : public jni::HybridClass, jni::alias_ref runtimeSchedulerHolder, jni::alias_ref javaUIManager, EventBeatManager *eventBeatManager, - jni::alias_ref jsMessageQueueThread, ComponentFactory *componentsRegistry, jni::alias_ref reactNativeConfig); From b2e6483876cedc158684d8985f73fbf67cf3b87d Mon Sep 17 00:00:00 2001 From: Marshall Roch Date: Thu, 14 Oct 2021 09:47:38 -0700 Subject: [PATCH 54/62] deploy v0.162.0 to xplat Summary: Changelog: [Internal] Reviewed By: vrama628 Differential Revision: D31640841 fbshipit-source-id: 783200913d06baca5b1d32d07b8ed5f4ecde7e1e --- .flowconfig | 2 +- .flowconfig.android | 2 +- package.json | 2 +- .../rn-tester/js/components/RNTesterSettingSwitchRow.js | 1 + repo-config/package.json | 2 +- template/_flowconfig | 2 +- yarn.lock | 8 ++++---- 7 files changed, 10 insertions(+), 9 deletions(-) diff --git a/.flowconfig b/.flowconfig index 5329d6d602..a7e698c442 100644 --- a/.flowconfig +++ b/.flowconfig @@ -71,4 +71,4 @@ untyped-import untyped-type-import [version] -^0.161.0 +^0.162.0 diff --git a/.flowconfig.android b/.flowconfig.android index 5669243488..10a1f58d0d 100644 --- a/.flowconfig.android +++ b/.flowconfig.android @@ -71,4 +71,4 @@ untyped-import untyped-type-import [version] -^0.161.0 +^0.162.0 diff --git a/package.json b/package.json index 29ea521de0..50cfac09c6 100644 --- a/package.json +++ b/package.json @@ -119,7 +119,7 @@ "ws": "^6.1.4" }, "devDependencies": { - "flow-bin": "^0.161.0", + "flow-bin": "^0.162.0", "react": "17.0.2" }, "detox": { diff --git a/packages/rn-tester/js/components/RNTesterSettingSwitchRow.js b/packages/rn-tester/js/components/RNTesterSettingSwitchRow.js index 3d38793e9e..eeec4aa4e7 100644 --- a/packages/rn-tester/js/components/RNTesterSettingSwitchRow.js +++ b/packages/rn-tester/js/components/RNTesterSettingSwitchRow.js @@ -50,6 +50,7 @@ const styles = StyleSheet.create({ /* $FlowFixMe[cannot-reassign-export] (>=0.85.0 site=react_native_fb) This * comment suppresses an error found when Flow v0.85 was deployed. To see the * error, delete this comment and run Flow. */ +// $FlowFixMe[cannot-reassign] RNTesterSettingSwitchRow = RNTesterStatePersister.createContainer( RNTesterSettingSwitchRow, { diff --git a/repo-config/package.json b/repo-config/package.json index 83772dfa04..ca4ac3eae9 100644 --- a/repo-config/package.json +++ b/repo-config/package.json @@ -36,7 +36,7 @@ "eslint-plugin-react-hooks": "^4.2.0", "eslint-plugin-react-native": "3.10.0", "eslint-plugin-relay": "1.8.1", - "flow-bin": "^0.161.0", + "flow-bin": "^0.162.0", "jest": "^26.6.3", "jest-junit": "^10.0.0", "jscodeshift": "^0.11.0", diff --git a/template/_flowconfig b/template/_flowconfig index 2a173f35c0..f0bc7b9aa3 100644 --- a/template/_flowconfig +++ b/template/_flowconfig @@ -62,4 +62,4 @@ untyped-import untyped-type-import [version] -^0.161.0 +^0.162.0 diff --git a/yarn.lock b/yarn.lock index c9dde3be89..591bd1f148 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3028,10 +3028,10 @@ flatted@^2.0.0: resolved "https://registry.yarnpkg.com/flatted/-/flatted-2.0.2.tgz#4575b21e2bcee7434aa9be662f4b7b5f9c2b5138" integrity sha512-r5wGx7YeOwNWNlCA0wQ86zKyDLMQr+/RB8xy74M4hTphfmjlijTSSXGuH8rnvKZnfT9i+75zmd8jcKdMR4O6jA== -flow-bin@^0.161.0: - version "0.161.0" - resolved "https://registry.yarnpkg.com/flow-bin/-/flow-bin-0.161.0.tgz#1c03ea4a9e3036a8bc639f050bd8dc6f5288e8bb" - integrity sha512-5BKQi+sjOXz67Kbc1teiBwd5e0Da6suW7S5oUCm9VclnzSZ3nlfNZUdrkvgJ5S4w5KDBDToEL7rREpn8rKF1zg== +flow-bin@^0.162.0: + version "0.162.0" + resolved "https://registry.yarnpkg.com/flow-bin/-/flow-bin-0.162.0.tgz#26e3f9db2c93684499c68f1a85e57d888858dc5c" + integrity sha512-AXbDZjRzMQpmvyqeXlS9NV4eNHWGV1Fg/1v6FtuIAu+zsYJJ0mJ2JumqNUxF47rxOoeL9jGtuMxInx9rgqnFCw== flow-parser@0.*, flow-parser@^0.121.0: version "0.121.0" From 678f2cb936ae4cf10e1fa4b032b91bfe9b77efaf Mon Sep 17 00:00:00 2001 From: Luna Wei Date: Thu, 14 Oct 2021 12:00:32 -0700 Subject: [PATCH 55/62] Publish npm, re-order nightly build version Summary: Changelog: [Internal] - Reorder nightly versioning to better support ordering Reviewed By: hramos Differential Revision: D31643453 fbshipit-source-id: 3f1b82085179b435d6920d9e5ae2350419154920 --- scripts/publish-npm.js | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/scripts/publish-npm.js b/scripts/publish-npm.js index 574b174df5..0b9deee0f2 100644 --- a/scripts/publish-npm.js +++ b/scripts/publish-npm.js @@ -91,6 +91,8 @@ if (buildFromMain) { // 34c034298dc9cad5a4553964a5a324450fda0385 const currentCommit = exec('git rev-parse HEAD', {silent: true}).stdout.trim(); + +// Note: We rely on tagsWithVersion to be alphabetically sorted // [34c034298dc9cad5a4553964a5a324450fda0385, refs/heads/0.33-stable, refs/tags/latest, refs/tags/v0.33.1, refs/tags/v0.34.1-rc] const tagsWithVersion = exec(`git ls-remote origin | grep ${currentCommit}`, { silent: true, @@ -103,8 +105,8 @@ const tagsWithVersion = exec(`git ls-remote origin | grep ${currentCommit}`, { ) // ['refs/tags/v0.33.0', 'refs/tags/v0.33.0-rc', 'refs/tags/v0.33.0-rc1', 'refs/tags/v0.33.0-rc2'] .filter(version => version.indexOf(branchVersion) !== -1) - // ['v0.33.0', 'v0.33.0-rc', 'v0.33.0-rc1', 'v0.33.0-rc2'] - .map(version => version.slice('refs/tags/'.length)); + // ['0.33.0', '0.33.0-rc', '0.33.0-rc1', '0.33.0-rc2'] + .map(version => version.slice('refs/tags/v'.length)); if (!buildFromMain && tagsWithVersion.length === 0) { echo( @@ -112,10 +114,11 @@ if (!buildFromMain && tagsWithVersion.length === 0) { ); exit(1); } + let releaseVersion; if (buildFromMain) { - releaseVersion = `0.0.0-${currentCommit.slice(0, 9)}`; + releaseVersion = '0.0.0'; if (nightlyBuild) { releaseVersion += '-'; @@ -126,6 +129,8 @@ if (buildFromMain) { .replace(/[-:]/g, '') .replace(/[T]/g, '-'); } + + releaseVersion += `-${currentCommit.slice(0, 9)}`; // Bump version number in various files (package.json, gradle.properties etc) if ( exec( @@ -138,11 +143,11 @@ if (buildFromMain) { } else if (tagsWithVersion[0].indexOf('-rc') === -1) { // if first tag on this commit is non -rc then we are making a stable release // '0.33.0' - releaseVersion = tagsWithVersion[0].slice(1); + releaseVersion = tagsWithVersion[0]; } else { - // otherwise pick last -rc tag alphabetically - // 0.33.0-rc2 - releaseVersion = tagsWithVersion[tagsWithVersion.length - 1].slice(1); + // otherwise pick last -rc tag, indicates latest rc version due to alpha-sort + // '0.33.0-rc2' + releaseVersion = tagsWithVersion[tagsWithVersion.length - 1]; } // -------- Generating Android Artifacts with JavaDoc From a75e615a90b74e1ea40c119f095940ed44d26fe9 Mon Sep 17 00:00:00 2001 From: Joshua Gross Date: Thu, 14 Oct 2021 15:32:47 -0700 Subject: [PATCH 56/62] Centralize C++ compiler flags in rn_defs.bzl Summary: Centralize C++ compiler flags in rn_defs.bzl. There is really no reason for these Cxx libraries to specify their own compiler flags: nearly 100% of them are identical, and the copypasta makes it difficult to make repo-wide changes (like upgrading C++ versions, etc). This is now causing build failures until everything is migrated properly, and there are two flags (enable_rtti and enable_exceptions) that MUST have the same value and can be configured per-module, as needed. Changelog: [Internal] Reviewed By: mdvacca Differential Revision: D31631767 fbshipit-source-id: 84f0441eb0ad09219e97d13babe0707d25f08472 --- tools/build_defs/oss/rn_defs.bzl | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/tools/build_defs/oss/rn_defs.bzl b/tools/build_defs/oss/rn_defs.bzl index 7064150c9d..45a732449d 100644 --- a/tools/build_defs/oss/rn_defs.bzl +++ b/tools/build_defs/oss/rn_defs.bzl @@ -80,17 +80,39 @@ def get_react_native_preprocessor_flags(): return [] # Building is not supported in OSS right now -def rn_xplat_cxx_library(name, **kwargs): - new_kwargs = { +def rn_xplat_cxx_library(name, compiler_flags_enable_exceptions = True, compiler_flags_enable_rtti = True, **kwargs): + visibility = kwargs.get("visibility", []) + kwargs = { k: v for k, v in kwargs.items() if k.startswith("exported_") } + # RTTI and exceptions must either be both on, or both off + if compiler_flags_enable_exceptions != compiler_flags_enable_rtti: + fail("Must enable or disable both exceptions and RTTI; they cannot be mismatched. See this post for details: https://fb.workplace.com/groups/iosappsize/permalink/2277094415672494/") + + # These are the default compiler flags for ALL React Native Cxx targets. + # For all of these, we PREPEND to compiler_flags: if these are already set + # or being overridden in compiler_flags, it's very likely that the flag is set + # app-wide or that we're otherwise in some special mode. + kwargs["compiler_flags"] = kwargs.get("compiler_flags", []) + kwargs["compiler_flags"] = ["-std=c++17"] + kwargs["compiler_flags"] + kwargs["compiler_flags"] = ["-Wall"] + kwargs["compiler_flags"] + kwargs["compiler_flags"] = ["-Werror"] + kwargs["compiler_flags"] + if compiler_flags_enable_exceptions: + kwargs["compiler_flags"] = ["-fexceptions"] + kwargs["compiler_flags"] + else: + kwargs["compiler_flags"] = ["-fno-exceptions"] + kwargs["compiler_flags"] + if compiler_flags_enable_rtti: + kwargs["compiler_flags"] = ["-frtti"] + kwargs["compiler_flags"] + else: + kwargs["compiler_flags"] = ["-fno-rtti"] + kwargs["compiler_flags"] + native.cxx_library( name = name, - visibility = kwargs.get("visibility", []), - **new_kwargs + visibility = visibility, + **kwargs ) rn_xplat_cxx_library2 = rn_xplat_cxx_library From b60e229d7f57f9ba79d984b85925f979290d31bf Mon Sep 17 00:00:00 2001 From: Joshua Gross Date: Thu, 14 Oct 2021 15:32:47 -0700 Subject: [PATCH 57/62] Remove compiler_flags from BUCK modules Summary: Nearly all of these are identical and these compiler_flags are now centralized in rn_defs.bzl. This should have NO CHANGE on build configuration, the flags have just moved for now. Changelog: [Internal] Reviewed By: mdvacca Differential Revision: D31631766 fbshipit-source-id: be40ebeb70ae52b7ded07ca08c4a29f10a0ed925 --- .../com/facebook/hermes/instrumentation/BUCK | 3 ++- .../facebook/react/common/mapbuffer/jni/BUCK | 6 ------ .../java/com/facebook/react/fabric/jni/BUCK | 6 ------ .../java/com/facebook/react/jscexecutor/BUCK | 3 ++- .../com/facebook/react/modules/blob/jni/BUCK | 6 ------ .../facebook/react/reactperflogger/jni/BUCK | 6 ------ .../facebook/react/turbomodule/core/jni/BUCK | 12 ------------ .../java/com/facebook/react/uimanager/jni/BUCK | 6 ------ ReactAndroid/src/main/jni/react/jni/BUCK | 5 ----- ReactAndroid/src/main/jni/react/perftests/BUCK | 4 ---- ReactCommon/better/BUCK | 6 ------ ReactCommon/callinvoker/BUCK | 6 ------ ReactCommon/cxxreact/BUCK | 17 +---------------- ReactCommon/jsi/BUCK | 9 --------- ReactCommon/jsinspector/BUCK | 5 ----- ReactCommon/logger/BUCK | 5 ----- ReactCommon/react/config/BUCK | 6 ------ ReactCommon/react/debug/BUCK | 6 ------ ReactCommon/react/nativemodule/core/BUCK | 5 ----- ReactCommon/react/nativemodule/samples/BUCK | 7 ------- ReactCommon/react/renderer/animations/BUCK | 4 ---- .../react/renderer/attributedstring/BUCK | 6 ------ .../react/renderer/componentregistry/BUCK | 6 ------ .../renderer/componentregistry/native/BUCK | 6 ------ .../react/renderer/components/image/BUCK | 6 ------ .../renderer/components/inputaccessory/BUCK | 6 ------ .../components/legacyviewmanagerinterop/BUCK | 6 ------ .../react/renderer/components/modal/BUCK | 6 ------ .../react/renderer/components/progressbar/BUCK | 6 ------ .../react/renderer/components/root/BUCK | 6 ------ .../renderer/components/safeareaview/BUCK | 6 ------ .../react/renderer/components/scrollview/BUCK | 6 ------ .../react/renderer/components/slider/BUCK | 6 ------ .../react/renderer/components/switch/BUCK | 6 ------ .../react/renderer/components/text/BUCK | 6 ------ .../react/renderer/components/textinput/BUCK | 6 ------ .../androidtextinput/AndroidTextInputProps.h | 2 ++ .../components/textinput/iostextinput/BUCK | 6 ------ .../renderer/components/unimplementedview/BUCK | 6 ------ .../react/renderer/components/view/BUCK | 6 ------ ReactCommon/react/renderer/core/BUCK | 6 ------ ReactCommon/react/renderer/debug/BUCK | 6 ------ ReactCommon/react/renderer/element/BUCK | 6 ------ ReactCommon/react/renderer/graphics/BUCK | 6 ------ ReactCommon/react/renderer/imagemanager/BUCK | 6 ------ ReactCommon/react/renderer/leakchecker/BUCK | 6 ------ ReactCommon/react/renderer/mapbuffer/BUCK | 6 ------ ReactCommon/react/renderer/mounting/BUCK | 6 ------ .../react/renderer/runtimescheduler/BUCK | 6 ------ ReactCommon/react/renderer/scheduler/BUCK | 6 ------ ReactCommon/react/renderer/telemetry/BUCK | 6 ------ .../react/renderer/templateprocessor/BUCK | 6 ------ .../react/renderer/textlayoutmanager/BUCK | 6 ------ ReactCommon/react/renderer/timeline/BUCK | 6 ------ ReactCommon/react/renderer/uimanager/BUCK | 6 ------ ReactCommon/react/test_utils/BUCK | 6 ------ ReactCommon/react/utils/BUCK | 6 ------ ReactCommon/reactperflogger/BUCK | 4 ---- ReactCommon/runtimeexecutor/BUCK | 6 ------ ReactCommon/yoga/BUCK | 6 +----- packages/react-native-codegen/BUCK | 12 ------------ packages/react-native-codegen/DEFS.bzl | 18 ------------------ 62 files changed, 8 insertions(+), 383 deletions(-) diff --git a/ReactAndroid/src/main/java/com/facebook/hermes/instrumentation/BUCK b/ReactAndroid/src/main/java/com/facebook/hermes/instrumentation/BUCK index c78901a85f..ead8aae637 100644 --- a/ReactAndroid/src/main/java/com/facebook/hermes/instrumentation/BUCK +++ b/ReactAndroid/src/main/java/com/facebook/hermes/instrumentation/BUCK @@ -31,7 +31,8 @@ rn_xplat_cxx_library( ], headers = ["HermesSamplingProfiler.h"], header_namespace = "", - compiler_flags = ["-fexceptions"], + compiler_flags_enable_exceptions = True, # TODO: is this necessary? + compiler_flags_enable_rtti = True, # TODO: is this necessary? labels = ["supermodule:xplat/default/public.react_native.infra"], platforms = ANDROID, soname = "libjsijniprofiler.$(ext)", diff --git a/ReactAndroid/src/main/java/com/facebook/react/common/mapbuffer/jni/BUCK b/ReactAndroid/src/main/java/com/facebook/react/common/mapbuffer/jni/BUCK index 0e5d2d726d..c2ac7a7ffb 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/common/mapbuffer/jni/BUCK +++ b/ReactAndroid/src/main/java/com/facebook/react/common/mapbuffer/jni/BUCK @@ -11,12 +11,6 @@ rn_xplat_cxx_library( ], prefix = "react/common/mapbuffer", ), - compiler_flags = [ - "-fexceptions", - "-frtti", - "-std=c++17", - "-Wall", - ], fbandroid_allow_jni_merging = True, labels = ["supermodule:xplat/default/public.react_native.infra"], platforms = ANDROID, diff --git a/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/BUCK b/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/BUCK index a534958295..c4297f303a 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/BUCK +++ b/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/BUCK @@ -11,12 +11,6 @@ rn_xplat_cxx_library( ], prefix = "react/fabric", ), - compiler_flags = [ - "-fexceptions", - "-frtti", - "-std=c++17", - "-Wall", - ], fbandroid_allow_jni_merging = True, labels = ["supermodule:xplat/default/public.react_native.infra"], platforms = ANDROID, diff --git a/ReactAndroid/src/main/java/com/facebook/react/jscexecutor/BUCK b/ReactAndroid/src/main/java/com/facebook/react/jscexecutor/BUCK index d601632a0f..54036fce0c 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/jscexecutor/BUCK +++ b/ReactAndroid/src/main/java/com/facebook/react/jscexecutor/BUCK @@ -20,7 +20,8 @@ rn_xplat_cxx_library( srcs = glob(["*.cpp"]), headers = glob(["*.h"]), header_namespace = "", - compiler_flags = ["-fexceptions"], + compiler_flags_enable_exceptions = True, # TODO: is this necessary? + compiler_flags_enable_rtti = True, # TODO: is this necessary? fbandroid_allow_jni_merging = True, platforms = ANDROID, soname = "libjscexecutor.$(ext)", diff --git a/ReactAndroid/src/main/java/com/facebook/react/modules/blob/jni/BUCK b/ReactAndroid/src/main/java/com/facebook/react/modules/blob/jni/BUCK index a6e6c32e36..e706c5bba9 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/modules/blob/jni/BUCK +++ b/ReactAndroid/src/main/java/com/facebook/react/modules/blob/jni/BUCK @@ -5,12 +5,6 @@ rn_xplat_cxx_library( srcs = glob(["*.cpp"]), headers = glob(["*.h"]), header_namespace = "", - compiler_flags = [ - "-fexceptions", - "-frtti", - "-std=c++17", - "-Wall", - ], labels = ["supermodule:xplat/default/public.react_native.infra"], platforms = ANDROID, soname = "libreactnativeblob.$(ext)", diff --git a/ReactAndroid/src/main/java/com/facebook/react/reactperflogger/jni/BUCK b/ReactAndroid/src/main/java/com/facebook/react/reactperflogger/jni/BUCK index cd3246bef1..956b28f2a6 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/reactperflogger/jni/BUCK +++ b/ReactAndroid/src/main/java/com/facebook/react/reactperflogger/jni/BUCK @@ -9,12 +9,6 @@ rn_xplat_cxx_library( exported_headers = { "reactperflogger/JNativeModulePerfLogger.h": "reactperflogger/JNativeModulePerfLogger.h", }, - compiler_flags = [ - "-fexceptions", - "-frtti", - "-std=c++17", - "-Wall", - ], fbandroid_allow_jni_merging = True, fbandroid_labels = [ "supermodule:xplat/default/public.react_native.infra", diff --git a/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/jni/BUCK b/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/jni/BUCK index 96ade8eaea..4291e2ae40 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/jni/BUCK +++ b/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/jni/BUCK @@ -11,12 +11,6 @@ rn_xplat_cxx_library( "ReactCommon/TurboModuleManager.h": "ReactCommon/TurboModuleManager.h", "ReactCommon/TurboModuleManagerDelegate.h": "ReactCommon/TurboModuleManagerDelegate.h", }, - compiler_flags = [ - "-fexceptions", - "-frtti", - "-std=c++17", - "-Wall", - ], labels = ["supermodule:xplat/default/public.react_native.infra"], platforms = ANDROID, preprocessor_flags = [ @@ -49,12 +43,6 @@ rn_xplat_cxx_library( exported_headers = { "ReactCommon/CallInvokerHolder.h": "ReactCommon/CallInvokerHolder.h", }, - compiler_flags = [ - "-fexceptions", - "-frtti", - "-std=c++17", - "-Wall", - ], fbandroid_deps = [ FBJNI_TARGET, ], diff --git a/ReactAndroid/src/main/java/com/facebook/react/uimanager/jni/BUCK b/ReactAndroid/src/main/java/com/facebook/react/uimanager/jni/BUCK index de23756429..5ded791923 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/uimanager/jni/BUCK +++ b/ReactAndroid/src/main/java/com/facebook/react/uimanager/jni/BUCK @@ -11,12 +11,6 @@ rn_xplat_cxx_library( ], prefix = "react/uimanager/jni", ), - compiler_flags = [ - "-fexceptions", - "-frtti", - "-std=c++17", - "-Wall", - ], fbandroid_allow_jni_merging = True, labels = ["supermodule:xplat/default/public.react_native.infra"], platforms = ANDROID, diff --git a/ReactAndroid/src/main/jni/react/jni/BUCK b/ReactAndroid/src/main/jni/react/jni/BUCK index 99160d55a3..39514497ec 100644 --- a/ReactAndroid/src/main/jni/react/jni/BUCK +++ b/ReactAndroid/src/main/jni/react/jni/BUCK @@ -35,11 +35,6 @@ rn_xplat_cxx_library( header_namespace = "react/jni", exported_headers = EXPORTED_HEADERS, compiler_flags = [ - "-Wall", - "-Werror", - "-fexceptions", - "-std=c++1y", - "-frtti", "-Wno-pessimizing-move", "-Wno-inconsistent-missing-override", ], diff --git a/ReactAndroid/src/main/jni/react/perftests/BUCK b/ReactAndroid/src/main/jni/react/perftests/BUCK index fbff1d6525..3675a6157b 100644 --- a/ReactAndroid/src/main/jni/react/perftests/BUCK +++ b/ReactAndroid/src/main/jni/react/perftests/BUCK @@ -3,10 +3,6 @@ load("//tools/build_defs/oss:rn_defs.bzl", "ANDROID", "react_native_xplat_target rn_xplat_cxx_library( name = "perftests", srcs = ["OnLoad.cpp"], - compiler_flags = [ - "-fexceptions", - "-std=c++1y", - ], platforms = ANDROID, soname = "libnativereactperftests.$(ext)", visibility = [ diff --git a/ReactCommon/better/BUCK b/ReactCommon/better/BUCK index 1bff7fd857..c287ec7965 100644 --- a/ReactCommon/better/BUCK +++ b/ReactCommon/better/BUCK @@ -29,12 +29,6 @@ rn_xplat_cxx_library( ], prefix = "better", ), - compiler_flags = [ - "-fexceptions", - "-frtti", - "-std=c++17", - "-Wall", - ], fbobjc_compiler_flags = APPLE_COMPILER_FLAGS, fbobjc_preprocessor_flags = get_preprocessor_flags_for_build_mode() + get_apple_inspector_flags(), force_static = True, diff --git a/ReactCommon/callinvoker/BUCK b/ReactCommon/callinvoker/BUCK index b86dfb7c9a..d6ff5cdb39 100644 --- a/ReactCommon/callinvoker/BUCK +++ b/ReactCommon/callinvoker/BUCK @@ -10,12 +10,6 @@ rn_xplat_cxx_library( ], prefix = "ReactCommon", ), - compiler_flags = [ - "-fexceptions", - "-frtti", - "-std=c++17", - "-Wall", - ], labels = ["supermodule:xplat/default/public.react_native.infra"], platforms = (ANDROID, APPLE, CXX), preferred_linkage = "static", diff --git a/ReactCommon/cxxreact/BUCK b/ReactCommon/cxxreact/BUCK index 095e3d98b2..a662a78414 100644 --- a/ReactCommon/cxxreact/BUCK +++ b/ReactCommon/cxxreact/BUCK @@ -1,11 +1,6 @@ load("@fbsource//tools/build_defs:glob_defs.bzl", "subdir_glob") load("//tools/build_defs/oss:rn_defs.bzl", "ANDROID", "APPLE", "get_android_inspector_flags", "get_apple_compiler_flags", "get_apple_inspector_flags", "get_preprocessor_flags_for_build_mode", "react_native_xplat_target", "rn_xplat_cxx_library") -CXX_LIBRARY_COMPILER_FLAGS = [ - "-std=c++17", - "-Wall", -] - rn_xplat_cxx_library( name = "module", header_namespace = "", @@ -17,7 +12,6 @@ rn_xplat_cxx_library( ], prefix = "cxxreact", ), - compiler_flags = CXX_LIBRARY_COMPILER_FLAGS, fbobjc_compiler_flags = get_apple_compiler_flags(), force_static = True, labels = ["supermodule:xplat/default/public.react_native.infra"], @@ -39,10 +33,6 @@ rn_xplat_cxx_library( [("", "JSBigString.h")], prefix = "cxxreact", ), - compiler_flags = CXX_LIBRARY_COMPILER_FLAGS + [ - "-fexceptions", - "-frtti", - ], fbobjc_compiler_flags = get_apple_compiler_flags(), force_static = True, labels = ["supermodule:xplat/default/public.react_native.infra"], @@ -61,9 +51,8 @@ rn_xplat_cxx_library( srcs = ["SampleCxxModule.cpp"], header_namespace = "", exported_headers = ["SampleCxxModule.h"], - compiler_flags = CXX_LIBRARY_COMPILER_FLAGS + [ + compiler_flags = [ "-fno-omit-frame-pointer", - "-fexceptions", ], fbobjc_compiler_flags = get_apple_compiler_flags(), labels = ["supermodule:xplat/default/public.react_native.infra"], @@ -120,10 +109,6 @@ rn_xplat_cxx_library( ) for header in CXXREACT_PUBLIC_HEADERS ]), - compiler_flags = CXX_LIBRARY_COMPILER_FLAGS + [ - "-fexceptions", - "-frtti", - ], fbandroid_preprocessor_flags = get_android_inspector_flags(), fbobjc_compiler_flags = get_apple_compiler_flags(), fbobjc_force_static = True, diff --git a/ReactCommon/jsi/BUCK b/ReactCommon/jsi/BUCK index 1fc3de0f7d..a3bfde64b9 100644 --- a/ReactCommon/jsi/BUCK +++ b/ReactCommon/jsi/BUCK @@ -14,11 +14,6 @@ rn_xplat_cxx_library( ], compiler_flags = [ "-O3", - "-fexceptions", - "-frtti", - "-std=c++17", - "-Wall", - "-Werror", "-Wextra", "-Wcast-qual", "-Wdelete-non-virtual-dtor", @@ -45,10 +40,6 @@ rn_xplat_cxx_library( exported_headers = [ "jsi/JSIDynamic.h", ], - compiler_flags = [ - "-fexceptions", - "-frtti", - ], fbobjc_force_static = True, labels = ["supermodule:xplat/default/public.react_native.infra"], visibility = [ diff --git a/ReactCommon/jsinspector/BUCK b/ReactCommon/jsinspector/BUCK index 1a7502a5fd..c298131a29 100644 --- a/ReactCommon/jsinspector/BUCK +++ b/ReactCommon/jsinspector/BUCK @@ -26,11 +26,6 @@ rn_xplat_cxx_library( ], prefix = "jsinspector", ), - compiler_flags = [ - "-Wall", - "-fexceptions", - "-std=c++1y", - ], fbandroid_preferred_linkage = "shared", labels = ["supermodule:xplat/default/public.react_native.infra"], platforms = (ANDROID, APPLE, CXX, FBCODE, WINDOWS), diff --git a/ReactCommon/logger/BUCK b/ReactCommon/logger/BUCK index c40d9fbe17..59976e3cb0 100644 --- a/ReactCommon/logger/BUCK +++ b/ReactCommon/logger/BUCK @@ -26,11 +26,6 @@ rn_xplat_cxx_library( ], prefix = "logger", ), - compiler_flags = [ - "-Wall", - "-fexceptions", - "-std=c++17", - ], fbandroid_preferred_linkage = "shared", labels = ["supermodule:xplat/default/public.react_native.infra"], platforms = (ANDROID, APPLE, CXX, FBCODE, WINDOWS), diff --git a/ReactCommon/react/config/BUCK b/ReactCommon/react/config/BUCK index 2cadc9a297..3fec8b7c1d 100644 --- a/ReactCommon/react/config/BUCK +++ b/ReactCommon/react/config/BUCK @@ -18,12 +18,6 @@ rn_xplat_cxx_library( ], prefix = "react/config", ), - compiler_flags = [ - "-fexceptions", - "-frtti", - "-std=c++17", - "-Wall", - ], fbobjc_compiler_flags = APPLE_COMPILER_FLAGS, fbobjc_preprocessor_flags = get_preprocessor_flags_for_build_mode() + get_apple_inspector_flags(), force_static = True, diff --git a/ReactCommon/react/debug/BUCK b/ReactCommon/react/debug/BUCK index 55c5584d26..603c6146e5 100644 --- a/ReactCommon/react/debug/BUCK +++ b/ReactCommon/react/debug/BUCK @@ -29,12 +29,6 @@ rn_xplat_cxx_library( ], prefix = "react/debug", ), - compiler_flags = [ - "-fexceptions", - "-frtti", - "-std=c++17", - "-Wall", - ], exported_platform_linker_flags = [ ( "^android.*", diff --git a/ReactCommon/react/nativemodule/core/BUCK b/ReactCommon/react/nativemodule/core/BUCK index 93321356d6..b0e29b37c2 100644 --- a/ReactCommon/react/nativemodule/core/BUCK +++ b/ReactCommon/react/nativemodule/core/BUCK @@ -13,10 +13,6 @@ rn_xplat_cxx_library( prefix = "ReactCommon", ), compiler_flags = [ - "-fexceptions", - "-frtti", - "-std=c++17", - "-Wall", "-Wno-global-constructors", ], fbandroid_deps = [ @@ -35,7 +31,6 @@ rn_xplat_cxx_library( ], ), fbobjc_compiler_flags = [ - "-Wall", "-fobjc-arc-exceptions", ], fbobjc_inherited_buck_flags = get_static_library_ios_flags(), diff --git a/ReactCommon/react/nativemodule/samples/BUCK b/ReactCommon/react/nativemodule/samples/BUCK index 693bf74aaf..d3ef2a8d95 100644 --- a/ReactCommon/react/nativemodule/samples/BUCK +++ b/ReactCommon/react/nativemodule/samples/BUCK @@ -12,12 +12,6 @@ rn_xplat_cxx_library( ], prefix = "ReactCommon", ), - compiler_flags = [ - "-fexceptions", - "-frtti", - "-std=c++17", - "-Wall", - ], fbandroid_deps = [ react_native_target("jni/react/jni:jni"), FBJNI_TARGET, @@ -34,7 +28,6 @@ rn_xplat_cxx_library( ], ), fbobjc_compiler_flags = [ - "-Wall", "-fobjc-arc-exceptions", ], fbobjc_inherited_buck_flags = get_static_library_ios_flags(), diff --git a/ReactCommon/react/renderer/animations/BUCK b/ReactCommon/react/renderer/animations/BUCK index 1998f8d971..72a29efdfc 100644 --- a/ReactCommon/react/renderer/animations/BUCK +++ b/ReactCommon/react/renderer/animations/BUCK @@ -32,10 +32,6 @@ rn_xplat_cxx_library( prefix = "react/renderer/animations", ), compiler_flags = [ - "-fexceptions", - "-frtti", - "-std=c++17", - "-Wall", "-lm", ], fbobjc_compiler_flags = APPLE_COMPILER_FLAGS, diff --git a/ReactCommon/react/renderer/attributedstring/BUCK b/ReactCommon/react/renderer/attributedstring/BUCK index c6d8371a41..4c79645fcf 100644 --- a/ReactCommon/react/renderer/attributedstring/BUCK +++ b/ReactCommon/react/renderer/attributedstring/BUCK @@ -31,12 +31,6 @@ rn_xplat_cxx_library( ], prefix = "react/renderer/attributedstring", ), - compiler_flags = [ - "-fexceptions", - "-frtti", - "-std=c++17", - "-Wall", - ], fbandroid_deps = [ react_native_xplat_target("react/renderer/mapbuffer:mapbuffer"), ], diff --git a/ReactCommon/react/renderer/componentregistry/BUCK b/ReactCommon/react/renderer/componentregistry/BUCK index a9f8d69717..4ffce4a8be 100644 --- a/ReactCommon/react/renderer/componentregistry/BUCK +++ b/ReactCommon/react/renderer/componentregistry/BUCK @@ -30,12 +30,6 @@ rn_xplat_cxx_library( ], prefix = "react/renderer/componentregistry", ), - compiler_flags = [ - "-fexceptions", - "-frtti", - "-std=c++17", - "-Wall", - ], fbobjc_compiler_flags = APPLE_COMPILER_FLAGS, fbobjc_preprocessor_flags = get_preprocessor_flags_for_build_mode() + get_apple_inspector_flags(), force_static = True, diff --git a/ReactCommon/react/renderer/componentregistry/native/BUCK b/ReactCommon/react/renderer/componentregistry/native/BUCK index c60fb13920..a6aceadb76 100644 --- a/ReactCommon/react/renderer/componentregistry/native/BUCK +++ b/ReactCommon/react/renderer/componentregistry/native/BUCK @@ -29,12 +29,6 @@ rn_xplat_cxx_library( ], prefix = "react/renderer/componentregistry/native", ), - compiler_flags = [ - "-fexceptions", - "-frtti", - "-std=c++17", - "-Wall", - ], fbobjc_compiler_flags = APPLE_COMPILER_FLAGS, fbobjc_preprocessor_flags = get_preprocessor_flags_for_build_mode() + get_apple_inspector_flags(), force_static = True, diff --git a/ReactCommon/react/renderer/components/image/BUCK b/ReactCommon/react/renderer/components/image/BUCK index 44fbbfe147..36ad159d49 100644 --- a/ReactCommon/react/renderer/components/image/BUCK +++ b/ReactCommon/react/renderer/components/image/BUCK @@ -29,12 +29,6 @@ rn_xplat_cxx_library( ], prefix = "react/renderer/components/image", ), - compiler_flags = [ - "-fexceptions", - "-frtti", - "-std=c++17", - "-Wall", - ], fbandroid_deps = [ react_native_xplat_target("react/renderer/mapbuffer:mapbuffer"), ], diff --git a/ReactCommon/react/renderer/components/inputaccessory/BUCK b/ReactCommon/react/renderer/components/inputaccessory/BUCK index 3cddfd26af..f50bb4337b 100644 --- a/ReactCommon/react/renderer/components/inputaccessory/BUCK +++ b/ReactCommon/react/renderer/components/inputaccessory/BUCK @@ -24,12 +24,6 @@ rn_xplat_cxx_library( ], prefix = "react/renderer/components/inputaccessory", ), - compiler_flags = [ - "-fexceptions", - "-frtti", - "-std=c++17", - "-Wall", - ], fbobjc_compiler_flags = APPLE_COMPILER_FLAGS, fbobjc_preprocessor_flags = get_preprocessor_flags_for_build_mode() + get_apple_inspector_flags(), force_static = True, diff --git a/ReactCommon/react/renderer/components/legacyviewmanagerinterop/BUCK b/ReactCommon/react/renderer/components/legacyviewmanagerinterop/BUCK index 93ee20de39..6a5f2da93f 100644 --- a/ReactCommon/react/renderer/components/legacyviewmanagerinterop/BUCK +++ b/ReactCommon/react/renderer/components/legacyviewmanagerinterop/BUCK @@ -27,12 +27,6 @@ rn_xplat_cxx_library( ], prefix = "react/renderer/components/legacyviewmanagerinterop", ), - compiler_flags = [ - "-fexceptions", - "-frtti", - "-std=c++17", - "-Wall", - ], fbobjc_compiler_flags = APPLE_COMPILER_FLAGS, fbobjc_preprocessor_flags = get_preprocessor_flags_for_build_mode() + get_apple_inspector_flags(), force_static = True, diff --git a/ReactCommon/react/renderer/components/modal/BUCK b/ReactCommon/react/renderer/components/modal/BUCK index 1b7d859bc1..10c9e229be 100644 --- a/ReactCommon/react/renderer/components/modal/BUCK +++ b/ReactCommon/react/renderer/components/modal/BUCK @@ -31,12 +31,6 @@ rn_xplat_cxx_library( ], prefix = "react/renderer/components/modal", ), - compiler_flags = [ - "-fexceptions", - "-frtti", - "-std=c++17", - "-Wall", - ], fbandroid_deps = [ react_native_xplat_target("react/renderer/mapbuffer:mapbuffer"), ], diff --git a/ReactCommon/react/renderer/components/progressbar/BUCK b/ReactCommon/react/renderer/components/progressbar/BUCK index f9c4c3ea33..b45bde96a1 100644 --- a/ReactCommon/react/renderer/components/progressbar/BUCK +++ b/ReactCommon/react/renderer/components/progressbar/BUCK @@ -32,12 +32,6 @@ rn_xplat_cxx_library( ], prefix = "react/renderer/components/progressbar", ), - compiler_flags = [ - "-fexceptions", - "-frtti", - "-std=c++17", - "-Wall", - ], cxx_tests = [":tests"], fbandroid_deps = [ react_native_target("jni/react/jni:jni"), diff --git a/ReactCommon/react/renderer/components/root/BUCK b/ReactCommon/react/renderer/components/root/BUCK index b09dc8c12d..59cd4b32a0 100644 --- a/ReactCommon/react/renderer/components/root/BUCK +++ b/ReactCommon/react/renderer/components/root/BUCK @@ -29,12 +29,6 @@ rn_xplat_cxx_library( ], prefix = "react/renderer/components/root", ), - compiler_flags = [ - "-fexceptions", - "-frtti", - "-std=c++17", - "-Wall", - ], fbobjc_compiler_flags = APPLE_COMPILER_FLAGS, fbobjc_preprocessor_flags = get_preprocessor_flags_for_build_mode() + get_apple_inspector_flags(), labels = ["supermodule:xplat/default/public.react_native.infra"], diff --git a/ReactCommon/react/renderer/components/safeareaview/BUCK b/ReactCommon/react/renderer/components/safeareaview/BUCK index fcb7febca1..fb85f5b0f0 100644 --- a/ReactCommon/react/renderer/components/safeareaview/BUCK +++ b/ReactCommon/react/renderer/components/safeareaview/BUCK @@ -24,12 +24,6 @@ rn_xplat_cxx_library( ], prefix = "react/renderer/components/safeareaview", ), - compiler_flags = [ - "-fexceptions", - "-frtti", - "-std=c++17", - "-Wall", - ], fbobjc_compiler_flags = APPLE_COMPILER_FLAGS, fbobjc_preprocessor_flags = get_preprocessor_flags_for_build_mode() + get_apple_inspector_flags(), force_static = True, diff --git a/ReactCommon/react/renderer/components/scrollview/BUCK b/ReactCommon/react/renderer/components/scrollview/BUCK index f75195782d..d5c0d3f246 100644 --- a/ReactCommon/react/renderer/components/scrollview/BUCK +++ b/ReactCommon/react/renderer/components/scrollview/BUCK @@ -32,12 +32,6 @@ rn_xplat_cxx_library( ], prefix = "react/renderer/components/scrollview", ), - compiler_flags = [ - "-fexceptions", - "-frtti", - "-std=c++17", - "-Wall", - ], fbandroid_deps = [ react_native_xplat_target("react/renderer/mapbuffer:mapbuffer"), ], diff --git a/ReactCommon/react/renderer/components/slider/BUCK b/ReactCommon/react/renderer/components/slider/BUCK index dd7d12dc28..01ac302615 100644 --- a/ReactCommon/react/renderer/components/slider/BUCK +++ b/ReactCommon/react/renderer/components/slider/BUCK @@ -33,12 +33,6 @@ rn_xplat_cxx_library( ], prefix = "react/renderer/components/slider", ), - compiler_flags = [ - "-fexceptions", - "-frtti", - "-std=c++17", - "-Wall", - ], cxx_tests = [":tests"], fbandroid_deps = [ react_native_target("jni/react/jni:jni"), diff --git a/ReactCommon/react/renderer/components/switch/BUCK b/ReactCommon/react/renderer/components/switch/BUCK index f26b6ba660..82ca7c4074 100644 --- a/ReactCommon/react/renderer/components/switch/BUCK +++ b/ReactCommon/react/renderer/components/switch/BUCK @@ -34,12 +34,6 @@ rn_xplat_cxx_library( ], prefix = "react/renderer/components/androidswitch", ), - compiler_flags = [ - "-fexceptions", - "-frtti", - "-std=c++17", - "-Wall", - ], cxx_tests = [":tests"], fbandroid_deps = [ react_native_target("jni/react/jni:jni"), diff --git a/ReactCommon/react/renderer/components/text/BUCK b/ReactCommon/react/renderer/components/text/BUCK index 660a7f2e0f..47f41977a1 100644 --- a/ReactCommon/react/renderer/components/text/BUCK +++ b/ReactCommon/react/renderer/components/text/BUCK @@ -36,12 +36,6 @@ rn_xplat_cxx_library( ], prefix = "react/renderer/components/text", ), - compiler_flags = [ - "-fexceptions", - "-frtti", - "-std=c++17", - "-Wall", - ], cxx_tests = [":tests"], fbandroid_deps = [ react_native_xplat_target("react/renderer/mapbuffer:mapbuffer"), diff --git a/ReactCommon/react/renderer/components/textinput/BUCK b/ReactCommon/react/renderer/components/textinput/BUCK index ad12c3b63e..76f69e93aa 100644 --- a/ReactCommon/react/renderer/components/textinput/BUCK +++ b/ReactCommon/react/renderer/components/textinput/BUCK @@ -33,12 +33,6 @@ rn_xplat_cxx_library( ], prefix = "react/renderer/components/androidtextinput", ), - compiler_flags = [ - "-fexceptions", - "-frtti", - "-std=c++17", - "-Wall", - ], cxx_tests = [":tests"], fbandroid_deps = [ react_native_xplat_target("react/renderer/mapbuffer:mapbuffer"), diff --git a/ReactCommon/react/renderer/components/textinput/androidtextinput/react/renderer/components/androidtextinput/AndroidTextInputProps.h b/ReactCommon/react/renderer/components/textinput/androidtextinput/react/renderer/components/androidtextinput/AndroidTextInputProps.h index 07daa9e2cd..34048ddf91 100644 --- a/ReactCommon/react/renderer/components/textinput/androidtextinput/react/renderer/components/androidtextinput/AndroidTextInputProps.h +++ b/ReactCommon/react/renderer/components/textinput/androidtextinput/react/renderer/components/androidtextinput/AndroidTextInputProps.h @@ -7,6 +7,8 @@ #pragma once +// foo bar 2 + // #include #include #include diff --git a/ReactCommon/react/renderer/components/textinput/iostextinput/BUCK b/ReactCommon/react/renderer/components/textinput/iostextinput/BUCK index b6c933480d..414f2d3985 100644 --- a/ReactCommon/react/renderer/components/textinput/iostextinput/BUCK +++ b/ReactCommon/react/renderer/components/textinput/iostextinput/BUCK @@ -33,12 +33,6 @@ rn_xplat_cxx_library( # TODO(shergin) T26519801 Figure out better directories structure prefix = "react/renderer/components/iostextinput", ), - compiler_flags = [ - "-fexceptions", - "-frtti", - "-std=c++17", - "-Wall", - ], cxx_tests = [":tests"], fbobjc_compiler_flags = APPLE_COMPILER_FLAGS, fbobjc_preprocessor_flags = get_preprocessor_flags_for_build_mode() + get_apple_inspector_flags(), diff --git a/ReactCommon/react/renderer/components/unimplementedview/BUCK b/ReactCommon/react/renderer/components/unimplementedview/BUCK index b3c76b9d7d..8e59dd374a 100644 --- a/ReactCommon/react/renderer/components/unimplementedview/BUCK +++ b/ReactCommon/react/renderer/components/unimplementedview/BUCK @@ -29,12 +29,6 @@ rn_xplat_cxx_library( ], prefix = "react/renderer/components/unimplementedview", ), - compiler_flags = [ - "-fexceptions", - "-frtti", - "-std=c++17", - "-Wall", - ], fbobjc_compiler_flags = APPLE_COMPILER_FLAGS, fbobjc_preprocessor_flags = get_preprocessor_flags_for_build_mode() + get_apple_inspector_flags(), labels = ["supermodule:xplat/default/public.react_native.infra"], diff --git a/ReactCommon/react/renderer/components/view/BUCK b/ReactCommon/react/renderer/components/view/BUCK index c3640ab3b4..d78b21f2cf 100644 --- a/ReactCommon/react/renderer/components/view/BUCK +++ b/ReactCommon/react/renderer/components/view/BUCK @@ -35,12 +35,6 @@ rn_xplat_cxx_library( ], prefix = "react/renderer/components/view", ), - compiler_flags = [ - "-fexceptions", - "-frtti", - "-std=c++17", - "-Wall", - ], fbobjc_compiler_flags = APPLE_COMPILER_FLAGS, fbobjc_preprocessor_flags = get_preprocessor_flags_for_build_mode() + get_apple_inspector_flags(), force_static = True, diff --git a/ReactCommon/react/renderer/core/BUCK b/ReactCommon/react/renderer/core/BUCK index 8ed779f428..f10420823e 100644 --- a/ReactCommon/react/renderer/core/BUCK +++ b/ReactCommon/react/renderer/core/BUCK @@ -32,12 +32,6 @@ rn_xplat_cxx_library( ], prefix = "react/renderer/core", ), - compiler_flags = [ - "-fexceptions", - "-frtti", - "-std=c++17", - "-Wall", - ], fbobjc_compiler_flags = APPLE_COMPILER_FLAGS, fbobjc_preprocessor_flags = get_preprocessor_flags_for_build_mode() + get_apple_inspector_flags(), force_static = True, diff --git a/ReactCommon/react/renderer/debug/BUCK b/ReactCommon/react/renderer/debug/BUCK index 26e3e9f793..e4b2ee2303 100644 --- a/ReactCommon/react/renderer/debug/BUCK +++ b/ReactCommon/react/renderer/debug/BUCK @@ -31,12 +31,6 @@ rn_xplat_cxx_library( ], prefix = "react/renderer/debug", ), - compiler_flags = [ - "-fexceptions", - "-frtti", - "-std=c++17", - "-Wall", - ], fbobjc_compiler_flags = APPLE_COMPILER_FLAGS, fbobjc_preprocessor_flags = get_preprocessor_flags_for_build_mode() + get_apple_inspector_flags(), force_static = True, diff --git a/ReactCommon/react/renderer/element/BUCK b/ReactCommon/react/renderer/element/BUCK index 88712f5595..6db4cf614b 100644 --- a/ReactCommon/react/renderer/element/BUCK +++ b/ReactCommon/react/renderer/element/BUCK @@ -31,12 +31,6 @@ rn_xplat_cxx_library( ], prefix = "react/renderer/element", ), - compiler_flags = [ - "-fexceptions", - "-frtti", - "-std=c++17", - "-Wall", - ], fbobjc_compiler_flags = APPLE_COMPILER_FLAGS, fbobjc_preprocessor_flags = get_preprocessor_flags_for_build_mode() + get_apple_inspector_flags(), force_static = True, diff --git a/ReactCommon/react/renderer/graphics/BUCK b/ReactCommon/react/renderer/graphics/BUCK index 7c300c3c3e..34748db242 100644 --- a/ReactCommon/react/renderer/graphics/BUCK +++ b/ReactCommon/react/renderer/graphics/BUCK @@ -36,12 +36,6 @@ rn_xplat_cxx_library( ], prefix = "react/renderer/graphics", ), - compiler_flags = [ - "-fexceptions", - "-frtti", - "-std=c++17", - "-Wall", - ], cxx_exported_headers = subdir_glob( [ ("platform/cxx/react/renderer/graphics", "**/*.h"), diff --git a/ReactCommon/react/renderer/imagemanager/BUCK b/ReactCommon/react/renderer/imagemanager/BUCK index 8227c1dd68..557d5f3c29 100644 --- a/ReactCommon/react/renderer/imagemanager/BUCK +++ b/ReactCommon/react/renderer/imagemanager/BUCK @@ -31,12 +31,6 @@ rn_xplat_cxx_library( ], prefix = "react/renderer/imagemanager", ), - compiler_flags = [ - "-fexceptions", - "-frtti", - "-std=c++17", - "-Wall", - ], contacts = ["oncall+react_native@xmail.facebook.com"], fbandroid_exported_headers = subdir_glob( [ diff --git a/ReactCommon/react/renderer/leakchecker/BUCK b/ReactCommon/react/renderer/leakchecker/BUCK index a927f7214e..c0796f177a 100644 --- a/ReactCommon/react/renderer/leakchecker/BUCK +++ b/ReactCommon/react/renderer/leakchecker/BUCK @@ -30,12 +30,6 @@ rn_xplat_cxx_library( ], prefix = "react/renderer/leakchecker", ), - compiler_flags = [ - "-fexceptions", - "-frtti", - "-std=c++17", - "-Wall", - ], fbobjc_compiler_flags = APPLE_COMPILER_FLAGS, fbobjc_preprocessor_flags = get_preprocessor_flags_for_build_mode() + get_apple_inspector_flags(), force_static = True, diff --git a/ReactCommon/react/renderer/mapbuffer/BUCK b/ReactCommon/react/renderer/mapbuffer/BUCK index 3c946f02fa..8e57a23c75 100644 --- a/ReactCommon/react/renderer/mapbuffer/BUCK +++ b/ReactCommon/react/renderer/mapbuffer/BUCK @@ -29,12 +29,6 @@ rn_xplat_cxx_library( ], prefix = "react/renderer/mapbuffer", ), - compiler_flags = [ - "-fexceptions", - "-frtti", - "-std=c++17", - "-Wall", - ], fbobjc_compiler_flags = APPLE_COMPILER_FLAGS, fbobjc_preprocessor_flags = get_preprocessor_flags_for_build_mode() + get_apple_inspector_flags(), force_static = True, diff --git a/ReactCommon/react/renderer/mounting/BUCK b/ReactCommon/react/renderer/mounting/BUCK index 2d0d42e585..20a434f868 100644 --- a/ReactCommon/react/renderer/mounting/BUCK +++ b/ReactCommon/react/renderer/mounting/BUCK @@ -32,12 +32,6 @@ rn_xplat_cxx_library( ], prefix = "react/renderer/mounting", ), - compiler_flags = [ - "-fexceptions", - "-frtti", - "-std=c++17", - "-Wall", - ], fbobjc_compiler_flags = APPLE_COMPILER_FLAGS, fbobjc_preprocessor_flags = get_preprocessor_flags_for_build_mode() + get_apple_inspector_flags(), force_static = True, diff --git a/ReactCommon/react/renderer/runtimescheduler/BUCK b/ReactCommon/react/renderer/runtimescheduler/BUCK index d313bb670a..81f2b99954 100644 --- a/ReactCommon/react/renderer/runtimescheduler/BUCK +++ b/ReactCommon/react/renderer/runtimescheduler/BUCK @@ -31,12 +31,6 @@ rn_xplat_cxx_library( ], prefix = "react/renderer/runtimescheduler", ), - compiler_flags = [ - "-fexceptions", - "-frtti", - "-std=c++17", - "-Wall", - ], fbobjc_compiler_flags = APPLE_COMPILER_FLAGS, fbobjc_preprocessor_flags = get_preprocessor_flags_for_build_mode() + get_apple_inspector_flags(), force_static = True, diff --git a/ReactCommon/react/renderer/scheduler/BUCK b/ReactCommon/react/renderer/scheduler/BUCK index be57647125..ee76e263bb 100644 --- a/ReactCommon/react/renderer/scheduler/BUCK +++ b/ReactCommon/react/renderer/scheduler/BUCK @@ -30,12 +30,6 @@ rn_xplat_cxx_library( ], prefix = "react/renderer/scheduler", ), - compiler_flags = [ - "-fexceptions", - "-frtti", - "-std=c++17", - "-Wall", - ], fbobjc_compiler_flags = APPLE_COMPILER_FLAGS, fbobjc_preprocessor_flags = get_preprocessor_flags_for_build_mode() + get_apple_inspector_flags(), force_static = True, diff --git a/ReactCommon/react/renderer/telemetry/BUCK b/ReactCommon/react/renderer/telemetry/BUCK index 3ec301b483..d6b46e35de 100644 --- a/ReactCommon/react/renderer/telemetry/BUCK +++ b/ReactCommon/react/renderer/telemetry/BUCK @@ -32,12 +32,6 @@ rn_xplat_cxx_library( ], prefix = "react/renderer/telemetry", ), - compiler_flags = [ - "-fexceptions", - "-frtti", - "-std=c++17", - "-Wall", - ], fbobjc_compiler_flags = APPLE_COMPILER_FLAGS, fbobjc_preprocessor_flags = get_preprocessor_flags_for_build_mode() + get_apple_inspector_flags(), force_static = True, diff --git a/ReactCommon/react/renderer/templateprocessor/BUCK b/ReactCommon/react/renderer/templateprocessor/BUCK index 1f106c4b94..430b0bdb1d 100644 --- a/ReactCommon/react/renderer/templateprocessor/BUCK +++ b/ReactCommon/react/renderer/templateprocessor/BUCK @@ -31,12 +31,6 @@ rn_xplat_cxx_library( ], prefix = "react/renderer/templateprocessor", ), - compiler_flags = [ - "-fexceptions", - "-frtti", - "-std=c++17", - "-Wall", - ], fbobjc_compiler_flags = APPLE_COMPILER_FLAGS, fbobjc_preprocessor_flags = get_preprocessor_flags_for_build_mode() + get_apple_inspector_flags(), force_static = True, diff --git a/ReactCommon/react/renderer/textlayoutmanager/BUCK b/ReactCommon/react/renderer/textlayoutmanager/BUCK index 18a9ddeb0f..1e7e142f4c 100644 --- a/ReactCommon/react/renderer/textlayoutmanager/BUCK +++ b/ReactCommon/react/renderer/textlayoutmanager/BUCK @@ -36,12 +36,6 @@ rn_xplat_cxx_library( ], prefix = "react/renderer/textlayoutmanager", ), - compiler_flags = [ - "-fexceptions", - "-frtti", - "-std=c++17", - "-Wall", - ], cxx_exported_headers = subdir_glob( [ ("platform/cxx", "*.h"), diff --git a/ReactCommon/react/renderer/timeline/BUCK b/ReactCommon/react/renderer/timeline/BUCK index d9887cc2c4..a8888cb22f 100644 --- a/ReactCommon/react/renderer/timeline/BUCK +++ b/ReactCommon/react/renderer/timeline/BUCK @@ -31,12 +31,6 @@ rn_xplat_cxx_library( ], prefix = "react/renderer/timeline", ), - compiler_flags = [ - "-fexceptions", - "-frtti", - "-std=c++17", - "-Wall", - ], fbobjc_compiler_flags = APPLE_COMPILER_FLAGS, fbobjc_labels = ["supermodule:ios/isolation/infra.react_native"], fbobjc_preprocessor_flags = get_preprocessor_flags_for_build_mode() + get_apple_inspector_flags(), diff --git a/ReactCommon/react/renderer/uimanager/BUCK b/ReactCommon/react/renderer/uimanager/BUCK index 4a58378147..d518a76c38 100644 --- a/ReactCommon/react/renderer/uimanager/BUCK +++ b/ReactCommon/react/renderer/uimanager/BUCK @@ -31,12 +31,6 @@ rn_xplat_cxx_library( ], prefix = "react/renderer/uimanager", ), - compiler_flags = [ - "-fexceptions", - "-frtti", - "-std=c++17", - "-Wall", - ], fbobjc_compiler_flags = APPLE_COMPILER_FLAGS, fbobjc_preprocessor_flags = get_preprocessor_flags_for_build_mode() + get_apple_inspector_flags(), force_static = True, diff --git a/ReactCommon/react/test_utils/BUCK b/ReactCommon/react/test_utils/BUCK index 8cd75144aa..55a8cac9d0 100644 --- a/ReactCommon/react/test_utils/BUCK +++ b/ReactCommon/react/test_utils/BUCK @@ -27,12 +27,6 @@ rn_xplat_cxx_library( ], prefix = "react/test_utils", ), - compiler_flags = [ - "-fexceptions", - "-frtti", - "-std=c++17", - "-Wall", - ], fbobjc_compiler_flags = APPLE_COMPILER_FLAGS, fbobjc_frameworks = ["Foundation"], fbobjc_preprocessor_flags = get_preprocessor_flags_for_build_mode() + get_apple_inspector_flags(), diff --git a/ReactCommon/react/utils/BUCK b/ReactCommon/react/utils/BUCK index 3d4bfde9b0..6525d5b9b5 100644 --- a/ReactCommon/react/utils/BUCK +++ b/ReactCommon/react/utils/BUCK @@ -34,12 +34,6 @@ rn_xplat_cxx_library( ], prefix = "react/utils", ), - compiler_flags = [ - "-fexceptions", - "-frtti", - "-std=c++17", - "-Wall", - ], fbandroid_deps = [ react_native_target("java/com/facebook/react/common/mapbuffer/jni:jni"), react_native_xplat_target("react/renderer/mapbuffer:mapbuffer"), diff --git a/ReactCommon/reactperflogger/BUCK b/ReactCommon/reactperflogger/BUCK index 09928787c7..d1a06c0957 100644 --- a/ReactCommon/reactperflogger/BUCK +++ b/ReactCommon/reactperflogger/BUCK @@ -9,10 +9,6 @@ rn_xplat_cxx_library( "reactperflogger/NativeModulePerfLogger.h": "reactperflogger/NativeModulePerfLogger.h", }, compiler_flags = [ - "-fexceptions", - "-frtti", - "-std=c++17", - "-Wall", "-Wno-global-constructors", ], labels = ["supermodule:xplat/default/public.react_native.infra"], diff --git a/ReactCommon/runtimeexecutor/BUCK b/ReactCommon/runtimeexecutor/BUCK index 60dc08ebb1..b8e04dfaf7 100644 --- a/ReactCommon/runtimeexecutor/BUCK +++ b/ReactCommon/runtimeexecutor/BUCK @@ -28,12 +28,6 @@ rn_xplat_cxx_library( exported_headers = { "ReactCommon/RuntimeExecutor.h": "ReactCommon/RuntimeExecutor.h", }, - compiler_flags = [ - "-fexceptions", - "-frtti", - "-std=c++17", - "-Wall", - ], fbobjc_compiler_flags = APPLE_COMPILER_FLAGS, fbobjc_frameworks = ["Foundation"], fbobjc_preprocessor_flags = get_preprocessor_flags_for_build_mode() + get_apple_inspector_flags(), diff --git a/ReactCommon/yoga/BUCK b/ReactCommon/yoga/BUCK index 13e624f86b..c6e4116f0b 100644 --- a/ReactCommon/yoga/BUCK +++ b/ReactCommon/yoga/BUCK @@ -7,11 +7,7 @@ cxx_library( exported_headers = glob(["yoga/**/*.h"]), compiler_flags = [ "-fno-omit-frame-pointer", - "-fexceptions", - "-Wall", - "-Werror", - "-std=c++1y", - "-O3", + "-O3" ], force_static = True, visibility = ["PUBLIC"], diff --git a/packages/react-native-codegen/BUCK b/packages/react-native-codegen/BUCK index 138f9de91a..04c7639d8f 100644 --- a/packages/react-native-codegen/BUCK +++ b/packages/react-native-codegen/BUCK @@ -55,12 +55,6 @@ rn_xplat_cxx_library( name = "rn_codegen_library", srcs = ["buck_tests/emptyFile.cpp"], headers = [], - compiler_flags = [ - "-fexceptions", - "-frtti", - "-std=c++17", - "-Wall", - ], platforms = (ANDROID, APPLE), preprocessor_flags = [ "-DLOG_TAG=\"ReactNative\"", @@ -79,12 +73,6 @@ rn_xplat_cxx_library( srcs = ["buck_tests/emptyFile.mm"], headers = [], apple_sdks = (IOS,), - compiler_flags = [ - "-fexceptions", - "-frtti", - "-std=c++17", - "-Wall", - ], platforms = APPLE, preprocessor_flags = [ "-DLOG_TAG=\"ReactNative\"", diff --git a/packages/react-native-codegen/DEFS.bzl b/packages/react-native-codegen/DEFS.bzl index 43ac82e0ae..a5211ce585 100644 --- a/packages/react-native-codegen/DEFS.bzl +++ b/packages/react-native-codegen/DEFS.bzl @@ -195,12 +195,6 @@ def rn_codegen_modules( exported_headers = { "{}/{}.h".format(name, name): ":{}".format(generate_module_jni_h_name), }, - compiler_flags = [ - "-fexceptions", - "-frtti", - "-std=c++14", - "-Wall", - ], force_static = True, preprocessor_flags = [ "-DLOG_TAG=\"ReactNative\"", @@ -416,12 +410,6 @@ def rn_codegen_components( "RCTComponentViewHelpers.h": ":{}".format(generate_component_hobjcpp_name), "ShadowNodes.h": ":{}".format(generate_shadow_node_h_name), }, - compiler_flags = [ - "-fexceptions", - "-frtti", - "-std=c++14", - "-Wall", - ], fbobjc_compiler_flags = get_apple_compiler_flags(), fbobjc_preprocessor_flags = get_preprocessor_flags_for_build_mode() + get_apple_inspector_flags(), ios_exported_headers = { @@ -563,12 +551,6 @@ def rn_codegen_cxx_modules( "NativeModules.cpp": ":{}".format(generate_module_cpp_name), "NativeModules.h": ":{}".format(generate_module_h_name), }, - compiler_flags = [ - "-fexceptions", - "-frtti", - "-std=c++14", - "-Wall", - ], fbobjc_compiler_flags = get_apple_compiler_flags(), fbobjc_preprocessor_flags = get_preprocessor_flags_for_build_mode() + get_apple_inspector_flags(), labels = ["codegen_rule"], From f7a33e3501570575d38689133dd13cfb4816199b Mon Sep 17 00:00:00 2001 From: Andrei Shikov Date: Thu, 14 Oct 2021 16:15:43 -0700 Subject: [PATCH 58/62] Use `Arguments.createArray` instead of `WritableNativeArray` Summary: Using `WriteableNativeArray` directly in common code is breaking unit tests on CircleCI. Changelog: [Android][Internal] - Use mock of native array for sending touches Reviewed By: mdvacca Differential Revision: D31665842 fbshipit-source-id: 886418ff6a3f07046e8e17d4743060d80c26b288 --- .../com/facebook/react/uimanager/events/TouchesHelper.java | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/TouchesHelper.java b/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/TouchesHelper.java index 25b4236828..9b60f6f803 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/TouchesHelper.java +++ b/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/TouchesHelper.java @@ -12,7 +12,6 @@ import com.facebook.react.bridge.Arguments; import com.facebook.react.bridge.ReactSoftExceptionLogger; import com.facebook.react.bridge.WritableArray; import com.facebook.react.bridge.WritableMap; -import com.facebook.react.bridge.WritableNativeArray; import com.facebook.react.uimanager.PixelUtil; /** Class responsible for generating catalyst touch events based on android {@link MotionEvent}. */ @@ -187,7 +186,7 @@ public class TouchesHelper { } private static WritableArray getWritableArray(boolean copyObjects, WritableMap... objects) { - WritableArray result = new WritableNativeArray(); + WritableArray result = Arguments.createArray(); for (WritableMap object : objects) { if (object != null) { result.pushMap(copyObjects ? object.copy() : object); From 6525f9b0828ec2c355ce5ebb54f7557f62b082c3 Mon Sep 17 00:00:00 2001 From: Joshua Gross Date: Thu, 14 Oct 2021 19:21:44 -0700 Subject: [PATCH 59/62] Stop using RTTI features in Fabric core and components Summary: These dynamic_casts aren't really giving us much (they have never fired once in dev! and don't run in prod anyway). They also prevent us from disabling RTTI. So, let's get rid of them. Changelog: [Internal] Reviewed By: philIip Differential Revision: D31634895 fbshipit-source-id: 4a9b259837127feb324f64fa3e9e23eb1cc481a6 --- .../java/com/facebook/react/fabric/jni/BUCK | 2 ++ .../com/facebook/react/fabric/jni/Binding.cpp | 19 +++++++++++-------- ReactAndroid/src/main/jni/react/jni/BUCK | 2 ++ .../image/ImageComponentDescriptor.h | 2 -- .../InputAccessoryComponentDescriptor.h | 4 ---- .../modal/ModalHostViewComponentDescriptor.h | 5 ----- .../AndroidProgressBarComponentDescriptor.h | 3 --- .../slider/SliderComponentDescriptor.h | 3 --- .../AndroidSwitchComponentDescriptor.h | 3 --- .../text/ParagraphComponentDescriptor.h | 3 --- .../AndroidTextInputComponentDescriptor.h | 3 --- .../TextInputComponentDescriptor.h | 3 --- .../UnimplementedViewComponentDescriptor.cpp | 4 ---- ReactCommon/react/renderer/core/BUCK | 2 ++ .../core/ConcreteComponentDescriptor.h | 3 --- .../react/renderer/core/ConcreteShadowNode.h | 10 ---------- 16 files changed, 17 insertions(+), 54 deletions(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/BUCK b/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/BUCK index c4297f303a..7ea630148b 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/BUCK +++ b/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/BUCK @@ -11,6 +11,8 @@ rn_xplat_cxx_library( ], prefix = "react/fabric", ), + compiler_flags_enable_exceptions = True, + compiler_flags_enable_rtti = True, # dynamic_cast used within Binding.cpp fbandroid_allow_jni_merging = True, labels = ["supermodule:xplat/default/public.react_native.infra"], platforms = ANDROID, diff --git a/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/Binding.cpp b/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/Binding.cpp index b4d0abd992..79b6c1ccf3 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/Binding.cpp +++ b/ReactAndroid/src/main/java/com/facebook/react/fabric/jni/Binding.cpp @@ -646,16 +646,19 @@ inline local_ref castReadableArray( // TODO: this method will be removed when binding for components are code-gen local_ref getPlatformComponentName(const ShadowView &shadowView) { - local_ref componentName; - auto newViewProps = - std::dynamic_pointer_cast(shadowView.props); + static std::string scrollViewComponentName = std::string("ScrollView"); - if (newViewProps && - newViewProps->getProbablyMoreHorizontalThanVertical_DEPRECATED()) { - componentName = make_jstring("AndroidHorizontalScrollView"); - } else { - componentName = make_jstring(shadowView.componentName); + local_ref componentName; + if (scrollViewComponentName.compare(shadowView.componentName) == 0) { + auto newViewProps = + std::static_pointer_cast(shadowView.props); + if (newViewProps->getProbablyMoreHorizontalThanVertical_DEPRECATED()) { + componentName = make_jstring("AndroidHorizontalScrollView"); + return componentName; + } } + + componentName = make_jstring(shadowView.componentName); return componentName; } diff --git a/ReactAndroid/src/main/jni/react/jni/BUCK b/ReactAndroid/src/main/jni/react/jni/BUCK index 39514497ec..c2a91196bb 100644 --- a/ReactAndroid/src/main/jni/react/jni/BUCK +++ b/ReactAndroid/src/main/jni/react/jni/BUCK @@ -38,6 +38,8 @@ rn_xplat_cxx_library( "-Wno-pessimizing-move", "-Wno-inconsistent-missing-override", ], + compiler_flags_enable_exceptions = True, + compiler_flags_enable_rtti = True, # dynamic_cast used within ReadableNative* fbandroid_allow_jni_merging = True, labels = ["supermodule:xplat/default/public.react_native.infra"], platforms = ANDROID, diff --git a/ReactCommon/react/renderer/components/image/ImageComponentDescriptor.h b/ReactCommon/react/renderer/components/image/ImageComponentDescriptor.h index 4366a886c4..39465a0fe6 100644 --- a/ReactCommon/react/renderer/components/image/ImageComponentDescriptor.h +++ b/ReactCommon/react/renderer/components/image/ImageComponentDescriptor.h @@ -7,7 +7,6 @@ #pragma once -#include #include #include #include @@ -29,7 +28,6 @@ class ImageComponentDescriptor final void adopt(ShadowNode::Unshared const &shadowNode) const override { ConcreteComponentDescriptor::adopt(shadowNode); - react_native_assert(std::dynamic_pointer_cast(shadowNode)); auto imageShadowNode = std::static_pointer_cast(shadowNode); diff --git a/ReactCommon/react/renderer/components/inputaccessory/InputAccessoryComponentDescriptor.h b/ReactCommon/react/renderer/components/inputaccessory/InputAccessoryComponentDescriptor.h index cf864d30f0..7978f06330 100644 --- a/ReactCommon/react/renderer/components/inputaccessory/InputAccessoryComponentDescriptor.h +++ b/ReactCommon/react/renderer/components/inputaccessory/InputAccessoryComponentDescriptor.h @@ -23,13 +23,9 @@ class InputAccessoryComponentDescriptor final using ConcreteComponentDescriptor::ConcreteComponentDescriptor; void adopt(ShadowNode::Unshared const &shadowNode) const override { - react_native_assert( - std::dynamic_pointer_cast(shadowNode)); auto concreteShadowNode = std::static_pointer_cast(shadowNode); - react_native_assert(std::dynamic_pointer_cast( - concreteShadowNode)); auto layoutableShadowNode = std::static_pointer_cast(concreteShadowNode); diff --git a/ReactCommon/react/renderer/components/modal/ModalHostViewComponentDescriptor.h b/ReactCommon/react/renderer/components/modal/ModalHostViewComponentDescriptor.h index 4b5adb9c58..c1130183ad 100644 --- a/ReactCommon/react/renderer/components/modal/ModalHostViewComponentDescriptor.h +++ b/ReactCommon/react/renderer/components/modal/ModalHostViewComponentDescriptor.h @@ -8,7 +8,6 @@ #pragma once #include -#include #include #include @@ -25,13 +24,9 @@ class ModalHostViewComponentDescriptor final using ConcreteComponentDescriptor::ConcreteComponentDescriptor; void adopt(ShadowNode::Unshared const &shadowNode) const override { - react_native_assert( - std::dynamic_pointer_cast(shadowNode)); auto modalShadowNode = std::static_pointer_cast(shadowNode); - react_native_assert( - std::dynamic_pointer_cast(modalShadowNode)); auto layoutableShadowNode = std::static_pointer_cast(modalShadowNode); diff --git a/ReactCommon/react/renderer/components/progressbar/android/react/renderer/components/progressbar/AndroidProgressBarComponentDescriptor.h b/ReactCommon/react/renderer/components/progressbar/android/react/renderer/components/progressbar/AndroidProgressBarComponentDescriptor.h index 8512b2ac91..9e012b91cc 100644 --- a/ReactCommon/react/renderer/components/progressbar/android/react/renderer/components/progressbar/AndroidProgressBarComponentDescriptor.h +++ b/ReactCommon/react/renderer/components/progressbar/android/react/renderer/components/progressbar/AndroidProgressBarComponentDescriptor.h @@ -7,7 +7,6 @@ #pragma once -#include #include #include "AndroidProgressBarMeasurementsManager.h" #include "AndroidProgressBarShadowNode.h" @@ -31,8 +30,6 @@ class AndroidProgressBarComponentDescriptor final void adopt(ShadowNode::Unshared const &shadowNode) const override { ConcreteComponentDescriptor::adopt(shadowNode); - react_native_assert( - std::dynamic_pointer_cast(shadowNode)); auto androidProgressBarShadowNode = std::static_pointer_cast(shadowNode); diff --git a/ReactCommon/react/renderer/components/slider/SliderComponentDescriptor.h b/ReactCommon/react/renderer/components/slider/SliderComponentDescriptor.h index a41089650b..c167f68fa4 100644 --- a/ReactCommon/react/renderer/components/slider/SliderComponentDescriptor.h +++ b/ReactCommon/react/renderer/components/slider/SliderComponentDescriptor.h @@ -7,7 +7,6 @@ #pragma once -#include #include #include #include @@ -32,8 +31,6 @@ class SliderComponentDescriptor final void adopt(ShadowNode::Unshared const &shadowNode) const override { ConcreteComponentDescriptor::adopt(shadowNode); - react_native_assert( - std::dynamic_pointer_cast(shadowNode)); auto sliderShadowNode = std::static_pointer_cast(shadowNode); diff --git a/ReactCommon/react/renderer/components/switch/androidswitch/react/renderer/components/androidswitch/AndroidSwitchComponentDescriptor.h b/ReactCommon/react/renderer/components/switch/androidswitch/react/renderer/components/androidswitch/AndroidSwitchComponentDescriptor.h index 754ec410eb..b253baf171 100644 --- a/ReactCommon/react/renderer/components/switch/androidswitch/react/renderer/components/androidswitch/AndroidSwitchComponentDescriptor.h +++ b/ReactCommon/react/renderer/components/switch/androidswitch/react/renderer/components/androidswitch/AndroidSwitchComponentDescriptor.h @@ -10,7 +10,6 @@ #include "AndroidSwitchMeasurementsManager.h" #include "AndroidSwitchShadowNode.h" -#include #include namespace facebook { @@ -31,8 +30,6 @@ class AndroidSwitchComponentDescriptor final void adopt(ShadowNode::Unshared const &shadowNode) const override { ConcreteComponentDescriptor::adopt(shadowNode); - react_native_assert( - std::dynamic_pointer_cast(shadowNode)); auto androidSwitchShadowNode = std::static_pointer_cast(shadowNode); diff --git a/ReactCommon/react/renderer/components/text/ParagraphComponentDescriptor.h b/ReactCommon/react/renderer/components/text/ParagraphComponentDescriptor.h index 42f6f386b6..0801a07b8d 100644 --- a/ReactCommon/react/renderer/components/text/ParagraphComponentDescriptor.h +++ b/ReactCommon/react/renderer/components/text/ParagraphComponentDescriptor.h @@ -7,7 +7,6 @@ #pragma once -#include #include #include #include @@ -33,8 +32,6 @@ class ParagraphComponentDescriptor final void adopt(ShadowNode::Unshared const &shadowNode) const override { ConcreteComponentDescriptor::adopt(shadowNode); - react_native_assert( - std::dynamic_pointer_cast(shadowNode)); auto paragraphShadowNode = std::static_pointer_cast(shadowNode); diff --git a/ReactCommon/react/renderer/components/textinput/androidtextinput/react/renderer/components/androidtextinput/AndroidTextInputComponentDescriptor.h b/ReactCommon/react/renderer/components/textinput/androidtextinput/react/renderer/components/androidtextinput/AndroidTextInputComponentDescriptor.h index 8f0591e772..1728de336a 100644 --- a/ReactCommon/react/renderer/components/textinput/androidtextinput/react/renderer/components/androidtextinput/AndroidTextInputComponentDescriptor.h +++ b/ReactCommon/react/renderer/components/textinput/androidtextinput/react/renderer/components/androidtextinput/AndroidTextInputComponentDescriptor.h @@ -15,7 +15,6 @@ #include #include -#include #include namespace facebook { @@ -88,8 +87,6 @@ class AndroidTextInputComponentDescriptor final protected: void adopt(ShadowNode::Unshared const &shadowNode) const override { - react_native_assert( - std::dynamic_pointer_cast(shadowNode)); auto textInputShadowNode = std::static_pointer_cast(shadowNode); diff --git a/ReactCommon/react/renderer/components/textinput/iostextinput/TextInputComponentDescriptor.h b/ReactCommon/react/renderer/components/textinput/iostextinput/TextInputComponentDescriptor.h index ef36380552..a23ad76a7b 100644 --- a/ReactCommon/react/renderer/components/textinput/iostextinput/TextInputComponentDescriptor.h +++ b/ReactCommon/react/renderer/components/textinput/iostextinput/TextInputComponentDescriptor.h @@ -7,7 +7,6 @@ #pragma once -#include #include #include @@ -30,8 +29,6 @@ class TextInputComponentDescriptor final void adopt(ShadowNode::Unshared const &shadowNode) const override { ConcreteComponentDescriptor::adopt(shadowNode); - react_native_assert( - std::dynamic_pointer_cast(shadowNode)); auto concreteShadowNode = std::static_pointer_cast(shadowNode); diff --git a/ReactCommon/react/renderer/components/unimplementedview/UnimplementedViewComponentDescriptor.cpp b/ReactCommon/react/renderer/components/unimplementedview/UnimplementedViewComponentDescriptor.cpp index 375a95c5d9..c6b4606416 100644 --- a/ReactCommon/react/renderer/components/unimplementedview/UnimplementedViewComponentDescriptor.cpp +++ b/ReactCommon/react/renderer/components/unimplementedview/UnimplementedViewComponentDescriptor.cpp @@ -7,8 +7,6 @@ #include "UnimplementedViewComponentDescriptor.h" -#include - namespace facebook { namespace react { @@ -28,8 +26,6 @@ Props::Shared UnimplementedViewComponentDescriptor::cloneProps( auto clonedProps = ConcreteComponentDescriptor::cloneProps( context, props, rawProps); - react_native_assert( - std::dynamic_pointer_cast(clonedProps)); // We have to clone `Props` object one more time to make sure that we have // an unshared (and non-`const`) copy of it which we can mutate. diff --git a/ReactCommon/react/renderer/core/BUCK b/ReactCommon/react/renderer/core/BUCK index f10420823e..feb8f6569b 100644 --- a/ReactCommon/react/renderer/core/BUCK +++ b/ReactCommon/react/renderer/core/BUCK @@ -32,6 +32,8 @@ rn_xplat_cxx_library( ], prefix = "react/renderer/core", ), + compiler_flags_enable_exceptions = True, + compiler_flags_enable_rtti = True, # Needed for DebugStringConvertible - need to find a non-RTTI way to do this / enable RTTI for debug builds only fbobjc_compiler_flags = APPLE_COMPILER_FLAGS, fbobjc_preprocessor_flags = get_preprocessor_flags_for_build_mode() + get_apple_inspector_flags(), force_static = True, diff --git a/ReactCommon/react/renderer/core/ConcreteComponentDescriptor.h b/ReactCommon/react/renderer/core/ConcreteComponentDescriptor.h index 7163094103..08193e7609 100644 --- a/ReactCommon/react/renderer/core/ConcreteComponentDescriptor.h +++ b/ReactCommon/react/renderer/core/ConcreteComponentDescriptor.h @@ -66,9 +66,6 @@ class ConcreteComponentDescriptor : public ComponentDescriptor { ShadowNode::Shared createShadowNode( const ShadowNodeFragment &fragment, ShadowNodeFamily::Shared const &family) const override { - react_native_assert( - std::dynamic_pointer_cast(fragment.props)); - auto shadowNode = std::make_shared(fragment, family, getTraits()); diff --git a/ReactCommon/react/renderer/core/ConcreteShadowNode.h b/ReactCommon/react/renderer/core/ConcreteShadowNode.h index 8ad8820f59..537aa6dcbf 100644 --- a/ReactCommon/react/renderer/core/ConcreteShadowNode.h +++ b/ReactCommon/react/renderer/core/ConcreteShadowNode.h @@ -99,9 +99,6 @@ class ConcreteShadowNode : public BaseShadowNodeT { ConcreteProps const &getConcreteProps() const { react_native_assert( BaseShadowNodeT::props_ && "Props must not be `nullptr`."); - react_native_assert( - std::dynamic_pointer_cast(props_) && - "Props must be an instance of ConcreteProps class."); return static_cast(*props_); } @@ -110,10 +107,6 @@ class ConcreteShadowNode : public BaseShadowNodeT { * Thread-safe after the node is sealed. */ ConcreteEventEmitter const &getConcreteEventEmitter() const { - react_native_assert( - std::dynamic_pointer_cast( - BaseShadowNodeT::getEventEmitter()) && - "EventEmitter must be an instance of ConcreteEventEmitter class."); return static_cast( *BaseShadowNodeT::getEventEmitter()); } @@ -124,9 +117,6 @@ class ConcreteShadowNode : public BaseShadowNodeT { */ ConcreteStateData const &getStateData() const { react_native_assert(state_ && "State must not be `nullptr`."); - react_native_assert( - std::dynamic_pointer_cast(state_) && - "State must be an instance of ConcreteState class."); return static_cast(state_.get())->getData(); } From 37efe38e6cb7c4ba21230435037b37b5a5c4b164 Mon Sep 17 00:00:00 2001 From: Nicola Corti Date: Fri, 15 Oct 2021 03:10:17 -0700 Subject: [PATCH 60/62] Add stale action to close older issues/PR that are more than one year inactive (#32403) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/32403 As the title says, we should cleanup issues that are really stale (i.e. more than one year inactive). I ended up using actions/stale which is the first party solution for this. Changelog: [Internal] [Changed] - Add stale GitHub action Reviewed By: hramos Differential Revision: D31653083 fbshipit-source-id: 48538a571183f9ff28a23e7d1fdd01980581de35 --- .github/workflows/stale-bot.yml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 .github/workflows/stale-bot.yml diff --git a/.github/workflows/stale-bot.yml b/.github/workflows/stale-bot.yml new file mode 100644 index 0000000000..2ef7890236 --- /dev/null +++ b/.github/workflows/stale-bot.yml @@ -0,0 +1,19 @@ +name: Mark stale issues and pull requests +on: + schedule: + - cron: "30 1 * * *" +jobs: + stale: + runs-on: ubuntu-latest + permissions: + issues: write + pull-requests: write + steps: + - uses: actions/stale@v4 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + days-before-stale: 365 + stale-issue-message: 'This issue is stale because it has been open 365 days with no activity. Remove stale label or comment or this will be closed in 7 days.' + stale-pr-message: 'This PR is stale because it has been open 365 days with no activity. Remove stale label or comment or this will be closed in 7 days.' + close-issue-message: 'This issue was closed because it has been stalled for 7 days with no activity.' + close-pr-message: 'This PR was closed because it has been stalled for 7 days with no activity.' From ec31b38ef199660db6bc720683b4554c02d27ebb Mon Sep 17 00:00:00 2001 From: Pieter De Baets Date: Fri, 15 Oct 2021 04:33:29 -0700 Subject: [PATCH 61/62] Fix bug with hittesting when skipping views due to overflow Summary: Noticed we were sometimes receiving incorrect paths through the view hierarchy. This was largely harmless, as the hover events generated from this would still be correct. We just sometimes send more onExit/onEnter events than necessary. Changelog: [Internal] Reviewed By: rshest Differential Revision: D31434300 fbshipit-source-id: 3888270eaa16edf48f5d894a1e6daeca1ecfed1e --- .../java/com/facebook/react/uimanager/TouchTargetHelper.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/uimanager/TouchTargetHelper.java b/ReactAndroid/src/main/java/com/facebook/react/uimanager/TouchTargetHelper.java index 4436ceda2b..05d2b48971 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/uimanager/TouchTargetHelper.java +++ b/ReactAndroid/src/main/java/com/facebook/react/uimanager/TouchTargetHelper.java @@ -182,7 +182,6 @@ public class TouchTargetHelper { eventCoords[0] = childPoint.x; eventCoords[1] = childPoint.y; View targetView = findTouchTargetViewWithPointerEvents(eventCoords, child, pathAccumulator); - if (targetView != null) { // We don't allow touches on views that are outside the bounds of an `overflow: hidden` // View @@ -196,6 +195,9 @@ public class TouchTargetHelper { } if (inOverflowBounds) { return targetView; + } else if (pathAccumulator != null) { + // Not a hit, reset the path found so far + pathAccumulator.clear(); } } eventCoords[0] = restoreX; From ed8e5e51516a81158d64dbbf39be3bff9796cc46 Mon Sep 17 00:00:00 2001 From: CodemodService FBSourceGoogleJavaFormatLinterBot <> Date: Fri, 15 Oct 2021 10:51:38 -0700 Subject: [PATCH 62/62] Daily `arc lint --take GOOGLEJAVAFORMAT` Reviewed By: zertosh Differential Revision: D31681073 fbshipit-source-id: 1283e00c2ba1ecfa824b3c182ac35ae11cbe9bc2 --- .../java/com/facebook/react/uimanager/events/TouchEvent.java | 1 - 1 file changed, 1 deletion(-) diff --git a/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/TouchEvent.java b/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/TouchEvent.java index 4ee7137456..eb8b7a78a7 100644 --- a/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/TouchEvent.java +++ b/ReactAndroid/src/main/java/com/facebook/react/uimanager/events/TouchEvent.java @@ -13,7 +13,6 @@ import androidx.core.util.Pools; import com.facebook.infer.annotation.Assertions; import com.facebook.react.bridge.ReactSoftExceptionLogger; import com.facebook.react.bridge.SoftAssertions; -import com.facebook.react.bridge.WritableMap; import com.facebook.react.config.ReactFeatureFlags; /**