Commit Graph
30122 Commits
Author SHA1 Message Date
Dr. Sergey PogodinandFacebook GitHub Bot c684f9fc62 Patches with-environment.sh script (#42184)
Summary:
Closes https://github.com/facebook/react-native/issues/42164

## Changelog:

[IOS] [FIXED] - Fixes `with-environment.sh` script for the case when Node can't be found prior to loading `.xcode.env`

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

Test Plan: This is a trivial update, no need for much testing.

Reviewed By: cortinico

Differential Revision: D52602653

Pulled By: cipolleschi

fbshipit-source-id: 0881456bf165d895252ae38cb7c7aee945cfaf52
2024-01-08 08:52:51 -08:00
Luna WeiandFacebook GitHub Bot fe0306d637 Support specifying dist-tags for monorepo package bumps (#42146)
Summary:
Currently our CI will auto-tag any `npm publish` as `latest` for the monorepo packages. This is because [we do not specify a tag](https://github.com/facebook/react-native/blob/main/scripts/monorepo/find-and-publish-all-bumped-packages.js#L104), so npm will [default to `latest`](https://docs.npmjs.com/cli/v10/commands/npm-dist-tag#description). We encountered a similar issue for `react-native` awhile ago and fixed that with [always specifying a tag](https://github.com/facebook/react-native/blob/main/scripts/npm-utils.js#L84), with the explicit opt-in for `latest`.

yarn and npm will resolve `*` dependencies using `latest`. This will be a problem for any React Native version that uses `*` deps. We have actively tried to remove these `*` versions but older patches may still contain them.

When we do a monorepo package bump, it may be for 0.71 and for a user who is initializing a 0.72 version project (that still has * deps), they will receive monorepo packages of version `0.71.x`, which is not compatible. (React Native monorepo packages do not faithfully follow semver)

This change allows us to specify what tags to use and suggest tags based on what branch you are on and asks for confirmation

```
> branch 0.73-stable
? Select suggested npm tags. (Press <space> to select, <a> to toggle all, <i> to invert selection)
❯◉ "0.73-stable"
 ◉ "latest"
? Confirm these tags for *ALL* packages being bumped: "0.73-stable","latest" (Y/n)

> branch 0.72-stable
? Select suggested npm tags. (Press <space> to select, <a> to toggle all, <i> to invert selection)
❯◉ "0.72-stable"
 ◯ "latest"
? Confirm these tags for *ALL* packages being bumped: "0.72-stable" (Y/n)

> branch main
? Select suggested npm tags. (Press <space> to select, <a> to toggle all, <i> to invert selection)
❯◉ "nightly"
? Confirm these tags for *ALL* packages being bumped: "nightly" (Y/n)
```

## Changelog:

[INTERNAL] [CHANGED] - Support dist-tags in publishing monorepo packages to avoid default "latest" tag.

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

Test Plan: `yarn test scripts/`

Reviewed By: NickGerleman

Differential Revision: D52551769

Pulled By: lunaleaps

fbshipit-source-id: 52f923464387cffdc6ca22c6f0a45425965a3680
2024-01-08 08:38:53 -08:00
Moti ZilbermanandFacebook GitHub Bot 8c14997cbd C++ InspectorPackagerConnection: Reconnect on socket failures (#42158)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42158

Changelog: [Internal]

* Ports an existing Java/ObjC InspectorPackagerConnection behaviour to the C++ implementation: socket errors should trigger a reconnection. This was a simple omission in D52134592.
* Clarifies the relationship between the `didFailWithError` and `didClose` methods on `IWebSocketDelegate`: calling either one will terminate the connection (and trigger a reconnection), and it's legal to call `didClose` after `didFailWithError`.
  * I'm also adding logic to ensure we don't double-schedule reconnections if both methods are called.
* Cleans up the scaffolding comments from D52134592

Reviewed By: huntie

Differential Revision: D52576727

fbshipit-source-id: 07e5a5c36222dc7bede8bcb17a1f3ced2788736b
2024-01-08 05:59:08 -08:00
Riccardo CipolleschiandFacebook GitHub Bot 51b7c681c9 Migrate boost download away from JFrog (#42118)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42118

JFrog CDN periodically gives us headaches when downloading boost.
this change moves from JFrog to the official CDN by boost.

## Changelog
[Internal] - Download boost directly from boost archives

Reviewed By: cortinico

Differential Revision: D52479171

fbshipit-source-id: a53a9cb2ea6dfdf2b82b3c8e69c697b24cc40cf2
2024-01-08 03:09:18 -08:00
Samuel SuslaandFacebook GitHub Bot cabae397c6 add nullptr check to avoid crash in RCTScrollViewComponentView (#42156)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42156

changelog: [internal]

Add a missing nullptr check to prevent crash if called after component was reused

Reviewed By: fkgozali

Differential Revision: D52572807

fbshipit-source-id: 1b5b26996e562abbcb986865299e02df20b58043
2024-01-05 15:13:53 -08:00
Saad NajmiandFacebook GitHub Bot 016bb24eac Remove deprecated RCTBundleURLProvider options (#42114)
Summary:
https://github.com/facebook/react-native/commit/f7219ec02d71d2f0f6c71af4d5c3d4850a898fd8 deprecated some of the methods in `RCTBundleURLProvider, and is part of React Native version 0.73. Let's remove the deprecated options for React Native 0.74+

bypass-github-export-checks

## Changelog:

[IOS] [REMOVED] - Remove deprecated RCTBundleURLProvider options

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

Test Plan: CI should pass.

Reviewed By: huntie

Differential Revision: D52537732

Pulled By: cipolleschi

fbshipit-source-id: ea5d17c7c66a60bceb2a12f2e17e39be4c56d422
2024-01-05 11:54:30 -08:00
Joe VilchesandFacebook GitHub Bot a68451232f Add gtests for order index logic (#42022)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42022

Some tests to ensure that the order of nodes is correct as defiend by order index that is derived from zIndex + positioning. These tests do not ensure that the native platform then goes and lays them out correctly. That will be done later with e2e tests on catalyst

Changelog: [Internal]

Reviewed By: NickGerleman

Differential Revision: D52295063

fbshipit-source-id: 8ae29fc50ad65db8e5c0ab28a132546d8489dffe
2024-01-05 11:33:40 -08:00
Joe VilchesandFacebook GitHub Bot 1838c16978 Stop applying zPosition for views (#42021)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42021

# Context
A while ago D48905010 was committed that set the CALayer's zPosition equal to the zIndex passed in via props. This was to avoid an issue like:  https://pxl.cl/40F72
where the rotating view would clip into the background.

There are a few issues here.
* The current zIndex code is designed to be cross platform on the C++ layer and not the native layer. This diverges from the Android behavior and adds a special case for this platform when we have the ability to share all of this logic
* Static nodes will apply a zIndex when they shouldn't. This code pre-empts the static check [here](https://www.internalfb.com/code/fbsource/[cf8ad268b4cf]/xplat/js/react-native-github/packages/react-native/ReactCommon/react/renderer/components/view/ConcreteViewShadowNode.h?lines=98) that zeroes out the "order index" for static nodes
* As a result of the above, static nodes can eclipse their children which should never happen because static nodes ignore zIndex values

# Reason for the clipping
The reason this clipping is happening is because the red/blue views share the same stacking context as the white background (as indicated by the vertical black line). {F1175070418}
This in combination with the fact that our zIndex implementation will NOT set iOS's zPosition means that these three views (red view, blue view, white background view) all have the same zPosition (0) and will be laid out in the order described by the orderIndex mentioned earlier. This index essentially just changes the document order that is used for tiebreakers when zPosition is tied.

So, all the views are on the same stacking context and they all have no zPosition set. Add the rotation that the colored views are doing and you get this clipping. Apple will change the "zPosition" in a sense for the parts of the view that should be perceived as "further away" due to the rotation. So, we clip into our background which has a lower order index but the same zPosition.

# This change
The fix here just makes it so that the rotating views are not on the same stacking context as the background so the changing zPosition from the rotation does not matter. This can be achieved by setting the zIndex of the container to any number (among other things). Note that this is only the case because the default position type is relative in this stack. Otherwise you would also need to set the position type as well. Now the stacking context looks like: {F1175083828} and the problem is solved!

Changelog: [Internal]

Reviewed By: NickGerleman

Differential Revision: D52181701

fbshipit-source-id: 580f860273b9c8470181d92d7ad542546664ed77
2024-01-05 11:33:40 -08:00
Joe VilchesandFacebook GitHub Bot 8ad083916b Make it so that static is considered in zIndex tiebreakers (#42064)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42064

# Context
Dealing with how we should stack Views in a world with static is actually a bit complicated, despite the fact that static cannot get zIndex. The outline of everything can be found in this spec: https://www.w3.org/TR/CSS21/zindex.html. That is a bit dense, but mainly because there is much more functionality to consider in the browser than we need to in RN (like block layout, inline, floats, etc). Basically it comes down to this order, with larger numbers stacked on top of smaller ones:

1) Root
2) Negative zIndex positioned nodes (ties in document order)
3) Non positioned nodes in document order
4) Positioned nodes with no zIndex (or 0) in document order*
5) Positioned nodes with positive zIndex (ties in document order)

Document order is a pre-order traversal of the tree. The asterisk on 4 is where it gets a bit complicated. Even though there is no zIndex set, you should still treat these nodes as if they form a stacking context - with their descendants stacked relative to the parent stacking context like normal if they have zIndex set. Essentially what this means in our world is that a static child will not come before (under) a positioned parent if they share the same stacking context. Without this, you would need to form a stacking context on all positioned nodes with static children if you wanted them to appear at all since static comes before (under) positioned nodes.

# Implementation
Implementing this was a bit tricky. We had to go in pre-order traversal of the tree, but if we see a relative node it needs to form a "pseudo-stacking-context" to allow static to show over it, but if any of those descendants have a zIndex set, that should be relative to the parent stacking context like normal, not this "pseudo-stacking-context". Without static we take care of this just fine because it just ends up being a pre-order traversal of the tree, then sort by zIndex.

My approach was to ignore zIndex's at first and gather all nodes that share the same stacking context in an array as if none of them had any zIndex set. After that was gathered, then sort by zIndex to get the final order for said stacking context. The second part was already implemented. For the first part I just did a pre-order traversal of the tree (stopping at nodes that form stacking contexts) and:

* If a node was non static, add to the end of the list
* If a node was static, insert into the list right after the previously inserted static node that shares the same "psuedo-stacking-context", or the parent if there were none.
  * Since inserting into arrays is slow, I opted to use `std::list`

In effect this was a pre-order traversal where static nodes are "sorted" to come first in the list of children, which is what we want since these nodes should come under non-positioned nodes that have the same "pseudo-stacking-context".

My implementation is a bit slower. The previous one just visits all nodes once with a pre-order traversal. This will also do that and thanks to `std::list`, we have no non-constant time operations while coming in that order. After the fact, however, we need to convert back to `std::vector` which is the type used across the mounting layer, so we have to iterate over this list again. I think this is the fastest we can do this and it is optimized for a world where most nodes are relative (since it will be the new default).

Changelog: [Internal]

Reviewed By: NickGerleman

Differential Revision: D52103057

fbshipit-source-id: 0b3fb28530cfc8ef248dbdc564b5c4b4a82045a4
2024-01-05 11:33:40 -08:00
Mateusz WitandFacebook GitHub Bot 0c37f8c85c Fix remount of SectionList header and footer (#42080)
Summary:
By default SectionList overrides `stickyHeaderIndices` with generated array based on `sections` provided via props. With this changes list header and footer keeps mounted when sections prop is changing from empty list to filled list and vice versa.

## Changelog:

[General] [Fixed] - Fix remount of header and footer in `SectionList` while transiting between empty and filled state

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

Test Plan:
**Before:**
https://github.com/facebook/react-native/assets/16048381/18d31bc2-817e-4a8d-88a8-0ad19fc71816
**After:**
https://github.com/facebook/react-native/assets/16048381/e205faad-7d55-4f96-a866-56e5eca976b6

**Playground:**
https://snack.expo.dev/Ypb-SSHVz?platform=android

## Knowledge base
https://www.smashingmagazine.com/2021/08/react-children-iteration-methods/

Reviewed By: NickGerleman

Differential Revision: D52508916

Pulled By: cipolleschi

fbshipit-source-id: 430463261887e9551f10c5c2dae352e0060ad6c4
2024-01-05 09:11:58 -08:00
Kevin GozaliandFacebook GitHub Bot d50c9068a9 iOS: Fixed up remaining RCT_USE_HERMES usage --> USE_HERMES (#42148)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42148

https://github.com/facebook/react-native/pull/41625 cleaned up some usages, but there are some remaining ones.

Changelog: [iOS][Fixed] Further cleaned up RCT_USE_HERMES

Reviewed By: cipolleschi

Differential Revision: D52555309

fbshipit-source-id: e19d10de339636eca2f4762a78cebb282d0427d9
2024-01-05 09:11:41 -08:00
Oskar KwaśniewskiandFacebook GitHub Bot 782e9eace9 feat: refactor RCTKeyWindow to be more resilient and work in multi-window apps (#42036)
Summary:
This PRs refactors `RCTKeyWindow()` to be more resilient and work in multi-window apps. After my recent PR got merged (https://github.com/facebook/react-native/issues/41935) it significantly reduced the number of calls to `RCTKeyWindow()` and now it's called only when necessary. So this PR makes this function a bit more resource intensive but it guarantees that we will find current scene's key window.

This would also fix some brownfield scenarios where React Native is working in multi-window mode and in the future allow us to more easily adopt `UIWindowSceneDelegate`

bypass-github-export-checks

## Changelog:

[IOS] [CHANGED] - refactor `RCTKeyWindow` to be more resilient and work in multi-window apps

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

Test Plan:
Checkout RNTester example for Alerts and LoadingView.

https://github.com/facebook/react-native/assets/52801365/8cf4d698-db6d-4a12-8d8d-7a5acf34858b

Reviewed By: huntie

Differential Revision: D52431720

Pulled By: cipolleschi

fbshipit-source-id: 0d6ef1d46b2428c30c9f64dae66b95dbc69f0a3b
2024-01-05 07:04:55 -08:00
Wojciech LewickiandFacebook GitHub Bot 613a5a7597 feat: make view recycling optional on iOS (#35378)
Summary:
This PR resolves the potential problem of misconfiguration of components after being recycled. Some of them have custom, sometimes native (e.g. connected to VCs) logic that messes up with the concept of recycling.

bypass-github-export-checks

## Changelog

Added `shouldBeRecycled` field checking to `RCTComponentViewClassDescriptor `, a check for it in `_enqueueComponentViewWithComponentHandle:(ComponentHandle)componentHandle
                         componentViewDescriptor:(RCTComponentViewDescriptor)componentViewDescriptor` method, and a default implementation in `RCTComponentViewDescriptor` returning `YES` in order not to change the default behavior.

[iOS] [Added] - Add `shouldBeRecycled` method on `iOS`.

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

Test Plan: Override this method in your custom `componentView` and see that the component is not recycled.

Reviewed By: javache

Differential Revision: D41381683

Pulled By: cipolleschi

fbshipit-source-id: 10fd1e88f99b3608767c0b57fad462837924f02a
2024-01-05 07:03:31 -08:00
Kudo ChienandFacebook GitHub Bot cfeb43eaa2 Bump folly to 2024.01.01.00 (#42145)
Summary:
Bump folly version to 2024.01.01.00. Actually we need a version newer than v2023.08.14.00 with the https://github.com/facebook/folly/commit/c52d4490bf1e0cf117a71342b427984f9ffc316e fix. That will fix build error on Android:

```
  In file included from /Users/kudo/expo/expo/node_modules/react-native-reanimated/android/src/main/cpp/NativeProxy.cpp:3:
  In file included from /Users/kudo/.gradle/caches/transforms-3/dd158a7d05d059a173ae31ca6d78ac49/transformed/jetified-react-android-0.74.0-nightly-20240103-0e533f308-SNAPSHOT-debug/prefab/modules/jsi/include/jsi/JSIDynamic.h:10:
  In file included from /Users/kudo/.gradle/caches/transforms-3/dd158a7d05d059a173ae31ca6d78ac49/transformed/jetified-react-android-0.74.0-nightly-20240103-0e533f308-SNAPSHOT-debug/prefab/modules/folly_runtime/include/folly/dynamic.h:1310:
  In file included from /Users/kudo/.gradle/caches/transforms-3/dd158a7d05d059a173ae31ca6d78ac49/transformed/jetified-react-android-0.74.0-nightly-20240103-0e533f308-SNAPSHOT-debug/prefab/modules/folly_runtime/include/folly/dynamic-inl.h:22:
  In file included from /Users/kudo/.gradle/caches/transforms-3/dd158a7d05d059a173ae31ca6d78ac49/transformed/jetified-react-android-0.74.0-nightly-20240103-0e533f308-SNAPSHOT-debug/prefab/modules/folly_runtime/include/folly/Conv.h:124:
  In file included from /Users/kudo/.gradle/caches/transforms-3/dd158a7d05d059a173ae31ca6d78ac49/transformed/jetified-react-android-0.74.0-nightly-20240103-0e533f308-SNAPSHOT-debug/prefab/modules/folly_runtime/include/folly/Demangle.h:19:
  /Users/kudo/.gradle/caches/transforms-3/dd158a7d05d059a173ae31ca6d78ac49/transformed/jetified-react-android-0.74.0-nightly-20240103-0e533f308-SNAPSHOT-debug/prefab/modules/folly_runtime/include/folly/FBString.h:1721:19: error: no member named 'strong_ordering' in namespace 'std'
        return std::strong_ordering::equal;
               ~~~~~^
  /Users/kudo/.gradle/caches/transforms-3/dd158a7d05d059a173ae31ca6d78ac49/transformed/jetified-react-android-0.74.0-nightly-20240103-0e533f308-SNAPSHOT-debug/prefab/modules/folly_runtime/include/folly/FBString.h:1723:19: error: no member named 'strong_ordering' in namespace 'std'
        return std::strong_ordering::less;
               ~~~~~^
  /Users/kudo/.gradle/caches/transforms-3/dd158a7d05d059a173ae31ca6d78ac49/transformed/jetified-react-android-0.74.0-nightly-20240103-0e533f308-SNAPSHOT-debug/prefab/modules/folly_runtime/include/folly/FBString.h:1725:19: error: no member named 'strong_ordering' in namespace 'std'
        return std::strong_ordering::greater;
               ~~~~~^
  3 errors generated.
```

## Changelog:

[GENERAL] [CHANGED] - Bump folly version to 2024.01.01.00

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

Test Plan: ci passed

Reviewed By: cortinico, cipolleschi

Differential Revision: D52546945

Pulled By: NickGerleman

fbshipit-source-id: 64aacb1d310062dddf987c7b95f10a477e293693
2024-01-05 04:09:50 -08:00
Alex HuntandFacebook GitHub Bot 16dff523b0 Bump Metro to ^0.80.3 (#42139)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42139

Bump to the latest Metro release.

Metro release notes: https://github.com/facebook/metro/releases/tag/v0.80.3

Changelog:
[General][Changed] - Bump Metro to ^v0.80.3

Reviewed By: GijsWeterings

Differential Revision: D52520542

fbshipit-source-id: 3c089e3f033a4d0597e9adb50d3377f1ad822743
2024-01-05 03:06:03 -08:00
Dmitry RykunandFacebook GitHub Bot ccd3b04770 Add Float and Int type support for Android modules (#42126)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42126

This diff changes how numeric types are generated for Android native modules.
Before this diff:
|Codegen Type|Java Type|
| -- | -- |
|number|double|
|Float|double|
|Double|double|
|Int32|double|
After this diff:
|Codegen Type|Java Type|
| -- | -- |
|number|double|
|Float|**float**|
|Double|double|
|Int32|**int**|

Changelog: [Android][Breaking] - Codegen: mapping for numeric types is changed for Android native modules. `Float` -> `float`; `Int32` -> `int`.

Reviewed By: cipolleschi

Differential Revision: D52420921

fbshipit-source-id: 32b3bbdf5fd24db8d7ac12c262bab5fde4e1f2bc
2024-01-05 02:47:17 -08:00
Moti ZilbermanandFacebook GitHub Bot 9ba3bc99e4 Change jsinspector back to a shared library in the CMake build (#42144)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42144

D51895785 changed several CMake libraries from shared to static, including `jsinspector`. This happens to be semantically incorrect in the case of `jsinspector`, as the library contains singletons which can be inadvertently duplicated due to static linking. As a result, different parts of the code can end up accessing different instances of a supposed singleton, leading to bugs.

Here we revert the change to `jsinspector` (only) and add an explanatory comment to signpost this for future readers.

## More context & general principle

While nothing is broken today, allowing static libraries to contain global state is brittle and breaks in surprising ways:

* The upcoming diff D52231237 introduces a new dependency on `jsinspector` which builds cleanly, but causes debugging to stop working because of the duplicated singleton.
* The only reason debugging currently works in the CMake build of Bridgeless is by a happy accident: the shared library `hermesinstancejni` depends on `reactnativejni` through a chain of three other libraries unrelated to debugging, and as a result, can access `reactnativejni`'s copy of `jsinspector` (see graph).

 {F1237835169}

It seems that the safest rule of thumb, given the way React Native is currently structured, is that **singletons should live in their own shared libraries** so no call site can cause them to be duplicated through static linking. (It's reasonable to revisit this guidance if we manage to consolidate React Native into one monolithic shared library, eliminating the footgun at the source.)

Changelog:
[Internal] [Changed] - Change jsinspector back to a shared library in the CMake build.

Reviewed By: cortinico, NickGerleman

Differential Revision: D52541488

fbshipit-source-id: 502210add0b734a9bbc470bdf38fb70a41e149a9
2024-01-04 10:01:26 -08:00
Dmitry RykunandFacebook GitHub Bot 5aa425c086 Add Float and Int type support for iOS modules (#42125)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42125

This diff changes how numeric types are generated for Objective-C native modules.
Before this diff:
|Codegen Type|Objective-C Type|
| -- | -- |
|number|double|
|Float|double|
|Double|double|
|Int32|double|
After this diff:
|Codegen Type|Objective-C Type|
| -- | -- |
|number|double|
|Float|**float**|
|Double|double|
|Int32|**NSInteger**|

Changelog: [iOS][Breaking] - Codegen: mapping for numeric types is changed for Objective-C native modules. `Float` -> `float`; `Int32` -> `NSInteger`.

Reviewed By: cipolleschi

Differential Revision: D52479442

fbshipit-source-id: 1b2e101a9593a75c7c19b0da3a01a0e592a35ba5
2024-01-04 05:41:51 -08:00
Nick GerlemanandFacebook GitHub Bot 7c444dea6a Remove suppressions for Wgnu-zero-variadic-macro-arguments (#42136)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42136

`Wpedantic` flags usage of variadic macros with zero arguments. This is widely supported by different compilers (including MSVC), but was previously forbidden by the standard.

C++ 20 explicitly allows them, so, theoretically Clang should know not to warn about these now. Let's try that.

Changelog: [Internal]

Reviewed By: cortinico

Differential Revision: D52534129

fbshipit-source-id: e27a75081fac6b4196c6dbb5242812877b0bd679
2024-01-04 04:42:38 -08:00
Carmi GrushkoandFacebook GitHub Bot b1590a2f98 Update ktfmt component on FBS:master
Differential Revision: D52529945

fbshipit-source-id: b43fc3e4cf207a63232b41b3e7b790ab9ef66880
2024-01-04 04:14:44 -08:00
Samuel SuslaandFacebook GitHub Bot e4708d661b Fix TouchableBounce, TouchableHighlight and TouchableNativeFeedback in React 18 (#42133)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42133

## Changelog:
[General][Fixed] - TouchableBounce, TouchableHighlight and TouchableNativeFeedback dropping touches with React 18.

TouchableBounce, TouchableHighlight and TouchableNativeFeedback do not trigger onPress when used with React 18. This is because it resets its pressability configuration in `componentWillUnmount`. This is fine, we want to stop deliver events and restart all timers when component is unmounted.
```
componentWillUnmount(): void {
    this.state.pressability.reset();
  }
```

But TouchableBounce, TouchableHighlight and TouchableNativeFeedback were not restarting the pressability configuration when component was mounted again. It was restarting the configuration in `componentDidUpdate`, which is not called when component is unmounted and mounted again.

Reviewed By: fkgozali

Differential Revision: D52514643

fbshipit-source-id: 0d6ae4bb7c2a797cc443181459c5614da0ecfc7a
2024-01-04 02:29:04 -08:00
Joe VilchesandFacebook GitHub Bot 73d02fadd2 Change strict layout conformance to not use any errata (#42063)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42063

Static is no longer the default with the previous diff. We can undo this change. See D51731778 (https://github.com/facebook/react-native/pull/41733) for context

Changelog: [Internal]

Reviewed By: NickGerleman

Differential Revision: D52381124

fbshipit-source-id: 1e4336be6db5aa5d8786fb4f0a211558a7f66365
2024-01-03 13:37:40 -08:00
Joe VilchesandFacebook GitHub Bot 348290b9b3 Change RN default position type to relative (#42062)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42062

We have had relative as the default for a few big frameworks/apps right now (Fabric FB iOS, Fabric FB Android, OSS, Litho, CK) and have not run into issues. Seems it is safe to pull the trigger here and put everything on relative 🎉

This also fixes a test that relied on this default, changes the layout metrics default, and removes the gating plumbing that was in place earlier.

Lastly, a few animation tests start failing after this change. Seems that there is an animation bug with relative trees that would have existed already, so this is merely discovering that that bug exists, not causing any extra issues. Since that test is a set of random trees with random props it is very hard to debug and I am just adding skips to the failing ones.

Changelog: [Internal]

Reviewed By: NickGerleman

Differential Revision: D52137858

fbshipit-source-id: 6856bc608b8211c868c9ee81fc92e005ec3d2faa
2024-01-03 13:37:40 -08:00
Joe VilchesandFacebook GitHub Bot 0e533f3081 Add position type check to layout metrics == operator (#42020)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42020

I added position type in D51412428 (https://github.com/facebook/react-native/pull/41819). I didn't notice this == override which makes it so position type in layout metrics will not be updated if it changes.

To use this cpp 20 feature we needed to change a few buck files which is also done here

Changelog: [Internal]

Reviewed By: NickGerleman

Differential Revision: D52339890

fbshipit-source-id: e77ee092477dbf786e4a72e6a33138ccbc450645
2024-01-03 09:34:58 -08:00
Dmitry RykunandFacebook GitHub Bot 82f8cf1836 Introduce TypeUtils (#42122)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42122

This diff introduces the `TypeUtils` directory where we can put platform-specific, context-independent type transformations.

Changelog: [Internal]

Reviewed By: cipolleschi

Differential Revision: D52291837

fbshipit-source-id: 561b9c494aab5bfee3b3c668d3346bbd320e5266
2024-01-03 08:58:30 -08:00
Riccardo CipolleschiandFacebook GitHub Bot 327df8a719 Implement onScrollToTop event for Fabric (#42128)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42128

Scroll view was not emitting the `onScrollToTop` event when the user tapped on the status bar.
This change fixes this by adding the event to the C++ Event Emitter and by invoking it into the `RCTScrollViewComponentView`

## Changelog
[iOS][Added] - Add onScrollToTop event in Fabric

Reviewed By: sammy-SC

Differential Revision: D52509919

fbshipit-source-id: 7b72c927823fa971be99c4da4b0287d4e23a02b6
2024-01-03 08:08:30 -08:00
Riccardo CipolleschiandFacebook GitHub Bot 6cd1aaf3ae Refactor ScrollView example to trigger onScrollToTop (#42127)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42127

The current scrollViewExamples does not trigger the OnScrollToTop event.
This change for Paper adds that and refactors the codebase to isolate that example.

## Changelog:
[Internal] - Improve RNTester ScrollView example adding OnScrollView event.

Reviewed By: sammy-SC

Differential Revision: D52509669

fbshipit-source-id: 8fd0fcca7153ba41bf054832928e661ef7dff3fe
2024-01-03 08:08:30 -08:00
Nick GerlemanandFacebook GitHub Bot e809e0aca7 Fix horizontal scrollview scrollTo coordinate space in RTL on oldarch (#42094)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42094

Fabric fixed this a while back with https://github.com/facebook/react-native/commit/9ca460f06405db85d0df60cbe53c304c9127c3bf

Looks like this is still broken on Paper, and now VirtualizedList relies on it. https://github.com/facebook/react-native/pull/38737#discussion_r1437874601

Changelog:
[ios][fixed] - Fix horizontal scrollview scrollTo coordinate space in RTL on oldarch

Reviewed By: lenaic

Differential Revision: D52451602

fbshipit-source-id: f41d8248c7f6ab23965800b09ca1082fd1a15151
2024-01-03 04:33:23 -08:00
Kevin GozaliandFacebook GitHub Bot b81a081bac Log that bridgeless is enabled (if so) to the console (#42113)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42113

For easier testing/debugging, log something if bridgeless is enabled for the app. This log will show up only once.

Changelog: [Internal]

Reviewed By: cortinico

Differential Revision: D52464640

fbshipit-source-id: 5019a1a6bf4f171a5f1dc4b3b2692db9e07ff43c
2024-01-02 13:53:05 -08:00
Kevin GozaliandFacebook GitHub Bot 41d9ed0ef9 RNTester iOS: Move Meta-internal setup to internal files (#42073)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42073

This moved various Meta-internal runtime setup off AppDelegate.mm to reduce the #if checks throughout the file.

Changelog: [Internal]

Reviewed By: cipolleschi

Differential Revision: D52424748

fbshipit-source-id: b53799c8bb1544dbbb429cea811861ae52125641
2024-01-02 13:53:05 -08:00
Luna WeiandFacebook GitHub Bot 6e5bc33b3c Remove caret from monorepo dependencies (#42086)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42086

Changelog: [General][Changed] - Update monorepo dependency versions to remove ^

This change will remove the caret for now as we already perform an "align" step everytime we bump a monorepo library. This prevents monorepo library updates to affect existing releases.

The "align" step updates all monorepo libraries to use the updated bumped version: https://fburl.com/code/xfistiph

Reviewed By: huntie

Differential Revision: D52440454

fbshipit-source-id: ff071032f04bc554903dde153c594991163dfe2f
2024-01-02 13:02:29 -08:00
Luna WeiandFacebook GitHub Bot 05ec058ac5 Add print-packages as a command (#41959)
Summary:
Working on releases, I'm often looking for the name of our monorepo packages (as sometimes the name doesn't align with the directory) and also getting a list of the versions of everything, as well as if its private/public -- which I've interpreted to mean that we publish it or we don't. I thought this might be convenient to add.

## Changelog:
[Internal] - Add `print-packages` as a command to print our monorepo packages (including react-native)

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

Test Plan:
```
❯ yarn print-packages
yarn run v1.22.19
$ node ./scripts/monorepo/print
┌─────────┬─────────┬─────────────────────────────────────────┬────────────────┐
│ (index) │ Public? │                  Name                   │ Version (main) │
├─────────┼─────────┼─────────────────────────────────────────┼────────────────┤
│    0    │  ''   │     'react-native/assets-registry'     │    '0.74.0'    │
│    1    │  ''   │  'react-native/babel-plugin-codegen'   │    '0.74.0'    │
│    2    │  ''   │  'react-native/community-cli-plugin'   │    '0.74.0'    │
│    3    │  ''   │    'react-native/debugger-frontend'    │    '0.74.0'    │
│    4    │  ''   │     'react-native/dev-middleware'      │    '0.74.0'    │
│    5    │  ''   │      'react-native/eslint-config'      │    '0.74.0'    │
│    6    │  ''   │      'react-native/eslint-plugin'      │    '0.74.0'    │
│    7    │  ''   │   'react-native/eslint-plugin-specs'   │    '0.74.0'    │
│    8    │  ''   │ 'react-native/hermes-inspector-msggen' │    '0.72.0'    │
│    9    │  ''   │      'react-native/metro-config'       │    '0.74.0'    │
│   10    │  ''   │    'react-native/normalize-colors'     │    '0.74.1'    │
│   11    │  ''   │      'react-native/js-polyfills'       │    '0.74.0'    │
│   12    │  ''   │             'react-native'              │   '1000.0.0'   │
│   13    │  ''   │      'react-native/babel-preset'       │    '0.74.0'    │
│   14    │  ''   │ 'react-native/metro-babel-transformer' │    '0.74.0'    │
│   15    │  ''   │          'react-native/bots'           │    '0.0.0'     │
│   16    │  ''   │         'react-native/codegen'         │    '0.74.0'    │
│   17    │  ''   │ 'react-native/codegen-typescript-test' │    '0.0.1'     │
│   18    │  ''   │      'react-native/gradle-plugin'      │    '0.74.0'    │
│   19    │  ''   │         'react-native/tester'          │    '0.0.1'     │
│   20    │  ''   │       'react-native/tester-e2e'        │    '0.0.1'     │
│   21    │  ''   │    'react-native/typescript-config'    │    '0.74.0'    │
│   22    │  ''   │    'react-native/virtualized-lists'    │    '0.74.0'    │
└─────────┴─────────┴─────────────────────────────────────────┴────────────────┘
  Done in 0.55s.
```

Also added filter flag for private/public
```
❯ yarn print-packages --type private
yarn run v1.22.19
$ node ./scripts/monorepo/print --type private
┌─────────┬─────────┬─────────────────────────────────────────┬────────────────┐
│ (index) │ Public? │                  Name                   │ Version (main) │
├─────────┼─────────┼─────────────────────────────────────────┼────────────────┤
│    0    │  ''   │ 'react-native/hermes-inspector-msggen' │    '0.72.0'    │
│    1    │  ''   │          'react-native/bots'           │    '0.0.0'     │
│    2    │  ''   │ 'react-native/codegen-typescript-test' │    '0.0.1'     │
│    3    │  ''   │         'react-native/tester'          │    '0.0.1'     │
│    4    │  ''   │       'react-native/tester-e2e'        │    '0.0.1'     │
└─────────┴─────────┴─────────────────────────────────────────┴────────────────┘
  Done in 0.16s.
```

Also added a npm query where you can see the latest published version of a minor
```
❯ yarn print-packages --type public --minor 72
yarn run v1.22.19
$ node ./scripts/monorepo/print --type public --minor 72
┌─────────┬─────────┬─────────────────────────────────────────┬────────────────┬──────────────────────────────────────┐
│ (index) │ Public? │                  Name                   │ Version (main) │             Version (72)             │
├─────────┼─────────┼─────────────────────────────────────────┼────────────────┼──────────────────────────────────────┤
│    0    │  ''   │     'react-native/assets-registry'     │    '0.74.0'    │               '0.72.0'               │
│    1    │  ''   │  'react-native/babel-plugin-codegen'   │    '0.74.0'    │               '0.72.3'               │
│    2    │  ''   │  'react-native/community-cli-plugin'   │    '0.74.0'    │ 'No match found for version ^0.72.0' │
│    3    │  ''   │    'react-native/debugger-frontend'    │    '0.74.0'    │ 'No match found for version ^0.72.0' │
│    4    │  ''   │     'react-native/dev-middleware'      │    '0.74.0'    │ 'No match found for version ^0.72.0' │
│    5    │  ''   │      'react-native/eslint-config'      │    '0.74.0'    │               '0.72.2'               │
│    6    │  ''   │      'react-native/eslint-plugin'      │    '0.74.0'    │               '0.72.0'               │
│    7    │  ''   │   'react-native/eslint-plugin-specs'   │    '0.74.0'    │               '0.72.4'               │
│    8    │  ''   │      'react-native/metro-config'       │    '0.74.0'    │              '0.72.11'               │
│    9    │  ''   │    'react-native/normalize-colors'     │    '0.74.1'    │               '0.72.0'               │
│   10    │  ''   │      'react-native/js-polyfills'       │    '0.74.0'    │               '0.72.1'               │
│   11    │  ''   │             'react-native'              │   '1000.0.0'   │               '0.72.8'               │
│   12    │  ''   │      'react-native/babel-preset'       │    '0.74.0'    │ 'No match found for version ^0.72.0' │
│   13    │  ''   │ 'react-native/metro-babel-transformer' │    '0.74.0'    │ 'No match found for version ^0.72.0' │
│   14    │  ''   │         'react-native/codegen'         │    '0.74.0'    │               '0.72.8'               │
│   15    │  ''   │      'react-native/gradle-plugin'      │    '0.74.0'    │              '0.72.11'               │
│   16    │  ''   │    'react-native/typescript-config'    │    '0.74.0'    │ 'No match found for version ^0.72.0' │
│   17    │  ''   │    'react-native/virtualized-lists'    │    '0.74.0'    │               '0.72.8'               │
└─────────┴─────────┴─────────────────────────────────────────┴────────────────┴──────────────────────────────────────┘
```

Reviewed By: cortinico

Differential Revision: D52347140

Pulled By: lunaleaps

fbshipit-source-id: 75811730e1afd5aae2d9fba4e437cd0d3d424a90
2024-01-02 11:46:03 -08:00
Samuel SuslaandFacebook GitHub Bot 54166342f0 fix TouchableWithoutFeedback and TouchableOpacity dropping onPress in React 18 (#42121)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42121

## Changelog:
[General][Fixed] - TouchableWithoutFeedback and TouchableOpacity dropping touches with React 18.

TouchableWithoutFeedback and TouchableOpacity do not trigger onPress when used with React 18. This is because it resets its pressability configuration in `componentWillUnmount`. This is fine, we want to stop deliver events and restart all timers when component is unmounted.
```
componentWillUnmount(): void {
    this.state.pressability.reset();
  }
```

But TouchableWithoutFeedback and TouchableOpacity were not restarting the pressability configuration when component was mounted again. It was restarting the configuration in `componentDidUpdate`, which is not called when component is unmounted and mounted again.

Reviewed By: fkgozali

Differential Revision: D52388699

fbshipit-source-id: ef13194c6581c5d31d0f1cb465bfd0cf98d672ea
2024-01-02 10:57:15 -08:00
Riccardo CipolleschiandFacebook GitHub Bot f1a7f08feb Add functions to check whether the New Arch is enabled at runtime (#42090)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42090

This change is the last pieces of removing `RCT_NEW_ARCH_ENABLED` flag and defragmenting the build setup on iOS.

Before, 3rd party libraries had to use the `#if RCT_NEW_ARCH_ENABLED` flag to compile in and out segment of code depending on whether the new architecture was turned on or not.

After the recent changes, we can now expose the `RCTIsNewArchEnabled()` function to read whether the New Arch is enabled at runtime or not.
This will promote better code practices as we can replace ugly, compile time, `#if-#else-#endif`s with a more readable and natural regular obj-c code.
We can also use inheritance to have different implementation based on the architecture.

To use the new function, a 3rd party library have to:
1. `#import <React/RCTUtils.h>` (if they use the  `install_modules_dependencies` function we provide, they can already do it)
2. invoke `RCTIsNewArchEnabled()` which returns a BOOL.
3. implement the code accordingly, depending on the New arch state.

**Note:** we implemented also the `RCTSetNewArchEnabled` function. This is called as soon as React Native is initialized in the `RCTAppDelegate`. The method can be called only once per React Native lifecycle. Subsequent calls to that method are ignored.

## Changelog:
[iOS][Added] - Added the `RCTIsNewArchEnabled()` to check whether the New Arch is enabled at runtime.

Reviewed By: cortinico

Differential Revision: D52445107

fbshipit-source-id: 1b432832912d33c85687b4c37f9e360ce9699f59
2024-01-02 04:53:38 -08:00
Riccardo CipolleschiandFacebook GitHub Bot db9c9eacac Add function to customise RootView in Bridgeless (#42088)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42088

This change adds an extra function to customise the RootView in both Bridge and Bridgeless mode.
To nudge users in a migration, we also add a warning message for next version that should push our users to migrate away from the old implementation to the new one.
*The Warning is shown ONLY when the user do customise the rootView*. For users which were not customising the Root View, the warning will not appear.

The documentation of the new method plus the warning should guide the users toward the right migration path.

## Changelog
[iOS][Added] - Added the customiseRootView method which is called in both bridge and bridgeless. Added also a warning for 0.74 with instructions on how to migrate.

Reviewed By: cortinico

Differential Revision: D52442598

fbshipit-source-id: 8b99b67f4741ee61989a8659a3d74c1eba27bc5b
2024-01-02 04:53:38 -08:00
Arushi KesarwaniandFacebook GitHub Bot af8c56ac58 Making UIManager not implement JSIModule (#42061)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42061

For removal of JSIModule getting rid of the inheritance relationship b/w interfaces UIManager & JSIModule by directly defining `initialize()` and `invalidate()`

Changelog:
[Internal] internal

Reviewed By: philIip, mdvacca

Differential Revision: D49306312

fbshipit-source-id: 041870418e13bb4b2381e609b94331c87be5f6fa
2024-01-01 21:07:09 -08:00
Arushi KesarwaniandFacebook GitHub Bot ce54772778 Delete getJSIModule() from context (#42097)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42097

Since we switched all apps from `getJSIModule()` to `getFabricUIManager()` from `ReactContext` and it's subclasses it's safe to delete this method.

NOTE: The fallback for FabricUIManager is still catalystInstance.getJSIModule() that's still there for backwards comptability just deleting the indirection through ReactContext

Changelog:
[Internal] Internal

Reviewed By: christophpurrer

Differential Revision: D51748655

fbshipit-source-id: dbf1a661f9e380307614662dd6079110f878d143
2024-01-01 21:07:09 -08:00
Saad NajmiandFacebook GitHub Bot 157cb0e02b Deprecate [RCTConvert UIBarStyle:] (#42100)
Summary:
The enums [UIBarStyleBlackOpaque](https://developer.apple.com/documentation/uikit/uibarstyle/uibarstyleblackopaque) and [UIBarStyleBlackTranslucent](https://developer.apple.com/documentation/uikit/uibarstyle/uibarstyleblacktranslucent) have been deprecated since iOS 13, already below React Native's minimum OS of iOS 13.4. Indeed, they are not available on visionOS and tvOS, making this a source of extra diffs.

Rather than deprecate and remove those options, I noticed that we don't actually use that `RCTConvert` method in the core repo, and haven't since `0.58-stable` (presumably before the lean core effort). Let's just remove it, it's a conversion that should be easy enough to replicate elsewhere. However, removal is a breaking change, so let's deprecate it for one release (0.74) and remove it for the next one (0.75). For posterity, tracking deprecation with https://github.com/microsoft/react-native-macos/issues/2008 and removal with https://github.com/microsoft/react-native-macos/issues/2009 .

## Changelog:

[IOS] [DEPRECATED] - Deprecate `[RCTConvert UIBarStyle:]`

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

Test Plan: CI should pass

Reviewed By: shwanton

Differential Revision: D52458912

Pulled By: NickGerleman

fbshipit-source-id: 5614b6624b9b929ba601ac976149b2002163ff54
2023-12-31 09:15:19 -08:00
Kevin GozaliandFacebook GitHub Bot 95bed60a1e iOS: renamed experimental new-arch-only flag to clarify its intent (#42072)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42072

This existing flag was for experimental (WIP) purpose only, and is undocumented, by design. Let's rename it so to make it clear. Libraries/Apps should not use this flag.

Changelog: [Internal]

Reviewed By: christophpurrer

Differential Revision: D52424750

fbshipit-source-id: 742fc6e31d1887e68439849e157dd23aaa054e36
2023-12-29 14:13:40 -08:00
Luna WeiandFacebook GitHub Bot b5e08e80d9 Remove * dependencies on @react-native (#42081)
Summary:
See https://github.com/facebook/react-native/issues/41929 for an issue on multiple monorepo packages being installed. The reason is that `*` resolves to whatever is tagged `latest` on npm.

We still need to fix the fact that our monorepo publish script will update the latest tag everytime we publish. For now, we should remove these from `main` and we will also update this in the 0.73 release branch.

I've left the two peer dependencies on `react-native` to keep at `*`.
```
virtualized-lists/package.json
30:    "react-native": "*"

rn-tester/package.json
32:    "react-native": "*"
```

As a peer-dependency this won't be a problem in terms of installing a second `react-native`. I thought about updating these to `nightly`, but that would install multiple nightly react-natives as the tag will be updated with each nightly release. I think for now this is fine and something we can revisit.

Things left to do
[ ] Fix monorepo publish script to not update `--latest`
[ ] Remove ^ dependencies on monorepo packages: https://github.com/facebook/react-native/pull/41958
[ ] Re-evaluate how we bump and align monorepo packages when we cut a release branch. I forget if we manually update this when we cut or if there is a script. We may want to change the script and have `main` dependencies point to some fake version like `1000.0.0` and only update these on nightly publishes. Regardless, this will need some discussion.

## Changelog:

[GENERAL] [CHANGED] - Be explicit about what monorepo versions we are using

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

Test Plan: N/A

Reviewed By: cortinico, cipolleschi

Differential Revision: D52435234

Pulled By: lunaleaps

fbshipit-source-id: 67da029d2b637e3997c12c21fe2a9ab9bc344399
2023-12-28 09:54:00 -08:00
Arushi KesarwaniandFacebook GitHub Bot e2fb88e6fd Deprecate old JSI module APIs (#42085)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42085

Deprecating the old JSI module APIs: `getJSIModule(JSIModuleType moduleType)`, `addJSIModules(List<JSIModuleSpec> jsiModules)` and `setTurboModuleManager(JSIModule getter)` to further delete them in future release. Deprecating them as of now to cater the OSS use-cases

Changelog:
[Internal] internal

Reviewed By: christophpurrer

Differential Revision: D50927292

fbshipit-source-id: 1d25f9f28b8aaf34979a90e4792317b263ae1714
2023-12-28 07:39:48 -08:00
Oscar FrancoandFacebook GitHub Bot 655b12dbfa Unhandled promise rejection - attach non-standard Error object stack info if possible (#42079)
Summary:
This is a continuation of my [last PR](https://github.com/facebook/react-native/pull/40914) which improved the symbolication of unhandled promise rejections.

While I was developing another library I noticed I still got an error stack of the log adding and not of the error itself. The library I'm trying to debug does not throw a standard error object but rather a custom one, but it still contains the stack field. By passing this stack field to the logbox call I was able to get a better symbolicated stack trace. The exact line of the failure is not displayed but at least the correct file is.

## Changelog:

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

Pick one each for the category and type tags:

[GENERAL] [ADDED] - Unhandled promise rejection - attach non-standard Error object stack info if possible

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

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

Test Plan:
Test any unhandled promise rejection with a non-standard error (line 23, toString must not return `[object Error]`) and see if the correct (or at least a better) stack trace is shown.

Here is the one I got before and after this change:

<img src="https://github.com/facebook/react-native/assets/1634213/3d07faad-9535-42c9-8032-b4d8fe407e88" width="200" />

<img src="https://github.com/facebook/react-native/assets/1634213/2c39bd82-c7a1-4f58-8ac4-5c479bb96b6e" width="200" />

Reviewed By: huntie

Differential Revision: D52431711

Pulled By: cipolleschi

fbshipit-source-id: be2172d3b1e2fc3f72812faac372c83bc6dface2
2023-12-28 04:23:58 -08:00
Kræn HansenandFacebook GitHub Bot e85d51c6f1 Detect ccache and provide a default configuration (#42051)
Summary:
Building native modules from source, may take a long time. Xcode already helps bring this down, by providing incremental builds, as long as the user doesn't delete their `ios/build` directory. But in some situations, i.e. when iterating the native code of an app or library or when the developer need to delete that `ios/build` directory, it's advantageous to use a compiler cache, such as ccache. This is already outlined in our ["Speeding up your Build phase"](https://reactnative.dev/docs/build-speed#xcode-specific-setup) guide.

But setting up an Xcode project to use Ccache with the correct configuration, isn't trivial in a way that doesn't require symlinking `clang` and `clang++` or passing configuration via environment variables on every `npm run ios` invokation.

This PR takes its inspiration from the existing guide on [setting up Ccache for Xcode](https://reactnative.dev/docs/build-speed#xcode-specific-setup), but applies the build settings only if an installation of `ccache` is detected and the feature is explicitly opted into via an argument to the `react_native_post_install` function or a `USE_CCACHE` environment variable. It uses two shell scripts to wrap the call to `ccache`, which both injects a default `CCACHE_CONFIGPATH` environment variable (i.e. it won't override this if already provided, to allow for customisations on CI), pointing to a `ccache.config` which works well with React Native projects (it has the same values as the guide mentions).

For context, I posted about this change in the ios channel of the contributors Discord server, where I discussed it with cipolleschi and saadnajmi

### Additional output printed when running `pod install`

#### When `ccache_available and ccache_enabled`

```
[Ccache]: Ccache found at /opt/homebrew/bin/ccache
[Ccache]: Setting CC, LD, CXX & LDPLUSPLUS build settings
```

#### When `ccache_available and !ccache_enabled`

```
[Ccache]: Ccache found at /opt/homebrew/bin/ccache
[Ccache]: Pass ':ccache_enabled => true' to 'react_native_post_install' in your Podfile or set environment variable 'USE_CCACHE=1' to increase the speed of subsequent builds
```

#### When `!ccache_available and ccache_enabled`

```
[!] [Ccache]: Install ccache or ensure your neither passing ':ccache_enabled => true' nor setting environment variable 'USE_CCACHE=1'
```

#### Otherwise

If the user doesn't have ccache installed and doesn't explicitly opt into this feature, nothing will be printed.

bypass-github-export-checks

## Changelog:

[IOS] [ADDED] - Added better support for `ccache`, to speed up subsequent builds of native code. After installing `ccache` and running `pod install`, the Xcode project is injected with compiler and linker build settings pointing scripts that loads a default  Ccache configuration and invokes the `ccache` executable.

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

Test Plan:
I've tested this manually - would love some inspiration on how to automate this, if the reviewer deem it needed.
To test this locally:
1. Install Ccache and make sure the `ccache` executable is in your `PATH` (verify by running `ccache --version`)
2. Create a new template app instance and apply the changes of this PR to the `node_modules/react-native` package.
3. Set the `USE_CCACHE` environment variable using `export USE_CCACHE=1`.
4. Run `pod install` in the `ios` directory.
5. Check the stats of Ccache (running `ccache -s`).
6. Run `npm run ios` or build the project from Xcode.
7. Check the Ccache stats again to verify ccache is intercepting compilation ("Cacheable calls" should ideally be 100%).
8. To check the speed gain:
  a. Delete the `ios/builds` directory
  b. Zero out the ccache stats (by running `ccache -z`)
  c. Run `pod install` again (only needed if you ran the initial `pod install` with new architecture enabled `RCT_NEW_ARCH_ENABLED=1`).
  d. Run `npm run ios` or build the project from Xcode.
  e. This last step should be significantly faster and you should see "Hits" under "Local storage" in the ccache stats approach 100%.

Reviewed By: huntie

Differential Revision: D52431507

Pulled By: cipolleschi

fbshipit-source-id: 6cfe39acd6250fae03959f0ee74d1f2fc46b0827
2023-12-28 01:42:01 -08:00
JorenVosandFacebook GitHub Bot e25a9b4c5d Fix support for --sourcemap-output path containing spaces in Xcode projects (#40937)
Summary:
This PR contains the changes from https://github.com/facebook/react-native/pull/30981 that got closed due to inactivity.

Many thanks to nickdowell for this bug report & fix. We encountered this error in our project when we had an Xcode scheme that contains a space (like `AppName alpha`).

This change fixes the generation of source maps for Xcode projects where the output path contains spaces.

The `EXTRA_ARGS` environment variable, being a plain string, would be split into arguments by whitespace - so a path containing spaces was being treated as several arguments rather than one.

This change uses an array to contain the arguments instead, allowing the proper handling of arguments that may contain spaces.

bypass-github-export-checks

## Changelog:

[iOS] [Fixed] - Fix support for --sourcemap-output path containing spaces

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

Test Plan:
Tested using a sample project with the following "Bundle React Native code and images" Xcode build phase

```
export SOURCEMAP_FILE="$CONFIGURATION_BUILD_DIR/$UNLOCALIZED_RESOURCES_FOLDER_PATH/main.jsbundle.map"
set -e
export NODE_BINARY=node
../node_modules/react-native/scripts/react-native-xcode.sh
```

and a `CONFIGURATION_BUILD_DIR` that contains spaces - `~/Library/Xcode/Derived Data`. **You can also try an XCode-scheme that contains a space.**

### Before

```
+ EXTRA_ARGS=
+ case "$PLATFORM_NAME" in
+ BUNDLE_PLATFORM=ios
+ EMIT_SOURCEMAP=
+ [[ ! -z /Users/nick/Library/Developer/Xcode/Derived Data/RN064-cpnwckdferodycbevupbrkjydate/Build/Products/Release-iphonesimulator/RN064.app/main.jsbundle.map ]]
+ EMIT_SOURCEMAP=true
+ PACKAGER_SOURCEMAP_FILE=
+ [[ true == true ]]
+ [[ '' == true ]]
+ PACKAGER_SOURCEMAP_FILE='/Users/nick/Library/Developer/Xcode/Derived Data/RN064-cpnwckdferodycbevupbrkjydate/Build/Products/Release-iphonesimulator/RN064.app/main.jsbundle.map'
+ EXTRA_ARGS=' --sourcemap-output /Users/nick/Library/Developer/Xcode/Derived Data/RN064-cpnwckdferodycbevupbrkjydate/Build/Products/Release-iphonesimulator/RN064.app/main.jsbundle.map'
+ node /Users/nick/Desktop/RN064/node_modules/react-native/cli.js bundle --entry-file index.js --platform ios --dev false --reset-cache --bundle-output '/Users/nick/Library/Developer/Xcode/Derived Data/RN064-cpnwckdferodycbevupbrkjydate/Build/Products/Release-iphonesimulator/main.jsbundle' --assets-dest '/Users/nick/Library/Developer/Xcode/Derived Data/RN064-cpnwckdferodycbevupbrkjydate/Build/Products/Release-iphonesimulator/RN064.app' --sourcemap-output /Users/nick/Library/Developer/Xcode/Derived Data/RN064-cpnwckdferodycbevupbrkjydate/Build/Products/Release-iphonesimulator/RN064.app/main.jsbundle.map
                    Welcome to Metro!
              Fast - Scalable - Integrated

info Writing bundle output to:, /Users/nick/Library/Developer/Xcode/Derived Data/RN064-cpnwckdferodycbevupbrkjydate/Build/Products/Release-iphonesimulator/main.jsbundle
info Writing sourcemap output to:, /Users/nick/Library/Developer/Xcode/Derived
```
Note the incorrect sourcemap output path.

### After

```
+ EXTRA_ARGS=()
+ case "$PLATFORM_NAME" in
+ BUNDLE_PLATFORM=ios
+ EMIT_SOURCEMAP=
+ [[ ! -z /Users/nick/Library/Developer/Xcode/Derived Data/RN064-cpnwckdferodycbevupbrkjydate/Build/Products/Release-iphonesimulator/RN064.app/main.jsbundle.map ]]
+ EMIT_SOURCEMAP=true
+ PACKAGER_SOURCEMAP_FILE=
+ [[ true == true ]]
+ [[ '' == true ]]
+ PACKAGER_SOURCEMAP_FILE='/Users/nick/Library/Developer/Xcode/Derived Data/RN064-cpnwckdferodycbevupbrkjydate/Build/Products/Release-iphonesimulator/RN064.app/main.jsbundle.map'
+ EXTRA_ARGS+=("--sourcemap-output")
+ EXTRA_ARGS+=("$PACKAGER_SOURCEMAP_FILE")
+ node /Users/nick/Desktop/RN064/node_modules/react-native/cli.js bundle --entry-file index.js --platform ios --dev false --reset-cache --bundle-output '/Users/nick/Library/Developer/Xcode/Derived Data/RN064-cpnwckdferodycbevupbrkjydate/Build/Products/Release-iphonesimulator/main.jsbundle' --assets-dest '/Users/nick/Library/Developer/Xcode/Derived Data/RN064-cpnwckdferodycbevupbrkjydate/Build/Products/Release-iphonesimulator/RN064.app' --sourcemap-output '/Users/nick/Library/Developer/Xcode/Derived Data/RN064-cpnwckdferodycbevupbrkjydate/Build/Products/Release-iphonesimulator/RN064.app/main.jsbundle.map'
                    Welcome to Metro!
              Fast - Scalable - Integrated

info Writing bundle output to:, /Users/nick/Library/Developer/Xcode/Derived Data/RN064-cpnwckdferodycbevupbrkjydate/Build/Products/Release-iphonesimulator/main.jsbundle
info Writing sourcemap output to:, /Users/nick/Library/Developer/Xcode/Derived Data/RN064-cpnwckdferodycbevupbrkjydate/Build/Products/Release-iphonesimulator/RN064.app/main.jsbundle.map
```
sourcemap output path fixed 🎉

Reviewed By: arushikesarwani94

Differential Revision: D52431057

Pulled By: cipolleschi

fbshipit-source-id: 528217c84fe3f467a30baa15cfa4dcb2ed713165
2023-12-28 00:58:17 -08:00
Arushi KesarwaniandFacebook GitHub Bot b507e11867 Make TurboModuleManager not implement JSIModule (#42060)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42060

For removal of JSIModule getting rid of the inheritance relationship b/w interfaces TurboModuleManager & JSIModule by directly defining `invalidate()`. `initialize()` here isn't being used hence not defining it.

Changelog:
[Internal] internal

Reviewed By: philIip, mdvacca

Differential Revision: D49977957

fbshipit-source-id: 8de644b1f344d8ce8d4a78655556829f860a2b10
2023-12-27 21:02:07 -08:00
Nicola CortiandFacebook GitHub Bot d992abc56d Move legacy tests from OSS to fbandroid/java/com/facebook/fbreact (#41802)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/41802

Those tests are not executing at all, they're just compiled.
Our internal infra is still depending on some bits of it though, so I'm moving them to `fbandroid/java/com/facebook/fbreact

Changelog:
[Internal] [Changed] - Move legacy tests from OSS to  fbandroid/java/com/facebook/fbreact

Reviewed By: rshest

Differential Revision: D51805702

fbshipit-source-id: 2c5cec68efa9854184e981220202d8f356ff690a
2023-12-27 17:34:29 -08:00
Nicola CortiandFacebook GitHub Bot c75abefea6 Convert the last Unit Tests to Kotlin (#42078)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42078

Resubmit of D51891716 and D52033328

I'm doing a pass and converting the last Java Unit Tests we had to Kotlin
I've also re-enabled multiple tests that were disabled in the past.

Changelog:
[Internal] [Changed] - Convert the last Unit Tests to Kotlin

Reviewed By: rshest

Differential Revision: D52430728

fbshipit-source-id: e6b4a6ed88d852024d959cf5148e992e97a84434
2023-12-27 08:52:29 -08:00
Janic DuplessisandFacebook GitHub Bot ac9b87cd57 Fix comment about adding packages in android template (#41856)
Summary:
I noticed this comment is still in Java in the Kotlin template. It also doesn't really work anymore since there is no packages variable.

To fix it I completed the comment with all code needed for it to work in kotlin. I think an older version of the template used to be more like:

```kotlin
val packages = PackageList(this).packages
// packages.add(MyReactNativePackage())
return packages
```

But then it requires adding a lint suppress annotation since packages variable can be simplified. I think this is simpler even if it makes the comment a few more lines.

## Changelog:

[GENERAL] [FIXED] - Fix comment about adding packages in android template

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

Test Plan: Tested that uncommenting that code works

Reviewed By: cipolleschi

Differential Revision: D51987483

Pulled By: cortinico

fbshipit-source-id: d0135b5b536960017ccc7b25f92c75b3bd863cd9
2023-12-27 08:47:02 -08:00
Ruslan ShestopalyukandFacebook GitHub Bot ffe219cd06 Avoid using std::views::filter to fix issues with macosx-x86_64 toolchain (#42076)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42076

## Changelog:
[Internal] -

In https://github.com/facebook/react-native/pull/41519 we introduced usage of C++20s range operations, which broke MacOSX desktop builds for the x86_64 targets (e.g. on Intel Mac laptops).

This appears to be a [known issue](https://stackoverflow.com/questions/73929080/error-with-clang-15-and-c20-stdviewsfilter), fixed in the later clang versions, however we need to support the earlier ones as well.

This changes the code to use the good old imperative style to do the same thing, but without using `std::views::filter`, thus working around the problem.

Reviewed By: christophpurrer

Differential Revision: D52428984

fbshipit-source-id: 6d0a390549c462b7040b5c0e669c00932bd99af7
2023-12-27 03:58:08 -08:00
Arushi KesarwaniandFacebook GitHub Bot c2c346ccaf Get rid of old APIs in FabricUIManagerProvider (#42059)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42059

Getting rid of old APIs in FabricUIManagerProvider and also clearing it of the inheritance dependency it has on JSIModule post it's references have been cleared.

Reviewed By: christophpurrer

Differential Revision: D51001239

fbshipit-source-id: c3d4650c292e957e9f939304662932c11af7a24f
2023-12-26 23:25:06 -08:00