Commit Graph
30326 Commits
Author SHA1 Message Date
Rubén NorteandFacebook GitHub Bot e04d1b47b6 Move feature flags for the event loop to ReactNativeFeatureFlags (#42434)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42434

Changelog: [internal]

The flags for the event loop were set up using different mechanisms due to the limitations of the previous feature flags systems. Now we can centralize on the new system and use them consistently on Android and iOS.

Reviewed By: RSNara

Differential Revision: D52819137

fbshipit-source-id: e30a6f2e12b4a027a906502b80a70dd48bb657b6
2024-01-25 13:55:11 -08:00
Rubén NorteandFacebook GitHub Bot 705c675d51 Implement new feature flag system (#42430)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42430

This PR creates a new internal feature flags system for React Native. This is only meant to be used internally within the framework, but we might expose it externally in some form in the future to allow customizing specific feature flags in frameworks and applications.

Features:
* 2 types of flags:
  * Common: can be overridden from native and are accessible from all layers of the stack (Objective-C/Swift, Java/Kotlin, C++ and JavaScript).
  * JS-only: flags that can only be defined and accessed from JS (to allow things like hot reloading without a native build).
* 1 source of truth for each flag.
* Feature flags are application/process scoped (using C++ singletons).

See the `README.md` file in this PR for additional information.

This also adds modifies `run-ci-javascript-tests` to run a new check to make sure that the generate files are in sync with the JSON file that contains the definitions.

Changelog: [internal]

Reviewed By: huntie

Differential Revision: D52806730

fbshipit-source-id: 0ba95803f61ec2f05266ee535921321bf6d3dc6a
2024-01-25 13:55:11 -08:00
David VaccaandFacebook GitHub Bot dc2ce9e66e Fix incorrect measurement of TextInput (#42655)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42655

This bug is caused by a caching issue: when the user enters a new character into the textInput: ReactTextInput 1) caches the Spannable entered by the user and 2) it updates internal Fabric state, which triggers the measurement of the TextInput component using the cached Spannable.

The problem is that the Spannable entered by the user has the wrong "styles" for the text input. Since measurement is using the cached Spannable, then the measurement of the TextInput ends up being is incorrect.

In this diff I'm fixing the bug by updating the styles (lineHeight) of the cached spannable that is cached when the user updates the TextInput.
The styles weren't updated correctly because mTextAttributes didn't have the proper style props set

Changelog:
    [Android][Fixed] - Fix incorrect measurement of TextInput when new architecture is enabled

Reviewed By: javache, sammy-SC

Differential Revision: D52924982

fbshipit-source-id: ced9f2c348bdb9bf706028b1063858cebd5a071a
2024-01-25 11:07:12 -08:00
Nicola CortiandFacebook GitHub Bot 97d6d724e1 Cleanup srcSet for java and res (#42659)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42659

Those folders for Java don't exist anymore, I'm removing this as it's unnecessary and will default to only src/main/java.
For resources instead, I'm using `setSrcDirs` as it will replace the default, while `srcDirs()` will add those folders.
We need to replace the default res folder as we need to follow the resource folder structure of BUCK

Changelog:
[Internal] [Changed] - Cleanup srcSet for java and res

Reviewed By: cipolleschi

Differential Revision: D53083677

fbshipit-source-id: 4dc42c700ea5446bbd49c63fc43b58ba316f4944
2024-01-25 10:58:00 -08:00
Samuel SuslaandFacebook GitHub Bot 889ead1f1f remove feature flag cancel_image_downloads_on_recycle (#42663)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42663

changelog: [internal]

Removing the MC, this has been shipped.

Reviewed By: rubennorte

Differential Revision: D53043474

fbshipit-source-id: 2036f6752a3930666e872df0f6418e3ad8986441
2024-01-25 08:47:56 -08:00
Pieter De BaetsandFacebook GitHub Bot c9764c5a17 Clarify docs and deprecation on Event methods (#42600)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42600

Disentangled the logic for emitting touches to JS on Android. `receiveTouches` should never be used as a public API, as TouchEvents can be dispatched just like any other event, and receiveTouches is an internal helper for `TouchEvent`.

Changelog: [Android][Removed] Updated migrated guidance for EventEmitter and reduced visibility of internal TouchesHelper methods

Reviewed By: cortinico

Differential Revision: D52907393

fbshipit-source-id: a8207039c863ab23a1d93dd2d2f28e8a274c8ecf
2024-01-25 07:33:17 -08:00
Pieter De BaetsandFacebook GitHub Bot 49f6ffc92f Fix Soloader call in DefaultComponentsRegistry (#42660)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42660

Calling `maybeLoadSoLibrary` from init is too late, as we call `initHybrid` before `init`. Instead use a static initializer.

Changelog: [Internal]

Reviewed By: cortinico

Differential Revision: D53048065

fbshipit-source-id: dfd2957fd9209e02c498ee08e9cbd7c7a1a83c3e
2024-01-25 07:07:04 -08:00
Riccardo CipolleschiandFacebook GitHub Bot e7fd142c38 Enable the DevMenu in bridgeless mode (#42657)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42657

When the RCT_DEV flag is turned on, we force the eager initialization of the DevMenu at startup.
The initialization was happening in a method of the `CxxBridgeDelegate` protocol.
In bridgeless mode, we don't have the bridge, hence we don't call this method.

I need to put the initialization code in the `RCTIntance` because the only way I found to eagerly initialize a module was to tap into the `RCTTurboModuleManager` and, in Bridgeless mode, that's seemed to be the only way.
I'm open to move the code to a better place, anyway!

## Changelog:
[Internal] - Enable the DevMenu eagerly in Bridgeless mode

Reviewed By: sammy-SC

Differential Revision: D53083637

fbshipit-source-id: 219698eab77ed115ab0f4ea43911ae883a4c9e8a
2024-01-25 06:27:14 -08:00
Jakub TrzebiatowskiandFacebook GitHub Bot 2dc2d4db8f RCTAttributedTextUtils.mm: Split NSAttributedString creation (#42595)
Summary:
`RCTAttributedTextUtils.mm`: Split `NSAttributedString` creation to functions in preparation for adding new logic here.

This is a minor improvement in the context of my multi-PR work on https://github.com/react-native-community/discussions-and-proposals/issues/695.

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

[INTERNAL] [CHANGE] - Refactor `NSAttributedString` creation in `RCTAttributedTextUtils.mm`

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

Reviewed By: cipolleschi

Differential Revision: D53001495

Pulled By: sammy-SC

fbshipit-source-id: 52d28e48f0a9d88d44325a73c64737fc7ac97781
2024-01-25 05:08:35 -08:00
Jakub TrzebiatowskiandFacebook GitHub Bot 011152318a CustomLineHeightSpan: Increase the readability (#42592)
Summary:
Increase the readability of `CustomLineHeightSpan` by making the logic less stateful.

This is a minor improvement in the context of my multi-PR work on https://github.com/react-native-community/discussions-and-proposals/issues/695.

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

[INTERNAL] [CHANGED] - Increase the readability of `CustomLineHeightSpan`

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

Test Plan:
- Prove the equivalence of the old and the new logic
- Test that the behavior of `lineHeight` doesn't change

Reviewed By: NickGerleman

Differential Revision: D53028467

Pulled By: mdvacca

fbshipit-source-id: d533bb77c8e10c29d8f2acc8cc39565d0013b03b
2024-01-25 04:40:49 -08:00
Samuel SuslaandFacebook GitHub Bot a5aed1294f enable setNativeProps in animations on by default (#42603)
Summary:
Changelog: [General][Added] Enable setNativeProps in animations in the New Architecture

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

Enabling setNativeProps in animations on by default.

Reviewed By: mdvacca

Differential Revision: D52962882

fbshipit-source-id: 67921c8e36e97b7b1315dfa0d5f3bd708ccb0079
2024-01-25 03:44:22 -08:00
Jakub TrzebiatowskiandFacebook GitHub Bot 87bcaa3fa1 TextLayoutUtils: Use named arguments (#42593)
Summary:
`TextLayoutUtils`: Use named arguments to ensure same-type arguments (like `start`/`end`) are not confused

This is a minor readability follow-up to https://github.com/facebook/react-native/pull/39630.

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

[INTERNAL] [CHANGED] - Increase the `TextLayoutUtils` readability slightly

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

Reviewed By: NickGerleman

Differential Revision: D53028402

Pulled By: mdvacca

fbshipit-source-id: 39e99ba70b93eecfc51bda19d30a5b1977cfe406
2024-01-25 02:49:30 -08:00
szymonrybczakandFacebook GitHub Bot 78967b33c0 Bump CLI to 13.5.1 (#42183)
Summary:
Updates CLI to v13.5.1.

## Changelog:

[GENERAL] [CHANGED] - Bump CLI to 13.5.1

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

Test Plan: CI

Reviewed By: christophpurrer

Differential Revision: D52600707

Pulled By: huntie

fbshipit-source-id: f314a405d8d7e9200595b42b62d354e61f0a2964
2024-01-25 02:32:45 -08:00
Alex HuntandFacebook GitHub Bot 02e7244b3d Improve types, fix translator compatibility for version-related modules (#42638)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42638

Enables these modules to be covered by `public-api-test`.

- Standardise as CommonJS modules, fixing compatibility with [`flow-api-translator`](https://www.npmjs.com/package/flow-api-translator).
- Use explicit object type in generated file template.

Changelog: [Internal]

Reviewed By: NickGerleman

Differential Revision: D52963967

fbshipit-source-id: c9f3e35f70859c1b99b7297228ee2498f91d9041
2024-01-25 02:32:00 -08:00
Krzysztof MagieraandFacebook GitHub Bot 0ea16fd3f7 Unify codepath for retrieveing metro location on Android (#42617)
Summary:
With the current ways metro location is determined, when we want to use a different metro port this requires app to be rebuild as the port and location are stored in resource file that gets compiled to R.class. The only way to avoid app rebuild due to a port change is to use shared preferences that can be accessed from dev menu, where metro URL can be specified. However, due to a separate code-paths for retrieving bundle location and for `/inspector/device` calls, the setting only applies to the former. As a consequence, you can change metro URL in the shared preferences, but debugging would only work if you use the default port or you rebuild the app with the correct port number.

This PR removes the separate code-path for retrieving inspector URL including all the dependencies scattered across different files including the gradle plugin. We then replace calls to `PackagerConnectionSettings.getInspectorServerHost` with `PackagerConnectionSettings.getDebugServerHost` which respects the shared preferences and other possible ways of configuring the port.

I decided to remove the separate inspector URL code path, as the resource value for inspector port added in https://github.com/facebook/react-native/issues/23616 was never functioning properly due to a bug. In the said PR introduced a bug in [AndroidInfoHelpers.java](https://github.com/facebook/react-native/blob/a13d51ff1c38ea85e59f4215563c0dd05452f670/packages/react-native/ReactAndroid/src/main/java/com/facebook/react/modules/systeminfo/AndroidInfoHelpers.java#L77) where `react_native_dev_server_port` was used instead `react_native_inspector_proxy_port`. As a result the added resource value was never read.

This can be potentially a breaking change as I'm removing some public methods. However I think it is unlikely anyone relied on said methods. As a part of this PR I'm also changing occurences of removed methods from ReactAndroid.api – I don't know how to test those changes since I don't understand how this file is used as it doesn't have any references in public code.

## Changelog:

[ANDROID] [FIXED] - Make Android respect metro location from shared preferences for the debugger workflow

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

Test Plan:
1. Run android app on emulator using default port
2. Check the debugger works when using "Open Debugger" option from dev menu
3. Restart metro with custom port (`--port 9090`) while keeping the app running
4. Open dev menu, click "Settings" then "Debug server host & port", put "10.0.2.2:9090" there
5. Reload the app
6. Before this change things like hot reload would continue to work while "Open Debugger" option would do nothing
7. After this change both reloading and debugging will work

Important: I haven't tested changes made to ReactAndroid.api as I don't know what this files is used for with no references in the codebase.

Reviewed By: cortinico

Differential Revision: D53010023

Pulled By: huntie

fbshipit-source-id: cc8b9c5c7e834ec9ea02b1ed5acf94f04f7b7116
2024-01-25 02:29:13 -08:00
Kudo ChienandFacebook GitHub Bot 631b6a12c5 Enable DEFINES_MODULE for DoubleConversion (#42591)
Summary:
since https://github.com/facebook/react-native/commit/32dab7a63fd0795c3aaefa766aa9f818428ed2de, `DoubleConversion` is now added as an implicit dependency for 3rd party module and it breaks swift integration. this pr tries to add the `DEFINES_MODULE` to DoubleConversion.

## Changelog:

[IOS] [FIXED] - Fixed `DoubleConversion` build error from Swift integration

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

Test Plan:
i'll need to test this on expo latest and react-native nightly build

```sh
# pull latest expo repo and get template tarball
$ git clone --depth 1 https://github.com/expo/expo.git
$ cd expo
$ yarn install
$ cd templates/expo-template-bare-minimum
$ npx pack --pack-destination ../../

# now create an expo app
$ yarn create expo -t blank@sdk-50 sdk50
$ cd sdk50
$ yarn add react-native@nightly
$ jq '.expo.runtimeVersion = { "policy": "appVersion" }' app.json > app.json.tmp && mv app.json.tmp app.json
$ npx expo prebuild -p ios --template /path/to/expo/expo-template-bare-minimum-50.0.17.tgz
$ cd ios
$ pod install
```

then it will show the error message:
```
[!] The following Swift pods cannot yet be integrated as static libraries:

The Swift pod `ExpoModulesCore` depends upon `DoubleConversion`, which does not define modules. To opt into those targets generating module maps (which is necessary to import them from Swift when building as static libraries), you may set `use_modular_headers!` globally in your Podfile, or specify `:modular_headers => true` for particular dependencies.
```

Reviewed By: cortinico

Differential Revision: D53048352

Pulled By: cipolleschi

fbshipit-source-id: b1e27d3d26e8543a4cb2e8062c93c68543a051c5
2024-01-25 02:05:56 -08:00
Gabriel DonadelandFacebook GitHub Bot 41c601e478 Remove ATS config patch from react_native_post_install (#42637)
Summary:
This PR removes the `apply_ats_config` function of ReactNativePodsUtils that was used inside `react_native_post_install` because it was preventing users from configuring `NSAllowsArbitraryLoads` to true in their projects, especially when building in CI as the plist file would be reset after running pod install.

## Changelog:

[IOS] [CHANGED] - Remove ATS config patch from react_native_post_install

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

Test Plan: Edit `Info.plist`, run `pod install` and check if changes have not been overwritten

Reviewed By: cortinico

Differential Revision: D53048299

Pulled By: cipolleschi

fbshipit-source-id: 8dc335fae2e05a62daf931a50fa3f7a314e76a2e
2024-01-25 02:04:18 -08:00
Riccardo CipolleschiandFacebook GitHub Bot f4dbd15f0b Fix RCTFabric podspec (#42639)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42639

When I reverted part of the deprecation of `RCT_NEW_ARCH_ENABLED`, I forget a little bit which was breaking RCTFabric podspec.

This diff fixes that.

## Changelog:
[Internal] - Bring back `RCT_NEW_ARCH_ENABLED` to Fabric to make the `RCTThirdPartyFabricComponentsProvider` work again.

Reviewed By: cortinico

Differential Revision: D53048270

fbshipit-source-id: d21e833c10b332fb70147cc65b690f88016655e6
2024-01-25 02:02:40 -08:00
Luna WeiandFacebook GitHub Bot f322dc7a84 Typing scripts used for test-e2e-local (#42610)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42610

Changelog: [Internal] Adding more typing to internal scripts used by test-e2e-local

Reviewed By: NickGerleman

Differential Revision: D52988733

fbshipit-source-id: 6e187b7c9560b30def014e8932ab82ed07cf8488
2024-01-24 15:39:06 -08:00
Luna WeiandFacebook GitHub Bot 3d097d46e3 Type circle-ci-artifacts-util (#42608)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42608

Changelog: [Internal] - Type circle-ci-artifacts-util and migrate it to node-fetch

Reviewed By: NickGerleman

Differential Revision: D52932555

fbshipit-source-id: 50e874e23fe8131a9376845006dab3116aed8a04
2024-01-24 15:39:06 -08:00
Ingrid WangandFacebook GitHub Bot ccff2bb8d1 Migrate RNTester onto new RN notification callbacks (#42406)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42406

## Changelog:

[iOS][Changed] Migrated RNTester/AppDelegate to the new notification callback

Reviewed By: philIip

Differential Revision: D52883367

fbshipit-source-id: 0afcd81f4ad4ee0c49b264785fa261789603a072
2024-01-24 09:29:41 -08:00
Riccardo CipolleschiandFacebook GitHub Bot d46d80d2ef Register RCTDeviceInfo to invalidating and cleanup observer (#42396)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42396

Cmmunity reported [#42120](https://github.com/facebook/react-native/issues/42120) where React Native was crashing if RCTDeviceInfo native module was receiving a notification while the bridge is invalidating.

Upon investigation, I realized that:
1. The RCTDeviceInfo module is never invalidated
2. Observers are still observing even when the Bridge is in an invalidated state and it is not back up.

This change makes sure that we invalidate the `RCTDeviceInfo.mm` module and that we unregister the observers.

## Changelog:
[iOS][Fixed] - Make `RCTDeviceInfo` listen to invalidate events and unregister observers while invalidating the bridge

Reviewed By: RSNara

Differential Revision: D52912604

fbshipit-source-id: 1727bcdef5393b1bd5a272e2143bc65456c2a389
2024-01-24 06:44:29 -08:00
Riccardo CipolleschiandFacebook GitHub Bot 7c4afa1006 Add a snapshot only if the Modal is visible (#42619)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42619

This is a workaround to prepare for the next diff in the stack and make sure that the modal works correctly

## Changelog
[iOS][Changed] - Add the for the dismissal snapshot only when we need it.

Reviewed By: sammy-SC

Differential Revision: D53003657

fbshipit-source-id: 6d6cc85946b1beb8e784e08a650d1247cf780228
2024-01-24 05:54:15 -08:00
Moti ZilbermanandFacebook GitHub Bot be441f8fbe Create PageTarget{Delegate,Controller}, respond to Page.reload (#42587)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42587

Changelog: [Internal]

* Introduces the Target Delegate and Target Controller concepts (see `CONCEPTS.md`).
* Introduces the `PageTargetDelegate` interface and `PageTargetController` class (see doc comments).
* Uses the above infra to implement support for the `Page.reload` CDP command. Each integration provides its own `PageTargetDelegate` that knows how to trigger a reload in a platform- and architecture-specific way.
  * iOS Bridge/Bridgeless and `PageTargetTest` are the only integrations that exist as of this diff, and are all updated here; Android will follow later.

NOTE: `RCTBridge` = iOS Bridge, `RCTHost` = iOS Bridgeless.

## Object lifetimes

`PageAgent` holds a raw `PageTargetController&` reference to a member of `PageTarget`, through which it gets access to that target's `PageTargetDelegate&` (another raw reference).

Here's what makes this safe:

1. **`PageTargetDelegate` outlives `PageTarget`** - this is the responsibility of the platform integration ( = the code that instantiates `PageTarget`).
2. **`PageTarget` outlives its Sessions and Agents** - this is `PageTarget`'s "moral" responsibility, even though it doesn't own its Sessions outright (`InspectorPackagerConnection` does). We add an assertion in `PageTarget`'s destructor to catch violations, and document that the integrator must call `getInspectorInstance().removePage` (which terminates all remaining sessions) before destroying the corresponding `PageTarget`.

NOTE: In upcoming diffs we'll use the new Target→Session references, currently used only for the assertion in (2), to power actual functionality (e.g. dispatching CDP events to the frontend when some imperative method is called on `PageTarget`).

## Thread safety

`PageTargetDelegate::onReload` is guaranteed to be called synchronously on the thread where messages are dispatched to `PageTargetSession`, which on iOS is the main (UI) thread.

Reviewed By: huntie

Differential Revision: D51164125

fbshipit-source-id: 4c3eeb81a8df9677c173588eb5acfd686722c3c9
2024-01-24 05:52:56 -08:00
Nicola CortiandFacebook GitHub Bot b8778abca5 Build Android on Ubuntu 22.04 (#42618)
Summary:
Bumping the Docker image we use to build Android from Ubuntu 20.04 to 22.04

## Changelog:

[INTERNAL] - Build Android on Ubuntu 22.04

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

Test Plan: CI

Reviewed By: NickGerleman

Differential Revision: D53003492

Pulled By: cortinico

fbshipit-source-id: 547d19628e67aeb7a6d32e0a006673c909b55f32
2024-01-24 00:54:51 -08:00
Jakub TrzebiatowskiandFacebook GitHub Bot cbd818dad7 Clean up the function naming in TextMeasureCache.h (#42598)
Summary:
Clean up the function naming in `TextMeasureCache.h`. One name was clearly a human mistake. Make the naming consistent.

This is a minor improvement in the context of my multi-PR work on https://github.com/react-native-community/discussions-and-proposals/issues/695.

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

[INTERNAL] [CHANGE] - Clean up the function naming in `TextMeasureCache.h`

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

Reviewed By: NickGerleman

Differential Revision: D52960435

Pulled By: sammy-SC

fbshipit-source-id: 01327610446933972e8dc87e1b6e2950b7c706d2
2024-01-23 08:59:56 -08:00
Oskar KwaśniewskiandFacebook GitHub Bot ebb2b9c3fc feat: make codegen take OOT Apple platforms into account (#42047)
Summary:
### The problem

1. We have a library that's supported on iOS but doesn't have support for visionOS.
2. We run pod install
3. Codegen runs and generates Code for this library and tries to reference library class in `RCTThirdPartyFabricComponentsProvider`
4. Example:

```objc
Class<RCTComponentViewProtocol> RNCSafeAreaProviderCls(void) __attribute__((used)); // 0
```

This is an issue because the library files are not linked for visionOS platform (because code is linked only for iOS due to pod supporting only iOS).

### Solution

Make codegen take Apple OOT platforms into account by adding compiler macros if the given platform doesn't explicitly support this platform in the native package's podspec file.

Example generated output for library supporting only `ios` and `visionos` in podspec:

![CleanShot 2023-12-22 at 15 48 22@2x](https://github.com/facebook/react-native/assets/52801365/0cdfe7f5-441d-4466-8713-5f65feef26e7)

I used compiler conditionals because not every platform works the same, and if in the future let's say react-native-visionos were merged upstream compiler conditionals would still work.

Also tvOS uses Xcode targets to differentiate which platform it builds so conditionally adding things to the generated file wouldn't work.

## Changelog:

[IOS] [ADDED] - make codegen take OOT Apple platforms into account

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

Test Plan:
1. Generate a sample app with a template
5. Add third-party library (In my case it was https://github.com/callstack/react-native-slider)
6. Check if generated codegen code includes compiler macros

Reviewed By: cipolleschi

Differential Revision: D52656076

Pulled By: dmytrorykun

fbshipit-source-id: c827f358997c70a3c49f80c55915c28bdab9b97f
2024-01-23 06:53:57 -08:00
Nicola CortiandFacebook GitHub Bot a13d51ff1c Remove dead android scripts (#42612)
Summary:
Those scripts are all dead, and should not be used anymore.
I'm removing them.

## Changelog:

[INTERNAL] - Remove dead android scripts

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

Test Plan: n/a

Reviewed By: cipolleschi

Differential Revision: D52997852

Pulled By: cortinico

fbshipit-source-id: cf57177eedb8bc0f40daf7c6c5fcd1d5ba89ba32
2024-01-23 03:03:08 -08:00
Jakub TrzebiatowskiandFacebook GitHub Bot 2722f95720 Extract fragment conversions to separate functions (#42597)
Summary:
Extract fragment conversions to separate functions to make refactoring easier and simplify reasoning about the code.

This code is being modified later.

This is a minor improvement in the context of my multi-PR work on https://github.com/react-native-community/discussions-and-proposals/issues/695.

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

[INTERNAL] [CHANGE] - Extract fragment conversions to separate functions

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

Reviewed By: NickGerleman

Differential Revision: D52960655

Pulled By: robhogan

fbshipit-source-id: 0df62b9980c06a1c2fc113d645ba8b6b668fa394
2024-01-23 00:48:38 -08:00
Nick GerlemanandFacebook GitHub Bot e27452a670 Fix flooring of border (#42411)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42411

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

I added a small regression D52605596, where negative border would not be correctly floored. This fixes that, and starts adding tests specifically targeting the computed style API, now decoupled from the yoga node.

Reviewed By: joevilches

Differential Revision: D52930827

fbshipit-source-id: e165dade705a8de54c92d65f3664c9081137788c
2024-01-22 22:07:49 -08:00
Phillip PanandFacebook GitHub Bot cfcf3a3f95 unpin SocketRocket from startup (#42410)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42410

Changelog: [Internal]

Properly compiling these files out so we don't need to pull in SocketRocket to startup

Long term, we need to lift DevSupport and Inspector directories out of ReactInternal target

Reviewed By: fkgozali

Differential Revision: D52890707

fbshipit-source-id: efe59092d8f5487ab3f62ffb4ebd2b8aa58399fe
2024-01-22 19:44:20 -08:00
Ingrid WangandFacebook GitHub Bot 1b85ed94a1 Introduce new notification callback in RCTPushNotificationManager (#42405)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42405

## Changelog:

[iOS][Deprecated] Deprecating RCTPushNotificationManager's didReceiveLocalNotification: and didReceiveRemoteNotification:

Reviewed By: philIip

Differential Revision: D52375779

fbshipit-source-id: a668d448e76960fd14784c1a0eede9629f264292
2024-01-22 16:43:55 -08:00
Joe VilchesandFacebook GitHub Bot 64d81905ac Fix mismatched cases of inlineStart/End and flexStart/End
Summary:
X-link: https://github.com/facebook/yoga/pull/1561

Back when I introduced the inline functions that would get the edge according to the writing direction I swapped some instances of `setLayoutPosition` which wrote to the flexStart edge erroneously. We should basically never read from some inline style and write to the flex edge. This changes them all to use the flex values.

Reviewed By: NickGerleman

Differential Revision: D52921401

fbshipit-source-id: 92b74d652018596134c91827806272ed7418ef6c
2024-01-22 15:41:09 -08:00
Xin ChenandFacebook GitHub Bot 212e795edb Deprecate ReactFeatureFlags.reduceDeleteCreateMutationLayoutAnimation (#42338)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42338

This diff cleans up the code added in D41895427 to run QE: https://fburl.com/qe2/0di6ipt6

More context: https://fb.workplace.com/groups/react.technologies.discussions/permalink/3479283292303384/

Changelog:
[Android][Internal] - Revert internal optimizations

Reviewed By: mdvacca

Differential Revision: D52751274

fbshipit-source-id: 61cd084ffa02561637d8ce7f8a113c3e6818b063
2024-01-22 12:52:01 -08:00
Xin ChenandFacebook GitHub Bot 0e90cd46f1 Revert QE for ReactFeatureFlags.reduceDeleteCreateMutation (#42339)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42339

This diff cleans up the code added in D41900201 to run QE: https://fburl.com/qe2/ovgxlayy

More context: https://fb.workplace.com/groups/react.technologies.discussions/permalink/3479283292303384/

Changelog:
[Android][Internal] - Revert internal optimizations

Reviewed By: mdvacca

Differential Revision: D52750975

fbshipit-source-id: 675a3d0bb05094e35e47b35e6840fb2e5a24b9a1
2024-01-22 12:52:01 -08:00
Alex HuntandFacebook GitHub Bot 4e92f87dfd Align parsing of custom resolver options, rename arg (#42392)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42392

Follow-up to https://github.com/facebook/react-native/pull/42333 following internal feedback. We are now aligning this to match the [`metro build` command](https://github.com/facebook/metro/blob/702e1b8fc7ab8b973bcd53f1a41f7e797cbf7dca/packages/metro/src/commands/build.js#L85-L91). This also improves validation on parsing (done after initial `commander` arg parsing as variadic string).

Changelog: [Internal]
(same as https://github.com/facebook/react-native/pull/42333)

Reviewed By: motiz88

Differential Revision: D52911017

fbshipit-source-id: 54049aa20c9db344a0f485fddf62fb267e672376
2024-01-22 10:31:51 -08:00
Christoph PurrerandFacebook GitHub Bot 4681e407b2 react-native: Bridging. Add conversion functions to std::array<T, N> and std::pair<T1, T2> (#42558)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42558

Changelog: [Internal]

These are currently missing.

They are convinient to e.g. turn an array of JS arrays such as `[["key", "value"]]` into a
- std::vector<std::array<T, N>> or
- std::vector<std::pair<T1, T2>>

which is e.g. used here: https://github.com/facebook/react-native/blob/main/packages/react-native/Libraries/Network/RCTNetworking.android.js#L25-L31

Reviewed By: javache

Differential Revision: D52943602

fbshipit-source-id: 039e3dbc82b28e795b024395550225452defc27d
2024-01-22 10:30:08 -08:00
Luna WeiandFacebook GitHub Bot 0851f04353 Flow type some util files (#42372)
Summary:
Changelog: [Internal] Flow comment type some util scripts

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

Reviewed By: NickGerleman

Differential Revision: D52893759

Pulled By: lunaleaps

fbshipit-source-id: 6a3632f2c0b9faa97a451d82ef5a888bb5be81fa
2024-01-22 10:29:54 -08:00
Moti ZilbermanandFacebook GitHub Bot a89005d709 Don't inject synthetic Debugger.disable message in modern CDP backend (#42400)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42400

Changelog: [Internal]

TSIA - iOS counterpart of D52040149 on Android.

The overarching principle is that nothing outside of an Agent should be doing anything with the CDP message stream. Here we have a case of `RCTInspectorDevServerHelper` basically impersonating the CDP frontend in order to paper over an apparent lifetime management bug in the old backend; this gets in the way of implementing reloads natively so we disable it under the new backend.

NOTE: I'm gating out both the call site in `RCTBridge` (to signal intent) *and* the actual body of `disableDebugger` (in case any out-of-tree code happens to be using this method).

Reviewed By: voideanvalue

Differential Revision: D50967799

fbshipit-source-id: 759718bf155b8b16c7db54ac2d2507bc71c93436
2024-01-22 10:09:17 -08:00
Rubén NorteandFacebook GitHub Bot 26e33a5f17 Back out "Revert D52919566: [RN] Move codegen root directory from Libraries to src"
Summary:
Changelog: [internal]

bypass-github-export-checks

Reviewed By: huntie

Differential Revision: D52958335

fbshipit-source-id: 24403cdae650fdd4ec0c739b912f69bd6cd5aaad
2024-01-22 09:47:08 -08:00
Rubén NorteandFacebook GitHub Bot 123fd9a535 Back out "Revert D52875998: [RN] Move DOM APIs to private directory"
Summary:
Changelog: [internal]

bypass-github-export-checks

Reviewed By: EdmondChuiHW

Differential Revision: D52958336

fbshipit-source-id: 61843a07e249784914f632932011ee18d106223c
2024-01-22 09:47:08 -08:00
Rubén NorteandFacebook GitHub Bot 3b97a624b6 Back out "Revert D52875999: [RN] Add support for src directory in react-native"
Summary:
Changelog: [internal]

bypass-github-export-checks

Reviewed By: EdmondChuiHW

Differential Revision: D52958337

fbshipit-source-id: 8375006f2e4b7b2c0dfa5bcb91de3d526d9add8b
2024-01-22 09:47:08 -08:00
Krzysztof MagieraandFacebook GitHub Bot d16531e8a4 Remove Content-Length header from proxy inspector response (#42590)
Summary:
This change removes Content-Length header from proxy inspector response.

The presence of this header was resulting in the response being cropped under some circumstances because of erroneously calculated length.

The `Content-Length` header value represents the number of bytes in the response. In the code, `string.length` was used to calculate that value, but in JavaScript it gives the number of characters in a string instead of its size in bytes. Specifically, if there are some UTF characters in the string that occupy more than byte, there would be a mismatch in this size. This mismatch resulted in the response being cropped.

The easiest way to reproduce this problem is to set the simulator name to contain a two-byte UTF character.

This change works according to the HTTP spec, which states that when Content-Length is not present, the end of the response stream indicates the end of the response. Since in the code `response.end(data)` is use, it terminates the stream and hence there is no need to provide the length in the header.

## Changelog:

[GENERAL] [FIXED] - fix issue with debugger not working when device name contain two-byte UTF characters

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

Test Plan:
1. Change your iOS simulator name to contain some two-byte UTF character (for example this one: "–")
2. Run metro and connect your app with it
3. Go to http://localhost:8081/json/list in your browser – see the response being marked invalid as it is cropped
4. Apply the change and see that the resulting JSON in the response is now correct
5. Open debugger workflow to confirm it sees the connected device

Reviewed By: robhogan

Differential Revision: D52958725

Pulled By: motiz88

fbshipit-source-id: 92c32893cbbf8552237585d824e4a44737fa3968
2024-01-22 09:26:44 -08:00
Pieter De BaetsandFacebook GitHub Bot 94c72d5916 Use RCTModernEventEmitter in EventAnimationDriver (#42388)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42388

This was our last call site still using the legacy `dispatch` API.

Changelog: [Internal]

Reviewed By: cortinico

Differential Revision: D52906894

fbshipit-source-id: b1c838ee695ce4c60aaed409e7dc46a0dd3f6c2e
2024-01-22 08:20:54 -08:00
Saad NajmiandFacebook GitHub Bot 6d77d7b895 Format package.json files in the monorepo (#42256)
Summary:
Over in React Native macOS land, I opened https://github.com/microsoft/react-native-macos/pull/2030 to update our mono repo to use Yarn 4. As a side effect, all the `package.json` files are formatted as a side effect of running `yarn install`. So that React Native macOS doesn't maintain this diff (and because they should only be good / no harm), let's upstream the formatting changes.

## Changelog:

[INTERNAL] [CHANGED] - Format package.json files in the monorepo

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

Test Plan: This change should be a no-op, CI should pass.

Reviewed By: cortinico

Differential Revision: D52727623

Pulled By: huntie

fbshipit-source-id: 67862b16d576b0903abd91e016d7add4c19853dc
2024-01-22 07:15:05 -08:00
Himanshi GoyalandFacebook GitHub Bot c92f7e5cc7 Revert D52875999: Add support for src directory in react-native
Differential Revision:
D52875999

Original commit changeset: 914ed806f2cb

Original Phabricator Diff: D52875999

fbshipit-source-id: 09c736fcc0187b09f7f05443ddb222326ffdd9e7
2024-01-22 06:53:20 -08:00
Himanshi GoyalandFacebook GitHub Bot 7475e2b712 Revert D52875998: Move DOM APIs to private directory
Differential Revision:
D52875998

Original commit changeset: c6c96eedcc54

Original Phabricator Diff: D52875998

fbshipit-source-id: 75d6c656551cd22f817058263207da47dc89228b
2024-01-22 06:53:20 -08:00
Himanshi GoyalandFacebook GitHub Bot 692f7275bc Revert D52919566: Move codegen root directory from Libraries to src
Differential Revision:
D52919566

Original commit changeset: 6de8a2d2b607

Original Phabricator Diff: D52919566

fbshipit-source-id: dc25ec0072b436c2b61bc36bd70c8ea12ab2b5c0
2024-01-22 06:53:20 -08:00
LIM AlbertandFacebook GitHub Bot 96ed1190c6 Call super.onRequestPermissionsResult in ReactActivity (#42478)
Summary:
This change allows activities to handle onRequestPermissionsResult callbacks (eg: registerForActivityResult)

Fixes #42403

## Changelog:

[Android][Changed] - Call super.onRequestPermissionsResult in ReactActivity's onRequestPermissionsResult()

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

Test Plan:
**Without super.onRequestPermissionsResult() call**

![before](https://github.com/facebook/react-native/assets/8672580/553ff597-c077-4831-a4d3-51846a253536)

**With super.onRequestPermissionsResult() call**

![after](https://github.com/facebook/react-native/assets/8672580/c7d588d2-5846-4083-a02f-59b5f915442c)

Reviewed By: cipolleschi

Differential Revision: D52952198

Pulled By: cortinico

fbshipit-source-id: 53b5dac65f6b5409d87b5fe7f8be659d7b48f70d
2024-01-22 05:19:28 -08:00
Moti ZilbermanandFacebook GitHub Bot 9003d08839 Register RCTBridge with modern CDP backend (#42394)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/42394

Changelog: [Internal][iOS] - Enable stub modern CDP backend in Bridge behind a feature flag

Minimally integrates the stub native CDP backend implementation (D50936932) into iOS Bridge.

This integration registers itself as a "Modern" target (D50967794, D50967795) to instruct `inspector-proxy` to disable its CDP hacks related to source map fetching, reloads, etc. This gives us a mostly-clean slate on which to develop and test native CDP functionality.

Reviewed By: huntie

Differential Revision: D50951138

fbshipit-source-id: 8c5ad9207e73265595884380c91e38f8d0ead84d
2024-01-22 05:00:01 -08:00