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

29202 Коммитов

Автор SHA1 Сообщение Дата
Phillip Pan 9f52378cc1 deprecate hasConstants from ReactModuleInfo (#39459)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39459

## Changelog
[Android][Deprecated] - ReactModuleInfo constructor with getConstants arg is deprecated

introducing a new constructor that doesn't use getConstants and updating the internal codebase to use it. deprecated the old one since it's been copypasta'd a lot in oss.

Reviewed By: cortinico

Differential Revision: D49262824

fbshipit-source-id: 1a4d36b3153d8ce0ee869b8635c94005fe7c9594
2023-09-16 01:35:01 -07:00
David Vacca 49197411d8 Create FeatureFlag to gate Stable API for Turbo Module (#39479)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39479

The goal of this diff is to create a feature flag that will be used to enable/disable Stable API for Turbo Module.
This featureflag will be used to experiment with the new API in fb4a

changelog: [intenral] internal

Reviewed By: arushikesarwani94

Differential Revision: D49212022

fbshipit-source-id: 4f4830f11ba18ad849dc8b35f4e178e938b03fc9
2023-09-15 17:37:58 -07:00
Phillip Pan 2be409ff55 hot fix for incorrect url parsing
Summary:
in this diff, we backout D49335986 to fix the issue where we are losing context from decoding an encoded string all at once via `NSURL URLWithString....`. this fixes the category of issues in https://fb.workplace.com/groups/rn.support/posts/25183724564582821.

however, this will regress the original issue that this fixed (https://fb.workplace.com/groups/rn.support/posts/25129344753354136), where encoding square brackets in the URI is causing percents to be re-encoded, resulting in a mixed uri with mixed encoding, i.e. `%2522%5B%5D`. we will be fixing this by not serving decoding brackets in our php serializer which was originally be the follow-up fix, since that does not respect the RFC.

bypass-github-export-checks

Reviewed By: fkgozali

Differential Revision: D49336101

fbshipit-source-id: 2012390b237de8a16a5e60e880905cec48584873
2023-09-15 14:53:26 -07:00
Alex Hunt 850e550422 Add serverBaseUrl option, set client-accessible URL value externally (#39456)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39456

**Fixes new debugger launch flow on Android:**

D49158227 aimed to improve proxy-safe behaviour for remote dev servers by auto-detecting the appropriate server URL for clients using the `Host` header (etc) from the HTTP request. However, this approach broke the local case for Android emulators and externally connected devices since they would originate from a device-relative server hostname — e.g. `10.0.2.2` for the stock Android emulator.

https://pxl.cl/3mVmR

This commit reverts to an explicit approach where callers specify the base URL to the dev server that should be addressible from the development machine — now as a single `serverBaseUrl` option.

**Changes**

- Adds new `serverBaseUrl` option to `createDevMiddleware`, designed to be the base URL value for constructing dev server URLs returned in endpoints such as `/json/list`.
    - This changes little for the `localhost` case (now enabling `https://` URLs), but enables remote dev server setups to specify this cleanly.
- Updates call site in `community-cli-plugin`.

Changelog: [Internal]

Reviewed By: robhogan

Differential Revision: D49276125

fbshipit-source-id: 2b6a8507073649832993971aa9d0870f54c9bd44
2023-09-15 13:11:04 -07:00
Sunbreak fd32931f95 Clean header-only SchedulerToolbox (#39455)
Summary:
Clean header-only `SchedulerToolbox.cpp`

## Changelog:

[INTERNAL] [REMOVED] - Clean header-only SchedulerToolbox

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

Test Plan: Compile success

Reviewed By: NickGerleman

Differential Revision: D49289800

Pulled By: arushikesarwani94

fbshipit-source-id: c177ab982e69a41126ab24c244b7f125e6a3d2bb
2023-09-15 11:12:09 -07:00
Arushi Kesarwani 8d2af4978a Adding UIManagerProvider interface (#39432)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39432

For the removal of JSI Module adding the `UIManagerProvider` interface as this will replace the `JSIModuleProvider`

Adding the `Deprecated` annotation since this would be deprecated later as part of Stable APIs with bridge removal and not encouraged usage.

Changelog:
[Internal] internal

Reviewed By: cortinico

Differential Revision: D49257901

fbshipit-source-id: 176ae03368309b56f7a7608419f1776baf4b512a
2023-09-15 10:28:04 -07:00
Samuel Susla 1ac7e92e53 Fix RawProps folly::dynamic ctor to give option to avoid copy (#39473)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39473

changelog: [internal]

avoid copy of folly::dynamic if possible.

Reviewed By: javache

Differential Revision: D49312487

fbshipit-source-id: cd7b1e9b5a6376168d472c311637fa1b076d61e3
2023-09-15 09:35:02 -07:00
Nicola Corti 1ff2dd29b4 Fix typo inside DefaultNewArchitectureEntryPoint (#39477)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39477

There is a typo inside `DefaultNewArchitectureEntryPoint` that we want to fix before this becomes part of the public API.

Changelog:
[Internal] [Changed] - Fix typo inside DefaultNewArchitectureEntryPoint

Reviewed By: sammy-SC, cipolleschi

Differential Revision: D49320026

fbshipit-source-id: 8cf4d2027860b8d2fafd2b8abc51e68392e6343e
2023-09-15 08:56:01 -07:00
Nate Stedman 88395bb17d Update ktfmt component on FBS:master
Reviewed By: hick209

Differential Revision: D49300079

fbshipit-source-id: 7e704e2366feee3f6f2c25ac25d3daea407e71f9
2023-09-15 07:19:43 -07:00
Juliovaz d208dc422c Update description about jsBundleURLForBundleRoot method (#39265)
Summary:
Update comment in RCTBundleURLProvider.h to use correct `jsBundleURLForBundleRoot` import with `fallbackExtension` instead `fallbackResource`

## Changelog:

- Update comment in `jsBundleURLForBundleRoot` definition on RCTBundleURLProvider.h file.

Pick one each for the category and type tags:

[IOS][CHANGED] - Updated comment in RCTBundleURLProvider.h to instance correct jsBundleURLForBundleRoot:fallbackExtension method.

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

Test Plan: N/A

Reviewed By: cortinico

Differential Revision: D49227104

Pulled By: GijsWeterings

fbshipit-source-id: 6ccfb984ab6c1e858f1c568b2dd8f4626e133ffb
2023-09-15 03:57:28 -07:00
Nick Gerleman a931867286 Fix formatting in folly_flags.cmake and template pbxproj (#39465)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39465

Separate a definition onto a separate line.

Changelog: [Internal]

Reviewed By: cortinico

Differential Revision: D49309462

fbshipit-source-id: 98726dfb3d2c79faca0fac758164186eb4c651b5
2023-09-15 03:43:04 -07:00
Nick Gerleman 5ea0b449e2 Fix podspecs building with C++ 14 (#39464)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39464

We currently have 854 warnings emitted due to nested namespaces being a C++ 17 extension lol.

This sets the standard explicitly to C++ 20 in the specs emitting the warnings (mostly RCT-Text).

It is undesirable that we add hundreds of warnings to the CocoaPods build without signal. Our Buck build and OSS Android build both treat warnings as errors. But... that is for another day.

Changelog: [Intenrnal]

Reviewed By: cortinico

Differential Revision: D49303081

fbshipit-source-id: 1233e9d51426fb8dbd8ca39a771e2fef3d0df856
2023-09-15 02:47:07 -07:00
Adam Averay 9ca16605e0 Feature: Improvements to `automaticallyAdjustKeyboardInsets` (#37766)
Summary:
This is a reopened version of https://github.com/facebook/react-native/issues/35224 by isidoro98 which was closed without explanation, updated to resolve new merge conflicts and now includes an example in the RN-Tester app. Aside from that it is unchanged. Here is isidoro98's description from their original PR:

This PR builds on top of https://github.com/facebook/react-native/issues/31402, which introduced the `automaticallyAdjustsScrollIndicatorInsets` functionality. It aims to fix one of RN's longstanding pain point regarding the keyboard.

The changes provide a better way of handling the `ScrollView` offset when a keyboard opens. Currently, when a keyboard opens we apply an **offset** to the `Scrollview` that matches the size of the keyboard. This approach is great if we are using an `InputAccessoryView` but if we have multiple `TextInputs` in a `ScrollView`; offsetting the content by the size of the keyboard doesn't yield the best user experience.

## Changelog:

[iOS] [Changed] - Scroll `ScrollView` text fields into view with `automaticallyAdjustsScrollIndicatorInsets`

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

Test Plan:
The videos below compare the current and proposed behaviors for the following code:

```js
<ScrollView
  automaticallyAdjustKeyboardInsets
  keyboardDismissMode="interactive">
  {[...Array(10).keys()].map(item => (
    <CustomTextInput placeholder={item.toString()} key={item} />
  ))}
</ScrollView>
```

| Current behaviour | Proposal |
|-|-|
| ![https://user-images.githubusercontent.com/25139053/200194972-1ac5f1cd-2d61-4118-ad77-95c04d30c98d.mov](https://user-images.githubusercontent.com/25139053/200194972-1ac5f1cd-2d61-4118-ad77-95c04d30c98d.mov) | ![https://user-images.githubusercontent.com/25139053/200194990-53f28296-be11-4a47-be70-cec917d7deb1.mov](https://user-images.githubusercontent.com/25139053/200194990-53f28296-be11-4a47-be70-cec917d7deb1.mov) |

As can be seen in the video, the **current behavior** applies an offset to the `ScrollView` content regardless of where the `TextInput` sits on the screen.

The proposal checks if the `TextInput` will be covered by the keyboard, and only then applies an offset. The offset applied is not the full size of the keyboard but instead only the required amount so that the `TextInput` is a **specific** distance above the top of the keyboard (customizable using the new `bottomKeyboardOffset` prop). This achieves a less "jumpy" experience for the user.

The proposal doesn't change the behavior of the `ScrollView` offset when an `InputAccessory` view is used, since it checks if the `TextField` that triggered the keyboard is a **descendant** of the `ScrollView` or not.

## Why not use other existing solutions?

RN ecosystem offers other alternatives for dealing with a keyboard inside a ScrollView, such as a `KeyboardAvoidingView` or using third party libraries like `react-native-keyboard-aware-scroll-view`. But as shown in the recordings below, these solutions don't provide the smoothness or behavior that can be achieved with `automaticallyAdjustsScrollIndicatorInsets`.

| KeyboardAvoidingView | rn-keyboard-aware-scroll-view |
|-|-|
| ![https://user-images.githubusercontent.com/25139053/200195145-de742f0a-6913-4099-83c4-7693448a8933.mov](https://user-images.githubusercontent.com/25139053/200195145-de742f0a-6913-4099-83c4-7693448a8933.mov) | ![https://user-images.githubusercontent.com/25139053/200195151-80745533-16b5-4aa0-b6cd-d01041dbd001.mov](https://user-images.githubusercontent.com/25139053/200195151-80745533-16b5-4aa0-b6cd-d01041dbd001.mov) |

As shown in the videos, the `TextInput` is hidden by the keyboard for a split second before becoming visible.

Code for the videos above:

```js
// KeyboardAvoidingView
<KeyboardAvoidingView
  style={{flex: 1, flexDirection: 'column', justifyContent: 'center'}}
  behavior="padding"
  enabled>
  <ScrollView>
    {[...Array(10).keys()].map(item => (
      <CustomTextInput placeholder={item.toString()} key={item} />
    ))}
  </ScrollView>
</KeyboardAvoidingView>
```

 ```js
// rn-keyboard-aware-scroll-view
<KeyboardAwareScrollView>
  {[...Array(10).keys()].map(item => (
    <CustomTextInput placeholder={item.toString()} key={item} />
  ))}
</KeyboardAwareScrollView>
```

Reviewed By: sammy-SC

Differential Revision: D49269426

Pulled By: javache

fbshipit-source-id: 6ec2e7b45f6854dd34b9dbb06ab77053b6419733
2023-09-15 02:34:40 -07:00
Nick Gerleman 17154a661f C++ 20 all the things (#39454)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39454

1. Build with C++ 20 everywhere.
2. Update folly in OSS build to avoid a warning, and let us opt out of heavy bits required for supporting coroutines (we are still more than a year behind).
3. Update the folly podspec for the new version of folly
4. Update the many, many, copy/pasted header search paths for folly dependencies to be able to resolve fmt, now exposed to folly headers
4. Replaces a deprecated atomic usage with equivalent.
5. Fixes a deprecated implicit capturing `this` by value in lambda (same behavior, added a TODO because it seems sus)

Changelog: [Internal]

Reviewed By: sammy-SC

Differential Revision: D49271685

fbshipit-source-id: 16610f7bcd1032d5796cc11f1cfa92a33d8c2593
2023-09-15 01:17:55 -07:00
David Vacca e513a50fe1 Introducing LazyTurboModuleManagerDelegate (#39462)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39462

In this diff I'm introdcuing the new UnstableAPI called LazyTurboModuleManagerDelegate.
The goal of this class is to provide a Lazy registration of TurboModules without relying on ReactModule annotations neither the TurboReactPackage#getReactModuleInfoProvider method.

This is not the final implementation, it's just a prototype that will be used to experiment and learn about perf implications.

This class will be used in the next diffs of the stack

changelog: [intenral] internal

Reviewed By: cortinico

Differential Revision: D49172555

fbshipit-source-id: 1609c523e6e72f2aa42ca7cc35e9170104a101db
2023-09-14 23:45:17 -07:00
David Vacca 040d13960f Create empty constructor on ReactPackageTurboModuleManagerDelegate (#39461)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39461

In this diff I'm creating an empty constructor on ReactPackageTurboModuleManagerDelegate. This will be used in the next diffs of the stack.
I'm also resorting methods for better read of the class

changelog: [intenral] internal

Reviewed By: arushikesarwani94

Differential Revision: D49172554

fbshipit-source-id: 54073c86c87aa145b12e783d8d8f75cd1f5b228c
2023-09-14 23:45:17 -07:00
David Vacca 0c8cb00e97 Fix lint warning (#39463)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39463

Fix lint warning

changelog: [intenral] internal

Reviewed By: rshest

Differential Revision: D49172556

fbshipit-source-id: 9e9543d3f9a507258f1c9466782234a3334cef75
2023-09-14 23:45:17 -07:00
Nick Gerleman 3b27c3992a C++ style enums 7/N: MeasureMode (#39452)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39452

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

This converts usages of YGMeasureMode to MeasureMode

Reviewed By: rozele

Differential Revision: D49271165

fbshipit-source-id: 273c9ed0a61c3965e469548d29d37e4566c974dc
2023-09-14 23:06:34 -07:00
Nick Gerleman 094046c78e C++ style enums 6/N: PrintOptions (#39449)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39449

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

This converts usages of YGPrintOptions to PrintOptions

Reviewed By: rozele

Differential Revision: D49270929

fbshipit-source-id: ad98dd25865138808d25b48eff22fbe81ccdd352
2023-09-14 23:06:34 -07:00
Nick Gerleman 2681b0e2b4 C++ style enums 5/N: LogLevel (#39447)
Summary:
X-link: https://github.com/facebook/yoga/pull/1387

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

This converts usages of YGLogLevel to LogLevel

Reviewed By: rozele

Differential Revision: D49270695

fbshipit-source-id: 2ba5b4f2b0af93fef89dbbb2ce54c2f486670aac
2023-09-14 23:06:34 -07:00
Nick Gerleman c64c26c3b3 C++ style enums 4/N: Errata (#39451)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39451

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

This converts usages of YGErrata to Errata

Reviewed By: rozele

Differential Revision: D49270354

fbshipit-source-id: 39c0d26a1609cca0a96da843796ab41c81e3af93
2023-09-14 23:06:34 -07:00
Nick Gerleman 073f5dfe8e C++ style enums 3/N: ExperimentalFeature (#39448)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39448

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

This converts usages of YGExperimentalFeature to ExperimentalFeature

Reviewed By: rozele

Differential Revision: D49269440

fbshipit-source-id: 0fcb4f380e214a6aadcac457df5a989789bb05d2
2023-09-14 23:06:34 -07:00
Nick Gerleman 850c93ae6c C++ style enums 2/N: NodeType (#39450)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39450

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

This converts usages of YGNodeType to NodeType

Reviewed By: rozele

Differential Revision: D49269117

fbshipit-source-id: 27318279fe555c28c605625a160d5be781b662b8
2023-09-14 23:06:34 -07:00
Nick Gerleman 14bbbdcecc C++ style enums 1/N: Generator (#39446)
Summary:
X-link: https://github.com/facebook/yoga/pull/1384

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

This adds logic to the enum generator to generate C++ style scoped enums.

This gives us a few nicities over C enums, even if both must exist:
1. We can add types and keep unsgined enums directly in bitfields
2. Style/readability
3. Avoiding implicit int conversion

Reviewed By: rozele

Differential Revision: D49267996

fbshipit-source-id: 1c41164c377b317c1fef97811c46cbc00b5a837e
2023-09-14 23:06:34 -07:00
Nick Gerleman 598b7ed690 Fixup hack for flex line size calculation (#39433)
Summary:
X-link: https://github.com/facebook/yoga/pull/1380

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

Back when rolling out flex gap, we encountered a bug where gap was added to the end of the main axis when a size was not specified.

During flex line justification/sizing, we calculate the amount of space that should be in between children. We erroneously add this, even after the last child element.

For `justify-content`, this space between children is derived from free space along the axis. The only time we have free space is if we had a dimension/dimension constraint already set on the parent. In this case, the extra space added to the end of the flex line is usually never noticed, because we bound `maxLineMainDim` to container dimension constraints at the end of layout, and the error doesn't effect how any children are positioned or sized.

There was at least one screenshot test where this issue showed up though, and I was able to add a slightly different repro where we may have free space without a definite dimension by enforcing a min dimension and not stretching.

{F1091401183}

The new reference is correct, and looking back at diffs, is what this seemed to originally look like when added three years ago. Seems like there may have been a potential regression, but I didn't spot anything suspicious when I looked around the code history.

`betweenMainDim` may still be set for `gap` even if we don't have a sized parent, which makes the extra space propagated to `maxLineMainDim` effect parent size.

Because we were in a code freeze, I opted to have us go with a solution just effecting flex gap, instead of the right one, in case there were any side effects. This cleans up the code to use the right calculation everywhere, and fixes a separate bug, where `endOfLineIndex` and `startOfLineIndex` may not be the last/first in the line if they are out of the layout flow (absolutely positioned, or display: none_

See the original conversation on https://github.com/facebook/yoga/pull/1188

Reviewed By: javache

Differential Revision: D49260049

fbshipit-source-id: 218552c5ff938668b9f257df7a1493e13ded4d0d
2023-09-14 20:26:31 -07:00
Phillip Pan 196d9f9520 deprecate mHasConstants in ReactModuleInfo (#39458)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39458

## Changelog
[Android][Deprecated] - hasConstants in ReactModuleInfo is marked as deprecated

getting rid of `mHasConstants` ivar here and marking the getter as deprecated

Reviewed By: cortinico

Differential Revision: D49262577

fbshipit-source-id: 5394281bdc4a315ffc0d1debfaef1808dc6f4299
2023-09-14 17:34:19 -07:00
Phillip Pan 691bd0f9fb remove rarely used bridge module optimization (#39457)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39457

## Changelog
[Android][General] - hasConstants in ReactModuleInfo does nothing now

we can get rid of this. currently, the default value of hasConstants true, and the only library setting this value to false is `WebSocketModule`. this value is only read in bridge mode - it is an optimization that will not initialize the constants dictionary for native modules in bridge.

however, we have plenty of native modules that don't provide constants that have not set this flag, so this is only turned on for `WebSocketModule`, which is probably not moving anything significant.

i would recommend we get rid of this to simplify the ReactModuleInfo deprecation plan.

Reviewed By: cortinico

Differential Revision: D49210251

fbshipit-source-id: c82c997e01cd8012b2c1a5c3c36061f81799eb04
2023-09-14 17:34:19 -07:00
Zeya Peng 88e19c0ce6 filter yoga props 2/x - filter out yoga props at creation of YogaStylableProps (#39431)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39431

Changelog: [Android][Breaking] - Do not enable `excludeYogaFromRawProps` feature flag, if you need to pass layout props to Java view managers when using new architecture
[Internal]

Reviewed By: NickGerleman

Differential Revision: D49114771

fbshipit-source-id: 171dfceef61d9851094465be8ff4eb9a87a3ab8f
2023-09-14 15:06:03 -07:00
Zeya Peng 7dbb52ae8f filter yoga props 1/x - add feature flag excludeYogaFromRawProps (#39430)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39430

Changelog: [Internal]

Reviewed By: javache

Differential Revision: D49162188

fbshipit-source-id: ec9dbd3561ceb3d142b78475a41368f598003c32
2023-09-14 15:06:03 -07:00
David Vacca 4b6fd81452 Use lambdas to return reactModuleInfoMap (#39341)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39341

Use lambdas to return reactModuleInfoMap

changelog: [intenral] internal

Reviewed By: christophpurrer

Differential Revision: D49077067

fbshipit-source-id: edd2e044cb258a7bc1597ece38836fc447758694
2023-09-14 11:13:16 -07:00
David Vacca eba05a557b Reduce visibility of TurboModulePerfLogger to pacakge (#39340)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39340

Reduce visibility of TurboModulePerfLogger to pacakge and remove some lint warns

changelog: [intenral] internal

Reviewed By: christophpurrer

Differential Revision: D49077068

fbshipit-source-id: 9fe3c65f72003b09ca412e0aa37bf132cf3daee2
2023-09-14 11:13:16 -07:00
David Vacca 46a524faa3 Reduce visibility of TurboModuleInteropUtils (#39352)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39352

Reduce visibility of TurboModuleInteropUtils to package only

changelog: [intenral] internal

Reviewed By: cortinico

Differential Revision: D49077066

fbshipit-source-id: b462e42e323f65aabde6206fa403b2faef491490
2023-09-14 11:13:16 -07:00
David Vacca a629ac4206 Annotate HybridData with DoNotStrip (#39342)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39342

Annotate HybridData with DoNotStrip

The stack of diffs aims to introduce new features and deprecate old ones in the React Native Android architecture. The main goal is to make the architecture more stable and easier to use for developers. The changes include marking ReactPackage as NullSafe, introducing the new getModule method, introducing the WillBeDeprecatedInNewArchitecture annotation, deprecating createNativeModules and marking getModule as UnstableReactNativeAPI, and fixing a lint warning in MainReactPackage.

# This diff
This diff is adding the annotation `DoNotStrip` to the `HybridData` field in the `NativeMethodCallInvokerHolderImpl` and `CallInvokerHolderImpl` classes. This is to prevent the Android ProGuard optimizer from stripping the `HybridData` field, which is necessary for the proper functioning of the TurboModule system in React Native. Additionally, the `BUCK` file for the `core` module is updated to include the `androidx:annotation` and `com.facebook.proguard.annotations:annotations` dependencies.

changelog: [intenral] internal# Context

Reviewed By: cortinico

Differential Revision: D49077065

fbshipit-source-id: cb36c0a11bdb8f5f0f4eaa7db1f0c9dcb3be2341
2023-09-14 11:13:16 -07:00
David Vacca fdae17daf9 Fix lint warning (#39338)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39338

Fix lint warning in MainReactPackage, as reactModule could be null

changelog: [internal] internal

Reviewed By: cortinico

Differential Revision: D49077064

fbshipit-source-id: 34e04cac1a8875af94bbb78119a323c6319b6d6b
2023-09-14 11:13:16 -07:00
David Vacca ab806bd60e Mark ReactPackage.getModule as UnstableReactNativeAPI (#39337)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39337

Mark ReactPackage.getModule as UnstableReactNativeAPI

changelog: [internal] internal

Reviewed By: arushikesarwani94

Differential Revision: D49068233

fbshipit-source-id: 56be5c08eaa5b33c069e540ba452dba30111a64f
2023-09-14 11:13:16 -07:00
David Vacca 33181ef8af Deprecate ReactPackage.createNativeModules recommending using getModule instead (#39339)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39339

Deprecating createNativeModules method from ReactPackage interface recommending using getModule instead in the new architecture of React Native

changelog: [Android][Changed] Deprecating createNativeModules method from ReactPackage interface recommending using getModule instead in the new architecture of React Native

Reviewed By: cortinico

Differential Revision: D48992719

fbshipit-source-id: b20de9274ed4bd35a239c672b52bfac529a79bc2
2023-09-14 11:13:16 -07:00
David Vacca 4fd44cdc11 Introduce WillBeDeprecatedInNewArchitecture annotation (#39351)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39351

In this diff I'm introducing the new WillBeDeprecatedInNewArchitecture annotation, the goal of this annotation is to describe that a class or method will be deprecated when the new architecture of react native is fully rolled out in
OSS.

changelog: [Android] Introduce WillBeDeprecatedInNewArchitecture annotation

Reviewed By: cortinico

Differential Revision: D49068234

fbshipit-source-id: 4c5ce25b3fbcc2d7545f2000d931be893a661332
2023-09-14 11:13:16 -07:00
David Vacca da8616ec69 Add ReactPackage.getModule method (#39336)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39336

We are introducing the new getModule method into the ReactPackage interface following the "Registration of Native Modules" design

This method defaults to true with the goal to avoid compatibility breakage

changelog: [Android][Changed] Introducing getModule method into ReactPackage interface, defaulting to null. This method will be used in the Stable API of React Native

Reviewed By: cortinico

Differential Revision: D48992720

fbshipit-source-id: 4ecc93bc84daa8903a4d9a1cf6ced60adb78f153
2023-09-14 11:13:16 -07:00
David Vacca a6708247e1 Mark ReactPackage as NullSafe (#39316)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39316

Marking ReactPackage as NullSafe as it has proper annotations

changelog: [internal] internal

Reviewed By: NickGerleman

Differential Revision: D48992474

fbshipit-source-id: 850cf260298a0fa71a864731c78444ff01a85d94
2023-09-14 11:13:16 -07:00
Samuel Susla b5d69af3f0 Wire up mobile config for cloneless state progression feature flag (#39428)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39428

changelog: [internal]

bypass-github-export-checks

Reviewed By: rozele, rshest

Differential Revision: D49234105

fbshipit-source-id: e0c9376e57de010b95dd023d60609b6b052843aa
2023-09-14 09:42:04 -07:00
Dmitry Rykun 59e6b11fbc Add @react-native/babel-plugin-codegen to the preset if src is null (#39159)
Summary:
X-link: https://github.com/facebook/metro/pull/1078

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

Source is not required for `getPreset` of `react-native/babel-preset`. There is a codition that adds `react-native/babel-plugin-codegen` to the preset only if source is passing certain regex. This condition fails if source is null, but that's wrong because the plugin may still be requred for this transformation even though source is not provided.
This diff changes the condition so the regexp tests source only if it is not null, and `react-native/babel-plugin-codegen` automatically added to the preset otherwise.
Changelog: [Internal]

Reviewed By: robhogan

Differential Revision: D48684443

fbshipit-source-id: 7cea69c91c0175ac0374d72e91f58e20fe75fd53
2023-09-14 08:25:40 -07:00
Samuel Susla 5bafef6622 Delete CoreFeatures::enableMapBuffer (#39407)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39407

changelog: [internal]

CoreFeatures::enableMapBuffer is not used and always set to false, let's delete it.

Reviewed By: christophpurrer

Differential Revision: D49144919

fbshipit-source-id: 7d6a2a96ade13f7cedc2d12f7672c9df9d247e0d
2023-09-14 07:16:26 -07:00
Moti Zilberman 6038598302 Experimentally support GET requests in /open-debugger (#39418)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39418

Changelog: [Internal]

Adds the `enableOpenDebuggerRedirect` experiment flag. The flag enables the handling of GET requests in the `/open-debugger` endpoint, in addition to POST requests. GET requests respond by redirecting to the debugger frontend, instead of opening it using the `BrowserLauncher` interface.

This can be useful when integrating `dev-middleware` in highly customised environments (e.g. VS Code remoting) where things like automatic port forwarding interact poorly with the `BrowserLauncher` abstraction.

WARNING: As this is gated by an experiment flag, the functionality may change or go away unannounced. In separate work, we will look into a stable solution for this use case.

Reviewed By: huntie

Differential Revision: D49144733

fbshipit-source-id: 5af6c8b2ddaa7b6e7d14c792e49fe3d0849c7a25
2023-09-14 06:08:57 -07:00
Moti Zilberman b8e42ea7b4 Build client-accessible frontend URLs in /open-debugger (#39423)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39423

D49158227 made the CDP WebSocket URLs returned from `/json` proxy-safe by using the Host header (etc) from the HTTP request. This did *not* fully fix the related `/open-debugger` endpoint, because the original headers were being lost in the internal `fetch('/json')` call.

Here, we eliminate that `fetch` call, and instead give the `/open-debugger` handler direct access to the method on `InspectorProxy` that backs the `/json` endpoint. This allows us to pass in an appropriate base URL derived from the headers seen by `/open-debugger`.

Changelog: [Internal]

Reviewed By: huntie

Differential Revision: D49229545

fbshipit-source-id: 9036ab295721e0d1fd3cdb608d0a7cc07b8f2eeb
2023-09-14 06:08:57 -07:00
Pieter De Baets 318b4c0d4b Fix thread-safety of enableFabricPendingEventQueue experiment (#39424)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39424

Make this struct-like class private, and fix incorrect threading access to `mPendingEventQueue`.

Changelog: [Android][Fixed] Improve threading in enableFabricPendingEventQueue experiment

Reviewed By: rshest

Differential Revision: D44667266

fbshipit-source-id: abf6b9b4ce01f23ac406cd29a2e40544d9b6464c
2023-09-14 05:47:10 -07:00
szymonrybczak 9d52767c01 fix(e2e): add versions when installing appium drivers (#39275)
Summary:
Right now we're fetching latests versions of drivers which isn't the best, we should always download the same versions.

## 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] - Add versions when installing Appium drivers.

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

Test Plan: CI Green - (side note: if jobs `test_e2e_ios` and `test_e2e_android` are green it doesn't mean that they passed.)

Reviewed By: cipolleschi

Differential Revision: D49248778

Pulled By: NickGerleman

fbshipit-source-id: 5b114b7dc1172993afc4b02e9d3380afa9f03c40
2023-09-14 05:21:09 -07:00
Alex Hunt 3e7a873f2d Migrate from legacy to new Hermes CDP handler (#39367)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39367

Updates React Native to use the new CDP handler provided by the Hermes engine instead of the legacy one (`Connection.cpp`) built into React Native. The new Hermes CDP handler has a simpler & safer design, new features (e.g. `console.log` buffering) and is under active development by the Hermes team.

NOTE: Both the legacy and modern handlers are Hermes-specific. In future work, React Native will *wrap* the modern Hermes handler in an engine-agnostic CDP layer implementing additional functionality and managing the lifecycle of debugging sessions more correctly. This diff is the first step of this larger migration.

Changelog: [General][Changed] Use new Hermes CDP handler implementation for debugging

Reviewed By: cipolleschi

Differential Revision: D48783980

fbshipit-source-id: 4d2ca3fa04e96e92a38d82c90737cb660ba56655
2023-09-14 04:31:36 -07:00
Nicola Corti f2884a761b Make sure first Gradle Sync is downloading 3rd party deps (#39426)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39426

When opening the react-native repo in Android Studio the first time, users is missing 3rd party native dependencies,
which gets downloaded during the first build.

Here I'm hooking the Gradle sync step to the `preBuild` task that takes care of preparing the repo so that the whole build can succeeds (i.e. downloading and unzipping native deps, running codegen, preparing hermes/hermesc, etc.).

Changelog:
[Internal] [Changed] - Make sure first Gradle Sync is downloading 3rd party deps

Reviewed By: cipolleschi

Differential Revision: D49231058

fbshipit-source-id: 11a3d436550581f8a67a582f9fd325ad39486ddc
2023-09-14 04:22:52 -07:00
Rob Hogan cda1cf9349 Prevent Babel registration from transforming plugins with arbitrary config (#39429)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/39429

Using `require` after `const registerFn = require('babel/register')` but before `registerFn(config)` causes Babel to transform required code with the default configuration (ie, using a nearby `babel.config.js`, if available).

This was causing the Babel plugins loaded by `metro-babel-register` to be (unnecessarily) transformed according to `babel.config.js`, which actually fails if the plugins/presets referenced in `babel.config.js` themselves require transformation.

This ensures no code is loaded in between registering Babel as a side effect of requiring Babel register, and replacing that hook with something explicitly configured.

## React Native
Changelog: [Internal]

## Metro
```
* **[Fix]:** `metro-babel-register` prevent arbitrary transformation of Babel plugins during registration setup
```

Reviewed By: dmytrorykun

Differential Revision: D49238671

fbshipit-source-id: 52a55b1b5dbd127171558c056f16ab04e8fa8232
2023-09-14 03:57:11 -07:00
Nick Gerleman b29b393d0e Use fbsource clang-format config
Summary:
This mirrors the clang-format config used by fbsource to Yoga.

They are pretty similar, except for an annoying habit where Yoga's previous forced small functions in headers to be a a single line, so you would get a combination of multiline and single line functions next to each other which are hard to read. That is what motivated this change.

It also enforces header ordering (yay). I don't think we have any side-effect causing headers, so this should be safe.

Reviewed By: yungsters

Differential Revision: D49248994

fbshipit-source-id: 66998395e7c0158ff9d9fb1bee44e8401bdd8f21
2023-09-13 20:12:55 -07:00