Commit Graph

38536 Commits

Author SHA1 Message Date
Genki Kondo d0fcd43f1a Introduce AnimatedObject JS node (#36688)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/36688

AnimatedObject is a more generic version of AnimatedTransform, able to handle animated values within arrays and objects. This is useful for props of native components that may need to be animated per field.

I considered flattening the node graph by removing AnimatedStyle and AnimatedTransform. However, this would add significant complexity in AnimatedProps because prop and style values depend on being submitted together on an animation tick (such as transform) using native driver; also, we'll have to special case style anyway.

Changelog:
[Internal][Added] - Introduce AnimatedObject JS node for handling array and object prop values

Reviewed By: rshest

Differential Revision: D44279594

fbshipit-source-id: 9504d841dc9196e51d09a0247601de4d4f991a49
2023-03-31 10:16:36 -07:00
Pieter De Baets 64033637e2 Align Android EventEmitter naming (#36718)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/36718

`EventEmitterWrapper` uses "invoke", while the event is still being queued and the event handler will only actually be "invoked" in another async step. Instead, align with the wrapped object and use "dispatch".

Also small optimization to construct the EventEmitterWrapper object fully in C++, without Java having to call back into C++ again by using `newObjectCxxArgs`.

Changelog: [Internal]

Reviewed By: mdvacca

Differential Revision: D44536400

fbshipit-source-id: 7b14acf3629944f4a20ab4f509fbae7f58de98e0
2023-03-31 07:14:10 -07:00
Lulu Wu 606946ddad Check nullability for current context (#36721)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/36721

We check RN instance immediately when onGlobalLayout is called in ReactRootView
https://www.internalfb.com/code/fbsource/[1f189dbb7238aa69319925bdc6a9e5389e160ad8]/xplat/js/react-native-github/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/ReactRootView.java?lines=903-907

but the RN instance could be destroyed due to exception, so when emitUpdateDimensionsEvent is called down the line there could be NPE which results in this [Logview](https://www.internalfb.com/logview/details/facebook_android_crashes/0f56580ff7b95827c8d4f932f2358841), we need to double check nullability in emitUpdateDimensionsEvent to avoid this

Changelog:
[Fixed][Android] - Check nullability for current context

Reviewed By: cipolleschi

Differential Revision: D44539899

fbshipit-source-id: c2587e92c1b8ca451420d340ac474860174d7a09
2023-03-31 03:03:33 -07:00
David Vacca b1b118d0f6 Refactor of IntBufferBatchMountItem class (#36728)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/36728

This diff refactors the creation and visibility of IntBufferBatchMountItem

This is not a breaking compatibility change because nobody should be using this class

changelog: [internal] internal

Reviewed By: javache

Differential Revision: D44115916

fbshipit-source-id: f0b0464483cafe55ffaf661b18c692be0df41199
2023-03-30 23:58:25 -07:00
David Vacca ed448b5ba4 Refactor preallocation of views (#36606)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/36606

This diff refactors the preallocation of views to minimize visibility of PreAllocateViewMountItem

this is not a backward compatible change because nobody should be using this class

Changelog: [Internal] Internal

Reviewed By: javache

Differential Revision: D44115487

fbshipit-source-id: 2d00f9f5edbe0517c3c5fcef94290180fa418fb3
2023-03-30 21:30:51 -07:00
David Vacca 817db84c6b Refactor creation of SendAccessibilityEventMountItem (#36607)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/36607

In this I'm refactoring the creation of SendAccessibilityEventMountItem to reduce visibility of classes

Changelog: [Internal] Internal

Reviewed By: javache

Differential Revision: D44115052

fbshipit-source-id: 021f59a65aed152324a13947609e23c0191ca0e8
2023-03-30 20:06:20 -07:00
David Vacca aa3e087be1 Refactor creation of MountItems (#36605)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/36605

This diff introduces the class MountItemFactory that will be used to create MountItems in Fabric.
The purpose of this refactor is to reduce visibility for custom implementations of MountItems

This should not be a breaking change, because nobody should be using these classes

changelog: [internal] internal

Reviewed By: javache

Differential Revision: D44115053

fbshipit-source-id: a62d0a42239d29380aa10d5eab428af90c313d00
2023-03-30 18:32:12 -07:00
David Vacca c76ab8d01d Small refactor to log state data during development (#36603)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/36603

Small refactor to log state data during development for preallocation of items

Changelog: [Internal] Internal

Reviewed By: javache

Differential Revision: D44112419

fbshipit-source-id: 290fbf0db3ea3f9863e7c86249dd1e6943556baa
2023-03-30 16:22:48 -07:00
Ruslan Lesiutin 8a18b53bcd bump packages for 0.73 (#36556)
Summary:
Changelog: [Internal]

Publishing to check CI if bumping and aligning in the same commit will work, since these new versions are not available on npm yet, but maybe our new monorepo setup will resolve this

**Adding back `react-native/virtualized-lists` as a workspace to `xplat/js` so that it won't be resolved from npm**

#publish-packages-to-npm

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

Reviewed By: cipolleschi

Differential Revision: D44255353

Pulled By: hoxyq

fbshipit-source-id: 21372487d6e9c0b2382b7cd9af835beed46b8ce1
2023-03-30 15:55:58 -07:00
Phillip Pan 5457811a16 don't pass around react context in react package if it's not needed (#36711)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/36711

Changelog: [Internal]

minimizing callsites to the react context, which has turned into a bloated toolbox class

Reviewed By: javache

Differential Revision: D44493500

fbshipit-source-id: 7272b18af96103dee3658d151fd8e9f03846bd09
2023-03-30 15:20:59 -07:00
David Vacca c62fca7525 Reduce visibility of FabricComponentName mappings (#36602)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/36602

This diff refactors and reduces visibility of the legacy class FabricComponents. This should not be a breaking change because nobody should be using it (there is no purpose to be used externally)

changelog: [internal] internal change on the APIs

Reviewed By: javache

Differential Revision: D44112418

fbshipit-source-id: 5608d682ca4fddb8e50db82ff23668fd82dccfb6
2023-03-30 14:26:43 -07:00
Alex Hunt f67bd676e5 Update template metro.config.js, remove transitive metro dep from main package (#36723)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/36723

Changelog: [Internal]

Reviewed By: hoxyq

Differential Revision: D44542544

fbshipit-source-id: 70807edc8a183c28e1f0018a5426f4f2e29580a0
2023-03-30 12:48:46 -07:00
Pieter Vanderwerff 367faa2282 Deploy v0.203.0 to xplat (#36727)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/36727

Changelog: [Internal]

Reviewed By: SamChou19815

Differential Revision: D44526612

fbshipit-source-id: 492a19a2186417d4562291ed9e7f0f18c0799a2c
2023-03-30 12:38:57 -07:00
Nicola Corti 7449fad587 Add examples of Direct Manipulation in Fabric Intrerop (#36724)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/36724

Similarly to iOS, this adds some examples of direct manipulation on Android using
all the various methods.

Changelog:
[Internal] [Changed] - Add examples of Direct Manipulation in Fabric Intrerop

Reviewed By: cipolleschi

Differential Revision: D44541437

fbshipit-source-id: b6e10ac0a815f41ff3c980236b7d8c6937e92065
2023-03-30 11:46:27 -07:00
Nicola Corti 97a9d3c01b Add example for dispatchViewManagerCommand on Fabric Interop (#36725)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/36725

This diff adds an example of using `dispatchViewManagerCommand` for the Fabric Intreop on Android.

Changelog:
[Android] [Added] - Add example for dispatchViewManagerCommand on Fabric Interop

Reviewed By: cipolleschi

Differential Revision: D44540951

fbshipit-source-id: 85bc65ad0eb3a951fbb37d61ca26532ec3cc53b7
2023-03-30 11:46:27 -07:00
Richard Howell 677672ab1f add missing function prototypes (#36709)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/36709

Add missing function prototypes

Changelog: [Internal]

Reviewed By: adamjernst

Differential Revision: D44520929

fbshipit-source-id: f363b8355b805f7f1a2701ebd9a61efd0d6bc06e
2023-03-30 08:34:35 -07:00
Alex Hunt c5a47abaf8 Bump RN CLI, add @react-native/metro-config to template (#36623)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/36623

Changelog:
[General][Changed] - The default `metro.config.js` in apps now extends `react-native/metro-config`, and should be updated in existing apps.

~~`react-native/rn-get-polyfills.js` is removed and should be updated to `react-native/js-polyfills` in existing apps (this is part of the new default config).~~

#publish-packages-to-npm

## Context

### React Native Metro config → React Native repo (https://github.com/facebook/react-native/pull/36502)

We (the React Native team) are aiming to relocate the default Metro config for React Native out of `react-native-community/cli-plugin-metro` and **into the React Native repo + app template** as a new `react-native/metro-config` package.

This is the first (and minimum viable) phase we can ship to separate the release process of Metro from RN CLI in order to reduce coupling and iterate faster for our users.

**See full motivation, design, and test plan (which previewed the CLI bump) here: https://github.com/facebook/react-native/pull/36502**

## Changes

NOTE: This PR is pending the inclusion of a bump to `react-native-community/cli`, and will be sequenced after https://github.com/react-native-community/cli/pull/1875 is merged.

- Upgrade `react-native-community/cli` to `11.0.0`, upgrade all `metro` packages to `0.76.0` (version distributed in this CLI release).
- Update the `metro.config.js` file in `packages/react-native/template/`.
    - Now merges defaults from `react-native/metro-config`, and can be used with CLI >= 11.0.0.
- Update the `metro.config.js` files for `packages/react-native/` and `packages/rn-tester/` (these are integration test locations).
    - Now merges defaults from `react-native/metro-config`, and can be used with CLI >= 11.0.0.

Changes to `react-native/metro-config` — `0.72.1` (prepared but not depended on yet):

- Export `mergeConfig` util (removing direct `metro-config` dependency in consuming projects).
- Explicitly depend on `metro-react-native-babel-transformer` and `metro-runtime` (transitively included today).

Reviewed By: cortinico, blakef

Differential Revision: D44099691

fbshipit-source-id: 405635dd69fd50a1e9548279eaeda3c932b5b167
2023-03-30 07:30:54 -07:00
Ján Ondrušek d1277df455 add missing include (#36708)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/36708

`#include` what you use!

Changelog: [Internal]

Reviewed By: ispeters

Differential Revision: D44516344

fbshipit-source-id: a96afe7a7098609270f1d25321133a9afb443db2
2023-03-30 06:43:40 -07:00
Sparsha Saha cb376dd0d8 Make setJSEngineResolutionAlgorithm a public method (#36715)
Summary:
`setJSEngineResolutionAlgorithm` is marked as private while it looks like it was intended to be public.
While the current implementation does not cause any issues as such, but in brownfield we will have the option to explicitly set the JS engine to hermes or jsc when initialising the ReactInstanceBuilder.

Right now, we look if the engine is set and if unset we look for the jsc engine. If jsc is not present we select hermes and this process unnecessary throws a warning.

## Changelog:

<!-- Help reviewers and the release process by writing your own changelog entry.

Pick one each for the category and type tags:

[ANDROID|GENERAL|IOS|INTERNAL] [BREAKING|ADDED|CHANGED|DEPRECATED|REMOVED|FIXED|SECURITY] - Message

For more details, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests
-->

[ANDROID][FIXED] - Changed the scope of `setJSEngineResolutionAlgorithm` to public from private. Brownfield apps should be able to setup the JSResolutionAlgorithm before hand.

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

Reviewed By: cortinico

Differential Revision: D44535444

Pulled By: javache

fbshipit-source-id: ae91e50de10c993c80ed4bba6f2fece64af178c4
2023-03-30 04:59:35 -07:00
Nicola Corti e5dd9cdc66 Re-enable Fabric in the default app template/RN-Tester (#36717)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/36717

After D43711737 landed, it turns out that Fabric is always disabled for both
RN-Tester and new app from template (so for 0.72 also RC0).
The reason is that a new method `createRootView(Bundle)` was introduced inside
`ReactActivityDelegate`. Both RN Tester and the template were using the
old `createRootView()` method which is not called anymore at this stage
(should potentially be deprecated?).

This diff fixes it by overriding both method inside `DefaultReactActivityDelegate`
so that both methods are setting the Fabric renderer.

Changelog:
[Android] [Fixed] - Re-enable Fabric in the default app template/RN-Tester

Reviewed By: cipolleschi

Differential Revision: D44536222

fbshipit-source-id: d22a0c522f011a8fe4d27b5d8f2fcf5dd13c3058
2023-03-30 04:44:21 -07:00
gabrieldonadel 66ae98e4a4 chore: Expand Codegen emitCommonTypes function adding the remaining basic types (#36706)
Summary:
[Codegen 81] This PR expands the  `emitCommonTypes` function adding support for the remaining basic types and adding
a `convertKeywordToTypeannotation` function to the codegen Parser class and implementing it in the Flow and TypeScript parsers as requested on https://github.com/facebook/react-native/issues/34872

## Changelog:

[Internal] [Added] - Expand Codegen emitCommonTypes function adding the remaining basic types

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

Test Plan: Run `yarn jest react-native-codegen` and ensure CI is green

Reviewed By: christophpurrer

Differential Revision: D44504571

Pulled By: cipolleschi

fbshipit-source-id: 220d9bc0cc39614002a67dafd626e5a4878a1447
2023-03-30 03:46:47 -07:00
Riccardo Cipolleschi a44d8a0f8a Add Examples for Direct Manipulation in the Interop Layer (#36610)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/36610

This change add to RNTester examples of a legacy Native Component, loaded in the New Architecture through the Interop Layer, that uses the APIs described in the [Direct Manipulation](https://reactnative.dev/docs/direct-manipulation) sectioon of the website.

## Changelog:
[iOS][Added] - Added examples of direct manipulation

Reviewed By: sammy-SC

Differential Revision: D43978674

fbshipit-source-id: 1cbc56f28034f84f309166e3e392ad97a8164e64
2023-03-29 15:30:26 -07:00
Riccardo Cipolleschi c7aaae61ca Make UIManager.dispatchViewManagerCommand work in Fabric through Interop Layer (#36578)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/36578

This change brings to the Fabric Interop Layer the possibility to directly call native methods on the View Manager, something that was not possible before and that we can use to simplify the migration to the New Architecture.

## Changelog:
[iOS][Added] - Native Components can now call native methods in Fabric when they are loaded through the Interop Layer

Reviewed By: sammy-SC

Differential Revision: D43945278

fbshipit-source-id: fe67ac85a5d0db3747105f56700d1dbba7ada5f1
2023-03-29 15:30:26 -07:00
Nicola Corti 688df2f7cc Move from from accidental template/ folder on root. (#36704)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/36704

Following up to #36696, I accidentally failed a rebase and had files
commited on the wrong folder. I'm updating them here to use `packages/react-native/template`.

Changelog:
[Internal] [Changed] - Move from from accidental template/ folder on root

Reviewed By: cipolleschi

Differential Revision: D44502966

fbshipit-source-id: d408f38884444c4ecc03852b1d145bf2e89df672
2023-03-29 14:01:35 -07:00
Phillip Pan a4fe9b2b6d deprecate ReactModuleWithSpec (#36673)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/36673

Changelog: [Android][Deprecated]

in this change, we deprecate ReactModuleWithSpec because it can be replaced with the TurboModule interface which better describes our generated modules.

Reviewed By: cortinico

Differential Revision: D44450959

fbshipit-source-id: adab192593843926f35bdbeb346ef374dd80e615
2023-03-29 12:06:52 -07:00
fortmarek 0328a8d26b Use packaged react-native in test-e2e-local script (#36703)
Summary:
The current `test-e2e-local` script had two bugs:
- On [this](https://github.com/facebook/react-native/blob/c1c22ebacc4097ce56f19385161ebb23ee1624b3/scripts/test-e2e-local.js#L219) line we were initializing a new RN project with the packed `react-native` created [here](https://github.com/facebook/react-native/blob/c1c22ebacc4097ce56f19385161ebb23ee1624b3/scripts/test-e2e-local.js#L211)
- We were updating the local RN version after running `npm pack` [here](https://github.com/facebook/react-native/blob/c1c22ebacc4097ce56f19385161ebb23ee1624b3/scripts/test-e2e-local.js#L214). This meant that the version inside the packaged `react-native-xyz.tgz` was not updated since we ran `pack` before updating it. This was fine since the `init` command was using the local `react-native` repository instead of the packed version.

## Changelog:

[INTERNAL] [FIXED] - Use packaged react-native in test-e2e-local script
<!-- Help reviewers and the release process by writing your own changelog entry.

Pick one each for the category and type tags:

[INTERNAL] [FIXED] - Use packaged react-native in test-e2e-local script

For more details, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests
-->

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

Test Plan:
- Run `yarn test-e2e-local -t RNTestProject -p Android`. The command should succeed.

I am not completely sure how to double check that we are using the packed version. Locally, I have a `fsmonitor--daemon.ipc` in my `react-native/.git` that can't be copied. The `.git` folder would be copied only when `cli.js init` was called with the whole repository  – which is how I found out about the issue in the first place.

Reviewed By: hoxyq

Differential Revision: D44504599

Pulled By: cipolleschi

fbshipit-source-id: e57e2858bab46d4f978eed3cbaf3e504138594b8
2023-03-29 10:21:44 -07:00
Kyaw Thura 969a8d0799 Enrich getCommandProperties with the parser object (#36500)
Summary:
> [Codegen 101] The code of getCommandProperties is almost identical in [Flow](https://github.com/facebook/react-native/blob/main/packages/react-native-codegen/src/parsers/flow/components/index.js#L128) and [TS](https://github.com/facebook/react-native/blob/main/packages/react-native-codegen/src/parsers/typescript/components/index.js#L129). There are small differences between flow/ts, so we need for it to accept a Parser object. Enrich the parser object with the required methods if necessary.

## Changelog:

[Internal] [Changed] - Enrich getCommandProperties with the parser object

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

Test Plan: `yarn test react-native-codegen`

Reviewed By: cortinico

Differential Revision: D44415265

Pulled By: cipolleschi

fbshipit-source-id: ed13b553a6f782beb0f1aec79bd17d865a96fac9
2023-03-29 09:28:00 -07:00
Riccardo Cipolleschi 3ac7a5ef4e Fix: Adapt template to new rules (#36705)
Summary:
Recently, we changed the logic to verify the body of a PR so that it is more compatible internally and externally, in both ways. But we forgot to update the template, so right
now, all the created PR are incompatible with the internal PR checker.
The required change is to have `:` after the Changelog title.
For consistency, I added the `:` after ALL the titles.

## Changelog:

[Internal] - Changed the PR template to align it to the new rules

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

Test Plan: No danger errors nor internal linter errors

Reviewed By: christophpurrer

Differential Revision: D44503519

Pulled By: cipolleschi

fbshipit-source-id: 43963c3cf774d19d6de8e86b18b684e76dd0fe87
2023-03-29 09:17:53 -07:00
Samuel Susla a9e7da12af Do not strongly own State from Java (#36699)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/36699

Changelog: [internal]

This fixes a crash introduced in D43692171 where `jsi::Pointer` outlives `jsi::Runtime` in which it was created. This leads to a crash.
The diff changed ownership model, retaining `TextLayoutManager` strongly from `ParagraphState`.

To resolve this, in this diff we change how `StateWrapperImpl` owns state, moving from shared_ptr to weak_ptr. We have tried to do it previously in D26815275 but it had to be reverted because it broke end to end tests. I made sure the tests are fine. However it is the right ownership model. Java objects should not strongly hold onto anything in ShadowTree. If ShadowTree is destroyed, Java calls should noop, not keep objects in memory and have them handle the case when runtime was destroyed.

jest_e2e[run_all_tests]

Reviewed By: cipolleschi

Differential Revision: D44472121

fbshipit-source-id: 83b79329440ac1211902ea9511c0dde9a77ab9e9
2023-03-29 09:11:47 -07:00
Nicola Corti fec5658a32 Fix the setup to allow the build-from-source on host projects (#36702)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/36702

With the monorepo changes we broke the build from source for users.
This fixes it so that folks can just follow the guide:
https://reactnative.dev/contributing/how-to-build-from-source

Changelog:
[Android] [Fixed] - Fix the setup to allow the build-from-source on host projects

Reviewed By: cipolleschi

Differential Revision: D44502428

fbshipit-source-id: 3ad8fb114f5e2f7ffdf6fffa617ceaa45334f5f3
2023-03-29 09:05:37 -07:00
Lorenzo Sciandra 8eb28e77b9 add 0.71.5 changelog (#36698)
Summary:
Adds changelog for new patch.

## Changelog:

<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests
-->

[Internal] [Changed] - add changelog entry for 0.71.5

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

Test Plan: N/A

Reviewed By: christophpurrer

Differential Revision: D44502179

Pulled By: cipolleschi

fbshipit-source-id: fe0470ccc067966af3a98e6959702ca26c7af6db
2023-03-29 08:07:48 -07:00
Nicola Corti c1c22ebacc Convert the app template to Kotlin (#36696)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/36696

As the title says, we're converting the new app template to Kotlin.
This will reduce the template size and make it more aligned to market standards.

Changelog:
[Android] [Changed] - Convert the app template to Kotlin

Reviewed By: mdvacca

Differential Revision: D44142081

fbshipit-source-id: 6111360b6580460eba0341e47c55704cc673e444
2023-03-29 05:09:32 -07:00
Nicola Corti 94debf1b3a Add Fabric Interop event example (#36692)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/36692

Similar to the iOS counterpart,
this changes adds an example to RNTester to verify that the Interop Layer can process bubbling events in Fabric as it used to do in Paper.

Changelog:
[Internal] [Changed] - Add Fabric Interop event example

Reviewed By: cipolleschi

Differential Revision: D44467555

fbshipit-source-id: 1f1af27583c402641c549bc2926a64469dcd7b3f
2023-03-29 04:48:21 -07:00
Nicola Corti 7562eb5550 Add Fabric Interop constants example (#36693)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/36693

Similar to #36417, this changes adds an example to RNTester to verify that the Interop Layer can process constants in Fabric as it used to do in Paper for Android.

Changelog:
[Android] [Added] - Add Fabric Interop constants example

Reviewed By: cipolleschi

Differential Revision: D44466391

fbshipit-source-id: 74e654319b93e60b415297dcdddc98eb100913df
2023-03-29 04:48:21 -07:00
Samuel Susla e17385ab06 React Native sync for revisions 3554c88...77ba161
Summary:
This sync includes the following changes:
- **[77ba1618a](https://github.com/facebook/react/commit/77ba1618a )**: Bugfix: Remove extra render pass when reverting to client render ([#26445](https://github.com/facebook/react/pull/26445)) //<Andrew Clark>//
- **[520f7f3ed](https://github.com/facebook/react/commit/520f7f3ed )**: Refactor ReactDOMComponent to use flatter property operations ([#26433](https://github.com/facebook/react/pull/26433)) //<Sebastian Markbåge>//
- **[0131d0cff](https://github.com/facebook/react/commit/0131d0cff )**: Check if suspensey instance resolves in immediate task ([#26427](https://github.com/facebook/react/pull/26427)) //<Andrew Clark>//

Changelog:
[General][Changed] - React Native sync for revisions 3554c88...77ba161

jest_e2e[run_all_tests]

Reviewed By: poteto

Differential Revision: D44476026

fbshipit-source-id: c6935d760a068672b714722dee1fd24839c08c4b
2023-03-29 01:59:19 -07:00
Phillip Pan bd7aa2c82d trigger codegenned reflection if module is a turbomodule (#36672)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/36672

Changelog: [Internal]

if we look at usages of ReactModuleWithSpec, we see that it's existence was to simply identify generated native modules since the inheritance graph of native modules was different if they were generated.

this was introduced before we created the TurboModule interface, which all codegenned native modules also conform to. since that exists now, there's no need for both of these. this is the only callsite in our code where ReactModuleWithSpec triggers any logic, so i'm updating it.

bypass-github-export-checks

Reviewed By: javache

Differential Revision: D44450687

fbshipit-source-id: f9c26fce8e360b6e319153aad83fc788079bac91
2023-03-28 23:48:23 -07:00
Phillip Pan e4a0a02d6a add unit test for method reflection on generated native modules (#36671)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/36671

Changelog: [Internal]

BaseJavaModuleTest tests the reflection of the native module methods wrapped by the JavaModuleWrapper abstraction, this abstraction is used by JNI in the C++ layer.

however, though we already have logic that supports the reflection of our codegenned modules (turbomodules), we didn't have a test for it yet, so i'm adding it in this change.

Reviewed By: javache, cortinico

Differential Revision: D44450433

fbshipit-source-id: 44abcf188d4b0559c684a95b058bd55e082b5531
2023-03-28 22:06:26 -07:00
Vincent Riemer a7f7f8aca9 Ensure Pressability doesn't forward onClick to onPress when it receives a click via pointer events (#36614)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/36614

Changelog: [Internal] - Ensure Pressability doesn't forward onClick to onPress when it receives a click via pointer events.

This is a better version of D43128801 which ensures that click events which are triggered by the new pointer events event emitter don't trigger onPress in Pressability — avoiding the double onPress issue while ensuring all existing usecases of onClick continue to work.

Reviewed By: yungsters

Differential Revision: D44031433

fbshipit-source-id: 5ecdd132f7f91338c5a3632c05510f96495b512e
2023-03-28 16:00:20 -07:00
Phillip Pan eaf8f8a161 decouple BaseJavaModuleTest from PowerMock (#36670)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/36670

Changelog: [Internal]

so powermock doesn't have compatibility with JDK 18 (not sure what RN is on), but regardless my understanding is that we should be moving away from powermock since it's not maintained anymore.

this test was disabled because of that so this should allow it to run again.

Reviewed By: javache, cortinico

Differential Revision: D44445586

fbshipit-source-id: f9cabe80332a9ef11df690ac2af20bd60bb61641
2023-03-28 15:55:14 -07:00
Ruslan Shestopalyuk 1301d3c19b Refer BUCK file for WebPerformance tests to the new location in packages (#36687)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/36687

## Changelog:

This apparently fell into the cracks during the recent (awesome! :)) monorepo migration, as the result the tests set for `WebPerformance` became empty.

Reviewed By: hoxyq

Differential Revision: D44466070

fbshipit-source-id: b13a696e73b18823f975946e8bc2e99d800d8891
2023-03-28 14:25:33 -07:00
Riccardo Cipolleschi a881269503 Fix RNTester in main (#36686)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/36686

After the recent changes of Metro and Metro-Config, we need to update the path used to load the bundle in RNTester

## Changelog:
[General][Fixed] - Use the right path to load RNTester bundle

Reviewed By: cortinico

Differential Revision: D44465418

fbshipit-source-id: 96170194579792f9a5d8a141328d43e45a4db973
2023-03-28 10:49:30 -07:00
Riccardo Cipolleschi 6668e7bd03 Add support to build hermes from a specific commit (#36681)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/36681

This change is needed to add some E2E tests on the Hermes repo so that we can test Hermes against iOS other than android.

## Changelog:
[Internal][Added] - Add possibility to download Hermes from a specific commit

Reviewed By: cortinico

Differential Revision: D44460479

fbshipit-source-id: 89c196aa7c38533e4904444f7f17eb3236fc6356
2023-03-28 10:06:26 -07:00
Ruslan Shestopalyuk 4a5f55031c Don't cache UIManager type inside the Event data structure (#36677)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/36677

## Changelog:

[Internal] - Don't cache UIManager type inside the Event data structure

A follow up to https://github.com/facebook/react-native/pull/36659

It's redundant, and it's good to have fewer "sources of truth" and keep the notion of UIManagerType separate from Event data structures.

Reviewed By: javache

Differential Revision: D44453812

fbshipit-source-id: 4efc0bb115bb4750e27afb2390afc9736ae67469
2023-03-28 09:39:39 -07:00
Ruslan Shestopalyuk 9ccf85e240 Fix hashing function in event name mapping in PerformanceEntryReporter (#36682)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/36682

## Changelog:

[Internal][Fix] - Fix hashing function in event name mapping in PerformanceEntryReporter

A textbook mistake, when mapping event names via the constant lookup table, only the first 8 characters were effectively taken into account, thus mixing names of some events.

Reviewed By: rubennorte

Differential Revision: D44462195

fbshipit-source-id: 273891d92251014661af731618d8a549627b2983
2023-03-28 09:16:36 -07:00
Ramanpreet Nara 83056947aa Setup TurboModule interop test in Fb4a (#36669)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/36669

The test: Route all TurboModules in Fb4a through the interop layer.

So now, instead of using the C++ codegen for method dispatch, TurboModules will instead be using JavaInteropTurboModule, which uses the ReactMethod annotations for method dispatch.

MobileConfig actualization diff: D44405316.

Changelog: [Internal]

Reviewed By: cortinico

Differential Revision: D44405336

fbshipit-source-id: 3b00028e26cdcd229e64630eef73409a3264636a
2023-03-28 09:11:56 -07:00
Ramanpreet Nara 1f7daf988b Finish the JS-facing side of the TurboModule interop layer (#36630)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/36630

## Changes
This diff hooks up global.nativeModuleProxy to the TurboModule interop layer.

Now, when you call NativeModules.Foo, the TurboModule system will create the Foo interop module, and return it to JavaScript.

|**Language**|**Abstraction**|**Description**|
|Java/C++|MethodDescriptor| The information needed by JavaTurboModule::invokeJavaMethod() to execute a module method: [example](https://www.internalfb.com/code/fbsource/[78577e97310db97c489e976168ca6ddf4cb894c3]/xplat/js/react-native-github/ReactCommon/react/nativemodule/samples/platform/android/ReactCommon/SampleTurboModuleSpec.cpp?lines=34-36).|
|Java|TurboModuleInteropUtils| Takes the interop module object, and parses out MethodDescriptors from the methods annotated with ReactMethod|
|C++|JavaInteropTurboModule| Facilitates JavaScript -> Java method dispatch for interop modules. Extends [JavaTurboModule](https://www.internalfb.com/code/fbsource/[6f0698784af39dd0e881d9a69087ae6ac5e9cdc4]/xplat/js/react-native-github/ReactCommon/react/nativemodule/core/platform/android/ReactCommon/JavaTurboModule.h?lines=28). Needs to be created with a list of MethodDescriptors.|

Shape of MethodDescriptor:
```
class MethodDescriptor {
    String methodName;
    String jniSignature;
    String jsiReturnKind;
    int jsArgCount;
}
```

## Example
global.nativeModuleProxy.Foo:
1. **Java:** Use TurboModuleManager to create the Java interop module for Foo
2. **Java:** Use TurboModuleInteropUtils to generate Foo's MethodDescriptors
3. **C++:** Use Foo's MethodDescriptors to create, cache, and return a JavaInteropTurboModule object to JavaScript.

Changelog: [Internal]

Reviewed By: cortinico

Differential Revision: D43918998

fbshipit-source-id: 562d3d7dc7f2ddb085dea6e94d72e1601012b741
2023-03-28 09:11:56 -07:00
Ramanpreet Nara 185bc248e4 Finish the Java-facing side of the TurboModule interop layer (#36627)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/36627

## Changes
Now, when you call TurboModuleManager.getModule(interopModuleName), the TurboModuleManager will create and return that interop module to you.

Changes in this diff:
1. Forward interop NativeModules from app's ReactPackages to the TurboModuleManager
2. Extend TurboModule system's module creation algorithm to create interop NativeModules.

## Details
TurboModuleManagerDelegate's capabilities:
||API| Without Interop | With Interop |
|same|getModule()|Java [NativeModule](https://www.internalfb.com/code/fbsource/[e5db2a0dc412f0656f7eeec1db9d2da4aab61f40]/xplat/js/react-native-github/ReactAndroid/src/main/java/com/facebook/react/bridge/NativeModule.java?lines=21) that also implements [TurboModule](https://www.internalfb.com/code/fbsource/[c7089c1408eda109f342a1f33252533e743614ed]/xplat/js/react-native-github/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/interfaces/TurboModule.java?lines=11) |Java [NativeModule](https://www.internalfb.com/code/fbsource/[e5db2a0dc412f0656f7eeec1db9d2da4aab61f40]/xplat/js/react-native-github/ReactAndroid/src/main/java/com/facebook/react/bridge/NativeModule.java?lines=21) that also implements [TurboModule](https://www.internalfb.com/code/fbsource/[c7089c1408eda109f342a1f33252533e743614ed]/xplat/js/react-native-github/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/interfaces/TurboModule.java?lines=11) |
|new|getLegacyModule()| |Java [NativeModule](https://www.internalfb.com/code/fbsource/[e5db2a0dc412f0656f7eeec1db9d2da4aab61f40]/xplat/js/react-native-github/ReactAndroid/src/main/java/com/facebook/react/bridge/NativeModule.java?lines=21) that **doesn't** implement [TurboModule](https://www.internalfb.com/code/fbsource/[c7089c1408eda109f342a1f33252533e743614ed]/xplat/js/react-native-github/ReactAndroid/src/main/java/com/facebook/react/turbomodule/core/interfaces/TurboModule.java?lines=11)|

Changelog: [Internal]

Reviewed By: cortinico

Differential Revision: D43751055

fbshipit-source-id: 75afb6f836b8ec270bb916525ff2fc9030d34012
2023-03-28 09:11:56 -07:00
Ramanpreet Nara 7a08fbb088 Deprecate TurboModuleManagerDelegate.getLegacyCxxModule (#36667)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/36667

## Context
TurboModuleManagerDelegate exposes two methods that create TurboModules:
- TurboModule getModule()
- CxxModuleWrapper getLegacyCxxModule()

## Problem
TurboModuleManagerDelegate.getLegacyCxxModule() is redundant: getModule() could just return all the modules that getLegacyCxxModule() returns: getLegacyCxxModule returns modules that implement TurboModule.

## Changes
So, let's deprecate getLegacyCxxModule(). This will simplify the implementation of TurboModuleManager.

Changelog: [Android][Deprecated] - Deprecate TurboModuleManager.getLegacyCxxModule

Reviewed By: cortinico

Differential Revision: D44407802

fbshipit-source-id: 88a6cf6597db76d8a74fd777d68ccf4f43aa6811
2023-03-28 09:11:56 -07:00
Ramanpreet Nara 3af66bf7fb Java: Make TurboModuleManager's APIs use NativeModule interface (#36629)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/36629

The scope of TurboModuleManager is increasing:
- Eventually, it'll be capable of creating interop NativeModules (i.e: NativeModules that don't implement TurboModule).

So, instead of creating duplicate methods for NativeModules on the TurboModuleManager, this diff changes the APIs of TurboModuleManager to work with the NativeModule interface.

Thoughts?

## Questions
**Question:** Is this a breaking change for open source?
- Technically, yes. This diff changes the public interface of TurboModuleManager.

**Question:** How large of a thrash will this cause for open source apps?
- The thrash should be minimal. People in open source shouldn't be creating their own TurboModuleManager. They also shouldn't be directly accessing the TurboModuleManager object either.

**Question:** Is this change safe?
- Yeah. All the code that calls into TurboModuleRegistry converts TurboModules it returns into NativeModules.

**Question:** Is this change move us in the right direction?
- Long term, the TurboModule system will support legacy modules as well as TurboModules.
- I think it makes a lot of sense to have one Java-facing registry: after all, Java will just treat these NativeModules/TurboModules as regular Java objects, and call public methods on them. It doesn't care if the module is TurboModule-compatible or not.
- As for the TurboModuleRegistry abstraction, I think we should eventually rename this to NativeModuleRegistry after we delete the current NativeModuleRegistry.
- Still thinking about this though. I will leave this diff in review to welcome comments.

Changelog: [Android][Deprecated] - Deprecate TurboModuleRegistry.getModule(), getModules(), hasModule(),

Reviewed By: mdvacca

Differential Revision: D43801531

fbshipit-source-id: 4af7cbc2e2dc7c1d664acbd38c83aa93aae23c9f
2023-03-28 09:11:56 -07:00
Ramanpreet Nara cb07358b12 Make TurboModule system support int/float args/returns (#36628)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/36628

The legacy NativeModule system supports integer and float in NativeModule method arguments and returns. This diff extends the TurboModule system for the same functionality. T

his is necessary because the TurboModule system will now need to dispatch method calls to legacy NativeModules.

NOTE: We can't actually test these changes until we run interop modules.

Changelog: [Internal]

Reviewed By: javache

Differential Revision: D44000389

fbshipit-source-id: 92282d582a0f98fcb88d83e460d4860a64fe1117
2023-03-28 09:11:56 -07:00