Commit Graph

12270 Commits

Author SHA1 Message Date
Soe Lynn ce588db63f Make getContentOriginOffset to know info about if call-site want transform or not (#44822)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44822

Changelog: [Breaking]

This is to make `getContentOriginOffset` to have `includeTransform` information passed during Layout computation.

Reviewed By: NickGerleman

Differential Revision: D58223380

fbshipit-source-id: 4faa1409d9c87e2c92118941aa193ba0a0f34367
2024-06-11 19:48:32 -07:00
Christoph Purrer fd618819c7 Add EventEmitter code-gen support for C++ Turbo Modules (#44809)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44809

Adding react-native-codegen parser support for a new `EventEmitter` property type on C++ Turbo Modules.

It is possible to later expand this feature to other languages (Java, ObjC).

## Characteristics

An `EventEmitter` must:
- be non null:
 `EventEmitter<string>` works, `?EventEmitter<string>` does NOT
- have a non null eventType:
  `EventEmitter<number>` works, `EventEmitter<?number>` does NOT
- have at most 1 eventType, `void` is possible as well:
  `EventEmitter<>` or `EventEmitter<MyObject>` work - `EventEmitter<number, string>` do NOT
- have a concrete eventType, `{}` is not allowed
  `EventEmitter<{}>` does NOT work
- be used in `Cxx` Turbo Modules only at this time

## Example

For these 4 eventEmitters in on an RN JS TM spec
```
  +onPress: EventEmitter<void>;
  +onClick: EventEmitter<string>;
  +onChange: EventEmitter<ObjectStruct>;
  +onSubmit: EventEmitter<ObjectStruct[]>;
```
We now generate this code:
1.) in the spec based header `{MyModuleName}CxxSpec` in the constructor:
```
      ... // existing code
      eventEmitterMap_["onPress"] = std::make_shared<AsyncEventEmitter<>>();
      eventEmitterMap_["onClick"] = std::make_shared<AsyncEventEmitter<OnClickType>>();
      eventEmitterMap_["onChange"] = std::make_shared<AsyncEventEmitter<OnChangeType>>();
      eventEmitterMap_["onSubmit"] = std::make_shared<AsyncEventEmitter<OnSubmitType>>();
```
2.) as `protected` functions
```
  void emitOnPress() {
      std::static_pointer_cast<AsyncEventEmitter<>>(delegate_.eventEmitterMap_["onPress"])->emit();
  }

  void emitOnClick(const OnClickType& value) {
      std::static_pointer_cast<AsyncEventEmitter<OnClickType>>(delegate_.eventEmitterMap_["onClick"])->emit(value);
  }

  void emitOnChange(const OnChangeType& value) {
      std::static_pointer_cast<AsyncEventEmitter<OnChangeType>>(delegate_.eventEmitterMap_["onChange"])->emit(value);
  }

  void emitOnSubmit(const OnSubmitType& value) {
      std::static_pointer_cast<AsyncEventEmitter<OnSubmitType>>(delegate_.eventEmitterMap_["onSubmit"])->emit(value);
  }
```

## Changelog:

[General] [Added] - Add EventEmitter code-gen support for C++ Turbo Modules

Reviewed By: javache

Differential Revision: D57407871

fbshipit-source-id: 2345cc6dacf0cb0d45f8a374ad9d4cbf8082f9d6
2024-06-11 19:19:22 -07:00
Nick Gerleman bfb3b7008d Support clipping to children everywhere using ReactViewBackgroundManager (#44734)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44734

Fixes https://github.com/facebook/react-native/issues/44671

This integrates functionality for clipping content to padding box into `ReactViewBackgroundManager`, to be shared between several ViewManagers. In practice, this means:

1. `overflow: hidden` now works on `Text` and `TextInput`
2. ScrollView children are now clipped to the interior of borders, included curved ones via borderRadius

This will be made more generic, then start being used in ReactViewGroup, and eventually ReactImage. That abstraction will then hide away extra background management we will use for shadows.

Different places in code currently do clipping in any of `draw()`, `onDraw()`, or `dispatchDraw()`. The distinction between these, is that `draw()` allows code to run before drawing background even, `onDraw()` is invoked before drawing foreground, and `dispatchDraw()` is before drawing children. We don't want to clip out borders/shadows, but do want to clip foreground content like text, so I used `onDraw()` here.

Changelog:
[Android][Fixed] - Better overflow support for ScrollView, Text, TextInput

Reviewed By: rozele

Differential Revision: D57953429

fbshipit-source-id: ca3b788deb4b32706df7db958877d18f525c039c
2024-06-11 16:13:28 -07:00
Pieter Vanderwerff c9d7774a24 Cleanup imports and types (#44862)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44862

Clean up:
* type imports to be consistent
* Remove long since deprecated `{| ... |}` exact object style.

Changelog: [Internal]

Reviewed By: NickGerleman

Differential Revision: D58381905

fbshipit-source-id: 4c061385a987a2bc7dd8339183533084f1efd699
2024-06-11 15:41:19 -07:00
dan 32c3cd3e8a Fix junk in React warnings in Logbox (#44812)
Summary:
Before all React errors showed junk like this:

![Screenshot 2024-06-06 at 06 24 38](https://github.com/facebook/react-native/assets/810438/40be3133-e31d-43e8-b04d-ffbc5b462027)

This is because `isComponentStack` detected a component stack but `parseComponentStack` couldn't actually parse it (it doesn't deal with React's current format like `in Foo (created by FeedItemInner)`) so `componentStack` was an empty array, resulting in the next block of code pushing stuff into `argsWithoutComponentStack` _again_, thus repeating its args.

The fix is not to do that. Result on my local copy:

![Screenshot 2024-06-06 at 06 24 24](https://github.com/facebook/react-native/assets/810438/8f3d32d9-6f28-472c-be34-c802a0e2f161)

Ofc this doesn't actually show the component stack but that was broken before too.

I edited in-place in my `node_modules` so I haven't verified this 100% works on main.

Hope this is useful!

## Changelog:

[General] [Fixed] - Remove accidental duplication in React warnings in Logbox

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

Reviewed By: cortinico

Differential Revision: D58240357

Pulled By: rickhanlonii

fbshipit-source-id: b6ecb659d3b393e497caf5e7b2087a8e529f1b28
2024-06-11 15:16:13 -07:00
Christoph Purrer 2a0a11256a Add EventEmitter C++ bridging type (#44808)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44808

Adds an `AsyncEventEmitter` class which can be used as a property of currently C++ only Turbo Modules to send type safe data back to JavaScript.

Adding support for ObjC / Java Turbo Modules is possible, straight forward and can be added as an afterthought.

It implements this interface
```
export type EventEmitter<T> = {
  addListener(handler: (T) => mixed): EventSubscription,
};
```

## Hybrid
It is a 'hybrid' object.

1.) You `addListener(handler: (T) => mixed)` in JavaScript for emitted events (coming from C++, native code)
2.) You `emit(...Arg)` events in C++, native code (getting sent to JavaScript)

## Changelog:

[General] [Added] - Add EventEmitter C++ bridging type

## Facebook:
Apps usually create custom functionality to achieve this kind of behavior - e.g. https://www.internalfb.com/code/fbsource/[e72bd42a028a]/arvr/js/apps/RemoteDesktopCompanion/shared/turbo_modules/TMSubscription.h

Reviewed By: javache

Differential Revision: D57424391

fbshipit-source-id: 4999cafe9daeac125712a4bb7679d7acb9a6c389
2024-06-11 15:00:16 -07:00
Eric Rozell d3e3e2a870 Allow out of tree platforms to customize cursor values (#44841)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44841

This change adds native support in Fabric for the remaining CSS cursor style values as defined here: https://developer.mozilla.org/en-US/docs/Web/CSS/cursor. Please note, this functionality is simply for prop parsing capabilities in Fabric, which are shared across all platforms. This does not add any additional cursor behavior support to iOS or Android, and the Flow and TypeScript types for cursor style values are still limited to `auto` and `pointer`.

## Changelog

[General][Added] Fabric prop parsing capabilities for all CSS cursor style values

Reviewed By: NickGerleman

Differential Revision: D58301970

fbshipit-source-id: 37ef8fcb4f62ac8c7613c7f6abcc48303953b71b
2024-06-11 14:58:45 -07:00
Wojciech Lewicki 8a15e0d97a fix: singletonMap for module events (#42354)
Summary:
Sometimes the events map can be a of type `SingletonMap` which will cause this code to throw exception when adding keys to it, so we change it to normal `HashMap`. Creating `SingletonMap` can especially happen in Kotlin when there is only one event added to a map, see:
https://github.com/plaid/react-native-plaid-link-sdk/blob/5ffab5eef576163528f0da504181162da3bef08b/android/src/main/java/com/plaid/PLKEmbeddedViewManager.kt#L21
## Changelog:

[ANDROID] [FIXED] - Cover SingletonMap when parsing events exported by module

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

Test Plan: Create `getExportedCustomBubblingEventTypeConstants` as `SingletonMap` in some example module and see that the code does not throw.

Reviewed By: cipolleschi

Differential Revision: D58417266

Pulled By: cortinico

fbshipit-source-id: 6c46398ddf4d044386a36d0c1663bd071d642fb6
2024-06-11 12:20:07 -07:00
Mauricio Meirelles 8597727c28 Adjust InputAccessoryView width to match device width within Safe Area constraints (#43303)
Summary:
This PR updates the `InputAccessoryView` component to improve its width handling during device orientation changes for both Fabric and the old renderer. With this update, the component will always occupy the full width of the screen and adjust its size when the device orientation changes.

It also updates the component to stick to the safe area in React Native instead of iOS native. This tweak opens up possibilities for better customizations down the line.

Resolves: https://github.com/facebook/react-native/issues/27887

## Changelog:

[IOS] [FIXED] - Fix `InputAccessoryView` width on device orientation change

<!-- 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

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

Test Plan:
https://github.com/facebook/react-native/assets/5813840/cd3cc7bf-21c2-42a7-9f59-53bb613b9ef1

Difference between horizontal list with horizontal safe area inset in the component or on the content
| component constraint | content inset |
| ------ | ------ |
|   <video src="https://github.com/facebook/react-native/assets/5813840/173c26c8-5420-4ea2-beaa-6151c13c2119">  |<video src="https://github.com/facebook/react-native/assets/5813840/217a06eb-8634-4a26-9b70-392f7cf16112">   |

Reviewed By: cortinico

Differential Revision: D58188210

Pulled By: cipolleschi

fbshipit-source-id: 196343494cf545a22f3bc011f79b5fd592a5deb3
2024-06-11 09:21:29 -07:00
Alex Hunt d72ac96e8e Remove nonstandard "vm" field from modern CDP targets (#44835)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44835

As titled. The `vm` field is not part of the CDP spec and will not be used by the modern debugger frontend or proxy.

This change affects modern CDP targets only (using `InspectorPackagerConnection`). We aim to enable sharing of more detailed metadata over 1/ a new, dedicated CDP domain, and 2/ namespaced under the existing `reactNative` field (for the latter, strictly limited to metadata necessary for dev server functionality).

Changelog: [Internal]

(Note: `/json` endpoint behaviour is unchanged for legacy CDP targets)

Reviewed By: robhogan

Differential Revision: D58285587

fbshipit-source-id: dfef3a56b20486ba11891df9940f6c7bef59528e
2024-06-11 08:48:45 -07:00
Nicola Corti d0012b7dcd Simplify build_android (#44870)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44870

This just simplifies the build_android step on GHA

Changelog:
[Internal] [Changed] - Simplify build_android

Reviewed By: cipolleschi

Differential Revision: D58407537

fbshipit-source-id: 2bb34ef8b8d1883e653914488d4d417356f0f1d2
2024-06-11 08:34:46 -07:00
Alex Hunt 3303dd35ed Expose unstable_loadFusebox API on Android (#44858)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44858

- Enables an opt-in to the Fusebox stack on Android for both architectures in open source.
- Templates use of this opt-in in RNTester.

Changelog: [Internal]

Reviewed By: rubennorte

Differential Revision: D58359907

fbshipit-source-id: d565dc8e00747dff56d3060e36e7f59e7dd2aec5
2024-06-11 06:11:35 -07:00
Alex Hunt 812f155527 Expose unstable_fuseboxEnabled API on iOS (#44860)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44860

- Enables an opt-in to the Fusebox stack on iOS for both architectures in open source.
- Templates use of this opt-in in RNTester.

Changelog: [Internal]

Reviewed By: rubennorte

Differential Revision: D58364053

fbshipit-source-id: c604b1589174bf7cfd0fe1bfb5624c4edd0a125d
2024-06-11 04:38:32 -07:00
rickhanlonii (Meta Employee) b0c0bb4591 Fix xplat sync syntax error
Summary: DiffTrain build for commit https://github.com/facebook/react/commit/bf1bb2e5e52733a9577848f2913d06edcf24df14.

Reviewed By: yungsters

Differential Revision: D58369382

Pulled By: rickhanlonii

fbshipit-source-id: 0e6058a285108279465b3c6f4edd8d23d9ddd4b8
2024-06-11 01:46:27 -07:00
Soe Lynn 0d345698d8 Measure with transform bugfix (#44821)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44821

Changelog: [Internal]

- Originally D37994809 was attempted to fix `Inverted FlatList` but was put behind Feature Toggle because it was causing problems in other scenarios.
- Later, D45866231 which was trying to fix scaling transform issue helped solve the issue attempted by the original diff.
- But after that points, Unit test around `computeRelativeLayoutMetrics` was having two variants where Feature Toggle for D37994809 was checked in with a wrong expected value.
- This diff revert D37994809 changes and clean up the unit test.

Reviewed By: NickGerleman

Differential Revision: D58197918

fbshipit-source-id: d8ae552018617e785e4010bc5805c53a875e02a3
2024-06-10 21:03:45 -07:00
Zeya Peng 712ff8cdba make RNTesterApp's back button customizable
Summary:
## Changelog

make RNTesterApp take a `customBackButton` prop to enable overriding whether to display back button and the look
by default, only ios platform has a back button, and android app relies on back button on navigation bar that comes with platform

[Internal]

Reviewed By: christophpurrer

Differential Revision: D58218208

fbshipit-source-id: 63a47390cc6d3de057b92a3c522c1b00d942c69d
2024-06-10 20:48:12 -07:00
Joe Vilches 5b3a321422 Fix issue with alternating flex direction and percent postions (#44792)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44792

X-link: https://github.com/facebook/yoga/pull/1663

Fixing https://github.com/facebook/yoga/issues/1658. We had a problem where if a child had a different flex direction than its parent, and it also set a position as a percent, it would look at the wrong axis to evaluate the percent. What was happening was we were passing in the container's mainAxis size and crossAxis size to use to evaluate the position size if it was a percent. However, we matched these sizes with the main/cross axis of the child - which is wrong if the flex direction is different.

I changed it so that the function just takes in ownerWidth and ownerHeight then calls isRow to determine which one to use for the main/cross axis position. This reduces the ambiguity quite a bit imo.

Changelog: [Internal]

Reviewed By: NickGerleman

Differential Revision: D58172416

fbshipit-source-id: eafd8069e03493fc56c41a76879d1ad9b7e9236d
2024-06-10 18:25:19 -07:00
Joe Vilches 940d738b89 Fix issue where % width would be wrong if physical and relative padding defined on parent (#44791)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44791

X-link: https://github.com/facebook/yoga/pull/1662

This should fix https://github.com/facebook/yoga/issues/1657. Rather insidious bug but we had code like

```
  // The total padding/border for a given axis does not depend on the direction
  // so hardcoding LTR here to avoid piping direction to this function
  return node->style().computeInlineStartPaddingAndBorder(
             axis, Direction::LTR, widthSize) +
      node->style().computeInlineEndPaddingAndBorder(
          axis, Direction::LTR, widthSize);
```

That comment is NOT true if someone sets both the physical edge and relative edge. So like paddingLeft and paddingEnd for RTL. This diff simply pipes the direction to that spot to use instead of hardcoding LTR. Every file changed is just to pipe `direction`.

Changelog: [Internal]

Reviewed By: NickGerleman

Differential Revision: D58169843

fbshipit-source-id: 5b4854dddc019285076bd06955557edf73ef7ec5
2024-06-10 18:25:19 -07:00
Nicola Corti e686b4330d Tentative fix for NPE JavaTimerManager$IdleCallbackRunnable.cancel (#44852)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44852

This attempts to fix #44842 by capturing the accessed field in a new variable.
We don't have a way to reproduce this & this is a best guess fix.

Changelog:
[Android] [Fixed] - Tentative fix for NPE `JavaTimerManager$IdleCallbackRunnable.cancel`

Reviewed By: javache

Differential Revision: D58356826

fbshipit-source-id: d016df9a52f81a8d645a0a100c6bc6111841e24e
2024-06-10 13:39:27 -07:00
Pieter De Baets fdb2427a86 Add getNativeModule(String) to ReactContext interface (#44851)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44851

This method is available on the (deprecated) CatalystInstance interface, but not on ReactContext, even though it is trivially supported.

Changelog: [Android][Added] - Added getNativeModule(name) to ReactContext

Reviewed By: cortinico

Differential Revision: D58355135

fbshipit-source-id: 0cc76bb2da2b49510dc626cb8b3a3e93db5a16b0
2024-06-10 09:02:05 -07:00
Rubén Norte e94852ff28 Modify IntersectionObserver example in RNTester to showcase changes in intersection due to changes in layout, instead of scroll (#44823)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44823

Changelog: [internal]

This modifies the example for `IntersectionObserver` in RNTester to test that the API reports changes in intersection also coming from changes in layout (previously is was only from changes in scroll position).

Reviewed By: javache

Differential Revision: D58260057

fbshipit-source-id: 305d5996148730d718da30896f6cc62991b717f7
2024-06-10 08:28:45 -07:00
Peter Abbondanzo 0b8222a854 Fix status bar height calculation for all cutout sizes (#44805)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44805

Google has discouraged attempting to read the `status_bar_height` resource [since 2017](https://youtu.be/_mGDMVRO3iE?si=qGQd7gLa_qTmfLGL&t=1079). With the introduction of display cutouts there can be a mismatch between the resource value and the true status bar size (and issues like [this one](https://github.com/facebook/react-native/issues/33612) popped up). The recommended approach is to instead call `getInsets` with the proper status bar and navigation flags provided by `WindowInsets`. On older APIs where `getInsets` is not supported, we have access to `systemWindowInsetTop`.

Changelog:
[Android][Fixed] - Fixed StatusBar.currentHeight calculations to honor all cutout sizes

Reviewed By: tdn120

Differential Revision: D58088036

fbshipit-source-id: 9c035a79cbb96db1cf3b5b5c36242df7453fe205
2024-06-10 08:25:33 -07:00
Riccardo Cipolleschi a8f4f1d658 Fix External CI (#44854)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44854

In the previous change, I followed the suggestion of the linter but in that case I shouldn't.

This was breaking circleci and GHA

This change will fix it

## Changelog:
[Internal] - Fix OSS CI

Reviewed By: huntie

Differential Revision: D58358164

fbshipit-source-id: eba1f41c17a191aa9d3bd213fddddd8ff3c24a6a
2024-06-10 05:53:06 -07:00
Oskar Kwaśniewski 924fb3de9b feat: build visionos hermes binary on the CI (#44691)
Summary:
As discussed with cipolleschi offline, this PR adds visionOS to the prebuilt Hermes binary for the CI.

## Changelog:

[IOS] [ADDED] - Prebuilt version of Hermes for visionOS

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

Test Plan: Check if CI builds xcframework for visionOS.

Reviewed By: cortinico

Differential Revision: D58189271

Pulled By: cipolleschi

fbshipit-source-id: dc76746b2c1e22670bef4c21411a598e43dad577
2024-06-10 04:52:24 -07:00
Nicola Corti feeb4b773b Remove import of com.facebook.react.ReactSettingsExtension (#44850)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44850

I'm removing this line from settings.gradle:
```
import com.facebook.react.ReactSettingsExtension
```
and just using a fully qualified class name in the `configure{}` block
as imports cannot be conditionally included and is making hard for RNTA
to integrated those changes.

Changelog:
[Internal] [Changed] - Remove import of `com.facebook.react.ReactSettingsExtension`

Reviewed By: huntie

Differential Revision: D58354443

fbshipit-source-id: bc45516661318021a042e1c5921e28d7217cacbc
2024-06-10 03:26:34 -07:00
Nicola Corti 6937c7044b rncli.h -> autolinking.h (#44829)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44829

Another renaming that now we can merge to make clear what's the intent of this header.

Changelog:
[Internal] [Changed] - rncli.h -> autolinking.h

Reviewed By: javache

Differential Revision: D58284662

fbshipit-source-id: 7b69118f72d9b34a88ece7e0855918f5c717999a
2024-06-09 05:09:18 -07:00
Levi Buzolic 2483c63017 Add missing remove method to addEventListener Jest mocks (#44270)
Summary:
While writing some Jest tests, I noticed some instances of the following error:

```
Cannot read properties of undefined (reading 'remove')
```

Looks like there were two cases where the `{remove: () => {}}` return result was missing in the provided Jest mocks:

 - `AccessibilityInfo.addEventListener`
 - `Linking.addEventListener`

## Changelog:

[GENERAL] [FIXED] - Added missing `remove` methods for `Linking.addEventListener` and `AccessibilityInfo.addEventListener` Jest mocks

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

Test Plan: N/A

Reviewed By: christophpurrer

Differential Revision: D58324784

Pulled By: robhogan

fbshipit-source-id: f46bd55db2517413f14182ae1bb81068d8d1e9f6
2024-06-08 10:59:04 -07:00
Nicola Corti 61de7da032 PackageList2 -> PackageList (#44828)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44828

I was using PackageList2 temporarily as I was migrating to Core Autolinking.
Now we can rename everything to `PackageList` to reduce the number of changes to the template for users.

Changelog:
[Internal] [Changed] - PackageList2 -> PackageList

Reviewed By: blakef

Differential Revision: D58284661

fbshipit-source-id: 8e1cc54e248519ece05336d79bb79e3f4ca706f4
2024-06-07 11:02:40 -07:00
Vitali Zaidman 138d50f412 Update debugger-frontend from 3307f31...fa5df76 (#44839)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44839

Changelog: [Internal] - Update `react-native/debugger-frontend` from 3307f31...fa5df76

Resyncs `react-native/debugger-frontend` from GitHub - see `rn-chrome-devtools-frontend` [changelog](https://github.com/facebookexperimental/rn-chrome-devtools-frontend/compare/3307f310241a11811288f70c756fded3b9ec2951...fa5df7604089aa4015132bb66b1d0b88411cc4c6).

Reviewed By: EdmondChuiHW

Differential Revision: D58291849

fbshipit-source-id: 10dd25c205b13b3ae142e9af552c23809dd3e9ce
2024-06-07 10:49:00 -07:00
Nicola Corti 8ce450c435 Convert MountingManagerTest to Kotlin (#44837)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44837

As the title says.

Changelog:
[Internal] [Changed] - Convert MountingManagerTest to Kotlin

Reviewed By: javache

Differential Revision: D58290597

fbshipit-source-id: a5c499fbffcaeef4e21ebbca1904b22803c35270
2024-06-07 10:40:36 -07:00
Ingrid Wang f4b921c1d5 Fix broken scroll view caused by D58157667 (#44820)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44820

# Changelog

[iOS][Fixed] Fixing scroll view breakage caused by #44789

Reviewed By: cipolleschi

Differential Revision: D58260014

fbshipit-source-id: 375697f1103ba7794f572f490b409a1d27304e66
2024-06-07 10:39:33 -07:00
Nicola Corti cf914e412d RNGP - Autolinking. Add support for linking projects. (#44799)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44799

This is the final part of core autolinking:
1. I split RNGP into an `app-plugin` and a `settings-plugin`. This was necessary as the Gradle modules need to be loaded inside the settings.gradle.kts.
2. I've introduced a Settings Plugin to take care of either invoking the `config` command from CLI or receiving a file in input.
3. I've removed the former `RunAutolinkingConfigTask` as now the command is invoked inside the settings plugin
4. I've added hashing computed based on the lockfiles so we won't be re-executing teh `config` command if the lockfiles are not changed.
5. I've updated RN-Tester to use the core autolinking rather than manual linking for the 2 libraries it's using.

Changelog:linking
[Internal] [Changed] - RNGP - Autolinking. Add support for linking projects

Reviewed By: blakef

Differential Revision: D58190363

fbshipit-source-id: 6ab8b36729e77ca715f50a4a00aa0ca4eb5b63b1
2024-06-07 10:32:16 -07:00
Benoit Girard 5a4cb3de3d Add Perfetto Hermes Sampling Data Source (#44818)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44818

Introduce a new data source for Perfetto. This one turns on the Hermes sampler, and at the end we flush the state to Perfetto.

This provides JS sampling data in Perfetto traces that can be used to easily spot JS performance problems not otherwise obvious.

Reviewed By: javache

Differential Revision: D57226087

fbshipit-source-id: 77c4a335bb462e73d74345eedc3fa634405bfd0f
2024-06-07 09:52:42 -07:00
Alex Hunt df19e597e3 Remove faviconUrl field from CDP list response (#44834)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44834

- Remove the nonstandard, unused `faviconUrl` field from CDP `/json` response targets (note: both legacy and modern targets).
- Reorder `PageDescription` members.

Changelog:
[General][Removed] - `react-native/dev-middleware`: Remove nonstandard `faviconUrl` field from CDP `/json` response

Reviewed By: hoxyq

Differential Revision: D58092090

fbshipit-source-id: a593be00464853a3fe179305efae5643d616573b
2024-06-07 08:23:45 -07:00
zhongwuzw 1a1795a537 Fixes enum codegen value cases (#44654)
Summary:
Fixes https://github.com/facebook/react-native/issues/44632

## Changelog:

[GENERAL] [FIXED] - [codegen] Fixes enum codegen value cases

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

Test Plan: https://github.com/facebook/react-native/issues/44632

Reviewed By: cipolleschi, dmytrorykun

Differential Revision: D58135645

Pulled By: cortinico

fbshipit-source-id: 5c0634ef1d1d7375d2ecfcf7f916d67fd39b7300
2024-06-07 07:53:59 -07:00
Nicola Corti 538dd1760d Add libmapbufferjni.so to pickFirst directives (#44827)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44827

After D57856389 (#44684), the build is now firing an issue as `libmapbufferjni.so` is exposed as a public `.so` and we're missing a pickFirst directive.

Changelog:
[Internal] [Changed] - Add libmapbufferjni.so to pickFirst directives

Reviewed By: javache

Differential Revision: D58284481

fbshipit-source-id: d476bd5df8ec4687177df7a698cbb6595ce62565
2024-06-07 07:06:37 -07:00
Pieter De Baets 7ee2dcb0f0 Cleanup enableBridgelessArchitectureNewCreateReloadDestroy (#44826)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44826

This was rolled out a while back, but some references remained.

Changelog: [Internal]

Reviewed By: cortinico

Differential Revision: D58190612

fbshipit-source-id: e7884909959c98eb5617c9dee75f4ce53834b05c
2024-06-07 05:24:57 -07:00
Andrew Coates dbdd4da14f Add ability to override the ViewStyle of the root View component (#44665)
Summary:
In order to host a ReactNative surface whose size is controlled by the RN content rather than the size of the surface, we need the ability to remove  the flex:1 style on the root View component.

`SurfaceHandler` has layout functions which take a `LayoutConstraint` (so min/max size).   The root View component in `AppContainer` has a hardcoded `flex:1` style.  This view is above the `WrapperComponent`, which we can currently override.  But I dont see anyway to avoid the root View having that flex style.  This flex style means that the rootview will always be the maxheight passed into the layout functions on `SurfaceHandler`.  Which prevents allowing RN surfaces that can size themselves based on their content.

This change adds a `setRootViewStyleProvider` method to `AppRegistry`, which works similar to `setWrapperComponentProvider` but allows apps to override the style property on the root View component.  In particular, this allows apps to remove the flex:1 style, which is required to enable react surfaces which are sized based on their contents.

## Changelog:

Pick one each for the category and type tags:

[GENERAL] [ADDED] - Added AppRegistry.setRootViewStyleProvider

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

Test Plan: Will be including this change into react-native-windows to enable scenarios with content sized surfaces within Microsoft Office to work with the new architecture.  Would like signoff on this direction before I go and integrate it there.

Reviewed By: javache

Differential Revision: D58138443

Pulled By: hoxyq

fbshipit-source-id: 95ab4842aa7f827867788d8787527f9675cf4fcc
2024-06-07 03:19:43 -07:00
Wojciech Lewicki f5c888c2d7 feat: move notifying observers to event dispatcher (#44474)
Summary:
Based on the discussion starting here: https://discord.com/channels/514829729862516747/1073566663825432587/1237407161991172157, I suggest moving the call to `_notifyEventDispatcherObserversOfEvent_DEPRECATED` straight to `RCTEventDispatcher.mm`. It was previously in `RCTInstance.mm` which is only relevant on bridgeless mode. We want to mimic the behavior of https://github.com/facebook/react-native/blob/06eea61c19cd730cf0c14a436f042d30791c3f4a/packages/react-native/React/Fabric/Mounting/ComponentViews/ScrollView/RCTScrollViewComponentView.mm#L75-L78 but without using `currentBridge` since it is considered bad practice: https://github.com/software-mansion/react-native-reanimated/issues/5497#issuecomment-2083400038.

## 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
-->

[IOS] [CHANGED] - Move `notifyObservers` straight to `RCTEventDispatcher.mm`.

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

Test Plan:
See that example with `stickyHeaders` still works correctly on both bridgeless and bridge mode.

Videos with it on https://github.com/facebook/react-native/blob/deee037c62a7d62a349d34db427b14d3560ddf83/packages/rn-tester/js/examples/FlatList/FlatList-stickyHeaders.js example with more items for visibility:

- bridgeless:

https://github.com/facebook/react-native/assets/32481228/8b78104a-226b-466a-9f32-60ba4ec14100

- bridge:

https://github.com/facebook/react-native/assets/32481228/f2ca67cb-578f-45d4-954f-3249c6fa9410

- old arch:

https://github.com/facebook/react-native/assets/32481228/7d642923-ddda-4dd3-8f14-c9982a03bc2e

Reviewed By: javache

Differential Revision: D57097880

Pulled By: cipolleschi

fbshipit-source-id: de1504e90529fe4f001f44f02ace329386cf7727
2024-06-07 03:15:09 -07:00
filip131311 b957513cc6 Fix Application always in light mode on initial load. (#44335)
Summary:
Hi, I'm Filip from software mansion.  This PR solves a problem I stumbled upon.

On iOS, applications are always in light mode on initial load. Even if the device is turned to dark mode.

### Cause of the problem:

The initial appearance is taken from `RCTKeyWindow()`, but at the time of initialization of `RCTAppearance` it does not exist yet.

### Solution:

This PR moves repeats initialization of the appearance the first time `getColorScheme()` is called if it was not initialized properly before.

## Changelog:

[IOS] [FIXED] - Fix dark mode on initial load.

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

Test Plan:
- Create new React native app with `npx react-native@latest init AwesomeProjec`
- Run the application on iphone using simulator
- turn on dark mode using `cmd+shift+A`
- close application and run it again

### without changes:
  The application will turn on in light mode despite the simulator being set to dark mode.
  When you reload the application it works as expected (is in dark mode)

### with changes:
  Works as expected

#### note:
any change to device ui settings will trigger a listener that will set appearance to correct state, so testing of this problem should happen in as isolated conditions as possible.

Reviewed By: cortinico

Differential Revision: D58189058

Pulled By: cipolleschi

fbshipit-source-id: 9a864f3d045e966bc88601f661d221c4796c5c95
2024-06-07 01:03:29 -07:00
Blake Friedman b5fd041917 swap test_ios_template for test_ios_helloworld in CircleCI (#44815)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44815

Remove our `test_ios_template` job for `test_ios_helloworld`.

NOTE: There needs to be a followup to do the same in our Github Actions.

Changelog: [General][Changed] use helloworld instead of template for CI tests.

Reviewed By: cipolleschi

Differential Revision: D57122797

fbshipit-source-id: 744c79230b716716fdfc234832f1eb241e091893
2024-06-06 14:41:19 -07:00
Pieter De Baets 4324f08749 Add experiment to bypass bridgeless background executor (#44797)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44797

Noticed when profiling bridgeless that  that every call into JS would be passed via a (default priority) background thread first. This is inefficient from a scheduling perspective. Instead use the Task's default/immediate executor to immediately execute the success callback on the current thread and avoid a thread change.

This diff adds a new feature flag, to use the immediate executor for any ReactInstance method that doesn't require further synchronization within ReactInstance. For most methods, this is indeed unnecessary as ReactInstance will synchronize internally by scheduling work on the JS thread.

Changelog: [Android][Added] Added featureflag to avoid additional background threads during execution

Reviewed By: cortinico

Differential Revision: D58186090

fbshipit-source-id: 67ffed2d34083a6b6e7871160a2f3d6f1967d630
2024-06-06 13:15:45 -07:00
Kudo Chien 52cec1e798 Decouple DevInternalSettings from DevSupportManagerBase (#44441)
Summary:
I was tried to fix breaking changes for Expo's React Native nightlies CI testing. Recently React Native core has some effort to migrate Java code to Kotlin. Since https://github.com/facebook/react-native/commit/a977b2e69, we cannot reuse the `DevSupportManagerBase` and replace `DevInternalSettings` inside [expo-dev-client](https://github.com/expo/expo/blob/26c9f49042f53db7d37f832c133d4da0f6d64f02/packages/expo-dev-launcher/android/src/debug/java/expo/modules/devlauncher/helpers/DevLauncherReactUtils.kt#L117-L126) because we cannot access to the `DevInternalSettings` anymore because Kotlin "internal" visibility.
This PR tries to decouple `DevInternalSettings` from `DevSupportManagerBase` then we could still use reflection to change the mDevSettings.

## Changelog:

[ANDROID] [CHANGED] - Decouple `DevInternalSettings` from `DevSupportManagerBase`

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

Test Plan: CI passed

Reviewed By: tdn120

Differential Revision: D57054234

Pulled By: cortinico

fbshipit-source-id: e87d64518cf98182e1d98b215038a1755dae84a0
2024-06-06 12:14:04 -07:00
Ingrid Wang ce10ce4d98 Migrate RCTScrollView off of deprecated scrollIndicatorInsets (#44789)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44789

# Changelog

[iOS][Fixed] Remove usage of deprecated scrollIndicatorInsets in RCTScrollView

Reviewed By: cipolleschi

Differential Revision: D58157667

fbshipit-source-id: be0fd4075934060f9419a8164ad3f7fd378d3ce7
2024-06-06 09:28:29 -07:00
Elene Botchoradze ed9978b8de feat(iOS): add all supported ReturnKeyTypes (#43362)
Summary:
Related issue: https://github.com/facebook/react-native/issues/43243
As [documentation](https://reactnative.dev/docs/textinput#returnkeytype) stated for the ReturnKeyType prop on the input there are different options, like "next", "go" and etc. They are actually supported on the iOS side but we can't use it in our react native app, because of the hardcoded version of DoneButton on existing code:
<img width="887" alt="image" src="https://github.com/facebook/react-native/assets/53994979/9ecaf63b-675c-45f0-b737-7ae3e937584a">
So, I decided to add support for types which were in documentation

## Changelog:
[IOS] [ADDED]: ReturnKeyTypes
<!-- 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

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

Test Plan:
ran yarn jest react-native-codegen and yarn jest react-native, both successfully:
<img width="420" alt="image" src="https://github.com/facebook/react-native/assets/53994979/c36b61f7-ef45-4062-ac5b-1dd2d0a9e544">

<img width="420" alt="image" src="https://github.com/facebook/react-native/assets/53994979/af83c22c-d110-4c28-94c1-d48ee27bfcfe">

Reviewed By: cortinico

Differential Revision: D56571845

Pulled By: cipolleschi

fbshipit-source-id: 74dbffb3795ab0b5c9eafa685761c2e770cd5cf9
2024-06-06 09:21:49 -07:00
Marlene Cota 3b60c86453 Fix signed/unsigned mismatch in BoundedConsumableBuffer.h (#44806)
Summary:
Previous PR (https://github.com/facebook/react-native/issues/44564) missed one int -> size_t switch to fix C4018 in react-native-windows.
![image](https://github.com/facebook/react-native/assets/1422161/373480ed-7f49-4c01-a7ac-ea65a347ab1c)

## Changelog:

[INTERNAL] - Fix signed/unsigned mismatch in BoundedConsumableBuffer.h

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

Test Plan: Builds on Windows + identical to forked file used in react-native-windows.

Reviewed By: cortinico

Differential Revision: D58234088

Pulled By: javache

fbshipit-source-id: 0453f3509c97854975b90e7a3b8c458ca977ec65
2024-06-06 08:43:50 -07:00
Moti Zilberman bbf8a87ce7 Defer HostTarget destruction until after the instance has been unregistered (#44767)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44767

Changelog: [Internal]

Fixes a lifecycle bug in both the Bridge (`com.facebook.react.bridge`) and Bridgeless (`com.facebook.react.runtime`) integrations of Fusebox in React Native Android, whereby `HostTarget::unregisterInstance` gets called after the `HostTarget` has been destroyed.

The solution consists of two parts:

1. If a ReactHost / InstanceManager is asked to destroy itself while it contains no active ReactInstance / ReactContext, we destroy the `HostTarget` immediately.
2. Otherwise, if there *is* a live ReactInstance / ReactContext that has yet to be destroyed, we wait for that to happen before destroying the `HostTarget`. In practice, we do this by checking for the BEFORE_CREATE ( = Host destroyed) lifecycle state every time we destroy a ReactInstance / ReactContext.

Reviewed By: javache

Differential Revision: D58031215

fbshipit-source-id: 321c73e85afd17a1b38c63f73aee5ebb59c00686
2024-06-06 07:38:23 -07:00
Blake Friedman 9744fa9283 cli support to bundle, build & upload (#44722)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/44722

Add support for bundling, building and uploading on iOS.  I've verified these locally and will enable on CircleCI to validate.

Changelog: [Internal]

Reviewed By: cipolleschi

Differential Revision: D57915365

fbshipit-source-id: 1e73918b31f70d337de4d3aee934c8acf88c86d0
2024-06-06 07:06:29 -07:00
Oskar Kwaśniewski 756f89aa59 feat: set Swift active compilation conditions build setting to DEBUG (#42330)
Summary:
This PR adds cocoapods utility to set `SWIFT_ACTIVE_COMPILATION_CONDITIONS` to DEBUG, which is set to this value by default (when generating a new native Xcode project).

This allows to use the `#if DEBUG` compilator directive in Swift to work out of the box, without any changes on user's side:

```swift
override func bundleURL() -> URL? {
#if DEBUG
    RCTBundleURLProvider.sharedSettings().jsBundleURL(forBundleRoot: "index")
#else
    Bundle.main.url(forResource: "main", withExtension: "jsbundle")
#endif
  }
```

## Changelog:

[IOS] [ADDED] - Set SWIFT_ACTIVE_COMPILATION_CONDITIONS to DEBUG

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

Test Plan:
Run `bundle exec pod install` and check if the active compilation flags are populated:

![CleanShot 2024-01-17 at 13 11 03@2x](https://github.com/facebook/react-native/assets/52801365/68f119a6-af47-41bc-a1f1-9085fe4df6a0)

Reviewed By: cortinico

Differential Revision: D58188103

Pulled By: cipolleschi

fbshipit-source-id: 64746f3c7bfbdf47c2dea5e5e8cb2962635b719b
2024-06-06 04:06:28 -07:00
Kudo Chien 8956869792 Support customizeRootView from RCTRootViewFactory (#44775)
Summary:
The new `customizeRootView` does not have the feature parity as `createRootViewWithBridge` where reusing RCTRootViewFactory to create a root view, it does not call `customizeRootView`. This PR moves the `customizeRootView` support from RCTAppDelegate into RCTRootViewFactory and improves the customizeRootView support.

## Changelog:

[IOS] [CHANGED] - Support `customizeRootView` from `RCTRootViewFactory`

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

Test Plan:
Add customizeRootView to **packages/rn-tester/RNTester/AppDelegate.mm** and test whether RNTester has blue background color in both new arch and old arch mode.

```objc
- (void)customizeRootView:(RCTRootView *)rootView
{
  rootView.backgroundColor = [UIColor blueColor];
}
```

Reviewed By: dmytrorykun

Differential Revision: D58179693

Pulled By: cipolleschi

fbshipit-source-id: 0fac9a1bd5b2583a2700b3a3d2c80d0f608c4481
2024-06-06 03:50:50 -07:00