Commit Graph

38536 Commits

Author SHA1 Message Date
Moti Zilberman 396475a26d Use RuntimeExecutor consistently throughout the modern CDP backend (#43332)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43332

Changelog: [Internal]

The Hermes debugger integrations in Bridge/Bridgeless have so far used `MessageQueueThread` directly to schedule work on the JS thread, instead of the Instance-managed executor.

This was always a smell, but is now actively unsafe since the modern CDP backend requires `JSExecutor` / `JSRuntime` to remain alive while work is ongoing on the JS thread. This is not guaranteed when using `MessageQueueThread` directly like we do now, but *is* guaranteed by the Instance-managed `RuntimeExecutor` (see reasoning in D54493456).

We already have access to that executor in `RuntimeTarget`, so here we ensure that it's the one used by the AgentDelegate too and eliminate the direct use of `MessageQueueThread`.

NOTE: It would have been, perhaps, nice to just house the executor inside `JSExecutor` / `JSRuntime` to begin with, instead of adding a parameter to `createAgentDelegate()`. This would require some broader refactoring which I'm choosing to avoid for now.

Reviewed By: huntie

Differential Revision: D54539429

fbshipit-source-id: 6a5ad1c56642d809f6193b230301fa268318bbce
2024-03-06 02:18:48 -08:00
Moti Zilberman 1caa0a9ea9 Refactor Hermes CDP integrations into HermesRuntimeTargetDelegate (#43326)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43326

Changelog: [Internal]

Extracts the common parts of `HermesJSRuntime` (Bridgeless) and `HermesExecutor` (Bridge) that pertain to integration with the modern CDP backend into a new `HermesRuntimeTargetDelegate` class. This also makes the `HermesRuntimeAgentDelegate` class fully private.

As a followup, we *might* want to change `JSRuntime` and `JSExecutor` so they don't *implement* `RuntimeTargetDelegate` but are required to expose a `RuntimeTargetDelegate& getRuntimeTargetDelegate()` method instead. That would remove some of the boilerplate required for our current "aggregation" approach.

Reviewed By: huntie

Differential Revision: D54537844

fbshipit-source-id: f8c51fda0dbf28add1daeb95c991a34670f6854f
2024-03-06 02:18:48 -08:00
Moti Zilberman 702aa25870 JsiIntegrationTest: Assert that optionals have values before dereferencing them
Summary:
Changelog: [Internal]

Use a gtest assertion to avoid running into an exception (which has worse diagnostics) when dereferencing an `optional` value that's expected to be non-empty.

bypass-github-export-checks

Reviewed By: huntie

Differential Revision: D54578843

fbshipit-source-id: e0269542f80045f02876bda06cb584b6c68e50cd
2024-03-06 02:12:50 -08:00
Alex Hunt b5117520fc Enforce sorting of feature flag definitions (#43329)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43329

Improve maintainability of this file, in particular reducing the probability of a merge conflict for new entries.

Changelog: [Internal]

Reviewed By: rubennorte

Differential Revision: D54539469

fbshipit-source-id: dc2fca42b4490d87c532b21043b0855d8d1a894d
2024-03-05 17:27:23 -08:00
Riccardo Cipolleschi 9aeb9f2f94 Allow the app to control the Activity Indicator in Bridgeless mode (#43195)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43195

Right now, the activity indicator is automatically hidden when the view is ready to be shown in bridgeless mode.
There is no way to prevent that the activity indicator is automatically removed.

In OSS, we have libraries (e.g.: `react-native-bootsplash`) that will allow the app to control when and how dismiss the splashscreen, but due to the current automatic behavior on Bridgeless, they stopped working.

***Note:** In the previous implementation, they were working because instead of using the `loadingView` property, they were adding the splashscreen view on top of the existing one. However, with the lazy behavior of the bridgeless mode, this is not working anymore because the RCTMountingManager [expect not to have any subview](https://www.internalfb.com/code/fbsource/[6962fa457dbc74ab3a760cf6090d9643c6748781]/xplat/js/react-native-github/packages/react-native/React/Fabric/Mounting/RCTMountingManager.mm?lines=176) when the first surface is mounted.*

## Changelog
[iOS][Added] - Allow the activityIndicator to be controlled from JS in bridgeless mode

Reviewed By: philIip

Differential Revision: D54191856

fbshipit-source-id: 14738032f04adf7eaf7d200d889acd752aed0ed3
2024-03-05 09:37:26 -08:00
Oskar Kwaśniewski 1387725aab fix: add compiler conditional to hover style (#43331)
Summary:
Commit https://github.com/facebook/react-native/commit/73664f576aaa472d5c8fb2a02e0ddd017bbb2ea4 broke two jobs in CircleCI that we run using Xcode 14.3.1 because the commit introduced some types that are available only to iOS 17.
The code was wrapped around if(available()) statement, but this does not compile out the code. It is a runtime check and the code needs to build anyway.

This takes effect at compile time as well. However, unlike with #available, the method must type check and compile. The code will always be emitted into your binary: however, it will only be used when the binary is executed on platforms that meet the availability requirements.

source: [forums.swift.org/t/if-vs-available-vs-if-available/40266/2](https://forums.swift.org/t/if-vs-available-vs-if-available/40266/2)

This change should fix it, introducing some compile time pragmas that removes the code if we build with older versions of Xcode

## Changelog:

[IOS] [ADDED] - Compiler conditionals for hover style (cursor: pointer)

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

Test Plan: CI Green

Reviewed By: dmytrorykun

Differential Revision: D54540520

Pulled By: cipolleschi

fbshipit-source-id: 943ac479062e11969efa7645ec0ead26c6866374
2024-03-05 07:58:47 -08:00
Marc Rousavy 8769245477 Allow ReactCommon/Folly to be used in Swift libraries (DEFINES_MODULE) (#43327)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43327

<!-- Thanks for submitting a pull request! We appreciate you spending the time to work on these changes. Please provide enough information so that others can review your pull request. The three fields below are mandatory. -->

## Summary

Swift Pods require the use of [modular headers](https://blog.cocoapods.org/CocoaPods-1.5.0/) to be statically linked. To interop with Objective-C modules, you need to make the Objective-C module "define a Module", that is modular header export.

This is already the case for a few podspecs so they can be consumed in Swift libraries, but `ReactCommon` and `RCT-Folly` don't do this yet and therefore this breaks in a few libraries of mine, for example see this issue: https://github.com/mrousavy/react-native-vision-camera/issues/195.

If I were to include `ReactCommon` or `RCT-Folly` in my Swift library's podspec, the following error arises:

```
[!] The following Swift pods cannot yet be integrated as static libraries:

The Swift pod `VisionCamera` depends upon `RCT-Folly`, 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.
```

So this PR fixes this issue by allowing Swift libraries to consume the `ReactCommon` and `RCT-Folly` podspecs since they now export modular headers.

## Changelog

<!-- Help reviewers and the release process by writing your own changelog entry. For an example, see:
https://github.com/facebook/react-native/wiki/Changelog
-->

[General] [Fixed] - Expose Modular Headers for `ReactCommon` podspec
[General] [Fixed] - Expose Modular Headers for `RCT-Folly` podspec

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

Test Plan: * Add s.dependency "ReactCommon" or RCT-Folly to a Swift pod and see what happens. (See https://github.com/mrousavy/react-native-vision-camera/pull/273)

Reviewed By: dmytrorykun

Differential Revision: D54539127

Pulled By: cipolleschi

fbshipit-source-id: 2291cc0c8d6675521b220b02ef0c3c6a3e73be38
2024-03-05 07:31:22 -08:00
Blake Friedman cdb2ff9cfe chore: bump @react-native/core-cli-utils @ 0.75.0-main
Summary:
Bump the version to match RN.

Changelog: [Internal]

Reviewed By: huntie

Differential Revision: D54538812

fbshipit-source-id: a2e8225ea02fb1e7a69b3b20436c821a857ca1e2
2024-03-05 07:11:51 -08:00
Moti Zilberman 1df3812933 Document extended RuntimeTargetDelegate lifetime requirements
Summary:
Changelog: [Internal]

NOTE: This is a documentation-only diff.

Documents that the caller of `InstanceTarget::registerRuntime()` is required to keep the `RuntimeTargetDelegate&` valid longer than previously stated. Rather than merely outliving the `RuntimeTarget` object ( = past `unregisterRuntime()`), the delegate must also remain valid while any JS is being executed in the underlying runtime.

Proof that this requirement is already met by the existing integrations:
* In Bridgeless, `RuntimeTargetDelegate` is implemented by [`JSRuntime`](https://github.com/facebook/react-native/blob/9f85a249fa9e18eae745f103e390b2a8542e8ee9/packages/react-native/ReactCommon/react/runtime/JSRuntimeFactory.h#L20). JS execution via the `RuntimeExecutor` happens [here](https://github.com/facebook/react-native/blob/9f85a249fa9e18eae745f103e390b2a8542e8ee9/packages/react-native/ReactCommon/react/runtime/ReactInstance.cpp#L70), while a [strong reference to the `JSRuntime`](https://github.com/facebook/react-native/blob/9f85a249fa9e18eae745f103e390b2a8542e8ee9/packages/react-native/ReactCommon/react/runtime/ReactInstance.cpp#L66) is in scope.
* In Bridge, `RuntimeTargetDelegate` is implemented by [`JSExecutor`](https://github.com/facebook/react-native/blob/9f85a249fa9e18eae745f103e390b2a8542e8ee9/packages/react-native/ReactCommon/cxxreact/JSExecutor.h#L58). JS execution via the `RuntimeExecutor` happens [here](https://github.com/facebook/react-native/blob/9f85a249fa9e18eae745f103e390b2a8542e8ee9/packages/react-native/ReactCommon/cxxreact/Instance.cpp#L253), while a (necessarily valid) non-owning [pointer to the `JSExecutor`](https://github.com/facebook/react-native/blob/9f85a249fa9e18eae745f103e390b2a8542e8ee9/packages/react-native/ReactCommon/cxxreact/Instance.cpp#L247) is in scope.

bypass-github-export-checks

Reviewed By: huntie

Differential Revision: D54493456

fbshipit-source-id: c8dc11b0696e20b5fe9f3e16bb7591be0b3b6157
2024-03-05 06:32:45 -08:00
Alex Hunt 42cab1488c Fix E2E template install in CI jobs (#43323)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43323

This fixes a seemingly pre-existent misconfiguration within our `test_ios_template` E2E test setup in CircleCI.

**Background**

We call `npx react-native-community/cli init` with the `--skip-install` flag, as part of the bootstrapping logic in `scripts/e2e/init-template-e2e.js`. This is necessary because we later want to explicitly call `npm install` with a custom `--registry` for our locally mirrored packages (via Verdaccio).

For some reason, we were observing unexpected differences when this was run under CircleCI:

1. Runs `yarn init`
2. Runs a `yarn add` (unknown pkg)

 {F1464781818}

https://app.circleci.com/pipelines/github/facebook/react-native/42725/workflows/f648468b-e916-4501-887d-ad293aa6fccf/jobs/1398950

This is causing a Yarn-based install ahead of where we want — ignoring the `--skip-install` flag.

*I'm still unsure on the exact LOC cause in CLI* (but most likely, it's around the Yarn v3 move).

**Impact of this fix**

- The above meant that, when we were bootstrapping `test_ios_template` previously, packages weren't being read from Verdaccio, but **instead from npm** — using the `"0.74.0"` versions from the *previous branch cut* .
- After D54006327, this behaviour became breaking 💀 — since for the 0.74 -> 0.75 cut, we no longer physically published `"0.75.0-main"` (new format) packages to npm.

**This change**

I'm passing `--pm npm` to `npx react-native-community/cli init` to skip around any Yarn behaviour. This appears to have removed the erroneous `yarn` invocations .

Changelog: [Internal]

bypass-github-export-checks

Reviewed By: cortinico, cipolleschi

Differential Revision: D54536848

fbshipit-source-id: 473b11924955f5787c82a6c81d4527d77b810aa5
2024-03-05 06:18:37 -08:00
Rubén Norte 3222805b4f Simplify logic in queueMicrotask (#43324)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43324

Changelog: [internal]

Reviewed By: sammy-SC

Differential Revision: D54537050

fbshipit-source-id: b7400fd5f39817e6cdcd791beea192919d79b3b0
2024-03-05 06:02:38 -08:00
Rubén Norte 74595907a2 Add JSI test for queueMicrotask and drainMicrotasks (#43309)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43309

Changelog: [internal]

X-link: https://github.com/facebook/hermes/pull/1336

Add JSI test verifying the behavior of `queueMicrotask` and `drainMicrotasks` in the runtimes that support them.

Reviewed By: neildhar

Differential Revision: D54484771

fbshipit-source-id: e8c0c8e05215d59a0a8c86161452642c41bcdbd7
2024-03-05 04:10:44 -08:00
Rubén Norte 244fe286a0 Make queueMicrotask pure virtual (#43311)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43311

X-link: https://github.com/facebook/hermes/pull/1337

Changelog: [internal]

We've done this in a separate diff because the changes in Hermes don't propagate immediately to the React Native repository. We need to land the changes in JSI and Hermes first (in a backwards-compatible way) and then land this in a separate commit to make the method mandatory.

Reviewed By: neildhar

Differential Revision: D54413830

fbshipit-source-id: 3b89fe0e6697b0019544b73daa89d932db97b63a
2024-03-05 04:10:44 -08:00
Cedric van Putten f3ce7cd76e feature(dev-middleware): add inspector proxy nativeNetworkInspection target capabilty flag (#43310)
Summary:
This adds the `nativeNetworkInspection` target capability flag, to enable/disable the proxy-side network inspection handling.

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

[GENERAL][ADDED] Add inspector proxy `nativeNetworkInspection` target capability flag

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

Test Plan:
Once this lands, and is published through `react-native/dev-middleware`, we (Expo) can disable the proxy-side network inspection handling.

See https://github.com/expo/expo/pull/27425/commits/1a1b601a29fbc5766628238db7259121689f6cd6 on PR expo/expo#27425

Reviewed By: christophpurrer, motiz88

Differential Revision: D54486516

Pulled By: huntie

fbshipit-source-id: cc151349c816fb3866d3ec07af1a29a5f4ff9b00
2024-03-05 04:03:30 -08:00
D N f043c832d1 chore: [Github Actions] Update actions/stale to the latest version (#43312)
Summary:
- Node.js 16 actions are deprecated. Please update the following actions to use Node.js 20: actions/stale@v5. For more information see: https://github.blog/changelog/2023-09-22-github-actions-transitioning-from-node-16-to-node-20/.
  - from last run: https://github.com/facebook/react-native/actions/runs/8136278191

## Changelog:

[INTERNAL] [CHANGED] - [Github Actions] Update actions/stale to the latest version

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

Test Plan: Run workflow once

Reviewed By: cortinico

Differential Revision: D54506678

Pulled By: arushikesarwani94

fbshipit-source-id: 530ed1f0ff5571ee124bc78bac11c6584a9af60c
2024-03-05 03:43:32 -08:00
Luna Wei bd6550192d Changelog for 0.74.0-rc.2 (#43315)
Summary:
Changelog: [Internal] - Changelog for 0.74.0-rc.2

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

Reviewed By: christophpurrer

Differential Revision: D54511031

Pulled By: lunaleaps

fbshipit-source-id: d82144b1f828462ee483ffdcbb8d1c0d1d83ee50
2024-03-04 21:52:16 -08:00
Ryan Linton 0dc5c5f1f4 Update bridge to handle long values (#43158)
Summary:
This adds support for 64 bit integer (long) values to the Android bridge. Per the wide gamut color [RFC](https://github.com/react-native-community/discussions-and-proposals/pull/738) Android encodes wide gamut colors as long values so we need to update the bridge to support 64 bit integers as well since these classes will soon receive those values from native.

## Changelog:

[ANDROID] [ADDED] - Update bridge to handle long values

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

Test Plan: I added tests where I could for long types and truncation. I would like to add tests for ReadableNativeArray and ReadableNativeMap but I'm not sure how to go about mocking HybridData.

Reviewed By: cipolleschi

Differential Revision: D54276496

Pulled By: NickGerleman

fbshipit-source-id: 1e71b5283f662748beef1bdb34d9c86099baecb0
2024-03-04 19:07:53 -08:00
Saad Najmi 73664f576a feat(iOS): Implement cursor style prop (#43078)
Summary:
Implement the cursor style prop for iOS (and consequently, visionOS), as described in this RFC: https://github.com/react-native-community/discussions-and-proposals/pull/750

See related PR in React Native macOS, where we target macOS and visionOS (not running in iPad compatibility mode) with the same change: https://github.com/microsoft/react-native-macos/pull/2080

Docs update: https://github.com/facebook/react-native-website/pull/4033

## Changelog:

[IOS] [ADDED] - Implement cursor style prop

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

Test Plan:
See the added example page, running on iOS with the new architecture enabled. This also runs the same on the old architecture.

https://github.com/facebook/react-native/assets/6722175/2af60a0c-1c1f-45c4-8d66-a20f6d5815df

See the example page running on all three apple platforms. The JS is slightly different because:
1. The "macOS Cursors" example is not part of this PR but the one in React Native macOS.
2. This PR (and exapmple) has went though a bunch of iterations and It got hard taking videos of every change 😅

https://github.com/facebook/react-native/assets/6722175/7775ba7c-8624-4873-a735-7665b94b7233

## Notes

- React Native macOS added the cursor prop to View with https://github.com/microsoft/react-native-macos/pull/760 and Text with https://github.com/microsoft/react-native-macos/pull/1469 . Much of the implementation comes from there.

- Due to an Apple bug, as of iOS 17.4 Beta 4, the shape of the iOS cursor hover effect doesn't render in the correct bounds (but it does on visionOS). I've worked around it with an ifdef. The result is that the hover effect will work on iOS and visionOS, but not iPad apps running in compatibility mode on visionOS.

Reviewed By: NickGerleman

Differential Revision: D54512945

Pulled By: vincentriemer

fbshipit-source-id: 699e3a01a901f55a466a2c1a19f667aede5aab80
2024-03-04 18:51:17 -08:00
Sam Zhou 923d4abd7b Update hermes-parser and related packages in fbsource to 0.20.1 (#43317)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43317

Bump hermes-parser and related packages to [0.20.1](https://github.com/facebook/hermes/blob/main/tools/hermes-parser/js/CHANGELOG.md).

Changelog: [internal]

Reviewed By: pieterv

Differential Revision: D54510131

fbshipit-source-id: 064d2078e85e465552dccf5c1368e49707c3aeef
2024-03-04 17:10:51 -08:00
D N 09c903c439 fix: [TypeScript] Remove non-existent methods from <ImageBackground/> (#43290)
Summary:
Using the code from `Test Plan` you will see that `ImageBackground` component doesn't have methods that declared on TypeScript side.

I checked the source code and there is also nothing:

https://github.com/facebook/react-native/blob/d9b0f15c844abce5e97edfd401656d84d0c84133/packages/react-native/Libraries/Image/ImageBackground.js#L47-L69

```tsx
// runtime (React Native 0.73)
 {
  "abortPrefetch": undefined,
  "getSize": undefined,
  "prefetch": undefined,
  "queryCache": undefined,
  "resizeMode": undefined
}
```

## Changelog:

[GENERAL] [REMOVED] - Remove non-existent methods from `<ImageBackground/>` component

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

Test Plan:
```tsx
      <ImageBackground
        resizeMode={'contain'}
        ref={ref => {
          if (ref) {
            console.log(' --- xdebug', {
              resizeMode: ref.resizeMode,
              queryCache: ref.queryCache,
              getSize: ref.getSize,
              prefetch: ref.prefetch,
              abortPrefetch: ref.abortPrefetch,
            });
          }
        }}
        style={{
          width: '100%',
          height: '100%',
        }}
        source={{
          uri: 'https://upload.wikimedia.org/wikipedia/commons/8/87/Arturo_Nieto-Dorantes.webp',
        }}
      />
```

Reviewed By: cipolleschi

Differential Revision: D54466918

Pulled By: NickGerleman

fbshipit-source-id: 39bb555954fd6146f0e99106dbe9c13353191081
2024-03-04 14:26:51 -08:00
Oskar Kwaśniewski ec928d7a66 feat(RCTAppDelegate): Implement RCTRootViewFactory (#42263)
Summary:
This PR implements `RCTRootViewFactory` a utility class (suggested by cipolleschi) that returns proper RCTRootView based on the current environment state (new arch/old arch/bridgeless). This class aims to preserve background compatibility by implementing a configuration class forwarding necessary class to RCTAppDelegate.

### Brownfield use case

This PR leverages the `RCTRootViewFactory` in `RCTAppDelegate` for the default initialization of React Native (greenfield).

Here is an example of creating a Brownfield integration (without RCTAppDelegate) using this class (can be later added to docs):

1. Store reference to `rootViewFactory` and to `UIWindow`

`AppDelegate.h`:
```objc
interface AppDelegate : UIResponder <UIApplicationDelegate>

property(nonatomic, strong) UIWindow* window;
property(nonatomic, strong) RCTRootViewFactory* rootViewFactory;

end
```

2. Create an initial configuration using `RCTRootViewFactoryConfiguration` and initialize `RCTRootViewFactory` using it. Then you can use the factory to create a new `RCTRootView` without worrying about old arch/new arch/bridgeless.

 `AppDelegate.mm`
```objc
implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary<UIApplicationLaunchOptionsKey,id> *)launchOptions {

  // Create configuration
 RCTRootViewFactoryConfiguration *configuration = [[RCTRootViewFactoryConfiguration alloc] initWithBundleURL:self.bundleURL
                                                                                                 newArchEnabled:self.fabricEnabled
                                                                                             turboModuleEnabled:self.turboModuleEnabled
                                                                                              bridgelessEnabled:self.bridgelessEnabled];

  // Initialize RCTRootViewFactory
  self.rootViewFactory = [[RCTRootViewFactory alloc] initWithConfiguration:configuration];

  // Create main root view
  UIView *rootView = [self.rootViewFactory viewWithModuleName:@"RNTesterApp" initialProperties:@{} launchOptions:launchOptions];

  // Set main window as you prefer for your Brownfield integration.
  self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
  UIViewController *rootViewController = [UIViewController new];
  rootViewController.view = rootView;
  self.window.rootViewController = rootViewController;
  [self.window makeKeyAndVisible];

  // Later in the codebase you can initialize more rootView's using rootViewFactory.

  return YES;
}
end
```
bypass-github-export-checks

## Changelog:

[INTERNAL] [ADDED] - Implement RCTRootViewFactory

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

Test Plan: Check if root view is properly created on app initialization

Reviewed By: dmytrorykun

Differential Revision: D53179625

Pulled By: cipolleschi

fbshipit-source-id: 9bc850965ba30d84ad3e67d91dd888f0547c2136
2024-03-04 10:14:44 -08:00
Luna Wei 9f85a249fa Link to releases repo for upgrade issues (#43295)
Summary:
Changelog: [Internal]

We're moving upgrade issues to https://github.com/reactwg/react-native-releases/issues/new/choose

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

Reviewed By: cortinico, cipolleschi

Differential Revision: D54442540

Pulled By: lunaleaps

fbshipit-source-id: a079935a290f56d2932c5fc588e96a68e1c13f9a
2024-03-04 08:55:00 -08:00
Samuel Susla 881942a958 avoid merging unrelated props into ShadowNodeFamily::nativeProps (#43305)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43305

changelog: [internal]

Originally when I built setNativeProps, I assumed a node is either controlled by handled directly or it is controlled by React. But we can't make sure that's the case, users can do both and control one prop with setNativeProps and the others with React. Additionally, Suspense uses display: none to hide a subtree.

Therefore, React controlled props must not be copied into `ShadowNodeFamily::nativeProps_DEPRECATED`

Reviewed By: javache

Differential Revision: D54453820

fbshipit-source-id: 5b4038f0dd366621d26a92f668d33f27ce60f4b4
2024-03-04 08:27:46 -08:00
Alex Hunt f57be12977 Bump packages for next major release (#43132)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43132

Command run:

```
node scripts/releases/set-version 0.75.0-main --skip-react-native-version
```

Changelog: [Internal]

Reviewed By: lunaleaps, cipolleschi

Differential Revision: D54006327

fbshipit-source-id: 7afe9e7ca3020faf399fdba2221fab8a102c56c7
2024-03-04 07:54:37 -08:00
Rubén Norte dc254acace Use new JSI method to queue microtasks in RuntimeSchedulerTest
Summary:
Changelog: [internal]

Now that `jsi::Runtime::queueMicrotask` is available, we can use it instead of calling an internal Hermes API in `RuntimeSchedulerTest`.

Reviewed By: christophpurrer

Differential Revision: D54416245

fbshipit-source-id: c9cbd3783d9dc1c3df499a7fec7acb6c229ec571
2024-03-04 05:03:39 -08:00
Rubén Norte bd89afa284 Implement queueMicrotask and drainMicrotasks in JSC
Summary:
Changelog: [internal]

## Context

We want to enable the new React Native event loop by default for all users on the new RN architecture (on the bridgeless initialization path more concretely), which requires support for microtasks in all the JS engines that the support (Hermes already has it, JSC doesn't).

## Changes

This adds initial support for microtasks in JSC, so we can schedule and execute microtasks in this runtime.

One limitation about this approach is that, AFAIK, the public API for JSC doesn't allow us to customize its internal microtask queue or specify the method to be used by its built-in `Promise` or native `async function`, so we're forced to continue using a polyfill in that case (which uses `setImmediate` that will be mapped to `queueMicrotask`).

Reviewed By: NickGerleman

Differential Revision: D54302534

fbshipit-source-id: 47f71620344a81bc6624917f77452106ffbf55a3
2024-03-04 05:03:39 -08:00
Rubén Norte 036f47ebc4 Add queueMicrotask method to JSI
Summary:
Changelog: [internal]

## Context

Microtasks are an important aspect of JavaScript and they will become increasingly important in the hosts where we're currently using JSI.

For example, React Native is going to adopt an event loop processing model similar to the one on the Web, which means it would need the ability to schedule and execute microtasks in every iteration of the loop. See https://github.com/react-native-community/discussions-and-proposals/pull/744 for details.

JSI already has a method to execute all pending microtasks (`drainMicrotasks`) but without a method to schedule microtasks this is incomplete.

We're currently testing microtasks with Hermes using an internal method to schedule microtasks (`HermesInternal.enqueueJob`) but we need a method in JSI so this also works in other runtimes like JSC and V8.

## Changes

This adds the `queueMicrotask` to the Runtime API in JSI so we have symmetric API for microtasks and we can implement the necessary functionality.

The expectation for JSI implementations is to queue microtasks from this method and from built-ins like Promises and async functions in the same queue, and not drain that queue until explicitly done via `drainMicrotasks` in JSI.

This also modifies Hermes and JSC to provide stubs for those methods, and the actual implementation will be done in following diffs.

Reviewed By: neildhar

Differential Revision: D54302536

fbshipit-source-id: 25f52f91d7ef1a51687c431d2c7562c373dc72a5
2024-03-04 05:03:39 -08:00
Blake Friedman 58b45e86a6 Remove RFC-0759 ram-bundle command from cli (#43292)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43292

The ram-bundle command isn't necessary now that Hermes is our default VM.  The RFC specifically calls for the CLI command to be removed [1].

[1] https://github.com/react-native-community/discussions-and-proposals/blob/main/proposals/0759-react-native-frameworks.md#commands-to-be-removed

Changelog:
[General][Removed] - RFC-0759 remove ram-bundle command.

Reviewed By: NickGerleman, cipolleschi

Differential Revision: D54430289

fbshipit-source-id: 49d519c007b739f89ffe9032fec905c56ea49f4a
2024-03-04 04:47:34 -08:00
Blake Friedman 6461dcd07b Port: @react-native-community/cli#clean → @react-native/core-cli-utils#clean (#43287)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43287

Move react-native-community/cli clean into core per RFC-0759.  Provides:

- android
- metro
- npm
- bun
- watchman
- yarn
- cocoapods

These tasks are used to clear up caching artefacts in React Native projects.  This is going to be called by the `react-native-community/cli` once we publish these in an npm package.

Changelog:
[General][Added] RFC-0759 Move cli clean into core

Reviewed By: cipolleschi

Differential Revision: D53997878

fbshipit-source-id: 56907be714184abecc8e3ef677ffc83e9ee7b54d
2024-03-04 04:41:41 -08:00
Pieter De Baets 5f45700bd0 Fix NullPointerException thrown on startup (#43293)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43293

Was debugging this, and found that this exception was being thrown due to `DefaultBindingsInstaller`, which was an invalid hybrid object. The ReactInstance initializer fully supports this being null, so let's use that as default.

Changelog: [Android][Fixed] NullPointerException is no longer ignored in MessageQueueThreadHandler

Reviewed By: sammy-SC

Differential Revision: D54434417

fbshipit-source-id: 52417b390061eface0f0578e32796d3a85303e03
2024-03-04 04:26:36 -08:00
Tomek Zawadzki adc9e5b0fa Expose rrc_textinput via prefab (#43274)
Summary:
The `rrc_textinput` was not exposed via prefab. I'm adding it to make possible for react-native-live-markdown to integrate on top of React Native via prefab. Based on https://github.com/facebook/react-native/issues/36166.

## Changelog:

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

Pick one each for the category and type tags:

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

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

[ANDROID] [CHANGED] - Expose `rrc_textinput` via prefab.

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

Reviewed By: cipolleschi

Differential Revision: D54482657

Pulled By: cortinico

fbshipit-source-id: ca7f4127f1808f841d88925238666e837de75bd0
2024-03-04 04:23:20 -08:00
Pieter De Baets 43c55e98d4 Allow moving SyncCallback (#43268)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43268

We previously restricted all copies and moves of SyncCallback, but that led to unsafe calling paths being added instead to AsyncCallback. Instead, allowing moving of SyncCallback, and document the need for the caller to invoke it safely, so can we remove the unsafe path from AsyncCallback.

Changelog: [General][Changed] Allow moving SyncCallback for advanced use-cases

Reviewed By: christophpurrer

Differential Revision: D54381734

fbshipit-source-id: 5fd797cd4541e507aa68f1e4e76a1be5cae20fbe
2024-03-04 04:11:36 -08:00
Pieter De Baets 24e6722cb4 Add TODOs for missing ReactActivityDelegate methods (#43294)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43294

These are gated by `ReactFeatureFlags.enableBridgelessArchitecture` and are missing support. They should be evaluated for backwards compatibility

Changelog: [Internal]

Reviewed By: fkgozali

Differential Revision: D54422143

fbshipit-source-id: b35b60f17d68d412a354b20e02fb6bbf591c40b0
2024-03-04 03:53:42 -08:00
Alex Hunt 6cacc6d5df Relocate and export updatePackageJson script util
Summary: Changelog: [Internal]

Reviewed By: lunaleaps

Differential Revision: D54423651

fbshipit-source-id: e6705b055bf1f1d70d86d2c6978b837bd0807081
2024-03-04 02:54:44 -08:00
Alex Hunt b919ff606a Update set-version script to version private packages and workspace deps
Summary:
Addresses a gap when using the `set-version` script to update all packages on `main` (i.e. post branch cut):
- Package versions were not being set consistently. It is safe to version all workspace packages, including `"private"`.
    - Our publishing workflow is independent from this, and only considers public packages for submission to npm.
- We also need to update the root `package.json`, which includes `devDependencies` referencing workspace dependencies.

Unblocks https://github.com/facebook/react-native/pull/43132.

Changelog: [Internal]

Reviewed By: lunaleaps

Differential Revision: D54419456

fbshipit-source-id: 93eee669c5cf7c2f16b68a2bf41e9a8ace5521bf
2024-03-04 02:54:44 -08:00
Alex Hunt 79d1706b50 Omit source/build file snapshots from set-version script tests
Summary:
Make the snapshot output of this test terser (since `set-version` is a superset of the fully tested `set-rn-version` script). Notably, this removes any instances of `generated` from the snapshot file, which would hide the diff in PRs.

Changelog: [Internal]

Reviewed By: lunaleaps

Differential Revision: D54420338

fbshipit-source-id: e4a94b1fda34efaedf1b309496954be35acd5f98
2024-03-04 02:54:44 -08:00
Nick Gerleman 9ce360be7e Enable Clang Tidy (#43299)
Summary:
X-link: https://github.com/facebook/litho/pull/976

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

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

Add the React Clang Tidy config to Yoga, run the auto fixes, and make some manual mechanical tweaks.

Notably, the automatic changes to the infra for generating a Yoga tree from JSON capture make it 70% faster.

Before:
{F1463947076}

After:
{F1463946802}

This also cleans up all the no-op shallow const parameters in headers.

{F1463943386}

Not all checks are available in all environments, but that is okay, as Clang Tidy will gracefully skip them.

Changelog: [Internal]

Reviewed By: sammy-SC

Differential Revision: D54461054

fbshipit-source-id: dbd2d9ce51afd3174d1f2c6d439fa7d08baff46f
2024-03-04 02:28:02 -08:00
Samuel Susla f5c8bc1e8e delete timeline module (#43301)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43301

changelog: [internal]

unused, let's delete it.

Reviewed By: fabriziocucci

Differential Revision: D54462220

fbshipit-source-id: 7a3f737b8359ccf438738e0473f3846be7df47f5
2024-03-04 01:38:26 -08:00
David Vacca 1d8dea54b6 Mark classes of package uimanager as @Nullsafe
Summary:
All these classes are NullSafe, let's mark them as NullSafe(Local) to ensure lint detect errors in the future

bypass-github-export-checks

changelog: [internal] internal

Reviewed By: javache

Differential Revision: D54027179

fbshipit-source-id: 4840becb8374ddbf8091be1e5e593289d18c78e0
2024-03-03 17:38:19 -08:00
Arushi Kesarwani 7d47781046 Fix CI by adding explicit visibility modifier to BridgelessCatalystInstance (#43296)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43296

Fix CI by adding explicit visibility modifier to the newly added `BridgelessCatalystInstance` class. In Kotlin, in explicit API mode, which is usually the default mode for Kotlin, we must explicitly specify one of the modifiers for every declaration to make it clear and explicit.

Changelog:
[Internal] internal

Reviewed By: makovkastar

Differential Revision: D54442485

fbshipit-source-id: 4409ff810a09cc4fadcd2ccf21f7fbac3015f413
2024-03-01 18:13:28 -08:00
Nick Gerleman 9c0edaec92 Clang Tidy in more places, running more checks
Summary:
Inspired by some new C++ code in `RKJSModules` where Clang Tidy  could have caught some C++ quirks and shown them in Phabricator, this enables Fabric's Clang Tidy checks in more places, and enables more checks.

1. Hoist the renderer `.clang-tidy` to `xplat/js`, and duplicate to `xplat/ReactNative`
2. Remove all the scattered `.clang-tidy` files in RN which are less aggressive
3. Sort the list of checks
4. Add the following new checks:
    1. `bugprone-incorrect-enable-if`
    1. `bugprone-infinite-loop`
    1. `bugprone-optional-value-conversion`
    1. `bugprone-redundant-branch-condition`
    1. `bugprone-shared-ptr-array-mismatch`
    1. `bugprone-signed-char-misuse`
    1. `bugprone-too-small-loop-variable`
    1. `bugprone-unique-ptr-array-mismatch`
    1. `bugprone-unsafe-functions`
    1. `bugprone-unused-raii`
    1. `cppcoreguidelines-avoid-const-or-ref-data-members`
    1. `cppcoreguidelines-avoid-non-const-global-variables`
    1. `cppcoreguidelines-init-variables`
    1. `cppcoreguidelines-interfaces-global-init`
    1. `cppcoreguidelines-missing-std-forward`
    1. `cppcoreguidelines-prefer-member-initializer`
    1. `facebook-hte-BadEnum`
    1. `facebook-hte-MissingStatic`
    1. `misc-header-include-cycle`
    1. `misc-misplaced-const`
    1. `modernize-use-constraints`
    1. `modernize-use-designated-initializers`
    1. `modernize-use-starts-ends-with`

I did not auto apply fixes, since even the existing set can sometimes (rarely) generate invalid code.

Changelog: [Internal]

Reviewed By: ksheedlo

Differential Revision: D54411398

fbshipit-source-id: 4958d880969ae07a03fa4f62ba68ee44790487ca
2024-03-01 15:21:48 -08:00
Rick Hanlon 1b53051b8c Support component stacks without debug source in LogBox (#43165)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43165

Fixes component stacks without source info, and duplication in the error message string.

## Before
No component stacks, and error message duplication:

 {F1459400803}

## After
Back to normal, albeit without the component source location:

 {F1459401148}

Changelog:
[General][Fixed] - Support component stacks without source info.

Reviewed By: yungsters

Differential Revision: D53981672

fbshipit-source-id: c83455673ce327ed1a4c6cfeb3247e97da9b6a2e
2024-03-01 13:48:25 -08:00
Thomas Nardone 30463fb007 Trim invalid response blob msg
Summary:
Small tweak to #43069 - trim the message to avoid ending with a newline.

Changelog:
[General][Changed] - Trim invalid blob response error message

Reviewed By: christophpurrer

Differential Revision: D54422284

fbshipit-source-id: 53a4e963f8aba36c55e16ad7539b2f2d98c781f8
2024-03-01 13:32:15 -08:00
jayshah d9b0f15c84 fix(iOS): add extended check for content typeapplication/javascript (#43262)
Summary:
When used with expo, JS code content type is `application/javascript; charset=UTF-8` instead of just `application/javascript`, We have a really large bundle and the application shows stuck at "Bundling 100%" and does not show "Downloading 1..100%".

Here we improve the check for the content type to correctly show the progress.

## Changelog:

[IOS] [FIXED] - Fixed headers content type check for iOS bundle download

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

Pick one each for the category and type tags:
For more details, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests

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

Reviewed By: huntie

Differential Revision: D54412657

Pulled By: robhogan

fbshipit-source-id: f12e260f1bda36495eb5e6ecd0f66c86f26d4747
2024-03-01 04:59:32 -08:00
Samuel Susla 571ef5660a introduce experimental props to ScrollView - JS part (#43265)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/43265

changelog: [internal]

Add experimental props to control scroll speed on iOS.

Reviewed By: rubennorte

Differential Revision: D53757138

fbshipit-source-id: e4d9787240ad421d3e4a1d50c860d7bcb26f43b5
2024-03-01 04:11:40 -08:00
Pieter De Baets d6a44e632a getChildAtWithSubviewClippingEnabled should be @Nullable
Summary:
The RemoveDeleteTree operation assumes it can safely call getChildAt with indices that are out of bounds to find all the children. `getChildAtWithSubviewClippingEnabled` was unnecessarily stricter than `getChildAt` and would crash in such cases.

Changelog: [Android][Fixed] - Fix crash in `getChildAtWithSubviewClippingEnabled`

Reviewed By: NickGerleman

Differential Revision: D54380975

fbshipit-source-id: 17e93c685cd07b02dc20efa2fae89090d6e38457
2024-03-01 03:59:08 -08:00
Dmitry Rykun 4d2262b8d2 Add scrollEventThrottle to validAttributes to ScrollView view config on Android
Summary:
The `scrollEventThrottle` prop is missing in the ViewConfig for ScrollView for the Android platform. Because of that it was ignored by native in the New Architecture.
This diff fixes that.

Changelog: [Android][Fixed] - Add support for scrollEventThrottle for ScrollView on the New Architecture.

Reviewed By: fkgozali

Differential Revision: D54303157

fbshipit-source-id: 824f32c2f9fb3958271b094bbfc770992a4335e1
2024-03-01 03:12:08 -08:00
Moti Zilberman 4cfac8eea6 Restore Content-Length header in inspector-proxy JSON responses
Summary:
Changelog: [General][Fixed] Re-enable listing Hermes debugger targets in chrome://inspect, broken in 0.74 RC

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

Reverts D52958725 and fixes the original `Content-Length` Unicode bug using a different approach.

Reviewed By: fabriziocucci

Differential Revision: D54409847

fbshipit-source-id: ed5bb464ab67f37535947646b124814d8bbf797c
2024-03-01 02:38:48 -08:00
Arushi Kesarwani 64b0c9cba4 Add BridgelessCatalystInstance as a placeholder for backwards comptability of legacy APIs of CatalystInstance
Summary:
In order to make the legacy APIs of Catalyst Instance backwards compatible, introducing a regular class that implements CatalystInstance so as to make these APIs available for folks in Bridgeless mode as well.

Changelog:
[Internal] internal

Reviewed By: RSNara

Differential Revision: D54093013

fbshipit-source-id: f494c05e79f570883f9b5374cd177862970304c0
2024-02-29 15:46:43 -08:00
Sam Zhou 2053364e5a Update hermes-parser and related packages in fbsource to 0.20.0
Summary:
Bump hermes-parser and related packages to [0.20.0](https://github.com/facebook/hermes/blob/main/tools/hermes-parser/js/CHANGELOG.md).

Changelog: [internal]

Reviewed By: alexmckenley

Differential Revision: D54368487

fbshipit-source-id: a5a05f1e499ff5d8bda4649433bd285f7215d3da
2024-02-29 14:19:29 -08:00