Граф коммитов

24463 Коммитов

Автор SHA1 Сообщение Дата
Genki Kondo 289c7f7180 Emit scroll events on overscroll and fix sticky header
Summary:
Sticky headers (via OCScrollTrackerStickyHeader) did not work with RN because overscroll does not trigger onScroll events.

This diff adds a listener to overscroll, which then emits scroll events.

Changelog:
[Internal][Changed] - Changed ScrollEvent's scrollX and scrollY to float

 ---

# Context

GamingActivity headers are part of the FlatList; on overscroll (when you scroll up when you're already at the top of the FlatList), the header is translated via Animated's native event. The problem on RN is that onScroll is not fired during overscroll (due to how overscroll-decor works - it merely applies a translation on the scroll view itself).

Scroll events propagate to the native animated events as follows:
- ReactScrollView.onScrollChanged -> ReactScrollViewHelper.updateStateOnScrollChanged -> ReactScrollViewHelper.emitScrollEvent -> EventDispatcher.dispatchEvent -> NativeAnimatedNodesManager.onEventDispatch

# Approaches

Two approaches were considered to fix sticky headers:
- [Implemented in this diff] Attach a listener on OverScrollDecor and fire onScroll events. I ran into 2 main issues with this:
  - The header clips as the scroll view is translated down. This is fixed via setting clipChildren.
- Move headers out of FlatList, and translate the header only for positive scroll offsets.
  - Requires product-side code changes
  - Hover outline is cut off by the header
  - Click-drag to scroll does not work on the header

Reviewed By: javache

Differential Revision: D34696042

fbshipit-source-id: 15450f31a7042ce67cdffc74614f4f7b9684d0ca
2022-03-15 10:55:08 -07:00
Krisztiaan 5d560ca99f fix: `cliPath` should handle absolute paths (#32983)
Summary:
Avoid breaking tools relying on absolute path for `cliPath`

## Changelog

[Android] [Fixed] - Enable cliPath to have an absolute path value

Pull Request resolved: https://github.com/facebook/react-native/pull/32983

Test Plan:
declare `cliPath` from `expo`:
```groovy
cliPath: new File(["node", "--print", "require.resolve('react-native/package.json')"].execute(null, rootDir).text.trim()).getParentFile().getAbsolutePath() + "/cli.js",
```
and run an android build

Reviewed By: ShikaSD

Differential Revision: D33843275

Pulled By: cortinico

fbshipit-source-id: 65f55a5e07a4ec0a6205d5f06f150377708c30cc
2022-03-15 09:24:22 -07:00
Nicola Corti 0d2ee7c17c Re-apply main changes to CMake files
Summary:
This Diff re-applies some of the changes that landed on main
to the CMake files we currently landed so far.

Changelog:
[Internal] [Changed] - Re-apply main changes to CMake files

Reviewed By: ShikaSD

Differential Revision: D34859685

fbshipit-source-id: 772a3aed05f56b6fbb2942bf9d1a5bd4581b48d5
2022-03-15 08:14:07 -07:00
Ken Tominaga f001d091b1 Add scripts to debug the `rn-tester` project easier (#33386)
Summary:
This pull request simplifies and makes it easy to debug the `rn-tester` project and switch configurations within the project.

- `yarn start` : Start packager
- `yarn install-android-jsc` : Build with `installJscDebug`.
- `yarn install-android-hermes` : Build with `installHermesDebug`.
- `yarn clean-android` : Clean up the Android build files.
- `yarn setup-ios-jsc` : Install dependencies to use JSC.
- `yarn setup-ios-hermes` : Install dependencies to use Hermes.
- `yarn clean-ios` : Clean up the build files and Pods.

## Changelog

<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://github.com/facebook/react-native/wiki/Changelog
-->

[iOS] [Changed] - Add scripts to debug `rn-tester` easier

Pull Request resolved: https://github.com/facebook/react-native/pull/33386

Test Plan:
<details><summary>Log</summary>
<p>

```sh
// packages/rn-tester

$ yarn setup-ios-jsc

yarn run v1.22.17
$ yarn install && bundle install && bundle exec pod install
[1/5] 🔍  Validating package.json...
[2/5] 🔍  Resolving packages...
success Already up-to-date.
Using rexml 3.2.5
Using CFPropertyList 3.0.5
Using concurrent-ruby 1.1.9
Using i18n 1.9.1
Using minitest 5.15.0
Using tzinfo 2.0.4
Using zeitwerk 2.5.4
Using activesupport 6.1.4.4
Using public_suffix 4.0.6
Using addressable 2.8.0
Using httpclient 2.8.3
Using json 2.6.1
Using algoliasearch 1.27.5
Using atomos 0.1.3
Using bundler 2.1.4
Using claide 1.1.0
Using fuzzy_match 2.0.4
Using nap 1.1.0
Using netrc 0.11.0
Using ffi 1.15.5
Using ethon 0.15.0
Using typhoeus 1.4.0
Using cocoapods-core 1.11.2
Using cocoapods-deintegrate 1.0.5
Using cocoapods-downloader 1.5.1
Using cocoapods-plugins 1.0.0
Using cocoapods-search 1.0.1
Using cocoapods-trunk 1.6.0
Using cocoapods-try 1.2.0
Using colored2 3.1.2
Using escape 0.0.4
Using fourflusher 2.3.1
Using gh_inspector 1.1.3
Using molinillo 0.8.0
Using ruby-macho 2.5.1
Using nanaimo 0.3.0
Using xcodeproj 1.21.0
Using cocoapods 1.11.2
Bundle complete! 2 Gemfile dependencies, 38 gems now installed.
Use `bundle info [gemname]` to see where a bundled gem is installed.
Building RNTester with Fabric enabled.
[Codegen] Generating ./build/generated/ios/React-Codegen.podspec.json
[Codegen] generating an empty RCTThirdPartyFabricComponentsProvider
Building RNTester with Fabric enabled.
[Codegen] Skipping React-Codegen podspec generation.
[Codegen] generating an empty RCTThirdPartyFabricComponentsProvider
Building RNTester with Fabric enabled.
[Codegen] Skipping React-Codegen podspec generation.
[Codegen] generating an empty RCTThirdPartyFabricComponentsProvider
Analyzing dependencies
[Codegen] Found FBReactNativeSpec
[Codegen] Found rncore
[Codegen] Found ScreenshotmanagerSpec
Downloading dependencies
Installing FBLazyVector 1000.0.0
Installing FBReactNativeSpec 1000.0.0
Installing RCTRequired 1000.0.0
Installing RCTTypeSafety 1000.0.0
Installing React 1000.0.0
Installing React-Core 1000.0.0
Installing React-CoreModules 1000.0.0
Installing React-Fabric 1000.0.0
Installing React-RCTActionSheet 1000.0.0
Installing React-RCTAnimation 1000.0.0
Installing React-RCTBlob 1000.0.0
Installing React-RCTFabric 1000.0.0
Installing React-RCTImage 1000.0.0
Installing React-RCTLinking 1000.0.0
Installing React-RCTNetwork 1000.0.0
Installing React-RCTPushNotification 1000.0.0
Installing React-RCTSettings 1000.0.0
Installing React-RCTTest 1000.0.0
Installing React-RCTText 1000.0.0
Installing React-RCTVibration 1000.0.0
Installing React-callinvoker 1000.0.0
Installing React-cxxreact 1000.0.0
Installing React-graphics 1000.0.0
Installing React-jsi 1000.0.0
Installing React-jsiexecutor 1000.0.0
Installing React-jsinspector 1000.0.0
Installing React-logger 1000.0.0
Installing React-perflogger 1000.0.0
Installing React-rncore 1000.0.0
Installing React-runtimeexecutor 1000.0.0
Installing ReactCommon 1000.0.0
Installing Yoga 1.14.0
Generating Pods project
[DEDUCTED]/react-native/packages/rn-tester/Pods/Target Support Files/Pods-RNTester/Pods-RNTester.release.xcconfig
[DEDUCTED]/react-native/packages/rn-tester/Pods/Target Support Files/Pods-RNTester/Pods-RNTester.debug.xcconfig
[DEDUCTED]/react-native/packages/rn-tester/Pods/Target Support Files/Pods-RNTesterUnitTests/Pods-RNTesterUnitTests.release.xcconfig
[DEDUCTED]/react-native/packages/rn-tester/Pods/Target Support Files/Pods-RNTesterUnitTests/Pods-RNTesterUnitTests.debug.xcconfig
[DEDUCTED]/react-native/packages/rn-tester/Pods/Target Support Files/Pods-RNTesterIntegrationTests/Pods-RNTesterIntegrationTests.release.xcconfig
[DEDUCTED]/react-native/packages/rn-tester/Pods/Target Support Files/Pods-RNTesterIntegrationTests/Pods-RNTesterIntegrationTests.debug.xcconfig
React-Core
Integrating client project
Pod installation complete! There are 65 dependencies from the Podfile and 53 total pods installed.
  Done in 8.68s.
```

</p>
</details>

Reviewed By: ShikaSD

Differential Revision: D34835086

Pulled By: cortinico

fbshipit-source-id: 83649f42e8ac77efd8617601e18f15bfcf8f1f61
2022-03-15 07:10:21 -07:00
Nicola Corti 21dd646eca Reduce flakyness of `configureNdkBuild*` tasks by setting an explicit dependency on prefab.
Summary:
I've noticed that `test_android` and the Test Android Docker image jobs fails sometime with a missing
`libhermes.so` file. That is happening because the `configureNdkBuild*` tasks are executing
before the prefab for Hermes is ready. I'm adding an explicit dependency here that will prevent this
kind of situations from happening.

Changelog:
[Internal] [Changed] - Reduce flakyness of `configureNdkBuild*` tasks by setting an explicit dependency on prefab.

Reviewed By: ShikaSD

Differential Revision: D34859961

fbshipit-source-id: e4dc4b22c808359018ec952287b2d8a7094f0698
2022-03-15 06:39:40 -07:00
Nicola Corti 68fde3b35b Allow to override Hermes source location with REACT_NATIVE_OVERRIDE_HERMES_DIR
Summary:
This commit allows to specify a custom location for Hermes sources with the
`REACT_NATIVE_OVERRIDE_HERMES_DIR` environment variable.

This can be useful during local development if you wish to build against a local
clone of facebook/hermes.

Changelog:
[Internal] [Changed] - Allow to override Hermes source location with REACT_NATIVE_OVERRIDE_HERMES_DIR

Reviewed By: ShikaSD

Differential Revision: D34858893

fbshipit-source-id: 4fad3d1c8e99f1f1880b5633e596b67f5dfcc264
2022-03-15 06:29:25 -07:00
Pieter De Baets 6c9de5543e Cleanup ScriptTag helpers on Instance
Summary:
We were opening the file multiple times just to read the same couple of bytes.

Changelog: [Internal]

Reviewed By: motiz88

Differential Revision: D34835972

fbshipit-source-id: 9de899f37a9193db4ab72e69e02e8d41e5515da0
2022-03-15 05:58:52 -07:00
Pieter De Baets be0ff779b1 Fix parseTypeFromHeader for Hermes bytecode
Summary: Changelog: [Internal] Fix bug where Hermes bytecode bundles were not always recognized

Reviewed By: motiz88

Differential Revision: D34718511

fbshipit-source-id: 5bbebe49962d098988d99153b0938fbb5d449ae6
2022-03-15 05:58:52 -07:00
Tommy Nguyen 4b6c0b92c0 Remove `@babel/plugin-transform-regenerator` from RN Babel preset (#789)
Summary:
## Summary

Hermes added support for generators in 0.2.0, and JSC is ES6 feature complete since r202125.

NOTE: This is a combined Metro + React Native commit. For React Native, the only change here is adding `babel/plugin-transform-regenerator` to `repo-config` ( = `devDependencies`), so the tests no longer implicitly consume it via Metro.

Changelog: [Internal]

X-link: https://github.com/facebook/metro/pull/789

Reviewed By: rh389

Differential Revision: D34819044

Pulled By: motiz88

fbshipit-source-id: fe27b2c2af0281d5309d4c16f95762d4d4935eba
2022-03-15 05:19:58 -07:00
Nicola Corti e12bc9cf62 Setup Globbing with CONFIGURE_DEPENDS inside CMake files.
Summary:
This Diff moves from specifying a list of files to use file(GLOB) with
CONFIGURE_DEPENDS on several CMakefiles.
I've updates those where we use globbing also inside buck.

Changelog:
[Internal] [Changed] - Setup Globbing with CONFIGURE_DEPENDS inside CMake files

Reviewed By: ShikaSD

Differential Revision: D34826311

fbshipit-source-id: 8fc654626c897cdc4cdd79c699ce19f1e5e1212f
2022-03-15 01:55:27 -07:00
Evan Yeung 75de6d46e3 Deploy 0.173.0 to xplat
Summary: Changelog: [Internal]

Reviewed By: bradzacher

Differential Revision: D34691988

fbshipit-source-id: f9c73d99d09440718cc05318ea415492652ff818
2022-03-14 13:15:22 -07:00
Oleg Kot 06f504b8b2 Revert D34784966: Consider relative to pwd installation root when looking for files in rn module via cocoapods
Differential Revision:
D34784966 (2f813f873a)

Original commit changeset: d6d5e71bc2fc

Original Phabricator Diff: D34784966 (2f813f873a)

fbshipit-source-id: edaf38cb26187f0bd08e1efb7fc086233cf094c8
2022-03-14 10:31:18 -07:00
Xin Chen 145fd041c7 Fix crash on empty snapToOffsets prop to ScrollView
Summary:
When the `snapToOffsets` prop is empty array, the scroll view would crash unexpectly. This diff fixed that by treating empty array prop as null value for `snapToOffsets`.

Changelog:
[Android][Fixed] - Fix crash on empty snapToOffsets array

Reviewed By: makovkastar

Differential Revision: D34802022

fbshipit-source-id: af330512e444081b0cb02b65288ec5cd2bd14205
2022-03-14 10:25:00 -07:00
Danilo Bürger 2f813f873a Consider relative to pwd installation root when looking for files in rn module via cocoapods (#33399)
Summary:
The `:reactNativePath` provided by `use_native_modules!` is the rn module path relative to the installation root (usually `./ios`). However, when executing cocoapods from a dir thats not the installation root, packages that use the relative `:reactNativePath` variable in their path must also consider the relative to pwd installation root.

This fixes usage of cocoapods with the `--project-directory` flag like

```bash
bundle exec pod install --project-directory=ios
```

## Changelog

[iOS] [Fixed] - Fix usage of cocoapods with --project-directory flag and new arch

Pull Request resolved: https://github.com/facebook/react-native/pull/33399

Test Plan:
1) Enable the new arch
2) Execute from the projects root dir

```bash
bundle exec pod install --project-directory=ios
```

3) It will fail with

```
[!] Invalid `Podfile` file: [codegen] Couldn't not find react-native-codegen..
```

4) Apply the patch
5) Execute from the projects root dir

```bash
bundle exec pod install --project-directory=ios
```

6) It will succeed

Reviewed By: ShikaSD

Differential Revision: D34784966

Pulled By: dmitryrykun

fbshipit-source-id: d6d5e71bc2fcd32f2cd60a498f39e6f772fc9005
2022-03-14 09:00:37 -07:00
Moti Zilberman c1e9aa9a27 Deprecate jest/preprocessor.js
Summary:
Changelog:
[General][Deprecated] Deprecate the use of `react-native/jest/preprocessor.js` by external projects

The supported method of using Jest in React Native projects is using the [Jest preset](https://jestjs.io/docs/tutorial-react-native) shipped as part of the `react-native` package. Some projects are directly using `preprocessor.js` which is part of the testing setup for the React Native repo itself.

In a future release of React Native, we will stop publishing this file to npm and require projects to switch to the supported preset (or a custom Jest config if necessary).

Reviewed By: GijsWeterings

Differential Revision: D34820086

fbshipit-source-id: 197c33726639e66c6916a244117252e6af11f2f6
2022-03-14 07:40:05 -07:00
Andrei Shikov 5ea50fd549 Fix Hermes Android release build (#33420)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/33420

Hermes executor release dependency was incorrectly merged.

Changelog: [Internal]

Reviewed By: cortinico

Differential Revision: D34853948

fbshipit-source-id: b4d41d2a9ad850c042049b6d945ee1d2bb32ebd7
2022-03-14 07:00:07 -07:00
Gijs Weterings b633cc1305 Remove console.disableYellowBox support
Summary:
We're replacing console.disableYellowBox (untyped, global hack, only warnings) with LogBox.ignoreAllLogs() (typed, local method, handles errors and warnings). rickhanlonii made the initial deprecation of this >2 years ago in 87f1e22434 . This diff finally removes the support of `console.disableYellowBox`. Users of LogBox should be using `LogBox.ignoreAllLogs`. This removal also allows us to move LogBox to strict mode flow.

Changelog: [BREAKING] [Removed] Removed console.disableYellowBox in favor of LogBox.ignoreAllLogs.

Reviewed By: rickhanlonii, yungsters

Differential Revision: D34689343

fbshipit-source-id: 3b2865a4918de703e47cd722e3f396475254c65a
2022-03-14 05:33:40 -07:00
Andrei Shikov 5d5addd661 Separate folly into runtime + folly_futures specific for hermes inspector
Summary:
Rearranges folly_futures configuration into a static library only required for `hermes-inspector` + `folly_runtime` which merges `folly_json` and mutex-related implementations `folly_futures` was used for. As `hermes-executor-debug` is removed by `vmCleanup` configurations later, it allows to shave additional 300KB from the release APK size.

Changelog: [Internal] - Rearrange folly build to reduce APK size

Reviewed By: cortinico

Differential Revision: D34342514

fbshipit-source-id: b646680343e6b9a7674019506b87b96f6007caf2
2022-03-13 15:15:21 -07:00
Andrei Shikov 0a004927ad Extract mapbuffer from reactutils module
Summary:
`MapBuffer` is not used in RN utils for anything shared for now, so we can remove it from the build config by reordering methods, shaving 20KB in APK size for each architecture.

Also applies clang-tidy rules to `MapBuffer`/`folly::dynamic` configurations.

Changelog: [Internal] - Remove `mapbuffer` dependency from `Android.mk` of reactutilsjni

Reviewed By: javache, cortinico

Differential Revision: D34620455

fbshipit-source-id: ad3717448f5c20fd071f71d436bb9dd00efe7eb0
2022-03-12 11:19:57 -08:00
Danilo Bürger 75105e692c Start surface after setting the delegate (#33402)
Summary:
When starting the surface, _propagateStageChange is called. This checks the delegate to call surface:didChangeStage: on it.

When initWithSurface:sizeMeasureMode: is called after start, then the delegate will be nil and thus not be called.

This turns it around so a delegate is present for the surface to propagate its state to.

This fixes RCTContentDidAppearNotification not getting posted otherwise.

## Changelog

[iOS] [Fixed] - Post RCTContentDidAppearNotification with new arch

Pull Request resolved: https://github.com/facebook/react-native/pull/33402

Test Plan:
I found it best to set a breakpoint in XCode to where RCTContentDidAppearNotification is being posted.

Prior to the patch that breakpoint will not be called. After applying the patch, it will be called.

Reviewed By: philIip

Differential Revision: D34753329

Pulled By: ShikaSD

fbshipit-source-id: cc44a4c3a787d49e22e9d0c3a82c0f11ed281a0a
2022-03-12 08:32:09 -08:00
Janic Duplessis ae756647c9 Fix babel-plugin-codegen crash when export init is null (#33387)
Summary:
It is possible that `init` is null when using the following code.

```js
export var a;
```

The typescript compiler actually generates something like this for enums so a lot of third party libraries triggered this issue.

For example in expo-apple-authentication/build/AppleAuthentication.types.js

```js
export var AppleAuthenticationScope;
(function (AppleAuthenticationScope) {
    AppleAuthenticationScope[AppleAuthenticationScope["FULL_NAME"] = 0] = "FULL_NAME";
    AppleAuthenticationScope[AppleAuthenticationScope["EMAIL"] = 1] = "EMAIL";
})(AppleAuthenticationScope || (AppleAuthenticationScope = {}));
```

This simply adds a null check.

## Changelog

[General] [Fixed] - Fix babel-plugin-codegen crash when export init is null

Pull Request resolved: https://github.com/facebook/react-native/pull/33387

Test Plan: Tested that this fixed the crash in an app.

Reviewed By: javache

Differential Revision: D34687271

Pulled By: philIip

fbshipit-source-id: 7a7e0fe1bb6a7a21a5b442af26b221a263d4173d
2022-03-11 23:24:22 -08:00
Gabriel Donadel Dall'Agnol 64ebe5bbdd feat: Add dismissActionSheet method to ActionSheetIOS (#33189)
Summary:
This PR adds a `dismissActionSheet` method to `ActionSheetIOS` in order to allow dismissing an ActionSheet programmatically. This is especially useful in apps where a user has the ability to open an ActionSheet and then open a push notification that will redirect them to another screen which usually leads to scenarios where the presented ActionSheet has no relation with the current screen.

#### TODO
- [ ]  Submit react-native-website PR updating ActionSheetIOS documentation.

## Changelog

[iOS] [Added] - Add dismissActionSheet method to ActionSheetIOS

Pull Request resolved: https://github.com/facebook/react-native/pull/33189

Test Plan:
1. Open the RNTester app and navigate to the ActionSheetIOS page
2. Test `dismissActionSheet` through the `Show Action Sheet and automatically dismiss it` example

https://user-images.githubusercontent.com/11707729/155867546-c6770a49-9b09-45e3-a6b1-4f7645d67dbf.mov

Reviewed By: lunaleaps

Differential Revision: D34518952

Pulled By: cortinico

fbshipit-source-id: 912a9b83ee078f791b42efddf5abb7e1cd09d520
2022-03-11 16:33:17 -08:00
Lulu Wu 1042a8012f Encode params in URLSearchParams
Summary:
URL params are not encoded which could cause a security risk, for more details pls see https://fb.workplace.com/groups/react.technologies.discussions/permalink/3184249088473474/

Changelog:
[General][Security] - Encode URL params in URLSearchParams.toString()

Reviewed By: yungsters

Differential Revision: D34415119

fbshipit-source-id: 83c29df9427ad0adc9b6a2b4d0ff5494247aa5cb
2022-03-11 16:26:48 -08:00
Nicola Corti a3d9892ed9 Build Hermes from Source (#33396)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/33396

This commit fully unplugs the `ReactAndroid` from using hermes from the NPM package and plugs the usage of Hermes via the `packages/hermes-engine` Gradle build.

I've used prefab to share the .so between the two builds, so we don't need any extra machinery to make this possible.

Moreover, I've added a `buildHermesFromSource` property, which defaults to false when RN is imported, but is set to true when RN is opened for local development. This should allow us to distribute the `react-native` NPM package and users could potentially toggle which source to use (but see below).

Changelog:
[Android] [Changed] - Build Hermes from Source

Reviewed By: hramos

Differential Revision: D34389875

fbshipit-source-id: 107cbe3686daf7607a1f0f75202f24cd80ce64bb
2022-03-11 15:23:36 -08:00
Vegas Murphy d34a75e9e5 Fix layout in casting screen
Summary:
Changelog:
[Android][Fixed] - Fix StatusBar not updating to use translucent values when set to the same value across different activities

With native nav we open routes in a new activity. Each activity has its own StatusBar configured so we need to ensure it is configured properly.
Currently since the statusBar RN component avoids changing the StatusBar if the value hasn't changed it never gets updated and doesn't become translucent this results in all our padding being off since we add padding to account for the status bar

Reviewed By: yungsters

Differential Revision: D34810143

fbshipit-source-id: 5e382026fb89542fe0c8f6ab396f2fbeedee7a05
2022-03-11 14:07:33 -08:00
Scott Kyle 31f0796237 Add codegen for C++ TurboModule automatic type conversions
Summary:
This adds the *option* for C++ TurboModules to use a `*CxxSpec<T>` base class that extends the existing (and unchanged) corresponding `*CxxSpecJSI` base class with code-generated methods that use `bridging::calFromJs` to safely convert types between JSI and C++. If a type conversion cannot be made, then it will fail to compile.

Changelog:
[General][Added] - Automatic type conversions for C++ TurboModules

Reviewed By: christophpurrer

Differential Revision: D34780512

fbshipit-source-id: 58b34533c40652db8e3aea43804ceb73bcbe97a5
2022-03-11 12:47:51 -08:00
Scott Kyle 6697b7bb90 Add callFromJs bridging API
Summary:
This adds `bridging::callFromJs` that can call class instance methods with JSI arguments and will automagically convert types to the types expected by the method, or otherwise will fail to compile. The same type conversion back to JSI applies as well for the return value, if there is one.

This will allow C++ TurboModules to more easily define their interface in terms of C++ types instead of having to interact with JSI directly for everything, though it remains possibles for JSI values to pass through if that's what a given method wants.

Changelog:
Internal

Reviewed By: christophpurrer

Differential Revision: D34780511

fbshipit-source-id: 1f9caadeefa6d4023f679e95f3decc64d156b3f0
2022-03-11 12:47:51 -08:00
Scott Kyle 30cb78e709 New bridging API for JSI <-> C++
Summary:
This adds  `bridging::toJs` and `bridging::fromJs` functions that will safely cast to and from JSI values and C++ types. This is extensible by specializing `Bridging<T>` with `toJs` and/or `fromJs` static methods. There are specializations for most common C++ and JSI types along with tests for those.

C++ functions and lambdas will effortlessly bridge into JS, and bridging JS functions back into C++ require you to choose `SyncCallback<R(Args...)>` or `AsyncCallback<Args...>` types. The sync version allows for having a return value and is strictly not movable to prevent accidentally moving onto another thread. The async version will move its args onto the JS thread and safely call the callback there, but hence always has a `void` return value.

For promises, you can construct a `AsyncPromise<T>` that has `resolve` and `reject` methods that can be called from any thread, and will bridge into JS as a regular `Promise`.

Changelog:
[General][Added] - New bridging API for JSI <-> C++

Reviewed By: christophpurrer

Differential Revision: D34607143

fbshipit-source-id: d832ac24cf84b4c1672a7b544d82e324d5fca3ef
2022-03-11 12:47:51 -08:00
Scott Kyle 6a9497dbbb Move some classes to new bridging library (#33413)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/33413

This moves `CallbackWrapper` and `LongLivedObject` into a new "bridging" library. This library is mostly intended for use by the native module system, but can also be used separately to "bridge" native and JS interfaces through higher-level (and safer) abstractions than relying JSI alone.

Changelog:
Internal

Reviewed By: christophpurrer

Differential Revision: D34723341

fbshipit-source-id: 7ca8fa815537152f8163920513b90313540477e3
2022-03-11 12:47:51 -08:00
Nicola Corti b676ca560d First Round of CMake files for React Android
Summary:
This is the first round of CMake files to support the React Native build on Android.
They're supposed to eventually replace the various Android.mk files we have around in the codebase.

So far we're not actively using them. This is the first step towards migrating our
setup to use CMake

Changelog:
[Internal] [Changed] - First Round of CMake files for React Android

Reviewed By: ShikaSD

Differential Revision: D34762524

fbshipit-source-id: 6671e203a2c83b8874cefe796aa55aa987902a3b
2022-03-11 11:39:23 -08:00
Andrei Shikov 28291461a8 Add @DoNotStrip to stop obfuscation of Fabric related classes
Summary:
Proguard seems to keep Fabric methods a bit differently from Redex, with method signature lookup with `MountItem` and `StateWrapperImpl` failing in release RNTester builds because of mangled names. Adding these annotations should keep the classes, ensuring lookup from native is correct.

Changelog: [Internal] - Add DoNotStrip annotations to Fabric related classes

Reviewed By: ryancat

Differential Revision: D34726510

fbshipit-source-id: 0c1d8e1fabec75511942943b533ddd8b637a5e19
2022-03-11 09:16:01 -08:00
Kudo Chien a6c2846b37 Fix ios build error when use_frameworks is on and fabric is off (v2) (#33409)
Summary:
alternative solution for https://github.com/facebook/react-native/issues/33379

> when `use_frameworks!` is on, there are errors like:
> ```
> 'FBReactNativeSpec/FBReactNativeSpec.h' file not found
> #import <FBReactNativeSpec/FBReactNativeSpec.h>
> ```
> this error may come from from https://github.com/facebook/react-native/commit/f7e4c07c84b6 regression.
>
> when `use_frameworks!` is on, xcode will search headers from framework directories, the correct imports would be `#import <React_Codegen/FBReactNativeSpec/FBReactNativeSpec.h>` (xcode will transform dash to underscore, so it is `React_Codegen` but not `React-Codegen`). in the other hand, when `use_frameworks!` is off, the correct import is `#import <React-Codegen/FBReactNativeSpec/FBReactNativeSpec.h>`.
>
>
> this fix is specific for old architecture (fabric is off).
>
> when fabric is on, there are other errors from duplicated headers when copying to build folder. [the reason is that framework build would try to flatten headers](https://mkonrad.net/2015/03/29/xcode-static-libraries-preserving-header-directory-structure.html). we have `primitives.h` in different folders and they would be flattened into `React_Fabric.framework/Headers`. to be honest, i don't know how to deal with the problem in the meantime,  maybe subspecs are not enough, we should separate them from subspecs to dedicated podspecs so that we can have these targets as different frameworks.

in this alternative fix, i try to add `React-Codegen/React_Codegen.framework/Headers` into header search paths and make original `#import <FBReactNativeSpec/FBReactNativeSpec.h>` reachable.

[this change](7a0398c331) in the pr is just a workaround to solve breaking in latest main branch and this is not important to the `use_frameworks!` fix at all. this breaking was coming from 1804951595.

## Changelog

[iOS] [Fixed] - Fix iOS build error when Podfile `use_frameworks!` is on and Fabric is off

Pull Request resolved: https://github.com/facebook/react-native/pull/33409

Test Plan:
verify with rn-tester
1. change `fabric_enabled` to false in `packages/rn-tester/Podfile`
2. `USE_FRAMEWORKS=1 pod install`
3. build rn-tester in xcode

Reviewed By: dmitryrykun

Differential Revision: D34817041

Pulled By: cortinico

fbshipit-source-id: 4d1a610e99a807793eb3f64461e0d735c0a9ca9c
2022-03-11 09:08:07 -08:00
Samuel Susla c9bbe75be8 Remove gating for legacy interop layer view hierarchy changes
Summary: changelog: [internal]

Reviewed By: javache

Differential Revision: D34756141

fbshipit-source-id: f78ee2376d03652813353bfd88c3c349d1c6ae4f
2022-03-11 09:00:17 -08:00
Arthur Kushka 009d80bf5a Dropped `using namespace` from TurboModuleUtils.h
Summary:
using namespace in header file is a bad practice due to many reasons as well as discouraged by `-Wheader-hygiene` compiler flag which is default for many apps

https://stackoverflow.com/questions/5849457/using-namespace-in-c-headers

Changelog:
[General][Fixed] - Fixed compilation warning due to `using namespace` being used as part of header

Reviewed By: nlutsenko

Differential Revision: D34788523

fbshipit-source-id: 2a50fbf2ac3371ff5670c600c7f5ad9055060ad2
2022-03-11 06:56:10 -08:00
Mike Hardy 2a5265dff7 fix(ios, flipper): update flipper sub-pods to support macCatalyst (#33406)
Summary:
Flipper-DoubleConversion and Flipper-Glog iOS pods received a build optimization
a few versions back that pre-compiled the pods and references the xcframework slices

Unfortunately, the pre-compile did not include macCatalyst slices, so this disabled support
for flipper on macOS for react-native >0.65

lblasa has re-compiled the pods with the macCatalyst slices added

See https://github.com/facebook/flipper/issues/3117

## Changelog

<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://github.com/facebook/react-native/wiki/Changelog
-->

[iOS] [Fixed] - update Flipper pods to support re-enable macCatalyst

Pull Request resolved: https://github.com/facebook/react-native/pull/33406

Test Plan:
- [ ] The Flipper repo has a react-native test that appeared to work with these versions, CI should work here
- [ ] Prove there is no regression, a flipper-enabled build test should work for simulator iOS target on arm64
- [ ] Prove there is no regression, a flipper-enabled build test should work for simulator iOS target on x86_64 mac
- [ ] Prove there is no regression, a flipper-enabled build test should work for real device iOS target
- [ ] To prove the issue is resolved, a build should be attempted for a macCatalyst target, and it should work.

Reviewed By: cortinico

Differential Revision: D34789654

Pulled By: lblasa

fbshipit-source-id: 466803dd07b5820220512b7d7d760b94b8aa65f7
2022-03-11 02:47:27 -08:00
Brian Vaughn a7a781ff4a React DevTools 4.24.0
Summary:
https://github.com/facebook/react/blob/main/packages/react-devtools/CHANGELOG.md

Changelog:
[General][Changed] - Upgraded react-devtools-core dependency to 4.24.0

Reviewed By: lunaruan

Differential Revision: D34798578

fbshipit-source-id: ce3b09023c98a9282cce92ef9661d6cb578455e1
2022-03-10 16:38:39 -08:00
Héctor Ramos 889578a142 Download Hermes tarball during pod install
Summary:
Downloads a tarball of the Hermes source code when `pod install` is run.

If the current release is pinned to a Hermes tag, it will use that specific tag, otherwise the latest Hermes commit will be used.

# Changelog:
[Internal]

Reviewed By: cortinico

Differential Revision: D34629595

fbshipit-source-id: 5f36af4a43bc2d137dfd702082558ab9d0191140
2022-03-10 11:24:48 -08:00
fabriziobertoglio1987 52aee50a70 underlineColor transparent not working on API 21 (#30897)
Summary:
This issue fixes https://github.com/facebook/react-native/issues/29379 `underlineColorAndroid'='transparent'` does not work on Android API 21.
Setting `style: { bottomBorderColor: 'transparent'}` fixes the issue.

The following steps fix underlineColorAndroid on Android API 21:
- Store the bottomBorderColor in a local variable
- Then set the bottomBorderColor to the same color of underlineColorAndroid
- Set underlineColorAndroid
- Then Set the bottomBorderColor to the previous color previously stored in the local variable

This change requires `ReactViewBackgroundDrawable` method `getBorderColor` to be public and accessible from `ReactTextInputManager` to retrieve the border color.

6061b79283/ReactAndroid/src/main/java/com/facebook/react/views/view/ReactViewBackgroundDrawable.java (L1231-L1236)

Related Discussions https://github.com/facebook/react-native/issues/18938 https://github.com/facebook/react-native/pull/18988 https://github.com/facebook/react-native/issues/29412#issuecomment-773412466

More Information at https://github.com/fabriziobertoglio1987/react-native-notes/issues/4#issuecomment-1029780852

## Changelog

[Android] [Fixed] - Fix underlineColorAndroid transparent not working on API 21

Pull Request resolved: https://github.com/facebook/react-native/pull/30897

Test Plan:
This changes fix the Java API which can not be tested as explained in commit 709a441ecf
The java TextInputTest was excluded from the test suite in commit 709a441ecf as they need the Yoga libraries to run

**<details><summary>CLICK TO OPEN TESTS RESULTS - API 21</summary>**
<p>

Does not show underline by default (`transparent`)

```javascript
<TextInput />
```

<image src="https://user-images.githubusercontent.com/24992535/107060953-dee34d00-67d7-11eb-8f01-360dbb1420b8.png" width="150" />

```javascript
<TextInput underlineColorAndroid="red" />
```

<image src="https://user-images.githubusercontent.com/24992535/107061134-194cea00-67d8-11eb-9da1-9780b1aa8294.png" width="150" />

```javascript
<TextInput
  underlineColorAndroid="green"
  style={
     {
        borderBottomColor: 'red',
        borderBottomWidth: 2,
        borderTopColor: 'black',
        borderTopWidth: 4
     }
   }
/>
```

<image src="https://user-images.githubusercontent.com/24992535/107062411-9167df80-67d9-11eb-810c-749992d8d2d3.png" width="150" />

```javascript
<TextInput
  style={
     {
        borderBottomColor: 'red',
        borderBottomWidth: 2,
        borderTopColor: 'black',
        borderTopWidth: 4
     }
   }
/>
```

<image src="https://user-images.githubusercontent.com/24992535/107062735-e6a3f100-67d9-11eb-93c3-02cd768f8421.png" width="150" />

```javascript
<TextInput
  underlineColorAndroid="blue"
  style={
    {
      borderBottomColor: 'red',
      borderBottomWidth: 2,
      borderTopColor: 'black',
      borderTopWidth: 4,
      borderLeftColor: 'pink',
      borderLeftWidth: 7,
      borderRightColor: 'yellow',
      borderRightWidth: 7,
    }
  }
/>
```

<image src="https://user-images.githubusercontent.com/24992535/107063263-75b10900-67da-11eb-97ab-316736d525a2.png" width="150" />

```javascript
<TextInput
  underlineColorAndroid="transparent"
  style={
    {
      borderBottomColor: 'red',
      borderBottomWidth: 2,
      borderTopColor: 'black',
      borderTopWidth: 4,
      borderLeftColor: 'pink',
      borderLeftWidth: 7,
      borderRightColor: 'yellow',
      borderRightWidth: 7,
    }
  }
/>
```

<image src="https://user-images.githubusercontent.com/24992535/107063332-8792ac00-67da-11eb-82fc-99793bf4d49d.png" width="150" />

</p>
</details>

Reviewed By: cortinico

Differential Revision: D33906415

Pulled By: lunaleaps

fbshipit-source-id: bd7efe4aac40ad701aec83f051ac40dcd4a99cda
2022-03-10 11:23:33 -08:00
Lulu Wu 1804951595 Hook EarlyJsErrorHandler
Summary:
Hoop up EarlyJsErrorHandler so we could pass js error data to object-c to report.

Changelog:
[iOS][Chagned] - Add function to report early js errors

Reviewed By: RSNara

Differential Revision: D34096343

fbshipit-source-id: fdbc6ea5d1f3cc6ab55fcd22b48bbe8fb1f1ca8f
2022-03-10 10:25:32 -08:00
Dmitry Rykun 325be429fd Relative path support for app_path added
Summary:
Changelog: [Internal] This diff add support of relative paths in `app_path` argument of `use_react_native` function.

Ruby's `relative_path_from` function requires both paths to be either relative or absolute. I added `realpath()` call that converts any path to absolute.

Reviewed By: ShikaSD

Differential Revision: D33311728

fbshipit-source-id: 393a7b4f0eb26831f4d9f4cec8ec180b41cad580
2022-03-10 04:34:53 -08:00
Andrei Shikov b347c3949f Enabled blocking access for animated queues under feature flag
Summary:
Blocks on queue write/drain for Animated module under a feature flag to test whether it resolves race conditions.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D34752947

fbshipit-source-id: a1b1a286772d29a7a27b5e9c3f743cac84cc2bab
2022-03-10 04:30:37 -08:00
Genki Kondo 04acb1cbc8 Backout D34630294
Summary:
Backout D34630294 (87cdb607e4) to fix T113767991

Changelog:
[Internal][Change] - Backing out "Support animating text color with native driver"

Differential Revision: D34772459

fbshipit-source-id: 7a536e4c5a9f692ddc410cb8cb352ffe71e7c93f
2022-03-09 18:01:17 -08:00
Vincent Riemer 84f8c9ad55 Ensure LogBoxView is sized based on the "window" size instead of the "screen" size
Summary:
In iOS, the native LogBox that gets rendered for JS errors/warnings is statically sized once and bases that size off of the entire screen's size. This causes issues when being run in a Mac Catalyst app since 1) the sizing is not static since we can resize the window and 2) the size of the LogBox's root should fill the *window* and not the screen. This diff fixes both of these issues.

Changelog:
[iOS][Fixed] - Ensure LogBoxView is sized relative to the key window instead of the full screen

Reviewed By: appden

Differential Revision: D34697076

fbshipit-source-id: 9665fd51bc86ed29837672cec882bac97904b0c8
2022-03-09 15:43:37 -08:00
Samuel Susla 538636440b Convert CGFLOAT_MAX to infinity
Summary:
changelog: [internal]

For embedded React Native screens, we need to calculate the intrinsic size. To do that, we need to pass Yoga value `YGUndefined`. However, if available size was `CGFLOAT_MAX` (which is not inifinity), we would pass it to Yoga and it would calculate layout with available height/width `CGFLOAT_MAX`.

To fix this, we convert `CGFLOAT_MAX` to infinity. Which in YogaLayoutableShadowNode gets converted to YGUndefined.

Reviewed By: ShikaSD

Differential Revision: D34719047

fbshipit-source-id: e6fd40724f81abfba164e67efc9ca8fc74e9b235
2022-03-09 03:36:11 -08:00
Xin Chen bb8ff9260f Fix issue with interruptted scroll cause touch in scroll view unresponsive
Summary:
This diff fixed an issue that caused regression in fb4a and React Native panel apps regarding scrolling behavior. When scrolling in either horizontal or vertical scroll view, if the consecutive touch interrupted the previous fling (post touch scrolling), the scroll view would block touch event from dispatching to the content view. Thus, the items in scroll view are not responding to touch events anymore.

The diff that caused this issue is D34627330 (0368081858). In that diff, I added code to cancel the scheduled post touch runnable when touch down is received in scroll view. That is expected as the post touch runnable is to handle snapping scroll case, where [an extra fling](https://fburl.com/code/7qza1ece) is triggered to make sure scroll view stops at the right position. When user touch the screen before the previous scroll fling finishes, this post processing is no longer needed -- the new touch should take full control of scroll view.

However, in D34627330 (0368081858), I failed to reset the runnable instance `mPostTouchRunnable` to null when cancelling it. This caused the future post touch handle logic [stops to run](https://fburl.com/code/lh8pi7l0), as it thinks the runnable is non-null and has been scheduled. This prevents fabric from receiving proper scroll state updates from android side, thus causing a state corruption and affects logic to decide where the scroll offset is and where the child item is after that.

This diff fixed the issue by resetting the runnable instance, as well as making sure if the runnable is already running and the extra fling starts, we are canceling that fling animation properly.

Changelog:
[Android][Fixed] - Fixed regression on content in scroll view not responding to touch when fling got interrupted

Reviewed By: ShikaSD

Differential Revision: D34734129

fbshipit-source-id: 7d7689d203ce76c59cd44e16e31582317bb409bd
2022-03-08 18:04:05 -08:00
Nick c34ef5841c Fix: Android react.gradle VmCleanup when packaging as library (#33179)
Summary:
When packaging a react app as an android library with the enableVmCleanup flag not set to false, an error occurs since the "package${targetName}" task can not be found. This PR adds a simple null check, similar to what is being done for the sTask and mTask just below it to prevent the error.

## Changelog

<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://github.com/facebook/react-native/wiki/Changelog
-->

[Android] [Fixed] - Fixes android build error when compiling as library

Pull Request resolved: https://github.com/facebook/react-native/pull/33179

Test Plan:
Compile project as library (com.android.library), and should not trigger and error with these changes.

Would also like to have this fix cherry-pick'd to release 0.67 after merging.

Reviewed By: ShikaSD

Differential Revision: D34475934

Pulled By: cortinico

fbshipit-source-id: ce6ce43960c4b388c4b1da49a9a6e21fd3bf8e16
2022-03-08 13:35:28 -08:00
Xavier Deguillard ece1dd4ed9 BUCK: define GLOG_NO_ABBREVIATED_SEVERITIES everywhere
Summary:
This is only defined on Windows, and thus code that compiles on all platforms
may successfully build on Linux/macOS, but not on Windows, making it
potentially harder to detect and debug. Let's unify all platforms to solve
this.

Changelog: [Internal]

Reviewed By: chadaustin

Differential Revision: D34648154

fbshipit-source-id: b2549bb3eb120e6207cab8baaafced8b1b18e6a7
2022-03-08 12:35:48 -08:00
John Porto c8067f1ffd Misc MsgGen fixes
Summary:
Fix a few issues with msggen:
1. run_msggen: fully-qualified path to clang-format
1. Updated the license for autogenerated files

Changelog: [Internal]

Reviewed By: neildhar

Differential Revision: D34114718

fbshipit-source-id: 831d4b20bfdc39cfa1226e2a32dcb445c8086ff3
2022-03-08 10:22:28 -08:00
Samuel Susla e97e3499c3 Avoid string copy in event dispatching
Summary:
Changelog: [internal]

To avoid unnecessary string copy in event pipeline, use move semantics.

Event pipeline has ownership of event type. Passing it by reference ends up in a copy when `RawEvent` object is constructed. To avoid this, pass string by value through each layer and use move semantics to avoid extra copies.

Reviewed By: javache

Differential Revision: D34392608

fbshipit-source-id: c11d221be345665e165d9edbc360ba5a057e3890
2022-03-08 04:28:51 -08:00
caioagiani 8200063ac6 fix: typos (#33040)
Summary:
Fix typos in:

- `Libraries/Renderer/implementations/ReactFabric-dev.js`: transfered -> **transferred**
- `Libraries/Renderer/implementations/ReactNativeRenderer-dev.js`: transfered -> **transferred**
- `ReactAndroid/src/main/java/com/facebook/react/modules/network/ProgressiveStringDecoder.java`: remainderLenght -> **remainderLength**
- `ReactAndroid/src/main/jni/first-party/yogajni/jni/ScopedGlobalRef.h`: Transfering -> **Transferring**
- `ReactCommon/react/renderer/graphics/Transform.h`:  tranformation -> **transformation**
- `packages/rn-tester/js/examples/ToastAndroid/ToastAndroidExample.android.js`: occured -> **occurred**

## Changelog

<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://github.com/facebook/react-native/wiki/Changelog
-->

[Internal] [Fixed] - fix typos

Pull Request resolved: https://github.com/facebook/react-native/pull/33040

Test Plan: Considering this only changes code comments, I don’t think this pull request needs a test plan.

Reviewed By: cortinico, pasqualeanatriello

Differential Revision: D34003812

Pulled By: dmitryrykun

fbshipit-source-id: 5c8699f8efcc4354854190a9aade30dbc5c90fdb
2022-03-08 03:58:58 -08:00